1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,201795,e=>{"use strict";e.s(["LayoutClient",()=>t1,"useTaskSidebar",()=>t0],201795);var t=e.i(843476);e.i(593843);var a=e.i(43605),r=e.i(317751),s=e.i(912598),i=e.i(271645),n=e.i(466337),l=e.i(235580),o=e.i(926436),d=e.i(703467),c=e.i(685343),m=e.i(899142),u=e.i(939692),h=e.i(75138),x=e.i(953197),g=e.i(994310),p=e.i(567847),b=e.i(922927),f=e.i(232676),y=e.i(562710),w=e.i(796780),v=e.i(133820),k=e.i(663420),j=e.i(120697),N=e.i(956846),C=e.i(202793),S=e.i(808548),E=e.i(228142),I=e.i(246780),T=e.i(768834),_=e.i(618566),A=e.i(126502),D=e.i(199609),P=e.i(169284),R=e.i(199778),M=e.i(963697),F=e.i(908263),L=e.i(32095),$=e.i(217255),O=e.i(173922),U=e.i(560491),B=e.i(65921),q=e.i(79222);e.i(932543);var z=e.i(621971),H=e.i(58765),V=e.i(542843),G=e.i(848968),W=e.i(503002),K=e.i(191741),Y=e.i(531278),J=e.i(373375),Q=e.i(463059),X=e.i(283086),Z=e.i(643531),ee=e.i(968553),et=e.i(37727),ea=e.i(347548),er=e.i(952571),es=e.i(595468),ei=e.i(719708),en=e.i(114724),el=e.i(810980),eo=e.i(356909),ed=e.i(788699),ec=e.i(248256),em=e.i(531245),eu=e.i(816933),eh=e.i(75998),ex=e.i(342920),eg=e.i(555436),ep=e.i(657688);function eb({selectedListings:e=[],selectedGroups:a=[],onListingsChange:r,onGroupsChange:s}){let[n,l]=(0,i.useState)(""),{listings:o,isLoadingListings:d}=(0,v.useCustomer)(),c=(0,i.useMemo)(()=>n.trim()?o.filter(e=>e.listings.some(e=>e.name.toLowerCase().includes(n.toLowerCase()))).map(e=>({...e,listings:e.listings.filter(e=>e.name.toLowerCase().includes(n.toLowerCase()))})):o,[o,n]),m=0===e.length;return(0,t.jsxs)(eu.Popover,{children:[(0,t.jsx)(eu.PopoverTrigger,{asChild:!0,children:(0,t.jsx)("button",{type:"button",className:(0,F.cn)("flex items-center gap-1 h-[26px] px-2 rounded text-xs font-medium transition-colors",m?"bg-blue-500/10 text-blue-400 hover:bg-blue-500/20":"bg-white/10 text-gray-500 dark:text-white/80 hover:bg-white/15"),children:m?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ec.Globe,{className:"h-3.5 w-3.5"}),"Global"]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ex.Building,{className:"h-3.5 w-3.5"}),e.length," listing",1!==e.length?"s":""]})})}),(0,t.jsx)(eu.PopoverContent,{className:"w-72 bg-white dark:bg-[#1D1D1F] border-gray-200 dark:border-white/[0.08] text-gray-900 dark:text-white p-3 z-[200]",align:"start",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)("h4",{className:"text-xs font-medium text-gray-400 dark:text-white/60",children:"Applies to"}),!m&&(0,t.jsx)("button",{type:"button",onClick:()=>r([]),className:"text-[10px] text-blue-400 hover:text-blue-300",children:"Clear all"})]}),m&&(0,t.jsx)("p",{className:"text-[11px] text-gray-400 dark:text-white/40",children:"Available across all properties. Select below to restrict."}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(eg.Search,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-gray-400 dark:text-white/40"}),(0,t.jsx)(eh.Input,{placeholder:"Search listings...",value:n,onChange:e=>l(e.target.value),className:"pl-8 h-8 text-xs bg-gray-50/80 dark:bg-white/[0.03] border-gray-200 dark:border-white/[0.08]"})]}),(0,t.jsx)("div",{className:"space-y-0.5 max-h-[280px] overflow-y-auto",onWheel:e=>{e.stopPropagation(),e.currentTarget.scrollTop+=e.deltaY},children:d?(0,t.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/40 text-center py-2",children:"Loading..."}):c.map(a=>(0,t.jsxs)("div",{children:[(0,t.jsxs)("button",{type:"button",onClick:()=>(t=>{let a=o.find(e=>e.id===t);if(!a)return;let s=a.listings.map(e=>Number(e.id));s.every(t=>e.includes(t))?r(e.filter(e=>!s.includes(e))):r([...new Set([...e,...s])].map(Number))})(a.id),className:"w-full flex items-center gap-2 px-1.5 py-1 rounded text-left hover:bg-white/[0.03]",children:[(0,t.jsx)("div",{className:"flex items-center justify-center w-3.5 h-3.5 border border-gray-300 dark:border-white/20 rounded",children:a.listings.every(t=>e.includes(Number(t.id)))&&(0,t.jsx)(Z.Check,{className:"w-2.5 h-2.5"})}),(0,t.jsx)("span",{className:"text-[11px] font-medium text-gray-400 dark:text-white/50",children:a.name})]}),a.listings.map((s,i)=>(0,t.jsxs)("button",{type:"button",onClick:()=>{let t=Number(s.id);r(e.includes(t)?e.filter(e=>e!==t):[...e,t])},className:"flex items-center gap-2 w-full py-1 pl-6 pr-1.5 rounded hover:bg-white/5 transition-colors",children:[(0,t.jsx)("div",{className:"flex items-center justify-center w-3.5 h-3.5 border border-gray-300 dark:border-white/20 rounded",children:e.includes(Number(s.id))&&
1(0,t.jsx)(Z.Check,{className:"w-2.5 h-2.5"})}),(0,t.jsx)("div",{className:"w-6 h-6 relative rounded overflow-hidden bg-white/5 shrink-0",children:s.thumbnailUrl?(0,t.jsx)(ep.default,{src:s.thumbnailUrl,alt:s.name,fill:!0,className:"object-cover"}):(0,t.jsx)(ex.Building,{className:"w-3.5 h-3.5 absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 text-gray-400 dark:text-white/40"})}),(0,t.jsx)("span",{className:"flex-1 text-xs text-gray-500 dark:text-white/80 text-left truncate",children:s.name})]},`${a.id}-${s.id}-${i}`))]},a.id))})]})})]})}var ef=e.i(637800);let ey=(0,ef.getClientApiBase)();function ew({listingId:e,initialArticles:a,source:r,onSaved:s,onBack:n,savedTitles:l,headerContent:o,renderArticleFooter:d,processContentBeforeSave:c,onAfterSave:m}){let{currentCustomerId:u}=(0,v.useCustomer)(),[h,x]=(0,i.useState)(a),[g,p]=(0,i.useState)(!1),[b,f]=(0,i.useState)(0),[y,w]=(0,i.useState)(null),[k,j]=(0,i.useState)(null),[N,C]=(0,i.useState)(null),[S,E]=(0,i.useState)(null),[I,T]=(0,i.useState)("public"),[_,A]=(0,i.useState)([e]),[D,P]=(0,i.useState)([]);(0,i.useEffect)(()=>{let e=h.filter(e=>e.approved);return window.dispatchEvent(new CustomEvent("video-articles:update",{detail:{articles:e.map(e=>({title:e.title,category:e.category,content:e.content}))}})),()=>{window.dispatchEvent(new CustomEvent("video-articles:update",{detail:null}))}},[h]);let R=(0,i.useCallback)((e,t)=>{x(a=>a.map((a,r)=>r===e?{...a,...t}:a))},[]),M=(0,i.useCallback)(e=>{x(t=>t.map((t,a)=>a===e?{...t,approved:!t.approved}:t))},[]),L=h.filter(e=>e.approved),$=(0,i.useCallback)(async(e,t)=>{let a=h[e];if(a&&t.trim()){j(e),C(null);try{let r=await fetch(`${ey}/kb/media/refine-article?customerId=${u}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:a.title,category:a.category,content:a.content,instruction:t})});if(!r.ok){let e=await r.json().catch(()=>({error:"Refine failed"}));throw Error(e.error||"Refine failed")}let s=await r.json();R(e,{title:s.title||a.title,content:s.content||a.content,category:s.category||a.category})}catch(e){w(e.message)}finally{j(null)}}},[h,u,R]),O=(0,i.useCallback)((e,t)=>{let a=t.innerHTML;a!==h[e]?.content&&R(e,{content:a})},[h,R]),U=(0,i.useCallback)(async()=>{if(0!==L.length){p(!0),w(null);try{let t=L.map(e=>{let t=c?c(e):e.content;return{title:e.title,category:e.category,content:t,source:r,visibility:I}}),a=await fetch(`${ey}/kb/media/save-articles?customerId=${u}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({listingId:e,articles:t,appliesTo:{listings:_,groups:D}})});if(!a.ok){let e=await a.json().catch(()=>({error:"Save failed"}));throw Error(e.error||"Save failed")}let i=await a.json();if(0===i.saved&&i.errors?.length)throw Error(`Failed to save articles: ${i.errors[0]}`);let n=i.saved||L.length;f(n),window.dispatchEvent(new CustomEvent("kb:refresh")),m?.(n),setTimeout(()=>s(),1500)}catch(e){w(e.message)}finally{p(!1)}}},[L,r,I,e,u,_,D,s,m,c]);return(0,t.jsxs)("div",{className:"space-y-5",children:[o,h.length>0&&(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(el.BookOpen,{className:"w-4 h-4 text-green-500"}),(0,t.jsxs)("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:["Draft Articles (",h.length,")"]}),(0,t.jsx)("span",{className:"text-[10px] text-gray-400 dark:text-white/30",children:"Click text to edit · toggle to include/exclude"})]}),h.map((e,a)=>(0,t.jsxs)("div",{className:(0,F.cn)("rounded-xl border overflow-hidden transition-all",e.approved?"border-green-200 dark:border-green-500/20 bg-white dark:bg-white/[0.02]":"border-gray-200 dark:border-white/[0.06] bg-gray-50 dark:bg-white/[0.01] opacity-60"),children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3",children:[(0,t.jsx)("button",{onClick:()=>M(a),className:(0,F.cn)("w-5 h-5 rounded-md flex items-center justify-center transition-colors shrink-0",e.approved?"bg-green-500 text-white":"bg-gray-200 dark:bg-white/[0.08] text-gray-400 dark:text-white/30"),children:e.approved?(0,t.jsx)(Z.Check,{className:"w-3 h-3"}):(0,t.jsx)(et.X,{className:"w-3 h-3"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[S===a?(0,t.jsx)("input",{autoFocus:!0,value:e.title,onChange:e=>R(a,{title:e.target.value}),onBlur:()=>E(null),onKeyDown:e=>"Enter"===e.key&&E(null),className:(0,F.cn)("w-full text-sm font-medium bg-transparent border-b border-primary/50 outline-none py-0.5","text-gray-900 dark:text-white")}):(0,t.jsxs)("h4",{className:"text-sm font-medium text-gray-900 dark:text-white truncate cursor-pointer hover:text-primary transition-colors group flex items-center gap-1.5",onClick:()=>E(a),children:[e.title,(0,t.jsx)(ed.Pencil,{className:"w-3 h-3 opacity-0 group-hover:opacity-50 transition-opacity"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,t.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-gray-100 dark:bg-white/[0.05] text-gray-500 dark:text-white/40",children:e.category}),l?.has(e.title.toLowerCase())&&(0,t.jsxs)("span",{className:"flex items-center gap-1 text-[10px] font-medium px-1.5 py-0.5 rounded bg-green-500/10 text-green-600 dark:text-green-400",children:[(0,t.jsx)(Z.Check,{className:"w-2.5 h-2.5"}),"Already saved"]})]})]}),e.approved&&(0,t.jsx)("div",{className:"flex items-center gap-1.5 shrink-0",children:k===a?(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-primary",children:[(0,t.jsx)(Y.Loader2,{className:"w-3.5 h-3.5 animate-spin"}),(0,t.jsx)("span",{children:"Refining..."})]}):(0,t.jsxs)("button",{onClick:()=>
1C(N?.idx===a?null:{idx:a,text:""}),className:(0,F.cn)("flex items-center gap-1 px-2 py-1 rounded-md text-[11px] font-medium transition-colors",N?.idx===a?"bg-primary/10 text-primary":"text-gray-500 dark:text-white/40 hover:text-primary hover:bg-primary/5"),children:[(0,t.jsx)(X.Sparkles,{className:"w-3 h-3"}),"Refine"]})})]}),N?.idx===a&&(0,t.jsxs)("div",{className:"px-4 pb-3 flex items-center gap-2",children:[(0,t.jsx)("input",{autoFocus:!0,value:N.text,onChange:e=>C({idx:a,text:e.target.value}),onKeyDown:e=>{"Enter"===e.key&&N.text.trim()&&$(a,N.text),"Escape"===e.key&&C(null)},placeholder:"e.g. make shorter, add recycling info, change tone...",className:(0,F.cn)("flex-1 px-3 py-1.5 text-xs rounded-lg border transition-colors","border-gray-200 dark:border-white/[0.06] bg-gray-50 dark:bg-white/[0.03]","text-gray-700 dark:text-white/70 placeholder:text-gray-400 dark:placeholder:text-white/25","focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary/30")}),(0,t.jsxs)(ei.Button,{size:"sm",onClick:()=>$(a,N.text),disabled:!N.text.trim(),className:"text-xs h-7 gap-1",children:[(0,t.jsx)(X.Sparkles,{className:"w-3 h-3"}),"Go"]})]}),e.approved&&(0,t.jsx)("div",{contentEditable:!0,suppressContentEditableWarning:!0,onBlur:e=>O(a,e.currentTarget),className:"px-4 pb-4 text-xs text-gray-600 dark:text-white/60 leading-relaxed prose prose-sm dark:prose-invert max-w-none outline-none focus:ring-1 focus:ring-primary/20 focus:rounded-lg mx-2 mb-2 px-2 py-1 [&_h3]:text-sm [&_h3]:font-semibold [&_h3]:text-gray-800 [&_h3]:dark:text-white/80 [&_h3]:mt-2 [&_h3]:mb-1 [&_ul]:pl-4 [&_li]:text-xs",dangerouslySetInnerHTML:{__html:e.content}}),e.approved&&d?.({article:e,idx:a,updateArticle:R})]},a))]}),y&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs text-red-500 bg-red-500/10 rounded-lg px-3 py-2",children:[(0,t.jsx)(et.X,{className:"w-3.5 h-3.5 shrink-0"}),(0,t.jsx)("span",{children:y})]}),L.length>0&&(0,t.jsxs)("div",{className:"rounded-xl border border-gray-200 dark:border-white/[0.08] bg-white dark:bg-white/[0.02] p-4",children:[(0,t.jsx)("p",{className:"text-xs font-medium text-gray-700 dark:text-white/70 mb-3",children:"Where should these articles be visible?"}),(0,t.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,t.jsxs)("button",{onClick:()=>T("public"),className:(0,F.cn)("flex items-start gap-3 p-3 rounded-lg border text-left transition-all","public"===I?"border-primary bg-primary/[0.03] ring-1 ring-primary/20":"border-gray-200 dark:border-white/[0.08] hover:border-gray-300 dark:hover:border-white/[0.12]"),children:[(0,t.jsx)(ec.Globe,{className:(0,F.cn)("w-5 h-5 mt-0.5 shrink-0","public"===I?"text-primary":"text-gray-400 dark:text-white/40")}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:(0,F.cn)("text-sm font-medium","public"===I?"text-primary":"text-gray-700 dark:text-white/70"),children:"Guest Portal"}),(0,t.jsx)("p",{className:"text-[11px] text-gray-500 dark:text-white/40 mt-0.5 leading-relaxed",children:"Visible to guests in the property guide. Also available to Vanio AI for answering questions."})]})]}),(0,t.jsxs)("button",{onClick:()=>T("ai_only"),className:(0,F.cn)("flex items-start gap-3 p-3 rounded-lg border text-left transition-all","ai_only"===I?"border-primary bg-primary/[0.03] ring-1 ring-primary/20":"border-gray-200 dark:border-white/[0.08] hover:border-gray-300 dark:hover:border-white/[0.12]"),children:[(0,t.jsx)(em.Bot,{className:(0,F.cn)("w-5 h-5 mt-0.5 shrink-0","ai_only"===I?"text-primary":"text-gray-400 dark:text-white/40")}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:(0,F.cn)("text-sm font-medium","ai_only"===I?"text-primary":"text-gray-700 dark:text-white/70"),children:"Vanio AI Only"}),(0,t.jsx)("p",{className:"text-[11px] text-gray-500 dark:text-white/40 mt-0.5 leading-relaxed",children:"Only Vanio AI can use this knowledge to answer guest questions. Not shown in the guest portal."})]})]})]})]}),L.length>0&&(0,t.jsxs)("div",{className:"rounded-xl border border-gray-200 dark:border-white/[0.08] bg-white dark:bg-white/[0.02] p-4",children:[(0,t.jsx)("p",{className:"text-xs font-medium text-gray-700 dark:text-white/70 mb-3",children:"Which listings should these articles apply to?"}),(0,t.jsx)(eb,{selectedListings:_,selectedGroups:D,onListingsChange:A,onGroupsChange:P})]}),(0,t.jsx)("div",{className:"sticky bottom-0 py-3 -mx-4 md:-mx-6 lg:-mx-8 px-4 md:px-6 lg:px-8 bg-white dark:bg-[#1D1D1F] border-t border-gray-200 dark:border-white/[0.08]",children:(0,t.jsxs)("div",{className:"flex items-center justify-between max-w-4xl mx-auto",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("p",{className:"text-xs text-gray-600 dark:text-white/50",children:[L.length," article",1!==L.length?"s":""," will be saved as"," ",(0,t.jsx)("span",{className:"font-medium text-gray-700 dark:text-white/70",children:"public"===I?"Guest Portal":"Vanio AI Only"}),(0,t.jsxs)("span",{className:"text-gray-500 dark:text-white/40",children:[" ","·"," ",0===_.length?"Global (all listings)":`${_.length} listing${1!==_.length?"s":""}`]})]}),b>0&&(0,t.jsxs)("p",{className:"text-[10px] text-green-600 dark:text-green-400 mt-0.5",children:[b," articles saved successfully"]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(ei.Button,{variant:"outline",size:"sm",onClick:n,children:"Back"}),(0,t.jsxs)(ei.Button,{onClick:U,disabled:0===L.length||g,className:"gap-2",children:[g?(0,t.jsx)(Y.Loader2,{className:"w-4 h-4 animate-spin"}):(0,t.jsx)(eo.Save,{className:"w-4 h-4"}),"Save ",L.length," Articles"]})]})]})})]})}function ev({articles:e,listingId:a,questionPhotos:r,onBack:s,onComplete:i}){let n=r?Object.values(r).flat():[],l=e.map(e=>({...e,approved:!0,includePhotos:!1,photoUrls:n}));return 0===e.length?(0,t.jsxs)("div",{className:"text-center py-8",children:[(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-white/50",children:"No articles were generated. Try providing more details."}),(0,t.jsxs)(ei.Button,{variant:"outline",size:"sm",onClick:s,className:"mt-3",children:[(0,t.jsx)(J.ChevronLeft,{className:"w-4 h-4 mr-1"}),"Go Back"]})]}
1):(0,t.jsx)(ew,{listingId:a,initialArticles:l,source:"questionnaire",onSaved:i,onBack:s,renderArticleFooter:({article:e,idx:a,updateArticle:r})=>e.photoUrls?.length?(0,t.jsxs)("div",{className:"px-4 pb-3 space-y-2 border-t border-gray-100 dark:border-white/[0.05] pt-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(ee.Camera,{className:"w-3.5 h-3.5 text-gray-400 dark:text-white/40 shrink-0"}),(0,t.jsx)("span",{className:"text-[11px] text-gray-500 dark:text-white/40 shrink-0",children:"Attached photos:"}),(0,t.jsx)("div",{className:"flex items-center gap-1.5 overflow-x-auto",children:e.photoUrls.map((e,a)=>(0,t.jsx)("div",{className:"w-8 h-8 rounded overflow-hidden bg-gray-100 dark:bg-white/[0.05] shrink-0",children:(0,t.jsx)("img",{src:e,alt:`Attached photo ${a+1}`,className:"w-full h-full object-cover"})},a))})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("button",{onClick:()=>r(a,{includePhotos:!e.includePhotos}),className:(0,F.cn)("relative w-8 h-[18px] rounded-full transition-colors focus:outline-none",e.includePhotos?"bg-green-500":"bg-gray-300 dark:bg-white/[0.15]"),children:(0,t.jsx)("div",{className:(0,F.cn)("absolute top-[2px] w-[14px] h-[14px] rounded-full bg-white shadow-sm transition-transform",e.includePhotos?"left-[16px]":"left-[2px]")})}),(0,t.jsx)(ee.Camera,{className:"w-3.5 h-3.5 text-gray-400 dark:text-white/40"}),(0,t.jsx)("span",{className:"text-[11px] text-gray-500 dark:text-white/40",children:"Embed photos in article"})]})]}):null,processContentBeforeSave:e=>e.includePhotos&&e.photoUrls?.length>0?e.photoUrls.map(e=>`<img src="${e}" alt="" style="max-width:100%;border-radius:8px;margin-bottom:8px" />`).join("")+e.content:e.content})}let ek="https://api.vanio.ai";function ej({listingId:e,initialCategory:a,onComplete:r,onCancel:s}){let{currentCustomerId:n}=(0,v.useCustomer)();(0,i.useEffect)(()=>{let e=e=>{let t=document.activeElement?.tagName;if("INPUT"===t||"TEXTAREA"===t||"SELECT"===t){if((e.metaKey||e.ctrlKey)&&("Enter"===e.key||"c"===e.key||"v"===e.key||"x"===e.key||"a"===e.key))return;if(e.metaKey||e.ctrlKey||e.altKey)return e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),!1}};return window.addEventListener("keydown",e,{capture:!0,passive:!1}),()=>{window.removeEventListener("keydown",e,{capture:!0})}},[]);let[l,o]=(0,i.useState)({hasPortal:!1}),[d,c]=(0,i.useState)(void 0),[m,u]=(0,i.useState)(!0),[h,x]=(0,i.useState)({}),g=(0,i.useMemo)(()=>(0,en.getWizardCategories)(l,d),[l,d]),[p,b]=(0,i.useState)("fill"),[f,y]=(0,i.useState)(0),[w,k]=(0,i.useState)({}),[j,N]=(0,i.useState)({}),[C,S]=(0,i.useState)(!1),[E,I]=(0,i.useState)([]),[T,_]=(0,i.useState)(null),A=(0,i.useCallback)(async()=>{try{let t=await fetch(`${ek}/kb/question-coverage?listingId=${e}&customerId=${n}`,{credentials:"include",cache:"no-store"});if(t?.ok){let e=await t.json();x(e.coverage||{})}}catch{}},[e,n]);(0,i.useEffect)(()=>{(async()=>{try{let[t]=await Promise.all([fetch(`${ek}/kb/portal-status?listingId=${e}&customerId=${n}`,{credentials:"include"}).catch(()=>null),A()]);if(t?.ok){let e=await t.json();o(e),Array.isArray(e.amenityIds)&&c(new Set(e.amenityIds))}}catch{}finally{u(!1)}})()},[e,n,A]),(0,i.useEffect)(()=>{let t=`training-wizard-${e}`;try{let e=localStorage.getItem(t);if(e){let t=JSON.parse(e);t.answers&&k(t.answers),t.photos&&N(t.photos)}}catch{}},[e]);let D=(0,i.useRef)(!1);(0,i.useEffect)(()=>{let t=Object.keys(w).length>0;if(t&&(D.current=!0),!t&&!D.current)return;let a=`training-wizard-${e}`;try{t?localStorage.setItem(a,JSON.stringify({answers:w,photos:j})):localStorage.removeItem(a)}catch{}},[w,j,e]);let P=(0,i.useCallback)(e=>e.questions.length>0&&e.questions.every(e=>!!h[e.id]),[h]),R=(0,i.useRef)(!1);(0,i.useEffect)(()=>{if(m||0===g.length||R.current)return;if(R.current=!0,a){let e=g.findIndex(e=>e.id===a);if(e>=0)return void y(e)}let e=g.findIndex(e=>!P(e));e>=0&&y(e)},[m,g,a,P]);let M=g[f]||null,F=M&&w[M.id]||{},L=M&&j[M.id]||{},$=M?M.questions.filter(e=>F[e.id]?.trim()).length:0,O=M?M.questions.filter(e=>h[e.id]).length:0,U=(0,i.useCallback)((e,t,a)=>{k(r=>({...r,[e]:{...r[e]||{},[t]:a}}))},[]),B=(0,i.useCallback)(async(t,a,r)=>{if(r.type.startsWith("image/"))try{let s=await fetch(`/api/kb/media/upload-photo?customerId=${n}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileName:r.name,fileType:r.type,fileSize:r.size,listingId:String(e)})});if(!s.ok)return;let{signedUrl:i,publicUrl:l}=await s.json();if(!(await fetch(i,{method:"PUT",headers:{"Content-Type":r.type},body:r})).ok)return;N(e=>({...e,[t]:{...e[t]||{},[a]:[...(e[t]||{})[a]||[],l]}}))}catch{}},[e,n]),q=(0,i.useCallback)((e,t,a)=>{N(r=>({...r,[e]:{...r[e]||{},[t]:((r[e]||{})[t]||[]).filter((e,t)=>
1t!==a)}}))},[]),z=(0,i.useCallback)(()=>{M&&(k(e=>{let t={...e};return delete t[M.id],t}),N(e=>{let t={...e};return delete t[M.id],t}));let t=f+1;for(;t<g.length&&P(g[t]);)t++;if(t<g.length)y(t),b("fill");else{try{localStorage.removeItem(`training-wizard-${e}`)}catch{}r()}},[f,g,P,M,e,r]),H=(0,i.useCallback)(async()=>{if(!M)return;let t=w[M.id]||{};if(!Object.values(t).some(e=>e?.trim()))return void z();b("generate"),S(!0),_(null);try{let a={categoryId:M.id,categoryName:M.name,answers:t,questionPhotos:j[M.id]&&Object.keys(j[M.id]).length>0?j[M.id]:void 0},r=await fetch(`${ek}/kb/generate-from-questionnaire`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({listingId:e,categories:[a],portalContext:l.hasPortal?l:void 0})});if(!r.ok)throw Error("Failed to generate articles");let s=await r.json();I(s.articles||[]),b("preview")}catch(e){_(e instanceof Error?e.message:"Something went wrong"),b("fill")}finally{S(!1)}},[M,w,j,e,l,z]),V=(0,i.useCallback)(()=>{f>0?(y(e=>e-1),b("fill")):s()},[f,s]),G=(0,i.useCallback)(()=>{z()},[z]),W=(0,i.useCallback)(async()=>{await A(),window.dispatchEvent(new CustomEvent("kb:refresh")),z()},[A,z]),J=(0,i.useMemo)(()=>{if(!M)return;let e=j[M.id];if(e&&0!==Object.keys(e).length)return e},[M,j]);return m?(0,t.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,t.jsx)(Y.Loader2,{className:"w-5 h-5 animate-spin text-gray-400 dark:text-white/40"})}):(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(K.ClipboardList,{className:"w-5 h-5 text-primary"}),(0,t.jsxs)("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:["fill"===p&&M?.name,"generate"===p&&`Generating ${M?.name} articles...`,"preview"===p&&`Review: ${M?.name}`]})]}),(0,t.jsx)(ei.Button,{variant:"ghost",size:"sm",onClick:s,className:"text-xs",children:"Cancel"})]}),"fill"===p&&M&&(0,t.jsx)(eN,{category:M,categoryIdx:f,totalCategories:g.length,answers:F,photos:L,coverage:h,onAnswerChange:(e,t)=>
1U(M.id,e,t),onPhotoUpload:(e,t)=>B(M.id,e,t),onRemovePhoto:(e,t)=>q(M.id,e,t),onNext:H,onPrev:V,onSkip:G,filledCount:$,coveredCount:O,hasAnswers:$>0,isFirst:0===f,isLast:f===g.length-1,error:T,portalContext:l}),"generate"===p&&(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 gap-3",children:[(0,t.jsx)(Y.Loader2,{className:"w-8 h-8 animate-spin text-primary"}),(0,t.jsxs)("p",{className:"text-sm text-gray-500 dark:text-white/50",children:["Generating articles for ",M?.name,"..."]})]}),"preview"===p&&(0,t.jsx)(ev,{articles:E,listingId:e,questionPhotos:J,onBack:()=>b("fill"),onComplete:W})]})}function eN({category:e,categoryIdx:a,totalCategories:r,answers:s,photos:i,coverage:n,onAnswerChange:l,onPhotoUpload:o,onRemovePhoto:d,onNext:c,onPrev:m,onSkip:u,filledCount:h,coveredCount:x,hasAnswers:g,isFirst:p,isLast:b,error:f,portalContext:y}){return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("div",{className:"flex items-center gap-1 justify-center",children:Array.from({length:r},(e,r)=>(0,t.jsx)("div",{className:(0,F.cn)("w-2 h-2 rounded-full transition-all",r===a?"w-6 bg-primary":r<a?"bg-primary/40":"bg-gray-200 dark:bg-white/[0.1]")},r))}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("span",{className:"text-xs text-gray-500 dark:text-white/40",children:[a+1," of ",r]}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[x>0&&(0,t.jsxs)("span",{className:"text-[11px] text-green-600 dark:text-green-400 flex items-center gap-1",children:[(0,t.jsx)(es.CheckCircle2,{className:"w-3 h-3"}),x," already covered"]}),(0,t.jsxs)("span",{className:"text-xs text-gray-500 dark:text-white/40",children:[h,"/",e.questions.length," answered"]})]})]}),(0,t.jsxs)("p",{className:"text-xs text-gray-500 dark:text-white/50",children:[e.description," Fill in what you know â skip what's already covered."]}),!y.hasPortal&&"check-in"===e.id&&(0,t.jsx)(eC,{text:"Send check-in instructions automatically via the Guest Portal â guests get a branded portal link with all the info they need."}),!y.hasPortal&&"procedures"===e.id&&(0,t.jsx)(eC,{text:"Automate upsells with the Guest Portal â guests can self-serve early check-in, late check-out, and mid-stay cleaning with automatic pricing."}),y.hasPortal&&"portal-services"===e.id&&(0,t.jsx)("div",{className:"rounded-lg border border-green-200 dark:border-green-500/20 bg-green-50 dark:bg-green-500/10 p-3",children:(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[(0,t.jsx)(Z.Check,{className:"w-4 h-4 text-green-500 shrink-0 mt-0.5"}),(0,t.jsxs)("div",{className:"text-xs text-green-700 dark:text-green-300",children:[(0,t.jsx)("p",{className:"font-medium",children:"Guest Portal is active"}),(0,t.jsx)("p",{className:"mt-0.5 text-green-600 dark:text-green-400",children:[y.portalSettings?.earlyCheckIn&&"Early check-in",y.portalSettings?.lateCheckOut&&"Late check-out",y.portalSettings?.midStayCleaning&&`Mid-stay cleaning (\u20AC${y.portalSettings.midStayCleaningFee||"?"})`,y.portalSettings?.extendStay&&`Extend stay (\u20AC${y.portalSettings.extendStayPerNight||"?"}/night)`,y.portalSettings?.damageProtection&&"Damage protection"].filter(Boolean).join(" ⢠")||"No upsells configured yet"})]})]})}),(0,t.jsx)("div",{className:"space-y-3",children:e.questions.map(e=>{let a=!!n[e.id];return(0,t.jsx)(eS,{question:e,value:s[e.id]||"",onChange:t=>l(e.id,t),photos:i[e.id]||[],onPhotoUpload:t=>o(e.id,t),onRemovePhoto:t=>d(e.id,t),coverage:a?n[e.id]:void 0},e.id)})}),f&&(0,t.jsx)("p",{className:"text-sm text-red-500",children:f}),(0,t.jsxs)("div",{className:"flex items-center justify-between pt-2",children:[(0,t.jsxs)(ei.Button,{variant:"ghost",size:"sm",onClick:m,children:[(0,t.jsx)(J.ChevronLeft,{className:"w-4 h-4 mr-1"}),p?"Cancel":"Previous"]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("button",{onClick:u,className:"text-xs text-gray-400 dark:text-white/30 hover:text-gray-600 dark:hover:text-white/50 transition-colors flex items-center gap-1",children:[(0,t.jsx)(ea.SkipForward,{className:"w-3 h-3"}),"Skip"]}
1),(0,t.jsx)(ei.Button,{size:"sm",onClick:c,children:g?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(X.Sparkles,{className:"w-4 h-4 mr-1.5"}),"Generate"]}):(0,t.jsxs)(t.Fragment,{children:["Next",(0,t.jsx)(Q.ChevronRight,{className:"w-4 h-4 ml-1"})]})})]})]})]})}function eC({text:e}){return(0,t.jsx)("div",{className:"rounded-lg border border-blue-200 dark:border-blue-500/20 bg-blue-50 dark:bg-blue-500/10 p-3",children:(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[(0,t.jsx)(er.Info,{className:"w-4 h-4 text-blue-500 shrink-0 mt-0.5"}),(0,t.jsx)("p",{className:"text-xs text-blue-600 dark:text-blue-400",children:e})]})})}function eS({question:e,value:a,onChange:r,photos:s,onPhotoUpload:n,onRemovePhoto:l,coverage:o}){let d=(0,i.useRef)(null),[c,m]=(0,i.useState)(!1),u=(0,_.useRouter)(),h=(0,_.useSearchParams)(),{openForm:x}=(0,R.useKBFormStore)(),g=!!o,p=o?.source==="questionnaire"?"Questionnaire":o?.source==="mining"||o?.source==="history"?"Conversation Mining":o?.source==="media"||o?.source==="ai_generated"?"Vanio AI":o?.source==="imported"?"Import":"Article",b=(0,F.cn)("w-full rounded-lg border px-3 py-2 text-sm transition-colors","bg-white dark:bg-white/[0.03]","border-gray-200 dark:border-white/[0.1]","text-gray-900 dark:text-white","placeholder:text-gray-400 dark:placeholder:text-white/30","focus:outline-none focus:ring-1 focus:ring-primary focus:border-primary"),f=async e=>{let t=e.target.files?.[0];t&&(m(!0),await n(t),m(!1),d.current&&(d.current.value=""))};return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,t.jsxs)("label",{className:"flex items-center gap-1.5 text-sm font-medium text-gray-700 dark:text-white/70",children:[e.label,e.required&&!g&&(0,t.jsx)("span",{className:"text-red-400 ml-0.5",children:"*"})]}),(0,t.jsx)("div",{className:"flex items-center gap-2",children:(0,t.jsxs)("button",{type:"button",onClick:()=>d.current?.click(),disabled:c,className:"flex items-center gap-1 text-[11px] text-gray-400 dark:text-white/30 hover:text-primary transition-colors",title:"Attach a photo to this answer",children:[c?(0,t.jsx)(Y.Loader2,{className:"w-3 h-3 animate-spin"}):(0,t.jsx)(ee.Camera,{className:"w-3 h-3"}),"Photo"]})}),(0,t.jsx)("input",{ref:d,type:"file",className:"hidden",accept:"image/*",onChange:f})]}),g&&o.articleTitle&&(0,t.jsxs)("button",{type:"button",onClick:()=>{if(o.knowledgeItemId){let e=new URLSearchParams(h?.toString());e.set("kb",String(o.knowledgeItemId)),u.push(`?${e.toString()}`,{scroll:!1}),x(String(o.knowledgeItemId))}},className:(0,F.cn)("w-full mb-1.5 flex items-center gap-2.5 px-3 py-2 rounded-lg border text-left transition-all","border-gray-200 dark:border-white/[0.08] bg-white dark:bg-white/[0.02]","hover:border-primary/50 dark:hover:border-primary/40 hover:bg-primary/[0.02] group"),children:[(0,t.jsx)(es.CheckCircle2,{className:"w-4 h-4 text-green-500 shrink-0"}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("p",{className:"text-xs font-medium text-gray-900 dark:text-white truncate group-hover:text-primary transition-colors",children:o.articleTitle}),o.articleSnippet&&(0,t.jsx)("p",{className:"text-[11px] text-gray-500 dark:text-white/40 truncate mt-0.5",children:o.articleSnippet})]}),(0,t.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-gray-100 dark:bg-white/[0.05] text-gray-500 dark:text-white/40 shrink-0",children:p})]}),"select"===e.type?(0,t.jsxs)("select",{value:a,onChange:e=>r(e.target.value),className:b,children:[(0,t.jsx)("option",{value:"",children:"Select..."}),e.options?.map(e=>(0,t.jsx)("option",{value:e,children:e},e))]}):"textarea"===e.type?(0,t.jsx)("textarea",{value:a,onChange:e=>r(e.target.value),placeholder:g&&!a?"Already covered â fill in to add more details or override":e.placeholder,rows:g&&!a?2:3,className:(0,F.cn)(b,"resize-none")}):(0,t.jsx)("input",{type:"text",value:a,onChange:e=>r(e.target.value),placeholder:g&&!a?"Already covered â fill in to override":e.placeholder,className:b}),s.length>0&&(0,t.jsx)("div",{className:"flex items-center gap-2 mt-1.5",children:s.map((e,a)=>(0,t.jsxs)("div",{className:"relative group",children:[(0,t.jsx)("div",{className:"w-12 h-12 rounded-lg overflow-hidden bg-gray-100 dark:bg-white/[0.05]",children:(0,t.jsx)("img",{src:e,alt:"",className:"w-full h-full object-cover"})}),(0,t.jsx)("button",{type:"button",onClick:()=>l(a),className:"absolute -top-1.5 -right-1.5 w-4 h-4 rounded-full bg-red-500 text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:(0,t.jsx)(et.X,{className:"w-2.5 h-2.5"})})]},a))})]})}var eE=e.i(278716),eI=e.i(871689),eT=e.i(972080),e_=e.i(569074),eA=e.i(972520),eD=e.i(503116),eP=e.i(878894),eR=e.i(724247);let eM={bedroom:"Bedroom",living_room:"Living Room",kitchen:"Kitchen",dining_room:"Dining Room",full_bathroom:"Bathroom",half_bathroom:"Half Bath",laundry_room:"Laundry",rooftop:"Rooftop",exterior:"Exterior"},eF={living_room:1,kitchen:2,dining_room:3,bedroom:4,full_bathroom:5,half_bathroom:6,laundry_room:7,rooftop:8,exterior:9};function eL(e){return"LISTING"===e?99:eF[e]??50}function e$({photos:e,onToggleSelect:a,onToggleAll:r,analyzedPhotoIds:s}
1){let[n,l]=(0,i.useState)(new Set),o=e.filter(e=>e.selected).length,d=o===e.length&&e.length>0,c=(0,i.useMemo)(()=>{var t;let a=new Map;for(let t of e){let e=t.roomType||t.category||"other";a.has(e)||a.set(e,[]),a.get(e).push(t)}let r=[];for(let[e,s]of a)r.push({key:e,label:(t=s[0].roomType??null,s[0].category,t?eM[t]||t:"Other"),photos:s});return r.sort((e,t)=>eL(e.key)-eL(t.key))},[e]);return(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("p",{className:"text-xs text-gray-500 dark:text-white/40",children:[o," of ",e.length," photos selected"]}),(0,t.jsx)("button",{onClick:()=>r(!d),className:"text-xs text-primary hover:text-primary/80 transition-colors",children:d?"Deselect All":"Select All"})]}),(0,t.jsx)("div",{className:"space-y-5",children:c.map(e=>{let r=e.photos.filter(e=>e.selected).length,i=s?e.photos.filter(e=>s.has(e.id)).length:0;return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,t.jsx)("h4",{className:"text-xs font-medium text-gray-700 dark:text-white/70",children:e.label}),(0,t.jsxs)("span",{className:"text-[10px] text-gray-400 dark:text-white/30",children:[r,"/",e.photos.length]}),i>0&&(0,t.jsxs)("span",{className:"flex items-center gap-0.5 text-[10px] text-green-600 dark:text-green-400",children:[(0,t.jsx)(X.Sparkles,{className:"w-2.5 h-2.5"}),i," analyzed"]})]}),(0,t.jsx)("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 gap-2",children:e.photos.map(e=>(0,t.jsxs)("button",{onClick:()=>a(e.id),className:(0,F.cn)("relative aspect-square rounded-lg overflow-hidden transition-all group",e.selected?"ring-2 ring-blue-500":"ring-1 ring-transparent"),children:[n.has(e.id)?(0,t.jsx)("div",{className:"w-full h-full flex items-center justify-center bg-gray-100 dark:bg-white/[0.05]",children:(0,t.jsx)(eR.ImageOff,{className:"w-5 h-5 text-gray-400 dark:text-white/30"})}):(0,t.jsx)("img",{src:e.thumbnailUrl,alt:e.caption||"Property photo",className:(0,F.cn)("w-full h-full object-cover transition-all",!e.selected&&"opacity-60"),loading:"lazy",onError:()=>l(t=>new Set(t).add(e.id))}),(0,t.jsx)("div",{className:(0,F.cn)("absolute top-1.5 right-1.5 w-5 h-5 rounded flex items-center justify-center transition-all z-10",e.selected?"bg-blue-500 text-white shadow-md":"bg-white/70 dark:bg-black/30 border border-gray-300 dark:border-white/50"),children:e.selected&&(0,t.jsx)(Z.Check,{className:"w-3.5 h-3.5",strokeWidth:3})}),s?.has(e.id)&&(0,t.jsx)("div",{className:"absolute bottom-1.5 left-1.5 flex items-center gap-0.5 px-1.5 py-0.5 rounded-full bg-black/50 backdrop-blur-sm text-white/80 text-[9px] font-medium z-10",children:(0,t.jsx)(X.Sparkles,{className:"w-2.5 h-2.5"})})]},e.id))})]},e.key)})})]})}var eO=e.i(505779);let eU="https://api.vanio.ai",eB=e=>fetch(e,{credentials:"include"}).then(e=>{if(!e.ok)throw Error("Failed to fetch");return e.json()});function eq({listingId:e,onAnalyze:a,onLoadAnalysis:r,mediaArticleCount:s=0,sessionAnalyzedIds:n}){let l,o,d,{currentCustomerId:c}=(0,v.useCustomer)(),m=(0,i.useRef)(null),[u,h]=(0,i.useState)([]),[x,g]=(0,i.useState)(!1),p=c&&e?`${eU}/kb/media/photos?customerId=${c}&listingId=${e}`:null,{data:b,isLoading:f}=(0,U.default)(p,eB),y=c&&e?`${eU}/kb/media/photo-analyses?customerId=${c}&listingId=${e}`:null,{data:w}=(0,U.default)(y,eB),k=w?.analyses||[],j=(0,i.useRef)(!1),N=b?.uploadedPhotos;(0,i.useEffect)(()=>{if(!j.current&&N?.length>0){j.current=!0;let e=N.map(e=>({id:e.id,url:e.url,thumbnailUrl:e.url,largeUrl:e.url,caption:e.name?.replace(/^\d+_/,"").replace(/\.[^/.]+$/,"").replace(/_/g," ")||"",source:"upload",selected:!0}));h(t=>t.length>0?t:e)}},[N]);let C=(b?.photos||[]).map(e=>({id:e.id,url:e.largeUrl||e.originalUrl,thumbnailUrl:e.thumbnailUrl,largeUrl:e.largeUrl||e.originalUrl,caption:e.caption,category:e.category,roomType:e.roomType,source:"airbnb",selected:!0})),S=(0,i.useMemo)(()=>(function(e,t,a=[]){let r=new Set(a);if(0===e.length)return r;let s=new Set;
1for(let t of e)for(let e of t.photoUrls||[]){let t=(0,eO.photoUrlMatchKey)(e);t&&s.add(t)}for(let e of t){let t=(0,eO.photoUrlMatchKey)(e.url);t&&s.has(t)&&r.add(e.id)}return r})(k,[...C,...u],n),[k,C,u,n]),[E,I]=(0,i.useState)(new Set),[T,_]=(0,i.useState)(new Set),A=C.map(e=>{let t=S.has(e.id),a=E.has(e.id),r=T.has(e.id);return{...e,selected:t?r:!a}}).concat(u.map(e=>{let t=S.has(e.id),a=T.has(e.id),r=t?a:e.selected;return{...e,selected:r}})),D=(0,i.useCallback)(e=>{S?.has(e)?_(t=>{let a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a}):e.startsWith("airbnb-")?I(t=>{let a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a}):h(t=>t.map(t=>t.id===e?{...t,selected:!t.selected}:t))},[S]),P=(0,i.useCallback)(e=>{e?(I(new Set),_(new Set([...C.filter(e=>S.has(e.id)).map(e=>e.id),...u.filter(e=>S.has(e.id)).map(e=>e.id)])),h(e=>e.map(e=>({...e,selected:!0})))):(I(new Set(C.map(e=>e.id))),_(new Set),h(e=>e.map(e=>({...e,selected:!1}))))},[C,u,S]),R=(0,i.useCallback)(async t=>{if(t&&0!==t.length){for(let a of(g(!0),Array.from(t)))if(a.type.startsWith("image/"))try{let t=await fetch(`/api/kb/media/upload-photo?customerId=${c}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileName:a.name,fileType:a.type,fileSize:a.size,listingId:String(e)})});if(!t.ok){let e=await t.json().catch(()=>({error:"Upload failed"}));console.error("[PhotoIntake] Upload failed:",e.error);continue}let{signedUrl:r,publicUrl:s}=await t.json();if(!(await fetch(r,{method:"PUT",headers:{"Content-Type":a.type},body:a})).ok){console.error("[PhotoIntake] Direct upload failed");continue}h(e=>[...e,{id:`upload-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,url:s,thumbnailUrl:s,largeUrl:s,caption:a.name.replace(/\.[^/.]+$/,""),source:"upload",selected:!0}])}catch(e){console.error("[PhotoIntake] Upload error:",e.message)}g(!1)}},[e,c]),M=(0,i.useCallback)(e=>{r&&r({photos:e.photos||[],articles:(e.articles||[]).map(e=>({...e,source:"media",approved:!1}))})},[r]),L=A.filter(e=>e.selected),$=L.filter(e=>!S?.has(e.id)),O=L.length-$.length;return f?(0,t.jsx)(ez,{}):(0,t.jsxs)("div",{className:"space-y-5",children:[k.length>0&&(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(eD.Clock,{className:"w-3.5 h-3.5 text-gray-400 dark:text-white/40"}),(0,t.jsx)("h4",{className:"text-xs font-medium text-gray-600 dark:text-white/50",children:"Previous Analyses"})]}),k.map(e=>(0,t.jsxs)("button",{onClick:()=>M(e),className:(0,F.cn)("w-full flex items-center gap-3 p-3 rounded-xl border text-left transition-all","border-gray-200 dark:border-white/[0.06] bg-white dark:bg-white/[0.01]","hover:border-gray-300 dark:hover:border-white/[0.12] hover:bg-gray-50 dark:hover:bg-white/[0.03]"),children:[(0,t.jsxs)("div",{className:"flex -space-x-2 shrink-0",children:[(e.photoUrls||[]).slice(0,3).map((e,a)=>(0,t.jsx)("div",{className:"w-10 h-10 rounded-lg overflow-hidden border-2 border-gray-50 dark:border-[#1D1D1F] bg-gray-100 dark:bg-white/[0.05]",children:e?(0,t.jsx)("img",{src:e,alt:"",className:"w-full h-full object-cover"}):(0,t.jsx)(ee.Camera,{className:"w-4 h-4 text-gray-400 dark:text-white/30 m-auto mt-3"})},a)),e.photoCount>3&&(0,t.jsxs)("div",{className:"w-10 h-10 rounded-lg border-2 border-gray-50 dark:border-[#1D1D1F] bg-gray-100 dark:bg-white/[0.05] flex items-center justify-center text-[10px] text-gray-500 dark:text-white/40 font-medium",children:["+",e.photoCount-3]})]}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("p",{className:"text-xs font-medium text-gray-700 dark:text-white/70 truncate",children:[e.photoCount," photo",1!==e.photoCount?"s":""," analyzed"]}),e.savedArticleCount>0&&e.savedArticleCount>=e.articleCount&&(0,t.jsxs)("span",{className:"flex items-center gap-1 text-[10px] font-medium text-green-600 dark:text-green-400 bg-green-500/10 px-1.5 py-0.5 rounded-full shrink-0",children:[(0,t.jsx)(es.CheckCircle2,{className:"w-3 h-3"}),"Saved"]}),e.savedArticleCount>0&&e.savedArticleCount<e.articleCount&&(0,t.jsxs)("span",{className:"text-[10px] font-medium text-amber-600 dar
1k:text-amber-400 bg-amber-500/10 px-1.5 py-0.5 rounded-full shrink-0",children:[e.savedArticleCount,"/",e.articleCount," saved"]})]}),(0,t.jsxs)("p",{className:"text-[10px] text-gray-400 dark:text-white/30 mt-0.5",children:[e.articleCount," article",1!==e.articleCount?"s":""," ·"," ",new Date(e.createdAt).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})]})]}),(0,t.jsx)(eA.ArrowRight,{className:"w-4 h-4 text-gray-300 dark:text-white/20 shrink-0"})]},e.id))]}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(ee.Camera,{className:"w-4 h-4 text-primary"}),(0,t.jsx)("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Property Photos"}),C.length>0&&(0,t.jsxs)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:[C.length," from Airbnb"]})]}),(0,t.jsxs)("button",{onClick:()=>m.current?.click(),className:"flex items-center gap-1.5 text-xs text-gray-600 dark:text-white/60 hover:text-gray-900 dark:hover:text-white transition-colors px-2.5 py-1.5 rounded-lg border border-gray-200 dark:border-white/[0.1] hover:border-gray-300 dark:hover:border-white/20",children:[(0,t.jsx)(e_.Upload,{className:"w-3.5 h-3.5"}),"Add Photos"]}),(0,t.jsx)("input",{ref:m,type:"file",className:"hidden",accept:"image/*",multiple:!0,onChange:e=>R(e.target.files)})]}),s>0&&(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-green-500/10 border border-green-200 dark:border-green-500/20",children:[(0,t.jsx)(es.CheckCircle2,{className:"w-4 h-4 text-green-600 dark:text-green-400 shrink-0"}),(0,t.jsxs)("p",{className:"text-xs text-green-700 dark:text-green-400",children:[s," article",1!==s?"s":""," already created from media. Select more photos to generate additional knowledge."]})]}),C.length>0&&(0,t.jsxs)("div",{className:"rounded-lg border border-gray-200 dark:border-white/[0.08] bg-gray-50 dark:bg-white/[0.02] px-3 py-2.5",children:[(0,t.jsx)("p",{className:"text-[11px] font-medium text-gray-700 dark:text-white/70 mb-1",children:"Tips for best results"}),(0,t.jsxs)("ul",{className:"text-[11px] text-gray-500 dark:text-white/40 space-y-0.5 list-disc list-inside",children:[(0,t.jsx)("li",{children:"Close-ups of controls work best (thermostat, oven panel, washing machine)"}),(0,t.jsx)("li",{children:"Photos of labels, signs, or WiFi cards are automatically transcribed"}),(0,t.jsx)("li",{children:"General room photos are less useful â Vanio AI focuses on actionable details"}),(0,t.jsx)("li",{children:"Upload your own photos for things not on Airbnb (lockbox, bins, fuse box)"})]})]}),A.length>0&&(0,t.jsx)(e$,{photos:A,onToggleSelect:D,onToggleAll:P,analyzedPhotoIds:S}),u.length>0&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("p",{className:"text-[11px] font-medium text-gray-600 dark:text-white/60",children:"What do your uploaded photos show?"}),u.map((e,a)=>(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded overflow-hidden bg-gray-100 dark:bg-white/[0.05] shrink-0",children:(0,t.jsx)("img",{src:e.thumbnailUrl,alt:"",className:"w-full h-full object-cover"})}),(0,t.jsx)("input",{type:"text",value:e.caption||"",onChange:e=>{h(t=>t.map((t,r)=>r===a?{...t,caption:e.target.value}:t))},placeholder:"e.g. lockbox on front door, thermostat in hallway, bin area...",className:(0,F.cn)("flex-1 px-2.5 py-1.5 text-xs rounded-lg border transition-colors","border-gray-200 dark:border-white/[0.06] bg-white dark:bg-white/[0.03]","text-gray-700 dark:text-white/70 placeholder:text-gray-400 dark:placeholder:text-white/25","focus:border-primary focus:outline-none")})]},e.id))]}),(0,t.jsx)("div",{onClick:()=>m.current?.click(),className:"rounded-xl border border-dashed border-gray-200 dark:border-white/[0.1] hover:border-gray-300 dark:hover:border-white/20 p-4 text-center cursor-pointer transition-all hover:bg-gray-50 dark:hover:bg-white/[0.02]",children:(0,t.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,t.jsx)(e_.Upload,{className:"w-4 h-4 text-gray-400 dark:text-white/30"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/40",children:"Drop or click to add your own photos (lockbox, controls, signs, etc.)"})]})}),A.length>0&&(o=(l=$.length>0?$:L).length>20,d=Math.min(l.length,20),(0,t.jsx)("div",{className:"sticky bottom-0 z-20 py-3 -mx-4 md:-mx-6 lg:-mx-8 px-4 md:px-6 lg:px-8 bg-white dark:bg-[#1D1D1F] border-t border-gray-200 dark:border-white/[0.08]",children:(0,t.jsxs)("div",{className:"flex items-center justify-between max-w-4xl mx-auto",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs text-gray-600 dark:text-white/50",children:$.length>0?`${$.length} new photo${1!==$.length?"s":""} selected`:`${L.length} photo${1!==L.length?"s":""} selected`}),O>0&&(0,t.jsxs)("p",{className:"text-[10px] text-gray-400 dark:text-white/30",children:[O," already analyzed"]}),o&&(0,t.jsxs)("p",{className:"flex items-center gap-1 text-[10px] text-amber-600 dar
1k:text-amber-400 mt-0.5",children:[(0,t.jsx)(eP.AlertTriangle,{className:"w-3 h-3"}),"Max ",20," per batch â first ",20," will be analyzed"]})]}),(0,t.jsxs)(ei.Button,{onClick:()=>a(l.slice(0,20)),disabled:0===L.length,className:"gap-2",children:[(0,t.jsx)(eT.ImagePlus,{className:"w-4 h-4"}),"Analyze"," ",$.length>0?`${d} New`:d," ","Photos",(0,t.jsx)(eA.ArrowRight,{className:"w-4 h-4"})]})]})})),0===A.length&&!f&&0===k.length&&(0,t.jsxs)("div",{className:"text-center py-8",children:[(0,t.jsx)(eT.ImagePlus,{className:"w-8 h-8 text-gray-300 dark:text-white/20 mx-auto mb-3"}),(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-white/50",children:"No Airbnb photos found for this listing"}),(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-white/30 mt-1",children:"Upload photos above to get started"})]})]})}function ez(){return(0,t.jsxs)("div",{className:"space-y-5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(B.Skeleton,{className:"w-4 h-4 rounded bg-gray-200 dark:bg-white/[0.08]"}),(0,t.jsx)(B.Skeleton,{className:"w-32 h-5 bg-gray-200 dark:bg-white/[0.08]"})]}),(0,t.jsx)(B.Skeleton,{className:"w-full h-4 bg-gray-200 dark:bg-white/[0.08]"}),(0,t.jsx)("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 gap-2",children:[...Array(12)].map((e,a)=>(0,t.jsx)(B.Skeleton,{className:"aspect-square rounded-lg bg-gray-200 dark:bg-white/[0.08]"},a))})]})}var eH=e.i(664659),eV=e.i(473708),eG=e.i(316328);function eW({listingId:e,result:a,savedTitles:r,onSaved:s,onBack:n}){let[l,o]=(0,i.useState)(!0),d=a.articles.map(e=>{let t=(a.photos||[]).filter(t=>t.suggestedTitle===e.title||t.suggestedCategory===e.category).map(e=>e.url).filter(Boolean);return{...e,approved:!r?.has(e.title?.toLowerCase()),photoUrls:t,includePhotos:!1}}),c=a.photos&&a.photos.length>0?(0,t.jsxs)("div",{className:"rounded-xl border border-gray-200 dark:border-white/[0.08] bg-white dark:bg-white/[0.02] overflow-hidden",children:[(0,t.jsxs)("button",{onClick:()=>o(e=>!e),className:"w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-gray-50 dark:hover:bg-white/[0.03] transition-colors",children:[l?(0,t.jsx)(eH.ChevronDown,{className:"w-4 h-4 text-gray-400 dark:text-white/40 shrink-0"}):(0,t.jsx)(Q.ChevronRight,{className:"w-4 h-4 text-gray-400 dark:text-white/40 shrink-0"}),(0,t.jsx)(ee.Camera,{className:"w-4 h-4 text-blue-500 shrink-0"}),(0,t.jsx)("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Analyzed Photos"}),(0,t.jsxs)("span",{className:"text-[10px] text-gray-400 dark:text-white/30 ml-auto",children:[a.photos.length," photo",1!==a.photos.length?"s":""]})]}),l&&(0,t.jsx)("div",{className:"border-t border-gray-100 dark:border-white/[0.05] p-4",children:(0,t.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3",children:a.photos.map((e,a)=>(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("div",{className:"relative aspect-[4/3] rounded-lg overflow-hidden bg-gray-100 dark:bg-white/[0.05]",children:(0,t.jsx)(eG.ListingPhotoTileImage,{url:e.url,alt:e.description,className:"w-full h-full object-cover"})}),(0,t.jsx)("p",{className:"text-[10px] text-gray-600 dark:text-white/60 line-clamp-2 leading-relaxed",children:e.description}),e.tags&&e.tags.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1",children:e.tags.slice(0,3).map((e,a)=>(0,t.jsx)("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-gray-100 dark:bg-white/[0.05] text-gray-500 dark:text-white/40",children:e},a))})]},a))})})]}):null;return(0,t.jsx)(ew,{listingId:e,initialArticles:d,source:"media",onSaved:s,onBack:n,savedTitles:r,headerContent:c,renderArticleFooter:({article:e,idx:a,updateArticle:r})=>e.photoUrls?.length?(0,t.jsxs)("div",{className:"px-4 pb-3 space-y-2 border-t border-gray-100 dark:border-white/[0.05] pt-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(eV.Image,{className:"w-3.5 h-3.5 text-gray-400 dark:text-white/40 shrink-0"}),(0,t.jsx)("span",{className:"text-[11px] text-gray-500 dark:text-white/40 shrink-0",children:"Source photos:"}),(0,t.jsx)("div",{className:"flex items-center gap-1.5 overflow-x-auto",children:e.photoUrls.map((e,a)=>(0,t.jsx)("div",{className:"w-8 h-8 rounded overflow-hidden bg-gray-100 dark:bg-white/[0.05] shrink-0",children:(0,t.jsx)("img",{src:e,alt:`Source photo ${a+1}
1`,className:"w-full h-full object-cover"})},a))})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("button",{onClick:()=>r(a,{includePhotos:!e.includePhotos}),className:(0,F.cn)("relative w-8 h-[18px] rounded-full transition-colors focus:outline-none",e.includePhotos?"bg-green-500":"bg-gray-300 dark:bg-white/[0.15]"),children:(0,t.jsx)("div",{className:(0,F.cn)("absolute top-[2px] w-[14px] h-[14px] rounded-full bg-white shadow-sm transition-transform",e.includePhotos?"left-[16px]":"left-[2px]")})}),(0,t.jsx)(ee.Camera,{className:"w-3.5 h-3.5 text-gray-400 dark:text-white/40"}),(0,t.jsx)("span",{className:"text-[11px] text-gray-500 dark:text-white/40",children:"Embed photos in article"})]})]}):null,processContentBeforeSave:e=>e.includePhotos&&e.photoUrls?.length>0?e.photoUrls.map(e=>`<img src="${e}" alt="" style="max-width:100%;border-radius:8px;margin-bottom:8px" />`).join("")+e.content:e.content})}var eK=e.i(727612),eY=e.i(178583),eJ=e.i(341240);function eQ({listingId:e,videoUrl:a,result:r,savedTitles:s,onSaved:n,onBack:l}){let[o,d]=(0,i.useState)(!1),[c,m]=(0,i.useState)(!0),u=r.articles.map(e=>({...e,approved:!s?.has(e.title?.toLowerCase()),includeVideo:!1})),h=(0,t.jsxs)(t.Fragment,{children:[r.transcript&&(0,t.jsxs)("div",{className:"rounded-xl border border-gray-200 dark:border-white/[0.08] bg-white dark:bg-white/[0.02] overflow-hidden",children:[(0,t.jsxs)("button",{onClick:()=>d(e=>!e),className:"w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-gray-50 dark:hover:bg-white/[0.03] transition-colors",children:[o?(0,t.jsx)(eH.ChevronDown,{className:"w-4 h-4 text-gray-400 dark:text-white/40 shrink-0"}):(0,t.jsx)(Q.ChevronRight,{className:"w-4 h-4 text-gray-400 dark:text-white/40 shrink-0"}),(0,t.jsx)(eY.FileText,{className:"w-4 h-4 text-blue-500 shrink-0"}),(0,t.jsx)("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Transcript"}),(0,t.jsxs)("span",{className:"text-[10px] text-gray-400 dark:text-white/30 ml-auto",children:[r.transcript.split(/\s+/).length," words"]})]}),o&&(0,t.jsx)("div",{className:"px-4 pb-4 border-t border-gray-100 dark:border-white/[0.05]",children:(0,t.jsx)("p",{className:"text-xs text-gray-600 dark:text-white/60 leading-relaxed whitespace-pre-wrap pt-3",children:r.transcript})})]}),r.knowledge.length>0&&(0,t.jsxs)("div",{className:"rounded-xl border border-gray-200 dark:border-white/[0.08] bg-white dark:bg-white/[0.02] overflow-hidden",children:[(0,t.jsxs)("button",{onClick:()=>m(e=>!e),className:"w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-gray-50 dark:hover:bg-white/[0.03] transition-colors",children:[c?(0,t.jsx)(eH.ChevronDown,{className:"w-4 h-4 text-gray-400 dark:text-white/40 shrink-0"}):(0,t.jsx)(Q.ChevronRight,{className:"w-4 h-4 text-gray-400 dark:text-white/40 shrink-0"}),(0,t.jsx)(eJ.Lightbulb,{className:"w-4 h-4 text-amber-500 shrink-0"}),(0,t.jsx)("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Extracted Knowledge"}),(0,t.jsxs)("span",{className:"text-[10px] text-gray-400 dark:text-white/30 ml-auto",children:[r.knowledge.length," topic",1!==r.knowledge.length?"s":""]})]}),c&&(0,t.jsx)("div",{className:"border-t border-gray-100 dark:border-white/[0.05] divide-y divide-gray-100 dark:divide-white/[0.05]",children:r.knowledge.map((e,a)=>(0,t.jsxs)("div",{className:"px-4 py-3",children:[(0,t.jsx)("h4",{className:"text-xs font-semibold text-gray-800 dark:text-white/80 mb-1",children:e.topic}),(0,t.jsx)("p",{className:"text-[11px] text-gray-500 dark:text-white/50 mb-2",children:e.details}),e.keyPoints.length>0&&(0,t.jsx)("ul",{className:"space-y-0.5",children:e.keyPoints.map((e,a)=>(0,t.jsxs)("li",{className:"text-[11px] text-gray-600 dark:text-white/60 flex items-start gap-1.5",children:[(0,t.jsx)("span",{className:"text-primary mt-0.5",children:"â¢"}),e]},a))})]},a))})]})]});return(0,t.jsx)(ew,{listingId:e,initialArticles:u,source:"media",onSaved:n,onBack:l,savedTitles:s,headerContent:h,renderArticleFooter:({article:e,idx:r,updateArticle:s})=>a?(0,t.jsxs)("div",{className:"px-4 pb-3 flex items-center gap-2 border-t border-gray-100 dark:border-white/[0.05] pt-2",children:[(0,t.jsx)("button",{onClick:()=>s(r,{includeVideo:!e.includeVideo}),className:(0,F.cn)("relative w-8 h-[18px] rounded-full transition-colors focus:outline-none",e.includeVideo?"bg-green-500":"bg-gray-300 dark:bg-white/[0.15]"),children:(0,t.jsx)("div",{className:(0,F.cn)("absolute top-[2px] w-[14px] h-[14px] rounded-full bg-white shadow-sm transition-transform",e.includeVideo?"left-[16px]":"left-[2px]")})}),(0,t.jsx)(eE.Video,{className:"w-3.5 h-3.5 text-gray-400 dark:text-white/40"}),(0,t.jsx)("span",{className:"text-[11px] text-gray-500 dark:text-white/40",children:"Embed video in article"})]}):null,processContentBeforeSave:e=>e.includeVideo&&a?`<div data-type="video-embed" src="${a}" provider="upload"></div>`+e.content:e.content})}let eX="https://api.vanio.ai",eZ=e=>fetch(e,{credentials:"include"}).then(e=>{if(!e.ok)throw Error("Failed to fetch");return e.json()});function e0({listingId:e,listingName:a}){let{currentCustomerId:r}=(0,v.useCustomer)(),s=(0,i.useRef)(null),[n,l]=(0,i.useState)([]),[o,d]=(0,i.useState)(!1),[c,m]=(0,i.useState)("upload"),[u,h]=(0,i.useState)(null),[x,g]=(0,i.useState)(new Map),[p,b]=(0,i.useState)(null),[f,y]=(0,i.useState)(null),[w,k]=(0,i.useState)(),[j,N]=(0,i.useState)(null),C=r&&e?`${eX}/kb/media/video-analyses?customerId=${r}&listingId=${e}`:null,{data:S,mutate:E}=(0,U.default)(C,eZ),I=S?.analyses||[],T=r&&e?`${eX}/kb/media/videos?customerId=${r}&listingId=${e}`:null,{data:_}=(0,U.default)(T,eZ),A=(0,i.useRef)(!1);(0,i.useEffect)(()=>
1{if(A.current||!_?.videos?.length||!S)return;A.current=!0;let e=new Set(I.map(e=>e.videoUrl)),t=_.videos.filter(t=>!e.has(t.url)).map(e=>({type:"upload",url:e.url,fileName:e.fileName,fileSize:e.fileSize,mimeType:e.mimeType}));t.length>0&&l(e=>{let a=new Set(e.map(e=>e.url)),r=t.filter(e=>!a.has(e.url));return r.length>0?[...e,...r]:e})},[_,S,I]);let D=r&&e?`${eX}/kb/items?customerId=${r}&listingId=${e}&limit=200`:null,{data:P,mutate:R}=(0,U.default)(D,eZ),M=new Set((P?.items||[]).map(e=>(e.title||"").toLowerCase())),L=(0,i.useCallback)(async t=>{if(t&&0!==t.length){for(let a of(d(!0),b(null),Array.from(t)))if(a.type.startsWith("video/")){if(a.size>524288e3){b(`${a.name} is too large (${(a.size/1024/1024).toFixed(0)} MB). Maximum 500 MB.`);continue}try{let t=await fetch(`/api/kb/media/upload-video?customerId=${r}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileName:a.name,fileType:a.type,fileSize:a.size,listingId:String(e)})});if(!t.ok){let e=await t.json().catch(()=>({error:"Upload failed"}));throw Error(e.error||"Upload failed")}let{signedUrl:s,token:i,publicUrl:n}=await t.json();if(!(await fetch(s,{method:"PUT",headers:{"Content-Type":a.type},body:a})).ok)throw Error("Direct upload failed");l(e=>[...e,{type:"upload",url:n,fileName:a.name,fileSize:a.size,mimeType:a.type}])}catch(e){b(e.message)}}d(!1)}},[e,r]),$=(0,i.useCallback)((e,t)=>{l(a=>a.map((a,r)=>r===e?{...a,contextHint:t}:a))},[]),O=(0,i.useCallback)(e=>{l(t=>t.filter((t,a)=>a!==e)),g(t=>{let a=new Map(t);return a.delete(e),a})},[]),B=(0,i.useCallback)(async t=>{let s=n[t];if(s){h(t),b(null);try{let i=await fetch(`${eX}/kb/media/analyze-video?customerId=${r}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({listingId:e,listingName:a,videoUrl:s.url,videoType:s.type,contextHint:s.contextHint||void 0,fileName:s.fileName||void 0})});if(!i.ok){let e=await i.json().catch(()=>({error:"Analysis failed"}));throw Error(e.error||"Analysis failed")}let n=await i.json();g(e=>new Map(e).set(t,n)),y(t),k(s.url),N(n),m("review"),E()}catch(e){b(e.message)}finally{h(null)}}},[n,e,a,r,E]),q=(0,i.useCallback)(e=>{let t={transcript:e.transcript||"",knowledge:e.knowledge||[],articles:(e.articles||[]).map(e=>({...e,source:"media",approved:!1}))};k(e.videoUrl),N(t),m("review")},[]);return"review"===c&&j?(0,t.jsx)(eQ,{listingId:e,videoUrl:w,result:j,savedTitles:M,onSaved:()=>{m("upload"),N(null),k(void 0),y(null),E(),R()},onBack:()=>{m("upload"),N(null),k(void 0),y(null)}}):(0,t.jsxs)("div",{className:"space-y-5",children:[(0,t.jsxs)("div",{onClick:()=>s.current?.click(),className:(0,F.cn)("rounded-xl border-2 border-dashed p-8 text-center cursor-pointer transition-all","border-gray-200 dark:border-white/[0.1] hover:border-primary/50 hover:bg-gray-50 dark:hover:bg-white/[0.02]"),children:[(0,t.jsx)("div",{className:"flex flex-col items-center gap-3",children:o?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Y.Loader2,{className:"w-8 h-8 text-primary animate-spin"}),(0,t.jsx)("p",{className:"text-sm text-gray-600 dark:text-white/60",children:"Uploading video..."})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"p-3 rounded-full bg-gray-100 dark:bg-white/[0.05]",children:(0,t.jsx)(e_.Upload,{className:"w-6 h-6 text-gray-400 dark:text-white/40"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium text-gray-700 dark:text-white/70",children:"Drop video files here or click to browse"}),(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-white/30 mt-1",children:"MP4, MOV, or WebM · Max 500 MB · Max 5 minutes"})]})]})}),(0,t.jsx)("input",{ref:s,type:"file",className:"hidden",accept:"video/mp4,video/quicktime,video/webm",multiple:!0,onChange:e=>L(e.target.files)})]}),p&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs text-red-500 bg-red-500/10 rounded-lg px-3 py-2",children:[(0,t.jsx)(et.X,{className:"w-3.5 h-3.5 shrink-0"}),(0,t.jsx)("span",{children:p})]}),n.length>0&&(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("h4",{className:"text-xs font-medium text-gray-700 dark:text-white/70",children:["Videos (",n.length,")"]}),n.map((e,a)=>{var r;return(0,t.jsxs)("div",{className:"rounded-xl border border-gray-200 dark:border-white/[0.08] bg-white dark:bg-white/[0.02] overflow-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 p-3",children:[(0,t.jsx)("div",{className:"w-24 h-16 rounded-lg overflow-hidden bg-gray-100 dark:bg-white/[0.05] flex items-center justify-center shrink-0",children:"upload"===e.type?(0,t.jsx)("video",{src:e.url,className:"w-full h-full object-cover",muted:!0,preload:"metadata"}):(0,t.jsx)(eE.Video,{className:"w-6 h-6 text-gray-400 dark:text-white/30"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("p",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:e.fileName||e.url}),(0,t.jsxs)("div",{className:"flex items-center gap-2 mt-0.5",children:[(0,t.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-gray-100 dark:bg-white/[0.05] text-gray-500 dark:text-white/40",children:e.type}),e.fileSize&&(0,t.jsx)("span",{className:"text-[10px] text-gray-400 dark:text-white/30",children:(r=e.fileSize)<1048576?`${(r/1024).toFixed(0)} KB`:`${(r/1048576).toFixed(1)} MB`})]}),x.has(a)&&(0,t.jsxs)("p",{className:"text-[10px] text-green-600 dark:text-green-400 mt-1",children:["Analyzed â ",x.get(a).articles.length," articles generated"]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[u===a?(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs text-primary",children:[(0,t.jsx)(Y.Loader2,{className:"w-4 h-4 animate-spin"}),(0,t.jsx)("span",{children:"Processing..."})]}):x.has(a)?(0,t.jsx)(ei.Button,{variant:"outline",size:"sm",onClick:()=>{k(n[a]?.url),N(x.get(a)),m("review")},className:"text-xs h-8 gap-1.5",children:"Review"}):(0,t.jsxs)(ei.Button,{size:"sm",onClick:()=>B(a),className:"text-xs h-8 gap-1.5",children:[(0,t.jsx)(X.Sparkles,{className:"w-3.5 h-3.5"}),"Process"]}),(0,t.jsx)("button",{onClick:()=>O(a),className:"p-1.5 rounded-lg text-gray-400 dark:text-white/30 hover:text-red-500 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-500/10 transition-colors",children:(0,t.jsx)(eK.Trash2,{className:"w-4 h-4"})})]})]}),!x.has(a)&&(0,t.jsx)("div",{className:"px-3 pb-3",children:(0,t.jsx)("input",{type:"text",value:e.contextHint||"",onChange:e=>$(a,e.target.value),placeholder:"What does this video show? (e.g. trash area, lockbox, thermostat)",className:(0,F.cn)("w-full px-3 py-1.5 text-xs rounded-lg border transition-colors","border-gray-200 dark:border-white/[0.06] bg-gray-50 dark:bg-white/[0.03]","text-gray-700 dark:text-white/70 placeholder:text-gray-400 dark:placeholder:text-white/25","focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary/30")})})]},a)})]}),n.length>0&&n.some((e,t)=>!x.has(t))&&(0,t.jsx)("div",{className:"sticky bottom-0 py-3 -mx-4 md:-mx-6 lg:-mx-8 px-4 md:px-6 lg:px-8 bg-white dark:bg-[#1D1D1F] border-t border-gray-200 dark:border-white/[0.08]",children:(0,t.jsxs)("div",{className:"flex items-center justify-between max-w-4xl mx-auto",children:[(0,t.jsxs)("p",{className:"text-xs text-gray-600 dark:text-white/50",children:[n.length," video",1!==n.length?"s":""," ready to process"]}),(0,t.jsxs)(ei.Button,{onClick:()=>{let e=n.findIndex((e,t)=>!x.has(t));e>=0&&B(e)},disabled:null!==u,className:"gap-2",children:[(0,t.jsx)(X.Sparkles,{className:"w-4 h-4"}),"Process Videos",(0,t.jsx)(eA.ArrowRight,{className:"w-4 h-4"})]})]})}),I.length>0&&(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(eD.Clock,{className:"w-3.5 h-3.5 text-gray-400 dark:text-white/40"}),(0,t.jsx)("h4",{className:"text-xs font-medium text-gray-600 dark:text-white/50",children:"Previous Analyses"})]}),I.map(e=>(0,t.jsxs)("button",{onClick:()=>q(e),className:(0,F.cn)("w-full flex items-center gap-3 p-3 rounded-xl border text-left transition-all","border-gray-200 dark:border-white/[0.06] bg-white dark:bg-white/[0.01]","hover:border-gray-300 dark:hover:border-white/[0.12] hover:bg-gray-50 dark:hover:bg-white/[0.03]"),children:[(0,t.jsx)("div",{className:"w-10 h-10 rounded-lg bg-gray-100 dark:bg-white/[0.05] flex items-center justify-center shrink-0 overflow-hidden",children:e.thumbnailUrl?(0,t.jsx)("img",{src:e.thumbnailUrl,alt:"",className:"w-full h-full object-cover"}):(0,t.jsx)(eY.FileText,{className:"w-4 h-4 text-gray-400 dark:text-white/30"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("p",{className:"text-xs font-medium text-gray-700 dark:text-white/70 truncate",children:e.contextHint||e.fileName||"Video analysis"}),e.savedArticleCount>0&&e.savedArticleCount>=e.articleCount&&(0,t.jsxs)("span",{className:"flex items-center gap-1 text-[10px] font-medium text-green-600 dark:text-green-400 bg-green-500/10 px-1.5 py-0.5 rounded-full shrink-0",children:[(0,t.jsx)(es.CheckCircle2,{className:"w-3 h-3"}),"Saved"]}),e.savedArticleCount>0&&e.savedArticleCount<e.articleCount&&(0,t.jsxs)("span",{className:"text-[10px] font-medium text-amber-600 dar
1k:text-amber-400 bg-amber-500/10 px-1.5 py-0.5 rounded-full shrink-0",children:[e.savedArticleCount,"/",e.articleCount," saved"]})]}),(0,t.jsxs)("p",{className:"text-[10px] text-gray-400 dark:text-white/30 mt-0.5",children:[e.fileName&&e.contextHint?`${e.fileName} \u00b7 `:"",e.articleCount," article",1!==e.articleCount?"s":""," ·"," ",e.knowledgeCount," topic",1!==e.knowledgeCount?"s":""," ·"," ",new Date(e.createdAt).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})]})]}),(0,t.jsx)(eA.ArrowRight,{className:"w-4 h-4 text-gray-300 dark:text-white/20 shrink-0"})]},e.id))]}),0===n.length&&!o&&0===I.length&&(0,t.jsx)("div",{className:"text-center py-4",children:(0,t.jsxs)("p",{className:"text-xs text-gray-400 dark:text-white/30",children:["Upload walkthrough videos showing lockbox, doors, thermostat, appliances, etc.",(0,t.jsx)("br",{}),"AI will transcribe and extract property knowledge automatically."]})})]})}var e1=e.i(572812);let e2="https://api.vanio.ai",e5=e=>fetch(e,{credentials:"include"}).then(e=>{if(!e.ok)throw Error("Failed to fetch");return e.json()});function e4({listingId:e,listingName:a,onBack:r}){let{currentCustomerId:s}=(0,v.useCustomer)(),[n,l]=(0,i.useState)(()=>"photos"===(0,e1.getTrainSubParams)().tab?"photos":"videos"),[o,d]=(0,i.useState)("select"),[c,m]=(0,i.useState)([]),[u,h]=(0,i.useState)(null),[x,g]=(0,i.useState)(null),[p,b]=(0,i.useState)(new Set);(0,i.useEffect)(()=>{(0,e1.setTrainSubParams)({tab:n,method:"media"})},[n]);let f=s&&e?`${e2}/kb/items?customerId=${s}&listingId=${e}&limit=200&status=active`:null,{data:y,mutate:w}=(0,U.default)(f,e5),k=new Set((y?.items||[]).map(e=>(e.title||"").toLowerCase())),j=(y?.items||[]).filter(e=>"media"===e.source).length,N=(0,i.useCallback)(async t=>{m(t),d("analyzing"),g(null);try{let r=await fetch(`${e2}/kb/media/analyze-photos?customerId=${s}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({listingId:e,listingName:a,photos:t.map(e=>({url:e.url,caption:e.caption,roomType:e.roomType,contextHint:"upload"===e.source?e.caption:void 0,source:e.source}))})});if(!r.ok){let e=await r.json().catch(()=>({error:"Analysis failed"})),t=[e.error||"Analysis failed"],a=Array.isArray(e.failures)?e.failures:[];a.length>0&&(t.push("","Photo fetch failures:"),a.slice(0,3).forEach(e=>t.push(` ⢠[${e.reason}] ${e.url}`)),a.length>3&&t.push(` â¦and ${a.length-3} more`));let s=Array.isArray(e.visionErrors)?e.visionErrors:[];throw s.length>0&&(t.push("","Model errors:"),s.forEach(e=>t.push(` ⢠[${e.model}] ${e.error}`))),e.mediaTypesUsed&&Array.isArray(e.mediaTypesUsed)&&t.push("",`MIME types sent: ${e.mediaTypesUsed.join(", ")}`),"number"==typeof e.photoCount&&t.push(`Photos: ${e.photoCount}`),Error(t.join("\n"))}let i=await r.json();h(i),b(e=>{let a=new Set(e);return t.forEach(e=>a.add(e.id)),a}),d("review")}catch(e){console.error("[MediaIntake] Photo analysis error:",e),g(e.message),d("select")}},[s,e,a]),C=(0,i.useCallback)(()=>{d("select"),h(null)},[]),S=(0,i.useCallback)(()=>{d("select"),h(null),w(),window.dispatchEvent(new CustomEvent("kb:refresh"))},[w]),E=(0,i.useCallback)(e=>{h(e),d("review")},[]),I=[{id:"videos",label:"Videos",icon:eE.Video},{id:"photos",label:"Photos",icon:ee.Camera}];return"review"===o&&u?(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)(ei.Button,{variant:"ghost",size:"sm",onClick:C,className:"text-xs text-gray-500 dark:text-white/50 hover:text-gray-700 dark:hover:text-white/70 gap-1.5 -ml-2",children:[(0,t.jsx)(eI.ArrowLeft,{className:"w-3.5 h-3.5"}),"Back to Photos"]}),(0,t.jsx)(eW,{listingId:e,result:u,savedTitles:k,onSaved:S,onBack:C})]}):"analyzing"===o?(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)(ei.Button,{variant:"ghost",size:"sm",onClick:()=>d("select"),className:"text-xs text-gray-500 dark:text-white/50 hover:text-gray-700 dark:hover:text-white/70 gap-1.5 -ml-2",children:[(0,t.jsx)(eI.ArrowLeft,{className:"w-3.5 h-3.5"}),"Cancel"]}),(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 space-y-4",children:[(0,t.jsx)(Y.Loader2,{className:"w-8 h-8 text-primary animate-spin"}),(0,t.jsxs)("div",{className:"text-center space-y-1",children:[(0,t.jsxs)("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:["Analyzing ",c.length," photo",1!==c.length?"s":"","..."]}
1),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/50",children:"Vanio AI is identifying rooms, amenities, and extracting knowledge"})]})]})]}):(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsxs)(ei.Button,{variant:"ghost",size:"sm",onClick:r,className:"text-xs text-gray-500 dark:text-white/50 hover:text-gray-700 dark:hover:text-white/70 gap-1.5 -ml-2 shrink-0",children:[(0,t.jsx)(eI.ArrowLeft,{className:"w-3.5 h-3.5"}),"Back"]}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(X.Sparkles,{className:"w-4 h-4 text-primary shrink-0"}),(0,t.jsx)("h2",{className:"text-sm font-semibold text-gray-900 dark:text-white truncate",children:"Media Analysis"})]}),(0,t.jsx)("p",{className:"text-[11px] text-gray-500 dark:text-white/40 mt-0.5",children:"Vanio AI extracts property knowledge from your photos and videos"})]})]}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-2",children:I.map(e=>{let a=n===e.id;return(0,t.jsxs)("button",{onClick:()=>l(e.id),className:(0,F.cn)("flex items-center gap-2.5 px-4 py-3 rounded-xl border text-left transition-all",a?"border-primary/30 bg-primary/[0.04] dark:bg-primary/[0.08]":"border-gray-200 dark:border-white/[0.08] bg-white dark:bg-white/[0.02] hover:border-gray-300 dark:hover:border-white/[0.12]"),children:[(0,t.jsx)("div",{className:(0,F.cn)("w-8 h-8 rounded-lg flex items-center justify-center shrink-0",a?"bg-primary/10 text-primary":"bg-gray-100 dark:bg-white/[0.05] text-gray-400 dark:text-white/40"),children:(0,t.jsx)(e.icon,{className:"w-4 h-4"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:(0,F.cn)("text-sm font-medium",a?"text-gray-900 dark:text-white":"text-gray-600 dark:text-white/60"),children:e.label}),(0,t.jsx)("p",{className:"text-[10px] text-gray-400 dark:text-white/30",children:"photos"===e.id?"Analyze property photos":"Process walkthrough videos"})]})]},e.id)})}),x&&(0,t.jsx)("div",{className:"flex items-center gap-2 text-xs text-red-500 bg-red-500/10 rounded-lg px-3 py-2",children:(0,t.jsx)("span",{children:x})}),"photos"===n&&(0,t.jsx)(eq,{listingId:e,onAnalyze:N,onLoadAnalysis:E,mediaArticleCount:j,sessionAnalyzedIds:p}),"videos"===n&&(0,t.jsx)(e0,{listingId:e,listingName:a})]})}var e3=e.i(565365),e6=e.i(39312);let e8="https://api.vanio.ai",e9={extracting:"Extracting conversations...",analyzing:"Analyzing guest questions & topics...",generating:"Generating knowledge articles...",deduplicating:"Preparing draft articles..."},e7=["extracting","analyzing","generating","deduplicating"];function te({listingId:e,listingName:a,conversationCount:r,hasHistory:s,isTrained:n,categories:l,onComplete:o,onBack:d}){let[c,m]=(0,i.useState)("ready"),[u,h]=(0,i.useState)([]),[x,g]=(0,i.useState)(0),[p,b]=(0,i.useState)(null),[f,y]=(0,i.useState)(!1),w=(0,i.useRef)(null),v=l.reduce((e,t)=>e+t.articleCount,0),k=l.filter(e=>"empty"===e.status);(0,i.useEffect)(()=>()=>{w.current&&clearTimeout(w.current)},[]);let j=(0,i.useCallback)(()=>{let e=[3e3,8e3,12e3,5e3],t=0,a=()=>{t<e7.length&&(m(e7[t]),w.current=setTimeout(a,e[++t-1]||5e3))};a()},[]),N=(0,i.useCallback)(async()=>{m("extracting"),b(null),h([]),j();try{let t=await fetch(`${e8}/ai-kb/train`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({listingId:e,dryRun:!0})});if(w.current&&clearTimeout(w.current),!t.ok){let e=await t.json().catch(()=>({error:"Mining failed"}));throw Error(e.error||"Mining failed")}let a=await t.json(),r=a.miningResult?.articles||[],s=a.miningResult?.conversationsProcessed??0;if(0===r.length){g(s),m("too-few");return}let i=r.map(e=>({title:e.title||"",category:e.category||"",content:e.content||"",source:"mining",approved:!0}));h(i),m("review")}catch(e){w.current&&clearTimeout(w.current),m("error"),b(e.message)}},[e,j]),C=(0,i.useCallback)(async t=>{if(0!==t){y(!0);try{await fetch(`${e8}/ai-kb/train`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({listingId:e,skipMining:!0})})}catch(e){console.error("[MiningInterface] Failed to mark trained:",e)}finally{y(!1)}}},[e]),S=(0,i.useCallback)(()=>{o(),m("done")},[o]),E=["extracting","analyzing","generating","deduplicating"].includes(c),I=e7.indexOf(c);return"review"===c&&u.length>0?(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(ei.Button,{variant:"ghost",size:"sm",onClick:()=>m("ready"),children:(0,t.jsx)(eI.ArrowLeft,{className:"w-4 h-4"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Review Mined Articles"}),(0,t.jsxs)("p",{className:"text-[11px] text-gray-500 dark:text-white/40",children:[u.length," articles extracted from conversations â review before saving"]})]})]}
1),(0,t.jsx)(ew,{listingId:e,initialArticles:u,source:"history",onSaved:S,onBack:()=>m("ready"),onAfterSave:C})]}):(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(ei.Button,{variant:"ghost",size:"sm",onClick:d,disabled:E,children:(0,t.jsx)(eI.ArrowLeft,{className:"w-4 h-4"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Conversation Mining"}),(0,t.jsx)("p",{className:"text-[11px] text-gray-500 dark:text-white/40",children:"Extract knowledge from guest conversations"})]})]}),(0,t.jsxs)("div",{className:"rounded-xl border border-gray-200 dark:border-white/[0.08] bg-white dark:bg-white/[0.02] overflow-hidden",children:[(0,t.jsx)("div",{className:"px-4 py-3 border-b border-gray-100 dark:border-white/[0.05]",children:(0,t.jsx)("h4",{className:"text-xs font-medium text-gray-700 dark:text-white/70",children:"Data Sources"})}),(0,t.jsxs)("div",{className:"p-4 space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:(0,F.cn)("w-8 h-8 rounded-lg flex items-center justify-center shrink-0",s?"bg-blue-500/10":"bg-gray-100 dark:bg-white/[0.05]"),children:(0,t.jsx)(e3.MessageSquareText,{className:(0,F.cn)("w-4 h-4",s?"text-blue-500":"text-gray-400 dark:text-white/30")})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("p",{className:"text-sm text-gray-900 dark:text-white",children:"Guest Conversations"}),(0,t.jsx)("p",{className:"text-[11px] text-gray-500 dark:text-white/40",children:s?`${r.toLocaleString()} conversation${1!==r?"s":""} available`:r>0?`${r} conversation${1!==r?"s":""} â minimum 5 needed for mining`:"No conversation history yet"})]}),s&&(0,t.jsx)(es.CheckCircle2,{className:"w-4 h-4 text-green-500 shrink-0"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center shrink-0 bg-violet-500/10",children:(0,t.jsx)(el.BookOpen,{className:"w-4 h-4 text-violet-500"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("p",{className:"text-sm text-gray-900 dark:text-white",children:"Current Knowledge Base"}),(0,t.jsxs)("p",{className:"text-[11px] text-gray-500 dark:text-white/40",children:[v," article",1!==v?"s":""," across"," ",l.length-k.length," categories",k.length>0&&` \xb7 ${k.length} empty`]})]}),n&&(0,t.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-600 dark:text-amber-400",children:"Previously mined"})]})]})]}),"ready"===c&&(0,t.jsxs)("div",{className:"rounded-xl border border-gray-200 dark:border-white/[0.08] bg-white dark:bg-white/[0.02] p-4",children:[(0,t.jsx)("h4",{className:"text-xs font-medium text-gray-700 dark:text-white/70 mb-3",children:"What happens during mining?"}),(0,t.jsx)("div",{className:"space-y-2.5",children:[{icon:e3.MessageSquareText,label:"Extract guest-host conversations",desc:"Pull all messages from dashboard threads"},{icon:e6.Zap,label:"AI analyzes topics & patterns",desc:"Identify recurring questions and key property info"},{icon:eY.FileText,label:"Generate knowledge articles",desc:"Create structured articles by category"},{icon:el.BookOpen,label:"Review & save",desc:"Review draft articles, edit, then save to knowledge base"}].map((e,a)=>(0,t.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,t.jsx)("div",{className:"w-5 h-5 rounded flex items-center justify-center bg-gray-100 dark:bg-white/[0.05] shrink-0 mt-0.5",children:(0,t.jsx)(e.icon,{className:"w-3 h-3 text-gray-500 dark:text-white/40"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs font-medium text-gray-700 dark:text-white/70",children:e.label}),(0,t.jsx)("p",{className:"text-[11px] text-gray-500 dark:text-white/40",children:e.desc})]})]},a))}),n&&(0,t.jsx)("div",{className:"mt-4 pt-3 border-t border-gray-100 dark:border-white/[0.05]",children:(0,t.jsx)("p",{className:"text-[11px] text-amber-600 dark:text-amber-400 leading-relaxed",children:"This property was previously mined. Re-mining will generate fresh articles from the latest conversations for you to review."})})]}),E&&(0,t.jsxs)("div",{className:"rounded-xl border border-primary/30 bg-primary/[0.02] p-4",children:[(0,t.jsx)("div",{className:"space-y-1",children:e7.map((e,a)=>{let r=e===c,s=I>a;return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:(0,F.cn)("w-7 h-7 rounded-full flex items-center justify-center shrink-0 transition-all",s?"bg-green-500 text-white":r?"bg-blue-600 text-white ring-2 ring-blue-400/40 ring-offset-1 ring-offset-white dark:ring-offset-[#1D1D1F]":"bg-gray-200 dark:bg-white/[0.08]"),children:s?(0,t.jsx)(es.CheckCircle2,{className:"w-4 h-4"}):r?(0,t.jsx)(Y.Loader2,{className:"w-4 h-4 animate-spin"}):(0,t.jsx)("span",{className:"text-[11px] text-gray-500 dark:text-white/40 font-medium",children:a+1})}),(0,t.jsx)("span",{className:(0,F.cn)("text-sm transition-colors",s?"text-green-600 dark:text-green-400":r?"text-gray-900 dark:text-white font-medium":"text-gray-400 dark:text-white/30"),children:e9[e]})]}),a<e7.length-1&&(0,t.jsx)("div",{className:(0,F.cn)("w-0.5 h-3 ml-[13px] transition-colors",s?"bg-green-500":"bg-gray-200 dark:bg-white/[0.08]")})]},e)})}),(0,t.jsx)("p",{className:"text-[11px] text-gray-500 dark:text-white/40 mt-4",children:"This typically takes 1-2 minutes depending on conversation volume."})]}),"too-few"===c&&(0,t.jsx)("div",{className:"rounded-xl border border-amber-200 dark:border-amber-500/20 bg-amber-50/50 dark:bg-amber-500/[0.03] p-4",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)(er.Info,{className:"w-5 h-5 text-amber-500 shrink-0 mt-0.5"}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("h4",{className:"text-sm font-semibold text-gray-900 dark:text-white mb-1",children:"Not enough conversations"}),(0,t.jsx)("p",{className:"text-xs text-gray-600 dark:text-white/60 leading-relaxed mb-3",children:x>0?`Only ${x} conversation${1!==x?"s":""} found with meaningful guest-host exchanges. Mining needs at least 5 conversations to identify patterns and generate useful articles.`:"No conversations with meaningful guest-host exchanges were found."}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/50 mb-3",children:"Try these alternatives to build your knowledge base:"}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsxs)(ei.Button,{size:"sm",variant:"outline",className:"text-xs h-8 gap-1.5",onClick:d,children:[(0,t.jsx)(K.ClipboardList,{className:"w-3.5 h-3.5"}),"Use Questionnaire"]}),(0,t.jsxs)(ei.Button,{size:"sm",variant:"outline",className:"text-xs h-8 gap-1.5",onClick:d,children:[(0,t.jsx)(eT.ImagePlus,{className:"w-3.5 h-3.5"}),"Upload Media"]})]})]})]})}),"done"===c&&(0,t.jsx)("div",{className:"rounded-xl border border-green-200 dark:border-green-500/20 bg-green-50/50 dark:bg-green-500/[0.03] p-4",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)(es.CheckCircle2,{className:"w-5 h-5 text-green-500 shrink-0 mt-0.5"}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("h4",{className:"text-sm font-semibold text-gray-900 dark:text-white mb-1",children:"Mining Complete"}),(0,t.jsxs)("p",{className:"text-xs text-gray-600 dark:text-white/60",children:["Articles have been saved to your knowledge base.",f&&" Consolidating group knowledge..."]})]})]})}),"error"===c&&(0,t.jsx)("div",{className:"rounded-xl border border-red-200 dark:border-red-500/20 bg-red-50/50 dark:bg-red-500/[0.03] p-4",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)(eP.AlertTriangle,{className:"w-5 h-5 text-red-500 shrink-0 mt-0.5"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h4",{className:"text-sm font-semibold text-gray-900 dark:text-white mb-1",children:"Mining Failed"}),(0,t.jsx)("p",{className:"text-xs text-gray-600 dark:text-white/60",children:p||"An unexpected error occurred. Please try again."})]})]})}),(0,t.jsxs)("div",{className:"flex items-center justify-between pt-2",children:[(0,t.jsxs)(ei.Button,{variant:"ghost",size:"sm",onClick:d,disabled:E,children:[(0,t.jsx)(eI.ArrowLeft,{className:"w-4 h-4 mr-1"}),"Back"]}),"ready"===c&&(0,t.jsxs)(ei.Button,{onClick:N,disabled:!s,className:"gap-2",children:[(0,t.jsx)(e6.Zap,{className:"w-4 h-4"}),n?"Re-mine Conversations":"Start Mining"]}),("done"===c||"too-few"===c)&&(0,t.jsx)(ei.Button,{onClick:d,className:"gap-2",children:"Continue"}),"error"===c&&(0,t.jsx)(ei.Button,{variant:"outline",onClick:()=>m("ready"),className:"gap-2",children:"Try Again"})]})]})}var tt=e.i(143527),ta=e.i(319032),ta=ta;let tr=(0,ef.getClientApiBase)();function ts({listingId:e,customerId:a,onBack:r,onArticlesCreated:s}
1){let[n,l]=(0,i.useState)("file"),[o,d]=(0,i.useState)(!1),[c,m]=(0,i.useState)(null),[u,h]=(0,i.useState)(null),[x,g]=(0,i.useState)(!1),p=(0,i.useRef)(null),[b,f]=(0,i.useState)(""),[y,w]=(0,i.useState)(""),v=b.length,k=v>3e4,j=v>0&&v<50,N=v>=25e3&&!k,C=v>=50&&!k&&!o,S=(0,i.useCallback)(async t=>{d(!0),m(null),h(null);let r=new FormData;r.append("file",t),r.append("listingId",String(e)),r.append("status","active");try{let e=await fetch(`${tr}/ai/training/upload?_dev_customerId=${a}`,{method:"POST",credentials:"include",body:r}),t=await e.json();if(!e.ok)return void m(t.error||"Upload failed");h({fileName:t.fileName,articles:t.articles||[]}),s?.()}catch(e){m(e instanceof Error?e.message:"Upload failed")}finally{d(!1)}},[e,a,s]),E=(0,i.useCallback)(async()=>{if(C){d(!0),m(null),h(null);try{let t=await fetch(`${tr}/ai/training/upload?_dev_customerId=${a}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({listingId:e,status:"active",text:b,sourceLabel:y.trim()||"Pasted notes"})}),r=await t.json();if(!t.ok)return void m(r.error||"Processing failed");h({fileName:r.fileName,articles:r.articles||[]}),s?.()}catch(e){m(e instanceof Error?e.message:"Processing failed")}finally{d(!1)}}},[C,e,a,b,y,s]),I=(0,i.useCallback)(e=>{e.preventDefault(),g(!1);let t=e.dataTransfer.files?.[0];t&&S(t)},[S]),T=(0,i.useCallback)(e=>{let t=e.target.files?.[0];t&&S(t)},[S]),_=(0,i.useCallback)(()=>{h(null),m(null),f(""),w("")},[]),A=(0,i.useMemo)(()=>v.toLocaleString(),[v]),D=(0,i.useMemo)(()=>3e4.toLocaleString(),[]);return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("button",{onClick:r,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.05] transition-colors",children:(0,t.jsx)(eI.ArrowLeft,{className:"w-4 h-4 text-gray-500 dark:text-white/40"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Upload Documents"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/40",children:"Upload house rules, SOPs, or guest guides â or paste text directly. Vanio AI extracts knowledge articles automatically."})]})]}),!u&&(0,t.jsxs)("div",{className:"inline-flex items-center gap-1 p-1 rounded-lg bg-gray-100 dark:bg-white/[0.04] border border-gray-200 dark:border-white/[0.06]",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>{o||(l("file"),m(null))},disabled:o,className:(0,F.cn)("flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-all","file"===n?"bg-white dark:bg-white/[0.08] text-gray-900 dark:text-white shadow-sm":"text-gray-500 dark:text-white/50 hover:text-gray-700 dark:hover:text-white/80",o&&"opacity-50 cursor-not-allowed"),children:[(0,t.jsx)(tt.FileUp,{className:"w-3.5 h-3.5"}),"Upload file"]}),(0,t.jsxs)("button",{type:"button",onClick:()=>{o||(l("paste"),m(null))},disabled:o,className:(0,F.cn)("flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-all","paste"===n?"bg-white dark:bg-white/[0.08] text-gray-900 dark:text-white shadow-sm":"text-gray-500 dark:text-white/50 hover:text-gray-700 dark:hover:text-white/80",o&&"opacity-50 cursor-not-allowed"),children:[(0,t.jsx)(ta.default,{className:"w-3.5 h-3.5"}),"Paste content"]})]}),!u&&"file"===n&&(0,t.jsxs)("div",{onDragOver:e=>{e.preventDefault(),g(!0)},onDragLeave:()=>g(!1),onDrop:I,onClick:()=>!o&&p.current?.click(),className:(0,F.cn)("relative flex flex-col items-center justify-center rounded-xl border-2 border-dashed p-8 transition-all cursor-pointer",o&&"pointer-events-none opacity-60",x?"border-primary bg-primary/[0.03] dark:bg-primary/[0.05]":"border-gray-300 dark:border-white/[0.12] hover:border-primary/50 dark:hover:border-primary/40 bg-gray-50/50 dark:bg-white/[0.01]"),children:[(0,t.jsx)("input",{ref:p,type:"file",accept:".pdf,.txt,.md,.docx",onChange:T,className:"hidden"}),o?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Y.Loader2,{className:"w-8 h-8 text-primary animate-spin mb-3"}),(0,t.jsx)("p",{className:"text-sm font-medium text-gray-700 dark:text-white/70",children:"Processing document..."}),(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-white/30 mt-1",children:"Vanio AI is extracting knowledge articles"})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(tt.FileUp,{className:(0,F.cn)("w-8 h-8 mb-3",x?"text-primary":"text-gray-400 dark:text-white/30")}),(0,t.jsx)("p",{className:"text-sm font-medium text-gray-700 dark:text-white/70",children:"Drop a document here or click to browse"}),(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-white/30 mt-1",children:"Supports PDF, TXT, DOCX, Markdown"})]})]}),!u&&"paste"===n&&(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("label",{className:"text-xs font-medium text-gray-700 dark:text-white/70",children:["Source label ",(0,t.jsx)("span",{className:"text-gray-400 dark:text-white/30 font-normal",children:"(optional)"})]}),(0,t.jsx)("input",{type:"text",value:y,onChange:e=>w(e.target.value),placeholder:"Pasted notes",disabled:o,maxLength:120,className:(0,F.cn)("w-full px-3 py-2 rounded-lg text-sm transition-colors","bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08]","text-gray-900 dark:text-white placeholder-gray-400 dark:placeholder-white/30","focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary/40","disabled:opacity-50 disabled:cursor-not-allowed")})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("p",{className:"text-xs text-gray-500 dark:text-white/50",children:["Up to ",D," characters. Markdown is supported â Vanio AI will preserve formatting."]}),(0,t.jsx)("textarea",{value:b,onChange:e=>f(e.target.value),placeholder:"Paste your content here. Markdown supp
1orted.\n\nExample:\n## WiFi\n- Network: HostHome\n- Password: Sunshine123\n\n## Parking\nUse spot #4 in the back lot.",disabled:o,rows:18,className:(0,F.cn)("w-full px-3 py-2.5 rounded-lg text-sm font-mono leading-relaxed transition-colors resize-y","bg-white dark:bg-white/[0.02] border",k?"border-red-400 dark:border-red-500/50":"border-gray-200 dark:border-white/[0.08]","text-gray-900 dark:text-white placeholder-gray-400 dark:placeholder-white/30","focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary/40","disabled:opacity-50 disabled:cursor-not-allowed")}),(0,t.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,t.jsxs)("span",{className:(0,F.cn)("transition-colors",k?"text-red-500":N?"text-amber-500 dark:text-amber-400":j?"text-gray-400 dark:text-white/30":"text-gray-500 dark:text-white/40"),children:[A," / ",D," chars",j&&" â minimum 50"]}),N&&(0,t.jsxs)("span",{className:"text-amber-500 dark:text-amber-400",children:["Approaching ",D," character limit"]}),k&&(0,t.jsxs)("span",{className:"text-red-500",children:["Exceeds ",D," character limit"]})]})]}),(0,t.jsx)("button",{type:"button",onClick:E,disabled:!C,className:(0,F.cn)("w-full flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg text-sm font-medium transition-all",C?"bg-primary text-white hover:bg-primary/90 shadow-sm":"bg-gray-100 dark:bg-white/[0.04] text-gray-400 dark:text-white/30 curs
1or-not-allowed"),children:o?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Y.Loader2,{className:"w-4 h-4 animate-spin"}),"Processing content..."]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ta.default,{className:"w-4 h-4"}),"Process"]})})]}),c&&(0,t.jsxs)("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-red-50 dark:bg-red-500/10 border border-red-200 dark:border-red-500/20",children:[(0,t.jsx)(et.X,{className:"w-4 h-4 text-red-500 shrink-0"}),(0,t.jsx)("p",{className:"text-sm text-red-600 dark:text-red-400",children:c})]}),u&&(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-emerald-50 dark:bg-emerald-500/10 border border-emerald-200 dark:border-emerald-500/20",children:[(0,t.jsx)(Z.Check,{className:"w-4 h-4 text-emerald-500 shrink-0"}),(0,t.jsxs)("p",{className:"text-sm text-emerald-600 dark:text-emerald-400",children:["Created ",u.articles.length," articles from â",u.fileName,"â"]})]}),(0,t.jsx)("div",{className:"space-y-1.5",children:u.articles.map(e=>(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.06]",children:[(0,t.jsx)(eY.FileText,{className:"w-3.5 h-3.5 text-gray-400 dark:text-white/30 shrink-0"}),(0,t.jsx)("span",{className:"text-sm text-gray-700 dark:text-white/70 flex-1 truncate",children:e.title}),(0,t.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-gray-100 dark:bg-white/[0.06] text-gray-500 dark:text-white/40 shrink-0",children:e.category})]},e.id))}),(0,t.jsx)("button",{onClick:_,className:"text-sm text-primary hover:underline",children:"paste"===n?"Paste more content":"Upload another document"})]})]})}let ti="https://api.vanio.ai",tn="training-modal:close",tl=e=>fetch(e,{credentials:"include"}).then(e=>{if(!e.ok)throw Error("Failed to fetch");return e.json()});function to(){let{isOpen:e,listingId:a,closeTraining:r}=(0,e1.useTrainingStore)(),{data:s}=(0,$.useSession)(),{listing:n,isLoading:l}=(0,O.useListing)(a??0),{currentCustomerId:o}=(0,v.useCustomer)(),[d,c]=(0,i.useState)(null),[m,u]=(0,i.useState)(null),[h,x]=(0,i.useState)(null),[g,p]=(0,i.useState)("assistant");(0,i.useEffect)(()=>{let e=()=>r();return window.addEventListener(tn,e),()=>window.removeEventListener(tn,e)},[r]),(0,i.useEffect)(()=>{if(e){let e=(0,e1.getTrainSubParams)();c(null),u("media"===e.method||"questionnaire"===e.method||"mining"===e.method?e.method:null),x(null),p("assistant")}},[e]),(0,i.useEffect)(()=>{e&&(0,e1.setTrainSubParams)({method:m||void 0})},[m,e]),(0,i.useEffect)(()=>{let e=e=>{e.detail&&e.detail.articles?.length?x(encodeURIComponent(JSON.stringify(e.detail.articles.map(e=>({title:e.title,category:e.category,content:e.content.slice(0,500)}))))):x(null)};return window.addEventListener("video-articles:update",e),()=>window.removeEventListener("video-articles:update",e)},[]);let b=o&&a?`/api/kb/categories?customerId=${o}&listingId=${a}`:null,{data:f,isLoading:y,mutate:w}=(0,U.default)(b,tl),k=o&&a?`/api/kb/training-status?customerId=${o}&listingId=${a}`:null,{data:j,isLoading:N,mutate:C}=(0,U.default)(k,tl),S=(f||[]).filter(e=>!en.HIDDEN_CATEGORIES.includes(e.name)).map(e=>({name:e.name,description:e.description||"",icon:e.icon||"",articleCount:e.count||0,status:e.count>=3?"complete":e.count>0?"partial":"empty"})),E=(0,i.useCallback)(e=>{c(t=>t===e?null:e),u(null)},[]),I=(0,i.useCallback)(e=>{u(e)},[]),T=(0,i.useCallback)(e=>{e&&c(e),u("questionnaire")},[]),_=(0,i.useCallback)(()=>{w(),C(),window.dispatchEvent(new CustomEvent("kb:refresh"))},[w,C]),A=(0,i.useCallback)(e=>{"refresh"===e.type&&(w(),window.dispatchEvent(new CustomEvent("kb:refresh")))},[w]);(0,i.useEffect)(()=>{let e=()=>w();return window.addEventListener("kb:refresh",e),()=>window.removeEventListener("kb:refresh",e)},[w]),(0,i.useEffect)(()=>{let e=()=>p("guest-demo");return window.addEventListener("training:switch-to-guest-demo",e),()=>window.removeEventListener("training:switch-to-guest-demo",e)},[]);let D=n?.name||"Property",P=(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"p-1.5 rounded-lg bg-primary/10",children:(0,t.jsx)(L.GraduationCap,{className:"w-4 h-4 text-primary"})}),(0,t.jsxs)("div",{className:"leading-tight",children:[(0,t.jsxs)("span",{className:"text-sm font-semibold text-gray-900 dark:text-white/90",children:["Train ",D]}),(0,t.jsx)("p",{className:"text-[11px] text-gray-500 dark:text-white/40",children:"Build knowledge for AI agent & guest portal"})]})]}),R="guest-demo"===g,M=R?"kb-guest-demo":"kb",B=a?h&&!R?`${ti}/chat/${M}/${a}?videoArticles=${h}`:`${ti}/chat/${M}/${a}`:"",K=a?(0,t.jsxs)("div",{className:"flex flex-col h-full",children:[(0,t.jsx)("div",{className:"px-3 pt-2 pb-0 shrink-0",children:(0,t.jsxs)("div",{className:"flex items-center rounded-lg bg-gray-100 dark:bg-white/[0.05] p-0.5",children:[(0,t.jsx)("button",{onClick:()=>p("assistant"),className:(0,F.cn)("flex-1 text-[11px] font-medium py-1.5 rounded-md transition-colors","assistant"===g?"bg-white dark:bg-white/[0.1] text-gray-900 dark:text-white shadow-sm":"text-gray-500 dark:text-white/40 hover:text-gray-700 dark:hover:text-white/60"),children:"Training Assistant"}),(0,t.jsx)("button",{onClick:()=>p("guest-demo"),className:(0,F.cn)("flex-1 text-[11px] font-medium py-1.5 rounded-md transition-colors","guest-demo"===g?"bg-white dark:bg-white/[0.1] text-gray-900 dark:text-white shadow-sm":"text-gray-500 dark:text-white/40 hover:text-gray-700 dark:hover:text-white/60"),children:"Guest Demo"})]})}),(0,t.jsx)("div",{className:"flex-1 min-h-0",children:(0,t.jsx)(z.VanioChat,{config:R?{apiEndpoint:B,subtitle:"Guest-facing preview",placeholder:"Ask a question as a guest would...",emptyHint:"Whatâs the WiFi password?",welcomeMessage:"Hi! ð Iâm your property concierge. Ask me anything about your stay â check-in, amenities, local tips, or house rules."}:{apiEndpoint:B,subtitle:h?"Video Article Assistant":"Training Assistant",placeholder:h?"Ask to rewrite, shorten, expand articles...":"Ask about this property, draft articles...",welcomeMessage:h?"I can see your video draft articles. I can:\n⢠Rewrite or improve any article\n⢠Shorten or expand content\n⢠Change the tone or focus\n⢠Merge articles together":"Iâm here to help you train this property. I can:\n⢠Draft knowledge articles from your descriptions\n⢠Answer questions about whatâs covered\n⢠Suggest gaps in your property knowledge\n⢠Help rewrite or improve existing articles"},onUiAction:A,userImage:R?void 0:s?.user?.image,userName:R?"Guest":s?.user?.name},g)})]}):null;return(0,t.jsx)(q.BaseModal,{isOpen:e&&!!a,title:P,onCloseAction:tn,rightSidebar:K,showNavigation:!1,widthClass:"lg:w-[85vw] lg:max-w-[1600px]",belowHeader:!0,children:(0,t.jsx)("div",{"data-no-shortcuts":!0,className:"contents",children:l||y||N?(0,t.jsx)(td,{children:(0,t.jsx)(tc,{})}):(0,t.jsxs)("div",{className:"flex h-full",children:[(0,t.jsx)("div",{className:"hidden lg:flex w-[240px] border-r border-gray-200 dark:border-white/[0.08] flex-col shrink-0 bg-white/50 dark:bg-white/[0.01]",children:(0,t.jsx)(H.TrainingProgress,{categories:S,activeCategory:d,onCategoryClick:E,trainingScore:j?.trainingScore})}),(0,t.jsx)("div",{className:"flex-1 overflow-y-auto px-4 md:px-6 lg:px-8 py-6",children:(0,t.jsx)("div",{className:"max-w-4xl mx-auto
1space-y-6",children:"mining"===m&&a?(0,t.jsx)(te,{listingId:a,listingName:D,conversationCount:j?.conversationCount??0,hasHistory:j?.hasHistory??!1,isTrained:j?.isTrained??!1,categories:S,onComplete:_,onBack:()=>u(null)}):"media"===m&&a?(0,t.jsx)(e4,{listingId:a,listingName:D,onBack:()=>u(null)}):"document"===m&&a&&o?(0,t.jsx)(ts,{listingId:a,customerId:o,onBack:()=>u(null),onArticlesCreated:()=>w()}):"questionnaire"===m&&a?(0,t.jsx)(ej,{listingId:a,initialCategory:d?(0,en.getQuestionnaireForCategory)(d)?.id:void 0,onComplete:()=>{u(null),w()},onCancel:()=>u(null)}):(0,t.jsxs)(t.Fragment,{children:[a&&(0,t.jsx)(G.TrainingGuidance,{listingId:a,listingName:D,categories:S,conversationCount:j?.conversationCount??0,hasHistory:j?.hasHistory??!1,isTrained:j?.isTrained??!1,videoAnalysisCount:j?.videoAnalysisCount??0,mediaArticleCount:j?.mediaArticleCount??0,onStartMedia:()=>u("media"),onStartMining:()=>u("mining"),onStartQuestionnaire:T,onMiningComplete:_}),(0,t.jsx)(V.TrainingMethods,{onSelectMethod:I,conversationCount:j?.conversationCount??0,isTrained:j?.isTrained??!1,mediaArticleCount:j?.mediaArticleCount??0,articleCount:S.reduce((e,t)=>e+t.articleCount,0)}),a&&(0,t.jsx)(W.TrainingCategoryGrid,{listingId:a,categories:S,activeCategory:d,onCategoryClick:E,onStartQuestionnaire:e=>{c(e),u("questionnaire")}})]})})})]})})})}function td({children:e}){return(0,t.jsx)("div",{className:"flex h-full",children:e})}function tc(){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"hidden lg:flex w-[240px] border-r border-gray-200 dark:border-white/[0.08] flex-col shrink-0",children:(0,t.jsxs)("div",{className:"p-4 space-y-3",children:[(0,t.jsx)(B.Skeleton,{className:"h-5 w-36 bg-gray-200 dark:bg-white/[0.08]"}),(0,t.jsx)(B.Skeleton,{className:"h-2 w-full bg-gray-200 dark:bg-white/[0.08] rounded-full"}),[...Array(8)].map((e,a)=>(0,t.jsx)(B.Skeleton,{className:"h-12 w-full bg-gray-200 dark:bg-white/[0.08] rounded-lg"},a))]})}),(0,t.jsx)("div",{className:"flex-1 px-4 md:px-6 lg:px-8 py-6",children:(0,t.jsxs)("div",{className:"max-w-4xl mx-auto space-y-6",children:[(0,t.jsx)(B.Skeleton,{className:"h-28 bg-gray-200 dark:bg-white/[0.08] rounded-xl"}),(0,t.jsx)("div",{className:"grid grid-cols-3 gap-3",children:[void 0,void 0,void 0].map((e,a)=>(0,t.jsx)(B.Skeleton,{className:"h-32 bg-gray-200 dark:bg-white/[0.08] rounded-xl"},a))}),[void 0,void 0,void 0,void 0].map((e,a)=>(0,t.jsx)(B.Skeleton,{className:"h-16 bg-gray-200 dark:bg-white/[0.08] rounded-xl"},a))]})})]})}let tm=new Set(e.i(836208).STEP_IDS),tu="https://api.vanio.ai";function th({children:e}){let{currentCustomerId:a,isSuperUser:r}=(0,v.useCustomer)(),s=(0,_.useRouter)(),n=(0,_.usePathname)(),[l,o]=(0,i.useState)(!1),d=(0,i.useRef)(!1);return(0,i.useEffect)(()=>{if(a&&!d.current){if(r||n?.startsWith("/onboarding")||n?.startsWith("/auth"))return void o(!0);d.current=!0,fetch(`${tu}/onboarding`,{credentials:"include"}).then(e=>e.json()).then(async e=>{let t=function(e){let{state:t,needsOnboarding:a,airbnbConnected:r}=e,s=t?.variant==="connected_supply";if(r&&!s)return null;if(t){let e=!!t.currentStep&&tm.has(t.currentStep);return"completed"!==t.status&&e?"resume":null}return a?"initialize":null}({state:e.state??null,needsOnboarding:!!e.needsOnboarding,airbnbConnected:!!e.airbnbConnected});if("resume"===t)s.replace("/onboarding");else if("initialize"===t){try{await fetch(`${tu}/onboarding`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"initialize"}),credentials:"include"})}catch{}s.replace("/onboarding")}else o(!0)}).catch(()=>{o(!0)}).finally(()=>{d.current=!1})}},[a,n,s]),n?.startsWith("/onboarding"),(0,t.jsx)(t.Fragment,{children:e})}var tx=e.i(961181),tg=e.i(568612),tp=e.i(996091),tb=e.i(846932),tf=e.i(88653),ty=e.i(655900),tw=e.i(826707),tv=e.i(245423),tk=e.i(529071),tk=tk,tj=e.i(107233),tN=e.i(323585);let tC=[{id:"connect_platform",label:"Connect your Airbnb",href:"/apps/2"},{id:"import_data",label:"Import your listings",href:"/apps/2"},{id:"team",label:"Add on-site staff",href:"/",chatPrompt:"I want to add my on-site person who handles check-ins and cleaning"},{id:"automations",label:"Automate check-in messages",href:"/",chatPrompt:"Help me set up automatic check-in messages for my guests"},{id:"setup_ai",label:"Turn on AI for guests",href:"/settings/ai"},{id:"test_ai",label:"Test the AI yourself",href:"/",chatPrompt:"I want to test how AI responds to guests. Open the AI Lab on my next upcoming reservation so I can simulate a guest conversation."},{id:"install_app",label:"Install app & notifications",href:"#install-app",isDrawer:!0,canDismiss:!0}],tS=[{id:"connect_platform",label:"Connect booking platforms",href:"/apps/2"},{id:"import_data",label:"Import listings & data",href:"/apps/2"},{id:"team",label:"Set up your team",href:"/settings/team"},{id:"automations",label:"Automate guest messages",href:"/workflows"},{id:"setup_ai",label:"Enable AI (shadow mode)",href:"/settings/ai"},{id:"smart_locks",label:"Connect smart locks",href:"/apps/iot"},{id:"payments",label:"Connect payments",href:"/apps/6"},{id:"test_ai",label:"Test AI as a guest",href:"/",chatPrompt:"I want to test how AI responds to guests. Open the AI Lab on my next upcoming reservation so I can simulate a guest conversation."},{id:"install_app",label:"Install app & notifications",href:"#install-app",isDrawer:!0,canDismiss:!0}],tE=[{id:"connect_host",label:"Connect your first host",href:"/settings/service-providers"},{id:"team",label:"Add team members",href:"/settings/team"},{id:"service_catalog",label:"Create service catalog",href:"/settings/service-catalog"},{id:"service_areas",label:"Set up service areas",href:"/settings/service-areas"},{id:"setup_ai",label:"Turn on AI",href:"/settings/ai"}];function tI(){let{workspaceType:e,personaTierKey:a,activeListingCount:r,isSuperUser:s}=(0,v.useCustomer)(),{settings:n}=(0,tg.useUserSettings)(),l=(0,tx.useSetupProgress)(e,a),{completedItems:o,isLoading:d,dismissed:c}=l,[m,u]=(0,i.useState)(!1),[h,x]=(0,i.useState)(!1),[g,p]=(0,i.useState)(!1),[b,f]=(0,i.useState)(()=>{try{let e=localStorage.getItem("vanio_setup_manual_done");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}}),y=(0,_.useRouter)(),w=(0,_.usePathname)(),k=["/onboarding","/auth","/login","/signup","/workflows"].some(e=>w?.startsWith(e));(0,i.useEffect)(()=>{try{let e=localStorage.getItem("vanio_setup_minimized");"true"===e&&x(!0)}catch{}},[]);let j=(0,i.useCallback)(()=>{x(e=>{let t=!e;try{localStorage.setItem("vanio_setup_minimized",String(t))}catch{}return t})},[]),N="service_provider"===e?tE:"owner"===a?tC:tS,C=new Set([...o,...b]),S=N.filter(e=>C.has(e.id)).length,E=N.length,I=Math.round(S/E*100),T=S>=E,[A,D]=(0,i.useState)(()=>{try{let e=localStorage.getItem("vanio_expansion_nudges");return e?JSON.parse(e):{}}catch{return{}}}),P=function(e,t){let a=[],r=e=>
1`$${e.toLocaleString()}`;if(e.includes("smart_locks")||a.push({id:"smart_locks",title:"Smart locks â never hand off a key again",benefit:`Automatic door codes for every guest across ${t} properties. Codes generated on booking, sent at check-in, deactivated at checkout. Staff get their own codes. Works with Yale, Schlage, August, and 30+ brands.`,href:"/apps/iot"}),!e.includes("website")){let e=Math.round(1.5*t*68);a.push({id:"website",title:`Your own booking site â save ${r(e)}/mo`,benefit:`Guests search, find, and book your ${t} properties directly â zero OTA commission. Same availability, real-time sync. Every repeat guest books here instead of giving Airbnb 15-20%.`,href:"/websites"})}if(!e.includes("guest_portal")){let e=Math.round(2*t*30);a.push({id:"guest_portal",title:`Guest portal & upsells â earn ${r(e)}/mo extra`,benefit:"Guests verify identity, get door codes, and buy early check-in, late checkout, mid-stay cleaning â all from their phone. Revenue youâre leaving on the table today.",href:"/websites"})}return e.includes("setup_ai")||a.push({id:"setup_ai",title:"AI guest messaging â stop answering at 2am",benefit:"Your AI already knows every property, every reservation, every house rule. It handles 90%+ of guest messages instantly â check-in instructions, WiFi, local tips, issue resolution. Any language, any channel, 24/7. Start in shadow mode: AI drafts, you approve.",href:"/settings/ai"}),e.includes("automations")||a.push({id:"automations",title:"Automations â zero manual coordination",benefit:"Guest checks out â cleaning dispatched. Booking confirmed â check-in message sent. Maintenance reported â task created. Define once, runs forever across all properties.",href:"/workflows"}),e.includes("payments")||a.push({id:"payments",title:"Payments â collect, split, pay out automatically",benefit:"Security deposits collected at booking. Upsell payments processed instantly. Staff paid on task completion. Owner statements generated automatically. All via Stripe â set up in 5 minutes.",href:"/apps/6"}),a}(o,r||5),R=Date.now(),M=Math.max(0,...Object.values(A)),L=M>0&&R-M<2592e5?null:P.find(e=>!A[e.id])||null,$=!T&&!c&&l.isVisible,O=!$&&null!==L;if(d||k||s||(0,tp.hasSimplifiedStaffView)(n)||!$&&!O)return null;if(O&&L)return(0,t.jsxs)(tb.motion.div,{initial:{opacity:0,scale:.9,y:30},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,y:30},transition:{type:"spring",stiffness:350,damping:25},className:(0,F.cn)("fixed bottom-20 left-4 md:bottom-4 z-[50]","w-80 rounded-xl overflow-hidden","bg-white dark:bg-[#2C2C2E] border border-orange-500/20","shadow-lg"),children:[(0,t.jsxs)("div",{className:"px-4 py-3 bg-gradient-to-r from-orange-500/[0.06] to-amber-500/[0.04] border-b border-orange-500/10 flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("div",{className:"w-6 h-6 rounded-full bg-orange-500/10 flex items-center justify-center",children:(0,t.jsx)(e6.Zap,{className:"w-3.5 h-3.5 text-orange-500"})}),(0,t.jsx)("span",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Did you know?"})]}),(0,t.jsx)("button",{onClick:()=>{D(e=>{let t={...e,[L.id]:Date.now()};try{localStorage.setItem("vanio_expansion_nudges",JSON.stringify(t))}catch{}return t})},className:"p-0.5 rounded hover:bg-gray-100 dark:hover:bg-white/[0.05] text-gray-400 dark:text-white/40",children:(0,t.jsx)(et.X,{className:"w-3.5 h-3.5"})})]}),(0,t.jsxs)("button",{onClick:()=>y.push(L.href),className:"w-full px-4 py-4 text-left hover:bg-gray-50 dark:hover:bg-white/[0.03] transition-colors",children:[(0,t.jsx)("p",{className:"text-sm font-semibold text-gray-900 dark:text-white leading-snug",children:L.title}),(0,t.jsx)("p",{className:"text-xs text-gray-600 dark:text-white/50 mt-1.5 leading-relaxed",children:L.benefit}),(0,t.jsx)("span",{className:"inline-flex items-center gap-1 mt-2.5 text-xs font-semibold text-orange-600 dark:text-orange-400",children:"Set it up â"})]})]},L.id);let U=N.find(e=>!C.has(e.id)),B=e=>{f(t=>{let a=new Set(t);a.add(e);let r=[...a];try{localStorage.setItem("vanio_setup_manual_done",JSON.stringify(r))}catch{}return fetch("https://api.vanio.ai/onboarding",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"update_step_metadata",stepId:"done",metadata:{setup:{completedItems:r}}}),credentials:"include"}).catch(()=>{}),a})},q=e=>{if(e.isDrawer)return void p(!0);if(e.chatPrompt){try{sessionStorage.setItem("vanio_setup_chat_prompt",e.chatPrompt)}catch{}y.push("/")}else y.push(e.href)};return(0,t.jsx)(tf.AnimatePresence,{mode:"wait",children:h?(0,t.jsxs)(tb.motion.button,{initial:{opacity:0,scale:.8,y:20}
1,animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.8,y:20},transition:{type:"spring",stiffness:400,damping:25},onClick:j,className:(0,F.cn)("fixed bottom-20 left-4 md:bottom-4 z-[50]","flex items-center gap-2 px-3 py-2 rounded-full","bg-white dark:bg-[#2C2C2E] border border-gray-200 dark:border-white/[0.08]","shadow-lg hover:shadow-xl","text-xs font-medium text-gray-600 dark:text-white/60"),children:[(0,t.jsx)(X.Sparkles,{className:"w-3.5 h-3.5 text-orange-500"}),(0,t.jsxs)("span",{children:["Setup ",I,"%"]})]},"pill"):(0,t.jsxs)(tb.motion.div,{initial:{opacity:0,scale:.9,y:30},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,y:30},transition:{type:"spring",stiffness:350,damping:25},className:(0,F.cn)("fixed bottom-20 left-4 md:bottom-4 z-[50]","w-72 rounded-xl overflow-hidden","bg-white dark:bg-[#2C2C2E] border border-gray-200 dark:border-white/[0.08]","shadow-lg"),children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 cursor-pointer select-none",onClick:()=>u(!m),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(X.Sparkles,{className:"w-4 h-4 text-orange-500"}),(0,t.jsx)("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Your Setup"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsxs)("div",{className:"relative w-6 h-6",children:[(0,t.jsxs)("svg",{className:"w-6 h-6 -rotate-90",viewBox:"0 0 24 24",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-gray-200 dark:text-white/[0.08]"}),(0,t.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-orange-500",strokeDasharray:`${.628*I} 62.8`,strokeLinecap:"round"})]}),(0,t.jsx)("span",{className:"absolute inset-0 flex items-center justify-center text-[8px] font-bold text-gray-600 dark:text-white/60",children:S})]}),m?(0,t.jsx)(eH.ChevronDown,{className:"w-4 h-4 text-gray-400 dark:text-white/40"}):(0,t.jsx)(ty.ChevronUp,{className:"w-4 h-4 text-gray-400 dark:text-white/40"}),(0,t.jsx)("button",{onClick:e=>{e.stopPropagation(),j()},className:"p-0.5 rounded hover:bg-gray-100 dark:hover:bg-white/[0.05] text-gray-400 dark:text-white/40",children:(0,t.jsx)(et.X,{className:"w-3.5 h-3.5"})})]})]}),(0,t.jsx)(tf.AnimatePresence,{children:m&&(0,t.jsx)(tb.motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{type:"spring",stiffness:400,damping:30},className:"overflow-hidden",children:(0,t.jsxs)("div",{className:"border-t border-gray-100 dark:border-white/[0.06] max-h-[400px] overflow-y-auto",ref:e=>{if(!e)return;let t=e.querySelector('[data-incomplete="true"]');t&&t.scrollIntoView({block:"nearest"})},children:[N.map(e=>{let a=C.has(e.id);return(0,t.jsxs)("div",{"data-incomplete":a?void 0:"true",className:(0,F.cn)("w-full flex items-center gap-3 px-4 py-2.5 text-left transition-colors",a?"opacity-50 cursor-default":"hover:bg-gray-50 dark:hover:bg-white/[0.04] cursor-pointer"),onClick:()=>!a&&q(e),children:[(0,t.jsx)("div",{className:(0,F.cn)("w-5 h-5 rounded-full flex items-center justify-center flex-shrink-0",a?"bg-green-500/20 text-green-500":"border border-gray-300 dark:border-white/20 hover:border-green-400 hover:bg-green-500/10 cursor-pointer"),onClick:t=>{a||(t.stopPropagation(),B(e.id))},title:a?void 0:"Mark as done",children:a&&(0,t.jsx)(Z.Check,{className:"w-3 h-3"})}),(0,t.jsx)("span",{className:(0,F.cn)("text-sm flex-1",a?"text-gray-400 dark:text-white/30 line-through":"text-gray-700 dark:text-white/80"),children:e.label}),!a&&(0,t.jsx)("button",{onClick:t=>{t.stopPropagation(),B(e.id)},className:"px-2 py-0.5 rounded text-[11px] font-medium text-gray-400 dark:text-white/30 hover:bg-gray-100 dark:hover:bg-white/[0.08] hover:text-gray-600 dark:hover:text-white/50 transition-colors shrink-0",children:"Skip"})]},e.id)}),(0,t.jsx)("div",{className:"px-4 py-2 border-t border-gray-100 dark:border-white/[0.06]",children:(0,t.jsx)("button",{onClick:()=>l.dismiss(),className:"text-[11px] text-gray-400 dark:text-white/25 hover:text-gray-600 dark:hover:text-white/50 transition-colors",children:"Dismiss setup guide"})})]})})}),!m&&U&&(0,t.jsx)("div",{className:"border-t border-gray-100 dark:border-white/[0.06]",children:(0,t.jsxs)("button",{onClick:()=>q(U),className:"w-full flex items-center gap-3 px-4 py-2.5 text-left hover:bg-gray-50 dark:hover:bg-white/[0.04] transition-colors",children:[(0,t.jsx)("div",{className:"w-5 h-5 rounded-full border border-orange-400 dark:border-orange-500/50 flex items-center justify-center flex-shrink-0",children:(0,t.jsx)("div",{className:"w-2 h-2 rounded-full bg-orange-500"})}),(0,t.jsxs)("span",{className:"text-sm text-gray-700 dark:text-white/80",children:["Next: ",
1U.label]})]})}),g&&(0,t.jsx)(tT,{onClose:()=>p(!1),onDone:()=>{B("install_app"),p(!1)}})]},"widget")})}function tT({onClose:e,onDone:a}){let[r,s]=(0,i.useState)("ios");return(0,i.useEffect)(()=>{let e=navigator.userAgent;/android/i.test(e)?s("android"):/iPad|iPhone|iPod/.test(e)?s("ios"):s("desktop")},[]),(0,t.jsxs)("div",{className:"fixed inset-0 z-[200] flex items-end md:items-center justify-center",children:[(0,t.jsx)("div",{className:"absolute inset-0 bg-black/50",onClick:e}),(0,t.jsxs)("div",{className:(0,F.cn)("relative w-full md:w-[440px] md:max-h-[85vh] max-h-[80vh] overflow-y-auto","bg-white dark:bg-[#1C1C1E] rounded-t-2xl md:rounded-2xl","border border-gray-200 dark:border-white/[0.08] shadow-2xl"),children:[(0,t.jsxs)("div",{className:"sticky top-0 bg-white dark:bg-[#1C1C1E] px-6 pt-5 pb-3 border-b border-gray-100 dark:border-white/[0.06] z-10",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 rounded-xl bg-orange-500/10 flex items-center justify-center",children:(0,t.jsx)(tw.Smartphone,{className:"w-5 h-5 text-orange-500"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-base font-semibold text-gray-900 dark:text-white",children:"Install Vanio AI"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/50",children:"Get the app + push notifications"})]})]}),(0,t.jsx)("button",{onClick:e,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.05]",children:(0,t.jsx)(et.X,{className:"w-4 h-4 text-gray-400"})})]}),(0,t.jsx)("div",{className:"flex gap-1 mt-4 p-1 rounded-lg bg-gray-100 dark:bg-white/[0.05]",children:["ios","android","desktop"].map(e=>(0,t.jsx)("button",{onClick:()=>s(e),className:(0,F.cn)("flex-1 py-1.5 text-xs font-medium rounded-md transition-colors",r===e?"bg-white dark:bg-white/[0.1] text-gray-900 dark:text-white shadow-sm":"text-gray-500 dark:text-white/40 hover:text-gray-700 dark:hover:text-white/60"),children:"ios"===e?"iPhone / iPad":"android"===e?"Android":"Desktop"},e))})]}),(0,t.jsxs)("div",{className:"px-6 py-5 space-y-5",children:["ios"===r&&(0,t.jsx)(tA,{}),"android"===r&&(0,t.jsx)(tD,{}),"desktop"===r&&(0,t.jsx)(tP,{}),(0,t.jsxs)("div",{className:"pt-4 border-t border-gray-100 dark:border-white/[0.06]",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,t.jsx)(tv.Bell,{className:"w-4 h-4 text-orange-500"}),(0,t.jsx)("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Step 2: Enable Notifications"})]}),(0,t.jsx)("p",{className:"text-sm text-gray-600 dark:text-white/60 mb-3",children:"ios"===r?'After installing, open the app and tap "Allow" when asked about notifications. On iOS, push notifications only work inside the installed app â not in Safari.':"android"===r?'After installing, open the app. You\'ll be asked to allow notifications â tap "Allow". You can also enable them later in Android Settings > Apps > Vanio AI > Notifications.':"After installing, click the bell icon in the app header to enable push notifications for your browser."}),(0,t.jsx)("div",{className:(0,F.cn)("rounded-lg p-3 text-xs","bg-amber-50 dark:bg-amber-500/10 text-amber-800 dark:text-amber-300","border border-amber-200 dark:border-amber-500/20"),children:"ios"===r?"Important: On iPhone/iPad, notifications will NOT work in Safari. You must install the app first.":"You'll receive real-time alerts for guest messages, booking confirmations, task updates, and AI escalations."})]}),(0,t.jsx)("div",{className:"pt-4 border-t border-gray-100 dark:border-white/[0.06]",children:(0,t.jsx)("button",{onClick:a,className:(0,F.cn)("w-full py-2.5 rounded-lg text-sm font-medium transition-colors","bg-orange-500 hover:bg-orange-600 text-white"),children:"Done â I installed it"})})]})]})]})}function t_({number:e,children:a}){return(0,t.jsxs)("div",{className:"flex gap-3",children:[(0,t.jsx)("div",{className:"w-6 h-6 rounded-full bg-orange-500/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:(0,t.jsx)("span",{className:"text-xs font-bold text-orange-500",children:e})}),(0,t.jsx)("div",{className:"text-sm text-gray-700 dark:text-white/70 leading-relaxed",children:a})]})}function tA(){return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,t.jsx)(tw.Smartphone,{className:"w-4 h-4 text-orange-500"}),(0,t.jsx)("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Step 1: Install the App"})]}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)(t_,{number:1,children:["Open ",(0,t.jsx)("strong",{children:"app.vanio.ai"})," in ",(0,t.jsx)("strong",{children:"Safari"})," (this only works in Safari on iPhone)"]}),(0,t.jsxs)(t_,{number:2,children:["Tap the ",(0,t.jsx)("strong",{children:"Share"})," button ",(0,t.jsx)(tk.default,{className:"w-3.5 h-3.5 inline text-blue-500"})," at the bottom of Safari"]}),(0,t.jsxs)(t_,{number:3,children:["Scroll down and tap ",(0,t.jsx)("strong",{children:'"Add to Home Screen"'})," ",(0,t.jsx)(tj.Plus,{className:"w-3.5 h-3.5 inline text-gray-500"})]}),(0,t.jsxs)(t_,{number:4,children:["Tap ",(0,t.jsx)("strong",{children:'"Add"'})," in the top right corner. The Vanio AI icon will appear on your home screen."]}),(0,t.jsx)(t_,{number:5,children:"Open the app from your home screen â it runs full-screen like a native app!"})]})]})}function tD(){return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,t.jsx)(tw.Smartphone,{className:"w-4 h-4 text-orange-500"}),(0,t.jsx)("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Step 1: Install the App"})]}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)(t_,{number:1,children:["Open ",(0,t.jsx)("strong",{children:"app.vanio.ai"})," in ",(0,t.jsx)("strong",{children:"Chrome"})]}),(0,t.jsxs)(t_,{number:2,children:["Tap the ",(0,t.jsx)("strong",{children:"three-dot menu"})," ",(0,t.jsx)(tN.MoreVertical,{className:"w-3.5 h-3.5 inline text-gray-500"})," in the top right"]}),(0,t.jsxs)(t_,{number:3,children:["Tap ",(0,t.jsx)("strong",{children:'"Install app"'})," or ",(0,t.jsx)("strong",{children:'"Add to Home screen"'})]}),(0,t.jsxs)(t_,{number:4,children:["Tap ",(0,t.jsx)("strong",{children:'"Install"'})," in the confirmation dialog"]}),(0,t.jsx)(t_,{number:5,children:"The app installs instantly â find it on your home screen or app drawer!"})]}),(0,t.jsx)("div",{className:(0,F.cn)("mt-3 rounded-lg p-3 text-xs","bg-blue-50 dark:bg-blue-500/10 text-blue-800 dark:text-blue-300","border border-blue-200 dark:border-blue-500/20"),children:'If you see an "Install Vanio AI" banner at the bottom of the screen, you can tap that directly.'})]})}function tP(){return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,t.jsx)(tw.Smartphone,{className:"w-4 h-4 text-orange-500"}),(0,t.jsx)("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Step 1: Install the App"})]}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)(t_,{number:1,children:["Open ",(0,t.jsx)("strong",{children:"app.vanio.ai"})," in ",(0,t.jsx)("strong",{children:"Chrome"})," or ",(0,t.jsx)("strong",{children:"Edge"})]}),(0,t.jsxs)(t_,{number:2,children:["Look for the ",(0,t.jsx)("strong",{children:"install icon"})," ",(0,t.jsx)(tj.Plus,{className:"w-3.5 h-3.5 inline text-gray-500"})," in the address bar (right side)"]}),(0,t.jsxs)(t_,{number:3,children:["Click ",(0,t.jsx)("strong",{children:'"Install"'})," â Vanio AI opens as a standalone app window"]})]}),(0,t.jsx)("div",{className:(0,F.cn)("mt-3 rounded-lg p-3 text-xs","bg-gray-50 dark:bg-white/[0.03] text-gray-600 dark:text-white/50","border border-gray-200 dark:border-white/[0.06]"),children:"Safari on Mac doesn't support app installation. Use Chrome or Edge instead."})]})}var tR=e.i(842291);let tM=["/settings/billing","/billing","/auth","/onboarding","/settings/account","/settings/billing/inactive"];function tF({children:e}){let a=(0,_.usePathname)(),r=(0,_.useRouter)(),{data:s}=(0,$.useSession)(),{subscription:n,isLoadingSubscription:l,error:o}=(0,tR.useSubscription)(),{isSuperUser:d,isCustomerValidated:c}=(0,v.useCustomer)(),{settings:m}=(0,tg.useUserSettings)(),u=d||m?.isSuperUser===!0||!!s?._originalCustomerId,{products:h,productC
1onfig:x,isLoading:g}=(0,k.useProductSafe)(),[p,b]=(0,i.useState)(!1);return((0,i.useEffect)(()=>{if(!s)return;if(u||tM.some(e=>a?.startsWith(e)))return void b(!0);if(l||g||!c)return;if(o){console.warn("[SubscriptionGate] subscription fetch error, allowing through:",o),b(!0);return}let e=n?.status==="active"||n?.status==="trialing"||n?.billingExempt===!0,t=x.id,i=h.some(e=>e.productId===t&&"active"===e.status);if(e||i)return void b(!0);b(!1);let d=new URL("/settings/billing",window.location.origin);n||d.searchParams.set("trial","true"),r.replace(d.pathname+d.search)},[u,m?.isSuperUser,c,n,l,o,h,g,x.id,a,r,s]),l||g||!s)?null:u||tM.some(e=>a?.startsWith(e))||p?(0,t.jsx)(t.Fragment,{children:e}):null}var tL=e.i(522016),t$=e.i(561659);function tO(){let[e,a]=(0,i.useState)(null),[r,s]=(0,i.useState)(!1);if((0,i.useEffect)(()=>{let e=!1,t=async()=>{try{let t=await fetch("/api/billing/credits",{credentials:"include"});if(!t.ok)return;let r=await t.json();e||a(r)}catch{}};t();let r=setInterval(t,6e4);return()=>{e=!0,clearInterval(r)}},[]),!e||!1===e.setup||r)return null;let n=!!e.paused,l=!n&&(e.rechargeRetryCount??0)>0;return n||l?n?(0,t.jsx)("div",{className:(0,F.cn)("flex-none border-b","md:mt-[calc(104px+var(--banner-offset,0px))]","bg-red-50 dark:bg-red-500/[0.08] border-red-200 dark:border-red-500/30"),role:"alert",children:(0,t.jsxs)("div",{className:"mx-auto max-w-[1920px] px-4 md:px-6 lg:px-8 py-2.5 flex items-center gap-3",children:[(0,t.jsx)(eP.AlertTriangle,{className:"h-4 w-4 text-red-500 shrink-0"}),(0,t.jsx)("div",{className:"flex-1 min-w-0",children:(0,t.jsxs)("p",{className:"text-sm font-medium text-red-700 dark:text-red-300",children:["Your Vanio AI services are paused",e.lastDeclineReason?(0,t.jsxs)(t.Fragment,{children:[" â payment method declined: ",(0,t.jsx)("span",{className:"font-normal opacity-90",children:e.lastDeclineReason})]}):(0,t.jsx)(t.Fragment,{children:" â payment method declined."})]})}),(0,t.jsxs)(tL.default,{href:"/settings/billing",className:(0,F.cn)("inline-flex items-center gap-1.5 px-3 py-1 rounded-md text-xs font-medium","bg-red-500 text-white hover:bg-red-600 transition-colors shrink-0"),children:[(0,t.jsx)(t$.CreditCard,{className:"h-3.5 w-3.5"})," Update payment"]}),(0,t.jsx)("button",{type:"button",onClick:()=>s(!0),"aria-label":"Dismiss",className:"p-1 text-red-500/60 hover:text-red-500 transition-colors shrink-0",children:(0,t.jsx)(et.X,{className:"h-4 w-4"})})]})}):(0,t.jsx)("div",{className:(0,F.cn)("flex-none border-b","md:mt-[calc(104px+var(--banner-offset,0px))]","bg-amber-50 dark:bg-amber-500/[0.08] border-amber-200 dark:border-amber-500/30"),role:"status",children:(0,t.jsxs)("div",{className:"mx-auto max-w-[1920px] px-4 md:px-6 lg:px-8 py-2.5 flex items-center gap-3",children:[(0,t.jsx)(eP.AlertTriangle,{className:"h-4 w-4 text-amber-500 shrink-0"}),(0,t.jsx)("div",{className:"flex-1 min-w-0",children:(0,t.jsxs)("p",{className:"text-sm font-medium text-amber-700 dark:text-amber-300",children:["Payment retry in progress",e.lastDeclineReason?(0,t.jsxs)(t.Fragment,{children:[" â ",e.lastDeclineReason,". Update your card to avoid interruption."]}):(0,t.jsx)(t.Fragment,{children:" â please update your payment method to avoid service interruption."})]})}),(0,t.jsxs)(tL.default,{href:"/settings/billing",className:(0,F.cn)("inline-flex items-center gap-1.5 px-3 py-1 rounded-md text-xs font-medium","bg-amber-500 text-white hover:bg-amber-600 transition-colors shrink-0"),children:[(0,t.jsx)(t$.CreditCard,{className:"h-3.5 w-3.5"})," Update payment"]}),(0,t.jsx)("button",{type:"button",onClick:()=>s(!0),"aria-label":"Dismiss",className:"p-1 text-amber-500/60 hover:text-amber-500 transition-colors shrink-0",children:(0,t.jsx)(et.X,{className:"h-4 w-4"})})]})}):null}var tU=e.i(14280),tB=e.i(514764),tq=e.i(846696);
1function tz({open:e,onOpenChange:a}){let{data:r}=(0,$.useSession)(),[s,n]=(0,i.useState)(""),[l,o]=(0,i.useState)(""),[d,c]=(0,i.useState)(""),[m,u]=(0,i.useState)(!1);(0,i.useEffect)(()=>{e&&r?.user&&(!s&&r.user.name&&n(r.user.name),!l&&r.user.email&&o(r.user.email))},[e,r]);let h=async()=>{if(!s.trim()||!l.trim()||!d.trim())return void tq.toast.error("Please fill in all fields");u(!0);try{await fetch("/api/billing/contact-sales",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,email:l,message:d})}),tq.toast.success("Message sent! We'll get back to you shortly."),a(!1),n(""),o(""),c("")}catch{tq.toast.error("Failed to send. Please email [email protected] directly.")}finally{u(!1)}};return(0,t.jsx)(tU.AlertDialog,{open:e,onOpenChange:a,children:(0,t.jsxs)(tU.AlertDialogContent,{className:(0,F.cn)("z-[200] max-w-md","bg-white dark:bg-[#1C1C1E] border-gray-200 dark:border-white/[0.1]"),children:[(0,t.jsxs)(tU.AlertDialogHeader,{children:[(0,t.jsx)(tU.AlertDialogTitle,{className:"text-gray-900 dark:text-white",children:"Contact Sales"}),(0,t.jsx)(tU.AlertDialogDescription,{className:"text-gray-500 dark:text-white/50",children:"Tell us about your needs and we'll create a custom plan for your portfolio."})]}),(0,t.jsxs)("div",{className:"space-y-3 my-4",children:[(0,t.jsx)("input",{type:"text",placeholder:"Your name",value:s,onChange:e=>n(e.target.value),className:(0,F.cn)("w-full px-3 py-2 rounded-lg text-sm border","bg-gray-50 dark:bg-white/[0.05] border-gray-200 dark:border-white/[0.08]","text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-white/30","focus:outline-none focus:ring-2 focus:ring-orange-500/30")}),(0,t.jsx)("input",{type:"email",placeholder:"Email address",value:l,onChange:e=>o(e.target.value),className:(0,F.cn)("w-full px-3 py-2 rounded-lg text-sm border","bg-gray-50 dark:bg-white/[0.05] border-gray-200 dark:border-white/[0.08]","text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-white/30","focus:outline-none focus:ring-2 focus:ring-orange-500/30")}),(0,t.jsx)("textarea",{placeholder:"Tell us about your portfolio â how many units, what you need...",rows:4,value:d,onChange:e=>c(e.target.value),className:(0,F.cn)("w-full px-3 py-2 rounded-lg text-sm border resize-none","bg-gray-50 dark:bg-white/[0.05] border-gray-200 dark:border-white/[0.08]","text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-white/30","focus:outline-none focus:ring-2 focus:ring-orange-500/30")})]}),(0,t.jsxs)(tU.AlertDialogFooter,{children:[(0,t.jsx)(ei.Button,{variant:"outline",onClick:()=>a(!1),disabled:m,className:"border-gray-200 dark:border-white/[0.08]",children:"Cancel"}),(0,t.jsxs)(ei.Button,{onClick:h,disabled:m,className:"bg-orange-500 hover:bg-orange-600 text-white",children:[m?(0,t.jsx)(Y.Loader2,{className:"h-4 w-4 mr-1.5 animate-spin"}):(0,t.jsx)(tB.Send,{className:"h-4 w-4 mr-1.5"}),"Send"]})]})]})})}var tH=e.i(632010);let tV="https://api.vanio.ai/app/track";function tG(){let e=(0,_.usePathname)(),t=(0,i.useRef)([]),a=(0,i.useRef)(""),r=(0,i.useRef)(0),s=()=>{let e=t.current.splice(0);if(0===e.length)return;let a=JSON.stringify({events:e});"u">typeof navigator&&navigator.sendBeacon?navigator.sendBeacon(tV,a):fetch(tV,{method:"POST",body:a,headers:{"Content-Type":"application/json"},keepalive:!0}).catch(()=>{})};return(0,i.useEffect)(()=>{if(!e||e===a.current)return;a.current=e;let r={};if(e.startsWith("/settings")){r.section="settings";let t=e.split("/settings/")[1]?.split("/")[0];t&&(r.subsection=t)}else if(e.startsWith("/workflows"))r.section="workflows";else if(e.startsWith("/apps")){r.section="apps";let t=e.split("/apps/")[1]?.split("/")[0];t&&(r.app=t)}else e.startsWith("/guests")?r.section="guests":e.startsWith("/reports")?r.section="reports":e.startsWith("/superadmin")?r.section="superadmin":("/"===e||""===e)&&(r.section="dashboard");t.current.push({type:"pageview",pathname:e,metadata:r,ts:Date.now()})},[e]),(0,i.useEffect)(()=>{let e=setInterval(()=>{if("visible"!==document.visibilityState)return;let e=Date.now();e-r.current<3e4||(r.current=e,t.current.push({type:"dwell",pathname:a.current,metadata:{seconds:30},ts:e}))},3e4),i=setInterval(s,1e4),n=()=>s(),l=()=>{"hidden"===document.visibilityState&&s()};return window.addEventListener("beforeunload",n),document.addEventListener("visibilitychange",l),()=>{clearInterval(e),clearInterval(i),window.removeEventListener("beforeunload",n),document.removeEventListener("visibilitychange",l),s()}},[]),null}var tW=i;let tK=(e,t)=>"string"==typeof e?e.slice(0,t):"";function tY(e){try{if("function"!=typeof fetch)return;fetch("/api/system/client-error",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),keepalive:!0}
1).catch(()=>{})}catch{}}let tJ=new Set;class tQ extends tW.default.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var a;let r,s,i=(a=t?.componentStack,{message:tK((r=e instanceof Error?e:Error(String(e))).message||String(e),500),stack:tK(r.stack,8e3),componentStack:tK(a,4e3),url:tK(window.location.href,500),userAgent:"u">typeof navigator?tK(navigator.userAgent,300):"",at:new Date().toISOString()});if(console.error("[client-error] dashboard error boundary caught a render crash",i),s=`${i.message??""}|${function(e){if(!e)return"";for(let t of e.split("\n")){let e=t.trim();if(e.startsWith("at "))return e}return""}(i.stack)}`,tJ.has(s)||(tJ.size>=50&&tJ.clear(),tJ.add(s),0))return;let n=this.props.report??tY;try{n(i)}catch{}}reset=()=>{this.setState({error:null})};render(){let{error:e}=this.state;return e?void 0!==this.props.fallback?this.props.fallback:(0,t.jsx)("div",{className:"min-h-screen flex items-center justify-center p-6 bg-gray-100 dark:bg-[#18181A] text-gray-900 dark:text-white",children:(0,t.jsxs)("div",{className:"w-full max-w-md rounded-xl border border-gray-200 dark:border-white/[0.08] bg-white dark:bg-white/[0.02] p-6",children:[(0,t.jsx)("h1",{className:"text-base font-medium",children:"This part of the dashboard stopped responding"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-gray-600 dark:text-white/60",children:"Nothing was lost. The problem has been reported. You can try again, or reload the page."}),(0,t.jsx)("p",{className:"mt-3 text-xs font-mono break-words text-gray-500 dark:text-white/40",children:e.message}),(0,t.jsxs)("div",{className:"mt-5 flex gap-2",children:[(0,t.jsx)("button",{type:"button",onClick:this.reset,className:"px-3 py-2 text-sm rounded-lg bg-gray-900 text-white dark:bg-white dark:text-black",children:"Try again"}),(0,t.jsx)("button",{type:"button",onClick:()=>{window.location.reload()},className:"px-3 py-2 text-sm rounded-lg border border-gray-200 dark:border-white/[0.12]",children:"Reload"})]})]})}):this.props.children}}let tX=e=>{};function tZ(){let{openModal:e,openModalByReservation:t,openModalByThreadId:a}=(0,f.useDashboard)(),{currentCustomerId:r}=(0,v.useCustomer)(),s=s=>r?s.dashboardItemId?(tX({message:"Loading...",type:"info"}),e(Number(s.dashboardItemId)),!0):s.reservationId?(tX({message:"Loading...",type:"info"}),t(s.reservationId,s.threadId||void 0),!0):!!s.threadId&&(tX({message:"Loading...",type:"info"}),a(s.threadId),!0):(indexedDB.open("vanio-notifications",1).onsuccess=e=>{e.target.result.transaction("pending-notifications","readwrite").objectStore("pending-notifications").add({id:Date.now(),...s,timestamp:Date.now()})},!1),n=async()=>!!r&&new Promise(e=>{let t=indexedDB.open("vanio-notifications",1);t.onupgradeneeded=e=>{let t=e.target.result;t.objectStoreNames.contains("pending-notifications")||t.createObjectStore("pending-notifications",{keyPath:"id"})},t.onsuccess=t=>{let a=t.target.result.transaction("pending-notifications","readwrite").objectStore("pending-notifications"),r=a.getAll();r.onsuccess=t=>{let r=t.target.result;if(r?.length>0){r.sort((e,t)=>t.timestamp-e.timestamp);let t=r[0];a.clear(),s(t),e(!0)}else e(!1)},r.onerror=()=>e(!1)},t.onerror=()=>e(!1)});return(0,i.useEffect)(()=>{"serviceWorker"in navigator&&navigator.serviceWorker.addEventListener("message",e=>{"NOTIFICATION_CLICKED"===e.data.type&&s(e.data)})},[]),(0,i.useEffect)(()=>{r&&n()},[r]),null}let t0=(0,T.create)((e,t)=>({isOpen:!1,taskId:null,context:"dashboard",openSidebar:(t,a="dashboard")=>e({isOpen:!0,taskId:t,context:a}),closeSidebar:()=>{e({isOpen:!1,taskId:null,context:"dashboard"});{let e=new URL(window.location.href),t=new URLSearchParams(e.search);t.delete("task"),t.delete("marketplace");let a=`${e.pathname}?${t.toString()}`;window.history.replaceState({},"",a)}}}));function t1({children:e,isImpersonating:T,initialProduct:P}){let F=new r.QueryClient({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),[L,$]=(0,i.useState)(!0);(0,_.useRouter)();let O=(0,_.usePathname)(),U=(0,_.useSearchParams)(),{openSidebar:B,isOpen:q,taskId:z,context:H,closeSidebar:V}=t0(),G=(0,D.useListingSidebarStore)();G.isOpen,G.listingId;let W=O?.startsWith("/auth"),K=O?.startsWith("/onboarding"),Y=O?.startsWith("/invoices"),J=O?.startsWith("/shared/"),{openForm:Q,isOpen:X,itemId:Z,closeForm:ee}=(0,R.useKBFormStore)(),{openTraining:et}=(0,e1.useTrainingStore)();return(0,i.useEffect)(()=>{(async()=>{window.isSecureContext&&await N.notificationService.registerServiceWorker()})()},[]),(0,i.useEffect)(()=>{let e=U?.get("task"),t=U?.get("kb"),a=U?.get("train");e&&B(e,O?.startsWith("/operations")?"operations":"dashboard"),t&&Q(t),a&&et(Number(a))},[U,B,Q,et,O]),(0,t.jsx)("div",{className:`${a.GeistSans.className} antialiased ${T?"impersonation-active":""}`,children:(0,t.jsx)(s.QueryClientProvider,{client:F,children:(0,t.jsx)(n.Providers,{attribute:"class",defaultTheme:"dark",enableSystem:!0,disableTransitionOnChange:!0,children:(0,t.jsx)(y.TooltipProvider,{children:(0,t.jsx)(tQ,{children:(0,t.jsx)(v.CustomerProvider,{children:(0,t.jsx)(k.ProductProvider,{initialProduct:P,children:(0,t.jsx)(t2,{children:W||K?e:Y||J?(0,t.jsx)("div",{className:"min-h-screen",children:e}):K?e:(0,t.jsx)(t.Fragment,{children:(0,t.jsx)(g.AchievementsProvider,{children:(0,t.jsx)(b.ActivityProvi
1der,{children:(0,t.jsxs)(p.CommandPaletteProvider,{children:[(0,t.jsx)(w.CommandHandler,{}),(0,t.jsxs)(f.DashboardProvider,{children:[(0,t.jsx)(tZ,{}),(0,t.jsx)(tG,{}),(0,t.jsx)(d.Header,{}),(0,t.jsxs)("div",{className:"relative flex flex-col min-h-[100dvh]",children:[(0,t.jsxs)("div",{className:"flex-none block",children:[(0,t.jsx)(o.NetworkStatus,{}),(0,t.jsx)(tO,{}),(0,t.jsx)("div",{className:"flex-none block md:hidden",children:(0,t.jsx)(C.DebugPush,{variant:"banner"})})]}),(0,t.jsxs)("main",{className:"flex-1 pb-[var(--shortcuts-height,0px)]",children:[(0,t.jsx)(t5,{}),(0,t.jsx)(t4,{}),(0,t.jsx)(tF,{children:(0,t.jsx)(th,{children:(0,t.jsx)("div",{className:"w-full mx-auto pl-0",children:e})})})]}),(0,t.jsxs)("div",{className:"flex-none hidden md:block",children:[T&&(0,t.jsx)(l.ImpersonationBanner,{}),(0,t.jsx)(c.Footer,{})]}),L&&(0,t.jsx)("div",{className:"hidden md:block fixed bottom-0 left-0 right-0 z-10",children:(0,t.jsx)("div",{className:"bg-gradient-to-t from-white via-white/80 to-transparent dark:from-[#1D1D1F] dark:via-[#1D1D1F]/80 dark:to-transparent",children:(0,t.jsx)("div",{className:"w-full max-w-[1920px] mx-auto px-4 md:px-6 lg:px-8",children:(0,t.jsx)(m.KeyboardShortcuts,{})})})})]}),(0,t.jsx)(u.CommandPalette,{}),(0,t.jsx)(h.SettingsSidebar,{}),(0,t.jsx)(x.NotificationsSidebar,{}),(0,t.jsx)(j.DashboardModal,{}),(0,t.jsx)(S.HistorySidebar,{}),(0,t.jsx)(tI,{}),G.isOpen&&G.listingId&&(0,t.jsx)(t.Fragment,{children:(0,t.jsx)(A.ListingSidebar,{listingId:G.listingId,isLoading:!1,zIndex:"z-50",usePortal:!0,isStatic:!1})}),q&&z&&("operations"===H?(0,t.jsx)(I.TaskModal,{taskId:z,onClose:V}):(0,t.jsx)(E.TaskSidebar,{taskId:z,onClose:V,context:H})),X&&Z&&(0,t.jsx)(M.KnowledgeItemForm,{isOpen:!0,onClose:ee,itemId:Z}),(0,t.jsx)(to,{})]})]})})})})})})})})})})})})}function t2({children:e}){let{currentCustomerId:a}=(0,v.useCustomer)(),{productConfig:r}=(0,k.useProductSafe)(),s=(0,_.usePathname)(),i=!!(s?.startsWith("/auth")||s?.startsWith("/onboarding")||s?.startsWith("/invoices")||s?.startsWith("/shared/")),n="atlas"===r.id,l=!!a&&!i&&!n;return(0,t.jsx)(P.CacheWarmer,{customerId:l?a:void 0,children:e})}function t5(){let{open:e,setOpen:a}=function(){let[e,t]=(0,i.useState)(!1);return(0,i.useEffect)(()=>{let e=()=>t(!0);return window.addEventListener("vanio:open-contact",e),()=>window.removeEventListener("vanio:open-contact",e)},[]),{open:e,setOpen:t}}();return(0,t.jsx)(tz,{open:e,onOpenChange:a})}function t4(){let{open:e,setOpen:a}=(0,tH.useFeedbackDialog)();return(0,t.jsx)(tH.FeedbackDialog,{open:e,onOpenChange:a})}},79222,957549,846594,875789,301014,257995,481755,695181,602064,e=>{"use strict";var t=e.i(843476),a=e.i(271645),r=e.i(846932),s=e.i(88653),i=e.i(373375),n=e.i(655900),l=e.i(664659),o=e.i(37727),d=e.i(686311),c=e.i(908263),m=e.i(922037),u=e.i(662031),h=e.i(174886),x=e.i(263488),g=e.i(248256),p=e.i(531278),b=e.i(816933),f=e.i(782839);function y({currentUrl:e,className:i,dashboardItemId:n,taskId:l}){let[o,m]=(0,a.useState)(!1),[w,v]=(0,a.useState)(""),[k,j]=(0,a.useState)(!1),N=(0,a.useMemo)(()=>(function(e,t={}){let a="",r="/";try{let t=new URL(e);a=t.origin,r=t.pathname}catch{a=window.location.origin}let s=null!=t.taskId?Number(t.taskId):NaN;if(Number.isFinite(s)&&s>0)return`${a}/?task=${s}`;let i=null!=t.dashboardItemId?Number(t.dashboardItemId):NaN;if(Number.isFinite(i)&&i>0)return`${a}/?item=${i}`;try{let t=new URL(e),s=t.searchParams.get("task");if(s&&Number(s)>0)return`${a}/?task=${s}`;let i=t.searchParams.get("item");if(i&&Number(i)>0)return`${a}/?item=${i}`;return`${a}${r}`}catch{return e}})(e,{taskId:l,dashboardItemId:n}),[e,l,n]),C=async()=>{if(n&&!k){j(!0);try{let e=await fetch("https://api.vanio.ai/dashboard/share",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({dashboardItemId:n})});if(!e.ok)throw Error("Failed to create share link");let{url:t}=await e.json();navigator.clipboard?(await navigator.clipboard.writeText(t),v("Public link copied to clipboard")):v("Share link created"),m(!0)}catch(e){console.error("Failed to create public share link:",e),v("Failed to create share link"),m(!0)}finally{j(!1)}}},S=async()=>
1{if("u">typeof navigator&&"function"==typeof navigator.share)try{console.log("ð Sharing URL:",N),await navigator.share({title:"Share",url:N}),v("Shared successfully"),m(!0)}catch(e){e instanceof Error&&"AbortError"!==e.name&&(console.error("Share error:",e),v("Failed to share"),m(!0))}},E=e=>{let t="",a="Check out this page";switch(console.log("ð± Sharing via",e,"URL:",N),e){case"whatsapp":t=`https://wa.me/?text=${encodeURIComponent(a+" "+N)}`;break;case"sms":t=`sms:?body=${encodeURIComponent(a+" "+N)}`;break;case"email":t=`mailto:?subject=Check this out&body=${encodeURIComponent(a+"\n\n"+N)}`;break;case"telegram":t=`https://t.me/share/url?url=${encodeURIComponent(N)}&text=${encodeURIComponent(a)}`;break;default:return}window.open(t,"_blank"),v(`Opening ${e} to share`),m(!0)};return(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsxs)(b.Popover,{children:[(0,t.jsx)(b.PopoverTrigger,{asChild:!0,children:(0,t.jsx)("button",{className:(0,c.cn)("p-1.5 rounded-md hover:bg-gray-100 dark:hover:bg-white/[0.08] transition-colors",i),children:(0,t.jsx)(u.Share2,{className:"w-4 h-4"})})}),(0,t.jsx)(b.PopoverContent,{side:"bottom",align:"end",className:"w-56 p-0 bg-white dark:bg-[#1C1C1E] border border-gray-200 dark:border-white/[0.08] z-[9998]",children:(0,t.jsxs)("div",{className:"p-1 space-y-1",children:[(0,t.jsxs)("button",{onClick:()=>{navigator.clipboard&&(console.log("ð Copying URL:",N),navigator.clipboard.writeText(N),v("URL copied to clipboard"),m(!0))},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-600 dark:text-white/80 hover:bg-gray-50 dark:hover:bg-white/[0.05] rounded-md transition-colors",children:[(0,t.jsx)(h.Copy,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:"Copy link"})]}),n&&(0,t.jsxs)("button",{onClick:C,disabled:k,className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-600 dark:text-white/80 hover:bg-gray-50 dark:hover:bg-white/[0.05] rounded-md transition-colors disabled:opacity-50",children:[k?(0,t.jsx)(p.Loader2,{className:"w-4 h-4 animate-spin"}):(0,t.jsx)(g.Globe,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:"Share timeline publicly"})]}),"u">typeof navigator&&"function"==typeof navigator.share&&(0,t.jsxs)("button",{onClick:S,className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-600 dark:text-white/80 hover:bg-gray-50 dark:hover:bg-white/[0.05] rounded-md transition-colors",children:[(0,t.jsx)(u.Share2,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:"Share..."})]}),(0,t.jsx)("div",{className:"w-full h-px bg-gray-200 dark:bg-white/[0.08] my-1"}),(0,t.jsxs)("button",{onClick:()=>E("whatsapp"),className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-600 dark:text-white/80 hover:bg-gray-50 dark:hover:bg-white/[0.05] rounded-md transition-colors",children:[(0,t.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,t.jsx)("path",{d:"M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"})}),(0,t.jsx)("span",{children:"WhatsApp"})]}),(0,t.jsxs)("button",{onClick:()=>E("sms"),className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-600 dark:text-white/80 hover:bg-gray-50 dark:hover:bg-white/[0.05] rounded-md transition-colors",children:[(0,t.jsx)(d.MessageSquare,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:"Messages"})]}),(0,t.jsxs)("button",{onClick:()=>E("email"),className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-600 dark:text-white/80 hover:bg-gray-50 dark:hover:bg-white/[0.05] rounded-md transition-colors",children:[(0,t.jsx)(x.Mail,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:"Email"})]}),(0,t.jsxs)("button",{onClick:()=>E("telegram"),className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-600 dark:text-white/80 hover:bg-gray-50 dark:hover:bg-white/[0.05] rounded-md transition-colors",children:[(0,t.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"
1currentColor",children:(0,t.jsx)("path",{d:"M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.96 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z"})}),(0,t.jsx)("span",{children:"Telegram"})]})]})})]}),(0,t.jsx)(s.AnimatePresence,{children:o&&(0,t.jsx)(r.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0},className:"fixed left-1/2 bottom-4 -translate-x-1/2 z-[9999] pointer-events-none",children:(0,t.jsx)(f.Notification,{message:w,type:"success",position:"bottom",onClose:()=>m(!1),icon:(0,t.jsx)(h.Copy,{className:"h-4 w-4 text-green-400"})})})})]})}e.s(["ShareButton",0,y],957549);let w=({onClick:e,disabled:a,icon:r,shortcut:s})=>(0,t.jsxs)("button",{onClick:e,disabled:a,className:(0,c.cn)("relative p-3 rounded-xl transition-all duration-200 group",a?"bg-gray-50 dark:bg-white/[0.02] text-gray-300 dark:text-white/20":"bg-gray-100 dark:bg-white/[0.05] hover:bg-gray-200 dark:hover:bg-white/[0.08] text-gray-500 dark:text-white/70 hover:text-gray-900 dark:hover:text-white"),children:[(0,t.jsx)(r,{className:"w-5 h-5"}),!a&&(0,t.jsx)("div",{className:"absolute left-full ml-2 top-1/2 -translate-y-1/2 hidden group-hover:block",children:(0,t.jsx)("div",{className:"bg-gray-100 dark:bg-[#18181A] rounded-md px-2 py-1",children:(0,t.jsx)(m.KeyboardShortcut,{shortcut:s})})})]});e.s(["BaseModal",0,function({isOpen:e,title:m,children:u,showNavigation:h=!1,hasNext:x=!1,hasPrevious:g=!1,rightSidebar:p,slideDirection:b="right",showCloseButton:f=!0,onCloseAction:v,onNextAction:k,onPreviousAction:j,className:N,widthClass:C,belowHeader:S=!1,dashboardItemId:E}){let I=C||"lg:w-[1100px]",T=S?"md:top-[104px]":"",[_,A]=(0,a.useState)(!1),[D,P]=(0,a.useState)(!1),R=(0,a.useRef)(0),[M,F]=(0,a.useState)(""),[L,$]=(0,a.useState)(!1),[O,U]=(0,a.useState)("");(0,a.useEffect)(()=>{if(e){R.current=window.scrollY;let e=setTimeout(()=>A(!0),150);return()=>clearTimeout(e)}A(!1),P(!1)},[e]),(0,a.useEffect)(()=>{F(new URL(window.location.href).toString())},[window.location.search,window.location.hash]);let B=(0,a.useCallback)(e=>{e&&(e.preventDefault(),e.stopPropagation()),window.dispatchEvent(new CustomEvent(v,{detail:{userInitiated:!0}})),requestAnimationFrame(()=>{window.scrollTo({top:R.current,behavior:"instant"})})},[v]);(0,a.useEffect)(()=>{let t=e=>{!document.body.hasAttribute("data-blocking-shortcuts")&&"Escape"===e.key&&v&&window.dispatchEvent(new CustomEvent(v))};return e&&window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}},[e,v,k,j,x,g]),(0,a.useEffect)(()=>{if(e){let e=window.scrollY;document.body.style.position="fixed",document.body.style.top=`-${e}px`,document.body.style.width="100%"}else{let e=document.body.style.top;document.body.style.position="",document.body.style.top="",document.body.style.width="",window.scrollTo(0,-1*parseInt(e||"0"))}return()=>{document.body.style.position="",document.body.style.top="",document.body.style.width=""}},[e,S]);let q=(0,a.useCallback)(()=>{"function"==typeof k&&k()},[k]),z=(0,a.useCallback)(()=>{"function"==typeof j&&j()},[j]);return(0,t.jsx)(s.AnimatePresence,{children:e&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(r.motion.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},className:(0,c.cn)("fixed inset-0 bg-black/60 backdrop-blur-sm",S?"z-[39]":"z-[160]",T),onClick:e=>{e.target===e.currentTarget&&B(e)}}),(0,t.jsxs)(r.motion.div,{initial:{x:"right"===b?"100%":0,y:"up"===b?"100%":0,opacity:0},animate:{x:0,y:0,opacity:1},exit:{x:"right"===b?"100%":0,y:"up"===b?"100%":0,opacity:0},transition:{type:"spring",damping:30,stiffness:300},className:(0,c.cn)("fixed inset-0",S?"z-[39]":"z-[161]",T,"lg:fixed lg:inset-y-0 lg:left-auto lg:right-0",I,N),children:[(0,t.jsx)("div",{className:"absolute inset-0",children:(0,t.jsx)("div",{className:(0,c.cn)("pointer-events-none fixed inset-y-0 right-0 flex w-full",T,"pl-0 lg:pl-10"),children:(0,t.jsx)("div",{className:(0,c.cn)("pointer-events-auto w-screen h-full ml-auto",I),onClick:e=>e.stopPropagation(),children:(0,t.jsxs)("div",{className:"h-full flex flex-col bg-white dark:bg-[#1D1D1F] backdrop-blur-xl",children:[(0,t.jsxs)("div",{className:"flex-none flex items-center justify-between px-4 py-3 bg-white dark:bg-[#1D1D1F] border-b border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[f&&(0,t.jsx)(w,{onClick:B,disabled:!1,icon:i.ChevronLeft,shortcut:"ESC"}),m&&(0,t.jsx)("h2",{className:"text-lg font-medium text-gray-900 dark:text-white/90",children:m})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[p&&(0,t.jsx)("button",{onClick:()=>P(e=>!e),className:(0,c.cn)("xl:hidden p-2 rounded-lg transition-colors",D?"bg-primary/20 text-primary":"hover:bg-white/[0.08] text-white/70"),children:(0,t.jsx)(d.MessageSquare,{className:"w-5 h-5"})}),(0,t.jsx)(y,{currentUrl:M,dashboardItemId:E}),f&&(0,t.jsx)("button",{onClick:B,className:"hidden lg:block p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.08] transition-colors",children:(0,t.jsx)(o.X,{className:"w-5 h-5 text-gray-500 dark:text-white/70"})})]})]}),(0,t.jsxs)("div",{className:"flex-1 flex min-h-0",children:[h&&(0,t.jsx)("div",{className:"hidden lg:block flex-none w-[70px] bg-gray-50 dark:bg-[#18181A] border-r border-gray-200 dark:border-white/[0.08] p-3",children:(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,t.jsx)(w,{onClick:z,disabled:!g,icon:n.ChevronUp,shortcut:"â"}),(0,t.jsx)("div",{className:"h-20 w-full rounded-xl bg-gray-100 dark:bg-white/[0.03]"}),(0,t.jsx)(w,{onClick:q,disabled:!x,icon:l.ChevronDown,shortcut:"â"})]})}),(0,t.jsx)("div",{className:"flex-1 min-w-0",children:(0,t.jsx)(s.AnimatePresence,{mode:"wait",children:_&&(0,t.jsx)(r.motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2},className:"h-full overflow-y-auto",children:u})})}),p&&(0,t.jsx)("div",{className:"hidden xl:block flex-none w-[400px] min-w-[320px] bg-gray-50 dark:bg-[#18181A] border-l border-gray-200 dark:border-white/[0.08] overflow-y-auto",children:p})]})]})})})}),(0,t.jsx)(s.AnimatePresence,{children:p&&D&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(r.motion.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},className:"xl:hidden fixed inset-0 z-[199] bg-black/50",onClick:()=>P(!1)}),(0,t.jsxs)(r.motion.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",damping:30,stiffness:300},className:(0,c.cn)("xl:hidden fixed inset-y-0 right-0 z-[200] w-[400px] max-w-[85vw]","bg-white dark:bg-[#18181A] border-l border-gray-200 dark:border-white/[0.08] overflow-y-auto shadow-2xl",T),children:[(0,t.jsx)("button",{onClick:()=>P(!1),className:"absolute top-3 right-3 z-10 p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.08] transition-colors",children:(0,t.jsx)(o.X,{className:"w-4 h-4 text-gray-500 dark:text-white/50"})}),p]})]})})]})]})})}],79222);var v=e.i(286536),k=e.i(805899),j=e.i(643531),N=e.i(503116),C=e.i(367240),S=e.i(98919),E=e.i(38982),I=e.i(289562),T=e.i(719708),_=e.i(144662),A=e.i(133820),D=e.i(657688),P=e.i(174080),R=e.i(95740),M=e.i(663854),F=e.i(555436),L=e.i(337607),$=e.i(180239);let O=()=>(0,t.jsxs)("div",{className:"flex items-center gap-1.5 animate-pulse",children:[(0,t.jsx)("div",{className:"w-5 h-5 rounded-full bg-gray-100 dark:bg-white/10"}),(0,t.jsx)("div",{className:"h-4 w-24 bg-gray-100 dark:bg-white/10 rounded"})]});function U({displayAssignee:e,isLoadingUsers:r,users:s,groups:i,onAssign:n,useAbsolutePositioning:o=!1,isTaskContext:d=!1,excludeOwners:c=!1}){let m,[u,h]=(0,a.useState)(!1),[x,g]=(0,a.useState)(""),p=(0,a.useRef)(null),b=(0,a.useRef)(null),f=(0,a.useRef)(null),[y,w]=(0,a.useState)({top:0,left:0}),v=(0,L.useTranslations)();(0,a.useEffect)(()=>{if(!u||!b.current)return;let e=()=>{let e=b.current.getBoundingClientRect();if(o)w({top:e.bottom,left:Math.max(8,e.right-280)});else if(p.current){let t=p.current.getBoundingClientRect();w({top:e.height+100,left:e.left-t.left})}};if(e(),o)return window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[u,o]);let k=(0,a.useMemo)(()=>c?(0,$.excludeOwnerAssignees)(s):s,[s,c]),j=(0,a.useMemo)(()=>{let e=x.toLowerCase();return k.filter(t=>(t.name||"").toLowerCase().includes(e)||(t.email||"").toLowerCase().includes(e))},[k,x]),N=(0,a.useMemo)(()=>{let e=x.toLowerCase();return i.filter(t=>(t.name||"").toLowerCase().includes(e)||(t.slug||"").toLowerCase().includes(e))},[i,x]),{nonOwnerEntries:C,ownerUsers:S}=(0,a.useMemo)(()=>{let e,t=Object.entries((e={},j.forEach(t=>{t.roles.forEach(a=>{e[a]||(e[a]=[]),e[a].push(t)})}),e));return{nonOwnerEntries:t.filter(([e])=>!(0,$.isOwnerTypeRole)(e)),ownerUsers:Array.from(new Map(t.filter(([e])=>(0,$.isOwnerTypeRole)(e)).flatMap(([,e])=>e).filter(e=>(0,$.isOwnerTypeUser)(e.roles)).map(e=>[e.id,e])).values())}},[j]),E=x.trim().length>0;return(0,a.useEffect)(()=>{function e(e){let t=e.target,a=p.current?.contains(t),r=f.current?.contains(t);a||r||h(!1)}return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[]),(0,t.jsxs)("div",{className:"flex-1 flex items-center relative",ref:p,children:[(0,t.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/40",children:v.tasks.header.labels.assignee}),(0,t.jsx)(T.Button,{ref:b,variant:"ghost",size:"sm",className:"flex-1 h-7 px-2 hover:bg-gray-100 dark:hover:bg-white/[0.08] relative justify-between w-auto",disabled:r,onClick:e=>{e.preventDefault(),e.stopPropagation(),h(!u)},children:(0,t.jsx)("div",{className:"flex items-center gap-1.5 w-full",children:r?(0,t.jsx)(O,{}):e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(I.Avatar,{className:"w-5 h-5 flex-shrink-0",children:"group"===e.type?(0,t.jsx)("div",{className:"flex items-center justify-center w-full h-full bg-gray-100 dark:bg-white/10 rounded-full",children:(0,t.jsx)(M.Users2,{className:"w-3 h-3 text-gray-500 dark:text-white/80"})}):"system"===e.type?(0,t.jsx)(I.AvatarImage,{src:"/favicon.ico"}):"unassigned"===e.type?(0,t.jsx)("div",{className:"flex items-center justify-center w-full h-full",children:(0,t.jsx)(R.UserCircle,{className:"w-4 h-4 text-gray-400 dark:text-white/60"})}):(0,t.jsx)(t.Fragment,{children:e.avatar?(0,t.jsx)(I.AvatarImage,{src:e.avatar}):(0,t.jsx)(I.AvatarFallback,{className:"z-10",children:e.name?.[0]||"?"})})}),(0,t.jsxs)("div",{className:"flex items-center flex-1 min-w-0",children:[(0,t.jsx)("span",{className:"text-[13px] text-gray-900 dark:text-white truncate",children:"group"===e.type?`@${e.name}`:e.name}),(0,t.jsx)(l.ChevronDown,{className:"w-3.5 h-3.5 text-gray-400 dark:text-white/40 flex-shrink-0 ml-2"})]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(R.UserCircle,{className:"w-4 h-4 flex-shrink-0"}),(0,t.jsxs)("div",{className:"flex items-center flex-1 min-w-0",children:[(0,t.jsx)("span",{className:"text-[13px] text-gray-400 dark:text-white/60",children:v.tasks.header.labels.unassigned}),(0,t.jsx)(l.ChevronDown,{className:"w-3.5 h-3.5 text-gray-400 dark:text-white/40 flex-shrink-0 ml-2"})]})]})})}),u&&(m=(0,t.jsxs)("div",{ref:f,className:"fixed z-[999] mt-1 w-[280px] bg-white dark:bg-[#1C1C1E] border border-gray-200 dark:border-white/[0.08] rounded-md shadow-lg max-h-[480px] overflow-y-auto scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-white/10 scrollbar-track-transparent",style:{to
1p:y.top,left:y.left},children:[(0,t.jsx)("div",{className:"sticky top-0 bg-white dark:bg-[#1C1C1E] z-20",children:(0,t.jsx)("div",{className:"p-2",children:(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(F.Search,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-white/40"}),(0,t.jsx)("input",{type:"text",value:x,onChange:e=>g(e.target.value),placeholder:v.tasks.header.assignment.searchPlaceholder,className:"w-full bg-gray-100 dark:bg-white/[0.05] text-sm text-gray-900 dark:text-white rounded pl-8 pr-2 py-1.5\n placeholder:text-gray-400 dark:placeholder:text-white/40 focus:outline-none focus:ring-1 focus:ring-gray-300 dark:focus:ring-white/[0.12]"})]})})}),r?(0,t.jsx)("div",{className:"p-4 flex items-center justify-center",children:(0,t.jsx)("div",{className:"w-5 h-5 border-2 border-gray-300 dark:border-white/20 border-t-gray-500 dark:border-t-white/80 rounded-full animate-spin"})}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("button",{className:"flex items-center gap-2 w-full px-2 py-1.5 hover:bg-gray-100 dark:hover:bg-[#2C2C2E]",onClick:e=>{e.preventDefault(),e.stopPropagation(),n("unassign","unassigned"),h(!1)},children:[(0,t.jsx)(R.UserCircle,{className:"w-4 h-4 text-gray-400 dark:text-white/60"}),(0,t.jsx)("span",{className:"text-sm text-gray-400 dark:text-white/60",children:v.tasks.header.assignment.unassign})]}),!d&&(0,t.jsxs)("button",{className:"flex items-center gap-2 w-full px-2 py-1.5 hover:bg-gray-100 dark:hover:bg-[#2C2C2E]",onClick:e=>{e.preventDefault(),e.stopPropagation(),n("SYSTEM","system"),h(!1)},children:[(0,t.jsx)(D.default,{src:"/favicon.ico",alt:"Vanio AI",width:16,height:16,className:"w-4 h-4 rounded-full"}),(0,t.jsx)("span",{className:"text-sm text-gray-900 dark:text-white",children:"Vanio AI"})]}),!d&&N.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"px-2 py-1 border-t border-gray-200 dark:border-white/[0.08]",children:(0,t.jsx)("p",{className:"text-xs font-medium text-gray-400 dark:text-white/40",children:v.tasks.header.assignment.groups})}),N.map(e=>(0,t.jsxs)("button",{className:"flex items-center gap-2 w-full px-2 pt-0.5 pb-2 hover:bg-gray-100 dark:hover:bg-[#2C2C2E]",onClick:t=>{t.preventDefault(),t.stopPropagation(),n(e.id,"group"),h(!1)},children:[(0,t.jsx)("div",{className:"flex items-center justify-center w-6 h-6 bg-gray-100 dark:bg-white/10 rounded-full",children:(0,t.jsx)(M.Users2,{className:"w-4 h-4 text-gray-400 dark:text-white/60"})}),(0,t.jsxs)("span",{className:"text-sm text-gray-900 dark:text-white",children:["@",e.name.charAt(0).toUpperCase()+e.name.slice(1)]})]},e.id))]}),C.map(([e,a])=>(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"px-2 py-1",children:(0,t.jsxs)("p",{className:"text-xs font-medium text-gray-400 dark:text-white/40 capitalize",children:[e,"s"]})}),a.map(e=>(0,t.jsxs)("button",{className:"flex items-center gap-2 w-full px-2 pt-0.5 pb-2 hover:bg-gray-100 dark:hover:bg-[#2C2C2E]",onClick:t=>{t.preventDefault(),t.stopPropagation(),n(e.id,"user"),h(!1)},children:[(0,t.jsxs)(I.Avatar,{className:"w-6 h-6",children:[(0,t.jsx)(I.AvatarImage,{src:e.image||void 0}),(0,t.jsx)(I.AvatarFallback,{children:e.name?.[0]||"?"})]}),(0,t.jsxs)("div",{className:"flex flex-col items-start",children:[(0,t.jsx)("span",{className:"text-sm text-gray-900 dark:text-white",children:e.name}),(0,t.jsx)("span",{className:"text-xs text-gray-400 dark:text-white/40",children:e.email})]})]},e.id))]},e)),E&&S.length>0&&(0,t.jsxs)("div",{className:"border-t border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsx)("div",{className:"px-2 py-1",children:(0,t.jsx)("p",{className:"text-xs font-medium text-gray-400 dark:text-white/40",children:v.tasks.header.assignment.owners})}),S.map(e=>(0,t.jsxs)("button",{className:"flex items-center gap-2 w-full px-2 pt-0.5 pb-2 hover:bg-gray-100 dark:hover:bg-[#2C2C2E]",onClick:t=>{t.preventDefault(),t.stopPropagation(),n(e.id,"user"),h(!1)},children:[(0,t.jsxs)(I.Avatar,{className:"w-6 h-6",children:[(0,t.jsx)(I.AvatarImage,{src:e.image||void 0}),(0,t.jsx)(I.AvatarFallback,{children:e.name?.[0]||"?"})]}),(0,t.jsxs)("div",{className:"flex flex-col items-start",children:[(0,t.jsx)("span",{className:"text-sm text-gray-900 dark:text-white",children:e.name}),(0,t.jsx)("span",{className:"text-xs text-gray-400 dark:text-white/40",children:e.email})]})]},e.id))]})]})]}),o&&"u">typeof document?(0,P.createPortal)(m,document.body):m)]})}e.s(["AssignmentDropdown",0,U],846594);var B=e.i(562710);let q=["critical","high","medium","low"];function z({itemId:e,isActive:r}){let[s,i]=(0,a.useState)(!1),[n,l]=(0,a.useState)(null),o=n??r,d=async()=>
1{if(!e||s)return;let t=!o;l(t),i(!0);try{(await fetch(`https://api.vanio.ai/dashboard-items/${e}/defend`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({enabled:t})})).ok||l(null)}catch{l(null)}finally{i(!1)}};return(0,a.useEffect)(()=>{l(null)},[r]),(0,t.jsxs)(B.Tooltip,{children:[(0,t.jsx)(B.TooltipTrigger,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",onClick:d,disabled:s,className:(0,c.cn)("flex items-center gap-1 px-2 py-0.5 rounded-full border transition-colors",o?"bg-red-500/10 border-red-500/20 hover:bg-red-500/20 text-red-400":"bg-transparent border-gray-200 dark:border-white/[0.08] hover:border-red-500/30 hover:bg-red-500/5 text-gray-400 dark:text-white/30 hover:text-red-400",s&&"opacity-50"),children:[s?(0,t.jsx)(p.Loader2,{className:"w-3 h-3 animate-spin"}):(0,t.jsx)(S.Shield,{className:"w-3 h-3"}),(0,t.jsx)("span",{className:"text-[11px] font-medium",children:"Defend"})]})}),(0,t.jsx)(B.TooltipContent,{side:"bottom",className:"text-xs max-w-[200px]",children:o?"Defend mode is active â AI handles this guest firmly. Click to deactivate.":"Activate Defend Mode â AI will be firm, stick to policy, and suppress unnecessary escalations."})]})}function H({itemId:e}){let{isSuperUser:a}=(0,A.useCustomer)();if(!a||!e)return null;let r=`/superadmin/ai-replay/${e}`;return(0,t.jsxs)(B.Tooltip,{children:[(0,t.jsx)(B.TooltipTrigger,{asChild:!0,children:(0,t.jsxs)("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:(0,c.cn)("hidden md:flex items-center gap-1 px-2 py-0.5 rounded-full border transition-colors","bg-transparent border-gray-200 dark:border-white/[0.08]","hover:border-emerald-500/30 hover:bg-emerald-500/5","text-gray-400 dark:text-white/30 hover:text-emerald-400"),children:[(0,t.jsx)(E.FlaskConical,{className:"w-3 h-3"}),(0,t.jsx)("span",{className:"text-[11px] font-medium",children:"Replay through AI"})]})}),(0,t.jsx)(B.TooltipContent,{side:"bottom",className:"text-xs max-w-[220px]",children:"Open the AI Replay Simulator for this dashboard item in a new tab. Dry-run only â no timeline post, no escalation, no real side effects."})]})}e.s(["CollaborationHeader",0,function({assignedTo:e,activeViewers:i,typingUsers:n,priority:o="medium",customerId:m,onAssign:u,onPriorityChange:h,onRead:x,className:g,readHistory:p=[],currentAssignee:f,onReminder:y,onCommand:w,isItemLoading:S=!1,currentItem:E,isActive:P=!0,onItemStatus:R}){let{users:{users:M,groups:F},isLoadingUsers:L}=(0,A.useCustomer)(),[$,O]=(0,a.useState)(null),B=(0,a.useMemo)(()=>{if($)return{id:$.id,name:$.name||"Unassigned",image:$.avatar,type:$.type};if(!f)return{id:"unassigned",name:"Unassigned",image:void 0,type:"unassigned"};if("SYSTEM"===f.id||"system"===f.type)return{id:"SYSTEM",name:"Vanio AI",image:"/Vanio.ai.png",type:"system"};if("group"===f.type||f.id&&F?.some(e=>e.id===f.id)){let e=F?.find(e=>e.id===f.id);if(e)return{id:e.id,name:e.name,type:"group",isGroup:!0}}if(f.id&&M?.length>0){let e=M.find(e=>e.id===f.id);if(e)return{id:e.id,name:e.name||f.name||"Unknown",image:e.image||f.avatar,type:f.type||"user"}}return{id:f.id||"unassigned",name:f.name||"Unknown",image:f.avatar,type:f.type||"user"}},[$,f,M,F]);B&&(B.id,B.name,B.image,B.type),(0,a.useEffect)(()=>{$&&("unassigned"===$.type?f&&f.id||O(null):f?.id===$.id&&O(null))},[f,$]);let V=(0,a.useCallback)(async(e,t)=>{try{if("unassign"===e||"unassigned"===t)return O({id:"unassigned",name:"Unassigned",type:"unassigned"}),await u({type:"unassigned"}),Promise.resolve();let a=F?.some(t=>t.id===e),r=t||(a?"group":"user"),s={id:e,name:"SYSTEM"===e?"Vanio AI":"group"===r?F?.find(t=>t.id===e)?.name||"Unknown Group":M?.find(t=>t.id===e)?.name||"Unknown",avatar:"SYSTEM"===e?"/Vanio.ai.png":"group"===r?void 0:M?.find(t=>t.id===e)?.image||"",type:r};return O(s),"user"===r?await u({type:"user",userId:e,userName:s.name,assignedAt:new Date().toISOString(),assignedBy:e,assignedByName:s.name,avatar:s.avatar}):"group"===r?await u({type:"group",groupId:e,groupName:s.name,groupSlug:F?.find(t=>t.id===e)?.slug||"",assignedAt:new Date().toISOString(),assignedBy:e,assignedByName:s.name}):"system"===r?await u({type:"system",systemId:"SYSTEM",assignedAt:new Date().toISOString(),assignedBy:e,assignedByName:s.name}):await u({type:"unassigned"}),Promise.resolve()}catch(e){return console.error("[CollaborationHeader] Assignment failed:",e),O(null),Promise.reject(e)}},[u,M,F]),G={critical:"text-priority-critical",high:"text-priority-high",medium:"text-priority-medium",low:"text-priority-low"};
1return S?(0,t.jsx)("div",{className:(0,c.cn)("px-6 py-2 md:py-4 md:px-6 border-b border-gray-200 dark:border-white/[0.08] bg-white dark:bg-[#1C1C1E]",g),children:(0,t.jsxs)("div",{className:"flex items-center justify-between min-h-[44px] md:min-h-0 md:h-auto",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 md:gap-6",children:[(0,t.jsx)("div",{className:"h-9 w-32 bg-gray-100 dark:bg-white/[0.08] rounded-lg animate-pulse"}),(0,t.jsx)("div",{className:"h-6 w-24 bg-gray-100 dark:bg-white/[0.08] rounded-full animate-pulse"})]}),(0,t.jsx)("div",{className:"h-9 w-28 bg-gray-100 dark:bg-white/[0.08] rounded-lg animate-pulse"})]})}):(0,t.jsx)("div",{className:(0,c.cn)("px-6 py-2 md:py-4 md:px-6 border-b border-gray-200 dark:border-white/[0.08] bg-white dark:bg-[#1C1C1E]",g),children:(0,t.jsxs)("div",{className:"flex items-center justify-between h-8 md:h-auto",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 md:gap-6",children:[(0,t.jsx)(U,{displayAssignee:B?{userId:B.id,name:B.name,avatar:B.image,type:B.type}:null,isLoadingUsers:L,users:M?.filter(e=>e.roles.some(e=>["admin","owner","user","concierge"].includes(e))),groups:F,onAssign:V}),(0,t.jsx)(z,{itemId:E?.id!=null?Number(E.id):void 0,isActive:E?.metadata?.defendMode===!0}),(0,t.jsx)(H,{itemId:E?.id!=null?Number(E.id):void 0}),i.length>0&&(0,t.jsxs)(b.Popover,{children:[(0,t.jsx)(b.PopoverTrigger,{asChild:!0,children:(0,t.jsxs)("div",{className:"flex items-center gap-2 cursor-pointer hover:opacity-80",children:[(0,t.jsx)(v.Eye,{className:"w-4 h-4 text-gray-400 dark:text-white/60"}),(0,t.jsx)("div",{className:"flex -space-x-2",children:i.map((e,a)=>(0,t.jsxs)(I.Avatar,{className:"w-5 h-5 flex-shrink-0",children:[(0,t.jsx)(I.AvatarImage,{src:e.avatar}),(0,t.jsx)(I.AvatarFallback,{children:e.name?.[0]||"?"})]},`${e.id}-${a}`))})]})}),(0,t.jsx)(b.PopoverContent,{align:"start",sideOffset:8,className:(0,c.cn)("w-[200px]","bg-white dark:bg-[#1C1C1E]","border border-gray-200 dark:border-white/[0.08]","shadow-xl shadow-black/5 dark:shadow-black/40","animate-in fade-in-0 zoom-in-95","z-[170]","[&>*]:bg-white dark:[&>*]:bg-[#1C1C1E]","backdrop-blur-none","overflow-hidden"),children:(0,t.jsxs)("div",{className:"bg-white dark:bg-[#1C1C1E] [&>*]:bg-white dark:[&>*]:bg-[#1C1C1E]",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-gray-600 dark:text-white/80 px-2 py-1",children:"Read History"}),(0,t.jsxs)("div",{className:"space-y-1",children:[p.map((e,a)=>(0,t.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1 hover:bg-gray-100 dark:hover:bg-[#2C2C2E]",children:[(0,t.jsxs)(I.Avatar,{className:"w-6 h-6",children:[(0,t.jsx)(I.AvatarImage,{src:e.avatar}),(0,t.jsx)(I.AvatarFallback,{children:e.userName?.[0]||"?"})]}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("p",{className:"text-sm text-gray-900 dark:text-white",children:e.userName}),(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-white/40",children:new Date(e.readAt).toLocaleString()})]})]},`${e.userId}-${e.readAt}-${a}`)),0===p.length&&(0,t.jsx)("p",{className:"text-sm text-gray-400 dark:text-white/40 px-2 py-1",children:"No read history yet"})]})]})})]}),(0,t.jsx)(s.AnimatePresence,{children:n.length>0&&(0,t.jsxs)(r.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},className:"flex items-center gap-2",children:[(0,t.jsx)(d.MessageSquare,{className:"w-4 h-4 text-gray-400 dark:text-white/60"}),(0,t.jsxs)("span",{className:"text-sm text-gray-400 dark:text-white/60",children:[n[0].name," is typing..."]})]})})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1 md:gap-0",children:[(0,t.jsxs)(_.DropdownMenu,{children:[(0,t.jsx)(_.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsxs)(T.Button,{variant:"ghost",size:"sm",className:(0,c.cn)("h-9 md:h-9","px-1.5 md:px-2","mr-1 md:mr-0","[&>*]:text-inherit","critical"===o&&["bg-priority-critical/20","hover:bg-priority-critical/30","!text-priority-critical"],"high"===o&&["bg-priority-high/20","hover:bg-priority-high/30","!text-priority-high"],"medium"===o&&["bg-priority-medium/20","hover:bg-priority-medium/30","!text-priority-medium"],"low"===o&&["bg-priority-low/20","hover:bg-priority-low/30","!text-priority-low"]),children:[(0,t.jsx)(k.Flag,{className:"w-4 h-4"}),(0,t.jsx)("span",{className:"hidden md:inline ml-2 text-sm capitalize",children:o}),(0,t.jsx)(l.ChevronDown,{className:"hidden md:inline-block w-4 h-4 ml-2 opacity-40"})]})}),(0,t.jsx)(_.DropdownMenuContent,{align:"end",sideOffset:8,className:(0,
1c.cn)("w-[150px]","bg-white dark:bg-[#1C1C1E]","border border-gray-200 dark:border-white/[0.08]","shadow-xl shadow-black/5 dark:shadow-black/40","animate-in fade-in-0 zoom-in-95","z-[170]","[&>*]:bg-white dark:[&>*]:bg-[#1C1C1E]","backdrop-blur-none","overflow-hidden"),children:(0,t.jsx)("div",{className:"bg-white dark:bg-[#1C1C1E] [&>*]:bg-white dark:[&>*]:bg-[#1C1C1E]",children:q.map(e=>(0,t.jsxs)(_.DropdownMenuItem,{className:(0,c.cn)("flex items-center gap-2 hover:bg-gray-100 dark:hover:bg-[#2C2C2E]","min-h-[44px] md:min-h-0","critical"===e&&"text-priority-critical","high"===e&&"text-priority-high","medium"===e&&"text-priority-medium","low"===e&&"text-priority-low"),onClick:()=>h(e),children:[(0,t.jsx)(k.Flag,{className:(0,c.cn)("w-4 h-4",G[e])}),(0,t.jsx)("span",{className:"text-sm capitalize",children:e})]},e))})})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1 md:gap-0 ml-0",children:[(0,t.jsx)(T.Button,{variant:"ghost",size:"sm",onClick:()=>R?.(P?"complete":"restore"),disabled:S,className:(0,c.cn)("flex items-center justify-center rounded-lg transition-colors","min-h-[44px] min-w-[44px] p-2 md:min-h-0 md:min-w-0 md:p-2","hover:bg-gray-100 dark:hover:bg-white/[0.08]","text-gray-400 dark:text-white/60 hover:text-gray-500 dark:hover:text-white/80",S&&"opacity-50 cursor-not-allowed"),title:P?"Mark as Done":"Make Active","aria-label":P?"Mark as Done":"Make Active",children:P?(0,t.jsx)(j.Check,{className:"w-5 h-5 md:w-4 md:h-4 text-gray-400 dark:text-white/60"}):(0,t.jsx)(C.RotateCcw,{className:"w-5 h-5 md:w-4 md:h-4 text-gray-400 dark:text-white/60"})}),(0,t.jsx)("button",{onClick:y,disabled:S,className:(0,c.cn)("flex items-center justify-center rounded-lg transition-colors","min-h-[44px] min-w-[44px] p-2 md:min-h-0 md:min-w-0 md:p-2","hover:bg-gray-100 dark:hover:bg-white/[0.08]","text-gray-400 dark:text-white/60 hover:text-gray-500 dark:hover:text-white/80",S&&"opacity-50 cursor-not-allowed"),title:"Set Reminder","aria-label":"Set Reminder",children:(0,t.jsx)(N.Clock,{className:"w-5 h-5"})}),(0,t.jsx)(T.Button,{onClick:()=>w?.(),variant:"ghost",size:"sm",className:(0,c.cn)("hover:bg-gray-100 dark:hover:bg-white/[0.08]","p-1.5 md:p-2","h-7 md:h-9 hidden md:block"),children:(0,t.jsx)(D.default,{src:"/Vanio.ai.png",alt:"Vanio AI",width:20,height:20,className:"w-4 h-4 md:w-5 md:h-5 opacity-60 hover:opacity-100 transition-opacity"})})]})]})]})})}],875789),e.s(["TIMELINE_EVENT_ENTRY_TYPES",0,["automation","system_note","team_action","seam_activity","price_update","price_change","reservation_update","review","issue","internal_note","reservation","task","inquiry","payment","ai_message","portal","alteration"]],301014);var V=e.i(194983),G=e.i(343432),W=e.i(514764),K=e.i(178583),Y=e.i(531245),J=e.i(342920),Q=e.i(49310);e.s(["AtSign",()=>Q.default],257995);var Q=Q,X=e.i(284765),Z=e.i(82735),ee=e.i(473708),et=e.i(387951),ea=e.i(319909),er=e.i(495242),es=e.i(431343),ei=e.i(382373),en=e.i(63209),el=e.i(284614),eo=e.i(283086),ed=e.i(390152),ec=e.i(56443);let em={US:"en-US",CA:"en-CA",GB:"en-GB",AU:"en-AU",NZ:"en-NZ",DE:"de-DE",AT:"de-AT",CH:"de-CH",FR:"fr-FR",ES:"es-ES",IT:"it-IT",PT:"pt-PT",BR:"pt-BR",NL:"nl-NL",BE:"nl-BE",SE:"sv-SE",NO:"nb-NO",DK:"da-DK",FI:"fi-FI",PL:"pl-PL",CZ:"cs-CZ",HR:"hr-HR",GR:"el-GR",BG:"bg-BG",RO:"ro-RO",HU:"hu-HU",SK:"sk-SK",JP:"ja-JP",KR:"ko-KR",CN:"zh-CN",TW:"zh-TW",IL:"he-IL",AE:"ar-AE",SA:"ar-SA",TR:"tr-TR",MX:"es-MX",AR:"es-AR",CO:"es-CO",CL:"es-CL",TH:"th-TH",ID:"id-ID",MY:"ms-MY",PH:"en-PH",IN:"en-IN",ZA:"en-ZA",IE:"en-IE"};function eu(e,t){try{let a=e;/^\d{4}-\d{2}-\d{2}$/.test(e)&&(a=`${e}T12:00:00`);let r=new Date(a);if(isNaN(r.getTime()))return e;let s=t&&em[t.toUpperCase()]||"en-US";return r.toLocaleDateString(s,{year:"numeric",month:"short",day:"numeric"})}catch{return e}}var eh=e.i(546118),ex=e.i(879002),eg=e.i(217255);function ep({watchdog:e,itemId:r,customerId:s,isDark:i}){let{data:n}=(0,eg.useSession)(),[l,d]=(0,a.useState)(!1),[m,u]=(0,a.useState)(null),h=e?.proposal?.messageId??e?.lastAlertedMessageId??void 0;if(!(e&&!e.dismissed&&!e.approval&&e.proposal)||l)return null;let x=null!==m,g=e?.proposal?.headline;async function b(e,t){let a=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(t)});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e?.error||`Request failed (${a.status})`)}return a.json()}async function f(){if(!x){u("approve");try{await b("/api/dashboard/watchdog/approve",{dashboardItemId:r,messageId:h}),d(!0)}catch(e){console.error("[WatchdogActionPill] approve failed",e),u(null)}}}async function y(){if(!x){u("dismiss");try{await b("/api/dashboard/watchdog/dismiss",{dashboardItemId:r,messageId:h}),d(!0)}catch(e){console.error("[WatchdogActionPill] dismiss failed",e),u(null)}}}function w(e){window.dispatchEvent(new CustomEvent("command:execute",{detail:{type:"direct",topic:"dashboard",event:"dashboard.assign",payload:{id:r,itemId:r,customerId:s,...e}}})),u(null),d(!0)}
1let v="inline-flex items-center gap-1.5 rounded-full px-3 py-1 text-xs font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed";return(0,t.jsxs)("div",{className:(0,c.cn)("px-3 py-2 border-b flex items-center gap-2 flex-wrap",i?"border-white/[0.08] bg-[#18181A]":"border-gray-200 bg-amber-50/60"),children:[(0,t.jsx)(en.AlertCircle,{className:"w-4 h-4 flex-none text-amber-500"}),(0,t.jsxs)("span",{className:(0,c.cn)("flex-1 min-w-0 text-xs truncate",i?"text-white/70":"text-gray-600"),children:["Vanio flagged this as waiting on a reply",g?(0,t.jsxs)("span",{className:(0,c.cn)(i?"text-white/50":"text-gray-400"),children:[" · ",g]}):null]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 flex-none",children:[(0,t.jsxs)("button",{type:"button",onClick:f,disabled:x,className:(0,c.cn)(v,"bg-emerald-500/10 text-emerald-500 hover:bg-emerald-500/20 border border-emerald-500/20"),children:["approve"===m?(0,t.jsx)(p.Loader2,{className:"w-3 h-3 animate-spin"}):(0,t.jsx)(j.Check,{className:"w-3 h-3"}),"Approve AI"]}),(0,t.jsxs)(_.DropdownMenu,{children:[(0,t.jsx)(_.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",disabled:x,className:(0,c.cn)(v,i?"bg-white/[0.06] text-white/80 hover:bg-white/[0.1] border border-white/[0.1]":"bg-gray-100 text-gray-700 hover:bg-gray-200 border border-gray-200"),children:["reassign"===m?(0,t.jsx)(p.Loader2,{className:"w-3 h-3 animate-spin"}):(0,t.jsx)(ex.UserPlus,{className:"w-3 h-3"}),"Reassign"]})}),(0,t.jsxs)(_.DropdownMenuContent,{align:"end",className:"z-[180]",children:[(0,t.jsx)(_.DropdownMenuItem,{onClick:function(){x||(u("reassign"),w({userId:"SYSTEM",userName:"Vanio AI",type:"system",metadata:{action:"system_assign"}}))},disabled:x,children:"Assign to Vanio AI"}),(0,t.jsx)(_.DropdownMenuItem,{onClick:function(){if(x)return;let e=n?.user?.id?String(n.user.id):void 0,t=n?.user?.name||e||"Me";e?(u("reassign"),w({userId:e,userName:t,type:"user",assignedBy:e,assignedByName:t,metadata:{action:"user_assign"}})):console.error("[WatchdogActionPill] no session user id â cannot assign to me")},disabled:x,children:"Assign to me"})]})]}),(0,t.jsxs)("button",{type:"button",onClick:y,disabled:x,className:(0,c.cn)(v,i?"bg-white/[0.04] text-white/60 hover:bg-white/[0.08] border border-white/[0.08]":"bg-gray-50 text-gray-500 hover:bg-gray-100 border border-gray-200"),children:["dismiss"===m?(0,t.jsx)(p.Loader2,{className:"w-3 h-3 animate-spin"}):(0,t.jsx)(o.X,{className:"w-3 h-3"}),"Dismiss"]})]})]})}var eb=e.i(374009),ef=e.i(568612);let ey=["send","send-and-complete","send-and-reassign","send-reassign-and-complete"],ew={send:{complete:!1,reassignToAi:!1},"send-and-complete":{complete:!0,reassignToAi:!1},"send-and-reassign":{complete:!1,reassignToAi:!0},"send-reassign-and-complete":{complete:!0,reassignToAi:!0}};function ev(e){return"string"==typeof e&&ey.includes(e)?ew[e]:ew.send}let ek={internal:d.MessageSquare,airbnb:V.MessageCircle,booking:J.Building,whatsapp:V.MessageCircle,email:x.Mail,sms:G.Phone,twilio:G.Phone,website:g.Globe,owner:el.User};function ej(e){if(!e)return null;let t=e.match(/^(telegram|viber|messenger|instagram|whatsapp)\.inbound$/);return t?t[1]:null}let eN=e=>{let t=(0,a.useRef)(null);return(0,a.useEffect)(()=>{let a=a=>{t.current&&!t.current.contains(a.target)&&e()};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[e]),t},eC=({users:e,isLoading:s,onSelect:i,isOpen:n,selectedIndex:l,onSelectedIndexChange:o})=>{let[d,c]=(0,a.useState)(""),m=(0,a.useRef)(null),u=eN(()=>{c("")}),h=(0,a.useMemo)(()=>[...e,{id:"vanio_ai",name:"Vanio AI",email:"[email protected]",image:"/Vanio.ai.png",roles:["ai"],active:!0,createdAt:new Date().toISOString(),language_preference:"en",location:{timezone:"UTC"}}],[e]);(0,a.useEffect)(()=>{m.current&&m.current.focus()},[]);let x=(0,$.filterOwnersUnlessSearching)(h,d).filter(e=>{let t=d.toLowerCase().trim();return!t||(e.name||"").toLowerCase().includes(t)||"isGroup"in e&&e.slug&&e.slug.toLowerCase().includes(t)}),g=e=>{n&&0!==x.length&&("ArrowDown"===e.key||"ArrowUp"===e.key?(e.preventDefault(),e.stopPropagation(),o("ArrowDown"===e.key?(l+1)%x.length:(l-1+x.length)%x.length)):"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),l>=0&&l<x.length&&i(x[l])))};return((0,a.useEffect)(()=>
1{if(n)return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[n,l,x.length]),s)?(0,t.jsx)("div",{className:"absolute bottom-full left-0 right-0 mb-2 bg-gray-900 rounded-lg border border-gray-200 dark:border-white/[0.08] shadow-xl",children:(0,t.jsx)("div",{className:"p-2 text-sm text-gray-400 dark:text-white/60",children:"Loading users..."})}):(0,t.jsxs)(r.motion.div,{ref:u,initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},className:"absolute bottom-full left-0 right-0 mb-2 bg-gray-900 rounded-lg border border-gray-200 dark:border-white/[0.08] shadow-xl",children:[(0,t.jsx)("div",{className:"p-2 border-b border-gray-200 dark:border-white/[0.08]",children:(0,t.jsx)("input",{ref:m,type:"text",value:d,onChange:e=>c(e.target.value),placeholder:"Search users...",className:"w-full bg-gray-100 dark:bg-white/[0.05] text-sm text-gray-900 dark:text-white rounded px-2 py-1 \n placeholder:text-white/40 focus:outline-none focus:ring-1 focus:ring-white/[0.12]",onClick:e=>e.stopPropagation()})}),(0,t.jsx)("div",{className:"max-h-[200px] overflow-y-auto",children:0===x.length?(0,t.jsx)("div",{className:"p-2 text-sm text-gray-400 dark:text-white/60",children:"No users or groups found"}):x.map((e,a)=>(0,t.jsxs)("div",{onClick:()=>i(e),className:` 2 flex items-center gap-2 p-2 cursor-pointer transition-colors 3 ${a===l?"bg-white/[0.08]":"hover:bg-white/[0.04]"} 4 `,children:[(0,t.jsx)(I.Avatar,{className:"w-6 h-6 flex-shrink-0",children:"isGroup"in e&&e.isGroup?(0,t.jsx)("div",{className:"flex items-center justify-center w-full h-full bg-white/10 rounded-full",children:(0,t.jsx)(M.Users2,{className:"w-3.5 h-3.5 text-gray-500 dark:text-white/80"})}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(I.AvatarImage,{src:e.image||void 0}),(0,t.jsx)(I.AvatarFallback,{children:e.name.charAt(0).toUpperCase()})]})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:e.name}),(0,t.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/40 truncate",children:"isGroup"in e&&e.isGroup?"Group":e.email})]})]},e.id))})]})},eS={guesty:"Guesty",hostaway:"Hostaway",lodgify:"Lodgify",ownerrez:"OwnerRez",beds24:"Beds24",smoobu:"Smoobu",igms:"iGMS",hospitable:"Hospitable",bookingsync:"BookingSync"},eE=e=>e.charAt(0).toUpperCase()+e.slice(1),eI=({selectedChannel:e,pmsSource:i,vrboInbox:n,onSelect:l,showLabel:o=!1,className:m,defaultChannel:u,itemType:h,sourceType:p})=>{let[b,f]=(0,a.useState)(!1),[y,w]=(0,a.useState)(""),v=(0,a.useRef)(null),k=eN(()=>{f(!1),w("")});(0,a.useEffect)(()=>{b&&v.current&&v.current.focus()},[b]);let j=(0,a.useCallback)(()=>{let e=ej(p);if(e)return[{...{telegram:{id:"telegram",label:"Telegram"},viber:{id:"viber",label:"Viber"},messenger:{id:"messenger",label:"Messenger"},instagram:{id:"instagram",label:"Instagram"},whatsapp:{id:"whatsapp",label:"WhatsApp"}}[e],icon:V.MessageCircle},{id:"email",label:"Email",icon:x.Mail},{id:"sms",label:"SMS",icon:G.Phone},{id:"internal",label:"Internal",icon:d.MessageSquare}];if("owner"===h)return[{id:"owner",label:"Owner Portal",icon:el.User},{id:"internal",label:"Internal",icon:d.MessageSquare},{id:"email",label:"Email",icon:x.Mail},{id:"sms",label:"SMS",icon:G.Phone}];let t=[{id:"internal",label:"Internal",icon:d.MessageSquare},{id:"email",label:"Email",icon:x.Mail},{id:"sms",label:"SMS",icon:G.Phone}],a=(()=>{switch(u){case"airbnb":return{id:"airbnb",label:"Airbnb",icon:V.MessageCircle};case"booking":return{id:"booking",label:"Booking",icon:J.Building};case"website":return{id:"website",label:"Website Chat",icon:g.Globe};case"vrbo":return n?{id:"vrbo",label:"VRBO",icon:V.MessageCircle}:null;default:return null}})(),r=(i?{id:i,label:a?`${a.label} (via ${eS[i]??eE(i)})`:eS[i]??eE(i),icon:a?.icon??ed.Plug}:null)??a,s=r&&!t.some(e=>e.id===r.id)?[...t,r]:t;return s.some(e=>"website"===e.id)||s.push({id:"website",label:"Website Chat",icon:g.Globe}),s},[u,h,p,i,n])().filter(e=>e.label.toLowerCase().includes(y.toLowerCase()));
4return(0,t.jsxs)("div",{className:(0,c.cn)("relative",m),ref:k,children:[(0,t.jsxs)("button",{onClick:()=>f(!b),className:"flex items-center gap-1.5 px-2 py-1 text-xs text-gray-400 hover:text-gray-300 transition-colors",children:[(()=>{if(["telegram","viber","messenger","instagram","whatsapp"].includes(e))return(0,t.jsx)(eh.BrandChannelIcon,{channel:e,size:16});let a=ek[e];return a?(0,t.jsx)(a,{className:"w-4 h-4"}):null})(),o&&(0,t.jsx)("span",{className:"text-gray-300 font-medium",children:e.charAt(0).toUpperCase()+e.slice(1)})]}),(0,t.jsx)(s.AnimatePresence,{children:b&&(0,t.jsxs)(r.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},className:"absolute bottom-full left-0 mb-2 bg-gray-900 rounded-lg border border-gray-200 dark:border-white/[0.08] shadow-xl min-w-[160px]",children:[(0,t.jsx)("div",{className:"p-2 border-b border-gray-200 dark:border-white/[0.08]",children:(0,t.jsx)("input",{ref:v,type:"text",value:y,onChange:e=>w(e.target.value),placeholder:"Search channels...",className:"w-full bg-gray-100 dark:bg-white/[0.05] text-sm text-gray-900 dark:text-white rounded px-2 py-1 \n placeholder:text-white/40 focus:outline-none focus:ring-1 focus:ring-white/[0.12]",onClick:e=>e.stopPropagation()})}),(0,t.jsx)("div",{className:"max-h-[200px] overflow-y-auto",children:j.map(a=>(0,t.jsxs)("div",{onClick:()=>{l(a.id),f(!1),w("")},className:` 5 flex items-center gap-2 p-2 cursor-pointer transition-colors 6 ${e===a.id?"bg-white/[0.08]":"hover:bg-white/[0.04]"} 7 `,children:[["telegram","viber","messenger","instagram","whatsapp"].includes(a.id)?(0,t.jsx)(eh.BrandChannelIcon,{channel:a.id,size:16,className:"text-gray-400 dark:text-white/60"}):(0,t.jsx)(a.icon,{className:"w-4 h-4 text-gray-400 dark:text-white/60"}),(0,t.jsx)("span",{className:"text-sm text-gray-900 dark:text-white",children:a.label})]},a.id))})]})})]})};function eT({onUpload:e}){let[r,s]=(0,a.useState)(!1),[i,n]=(0,a.useState)(null),[l,o]=(0,a.useState)(0),d=(0,a.useRef)([]),c=(0,a.useRef)(null),m=(0,a.useRef)(0);(0,a.useEffect)(()=>(r?(o(0),m.current=0,c.current=setInterval(()=>{o(e=>(m.current=e+1,e+1))},1e3)):c.current&&clearInterval(c.current),()=>{c.current&&clearInterval(c.current)}),[r]);let u=async()=>{if(!navigator.mediaDevices?.getUserMedia)return void alert("Audio recording is not supported in this browser.");let t=await navigator.mediaDevices.getUserMedia({audio:!0}),a=new MediaRecorder(t,{mimeType:"audio/webm;codecs=opus"});d.current=[],a.ondataavailable=e=>{e.data.size>0&&d.current.push(e.data)},a.onstop=async()=>{try{await new Promise(e=>setTimeout(e,100));let t=d.current;if(0===t.length)return void console.error("No audio chunks recorded");let a=new Blob(t,{type:"audio/webm;codecs=opus"});if(0===a.size)return void console.error("Created blob has zero size");let r=new File([a],`voice-note-${Date.now()}.webm`,{type:"audio/webm",lastModified:Date.now()});if(0===r.size)return void console.error("Created file has zero size");let s=Object.assign(r,{metadata:{duration:m.current,mimeType:"audio/webm",size:r.size}});e(s)}catch(e){console.error("Error processing audio:",e)}finally{t.getTracks().forEach(e=>e.stop())}},n(a),a.start(100),s(!0)};return(0,t.jsx)("div",{className:"flex items-center",children:r?(0,t.jsxs)(T.Button,{onClick:()=>{i&&"inactive"!==i.state&&(i.stop(),s(!1),n(null))},variant:"destructive",size:"sm",className:"p-1.5 text-red-500 hover:text-red-700",title:"Stop recording",children:[(0,t.jsx)(ea.StopCircle,{className:"w-4 h-4"}),(0,t.jsxs)("span",{className:"ml-2",children:[l,"s"]}
7)]}):(0,t.jsx)(T.Button,{onClick:u,variant:"ghost",size:"sm",className:"p-1.5 text-gray-400 dark:text-white/60 hover:text-white/90",title:"Record voice note",children:(0,t.jsx)(et.Mic,{className:"w-4 h-4"})})})}function e_({url:e,name:r,onRemove:s,metadata:i,transcription:n,originalTranscription:l}){let[d,c]=(0,a.useState)(!1),[m,u]=(0,a.useState)(i?.duration||0),[h,x]=(0,a.useState)(0),[g,p]=(0,a.useState)(null),[b,f]=(0,a.useState)(!0),[y,w]=(0,a.useState)(!1),v=(0,a.useRef)(null),k=e=>{e.preventDefault(),e.stopPropagation()};(0,a.useEffect)(()=>{let t;if(!v.current)return;let a=v.current;i?.duration?f(!1):(t=()=>{u(a.duration||0),f(!1)},a.addEventListener("loadedmetadata",t));let r=()=>x(a.currentTime||0),s=()=>{c(!1),x(0)},n=t=>{console.error("Audio playback error:",t,"URL:",e),p("Failed to load audio"),c(!1),f(!1)};return a.addEventListener("timeupdate",r),a.addEventListener("ended",s),a.addEventListener("error",n),a.load(),()=>{t&&a.removeEventListener("loadedmetadata",t),a.removeEventListener("timeupdate",r),a.removeEventListener("ended",s),a.removeEventListener("error",n)}},[i?.duration,e]);let j=async e=>{if(k(e),v.current)try{d?await v.current.pause():(p(null),await v.current.play()),c(!d)}catch(e){console.error("Playback error:",e),p("Failed to play audio"),c(!1)}},N=e=>{if(!isFinite(e)||isNaN(e)||e<0)return"--:--";let t=Math.floor(e/60),a=Math.floor(e%60);return`${t}:${a.toString().padStart(2,"0")}`};return(0,t.jsxs)("div",{className:"flex flex-col gap-3 p-3 rounded-lg bg-gray-50/80 dark:bg-white/[0.03] border border-gray-200 dark:border-white/[0.06] w-full",onClick:k,onTouchStart:k,onTouchMove:k,onTouchEnd:k,children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("audio",{ref:v,src:e,preload:"metadata"}),(0,t.jsx)("button",{onClick:j,className:"w-10 h-10 rounded-full bg-purple-500/20 flex items-center justify-center hover:bg-purple-500/30 transition-colors",type:"button",disabled:!!g||b,children:b?(0,t.jsx)("div",{className:"w-5 h-5 border-2 border-purple-400/20 border-t-purple-400 rounded-full animate-spin"}):d?(0,t.jsx)(er.Pause,{className:"w-5 h-5 text-purple-400"}):(0,t.jsx)(es.Play,{className:"w-5 h-5 text-purple-400"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(ei.Volume2,{className:"w-4 h-4 text-gray-400 dark:text-white/40"}),(0,t.jsx)("div",{className:"flex-1 h-1 bg-gray-100 dark:bg-white/[0.08] rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:"h-full bg-purple-500/50 rounded-full transition-all duration-100",style:{width:`${m?h/m*100:0}%`}})})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between mt-1",children:[(0,t.jsx)("span",{className:"text-xs text-gray-400 dark:text-white/40",children:g?(0,t.jsx)("span",{className:"text-red-400",children:g}):b?(0,t.jsx)("span",{children:"Loading..."}):`${N(h)} / ${m?N(m):"--:--"}`}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[n&&(0,t.jsx)("button",{onClick:e=>{k(e),w(!y)},className:"p-1.5 rounded-md hover:bg-gray-100 dark:hover:bg-white/[0.08] text-gray-400 dark:text-white/40 hover:text-white/70 transition-colors",title:y?"Hide transcription":"Show transcription",children:(0,t.jsx)(K.FileText,{className:"w-4 h-4"})}),r&&(0,t.jsx)("span",{className:"text-xs text-gray-400 dark:text-white/50 ml-2 truncate max-w-[120px]",children:r})]})]})]}),s&&(0,t.jsx)("button",{onClick:e=>{k(e),s()},className:"ml-2 p-1 hover:bg-gray-100 dark:hover:bg-white/[0.08] rounded-md",type:"button",children:(0,t.jsx)(o.X,{className:"w-4 h-4 text-gray-400 dark:text-white/40"})})]}),(n||l)&&y&&(0,t.jsxs)("div",{className:"mt-2 p-2 rounded-md bg-gray-50/80 dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.06]",children:[l&&l!==n&&(0,t.jsxs)("div",{className:"mb-2",children:[(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-white/40 mb-1",children:"Original Transcription:"}),(0,t.jsx)("p",{className:"text-sm text-gray-400 dark:text-white/50 whitespace-pre-wrap",children:l})]}),n&&(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-white/40 mb-1",children:"Transcription:"}),(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-white/70 whitespace-pre-wrap",children:n})]})]})]})}e.s(["TimelineComposer",0,function({onCommand:e,onCommandPaletteOpen:i,onTyping:n,replyTo:l,onCancelReply:d,className:m,defaultChannel:u="airbnb",pmsSource:h,vrboInbox:x,placeholder:g="Type a message...",disabled:p=!1,userId:b="",customerId:f="",itemId:y="",threadId:w="",onItemStatus:v,isActive:k=!0,currentAssignment:C,currentUserId:S,guestPhoneNumber:E,guestEmail:I,reservationSummary:P,itemType:R,sourceType:M,fromExternalId:F,watchdog:L}){let{users:{users:O,groups:U}}=(0,A.useCustomer)(),{settings:B}=(0,ef.useUserSettings)(),{data:q}=(0,eg.useSession)(),z=(B?.theme??"dark")!=="light",H=(0,a.useMemo)(()=>
7{if(!P?.confirmationCode)return"New Message";let e=P.confirmationCode,t=P.countryCode,a=P.checkIn?eu(P.checkIn,t):null,r=P.checkOut?eu(P.checkOut,t):null;return a&&r?`Reservation ${e} dates: ${a} - ${r}`:`Reservation ${e}`},[P?.confirmationCode,P?.checkIn,P?.checkOut,P?.countryCode]),[V,G]=(0,a.useState)([]),[J,et]=(0,a.useState)(""),[ea,er]=(0,a.useState)(!1),[es,ei]=(0,a.useState)(!1),[el,ed]=(0,a.useState)(null),[em,eh]=(0,a.useState)([]),[ex,ey]=(0,a.useState)([]),[ew,ek]=(0,a.useState)(!1),[eN,eS]=(0,a.useState)(()=>{let e=ej(M);return e||(C&&("user"!==C.type||C.userId===S)&&"group"!==C.type?"direct"!==u&&["airbnb","booking","vrbo"].includes(u)?u:"sms":"internal")}),[eE,eA]=(0,a.useState)(!1),[eD,eP]=(0,a.useState)(!1),[eR,eM]=(0,a.useState)(""),eF=(0,a.useRef)(null),[eL,e$]=(0,a.useState)(0),[eO,eU]=(0,a.useState)(!1),[eB,eq]=(0,a.useState)(E||""),[ez,eH]=(0,a.useState)(""),[eV,eG]=(0,a.useState)(""),[eW,eK]=(0,a.useState)(!1),[eY,eJ]=(0,a.useState)(""),[eQ,eX]=(0,a.useState)([]),[eZ,e0]=(0,a.useState)(null),e1=(0,a.useRef)(!1),e2=(0,a.useCallback)(e=>{n?.(e)},[n]),e5=(0,a.useCallback)((0,eb.default)(e=>{e2(e)},1e3),[e2]);(0,a.useEffect)(()=>{B?.uiPreferences?.composer?.defaultSendMode&&"internal"!==eN?e7(B.uiPreferences.composer.defaultSendMode):"internal"===eN&&e7("send")},[B?.uiPreferences?.composer?.defaultSendMode,eN]);let e4=em.length>0&&"airbnb"===eN;(0,a.useEffect)(()=>{e4&&(et(""),eF.current?.blur())},[e4]),(0,a.useEffect)(()=>{l?.channel&&eS(l.channel),l&&(setTimeout(()=>eF.current?.focus(),50),"email"===l.channel&&("forward"===l.mode?(eH(l.content||""),eG(""),l.quotedBody&&(et(l.quotedBody),setTimeout(()=>{let e=eF.current;e&&(e.setSelectionRange(0,0),e.scrollTop=0)},100))):(l.content&&eH(l.content.startsWith("Re: ")?l.content:`Re: ${l.content}`),l.sender?.email&&eG(l.sender.email))))},[l?.id]),(0,a.useEffect)(()=>{E&&eq(E)},[E]),(0,a.useEffect)(()=>{I&&!eV&&eG(I)},[I]),(0,a.useEffect)(()=>{"email"!==eN&&eK(!1),"email"!==eN||ez||l||eH(H),"email"===eN&&!e1.current&&f&&(e1.current=!0,fetch(`/api/email/inboxes?_dev_customerId=${f}`).then(e=>e.json()).then(e=>{let t=(e.inboxes||[]).filter(e=>e.isActive);eX(t),1===t.length&&e0(t[0].id)}).catch(()=>{}))},[eN]);let e3=(0,a.useRef)(!1),e6=(0,a.useRef)(!1);(0,a.useEffect)(()=>{if(e6.current)return;let e=ej(M);e&&(e6.current=!0,eS(e))},[M]),(0,a.useEffect)(()=>{let e=e=>{let t=e.detail,a=t?.content;a&&(e3.current=!0,et(e=>e?`${e} 8${a}`:a),t?.switchToGuestChannel&&("direct"!==u&&["airbnb","booking","vrbo"].includes(u)?eS(u):eS("sms")))};return window.addEventListener("composer:insert-content",e),()=>window.removeEventListener("composer:insert-content",e)},[u]),(0,a.useEffect)(()=>{if(e3.current&&eF.current){e3.current=!1;let e=eF.current;e.style.height="auto",e.style.height=`${e.scrollHeight}px`,e.focus()}},[J]);let e8=(0,a.useCallback)(async e=>{e7(e);try{await fetch("/api/user",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({uiPreferences:{composer:{defaultSendMode:e}}})})}catch(e){console.error("[TimelineComposer] Failed to update send mode preference:",e)}},[]);(0,a.useEffect)(()=>{},[eE]),(0,a.useEffect)(()=>{if(eD){let e=(0,$.sortUsersOwnersLast)(Array.isArray(O)?O:[]),t=Array.isArray(U)?U:[];if(eR.trim()){let a=eR.trim().toLowerCase();G([...e.filter(e=>(e.name||"").toLowerCase().includes(a)||(e.email||"").toLowerCase().includes(a)),...t.map(e=>({...e,isGroup:!0,name:`@${(e.name||"").charAt(0).toUpperCase()+(e.name||"").slice(1)}`,email:`group:${e.slug}`,image:null})).filter(e=>(e.name||"").toLowerCase().substring(1).includes(a)||(e.slug||"").toLowerCase().includes(a)||(e.email||"").toLowerCase().includes(a))])}else G([...e,...t.map(e=>({...e,isGroup:!0,name:`@${e.name.charAt(0).toUpperCase()+e.name.slice(1)}`,email:`group:${e.slug}`,image:null}))])}},[eR,O,U,eD]);let[e9,e7]=(0,a.useState)(()=>B?.uiPreferences?.composer?.defaultSendMode||"send"),te=(0,a.useCallback)(()=>{if((J.trim()||0!==em.length)&&y&&w&&!ea){if("email"===eN){let e=l?.mode==="forward"?eV:eV||I||"";if(!e.trim()||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim()))return void ed("Please enter a valid email address in the To field")}
8try{er(!0),e5.cancel(),e2(!1);let t=ex.filter(e=>J.includes(`@${e.username}`)||J.includes(`@${e.display}`)),a=t.length>0||"internal"===eN,r=J.toLowerCase().includes("@vanio"),s=`local-${Date.now()}`,i=["telegram","viber","messenger","instagram","whatsapp"].includes(eN);e(a?"message.user.send":"owner"===R?"message.owner.send":"message.guest.send",{localId:s,channel:a?"internal":eN,content:J.trim(),recipientType:a?"user":"guest",...("sms"===eN||"twilio"===eN)&&eB.trim()?{recipientId:eB.trim()}:{},..."email"===eN&&(eV.trim()||I)?{recipientId:eV.trim()||I}:{},...i&&F?{recipientId:F}:{},metadata:{userId:b,customerId:f,channel:a?"internal":eN,mentions:t.map(e=>e.username),mentionData:t.map(e=>({id:e.id,username:e.username,display:e.display})),dashboardItemId:y,keepAssignedToVanioAi:!a&&ev(e9).reassignToAi,threadId:w,userAvatar:q?.user?.image||void 0,..."email"===eN?{subject:ez||H,...eZ?{inboxId:eZ}:{},...eY.trim()?{cc:eY.split(",").map(e=>e.trim()).filter(Boolean)}:{}}:{},triggeredAI:r,attachments:em.map(e=>{let t=e.type;if(!t){let a=e.name.split(".").pop()?.toLowerCase();t="jpg"===a||"jpeg"===a?"jpeg":"png"===a?"png":"gif"===a?"gif":e.name.includes("voice-note")?"audio/webm":"jpeg"}let a="audio/webm"===t?"audio/webm":"video/webm"===t?"video/webm":"application/pdf"===t?"application/pdf":(t.includes("image"),"jpeg"),r={url:e.url,contentType:a,...e.transcription?{transcription:e.transcription}:{},..."audio/webm"===a&&e.metadata?{metadata:{duration:e.metadata.duration,mimeType:e.metadata.mimeType||a,size:e.metadata.size}}:{}};return"audio/webm"===a&&r.transcription&&et(e=>{let t=r.transcription||"";if(t&&e.includes(t))return e;let a=(e.trim()?e.trim()+"\n":"")+t;return t.includes("@vanio")&&eS("internal"),a}),r})}});let n=ev(e9);!a&&n.complete&&k&&v?.("complete"),et(""),ey([]),eh([]),"email"===eN&&(eH(""),eG(""),eJ(""),eK(!1),d?.()),eF.current&&(eF.current.style.height="auto")}finally{er(!1)}}},[J,eN,em,y,w,ea,e5,e2,ex,e,b,f,e9,k,v,q,eV,I,l,d]),tt=(0,a.useCallback)(()=>{e("message.guest.template",{channel:eN,content:"",...("sms"===eN||"twilio"===eN)&&eB.trim()?{recipientId:eB.trim()}:{},..."email"===eN&&I?{recipientId:I}:{},metadata:{userId:b,customerId:f}}),eA(!1)},[e,eN,b,f,eB]),ta=(0,a.useCallback)(()=>{e("message.ai.assist",{channel:eN,content:J||"",...("sms"===eN||"twilio"===eN)&&eB.trim()?{recipientId:eB.trim()}:{},..."email"===eN&&I?{recipientId:I}:{},metadata:{userId:b,customerId:f}}),eA(!1)},[e,eN,J,b,f,eB]),tr=(0,a.useCallback)(()=>{e("message.schedule",{channel:eN,content:J||"",...("sms"===eN||"twilio"===eN)&&eB.trim()?{recipientId:eB.trim()}:{},..."email"===eN&&(eV.trim()||I)?{recipientId:eV.trim()||I}:{},metadata:{userId:b,customerId:f,scheduledAt:new Date(Date.now()+36e5).toISOString(),..."email"===eN?{subject:ez||H}:{}}}),eA(!1)},[e,eN,J,b,f,eB,H,ez,eV,I]);(0,a.useEffect)(()=>{let e=e=>{if(document.activeElement===eF.current&&(!e.metaKey&&!e.ctrlKey||"Enter"!==e.key)&&(!e.metaKey&&!e.ctrlKey||"c"!==e.key&&"v"!==e.key&&"x"!==e.key&&"a"!==e.key)&&(e.metaKey||e.ctrlKey||e.altKey))return e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),!1};return window.addEventListener("keydown",e,{capture:!0,passive:!1}),()=>{window.removeEventListener("keydown",e,{capture:!0})}},[]);let ts=(0,a.useCallback)(e=>{e.stopPropagation()},[]),ti=(0,a.useCallback)(e=>{if(e.stopPropagation(),"Enter"===e.key&&(e.ctrlKey||e.metaKey)){e.preventDefault(),te();return}if((e.metaKey||e.ctrlKey)&&("c"===e.key||"v"===e.key||"x"===e.key||"a"===e.key))return},[te]),tn=e=>{e.stopPropagation()};(0,a.useEffect)(()=>()=>{e5.cancel(),e2(!1)},[e2,e5]);let tl=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(ej(M))return;let e=C?`${C.type??"user"}:${C.userId??""}:${C.groupId??""}`:"none";tl.current===e||((tl.current=e,!C||C.userId&&C.userId!==S)?eS("internal"):eS("direct"!==u&&["airbnb","booking","vrbo"].includes(u)?u:"sms"))},[C,S,u,M]);let to=(0,a.useRef)(null),td=async e=>{if(e?.length&&y&&!(em.length+e.length>10))try{ei(!0),ed(null);let t=Array.from(e);for(let e of t)if(e.type.startsWith("image/"))try{await new Promise((t,a)=>{let r=new window.Image;r.onload=()=>{URL.revokeObjectURL(r.src),t()},r.onerror=()=>{URL.revokeObjectURL(r.src),a(Error(`Cannot read image: ${e.name}`))},r.src=URL.createObjectURL(e)})}catch(e){ed(e.message||"Invalid image file"),ei(!1);return}let a=new FormData;a.append("itemId",y.toString());let r=t.map(e=>({file:e,previewUrl:URL.createObjectURL(e)}));
8t.forEach(e=>{e.type.startsWith("audio/")?(a.append("file",e,e.name),a.append(`metadata_${e.name}`,JSON.stringify({duration:e.metadata?.duration||0,mimeType:e.type,size:e.size}))):a.append("file",e)});let s=await fetch("/api/dashboard/messages/attachments",{method:"POST",credentials:"include",body:a}),i=await s.json();if(!i.success)throw Error("Failed to upload files");eh(t=>[...t,...i.attachments.map((t,a)=>{let s=e[a].type.startsWith("audio/");console.log("[TimelineComposer] Processing attachment:",{isAudioFile:s,transcription:t.transcription,originalTranscription:t.originalTranscription,metadata:t.metadata});let i={url:t.url,previewUrl:s?void 0:r[a]?.previewUrl,name:e[a].name,type:e[a].type,metadata:t.metadata,transcription:t.transcription,originalTranscription:t.originalTranscription};return s&&t.transcription&&et(e=>{let a=t.transcription||"";if(console.log("[TimelineComposer] Updating content with transcription:",{prevContent:e,transcription:a,hasTranscription:e.includes(a),originalText:t.originalTranscription}),a&&e.includes(a))return console.log("[TimelineComposer] Transcription already exists in content, skipping"),e;let r=(e.trim()?e.trim()+"\n":"")+a;return console.log("[TimelineComposer] New content:",r),a.includes("@vanio")&&(console.log("[TimelineComposer] @vanio detected, switching to internal channel"),eS("internal")),r}),i})])}catch(e){console.error("[TimelineComposer] Error uploading files:",e),ed("Failed to upload file. Please try again.")}finally{ei(!1)}};return(0,a.useEffect)(()=>{eD&&e$(0)},[eD]),(0,t.jsxs)("div",{className:(0,c.cn)("relative bg-gray-50 dark:bg-[#18181A] border-t border-gray-200 dark:border-white/[0.08]",m),children:[(0,t.jsx)("input",{type:"file",ref:to,className:"hidden",onChange:e=>td(e.target.files)}),em.length>0&&(0,t.jsxs)("div",{className:"mb-2 px-4 pt-4 space-y-2",children:[em.map((e,a)=>(0,t.jsx)("div",{className:"w-full",children:e.type&&e.type.startsWith("audio/")?(0,t.jsx)(e_,{url:e.url,name:e.name,metadata:e.metadata,transcription:e.transcription,originalTranscription:e.originalTranscription,onRemove:()=>eh(e=>e.filter((e,t)=>t!==a))}):e.type?.startsWith("image/")&&(e.previewUrl||e.url)?(0,t.jsxs)("div",{className:"relative inline-block",children:[(0,t.jsx)("img",{src:e.previewUrl||e.url,alt:e.name,className:"max-h-24 rounded-lg object-cover"}),(0,t.jsx)("button",{onClick:()=>eh(e=>e.filter((e,t)=>t!==a)),className:"absolute -top-1.5 -right-1.5 p-0.5 bg-gray-800 rounded-full border border-gray-200 dark:border-white/[0.1] hover:bg-gray-700",children:(0,t.jsx)(o.X,{className:"w-3 h-3 text-white"})})]}):(0,t.jsxs)("div",{className:"px-3 py-2 bg-gray-50/80 dark:bg-white/[0.03] rounded-lg flex items-center gap-2",children:[(0,t.jsx)(Z.Paperclip,{className:"w-4 h-4 text-gray-400 dark:text-white/40"}),(0,t.jsx)("span",{className:"text-sm text-gray-400 dark:text-white/60 flex-1 truncate",children:e.name}),(0,t.jsx)("button",{onClick:()=>eh(e=>e.filter((e,t)=>t!==a)),className:"p-1 hover:bg-gray-100 dark:hover:bg-white/[0.08] rounded-md",children:(0,t.jsx)(o.X,{className:"w-4 h-4 text-gray-400 dark:text-white/40"})})]})},a)),em.length>0&&(0,t.jsxs)("div",{className:"text-xs text-gray-400 dark:text-white/40 pl-1",children:[em.length," ",1===em.length?"file":"files"," attached (max 10)"]})]}),el&&(0,t.jsxs)("div",{className:"px-4 py-2 flex items-center gap-2 text-red-400 text-xs",children:[(0,t.jsx)(en.AlertCircle,{className:"w-3.5 h-3.5 flex-none"}),(0,t.jsx)("span",{children:el}),(0,t.jsx)("button",{onClick:()=>ed(null),className:"ml-auto p-0.5 hover:bg-white/[0.08] rounded",children:(0,t.jsx)(o.X,{className:"w-3 h-3"})})]}),(0,t.jsx)(ep,{watchdog:L,itemId:y,customerId:f,isDark:z}),l&&(0,t.jsxs)("div",{className:"px-3 py-2 border-b border-gray-200 dark:border-white/[0.08] flex items-start gap-2",onClick:ts,children:[(0,t.jsxs)("div",{className:"flex-1 text-sm",children:[(0,t.jsx)("div",{className:"text-gray-400 dark:text-white/40",children:"forward"===l.mode?"Forwarding email":`Replying to ${l.sender.name}`}),(0,t.jsx)("div",{className:"text-gray-400 dark:text-white/60 line-clamp-1",children:l.content})]}),(0,t.jsx)("button",{onClick:d,className:"flex-none text-gray-400 dark:text-white/40 hover:text-white/60",children:(0,t.jsx)(o.X,{className:"w-4 h-4"})})]}),("sms"===eN||"twilio"===eN)&&(0,t.jsx)("div",{className:"px-3 pt-1 pb-0.5 border-b border-gray-200 dark:border-white/[0.06]",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,t.jsx)("span",{className:"text-gray-400 dark:text-white/40 w-10 flex-none",children:"To"}),(0,t.jsx)("input",{type:"tel",value:eB,onChange:e=>eq(e.target.value),placeholder:"+1 (555) 123-4567",className:"flex-1 bg-transparent text-gray-700 dark:text-white/80 text-xs outline-none placeholder:text-gray-300 dark:placeholder:text-white/20"})]})}),"email"===eN&&(0,t.jsxs)("div",{className:"px-3 pt-1 pb-0.5 space-y-1 border-b border-gray-200 dark:border-white/[0.06]",children:[eQ.length>0&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,t.jsx)("span",{className:"text-gray-400 dark:text-white/40 w-10 flex-none",children:"From"}),1===eQ.length?(0,t.jsx)("span",{className:"text-gray-600 dark:text-white/60",children:eQ[0].name?(0,t.jsxs)(t.Fragment,{children:[eQ[0].name," <",eQ[0].emailAddress,">"]}):eQ[0].emailAddress}):(0,t.jsx)("select",{value:eZ||"",onChange:e=>e0(Number(e.target.value)),className:"flex-1 bg-transparent text-gray-700 dark:text-white/80 text-xs outline-none cursor-pointer",children:eQ.map(e=>(0,t.jsx)("option",{value:e.id,className:"bg-gray-900 text-white",children:e.name?`${e.name} <${e.emailAddress}>`:e.emailAddress},e.id))})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,t.jsx)("span",{className:"text-gray-400 dark:text-white/40 w-10 flex-none",children:"To"}),(0,t.jsx)("input",{type:"email",value:eV,onChange:e=>eG(e.target.value),placeholder:"[email protected]",className:"flex-1 bg-transparent text-gray-700 dark:text-white/80 text-xs outline-none placeholder:text-gray-300 dark:placeholder:text-white/20"}),!eW&&(0,t.jsx)("button",{onClick:()=>eK(!0),className:"text-gray-400 dark:text-white/30 hover:text-gray-600 dark:hover:text-white/50 text-xs",children:"CC"})]}),eW&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,t.jsx)("span",{className:"text-gray-400 dark:text-white/40 w-10 flex-none",children:"CC"}),(0,t.jsx)("input",{type:"text",value:eY,onChange:e=>eJ(e.target.value),placeholder:"[email protected]",className:"flex-1 bg-transparent text-gray-700 dark:text-white/80 text-xs outline-none placeholder:text-gray-300 dark:placeholder:text-white/20"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,t.jsx)("span",{className:"text-gray-400 dark:text-white/40 w-10 flex-none",children:"Subj"}),(0,t.jsx)("input",{type:"text",value:ez,onChange:e=>eH(e.target.value),placeholder:"Subject",className:"flex-1 bg-transparent text-gray-700 dark:text-white/80 text-xs outline-none placeholder:text-gray-300 dark:placeholder:text-white/20"})]})]}),(0,t.jsx)("div",{className:"px-3 flex items-center text-xs text-gray-400",onClick:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),onTouchMove:e=>e.stopPropagation(),onTouchEnd:e=>e.stopPropagation(),children:(0,t.jsxs)("span",{className:"flex items-center gap-1.5",onClick:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),onTouchMove:e=>e.stopPropagation(),onTouchEnd:e=>e.stopPropagation(),children:["Sending via"," ",{internal:"Internal",airbnb:"Airbnb",booking:"Booking",email:"Email",whatsapp:"WhatsApp",telegram:"Telegram",viber:"Viber",messenger:"Messenger",instagram:"Instagram",owner:"Owner Portal",sms:"SMS",twilio:"SMS",direct:"SMS"}[eN]||eN.charAt(0).toUpperCase()+eN.slice(1),(0,t.jsx)(eI,{selectedChannel:eN,onSelect:eS,defaultChannel:u,pmsSource:h,vrboInbox:x,itemType:R,sourceType:M})]})}),(0,t.jsx)(s.AnimatePresence,{children:eD&&(0,t.jsx)(eC,{users:V,isLoading:!1,onSelect:e=>{let t=eF.current;if(!t)return;let a=t.selectionStart,r=J.substring(0,a),s=r.lastIndexOf("@"),i=J.substring(a),n="isGroup"in e?`group:${e.slug}`:e.email?.split("@")[0]||e.name;ey(t=>[...t,{id:e.id,username:n,display:e.name}]),et(`${r.substring(0,s)}@${n} ${i}`),eP(!1),t.focus();let l=s+n.length+2;setTimeout(()=>{t.setSelectionRange(l,l)},0),eS("internal")}
8,isOpen:eD,selectedIndex:eL,onSelectedIndexChange:e$})}),(0,t.jsxs)(r.motion.div,{className:(0,c.cn)("relative rounded-lg transition-all duration-200","min-h-[40px] flex flex-col","bg-gray-50/80 dark:bg-white/[0.03]","border border-gray-200 dark:border-white/[0.06]","shadow-[inset_0_0_0_1px_rgba(0,0,0,0.02)] dark:shadow-[inset_0_0_0_1px_rgba(255,255,255,0.04)]","hover:border-gray-300 dark:hover:border-white/[0.08]","focus-within:border-gray-400 dark:focus-within:border-white/[0.12]","focus-within:shadow-[inset_0_0_0_1px_rgba(0,0,0,0.04)] dark:focus-within:shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] pb-2","timeline-composer"),children:[(0,t.jsxs)("div",{className:"flex items-center px-3 py-2",children:[(0,t.jsx)("div",{className:"flex items-center gap-2 lg:hidden",onTouchStart:tn,onTouchMove:tn,onTouchEnd:tn}),(0,t.jsx)("div",{className:"hidden lg:flex items-center gap-2",onClick:ts}),(0,t.jsxs)("div",{className:"flex-1 relative",children:["internal"!==eN&&(0,t.jsxs)(r.motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},className:(0,c.cn)("absolute -top-7 right-3","px-2 py-1 rounded-full","bg-amber-500/10 border border-amber-500/20","flex items-center gap-1.5","text-xs font-medium text-amber-300/90","shadow-sm shadow-amber-500/5"),children:[(0,t.jsx)(Q.default,{className:"w-3 h-3"}),(0,t.jsx)("span",{children:"owner"===R?"Sending to Owner":"Sending to Guest"})]}),(0,t.jsx)("textarea",{ref:eF,value:J,onChange:e=>{let t=e.target;et(t.value),t.value.trim()?e5(!0):(e5.cancel(),e2(!1)),t.style.height="auto",t.style.height=`${t.scrollHeight}px`;let a=t.selectionStart,r=t.value.substring(0,a),s=r.lastIndexOf("@"),i=r.substring(0,s).lastIndexOf(" ");-1!==s&&(s===(-1===i?0:i+1)||0===s)&&a-s<=15&&!r.substring(s).includes(" ")?(eM(r.substring(s+1)),eP(!0)):eP(!1)},onKeyDown:ti,onTouchStart:tn,onTouchMove:tn,onTouchEnd:tn,onFocus:e=>{ek(!0),e.stopPropagation()},onBlur:e=>{ek(!1),e.stopPropagation()},onClick:e=>e.stopPropagation(),placeholder:e4?"Airbnb doesnât support text with media":"internal"===eN?"Type a message, @ mention or @vanio":g,disabled:p||e4,className:(0,c.cn)("min-h-[36px] lg:min-h-[44px] w-full resize-none","bg-transparent px-3 py-[8px] lg:py-[10px]","text-sm outline-none disabled:opacity-50 pr-10","touch-action-manipulation","cursor-text"),rows:1,"data-composer":"timeline"}),(ew||eO||em.length>0)&&(0,t.jsxs)("div",{className:"absolute right-2 bottom-[6px] flex items-center gap-1",children:[(0,t.jsxs)(_.DropdownMenu,{open:eO,modal:!0,onOpenChange:e=>{!e&&eO?setTimeout(()=>{eU(!1)},50):eU(e)},children:[(0,t.jsx)(_.DropdownMenuTrigger,{asChild:!0,onTouchStart:e=>{e.stopPropagation()},children:(0,t.jsx)("button",{className:(0,c.cn)("p-1 rounded-full transition-all duration-200","hover:bg-gray-100 dark:hover:bg-white/[0.08]","send-and-complete"===e9&&"bg-gray-100 dark:bg-white/[0.08]",eO&&"bg-gray-200 dark:bg-white/[0.12]","z-[180]"),onClick:e=>(e.preventDefault(),e.stopPropagation(),eO||eU(!0),e.nativeEvent.stopImmediatePropagation(),!1),children:(0,t.jsx)(X.Settings2,{className:"w-4 h-4 text-gray-400 dark:text-white/60 hover:text-white/90"})})}),(0,t.jsxs)(_.DropdownMenuContent,{align:"end",sideOffset:8,onPointerDownOutside:e=>{e.preventDefault(),setTimeout(()=>eU(!1),50)},onEscapeKeyDown:e=>{e.preventDefault(),eU(!1)},onInteractOutside:e=>{e.preventDefault(),setTimeout(()=>eU(!1),50)},onClick:e=>{e.stopPropagation(),e.preventDefault()},className:(0,c.cn)("w-[220px]","bg-white dark:bg-[#1C1C1E]","border border-gray-200 dark:border-white/[0.08]","shadow-xl shadow-black/5 dark:shadow-black/40","animate-in fade-in-0 zoom-in-95","z-[180]","[&>*]:bg-white dark:[&>*]:bg-[#1C1C1E]","backdrop-blur-none","overflow-hidden"),children:[(0,t.jsxs)(_.DropdownMenuItem,{className:"flex items-center gap-2 hover:bg-gray-100 dark:hover:bg-[#2C2C2E]",onClick:e=>{e.stopPropagation(),e8("send"),eU(!1),setTimeout(()=>{eF.current&&(eF.current.focus(),ek(!0))},100)},onSelect:e=>{e.preventDefault()},children:[(0,t.jsx)(W.Send,{className:"w-4 h-4"}),(0,t.jsx)("span",{className:"text-sm",children:"Send Message"})]}),!eN.includes("internal")&&(0,t.jsxs)(_.DropdownMenuItem,{className:"flex items-center gap-2 hover:bg-gray-100 dark:hover:bg-[#2C2C2E]",onClick:e=>{e.stopPropagation(),e8("send-and-complete"),eU(!1),setTimeout(()=>{eF.current&&(eF.current.focus(),ek(!0))},100)},onSelect:e=>{e.preventDefault()},children:[(0,t.jsxs)("div",{className:"relative w-4 h-4",children:[(0,t.jsx)(W.Send,{className:"w-4 h-4"}),(0,t.jsx)("div",{className:"absolute -right-1 -bottom-1 w-3 h-3 rounded-full bg-white dark:bg-[#1C1C1E] flex items-center justify-center",children:(0,t.jsx)(j.Check,{className:"w-2 h-2 text-gray-400 dark:text-white/60"})})]}),(0,t.jsx)("span",{className:"text-sm",children:"Send & Mark as Done"})]}),!eN.includes("internal")&&(0,t.jsxs)(_.DropdownMenuItem,{className:"flex items-center gap-2 hover:bg-gray-100 dark:hover:bg-[#2C2C2E]",onClick:e=>{e.stopPropagation(),e8("send-and-reassign"),eU(!1),setTimeout(()=>{eF.current&&(eF.current.focus(),ek(!0))},100)},onSelect:e=>{e.preventDefault()},children:[(0,t.jsxs)("div",{className:"relative w-4 h-4",children:[(0,t.jsx)(W.Send,{className:"w-4 h-4"}),(0,t.jsx)("div",{className:"absolute -right-1 -bottom-1 w-3 h-3 rounded-full bg-white dark:bg-[#1C1C1E] flex items-center justify-center",children:(0,t.jsx)(eo.Sparkles,{className:"w-2 h-2 text-gray-400 dark:text-white/60"})})]}),(0,t.jsx)("span",{className:"text-sm",children:"Send & Reassign to Vanio AI"})]}),!eN.includes("internal")&&(0,t.jsxs)(_.DropdownMenuItem,{className:"flex items-center gap-2 hover:bg-gray-100 dark:hover:bg-[#2C2C2E]",onClick:e=>{e.stopPropagation(),e8("send-reassign-and-complete"),eU(!1),setTimeout(()=>{eF.current&&(eF.current.focus(),ek(!0))},100)},onSelect:e=>{e.preventDefault()},children:[(0,t.jsxs)("div",{className:"relative w-4 h-4",children:[(0,t.jsx)(W.Send,{className:"w-4 h-4"}),(0,t.jsx)("div",{className:"absolute -right-1 -bottom-1 w-3 h-3 rounded-full bg-white dark:bg-[#1C1C1E] flex items-center justify-center",children:(0,t.jsx)(eo.Sparkles,{className:"w-2 h-2 text-gray-400 dark:text-white/60"})})]}),(0,t.jsx)("span",{className:"text-sm",children:"Send, Reassign to Vanio AI & Done"})]}),eN.includes("internal")&&(0,t.jsxs)(_.DropdownMenuItem,{className:"flex items-center gap-2 hover:bg-gray-100 dark:hover:bg-[#2C2C2E] text-gray-400 dark:text-white/40",disabled:!0,onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)("div",{className:"relative w-4 h-4 opacity-40",children:[(0,t.jsx)(W.Send,{className:"w-4 h-4"}),(0,t.jsx)("div",{className:"absolute -right-1 -bottom-1 w-3 h-3 rounded-full bg-white dark:bg-[#1C1C1E] flex items-center justify-center",children:(0,t.jsx)(j.Check,{className:"w-2 h-2 text-gray-400 dark:text-white/60"})})]}),(0,t.jsx)("span",{className:"text-sm",children:"Send & Complete (Guest only)"})]})]})]}),(0,t.jsx)("button",{onMouseDown:e=>{e.preventDefault()},onMouseUp:e=>{e.preventDefault(),e.stopPropagation(),te()}
8,disabled:!J.trim()&&0===em.length||!y||!w||p||ea,className:(0,c.cn)("p-1 text-gray-400 dark:text-white/60 hover:text-white/90","disabled:opacity-40 transition-opacity","flex items-center gap-1"),type:"button",children:"internal"===eN||"send"===e9?(0,t.jsx)(W.Send,{className:"w-4 h-4"}):(0,t.jsxs)("div",{className:"relative w-4 h-4",children:[(0,t.jsx)(W.Send,{className:"w-4 h-4"}),(0,t.jsx)("div",{className:"absolute -right-1 -bottom-1 w-3 h-3 rounded-full bg-white dark:bg-[#1C1C1E] flex items-center justify-center",children:(0,t.jsx)(j.Check,{className:"w-2 h-2 text-gray-400 dark:text-white/60"})})]})})]})]})]}),(0,t.jsx)(s.AnimatePresence,{children:eE&&(0,t.jsx)(r.motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2},className:"absolute bottom-full left-0 mb-2 px-3 py-2 bg-gray-900 border border-gray-200 dark:border-white/[0.08] rounded-lg shadow-lg z-50",onClick:ts,children:(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)("button",{onClick:tt,className:"p-1.5 text-gray-400 dark:text-white/60 hover:text-white/90",children:(0,t.jsx)(K.FileText,{className:"w-4 h-4"})}),(0,t.jsx)("button",{onClick:ta,className:"p-1.5 text-gray-400 dark:text-white/60 hover:text-white/90",children:(0,t.jsx)(Y.Bot,{className:"w-4 h-4"})}),(0,t.jsx)("button",{onClick:tr,className:"p-1.5 text-gray-400 dark:text-white/60 hover:text-white/90",children:(0,t.jsx)(N.Clock,{className:"w-4 h-4"})})]})})}),(0,t.jsxs)("div",{className:"flex items-center gap-1 mt-0 px-2",children:[(0,t.jsx)(T.Button,{onClick:()=>i?.(),variant:"ghost",size:"sm",className:"p-1.5 text-gray-400 dark:text-white/60 hover:text-white/90",children:(0,t.jsx)(D.default,{src:"/Vanio.ai.png",alt:"Vanio AI",width:16,height:16,className:"w-4 h-4 opacity-60 hover:opacity-100 transition-opacity"})}),"internal"===eN&&(0,t.jsx)(eT,{onUpload:async e=>{await td({0:e,length:1})}}),(0,t.jsx)("button",{onClick:()=>{(0,ec.openFilePicker)(to.current,{accept:"image/*",capture:"environment"})},className:"p-1.5 rounded-md hover:bg-gray-100 dark:hover:bg-white/[0.08] text-gray-400 dark:text-white/40 hover:text-white/70 transition-colors",disabled:p||ea||es,title:"Take a photo",children:(0,t.jsx)(ee.Image,{className:"w-4 h-4"})}),(0,t.jsx)("button",{onClick:()=>{(0,ec.openFilePicker)(to.current,{accept:null,capture:null,multiple:!0})},className:"p-1.5 rounded-md hover:bg-gray-100 dark:hover:bg-white/[0.08] text-gray-400 dark:text-white/40 hover:text-white/70 transition-colors",disabled:p||ea||es,title:"Attach files",children:(0,t.jsx)(Z.Paperclip,{className:"w-4 h-4"})}),(0,t.jsx)("button",{"data-mentions-trigger":!0,onClick:()=>{eP(e=>!e),eD||eM("")},className:(0,c.cn)("p-1.5 rounded-md hover:bg-gray-100 dark:hover:bg-white/[0.08] text-gray-400 dark:text-white/40 hover:text-gray-500 dark:hover:text-white/70 transition-colors",eD&&"text-gray-500 dark:text-white/70"),disabled:p||ea,title:"Mention someone",children:(0,t.jsx)(Q.default,{className:(0,c.cn)("w-4 h-4 transition-colors",eD&&"text-gray-500 dark:text-white/70")})}),es&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-xs text-gray-400 dark:text-white/40",children:[(0,t.jsx)("div",{className:"w-3 h-3 border-2 border-gray-300 dark:border-white/20 border-t-white/60 rounded-full animate-spin"}),"Uploading..."]})]})]})]})}],481755);var eA=e.i(912598),eD=e.i(714004);e.s(["useRealtimeMessages",0,function(e){let t=(0,eA.useQueryClient)(),[r,s]=(0,a.useState)([]);return(0,a.useEffect)(()=>{if(!e)return;let a=eD.supabase.channel(`reservation-${e}`).on("postgres_changes",{event:"*",schema:"public",table:"messages",filter:`reservation_id=eq.${e}`},a=>{s(e=>{let t=a.new,r=e.findIndex(e=>e.id.startsWith("local-")&&e.data?.content===t.data?.content);return -1!==r?e.map((e,a)=>a===r?t:e):[...e,t]}),t.invalidateQueries({queryKey:["reservation",e]})}).subscribe();return()=>{a.unsubscribe()}},[e,t]),{messages:r}}],695181);var eP=e.i(87316),eR=e.i(711219),eM=e.i(625233),eF=e.i(586433),eL=e.i(461250),e$=e.i(646804),eO=e.i(662559),eU=e.i(358037),eB=e.i(752087),eq=e.i(489800),ez=e.i(63955),eH=e.i(148499),eV=e.i(392257);e.s(["EventsTimeline",0,function({events:e,className:a,depositStatus:s,onDepositAction:i,upsellRequests:n,upsellRequestsLoading:l}){let o=e.reduce((e,t)=>
8{let a=new Date(t.timestamp).toLocaleDateString(),r=e[e.length-1];if(r&&r.date===a)r.events.push(t),"issue"===t.type&&r.counts.issues++,"automation"===t.type&&r.counts.automations++,"task"===t.type&&r.counts.tasks++,"reservation"===t.type&&r.counts.reservations++,"review"===t.type&&r.counts.reviews++,"seam_activity"===t.type&&r.counts.activities++,"payment"===t.type&&r.counts.payments++,r.counts.total++;else{let r={date:a,events:[t],counts:{issues:+("issue"===t.type),automations:+("automation"===t.type),tasks:+("task"===t.type),reservations:+("reservation"===t.type),reviews:+("review"===t.type),activities:+("seam_activity"===t.type),payments:+("payment"===t.type),total:1}};e.push(r)}return e},[]),d=o.reduce((e,t)=>({issues:e.issues+t.counts.issues,automations:e.automations+t.counts.automations,tasks:e.tasks+t.counts.tasks,reservations:e.reservations+t.counts.reservations,reviews:e.reviews+t.counts.reviews,activities:e.activities+t.counts.activities,payments:e.payments+t.counts.payments,total:e.total+t.counts.total}),{issues:0,automations:0,tasks:0,reservations:0,reviews:0,activities:0,payments:0,total:0});return(0,t.jsxs)("div",{className:(0,c.cn)("space-y-8",a),children:[(0,t.jsx)("div",{className:"flex gap-4 text-sm text-gray-400 dark:text-white/60",children:d.issues>0&&(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)(en.AlertCircle,{className:"w-4 h-4"}),d.issues," ",1===d.issues?"Issue":"Issues"]})}),o.map((e,a)=>(0,t.jsxs)(r.motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1*a},className:"relative",children:[(0,t.jsx)("div",{className:"sticky top-0 z-10 bg-gradient-to-b from-black to-transparent pb-4",children:(0,t.jsx)("h3",{className:"text-sm font-medium text-gray-400 dark:text-white/60",children:new Date(e.date).toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric"})})}),(0,t.jsxs)("div",{className:"relative pl-4",children:[(0,t.jsx)("div",{className:"absolute left-[11px] top-0 bottom-0 w-px bg-gradient-to-b from-white/10 via-white/5 to-transparent"}),(0,t.jsx)("div",{className:"space-y-6",children:e.events.map((e,a)=>(0,t.jsxs)(r.motion.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.05*a},children:["automation"===e.type&&(0,t.jsx)(eM.AutomationEntry,{automation:e}),"issue"===e.type&&(0,t.jsx)(eF.IssueEntry,{issue:e}),"seam_activity"===e.type&&(0,t.jsx)(eL.SeamActivity,{activity:e}),("system_note"===e.type||"team_action"===e.type)&&(0,t.jsx)(e$.SystemEvent,{event:e}),"price_update"===e.type&&(0,t.jsx)(eO.PriceUpdate,{update:e}),"price_change"===e.type&&(0,t.jsx)(eO.PriceUpdate,{update:e}),"review"===e.type&&(0,t.jsx)(eU.ReviewEntry,{review:e}),"reservation_update"===e.type&&(0,t.jsx)(eB.ReservationUpdateEntry,{update:e,depositStatus:s,onAction:i,upsellRequests:n,upsellRequestsLoading:l}),"upsell_approval"===e.type&&(0,t.jsx)(eq.UpsellApprovalEntry,{update:e,onAction:i}),"calendar"===e.type&&(0,t.jsx)(ez.CalendarEntry,{entry:e}),"portal"===e.type&&(0,t.jsx)(eH.PortalEntry,{entry:e}),"alteration"===e.type&&(0,t.jsx)(eV.AlterationEntry,{alteration:e,onAction:i}),"reservation"===e.type&&(0,t.jsxs)(r.motion.div,{className:"relative flex gap-3",children:[(0,t.jsx)("div",{className:"flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center bg-blue-500/20",children:(0,t.jsx)(eP.Calendar,{className:"w-4 h-4"})}),(0,t.jsx)("div",{className:"flex-1 min-w-0",children:(0,t.jsxs)("div",{className:"bg-white dark:bg-[#1C1C1E] border border-gray-200 dark:border-white/[0.08] rounded-xl p-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"font-medium text-gray-900 dark:text-white",children:"internal_cancel"===e.data.action?"Cancelled":"reservation_created"===e.data.action?"Reservation created":e.actor.name}),"user"===e.actor.type&&e.actor.name&&(0,t.jsxs)("span",{className:"text-xs text-gray-500 dark:text-white/50",children:["by ",e.actor.name]}),e.data.source&&"user"!==e.actor.type&&(0,t.jsxs)("span",{className:"text-xs text-gray-400 dark:text-white/30",children:["via ",e.data.source]}),(0,t.jsx)("span",{className:"text-sm text-gray-400 dark:text-white/40",children:(0,eR.formatMessageTimestamp)(new Date(e.timestamp))})]}
8),(0,t.jsx)("span",{className:(0,c.cn)("text-xs px-2 py-1 rounded-full","accept"===e.data.status?"bg-green-500/20 text-green-400":"pending"===e.data.status?"bg-yellow-500/20 text-yellow-400":"bg-blue-500/20 text-blue-400"),children:e.data.status})]}),"user"===e.actor.type&&e.data.guestName&&"reservation_created"===e.data.action&&(0,t.jsxs)("div",{className:"text-xs text-gray-500 dark:text-white/40 mt-1",children:["Guest: ",e.data.guestName]})]})})]})]},`${e.type}-${e.id}-${a}`))})]})]},e.date))]})}],602064)},383652,e=>{"use strict";var t=e.i(271645),a=e.i(560491),r=e.i(568612),s=e.i(88014),i=e.i(782839);let n=(e,a)=>{let r=document.createElement("div");document.body.appendChild(r);let n=(0,s.createRoot)(r),l=()=>{n.unmount(),document.body.removeChild(r)};return n.render(t.default.createElement(i.Notification,{message:e,type:"success",onClose:l,duration:a?.duration})),a?.duration!==0&&setTimeout(l,a?.duration||3e3),l},l=(e,a)=>{let r=document.createElement("div");document.body.appendChild(r);let n=(0,s.createRoot)(r),l=()=>{n.unmount(),document.body.removeChild(r)};return n.render(t.default.createElement(i.Notification,{message:e,type:"error",onClose:l,duration:a?.duration||6e3})),a?.duration!==0&&setTimeout(l,a?.duration||6e3),l},o=e=>fetch(e).then(e=>{if(!e.ok)throw Error("Failed to fetch data");return e.json()});e.s(["useMarketplaceTasks",0,function(e){let{settings:s}=(0,r.useUserSettings)(e),[i,d]=(0,t.useState)(20),[c,m]=(0,t.useState)(1),u=s?.serviceProvider?.type==="individual"||s?.serviceProvider?.type==="company",h=`/api/tasks/marketplace?limit=${i}&offset=${(c-1)*i}${void 0!==e?`&customerId=${e}`:""}`,{data:x,error:g,isLoading:p,mutate:b}=(0,a.default)(u?h:null,o,{revalidateOnFocus:!1,revalidateOnReconnect:!1}),f=x?.total?Math.ceil(x.total/i):0,y=c>1,w=c<f,v=(0,t.useCallback)(()=>{w&&m(e=>e+1)},[w]),k=(0,t.useCallback)(()=>{y&&m(e=>e-1)},[y]),j=(0,t.useCallback)(e=>{e>=1&&e<=f&&m(e)},[f]),N=(0,t.useCallback)(e=>{d(e),m(1)},[]),C=(0,t.useCallback)(()=>{x?.hasMore&&m(e=>e+1)},[x?.hasMore]),S=(0,t.useCallback)(()=>b(),[b]),E=(0,t.useCallback)(async e=>{try{let t=await fetch("/api/tasks/marketplace/bids",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await t.json();
8if(!t.ok)throw l(a.error||"Failed to submit bid"),Error(a.error||"Failed to submit bid");return n("Your bid has been successfully submitted"),S(),a}catch(e){throw console.error("Error submitting bid:",e),e}},[S]),I=(0,t.useCallback)(async(e,t,a)=>{try{let r=await fetch("/api/tasks/marketplace/claim",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:parseInt(e),assigneeId:t,estimatedDuration:a?.estimatedDuration,notes:a?.notes})}),s=await r.json();if(!r.ok)throw l(s.error||"Failed to claim task"),Error(s.error||"Failed to claim task");return n("Task claimed successfully"),S(),s}catch(e){throw console.error("Error claiming task:",e),e}},[S]);return{tasks:x?.tasks||[],totalTasks:x?.total||0,completedTasksCount:x?.completedTasksCount||0,hasMoreTasks:x?.hasMore||!1,isLoading:p,error:g,currentPage:c,pageSize:i,totalPages:f,hasPreviousPage:y,hasNextPage:w,nextPage:v,previousPage:k,goToPage:j,changePageSize:N,loadMore:C,refresh:S,submitBid:E,claimTask:I,isServiceProvider:u,providerType:s?.serviceProvider?.type}}],383652)},436930,e=>{"use strict";var t=e.i(887652),a=e.i(271645);e.s(["useTouchState",0,()=>{let e=(0,a.useRef)(0),r=(0,a.useRef)(0),s=(0,a.useRef)(0),i=(0,a.useRef)(!1),n=(0,t.useMotionValue)(0),l=(0,a.useRef)(!1),o=(0,t.useMotionValue)(0),d=(0,t.useMotionValue)(0);return{modalTouchStart:e,modalTouchEnd:r,modalDragStartTime:s,isPulling:i,pullDeltaY:n,isDragging:l,x:o,dragProgress:d,resetAllTouchStates:()=>{e.current=0,r.current=0,s.current=0,i.current=!1,n.set(0),l.current=!1,o.set(0),d.set(0)}}}])},284467,e=>{"use strict";var t=e.i(843476),a=e.i(271645),r=e.i(37727),s=e.i(503116),i=e.i(212426),n=e.i(747697),l=e.i(952571),o=e.i(531278),d=e.i(542027),c=e.i(786419),m=e.i(494436),u=e.i(801601),h=e.i(303293),x=e.i(952999),g=e.i(908263),p=e.i(941077),b=e.i(232676),f=e.i(811462),y=e.i(133820),w=e.i(65921),v=e.i(85507),k=e.i(281547),j=e.i(173922),N=e.i(950086),C=e.i(782839),S=e.i(412016),E=e.i(846932),I=e.i(88653),T=e.i(947321);e.s(["CreateReservationPopover",0,function({dates:e,listingId:_,listing:A,calendarData:D,onClose:P}){let R=(0,a.useMemo)(()=>_,[_]),{openModalByReservation:M}=(()=>{try{return(0,b.useDashboard)()}catch{return{openModalByReservation:()=>{}}}})(),[F,L]=(0,a.useState)(!1),[$,O]=(0,a.useState)(()=>{if(e&&e.length>0){let t=[...e].sort((e,t)=>e.getTime()-t.getTime())[0];return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}`}let t=new Date;return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}`}),{data:U,isLoading:B}=(0,T.useListingCalendar)(_,$),{listing:q,isLoading:z,error:H}=(0,j.useListing)(R),{pricing:V,isLoading:G}=function(e){let{currentCustomerId:t}=(0,y.useCustomer)(),[r,s]=(0,a.useState)(null),[i,n]=(0,a.useState)(!1),[l,o]=(0,a.useState)(null);return(0,a.useEffect)(()=>{!async function(){if(e&&t){n(!0),o(null);try{let a=await fetch(`/api/listings/pricing?listingId=${e}&customerId=${t}`);if(!a.ok)throw Error("Failed to fetch pricing settings");let r=await a.json();s(r)}catch(e){console.error("Error fetching pricing:",e),o(e instanceof Error?e.message:"Failed to fetch pricing")}finally{n(!1)}}}()},[e,t]),{pricing:r,isLoading:i,error:l}}(R),[W,K]=(0,a.useState)(()=>{if(!e||0===e.length)return;let t=[...e].sort((e,t)=>e.getTime()-t.getTime()),a=new Date(t[0].getFullYear(),t[0].getMonth(),t[0].getDate()),r=new Date(t[t.length-1].getFullYear(),t[t.length-1].getMonth(),t[t.length-1].getDate());return(1===t.length||r.getTime()===a.getTime())&&(r=new Date(a.getFullYear(),a.getMonth(),a.getDate()+1)),{from:a,to:r}}),[Y,J]=(0,a.useState)(null),[Q,X]=(0,a.useState)(!1),[Z,ee]=(0,a.useState)(!1),[et,ea]=(0,a.useState)(null),[er,es]=(0,a.useState)([]),[ei,en]=(0,a.useState)([]),[el,eo]=(0,a.useState)(null),[ed,ec]=(0,a.useState)("total"),em=(0,a.useRef)(null),eu=(0,a.useCallback)(()=>{em.current&&(clearTimeout(em.current),em.current=null),X(!0)},[]),eh=(0,a.useCallback)(()=>{em.current&&clearTimeout(em.current),em.current=setTimeout(()=>{X(!1),em.current=null},200)},[]);(0,a.useEffect)(()=>()=>{em.current&&clearTimeout(em.current)},[]);let{query:ex,setQuery:eg,results:ep,isLoading:eb,setIsLoading:ef,setResults:ey,setIsSearchEnabled:ew}=function(){let[e,t]=(0,a.useState)(""),[r,s]=(0,a.useState)([]),[i,n]=(0,a.useState)(!1),[l,o]=(0,a.useState)(!0),d=(0,x.useDebounce)(e,300);return(0,a.useEffect)(()=>{let e=!0;return async function(){if(l)try{if(n(!0),!d||d.length<2)return void s([]);let t=await fetch(`/api/search/guests?q=${encodeURIComponent(d)}`),a=await t.json();if(!e)return;if(!a||!a.guests){console.error("[useGuestSearch] Invalid response format:",a),s([]);return}let r=Array.isArray(a.guests)?a.guests:[];s(r.map(e=>{let t=e.contacts?.find(e=>"email"===e.type&&e.isPrimary)?.value,a=e.contacts?.find(e=>"phone"===e.type&&e.isPrimary)?.value;return{id:e.id?.toString()||"",name:`${e.firstName||""} ${e.lastName||""}`.trim(),description:t||a||"",type:"guest",value:e.id?.toString()||"",icon:"user",shortcut:null,groupName:"Guests",contexts:[],configuration:{},label:`${e.firstName||""} ${e.lastName||""}`.trim(),metadata:{id:e.id,firstName:e.firstName,lastName:e.lastName,email:t,phone:a,preferences:e.preferences||{communicationChannel:"",checkInPreference:"",specialRequests:[],dietaryRestrictions:[]},contacts:e.contacts||[]}}}))}catch(t){console.error("[useGuestSearch] Search failed:",t),e&&s([])}finally{e&&n(!1)}}(),()=>{e=!1}},[d,l]),{query:e,setQuery:t,results:r,isLoading:i,setIsLoading:n,setResults:s,setIsSearchEnabled:o}}(),[ev,ek]=(0,a.useState)(()=>({isAdvancedMode:!1,basicFields:{checkIn:{date:(()=>
8{if(!e||0===e.length){let e=new Date;return new Date(e.getFullYear(),e.getMonth(),e.getDate())}let t=[...e].sort((e,t)=>e.getTime()-t.getTime())[0];return new Date(t.getFullYear(),t.getMonth(),t.getDate())})(),time:"16:00",timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone},checkOut:{date:(()=>{if(!e||0===e.length){let e=new Date;return new Date(e.getFullYear(),e.getMonth(),e.getDate()+1)}let t=[...e].sort((e,t)=>e.getTime()-t.getTime()),a=t[0],r=t[t.length-1],s=new Date(a.getFullYear(),a.getMonth(),a.getDate()),i=new Date(r.getFullYear(),r.getMonth(),r.getDate());return(1===t.length||i.getTime()===s.getTime())&&(i=new Date(s.getFullYear(),s.getMonth(),s.getDate()+1)),i})(),time:"10:00",timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone},guestId:0,listingId:_,guestCount:{number_of_guests:1,number_of_adults:1,number_of_children:0,number_of_infants:0,number_of_pets:0},numberOfGuests:1,basePrice:D?.basePrice||0,currency:D?.currency||"USD",status:"accept",guestDetails:{firstName:"",lastName:"",email:"",phone:""},platform:"direct"},advancedFields:{isBusinessTrip:!1,guestPreferences:{communicationChannel:"",checkInPreference:"",specialRequests:[],dietaryRestrictions:[]},guestContacts:[],fees:{cleaningFee:D?.cleaningFee||0,securityDeposit:D?.securityDeposit||0,petFee:0,extraGuestFee:0,serviceFee:0,platformFee:0,processingFee:0},taxes:D?.taxes||{vatAmount:0,cityTax:0,touristTax:0},totalTaxes:0,notes:"",specialRequests:[],amenityRequests:[],cancellationPolicy:"flexible"}}));(0,a.useEffect)(()=>{let e=q?.rules,t=q?.currency||q?.pricing?.currency||A?.currency||D?.currency||"USD";ek(a=>({...a,basicFields:{...a.basicFields,checkIn:{...a.basicFields.checkIn,time:e?.checkIn?`${e.checkIn.toString().padStart(2,"0")}:00`:a.basicFields.checkIn.time},checkOut:{...a.basicFields.checkOut,time:e?.checkOut?`${e.checkOut.toString().padStart(2,"0")}:00`:a.basicFields.checkOut.time},currency:t},advancedFields:{...a.advancedFields,cancellationPolicy:e?.cancellation?.policy||a.advancedFields.cancellationPolicy}}))},[q?.rules,q,A,V,D]);let ej=(0,a.useCallback)(e=>{if(console.group("ð
[DEBUG] handleDateChange"),console.log("ð Input received:",{newDateRange:e,hasFrom:!!e?.from,hasTo:!!e?.to,currentDateRange:W}),!e||!e.from){console.log("â No valid date range provided, exiting"),console.groupEnd();return}let t=new Date(e.from.getFullYear(),e.from.getMonth(),e.from.getDate()),a=e.to?new Date(e.to.getFullYear(),e.to.getMonth(),e.to.getDate()):null;console.log("ð§ Date processing:",{originalFrom:e.from,originalTo:e.to,processedFrom:t,processedTo:a,autoAdjustmentNeeded:!a||a&&a<t}),a?a<t&&console.log("ð Auto-adjusted: To-date was before from-date, set to next day:",a=new Date(t.getFullYear(),t.getMonth(),t.getDate()+1)):console.log("ð Auto-adjusted: No to-date provided, set to next day:",a=new Date(t.getFullYear(),t.getMonth(),t.getDate()+1));let r={from:t,to:a};console.log("â
Final adjusted range:",{from:r.from,to:r.to,nights:(0,c.differenceInDays)(r.to,r.from)}),K(r),ek(e=>({...e,basicFields:{...e.basicFields,checkIn:{...e.basicFields.checkIn,date:t},checkOut:{...e.basicFields.checkOut,date:a}}})),console.log("ð State updates triggered for dateRange and formState"),console.groupEnd()},[W]),eN=({value:e,onChange:a,field:r})=>(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),J(Y===r?null:r)},className:"flex items-center gap-2 bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg px-4 py-2 text-gray-900 dark:text-white w-[120px]",children:[(0,t.jsx)(s.Clock,{className:"w-4 h-4 text-gray-400 dark:text-white/60"}),(0,t.jsx)("span",{children:e})]}),Y===r&&(0,t.jsx)("div",{className:"absolute top-full left-0 mt-1 bg-white dark:bg-[#1C1C1E] border border-gray-200 dark:border-white/10 rounded-lg shadow-lg z-50 max-h-[300px] overflow-y-auto",onClick:e=>e.stopPropagation(),children:Array.from({length:24}).map((r,s)=>(0,t.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),a(`${s.toString().padStart(2,"0")}:00`),J(null)},className:(0,g.cn)("w-full px-4 py-2 text-left hover:bg-gray-50 dark:hover:bg-white/5 text-sm",e===`${s.toString().padStart(2,"0")}:00`?"bg-gray-200 dark:bg-white/10 text-gray-900 dark:text-white":"text-gray-500 dark:text-white/60"),children:(0,d.format)(new Date().setHours(s,0),"hh:mm a")},s))})]}),eC=(0,a.useCallback)((e,t)=>{ek(a=>({...a,basicFields:{...a.basicFields,[e]:{...a.basicFields[e],time:t}}}))},[]),eS=(0,a.useCallback)(()=>
8{if(!W?.from||!W?.to||W.to<=W.from)return 0;try{let e=(0,m.eachDayOfInterval)({start:W.from,end:W.to}).slice(0,-1).reduce((e,t,a)=>{let r=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,s=U?.days?.find(e=>e.date===r),i=s?.basePrice?parseFloat(s.basePrice):parseFloat(D?.basePrice||"0");return e+i},0);return Number(e.toFixed(2))}catch(e){return console.error("â Error calculating total base price:",e),console.groupEnd(),0}},[W,U,D?.basePrice]);(0,a.useEffect)(()=>{let e=eS();ek(t=>({...t,basicFields:{...t.basicFields,basePrice:e}}))},[W,eS]);let eE=(e,t)=>{ek(a=>({...a,basicFields:{...a.basicFields,[e]:t}}))},eI=(e,t)=>{ek(a=>({...a,advancedFields:{...a.advancedFields,[e]:t}}))},eT=(e,t,a,r=!1)=>{ek(s=>({...s,[r?"advancedFields":"basicFields"]:{...r?s.advancedFields||{}:s.basicFields,[e]:{...r?s.advancedFields?.[e]||{}:s.basicFields[e],[t]:a}}}))},e_=e=>t=>{t.stopPropagation(),ek(t=>({...t,isAdvancedMode:e}))},eA=(0,a.useCallback)(e=>{ea(e),ew(!1),eg(e.name),ef(!1),ey([]),ek(t=>({...t,basicFields:{...t.basicFields,guestId:e.metadata?.id,guestDetails:{firstName:e.metadata?.firstName,lastName:e.metadata?.lastName,email:e.metadata?.email||"",phone:e.metadata?.phone||""}},advancedFields:{...t.advancedFields,guestPreferences:{...t.advancedFields?.guestPreferences,...e.metadata?.preferences},guestContacts:e.metadata?.contacts||[]}}))},[eg,ef,ey,ew]);(0,a.useEffect)(()=>{V&&ek(e=>({...e,advancedFields:{...e.advancedFields,cleaningFee:V.cleaningFee,securityDeposit:V.securityDeposit,taxes:V.taxes,standardFees:V.standardFees}}))},[V]);let eD=e=>new Intl.NumberFormat("en-US",{style:"currency",currency:ev.basicFields.currency||"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(e/1e6),eP=(0,a.useCallback)(()=>{let t,a=W?.from||(()=>{if(!e||0===e.length){let e=new Date;return new Date(e.getFullYear(),e.getMonth(),e.getDate())}let t=[...e].sort((e,t)=>e.getTime()-t.getTime())[0];return new Date(t.getFullYear(),t.getMonth(),t.getDate())})(),r=W?.to||(()=>{if(!e||0===e.length){let e=new Date;return new Date(e.getFullYear(),e.getMonth(),e.getDate()+1)}let t=[...e].sort((e,t)=>e.getTime()-t.getTime()),a=t[0],r=t[t.length-1],s=new Date(a.getFullYear(),a.getMonth(),a.getDate()),i=new Date(r.getFullYear(),r.getMonth(),r.getDate());return(1===t.length||i.getTime()===s.getTime())&&(i=new Date(s.getFullYear(),s.getMonth(),s.getDate()+1)),i})();if(!a||!r||r<=a)return{numberOfNights:1,cleaningFee:(ev.advancedFields?.cleaningFee||0)/1e6,taxes:{vat:0,city:0,tourist:0},pricing:{base:{amount:ev.basicFields.basePrice||0},fees:{cleaning:(ev.advancedFields?.cleaningFee||0)/1e6},discounts:[],taxes:{vatAmount:0,cityTax:0,touristTax:0},totals:{currency:ev.basicFields.currency,totalAddOns:0,totalDiscounts:0,total:ev.basicFields.basePrice||0}}};let s=(0,c.differenceInDays)(r,a),i=ev.basicFields.basePrice,n=(ev.advancedFields?.cleaningFee||0)/1e6,l=ev.advancedFields?.fees?.processingFee||0,o=ev.advancedFields?.fees?.petFee||0,d=ev.advancedFields?.fees?.extraGuestFee||0,m=ev.advancedFields?.fees?.serviceFee||0,u=ev.advancedFields?.fees?.platformFee||0,h=ei.reduce((e,t)=>{let a=V?.availableAddOns?.find(e=>e.id===t.id);return e+(a?.amount||0)},0),x=i+n+(o+d+m+u)+h,g=er.reduce((e,t)=>{let a=V?.availableDiscounts?.find(e=>e.id===t);return a?.discountType==="percentage"?e+x*(a.amount/100):e+(a?.amount||0)},0),p=x-g,b=0,f=0,y=0;"total"===ed?t={totalTax:ev.advancedFields?.totalTaxes||0}:(b=ev.advancedFields?.taxes?.vatAmount||0,t={vat:b/100*p,city:(f=ev.advancedFields?.taxes?.cityTax||0)/100*p,tourist:(y=ev.advancedFields?.taxes?.touristTax||0)/100*p});let w=Object.values(t).reduce((e,t)=>e+(t||0),0);return{numberOfNights:s,cleaningFee:n,taxes:t,pricing:{base:{amount:i},fees:{cleaning:n},discounts:ev.basicFields.discounts||[],taxes:{vatAmount:b,cityTax:f,touristTax:y},totals:{currency:ev.basicFields.currency,totalAddOns:h,totalDiscounts:g,total:x-g+w},businessCosts:{processingFee:l,hostFee:ev.advancedFields?.fees?.hostFee||0}}}},[W,ev,e,ei,er,V?.availableAddOns,V?.availableDiscounts,ed]),[eR,eM]=(0,a.useState)(null);(0,a.useEffect)(()=>
8{if(V?.availableAddOns&&V?.availableDiscounts){let e=ei.map(e=>{let t=V.availableAddOns.find(t=>t.id===e.id);if(!t)return null;let a="per_night"===t.pricingType?t.amount*eP().numberOfNights*e.quantity:t.amount*e.quantity;return{id:e.id,name:t.name,description:t.description,amount:t.amount,pricingType:t.pricingType,quantity:e.quantity,appliedAmount:a}}).filter(Boolean),t=er.map(e=>{let t=V.availableDiscounts.find(t=>t.id===e);if(!t)return null;let a=ev.basicFields.basePrice||0,r="percentage"===t.discountType?a*t.amount/100:t.amount;return{id:e,name:t.name,type:t.discountType,amount:t.amount,description:t.description,discountType:t.discountType,appliedAmount:r}}).filter(Boolean);ek(a=>({...a,advancedFields:{...a.advancedFields,priceBreakdown:{...a.advancedFields?.priceBreakdown,addOns:e.filter(Boolean),discounts:t.filter(Boolean)}}}))}},[ei,er,V,ev.basicFields.basePrice]),(0,a.useEffect)(()=>{let e=()=>J(null);return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[]);let[eF,eL]=(0,a.useState)(!1);(0,a.useEffect)(()=>{eL((()=>{let{basicFields:e}=ev;return Object.values({dates:!!W?.from&&!!W?.to,checkInTime:!!e.checkIn?.time,checkOutTime:!!e.checkOut?.time,firstName:!!e.guestDetails?.firstName?.trim(),lastName:!!e.guestDetails?.lastName?.trim(),email:!!e.guestDetails?.email?.trim(),phone:!!e.guestDetails?.phone?.trim(),basePrice:e.basePrice>0,currency:!!e.currency,numberOfGuests:e.numberOfGuests>0,status:!!e.status,platform:!!e.platform}).every(e=>!0===e)})())},[W,ev.basicFields.checkIn?.time,ev.basicFields.checkOut?.time,ev.basicFields.guestDetails?.firstName,ev.basicFields.guestDetails?.lastName,ev.basicFields.guestDetails?.email,ev.basicFields.guestDetails?.phone,ev.basicFields.basePrice,ev.basicFields.currency,ev.basicFields.numberOfGuests,ev.basicFields.status,ev.basicFields.platform]),(0,a.useEffect)(()=>{let e=()=>J(null);return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[]);let e$=async e=>{e.preventDefault(),e.stopPropagation(),L(!0),eM({message:"Saving..",type:"info"});try{let e={guestId:et?.metadata?.id||`direct_${Date.now()}`,firstName:ev.basicFields.guestDetails.firstName,lastName:ev.basicFields.guestDetails.lastName,email:ev.basicFields.guestDetails.email,phone:ev.basicFields.guestDetails.phone,preferences:ev.advancedFields?.guestPreferences||{},contacts:ev.advancedFields?.guestContacts||[]},t=ev.advancedFields?.cancellationPolicy||q?.rules?.cancellation?.policy||"flexible",a=el?.priceBreakdown?.cleaning_fee?.amount||0,r=el?.priceBreakdown?.security_deposit?.amount||0,s=ev.advancedFields?.fees?.processingFee||0,i=ev.advancedFields?.fees?.hostFee||0,n={...ev.basicFields,checkIn:{...ev.basicFields.checkIn,date:`${ev.basicFields.checkIn.date.getFullYear()}-${String(ev.basicFields.checkIn.date.getMonth()+1).padStart(2,"0")}-${String(ev.basicFields.checkIn.date.getDate()).padStart(2,"0")}`},checkOut:{...ev.basicFields.checkOut,date:`${ev.basicFields.checkOut.date.getFullYear()}-${String(ev.basicFields.checkOut.date.getMonth()+1).padStart(2,"0")}-${String(ev.basicFields.checkOut.date.getDate()).padStart(2,"0")}`},checkInTime:ev.basicFields.checkIn.time,checkOutTime:ev.basicFields.checkOut.time,listingId:_,location:q?.location,propertyTypeCategory:q?.propertyTypeCategory,roomTypeCategory:q?.roomTypeCategory,guestCount:{number_of_guests:ev.basicFields.numberOfGuests,number_of_adults:ev.basicFields.numberOfGuests,number_of_children:0,number_of_infants:0,number_of_pets:0},addOns:ei.map(e=>({id:e.id,quantity:e.quantity,amount:e.amount})),cleaningFee:a,securityDeposit:r,processingFee:s,hostFee:i,petFee:ev.advancedFields?.fees?.petFee||0,extraGuestFee:ev.advancedFields?.fees?.extraGuestFee||0,serviceFee:ev.advancedFields?.fees?.serviceFee||0,platformFee:ev.advancedFields?.fees?.platformFee||0,...el,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,confirmationCode:`DIR${Date.now()}`,needsAttention:!1,hasDiscrepancy:!1,internalNotes:ev.advancedFields?.notes||"",cancellationPolicy:t,platform:ev.basicFields.platform||"direct"},l=await fetch("/api/reservations/direct",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,...n})});if(!l.ok){let e=await l.json().catch(()=>null);throw Error("string"==typeof e?.error&&e.error?e.error:"Failed to create reservation")}let o=await l.json();eM({message:"Reservation created successfully.",type:"success"});let d=o?.reservation?.id;null!=d&&M(String(d)),P()}catch(e){console.error("Error creating reservation:",e),eM({message:e instanceof Error?e.message:"Failed to create reservation",type:"error"})}finally{L(!1)}},eO=(0,a.useCallback)(e=>{eo(e)},[]),eU=(0,a.useMemo)(()=>({reservation:{pricing:{base:{amount:ev.basicFields.basePrice||0},fees:{cleaning:eP().cleaningFee,pet:ev.advancedFields?.fees?.petFee||0,extraGuest:ev.advancedFields?.fees?.extraGuestFee||0,service:ev.advancedFields?.fees?.serviceFee||0,platform:ev.advancedFields?.fees?.platformFee||0,host:ev.advancedFields?.fees?.hostFee||0},addOns:ei.map(e=>{let t=V?.availableAddOns?.find(t=>
8t.id===e.id);return{name:t?.name||"",amount:t?.amount||0,description:t?.description||"",quantity:e.quantity}}),discounts:er.map(e=>{let t=V?.availableDiscounts?.find(t=>t.id===e);if(!t)return null;let a=ev.basicFields.basePrice+eP().cleaningFee,r="percentage"===t.discountType?a*(t.amount/100):t.amount;return{id:t.id,name:t.name,type:t.discountType,amount:t.amount,description:t.description,appliedAmount:r}}).filter(Boolean),taxes:"total"===ed?{"Total Taxes":eP().taxes.totalTax||0}:{VAT:eP().taxes.vat||0,"City Tax":eP().taxes.city||0,"Tourist Tax":eP().taxes.tourist||0},totals:{currency:ev.basicFields.currency,subtotal:ev.basicFields.basePrice+eP().cleaningFee,total:eP().pricing.totals.total,totalTaxes:Object.values(eP().taxes).reduce((e,t)=>e+t,0),expected_payout_amount:eP().pricing.totals.total,host_fee:ev.advancedFields?.fees?.hostFee||0,hostPayout:eP().pricing.totals.total-(ev.advancedFields?.fees?.processingFee||0)-(ev.advancedFields?.fees?.hostFee||0),totalDiscounts:eP().pricing.totals.totalDiscounts,totalAddOns:eP().pricing.totals.totalAddOns}},dates:{numberOfNights:eP().numberOfNights},businessCosts:{processingFee:ev.advancedFields?.fees?.processingFee||0,hostFee:ev.advancedFields?.fees?.hostFee||0}},listing:{businessModel:q?.businessDetails},onPriceBreakdownUpdate:eO,originalThreadData:{reservationMetadata:{pricing:{paymentStatus:"pending"}}}}),[ev.basicFields.basePrice,ev.basicFields.currency,ei,V?.availableAddOns,eP,q?.businessDetails,ed,ev.advancedFields?.fees?.petFee,ev.advancedFields?.fees?.extraGuestFee,ev.advancedFields?.fees?.serviceFee,ev.advancedFields?.fees?.platformFee,ev.advancedFields?.fees?.hostFee,ev.advancedFields?.fees?.processingFee]),[eB,eq]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{let e=e=>{let t=document.activeElement;if(t?.closest("[data-reservation-popover]")){if(("a"===e.key||"A"===e.key)&&(e.metaKey||e.ctrlKey)||("c"===e.key||"C"===e.key||"v"===e.key||"V"===e.key||"x"===e.key||"X"===e.key)&&(e.metaKey||e.ctrlKey))return;if(e.metaKey||e.ctrlKey||e.altKey)return e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),!1}};return window.addEventListener("keydown",e,{capture:!0,passive:!1}),()=>{window.removeEventListener("keydown",e,{capture:!0})}},[]),(0,a.useEffect)(()=>{U?.days&&U.days.filter(e=>e.date.startsWith("2025-04")).sort((e,t)=>e.date.localeCompare(t.date)).reduce((e,t)=>({total:e.total+1,closed:e.closed+ +!!t.closed,busy:e.busy+ +("busy"===t.availabilityType),available:e.available+ +("available"===t.availabilityType),withPrice:e.withPrice+ +!!t.basePrice,byAvailabilityType:{...e.byAvailabilityType,[t.availabilityType]:(e.byAvailabilityType[t.availabilityType]||0)+1},bySubType:{...e.bySubType,[t.availabilitySubType]:(e.bySubType[t.availabilitySubType]||0)+1}}),{total:0,closed:0,busy:0,available:0,withPrice:0,byAvailabilityType:{},bySubType:{}})},[U]),(0,t.jsxs)("div",{"data-reservation-popover":"true",className:"fixed inset-0 bg-black/20 backdrop-blur-sm z-50",children:[(0,t.jsx)("div",{className:"min-h-screen flex items-center justify-center p-4",children:(0,t.jsx)("div",{className:"fixed inset-0 overflow-hidden",children:(0,t.jsx)("div",{className:"pointer-events-none fixed inset-y-0 right-0 flex max-w-full",children:(0,t.jsxs)("div",{className:"pointer-events-auto w-full md:w-auto md:max-w-[1000px] pb-20",children:[(0,t.jsxs)("form",{onSubmit:e=>{e.preventDefault(),e$(e)},className:"flex h-full flex-col bg-white dark:bg-[#1C1C1E]",children:[(0,t.jsxs)("div",{className:"sticky top-0 bg-white dark:bg-[#1C1C1E] z-10 border-b border-gray-200 dark:border-white/10",children:[(0,t.jsxs)("div",{className:"flex justify-between items-center p-4 md:p-6 pb-4",children:[(0,t.jsx)("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"New Reservation"}),(0,t.jsx)("button",{onClick:P,className:"text-gray-400 dark:text-white/60 hover:text-gray-900 dark:hover:text-white",children:(0,t.jsx)(r.X,{className:"w-5 h-5"})})]}),(0,t.jsxs)("div",{className:"px-4 md:px-6 flex gap-4 items-center",children:[(0,t.jsx)("button",{onClick:e_(!1),type:"button",className:(0,g.cn)("pb-2 text-sm font-medium transition-colors relative",ev.isAdvancedMode?"text-gray-400 dark:text-white/60 hover:text-gray-900 dark:hover:text-white":"text-gray-900 dark:text-white border-b-2 border-gray-900 dark:border-white"),children:"Basic Details"}),(0,t.jsx)("button",{onClick:e_(!0),className:(0,g.cn)("pb-2 text-sm font-medium transition-colors relative",ev.isAdvancedMode?"text-gray-900 dark:text-white border-b-2 border-gray-900 dark:border-white":"text-gray-400 dark:text-white/60 hover:text-gray-900 dark:hover:text-white"),type:"button",children:"Advanced Options"}),(0,t.jsxs)("button",{onClick:()=>eq(!0),className:"md:hidden ml-auto pb-2 text-sm font-medium text-gray-400 dark:text-white/60 hover:text-gray-900 dark:hover:text-white flex items-center gap-2",type:"button",children:[(0,t.jsx)("span",{children:"->"}),(0,t.jsx)("span",{className:"text-xs text-gray-400 dark:text-white/40",children:el?.priceBreakdown?.total_paid_amount?.amount?`($${el.priceBreakdown.total_paid_amount.amount.toFixed(2)})`:null})]})]})]}),(0,t.jsxs)("div",{className:"flex flex-col md:flex-row flex-1 overflow-hidden",children:[(0,t.jsx)("div",{className:"flex-1 overflow-y-auto min-w-0 md:min-w-[650px]",children:(0,t.jsxs)("div",{className:"p-0 md:p-6 space-y-6 pb-24 md:pb-6",children:[(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsx)("div",{className:"space-y-4",children:(0,t.jsxs)("div",{className:"px-6 md:px-0",children:[Q&&(0,t.jsxs)("div",{className:"bg-gray-50 dark:bg-white/5 rounded-lg p-4 mb-4",onMouseDown:e=>e.preventDefault(),children:[B?(0,t.jsx)(w.Skeleton,{className:"h-[400px] w-full bg-gray-100 dark:bg-white/5"}):(0,t.jsx)(p.Calendar,{mode:"range",selected:W,onSelect:ej,numberOfMonths:window.innerWidth<768?1:2,month:new Date(`${$}-01T12:00:00`),onMonthChange:e=>{O(`${e.getFullYear()}
8-${String(e.getMonth()+1).padStart(2,"0")}`)},className:"bg-white dark:bg-[#1C1C1E]",modifiers:{reserved:e=>{let t=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`;return!!U?.days?.find(e=>e.date===t)&&(U?.reservations?.some(t=>{if("cancelled"===t.status)return!1;let a=new Date(t.checkIn),r=new Date(t.checkOut);return e>=a&&e<r&&Number(t.listingId)===_})||!1)},unavailable:e=>{let t=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,a=U?.days?.find(e=>e.date===t);if(!a)return!0;let r=U?.reservations?.some(t=>{if("cancelled"===t.status)return!1;let a=new Date(t.checkIn),r=new Date(t.checkOut);return e>=a&&e<r&&Number(t.listingId)===_})||!1;return!((a.availableUnits??1)>0)&&!r}},modifiersStyles:{reserved:{backgroundColor:"rgba(34, 197, 94, 0.2)",color:"rgba(255, 255, 255, 0.9)"},unavailable:{backgroundColor:"rgba(255, 255, 255, 0.1)",color:"rgba(255, 255, 255, 0.4)",cursor:"not-allowed"}},disabled:e=>{let t=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,a=U?.days?.find(e=>e.date===t);if(!a)return!0;U?.reservations?.filter(t=>{if("cancelled"===t.status||Number(t.listingId)!==_)return!1;let a=new Date(t.checkIn),r=new Date(t.checkOut);return e>=a&&e<=r});let r=U?.reservations?.some(e=>{if("cancelled"===e.status||Number(e.listingId)!==_)return!1;let a=e.checkIn.split("T")[0],r=e.checkOut.split("T")[0];return t>a&&t<r})||!1;if(U?.reservations?.some(e=>{if("cancelled"===e.status||Number(e.listingId)!==_)return!1;let a=e.checkIn.split("T")[0],r=e.checkOut.split("T")[0];return t===a||t===r}))return!1;let s=(a.availableUnits??1)>0;return(!W?.from||!(e>W.from)||!s)&&(r||!s)},components:{DayContent:({date:e})=>{let a=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,r=U?.days?.find(e=>e.date===a);return(0,t.jsxs)("div",{className:"relative w-full h-full flex flex-col items-center justify-center",children:[(0,t.jsx)("span",{children:(0,d.format)(e,"d")}),r?.basePrice&&(0,t.jsxs)("span",{className:"text-[10px] text-gray-400 dark:text-white/60",children:["$",parseFloat(r.basePrice).toFixed(0)]})]})}},classNames:{months:"flex flex-col sm:flex-row sm:space-x-6 space-y-6 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center mb-4",caption_label:"text-lg font-medium text-gray-900 dark:text-white",nav:"space-x-1 flex items-center",nav_button:(0,g.cn)("h-7 w-7 bg-transparent p-0 opacity-90 hover:opacity-100","border-0 hover:bg-transparent hover:border-0 !text-gray-700 dark:!text-white/90 hover:!text-gray-900 dark:hover:!text-white"),table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-gray-400 dark:text-white/50 w-9 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"relative p-0 text-center text-sm focus-within:relative focus-within:z-20",day:(0,g.cn)("h-9 w-9 p-0 font-normal text-base aria-selected:opacity-100","hover:bg-gray-100 dark:hover:bg-white/10 transition-colors","!text-gray-700 dark:!text-white/90 hover:!text-gray-900 dark:hover:!text-white relative"),day_selected:"bg-gray-200 dark:bg-white/10 text-gray-900 dark:text-white hover:bg-gray-300 dark:hover:bg-white/20",day_today:"bg-gray-100 dark:bg-white/5 text-gray-900 dark:text-white",day_range_start:"rounded-l-md bg-gray-200 dark:bg-white/10 text-gray-900 dark:text-white hover:bg-gray-300 dark:hover:bg-white/20",day_range_end:"rounded-r-md bg-gray-200 dark:bg-white/10 text-gray-900 dark:text-white hover:bg-gray-300 dark:hover:bg-white/20",day_range_middle:"bg-gray-100 dark:bg-white/5 text-gray-900 dark:text-white hover:bg-gray-200 dark:hover:bg-white/10"}}),(0,t.jsxs)("div",{className:"flex items-center gap-4 text-xs text-gray-400 dark:text-white/40 mt-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("div",{className:"w-2 h-2 rounded-full bg-[rgba(34,197,94,0.2)]"}),"Reserved"]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("div",{className:"w-2 h-2 rounded-full bg-gray-400 dark:bg-white/40"}),"Unavailable"]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("div",{className:"w-2 h-2 rounded-full bg-gray-200 dark:bg-white/10"}),"Selected"]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("div",{className:"w-2 h-2 rounded-full bg-gray-100 dark:bg-white/5"}),"Today"]})]})]}),(0,t.jsx)("div",{className:"px-6 md:px-0",children:(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-2",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60",children:"Check-in Date & Time *"}),(0,t.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,t.jsxs)("div",{className:"flex-1 px-3 py-2 bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg text-gray-900 dark:text-white text-sm flex items-center",children:[(0,t.jsx)(n.CalendarIcon,{className:"w-4 h-4 mr-2 text-gray-400 dark:text-white/60"}),(0,t.jsx)("input",{type:"text",value:W?.from?(0,d.format)(W.from,"MM/dd/yyyy"):"",onCh
8ange:e=>{try{let t=(0,u.parse)(e.target.value,"MM/dd/yyyy",new Date);if((0,h.isValid)(t)){let e=new Date(t.getFullYear(),t.getMonth(),t.getDate()),a=W?.to;(!a||a<=e)&&(a=new Date(e.getFullYear(),e.getMonth(),e.getDate()+1)),ej({from:e,to:a})}}catch(e){console.log("[CreateReservationPopover] Invalid date format:",e)}},onFocus:eu,onBlur:eh,className:"bg-transparent outline-none w-full",placeholder:"MM/DD/YYYY"})]}),(0,t.jsx)(eN,{value:ev.basicFields.checkIn?.time||(q?.rules?.checkIn?`${q.rules.checkIn.toString().padStart(2,"0")}:00`:"15:00"),onChange:e=>eC("checkIn",e),field:"checkIn"})]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60",children:"Check-out Date & Time *"}),(0,t.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,t.jsxs)("div",{className:"flex-1 px-3 py-2 bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg text-gray-900 dark:text-white text-sm flex items-center",children:[(0,t.jsx)(n.CalendarIcon,{className:"w-4 h-4 mr-2 text-gray-400 dark:text-white/60"}),(0,t.jsx)("input",{type:"text",value:W?.to?(0,d.format)(W.to,"MM/dd/yyyy"):"",onChange:e=>{try{let t=(0,u.parse)(e.target.value,"MM/dd/yyyy",new Date);if((0,h.isValid)(t)&&W?.from){let e=new Date(t.getFullYear(),t.getMonth(),t.getDate()),a=new Date(W.from.getFullYear(),W.from.getMonth(),W.from.getDate()+1),r=e<=W.from?a:e;ej({from:W.from,to:r})}}catch(e){console.log("[CreateReservationPopover] Invalid date format:",e)}},onFocus:eu,onBlur:eh,className:"bg-transparent outline-none w-full",placeholder:"MM/DD/YYYY"})]}),(0,t.jsx)(eN,{value:ev.basicFields.checkOut?.time||(q?.rules?.checkOut?`${q.rules.checkOut.toString().padStart(2,"0")}:00`:"11:00"),onChange:e=>eC("checkOut",e),field:"checkOut"})]})]})]})})]})}),(0,t.jsx)("div",{className:"px-4 md:px-0",children:(0,t.jsx)("div",{className:"space-y-4",children:(0,t.jsx)("h3",{className:"text-lg font-medium text-gray-900 dark:text-white",children:"Guest Information"})})})]}),(0,t.jsxs)("div",{className:"space-y-4 mt-2 px-4 md:px-0",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60 mb-2",children:"Existing Guest lookup"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{type:"text",value:ex,onChange:e=>{var t;(t=e.target.value).includes(et?.name||"")||ew(!0),eg(t)},placeholder:"Search guests...",className:"w-full bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg px-4 py-2 text-gray-900 dark:text-white"}),ex.length>1&&(ep.length>0||eb)&&(0,t.jsx)("div",{className:"absolute top-full left-0 right-0 mt-1 bg-white dark:bg-[#1C1C1E] border border-gray-200 dark:border-white/10 rounded-lg max-h-60 overflow-y-auto z-50",children:eb?(0,t.jsx)("div",{className:"p-4 text-gray-400 dark:text-white/60 text-center",children:(0,t.jsx)(f.Icons.spinner,{className:"h-8 w-8 animate-spin"})}):ep.map(e=>{let a=e.metadata?`${e.metadata.firstName||""} ${e.metadata.lastName||""}`.trim():e.name,r=e.metadata?[e.metadata.phone&&`ð± ${e.metadata.phone}`,e.metadata.email&&`ð§ ${e.metadata.email}`].filter(Boolean).join(" ⢠"):e.description;return(0,t.jsxs)("button",{onClick:()=>eA(e),className:"w-full px-4 py-2 text-left hover:bg-gray-50 dark:hover:bg-white/5 text-gray-900 dark:text-white flex flex-col gap-1",type:"button",children:[(0,t.jsx)("span",{className:"font-medium",children:a}),r&&(0,t.jsx)("span",{className:"text-sm text-gray-500 dark:text-white/60",children:r})]},e.id)})})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60 mb-2",children:"First Name *"}),(0,t.jsx)("input",{type:"text",value:ev.basicFields.guestDetails.firstName,onChange:e=>eT("guestDetails","firstName",e.target.value),className:"w-full bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg px-4 py-2 text-gray-900 dark:text-white",required:!0})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60 mb-2",children:"Last Name *"}),(0,t.jsx)("input",{type:"text",value:ev.basicFields.guestDetails.lastName,onChange:e=>eT("guestDetails","lastName",e.target.value),className:"w-full bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg px-4 py-2 text-gray-900 dark:text-white",required:!0})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60 mb-2",children:"Email *"}),(0,t.jsx)("input",{type:"email",value:ev.basicFields.guestDetails.email,onChange:e=>eT("guestDetails","email",e.target.value),className:"w-full bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg px-4 py-2 text-gray-900 dark:text-white",required:!0})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60 mb-2",children:"Phone *"}),(0,t.jsx)("input",{type:"tel",value:ev.basicFields.guestDetails.phone,onChange:e=>eT("guestDetails","phone",e.target.value),className:"w-full bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg px-4 py-2 text-gray-900 dark:text-white",required:!0})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60 mb-2",children:"Base Price *"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{type:"number",value:ev.basicFields.basePrice,onChange:e=>eE("basePrice",parseFloat(e.target.value)),className:"w-full bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg pl-10 pr-4 py-2 text-gray-900 dark:text-white",required:!0}),(0,t.jsx)(i.DollarSign,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-white/60"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60 mb-2",children:"Currency"}),(0,t.jsxs)("div",{className:"w-full bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg px-4 py-2 text-gray-700 dark:text-white/80 text-sm",children:[ev.basicFields.currency||"USD",(0,t.jsx)("span",{className:"text-gray-300 dark:text-white/40 text-xs ml-2",children:"(from listing)"})]})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60 mb-2",children:"Number of Guests *"}),(0,t.jsx)("input",{type:"number",value:ev.basicFields.numberOfGuests,onChange:e=>eE("numberOfGuests",parseInt(e.target.value)),min:"1",className:"w-full bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg px-4 py-2 text-gray-900 dark:text-white",required:!0})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"block text-sm font-medium text-gray-900 dark:text-white/60",children:"Status *"}),(0,t.jsxs)("select",{value:ev.basicFields.status||"",onChange:e=>eE("status",e.target.value),className:"w-full bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg px-4 py-2 text-gray-900 dark:text-white",required:!0,children:[(0,t.jsx)("option",{value:"accept",children:"Confirmed"}),(0,t.jsx)("option",{value:"pending",children:"Pending"})]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60",children:"Platform *"}),(0,t.jsxs)("select",{value:ev.basicFields.platform||"direct",onChange:e=>eE("platform",e.target.value),className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg text-gray-900 dark:text-white text-sm",children:[(0,t.jsx)("option",{value:"direct",children:"Direct Booking"}),(0,t.jsx)("option",{value:"website",children:"Website"}),(0,t.jsx)("option",{value:"owner",children:"Owner Stay"}),(0,t.jsx)("option",{value:"mid_stay_clean",children:"Mid stay clean"}),(0,t.jsx)("option",{value:"airbnb",children:"Airbnb"}),(0,t.jsx)("option",{value:"booking",children:"Booking.com"}),(0,t.jsx)("option",{value:"vrbo",children:"VRBO"}),(0,t.jsx)("option",{value:"expedia",children:"Expedia"})]})]})]}),ev.isAdvancedMode&&(0,t.jsxs)("div",{className:"space-y-6 px-4",children:[(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("h4",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Additional Fees"}),G?(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60 mb-2",children:"Cleaning Fee"}),(0,t.jsx)(w.Skeleton,{className:"h-10 w-full bg-gray-100 dark:bg-white/5"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60 mb-2",children:"Security Deposit"}),(0,t.jsx)(w.Skeleton,{className:"h-10 w-full bg-gray-100 dark:bg-white/5"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h5",{className:"text-sm font-medium text-gray-900 dark:text-white mb-3",children:"Taxes"}),(0,t.jsxs)("div",{className:"grid grid-cols-3 gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60 mb-2",children:"VAT"}),(0,t.jsx)(w.Skeleton,{className:"h-10 w-full bg-gray-100 dark:bg-white/5"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60 mb-2",children:"City Tax"}),(0,t.jsx)(w.Skeleton,{className:"h-10 w-full bg-gray-100 dark:bg-white/5"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60 mb-2",children:"Tourist Tax"}),(0,t.jsx)(w.Skeleton,{className:"h-10 w-full bg-gray-100 dark:bg-white/5"})]})]})]})]}):(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60 mb-2",children:"Cleaning Fee"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{type:"text",value:eD(ev.advancedFields?.cleaningFee||0),readOnly:!0,className:"w-full bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg pl-10 pr-4 py-2 text-gray-900 dark:text-white"}),(0,t.jsx)(i.DollarSign,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-white/60"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60 mb-2",children:"Security Deposit"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{type:"text",value:eD(ev.advancedFields?.securityDeposit||0),readOnly:!0,className:"w-full bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg pl-10 pr-4 py-2 text-gray-900 dark:text-white"}),(0,t.jsx)(i.DollarSign,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-white/60"})]})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,t.jsx)("h5",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Taxes"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("button",{type:"button",onClick:()=>ec("total"),className:`px-3 py-1 text-xs rounded-md transition-colors ${"total"===ed?"bg-gray-200 dark:bg-white/20 text-gray-900 dark:text-white":"bg-gray-50 dark:bg-white/5 text-gray-400 dark:text-white/60 hover:text-gray-900 dark:hover:text-white"}`,children:"Total Amount"}),(0,t.jsx)("button",{type:"button",onClick:()=>ec("percentage"),className:`px-3 py-1 text-xs rounded-md transition-colors ${"percentage"===ed?"bg-gray-200 dark:bg-white/20 text-gray-900 dark:text-white":"bg-gray-50 dark:bg-white/5 text-gray-400 dark:text-white/60 hover:text-gray-900 dark:hover:text-white"}`,children:"Percentage"})]})]}),"total"===ed?(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60 mb-2",children:"Total Taxes Amount"}),(0,t.jsxs)("div",{className:"relative max-w-xs",children:[(0,t.jsx)("input",{type:"number",step:"0.01",min:"0",value:ev.advancedFields?.totalTaxes||0,onChange:e=>eI("totalTaxes",parseFloat(e.target.value)||0),className:"w-full bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg pl-10 pr-4 py-2 text-gray-900 dark:text-white",placeholder:"0.00"}),(0,t.jsx)(i.DollarSign,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-white/60"})]}),(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-white/40 mt-1",children:"Enter the total tax amount instead of individual percentages"})]}):(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60 mb-2",children:"VAT (%)"}),(0,t.jsx)("input",{type:"number",value:ev.advancedFields?.taxes?.vatAmount||0,onChange:e=>{eT("taxes","vatAmount",parseFloat(e.target.value),!0)},className:"w-full bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg px-4 py-2 text-gray-900 dark:text-white"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60 mb-2",children:"City Tax (%)"}),(0,t.jsx)("input",{type:"number",value:ev.advancedFields?.taxes?.cityTax||0,onChange:e=>{eT("taxes","cityTax",parseFloat(e.target.value),!0)},className:"w-full bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg px-4 py-2 text-gray-900 dark:text-white"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60 mb-2",children:"Tourist Tax (%)"}),(0,t.jsx)("input",{type:"number",value:ev.advancedFields?.taxes?.touristTax||0,onChange:e=>{eT("taxes","touristTax",parseFloat(e.target.value),!0)},className:"w-full bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg px-4 py-2 text-gray-900 dark:text-white"})]})]})]}),(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("h4",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Additional Fees"}),(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-white/60 mb-3",children:"Extra charges that will be added to the guest's total"}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60 mb-2",children:"Pet Fee"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{type:"number",step:"0.01",min:"0",value:ev.advancedFields?.fees?.petFee||0,onChange:e=>eT("fees","petFee",parseFloat(e.target.value)||0,!0),className:"w-full bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg pl-10 pr-4 py-2 text-gray-900 dark:text-white",placeholder:"0.00"}),(0,t.jsx)(i.DollarSign,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-white/60"})]}),(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-white/40 mt-1",children:"Fee for pets staying at the property"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60 mb-2",children:"Extra Guest Fee"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{type:"number",step:"0.01",min:"0",value:ev.advancedFields?.fees?.extraGuestFee||0,onChange:e=>eT("fees","extraGuestFee",parseFloat(e.target.value)||0,!0),className:"w-full bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg pl-10 pr-4 py-2 text-gray-900 dark:text-white",placeholder:"0.00"}),(0,t.jsx)(i.DollarSign,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-white/60"})]}),(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-white/40 mt-1",children:"Fee for additional guests beyond the base capacity"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-gra
8y-500 dark:text-white/60 mb-2",children:"Service Fee"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{type:"number",step:"0.01",min:"0",value:ev.advancedFields?.fees?.serviceFee||0,onChange:e=>eT("fees","serviceFee",parseFloat(e.target.value)||0,!0),className:"w-full bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg pl-10 pr-4 py-2 text-gray-900 dark:text-white",placeholder:"0.00"}),(0,t.jsx)(i.DollarSign,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-white/60"})]}),(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-white/40 mt-1",children:"Platform service fee (e.g., Booking.com service fee)"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60 mb-2",children:"Platform Fee"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{type:"number",step:"0.01",min:"0",value:ev.advancedFields?.fees?.platformFee||0,onChange:e=>eT("fees","platformFee",parseFloat(e.target.value)||0,!0),className:"w-full bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg pl-10 pr-4 py-2 text-gray-900 dark:text-white",placeholder:"0.00"}),(0,t.jsx)(i.DollarSign,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-white/60"})]}),(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-white/40 mt-1",children:"General platform or booking fees"})]})]})]}),(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("h4",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Business Costs"}),(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-white/60 mb-3",children:"Internal costs for tracking purposes (not charged to guest)"}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60 mb-2",children:"Processing Fee"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{type:"number",step:"0.01",min:"0",value:ev.advancedFields?.fees?.processingFee||0,onChange:e=>eT("fees","processingFee",parseFloat(e.target.value)||0,!0),className:"w-full bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg pl-10 pr-4 py-2 text-gray-900 dark:text-white",placeholder:"0.00"}),(0,t.jsx)(i.DollarSign,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-white/60"})]}),(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-white/40 mt-1",children:"Credit card processing or payment gateway fees"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60 mb-2",children:"Host Fee"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{type:"number",step:"0.01",min:"0",value:ev.advancedFields?.fees?.hostFee||0,onChange:e=>eT("fees","hostFee",parseFloat(e.target.value)||0,!0),className:"w-full bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg pl-10 pr-4 py-2 text-gray-900 dark:text-white",placeholder:"0.00"}),(0,t.jsx)(i.DollarSign,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-white/60"})]}),(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-white/40 mt-1",children:"Platform host fees or commission charges"})]})]})]}),(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Available Add-ons"}),V?.availableAddOns?.map(e=>(0,t.jsxs)("div",{className:"flex items-center space-x-3 p-3 bg-gray-50 dark:bg-white/5 rounded-lg",children:[(0,t.jsx)(N.Checkbox,{checked:ei.some(t=>t.id===e.id),onCheckedChange:()=>{var t;return t=e.id,void en(e=>e.find(e=>e.id===t)?e.filter(e=>e.id!==t):[...e,{id:t,quantity:1}])}}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium text-gray-900 dark:text-white",children:e.name}),e.description&&(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-white/60",children:e.description}),(0,t.jsxs)("p",{className:"text-sm text-gray-700 dark:text-white/80",children:["$",e.amount," ","per_night"===e.pricingType?" per night":""]})]})]},e.id))]}),(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Available Discounts"}),V?.availableDiscounts?.map(e=>(0,t.jsxs)("div",{className:"flex items-center space-x-3 p-3 bg-gray-50 dark:bg-white/5 rounded-lg",children:[(0,t.jsx)(N.Checkbox,{checked:er.includes(e.id),onCheckedChange:()=>{var t;return t=e.id,void es(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])}}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium text-gray-900 dark:text-white",children:e.name}),e.description&&(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-white/60",children:e.description}),(0,t.jsxs)("p",{className:"text-sm text-gray-700 dark:text-white/80",children:["percentage"===e.discountType?`${e.amount}%`:eD(e.amount),e.minNights&&` (min ${e.minNights} nights)`,e.maxNights&&` (max ${e.maxNights} nights)`]})]})]},e.id))]})]})]}),(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Cancellation Policy"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60 mb-2",children:"Select Policy"}),(0,t.jsxs)("select",{value:ev.advancedFields?.cancellationPolicy||q?.rules?.cancellation?.policy||"flexible",onCh
8ange:e=>{eI("cancellationPolicy",e.target.value)},className:"w-full bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg px-4 py-2 text-gray-900 dark:text-white",children:[(0,t.jsx)("optgroup",{label:"Standard Policies",children:["flexible","moderate","better_strict_with_grace_period","strict_14_with_grace_period","super_strict_30","super_strict_60","tiered_pricing_non_refundable","firm_14"].map(e=>(0,t.jsx)("option",{value:e,children:S.CANCELLATION_POLICY_DETAILS[e].name},e))}),(0,t.jsx)("optgroup",{label:"Italian Policies",children:["flexible_new","moderate_new","strict_new","super_strict_30_new","super_strict_60_new"].map(e=>(0,t.jsx)("option",{value:e,children:S.CANCELLATION_POLICY_DETAILS[e].name},e))}),(0,t.jsx)("optgroup",{label:"Long-term Policies",children:["CANCEL_LONG_TERM_FAIR","CANCEL_LONG_TERM_WITH_GRACE_PERIOD","long_term_new"].map(e=>(0,t.jsx)("option",{value:e,children:S.CANCELLATION_POLICY_DETAILS[e].name},e))})]})]}),(0,t.jsx)("div",{className:"text-sm text-gray-500 dark:text-white/60 bg-gray-50 dark:bg-white/5 p-4 rounded-lg",children:(0,S.getCancellationPolicyDetails)(ev.advancedFields?.cancellationPolicy||q?.rules?.cancellation?.policy||"flexible").description})]}),(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Notes & Special Requests"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-gray-500 dark:text-white/60 mb-2",children:"Notes"}),(0,t.jsx)("textarea",{value:ev.advancedFields?.notes,onChange:e=>eI("notes",e.target.value),className:"w-full bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg px-4 py-2 text-gray-900 dark:text-white h-24",placeholder:"Add any additional notes..."})]})]}),(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Guest Preferences"}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"block text-sm font-medium text-gray-900 dark:text-white/60",children:"Communication Channel"}),(0,t.jsxs)("select",{value:ev.advancedFields?.guestPreferences?.communicationChannel||"",onChange:e=>eT("guestPreferences","communicationChannel",e.target.value,!0),className:"w-full bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg px-4 py-2 text-gray-900 dark:text-white",children:[(0,t.jsx)("option",{value:"",children:"Select channel"}),(0,t.jsx)("option",{value:"email",children:"Email"}),(0,t.jsx)("option",{value:"phone",children:"Phone"}),(0,t.jsx)("option",{value:"whatsapp",children:"WhatsApp"})]})]})]}),(0,t.jsx)("div",{className:"md:hidden mt-6 border-t border-gray-200 dark:border-white/10 pt-6",children:(0,t.jsxs)("div",{className:"flex justify-end items-center gap-4",children:[(0,t.jsx)("button",{type:"button",onClick:P,className:"px-4 py-2 text-sm font-medium text-gray-400 dark:text-white/60 hover:text-gray-900 dark:hover:text-white",children:"Cancel"}),(0,t.jsx)("button",{type:"submit",disabled:!eF,onClick:e$,className:(0,g.cn)("px-4 py-2 text-sm font-medium rounded-lg","transition-colors duration-200",eF?"bg-gray-900 dark:bg-white text-gray-900 dark:text-white dark:text-black hover:bg-gray-800 dark:hover:bg-white/90":"bg-gray-200 dark:bg-white/20 text-gray-400 dark:text-white/60 cursor-not-allowed"),children:"Create Reservation"})]})})]})]})}),(0,t.jsx)("div",{className:"hidden md:block w-[350px] border-l border-gray-200 dark:border-white/10 p-6 bg-gray-50 dark:bg-[#2C2C2E] overflow-y-auto",children:(0,t.jsxs)("div",{className:"sticky top-6 space-y-6",children:[z?(0,t.jsx)("div",{className:"space-y-4",children:(0,t.jsx)(w.Skeleton,{className:"h-32 w-full bg-gray-100 dark:bg-white/5"})}):q?(0,t.jsx)(v.ReservationListing,{data:{listing:q}}):(0,t.jsx)("div",{className:"p-4 bg-gray-50 dark:bg-white/5 rounded-lg",children:(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-white/60",children:H||"Error loading listing details"})}),(0,t.jsx)(k.ReservationFinancials,{quote_mode:!0,isLoading:z,data:eU,onPriceBreakdownUpdate:eO})]})})]})]}),(0,t.jsx)("div",{className:"fixed bottom-0 left-0 right-0 bg-white dark:bg-[#1C1C1E] border-t border-gray-200 dark:border-white/10 px-0 md:px-6 py-6 pb-[calc(4rem+env(safe-area-inset-bottom))] md:pb-6 z-[9999]",children:(0,t.jsxs)("div",{className:"flex justify-end items-center gap-4 px-4 md:px-0",children:[(0,t.jsxs)("div",{className:"relative flex items-center gap-2 group",children:[(0,t.jsxs)("label",{className:"flex items-center gap-2 text-sm text-gray-300 dark:text-white/40 cursor-not-allowed",children:[(0,t.jsx)("input",{type:"checkbox",disabled:!0,className:"rounded border-gray-300 dark:border-white/10 bg-gray-50 dark:bg-white/5 text-gray-300 dark:text-white/40 cursor-not-allowed"}),(0,t.jsx)("span",{className:"md:hidden",children:"Send payment link"}),(0,t.jsx)("span",{className:"hidden md:inline",children:"Send payment link to guest"}),(0,t.jsx)(l.Info,{className:"w-4 h-4 text-gray-400 dark:text-white/40"})]}),(0,t.jsx)("div",{className:"absolute bottom-full right-0 mb-2 px-3 py-2 bg-black/90 text-gray-900 dark:text-white text-sm rounded-lg opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none whitespace-nowrap",children:"Coming soon"})]}),(0,t.jsx)("button",{type:"button",onClick:P,className:"px-4 py-2 text-sm font-medium text-gray-400 dark:text-white/60 hover:text-gray-900 dark:hover:text-white",children:"Cancel"}),(0,t.jsx)("button",{type:"submit",disabled:!eF||F,onClick:e$,className:(0,g.cn)("px-4 py-2 text-sm font-medium rounded-lg","transition-colors duration-200",eF&&!F?"bg-gray-900 dark:bg-white text-gray-900 dark:text-white dark:text-black hover:bg-gray-800 dark:hover:bg-white/90":"bg-gray-200 dark:bg-white/20 text-gray-400 dark:text-white/60 cursor-not-allowed"),children:F?(0,t.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,t.jsx)(o.Loader2,{className:"h-4 w-4 animate-spin"}),(0,t.jsx)("span",{className:"md:hidden",children:"Saving..."}),(0,t.jsx)("span",{className:"hidden md:inline",children:"Creating Reservation..."})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"md:hidden",children:"Save"}),(0,t.jsx)("span",{className:"hidden md:inline",children:"Create Reservation"})]})})]})})]})})})}),eR&&(0,t.jsx)(C.Notification,{message:eR.message,type:eR.type,onUndo:eR.onUndo,onClose:()=>eM(null)}),(0,t.jsx)(I.AnimatePresence,{children:eB&&(0,t.jsxs)(E.motion.div,{initial:{y:"100%"},animate:{y:0},exit:{y:"100%"},transition:{type:"spring",damping:30},className:"fixed inset-0 top-auto bg-gray-50 dark:bg-[#2C2C2E] z-50 h-[80vh] overflow-y-auto rounded-t-2xl border-t border-gray-200 dark:border-white/10",children:[(0,t.jsx)("div",{className:"sticky top-0 bg-gray-50 dark:bg-[#2C2C2E] z-10 p-4 border-b border-gray-200 dark:border-white/10",children:(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsx)("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Quote Details"}),(0,t.jsx)("button",{onClick:()=>eq(!1),className:"text-gray-400 dark:text-white/60 hover:text-gray-900 dark:hover:text-white",children:(0,t.jsx)(r.X,{className:"w-5 h-5"})})]})}),(0,t.jsx)("div",{className:"p-4 pb-40",children:(0,t.jsx)(k.ReservationFinancials,{data:eU,onPriceBreakdownUpdate:eO})}),(0,t.jsx)("div",{className:"h-[env(safe-area-inset-bottom)]"})]})})]})}],284467)},939692,877077,953197,994310,796780,e=>{"use strict";e.s(["CommandPalette",()=>I],939692);var t=e.i(843476),a=e.i(271645),r=e.i(11737),s=e.i(803181),i=e.i(148395),n=e.i(854878),l=e.i(770352),o=e.i(908263),d=e.i(567847),c=e.i(591236),m=e.i(325854);e.i(537187);var u=e.i(874189),h=e.i(134969),x=e.i(671142),g=e.i(294082),p=e.i(121798),b=e.i(490446),f=e.i(232676),y=e.i(174080),w=e.i(724338),v=e.i(910183),k=e.i(782839),j=e.i(88014),N=e.i(284467),C=e.i(639907);let S=e=>{if(!e)return;let t=e.closest("[cmdk-list]");if(!t)return;let a=t.getBoundingClientRect(),r=e.getBoundingClientRect(),s=r.top<a.top,i=r.bottom>a.bottom;if(s||i){let a=e.offsetTop-t.offsetHeight/2+e.offsetHeight/2;t.scrollTo({top:Math.max(0,a),behavior:"smooth"})}},E=e=>{let t=["Escape","ArrowUp","ArrowDown","Enter","Tab","CMD"].includes(e.ke
8y),a=!e.ctrlKey&&!e.metaKey&&!e.altKey,r=("a"===e.key||"A"===e.key)&&(e.metaKey||e.ctrlKey),s=("c"===e.key||"C"===e.key||"v"===e.key||"V"===e.key||"x"===e.key||"X"===e.key)&&(e.metaKey||e.ctrlKey),i=e.target instanceof HTMLInputElement;(r||s)&&i||t||a||(e.stopPropagation(),e.preventDefault())};function I(){return(0,x.useCanUseCommandPalette)()?(0,t.jsx)(h.StepFooterProvider,{children:(0,t.jsx)(T,{})}):null}function T(){let{footerComponent:e}=(0,h.useStepFooter)(),[x,I]=(0,a.useState)(""),[T,_]=(0,a.useState)(null),[A,D]=(0,a.useState)({currentStep:void 0,data:{},history:[],context:void 0}),[P,R]=(0,a.useState)(0),[M,F]=(0,a.useState)(!1),[L,$]=(0,a.useState)(null),[O,U]=(0,a.useState)(),[B,q]=(0,a.useState)("commands"),[z,H]=(0,a.useState)(0),[V,G]=(0,a.useState)(0),[W,K]=(0,a.useState)(!1),[Y,J]=(0,a.useState)(!1),{isOpen:Q,commands:X,initialQuery:Z,initialSelection:ee,closeCommandPalette:et,openCommandPalette:ea,executeCommand:er,state:es,isLoading:ei,setCommandPaletteContext:en}=(0,d.useCommandPalette)(),{toast:el}=(0,c.useToast)(),eo=(0,a.useRef)(null),ed=(0,a.useMemo)(()=>{let e,t=e=>{let t=!x||e.name?.toLowerCase().includes(x.toLowerCase())||e.description?.toLowerCase().includes(x.toLowerCase()),a=Array.isArray(e.contexts)?e.contexts:[],r=es?.context==="global"||!es?.context||0===a.length||a.includes(es?.context)||a.includes("global");if(e.configuration?.type?.startsWith("reservation.")){let t=es?.metadata?.reservation?.status?.status?.toLowerCase(),a=es?.metadata?.reservation?.platform?.source?.toLowerCase();if(("reservation.accept"===e.configuration.type||"reservation.decline"===e.configuration.type)&&("airbnb"!==a||"pending"!==t&&"request"!==t&&"inquiry"!==t||(0,i.isLapsedRequest)((0,i.requestWindowFromMetadata)(es?.metadata?.reservation))))return!1;if(e.configuration.type===g.RESYNC_BOOKING_EVENT&&!(0,g.paletteReservationIsAirbnb)(es?.metadata)||("reservation.alteration.accept"===e.configuration.type||"reservation.alteration.decline"===e.configuration.type)&&("airbnb"!==a||!es?.metadata?.hasPendingAlteration)||"reservation.cancel.internal"===e.configuration.type&&"cancelled"===t||"reservation.confirm.internal"===e.configuration.type&&("confirmed"===t||"accept"===t))return!1}return t&&r},a=Object.entries(X||{}).reduce((e,[a,r])=>({...e,...!es?.context?{[a]:r}:"messages"===a?{[a]:Object.entries(r).reduce((e,[a,r])=>({...e,[a]:r.filter(t)}),{})}:{[a]:Array.isArray(r)?r.filter(t):r}}),{});return(0,g.paletteReservationIsAirbnb)(es?.metadata)||(a.reservations=(a.reservations||[]).filter(e=>e?.configuration?.type!==g.RESYNC_BOOKING_EVENT&&e?.action?.event!==g.RESYNC_BOOKING_EVENT)),("atlasdna.ai"===(e=window.location.hostname)||"app.atlasdna.ai"===e||"atlas.localhost"===e?"atlas":"fantasticstay.com"===e||"app.fantasticstay.com"===e||"fs.localhost"===e?"fantasticstay":null)&&(a.create=[],a.general=[],a.reservations=[],a.messages={guest:[],team:[],thread:[],contact:[],channel:[]}),a},[X,x,es]);(0,a.useEffect)(()=>{Q&&(R(0),requestAnimationFrame(()=>{let e=document.querySelectorAll("[cmdk-item]:not([hidden])");if(e.length>0){document.querySelectorAll("[cmdk-item]").forEach(e=>{e.setAttribute("data-selected","false")});let t=e[0];t.setAttribute("data-selected","true"),U(t.getAttribute("data-suggestion-id")||t.getAttribute("data-command-id")||void 0),S(t)}}))},[Q,x]),(0,a.useEffect)(()=>{if(!Q)return;let e=document.documentElement.classList.contains("dark"),t=document.createElement("style");return t.textContent=e?` 9 [cmdk-item][data-selected="true"] { 10 background-color: rgba(255, 255, 255, 0.06) !important; 11 } 12 13 .command-palette [cmdk-item]:hover { 14 background-color: rgba(255, 255, 255, 0.04); 15 } 16 `:` 17 [cmdk-item][data-selected="true"] { 18 background-color: rgba(0, 0, 0, 0.04) !important; 19 } 20 21 .command-palette [cmdk-item]:hover { 22 background-color: rgba(0, 0, 0, 0.02); 23 } 24 `,document.head.appendChild(t),()=>{document.head.removeChild(t)}},[Q]),(0,a.useEffect)(()=>{let e=e=>{if(!Q)return;let t=document.querySelectorAll("[cmdk-item]:not([hidden])"),a=t.length;if(0!==a)switch(e.key){case"ArrowDown":case"ArrowUp":{e.preventDefault();let r=(P+("ArrowUp"===e.key?-1:1)+a)%a;R(r),requestAnimationFrame(()=>
24{t.forEach(e=>{e.setAttribute("data-selected","false")});let e=t[r];e&&(e.setAttribute("data-selected","true"),U(e.getAttribute("data-suggestion-id")||e.getAttribute("data-command-id")||void 0),S(e))});break}case"Enter":{e.preventDefault();let a=document.querySelector('[cmdk-item][data-selected="true"]:not([hidden])');!a&&t.length>0&&(a=t[Math.min(P,t.length-1)]||t[0]),a&&a.click()}}};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[Q,P]),(0,a.useEffect)(()=>{if(!Q)return;R(0);let e=setTimeout(()=>{let e=(t=0)=>{let a=document.querySelectorAll("[cmdk-item]:not([hidden])");if(0===a.length&&t<3)return void setTimeout(()=>e(t+1),100);if(a.length>0){document.querySelectorAll("[cmdk-item]").forEach(e=>{e.setAttribute("data-selected","false")});let e=a[0];if(ee&&x===Z)for(let t=0;t<a.length;t++){let r=a[t],s=r.getAttribute("data-command-id"),i=r.textContent?.toLowerCase()||"",n=ee.toLowerCase();if(s===ee||i.includes(n)){e=r,R(t),setTimeout(()=>{e.click()},100);break}}e.setAttribute("data-selected","true"),U(e.getAttribute("data-suggestion-id")||e.getAttribute("data-command-id")||void 0),S(e)}};e()},150);return()=>clearTimeout(e)},[Q,x,ee,Z]);let ec=(0,f.useDashboard)(),em=(0,a.useCallback)((e,a="success")=>{let r=document.getElementById("notification-root")||document.body,s=document.createElement("div");r.appendChild(s);let i=(0,j.createRoot)(s);i.render((0,t.jsx)(k.Notification,{message:e,type:a,position:"bottom"})),setTimeout(()=>{s.parentNode&&(i.unmount(),s.parentNode.removeChild(s))},"error"===a?6500:3500)},[]),eu=(0,a.useCallback)(async e=>{try{if(F(!0),e.url){window.location.href=e.url,et();return}let t=await (0,p.withCommandInFlight)(e.event,$,()=>er(e)),a=t.success?void 0:(0,r.commandFailureMessage)(t,"Couldn't complete that â please try again");if(document.dispatchEvent(new CustomEvent("command:result",{detail:{action:e,success:t.success,data:t.data,error:a,timestamp:new Date}})),t.success)return et(),ec?.setLastAction&&ec.setLastAction({...e,payload:{...e.payload,...t.data,error:void 0}}),em(t?.operatorMessage||t?.data?.operatorMessage||"Command executed successfully"),t;ec?.setLastAction&&ec.setLastAction({...e,payload:{...e.payload,error:a}}),em(a,"error")}catch(a){console.error("[CommandPalette] Command execution error:",a);let t=(0,s.toUserFacingError)(a,"Couldn't complete that â please try again");document.dispatchEvent(new CustomEvent("command:result",{detail:{action:e,success:!1,error:t,timestamp:new Date}})),ec?.setLastAction&&ec.setLastAction({...e,payload:{...e.payload,error:t}}),em(t,"error")}finally{F(!1)}},[ec,et,er,F,em]);(0,a.useCallback)(async e=>{if(!T?.action?.steps||!A.currentStep)return void console.error("[CommandPalette] Missing activeCommand steps or currentStep");let t=A.currentStep,a=T.action.steps.indexOf(t);if(-1===a)return void console.error("[CommandPalette] Current step not found in active command steps");let r=T.action.steps[a+1],s={...A,currentStep:r,data:{...A.data,[t.id]:e},history:[...A.history,t.id]};y.default.unstable_batchedUpdates(()=>{D(s),R(0)}),r||await eu({type:T.type,topic:T.action.topic,event:T.action.event,payload:s.data,url:T.action.url})},[T,A,eu]);let eh=(0,a.useCallback)(e=>{let t=e.action?.steps&&e.action.steps.length>0||e.configuration?.steps&&e.configuration.steps.length>0,a=es?.context||"global",r=e.configuration?.contextBehavior?.[a];if(I(""),r){let t=e.configuration?.steps||[],s=r.initialStep,i=t.find(e=>e.id===s);if(i){let s={...e,action:{...e.action,type:e.action?.type||e.type||"general",topic:e.action?.topic||e.configuration?.topic||e.configuration?.type?.split(".")?.[0]||"general",event:e.action?.event||e.configuration?.event||e.configuration?.type||"",payload:e.action?.payload||{},steps:t}},n={};if(r.autoFillData){let{source:e,mapping:t}=r.autoFillData,a=eb(es,e);if(a&&t){let r={};Object.entries(t).forEach(([e,t])=>{r[e]=eb(a,t)}),n[e.split(".").pop()||"data"]=r}}_(s),D({type:e.configuration?.type,currentStep:i,data:n,history:[],context:a,metadata:"object"==typeof es&&null!==es?es.metadata:void 0});return}}if(t){let t=e.action?.steps||e.configuration?.steps||[];if(t.length>0){let a=t[0],r={id:e.id,type:e.type||e.configuration?.type||"general",name:e.name,description:e.description,action:{type:e.action?.type||e.type||e.configuration?.type||"general",topic:e.action?.topic||e.configuration?.topic||e.configuration?.type?.split(".")?.[0]||"general",event:e.action?.event||e.configuration?.event||e.configuration?.type||"",payload:e.action?.payload||{},steps:t,url:e.action?.url,metadata:e.action?.metadata}};
24try{_(r),D({type:e.configuration?.type,currentStep:a,data:{},history:[],context:es,metadata:"object"==typeof es&&null!==es?es.metadata:void 0})}catch(e){console.error("[CommandPalette] Error updating state:",e)}}else console.warn("[CommandPalette] Command has steps property but no steps found"),s(e)}else s(e);function s(e){let t=e.action?.topic||e.configuration?.topic||e.configuration?.type?.split(".")?.[0]||"general",a=e.action?.event||e.configuration?.event||e.configuration?.type||"execute",r=(0,g.paletteContextPayloadForCommand)(a,"object"==typeof es&&null!==es?es.metadata:void 0);eu({type:(0,g.paletteDispatchTypeForCommand)(a,e.action?.type),topic:t,event:a,payload:{...r,...e.action?.payload||{}},url:e.action?.url})}},[es,_,D,eu]);(0,a.useCallback)(e=>{if(!T?.action?.steps||!A.currentStep)return;let t=A.currentStep.suggestions.find(t=>t.id===e);if(!t)return;let a=T.action.steps.indexOf(A.currentStep),r=T.action.steps[a+1],s={type:T.type,currentStep:r,data:{...A.data,[A.currentStep.id]:t},history:[...A.history,A.currentStep.id]};D(s),R(0),r||eu({type:T.type,topic:T.action.topic,event:T.action.event,payload:s.data,url:T.action.url})},[T,A,eu]),(0,a.useEffect)(()=>{if(!Q)return;let e=e=>{},t=e=>{let{command:t}=e.detail;t&&eh(t)},a=e=>{let{command:t}=e.detail;D(e=>({...e,commandInProgress:!0})),er(t).then(e=>{if(e&&!1===e.success)throw Error((0,r.commandFailureMessage)(e,"Couldn't complete that â please try again"));let a=new CustomEvent("command:result",{detail:{action:t,success:!0,response:e}});document.dispatchEvent(a);let s="seam.accessCode.delete"===t.event||"signature.reservation.list"===t.event||"signature.reservation.cancel"===t.event||"signature.profiles.list"===t.event;D(e=>({...e,commandInProgress:!1,successMessage:s?void 0:"Command executed successfully"}));let i="seam.accessCode.create"===t.event?"Access code created successfully":"signature.reservation.create"===t.event?"Signature reservation created":"signature.reservation.cancel"===t.event?"Signature reservation cancelled":s?"":"Command executed successfully";i&&em(i),s||setTimeout(()=>{et()},1e3)}).catch(e=>{console.error("[CommandPalette] Command execution failed:",e);let a=(0,s.toUserFacingError)(e,"Couldn't complete that â please try again"),r=new CustomEvent("command:result",{detail:{action:t,success:!1,error:a}});document.dispatchEvent(r),D(e=>({...e,commandInProgress:!1,error:a})),em(a,"error")})};return document.addEventListener("keydown",e,!0),document.addEventListener("command-select",t),document.addEventListener("command-action",a),()=>{document.removeEventListener("keydown",e,!0),document.removeEventListener("command-select",t),document.removeEventListener("command-action",a)}},[Q,P,eh,eu,er]),(0,a.useEffect)(()=>{if(Q){let e=setTimeout(()=>{eo.current?.focus(),Z&&I(Z)},0);return()=>clearTimeout(e)}},[Q,Z,ee,X,es]),(0,a.useEffect)(()=>{Q||I("")},[Q]),(0,a.useEffect)(()=>{if(Q)return document.body.setAttribute("data-blocking-shortcuts","true"),document.addEventListener("keydown",E,!0),()=>{document.body.removeAttribute("data-blocking-shortcuts"),document.removeEventListener("keydown",E,!0)}},[Q]),(0,a.useEffect)(()=>{let e=eo.current;if(!e)return;let t=()=>{e.select()};return e.addEventListener("focus",t),()=>e.removeEventListener("focus",t)},[]),(0,a.useEffect)(()=>{Q||y.default.unstable_batchedUpdates(()=>{I(""),R(0),_(null),D({currentStep:void 0,data:{},history:[],context:void 0})})},[Q]),(0,a.useEffect)(()=>{let e=()=>{Q||et()};return document.addEventListener("command-palette:cleanup",e),()=>{document.removeEventListener("command-palette:cleanup",e)}},[Q,et]);let ex=(0,a.useCallback)(async()=>{if(!A.currentStep)return;let e=A.currentStep;if((T?.action?.steps||[]).indexOf(e),A.pendingCommand){try{D(e=>({...e,isLoading:!0}));let e={...A.pendingCommand};e.event?.startsWith("seam.")&&(e.type="seam",e.topic="seam");let t=await er(e);if(!t.success)throw Error(t.error||"Failed to execute command");window.dispatchEvent(new CustomEvent("command:executed",{detail:{action:e,response:t,timestamp:new Date,customerId:A.metadata?.customerId||0}})),D(e=>({...e,isLoading:!1,pendingCommand:void 0,successMessage:"Command executed successfully!"})),em("Access code created successfully!"),setTimeout(()=>{et()},1e3)}catch(t){console.error("[CommandPalette] Command execution error:",t);let e=(0,s.toUserFacingError)(t,"Couldn't complete that â please try again");em(e,"error"),D(t=>({...t,isLoading:!1,pendingCommand:void 0,error:e}))}return}},[T,A,D,er,et,em]);(0,a.useEffect)(()=>{Q&&x?T||(x.startsWith("/")?q("search"):x.startsWith(">")||(/^[A-Z0-9]{6,}
24$/.test(x)?q("search"):(Object.entries(ed).forEach(([e,t])=>{Array.isArray(t)&&t.length>0||"object"==typeof t&&null!==t&&Object.values(t).forEach(e=>{Array.isArray(e)&&e.length})}),q("commands")))):q("commands")},[x,Q,ed,T,Z]);let eg=(0,a.useMemo)(()=>(0,v.resolveBareListingQuery)(x,T),[x,T]),ep=e=>e.startsWith("/")?e.substring(1):e,eb=(e,t)=>{if(e&&t)return t.split(".").reduce((e,t)=>e&&void 0!==e[t]?e[t]:void 0,e)},ef=(0,a.useCallback)(e=>{if(!e.startsWith(">"))return!1;let t=null,a=a=>!!a&&a.shortcut===e&&(t=a,!0);return Object.values(ed).forEach(e=>{t||(Array.isArray(e)?e.some(a):"object"==typeof e&&null!==e&&Object.values(e).forEach(e=>{!t&&Array.isArray(e)&&e.some(a)}))}),!!t&&(eh(t),!0)},[ed,eh]);(0,a.useEffect)(()=>{if(!Q)return;let e=e=>{if("Enter"===e.key){let t=document.querySelector("[cmdk-input]");t&&t.value.startsWith(">")&&ef(t.value.trim())&&(e.preventDefault(),e.stopPropagation(),t.value="",I(""))}};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[Q,ef]);let ey=(0,a.useCallback)(e=>{I(e),e.startsWith(">")&&2===e.length&&setTimeout(()=>{if(ef(e)){let e=document.querySelector("[cmdk-input]");e&&(e.value="",I(""))}},10)},[ef]);(0,a.useEffect)(()=>{if(Q&&es){let e=es.initialCommand;if(es.autoExecute,e){let t=(t,a)=>(t.forEach(t=>{let a=t.id||"unknown",r=t.type||t.configuration?.type||"unknown";t.name,a===e||r===e||t.configuration?.type}),t.find(t=>t.id===e||t.configuration?.type===e||t.type===e)),a=null;Object.entries(X||{}).forEach(([e,r])=>{if(!a)if(Array.isArray(r)){let s=t(r,e);s&&(a=s)}else"object"==typeof r&&null!==r&&Object.entries(r).forEach(([r,s])=>{if(a||!Array.isArray(s))return;let i=t(s,`${e}.${r}`);i&&(a=i)})}),null!==a&&setTimeout(()=>{eh(a)},200)}}},[Q,es,X,eh]);let[ew,ev]=(0,a.useState)({isOpen:!1});(0,a.useCallback)(e=>{let t=e.payload?.completionAction;t?.action==="openPopover"&&t?.popover==="createReservation"&&(et(),ej({isOpen:!0,listingId:t.data.listingId,listing:t.data.listing}))},[et]);let[ek,ej]=(0,a.useState)({isOpen:!1,listingId:0,listing:null});return(0,a.useEffect)(()=>{let e=e=>{let{type:t,popover:a,data:r}=e.detail;"openPopover"===t&&"createReservation"===a&&(et(),ej({isOpen:!0,listingId:r.listingId,listing:r.listing}))};return document.addEventListener("ui-action",e),()=>{document.removeEventListener("ui-action",e)}},[et]),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(n.Dialog,{open:Q,onClose:et,className:"relative z-[200]",children:[(0,t.jsx)("div",{className:"fixed inset-0 bg-black/10 dark:bg-black/30 backdrop-blur-sm"}),(0,t.jsx)("div",{className:"fixed inset-0",children:(0,t.jsx)("div",{className:(0,o.cn)("absolute left-1/2 -translate-x-1/2","lg:top-[20vh] top-[10vh]"),children:(0,t.jsx)(n.Dialog.Panel,{className:(0,o.cn)("bg-white dark:bg-[#1D1D1F] border border-gray-200 dark:border-white/[0.08] rounded-2xl","shadow-[0_0_0_1px_rgba(0,0,0,0.05),0_2px_8px_0_rgba(0,0,0,0.08),0_4px_20px_0_rgba(0,0,0,0.12)] dark:shadow-[0_0_0_1px_rgba(255,255,255,0.05),0_2px_8px_0_rgba(0,0,0,0.2),0_4px_20px_0_rgba(0,0,0,0.4)]","max-h-[90vh]","lg:max-h-[80vh]","flex flex-col","w-[95vw] min-w-0","lg:w-[600px] lg:min-w-[600px]","mx-auto lg:mx-0"),children:(0,t.jsxs)(l.Command,{className:"command-palette",shouldFilter:!1,style:{"--command-dialog-width":"100%","--command-root-height":"auto","--command-input-height":"48px","--command-list-height":"auto","--command-list-padding":"8px"},children:[(0,t.jsx)(m.CommandPaletteHeader,{search:x,setSearch:I,activeCommand:T,stepState:A,onBack:()=>{if(A.history.length>0){let e=[...A.history],t=e.pop();if(t&&T?.action?.steps){let a=T.action.steps.find(e=>e.id===t);D(t=>({currentStep:a,data:t.data,history:e}))}}else _(null),D({currentStep:void 0,data:{},history:[]});I(""),R(0)},inputRef:eo,onSearchChange:ey}),(0,t.jsx)(l.Command.List,{className:(0,o.cn)("overflow-y-auto w-full","min-h-[100px]","max-h-[calc(80vh-80px)]","lg:max-h-[60vh]","py-2"),children:M&&L?(0,t.jsx)(b.CommandInFlightRow,{label:L}):ei?T?(0,t.jsx)(()=>(0,t.jsxs)("div",{className:"pb-2",children:[(0,t.jsx)("div",{className:"px-2 pb-1 h-4 w-28 bg-gray-200 dark:bg-white/[0.06] rounded animate-pulse mb-2"}),[1,2,3,4].map(e=>(0,t.jsxs)("div",{className:"px-4 py-3 flex items-center gap-3 rounded-lg",children:[(0,t.jsx)("div",{className:"w-10 h-10 rounded-lg bg-gray-200 dark:bg-white/[0.06] animate-pulse"}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("div",{className:"h-5 w-40 bg-gray-200 dark:bg-white/[0.06] rounded animate-pulse mb-2"}),(0,t.jsx)("div",{className:"h-4 w-24 bg-gray-200 dark:bg-white/[0.06] rounded animate-pulse"})]})]},e))]}),{}):(0,t.jsx)(()=>(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"pb-2",children:[(0,t.jsx)("div",{className:"px-2 pb-1 h-4 w-20 bg-gray-200 dark:bg-white/[0.06] rounded animate-pulse mb-2"}),[1,2,3].map(e=>(0,t.jsxs)("div",{className:"px-3 py-2 flex items-center gap-2",children:[(0,t.jsx)("div",{className:"w-6 h-6 rounded-full bg-gray-200 dark:bg-white/[0.06] animate-pulse"}),(0,t.jsx)("div",{className:"flex-1",children:(0,t.jsx)("div",{className:"h-4 w-32 bg-gray-200 dark:bg-white/[0.06] rounded animate-pulse"})})]},e))]}),(0,t.jsxs)("div",{className:"pb-2",children:[(0,t.jsx)("div",{className:"px-2 pb-1 h-4 w-24 bg-gray-200 dark:bg-white/[0.06] rounded animate-pulse mb-2"}),[1,2].map(e=>(0,t.jsxs)("div",{className:"px-3 py-2 flex items-center gap-2",children:[(0,t.jsx)("div",{className:"w-6 h-6 rounded-full bg-gray-200 dark:bg-white/[0.06] animate-pulse"}),(0,t.jsx)("div",{className:"flex-1",children:(0,t.jsx)("div",{className:"h-4 w-40 bg-gray-200 dark:bg-white/[0.06] rounded animate-pulse"})})]},e))]})]}),{}):T?(0,t.jsx)(u.CommandPaletteSuggestions,{loading:M,activeCommand:T,stepState:A,selectedIndex:P,filteredCommands:ed,rawCommands:X,selectedId:O,onContinue:ex,search:x,onStepStateChange:D}):"search"!==B||T?(0,t.jsx)(u.CommandPaletteSuggestions,{loading:M,activeCommand:null,stepState:A,selectedIndex:P,filteredCommands:ed,rawCommands:X,selectedId:O,onContinue:ex,search:x,onStepStateChange:D,renderExtraSections:({hasCommands:e})=>eg?(0,t.jsx)(v.ListingSuggestions,{suggestions:[],stepState:{currentStep:{id:"inline-listings",type:"listing",heading:"Listings",placeholder:"Search listings...",label:"Listings",suggestions:[]},data:{},history:[]},selectedIndex:-1,search:eg,limitResults:e?v.INLINE_LISTING_CAP:void 0,hideWhenEmpty:!0,hideLoadingSpinner:!0,onSuggestionClick:e=>{let t=e.metadata?.listingId||e.id;window.location.href=`/listings/${t}`,et()}}):null}):(0,t.jsxs)("div",{className:"space-y-2",children:[(z>0||V>0)&&(0,t.jsx)("div",{className:"flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-white/[0.02] rounded-lg",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[z>0&&(0,t.jsxs)("span",{className:"bg-gray-100 dark:bg-white/10 text-gray-500 dark:text-white/60 px-2 py-0.5 rounded-full text-xs",children:[z," reservation",1!==z?"s":""]}),V>0&&(0,t.jsxs)("span",{className:"bg-gray-100 dark:bg-white/10 text-gray-500 dark:text-white/60 px-2 py-0.5 rounded-full text-xs",children:[V," listing",1!==V?"s":""]})]})}),(W||Y)&&0===z&&0===V&&(0,t.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,t.jsx)(C.Spinner,{className:"w-6 h-6"})}),(0,t.jsx)(w.ReservationSuggestions,{suggestions:[],stepState:{currentStep:{id:"search-reservations",type:"reservation",heading:"Reservations",placeholder:"Search reservations...",label:"Reservations",suggestions:[]},data:{},history:[]},selectedIndex:P,selectedId:O,search:ep(x),isSearch:!0,showCountBadge:!0,limitResults:3,onCountChange:H,onLoadingChange:K,hideLoadingSpinner:(W||Y)&&0===z&&0===V}),(0,t.jsx)(v.ListingSuggestions,{suggestions:[],stepState:{currentStep:{id:"search-listings",type:"listing",heading:"Listings",placeholder:"Search listings...",label:"Listings",suggestions:[]},data:{},history:[]},selectedIndex:P,selectedId:O,search:ep(x),onSuggestionClick:e=>{let t=e.metadata?.listingId||e.id,a=`/listings/${t}`;window.location.href=a,et()},showCountBadge:!0,onCountChange:G,onLoadingChange:J,hideLoadingSpinner:(W||Y)&&0===z&&0===V})]})}),e&&(0,t.jsx)("div",{className:"flex-none border-t border-gray-200 dark:border-white/[0.08] bg-white dark:bg-[#1D1D1F]",children:e})]})})})})]}),ek.isOpen&&ek.listing&&(0,t.jsx)(N.CreateReservationPopover,{dates:[],listingId:ek.listingId,listing:ek.listing,onClose:()=>ej(e=>({...e,isOpen:!1}))})]})}var _=e.i(846932),A=e.i(88653),D=e.i(37727),P=e.i(686311),R=e.i(643531),M=e.i(797548),F=e.i(555436),L=e.i(332102),$=e.i(63209),O=e.i(87316),U=e.i(212426),B=e.i(870273),q=e.i(239616),z=e.i(761911),H=e.i(722915),V=e.i(694351),G=e.i(655900),W=e.i(664659),K=e.i(778917),Y=e.i(531278),J=e.i(876926),Q=e.i(922927),X=e.i(941912);let Z={PAYMENT_FAILURE:"payment_failure",PAYMENT_SUCCESS:"payment_success",PAYOUT_INITIATED:"payout_initiated",PAYOUT_COMPLETED:"payout_completed",PAYOUT_FAILED:"payout_failed",DEPOSIT_RENEWAL_FAILED:"deposit_renewal_failed",MESSAGE:"message",THREAD_UPDATE:"thread_update",MENTION:"mention",RESERVATION_REQUEST:"reservation_request",RESERVATION_CONFIRMED:"reservation_confirmed",RESERVATION_CANCELLED:"reservation_cancelled",RESERVATION_MODIFIED:"reservation_modified",RESERVATION_CREATED:"reservation_created",RESERVATION_UPDATED:"reservation_updated",RESERVATION_PAYMENT_PENDING:"reservation_payment_pending",RESERVATION_PAYMENT_COMPLETED:"reservation_payment_completed",RESERVATION_REQUESTED:"reservation_requested",RESERVATION_REQUEST_VOIDED:"reservation_request_voided",UPSELL_REQUEST:"upsell_request",RESERVATION_ALTERATION_REQUESTED:"reservation_alteration_requested",RESERVATION_ALTERATION_ACCEPTED:"reservation_alteration_accepted",RESERVATION_ALTERATION_DECLINED:"reservation_alteration_declined",CHECKIN_REMINDER:"checkin_reminder",CHECKOUT_REMINDER:"checkout_reminder",REVIEW:"review",REVIEW_RECEIVED:"review_received",REVIEW_REMINDER:"review_reminder",REVIEW_RESPONSE_RECEIVED:"review_response_received",REVIEW_NEGATIVE:"review_negative",REVIEW_POSITIVE:"review_positive",REVIEW_NEUTRAL:"review_neutral",LISTING_PUBLISHED:"listing_published",LISTING_UNPUBLISHED:"listing_unpublished",LISTING_UPDATED:"listing_updated",LISTING_ISSUE:"listing_issue",LISTING_SUSPENDED:"listing_suspended",LISTING_REACTIVATED:"listing_reactivated",CALENDAR_CONFLICT:"calendar_conflict",CALENDAR_UPDATE:"calendar_update",PRICE_UPDATE:"price_update",SYSTEM:"system",ERROR:"error",SYNC:"sync",MAINTENANCE:"maintenance",PERFORMANCE_ALERT:"performance_alert",RANKING_CHANGE:"ranking_change",QUALITY_ISSUE:"quality_issue",BLACKLISTED_GUEST_BOOKING:"blackl
24isted_guest_booking",GUEST_COMPLAINT:"guest_complaint",GUEST_REQUEST:"guest_request",GUEST_REVIEW_ALERT:"guest_review_alert",QUALITY_STANDARD:"quality_standard",TIMELINE_UPDATE:"timeline_update",DASHBOARD_ASSIGNMENT:"dashboard_assignment",IOT_BATTERY:"iot_battery",IOT_WIFI:"iot_wifi",OPERATIONS_DAILY_REPORT:"operations_daily_report",TASK_COMPLETED:"task_completed",REPULL_SUBSCRIPTION_CREATED:"repull_subscription_created",REPULL_SUBSCRIPTION_CANCELED:"repull_subscription_canceled",HOST_SUSPENDED:"host_suspended",HOST_REACTIVATED:"host_reactivated",HOST_AUTHORIZATION_REVOKED:"host_authorization_revoked",HOST_ACCOUNT_ACTIVATED:"host_account_activated",PMS_RECONNECT_REQUIRED:"pms_reconnect_required"},ee={CRITICAL:"critical",HIGH:"high",MEDIUM:"medium",LOW:"low"},et={FINANCIAL:"financial",COMMUNICATION:"communication",RESERVATION:"reservation",REVIEW:"review",LISTING:"listing",CALENDAR:"calendar",SYSTEM:"system",PERFORMANCE:"performance",GUEST:"guest",SMART_DEVICES:"smart_devices"};Z.PAYMENT_FAILURE,ee.CRITICAL,Z.PAYMENT_SUCCESS,ee.HIGH,Z.PAYOUT_INITIATED,ee.HIGH,Z.PAYOUT_COMPLETED,ee.HIGH,Z.PAYOUT_FAILED,ee.CRITICAL,Z.DEPOSIT_RENEWAL_FAILED,ee.CRITICAL,Z.REPULL_SUBSCRIPTION_CREATED,ee.HIGH,Z.REPULL_SUBSCRIPTION_CANCELED,ee.HIGH,Z.MESSAGE,ee.MEDIUM,Z.THREAD_UPDATE,ee.MEDIUM,Z.MENTION,ee.MEDIUM,Z.REVIEW,ee.MEDIUM,Z.REVIEW_RECEIVED,ee.MEDIUM,Z.REVIEW_REMINDER,ee.LOW,Z.REVIEW_RESPONSE_RECEIVED,ee.MEDIUM,Z.REVIEW_NEGATIVE,ee.HIGH,Z.REVIEW_POSITIVE,ee.LOW,Z.REVIEW_NEUTRAL,ee.MEDIUM,Z.RESERVATION_REQUEST,ee.HIGH,Z.RESERVATION_CONFIRMED,ee.HIGH,Z.RESERVATION_CANCELLED,ee.HIGH,Z.RESERVATION_MODIFIED,ee.HIGH,Z.RESERVATION_CREATED,ee.HIGH,Z.RESERVATION_UPDATED,ee.MEDIUM,Z.RESERVATION_REQUESTED,ee.HIGH,Z.RESERVATION_REQUEST_VOIDED,ee.LOW,Z.UPSELL_REQUEST,ee.HIGH,Z.RESERVATION_ALTERATION_REQUESTED,ee.HIGH,Z.RESERVATION_ALTERATION_ACCEPTED,ee.MEDIUM,Z.RESERVATION_ALTERATION_DECLINED,ee.MEDIUM,Z.RESERVATION_PAYMENT_PENDING,ee.HIGH,Z.RESERVATION_PAYMENT_COMPLETED,ee.MEDIUM,Z.CHECKIN_REMINDER,ee.MEDIUM,Z.CHECKOUT_REMINDER,ee.MEDIUM,Z.LISTING_PUBLISHED,ee.HIGH,Z.LISTING_UNPUBLISHED,ee.HIGH,Z.LISTING_UPDATED,ee.MEDIUM,Z.LISTING_ISSUE,ee.HIGH,Z.LISTING_SUSPENDED,ee.CRITICAL,Z.LISTING_REACTIVATED,ee.HIGH,Z.CALENDAR_CONFLICT,ee.HIGH,Z.CALENDAR_UPDATE,ee.MEDIUM,Z.PRICE_UPDATE,ee.MEDIUM,Z.SYSTEM,ee.MEDIUM,Z.ERROR,ee.CRITICAL,Z.SYNC,ee.MEDIUM,Z.MAINTENANCE,ee.HIGH,Z.PERFORMANCE_ALERT,ee.HIGH,Z.RANKING_CHANGE,ee.MEDIUM,Z.QUALITY_ISSUE,ee.HIGH,Z.BLACKLISTED_GUEST_BOOKING,ee.CRITICAL,Z.GUEST_COMPLAINT,ee.HIGH,Z.GUEST_REQUEST,ee.HIGH,Z.GUEST_REVIEW_ALERT,ee.HIGH,Z.QUALITY_STANDARD,ee.HIGH,Z.TIMELINE_UPDATE,ee.MEDIUM,Z.DASHBOARD_ASSIGNMENT,ee.HIGH,Z.IOT_BATTERY,ee.HIGH,Z.IOT_WIFI,ee.MEDIUM,Z.HOST_SUSPENDED,ee.HIGH,Z.HOST_REACTIVATED,ee.HIGH,Z.HOST_AUTHORIZATION_REVOKED,ee.HIGH,Z.HOST_ACCOUNT_ACTIVATED,ee.HIGH,Z.PMS_RECONNECT_REQUIRED,ee.HIGH,Z.OPERATIONS_DAILY_REPORT,ee.MEDIUM,Z.TASK_COMPLETED,ee.MEDIUM,e.s(["NotificationCategory",0,et,"NotificationPriority",0,ee,"NotificationType",0,Z],877077);let ea=Object.values(ee),er={[et.FINANCIAL]:[Z.PAYMENT_FAILURE,Z.PAYMENT_SUCCESS,Z.PAYOUT_INITIATED,Z.PAYOUT_COMPLETED,Z.PAYOUT_FAILED],[et.RESERVATION]:[Z.RESERVATION_REQUEST,Z.RESERVATION_CONFIRMED,Z.RESERVATION_CANCELLED,Z.RESERVATION_MODIFIED,Z.RESERVATION_CREATED,Z.RESERVATION_UPDATED,Z.RESERVATION_PAYMENT_PENDING,Z.RESERVATION_PAYMENT_COMPLETED,Z.RESERVATION_REQUESTED,Z.RESERVATION_REQUEST_VOIDED,Z.CHECKIN_REMINDER,Z.CHECKOUT_REMINDER],[et.COMMUNICATION]:[Z.MESSAGE,Z.MENTION],[et.REVIEW]:[Z.REVIEW,Z.REVIEW_RECEIVED,Z.REVIEW_RESPONSE_RECEIVED,Z.REVIEW_REMINDER,Z.REVIEW_NEGATIVE,Z.REVIEW_POSITIVE,Z.REVIEW_NEUTRAL],[et.LISTING]:[Z.LISTING_PUBLISHED,Z.LISTING_UNPUBLISHED,Z.LISTING_UPDATED,Z.LISTING_ISSUE,Z.LISTING_SUSPENDED,Z.LISTING_REACTIVATED],[et.CALENDAR]:[Z.CALENDAR_CONFLICT,Z.CALENDAR_UPDATE,Z.PRICE_UPDATE],[et.SYSTEM]:[Z.SYSTEM,Z.ERROR,Z.SYNC,Z.MAINTENANCE],[et.PERFORMANCE]:[Z.PERFORMANCE_ALERT,Z.RANKING_CHANGE,Z.QUALITY_ISSUE,Z.QUALITY_STANDARD],[et.GUEST]:[Z.GUEST_COMPLAINT,Z.GUEST_REQUEST,Z.GUEST_REVIEW_ALERT]},es=["Read","Unread","Archived"];function ei({isOpen:e,onClose:r,onApplyFilters:s,initialFilters:i}
24){let[n,l]=(0,a.useState)(i||{priority:[],type:[],status:[],dateRange:{from:null,to:null}});return(0,a.useEffect)(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="unset",()=>{document.body.style.overflow="unset"}),[e]),(0,t.jsx)(A.AnimatePresence,{children:e&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(_.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/30 backdrop-blur-sm z-[101]",onClick:r}),(0,t.jsxs)(_.motion.div,{initial:{opacity:0,y:-20,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-20,scale:.95},transition:{duration:.2},className:(0,o.cn)("fixed right-8 top-20 z-[102]","w-[320px] max-h-[80vh] flex flex-col","bg-white dark:bg-[#1D1D1F] rounded-2xl","border border-gray-200 dark:border-white/[0.08]","shadow-[0_0_0_1px_rgba(0,0,0,0.05),0_2px_8px_0_rgba(0,0,0,0.08)] dark:shadow-[0_0_0_1px_rgba(255,255,255,0.05),0_2px_8px_0_rgba(0,0,0,0.2)]"),children:[(0,t.jsxs)("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsx)("h2",{className:"text-lg font-medium text-gray-900 dark:text-white",children:"Filter Notifications"}),(0,t.jsx)("button",{onClick:r,className:"p-2 rounded-full hover:bg-gray-100 dark:hover:bg-white/[0.08] transition-colors",children:(0,t.jsx)(D.X,{className:"w-5 h-5 text-gray-600 dark:text-white/70"})})]}),(0,t.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,t.jsxs)("div",{className:"p-4 space-y-6",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Priority"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:ea.map(e=>(0,t.jsx)("button",{onClick:()=>{let t=n.priority.includes(e)?n.priority.filter(t=>t!==e):[...n.priority,e];l({...n,priority:t})},className:(0,o.cn)("px-3 py-1.5 text-sm rounded-lg","transition-colors",n.priority.includes(e)?"bg-gray-200 dark:bg-white/20 text-gray-900 dark:text-white":"bg-gray-50 dark:bg-white/5 text-gray-500 dark:text-white/60 hover:bg-gray-100 dark:hover:bg-white/10"),children:e},e))})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Type"}),Object.entries(er).map(([e,a])=>(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-xs font-medium text-gray-500 dark:text-white/60",children:e}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:a.map(e=>(0,t.jsx)("button",{onClick:()=>{let t=n.type.includes(e)?n.type.filter(t=>t!==e):[...n.type,e];l({...n,type:t})},className:(0,o.cn)("px-3 py-1.5 text-sm rounded-lg","transition-colors",n.type.includes(e)?"bg-gray-200 dark:bg-white/20 text-gray-900 dark:text-white":"bg-gray-50 dark:bg-white/5 text-gray-500 dark:text-white/60 hover:bg-gray-100 dark:hover:bg-white/10"),children:e.split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")},e))})]},e))]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Status"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:es.map(e=>(0,t.jsx)("button",{onClick:()=>{let t=n.status.includes(e)?n.status.filter(t=>t!==e):[...n.status,e];l({...n,status:t})},className:(0,o.cn)("px-3 py-1.5 text-sm rounded-lg","transition-colors",n.status.includes(e)?"bg-gray-200 dark:bg-white/20 text-gray-900 dark:text-white":"bg-gray-50 dark:bg-white/5 text-gray-500 dark:text-white/60 hover:bg-gray-100 dark:hover:bg-white/10"),children:e},e))})]})]})}),(0,t.jsxs)("div",{className:"flex-shrink-0 flex justify-end gap-2 p-4 border-t border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsx)("button",{onClick:r,className:(0,o.cn)("px-4 py-2 text-sm font-medium rounded-lg","text-gray-600 dark:text-white/70 hover:bg-gray-100 dark:hover:bg-white/[0.08] transition-colors"),children:"Cancel"}),(0,t.jsx)("button",{onClick:()=>{s(n),r()},className:(0,o.cn)("px-4 py-2 text-sm font-medium rounded-lg","bg-gray-100 dark:bg-white/10 text-gray-900 dark:text-white hover:bg-gray-200 dark:hover:bg-white/20 transition-colors"),children:"Apply Filters"})]})]})]})})}var en=e.i(217949),el=e.i(522016),eo=e.i(133820),ed=e.i(618566);let ec=[{id:"all",name:"All",icon:L.Inbox},{id:"unread",name:"Unread",icon:$.AlertCircle},{id:et.FINANCIAL,name:"Financial",icon:U.DollarSign},{id:et.RESERVATION,name:"Reservations",icon:O.Calendar},{id:et.COMMUNICATION,name:"Messages",icon:P.MessageSquare},{id:et.REVIEW,name:"Reviews",icon:B.Star},{id:et.LISTING,name:"Listings",icon:V.Home},{id:et.SYSTEM,name:"System",icon:q.Settings},{id:et.GUEST,name:"Guests",icon:z.Users}];e.s(["NotificationsSidebar",0,function(){let{currentCustomerId:e}=(0,eo.useCustomer)(),{isSidebarOpen:r,closeSidebar:s}=(0,J.useNotificationStore)(),[i,n]=(0,a.useState)("all"),[l,d]=(0,a.useState)(""),{activities:c,markAsRead:m,getUnreadCount:u}=(0,Q.useActivity)(),[h,x]=(0,a.useState)(!1),[g,p]=(0,a.useState)(null),[b,y]=(0,a.useState)(null),[w,v]=(0,a.useState)({priority:[],type:[],status:[],dateRange:{from:null,to:null}}),[k,j]=(0,a.useState)(!1),[N,C]=(0,a.useState)(!1),[S,E]=(0,a.useState)(null),[I,T]=(0,a.useState)(new Set),P=(0,a.useRef)(!1),L=(0,ed.useRouter)(),{fetchItem:$}
24=(0,en.useDashboardItem)(),{openModalByReservation:O,openModal:U,openModalByThreadId:B}=(0,f.useDashboard)(),[z,V]=(0,a.useState)(!1),Z=(0,a.useRef)(0),ee=(0,a.useCallback)(async t=>{if(!e)return void console.log("[NotificationsSidebar] No customer ID available");try{eb(!0);let a=new URLSearchParams({customerId:e.toString(),includeArchived:t?.includeArchived?"true":"false",_t:Date.now().toString()}),r=await fetch(`/api/notifications?${a.toString()}`);if(!r.ok)throw Error(`Failed to fetch notifications: ${r.status}`);let s=await r.json();s?.notifications&&window.dispatchEvent(new CustomEvent("notifications:refresh",{detail:{notifications:s.notifications}})),V(!1),Z.current=Date.now()}catch(e){console.error("[NotificationsSidebar] Error refreshing notifications:",e)}finally{eb(!1)}},[e]),ea=w.status.includes("archived")||"all"!==i&&"unread"!==i&&"filters"!==i;(0,a.useEffect)(()=>{!r||Date.now()-Z.current>3e4&&(V(!0),ee({includeArchived:ea}))},[r,ee,ea]),(0,a.useEffect)(()=>{let e=()=>{"visible"===document.visibilityState&&r&&Date.now()-Z.current>3e4&&(V(!0),ee({includeArchived:ea}))};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[r,ee,ea]);let er=c.filter(e=>{let t=e.notificationType||("notification"===e.type&&e.title?.toLowerCase()?.includes("booking")?"reservation_request":e.type),a="reservation_request"===t||t.startsWith("reservation_")||"checkin_reminder"===t||"checkout_reminder"===t?et.RESERVATION:t.startsWith("payment_")||t.startsWith("payout_")?et.FINANCIAL:t.startsWith("message_")||t.startsWith("timeline_")||"thread_update"===t||"mention"===t?et.COMMUNICATION:t.startsWith("review_")?et.REVIEW:t.startsWith("listing_")?et.LISTING:t.startsWith("calendar_")||"price_update"===t?et.CALENDAR:t.startsWith("guest_")?et.GUEST:["system","error","sync","maintenance"].includes(t)?et.SYSTEM:["performance_alert","ranking_change","quality_issue"].includes(t)?et.PERFORMANCE:et.SYSTEM,r="read"===e.status||!0===e.is_read||e.recipient_status&&!0===e.recipient_status.is_read,s=!l||""===l.toLowerCase()||(e.title?.toLowerCase()||"").includes(l.toLowerCase())||(e.description?.toLowerCase()||e.message?.toLowerCase()||"").includes(l.toLowerCase()),n=0===w.priority.length||w.priority.includes(e.priority?.toLowerCase()||""),o=0===w.type.length||w.type.includes(t),d=!0===e.is_archived||e.recipient_status?.is_archived===!0,c=0===w.status.length?"all"!==i&&"unread"!==i||!d:w.status.some(e=>{let t=e.toLowerCase();return"archived"===t?d:"read"===t?r&&!d:"unread"===t&&!r&&!d}),m="filters"===i||"all"===i||"unread"===i&&!r||Object.values(et).includes(i)&&a===i;return s&&n&&o&&c&&m});(0,a.useEffect)(()=>{let e="all"!==i&&"unread"!==i&&"filters"!==i,t=w.type.length>0||w.status.length>0;(e||t)&&ee({includeArchived:ea})},[i,w,ee,ea]);let es=()=>Object.values(w).some(e=>Array.isArray(e)?e.length>0:e&&"object"==typeof e?!!(e.from||e.to):!!e),em=[{id:"filters",name:"Filters",icon:M.Filter},...ec];(0,a.useEffect)(()=>{es()&&"filters"!==i?n("filters"):es()||"filters"!==i||n("all")},[w,i]);let eu=async e=>{y(e);try{if(!(await fetch("/api/notifications",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"archive",id:e})})).ok)throw Error("Failed to archive notification");window.dispatchEvent(new CustomEvent("notification:archive",{detail:{id:Number(e)}}))}catch(e){console.error("Error archiving notification:",e)}finally{y(null)}},eh=async()=>{C(!0);try{if(!(await fetch("/api/notifications",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"archiveAll"})})).ok)throw Error("Failed to archive all");window.dispatchEvent(new CustomEvent("notification:archiveAll",{detail:{ids:er.map(e=>Number(e.id))}})),E("archive"),setTimeout(()=>E(null),2e3)}catch(e){console.error("Error archiving all:",e)}finally{C(!1)}},ex=async()=>{if(!P.current){P.current=!0,j(!0);try{if(console.log(`Marking ${er.length} notifications as read`),!(await fetch("/api/notifications",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"markAllRead"})})).ok)throw Error("Failed to mark all as read");let e=er.map(e=>Number(e.id));console.log("[NotificationsSidebar] Marking notifications as read:",e),window.dispatchEvent(new CustomEvent("notifications:markAllRead",{detail:{ids:e}})),E("read"),setTimeout(()=>E(null),2e3)}catch(e){console.error("[NotificationsSidebar] Error marking all as read:",e)}finally{j(!1),setTimeout(()=>{P.current=!1},1e3)}}};(0,a.useEffect)(()=>(r?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[r]),(0,a.useEffect)(()=>{let e=()=>{s()};return window.addEventListener("modal:open",e),window.addEventListener("modal.open",e),()=>{window.removeEventListener("modal:open",e),window.removeEventListener("modal.open",e)}},[s]);let eg=(0,a.useRef)(null),[ep,eb]=(0,a.useState)(!1),ef=(0,a.useRef)(null),ey=(0,a.useRef)(null);return(0,t.jsx)(A.AnimatePresence,{children:r&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(_.motion.div,{initial:{opacity:0}
24,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/30 backdrop-blur-sm z-50",onClick:s}),(0,t.jsxs)(_.motion.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",damping:20,stiffness:300},className:(0,o.cn)("fixed inset-y-0 right-0 w-[400px] z-50","bg-gray-100 dark:bg-[#1D1D1F] border-l border-gray-200 dark:border-white/[0.08]","shadow-[0_0_0_1px_rgba(0,0,0,0.05),0_2px_8px_0_rgba(0,0,0,0.08)] dark:shadow-[0_0_0_1px_rgba(255,255,255,0.05),0_2px_8px_0_rgba(0,0,0,0.2)]","flex flex-col overflow-hidden"),children:[(0,t.jsxs)("div",{className:"flex-none",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsx)("div",{className:"text-lg font-medium text-gray-900 dark:text-white",children:"Notifications"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(el.default,{href:"/settings/notifications",onClick:s,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.08] transition-colors",title:"Notification Settings",children:(0,t.jsx)(q.Settings,{className:"w-4 h-4 text-gray-600 dark:text-white/70"})}),(0,t.jsx)("button",{onClick:()=>x(!0),className:(0,o.cn)("p-2 rounded-lg transition-colors",es()?"bg-gray-100 dark:bg-white/10 text-gray-900 dark:text-white hover:bg-gray-200 dark:hover:bg-white/20":"hover:bg-gray-100 dark:hover:bg-white/[0.08] text-gray-600 dark:text-white/70"),children:(0,t.jsx)(M.Filter,{className:"w-4 h-4"})}),(0,t.jsx)("button",{onClick:s,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.08] transition-colors",children:(0,t.jsx)(D.X,{className:"w-4 h-4 text-gray-600 dark:text-white/70"})})]})]}),(0,t.jsx)("div",{className:"p-4 border-b border-gray-200 dark:border-white/[0.08]",children:(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(F.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500 dark:text-white/40"}),(0,t.jsx)("input",{type:"text",placeholder:"Search notifications...",value:l,onChange:e=>d(e.target.value),className:(0,o.cn)("w-full pl-10 pr-4 py-2 rounded-lg","bg-gray-50 dark:bg-white/[0.05]","text-sm text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-white/40","border border-transparent focus:border-gray-300 dark:focus:border-white/10","transition-colors")})]})}),(0,t.jsx)("div",{className:"flex overflow-x-auto p-2 gap-2 border-b border-gray-200 dark:border-white/[0.08]",children:em.map(e=>"filters"!==e.id||es()?(0,t.jsxs)("button",{onClick:()=>n(e.id),className:(0,o.cn)("px-3 py-1.5 rounded-lg text-sm whitespace-nowrap","flex items-center gap-2","transition-colors",i===e.id?"bg-gray-100 dark:bg-white/10 text-gray-900 dark:text-white":"text-gray-500 dark:text-white/60 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-white/[0.08]"),children:[(0,t.jsx)(e.icon,{className:"w-4 h-4"}),e.name,"filters"===e.id&&(0,t.jsx)("span",{className:"ml-1 px-1.5 py-0.5 text-xs bg-gray-200 dark:bg-white/20 rounded-full",children:Object.values(w).reduce((e,t)=>e+(Array.isArray(t)?t.length:0),0)})]},e.id):null)})]}),(0,t.jsxs)("div",{ref:eg,className:"flex-1 overflow-y-auto overflow-x-hidden relative",onTouchStart:e=>{eg.current?.scrollTop===0&&(ef.current=e.touches[0].clientY)},onTouchMove:e=>{if(null===ef.current)return;ey.current=e.touches[0].clientY;let t=ey.current-ef.current;t>0&&t<200&&(e.preventDefault(),eg.current.style.transform=`translateY(${t}px)`)},onTouchEnd:async()=>{if(null===ef.current||null===ey.current)return;let e=ey.current-ef.current;eg.current.style.transform="",e>100&&(eb(!0),await ee(),eb(!1)),ef.current=null,ey.current=null},children:[ep&&(0,t.jsx)("div",{className:"absolute top-0 left-0 right-0 flex items-center justify-center py-2",children:(0,t.jsx)(Y.Loader2,{className:"w-5 h-5 animate-spin text-gray-500 dark:text-white/60"})}),er.length>0?er.map(e=>{let a=b===e.id.toString(),r="read"===e.status||!0===e.is_read||e.recipient_status?.is_read===!0,i=X.NotificationUtils.getNotificationIcon(e);return(0,t.jsxs)("div",{onClick:()=>(e=>
24{if(e.id&&m(e.id.toString()),e.collapsed_ids?.length&&fetch("/api/notifications",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"markBatchRead",ids:e.collapsed_ids})}),"proactive_chat"===e.source_type&&e.source_reference?.conversationId){L.push(`/?c=${e.source_reference.conversationId}`),s();return}if(e.source_reference?.url){L.push(e.source_reference.url),s();return}if(e.source_type?.includes("task")&&e.source_reference?.taskId){let t=e.source_reference.taskId,a=e.metadata?.biddedAt,r=new URL(window.location.href),i=new URLSearchParams(r.search);i.set("task",t),a?i.set("marketplace","true"):i.delete("marketplace");let n=`${r.pathname}?${i.toString()}`;L.push(n),s();return}let t=e.external_link||e.externalLink||e.metadata?.externalLink;if(t){window.open(t,"_blank","noopener,noreferrer"),s();return}X.NotificationUtils.handleNotificationClick(e,{closeDropdown:s,onClose:s,openModalByReservation:O,openModalByThreadId:B,openModal:U,markAsRead:m})})(e),onMouseEnter:()=>p(e.id.toString()),onMouseLeave:()=>p(null),className:(0,o.cn)("relative px-4 py-3","hover:bg-gray-50 dark:hover:bg-white/[0.02] transition-colors cursor-pointer",!r&&"bg-white dark:bg-white/[0.02]","border-l-2",r?"border-l-transparent":"border-l-blue-500"),children:[(0,t.jsxs)("div",{className:"flex gap-3",children:[(0,t.jsx)("div",{className:(0,o.cn)("w-8 h-8 shrink-0 rounded-full flex items-center justify-center","bg-gray-50 dark:bg-white/[0.05]"),children:(0,t.jsx)(i,{className:"w-4 h-4 text-gray-600 dark:text-white/70"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsx)("div",{className:"flex-1 min-w-0",children:(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("div",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",title:e.title||"No title",children:[e.title||"No title",(e.external_link||e.externalLink||e.metadata?.externalLink)&&(0,t.jsx)(K.ExternalLink,{className:"w-3.5 h-3.5 inline-block ml-1 text-gray-500 dark:text-white/60"})]}),e.collapsed_count&&e.collapsed_count>1&&(0,t.jsxs)("span",{className:"px-1.5 py-0.5 text-xs font-medium rounded-full shrink-0 bg-blue-500/10 text-blue-500 dark:bg-blue-400/10 dark:text-blue-400",children:["+",e.collapsed_count-1]}),e.priority&&(0,t.jsx)("span",{className:(0,o.cn)("px-2 py-0.5 text-xs font-medium rounded-full shrink-0",X.NotificationUtils.getPriorityStyles(e.priority)),children:e.priority})]})}),(0,t.jsx)("div",{className:"text-xs text-gray-500 dark:text-white/40 whitespace-nowrap shrink-0",children:e.time||e.timestamp&&X.NotificationUtils.formatTime(e.timestamp)||e.created_at&&X.NotificationUtils.formatTime(e.created_at)||"Unknown time"})]}),(e.description||e.message)&&(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsxs)("div",{className:(0,o.cn)("text-sm whitespace-pre-line",r?"text-gray-500 dark:text-white/60":"text-gray-600 dark:text-white/80",I.has(e.id.toString())?"max-h-none":"max-h-[120px] overflow-hidden relative"),children:[e.description||e.message||"No description",!I.has(e.id.toString())&&(e.description?.length||0)+(e.message?.length||0)>120&&(0,t.jsx)("div",{className:(0,o.cn)("absolute bottom-0 left-0 right-0 h-16 pointer-events-none","bg-gradient-to-t from-gray-100 via-gray-100/80 to-transparent","dark:from-[#1D1D1F] dark:via-[#1D1D1F]/80 dark:to-transparent","backdrop-blur-[2px]")})]}),(e.description?.length||0)+(e.message?.length||0)>120&&(0,t.jsx)("div",{className:I.has(e.id.toString())?"mt-2":"-mt-6 relative z-10",children:(0,t.jsx)("button",{onClick:t=>{var a;return a=e.id.toString(),void(t.stopPropagation(),T(e=>{let t=new Set(e);return t.has(a)?t.delete(a):t.add(a),t}))},className:"text-xs text-gray-600 dark:text-white/70 self-start flex items-center gap-1 transition-colors hover:text-gray-700 dark:hover:text-white/90",children:I.has(e.id.toString())?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(G.ChevronUp,{className:"w-3 h-3"}),(0,t.jsx)("span",{children:"Show less"})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(W.ChevronDown,{className:"w-3 h-3"}),(0,t.jsx)("span",{children:"Show more"})]})})})]})]})]}),(g===e.id.toString()||a)&&(0,t.jsx)("div",{className:"absolute right-4 top-1/2 -translate-y-1/2 flex items-center gap-1",children:(0,t.jsx)("button",{onClick:t=>{t.stopPropagation(),eu(e.id.toString())},disabled:a,className:(0,o.cn)("p-1.5 rounded-full transition-colors","bg-gray-100 dark:bg-[#2A2A2D] hover:bg-gray-200 dark:hover:bg-[#3A3A3D]","shadow-sm shadow-black/5 dark:shadow-black/10",a?"opacity-70":"","text-gray-500 dark:text-white/60 hover:text-red-400"),children:a?(0,t.jsx)(Y.Loader2,{className:"w-4 h-4 animate-spin text-gray-500 dark:text-white/60"}):(0,t.jsx)(H.Archive,{className:"w-4 h-4"})})})]},e.id)}):(0,t.jsx)(X.NotificationUtils.EmptyState,{className:(0,o.cn)("min-h-[400px]",l&&"pt-16")})]}),er.length>0&&(0,t.jsx)("div",{className:"flex-none p-4 border-t border-gray-200 dark:border-white/[0.08] bg-white/95 dar
24k:bg-[#18181A]/95 backdrop-blur supports-[backdrop-filter]:bg-white/80 dark:supports-[backdrop-filter]:bg-[#18181A]/80 pb-5 relative z-[1002]",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 relative z-[1005]",children:[(0,t.jsxs)("button",{onClick:ex,disabled:k,className:(0,o.cn)("flex-1 px-4 py-2 rounded-lg text-sm","bg-gray-100 dark:bg-[#2A2A2D] hover:bg-gray-200 dark:hover:bg-[#3A3A3D]","text-gray-600 dark:text-white/70 hover:text-gray-900 dark:hover:text-white","transition-colors","flex items-center justify-center gap-2","relative",k&&"opacity-50 cursor-not-allowed"),children:[k?(0,t.jsx)(Y.Loader2,{className:"w-4 h-4 animate-spin text-gray-500 dark:text-white/60"}):"read"===S?(0,t.jsx)(R.Check,{className:"w-4 h-4 text-green-400"}):(0,t.jsx)(R.Check,{className:"w-4 h-4"}),"read"===S?"Marked as read":"Mark all read"]}),(0,t.jsxs)("button",{onClick:eh,disabled:N,className:(0,o.cn)("flex-1 px-4 py-2 rounded-lg text-sm","bg-gray-100 dark:bg-[#2A2A2D] hover:bg-gray-200 dark:hover:bg-[#3A3A3D]","text-gray-600 dark:text-white/70 hover:text-red-400","transition-colors","flex items-center justify-center gap-2","relative",N&&"opacity-50 cursor-not-allowed"),children:[N?(0,t.jsx)(Y.Loader2,{className:"w-4 h-4 animate-spin text-gray-500 dark:text-white/60"}):"archive"===S?(0,t.jsx)(R.Check,{className:"w-4 h-4 text-green-400"}):(0,t.jsx)(H.Archive,{className:"w-4 h-4"}),"archive"===S?"Archived":"Archive all"]})]})}),(0,t.jsx)(ei,{isOpen:h,onClose:()=>x(!1),initialFilters:w,onApplyFilters:v})]})]})})}],953197);let em=(0,a.createContext)(null);e.s(["AchievementsProvider",0,function({children:e,onInitialized:r}){let[s,i]=(0,a.useState)(!1),[n,l]=(0,a.useState)(!0),o=(0,a.useRef)(!1);(0,a.useEffect)(()=>{o.current||(o.current=!0,r?.())},[]);let d=(0,a.useCallback)(()=>{i(!0)},[]),c=(0,a.useCallback)(()=>{i(!1)},[]),m=(0,a.useCallback)(()=>{l(!1)},[]);return(0,t.jsx)(em.Provider,{value:{isOpen:s,openAchievements:d,closeAchievements:c,hasNewAchievements:n,markAchievementsSeen:m},children:e})},"useAchievements",0,function(){let e=(0,a.useContext)(em);if(!e)throw Error("useAchievements must be used within an AchievementsProvider");return e}],994310);var eu=e.i(217255);function eh(e,t,a=window){a.dispatchEvent(new CustomEvent("command:result",{detail:{command:e,result:{...t,localId:e.localId,silent:!0===e.silent}}}))}let ex=function(e={}){let t=e.windowMs??1e3,a=e.now??Date.now,r=new Map;return{async run(s,i){let n=function(e){let t=e.payload?.ids;if(Array.isArray(t))return`${e.topic}:${e.event}:${t.join(",")}`;let a=e.payload?.id;if(null!=a&&""!==a)return`${e.topic}:${e.event}:${a}`;try{return`${e.topic}:${e.event}:payload:${function e(t){if(Array.isArray(t))return`[${t.map(e).join(",")}]`;if(t&&"object"==typeof t){let a=Object.keys(t).sort().filter(e=>void 0!==t[e]).map(a=>`${JSON.stringify(a)}:${e(t[a])}`);return`{${a.join(",")}}`}return JSON.stringify(t)??"undefined"}(e.payload??null)}`}catch{return`${e.topic}:${e.event}:${a}`}}(s),l=a(),o=r.get(n);if(o&&l-o.startedAt<t){let t=await o.outcome.catch(e=>({success:!1,error:e instanceof Error?e.message:"Unknown error"}));return s.localId&&s.localId!==o.localId&&eh(s,t,e.target),t}for(let[e,a]of r)l-a.startedAt>=t&&r.delete(e);let d=i(s);return r.set(n,{startedAt:l,localId:s.localId,outcome:d}),d}}}();function eg(e,t){(e.silent?console.debug:console.error)("[CommandHandler] Command execution failed:",{topic:e.topic,event:e.event,error:t})}e.s(["CommandHandler",0,function({closeCommandPalette:e}){let t=(0,ed.useRouter)(),{data:r}=(0,eu.useSession)(),{currentCustomerId:s}=(0,eo.useCustomer)(),i=(0,a.useCallback)(()=>s||r?.user?.customerId,[s,r?.user?.customerId]),n=async e=>{let t=!1;try{var a;let s=e.payload?.type==="unassign",n={userId:e.payload?.userId||r?.user?.id,userName:e.payload?.userName||r?.user?.name||"System",userAvatar:e.payload?.userAvatar||r?.user?.image},l={...e,payload:{...e.payload,customerId:e.payload?.customerId||i(),userId:n.userId,userName:n.userName,userAvatar:n.userAvatar,...s?{}:{userId:e.payload?.userId||r?.user?.id},itemId:e.payload?.itemId,metadata:{...e.payload?.metadata,customerId:e.payload?.customerId||i(),userId:n.userId,userName:n.userName,userAvatar:n.userAvatar,threadId:e.payload?.metadata?.threadId,messageThreadI
24d:e.payload?.metadata?.messageThreadId,itemId:e.payload?.itemId}}},o="notifications"===e.topic?"/api/notifications":"/api/commands",d=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:l})}),c=await d.json();return a={success:c.success,data:c.data,error:c.error,operatorMessage:c.operatorMessage??c.data?.operatorMessage,code:c.code},eh(e,a),t=!0,c.success||eg(e,c.error||`${e.topic} action failed`),c}catch(r){let a=r instanceof Error?r.message:"Unknown error";return eg(e,a),t||eh(e,{success:!1,data:null,error:a}),{success:!1,error:a,data:null}}},l=async a=>{if(!a.detail||!a.detail.topic)return void console.error("[CommandHandler] Invalid command structure:",a.detail);let{type:r,url:s}=a.detail;await ex.run(a.detail,async a=>{if(e?.(),"direct"===r&&s)return t.push(s),{success:!0};let i=await n(a);return{success:i.success,data:i.data,error:i.error,operatorMessage:i.operatorMessage??i.data?.operatorMessage,code:i.code}})},o=e=>{var t;let a;a={type:"direct",topic:"dashboard",event:"items.complete"===(t=e.detail.action).event?"items.restore":"item.complete"===t.event?"item.restore":"item.remove_reminder",payload:"items.complete"===t.event?{ids:t.payload.ids,updates:{isActive:!0},originalItems:t.payload.originalItems,customerId:i()}:{id:t.payload.id,customerId:i(),updates:"item.reminder"===t.event?{reminder:null}:{isActive:!0}}},window.dispatchEvent(new CustomEvent("command:execute",{detail:a}))};return(0,a.useEffect)(()=>{let e=e=>{l(e)};return window.addEventListener("command:execute",e),window.addEventListener("dashboard:undo",o),()=>{window.removeEventListener("command:execute",e),window.removeEventListener("dashboard:undo",o)}},[e]),null}],796780)},120697,e=>{"use strict";e.s(["DashboardModal",()=>ea],120697);var t=e.i(843476),a=e.i(885071),r=e.i(271645),s=e.i(79222),i=e.i(232676),n=e.i(63237),l=e.i(875789),o=e.i(321814),d=e.i(374326),c=e.i(569687),m=e.i(361115),u=e.i(699346),h=e.i(510087),x=e.i(217255),g=e.i(133820),p=e.i(567847),b=e.i(88653),f=e.i(846932),y=e.i(374009),w=e.i(147361),v=e.i(436930),k=e.i(908263);let j=()=>(0,t.jsx)("div",{className:"absolute inset-0",children:(0,t.jsx)("div",{className:"relative w-full h-full overflow-hidden",children:(0,t.jsx)(f.motion.div,{className:"absolute inset-0 -translate-x-full",animate:{translateX:["0%","100%"]},transition:{duration:1.5,repeat:1/0,ease:"linear"},style:{background:"linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent)"}})})});function N({className:e}){return(0,t.jsxs)("div",{className:(0,k.cn)("flex flex-col h-full",e),children:[(0,t.jsx)("div",{className:"flex-none flex items-center justify-between px-4 py-3 border-b border-gray-200 dark:border-white/[0.08]",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"w-10 h-10 rounded-xl bg-gray-100 dark:bg-white/[0.08] relative overflow-hidden",children:(0,t.jsx)(j,{})}),(0,t.jsx)("div",{className:"h-6 w-48 bg-gray-100 dark:bg-white/[0.08] rounded-md relative overflow-hidden",children:(0,t.jsx)(j,{})})]})}),(0,t.jsx)("div",{className:"flex-none p-4 border-b border-gray-200 dark:border-white/[0.08]",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-4",children:[(0,t.jsx)("div",{className:"flex -space-x-2",children:[void 0,void 0,void 0].map((e,a)=>(0,t.jsx)("div",{className:"w-8 h-8 rounded-full bg-gray-100 dark:bg-white/[0.08] border-2 border-[#1D1D1F] relative overflow-hidden",children:(0,t.jsx)(j,{})},a))}),(0,t.jsx)("div",{className:"h-5 w-24 bg-gray-100 dark:bg-white/[0.08] rounded-full relative overflow-hidden",children:(0,t.jsx)(j,{})})]}),(0,t.jsx)("div",{className:"h-8 w-28 bg-gray-100 dark:bg-white/[0.08] rounded-lg relative overflow-hidden",children:(0,t.jsx)(j,{})})]})}),(0,t.jsx)("div",{className:"flex-none px-4 py-3 border-b border-gray-200 dark:border-white/[0.08]",children:(0,t.jsx)("div",{className:"flex gap-2",children:[void 0,void 0,void 0,void 0].map((e,a)=>(0,t.jsx)("div",{className:"h-8 w-24 bg-gray-100 dark:bg-white/[0.08] rounded-full relative overflow-hidden",children:(0,t.jsx)(j,{})},a))})}),(0,t.jsxs)("div",{className:"flex-1 flex min-h-0",children:[(0,t.jsx)("div",{className:"hidden lg:block flex-none w-[70px] bg-gray-50 dark:bg-[#18181A] border-r border-gray-200 dark:border-white/[0.08] p-3",children:(0,t.jsx)("div",{className:"flex flex-col items-center gap-2",children:[void 0,void 0].map((e,a)=>(0,t.jsx)("div",{className:"w-full h-10 rounded-xl bg-gray-100 dark:bg-white/[0.08] relative overflow-hidden",children:(0,t.jsx)(j,{})},a))})}),(0,t.jsx)("div",{className:"flex-1 p-4 overflow-y-auto",children:(0,t.jsx)("div",{className:"space-y-4",children:[void 0,void 0,void 0,void 0,void 0].map((e,a)=>(0,t.jsxs)("div",{className:"flex gap-4",children:[(0,t.jsx)("div",{className:"flex-none w-2 h-2 mt-2 rounded-full bg-gray-100 dark:bg-white/[0.08] relative overflow-hidden",children:(0,t.jsx)(j,{})}),(0,t.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,t.jsx)("div",{className:"h-4 w-32 bg-gray-100 dark:bg-white/[0.08] rounded relative overflow-hidden",children:(0,t.jsx)(j,{})}),(0,t.jsx)("div",{className:"h-20 bg-gray-100 dark:bg-white/[0.08] rounded-lg relative overflow-hidden",children:(0,t.jsx)(j,{})})]})]},a))})}),(0,t.jsx)("div",{className:"hidden lg:block flex-none w-[400px] bg-gray-50 dark:bg-[#18181A] border-l border-gray-200 dark:border-white/[0.08] p-4",children:(0,t.jsx)("div",{className:"space-y-4",children:[void 0,void 0,void 0,void 0].map((e,a)=>(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("div",{className:"h-4 w-24 bg-gray-100 dark:bg-white/[0.08] rounded relative overflow-hidden",children:(0,t.jsx)(j,{})}),(0,t.jsx)("div",{className:"h-16 bg-gray-100 dark:bg-white/[0.08] rounded-lg relative overflow-hidden",children:(0,t.jsx)(j,{})})]},a))})})]})]})}var C=e.i(531278),S=e.i(555436),E=e.i(284614),I=e.i(694351),T=e.i(87316),_=e.i(37727),A=e.i(643531);let D="https://api.vanio.ai";function P({dashboardItemId:e,initialQuery:a="",onLinked:s,onClose:i,isDark:n=!0}){let[l,o]=(0,r.useState)("guest"),[d,c]=(0,r.useState)(a),[m,u]=(0,r.useState)([]),[h,x]=(0,r.useState)(!1),[g,p]=(0,r.useState)(!1),[b,f]=(0,r.useState)(null),[y,w]=(0,r.useState)(null),v=(0,r.useCallback)(async(e,t)=>{if(e.trim().length<2)return void u([]);x(!0),f(null);try{let a=[];if("guest"===t){let t=await fetch(`${D}/search/guests?q=${encodeURIComponent(e)}`,{credentials:"include"}),r=await t.json();a=(r?.guests||r?.results||[]).slice(0,20).map(e=>
24({id:Number(e.id),label:[e.firstName,e.lastName].filter(Boolean).join(" ")||e.name?.first||`Guest #${e.id}`,sub:e.email||e.phone||void 0}))}else if("owner"===t){let t=await fetch(`${D}/owners?search=${encodeURIComponent(e)}&limit=20`,{credentials:"include"}),r=await t.json();a=(r?.owners||r?.results||[]).slice(0,20).map(e=>({id:Number(e.id),label:[e.firstName,e.lastName].filter(Boolean).join(" ")||e.companyName||`Owner #${e.id}`,sub:e.primaryEmail||e.companyName||void 0}))}else{let t=await fetch(`${D}/search/reservations?q=${encodeURIComponent(e)}`,{credentials:"include"}),r=await t.json();a=(r?.results||[]).slice(0,20).map(e=>({id:Number(e.id),label:`${e.guestName||"Guest"} â ${e.listingName||"Listing"}`,sub:`${e.confirmationCode||""} \xb7 ${e.checkIn?.slice(0,10)||""}`}))}u(a)}catch(e){f(e?.message||"search failed")}x(!1)},[]);(0,r.useEffect)(()=>{let e=setTimeout(()=>v(d,l),250);return()=>clearTimeout(e)},[d,l,v]);let j=async()=>{if(y){p(!0),f(null);try{let t=await fetch(`${D}/dashboard-items/${e}/link`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:l,targetId:y})}),a=await t.json();if(!t.ok||!a.ok)throw Error(a.error||"link failed");s({targetDashboardItemId:a.targetDashboardItemId,targetThreadId:a.targetThreadId})}catch(e){f(e?.message||"link failed")}p(!1)}};return(0,t.jsx)("div",{className:"fixed inset-0 z-[170] flex items-center justify-center bg-black/60 p-4",onClick:i,children:(0,t.jsxs)("div",{className:(0,k.cn)("w-full max-w-lg rounded-xl border shadow-xl",n?"bg-[#141414] border-white/[0.1]":"bg-white border-gray-200"),onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)("div",{className:(0,k.cn)("flex items-center justify-between px-4 py-3 border-b",n?"border-white/[0.08]":"border-gray-200"),children:[(0,t.jsx)("h3",{className:(0,k.cn)("text-sm font-semibold",n?"text-white":"text-gray-900"),children:"Link to existing entity"}),(0,t.jsx)("button",{onClick:i,className:n?"text-white/40 hover:text-white/70":"text-gray-400 hover:text-gray-700",children:(0,t.jsx)(_.X,{className:"w-4 h-4"})})]}),(0,t.jsx)("div",{className:(0,k.cn)("flex gap-1 p-2 border-b",n?"border-white/[0.08] bg-white/[0.02]":"border-gray-200 bg-gray-50"),children:["guest","owner","reservation"].map(e=>(0,t.jsxs)("button",{onClick:()=>{o(e),w(null)},className:(0,k.cn)("flex-1 text-xs font-semibold px-3 py-2 rounded-md flex items-center justify-center gap-1.5 transition-colors",l===e?"bg-emerald-500 text-white":n?"text-white/60 hover:text-white/90":"text-gray-600 hover:text-gray-900"),children:["guest"===e&&(0,t.jsx)(E.User,{className:"w-3.5 h-3.5"}),"owner"===e&&(0,t.jsx)(I.Home,{className:"w-3.5 h-3.5"}),"reservation"===e&&(0,t.jsx)(T.Calendar,{className:"w-3.5 h-3.5"}),e.charAt(0).toUpperCase()+e.slice(1)]},e))}),(0,t.jsxs)("div",{className:"p-4 space-y-3",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(S.Search,{className:(0,k.cn)("absolute left-3 top-2.5 w-4 h-4",n?"text-white/40":"text-gray-400")}),(0,t.jsx)("input",{autoFocus:!0,value:d,onChange:e=>c(e.target.value),placeholder:`Search ${l}s by name${"reservation"===l?" or confirmation code":""}â¦`,className:(0,k.cn)("w-full pl-9 pr-3 py-2 rounded-lg text-sm border outline-none",n?"bg-white/[0.04] border-white/[0.08] text-white placeholder:text-white/25 focus:border-emerald-500/40":"bg-gray-50 border-gray-200 text-gray-900 placeholder:text-gray-400 focus:border-emerald-500/40")})]}),(0,t.jsx)("div",{className:(0,k.cn)("max-h-64 overflow-y-auto rounded-lg border",n?"border-white/[0.06]":"border-gray-200"),style:{overscrollBehavior:"contain"},children:h?(0,t.jsx)("div",{className:"p-4 text-center",children:(0,t.jsx)(C.Loader2,{className:"w-4 h-4 animate-spin mx-auto"})}):0===m.length?(0,t.jsx)("div",{className:(0,k.cn)("p-4 text-center text-xs",n?"text-white/40":"text-gray-500"),children:d.trim().length<2?"Type at least 2 characters":"No matches"}):m.map(e=>(0,t.jsxs)("button",{onClick:()=>w(e.id),className:(0,k.cn)("w-full text-left px-3 py-2 border-b flex items-center gap-2 transition-colors",n?"border-white/[0.04] hover:bg-white/[0.04]":"border-gray-100 hover:bg-gray-50",y===e.id&&(n?"bg-emerald-500/10":"bg-emerald-50")),children:[(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("div",{className:(0,k.cn)("text-sm font-medium truncate",n?"text-white":"text-gray-900"),children:e.label}),e.sub&&(0,t.jsx)("div",{className:(0,k.cn)("text-[11px] truncate",n?"text-white/40":"text-gray-500"),children:e.sub})]}),y===e.id&&(0,t.jsx)(A.Check,{className:"w-4 h-4 text-emerald-500 flex-shrink-0"})]},e.id))}),b&&(0,t.jsx)("div",{className:"text-xs text-red-400",children:b}),(0,t.jsxs)("div",{className:"flex items-center gap-2 pt-2",children:[(0,t.jsx)("button",{onClick:i,className:(0,k.cn)("text-xs px-3 py-2 rounded-lg",n?"text-white/60 hover:bg-white/[0.04]":"text-gray-600 hover:bg-gray-100"),children:"Cancel"}),(0,t.jsx)("div",{className:"flex-1"}),(0,t.jsxs)("button",{onClick:j,disabled:!y||g,className:"text-xs flex items-center gap-1 px-3 py-2 rounded-lg bg-emerald-500 hover:bg-emerald-400 text-white font-semibold disabled:opacity-40",children:[g?(0,t.jsx)(C.Loader2,{className:"w-3 h-3 animate-spin"}):(0,t.jsx)(A.Check,{className:"w-3 h-3"}),"Link"]})]}),(0,t.jsx)("p",{className:(0,k.cn)("text-[10px]",n?"text-white/30":"text-gray-400"),children:"Messages move to the target's thread and this sender will auto-resolve on every future inbound."})]})]})})}var R=e.i(158524),M=e.i(546118);let F={telegram:{primary:"#229ED9",soft:"#229ED91A",label:"Telegram"},viber:{primary:"#7360F2",soft:"#7360F21A",label:"Viber"},messenger:{primary:"#0084FF",soft:"#0084FF1A",label:"Messenger"},instagram:{primary:"#E1306C",soft:"#E1306C1A",label:"Instagram"},whatsapp:{primary:"#3FB567",soft:"#3FB5671A",label:"WhatsApp"}};function L({channel:e,fromName:a,fromExternalId:r,onLink:s,isDark:i=!0,alreadyMerged:n=!1}){let l=F[e]||F.telegram,o=a?.trim()||r||"Unknown sender",d=(o[0]||"?").toUpperCase();return(0,t.jsxs)("div",{className:(0,k.cn)("flex-none flex items-center gap-3 px-5 py-4 border-b",i?"border-white/[0.08]":"border-gray-200"),style:{background:`linear-gradient(90deg, ${l.soft}, transparent)`},children:[(0,t.jsx)("div",{className:"w-11 h-11 rounded-full flex items-center justify-center flex-shrink-0 text-base font-semibold text-white",style:{backgroundColor:l.primary},"aria-hidden":"true",children:d}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("div",{className:(0,k.cn)("text-sm font-semibold truncate",i?"text-white":"text-gray-900"),children:o}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 mt-0.5",children:[(0,t.jsx)(M.BrandChannelIcon,{channel:e,size:11}),(0,t.jsx)("span",{className:"text-[11px] font-medium",style:{color:l.primary},children:l.label}),r&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:(0,k.cn)("text-[11px]",i?"text-white/30":"text-gray-400"),children:"·"}),(0,t.jsx)("span",{className:(0,k.cn)("text-[11px] font-mono truncate",i?"text-white/40":"text-gray-500"),children:r})]})]})]}),!n&&(0,t.jsxs)("button",{onClick:s,className:"text-xs font-semibold px-3 py-1.5 rounded-lg text-white flex items-center gap-1.5 flex-shrink-0 transition-opacity hover:opacity-90",style:{backgroundColor:l.primary},children:[(0,t.jsx)(R.Link2,{className:"w-3 h-3"}),"Link toâ¦"]})]})}var $=e.i(655900),O=e.i(664659),U=e.i(98919),B=e.i(178583),q=e.i(194983),z=e.i(620278),H=e.i(248256),V=e.i(514764),G=e.i(560491),W=e.i(212865),K=e.i(58147),Y=e.i(816933),J=e.i(367193);let Q=e=>fetch(e,{credentials:"include"}).then(e=>e.json());function X({threadId:e,customerId:a,dashboardItemId:s,listingName:i,isDark:n=!0}){let[l,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)(null),[m,u]=(0,r.useState)({}),h="https://api.vanio.ai",{data:x,error:g}=(0,G.default)(e?`${h}/ai-decisions?customerId=${a}&threadId=${e}&status=pending`:null,Q,{refreshInterval:1e4}),{data:p}=(0,G.default)(e&&l?`${h}/ai-decisions?customerId=${a}&threadId=${e}
24`:null,Q),y=x?.decisions||[],w=(p?.decisions||[]).filter(e=>"pending"!==e.status),v=[...new Set(y.map(e=>e.category))],{data:j}=(0,G.default)(v.length>0?`${h}/ai-decisions?customerId=${a}&recommend=${v[0]}`:null,Q),N=j?.recommendation;(0,r.useEffect)(()=>{y.length&&S(e=>{let t={...e};for(let e of y){let a=e.actionPayload?.completedActions;Array.isArray(a)&&a.length>0&&!t[e.id]?.length&&(t[e.id]=a)}return t})},[y]),(0,r.useEffect)(()=>{let e=()=>o(!1);return window.addEventListener("ai-drawer:collapse",e),()=>window.removeEventListener("ai-drawer:collapse",e)},[]),(0,r.useEffect)(()=>{y.length>0&&!l&&o(!0)},[y.length]);let[C,S]=(0,r.useState)(()=>{let e={};for(let t of x?.decisions||[]){let a=t.actionPayload?.completedActions;Array.isArray(a)&&a.length>0&&(e[t.id]=a)}return e}),E=(0,r.useCallback)(async(e,t,a)=>{c(`${e}:${t}`);try{await fetch(`${h}/ai-decisions/${e}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({chosenOption:t,actionPayload:a})}),await fetch(`${h}/ai-decisions/${e}/execute`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:t})}),S(a=>({...a,[e]:[...a[e]||[],t]}))}catch(e){console.error("[AIDrawer] Failed to execute action:",e)}finally{c(null)}},[h]),I=(0,r.useCallback)(async t=>{let r=C[t]||[];if(0===r.length)return void await T(t);await fetch(`${h}/ai-decisions/${t}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"close",chosenOption:r.join("+")})}).catch(()=>{});try{let t=await fetch(`${h}/chat/dashboard/${e}?limit=10`,{credentials:"include"}),a="Please respond to the guest with the updated policy.";if(t.ok){let e=await t.json(),r=e.messages||e;if(Array.isArray(r)){let e=e=>["guest","cotraveler","booker"].includes(String(e||"").toLowerCase()),t=[...r].reverse().find(t=>"user"===t.role||e(t.sender_type)||e(t.senderType));t&&(a=t.content||t.message||a)}}window.dispatchEvent(new CustomEvent("vanio:regenerate",{detail:{threadId:Number(e),query:a,source:"guest_message"}}))}catch(e){console.error("[AIDrawer] Failed to trigger regenerate:",e)}(0,W.mutate)(`${h}/ai-decisions?customerId=${a}&threadId=${e}&status=pending`),(0,W.mutate)(`${h}/ai-decisions?customerId=${a}&threadId=${e}`),o(!1)},[h,a,e,C,y]),T=(0,r.useCallback)(async t=>{c(`${t}:dismiss`);try{await fetch(`${h}/ai-decisions/${t}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"dismiss"})}),(0,W.mutate)(`${h}/ai-decisions?customerId=${a}&threadId=${e}&status=pending`)}catch(e){console.error("[AIDrawer] Failed to dismiss:",e)}finally{c(null)}},[h,a,e]);if(0===y.length&&!l)return null;let _={missing_policy:"No policy exists for this scenario",judgment_call:"I need your strategic call",unknown_preference:"I don't know your preference here",capability_gap:"This needs a human to act",pattern_detected:"I noticed a pattern worth flagging",proactive_suggestion:"I have a suggestion"},A={draft_policy:B.FileText,defend:U.Shield,action:z.Target,chat:q.MessageCircle};return(0,t.jsxs)("div",{"data-ai-drawer":"true",className:(0,k.cn)("flex-none border-t",n?"border-white/[0.08] bg-[#1C1C1E]":"border-gray-200 bg-white"),children:[(0,t.jsxs)("button",{onClick:()=>o(!l),className:(0,k.cn)("w-full flex items-center justify-between px-4 py-2.5 text-sm font-medium transition-colors",n?"text-white/80 hover:bg-white/[0.04]":"text-gray-700 hover:bg-gray-50"),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("img",{src:"/Vanio.ai.png",alt:"Vanio",className:"w-5 h-5 rounded-full"}),(0,t.jsx)("span",{children:y.length>0?`I need your input (${y.length})`:"Vanio AI"}),y.length>0&&(0,t.jsx)("span",{className:"w-2 h-2 rounded-full bg-orange-500 animate-pulse"})]}),l?(0,t.jsx)(O.ChevronDown,{className:"w-4 h-4"}):(0,t.jsx)($.ChevronUp,{className:"w-4 h-4"})]}),(0,t.jsx)(b.AnimatePresence,{children:l&&(0,t.jsx)(f.motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:"overflow-hidden",children:(0,t.jsxs)("div",{className:(0,k.cn)("max-h-[50vh] overflow-y-auto px-4 pb-4 space-y-3",n?"scrollbar-dark":""),children:[y.map(r=>
24(0,t.jsx)(Z,{decision:r,isDark:n,executingKey:d,categoryLabels:_,optionIcons:A,actionInput:m[r.id]||"",onActionInputChange:e=>u(t=>({...t,[r.id]:e})),onResolve:E,onDismiss:T,onClose:I,completedActions:C[r.id]||[],threadId:e,customerId:a,recommendation:N},r.id)),0===y.length&&(0,t.jsx)("div",{className:(0,k.cn)("text-center py-6 text-sm",n?"text-white/40":"text-gray-400"),children:"No pending decisions. All caught up."}),w.length>0&&(0,t.jsxs)("div",{className:(0,k.cn)("border-t pt-3 mt-3",n?"border-white/[0.06]":"border-gray-100"),children:[(0,t.jsx)("p",{className:(0,k.cn)("text-xs font-medium mb-2",n?"text-white/40":"text-gray-400"),children:"Past Decisions"}),w.slice(0,5).map(e=>(0,t.jsxs)("div",{className:(0,k.cn)("text-xs py-1.5 flex items-center gap-2",n?"text-white/50":"text-gray-500"),children:[(0,t.jsx)("span",{className:(0,k.cn)("inline-flex px-1.5 py-0.5 rounded text-[10px] font-medium","defend"===e.chosenOption?"bg-red-500/10 text-red-400":"draft_policy"===e.chosenOption?"bg-blue-500/10 text-blue-400":"bg-white/[0.06] text-white/50"),children:e.chosenOption}),(0,t.jsxs)("span",{className:"truncate",children:[e.situation.slice(0,80),"..."]}),(0,t.jsxs)("span",{className:"flex-none text-[10px]",children:[new Date(e.createdAt).toLocaleDateString()," ",new Date(e.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]})]},e.id))]})]})})})]})}function Z({decision:e,isDark:a,executingKey:s,categoryLabels:i,optionIcons:n,actionInput:l,onActionInputChange:o,onResolve:d,onDismiss:c,onClose:m,completedActions:u,threadId:h,customerId:x,recommendation:g}){let[p,b]=(0,r.useState)(!1),f=e.options.find(e=>"draft_policy"===e.id),[y,w]=(0,r.useState)(f?.payload?.title||""),[v,j]=(0,r.useState)(f?.payload?.content||""),[N,S]=(0,r.useState)(f?.payload?.appliesTo?.listings||[]),[E,I]=(0,r.useState)(f?.payload?.appliesTo?.groups||[]),[T,_]=(0,r.useState)(!1),[A,D]=(0,r.useState)(""),[P,R]=(0,r.useState)(!1),[M,F]=(0,r.useState)(!1),[L,$]=(0,r.useState)(!1),[O,U]=(0,r.useState)(!1),B=(e.draftReply||"").trim();(0,r.useEffect)(()=>{T||N.length>0||E.length>0||(e.listingId?fetch(`https://api.vanio.ai/listings/groups/by-listing?listingId=${e.listingId}`,{credentials:"include"}).then(e=>e.ok?e.json():null).then(t=>{let a=t?.groups||(Array.isArray(t)?t:[]);a.length>0?I(a.map(e=>e.id||e)):S([e.listingId])}).catch(()=>{e.listingId&&S([e.listingId])}).finally(()=>_(!0)):_(!0))},[e.listingId]);let q=g&&g.confidence>=.8&&g.confidence<.95&&0===u.length,[H,G]=(0,r.useState)(!1);return(0,t.jsxs)("div",{className:(0,k.cn)("rounded-xl border p-4",a?"border-white/[0.08] bg-white/[0.02]":"border-gray-200 bg-gray-50"),children:[(0,t.jsxs)("div",{className:"mb-3",children:[(0,t.jsx)("p",{className:(0,k.cn)("text-xs font-medium uppercase tracking-wider mb-1",a?"text-orange-400/80":"text-orange-600"),children:"Why I'm here"}),(0,t.jsx)("p",{className:(0,k.cn)("text-xs",a?"text-white/50":"text-gray-500"),children:i[e.category]||e.category}),(0,t.jsx)("p",{className:(0,k.cn)("text-sm mt-1",a?"text-white/80":"text-gray-700"),children:e.situation})]}),e.guestSentiment&&"neutral"!==e.guestSentiment&&(0,t.jsxs)("div",{className:(0,k.cn)("inline-flex items-center gap-1.5 text-xs px-2 py-1 rounded-full mb-3","threatening"===e.guestSentiment?"bg-red-500/10 text-red-400":"angry"===e.guestSentiment?"bg-orange-500/10 text-orange-400":"bg-yellow-500/10 text-yellow-400"),children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-current"}),"Guest sentiment: ",e.guestSentiment]}),B&&!p&&!M&&(0,t.jsxs)("div",{className:(0,k.cn)("rounded-lg border p-3 mb-3",a?"border-green-500/20 bg-green-500/[0.04]":"border-green-200 bg-green-50"),children:[(0,t.jsx)("p",{className:(0,k.cn)("text-xs font-medium uppercase tracking-wider mb-1",a?"text-green-400/80":"text-green-600"),children:"Vanio AI's held-back reply"}),(0,t.jsx)("p",{className:(0,k.cn)("text-xs leading-relaxed mb-2 whitespace-pre-wrap line-clamp-4",a?"text-white/70":"text-gray-600"),children:B}),(0,t.jsxs)("button",{onClick:()=>{if(B&&!O){U(!0);try{window.dispatchEvent(new CustomEvent("composer:insert-content",{detail:{content:B,switchToGuestChannel:!0}})),d(e.id,"send_draft",{draftReply:B}),window.dispatchEvent(new CustomEvent("ai-drawer:collapse"))}finally{U(!1)}}},disabled:O,className:(0,k.cn)("w-full py-2 rounded-md text-sm font-medium transition-colors flex items-center justify-center gap-1.5",O&&"opacity-60 cursor-not-allowed",a?"bg-green-500/10 text-green-400 hover:bg-green-500/20 border border-green-500/20":"bg-green-600 text-white hover:bg-green-700"),children:[O?(0,t.jsx)(C.Loader2,{className:"w-3.5 h-3.5 animate-spin"}):(0,t.jsx)(V.Send,{className:"w-3.5 h-3.5"}),"Send AI draft"]})]}),p&&(0,t.jsx)(ee,{isDark:a,isExecuting:s===`${e.id}:draft_policy`,policyTitle:y,setPolicyTitle:w,policyContent:v,setPolicyContent:j,selectedListings:N,setSelectedListings:S,selectedGroups:E,setSelectedGroups:I,refineInput:A,setRefineInput:D,isRefining:P,setIsRefining:R,customerId:e.customerId,situation:e.situation,onSave:async()=>{await d(e.id,"draft_policy",{title:y,content:v,category:f?.payload?.category||"Policies",tags:f?.payload?.tags||["policy"],appliesTo:{listings:N.map(Number),groups:E}}),b(!1)},onBack:()=>b(!1)}),q&&!H&&!p&&!M&&g&&(0,t.jsxs)("div",{className:(0,k.cn)("rounded-lg border p-3 mb-3",a?"border-orange-500/20 bg-orange-500/[0.04]":"border-orange-200 bg-orange-50"),children:[(0,t.jsxs)("p",{className:(0,k.cn)("text-xs mb-2",a?"text-white/50":"text-gray-500"),children:["Based on your past ",g.total," decisions (",(100*g.confidence).toFixed(0),"% match):"]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("button",{onClick:()=>{d(e.id,g.option),"defend"===g.option&&window.dispatchEvent(new CustomEvent("ai-drawer:collapse"))},disabled:!!s,className:(0,k.cn)("flex-1 py-2 rounded-lg text-sm font-medium text-center transition-colors","defend"===g.option?a?"bg-red-500/10 text-red-400 hover:bg-red-500/20 border border-red-500/20":"bg-red-50 text-red-700 hover:bg-red-100 border border-red-200":a?"bg-orange-500/10 text-orange-400 hover:bg-orange-500/20 border border-orange-500/20":"bg-orange-50 text-orange-700 hover:bg-orange-100 border border-orange-200"),children:[s?(0,t.jsx)(C.Loader2,{className:"w-4 h-4 animate-spin inline mr-1"}):null,{defend:"Activate Defend Mode",draft_policy:"Draft a Policy",action:"Give Specific Instru
24ction",chat:"Chat About This"}[g.option]||g.option]}),(0,t.jsx)("button",{onClick:()=>G(!0),className:(0,k.cn)("px-3 py-2 rounded-lg text-xs transition-colors",a?"text-white/40 hover:text-white/60 hover:bg-white/[0.04]":"text-gray-500 hover:text-gray-700 hover:bg-gray-100"),children:"Change"})]})]}),M&&(0,t.jsx)(et,{threadId:h,customerId:x,situation:e.situation,isDark:a,onClose:()=>{F(!1),u.includes("chat")||d(e.id,"chat")}}),!p&&!M&&(!q||H)&&(0,t.jsx)("div",{className:"space-y-2",children:e.options.map(r=>{let i=n[r.id]||z.Target,c="defend"===r.id,m="action"===r.id,x="draft_policy"===r.id,p="chat"===r.id,f=u.includes(r.id),y=s===`${e.id}:${r.id}`,w=!!s,v=g?.option===r.id&&g.confidence>=.6;return(0,t.jsx)("div",{className:(0,k.cn)("rounded-lg border p-3 transition-colors",f&&"opacity-60",a?(0,k.cn)("border-white/[0.06]",c&&!f?"hover:border-red-500/30 hover:bg-red-500/[0.04]":f?"":"hover:border-white/[0.12] hover:bg-white/[0.03]"):(0,k.cn)("border-gray-200",c&&!f?"hover:border-red-300 hover:bg-red-50":f?"":"hover:border-gray-300 hover:bg-white")),children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("div",{className:(0,k.cn)("flex-none w-8 h-8 rounded-lg flex items-center justify-center text-sm",c?"bg-red-500/10 text-red-400":a?"bg-white/[0.06] text-white/60":"bg-gray-100 text-gray-500"),children:r.icon||(0,t.jsx)(i,{className:"w-4 h-4"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("p",{className:(0,k.cn)("text-sm font-medium",c?"text-red-400":a?"text-white/90":"text-gray-800"),children:r.label}),v&&!f&&(0,t.jsx)("span",{className:(0,k.cn)("text-[10px] px-1.5 py-0.5 rounded-full font-medium",a?"bg-orange-500/10 text-orange-400":"bg-orange-100 text-orange-600"),children:"You usually pick this"})]}),(0,t.jsxs)("p",{className:(0,k.cn)("text-xs mt-0.5",a?"text-white/50":"text-gray-500"),children:[r.description,c&&(0,t.jsx)("a",{href:"https://www.vanio.ai/docs/defend-mode",target:"_blank",rel:"noopener noreferrer",className:(0,k.cn)("ml-1",a?"text-white/30 hover:text-white/50":"text-gray-400 hover:text-gray-600"),children:"Learn more"})]}),m&&!f&&(0,t.jsxs)("div",{className:"mt-2 flex gap-2",children:[(0,t.jsx)("input",{type:"text",value:l,onChange:e=>o(e.target.value),onKeyDown:t=>{"Enter"===t.key&&l.trim()&&!w&&(d(e.id,"action",{instruction:l}),window.dispatchEvent(new CustomEvent("vanio:regenerate",{detail:{threadId:Number(h),query:l,source:"internal_chat"}})),window.dispatchEvent(new CustomEvent("ai-drawer:collapse")))},placeholder:"e.g. Ask cleaner to bring extra towels",className:(0,k.cn)("flex-1 text-xs px-2.5 py-1.5 rounded-md border outline-none",a?"bg-white/[0.05] border-white/[0.08] text-white/80 placeholder:text-white/30":"bg-white border-gray-200 text-gray-800 placeholder:text-gray-400")}),(0,t.jsx)("button",{onClick:()=>{d(e.id,"action",{instruction:l}),window.dispatchEvent(new CustomEvent("vanio:regenerate",{detail:{threadId:Number(h),query:l,source:"internal_chat"}})),window.dispatchEvent(new CustomEvent("ai-drawer:collapse"))},disabled:w||!l.trim(),className:(0,k.cn)("flex-none px-3 py-1.5 rounded-md text-xs font-medium transition-colors",a?"bg-white/[0.08] text-white/80 hover:bg-white/[0.12] disabled:opacity-40":"bg-gray-200 text-gray-700 hover:bg-gray-300 disabled:opacity-40"),children:y?(0,t.jsx)(C.Loader2,{className:"w-3 h-3 animate-spin"}):"Go"})]}),x&&!f&&(0,t.jsx)("button",{onClick:()=>b(!0),className:(0,k.cn)("mt-2 px-3 py-1.5 rounded-md text-xs font-medium transition-colors",a?"bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 border border-blue-500/20":"bg-blue-100 text-blue-700 hover:bg-blue-200"),children:"Draft a Policy"}),x&&f&&(0,t.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,t.jsx)("span",{className:(0,k.cn)("text-xs font-medium",a?"text-green-400":"text-green-600"),children:"â Created"}),(0,t.jsx)("button",{onClick:()=>b(!0),className:(0,k.cn)("px-2 py-1 rounded text-[11px] transition-colors",a?"text-white/50 hover:text-white/70 hover:bg-white/[0.06]":"text-gray-500 hover:text-gray-700 hover:bg-gray-100"),children:"Edit"})]}),f&&!x&&(0,t.jsx)("p",{className:(0,k.cn)("mt-2 text-xs font-medium",a?"text-green-400":"text-green-600"),children:"â Done"}),p&&(0,t.jsx)("button",{onClick:()=>F(!0),className:(0,k.cn)("mt-2 px-3 py-1.5 rounded-md text-xs font-medium transition-colors",f?a?"bg-green-500/10 text-green-400 hover:bg-green-500/20 border border-green-500/20":"bg-green-100 text-green-700 hover:bg-green-200":a?"bg-white/[0.08] text-white/70 hover:bg-white/[0.12]":"bg-gray-200 text-gray-600 hover:bg-gray-300"),children:f?"â Continue Chat":"Chat About This"}),!m&&!x&&!p&&!f&&(0,t.jsxs)("button",{onClick:()=>d(e.id,r.id,r.payload),disabled:w,className:(0,k.cn)("mt-2 px-3 py-1.5 rounded-md text-xs font-medium transition-colors",c?"bg-red-500/10 text-red-400 hover:bg-red-500/20 border border-red-500/20":a?"bg-white/[0.08] text-white/70 hover:bg-white/[0.12]":"bg-gray-200 text-gray-600 hover:bg-gray-300",w&&"opacity-50 cursor-not-allowed"),children:[y?(0,t.jsx)(C.Loader2,{className:"w-3 h-3 animate-spin inline mr-1"}):null,c?"Activate Defend Mode":r.label]})]})]})},r.id)})}),u.length>0&&(0,t.jsx)("div",{className:"mt-3 flex items-center gap-1.5 flex-wrap",children:u.map(e=>(0,t.jsxs)("span",{className:(0,k.cn)("inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-medium","defend"===e?"bg-red-500/10 text-red-400":"draft_policy"===e?"bg-blue-500/10 text-blue-400":a?"bg-green-500/10 text-green-400":"bg-green-100 text-green-700"),children:["â ","draft_policy"===e?"Policy created":"defend"===e?"Defend on":"chat"===e?"Discu
24ssed":e]},e))}),(0,t.jsx)("div",{className:"mt-3",children:u.length>0?(0,t.jsx)("button",{onClick:async()=>{L||($(!0),await m(e.id))},disabled:L,className:(0,k.cn)("w-full py-2.5 rounded-lg text-sm font-medium text-center transition-colors flex items-center justify-center gap-2",L&&"opacity-60 cursor-not-allowed",a?"bg-green-500/10 text-green-400 hover:bg-green-500/20 border border-green-500/20":"bg-green-50 text-green-700 hover:bg-green-100 border border-green-200"),children:L?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(C.Loader2,{className:"w-4 h-4 animate-spin"})," Generating new reply..."]}):"All done â close this"}):(0,t.jsx)("button",{onClick:()=>c(e.id),disabled:!!s,className:(0,k.cn)("w-full py-2 rounded-lg text-xs text-center transition-colors",a?"text-white/30 hover:text-white/50 hover:bg-white/[0.03]":"text-gray-400 hover:text-gray-600 hover:bg-gray-50"),children:"Dismiss"})})]})}function ee({isDark:e,isExecuting:a,policyTitle:r,setPolicyTitle:s,policyContent:i,setPolicyContent:n,selectedListings:l,setSelectedListings:o,selectedGroups:d,setSelectedGroups:c,refineInput:m,setRefineInput:u,isRefining:h,setIsRefining:x,customerId:g,situation:p,onSave:b,onBack:f}){let y=async()=>{if(m.trim()&&!h){x(!0);try{let e=await fetch(`https://api.vanio.ai/kb/media/refine-article?customerId=${g}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:r,category:"Policies",content:i,instruction:m,format:"plain"})});if(!e.ok)throw Error("Refine failed");let t=await e.json();t.title&&s(t.title),t.content&&n(t.content),u("")}catch(e){console.error("[PolicyDraft] Refine error:",e)}finally{x(!1)}}},w=l.length+d.length;return(0,t.jsxs)("div",{className:(0,k.cn)("rounded-lg border p-4 mb-3 space-y-3",e?"border-blue-500/20 bg-blue-500/[0.04]":"border-blue-200 bg-blue-50"),children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(B.FileText,{className:"w-4 h-4 text-blue-400"}),(0,t.jsx)("p",{className:(0,k.cn)("text-sm font-medium",e?"text-blue-400":"text-blue-600"),children:"Draft Policy"})]}),(0,t.jsxs)(Y.Popover,{children:[(0,t.jsx)(Y.PopoverTrigger,{asChild:!0,children:(0,t.jsx)("button",{className:(0,k.cn)("flex items-center gap-1 h-[26px] px-2 rounded text-xs font-medium transition-colors",0===w?"bg-blue-500/10 text-blue-400 hover:bg-blue-500/20":e?"bg-white/10 text-white/80 hover:bg-white/15":"bg-gray-200 text-gray-700 hover:bg-gray-300"),children:0===w?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(H.Globe,{className:"h-3.5 w-3.5"})," Global"]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(U.Shield,{className:"h-3.5 w-3.5"}),d.length?`${d.length} group${d.length>1?"s":""}`:"",d.length&&l.length?", ":"",l.length?`${l.length} listing${l.length>1?"s":""}`:""]})})}),(0,t.jsx)(Y.PopoverContent,{className:(0,k.cn)("w-80 p-3 z-[200]",e?"bg-[#1D1D1F] border-white/[0.08]":"bg-white border-gray-200"),align:"end",children:(0,t.jsx)(K.ListingScopeSelector,{customerId:g,selectedIds:l,selectedGroupIds:d,scopeMode:"include",onChangeIds:o,onChangeGroupIds:c,onChangeScopeMode:()=>{},hideScopeToggle:!0,hideLabel:!0})})]})]}),(0,t.jsx)("input",{type:"text",value:r,onChange:e=>s(e.target.value),placeholder:"Policy title",className:(0,k.cn)("w-full text-sm px-3 py-2 rounded-md border outline-none font-medium",e?"bg-white/[0.05] border-white/[0.08] text-white/90 placeholder:text-white/30":"bg-white border-gray-200 text-gray-800 placeholder:text-gray-400")}),(0,t.jsx)("textarea",{value:i,onChange:e=>n(e.target.value),rows:8,placeholder:"Policy content â what should the AI know and follow?",className:(0,k.cn)("w-full text-xs px-3 py-2 rounded-md border outline-none resize-y leading-relaxed",e?"bg-white/[0.05] border-white/[0.08] text-white/80 placeholder:text-white/30":"bg-white border-gray-200 text-gray-800 placeholder:text-gray-400")}),(0,t.jsxs)("div",{className:(0,k.cn)("flex items-center gap-2 rounded-md border px-2.5 py-1.5",e?"border-white/[0.08] bg-white/[0.03]":"border-gray-200 bg-white"),children:[(0,t.jsx)("img",{src:"/Vanio.ai.png",alt:"
24Vanio",className:"w-4 h-4 flex-none rounded-full"}),(0,t.jsx)("input",{type:"text",value:m,onChange:e=>u(e.target.value),onKeyDown:e=>"Enter"===e.key&&y(),placeholder:'Instruct Vanio: e.g. "Make it firmer" or "Add pricing in EUR too"',disabled:h,className:(0,k.cn)("flex-1 text-xs bg-transparent outline-none",e?"text-white/80 placeholder:text-white/30":"text-gray-800 placeholder:text-gray-400")}),(0,t.jsx)("button",{onClick:y,disabled:h||!m.trim(),className:(0,k.cn)("flex-none p-1 rounded transition-colors",e?"text-purple-400 hover:bg-purple-500/10 disabled:opacity-30":"text-purple-500 hover:bg-purple-50 disabled:opacity-30"),children:h?(0,t.jsx)(C.Loader2,{className:"w-3.5 h-3.5 animate-spin"}):(0,t.jsx)(V.Send,{className:"w-3.5 h-3.5"})})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsxs)("button",{onClick:b,disabled:a||!r.trim()||!i.trim(),className:(0,k.cn)("px-4 py-2 rounded-md text-xs font-medium transition-colors",e?"bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 border border-blue-500/20 disabled:opacity-40":"bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-40"),children:[a?(0,t.jsx)(C.Loader2,{className:"w-3 h-3 animate-spin inline mr-1"}):null,"Approve & Create KB Article"]}),(0,t.jsx)("button",{onClick:f,className:(0,k.cn)("px-3 py-2 rounded-md text-xs transition-colors",e?"text-white/40 hover:text-white/60":"text-gray-400 hover:text-gray-600"),children:"Back"})]})]})}function et({threadId:e,customerId:a,situation:s,isDark:i,onClose:n}){let[l,o]=(0,r.useState)([{role:"assistant",text:s}]),[d,c]=(0,r.useState)(""),[m,u]=(0,r.useState)(!1),h=(0,r.useRef)(null);(0,r.useEffect)(()=>{h.current?.scrollTo({top:h.current.scrollHeight,behavior:"smooth"})},[l]);let x=async()=>{let t=d.trim();if(t&&!m){c(""),o(e=>[...e,{role:"user",text:t}]),u(!0);try{let a=await fetch(`https://api.vanio.ai/chat/dashboard/${e}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:t,source:"internal_chat"})});if(!a.ok){let e=await a.text();o(t=>[...t,{role:"assistant",text:(0,J.describeChatFailure)(e,`Error: ${e}`)}]);return}let r=a.body?.getReader();if(!r)return;let s="";o(e=>[...e,{role:"assistant",text:""}]);let i=new TextDecoder,n="";for(;;){let{done:e,value:t}=await r.read();if(e)break;let a=(n+=i.decode(t,{stream:!0})).split("\n");for(let e of(n=a.pop()||"",a))if(e.startsWith("data: "))try{let t=JSON.parse(e.slice(6));"text-delta"===t.type&&t.delta?(s+=t.delta,o(e=>{let t=[...e];return t[t.length-1]={role:"assistant",text:s},t})):"vanio-final"===t.type&&"string"==typeof t.text&&(s=t.text,o(e=>{let t=[...e];return t[t.length-1]={role:"assistant",text:s},t}))}catch{}}}catch(e){o(t=>[...t,{role:"assistant",text:`Failed to reach Vanio AI: ${e.message}`}])}finally{u(!1)}}};return(0,t.jsxs)("div",{className:(0,k.cn)("rounded-lg border mb-3 overflow-hidden flex flex-col",i?"border-white/[0.08]":"border-gray-200"),children:[(0,t.jsxs)("div",{className:(0,k.cn)("flex items-center justify-between px-3 py-2 border-b flex-none",i?"border-white/[0.06]":"border-gray-100"),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("img",{src:"/Vanio.ai.png",alt:"Vanio",className:"w-4 h-4 rounded-full"}),(0,t.jsx)("span",{className:(0,k.cn)("text-xs font-medium",i?"text-white/70":"text-gray-600"),children:"Chat with Vanio AI"})]}),(0,t.jsx)("button",{onClick:n,className:(0,k.cn)("p-1 rounded",i?"text-white/30 hover:text-white/60":"text-gray-400 hover:text-gray-600"),children:(0,t.jsx)(_.X,{className:"w-3.5 h-3.5"})})]}),(0,t.jsx)("div",{ref:h,className:(0,k.cn)("flex-1 overflow-y-auto px-3 py-2 space-y-3 max-h-[300px] min-h-[150px]"),children:l.map((e,a)=>(0,t.jsxs)("div",{className:(0,k.cn)("flex gap-2","user"===e.role&&"flex-row-reverse"),children:["assistant"===e.role&&(0,t.jsx)("img",{src:"/Vanio.ai.png",alt:"",className:"w-5 h-5 rounded-full flex-none mt-0.5"}),(0,t.jsx)("div",{className:(0,k.cn)("text-xs leading-relaxed rounded-lg px-3 py-2 max-w-[85%]","user"===e.role?i?"bg-blue-500/20 text-blue-100":"bg-blue-100 text-blue-900":i?"bg-white/[0.04] text-white/80":"bg-gray-50 text-gray-700"),children:e.text||(m&&a===l.length-1?(0,t.jsx)(C.Loader2,{className:"w-3 h-3 animate-spin"}):null)})]},a))}),(0,t.jsxs)("div",{className:(0,k.cn)("flex items-center gap-2 px-3 py-2 border-t flex-none",i?"border-white/[0.06]":"border-gray-100"),children:[(0,t.jsx)("input",{type:"text",value:d,onChange:e=>c(e.target.value),onKeyDown:e=>"Enter"===e.key&&!e.shiftKey&&x(),placeholder:"Ask Vanio AI...",disabled:m,className:(0,k.cn)("flex-1 text-xs bg-transparent outline-none",i?"text-white/80 placeholder:text-white/30":"text-gray-800 placeholder:text-gray-400")}),(0,t.jsx)("button",{onClick:x,disabled:m||!d.trim(),className:(0,k.cn)("flex-none p-1.5 rounded transition-colors",i?"text-white/50 hover:bg-white/[0.06] disabled:opacity-30":"text-gray-500 hover:bg-gray-100 disabled:opacity-30"),children:m?(0,t.jsx)(C.Loader2,{className:"w-3.5 h-3.5 animate-spin"}):(0,t.jsx)(V.Send,{className:"w-3.5 h-3.5"})})]})]})}function ea(){let e,{modalTouchStart:k,modalTouchEnd:j,modalDragStartTime:C,resetAllTouchStates:S,isDragging:E,isPulling:I,x:T}=(0,v.useTouchState)(),{data:_}=(0,x.useSession)(),{currentCustomerId:A,users:D}=(0,g.useCustomer)(),R=new URLSearchParams(window.location.search).get("tab"),[M,F]=(0,r.useState)(!1),[$,O]=(0,r.useState)("lifecycle"===R?"lifecycle":"lab"===R?"lab":"all"),[U,B]=(0,r.useState)("all"),[q,z]=(0,r.useState)(!1),{currentItem:H,setCurrentItem:V,items:G,setItems:W,modalOpen:K,closeModal:Y,navigateNext:J,navigatePrevious:Q,hasNext:Z,hasPrevious:ee,handleItemAction:et,isItemProcessing:ea,error:er}=(0,i.useDashboard)(),{activeViewers:es,typingUsers:ei,assignedTo:en,handleUserPresence:el,handleTypingStatus:eo}=(0,n.useRealtimePresence)("dashboard-item",H?.id),{setCommandPaletteContext:ed,openCommandPalette:ec}=(0,p.useCommandPalette)(),em=H?.sourceType==="email.inbound"||H?.sourceType==="email.outbound"||H?.source_type==="email.inbound"||H?.source_type==="email.outbound",eu=H?.type==="owner"||H?.ownerId!=null,eh=(e=H?.sourceType||H?.source_type||"",/^(telegram|viber|messenger|instagram|whatsapp)\.inbound$/.test(e)?e:null),ex=eh?eh.replace(".inbou
24nd",""):null,eg=H?.status==="merged",ep=!!ex&&!eg,[eb,ef]=(0,r.useState)(!1),ey=(0,r.useRef)(null),ew=(0,r.useRef)([]),ev=(0,r.useRef)(null),ek=(0,r.useCallback)((e,t,a)=>{if(!A||!H?.id)return;let r={userId:_?.user?.id,userName:_?.user?.name,userAvatar:_?.user?.image,userRole:"user"};window.dispatchEvent(new CustomEvent("command:execute",{detail:{type:"direct",topic:e.split(".")[0],event:e,...a?.silent?{silent:!0}:{},payload:{...t,itemId:H.id,customerId:A,...!t.__preventSessionUserOverride?r:{},..."dashboard.assign"===e&&"group"===t.type&&{groupName:t.metadata?.groupName,groupSlug:t.metadata?.groupSlug},metadata:{...H?.metadata,...t.metadata,customerId:A,...r}}}}))},[H,_,A]),ej=(0,r.useCallback)(()=>{document.body.setAttribute("data-blocking-shortcuts","true"),Y(),setTimeout(()=>{document.body.removeAttribute("data-blocking-shortcuts")},100)},[Y]);(0,r.useEffect)(()=>{let e=e=>{"modal.close"===e.type&&(e.preventDefault(),e.stopPropagation(),ej())};return window.addEventListener("modal.close",e),()=>{window.removeEventListener("modal.close",e)}},[ej]);let eN=(0,r.useCallback)((0,y.default)((e,t)=>{e?.id&&t?.user?.id&&ey.current!==e.id.toString()&&ek("dashboard.read",{id:e.id,customerId:e.customerId,metadata:{type:e.type,status:e.status,customerId:A,userName:t.user.name,userAvatar:t.user.image}},{silent:!0})},5e3),[ek,A]);(0,r.useEffect)(()=>{if(!H||!_?.user)return;let e=!document.hidden,t=()=>{e=!document.hidden,ev.current&&(clearTimeout(ev.current),ev.current=null),e?ey.current!==H.id.toString()&&(ev.current=setTimeout(()=>{eN(H,_)},3e3)):eN.cancel()};return document.addEventListener("visibilitychange",t),e&&ey.current!==H.id.toString()&&(ev.current=setTimeout(()=>{eN(H,_)},3e3)),()=>{document.removeEventListener("visibilitychange",t),ev.current&&(clearTimeout(ev.current),ev.current=null),eN.cancel()}},[H?.id,_,eN]),(0,r.useEffect)(()=>{K&&H||(ey.current=null,ew.current=[],ev.current&&(clearTimeout(ev.current),ev.current=null),eN.cancel())},[K,H?.id,eN]);let eC=(0,r.useCallback)(()=>{if(!H?.id)return void console.log("[DashboardModal] Cannot open command palette - missing item ID");let e=H.timelines?.events?.data||[],t=(0,a.findPendingAlteration)(e),r=!!t&&(0,a.awaitsHostResponse)(t),s={context:"reservation",itemId:H.id,metadata:{...H.metadata,type:H.type,status:H.status,hasPendingAlteration:r}};ed(s),ec(s)},[H,ed,ec]),eS=(0,r.useRef)(0),eE=(0,r.useRef)(0),eI=(0,r.useCallback)(e=>{e.target instanceof Element&&(e.target.closest("[data-tooltip]")||e.target.closest('[role="tooltip"]')||e.target.closest('[role="dialog"]')||e.target.closest('[role="alertdialog"]'))||e.target instanceof Element&&(e.target.closest('[data-composer="timeline"]')||e.target.closest(".timeline-composer")||e.target.closest('[role="textbox"]')||e.target.closest("[data-ai-drawer]")||e.target.closest("button"))||k.current>0||E.current||I.current||e.touches[0].clientX>=.7*window.innerWidth&&(eS.current=e.touches[0].clientX,C.current=Date.now())},[]),eT=(0,r.useCallback)(e=>{e.target instanceof Element&&(e.target.closest("[data-tooltip]")||e.target.closest('[role="tooltip"]')||e.target.closest('[role="dialog"]')||e.target.closest('[role="alertdialog"]'))||e.target instanceof Element&&(e.target.closest('[data-composer="timeline"]')||e.target.closest(".timeline-composer")||e.target.closest('[role="textbox"]')||e.target.closest("[data-ai-drawer]")||e.target.closest("button"))||!(k.current>0)&&eS.current>0&&(eE.current=e.touches[0].clientX,eS.current-eE.current>20&&e.stopPropagation())},[]),e_=(0,r.useCallback)(e=>{if(!(e.target instanceof Element&&(e.target.closest('[role="dialog"]')||e.target.closest('[role="alertdialog"]')||e.target.closest('[data-composer="timeline"]')||e.target.closest(".timeline-composer")||e.target.closest('[role="textbox"]')||e.target.closest("[data-ai-drawer]")||e.target.closest("button")))&&!(k.current>0)){if(eS.current>0){let e=eS.current-eE.current,t=Date.now()-C.current;e>50&&t>50&&t<500&&Math.abs(eS.current-eE.current)>30&&z(!0)}eS.current=0,eE.current=0,C.current=0}},[]),eA=(0,r.useMemo)(()=>{if(!H?.timelines)return{messages:{guest:0,internal:0,system:0,total:0},events:{reservation:0,review:0,payment:0,activity:0,total:0},tasks:{completed:0,pending:0,critical:0,high:0,normal:0,low:0,total:0},automations:{failed:0,pending:0,completed:0,total:0},issues:{open:0,inProgress:0,resolved:0,total:0},all:0};let e=H.timelines.messages?.data||[],t=H.timelines.events?.data||[],a=[...H.timelines.issues?.data||[],...t.filter(e=>"issue"===e.type)],r={open:a.filter(e=>e.data?.status==="open").length,inProgress:a.filter(e=>e.data?.status==="in_progress").length,resolved:a.filter(e=>e.data?.status==="resolved").length,total:a.length},s={guest:e.filter(e=>"guest_message"===e.type).length,internal:e.filter(e=>"internal_message"===e.type).length,system:e.filter(e=>"system_note"===e.type).length,total:e.length},i={reservation:t.filter(e=>"reservation"===e.type).length,review:t.filter(e=>"review"===e.type).length,payment:t.filter(e=>"payment"===e.type).length,activity:t.filter(e=>"activity"===e.type).length,total:t.filter(e=>!["task","automation","issue"].includes(e.type)).length},n=t.filter(e=>"task"===e.type),l={completed:n.filter(e=>e.data?.status==="completed").length,pending:n.filter(e=>e.data?.status==="pending").length,critical:n.filter(e=>e.data?.priority==="critical").length,high:n.filter(e=>e.data?.priority==="high").length,normal:n.filter(e=>e.data?.priority==="normal").length,low:n.filter(e=>e.data?.priority==="low").length,total:n.length},o=t.filter(e=>"automation"===e.type),d={failed:o.filter(e=>e.data?.status==="failed").length,pending:o.filter(e=>e.data?.status==="pending").length,completed:o.filter(e=>e.data?.status==="completed").length,total:o.length},c=s.total+i.total+l.total+d.total+r.total;return{messages:s,events:i,tasks:l,automations:d,issues:r,all:c}},[H?.timelines]);(0,r.useEffect)(()=>{K?(F(!0),(async()=>{try{F(!1)}catch(e){F(!1)}}
24)()):(F(!1),S())},[K,S]);let eD=(0,r.useRef)(null);(0,r.useEffect)(()=>{if(K&&eD.current)return eD.current,()=>{document.body.style.overflow=""}},[K,E,I,q,k,j,C]),(0,r.useEffect)(()=>{K||(z(!1),S())},[K,S]);let[eP,eR]=(0,r.useState)(!1),eM=(0,r.useCallback)((e="complete")=>{H?.id&&et(e,H.id,{fromModal:!0,onSuccess:()=>{"complete"===e&&ej()}})},[H,et,ej]),eF=(0,r.useCallback)(e=>{switch(e.type){case"message.react":case"message.unreact":case"message.edit":case"message.unsend":ek(e.type,{...e.payload,metadata:{...e.payload.metadata,customerId:A,type:H?.type,status:H?.status}});break;case"message.guest.preapproval":ek("message.guest.preapproval",{channel:"airbnb",inquiryId:e.payload.inquiryId,blockInstantBooking:e.payload.blockInstantBooking||!1,metadata:{airbnbThreadId:H?.metadata?.reservation?.platform?.platformThreadId||H?.metadata?.airbnbThreadId||H?.threadId,threadId:H?.metadata?.airbnbThreadId||H?.threadId,host:{id:H?.metadata?.host?.id||""},customerId:A}});break;case"message.guest.withdraw_preapproval":ek("message.guest.withdraw_preapproval",{channel:"vrbo",inquiryId:e.payload.inquiryId,metadata:{threadId:H?.metadata?.airbnbThreadId||H?.threadId,customerId:A}});break;case"message.guest.special_offer":if(e.payload?.vrboQuote){ek("message.guest.special_offer",{channel:"vrbo",inquiryId:e.payload.inquiryId,vrboQuote:e.payload.vrboQuote,message:e.payload.message,metadata:{threadId:H?.metadata?.airbnbThreadId||H?.threadId,customerId:A}});break}if(!H?.metadata?.reservation?.platform?.platformThreadId)return void console.error("[DashboardModal] Missing platformThreadId for special offer");ek("message.guest.special_offer",{channel:"airbnb",inquiryId:e.payload.inquiryId,metadata:{airbnbThreadId:H.metadata.reservation.platform.platformThreadId,threadId:H.metadata.airbnbThreadId,host:H.metadata.host?.id,customerId:A,type:H.type,status:H.status}});break;case"reply":break;default:ek(e.type,e.payload)}},[ek,A,H]),eL=(0,r.useCallback)(e=>{if(!H)return;let t={...H};if("unassigned"===e.type)return void ek("dashboard.assign",{type:"unassign",id:t.id,__preventSessionUserOverride:!0,assignedBy:_?.user?.id,assignedByName:_?.user?.name,assignedByAvatar:_?.user?.image,metadata:{...t.metadata,type:t.type,status:t.status,action:"unassign",assignment:null}});if("system"===e.type)return void ek("dashboard.assign",{userId:"SYSTEM",userName:"Vanio AI",userAvatar:"/Vanio.ai.png",type:"system",id:t.id,__preventSessionUserOverride:!0,assignedBy:_?.user?.id,assignedByName:_?.user?.name,assignedByAvatar:_?.user?.image,metadata:{...t.metadata,type:t.type,status:t.status,action:"system_assign",assignedBy:_?.user?.id,assignedByName:_?.user?.name}});if("group"===e.type){let a=e.groupId,r=D.groups.find(e=>e.id===a);return r?void ek("dashboard.assign",{groupId:r.id,groupName:r.name,groupSlug:r.slug,type:"group",id:t.id,assignedBy:_?.user?.id,assignedByName:_?.user?.name,assignedByAvatar:_?.user?.image}):void console.error("[DashboardModal] Group not found:",a)}if("user"===e.type){let a=e.userId,r=D.users.find(e=>e.id===a);if(!r)return void console.error("[DashboardModal] User not found:",a);ek("dashboard.assign",{userId:r.id,userName:r.name,userAvatar:r.image,assignedBy:_?.user?.id,assignedByName:_?.user?.name,assignedByAvatar:_?.user?.image,type:"user",id:t.id,__preventSessionUserOverride:!0,metadata:{...t.metadata,type:t.type,status:t.status,action:"user_assign"}})}},[H,D,ek,_]);(0,r.useEffect)(()=>{if(!H?.id)return;let e=e=>{let{command:t,result:a}=e.detail;if("dashboard"===t.topic&&"dashboard.assign"===t.event&&t.payload.id===H.id&&a?.success&&a?.data?.item){let e=a.data.item;V(e),W(t=>t.map(t=>Number(t.id)===Number(e.id)?e:t))}};return window.addEventListener("command:result",e),()=>{window.removeEventListener("command:result",e)}},[H?.id,V,W]),(0,r.useEffect)(()=>{if(!H?.id)return;let e=async e=>{let{command:t,result:a}=e.detail;if(t?.topic==="seam"&&a?.success)try{let e=await fetch(`/api/dashboard/item?id=${H.id}`);if(!e.ok)return;let{item:t}=await e.json();if(!t)return;V(t),W(e=>e.map(e=>Number(e.id)===Number(t.id)?t:e))}catch{}};return window.addEventListener("command:result",e),()=>{window.removeEventListener("command:result",e)}},[H?.id,V,W]);let e$=(0,r.useRef)(null);return((0,r.useEffect)(()=>{let e=!1,t=()=>{if(e)return;let t=new URLSearchParams(window.location.search),a=t.get("messageId"),r=t.get("action");a&&"highlight"===r&&(e=!0,setTimeout(()=>{window.dispatchEvent(new CustomEvent("highlight-message",{detail:{messageId:a}}))},500))};t();let a=()=>{e=!1,t()};return window.addEventListener("popstate",a),()=>{window.removeEventListener("popstate",a)}},[]),(0,r.useEffect)(()=>{let e=e=>{e.detail?.type==="commands"&&e.detail?.initialCommand&&(eC(),setTimeout(()=>{let t=document.querySelector(`[data-command-id="${e.detail.initialCommand}"]`);if(t||(t=document.querySelector(`[data-command-type="${e.detail.initialCommand}"]`)),!t){let a="reservation.cancel.internal"===e.detail.initialCommand?"Cancel Reservation":e.detail.initialCommand.split(".").pop();for(let e of document.querySelectorAll("[cmdk-item]"))if(e.textContent?.includes(a)){t=e;break}}t?t.click():e.detail.autoExecute&&window.dispatchEvent(new CustomEvent("command-select",{detail:{command:{id:e.detail.initialCommand,type:e.detail.initialCommand.split(".")[0]||"reservation",name:"reservation.cancel.internal"===e.detail.initialCommand?"Cancel Reservation":e.detail.initialCommand,configuration:{type:e.detail.initialCommand}}}}))},300))};return window.addEventListener("modal:open",e),()=>{window.removeEventListener("modal:open",e)}},[eC]),er)?(0,t.jsx)(s.BaseModal,{isOpen:K,onCloseAction:"modal.close",showCloseButton:!0,children:(0,t.jsx)(h.ErrorDisplay,{error:er,className:"min-h-[400px]"})}):M||!H?(0,t.jsx)(s.BaseModal,{isOpen:K,onCloseAction:"modal.close",showCloseButton:!0,children:(0,t.jsx)(N,{})}):(0,t.jsxs)(s.BaseModal,{isOpen:K,onCloseAction:"modal.close",widthClass:ep?"lg:w-[680px]":void 0,showNavigation:!0,hasNext:Z,hasPrevious:ee,dashboardItemId:H?.id?Number(H.id):void 0,onNextAction:()=>{J()},onPreviousAction:()=>{Q()},title:H?em?H.title||H.metadata?.subject||"Email":eu?H.title||"Owner":`${H.metadata?.listing?.name?.split("·")[0].trim()||H.title||"Conversation"}${H.metadata?.reservation?.confirmationCode?`: ${H.metadata.reservation.confirmationCode}`:""}`:void 0,children:[eP||!H?(0,t.jsxs)("div",{className:"flex flex-col h-full",children:[(0,t.jsx)("div",{className:"flex-none",children:(0,t.jsx)(l.CollaborationHeader,{isItemLo
24ading:!0,assignedTo:null,activeViewers:[],typingUsers:[],priority:"medium",customerId:"",onAssign:()=>{},onPriorityChange:()=>{}})}),(0,t.jsx)(N,{})]}):(0,t.jsxs)("div",{ref:eD,className:"flex flex-col h-full",children:[ex&&(0,t.jsx)(L,{channel:ex,fromName:H?.metadata?.fromName||null,fromExternalId:H?.metadata?.fromExternalId||null,onLink:()=>ef(!0),isDark:!0,alreadyMerged:eg}),(0,t.jsx)("div",{className:"flex-none",children:(0,t.jsx)(l.CollaborationHeader,{assignedTo:en,activeViewers:es,typingUsers:ei,priority:H?.priority||"medium",customerId:A||"",currentAssignee:H?.assignment?{id:"group"===H.assignment.type?H.assignment.groupId:H.assignment.userId,name:"group"===H.assignment.type?H.assignment.groupName:H.assignment.userName,avatar:"group"===H.assignment.type?H.assignment.assignedByAvatar:H.assignment.avatar}:void 0,onAssign:eL,onPriorityChange:e=>{ek("dashboard.priority",{priority:e,id:H?.id,customerId:A,metadata:{type:H?.type,status:H?.status,customerId:A}})},isActive:H?.is_active??!0,onItemStatus:eM,onReminder:()=>{H?.id&&(ed({type:"reminder",itemId:H.id,placeholder:"When to remind? (8am, 3d, aug 7, mon...)"}),ec({type:"reminder",itemId:H.id,placeholder:"When to remind? (8am, 3d, aug 7, mon...)"}))},onCommand:eC,currentItem:H?{id:H.id,metadata:H.metadata,type:H.type,status:H.status}:void 0,isItemLoading:eP||ea(H?.id),readHistory:H?.interactions?.filter(e=>"read"===e.type&&e.isActive)?.map(e=>({userId:e.userId,userName:e.userName||"Unknown",avatar:e.userAvatar||void 0,readAt:e.createdAt||""}))||[]})}),eb&&H?.id&&(0,t.jsx)(P,{dashboardItemId:Number(H.id),initialQuery:H.metadata?.fromName||"",onClose:()=>ef(!1),onLinked:e=>{ef(!1),e.targetDashboardItemId&&window.dispatchEvent(new CustomEvent("modal:open",{detail:{itemId:e.targetDashboardItemId}}))}}),(0,t.jsx)("div",{className:"flex-none isolate",children:(0,t.jsx)(w.DashboardModalFilters,{activeFilter:$,onFilterChange:e=>{O(e);let t=new URL(window.location.href);"lifecycle"===e||"lab"===e?t.searchParams.set("tab",e):t.searchParams.delete("tab"),window.history.replaceState({},"",t.toString())},counts:eA,lifecycleActionFilter:U,onLifecycleActionFilterChange:B})}),(0,t.jsxs)("div",{className:"flex flex-1 min-h-0",onClick:()=>z(!1),children:[(0,t.jsxs)("div",{className:"flex-1 min-w-0 relative flex flex-col",children:[(0,t.jsx)("div",{className:"flex-1 overflow-y-auto",ref:e$,onTouchStart:eI,onTouchMove:eT,onTouchEnd:e_,children:"lab"===$&&H?(0,t.jsx)(c.AILabPanel,{reservationId:H?.metadata?.reservation?.id,listingId:H?.metadata?.listing?.id||H?.metadata?.listingId,customerId:A||H?.metadata?.listing?.customerId,threadId:H?.thread_id||H?.threadId,guestName:H?.metadata?.reservation?.guestName||H?.metadata?.guestName||H?.details?.guest?.name||H?.guest_name,listingName:H?.metadata?.listing?.name||H?.metadata?.listingName},`lab-${H?.id}`):"lifecycle"===$&&H?.metadata?.reservation?.id?(0,t.jsx)(d.LifecycleTimeline,{reservationId:H.metadata.reservation.id,customerId:A||H.metadata.listing?.customerId,actionTypeFilter:U,className:"h-full overflow-y-auto"},`lifecycle-${H?.id}`):(0,t.jsx)(o.UnifiedTimeline,{data:H,isLoading:M,onAction:eF,onTyping:eo,onCommandPaletteOpen:eC,className:"h-full",itemId:H?.id?.toString()||"",threadId:H?.thread_id||H?.threadId,userId:_?.user?.id||"",customerId:A?.toString()||"",activeFilter:$,onItemStatus:eM,isActive:H?.is_active??!0,typingUsers:ei,currentAssignment:H?.assignment,currentUserId:_?.user?.id},`timeline-${H?.id}`)}),(H?.thread_id||H?.threadId)&&A&&(0,t.jsx)(X,{threadId:H.thread_id||H.threadId,customerId:A.toString(),dashboardItemId:"number"==typeof H.id?H.id:Number(H.id),listingName:H?.metadata?.listing?.name||H?.metadata?.listingName})]}),!em&&!ep&&(0,t.jsx)("button",{className:"fixed right-0 top-1/2 -translate-y-1/2 lg:hidden z-10",onClick:e=>{e.stopPropagation(),z(!0)},children:(0,t.jsx)("div",{className:"bg-gray-100 dark:bg-white/[0.08] rounded-l-lg py-12 px-1 flex items-center",children:(0,t.jsx)("div",{className:"w-1 h-12 bg-gray-300 dark:bg-white/20 rounded-full"})})}),!em&&!ep&&(0,t.jsx)("div",{className:"hidden lg:block flex-none w-[400px] min-w-[320px] overflow-hidden",children:eu?(0,t.jsx)(u.OwnerSidebar,{data:H?.metadata,onAction:e=>ek(e.type,e.payload),itemId:H?.id?.toString()||""}):(0,t.jsx)(m.ReservationSidebar,{data:H?.metadata,onAction:e=>ek(e.type,e.payload),itemId:H?.id?.toString()||"",pendingAlteration:(0,a.findPendingAlteration)(H?.timelines?.events?.data)})})]})]}),(0,t.jsx)(b.AnimatePresence,{children:q&&!em&&!ep&&(0,t.jsxs)(f.motion.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",damping:30,stiffness:300},className:"fixed inset-y-0 right-0 w-[calc(100%-48px)] max-w-[500px] bg-gray-50 dark:bg-[#18181A] border-l border-gray-200 dark:border-white/[0.08] overflow-y-auto lg:hidden z-50",children:[(0,t.jsx)("button",{className:"absolute top-4 right-4 p-2 text-gray-400 dark:text-white/60 hover:text-gray-900 dark:hover:text-white",onClick:()=>z(!1),children:(0,t.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,t.jsx)("path",{d:"M18 6L6 18M6 6l12 12"})})}),eu?(0,t.jsx)(u.OwnerSidebar,{data:H?.metadata,onAction:e=>ek(e.type,e.payload)}):(0,t.jsx)(m.ReservationSidebar,{data:H?.metadata,onAction:e=>ek(e.type,e.payload),pendingAlteration:(0,a.findPendingAlteration)(H?.timelines?.events?.data)})]})})]})}},808548,978731,355390,819813,979357,376761,864218,232753,182189,349330,784070,451076,e=>{"use strict";var t=e.i(843476),a=e.i(271645),r=e.i(846932),s=e.i(88653),i=e.i(227516),n=e.i(37727),l=e.i(266027),o=e.i(719708),d=e.i(686311),c=e.i(87316),m=e.i(656272),u=e.i(503116),h=e.i(245423),x=e.i(878894),g=e.i(269638),p=e.i(63209),b=e.i(694351),f=e.i(125511),y=e.i(212426),w=e.i(643531),v=e.i(204997),k=e.i(292270),j=e.i(367240),N=e.i(663854),C=e.i(263488),S=e.i(284614),E=e.i(908263),I=e.i(232676),T=e.i(567847),_=e.i(542027),A=e.i(657688),D=e.i(618566),P=e.i(133820),R=e.i(217255),M=e.i(289562),F=e.i(436930),L=e.i(811998);d.MessageSquare,m.CheckSquare,f.Hotel,b.Home,h.Bell,x.AlertTriangle,g.CheckCircle,p.AlertCircle,r.motion.div;let $=(0,a.forwardRef)(({item:e,itemId:r,isSelected:s,selectedStyle:i="scale-[1.02]",filteredItems:n,isActive:l=!0,onItemClick:o},d)=>{var m;let h,x,g,p,f,$,U,B,q,{isDragging:z,isPulling:H}=(0,F.useTouchState)(),[V,G]=(0,a.useState)(!1);if((0,a.useRef)(0),!e)return console.warn("[DashboardItem] Missing item prop"),null;if(!r)return console.warn("[DashboardItem] Missing itemId prop"),null;let{setSelectedId:W,handleItemAction:K,isItemProcessing:Y,openModal:J,activeTab:Q,selectedId:X,modalOpen:Z}=(0,I.useDashboard)(),{openCommandPalette:ee,setCommandPaletteContext:et,isOpen:ea}=(0,T.useCommandPalette)(),{users:{users:er,groups:es},isLoadingUsers:ei}=(0,P.useCustomer)(),{data:en}=(0,R.useSession)(),{assignedUser:el,assignedBy:eo}=(0,a.useMemo)(()=>{let t=null,a=null;if(e.assignment){switch(e.assignment.type){case"group":let r=es?.find(t=>
24t.id===e.assignment.groupId);t={id:e.assignment.groupId,name:r?`@${r.name}`:"@Unknown Group",image:void 0};break;case"user":if("SYSTEM"===e.assignment.userId)t={name:"Vanio AI",image:"/favicon.ico",isSystem:!0};else{let a=er?.find(t=>t.id===e.assignment.userId);t=a?{name:a.name,image:a.image,isUser:!0,userId:a.id}:{name:e.assignment.userName,image:e.assignment.avatar,isUser:!0,userId:e.assignment.userId}}}if(e.assignment?.assignedBy){let t=er?.find(t=>t.id===e.assignment.assignedBy);a=t?{name:t.name,image:t.image,isUser:!0}:{name:e.assignment.assignedByName,image:"group"===e.assignment.type?e.assignment.assignedByAvatar:void 0}}}return{assignedUser:t,assignedBy:a}},[e.assignment,er,es]),ed=(0,a.useRef)(r),ec=(0,a.useRef)(s),em=(0,a.useRef)(!1),eu=(0,a.useRef)(!1);(0,a.useEffect)(()=>(eu.current=!0,()=>{eu.current=!1}),[]),(0,a.useEffect)(()=>{ed.current=r,ec.current=s},[r,s]);let eh=(0,a.useCallback)(e=>{if(e&&e.stopPropagation(),V||z.current)return;let t=l?"complete":"restore";if(e?.type==="click"&&!s){W(Number(r)),requestAnimationFrame(()=>{K(t,r)});return}K(t,r)},[r,l,s,W,K,V,z]);(0,a.useEffect)(()=>{if(!eu.current)return;let e=e=>{document.body.hasAttribute("data-blocking-shortcuts")||ea||e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement||e.metaKey||e.ctrlKey||ec.current&&Number(ed.current)===Number(X)&&("e"===e.key.toLowerCase()&&(e.preventDefault(),e.stopPropagation(),eh()),"h"===e.key.toLowerCase()&&(e.preventDefault(),e.stopPropagation(),et({type:"reminder",itemId:ed.current,placeholder:"When to remind? (8am, 3d, aug 7, mon...)"}),ee({type:"reminder",itemId:ed.current,placeholder:"When to remind? (8am, 3d, aug 7, mon...)"}
24)))};return window.addEventListener("keydown",e),em.current=!0,()=>{em.current&&(window.removeEventListener("keydown",e),em.current=!1)}},[r,s,X,ea,eh,ee,et]);let ex=e=>{e.stopPropagation(),et({type:"reminder",itemId:r,placeholder:"When to remind? (8am, 3d, aug 7, mon...)"}),ee({type:"reminder",itemId:r,placeholder:"When to remind? (8am, 3d, aug 7, mon...)"})},eg=(0,D.useSearchParams)();(0,a.useEffect)(()=>{window.__dashboardModalRegistry||(window.__dashboardModalRegistry={urlOpened:!1,urlItemId:null,openedAt:0,clickedItemId:null,clickedAt:0})},[]);let ep=(0,a.useCallback)(t=>{if((t.preventDefault(),t.stopPropagation(),!V&&!z.current)&&!Z){if("todo"===e.type&&("task"===e.sourceType||e.metadata?.taskId)){let t=e.metadata?.tasks?.tasks?.[0]?.id||e.metadata?.taskId||e.taskId;if(t){let e=new URL(window.location.href);e.searchParams.set("task",String(t)),window.history.pushState({},"",e.toString()),window.dispatchEvent(new PopStateEvent("popstate")),o?.();return}}J(Number(r),{fromClick:!0}),o?.()}},[V,z,r,Z,J,o,Q,e]);(0,a.useEffect)(()=>{if(!eg||Z)return;let t=eg.get("item");if(t&&(window.__openedFromClick,t===r)){let t=e.metadata?.taskId;if("todo"===e.type&&t){let e=new URL(window.location.href);e.searchParams.delete("item"),e.searchParams.set("task",String(t)),window.history.replaceState({},"",e.toString()),window.dispatchEvent(new PopStateEvent("popstate"));return}J(Number(r))}},[eg,r,Z,J,e]);let eb=(0,a.useMemo)(()=>!!en?.user?.id&&!!e.interactions&&e.interactions.some(e=>"read"===e.type&&e.userId===en.user.id&&e.isActive),[e.interactions,en?.user?.id]),ef=(0,a.useMemo)(()=>{let t,a,r;return t={checkIn:e.metadata?.reservation?.dates?.checkIn,checkOut:e.metadata?.reservation?.dates?.checkOut},a={checkIn:e.metadata?.reservation?.checkIn,checkOut:e.metadata?.reservation?.checkOut},r={checkIn:e.metadata?.data?.reservation?.dates?.checkIn,checkOut:e.metadata?.data?.reservation?.dates?.checkOut},t.checkIn?t:a.checkIn?a:r.checkIn?r:{checkIn:void 0,checkOut:void 0}},[e]),ey=(0,a.useMemo)(()=>{let t,a,r;return t={total:e.metadata?.reservation?.pricing?.totals?.hostPayout,currency:e.metadata?.reservation?.pricing?.totals?.currency},a={total:e.metadata?.reservation?.priceBreakdown?.total,currency:e.metadata?.reservation?.priceBreakdown?.currency},r={total:e.metadata?.reservation?.totalPrice,currency:e.metadata?.reservation?.currency},t.total?t:a.total?a:r.total?r:{total:void 0,currency:"USD"}},[e]),ew=e.status?.toLowerCase()==="support",ev=e.sourceType||e.source_type||null,ek="email.inbound"===ev||"email.outbound"===ev,ej="owner"===e.type||null!=e.ownerId||null!=e.owner_id,eN=($=ev?.match?.(/^(telegram|viber|messenger|instagram|whatsapp)\.inbound$/))?$[1]:null,eC=!!eN,eS=eN?({telegram:{primary:"#229ED9",label:"Telegram"},viber:{primary:"#7360F2",label:"Viber"},messenger:{primary:"#0084FF",label:"Messenger"},instagram:{primary:"#E1306C",label:"Instagram"},whatsapp:{primary:"#3FB567",label:"WhatsApp"}})[eN]:null,eE=e.metadata?.fromName,eI=e.metadata?.fromExternalId;return(0,t.jsx)("div",{className:"relative overflow-visible",children:(0,t.jsxs)("div",{ref:d,"data-item-id":r,style:{scale:s?1.02:1},onClick:ep,onKeyDown:t=>{if("Enter"===t.key){t.preventDefault();let a=e.metadata?.taskId;if("todo"===e.type&&a){let e=new URL(window.location.href);e.searchParams.set("task",String(a)),window.history.pushState({},"",e.toString()),window.dispatchEvent(new PopStateEvent("popstate"));return}J(Number(r))}},tabIndex:0,role:"button","aria-pressed":s,className:(0,E.cn)("relative group","rounded-2xl","bg-gray-100 dark:bg-white/[0.05] border border-gray-200 dark:border-white/[0.08]","supports-hover:hover:bg-gray-200 dark:supports-hover:hover:bg-white/[0.08]","transition-all duration-200","cursor-pointer",!eb&&["border-l-2 border-l-blue-500","bg-blue-950/30","supports-hover:hover:bg-blue-950/40"],s&&["ring-2 ring-gray-300 dark:ring-white/20","bg-gray-200 dark:bg-white/[0.08]","shadow-lg shadow-black/10","z-10"],Y(r)&&"opacity-50 pointer-events-none"),children:[(0,t.jsxs)("div",{className:(0,E.cn)("absolute right-4 top-4 flex items-center gap-2","opacity-0 supports-hover:group-hover:opacity-100","transition-opacity duration-200","z-20","supp
24orts-hover:flex hidden"),children:[(0,t.jsx)("button",{onClick:eh,className:"p-2 rounded-lg bg-gray-100 dark:bg-white/10 hover:bg-gray-200 dark:hover:bg-white/20 transition-colors",title:l?"Mark as Done":"Make Active",children:l?(0,t.jsx)(w.Check,{className:"w-4 h-4"}):(0,t.jsx)(j.RotateCcw,{className:"w-4 h-4"})}),(0,t.jsx)("button",{onClick:ex,className:"p-2 rounded-lg bg-gray-100 dark:bg-white/10 hover:bg-gray-200 dark:hover:bg-white/20 transition-colors",children:(0,t.jsx)(u.Clock,{className:"w-4 h-4"})}),(0,t.jsx)("button",{onClick:e=>{e.stopPropagation(),ex(e)},className:"p-2 rounded-lg bg-gray-100 dark:bg-white/10 hover:bg-gray-200 dark:hover:bg-white/20 transition-colors",children:(0,t.jsx)(A.default,{src:"/favicon.ico",alt:"Ask Vanio AI",width:16,height:16})})]}),(0,t.jsx)("div",{className:(0,E.cn)(eC?"px-3 py-2":"p-4"),children:(0,t.jsxs)("div",{className:(0,E.cn)("flex",eC?"gap-2.5 md:gap-3 items-center":"gap-3 md:gap-4"),children:[(0,t.jsx)("div",{className:(0,E.cn)("flex-none",eC?"w-9 md:w-10":ek||ej?"w-12 md:w-14":"w-24 md:w-32"),children:ej?(0,t.jsx)("div",{className:"w-10 h-10 md:w-12 md:h-12 rounded-xl bg-purple-500/10 dark:bg-purple-400/10 flex items-center justify-center mt-1",children:e.metadata?.owner?.avatarUrl?(0,t.jsx)(A.default,{src:e.metadata.owner.avatarUrl,alt:e.metadata?.owner?.firstName||"Owner",width:48,height:48,className:"w-full h-full rounded-xl object-cover"}):(0,t.jsx)(S.User,{className:"w-5 h-5 md:w-6 md:h-6 text-purple-500 dark:text-purple-400"})}):ek?(0,t.jsx)("div",{className:"w-10 h-10 md:w-12 md:h-12 rounded-xl bg-blue-500/10 dark:bg-blue-400/10 flex items-center justify-center mt-1",children:(0,t.jsx)(C.Mail,{className:"w-5 h-5 md:w-6 md:h-6 text-blue-500 dark:text-blue-400"})}):eC&&eS?(0,t.jsx)("div",{className:"w-9 h-9 md:w-10 md:h-10 rounded-full flex items-center justify-center text-sm font-semibold text-white",style:{backgroundColor:eS.primary},"aria-label":`${eS.label} \xb7 ${eE||"Unknown sender"}`,children:(eE?.trim()?.[0]||eI?.[0]||"?").toUpperCase()}):(0,t.jsxs)(t.Fragment,{children:[!ew&&e.metadata?.listing?.name&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px] md:text-xs text-gray-400 dark:text-white/50 mb-2",children:[(0,t.jsx)(b.Home,{className:"w-3 h-3 text-gray-400 dark:text-white/40 flex-shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:e.metadata.listing.name})]}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("div",{className:"w-24 h-24 md:w-32 md:h-32 rounded-lg overflow-hidden bg-gray-100 dark:bg-white/[0.05] border border-gray-200 dark:border-white/[0.08]",children:e.metadata?.listing?.thumbnail||e.metadata?.listing?.thumbnailUrl?(0,t.jsx)(A.default,{src:e.metadata.listing.thumbnail||e.metadata.listing.thumbnailUrl,alt:e.metadata?.listing?.name||"Property",width:128,height:128,className:"w-full h-full object-cover",priority:10>n.findIndex(t=>t.id===e.id)}):(0,t.jsx)("div",{className:"w-full h-full flex items-center justify-center",children:(0,t.jsx)(b.Home,{className:"w-6 h-6 md:w-8 md:h-8 text-gray-400 dark:text-white/40"})})}),ew?(0,t.jsx)("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent flex flex-col justify-end p-2",children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)(M.Avatar,{className:"w-5 h-5 md:w-6 md:h-6",children:[(0,t.jsx)(M.AvatarImage,{src:"/airbnb-fill.png"}),(0,t.jsx)(M.AvatarFallback,{className:"bg-[#FF5A5F] text-gray-900 dark:text-white",children:"A"})]}),(0,t.jsx)("span",{className:"text-xs text-gray-900 dark:text-white truncate",children:"Airbnb"})]})}):e.metadata?.guest?.name?.first&&(0,t.jsx)("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent flex flex-col justify-end p-2",children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)(M.Avatar,{className:"w-5 h-5 md:w-6 md:h-6",children:[(0,t.jsx)(M.AvatarImage,{src:e.metadata?.guest?.metadata?.avatarUrl}),(0,t.jsx)(M.AvatarFallback,{className:"bg-gray-100 dark:bg-[#1C1C1E] text-gray-500 dark:text-white/70",children:(e.metadata?.guest?.name?.first||"?").toString().charAt(0).toUpperCase()})]}),(0,t.jsx)("span",{className:"text-xs text-gray-900 dark:text-white truncate",children:e.metadata?.guest?.name?.first||"Guest"})]})}),(0,t.jsx)("div",{className:"absolute -top-1 -left-1 md:-top-2 md:-left-2",children:ej?(0,t.jsx)("div",{className:"rounded-md px-1.5 py-0.5 text-[10px] md:text-xs font-medium shadow-sm bg-purple-500/10 text-purple-500 border border-purple-500/20",children:"Owner"}
24):ew?(0,t.jsxs)("div",{className:"rounded-md px-1.5 py-0.5 text-[10px] md:text-xs font-medium shadow-sm bg-[#FF5A5F] text-gray-900 dark:text-white hover:bg-[#FF5A5F]/90 transition-colors",children:[(0,t.jsx)("span",{className:"md:hidden flex items-center gap-1",children:"Support"}),(0,t.jsx)("span",{className:"hidden md:block",children:"Airbnb Support"})]}):"todo"===e.type||"task"===e.sourceType?(0,t.jsx)("div",{className:"rounded-md px-1.5 py-0.5 text-[10px] md:text-xs font-medium text-white",style:{backgroundColor:"completed"===e.status?"#22c55e":"in_progress"===e.status?"#3b82f6":"#f59e0b"},children:(0,t.jsx)("span",{className:"capitalize",children:e.metadata?.taskCategory||"Task"})}):(U={isInquiry:"inquiry"===e.type,metadata:{reservation:{dates:{checkIn:e.metadata?.reservation?.dates?.checkIn,checkOut:e.metadata?.reservation?.dates?.checkOut},status:e.metadata?.reservation?.status}}},B=(0,L.getReservationStatus)(U),(0,t.jsxs)("div",{className:(0,E.cn)("rounded-md px-1.5 py-0.5 text-[10px] md:text-xs font-medium","shadow-sm",L.STATUS_STYLES[B.text]),children:[(0,t.jsxs)("span",{className:"md:hidden flex items-center gap-1",children:["Checking-in today"===B.text&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(v.LogIn,{className:"w-3 h-3"}),(0,t.jsx)("span",{children:"today"})]}),"Checking-out today"===B.text&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(k.LogOut,{className:"w-3 h-3"}),(0,t.jsx)("span",{children:"today"})]}),"Checking-in today"!==B.text&&"Checking-out today"!==B.text&&B.text]}),(0,t.jsx)("span",{className:"hidden md:block",children:B.text})]}))})]})]})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[!eC&&(0,t.jsxs)("div",{className:"flex items-center justify-between w-full mb-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-x-2 gap-y-1 text-[10px] md:text-xs text-gray-400 dark:text-white/50",children:[ek&&(0,t.jsx)("div",{className:"flex items-center gap-1 min-w-0",children:(0,t.jsx)("span",{className:"truncate",children:e.metadata?.fromName||e.metadata?.fromAddress||"Unknown sender"})}),ek&&e.metadata?.emailInbox?.displayName&&(0,t.jsxs)("div",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded bg-blue-500/10 dark:bg-blue-400/10 text-blue-600 dark:text-blue-400",children:[(0,t.jsx)(C.Mail,{className:"w-2.5 h-2.5"}),(0,t.jsx)("span",{className:"truncate",children:e.metadata.emailInbox.displayName})]}),ej&&e.metadata?.owner&&(0,t.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,t.jsx)(b.Home,{className:"w-3 h-3 text-gray-400 dark:text-white/40 flex-shrink-0"}),(0,t.jsxs)("span",{className:"truncate",children:[e.metadata?.listings?.length||0," ",e.metadata?.listings?.length===1?"property":"properties"]})]}),!ek&&!ew&&!ej&&ef.checkIn&&(0,t.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,t.jsx)(c.Calendar,{className:"w-3 h-3 text-gray-400 dark:text-white/40 flex-shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:((e,t)=>{if(!e)return console.warn("[formatDateRange] Missing start date"),"";try{let a=e=>{let t=e.replace(/\[.*\]$/,"").split("T")[0].match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!t)return console.warn("[formatDateRange] Invalid date format:",e),null;let[,a,r,s]=t,i=new Date(parseInt(a),parseInt(r)-1,parseInt(s));return isNaN(i.getTime())?(console.warn("[formatDateRange] Invalid date:",e),null):i},r=a(e);if(!r)return"";let s=null;t&&(s=a(t));let i=new Date().getFullYear(),n=r.getFullYear(),l=s?.getFullYear(),o=e=>`'${e.toString().slice(-2)}`,d=n!==i||s&&l!==i;if(s&&n===l)return`${(0,_.format)(r,"MMM d")}${d?`, ${o(n)}`:""} - ${(0,_.format)(s,"MMM d")}`;return`${(0,_.format)(r,"MMM d")}${d?`, ${o(n)}`:""}${s?` - ${(0,_.format)(s,"MMM d")}${d?`, ${o(l)}`:""}`:""}`}catch(e){return console.error("[formatDateRange] Error:",e),""}})(ef.checkIn,ef.checkOut)})]}),!ek&&!ew&&!ej&&ey.total&&(0,t.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,t.jsx)(y.DollarSign,{className:"w-3 h-3 text-gray-400 dark:text-white/40 flex-shrink-0"}),(0,t.jsxs)("span",{className:"truncate",children:[(q="string"==typeof(m=ey.total)?parseFloat(m):m,new Intl.NumberFormat("en-US",{style:"decimal",maximumFractionDigits:2,minimumFractionDigits:0}).format(q))," ",ey.currency]})]})]}),(0,t.jsx)("span",{className:"text-[10px] md:text-xs text-gray-400 dark:text-white/40 flex-shrink-0 whitespace-nowrap ml-4",children:e.updatedAt&&O(new Date(e.updatedAt))})]}),eC?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white truncate leading-tight",children:eE||eI||e.title}),(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.priority&&(0,t.jsxs)("span",{className:(0,E.cn)("flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[9px] font-semibold","critical"===e.priority&&"text-priority-critical bg-priority-critical/20","high"===e.priority&&"text-priority-high bg-priority-high/20","medium"===e.priority&&"text-priority-medium bg-priority-medium/20","low"===e.priority&&"text-priority-low bg-priority-low/20"),children:[(0,t.jsx)("span",{className:(0,E.cn)("w-1 h-1 rounded-full","critical"===e.priority&&"bg-priority-critical","high"===e.priority&&"bg-priority-high","medium"===e.priority&&"bg-priority-medium","low"===e.priority&&"bg-priority-low")}),e.priority]}),e.assignment&&(0,t.jsxs)("div",{className:"flex items-center gap-1 pl-0.5 pr-2 py-0.5 rounded-full bg-gray-100 dark:bg-white/[0.08] max-w-[140px]",title:e.assignment.userName||e.assignment.groupName||"Assigned",children:[(0,t.jsx)("div",{className:"w-4 h-4 rounded-full overflow-hidden bg-gray-200 dark:bg-white/10 flex items-center justify-center flex-shrink-0",children:"SYSTEM"===e.assignment.userId?(0,t.jsx)(A.default,{src:"/favicon.ico",alt:"Vanio AI",width:16,height:16,className:"w-full h-full"}):"group"===e.assignment.type?(0,t.jsx)(N.Users2,{className:"w-2.5 h-2.5 text-gray-500 dark:text-white/70"}):el?.image?(0,t.jsx)(A.default,{src:el.image,alt:el.name||"",width:16,height:16,className:"w-full h-full object-cover"}):(0,t.jsx)("span",{className:"text-[8px] font-bold text-gray-600 dark:text-white/70",children:(e.assignment.userName||e.assignment.groupName||"?")[0]?.toUpperCase()})}),(0,t.jsx)("span",{className:"text-[10px] font-medium text-gray-700 dark:text-white/80 truncate",children:e.assignment.userName||e.assignment.groupName||"Assigned"})]}),(0,t.jsx)("span",{className:"text-[10px] text-gray-400 dark:text-white/40 whitespace-nowrap",children:e.updatedAt&&O(new Date(e.updatedAt))})]})]}),e.preview&&(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/50 line-clamp-1 leading-tight mt-0.5",children:e.preview})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("h3",{className:"text-base md:text-base font-medium text-gray-900 dark:text-white mb-2 line-clamp-1",children:[ej||ek?"":ew?"Airbnb Support Thread: ":e.metadata?.reservation?.confirmationCode?`${e.metadata.reservation.confirmationCode}: `:"",e.title]}),e.preview&&(0,t.jsx)("p",{className:"text-sm md:text-sm text-gray-400 dark:text-white/50 line-clamp-2 mb-2",children:e.preview})]}),!eC&&(0,t.jsxs)("div",{className:(0,E.cn)("flex items-center gap-2","mt-2"),children:[e.assignment&&(0,t.jsxs)("div",{className:"relative flex items-center gap-1.5 h-6 px-2 rounded-full bg-gray-100 dark:bg-white/[0.08] group text-xs md:text-xs flex-shrink-0",children:["SYSTEM"===e.assignment.userId?(0,t.jsx)(A.default,{src:"/favicon.ico",alt:"Vanio AI",width:16,height:16,className:"w-4 h-4 rounded-full"}):"group"===e.assignment.type?(0,t.jsx)("div",{className:"w-4 h-4 rounded-full bg-gray-100 dark:bg-white/10 flex items-center justify-center",children:(0,t.jsx)(N.Users2,{className:"w-3 h-3 text-gray-500 dark:text-white/70"})}):el?.image?(0,t.jsx)(A.default,{src:el.image,alt:el.name||"Assigned user",width:16,height:16,className:"w-4 h-4 rounded-full"}):(0,t.jsx)("div",{className:"w-4 h-4 rounded-full bg-gray-100 dark:bg-white/10 flex items-center justify-center",children:(0,t.jsx)("span",{className:"text-[10px] text-gray-500 dark:text-white/70",children:el?.name?.charAt(0)||"?"})}),(0,t.jsx)("span",{className:"text-gray-500 dark:text-white/70",children:"SYSTEM"===e.assignment.userId?"Vanio AI":"group"===e.assignment.type?`@${es.find(t=>
24t.id===e.assignment.groupId)?.name||"Unknown Group"}`:el?.name||"Unknown"}),e.assignment?.assignedAt&&(0,t.jsx)("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 hidden group-hover:block z-50",children:(0,t.jsx)("div",{className:"bg-black/90 text-xs px-2 py-1 rounded whitespace-nowrap",children:(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)("span",{className:"text-gray-500 dark:text-white/70",children:["Assigned ",O(new Date(e.assignment.assignedAt))]}),eo&&(0,t.jsxs)("span",{className:"text-gray-400 dark:text-white/50",children:["by ",eo.name]})]})})})]}),e.priority&&(0,t.jsxs)("div",{className:(0,E.cn)("flex items-center gap-1.5 h-6","px-2 rounded-full text-xs md:text-xs font-medium flex-shrink-0","critical"===e.priority&&"text-priority-critical bg-priority-critical/20","high"===e.priority&&"text-priority-high bg-priority-high/20","medium"===e.priority&&"text-priority-medium bg-priority-medium/20","low"===e.priority&&"text-priority-low bg-priority-low/20"),children:[(0,t.jsx)("div",{className:(0,E.cn)("w-1.5 h-1.5 rounded-full flex-shrink-0","critical"===e.priority&&"bg-priority-critical","high"===e.priority&&"bg-priority-high","medium"===e.priority&&"bg-priority-medium","low"===e.priority&&"bg-priority-low")}),e.priority]}),e.reminder&&(0,t.jsxs)("div",{className:"flex items-center gap-1 h-6 px-2 rounded-full bg-blue-500/10 dark:bg-blue-400/10 text-blue-600 dark:text-blue-400 text-xs font-medium flex-shrink-0",children:[(0,t.jsx)(u.Clock,{className:"w-3 h-3"}),(0,t.jsx)("span",{children:(h=new Date(e.reminder),x=new Date,p=(g=h.getTime()-x.getTime())/36e5,f=g/864e5,g<0?"Overdue":p<1?`${Math.round(g/6e4)}m`:p<24?`${Math.round(p)}h`:f<2?"Tomorrow":f<7?(0,_.format)(h,"EEE"):(0,_.format)(h,"MMM d"))})]}),e.metadata?.analysis?.category&&!e.metadata?.analysis?.quality&&(0,t.jsxs)("div",{className:"hidden md:flex items-center gap-1.5 flex-shrink-0",children:["high"===e.metadata.analysis.priority&&(0,t.jsx)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-red-400/15 text-red-400",children:"High"}),(0,t.jsx)("span",{className:(0,E.cn)("inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium","negative"===e.metadata.analysis.sentiment&&"bg-red-400/10 text-red-400","positive"===e.metadata.analysis.sentiment&&"bg-emerald-400/10 text-emerald-400",(!e.metadata.analysis.sentiment||"neutral"===e.metadata.analysis.sentiment)&&"bg-gray-400/10 text-gray-500 dark:text-white/40"),children:e.metadata.analysis.category})]}),e.metadata?.analysis?.quality&&(0,t.jsx)("div",{className:"hidden md:block relative flex-shrink-0",children:(()=>{let a=e.metadata.analysis.quality,r=[a.clarity,a.effectiveness,a.professionalism,a.contextRelevance,a.completeness].filter(e=>"number"==typeof e&&!isNaN(e)&&void 0!==e);if(0===r.length)return null;let s=r.some(e=>e<7),i=r.reduce((e,t)=>e+t,0)/r.length,n=Math.round(s?Math.max(i-1,1):i);return(0,t.jsxs)("div",{className:(0,E.cn)("relative inline-flex items-center gap-1.5 h-6","px-2 rounded-full text-xs font-medium","cursor-help hover:bg-opacity-75 transition-colors","overflow-visible",n<=6&&"bg-red-400/20 text-red-400",n>6&&n<8&&"bg-orange-400/20 text-orange-400",n>=8&&"bg-blue-400/20 text-blue-400"),onMouseEnter:e=>{e.stopPropagation();let t=e.currentTarget.querySelector("[data-tooltip]");t&&(t.classList.remove("invisible","opacity-0"),t.classList.add("visible","opacity-100"))},onMouseLeave:e=>{e.stopPropagation();let t=e.currentTarget.querySelector("[data-tooltip]");t&&(t.classList.add("invisible","opacity-0"),t.classList.remove("visible","opacity-100"))},children:[(0,t.jsx)("span",{className:"text-gray-500 dark:text-white/70",children:"Quality:"}),(0,t.jsxs)("span",{children:[n,"/10"]}),(0,t.jsx)("div",{"data-tooltip":!0,className:(0,E.cn)("invisible opacity-0","fixed","w-64 p-3","bg-black/90 rounded-lg","text-xs text-gray-700 dark:text-white/90","transition-all duration-200","shadow-xl z-[9999]","pointer-events-none","transform -translate-x-1/2 translate-y-2","[&.visible]:block"),style:{top:"calc(100% - 45px)",left:"50%"},children:(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("p",{className:"text-gray-400 dark:text-white/50 text-[10px] mb-2 italic",children:"Quality metrics for manual response"}),[{label:"Clarity",value:a.clarity},{label:"Effectiveness",value:a.effectiveness},{label:"Professionalism",value:a.professionalism},{label:"Context",value:a.contextRelevance},{label:"Completeness",value:a.completeness}].map(({label:e,value:a})=>(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsxs)("span",{children:[e,":"]}
24),(0,t.jsx)("span",{className:(0,E.cn)(a&&a<=6&&"text-red-400",a&&a>6&&a<8&&"text-orange-400",a&&a>=8&&"text-blue-400"),children:a?`${a}/10`:"N/A"})]},e)),(()=>{let a=e.metadata?.analysis?.quality?.suggestedImprovements;if(!a)return null;let r=[];return(Array.isArray(a)?r=a.map(e=>"string"==typeof e?e:e?.suggestion||""):"string"==typeof a?r=a.split("\n").filter(e=>""!==e.trim()):"object"==typeof a&&null!==a&&(r=[a.suggestion||"No suggestion available"]),0===r.length)?null:(0,t.jsxs)("div",{className:"mt-3 pt-3 border-t border-gray-200 dark:border-white/10",children:[(0,t.jsx)("p",{className:"text-gray-400 dark:text-white/60 mb-1 text-[11px]",children:"Suggestions:"}),r.map((e,a)=>(0,t.jsx)("p",{className:"text-gray-500 dark:text-white/80 text-[11px] leading-[1.4] break-words whitespace-normal mb-1",children:e},a))]})})()]})})]})})()})]})]})]})})]})})});function O(e){let t=Math.floor((new Date().getTime()-e.getTime())/1e3);if(t<60)return"just now";if(t<3600){let e=Math.floor(t/60);return`${e}m ago`}if(t<86400){let e=Math.floor(t/3600);return`${e}h ago`}{let e=Math.floor(t/86400);return`${e}d ago`}}$.displayName="DashboardItem",e.s(["DashboardItem",0,$],978731),e.s(["HistorySidebar",0,function(){let[e,d]=(0,a.useState)(!1),[c,m]=(0,a.useState)(!1),[u,h]=(0,a.useState)(!1),[x,g]=(0,a.useState)(!1),p=(0,a.useRef)(null);(0,a.useEffect)(()=>{let e=()=>{m(document.body.hasAttribute("data-vanio-chat")),h(document.body.hasAttribute("data-vanio-chat-full")),g(document.body.hasAttribute("data-vanio-chat-sidebar-open"))};e();let t=new MutationObserver(e);return t.observe(document.body,{attributes:!0,attributeFilter:["data-vanio-chat","data-vanio-chat-full","data-vanio-chat-sidebar-open"]}),()=>t.disconnect()},[]);let{data:b,isLoading:f}=(0,l.useQuery)({queryKey:["dashboard-history"],queryFn:async()=>{let e=await fetch("/api/dashboard/history");if(!e.ok)throw Error("Failed to fetch history");return await e.json()},enabled:e});(0,a.useEffect)(()=>{let e=()=>{d(!0)};return window.addEventListener("open-history-sidebar",e),()=>{window.removeEventListener("open-history-sidebar",e)}},[]),(0,a.useEffect)(()=>{function t(e){if(p.current&&!p.current.contains(e.target)){let t=document.querySelector("[data-history-toggle]");t?.contains(e.target)||d(!1)}}return e&&document.addEventListener("mousedown",t),()=>{document.removeEventListener("mousedown",t)}},[e]);let y=()=>{d(!1)};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(o.Button,{"data-history-toggle":!0,variant:"ghost",size:"icon",className:(0,E.cn)("p-2 rounded-lg","text-gray-500 dark:text-white/60 hover:text-gray-900 dark:hover:text-white","transition-all duration-200","bg-gray-100 dark:bg-white/[0.05] hover:bg-gray-200 dark:hover:bg-white/[0.08]","border border-gray-200 dark:border-white/[0.08]","md:fixed md:bottom-[22px] md:z-[49] md:h-[52px] md:w-[52px] md:rounded-full md:bg-white md:dark:bg-[#1C1C1E] md:border md:border-gray-200 md:dark:border-white/[0.08] md:hover:bg-gray-100 md:dark:hover:bg-[#2C2C2E]",u?"hidden":c?"xl:right-[400px] md:right-[88px]":"md:right-[88px]"),onClick:()=>d(!e),children:(0,t.jsx)(i.History,{className:"h-[22px] w-[22px] text-gray-600 dark:text-white/70"})}),(0,t.jsx)(s.AnimatePresence,{children:e&&(0,t.jsxs)(r.motion.div,{ref:p,initial:{x:"100%",opacity:0}
24,animate:{x:0,opacity:1},exit:{x:"100%",opacity:0},transition:{type:"spring",damping:20},className:"fixed right-0 top-0 z-50 h-screen w-full sm:w-[480px] bg-white dark:bg-[#1C1C1E] border-l border-gray-200 dark:border-white/[0.08] shadow-xl",children:[(0,t.jsxs)("div",{className:"flex h-14 items-center justify-between border-b border-gray-200 dark:border-white/[0.08] px-4",children:[(0,t.jsx)("h2",{className:"text-sm font-medium",children:"Recent Activity"}),(0,t.jsx)(o.Button,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>d(!1),children:(0,t.jsx)(n.X,{className:"h-4 w-4"})})]}),(0,t.jsx)("div",{className:"h-[calc(100vh-3.5rem)] overflow-y-auto p-4 pb-[80px] md:pb-4",children:f?(0,t.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,t.jsx)("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-gray-300 dark:border-white/20 border-t-gray-600 dark:border-t-white/80"})}):b?.items?.length>0?(0,t.jsx)("div",{className:"space-y-4",children:b.items.map(e=>(0,t.jsxs)("div",{children:[(0,t.jsx)($,{item:e,itemId:e.id.toString(),filteredItems:[],onItemClick:y}),(0,t.jsx)("div",{className:"mt-1 pl-2 text-xs text-gray-400 dark:text-white/40",children:new Date(e.lastInteraction).toLocaleString()})]},e.id))}):(0,t.jsx)("div",{className:"flex items-center justify-center py-8 text-sm text-gray-400 dark:text-white/40",children:"No recent activity"})})]})})]})}],808548);let U=new Set(["partner","maintenance","cleaner","listing_owner"]);e.s(["canEditTaskAssignment",0,function(e){let{role:t,userId:a,assigneeUserIds:r,companyWorkerUserIds:s}=e;return!t||!(!t||U.has(t))||!!a&&(!!r.includes(a)||"partner"===t&&!!s&&s.length>0&&r.some(e=>s.includes(e)))}],355390);let B="00000000-0000-0000-0000-000000000000",q="Assigned",z=["user","group","system"];e.s(["SYSTEM_USER_ID",0,B,"resolveHeaderAssignee",0,function(e){let{assignment:t,fallback:a,findUser:r,usersSettling:s}=e;if(t?.user_id){let e={status:t.status??void 0,acceptance_status:t.acceptance_status,approval_status:t.approval_status};if(t.user_id===B)return{userId:B,name:"Vanio AI",avatar:"/favicon.ico",type:"system",...e};let a=r(t.user_id);return a?{userId:t.user_id,name:a.name||q,avatar:a.image||void 0,type:"user",...e}:s?"loading":{userId:t.user_id,name:q,type:"user",unnamed:!0,...e}}if(a?.userId){var i;let e={status:a.status??void 0,acceptance_status:a.acceptance_status,approval_status:a.approval_status};if("system"===a.type||a.userId===B)return{userId:a.userId,name:"Vanio AI",avatar:"/favicon.ico",type:"system",...e};let t=r(a.userId),s=t?.name||(a.name&&a.name!==a.userId?a.name:null);return{userId:a.userId,name:s||q,avatar:t?.image||a.avatar||void 0,type:(i=a.type,z.includes(i)?i:"user"),...s?{}:{unnamed:!0},...e}}return null}],819813);var H=e.i(124252);e.s(["AssignmentErrorNotice",0,function({message:e,onDismiss:a}){return e?(0,t.jsx)(H.Portal,{children:(0,t.jsxs)("div",{role:"alert",className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-[200] max-w-[min(92vw,560px)] px-4 py-2.5 rounded-lg bg-red-500/90 text-white text-sm font-medium shadow-xl flex items-start gap-2",children:[(0,t.jsx)(x.AlertTriangle,{className:"w-4 h-4 mt-0.5 shrink-0"}),(0,t.jsx)("span",{className:"flex-1",children:e}),(0,t.jsx)("button",{type:"button",onClick:a,"aria-label":"Dismiss",className:"shrink-0 opacity-80 hover:opacity-100",children:(0,t.jsx)(n.X,{className:"w-4 h-4"})})]})}):null},"useAssignmentError",0,function(){let[e,t]=(0,a.useState)(null),r=(0,a.useRef)(null),s=(0,a.useCallback)(()=>{r.current&&clearTimeout(r.current),r.current=null,t(null)},[]),i=(0,a.useCallback)(e=>{r.current&&clearTimeout(r.current),t(e),r.current=setTimeout(()=>t(null),8e3)},[]);return(0,a.useEffect)(()=>()=>{r.current&&clearTimeout(r.current)},[]),{message:e,show:i,clear:s}}],979357);var V=e.i(541071),G=e.i(239616),W=e.i(115057),K=e.i(431343),Y=e.i(957549),J=e.i(337607),Q=e.i(75998),X=e.i(474035),Z=e.i(406671),ee=e.i(568612),et=e.i(144662),ea=e.i(300297);function er({task:e,onSave:r,onClose:s}){let i=(0,J.useTranslations)(),[n,l]=(0,a.useState)(!1),[d,c]=(0,a.useState)({startDate:e.start_date?new Date(e.start_date):null,dueDate:e.due_date?new Date(e.due_date):null,estimatedDuration:e.estimated_duration||0,actualDuration:e.actual_duration||0,startedAt:e.started_at?new Date(e.started_at):null,requiresApproval:e.requires_approval||!1,requiresAcceptance:e.requires_acceptance||!1,acceptanceDeadline:e.acceptance_deadline?new Date(e.acceptance_deadline):null,approvalDeadline:e.approval_deadline?new Date(e.approval_deadline):null});(0,a.useEffect)(()=>{c(t=>({...t,startDate:e.start_date?new Date(e.start_date):null,dueDate:e.due_date?new Date(e.due_date):null,estimatedDuration:e.estimated_duration||0,actualDuration:e.actual_duration||0,startedAt:e.started_at?new Date(e.started_at):null,requiresApproval:e.requires_approval||!1,requiresAcceptance:e.requires_acceptance||!1,acceptanceDeadline:e.acceptance_deadline?new Date(e.acceptance_deadline):null,approvalDeadline:e.approval_deadline?new Date(e.approval_deadline):null}))},[e]);let m=(e,t)=>
24{c(a=>{let r={...a,[e]:t};return"dueDate"===e&&t&&r.requiresApproval&&(r.approvalDeadline=new Date(t.getTime()-1728e5)),r})},u=async()=>{try{l(!0),await r(d),s()}catch(e){console.error("[TaskPropertiesEditor] Error:",e)}finally{l(!1)}};return(0,t.jsxs)("div",{className:"p-4 space-y-4",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:i.tasks.actions.properties.title}),(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60",children:i.tasks.actions.properties.startDate}),d.startDate?(0,t.jsx)(Z.DateTimePicker,{date:d.startDate,setDate:e=>m("startDate",e)}):(0,t.jsx)(o.Button,{variant:"outline",size:"sm",onClick:()=>m("startDate",new Date),className:"w-full justify-start text-left font-normal",children:i.tasks.actions.properties.setStartDate})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60",children:i.tasks.actions.properties.dueDate}),d.dueDate?(0,t.jsx)(Z.DateTimePicker,{date:d.dueDate,setDate:e=>m("dueDate",e)}):(0,t.jsx)(o.Button,{variant:"outline",size:"sm",onClick:()=>m("dueDate",new Date),className:"w-full justify-start text-left font-normal",children:i.tasks.actions.properties.setDueDate})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60",children:i.tasks.actions.properties.estimatedDuration}),(0,t.jsx)(Q.Input,{type:"number",value:d.estimatedDuration,onChange:e=>c(t=>({...t,estimatedDuration:parseInt(e.target.value)||0})),min:0,className:"bg-gray-50 dark:bg-white/5"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60",children:i.tasks.actions.properties.startedAt}),d.startedAt?(0,t.jsx)(Z.DateTimePicker,{date:d.startedAt,setDate:e=>m("startedAt",e)}):(0,t.jsx)(o.Button,{variant:"outline",size:"sm",onClick:()=>m("startedAt",new Date),className:"w-full justify-start text-left font-normal",children:i.tasks.actions.properties.setStartedAt})]}),(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("label",{className:"text-sm text-gray-600 dark:text-white/80",children:i.tasks.actions.properties.requiresApproval}),(0,t.jsx)(X.Switch,{checked:d.requiresApproval,onCheckedChange:e=>{c(t=>({...t,requiresApproval:e,approvalDeadline:e&&t.dueDate?new Date(t.dueDate.getTime()-1728e5):null}))}})]}),d.requiresApproval&&(0,t.jsxs)("div",{className:"space-y-2 pl-4",children:[(0,t.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60",children:i.tasks.actions.properties.approvalDeadline}),d.approvalDeadline?(0,t.jsx)(Z.DateTimePicker,{date:d.approvalDeadline,setDate:e=>m("approvalDeadline",e)}):(0,t.jsx)(o.Button,{variant:"outline",size:"sm",onClick:()=>{m("approvalDeadline",new Date((d.dueDate||new Date).getTime()-1728e5))},className:"w-full justify-start text-left font-normal",children:i.tasks.actions.properties.setApprovalDeadline})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("label",{className:"text-sm text-gray-600 dark:text-white/80",children:i.tasks.actions.properties.requiresAcceptance}),(0,t.jsx)(X.Switch,{checked:d.requiresAcceptance,onCheckedChange:e=>c(t=>({...t,requiresAcceptance:e}))})]}),d.requiresAcceptance&&(0,t.jsxs)("div",{className:"space-y-2 pl-4",children:[(0,t.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60",children:i.tasks.actions.properties.acceptanceDeadline}),d.acceptanceDeadline?(0,t.jsx)(Z.DateTimePicker,{date:d.acceptanceDeadline,setDate:e=>m("acceptanceDeadline",e)}):(0,t.jsx)(o.Button,{variant:"outline",size:"sm",onClick:()=>m("acceptanceDeadline",new Date),className:"w-full justify-start text-left font-normal",children:i.tasks.actions.properties.setAcceptanceDeadline})]})]})]}),(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-4",children:[(0,t.jsx)(o.Button,{variant:"ghost",size:"sm",onClick:s,disabled:n,children:i.tasks.actions.properties.cancel}),(0,t.jsx)(o.Button,{size:"sm",onClick:u,disabled:n,children:n?(0,t.jsx)("div",{className:"w-4 h-4 border-2 border-current border-t-transparent roun
24ded-full animate-spin"}):i.tasks.actions.properties.save})]})]})}e.s(["TaskActions",0,function({task:e,checklist:r=[],onUpdate:s,onClose:i,className:l,canEdit:o,onStartExecution:d}){let{data:c}=(0,R.useSession)(),m=(0,ee.useUserSettings)(),[u,h]=(0,a.useState)(!1),[x,g]=(0,a.useState)(!1),[b,f]=(0,a.useState)(!1),[y,v]=(0,a.useState)(!1),k="completed"===e.status,j=(0,J.useTranslations)();(0,a.useEffect)(()=>{let e=()=>{v(window.innerWidth<768)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);let N=m.getCurrentRole(),C=N&&["cleaner","maintenance","partner"].includes(N),S=c?.user?.id,I=e.assignments?.some(e=>e.user_id===S&&["accepted","pending","completed"].includes(e.status)),T=(0,a.useMemo)(()=>{if(!e?.start_date&&!e?.due_date)return!0;let t=new Date().toISOString().split("T")[0];return e.start_date&&e.due_date||e.start_date?t>=new Date(e.start_date).toISOString().split("T")[0]:(e.due_date,!0)},[e?.start_date,e?.due_date]),_=e?.issues?.some(e=>!0===e.is_blocking&&"resolved"!==e.status)||!1,A=C&&I&&T&&["todo","pending"].includes(e.status),D=C&&I&&["in_progress","blocked"].includes(e.status)&&!_,P=r.some(e=>e.required&&!e.completed),M=async()=>{try{if(!c?.user?.id)throw Error("User not authenticated");if(!k&&P){f(!0),console.warn("[TaskActions] Cannot complete task: required items incomplete");return}f(!1),h(!0);let t={status:k?"todo":"completed",completedAt:k?null:new Date().toISOString(),updatedBy:c.user.id},a=await fetch(`/api/tasks?taskId=${e.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok){let e=await a.json();throw Error(e.error||"Failed to update task")}s?.()}catch(e){console.error("[TaskActions] Error updating task status:",e)}finally{h(!1)}},F=async()=>{try{d&&await d()}catch(e){console.error("Error starting task:",e)}};(0,a.useEffect)(()=>{f(!1)},[k]);let L=async t=>{try{let a={startDate:t.startDate?.toISOString()||null,dueDate:t.dueDate?.toISOString()||null,estimatedDuration:t.estimatedDuration,actualDuration:t.actualDuration,startedAt:t.startedAt?.toISOString()||null,requiresApproval:t.requiresApproval,requiresAcceptance:t.requiresAcceptance,acceptanceDeadline:t.acceptanceDeadline?.toISOString()||null,approvalDeadline:t.approvalDeadline?.toISOString()||null,updatedAt:new Date().toISOString(),updatedBy:c?.user?.id,updatedByEmail:c?.user?.email};if(!(await fetch(`/api/tasks?taskId=${e.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).ok)throw Error(j.tasks.actions.properties.errors.update);s?.(),g(!1)}catch(e){throw console.error("[TaskActions] Error updating properties:",e),e}},$=async()=>{try{if(!(await fetch(`/api/tasks?taskId=${e.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({convertToTask:!0})})).ok)throw Error(j.tasks.actions.properties.errors.update);s?.()}catch(e){console.error("[TaskActions] Error converting subtask:",e)}};return(0,t.jsxs)("div",{className:(0,E.cn)("flex items-center justify-between border-b border-gray-200 dark:border-white/[0.04] pb-4",l),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[y&&(A||D)&&(0,t.jsxs)("button",{onClick:F,className:(0,E.cn)("flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-colors",D?"bg-green-600 text-gray-900 dark:text-white hover:bg-green-700":"bg-blue-600 text-gray-900 dark:text-white hover:bg-blue-700"),children:[(0,t.jsx)(K.Play,{className:"w-3.5 h-3.5"}),D?"Resume Task":"Start Task"]}),!C&&(0,t.jsxs)("button",{onClick:M,disabled:u||!c?.user||!o,className:(0,E.cn)("flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-colors",k?"bg-green-500/20 text-green-500 hover:bg-green-500/30":"bg-gray-50 dark:bg-white/[0.05] text-gray-600 dark:text-white/70 hover:bg-gray-100 dark:hover:bg-white/[0.08]",(u||!c?.user||!o)&&"opacity-50 cursor-not-allowed"),children:[u?(0,t.jsx)("div",{className:"w-3.5 h-3.5 border-2 border-current border-t-transparent rounded-full animate-spin"}):(0,t.jsx)(w.Check,{className:"w-3.5 h-3.5"}),k?j.tasks.actions.complete.completed:j.tasks.actions.complete.button]}),!C&&!k&&b&&P&&(0,t.jsxs)("span",{className:"text-xs text-amber-500 flex items-center gap-1",children:[(0,t.jsx)(p.AlertCircle,{className:"w-3.5 h-3.5"}),j.tasks.actions.complete.requiredIncomplete]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Y.ShareButton,{currentUrl:window.location.href,taskId:e.id,className:"text-gray-500 dark:text-white/50 hover:text-gray-600 dark:hover:text-white/70"}),o&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(et.DropdownMenu,{children:[(0,t.jsx)(et.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsx)("button",{className:"p-1.5 rounded-md hover:bg-gray-100 dark:hover:bg-white/[0.08] text-gray-500 dark:text-white/50 hover:text-gray-600 dark:hover:text-white/70 transition-colors",children:(0,t.jsx)(V.MoreHorizontal,{className:"w-4 h-4"})})}),(0,t.jsxs)(et.DropdownMenuContent,{align:"end",className:"z-[170] min-w-[180px] bg-white dark:bg-[#1a1a1a] border border-gray-200 dark:border-white/[0.08] rounded-lg p-1",children:[(0,t.jsxs)(et.DropdownMenuItem,{onSelect:()=>g(!0),className:"flex items-center gap-2 px-3 py-2 text-sm text-gray-600 dark:text-white/70 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-white/[0.08] rounded-md cursor-pointer transition-colors",children:[(0,t.jsx)(G.Settings,{className:"w-4 h-4"}),j.tasks.actions.properties.menu.properties]}),e.is_subtask&&(0,t.jsxs)(et.DropdownMenuItem,{onSelect:$,className:"flex items-center gap-2 px-3 py-2 text-sm text-gray-600 dark:text-white/70 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-white/[0.08] rounded-md cursor-pointer transition-colors",children:[(0,t.jsx)(W.ArrowUpRight,{className:"w-4 h-4"}),j.tasks.actions.properties.menu.convertToTask]})]})]}),(0,t.jsx)(ea.Dialog,{open:x,onOpenChange:g,children:(0,t.jsx)(ea.DialogContent,{className:"sm:max-w-[425px]",children:(0,t.jsx)(er,{task:e,onSave:L,onClose:()=>g(!1)})})})]}),(0,t.jsx)("button",{onClick:e=>{e.preventDefault(),e.stopPropagation(),i?.()},className:"p-1.5 rounded-md hover:bg-gray-100 dark:hover:bg-white/[0.08] text-gray-500 dark:text-white/50 hover:text-gray-600 dark:hover:text-white/70 transition-colors",children:(0,t.jsx)(n.X,{className:"w-4 h-4"})})]})]})}],376761);var es=e.i(91144),ei=e.i(846696);e.s(["TaskAssigneeActions",0,function({task:e,onUpdate:r}){let{data:s}=(0,R.useSession)(),[i,l]=(0,a.useState)(!1),o=(0,J.useTranslations)(),d=e.assignments?.find(e=>e.user_id===s?.user?.id);if(d?.acceptance_status!=="pending"||"completed"===e.status||"cancelled"===e.status)return null;
24let c=async t=>{try{if(l(!0),console.log("[TaskAssigneeActions] Responding to task acceptance:",{accept:t,taskId:e.id,assignmentId:d?.id}),!(await fetch(`/api/tasks/assignments/${d?.id}/respond`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accept:t,notes:null})})).ok)throw Error(o.tasks.assigneeActions.errors.update);r?.()}catch(e){console.error("[TaskAssigneeActions] Error responding to task:",e),ei.toast.error(e instanceof Error?e.message:o.tasks.assigneeActions.errors.update)}finally{l(!1)}};return(0,t.jsx)("div",{className:"mb-4 p-3 bg-amber-500/10 border border-amber-500/20 rounded-lg",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-amber-500 mb-1",children:o.tasks.assigneeActions.acceptance.title}),(0,t.jsx)("p",{className:"text-xs text-amber-500/80",children:o.tasks.assigneeActions.acceptance.description.replace("{role}",d?.role_type||"")})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 ml-4",children:[(0,t.jsxs)(es.Badge,{variant:"success",className:"cursor-pointer hover:bg-green-500/30 px-3 py-1 text-sm",onClick:()=>!i&&c(!0),children:[(0,t.jsx)(w.Check,{className:"w-4 h-4 mr-1.5"}),o.tasks.assigneeActions.acceptance.buttons.accept]}),(0,t.jsxs)(es.Badge,{variant:"secondary",className:"cursor-pointer",onClick:()=>!i&&c(!1),children:[(0,t.jsx)(n.X,{className:"w-4 h-4 mr-1"}),o.tasks.assigneeActions.acceptance.buttons.decline]})]})]})})}],864218);var en=e.i(107233),el=e.i(88081),eo=e.i(647780),ed=e.i(16715);let ec=["#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#22C55E","#10B981","#06B6D4","#3B82F6","#6366F1","#8B5CF6","#A855F7","#EC4899","#F43F5E","#6B7280","#374151"];e.s(["TaskTags",0,function({taskId:e,tags:r=[],onUpdate:s,canEdit:i=!0,canEditStructure:l=!0}){let o,{currentCustomerId:d}=(0,P.useCustomer)(),{data:c}=(0,R.useSession)(),[m,u]=(0,a.useState)(!1),[h,x]=(0,a.useState)(""),[g,p]=(0,a.useState)(ec[0]),[b,f]=(0,a.useState)(!1),[y,w]=(0,a.useState)(null),[v,k]=(0,a.useState)([]),[j,N]=(0,a.useState)(!1),[C,S]=(0,a.useState)(!1),[I,T]=(0,a.useState)(!1),[_,A]=(0,a.useState)("left"),D=(0,a.useCallback)(async()=>{if(h.trim()&&d&&c?.user?.id){T(!0);try{let t=await fetch(`/api/tasks?taskId=${e}&customerId=${d}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tagOperation:"add",tagName:h.trim(),tagColor:g})});if(!t.ok){let e=await t.json();throw Error(e.error||"Failed to add tag")}x(""),p(ec[0]),f(!1),u(!1),M(),s?.()}catch(e){console.error("Error adding tag:",e)}finally{T(!1)}}},[e,d,c?.user?.id,h,g,s]),M=(0,a.useCallback)(async()=>{if(d){S(!0);try{let e=await fetch(`/api/tasks?fetchTags=true&customerId=${d}`);if(e.ok){let t=await e.json();k(t)}}catch(e){console.error("Error loading available tags:",e)}finally{S(!1)}}},[d]);(0,a.useEffect)(()=>{M()},[M]);let F=(0,a.useCallback)(async(t,a)=>{if(d&&c?.user?.id){T(!0);try{let r=await fetch(`/api/tasks?taskId=${e}&customerId=${d}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tagOperation:"add",tagName:t,tagColor:a})});if(!r.ok){let e=await r.json();throw Error(e.error||"Failed to add tag")}x(""),p(ec[0]),f(!1),N(!1),u(!1),M(),s?.()}catch(e){console.error("Error adding tag:",e)}finally{T(!1)}}},[e,d,c?.user?.id,s,M]);(0,a.useEffect)(()=>{let e=e=>{let t=e.target;b&&!t.closest("[data-color-picker]")&&f(!1),m&&!t.closest("[data-tag-form]")&&(u(!1),N(!1),f(!1),x(""),p(ec[0]))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[b,m]);let L=(0,a.useCallback)(async t=>{if(d){w(t);try{let a=await fetch(`/api/tasks?taskId=${e}&customerId=${d}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tagOperation:"remove",tagId:t})});if(!a.ok){let e=await a.json();throw Error(e.error||"Failed to remove tag")}M(),s?.()}catch(e){console.error("Error removing tag:",e)}finally{w(null)}}},[e,d,s]);return i||0!==r.length?(0,t.jsx)(t.Fragment,{children:(0,t.jsxs)("div",{className:"flex items-center gap-1 flex-wrap",children:[r.map(e=>(0,t.jsxs)("div",{className:"inline-flex items-center space-x-0.5 px-2 py-1 rounded-full text-xs font-medium",style:{backgroundColor:`${e.color}15`,color:e.color,border:`1px solid ${e.color}30`}
24,children:[(0,t.jsx)(el.Hash,{className:"w-2.5 h-2.5"}),(0,t.jsx)("span",{children:e.name}),i&&l&&(0,t.jsx)("button",{onClick:()=>L(e.id),className:"ml-0.5 hover:bg-gray-100 dark:hover:bg-white/10 rounded-full p-0.5 transition-colors duration-200",disabled:null!==y,children:y===e.id?(0,t.jsx)("div",{className:"w-2.5 h-2.5 border border-current border-t-transparent rounded-full animate-spin"}):(0,t.jsx)(n.X,{className:"w-2.5 h-2.5"})})]},e.id)),i&&l&&(0,t.jsx)(t.Fragment,{children:m?(0,t.jsxs)("div",{className:"relative flex items-center gap-2","data-tag-form":!0,"data-color-picker":!0,children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{type:"text",value:h,onChange:e=>{x(e.target.value),N(!0)},onFocus:()=>N(!0),placeholder:"Tag name...",className:"w-32 px-2 py-1 bg-gray-50 dark:bg-white/[0.05] border border-gray-200 dark:border-white/[0.1] rounded text-xs text-gray-900 dark:text-white placeholder-white/40 focus:outline-none focus:ring-1 focus:ring-blue-500/50",maxLength:20,onKeyDown:e=>{"Enter"===e.key&&h.trim()?D():"Escape"===e.key&&(u(!1),x(""),f(!1),N(!1))},autoFocus:!0}),j&&(0!==(o=v.filter(e=>{let t=!r.some(t=>t.name.toLowerCase()===e.name.toLowerCase());return""===h.trim()?t:e.name.toLowerCase().includes(h.toLowerCase())&&t})).length||C?(0,t.jsxs)("div",{className:"absolute top-full left-0 mt-1 w-48 bg-gray-800 border border-gray-200 dark:border-white/10 rounded-lg shadow-lg z-[100] max-h-40 overflow-y-auto",children:[o.slice(0,8).map(e=>(0,t.jsxs)("button",{onClick:()=>F(e.name,e.color),disabled:I,className:"w-full px-3 py-2 text-left text-xs hover:bg-gray-100 dark:hover:bg-white/10 flex items-center gap-2 first:rounded-t-lg last:rounded-b-lg disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,t.jsx)("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:e.color}}),(0,t.jsx)("span",{className:"text-gray-900 dark:text-white flex-1",children:e.name}),I?(0,t.jsx)("div",{className:"w-3 h-3 border border-current border-t-transparent rounded-full animate-spin"}):(0,t.jsxs)("span",{className:"text-gray-400 dark:text-white/40 text-[10px]",children:["(",e.count,")"]})]},`${e.name}-${e.color}`)),C&&(0,t.jsxs)("div",{className:"px-3 py-2 text-xs text-gray-400 dark:text-white/40 flex items-center gap-2",children:[(0,t.jsx)(ed.RefreshCw,{className:"w-3 h-3 animate-spin"}),(0,t.jsx)("span",{children:"Loading tags..."})]}),!C&&0===v.filter(e=>!r.some(t=>t.name.toLowerCase()===e.name.toLowerCase())).length&&(0,t.jsxs)("div",{className:"px-3 py-2 text-xs text-gray-400 dark:text-white/40 flex items-center justify-between",children:[(0,t.jsx)("span",{children:"No available tags"}),(0,t.jsx)("button",{onClick:e=>{e.stopPropagation(),M()},className:"text-blue-400 hover:text-blue-300",children:(0,t.jsx)(ed.RefreshCw,{className:"w-3 h-3"})})]})]}):null)]}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation();let t=e.currentTarget.getBoundingClientRect(),a=window.innerWidth;t.right+160>a?A("right"):A("left"),f(!b)},className:"w-6 h-6 rounded-full border-2 border-gray-300 dark:border-white/20 flex items-center justify-center hover:border-white/40 transition-colors",style:{backgroundColor:g},children:(0,t.jsx)(eo.Palette,{className:"w-3 h-3 text-gray-600 dark:text-white/80"})}),b&&(0,t.jsx)("div",{className:(0,E.cn)("absolute top-full mt-2 p-3 bg-gray-900/95 backdrop-blur-sm border border-gray-700 rounded-lg shadow-2xl z-[200] min-w-[160px]","right"===_?"right-0":"left-0"),children:(0,t.jsx)("div",{className:"grid grid-cols-4 gap-2",children:ec.map(e=>(0,t.jsx)("button",{type:"button",onClick:t=>{t.preventDefault(),t.stopPropagation(),p(e),f(!1)},className:(0,E.cn)("w-6 h-6 rounded-full border-2 hover:scale-105 transition-all duration-200",g===e?"border-white shadow-lg":"border-gray-600 hover:border-gray-400"),style:{backgroundColor:e}},e))})})]}),h.trim()&&(0,t.jsxs)("button",{onClick:D,disabled:I,className:"px-2 py-1 text-xs text-blue-400 hover:text-blue-300 bg-blue-500/10 hover:bg-blue-500/20 rounded transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-1",children:[I&&(0,t.jsx)("div",{className:"w-3 h-3 border border-current border-t-transparent roun
24ded-full animate-spin"}),"Add"]})]}):(0,t.jsxs)("button",{onClick:()=>u(!0),className:"inline-flex items-center space-x-1 px-2 py-1 rounded-full text-xs font-medium bg-gray-50 dark:bg-white/[0.05] text-gray-500 dark:text-white/60 hover:bg-gray-100 dark:hover:bg-white/[0.1] hover:text-white/80 transition-colors duration-200",disabled:null!==y,children:[(0,t.jsx)(en.Plus,{className:"w-3 h-3"}),(0,t.jsx)("span",{children:"Tag"})]})})]})}):null}],232753);var em=e.i(858500),eu=e.i(575787);function eh(e,t){if(!e)return"unknown";let a=new Date(t).getTime();if(!Number.isFinite(a))return"unknown";let r=e.windowsValidUntil?Date.parse(e.windowsValidUntil):NaN;return Number.isFinite(r)&&a>=r?"unknown":!function(e,t){if(!e?.length)return!1;let a=new Date(t).getTime();return!!Number.isFinite(a)&&e.some(e=>{let t=Date.parse(e?.startsAt),r=Date.parse(e?.endsAt);return!!Number.isFinite(t)&&!!Number.isFinite(r)&&a>=t&&a<r})}(e.liveWindows,a)?"vacant":"occupied"}e.s(["occupancyAt",0,eh],182189);let ex=new Set,eg=null;function ep(e){let t=function(){let[e,t]=(0,a.useState)(0);return(0,a.useEffect)(()=>(t(Date.now()),ex.add(t),null===eg&&(eg=setInterval(()=>{let e=Date.now();ex.forEach(t=>t(e))},3e4)),()=>{ex.delete(t),0===ex.size&&null!==eg&&(clearInterval(eg),eg=null)}),[]),e}();return e?t?eh(e,t):!0===e.occupiedNow?"occupied":"vacant":"unknown"}e.s(["useLiveOccupancy",0,ep],349330),e.s(["OccupancyBadge",0,function({occupancy:e,className:a}){let r=ep(e);if(!e||"unknown"===r)return null;let s="occupied"===r,{isCheckIn:i,isCheckOut:n}=e,l=[s?"Someone is in the property right now":"The property is empty right now",n?"a guest checks out on this taskâs date":null,i?"a guest checks in on this taskâs date":null].filter(Boolean).join(" · ");return(0,t.jsxs)("div",{title:l,className:(0,E.cn)("flex shrink-0 items-center gap-1 whitespace-nowrap px-1.5 py-0.5 rounded-full border text-[10px] font-medium",s?"bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-500/20":"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20",a),children:[s?(0,t.jsx)(em.BedDouble,{className:"w-3 h-3"}):(0,t.jsx)(eu.DoorOpen,{className:"w-3 h-3"}),(0,t.jsx)("span",{children:s?"Occupied":"Vacant"}),n&&(0,t.jsx)(k.LogOut,{className:"w-2.5 h-2.5"}),i&&(0,t.jsx)(v.LogIn,{className:"w-2.5 h-2.5"})]})},"TurnoverWindow",0,function({occupancy:e,className:a}){if(!e)return null;let{previousCheckout:r,nextCheckIn:s}=e;if(!r&&!s)return null;let i=e=>"late"===e||"early"===e?"text-amber-600 dark:text-amber-400 font-medium":"text-gray-500 dark:text-white/50";return(0,t.jsxs)("div",{className:(0,E.cn)("flex shrink-0 items-center gap-2 whitespace-nowrap text-[10px]",a),children:[r&&(0,t.jsxs)("span",{className:i(r.timing),title:`Previous guest checks out at ${r.time}`,children:[(0,t.jsx)(k.LogOut,{className:"w-2.5 h-2.5 inline mr-0.5"}),"out ",r.time,"standard"!==r.timing&&` (${r.timing})`]}),s&&(0,t.jsxs)("span",{className:i(s.timing),title:`Next guest checks in at ${s.time}`,children:[(0,t.jsx)(v.LogIn,{className:"w-2.5 h-2.5 inline mr-0.5"}),"in ",s.time,"standard"!==s.timing&&` (${s.timing})`]})]})}],784070);var eb=e.i(531278);e.s(["EditableTaskTitle",0,function({taskId:e,title:r,onUpdate:s,className:i,as:n="h1"}){let[l,o]=(0,a.useState)(!1),[d,c]=(0,a.useState)(r),[m,u]=(0,a.useState)(!1),h=(0,a.useRef)(null),x=(0,a.useRef)(!1);(0,a.useEffect)(()=>{l||c(r)},[r,l]),(0,a.useEffect)(()=>{l&&(h.current?.focus(),h.current?.select())},[l]);let g=(0,a.useCallback)(async()=>{if(x.current)return;x.current=!0;let t=d.trim();if(!t||t===r){c(r),o(!1);return}u(!0);try{if(!(await fetch(`/api/tasks?taskId=${e}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:t})})).ok)throw Error("Failed to update title");o(!1),s?.()}catch{x.current=!1,h.current?.focus()}finally{u(!1)}},[d,r,e,s]),p=(0,a.useCallback)(()=>{x.current=!0,c(r),o(!1)},[r]);return l?(0,t.jsxs)("div",{className:"flex items-center gap-2 -mx-1",children:[(0,t.jsx)("input",{ref:h,type:"text",value:d,disabled:m,enterKeyHint:"done",autoComplete:"off",onChange:e=>c(e.target.value),onBlur:g,onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),g()):"Escape"===e.key&&(e.preventDefault(),p())},className:(0,E.cn)("w-full min-w-0 rounded border bg-transparent px-1 py-1 outline-none","border-gray-300 focus:border-gray-400 dark:border-white/[0.15] dark:focus:border-white/30",i,"max-md:!text-base")}),m&&(0,t.jsx)(eb.Loader2,{className:"w-4 h-4 animate-spin text-gray-400 flex-shrink-0"})]}):(0,t.jsx)(n,{className:(0,E.cn)("cursor-text rounded -mx-1 px-1 py-1 transition-colors hover:bg-black/[0.03] active:bg-black/[0.05] dark:hover:bg-white/[0.04] dark:active:bg-white/[0.06]",i),role:"button",tabIndex:0,onClick:()=>{x.current=!1,o(!0)},onKeyDown:e=>
24{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),x.current=!1,o(!0))},title:"Tap to edit title",children:r})}],451076)},374326,514052,569687,699346,147361,e=>{"use strict";var t=e.i(843476),a=e.i(271645),r=e.i(908263),s=e.i(65921),i=e.i(474035),n=e.i(435026),l=e.i(531278),o=e.i(503116),d=e.i(463059),c=e.i(664659),m=e.i(595468),u=e.i(373884),h=e.i(514764),x=e.i(801073),g=e.i(818836),p=e.i(347548),b=e.i(286536),f=e.i(77705),y=e.i(778917),w=e.i(562710),v=e.i(576844),k=e.i(542027);function j({action:e,isExpanded:a,onToggleExpand:s,onSendNow:i,onToggleSuppress:n,isSending:C,isSent:S,isToggling:E,globalSuppressed:I,previewsLoaded:T,effectivelyPast:_}){let A,D="past"===e.status||_,P="suppressed"===e.status,R="completed"===e.executionStatus||"sent"===e.executionStatus,M="failed"===e.executionStatus,F="skipped"===e.executionStatus,L=!!e.interpolatedContent&&Object.keys(e.interpolatedContent).length>0,$=e.isActive?P?"suppressed":R?"sent":M?"failed":F?"skipped":D?"past_unknown":"upcoming":"inactive",O={upcoming:{icon:(0,t.jsx)(o.Clock,{className:"w-3.5 h-3.5 text-blue-400"}),border:"border-blue-500/15 bg-blue-500/[0.03]",label:null},suppressed:{icon:(0,t.jsx)(x.PauseCircle,{className:"w-3.5 h-3.5 text-amber-400/70"}),border:"border-amber-500/20 bg-amber-500/[0.04]",label:(0,t.jsx)("span",{className:"text-[10px] text-amber-600 dark:text-amber-400/70 bg-amber-500/10 px-1.5 py-0.5 rounded",children:"Paused"})},inactive:{icon:(0,t.jsx)(g.MinusCircle,{className:"w-3.5 h-3.5 text-gray-400 dark:text-white/25"}),border:"border-gray-200 dark:border-white/[0.04]",label:(0,t.jsx)("span",{className:"text-[10px] text-gray-400 dark:text-white/25 bg-gray-100 dark:bg-white/[0.04] px-1.5 py-0.5 rounded",children:"Inactive"})},sent:{icon:(0,t.jsx)(m.CheckCircle2,{className:"w-3.5 h-3.5 text-emerald-400"}),border:"border-emerald-500/15 bg-emerald-500/[0.03]",label:(0,t.jsx)("span",{className:"text-[10px] text-emerald-500 dark:text-emerald-400/80",children:"Sent"})},failed:{icon:(0,t.jsx)(u.XCircle,{className:"w-3.5 h-3.5 text-red-400"}),border:"border-red-500/20 bg-red-500/[0.04]",label:(0,t.jsx)("span",{className:"text-[10px] text-red-500 dark:text-red-400/80",children:"Failed"})},skipped:{icon:(0,t.jsx)(p.SkipForward,{className:"w-3.5 h-3.5 text-gray-400 dark:text-white/35"}),border:"border-gray-200 dark:border-white/[0.06] bg-gray-50 dark:bg-white/[0.02]",label:(0,t.jsx)("span",{className:"text-[10px] text-gray-400 dark:text-white/35",children:"Skipped"})},past_unknown:{icon:(0,t.jsx)(o.Clock,{className:"w-3.5 h-3.5 text-gray-400 dark:text-white/25"}),border:"border-gray-200 dark:border-white/[0.06] bg-gray-50 dark:bg-white/[0.02]",label:null}}[$];return(0,t.jsxs)("div",{className:(0,r.cn)("rounded-lg border overflow-hidden transition-colors",O.border),children:[(0,t.jsxs)("button",{onClick:"inactive"!==$?s:void 0,className:(0,r.cn)("w-full px-3 py-2.5 flex items-start gap-2.5 transition-colors text-left","inactive"!==$?"hover:bg-gray-50 dark:hover:bg-white/[0.02] cursor-pointer":"cursor-default"),children:[(0,t.jsx)("div",{className:"mt-0.5 shrink-0",children:O.icon}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-sm text-gray-700 dark:text-white/70 truncate",children:e.actionName}),O.label]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,t.jsx)(N,{type:e.actionType}),(0,t.jsx)("span",{className:"text-xs text-gray-400 dark:text-white/30",children:e.triggerLabel}),e.workflowName&&(0,t.jsxs)("span",{className:"text-xs text-gray-400 dark:text-white/30 truncate",title:`Part of workflow: ${e.workflowName}`,children:["· from ",e.workflowName]}),e.executionTime&&(0,t.jsxs)(w.Tooltip,{children:[(0,t.jsx)(w.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"text-[10px] text-gray-400 dark:text-white/20 shrink-0",children:(0,k.format)(new Date(e.executionTime),"MMM d, h:mm a")})}),(0,t.jsx)(w.TooltipContent,{side:"top",className:"z-[200]",children:(0,t.jsx)("p",{className:"text-xs",children:(0,k.format)(new Date(e.executionTime),"MMM d, yyyy h:mm:ss a")})})]}),!e.executionTime&&e.scheduledFor&&(0,t.jsxs)(w.Tooltip,{children:[(0,t.jsx)(w.TooltipTrigger,{asChild:!0,children:(0,t.jsxs)("span",{className:"text-[10px] text-gray-400 dark:text-white/20 flex items-center gap-0.5 shrink-0",children:[(0,t.jsx)(o.Clock,{className:"w-2.5 h-2.5"}),(A=new Date(e.scheduledFor))<new Date?"passed":(0,v.formatDistanceToNow)(A,{addSuffix:!0})]})}),(0,t.jsx)(w.TooltipContent,{side:"top",className:"z-[200]",children:(0,t.jsx)("p",{className:"text-xs",children:(0,k.format)(new Date(e.scheduledFor),"MMM d, yyyy h:mm a")})})]})]}),F&&e.skipReasoning&&(0,t.jsx)("p",{className:"text-[10px] text-gray-500 dark:text-white/40 mt-1 leading-snug whitespace-pre-wrap",children:e.skipReasoning}),F&&!e.skipReasoning&&e.skipReason&&(0,t.jsx)("p",{className:"text-[10px] text-gray-400 dark:text-white/25 mt-1 leading-snug truncate",children:e.skipReason}),M&&e.executionError&&(0,t.jsx)("p",{className:"text-[10px] text-red-500/70 dark:text-red-400/50 mt-1 leading-snug truncate",children:e.executionError})]}),"inactive"!==$&&(0,t.jsx)("div",{className:"shrink-0 mt-0.5",children:a?(0,t.jsx)(c.ChevronDown,{className:"w-3.5 h-3.5 text-gray-400 dark:text-white/20"}
24):(0,t.jsx)(d.ChevronRight,{className:"w-3.5 h-3.5 text-gray-400 dark:text-white/20"})})]}),a&&(0,t.jsxs)("div",{className:"border-t border-gray-100 dark:border-white/[0.04] px-3 py-2.5 space-y-2 bg-gray-50/50 dark:bg-white/[0.01]",children:[L?(0,t.jsxs)(t.Fragment,{children:[Object.entries(e.interpolatedContent).map(([e,a])=>{var r;return(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-[10px] text-gray-400 dark:text-white/30 font-medium mb-0.5 uppercase tracking-wider",children:{message:"Message",subject:"Subject",response:"Response",publicReview:"Public Review",privateFeedback:"Private Feedback",taskTitle:"Task Title",taskDescription:"Task Description",category:"Category",priority:"Priority",assignee:"Assigned To",dueDate:"Due Date",taskStatus:"Status",updateFields:"Updates",url:"URL",method:"Method",operation:"Operation"}[r=e]||r.replace(/([A-Z])/g," $1").replace(/^./,e=>e.toUpperCase()).trim()}),(0,t.jsx)("p",{className:"text-xs text-gray-600 dark:text-white/55 whitespace-pre-wrap break-words leading-relaxed",children:function(e,t){if("string"==typeof t)return t;if("number"==typeof t||"boolean"==typeof t)return String(t);if(null==t)return"-";if("object"==typeof t&&!Array.isArray(t)){if("dueDate"===e&&"baseDate"in t){let e="checkIn"===t.baseDate?"check-in":"checkOut"===t.baseDate?"check-out":String(t.baseDate),a=Number(t.offsetHours)||0;if(0===a)return`At ${e}`;if(a<1)return`${Math.round(60*a)} min after ${e}`;if(1===a)return`1 hour after ${e}`;if(a<24)return`${a} hours after ${e}`;let r=a/24;return`${r} day${1!==r?"s":""} after ${e}`}if("updateFields"===e)return Object.entries(t).map(([e,t])=>`${e}: ${t}`).join(", ")}return Array.isArray(t)?t.join(", "):JSON.stringify(t)}(e,a)})]},e)}),e.channelResolution&&(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-[10px] text-gray-400 dark:text-white/30 font-medium mb-0.5 uppercase tracking-wider",children:"Channel"}),(0,t.jsxs)("p",{className:"text-xs text-gray-600 dark:text-white/55",children:[e.channelResolution.resolved,e.channelResolution.configured!==e.channelResolution.resolved&&(0,t.jsxs)("span",{className:"text-gray-400 dark:text-white/25",children:[" (configured: ",e.channelResolution.configured,")"]})]})]})]}):T?(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-white/20 italic",children:"No preview available"}):null,"inactive"!==$&&(0,t.jsxs)("div",{className:"flex items-center gap-2 pt-1 border-t border-gray-100 dark:border-white/[0.04]",children:[(0,t.jsxs)("a",{href:`/workflows/${e.workflowId}?action=${e.actionId}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-[11px] text-gray-500 dark:text-white/40 hover:text-blue-600 dark:hover:text-blue-400/70 transition-colors px-2 py-1 rounded hover:bg-blue-500/10",children:[(0,t.jsx)(y.ExternalLink,{className:"w-3 h-3"}),"Edit in workflow"]}),"upcoming"===$&&(0,t.jsxs)("button",{onClick:n,disabled:I||E,className:"flex items-center gap-1 text-[11px] text-gray-500 dark:text-white/40 hover:text-amber-600 dark:hover:text-amber-400/70 transition-colors px-2 py-1 rounded hover:bg-amber-500/10 disabled:opacity-30",children:[E?(0,t.jsx)(l.Loader2,{className:"w-3 h-3 animate-spin"}):(0,t.jsx)(f.EyeOff,{className:"w-3 h-3"}),"Skip"]}),"suppressed"===$&&(0,t.jsxs)("button",{onClick:n,disabled:E,className:"flex items-center gap-1 text-[11px] text-amber-600 dark:text-amber-400/60 hover:text-amber-700 dark:hover:text-amber-400/80 transition-colors px-2 py-1 rounded hover:bg-amber-500/10",children:[E?(0,t.jsx)(l.Loader2,{className:"w-3 h-3 animate-spin"}):(0,t.jsx)(b.Eye,{className:"w-3 h-3"}),"Enable"]}),(0,t.jsx)("span",{className:"flex-1"}),S?(0,t.jsxs)("span",{className:"flex items-center gap-1 text-[11px] text-emerald-500 dark:text-emerald-400/60",children:[(0,t.jsx)(m.CheckCircle2,{className:"w-3 h-3"})," Queued"]}):(0,t.jsxs)("button",{onClick:i,disabled:C,className:"flex items-center gap-1 text-[11px] text-blue-500 dark:text-blue-400 hover:text-blue-600 dark:hover:text-blue-300 transition-colors px-2 py-1 rounded hover:bg-blue-500/10",children:[C?(0,t.jsx)(l.Loader2,{className:"w-3 h-3 animate-spin"}):(0,t.jsx)(h.Send,{className:"w-3 h-3"}),R?"Send Again":M?"Retry":"Send Now"]})]})]})]})}function N({type:e,size:a="sm"}){let s={message_send:{text:"MSG",color:"text-blue-400/70 bg-blue-500/10"},email:{text:"EMAIL",color:"text-green-400/70 bg-green-500/10"},whatsapp:{text:"WA",color:"text-green-400/70 bg-green-500/10"},task_creation:{text:"TASK",color:"text-purple-400/70 bg-purple-500/10"},task_update:{text:"TASK",color:"text-purple-400/70 bg-purple-500/10"},payment_setup:{text:"PAY",color:"text-amber-400/70 bg-amber-500/10"},payment_scheduling:{text:"PAY",color:"text-amber-400/70 bg-amber-500/10"},review_reply:{text:"REV",color:"text-yellow-400/70 bg-yellow-500/10"},host_review:{text:"REV",color:"text-yellow-400/70 bg-yellow-500/10"},webhook:{text:"HOOK",color:"text-orange-400/70 bg-orange-500/10"},seam:{text:"LOCK",color:"text-cyan-400/70 bg-cyan-500/10"},send_slack_message:{text:"SLACK",color:"text-purple-400/70 bg-purple-500/10"}}[e]||{text:e.toUpperCase().slice(0,4),color:"text-gray-500 dark:text-white/40 bg-gray-100 dark:bg-white/[0.05]"};return(0,t.jsx)("span",{className:(0,r.cn)("font-semibold rounded shrink-0",s.color,"sm"===a?"text-[10px] px-1 py-0.5":"text-[11px] px-1.5 py-0.5"),children:s.text})}var C=e.i(972520),S=e.i(623385),E=e.i(354385),I=e.i(465261),T=e.i(341240),_=e.i(565365),A=e.i(751737),D=e.i(283086),P=e.i(631745);let R={MessageSquare:_.MessageSquareText,Sparkles:D.Sparkles,Clock:E.ClipboardCheck,Star:P.StarHalf,Lock:I.KeyRound,Brain:S.BrainCircuit,MessageCircle:_.MessageSquareText,Webhook:A.ShieldAlert};function M({gap:e,canInstall:a,isInstalling:r,onInstall:s}){let i=R[e.icon]||T.Lightbulb;return(0,t.jsxs)("div",{className:"flex items-start gap-3 px-4 py-3 group",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded-xl bg-amber-500/10 flex items-center justify-center shrink-0 mt-0.5",children:(0,t.jsx)(i,{className:"w-4 h-4 text-amber-500"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("p",{className:"text-sm font-medium text-gray-900 dark:text-white/80",children:e.gapTitle}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/35 mt-0.5",children:e.gapDescription})]}),a&&(0,t.jsxs)("button",{disabled:r,onClick:s,className:"text-xs text-blue-500 dark:text-blue-400 shrink-0 mt-1 flex items-center gap-1 hover:text-blue-600 dar
24k:hover:text-blue-300 transition-colors disabled:opacity-50",children:[r?(0,t.jsx)(l.Loader2,{className:"w-3 h-3 animate-spin"}):(0,t.jsx)(C.ArrowRight,{className:"w-3 h-3"}),r?"Installing...":"Install"]})]})}var F=e.i(846696),L=e.i(923698);let $="Couldn't add this automation. Please try again.";async function O(e,t=fetch){try{let a=await t("https://api.vanio.ai/recipes/install",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({recipeId:e})});if(a.ok)return!0;return F.toast.error(403===a.status?"Only workspace owners and admins can add automations. Ask an owner or admin of this workspace to install it.":$),!1}catch{return F.toast.error($),!1}}var U=e.i(671142),B=e.i(764417),q=e.i(114683),z=e.i(561659),H=e.i(191741),V=e.i(455711),G=e.i(39312),W=e.i(489853),K=e.i(204997),Y=e.i(694351),J=e.i(292270),Q=e.i(870273),X=e.i(555436),Z=e.i(37727),ee=e.i(223622);let et="https://api.vanio.ai",ea={booking:W.CalendarDays,"pre-checkin":o.Clock,checkin:K.LogIn,stay:Y.Home,cancellation:ee.Ban,checkout:J.LogOut,"post-stay":Q.Star},er={completed:m.CheckCircle2,pending:o.Clock,failed:u.XCircle,suppressed:x.PauseCircle,future:q.Circle},es={completed:"text-emerald-500",pending:"text-amber-500",failed:"text-red-500",suppressed:"text-gray-400 dark:text-white/30",future:"text-gray-300 dark:text-white/15"},ei={workflow_action:G.Zap,automation_log:G.Zap,payment:z.CreditCard,task:H.ClipboardList,ai_action:V.Brain,system_event:q.Circle};function en({item:e}){let a=er[e.status]||q.Circle,s=ei[e.type]||q.Circle,i=es[e.status]||es.future;return(0,t.jsxs)("div",{className:(0,r.cn)("flex items-center gap-2 px-3 py-2 rounded-lg","bg-gray-50/50 dark:bg-white/[0.02] border border-gray-100 dark:border-white/[0.04]"),children:[(0,t.jsx)(a,{className:(0,r.cn)("w-3.5 h-3.5 shrink-0",i)}),(0,t.jsx)(s,{className:"w-3 h-3 shrink-0 text-gray-400 dark:text-white/25"}),(0,t.jsx)("span",{className:(0,r.cn)("text-xs flex-1 truncate","future"===e.status?"text-gray-400 dark:text-white/25":"suppressed"===e.status?"text-gray-400 dark:text-white/30 line-through":"text-gray-700 dark:text-white/70"),children:e.label}),e.metadata?.actionType&&(0,t.jsx)(N,{type:e.metadata.actionType}),e.source&&(0,t.jsx)("span",{className:"text-[10px] text-gray-400 dark:text-white/20 shrink-0 max-w-[100px] truncate",children:e.source}),e.timestamp&&(0,t.jsx)("span",{className:"text-[10px] text-gray-400 dark:text-white/20 shrink-0",children:function(e){try{let t=new Date(e),a=new Date,r=Math.floor((a.getTime()-t.getTime())/864e5);if(0===r)return t.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"});if(r<7)return t.toLocaleDateString("en-US",{weekday:"short"});return t.toLocaleDateString("en-US",{month:"short",day:"numeric"})}catch{return e}}(e.timestamp)})]})}function el({customerId:e}){let[r,s]=(0,a.useState)([]),[i,n]=(0,a.useState)(!0),[l,o]=(0,a.useState)(!1),[d,u]=(0,a.useState)(null),{role:h,isSuperUser:x}=(0,U.useViewerRole)(e),g=function({role:e,isSuperUser:t,accessOverride:a}){return!!t||!!e&&(0,L.resolveWorkspaceFeatureRoles)("workflows",a).includes(e)}({role:h,isSuperUser:x,accessOverride:(0,B.useWorkspaceAccessOverride)()});if((0,a.useEffect)(()=>{e?Promise.all([fetch(`${et}/recipes/catalog?gaps=true`,{credentials:"include"}).then(e=>e.ok?e.json():{recipes:[]}),fetch(`${et}/workflows`,{credentials:"include"}).then(e=>e.ok?e.json():{workflows:[]}),fetch(`${et}/procedures`,{credentials:"include"}).then(e=>e.ok?e.json():{procedures:[]})]).then(([e,t,a])=>{let r=(e.recipes||[]).filter(e=>e.gapTitle&&e.gapCheckType),i=t.workflows||t||[],n=a.procedures||a||[],l=new Set;for(let e of i)e.metadata?.templateId&&l.add(e.metadata.templateId),e.metadata?.migratedFromTemplateId&&l.add(e.metadata.migratedFromTemplateId);for(let e of n)e.metadata?.templateId&&l.add(e.metadata.templateId);s(r.filter(e=>"template_id"!==e.gapCheckType||!l.has(e.gapCheckValue)))}).catch(()=>s([])).finally(()=>n(!1)):n(!1)},[e]),i)return null;if(0===r.length)return(0,t.jsxs)("div",{className:"rounded-2xl border border-emerald-500/15 bg-emerald-500/[0.03] px-4 py-3 flex items-center gap-3",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded-full bg-emerald-500/10 flex items-center justify-center shrink-0",children:(0,t.jsx)(m.CheckCircle2,{className:"w-4.5 h-4.5 text-emerald-500"})}),(0,t.jsx)("p",{className:"text-sm font-medium text-emerald-600 dark:text-emerald-400",children:"Fully automated â all key workflows are active"})]});let p=l?r:r.slice(0,2),b=r.length-2;return(0,t.jsxs)("div",{className:"rounded-2xl border border-gray-200 dark:border-white/[0.08] overflow-hidden",children:[(0,t.jsxs)("div",{className:"px-4 py-3 flex items-center gap-2 border-b border-gray-100 dark:border-white/[0.06]",children:[(0,t.jsx)(T.Lightbulb,{className:"w-4 h-4 text-amber-500"}),(0,t.jsxs)("p",{className:"text-sm font-medium text-gray-700 dark:text-white/70",children:[r.length," opportunity",1!==r.length?"ies":"y"," to improve"]})]}),(0,t.jsx)("div",{className:"divide-y divide-gray-100 dark:divide-white/[0.04]",children:p.map(e=>(0,t.jsx)(M,{gap:e,canInstall:g,isInstalling:d===e.id,onInstall:async()=>{u(e.id);try{await O(e.id)&&s(t=>t.filter(t=>t.id!==e.id))}finally{u(null)}}},e.id))}),b>0&&!l&&(0,t.jsxs)("button",{onClick:()=>o(!0),className:"w-full px-4 py-2.5 text-xs font-medium text-gray-500 dark:text-white/30 hover:text-gray-700 dark:hover:text-white/50 border-t border-gray-100 dark:border-white/[0.04] flex items-center justify-center gap-1 transition-colors",children:["Show ",b," more ",(0,t.jsx)(c.ChevronDown,{className:"w-3 h-3"})]})]})}e.s(["LifecycleTimeline",0,function({reservationId:e,customerId:h,actionTypeFilter:x="all",className:g}){let[p,b]=(0,a.useState)(null),[f,w]=(0,a.useState)(!0),[v,k]=(0,a.useState)(new Set),[N,C]=(0,a.useState)(null),[S,E]=(0,a.useState)(new Set),[I,T]=(0,a.useState)(""),_=(0,n.useReservationAutomations)(e,h);(0,a.useEffect)(()=>{e&&(w(!0),fetch(`${et}/reservations/${e}/lifecycle`,{credentials:"include"}).then(e=>e.ok?e.json():null).then(e=>
24{if(b(e),e?.phases){let t=e.phases.find(e=>"current"===e.status);k(t?new Set([t.phase]):new Set)}}).catch(()=>b(null)).finally(()=>w(!1)),fetch(`${et}/operations/readiness?reservationId=${e}`,{credentials:"include"}).then(e=>e.ok?e.json():null).then(e=>{e?.report&&C(e.report)}).catch(()=>{}))},[e]);let A=(0,a.useCallback)(e=>{k(t=>{let a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},[]),D=(0,a.useCallback)(e=>{E(t=>{let a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},[]),P=new Map;for(let e of _.actions)P.set(e.actionId,e);if(f||_.isLoading)return(0,t.jsxs)("div",{className:(0,r.cn)("p-6 space-y-4",g),children:[(0,t.jsx)(s.Skeleton,{className:"h-10 w-full rounded-lg"}),[1,2,3,4].map(e=>(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(s.Skeleton,{className:"h-6 w-6 rounded-full"}),(0,t.jsx)(s.Skeleton,{className:"h-4 w-32"})]}),(0,t.jsxs)("div",{className:"ml-9 space-y-2",children:[(0,t.jsx)(s.Skeleton,{className:"h-12 w-full rounded-lg"}),(0,t.jsx)(s.Skeleton,{className:"h-12 w-3/4 rounded-lg"})]})]},e))]});if(!p)return(0,t.jsx)("div",{className:(0,r.cn)("p-6 text-center",g),children:(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-white/40",children:"Could not load lifecycle data"})});let R=I.toLowerCase().trim();return(0,t.jsxs)("div",{className:(0,r.cn)("p-4 md:p-6 space-y-4",g),children:[(0,t.jsxs)("div",{className:(0,r.cn)("rounded-lg border px-3 py-3 flex items-center justify-between gap-3",_.isSuppressed?"border-amber-500/30 bg-amber-500/[0.06]":"border-gray-200 dark:border-white/[0.08] bg-gray-50/80 dark:bg-white/[0.02]"),children:[(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("p",{className:(0,r.cn)("text-sm font-medium",_.isSuppressed?"text-amber-600 dark:text-amber-300":"text-gray-600 dark:text-white/70"),children:_.isSuppressed?"All workflows paused":"Workflows active"}),_.isSuppressed&&_.suppressionReason&&(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-white/30 mt-0.5",children:_.suppressionReason})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("a",{href:"/workflows",target:"_blank",rel:"noopener noreferrer",className:"text-gray-400 dark:text-white/20 hover:text-gray-600 dark:hover:text-white/50 transition-colors",children:(0,t.jsx)(y.ExternalLink,{className:"w-3.5 h-3.5"})}),_.suppressLoading?(0,t.jsx)(l.Loader2,{className:"w-4 h-4 animate-spin text-gray-400 dark:text-white/40 shrink-0"}):(0,t.jsx)(i.Switch,{checked:!_.isSuppressed,onCheckedChange:_.handleGlobalToggle})]})]}),N&&(0,t.jsxs)("div",{className:(0,r.cn)("rounded-2xl border px-4 py-3 flex items-start gap-3","ready"===N.overallStatus?"border-emerald-500/15 bg-emerald-500/[0.03]":"critical"===N.overallStatus?"border-red-500/15 bg-red-500/[0.03]":"border-amber-500/15 bg-amber-500/[0.03]"),children:[(0,t.jsx)("div",{className:(0,r.cn)("w-8 h-8 rounded-full flex items-center justify-center shrink-0 mt-0.5","ready"===N.overallStatus?"bg-emerald-500/10":"critical"===N.overallStatus?"bg-red-500/10":"bg-amber-500/10"),children:"ready"===N.overallStatus?(0,t.jsx)(m.CheckCircle2,{className:"w-4.5 h-4.5 text-emerald-500"}):"critical"===N.overallStatus?(0,t.jsx)(u.XCircle,{className:"w-4.5 h-4.5 text-red-500"}):(0,t.jsx)(o.Clock,{className:"w-4.5 h-4.5 text-amber-500"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("p",{className:(0,r.cn)("text-sm font-medium","ready"===N.overallStatus?"text-emerald-600 dark:text-emerald-400":"critical"===N.overallStatus?"text-red-600 dark:text-red-400":"text-amber-600 dark:text-amber-400"),children:"ready"===N.overallStatus?"All systems go":`${N.checks.filter(e=>"ok"!==e.status).length} issue${1!==N.checks.filter(e=>"ok"!==e.status).length?"s":""} detected`}),"ready"!==N.overallStatus&&(0,t.jsx)("div",{className:"mt-1.5 space-y-1",children:N.checks.filter(e=>"ok"!==e.status).slice(0,3).map(e=>(0,t.jsxs)("p",{className:(0,r.cn)("text-xs flex items-center gap-1.5","critical"===e.status?"text-red-500/70 dark:text-red-400/60":"text-amber-600/70 dark:text-amber-400/50"),children:["critical"===e.status?(0,t.jsx)(u.XCircle,{className:"w-3 h-3 shrink-0"}):(0,t.jsx)(o.Clock,{className:"w-3 h-3 shrink-0"}),e.message]},e.id))})]})]}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(X.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-gray-400 dark:text-white/25"}),(0,t.jsx)("input",{type:"text",value:I,onChange:e=>T(e.target.value),placeholder:"Search actions, workflows...",className:(0,r.cn)("w-full pl-9 pr-8 py-2 text-xs rounded-lg border transition-colors","bg-gray-50 dark:bg-white/[0.03] border-gray-200 dark:border-white/[0.08]","text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-white/25","focus:outline-none focus:border-gray-300 dark:focus:border-white/[0.15]")}),I&&(0,t.jsx)("button",{onClick:()=>T(""),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-gray-400 dark:text-white/25 hover:text-gray-600 dark:hover:text-white/50",children:(0,t.jsx)(Z.X,{className:"w-3.5 h-3.5"})})]}),(0,t.jsx)(el,{customerId:h}),(0,t.jsx)("div",{className:"relative",children:p.phases.map((e,a)=>{let s=ea[e.phase],i=v.has(e.phase),n=a===p.phases.length-1,l=e.items.filter(e=>{var t;return("all"===x||(t=e.metadata?.actionType,"all"===x||(t?"message_send"===x?"message_send"===t||"email"===t||"whatsapp"===t:"task"===x?"task_creation"===t||"task_update"===t:"review"===x?"host_review"===t||"review_reply"===t:"payment"===x?"payment_setup"===t||"payment_scheduling"===t:"slack"===x?"send_slack_message"===t:t===x:"all"===x)))&&(!R||e.label?.toLowerCase().includes(R)||e.source?.toLowerCase().includes(R)||e.sublabel?.toLowerCase().includes(R)||e.conditionalLabel?.toLowerCase().includes(R)||e.metadata?.actionType?.toLowerCase().includes(R))}),o=l.length>0;return(0,t.jsxs)("div",{className:"relative",children:[!n&&(0,t.jsx)("div",{className:(0,r.cn)("absolute left-3 top-8 bottom-0 w-px","completed"===e.status?"bg-emerald-500/30":"current"===e.status?"bg-amber-500/30":"bg-gray-200 dark:bg-white/[0.08]")}),(0,t.jsxs)("button",{onClick:()=>o&&A(e.phase),disabled:!o,className:(0,r.cn)("flex items-center gap-3 w-full text-left py-2 group",o&&"cursor-pointer"),children:[(0,t.jsx)("div",{className:(0,r.cn)("w-6 h-6 rounded-full flex items-center justify-center shrink-0 z-10","completed"===e.status?"bg-emerald-500/15":"current"===e.status?"bg-amber-500/15":"bg-gray-100 dark:bg-white/[0.05]"),children:(0,t.jsx)(s,{className:(0,r.cn)("w-3.5 h-3.5","completed"===e.status?"text-emerald-500":"current"===e.status?"text-amber-500":"text-gray-400 dark:text-white/25")})}),(0,t.jsx)("span",{className:(0,r.cn)("text-sm font-medium flex-1","completed"===e.status?"text-gray-900 dark:text-white":"current"===e.status?"text-amber-600 dar
24k:text-amber-400":"text-gray-400 dark:text-white/30"),children:e.label}),e.timestamp&&(0,t.jsx)("span",{className:"text-[11px] text-gray-400 dark:text-white/25",children:function(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric"})}catch{return e}}(e.timestamp)}),o&&(0,t.jsx)("span",{className:"text-gray-400 dark:text-white/25",children:i?(0,t.jsx)(c.ChevronDown,{className:"w-3.5 h-3.5"}):(0,t.jsx)(d.ChevronRight,{className:"w-3.5 h-3.5"})}),o&&(0,t.jsx)("span",{className:(0,r.cn)("text-[10px] px-1.5 py-0.5 rounded-full","bg-gray-100 dark:bg-white/[0.05] text-gray-500 dark:text-white/30"),children:l.length})]}),o&&i&&(0,t.jsx)("div",{className:"ml-9 mb-3 space-y-1.5",children:l.map(e=>{let a=e.metadata?.actionId?P.get(e.metadata.actionId):void 0;return a&&("workflow_action"===e.type||"automation_log"===e.type)?(0,t.jsxs)("div",{children:[e.conditional&&e.conditionalLabel&&(0,t.jsx)("p",{className:"text-[10px] text-gray-400 dark:text-white/25 italic mb-1 ml-1",children:e.conditionalLabel}),(0,t.jsx)("div",{className:(0,r.cn)(e.conditional&&"opacity-60"),children:(0,t.jsx)(j,{action:a,isExpanded:S.has(a.actionId),onToggleExpand:()=>D(a.actionId),onSendNow:()=>_.handleSendNow(a.workflowId,a.actionId),onToggleSuppress:()=>_.handleActionToggle(a.actionId,"suppressed"===a.status),isSending:_.sendingActionId===a.actionId,isSent:_.sentActionIds.has(a.actionId),isToggling:_.actionLoadingIds.has(a.actionId),globalSuppressed:_.isSuppressed,previewsLoaded:_.previewsLoaded,effectivelyPast:"completed"===e.status||"pending"===e.status})})]},e.id):(0,t.jsx)(en,{item:e},e.id)})})]},e.phase)})})]})}],374326);var eo=e.i(441868),ed=e.i(98919),ec=e.i(810980),em=e.i(808554),em=em,eu=e.i(343432),eh=e.i(755481);e.s(["PhoneOff",()=>eh.default],514052);var eh=eh,ex=e.i(178583),eg=e.i(107233),ep=e.i(382373);let eb="https://api.vanio.ai";e.s(["AILabPanel",0,function({reservationId:e,listingId:i,customerId:n,threadId:o,guestName:d,listingName:m}){let x,g,[p,y]=(0,a.useState)(null),[w,v]=(0,a.useState)(d),k=w||d,[j,N]=(0,a.useState)(!0),[C,S]=(0,a.useState)([]),[E,I]=(0,a.useState)(""),[T,_]=(0,a.useState)(!1),[A,D]=(0,a.useState)(null),[P,R]=(0,a.useState)([]),[M,F]=(0,a.useState)(()=>`lab-${Date.now()}`),[L,$]=(0,a.useState)(!1),[O,U]=(0,a.useState)(!1),B=(0,a.useRef)(null),[q,z]=(0,a.useState)("idle"),[H,W]=(0,a.useState)(300),[K,Y]=(0,a.useState)([]),J=(0,a.useRef)(null),Q=(0,a.useRef)(null),X=(0,a.useRef)(null),Z=(0,a.useRef)(null),ee=(0,a.useRef)(!1),et="active"===q||"connecting"===q,ea=(0,a.useCallback)(async()=>window.Twilio?.Device?window.Twilio.Device:new Promise((e,t)=>{let a=document.createElement("script");a.src="https://unpkg.com/@twilio/[email protected]/dist/twilio.min.js",a.onload=()=>e(window.Twilio.Device),a.onerror=()=>t(Error("Failed to load Twilio SDK")),document.head.appendChild(a)}),[]),er=(0,a.useCallback)(()=>{if(Z.current&&(clearInterval(Z.current),Z.current=null),X.current&&(X.current.close(),X.current=null),Q.current){try{Q.current.disconnect()}catch{}Q.current=null}if(J.current){try{J.current.destroy()}catch{}J.current=null}ee.current=!1},[]),es=(0,a.useCallback)(()=>{er(),z("ended")},[er]),ei=(0,a.useCallback)(async()=>{if(!ee.current&&"active"!==q){ee.current=!0,z("connecting"),Y([]),W(300);try{let t=await fetch(`${eb}/ai/lab/voice-token?_dev_customerId=${n}`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({reservationId:e,listingId:i,threadId:o,guestName:k})});if(!t.ok)throw Error("Failed to get voice token");let{twilioToken:a,sessionToken:r,voiceServerWs:s}=await t.json();if(!a||!s)throw Error("Voice not configured");let l=new WebSocket(`${s}/demo-feed?token=${encodeURIComponent(r)}`);X.current=l,l.onmessage=e=>{try{let t=JSON.parse(e.data);"listening"===t.type&&t.text?Y(e=>[...e,{type:"message",role:"guest",text:t.text}]):"tool_call"===t.type?Y(e=>[...e,{type:"tool",toolName:t.name,toolStatus:"started",toolDescription:t.description}]):"tool_result"===t.type?Y(e=>{let a=e.findLastIndex(e=>"tool"===e.type&&e.toolName===t.name&&"started"===e.toolStatus);if(-1===a)return e;let r=[...e];return r[a]={...r[a],toolStatus:"result",toolDescription:t.description},r}):"responding"===t.type?Y(e=>[...e,{type:"message",role:"ai",text:"",streaming:!0}]):"text_delta"===t.type&&t.text?Y(e=>{let a=e.findLastIndex(e=>"message"===e.type&&"ai"===e.role&&e.streaming);if(-1===a)return e;let r=[...e];return r[a]={...r[a],text:(r[a].text||"")+t.text},r}):"done"===t.type&&Y(e=>{let t=e.findLastIndex(e=>"message"===e.type&&"ai"===e.role&&e.streaming);if(-1===t)return e;let a=[...e];return a[t]={...a[t],streaming:!1},a})}catch{}},l.onclose=()=>{X.current=null};try{let e=new(window.AudioContext||window.webkitAudioContext);"suspended"===e.state&&await e.resume();let t=e.createBuffer(1,1,22050),a=e.createBufferSource();a.buffer=t,a.connect(e.destination),a.start(0)}catch{}let d=new(await ea())(a,{edge:"ashburn"});J.current=d,await d.register();let c=await d.connect({params:{demoToken:r}});Q.current=c,c.on("accept",()=>{z("active"),Z.current=setInterval(()=>{W(e=>e<=1?(es(),0):e-1)},1e3)}),c.on("disconnect",()=>{z("ended"),er()}),c.on("error",()=>{z("ended"),er()})}catch(e){console.error("[AILab Voice] Start error:",e),z("idle"),er()}}},[n,e,i,o,k,q,ea,er,es]),en=(0,a.useCallback)(()=>{"active"===q||"connecting"===q?(es(),z("idle")):ei()},[q,es,ei]);(0,a.useEffect)(()=>()=>er(),[er]),(0,a.useEffect)(()=>
24{if(!n)return;N(!0);let t=new URLSearchParams({_dev_customerId:String(n)});e&&t.set("reservationId",String(e)),i&&t.set("listingId",String(i)),fetch(`${eb}/ai/context-summary?${t}`,{credentials:"include"}).then(e=>e.ok?e.json():null).then(e=>{e&&(y(e),e.guestName&&v(e.guestName))}).catch(()=>{}).finally(()=>N(!1))},[n,e,i]),(0,a.useEffect)(()=>{o&&n&&fetch(`${eb}/ai/lab?threadId=${o}&_dev_customerId=${n}`,{credentials:"include"}).then(e=>e.ok?e.json():null).then(e=>{e?.conversations?.length&&(R(e.conversations),F(e.conversations[0].conversationId),el(e.conversations[0].conversationId))}).catch(()=>{})},[o,n]);let el=e=>{o&&n&&(U(!0),fetch(`${eb}/ai/lab?threadId=${o}&conversationId=${e}&_dev_customerId=${n}`,{credentials:"include"}).then(e=>e.ok?e.json():null).then(e=>{e?.messages&&S(e.messages.map(e=>({role:e.role,content:e.content,toolCalls:e.toolCalls,latencyMs:e.latencyMs,supervisor:e.supervisor,sources:e.sources,timestamp:e.createdAt||e.timestamp})))}).catch(()=>{}).finally(()=>U(!1)))},ef=(e,t,a,r)=>{o&&n&&t&&fetch(`${eb}/ai/lab?_dev_customerId=${n}`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({threadId:o,conversationId:a,role:e,content:t,metadata:r})}).catch(()=>{})};(0,a.useEffect)(()=>{B.current?.scrollIntoView({behavior:"smooth"})},[C,T]);let ey=(0,a.useCallback)(async()=>{let t;if(!E.trim()||T||!o)return;let a=E.trim(),r=new Date().toISOString();I(""),S(e=>[...e,{role:"user",content:a,timestamp:r}]),ef("user",a,M),_(!0);let s=Date.now(),i="",l=[],d=null;try{let r=k||"Guest",c=await fetch(`${eb}/chat/dashboard/${o}?_dev_customerId=${n}&_dev_userId=test&_dev_userName=${encodeURIComponent(r)}`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({query:a,source:"lab",reservationId:e})});if(!c.ok)throw Error("Stream failed");let m=c.body?.getReader(),u=new TextDecoder;S(e=>[...e,{role:"assistant",content:"",timestamp:new Date().toISOString()}]);let h="";for(;m;){let{done:e,value:a}=await m.read();if(e)break;let r=(h+=u.decode(a,{stream:!0})).split("\n");for(let e of(h=r.pop()||"",r)){let a=e.trim();if(a.startsWith("data: "))try{let e=JSON.parse(a.slice(6));if("text-delta"===e.type&&e.delta)i+=e.delta,S(e=>{let t=[...e];return t[t.length-1]={...t[t.length-1],content:i},t});else if("tool-input-available"===e.type&&e.toolName)l.push({toolCallId:e.toolCallId,name:e.toolName,args:e.input||{},result:null}),S(e=>{let t=[...e];return t[t.length-1]={...t[t.length-1],toolCalls:[...l]},t});else if("tool-output-available"===e.type){let t=l.find(t=>t.toolCallId===e.toolCallId)||l.find(e=>!e.result);t&&(t.result=e.output),S(e=>{let t=[...e];return t[t.length-1]={...t[t.length-1],toolCalls:[...l]},t})}else"procedure-info"===e.type?(t={id:e.procedureId,title:e.procedureTitle},S(e=>{let a=[...e];return a[a.length-1]={...a[a.length-1],procedureInfo:t},a})):"lab-metadata"===e.type&&(d=e)}catch{}}}let x=Date.now()-s,g=l.length>0?l:Array.isArray(d?.toolCalls)?d.toolCalls:void 0;i&&ef("assistant",i,M,{toolCalls:g,latencyMs:x,supervisor:d?.supervisor,sources:d?.sources}),S(e=>{let a=[...e],r=a[a.length-1];return r?.role==="assistant"&&(a[a.length-1]={...r,content:i,toolCalls:g,latencyMs:x,supervisor:d?.supervisor||null,sources:d?.sources?.length?d.sources:void 0,procedureInfo:t}),a}),o&&n&&fetch(`${eb}/ai/lab?threadId=${o}&_dev_customerId=${n}`,{credentials:"include"}).then(e=>e.ok?e.json():null).then(e=>{e?.conversations&&R(e.conversations)}).catch(()=>{})}catch{S(e=>{let t=[...e],a=t[t.length-1];return a?.role!=="assistant"||a.content||(t[t.length-1]={...a,content:"Error: Failed to get AI response."}),t})}finally{_(!1)}},[E,T,o,n,e,M]),ew={active:{bg:"bg-emerald-500/10",text:"text-emerald-600 dark:text-emerald-400",border:"border-emerald-500/20",icon:b.Eye},shadow:{bg:"bg-amber-500/10",text:"text-amber-600 dark:text-amber-400",border:"border-amber-500/20",icon:f.EyeOff},disabled:{bg:"bg-red-500/10",text:"text-red-600 dark:text-red-400",border:"border-red-500/20",icon:u.XCircle}};return(0,t.jsxs)("div",{className:"flex flex-col h-full",children:[(0,t.jsx)("div",{className:"shrink-0 px-4 py-3 border-b border-gray-200 dark:border-white/[0.08] bg-gray-50 dark:bg-white/[0.02]",children:j?(0,t.jsx)("div",{className:"flex gap-2",children:Array.from({length:5}).map((e,a)=>(0,t.jsx)(s.Skeleton,{className:"h-8 w-24 rounded-lg"},a))}):p?(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(g=(x=ew[p.aiMode]||ew.disabled).icon,(0,t.jsxs)("div",{className:(0,r.cn)("flex items-center gap-1.5 px-2.5 py-1 rounded-lg border text-xs font-medium",x.bg,x.text,x.border),children:[(0,t.jsx)(g,{className:"w-3 h-3"}),"active"===p.aiMode?"Live":"shadow"===p.aiMode?"Shadow":"Disabled"]})),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-lg border border-gray-200 dark:border-white/[0.08] bg-white dark:bg-white/[0.03] text-xs text-gray-600 dark:text-white/50",children:[(0,t.jsx)(V.Brain,{className:"w-3 h-3"}),p.assignment?.userName||"Unassigned"]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-lg border border-gray-200 dark:border-white/[0.08] bg-white dark:bg-white/[0.03] text-xs text-gray-600 dark:text-white/50",children:[(0,t.jsx)(ec.BookOpen,{className:"w-3 h-3"}),p.kbCount," KB"]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-lg border border-gray-200 dark:border-white/[0.08] bg-white dark:bg-white/[0.03] text-xs text-gray-600 dark:text-white/50",children:[(0,t.jsx)(G.Zap,{className:"w-3 h-3"}),p.skillsCount," skills"]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-lg border border-gray-200 dark:border-white/[0.08] bg-white dark:bg-white/[0.03] text-xs text-gray-600 dark:text-white/50",children:[(0,t.jsx)(em.default,{className:"w-3 h-3"}),p.rulesCount," rules"]}),p.portalStatus&&(0,t.jsxs)("div",{className:(0,r.cn)("flex items-center gap-1.5 px-2.5 py-1 rounded-lg border text-xs","verified"===p.portalStatus?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20":"bg-
24amber-500/10 text-amber-600 dark:text-amber-400 border-amber-500/20"),children:[(0,t.jsx)(ed.Shield,{className:"w-3 h-3"}),"verified"===p.portalStatus?"Verified":"Unverified"]})]}):null}),(0,t.jsxs)("div",{className:"shrink-0 px-4 py-2.5 border-b border-gray-200 dark:border-white/[0.06] flex items-center justify-between relative",children:[O&&0===C.length?(0,t.jsx)(s.Skeleton,{className:"h-5 w-48 rounded"}):(0,t.jsxs)("button",{onClick:()=>$(!L),className:"flex items-center gap-1.5 text-sm text-gray-500 dark:text-white/40 hover:text-gray-700 dark:hover:text-white/60 transition-colors",children:[(0,t.jsx)(ex.FileText,{className:"w-3.5 h-3.5"}),(0,t.jsxs)("span",{className:"truncate max-w-[250px]",children:[P.find(e=>e.conversationId===M)?.firstUserMessage?.substring(0,40)||"New conversation",P.length>1&&(0,t.jsxs)("span",{className:"text-gray-400 dark:text-white/20 ml-1",children:["(",P.length,")"]})]}),(0,t.jsx)(c.ChevronDown,{className:"w-3.5 h-3.5"})]}),(0,t.jsxs)("button",{onClick:()=>{F(`lab-${Date.now()}`),S([]),$(!1),D(null)},className:"flex items-center gap-1 text-xs font-medium text-indigo-500 hover:text-indigo-400 transition-colors",children:[(0,t.jsx)(eg.Plus,{className:"w-3.5 h-3.5"})," New"]}),L&&P.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"fixed inset-0 z-10",onClick:()=>$(!1)}),(0,t.jsx)("div",{className:"absolute left-4 top-full mt-1 z-20 w-72 bg-white dark:bg-[#2A2A2C] border border-gray-200 dark:border-white/[0.1] rounded-lg shadow-lg overflow-hidden",children:(0,t.jsx)("div",{className:"max-h-48 overflow-y-auto",children:P.map(e=>(0,t.jsxs)("button",{onClick:()=>{var t;F(t=e.conversationId),S([]),$(!1),D(null),el(t)},className:(0,r.cn)("w-full flex items-center gap-2 px-3 py-2.5 text-left text-sm transition-colors",e.conversationId===M?"bg-indigo-500/10 text-indigo-600 dark:text-indigo-400":"text-gray-600 dark:text-white/60 hover:bg-gray-100 dark:hover:bg-white/[0.05]"),children:[(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("p",{className:"truncate font-medium",children:e.firstUserMessage?.substring(0,50)||"Empty"}),(0,t.jsxs)("p",{className:"text-xs text-gray-400 dark:text-white/25 mt-0.5",children:[e.messageCount," msgs · ",new Date(e.lastMessageAt).toLocaleDateString()]})]}),e.conversationId===M&&(0,t.jsx)("div",{className:"w-1.5 h-1.5 rounded-full bg-indigo-500 shrink-0"})]},e.conversationId))})})]})]}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto px-4 py-4 space-y-4",children:[O?(0,t.jsx)("div",{className:"space-y-3",children:Array.from({length:3}).map((e,a)=>(0,t.jsxs)("div",{className:(0,r.cn)("flex gap-2.5",a%2==0?"justify-end":"justify-start"),children:[a%2!=0&&(0,t.jsx)(s.Skeleton,{className:"w-7 h-7 rounded-full shrink-0"}),(0,t.jsx)(s.Skeleton,{className:(0,r.cn)("rounded-2xl",a%2==0?"w-48 h-10":"w-64 h-16")}),a%2==0&&(0,t.jsx)(s.Skeleton,{className:"w-7 h-7 rounded-full shrink-0"})]},a))}):0===C.length?(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-center py-12",children:[(0,t.jsx)(V.Brain,{className:"w-10 h-10 text-gray-300 dark:text-white/15 mb-3"}),(0,t.jsx)("p",{className:"text-sm font-medium text-gray-500 dark:text-white/40",children:"AI Lab"}),(0,t.jsxs)("p",{className:"text-xs text-gray-400 dark:text-white/25 mt-1 max-w-xs",children:["Test Vanio AI as a guest would experience it.",k&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("br",{}),"Guest: ",k]}),m&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("br",{}),"Property: ",m]})]})]}):C.map((e,a)=>{var r,s;let i;return(0,t.jsx)("div",{children:"user"===e.role?(0,t.jsxs)("div",{className:"flex gap-2.5 justify-end",children:[(0,t.jsxs)("div",{className:"max-w-[80%]",children:[(0,t.jsx)("div",{className:"rounded-2xl rounded-br-md px-4 py-3 text-[15px] leading-relaxed bg-indigo-600 text-white",children:e.content}),(0,t.jsx)("p",{className:"text-xs mt-1 text-right text-gray-400 dark:text-white/20",children:(r=e.timestamp)?new Date(r).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""})]}),(0,t.jsx)("div",{className:"w-7 h-7 rounded-full bg-indigo-600 shrink-0 mt-0.5 flex items-center justify-center",children:(0,t.jsx)("span",{className:"text-white text-xs font-semibold",children:(k||"G").charAt(0).toUpperCase()})})]}):(0,t.jsx)(eo.AIMessage,{message:(s=T&&a===C.length-1,i=e.toolCalls?.some(e=>
24e.name?.startsWith("skill:")),{id:`lab-${a}`,timestamp:e.timestamp||new Date().toISOString(),actor:{name:"Vanio AI",avatar:"/Vanio.ai.png"},data:{message:e.content,metadata:{isStreaming:s&&!e.content,streamComplete:!s,aiContent:{actions:(Array.isArray(e.toolCalls)?e.toolCalls:[]).map(e=>{let t=e.result?.output||e.result,a=e.args?.displayName||e.name,r=e.args?.summary||t?.note||t?.message||"Completed";return{type:i?a:e.name,params:i?{}:e.args||{},status:"completed",priority:"medium",result:{success:!0,message:r}}}),statements:[],sources:(e.sources||[]).map((e,t)=>({id:String(t),label:e.title||e.category||"KB Article"}))},procedureInfo:e.procedureInfo,vanioResult:{mode:"active",type:"answer",source:"lab",...e.supervisor&&{supervisor:e.supervisor}}}}}),isLoading:T&&a===C.length-1&&!e.content})},a)}),(0,t.jsx)("div",{ref:B})]}),("active"===q||"connecting"===q)&&(0,t.jsxs)("div",{className:"absolute inset-0 z-30 flex flex-col bg-white dark:bg-[#1C1C1E]",children:[(0,t.jsxs)("div",{className:"shrink-0 px-4 py-3 border-b border-gray-200 dark:border-white/[0.08] flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("div",{className:(0,r.cn)("w-2.5 h-2.5 rounded-full","active"===q?"bg-emerald-500 animate-pulse":"bg-amber-500 animate-pulse")}),(0,t.jsx)("span",{className:"text-sm font-medium text-gray-700 dark:text-white/70",children:"connecting"===q?"Connecting...":`Voice Call â ${Math.floor(H/60)}:${String(H%60).padStart(2,"0")}`})]}),(0,t.jsx)("button",{onClick:()=>{es(),z("idle")},className:"px-3 py-1.5 text-xs font-medium rounded-lg bg-red-500/10 text-red-500 hover:bg-red-500/20 border border-red-500/20 transition-colors",children:"End Call"})]}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto px-4 py-4 space-y-3",children:[0===K.length&&"active"===q&&(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-center",children:[(0,t.jsx)(ep.Volume2,{className:"w-8 h-8 text-gray-300 dark:text-white/15 mb-2 animate-pulse"}),(0,t.jsx)("p",{className:"text-sm text-gray-400 dark:text-white/30",children:"Speak to Vanio AI..."}),(0,t.jsx)("p",{className:"text-xs text-gray-300 dark:text-white/20 mt-1",children:"ElevenLabs + Deepgram â production pipeline"})]}),K.map((e,a)=>(0,t.jsxs)("div",{children:["message"===e.type&&"guest"===e.role&&(0,t.jsxs)("div",{className:"flex gap-2.5 justify-end",children:[(0,t.jsx)("div",{className:"max-w-[80%]",children:(0,t.jsx)("div",{className:"rounded-2xl rounded-br-md px-4 py-3 text-[15px] bg-indigo-600 text-white",children:e.text})}),(0,t.jsx)("div",{className:"w-7 h-7 rounded-full bg-indigo-600 shrink-0 mt-0.5 flex items-center justify-center",children:(0,t.jsx)(eu.Phone,{className:"w-3 h-3 text-white"})})]}),"message"===e.type&&"ai"===e.role&&(0,t.jsxs)("div",{className:"flex gap-2.5",children:[(0,t.jsx)("div",{className:"w-7 h-7 rounded-full bg-gray-100 dark:bg-white/[0.08] shrink-0 mt-0.5 flex items-center justify-center overflow-hidden",children:(0,t.jsx)("img",{src:"/Vanio.ai.png",alt:"",className:"w-full h-full object-cover"})}),(0,t.jsx)("div",{className:"max-w-[80%]",children:(0,t.jsx)("div",{className:(0,r.cn)("rounded-2xl rounded-bl-md px-4 py-3 text-[15px] bg-gray-100 dark:bg-white/[0.06] text-gray-900 dark:text-white",e.streaming&&"animate-pulse"),children:e.text||(0,t.jsx)(l.Loader2,{className:"w-4 h-4 animate-spin text-gray-400"})})})]}),"tool"===e.type&&(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 mx-8 text-xs rounded-lg bg-amber-500/5 dark:bg-amber-500/10 text-amber-600 dark:text-amber-400 border border-amber-500/10 dark:border-amber-500/20",children:["started"===e.toolStatus?(0,t.jsx)(l.Loader2,{className:"w-3 h-3 animate-spin"}):(0,t.jsx)(G.Zap,{className:"w-3 h-3"}),(0,t.jsx)("span",{className:"font-medium",children:e.toolName}),e.toolDescription&&(0,t.jsxs)("span",{className:"text-amber-500/60 dark:text-amber-400/50 truncate",children:["â ",e.toolDescription]})]})]},a))]})]}),(0,t.jsxs)("div",{className:"shrink-0 px-4 py-3 border-t border-gray-200 dark:border-white/[0.08] bg-white dark:bg-[#1C1C1E]",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("button",{onClick:en,disabled:"connecting"===q,className:(0,r.cn)("flex items-center gap-1.5 px-3 py-2.5 rounded-xl text-xs font-medium transition-colors","active"===q||"connecting"===q?"bg-red-500/10 text-red-500 hover:bg-red-500/20 border border-red-500/20":"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 hover:bg-emerald-500/20 border border-emerald-500/20","disabled:opacity-50"),title:et?"End voice call":"Test as a phone call",children:"connecting"===q?(0,t.jsx)(l.L
24oader2,{className:"w-4 h-4 animate-spin"}):et?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eh.default,{className:"w-3.5 h-3.5"})," End"]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eu.Phone,{className:"w-3.5 h-3.5"})," Call"]})}),(0,t.jsx)("input",{value:E,onChange:e=>I(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),ey())},placeholder:"Ask as a guest...",disabled:T||et,className:(0,r.cn)("flex-1 px-4 py-3 rounded-xl text-base","bg-gray-100 dark:bg-white/[0.06] border border-gray-200 dark:border-white/[0.08]","text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-white/25","focus:outline-none focus:border-indigo-500/40 focus:ring-1 focus:ring-indigo-500/20","disabled:opacity-50")}),(0,t.jsx)("button",{onClick:ey,disabled:!E.trim()||T||et,className:"p-2.5 rounded-xl bg-indigo-600 text-white hover:bg-indigo-500 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:T?(0,t.jsx)(l.Loader2,{className:"w-4 h-4 animate-spin"}):(0,t.jsx)(h.Send,{className:"w-4 h-4"})})]}),(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-white/20 mt-1.5 text-center",children:et?"Live voice call â Twilio + ElevenLabs + Deepgram":"Text mode â type or tap mic for voice"})]})]})}],569687);var ef=e.i(846932),ey=e.i(618566),ew=e.i(284614),ev=e.i(607486),ek=e.i(263488),ej=e.i(174886),eN=e.i(643531);function eC({owner:e,ownerName:a}){let s=(0,ey.useRouter)();return(0,t.jsx)("section",{className:"space-y-3",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[e.avatarUrl?(0,t.jsx)("img",{src:e.avatarUrl,alt:a,className:"w-12 h-12 rounded-full object-cover flex-shrink-0"}):(0,t.jsx)("div",{className:"w-12 h-12 rounded-full bg-gray-200 dark:bg-white/[0.08] flex items-center justify-center flex-shrink-0",children:(0,t.jsx)(ew.User,{className:"w-6 h-6 text-gray-400 dark:text-white/40"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("h3",{className:(0,r.cn)("text-base font-semibold text-gray-900 dark:text-white truncate",e.id&&"cursor-pointer hover:text-blue-500 dark:hover:text-blue-400 transition-colors"),onClick:()=>e.id&&s.push(`/owners/${e.id}`),children:a}),e.companyName&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 mt-0.5",children:[(0,t.jsx)(ev.Building2,{className:"w-3.5 h-3.5 text-gray-400 dark:text-white/40 flex-shrink-0"}),(0,t.jsx)("span",{className:"text-sm text-gray-500 dark:text-white/60 truncate",children:e.companyName})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 mt-1.5",children:[(0,t.jsx)("span",{className:(0,r.cn)("text-xs font-medium px-2 py-0.5 rounded-full border",{active:"bg-green-500/10 text-green-500 border-green-500/20",lead:"bg-blue-500/10 text-blue-500 border-blue-500/20",contacted:"bg-yellow-500/10 text-yellow-500 border-yellow-500/20",proposal_sent:"bg-purple-500/10 text-purple-500 border-purple-500/20",onboarding:"bg-orange-500/10 text-orange-500 border-orange-500/20",churned:"bg-red-500/10 text-red-500 border-red-500/20"}[e.status]||"bg-gray-100 text-gray-500 border-gray-200 dark:bg-white/[0.05] dark:text-white/50 dark:border-white/[0.1]"),children:{active:"Active",lead:"Lead",contacted:"Contacted",proposal_sent:"Proposal Sent",onboarding:"Onboarding",churned:"Churned"}[e.status]||e.status}),e.source&&(0,t.jsxs)("span",{className:"text-xs text-gray-400 dark:text-white/30",children:["via ",e.source.replace(/_/g," ")]})]})]})]})})}function eS({owner:e}){let[r,s]=(0,a.useState)(null),i=(0,a.useCallback)(async(e,t)=>{try{await navigator.clipboard.writeText(e),s(t),setTimeout(()=>s(null),2e3)}catch{}},[]);return e.primaryEmail||e.primaryPhone?(0,t.jsxs)("section",{className:"space-y-2",children:[(0,t.jsx)("h4",{className:"text-xs font-medium text-gray-400 dark:text-white/40 uppercase tracking-wider",children:"Contact"}),e.primaryEmail&&(0,t.jsxs)("button",{onClick:()=>i(e.primaryEmail,"email"),className:"w-full flex items-center gap-2.5 p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.03] transition-colors group",children:[(0,t.jsx)(ek.Mail,{className:"w-4 h-4 text-gray-400 dark:text-white/40 flex-shrink-0"}),(0,t.jsx)("span",{className:"text-sm text-gray-700 dark:text-white/80 truncate flex-1 text-left",children:e.primaryEmail}),"email"===r?(0,t.jsx)(eN.Check,{className:"w-3.5 h-3.5 text-green-500 flex-shrink-0"}):(0,t.jsx)(ej.Copy,{className:"w-3.5 h-3.5 text-gray-300 dark:text-white/20 opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0"})]}),e.primaryPhone&&(0,t.jsxs)("button",{onClick:()=>i(e.primaryPhone,"phone"),className:"w-full flex items-center gap-2.5 p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.03] transition-colors group",children:[(0,t.jsx)(eu.Phone,{className:"w-4 h-4 text-gray-400 dark:text-white/40 flex-shrink-0"}),(0,t.jsx)("span",{className:"text-sm text-gray-700 dark:text-white/80 truncate flex-1 text-left",children:e.primaryPhone}
24),"phone"===r?(0,t.jsx)(eN.Check,{className:"w-3.5 h-3.5 text-green-500 flex-shrink-0"}):(0,t.jsx)(ej.Copy,{className:"w-3.5 h-3.5 text-gray-300 dark:text-white/20 opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0"})]})]}):null}function eE({listings:e}){let a=(0,ey.useRouter)();return e.length?(0,t.jsxs)("section",{className:"space-y-2",children:[(0,t.jsx)("div",{className:"flex items-center justify-between",children:(0,t.jsxs)("h4",{className:"text-xs font-medium text-gray-400 dark:text-white/40 uppercase tracking-wider",children:["Properties (",e.length,")"]})}),(0,t.jsx)("div",{className:"space-y-1",children:e.map(e=>(0,t.jsxs)("button",{onClick:()=>a.push(`/listings/${e.id}`),className:"w-full flex items-center gap-2.5 p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.03] transition-colors group text-left",children:[(0,t.jsx)(Y.Home,{className:"w-4 h-4 text-gray-400 dark:text-white/40 flex-shrink-0"}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("div",{className:"text-sm text-gray-700 dark:text-white/80 truncate",children:e.name}),e.address&&(0,t.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/30 truncate",children:e.address})]}),e.ownershipType&&(0,t.jsx)("span",{className:"text-[10px] text-gray-400 dark:text-white/30 bg-gray-100 dark:bg-white/[0.05] px-1.5 py-0.5 rounded flex-shrink-0",children:e.ownershipType}),(0,t.jsx)(d.ChevronRight,{className:"w-3.5 h-3.5 text-gray-300 dark:text-white/15 opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0"})]},e.id))})]}):null}function eI({stats:e}){let a,r;return(0,t.jsxs)("section",{className:"space-y-2",children:[(0,t.jsx)("h4",{className:"text-xs font-medium text-gray-400 dark:text-white/40 uppercase tracking-wider",children:"Overview"}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,t.jsxs)("div",{className:"p-2.5 rounded-lg bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.06]",children:[(0,t.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/40",children:"Listings"}),(0,t.jsx)("div",{className:"text-lg font-semibold text-gray-900 dark:text-white mt-0.5",children:e.totalListings})]}),(0,t.jsxs)("div",{className:"p-2.5 rounded-lg bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.06]",children:[(0,t.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/40",children:"Reservations"}),(0,t.jsx)("div",{className:"text-lg font-semibold text-gray-900 dark:text-white mt-0.5",children:e.totalReservations})]}),e.totalRevenue>0&&(0,t.jsxs)("div",{className:"col-span-2 p-2.5 rounded-lg bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.06]",children:[(0,t.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/40",children:"Total Revenue"}),(0,t.jsx)("div",{className:"text-lg font-semibold text-gray-900 dark:text-white mt-0.5",children:(a=e.totalRevenue,r=e.currency,new Intl.NumberFormat("en-US",{style:"currency",currency:r||"USD",minimumFractionDigits:0,maximumFractionDigits:0}).format(a))})]})]})]})}function eT({isActive:e,onClick:a,label:s,mobileLabel:i,count:n,type:l,variant:o="primary",subCounts:d,countClassName:c}){return(0,t.jsxs)("button",{onClick:a,className:(0,r.cn)("relative flex items-center gap-2 transition-all",{"px-4 h-9 text-sm font-medium bg-gray-100 dark:bg-white/[0.08] rounded-l-full":"primary"===o,"px-4 h-9 text-sm font-medium bg-gray-100 dark:bg-white/[0.08]":"secondary"===o,"rounded-r-full":"lab"===l,"-ml-[1px] border-l border-white/[0.15]":["chat","timeline","lifecycle","lab"].includes(l),"px-4 h-9 text-xs rounded-full ml-2":"tertiary"===o,"!bg-white/[0.15] text-gray-900 dark:text-white":e&&("primary"===o||"secondary"===o),"bg-white/[0.08] text-gray-900 dark:text-white":e&&"tertiary"===o,"hover:bg-white/[0.12]":!e&&("primary"===o||"secondary"===o),"hover:bg-white/[0.08]":!e&&"tertiary"===o}),children:[i?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"md:hidden",children:i}),(0,t.jsx)("span",{className:"hidden md:inline",children:s})]}):(0,t.jsx)("span",{children:s}),n>0&&("primary"===o||"tertiary"===o)&&(0,t.jsx)("span",{className:(0,r.cn)("min-w-[22px] h-5 text-xs rounded-full flex items-center justify-center",{"bg-white/[0.15]":"primary"===o,"bg-white/[0.12]":"tertiary"===o},n>=100?"min-w-[28px] px-1":"",c),children:n})]})}e.s(["OwnerSidebar",0,function({data:e,onAction:a,className:s,itemId:i}){let n=e?.owner,l=e?.listings||[],o=e?.stats;if(!n)return(0,t.jsx)("div",{className:(0,r.cn)("h-full overflow-y-auto p-6 border-l border-gray-200 dark:border-white/[0.08] bg-gray-50 dark:bg-[#18181A]",s),children:(0,t.jsx)("div",{className:"text-sm text-gray-400 dark:text-white/40",children:"No owner data available"})});let d=`${n.firstName} ${n.lastName||""}`.trim();return(0,t.jsxs)(ef.motion.div,{initial:{opacity:0,x:20}
24,animate:{opacity:1,x:0},exit:{opacity:0,x:20},className:(0,r.cn)("h-full overflow-y-auto overflow-x-visible p-6 space-y-4 border-l border-gray-200 dark:border-white/[0.08] bg-gray-50 dark:bg-[#18181A]",s),onTouchStart:e=>e.stopPropagation(),onTouchEnd:e=>e.stopPropagation(),onTouchMove:e=>e.stopPropagation(),children:[(0,t.jsx)(eC,{owner:n,ownerName:d}),(0,t.jsx)("div",{className:"border-t border-gray-200 dark:border-white/[0.08]"}),(0,t.jsx)(eS,{owner:n}),(0,t.jsx)("div",{className:"border-t border-gray-200 dark:border-white/[0.08]"}),(0,t.jsx)(eE,{listings:l}),o&&(o.totalReservations>0||o.totalRevenue>0)&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"border-t border-gray-200 dark:border-white/[0.08]"}),(0,t.jsx)(eI,{stats:o})]})]})}],699346);let e_=[{id:"all",label:"Timeline"},{id:"message_send",label:"Messages"},{id:"task",label:"Tasks"},{id:"seam",label:"Locks"},{id:"webhook",label:"Webhooks"},{id:"review",label:"Reviews"},{id:"payment",label:"Payments"},{id:"slack",label:"Slack"}];e.s(["DashboardModalFilters",0,function({activeFilter:e,onFilterChange:s,counts:i,lifecycleActionFilter:n="all",onLifecycleActionFilterChange:l,className:o}){let d=(0,a.useMemo)(()=>[{id:"all",label:"Timeline",count:i.all,variant:"primary"},{id:"lifecycle",label:"Lifecycle",desktopLabel:"Workflow Lifecycle",count:0,variant:"secondary"},{id:"lab",label:"AI Lab",desktopLabel:"AI Lab",count:0,variant:"secondary"},{id:"messages",label:"Messages",count:i.messages.total,variant:"tertiary",subCounts:{internal:i.messages.internal,system:i.messages.system}},{id:"events",label:"Events",count:i.events.total,variant:"tertiary",subCounts:{reviews:i.events.review,payments:i.events.payment,activities:i.events.activity,reservations:i.events.reservation}},{id:"tasks",label:"Tasks",count:i.tasks?.total||0,variant:"tertiary",subCounts:{completed:i.tasks?.completed||0,pending:i.tasks?.pending||0}},{id:"issues",label:"Issues",count:i.issues.total,variant:"tertiary",subCounts:{open:i.issues.open,"in progress":i.issues.inProgress}},{id:"automations",label:"Automations",count:i.automations.total,variant:"tertiary",subCounts:{failed:i.automations.failed,pending:i.automations.pending,completed:i.automations.completed}}],[i]),c=d.filter(e=>["all","lifecycle","lab"].includes(e.id)),m=d.filter(e=>!["all","lifecycle","lab"].includes(e.id));return(0,t.jsx)("div",{className:(0,r.cn)("flex-none px-6 py-2 md:py-3 md:px-6 border-b border-gray-200 dark:border-white/[0.08] bg-white dark:bg-[#1C1C1E] max-w-full overflow-x-auto",o),children:(0,t.jsxs)("div",{className:"flex items-center gap-3 overflow-x-auto scrollbar-none max-w-full",children:[(0,t.jsx)("div",{className:"flex items-center",children:c.map(a=>(0,t.jsx)(eT,{isActive:e===a.id,onClick:()=>s(a.id),label:a.desktopLabel||a.label,mobileLabel:a.desktopLabel?a.label:void 0,count:a.count,type:a.id,variant:a.variant,subCounts:a.subCounts},a.id))}),"lab"===e?null:"lifecycle"===e?(0,t.jsx)("div",{className:"flex items-center gap-1",children:e_.map(e=>(0,t.jsx)("button",{onClick:()=>l?.(e.id),className:(0,r.cn)("px-3 h-9 text-xs rounded-full transition-colors whitespace-nowrap",n===e.id?"bg-gray-200/80 dark:bg-white/[0.08] text-gray-900 dark:text-white":"text-gray-500 dark:text-white/35 hover:bg-gray-100 dark:hover:bg-white/[0.05] hover:text-gray-700 dark:hover:text-white/55"),children:e.label},e.id))}):(0,t.jsx)("div",{className:"flex items-center gap-1",children:m.map(a=>(0,t.jsx)(eT,{isActive:e===a.id,onClick:()=>s(a.id),label:a.label,count:a.count,type:a.id,variant:a.variant,subCounts:a.subCounts},a.id))})]})})}],147361)},321814,435026,818836,e=>{"use strict";e.s(["UnifiedTimeline",()=>Z],321814);var t=e.i(843476),a=e.i(846932),r=e.i(88653),s=e.i(711219),i=e.i(646804),n=e.i(736381),l=e.i(301014),o=e.i(217255),d=e.i(271645),c=e.i(908263),m=e.i(932070),u=e.i(481755),h=e.i(695181),x=e.i(461250),g=e.i(662559),p=e.i(358037),b=e.i(63209),f=e.i(655900),y=e.i(531278),w=e.i(65921),v=e.i(846696),k=e.i(524983),j=e.i(394096),N=e.i(586433),C=e.i(625233),S=e.i(752087),E=e.i(686851),I=e.i(489800),T=e.i(602064),_=e.i(392257),A=e.i(94951),D=e.i(568612),P=e.i(201795),R=e.i(191741),M=e.i(463059);let F={todo:{label:"To do",dot:"bg-gray-400 dark:bg-white/40",text:"text-gray-500 dark:text-white/60"},pending:{label:"To do",dot:"bg-gray-400 dark:bg-white/40",text:"text-gray-500 dark:text-white/60"},in_progress:{label:"In progress",dot:"bg-blue-500",text:"text-blue-600 dar
24k:text-blue-300/80"},blocked:{label:"Blocked",dot:"bg-red-500",text:"text-red-600 dark:text-red-300/80"},completed:{label:"Complete",dot:"bg-emerald-500",text:"text-emerald-600 dark:text-emerald-300/80"},failed:{label:"Needs attention",dot:"bg-orange-500",text:"text-orange-600 dark:text-orange-300/80"}};function L(e){if(!e)return null;let[t,a,r]=String(e).slice(0,10).split("-").map(Number);return t&&a&&r?new Date(t,a-1,r).toLocaleDateString("en-US",{month:"short",day:"numeric"}):null}function $({task:e,isDark:a,onOpen:r}){let s=F[e.status||"todo"]||F.todo,i=L(e.dueDate),n=function(e){let t=String(e||"").slice(11,16);if(!/^\d{2}:\d{2}$/.test(t))return null;let[a,r]=t.split(":").map(Number);return`${a%12==0?12:a%12}:${String(r).padStart(2,"0")} ${a>=12?"PM":"AM"}`}(e.dueDate);return(0,t.jsx)("li",{children:(0,t.jsxs)("button",{type:"button",onClick:()=>r(e.id),className:(0,c.cn)("w-full flex items-center gap-3 rounded-lg px-3 py-2 text-left transition-colors duration-150",a?"border border-white/[0.06] bg-white/[0.02] hover:bg-white/[0.05] hover:border-white/[0.12]":"border border-gray-200 bg-white hover:bg-gray-50 hover:border-gray-300"),children:[(0,t.jsx)("span",{className:(0,c.cn)("w-2 h-2 rounded-full flex-none",s.dot)}),(0,t.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,t.jsx)("span",{className:(0,c.cn)("block truncate text-sm",a?"text-white/90":"text-gray-900","completed"===e.status&&"line-through opacity-70"),children:e.title||"Untitled task"}),(0,t.jsxs)("span",{className:"flex items-center gap-2 mt-0.5",children:[(0,t.jsx)("span",{className:(0,c.cn)("text-[11px]",s.text),children:s.label}),e.category&&(0,t.jsxs)("span",{className:(0,c.cn)("text-[11px]",a?"text-white/35":"text-gray-400"),children:["· ",String(e.category).replace(/_/g," ")]})]})]}),i&&(0,t.jsxs)("span",{className:(0,c.cn)("flex-none text-right",a?"text-white/50":"text-gray-500"),children:[(0,t.jsx)("span",{className:"block text-[11px] font-medium",children:i}),n&&(0,t.jsx)("span",{className:(0,c.cn)("block text-[10px]",a?"text-white/30":"text-gray-400"),children:n})]}),(0,t.jsx)(M.ChevronRight,{className:(0,c.cn)("w-4 h-4 flex-none",a?"text-white/30":"text-gray-300")})]})})}function O({isDark:e}){return(0,t.jsxs)("div",{className:(0,c.cn)("rounded-xl border",e?"border-white/[0.08] bg-white/[0.02]":"border-gray-200 bg-white"),children:[(0,t.jsxs)("div",{className:(0,c.cn)("px-4 py-3 border-b",e?"border-white/[0.08]":"border-gray-200"),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(w.Skeleton,{className:"h-4 w-4 rounded"}),(0,t.jsx)(w.Skeleton,{className:"h-4 w-56"}),(0,t.jsx)(w.Skeleton,{className:"h-4 w-10 rounded-full ml-auto"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3 mt-2",children:[(0,t.jsx)(w.Skeleton,{className:"h-3 w-16"}),(0,t.jsx)(w.Skeleton,{className:"h-3 w-20"}),(0,t.jsx)(w.Skeleton,{className:"h-3 w-16"}),(0,t.jsx)(w.Skeleton,{className:"h-3 w-20"})]})]}),(0,t.jsxs)("div",{className:"p-4 space-y-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(w.Skeleton,{className:"h-3 w-28"}),(0,t.jsx)(w.Skeleton,{className:"h-[52px] w-full rounded-lg"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(w.Skeleton,{className:"h-3 w-40"}),(0,t.jsx)(w.Skeleton,{className:"h-[52px] w-full rounded-lg"}),(0,t.jsx)(w.Skeleton,{className:"h-[52px] w-full rounded-lg"})]})]})]})}function U({overview:e,isDark:a,onOpen:r}){let s=e?.tasks||[],i=s.filter(e=>e.isBookingTask),n=s.filter(e=>!e.isBookingTask),l=L(e?.checkIn),o=L(e?.checkOut),d=l&&o?l===o?l:`${l} â ${o}`:null,m=e?.counts,u=m?.total??0;return(0,t.jsxs)("div",{className:(0,c.cn)("rounded-xl border",a?"border-white/[0.08] bg-white/[0.02]":"border-gray-200 bg-white"),children:[(0,t.jsxs)("div",{className:(0,c.cn)("px-4 py-3 border-b",a?"border-white/[0.08]":"border-gray-200"),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(R.ClipboardList,{className:(0,c.cn)("w-4 h-4 flex-none",a?"text-white/50":"text-gray-400")}),(0,t.jsx)("h3",{className:(0,c.cn)("text-sm font-medium",a?"text-white":"text-gray-900"),children:"Tasks at this property during this stay"}
24),(0,t.jsx)("span",{className:(0,c.cn)("ml-auto px-1.5 py-0.5 rounded-full text-[11px] font-medium flex-none",a?"bg-white/[0.06] text-white/50":"bg-gray-100 text-gray-500"),children:e?.truncated?`${u}+`:u})]}),(0,t.jsxs)("p",{className:(0,c.cn)("mt-1 text-[11px]",a?"text-white/40":"text-gray-500"),children:[d?`Due ${d} (check-in through check-out)`:"Due during this stay"," · all task types, cancelled excluded"]}),u>0&&m&&(0,t.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px]",children:[m.byStatus.todo>0&&(0,t.jsxs)("span",{className:F.todo.text,children:[m.byStatus.todo," to do"]}),m.byStatus.inProgress>0&&(0,t.jsxs)("span",{className:F.in_progress.text,children:[m.byStatus.inProgress," in progress"]}),m.byStatus.blocked>0&&(0,t.jsxs)("span",{className:F.blocked.text,children:[m.byStatus.blocked," blocked"]}),m.byStatus.completed>0&&(0,t.jsxs)("span",{className:F.completed.text,children:[m.byStatus.completed," complete"]})]})]}),0===u?(0,t.jsx)("div",{className:(0,c.cn)("px-4 py-6 text-center text-sm",a?"text-white/40":"text-gray-500"),children:"No tasks are due at this property during this stay."}):(0,t.jsxs)("div",{className:"p-4 space-y-4",children:[i.length>0&&(0,t.jsxs)("div",{children:[(0,t.jsxs)("p",{className:(0,c.cn)("mb-2 text-[11px] font-medium uppercase tracking-wide",a?"text-white/40":"text-gray-400"),children:["This booking · ",i.length]}),(0,t.jsx)("ul",{className:"space-y-1",children:i.map(e=>(0,t.jsx)($,{task:e,isDark:a,onOpen:r},e.id))})]}),n.length>0&&(0,t.jsxs)("div",{children:[(0,t.jsxs)("p",{className:(0,c.cn)("mb-2 text-[11px] font-medium uppercase tracking-wide",a?"text-white/40":"text-gray-400"),children:["Elsewhere at this property · ",n.length]}),(0,t.jsx)("ul",{className:"space-y-1",children:n.map(e=>(0,t.jsx)($,{task:e,isDark:a,onOpen:r},e.id))})]}),e?.truncated&&(0,t.jsxs)("p",{className:(0,c.cn)("px-1 text-[11px]",a?"text-white/40":"text-gray-400"),children:["Showing the first ",u," tasks â more are due at this property during this stay."]})]})]})}function B({reservationId:e,context:a="dashboard",className:r}){let{settings:s}=(0,D.useUserSettings)(),i=(s?.theme??"dark")!=="light",n=(0,P.useTaskSidebar)(e=>e.openSidebar),[l,o]=(0,d.useState)(null),[m,u]=(0,d.useState)(!0),[h,x]=(0,d.useState)(null);(0,d.useEffect)(()=>{if(!e)return void u(!1);let t=!1,a=new AbortController;return u(!0),x(null),fetch(`/api/reservations/${e}/property-tasks`,{signal:a.signal}).then(async e=>{if(!e.ok)throw Error(`Request failed (${e.status})`);return e.json()}).then(e=>{t||o(e)}).catch(e=>{t||e?.name==="AbortError"||x("Could not load the property tasks for this stay.")}).finally(()=>{t||u(!1)}),()=>{t=!0,a.abort()}},[e]);let g=(0,d.useCallback)(e=>{n(String(e),a)},[n,a]);return e?m?(0,t.jsx)("div",{className:r,children:(0,t.jsx)(O,{isDark:i})}):h?(0,t.jsx)("div",{className:r,children:(0,t.jsxs)("div",{className:(0,c.cn)("rounded-xl border px-4 py-3 flex items-center gap-2",i?"border-white/[0.08] bg-white/[0.02]":"border-gray-200 bg-white"),children:[(0,t.jsx)(b.AlertCircle,{className:"w-4 h-4 text-red-500 flex-none"}),(0,t.jsx)("span",{className:(0,c.cn)("text-sm",i?"text-white/70":"text-gray-600"),children:h})]})}):(0,t.jsx)("div",{className:r,children:(0,t.jsx)(U,{overview:l,isDark:i,onOpen:g})}):null}var q=e.i(886363),z=e.i(977380),H=e.i(498641),V=e.i(441868),G=e.i(63955),W=e.i(148499),K=e.i(289562),Y=e.i(367193),J=e.i(803181);let Q=e=>e instanceof Date?e.getTime():new Date(e).getTime();function X({activeFilter:e,sections:a,onShowOlder:r}){let s=(()=>{switch(e){case"messages":return["messages"];case"events":return["events"];case"issues":return["issues"];case"automations":return["automations"];case"tasks":return[];default:return["messages","events","issues","automations"]}})().map(e=>({type:e,state:a[e]})).filter(({state:e})=>e&&(e.hasMore||e.loading||e.error));if(0===s.length)return null;let i={messages:"Show older messages",events:"Show older events",issues:"Show older issues",automations:"Show older automations"};return(0,t.jsx)("div",{className:"flex flex-col gap-2 py-3",children:s.map(({type:e,state:a})=>(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[a.loading?(0,t.jsxs)("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg bg-gray-50 dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.06]",children:[(0,t.jsx)(y.Loader2,{className:"w-3.5 h-3.5 animate-spin text-gray-400 dark:text-white/40 flex-none"}),(0,t.jsxs)("div",{className:"flex-1 flex flex-col gap-1.5",children:[(0,t.jsx)(w.Skeleton,{className:"h-3 w-2/3 bg-gray-200 dark:bg-white/[0.06]"}),(0,t.jsx)(w.Skeleton,{className:"h-2.5 w-1/2 bg-gray-200 dark:bg-white/[0.05]"})]})]}):a.hasMore?(0,t.jsxs)("button",{type:"button",onClick:()=>
24r(e,a.nextCursor),className:(0,c.cn)("w-full flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-xs font-medium","bg-gray-50 hover:bg-gray-100 dark:bg-white/[0.03] dark:hover:bg-white/[0.06]","border border-gray-200 dark:border-white/[0.08]","text-gray-600 dark:text-white/70 hover:text-gray-900 dark:hover:text-white","transition-colors"),children:[(0,t.jsx)(f.ChevronUp,{className:"w-3.5 h-3.5"}),(0,t.jsx)("span",{children:i[e]})]}):null,a.error&&!a.loading&&(0,t.jsx)("div",{className:"text-xs text-red-500 dark:text-red-400 px-1",children:a.error})]},e))})}function Z({data:e,isLoading:b,onAction:f,onTyping:y,onCommandPaletteOpen:w,className:D,itemId:P,threadId:R,userId:M,customerId:F,activeFilter:L,onItemStatus:$,isActive:O,typingUsers:U=[],currentAssignment:ee,currentUserId:et}){let ea=(0,d.useRef)(null),[er,es]=(0,d.useState)(!0),[ei,en]=(0,d.useState)(0),el=(0,d.useRef)(0),eo=(0,d.useCallback)(()=>{let e=ea.current;e&&(e.scrollTo({top:e.scrollHeight,behavior:"smooth"}),en(0))},[]),{data:ed}=(0,o.useSession)(),[ec,em]=(0,d.useState)([]),[eu,eh]=(0,d.useState)({}),[ex,eg]=(0,d.useState)(null),[ep,eb]=(0,d.useState)(null),ef=(0,d.useRef)({}),[ey,ew]=(0,d.useState)(),[ev,ek]=(0,d.useState)(),ej=(0,d.useRef)(!1),eN=(0,d.useRef)(null),eC={olderItems:[],hasMore:!1,nextCursor:null,loading:!1,error:null},[eS,eE]=(0,d.useState)(eC),[eI,eT]=(0,d.useState)(eC),[e_,eA]=(0,d.useState)(eC),[eD,eP]=(0,d.useState)(eC),eR=(0,d.useRef)(null);(0,d.useEffect)(()=>{let t=e?.id!=null?String(e.id):null;if(!t||eR.current===t)return;eR.current=t;let a=e?.timelines?.messages?.pagination?.messages;eE({olderItems:[],hasMore:a?.hasMore??!1,nextCursor:a?.nextCursor??null,loading:!1,error:null});let r=e?.timelines?.events?.pagination?.seamLogs;eT({olderItems:[],hasMore:r?.hasMore??!1,nextCursor:r?.nextCursor??null,loading:!1,error:null});let s=e?.timelines?.issues?.pagination;eA({olderItems:[],hasMore:s?.hasMore??!1,nextCursor:s?.nextCursor??null,loading:!1,error:null});let i=e?.timelines?.automations?.pagination;eP({olderItems:[],hasMore:i?.hasMore??!1,nextCursor:i?.nextCursor??null,loading:!1,error:null})},[e?.id,e?.timelines]);let eM={messages:eE,events:eT,issues:eA,automations:eP},eF=(0,d.useCallback)(async(t,a)=>{if(!e?.id||null==a)return;let r=eM[t];r(e=>({...e,loading:!0,error:null}));try{let s=`/api/dashboard/item/timeline?id=${encodeURIComponent(String(e.id))}&type=${t}&before=${encodeURIComponent(String(a))}&limit=50`,i=await fetch(s,{credentials:"include"});if(!i.ok)throw Error(`HTTP ${i.status}`);let n=await i.json(),l=Array.isArray(n?.data)?n.data:[];r(e=>({olderItems:[...l,...e.olderItems],hasMore:!!n?.hasMore,nextCursor:n?.nextCursor??null,loading:!1,error:null}))}catch(a){let e=(0,J.toUserFacingError)(a,`Couldn't load older ${t} â please try again`);r(t=>({...t,loading:!1,error:e})),v.toast.error(e)}},[e?.id]);(0,d.useEffect)(()=>()=>{eN.current?.abort()},[]);let{messages:eL}=(0,h.useRealtimeMessages)(e?.metadata?.reservation?.id),e$=new Map,eO=(0,d.useMemo)(()=>{let t=e?.timelines?.messages?.data||[],a=eL||[],r=e?.timelines?.issues?.data||[],s=e?.timelines?.automations?.data||[],i=e?.timelines?.events?.data||[],n=i.filter(e=>"task"===e.type)||[],l=i.filter(e=>"task"!==e.type)||[],o=eS.olderItems,d=eI.olderItems,c=e_.olderItems,m=eD.olderItems,u=new Map,h=[];ec.forEach(e=>{e.id.startsWith("streaming-")&&e.data?.metadata?.streamComplete&&e.data?.message&&h.push({id:e.id,content:e.data.message,timestamp:new Date(e.timestamp).getTime()})});let x=new Set;return[...t,...a,...ec,...r,...s,...n,...l,...o,...d,...c,...m].forEach(e=>{if(h.length>0&&"ai_message"===e.type&&e.actor?.id==="vanio_ai"&&!e.id.startsWith("streaming-")&&e.data?.message){let t=new Date(e.timestamp).getTime();for(let a of h){let r=a.content===e.data.message,s=6e4>Math.abs(t-a.timestamp);if(r||s){x.add(a.id);break}}}e.id.startsWith("streaming-")&&x.has(e.id)||u.set(e.id,e)}),e$.forEach((e,t)=>{let a=e[0]?.timestamp;if(e.every(e=>e.timestamp===a)&&e.length>1){let t=e.find(e=>"data"in e&&"status"in e.data&&"published"===e.data.status);t&&u.set(t.id,t)}
24else e.forEach(e=>u.set(e.id,e))}),Array.from(u.values()).sort((e,t)=>Q(e.timestamp)-Q(t.timestamp))},[e?.timelines?.messages?.data,eL,ec,e?.timelines?.issues?.data,e?.timelines?.automations?.data,e?.timelines?.events?.data,eS.olderItems,eI.olderItems,e_.olderItems,eD.olderItems]),eU=(0,d.useMemo)(()=>eO.filter(e=>"ai_message"===e.type&&"string"==typeof e.id&&!e.id.startsWith("thinking-")&&!e.id.startsWith("local-")&&!isNaN(Number(e.id.replace("ai_","")))).map(e=>e.id.replace("ai_","")).sort().join(","),[eO]);(0,d.useEffect)(()=>{(async()=>{if(!eU)return;let e=eU.split(",");try{let t=await fetch(`/api/ai/ratings?messageIds=${e.join(",")}`),a=await t.json(),r=Object.entries(a).reduce((e,[t,a])=>(e[`ai_${t}`]={rating:a.rating,stats:{thumbs_up_count:a.stats.thumbs_up_count||0,thumbs_down_count:a.stats.thumbs_down_count||0,thumbs_up_users:a.stats.thumbs_up_users||[],thumbs_down_users:a.stats.thumbs_down_users||[]}},e),{});eh(r)}catch(e){console.error("Error fetching message ratings:",e)}})()},[eU]);let eB=(0,d.useCallback)(async(e,t,a,r,s,i,n,l)=>{let o=new AbortController;eN.current=o;let d="";try{let c=await fetch(`https://api.vanio.ai/chat/dashboard/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({query:a,reservationId:r,originalMessageId:s,source:i,feedback:n,previousAnswer:l}),signal:o.signal});if(!c.ok||!c.body){if(429===c.status)return void em(e=>e.filter(e=>e.id!==t));console.error("[VanioStream] Failed:",c.status);let e=403===c.status?await c.text().catch(()=>""):"",a=(0,Y.describeChatFailure)(e,"Sorry, I encountered an error. Please try again.");em(e=>e.map(e=>e.id===t?{...e,data:{...e.data,message:a,metadata:{isStreaming:!1}}}:e));return}let m=c.body.getReader(),u=new TextDecoder,h="";for(;;){let{done:e,value:a}=await m.read();if(e)break;let r=(h+=u.decode(a,{stream:!0})).split("\n");for(let e of(h=r.pop()||"",r)){let a=e.trim();if(a&&a.startsWith("data: "))try{let e=JSON.parse(a.slice(6));if("text-delta"===e.type&&e.delta){d+=e.delta,em(e=>e.map(e=>e.id===t?{...e,data:{...e.data,message:d,metadata:{isStreaming:!0}}}:e));let a=ea.current;a&&a.scrollHeight-a.scrollTop-a.clientHeight<150&&requestAnimationFrame(()=>{a.scrollTop=a.scrollHeight})}else"vanio-final"===e.type&&"string"==typeof e.text?(d=e.text,em(a=>a.map(a=>a.id===t?{...a,data:{...a.data,message:e.text,metadata:{isStreaming:!0}}}:a))):"tool-input-start"===e.type||"tool-call"===e.type?em(a=>a.map(a=>a.id===t?{...a,data:{...a.data,metadata:{isStreaming:!0,activeToolCall:e.toolName||"tool"}}}:a)):"tool-result"===e.type&&em(e=>e.map(e=>e.id===t?{...e,data:{...e.data,metadata:{isStreaming:!0,activeToolCall:void 0}}}:e))}catch{}}}em(e=>e.map(e=>e.id===t?{...e,data:{...e.data,metadata:{streamComplete:!0}}}:e))}catch(e){if(e?.name==="AbortError")return;console.error("[VanioStream] Error:",e),em(e=>e.map(e=>e.id===t?{...e,data:{...e.data,message:d||"Sorry, I encountered an error. Please try again.",metadata:{isStreaming:!1}}}:e))}finally{eN.current=null}},[]);(0,d.useEffect)(()=>{let e=new AbortController;return window.addEventListener("vanio:regenerate",e=>{let t=e.detail;if(!t?.threadId||!t?.query)return;let a=`streaming-regen-${Date.now()}`,r={id:a,type:"ai_message",timestamp:new Date().toISOString(),actor:{id:"vanio_ai",name:"Vanio AI",type:"ai_agent",avatar:"/favicon.ico"},data:{message:"",metadata:{isStreaming:!0}},visibility:"public",channel:"internal"};em(e=>[...e,r]),requestAnimationFrame(()=>{ea.current?.scrollTo({top:ea.current.scrollHeight,behavior:"smooth"})}),eB(t.threadId.toString(),a,t.query,t.reservationId,t.originalMessageId,t.source,t.feedback,t.previousAnswer)},{signal:e.signal}),()=>e.abort()},[]);let eq=(0,d.useCallback)(async(t,a)=>{if("internal"===a.channel){try{let e=a.content?.toLowerCase().includes("@vanio");if(e){let e=Date.now(),t=`streaming-${e}`,r={id:`local-internal-${e}`,type:"internal_message",timestamp:new Date(e).toISOString(),actor:{id:ed?.user?.id||"",name:ed?.user?.name||"You",type:"user",avatar:ed?.user?.image||void 0},data:{message:a.content||""},visibility:"public",channel:"internal"},s={id:t,type:"ai_message",timestamp:new Date(e+1e3).toISOString(),actor:{id:"vanio_ai",name:"Vanio AI",type:"ai_agent",avatar:"/favicon.ico"},data:{message:"",metadata:{isStreaming:!0}},visibility:"public",channel:"internal"};em(e=>[...e,r,s]),requestAnimationFrame(()=>{ea.current?.scrollTo({top:ea.current.scrollHeight,behavior:"smooth"})});let i=e=>{let r=e.detail?.result;r?.data?.streaming&&(window.removeEventListener("command:result",i),eB(r.data.threadId||R,t,a.content,r.data.reservationId,r.data.originalMessageId,"internal_chat"))};window.addEventListener("command:result",i)}f({type:t,payload:{...a,metadata:{...a.metadata,triggeredAI:e}}})}catch(e){console.error("[DEBUG] Error sending internal message:",e)}return}let r=a.localId||`local-${Date.now()}`,s=a.metadata?.attachments?.map(e=>({url:e.url,type:e.contentType?.startsWith("video")?"video":"image",contentType:e.contentType})),i="email"===a.channel||a.metadata?.channel==="email",n="sms"===a.channel||"twilio"===a.channel||a.metadata?.channel==="sms"||a.metadata?.channel==="twilio",l={id:r,type:"host_message",timestamp:new Date().toISOString(),status:"sending",data:{message:a.content||"",externalMessageId:null,status:"sending",...s?.length?{attachments:s}:{},...i?{metadata:{subject:a.metadata?.subject,from:e?.metadata?.emailInbox?.email||"",fromName:e?.metadata?.emailInbox?.displayName||ed?.user?.name||"",to:a.recipientId?[a.recipientId]:[],inboxEmail:e?.metadata?.emailInbox?.email||""}}:{},...n&&a.recipientId?{metadata:{smsRecipient:a.recipientId}}:{}},actor:{id:ed?.user?.id||"",name:ed?.user?.name||e?.metadata?.emailInbox?.displayName||"",type:"user",avatar:ed?.user?.image||""},visibility:"public",channel:a.metadata?.channel||"airbnb"};em(e=>[...e,l]),a.localId=r;try{await f({type:t,payload:a})}catch(e){console.error("[UnifiedTimeline][handleMessageCommand] Error:",e),em(t=>t.map(t=>
24t.id===r?{...t,status:"failed",data:{...t.data,status:"failed",error:e instanceof Error?e.message:"Failed to send message"}}:t))}},[f,ed,em]);(0,d.useEffect)(()=>{if(!ea.current)return;let t=e?.timelines?.messages?.data?.length??0;requestAnimationFrame(()=>{let e=ea.current;if(!e)return;if(er){e.scrollTop=e.scrollHeight,es(!1),el.current=t;return}let a=e.scrollHeight-e.scrollTop-e.clientHeight<100,r=t-el.current;el.current=t,a?(e.scrollTo({top:e.scrollHeight,behavior:"smooth"}),en(0)):r>0&&en(e=>e+r)})},[e?.timelines?.messages?.data,e?.timelines?.events?.data,er]);let ez=!b&&(!e?.timelines||(!e.timelines.messages?.data||0===e.timelines.messages.data.length)&&(!e.timelines.events?.data||0===e.timelines.events.data.length)),eH=(0,d.useCallback)(t=>{if("message.guest.preapproval"===t.type||"message.guest.special_offer"===t.type||"message.guest.withdraw_preapproval"===t.type)return void f({type:t.type,payload:t.payload});switch(t.type){case"reply":{let e=eO.find(e=>"id"in e&&"data"in e&&"actor"in e&&e.id===t.messageId&&"message"in e.data&&"string"==typeof e.data.message&&"name"in e.actor);e&&"data"in e&&"message"in e.data&&"actor"in e&&eg({id:e.id,content:e.data.message,sender:{name:e.actor.name},channel:e.channel});break}case"retry":let a=ec.find(e=>e.id===t.messageId)||eO.find(e=>e.id===t.messageId);a&&(em(e=>e.filter(e=>e.id!==t.messageId)),eq("message.guest.send",{content:a.data.message,metadata:{threadId:R,customerId:F,...a.data?.metadata||{}},channel:a.channel||a.data?.channel}));break;case"react":case"unreact":let r=eO.find(e=>e.id===t.messageId);if(!r)return;eq("react"===t.type?"message.react":"message.unreact",{messageId:t.messageId,reaction:t.emoji,channel:r.channel||"airbnb",content:"",metadata:{threadId:R,airbnbThreadId:r.data?.threadId||r.threadId,host:r.data?.host||r.host,customerId:F}});break;case"edit":let s=eO.find(e=>e.id===t.messageId);if(!s)return;eq("message.edit",{messageId:t.messageId,content:t.content,channel:s.channel||"airbnb",metadata:{threadId:R,airbnbThreadId:s.data?.threadId||s.threadId,host:s.data?.host||s.host,customerId:F}});break;case"unsend":let i=eO.find(e=>e.id===t.messageId);if(!i)return;eq("message.unsend",{messageId:t.messageId,channel:i.channel||"airbnb",metadata:{threadId:R,airbnbThreadId:i.data?.threadId||i.threadId,host:i.data?.host||i.host,customerId:F}});break;case"message.guest.special_offer":eq("message.guest.special_offer",{channel:"airbnb",metadata:{airbnbThreadId:e?.metadata.reservation.platform.platformThreadId,threadId:R,host:{id:e?.metadata?.host?.id},customerId:F},inquiryId:t.payload?.inquiryId});break;case"message.guest.preapproval":eq("message.guest.preapproval",{channel:"airbnb",metadata:{airbnbThreadId:e?.metadata.reservation.platform.platformThreadId,threadId:R,host:{id:e?.metadata?.host?.id},customerId:F},inquiryId:t.payload?.inquiryId,blockInstantBooking:t.payload?.blockInstantBooking||!1})}},[f,eq,ec,eO,P,F]);(0,d.useEffect)(()=>{let e=new URLSearchParams(window.location.search),t=e.get("messageId"),a=e.get("action"),r=e.get("highlightId");if(t){if("retry"===a){let e=ec.find(e=>e.id===t);e&&eq("message.guest.send",{content:e.data.message,metadata:e.data.metadata,channel:e.data.channel,userId:e.actor.id})}else if("reply"===a){let e=eO.find(e=>"id"in e&&"data"in e&&"actor"in e&&e.id===t&&"message"in e.data&&"string"==typeof e.data.message&&"name"in e.actor);e&&"data"in e&&"message"in e.data&&"actor"in e&&eg({id:e.id,content:e.data.message,sender:{name:e.actor.name},channel:e.channel})}else if("highlight"===a||r){let e=r||t;setTimeout(()=>{let t=document.getElementById(`message-${e}`);t&&ea.current&&(t.scrollIntoView({behavior:"smooth",block:"center"}),t.classList.add("highlight-message"),setTimeout(()=>{t.classList.remove("highlight-message")},3e3))},100)}let e=new URL(window.location.href);e.searchParams.delete("messageId"),e.searchParams.delete("action"),e.searchParams.delete("highlightId"),window.history.replaceState({},"",e)}},[eO,eq,ec]);let eV=(0,d.useCallback)(e=>{let t=e.detail?.messageId;t&&e.detail?.source!=="unified-timeline"&&(eb(t),setTimeout(()=>{if(!ea.current)return;let e=document.getElementById(`message-${t}`);e||(e=ea.current.querySelector(`[data-message-id="${t}"]`)),e&&(e.scrollIntoView({behavior:"smooth",block:"center"}),e.classList.add("highlight-message"),setTimeout(()=>{e?.classList.remove("highlight-message"),eb(null)},3e3))},100))},[]);(0,d.useEffect)(()=>{window.addEventListener("highlight-message",eV);let e=new URLSearchParams(window.location.search),t=e.get("messageId"),a=e.get("action");return t&&"highlight"===a&&setTimeout(()=>{window.dispatchEvent(new CustomEvent("highlight-message",{detail:{messageId:t,source:"unified-timeline-url"}}
24))},500),()=>{window.removeEventListener("highlight-message",eV)}},[eV]);let eG=(0,d.useMemo)(()=>{let t=eO?.filter(t=>{if("seam_activity"!==t.type||t.data?.actionType!=="lock.unlocked"&&t.data?.actionType!=="lock.locked")return!0;let a=t.data?.actionType==="lock.unlocked"&&!eO.some(e=>"seam_activity"===e.type&&e.data?.actionType==="lock.unlocked"&&new Date(e.timestamp)<new Date(t.timestamp)),r=t.data?.actionType==="lock.locked"&&eW(t.timestamp,e?.metadata?.reservation?.dates?.checkOut)&&!eO.some(a=>"seam_activity"===a.type&&a.data?.actionType==="lock.locked"&&eW(a.timestamp,e?.metadata?.reservation?.dates?.checkOut)&&new Date(a.timestamp)>new Date(t.timestamp));return a||r});if("all"===L)return t;if("timeline"===L){let e=t?.filter(e=>l.TIMELINE_EVENT_ENTRY_TYPES.includes(e.type));return console.log("[DEBUG] After timeline filter:",{filteredCount:e?.length||0,thinkingMessages:e?.filter(e=>"ai_message"===e.type&&e.data?.metadata?.isThinking).map(e=>({id:e.id,originalId:e.data?.metadata?.originalMessageId}))}),e}let a=t?.filter(e=>{switch(L){case"messages":return["guest_message","host_message","internal_message","ai_message"].includes(e.type);case"events":return l.TIMELINE_EVENT_ENTRY_TYPES.includes(e.type);case"tasks":return"task"===e.type;case"issues":return"issue"===e.type;case"automations":return"automation"===e.type;default:return!0}});return console.log("[DEBUG] Final filtered messages:",{filteredCount:a?.length||0,thinkingMessages:a?.filter(e=>"ai_message"===e.type&&e.data?.metadata?.isThinking).map(e=>({id:e.id,originalId:e.data?.metadata?.originalMessageId}))}),a},[eO,L,e?.metadata?.reservation?.dates?.checkOut]);(0,d.useEffect)(()=>{if(ea.current){let e=ea.current;e.scrollHeight-e.scrollTop-e.clientHeight<100&&e.scrollTo({top:e.scrollHeight,behavior:"smooth"})}},[e?.timelines]),(0,d.useEffect)(()=>{let e=e=>{let{command:t,result:a}=e.detail;"message"===t.topic&&t.payload?.localId&&(a.success?(em(e=>e.map(e=>e.id===t.payload.localId?{...e,status:"sent",data:{...e.data,status:"sent",externalMessageId:a.data?.externalMessageId||null,messageId:a.data?.messageId||null}}:e)),a.data?.messageId&&(ef.current[t.payload.localId]=a.data.messageId)):em(e=>e.map(e=>e.id===t.payload.localId?{...e,status:"failed",data:{...e.data,status:"failed",error:a.error||"Failed to send message"}}:e)))};return window.addEventListener("command:result",e),()=>{window.removeEventListener("command:result",e)}},[]),(0,d.useEffect)(()=>{!eG||0===eG.length||ec&&0!==ec.length&&em(e=>{let t=[];return(e.forEach(e=>{if(!e.data||"ai_message"===e.type&&(e.data.metadata?.isThinking||e.data.metadata?.isStreaming))return;let a="object"==typeof e.data&&"message"in e.data?e.data.message:null,r=ef.current[e.id],s=eG.find(e=>{if(!e.id||"string"!=typeof e.id||e.id.startsWith("local-")||e.id.startsWith("streaming-")||!e.data)return!1;if(r&&String(e.id)===String(r))return!0;let t="object"==typeof e.data&&"message"in e.data?e.data.message:null;return!!a&&!!t&&a===t});if(s){let a=e.data?.attachments,r="data"in s&&s.data?.attachments;if(a?.length&&!r?.length)return;t.push(e.id)}}),0===t.length)?e:e.filter(e=>!t.includes(e.id))})},[eG,ec]),(0,d.useEffect)(()=>{em(e=>{let t=e.filter(e=>"ai_message"===e.type&&e.data?.metadata?.isThinking);if(0===t.length)return e;let a=new Set;return(t.forEach(e=>{let t=new Date(e.timestamp).getTime();eG.some(e=>"ai_message"===e.type&&!e.data?.metadata?.isThinking&&!e.data?.metadata?.isStreaming&&new Date(e.timestamp).getTime()>t-1e4)&&a.add(e.id)}),0===a.size)?e:e.filter(e=>!a.has(e.id))})},[eG]);let eW=(e,t)=>{if(!t)return!1;let a=new Date(e),r=new Date(t);return a.getFullYear()===r.getFullYear()&&a.getMonth()===r.getMonth()&&a.getDate()===r.getDate()},eK=(0,d.useMemo)(()=>{let t=e?.metadata?.guest?.contacts?.find(e=>"phone"===e.type&&e.isPrimary),a=e?.metadata?.guest?.contacts?.find(e=>"phone"===e.type);return t?.value||a?.value||void 0},[e?.metadata?.guest?.contacts]),eY=e?.metadata?.fromAddress,eJ=(0,d.useMemo)(()=>{if(e?.type==="owner"||e?.ownerId){let t=e?.metadata?.owner?.primaryEmail;if(t)return t}let t=e?.metadata?.guest?.contacts?.find(e=>"email"===e.type&&e.isPrimary),a=e?.metadata?.guest?.contacts?.find(e=>"email"===e.type);return t?.value||a?.value||eY||void 0},[e?.metadata?.guest?.contacts,eY,e?.type,e?.ownerId,e?.metadata]),eQ=e?.metadata?.reservation?.platform?.source||e?.metadata?.reservation?.platform,eX=(0,d.useCallback)(e=>{y?.(e)},[y]),eZ=e?.metadata?.reservation?.id;(0,d.useEffect)(()=>{eZ&&F&&!ej.current&&(ej.current=!0,fetch(`/api/payments/reservation/history?reservationId=${eZ}&guestId=0&customerId=${F}`,{credentials:"include"}).then(e=>e.ok?e.json():null).then(e=>{e?.paymentSummary?.depositsAuthorized>0&&ew("authorized");let t={};for(let a of e?.payments&&"object"==typeof e.payments?Object.values(e.payments):[])if(Array.isArray(a))for(let e of a)e?.source==="portal_upsell"&&e?.request&&e?.stripe_payment_intent_id&&(t[e.stripe_payment_intent_id]=e.request);ek(t)}
24).catch(()=>ek({})))},[eZ,F]);let e0=!!eZ&&!!F&&void 0===ev,e1=(0,d.useCallback)(async e=>{if("upsell_approve"===e.type||"upsell_decline"===e.type){let t={type:"direct",topic:"reservation",event:"upsell_approve"===e.type?"reservation.upsell.approve":"reservation.upsell.decline",payload:{reservationId:e.metadata?.reservationId||eZ,customerId:e.metadata?.customerId||parseInt(F),purchaseId:e.metadata?.purchaseId,upsellType:e.metadata?.upsellType,requestedTime:e.metadata?.requestedTime,threadId:R,userId:ed?.user?.id,userName:ed?.user?.name}};window.dispatchEvent(new CustomEvent("command:execute",{detail:t}));return}let t="deposit_capture"===e.type?"capture":"release",a=await (0,E.runDepositCommand)({type:"direct",topic:"payment",event:e.type,payload:{type:e.type,reservationId:eZ,customerId:parseInt(F),metadata:e.metadata,userId:ed?.user?.id,userName:ed?.user?.name}},t);return a.success&&ew("deposit_capture"===e.type?"captured":"released"),a},[eZ,F,ed?.user?.id,ed?.user?.name,R]);return(0,t.jsxs)("div",{className:(0,c.cn)("flex flex-col h-full",D),children:[(0,t.jsxs)("div",{className:"flex-1 overflow-hidden relative",children:[ei>0&&(0,t.jsxs)("button",{type:"button",onClick:eo,className:(0,c.cn)("absolute bottom-3 left-1/2 -translate-x-1/2 z-20","flex items-center gap-1.5 px-3 py-1.5 rounded-full shadow-lg","text-xs font-medium text-white bg-emerald-600 hover:bg-emerald-500","border border-emerald-400/30 transition-colors animate-in fade-in slide-in-from-bottom-2"),"aria-label":"Scroll to newest messages",children:[(0,t.jsxs)("span",{children:[ei," new message",1===ei?"":"s"]}),(0,t.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,t.jsx)("path",{d:"M12 5v14M19 12l-7 7-7-7"})})]}),(0,t.jsxs)("div",{ref:ea,onScroll:e=>{if(0===ei)return;let t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<100&&en(0)},className:"h-full overflow-y-auto overflow-x-hidden px-4 pb-4\n [&::-webkit-scrollbar]:w-[2px]\n [&::-webkit-scrollbar-track]:bg-transparent\n [&::-webkit-scrollbar-thumb]:bg-gray-200 dark:[&::-webkit-scrollbar-thumb]:bg-white/5\n hover:[&::-webkit-scrollbar-thumb]:bg-gray-300 dark:hover:[&::-webkit-scrollbar-thumb]:bg-white/10",children:["tasks"===L&&e?.metadata?.reservation?.id&&(0,t.jsx)("div",{"data-pinned-overview":!0,className:"sticky top-0 z-10 -mx-4 px-4 bg-white dark:bg-[#1D1D1F] max-h-[45vh] overflow-y-auto border-b border-gray-100 dark:border-white/[0.06] mb-4",children:(0,t.jsx)(B,{reservationId:e.metadata.reservation.id,className:"pt-2 pb-3"})}),ez?"tasks"===L&&e?.metadata?.reservation?.id?null:(0,t.jsx)(n.TimelineEmpty,{}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(X,{activeFilter:L,sections:{messages:eS,events:eI,issues:e_,automations:eD},onShowOlder:eF}),"timeline"===L?(0,t.jsx)(T.EventsTimeline,{events:eG,depositStatus:ey,onDepositAction:e1,upsellRequests:ev,upsellRequestsLoading:e0}):(0,t.jsxs)("div",{className:"flex flex-col space-y-4 pb-4",children:[" ",(0,t.jsx)(r.AnimatePresence,{initial:!1,children:eG?.map((r,n)=>{var l;let o,d,c,m;return(0,t.jsxs)(a.motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,delay:.05*n},children:[("guest_message"===r.type||"host_message"===r.type)&&"email"===r.channel&&(0,t.jsx)(j.EmailMessageBubble,{message:r,onReply:e=>{let t="host_message"===e.type?e.data?.metadata?.to?.[0]:e.data?.metadata?.from;eg({id:e.id,content:e.data?.metadata?.subject?`Re: ${e.data.metadata.subject}`:e.data.message?.slice(0,100),sender:{name:e.actor.name,email:t},channel:"email"})},onForward:e=>{let t=e.data?.metadata?.subject||"",a=t.startsWith("Fwd: ")?t:`Fwd: ${t}`,r=e.data?.metadata?.fromName||e.actor.name,s=e.data?.metadata?.from||e.actor.id,i=new Date(e.timestamp).toLocaleString(),n=e.data?.metadata?.textBody||e.data.message||"",l=` 25 26---------- Forwarded message ---------- 27From: ${r} <${s}> 28Date: ${i} 29Subject: ${t} 30 31${n}`;eg({id:e.id,content:a,sender:{name:r,email:""},channel:"email",mode:"forward",quotedBody:l})}}),("guest_message"===r.type||"host_message"===r.type||"notes"===r.type)&&"email"!==r.channel&&(0,t.jsx)(s.MessageBubble,{message:r,messages:eO,host:e?.metadata?.host,onMessageAction:eH,reservationContext:e?.metadata?.reservation?{id:e.metadata.reservation.id,confirmationCode:e.metadata.reservation.confirmationCode,listingId:e.metadata.listing?.id,listingName:e.metadata.listing?.name,checkIn:e.metadata.reservation.dates?.checkIn,checkOut:e.metadata.reservation.dates?.checkOut,guestName:e.metadata.guest?.name?.full||e.metadata.guest?.name?.first,guestId:e.metadata.guest?.id}:void 0,listingContext:e?.metadata?.listing?{id:e.metadata.listing.id,name:e.metadata.listing.name,location:e.metadata.listing.location?.city||e.metadata.listing.location?.street}:void 0}),"calendar"===r.type&&"data"in r&&r.data&&"action"in r.data&&"details"in r.data&&(0,t.jsx)(G.CalendarEntry,{entry:r}),"internal_message"===r.type&&(0,t.jsx)(k.InternalMessageBubble,{message:{id:r.id,content:r.data.message,sender:{id:r.actor.id,name:r.actor.name,avatar:r.actor.avatar,type:r.actor.type},timestamp:r.timestamp,readBy:r.readBy,attachments:r.data.attachments,data:{...r.data,tags:r.data?.tags,metadata:r.data?.metadata}},onReply:e=>f({type:"reply",payload:{messageId:e}}),dashboardInteractions:e?.interactions||[]}),"automation"===r.type&&(0,t.jsx)(C.AutomationEntry,{automation:r,onAction:e=>{f({type:e.type,payload:{automationId:e.automationId}})}}),("system_note"===r.type||"team_action"===r.type)&&(0,t.jsx)(i.SystemEvent,{event:r}),"seam_activity"===r.type&&(o=r.data?.actionType==="lock.unlocked"&&!eO.some(e=>"seam_activity"===e.type&&e.data?.actionType==="lock.unlocked"&&new Date(e.timestamp)<new Date(r.timestamp))||r.data?.actionType==="lock.locked"&&eW(r.t
31imestamp,e?.metadata?.reservation?.dates?.checkOut)&&!eO.some(t=>"seam_activity"===t.type&&t.data?.actionType==="lock.locked"&&eW(t.timestamp,e?.metadata?.reservation?.dates?.checkOut)&&new Date(t.timestamp)>new Date(r.timestamp)),(r.data?.actionType!=="lock.unlocked"&&r.data?.actionType!=="lock.locked"||!!o)&&(0,t.jsx)(x.SeamActivity,{activity:{id:r.id,timestamp:r.timestamp,actor:{id:r.actor.id,name:r.actor.name,avatar:r.actor.avatar,type:"automation"===r.actor.type||"ai_agent"===r.actor.type?"system":r.actor.type},data:{...r.data},type:r.type,visibility:r.visibility},isFirstUnlock:r.data?.actionType==="lock.unlocked"&&!eO.some(e=>"seam_activity"===e.type&&e.data?.actionType==="lock.unlocked"&&new Date(e.timestamp)<new Date(r.timestamp)),isLastLock:r.data?.actionType==="lock.locked"&&eW(r.timestamp,e?.metadata?.reservation?.dates?.checkOut)&&!eO.some(t=>"seam_activity"===t.type&&t.data?.actionType==="lock.locked"&&eW(t.timestamp,e?.metadata?.reservation?.dates?.checkOut)&&new Date(t.timestamp)>new Date(r.timestamp))})),("price_update"===r.type||"price_change"===r.type)&&(0,t.jsx)(g.PriceUpdate,{update:r}),"review"===r.type&&(0,t.jsx)(p.ReviewEntry,{review:r,...(({hostInfo:e,guestInfo:t})=>({hostInfo:e,guestInfo:t}))((l=e?.metadata,d=l?.host,c=l?.guest,{hostInfo:d?{id:d.id,name:d.name,avatar:d.avatarUrl}:void 0,guestInfo:c?{id:c.id,name:c.name,avatar:c.metadata?.avatarUrl}:void 0})),listingId:e?.metadata?.listing?.id}),"issue"===r.type&&(0,t.jsx)(N.IssueEntry,{issue:r,onAction:e=>{f({type:e.type,payload:{issueId:e.issueId}})}}),"reservation_update"===r.type&&(0,t.jsx)(S.ReservationUpdateEntry,{update:r,depositStatus:ey,upsellRequests:ev,upsellRequestsLoading:e0,onAction:e=>{if("deposit_capture"===e.type||"deposit_release"===e.type)return e1(e);f({type:e.type,payload:{updateId:e.updateId}})}},r.id),"upsell_approval"===r.type&&(0,t.jsx)(I.UpsellApprovalEntry,{update:r,onAction:e1}),"portal"===r.type&&(0,t.jsx)(W.PortalEntry,{entry:r}),"alteration"===r.type&&(0,t.jsx)(_.AlterationEntry,{alteration:r,onAction:e1}),"reservation"===r.type&&(m=e?.metadata?.host?.id,(0,t.jsx)(z.ReservationEntry,{reservation:{...r,hostId:m,currentStatus:e?.metadata?.reservation?.status,currentReservation:e?.metadata?.reservation},onAction:async e=>{try{let t=await f({type:e.type,payload:{...e.payload,userId:m}});return{success:!0,data:t}}catch(e){return console.error("Error handling reservation action:",e),{success:!1,error:e instanceof Error?e.message:"An unknown error occurred"}}}})),"task"===r.type&&(0,t.jsx)(A.Task,{task:{id:r.id,data:{title:r.data.title,status:"pending"===r.data.status?"todo":"completed",priority:r.data.priority||"normal",dueDate:r.data.dueDate,assignee:r.data.assignee||void 0,description:r.data.description,metadata:r.data.metadata,category:r.data.metadata?.cleaningType||"other"},actor:r.actor,timestamp:"string"==typeof r.timestamp?r.timestamp:r.timestamp.toISOString(),visibility:r.visibility},className:"mb-4"},r.id),"inquiry"===r.type&&(0,t.jsx)(q.InquiryEntry,{inquiry:r,onRespond:(t,a)=>{eH({type:t,messageId:r.id,payload:{...a,inquiryId:r.id,metadata:{...a?.metadata||{},airbnbThreadId:r.data?.threadId,threadId:r.data?.threadId,hostId:e?.metadata?.host?.id}}})}},r.id),"payment"===r.type&&(0,t.jsx)(H.PaymentEntry,{payment:r},r.id),"ai_message"===r.type&&(()=>{let e;for(let t=n-1;t>=0;t--){let a=eG[t];if("guest_message"===a.type&&a.data?.message){e=a.data.message;break}}return(0,t.jsx)(V.AIMessage,{message:r,isLoading:eL?.some(e=>e.id===r.id&&e.data?.status==="processing"),threadId:parseInt(R)||void 0,ratings:eu[r.id],originalGuestMessage:e})})()]},`${r.type}-${r.timestamp}-${n}`)})})]})]}),U?.length>0&&(0,t.jsxs)(a.motion.div,{ref:e=>{e&&requestAnimationFrame(()=>{e.scrollIntoView({behavior:"smooth",block:"end"})})},initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.3,ease:"easeOut"},className:(0,c.cn)("flex items-center gap-2 mt-2 px-3 py-2","bg-white/[0.03] rounded-xl border border-gray-200 dark:border-white/[0.08]"),children:[(0,t.jsx)("div",{className:"flex -space-x-2",children:U.slice(0,3).map(e=>(0,t.jsxs)(K.Avatar,{className:"h-6 w-6 border-2 border-[#18181A]",children:[(0,t.jsx)(K.AvatarImage,{src:e.avatar,alt:e.name}),(0,t.jsx)(K.AvatarFallback,{className:"bg-gray-100 dark:bg-white/5 text-xs",title:e.name,children:e.name.charAt(0)})]},e.id))}),(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)("span",{className:"text-sm text-gray-500 dark:text-white/80",children:1===U.length?`${U[0].name} is typing...`:`${U.length} people are typing...`}),(0,t.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,t.jsx)("div",{className:"w-1.5 h-1.5 rounded-full bg-gray-400 dark:bg-white/40 animate-bounce",style:{animationDelay:"0ms"}}),(0,t.jsx)("div",{className:"w-1.5 h-1.5 rounded-full bg-gray-400 dark:bg-white/40 animate-bounce",style:{animationDelay:"150ms"}}),(0,t.jsx)("div",{className:"w-1.5 h-1.5 rounded-full bg-gray-400 dark:bg-white/40 animate-bounce",style:{animationDelay:"300ms"}})]})]})]}),b&&(0,t.jsx)("div",{className:"flex justify-center py-8",children:(0,t.jsx)(m.LoadingSpinner,{})})]})]}),(0,t.jsx)("div",{className:"flex-none border-t border-gray-200 dark:border-white/[0.08]",children:(0,t.jsx)("div",{className:"relative z-50 isolate bg-gray-50 dark:bg-[#18181A]",children:(0,t.jsx)(u.TimelineComposer,{onCommand:eq,onCommandPaletteOpen:w,onTyping:eX,replyTo:ex,onCancelReply:()=>eg(null),userId:M,customerId:F,itemId:P,threadId:R,defaultChannel:eQ,pmsSource:e?.metadata?.pmsSource??null,vrboInbox:String(e?.metadata?.thread?.externalThreadId||"").startsWith("vrbo:"),itemType:e?.type,sourceType:e?.sourceType||e?.source_type,fromExternalId:e?.metadata?.fromExternalId,watchdog:e?.metadata?.slaWatchdog,onItemStatus:$,isActive:O,currentAssignment:ee,currentUserId:et,guestPhoneNumber:eK,guestEmail:eJ,reservationSummary:{confirmationCode:e?.metadata?.reservation?.confirmationCode,checkIn:e?.metadata?.reservation?.dates?.checkIn,checkOut:e?.metadata?.reservation?.dates?.checkOut,countryCode:e?.metadata?.listing?.location?.country}})})})]})}let ee="https://api.vanio.ai";e.s(["useReservationAutomations",0,function(e,t){let[a,r]=(0,d.useState)(!1),[s,i]=(0,d.useState)(),[n,l]=(0,d.useState)([]),[o,c]=(0,d.useState)(!0),[m,u]=(0,d.useState)(!1),[h,x]=(0,d.useState)(new Set),[g,p]=(0,d.useState)(null),[b,f]=(0,d.useState)(new Set),[y,w]=(0,d.useState)(!1),v=(0,d.useCallback)(async()=>
31{if(e&&t){c(!0);try{let[t,a]=await Promise.all([fetch(`${ee}/reservations/${e}/automations`,{credentials:"include"}),fetch(`${ee}/reservations/${e}/automations/upcoming`,{credentials:"include"})]);if(t.ok){let e=await t.json();r(e.suppressed),i(e.reason)}let s=[];if(a.ok&&(s=(await a.json()).actions||[],l(s)),s.length>0){let t=[...new Set(s.map(e=>e.workflowId))];try{let a=await fetch(`${ee}/workflows/preview-batch`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({reservationId:e,workflowIds:t})});if(a.ok){let{previews:e}=await a.json(),t=new Map;for(let a of Object.values(e))if(a?.events)for(let e of a.events)for(let a of e.actions)a.interpolatedContent&&t.set(a.actionId,{interpolatedContent:a.interpolatedContent,channelResolution:a.channelResolution});t.size>0&&l(e=>e.map(e=>{let a=t.get(e.actionId);return a?{...e,...a}:e}))}}catch{}w(!0)}else w(!0)}catch(e){console.error("[useReservationAutomations] Error fetching data:",e)}finally{c(!1)}}},[e,t]);(0,d.useEffect)(()=>{v()},[v]);let k=(0,d.useCallback)(async()=>{if(e){u(!0);try{let s=a?"unsuppress":"suppress";window.dispatchEvent(new CustomEvent("command:execute",{detail:{type:"direct",topic:"reservation",event:`reservation.automation.${s}`,payload:{reservationId:e,customerId:t,reason:"Manual pause from dashboard"}}})),r(!a),i(a?void 0:"Manual pause from dashboard"),setTimeout(()=>{v(),u(!1)},1e3)}catch{u(!1)}}},[a,e,t,v]);return{actions:n,isSuppressed:a,suppressionReason:s,isLoading:o,suppressLoading:m,actionLoadingIds:h,sendingActionId:g,sentActionIds:b,previewsLoaded:y,handleGlobalToggle:k,handleActionToggle:(0,d.useCallback)(async(t,a)=>{if(e){x(e=>new Set(e).add(t));try{(await fetch(`${ee}/reservations/${e}/automations/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({action:a?"unsuppress":"suppress"})})).ok&&l(e=>e.map(e=>e.actionId===t?{...e,status:a?"upcoming":"suppressed"}:e))}catch(e){console.error("[useReservationAutomations] Error toggling action:",e)}finally{x(e=>{let a=new Set(e);return a.delete(t),a})}}},[e]),handleSendNow:(0,d.useCallback)(async(t,a)=>{if(e){p(a);try{(await fetch(`${ee}/workflows/${t}/send-now`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({actionId:a,reservationId:e})})).ok&&f(e=>new Set(e).add(a))}catch{}finally{p(null)}}},[e]),refetch:v}}],435026);var et=e.i(768841);e.s(["MinusCircle",()=>et.default],818836)},956846,e=>{"use strict";var t=e.i(244788),a=e.i(877077);function r(e,t){return null===e||!t||0===t.length||t.some(t=>e.has(t))}var s=e.i(329536);let i=new Set(["owner","admin"]);function n(e){let t=(0,s.normalizeAllowedTaskCategories)(e);return t?new Set(t):null}function l(e,t){if(null===e)return t;if(null===t)return e;let a=new Set;for(let r of e)t.has(r)&&a.add(r);return a}let o=e=>e.some(e=>i.has(e)),d=new Set(["rejected","declined","cancelled","expired"]),c=new Set(["declined","expired"]),m=["listing","listing_health","device","review","calendar","voice","reservation"],u=["blacklisted_guest_booking"];function h(e,t){return e?.[t]?.enabled===!1}e.i(73432);var x=e.i(309077);let g=new Set(["dashboard_assignment","dashboard_group_assignment","thread_update","message"]),p=new class{vapidPublicKey;logPrefix;supabase=null;constructor(){this.vapidPublicKey="BKyeVAPlIy9v7AmlShp02wWaRBtQGXQ_fxLrK5V5N3TAS_QGkp3fpZYS3tSh350zTt8gWaeZiLQYD1jPN5W0-gw",this.logPrefix="[NotificationService]"}async createNotification(r){if(!this.supabase)return console.warn(`${this.logPrefix} Supabase client not initialized. This method can only be called server-side.`),null;let s=(0,x.createPhaseTracker)("NotificationService.createNotification",{type:r.type,customerId:r.customerId});try{if("mention"===r.type&&r.userId?.startsWith("group:")){let e=r.userId.replace("group:",""),{data:t,error:a}=await s.phase("selectGroupMembers",()=>this.supabase.from("user_group_members").select("user_id").eq("group_id",e));if(a)return console.error(`${this.logPrefix} Error fetching group members:`,a),null;if(!t||0===t.length)return console.log(`${this.logPrefix} No members found for group ${e}`),null;return(await Promise.all(t.map(t=>this.createNotification({...r,userId:t.user_id,metadata:{...r.metadata,originalGroupId:e,isGroupMention:!0}
31}))))[0]}let i=await s.phase("collapseExistingThreadNotification",()=>this.findCollapsibleThreadNotification(r)),n=!!i;if(i){let e=await s.phase("updateCollapsedNotification",()=>this.applyCollapseUpdate(i,r));e&&(i=e)}else{let e={customer_id:r.customerId,type:r.type,title:r.title,message:r.message||"",priority:r.priority,source_type:r.sourceType,source_reference:r.sourceReference||{},metadata:r.metadata||{},is_read:!1,is_archived:!1,is_active:!0,external_link:r.externalLink||null},{data:t,error:a}=await s.phase("insertNotification",()=>this.supabase.from("notifications").insert(e).select("*").single());if(a||!t)throw Error(`Failed to create notification: ${a?.message||"Unknown error"}`);i=t}if(!i)throw Error("Failed to create notification: no notification record produced");let l=[];if(r.userId){if(r.type===a.NotificationType.DASHBOARD_ASSIGNMENT||r.type===a.NotificationType.TIMELINE_UPDATE&&(r.metadata?.eventType==="assignment"||r.metadata?.updateType==="assignment")||await this.shouldSendNotificationToUser(r.userId,r.type,r.sourceType,r.metadata)){let{data:e,error:t}=await this.supabase.from("users").select("notification_preferences").eq("id",r.userId).single();t&&console.warn(`${this.logPrefix} Error getting user preferences, defaulting to all channels disabled:`,t);let a=(e?.notification_preferences||{}).delivery||{};l.push({userId:r.userId,targetReason:"direct",shouldReceiveEmail:!1!==a.email,shouldReceivePush:!1!==a.push,shouldReceiveSms:!1!==a.sms})}}else l=await this.findRelevantUsersForNotification(r.customerId,r.type,r.sourceType,r.sourceReference,r.metadata);if(0===l.length)return null;if(l.length>0)if(n){let e=l.map(e=>({notification_id:i.id,user_id:e.userId,target_reason:e.targetReason,is_read:!1,is_archived:!1,updated_at:new Date().toISOString()})),{error:t}=await this.supabase.from("notification_recipients").upsert(e,{onConflict:"notification_id,user_id"});t&&console.error(`${this.logPrefix} Error upserting collapsed recipient records:`,t)}else{let e=l.map(e=>({notification_id:i.id,user_id:e.userId,target_reason:e.targetReason,is_read:!1,is_archived:!1})),{error:t}=await this.supabase.from("notification_recipients").insert(e);t&&console.error(`${this.logPrefix} Error creating recipient records:`,t)}try{let e=(await Promise.all(l.map(async e=>{if(!e||!e.userId)return null;let{data:t}=await this.supabase.from("users").select("notification_preferences").eq("id",e.userId).single(),a=t?.notification_preferences?.delivery||{};return!1!==a.push&&e.shouldReceivePush?e:null}))).filter(e=>null!==e);if(e.length>0)for(let a of e){let{data:e,error:s}=await this.supabase.from("push_subscriptions").select("*").eq("user_id",a.userId);if(s){console.error(`${this.logPrefix} Error fetching push subscriptions:`,s);continue}if(e&&e.length>0){let s=e.map(e=>{let s={endpoint:e.endpoint,keys:{p256dh:e.p256dh,auth:e.auth}};return this.sendPushNotification(s,{title:r.title,message:r.message||"",url:i.external_link||void 0,metadata:{sourceReference:i.source_reference,type:i.type}}).then(()=>this.supabase.from("notification_recipients").update({push_sent:!0,push_sent_at:new Date().toISOString()}).eq("notification_id",i.id).eq("user_id",a.userId)).catch(a=>{if(a instanceof t.default.WebPushError&&(410===a.statusCode||404===a.statusCode))return console.log(`${this.logPrefix} Removing invalid/expired push subscription (${a.statusCode}):`,e.endpoint),this.removePushSubscription(e.endpoint);console.error(`${this.logPrefix} Error sending push to ${e.endpoint}:`,a)})});await Promise.allSettled(s)}}}catch(e){console.error(`${this.logPrefix} Error sending push notifications:`,e)}try{let{deliverToChatChannel:t}=await e.A(244978);await t(l.map(e=>e.userId),{notificationType:r.type,title:r.title,message:r.message,priority:r.priority,sourceType:r.sourceType,sourceReference:r.sourceReference||{},metadata:r.metadata||{},customerId:r.customerId})}catch(e){console.warn(`${this.logPrefix} Chat delivery error (non-blocking):`,e)}return s.total("done",{notificationId:i?.id}),i}catch(e){throw String(e?.message??"").includes("uq_notifications_system_outage_customer")?console.warn(`${this.logPrefix} Outage notification already sent to this customer â skipped`):console.error(`${this.logPrefix} Error creating notification:`,e),s.total("failed"),e}}async createFromWebhook(e){return this.createNotification(e)}async findCollapsibleThreadNotification(e){if(!this.supabase||!e.userId||e.userId.startsWith("group:"))return null;let t=function(e,t){if(!g.has(e))return null;let a=t?.threadId;return null==a||""===a?null:String(a)}(e.type,e.sourceReference);if(!t)return null;try{let{data:a,error:r}=await this.supabase.from("notification_recipients").select(` 32 id, 33 is_read, 34 is_archived, 35 notification:notifications!inner(*) 36 `).eq("user_id",e.userId).eq("is_read",!1).eq("is_archived",!1).eq("notifications.customer_id",e.customerId).eq("notifications.type",e.type).eq("notifications.is_active",!0).eq("notifications.source_reference->>threadId",t).order("notification(created_at)",{ascending:!1}).limit(1);if(r)return console.warn(`${this.logPrefix} Collapse lookup failed (falling back to insert):`,r.message),null;return a?.[0]?.notification||null}catch(e){return console.warn(`${this.logPrefix} Collapse lookup threw (falling back to insert):`,e),null}}async applyCollapseUpdate(e,t){if(!this.supabase)return null;let a=new Date().toISOString(),r=e.metadata||{},s=Number(r.collapsedCount)||1,i={collapsed:!0,collapseThreadId:String(t.sourceReference?.threadId),collapsedCount:s+1,lastCollapsedAt:a},n={...r,...t.metadata||{},...i},l=i.collapsedCount,o=t.message||"",d=l>1?`${l} new â ${o}`:o,{data:c,error:m}=await this.supabase.from("notifications").update({title:t.title,message:d,priority:t.priority,source_reference:t.sourceReference||e.source_reference||{},metadata:n,external_link:t.externalLink??e.external_link??null,is_read:!1,is_archived:!1,created_at:a,updated_at:a}).eq("id",e.id).select("*").single();return m||!c?(console.warn(`${this.logPrefix} Failed to update collapsed notification ${e.id}:`,m?.message),null):c}
36async registerServiceWorker(){if(this.supabase)try{let e=await fetch("/api/auth/session"),t=await e.json(),a=/iPad|iPhone|iPod/.test(navigator.userAgent);if(/^((?!chrome|android).)*safari/i.test(navigator.userAgent),!t?.user?.id)return void console.error(`${this.logPrefix} No authenticated user found`);if(!("serviceWorker"in navigator))return void console.error(`${this.logPrefix} Service Worker not supported`);if(!("PushManager"in window))return void console.error(`${this.logPrefix} Push not supported`);if(!("Notification"in window))return void console.error(`${this.logPrefix} Notifications not supported`);let r=await navigator.serviceWorker.register("/sw.js");if(await r.pushManager.getSubscription())return;if(a){let e=await this.requestNotificationPermission();if("granted"!==e)return void console.log(`${this.logPrefix} Permission not granted on iOS:`,e)}let s=await Notification.requestPermission();if("granted"===s){let e=await r.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:this.vapidPublicKey});await fetch("/api/notifications/push",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e.toJSON())}),console.log(`${this.logPrefix} Push subscription saved successfully`)}else console.log(`${this.logPrefix} Permission not granted:`,s)}catch(e){console.error(`${this.logPrefix} Error in registerServiceWorker:`,e)}}async requestNotificationPermission(){if(!this.supabase)throw console.warn(`${this.logPrefix} Supabase client not initialized. This method can only be called server-side.`),Error("Supabase client not initialized");try{let e=await Notification.requestPermission();return console.log(`${this.logPrefix} Notification permission:`,e),e}catch(e){throw console.error(`${this.logPrefix} Error requesting permission:`,e),e}}async sendPushNotification(e,a){if(!this.supabase)throw console.warn(`${this.logPrefix} Supabase client not initialized. This method can only be called server-side.`),Error("Supabase client not initialized");let r=(0,x.createPhaseTracker)("NotificationService.sendPushNotification");try{return await r.phase("webpush.sendNotification",()=>t.default.sendNotification(e,JSON.stringify({title:a.title,message:a.message,url:a.url,icon:"/favicon.ico",badge:"/favicon.ico",timestamp:Date.now(),requireInteraction:!0,metadata:a.metadata}))),r.total("done"),!0}catch(e){throw console.error(`${this.logPrefix} Error sending push notification:`,{error:e.message,statusCode:e.statusCode,body:e.body,headers:e.headers,stack:e.stack}),r.total("failed"),e}}async removePushSubscription(e){if(!this.supabase)return console.warn(`${this.logPrefix} Supabase client not initialized. This method can only be called server-side.`),!1;try{let{error:t}=await this.supabase.from("push_subscriptions").delete().eq("endpoint",e);if(t)throw t;return!0}catch(e){return console.error(`${this.logPrefix} Error removing push subscription:`,e),!1}}async registerPushSubscription(e,t,a){if(!this.supabase)return console.warn(`${this.logPrefix} Supabase client not initialized. This method can only be called server-side.`),!1;try{console.log(`${this.logPrefix} Registering push subscription for user:`,{userId:t,customerId:a,endpoint:e.endpoint});let{data:r,error:s}=await this.supabase.from("push_subscriptions").select("id").eq("endpoint",e.endpoint).maybeSingle();if(s)throw s;if(r){let{error:s}=await this.supabase.from("push_subscriptions").update({user_id:t,customer_id:a,p256dh:e.keys.p256dh,auth:e.keys.auth,updated_at:new Date().toISOString()}).eq("id",r.id);if(s)throw s;console.log(`${this.logPrefix} Updated existing push subscription`)}else{let{error:r}=await this.supabase.from("push_subscriptions").insert({user_id:t,customer_id:a,endpoint:e.endpoint,p256dh:e.keys.p256dh,auth:e.keys.auth});if(r)throw r;console.log(`${this.logPrefix} Created new push subscription`)}return!0}catch(e){return console.error(`${this.logPrefix} Error registering push subscription:`,e),!1}}async shouldSendNotificationToUser(e,t,r,s,i="delivery"){if(!this.supabase)return console.warn(`${this.logPrefix} Supabase client not initialized. This method can only be called server-side.`),"delivery"===i;try{let{data:r,error:n}=await this.supabase.from("users").select("notification_preferences").eq("id",e).single();if(n)return console.log(`${this.logPrefix} Error fetching user preferences, defaulting to true:`,n),!0;if(s?.priority===a.NotificationPriority.CRITICAL)return!0;
36if(t===a.NotificationType.DASHBOARD_ASSIGNMENT&&(s?.assignedTo===e||s?.eventType==="assignment"||s?.updateType==="assignment"))return console.log(`${this.logPrefix} Sending mandatory dashboard assignment notification to user ${e}`),!0;if(!r?.notification_preferences)return!0;let l=r.notification_preferences,{email:o=!0,push:d=!0,sms:c=!0}=r.notification_preferences;if(!o&&!d&&!c)return console.log(`${this.logPrefix} All notification channels disabled for user ${e}`),!1;if(t.startsWith("payment_")||t.startsWith("payout_")){let s=r.notification_preferences.financial;if(h(l,"financial"))return console.log(`${this.logPrefix} Financial notifications disabled for user ${e}`),!1;if(t===a.NotificationType.PAYMENT_FAILURE&&s?.paymentFailures===!1||t===a.NotificationType.PAYMENT_SUCCESS&&s?.paymentSuccesses===!1||t===a.NotificationType.PAYOUT_INITIATED&&s?.payoutInitiated===!1||t===a.NotificationType.PAYOUT_COMPLETED&&s?.payoutCompleted===!1||t===a.NotificationType.PAYOUT_FAILED&&s?.payoutFailed===!1)return!1}if(t===a.NotificationType.MESSAGE||t===a.NotificationType.THREAD_UPDATE||t===a.NotificationType.MENTION){let e=r.notification_preferences.messages;if(h(l,"messages")){if(t===a.NotificationType.MENTION&&e?.mentions===!0)return!0;return!1}if(t===a.NotificationType.MESSAGE&&e?.directMessages===!1||t===a.NotificationType.MENTION&&e?.mentions===!1||t===a.NotificationType.THREAD_UPDATE&&e?.groupMessages===!1)return!1}if(t===a.NotificationType.DASHBOARD_ASSIGNMENT){let t=r.notification_preferences.messages;if(t?.assignments===!0)return!0;if(h(l,"messages")&&t?.assignments!==!0)return console.log(`${this.logPrefix} Assignment notifications disabled for user ${e}`),!1;return!0}if(t.startsWith("review_")||t===a.NotificationType.REVIEW){let i=r.notification_preferences.reviews;if(h(l,"reviews"))return console.log(`${this.logPrefix} Review notifications disabled for user ${e}`),!1;if(s?.rating!==void 0){let e=Number(s.rating);if(!isNaN(e)){let t=5===e?"positive":"negative";if(s.sentiment=t,"positive"===t&&i?.includePositive===!1||"negative"===t&&i?.includeNegative===!1)return!1}}if(t===a.NotificationType.REVIEW_REMINDER&&i?.reminders===!1||t===a.NotificationType.REVIEW_RESPONSE_RECEIVED&&i?.responses===!1)return!1}if(t.startsWith("reservation_")||t===a.NotificationType.CHECKIN_REMINDER||t===a.NotificationType.CHECKOUT_REMINDER){let e=r.notification_preferences.reservations;if(h(l,"reservations")||t===a.NotificationType.RESERVATION_CREATED&&e?.newBookings===!1||t===a.NotificationType.RESERVATION_CONFIRMED&&e?.confirmations===!1||t===a.NotificationType.RESERVATION_CANCELLED&&e?.cancellations===!1||t===a.NotificationType.RESERVATION_MODIFIED&&e?.modifications===!1||t===a.NotificationType.RESERVATION_UPDATED&&e?.modifications===!1||t===a.NotificationType.RESERVATION_PAYMENT_PENDING&&e?.payments===!1||t===a.NotificationType.RESERVATION_PAYMENT_COMPLETED&&e?.payments===!1||t===a.NotificationType.RESERVATION_REQUESTED&&e?.inquiries===!1||t===a.NotificationType.RESERVATION_REQUEST&&e?.inquiries===!1||t===a.NotificationType.RESERVATION_REQUEST_VOIDED&&e?.inquiries===!1||t===a.NotificationType.CHECKIN_REMINDER&&e?.checkInReminders===!1||t===a.NotificationType.CHECKOUT_REMINDER&&e?.checkOutReminders===!1)return!1}if(t===a.NotificationType.UPSELL_REQUEST){let e=r.notification_preferences.reservations;if(e?.upsellRequests===!1)return!1;return!0}if(t===a.NotificationType.BLACKLISTED_GUEST_BOOKING){let e=r.notification_preferences.reservations;if(e?.blacklistedGuestBookings===!1)return!1;return!0}if(t.startsWith("listing_")){let e=r.notification_preferences.listings;if(h(l,"listings")||t===a.NotificationType.LISTING_PUBLISHED&&e?.published===!1||t===a.NotificationType.LISTING_UNPUBLISHED&&e?.unpublished===!1||t===a.NotificationType.LISTING_UPDATED&&e?.updates===!1||t===a.NotificationType.LISTING_ISSUE&&e?.issues===!1||t===a.NotificationType.LISTING_SUSPENDED&&e?.suspensions===!1||t===a.NotificationType.LISTING_REACTIVATED&&e?.reactivations===!1)return!1}if(t.startsWith("calendar_")||t===a.NotificationType.PRICE_UPDATE){let s=r.notification_preferences.calendar;if(h(l,"calendar"))return console.log(`${this.logPrefix} Calendar notifications disabled for user ${e}
36`),!1;if(t===a.NotificationType.CALENDAR_CONFLICT&&s?.conflicts===!1||t===a.NotificationType.CALENDAR_UPDATE&&s?.updates===!1||t===a.NotificationType.PRICE_UPDATE&&s?.priceChanges===!1)return!1}if(t===a.NotificationType.TASK_COMPLETED){let t=r.notification_preferences.operations;if(t?.enabled===!1)return console.log(`${this.logPrefix} Operations notifications disabled for user ${e}`),!1;if(t?.taskCompleted===!1)return!1}if(!function(e,t){let a="TASK_ISSUE_REPORTED"===t?"issueReported":"TASK_ISSUE_RESOLVED"===t?"issueResolved":null;if(!a)return!0;let r=e?.operations;return!r||!1!==r.enabled&&!1!==r[a]}(r.notification_preferences,t))return!1;if(["progress_required","deadline_approaching","marketplace_opportunity","task_released","confirmation_required","task_overdue"].includes(t)){let t=r.notification_preferences.operations;if(t?.enabled===!1)return console.log(`${this.logPrefix} Task marketplace notifications disabled for user ${e}`),!1}if("voice_call_attention"===t){let t=r.notification_preferences.operations;if(t?.enabled===!1)return console.log(`${this.logPrefix} Voice call notifications disabled for user ${e}`),!1}if(t===a.NotificationType.SYSTEM||t===a.NotificationType.ERROR||t===a.NotificationType.SYNC||t===a.NotificationType.MAINTENANCE){let s=r.notification_preferences.system;if(h(l,"system"))return console.log(`${this.logPrefix} System notifications disabled for user ${e}`),!1;if(t===a.NotificationType.ERROR&&s?.errors===!1||t===a.NotificationType.SYNC&&s?.syncs===!1||t===a.NotificationType.MAINTENANCE&&s?.maintenance===!1)return!1}if(t===a.NotificationType.PERFORMANCE_ALERT||t===a.NotificationType.RANKING_CHANGE||t===a.NotificationType.QUALITY_ISSUE){let s=r.notification_preferences.performance;if(h(l,"performance"))return console.log(`${this.logPrefix} Performance notifications disabled for user ${e}`),!1;if(t===a.NotificationType.PERFORMANCE_ALERT&&s?.alerts===!1||t===a.NotificationType.RANKING_CHANGE&&s?.rankingChanges===!1||t===a.NotificationType.QUALITY_ISSUE&&s?.qualityIssues===!1)return!1}if(t.startsWith("guest_")){let s=r.notification_preferences.guests;if(h(l,"guests"))return console.log(`${this.logPrefix} Guest notifications disabled for user ${e}`),!1;if(t===a.NotificationType.GUEST_COMPLAINT&&s?.complaints===!1||t===a.NotificationType.GUEST_REQUEST&&s?.requests===!1||t===a.NotificationType.GUEST_REVIEW_ALERT&&s?.reviewAlerts===!1)return!1}if(t===a.NotificationType.QUALITY_STANDARD&&(r.notification_preferences.quality,h(l,"quality")))return console.log(`${this.logPrefix} Quality standard notifications disabled for user ${e}`),!1;if(t===a.NotificationType.TIMELINE_UPDATE){let t=r.notification_preferences.timeline;if(h(l,"timeline")&&s?.eventType!=="assignment"&&s?.updateType!=="assignment")return console.log(`${this.logPrefix} Timeline notifications disabled for user ${e}`),!1;if(s?.eventType!=="assignment"&&s?.updateType!=="assignment"&&t?.updates===!1)return!1}if("inquiry_created"===t||t.includes("inquiry")){let e=r.notification_preferences.reservations;if(h(l,"reservations")||e?.inquiries===!1)return!1}if(t.startsWith("host_")){let s=r.notification_preferences.hosts;if(h(l,"hosts"))return console.log(`${this.logPrefix} Host notifications disabled for user ${e}`),!1;if((t===a.NotificationType.HOST_SUSPENDED||t===a.NotificationType.HOST_REACTIVATED)&&s?.restrictions===!1||t===a.NotificationType.HOST_AUTHORIZATION_REVOKED&&s?.authorization===!1||t===a.NotificationType.HOST_ACCOUNT_ACTIVATED&&s?.accountStatus===!1)return!1}if(t.startsWith("iot_")){let s=r.notification_preferences.smartDevices;if(h(l,"smartDevices"))return console.log(`${this.logPrefix} Smart device notifications disabled for user ${e}`),!1;if(t===a.NotificationType.IOT_BATTERY)return s?.batteryAlerts!==!1;if(t===a.NotificationType.IOT_WIFI)return s?.wifiConnectivity!==!1;return!1}if("display"===i){let{data:t}=await this.supabase.from("notification_recipients").select("id").eq("notification_id",s?.notificationId).eq("user_id",e).maybeSingle();return!!t}return!0}catch(e){return console.error(`${this.logPrefix} Error checking notification preferences:`,e),"delivery"===i}}async findRelevantUsersForNotification(e,t,a,r,s){if(!this.supabase)return console.warn(`${this.logPrefix} Supabase client not initialized. This method can only be called server-side.`),[];try{let{data:i,error:n}=await this.supabase.from("users").select(` 37 id, 38 notification_preferences, 39 user_roles!inner( 40 role, 41 active 42 ) 43 `).eq("user_roles.customer_id",e).eq("user_roles.active",!0);if(n)return console.error(`${this.logPrefix} Error fetching users for customer:`,n),[];if(!i||0===i.length)return console.log(`${this.logPrefix} No users with active roles found for customer ${e}`),[];let l=new Map;
43i.forEach(e=>{let t=e.user_roles?.filter(e=>e.active).map(e=>e.role)||[];l.set(e.id,t)});let o=[];for(let e of i){let i=e.notification_preferences||{};if(!1===i.email&&!1===i.push&&!1===i.sms){console.log(`${this.logPrefix} User ${e.id} has all notification channels disabled`);continue}if(!await this.shouldSendNotificationToUser(e.id,t,a,s))continue;let n=l.get(e.id)||[],d=this.determineTargetReasonByRoleAndType(n,t,a,r,s,e.id);d&&o.push({userId:e.id,targetReason:d,shouldReceiveEmail:!1!==i.email,shouldReceivePush:!1!==i.push,shouldReceiveSms:!1!==i.sms,isOperatorRole:n.includes("user")})}if("task_issue"===a){let t=await this.filterIssueRecipientsByListingAccess(o,e,s,r);return await this.filterIssueRecipientsByTaskType(t,e,s,r)}if(a&&m.includes(a)||t&&u.includes(t))return await this.filterRecipientsByDirectListingAccess(o,e,a,r,s,{grantlessIsUnrestricted:!0});return o}catch(e){return console.error(`${this.logPrefix} Error finding relevant users:`,e),[]}}async accessibleListingIdsForScope(e,t,a,r){if("admin"===e.targetReason)return null;let{data:s}=await this.supabase.from("users").select("super_user").eq("id",e.userId).maybeSingle();if(s?.super_user===!0)return null;let i=new Set,{data:n,error:l}=await this.supabase.from("user_listing_permissions").select("listing_id").eq("user_id",e.userId).eq("customer_id",t).in("listing_id",a);if(l)throw Error(`direct perms: ${l.message}`);(n||[]).forEach(e=>i.add(Number(e.listing_id)));let{data:o,error:d}=await this.supabase.from("user_group_members").select("group_id").eq("user_id",e.userId);if(d)throw Error(`group membership: ${d.message}`);let c=(o||[]).map(e=>e.group_id).filter(Boolean);if(c.length>0){let{data:e,error:r}=await this.supabase.from("group_listing_permissions").select("listing_id").eq("customer_id",t).in("group_id",c).in("listing_id",a);if(r)throw Error(`group perms: ${r.message}`);(e||[]).forEach(e=>i.add(Number(e.listing_id)))}try{let{data:t}=await this.supabase.from("user_listing_group_permissions").select("id").eq("user_id",e.userId).limit(1);if(t&&t.length>0)return null;if(c.length>0){let{data:e}=await this.supabase.from("group_listing_group_permissions").select("id").in("group_id",c).limit(1);if(e&&e.length>0)return null}}catch{return null}if(r?.grantlessIsUnrestricted&&!0===e.isOperatorRole&&0===i.size){let{data:a,error:r}=await this.supabase.from("user_listing_permissions").select("listing_id").eq("user_id",e.userId).eq("customer_id",t).limit(1);if(r)return i;if(!a||0===a.length){if(0===c.length)return null;let{data:e,error:a}=await this.supabase.from("group_listing_permissions").select("listing_id").eq("customer_id",t).in("group_id",c).limit(1);if(a)return i;if(!e||0===e.length)return null}}return i}async filterIssueRecipientsByListingAccess(e,t,a,s){if(0===e.length)return e;try{let i=a?.taskId??s?.taskId,n=Number(i);if(!i||!Number.isFinite(n))return e;let{data:l,error:o}=await this.supabase.from("task_relations").select("listing_id").eq("task_id",n);if(o)return console.warn(`${this.logPrefix} #727 listing lookup failed for task ${n}; not filtering:`,o.message),e;let d=(l||[]).map(e=>Number(e.listing_id)).filter(e=>Number.isFinite(e));if(0===d.length)return e;let c=[];for(let a of e)try{let e=await this.accessibleListingIdsForScope(a,t,d);r(e,d)&&c.push(a)}catch(e){console.warn(`${this.logPrefix} #727 access lookup failed for ${a.userId}; keeping:`,e),c.push(a)}return c}catch(t){return console.warn(`${this.logPrefix} #727 scope filter errored; sending unfiltered:`,t),e}}async filterIssueRecipientsByTaskType(e,t,a,r){if(0===e.length)return e;try{let i=a?.taskId??r?.taskId,m=Number(i);if(!i||!Number.isFinite(m))return e;let u=Array.from(new Set(e.map(e=>e.userId))),{data:h,error:x}=await this.supabase.from("workspace_connections").select("provider_customer_id, allowed_task_categories").eq("host_customer_id",t).eq("status","active");if(x)return e;let g=Array.from(new Set((h||[]).map(e=>Number(e.provider_customer_id)))),{data:p,error:b}=await this.supabase.from("user_task_type_permissions").select("user_id, customer_id, allowed_categories").in("user_id",u).in("customer_id",[t,...g]);if(b)return e;let f=(h||[]).some(e=>null!==n(e.allowed_task_categories));if(0===(p||[]).length&&!f)return e;let{data:y,error:w}=await this.supabase.from("tasks").select("id, category, task_assignments(user_id, status, acceptance_status)").eq("id",m).maybeSingle();if(w||!y)return e;let{data:v,error:k}=await this.supabase.from("users").select("id, super_user").in("id",u),{data:j,error:N}=await this.supabase.from("user_roles").select("user_id, customer_id, role").in("user_id",u).in("customer_id",[t,...g]).eq("active",!0);if(k||N)return e;let C=new Set((y.task_assignments||[]).filter(e=>(function(e){if(!e)return!1;let t=e.status??null;if(null!==t&&d.has(t))return!1;let a=e.acceptance_status??null;return!((null===t||"pending"===t)&&null!==a&&c.has(a))})(e)).map(e=>e.user_id)),S=(e,t)=>(j||[]).filter(a=>a.user_id===e&&Number(a.customer_id)===t).map(e=>String(e.role)),E=(e,t)=>(p||[]).find(a=>a.user_id===e&&Number(a.customer_id)===t)?.allowed_categories??null;return e.filter(e=>{var a;let r=function(e){if(e.superUser||o(e.hostRoles))return null;let t=n(e.hostAllowed);
43for(let a of e.connectionPaths){if(0===a.providerRoles.length)continue;let e=o(a.providerRoles)?null:n(a.providerAllowed);t=l(t,l(n(a.connectionAllowed),e))}return t}({superUser:!!(v||[]).find(t=>t.id===e.userId)?.super_user,hostRoles:S(e.userId,t),hostAllowed:E(e.userId,t),connectionPaths:(h||[]).map(t=>({providerRoles:S(e.userId,Number(t.provider_customer_id)),providerAllowed:E(e.userId,Number(t.provider_customer_id)),connectionAllowed:t.allowed_task_categories}))});return a=y.category,C.has(e.userId)||null===r||!!a&&!!(0,s.isTaskCategory)(a)&&r.has(a)})}catch(t){return console.warn(`${this.logPrefix} task-type recipient filter errored; sending unfiltered:`,t),e}}async filterRecipientsByDirectListingAccess(e,t,a,s,i,n){if(0===e.length)return e;try{let{listingId:l}=function(e,t){for(let[a,r]of[[e,"sourceReference"],[t,"metadata"]]){if(!a)continue;let e=a.listingId??a.listing_id;if(null==e||""===e)continue;let t=Number(e);if(Number.isInteger(t)&&t>0)return{listingId:t,source:r}}return{listingId:null,source:null}}(s,i);if(null===l)return e;let o=[l],d=[];for(let s of e)try{let e=await this.accessibleListingIdsForScope(s,t,o,n);r(e,o)?d.push(s):console.log(`${this.logPrefix} listing-scope: dropped ${s.userId} from ${a} notification for listing ${l} (no access)`)}catch(e){console.warn(`${this.logPrefix} listing-scope: access lookup failed for ${s.userId}; keeping:`,e),d.push(s)}return d}catch(t){return console.warn(`${this.logPrefix} listing-scope filter errored; sending unfiltered:`,t),e}}determineTargetReasonByRoleAndType(e,t,r,s,i,n){return"mention"===t?i?.mentionedUserId===n?"direct":"":this.supabase?e.some(e=>["owner","admin"].includes(e))?"admin":(t.startsWith("listing_")||"listing"===r)&&e.some(e=>["listing_owner","user"].includes(e))?"listing_manager":(t.startsWith("reservation_")||"reservation"===r)&&e.some(e=>["user"].includes(e))?"reservation_manager":t===a.NotificationType.UPSELL_REQUEST||"upsell"===r?e.some(e=>["user"].includes(e))?"upsell_manager":"":t===a.NotificationType.BLACKLISTED_GUEST_BOOKING?e.some(e=>"user"===e)?"blacklist_manager":"":(t.startsWith("payment_")||t.startsWith("payout_")||"financial"===r)&&e.some(e=>["accountant","bookkeeper","user"].includes(e))?"financial_manager":(t.startsWith("review_")||"review"===r)&&e.some(e=>["user"].includes(e))?"review_manager":(t.startsWith("maintenance_")||"maintenance"===r)&&e.some(e=>["maintenance","roamer","inspector","team_lead","supervisor"].includes(e))?"maintenance_staff":(t.startsWith("cleaning_")||"cleaning"===r)&&e.some(e=>["cleaner","roamer","inspector","team_lead","supervisor"].includes(e))?"cleaning_staff":(t.startsWith("guest_")||"guest"===r)&&e.some(e=>["concierge","user"].includes(e))?"guest_services":(t===a.NotificationType.SYSTEM||t===a.NotificationType.ERROR||t===a.NotificationType.MAINTENANCE||t===a.NotificationType.SYNC)&&e.some(e=>["user"].includes(e))?"system_manager":"dashboard_assignment"===t||n&&i?.assignedTo===n?"assignee":e.includes("user")?"standard_user":"":(console.warn(`${this.logPrefix} Supabase client not initialized. This method can only be called server-side.`),"")}async getUserNotifications(e,t,a=25,r=0,s=!1){return console.warn(`${this.logPrefix} getUserNotifications should not be called directly from client-side code.`),[]}convertToUserNotification(e,t){return{...e,is_read:t.is_read,is_archived:t.is_archived,recipient_status:{is_read:t.is_read,is_archived:t.is_archived,target_reason:t.target_reason,email_sent:t.email_sent,push_sent:t.push_sent,sms_sent:t.sms_sent}}}collapseByThread(e){let t=new Set(["message","thread_update","mention","timeline_update","dashboard_assignment"]),a=new Map,r=[];for(let s of e){let e=s.source_reference?.threadId||s.source_reference?.dashboardItemId;if(e&&t.has(s.type)){let t=String(e);a.has(t)||a.set(t,[]),a.get(t).push(s)}else r.push(s)}let s=[];for(let[,e]of a){let t=e[0];e.length>1&&(t.collapsed_count=e.length,t.collapsed_ids=e.slice(1).map(e=>e.id)),s.push(t)}return[...s,...r].sort((e,t)=>new Date(t.created_at).getTime()-new Date(e.created_at).getTime())}async markBatchAsReadForUser(e,t){if(!this.supabase||!e.length)return!1;try{for(let a of e){let{data:e}=await this.supabase.from("notification_recipients").select("id").eq("notification_id",a).eq("user_id",t).maybeSingle();e?await this.supabase.from("notification_recipients").update({is_read:!0,updated_at:new Date().toISOString()}).eq("id",e.id):await this.supabase.from("notification_recipients").insert({notification_id:a,user_id:t,is_read:!0})}return!0}catch(e){return console.error(`${this.logPrefix} Error batch marking as read:`,e),!1}}async markAsReadForUser(e,t){if(!this.supabase)return console.warn(`${this.logPrefix} Supabase client not initialized. This method can only be called server-side.`),!1;try{let{data:a,error:r}=await this.supabase.from("notification_recipients").select("id").eq("notification_id",e).eq("user_id",t).maybeSingle();if(r)throw console.error(`${this.logPrefix} Error checking for recipient record:`,r),r;if(a){let{error:e}=await this.supabase.from("notification_recipients").update({is_read:!0,updated_at:new Date().toISOString()}).eq("id",a.id);if(e)throw e}else{let{data:a,error:r}=await this.supabase.from("notifications").select("id").eq("id",e).maybeSingle();if(r)throw r;if(!a)throw Error("Notification not found");let{error:s}=await this.supabase.from("notification_recipients").insert({notification_id:e,user_id:t,is_read:!0,is_archived:!1,target_reason:"manual_read"});if(s)throw s}return window.dispatchEvent(new CustomEvent("notification:read",{detail:{id:e}})),!0}catch(e){throw console.error(`${this.logPrefix} Error marking notification as read:`,e),e}}async markAllAsReadForUser(e,t,a){if(!this.supabase)return console.warn(`${this.logPrefix} Supabase client not initialized.`),!1;try{console.log(`${this.logPrefix} Marking all notifications as read for user:`,{userId:e,customerId:t,excludePriority:a});let r=this.supabase.from("notification_recipients").select("notification_id, user_id, is_read, is_archived").eq("user_id",e).eq("is_read",!1);a&&(r=this.supabase.from("notification_recipients").select(` 44 notification_id, 45 user_id, 46 is_read, 47 is_archived, 48 notification:notifications!inner(priority) 49 `).eq("user_id",e).eq("is_read",!1).eq("notifications.customer_id",t).neq("notifications.priority",a));let{data:s,error:i}=await r;if(i)throw i;if(!s||0===s.length)return console.log(`${this.logPrefix}
49 No unread notifications found for user ${e}`),!0;let{error:n}=await this.supabase.rpc("mark_notifications_read_for_user",{p_user_id:e,p_notification_ids:s.map(e=>e.notification_id)});if(n)throw n;return!0}catch(e){return console.error(`${this.logPrefix} Error marking all notifications as read:`,e),!1}}async archiveNotificationForUser(e,t){if(!this.supabase)return console.warn(`${this.logPrefix} Supabase client not initialized. This method can only be called server-side.`),[];try{let{data:a,error:r}=await this.supabase.from("notification_recipients").select("id").eq("notification_id",e).eq("user_id",t).maybeSingle();if(r)throw console.error(`${this.logPrefix} Error checking for recipient record:`,r),r;if(a){let{error:e}=await this.supabase.from("notification_recipients").update({is_archived:!0,is_read:!0,updated_at:new Date().toISOString()}).eq("id",a.id);if(e)throw e}else{let{data:a,error:r}=await this.supabase.from("notifications").select("id").eq("id",e).maybeSingle();if(r)throw r;if(!a)throw Error("Notification not found");let{error:s}=await this.supabase.from("notification_recipients").insert({notification_id:e,user_id:t,is_read:!0,is_archived:!0,target_reason:"manual_archive"});if(s)throw s}let{data:s,error:i}=await this.supabase.from("notification_recipients").select(` 50 *, 51 notification:notifications(*) 52 `).eq("notification_id",e).eq("user_id",t).single();if(i||!s)throw i||Error("Failed to retrieve updated notification");return this.convertToUserNotification(s.notification,s)}catch(e){throw console.error(`${this.logPrefix} Error archiving notification:`,e),e}}async archiveAllForUser(e,t){if(!this.supabase)return console.warn(`${this.logPrefix} Supabase client not initialized.`),!1;try{console.log(`${this.logPrefix} Archiving all notifications for user:`,{userId:e,customerId:t});let{data:a,error:r}=await this.supabase.from("notification_recipients").select("notification_id").eq("user_id",e).eq("is_archived",!1);if(r)throw r;if(!a||0===a.length)return console.log(`${this.logPrefix} No unarchived notifications found for user ${e}`),!0;let{error:s}=await this.supabase.from("notification_recipients").update({is_archived:!0}).eq("user_id",e).eq("is_archived",!1);if(s)throw s;return console.log(`${this.logPrefix} Successfully archived all notifications for user ${e}`),!0}catch(e){return console.error(`${this.logPrefix} Error archiving all notifications:`,e),!1}}async getUnreadCountForUser(e,t){if(!this.supabase)return console.warn(`${this.logPrefix} Supabase client not initialized. This method can only be called server-side.`),0;try{let{data:a,error:r}=await this.supabase.from("users").select("notification_preferences").eq("id",e).single();r&&console.error(`${this.logPrefix} Error fetching user preferences:`,r);let{data:s,error:i}=await this.supabase.from("notifications").select("id, type, source_type, metadata, priority").eq("customer_id",t);if(i)throw i;if(!s||0===s.length)return 0;let{data:n,error:l}=await this.supabase.from("notification_recipients").select("notification_id, is_read, is_archived").eq("user_id",e);if(l)throw l;let o=new Set((n||[]).map(e=>e.notification_id)),d=await Promise.all(s.map(async t=>!o.has(t.id)&&("critical"===t.priority||await this.shouldSendNotificationToUser(e,t.type,t.source_type,t.metadata)))).then(e=>e.filter(Boolean).length);return console.log(`${this.logPrefix} Unread count for user ${e}:`,{total:s.length,unread:d}),d}catch(e){return console.error(`${this.logPrefix} Error getting unread count:`,e),0}}async sendPushNotificationsToUser(e,a,r){if(!this.supabase)return console.warn(`${this.logPrefix} Supabase client not initialized. This method can only be called server-side.`),!1;try{console.log(`${this.logPrefix} Sending push notifications to user:`,{userId:e,customerId:a,notificationId:r.id});let{data:s,error:i}=await this.supabase.from("users").select("notification_preferences").eq("id",e).single(),n=s?.notification_preferences,l=n?.delivery,o=l?!1===l.push:n?.push===!1;if(i||o)return console.log(`${this.logPrefix} Push notifications disabled for user ${e}
52`),!1;let{data:d,error:c}=await this.supabase.from("push_subscriptions").select("*").eq("user_id",e);if(c)return console.error(`${this.logPrefix} Error fetching push subscriptions:`,c),!1;if(!d||0===d.length)return console.log(`${this.logPrefix} No push subscriptions found for user ${e}`),!1;console.log(`${this.logPrefix} Found ${d.length} push subscriptions for user ${e}`);let m=r.title,u=r.message||"";r.metadata;let h=r.source_reference||{},x=r.type,g=(await Promise.allSettled(d.map(e=>{let a={endpoint:e.endpoint,keys:{p256dh:e.p256dh,auth:e.auth}};return this.sendPushNotification(a,{title:m,message:u,metadata:{sourceReference:h,type:x}}).catch(a=>a instanceof t.default.WebPushError&&(410===a.statusCode||404===a.statusCode)?(console.log(`${this.logPrefix} Removing invalid/expired push subscription (${a.statusCode}):`,e.endpoint),this.removePushSubscription(e.endpoint)):(console.error(`${this.logPrefix} Error sending push to ${e.endpoint}:`,a),!1))}))).filter(e=>"fulfilled"===e.status&&e.value).length;if(console.log(`${this.logPrefix} Successfully sent ${g}/${d.length} push notifications`),g>0)try{await this.supabase.from("notification_recipients").update({push_sent:!0,push_sent_at:new Date().toISOString()}).eq("notification_id",r.id).eq("user_id",e)}catch(e){console.error(`${this.logPrefix} Error updating push sent status:`,e)}return g>0}catch(e){return console.error(`${this.logPrefix} Error sending push notifications to user:`,e),!1}}async searchUserNotifications(e,t,a){if(!this.supabase)return console.warn(`${this.logPrefix} Supabase client not initialized. This method can only be called server-side.`),[];try{console.log(`${this.logPrefix} Searching user notifications:`,{userId:e,customerId:t,searchParams:a});let r=a.limit||25,s=a.offset||0,i=this.supabase.from("notification_recipients").select(` 53 *, 54 notification:notifications(*) 55 `).eq("user_id",e).eq("notifications.customer_id",t);void 0!==a.isRead&&(i=i.eq("is_read",a.isRead)),void 0!==a.isArchived&&(i=i.eq("is_archived",a.isArchived)),a.types&&a.types.length>0&&(i=i.in("notifications.type",a.types)),a.sourceTypes&&a.sourceTypes.length>0&&(i=i.in("notifications.source_type",a.sourceTypes)),a.fromDate&&(i=i.gte("notifications.created_at",a.fromDate.toISOString())),a.toDate&&(i=i.lte("notifications.created_at",a.toDate.toISOString())),a.keyword&&(i=i.or(`notifications.title.ilike.%${a.keyword}%,notifications.message.ilike.%${a.keyword}%`)),i=i.order("notifications.created_at",{ascending:!1}).range(s,s+r-1);let{data:n,error:l}=await i;if(l)throw l;if(!n||0===n.length)return[];return n.map(e=>this.convertToUserNotification(e.notification,e))}catch(e){throw console.error(`${this.logPrefix} Error searching user notifications:`,e),e}}async getNotificationStats(e,t){if(!this.supabase)return console.warn(`${this.logPrefix} Supabase client not initialized. This method can only be called server-side.`),{unreadCount:0,priorityUnreadCount:0,totalCount:0,recentNotificationDate:null};try{let{data:a,error:r}=await this.supabase.from("notifications").select("id, priority, created_at").eq("customer_id",t).order("created_at",{ascending:!1});if(r)throw r;let{data:s,error:i}=await this.supabase.from("notification_recipients").select("notification_id, is_read, is_archived").eq("user_id",e);if(i)throw i;let n=new Map,l=new Map;(s||[]).forEach(e=>{n.set(e.notification_id,e.is_read),l.set(e.notification_id,e.is_archived)});let o=0,d=0,c=0,m=null;if(a)for(let e of(a.length>0&&(m=a[0].created_at),a)){let t=!!n.has(e.id)&&n.get(e.id);!(l.has(e.id)&&l.get(e.id))&&(c++,!t&&(o++,("high"===e.priority||"critical"===e.priority)&&d++))}return{unreadCount:o,priorityUnreadCount:d,totalCount:c,recentNotificationDate:m}}catch(e){return console.error(`${this.logPrefix} Error getting notification stats:`,e),{unreadCount:0,priorityUnreadCount:0,totalCount:0,recentNotificationDate:null}}}async getUserNotificationPreferences(e){if(!this.supabase)throw console.warn(`${this.logPrefix} Supabase client not initialized. This method can only be called server-side.`),Error("Supabase client not initialized");try{let{data:t,error:a}=await this.supabase.from("users").select("notification_preferences").eq("id",e).single();if(a)throw a;return t?.notification_preferences||{}}catch(e){throw console.error(`${this.logPrefix} Error fetching notification preferences:`,e),e}}async updateUserNotificationPreferences(e,t){if(!this.supabase)throw console.warn(`${this.logPrefix} Supabase client not initialized. This method can only be called server-side.`),Error("Supabase client not initialized");try{let{data:a,error:r}=await this.supabase.from("users").select("notification_preferences").eq("id",e).single();if(r)throw r;let s=a?.notification_preferences||{},i=this.deepMerge(s,t),{data:n,error:l}=await this.supabase.from("users").update({notification_preferences:i}).eq("id",e).select("notification_preferences").single();if(l)throw l;return n?.notification_preferences||i}catch(e){throw console.error(`${this.logPrefix} Error updating notification preferences:`,e),e}}deepMerge(e,t){let a=e=>e&&"object"==typeof e&&!Array.isArray(e);if(!a(e)||!a(t))return t;let r={...e};return Object.keys(t).forEach(s=>{a(t[s])&&s in e?r[s]=this.deepMerge(e[s],t[s]):r[s]=t[s]}),r}async getNotificationsByType(e,t,a,r=25,s=0){if(!this.supabase)return console.warn(`${this.logPrefix} Supabase client not initialized. This method can only be called server-side.`),[];try{let{data:i,error:n}=await this.supabase.from("notification_recipients").select(` 56 *, 57 notification:notifications(*) 58 `).eq("user_id",e).eq("notifications.customer_id",t).eq("notifications.type",a).eq("is_archived",!1).order("notifications.created_at",{ascending:!1}).range(s,s+r-1);if(n)throw n;if(!i||0===i.length)return[];return i.filter(e=>e.notification&&e.notification.type).map(e=>this.convertToUserNotification(e.notification,e))}catch(e){throw console.error(`${this.logPrefix} Error getting notifications by type:`,e),e}}};e.s(["notificationService",0,p],956846)},272922,e=>{"use strict";e.s(["resolveIssuesIndicator",0,function(e){let t=e.ownIssues||[],a=e.propertyIssues||[],r=t.filter(e=>"resolved"!==e.status),s=r.length,i=r.filter(e=>!!e.isFromSubtask).length,n=a.length,l=n>10,o=l?10:n,d=s+o;return{mode:d>0?"open":"add",openCount:d,capped:l,blocking:r.some(e=>!!e.is_blocking)||a.some(e=>!!e.is_blocking),propertyWide:n>0,ownOpenCount:s,propertyOpenCount:o,subtaskOpenCount:i,ownIssueCount:t.length}}])},904257,886263,92167,131715,839221,877223,32979,633393,843409,410839,673811,37020,675897,760080,155274,e=>{"use strict";e.s(["TaskSubtasks",()=>eR],877223),e.s(["TaskHeader",()=>ee],904257);var t=e.i(843476),a=e.i(271645),r=e.i(37727),s=e.i(283086),i=e.i(195116),n=e.i(286536),l=e.i(201928),o=e.i(194983),d=e.i(178583),c=e.i(16715),m=e.i(358519),u=e.i(354385),h=e.i(664659),x=e.i(95740),g=e.i(555436),p=e.i(548433),b=e.i(878894),f=e.i(503116),y=e.i(751975),w=e.i(87316),v=e.i(158524),k=e.i(39312),j=e.i(107233),N=e.i(908263),C=e.i(355390
58),S=e.i(819813),E=e.i(979357),I=e.i(173922),T=e.i(719910),_=e.i(639907),A=e.i(376761),D=e.i(289562),P=e.i(133820),R=e.i(816933),M=e.i(864218),F=e.i(232753),L=e.i(784070),$=e.i(406671),O=e.i(337607),U=e.i(201795),B=e.i(846594),q=e.i(180239),z=e.i(568612),H=e.i(730603),V=e.i(217255),G=e.i(144662),W=e.i(451076),K=e.i(272922);let Y={maintenance:i.Wrench,cleaning:s.Sparkles,inspection:n.Eye,purchase:l.ShoppingCart,communication:o.MessageCircle,documentation:d.FileText,turnover:c.RefreshCw,deep_cleaning:m.Brush,laundry:p.Bed,other:u.ClipboardCheck},J=new Set,Q=e=>{switch(e){case"in_progress":return"In Progress";case"todo":return"To Do";default:return e.charAt(0).toUpperCase()+e.slice(1)}},X=e=>e.replace("_"," ").split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),Z=e=>e.charAt(0).toUpperCase()+e.slice(1);function ee({task:e,onClose:s,onUpdate:i,checklist:l,activeViewers:o,typingUsers:d,isConnected:c,onStartExecution:m,onScrollToTimeline:p,onToggleIssues:et}){let ea,{users:{users:er,groups:es},isLoadingUsers:ei,currentCustomerId:en}=(0,P.useCustomer)(),el=(0,z.useUserSettings)(en||void 0),{data:eo}=(0,V.useSession)(),[ed,ec]=(0,a.useState)(null),[em,eu]=(0,a.useState)(null),[eh,ex]=(0,a.useState)(""),[eg,ep]=(0,a.useState)(null),[eb,ef]=(0,a.useState)({}),[ey,ew]=(0,a.useState)(()=>e.due_date?new Date(e.due_date):new Date),[ev,ek]=(0,a.useState)(!1),[ej,eN]=(0,a.useState)(!1),eC=el.getCurrentRole(en||void 0),eS=(0,a.useMemo)(()=>eC&&["cleaner","maintenance","partner"].includes(eC),[eC]),eE=(0,a.useMemo)(()=>"cleaner"!==eC&&"maintenance"!==eC,[eC]),eI=(0,a.useMemo)(()=>{if(eC&&["admin","owner","user","team_lead","supervisor","roamer"].includes(eC))return!0;if(eC&&["partner","maintenance","cleaner"].includes(eC)){let t=eo?.user?.id;if(!t)return!1;if(e.assignments?.some(e=>e.user_id===t))return!0;if("partner"===eC&&el.settings?.partner?.partnerId){let t=el.settings.partner.partnerId,a=er.filter(e=>{let a=e.company?.companyId===t,r=e.serviceProvider?.type==="company"&&e.serviceProvider?.id===t;return a||r}).map(e=>e.id);if(e.assignments?.some(e=>a.includes(e.user_id)))return!0}return!1}return!0},[eC,e.assignments,eo?.user?.id,el.settings,er]),eT=(0,a.useMemo)(()=>{let t=el.settings?.partner?.partnerId,a="partner"===eC&&t&&er?er.filter(e=>e.company?.companyId===t||e.serviceProvider?.type==="company"&&e.serviceProvider?.id===t).map(e=>e.id):[];return(0,C.canEditTaskAssignment)({role:eC,userId:eo?.user?.id,assigneeUserIds:(e?.assignments||[]).map(e=>e.user_id),companyWorkerUserIds:a})},[eC,e?.assignments,eo?.user?.id,el.settings,er]),e_=(0,a.useMemo)(()=>!(eC&&["partner","maintenance","cleaner"].includes(eC)),[eC]),eA=(0,a.useMemo)(()=>{if(eC===H.USER_ROLE.PARTNER&&el.settings?.partner?.partnerId){let e=el.settings.partner.partnerId;return er.filter(t=>{let a=t.company?.companyId===e,r=t.serviceProvider?.type==="company"&&t.serviceProvider?.id===e;return a||r})}return er},[eC,er,el.settings?.partner?.partnerId]),eD=(0,a.useMemo)(()=>{if(e.id)return e.id.toString()},[e.id]),eP=(0,a.useMemo)(()=>{if(en)return en.toString()},[en]);(0,a.useEffect)(()=>{if(eD)return J.has(eD)||J.add(eD),()=>{clearTimeout(setTimeout(()=>{document.querySelector(`[data-task-id="${eD}"]`)||J.delete(eD)},0))}},[eD,eP]);let eR=(0,O.useTranslations)(),{openSidebar:eM}=(0,U.useTaskSidebar)(),eF=async(t,a)=>{try{if(ec(t),ef(e=>({...e,[t]:a})),!(await fetch(`/api/tasks?taskId=${e.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[t]:a})})).ok)throw Error("Failed to update task");i?.()}catch(e){console.error("[TaskHeader] Error updating task:",e),ef(e=>{let{[t]:a,...r}=e;return r})}finally{ec(null),eu(null),setTimeout(()=>{ef(e=>{let{[t]:a,...r}=e;return r})},100)}},eL=async(t,a)=>{try{if(ec("dueDate"),ef(e=>({...e,dueDate:t})),!(await fetch(`/api/tasks?taskId=${e.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({dueDate:t,dueDateBinding:a??null})})).ok)throw Error("Failed to update task due date");i?.()}catch(e){console.error("[TaskHeader] Error updating due date:",e),ef(e=>{let{dueDate:t,...a}=e;return a})}finally{ec(null),setTimeout(()=>{ef(e=>{let{dueDate:t,...a}=e;return a})},100)}};(0,a.useEffect)(()=>{let e=e=>{em&&(e.target.closest("[data-dropdown-container]")||eu(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[em]);let e$=e.relations?.find(e=>e.listing_id),eO=e$?.listing_id||e.metadata?.listingId,{listing:eU,isLoading:eB,error:eq}=(0,I.useListing)(eO?Number(eO):void 0),{checkInDates:ez,checkOutDates:eH,nextCheckout:eV,nextCheckoutRe
58servationId:eG}=(0,T.useListingBookings)(eO?Number(eO):void 0),eW=Y[e.category]||u.ClipboardCheck;eU&&(eU.id,eU.name?.split("·")[0].trim().slice(0,25),eU.name?.length&&eU.name?.length,eU.thumbnailUrl,eU.location?.address,eU.location?.city,eU.location?.state,eU.location?.address,eU.details?.guests,eU.details?.bedrooms,eU.details?.beds,eU.details?.baths,eU.propertyTypeCategory,eU.roomTypeCategory,eU.businessDetails,eU.platformData);let eK=(0,a.useMemo)(()=>eA.filter(e=>e.roles.some(e=>["cleaner","maintenance"].includes(e))).length,[eA]),eY=!eh&&eK>10,eJ=(0,a.useMemo)(()=>{let e=eh.toLowerCase(),t=eA.filter(t=>t.name.toLowerCase().includes(e)||t.email.toLowerCase().includes(e));if(!e){let e=t.filter(e=>e.roles.some(e=>["cleaner","maintenance"].includes(e)));return[...t.filter(e=>!e.roles.some(e=>["cleaner","maintenance"].includes(e))),...e.slice(0,10)]}return t},[eA,eh]),eQ=(0,a.useMemo)(()=>(0,q.excludeOwnerAssignees)(eJ),[eJ]);(0,a.useMemo)(()=>{let e=eh.toLowerCase();return es.filter(t=>t.name.toLowerCase().includes(e)||t.slug.toLowerCase().includes(e))},[es,eh]);let eX=(0,E.useAssignmentError)(),eZ=(0,a.useCallback)(async(t,a)=>{try{let r="user"===a?eA.find(e=>e.id===t):null;if("user"===a&&!r&&"unassign"!==t&&"SYSTEM"!==t)throw Error("User not found");let s="user"===a&&r?r.roles[0]:void 0,n=await fetch(`/api/tasks?taskId=${e.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({assignedTo:t,roleType:s,assignmentType:a})});if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error||"Could not update the assignment")}i?.(),eN(!1)}catch(e){console.error("[TaskHeader] Assignment failed:",e),eX.show(e instanceof Error?e.message:"Could not update the assignment")}},[e.id,i,eA,eX.show]),{refreshUsers:e0}=(0,P.useCustomer)(),[e1,e2]=(0,a.useState)(!1);(0,a.useEffect)(()=>{if(e.assignments?.[0]){let t=e.assignments[0];t.user_id!==e5&&(er.find(e=>e.id===t.user_id)||!t.user_id||ei||e1||(e2(!0),e0().finally(()=>{setTimeout(()=>e2(!1),5e3)})))}},[e.assignments,er,ei,e1,e0]);let e5=S.SYSTEM_USER_ID,e4=(0,a.useMemo)(()=>{let t=(0,S.resolveHeaderAssignee)({assignment:e.assignments?.[0],fallback:e.assignedTo,findUser:e=>er.find(t=>t.id===e),usersSettling:ei||e1});return"loading"===t?null:t},[e.assignments,e.assignedTo,er,ei,e1]),e3=(e=>{let{nextReservation:t,due_date:a,status:r}=e;if(!a)return null;let s=new Date(a),i=s.toLocaleDateString("en-US",{month:"short",day:"numeric"}),n=s.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0}),l=null,o=!1,d="normal";if(t&&t.checkIn){let e=new Date(t.checkIn+"T"+(t.checkInTime||"15:00")),a=e.toLocaleDateString("en-US",{month:"short",day:"numeric"}),r=t.checkInTime?(()=>{if(5===t.checkInTime.length){let[e,a]=t.checkInTime.split(":"),r=parseInt(e);return`${0===r?12:r>12?r-12:r}:${a} ${r>=12?"PM":"AM"}`}return t.checkInTime})():"3:00 PM";o=s.toDateString()===e.toDateString(),l={dateStr:a,timeStr:r,guestCount:t.guestDetails?.number_of_guests||1,confirmationCode:t.confirmationCode}}let c=new Date,m=s.getTime()-c.getTime(),u=Math.floor(m/36e5);return"completed"===r?d="normal":m<0?d="overdue":u<=24?d="urgent":u<=72&&(d="soon"),{start:{dateStr:i,timeStr:n,fullDate:s},finish:l,isSameDay:o,urgencyLevel:d,hasTimeWindow:!!l}})(e);return(0,t.jsxs)("div",{className:"flex flex-col p-4 pb-0 border-b border-gray-200 dark:border-white/[0.08]",onClick:e=>e.stopPropagation(),"data-task-id":eD,children:[(0,t.jsx)(M.TaskAssigneeActions,{task:e,onUpdate:i}),(0,t.jsx)(E.AssignmentErrorNotice,{message:eX.message,onDismiss:eX.clear}),(0,t.jsx)(A.TaskActions,{task:e,checklist:l,onUpdate:i,onClose:()=>{s()},className:"mb-2",canEdit:eI,onStartExecution:m}),(0,t.jsx)("div",{children:o.length>0?(0,t.jsxs)(R.Popover,{children:[(0,t.jsx)(R.PopoverTrigger,{asChild:!0,children:(0,t.jsxs)("div",{className:"flex items-center gap-2 cursor-pointer hover:opacity-80",children:[(0,t.jsx)(n.Eye,{className:"w-4 h-4 text-gray-500 dark:text-white/60"}),(0,t.jsx)("div",{className:"flex -space-x-2",children:o.map(e=>(0,t.jsxs)(D.Avatar,{className:"w-6 h-6 border-2 border-white dark:border-[#1C1C1E]",children:[(0,t.jsx)(D.AvatarImage,{src:e.avatar,alt:e.name}),(0,t.jsx)(D.AvatarFallback,{children:e.name?.[0]||"?"})]},e.id))}),d.length>0&&(0,t.jsxs)("span",{className:"text-xs text-gray-500 dark:text-white/60 ml-2",children:[d[0].name," ",eR.tasks.header.assignment.isTyping]})]})}),(0,t.jsx)(R.PopoverContent,{align:"start",sideOffset:8,className:"w-[200px] bg-white dark:bg-[#1C1C1E] border border-gray-200 dark:border-white/[0.08] z-50",children:(0,t.jsxs)("div",{className:"p-2",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-gray-600 dark:text-white/80 mb-2",children:eR.tasks.header.assignment.currentlyViewing}),o.map(e=>(0,t.jsxs)("div",{className:"flex items-center gap-2 py-1",children:[(0,t.jsxs)(D.Avatar,{className:"w-6 h-6",children:[(0,t.jsx)(D.AvatarImage,{src:e.avatar,alt:e.name}),(0,t.jsx)(D.AvatarFallback,{children:e.name?.[0]||"?"})]}),(0,t.jsx)("span",{className:"text-sm text-gray-900 dark:text-white",children:e.name})]},e.id))]})})]}):null}),(0,t.jsxs)("div",{className:"flex flex-col gap-2 mb-4",children:[(0,t.jsx)(W.EditableTaskTitle,{taskId:e.id,title:e.title,onUpdate:i,as:"h1",className:"text-xl font-semibold text-gray-900 dark:text-white line-clamp-3"}),e.is_subtask&&e.parent&&(0,t.jsxs)("button",{onClick:()=>eM(e.parent.id.toString()),className:"group flex items-center gap-1.5 text-sm text-gray-500 dark:text-white/60 hover:text-gray-900 dark:hover:text-white/80 w-fit",children:[(0,t.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded-full bg-gray-100 dark:bg-white/[0.08] group-hover:bg-gray-100 dark:group-hover:bg-white/[0.12]",children:"Subtask"}),(0,t.jsxs)("span",{className:"truncate max-w-[400px]",children:["of ",e.parent.title]})]})]}),(ea=(e=>{let{nextReservation:t,due_date:a}=e;if(!t||!a||a.split("T")[0]!==t.checkIn)return null;let r=t.checkInTime||"3:00 PM";return{isSameDayCheckIn:!0,checkInTime:r.includes(":")?5===r.length?(()=>{let[e,t]=r.split(":"),a=parseInt(e);return`${0===a?12:a>12?a-12:a}:${t} ${a>=12?"PM":"AM"}`})():r:"3:00 PM",confirmationCode:t.confirmationCode,guestCount:t.guestDetails?.number_of_guests||1}})(e))?(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 mb-4 rounded-lg bg-amber-500/10 border border-amber-500/20",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("div",{className:"w-2 h-2 rounded-full bg-amber-500 animate-pulse"}),(0,t.jsx)("span",{className:"text-sm font-medium text-amber-400",children:"Same-day Check-in"})]}),(0,t.jsxs)("div",{className:"text-sm text-gray-600 dark:text-white/80",children:["Guests arrive at ",(0,t.jsx)("span",{className:"font-medium text-gray-900 dark:text-white",children:ea.checkInTime})," ","(",ea.guestCount," guest",1!==ea.guestCount?"s":"",")"," ","⢠Confirmation: ",(0,t.jsx)("span",{className:"font-mono text-xs",children:ea.confirmationCode})]})]}):null,(0,t.jsxs)("div",{className:"flex items-center gap-3 flex-wrap mb-4",children:[(0,t.jsx)(L.OccupancyBadge,{occupancy:e.occupancy}),(0,t.jsx)(L.TurnoverWindow,{occupancy:e.occupancy}),(0,t.jsxs)(G.DropdownMenu,{open:"category"===em,onOpenChange:e=>eu(e?"category":null),children:[(0,t.jsx)(G.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsxs)("button",{disabled:!!("category"===ed||!e_||eS),className:(0,N.cn)("flex items-center gap-1.5 px-2 py-1 rounded-full bg-gray-50 dark:bg-white/[0.05] text-xs font-medium text-gray-600 dark:text-white/80",!e_||ed||eS?"cursor-not-allowed opacity-60":"hover:bg-gray-100 dark:hover:bg-white/[0.08] cursor-pointer"),children:[(0,t.jsx)(eW,{className:"w-3.5 h-3.5"}),"category"===ed?(0,t.jsx)("div",{className:"w-4 h-4 border-2 border-gray-300 dark:border-white/20 border-t-gray-700 dark:border-t-white/80 rounded-full animate-spin"}):X(eb.category||e.category),e_&&!ed&&!eS&&(0,t.jsx)(h.ChevronDown,{className:"w-3 h-3 ml-0.5"})]})}),!eS&&(0,t.jsx)(G.DropdownMenuContent,{className:"w-44 bg-white dark:bg-[#1C1C1E] border-gray-300 dark:border-[#3A3A3C] z-[170]",children:Object.keys(Y).map(e=>{let a=Y[e];return(0,t.jsxs)(G.DropdownMenuItem,{onClick:()=>eF("category",e),className:"flex items-center gap-2 text-sm text-gray-700 dark:text-white/90 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:bg-[#2C2C2E]",children:[(0,t.jsx)(a,{className:"w-4 h-4"}),X(e)]},e)})})]}),e.metadata?.source&&(()=>{let a={ical_import:{icon:w.Calendar,label:"iCal",color:"bg-blue-500/15 text-blue-400"},workspace_connection_backfill:{icon:v.Link2,label:"Vanio Workspace",color:"bg-orange-500/15 text-orange-400"},automation:{icon:k.Zap,label:"Automation",color:"bg-purple-500/15 text-purple-400"}}[e.metadata.source];if(!a)return null;let r=a.icon;return(0,t.jsxs)("span",{className:(0,N.cn)("flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",a.color),children:[(0,t.jsx)(r,{className:"w-3 h-3"}),a.label,e.metadata.confirmationCode&&(0,t.jsxs)("span",{className:"opacity-60 ml-0.5",children:["#",e.metadata.confirmationCode]})]})})(),(0,t.jsxs)(G.DropdownMenu,{open:"priority"===em,onOpenChange:e=>eu(e?"priority":null),children:[(0,t.jsx)(G.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsxs)("button",{disabled:!!("priority"===ed||!e_||eS),className:(0,N.cn)("flex items-center gap-1.5 px-2 py-1 rounded-full text-xs font-medium","urgent"===e.priority&&"bg-red-500/20 text-red-500","high"===e.priority&&"bg-orange-500/20 text-orange-500","medium"===e.priority&&"bg-yellow-500/20 text-yellow-500","low"===e.priority&&"bg-blue-500/20 text-blue-500",!e_||ed||eS?"cursor-not-allowed opacity-60":"hover:bg-opacity-30 curs
58or-pointer"),children:["priority"===ed?(0,t.jsx)("div",{className:"w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):Z(eb.priority||e.priority),e_&&!ed&&!eS&&(0,t.jsx)(h.ChevronDown,{className:"w-3 h-3 ml-0.5"})]})}),!eS&&(0,t.jsx)(G.DropdownMenuContent,{className:"w-36 bg-white dark:bg-[#1C1C1E] border-gray-300 dark:border-[#3A3A3C] z-[170]",children:["urgent","high","medium","low"].map(e=>(0,t.jsx)(G.DropdownMenuItem,{onClick:()=>eF("priority",e),className:(0,N.cn)("text-sm text-left font-medium hover:bg-gray-100 dark:bg-[#2C2C2E]","urgent"===e&&"text-red-400 hover:text-red-300","high"===e&&"text-orange-400 hover:text-orange-300","medium"===e&&"text-yellow-400 hover:text-yellow-300","low"===e&&"text-blue-400 hover:text-blue-300"),children:Z(e)},e))})]}),(0,t.jsxs)(G.DropdownMenu,{open:"status"===em,onOpenChange:e=>eu(e?"status":null),children:[(0,t.jsx)(G.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsxs)("button",{disabled:!!("status"===ed||!eI||eS),className:(0,N.cn)("flex items-center gap-1.5 px-2 py-1 rounded-full text-xs font-medium","todo"===e.status&&"bg-slate-500/20 text-slate-400","in_progress"===e.status&&"bg-blue-500/20 text-blue-500","completed"===e.status&&"bg-green-500/20 text-green-500","blocked"===e.status&&"bg-red-500/20 text-red-500","cancelled"===e.status&&"bg-gray-500/20 text-gray-400",!eI||ed||eS?"cursor-not-allowed opacity-60":"hover:bg-opacity-30 cursor-pointer"),children:["status"===ed?(0,t.jsx)("div",{className:"w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):Q(eb.status||e.status),eI&&!ed&&!eS&&(0,t.jsx)(h.ChevronDown,{className:"w-3 h-3 ml-0.5"})]})}),e.metadata?.isPaused&&(0,t.jsxs)("span",{className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium bg-orange-500/20 text-orange-400",children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-orange-400 animate-pulse"}),"Paused"]}),!eS&&(0,t.jsx)(G.DropdownMenuContent,{className:"w-36 bg-white dark:bg-[#1C1C1E] border-gray-300 dark:border-[#3A3A3C] z-[170]",children:["todo","in_progress","blocked","cancelled"].map(e=>(0,t.jsx)(G.DropdownMenuItem,{onClick:()=>eF("status",e),className:(0,N.cn)("text-sm text-left font-medium hover:bg-gray-100 dark:bg-[#2C2C2E]","todo"===e&&"text-slate-400 hover:text-slate-300","in_progress"===e&&"text-blue-400 hover:text-blue-300","blocked"===e&&"text-red-400 hover:text-red-300","cancelled"===e&&"text-gray-400 hover:text-gray-300"),children:Q(e)},e))})]}),e.assignments?.[0]&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[e.requires_acceptance&&"accepted"!=e.assignments[0].acceptance_status&&(0,t.jsx)("span",{className:"px-2 py-1 rounded-full text-xs font-medium bg-yellow-500/20 text-yellow-500",children:eR.tasks.header.assignment.notAccepted}),e.requires_approval&&"accepted"!=e.assignments[0].approval_status&&(0,t.jsx)("span",{className:"px-2 py-1 rounded-full text-xs font-medium bg-blue-500/20 text-blue-500",children:eR.tasks.header.assignment.notApproved}),e.assignments[0].started_at&&!e.assignments[0].completed_at&&(0,t.jsx)("span",{className:"px-2 py-1 rounded-full text-xs font-medium bg-green-500/20 text-green-500",children:eR.tasks.header.assignment.inProgress})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(y.Tag,{className:"w-3 h-3 text-gray-400 dark:text-white/40"}),(0,t.jsx)(F.TaskTags,{taskId:"string"==typeof e.id?parseInt(e.id):e.id,tags:e.tags,onUpdate:i,canEdit:eI,canEditStructure:eI})]}),(()=>{let a=e.issues||[],r=e.propertyIssues||[],s=(0,K.resolveIssuesIndicator)({ownIssues:a,propertyIssues:r});if("add"===s.mode)return(0,t.jsxs)("button",{onClick:()=>{p?.(),et?.(!0)},className:"flex items-center gap-1.5 px-2 py-1 rounded-full text-xs font-medium transition-colors border bg-white/[0.03] text-white/60 border-white/[0.1] hover:bg-white/[0.08] hover:text-white/80",title:"Report an issue with this task",children:[(0,t.jsx)(j.Plus,{className:"w-3.5 h-3.5"}),"Add issue"]});let i="",n="",l="",o="",d="",c="";{let e=`${s.openCount}${s.capped?"+":""}`,t=1!==s.openCount||s.capped?"issues":"issue";if(s.blocking?(i="bg-red-500/10",n="text-red-400",l="border-red-500/20",o="hover:bg-red-500/20"):(i="bg-yellow-500/10",n="text-yellow-400",l="border-yellow-500/20",o="hover:bg-yellow-500/20"),0===s.ownOpenCount&&s.propertyWide)d=`${e} property ${t}`,c=`${s.propertyOpenCount}${s.capped?"+":""} open ${1===s.propertyOpenCount&&!s.capped?"issue":"issues"} on other tasks at this property`;else{d=`${e} ${t}`;let a=[`${s.ownOpenCount} on this task`];s.subtaskOpenCount>0&&a.push(`${s.subtaskOpenCount} from subtasks`),s.propertyWide&&a.push(`${s.propertyOpenCount}${s.capped?"+":""} on other tasks at this property`),c=a.join(", ")}}return(0,t.jsxs)("button",{onClick:()=>{p?.(),et?.(!0)},className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs font-medium transition-colors border ${i} ${n} ${l} ${o}`,title:c,children:[(0,t.jsx)(b.AlertTriangle,{className:"w-3.5 h-3.5"}),d]})})()]}),(0,t.jsxs)("div",{className:"flex flex-col gap-4 mb-4",children:[eS&&e3&&(0,t.jsxs)("div",{className:(0,N.cn)("flex items-center justify-between px-3 py-2 rounded-lg border","overdue"===e3.urgencyLevel?"bg-red-500/10 border-red-500/20":"urgent"===e3.urgencyLevel?"bg-orange-500/10 border-orange-500/20":"soon"===e3.urgencyLevel?"bg-yellow-500/10 border-yellow-500/20":"bg-blue-500/10 border-blue-500/20"),children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(f.Clock,{className:(0,N.cn)("w-3.5 h-3.5","overdue"===e3.urgencyLevel?"text-red-400":"urgent"===e3.urgencyLevel?"text-orange-400":"soon"===e3.urgencyLevel?"text-yellow-400":"text-blue-400")}),(0,t.jsxs)("div",{className:(0,N.cn)("text-xs font-medium","overdue"===e3.urgencyLevel?"text-red-400":"urgent"===e3.urgencyLevel?"text-orange-400":"soon"===e3.urgencyLevel?"text-yellow-400":"text-blue-400"),children:[(0,t.jsx)("div",{children:"Start"}),(0,t.jsxs)("div",{children:[e3.start.dateStr," ",e3.start.timeStr]})]})]}),e3.isSameDay&&e3.hasTimeWindow?(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("div",{className:(0,N.cn)("px-1.5 py-0.5 rounded text-[10px] font-medium","overdue"===e3.urgencyLevel?"bg-red-500/20 text-red-300":"urgent"===e3.urgencyLevel?"bg-orange-500/20 text-orange-300":"soon"===e3.urgencyLevel?"bg-yellow-500/20 text-yellow-300":"bg-blue-500/20 text-blue-300"),children:"Same Day"}),(0,t.jsxs)("div",{className:"text-xs text-gray-600 dark:text-white/70",children:[(0,t.jsx)("div",{children:"Finish by"}),(0,t.jsx)("div",{className:"font-medium text-gray-900 dark:text-white",children:e3.finish?.timeStr})]})]}):null]}),(0,t.jsxs)("div",{className:"flex flex-col gap-2 px-1 relative z-[80]",children:[!eS&&
58(0,t.jsxs)("div",{className:"flex items-center w-full relative z-[90]",children:[(0,t.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/40 mr-2",children:eR.tasks.header.labels.due}),(0,t.jsx)($.DateTimePicker,{date:ey,setDate:(e,t)=>{if(!e_||eS)return;ew(e);let a=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0"),i=String(e.getHours()).padStart(2,"0"),n=String(e.getMinutes()).padStart(2,"0"),l=String(e.getSeconds()).padStart(2,"0");eL(`${a}-${r}-${s}T${i}:${n}:${l}`,t)},className:(0,N.cn)("text-[13px] relative z-[90] flex-1",(!e_||eS)&&"pointer-events-none opacity-60"),rawValue:e.due_date,checkInDates:ez,checkOutDates:eH,nextCheckout:eV,nextCheckoutReservationId:eG,nextCheckoutListingId:eO?Number(eO):null})]}),eE&&(0,t.jsxs)("div",{className:"flex items-center w-full",children:[(0,t.jsx)("div",{className:"md:hidden w-full",children:(0,t.jsxs)(R.Popover,{open:ej,onOpenChange:eN,children:[(0,t.jsx)(R.PopoverTrigger,{asChild:!0,children:(0,t.jsxs)("button",{disabled:!eT,className:(0,N.cn)("flex items-center justify-between w-full p-3 rounded-lg border border-gray-200 dark:border-white/10 bg-gray-50 dark:bg-white/5 text-left",eT?"hover:bg-gray-100 dark:hover:bg-white/10 active:bg-white/15":"opacity-60 cursor-not-allowed"),children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"text-sm text-gray-500 dark:text-white/60",children:"Assigned to"}),e4?(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)(D.Avatar,{className:"w-6 h-6",children:[(0,t.jsx)(D.AvatarImage,{src:e4.avatar,alt:e4.name}),(0,t.jsx)(D.AvatarFallback,{className:"text-xs",children:e4.name?.[0]||"?"})]}),(0,t.jsx)("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:e4.name})]}):(0,t.jsx)("span",{className:"text-sm text-gray-500 dark:text-white/60",children:"Unassigned"})]}),(0,t.jsx)(h.ChevronDown,{className:"w-4 h-4 text-gray-400 dark:text-white/40"})]})}),(0,t.jsx)(R.PopoverContent,{className:"w-[calc(100vw-2rem)] max-w-sm bg-white dark:bg-[#1C1C1E] border border-gray-200 dark:border-white/10 p-0 z-[170]",align:"start",sideOffset:8,children:(0,t.jsxs)("div",{className:"p-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,t.jsx)(x.UserCircle,{className:"w-5 h-5 text-gray-500 dark:text-white/60"}),(0,t.jsx)("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Assign Task"})]}),(0,t.jsxs)("div",{className:"relative mb-3",children:[(0,t.jsx)(g.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-white/40"}),(0,t.jsx)("input",{type:"text",placeholder:"Search team members...",value:eh,onChange:e=>ex(e.target.value),className:"w-full pl-10 pr-4 py-2 bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 rounded-lg text-sm text-gray-900 dark:text-white placeholder:text-gray-400 dark:text-white/40 focus:outline-none focus:ring-2 focus:ring-blue-500/50"})]}),(0,t.jsxs)("button",{onClick:()=>eZ("unassign","user"),className:"flex items-center gap-3 w-full p-3 rounded-lg hover:bg-gray-100 dark:hover:bg-white/5 active:bg-gray-100 dark:bg-white/10 text-left",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded-full bg-gray-100 dark:bg-white/10 flex items-center justify-center",children:(0,t.jsx)(r.X,{className:"w-4 h-4 text-gray-500 dark:text-white/60"})}),(0,t.jsx)("span",{className:"text-sm text-gray-600 dark:text-white/80",children:"Unassign"})]}),(0,t.jsxs)("div",{className:"max-h-60 overflow-y-auto",children:[ei?(0,t.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,t.jsx)(_.Spinner,{className:"w-6 h-6"})}):eQ.length>0?eQ.map(e=>(0,t.jsxs)("button",{onClick:()=>eZ(e.id,"user"),className:(0,N.cn)("flex items-center gap-3 w-full p-3 rounded-lg text-left transition-colors",e4?.userId===e.id?"bg-blue-500/20 border border-blue-500/30":"hover:bg-gray-100 dark:hover:bg-white/5 active:bg-gray-100 dark:bg-white/10"),children:[(0,t.jsxs)(D.Avatar,{className:"w-8 h-8",children:[(0,t.jsx)(D.AvatarImage,{src:e.image||e.avatar,alt:e.name}),(0,t.jsx)(D.AvatarFallback,{className:"text-sm",children:e.name?.[0]||"?"})]}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:e.name}),(0,t.jsx)("div",{className:"text-xs text-gray-500 dark:text-white/60 truncate",children:e.email}),e.roles&&e.roles.length>0&&(0,t.jsx)("div",{className:"flex gap-1 mt-1",children:e.roles.slice(0,2).map(e=>(0,t.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-gray-100 dark:bg-white/10 text-gray-600 dark:text-white/70",children:e},e))})]})]},e.id)):(0,t.jsx)("div",{className:"py-8 text-center text-sm text-gray-500 dark:text-white/60",children:"No team members found"}),eY&&(0,t.jsxs)("div",{className:"px-3 py-2 mt-2 bg-blue-500/10 border border-blue-500/20 rounded-lg",children:[(0,t.jsx)("div",{className:"text-xs text-blue-400 font-medium mb-1",children:"ð More cleaners available"}),(0,t.jsxs)("div",{className:"text-xs text-gray-600 dark:text-white/70",children:["Showing 10 of ",eK," cleaners/maintenance workers. Use search above to find specific team members."]})]})]})]})})]})}),(0,t.jsx)("div",{className:"hidden md:flex items-center w-full",children:(0,t.jsx)(B.AssignmentDropdown,{displayAssignee:e4,isLoadingUsers:ei,users:eJ,groups:es,onAssign:eZ,useAbsolutePositioning:!0,isTaskContext:!0,excludeOwners:!0,disabled:!eT})})]})]})]})]})}
58var et=e.i(788699),ea=e.i(463059),er=e.i(204997),es=e.i(292270),ei=e.i(575787),en=e.i(531278),el=e.i(14280),eo=e.i(542027),ed=e.i(719708),ec=e.i(526050),em=e.i(85507),eu=e.i(671378),eh=e.i(549691);function ex({task:e}){let r=e.is_subtask&&e.parent?e.parent.task_relations?.find(e=>e.listing_id):e.relations?.find(e=>e.listing_id),s=r?.listing_id||e.metadata?.listingId||void 0,i=e.relations?.find(e=>e.reservation_id)?.reservation_id,{deviceHealth:n,isLoading:l}=(0,eu.useDeviceHealth)(s),[o,d]=(0,a.useState)(!1);return s&&n&&!l?(0,t.jsxs)("div",{className:"mt-2 rounded-xl border border-gray-200 dark:border-white/[0.08] bg-white dark:bg-white/[0.02]",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>d(e=>!e),"aria-expanded":o,className:"w-full flex items-center justify-between px-4 py-3 text-left",children:[(0,t.jsx)("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Smart Devices"}),(0,t.jsx)(ea.ChevronRight,{className:(0,N.cn)("w-4 h-4 text-gray-400 dark:text-white/40 transition-transform duration-200",o&&"rotate-90")})]}),o&&(0,t.jsx)("div",{className:"px-4 pb-4",children:(0,t.jsx)(eh.ListingDevices,{devices:n.devices||[],summary:n.summary||{lastChecked:new Date().toISOString()},isLoading:l,listingId:Number(s),reservationId:i?Number(i):void 0,className:"pt-0 border-t-0"})})]}):null}e.s(["TaskSmartDevicesPanel",0,ex],886263);var eg=e.i(283390),ep=e.i(618566),eb=e.i(232676),ef=e.i(569508);e.s(["TaskDetails",0,function({task:e,searchQuery:r,onUpdate:s,canEdit:i=!1,canEditStructure:n=!1,isServiceProvider:l=!1,showSmartDevices:o=!0}){let c,m,u,h,x,{data:g}=(0,V.useSession)(),{currentCustomerId:p}=(0,P.useCustomer)(),b=(0,z.useUserSettings)(p||void 0),{openModalByReservation:f}=(0,eb.useDashboard)(),y=b.getCurrentRole(p||void 0),v=(0,a.useRef)(null),[k,j]=(0,a.useState)(!1),[C,S]=(0,a.useState)(!1),[E,T]=(0,a.useState)(e.description||""),[A,D]=(0,a.useState)(!1),[R,M]=(0,a.useState)(null),[F,L]=(0,a.useState)(e.permission_to_enter??null),[$,U]=(0,a.useState)({setAt:e.permission_to_enter_set_at??null,setByName:e.permissionToEnterSetByName??null}),[B,q]=(0,a.useState)(!1),[H,G]=(0,a.useState)(null),W=(0,O.useTranslations)(),K=(0,ep.useRouter)(),Y=(0,ep.useSearchParams)(),J=(0,a.useRef)(e.permission_to_enter??null);(0,a.useEffect)(()=>{let t=e.permission_to_enter??null;t!==J.current&&(J.current=t,L(t),U({setAt:e.permission_to_enter_set_at??null,setByName:e.permissionToEnterSetByName??null}))},[e.permission_to_enter,e.permission_to_enter_set_at,e.permissionToEnterSetByName]);let Q=(0,a.useCallback)(async t=>{M(t),G(null);try{let a=await fetch(`/api/tasks?taskId=${e.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({permissionToEnter:t})}),r=await a.json().catch(()=>({}));if(!a.ok)throw Error(r?.error||"Could not update permission to enter");L(t),J.current=t,U({setAt:r?.setAt||new Date().toISOString(),setByName:g?.user?.name||"You"}),s?.()}catch(e){G(e?.message||"Could not update permission to enter")}finally{M(null)}},[e.id,s,g?.user?.name]),X=e.is_subtask&&e.parent?e.parent.task_relations?.find(e=>e.listing_id):e.relations?.find(e=>e.listing_id),Z=X?.listing_id||e.metadata?.listingId||void 0,{listing:ee,isLoading:eh,error:ey}=(0,I.useListing)(Z?Number(Z):void 0),ew=(h=e.relations,h?.find(e=>e.reservation_id)?.reservation_id),{deviceHealth:ev}=(0,eu.useDeviceHealth)(Z),ek=ee?{listing:{id:ee.id,name:(x=ee.name?.split("·")[0].trim()||"").length>25?x.slice(0,25)+"...":x,thumbnail:ee.thumbnailUrl,location:{street:ee.location?.address,city:ee.location?.city,state:ee.location?.state,address:ee.location?.address},details:{guests:ee.details?.guests,bedrooms:ee.details?.bedrooms,beds:ee.details?.beds,bathrooms:ee.details?.baths,propertyType:ee.propertyTypeCategory,roomType:ee.roomTypeCategory},businessDetails:ee.businessDetails,platformData:ee.platformData}}:null,ej=async()=>{try{D(!0);let t=await fetch(`/api/tasks?taskId=${e.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:E.trim(),updatedByEmail:g?.user?.email})});if(!t.ok)throw Error(W.tasks.details.description.errors.update);await t.json(),s?.(),S(!1)}
58catch(e){console.error("[TaskDetails] Error updating description:",e)}finally{D(!1)}};(0,a.useEffect)(()=>{j(navigator.platform.toLowerCase().includes("mac"))},[]),(0,a.useEffect)(()=>{let e=e=>{if(document.activeElement===v.current&&(!e.metaKey&&!e.ctrlKey||"Enter"!==e.key)&&(!e.metaKey&&!e.ctrlKey||"c"!==e.key&&"v"!==e.key&&"x"!==e.key&&"a"!==e.key)&&(e.metaKey||e.ctrlKey||e.altKey))return e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),!1};return window.addEventListener("keydown",e,{capture:!0,passive:!1}),()=>{window.removeEventListener("keydown",e,{capture:!0})}},[]);let eN=(0,a.useCallback)(e=>{e.stopPropagation()},[]),eC=e=>{e.stopPropagation()};return(0,a.useMemo)(()=>ev&&ev.devices?ev.devices.filter(e=>e.deviceType&&"lock"===e.deviceType.toLowerCase()||e.type&&"lock"===e.type.toLowerCase()||e.name&&e.name.toLowerCase().includes("lock")):[],[ev]),(0,t.jsxs)("div",{className:"p-4 border-b border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsx)("div",{className:"mb-4",children:(0,t.jsx)("div",{className:"bg-white dark:bg-white/[0.03] rounded-lg border border-gray-200 dark:border-white/[0.06] p-4",children:eh?(0,t.jsx)("div",{className:"flex items-center justify-center py-2",children:(0,t.jsx)(_.Spinner,{className:"w-4 h-4"})}):ey?(0,t.jsx)("div",{className:"text-sm text-red-400 py-2",children:W.tasks.details.property.error}):ek?(0,t.jsx)(em.ReservationListing,{data:ek,showCalendarFeature:!0,currentReservationId:ew?String(ew):void 0,isServiceProvider:l,enableLinks:!l}):null})}),n&&"roamer"!==y&&(e.sourceReservation||e.nextReservation)&&(0,t.jsx)("div",{className:"mb-4",children:(0,t.jsxs)("div",{className:"bg-white dark:bg-white/[0.02] rounded-lg border border-gray-200 dark:border-white/[0.04] p-3",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2 mb-3",children:[(0,t.jsx)("div",{className:"w-4 h-4 bg-blue-500/20 rounded-full flex items-center justify-center",children:(0,t.jsx)(w.Calendar,{className:"w-2.5 h-2.5 text-blue-400"})}),(0,t.jsx)("span",{className:"text-xs font-medium text-gray-600 dark:text-white/80",children:"Related Reservations"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[e.sourceReservation&&(0,t.jsx)(ed.Button,{size:"sm",variant:"ghost",onClick:()=>f(e.sourceReservation.id.toString()),className:"w-full justify-start bg-white dark:bg-white/[0.02] hover:bg-gray-50 dark:hover:bg-white/[0.05] text-gray-600 dark:text-white/80 border-gray-200 dark:border-white/[0.08] text-xs h-8",children:(0,t.jsxs)("div",{className:"flex items-center space-x-2 w-full",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-1.5",children:[(0,t.jsx)("div",{className:"w-1.5 h-1.5 bg-orange-400 rounded-full"}),(0,t.jsx)("span",{className:"text-orange-400 text-[10px] uppercase font-medium",children:"Source"})]}),(0,t.jsx)("div",{className:"flex-1 text-left truncate",children:(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)("span",{className:"font-medium",children:e.sourceReservation.confirmationCode}),(0,t.jsxs)("div",{className:"flex items-center space-x-1 text-gray-400 dark:text-white/40",children:[(0,t.jsx)(es.LogOut,{className:"w-3 h-3"}),(0,t.jsx)("span",{className:"text-xs",children:(0,eo.format)(new Date(e.sourceReservation.checkOut+"T00:00:00"),"MMM d, yyyy")})]})]})}),(0,t.jsx)("div",{className:"text-gray-400 dark:text-white/30",children:(0,t.jsx)(ea.ChevronRight,{className:"w-3 h-3"})})]})}),e.nextReservation&&(0,t.jsx)(ed.Button,{size:"sm",variant:"ghost",onClick:()=>f(e.nextReservation.id.toString()),className:"w-full justify-start bg-white dark:bg-white/[0.02] hover:bg-gray-50 dark:hover:bg-white/[0.05] text-gray-600 dark:text-white/80 border-gray-200 dark:border-white/[0.08] text-xs h-8",children:(0,t.jsxs)("div",{className:"flex items-center space-x-2 w-full",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-1.5",children:[(0,t.jsx)("div",{className:"w-1.5 h-1.5 bg-green-400 rounded-full"}),(0,t.jsx)("span",{className:"text-green-400 text-[10px] uppercase font-medium",children:"Next"})]}),(0,t.jsx)("div",{className:"flex-1 text-left truncate",children:(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)("span",{className:"font-medium",children:e.nextReservation.confirmationCode}),(0,t.jsxs)("div",{className:"flex items-center space-x-1 text-gray-400 dark:text-white/40",children:[(0,t.jsx)(er.LogIn,{className:"w-3 h-3"}),(0,t.jsx)("span",{className:"text-xs",children:(0,eo.format)(new Date(e.nextReservation.checkIn+"T00:00:00"),"MMM d, yyyy")})]})]})}),(0,t.jsx)("div",{className:"text-gray-400 dark:text-white/30",children:(0,t.jsx)(ea.ChevronRight,{className:"w-3 h-3"})})]})})]})]})}),n&&"roamer"!==y&&(0,t.jsx)("div",{className:"mb-4",children:(0,t.jsxs)("div",{className:"bg-white dark:bg-white/[0.02] rounded-lg border border-gray-200 dark:border-white/[0.04] p-3",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2 mb-1",children:[(0,t.jsx)("div",{className:"w-4 h-4 bg-amber-500/20 rounded-full flex items-center justify-center",children:(0,t.jsx)(ei.DoorOpen,{className:"w-2.5 h-2.5 text-amber-400"})}),(0,t.jsx)("span",{className:"text-xs font-medium text-gray-600 dark:text-white/80",children:"Permission to enter"})]}),(0,t.jsx)("p",{className:"text-[11px] text-gray-500 dark:text-white/40 mb-3",children:"What service providers see on this task while the property is occupied."}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-2",role:"group","aria-label":"Permission to enter",children:[{value:"pending",label:"Awaiting guest",active:"bg-amber-500/15 text-amber-400 border-amber-500/30"},{value:"granted",label:"Guest approved",active:"bg-green-500/15 text-green-400 border-green-500/30"}].map(e=>{let a=F===e.value,r=R===e.value;return(0,t.jsxs)("button",{type:"button","aria-pressed":a,disabled:null!==R,onClick:()=>{a||R||("granted"===e.value?q(!0):Q("pending"))},className:(0,N.cn)("flex items-center justify-center space-x-1.5 h-8 rounded-md border text-xs font-medium transition-colors disabled:opacity-60",a?e.active:"bg-white dark:bg-white/[0.02] text-gray-600 dark:text-white/60 border-gray-200 dark:border-white/[0.08] hover:bg-gray-50 dark:hover:bg-white/[0.05]"),children:[r&&(0,t.jsx)(en.Loader2,{className:"w-3 h-3 animate-spin"}),(0,t.jsx)("span",{children:e.label})]},e.value)})}),H&&(0,t.jsx)("p",{className:"text-[11px] text-red-400 mt-2",children:H}),F?(0,t.jsxs)("p",{className:"text-[11px] text-gray-500 dark:text-white/40 mt-2",children:["Set by ",$.setByName||"a team member",$.setAt?` ⢠${new Date($.setAt).toLocaleStr
58ing()}`:""," · ","Stays as set â automatic updates will not change it."]}):(0,t.jsx)("p",{className:"text-[11px] text-gray-500 dark:text-white/40 mt-2",children:'Not set â providers currently see "Awaiting guest".'})]})}),(0,t.jsx)(el.AlertDialog,{open:B,onOpenChange:q,children:(0,t.jsxs)(el.AlertDialogContent,{className:"bg-[#141414] border-white/[0.1] z-[200]",children:[(0,t.jsxs)(el.AlertDialogHeader,{children:[(0,t.jsx)(el.AlertDialogTitle,{className:"text-white",children:"Mark permission as granted?"}),(0,t.jsx)(el.AlertDialogDescription,{className:"text-white/60",children:'Service providers assigned to this task will see "Granted" and may enter the property even while a guest is staying there. Only set this once the guest has agreed.'})]}),(0,t.jsxs)(el.AlertDialogFooter,{children:[(0,t.jsx)(el.AlertDialogCancel,{className:"bg-white/[0.05] border-white/[0.1] text-white hover:bg-white/[0.1]",children:"Cancel"}),(0,t.jsx)(el.AlertDialogAction,{onClick:()=>Q("granted"),disabled:null!==R,className:"bg-green-500/10 text-green-400 hover:bg-green-500/20 border border-green-500/20",children:"granted"===R?(0,t.jsx)(en.Loader2,{className:"w-4 h-4 animate-spin"}):"Mark as granted"})]})]})}),(0,t.jsxs)("div",{className:"mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:W.tasks.details.description.title}),n&&!C&&(0,t.jsx)(ed.Button,{variant:"ghost",size:"sm",className:"h-8 px-2 text-gray-500 dark:text-white/60 hover:text-gray-900 dark:hover:text-white",onClick:()=>S(!0),title:W.tasks.details.description.buttons.edit,children:(0,t.jsx)(et.Pencil,{className:"w-4 h-4"})})]}),C?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ec.Textarea,{ref:v,value:E,onChange:e=>{T(e.target.value)},onKeyDown:e=>{e.stopPropagation(),"Enter"===e.key&&(k&&e.metaKey||!k&&e.ctrlKey)&&(e.preventDefault(),A||ej())},onClick:eN,onTouchStart:eC,onTouchMove:eC,onTouchEnd:eC,className:"min-h-[100px] bg-gray-50 dark:bg-white/5 border-gray-200 dark:border-white/10 text-gray-600 dark:text-white/80",placeholder:W.tasks.details.description.placeholder}),(0,t.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,t.jsx)("button",{onClick:()=>{T(e.description||""),S(!1)},disabled:A,className:"px-3 py-1.5 text-gray-500 dark:text-white/60 hover:text-gray-900 dark:hover:text-white transition-colors text-xs",children:W.tasks.details.description.buttons.cancel}),(0,t.jsx)("button",{onClick:ej,disabled:A,className:(0,N.cn)("flex items-center justify-center gap-1.5","px-3 py-1.5 rounded-lg text-xs","bg-white text-black","hover:bg-white/90 transition-colors","relative",A&&"opacity-50 cursor-not-allowed","ring-1 ring-offset-1 ring-offset-white dark:ring-offset-white dark:ring-offset-white dark:ring-offset-white dark:ring-offset-white dark:ring-offset-[#1C1C1E] ring-gray-200 dark:ring-white/10"),children:A?(0,t.jsx)("div",{className:"w-3 h-3 border-2 border-black/20 border-t-black/80 rounded-full animate-spin"}):(0,t.jsxs)(t.Fragment,{children:[W.tasks.details.description.buttons.save,(0,t.jsxs)("span",{className:"ml-1 opacity-60 text-[10px]",children:["(",W.tasks.details.description.buttons.saveShortcut.replace("{key}",k?"â":"Ctrl"),")"]})]})})]})]}):(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm text-gray-600 dark:text-white/80 whitespace-pre-wrap",children:e.description?(0,ef.linkifyText)(e.description):W.tasks.details.description.empty}),0===(u=e.attachments||[]).length?null:(0,t.jsxs)("div",{className:"mt-3 space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2 mb-2",children:[(0,t.jsx)("div",{className:"w-5 h-5 bg-gray-100 dark:bg-white/10 rounded-full flex items-center justify-center",children:(0,t.jsx)(d.FileText,{className:"w-3 h-3 text-gray-500 dark:text-white/60"})}),(0,t.jsx)("span",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:"Attachments"}),(0,t.jsxs)("span",{className:"text-xs text-gray-400 dark:text-white/40",children:["(",u.length,")"]})]}),(0,t.jsx)("div",{className:"space-y-2",children:u.map((e,a)=>{let r=e.type?.startsWith("audio/"),s=e.type?.startsWith("image/"),i=e.type?.startsWith("video/");return r?(0,t.jsx)(eg.VoiceNotePlayer,{url:e.url,name:e.name,transcription:e.transcription,metadata:e.metadata,showRemove:!1,showExternalLink:!0,variant:"default",className:"w-full"},a):s?(0,t.jsxs)("div",{className:"relative aspect-video bg-gray-50 dark:bg-white/5 rounded-lg overflow-hidden border border-gray-200 dark:border-white/10",children:[(0,t.jsx)("img",{src:e.url,alt:e.name,className:"w-full h-full object-cover cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>window.open(e.url,"_blank")}),(0,t.jsxs)("div",{className:"absolute bottom-0 left-0 right-0 bg-black/50 text-gray-900 dark:text-white text-xs p-1 truncate",children:[e.name,e.metadata?.source&&(0,t.jsxs)("span",{className:"ml-2 opacity-60",children:["(","issue"===e.metadata.source?"from issue":"uploaded",")"]})]})]},a):i?(0,t.jsxs)("div",{className:"relative bg-gray-50 dark:bg-white/5 rounded-lg overflow-hidden border border-gray-200 dark:border-white/10",children:[(0,t.jsxs)("video",{controls:!0,className:"w-full aspect-video",poster:e.metadata?.thumbnail,children:[(0,t.jsx)("source",{src:e.url,type:"video/mp4"}),(0,t.jsx)("source",{src:e.url,type:"video/webm"}),"Your browser does not support the video element."]}),(0,t.jsxs)("div",{className:"absolute bottom-0 left-0 right-0 bg-black/50 text-gray-900 dark:text-white text-xs p-1 truncate",children:[e.name,e.metadata?.source&&(0,t.jsxs)("span",{className:"ml-2 opacity-60",children:["(","issue"===e.metadata.source?"from issue":"uploaded",")"]})]})]},a):(0,t.jsxs)("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsx)(d.FileText,{className:"w-4 h-4 text-gray-500 dark:text-white/60"}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("span",{className:"text-sm text-gray-600 dark:text-white/80 truncate block",children:e.name}),e.metadata?.source&&(0,t.jsx)("span",{className:"text-xs text-gray-400 dark:text-white/40",children:"issue"===e.metadata.source?"From issue":"Uploaded during task creation"})]}),(0,t.jsx)("button",{onClick:()=>window.open(e.url,"_blank"),className:"p-1 hover:bg-gray-100 dark:hover:bg-white/[0.08] rounded-md text-gray-400 dark:text-white/40 hover:text-gray-600 dark:hover:text-white/70",children:(0,t.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})})]},a)})}),!l&&e.metadata?.originalIssueId&&(0,t.jsx)("div",{className:"pt-2 border-t border-blue-500/20",children:(0,t.jsxs)(ed.Button,{size:"sm",variant:"secondary",onClick:()=>{let t=new URLSearchParams(Y?.toString()||""),a=e.parent?.id;a&&(t.set("task",String(a)),t.set("issues","true"),K.push(`${window.location.pathname}?${t.toString()}`))},className:"bg-blue-500/20 hover:bg-blue-500/30 text-blue-400 border-blue-500/30 text-xs",children:[(0,t.jsx)(d.FileText,{className:"w-3 h-3 mr-1"}),(c=e?.originalIssue,(m=c?.title||`Issue #${e.metadata?.originalIssueId}`).length>40?`${m.slice(0,40)}
58...`:m)]})})]})]})]}),o&&(0,t.jsx)(ex,{task:e})]})}],92167);var ey=e.i(643531),ew=e.i(968553),ev=e.i(870273),ek=e.i(750570),ej=e.i(400417),eN=e.i(365582);function eC({ratingType:e,value:a,size:s="sm"}){if(!a)return null;let i="sm"===s?"w-3.5 h-3.5":"w-4 h-4";switch(e){case"pass_fail":return(0,t.jsxs)("span",{className:(0,N.cn)("flex items-center gap-1 text-xs font-medium",a.value?"text-green-500":"text-red-500"),children:[a.value?(0,t.jsx)(ey.Check,{className:i}):(0,t.jsx)(r.X,{className:i}),a.value?"Pass":"Fail"]});case"yes_no":return(0,t.jsx)("span",{className:(0,N.cn)("text-xs font-medium",a.value?"text-green-500":"text-red-500"),children:a.value?"Yes":"No"});case"stars_5":return(0,t.jsxs)("div",{className:"flex items-center gap-0.5",children:[[1,2,3,4,5].map(e=>(0,t.jsx)(ev.Star,{className:(0,N.cn)(i,"number"==typeof a.value&&e<=a.value?"text-amber-400 fill-amber-400":"text-gray-300 dark:text-white/15")},e)),(0,t.jsxs)("span",{className:"text-xs text-gray-500 dark:text-white/50 ml-1",children:[a.value,"/5"]})]});case"thumbs":return(0,t.jsx)("span",{className:(0,N.cn)("flex items-center gap-1",a.value?"text-green-500":"text-red-500"),children:a.value?(0,t.jsx)(ej.ThumbsUp,{className:i}):(0,t.jsx)(eN.ThumbsDown,{className:i})});case"scale_1_10":{let e="number"==typeof a.value?a.value:0;return(0,t.jsxs)("span",{className:(0,N.cn)("text-xs font-semibold px-1.5 py-0.5 rounded",e>=7?"text-green-500 bg-green-500/10":e>=4?"text-amber-500 bg-amber-500/10":"text-red-500 bg-red-500/10"),children:[e,"/10"]})}default:return null}}function eS({status:e,confidence:a,size:s="sm"}){if(!e||"pending"===e)return null;let i={passed:{label:"Passed",bg:"bg-green-500/10 dark:bg-green-500/15",text:"text-green-600 dark:text-green-400",icon:(0,t.jsx)(ey.Check,{className:"w-3 h-3"})},failed:{label:"Failed",bg:"bg-red-500/10 dark:bg-red-500/15",text:"text-red-600 dark:text-red-400",icon:(0,t.jsx)(r.X,{className:"w-3 h-3"})},review_needed:{label:"Review",bg:"bg-amber-500/10 dark:bg-amber-500/15",text:"text-amber-600 dark:text-amber-400",icon:null}}[e];return i?(0,t.jsxs)("span",{className:(0,N.cn)("inline-flex items-center gap-1 px-2 py-0.5 rounded-full font-medium","sm"===s?"text-[11px]":"text-xs",i.bg,i.text),children:[i.icon,i.label,null!=a&&a>0&&(0,t.jsxs)("span",{className:"opacity-60",children:["(",Math.round(100*a),"%)"]})]}):null}e.s(["RatingDisplay",0,eC,"RatingInput",0,function({ratingType:e,value:a,onChange:s,disabled:i,size:n="md"}){let l=a?.value,o=t=>{s({type:e,value:t})},d="sm"===n?"w-4 h-4":"w-5 h-5",c="sm"===n?"p-1.5":"p-2";switch(e){case"pass_fail":return(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("button",{type:"button",disabled:i,onClick:()=>o(1),className:(0,N.cn)(c,"rounded-lg border transition-colors",1===l||!0===l?"bg-green-500/15 border-green-500/30 text-green-500":"bg-gray-50 dark:bg-white/[0.03] border-gray-200 dark:border-white/[0.1] text-gray-400 dark:text-white/30 hover:border-green-500/30 hover:text-green-500",i&&"opacity-50 cursor-not-allowed"),children:(0,t.jsx)(ey.Check,{className:d})}),(0,t.jsx)("button",{type:"button",disabled:i,onClick:()=>o(0),className:(0,N.cn)(c,"rounded-lg border transition-colors",0===l||!1===l?"bg-red-500/15 border-red-500/30 text-red-500":"bg-gray-50 dark:bg-white/[0.03] border-gray-200 dark:border-white/[0.1] text-gray-400 dark:text-white/30 hover:border-red-500/30 hover:text-red-500",i&&"opacity-50 cursor-not-allowed"),children:(0,t.jsx)(r.X,{className:d})}),null!=l&&(0,t.jsx)("span",{className:(0,N.cn)("text-xs font-medium",l?"text-green-500":"text-red-500"),children:l?"Pass":"Fail"})]});case"yes_no":return(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("button",{type:"button",disabled:i,onClick:()=>o(!0),className:(0,N.cn)("px-3 rounded-lg border text-xs font-medium transition-colors",c,!0===l?"bg-green-500/15 border-green-500/30 text-green-500":"bg-gray-50 dark:bg-white/[0.03] border-gray-200 dark:border-white/[0.1] text-gray-500 dark:text-white/40 hover:border-green-500/30",i&&"opacity-50 cursor-not-allowed"),children:"Yes"}),(0,t.jsx)("button",{type:"button",disabled:i,onClick:()=>o(!1),className:(0,N.cn)("px-3 rounded-lg border text-xs font-medium transition-colors",c,!1===l?"bg-red-500/15 border-red-500/30 text-red-500":"bg-gray-50 dark:bg-white/[0.03] border-gray-200 dark:border-white/[0.1] text-gray-500 dark:text-white/40 hover:border-red-500/30",i&&"opacity-50 cursor-not-allowed"),children:"No"})]});case"stars_5":return(0,t.jsxs)("div",{className:"flex items-center gap-0.5",children:[[1,2,3,4,5].map(e=>(0,t.jsx)("button",{type:"button",disabled:i,onClick:()=>o(e),className:(0,N.cn)("transition-colors",i&&"cursor-not-allowed opacity-50"),children:(0,t.jsx)(ev.Star,{className:(0,N.cn)(d,"number"==typeof l&&e<=l?"text-amber-400 fill-amber-400":"text-gray-300 dark:text-white/20 hover:text-amber-300")})},e)),"number"==typeof l&&(0,t.jsxs)("span",{className:"text-xs text-gray-500 dark:text-white/50 ml-1.5",children:[l,"/5"]})]});case"thumbs":return(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("button",{type:"button",disabled:i,onClick:()=>o(1),className:(0,N.cn)(c,"rounded-lg border transition-colors",1===l||!0===l?"bg-green-500/15 border-green-500/30 text-green-500":"bg-gray-50 dark:bg-white/[0.03] border-gray-200 dark:border-white/[0.1] text-gray-400 dark:text-white/30 hover:border-green-500/30 hover:text-green-500",i&&"opacity-50 cursor-not-allowed"),children:(0,t.jsx)(ej.ThumbsUp,{
58className:d})}),(0,t.jsx)("button",{type:"button",disabled:i,onClick:()=>o(0),className:(0,N.cn)(c,"rounded-lg border transition-colors",0===l||!1===l?"bg-red-500/15 border-red-500/30 text-red-500":"bg-gray-50 dark:bg-white/[0.03] border-gray-200 dark:border-white/[0.1] text-gray-400 dark:text-white/30 hover:border-red-500/30 hover:text-red-500",i&&"opacity-50 cursor-not-allowed"),children:(0,t.jsx)(eN.ThumbsDown,{className:d})})]});case"scale_1_10":{let e="number"==typeof l?l:5;return(0,t.jsxs)("div",{className:"flex items-center gap-2 w-full",children:[(0,t.jsx)("input",{type:"range",min:1,max:10,value:e,onChange:e=>o(parseInt(e.target.value)),disabled:i,className:(0,N.cn)("flex-1 h-2 rounded-lg appearance-none cursor-pointer accent-blue-500","bg-gray-200 dark:bg-white/10",i&&"opacity-50 cursor-not-allowed")}),(0,t.jsx)("span",{className:(0,N.cn)("text-sm font-semibold min-w-[2rem] text-center rounded-md px-1.5 py-0.5",e>=7?"text-green-500 bg-green-500/10":e>=4?"text-amber-500 bg-amber-500/10":"text-red-500 bg-red-500/10"),children:e})]})}default:return null}},"VerificationBadge",0,eS],131715);var eE=e.i(477183),eI=e.i(76590),eT=e.i(807311);function e_({item:e,canManageChecklist:a,canManageChecklistStructure:i,updatingItems:n,editingItemId:l,editText:o,isSavingEdit:d,verificationsByItem:c,getUserInfo:m,onToggle:u,onDelete:h,onStartEditing:x,onCancelEditing:g,onSaveEdit:p,onEditTextChange:b,onLightbox:f,dragHandle:y}){let w,v,k,j,C=(0,O.useTranslations)(),S=m(e.completed_by);return(0,t.jsxs)("div",{className:"flex items-start gap-3 group",children:[y,(0,t.jsx)("button",{onClick:()=>u(e),disabled:n.has(e.id.toString())||!a,className:(0,N.cn)("flex-none mt-0.5 w-5 h-5 rounded-md border","flex items-center justify-center","transition-colors duration-200",e.completed?"bg-green-500 border-transparent":"border-gray-300 dark:border-white/20 hover:border-gray-400 dark:hover:border-white/40",(n.has(e.id.toString())||!a)&&"opacity-50 cursor-not-allowed"),children:n.has(e.id.toString())?(0,t.jsx)("div",{className:"w-3 h-3 border-2 border-gray-300 dark:border-white/20 border-t-gray-700 dark:border-t-white/80 rounded-full animate-spin"}):e.completed?(0,t.jsx)(ey.Check,{className:"w-3 h-3 text-gray-900 dark:text-white"}):null}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("div",{className:"flex items-center gap-2 min-w-0",children:l===e.id?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("input",{type:"text",value:o,onChange:e=>b(e.target.value),onKeyDown:t=>{"Enter"===t.key&&o.trim()&&p(e),"Escape"===t.key&&g()},disabled:d,autoFocus:!0,className:(0,N.cn)("flex-1 min-w-0 bg-gray-50 dark:bg-white/[0.05] rounded-md px-2 py-1 text-sm","text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-white/40","border border-gray-200 dark:border-white/[0.12] focus:outline-none focus:border-gray-300 dark:focus:border-white/20",d&&"opacity-50")}),(0,t.jsx)("button",{onClick:()=>p(e),disabled:d||!o.trim(),className:(0,N.cn)("flex-shrink-0 text-gray-400 dark:text-white/40 hover:text-gray-600 dark:hover:text-white/70","transition-colors",(d||!o.trim())&&"opacity-50 cursor-not-allowed"),title:"Save",children:d?(0,t.jsx)(en.Loader2,{className:"w-4 h-4 animate-spin"}):(0,t.jsx)(ey.Check,{className:"w-4 h-4"})}),(0,t.jsx)("button",{onClick:g,disabled:d,className:(0,N.cn)("flex-shrink-0 text-gray-400 dark:text-white/40 hover:text-gray-600 dark:hover:text-white/70","transition-colors",d&&"opacity-50 cursor-not-allowed"),title:"Cancel",children:(0,t.jsx)(r.X,{className:"w-4 h-4"})})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:(0,N.cn)("text-sm flex-1 min-w-0",e.completed?"text-gray-400 dark:text-white/40 line-through":"text-gray-900 dark:text-white"),children:e.title}),e.required&&!e.completed&&(0,t.jsx)("span",{className:"text-xs px-1 py-0.5 rounded bg-orange-500/10 text-orange-400/80 flex-shrink-0 whitespace-nowrap",children:"Required"})]})}),e.completed_by&&e.completed_at&&S&&(0,t.jsxs)("div",{className:"flex items-center gap-2 mt-1 text-xs text-gray-400 dark:text-white/40",children:[(0,t.jsxs)(D.Avatar,{className:"w-4 h-4",children:[(0,t.jsx)(D.AvatarImage,{src:S.avatar||""}),(0,t.jsx)(D.AvatarFallback,{children:S.name[0]})]}),(0,t.jsxs)("span",{children:[S.name,S.role&&(0,t.jsxs)("span",{className:"ml-1 text-gray-400 dark:text-white/30",children:["⢠",S.role]}
58)]}),(0,t.jsx)("span",{children:"â¢"}),(0,t.jsx)("span",{children:new Date(e.completed_at).toLocaleDateString()})]}),e.notes&&(0,t.jsx)("div",{className:"mt-1 text-sm text-gray-400 dark:text-white/40",children:e.notes}),(e.photo_required||e.rating_type||e.ai_verification_prompt)&&!e.completed&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 mt-1.5",children:[e.photo_required&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-[11px] px-1.5 py-0.5 rounded bg-blue-500/10 text-blue-500 dark:text-blue-400",children:[(0,t.jsx)(ew.Camera,{className:"w-3 h-3"})," Photo"]}),e.rating_type&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-[11px] px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-500 dark:text-amber-400",children:[(0,t.jsx)(ev.Star,{className:"w-3 h-3"})," ",e.rating_type.replace("_","/")]}),e.ai_verification_prompt&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-[11px] px-1.5 py-0.5 rounded bg-purple-500/10 text-purple-500 dark:text-purple-400",children:[(0,t.jsx)(s.Sparkles,{className:"w-3 h-3"})," AI"]})]}),(v=(w=e.verifications||c[e.id]||[]).find(e=>"passed"===e.status),k=v?.mediaUrl,j=e.photos&&e.photos.length>0||k,e.reference_image_url||j?(0,t.jsx)("div",{className:"mt-2 space-y-2",children:(0,t.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[e.reference_image_url&&(0,t.jsxs)("button",{onClick:()=>f({url:e.reference_image_url,feedback:"Reference image â what the completed work should look like."}),className:"relative block group/photo flex-shrink-0 text-left",children:[(0,t.jsx)("img",{src:e.reference_image_url,alt:"Reference",className:"w-16 h-16 rounded-lg object-cover border border-gray-200 dark:border-white/10 group-hover/photo:ring-2 group-hover/photo:ring-blue-400 transition-all cursor-zoom-in"}),(0,t.jsx)("span",{className:"absolute -top-1.5 -left-1.5 text-[8px] bg-gray-600 dark:bg-gray-500 text-white px-1 py-0.5 rounded font-medium",children:"Expected"})]}
58),k&&(0,t.jsxs)("button",{onClick:()=>f({url:k,feedback:v?.feedback,status:"passed"}),className:"relative block group/photo flex-shrink-0 text-left",children:[(0,t.jsx)("img",{src:k,alt:"Approved",className:"w-16 h-16 rounded-lg object-cover border border-gray-200 dark:border-white/10 group-hover/photo:ring-2 group-hover/photo:ring-blue-400 transition-all cursor-zoom-in"}),(0,t.jsx)("span",{className:"absolute -top-1.5 -left-1.5 text-[8px] bg-green-600 text-white px-1 py-0.5 rounded font-medium",children:"Approved"})]}),e.photos?.map((e,a)=>{if(k&&e.url===k)return null;let r=w.find(t=>t.mediaUrl===e.url);return(0,t.jsx)("button",{onClick:()=>f({url:e.url,feedback:r?.feedback,status:r?.status}),className:"block group/photo flex-shrink-0 text-left",children:(0,t.jsx)("img",{src:e.url,alt:`Photo ${a+1}`,className:(0,N.cn)("w-16 h-16 rounded-lg object-cover border border-gray-200 dark:border-white/10 group-hover/photo:ring-2 group-hover/photo:ring-blue-400 transition-all cursor-zoom-in",r?.status==="failed"&&"opacity-70")})},a)})]})}):null),e.verification_status&&"pending"!==e.verification_status&&(0,t.jsxs)("div",{className:(0,N.cn)("mt-2 p-2 rounded-lg border text-sm","passed"===e.verification_status&&"bg-green-500/5 border-green-500/20","failed"===e.verification_status&&"bg-red-500/5 border-red-500/20","review_needed"===e.verification_status&&"bg-amber-500/5 border-amber-500/20"),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(eS,{status:e.verification_status,confidence:"string"==typeof e.verification_confidence?parseFloat(e.verification_confidence):e.verification_confidence}),(0,t.jsx)("span",{className:"text-xs text-gray-500 dark:text-white/50",children:"Vanio AI"})]}),e.ai_feedback&&(0,t.jsx)("p",{className:"text-xs text-gray-600 dark:text-white/60 mt-1",children:e.ai_feedback})]}),e.rating_type&&e.rating_value&&(0,t.jsx)("div",{className:"flex items-center gap-2 mt-1.5",children:(0,t.jsx)(eC,{ratingType:e.rating_type,value:e.rating_value})})]}),l!==e.id&&(0,t.jsx)("button",{onClick:()=>x(e),disabled:n.has(e.id.toString())||!i,className:(0,N.cn)("opacity-0 group-hover:opacity-100","text-gray-400 dark:text-white/40 hover:text-gray-500 dark:hover:text-white/60","transition-opacity duration-200",n.has(e.id.toString())&&"opacity-50 cursor-not-allowed",!i&&"hidden"),title:"Edit item",children:(0,t.jsx)(et.Pencil,{className:"w-4 h-4"})}),l!==e.id&&(0,t.jsx)("button",{onClick:()=>h(e),disabled:n.has(e.id.toString())||!i||e.required,className:(0,N.cn)("opacity-0 group-hover:opacity-100","text-gray-400 dark:text-white/40 hover:text-gray-500 dark:hover:text-white/60","transition-opacity duration-200",(n.has(e.id.toString())||!i||e.required)&&"opacity-50 cursor-not-allowed",(!i||e.required)&&"hidden"),title:e.required?"Required items cannot be deleted":C.tasks.checklist.item.delete,children:(0,t.jsx)(r.X,{className:"w-4 h-4"})})]})}function eA(e){let{attributes:a,listeners:r,setNodeRef:s,transform:i,transition:n,isDragging:l}=(0,eI.useSortable)({id:e.item.id}),o={transform:eT.CSS.Transform.toString(i),transition:n,opacity:l?.5:1,zIndex:+!!l},d=(0,t.jsx)("button",{type:"button",className:"flex-none mt-0.5 h-5 flex items-center text-gray-300 dark:text-white/25 hover:text-gray-500 dark:hover:text-white/50 cursor-grab active:cursor-grabbing touch-none","aria-label":"Reorder item",...a,...r,children:(0,t.jsx)(ek.GripVertical,{className:"w-4 h-4"})});return(0,t.jsx)("div",{ref:s,style:o,children:(0,t.jsx)(e_,{...e,dragHandle:d})})}e.s(["TaskChecklist",0,function({taskId:e,checklist:r,searchQuery:s,onUpdate:i,selectedTemplateId:n,task:l,canEdit:o=!1,canEditStructure:d=!1}){let[c,m]=(0,a.useState)(new Set),[u,h]=(0,a.useState)(null),[x,g]=(0,a.useState)(!1),[p,b]=(0,a.useState)(""),[f,y]=(0,a.useState)(!1),[w,v]=(0,a.useState)(new Set),[k,C]=(0,a.useState)(null),[S,E]=(0,a.useState)(""),[I,T]=(0,a.useState)(!1),[_,A]=(0,a.useState)(!1),[D,R]=(0,a.useState)(!1),[M,F]=(0,a.useState)([]),[L,$]=(0,a.useState)(!0),[U,B]=(0,a.useState)(""),q=(0,O.useTranslations)(),{users:{users:H}}=(0,P.useCustomer)();(0,z.useUserSettings)();let{data:W}=(0,V.useSession)(),[K,Y]=(0,a.useState)({});(0,a.useEffect)(()=>{e&&fetch(`/api/tasks/checklist-items/verifications?taskId=${e}`).then(e=>e.ok?e.json():{verifications:[]}).then(e=>{let t={};for(let a of e.verifications||[])t[a.checklist_item_id]||(t[a.checklist_item_id]=[]),t[a.checklist_item_id].push({mediaUrl:a.media_url,status:a.verification_status,feedback:a.feedback});Y(t)}).catch(()=>{})},[e,r]);let[J,Q]=(0,a.useState)(r||[]),[X,Z]=(0,a.useState)(!1);(0,a.useEffect)(()=>{Q(r||[])},[r]);let ee=(0,eE.useSensors)((0,eE.useSensor)(eE.PointerSensor,{activationConstraint:{distance:8}}),(0,eE.useSensor)(eE.TouchSensor,{activationConstraint:{delay:200,tolerance:8}}),(0,eE.useSensor)(eE.KeyboardSensor,{coordinateGetter:eI.sortableKeyboardCoordinates})),ea=d&&!s,er=(0,a.useCallback)(async(t,a)=>{Z(!0);try{if(!(await fetch("/api/tasks/checklists/reorder",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:Number(e),itemIds:t})})).ok)throw Error("Failed to persist checklist order");i?.()}catch(e){console.error("[TaskChecklist] Error reordering items:",e),Q(a)}finally{Z(!1)}},[e,i]),es=(0,a.useCallback)(e=>{let{active:t,over:a}=e;if(!a||t.id===a.id)return;let r=function(e,t,a){if(t===a)return e.slice();let r=e.findIndex(e=>e.id===t),s=e.findIndex(e=>e.id===a);if(-1===r||-1===s)return e.slice();let i=e.slice(),[n]=i.splice(r,1);return i.splice(s,0,n),i}(J,Number(t.id),Number(a.id));r!==J&&(Q(r),er(r.map(e=>e.id),J))},[J,er]);(0,a.useEffect)(()=>{(async()=>{$(!0);try{let e=await fetch("/api/tasks/checklists/templates");if(e.ok){let t=((await e.json()).templates||[]).map(e=>({id:e.id,category:e.category,section:e.section||"General",title:e.title||e.name,required:e.required||!1,order:e.order||0,standard:e.standard||null,is_active:!1!==e.isActive}));F(t.filter(e=>e.is_active))}}catch(e){console.error("Failed to fetch checklist templates:",e)}finally{$(!1)}})()},[]);let ei=M.find(e=>e.id===n),en=M.filter(e=>e.title.toLowerCase().includes(U.toLowerCase())||e.category.toLowerCase().includes(U.toLowerCase())||e.section&&e.section.toLowerCase().includes(U.toLowerCase())),el=async()=>
58{if(p.trim())try{if(y(!0),!(await fetch("/api/tasks/checklists",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:Number(e),title:p.trim(),notes:null})})).ok)throw Error(q.tasks.checklist.errors.create);b(""),g(!1),i?.()}catch(e){console.error("[TaskChecklist] Error creating item:",e)}finally{y(!1)}},eo=async t=>{if(t)try{if(A(!0),B(""),!(await fetch("/api/tasks/checklists",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:Number(e),templateId:t})})).ok)throw Error("Failed to apply template");i?.()}catch(e){console.error("[TaskChecklist] Error applying template:",e)}finally{A(!1)}},ed=d?(0,t.jsxs)("div",{className:"flex items-center gap-3 relative max-w-full",children:[(0,t.jsxs)(G.DropdownMenu,{children:[(0,t.jsx)(G.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsx)("button",{type:"button",className:(0,N.cn)("flex items-center gap-2 px-3 py-2 rounded-md min-w-[120px] max-w-full","bg-gray-50 dark:bg-white/[0.07] border border-gray-200 dark:border-white/[0.12] text-gray-600 dark:text-white/80 hover:text-gray-900 dark:hover:text-white","transition-colors cursor-pointer text-xs font-medium",_&&"opacity-50 cursor-not-allowed"),disabled:_,"aria-haspopup":"listbox","aria-expanded":void 0,children:_?(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"w-4 h-4 border-2 border-gray-300 dark:border-white/20 border-t-gray-700 dark:border-t-white/80 rounded-full animate-spin"}),(0,t.jsx)("span",{children:q.tasks.checklist.templates.select})]}):L?(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"w-4 h-4 border-2 border-gray-300 dark:border-white/20 border-t-gray-700 dark:border-t-white/80 rounded-full animate-spin"}),(0,t.jsx)("span",{children:"Loading templates..."})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"truncate max-w-[100px]",children:ei?ei.title:q.tasks.checklist.templates.select}),(0,t.jsx)("svg",{className:"w-4 h-4 text-gray-400 dark:text-white/40 ml-2",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"})})]})})}),(0,t.jsx)(G.DropdownMenuContent,{align:"start",className:"min-w-[280px] max-w-[400px] max-h-[400px] z-[200] p-0",children:L?(0,t.jsx)("div",{className:"p-3 text-center text-gray-500 dark:text-white/60",children:(0,t.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,t.jsx)("div",{className:"w-4 h-4 border-2 border-gray-300 dark:border-white/20 border-t-gray-700 dark:border-t-white/80 rounded-full animate-spin"}),(0,t.jsx)("span",{children:"Loading templates..."})]})}):0===M.length?(0,t.jsx)("div",{className:"p-3 text-center text-gray-500 dark:text-white/60",children:q.tasks.checklist.templates.noTemplates}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"p-3 border-b border-gray-200 dark:border-white/10",children:(0,t.jsx)("input",{type:"text",placeholder:"Search templates...",value:U,onChange:e=>B(e.target.value),className:"w-full px-3 py-2 text-sm bg-gray-50 dark:bg-white/[0.05] border border-gray-200 dark:border-white/[0.1] rounded-md text-gray-900 dark:text-white placeholder:text-gray-400 dark:text-white/40 focus:outline-none focus:border-gray-300 dark:border-white/20",autoFocus:!0})}),(0,t.jsx)("div",{className:"max-h-[300px] overflow-y-auto",children:0===en.length?(0,t.jsxs)("div",{className:"p-3 text-center text-gray-500 dark:text-white/60",children:['No templates found matching "',U,'"']}):en.map(e=>(0,t.jsx)(G.DropdownMenuItem,{onSelect:()=>eo(e.id),className:(0,N.cn)("mx-1 my-0.5 rounded-sm px-3 py-2 cursor-pointer",n===e.id?"bg-gray-100 dark:bg-white/10 text-gray-900 dark:text-white":"text-gray-600 dark:text-white/80 hover:bg-gray-100 dark:hover:bg-white/5 hover:text-gray-900 dark:hover:text-white"),children:(0,t.jsxs)("div",{className:"flex flex-col gap-1 min-w-0",children:[(0,t.jsx)("span",{className:"font-medium truncate",children:e.title}),(0,t.jsxs)("span",{className:"text-xs text-gray-500 dark:text-white/50 truncate",children:[e.category," ",e.section&&`⢠${e.section}`]})]})},e.id))})]})})]}),(0,t.jsxs)("div",{className:"relative group",children:[(0,t.jsx)("a",{href:"/settings/c
58hecklists",target:"_blank",rel:"noopener noreferrer",className:"flex items-center text-gray-400 dark:text-white/40 hover:text-gray-500 dark:hover:text-white/60 transition-colors",children:(0,t.jsx)(et.Pencil,{className:"w-5 h-5"})}),(0,t.jsx)("div",{className:"absolute left-1/2 -translate-x-1/2 bottom-full mb-1 whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:(0,t.jsx)("div",{className:"bg-white dark:bg-[#1C1C1E] text-xs text-gray-500 dark:text-white/60 px-2 py-1 rounded",children:q.tasks.checklist.templates.manage})})]})]}):null;if(!r?.length)return(0,t.jsxs)("div",{className:"p-4 border-b border-gray-200 dark:border-white/[0.08] overflow-x-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:q.tasks.checklist.title}),ed]}),(0,t.jsx)("p",{className:"text-sm text-gray-400 dark:text-white/40 mb-4",children:q.tasks.checklist.empty}),d&&(0,t.jsx)("div",{className:"mb-4",children:x?(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("input",{type:"text",value:p,onChange:e=>b(e.target.value),placeholder:q.tasks.checklist.input.placeholder,className:"flex-1 bg-gray-50 dark:bg-white/[0.05] rounded-md px-3 py-2 text-sm text-gray-900 dark:text-white placeholder:text-gray-400 dark:text-white/40",onKeyDown:e=>"Enter"===e.key&&p.trim()&&el()}),(0,t.jsx)("button",{onClick:el,disabled:f||!p.trim(),className:(0,N.cn)("px-3 py-2 rounded-md bg-gray-50 dark:bg-white/[0.05]","hover:bg-gray-100 dark:hover:bg-white/[0.1] transition-colors","disabled:opacity-50 disabled:cursor-not-allowed","flex-shrink-0"),title:q.tasks.checklist.input.addButton,children:f?(0,t.jsx)("div",{className:"w-4 h-4 border-2 border-gray-300 dark:border-white/20 border-t-gray-700 dark:border-t-white/80 rounded-full animate-spin"}):(0,t.jsx)(j.Plus,{className:"w-4 h-4"})})]}):(0,t.jsxs)("button",{onClick:()=>g(!0),className:(0,N.cn)("w-full px-3 py-2 rounded-md","bg-white dark:bg-white/[0.03] hover:bg-gray-50 dark:hover:bg-white/[0.05] border border-gray-200 dark:border-white/[0.08]","text-gray-600 dark:text-white/70 hover:text-gray-900 dark:hover:text-white","transition-colors","flex items-center justify-center gap-2"),children:[(0,t.jsx)(j.Plus,{className:"w-4 h-4"}),(0,t.jsx)("span",{className:"text-sm",children:q.tasks.checklist.input.showForm})]})})]});let ec=async t=>{try{let a=t.id.toString();if(m(e=>new Set([...e,a])),console.log("[TaskChecklist] Toggling item:",{taskId:e,itemId:t.id,currentCompleted:t.completed}),!(await fetch(`/api/tasks/checklists?taskId=${e}&itemId=${t.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({completed:!t.completed})})).ok)throw Error(q.tasks.checklist.errors.update);i?.()}catch(e){console.error("[TaskChecklist] Error updating item:",e)}finally{m(e=>{let a=new Set(e);return a.delete(t.id.toString()),a})}},em=async t=>{try{let a=t.id.toString();if(m(e=>new Set([...e,a])),!(await fetch(`/api/tasks/checklists?taskId=${e}&itemId=${t.id}`,{method:"DELETE"})).ok)throw Error(q.tasks.checklist.errors.delete);i?.()}catch(e){console.error("[TaskChecklist] Error deleting item:",e)}finally{m(e=>{let a=new Set(e);return a.delete(t.id.toString()),a})}},eu=()=>{C(null),E("")},eh=async t=>{let a=S.trim();if(!a||a===t.title)return void eu();try{if(T(!0),!(await fetch(`/api/tasks/checklists?taskId=${e}&itemId=${t.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:a})})).ok)throw Error(q.tasks.checklist.errors.update);eu(),i?.()}catch(e){console.error("[TaskChecklist] Error renaming item:",e)}finally{T(!1)}},ex=(s?J.filter(e=>e.title.toLowerCase().includes(s.toLowerCase())):J).reduce((e,t)=>{let a=t.section||q.tasks.checklist.sections.other;return e[a]||(e[a]=[]),e[a].push(t),e},{}),eg={canManageChecklist:o,canManageChecklistStructure:d,updatingItems:c,editingItemId:k,editText:S,isSavingEdit:I,verificationsByItem:K,getUserInfo:e=>{if(!e)return null;let t=H.find(t=>t.id===e);return t?{name:t.name,avatar:t.image,role:t.roles?.[0]}:null},onToggle:ec,onDelete:em,onStartEditing:e=>{C(e.id),E(e.title)},onCancelEditing:eu,onSaveEdit:eh,onEditTextChange:E,onLightbox:h};return(0,t.jsxs)("div",{className:"p-4 border-b border-gray-200 dark:border-white/[0.08] overflow-x-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:q.tasks.checklist.title}),ed]}),d&&(0,t.jsx)("div",{className:"mb-4",children:x?(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("input",{type:"text",value:p,onChange:e=>b(e.target.value),placeholder:q.tasks.checklist.input.placeholder,className:"flex-1 bg-gray-50 dark:bg-white/[0.05] rounded-md px-3 py-2 text-sm text-gray-900 dark:text-white placeholder:text-gray-400 dark:text-white/40",onKeyDown:e=>"Enter"===e.key&&p.trim()&&el()}),(0,t.jsx)("button",{onClick:el,disabled:f||!p.trim(),className:(0,N.cn)("px-3 py-2 rounded-md bg-gray-50 dark:bg-white/[0.05]","hover:bg-gray-100 dark:hover:bg-white/[0.1] transition-colors","disabled:opacity-50 disabled:cursor-not-allowed","flex-shrink-0"),title:q.tasks.checklist.input.addButton,children:f?(0,t.jsx)("div",{className:"w-4 h-4 border-2 border-gray-300 dark:border-white/20 border-t-gray-700 dark:border-t-white/80 rounded-full animate-spin"}):(0,t.jsx)(j.Plus,{className:"w-4 h-4"})})]}):(0,t.jsxs)("button",{onClick:()=>g(!0),className:(0,N.cn)("w-full px-3 py-2 rounded-md","bg-white dark:bg-white/[0.03] hover:bg-gray-50 dark:hover:bg-white/[0.05] border border-gray-200 dark:border-white/[0.08]","text-gray-600 dark:text-white/70 hover:text-gray-900 dark:hover:text-white","transition-colors","flex items-center justify-center gap-2"),children:[(0,t.jsx)(j.Plus,{className:"w-4 h-4"}),(0,t.jsx)("span",{className:"text-sm",children:q.tasks.checklist.input.showForm})]})}),(0,t.jsx)("div",{className:(0,N.cn)("space-y-6 transition-opacity",X&&"opacity-70"),children:Object.entries(ex).map(([e,a])=>(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("h4",{className:"text-sm font-medium text-gray-500 dark:text-white/60 mb-2",children:e}),ea?(0,t.jsx)(eE.DndContext,{sensors:ee,collisionDetection:eE.closestCenter,onDragEnd:es,children:(0,t.jsx)(eI.SortableContext,{items:a.map(e=>e.id),strategy:eI.verticalListSortingStrategy,children:(0,t.jsx)("div",{className:"space-y-2",children:a.map(e=>(0,t.jsx)(eA,{item:e,...eg},e.id))})})}):a.map(e=>(0,t.jsx)(e_,{item:e,...eg},e.id))]},e))}),u&&(0,t.jsx)("div",{className:"fixed inset-0 z-[200] bg-black/80 flex items-center justify-center p-4",onClick:()=>h(null),children:(0,t.jsxs)("div",{className:"bg-white dark:bg-[#1C1C1E] rounded-2xl max-w-lg w-full overflow-hidden shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,t.jsx)("img",{src:u.url,alt:"Photo",className:"w-full max-h-[60vh] object-contain bg-black"}),u.feedback&&(0,t.jsxs)("div",{className:(0,N.cn)("p-4 border-t border-gray-200 dark:border-white/10","passed"===u.status&&"bg-green-50 dark:bg-green-500/5","failed"===u.status&&"bg-red-50 dark:bg-red-500/5"),children:[u.status&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 mb-1.5",children:[(0,t.jsx)(eS,{status:u.status}),(0,t.jsx)("span",{className:"text-xs text-gray-400 dark:text-white/40",children:"Vanio AI"})]}),(0,t.jsx)("p",{className:"text-sm text-gray-700 dark:text-white/70 leading-relaxed",children:u.feedback})]}),(0,t.jsx)("button",{onClick:()=>h(null),className:"w-full py-3 text-sm text-gray-500 dark:text-white/40 hover:bg-gray-50 dark:hover:bg-white/[0.03] border-t border-gray-200 dark:border-white/10",children:"Close"})]})})]})}],839221);var eD=e.i(761911),eP=e.i(576844);function eR({taskId:e,subtasks:r=[],searchQuery:s,onSubtaskToggle:i,onAddSubtask:n,onUpdateSubtask:l,isSubtask:o=!1,canEdit:d=!1,canEditStructure:c=!1}){if(o)return null;let[m,u]=(0,a.useState)(""),[h,x]=(0,a.useState)(!1),{openSidebar:g}=(0,U.useTaskSidebar)(),{currentCustomerId:p,users:{users:b}}=(0,P.useCustomer)(),f=(0,z.useUserSettings)(p||void 0),{data:y}=(0,V.useSession)(),v=e=>{let t=f.getCurrentRole(p||void 0);if(t&&["admin","owner","user","team_lead","supervisor","roamer"].includes(t))return!0;
58if(t&&["partner","maintenance","cleaner"].includes(t)){let a=y?.user?.id;if(!a)return!1;let r=e.task_assignments||e.assignments||[];if(r.some(e=>e.user_id===a))return!0;if("partner"===t&&f.settings?.partner?.partnerId&&b){let e=f.settings.partner.partnerId,t=b.filter(t=>{let a=t.company?.companyId===e,r=t.serviceProvider?.type==="company"&&t.serviceProvider?.id===e;return a||r}).map(e=>e.id);return r.some(e=>t.includes(e.user_id))}return!1}return!0},k=async()=>{if(c&&m.trim()){x(!0);try{await n?.({title:m.trim()}),u("")}finally{x(!1)}}},C=async(e,t)=>{if(e.stopPropagation(),!v(t))return;let a="completed"===t.status?"todo":"completed";await l?.(t.id,{status:a})};return(0,t.jsxs)("div",{className:"p-4 border-b border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-gray-900 dark:text-white mb-4",children:"Subtasks"}),(0,t.jsxs)("div",{className:"space-y-0",children:[r.sort((e,t)=>(e.subtaskOrder||0)-(t.subtaskOrder||0)).map(e=>{let a=v(e);return(0,t.jsxs)("div",{className:(0,N.cn)("flex items-start gap-3","cursor-pointer hover:bg-white dark:hover:bg-white/[0.02] rounded-lg p-2 -ml-2 transition-colors","group w-full"),onClick:()=>{g(e.id.toString())},children:[(0,t.jsx)("button",{onClick:t=>C(t,e),disabled:!a,className:(0,N.cn)("flex-none mt-0.5 w-5 h-5 rounded-md border","flex items-center justify-center","transition-colors","completed"===e.status?"bg-green-500 border-transparent":"border-gray-300 dark:border-white/20 group-hover:border-gray-400 dark:group-hover:border-white/40",!a&&"cursor-not-allowed"),children:"completed"===e.status&&(0,t.jsx)(ey.Check,{className:"w-3 h-3 text-gray-900 dark:text-white"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,t.jsx)("span",{className:(0,N.cn)("text-sm truncate","completed"===e.status?"text-gray-400 dark:text-white/40 line-through":"text-gray-900 dark:text-white"),children:e.title}),e.priority&&(0,t.jsx)("span",{className:(0,N.cn)("text-xs px-1.5 py-0.5 rounded-full flex-shrink-0",{"bg-red-500/20 text-red-500":"urgent"===e.priority,"bg-orange-500/20 text-orange-500":"high"===e.priority,"bg-blue-500/20 text-blue-500":"normal"===e.priority,"bg-green-500/20 text-green-500":"low"===e.priority}),children:e.priority})]}),e.description&&(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-white/60 mt-1 line-clamp-2 break-words",children:e.description}),(0,t.jsxs)("div",{className:"flex items-center gap-4 mt-1 min-w-0",children:[e.assignedTo&&(0,t.jsxs)("div",{className:"flex items-center gap-1 text-sm text-gray-400 dark:text-white/40 min-w-0",children:[(0,t.jsx)(eD.Users,{className:"w-3 h-3 flex-shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:e.assignedTo.name})]}),e.dueDate&&(0,t.jsxs)("div",{className:"flex items-center gap-1 text-sm text-gray-400 dark:text-white/40 flex-shrink-0",children:[(0,t.jsx)(w.Calendar,{className:"w-3 h-3"}),(0,t.jsxs)("span",{children:["Due ",(0,eP.formatDistanceToNow)(new Date(e.dueDate),{addSuffix:!0})]})]})]})]})]},e.id)}),(0,t.jsxs)("div",{className:"flex items-center gap-2 mt-4",children:[(0,t.jsx)("input",{type:"text",value:m,onChange:e=>u(e.target.value),placeholder:c?"Add a subtask...":"No permission to add subtasks",className:(0,N.cn)("flex-1 bg-transparent","text-sm text-gray-900 dark:text-white placeholder:text-gray-400 dark:text-white/40","focus:outline-none",!c&&"cursor-not-allowed"),onKeyDown:e=>{"Enter"===e.key&&c&&k()},disabled:!c||h}),(0,t.jsx)("button",{onClick:k,disabled:!c||!m.trim()||h,className:(0,N.cn)("p-1.5 rounded-md","text-gray-400 dark:text-white/40 hover:text-gray-900 dark:hover:text-white","disabled:opacity-50 disabled:cursor-not-allowed"),children:(0,t.jsx)(j.Plus,{className:"w-4 h-4"})})]})]})]})}var eM=e.i(212426);e.s(["TaskBilling",0,function({billing:e}){if(!e)return null;let a=e=>{if(!e)return"Not set";let t=Math.floor(e/60);return`${t}h ${e%60}m`},r=t=>t?new Intl.NumberFormat("en-US",{style:"currency",currency:e.rate.currency}).format(t):"-";return(0,t.jsxs)("div",{className:"p-4 border-b border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-gray-900 dark:text-white mb-4",children:"Billing"}),(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 dark:text-white/60",children:[(0,t.jsx)(eM.DollarSign,{className:"w-4 h-4"}),(0,t.jsxs)("span",{className:"text-sm",children:["Rate (",e.rate.type,")"]})]}),(0,t.jsxs)("span",{className:"text-sm text-gray-900 dark:text-white",children:[r(e.rate.amount),"hourly"===e.rate.type&&"/hr","per_room"===e.rate.type&&"/room"]}
58)]}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 dark:text-white/60",children:[(0,t.jsx)(f.Clock,{className:"w-4 h-4"}),(0,t.jsx)("span",{className:"text-sm",children:"Duration"})]}),(0,t.jsxs)("div",{className:"text-sm",children:[(0,t.jsx)("span",{className:"text-gray-500 dark:text-white/60",children:"Est: "}),(0,t.jsx)("span",{className:"text-gray-900 dark:text-white",children:a(e.estimatedDuration)}),e.actualDuration&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"text-gray-500 dark:text-white/60 mx-2",children:"â¢"}),(0,t.jsx)("span",{className:"text-gray-500 dark:text-white/60",children:"Actual: "}),(0,t.jsx)("span",{className:"text-gray-900 dark:text-white",children:a(e.actualDuration)})]})]})]}),e.totalAmount&&(0,t.jsxs)("div",{className:"pt-4 mt-4 border-t border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Total Amount"}),(0,t.jsx)("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:r(e.totalAmount)})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between mt-1",children:[(0,t.jsx)("span",{className:"text-sm text-gray-500 dark:text-white/60",children:"Status"}),(0,t.jsx)("span",{className:(0,N.cn)("text-sm font-medium","paid"===e.status&&"text-green-500","pending"===e.status&&"text-yellow-500","approved"===e.status&&"text-blue-500"),children:e.status.charAt(0).toUpperCase()+e.status.slice(1)})]})]})]})]})}],32979);let eF={submitted:["approved","rejected"],approved:["billed","rejected"],rejected:["submitted"],billed:[]},eL=[{value:"",label:"All Categories"},{value:"maintenance",label:"Maintenance"},{value:"supplies",label:"Supplies"},{value:"cleaning",label:"Cleaning"},{value:"damage_repair",label:"Damage Repair"},{value:"utilities",label:"Utilities"},{value:"equipment",label:"Equipment"},{value:"labor",label:"Labor"},{value:"other",label:"Other"}],e$=eL.filter(e=>""!==e.value);function eO(e,t,a){return t?"billed"!==e.status:!!a&&e.submittedBy===a&&"submitted"===e.status}let eU={todo:"To Do",in_progress:"In Progress",blocked:"Blocked",completed:"Completed",cancelled:"Cancelled",pending:"Pending",failed:"Failed"};e.s(["DEFAULT_EXPENSE_SORT",0,{field:"date",dir:"desc"},"EXPENSE_CATEGORIES",0,eL,"EXPENSE_EDIT_CATEGORIES",0,e$,"EXPENSE_STATUS_ACCENTS",0,{submitted:{fill:"bg-amber-500 text-white",badge:"bg-amber-500/15 text-amber-300 border border-amber-500/20",text:"text-amber-400",tint:"border-amber-500/20 bg-amber-500/[0.05]",dot:"bg-amber-400"},approved:{fill:"bg-emerald-500 text-white",badge:"bg-emerald-500/15 text-emerald-300 border border-emerald-500/20",text:"text-emerald-400",tint:"border-emerald-500/20 bg-emerald-500/[0.05]",dot:"bg-emerald-400"},billed:{fill:"bg-indigo-500 text-white",badge:"bg-indigo-500/15 text-indigo-300 border border-indigo-500/20",text:"text-indigo-400",tint:"border-indigo-500/20 bg-indigo-500/[0.05]",dot:"bg-indigo-400"},rejected:{fill:"bg-red-500 text-white",badge:"bg-red-500/15 text-red-300 border border-red-500/20",text:"text-red-400",tint:"border-red-500/20 bg-red-500/[0.05]",dot:"bg-red-400"}},"EXPENSE_STATUS_LABELS",0,{submitted:"Submitted",approved:"Approved",billed:"Billed",rejected:"Rejected"},"EXPENSE_STATUS_ORDER",0,["submitted","approved","billed","rejected"],"canEditExpense",0,eO,"categoryLabel",0,function(e){return e?eL.find(t=>t.value===e)?.label||e:"â"},"formatExpenseAmount",0,function(e,t){let a="string"==typeof e?parseFloat(e):e,r=Number.isFinite(a)?a:0;return`${(t||"USD").toUpperCase()} ${r.toFixed(2)}`},"formatExpenseDate",0,function(e){let t=new Date(e);return Number.isNaN(t.getTime())?"â":t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})},"formatTaskDueDate",0,function(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"})},"isAllowedTransition",0,function(e,t){return e!==t&&(eF[e]?.includes(t)??!1)},"sortExpenses",0,function(e,t){return[...e].sort((e,a)=>(function(e,t,a){let r="asc"===a.dir?1:-1;if("property"===a.field){let a=(e.listingName??"").trim(),s=(t.listingName??"").trim();if(!a&&!s)return e.id-t.id;if(!a)return 1;if(!s)return -1;let i=a.localeCompare(s,void 0,{sensitivity:"base"});return 0!==i?i*r:e.id-t.id}let s=new Date(e.createdAt).getTime(),i=new Date(t.createdAt).getTime(),n=Number.isFinite(s)?s:0,l=Number.isFinite(i)?i:0;return n!==l?(n-l)*r:e.id-t.id})(e,a,t))},"taskStatusChipClasses",0,function(e){switch(e){case"completed":return"bg-emerald-500/15 text-emerald-400";case"in_progress":return"bg-blue-500/15 text-blue-400";case"blocked":case"failed":return"bg-red-500/15 text-red-400";case"cancelled":return"bg-zinc-500/15 text-zinc-400";default:return"bg-amber-500/15 text-amber-400"}},"taskStatusLabel",0,function(e){return e?eU[e]||e.replace(/_/g," "):"â"}],633393);let eB=new Set(["submitted","pending"]);var eq=e.i(522016),ez=e.i(727612),eH=e.i(607486),eV=e.i(778917),eG=e.i(569074),eW=e.i(920884),eK=e.i(837647),eY=e.i(996091),eJ=e.i(261065),eQ=e.i(75998),eX=e.i(751523);let eZ=["admin","owner","team_lead","supervisor","accountant","bookkeeper"],e0=["USD","EUR","GBP","BGN","CAD"],e1=[{value:"maintenance",label:"Maintenance"},{value:"supplies",label:"Supplies"},{value:"cleaning",label:"Cleaning"},{value:"damage_repair",label:"Damage Repair"},{value:"utilities",label:"Utilities"},{value:"equipment",label:"Equipment"},{value:"labor",label:"Labor"},{value:"other",label:"Other"}];e.s(["TaskExpensesPanel",0,function({taskId:e,onExpenseChange:s}){let{currentCustomerId:i}=(0,P.useCustomer)(),n=(0,z.useUserSettings)(i||void 0),l=(0,eJ.useServiceProviderRules)(),o=n.settings?.theme!=="light",d=n.getCurrentRole(i||void 0),c=!!d&&eZ.includes(d),{data:m}=(0,V.useSession)(),u=m?.user?.id,[h,x]=(0,a.useState)([]),[g,p]=(0,a.useState)(!0),[b,f]=(0,a.useState)(!1),[y,w]=(0,a.useState)(!1),[v,k]=(0,a.useState)(null),[C,S]=(0,a.useState)(null),[E,I]=(0,a.useState)(null),[T,_]=(0,a.useState)(null),[A,D]=(0,a.useState)(""),[R,M]=(0,a.useState)(""),[F,L]=(0,a.useState)(null),[$,O]=(0,a.useState)(""),[U,B]=(0,a.useState)(null),[q,H]=(0,a.useState)(""),[G,W]=(0,a.useState)(""),[K,Y]=(0,a.useState)("other"),[J,Q]=(0,a.useState)(""),[X,Z]=(0,a.useState)("total"),[ee,ea]=(0,a.useState)(""),[er,es]=(0,a.useState)(""),[ei,eo]=(0,a.useState)("USD"),[em,eu]=(0,a.useState)(null),eh=(0,a.useRef)(!1),[ex,eg]=(0,a.useState)(""),[ep,eb]=(0,a.useState)(!1),[ef,ew]=(0,a.useState)(null),ev=(0,a.useRef)(null),ek=async e=>{eb(!0),ew(null);try{let t=await fetch("/api/tasks/expenses/upload",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({fileName:e.name,fileType:e.type,fileSize:e.size})}),a=await t.json();if(!t.ok)return void ew(a.error||"Upload failed");await fetch(a.signedUrl,{method:"PUT",headers:{"Content-Type":e.type},body:e}),eg(a.publicUrl)}catch{ew("Upload failed")}finally{eb(!1)}},ej=(0,a.useCallback)(async()=>{try{let t=await fetch(`/api/tasks/expenses?taskId=${e}`,{credentials:"include"}),a=await t.json();x(a.expenses||[]),"string"==typeof a.accountCurrency&&a.accountCurrency&&eu(a.accountCurrency.toUpperCase())}catch(e){console.error("Failed to fetch expenses:",e)}finally{p(!1)}},[e]);(0,a.useEffect)(()=>{ej()},[ej]),(0,a.useEffect)(()=>{em&&!eh.current&&eo(em)},[em]);let eN=parseFloat(ee),eC=parseFloat(er),eS=Number.isFinite(eN)&&Number.isFinite(eC)?eN*eC:0,eE=eN>0&&eC>0,eI=!!q.trim()&&("quantity"===X?eE:!!J),eT=()=>{H(""),W(""),Y("other"),Q(""),ea(""),es(""),Z("total"),eg(""),eh.current=!1,eo(em||"USD")},e_=async()=>
58{if(!eI)return;let t="quantity"===X;w(!0);try{await fetch("/api/tasks/expenses",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({taskId:Number(e),title:q.trim(),description:G.trim()||void 0,category:K,amount:t?eS:parseFloat(J),quantity:t?eN:void 0,unitPrice:t?eC:void 0,currency:ei,receiptUrl:ex.trim()||void 0})}),eT(),f(!1),ej(),s?.()}catch(e){console.error("Failed to create expense:",e)}finally{w(!1)}},eA=()=>{_(null),L(null)},eD=async e=>{let t=A.trim(),a=parseFloat(R);if(!t)return void L("Give the expense a name.");if(!Number.isFinite(a)||a<=0)return void L("Enter an amount greater than zero.");k(e),S("update"),L(null);try{let r=await fetch("/api/tasks/expenses",{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({action:"update",expenseId:e,fields:{title:t,amount:a}})});if(!r.ok){let e=await r.json().catch(()=>null);L(e?.error||"Could not save the change.");return}_(null),ej(),s?.()}catch(e){console.error("Failed to update expense:",e),L("Could not save the change.")}finally{k(null),S(null)}},eP=async(e,t,a)=>{k(e),S(t);try{await fetch("/api/tasks/expenses",{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({action:t,expenseId:e,reason:a})}),ej(),s?.(),B(null),O("")}catch(e){console.error(`Failed to ${t} expense:`,e)}finally{k(null),S(null)}},eR=async e=>{k(e),S("delete");try{await fetch(`/api/tasks/expenses?id=${e}`,{method:"DELETE",credentials:"include"}),ej(),s?.()}catch(e){console.error("Failed to delete expense:",e)}finally{k(null),S(null),I(null)}},eF=h.reduce((e,t)=>e+parseFloat(t.amount||"0"),0),eL=h.filter(e=>"submitted"===e.status||"pending"===e.status).length,e$=o?{submitted:"bg-amber-500/15 text-amber-300 border-amber-500/20",pending:"bg-amber-500/15 text-amber-300 border-amber-500/20",approved:"bg-emerald-500/15 text-emerald-300 border-emerald-500/20",billed:"bg-indigo-500/15 text-indigo-300 border-indigo-500/20",rejected:"bg-red-500/15 text-red-300 border-red-500/20"}:{submitted:"bg-amber-50 text-amber-700 border-amber-200",pending:"bg-amber-50 text-amber-700 border-amber-200",approved:"bg-emerald-50 text-emerald-700 border-emerald-200",billed:"bg-indigo-50 text-indigo-700 border-indigo-200",rejected:"bg-red-50 text-red-700 border-red-200"},eU=o?"bg-white/[0.05] border-white/[0.1] text-white":"bg-white border-gray-300 text-gray-900",e2=o?"text-white/80 focus:bg-white/[0.06] focus:text-white":"text-gray-700 focus:bg-gray-100 focus:text-gray-900",e5=em&&!e0.includes(em)?[em,...e0]:[...e0],e4=e=>{eh.current=!0,eo(e)};return(0,eY.mayAddTaskExpenses)({currentRole:d||null,roles:n.settings?.roles,isSuperUser:n.settings?.isSuperUser},l.blockServiceProviderExpenses)?(0,t.jsxs)("div",{className:(0,N.cn)("p-4 border-b",o?"border-white/[0.08]":"border-gray-200"),children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("h3",{className:(0,N.cn)("text-sm font-medium",o?"text-white":"text-gray-900"),children:"Expenses"}),h.length>0&&(0,t.jsxs)("span",{className:(0,N.cn)("text-xs",o?"text-white/40":"text-gray-400"),children:["(",h.length,")"]}),eL>0&&c&&(0,t.jsxs)("span",{className:(0,N.cn)("text-[10px] px-1.5 py-0.5 rounded border",o?"bg-amber-500/15 text-amber-300 border-amber-500/20":"bg-amber-50 text-amber-700 border-amber-200"),children:[eL," to review"]})]}),eF>0&&(0,t.jsxs)("span",{className:(0,N.cn)("text-sm font-medium",o?"text-white":"text-gray-900"),children:[h[0]?.currency||"USD"," ",eF.toFixed(2)]})]}),g?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("div",{className:(0,N.cn)("h-8 rounded animate-pulse",o?"bg-white/[0.05]":"bg-gray-100")}),(0,t.jsx)("div",{className:(0,N.cn)("h-8 rounded animate-pulse w-3/4",o?"bg-white/[0.05]":"bg-gray-100")})]}):(0,t.jsxs)(t.Fragment,{children:[0===h.length&&!b&&(0,t.jsx)("p",{className:(0,N.cn)("text-sm mb-4",o?"text-white/40":"text-gray-500"),children:"No expenses recorded"}),h.length>0&&(0,t.jsx)("div",{className:"space-y-2 mb-4",children:h.map(a=>{var s;let i;return(0,t.jsxs)("div",{className:(0,N.cn)("rounded-lg border px-3 py-2.5",o?"border-white/[0.08] bg-white/[0.02]":"border-gray-200 bg-white"),children:[T===a.id&&(0,t.jsxs)("div",{className:"mb-2 space-y-2",children:[(0,t.jsx)(eQ.Input,{value:A,onChange:e=>D(e.target.value),placeholder:"Expense name",className:"h-8 text-sm",disabled:v===a.id}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(eQ.Input,{value:R,onChange:e=>M(e.target.value),placeholder:"Amount",inputMode:"decimal",className:"h-8 text-sm w-32",disabled:v===a.id}),(0,t.jsx)("span",{className:(0,N.cn)("text-xs",o?"text-white/40":"text-gray-500"),children:a.currency}),(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-1.5",children:[(0,t.jsx)(ed.Button,{size:"sm",variant:"ghost",className:"h-8 px-2 text-xs",onClick:eA,disabled:v===a.id,children:"Cancel"}),(0,t.jsx)(ed.Button,{size:"sm",className:"h-8 px-3 text-xs",onClick:()=>eD(a.id),disabled:v===a.id,children:v===a.id&&"update"===C?(0,t.jsx)(en.Loader2,{className:"w-3.5 h-3.5 animate-spin"}):"Save"})]})]}),F&&(0,t.jsx)("p",{className:"text-xs text-red-400",children:F})]}),(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-0.5",children:[(0,t.jsx)("span",{className:(0,N.cn)("text-sm font-medium truncate",o?"text-white/80":"text-gray-900"),children:a.title}),(0,t.jsx)("span",{className:(0,N.cn)("text-[10px] px-1.5 py-0.5 rounded border shrink-0",e$[a.status]||e$.submitted),children:a.status})]}),a.description&&(0,t.jsx)("p",{className:(0,N.cn)("text-xs mb-1",o?"text-white/40":"text-gray-500"),children:a.description}),(0,t.jsxs)("div",{className:(0,N.cn)("flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px]",o?"text-white/30":"text-gray-500"),children:[(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)(eM.DollarSign,{className:"w-3 h-3"}),a.currency," ",parseFloat(a.amount).toFixed(2)]}),null!=a.quantity&&null!=a.unitPrice&&(0,t.jsxs)("span",{className:(0,N.cn)(o?"text-white/40":"text-gray-400"),children:[Number.isFinite(i="number"==typeof(s=a.quantity)?s:p
58arseFloat(s))?Number.isInteger(i)?String(i):String(parseFloat(i.toFixed(2))):String(s)," à ",a.currency," ",parseFloat(a.unitPrice).toFixed(2)]}),(0,t.jsx)("span",{children:e1.find(e=>e.value===a.category)?.label||a.category}),null!=a.taskId&&Number(a.taskId)!==Number(e)&&a.taskTitle&&(0,t.jsxs)("span",{className:(0,N.cn)("flex items-center gap-1 min-w-0",o?"text-white/40":"text-gray-500"),title:`From subtask: ${a.taskTitle}`,children:[(0,t.jsx)(eW.CornerDownRight,{className:"w-3 h-3 shrink-0"}),(0,t.jsx)("span",{className:"truncate max-w-[160px]",children:a.taskTitle})]}),a.listingName&&(0,t.jsxs)("span",{className:(0,N.cn)("flex items-center gap-1 min-w-0",o?"text-white/40":"text-gray-500"),children:[(0,t.jsx)(eH.Building2,{className:"w-3 h-3 shrink-0"}),(0,t.jsx)("span",{className:"truncate max-w-[160px]",children:a.listingName})]}),a.submittedByName&&(0,t.jsxs)("span",{children:["by ",a.submittedByName]}),a.rejectionReason&&(0,t.jsxs)("span",{className:o?"text-red-300/60":"text-red-600",children:["Reason: ",a.rejectionReason]})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0",children:[("submitted"===a.status||"pending"===a.status)&&c&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{onClick:()=>eP(a.id,"approve"),disabled:v===a.id,className:(0,N.cn)("p-1.5 rounded hover:bg-emerald-500/10 text-emerald-400 transition-colors",v===a.id&&"opacity-50 cursor-not-allowed"),title:"Approve",children:v===a.id&&"approve"===C?(0,t.jsx)(en.Loader2,{className:"w-3.5 h-3.5 animate-spin"}):(0,t.jsx)(ey.Check,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("button",{onClick:()=>B(a.id),disabled:v===a.id,className:(0,N.cn)("p-1.5 rounded hover:bg-red-500/10 text-red-400 transition-colors",v===a.id&&"opacity-50 cursor-not-allowed"),title:"Reject",children:(0,t.jsx)(r.X,{className:"w-3.5 h-3.5"})})]}),"approved"===a.status&&c&&(0,t.jsx)("button",{onClick:()=>eP(a.id,"reopen"),disabled:v===a.id,className:(0,N.cn)("p-1.5 rounded hover:bg-amber-500/10 text-amber-400 transition-colors",v===a.id&&"opacity-50 cursor-not-allowed"),title:"Move back to submitted",children:v===a.id&&"reopen"===C?(0,t.jsx)(en.Loader2,{className:"w-3.5 h-3.5 animate-spin"}):(0,t.jsx)(eK.Undo2,{className:"w-3.5 h-3.5"})}),!!eB.has(String(a.status))&&eO(a,c,u)&&(0,t.jsx)("button",{onClick:()=>T===a.id?eA():void(_(a.id),D(a.title||""),M(String(a.amount??"")),L(null)),disabled:v===a.id,className:(0,N.cn)("p-1.5 rounded hover:bg-blue-500/10 hover:text-blue-400 transition-colors",o?"text-white/30":"text-gray-400",T===a.id&&"bg-blue-500/10 text-blue-400",v===a.id&&"opacity-50 cursor-not-allowed"),title:T===a.id?"Cancel edit":"Edit",children:v===a.id&&"update"===C?(0,t.jsx)(en.Loader2,{className:"w-3.5 h-3.5 animate-spin"}):(0,t.jsx)(et.Pencil,{className:"w-3.5 h-3.5"})}),("submitted"===a.status||"pending"===a.status)&&(c||!!u&&a.submittedBy===u)&&(0,t.jsx)("button",{onClick:()=>I(a.id),disabled:v===a.id,className:(0,N.cn)("p-1.5 rounded hover:bg-red-500/10 hover:text-red-400 transition-colors",o?"text-white/30":"text-gray-400",v===a.id&&"opacity-50 cursor-not-allowed"),title:"Delete",children:v===a.id&&"delete"===C?(0,t.jsx)(en.Loader2,{className:"w-3.5 h-3.5 animate-spin"}):(0,t.jsx)(ez.Trash2,{className:"w-3.5 h-3.5"})}),(0,t.jsx)(eq.default,{href:"/tasks?view=expenses",className:(0,N.cn)("p-1.5 rounded transition-colors",o?"hover:bg-white/[0.06] text-white/30 hover:text-white/70":"hover:bg-gray-100 text-gray-400 hover:text-gray-700"),title:"Open in Expenses",children:(0,t.jsx)(eV.ExternalLink,{className:"w-3.5 h-3.5"})})]})]}),U===a.id&&(0,t.jsxs)("div",{className:"mt-2 flex gap-2",children:[(0,t.jsx)(eQ.Input,{value:$,onChange:e=>O(e.target.value),placeholder:"Rejection reason (optional)",className:(0,N.cn)("text-xs h-7 flex-1",o?"bg-white/[0.05] border-white/[0.1] text-white":"bg-white border-gray-300 text-gray-900")}),(0,t.jsx)(ed.Button,{size:"sm",onClick:()=>eP(a.id,"reject",$),disabled:v===a.id,className:"text-xs h-7 bg-red-500/10 text-red-400 hover:bg-red-500/20 border border-red-500/20",children:v===a.id?(0,t.jsx)(en.Loader2,{className:"w-3 h-3 animate-spin"}):"Reject"}),(0,t.jsx)(ed.Button,{variant:"ghost",size:"sm",onClick:()=>{B(null),O("")},className:(0,N.cn)("text-xs h-7",o?"text-white/50":"text-gray-500"),children:"Cancel"})]})]},a.id)})}),b?(0,t.jsxs)("div",{className:(0,N.cn)("space-y-2 rounded-lg border p-3",o?"border-white/[0.08] bg-white/[0.02]":"border-gray-200 bg-white"),children:[(0,t.jsx)(eQ.Input,{value:q,onChange:e=>H(e.target.value),placeholder:"Expense title",className:(0,N.cn)("text-sm h-8",eU),onKeyDown:e=>e.stopPropagation()}),(0,t.jsx)("div",{className:(0,N.cn)("inline-flex items-center gap-0.5 rounded-md border p-0.5",o?"border-white/[0.1] bg-white/[0.03]":"border-gray-200 bg-gray-50"),children:[{key:"total",label:"Total"},{key:"quantity",label:"Quantity à unit price"}].map(e=>(0,t.jsx)("button",{type:"button",onClick:()=>Z(e.key),className:(0,N.cn)("px-2.5 py-1 rounded text-xs transition-colors",X===e.key?o?"bg-white text-black":"bg-gray-900 text-white":o?"text-white/60 hover:text-white":"text-gray-500 hover:text-gray-900"),children:e.label},e.key))}),"total"===X?(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("div",{className:"flex-1",children:(0,t.jsx)(eQ.Input,{type:"number",step:"0.01",value:J,onChange:e=>Q(e.target.value),placeholder:"Amount",className:(0,N.cn)("text-sm h-8",eU),onKeyDown:e=>e.stopPropagation()})}),(0,t.jsxs)(eX.Select,{value:ei,onValueChange:e4,children:[(0,t.jsx)(eX.SelectTrigger,{className:(0,N.cn)("w-20 text-sm h-8",eU),children:(0,t.jsx)(eX.SelectValue,{})}),(0,t.jsx)(eX.SelectContent,{className:(0,N.cn)("z-[200]",o?"bg-[#1a1a1a] border-white/[0.1]":"bg-white border-gray-200"),children:e5.map(e=>(0,t.jsx)(eX.SelectItem,{value:e,className:(0,N.cn)("text-sm",e2),children:e},e))})]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(eQ.Input,{type:"number",step:"0.01",min:"0",value:ee,onChange:e=>ea(e.target.value),placeholder:"Qty",className:(0,N.cn)("text-sm h-8 flex-1",eU),onKeyDown:e=>e.stopPropagation()}),(0,t.jsx)("span",{className:(0,N.cn)("text-sm shrink-0",o?"text-white/40":"text-gray-400"),children:"Ã"}),(0,t.jsx)(eQ.Input,{type:"number",step:"0.01",min:"0",value:er,onCh
58ange:e=>es(e.target.value),placeholder:"Unit price",className:(0,N.cn)("text-sm h-8 flex-1",eU),onKeyDown:e=>e.stopPropagation()}),(0,t.jsxs)(eX.Select,{value:ei,onValueChange:e4,children:[(0,t.jsx)(eX.SelectTrigger,{className:(0,N.cn)("w-20 text-sm h-8 shrink-0",eU),children:(0,t.jsx)(eX.SelectValue,{})}),(0,t.jsx)(eX.SelectContent,{className:(0,N.cn)("z-[200]",o?"bg-[#1a1a1a] border-white/[0.1]":"bg-white border-gray-200"),children:e5.map(e=>(0,t.jsx)(eX.SelectItem,{value:e,className:(0,N.cn)("text-sm",e2),children:e},e))})]})]}),(0,t.jsxs)("div",{className:(0,N.cn)("flex items-center justify-between rounded-md border px-3 py-1.5 text-xs",o?"border-white/[0.08] bg-white/[0.02] text-white/70":"border-gray-200 bg-gray-50 text-gray-600"),children:[(0,t.jsx)("span",{children:"Total"}),(0,t.jsxs)("span",{className:(0,N.cn)("font-medium",o?"text-white":"text-gray-900"),children:[ei," ",eS.toFixed(2)]})]})]}),(0,t.jsxs)(eX.Select,{value:K,onValueChange:Y,children:[(0,t.jsx)(eX.SelectTrigger,{className:(0,N.cn)("text-sm h-8",eU),children:(0,t.jsx)(eX.SelectValue,{})}),(0,t.jsx)(eX.SelectContent,{className:(0,N.cn)("z-[200]",o?"bg-[#1a1a1a] border-white/[0.1]":"bg-white border-gray-200"),children:e1.map(e=>(0,t.jsx)(eX.SelectItem,{value:e.value,className:(0,N.cn)("text-sm",e2),children:e.label},e.value))})]}),(0,t.jsx)(ec.Textarea,{value:G,onChange:e=>W(e.target.value),placeholder:"Description (optional)",rows:2,className:(0,N.cn)("text-sm",eU),onKeyDown:e=>e.stopPropagation()}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(eQ.Input,{value:ex,onChange:e=>eg(e.target.value),placeholder:"Receipt URL or upload",disabled:ep,className:(0,N.cn)("text-sm h-8 flex-1",eU),onKeyDown:e=>e.stopPropagation()}),(0,t.jsx)("input",{ref:ev,type:"file",accept:"image/*,.pdf",className:"hidden",onChange:e=>{let t=e.target.files?.[0];t&&ek(t),e.target.value=""}}),(0,t.jsx)("button",{type:"button",disabled:ep,onClick:()=>ev.current?.click(),className:(0,N.cn)("h-8 w-8 rounded-md border flex items-center justify-center shrink-0 transition-colors",o?"border-white/[0.1] text-white/50 hover:bg-white/[0.05]":"border-gray-300 text-gray-500 hover:bg-gray-50"),children:ep?(0,t.jsx)(en.Loader2,{className:"w-3.5 h-3.5 animate-spin"}):(0,t.jsx)(eG.Upload,{className:"w-3.5 h-3.5"})})]}),ef&&(0,t.jsx)("p",{className:"text-[11px] text-red-400",children:ef}),(0,t.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,t.jsx)("button",{onClick:()=>{f(!1),eT()},className:(0,N.cn)("px-3 py-1.5 transition-colors text-xs",o?"text-white/60 hover:text-white":"text-gray-500 hover:text-gray-900"),children:"Cancel"}),(0,t.jsx)("button",{onClick:e_,disabled:y||!eI,className:(0,N.cn)("flex items-center justify-center gap-1.5","px-3 py-1.5 rounded-lg text-xs transition-colors",o?"bg-white text-black hover:bg-white/90":"bg-gray-900 text-white hover:bg-gray-800",(y||!eI)&&"opacity-50 cursor-not-allowed"),children:y?(0,t.jsx)("div",{className:(0,N.cn)("w-3 h-3 border-2 rounded-full animate-spin",o?"border-black/20 border-t-black/80":"border-white/30 border-t-white")}):"Add Expense"})]})]}):(0,t.jsxs)("button",{onClick:()=>f(!0),className:(0,N.cn)("w-full px-3 py-2 rounded-md border transition-colors","flex items-center justify-center gap-2",o?"bg-white/[0.03] hover:bg-white/[0.05] border-white/[0.08] text-white/70 hover:text-white":"bg-gray-50 hover:bg-gray-100 border-gray-200 text-gray-600 hover:text-gray-900"),children:[(0,t.jsx)(j.Plus,{className:"w-4 h-4"}),(0,t.jsx)("span",{className:"text-sm",children:"Add Expense"})]})]}),(0,t.jsx)(el.AlertDialog,{open:null!==E,onOpenChange:()=>I(null),children:(0,t.jsxs)(el.AlertDialogContent,{className:"bg-[#141414] border-white/[0.1]",children:[(0,t.jsxs)(el.AlertDialogHeader,{children:[(0,t.jsx)(el.AlertDialogTitle,{className:"text-white",children:"Delete Expense"}),(0,t.jsx)(el.AlertDialogDescription,{className:"text-white/60",children:"This will permanently remove this expense. This cannot be undone."})]}),(0,t.jsxs)(el.AlertDialogFooter,{children:[(0,t.jsx)(el.AlertDialogCancel,{className:"bg-white/[0.05] border-white/[0.1] text-white hover:bg-white/[0.1]",children:"Cancel"}),(0,t.jsx)(el.AlertDialogAction,{onClick:()=>E&&eR(E),disabled:v===E,className:"bg-red-500/10 text-red-400 hover:bg-red-500/20 border border-red-500/20",children:v===E?(0,t.jsx)(en.Loader2,{className:"w-4 h-4 animate-spin"}):"Delete"})]})]})})]}):null}],843409);var e2=e.i(560491),e5=e.i(996781),e4=e.i(495242),e3=e.i(431343),e6=e.i(959208),e8=e.i(65921);let e9=[{value:"day",label:"day(s)"},{value:"week",label:"week(s)"},{value:"month",label:"month(s)"}];function e7(e){if(!e)return null;let t=new Date(e);return isNaN(t.getTime())?null:(0,eo.format)(t,"MMM d, yyyy")}let te=async e=>{let t=await fetch(e,{credentials:"include"}),a=await t.json().catch(()=>({}));if(!t.ok){let e=Error(a?.error||"Failed to load recurrence");throw e.fix=a?.fix,e}return a};e.s(["TaskRecurrencePanel",0,function({taskId:e,recurrenceId:s,canEdit:i=!1,onUpdate:n}){var l,o,d;let[c,m]=(0,a.useState)(!1),u=null!=s||c?`/api/tasks/recurrences?taskId=${e}
58`:null,{data:h,error:x,isLoading:g,mutate:p}=(0,e2.default)(u,te,{revalidateOnFocus:!1}),b=(l=h?.recurrence)?{id:l.id,everyInterval:Number(l.everyInterval??l.every_interval??l.every??1),unit:l.unit??"day",nextRunAt:l.nextRunAt??l.next_run_at??null,endDate:l.endDate??l.end_date??null,active:!1!==l.active,cancelled:!0===l.cancelled,occurrencesCreated:Number(l.occurrencesCreated??l.occurrences_created??0)}:null,f=!!b&&!b.cancelled,[y,w]=(0,a.useState)(!1),[v,k]=(0,a.useState)("1"),[j,C]=(0,a.useState)("week"),[S,E]=(0,a.useState)(""),[I,T]=(0,a.useState)(null),[_,A]=(0,a.useState)(null),[D,P]=(0,a.useState)(!1),R=parseInt(v,10),M=Number.isFinite(R)&&R>=1,F=()=>{f&&b?(k(String(b.everyInterval)),C(b.unit),E(function(e){if(!e)return"";let t=new Date(e);return isNaN(t.getTime())?"":(0,eo.format)(t,"yyyy-MM-dd")}(b.endDate))):(k("1"),C("week"),E("")),A(null),w(!0)},L=async(e,t,a)=>{T(e),A(null);try{let e=await fetch("/api/tasks/recurrences",{credentials:"include",headers:{"Content-Type":"application/json"},...t}),r=await e.json().catch(()=>({}));if(!e.ok)return void A({error:r?.error||"Something went wrong",fix:r?.fix});a?.(r)}catch{A({error:"Network error â could not reach the server"})}finally{T(null)}},$=async()=>{if(!M)return;let t={every:R,unit:j};S&&(t.endDate=S),f&&b?await L("save",{method:"PATCH",body:JSON.stringify({id:b.id,action:"update",rule:t})},e=>{p({recurrence:e.recurrence},!1),w(!1)}):await L("save",{method:"POST",body:JSON.stringify({taskId:Number(e),rule:t})},e=>{m(!0),p({recurrence:e.recurrence},!1),w(!1),n?.()})},O=async()=>{b&&await L("toggle",{method:"PATCH",body:JSON.stringify({id:b.id,action:b.active?"pause":"resume"})},e=>{p({recurrence:e.recurrence},!1)})},U=async()=>{b&&await L("cancel",{method:"PATCH",body:JSON.stringify({id:b.id,action:"cancel"})},()=>{P(!1),m(!1),p({recurrence:null},!1),n?.()})};if(!f&&!y&&!i&&!g)return null;let B=b?e7(b.nextRunAt):null,q=b?e7(b.endDate):null;return(0,t.jsxs)("div",{className:"p-4 border-b border-gray-200 dark:border-white/[0.08]",children:[u&&g&&!h?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(e8.Skeleton,{className:"h-4 w-40 bg-gray-100 dark:bg-white/[0.05]"}),(0,t.jsx)(e8.Skeleton,{className:"h-3 w-56 bg-gray-100 dark:bg-white/[0.05]"})]}):y?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,t.jsx)(e5.Repeat,{className:"w-3.5 h-3.5 text-blue-400"}),(0,t.jsx)("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:f?"Edit recurrence":"Make recurring"})]}),(0,t.jsxs)("div",{className:"space-y-2 rounded-lg border border-gray-200 dark:border-white/[0.08] bg-white dark:bg-white/[0.02] p-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-xs text-gray-500 dark:text-white/50 shrink-0",children:"Every"}),(0,t.jsx)(eQ.Input,{type:"number",min:1,value:v,onChange:e=>k(e.target.value),onKeyDown:e=>e.stopPropagation(),className:"w-20 h-11 sm:h-8 bg-gray-50 dark:bg-white/[0.05] border-gray-200 dark:border-white/[0.1] text-gray-900 dark:text-white text-sm"}),(0,t.jsxs)(eX.Select,{value:j,onValueChange:e=>C(e),children:[(0,t.jsx)(eX.SelectTrigger,{className:"flex-1 h-11 sm:h-8 bg-gray-50 dark:bg-white/[0.05] border-gray-200 dark:border-white/[0.1] text-gray-900 dark:text-white text-sm",children:(0,t.jsx)(eX.SelectValue,{})}),(0,t.jsx)(eX.SelectContent,{className:"z-[200] bg-white dark:bg-[#1a1a1a] border-gray-200 dark:border-white/[0.1]",children:e9.map(e=>(0,t.jsx)(eX.SelectItem,{value:e.value,className:"text-gray-700 dark:text-white/80 focus:bg-gray-100 dark:focus:bg-white/[0.06] focus:text-gray-900 dark:focus:text-white text-sm",children:e.label},e.value))})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-xs text-gray-500 dark:text-white/50 shrink-0",children:"Ends"}),(0,t.jsx)(eQ.Input,{type:"date",value:S,onChange:e=>E(e.target.value),onKeyDown:e=>e.stopPropagation(),className:"flex-1 h-11 sm:h-8 bg-gray-50 dark:bg-white/[0.05] border-gray-200 dark:border-white/[0.1] text-gray-900 dark:text-white text-sm"}),S&&(0,t.jsx)("button",{onClick:()=>E(""),className:"flex items-center justify-center min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0 sm:p-1.5 rounded text-gray-400 dark:text-white/40 hover:text-gray-600 dark:hover:text-white/70 hover:bg-gray-100 dark:hover:bg-white/[0.06] transition-colors",title:"Clear end date",children:(0,t.jsx)(r.X,{className:"w-3.5 h-3.5"})})]}),(0,t.jsx)("p",{className:"text-[11px] text-gray-400 dark:text-white/30",children:"Leave end date empty to repeat indefinitely."}),_&&(0,t.jsxs)("div",{className:"text-xs text-red-400",children:[(0,t.jsx)("span",{children:_.error}),_.fix&&(0,t.jsx)("span",{className:"block text-red-300/70 mt-0.5",children:_.fix})]}),(0,t.jsxs)("div",{className:"flex gap-2 justify-end pt-1",children:[(0,t.jsx)("button",{onClick:()=>{w(!1),A(null)},disabled:"save"===I,className:"min-h-[44px] sm:min-h-0 px-3 py-1.5 text-gray-500 dark:text-white/60 hover:text-gray-900 dark:hover:text-white transition-colors text-xs",children:"Cancel"}),(0,t.jsx)("button",{onClick:$,disabled:"save"===I||!M,className:(0,N.cn)("flex items-center justify-center gap-1.5","min-h-[44px] sm:min-h-0 px-3 py-1.5 rounded-lg text-xs","bg-gray-900 text-white dark:bg-white dark:text-black","hover:bg-gray-800 dark:hover:bg-white/90 transition-colors",("save"===I||!M)&&"opacity-50 cursor-not-allowed"),children:"save"===I?(0,t.jsx)(en.Loader2,{className:"w-3 h-3 animate-spin"}):f?"Save":"Start repeating"})]})]})]}):f&&b?(0,t.jsx)(t.Fragment,{children:(0,t.jsxs)("div",{className:"rounded-lg border border-gray-200 dark:border-white/[0.08] bg-white dark:bg-white/[0.02] px-3 py-2.5",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,t.jsx)(e5.Repeat,{className:"w-3.5 h-3.5 text-blue-400 shrink-0"}),(0,t.jsx)("span",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:(o=b.everyInterval,d=b.unit,1===o?"day"===d?"Repeats daily":"week"===d?"Repeats weekly":"Repeats monthly":`Repeats every ${o} ${d}s`)}),!b.active&&(0,t.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-500/15 text-amber-500 dark:text-amber-300 border border-amber-500/20 shrink-0",children:"Paused"})]}),i&&(0,t.jsxs)("div",{className:"flex items-center shrink-0",children:[(0,t.jsx)("button",{onClick:O,disabled:null!==I,className:(0,N.cn)("flex items-center justify-center min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0 sm:p-1.5 rounded transition-colors","text-gray-400 dark:text-white/40 hover:text-gray-700 dark:hover:text-white/80 hover:bg-gray-100 dark:hover:bg-white/[0.06]",null!==I&&"opacity-50 cursor-not-allowed"),title:b.active?"Pause":"Resume",children:"toggle"===I?(0,t.jsx)(en.Loader2,{className:"w-3.5 h-3.5 animate-spin"}):b.active?(0,t.jsx)(e4.Pause,{className:"w-3.5 h-3.5"}):(0,t.jsx)(e3.Play,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("button",{onClick:F,disabled:null!==I,className:(0,N.cn)("flex items-center justify-center min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0 sm:p-1.5 rounded transition-colors","text-gray-400 dark:text-white/40 hover:text-gray-700 dark:hover:text-white/80 hover:bg-gray-100 dark:hover:bg-white/[0.06]",null!==I&&"opacity-50 cursor-not-allowed"),title:"Edit recurrence",children:(0,t.jsx)(et.Pencil,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("button",{onClick:()=>P(!0),disabled:null!==I,className:(0,N.cn)("flex items-center justify-center min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0 sm:p-1.5 rounded transition-colors","text-gray-400 dark:text-white/40 hover:text-red-400 hover:bg-red-500/10",null!==I&&"opacity-50 cursor-not-allowed"),title:"Stop repeating",children:"cancel"===I?(0,t.jsx)(en.Loader2,{className:"w-3.5 h-3.5 animate-spin"}):(0,t.jsx)(r.X,{className:"w-3.5 h-3.5"})})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 mt-1.5 text-[11px] text-gray-400 dark:text-white/40",children:[B&&(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)(e6.CalendarClock,{className:"w-3 h-3"}),"Next: ",B]}),(0,t.jsxs)("span",{children:[b.occurrencesCreated," occurrence",1!==b.occurrencesCreated?"s":""," created"]}),q&&(0,t.jsxs)("span",{children:["Ends ",q]})]}),_&&(0,t.jsxs)("div",{className:"text-xs text-red-400 mt-2",children:[(0,t.jsx)("span",{children:_.error}),_.fix&&(0,t.jsx)("span",{className:"block text-red-300/70 mt-0.5",children:_.fix})]})]})}):x?(0,t.jsxs)("div",{className:"text-xs text-red-400",children:[(0,t.jsx)("span",{children:x.message}),x.fix&&(0,t.jsx)("span",{className:"block text-red-300/70 mt-0.5",children:x.fix})]}):i?(0,t.jsxs)("button",{onClick:F,className:(0,N.cn)("w-full min-h-[44px] sm:min-h-0 px-3 py-2 rounded-md","bg-gray-50 dark:bg-white/[0.03] hover:bg-gray-100 dark:hover:bg-white/[0.05]","border border-gray-200 dark:border-white/[0.08]","text-gray-500 dark:text-white/60 hover:text-gray-700 dark:hover:text-white","transition-colors flex items-center justify-center gap-2"),children:[(0,t.jsx)(e5.Repeat,{className:"w-4 h-4"}),(0,t.jsx)("span",{className:"text-sm",children:"Make recurring"})]}):null,(0,t.jsx)(el.AlertDialog,{open:D,onOpenChange:e=>{e||P(!1)},children:(0,t.jsxs)(el.AlertDialogContent,{className:"bg-[#141414] border-white/[0.1] z-[200]",children:[(0,t.jsxs)(el.AlertDialogHeader,{children:[(0,t.jsx)(el.AlertDialogTitle,{className:"text-white",children:"Stop repeating"}),(0,t.jsx)(el.AlertDialogDescription,{className:"text-white/60",children:"Future occurrences will no longer be created. E
58xisting tasks stay."})]}),(0,t.jsxs)(el.AlertDialogFooter,{children:[(0,t.jsx)(el.AlertDialogCancel,{className:"bg-white/[0.05] border-white/[0.1] text-white hover:bg-white/[0.1]",children:"Keep repeating"}),(0,t.jsx)(el.AlertDialogAction,{onClick:e=>{e.preventDefault(),U()},disabled:"cancel"===I,className:"bg-red-500/10 text-red-400 hover:bg-red-500/20 border border-red-500/20",children:"cancel"===I?(0,t.jsx)(en.Loader2,{className:"w-4 h-4 animate-spin"}):"Stop repeating"})]})]})})]})}],410839);var tt=e.i(82735),ta=e.i(536468),tr=e.i(562710);let ts=["comment","text_only","voice"],ti=e=>{try{let[t,a]=e.split("T"),[r,s,i]=t.split("-"),[n,l]=a.split(":"),o=["January","February","March","April","May","June","July","August","September","October","November","December"][parseInt(s)-1],d=parseInt(n);return`${o} ${parseInt(i)}, ${r} at ${d%12||12}:${l} ${d>=12?"PM":"AM"}`}catch(t){return console.error("[TaskTimeline] Error formatting date:",t),e}};function tn(){return(0,t.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,t.jsx)("div",{className:"w-1.5 h-1.5 rounded-full bg-white/40 animate-bounce",style:{animationDelay:"0ms"}}),(0,t.jsx)("div",{className:"w-1.5 h-1.5 rounded-full bg-white/40 animate-bounce",style:{animationDelay:"150ms"}}),(0,t.jsx)("div",{className:"w-1.5 h-1.5 rounded-full bg-white/40 animate-bounce",style:{animationDelay:"300ms"}})]})}e.s(["TaskTimeline",0,function({events:e=[],typingUsers:r=[]}){let{users:{users:s}}=(0,P.useCustomer)(),[i,n]=(0,a.useState)(!1),[l,o]=(0,a.useState)("comments"),[d,c]=(0,a.useState)(new Map),m=(0,O.useTranslations)(),u=e||[],h="all"===l?u:u.filter(e=>{var t;return!!(t=e.type)&&ts.includes(t)}),x=i?h:h.slice(0,5),g=h.length>5,p=e=>e?e.split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2):"?";return(0,t.jsxs)("div",{className:"p-4 border-b border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-gray-900 dark:text-white mb-4",children:m.tasks.timeline.title}),(0,t.jsxs)("div",{className:"space-y-4",children:[r?.length>0&&(0,t.jsx)("div",{className:"flex-1 bg-white dark:bg-white/[0.02] rounded-lg p-3",children:(0,t.jsx)("div",{className:"flex items-start justify-between",children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("div",{className:"flex -space-x-2",children:r.slice(0,3).map(e=>(0,t.jsxs)(D.Avatar,{className:"h-6 w-6 border-2 border-white dark:border-[#18181A]",children:[(0,t.jsx)(D.AvatarImage,{src:e.avatar,alt:e.name}),(0,t.jsx)(D.AvatarFallback,{className:"bg-gray-50 dark:bg-white/5 text-xs",title:e.name,children:p(e.name)})]},e.id))}),(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)("span",{className:"text-sm text-gray-600 dark:text-white/80",children:1===r.length?`${r[0].name} is typing...`:`${r.length} people are typing...`}),(0,t.jsx)(tn,{})]})]})})}),u.length>0&&(0,t.jsx)("div",{className:"flex items-center gap-1 pb-1",children:["comments","all"].map(e=>(0,t.jsx)("button",{type:"button",onClick:()=>{o(e),n(!1)},className:(0,N.cn)("px-2 py-0.5 rounded-md text-xs transition-colors",l===e?"bg-gray-100 text-gray-700 dark:bg-white/10 dark:text-white/80":"text-gray-400 hover:text-gray-600 dark:text-white/40 dark:hover:text-white/60"),children:"comments"===e?"Comments":"All"},e))}),h.length>0?(0,t.jsxs)(t.Fragment,{children:[x.map(e=>(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between",children:[(e=>{if("00000000-0000-0000-0000-000000000000"===e.created_by||"vanio_ai"===e.created_by||e.metadata?.aiGenerated)return(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)(D.Avatar,{className:"h-6 w-6",children:[(0,t.jsx)(D.AvatarImage,{src:"/Vanio.ai.png",alt:"Vanio AI"}),(0,t.jsx)(D.AvatarFallback,{className:"bg-gray-50 dark:bg-white/5 text-xs",children:"VA"})]}),(0,t.jsx)("div",{className:"flex flex-col",children:(0,t.jsx)("span",{className:"text-sm text-gray-600 dark:text-white/80",children:"Vanio AI"})})]});if("system"===e.created_by)return(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)(D.Avatar,{className:"h-6 w-6",children:[(0,t.jsx)(D.AvatarImage,{src:"/Vanio.ai.png",alt:"
58Vanio AI"}),(0,t.jsx)(D.AvatarFallback,{className:"bg-gray-50 dark:bg-white/5 text-xs",children:"VA"})]}),(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)("span",{className:"text-sm text-gray-600 dark:text-white/80",children:m.tasks.timeline.user.system}),e.user_role&&(0,t.jsx)("span",{className:"text-xs text-gray-400 dark:text-white/40",children:e.user_role})]})]});let a=s.find(t=>t.id===e.created_by),r=d.get(e.created_by),i=a?.name||r?.name||e.user_name||m.tasks.timeline.user.unknown,n=a?.roles?.[0]||r?.role||e.user_role,l=a?.image||a?.avatar||r?.avatar;if(!a&&!r&&e.user_name){let t={name:e.user_name,role:e.user_role||void 0,avatar:void 0};c(a=>new Map(a).set(e.created_by,t))}let o=e.metadata?.channel==="sms"||e.metadata?.source==="operations-sms";return(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)(D.Avatar,{className:"h-6 w-6",children:[(0,t.jsx)(D.AvatarImage,{src:l||"",alt:i}),(0,t.jsx)(D.AvatarFallback,{className:"bg-gray-50 dark:bg-white/5 text-xs",children:p(i)})]}),(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-sm text-gray-600 dark:text-white/80",children:i}),o&&(0,t.jsx)("span",{className:"text-[9px] px-1 py-0.5 rounded bg-green-500/10 text-green-500 font-medium",children:"SMS"})]}),n&&(0,t.jsx)("span",{className:"text-xs text-gray-400 dark:text-white/40",children:n})]})]})})(e),(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs text-gray-400 dark:text-white/40",children:[(0,t.jsx)(f.Clock,{className:"w-3 h-3"}),(0,t.jsx)("span",{children:(e=>{if(!e)return m.tasks.timeline.time.unknownDate;try{let t=new Date(e);if(isNaN(t.getTime()))return m.tasks.timeline.time.invalidDate;return(0,eP.formatDistanceToNow)(t,{addSuffix:!0})}catch(e){return console.error("[TaskTimeline] Error formatting date:",e),m.tasks.timeline.time.invalidDate}})(e.created_at)})]})]}),((e,a,r=[])=>{let s=(e,r,s,i=!0,n)=>r?.startsWith("audio/")||e.match(/\.(mp3|wav|webm|ogg|m4a)$/i)?(0,t.jsx)(eg.VoiceNotePlayer,{url:e,variant:"timeline",showRemove:!1,showExternalLink:!1,className:"mt-2 min-w-[100px]",metadata:n,transcription:n?.transcription,originalTranscription:n?.originalTranscription}):r?.startsWith("video/")||e.match(/\.(mp4|webm|ogg|mov|avi)$/i)?(0,t.jsx)(ta.VideoPlayer,{url:e,variant:"timeline",showRemove:!1,className:"mt-2"}):r?.startsWith("image/")||e.match(/\.(jpg|jpeg|png|gif|webp|svg)$/i)?(0,t.jsx)("div",{className:"mt-2",children:(0,t.jsxs)("div",{className:(0,N.cn)("rounded-lg overflow-hidden bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.06]",i&&"max-w-[200px]"),children:[(0,t.jsx)("img",{src:e,alt:a.tasks.timeline.attachments.viewExternal,className:(0,N.cn)("w-full h-auto object-cover",i?"max-h-[150px]":"max-h-[120px]")}),(0,t.jsx)("div",{className:"flex items-center justify-end p-2 border-t border-gray-200 dark:border-white/[0.06]",children:(0,t.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"p-1.5 rounded-md hover:bg-gray-100 dark:hover:bg-white/[0.08] text-gray-400 dark:text-white/40 hover:text-gray-600 dark:hover:text-white/70 transition-colors",title:a.tasks.timeline.attachments.viewExternal,children:(0,t.jsx)(eV.ExternalLink,{className:"w-4 h-4"})})})]})}):(0,t.jsxs)("div",{className:"flex items-start gap-3 p-3 mt-2 rounded-lg bg-white dark:bg-white/[0.03] border border-gray-200 dark:border-white/[0.06]",children:[(0,t.jsx)("div",{className:"w-12 h-12 rounded-md bg-white dark:bg-white/[0.02] flex items-center justify-center",children:(0,t.jsx)(tt.Paperclip,{className:"w-6 h-6 text-gray-400 dark:text-white/40"})}),(0,t.jsx)("div",{className:"flex-1 min-w-0",children:s&&(0,t.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/40 mt-0.5",children:((e,t)=>{if(!e)return`0 ${t.tasks.timeline.attachments.units.B}`;let a=Math.floor(Math.log(e)/Math.log(1024)),r=parseFloat((e/Math.pow(1024,a)).toFixed(1)).toString();return t.tasks.timeline.attachments.size.replace("{size}",r).replace("{unit}",t.tasks.timeline.attachments.units[["B","KB","MB","GB"][a]])})(s,a)})}),(0,t.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-md hover:bg-gray-100 dark:hover:bg-white/[0.08] text-gray-400 dark:text-white/40 hover:text-gray-600 dark:hover:text-white/70 transition-colors",title:a.tasks.timeline.attachments.viewExternal,children:(0,t.jsx)(eV.Exter
58nalLink,{className:"w-4 h-4"})})]});if("task_completed"===e.type||"completion"===e.type||"task_reopened"===e.type||"task_blocked"===e.type||"task_started"===e.type||"task_created"===e.type){let r;if("task_started"===e.type)r="in_progress";else if("completion"===e.type||"task_completed"===e.type)r="completed";else{if("task_created"===e.type)return(0,t.jsx)("div",{className:"mt-2 text-sm text-gray-500 dark:text-white/60",children:e.description});r=e.type.replace("task_","")}return(0,t.jsx)("div",{className:"mt-2 text-sm text-gray-500 dark:text-white/60",children:a.tasks.timeline.updates.status[r]})}if("text_only"===e.type||"comment"===e.type){let r,i=!!(e.metadata?.originalText||e.metadata?.translatedText),n=e.metadata?.originalText||e.description;e.metadata?.translatedText||e.description;let l=(e.description||"").replace(/^\[SMS[^\]]*\]\s*/i,"").split(/(@\[.*?\]\(.*?\)|@\w+)/g);return(0,t.jsxs)("div",{className:"mt-2",children:[(0,t.jsx)("div",{className:"text-sm text-gray-500 dark:text-white/60",children:l.map((e,r)=>{let s=e.match(/@\[(.*?)\]\((.*?)\)/),i=e.match(/@(\w+)/);if(s){let[e,i,n]=s;return(0,t.jsxs)(tr.Tooltip,{children:[(0,t.jsx)(tr.TooltipTrigger,{asChild:!0,children:(0,t.jsxs)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded-md bg-amber-500/20 text-amber-400 hover:bg-amber-500/30 transition-colors cursor-pointer font-medium",children:["@",i]})}),(0,t.jsx)(tr.TooltipContent,{children:(0,t.jsx)("p",{className:"text-sm",children:a.tasks.timeline.user.viewProfile.replace("{name}",i)})})]},`mention-${r}`)}if(i){let[e,s]=i;return(0,t.jsxs)(tr.Tooltip,{children:[(0,t.jsx)(tr.TooltipTrigger,{asChild:!0,children:(0,t.jsxs)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded-md bg-amber-500/20 text-amber-400 hover:bg-amber-500/30 transition-colors cursor-pointer font-medium",children:["@",s]})}),(0,t.jsx)(tr.TooltipContent,{children:(0,t.jsx)("p",{className:"text-sm",children:a.tasks.timeline.user.viewProfile.replace("{name}",s)})})]},`mention-${r}`)}return(0,t.jsx)("span",{children:(0,ef.linkifyText)(e)},r)})}),i&&(0,t.jsxs)("div",{className:"mt-1.5 pl-2 border-l-2 border-gray-200 dark:border-white/10",children:[(0,t.jsxs)("div",{className:"text-[11px] text-gray-400 dark:text-white/30 mb-0.5",children:["Original (",e.metadata?.originalLanguage||"unknown",")"]}),(0,t.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/40 italic",children:n.split(/(@\[.*?\]\(.*?\)|@\w+)/g).map((e,a)=>{let r=e.match(/@\[(.*?)\]\((.*?)\)/),s=e.match(/@(\w+)/);if(r){let[,e]=r;return(0,t.jsxs)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded-md bg-amber-500/20 text-amber-400 font-medium",children:["@",e]},a)}if(s){let[,e]=s;return(0,t.jsxs)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded-md bg-amber-500/20 text-amber-400 font-medium",children:["@",e]},a)}return(0,t.jsx)("span",{children:(0,ef.linkifyText)(e)},a)})})]}),"comment"===e.type&&(e.metadata?.attachment||e.metadata?.attachments)&&(0,t.jsx)(t.Fragment,{children:1===(r=e.metadata.attachments||(e.metadata.attachment?[e.metadata.attachment]:[])).length?s(r[0].url,void 0,void 0,!0,r[0].metadata):(0,t.jsx)("div",{className:"mt-2 grid grid-cols-2 md:grid-cols-3 gap-2",children:r.map((e,a)=>(0,t.jsx)("div",{children:s(e.url,void 0,void 0,!1,e.metadata)},a))})})]})}if("attachment_added"===e.type&&e.metadata?.url)return s(e.metadata.url,e.metadata.fileType,e.metadata.size,!0,e.metadata);if("task_updated"===e.type){if(e.description===a.tasks.timeline.updates.properties.generic)return(0,t.jsx)("div",{className:"mt-2 text-sm text-gray-500 dark:text-white/60",children:e.description});let r=e.metadata||{},s=[];return r.category&&s.push(a.tasks.timeline.updates.properties.category.replace("{category}",a.tasks.header.category[r.category])),r.dueDate&&s.push(a.tasks.timeline.updates.properties.dueDate.replace("{date}",ti(r.dueDate))),r.startDate&&s.push(a.tasks.timeline.updates.properties.startDate.replace("{date}",ti(r.startDate))),r.startedAt&&s.push(a.tasks.timeline.updates.properties.startedAt.replace("{date}",ti(r.startedAt))),"requiresApproval"in r&&s.push(a.tasks.timeline.updates.properties.approvalRequirement[r.requiresApproval?"enabled":"disabled"]),"requiresAcceptance"in r&&s.push(a.tasks.timeline.updates.properties.acceptanceRequirement[r.requiresAcceptance?"enabled":"disabled"]),r.approvalDeadline&&s.push(a.tasks.timeline.updates.properties.approvalDeadline.replace("{date}",ti(r.approvalDeadline))),r.acceptanceDeadline&&s.push(a.tasks.timeline.updates.properties.acceptanceDeadline.replace("{date}",ti(r.acceptanceDeadline))),r.estimatedDuration&&s.push(a.tasks.timeline.updates.properties.estimatedDuration.replace("{duration}",r.estimatedDuration.toString())),(0,t.jsx)("div",{className:"mt-2 text-sm text-gray-500 dark:text-white/60",children:`Updated task ${s.join(", ")}`})}if("checklist_template_applied"===e.type)return(0,t.jsx)("div",{className:"mt-2 text-sm text-gray-500 dark:text-white/60",children:a.tasks.timeline.updates.checklist.templateApplied.replace("{title}",e.metadata?.templateTitle||"")});if("checklist_item_created"===e.type)return(0,t.jsxs)("div",{className:"mt-2 text-sm text-gray-500 dark:text-white/60",children:[a.tasks.timeline.updates.checklist.itemCreated.replace("{title}",e.metadata?.title||""),e.metadata?.notes&&(0,t.jsx)("div",{className:"mt-1 text-gray-400 dark:text-white/40",children:e.metadata.notes})]});if("checklist_item_deleted"===e.type)return(0,t.jsx)("div",{className:"mt-2 text-sm text-gray-500 dark:text-white/60",children:a.tasks.timeline.updates.checklist.itemDeleted.replace("{title}",e.metadata?.title||"")});if(e.type.startsWith("subtask_")){let r=e.type.replace("subtask_","");if(r in a.tasks.timeline.updates.subtasks){let s=e.description.replace(`Subtask ${r}: `,"")||e.metadata?.title||"Unknown subtask";return(0,t.jsx)("div",{className:"mt-2 text-sm text-gray-500 dark:text-white/60",children:a.tasks.timeline.updates.subtasks[r].replace("{title}",s)})}}if("checklist_update"===e.type){let r=e.metadata?.completed,s=e.metadata?.title||"";return(0,t.jsx)("div",{className:"mt-2 text-sm text-gray-500 dark:text-white/60",children:r?a.tasks.timeline.updates.checklist.itemCompleted.replace("{title}",s):a.tasks.timeline.updates.checklist.itemUncompleted.replace("{title}",s)})}if("assignment_updated"===e.type){let s=function(e,t=[]){let a=e.metadata?.assigneeName;if(a&&"string"==typeof a)return a;let r=(e.description||"").replace(/^Task assigned to\s+/i,"").replace(/\s*\(.*\)\s*$/,"").trim();if(!r)return"Unknown";if(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(r)){let e=t.find(e=>e.id===r);return e?.name||r}return r}(e,r);return(0,t.jsx)("div",{className:"mt-2 text-sm text-gray-500 dark:text-white/60",children:a.tasks.timeline.updates.assignment.updated.replace("{name}",s)})}if("claim"===e.type){let r=e.metadata?.priorityLevel;if(e.metadata?.requiresApproval)return(0,t.jsx)("div",{className:"mt-2 text-sm text-gray-500 dark:text-white/60",children:a.tasks.timeline.updates.marketplace.claim.requiresApproval});if(r&&"marketplace"!==r){let e=a.tasks.timeline.updates.marketplace.claim.priority[r];return(0,t.jsx)("div",{className:"mt-2 text-sm text-gray-500 dark:text-white/60",children:a.tasks.timeline.updates.marketplace.claim.withPriority.replace("{priority}",e)})}return(0,t.jsx)("div",{className:"mt-2 text-sm text-gray-500 dark:text-white/60",children:a.tasks.timeline.updates.marketplace.claim.success})}if("bid_submitted"===e.type){let r=e.metadata?.amount||0,s=e.metadata?.currency||"USD";return(0,t.jsx)("div",{className:"mt-2 text-sm text-gray-500 dark:text-white/60",children:a.tasks.timeline.updates.marketplace.bid.submitted.replace("{amount}",r.toString()).replace("{currency}",s)})}if("bid_accepted"===e.type){let r=e.metadata?.amount||0,s=e.metadata?.currency||"USD";return(0,t.jsx)("div",{className:"mt-2 text-sm text-gray-500 dark:text-white/60",children:a.tasks.timeline.updates.marketplace.bid.accepted.replace("{amount}",r.toString()).replace("{currency}",s)})}if("bid_rejected"===e.type){let r=e.metadata?.amount||0,s=e.metadata?.currency||"USD",i=e.metadata?.reason;return(0,t.jsx)("div",{className:"mt-2 text-sm text-gray-500 dark:text-white/60",children:i?a.tasks.timeline.updates.marketplace.bid.withReason.replace("{amount}",r.toString()).replace("{currency}",s).replace("{reason}",i):a.tasks.timeline.updates.marketplace.bid.rejected.replace("{amount}",r.toString()).replace("{currency}",s)})}if("release"===e.type){let r=e.metadata?.reason;return(0,t.jsx)("div",{className:"mt-2 text-sm text-gray-500 dark:text-white/60",children:r?a.tasks.timeline.updates.marketplace.release.withReason.replace("{reason}",r):a.tasks.timeline.updates.marketplace.release.success})}if("bid_withdrawn"===e.type)return(0,t.jsx)("div",{className:"mt-2 text-sm text-gray-500 dark:text-white/60",children:"Bid withdrawn by provider"});if("marketplace_eligibility"===e.type)return(0,t.jsx)("div",{className:"mt-2 text-sm text-gray-500 dark:text-white/60",children:"Task made eligible for marketplace"});if("escalation_created"===e.type){let a=e.metadata?.reason||"";return(0,t.jsxs)("div",{className:"mt-2 text-sm text-gray-500 dark:text-white/60",children:["Escalation created: ",a]})}if("escalation_rules_updated"===e.type)return(0,t.jsx)("div",{className:"mt-2 text-sm text-gray-500 dark:text-white/60",children:"Escalation rules updated"});if("escalation_resolved"===e.type){let a=e.metadata?.resolution||"";return(0,t.jsxs)("div",{className:"mt-2 text-sm text-gray-500 dark:text-white/60",children:["Escalation resolved: ",a]})}return e.description?(0,t.jsx)("div",{className:"mt-2 text-sm text-gray-500 dark:text-white/60",children:e.description}):null})(e,m,s)]},e.id)),g&&(0,t.jsx)("div",{className:"pt-2 text-center",children:(0,t.jsx)("button",{onClick:()=>n(!i),className:(0,N.cn)("text-xs text-gray-400 dark:text-white/40 hover:text-gray-500 dark:hover:text-white/60","transition-colors","flex items-center gap-1 mx-auto"),children:i?m.tasks.timeline.showMore.collapse:m.tasks.timeline.showMore.expand.replace("{count}",String(u.length-5)).replace("{count, plural, one {message} other {messages}}",u.length-5==1?"message":"messages")})})]}):(0,t.jsx)("p",{className:"text-sm text-gray-400 dark:text-white/40",children:m.tasks.timeline.empty})]})]})}],673811),e.s(["TaskProgress",0,function({task:e}){let a=(0,O.useTranslations)(),r=e.checklist||[],s=r.length,i=r.filter(e=>e.completed).length,n=s>0?Math.round(i/s*100):0;return s?(0,t.jsxs)("div",{className:"px-4 py-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between text-xs text-gray-500 dark:text-white/50 mb-1",children:[(0,t.jsx)("span",{children:a.tasks.progress.title}),(0,t.jsx)("span",{children:a.tasks.checklist.progress.counter.replace("{completed}",String(i)).replace("{total}",String(s))})]}),(0,t.jsx)("div",{className:"h-1 bg-gray-50 dark:bg-white/[0.05] rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:"h-full bg-green-500 transition-all duration-300",style:{width:`${n}%`}})})]}):null}],37020);var tl=e.i(846932),to=e.i(88653),td=e.i(25652),tc=e.i(284614),tm=e.i(269638),tu=e.i(373884),th=e.i(63727);function tx({task:e,onUpdate:r,canEdit:s,canEditStructure:i}
58){let[n,l]=(0,a.useState)(null),[o,d]=(0,a.useState)(null),[c,m]=(0,a.useState)({}),u=e?.bids||[];(0,a.useEffect)(()=>{e?.id&&0!==u.length&&0!==u.filter(e=>"pending"===e.status).length&&fetch(`https://api.vanio.ai/tasks/marketplace/bids/workload?taskId=${e.id}`,{credentials:"include"}).then(e=>e.ok?e.json():null).then(e=>{e?.workloads&&m(e.workloads)}).catch(()=>{})},[e?.id,u.length]);let h=async t=>{if(i){d(t);try{if(!(await fetch("/api/tasks/marketplace/bids",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"accept",taskId:e.id,bidId:t})})).ok)throw Error("Failed to accept bid");await r()}catch(e){console.error("Error accepting bid:",e)}finally{d(null)}}},x=async(t,a)=>{if(i){d(t);try{if(!(await fetch("/api/tasks/marketplace/bids",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"reject",taskId:e.id,bidId:t,reason:a})})).ok)throw Error("Failed to reject bid");await r()}catch(e){console.error("Error rejecting bid:",e)}finally{d(null)}}},g=(e,t="USD")=>new Intl.NumberFormat("en-US",{style:"currency",currency:t,minimumFractionDigits:0,maximumFractionDigits:2}).format(e),p=e=>{switch(e){case"excessive_cleaning":return"Excessive Cleaning";case"additional_supplies":return"Additional Supplies";case"damage_repair":return"Damage Repair";case"scope_change":return"Scope Change";default:return e.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase())}};if(0===u.length)return(0,t.jsxs)("div",{className:"p-6 text-center",children:[(0,t.jsx)("div",{className:"w-16 h-16 bg-blue-500/10 rounded-full flex items-center justify-center mx-auto mb-4",children:(0,t.jsx)(eM.DollarSign,{className:"w-8 h-8 text-blue-400"})}),(0,t.jsx)("h4",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"No Bids Yet"}),(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-white/60 mb-6",children:"Service providers haven't submitted any bids for this task yet. Try inviting specific providers or adjusting the task requirements."}),(0,t.jsx)("button",{className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-gray-900 dark:text-white rounded-lg transition-colors duration-200 text-sm font-medium",children:"Invite Providers"})]});let y=[...u].sort((e,t)=>{if(e.status!==t.status){if("pending"===e.status)return -1;if("pending"===t.status)return 1;if("accepted"===e.status)return -1;if("accepted"===t.status)return 1}return e.amount-t.amount});return(0,t.jsxs)("div",{className:"p-6 space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("h4",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:["Bids (",u.length,")"]}),(0,t.jsxs)("div",{className:"text-sm text-gray-500 dark:text-white/60",children:["Range: ",g(Math.min(...u.map(e=>e.amount)),u[0]?.currency)," - ",g(Math.max(...u.map(e=>e.amount)),u[0]?.currency)]})]}),(0,t.jsx)("div",{className:"space-y-3",children:(0,t.jsx)(to.AnimatePresence,{children:y.map((e,a)=>{let r,s;return(0,t.jsxs)(tl.motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{delay:.05*a},className:(0,N.cn)("bg-white dark:bg-white/[0.02] border rounded-lg p-4 transition-all duration-200","accepted"===e.status?"border-green-500/30 bg-green-500/5":"rejected"===e.status?"border-red-500/30 bg-red-500/5":"border-gray-200 dark:border-white/[0.08] hover:border-gray-300 dark:hover:border-white/[0.15]",n===e.id&&"ring-2 ring-blue-500/50"),onClick:()=>l(n===e.id?null:e.id),children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsx)("div",{className:"w-10 h-10 bg-gray-100 dark:bg-white/[0.1] rounded-full flex items-center justify-center",children:e.provider?.avatar?(0,t.jsx)("img",{src:e.provider.avatar,alt:e.provider.name||"Provider",className:"w-10 h-10 rounded-full object-cover"}):(0,t.jsx)(tc.User,{className:"w-5 h-5 text-gray-400 dark:text-white/40"})}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("h5",{className:"font-medium text-gray-900 dark:text-white",children:e.provider?.name||"Unknown Provider"}),(0,t.jsxs)("div",{className:"flex items-center space-x-2 text-xs text-gray-500 dark:text-white/60",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,t.jsx)(ev.Star,{className:"w-3 h-3 text-yellow-400"}),(0,t.jsx)("span",{children:e.provider?.rating?.toFixed(1)||"N/A"})]}),(0,t.jsx)("span",{children:"â¢"}),(0,t.jsx)("span",{children:e.provider?.completedTasks?`${e.provider.completedTasks} completed tasks`:"No completed tasks"})]})]})]}),(r=e.original_amount&&e.original_amount!==e.amount,s=e.adjustments&&e.adjustments.some(e=>"approved"===e.status),(0,t.jsxs)("div",{className:"text-right",children:[r&&(0,t.jsxs)("div",{className:"text-sm text-gray-500 dark:text-white/50 line-through mb-1",children:["Original: ",g(e.original_amount,e.currency)]}),(0,t.jsx)("div",{className:"text-xl font-bold text-gray-900 dark:text-white",children:g(e.amount,e.currency)}),(0,t.jsx)("div",{className:"text-sm text-gray-500 dark:text-white/60",children:e.currency.toUpperCase()}),s&&(0,t.jsxs)("div",{className:"text-xs text-green-400 mt-1",children:["+",g(e.adjustments.filter(e=>"approved"===e.status).reduce((e,t)=>
58e+t.amount,0),e.currency)," added"]})]}))]}),"pending"===e.status&&c[e.provider_id]&&(0,t.jsxs)("div",{className:(0,N.cn)("flex items-center gap-2 mb-3 px-3 py-1.5 rounded-lg text-xs",c[e.provider_id].totalMinutes>=300?"bg-red-500/10 text-red-400":c[e.provider_id].totalMinutes>=240?"bg-yellow-500/10 text-yellow-400":"bg-gray-50 dark:bg-white/[0.04] text-gray-500 dark:text-white/50"),children:[(0,t.jsx)(th.Briefcase,{className:"w-3.5 h-3.5 flex-shrink-0"}),(0,t.jsxs)("span",{children:[(c[e.provider_id].totalMinutes/60).toFixed(1),"h committed today (",c[e.provider_id].taskCount," task",1!==c[e.provider_id].taskCount?"s":"",")"]}),c[e.provider_id].totalMinutes>=300&&(0,t.jsx)("span",{className:"font-medium ml-auto",children:"Over 5h cap"})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4 mb-3 text-sm",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)(f.Clock,{className:"w-4 h-4 text-gray-400 dark:text-white/40"}),(0,t.jsx)("span",{className:"text-gray-600 dark:text-white/80",children:e.estimated_duration?`${Math.floor(e.estimated_duration/60)}h ${e.estimated_duration%60}m`:"N/A"})]}),(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)(w.Calendar,{className:"w-4 h-4 text-gray-400 dark:text-white/40"}),(0,t.jsx)("span",{className:"text-gray-600 dark:text-white/80",children:new Date(e.created_at).toLocaleDateString()})]})]}),e.notes&&(0,t.jsx)("div",{className:"mb-3",children:(0,t.jsx)("p",{className:"text-sm text-gray-600 dark:text-white/80 bg-white dark:bg-white/[0.02] rounded p-2",children:e.notes})}),(e=>{if(!e.adjustments||0===e.adjustments.length)return null;let a=e.adjustments.filter(e=>"approved"===e.status),r=e.adjustments.filter(e=>"pending"===e.status),s=e.adjustments.filter(e=>"rejected"===e.status);return(0,t.jsxs)("div",{className:"mt-3 pt-3 border-t border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,t.jsx)(b.AlertTriangle,{className:"w-4 h-4 text-yellow-400"}),(0,t.jsx)("span",{className:"text-sm font-medium text-gray-600 dark:text-white/70",children:"Adjustments"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[a.map(a=>(0,t.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(j.Plus,{className:"w-3 h-3 text-green-400"}),(0,t.jsx)("span",{className:"text-gray-500 dark:text-white/60",children:p(a.type)})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("span",{className:"text-green-400",children:["+",g(a.amount,e.currency)]}),(0,t.jsx)("span",{className:"text-green-400 text-xs",children:"Approved"})]})]},a.id)),r.map(a=>(0,t.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(f.Clock,{className:"w-3 h-3 text-yellow-400"}),(0,t.jsx)("span",{className:"text-gray-500 dark:text-white/60",children:p(a.type)})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("span",{className:"text-yellow-400",children:["+",g(a.amount,e.currency)]}),(0,t.jsx)("span",{className:"text-yellow-400 text-xs",children:"Pending"})]})]},a.id)),s.map(a=>(0,t.jsxs)("div",{className:"flex items-center justify-between text-sm opacity-60",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(tu.XCircle,{className:"w-3 h-3 text-red-400"}),(0,t.jsx)("span",{className:"text-gray-500 dark:text-white/60",children:p(a.type)})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("span",{className:"text-red-400 line-through",children:["+",g(a.amount,e.currency)]}),(0,t.jsx)("span",{className:"text-red-400 text-xs",children:"Rejected"})]})]},a.id))]})]})})(e),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:["accepted"===e.status&&(0,t.jsxs)("div",{className:"flex items-center space-x-1 px-2 py-1 bg-green-500/10 text-green-400 rounded-full text-xs",children:[(0,t.jsx)(tm.CheckCircle,{className:"w-3 h-3"}),(0,t.jsx)("span",{children:"Accepted"})]}),"rejected"===e.status&&(0,t.jsxs)("div",{className:"flex items-center space-x-1 px-2 py-1 bg-red-500/10 text-red-400 rounded-full text-xs",children:[(0,t.jsx)(tu.XCircle,{className:"w-3 h-3"}),(0,t.jsx)("span",{children:"Rejected"})]}),"pending"===e.status&&(0,t.jsxs)("div",{className:"flex items-center space-x-1 px-2 py-1 bg-yellow-500/10 text-yellow-400 rounded-full text-xs",children:[(0,t.jsx)(f.Clock,{className:"w-3 h-3"}),(0,t.jsx)("span",{children:"Pending"})]})]}),"pending"===e.status&&i&&(0,t.jsxs)("div",{className:"flex space-x-2",children:[(0,t.jsx)("button",{onClick:t=>{t.stopPropagation(),x(e.id)},disabled:o===e.id,className:"px-3 py-1 bg-red-600/20 hover:bg-red-600/30 text-red-400 rounded text-xs font-medium transition-colors duration-200 disabled:opacity-50",children:"Reject"}),(0,t.jsx)("button",{onClick:t=>{t.stopPropagation(),h(e.id)},disabled:o===e.id,className:"px-3 py-1 bg-green-600/20 hover:bg-green-600/30 text-green-400 rounded text-xs font-medium transition-colors duration-200 disabled:opacity-50",children:o===e.id?"Processing...":"Accept"})]})]}),(0,t.jsx)(to.AnimatePresence,{children:n===e.id&&(0,t.jsx)(tl.motion.div,{initial:{opacity:0,height:0}
58,animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2},className:"mt-4 pt-4 border-t border-gray-200 dark:border-white/[0.08]",children:(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h6",{className:"font-medium text-gray-900 dark:text-white mb-2",children:"Provider Skills"}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-1",children:[e.provider?.skills?.slice(0,3).map((e,a)=>(0,t.jsx)("span",{className:"px-2 py-1 bg-blue-500/10 text-blue-400 rounded text-xs",children:"string"==typeof e?e:e?.name||"Unknown"},`skill-${a}`)),(e.provider?.skills?.length||0)>3&&(0,t.jsxs)("span",{className:"px-2 py-1 bg-gray-50 dark:bg-white/[0.05] text-gray-500 dark:text-white/60 rounded text-xs",children:["+",(e.provider?.skills?.length||0)-3," more"]})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h6",{className:"font-medium text-gray-900 dark:text-white mb-2",children:"Service Areas"}),(0,t.jsx)("div",{className:"text-gray-500 dark:text-white/60 text-xs",children:Array.isArray(e.provider?.serviceAreas)&&(e.provider?.serviceAreas?.length||0)>0?(()=>{var t;let a=e.provider.serviceAreas;if(0===a.length)return"No service areas specified";let r="string"==typeof(t=a[0])?t.split(",")[0].trim():"object"==typeof t&&null!==t?(t.name||t.area_name||"Unknown area").split(",")[0].trim():"Unknown area",s=a.length-1;return s>0?`${r} (+${s} more)`:r})():"No service areas specified"})]})]})})})]},e.id)})})})]})}var tg=e.i(346897),tp=e.i(514764),tb=e.i(797548);let tf=async e=>{let t=await fetch(e);if(!t.ok)throw Error("Failed to fetch providers");return t.json()};function ty({task:e,onUpdate:r,canEdit:s,canEditStructure:i}){let[n,l]=(0,a.useState)(""),[o,d]=(0,a.useState)([]),[m,u]=(0,a.useState)(!1),[h,x]=(0,a.useState)(!1),[p,b]=(0,a.useState)({minRating:0,skills:[],availability:"any"}),y=(0,a.useMemo)(()=>{let t=e?.id,a=e?.category||"";return(console.log("[TaskProviderMatching] Task data:",e),console.log("[TaskProviderMatching] SWR Key calculation:",{taskId:t,category:a,taskData:{id:e?.id,category:e?.category,location:e?.location,relations:e?.relations,metadata:e?.metadata}}),t&&"number"==typeof t)?console.log("[TaskProviderMatching] Provider matching temporarily disabled - location data needs to be properly configured in backend"):console.log("[TaskProviderMatching] No valid task ID, skipping API call",{taskId:t}),null},[e?.id,e?.category,e?.relations,e?.metadata,e?.location]),{data:w,error:v,mutate:k,isLoading:j,isValidating:C}=(0,e2.default)(y,tf,{revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,dedupingInterval:3e5,errorRetryCount:1,errorRetryInterval:5e3,isPaused:()=>!y}),S=w?.providers||[],E=w?.total||0,I=S.filter(e=>{if(n){let t=n.toLowerCase(),a=e.userDetails?.name?.toLowerCase().includes(t),r=e.skills.some(e=>e.toLowerCase().includes(t));if(!a&&!r)return!1}return(!(p.minRating>0)||!(e.rating<p.minRating))&&(!(p.skills.length>0)||!!p.skills.every(t=>e.skills.includes(t)))&&!0}),T=async()=>{if(i&&0!==o.length){u(!0);try{if(!(await fetch("/api/tasks/marketplace/providers/invite",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:e.id,providerIds:o})})).ok)throw Error("Failed to invite providers");d([]),await r()}catch(e){console.error("Error inviting providers:",e)}finally{u(!1)}}},_=()=>{k()};return v?(0,t.jsxs)("div",{className:"p-6 text-center",children:[(0,t.jsx)("div",{className:"w-16 h-16 bg-red-500/10 rounded-full flex items-center justify-center mx-auto mb-4",children:(0,t.jsx)(eD.Users,{className:"w-8 h-8 text-red-400"})}),(0,t.jsx)("h4",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Failed to Load Providers"}),(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-white/60 mb-4",children:"There was an error loading the provider list. Please try again."}),(0,t.jsx)("button",{onClick:_,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-gray-900 dark:text-white rounded-lg transition-colors duration-200 text-sm font-medium",children:"Try Again"})]}):j&&!w?(0,t.jsxs)("div",{className:"p-6 space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("div",{className:"h-6 bg-gray-100 dark:bg-white/[0.1] rounded w-40 animate-pulse"}),(0,t.jsx)("div",{className:"w-8 h-8 bg-gray-100 dark:bg-white/[0.1] rounded-lg animate-pulse"})]}),(0,t.jsx)("div",{className:"h-10 bg-gray-50 dark:bg-white/[0.05] border border-gray-200 dark:border-white/[0.1] rounded-lg animate-pulse"}),(0,t.jsxs)("div",{className:"text-center py-6",children:[(0,t.jsx)("div",{className:"w-12 h-12 border-2 border-gray-300 dark:border-white/20 border-t-blue-400 rounded-full animate-spin mx-auto mb-4"}),(0,t.jsx)("h4",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Finding Providers"}),(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-white/60",children:"Searching for qualified service providers in your area..."})]}),(0,t.jsx)(()=>(0,t.jsx)("div",{className:"space-y-3",children:[void 0,void 0,void 0].map((e,a)=>(0,t.jsx)("div",{className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-4 animate-pulse",children:(0,t.jsxs)("div",{className:"flex items-center space-x-3 mb-3",children:[(0,t.jsx)("div",{className:"w-12 h-12 bg-gray-100 dark:bg-white/[0.1] rounded-full"}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("div",{className:"h-4 bg-gray-100 dark:bg-white/[0.1] rounded w-32 mb-2"}),(0,t.jsx)("div",{className:"h-3 bg-gray-100 dark:bg-white/[0.1] rounded w-24 mb-2"}),(0,t.jsxs)("div",{className:"flex space-x-2",children:[(0,t.jsx)("div",{className:"h-5 bg-gray-100 dark:bg-white/[0.1] rounded w-16"}),(0,t.jsx)("div",{className:"h-5 bg-gray-100 dark:bg-white/[0.1] rounded w-20"}),(0,t.jsx)("div",{className:"h-5 bg-gray-100 dark:bg-white/[0.1] rounded w-14"})]})]})]})},a))}),{})]}):(0,t.jsxs)("div",{className:"p-6 space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsxs)("h4",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:["Find Providers (",
58E,")"]}),C&&(0,t.jsx)("div",{className:"w-4 h-4 border border-gray-300 dark:border-white/20 border-t-blue-400 rounded-full animate-spin"})]}),(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)("button",{onClick:_,disabled:C,className:(0,N.cn)("p-2 rounded-lg transition-colors duration-200",C?"bg-gray-50 dark:bg-white/[0.05] text-gray-400 dark:text-white/40 cursor-not-allowed":"bg-gray-100 dark:bg-white/[0.1] text-gray-500 dark:text-white/60 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-white/[0.15]"),title:"Refresh providers",children:(0,t.jsx)(c.RefreshCw,{className:(0,N.cn)("w-4 h-4",C&&"animate-spin")})}),(0,t.jsx)("button",{onClick:()=>x(!h),className:(0,N.cn)("p-2 rounded-lg transition-colors duration-200",h?"bg-blue-600 text-gray-900 dark:text-white":"bg-gray-100 dark:bg-white/[0.1] text-gray-500 dark:text-white/60 hover:text-gray-900 dark:hover:text-white"),children:(0,t.jsx)(tb.Filter,{className:"w-4 h-4"})})]})]}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(g.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-white/40"}),(0,t.jsx)("input",{type:"text",placeholder:"Search providers by name or skills...",value:n,onChange:e=>l(e.target.value),className:"w-full pl-10 pr-4 py-2 bg-gray-50 dark:bg-white/[0.05] border border-gray-200 dark:border-white/[0.1] rounded-lg text-gray-900 dark:text-white placeholder-white/40 focus:outline-none focus:border-blue-500"})]}),(0,t.jsx)(to.AnimatePresence,{children:h&&(0,t.jsx)(tl.motion.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2},className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-4 space-y-4",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm font-medium text-gray-900 dark:text-white mb-2",children:"Minimum Rating"}),(0,t.jsxs)("select",{value:p.minRating,onChange:e=>b(t=>({...t,minRating:Number(e.target.value)})),className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.05] border border-gray-200 dark:border-white/[0.1] rounded-lg text-gray-900 dark:text-white focus:outline-none focus:border-blue-500",children:[(0,t.jsx)("option",{value:0,children:"Any rating"}),(0,t.jsx)("option",{value:3,children:"3+ stars"}),(0,t.jsx)("option",{value:4,children:"4+ stars"}),(0,t.jsx)("option",{value:4.5,children:"4.5+ stars"})]})]})})}),o.length>0&&(0,t.jsxs)("div",{className:"flex items-center justify-between bg-blue-500/10 border border-blue-500/30 rounded-lg p-3",children:[(0,t.jsxs)("span",{className:"text-blue-400 text-sm",children:[o.length," provider",1!==o.length?"s":""," selected"]}),(0,t.jsxs)("div",{className:"flex space-x-2",children:[(0,t.jsx)("button",{onClick:()=>d([]),className:"px-3 py-1 text-blue-400 hover:text-blue-300 text-sm",children:"Clear"}),(0,t.jsxs)("button",{onClick:T,disabled:m,className:"flex items-center space-x-2 px-4 py-1 bg-blue-600 hover:bg-blue-700 text-gray-900 dark:text-white rounded text-sm font-medium transition-colors duration-200 disabled:opacity-50",children:[(0,t.jsx)(tp.Send,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:m?"Inviting...":"Invite to Bid"})]})]})]}),(0,t.jsxs)("div",{className:"space-y-3",children:[C&&w&&(0,t.jsx)("div",{className:"relative",children:(0,t.jsx)("div",{className:"absolute inset-0 bg-black/20 backdrop-blur-sm rounded-lg z-10 flex items-center justify-center",children:(0,t.jsxs)("div",{className:"flex items-center space-x-2 text-gray-600 dark:text-white/80",children:[(0,t.jsx)("div",{className:"w-4 h-4 border border-white/40 border-t-white rounded-full animate-spin"}),(0,t.jsx)("span",{className:"text-sm",children:"Updating providers..."})]})})}),0!==I.length||j?(0,t.jsx)(to.AnimatePresence,{children:I.map((e,a)=>{let r,s,n,l=o.includes(e.id);return(0,t.jsx)(tl.motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{delay:.05*a},className:(0,N.cn)("bg-white dark:bg-white/[0.02] border rounded-lg p-4 transition-all duration-200 cursor-pointer",l?"border-blue-500/50 bg-blue-500/5 ring-2 ring-blue-500/30":"border-gray-200 dark:border-white/[0.08] hover:border-gray-300 dark:hover:border-white/[0.15]"),onClick:()=>{var t;return i&&(t=e.id,void d(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t]))},children:(0,t.jsxs)("div",{className:"flex items-start justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3 flex-1",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("div",{className:"w-12 h-12 bg-gray-100 dark:bg-white/[0.1] rounded-full flex items-center justify-center",children:e.userDetails?.image?(0,t.jsx)("img",{src:e.userDetails.image,alt:e.userDetails.name,className:"w-12 h-12 rounded-full object-cover"}):(0,t.jsx)(tc.User,{className:"w-6 h-6 text-gray-500 dark:text-white/60"})}),l&&(0,t.jsx)("div",{className:"absolute -top-1 -right-1 w-5 h-5 bg-blue-500 rounded-full flex items-center justify-center",children:(0,t.jsx)(tm.CheckCircle,{className:"w-3 h-3 text-gray-900 dark:text-white"})})]}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2 mb-1",children:[(0,t.jsx)("h5",{className:"font-medium text-gray-900 dark:text-white",children:e.userDetails?.name||"Anonymous Provider"}),(0,t.jsx)("span",{className:(0,N.cn)("px-2 py-0.5 rounded-full text-xs font-medium","individual"===e.type?"bg-green-500/10 text-green-400":"bg-purple-500/10 text-purple-400"),children:e.type})]}),(0,t.jsxs)("div",{className:"flex items-center space-x-4 text-sm text-gray-500 dark:text-white/60 mb-2",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,t.jsx)(ev.Star,{className:"w-3 h-3 text-yellow-400"}),(0,t.jsx)("span",{children:e.rating.toFixed(1)})]}),(0,t.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,t.jsx)(td.TrendingUp,{className:"w-3 h-3 text-green-400"}),(0,t.jsxs)("span",{children:[e.completionRate,"% completion"]})]}),(0,t.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,t.jsx)(tg.MapPin,{className:"w-3 h-3 text-blue-400"}),(0,t.jsx)("span",{children:Array.isArray(e.serviceAreas)&&e.serviceAreas.length>0?(s="string"==typeof(r=e.serviceAreas[0])?r.split(",")[0]:r.name.split(",")[0],(n=e.serviceAreas.length-1)>0?`${s} +${n} more`:s):"No service areas"})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-1",children:[e.skills.slice(0,4).map(e=>(0,t.jsx)("span",{className:"px-2 py-0.5 bg-blue-500/10 text-blue-400 rounded text-xs",children:e},e)),e.skills.length>4&&(0,t.jsxs)("span",{className:"px-2 py-0.5 bg-gray-50 dark:bg-white/[0.05] text-gray-500 dark:text-white/60 rounded text-xs",children:["+",e.skills.length-4," more"]})]})]})]}),(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-1 text-sm text-gray-500 dark:text-white/60 mb-1",children:[(0,t.jsx)(f.Clock,{className:"w-3 h-3"}),(0,t.jsx)("span",{children:"Available"})]}),(0,t.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/40",children:"Last active: Today"})]})]})},e.id)})}):(0,t.jsxs)("div",{className:"text-center py-8",children:[(0,t.jsx)(eD.Users,{className:"w-12 h-12 text-gray-400 dark:text-white/20 mx-auto mb-4"}),(0,t.jsx)("h5",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"No Providers Found"}),(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-white/60",children:n||p.minRating>0||p.skills.length>0?"Try adjusting your search criteria or filters.":"No eligible providers found for this task location and requirements."})]})]}),S.length<E&&!j&&(0,t.jsx)("div",{className:"text-center pt-4",children:(0,t.jsx)("button",{className:"px-4 py-2 bg-gray-100 dark:bg-white/[0.1] hover:bg-gray-200 dark:hover:bg-white/[0.15] text-gray-900 dark:text-white rounded-lg transition-colors duration-200 text-sm font-medium",children:"Load More Providers"})})]})}var tw=e.i(561659),tv=e.i(972520);function tk({task:e,onUpdate:r,canEdit:s,canEditStructure:i}
58){let[n,l]=(0,a.useState)(!1),[o,d]=(0,a.useState)(!1),[m,u]=(0,a.useState)(e?.estimated_cost||0),h=e?.payments||[],x={payments:h,scheduledPayments:h.filter(e=>"scheduled"===e.status),refunds:h.filter(e=>"refunded"===e.status),releases:h.filter(e=>"released"===e.status)},g=e?.assignments?.length>0,p=e?.bids?.some(e=>"accepted"===e.status),y=e?.bids?.length>0||e?.marketplace_eligible,v=h.length>0||e?.payment_status!=="pending",j=g||p||v,C=e?.payment_status||"pending",S=(x?.payments?.length??0)>0,E=(x?.scheduledPayments?.length??0)>0,I={pending:{label:"Payment Pending",color:"text-yellow-400",bgColor:"bg-yellow-500/10",icon:f.Clock},processing:{label:"Processing Payment",color:"text-blue-400",bgColor:"bg-blue-500/10",icon:c.RefreshCw},paid:{label:"Payment Complete",color:"text-green-400",bgColor:"bg-green-500/10",icon:tm.CheckCircle},held:{label:"Payment Held",color:"text-orange-400",bgColor:"bg-orange-500/10",icon:b.AlertTriangle},refunded:{label:"Payment Refunded",color:"text-red-400",bgColor:"bg-red-500/10",icon:tu.XCircle},scheduled:{label:"Payment Scheduled",color:"text-purple-400",bgColor:"bg-purple-500/10",icon:w.Calendar}},T=I[C]||I.pending,_=T.icon,A=async()=>{if(i){l(!0);try{if(!(await fetch("/api/tasks/marketplace/payments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:e.id,amount:m,action:"process_payment"})})).ok)throw Error("Failed to process payment");await r(),d(!1)}catch(e){console.error("Error processing payment:",e)}finally{l(!1)}}},D=async t=>{if(i){l(!0);try{if(!(await fetch("/api/tasks/marketplace/payments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:e.id,amount:m,scheduleDate:t.toISOString(),action:"schedule_payment"})})).ok)throw Error("Failed to schedule payment");await r(),d(!1)}catch(e){console.error("Error scheduling payment:",e)}finally{l(!1)}}},P=async()=>{if(i){l(!0);try{if(!(await fetch("/api/tasks/marketplace/payments",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:e.id,action:"release_payment"})})).ok)throw Error("Failed to release payment");await r()}catch(e){console.error("Error releasing payment:",e)}finally{l(!1)}}};return j?(0,t.jsxs)("div",{className:"p-6 space-y-6 relative",children:[(0,t.jsx)("div",{className:"absolute inset-0 bg-black/80 backdrop-blur-sm z-50 flex items-center justify-center rounded-lg",children:(0,t.jsxs)("div",{className:"text-center p-6 bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-xl shadow-2xl max-w-sm mx-4",children:[(0,t.jsx)("div",{className:"w-16 h-16 bg-blue-100/10 rounded-full flex items-center justify-center mx-auto mb-4",children:(0,t.jsx)(eM.DollarSign,{className:"w-8 h-8 text-blue-400"})}),(0,t.jsx)("h3",{className:"text-xl font-bold text-gray-900 dark:text-white mb-2",children:"Payments Coming Soon"}),(0,t.jsx)("p",{className:"text-gray-500 dark:text-white/60 text-sm mb-4",children:"We're currently setting up our payment infrastru
58cture. Payment processing will be available shortly."}),(0,t.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/40",children:"Thank you for your patience"})]})}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsx)("div",{className:(0,N.cn)("w-10 h-10 rounded-full flex items-center justify-center",T.bgColor),children:(0,t.jsx)(_,{className:(0,N.cn)("w-5 h-5",T.color)})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h4",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:T.label}),(0,t.jsxs)("p",{className:"text-sm text-gray-500 dark:text-white/60",children:["pending"===C&&"No payment processed yet","processing"===C&&"Payment is being processed","paid"===C&&`Paid $${e?.payment_amount||0} on ${e?.payment_date?new Date(e.payment_date).toLocaleDateString():"Unknown"}`,"held"===C&&"Payment is held pending review","scheduled"===C&&`Payment scheduled for ${e?.scheduled_payment_date?new Date(e.scheduled_payment_date).toLocaleDateString():"Unknown"}`]})]})]}),e?.payment_amount&&(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsxs)("div",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:["$",e.payment_amount]}),(0,t.jsx)("div",{className:"text-sm text-gray-500 dark:text-white/60",children:e?.currency?.toUpperCase()||"USD"})]})]}),i&&(0,t.jsxs)("div",{className:"space-y-3",children:["pending"===C&&(0,t.jsxs)("div",{className:"flex space-x-3",children:[(0,t.jsx)("button",{onClick:()=>d(!0),className:"flex-1 px-4 py-2 bg-green-600 hover:bg-green-700 text-gray-900 dark:text-white rounded-lg transition-colors duration-200 text-sm font-medium",children:"Process Payment"}),(0,t.jsx)("button",{onClick:()=>d(!0),className:"flex-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-gray-900 dark:text-white rounded-lg transition-colors duration-200 text-sm font-medium",children:"Schedule Payment"})]}),"held"===C&&(0,t.jsx)("button",{onClick:P,disabled:n,className:"w-full px-4 py-2 bg-green-600 hover:bg-green-700 text-gray-900 dark:text-white rounded-lg transition-colors duration-200 text-sm font-medium disabled:opacity-50",children:n?"Releasing...":"Release Payment"})]}),(0,t.jsx)(to.AnimatePresence,{children:o&&(0,t.jsxs)(tl.motion.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2},className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-4 space-y-4",children:[(0,t.jsx)("h5",{className:"font-medium text-gray-900 dark:text-white",children:"Payment Details"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm font-medium text-gray-900 dark:text-white mb-2",children:"Payment Amount"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(eM.DollarSign,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-white/40"}),(0,t.jsx)("input",{type:"number",value:m,onChange:e=>u(Number(e.target.value)),className:"w-full pl-10 pr-4 py-2 bg-gray-50 dark:bg-white/[0.05] border border-gray-200 dark:border-white/[0.1] rounded-lg text-gray-900 dark:text-white focus:outline-none focus:border-blue-500",placeholder:"0.00"})]})]}),(0,t.jsxs)("div",{className:"flex space-x-3",children:[(0,t.jsx)("button",{onClick:A,disabled:n,className:"flex-1 px-4 py-2 bg-green-600 hover:bg-green-700 text-gray-900 dark:text-white rounded-lg transition-colors duration-200 text-sm font-medium disabled:opacity-50",children:n?"Processing...":"Process Now"}),(0,t.jsx)("button",{onClick:()=>D(new Date(Date.now()+864e5)),disabled:n,className:"flex-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-gray-900 dark:text-white rounded-lg transition-colors duration-200 text-sm font-medium disabled:opacity-50",children:"Schedule for Tomorrow"}),(0,t.jsx)("button",{onClick:()=>d(!1),className:"px-4 py-2 bg-gray-100 dark:bg-white/[0.1] hover:bg-gray-200 dark:hover:bg-white/[0.15] text-gray-900 dark:text-white rounded-lg transition-colors duration-200 text-sm font-medium",children:"Cancel"})]})]})}),x&&(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("h5",{className:"font-medium text-gray-900 dark:text-white",children:"Payment History"}),S&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("h6",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:"Completed Payments"}),x.payments.slice(0,3).map((e,a)=>(0,t.jsxs)("div",{className:"flex items-center justify-between bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-3",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsx)("div",{className:"w-8 h-8 bg-green-500/10 rounded-full flex items-center justify-center",children:(0,t.jsx)(tm.CheckCircle,{className:"w-4 h-4 text-green-400"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Payment Processed"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/60",children:new Date(e.created_at).toLocaleDateString()})]})]}),(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsxs)("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:["$",e.amount]}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/60",children:e.status})]})]},a))]}),E&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("h6",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:"Scheduled Payments"}),x.scheduledPayments.map((e,a)=>(0,t.jsxs)("div",{className:"flex items-center justify-between bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-3",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsx)("div",{className:"w-8 h-8 bg-purple-500/10 rounded-full flex items-center justify-center",children:(0,t.jsx)(w.Calendar,{className:"w-4 h-4 text-purple-400"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Scheduled Payment"}),(0,t.jsxs)("p",{className:"text-xs text-gray-500 dark:text-white/60",children:["Due: ",new Date(e.scheduled_date).toLocaleDateString()]})]})]}),(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsxs)("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:["$",e.amount]}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/60",children:e.status})]})]},a))]}),x.refunds?.length>0&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("h6",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:"Refunds"}),x.refunds.map((e,a)=>(0,t.jsxs)("div",{className:"flex items-center justify-between bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-3",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsx)("div",{className:"w-8 h-8 bg-red-500/10 rounded-full flex items-center justify-center",children:(0,t.jsx)(tu.XCircle,{className:"w-4 h-4 text-red-400"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Refund Processed"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/60",children:new Date(e.created_at).toLocaleDateString()})]})]}),(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsxs)("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:["-$",e.amount]}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/60",children:e.reason})]})]},a))]}),!S&&!E&&j&&(0,t.jsxs)("div",{className:"text-center py-6",children:[(0,t.jsx)(tw.CreditCard,{className:"w-12 h-12 text-gray-400 dark:text-white/20 mx-auto mb-3"}),(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-white/60",children:"No payment history yet"})]})]}),e?.estimated_cost&&j&&(0,t.jsxs)("div",{className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-4",children:[(0,t.jsx)("h6",{className:"text-sm font-medium text-gray-900 dark:text-white mb-3",children:"Payment Summary"}),(0,t.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-gray-500 dark:text-white/60",children:"Estimated Cost:"}),(0,t.jsxs)("span",{className:"text-gray-900 dark:text-white",children:["$",e.estimated_cost]})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-gray-500 dark:text-white/60",children:"Platform Fee (10%):"}),(0,t.jsxs)("span",{className:"text-gray-900 dark:text-white",children:["$",(.1*e.estimated_cost).toFixed(2)]})]}),(0,t.jsxs)("div",{className:"border-t border-gray-200 dark:border-white/[0.08] pt-2 flex justify-between font-medium",children:[(0,t.jsx)("span",{className:"text-gray-900 dark:text-white",children:"Total:"}),(0,t.jsxs)("span",{className:"text-gray-900 dark:text-white",children:["$",(1.1*e.estimated_cost).toFixed(2)]})]})]})]})]}):(0,t.jsxs)("div",{className:"p-6 relative",children:[(0,t.jsx)("div",{className:"absolute inset-0 bg-black/80 backdrop-blur-sm z-50 flex items-center justify-center rounded-lg",children:(0,t.jsxs)("div",{className:"text-center p-6 bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-xl shadow-2xl max-w-sm mx-4",children:[(0,t.jsx)("div",{className:"w-16 h-16 bg-blue-100/10 rounded-full flex items-center justify-center mx-auto mb-4",children:(0,t.jsx)(eM.DollarSign,{className:"w-8 h-8 text-blue-400"})}),(0,t.jsx)("h3",{className:"text-xl font-bold text-gray-900 dark:text-white mb-2",children:"Payments Coming Soon"}),(0,t.jsx)("p",{className:"text-gray-500 dark:text-white/60 text-sm mb-4",children:"We're currently setting up our payment infrastru
58cture. Payment processing will be available shortly."}),(0,t.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/40",children:"Thank you for your patience"})]})}),(0,t.jsxs)("div",{className:"text-center py-12",children:[(0,t.jsx)("div",{className:"w-20 h-20 bg-gradient-to-br from-blue-500/20 to-purple-500/20 rounded-full flex items-center justify-center mx-auto mb-6",children:(0,t.jsx)(tw.CreditCard,{className:"w-10 h-10 text-blue-400"})}),(0,t.jsx)("h3",{className:"text-xl font-semibold text-gray-900 dark:text-white mb-3",children:"No Payment Activity Yet"}),(0,t.jsx)("p",{className:"text-gray-500 dark:text-white/60 mb-8 max-w-md mx-auto leading-relaxed",children:"Payments will be available once you have an assigned provider. Get started by finding providers or accepting bids for this task."}),(0,t.jsxs)("div",{className:"space-y-4 max-w-sm mx-auto",children:[y?(0,t.jsx)("div",{className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-4",children:(0,t.jsxs)("div",{className:"flex items-center space-x-3 mb-3",children:[(0,t.jsx)("div",{className:"w-8 h-8 bg-green-500/20 rounded-full flex items-center justify-center",children:(0,t.jsx)(tm.CheckCircle,{className:"w-4 h-4 text-green-400"})}),(0,t.jsxs)("div",{className:"text-left",children:[(0,t.jsx)("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Marketplace Enabled"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/60",children:"Ready to receive bids"})]})]})}):(0,t.jsxs)("div",{className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-4",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3 mb-3",children:[(0,t.jsx)("div",{className:"w-8 h-8 bg-blue-500/20 rounded-full flex items-center justify-center",children:(0,t.jsx)(k.Zap,{className:"w-4 h-4 text-blue-400"})}),(0,t.jsxs)("div",{className:"text-left",children:[(0,t.jsx)("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Enable Marketplace"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/60",children:"Allow providers to bid on this task"})]})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between text-xs text-gray-400 dark:text-white/40",children:[(0,t.jsx)("span",{children:"Step 1"}),(0,t.jsx)(tv.ArrowRight,{className:"w-3 h-3"})]})]}),(0,t.jsxs)("div",{className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-4",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3 mb-3",children:[(0,t.jsx)("div",{className:"w-8 h-8 bg-purple-500/20 rounded-full flex items-center justify-center",children:(0,t.jsx)(eD.Users,{className:"w-4 h-4 text-purple-400"})}),(0,t.jsxs)("div",{className:"text-left",children:[(0,t.jsx)("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Find Providers"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/60",children:e?.bi
58ds?.length>0?`${e.bids.length} bid${1!==e.bids.length?"s":""} received`:"Invite providers or wait for bids"})]})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between text-xs text-gray-400 dark:text-white/40",children:[(0,t.jsx)("span",{children:"Step 2"}),(0,t.jsx)(tv.ArrowRight,{className:"w-3 h-3"})]})]}),(0,t.jsxs)("div",{className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-4 opacity-50",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3 mb-3",children:[(0,t.jsx)("div",{className:"w-8 h-8 bg-gray-500/20 rounded-full flex items-center justify-center",children:(0,t.jsx)(eM.DollarSign,{className:"w-4 h-4 text-gray-400"})}),(0,t.jsxs)("div",{className:"text-left",children:[(0,t.jsx)("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Process Payment"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/60",children:"Available after provider assignment"})]})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between text-xs text-gray-400 dark:text-white/40",children:[(0,t.jsx)("span",{children:"Step 3"}),(0,t.jsx)("div",{className:"w-3 h-3 rounded-full bg-gray-100 dark:bg-white/10"})]})]})]}),(0,t.jsxs)("div",{className:"mt-8 flex flex-col sm:flex-row gap-3 justify-center",children:[(0,t.jsx)("button",{onClick:()=>{let e=new CustomEvent("switchMarketplaceTab",{detail:"bids"});window.dispatchEvent(e)},className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-gray-900 dark:text-white rounded-lg transition-colors duration-200 text-sm font-medium",children:"View Bids"}),(0,t.jsx)("button",{onClick:()=>{let e=new CustomEvent("switchMarketplaceTab",{detail:"providers"});window.dispatchEvent(e)},className:"px-4 py-2 bg-gray-100 dark:bg-white/[0.1] hover:bg-gray-200 dark:hover:bg-white/[0.15] text-gray-900 dark:text-white rounded-lg transition-colors duration-200 text-sm font-medium",children:"Find Providers"})]})]})]})}var tj=e.i(239616),tN=e.i(227516),tC=e.i(98919),tS=e.i(882293);function tE({task:e,onUpdate:r,canEdit:s,canEditStructure:i}){let[n,l]=(0,a.useState)(!1),[o,d]=(0,a.useState)(!1),[m,u]=(0,a.useState)(!1),[h,x]=(0,a.useState)({primaryVisibilityTime:2,backupVisibilityTime:6,marketplaceVisibilityTime:24,confirmationReminderTime:7,confirmationDeadlineTime:3,progressUpdateTime:24,completionReminderTime:24}),g=e?.escalations||[],p=e?.assignments?.length>0,f=e?.bids?.some(e=>"accepted"===e.status),y=e?.bids?.length>0||e?.marketplace_eligible,w=e?.assignments?.some(e=>"accepted"===e.status),v=p||f||w,j=e?.escalation_rules||{primaryVisibilityTime:2,backupVisibilityTime:6,marketplaceVisibilityTime:24,confirmationReminderTime:7,confirmationDeadlineTime:3,progressUpdateTime:24,completionReminderTime:24};(0,a.useEffect)(()=>{x(j)},[e?.escalation_rules]);let C=async()=>{if(i){l(!0);try{if(!(await fetch("/api/tasks/marketplace/escalations",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:e.id,action:"update_rules",rules:h})})).ok)throw Error("Failed to update escalation rules");await r(),u(!1)}catch(e){console.error("Error updating escalation rules:",e)}finally{l(!1)}}},S={warning:{label:"Warning",color:"text-yellow-400",bgColor:"bg-yellow-500/10",icon:b.AlertTriangle},provider_change:{label:"Provider Change",color:"text-orange-400",bgColor:"bg-orange-500/10",icon:eD.Users},marketplace:{label:"Marketplace",color:"text-red-400",bgColor:"bg-red-500/10",icon:k.Zap},resolved:{label:"Resolved",color:"text-green-400",bgColor:"bg-green-500/10",icon:tm.CheckCircle}},E={non_responsive:"Provider not responding",no_progress:"No progress updates",reassigned_to_backup:"Reassigned to backup provider",escalated_to_marketplace:"Escalated to marketplace",quality_issues:"Quality concerns",deadline_missed:"Deadline missed"},I=async t=>{if(i){l(!0);try{if(!(await fetch("/api/tasks/marketplace/escalations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:e.id,reason:t,escalation_level:"warning"})})).ok)throw Error("Failed to create escalation");await r()}catch(e){console.error("Error creating escalation:",e)}finally{l(!1)}}},T=async()=>
58{if(i){l(!0);try{if(!(await fetch("/api/tasks/marketplace/escalations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:e.id,action:"escalate_to_marketplace"})})).ok)throw Error("Failed to escalate to marketplace");await r()}catch(e){console.error("Error escalating to marketplace:",e)}finally{l(!1)}}};if(!v&&0===g.length)return(0,t.jsxs)("div",{className:"p-6 space-y-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsx)("div",{className:"w-10 h-10 bg-orange-500/10 rounded-full flex items-center justify-center",children:(0,t.jsx)(tj.Settings,{className:"w-5 h-5 text-orange-400"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h4",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Escalation Settings"}),(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-white/60",children:"Configure automatic escalation timeframes"})]})]}),(0,t.jsx)("button",{onClick:()=>d(!o),className:(0,N.cn)("p-2 rounded-lg transition-colors duration-200",o?"bg-blue-600 text-gray-900 dark:text-white":"bg-gray-100 dark:bg-white/[0.1] text-gray-500 dark:text-white/60 hover:text-gray-900 dark:hover:text-white"),children:(0,t.jsx)(tj.Settings,{className:"w-4 h-4"})})]}),(0,t.jsx)(to.AnimatePresence,{children:o&&(0,t.jsxs)(tl.motion.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2},className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-4 space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("h5",{className:"font-medium text-gray-900 dark:text-white",children:"Escalation Rules"}),i&&(0,t.jsx)("div",{className:"flex space-x-2",children:m?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{onClick:C,disabled:n,className:"px-3 py-1 bg-green-600 hover:bg-green-700 text-gray-900 dark:text-white rounded text-sm font-medium disabled:opacity-50",children:n?"Saving...":"Save"}),(0,t.jsx)("button",{onClick:()=>{x(j),u(!1)},className:"px-3 py-1 bg-gray-600 hover:bg-gray-700 text-gray-900 dark:text-white rounded text-sm font-medium",children:"Cancel"})]}):(0,t.jsx)("button",{onClick:()=>u(!0),className:"px-3 py-1 bg-blue-600 hover:bg-blue-700 text-gray-900 dark:text-white rounded text-sm font-medium",children:"Edit"})})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[(0,t.jsx)("div",{className:"col-span-2",children:(0,t.jsx)("h4",{className:"text-gray-900 dark:text-white font-medium mb-3 text-sm",children:"ð New Task Visibility Escalation"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-gray-600 dark:text-white/80 mb-2",children:"Primary Visibility Time (hours)"}),m?(0,t.jsx)("input",{type:"number",value:h.primaryVisibilityTime,onChange:e=>x(t=>({...t,primaryVisibilityTime:Number(e.target.value)})),className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.05] border border-gray-200 dark:border-white/[0.1] rounded text-gray-900 dark:text-white focus:outline-none focus:border-blue-500",min:"1",max:"168"}):(0,t.jsxs)("div",{className:"text-gray-900 dark:text-white",children:[j.primaryVisibilityTime," hour",1!==j.primaryVisibilityTime?"s":""]}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/50 mt-1",children:"How long only primary providers see new tasks"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-gray-600 dark:text-white/80 mb-2",children:"Backup Visibility Time (hours)"}),m?(0,t.jsx)("input",{type:"number",value:h.backupVisibilityTime,onChange:e=>x(t=>({...t,backupVisibilityTime:Number(e.target.value)})),className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.05] border border-gray-200 dark:border-white/[0.1] rounded text-gray-900 dark:text-white focus:outline-none focus:border-blue-500",min:"1",max:"168"}):(0,t.jsxs)("div",{className:"text-gray-900 dark:text-white",children:[j.backupVisibilityTime," hour",1!==j.backupVisibilityTime?"s":""]}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/50 mt-1",children:"When to expand to backup providers"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-gray-600 dark:text-white/80 mb-2",children:"Marketplace Visibility Time (hours)"}),m?(0,t.jsx)("input",{type:"number",value:h.marketplaceVisibilityTime,onChange:e=>x(t=>({...t,marketplaceVisibilityTime:Number(e.target.value)})),className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.05] border border-gray-200 dark:border-white/[0.1] rounded text-gray-900 dark:text-white focus:outline-none focus:border-blue-500",min:"1",max:"168"}):(0,t.jsxs)("div",{className:"text-gray-900 dark:text-white",children:[j.marketplaceVisibilityTime," hour",1!==j.marketplaceVisibilityTime?"s":""]}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/50 mt-1",children:"When to open to full marketplace"})]}),(0,t.jsx)("div",{className:"col-span-2 mt-4",children:(0,t.jsx)("h4",{className:"text-gray-900 dark:text-white font-medium mb-3 text-sm",children:"â Claimed Task Confirmation"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-gray-600 dark:text-white/80 mb-2",children:"Confirmation Reminder (days before due)"}),m?(0,t.jsx)("input",{type:"number",value:h.confirmationReminderTime,onChange:e=>x(t=>({...t,confirmationReminderTime:Number(e.target.value)})),className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.05] border border-gray-200 dark:border-white/[0.1] rounded text-gray-900 dark:text-white focus:outline-none focus:border-blue-500",min:"1",max:"30"}):(0,t.jsxs)("div",{className:"text-gray-900 dark:text-white",children:[j.confirmationReminderTime," day",1!==j.confirmationReminderTime?"s":""]}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/50 mt-1",children:'Send "Still doing this?" reminder'})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-gray-600 dark:text-white/80 mb-2",children:"Confirmation Deadline (days before due)"}),m?(0,t.jsx)("input",{type:"number",value:h.confirmationDeadlineTime,onChange:e=>x(t=>({...t,confirmationDeadlineTime:Number(e.target.value)})),className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.05] border border-gray-200 dark:border-white/[0.1] rounded text-gray-900 dark:text-white focus:outline-none focus:border-blue-500",min:"1",max:"30"}):(0,t.jsxs)("div",{className:"text-gray-900 dark:text-white",children:[j.confirmationDeadlineTime," day",1!==j.confirmationDeadlineTime?"s":""]}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/50 mt-1",children:"Must confirm b
58y this time or task is re-released"})]}),(0,t.jsx)("div",{className:"col-span-2 mt-4",children:(0,t.jsx)("h4",{className:"text-gray-900 dark:text-white font-medium mb-3 text-sm",children:"ð Assigned Task Progress"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-gray-600 dark:text-white/80 mb-2",children:"Progress Update Time (hours)"}),m?(0,t.jsx)("input",{type:"number",value:h.progressUpdateTime,onChange:e=>x(t=>({...t,progressUpdateTime:Number(e.target.value)})),className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.05] border border-gray-200 dark:border-white/[0.1] rounded text-gray-900 dark:text-white focus:outline-none focus:border-blue-500",min:"1",max:"168"}):(0,t.jsxs)("div",{className:"text-gray-900 dark:text-white",children:[j.progressUpdateTime," hour",1!==j.progressUpdateTime?"s":""]}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/50 mt-1",children:"How often progress updates are required"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-gray-600 dark:text-white/80 mb-2",children:"Completion Reminder Time (hours)"}),m?(0,t.jsx)("input",{type:"number",value:h.completionReminderTime,onChange:e=>x(t=>({...t,completionReminderTime:Number(e.target.value)})),className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.05] border border-gray-200 dark:border-white/[0.1] rounded text-gray-900 dark:text-white focus:outline-none focus:border-blue-500",min:"1",max:"168"}):(0,t.jsxs)("div",{className:"text-gray-900 dark:text-white",children:[j.completionReminderTime," hour",1!==j.completionReminderTime?"s":""]}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/50 mt-1",children:"Reminder before task deadline"})]})]}),(0,t.jsxs)("div",{className:"text-xs text-gray-500 dark:text-white/60 bg-white dark:bg-white/[0.02] rounded p-3",children:[(0,t.jsx)("p",{className:"mb-2",children:(0,t.jsx)("strong",{children:"How the hybrid escalation system works:"})}),(0,t.jsxs)("ul",{className:"space-y-1 list-disc list-inside",children:[(0,t.jsxs)("li",{children:[(0,t.jsx)("strong",{children:"New Tasks:"})," Start with primary providers, expand to backup, then full marketplace"]}),(0,t.jsxs)("li",{children:[(0,t.jsx)("strong",{children:"Claimed Tasks:"})," Send confirmation reminders for tasks claimed in advance"]}),(0,t.jsxs)("li",{children:[(0,t.jsx)("strong",{children:"Active Tasks:"})," Monitor progress and send completion reminders"]}),(0,t.jsxs)("li",{children:[(0,t.jsx)("strong",{children:"Re-release:"})," Tasks return to marketplace if providers don't confirm or respond"]})]})]})]})}),(0,t.jsxs)("div",{className:"text-center py-8",children:[(0,t.jsx)("div",{className:"w-20 h-20 bg-gradient-to-br from-orange-500/20 to-red-500/20 rounded-full flex items-center justify-center mx-auto mb-6",children:(0,t.jsx)(tC.Shield,{className:"w-10 h-10 text-orange-400"})}),(0,t.jsx)("h3",{className:"text-xl font-semibold text-gray-900 dark:text-white mb-3",children:"Hybrid Escalation System"}),(0,t.jsx)("p",{className:"text-gray-500 dark:text-white/60 mb-8 max-w-md mx-auto leading-relaxed",children:"Our smart escalation system manages both new task visibility (Primary â Backup â Marketplace) and claimed task confirmations to ensure reliable service delivery."}),(0,t.jsxs)("div",{className:"space-y-4 max-w-lg mx-auto mb-8",children:[(0,t.jsx)("div",{className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-4",children:(0,t.jsxs)("div",{className:"flex items-center space-x-3 mb-3",children:[(0,t.jsx)("div",{className:"w-8 h-8 bg-blue-500/20 rounded-full flex items-center justify-center",children:(0,t.jsx)(eD.Users,{className:"w-4 h-4 text-blue-400"})}),(0,t.jsxs)("div",{className:"text-left",children:[(0,t.jsx)("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Smart Provider Prioritization"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/60",children:"New tasks shown to primary providers first, then backup, then marketplace"})]})]})}),(0,t.jsx)("div",{className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-4",children:(0,t.jsxs)("div",{className:"flex items-center space-x-3 mb-3",children:[(0,t.jsx)("div",{className:"w-8 h-8 bg-yellow-500/20 rounded-full flex items-center justify-center",children:(0,t.jsx)(tS.UserCheck,{className:"w-4 h-4 text-yellow-400"})}),(0,t.jsxs)("div",{className:"text-left",children:[(0,t.jsx)("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Claimed Task Confirmations"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/60",children:"Providers confirm availability for tasks claimed in advance"})]})]})}),(0,t.jsx)("div",{className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-4",children:(0,t.jsxs)("div",{className:"flex items-center space-x-3 mb-3",children:[(0,t.jsx)("div",{className:"w-8 h-8 bg-red-500/20 rounded-full flex items-center justify-center",children:(0,t.jsx)(c.RefreshCw,{className:"w-4 h-4 text-red-400"})}),(0,t.jsxs)("div",{className:"text-left",children:[(0,t.jsx)("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Automatic Re-release"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/60",children:"Tasks return to marketplace if providers don't confirm or respond"})]})]})})]}),(0,t.jsxs)("div",{className:"space-y-4 max-w-sm mx-auto",children:[y?p?(0,t.jsx)("div",{className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-4",children:(0,t.jsxs)("div",{className:"flex items-center space-x-3 mb-3",children:[(0,t.jsx)("div",{className:"w-8 h-8 bg-green-500/20 rounded-full flex items-center justify-center",children:(0,t.jsx)(tS.UserCheck,{className:"w-4 h-4 text-green-400"})}),(0,t.jsxs)("div",{className:"text-left",children:[(0,t.jsx)("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Provider Assigned"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/60",children:"Escalations now available"})]})]})}):(0,t.jsxs)("div",{className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-4",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3 mb-3",children:[(0,t.jsx)("div",{className:"w-8 h-8 bg-purple-500/20 rounded-full flex items-center justify-center",children:(0,t.jsx)(eD.Users,{className:"w-4 h-4 text-purple-400"})}),(0,t.jsxs)("div",{className:"text-left",children:[(0,t.jsx)("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Assign Provider"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/60",children:e?.bi
58ds?.length>0?`${e.bids.length} bid${1!==e.bids.length?"s":""} waiting for acceptance`:"Waiting for provider bids"})]})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between text-xs text-gray-400 dark:text-white/40",children:[(0,t.jsx)("span",{children:"Step 2"}),(0,t.jsx)(tv.ArrowRight,{className:"w-3 h-3"})]})]}):(0,t.jsxs)("div",{className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-4",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3 mb-3",children:[(0,t.jsx)("div",{className:"w-8 h-8 bg-gray-500/20 rounded-full flex items-center justify-center",children:(0,t.jsx)(k.Zap,{className:"w-4 h-4 text-gray-400"})}),(0,t.jsxs)("div",{className:"text-left",children:[(0,t.jsx)("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Enable Marketplace"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/60",children:"First step to get providers"})]})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between text-xs text-gray-400 dark:text-white/40",children:[(0,t.jsx)("span",{children:"Step 1"}),(0,t.jsx)(tv.ArrowRight,{className:"w-3 h-3"})]})]}),(0,t.jsxs)("div",{className:(0,N.cn)("bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-4",!v&&"opacity-50"),children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3 mb-3",children:[(0,t.jsx)("div",{className:"w-8 h-8 bg-orange-500/20 rounded-full flex items-center justify-center",children:(0,t.jsx)(tC.Shield,{className:"w-4 h-4 text-orange-400"})}),(0,t.jsxs)("div",{className:"text-left",children:[(0,t.jsx)("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Escalation Tools"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/60",children:v?"Ready to use when needed":"Available after provider assignment"})]})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between text-xs text-gray-400 dark:text-white/40",children:[(0,t.jsx)("span",{children:"Step 3"}),v?(0,t.jsx)(tm.CheckCircle,{className:"w-3 h-3 text-green-400"}):(0,t.jsx)("div",{className:"w-3 h-3 rounded-full bg-gray-100 dark:bg-white/10"})]})]})]}),(0,t.jsxs)("div",{className:"mt-8 flex flex-col sm:flex-row gap-3 justify-center",children:[(0,t.jsx)("button",{onClick:()=>{let e=new CustomEvent("switchMarketplaceTab",{detail:"bids"});window.dispatchEvent(e)},className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-gray-900 dark:text-white rounded-lg transition-colors duration-200 text-sm font-medium",children:"View Bids"}),(0,t.jsx)("button",{onClick:()=>{let e=new CustomEvent("switchMarketplaceTab",{detail:"providers"});window.dispatchEvent(e)},className:"px-4 py-2 bg-gray-100 dark:bg-white/[0.1] hover:bg-gray-200 dark:hover:bg-white/[0.15] text-gray-900 dark:text-white rounded-lg transition-colors duration-200 text-sm font-medium",children:"Find Providers"})]})]})]});let _=g.some(e=>!e.resolved_at);return g[0],(0,t.jsxs)("div",{className:"p-6 space-y-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsx)("div",{className:(0,N.cn)("w-10 h-10 rounded-full flex items-center justify-center",_?"bg-red-500/10":"bg-green-500/10"),children:_?(0,t.jsx)(b.AlertTriangle,{className:"w-5 h-5 text-red-400"}):(0,t.jsx)(tm.CheckCircle,{className:"w-5 h-5 text-green-400"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h4",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:_?"Active Escalations":"No Active Escalations"}),(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-white/60",children:_?`${g.filter(e=>!e.resolved_at).length} unresolved escalation${1!==g.filter(e=>!e.resolved_at).length?"s":""}`:"Task is proceeding normally"})]})]}),(0,t.jsx)("button",{onClick:()=>d(!o),className:(0,N.cn)("p-2 rounded-lg transition-colors duration-200",o?"bg-blue-600 text-gray-900 dark:text-white":"bg-gray-100 dark:bg-white/[0.1] text-gray-500 dark:text-white/60 hover:text-gray-900 dark:hover:text-white"),children:(0,t.jsx)(tj.Settings,{className:"w-4 h-4"})})]}),i&&v&&(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("h5",{className:"font-medium text-gray-900 dark:text-white",children:"Manual Actions"}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,t.jsx)("button",{onClick:()=>I("no_progress"),disabled:n,className:"px-4 py-2 bg-yellow-600/20 hover:bg-yellow-600/30 text-yellow-400 rounded-lg transition-colors duration-200 text-sm font-medium disabled:opacity-50",children:"Request Progress Update"}),(0,t.jsx)("button",{onClick:()=>I("quality_issues"),disabled:n,className:"px-4 py-2 bg-orange-600/20 hover:bg-orange-600/30 text-orange-400 rounded-lg transition-colors duration-200 text-sm font-medium disabled:opacity-50",children:"Report Quality Issue"})]}),(0,t.jsx)("button",{onClick:T,disabled:n,className:"w-full px-4 py-2 bg-red-600/20 hover:bg-red-600/30 text-red-400 rounded-lg transition-colors duration-200 text-sm font-medium disabled:opacity-50",children:n?"Escalating...":"Escalate to Marketplace"})]}),(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)(tN.History,{className:"w-4 h-4 text-gray-500 dark:text-white/60"}),(0,t.jsx)("h5",{className:"font-medium text-gray-900 dark:text-white",children:"Escalation History"})]}),0===g.length?(0,t.jsxs)("div",{className:"text-center py-6",children:[(0,t.jsx)(tm.CheckCircle,{className:"w-12 h-12 text-green-400/20 mx-auto mb-3"}),(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-white/60",children:"No escalations recorded"}),(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-white/40",children:v?"Task is proceeding smoothly":"Escalations will appear here once available"})]}):(0,t.jsx)("div",{className:"space-y-3",children:g.map((e,a)=>{let r=S[e.escalation_level],s=r?.icon||b.AlertTriangle;return(0,t.jsxs)(tl.motion.div,{initial:{opacity:0,x:-20}
58,animate:{opacity:1,x:0},transition:{delay:.1*a},className:(0,N.cn)("flex items-start space-x-3 p-3 rounded-lg border",e.resolved_at?"bg-white dark:bg-white/[0.02] border-gray-200 dark:border-white/[0.08]":"bg-red-500/5 border-red-500/20"),children:[(0,t.jsx)("div",{className:(0,N.cn)("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0",r?.bgColor||"bg-red-500/10"),children:(0,t.jsx)(s,{className:(0,N.cn)("w-4 h-4",r?.color||"text-red-400")})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,t.jsx)("h6",{className:"text-sm font-medium text-gray-900 dark:text-white",children:E[e.reason]||e.reason}),(0,t.jsx)("span",{className:(0,N.cn)("px-2 py-0.5 rounded-full text-xs font-medium",r?.bgColor||"bg-red-500/10",r?.color||"text-red-400"),children:r?.label||e.escalation_level})]}),(0,t.jsxs)("p",{className:"text-xs text-gray-500 dark:text-white/60 mb-2",children:[new Date(e.created_at).toLocaleString(),e.resolved_at&&(0,t.jsxs)("span",{className:"ml-2 text-green-400",children:["⢠Resolved ",new Date(e.resolved_at).toLocaleString()]})]}),e.details&&(0,t.jsx)("p",{className:"text-sm text-gray-600 dark:text-white/80 bg-white dark:bg-white/[0.02] rounded p-2",children:e.details}),e.from_provider_id&&e.to_provider_id&&(0,t.jsxs)("div",{className:"flex items-center space-x-2 mt-2 text-xs text-gray-500 dark:text-white/60",children:[(0,t.jsx)("span",{children:"Provider changed"}),(0,t.jsx)(tv.ArrowRight,{className:"w-3 h-3"}),(0,t.jsx)("span",{children:"New provider assigned"})]})]})]},e.id)})})]}),g.length>0&&(0,t.jsxs)("div",{className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-4",children:[(0,t.jsx)("h6",{className:"text-sm font-medium text-gray-900 dark:text-white mb-3",children:"Escalation Metrics"}),(0,t.jsxs)("div",{className:"grid grid-cols-3 gap-4 text-sm",children:[(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)("div",{className:"text-lg font-bold text-gray-900 dark:text-white",children:g.length}),(0,t.jsx)("div",{className:"text-gray-500 dark:text-white/60",children:"Total"})]}),(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)("div",{className:"text-lg font-bold text-yellow-400",children:g.filter(e=>!e.resolved_at).length}),(0,t.jsx)("div",{className:"text-gray-500 dark:text-white/60",children:"Active"})]}),(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)("div",{className:"text-lg font-bold text-green-400",children:g.filter(e=>e.resolved_at).length}),(0,t.jsx)("div",{className:"text-gray-500 dark:text-white/60",children:"Resolved"})]})]})]})]})}var tI=e.i(842009);function tT({task:e}){let r=(0,a.useMemo)(()=>e?.bids?.find(e=>"accepted"===e.status),[e?.bids]),s=(0,a.useMemo)(()=>{let t=e?.assignments?.find(e=>"accepted"===e.status);return!t&&r&&(t=e?.assignments?.find(e=>e.user_id===r.provider_id&&("pending"===e.status||"accepted"===e.status))),t},[e?.assignments,r]);if(!r)return null;let i=r.provider;return(0,t.jsxs)(tl.motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"bg-gradient-to-br from-green-500/10 to-blue-500/5 border border-green-500/20 rounded-xl p-6",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3 mb-6",children:[(0,t.jsx)("div",{className:"w-10 h-10 bg-green-500/20 rounded-full flex items-center justify-center",children:(0,t.jsx)(tm.CheckCircle,{className:"w-5 h-5 text-green-400"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h4",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Provider Assigned"}),(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-white/60",children:"Task has been awarded to a marketplace provider"})]})]}),(0,t.jsxs)("div",{className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-5",children:[(0,t.jsxs)("div",{className:"flex items-start space-x-4",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("div",{className:"w-16 h-16 bg-gray-100 dark:bg-white/[0.1] rounded-full flex items-center justify-center overflow-hidden",children:i?.image?(0,t.jsx)("img",{src:i.image,alt:i.name,className:"w-16 h-16 object-cover"}):(0,t.jsx)(tc.User,{className:"w-8 h-8 text-gray-500 dark:text-white/60"})}),(0,t.jsx)("div",{className:(0,N.cn)("absolute -bottom-1 -right-1 px-2 py-0.5 rounded-full text-xs font-medium",i?.type==="individual"?"bg-green-500/20 text-green-400":"bg-purple-500/20 text-purple-400"),children:i?.type||"individual"})]}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("div",{className:"flex items-center justify-between mb-2",children:(0,t.jsx)("h5",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:i?.name||"Unknown Provider"})}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4 mb-4",children:[(0,t.jsxs)("div",{className:"bg-gray-50 dark:bg-white/[0.05] rounded-lg p-3",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2 mb-1",children:[(0,t.jsx)(tm.CheckCircle,{className:"w-4 h-4 text-green-400"}),(0,t.jsx)("span",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:"Tasks Completed"})]}),(0,t.jsx)("p",{className:"text-lg font-bold text-gray-900 dark:text-white",children:i?.completedTasks||i?.totalReviews||0})]}),(0,t.jsxs)("div",{className:"bg-gray-50 dark:bg-white/[0.05] rounded-lg p-3",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2 mb-1",children:[(0,t.jsx)(ev.Star,{className:"w-4 h-4 text-yellow-400"}),(0,t.jsx)("span",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:"Rating"})]}),(0,t.jsxs)("p",{className:"text-lg font-bold text-gray-900 dark:text-white",children:[i?.rating?.toFixed(1)||"0.0"," (",i?.totalReviews||0,")"]})]})]}),i?.serviceAreas&&i.serviceAreas.length>0&&(0,t.jsxs)("div",{className:"mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2 mb-2",children:[(0,t.jsx)(tg.MapPin,{className:"w-4 h-4 text-blue-400"}),(0,t.jsx)("span",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:"Service Areas"})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-1",children:[i.serviceAreas.slice(0,2).map((e,a)=>(0,t.jsx)("span",{className:"px-2 py-1 bg-blue-500/10 text-blue-400 rounded text-xs",children:e},a)),i.serviceAreas.length>2&&(0,t.jsxs)("span",{className:"px-2 py-1 bg-gray-100 dark:bg-white/[0.1] text-gray-500 dark:text-white/60 rounded text-xs",children:["+",i.serviceAreas.length-2," more"]})]})]}),i?.skills&&i.skills.length>0&&(0,t.jsxs)("div",{className:"mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2 mb-2",children:[(0,t.jsx)(tI.Award,{className:"w-4 h-4 text-purple-400"}),(0,t.jsx)("span",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:"Skills"})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-1",children:[i.skills.slice(0,3).map((e,a)=>(0,t.jsx)("span",{className:"px-2 py-1 bg-purple-500/10 text-purple-400 rounded text-xs",children:e},a)),i.skills.length>3&&(0,t.jsxs)("span",{className:"px-2 py-1 bg-gray-100 dark:bg-white/[0.1] text-gray-500 dark:text-white/60 rounded text-xs",children:["+",i.skills.length-3," more"]})]})]})]})]}),(0,t.jsxs)("div",{className:"mt-5 pt-5 border-t border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsxs)("div",{className:"flex items-center justify-center space-x-1 mb-1",children:[(0,t.jsx)(eM.DollarSign,{className:"w-4 h-4 text-green-400"}),(0,t.jsx)("span",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:"Winning Bid"})]}),(0,t.jsxs)("p",{className:"text-xl font-bold text-green-400",children:["$",r.amount]}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/60",children:r.currency.toUpperCase()})]}),(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsxs)("div",{className:"flex items-center justify-center space-x-1 mb-1",children:[(0,t.jsx)(f.Clock,{className:"w-4 h-4 text-blue-400"}),(0,t.jsx)("span",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:"Duration"})]}),(0,t.jsx)("p",{className:"text-xl font-bold text-gray-900 dark:text-white",children:r.estimated_duration||s.billing?.estimatedDuration||"N/A"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/60",children:"minutes"})]}),(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsxs)("div",{className:"flex items-center justify-center space-x-1 mb-1",children:[(0,t.jsx)(tC.Shield,{className:"w-4 h-4 text-purple-400"}),(0,t.jsx)("span",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:"Status"})]}),(0,t.jsx)("p",{className:(0,N.cn)("text-xl font-bold",s?.status==="accepted"?"text-green-400":"text-yellow-400"),children:s?.status==="pending"?"Assigned (Pending Confirmation)":s?.status||"Assigned"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/60",children:s?.status==="pending"?"Awaiting provider confirmation":s?.billing?.status||"ready"})]})]}),r.notes&&(0,t.jsx)("div",{className:"mt-4 p-3 bg-gray-50 dark:bg-white/[0.05] rounded-lg",children:(0,t.jsxs)("p",{className:"text-sm text-gray-600 dark:text-white/80 italic",children:['"',r.notes,'"']})}),s?.created_at&&(0,t.jsxs)("div",{className:"mt-4 flex items-center justify-center space-x-2 text-sm text-gray-500 dark:text-white/60",children:[(0,t.jsx)(w.Calendar,{className:"w-4 h-4"}),(0,t.jsxs)("span",{children:["Assigned on ",new Date(s.created_at).toLocaleDateString()]})]})]})]})]})}function t_({task:e,metrics:r,onUpdate:s,isMarketplaceEligible:i,onMakeEligible:l,isLoading:o,canEditStructure:d,onNavigateToBids:c,onNavigateToProviders:m}){let u=(0,a.useMemo)(()=>e?.status==="completed"?"completed":r.assignedProviders>0?"assigned":r.totalBids>
580?"bidding":"open",[e?.status,r]),h={open:{label:"Open for Bids",color:"text-blue-400",bgColor:"bg-blue-500/10",icon:n.Eye},bidding:{label:"Receiving Bids",color:"text-yellow-400",bgColor:"bg-yellow-500/10",icon:eM.DollarSign},assigned:{label:"Provider Assigned",color:"text-green-400",bgColor:"bg-green-500/10",icon:tm.CheckCircle},completed:{label:"Completed",color:"text-gray-400",bgColor:"bg-gray-500/10",icon:tm.CheckCircle}}[u],x=h.icon,g=[{label:"Total Bids",value:r.totalBids,icon:eM.DollarSign,color:"text-blue-400",bgColor:"bg-blue-500/10"},{label:"Average Bid",value:r.averageBid>0?`$${r.averageBid.toFixed(0)}`:"-",icon:td.TrendingUp,color:"text-green-400",bgColor:"bg-green-500/10"},{label:"Providers",value:r.assignedProviders,icon:eD.Users,color:"text-purple-400",bgColor:"bg-purple-500/10"},{label:"Payment Status",value:r.paymentStatus.replace("_"," ").toUpperCase(),icon:tm.CheckCircle,color:"paid"===r.paymentStatus?"text-green-400":"text-yellow-400",bgColor:"paid"===r.paymentStatus?"bg-green-500/10":"bg-yellow-500/10"}];return(0,t.jsxs)("div",{className:"p-6 space-y-6",children:[!i&&(0,t.jsxs)("div",{className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-6 text-center",children:[(0,t.jsx)("div",{className:"w-12 h-12 bg-blue-500/10 rounded-full flex items-center justify-center mx-auto mb-4",children:(0,t.jsx)(n.Eye,{className:"w-6 h-6 text-blue-400"})}),(0,t.jsx)("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Enable Marketplace"}),(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-white/60 mb-6",children:"Make this task available to service providers in the marketplace to receive bids and find the best match."}),d&&(0,t.jsx)("button",{onClick:l,disabled:o,className:(0,N.cn)("px-4 py-2 bg-blue-600 hover:bg-blue-700 text-gray-900 dark:text-white rounded-lg","transition-colors duration-200 font-medium","disabled:opacity-50 disabled:cursor-not-allowed"),children:o?"Enabling...":"Enable Marketplace"})]}),i&&(0,t.jsxs)(t.Fragment,{children:["assigned"===u&&(0,t.jsx)(tT,{task:e}),"assigned"!==u&&(0,t.jsx)(t.Fragment,{children:"completed"===u&&e?.invoice?(0,t.jsxs)("div",{className:"bg-white dark:bg-white/[0.02] rounded-lg border border-gray-200 dark:border-white/[0.05] p-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"w-10 h-10 rounded-lg bg-green-500/20 flex items-center justify-center",children:(0,t.jsx)(tm.CheckCircle,{className:"w-5 h-5 text-green-400"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-lg font-semibold text-gray-700 dark:text-white/90",children:"Task Completed"}),(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-white/60",children:"Invoice generated and ready for payment"})]})]}),(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-2xl font-bold text-green-400",children:new Intl.NumberFormat("en-US",{style:"currency",currency:e.invoice.invoiceCurrency||"USD"}).format(e.invoice.invoiceTotal||0)}),(0,t.jsx)("div",{className:(0,N.cn)("text-xs font-medium px-2 py-1 rounded-full mt-1","paid"===e.invoice.invoiceStatus||"paid"===e.invoice.paymentStatus?"bg-green-500/20 text-green-400":"overdue"===e.invoice.invoiceStatus?"bg-red-500/20 text-red-400":"bg-yellow-500/20 text-yellow-400"),children:"paid"===e.invoice.invoiceStatus?"paid":e.invoice.invoiceStatus||"sent"})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4 mb-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/50 mb-1",children:"Invoice Number"}),(0,t.jsx)("p",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:e.invoice.invoiceNumber||`TASK-${String(e.invoice.invoiceId).padStart(3,"0")}`})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/50 mb-1",children:"Issued Date"}),(0,t.jsx)("p",{className:"text-sm text-gray-600 dark:text-white/80",children:e.invoice.invoiceIssuedAt?new Date(e.invoice.invoiceIssuedAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"N/A"})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsxs)("a",{href:`/invoices/${e.invoice.invoiceId}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-gray-900 dark:text-white rounded-lg text-sm font-medium transition-colors",children:[(0,t.jsx)(n.Eye,{className:"w-4 h-4"}),"View Invoice"]}),(0,t.jsxs)("a",{href:`/api/invoices/${e.invoice.invoiceId}/pdf`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-4 py-2 bg-gray-100 dark:bg-white/10 hover:bg-gray-200 dark:hover:bg-white/20 text-gray-900 dark:text-white rounded-lg text-sm font-medium transition-colors border border-gray-300 dark:border-white/20",children:[(0,t.jsx)(td.TrendingUp,{className:"w-4 h-4"}),"Download PDF"]})]})]}):(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsx)("div",{className:(0,N.cn)("w-10 h-10 rounded-full flex items-center justify-center",h.bgColor),children:(0,t.jsx)(x,{className:(0,N.cn)("w-5 h-5",h.color)})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h4",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:h.label}),(0,t.jsxs)("p",{className:"text-sm text-gray-500 dark:text-white/60",children:["open"===u&&"Waiting for provider bids","bi
58dding"===u&&`${r.activeBids>0?r.activeBids+" active, ":""}${r.totalBids} total bid${1!==r.totalBids?"s":""}`,"completed"===u&&"Task has been completed"]})]})]}),r.hasEscalations&&(0,t.jsxs)("div",{className:"flex items-center space-x-2 px-3 py-1 bg-red-500/10 rounded-full",children:[(0,t.jsx)(b.AlertTriangle,{className:"w-4 h-4 text-red-400"}),(0,t.jsx)("span",{className:"text-xs text-red-400 font-medium",children:"Escalated"})]})]})}),(0,t.jsx)("div",{className:(0,N.cn)("grid gap-4","grid-cols-2"),children:g.map((e,a)=>{let r=e.icon;return(0,t.jsxs)(tl.motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1*a},className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-4",children:[(0,t.jsx)("div",{className:"flex items-center justify-between mb-2",children:(0,t.jsx)("div",{className:(0,N.cn)("w-8 h-8 rounded-lg flex items-center justify-center",e.bgColor),children:(0,t.jsx)(r,{className:(0,N.cn)("w-4 h-4",e.color)})})}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("p",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:e.value}),(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-white/60",children:e.label})]})]},e.label)})}),"assigned"!==u&&(0,t.jsxs)(t.Fragment,{children:[r.totalBids>0&&(0,t.jsxs)("div",{className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-4",children:[(0,t.jsx)("h5",{className:"text-sm font-medium text-gray-900 dark:text-white mb-3",children:"Bid Range"}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsxs)("p",{className:"text-lg font-bold text-green-400",children:["$",r.lowestBid.toFixed(0)]}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/60",children:"Lowest"})]}),(0,t.jsx)("div",{className:"flex-1 mx-4",children:(0,t.jsx)("div",{className:"h-2 bg-gray-100 dark:bg-white/[0.1] rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:"h-full bg-gradient-to-r from-green-400 to-red-400 rounded-full",style:{width:"100%"}})})}),(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsxs)("p",{className:"text-lg font-bold text-red-400",children:["$",r.highestBid.toFixed(0)]}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/60",children:"Highest"})]})]})]}),(0,t.jsx)("div",{className:"space-y-4",children:r.totalBids>0?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,t.jsx)("h5",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Recent Bids"}),(0,t.jsx)("button",{onClick:c,className:"text-xs text-blue-400 hover:text-blue-300",children:"View All"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,t.jsx)("span",{className:"text-gray-600 dark:text-white/80",children:"Latest bid received"}),(0,t.jsxs)("span",{className:"text-green-400 font-medium",children:["$",r.lowestBid]})]}),r.activeBids>0&&(0,t.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,t.jsxs)("span",{className:"text-gray-600 dark:text-white/80",children:[r.activeBids," pending review"]}),(0,t.jsx)("span",{className:"text-yellow-400 text-xs",children:"Action needed"})]})]})]}),(0,t.jsxs)("div",{className:"flex space-x-3",children:[(0,t.jsxs)("button",{onClick:c,className:"flex-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-gray-900 dark:text-white rounded-lg transition-colors duration-200 text-sm font-medium",children:["Review Bids (",r.totalBids,")"]}),(0,t.jsx)("button",{onClick:m,className:"flex-1 px-4 py-2 bg-gray-100 dark:bg-white/[0.1] hover:bg-gray-200 dark:hover:bg-white/[0.15] text-gray-900 dark:text-white rounded-lg transition-colors duration-200 text-sm font-medium",children:"Find More Providers"})]})]}):(0,t.jsx)(t.Fragment,{children:(0,t.jsxs)("div",{className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-4 text-center",children:[(0,t.jsx)(eD.Users,{className:"w-8 h-8 text-gray-400 dark:text-white/40 mx-auto mb-2"}),(0,t.jsx)("h5",{className:"text-sm font-medium text-gray-900 dark:text-white mb-1",children:"No Bids Yet"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/60 mb-3",children:"Find and invite qualified service providers to bi
58d on this task"}),(0,t.jsx)("button",{onClick:m,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-gray-900 dark:text-white rounded-lg transition-colors duration-200 text-sm font-medium",children:"Find Providers"})]})})})]}),e?.marketplace_timeline&&(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("h5",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Recent Activity"}),(0,t.jsx)("div",{className:"space-y-2",children:e.marketplace_timeline.slice(0,3).map((e,a)=>(0,t.jsxs)("div",{className:"flex items-center space-x-3 text-sm",children:[(0,t.jsx)("div",{className:"w-2 h-2 bg-blue-400 rounded-full"}),(0,t.jsx)("span",{className:"text-gray-600 dark:text-white/80",children:e.description}),(0,t.jsx)("span",{className:"text-gray-400 dark:text-white/40 ml-auto",children:new Date(e.created_at).toLocaleDateString()})]},a))})]})]})]})}let tA=[{id:"overview",label:"Overview",icon:n.Eye,description:"Marketplace status and metrics"},{id:"bids",label:"Bids",icon:eM.DollarSign,description:"View and manage provider bids"},{id:"providers",label:"Providers",icon:eD.Users,description:"Find and invite providers"},{id:"payments",label:"Payments",icon:td.TrendingUp,description:"Payment processing and history"},{id:"escalations",label:"Escalations",icon:b.AlertTriangle,description:"Escalation rules and history"}];e.s(["TaskMarketplacePanel",0,function({task:e,onUpdate:r,canEdit:s,canEditStructure:i}){let[n,l]=(0,a.useState)("overview"),[o,d]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let e=e=>{let t=e.detail;tA.some(e=>e.id===t)&&l(t)};return window.addEventListener("switchMarketplaceTab",e),()=>{window.removeEventListener("switchMarketplaceTab",e)}},[]);let c=(0,a.useMemo)(()=>e?.marketplace_eligible||e?.metadata?.marketplaceEligible,[e]),m=(0,a.useMemo)(()=>{let t=e?.bids||[],a=e?.assignments||[];return{totalBids:t.length,activeBids:t.filter(e=>"pending"===e.status).length,averageBid:t.length>0?t.reduce((e,t)=>e+t.amount,0)/t.length:0,lowestBid:t.length>0?Math.min(...t.map(e=>e.amount)):0,highestBid:t.length>0?Math.max(...t.map(e=>e.amount)):0,assignedProviders:a.length,hasEscalations:e?.escalations?.length>0,paymentStatus:e?.payment_status||"pending"}},[e]),u=async()=>{if(i){d(!0);try{if(!(await fetch(`/api/tasks/marketplace?taskId=${e.id}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"make_eligible",visibleFrom:new Date,expiresAt:new Date(Date.now()+1728e5),maxBidPrice:500,requiredSkills:[e.category]})})).ok)throw Error("Failed to make task marketplace eligible");await r()}catch(e){console.error("Error making task marketplace eligible:",e)}finally{d(!1)}}};return(0,t.jsxs)("div",{className:"bg-white dark:bg-[#1A1A1C] h-full flex flex-col",children:[(0,t.jsx)("div",{className:"px-6 py-4 border-b border-gray-200 dark:border-white/[0.08] flex-none",children:(0,t.jsx)("div",{className:"flex space-x-1 bg-gray-50 dark:bg-white/[0.05] rounded-lg p-1",children:tA.map(e=>{let a=e.icon,r=n===e.id,s=!c&&"overview"!==e.id;return(0,t.jsxs)("button",{onClick:()=>!s&&l(e.id),disabled:s,className:(0,N.cn)("flex-1 flex items-center justify-center space-x-2 px-3 py-2 rounded-md","text-sm font-medium transition-all duration-200",s?"text-gray-400 dark:text-white/30 curs
58or-not-allowed":r?"bg-gray-100 dark:bg-white/[0.1] text-gray-900 dark:text-white shadow-sm":"text-gray-500 dark:text-white/60 hover:text-gray-900 dark:hover:text-white/80 hover:bg-gray-50 dark:hover:bg-white/[0.05]"),children:[(0,t.jsx)(a,{className:"w-4 h-4"}),(0,t.jsx)("span",{className:"hidden lg:inline",children:e.label})]},e.id)})})}),(0,t.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,t.jsx)(to.AnimatePresence,{mode:"wait",children:(0,t.jsxs)(tl.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2},className:"h-full overflow-y-auto",children:["overview"===n&&(0,t.jsx)("div",{className:"h-full",children:(0,t.jsx)(t_,{task:e,metrics:m,onUpdate:r,isMarketplaceEligible:c,onMakeEligible:u,isLoading:o,canEditStructure:i,onNavigateToBids:()=>l("bids"),onNavigateToProviders:()=>l("providers")})}),"bids"===n&&(0,t.jsx)(tx,{task:e,onUpdate:r,canEdit:s,canEditStructure:i}),"providers"===n&&(0,t.jsx)(ty,{task:e,onUpdate:r,canEdit:s,canEditStructure:i}),"payments"===n&&(0,t.jsx)(tk,{task:e,onUpdate:r,canEdit:s,canEditStructure:i}),"escalations"===n&&(0,t.jsx)(tE,{task:e,onUpdate:r,canEdit:s,canEditStructure:i})]},n)})})]})}],675897),e.s(["useFullListing",0,function(e){let[t,r]=(0,a.useState)(null),[s,i]=(0,a.useState)(!1),[n,l]=(0,a.useState)(null);return(0,a.useEffect)(()=>{(async()=>{if(e)try{i(!0),l(null);let t=await fetch(`/api/listings/full?listingId=${e}`);if(!t.ok)throw Error(`Failed to fetch listing: ${t.statusText}`);let a=await t.json();r(a)}catch(e){console.error("Error fetching full listing:",e),l(e instanceof Error?e.message:"Failed to fetch listing")}finally{i(!1)}})()},[e]),{listing:t,isLoading:s,error:n}}],760080);var tD=e.i(612059);e.s(["Gavel",()=>tD.default],155274)},228142,193664,543863,246780,169284,58765,972080,143527,542843,848968,114724,503002,e=>{"use strict";e.s(["TaskModal",()=>tL],246780),e.s(["TaskSidebar",()=>tN],228142);var t=e.i(843476),a=e.i(271645),r=e.i(846932),s=e.i(88653),i=e.i(124252),n=e.i(908263),l=e.i(904257),o=e.i(92167),d=e.i(839221),c=e.i(877223),m=e.i(32979),u=e.i(843409),h=e.i(410839),x=e.i(886263),g=e.i(673811),p=e.i(37020),b=e.i(675897),f=e.i(503116),y=e.i(761911),w=e.i(548433),v=e.i(934972),k=e.i(694351),j=e.i(373375),N=e.i(463059),C=e.i(778917),S=e.i(63209),E=e.i(269638),I=e.i(870273),T=e.i(25652),_=e.i(212426),A=e.i(178583),D=e.i(354385),P=e.i(37727),R=e.i(442896),M=e.i(760080),F=e.i(155274),L=e.i(227516),$=e.i(39312),O=e.i(346897),U=e.i(300297),B=e.i(77941),q=e.i(75998),z=e.i(526050),H=e.i(383652);function V({task:e,listing:r,isOpen:s,onClose:i,onSuccess:n,expressInterestMode:l=!1}){let[o,d]=(0,a.useState)(""),[c,m]=(0,a.useState)(""),[u,h]=(0,a.useState)(""),[x,g]=(0,a.useState)(!1),[p,b]=(0,a.useState)([]),[y,w]=(0,a.useState)(!1),{submitBid:v}=(0,H.useMarketplaceTasks)(),k=e?.listing?.id||e?.metadata?.listing?.id||r?.id,j=r?.currency||"USD",N={USD:"$",EUR:"â¬",GBP:"£",CAD:"C$",AUD:"A$",NZD:"NZ$",JPY:"Â¥",CNY:"Â¥",KRW:"â©",INR:"â¹",RUB:"â½",BRL:"R$",MXN:"$",CHF:"CHF",SEK:"kr",NOK:"kr",DKK:"kr",PLN:"zÅ",CZK:"KÄ",HUF:"Ft",ILS:"âª",TRY:"âº",ZAR:"R",SGD:"S$",HKD:"HK$",THB:"฿"}[j?.toUpperCase()]||j?.toUpperCase()||"$",{quote:C,isLoading:S}=function(e,t){let[r,s]=(0,a.useState)(null),[i,n]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{if(!t||!e){s(null),n(!1);return}let a=!1;return n(!0),fetch(`/api/tasks/marketplace/bids/express-interest-quote?listingId=${encodeURIComponent(String(e))}`).then(async e=>{if(!e.ok)throw Error(`quote failed: ${e.status}`);return await e.json()}).then(e=>{a||s(e)}).catch(e=>{console.error("[useExpressInterestQuote] failed:",e),a||s(null)}).finally(()=>{a||n(!1)}),()=>{a=!0}},[e,t]),{quote:r,isLoading:i}}(k,!!(s&&l)),E=C?.estimatedDurationMinutes??null,I=C?.amount??null,T=!!C&&!S,D=l?null!==I&&E?I.toFixed(2):"":o;(0,a.useEffect)(()=>{(async()=>{if(s&&e?.category&&r?.id&&!l){w(!0);try{let t=await fetch(`/api/tasks/marketplace/bids/previous?category=${e.category}&listingId=${r.id}`);if(t.ok){let e=await t.json();b(e.bids||[])}}catch(e){console.error("Error fetching previous bids:",e)}finally{w(!1)}}})()},[s,e?.category,r?.id,l]);let P=async()=>
58{if(!D||!v)return;let t=l?E??void 0:u?parseInt(u):void 0,a=l?"Auto-calculated based on hourly rate and estimated cleaning time":c||void 0;g(!0);try{await v({taskId:parseInt(e.id),bidAmount:parseFloat(D),currency:j,estimatedDuration:t,notes:a,mode:l?"interest":"bid"}),d(""),m(""),h(""),i(),n?.()}catch(e){console.error("Error submitting bid:",e)}finally{g(!1)}},M=()=>{x||i()},G=p.reduce((e,t)=>(e.find(e=>e.amount===t.amount)||e.push(t),e),[]).slice(0,3);return(0,t.jsxs)(U.Dialog,{open:s,onOpenChange:M,children:[s&&(0,t.jsx)("div",{className:"fixed inset-0 z-[9998] bg-black/80 backdrop-blur-sm"}),(0,t.jsxs)(U.DialogContent,{className:"fixed z-[9999] top-[50%] left-[50%] translate-x-[-50%] translate-y-[-50%] w-[95vw] max-w-md max-h-[90vh] overflow-y-auto bg-white dark:bg-[#1A1A1C] border border-gray-200 dark:border-white/[0.1] rounded-2xl shadow-2xl",children:[(0,t.jsxs)(U.DialogHeader,{className:"sticky top-0 bg-white dark:bg-[#1A1A1C] pb-4 border-b border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsxs)(U.DialogTitle,{className:"flex items-center gap-2 text-lg",children:[(0,t.jsx)(F.Gavel,{className:l?"w-5 h-5 text-blue-400":"w-5 h-5 text-purple-400"}),l?"Express Interest":"Place Bid"]}),(0,t.jsx)(U.DialogDescription,{className:"text-gray-500 dark:text-white/60",children:l?"Confirm your interest in this task. The bid amount is automatically calculated based on your hourly rate.":"Submit your bid for this marketplace task. Include your price and estimated completion time."})]}),(0,t.jsxs)("div",{className:"grid gap-6 py-6 px-6",children:[(0,t.jsxs)("div",{className:"bg-gradient-to-br from-purple-500/10 to-blue-500/10 rounded-xl p-4 border border-purple-500/20",children:[(0,t.jsxs)("h4",{className:"font-medium text-gray-700 dark:text-white/90 mb-2 flex items-center gap-2",children:[(0,t.jsx)(A.FileText,{className:"w-4 h-4 text-purple-400"}),e.title]}),(0,t.jsxs)("div",{className:"flex flex-col gap-2 text-sm text-gray-500 dark:text-white/60",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)(f.Clock,{className:"w-4 h-4"}),"Due ",(()=>{let t=e.dueDate||e?.due_date;if(!t)return"No due date";try{return new Date(t).toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return"Invalid date"}})()]}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)(O.MapPin,{className:"w-4 h-4"}),e.location?e.location:r?.location?.city?r.location.city:"Location not specified"]})]})]}),l&&null!==I&&E&&(0,t.jsx)("div",{className:"bg-gradient-to-br from-blue-500/10 to-green-500/10 rounded-xl p-4 border border-blue-500/20",children:(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsx)("span",{className:"text-sm text-gray-500 dark:text-white/60",children:"Estimated Time:"}),(0,t.jsxs)("span",{className:"text-lg font-medium text-gray-900 dark:text-white",children:[(E/60).toFixed(1)," hours"]})]}),(0,t.jsxs)("div",{className:"border-t border-gray-200 dark:border-white/10 pt-3 flex justify-between items-center",children:[(0,t.jsx)("span",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:"Calculated Amount:"}),(0,t.jsxs)("span",{className:"text-2xl font-bold text-green-400",children:[N,D]})]})]})}),l&&T&&!C?.hasRate&&(0,t.jsx)("div",{className:"bg-red-500/10 rounded-xl p-4 border border-red-500/20",children:(0,t.jsx)("p",{className:"text-sm text-red-400",children:"Your workspace admin hasn't set your hourly rate yet, so this bid can't be calculated. Ask them to set it, then express interest again."})}),l&&T&&C?.hasRate&&!E&&(0,t.jsx)("div",{className:"bg-yellow-500/10 rounded-xl p-4 border border-yellow-500/20",children:(0,t.jsx)("p",{className:"text-sm text-yellow-400",children:"This property doesn't have an estimated cleaning time set. Please contact the admin."})}),!l&&G.length>0&&(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(L.History,{className:"w-4 h-4 text-blue-400"}),(0,t.jsx)(B.Label,{className:"text-sm font-medium text-gray-700 dark:text-white/90",children:"Previous Bids for Similar Tasks"})]}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:G.map((e,a)=>(0,t.jsxs)(R.Button,{variant:"outline",size:"sm",onClick:()=>{d(e.amount.toString()),e.estimatedDuration&&h(e.estimatedDuration.toString()),e.notes&&m(e.notes)},disabled:x,className:"text-xs bg-blue-500/10 border-blue-500/30 text-blue-300 hover:bg-blue-500/20 transition-all duration-200",children:[(0,t.jsx)($.Zap,{className:"w-3 h-3 mr-1"}),N,e.amount,e.estimatedDuration&&(0,t.jsxs)("span",{className:"ml-1 text-blue-400/70",children:["⢠",Math.round(e.estimatedDuration/60),"h"]})]},e.id))}),(0,t.jsxs)("p",{className:"text-xs text-gray-500 dark:text-white/50",children:["Click to auto-fill based on your previous ",e.category," bids at this property"]})]}),!l&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)(B.Label,{htmlFor:"bid-amount",className:"flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-white/90",children:[(0,t.jsx)(_.DollarSign,{className:"w-4 h-4 text-green-400"}),"Bid Amount (",j,") *"]}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("span",{className:"absolute left-4 top-1/2 -translate-y-1/2 text-gray-500 dark:text-white/60 text-sm font-medium",children:N}),(0,t.jsx)(q.Input,{id:"bid-amount",type:"number",step:"0.01",min:"0",placeholder:"Enter your bid amount",value:o,onChange:e=>d(e.target.value),className:"bg-gray-50 dark:bg-white/5 border-gray-300 dark:border-white/20 pl-10 h-12 text-lg font-medium text-gray-900 dark:text-white placeholder:text-gray-400 dark:text-white/40 focus:border-purple-500/50 focus:ring-2 focus:ring-purple-500/20",disabled:x})]})]}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)(B.Label,{htmlFor:"estimated-duration",className:"flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-white/90",children:[(0,t.jsx)(f.Clock,{className:"w-4 h-4 text-blue-400"}),"Estimated Duration (minutes)"]}),(0,t.jsx)(q.Input,{id:"estimated-duration",type:"number",min:"0",placeholder:"e.g., 120",value:u,onChange:e=>h(e.target.value),className:"bg-gray-50 dark:bg-white/5 border-gray-300 dark:border-white/20 h-12 text-gray-900 dark:text-white placeholder:text-gray-400 dark:text-white/40 focus:border-blue-500/50 focus:ring-2 focus:ring-blue-500/20",disabled:x})]}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(B.Label,{htmlFor:"bid-notes",className:"text-sm font-medium text-gray-700 dark:text-white/90",children:"Notes (optional)"}),(0,t.jsx)(z.Textarea,{id:"bid-notes",placeholder:"Add any specific notes about your approach, availability, or special considerations...",value:c,onChange:e=>m(e.target.value),className:"bg-gray-50 dark:bg-white/5 border-gray-300 dark:border-white/20 min-h-[100px] text-gray-900 dark:text-white placeholder:text-gray-400 dark:text-white/40 focus:border-white/40 focus:ring-2 focus:ring-gray-200 dark:ring-white/10 resize-none",disabled:x})]})]}),l&&S&&(0,t.jsxs)("div",{className:"flex items-center justify-center gap-2 text-sm text-gray-500 dark:text-white/60 py-4",children:[(0,t.jsx)("div",{className:"w-4 h-4 border-2 border-gray-300 dark:border-white/20 border-t-blue-500 rounded-full animate-spin"}),"Loading property details..."]}),y&&(0,t.jsxs)("div",{className:"flex items-center justify-center gap-2 text-sm text-gray-500 dark:text-white/60 py-4",children:[(0,t.jsx)("div",{className:"w-4 h-4 border-2 border-gray-300 dark:border-white/20 border-t-purple-500 rounded-full animate-spin"}),"Loading previous bids..."]})]}),(0,t.jsxs)(U.DialogFooter,{className:"sticky bottom-0 bg-white dark:bg-[#1A1A1C] pt-4 border-t border-gray-200 dark:border-white/[0.08] px-6 pb-6 flex gap-3",children:[(0,t.jsx)(R.Button,{variant:"outline",onClick:M,disabled:x,className:"flex-1 h-12 text-gray-600 dark:text-white/80 border-gray-300 dark:border-white/20 hover:bg-gray-100 dark:hover:bg-white/5",children:"Cancel"}),(0,t.jsx)(R.Button,{onClick:P,disabled:x||!D,className:l?"flex-1 h-12 bg-gradient-to-r from-blue-600 to-blue-500 hover:from-blue-700 hover:to-blue-600 text-gray-900 dark:text-white font-medium shadow-lg disabled:opacity-50 disabled:cursor-not-allowed":"flex-1 h-12 bg-gradient-to-r from-purple-600 to-purple-500 hover:from-purple-700 hover:to-purple-600 text-gray-900 dark:text-white font-medium shadow-lg disabled:opacity-50 disabled:cursor-not-allowed",children:x?(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("div",{className:"w-4 h-4 border-2 border-gray-300 dark:border-white/30 border-t-gray-700 dark:border-t-white rounded-full animate-spin"}),l?"Confirming...":"Submitting..."]}):l?"Confirm Interest":"Submit Bid"})]})]})]})}e.s(["BidSubmissionDialog",0,V],193664);var G=e.i(553475);function W({listing:e,compact:a=!1,showMapsButton:r=!0,showAccessInstructions:s=!0,className:i=""}){if(!e)return null;let n=e.serviceProviderAccess,l=n?.htmlContent;return(0,t.jsxs)("div",{className:`space-y-4 ${i}`,children:[(0,t.jsxs)("div",{className:"bg-white dark:bg-[#1A1A1C] rounded-2xl p-4 border border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsxs)("h3",{className:"text-gray-900 dark:text-white font-medium mb-3 flex items-center",children:[(0,t.jsx)(O.MapPin,{className:"w-4 h-4 mr-2 text-blue-400"}),"Property Address"]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("p",{className:"text-gray-700 dark:text-white/90",children:[e.location?.address,e.location?.apt&&`, ${e.location?.apt}`]}),(0,t.jsxs)("p",{className:"text-gray-500 dark:text-white/60 text-sm",children:[e.location?.city,", ",e.location?.state," ",e.location?.z
58ipcode]})]}),r&&(0,t.jsxs)(R.Button,{variant:"outline",size:"sm",className:"mt-3 w-full",onClick:()=>{let t;return window.open((t=[e.location?.address,e.location?.apt,e.location?.city,e.location?.state,e.location?.zipcode].filter(Boolean).join(", "),`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(t)}`),"_blank")},children:[(0,t.jsx)(O.MapPin,{className:"w-4 h-4 mr-2"}),"Open in Google Maps",(0,t.jsx)(C.ExternalLink,{className:"w-3 h-3 ml-2"})]})]}),l&&s&&(0,t.jsxs)("div",{className:"bg-white dark:bg-[#1A1A1C] rounded-2xl p-4 border border-green-500/20",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2 mb-3",children:[(0,t.jsx)("div",{className:"w-2 h-2 bg-green-400 rounded-full"}),(0,t.jsx)("h3",{className:"text-green-400 font-medium",children:"Service Provider Instructions"})]}),(0,t.jsx)("p",{className:"text-gray-600 dark:text-white/80 text-sm mb-4",children:"These instructions have been customized for service providers working at this property."}),(0,t.jsx)("div",{className:"prose dark:prose-invert prose-sm max-w-none\n prose-headings:text-gray-900 dark:prose-headings:text-white prose-headings:font-medium prose-headings:mb-3\n prose-p:text-gray-700 dark:prose-p:text-white/90 prose-p:mb-2 prose-p:leading-relaxed\n prose-strong:text-gray-900 dark:prose-strong:text-white prose-strong:font-medium\n prose-ul:text-gray-700 dark:prose-ul:text-white/90 prose-li:mb-1\n [&_h2]:text-lg [&_h2]:border-b [&_h2]:border-gray-200 dark:[&_h2]:border-white/20 [&_h2]:pb-2 [&_h2]:mb-4\n [&_p]:text-sm [&_li]:text-sm",dangerouslySetInnerHTML:{__html:n.htmlContent}})]}),(0,t.jsxs)("div",{className:"bg-white dark:bg-[#1A1A1C] rounded-2xl p-4 border border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsxs)("h3",{className:"text-gray-900 dark:text-white font-medium mb-3 flex items-center",children:[(0,t.jsx)(G.Wifi,{className:"w-4 h-4 mr-2 text-blue-400"}),"WiFi & Utilities"]}),(0,t.jsxs)("div",{className:"space-y-2",children:[e.wifi?.network&&(0,t.jsxs)("div",{className:"p-3 bg-blue-500/10 border border-blue-500/20 rounded-lg",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2 mb-2",children:[(0,t.jsx)(G.Wifi,{className:"w-4 h-4 text-blue-400"}),(0,t.jsx)("span",{className:"text-blue-400 text-sm font-medium",children:"ð¶ WiFi Access"})]}),(0,t.jsxs)("p",{className:"text-gray-600 dark:text-white/80 text-sm",children:["Network: ",(0,t.jsx)("span",{className:"text-gray-700 dark:text-white/90 font-mono",children:e.wifi.network})]}),e.wifi.password&&(0,t.jsxs)("p",{className:"text-gray-600 dark:text-white/80 text-sm",children:["Password: ",(0,t.jsx)("span",{className:"text-gray-700 dark:text-white/90 font-mono",children:e.wifi.password})]})]}),!e.wifi?.network&&(0,t.jsx)("div",{className:"p-3 bg-gray-500/10 border border-gray-500/20 rounded-lg",children:(0,t.jsx)("p",{className:"text-gray-400 text-sm",children:"ð¶ No WiFi information available."})})]})]})]})}var K=e.i(489853),Y=e.i(204997),J=e.i(292270),Q=e.i(65921);let X=["M","T","W","T","F","S","S"];function Z({listingId:e,taskDate:r,className:s}){var i,l;let[o,d]=(0,a.useState)(null),[c,m]=(0,a.useState)(!1),[u,h]=(0,a.useState)(null);if((0,a.useEffect)(()=>{if(!e)return;let t=!1;return(async()=>{m(!0),h(null);try{let a=await fetch(`/api/tasks/provider/listing-calendar?listingId=${e}`);if(!a.ok){if(403===a.status||401===a.status){t||d([]);return}throw Error(`Failed to load availability (${a.status})`)}let r=await a.json();t||d(Array.isArray(r?.days)?r.days:[])}catch(e){t||h(e instanceof Error?e.message:"Failed to load availability")}finally{t||m(!1)}})(),()=>{t=!0}},[e]),!e)return null;if(c)return(0,t.jsxs)("div",{className:(0,n.cn)("rounded-xl border border-gray-200 dark:border-white/[0.08] bg-white dark:bg-white/[0.02] p-4",s),children:[(0,t.jsx)(Q.Skeleton,{className:"h-4 w-32 mb-3"}),(0,t.jsx)("div",{className:"grid grid-cols-7 gap-1.5",children:Array.from({length:28}).map((e,a)=>(0,t.jsx)(Q.Skeleton,{className:"h-8 rounded-md"},a))})]});if(u||!o||0===o.length)return null;let x=(i=o[0].date,(new Date(`${i}T00:00:00Z`).getUTCDay()+6)%7);return(0,t.jsxs)("div",{className:(0,n.cn)("rounded-xl border border-gray-200 dark:border-white/[0.08] bg-white dark:bg-white/[0.02] p-4",s),children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,t.jsxs)("h3",{className:"text-sm font-medium text-gray-700 dark:text-white/90 flex items-center gap-2",children:[(0,t.jsx)(K.CalendarDays,{className:"w-4 h-4"}),"Availability"]}),(0,t.jsx)("span",{className:"text-xs text-gray-500 dark:text-white/50",children:(l=o[0].date,new Date(`${l}T00:00:00Z`).toLocaleDateString(void 0,{month:"long",year:"numeric",timeZone:"UTC"}))})]}),(0,t.jsx)("div",{className:"grid grid-cols-7 gap-1.5 mb-1.5",children:X.map((e,a)=>(0,t.jsx)("div",{className:"text-[10px] text-center text-gray-400 dark:text-white/40",children:e},a))}),(0,t.jsxs)("div",{className:"grid grid-cols-7 gap-1.5",children:[Array.from({length:x}).map((e,a)=>(0,t.jsx)("div",{},`b${a}`)),o.map(e=>{let a=!!r&&e.date===r.slice(0,10);return(0,t.jsxs)("div",{title:`${e.date} â ${e.isBooked?"Occupied":"Free"}${e.isCheckOut?" · check-out":""}${e.isCheckIn?" · check-in":""}`,className:(0,n.cn)("relative h-8 rounded-md flex items-center justify-center text-xs",e.isBooked?"bg-amber-500/15 text-amber-700 dark:text-amber-300":"bg-gray-100 dark:bg-white/[0.04] text-gray-600 dark:text-white/60",a&&"ring-2 ring-blue-500"),children:[Number(e.date.slice(8,10)),(e.isCheckOut||e.isCheckIn)&&(0,t.jsxs)("span",{className:"absolute bottom-0.5 right-0.5 flex gap-[1px]",children:[e.isCheckOut&&(0,t.jsx)(J.LogOut,{className:"w-2 h-2 text-rose-500"}),e.isCheckIn&&(0,t.jsx)(Y.LogIn,{className:"w-2 h-2 text-emerald-500"})]})]},e.date)})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3 mt-3 text-[10px] text-gray-500 dark:text-white/50",children:[(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)("span",{className:"w-2.5 h-2.5 rounded bg-amber-500/30"})," Occupied"]}),(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)(J.LogOut,{className:"w-2.5 h-2.5 text-rose-500"})," Check-out"]}),(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)(Y.LogIn,{className:"w-2.5 h-2.5 text-emerald-500"})," Check-in"]})]})]})}var ee=e.i(568612);function et({task:e,onClose:i}){var n;let l,o,d,[c,m]=(0,a.useState)(0),[u,h]=(0,a.useState)(null),[x,g]=(0,a.useState)(!0),[p,b]=(0,a.useState)(!1),[F,L]=(0,a.useState)(!1),$=(0,a.useRef)(null),O=(0,a.useRef)(null),{settings:U}=(0,ee.useUserSettings)(),B=e?.metadata?.listingId||e?.listing?.id,{listing:q,isLoading:z,error:H}=(0,M.useFullListing)(B),G=e?.marketplace_eligible||e?.marketplaceEligible,K=e?.assignments?.length>0,Y=U?.id&&e?.assignments?.some(e=>e.user_id===U.id),J=G&&!K&&!Y;if((0,a.useEffect)(()=>{let e=()=>{L(window.innerWidth<768)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),(0,a.useEffect)(()=>{e?.historicalAnalytics&&h({averageDuration:e.historicalAnalytics.averageDuration,completedTasks:e.historicalAnalytics.completedTasks,averageRating:e.historicalAnalytics.averageRating,lastCompleted:e.historicalAnalytics.lastCompleted}),g(!1)},[e]),z)return(0,t.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,t.jsx)("div",{className:"w-8 h-8 border-2 border-gray-300 dark:border-white/20 border-t-gray-700 dark:border-t-white/80 rounded-full animate-spin"})});if(H||!q)return(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-center p-6",children:[(0,t.jsx)(S.AlertCircle,{className:"w-12 h-12 text-red-400 mb-4"}),(0,t.jsx)("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"Unable to load listing"}),(0,t.jsx)("p",{className:"text-gray-500 dark:text-white/60 text-sm",children:H||"Listing information is not available for this task."})]});let Q=q.photos||[],X=Q.length>0,ea=()=>{m(e=>(e+1)%Q.length)},er=()=>{m(e=>(e-1+Q.length)%Q.length)},es=()=>{i()};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"h-full flex flex-col bg-white dark:bg-[#1A1A1C] relative",children:[(0,t.jsx)("div",{className:"flex-none border-b border-gray-200 dark:border-white/[0.08] p-4",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:q.name}),(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-white/60",children:"Property Details & Access"})]}),(0,t.jsx)(R.Button,{variant:"ghost",size:"sm",onClick:i,className:"text-gray-500 dark:text-white/60 hover:text-gray-900 dark:hover:text-white",children:(0,t.jsx)(P.X,{className:"w-4 h-4"})})]})}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[X&&(0,t.jsxs)("div",{className:"relative h-64 bg-gray-900",onTouchStart:e=>{$.current=e.targetTouches[0].clientX},onTouchMove:e=>{O.current=e.targetTouches[0].clientX},onTouchEnd:()=>
58{if(!$.current||!O.current)return;let e=$.current-O.current;e>50&&Q.length>1&&ea(),e<-50&&Q.length>1&&er(),$.current=null,O.current=null},children:[(0,t.jsx)(s.AnimatePresence,{mode:"wait",children:(0,t.jsx)(r.motion.img,{src:Q[c]?.largeUrl||Q[c]?.thumbnailUrl,alt:`Property photo ${c+1}`,className:"w-full h-full object-cover",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3}},c)}),Q.length>1&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{onClick:er,className:"absolute left-2 top-1/2 -translate-y-1/2 w-8 h-8 bg-black/50 hover:bg-black/70 rounded-full flex items-center justify-center text-white transition-colors",children:(0,t.jsx)(j.ChevronLeft,{className:"w-4 h-4"})}),(0,t.jsx)("button",{onClick:ea,className:"absolute right-2 top-1/2 -translate-y-1/2 w-8 h-8 bg-black/50 hover:bg-black/70 rounded-full flex items-center justify-center text-white transition-colors",children:(0,t.jsx)(N.ChevronRight,{className:"w-4 h-4"})}),(0,t.jsx)("div",{className:"absolute bottom-2 left-1/2 -translate-x-1/2 flex space-x-1",children:Q.map((e,a)=>(0,t.jsx)("button",{onClick:()=>m(a),className:`w-2 h-2 rounded-full transition-colors ${a===c?"bg-white":"bg-white/40"}`},a))})]}),(0,t.jsxs)("div",{className:"absolute top-2 right-2 bg-black/50 rounded-lg px-2 py-1 text-white text-xs",children:[c+1," / ",Q.length]})]}),(0,t.jsxs)("div",{className:"p-4 space-y-6",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-gray-700 dark:text-white/90 mb-3",children:"Property Overview"}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2 text-gray-600 dark:text-white/70",children:[(0,t.jsx)(y.Users,{className:"w-4 h-4"}),(0,t.jsxs)("span",{className:"text-sm",children:[q.details?.guests||0," guests"]})]}),(0,t.jsxs)("div",{className:"flex items-center space-x-2 text-gray-600 dark:text-white/70",children:[(0,t.jsx)(w.Bed,{className:"w-4 h-4"}),(0,t.jsxs)("span",{className:"text-sm",children:[q.details?.bedrooms||0," bedrooms"]})]}),(0,t.jsxs)("div",{className:"flex items-center space-x-2 text-gray-600 dark:text-white/70",children:[(0,t.jsx)(v.Bath,{className:"w-4 h-4"}),(0,t.jsxs)("span",{className:"text-sm",children:[q.details?.baths||0," bathrooms"]})]}),(0,t.jsxs)("div",{className:"flex items-center space-x-2 text-gray-600 dark:text-white/70",children:[(0,t.jsx)(k.Home,{className:"w-4 h-4"}),(0,t.jsxs)("span",{className:"text-sm",children:[q.details?.beds||0," beds"]})]})]})]}),(l=(e=>{let{nextReservation:t,due_date:a}=e;if(!t||!a||a.split("T")[0]!==t.checkIn)return null;let r=t.checkInTime||"3:00 PM";return{isSameDayCheckIn:!0,checkInTime:r.includes(":")?5===r.length?(()=>{let[e,t]=r.split(":"),a=parseInt(e);return`${0===a?12:a>12?a-12:a}:${t} ${a>=12?"PM":"AM"}`})():r:"3:00 PM",confirmationCode:t.confirmationCode,guestCount:t.guestDetails?.number_of_guests||1}})(e))?(0,t.jsx)("div",{className:"bg-amber-500/10 border border-amber-500/20 rounded-xl p-4",children:(0,t.jsxs)("div",{className:"flex items-center space-x-3 mb-3",children:[(0,t.jsx)("div",{className:"w-6 h-6 bg-amber-500/20 rounded-full flex items-center justify-center flex-shrink-0",children:(0,t.jsx)(f.Clock,{className:"w-3.5 h-3.5 text-amber-400"})}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2 mb-1",children:[(0,t.jsx)("div",{className:"w-2 h-2 rounded-full bg-amber-500 animate-pulse"}),(0,t.jsx)("span",{className:"text-amber-400 font-semibold text-sm",children:"Same-day Check-in"})]}),(0,t.jsxs)("p",{className:"text-amber-300/90 text-sm",children:["Guests arrive at ",(0,t.jsx)("span",{className:"font-semibold text-gray-900 dark:text-white",children:l.checkInTime})," ","(",l.guestCount," guest",1!==l.guestCount?"s":"",")"]}),(0,t.jsxs)("p",{className:"text-amber-300/70 text-xs mt-1",children:["Confirmation: ",(0,t.jsx)("span",{className:"font-mono text-xs",children:l.confirmationCode})," ","⢠Complete before guests arrive"]})]})]})}):null,(0,t.jsx)("div",{className:"border-t border-gray-200 dark:border-white/[0.08]"}),!x&&u&&u.averageDuration>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("h3",{className:"text-sm font-medium text-gray-700 dark:text-white/90 mb-3 flex items-center",children:[(0,t.jsx)(T.TrendingUp,{className:"w-4 h-4 mr-2"}),"Task Analytics"]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{className:"bg-gray-50 dark:bg-white/[0.05] rounded-lg p-3",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2 mb-1",children:[(0,t.jsx)(f.Clock,{className:"w-4 h-4 text-blue-400"}),(0,t.jsx)("span",{className:"text-xs text-gray-500 dark:text-white/60",children:"Avg Duration"})]}),(0,t.jsx)("p",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:(o=Math.floor((n=u.averageDuration)/60),d=n%60,o>0?`${o}h ${d}m`:`${d}m`)})]}),(0,t.jsxs)("div",{className:"bg-gray-50 dark:bg-white/[0.05] rounded-lg p-3",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2 mb-1",children:[(0,t.jsx)(E.CheckCircle,{className:"w-4 h-4 text-green-400"}),(0,t.jsx)("span",{className:"text-xs text-gray-500 dark:text-white/60",children:"Completed"})]}),(0,t.jsx)("p",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:u.completedTasks})]}),u.averageRating>0&&(0,t.jsxs)("div",{className:"bg-gray-50 dark:bg-white/[0.05] rounded-lg p-3 col-span-2",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2 mb-1",children:[(0,t.jsx)(I.Star,{className:"w-4 h-4 text-yellow-400"}),(0,t.jsx)("span",{className:"text-xs text-gray-500 dark:text-white/60",children:"Average Rating"})]}),(0,t.jsxs)("p",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:[u.averageRating.toFixed(1)," / 5.0"]})]})]})]}),(0,t.jsx)("div",{className:"border-t border-gray-200 dark:border-white/[0.08]"})]}),(0,t.jsx)(W,{listing:q,showMapsButton:!0,showAccessInstructions:Y}),Y&&(0,t.jsx)(Z,{listingId:q?.id,taskDate:e?.dueDate||e?.due_date||e?.startDate}),F&&(0,t.jsxs)("div",{className:"border-t border-gray-200 dark:border-white/[0.08] pt-6",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-gray-700 dark:text-white/90 mb-3",children:"Task Details"}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,t.jsxs)(R.Button,{variant:"outline",size:"sm",onClick:es,className:"flex items-center justify-center",children:[(0,t.jsx)(D.ClipboardCheck,{className:"w-4 h-4 mr-2"}),"View Checklist"]}),(0,t.jsxs)(R.Button,{variant:"outline",size:"sm",onClick:es,className:"flex items-center justify-center",children:[(0,t.jsx)(A.FileText,{className:"w-4 h-4 mr-2"}),"Task Details"]}
58)]})]}),q.platformData?.airbnbUrl&&(0,t.jsx)("div",{className:"pt-4",children:(0,t.jsxs)(R.Button,{variant:"outline",size:"sm",className:"w-full",onClick:()=>window.open(q.platformData?.airbnbUrl,"_blank"),children:[(0,t.jsx)(C.ExternalLink,{className:"w-4 h-4 mr-2"}),"View on Airbnb"]})}),J&&(0,t.jsx)("div",{className:"h-20"})]})]}),J&&(0,t.jsx)("div",{className:"absolute bottom-0 left-0 right-0 bg-white dark:bg-[#1A1A1C] border-t border-purple-500/20 p-4",children:(0,t.jsxs)(R.Button,{onClick:()=>{b(!0)},className:"w-full bg-purple-500/20 text-purple-300 hover:bg-purple-500/30 border border-purple-500/30 font-medium",size:"lg",variant:"outline",children:[(0,t.jsx)(_.DollarSign,{className:"w-4 h-4 mr-2"}),"Submit Bid for This Task"]})})]}),(0,t.jsx)(V,{task:e,listing:q,isOpen:p,onClose:()=>b(!1),onSuccess:()=>{}})]})}var ea=e.i(878894),er=e.i(107233),es=e.i(968553),ei=e.i(278716),en=e.i(387951),el=e.i(195116),eo=e.i(400417),ed=e.i(365582),ec=e.i(561659),em=e.i(719708),eu=e.i(91144),eh=e.i(576844),ex=e.i(567847),eg=e.i(618566),ep=e.i(283390),eb=e.i(582903);let ef={damage:ea.AlertTriangle,maintenance:el.Wrench,cleaning:ea.AlertTriangle,access:O.MapPin,supplies:A.FileText,other:ea.AlertTriangle},ey={reported:{label:"Reported",color:"text-yellow-400",bgColor:"bg-yellow-500/10",borderColor:"border-yellow-500/20"},investigating:{label:"Investigating",color:"text-blue-400",bgColor:"bg-blue-500/10",borderColor:"border-blue-500/20"},resolved:{label:"Resolved",color:"text-green-400",bgColor:"bg-green-500/10",borderColor:"border-green-500/20"},blocked:{label:"Blocked",color:"text-red-400",bgColor:"bg-red-500/10",borderColor:"border-red-500/20"}};function ew({task:e,onUpdate:s,canEdit:i,canEditStructure:l}){let[o,d]=(0,a.useState)(!1),[c,m]=(0,a.useState)(null),[u,h]=(0,a.useState)(null),[x,g]=(0,a.useState)(null),[p,b]=(0,a.useState)(!1),y=(0,a.useRef)(!1),{openCommandPalette:w,setCommandPaletteContext:v}=(0,ex.useCommandPalette)(),j=(0,eg.useRouter)(),S=(0,eg.useSearchParams)(),I=(0,a.useCallback)(async t=>{if(!y.current){y.current=!0;try{let a=`/api/tasks/${e.id}/issues`.replace("/api","https://api.vanio.ai"),r=await fetch(a,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:t.type,description:t.description,location:t.location,photos:t.photos?.map(e=>e?.url||e),voiceRecordings:t.voiceRecordings,videos:t.videos,isBlocking:t.isBlocking,metadata:t.metadata})});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error||"Failed to report issue")}b(!1),Promise.resolve(s()).catch(e=>{console.error("[TaskIssuesPanel] Background refresh after add failed:",e)})}catch(e){throw console.error("[TaskIssuesPanel] Error adding issue:",e),y.current=!1,e}}},[e.id,s]),D=e=>({USD:"$",EUR:"â¬",GBP:"£",CAD:"C$",AUD:"A$",NZD:"NZ$",JPY:"Â¥",CNY:"Â¥",KRW:"â©",INR:"â¹",RUB:"â½",BRL:"R$",MXN:"$",CHF:"CHF",SEK:"kr",NOK:"kr",DKK:"kr",PLN:"zÅ",CZK:"KÄ",HUF:"Ft",ILS:"âª",TRY:"âº",ZAR:"R",SGD:"S$",HKD:"HK$",THB:"฿"})[e?.toUpperCase()]||e?.toUpperCase()||"$",P=e?.issues||[],R=P.filter(e=>"resolved"!==e.status),M=P.filter(e=>e.is_blocking&&"resolved"!==e.status),F=e?.propertyIssues||[],L=F.slice(0,10),$=F.length>10,U=(0,a.useCallback)(e=>{if(!e)return;let t=new URLSearchParams(S?.toString()||"");t.set("task",String(e)),t.set("issues","true"),j.push(`${window.location.pathname}?${t.toString()}`)},[j,S]);P.filter(e=>e.metadata?.bidAdjustment?.status==="pending");let B=P.filter(e=>e.metadata?.bidAdjustment?.status==="approved");B.reduce((e,t)=>e+(t.metadata?.bidAdjustment?.requestedAmount||0),0),B[0]?.metadata?.bidAdjustment?.requestedCurrency||e?.listing?.currency;let q=e?.bids?.find(e=>"accepted"===e.status),z=q?.adjustments||[],H=z.filter(e=>"pending"===e.status),V=z.filter(e=>"approved"===e.status),G=V.reduce((e,t)=>e+(t.amount||0),0),W=V.length>0?V[0].currency||e?.listing?.currency||"USD":e?.listing?.currency||"USD",K=e=>z.find(t=>t.issueId===e),Y=(0,a.useMemo)(()=>{let e={};P.forEach(t=>{let a=t.location||"General";e[a]||(e[a]=[]),e[a].push(t)});let t=Object.keys(e).sort((e,t)=>"General"===e?1:"General"===t?-1:e.localeCompare(t)),a={};return t.forEach(t=>{a[t]=e[t]}),a},[P]),J=(0,a.useCallback)(async t=>{if(i){m(t);try{let a=`/api/tasks/${e.id}/issues`.replace("/api","https://api.vanio.ai");if(!(await fetch(a,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({issueId:t,action:"resolve"})})).ok)throw Error("Failed to resolve issue");await s()}catch(e){console.error("Error resolving issue:",e)}finally{m(null)}}},[e.id,s,i]),Q=(0,a.useCallback)(async(t,a,r)=>{if(i){h(t),g({id:t,action:a});try{let i=await fetch("/api/tasks/marketplace/bids",{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"}
58,body:JSON.stringify({action:"approve"===a?"approve_adjustment":"reject_adjustment",taskId:e.id,adjustmentId:t,reason:r})}),n=await i.json();if(!i.ok)throw console.error(`[TaskIssuesPanel] Failed to ${a} bid adjustment:`,n),Error(n.error||`Failed to ${a} bid adjustment`);await s()}catch(e){console.error(`Error ${a}ing bid adjustment:`,e)}finally{h(null),g(null)}}},[e.id,s,i]),X=e=>{if(!e)return!1;let t=e.toLowerCase();return[".mp3",".wav",".m4a",".aac",".ogg",".webm",".opus"].some(e=>t.includes(e))||t.includes("audio")},Z=(e=[])=>({actualPhotos:e.filter(e=>!X(e.url)),audioFiles:e.filter(e=>X(e.url))}),ee=(0,a.useCallback)(async t=>{if(!l)return;console.log("[TaskIssuesPanel] Opening command palette for task creation with issue:",t);let a=(e=>{let t=[],{actualPhotos:a,audioFiles:r}=Z(e.photos||[]),s=e.voice_recordings||[],i=e.videos||[];if(a.length>0&&t.push(`ð¸ ${a.length} photo${1!==a.length?"s":""}`),r.length>0||s.length>0){let e=r.length+s.length;t.push(`ð¤ ${e} voice recording${1!==e?"s":""}`)}return(i.length>0&&t.push(`ð¥ ${i.length} video${1!==i.length?"s":""}`),0===t.length)?"":` 59 60ð Attachments from issue: 61${t.map(e=>`⢠${e}`).join("\n")}`})(t),r=(e=>{let t={photos:[],voiceRecordings:[],videos:[]};if(e.photos?.length>0){let{actualPhotos:a,audioFiles:r}=Z(e.photos);t.photos=a,t.voiceRecordings=[...t.voiceRecordings,...r]}return e.voice_recordings?.length>0&&(t.voiceRecordings=[...t.voiceRecordings,...e.voice_recordings]),e.videos?.length>0&&(t.videos=e.videos),t})(t),s=`Follow-up task to resolve the reported issue: 62 63${t.description}${a}`,i=e.reservationId||e.metadata?.reservationId||e.metadata?.reservation?.id||e.relations?.find(e=>"reservation"===e.entityType||e.reservation_id)?.entityId||e.relations?.find(e=>e.reservation_id)?.reservation_id;v({context:"task",initialQuery:"Create Task",initialSelection:"34",metadata:{task:e,listing:{id:e.metadata?.listingId||e.relations?.find(e=>e.listing_id)?.listing_id},reservation:e.metadata?.reservation||(i?{id:i}:void 0),reservationId:i,suggestedTitle:`${t.title}`,suggestedDescription:s,suggestedCategory:et(t),suggestedPriority:t.is_blocking?"urgent":"high",relatedIssueId:t.id,issueType:t.title.split(":")[0]?.toLowerCase()||"other",location:t.location,issueAttachments:r,hasAttachments:r.photos.length+r.voiceRecordings.length+r.videos.length>0}}),console.log("[TaskIssuesPanel] Context set, opening palette..."),w()},[e,l,v,w]),et=e=>({damage:"maintenance",maintenance:"maintenance",cleaning:"cleaning",access:"other",supplies:"purchase",other:"other"})[e.title.split(":")[0]?.toLowerCase()||"other"]||"other",el=a=>{let s,d,m=ey[a.status]||ey.reported,u=ef[a.type||"other"]||ea.AlertTriangle,h=c===a.id;return(0,t.jsxs)(r.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:(0,n.cn)("bg-white dark:bg-white/[0.02] border rounded-lg p-4 space-y-4",m.borderColor,a.is_blocking&&"ring-1 ring-red-500/20"),children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,t.jsxs)("div",{className:"flex items-start space-x-3 flex-1 min-w-0",children:[(0,t.jsx)("div",{className:(0,n.cn)("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0",m.bgColor),children:(0,t.jsx)(u,{className:(0,n.cn)("w-4 h-4",m.color)})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-start flex-col space-y-0",children:[(0,t.jsx)("h4",{className:"text-sm font-medium text-gray-900 dark:text-white break-words",children:a.title}),(0,t.jsxs)("div",{className:"flex items-center space-x-2 flex-wrap",children:[a.is_blocking&&(0,t.jsx)(eu.Badge,{variant:"destructive",className:"text-xs",children:"Blocking"}),a.isFromSubtask&&(0,t.jsxs)(eu.Badge,{variant:"outline",className:"text-xs bg-blue-500/10 text-blue-400 border-blue-500/20",children:["From subtask: ",a.subtaskTitle]})]})]}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/60 line-clamp-2 break-words",children:a.description}),(0,t.jsxs)("div",{className:"flex items-center space-x-4 mt-1 text-xs text-gray-400 dark:text-white/40",children:[(0,t.jsx)("span",{children:(0,eh.formatDistanceToNow)(new Date(a.created_at),{addSuffix:!0})}),a.location&&(0,t.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,t.jsx)(O.MapPin,{className:"w-3 h-3"}),(0,t.jsx)("span",{children:a.location})]})]})]})]}),(0,t.jsx)("div",{className:(0,n.cn)("px-2 py-1 rounded-full text-xs font-medium flex-shrink-0",m.bgColor,m.color),children:m.label})]}),(a.photos?.length>0||a.voice_recordings?.length>0||a.videos?.length>0)&&(0,t.jsxs)("div",{className:"space-y-3",children:[a.photos?.length>0&&(()=>{let{actualPhotos:e,audioFiles:r}=Z(a.photos);return(0,t.jsxs)(t.Fragment,{children:[e.length>0&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,t.jsx)(es.Camera,{className:"w-3 h-3 text-gray-500 dark:text-white/60"}),(0,t.jsxs)("span",{className:"text-xs text-gray-500 dark:text-white/60",children:[e.length," photo",1!==e.length?"s":""]})]}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-2",children:e.map((e,a)=>(0,t.jsxs)("div",{className:"relative aspect-video bg-gray-50 dark:bg-white/5 rounded-lg overflow-hidden border border-gray-200 dark:border-white/10",children:[(0,t.jsx)("img",{src:e.url,alt:e.caption||`Photo ${a+1}
63`,className:"w-full h-full object-cover cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>window.open(e.url,"_blank")}),e.caption&&(0,t.jsx)("div",{className:"absolute bottom-0 left-0 right-0 bg-black/50 text-white text-xs p-1 truncate",children:e.caption})]},a))})]}),r.length>0&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,t.jsx)(en.Mic,{className:"w-3 h-3 text-gray-500 dark:text-white/60"}),(0,t.jsxs)("span",{className:"text-xs text-gray-500 dark:text-white/60",children:[r.length," recording",1!==r.length?"s":""]})]}),(0,t.jsx)("div",{className:"space-y-2",children:r.map((e,a)=>(0,t.jsx)(ep.VoiceNotePlayer,{url:e.url,transcription:e.transcription,metadata:e.metadata||{duration:e.duration},showRemove:!1,showExternalLink:!0,variant:"default",className:"w-full"},a))})]})]})})(),a.voice_recordings?.length>0&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,t.jsx)(en.Mic,{className:"w-3 h-3 text-gray-500 dark:text-white/60"}),(0,t.jsxs)("span",{className:"text-xs text-gray-500 dark:text-white/60",children:[a.voice_recordings.length," recording",1!==a.voice_recordings.length?"s":""]})]}),(0,t.jsx)("div",{className:"space-y-2",children:a.voice_recordings.map((e,a)=>(0,t.jsx)(ep.VoiceNotePlayer,{url:e.url,transcription:e.transcription,metadata:e.metadata||{duration:e.duration},showRemove:!1,showExternalLink:!0,variant:"default",className:"w-full"},a))})]}),a.videos?.length>0&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,t.jsx)(ei.Video,{className:"w-3 h-3 text-gray-500 dark:text-white/60"}),(0,t.jsxs)("span",{className:"text-xs text-gray-500 dark:text-white/60",children:[a.videos.length," video",1!==a.videos.length?"s":""]})]}),(0,t.jsx)("div",{className:"grid grid-cols-1 gap-2",children:a.videos.map((e,a)=>(0,t.jsxs)("div",{className:"relative bg-gray-50 dark:bg-white/5 rounded-lg overflow-hidden border border-gray-200 dark:border-white/10",children:[(0,t.jsxs)("video",{controls:!0,className:"w-full aspect-video",poster:e.thumbnail,children:[(0,t.jsx)("source",{src:e.url,type:"video/mp4"}),(0,t.jsx)("source",{src:e.url,type:"video/webm"}),"Your browser does not support the video element."]}),e.caption&&(0,t.jsx)("div",{className:"p-2 text-xs text-gray-600 dark:text-white/70",children:e.caption}),e.duration&&(0,t.jsxs)("div",{className:"absolute top-2 right-2 bg-black/50 text-white text-xs px-1 py-0.5 rounded",children:[Math.round(e.duration),"s"]})]},a))})]})]}),(s=K(a.id))?(0,t.jsxs)("div",{className:(0,n.cn)("border rounded-lg p-4 space-y-3","pending"===s.status&&"bg-yellow-500/5 border-yellow-500/20","approved"===s.status&&"bg-green-500/5 border-green-500/20","rejected"===s.status&&"bg-red-500/5 border-red-500/20"),children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsxs)("div",{className:(0,n.cn)("w-6 h-6 rounded-full flex items-center justify-center","pending"===s.status&&"bg-yellow-500/20","approved"===s.status&&"bg-green-500/20","rejected"===s.status&&"bg-red-500/20"),children:["pending"===s.status&&(0,t.jsx)(_.DollarSign,{className:"w-3 h-3 text-yellow-400"}),"approved"===s.status&&(0,t.jsx)(eo.ThumbsUp,{className:"w-3 h-3 text-green-400"}),"rejected"===s.status&&(0,t.jsx)(ed.ThumbsDown,{className:"w-3 h-3 text-red-400"})]}),(0,t.jsx)("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Bid Adjustment Request"})]}),(0,t.jsxs)(eu.Badge,{variant:"pending"===s.status?"secondary":"approved"===s.status?"default":"destructive",className:"text-xs",children:["pending"===s.status&&"Pending Approval","approved"===s.status&&"Approved","rejected"===s.status&&"Rejected"]})]}),(0,t.jsxs)("div",{className:"text-sm text-gray-600 dark:text-white/70",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,t.jsx)("span",{children:"Additional Cost:"}),(0,t.jsxs)("span",{className:"font-medium text-gray-900 dark:text-white",children:[D(s.currency||"USD"),s.amount]})]}),(0,t.jsxs)("div",{className:"text-xs text-gray-500 dark:text-white/50",children:["Requested ",(0,eh.formatDistanceToNow)(new Date(s.requestedAt),{addSuffix:!0})]})]}),"pending"===s.status&&i&&(0,t.jsxs)("div",{className:"flex space-x-2",children:[(0,t.jsxs)(em.Button,{size:"sm",variant:"secondary",onClick:()=>Q(s.id,"approve"),disabled:x?.id===s.id,className:"flex-1 bg-green-500/10 hover:bg-green-500/20 text-green-400 border-green-500/20",children:[x?.id===s.id&&x?.action==="approve"?(0,t.jsx)(r.motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},className:"w-4 h-4 border-2 border-green-400 border-t-transparent roun
63ded-full"}):(0,t.jsx)(eo.ThumbsUp,{className:"w-4 h-4 mr-2"}),"Approve"]}),(0,t.jsxs)(em.Button,{size:"sm",variant:"secondary",onClick:()=>Q(s.id,"reject","Not justified"),disabled:x?.id===s.id,className:"flex-1 bg-red-500/10 hover:bg-red-500/20 text-red-400 border-red-500/20",children:[x?.id===s.id&&x?.action==="reject"?(0,t.jsx)(r.motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},className:"w-4 h-4 border-2 border-red-400 border-t-transparent rounded-full"}):(0,t.jsx)(ed.ThumbsDown,{className:"w-4 h-4 mr-2"}),"Reject"]})]}),"approved"===s.status&&(0,t.jsxs)("div",{className:"text-xs text-green-400",children:["â Approved ",(0,eh.formatDistanceToNow)(new Date(s.approvedAt),{addSuffix:!0})]}),"rejected"===s.status&&(0,t.jsxs)("div",{className:"text-xs text-red-400",children:["â Rejected ",(0,eh.formatDistanceToNow)(new Date(s.rejectedAt),{addSuffix:!0})]})]}):a.metadata?.bidAdjustment?(0,t.jsx)("div",{className:(0,n.cn)("border rounded-lg p-4 space-y-3","pending"===a.metadata.bidAdjustment.status&&"bg-yellow-500/5 border-yellow-500/20","approved"===a.metadata.bidAdjustment.status&&"bg-green-500/5 border-green-500/20","rejected"===a.metadata.bidAdjustment.status&&"bg-red-500/5 border-red-500/20"),children:(0,t.jsx)("div",{className:"text-xs text-orange-400 mb-2",children:"â ï¸ Using legacy bid adjustment data - this should be migrated"})}):null,a.metadata?.costEstimation&&!a.metadata?.bidAdjustment&&(0,t.jsxs)("div",{className:"bg-orange-500/10 border border-orange-500/20 rounded-lg p-3",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2 mb-2",children:[(0,t.jsx)("div",{className:"w-5 h-5 bg-orange-500/20 rounded-full flex items-center justify-center",children:(0,t.jsx)(T.TrendingUp,{className:"w-3 h-3 text-orange-400"})}),(0,t.jsx)("span",{className:"text-sm font-medium text-orange-400",children:"Cost Impact"})]}),(0,t.jsxs)("div",{className:"text-sm text-gray-600 dark:text-white/70 space-y-1",children:[a.metadata.costEstimation.additionalTime&&(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{children:"Additional Time:"}),(0,t.jsxs)("span",{className:"text-gray-900 dark:text-white",children:[a.metadata.costEstimation.additionalTime," minutes"]})]}),a.metadata.costEstimation.additionalCost&&(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{children:"Additional Cost:"}),(0,t.jsxs)("span",{className:"font-medium text-gray-900 dark:text-white",children:[D(a.metadata.costEstimation.currency||"USD"),a.metadata.costEstimation.additionalCost]})]})]}),(()=>{if(!e.bids?.some(e=>"accepted"===e.status))return(0,t.jsx)("div",{className:"mt-3 p-2 bg-green-500/10 border border-green-500/20 rounded text-xs text-green-400",children:"â Additional time will be billed at hourly rate on next invoice"});{let e=K(a.id);if(!e)return(0,t.jsx)("div",{className:"mt-3 p-2 bg-blue-500/10 border border-blue-500/20 rounded text-xs text-blue-400",children:"â ï¸ Bid adjustment should have been created automatically. Check bid adjustments section."});if("pending"===e.status)return(0,t.jsxs)("div",{className:"mt-3 p-2 bg-yellow-500/10 border border-yellow-500/20 rounded text-xs text-yellow-400",children:["ð° Bid adjustment requested: +",D(e.currency||"USD"),e.amount,(0,t.jsx)("br",{}),(0,t.jsx)("span",{className:"text-gray-500 dark:text-white/60",children:"Use the buttons above to approve or reject this request."})]});if("approved"===e.status)return(0,t.jsxs)("div",{className:"mt-3 p-2 bg-green-500/10 border border-green-500/20 rounded text-xs text-green-400",children:["â Bid adjustment approved: +",D(e.currency||"USD"),e.amount]});else if("rejected"===e.status)return(0,t.jsxs)("div",{className:"mt-3 p-2 bg-red-500/10 border border-red-500/20 rounded text-xs text-red-400",children:["â Bid adjustment rejected: ",D(e.currency||"USD"),e.amount]})}})()]}),("excessive_cleaning"===(d=a.type||"other")||"damage"===d)&&"cleaning"===e.category&&e.sourceReservation&&(0,t.jsxs)("div",{className:"bg-purple-500/10 border border-purple-500/20 rounded-lg p-3",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2 mb-3",children:[(0,t.jsx)("div",{className:"w-5 h-5 bg-purple-500/20 rounded-full flex items-center justify-center",children:(0,t.jsx)(ec.CreditCard,{className:"w-3 h-3 text-purple-400"})}),(0,t.jsx)("span",{className:"text-sm font-medium text-purple-400",children:"Guest Claims"})]}),(0,t.jsxs)("div",{className:"space-y-2 mb-3",children:[(0,t.jsxs)("div",{className:"text-xs text-gray-600 dark:text-white/70",children:["Source: ","airbnb"===e.sourceReservation.platform?"Airbnb":e.sourceReservation.platform,"⢠Confirmation: ",e.sourceReservation.confirmationCode]}),(0,t.jsxs)("div",{className:"text-xs text-gray-500 dark:text-white/50",children:["Check-out: ",e.sourceReservation.checkOut]})]}),(0,t.jsx)("div",{className:"flex space-x-2",children:"airbnb"===e.sourceReservation.platform?(0,t.jsxs)(em.Button,{size:"sm",variant:"secondary",disabled:!0,className:"flex-1 bg-purple-500/10 hover:bg-purple-500/20 text-purple-400 border-purple-500/20 opacity-50 cursor-not-allowed",children:[(0,t.jsx)(C.ExternalLink,{className:"w-4 h-4 mr-2"}),"Open Airbnb Claim",(0,t.jsx)("span",{className:"ml-2 text-xs bg-yellow-500/20 text-yellow-400 px-2 py-0.5 rounded",children:"Coming Soon"})]}):(0,t.jsxs)(em.Button,{size:"sm",variant:"secondary",disabled:!0,className:"flex-1 bg-purple-500/10 hover:bg-purple-500/20 text-purple-400 border-purple-500/20 opacity-50 cursor-not-allowed",children:[(0,t.jsx)(C.ExternalLink,{className:"w-4 h-4 mr-2"}),"Open Guest Claim",(0,t.jsx)("span",{className:"ml-2 text-xs bg-yellow-500/20 text-yellow-400 px-2 py-0.5 rounded",children:"Coming Soon"})]})}),(0,t.jsx)("div",{className:"mt-2 text-xs text-gray-500 dark:text-white/50",children:"Create a claim with the guest for damages or excessive cleaning costs"})]}),a.created_task_id&&(0,t.jsxs)("div",{className:"bg-blue-500/10 border border-blue-500/20 rounded-lg p-3",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2 mb-2",children:[(0,t.jsx)("div",{className:"w-5 h-5 bg-blue-500/20 rounded-full flex items-center justify-center",children:(0,t.jsx)(A.FileText,{className:"w-3 h-3 text-blue-400"})}),(0,t.jsx)("span",{className:"text-sm font-medium text-blue-400",children:"Linked Task Created"})]}),(0,t.jsx)("p",{className:"text-xs text-gray-600 dark:text-white/70 mb-2",children:"A task was created to resolve this issue"}),(0,t.jsxs)(em.Button,{size:"sm",variant:"secondary",onClick:()=>{let e=new URLSearchParams(S?.toString()||"");e.set("task",String(a.created_task_id)),j.push(`${window.location.pathname}?${e.toString()}`)},className:"bg-blue-500/20 hover:bg-blue-500/30 text-blue-400 border-blue-500/30 text-xs",children:[(0,t.jsx)(A.FileText,{className:"w-3 h-3 mr-1"}),"View Task #",a.created_task_id]})]}),"resolved"!==a.status&&i&&(0,t.jsxs)("div",{className:"flex space-x-2",children:[(0,t.jsxs)(em.Button,{size:"sm",variant:"secondary",onClick:()=>J(a.id),disabled:h,className:"flex-1 bg-green-500/10 hover:bg-green-500/20 text-green-400 border-green-500/20",children:[h?(0,t.jsx)(r.motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},className:"w-4 h-4 border-2 border-green-400 border-t-transparent roun
63ded-full"}):(0,t.jsx)(E.CheckCircle,{className:"w-4 h-4 mr-2"}),h?"Resolving...":"Resolve"]}),l&&(0,t.jsxs)(em.Button,{size:"sm",variant:"secondary",onClick:()=>ee(a),disabled:o,className:"flex-1 bg-blue-500/10 hover:bg-blue-500/20 text-blue-400 border-blue-500/20",children:[(0,t.jsx)(er.Plus,{className:"w-4 h-4 mr-2"}),a.created_task_id?"Create Another Task":"Create Task"]})]})]},a.id)};return(0,t.jsxs)("div",{className:"bg-white dark:bg-[#1A1A1C] h-full flex flex-col",children:[(0,t.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,t.jsxs)("div",{className:"p-6 space-y-6",children:[(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,t.jsx)("div",{className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-4",children:(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsx)("div",{className:"w-8 h-8 bg-red-500/20 rounded-full flex items-center justify-center",children:(0,t.jsx)(ea.AlertTriangle,{className:"w-4 h-4 text-red-400"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:R.length}),(0,t.jsx)("div",{className:"text-xs text-gray-500 dark:text-white/60",children:"Unresolved Issues"})]})]})}),(0,t.jsx)("div",{className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-4",children:(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsx)("div",{className:"w-8 h-8 bg-orange-500/20 rounded-full flex items-center justify-center",children:(0,t.jsx)(f.Clock,{className:"w-4 h-4 text-orange-400"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:M.length}),(0,t.jsx)("div",{className:"text-xs text-gray-500 dark:text-white/60",children:"Blocking Issues"})]})]})}),(H.length>0||V.length>0)&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-4",children:(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsx)("div",{className:"w-8 h-8 bg-yellow-500/20 rounded-full flex items-center justify-center",children:(0,t.jsx)(_.DollarSign,{className:"w-4 h-4 text-yellow-400"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:H.length}),(0,t.jsx)("div",{className:"text-xs text-gray-500 dark:text-white/60",children:"Pending Adjustments"})]})]})}),(0,t.jsx)("div",{className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-4",children:(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsx)("div",{className:"w-8 h-8 bg-green-500/20 rounded-full flex items-center justify-center",children:(0,t.jsx)(T.TrendingUp,{className:"w-4 h-4 text-green-400"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:G>0?`${D(W)}${G.toFixed(2)}`:"0"}),(0,t.jsx)("div",{className:"text-xs text-gray-500 dark:text-white/60",children:"Additional Costs"})]})]})})]})]}),(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Task Issues"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[M.length>0&&(0,t.jsxs)(eu.Badge,{variant:"destructive",className:"text-xs",children:[M.length," Blocking"]}),(0,t.jsxs)(em.Button,{size:"sm",variant:"secondary",onClick:()=>{y.current=!1,b(!0)},className:"bg-orange-500/10 hover:bg-orange-500/20 text-orange-400 border-orange-500/20 text-xs",children:[(0,t.jsx)(er.Plus,{className:"w-4 h-4 mr-1"}),"Add Issue"]})]})]}),e?.originalIssue&&(0,t.jsxs)("div",{className:"bg-blue-500/10 border border-blue-500/20 rounded-lg p-3",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2 mb-2",children:[(0,t.jsx)("div",{className:"w-5 h-5 bg-blue-500/20 rounded-full flex items-center justify-center",children:(0,t.jsx)(A.FileText,{className:"w-3 h-3 text-blue-400"})}),(0,t.jsx)("span",{className:"text-sm font-medium text-blue-400",children:"Original Issue"})]}),(0,t.jsxs)("p",{className:"text-xs text-gray-600 dark:text-white/70 mb-2",children:["This task was created to resolve issue: ",e.originalIssue.title]}),(0,t.jsxs)(em.Button,{size:"sm",variant:"secondary",onClick:()=>{let t=new URLSearchParams(S?.toString()||""),a=e.parent?.id;a&&(t.set("task",String(a)),t.set("issues","true"),j.push(`${window.location.pathname}?${t.toString()}`))},className:"bg-blue-500/20 hover:bg-blue-500/30 text-blue-400 border-blue-500/30 text-xs",children:[(0,t.jsx)(A.FileText,{className:"w-3 h-3 mr-1"}),"View Original Task"]})]}),0===P.length?(0,t.jsxs)("div",{className:"text-center py-8",children:[(0,t.jsx)(E.CheckCircle,{className:"w-12 h-12 text-green-400 mx-auto mb-4"}),(0,t.jsx)("h4",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"No Issues Reported"}),(0,t.jsx)("p",{className:"text-gray-500 dark:text-white/60 text-sm mb-4",children:"This task is running smoothly with no reported issues."}),(0,t.jsxs)(em.Button,{size:"sm",variant:"secondary",onClick:()=>{y.current=!1,b(!0)},className:"bg-orange-500/10 hover:bg-orange-500/20 text-orange-400 border-orange-500/20 text-xs",children:[(0,t.jsx)(er.Plus,{className:"w-4 h-4 mr-1"}),"Add Issue"]})]}):(0,t.jsx)("div",{className:"space-y-6",children:Object.entries(Y).map(([e,a])=>(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsx)("div",{className:"w-6 h-6 bg-gray-100 dark:bg-white/[0.1] rounded-lg flex items-center justify-center",children:(0,t.jsx)(O.MapPin,{className:"w-3 h-3 text-gray-500 dark:text-white/60"})}),(0,t.jsx)("h4",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:e}),(0,t.jsxs)("div",{className:"text-xs text-gray-400 dark:text-white/40",children:[a.length," issue",1!==a.length?"s":""]}),a.some(e=>e.is_blocking&&"resolved"!==e.status)&&(0,t.jsx)(eu.Badge,{variant:"destructive",className:"text-xs",children:"Blocking"})]}),(0,t.jsx)("div",{className:"space-y-3 ml-9",children:a.map(el)})]},e))})]}),F.length>0&&(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)(k.Home,{className:"w-4 h-4 text-amber-400"}),(0,t.jsx)("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Other Open Issues for This Property"})]}),(0,t.jsxs)(eu.Badge,{variant:"outline",className:"text-xs bg-amber-500/10 text-amber-400 border-amber-500/20",children:[$?"10+":F.length," property-wide"]})]}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/60 -mt-2",children:"Unresolved
63issues reported on other tasks for this property. Review them during inspection."}),(0,t.jsx)("div",{className:"space-y-2",children:L.map(e=>{let a=ef[e.type||"other"]||ea.AlertTriangle,r=ey[e.status]||ey.reported;return(0,t.jsx)("button",{type:"button",onClick:()=>U(e.sourceTaskId),disabled:!e.sourceTaskId,className:(0,n.cn)("w-full text-left bg-white dark:bg-white/[0.02] border rounded-lg p-3 transition-colors",r.borderColor,e.is_blocking&&"ring-1 ring-red-500/20",e.sourceTaskId?"hover:bg-gray-50 dark:hover:bg-white/[0.04] cursor-pointer":"cursor-default"),children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("div",{className:(0,n.cn)("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0",r.bgColor),children:(0,t.jsx)(a,{className:(0,n.cn)("w-4 h-4",r.color)})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsx)("h4",{className:"text-sm font-medium text-gray-900 dark:text-white break-words",children:e.title}),e.is_blocking&&(0,t.jsx)(eu.Badge,{variant:"destructive",className:"text-xs",children:"Blocking"})]}),e.description&&(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/60 line-clamp-2 break-words mt-0.5",children:e.description}),(0,t.jsxs)("div",{className:"flex items-center space-x-3 mt-1 text-xs text-gray-400 dark:text-white/40",children:[(0,t.jsx)("span",{children:(0,eh.formatDistanceToNow)(new Date(e.created_at),{addSuffix:!0})}),e.location&&(0,t.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,t.jsx)(O.MapPin,{className:"w-3 h-3"}),(0,t.jsx)("span",{children:e.location})]}),e.sourceTaskTitle&&(0,t.jsxs)("div",{className:"flex items-center space-x-1 min-w-0",children:[(0,t.jsx)(A.FileText,{className:"w-3 h-3 flex-shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:e.sourceTaskTitle})]})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[(0,t.jsx)("span",{className:(0,n.cn)("px-2 py-1 rounded-full text-xs font-medium",r.bgColor,r.color),children:r.label}),e.sourceTaskId&&(0,t.jsx)(N.ChevronRight,{className:"w-4 h-4 text-gray-400 dark:text-white/40"})]})]})},`prop-${e.id}`)})}),$&&(0,t.jsxs)("p",{className:"px-1 text-xs text-gray-400 dark:text-white/40",children:["Showing the first ",10," â more open issues exist at this property."]})]}),P.length>0&&(0,t.jsxs)("div",{className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-4",children:[(0,t.jsx)("h4",{className:"text-sm font-medium text-gray-900 dark:text-white mb-3",children:"Marketplace Impact"}),(0,t.jsxs)("div",{className:"space-y-2 text-sm",children:[M.length>0&&(0,t.jsxs)("div",{className:"flex items-center space-x-2 text-red-400",children:[(0,t.jsx)(ea.AlertTriangle,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:"Task cannot be completed until blocking issues are resolved"})]}),R.length>0&&0===M.length&&(0,t.jsxs)("div",{className:"flex items-center space-x-2 text-yellow-400",children:[(0,t.jsx)(f.Clock,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:"Task may experience delays due to unresolved issues"})]}),0===R.length&&(0,t.jsxs)("div",{className:"flex items-center space-x-2 text-green-400",children:[(0,t.jsx)(E.CheckCircle,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:"All issues resolved - task ready for marketplace"})]})]})]})]})}),p&&(0,t.jsx)(eb.TaskExecutionIssueReport,{onClose:()=>b(!1),submitIssue:I,taskId:e.id,task:{id:e.id,category:e.category,title:e.title}})]})}var ev=e.i(959208),ek=e.i(201795);let ej={todo:{label:"To do",dot:"bg-white/40",text:"text-white/60"},pending:{label:"Pending",dot:"bg-yellow-400",text:"text-yellow-300/80"},in_progress:{label:"In progress",dot:"bg-blue-400",text:"text-blue-300/80"},blocked:{label:"Blocked",dot:"bg-red-400",text:"text-red-300/80"},failed:{label:"Needs attention",dot:"bg-orange-400",text:"text-orange-300/80"}};function eN({task:e,context:r="dashboard"}){let s=(0,ek.useTaskSidebar)(e=>e.openSidebar),i=(0,a.useMemo)(()=>Array.isArray(e?.sameDayPropertyTasks)?e.sameDayPropertyTasks:[],[e?.sameDayPropertyTasks]),l=(0,a.useMemo)(()=>
63{if(!e?.due_date)return null;let[t,a,r]=String(e.due_date).slice(0,10).split("-").map(Number);return t&&a&&r?new Date(t,a-1,r).toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric"}):null},[e?.due_date]),o=(0,a.useCallback)(e=>{s(String(e),r)},[s,r]),d=i.slice(0,10),c=i.length>10;return 0===i.length?null:(0,t.jsxs)("div",{className:"border-b border-white/[0.08] px-6 py-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,t.jsx)(ev.CalendarClock,{className:"w-4 h-4 text-white/50"}),(0,t.jsxs)("h3",{className:"text-sm font-medium text-white",children:["Also at this property",l?` on ${l}`:" today"]}),(0,t.jsx)("span",{className:"ml-1 px-1.5 py-0.5 rounded-full bg-white/[0.06] text-[11px] font-medium text-white/50",children:c?"10+":i.length})]}),(0,t.jsx)("ul",{className:"space-y-1",children:d.map(e=>{let a=ej[e.status||"todo"]||ej.todo;return(0,t.jsx)("li",{children:(0,t.jsxs)("button",{type:"button",onClick:()=>o(e.id),className:(0,n.cn)("w-full flex items-center gap-3 rounded-lg px-3 py-2 text-left","border border-white/[0.06] bg-white/[0.02]","hover:bg-white/[0.05] hover:border-white/[0.12] transition-colors duration-150"),children:[(0,t.jsx)("span",{className:(0,n.cn)("w-2 h-2 rounded-full flex-none",a.dot)}),(0,t.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,t.jsx)("span",{className:"block truncate text-sm text-white/90",children:e.title||"Untitled task"}),(0,t.jsx)("span",{className:(0,n.cn)("block text-[11px]",a.text),children:a.label})]}),(0,t.jsx)(N.ChevronRight,{className:"w-4 h-4 flex-none text-white/30"})]})},e.id)})}),c&&(0,t.jsxs)("p",{className:"mt-2 px-1 text-[11px] text-white/40",children:["Showing the first ",10," â more tasks are due here that day."]})]})}var eC=e.i(846696),eS=e.i(431343),eE=e.i(871689),eI=e.i(620278),eT=e.i(417835),e_=e.i(194983),eA=e.i(575787),eD=e.i(618348),eP=e.i(373884),eR=e.i(182189);let eM="15:00",eF="11:00";function eL(e){return"granted"===e?"granted":"denied"===e?"declined":"pending"===e?"pending":null}function e$(e){if(!e||"string"!=typeof e)return null;let t=e.split(/[+]/)[0].replace(/Z$/,"").trim(),a=t.match(/^(\d{1,2}):(\d{2})\s*(AM|PM)$/i);if(a){let e=parseInt(a[1],10),t=a[2],r="PM"===a[3].toUpperCase();return 12===e?e=12*!!r:r&&(e+=12),`${String(e).padStart(2,"0")}:${t}`}let r=t.match(/^(\d{1,2}):(\d{2})(?::\d{2})?$/);if(r){let e=parseInt(r[1],10);return e>23?null:`${String(e).padStart(2,"0")}:${r[2]}`}return null}function eO(e){let t=e$(e);if(!t)return null;let[a,r]=t.split(":").map(e=>parseInt(e,10));return 60*a+r}function eU(e){let t=e$(e);if(!t)return e||"";let[a,r]=t.split(":"),s=parseInt(a,10);return`${0===s?12:s>12?s-12:s}:${r} ${s>=12?"PM":"AM"}`}function eB(e){return e?.guestDetails?.number_of_guests||e?.guestDetails?.numberOfGuests||1}function eq(e){return e&&"string"==typeof e?e.split("T")[0]:null}var ez=e.i(349330),eH=e.i(514764),eV=e.i(663854),eG=e.i(473708),eW=e.i(82735),eK=e.i(257995),eY=e.i(752044),eJ=e.i(56443);let eQ=new Set([408,429,500,502,503,504]),eX=e=>new Promise(t=>setTimeout(t,e));async function eZ(e,t,a={}){let r,{maxAttempts:s=3,initialDelayMs:i=600,maxDelayMs:n=8e3,sleep:l=eX}=a;for(let a=1;a<=s;a++)try{return await t(e)}catch(t){if(r=t,a>=s||!function(e){let t=e?.status;return"number"!=typeof t||eQ.has(t)}(t))break;let e=Math.min(i*2**(a-1),n);await l(e)}throw r instanceof Error?r:Error(String(r))}async function e0(e,t,a={}){let r=[];for(let s of e)try{let e=await eZ(s,t,a);r.push({file:s,ok:!0,value:e})}catch(e){r.push({file:s,ok:!1,error:e instanceof Error?e:Error(String(e))})}return r}async function e1(e){try{if("u"<typeof document||!e.type.startsWith("image/")||"image/gif"===e.type||"image/svg+xml"===e.type||e.size<1e6||"function"!=typeof createImageBitmap)return e;let t=await createImageBitmap(e),{width:a,height:r}=t,s=Math.max(a,r);if(!s)return t.close?.(),e;let i=Math.min(1,2048/s),n=Math.round(a*i),l=Math.round(r*i),o=document.createElement("canvas");o.width=n,o.height=l;let d=o.getContext("2d");if(!d)return t.close?.(),e;d.drawImage(t,0,0,n,l),t.close?.();let c=await new Promise(e=>
63o.toBlob(e,"image/jpeg",.82));if(!c||c.size>=e.size)return e;let m=e.name.replace(/\.(heic|heif|png|webp|jpeg|jpg)$/i,"")+".jpg";return new File([c],m,{type:"image/jpeg",lastModified:Date.now()})}catch{return e}}var e2=e.i(657688),e5=e.i(63237),e4=e.i(133820),e3=e.i(180239),e6=e.i(217255),e8=e.i(374009),e9=e.i(782839),e7=e.i(289562),te=e.i(337607);let tt=({users:e,isLoading:s,onSelect:i})=>{let[l,o]=(0,a.useState)(0);(0,a.useEffect)(()=>{o(0)},[e]);let d=t=>{if(0!==e.length)switch(t.key){case"ArrowDown":t.preventDefault(),o(t=>(t+1)%e.length);break;case"ArrowUp":t.preventDefault(),o(t=>(t-1+e.length)%e.length);break;case"Enter":t.preventDefault(),i(e[l])}};return((0,a.useEffect)(()=>(window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)),[e,l]),s)?(0,t.jsx)("div",{className:"absolute bottom-full left-0 right-0 mb-2 bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-white/[0.08] shadow-xl",children:(0,t.jsx)("div",{className:"p-2 text-sm text-gray-500 dark:text-white/60",children:"Loading users..."})}):(0,t.jsx)(r.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},className:"mentions-dropdown absolute bottom-full left-0 right-0 mb-2 bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-white/[0.08] shadow-xl",children:(0,t.jsx)("div",{className:"max-h-[200px] overflow-y-auto",children:0===e.length?(0,t.jsx)("div",{className:"p-2 text-sm text-gray-500 dark:text-white/60",children:"No users or groups found"}):e.map((e,a)=>(0,t.jsxs)("div",{onClick:()=>{i(e)},className:(0,n.cn)("flex items-center gap-2 p-2 cursor-pointer transition-colors",a===l?"bg-gray-100 dark:bg-white/[0.08]":"hover:bg-gray-50 dark:hover:bg-white/[0.04]"),children:[(0,t.jsx)(e7.Avatar,{className:"w-6 h-6 flex-shrink-0",children:"isGroup"in e&&e.isGroup?(0,t.jsx)("div",{className:"flex items-center justify-center w-full h-full bg-gray-100 dark:bg-white/10 rounded-full",children:(0,t.jsx)(eV.Users2,{className:"w-3.5 h-3.5 text-gray-600 dark:text-white/80"})}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e7.AvatarImage,{src:e.image||void 0}),(0,t.jsx)(e7.AvatarFallback,{children:e.name.charAt(0).toUpperCase()})]})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:e.name}),(0,t.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/40 truncate",children:"isGroup"in e&&e.isGroup?"Group":e.email})]})]},e.id))})})};function ta({onCommand:e,onCommandPaletteOpen:i,className:l,placeholder:o,disabled:d=!1,taskId:c,onMessageSent:m,task:u,onTaskUpdate:h,onStartExecution:x,showResumeTask:g=!0,hostContact:p,contactRole:b,reservationId:y}){let w,v,{data:k}=(0,e6.useSession)(),{currentCustomerId:j,users:{users:N,groups:C}}=(0,e4.useCustomer)(),[S,E]=(0,a.useState)(""),[I,T]=(0,a.useState)(!1),_=(0,a.useRef)(null),[A,D]=(0,a.useState)(null),[R,M]=(0,a.useState)([]),[F,L]=(0,a.useState)(!1),[$,O]=(0,a.useState)(""),[U,B]=(0,a.useState)([]),[q,z]=(0,a.useState)(!1),H=(0,a.useRef)(null),[V,G]=(0,a.useState)([]),W=(0,te.useTranslations)(),[K,Y]=(0,a.useState)("internal"),J=!!(p&&(p.phone||p.email)),Q=(0,a.useMemo)(()=>{if(!p)return[];let e=[{id:"internal",label:"Team",enabled:!0},{id:"sms",label:"SMS",enabled:!!p.phone}];return"host"!==b&&e.push({id:"email",label:"Email",enabled:!!p.email}),e},[p,b]),{handleTypingStatus:X,isConnected:Z}=(0,e5.useRealtimePresence)("task",c),et=(0,a.useCallback)((0,e8.default)(e=>{X(e)},500),[X]);(0,a.useEffect)(()=>{if(F){let e=(0,e3.filterOwnersUnlessSearching)(Array.isArray(N)?N:[],$),t=Array.isArray(C)?C:[];if($.trim()){let a=$.trim().toLowerCase();M([...e.filter(e=>e.name.toLowerCase().includes(a)||e.email.toLowerCase().includes(a)),...t.map(e=>({...e,isGroup:!0,name:`@${e.name.charAt(0).toUpperCase()+e.name.slice(1)}`,email:`group:${e.slug}`,image:null})).filter(e=>e.name.toLowerCase().substring(1).includes(a)||e.slug.toLowerCase().includes(a))])}else M([...e,...t.map(e=>({...e,isGroup:!0,name:`@${e.name.charAt(0).toUpperCase()+e.name.slice(1)}`,email:`group:${e.slug}`,image:null}))])}},[$,N,C,F]);let ea=e=>{let t=_.current;if(!t)return;let a=t.selectionStart,r=S.substring(0,a),s=r.lastIndexOf("@"),i=S.substring(a),n="isGroup"in e&&e.
63isGroup?`group:${e.slug}`:e.email?.split("@")[0]||"";B(t=>[...t,{id:e.id,username:n,display:e.name}]),E(`${r.substring(0,s)}@${n} ${i}`),L(!1),t.focus();let l=s+n.length+2;setTimeout(()=>{t.setSelectionRange(l,l)},0)};(0,a.useEffect)(()=>()=>{X(!1),et.cancel()},[X,et]);let er=(0,a.useCallback)(async()=>{if(c&&k?.user&&j&&!I&&(S.trim()||0!==V.length))try{if(T(!0),D(null),"internal"!==K&&J&&p?.userId){let e=await fetch("/api/operations/send-message",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:c,channel:K,content:S.trim(),recipientUserId:p.userId})}),t=await e.json();if(!e.ok)throw Error(t.error||"Failed to send message");E(""),G([]),_.current&&(_.current.style.height="auto"),m?.();return}let e=S.match(/@(group:\w+|\w+)/g),t=e?.map(e=>e.substring(1))||[],a=U.filter(e=>t.includes(e.username)),r=await fetch("/api/tasks/messages",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:S,taskId:c,customerId:j,mentions:a,attachments:V.map(e=>({url:e.url,metadata:e.metadata,transcription:e.transcription,originalTranscription:e.originalTranscription}))})});if(await r.json(),!r.ok)throw Error(W.tasks.composer.errors.send);E(""),B([]),G([]),_.current&&(_.current.style.height="auto"),m?.()}catch(e){console.error("[TaskComposer] Error sending message:",e),D(e instanceof Error?e.message:W.tasks.composer.errors.send)}finally{T(!1),X(!1)}},[S,c,k?.user,j,I,m,X,U,V,W,K,J,p]);(0,a.useEffect)(()=>{let e=e=>{if(document.activeElement===_.current&&(!e.metaKey&&!e.ctrlKey||"Enter"!==e.key)&&(!e.metaKey&&!e.ctrlKey||"c"!==e.key&&"v"!==e.key&&"x"!==e.key&&"a"!==e.key)&&(e.metaKey||e.ctrlKey||e.altKey))return e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),!1};return window.addEventListener("keydown",e,{capture:!0,passive:!1}),()=>{window.removeEventListener("keydown",e,{capture:!0})}},[]);let es=(0,a.useCallback)(e=>{e.stopPropagation()},[]),ei=(0,a.useCallback)(e=>{if(e.stopPropagation(),F&&"Enter"===e.key){e.preventDefault(),R.length>0&&ea(R[0]);return}"Enter"===e.key&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),er())},[er,F,R,ea]),el=e=>{e.stopPropagation()},eo=async e=>{if(e?.length&&c){if(V.length+e.length>10)return void D(W.tasks.composer.attachments.maxError);try{z(!0),D(null);let t=Array.from(e),a=await e0(t,async e=>{let t=await e1(e),a=new FormData;a.append("taskId",c.toString()),a.append("file",t);let r=await fetch("/api/tasks/messages",{method:"POST",body:a});if(!r.ok){let e=Error(W.tasks.composer.errors.upload);throw e.status=r.status,e}let s=await r.json(),i=s?.attachments?.[0];if(!i?.url)throw Error(W.tasks.composer.errors.upload);return{url:i.url,name:e.name,type:i.type?.startsWith("audio/")?"voice":"file",metadata:i.metadata}}),r=a.filter(e=>e.ok).map(e=>e.value);r.length&&G(e=>[...e,...r]),a.length-r.length>0&&(console.error("[TaskComposer] Some files failed to upload:",a.filter(e=>!e.ok)),D(W.tasks.composer.errors.upload))}catch(e){console.error("[TaskComposer] Error uploading files:",e),D(e instanceof Error?e.message:W.tasks.composer.errors.upload)}finally{z(!1)}}};(0,a.useEffect)(()=>{if(!F)return;let e=e=>{let t=e.target;t.closest(".mentions-dropdown")||t.closest("[data-mentions-trigger]")||L(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[F]);let ed=(0,ee.useUserSettings)().getCurrentRole(),ec=ed&&["cleaner","maintenance","partner"].includes(ed),eu=k?.user?.id,eh=u?.assignments?.some(e=>e.user_id===eu&&["accepted","pending","completed"].includes(e.status)),ex=(0,a.useMemo)(()=>{if(!u?.start_date&&!u?.due_date)return!0;let e=new Date().toISOString().split("T")[0];return u.start_date&&u.due_date||u.start_date?e>=new Date(u.start_date).toISOString().split("T")[0]:(u.due_date,!0)},[u?.start_date,u?.due_date]),eg=ec&&eh&&ex&&u&&["todo","pending"].includes(u.status),eb=u?.issues?.some(e=>!0===e.is_blocking&&"resolved"!==e.status)||!1,ef=ec&&eh&&u&&["in_progress","blocked"].includes(u.status)&&g&&!eb,[ey,ew]=(0,a.useState)(!1),[ev,ek]=(0,a.useState)(!1),ej=async()=>
63{if(u&&x){ew(!0);try{await x()}catch(e){console.error("Error starting task:",e)}finally{ew(!1)}}},eN=u?u.estimated_duration&&u.estimated_duration>0?u.estimated_duration:u.actual_duration&&u.actual_duration>0?u.actual_duration:u.historicalAnalytics?.estimatedDuration&&u.historicalAnalytics.estimatedDuration>0?u.historicalAnalytics.estimatedDuration:0:0;(0,a.useEffect)(()=>{let e=()=>{ek(window.innerWidth<768)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);let eC=async e=>{if(c)try{z(!0),D(null);let t=new FormData;t.append("taskId",c.toString()),e.type.startsWith("audio/")?(t.append("file",e,e.name),t.append(`metadata_${e.name}`,JSON.stringify({duration:e.metadata?.duration||0,mimeType:e.type,size:e.size}))):t.append("file",e);let a=await fetch("/api/tasks/messages",{method:"POST",body:t}),r=await a.json();if(!a.ok)throw Error(W.tasks.composer.errors.upload);if(console.log("[TaskComposer] Voice upload response:",r),!r.success||!r.attachments||!Array.isArray(r.attachments)||0===r.attachments.length)throw console.error("[TaskComposer] Unexpected response structure:",r),Error("Voice note uploaded but attachment not found in response");let s=r.attachments[0];e.type.startsWith("audio/")&&s.transcription&&E(e=>{let t=s.transcription||"";if(console.log("[TaskComposer] Updating content with transcription:",{prevContent:e,transcription:t,hasTranscription:e.includes(t),originalText:s.originalTranscription}),t&&e.includes(t))return console.log("[TaskComposer] Transcription already exists in content, skipping"),e;let a=(e.trim()?e.trim()+"\n":"")+t;return console.log("[TaskComposer] New content:",a),a}),G(t=>[...t,{url:s.url,name:e.name,type:"voice",metadata:{duration:s.metadata?.duration||0,mimeType:s.metadata?.mimeType||e.type},transcription:s.transcription,originalTranscription:s.originalTranscription}])}catch(e){console.error("[TaskComposer] Error uploading voice note:",e),D(e instanceof Error?e.message:W.tasks.composer.errors.upload)}finally{z(!1)}};return(0,t.jsxs)(t.Fragment,{children:[A&&(0,t.jsx)(e9.Notification,{type:"error",message:A,onClose:()=>D(null),position:"bottom"}),(0,t.jsxs)("div",{className:(0,n.cn)("relative bg-gray-100 dark:bg-[#18181A] border-t border-gray-200 dark:border-white/[0.08] p-4",l),children:[(0,t.jsx)(s.AnimatePresence,{children:ev&&(eg||ef)&&(0,t.jsx)(r.motion.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"mb-3 border-b border-gray-200 dark:border-white/[0.04] pb-3",children:(0,t.jsx)(r.motion.button,{onClick:ej,className:(0,n.cn)("w-full font-medium py-3 px-4 rounded-xl shadow-sm border transition-all duration-200",ef?"bg-gradient-to-r from-green-600/80 to-green-500/80 hover:from-green-600 hover:to-green-500 border-green-400/20 text-gray-900 dark:text-white":"bg-gradient-to-r from-blue-600/80 to-blue-500/80 hover:from-blue-600 hover:to-blue-500 border-blue-400/20 text-gray-900 dark:text-white"),whileHover:{scale:1.01},whileTap:{scale:.99},children:(0,t.jsxs)("div",{className:"flex items-center justify-center space-x-3",children:[(0,t.jsx)("div",{className:"bg-gray-200 dark:bg-white/20 p-2 rounded-lg",children:(0,t.jsx)(eS.Play,{className:"w-4 h-4"})}),(0,t.jsxs)("div",{className:"text-left",children:[(0,t.jsx)("div",{className:"text-sm font-semibold",children:ef?"Resume Task":"Start Task"}),(0,t.jsx)("div",{className:(0,n.cn)("text-xs opacity-90",ef?"text-green-100":"text-blue-100"),children:ef?"Continue where you left off":"Begin with timer & checklist"})]}),eN>0&&(0,t.jsxs)("div",{className:"flex items-center space-x-2 bg-gray-100 dark:bg-white/10 rounded-full px-3 py-1",children:[(0,t.jsx)(f.Clock,{className:"w-4 h-4"}),(0,t.jsxs)("span",{className:"text-xs font-medium",children:["~",(w=Math.floor(eN/60),v=eN%60,w>0?`${w}h ${v}m`:`${v}m`)]})]})]})})})}),V.length>0&&(0,t.jsxs)("div",{className:"mb-2 space-y-2",children:[V.map((e,a)=>(0,t.jsx)("div",{children:"voice"===e.type?(0,t.jsx)(ep.VoiceNotePlayer,{url:e.url,name:e.name,metadata:e.metadata,onRemove:()=>G(e=>e.filter((e,t)=>t!==a)),variant:"zinc",className:"w-full"}):(0,t.jsxs)("div",{className:"px-3 py-2 bg-white dark:bg-white/[0.03] rounded-lg flex items-center gap-2",children:[(0,t.jsx)(eW.Paperclip,{className:"w-4 h-4 text-gray-400 dark:text-white/40"}),(0,t.jsx)("span",{className:"text-sm text-gray-500 dark:text-white/60 flex-1 truncate",children:e.name}),(0,t.jsx)("button",{onClick:()=>G(e=>e.filter((e,t)=>
63t!==a)),className:"p-1 hover:bg-gray-100 dark:hover:bg-white/[0.08] rounded-md",children:(0,t.jsx)(P.X,{className:"w-4 h-4 text-gray-400 dark:text-white/40"})})]})},a)),V.length>0&&(0,t.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/40 pl-1",children:W.tasks.composer.attachments.limit.replace("{count}",String(V.length))})]}),(0,t.jsx)(s.AnimatePresence,{children:F&&(0,t.jsx)(tt,{users:R,isLoading:!1,onSelect:e=>{ea(e)}})}),(0,t.jsx)("div",{className:(0,n.cn)("relative rounded-lg transition-all duration-200","min-h-[40px] flex flex-col","bg-white dark:bg-white/[0.03]","border border-gray-200 dark:border-white/[0.06]","shadow-[inset_0_0_0_1px_rgba(0,0,0,0.04)] dark:shadow-[inset_0_0_0_1px_rgba(255,255,255,0.04)]","hover:border-gray-200 dark:hover:border-white/[0.08]","focus-within:border-gray-200 dark:border-white/[0.12]","focus-within:shadow-[inset_0_0_0_1px_rgba(0,0,0,0.06)] dark:shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]"),children:(0,t.jsxs)("div",{className:"flex items-center px-3 py-2",children:[(0,t.jsx)("div",{className:"flex items-center gap-2",children:(0,t.jsx)(em.Button,{onClick:()=>i?.(),variant:"ghost",size:"sm",className:"p-1.5 text-gray-500 dark:text-white/60 hover:text-gray-900 dark:hover:text-white/90",children:(0,t.jsx)(e2.default,{src:"/favicon.ico",alt:"Vanio AI",width:16,height:16,className:"w-4 h-4 opacity-60 hover:opacity-100 transition-opacity"})})}),(0,t.jsxs)("div",{className:"flex-1 relative",children:[J&&(0,t.jsxs)("div",{className:"flex items-center gap-0.5 px-3 pt-1.5 pb-0.5",children:[Q.filter(e=>e.enabled).map(e=>(0,t.jsx)("button",{onClick:()=>Y(e.id),className:(0,n.cn)("px-2 py-0.5 rounded text-[10px] font-medium transition-colors",K===e.id?"sms"===e.id?"bg-green-500/20 text-green-400":"email"===e.id?"bg-blue-500/20 text-blue-400":"bg-gray-500/20 text-gray-300 dark:text-white/60":"text-gray-400 dark:text-white/25 hover:text-gray-600 dark:hover:text-white/40"),children:e.label},e.id)),"internal"!==K&&p&&(0,t.jsxs)("span",{className:"text-[10px] text-gray-400 dark:text-white/25 ml-1.5 truncate",children:["â ",p.name]})]}),(0,t.jsx)("textarea",{ref:_,value:S,onChange:e=>{let t=e.target;E(t.value),t.style.height="auto",t.style.height=`${t.scrollHeight}px`,t.value.trim()?et(!0):et(!1);let a=t.selectionStart,r=t.value.substring(0,a),s=r.lastIndexOf("@"),i=r.substring(0,s).lastIndexOf(" ");-1!==s&&(s===(-1===i?0:i+1)||0===s)&&a-s<=15&&!r.substring(s).includes(" ")?(O(r.substring(s+1)),L(!0)):L(!1)},onKeyDown:ei,onClick:es,onTouchStart:el,onTouchMove:el,onTouchEnd:el,placeholder:"sms"===K?`SMS to ${p?.name||"host"}...`:"email"===K?`Email to ${p?.name||"host"}...`:o||W.tasks.composer.placeholder,disabled:d||I,className:(0,n.cn)("min-h-[36px] lg:min-h-[44px] w-full resize-none","bg-transparent px-3 py-[6px] lg:py-[10px]","text-sm outline-none disabled:opacity-50 pr-10"),rows:1,style:{height:"auto"}}),(0,t.jsx)("div",{className:"absolute right-2 bottom-[6px] flex items-center gap-1",children:(0,t.jsx)("button",{onClick:er,disabled:!S.trim()&&0===V.length||d||I,className:(0,n.cn)("p-1 text-gray-500 dark:text-white/60 hover:text-gray-900 dark:hover:text-white/90","disabled:opacity-40 transition-opacity"),title:W.tasks.composer.buttons.send,children:I?(0,t.jsx)("div",{className:"w-4 h-4 border-2 border-gray-300 dark:border-white/20 border-t-gray-700 dark:border-t-white/80 rounded-full animate-spin"}):(0,t.jsx)(eH.Send,{className:"w-4 h-4"})})})]})]})}),(0,t.jsxs)("div",{className:"flex items-center gap-1 mt-2 px-2",children:[(0,t.jsx)("input",{type:"file",ref:H,className:"hidden",onChange:e=>eo(e.target.files)}),(0,t.jsx)("button",{onClick:()=>{(0,eJ.openFilePicker)(H.current,{accept:"image/*",capture:"environment"})},className:"p-1.5 rounded-md hover:bg-gray-100 dark:hover:bg-white/[0.08] text-gray-400 dark:text-white/40 hover:text-gray-600 dark:hover:text-white/70 transition-colors",disabled:d||I||q,title:W.tasks.composer.buttons.camera,children:(0,t.jsx)(eG.Image,{className:"w-4 h-4"})}),(0,t.jsx)("button",{onClick:()=>{(0,eJ.openFilePicker)(H.current,{accept:null,capture:null,multiple:!0})},className:"p-1.5 rounded-md hover:bg-gray-100 dark:hover:bg-white/[0.08] text-gray-400 dark:text-white/40 hover:text-gray-600 dark:hover:text-white/70 transition-colors",disabled:d||I||q,title:W.tasks.composer.buttons.attachment,children:(0,t.jsx)(eW.Paperclip,{className:"w-4 h-4"})}),(0,t.jsx)(function({onUpload:e}){let[s,i]=(0,a.useState)(!1),[n,l]=(0,a.useState)(null),[o,d]=(0,a.useState)(0),c=(0,a.useRef)(null),m=(0,a.useRef)([]),u=(0,a.useRef)(0);(0,a.useEffect)(()=>(s?(d(0),u.current=0,c.current=setInterval(()=>{d(e=>(u.current=e+1,e+1))},1e3)):c.current&&clearInterval(c.current),()=>{c.current&&clearInterval(c.current)}),[s]);let h=async()=>{try{let t=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}
63),a=new MediaRecorder(t,{mimeType:MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":"audio/webm"});m.current=[],a.ondataavailable=e=>{e.data.size>0&&m.current.push(e.data)},a.onstop=async()=>{try{await new Promise(e=>setTimeout(e,100));let t=m.current;if(0===t.length)return void console.error("No audio chunks recorded");let r=new Blob(t,{type:a.mimeType});if(0===r.size)return void console.error("Created blob has zero size");let s=new File([r],`voice-note-${Date.now()}.webm`,{type:a.mimeType,lastModified:Date.now()});if(0===s.size)return void console.error("Created file has zero size");let i=Object.assign(s,{metadata:{duration:u.current,mimeType:a.mimeType,size:s.size}});e(i)}catch(e){console.error("Error processing audio:",e)}finally{t.getTracks().forEach(e=>e.stop()),l(null),d(0),c.current&&(clearInterval(c.current),c.current=null)}},a.start(100),l(a),i(!0)}catch(e){console.error("Error starting recording:",e)}};if(s){let e;return(0,t.jsx)(r.motion.button,{initial:{scale:.8},animate:{scale:1},onClick:()=>{n&&"recording"===n.state&&(n.stop(),i(!1))},className:"p-1.5 rounded-md bg-red-500/10 text-red-400 hover:bg-red-500/20 transition-colors",title:"Stop recording",children:(0,t.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,t.jsx)(eY.Square,{className:"w-4 h-4"}),(0,t.jsx)("span",{className:"text-xs font-mono",children:(e=Math.floor(o/60),`${e}:${(o%60).toString().padStart(2,"0")}`)})]})})}return(0,t.jsx)("button",{onClick:h,className:"p-1.5 rounded-md hover:bg-gray-100 dark:hover:bg-white/[0.08] text-gray-400 dark:text-white/40 hover:text-gray-600 dark:hover:text-white/70 transition-colors",title:"Record voice note",children:(0,t.jsx)(en.Mic,{className:"w-4 h-4"})})},{onUpload:eC}),(0,t.jsx)("button",{"data-mentions-trigger":!0,onClick:()=>{L(e=>!e),F||O("")},className:(0,n.cn)("p-1.5 rounded-md hover:bg-gray-100 dark:hover:bg-white/[0.08] text-gray-400 dark:text-white/40 hover:text-gray-600 dark:hover:text-white/70 transition-colors",F&&"text-gray-600 dark:text-white/70"),disabled:d||I,title:W.tasks.composer.buttons.mention,children:(0,t.jsx)(eK.AtSign,{className:(0,n.cn)("w-4 h-4 transition-colors",F&&"text-gray-600 dark:text-white/70")})}),q&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-xs text-gray-400 dark:text-white/40",children:[(0,t.jsx)("div",{className:"w-3 h-3 border-2 border-gray-300 dark:border-white/20 border-t-gray-600 dark:border-t-white/60 rounded-full animate-spin"}),W.tasks.composer.loading.upload]})]})]})]})}function tr({task:e,checklist:s,onStart:i,onClose:n,onReportAccessIssue:l,onResolveAccessIssue:o,isResuming:d=!1,completedItems:c=new Set,elapsedTime:m=0,onRefresh:u}){let h,x,p,[b,y]=(0,a.useState)(!1),w=(0,ez.useLiveOccupancy)(e.occupancy),v=e.metadata?.listingId,{listing:j,isLoading:N,error:C}=(0,M.useFullListing)(v),S=e.issues?.filter(e=>"access"===e.location)||[],I=e.issues?.filter(e=>!0===e.is_blocking)||[],T=S.filter(e=>"resolved"!==e.status),_=I.filter(e=>"resolved"!==e.status);T.length;let A=_.length>0,D=b||A,P=S.length>0?S.sort((e,t)=>new Date(t.created_at).getTime()-new Date(e.created_at).getTime())[0]:null;I.length>0&&I.sort((e,t)=>new Date(t.created_at).getTime()-new Date(e.created_at).getTime())[0];let R=_.length>0?_.sort((e,t)=>new Date(t.created_at).getTime()-new Date(e.created_at).getTime())[0]:null,F=e=>{let t=new Date,a=new Date(e),r=Math.floor((t.getTime()-a.getTime())/6e4);if(r<1)return"Just now";if(r<60)return`${r}m ago`;let s=Math.floor(r/60);if(s<24)return`${s}h ago`;let i=Math.floor(s/24);return`${i}d ago`},L=e.estimated_duration&&e.estimated_duration>0?e.estimated_duration:e.actual_duration&&e.actual_duration>0?e.actual_duration:e.historicalAnalytics?.estimatedDuration&&e.historicalAnalytics.estimatedDuration>0?e.historicalAnalytics.estimatedDuration:0;return(0,t.jsxs)("div",{className:"fixed inset-0 bg-gray-100 dark:bg-[#0A0A0B] z-[200] flex flex-col",children:[(0,t.jsxs)("div",{className:"flex-none border-b border-gray-200 dark:border-white/[0.08] bg-white dark:bg-[#111113]",children:[D&&R&&(0,t.jsx)("div",{className:"bg-amber-500/10 border-b border-amber-500/20 px-4 py-4",children:(0,t.jsxs)("div",{className:"flex items-start space-x-3",children:[(0,t.jsx)("div",{className:"w-6 h-6 bg-amber-500/20 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",children:(0,t.jsx)(ea.AlertTriangle,{className:"w-3.5 h-3.5 text-amber-400"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,t.jsx)("p",{className:"text-amber-400 text-sm font-semibold",children:R?.location==="access"?"Access Issue Reported":"Blocking Issue Reported"}),(0,t.jsxs)("div",{className:"flex items-center space-x-1 text-amber-300/60 text-xs",children:[(0,t.jsx)(f.Clock,{className:"w-3 h-3"}),(0,t.jsx)("span",{children:F(R.created_at)})]})]}),(0,t.jsxs)("p",{className:"text-amber-300/90 text-sm font-medium mb-1",children:['"',R.description,'"']}),(0,t.jsx)("div",{className:"flex items-center justify-between",children:(0,t.jsxs)("p",{className:"text-amber-300/70 text-xs",children:["Team notified ⢠",R?.location==="access"?"Property manager":"Support"," will assist ⢠Use chat below for updates"]})})]}),(0,t.jsx)(E.CheckCircle,{className:"w-4 h-4 text-amber-400 flex-shrink-0 mt-1"})]})}),(0,t.jsx)("div",{className:"p-4",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("button",{onClick:n,className:"p-2 hover:bg-gray-100 dark:hover:bg-white/[0.08] rounded-xl transition-colors",children:(0,t.jsx)(eE.ArrowLeft,{className:"w-5 h-5 text-gray-500 dark:text-white/60"})}),(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)("h1",{className:"text-gray-900 dark:text-white font-semibold",children:D?R?.location==="access"?"Access Issue - Stay Connected":"Blocking Issue - Stay Connected":d?"Resume Task":"Ready to Start"}),(0,t.jsx)("p",{className:"text-gray-500 dark:text-white/50 text-sm",children:D?R?.location==="access"?"Communicate with property manager below":"Communicate with support team below":d?"Continue from where you left off":"Property Access & Task Info"})]}),(0,t.jsx)("div",{className:"w-9"})]})})]}),(0,t.jsx)("div",{className:"flex-1 overflow-y-auto",children:D?(0,t.jsxs)("div",{className:"space-y-0 pb-20",children:[(0,t.jsxs)("div",{className:"bg-blue-500/5 border-b border-blue-500/20 px-4 py-3",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)(e_.MessageCircle,{className:"w-4 h-4 text-blue-400"}),(0,t.jsx)("h3",{className:"text-blue-400 font-medium text-sm",children:"Task Communication"})]}),(0,t.jsx)("p",{className:"text-blue-300/70 text-xs mt-1",children:"Property manager and support team can assist you here"})]}),(0,t.jsx)("div",{className:"bg-white dark:bg-[#111113]",children:(0,t.jsx)(g.TaskTimeline,{events:e.timeline||[]})})]}):(0,t.jsx)("div",{className:"p-4 pb-6",children:(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{className:"text-center space-y-3",children:[(0,t.jsx)("div",{className:"w-16 h-16 bg-blue-500/20 rounded-2xl flex items-center justify-center mx-auto",children:(0,t.jsx)($.Zap,{className:"w-8 h-8 text-blue-400"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-xl font-bold text-gray-900 dark:text-white mb-1",children:e.title}),(0,t.jsx)("p",{className:"text-gray-500 dark:text-white/60 text-sm",children:d?"Continue working on this task":"Ready to begin? Check property access details below."})]})]}),(h=(e=>{let{nextReservation:t,due_date:a}=e;if(!t||!a||a.split("T")[0]!==t.checkIn)return null;let r=t.checkInTime||"3:00 PM";return{isSameDayCheckIn:!0,checkInTime:r.includes(":")?5===r.length?(()=>{let[e,t]=r.split(":"),a=parseInt(e);return`${0===a?12:a>12?a-12:a}:${t} ${a>=12?"PM":"AM"}`})():r:"3:00 PM",confirmationCode:t.confirmationCode,guestCount:t.guestDetails?.number_of_guests||1}})(e))?(0,t.jsx)("div",{className:"bg-amber-500/10 border border-amber-500/20 rounded-2xl p-4",children:(0,t.jsxs)("div",{className:"flex items-center space-x-3 mb-3",children:[(0,t.jsx)("div",{className:"w-6 h-6 bg-amber-500/20 rounded-full flex items-center justify-center flex-shrink-0",children:(0,t.jsx)(f.Clock,{className:"w-3.5 h-3.5 text-amber-400"})}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2 mb-1",children:[(0,t.jsx)("div",{className:"w-2 h-2 rounded-full bg-amber-500 animate-pulse"}),(0,t.jsx)("span",{className:"text-amber-400 font-semibold text-sm",children:"Same-day Check-in"})]}),(0,t.jsxs)("p",{className:"text-amber-300/90 text-sm",children:["Guests arrive at ",(0,t.jsx)("span",{className:"font-semibold text-gray-900 dark:text-white",children:h.checkInTime})," ","(",h.guestCount," guest",1!==h.guestCount?"s":"",")"]}),(0,t.jsxs)("p",{className:"text-amber-300/70 text-xs mt-1",children:["Confirmation: ",(0,t.jsx)("span",{className:"font-mono",children:h.confirmationCode})," ","⢠Complete before guests arrive"]})]})]})}):null,(()=>{let a=function(e){var t,a;let r,{dueDate:s,sourceReservation:i,nextReservation:n,occupancyVerdict:l,occupancy:o,now:d,standards:c,permissionOverride:m}=e,u=eq(s)||"",h=e$(c?.checkOutTime)||eF,x=e$(c?.checkInTime)||eM,g=l??(0,eR.occupancyAt)(o,d??Date.now()),p=null;if(i){let e,a,r=e$(i.checkOutTime)||h;p={reservationId:i.id,confirmationCode:i.confirmationCode,date:eq(i.checkOut)||"",time:eU(r),rawTime:r,timing:(t=i.checkOutTime,e=eO(t),a=eO(h)??eO(eF),null==e?"standard":e<a?"early":e>a?"late":"standard"),guestCount:eB(i)}}let b=null;if(n){let e,t,r=e$(n.checkInTime)||x,s=eq(n.checkIn)||"";b={reservationId:n.id,confirmationCode:n.confirmationCode,date:s,time:eU(r),rawTime:r,timing:(a=n.checkInTime,e=eO(a),t=eO(x)??eO(eM),null==e?"standard":e<t?"early":e>t?"late":"standard"),guestCount:eB(n),sameDay:!!u&&s===u}}let f=null!==eL(m?.value),y="occupied"===g?(r=eL(m?.value))||(i?!0===i.earlyCheckInApproved?"granted":!0===i.earlyCheckInDeclined?"declined":!0===i.earlyCheckInRequested?"pending":null:null):null;return{vacancyStatus:g,previousCheckout:p,nextCheckIn:b,permissionToEnter:y,permissionToEnterOverridden:f,permissionToEnterSetAt:f?m?.setAt??null:null,permissionToEnterSetByName:f?m?.setByName??null:null,permissionToEnterSource:f?m?.source??null:null}}({dueDate:e.due_date,sourceReservation:e.sourceReservation,nextReservation:e.nextReservation,occupancyVerdict:w,standards:e.occupancy?.standards,permissionOverride:{value:e.permission_to_enter??null,setAt:e.permission_to_enter_set_at??null,setBy:e.permission_to_enter_set_by??null,setByName:e.permissionToEnterSetByName??null,source:e.permission_to_enter_source??null}});if(!a.previousCheckout&&!a.nextCheckIn&&"unknown"===a.vacancyStatus)return null;let r=e=>"early"===e?{label:"Early",cls:"bg-amber-500/15 text-amber-400 border border-amber-500/30"}:"late"===e?{label:"Late",cls:"bg-amber-500/15 text-amber-400 border border-amber-500/30"}:{label:"Standard",cls:"bg-gray-100 dark:bg-white/[0.06] text-gray-500 dark:text-white/50 border border-gray-200 dark:border-white/[0.08]"},s="occupied"===a.vacancyStatus,i="unknown"!==a.vacancyStatus;return(0,t.jsxs)("div",{className:"bg-white dark:bg-[#1A1A1C] rounded-2xl p-4 border border-gray-200 dark:border-white/[0.08] space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)(f.Clock,{className:"w-4 h-4 text-blue-400"}),(0,t.jsx)("span",{className:"text-gray-900 dark:text-white font-semibold text-sm",children:"Turnover Details"})]}),i&&(0,t.jsxs)("div",{className:"inline-flex items-center space-x-1.5 px-2.5 py-1 rounded-full text-xs font-semibold "+(s?"bg-purple-500/15 text-purple-400 border border-purple-500/30":"bg-green-500/15 text-green-400 border border-green-500/30"),children:[(0,t.jsx)(k.Home,{className:"w-3 h-3"}),(0,t.jsx)("span",{children:s?"Occupied":"Vacant"})]})]}),s&&(0,t.jsxs)("div",{className:"rounded-xl px-3 py-2.5 "+("granted"===a.permissionToEnter?"bg-green-500/10 border border-green-500/20":"declined"===a.permissionToEnter?"bg-red-500/10 border border-red-500/20":"bg-
63amber-500/10 border border-amber-500/20"),children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)(eA.DoorOpen,{className:"w-4 h-4 "+("granted"===a.permissionToEnter?"text-green-400":"declined"===a.permissionToEnter?"text-red-400":"text-amber-400")}),(0,t.jsx)("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Permission to enter"})]}),(0,t.jsxs)("div",{className:"flex items-center space-x-1.5",children:["granted"===a.permissionToEnter&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(E.CheckCircle,{className:"w-3.5 h-3.5 text-green-400"}),(0,t.jsx)("span",{className:"text-xs font-semibold text-green-400",children:"Granted"})]}),"declined"===a.permissionToEnter&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eP.XCircle,{className:"w-3.5 h-3.5 text-red-400"}),(0,t.jsx)("span",{className:"text-xs font-semibold text-red-400",children:"Declined"})]}),("pending"===a.permissionToEnter||null===a.permissionToEnter)&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eD.HelpCircle,{className:"w-3.5 h-3.5 text-amber-400"}),(0,t.jsx)("span",{className:"text-xs font-semibold text-amber-400",children:"Awaiting guest"})]})]})]}),a.permissionToEnterOverridden&&(0,t.jsxs)("p",{className:"text-[11px] text-gray-500 dark:text-white/40 mt-1.5 pl-6",children:["Set by ",a.permissionToEnterSetByName||("ai"===a.permissionToEnterSource?"Vanio AI":"your property manager"),a.permissionToEnterSetAt?` ⢠${new Date(a.permissionToEnterSetAt).toLocaleString()}`:""]})]}),a.previousCheckout&&(0,t.jsxs)("div",{className:"flex items-start justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)(J.LogOut,{className:"w-4 h-4 text-gray-400 dark:text-white/50 mt-0.5"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/50",children:"Previous checkout"}),(0,t.jsxs)("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:[a.previousCheckout.date," ⢠",a.previousCheckout.time]}),a.previousCheckout.confirmationCode&&(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-white/40 font-mono mt-0.5",children:a.previousCheckout.confirmationCode})]})]}),(0,t.jsx)("span",{className:"px-2 py-0.5 rounded-full text-[11px] font-semibold "+r(a.previousCheckout.timing).cls,children:r(a.previousCheckout.timing).label})]}),a.nextCheckIn&&(0,t.jsxs)("div",{className:"flex items-start justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)(Y.LogIn,{className:"w-4 h-4 text-gray-400 dark:text-white/50 mt-0.5"}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("p",{className:"text-xs text-gray-500 dark:text-white/50",children:["Next check-in",a.nextCheckIn.sameDay?" (same day)":""]}),(0,t.jsxs)("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:[a.nextCheckIn.date," ⢠",a.nextCheckIn.time," ","(",a.nextCheckIn.guestCount," guest",1!==a.nextCheckIn.guestCount?"s":"",")"]}),a.nextCheckIn.confirmationCode&&(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-white/40 font-mono mt-0.5",children:a.nextCheckIn.confirmationCode})]})]}),(0,t.jsx)("span",{className:"px-2 py-0.5 rounded-full text-[11px] font-semibold "+r(a.nextCheckIn.timing).cls,children:r(a.nextCheckIn.timing).label})]})]})})(),!D&&S.length>0&&P?.status==="resolved"&&(0,t.jsx)("div",{className:"bg-green-500/10 border border-green-500/20 rounded-2xl p-4",children:(0,t.jsxs)("div",{className:"flex items-start space-x-3",children:[(0,t.jsx)("div",{className:"w-6 h-6 bg-green-500/20 rounded-full flex items-center justify-center flex-shrink-0",children:(0,t.jsx)(E.CheckCircle,{className:"w-3.5 h-3.5 text-green-400"})}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,t.jsx)("p",{className:"text-green-400 text-sm font-semibold",children:"Access Issue Resolved"}),(0,t.jsxs)("div",{className:"flex items-center space-x-1 text-green-300/60 text-xs",children:[(0,t.jsx)(f.Clock,{className:"w-3 h-3"}),(0,t.jsx)("span",{children:F(P.created_at)})]})]}),(0,t.jsxs)("p",{className:"text-green-300/90 text-sm mb-1",children:['"',P.description,'" has been resolved']}),(0,t.jsx)("p",{className:"text-green-300/70 text-xs",children:"You can now proceed with the task"})]})]})}),d&&(0,t.jsxs)("div",{className:"bg-green-500/10 border border-green-500/20 rounded-2xl p-4",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3 mb-3",children:[(0,t.jsx)("div",{className:"w-3 h-3 bg-green-400 rounded-full animate-pulse"}),(0,t.jsx)("span",{className:"text-green-400 font-medium text-sm",children:"Task in Progress"})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsxs)("p",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:[c.size,"/",s.length]}),(0,t.jsx)("p",{className:"text-gray-500 dark:text-white/60 text-sm",children:"Items Completed"})]}),m>0&&(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsxs)("p",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:[Math.floor(m/60),":",(m%60).toString().padStart(2,"0")]}),(0,t.jsx)("p",{className:"text-gray-500 dark:text-white/60 text-sm",children:"Time Elapsed"})]})]}),c.size>0&&(0,t.jsx)("div",{className:"mt-3",children:(0,t.jsx)("div",{className:"w-full bg-gray-100 dark:bg-white/10 rounded-full h-2",children:(0,t.jsx)("div",{className:"bg-green-400 h-2 rounded-full transition-all duration-300",style:{width:`${c.size/s.length*100}%`}})})})]}),!N&&j&&(0,t.jsx)(W,{listing:j,showMapsButton:!0}),!N&&j&&(0,t.jsx)(Z,{listingId:j?.id,taskDate:e?.dueDate||e?.due_date||e?.startDate}),N&&(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("div",{className:"bg-white dark:bg-[#1A1A1C] rounded-2xl p-6 border border-gray-200 dark:border-white/[0.08]",children:(0,t.jsxs)("div",{className:"flex items-start space-x-4",children:[(0,t.jsx)("div",{className:"bg-gray-100 dark:bg-white/[0.08] w-12 h-12 rounded-xl animate-pulse"}),(0,t.jsxs)("div",{className:"flex-1 space-y-3",children:[(0,t.jsx)("div",{className:"bg-gray-100 dark:bg-white/[0.08] h-5 w-3/4 rounded animate-pulse"}),(0,t.jsx)("div",{className:"bg-gray-100 dark:bg-white/[0.08] h-4 w-1/2 roun
63ded animate-pulse"}),(0,t.jsx)("div",{className:"bg-gray-100 dark:bg-white/[0.08] h-4 w-2/3 rounded animate-pulse"})]})]})}),(0,t.jsxs)("div",{className:"bg-white dark:bg-[#1A1A1C] rounded-2xl p-6 border border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3 mb-4",children:[(0,t.jsx)("div",{className:"bg-gray-100 dark:bg-white/[0.08] w-6 h-6 rounded animate-pulse"}),(0,t.jsx)("div",{className:"bg-gray-100 dark:bg-white/[0.08] h-5 w-32 rounded animate-pulse"})]}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("div",{className:"bg-gray-100 dark:bg-white/[0.08] h-4 w-full rounded animate-pulse"}),(0,t.jsx)("div",{className:"bg-gray-100 dark:bg-white/[0.08] h-4 w-5/6 rounded animate-pulse"}),(0,t.jsx)("div",{className:"bg-gray-100 dark:bg-white/[0.08] h-4 w-4/5 rounded animate-pulse"})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{className:"bg-white dark:bg-[#1A1A1C] rounded-xl p-4 border border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3 mb-3",children:[(0,t.jsx)("div",{className:"bg-gray-100 dark:bg-white/[0.08] w-5 h-5 rounded animate-pulse"}),(0,t.jsx)("div",{className:"bg-gray-100 dark:bg-white/[0.08] h-4 w-16 rounded animate-pulse"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("div",{className:"bg-gray-100 dark:bg-white/[0.08] h-3 w-24 rounded animate-pulse"}),(0,t.jsx)("div",{className:"bg-gray-100 dark:bg-white/[0.08] h-3 w-32 rounded animate-pulse"})]})]}),(0,t.jsxs)("div",{className:"bg-white dark:bg-[#1A1A1C] rounded-xl p-4 border border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3 mb-3",children:[(0,t.jsx)("div",{className:"bg-gray-100 dark:bg-white/[0.08] w-5 h-5 rounded animate-pulse"}),(0,t.jsx)("div",{className:"bg-gray-100 dark:bg-white/[0.08] h-4 w-20 rounded animate-pulse"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("div",{className:"bg-gray-100 dark:bg-white/[0.08] h-3 w-28 rounded animate-pulse"}),(0,t.jsx)("div",{className:"bg-gray-100 dark:bg-white/[0.08] h-3 w-36 rounded animate-pulse"})]})]})]}),(0,t.jsx)("div",{className:"bg-white dark:bg-[#1A1A1C] rounded-xl p-4 border border-gray-200 dark:border-white/[0.08]",children:(0,t.jsx)("div",{className:"bg-gray-100 dark:bg-white/[0.08] h-12 w-full rounded-lg animate-pulse"})}),(0,t.jsx)("div",{className:"text-center",children:(0,t.jsxs)("div",{className:"inline-flex items-center space-x-2 text-gray-500 dark:text-white/60 text-sm",children:[(0,t.jsx)("div",{className:"w-4 h-4 border-2 border-gray-300 dark:border-white/20 border-t-gray-600 dark:border-t-white/60 rounded-full animate-spin"}),(0,t.jsx)("span",{children:"Loading property access information..."})]})})]}),C&&(0,t.jsx)("div",{className:"bg-red-500/10 border border-red-500/20 rounded-2xl p-4",children:(0,t.jsx)("p",{className:"text-red-400 text-sm",children:"â ï¸ Unable to load property access information. Please contact support."})}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,t.jsxs)("div",{className:"bg-white dark:bg-[#1A1A1C] rounded-xl p-3 text-center border border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsx)(eI.Target,{className:"w-5 h-5 text-green-400 mx-auto mb-2"}),(0,t.jsx)("p",{className:"text-lg font-bold text-gray-900 dark:text-white",children:s.length}),(0,t.jsx)("p",{className:"text-gray-500 dark:text-white/50 text-xs",children:"Items"})]}),L>0?(0,t.jsxs)("div",{className:"bg-white dark:bg-[#1A1A1C] rounded-xl p-3 text-center border border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsx)(eT.Timer,{className:"w-5 h-5 text-blue-400 mx-auto mb-2"}),(0,t.jsx)("p",{className:"text-lg font-bold text-gray-900 dark:text-white",children:(x=Math.floor(L/60),p=L%60,x>0?`${x}h ${p}m`:`${p}m`)}),(0,t.jsx)("p",{className:"text-gray-500 dark:text-white/50 text-xs",children:"Estimated"})]}):null]}),(0,t.jsx)("div",{className:"h-20"})]})})}),(0,t.jsx)("div",{className:"flex-none bg-gradient-to-t from-gray-100 dark:from-[#0A0A0B] via-gray-100 dark:via-[#0A0A0B] to-transparent",children:D?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("div",{className:"px-4 pt-6",children:(0,t.jsx)(r.motion.button,{onClick:()=>{R&&o&&o(R.id),i()},className:"w-full bg-gradient-to-r from-green-600 to-green-500 text-gray-900 dark:text-white font-semibold py-4 px-6 rounded-xl shadow-lg",whileHover:{scale:1.02},whileTap:{scale:.98},children:(0,t.jsxs)("div",{className:"flex items-center justify-center space-x-3",children:[(0,t.jsx)(E.CheckCircle,{className:"w-5 h-5"}),(0,t.jsxs)("span",{className:"text-lg",children:[(e=>{switch((e=>{if(!e)return"other";if("access"===e.location)return"access";let t=e.title?.toLowerCase()||"",a=e.description?.toLowerCase()||"";return t.includes("damage")||a.includes("damage")?"damage":t.includes("supplies")||a.includes("supplies")?"supplies":"other"})(e)){case"access":return"I got in";case"damage":default:return"Issue resolved";case"supplies":return"Supplies obtained"}})(R)," - ",d?"Resume Task":"Start Task"]})]})})}),(0,t.jsx)(ta,{taskId:e.id,task:void 0,placeholder:"Message property manager or support team...",onMessageSent:u,showResumeTask:!A})]}):(0,t.jsx)("div",{className:"p-4 pt-6",children:(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(r.motion.button,{onClick:i,className:"w-full bg-gradient-to-r from-blue-600 to-blue-500 text-gray-900 dark:text-white font-semibold py-4 px-6 rounded-xl shadow-lg",whileHover:{scale:1.02},whileTap:{scale:.98},children:(0,t.jsxs)("div",{className:"flex items-center justify-center space-x-3",children:[(0,t.jsx)(eS.Play,{className:"w-5 h-5"}),(0,t.jsx)("span",{className:"text-lg",children:d?"Resume Task":"Start Task"})]})}),l&&(0,t.jsx)(r.motion.button,{onClick:()=>{l?.(),y(!0)},className:"w-full bg-red-500/20 hover:bg-red-500/30 text-red-400 py-3 px-4 roun
63ded-lg border border-red-500/30 hover:border-red-500/50 transition-all duration-200",whileHover:{scale:1.01},whileTap:{scale:.99},children:(0,t.jsxs)("div",{className:"flex items-center justify-center space-x-2",children:[(0,t.jsx)(ea.AlertTriangle,{className:"w-4 h-4"}),(0,t.jsx)("span",{className:"text-sm font-medium",children:"I cannot access the property"})]})})]})})})]})}e.s(["TaskComposer",0,ta],543863);var ts=e.i(296139);function ti({task:e,completedItems:a,checklist:r,totalBreakTime:s,progress:i,formatTime:n,onResumeFromBreak:l}){return(0,t.jsx)("div",{className:"fixed inset-0 bg-gray-50 dark:bg-black z-[200]",children:(0,t.jsxs)("div",{className:"h-full flex flex-col",children:[(0,t.jsx)("div",{className:"flex-none p-4 border-b border-gray-200 dark:border-white/[0.1] bg-white dark:bg-[#1C1C1E]",children:(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)("h1",{className:"text-gray-900 dark:text-white font-medium",children:"Taking a Break"}),(0,t.jsx)("p",{className:"text-gray-500 dark:text-white/50 text-sm",children:"Task Paused"})]})}),(0,t.jsx)("div",{className:"flex-1 flex flex-col items-center justify-start p-6 pt-12 space-y-8 overflow-y-auto",children:(0,t.jsxs)("div",{className:"text-center space-y-6 w-full max-w-sm",children:[(0,t.jsx)("div",{className:"w-20 h-20 bg-orange-500/20 rounded-full flex items-center justify-center mx-auto",children:(0,t.jsx)(ts.Coffee,{className:"w-10 h-10 text-orange-400"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-2xl font-semibold text-gray-900 dark:text-white mb-2",children:"Break Time"}),(0,t.jsx)("p",{className:"text-gray-500 dark:text-white/60",children:"Take your time, we'll be here when you're ready"})]}),(0,t.jsx)("div",{className:"bg-white dark:bg-[#1C1C1E] rounded-2xl p-6 border border-gray-200 dark:border-white/[0.08]",children:(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)("p",{className:"text-gray-500 dark:text-white/50 text-sm mb-2",children:"Break Duration"}),(0,t.jsx)("p",{className:"text-3xl font-mono font-medium text-orange-400",children:n(s)})]})}),(0,t.jsxs)("div",{className:"bg-white dark:bg-[#1C1C1E] rounded-2xl p-4 border border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between text-sm mb-2",children:[(0,t.jsx)("span",{className:"text-gray-500 dark:text-white/60",children:"Progress"}),(0,t.jsxs)("span",{className:"text-gray-900 dark:text-white",children:[a.size,"/",r.length," completed"]})]}),(0,t.jsx)("div",{className:"w-full bg-gray-100 dark:bg-white/[0.1] rounded-full h-2",children:(0,t.jsx)("div",{className:"bg-gray-900 dark:bg-white h-2 rounded-full transition-all duration-300",style:{width:`${i}%`}})})]}),(0,t.jsx)("div",{className:"h-20"})]})}),(0,t.jsx)("div",{className:"flex-none bg-white dark:bg-[#1C1C1E] border-t border-gray-200 dark:border-white/[0.1] p-4",children:(0,t.jsxs)("button",{onClick:l,className:"w-full bg-gray-900 dark:bg-white text-white dark:text-black font-semibold py-4 px-6 rounded-xl transition-all duration-200 flex items-center justify-center space-x-3 hover:bg-gray-800 dark:hover:bg-white/90",children:[(0,t.jsx)(eS.Play,{className:"w-5 h-5"}),(0,t.jsx)("span",{children:"Resume Task"})]})})]})})}var tn=e.i(495242),tl=e.i(595468),to=e.i(842009),td=e.i(283086);function tc({issue:e,timeline:a=[],onResolveIssue:r,showTimeline:s=!0,showCommunication:i=!0,showComposer:n=!0,taskId:l,onMessageSent:o,className:d="",isServiceProvider:c=!1}){let m=e=>{if(!e)return"other";if("access"===e.location)return"access";let t=e.title?.toLowerCase()||"",a=e.description?.toLowerCase()||"";return t.includes("damage")||a.includes("damage")?"damage":t.includes("supplies")||a.includes("supplies")?"supplies":"other"},u=m(e);return(0,t.jsxs)("div",{className:`bg-amber-500/10 border border-amber-500/20 ${d}`,children:[(0,t.jsx)("div",{className:"px-4 py-4 border-b border-amber-500/20",children:(0,t.jsxs)("div",{className:"flex items-start space-x-3",children:[(0,t.jsx)("div",{className:"w-6 h-6 bg-amber-500/20 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",children:(0,t.jsx)(ea.AlertTriangle,{className:"w-3.5 h-3.5 text-amber-400"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,t.jsx)("p",{className:"text-amber-400 text-sm font-semibold",children:"access"===u?"Access Issue Reported":"Blocking Issue Reported"}),(0,t.jsxs)("div",{className:"flex items-center space-x-1 text-amber-300/60 text-xs",children:[(0,t.jsx)(f.Clock,{className:"w-3 h-3"}),(0,t.jsx)("span",{children:(e=>{let t=new Date,a=new Date(e),r=Math.floor((t.getTime()-a.getTime())/6e4);if(r<1)return"Just now";if(r<60)return`${r}m ago`;let s=Math.floor(r/60);if(s<24)return`${s}h ago`;let i=Math.floor(s/24);return`${i}d ago`})(e.created_at)})]})]}),(0,t.jsxs)("p",{className:"text-amber-300/90 text-sm font-medium mb-1",children:['"',e.description,'"']}),(0,t.jsx)("div",{className:"flex items-center justify-between",children:(0,t.jsxs)("p",{className:"text-amber-300/70 text-xs",children:["Team notified ⢠","access"===u?"Property manager":"Support"," will assist ⢠Use chat below for updates"]})})]}),(0,t.jsx)(E.CheckCircle,{className:"w-4 h-4 text-amber-400 flex-shrink-0 mt-1"})]})}),i&&(0,t.jsxs)("div",{className:"bg-blue-500/5 border-b border-blue-500/20 px-4 py-3",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)(e_.MessageCircle,{className:"w-4 h-4 text-blue-400"}),(0,t.jsx)("h3",{className:"text-blue-400 font-medium text-sm",children:"Task Communication"})]}),(0,t.jsxs)("p",{className:"text-blue-300/70 text-xs mt-1",children:["access"===u?"Property manager":"Support team"," and team can assist you here"]})]}),s&&a&&a.length>0&&(0,t.jsx)("div",{className:"bg-white dark:bg-[#111113]",children:(0,t.jsx)(g.TaskTimeline,{events:a})}),r&&(0,t.jsx)("div",{className:"px-4 py-3 border-t border-amber-500/20",children:(0,t.jsx)("button",{onClick:()=>r(e.id),className:"w-full bg-gradient-to-r from-green-600 to-green-500 text-gray-900 dark:text-white font-semibold py-3 px-4 roun
63ded-lg shadow-lg hover:scale-[1.02] transition-transform",children:(0,t.jsxs)("div",{className:"flex items-center justify-center space-x-2",children:[(0,t.jsx)(E.CheckCircle,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:(e=>{switch(m(e)){case"access":return c?"I got in":"Access provided";case"damage":default:return"Issue resolved";case"supplies":return"Supplies obtained"}})(e)})]})})}),n&&l&&(0,t.jsx)("div",{className:"px-4 py-3 border-t border-amber-500/20",children:(0,t.jsx)(ta,{taskId:l,onMessageSent:o})})]})}var tm=e.i(131715);function tu({task:e,checklist:i,currentItem:n,currentItemIndex:l,completedItems:d,executionState:c,elapsedTime:m,progress:u,formatTime:h,onStart:x,onPause:g,onBreak:p,onCompleteItem:b,onReportIssue:y,onClose:w,onScrollToTimeline:v,onRefreshTask:k}){let j,[N,C]=(0,a.useState)(!1),[S,I]=(0,a.useState)(!1),[T,_]=(0,a.useState)(!1),[A,D]=(0,a.useState)(null),[P,R]=(0,a.useState)(null),[M,F]=(0,a.useState)(!1),[L,$]=(0,a.useState)(!1),[O,U]=(0,a.useState)(!1),B=(0,a.useRef)(null),q=i.length>0&&d.size===i.length,z=0===i.length,H=e.issues?.filter(e=>!0===e.is_blocking&&"resolved"!==e.status)||[],V=H.length>0,G=H.length>0?H.sort((e,t)=>new Date(t.created_at).getTime()-new Date(e.created_at).getTime())[0]:null,W=async t=>{try{let a=`/api/tasks/${e.id}/issues`.replace("/api","https://api.vanio.ai");if(!(await fetch(a,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({issueId:t,action:"resolve"})})).ok)throw Error("Failed to resolve issue");k?.()}catch(e){console.error("Error resolving issue:",e)}},K=async()=>{try{if($(!0),i.length>0){let e=i.filter(e=>!e.completed);if(e.length>0){console.error("Cannot complete task: incomplete checklist items found",e),alert(`Cannot complete task. The following steps are not completed: 64${e.map(e=>`⢠${e.title}`).join("\n")}`);return}}let t=Math.round(m/60);if(!(await fetch(`/api/tasks?taskId=${e.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"completed",completedAt:new Date().toISOString(),actualDuration:t})})).ok)throw Error("Failed to complete task");setTimeout(()=>{let e=new URL(window.location.href);e.searchParams.delete("task"),window.history.replaceState({},"",e.toString()),w()},1500)}catch(e){console.error("Error completing task:",e),$(!1)}};if(V&&G)return(0,t.jsxs)("div",{className:"fixed inset-0 bg-gray-100 dark:bg-[#0A0A0B] z-[200] flex flex-col",children:[(0,t.jsx)("div",{className:"flex-none border-b border-gray-200 dark:border-white/[0.08] bg-white dark:bg-[#111113]",children:(0,t.jsx)("div",{className:"p-4",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("button",{onClick:w,className:"p-2 hover:bg-gray-100 dark:hover:bg-white/[0.08] rounded-xl transition-colors",children:(0,t.jsx)(eE.ArrowLeft,{className:"w-5 h-5 text-gray-500 dark:text-white/60"})}),(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)("h1",{className:"text-gray-900 dark:text-white font-semibold",children:G?.location==="access"?"Access Issue - Cannot Continue":"Blocking Issue - Cannot Continue"}),(0,t.jsx)("p",{className:"text-gray-500 dark:text-white/50 text-sm",children:"Resolve the issue below to continue with task execution"})]}),(0,t.jsx)("div",{className:"w-9"})]})})}),(0,t.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,t.jsx)(tc,{issue:G,timeline:e.timeline||[],onResolveIssue:void 0,showTimeline:!0,showCommunication:!0,showComposer:!1,taskId:e.id,onMessageSent:k,className:""})}),(0,t.jsxs)("div",{className:"flex-none bg-white/95 dark:bg-[#0A0A0B]/95 backdrop-blur supports-[backdrop-filter]:bg-white/80 dark:supports-[backdrop-filter]:bg-[#0A0A0B]/80 border-t border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsx)("div",{className:"px-4 pt-4",children:(0,t.jsx)("button",{onClick:()=>W(G.id),className:"w-full bg-gradient-to-r from-green-600 to-green-500 text-gray-900 dark:text-white font-semibold py-3 px-4 rounded-lg shadow-lg hover:scale-[1.02] transition-transform",children:(0,t.jsxs)("div",{className:"flex items-center justify-center space-x-2",children:[(0,t.jsx)(E.CheckCircle,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:G?.location==="access"?"I got in":"Issue resolved"})]})})}),(0,t.jsx)(ta,{taskId:e.id,onMessageSent:k,placeholder:"Message property manager or support team..."})]})]});let Y=async()=>{(0,eJ.openFilePicker)(B.current,{accept:"image/*",capture:"environment"})},J=async t=>{if(t?.length&&e.id)try{I(!0);let a=new FormData;
64a.append("taskId",e.id.toString()),Array.from(t).forEach(e=>{a.append("file",e)});let r="/api/tasks/messages".replace("/api","https://api.vanio.ai"),s=await fetch(r,{method:"POST",credentials:"include",body:a}),i=await s.json();if(!s.ok)throw Error("Failed to upload photos");if(console.log("Photos uploaded successfully:",i.urls),n?.aiVerificationPrompt&&i.urls?.[0]){_(!0),D(null);try{let t=`/api/tasks/checklist-items/${n.id}/verify`,a=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({taskId:e.id,photoUrl:i.urls[0]})});if(a.ok){let e=await a.json();D(e)}}catch(e){console.error("AI verification failed:",e)}finally{_(!1)}}}catch(e){console.error("Error uploading photos:",e)}finally{I(!1)}},Q=async t=>{await y(e.id,t),F(!1)};if(M){let a=e.bids?.find(e=>"accepted"===e.status)||e.bids?.[0];return(0,t.jsx)(eb.TaskExecutionIssueReport,{onClose:()=>F(!1),onReportIssue:Q,taskId:e.id,task:{id:e.id,category:e.category,title:e.title},bid:a?{amount:a.amount,currency:a.currency,estimatedDuration:a.estimated_duration,status:a.status}:void 0,serviceProviderRate:e.serviceProviderRate})}return(0,t.jsx)("div",{className:"fixed inset-0 bg-gray-50 dark:bg-black z-[200]",children:(0,t.jsxs)("div",{className:"h-full flex flex-col",children:[(0,t.jsx)("div",{className:"flex-none bg-white dark:bg-[#1C1C1E] border-b border-gray-200 dark:border-white/[0.1]",children:(0,t.jsxs)("div",{className:"px-4 py-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsx)("button",{onClick:w,className:"p-2 hover:bg-gray-100 dark:hover:bg-white/[0.1] rounded-lg transition-colors",children:(0,t.jsx)(eE.ArrowLeft,{className:"w-5 h-5 text-gray-600 dark:text-white/70"})}),(0,t.jsxs)("div",{className:"text-center flex-1",children:[(0,t.jsx)("h1",{className:"text-gray-900 dark:text-white font-medium text-base",children:e.title}),(0,t.jsx)("p",{className:"text-gray-500 dark:text-white/50 text-sm",children:"paused"===c?"Paused":"In Progress"})]}),(0,t.jsx)("button",{onClick:p,className:"p-2 hover:bg-gray-100 dark:hover:bg-white/[0.1] rounded-lg transition-colors",children:(0,t.jsx)(ts.Coffee,{className:"w-5 h-5 text-gray-600 dark:text-white/70"})})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsx)(f.Clock,{className:"w-5 h-5 text-gray-500 dark:text-white/50"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-gray-900 dark:text-white text-lg font-mono font-medium",children:h(m)}),(0,t.jsx)("p",{className:"text-gray-500 dark:text-white/40 text-xs",children:"Elapsed"})]})]}),(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsx)(E.CheckCircle,{className:"w-5 h-5 text-gray-500 dark:text-white/50"}),(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsxs)("p",{className:"text-gray-900 dark:text-white text-lg font-medium",children:[d.size,"/",i.length]}),(0,t.jsx)("p",{className:"text-gray-500 dark:text-white/40 text-xs",children:"Completed"})]})]})]}),(0,t.jsx)("div",{className:"space-y-2 mb-4",children:(0,t.jsx)("div",{className:"w-full bg-gray-100 dark:bg-white/[0.1] rounded-full h-2 overflow-hidden",children:(0,t.jsx)(r.motion.div,{className:"bg-gray-900 dark:bg-white h-2 rounded-full",initial:{width:0},animate:{width:`${u}%`},transition:{duration:.3,ease:"easeOut"}})})}),(j=(e=>{let{nextReservation:t,due_date:a}=e;if(!t||!a||a.split("T")[0]!==t.checkIn)return null;let r=t.checkInTime||"3:00 PM";return{isSameDayCheckIn:!0,checkInTime:r.includes(":")?5===r.length?(()=>{let[e,t]=r.split(":"),a=parseInt(e);return`${0===a?12:a>12?a-12:a}:${t} ${a>=12?"PM":"AM"}`})():r:"3:00 PM",confirmationCode:t.confirmationCode,guestCount:t.guestDetails?.number_of_guests||1}})(e))?(0,t.jsx)("div",{className:"bg-amber-500/10 border border-amber-500/20 rounded-xl p-3 mb-4",children:(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-1.5",children:[(0,t.jsx)("div",{className:"w-1.5 h-1.5 rounded-full bg-amber-500 animate-pulse"}),(0,t.jsx)("span",{className:"text-amber-400 font-medium text-xs",children:"Same-day Check-in"})]}),(0,t.jsxs)("span",{className:"text-amber-300/90 text-xs",children:["Guests arrive at ",(0,t.jsx)("span",{className:"font-semibold text-gray-900 dark:text-white",children:j.checkInTime})]}),(0,t.jsxs)("span",{className:"text-amber-300/70 text-xs",children:["⢠",j.confirmationCode]})]})}):null,(0,t.jsxs)("div",{className:"flex justify-center",children:["active"===c&&(0,t.jsxs)("button",{onClick:g,className:"bg-gray-200 dark:bg-white/[0.15] hover:bg-gray-300 dark:hover:bg-white/[0.2] text-gray-900 dark:text-white px-6 py-3 rounded-xl font-medium transition-all duration-200 flex items-center space-x-2",children:[(0,t.jsx)(tn.Pause,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:"Pause"})]}),"paused"===c&&(0,t.jsxs)("div",{className:"flex space-x-3",children:[(0,t.jsxs)("button",{onClick:x,className:"bg-gray-900 dark:bg-white text-white dark:text-black px-6 py-3 rounded-xl font-medium transition-all duration-200 flex items-center space-x-2 hover:bg-gray-800 dark:hover:bg-white/90",children:[(0,t.jsx)(eS.Play,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:"Resume"})]}),(0,t.jsxs)("button",{onClick:p,className:"bg-gray-200 dark:bg-white/[0.15] hover:bg-gray-300 dark:hover:bg-white/[0.2] text-gray-900 dark:text-white px-6 py-3 rounded-xl font-medium transition-all duration-200 flex items-center space-x-2",children:[(0,t.jsx)(ts.Coffee,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:"Break"})]})]})]})]})}),(0,t.jsxs)("div",{className:"flex-1 p-4 overflow-y-auto bg-gray-50 dark:bg-black",children:[q&&i.length>0&&(0,t.jsxs)(r.motion.div,{initial:{opacity:0,y:20}
64,animate:{opacity:1,y:0},transition:{duration:.3},className:"space-y-6",children:[(0,t.jsx)("div",{className:"bg-gradient-to-br from-green-500/20 to-blue-500/20 rounded-2xl p-8 border border-green-500/30 text-center",children:(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("div",{className:"flex justify-center",children:(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(to.Award,{className:"w-16 h-16 text-green-400"}),(0,t.jsx)(r.motion.div,{className:"absolute -top-1 -right-1",animate:{rotate:[0,10,-10,0]},transition:{duration:2,repeat:1/0},children:(0,t.jsx)(td.Sparkles,{className:"w-6 h-6 text-yellow-400"})})]})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-2xl font-bold text-green-400 mb-2",children:"All Steps Completed! ð"}),(0,t.jsxs)("p",{className:"text-green-300/80 text-lg",children:["Excellent work! You've successfully completed all ",i.length," steps."]}),(0,t.jsxs)("p",{className:"text-gray-500 dark:text-white/60 text-sm mt-2",children:["Time to finalize and mark this task as complete.",(0,t.jsx)("br",{}),"If you have auto-invoicing enabled, an invoice will be automatically generated and sent to the property."]})]}),(0,t.jsx)("div",{className:"bg-green-500/10 rounded-xl p-4 border border-green-500/20",children:(0,t.jsxs)("div",{className:"flex items-center justify-center space-x-2 text-green-400",children:[(0,t.jsx)(tl.CheckCircle2,{className:"w-5 h-5"}),(0,t.jsx)("span",{className:"font-medium",children:"Ready to Complete Task"})]})})]})}),(0,t.jsxs)(r.motion.div,{className:"bg-white dark:bg-[#1C1C1E] rounded-2xl p-4 border border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsxs)("h4",{className:"text-gray-900 dark:text-white font-medium mb-3 flex items-center space-x-2",children:[(0,t.jsx)(tl.CheckCircle2,{className:"w-5 h-5 text-green-400"}),(0,t.jsxs)("span",{children:["Completed Steps (",d.size,")"]})]}),(0,t.jsx)("div",{className:"space-y-2",children:Array.from(d).reverse().map(e=>{let a=i.find(t=>t.id===e);return(0,t.jsx)("div",{className:"bg-green-500/10 text-green-400 p-3 rounded-lg border border-green-500/20 text-sm",children:a?.title},e)})})]}),(0,t.jsx)("div",{className:"h-4"})]}),z&&(0,t.jsxs)(r.motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.3},className:"space-y-6",children:[(0,t.jsxs)("div",{className:"bg-white dark:bg-[#1C1C1E] rounded-2xl border border-gray-200 dark:border-white/[0.08] overflow-hidden",children:[(0,t.jsxs)("div",{className:"p-6 border-b border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsx)("div",{className:"flex items-center justify-between mb-4",children:(0,t.jsx)("div",{className:"bg-blue-500/20 text-blue-400 text-sm font-medium px-3 py-1 rounded-full",children:"Task Details"})}),(0,t.jsx)("h3",{className:"text-gray-900 dark:text-white text-xl font-semibold mb-2 leading-tight",children:"Review Task Requirements"}),(0,t.jsx)("p",{className:"text-gray-500 dark:text-white/60 text-base",children:"No specific checklist provided. Please review the task description and complete as required."})]}),(0,t.jsx)(o.TaskDetails,{task:e,canEdit:!1,canEditStructure:!1,isServiceProvider:!0})]}),(0,t.jsx)("div",{className:"h-4"})]}),!q&&i.length>0&&n&&(0,t.jsxs)(r.motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.3},className:"space-y-6",children:[(0,t.jsx)("div",{className:"bg-white dark:bg-[#1C1C1E] rounded-2xl p-6 border border-gray-200 dark:border-white/[0.08]",children:(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"bg-gray-100 dark:bg-white/[0.1] text-gray-600 dark:text-white/70 text-sm font-medium px-3 py-1 rounded-full",children:["Step ",l+1," of ",i.length]}),n.required&&(0,t.jsx)("div",{className:"bg-orange-500/20 text-orange-400 text-xs font-medium px-3 py-1 rounded-full",children:"Required"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-gray-900 dark:text-white text-xl font-semibold mb-2 leading-tight",children:n.title}),n.section&&(0,t.jsx)("p",{className:"text-gray-500 dark:text-white/60 text-base",children:n.section})]}),n.photoRequired&&(0,t.jsx)("div",{className:"bg-blue-500/10 border border-blue-500/20 rounded-xl p-4",children:(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsx)(eG.Image,{className:"w-5 h-5 text-blue-400"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-blue-400 font-medium",children:"Photo Required"}),(0,t.jsx)("p",{className:"text-blue-400/70 text-sm",children:"Take a photo to verify completion"})]})]})}),n.referenceImageUrl&&(0,t.jsxs)("div",{className:"rounded-xl overflow-hidden border border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsx)("div",{className:"px-4 py-2 bg-gray-50 dark:bg-white/[0.03] border-b border-gray-200 dark:border-white/[0.06]",children:(0,t.jsx)("p",{className:"text-sm font-medium text-gray-700 dark:text-white/70",children:"Reference â what it should look like"})}),(0,t.jsx)("img",{src:n.referenceImageUrl,alt:"Reference",className:"w-full max-h-48 object-cover"})]}),T&&(0,t.jsx)("div",{className:"bg-purple-500/10 border border-purple-500/20 rounded-xl p-4",children:(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsx)("div",{className:"w-5 h-5 border-2 border-purple-400 border-t-transparent roun
64ded-full animate-spin"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-purple-400 font-medium",children:"Vanio AI is checking..."}),(0,t.jsx)("p",{className:"text-purple-400/70 text-sm",children:"Comparing your photo to the standard"})]})]})}),A&&!A.skipped&&(0,t.jsx)("div",{className:`rounded-xl p-4 border ${A.passed?"bg-green-500/10 border-green-500/20":"bg-red-500/10 border-red-500/20"}`,children:(0,t.jsxs)("div",{className:"flex items-start space-x-3",children:[A.passed?(0,t.jsx)(tl.CheckCircle2,{className:"w-6 h-6 text-green-400 flex-shrink-0 mt-0.5"}):(0,t.jsx)(ea.AlertTriangle,{className:"w-6 h-6 text-red-400 flex-shrink-0 mt-0.5"}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("p",{className:`font-semibold text-base ${A.passed?"text-green-400":"text-red-400"}`,children:A.passed?"Looks great!":"Needs attention"}),(0,t.jsx)("p",{className:`text-sm mt-1 ${A.passed?"text-green-400/80":"text-red-400/80"}`,children:A.feedback}),A.details?.issues&&A.details.issues.length>0&&(0,t.jsx)("ul",{className:"mt-2 space-y-1",children:A.details.issues.map((e,a)=>(0,t.jsxs)("li",{className:"text-sm text-red-400/70 flex items-center gap-2",children:[(0,t.jsx)("span",{className:"w-1 h-1 bg-red-400 rounded-full flex-shrink-0"}),e]},a))}),!A.passed&&(0,t.jsx)("button",{onClick:()=>{D(null),Y()},className:"mt-3 bg-red-500/20 hover:bg-red-500/30 text-red-400 px-4 py-2 rounded-lg text-sm font-medium border border-red-500/30 transition-colors",children:"Retake Photo"})]})]})}),n.ratingType&&(0,t.jsxs)("div",{className:"bg-white dark:bg-white/[0.03] rounded-xl p-4 border border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsxs)("p",{className:"text-sm font-medium text-gray-700 dark:text-white/70 mb-3",children:["Rate this item ",n.ratingRequired&&(0,t.jsx)("span",{className:"text-orange-400 text-xs ml-1",children:"(Required)"})]}),(0,t.jsx)(tm.RatingInput,{ratingType:n.ratingType,value:P,onChange:R,size:"md"})]})]})}),(0,t.jsx)(s.AnimatePresence,{children:d.size>0&&(0,t.jsxs)(r.motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"bg-white dark:bg-[#1C1C1E] rounded-2xl p-4 border border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsxs)("h4",{className:"text-gray-900 dark:text-white font-medium mb-3 flex items-center space-x-2",children:[(0,t.jsx)(tl.CheckCircle2,{className:"w-5 h-5 text-green-400"}),(0,t.jsxs)("span",{children:["Completed (",d.size,")"]})]}),(0,t.jsx)("div",{className:"space-y-2",children:Array.from(d).reverse().map(e=>{let a=i.find(t=>t.id===e);return(0,t.jsx)("div",{className:"bg-green-500/10 text-green-400 p-3 rounded-lg border border-green-500/20 text-sm",children:a?.title},e)})})]})}),(0,t.jsx)("div",{className:"h-4"})]},n.id)]}),(0,t.jsxs)("div",{className:"flex-none bg-white dark:bg-[#1C1C1E] border-t border-gray-200 dark:border-white/[0.1] p-4",children:[(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex space-x-3",children:[(0,t.jsxs)("button",{onClick:()=>F(!0),className:"flex-1 bg-red-500/20 hover:bg-red-500/30 text-red-400 py-4 px-6 rounded-xl font-medium transition-all duration-200 flex items-center justify-center space-x-3 border border-red-500/30",children:[(0,t.jsx)(ea.AlertTriangle,{className:"w-5 h-5"}),(0,t.jsx)("span",{children:"Report Issue"})]}),e.issues&&e.issues.length>0&&(0,t.jsxs)("button",{onClick:()=>{w(),setTimeout(()=>{v?.()},100)},className:"flex-1 bg-orange-500/20 hover:bg-orange-500/30 text-orange-400 py-4 px-6 rounded-xl font-medium transition-all duration-200 flex items-center justify-center space-x-3 border border-orange-500/30 relative",children:[(0,t.jsx)(ea.AlertTriangle,{className:"w-5 h-5"}),(0,t.jsx)("span",{children:"View Issues"}),(0,t.jsx)("span",{className:"absolute -top-1 -right-1 bg-orange-500 text-gray-900 dark:text-white text-xs font-bold rounded-full w-6 h-6 flex items-center justify-center",children:e.issues.length})]})]}),(0,t.jsxs)("button",{onClick:Y,disabled:N||S,className:"w-full bg-gray-100 dark:bg-[#2C2C2E] hover:bg-gray-200 dark:hover:bg-[#3A3A3C] text-gray-900 dark:text-white py-4 px-6 rounded-xl font-medium transition-all duration-200 flex items-center justify-center space-x-3 border border-gray-200 dark:border-white/[0.08] disabled:opacity-50",children:[S?(0,t.jsx)("div",{className:"w-5 h-5 border-2 border-gray-300 dark:border-white/30 border-t-gray-700 dark:border-t-white rounded-full animate-spin"}):(0,t.jsx)(es.Camera,{className:"w-5 h-5"}),(0,t.jsx)("span",{children:S?"Uploading...":"Take Photo"})]}),q||z?(0,t.jsxs)("button",{onClick:K,disabled:L,className:"w-full bg-gradient-to-r from-green-600 to-green-500 text-gray-900 dark:text-white py-4 px-6 rounded-xl font-semibold transition-all duration-200 flex items-center justify-center space-x-3 disabled:opacity-50 disabled:cursor-not-allowed hover:scale-[1.02] shadow-lg",children:[L?(0,t.jsx)("div",{className:"w-5 h-5 border-2 border-gray-300 dark:border-white/30 border-t-gray-700 dark:border-t-white rounded-full animate-spin"}):(0,t.jsx)(to.Award,{className:"w-5 h-5"}),(0,t.jsx)("span",{children:L?"Completing...":"Complete Task"})]}):(0,t.jsxs)("button",{onClick:async()=>{try{U(!0),"paused"===c&&x(),await b(),D(null),R(null)}finally{U(!1)}},disabled:n?.photoRequired&&0===d.size||O,className:"w-full bg-gray-900 dark:bg-white text-white dark:text-black py-4 px-6 rounded-xl font-semibold transition-all duration-200 flex items-center justify-center space-x-3 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-800 dark:hover:bg-white/90",children:[O?(0,t.jsx)("div",{className:"w-5 h-5 border-2 border-black/30 border-t-black rounded-full animate-spin"}):(0,t.jsx)(tl.CheckCircle2,{className:"w-5 h-5"}),(0,t.jsx)("span",{children:O?"Completing...":"Complete Step"})]})]}),(0,t.jsx)("input",{type:"file",ref:B,className:"hidden",accept:"image/*",multiple:!0,onChange:e=>J(e.target.files)})]})]})})}function th({task:e,checklist:r,onComplete:s,onUpdateProgress:i,onReportIssue:n,onRefreshTask:l,onClose:o,onScrollToTimeline:d}){let[c,m]=(0,a.useState)("ready"),[u,h]=(0,a.useState)(0),[x,g]=(0,a.useState)(0),[p,b]=(0,a.useState)(0),[f,y]=(0,a.useState)(null),[w,v]=(0,a.useState)(null),[k,j]=(0,a.useState)(null),[N,C]=(0,a.useState)(!1),[S,E]=(0,a.useState)(!1),I=(0,a.useRef)(null),T=new Set(r.filter(e=>e.completed).map(e=>e.id.toString())),_=r.findIndex(e=>!e.completed),A=_>=0?r[_]:null,D=T.size/r.length*100;T.size,r.length,(0,a.useEffect)(()=>{P()},[e.id]);let P=async()=>{try{let t=`/api/tasks/execution/${e.id}`.replace("/api","https://api.vanio.ai"),a=await fetch(t,{method:"GET",credentials:"include",headers:{"Content-Type":"application/json"}});if(a.ok){let t=await a.json();if(t.executionState){let a=t.executionState,r=a.completed_items?.length>0||a.total_work_time>0||a.total_break_time>0||!!e.started_at;C(r);let s=a.current_state||"ready";if(e.metadata?.isPaused?s="paused":t.activeBreak?(s="break",v(new Date(t.activeBreak.started_at).getTime()),j(t.activeBreak.id)):r&&"ready"===s&&(s="active"),m(s),h(a.total_work_time||0),g(a.total_break_time||0),"paused"===s){let t=e.metadata?.pausedAt?new Date(e.metadata.pausedAt).getTime():Date.now();y(t)}}}}catch(e){console.error("Failed to load execution state:",e)}},R=()=>
64{if("paused"===c)return u;let t=e.started_at?new Date(e.started_at).getTime():Date.now();return Math.floor(Math.max(0,Date.now()-t-1e3*x)/1e3)};(0,a.useEffect)(()=>{e.started_at&&h(R())},[e.started_at,x]),(0,a.useEffect)(()=>("active"===c?I.current=setInterval(()=>{h(R()),Date.now()%3e4<1e3&&M()},1e3):"break"===c?I.current=setInterval(()=>{b(w?Math.floor((Date.now()-w)/1e3):0)},1e3):I.current&&(clearInterval(I.current),I.current=null),()=>{I.current&&clearInterval(I.current)}),[c,x,e.started_at]);let M=async()=>{try{let t=`/api/tasks/execution/${e.id}`.replace("/api","https://api.vanio.ai");await fetch(t,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentState:c,totalWorkTime:u,totalBreakTime:x})})}catch(e){console.error("Failed to sync execution state:",e)}},F=e=>{let t=Math.floor(e/3600),a=Math.floor(e%3600/60),r=e%60;return t>0?`${t}:${a.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`:`${a}:${r.toString().padStart(2,"0")}`},L=async()=>{try{if(m("active"),f){let t=`/api/tasks/execution/${e.id}/resume`.replace("/api","https://api.vanio.ai");await fetch(t,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});let a=Math.floor((Date.now()-f)/1e3);g(e=>e+a),y(null)}else{let t=`/api/tasks/execution/${e.id}/start`.replace("/api","https://api.vanio.ai"),a=await fetch(t,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});if(403===a.status){let e=await a.json().catch(()=>({}));m("ready"),eC.toast.error(e?.error||"This task can't be started yet.");return}}h(R()),await M()}catch(e){console.error("Failed to start task:",e)}},$=async()=>{try{m("paused"),y(Date.now());let t=`/api/tasks/execution/${e.id}/pause`.replace("/api","https://api.vanio.ai");await fetch(t,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:"User paused task"})}),await M()}catch(e){console.error("Failed to pause task:",e)}},O=async()=>{try{m("break"),v(Date.now()),b(0);let t=`/api/tasks/execution/${e.id}/break/start`.replace("/api","https://api.vanio.ai"),a=await fetch(t,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({breakType:"user_break",reason:"User requested break"})});if(a.ok){let e=await a.json();j(e.breakId)}await M()}catch(e){console.error("Failed to start break:",e)}},U=async()=>{try{if(m("active"),k){let t=`/api/tasks/execution/${e.id}/break/end`.replace("/api","https://api.vanio.ai");await fetch(t,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({breakId:k})})}if(w){let e=Math.floor((Date.now()-w)/1e3);g(t=>t+e),v(null),b(0),j(null)}await M()}catch(e){console.error("Failed to end break:",e)}},B=async()=>{if(A)try{if("in_progress"!==e.status&&(console.log("ð [TaskExecutionView] Task status is not in_progress, updating it..."),(await fetch(`/api/tasks?taskId=${e.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"in_progress",startedAt:new Date().toISOString()})})).ok||console.error("Failed to update task status to in_progress")),!(await fetch(`/api/tasks/checklists?taskId=${e.id}&itemId=${A.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({completed:!0})})).ok)throw Error("Failed to mark checklist item as completed");console.log("ð [TaskExecutionView] Checklist item completed, refreshing task data..."),await l(),await M()}catch(e){console.error("Failed to complete checklist item:",e),await l(),await M()}},q=async t=>{await n(e.id,t),E(!1),await l()},z=async t=>{try{let a=`/api/tasks/${e.id}/issues`.replace("/api","https://api.vanio.ai"),r=await fetch(a,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({issueId:t,action:"resolve"})});if(!r.ok){let e=await r.json().catch(()=>({error:"Unknown error"}));throw Error(e.error||"Failed to resolve issue")}await l()}catch(e){console.error("Error resolving access issue:",e)}};if(S){let a=e.bids?.find(e=>"accepted"===e.status)||e.bids?.[0];return(0,t.jsx)(eb.TaskExecutionIssueReport,{onClose:()=>E(!1),onReportIssue:q,taskId:e.id,task:{id:e.id,category:e.category,title:e.title}
64,presetType:"access_problem",bid:a?{amount:a.amount,currency:a.currency,estimatedDuration:a.estimated_duration,status:a.status}:void 0,serviceProviderRate:e.serviceProviderRate})}return"ready"===c?(0,t.jsx)(tr,{task:e,checklist:r,onStart:L,onClose:o,onReportAccessIssue:()=>E(!0),onResolveAccessIssue:z,onRefresh:l,isResuming:N,completedItems:T,elapsedTime:u}):"break"===c?(0,t.jsx)(ti,{task:e,completedItems:T,checklist:r,totalBreakTime:p,progress:D,formatTime:F,onResumeFromBreak:U}):(0,t.jsx)(tu,{task:e,checklist:r,currentItem:A,currentItemIndex:_,completedItems:T,executionState:c,elapsedTime:u,progress:D,formatTime:F,onStart:L,onPause:$,onBreak:O,onCompleteItem:B,onReportIssue:n,onClose:o,onScrollToTimeline:d,onRefreshTask:l})}var tx=e.i(358519),tg=e.i(201928),tp=e.i(286536),tb=e.i(16715),tf=e.i(560491),ty=e.i(510087),tw=e.i(714004),tv=e.i(466261),tk=e.i(734858);el.Wrench,td.Sparkles,tp.Eye,tg.ShoppingCart,e_.MessageCircle,A.FileText,tb.RefreshCw,tx.Brush,tx.Brush,D.ClipboardCheck;let tj=async e=>{let t=await fetch(e);if(!t.ok)throw Error("Failed to fetch task details");return t.json()};function tN({taskId:e,onClose:f,context:y="dashboard"}){let w,v,k,j,C,S,E="operations"===y,{currentCustomerId:I,users:{users:T}}=(0,e4.useCustomer)(),_=(0,ee.useUserSettings)(I||void 0),{data:A}=(0,e6.useSession)(),{openCommandPalette:D,setCommandPaletteContext:P}=(0,ex.useCommandPalette)(),R=(0,eg.useRouter)(),M=(0,eg.useSearchParams)(),F=(0,eg.usePathname)(),[L,O]=(0,a.useState)(()=>M?.get("marketplace")==="true"),[U,B]=(0,a.useState)(()=>M?.get("issues")==="true"),[q,z]=(0,a.useState)(window.innerWidth),[H,V]=(0,a.useState)(!1),[G,W]=(0,a.useState)(null),[K,Y]=(0,a.useState)([]),J=(0,a.useRef)(null),Q=(0,a.useCallback)(()=>{J.current&&J.current.scrollIntoView({behavior:"smooth",block:"start"})},[]);(0,a.useEffect)(()=>{let e=()=>z(window.innerWidth);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),(0,a.useEffect)(()=>{O("true"===M?.get("marketplace"))},[M]),(0,a.useEffect)(()=>{B("true"===M?.get("issues"))},[M]);let X=(0,a.useCallback)(t=>{O(t);let a=new URLSearchParams(M?.toString()||"");a.set("task",e.toString()),t?(a.set("marketplace","true"),a.delete("issues"),B(!1)):a.delete("marketplace"),R.replace(`${F}?${a.toString()}`,{scroll:!1})},[F,R,M,e]),Z=(0,a.useCallback)(t=>{B(t);let a=new URLSearchParams(M?.toString()||"");a.set("task",e.toString()),t?(a.set("issues","true"),a.delete("marketplace"),O(!1)):a.delete("issues"),R.replace(`${F}?${a.toString()}`,{scroll:!1})},[F,R,M,e]),{data:er,error:es,mutate:ei}=(0,tf.default)(`/api/tasks?taskId=${e}`,tj,{revalidateOnFocus:!0,revalidateOnReconnect:!0,dedupingInterval:5e3,refreshInterval:15e3}),{data:en}=(0,tf.default)(E&&er?.id?`/api/operations/task-contacts?taskId=${er.id}`:null,e=>fetch(e,{credentials:"include"}).then(e=>e.json())),el=en?.contactTarget||null,{activeViewers:eo,typingUsers:ed,isConnected:ec}=(0,e5.useRealtimePresence)("task",er?.id,!1),em=_.getCurrentRole(I||void 0),eu=(0,a.useMemo)(()=>{if(em&&["admin","owner","user","team_lead","supervisor","roamer"].includes(em))return!0;if(em&&["partner","maintenance","cleaner"].includes(em)){let e=A?.user?.id;if(!e||!er)return!1;if(er.assignments?.some(t=>t.user_id===e))return!0;if("partner"===em&&_.settings?.partner?.partnerId&&T){let e=_.settings.partner.partnerId,t=T.filter(t=>{let a=t.company?.companyId===e,r=t.serviceProvider?.type==="company"&&t.serviceProvider?.id===e;return a||r}).map(e=>e.id);return er.assignments?.some(e=>t.includes(e.user_id))}return!1}return!0},[em,er?.assignments,A?.user?.id,_.settings,T]),eh=(0,a.useMemo)(()=>!!(em&&["admin","owner","user","team_lead","supervisor","roamer","concierge"].includes(em)),[em]),ep=(0,a.useMemo)(()=>er?.marketplace_eligible||er?.metadata?.marketplaceEligible||er?.bids&&er.bids.length>0||er?.payment_status||er?.escalations&&er.escalations.length>0,[er]),eb=(0,a.useMemo)(()=>!0,[]),ef=(0,a.useMemo)(()=>!!(em&&["cleaner","maintenance","partner"].includes(em)),[em]),ey=(0,a.useMemo)(()=>!!er&&!!I&&(!!_.settings?.isSuperUser||(er.customer_id,!0)),[er,I,_.settings?.isSuperUser]),ev=(0,a.useCallback)(()=>{ei()},[ei]);(0,a.useCallback)(e=>{er&&(e.new?.task_id===er.id||e.old?.task_id===er.id)&&ei(async t=>{if(!t)return t;if("task_assignments"===e.table){let a=[...t.assignments||[]];if("DELETE"===e.eventType)return{...t,assignments:a.filter(t=>
64t.id!==e.old.id)};if("INSERT"===e.eventType)return{...t,assignments:[...a,e.new]};if("UPDATE"===e.eventType)return{...t,assignments:a.map(t=>t.id===e.new.id?{...t,...e.new}:t)}}return"tasks"===e.table&&e.new?.id===er.id?{...t,...e.new}:t},!1)},[er,ei]);let ek=(0,a.useCallback)(async e=>{e?ei(t=>({...t,...e}),!1):await ei()},[ei]);(0,a.useEffect)(()=>{if(!er?.id||!I)return;let e=tw.supabase.channel(`task-sidebar:${er.id}`).on("postgres_changes",{event:"*",schema:"public",table:"tasks",filter:`id=eq.${er.id}`},e=>{ei()}).on("postgres_changes",{event:"*",schema:"public",table:"task_timeline",filter:`task_id=eq.${er.id}`},e=>{ei()}).on("postgres_changes",{event:"*",schema:"public",table:"task_issues",filter:`task_id=eq.${er.id}`},e=>{ei()}).on("postgres_changes",{event:"*",schema:"public",table:"task_assignments",filter:`task_id=eq.${er.id}`},e=>{ei()}).on("postgres_changes",{event:"*",schema:"public",table:"task_checklist",filter:`task_id=eq.${er.id}`},e=>{ei()}).on("postgres_changes",{event:"*",schema:"public",table:"tasks",filter:`parent_task_id=eq.${er.id}`},e=>{ei()}).on("postgres_changes",{event:"*",schema:"public",table:"task_bids",filter:`task_id=eq.${er.id}`},e=>{ei()}).on("postgres_changes",{event:"*",schema:"public",table:"task_payments",filter:`task_id=eq.${er.id}`},e=>{ei()}).on("postgres_changes",{event:"*",schema:"public",table:"task_tags",filter:`task_id=eq.${er.id}`},e=>{ei()}).subscribe();return()=>{tw.supabase.removeChannel(e)}},[er?.id,I,ei]),(0,a.useEffect)(()=>{let e=e=>{"Escape"===e.key&&f()};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}},[f,er?.id]),(0,a.useEffect)(()=>{let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}},[]);let ej=(0,a.useCallback)(e=>{e?.preventDefault(),e?.stopPropagation();let t=new URLSearchParams(M?.toString()||"");t.delete("task"),t.delete("marketplace"),t.delete("issues"),R.replace(`${F}?${t.toString()}`,{scroll:!1}),f()},[f,F,R,M]),eC=async e=>{try{if(!(await fetch(`/api/tasks?customerId=${I}&taskId=${er.id}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e.title,description:e.description,isSubtask:!0,parentTaskId:er.id,customerId:I,category:er.category||"other",priority:er.priority||"normal"})})).ok)throw Error("Failed to create subtask");await ei()}catch(e){console.error("Error creating subtask:",e)}},eS=async(e,t)=>{try{if(!(await fetch(`/api/tasks?taskId=${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).ok)throw Error("Failed to update subtask");await ei()}catch(e){console.error("Error updating subtask:",e)}};(0,a.useEffect)(()=>{V("true"===M?.get("execution"))},[M]);let eE=(0,a.useCallback)(e=>{V(e);{let t=new URLSearchParams(M?.toString()||"");e?t.set("execution","true"):t.delete("execution"),R.replace(`${F}?${t.toString()}`,{scroll:!1})}},[F,R,M]),eI=(0,a.useCallback)(async()=>{try{eE(!0)}catch(e){console.error("Error starting task execution:",e),eE(!1)}},[eE]),eT=(0,a.useCallback)(()=>{V(!1);{let e=new URLSearchParams(M?.toString()||"");e.delete("execution"),R.replace(`${F}?${e.toString()}`,{scroll:!1})}},[F,R,M]),e_=(0,a.useCallback)(async(e,t)=>{try{let a=t.totalTime?Math.round(t.totalTime/60):void 0;if(!(await fetch(`/api/tasks?taskId=${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"completed",completedAt:new Date().toISOString(),actualDuration:a})})).ok)throw Error("Failed to complete task");eE(!1),await ei()}catch(e){console.error("Error completing task execution:",e)}},[ei,eE]),eA=(0,a.useCallback)(async(e,t)=>{await ei()},[ei]),eD=(0,a.useCallback)(async(e,t)=>{try{await ei()}catch(e){console.error("Error refreshing task after issue report:",e)}},[ei]),eP=(0,a.useCallback)(async()=>{try{await ei()}catch(e){console.error("Error refreshing task data:",e)}},[ei]),eR=(0,a.useMemo)(()=>er?.issues?.filter(e=>!0===e.is_blocking&&"resolved"!==e.status)||[],[er?.issues]),eM=eR.length>0,eF=eR.length>0?eR.sort((e,t)=>new Date(t.created_at).getTime()-new Date(e.created_at).getTime())[0]:null,eL=(0,a.useCallback)(async t=>{try{let a=`/api/tasks/${e}/issues`.replace("/api","https://api.vanio.ai");if(!(await fetch(a,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({issueId:t,action:"resolve"})})).ok)throw Error("Failed to resolve issue");await ei()}catch(e){console.error("Error resolving issue:",e)}},[e,ei]);
64if(!er&&!es)return(0,t.jsxs)(i.Portal,{children:[(0,t.jsx)("div",{className:"fixed inset-0 bg-black/50 z-[40]",onClick:ej}),(0,t.jsx)("div",{className:"fixed right-0 top-0 h-full w-full md:w-[448px] bg-[#18181A] shadow-xl z-[50] flex items-center justify-center",children:(0,t.jsx)("div",{className:"w-8 h-8 border-2 border-white/20 border-t-white/80 rounded-full animate-spin"})})]});if(!ey)return(0,t.jsxs)(i.Portal,{children:[(0,t.jsx)("div",{className:"fixed inset-0 bg-black/50 z-[102]",onClick:ej}),(0,t.jsx)("div",{className:"fixed right-0 top-0 h-full w-full md:w-[448px] bg-[#18181A] shadow-xl z-[50]",children:(0,t.jsx)(ty.ErrorDisplay,{error:Error("You do not have permission to view this task"),statusCode:401,referenceId:`TASK-${e}`})})]});if(es)return(0,t.jsxs)(i.Portal,{children:[(0,t.jsx)("div",{className:"fixed inset-0 bg-black/50 z-[100]",onClick:ej}),(0,t.jsx)("div",{className:"fixed right-0 top-0 h-full w-full md:w-[448px] bg-[#18181A] shadow-xl z-[50]",children:(0,t.jsx)(ty.ErrorDisplay,{error:es})})]});if(H&&er){let e={id:"string"==typeof er.id?parseInt(er.id):er.id,customerId:er.customer_id||1,title:er.title||"Task Execution",description:er.description||"",category:er.category||"other",priority:er.priority||"medium",status:er.status,dueDate:er.due_date||null,startDate:er.start_date||null,estimatedDuration:er.estimated_duration||30,actualDuration:er.actual_duration||null,createdAt:er.created_at||new Date().toISOString(),updatedAt:er.updated_at||new Date().toISOString(),completedAt:er.completed_at||null,createdBy:er.created_by||A?.user?.id||"",updatedBy:er.updated_by||A?.user?.id||"",assignedTo:null,assignedBy:null,assignedAt:null,started_at:er.started_at||null,requiresApproval:er.requires_approval||!1,requiresAcceptance:er.requires_acceptance||!1,acceptanceDeadline:er.acceptance_deadline||null,approvalDeadline:er.approval_deadline||null,isSubtask:er.is_subtask||!1,parentTaskId:er.parent_task_id||null,subtaskOrder:er.subtask_order||null,metadata:er.metadata||{},tags:er.tags||[],attachments:er.attachments||[],assignments:er.assignments||[],checklistTemplateId:null,marketplaceEligible:!1,firstResponseAt:null,lastProgressUpdate:null,relations:[],notes:[],completionReminderSent:!1,marketplacePublishedAt:null,historicalAnalytics:er.historicalAnalytics,issues:er.issues||[],timeline:er.timeline||[],bids:er.bids||[],serviceProviderRate:er.serviceProviderRate||void 0,sourceReservation:er.sourceReservation||null,nextReservation:er.nextReservation||null,occupancy:er.occupancy||null,permission_to_enter:er.permission_to_enter??null,permission_to_enter_set_at:er.permission_to_enter_set_at??null,permission_to_enter_set_by:er.permission_to_enter_set_by??null,permission_to_enter_source:er.permission_to_enter_source??null,permissionToEnterSetByName:er.permissionToEnterSetByName??null,due_date:er.due_date||null},a=(er.checklist||[]).map((e,t)=>({id:e.id.toString(),title:e.title||`Step ${t+1}`,section:e.section||"",required:e.required,completed:e.completed,photoRequired:e.photo_required||!1,estimatedDuration:e.estimated_duration||5,instructions:e.instructions||"",verificationCriteria:e.verification_criteria||"",order:t}));return(0,t.jsx)(th,{task:e,checklist:a,onComplete:e_,onUpdateProgress:eA,onReportIssue:eD,onClose:eT,onScrollToTimeline:Q,onRefreshTask:eP})}return(0,t.jsxs)(i.Portal,{children:[(0,t.jsx)("div",{className:"fixed inset-0 bg-black/50 z-[160]",onClick:ej,onWheel:e=>e.stopPropagation(),onTouchMove:e=>e.stopPropagation()}),(0,t.jsx)(s.AnimatePresence,{children:(0,t.jsxs)(r.motion.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",damping:30,stiffness:300},className:(0,n.cn)("fixed right-0 top-0 h-full w-full","md:w-[448px]","bg-gray-50 dark:bg-[#18181A] shadow-xl z-[161]","flex flex-col isolate","border-l border-gray-200 dark:border-white/[0.08]"),onClick:e=>e.stopPropagation(),onWheel:e=>e.stopPropagation(),onTouchMove:e=>e.stopPropagation(),children:[(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto relative z-[1] overscroll-contain",onWheel:e=>e.stopPropagation(),onTouchMove:e=>e.stopPropagation(),children:[(0,t.jsx)("div",{className:"border-b border-white/[0.08] bg-[#18181A]/95 backdrop-blur supports-[backdrop-filter]:bg-[#18181A]/80",children:(0,t.jsx)(l.TaskHeader,{task:{...er,tags:er.tags}
64,onClose:ej,onUpdate:ek,checklist:er.checklist,activeViewers:eo,typingUsers:ed,isConnected:ec,onStartExecution:eI,onScrollToTimeline:Q,onToggleIssues:Z})}),(0,t.jsxs)("div",{className:"pb-[120px] max-w-full",children:[(0,t.jsx)(p.TaskProgress,{task:er}),(0,t.jsx)(eN,{task:er,context:y}),eM&&eF?(0,t.jsx)(tc,{issue:eF,timeline:er.timeline,onResolveIssue:eL,showTimeline:!1,showCommunication:!1,showComposer:!1,taskId:er.id,onMessageSent:ev,className:"border-b border-white/[0.08]",isServiceProvider:ef}):(0,t.jsxs)(t.Fragment,{children:[E&&er.metadata?.reservationId&&(0,t.jsx)(tC,{reservationId:er.metadata.reservationId,listingId:er.metadata?.listingId,listingAddress:er.listing?.address||er.listing?.city}),(0,t.jsx)(o.TaskDetails,{task:er,onUpdate:ek,canEdit:eu,canEditStructure:eh,isServiceProvider:ef,showSmartDevices:!1}),(0,t.jsx)(d.TaskChecklist,{taskId:er.id,checklist:er.checklist,onUpdate:ek,selectedTemplateId:er.checklist_template_id,task:er,canEdit:eu,canEditStructure:eh}),!er.is_subtask&&(0,t.jsx)(c.TaskSubtasks,{taskId:er.id,subtasks:er.subtasks,onAddSubtask:eC,onUpdateSubtask:eS,canEdit:eu,canEditStructure:eh}),(0,t.jsx)(m.TaskBilling,{billing:er.billing}),(0,t.jsx)(u.TaskExpensesPanel,{taskId:"string"==typeof er.id?parseInt(er.id):er.id,canApprove:eh})]}),eb&&(0,t.jsx)("div",{className:"border-t border-white/[0.08]",children:(0,t.jsxs)("button",{onClick:()=>X(!L),className:(0,n.cn)("w-full px-6 py-4 flex items-center justify-between","hover:bg-white/[0.02] transition-colors duration-200",L&&"bg-blue-500/5"),children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsx)("div",{className:(0,n.cn)("w-8 h-8 rounded-lg flex items-center justify-center",L?"bg-blue-500/20 text-blue-400":"bg-white/[0.1] text-white/60"),children:(0,t.jsx)($.Zap,{className:"w-4 h-4"})}),(0,t.jsxs)("div",{className:"text-left",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-white",children:ef?"Property Details":"Marketplace"}),(0,t.jsx)("p",{className:"text-xs text-white/60",children:ef?"View property information & access details":ep?(k=er?.assignments?.some(e=>"accepted"===e.status),j=er?.bids?.find(e=>"accepted"===e.status),k&&j?`Assigned to ${j.provider?.name||"provider"} ⢠$${j.amount}`:er?.bids?.length>0?(w=er.bids.filter(e=>"pending"===e.status).length,v=er.bids.length,w>0?`${w} active bid${1!==w?"s":""} ⢠${v} total`:`${v} bid${1!==v?"s":""} received`):"Find providers, manage bids & payments"):"Enable marketplace to receive bids"})]}),!L&&(0,t.jsxs)("div",{className:"flex items-center space-x-1",children:[(C=er?.assignments?.some(e=>"accepted"===e.status),S=er?.bids?.find(e=>"accepted"===e.status),C&&S?(0,t.jsx)("div",{className:"px-2 py-1 bg-green-500/10 text-green-400 rounded-full text-xs font-medium",children:"Assigned"}):null),er?.bids?.length>0&&!er?.assignments?.some(e=>"accepted"===e.status)&&(0,t.jsx)("div",{className:"px-2 py-1 bg-blue-500/10 text-blue-400 rounded-full text-xs font-medium",children:er.bids.filter(e=>"pending"===e.status).length>0?`${er.bids.filter(e=>"pending"===e.status).length} active bid${1!==er.bids.filter(e=>"pending"===e.status).length?"s":""}`:`${er.bids.length} bid${1!==er.bids.length?"s":""}`}),!ep&&(0,t.jsx)("div",{className:"px-2 py-1 bg-gray-500/10 text-gray-400 rounded-full text-xs font-medium",children:"Enable"}),er?.payment_status==="paid"&&(0,t.jsx)("div",{className:"px-2 py-1 bg-green-500/10 text-green-400 rounded-full text-xs font-medium",children:"Paid"}),er?.payment_status==="pending"&&er?.assignments?.some(e=>"accepted"===e.status)&&(0,t.jsx)("div",{className:"px-2 py-1 bg-yellow-500/10 text-yellow-400 rounded-full text-xs font-medium",children:"Payment Due"}),er?.escalations?.length>0&&(0,t.jsx)("div",{className:"px-2 py-1 bg-red-500/10 text-red-400 rounded-full text-xs font-medium",children:er.escalations.filter(e=>"active"===e.status).length>0?"Active Escalation":"Escalated"})]})]}),(0,t.jsx)(r.motion.div,{animate:{rotate:90*!!L},transition:{duration:.2},children:(0,t.jsx)(N.ChevronRight,{className:"w-4 h-4 text-white/40"})})]})}),!(eM&&eF)&&(0,t.jsxs)("div",{className:"space-y-2 px-6 py-3 border-t border-white/[0.08]",children:[(0,t.jsx)(x.TaskSmartDevicesPanel,{task:er}),(0,t.jsx)(h.TaskRecurrencePanel,{taskId:er.id,recurrenceId:er.recurrenceId??er.recurrence_id??null,canEdit:eh,onUpdate:ek})]}),(0,t.jsx)("div",{ref:J,children:(0,t.jsx)(g.TaskTimeline,{events:er.timeline,typingUsers:ed})})]})]}),eu&&(0,t.jsx)("div",{className:"absolute bottom-0 left-0 right-0 bg-[#18181A]/95 backdrop-blur supports-[backdrop-filter]:bg-[#18181A]/80 z-[1]",onWheel:e=>e.stopPropagation(),onTouchMove:e=>e.stopPropagation(),children:(0,t.jsx)(ta,{taskId:er.id,task:er,onTaskUpdate:ek,onMessageSent:ev,onStartExecution:eI,hostContact:E?el:null,contactRole:en?.role||null,reservationId:er.metadata?.reservationId?Number(er.metadata.reservationId):null,onCommandPaletteOpen:()=>{P({topic:"task",type:"direct",placeholder:"What shall we do with this task?",context:"task",itemId:er.id}),D()},placeholder:eM?ef?"Message property manager or support team...":"Respond to service provider...":void 0})})]},"main-task-sidebar")}),(0,t.jsx)(s.AnimatePresence,{children:U&&(0,t.jsxs)(r.motion.div,{initial:{x:"100%",opacity:0}
64,animate:{x:0,opacity:1},exit:{x:"100%",opacity:0},transition:{type:"spring",damping:30,stiffness:300,opacity:{duration:.2}},className:(0,n.cn)("fixed top-0 h-full w-full lg:w-[600px]","bg-[#1A1A1C] shadow-xl z-[162]","border-l border-white/[0.08]","flex flex-col"),style:{right:q>=768?"448px":"0px"},onClick:e=>e.stopPropagation(),children:[(0,t.jsx)("div",{className:"flex-none border-b border-white/[0.08] bg-[#1A1A1C]/95 backdrop-blur p-4",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsx)("div",{className:"w-8 h-8 bg-red-500/20 rounded-lg flex items-center justify-center",children:(0,t.jsx)(ea.AlertTriangle,{className:"w-4 h-4 text-red-400"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-white",children:"Task Issues"}),(0,t.jsx)("p",{className:"text-sm text-white/60",children:"Manage and resolve task issues"})]})]}),(0,t.jsx)("button",{onClick:()=>Z(!1),className:"p-2 hover:bg-white/[0.1] rounded-lg transition-colors duration-200",children:(0,t.jsx)(N.ChevronRight,{className:"w-4 h-4 text-white/60"})})]})}),(0,t.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,t.jsx)(ew,{task:er,onUpdate:ek,canEdit:eu,canEditStructure:eh})})]},"issues-panel")}),(0,t.jsx)(s.AnimatePresence,{children:L&&eb&&(0,t.jsxs)(r.motion.div,{initial:{x:"100%",opacity:0}
64,animate:{x:0,opacity:1},exit:{x:"100%",opacity:0},transition:{type:"spring",damping:30,stiffness:300,opacity:{duration:.2}},className:(0,n.cn)("fixed top-0 h-full w-full lg:w-[600px]","bg-[#1A1A1C] shadow-xl z-[162]","border-l border-white/[0.08]","flex flex-col"),style:{right:q>=768?"448px":"0px"},onClick:e=>e.stopPropagation(),children:[(0,t.jsx)("div",{className:"flex-none border-b border-white/[0.08] bg-[#1A1A1C]/95 backdrop-blur p-4",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsx)("div",{className:"w-8 h-8 bg-blue-500/20 rounded-lg flex items-center justify-center",children:(0,t.jsx)($.Zap,{className:"w-4 h-4 text-blue-400"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-white",children:ef?"Property Details":"Marketplace"}),(0,t.jsx)("p",{className:"text-sm text-white/60",children:ef?"Property information & access details":"Manage bids, providers & payments"})]})]}),(0,t.jsx)("button",{onClick:()=>X(!1),className:"p-2 hover:bg-white/[0.1] rounded-lg transition-colors duration-200",children:(0,t.jsx)(N.ChevronRight,{className:"w-4 h-4 text-white/60"})})]})}),(0,t.jsx)("div",{className:"flex-1 overflow-hidden",children:ef?(0,t.jsx)(et,{task:er,onClose:()=>X(!1)}):(0,t.jsx)(b.TaskMarketplacePanel,{task:er,onUpdate:ek,canEdit:eu,canEditStructure:eh})})]},"marketplace-panel")})]})}function tC({reservationId:e,listingId:a,listingAddress:r}){let{data:s}=(0,tf.default)(e?`/api/operations/task-context?reservationId=${e}${a?`&listingId=${a}`:""}`:null,e=>fetch(e,{credentials:"include"}).then(e=>e.json()));if(!s||s.error)return null;let{departingGuest:i,arrivingGuest:l,checkoutTime:o,checkinTime:d,isTurnover:c,listingName:m,address:u}=s,h=u||r;return(0,t.jsxs)("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-white/[0.08] space-y-2",children:[c&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-lg bg-orange-500/15 border border-orange-500/20 w-fit",children:[(0,t.jsx)(tv.ArrowRightLeft,{className:"w-3.5 h-3.5 text-orange-400"}),(0,t.jsx)("span",{className:"text-xs font-semibold text-orange-400",children:"Turnover"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-4 text-sm",children:[i&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(J.LogOut,{className:"w-3.5 h-3.5 text-gray-400 dark:text-white/30"}),(0,t.jsx)("span",{className:"text-gray-600 dark:text-white/50",children:i}),o&&(0,t.jsx)("span",{className:"text-xs font-mono text-gray-400 dark:text-white/30",children:o})]}),l&&(0,t.jsxs)("div",{className:(0,n.cn)("flex items-center gap-1.5",c?"text-orange-500 dark:text-orange-400 font-medium":""),children:[(0,t.jsx)(Y.LogIn,{className:"w-3.5 h-3.5"}),(0,t.jsx)("span",{children:l}),d&&(0,t.jsx)("span",{className:"text-xs font-mono",children:d})]})]}),h&&(0,t.jsxs)("a",{href:`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(h)}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-xs text-blue-500 hover:text-blue-400 transition-colors w-fit",children:[(0,t.jsx)(tk.Navigation,{className:"w-3 h-3"}),"Get directions"]})]})}var tS=e.i(979357),tE=e.i(534158),tE=tE,tI=e.i(686311),tT=e.i(343432),t_=e.i(531278),tA=e.i(664659),tD=e.i(805899),tP=e.i(451076),tR=e.i(270029),tM=e.i(44140);let tF=async e=>{let t=await fetch(e,{credentials:"include"});if(!t.ok)throw Error("Failed to fetch");return t.json()};function tL({taskId:e,onClose:l}){let{currentCustomerId:o,users:{users:d},workspaceType:c}=(0,e4.useCustomer)(),m=(0,ee.useUserSettings)(o||void 0),{settings:u}=m,{data:h}=(0,e6.useSession)(),x=u?.theme!=="light",[g,p]=(0,a.useState)(!0),[f,y]=(0,a.useState)(!1),[w,v]=(0,a.useState)("chat"),k=(0,a.useRef)(null),{data:j,error:N,mutate:C}=(0,tf.default)(`/api/tasks?taskId=${e}`,tF,{revalidateOnFocus:!0,revalidateOnReconnect:!0,dedupingInterval:5e3,refreshInterval:15e3}),{data:S}=(0,tf.default)(j?.id?`/api/operations/task-contacts?taskId=${j.id}`:null,tF),E=S?.contactTarget||null,I=j?.metadata?.reservationId,T=j?.metadata?.listingId,{data:_}=(0,tf.default)(I?`/api/operations/task-context?reservationId=${I}${T?`&listingId=${T}`:""}`:null,tF),A=m.getCurrentRole(o||void 0),D=(0,a.useMemo)(()=>
64{if(A&&["admin","owner","user","team_lead","supervisor","roamer"].includes(A))return!0;if(A&&["partner","maintenance","cleaner"].includes(A)){let e=h?.user?.id;if(!e||!j)return!1;if(j.assignments?.some(t=>t.user_id===e))return!0;if("partner"===A&&m.settings?.partner?.partnerId&&d){let e=m.settings.partner.partnerId,t=d.filter(t=>{let a=t.company?.companyId===e,r=t.serviceProvider?.type==="company"&&t.serviceProvider?.id===e;return a||r}).map(e=>e.id);return j.assignments?.some(e=>t.includes(e.user_id))}return!1}return!0},[A,j?.assignments,h?.user?.id,m.settings,d]),R=(0,a.useMemo)(()=>!!(A&&["admin","owner","user","team_lead","supervisor","roamer","concierge"].includes(A)),[A]),M=(0,a.useCallback)(async()=>{await C()},[C]),F=(0,a.useCallback)(()=>{setTimeout(()=>C(),500)},[C]);(0,a.useEffect)(()=>{j?.timeline&&k.current?.scrollIntoView({behavior:"smooth"})},[j?.timeline?.length]),(0,a.useEffect)(()=>(document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}),[]);let L=(0,a.useCallback)(()=>{document.body.style.overflow="",l()},[l]);if(N)return(0,t.jsxs)(i.Portal,{children:[(0,t.jsx)("div",{className:"fixed inset-0 z-[160] bg-black/60",onClick:L}),(0,t.jsx)("div",{className:"fixed inset-y-0 right-0 z-[161] w-full lg:w-[1100px] bg-gray-50 dark:bg-[#18181A] flex items-center justify-center",children:(0,t.jsx)("p",{className:"text-sm text-red-400",children:"Failed to load task"})})]});if(!j)return(0,t.jsxs)(i.Portal,{children:[(0,t.jsx)("div",{className:"fixed inset-0 z-[160] bg-black/60"}),(0,t.jsx)("div",{className:"fixed inset-y-0 right-0 z-[161] w-full lg:w-[1100px] bg-gray-50 dark:bg-[#18181A] flex items-center justify-center",children:(0,t.jsx)("div",{className:"w-6 h-6 border-2 border-gray-300 dark:border-white/20 border-t-orange-500 rounded-full animate-spin"})})]});let $=[...j.timeline||[]].sort((e,t)=>new Date(e.created_at).getTime()-new Date(t.created_at).getTime());return(0,t.jsxs)(i.Portal,{children:[(0,t.jsx)(r.motion.div,{initial:{opacity:0}
64,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[160] bg-black/60",onClick:L}),(0,t.jsxs)(r.motion.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",damping:30,stiffness:300},className:(0,n.cn)("fixed inset-y-0 right-0 z-[161]","w-full lg:w-[1100px]","bg-gray-100 dark:bg-[#18181A]","flex shadow-2xl","border-l border-gray-200 dark:border-white/[0.08]"),onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)("div",{className:"flex-1 flex flex-col min-w-0",children:[(0,t.jsxs)("div",{className:(0,n.cn)("px-5 py-3 border-b","border-gray-200 dark:border-white/[0.08]","bg-white dark:bg-[#1C1C1E]"),children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,t.jsx)("button",{onClick:L,className:"text-gray-400 hover:text-gray-600 dark:hover:text-white/70 flex-shrink-0",children:(0,t.jsx)(P.X,{className:"w-5 h-5"})}),(0,t.jsxs)("div",{className:"min-w-0",children:[j.listing?.name?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("h2",{className:(0,n.cn)("text-sm font-semibold truncate",x?"text-white":"text-gray-900"),children:j.listing.name}),(0,t.jsx)(tP.EditableTaskTitle,{taskId:j.id,title:j.title,onUpdate:M,as:"div",className:(0,n.cn)("text-xs truncate",x?"text-white/60":"text-gray-600")})]}):(0,t.jsx)(tP.EditableTaskTitle,{taskId:j.id,title:j.title,onUpdate:M,as:"h2",className:(0,n.cn)("text-sm font-semibold truncate",x?"text-white":"text-gray-900")}),(0,t.jsxs)("div",{className:(0,n.cn)("flex items-center gap-1.5 text-xs",x?"text-white/40":"text-gray-500"),children:[(0,t.jsx)("span",{className:"capitalize",children:j.category}),(0,t.jsx)("span",{children:"·"}),(0,t.jsx)(tH,{status:j.status}),_?.isTurnover&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{children:"·"}),(0,t.jsxs)("span",{className:"text-orange-400 font-medium flex items-center gap-1",children:[(0,t.jsx)(tv.ArrowRightLeft,{className:"w-3 h-3"})," Turnover"]})]}),j.metadata?.source&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{children:"·"}),(0,t.jsx)("span",{className:(0,n.cn)("font-medium","ical_import"===j.metadata.source?"text-blue-400":"workspace_connection_backfill"===j.metadata.source?"text-orange-400":"text-purple-400"),children:"ical_import"===j.metadata.source?"iCal":"workspace_connection_backfill"===j.metadata.source?"Workspace":"Auto"})]})]})]})]}),(0,t.jsx)("button",{onClick:()=>p(!g),className:(0,n.cn)("p-1.5 rounded-lg transition-colors flex-shrink-0",x?"hover:bg-white/[0.05]":"hover:bg-gray-100"),children:(0,t.jsx)(tE.default,{className:"w-4 h-4"})})]}),(_?.departingGuest||_?.arrivingGuest)&&(0,t.jsxs)("div",{className:"flex items-center gap-2 mt-2 pl-8",children:[_?.departingGuest&&(0,t.jsxs)("div",{className:(0,n.cn)("flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs",x?"bg-white/[0.05] text-white/50":"bg-gray-100 text-gray-500"),children:[(0,t.jsx)(J.LogOut,{className:"w-3.5 h-3.5 flex-shrink-0"}),(0,t.jsxs)("span",{children:["Out: ",_.departingGuest]}),_.checkoutTime&&(0,t.jsx)("span",{className:"font-mono opacity-60",children:_.checkoutTime})]}),_?.arrivingGuest&&(0,t.jsxs)("div",{className:(0,n.cn)("flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs",_.isTurnover?"bg-orange-500/15 text-orange-400 border border-orange-500/20 font-medium":x?"bg-white/[0.05] text-white/50":"bg-gray-100 text-gray-500"),children:[(0,t.jsx)(Y.LogIn,{className:"w-3.5 h-3.5 flex-shrink-0"}),(0,t.jsxs)("span",{children:["In today: ",_.arrivingGuest]}),_.checkinTime&&(0,t.jsx)("span",{className:"font-mono opacity-60",children:_.checkinTime})]})]})]}),(j.marketplace_eligible||j.task_assignments?.length>0)&&(0,t.jsxs)("div",{className:(0,n.cn)("flex border-b flex-shrink-0",x?"border-white/[0.08]":"border-gray-200","bg-white dark:bg-[#1C1C1E]"),children:[(0,t.jsx)("button",{onClick:()=>v("chat"),className:(0,n.cn)("px-5 py-2 text-xs font-medium transition-colors","chat"===w?x?"text-white border-b-2 border-orange-500":"text-gray-900 border-b-2 border-orange-500":x?"text-white/40 hover:text-white/60":"text-gray-500 hover:text-gray-700"),children:"Timeline"}),(0,t.jsx)("button",{onClick:()=>v("marketplace"),className:(0,n.cn)("px-5 py-2 text-xs font-medium transition-colors","marketplace"===w?x?"text-white border-b-2 border-orange-500":"text-gray-900 border-b-2 border-orange-500":x?"text-white/40 hover:text-white/60":"text-gray-500 hover:text-gray-700"),children:"Marketplace"})]}),"chat"===w&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-3",children:[0===$.length&&(0,t.jsxs)("div",{className:(0,n.cn)("text-center py-16",x?"text-white/20":"text-gray-400"),children:[(0,t.jsx)(tI.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40"}),(0,t.jsx)("p",{className:"text-sm",children:"No activity yet"})]}),$.map(e=>{let a=e.metadata?.channel==="sms"||e.metadata?.source==="operations-sms",r=e.description?.startsWith("ð¨"),s="comment"===e.type&&!a&&!r;if(r){let a=j.issues?.find(t=>e.description?.includes(t.type?.replace("_"," ").toUpperCase())&&6e4>Math.abs(new Date(t.created_at).getTime()-new Date(e.created_at).getTime()));
64return(0,t.jsx)(tq,{event:e,issue:a,isDark:x,taskId:j.id,onUpdate:M},e.id)}return a?(0,t.jsx)(tO,{event:e,users:d,isDark:x,currentUserId:h?.user?.id},e.id):s?(0,t.jsx)(tU,{event:e,users:d,isDark:x,currentUserId:h?.user?.id},e.id):(0,t.jsx)(tB,{event:e,isDark:x},e.id)}),(0,t.jsx)("div",{ref:k})]}),(0,t.jsx)("div",{className:(0,n.cn)("border-t px-4 py-3","border-gray-200 dark:border-white/[0.08]","bg-white dark:bg-[#1C1C1E]"),children:(0,t.jsx)(ta,{taskId:j.id,task:j,onMessageSent:F,hostContact:E,contactRole:S?.role||null,reservationId:I?Number(I):null})})]}),"marketplace"===w&&(0,t.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,t.jsx)(b.TaskMarketplacePanel,{taskId:j.id,task:j,onUpdate:M,canEdit:D,canEditStructure:R})})]}),(0,t.jsx)("div",{className:(0,n.cn)("w-[400px] flex-shrink-0 border-l overflow-y-auto","border-gray-200 dark:border-white/[0.08]","bg-white dark:bg-[#1A1A1C]",g?"hidden lg:block":"hidden"),children:(0,t.jsx)(t$,{task:j,users:d,isDark:x,isServiceProvider:"service_provider"===c,canEdit:D,canEditStructure:R,onUpdate:M})}),(0,t.jsx)("button",{className:"fixed right-0 top-1/2 -translate-y-1/2 lg:hidden z-[162]",onClick:e=>{e.stopPropagation(),y(!0)},"aria-label":"Show task details",children:(0,t.jsx)("div",{className:"bg-gray-100 dark:bg-white/[0.08] rounded-l-lg py-12 px-1 flex items-center",children:(0,t.jsx)("div",{className:"w-1 h-12 bg-gray-300 dark:bg-white/20 rounded-full"})})})]}),(0,t.jsxs)(s.AnimatePresence,{children:[f&&(0,t.jsx)(r.motion.div,{initial:{opacity:0}
64,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[162] lg:hidden bg-black/40",onClick:()=>y(!1),"aria-hidden":"true"},"mobile-details-backdrop"),f&&(0,t.jsxs)(r.motion.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",damping:30,stiffness:300},className:(0,n.cn)("fixed inset-y-0 right-0 z-[163] lg:hidden overflow-y-auto","w-[calc(100%-48px)] max-w-[440px]","bg-white dark:bg-[#1A1A1C]","border-l border-gray-200 dark:border-white/[0.08] shadow-2xl"),onClick:e=>e.stopPropagation(),children:[(0,t.jsx)("button",{className:"absolute top-3 right-3 z-[1] p-2 text-gray-400 dark:text-white/60 hover:text-gray-900 dark:hover:text-white",onClick:()=>y(!1),"aria-label":"Close task details",children:(0,t.jsx)(P.X,{className:"w-5 h-5"})}),(0,t.jsx)(t$,{task:j,users:d,isDark:x,isServiceProvider:"service_provider"===c,canEdit:D,canEditStructure:R,onUpdate:M})]},"mobile-details-pane")]})]})}function t$({task:e,users:r,isDark:s,isServiceProvider:i,canEdit:l,canEditStructure:x,onUpdate:g}){let b=(0,a.useCallback)(async()=>{await g()},[g]),f=e.issues?.filter(e=>"resolved"!==e.status)||[];return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(tK,{task:e,users:r,isDark:s,onUpdate:b}),f.length>0&&(0,t.jsxs)("div",{className:(0,n.cn)("mx-4 mb-3 px-3 py-2 rounded-lg flex items-center gap-2 text-xs font-medium",s?"bg-red-500/10 text-red-400 border border-red-500/20":"bg-red-50 text-red-700 border border-red-200"),children:[(0,t.jsx)(tD.Flag,{className:"w-3.5 h-3.5"}),f.length," unresolved issue",1!==f.length?"s":""]}),(0,t.jsx)(p.TaskProgress,{task:e}),(0,t.jsx)(eN,{task:e,context:"operations"}),(0,t.jsx)(o.TaskDetails,{task:e,onUpdate:b,canEdit:l,canEditStructure:x,isServiceProvider:i}),(0,t.jsx)(h.TaskRecurrencePanel,{taskId:e.id,recurrenceId:e.recurrenceId??e.recurrence_id??null,canEdit:x,onUpdate:b}),(0,t.jsx)(d.TaskChecklist,{taskId:e.id,checklist:e.checklist,onUpdate:b,selectedTemplateId:e.checklist_template_id,task:e,canEdit:l,canEditStructure:x}),!e.is_subtask&&e.subtasks?.length>0&&(0,t.jsx)(c.TaskSubtasks,{taskId:e.id,subtasks:e.subtasks,onUpdate:b,canEdit:l,canEditStructure:x}),(0,t.jsx)(m.TaskBilling,{task:e,onUpdate:b,canEdit:l}),(0,t.jsx)(u.TaskExpensesPanel,{taskId:"string"==typeof e.id?parseInt(e.id):e.id,task:e,canEdit:l,canApprove:x}),(0,t.jsx)("div",{className:(0,n.cn)("border-t",s?"border-white/[0.08]":"border-gray-200"),children:(0,t.jsx)(ew,{task:e,onUpdate:b,canEdit:l,canEditStructure:x})}),(0,t.jsxs)("div",{className:(0,n.cn)("px-4 py-3 border-t",s?"border-white/[0.08]":"border-gray-200"),children:[(0,t.jsx)("h4",{className:(0,n.cn)("text-xs font-semibold uppercase tracking-wide mb-2",s?"text-white/30":"text-gray-400"),children:"Report"}),e.report_token?(0,t.jsxs)("a",{href:`/report/${e.report_token}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-sm text-orange-500 hover:text-orange-400",children:[(0,t.jsx)(A.FileText,{className:"w-4 h-4"}),"View Cleaning Report"]}):(0,t.jsx)(tV,{taskId:e.id,onGenerated:b,isDark:s})]})]})}function tO({event:e,users:a,isDark:r,currentUserId:s}){let i=e.created_by===s,l=a.find(t=>t.id===e.created_by),o=l?.name||e.user_name||"Unknown",d=e.description||"",[c,m]=d.includes("\nð")?d.split("\nð"):[d,null],u=c.match(/^\[SMS[^]]*\]\s*(.+)$/s),h=u?u[1].trim():c,x=m?.match(/^\s*(.+?):\s*(.+)$/s),g=x?.[1]?.trim(),p=x?.[2]?.trim();return(0,t.jsxs)("div",{className:(0,n.cn)("flex gap-2.5",i?"flex-row-reverse":""),children:[(0,t.jsxs)(e7.Avatar,{className:"h-7 w-7 flex-shrink-0",children:[(0,t.jsx)(e7.AvatarImage,{src:l?.image||""}),(0,t.jsx)(e7.AvatarFallback,{className:(0,n.cn)("text-[10px] font-bold",r?"bg-green-500/20 text-green-400":"bg-green-100 text-green-700"),children:o[0]?.toUpperCase()})]}),(0,t.jsxs)("div",{className:(0,n.cn)("max-w-[75%]",i?"items-end":"items-start"),children:[(0,t.jsxs)("div",{className:(0,n.cn)("flex items-center gap-2 mb-0.5",i?"flex-row-reverse":""),children:[(0,t.jsx)("span",{className:(0,n.cn)("text-xs font-medium",r?"text-white/60":"text-gray-600"),children:o}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)(tT.Phone,{className:"w-2.5 h-2.5 text-green-500"}),(0,t.jsx)("span",{className:"text-[10px] text-green-500 font-medium",children:"SMS"})]}),(0,t.jsx)("span",{className:(0,n.cn)("text-[10px]",r?"text-white/25":"text-gray-400"),children:(0,eh.formatDistanceToNow)(new Date(e.created_at),{addSuffix:!0})})]}),(0,t.jsx)("div",{className:(0,n.cn)("rounded-2xl px-3.5 py-2.5",i?"bg-green-600 text-white rounded-tr-sm":r?"bg-white/[0.06] text-white/90 rounded-tl-sm":"bg-white text-gray-900 rounded-tl-sm border border-gray-200"),children:(0,t.jsx)("p",{className:"text-sm whitespace-pre-wrap",children:h})}),p&&(0,t.jsxs)("div",{className:(0,n.cn)("mt-1 rounded-xl px-3 py-2",r?"bg-white/[0.03] border border-white/[0.06]":"bg-gray-50 border border-gray-100"),children:[(0,t.jsx)("span",{className:(0,n.cn)("text-[10px] font-medium",r?"text-white/30":"text-gray-400"),children:g}),(0,t.jsx)("p",{className:(0,n.cn)("text-xs",r?"text-white/50":"text-gray-500"),children:p})]})]})]})}function tU({event:e,users:a,isDark:r,currentUserId:s}){let i=e.created_by===s,l=a.find(t=>
64t.id===e.created_by),o=l?.name||e.user_name||"Unknown";return(0,t.jsxs)("div",{className:(0,n.cn)("flex gap-2.5",i?"flex-row-reverse":""),children:[(0,t.jsxs)(e7.Avatar,{className:"h-7 w-7 flex-shrink-0",children:[(0,t.jsx)(e7.AvatarImage,{src:l?.image||""}),(0,t.jsx)(e7.AvatarFallback,{className:(0,n.cn)("text-[10px] font-bold",r?"bg-orange-500/20 text-orange-400":"bg-orange-100 text-orange-700"),children:o[0]?.toUpperCase()})]}),(0,t.jsxs)("div",{className:(0,n.cn)("max-w-[75%]"),children:[(0,t.jsxs)("div",{className:(0,n.cn)("flex items-center gap-2 mb-0.5",i?"flex-row-reverse":""),children:[(0,t.jsx)("span",{className:(0,n.cn)("text-xs font-medium",r?"text-white/60":"text-gray-600"),children:o}),(0,t.jsx)("span",{className:(0,n.cn)("text-[10px]",r?"text-white/25":"text-gray-400"),children:(0,eh.formatDistanceToNow)(new Date(e.created_at),{addSuffix:!0})})]}),(0,t.jsx)("div",{className:(0,n.cn)("rounded-2xl px-3.5 py-2.5",i?"bg-blue-600 text-white rounded-tr-sm":r?"bg-white/[0.06] text-white/90 rounded-tl-sm":"bg-white text-gray-900 rounded-tl-sm border border-gray-200"),children:(0,t.jsx)("p",{className:"text-sm whitespace-pre-wrap",children:e.description})})]})]})}function tB({event:e,isDark:a}){let r={completion:E.CheckCircle,task_completed:E.CheckCircle,task_started:td.Sparkles,checklist_update:E.CheckCircle}[e.type]||f.Clock;return(0,t.jsxs)("div",{className:"flex items-center justify-center gap-2 py-1",children:[(0,t.jsx)("div",{className:(0,n.cn)("h-px flex-1",a?"bg-white/[0.06]":"bg-gray-200")}),(0,t.jsxs)("div",{className:(0,n.cn)("flex items-center gap-1.5 text-[10px]",a?"text-white/25":"text-gray-400"),children:[(0,t.jsx)(r,{className:"w-3 h-3"}),(0,t.jsxs)("span",{children:[e.description?.slice(0,60),e.description?.length>60?"...":""]}),(0,t.jsx)("span",{className:"font-mono",children:(0,eh.formatDistanceToNow)(new Date(e.created_at),{addSuffix:!0})})]}),(0,t.jsx)("div",{className:(0,n.cn)("h-px flex-1",a?"bg-white/[0.06]":"bg-gray-200")})]})}function tq({event:e,issue:r,isDark:s,taskId:i,onUpdate:l}){let[o,d]=(0,a.useState)(!1),c=e.metadata?.attachments?.filter(e=>e.metadata?.type==="photo")||r?.photos||[],m=r?.description||e.description?.replace(/^ð¨.*?\n\n/,"")||"",u=r?.type||"damage",h=r?.is_blocking,x=r?.status||"reported",g=(0,eh.formatDistanceToNow)(new Date(e.created_at),{addSuffix:!0}),p=async()=>{if(r?.id){d(!0);try{(await fetch(`/api/tasks/${i}/issues`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({issueId:r.id,action:"resolve"})})).ok&&await l()}catch{}finally{d(!1)}}},b={damage:{bg:"bg-red-50 dark:bg-red-500/[0.06]",border:"border-red-200 dark:border-red-500/20",icon:"â ï¸"},missing_supplies:{bg:"bg-amber-50 dark:bg-amber-500/[0.06]",border:"border-amber-200 dark:border-amber-500/20",icon:"ð¦"},access_problem:{bg:"bg-blue-50 dark:bg-blue-500/[0.06]",border:"border-blue-200 dark:border-blue-500/20",icon:"ð"},excessive_cleaning:{bg:"bg-orange-50 dark:bg-orange-500/[0.06]",border:"border-orange-200 dark:border-orange-500/20",icon:"ð§¹"},other:{bg:"bg-gray-50 dark:bg-gray-500/[0.06]",border:"border-gray-200 dark:border-gray-500/20",icon:"ð"}},f=b[u]||b.other;return(0,t.jsxs)("div",{className:(0,n.cn)("rounded-xl border p-3",f.bg,f.border),children:[(0,t.jsxs)("div",{className:"flex items-start justify-between mb-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-sm",children:f.icon}),(0,t.jsx)("span",{className:(0,n.cn)("text-xs font-semibold uppercase tracking-wide",s?"text-white/70":"text-gray-700"),children:u.replace("_"," ")}),h&&(0,t.jsx)("span",{className:"text-[10px] font-bold px-1.5 py-0.5 rounded bg-red-500 text-white",children:"BLOCKING"}),"resolved"===x&&(0,t.jsx)("span",{className:"text-[10px] font-bold px-1.5 py-0.5 rounded bg-green-500 text-white",children:"RESOLVED"})]}),(0,t.jsx)("span",{className:(0,n.cn)("text-[10px]",s?"text-white/20":"text-gray-400"),children:g})]}),m&&(0,t.jsx)("p",{className:(0,n.cn)("text-sm mb-2",s?"text-white/70":"text-gray-600"),children:m}),c.length>0&&(0,t.jsx)("div",{className:"flex gap-2 mb-2 overflow-x-auto",children:c.map((e,a)=>(0,t.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"shrink-0",children:(0,t.jsx)("img",{src:e.url,alt:"",className:"h-24 w-24 rounded-lg object-cover border border-gray-200 dark:border-white/10"})},a))}
64),r?.id&&"resolved"!==x&&(0,t.jsxs)("div",{className:"flex gap-2 mt-2",children:[(0,t.jsx)("button",{onClick:p,disabled:o,className:(0,n.cn)("px-3 py-1.5 rounded-lg text-xs font-medium transition-colors",s?"bg-green-500/10 text-green-400 hover:bg-green-500/20":"bg-green-50 text-green-700 hover:bg-green-100"),children:o?"Resolving...":"â Resolve"}),!r.created_task_id&&(0,t.jsx)("button",{onClick:async()=>{try{await fetch(`/api/tasks?customerId=${r.customer_id||""}&_dev_customerId=${r.customer_id||""}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:`${r.type?.replace("_"," ")}: ${r.description?.slice(0,50)||"Follow-up"}`,category:"damage"===r.type?"maintenance":"other",priority:r.is_blocking?"urgent":"high",description:`Created from issue report #${r.id} 65 66${r.description||""}`,parentTaskId:i})}),await l()}catch{}},className:(0,n.cn)("px-3 py-1.5 rounded-lg text-xs font-medium transition-colors",s?"bg-blue-500/10 text-blue-400 hover:bg-blue-500/20":"bg-blue-50 text-blue-700 hover:bg-blue-100"),children:"+ Create Task"})]})]})}let tz={todo:{label:"To Do",color:"text-gray-400"},pending:{label:"Pending",color:"text-gray-400"},in_progress:{label:"In Progress",color:"text-blue-500"},completed:{label:"Completed",color:"text-green-500"},cancelled:{label:"Cancelled",color:"text-red-400"},blocked:{label:"Blocked",color:"text-red-500"},failed:{label:"Failed",color:"text-red-500"}};function tH({status:e}){let a=tz[e]||{label:e,color:"text-gray-400"};return(0,t.jsx)("span",{className:(0,n.cn)("font-medium",a.color),children:a.label})}function tV({taskId:e,onGenerated:r,isDark:s}){let[i,l]=(0,a.useState)(!1),[o,d]=(0,a.useState)(null),[c,m]=(0,a.useState)(null),u=async()=>{l(!0),d(null);try{let t=await fetch(`/api/tasks/${e}/report`,{method:"POST",credentials:"include"}),a=await t.json();if(!t.ok)throw Error(a.error||"Failed to generate report");m(a.reportUrl||`/report/${a.token}`),r()}catch(e){d(e.message)}finally{l(!1)}};return c?(0,t.jsxs)("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-sm text-orange-500 hover:text-orange-400",children:[(0,t.jsx)(A.FileText,{className:"w-4 h-4"}),"View Cleaning Report"]}):(0,t.jsxs)("div",{children:[(0,t.jsxs)("button",{onClick:u,disabled:i,className:(0,n.cn)("flex items-center gap-2 text-sm font-medium transition-colors",i?"opacity-50":"text-orange-500 hover:text-orange-400"),children:[i?(0,t.jsx)(t_.Loader2,{className:"w-4 h-4 animate-spin"}):(0,t.jsx)(A.FileText,{className:"w-4 h-4"}),i?"Generating...":"Generate Report"]}),o&&(0,t.jsx)("p",{className:"text-xs text-red-400 mt-1",children:o})]})}let tG={low:{label:"Low",color:"text-gray-400"},medium:{label:"Medium",color:"text-blue-400"},high:{label:"High",color:"text-orange-400"},urgent:{label:"Urgent",color:"text-red-400"}},tW={todo:{label:"To Do",color:"bg-gray-500/10 text-gray-400"},in_progress:{label:"In Progress",color:"bg-blue-500/10 text-blue-400"},completed:{label:"Completed",color:"bg-green-500/10 text-green-400"},cancelled:{label:"Cancelled",color:"bg-red-500/10 text-red-400"},blocked:{label:"Blocked",color:"bg-amber-500/10 text-amber-400"}};function tK({task:e,users:r,isDark:s,onUpdate:i}){let[l,o]=(0,a.useState)(!1),[d,c]=(0,a.useState)(!1),m=(0,tS.useAssignmentError)(),[u,h]=(0,a.useState)(!1),[x,g]=(0,a.useState)(!1),[p,b]=(0,a.useState)(""),f=e.assignments?.[0]||e.task_assignments?.[0],y=f?r.find(e=>e.id===f.user_id):null,w=async(t,a)=>{o(!0);try{await fetch(`/api/tasks?taskId=${e.id}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({[t]:a})}),i()}catch(e){console.error("Update failed:",e)}finally{o(!1)}},v=async t=>{o(!0),c(!1);try{let a=await fetch(`/api/tasks/${e.id}/assign`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:t??"unassign"})});if(!a.ok){let e=await a.json().catch(()=>null);m.show(e?.error||"Could not update the assignment")}i()}catch(e){console.error("Assign failed:",e),m.show("Could not update the assignment")}finally{o(!1)}},k=new Set(["cleaner","maintenance","roamer","inspector","concierge"]),j=r.filter(e=>e.roles?.some(e=>k.has(e))),N=p.trim()?j.filter(e=>e.name?.toLowerCase().includes(p.toLowerCase())):j,C=tG[e.priority]||tG.medium,S=tW[e.status]||tW.todo;return(0,t.jsxs)("div",{className:(0,n.cn)("px-4 py-3 border-b space-y-2.5",s?"border-white/[0.08]":"border-gray-200"),children:[(0,t.jsx)(tS.AssignmentErrorNotice,{message:m.message,onDismiss:m.clear}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:(0,n.cn)("text-xs",s?"text-white/40":"text-gray-500"),children:"Status"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsxs)("button",{onClick:()=>g(!x),className:(0,n.cn)("flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium",S.color),children:[S.label,(0,t.jsx)(tA.ChevronDown,{className:"w-3 h-3"})]}),x&&(0,t.jsx)("div",{className:(0,n.cn)("absolute right-0 top-full mt-1 w-40 rounded-xl border shadow-xl z-[200] overflow-hidden",s?"bg-[#1C1C1E] border-white/[0.1]":"bg-white border-gray-200"),children:Object.entries(tW).map(([a,r])=>(0,t.jsxs)("button",{onClick:()=>{w("status",a),g(!1)},className:(0,n.cn)("w-full text-left px-3 py-2 text-xs transition-colors flex items-center justify-between",a===e.status?s?"bg-white/[0.08]":"bg-gray-100":s?"hover:bg-white/[0.04]":"hover:bg-gray-50"),children:[(0,t.jsx)("span",{className:r.color.split(" ")[1],children:r.label}),a===e.status&&(0,t.jsx)(E.CheckCircle,{className:"w-3 h-3 text-green-400"})]},a))})]})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:(0,n.cn)("text-xs",s?"text-white/40":"text-gray-500"),children:"Priority"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsxs)("button",{onClick:()=>h(!u),className:(0,n.cn)("flex items-center gap-1.5 text-xs font-medium",C.color),children:[(0,t.jsx)(tD.Flag,{className:"w-3 h-3"}),C.label,(0,t.jsx)(tA.ChevronDown,{className:"w-3 h-3"})]}),u&&(0,t.jsx)("div",{className:(0,n.cn)("absolute right-0 top-full mt-1 w-36 rounded-xl border shadow-xl z-[200] overflow-hidden",s?"bg-[#1C1C1E] border-white/[0.1]":"bg-white border-gray-200"),children:Object.entries(tG).map(([a,r])=>(0,t.jsxs)("button",{onClick:()=>{w("priority",a),h(!1)},className:(0,n.cn)("w-full text-left px-3 py-2 text-xs transition-colors flex items-center justify-between",a===e.priority?s?"bg-white/[0.08]":"bg-gray-100":s?"hover:bg-white/[0.04]":"hover:bg-gray-50"),children:[(0,t.jsx)("span",{className:r.color,children:r.label}),a===e.priority&&(0,t.jsx)(E.CheckCircle,{className:"w-3 h-3 text-green-400"})]},a))})]})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:(0,n.cn)("text-xs",s?"text-white/40":"text-gray-500"),children:"Assignee"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsxs)("button",{onClick:()=>{c(!d),b("")},className:(0,n.cn)("flex items-center gap-2 text-xs font-medium",s?"text-white/70":"text-gray-700"),children:[y?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(e7.Avatar,{className:"w-5 h-5",children:[(0,t.jsx)(e7.AvatarImage,{src:y.image}),(0,t.jsx)(e7.AvatarFallback,{className:"text-[10px]",children:y.name?.[0]})]}),y.name]}):(0,t.jsx)("span",{className:s?"text-white/40":"text-gray-400",children:"Unassigned"}),(0,t.jsx)(tA.ChevronDown,{className:"w-3 h-3"})]}),d&&(0,t.jsxs)("div",{className:(0,n.cn)("absolute right-0 top-full mt-1 w-56 rounded-xl border shadow-xl z-[200] overflow-hidden",s?"bg-[#1C1C1E] border-white/[0.1]":"bg-white border-gray-200"),children:[(0,t.jsx)("div",{className:"p-2",children:(0,t.jsx)("input",{autoFocus:!0,value:p,onChange:e=>b(e.target.value),placeholder:"Search...",className:(0,n.cn)("w-full text-xs px-2.5 py-1.5 rounded-lg border outline-none",s?"bg-white/[0.05] border-white/[0.08] text-white placeholder:text-white/25":"bg-gray-50 border-gray-200 text-gray-900 placeholder:text-gray-400")})}),(0,t.jsxs)("div",{className:"max-h-48 overflow-y-auto",style:{overscrollBehavior:"contain"},children:[f&&(0,t.jsx)("button",{onClick:()=>v(null),className:(0,n.cn)("w-full text-left px-3 py-2 text-xs",s?"text-white/40 hover:bg-white/[0.04]":"text-gray-400 hover:bg-gray-50"),children:"Unassign"}),N.map(a=>(0,t.jsxs)("button",{onClick:()=>v(a.id),className:(0,n.cn)("w-full text-left px-3 py-2 text-xs flex items-center gap-2 transition-colors",a.id===f?.user_id?s?"bg-white/[0.08]":"bg-gray-100":s?"hover:bg-white/[0.04]":"hover:bg-gray-50"),children:[(0,t.jsxs)(e7.Avatar,{className:"w-5 h-5",children:[(0,t.jsx)(e7.AvatarImage,{src:a.image}),(0,t.jsx)(e7.AvatarFallback,{className:"text-[10px]",children:a.name?.[0]})]}),(0,t.jsx)("span",{className:s?"text-white/70":"text-gray-700",children:a.name}),(0,tR.assigneeOutsideTaskTypes)(a,e.category)&&(0,t.jsx)("span",{title:tM.settings.sections.taskTypes.assignee.outsideTooltip.replace("{name}",a.name||"this person"),className:(0,n.cn)("ml-auto shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] leading-none",s?"border-amber-500/20 bg-amber-500/10 text-amber-400":"border-amber-200 bg-amber-50 text-amber-700"),children:tM.settings.sections.taskTypes.assignee.outside}),a.id===f?.user_id&&(0,t.jsx)(E.CheckCircle,{className:(0,n.cn)("w-3 h-3 text-green-400 shrink-0",!(0,tR.assigneeOutsideTaskTypes)(a,e.category)&&"ml-auto")})]},a.id))]})]})]})]})]})}var tY=e.i(844563);let tJ=(e="boot-sequence")=>({lastUpdated:new Date().toISOString(),version:"1.0",source:e}),tQ=(0,e.i(768834).create)((e,t)=>({listingsCache:new Map,customerData:null,setListing:(t,a)=>e(e=>{let r=new Map(e.listingsCache);return r.set(t,a),{listingsCache:r}}),getListing:e=>t().listingsCache.get(e),clearListings:()=>e({listingsCache:new Map}),setCustomerData:t=>e({customerData:t}),getCustomerData:()=>t().customerData})),tX=async e=>{try{let t=await fetch(`/api/user/users?customerId=${e}`,{credentials:"include",signal:(()=>{try{return AbortSignal.timeout(2e4)}catch{let e=new AbortController;return setTimeout(()=>e.abort(),2e4),e.signal}})()});if(!t.ok)throw Error("Failed to fetch customer data");let a=await t.json(),r=`customer:${e}:data`,s=await tY.cacheService.get(r),i=s?.listings??[],n={users:{users:a.users,groups:a.groups},listings:i,metadata:{lastUpdated:new Date().toISOString(),customerId:e}};tQ.getState().setCustomerData(n),await tY.cacheService.set(r,n,{...tJ("boot-sequence"),dependencies:["customer"]});let l=`listings:${e}:index`,o=await tY.cacheService.get(l),d={listingCount:o?.listingCount??i.reduce((e,t)=>
66e+(t?.listings?.length||0),0),cachedListings:o?.cachedListings??[],customerId:e,metadata:{lastUpdated:new Date().toISOString(),source:"customer-boot"}};await tY.cacheService.set(l,d);let c=`customer:${e}:index`,m={...tJ("boot-sequence"),customerId:e,userCount:a.users.length,groupCount:a.groups.length,listingCount:d.listingCount};await tY.cacheService.set(c,m),window.dispatchEvent(new CustomEvent("customer-data-updated",{detail:{customerId:e,users:a.users,groups:a.groups,source:"background-refresh"}})),console.log("â
Background customer refresh complete")}catch(e){console.error("â Background customer refresh failed:",e)}},tZ=async({customerId:e,onComplete:t,updateStepStatus:a})=>{try{a("customer","loading");let r=`customer:${e}:index`,s=await tY.cacheService.get(r);if(s)return(e=>{if(!e)return!0;let t=new Date(e.lastUpdated),a=new Date;return t.toDateString()!==a.toDateString()})(s)&&(console.log("Cache needs refresh, starting background refresh..."),tX(e)),a("customer","complete"),t&&t(),!0;return tX(e).catch(()=>void 0),a("customer","complete"),t&&t(),!0}catch(e){return console.error("â Customer boot failed:",e),a("customer","error"),!1}};e.s(["CacheWarmer",0,function({customerId:e,children:r}){let s=(0,a.useRef)(null);return(0,a.useEffect)(()=>{e&&s.current!==e&&(s.current=e,tZ({customerId:e,updateStepStatus:()=>{}}).catch(()=>void 0))},[e]),(0,t.jsx)(t.Fragment,{children:r})}],169284);var t0=e.i(114683),t1=e.i(32095);function t2({status:e}){switch(e){case"complete":return(0,t.jsx)(tl.CheckCircle2,{className:"w-4 h-4 text-green-500 shrink-0"});case"partial":return(0,t.jsx)(S.AlertCircle,{className:"w-4 h-4 text-amber-500 shrink-0"});case"empty":return(0,t.jsx)(t0.Circle,{className:"w-4 h-4 text-gray-300 dark:text-white/20 shrink-0"})}}function t5(){return(0,t.jsxs)("div",{className:"flex flex-col h-full",children:[(0,t.jsxs)("div",{className:"p-4 border-b border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsx)(Q.Skeleton,{className:"h-5 w-36 bg-gray-200 dark:bg-white/[0.08] mb-3"}),(0,t.jsx)(Q.Skeleton,{className:"h-2 w-full bg-gray-200 dark:bg-white/[0.08] rounded-full mb-1.5"}),(0,t.jsx)(Q.Skeleton,{className:"h-3 w-24 bg-gray-200 dark:bg-white/[0.08]"})]}),(0,t.jsx)("div",{className:"p-2 space-y-1",children:[...Array(10)].map((e,a)=>(0,t.jsx)(Q.Skeleton,{className:"h-14 w-full bg-gray-200 dark:bg-white/[0.08] rounded-lg"},a))})]})}e.s(["TrainingProgress",0,function({categories:e,activeCategory:a,onCategoryClick:r,isLoading:s,trainingScore:i}){if(s)return(0,t.jsx)(t5,{});let l=e.filter(e=>"complete"===e.status).length,o=e.length,d=null!=i?Math.round(i):o>0?Math.round(l/o*100):0;return(0,t.jsxs)("div",{className:"flex flex-col h-full",children:[(0,t.jsxs)("div",{className:"p-4 border-b border-gray-200 dark:border-white/[0.08]",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,t.jsx)(t1.GraduationCap,{className:"w-5 h-5 text-primary"}),(0,t.jsx)("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Training Progress"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"flex-1",children:(0,t.jsx)("div",{className:"h-2 rounded-full bg-gray-100 dark:bg-white/[0.08] overflow-hidden",children:(0,t.jsx)("div",{className:"h-full rounded-full bg-primary transition-all duration-500",style:{width:`${d}%`}})})}),(0,t.jsxs)("span",{className:"text-sm font-medium text-gray-600 dark:text-white/60 tabular-nums",children:[d,"%"]})]}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/40 mt-1.5",children:null!=i?"Question coverage":`${l}/${o} categories covered`})]}),(0,t.jsx)("div",{className:"flex-1 overflow-y-auto p-2",children:(0,t.jsx)("div",{className:"space-y-0.5",children:e.map(e=>{let s=a===e.name;return(0,t.jsxs)("button",{onClick:()=>r(e.name),className:(0,n.cn)("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg text-left transition-colors",s?"bg-primary/10 text-primary":"text-gray-700 dark:text-white/70 hover:bg-gray-100 dark:hover:bg-white/[0.05]"),children:[(0,t.jsx)(t2,{status:e.status}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("p",{className:"text-sm font-medium truncate",children:e.name}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/40",children:0===e.articleCount?"No articles":`${e.articleCount} article${1!==e.articleCount?"s":""}`})]})]},e.name)})})})]})}],58765);var t4=e.i(191741),t3=e.i(565365),t6=e.i(236579);e.s(["ImagePlus",()=>t6.default],972080);var t6=t6,t8=e.i(972520),t9=e.i(643531),t7=e.i(114890);e.s(["FileUp",()=>t7.default],143527);var t7=t7;e.s(["TrainingMethods",0,function({onSelectMethod:e,conversationCount:a=0,isTrained:r=!1,mediaArticleCount:s=0,articleCount:i=0}){let l=s>=3,o=null;a>=5&&!r?o="mining":l?i<10&&(o="questionnaire"):o="media";let d=[{id:"mining",title:"Mine from Conversations",description:r?"Conversations have been mined. You can re-mine to pick up new conversations.":a>
66=5?`Extract knowledge from ${a.toLocaleString()} guest conversations automatically.`:a>0?`${a} conversation${1!==a?"s":""} available â minimum 5 needed for mining.`:"No conversations available yet. Chat history will appear after guest interactions.",icon:t3.MessageSquareText,statusBadge:r?"Done":a>=5?`${a.toLocaleString()} chats`:a>0?`${a}/5 chats`:void 0,statusColor:r?"bg-green-500/10 text-green-600 dark:text-green-400":"bg-amber-500/10 text-amber-500",available:a>=5,step:1},{id:"media",title:"Videos & Photos",description:l?`${s} media articles generated. Upload more to expand coverage.`:s>0?`${s} media article${1!==s?"s":""} so far. Upload more videos & photos for better coverage.`:"Upload walkthrough videos or property photos. Vanio AI analyzes them and generates articles.",icon:t6.default,statusBadge:l?`${s} articles`:s>0?`${s}/3 articles`:"Photos & Videos",statusColor:l?"bg-green-500/10 text-green-600 dark:text-green-400":s>0?"bg-amber-500/10 text-amber-500":"bg-violet-500/10 text-violet-500",available:!0,step:2},{id:"questionnaire",title:"Quick Questionnaire",description:"Answer guided questions about your property. Best for filling specific knowledge gaps.",icon:t4.ClipboardList,statusBadge:void 0,statusColor:"bg-primary/10 text-primary",available:!0,step:3},{id:"document",title:"Upload Documents",description:"Upload house rules, SOPs, or guest guides. Vanio AI extracts knowledge articles automatically.",icon:t7.default,statusBadge:void 0,statusColor:"bg-emerald-500/10 text-emerald-500",available:!0,step:4}];return(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(td.Sparkles,{className:"w-4 h-4 text-primary"}),(0,t.jsx)("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Training Methods"})]}),(0,t.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:d.map(a=>{let s=a.id===o,i="mining"===a.id&&r||"media"===a.id&&l;return(0,t.jsxs)("button",{onClick:()=>a.available&&e(a.id),disabled:!a.available,className:(0,n.cn)("group relative flex flex-col items-start p-4 rounded-xl border text-left transition-all",a.available?s?"border-primary/50 dark:border-primary/40 bg-primary/[0.02] dark:bg-primary/[0.03] hover:border-primary hover:shadow-sm cursor-pointer ring-1 ring-primary/20":"border-gray-200 dark:border-white/[0.08] bg-white dark:bg-white/[0.02] hover:border-primary/50 dark:hover:border-primary/50 hover:shadow-sm cursor-pointer":"border-gray-200 dark:border-white/[0.06] bg-gray-50 dark:bg-white/[0.01] opacity-60 cursor-not-allowed"),children:[(0,t.jsxs)("div",{className:"absolute top-3 right-3 flex items-center gap-1.5",children:[i&&(0,t.jsx)("div",{className:"w-5 h-5 rounded-full bg-green-500/10 flex items-center justify-center",children:(0,t.jsx)(t9.Check,{className:"w-3 h-3 text-green-500"})}),(0,t.jsxs)("span",{className:"text-[10px] text-gray-300 dark:text-white/15 font-medium",children:["Step ",a.step]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,t.jsx)(a.icon,{className:(0,n.cn)("w-5 h-5",s?"text-primary":"text-gray-600 dark:text-white/60")}),s&&(0,t.jsx)("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full bg-primary/10 text-primary",children:"Recommended"}),a.statusBadge&&!s&&(0,t.jsx)("span",{className:(0,n.cn)("text-[10px] font-medium px-1.5 py-0.5 rounded-full",a.statusColor),children:a.statusBadge})]}),(0,t.jsx)("h4",{className:"text-sm font-medium text-gray-900 dark:text-white mb-1",children:a.title}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/50 leading-relaxed",children:a.description}),a.available&&(0,t.jsx)(t8.ArrowRight,{className:"w-4 h-4 text-gray-400 dark:text-white/30 absolute bottom-4 right-4 opacity-0 group-hover:opacity-100 transition-opacity"})]},a.id)})})]})}],542843);var t6=t6;let ae=(0,e.i(637800).getClientApiBase)();function at({listingId:e}){let[r,s]=(0,a.useState)([]),i=(0,a.useCallback)(async()=>{try{let t=await fetch(`${ae}/ai/training/suggestions?listingId=${e}&status=pending`,{credentials:"include"});if(t.ok){let e=await t.json();s(e.suggestions||[])}}catch{}},[e]);(0,a.useEffect)(()=>{i()},[i]);let n=async(e,t)=>{(await fetch(`${ae}/ai/training/suggestions`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({suggestionId:e,action:"answer",answer:t})})).ok&&s(t=>t.filter(t=>t.id!==e))},l=async e=>{(await fetch(`${ae}/ai/training/suggestions`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({suggestionId:e,action:"dismiss"})})).ok&&s(t=>t.filter(t=>t.id!==e))};return 0===r.length?null:(0,t.jsxs)("div",{className:"rounded-xl border border-amber-200 dark:border-amber-500/20 bg-amber-50/50 dark:bg-amber-500/[0.03] overflow-hidden",children:[(0,t.jsxs)("div",{className:"px-4 py-2.5 border-b border-amber-200 dark:border-amber-500/10 flex items-center gap-2",children:[(0,t.jsx)(eD.HelpCircle,{className:"w-3.5 h-3.5 text-amber-500"}),(0,t.jsxs)("span",{className:"text-xs font-medium text-gray-800 dark:text-white/80",children:["Vanio AI needs your help (",r.length,")"]})]}),(0,t.jsx)("div",{className:"p-3 space-y-2.5",children:r.map(e=>(0,t.jsx)(aa,{suggestion:e,onAnswer:n,onDismiss:l},e.id))})]})}function aa({suggestion:e,onAnswer:r,onDismiss:s}){let[i,l]=(0,a.useState)(""),[o,d]=(0,a.useState)(!1);return(0,t.jsxs)("div",{className:"rounded-lg border border-gray-200 dark:border-white/[0.08] bg-white dark:bg-white/[0.02] p-3",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2 mb-2",children:[(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("p",{className:"text-xs font-medium text-gray-700 dark:text-white/70",children:e.category}),(0,t.jsxs)("p",{className:"text-xs text-gray-500 dark:text-white/50 mt-0.5",children:["â",e.question,"â"]}
66)]}),(0,t.jsx)("button",{onClick:()=>s(e.id),className:"p-1 rounded hover:bg-gray-100 dark:hover:bg-white/[0.05] shrink-0",children:(0,t.jsx)(P.X,{className:"w-3 h-3 text-gray-300 dark:text-white/20"})})]}),(0,t.jsxs)("div",{className:"flex gap-1.5",children:[(0,t.jsx)("input",{type:"text",value:i,onChange:e=>l(e.target.value),onKeyDown:t=>{"Enter"===t.key&&i.trim()&&(d(!0),r(e.id,i.trim()).finally(()=>d(!1)))},placeholder:"Type the answer...",className:"flex-1 px-2.5 py-1.5 rounded-md text-xs border border-gray-200 dark:border-white/[0.08] bg-gray-50 dark:bg-white/[0.03] text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-white/30 outline-none focus:border-primary/50"}),(0,t.jsxs)("button",{onClick:()=>{i.trim()&&!o&&(d(!0),r(e.id,i.trim()).finally(()=>d(!1)))},disabled:!i.trim()||o,className:(0,n.cn)("px-2.5 py-1.5 rounded-md text-xs font-medium flex items-center gap-1 shrink-0",i.trim()?"bg-blue-600 text-white hover:bg-blue-700":"bg-gray-100 dark:bg-white/[0.05] text-gray-300 dark:text-white/20"),children:[o?(0,t.jsx)(t_.Loader2,{className:"w-3 h-3 animate-spin"}):(0,t.jsx)(eH.Send,{className:"w-3 h-3"}),"Teach"]})]})]})}e.s(["TrainingGuidance",0,function({listingId:e,categories:a,hasHistory:r,isTrained:s,onStartQuestionnaire:i,videoAnalysisCount:l,mediaArticleCount:o,onStartMedia:d,onStartMining:c}){let m=(0,eg.useRouter)(),u=a.reduce((e,t)=>e+t.articleCount,0),h=a.filter(e=>"empty"===e.status),x=a.filter(e=>"complete"===e.status),g=function(e){let{hasHistory:t,isTrained:a,totalArticles:r,emptyCategories:s,completeCategories:i,totalCategories:n,mediaArticleCount:l}=e,o=l>=3,d=(!t||a)&&o;if(t&&!a)return{icon:t3.MessageSquareText,iconBg:"bg-amber-500/10",iconColor:"text-amber-500",borderClass:"border-amber-200 dark:border-amber-500/20 bg-amber-50/50 dark:bg-amber-500/[0.03]",title:0===r?"Start by mining conversations":"Mine conversations to expand coverage",description:0===r?"This property has guest conversations that can be automatically analyzed. Mining extracts property knowledge and generates articles â the fastest way to build your knowledge base.":`You have ${r} articles but conversation history hasn\u2019t been mined yet. Mining will extract more knowledge from guest chats automatically.`,actions:[{type:"mine",label:"Mine Conversations",icon:t3.MessageSquareText,primary:!0},{type:"media",label:"Upload Videos & Photos",icon:t6.default},{type:"test-ai",label:"Test Vanio AI",icon:C.ExternalLink}]};if(!o){let e=r>0,t=l>0?` You have ${l} media article${1!==l?"s":""} \u2014 aim for at least 3 to cover key areas (entry, appliances, building access).`:"";return{icon:t6.default,iconBg:"bg-violet-500/10",iconColor:"text-violet-500",borderClass:"border-violet-200 dark:border-violet-500/20 bg-violet-50/50 dark:bg-violet-500/[0.03]",title:e?"Add videos & photos for visual guides":"Upload videos & photos to get started",description:e?`Upload walkthrough videos or property photos. Vanio AI will analyze them and create guest-friendly articles with visual instructions \u2014 perfect for check-in, appliances, and building access.${t}`:`No conversation history to mine. Upload walkthrough videos or property photos instead \u2014 Vanio AI will analyze them and generate knowledge articles automatically.${t}`,actions:[{type:"media",label:"Upload Videos & Photos",icon:t6.default,primary:!0},{type:"questionnaire",label:"Use Questionnaire Instead",icon:t4.ClipboardList},{type:"test-ai",label:"Test Vanio AI",icon:C.ExternalLink}]}}return d&&s>0?{icon:t4.ClipboardList,iconBg:"bg-primary/10",iconColor:"text-primary",borderClass:"border-primary/20 bg-primary/[0.02]",title:`${s} categories need content`,description:`Conversations and media have been processed. ${i}/${n} categories are covered. Use the questionnaire to fill the remaining gaps \u2014 answer a few questions and we\u2019ll generate articles.`,actions:[{type:"questionnaire",label:"Fill Gaps",icon:t4.ClipboardList,primary:!0},...t?[{type:"mine",label:"Re-mine Conversations",icon:t3.MessageSquareText}]:[],{type:"media",label:"Add More Media",icon:t6.default},{type:"test-ai",label:"Test Vanio AI",icon:C.ExternalLink}]}:d&&0===s?{icon:tl.CheckCircle2,iconBg:"bg-green-500/10",iconColor:"text-green-500",borderClass:"border-green-200 dark:border-green-500/20 bg-green-50/50 dark:bg-green-500/[0.03]",title:"Knowledge is looking good",description:`All ${n} categories have content (${r} articles total). Test how the AI responds as a guest, or add more detail.`,actions:[{type:"guest-demo",label:"Test as Guest",icon:e_.MessageCircle,primary:!0},{type:"test-ai",label:"Test Vanio AI",icon:C.ExternalLink},{type:"questionnaire",label:"Add More Detail",icon:t4.ClipboardList},...t?[{type:"mine",label:"Re-mine Conversations",icon:t3.MessageSquareText}]:[],{type:"media",label:"Add More Media",icon:t6.default}]}:{icon:t4.ClipboardList,iconBg:"bg-primary/10",iconColor:"text-primary",borderClass:"border-primary/20 bg-primary/[0.02]",title:s>0?`${s} categories still need content`:"Review and expand your knowledge",description:s>0?`You have ${r} articles. Use the questionnaire to fill the remaining ${s} empty categories.`:`${r} articles across all categories. Use the questionnaire to add more detail where needed.`,actions:[{type:"questionnaire",label:s>0?"Fill Gaps":"Add More",icon:t4.ClipboardList,primary:s>0},{type:"media",label:"Add More Media",icon:t6.default},{type:"test-ai",label:"Test Vanio AI",icon:C.ExternalLink}]}}({hasHistory:r,isTrained:s,totalArticles:u,emptyCategories:h.length,completeCategories:x.length,totalCategories:a.length,videoAnalysisCount:l,mediaArticleCount:o});return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:(0,n.cn)("rounded-xl border p-4",g.borderClass),children:(0,t.jsxs)("div",{className:"flex items-start gap-4",children:[(0,t.jsx)("div",{className:(0,n.cn)("p-2.5 rounded-xl shrink-0",g.iconBg),children:(0,t.jsx)(g.icon,{className:(0,n.cn)("w-5 h-5",g.iconColor)})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white mb-1",children:g.title}),(0,t.jsx)("p",{className:"text-xs text-gray-600 dark:text-white/60 leading-relaxed mb-3",children:g.description}),(0,t.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:g.actions.map(e=>(0,t.jsxs)(em.Button,{size:"sm",variant:e.primary?"default":"outline",className:"text-xs h-8",onClick:()=>{"mine"===e.type&&c?.(),"media"===e.type&&d?.(),"questionnaire"===e.type&&i(e.category),"guest-demo"===e.type&&window.dispatchEvent(new CustomEvent("training:switch-to-guest-demo")),"test-ai"===e.type&&m.push("/test-ai")},children:[e.icon&&(0,t.jsx)(e.icon,{className:"w-3.5 h-3.5 mr-1.5"}),e.label,e.primary&&(0,t.jsx)(t8.ArrowRight,{className:"w-3.5 h-3.5 ml-1.5"})]},e.label))}),s&&h.length>0&&(0,t.jsxs)("div",{className:"mt-3 pt-3 border-t border-gray-100 dark:border-white/[0.06]",children:[(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/40 mb-1.5",children:"Categories that need content:"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:h.map(e=>(0,t.jsx)("button",{onClick:()=>i(e.name),className:"text-[11px] px-2 py-1 rounded-md bg-amber-500/10 text-amber-600 dar
66k:text-amber-400 hover:bg-amber-500/20 transition-colors",children:e.name},e.name))})]})]})]})}),(0,t.jsx)(at,{listingId:e})]})}],848968);var ar=e.i(199778),as=e.i(810980);let ai={checkin:"Check-in/Check-out",checkout:"Check-in/Check-out","Check-in":"Check-in/Check-out","Check-out":"Check-in/Check-out","Check-in & Check-out":"Check-in/Check-out",maintenance:"Maintenance/Housekeeping",Maintenance:"Maintenance/Housekeeping",troubleshooting:"Technical Issues",Troubleshooting:"Technical Issues",amenities:"Amenities","Local Tips":"Local Guide",Local:"Local Guide",local:"Local Guide","local guide":"Local Guide",Nearby:"Local Guide",Restaurants:"Local Guide",general:"General",area:"General",contacts:"General",Miscellaneous:"General",Location:"General",faq:"FAQ","Guest FAQs":"FAQ",rules:"House Rules",Policies:"House Rules",Availability:"Booking/Reservation",Reviews:"Feedback/Reviews"},an=[{id:"check-in",name:"Check-in/Check-out",description:"How guests access the property and what to do at departure.",icon:"ð",questions:[{id:"access-method",label:"How do guests get in?",placeholder:"e.g. Lockbox at the front door, code sent 24h before via guest portal. Or: smart lock, or meet on-site.",type:"textarea",required:!0},{id:"lockbox-location",label:"Lockbox/key location â exact details",placeholder:"e.g. Black KeySafe box mounted on the wall to the left of the main entrance, waist height. Sometimes sticks â push firmly while turning.",type:"textarea"},{id:"arrival-directions",label:"Step-by-step directions from the street to the door",placeholder:"e.g. Enter building through glass doors, take elevator to 3rd floor, turn right, unit 13 is the second door on the left.",type:"textarea",prefillFrom:"airbnb.directions"},{id:"checkout-instructions",label:"Check-out instructions",placeholder:"e.g. Leave keys in lockbox and scramble code. Close all windows. Take rubbish to bins at back of building.",type:"textarea",prefillFrom:"airbnb.checkout_tasks"}]},{id:"amenities",name:"Amenities",description:"WiFi, kitchen, appliances, and other amenities â especially operational details.",icon:"ð¶",questions:[{id:"wifi-name",label:"WiFi network name",placeholder:"e.g. HomeWiFi_5G",type:"text",required:!0,prefillFrom:"airbnb.wifi_network"}
66,{id:"wifi-password",label:"WiFi password",placeholder:"e.g. welcome2024",type:"text",required:!0,prefillFrom:"airbnb.wifi_password"},{id:"kitchen",label:"Kitchen equipment & quirks",placeholder:"e.g. Full kitchen with Nespresso machine (pods in drawer), dishwasher (press & hold Start 3 sec), oven preheats slowly...",type:"textarea"},{id:"laundry",label:"Washer/Dryer",placeholder:"e.g. Washer in bathroom closet, no dryer. Detergent under sink. Drying rack on balcony.",type:"text",requiredAmenities:["washer","dryer","clothes_drying_rack"]},{id:"climate",label:"Heating & air conditioning â how to operate",placeholder:"e.g. Central AC in all rooms, remote on bedside table. Heating: radiators with thermostat in hallway.",type:"textarea",requiredAmenities:["ac","heating","fireplace","ceiling_fan","portable_fans","heated_floors"]},{id:"entertainment",label:"TV & entertainment",placeholder:'e.g. 55" Samsung Smart TV with Netflix pre-logged in. Remote on coffee table.',type:"text",requiredAmenities:["tv","smart_tv","game_console","sound_system","home_theater","projector_and_screen","netflix"]},{id:"coffee-machine",label:"Coffee machine â type, pods/capsules, where?",placeholder:"e.g. Nespresso machine on kitchen counter. Pods in the drawer below. Descale button: hold 3 sec.",type:"textarea",requiredAmenities:["coffee_maker","nespresso_machine","espresso_machine","keurig_coffee_machine"]},{id:"safe",label:"Safe â how to use, default code?",placeholder:"e.g. Digital safe in bedroom closet. Set your own 4-digit code. Master reset: hold C for 5 sec.",type:"text",requiredAmenities:["safe"]},{id:"outdoor",label:"Outdoor spaces & shared areas",placeholder:"e.g. Private balcony with table for 4. Shared rooftop terrace â open 8 AM - 10 PM.",type:"textarea",requiredAmenities:["patio_or_balcony","patio","patio_or_belcony","balcony","terrace","garden_or_backyard","bbq_area","outdoor_seating","alfresco_dining","outdoor_kitchen","fire_pit","hammock","sun_loungers"]},{id:"pool-hottub",label:"Pool or hot tub â access, hours, rules?",placeholder:"e.g. Shared pool on 3rd floor, open 7 AM - 10 PM. No glass allowed. Hot tub closes at 9 PM.",type:"textarea",requiredAmenities:["pool","private_pool","jacuzzi"]},{id:"gym",label:"Gym/fitness â location, hours, access?",placeholder:"e.g. Building gym on ground floor. Open 6 AM - 10 PM. Access with room key. Towels provided.",type:"textarea",requiredAmenities:["gym","exercise_equipment"]},{id:"fireplace",label:"Fireplace â how to operate?",placeholder:"e.g. Gas fireplace in living room. Turn on with wall switch (left of mantel). Keep flue open.",type:"textarea",requiredAmenities:["fireplace","outdoor_fireplace"]},{id:"sauna",label:"Sauna â access, hours, rules?",placeholder:"e.g. Private sauna in basement. Max 2 hours per session. Temperature dial on the wall.",type:"textarea",requiredAmenities:["sauna"]},{id:"beach-access",label:"Beach access â directions, essentials, rules?",placeholder:"e.g. Private beach 2 min walk. Beach towels in hallway closet. Umbrella and chairs on the terrace.",type:"textarea",requiredAmenities:["beach_access","beach_essentials"]},{id:"ev-charging",label:"EV charging â location, cost, type of charger?",placeholder:"e.g. Tesla Wall Connector in parking garage spot #12. Free for guests. Type 2 connector, 7kW.",type:"text",requiredAmenities:["ev_charger"]},{id:"workspace",label:"Workspace â setup for remote workers?",placeholder:"e.g. Dedicated desk in bedroom 2 with monitor, keyboard, and ergonomic chair. Ethernet port available.",type:"textarea",requiredAmenities:["laptop_friendly_workspace"]},{id:"smart-devices",label:"Smart home devices â voice assistants, smart locks, app controls?",placeholder:"e.g. Alexa Echo in living room (can control lights & AC). Smart thermostat via Nest app.",type:"textarea"}]},{id:"rules",name:"House Rules",description:"House rules â especially things not covered by platform rules.",icon:"ð",questions:[{id:"garbage",label:"Garbage & recycling",placeholder:"e.g. Bins under sink: black (general), blue (recycling). Main bins at ground floor opposite elevator.",type:"textarea"},{id:"visitor-policy",label:"Visitor / additional guest policy",placeholder:"e.g. Visitors allowed until 10 PM. No unregistered overnight guests. Maximum 6 people at any time.",type:"textarea"},{id:"other-rules",label:"Other rules or building-specific requirements",placeholder:"e.g. No shoes inside (slippers provided), keep entrance door locked at all times...",type:"textarea"}]},{id:"property-info",name:"Property Information",description:"Physical property details guests need to know.",icon:"ð ",questions:[{id:"floor-access",label:"Floor & building access",placeholder:"e.g. 3rd floor, elevator available but max 3 people, stairs as backup...",type:"textarea"},{id:"bedrooms",label:"Bedrooms & sleeping arrangements",placeholder:"e.g. 2 bedrooms: master with king bed, second with twin beds + sofa bed in living room",type:"textarea",prefillFrom:"airbnb.bedrooms"},{id:"bathrooms",label:"Bathrooms",placeholder:"e.g. 1 full bathroom with shower/tub combo, 1 half bath",type:"text",prefillFrom:"airbnb.bathrooms"},{id:"max-guests",label:"Maximum guests",placeholder:"e.g. 6",type:"text",listingField:"maxGuests",prefillFrom:"airbnb.person_capacity"},{id:"parking",label:"Parking",placeholder:"e.g. No parking at building. Nearest: Fentiman Road, £15/24h, 10 min walk.",type:"textarea"},{id:"special-features",label:"Anything unique about the property?",placeholder:"e.g. Shared rooftop terrace (key in kitchen drawer), garden access, sea view...",type:"textarea"}]}
66,{id:"area",name:"Travel Planning",description:"Local area info: transport, food, things to do.",icon:"ðºï¸",questions:[{id:"transport",label:"Nearest public transport",placeholder:"e.g. Vauxhall station (Tube + train) 5 min walk. Bus stop right outside.",type:"textarea",prefillFrom:"airbnb.transit"},{id:"grocery",label:"Nearest grocery stores",placeholder:"e.g. Tesco Express 2 min walk on Main St. Sainsbury Local 5 min walk.",type:"textarea"},{id:"restaurants",label:"Recommended restaurants & cafes",placeholder:'e.g. Italian: "La Trattoria" (5 min walk, great pizza), Coffee: "The Grind" (3 min)...',type:"textarea"},{id:"attractions",label:"Key attractions nearby",placeholder:"e.g. British Museum 15 min walk, Hyde Park 10 min walk...",type:"textarea"},{id:"airport",label:"Airport / train station access",placeholder:"e.g. Heathrow: 45 min by Piccadilly line. Kings Cross: 20 min by Northern line.",type:"text"},{id:"medical",label:"Nearest pharmacy, clinic, or hospital",placeholder:"e.g. Pharmacy: Boots 5 min walk. 24h clinic: CityDoc. Nearest A&E: St Thomasâ Hospital.",type:"textarea"}]},{id:"troubleshooting",name:"Technical Issues",description:"Common issues guests face and how to fix them.",icon:"ð§",questions:[{id:"wifi-issues",label:"WiFi not working â what to do?",placeholder:"e.g. Unplug the white router in the hallway cabinet, wait 30 seconds, plug back in.",type:"textarea"},{id:"heating-issues",label:"Heating/AC not working",placeholder:"e.g. Check thermostat batteries (AA, in hallway unit). If AC shows E1 error, turn off at wall for 5 min.",type:"textarea"},{id:"hot-water",label:"No hot water",placeholder:"e.g. Boiler in kitchen cupboard. If pressure below 1 bar, use filling loop underneath.",type:"textarea"},{id:"appliance-quirks",label:"Appliance quirks guests should know",placeholder:"e.g. Dishwasher: press & hold Start 3 sec. Oven takes 10 min to preheat.",type:"textarea"},{id:"smart-lock-issues",label:"Smart lock / keypad issues â battery, reset, backup entry?",placeholder:"e.g. If keypad unresponsive: hold # for 5 sec to reset. Backup key in lockbox at side entrance.",type:"textarea"},{id:"lockout",label:"What should guests do if locked out?",placeholder:"e.g. Call host at +44 7700 900000. Backup key in lockbox at side entrance (code: 1234). Locksmith: KeyMaster 24/7.",type:"textarea"},{id:"no-electricity",label:"Power outage â where is the fuse box? What to do?",placeholder:"e.g. Fuse box in hallway cupboard, top shelf. If a circuit trips, flip the switch back up. If whole building is out, call building management.",type:"textarea"},{id:"emergency",label:"Emergency info",placeholder:"e.g. Fire extinguisher under kitchen sink. Emergency exit via back stairwell. Call 999 for emergencies.",type:"textarea"}]},{id:"contacts",name:"Customer Service",description:"Who to contact for different situations.",icon:"ð",questions:[{id:"host-contact",label:"Host/manager contact",placeholder:"e.g. Ivan: +44 7700 900000, available 9 AM - 10 PM. After-hours emergencies: +44 7700 900001.",type:"textarea",required:!0},{id:"building-manager",label:"Building manager / concierge",placeholder:"e.g. Concierge desk open 8 AM - 8 PM. Building manager: John +44 7700 900002.",type:"textarea"},{id:"maintenance-contact",label:"Maintenance / emergency repairs",placeholder:"e.g. Plumbing/electric: Building maintenance +44 7700 900002 (Mon-Fri 9-5).",type:"textarea"},{id:"local-services",label:"Useful local services",placeholder:"e.g. Pharmacy: Boots 5 min walk. Locksmith: KeyMaster 24/7 +44 7700 900004.",type:"textarea"}]},{id:"maintenance-housekeeping",name:"Maintenance/Housekeeping",description:"Cleaning, linen, and maintenance arrangements.",icon:"ð§¹",questions:[{id:"cleaning-schedule",label:"Cleaning between guests",placeholder:"e.g. Full clean after every checkout. Cleaning team arrives at 11 AM. Turnover takes 2-3 hours.",type:"textarea"},{id:"midstay-clean",label:"Mid-stay cleaning availability",placeholder:"e.g. Available for stays 5+ nights. £40 per clean. Guest can request via portal or message.",type:"text"},{id:"linen-towels",label:"Linen & towel policy",placeholder:"e.g. Fresh linens provided at check-in. Extra towels in bedroom closet. Linen change available weekly.",type:"textarea"},{id:"supplies",label:"Supplies provided",placeholder:"e.g. Starter pack: toilet paper (2 rolls), hand soap, dish soap, sponge, bin bags.",type:"textarea"}]},{id:"booking-reservation",name:"Booking/Reservation",description:"Booking policies, cancellation, and payment terms.",icon:"ð
",questions:[{id:"cancellation-policy",label:"Cancellation policy",placeholder:"e.g. Free cancellation up to 7 days before check-in. 50% refund 3-7 days. No refund within 3 days.",type:"textarea"},{id:"minimum-stay",label:"Minimum stay requirements",placeholder:"e.g. 2 nights minimum. 3 nights on weekends. 7 nights in high season (Jun-Sep).",type:"text"},{id:"payment-terms",label:"Payment terms",placeholder:"e.g. Full payment at booking for stays under 28 nights. Monthly billing for long-term.",type:"textarea"},{id:"modification-policy",label:"Can guests modify their booking?",placeholder:"e.g. Date changes allowed up to 48h before check-in subject to availability.",type:"textarea"},{id:"security-deposit",label:"Security deposit â amount, when charged, refund timeline?",placeholder:"e.g. £200 pre-authorized at check-in. Released within 7 days after checkout if no damage.",type:"textarea"},{id:"extra-guest-fees",label:"Extra guest fees or child policies?",placeholder:"e.g. Up to 4 guests included. £15/night per additional guest. Children under 5 free.",type:"textarea"}]},{id:"procedures",name:"Procedures",description:"Internal operational procedures â how the AI should handle specific situations.",icon:"âï¸",questions:[{id:"early-checkin-policy",label:"Early check-in â when to approve, when to deny?",placeholder:"e.g. Approve if no checkout that day. Charge £30 if same-day checkout. Deny if back-to-back.",type:"textarea",prefillFrom:"portal.earlyCheckinFee"},{id:"late-checkout-policy",label:"Late check-out â when to approve, when to deny?",placeholder:"e.g. Free until 1 PM if no same-day check-in. £20 until 2 PM. Deny if new guest arriving.",type:"textarea",prefillFrom:"portal.lateCheckoutFee"},{id:"refund-policy",label:"Refund handling â when can AI offer refunds?",placeholder:"e.g. Up to £50 for cleanliness issues without escalation. Over £50 needs manager approval.",type:"textarea"},{id:"complaint-handling",label:"Guest complaints â how to respond?",placeholder:"e.g. Acknowledge, apologize, offer solution. For noise: contact building management.",type:"textarea"},{id:"escalation-rules",label:"When should AI escalate to a human?",placeholder:"e.g. Always escalate: damage claims, safety issues. After 2 failed resolution attempts.",type:"textarea"},{id:"upsells",label:"Upsell offerings",placeholder:"e.g. Airport transfer £60, mid-stay clean £40, late checkout £20. Mention for stays 5+ nights.",type:"textarea"},{id:"maintenance-procedure",label:"Maintenance issue handling",placeholder:"e.g. Minor (lightbulb): create task, tell guest 24h. Major (flood
66): call emergency line, escalate.",type:"textarea"}]}],al={id:"portal-services",name:"Guest Portal & Services",description:"Configure how Vanio uses your guest portal for check-in, upsells, and invoices.",icon:"ð",questions:[{id:"portal-checkin-link",label:"Should Vanio direct guests to the portal for check-in instructions?",placeholder:"e.g. Yes, always send the portal link with check-in details. Or: Only for direct bookings.",type:"textarea"},{id:"early-checkin-limits",label:"Early check-in â earliest time and conditions?",placeholder:"e.g. No earlier than 1 PM. Only if no same-day checkout. Always require approval for same-day arrivals.",type:"textarea",prefillFrom:"portal.earlyCheckinFee"},{id:"late-checkout-limits",label:"Late check-out â latest time and conditions?",placeholder:"e.g. Latest 2 PM. Only if no same-day check-in. Auto-approve if next guest arrives next day.",type:"textarea",prefillFrom:"portal.lateCheckoutFee"},{id:"midstay-cleaning-details",label:"Mid-stay cleaning â any special instructions or available days?",placeholder:"e.g. Available Mon-Fri only. Guest must book 24h in advance. Cleaning takes 2 hours.",type:"textarea"},{id:"upsell-approval-criteria",label:"When should upsell requests be auto-approved vs need human approval?",placeholder:"e.g. Auto-approve early c/i if no same-day checkout. Always require approval for late c/o past 2 PM.",type:"textarea"},{id:"portal-invoices",label:"Anything Vanio should tell guests about invoices/receipts?",placeholder:"e.g. All invoices are automatically available in the guest portal. City tax receipts generated separately.",type:"textarea"}]},ao={"Property Information":"property-info",Amenities:"amenities","House Rules":"rules","Check-in/Check-out":"check-in","Technical Issues":"troubleshooting","Travel Planning":"area","Customer Service":"contacts","Maintenance/Housekeeping":"maintenance-housekeeping","Booking/Reservation":"booking-reservation",Procedures:"procedures","Guest Portal & Services":"portal-services"};function ad(e){let t=ao[e];return t&&[...an,al].find(e=>e.id===t)||null}e.s(["HIDDEN_CATEGORIES",0,["Shadow Learned","AI Learned","Property Information","Service Provider Access","General","Feedback/Reviews"],"getQuestionnaireForCategory",0,ad,"getWizardCategories",0,function(e,t){let a=[...an];return e?.hasPortal&&a.push(al),t&&(a=a.map(e=>({...e,questions:e.questions.filter(e=>!e.requiredAmenities||0===e.requiredAmenities.length||e.requiredAmenities.some(e=>t.has(e)))})).filter(e=>e.questions.length>0)),a}],114724);let ac=e=>fetch(e,{credentials:"include"}).then(e=>{if(!e.ok)throw Error("Failed to fetch");return e.json()});function am({category:e,items:a,isExpanded:r,onToggle:s,hasQuestionnaire:i,onStartQuestionnaire:l,onEditItem:o,onCreateItem:d}){return(0,t.jsxs)("div",{className:(0,n.cn)("rounded-xl border transition-colors",r?"border-primary/30 bg-primary/[0.02]":"border-gray-200 dark:border-white/[0.08] bg-white dark:bg-white/[0.02]"),children:[(0,t.jsxs)("button",{onClick:s,className:"w-full flex items-center justify-between px-4 py-3 text-left",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[r?(0,t.jsx)(tA.ChevronDown,{className:"w-4 h-4 text-gray-400 dark:text-white/40"}):(0,t.jsx)(N.ChevronRight,{className:"w-4 h-4 text-gray-400 dark:text-white/40"}),(0,t.jsx)("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:e.name}),(0,t.jsxs)("span",{className:"text-xs text-gray-500 dark:text-white/40",children:[e.articleCount," article",1!==e.articleCount?"s":""]})]}),(0,t.jsx)(au,{status:e.status})]}),r&&(0,t.jsx)("div",{className:"px-4 pb-4 border-t border-gray-100 dark:border-white/[0.06]",children:0===a.length?(0,t.jsxs)("div",{className:"py-6 text-center",children:[(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-white/50 mb-3",children:"No articles in this category yet."}),(0,t.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[i&&(0,t.jsxs)(em.Button,{size:"sm",variant:"outline",onClick:l,className:"text-xs",children:[(0,t.jsx)(t4.ClipboardList,{className:"w-3.5 h-3.5 mr-1.5"}),"Start Questionnaire"]}),(0,t.jsxs)(em.Button,{size:"sm",variant:"outline",onClick:d,className:"text-xs",children:[(0,t.jsx)(er.Plus,{className:"w-3.5 h-3.5 mr-1.5"}),"Create Article"]})]})]}):(0,t.jsxs)("div",{className:"mt-3 space-y-1.5",children:[a.map(e=>(0,t.jsxs)("button",{onClick:()=>o(e.id),className:"w-full flex items-center gap-3 px-3 py-2 rounded-lg text-left hover:bg-gray-50 dark:hover:bg-white/[0.04] transition-colors group",children:[(0,t.jsx)(A.FileText,{className:"w-4 h-4 text-gray-400 dark:text-white/30 shrink-0"}),(0,t.jsx)("div",{className:"flex-1 min-w-0",children:(0,t.jsx)("p",{className:"text-sm text-gray-700 dark:text-white/70 truncate group-hover:text-gray-900 dark:group-hover:text-white",children:e.title})}),(0,t.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,t.jsx)(ax,{visibility:e.visibility}),(0,t.jsx)(ah,{source:e.source})]})]},e.id)),(0,t.jsxs)("div",{className:"flex gap-2 mt-2 pt-2 border-t border-gray-100 dark:border-white/[0.06]",children:[i&&(0,t.jsxs)(em.Button,{size:"sm",variant:"ghost",onClick:l,className:"text-xs text-gray-500 dark:text-white/50",children:[(0,t.jsx)(t4.ClipboardList,{className:"w-3.5 h-3.5 mr-1.5"}),"Questionnaire"]}),(0,t.jsxs)(em.Button,{size:"sm",variant:"ghost",onClick:d,className:"text-xs text-gray-500 dark:text-white/50",children:[(0,t.jsx)(er.Plus,{className:"w-3.5 h-3.5 mr-1.5"}),"Add Article"]})]})]})})]})}function au({status:e}){let{label:a,className:r}={complete:{label:"Complete",className:"bg-green-500/10 text-green-600 dark:text-green-400"},partial:{label:"In Progress",className:"bg-amber-500/10 text-amber-600 dar
66k:text-amber-400"},empty:{label:"Empty",className:"bg-gray-100 text-gray-500 dark:bg-white/[0.05] dark:text-white/40"}}[e];return(0,t.jsx)("span",{className:(0,n.cn)("text-[10px] font-medium px-2 py-0.5 rounded-full",r),children:a})}function ah({source:e}){let a="history"===e?"Mined":"ai_generated"===e?"AI":"media"===e?"Media":"questionnaire"===e?"Quiz":"manual"===e?"Manual":e;return(0,t.jsx)("span",{className:"text-[10px] text-gray-400 dark:text-white/30 bg-gray-100 dark:bg-white/[0.05] px-1.5 py-0.5 rounded",children:a})}function ax({visibility:e}){return"public"===e?(0,t.jsx)("span",{className:"text-[10px] text-green-600 dark:text-green-400 bg-green-500/10 px-1.5 py-0.5 rounded",children:"Portal"}):"ai_only"===e?(0,t.jsx)("span",{className:"text-[10px] text-purple-600 dark:text-purple-400 bg-purple-500/10 px-1.5 py-0.5 rounded",children:"Vanio AI"}):null}e.s(["TrainingCategoryGrid",0,function({listingId:e,categories:r,activeCategory:s,onCategoryClick:i,onStartQuestionnaire:n}){let{currentCustomerId:l}=(0,e4.useCustomer)(),{openForm:o}=(0,ar.useKBFormStore)(),d=l?`/api/kb/items?customerId=${l}&listingId=${e}&limit=200&status=active`:null,{data:c}=(0,tf.default)(d,ac),m=c?.items||[],{mutate:u}=(0,tf.default)(d,ac);(0,a.useEffect)(()=>{let e=()=>u();return window.addEventListener("kb:refresh",e),()=>window.removeEventListener("kb:refresh",e)},[u]);let h=m.reduce((e,t)=>{var a;let r=ai[a=t.category||"Uncategorized"]||a;return e[r]||(e[r]=[]),e[r].push(t),e},{}),x=s?r.filter(e=>e.name===s):r;return 0===r.length?(0,t.jsxs)("div",{className:"rounded-xl border border-gray-200 dark:border-white/[0.08] bg-white dark:bg-white/[0.02] p-8 text-center",children:[(0,t.jsx)(as.BookOpen,{className:"w-8 h-8 text-gray-400 dark:text-white/30 mx-auto mb-3"}),(0,t.jsx)("h3",{className:"text-sm font-medium text-gray-900 dark:text-white mb-1",children:"No categories found"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/50",children:"Categories will appear once knowledge base is set up."})]}):(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(as.BookOpen,{className:"w-4 h-4 text-primary"}),(0,t.jsx)("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Knowledge by Category"})]}),s&&(0,t.jsx)(em.Button,{variant:"ghost",size:"sm",onClick:()=>i(s),className:"text-xs text-gray-500 dark:text-white/50 hover:text-gray-700 dark:hover:text-white/70",children:"Show all categories"})]}),(0,t.jsx)("div",{className:"space-y-2",children:x.map(a=>(0,t.jsx)(am,{category:a,items:h[a.name]||[],isExpanded:s===a.name,onToggle:()=>i(a.name),hasQuestionnaire:!!ad(a.name),onStartQuestionnaire:()=>n(a.name),onEditItem:t=>o(String(t),e),onCreateItem:()=>o("new",e)},a.name))})]})}],503002)},244788,(e,t,a)=>{let r=new Proxy(function(){},{get:(e,t)=>"__esModule"===t||("default"===t?r:void 0),apply(){},construct:()=>({})});t.exports=r},114272,e=>{"use strict";var t=e.i(540143),a=e.i(936553),r=e.i(88587),s=class extends r.Removable{#e;#t;#a;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#a=e.mutationCache,this.#t=[],this.state=e.state||i(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#a.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#a.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||("pending"===this.state.status?this.scheduleGc():this.#a.remove(this))}continue(){return this.#r?.continue()??("pending"===this.state.status?this.execute(this.state.variables):Promise.resolve())}async execute(e){let t=()=>{this.#s({type:"continue"})},r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},s=this.#r=(0,a.createRetryer)({fn:()=>this.options.mutationFn?this.options.mutationFn(e,r):Promise.reject(Error("No mutationFn found")),onFail:(e,t)=>{this.#s({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#s({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#a.canRun(this)}
66),i="pending"===this.state.status,n=!s.canStart();try{if(i)t();else{this.#s({type:"pending",variables:e,isPaused:n}),this.#a.config.onMutate&&await this.#a.config.onMutate(e,this,r);let t=await this.options.onMutate?.(e,r);t!==this.state.context&&this.#s({type:"pending",context:t,variables:e,isPaused:n})}let a=await s.start();return await this.#a.config.onSuccess?.(a,e,this.state.context,this,r),await this.options.onSuccess?.(a,e,this.state.context,r),await this.#a.config.onSettled?.(a,null,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(a,null,e,this.state.context,r),this.#s({type:"success",data:a}),a}catch(t){try{await this.#a.config.onError?.(t,e,this.state.context,this,r)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,r)}catch(e){Promise.reject(e)}try{await this.#a.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,r)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,r)}catch(e){Promise.reject(e)}throw this.#s({type:"error",error:t}),t}finally{this.#r===s&&(this.#r=void 0),this.#a.runNext(this)}}#s(e){this.state=(t=>{switch(e.type){case"failed":return{...t,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...t,isPaused:!0};case"continue":return{...t,isPaused:!1};case"pending":return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}})(this.state),t.notifyManager.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#a.notify({mutation:this,type:"updated",action:e})})}};function i(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}e.s(["Mutation",0,s,"getDefaultState",0,i])},317751,466337,235580,926436,941912,703467,685343,899142,854878,770352,325854,296139,910183,134969,724338,406671,719910,874189,537187,294082,121798,490446,e=>{"use strict";let t,a,r,s,i,n,l,o,d,c,m,u,h,x,g,p;e.s([],537187),e.s(["CommandPaletteSuggestions",()=>ij],874189);var b,f,y=e.i(619273),w=e.i(175555),v=e.i(540143),k=e.i(814448),j=e.i(915823),N=e.i(114272),C=class extends j.Subscribable{#i;#n;#l;constructor(e={}){super(),this.config=e,this.#i=new Set,this.#n=new Map,this.#l=0}build(e,t,a){let r=new N.Mutation({client:e,mutationCache:this,mutationId:++this.#l,options:e.defaultMutationOptions(t),state:a});return this.add(r),r}add(e){this.#i.add(e);let t=S(e);if("string"==typeof t){let a=this.#n.get(t);a?a.push(e):this.#n.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#i.delete(e)){let t=S(e);if("string"==typeof t){let a=this.#n.get(t);if(a)if(a.length>1){let t=a.indexOf(e);-1!==t&&a.splice(t,1)}else a[0]===e&&this.#n.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){let t=S(e);if("string"!=typeof t)return!0;{let a=this.#n.get(t)?.find(e=>"pending"===e.state.status);return!a||a===e}}runNext(e){let t=S(e);return"string"==typeof t?this.#n.get(t)?.find(t=>
66t!==e&&t.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){v.notifyManager.batch(()=>{this.#i.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#i.clear(),this.#n.clear()})}getAll(){return Array.from(this.#i)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>(0,y.matchMutation)(t,e))}findAll(e={}){return this.getAll().filter(t=>(0,y.matchMutation)(e,t))}notify(e){v.notifyManager.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return v.notifyManager.batch(()=>Promise.all(e.map(e=>e.continue().catch(y.noop))))}};function S(e){return e.options.scope?.id}var E=j,I=e.i(286491),T=class extends E.Subscribable{#o;constructor(e={}){super(),this.config=e,this.#o=new Map}build(e,t,a){let r=t.queryKey,s=t.queryHash??(0,y.hashQueryKeyByOptions)(r,t),i=this.get(s);return i||(i=new I.Query({client:e,queryKey:r,queryHash:s,options:e.defaultQueryOptions(t),state:a,defaultOptions:e.getQueryDefaults(r)}),this.add(i)),i}add(e){this.#o.has(e.queryHash)||(this.#o.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){this.#o.get(e.queryHash)===e&&(e.destroy(),this.#o.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){v.notifyManager.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#o.get(e)}getAll(){return[...this.#o.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>(0,y.matchQuery)(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>(0,y.matchQuery)(e,t)):t}notify(e){v.notifyManager.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){v.notifyManager.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){v.notifyManager.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},_=class{#d;#a;#c;#m;#u;#h;#x;#g;constructor(e={}){this.#d=e.queryCache||new T,this.#a=e.mutationCache||new C,this.#c=e.defaultOptions||{},this.#m=new Map,this.#u=new Map,this.#h=0}mount(){this.#h++,1===this.#h&&(this.#x=w.focusManager.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#d.onFocus())}),this.#g=k.onlineManager.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#d.onOnline())}))}unmount(){this.#h--,0===this.#h&&(this.#x?.(),this.#x=void 0,this.#g?.(),this.#g=void 0)}isFetching(e){return this.#d.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#a.findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#d.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),a=this.#d.build(this,t),r=a.state.data;return void 0===r?this.fetchQuery(e):(e.revalidateIfStale&&a.isStaleByTime((0,y.resolveQueryValue)(t.staleTime,a))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#d.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,a){let r=this.defaultQueryOptions({queryKey:e}),s=this.#d.get(r.queryHash)?.state.data,i=(0,y.functionalUpdate)(t,s);if(void 0!==i)return this.#d.build(this,r).setData(i,{...a,manual:!0})}setQueriesData(e,t,a){return v.notifyManager.batch(()=>this.#d.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,a)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#d.get(t.queryHash)?.state}removeQueries(e){let t=this.#d;v.notifyManager.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let a=this.#d;return v.notifyManager.batch(()=>{let r=a.findAll(e),s=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:"active",predicate:e=>s.has(e)},t)})}cancelQueries(e,t={}){let a={revert:!0,...t};return Promise.all(v.notifyManager.batch(()=>this.#d.findAll(e).map(e=>e.cancel(a)))).then(y.noop).catch(y.noop)}invalidateQueries(e,t={}){return v.notifyManager.batch(()=>(this.#d.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType==="none")?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t))}refetchQueries(e,t={}){let a={...t,cancelRefetch:t.cancelRefetch??!0};return Promise.all(v.notifyManager.batch(()=>this.#d.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,a);
66return a.throwOnError||(t=t.catch(y.noop)),"paused"===e.state.fetchStatus?Promise.resolve():t}))).then(y.noop)}async query(e){let t=this.defaultQueryOptions(e);void 0===t.retry&&(t.retry=!1);let a=this.#d.build(this,t),r=a.isStaleByTime((0,y.resolveQueryValue)(t.staleTime,a))?await a.fetch(t):a.state.data,s=t.select;return s?s(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);void 0===t.retry&&(t.retry=!1);let a=this.#d.build(this,t);return a.isStaleByTime((0,y.resolveQueryValue)(t.staleTime,a))?a.fetch(t):Promise.resolve(a.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(y.noop).catch(y.noop)}infiniteQuery(e){return e._type="infinite",this.query(e)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(y.noop).catch(y.noop)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return k.onlineManager.isOnline()?this.#a.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#d}getMutationCache(){return this.#a}getDefaultOptions(){return this.#c}setDefaultOptions(e){this.#c=e}setQueryDefaults(e,t){this.#m.set((0,y.hashKey)(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#m.values()],a={};return t.forEach(t=>{(0,y.partialMatchKey)(e,t.queryKey)&&Object.assign(a,t.defaultOptions)}),a}setMutationDefaults(e,t){this.#u.set((0,y.hashKey)(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#u.values()],a={};return t.forEach(t=>{(0,y.partialMatchKey)(e,t.mutationKey)&&Object.assign(a,t.defaultOptions)}),a}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#c.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=(0,y.hashQueryKeyByOptions)(t.queryKey,t)),void 0===t.refetchOnReconnect&&(t.refetchOnReconnect="always"!==t.networkMode),void 0===t.throwOnError&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===y.skipToken&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#c.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#d.clear(),this.#a.clear()}};e.s(["QueryClient",0,_],317751);var A=e.i(843476),D=e.i(363178),P=e.i(217255),R=e.i(271645);let M="sidebar",F=R.createContext(void 0);function L({children:e}){let[t,a]=R.useState(!0),[r,s]=R.useState(!0);return(R.useEffect(()=>{let e=localStorage.getItem(M);e&&a(JSON.parse(e)),s(!1)},[]),r)?null:(0,A.jsx)(F.Provider,{value:{isSidebarOpen:t,toggleSidebar:()=>{a(e=>{let t=!e;return localStorage.setItem(M,JSON.stringify(t)),t})},isLoading:r},children:e})}var $=e.i(562710);function O(){let{data:e,status:t}=(0,P.useSession)();return(0,R.useEffect)(()=>{if("authenticated"!==t||!e?.user?.email)return;let a=e.user.email.toLowerCase();if("u"<typeof document)return;let r=window.location.hostname;if(!r.endsWith(".vanio.ai")&&"vanio.ai"!==r)return;let s="https:"===window.location.protocol?"; Secure":"";try{document.cookie=`vanio_email=${encodeURIComponent(a)}; domain=.vanio.ai; path=/; max-age=31536000; SameSite=Lax${s}`}catch{}},[t,e?.user?.email]),null}var U=e.i(846696);let B=({...e})=>{let{theme:t}=(0,D.useTheme)();return(0,A.jsx)(U.Toaster,{theme:"light"===t?"light":"dark",className:"toaster group",style:{zIndex:2147483e3},toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})};e.s(["Providers",0,function({children:e,...t}){return(0,A.jsx)(P.SessionProvider,{basePath:"/api/auth",refetchInterval:0,refetchOnWindowFocus:!0,children:(0,A.jsx)(D.ThemeProvider,{attribute:"class",defaultTheme:"system",enableSystem:!0,...t,children:(0,A.jsx)(L,{children:(0,A.jsxs)($.TooltipProvider,{children:[(0,A.jsx)(O,{}),e,(0,A.jsx)(B,{})]})})})})}],466337);var q=e.i(618566);e.s(["ImpersonationBanner",0,()=>{let{data:e,update:t}=(0,P.useSession)();(0,q.useRouter)();let a=e?.originalUser,r=async()=>{try{if(!(await fetch("/api/admin/end-impersonation",{method:"POST",credentials:"include"})).ok)throw Error("Failed to end impersonation");let e=await (0,P.signIn)("credentials",{redirect:!1,email:a?.email,restoreAdmin:"true",customerId:a?.customerId,isAdmin:a?.isAdmin});e?.ok?(await t(),window.location.href="/admin/customers"):(console.error("Failed to restore admin session:",e?.error),await (0,P.signOut)({callbackUrl:"/app/listings"}))}catch(e){console.error("Error ending impersonation:",e),await (0,P.signOut)({callbackUrl:"/app/listings"})}};return(0,A.jsx)("div",{className:"fixed bottom-0 left-0 right-0 bg-yellow-100 dark:bg-yellow-900 border-t border-yellow-200 dark:border-yellow-800 p-4 z-50",children:(0,A.jsxs)("div",{className:"container mx-auto flex justify-between items-center",children:[(0,A.jsxs)("div",{className:"text-yellow-800 dark:text-yellow-200",children:[(0,A.jsx)("span",{className:"font-medium",children:"Impersonating:"})," ",e?.user.email,(0,A.jsx)("span",{className:"mx-2",children:"|"}),(0,A.jsx)("span",{className:"font-medium",children:"Original user:"})," ",a?.email]}),(0,A.jsx)("button",{onClick:r,className:"bg-yellow-200 dark:bg-yellow-800 text-yellow-900 dark:text-yellow-100 px-4 py-2 rounded-md \n hover:bg-yellow-300 dark:hover:bg-yellow-700 transition-colors duration-200\n focus:outline-none focus:ring-2 focus:ring-yellow-500 focus:ring-opacity-50",children:"End Impersonation"})]})})}],235580);var z=e.i(482568);let H=(0,z.registerPlugin)("Network",{web:()=>e.A(437733).then(e=>new e.NetworkWeb)});var V=e.i(553475),G=e.i(657212),W=e.i(846932),K=e.i(88653);e.s(["NetworkStatus",0,function(){let[e,t]=(0,R.useState)(!0),[a,r]=(0,R.useState)(!1),s=z.Capacitor.isNativePlatform();return(0,R.useEffect)(()=>{let e=()=>{t(!0),r(!0),setTimeout(()=>r(!1),3e3)},a=()=>{t(!1),r(!0)};return(async()=>
66{if(s){let e=await H.getStatus();t(e.connected),r(!e.connected)}else t(navigator.onLine),r(!navigator.onLine)})(),s?H.addListener("networkStatusChange",e=>{t(e.connected),e.connected?(r(!0),setTimeout(()=>r(!1),3e3)):r(!0)}):(window.addEventListener("online",e),window.addEventListener("offline",a)),()=>{s?H.removeAllListeners():(window.removeEventListener("online",e),window.removeEventListener("offline",a))}},[s]),(0,A.jsx)(K.AnimatePresence,{children:a&&(0,A.jsx)(W.motion.div,{className:"fixed inset-x-0 top-0 z-[100] pt-safe",initial:{opacity:0,y:-100},animate:{opacity:1,y:0},exit:{opacity:0,y:-100},transition:{duration:.3,ease:"easeInOut"},children:(0,A.jsx)("div",{className:`w-full p-3 backdrop-blur-sm shadow-md ${e?"bg-green-900/95 border-b border-green-700/30":"bg-destructive/95 border-b border-destructive/30"}`,children:(0,A.jsx)("div",{className:"flex items-center justify-center px-4",children:e?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(V.Wifi,{className:"h-4 w-4 mr-2 text-green-400"}),(0,A.jsx)("p",{className:"text-green-400 font-medium text-sm",children:"Connection restored"})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(G.WifiOff,{className:"h-4 w-4 mr-2 text-gray-900 dark:text-white"}),(0,A.jsx)("p",{className:"text-white font-medium text-sm",children:"No internet connection"})]})})})})})}],926436);var Y=e.i(247167),J=e.i(974488),Q=e.i(522016),X=e.i(657688),Z=e.i(555436),ee=e.i(245423),et=e.i(239616),ea=e.i(107233),er=e.i(214416),es=e.i(878894),ei=e.i(37727),en=e.i(209912),el=e.i(725147),eo=e.i(931091),ed=e.i(737345),ec=e.i(664659),em=e.i(643531),eu=e.i(531278),eh=e.i(972520),ex=e.i(649582),eg=e.i(13270),ep=e.i(158809),eb=e.i(75138),ef=e.i(568612);function ey(){let{data:e}=(0,P.useSession)(),t=(0,eb.useSettingsStore)(e=>e.openSettings),{settings:a}=(0,ef.useUserSettings)();if(!e?.user||!a)return null;let r=a.image||e.user.image,s=a.name||e.user.name,i=a.email||e.user.email;return(0,A.jsx)("div",{className:"relative",children:(0,A.jsx)("button",{onClick:t,className:"w-8 h-8 rounded-full overflow-hidden bg-gray-100 hover:bg-gray-200 dark:bg-white/10 dark:hover:bg-white/20 transition-colors",children:r?(0,A.jsx)(X.default,{src:r,alt:s||"User avatar",width:32,height:32,className:"object-cover"}):(0,A.jsx)("div",{className:"w-full h-full flex items-center justify-center text-gray-600 dark:text-white/70",children:s?.[0]||i?.[0]||"?"})})})}var ew=e.i(908263),ev=e.i(567847),ek=e.i(876926),ej=e.i(922927),eN=e.i(722915),eC=e.i(655900),eS=e.i(778917),eE=e.i(686311),eI=e.i(730699),eT=e.i(503116),e_=e.i(87316),eA=e.i(564680),eA=eA;let eD={getPriorityStyles:e=>{switch(e?.toLowerCase()){case"critical":return"bg-red-500/10 text-red-500";case"high":return"bg-orange-500/10 text-orange-500";case"medium":return"bg-yellow-500/10 text-yellow-500";default:return"bg-blue-500/10 text-blue-500"}},getNotificationIcon:e=>{let t=("source_type"in e?e.source_type?.toLowerCase():void 0)||e.metadata?.sourceType?.toLowerCase(),a=e.type?.toLowerCase();if("reservation"===t)return e_.Calendar;switch(a){case"message":case"notification":return eE.MessageSquare;case"achievement":return eI.Gift;case"command":return eT.Clock;default:return ee.Bell}},formatTime:e=>{if(!e)return"";let t="string"==typeof e?new Date(e):e,a=Math.floor((new Date().getTime()-t.getTime())/6e4),r=Math.floor(a/60),s=Math.floor(r/24);return a<60?`${a}m ago`:r<24?`${r}h ago`:s<7?`${s}d ago`:t.toLocaleDateString()},EmptyState:({className:e})=>(0,A.jsxs)("div",{className:(0,ew.cn)("flex flex-col items-center justify-center p-8 text-center","min-h-[300px]",e),children:[(0,A.jsx)("div",{className:(0,ew.cn)("w-12 h-12 rounded-full","bg-gradient-to-br from-gray-100 dark:from-white/[0.08] to-gray-50 dark:to-white/[0.02]","flex items-center justify-center mb-4","border border-gray-200 dark:border-white/[0.08]"),children:(0,A.jsx)(eA.default,{className:"w-6 h-6 text-gray-500 dark:text-white/40"})}),(0,A.jsx)("h3",{className:"text-base font-medium text-gray-900 dark:text-white mb-2",children:"All caught up!"}),(0,A.jsx)("p",{className:"text-sm text-gray-500 dark:text-white/60 max-w-[280px]",children:"When you receive notifications, they'll show up here. We'll let you know
66when something needs your attention."})]}),handleNotificationClick:async(e,t)=>{let a=e.external_link||e.externalLink||e.metadata?.externalLink;t.closeDropdown&&t.closeDropdown(),t.onClose&&t.onClose();let r=e.metadata?.path||e.source_reference?.path;if(r&&!a){e.id&&!e.readAt&&fetch("/api/notifications",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id,action:"markAsRead"})}).catch(()=>{}),window.location.href=r;return}if(a){e.id&&!e.readAt&&fetch("/api/notifications",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id,action:"markAsRead"})}).then(()=>{t.markAsRead&&t.markAsRead(e.id),window.dispatchEvent(new CustomEvent("notification:read",{detail:{id:Number(e.id)}}))}).catch(e=>{console.error("â [NotificationUtils] Error marking notification as read:",e)}),window.open(a,"_blank","noopener,noreferrer");return}localStorage.setItem("opening_from_notification","true");let s=e.source_reference||e.metadata?.sourceReference,i=s?.threadId||e.metadata?.threadId,n=s?.reservationId,l=s?.dashboardItemId||s?.itemId;try{if(l)if(t.openModal){let e=Number(l);isNaN(e)?console.error("[NotificationUtils] Failed to convert dashboardItemId to number:",l):t.openModal(e,{fromClick:!0,force:!0})}else console.warn("[NotificationUtils] openModal function not provided in options"),"function"==typeof window.openModal?window.openModal(l):console.warn("[NotificationUtils] No openModal function available");else i?t.openModalByThreadId(i):n&&(!s?.type||s?.type!=="inquiry")&&t.openModalByReservation(n);e.id&&!e.readAt&&fetch("/api/notifications",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id,action:"markAsRead"})}).then(()=>{t.markAsRead&&t.markAsRead(e.id),window.dispatchEvent(new CustomEvent("notification:read",{detail:{id:Number(e.id)}}))}).catch(e=>{console.error("â [NotificationUtils] Error marking notification as read:",e)})}catch(e){console.error("â [NotificationUtils] Error opening modal:",e)}finally{setTimeout(()=>{localStorage.removeItem("opening_from_notification")},1e3)}},renderHTML:e=>({__html:e})};e.s(["NotificationUtils",0,eD],941912);var eP=e.i(232676);function eR({onClose:e,openSidebar:t}){let{isDropdownOpen:a,closeDropdown:r,showAllNotifications:s}=(0,ek.useNotificationStore)(),{notifications:i,getUnreadCount:n,markAsRead:l}=(0,ej.useActivity)(),[o,d]=(0,R.useState)(null),[c,m]=(0,R.useState)(null),{openModalByReservation:u,openModal:h,openModalByThreadId:x}=(0,eP.useDashboard)(),[g,p]=(0,R.useState)(new Set),b=(0,R.useRef)(!1),f=(0,q.useRouter)(),y=n(),w=i.slice(0,5),v=i.length>5;(0,R.useEffect)(()=>{a&&!b.current&&(b.current=!0,(async()=>{let e=i.filter(e=>("unread"===e.status||!1===e.is_read||e.recipient_status&&!e.recipient_status.is_read)&&"critical"!==e.priority);if(0!==e.length)try{if(!(await fetch("/api/notifications",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"markAllRead",excludePriority:"critical"})})).ok)throw Error("Failed to mark all as read");e.forEach(e=>{window.dispatchEvent(new CustomEvent("notification:read",{detail:{id:Number(e.id)}}))})}catch(e){console.error("Error marking all as read:",e)}})()),a||(b.current=!1)},[a,i]);let k=async e=>{m(e);try{if(!(await fetch("/api/notifications",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"archive",id:e})})).ok)throw Error("Failed to archive notification");window.dispatchEvent(new CustomEvent("notification:archive",{detail:{id:Number(e)}}))}catch(e){console.error("Error archiving notification:",e)}finally{m(null)}};return(0,R.useEffect)(()=>{let t=t=>{let a=document.getElementById("notification-dropdown"),s=document.getElementById("notification-trigger");!a||a.contains(t.target)||s?.contains(t.target)||(r(),e())};return a&&document.addEventListener("mousedown",t),()=>{document.removeEventListener("mousedown",t)}},[a,r,e]),(0,A.jsx)(K.AnimatePresence,{children:a&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(W.motion.div,{initial:{opacity:0}
66,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-50"}),(0,A.jsxs)(W.motion.div,{id:"notification-dropdown",onClick:e=>e.stopPropagation(),initial:{opacity:0,y:-8,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.98},transition:{duration:.2},className:(0,ew.cn)("absolute right-0 top-12 z-50 w-[380px]","bg-white dark:bg-[#1D1D1F] rounded-2xl","border border-gray-200 dark:border-white/[0.08]","shadow-[0_0_0_1px_rgba(0,0,0,0.05),0_2px_8px_0_rgba(0,0,0,0.08)] dark:shadow-[0_0_0_1px_rgba(255,255,255,0.05),0_2px_8px_0_rgba(0,0,0,0.2)]"),children:[(0,A.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-white/[0.08]",children:[(0,A.jsxs)("div",{className:"flex items-center gap-2",children:[(0,A.jsx)(ee.Bell,{className:"w-5 h-5 text-gray-600 dark:text-white/70"}),(0,A.jsx)("h2",{className:"text-base font-medium text-gray-900 dark:text-white",children:"Notifications"}),y>0&&(0,A.jsx)("span",{className:"px-2 py-0.5 text-xs font-medium rounded-full bg-red-500/20 text-red-500",children:y})]}),(0,A.jsxs)("div",{className:"flex items-center gap-2",children:[(0,A.jsx)(Q.default,{href:"/settings/notifications",onClick:()=>{r(),e()},className:"p-2 rounded-full hover:bg-gray-100 dark:hover:bg-white/[0.08] transition-colors",title:"Notification Settings",children:(0,A.jsx)(et.Settings,{className:"w-4 h-4 text-gray-600 dark:text-white/70"})}),(0,A.jsx)("button",{onClick:r,className:"p-2 rounded-full hover:bg-gray-100 dark:hover:bg-white/[0.08] transition-colors",children:(0,A.jsx)(ei.X,{className:"w-4 h-4 text-gray-600 dark:text-white/70"})})]})]}),(0,A.jsx)("div",{className:"py-2 max-h-[min(420px,60vh)] overflow-y-auto",children:w.length>0?(0,A.jsx)(A.Fragment,{children:w.map(t=>{if(!t?.id)return null;let a=t.id.toString(),s=eD.getNotificationIcon(t),i=c===a;return(0,A.jsxs)("div",{onClick:()=>(t=>{if(!g.has(t.id.toString()+"_clicking")){if(l(t.id.toString()),t.source_reference?.url){f.push(t.source_reference.url),r(),e();return}if(t.source_type?.includes("task")&&t.source_reference?.taskId){let a=t.source_reference.taskId,s=t.metadata?.biddedAt,i=new URL(window.location.href),n=new URLSearchParams(i.search);n.set("task",a),s?n.set("marketplace","true"):n.delete("marketplace");let l=`${i.pathname}?${n.toString()}`;f.push(l),r(),e();return}let a=t.external_link||t.externalLink||t.metadata?.externalLink;if(a){a.startsWith("/")?f.push(a):window.open(a,"_blank","noopener,noreferrer"),r(),e();return}eD.handleNotificationClick(t,{closeDropdown:r,onClose:e,openModalByReservation:u,openModalByThreadId:x,openModal:h,markAsRead:l})}})(t),onMouseEnter:()=>d(a),onMouseLeave:()=>d(null),className:(0,ew.cn)("relative px-4 py-3","hover:bg-gray-50 dark:hover:bg-white/[0.02] transition-colors cursor-pointer",("unread"===t.status||!1===t.is_read)&&"bg-gray-50 dark:bg-white/[0.02]","border-l-2","unread"===t.status||!1===t.is_read?"border-l-blue-500":"border-l-transparent"),children:[(0,A.jsxs)("div",{className:"flex gap-3",children:[(0,A.jsx)("div",{className:(0,ew.cn)("w-8 h-8 rounded-full flex items-center justify-center","bg-gray-50 dark:bg-white/[0.05]"),children:(0,A.jsx)(s,{className:"w-4 h-4 text-gray-600 dark:text-white/70"})}),(0,A.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,A.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,A.jsxs)("div",{className:"flex items-center gap-2",children:[(0,A.jsxs)("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:[t.title,(t.external_link||t.externalLink||t.metadata?.externalLink)&&(0,A.jsx)("span",{className:"inline-block ml-1",children:(0,A.jsx)(eS.ExternalLink,{className:"w-3.5 h-3.5 text-gray-500 dark:text-white/60 inline align-text-bottom"})})]}),(0,A.jsx)("span",{className:(0,ew.cn)("px-2 py-0.5 text-xs font-medium rounded-full",eD.getPriorityStyles(t.priority)),children:t.priority})]}),(0,A.jsx)("div",{className:"text-xs text-gray-500 dark:text-white/40 whitespace-nowrap",children:t.time})]}),(t.description||t.message)&&(0,A.jsxs)("div",{className:"flex flex-col",children:[(0,A.jsxs)("div",{className:(0,ew.cn)("text-sm whitespace-pre-line","unread"===t.status||!1===t.is_read?"text-gray-600 dark:text-white/80":"text-gray-500 dark:text-white/60",g.has(a)?"max-h-none":"max-h-[120px] overflow-hidden relative"),children:[t.description||t.message,!g.has(a)&&((t.description?.length??0)>120||(t.message?.length??0)>120)&&(0,A.jsx)("div",{className:(0,ew.cn)("absolute bottom-0 left-0 right-0 h-16 pointer-events-none","bg-gradient-to-t from-white via-white/80 to-transparent","dark:from-[#1D1D1F] dark:via-[#1D1D1F]/80 dark:to-transparent","backdrop-blur-[2px]")})]}),((t.description?.length??0)>120||(t.message?.length??0)>120)&&(0,A.jsx)("div",{className:g.has(a)?"mt-2":"-mt-6 relative z-10",children:(0,A.jsx)("button",{onClick:e=>{e.stopPropagation(),p(e=>{let t=new Set(e);return t.has(a)?t.delete(a):t.add(a),t})},className:"text-xs text-gray-600 dark:text-white/70 self-start flex items-center gap-1 transition-colors hover:text-gray-700 dark:hover:text-white/90",children:g.has(a)?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(eC.ChevronUp,{className:"w-3 h-3"}),(0,A.jsx)("span",{children:"Show less"})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(ec.ChevronDown,{className:"w-3 h-3"}),(0,A.jsx)("span",{children:"Show more"})]})})})]})]})]}),(o===a||i)&&(0,A.jsx)("div",{className:"absolute right-4 top-1/2 -translate-y-1/2 flex items-center gap-1",children:(0,A.jsx)("button",{onClick:e=>{e.stopPropagation(),k(a)},disabled:i,className:(0,ew.cn)("p-1.5 rounded-full transition-colors","bg-gray-100 dark:bg-[#2A2A2D] hover:bg-gray-200 dark:hover:bg-[#3A3A3D]","shadow-sm shadow-black/5 dark:shadow-black/10",i?"opacity-70":"","text-gray-500 dark:text-white/60 hover:text-red-400"),children:i?(0,A.jsx)(eu.Loader2,{className:"w-4 h-4 animate-spin text-gray-500 dark:text-white/60"}):(0,A.jsx)(eN.Archive,{className:"w-4 h-4"})})})]},a)})}):(0,A.jsx)(eD.EmptyState,{})}),v&&(0,A.jsx)("div",{className:"p-3 border-t border-gray-200 dark:border-white/[0.08]",children:(0,A.jsxs)("button",{onClick:()=>{r(),s()},className:(0,ew.cn)("w-full px-4 py-2 rounded-xl","text-sm font-medium text-gray-600 dark:text-white/70","hover:bg-gray-100 dark:hover:bg-white/[0.08] transition-colors","flex items-center justify-center gap-2"),children:["See all notifications",(0,A.jsx)(eh.ArrowRight,{className:"w-4 h-4"})]})})]})]})})}var eM=e.i(671142),eF=e.i(839305),eL=e.i(180239),e$=e.i(996091),eO=e.i(663420),eU=e.i(260934),eB=e.i(667770),eq=e.i(337607),ez=e.i(187377),eH=e.i(283086),eV=e.i(195116),eG=e.i(710289),eW=e.i(473815),eW=eW,eK=e.i(751975),eY=e.i(463059),eJ=e.i(215286);let eQ="https://api.vanio.ai",eX="https://www.vanio.ai",eZ={feature:{icon:eH.Sparkles,color:"indigo"},improvement:{icon:eV.Wrench,color:"emerald"},fix:{icon:eG.Bug,color:"amber"}};function e0(e,t="en"){return new Date(e).toLocaleDateString({en:"en-US",es:"es-ES",fr:"fr-FR",it:"it-IT",pl:"pl-PL",bg:"bg-BG"}[t]||"en-US",{month:"short",day:"numeric",year:"numeric"})}function e1(e,t,a){return"en"!==a&&e.translations?.[a]?.[t]?e.translations[a][t]:e[t]||""}function e2({open:e,onOpenChange:t}){let a,{changelog:r,activeLanguage:s}=(0,eq.useTranslations)(),[i,n]=(0,R.useState)("overview"),[l,o]=(0,R.useState)([]),[d,c]=(0,R.useState)([]),[m,u]=(0,R.useState)(new Map),[h,x]=(0,R.useState)(!1),[g,p]=(0,R.useState)(!1),b=(0,R.useCallback)(async()=>{x(!0);try{let[e,t]=await Promise.all([fetch(`${eQ}/changelog`,{credentials:"include"}),fetch(`${eQ}/releases?limit=20`).catch(()=>null)]);if(e.ok){let t=await e.json();o(t.entries||[])}if(t?.ok){let e=((await t.json()).releases||[]).filter(e=>"published"===e.status);c(e);let a=e.filter(e=>e.blog_post_id).map(e=>e.blog_post_id);if(a.length>0){let e=new Map;await Promise.all(a.map(async t=>{try{let a=await fetch(`${eQ}/blog/${t}`);if(a.ok){let r=await a.json();r&&e.set(t,{id:r.id,slug:r.slug,title:r.title,audio_url:r.audio_url})}}catch{}})),u(e)}}}catch(e){console.error("[ChangelogSheet] Fetch error:",e)}finally{x(!1),p(!0)}},[]),f=(0,R.useCallback)(async()=>{try{await fetch(`${eQ}/changelog/seen`,{method:"POST",credentials:"include"}),window.dispatchEvent(new CustomEvent("changelog:seen"))}catch{}},[]);(0,R.useEffect)(()=>{e&&!g&&b(),e&&f()},[e,g,b,f]);let{activeProduct:y}=(0,eO.useProductSafe)(),w="atlasdna.ai"===(a=window.location.hostname)||"app.atlasdna.ai"===a||"atlas.localhost"===a||"fantasticstay.com"===a||"app.fantasticstay.com"===a||"fs.localhost"===a,v=(0,R.useMemo)(()=>l.filter(e=>{let t=["vanio_ai","atlas","fantasticstay","repull"],a=e.product_ids?.length?e.product_ids:e.tags?.filter(e=>t.includes(e))||[];return 0===a.length?!w:a.includes(y)}),[l,y,w]),k=(0,R.useMemo)(()=>d.filter(e=>e.product_ids?.length?e.product_ids.includes(y):!w),[d,y,w]),j=(0,R.useMemo)(()=>(function(e,t="en"){let a={en:"en-US",es:"es-ES",fr:"fr-FR",it:"it-IT",pl:"pl-PL",bg:"bg-BG"},r={};for(let s of e){let e=new Date(s.published_at).toLocaleDateString(a[t]||"en-US",{month:"long",year:"numeric"});r[e]||(r[e]=[]),r[e].push(s)}return r})(v,s),[v,s]);
66return(0,A.jsx)(ez.Sheet,{open:e,onOpenChange:t,children:(0,A.jsxs)(ez.SheetContent,{side:"right",className:(0,ew.cn)("w-full sm:max-w-[440px] p-0 overflow-hidden","bg-white dark:bg-[#1C1C1E]","border-gray-200 dark:border-white/[0.08]"),children:[(0,A.jsxs)(ez.SheetHeader,{className:"px-5 pt-5 pb-3 border-b border-gray-200 dark:border-white/[0.08]",children:[(0,A.jsxs)(ez.SheetTitle,{className:"flex items-center gap-2 text-lg font-semibold text-gray-900 dark:text-white",children:[(0,A.jsx)(eH.Sparkles,{className:"w-5 h-5 text-indigo-500"}),r.title]}),(0,A.jsx)(ez.SheetDescription,{className:"text-sm text-gray-500 dark:text-white/40 mt-1",children:r.subtitle})]}),(0,A.jsx)("div",{className:"flex border-b border-gray-200 dark:border-white/[0.06] px-5",children:[{key:"overview",label:"Overview"},{key:"releases",label:r.tabs.releases},{key:"all",label:r.tabs.allChanges}].map(({key:e,label:t})=>(0,A.jsx)("button",{onClick:()=>n(e),className:(0,ew.cn)("px-3 py-2.5 text-sm font-medium border-b-2 transition-colors -mb-px",i===e?"border-indigo-500 text-indigo-600 dark:text-indigo-400":"border-transparent text-gray-500 dark:text-white/40 hover:text-gray-700 dark:hover:text-white/60"),children:t},e))}),(0,A.jsxs)("div",{className:"overflow-y-auto h-[calc(100%-120px)]",children:["vanio_ai"===y&&(0,A.jsx)("a",{href:`${eX}/invest`,target:"_blank",rel:"noopener noreferrer",onClick:()=>{fetch("https://api.vanio.ai/user/seen",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({feature:"invest"})}).catch(()=>{})},className:"block px-5 py-4 bg-gradient-to-r from-indigo-500/[0.06] to-violet-500/[0.04] hover:from-indigo-500/[0.10] hover:to-violet-500/[0.06] transition-colors border-b border-gray-100 dark:border-white/[0.06]",children:(0,A.jsxs)("div",{className:"flex items-center gap-3",children:[(0,A.jsx)("div",{className:"w-8 h-8 rounded-full bg-indigo-500/10 border border-indigo-500/20 flex items-center justify-center shrink-0",children:(0,A.jsx)(el.Gem,{className:"w-4 h-4 text-indigo-400"})}),(0,A.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,A.jsx)("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Vanio AI is community-funded"}),(0,A.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/40 mt-0.5",children:"Join the operators and builders investing in the future of hospitality â"})]})]})}),h&&!g?(0,A.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,A.jsx)(eu.Loader2,{className:"w-5 h-5 animate-spin text-gray-400 dark:text-white/40"})}):"overview"===i?(0,A.jsx)(e5,{releases:k,entries:v,blogPosts:m,locale:s,t:r}):"releases"===i?(0,A.jsx)(e4,{releases:k,blogPosts:m,locale:s,t:r}):(0,A.jsx)(e3,{grouped:j,locale:s,t:r})]})]})})}function e5({releases:e,entries:t,blogPosts:a,locale:r,t:s}){let i,n,l,o=e[0]||null,d=t.slice(0,8);return(0,A.jsxs)("div",{children:[o&&(i=o.blog_post_id?a.get(o.blog_post_id):null,n=e1(o,"title",r),l=e1(o,"tagline",r),(0,A.jsxs)("div",{className:"px-5 py-5 border-b border-gray-100 dark:border-white/[0.06]",children:[(0,A.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,A.jsx)(eH.Sparkles,{className:"w-3.5 h-3.5 text-indigo-500"}),(0,A.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-indigo-600 dark:text-indigo-400",children:"Latest Release"})]}),(0,A.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,A.jsxs)("span",{className:"text-xs font-semibold px-2 py-0.5 rounded-full bg-indigo-500/10 text-indigo-600 dark:text-indigo-400 border border-indigo-500/20",children:["v",o.version]}),o.published_at&&(0,A.jsx)("span",{className:"text-xs text-gray-400 dark:text-white/30",children:e0(o.published_at,r)})]}),(0,A.jsx)("h3",{className:"text-base font-semibold text-gray-900 dark:text-white leading-snug",children:n}),(0,A.jsx)("p",{className:"text-sm text-gray-600 dark:text-white/50 mt-1 leading-relaxed line-clamp-2",children:l}),(0,A.jsxs)("div",{className:"flex items-center gap-3 mt-3",children:[(0,A.jsxs)("a",{href:`${eX}/releases/${o.slug}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-xs font-medium text-indigo-600 dark:text-indigo-400 hover:text-indigo-500",children:[s.release.readMore,(0,A.jsx)(eY.ChevronRight,{className:"w-3 h-3"})]}),i&&(0,A.jsxs)("a",{href:`${eX}/blog/${i.slug}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-xs font-medium text-gray-500 dark:text-white/40 hover:text-gray-700 dark:hover:text-white/60",children:[(0,A.jsx)(eS.ExternalLink,{className:"w-3 h-3"}),s.release.viewBlogPost,i.audio_url&&(0,A.jsx)(eW.default,{className:"w-3 h-3 text-indigo-400"})]})]}),o.cover_image&&(0,A.jsx)("div",{className:"mt-3 rounded-lg overflow-hidden border border-gray-200 dark:border-white/[0.08]",children:(0,A.jsx)("img",{src:o.cover_image,alt:n,className:"w-full h-auto"})})]})),d.length>0&&(0,A.jsxs)("div",{children:[(0,A.jsx)("div",{className:"px-5 py-2 bg-gray-50 dark:bg-white/[0.03] border-b border-gray-100 dark:border-white/[0.06]",children:(0,A.jsx)("span",{className:"text-xs font-medium text-gray-500 dark:text-white/40 uppercase tracking-wider",children:"Recent
66Changes"})}),d.map(e=>{let t=eZ[e.type]||eZ.feature,a=t.icon,i=e1(e,"title",r),n=s.entry.types[e.type]||e.type,l={indigo:"bg-indigo-500/10 text-indigo-500 dark:text-indigo-400 border-indigo-500/20",emerald:"bg-emerald-500/10 text-emerald-500 dark:text-emerald-400 border-emerald-500/20",amber:"bg-amber-500/10 text-amber-500 dark:text-amber-400 border-amber-500/20"}[t.color];return(0,A.jsx)("div",{className:"px-5 py-3 hover:bg-gray-50 dark:hover:bg-white/[0.02] transition-colors border-b border-gray-50 dark:border-white/[0.03] last:border-0",children:(0,A.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,A.jsxs)("div",{className:(0,ew.cn)("flex items-center gap-1 px-1.5 py-0.5 rounded-full border text-[10px] font-medium shrink-0",l),children:[(0,A.jsx)(a,{className:"w-2.5 h-2.5"}),n]}),(0,A.jsx)("p",{className:"text-sm text-gray-900 dark:text-white leading-snug flex-1 min-w-0 truncate",children:i}),(0,A.jsx)("span",{className:"text-[10px] text-gray-400 dark:text-white/25 shrink-0",children:e0(e.published_at,r)})]})},e.id)})]}),!o&&0===d.length&&(0,A.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 px-5",children:[(0,A.jsx)(eH.Sparkles,{className:"w-8 h-8 text-gray-300 dark:text-white/20 mb-3"}),(0,A.jsx)("p",{className:"text-sm font-medium text-gray-500 dark:text-white/40",children:s.empty.noEntries}),(0,A.jsx)("p",{className:"text-xs text-gray-400 dark:text-white/25 mt-1",children:s.empty.noEntriesDescription})]})]})}function e4({releases:e,blogPosts:t,locale:a,t:r}){return 0===e.length?(0,A.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 px-5",children:[(0,A.jsx)(eK.Tag,{className:"w-8 h-8 text-gray-300 dark:text-white/20 mb-3"}),(0,A.jsx)("p",{className:"text-sm font-medium text-gray-500 dark:text-white/40",children:r.empty.noReleases}),(0,A.jsx)("p",{className:"text-xs text-gray-400 dark:text-white/25 mt-1",children:r.empty.noReleasesDescription})]}):(0,A.jsx)("div",{className:"divide-y divide-gray-100 dark:divide-white/[0.06]",children:e.map(e=>{let s=e.blog_post_id?t.get(e.blog_post_id):null,i=e1(e,"title",a),n=e1(e,"tagline",a),l=e1(e,"excerpt",a);return(0,A.jsxs)("div",{className:"px-5 py-5",children:[(0,A.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,A.jsxs)("span",{className:"text-xs font-semibold px-2 py-0.5 rounded-full bg-indigo-500/10 text-indigo-600 dark:text-indigo-400 border border-indigo-500/20",children:["v",e.version]}),e.published_at&&(0,A.jsx)("span",{className:"text-xs text-gray-400 dark:text-white/30",children:e0(e.published_at,a)})]}),(0,A.jsx)("h3",{className:"text-base font-semibold text-gray-900 dark:text-white leading-snug",children:i}),(0,A.jsx)("p",{className:"text-sm text-gray-600 dark:text-white/50 mt-1 leading-relaxed",children:n}),l&&(0,A.jsx)("p",{className:"text-sm text-gray-500 dark:text-white/40 mt-2 leading-relaxed line-clamp-3",children:l}),(0,A.jsxs)("div",{className:"flex items-center gap-3 mt-3",children:[(0,A.jsxs)("a",{href:`${eX}/releases/${e.slug}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-xs font-medium text-indigo-600 dark:text-indigo-400 hover:text-indigo-500",children:[r.release.readMore,(0,A.jsx)(eY.ChevronRight,{className:"w-3 h-3"})]}),s&&(0,A.jsxs)("a",{href:`${eX}/blog/${s.slug}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-xs font-medium text-gray-500 dark:text-white/40 hover:text-gray-700 dark:hover:text-white/60",children:[(0,A.jsx)(eS.ExternalLink,{className:"w-3 h-3"}),r.release.viewBlogPost,s.audio_url&&(0,A.jsx)(eW.default,{className:"w-3 h-3 text-indigo-400"})]})]}),e.cover_image&&(0,A.jsx)("div",{className:"mt-3 rounded-lg overflow-hidden border border-gray-200 dark:border-white/[0.08]",children:(0,A.jsx)("img",{src:e.cover_image,alt:i,className:"w-full h-auto"})})]},e.id)})})}function e3({grouped:e,locale:t,t:a}){return 0===Object.keys(e).length?(0,A.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 px-5",children:[(0,A.jsx)(eH.Sparkles,{className:"w-8 h-8 text-gray-300 dark:text-white/20 mb-3"}),(0,A.jsx)("p",{className:"text-sm font-medium text-gray-500 dark:text-white/40",children:a.empty.noEntries}),(0,A.jsx)("p",{className:"text-xs text-gray-400 dark:text-white/25 mt-1",children:a.empty.noEntriesDescription})]}):(0,A.jsx)("div",{className:"divide-y divide-gray-100 dark:divide-white/[0.06]",children:Object.entries(e).map(([e,r])=>(0,A.jsxs)("div",{children:[(0,A.jsx)("div",{className:"sticky top-0 z-10 px-5 py-2 bg-gray-50 dark:bg-white/[0.03] border-b border-gray-100 dark:border-white/[0.06]",children:(0,A.jsx)("span",{className:"text-xs font-medium text-gray-500 dark:text-white/40 uppercase tracking-wider",children:e})}),r.map(e=>{let r=eZ[e.type]||eZ.feature,s=r.icon,i=e1(e,"title",t),n=e1(e,"summary",t),l=a.entry.types[e.type]||e.type,o={indigo:"bg-indigo-500/10 text-indigo-500 dark:text-indigo-400 border-indigo-500/20",emerald:"bg-emerald-500/10 text-emerald-500 dark:text-emerald-400 border-emerald-500/20",amber:"bg-amber-500/10 text-amber-500 dark:text-amber-400 border-amber-500/20"}[r.color];return(0,A.jsx)("div",{className:"px-5 py-4 hover:bg-gray-50 dark:hover:bg-white/[0.02] transition-colors",children:(0,A.jsxs)("div",{className:"flex items-start gap-3",children:[(0,A.jsxs)("div",{className:(0,ew.cn)("flex items-center gap-1.5 px-2 py-0.5 rounded-full border text-xs font-medium shrink-0 mt-0.5",o),children:[(0,A.jsx)(s,{className:"w-3 h-3"}),l]}),(0,A.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,A.jsx)("h3",{className:"text-sm font-medium text-gray-900 dark:text-white leading-snug",children:i}),(0,A.jsx)("div",{className:"text-sm text-gray-600 dark:text-white/60 mt-1 leading-relaxed [&_strong]:font-semibold [&_em]:italic [&_a]:underline [&_p]:mb-1 [&_p:last-child]:mb-0",children:(0,A.jsx)(eJ.MemoizedReactMarkdown,{children:n})}),(0,A.jsxs)("div",{className:"flex items-center gap-2 mt-2",children:[(0,A.jsx)("span",{className:"text-xs text-gray-400 dark:text-white/30",children:e0(e.published_at,t)}),e.tags?.length>0&&(0,A.jsx)("div",{className:"flex gap-1",children:e.tags.slice(0,3).map(e=>(0,A.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-gray-100 dark:bg-white/[0.05] text-gray-500 dark:text-white/40",children:e},e))})]})]})]})},e.id)})]},e))})}var e6=e.i(961181),e8=e.i(133820),e9=e.i(842291);function e7(){let{currentCustomerId:e,currentCustomerName:t,isSuperUser:a}=(0,e8.useCustomer)(),{data:r}=(0,P.useSession)(),s=r?._originalCustomerId,i=!!s&&s!==r?.user?.customerId;if(!a||!i)return null;let n=async()=>{try{await fetch("/api/admin/switch-workspace",{method:"DELETE",credentials:"include"}),window.location.reload()}catch{}};return(0,A.jsxs)("div",{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-lg bg-orange-500/10 border border-orange-500/20",children:[(0,A.jsx)("span",{className:"text-xs font-medium text-orange-400 truncate max-w-[120px]",children:t||`#${e}`}),(0,A.jsx)("button",{onClick:n,className:"p-0.5 rounded hover:bg-orange-500/20 transition-colors",title:"Exit workspace",children:(0,A.jsx)(ei.X,{className:"w-3 h-3 text-orange-400/60"})})]})}function te({hasReleaseBanner:e,hasOutageBanner:t,hasVerificationBanner:
66a,hasPaymentBanner:r}){let s=36*!!e+40*!!t+40*!!a+36*!!r;return R.useEffect(()=>(document.documentElement.style.setProperty("--banner-offset",`${s}px`),()=>{document.documentElement.style.removeProperty("--banner-offset")}),[s]),null}function tt(){let{activeProduct:e,productConfig:t,products:a,hasMultipleProducts:r,switchProduct:s}=(0,eO.useProductSafe)(),{currentCustomerName:i,currentCustomerId:n,isSuperUser:l}=(0,e8.useCustomer)(),[o,d]=R.useState(!1),[c,m]=R.useState([]),[u,h]=R.useState(!1),[x,g]=R.useState(!1),[p,b]=R.useState(""),[f,y]=R.useState(!1),w=(0,eB.filterBrandVisibleProducts)(a.filter(e=>"active"===e.status));R.useEffect(()=>{!o||c.length>0||(h(!0),fetch("/api/user/workspaces",{credentials:"include"}).then(e=>e.ok?e.json():null).then(e=>{e?.workspaces&&m(e.workspaces)}).catch(()=>{}).finally(()=>h(!1)))},[o,c.length]);let v=async e=>{d(!1);try{(await fetch("/api/user/workspaces/switch",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({customerId:e})})).ok||await fetch("/api/admin/switch-workspace",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({customerId:e})}),window.location.reload()}catch{}},k=async()=>{if(p.trim()&&!(p.trim().length<2)){g(!0);try{(await fetch("/api/user/workspaces/create",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:p.trim()})})).ok&&(window.location.href="/onboarding")}catch{}g(!1)}};return(0,A.jsxs)("div",{className:"relative",children:[(0,A.jsxs)("button",{onClick:()=>d(!o),className:(0,ew.cn)("flex items-center gap-2 px-2 py-1 rounded-lg transition-colors","hover:bg-gray-100 dark:hover:bg-white/[0.05] cursor-pointer",o&&"bg-gray-100 dark:bg-white/[0.05]"),children:[(0,A.jsx)("span",{className:(0,ew.cn)("text-sm font-semibold","text-gray-900 dark:text-white"),children:t.shortName}),i&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("span",{className:"text-gray-300 dark:text-white/20",children:"/"}),(0,A.jsx)("span",{className:(0,ew.cn)("text-sm text-gray-500 dark:text-white/50 max-w-[120px] truncate"),children:i})]}),(0,A.jsx)(ec.ChevronDown,{className:(0,ew.cn)("w-3.5 h-3.5 text-gray-400 dark:text-white/30 transition-transform",o&&"rotate-180")})]}),o&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("div",{className:"fixed inset-0 z-40",onClick:()=>d(!1)}),(0,A.jsxs)("div",{className:(0,ew.cn)("absolute top-full left-0 mt-1.5 z-50 w-72 rounded-xl shadow-xl overflow-hidden","bg-white dark:bg-[#2C2C2E] border border-gray-200 dark:border-white/[0.1]"),children:[w.length>0&&(0,A.jsxs)("div",{className:"p-1.5",children:[(0,A.jsx)("div",{className:"px-2 py-1.5",children:(0,A.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-gray-500 dark:text-white/30",children:"Products"})}),w.map(t=>{let a=eU.PRODUCT_REGISTRY[t.productId];if(!a)return null;let r=t.productId===e;return(0,A.jsxs)("button",{onClick:()=>{var e;let a,r,i,n;return e=t.productId,d(!1),a=window.location.port?`:${window.location.port}`:"",r=window.location.hostname.endsWith(".localhost"),void((n=(i=eU.PRODUCT_REGISTRY[e])?r?`http://${"vanio_ai"===e?"app":"atlas"===e?"atlas":"fantasticstay"===e?"fs":e}.localhost${a}`:i.appDomain?`https://${i.appDomain}`:null:null)?window.location.href=n:s(e))},className:(0,ew.cn)("w-full flex items-center gap-3 px-2.5 py-2.5 rounded-lg text-sm text-left transition-colors",r?"bg-gray-100 dark:bg-white/[0.08]":"hover:bg-gray-50 dark:hover:bg-white/[0.04]"),children:[(0,A.jsx)("div",{className:"w-8 h-8 rounded-lg overflow-hidden shrink-0 shadow-sm ring-1 ring-gray-200/50 dark:ring-white/[0.06]",children:(0,A.jsx)(X.default,{src:a.logo,alt:"",width:32,height:32,className:"object-cover w-full h-full"})}),(0,A.jsx)("div",{className:"flex-1 min-w-0",children:(0,A.jsx)("span",{className:(0,ew.cn)("font-medium",r?"text-gray-900 dark:text-white":"text-gray-600 dark:text-white/70"),children:a.name})}),r&&(0,A.jsx)(em.Check,{className:"w-4 h-4 text-gray-400 dark:text-white/40 shrink-0"})]},t.productId)})]}),(l||c.length>1||u)&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("div",{className:"h-px bg-gray-100 dark:bg-white/[0.06]"}),(0,A.jsxs)("div",{className:"p-1.5 max-h-48 overflow-y-auto",children:[(0,A.jsx)("div",{className:"px-2 py-1.5",children:(0,A.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-gray-500 dark:text-white/30",children:"Worksp
66aces"})}),u&&0===c.length&&(0,A.jsx)(A.Fragment,{children:[1,2,3].map(e=>(0,A.jsxs)("div",{className:"flex items-center gap-2.5 px-2.5 py-2",children:[(0,A.jsx)("div",{className:"w-5 h-5 rounded bg-gray-200 dark:bg-white/[0.08] animate-pulse"}),(0,A.jsx)("div",{className:"h-3.5 rounded bg-gray-200 dark:bg-white/[0.08] animate-pulse",style:{width:`${50+20*e}px`}})]},e))}),c.map(e=>{let t=e.id===n;return(0,A.jsxs)("button",{onClick:()=>v(e.id),className:(0,ew.cn)("w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-sm text-left transition-colors",t?"bg-gray-100 dark:bg-white/[0.08]":"hover:bg-gray-50 dark:hover:bg-white/[0.04]"),children:[(0,A.jsx)("div",{className:(0,ew.cn)("w-5 h-5 rounded flex items-center justify-center text-[10px] font-bold shrink-0",t?"bg-gray-200 dark:bg-white/[0.12] text-gray-700 dark:text-white":"bg-gray-100 dark:bg-white/[0.06] text-gray-600 dark:text-white/50"),children:e.name?.[0]?.toUpperCase()||"?"}),(0,A.jsx)("span",{className:(0,ew.cn)("truncate",t?"font-medium text-gray-900 dark:text-white":"text-gray-600 dark:text-white/70"),children:e.name}),t&&(0,A.jsx)(em.Check,{className:"w-4 h-4 text-gray-400 dark:text-white/40 shrink-0 ml-auto"})]},e.id)})]})]}),(0,A.jsx)("div",{className:"h-px bg-gray-100 dark:bg-white/[0.06]"}),(0,A.jsx)("div",{className:"p-1.5",children:f?(0,A.jsxs)("div",{className:"flex items-center gap-1.5 px-1",children:[(0,A.jsx)("input",{autoFocus:!0,t
66ype:"text",value:p,onChange:e=>b(e.target.value),onKeyDown:e=>{"Enter"===e.key&&k(),"Escape"===e.key&&(y(!1),b(""))},placeholder:"Workspace name",className:(0,ew.cn)("flex-1 text-sm px-2.5 py-1.5 rounded-lg outline-none","bg-gray-100 dark:bg-white/[0.06] text-gray-900 dark:text-white","placeholder:text-gray-500 dark:placeholder:text-white/30","border border-transparent focus:border-gray-300 dark:focus:border-white/[0.15]")}),(0,A.jsx)("button",{onClick:k,disabled:x||p.trim().length<2,className:(0,ew.cn)("p-1.5 rounded-lg transition-colors shrink-0","bg-gray-900 dark:bg-white text-white dark:text-gray-900","hover:bg-gray-800 dark:hover:bg-white/90","disabled:opacity-40 disabled:cursor-not-allowed"),children:x?(0,A.jsx)(eu.Loader2,{className:"w-3.5 h-3.5 animate-spin"}):(0,A.jsx)(eh.ArrowRight,{className:"w-3.5 h-3.5"})})]}):(0,A.jsxs)("button",{onClick:()=>y(!0),className:(0,ew.cn)("w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-sm text-left transition-colors","text-gray-600 dark:text-white/50 hover:bg-gray-50 dark:hover:bg-white/[0.04]"),children:[(0,A.jsx)(ea.Plus,{className:"w-4 h-4"}),(0,A.jsx)("span",{children:"New Workspace"})]})})]})]})]})}e.s(["Header",0,function({onTabChange:e}){let{data:t,status:a}=(0,P.useSession)(),r=(0,q.usePathname)(),s=(0,e8.useCustomer)(),{productConfig:i,productNavKeys:n,isDomainLocked:l}=(0,eO.useProductSafe)();R.useRef(null);let{isOpen:o,openCommandPalette:d,closeCommandPalette:c,setCommandPaletteContext:m}=(0,ev.useCommandPalette)(),u=(0,eb.useSettingsStore)(e=>e.openSettings),{isDropdownOpen:h,openDropdown:x,closeDropdown:g,isSidebarOpen:p,openSidebar:b,closeSidebar:f}=(0,ek.useNotificationStore)(),{getUnreadCount:y,notificationApiOutage:w}
66=(0,ej.useActivity)(),v=y(),[k,j]=R.useState(!1),[N,C]=R.useState(!1),[S,E]=R.useState(!1),{resolvedTheme:I}=(0,D.useTheme)(),[T,_]=R.useState(0),[M,F]=R.useState(null),[L,$]=R.useState(!0),[O,U]=R.useState(!1),{subscription:B}=(0,e9.useSubscription)();(0,q.useSearchParams)();let{settings:z}=(0,ef.useUserSettings)(),H=(0,eq.useTranslations)(),V=(0,eF.useNavigationConfig)(),G=(0,e6.useSetupProgress)(),W=R.useCallback(e=>{$(!0),localStorage.setItem("vanio_dismissed_release_id",String(e)),fetch("https://api.vanio.ai/user/seen",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({feature:"release",referenceId:String(e)})}).catch(()=>{})},[]);R.useEffect(()=>{if("authenticated"!==a)return;let e="https://api.vanio.ai",t=()=>{fetch(`${e}/changelog`,{credentials:"include"}).then(e=>e.ok?e.json():null).then(e=>{e?.unseenCount!=null&&_(e.unseenCount)}).catch(()=>{}),Promise.all([fetch(`${e}/releases?limit=1`).then(e=>e.ok?e.json():null),fetch(`${e}/user/seen`,{credentials:"include"}).then(e=>e.ok?e.json():null)]).then(([e,t])=>{let a=e?.releases?.[0];if(a&&"published"===a.status){F({id:a.id,version:a.version,title:a.title,tagline:a.tagline,slug:a.slug});let e=t?.release?.referenceId?parseInt(t.release.referenceId,10):null,r=localStorage.getItem("vanio_dismissed_release_id");$(null!=e&&e>=a.id||r===String(a.id))}}).catch(()=>{}),fetch(`${e}/invest/check`,{credentials:"include"}).then(e=>e.ok?e.json():null).then(e=>{e?.isInvestor&&U(!0)}).catch(()=>{})},r="u">typeof requestIdleCallback?requestIdleCallback(t):setTimeout(t,3e3),s="u">typeof requestIdleCallback?()=>cancelIdleCallback(r):()=>clearTimeout(r),i=()=>{_(0),F(e=>(e&&W(e.id),e))};window.addEventListener("changelog:seen",i);let n=()=>C(!0);return window.addEventListener("changelog:open",n),()=>{s(),window.removeEventListener("changelog:seen",i),window.removeEventListener("changelog:open",n)}},[a]);
66let[,K]=R.useState(0);R.useEffect(()=>{let e=()=>{K(e=>e+1)};return window.addEventListener("languageChanged",e),()=>{window.removeEventListener("languageChanged",e)}},[]);let Y=t?.user?.customerId===1,ec=(0,R.useMemo)(()=>{if(!z)return[];let e=Object.entries(V);if(z.isSuperUser)return e.filter(([e,t])=>"/tasks/dashboard"!==t.href&&("/superadmin"===t.href||0!==t.roles.length&&("arbCalendar"!==e||!!Y)&&(!l||!(n.length>0)||!!n.includes(e)))).map(([,e])=>e);if("listing_owner"===z.currentRole){let t=!0===z.reportsAccess;return e.filter(([,e])=>"/calendar"===e.href||t&&"/reports"===e.href).filter(([,e])=>e.roles.includes("listing_owner")).map(([,e])=>e)}if((0,eL.isOperationsStaffRole)(z))return(0,eF.filterStaffNav)(e.map(([,e])=>e),z.currentRole,{reports:(0,eL.canSeeReports)(z.roles.map(e=>e.role),!0===z.reportsAccess)});let t=z.currentRole?[z.currentRole]:z.roles.map(e=>e.role);return e.filter(([e,a])=>"/superadmin"!==a.href&&("arbCalendar"!==e||!!Y)&&(!(n.length>0)||!!n.includes(e))&&("/reports"===a.href?(0,eL.canSeeReports)(t,!0===z.reportsAccess):a.roles.some(e=>t.includes(e)))).map(([,e])=>e)},[z,V,n,l,Y]),em=(0,eL.isOperationsStaffRole)(z),eu="workspaceType"in s&&"service_provider"===s.workspaceType,eh=(0,eF.filterServiceProviderNav)(ec,{isServiceProviderWorkspace:eu&&!z?.isSuperUser,isSpStaff:em}),eN=s.personaTierKey,eC=eN&&!z?.isSuperUser?eh.filter(e=>!e.hideForPersonas?.includes(eN)):eh,eS=z?.uiPreferences?.navigation,eE=(0,R.useMemo)(()=>(0,eg.applyNavPreference)(eC,eS),[eC,eS]),eI=(0,eM.useCanUseCommandPalette)();R.useEffect(()=>{let e=e=>{eI&&(e.metaKey||e.ctrlKey)&&"k"===e.key&&(e.preventDefault(),m({topic:"search",placeholder:"vanio_ai"!==i.id?`Search ${i.shortName}...`:H.header.search.tip,context:"global"}),d())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[d,m,eI,i,H.header.search.tip]),R.useEffect(()=>{let e=e=>{!eI||"c"!==e.key.toLowerCase()||e.metaKey||e.ctrlKey||e.altKey||(0,J.shouldSkipShortcut)(e)||(e.preventDefault(),o?c():(m({topic:"create",placeholder:"Create new"}),d()))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[o,d,c,m,eI]),R.useEffect(()=>{let e=e=>{!eI||"i"!==e.key.toLowerCase()||e.metaKey||e.ctrlKey||e.altKey||(0,J.shouldSkipShortcut)(e)||(e.preventDefault(),p?f():b())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[p,b,f,eI]),R.useEffect(()=>{h||j(!1)},[h]);let[eT,{width:e_}]=function(){let[e,t]=R.useState({width:0,height:0}),a=R.useRef(null),r=R.useCallback(()=>{a.current&&setTimeout(()=>{let e=a.current?.getBoundingClientRect().width||0;t(t=>t.width!==e?{width:e,height:a.current?.offsetHeight||0}:t)},0)},[]);return R.useEffect(()=>{r();let e=new ResizeObserver(()=>{window.requestAnimationFrame(r)});return a.current&&e.observe(a.current),window.addEventListener("load",r),window.addEventListener("resize",r),()=>{e.disconnect(),window.removeEventListener("load",r),window.removeEventListener("resize",r)}},[r]),[a,e]}();R.useEffect(()=>{if(eC.length>0){let e=setTimeout(()=>{window.dispatchEvent(new Event("resize"))},100);return()=>clearTimeout(e)}},[eC]);let{visibleItems:eA,overflowItems:eD}=R.useMemo(()=>{if(!eC.length)return{visibleItems:[],overflowItems:[]};if(!e_)return{visibleItems:eC,overflowItems:[]};let e=e_-40;if(Math.floor(e/74)>=eC.length)return{visibleItems:eC,overflowItems:[]};let t=Math.floor((e-28-4)/74);return{visibleItems:eC.slice(0,t),overflowItems:eC.slice(t)}},[eC,e_]);if("authenticated"!==a||!t)return null;let eP=z&&!z.emailVerified;return(0,A.jsxs)(A.Fragment,{children:[w&&(0,A.jsx)("div",{className:"fixed top-0 left-0 right-0 z-[100] bg-green-900/90 text-green-100 py-2.5 px-4 text-center shadow-md border-b border-green-800 animate-fade-in",role:"alert","aria-live":"polite",children:(0,A.jsxs)("div",{className:"container mx-auto flex flex-col sm:flex-row items-center justify-center gap-2 text-sm",children:[(0,A.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,A.jsxs)("svg",{className:"w-4 h-4 text-green-300 flex-shrink-0",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[(0,A.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none"}
66),(0,A.jsx)("circle",{cx:"12",cy:"12",r:"4",fill:"currentColor"})]}),"Our Infrastructure provider is experiencing technical issues."]}),(0,A.jsx)("span",{className:"hidden sm:inline mx-2 text-green-300",children:"|"}),(0,A.jsx)("a",{href:"https://status.supabase.com",target:"_blank",rel:"noopener noreferrer",className:"underline text-green-200 hover:text-green-100 transition-colors py-1",children:"Follow status.supabase.com for updates"})]})}),eP&&(0,A.jsx)("div",{className:(0,ew.cn)("fixed left-0 right-0 z-50 bg-amber-500 text-black py-2.5 px-4 text-center shadow-md",w?"top-10":"top-0"),role:"alert","aria-live":"polite",children:(0,A.jsxs)("div",{className:"container flex flex-wrap items-center justify-center gap-2 text-sm font-medium",children:[(0,A.jsx)(es.AlertTriangle,{className:"h-4 w-4 flex-shrink-0"}),(0,A.jsx)("span",{children:eP?H.header.verification.emailNeeded:H.header.verification.phoneNeeded}),(0,A.jsx)(Q.default,{href:"/settings/profile",className:"underline font-semibold hover:text-amber-800 transition-colors focus:outline-none focus:ring-2 focus:ring-amber-800 focus:ring-offset-1 rounded px-1",children:H.header.verification.action})]})}),M&&!L&&!eP&&"vanio_ai"===i.id&&(0,A.jsx)("div",{className:(0,ew.cn)("fixed left-0 right-0 z-50 bg-gradient-to-r from-indigo-600 to-violet-600 text-white py-2 px-4 text-center shadow-md",w?"top-10":"top-0"),children:(0,A.jsxs)("div",{className:"container flex items-center justify-center gap-3 text-sm",children:[(0,A.jsx)(en.Rocket,{className:"w-4 h-4 shrink-0"}),(0,A.jsxs)("span",{className:"font-semibold",children:[H.header.releaseBanner.newVersion," v",M.version]}),(0,A.jsx)("span",{className:"hidden sm:inline text-white/70",children:"â"}),(0,A.jsx)("span",{className:"hidden sm:inline text-white/80",children:M.title}),(0,A.jsxs)("a",{href:`https://www.vanio.ai/releases/${M.slug}`,target:"_blank",rel:"noopener noreferrer",onClick:()=>W(M.id),className:"ml-2 px-3 py-0.5 rounded-full bg-white/20 hover:bg-white/30 text-xs font-medium transition-colors",children:[H.header.releaseBanner.seeWhatsNew," â"]}),(0,A.jsx)("button",{onClick:()=>W(M.id),className:"absolute right-4 top-1/2 -translate-y-1/2 p-1 hover:bg-white/10 rounded transition-colors","aria-label":"Dismiss",children:(0,A.jsx)(ei.X,{className:"w-3.5 h-3.5"})})]})}),B?.hasFailedPayment&&(0,A.jsx)("div",{className:(0,ew.cn)("fixed left-0 right-0 z-50 bg-gradient-to-r from-red-600 to-red-700 text-white py-2 px-4 text-center shadow-md","top-0"),style:{top:40*!!w+(M&&!L?36:0)+40*!!eP},children:(0,A.jsxs)("div",{className:"container flex items-center justify-center gap-3 text-sm",children:[(0,A.jsxs)("span",{className:"font-semibold",children:["Payment of $",B.failedAmount?.toLocaleString("en-US",{minimumFractionDigits:2})," failed"]}),(0,A.jsx)("span",{className:"text-white/70",children:"â"}),(0,A.jsx)("span",{className:"text-white/80",children:"Your bank declined the charge"}),(0,A.jsx)("a",{href:"/settings/billing",className:"ml-2 px-3 py-0.5 rounded-full bg-white/20 hover:bg-white/30 text-xs font-medium transition-colors",children:"Resolve â"})]})}),(0,A.jsx)("header",{className:(0,ew.cn)("hidden md:block md:fixed left-0 right-0 z-40 w-full shrink-0","bg-white/80 dark:bg-[#1D1D1F]/80 backdrop-blur-xl","transition-all duration-200","border-b border-gray-200 dark:border-white/[0.08]",w&&eP?"top-20":w||eP?"top-10":M&&!L&&B?.hasFailedPayment?"top-[72px]":M&&!L||B?.hasFailedPayment?"top-9":"top-0"),children:(0,A.jsxs)("div",{className:"flex",children:["vanio_ai"!==i.id?(0,A.jsx)(Q.default,{href:i.defaultRoute,className:"shrink-0 flex items-center justify-center py-2",style:{width:"128px"},children:(0,A.jsx)("div",{className:"w-[88px] h-[88px] relative overflow-hidden rounded-2xl shadow-lg ring-1 ring-white/10",children:(0,A.jsx)(X.default,{src:i.logo,alt:i.name,className:"object-cover",fill:!0,sizes:"64px",priority:!0})})}):null,(0,A.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,A.jsx)("div",{className:(0,ew.cn)("h-14","vanio_ai"!==i.id?"pl-0 pr-4":"px-4"),children:(0,A.jsxs)("div",{className:"flex items-center justify-between h-full mx-auto",children:[(0,A.jsxs)("div",{className:"flex items-center gap-4 flex-1 min-w-0",children:["vanio_ai"===i.id&&(0,A.jsx)(Q.default,{href:i.defaultRoute,className:"relative shrink-0",children:(0,A.jsx)("div",{className:"w-10 h-10 relative overflow-hidden rounded-lg",children:(0,A.jsx)(X.default,{src:i.logo,alt:i.name,className:"object-cover",fill:!0,sizes:"40px",priority:!0})})}),(0,A.jsx)(tt,{}),O&&(0,A.jsxs)("div",{className:"relative group",title:"Vanio AI Investor",children:[(0,A.jsx)(el.Gem,{className:"w-4 h-4 text-violet-400"}),(0,A.jsx)("div",{className:"absolute -bottom-8 left-1/2 -translate-x-1/2 hidden group-hover:block whitespace-nowrap px-2 py-1 rounded-md bg-gray-900 dark:bg-white text-white dark:text-gray-900 text-[10px] font-medium shadow-lg z-50",children:"Investor"})]}),(0,A.jsx)(e7,{}),eI&&(0,e$.showsWorkspaceChrome)(z)&&(0,A.jsx)("div",{className:"min-w-0 flex-1 max-w-[16rem] transition-all duration-200",children:(0,A.jsx)("div",{className:"relative group",children:(0,A.jsxs)("button",{"data-testid":"header-search","aria-label":"vanio_ai"!==i.id?`Search ${i.shortName}...`:H.header.search.placeholder,onClick:e=>{m({topic:"search",placeholder:"vanio_ai"!==i.id?`Search ${i.shortName}...`:H.header.search.tip,context:"global"}),d()},className:(0,ew.cn)("w-full h-8 bg-gray-200/60 dark:bg-white/10 rounded-full px-4 pl-10","text-sm text-gray-600 dark:text-white/70 text-left","truncate","hover:bg-gray-200 dark:hover:bg-white/[0.15] focus:bg-gray-200 dark:focus:bg-white/[0.15]","transition-all duration-200"),children:[(0,A.jsx)(Z.Search,{className:"w-4 h-4 text-gray-600 dark:text-white/70 absolute left-3 top-2"}),"vanio_ai"!==i.id?`Search ${i.shortName}...`:H.header.search.placeholder,(0,A.jsxs)("div",{className:(0,ew.cn)("absolute right-3 top-1.5 hidden lg:flex items-center gap-1","text-gray-500 dark:text-white/40","pointer-events-none select-none"),children:[(0,A.jsx)("div",{className:(0,ew.cn)("flex items-center justify-center","min-w-[22px] h-[20px] px-1","rounded border border-gray-300 dark:border-white/40","bg-white dark:bg-[#1D1D1F]"),children:(0,A.jsx)(er.Command,{className:"w-3.5 h-3.5 text-gray-900 dark:text-white"})}),(0,A.jsx)("div",{className:(0,ew.cn)("flex items-center justify-center","min-w-[22px] h-[20px] px-1","rounded border border-gray-300 dark:border-white/40","bg-white dark:bg-[#1D1D1F]"),children:(0,A.jsx)("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:H.header.search.shortcutLabel})})]})]})})})]}),(0,A.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,e$.showsWorkspaceChrome)(z)&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("button",{"data-header-help":!0,className:"hidden lg:block px-3 py-1.5 text-gray-500 dark:text-white/50 hover:text-gray-900 dark:hover:text-white transition-colors text-sm",onClick:()=>window.dispatchEvent(new CustomEvent("vanio-chat:open")),children:H.header.topNav.help}),(0,A.jsxs)(Q.default,{href:"/feedback","data-header-feedback":!0,"aria-label":"Feedback",className:"px-3 py-1.5 text-gray-500 dark:text-white/50 hover:text-gray-900 dark:hover:text-white transition-colors text-sm flex items-center gap-1.5",children:[(0,A.jsx)(ed.MessageSquarePlus,{className:"w-4 h-4"}),(0,A.jsx)("span",{className:"hidden lg:inline",children:"Feedback"})]}),(0,A.jsxs)("button",{"data-changelog-trigger":!0,"aria-label":H.header.topNav.changelog,className:"relative px-3 py-1.5 text-gray-500 dark:text-white/50 hover:text-gray-900 dark:hover:text-white transition-colors text-sm flex items-center gap-1.5",onClick:()=>C(!0),children:[(0,A.jsx)(eo.Megaphone,{className:"w-4 h-4"}),(0,A.jsx)("span",{className:"hidden lg:inline",children:H.header.topNav.changelog}),T>0&&(0,A.jsx)("span",{className:(0,ew.cn)("min-w-[18px] h-[18px]","flex items-center justify-center","text-[10px] font-semibold","bg-indigo-500 text-white","rounded-full px-1"),children:T>99?"99+":T})]}),G.isVisible&&(0,A.jsxs)(Q.default,{href:"/setup","data-header-setup":!0,className:"relative group flex items-center gap-1.5 px-2 py-1 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.05] transition-colors",title:`Setup: ${G.completedCount} of ${G.totalCount} complete`,children:[(0,A.jsxs)("svg",{className:"w-5 h-5 -rotate-90",viewBox:"0 0 36 36",children:[(0,A.jsx)("circle",{cx:"18",cy:"18",r:"15",fill:"none",className:"stroke-gray-200 dark:stroke-white/[0.12]",strokeWidth:"3"}),(0,A.jsx)("circle",{cx:"18",cy:"18",r:"15",fill:"none",className:"stroke-blue-500",strokeWidth:"3",strokeDasharray:`${G.progressPct} ${100-G.progressPct}`,strokeLinecap:"round"})]}),(0,A.jsx)("span",{className:"absolute left-2 top-1 w-5 h-5 flex items-center justify-center text-[8px] font-bold text-gray-600 dark:text-white/60",children:G.completedCount}),(0,A.jsx)("span",{className:"hidden lg:inline text-xs text-gray-500 dark:text-white/40 group-hover:text-gray-700 dark:group-hover:text-white/60 transition-colors",children:"Setup"})]})]}),(0,A.jsx)("div",{className:"w-px h-6 bg-gray-200 dark:bg-white/[0.08] mx-2"}),eI&&(0,A.jsxs)("button",{type:"button","data-testid":"header-create-new","aria-label":H.header.actions.create.label,className:"p-2 rounded-full hover:bg-gray-100 dark:hover:bg-white/10 transition-colors group relative",onClick:()=>{o?c():(m({topic:"create",type:"direct",placeholder:H.header.actions.create.label,context:"global"}),d())},children:[(0,A.jsx)(ea.Plus,{className:"w-5 h-5 text-gray-600 dark:text-white/70"}),(0,A.jsx)("div",{className:(0,ew.cn)("absolute -bottom-8 left-1/2 -translate-x-1/2","px-2 py-1 rounded bg-white dark:bg-[#1D1D1F]","text-xs text-gray-500 dark:text-white/40","border border-gray-200 dark:border-white/[0.08]","opacity-0 group-hover:opacity-100 transition-opacity","pointer-events-none"),children:H.header.actions.create.shortcutLabel})]}),(0,A.jsxs)("div",{className:"relative group",children:[(0,A.jsxs)("button",{onClick:()=>{p?f():h?(g(),j(!1)):(x(),j(!0))},className:(0,ew.cn)("w-8 h-8 rounded-full","flex items-center justify-center","hover:bg-gray-100 dark:hover:bg-white/[0.05]","transition-colors","relative"),children:[(0,A.jsx)(ee.Bell,{className:"w-5 h-5 text-gray-600 dark:text-white/70"}),v>0&&(0,A.jsx)("span",{className:(0,ew.cn)("absolute -top-1 -right-1","min-w-[18px] h-[18px]","flex items-center justify-center","text-xs font-medium","bg-red-500 text-gray-900 dark:text-white","rounded-full px-1"),children:v>99?H.header.actions.notifications.overflowLabel:v})]}),h&&(0,A.jsx)(eR,{onClose:()=>{g(),j(!1)},openSidebar:()=>{g(),j(!1),b()}})]}),(0,A.jsx)("button",{className:"p-2 rounded-full hover:bg-gray-100 dark:hover:bg-white/10 transition-colors",onClick:()=>u(),children:(0,A.jsx)(et.Settings,{className:"w-5 h-5 text-gray-600 dark:text-white/70"})}),(0,A.jsx)(ey,{})]})]})}),(0,A.jsx)("div",{className:(0,ew.cn)("h-12 border-t border-gray-200 dark:border-white/[0.08]","vanio_ai"!==i.id?"pl-0 pr-4":"px-4"),children:(0,A.jsx)("div",{className:"flex items-center h-full mx-auto",children:(0,A.jsxs)("nav",{className:"flex items-center space-x-1",children:[eC.length>0&&(0,A.jsx)("button",{type:"button",onClick:()=>E(!0),"aria-label":"Customize menu",title:"Customize menu",className:"flex items-center justify-center w-8 h-8 rounded-full text-gray-500 dark:text-white/50 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-white/[0.05] transition-colors",children:(0,A.jsx)(ex.SlidersHorizontal,{className:"w-4 h-4"})}),eE.map(e=>{let t="/"===e.href?r===e.href:r===e.href||r?.startsWith(e.href+"/"),a=e.icon;return(0,A.jsxs)(Q.default,{href:e.href,className:(0,ew.cn)("flex items-center space-x-2 px-3 py-1.5 rounded-full","text-sm font-medium transition-colors whitespace-nowrap",t?"bg-gray-200/60 dark:bg-white/10 text-gray-900 dark:text-white":"text-gray-600 dark:text-white/70 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-white/[0.05]"),children:[(0,A.jsx)(a,{className:"w-4 h-4"}),(0,A.jsx)("span",{children:e.name})]},e.href)})]})})})]})]})}),(0,A.jsx)(te,{hasReleaseBanner:!!(M&&!L&&!eP),hasOutageBanner:!!w,hasVerificationBanner:!!eP,hasPaymentBanner:!!B?.hasFailedPayment}),(0,A.jsx)("div",{className:(0,ew.cn)("mt-0 md:mt-[60px]",w&&eP?"md:mt-[120px]":w||eP?"md:mt-[100px]":!M||L||eP?"":"md:mt-[96px]")}),(0,A.jsx)(e2,{open:N,onOpenChange:C}),(0,A.jsx)(ep.NavCustomizeDialog,{open:S,onOpenChange:E,items:eC,preference:eS,isDark:"light"!==I})]})}
66],703467),e.s(["Footer",0,function(){let{productConfig:e}=(0,eO.useProductSafe)();return"atlas"===e.id?null:(0,A.jsx)("footer",{className:"w-full py-3 bg-gray-100 dark:bg-[#0c0c0c] border-t border-gray-200 dark:border-[#282829]",children:(0,A.jsxs)("div",{className:"max-w-[980px] mx-auto px-4 flex flex-col md:flex-row justify-between items-center gap-2 text-[12px]",children:[(0,A.jsxs)("div",{className:"flex flex-wrap justify-center md:justify-start items-center gap-x-6 text-gray-500 dark:text-[#6e6e73]",children:[(0,A.jsxs)("a",{href:"https://status.vanio.ai",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 hover:text-gray-600 dark:hover:text-[#8e8e93] transition-colors",children:[(0,A.jsx)("img",{src:"https://uptime.betterstack.com/status-badges/v3/monitor/vanio.svg",alt:"Vanio AI status",className:"h-[14px]",loading:"lazy"}),(0,A.jsx)("span",{children:"System Status"})]}),(0,A.jsx)(Q.default,{href:"/system",className:"hover:text-gray-600 dark:hover:text-[#8e8e93] transition-colors",children:"Internal Health"}),(0,A.jsx)("button",{className:"hover:text-gray-600 dark:hover:text-[#8e8e93] transition-colors",children:"Privacy Policy"}),(0,A.jsx)("button",{className:"hover:text-gray-600 dark:hover:text-[#8e8e93] transition-colors",children:"Terms & Conditions"})]}),(0,A.jsxs)("div",{className:"text-gray-500 dark:text-[#6e6e73]",children:["Copyright © ",new Date().getFullYear()," Vanio.AI. All rights reserved."]})]})})}],685343),e.s(["KeyboardShortcuts",0,function(){let{settings:e,updateUIPreference:t}=(0,ef.useUserSettings)(),a=(0,eM.useCanUseCommandPalette)(),r=(0,e$.showsWorkspaceChrome)(e),[s,i]=(0,R.useState)(!0);(0,R.useEffect)(()=>{e?.uiPreferences?.desktop?.hideKeyboardShortcuts&&i(!1)},[e?.uiPreferences?.desktop?.hideKeyboardShortcuts]);let n=(0,R.useCallback)(()=>{t("hideKeyboardShortcuts",!0,"desktop").catch(e=>{console.error("Failed to save keyboard shortcuts preference:",e)}),i(!1)},[t]);return a&&r&&s?(0,A.jsx)("div",{className:(0,ew.cn)("hidden lg:block","w-full py-3","bg-white/80 dark:bg-[#1D1D1F]/80 backdrop-blur-xl","border-t border-gray-200 dark:border-white/[0.08]","transition-all duration-200"),children:(0,A.jsxs)("div",{className:"max-w-[980px] mx-auto px-4 relative",children:[(0,A.jsxs)("div",{className:(0,ew.cn)("flex items-center justify-center gap-4","text-xs text-gray-500 dark:text-[#6e6e73]"),children:[(0,A.jsxs)("div",{className:"flex items-center gap-1",children:["Hit",(0,A.jsx)("div",{className:(0,ew.cn)("flex items-center justify-center","min-w-[22px] h-[20px] px-1","rounded border border-gray-200 dark:border-white/[0.08] bg-gray-100 dark:bg-white/[0.05]","hover:bg-gray-100 dark:hover:bg-white/10"),children:(0,A.jsx)("span",{className:"text-sm font-medium text-gray-600 dark:text-white/70",children:"E"})}),(0,A.jsx)("span",{children:"to Mark Done"})]}),(0,A.jsxs)("div",{className:"flex items-center gap-1",children:[(0,A.jsx)("div",{className:(0,ew.cn)("flex items-center justify-center","min-w-[22px] h-[20px] px-1","rounded border border-gray-200 dark:border-white/[0.08] bg-gray-100 dark:bg-white/[0.05]","hover:bg-gray-100 dark:hover:bg-white/10"),children:(0,A.jsx)("span",{className:"text-sm font-medium text-gray-600 dark:text-white/70",children:"H"})}),(0,A.jsx)("span",{children:"to set a reminder"})]}),(0,A.jsxs)("div",{className:"flex items-center gap-1",children:[(0,A.jsx)("div",{className:(0,ew.cn)("flex items-center justify-center","min-w-[22px] h-[20px] px-1","rounded border border-gray-200 dark:border-white/[0.08] bg-gray-100 dark:bg-white/[0.05]","hover:bg-gray-100 dark:hover:bg-white/10"),children:(0,A.jsx)("span",{className:"text-sm font-medium text-gray-600 dark:text-white/70",children:"C"})}),(0,A.jsx)("span",{children:"for New"})]}),(0,A.jsxs)("div",{className:"flex items-center gap-1",children:[(0,A.jsx)("div",{className:(0,ew.cn)("flex items-center justify-center","min-w-[22px] h-[20px] px-1","rounded border border-gray-200 dark:border-white/[0.08] bg-gray-100 dark:bg-white/[0.05]","hover:bg-gray-100 dark:hover:bg-white/10"),children:(0,A.jsx)("span",{className:"text-xs font-medium text-gray-600 dark:text-white/70",children:"i"})}),(0,A.jsx)("span",{children:"for Notifications"})]}),(0,A.jsxs)("div",{className:"flex items-center gap-1",children:[(0,A.jsxs)("div",{className:"flex items-center gap-1",children:[(0,A.jsx)("div",{className:(0,ew.cn)("flex items-center justify-center","min-w-[22px] h-[20px] px-1","rounded border border-gray-200 dark:border-white/[0.08] bg-gray-100 dark:bg-white/[0.05]","hover:bg-gray-100 dark:hover:bg-white/10"),children:(0,A.jsx)(er.Command,{className:"w-3.5 h-3.5 text-gray-600 dark:text-white/70"})}),(0,A.jsx)("div",{className:(0,ew.cn)("flex items-center justify-center","min-w-[22px] h-[20px] px-1","rounded border border-gray-200 dark:border-white/[0.08] bg-gray-100 dark:bg-white/[0.05]","hover:bg-gray-100 dark:hover:bg-white/10"),children:(0,A.jsx)("span",{className:"text-sm font-medium text-gray-600 dark:text-white/70",children:"K"})})]}),(0,A.jsx)("span",{children:"Ask Vanio AI"})]})]}),(0,A.jsx)("button",{onClick:n,className:(0,ew.cn)("absolute right-4 top-1/2 -translate-y-1/2","p-2 rounded-full","hover:bg-gray-100 dark:hover:bg-white/[0.05] transition-colors"),children:(0,A.jsx)(ei.X,{className:"w-5 h-5 text-gray-500 dark:text-[#6e6e73]"})})]})}):null}],899142);var ta=((t=ta||{}).Space=" ",t.Enter="Enter",t.Escape="Escape",t.Backspace="Backspace",t.Delete="Delete",t.ArrowLeft="ArrowLeft",t.ArrowUp="ArrowUp",t.ArrowRight="ArrowRight",t.ArrowDown="ArrowDown",t.Home="Home",t.End="End",t.PageUp="PageUp",t.PageDown="PageDown",t.Tab="Tab",t),tr=Object.defineProperty,ts=(e,t,a)=>{let r;return(r="symbol"!=typeof t?t+"":t)in e?tr(e,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[r]=a,a};let ti=new class{constructor(){ts(this,"current",this.detect()),ts(this,"handoffState","pending"),ts(this,"currentId",0)}set(e){this.current!==e&&(this.handoffState="pending",this.currentId=0,this.current=e)}reset(){this.set(this.detect())}nextId(){return++this.currentId}get isServer(){return"server"===this.current}get isClient(){return"client"===this.current}
66detect(){return"u"<typeof window||"u"<typeof document?"server":"client"}handoff(){"pending"===this.handoffState&&(this.handoffState="complete")}get isHandoffComplete(){return"complete"===this.handoffState}},tn=(e,t)=>{ti.isServer?(0,R.useEffect)(e,t):(0,R.useLayoutEffect)(e,t)};function tl(e){let t=(0,R.useRef)(e);return tn(()=>{t.current=e},[e]),t}function to(e,t,a,r){let s=tl(a);(0,R.useEffect)(()=>{function a(e){s.current(e)}return(e=null!=e?e:window).addEventListener(t,a,r),()=>e.removeEventListener(t,a,r)},[e,t,r])}class td extends Map{constructor(e){super(),this.factory=e}get(e){let t=super.get(e);return void 0===t&&(t=this.factory(e),this.set(e,t)),t}}function tc(e,t){let a=e(),r=new Set;return{getSnapshot:()=>a,subscribe:e=>(r.add(e),()=>r.delete(e)),dispatch(e,...s){let i=t[e].call(a,...s);i&&(a=i,r.forEach(e=>e()))}}}function tm(e){return(0,R.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot)}let tu=new td(()=>tc(()=>[],{ADD(e){return this.includes(e)?this:[...this,e]},REMOVE(e){let t=this.indexOf(e);if(-1===t)return this;let a=this.slice();return a.splice(t,1),a}}));function th(e,t){let a=tu.get(t),r=(0,R.useId)(),s=tm(a);if(tn(()=>{if(e)return a.dispatch("ADD",r),()=>a.dispatch("REMOVE",r)},[a,e]),!e)return!1;let i=s.indexOf(r),n=s.length;return -1===i&&(i=n,n+=1),i===n-1}let tx=function(e){let t=tl(e);return R.default.useCallback((...e)=>t.current(...e),[t])};function tg(e){"function"==typeof queueMicrotask?queueMicrotask(e):Promise.resolve().then(e).catch(e=>setTimeout(()=>{throw e}))}function tp(){let e=[],t={addEventListener:(e,a,r,s)=>(e.addEventListener(a,r,s),t.add(()=>e.removeEventListener(a,r,s))),requestAnimationFrame(...e){let a=requestAnimationFrame(...e);return t.add(()=>cancelAnimationFrame(a))},nextFrame:(...e)=>t.requestAnimationFrame(()=>t.requestAnimationFrame(...e)),setTimeout(...e){let a=setTimeout(...e);return t.add(()=>clearTimeout(a))},microTask(...e){let a={current:!0};return tg(()=>{a.current&&e[0]()}),t.add(()=>{a.current=!1})},style(e,t,a){let r=e.style.getPropertyValue(t);return Object.assign(e.style,{[t]:a}),this.add(()=>{Object.assign(e.style,{[t]:r})})},group(e){let t=tp();return e(t),this.add(()=>t.dispose())},add:t=>(e.includes(t)||e.push(t),()=>{let a=e.indexOf(t);if(a>=0)for(let t of e.splice(a,1))t()}),dispose(){for(let t of e.splice(0))t()}};return t}function tb(e){var t,a;return ti.isServer?null:e?"ownerDocument"in e?e.ownerDocument:"current"in e?null!=(a=null==(t=e.current)?void 0:t.ownerDocument)?a:document:null:document}let tf=new Map,ty=new Map;function tw(e){var t;let a=null!=(t=ty.get(e))?t:0;return ty.set(e,a+1),0!==a?()=>tv(e):(tf.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>tv(e))}function tv(e){var t;let a=null!=(t=ty.get(e))?t:1;if(1===a?ty.delete(e):ty.set(e,a-1),1!==a)return;let r=tf.get(e);r&&(null===r["aria-hidden"]?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r["aria-hidden"]),e.inert=r.inert,tf.delete(e))}function tk(e,t,...a){if(e in t){let r=t[e];return"function"==typeof r?r(...a):r}let r=Error(`Tried to handle "${e}" but there is no handler defined. Only defined handlers are: ${Object.keys(t).map(e=>`"${e}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,tk),r}let tj=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].map(e=>`${e}:not([tabindex='-1'])`).join(","),tN=["[data-autofocus]"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var tC=((a=tC||{})[a.First=1]="First",a[a.Previous=2]="Previous",a[a.Next=4]="Next",a[a.Last=8]="Last",a[a.WrapAround=16]="WrapAround",a[a.NoScroll=32]="NoScroll",a[a.AutoFocus=64]="AutoFocus",a),tS=((r=tS||{})[r.Error=0]="Error",r[r.Overflow=1]="Overflow",r[r.Success=2]="Success",r[r.Underflow=3]="Underflow",r),tE=((s=tE||{})[s.Previous=-1]="Previous",s[s.Next=1]="Next",s),tI=((i=tI||{})[i.Strict=0]="Strict",i[i.Loose=1]="Loose",i),tT=((n=tT||{})[n.Keyboard=0]="Keyboard",n[n.Mouse=1]="Mouse",n);function t_(e){null==e||e.focus({preventScroll:!0})}function tA(e,t,{sorted:a=!0,relativeTo:r=null,skipElements:s=[]}={}){var i,n,l;let o=Array.isArray(e)?e.length>0?e[0].ownerDocument:document:e.ownerDocument,d=Array.isArray(e)?a?function(e,t=e=>e){return e.slice().sort((e,a)=>{let r=t(e),s=t(a);if(null===r||null===s)return 0;let i=r.compareDocumentPosition(s);return i&Node.DOCUMENT_POSITION_FOLLOWING?-1:i&Node.DOCUMENT_POSITION_PRECEDING?1:0})}(e):e:64&t?function(e=document.body){return null==e?[]:Array.from(e.querySelectorAll(tN)).sort((e,t)=>
66Math.sign((e.tabIndex||Number.MAX_SAFE_INTEGER)-(t.tabIndex||Number.MAX_SAFE_INTEGER)))}(e):function(e=document.body){return null==e?[]:Array.from(e.querySelectorAll(tj)).sort((e,t)=>Math.sign((e.tabIndex||Number.MAX_SAFE_INTEGER)-(t.tabIndex||Number.MAX_SAFE_INTEGER)))}(e);s.length>0&&d.length>1&&(d=d.filter(e=>!s.some(t=>null!=t&&"current"in t?(null==t?void 0:t.current)===e:t===e))),r=null!=r?r:o.activeElement;let c=(()=>{if(5&t)return 1;if(10&t)return -1;throw Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),m=(()=>{if(1&t)return 0;if(2&t)return Math.max(0,d.indexOf(r))-1;if(4&t)return Math.max(0,d.indexOf(r))+1;if(8&t)return d.length-1;throw Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),u=32&t?{preventScroll:!0}:{},h=0,x=d.length,g;do{if(h>=x||h+x<=0)return 0;let e=m+h;if(16&t)e=(e+x)%x;else{if(e<0)return 3;if(e>=x)return 1}null==(g=d[e])||g.focus(u),h+=c}while(g!==o.activeElement)return 6&t&&null!=(l=null==(n=null==(i=g)?void 0:i.matches)?void 0:n.call(i,"textarea,input"))&&l&&g.select(),2}function tD(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function tP(e,t,a,r){let s=tl(a);(0,R.useEffect)(()=>{if(e)return document.addEventListener(t,a,r),()=>document.removeEventListener(t,a,r);function a(e){s.current(e)}},[e,t,r])}function tR(e,t,a,r){let s=tl(a);(0,R.useEffect)(()=>{if(e)return window.addEventListener(t,a,r),()=>window.removeEventListener(t,a,r);function a(e){s.current(e)}},[e,t,r])}function tM(...e){return(0,R.useMemo)(()=>tb(...e),[...e])}function tF(...e){return Array.from(new Set(e.flatMap(e=>"string"==typeof e?e.split(" "):[]))).filter(Boolean).join(" ")}"u">typeof window&&"u">typeof document&&(document.addEventListener("keydown",e=>{e.metaKey||e.altKey||e.ctrlKey||(document.documentElement.dataset.headlessuiFocusVisible="")},!0),document.addEventListener("click",e=>{1===e.detail?delete document.documentElement.dataset.headlessuiFocusVisible:0===e.detail&&(document.documentElement.dataset.headlessuiFocusVisible="")},!0));var tL=((l=tL||{})[l.None=0]="None",l[l.RenderStrategy=1]="RenderStrategy",l[l.Static=2]="Static",l),t$=((o=t$||{})[o.Unmount=0]="Unmount",o[o.Hidden=1]="Hidden",o);function tO(){let e,t,a=(e=(0,R.useRef)([]),t=(0,R.useCallback)(t=>{for(let a of e.current)null!=a&&("function"==typeof a?a(t):a.current=t)},[]),(...a)=>{if(!a.every(e=>null==e))return e.current=a,t});return(0,R.useCallback)(e=>(function({ourProps:e,theirProps:t,slot:a,defaultTag:r,features:s,visible:i=!0,name:n,mergeRefs:l}){l=null!=l?l:tB;let o=tq(t,e);if(i)return tU(o,a,r,n,l);let d=null!=s?s:0;if(2&d){let{static:e=!1,...t}=o;if(e)return tU(t,a,r,n,l)}if(1&d){let{unmount:e=!0,...t}=o;return tk(+!e,{0:()=>null,1:()=>tU({...t,hidden:!0,style:{display:"none"}},a,r,n,l)})}return tU(o,a,r,n,l)})({mergeRefs:a,...e}),[a])}function tU(e,t={},a,r,s){let{as:i=a,children:n,refName:l="ref",...o}=tV(e,["unmount","static"]),d=void 0!==e.ref?{[l]:e.ref}:{},c="function"==typeof n?n(t):n;"className"in o&&o.className&&"function"==typeof o.className&&(o.className=o.className(t)),o["aria-labelledby"]&&o["aria-labelledby"]===o.id&&(o["aria-labelledby"]=void 0);let m={};if(t){let e=!1,a=[];for(let[r,s]of Object.entries(t))"boolean"==typeof s&&(e=!0),!0===s&&a.push(r.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`));if(e)for(let e of(m["data-headlessui-state"]=a.join(" "),a))m[`data-${e}`]=""}if(i===R.Fragment&&(Object.keys(tH(o)).length>0||Object.keys(tH(m)).length>0))if(!(0,R.isValidElement)(c)||Array.isArray(c)&&c.length>1){if(Object.keys(tH(o)).length>0)throw Error(['Passing props on "Fragment"!',"",`The current component <${r} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(tH(o)).concat(Object.keys(tH(m))).map(e=>` - ${e}`).join(` 67`),"","You can apply a few solutions:",['Add an `as="..."` prop, to ensure that we render an actual element instead of a "Fragment".',"Render a single element as the child so that we can forward the props onto that element."].map(e=>` - ${e}`).join(` 68`)].join(` 69`))}else{var u;let e=c.props,t=null==e?void 0:e.className,a="function"==typeof t?(...e)=>tF(t(...e),o.className):tF(t,o.className),r=tq(c.props,tH(tV(o,["ref"])));for(let e in m)e in r&&delete m[e];return(0,R.cloneElement)(c,Object.assign({},r,m,d,{ref:s((u=c,R.default.version.split(".")[0]>="19"?u.props.ref:u.ref),d.ref)},a?{className:a}:{}))}return(0,R.createElement)(i,Object.assign({},tV(o,["ref"]),i!==R.Fragment&&d,i!==R.Fragment&&m),c)}function tB(...e){return e.every(e=>null==e)?void 0:t=>{for(let a of e)null!=a&&("function"==typeof a?a(t):a.current=t)}}function tq(...e){if(0===e.length)return{};if(1===e.length)return e[0];let t={},a={};for(let r of e)for(let e in r)e.startsWith("on")&&"function"==typeof r[e]?(null!=a[e]||(a[e]=[]),a[e].push(r[e])):t[e]=r[e];if(t.disabled||t["aria-disabled"])for(let e in a)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(e)&&(a[e]=[e=>{var t;return null==(t=null==e?void 0:e.preventDefault)?void 0:t.call(e)}]);for(let e in a)Object.assign(t,{[e](t,...r){for(let s of a[e]){if((t instanceof Event||(null==t?void 0:t.nativeEvent)instanceof Event)&&t.defaultPrevented)return;s(t,...r)}}});return t}function tz(e){var t;return Object.assign((0,R.forwardRef)(e),{displayName:null!=(t=e.displayName)?t:e.name})}function tH(e){let t=Object.assign({},e);for(let e in t)void 0===t[e]&&delete t[e];return t}function tV(e,t=[]){let a=Object.assign({},e);for(let e of t)e in a&&delete a[e];return a}var tG=((d=tG||{})[d.None=1]="None",d[d.Focusable=2]="Focusable",d[d.Hidden=4]="Hidden",d);let tW=tz(function(e,t){var a;let{features:r=1,...s}=e,i={ref:t,"aria-hidden":(2&r)==2||(null!=(a=s["aria-hidden"])?a:void 0),hidden:(4&r)==4||void 0,style:{position:"fixed",top:1,left:1,width:1,height:0,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0",...(4&r)==4&&(2&r)!=2&&{display:"none"}}};return tO()({ourProps:i,theirProps:s,slot:{},defaultTag:"span",name:"Hidden"})}),tK=(0,R.createContext)(null);function tY({children:e,node:t}){let[a,r]=(0,R.useState)(null),s=tJ(null!=t?t:a);return R.default.createElement(tK.Provider,{value:s},e,null===s&&R.default.createElement(tW,{features:tG.Hidden,ref:e=>{var t,a;if(e){for(let s of null!=(a=null==(t=tb(e))?void 0:t.querySelectorAll("html > *, body > *"))?a:[])if(s!==document.body&&s!==document.head&&s instanceof HTMLElement&&null!=s&&s.contains(e)){r(s);break}}}}))}function tJ(e=null){var t;return null!=(t=(0,R.useContext)(tK))?t:e}let tQ=tc(()=>new Map,{PUSH(e,t){var a;let r=null!=(a=this.get(e))?a:{doc:e,count:0,d:tp(),meta:new Set};return r.count++,r.meta.add(t),this.set(e,r),this},POP(e,t){let a=this.get(e);return a&&(a.count--,a.meta.delete(t)),this},SCROLL_PREVENT({doc:e,d:t,meta:a}){let r,s={doc:e,d:t,meta:function(e){let t={};for(let a of e)Object.assign(t,a(t));return t}(a)},i=[tD()?{before({doc:e,d:t,meta:a}){function r(e){return a.containers.flatMap(e=>e()).some(t=>t.contains(e))}t.microTask(()=>{var a;if("auto"!==window.getComputedStyle(e.documentElement).scrollBehavior){let a=tp();a.style(e.documentElement,"scrollBehavior","auto"),t.add(()=>t.microTask(()=>a.dispose()))}let s=null!=(a=window.scrollY)?a:window.pageYOffset,i=null;t.addEventListener(e,"click",t=>{if(t.target instanceof HTMLElement)try{let a=t.target.closest("a");if(!a)return;let{hash:s}=new URL(a.href),n=e.querySelector(s);n&&!r(n)&&(i=n)}catch{}},!0),t.addEventListener(e,"touchstart",e=>{if(e.target instanceof HTMLElement)if(r(e.target)){let a=e.target;for(;a.parentElement&&r(a.parentElement);)a=a.parentElement;t.style(a,"overscrollBehavior","contain")}else t.style(e.target,"touchAction","none")}),t.addEventListener(e,"touchmove",e=>{if(e.target instanceof HTMLElement&&"INPUT"!==e.target.tagName)if(r(e.target)){let t=e.target;for(;t.parentElement&&""!==t.dataset.headlessuiPortal&&!(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth);)t=t.parentElement;""===t.dataset.headlessuiPortal&&e.preventDefault()}else e.preventDefault()},{passive:!1}),t.add(()=>{var e;s!==(null!=(e=window.scrollY)?e:window.pageYOffset)&&window.scrollTo(0,s),i&&i.isConnected&&(i.scrollIntoView({block:"nearest"}),i=null)})})}}:{},{before({doc:e}){var t;let a=e.documentElement;
69r=Math.max(0,(null!=(t=e.defaultView)?t:window).innerWidth-a.clientWidth)},after({doc:e,d:t}){let a=e.documentElement,s=Math.max(0,a.clientWidth-a.offsetWidth),i=Math.max(0,r-s);t.style(a,"paddingRight",`${i}px`)}},{before({doc:e,d:t}){t.style(e.documentElement,"overflow","hidden")}}];i.forEach(({before:e})=>null==e?void 0:e(s)),i.forEach(({after:e})=>null==e?void 0:e(s))},SCROLL_ALLOW({d:e}){e.dispose()},TEARDOWN({doc:e}){this.delete(e)}});function tX(){let e,t=(e="u"<typeof document,"useSyncExternalStore"in R&&(0,R.useSyncExternalStore)(()=>()=>{},()=>!1,()=>!e)),[a,r]=R.useState(ti.isHandoffComplete);return a&&!1===ti.isHandoffComplete&&r(!1),R.useEffect(()=>{!0!==a&&r(!0)},[a]),R.useEffect(()=>ti.handoff(),[]),!t&&a}tQ.subscribe(()=>{let e=tQ.getSnapshot(),t=new Map;for(let[a]of e)t.set(a,a.documentElement.style.overflow);for(let a of e.values()){let e="hidden"===t.get(a.doc),r=0!==a.count;(r&&!e||!r&&e)&&tQ.dispatch(a.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",a),0===a.count&&tQ.dispatch("TEARDOWN",a)}});let tZ=Symbol();function t0(...e){let t=(0,R.useRef)(e);(0,R.useEffect)(()=>{t.current=e},[e]);let a=tx(e=>{for(let a of t.current)null!=a&&("function"==typeof a?a(e):a.current=e)});return e.every(e=>null==e||(null==e?void 0:e[tZ]))?void 0:a}let t1=(0,R.createContext)(()=>{});function t2({value:e,children:t}){return R.default.createElement(t1.Provider,{value:e},t)}let t5=(0,R.createContext)(null);t5.displayName="OpenClosedContext";var t4=((c=t4||{})[c.Open=1]="Open",c[c.Closed=2]="Closed",c[c.Closing=4]="Closing",c[c.Opening=8]="Opening",c);function t3(){return(0,R.useContext)(t5)}function t6({value:e,children:t}){return R.default.createElement(t5.Provider,{value:e},t)}function t8({children:e}){return R.default.createElement(t5.Provider,{value:null},e)}let t9=(0,R.createContext)(!1);function t7(e){return R.default.createElement(t9.Provider,{value:e.force},e.children)}let ae=(0,R.createContext)(void 0),at=(0,R.createContext)(null);at.displayName="DescriptionContext";let aa=Object.assign(tz(function(e,t){let a=(0,R.useId)(),r=(0,R.useContext)(ae),{id:s=`headlessui-description-${a}`,...i}=e,n=function e(){let t=(0,R.useContext)(at);if(null===t){let t=Error("You used a <Description /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(t,e),t}return t}(),l=t0(t);tn(()=>n.register(s),[s,n.register]);let o=r||!1,d=(0,R.useMemo)(()=>({...n.slot,disabled:o}),[n.slot,o]),c={ref:l,...n.props,id:s};return tO()({ourProps:c,theirProps:i,slot:d,defaultTag:"p",name:n.name||"Description"})}),{});function ar(){let[e]=(0,R.useState)(tp);return(0,R.useEffect)(()=>()=>e.dispose(),[e]),e}function as(){let e=(0,R.useRef)(!1);return tn(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function ai(e){let t=tx(e),a=(0,R.useRef)(!1);(0,R.useEffect)(()=>(a.current=!1,()=>{a.current=!0,tg(()=>{a.current&&t()})}),[t])}var an=((m=an||{})[m.Forwards=0]="Forwards",m[m.Backwards=1]="Backwards",m);function al(e,t){let a=(0,R.useRef)([]),r=tx(e);(0,R.useEffect)(()=>{let e=[...a.current];for(let[s,i]of t.entries())if(a.current[s]!==i){let s=r(t,e);return a.current=t,s}},[r,...t])}let ao=[];function ad(){"loading"!==document.readyState&&((()=>{function e(e){if(!(e.target instanceof HTMLElement)||e.target===document.body||ao[0]===e.target)return;let t=e.target;t=t.closest(tj),ao.unshift(null!=t?t:e.target),(ao=ao.filter(e=>null!=e&&e.isConnected)).splice(10)}window.addEventListener("click",e,{capture:!0}),window.addEventListener("mousedown",e,{capture:!0}),window.addEventListener("focus",e,{capture:!0}),document.body.addEventListener("click",e,{capture:!0}),document.body.addEventListener("mousedown",e,{capture:!0}),document.body.addEventListener("focus",e,{capture:!0})})(),document.removeEventListener("DOMContentLoaded",ad))}function ac(e){if(!e)return new Set;if("function"==typeof e)return new Set(e());let t=new Set;for(let a of e.current)a.current instanceof HTMLElement&&t.add(a.current);return t}"u">typeof window&&"u">typeof document&&(document.addEventListener("DOMContentLoaded",ad),ad());var am=((u=am||{})[u.None=0]="None",u[u.InitialFocus=1]="InitialFocus",u[u.TabLock=2]="TabLock",u[u.FocusLock=4]="FocusLock",u[u.RestoreFocus=8]="RestoreFocus",u[u.AutoFocus=16]="AutoFocus",u);let au=Object.assign(tz(function(e,t){let a,r=(0,R.useRef)(null),s=t0(r,t),{initialFocus:i,initialFocusFallback:n,containers:l,features:o=15,...d}=e;tX()||(o=0);let c=tM(r);!function(e,{ownerDocument:t}){let a=!!(8&e),r=function(e=!0){let t=(0,R.useRef)(ao.slice());return al(([e],[a])=>{!0===a&&!1===e&&tg(()=>{t.current.splice(0)}),!1===a&&!0===e&&(t.current=ao.slice())},[e,ao,t]),tx(()=>{var e;return null!=(e=t.current.find(e=>null!=e&&e.isConnected))?e:null})}(a);al(()=>{a||(null==t?void 0:t.activeElement)===(null==t?void 0:t.body)&&t_(r())},[a]),ai(()=>{a&&t_(r())})}(o,{ownerDocument:c});let m=function(e,{ownerDocument:t,container:a,initialFocus:r,initialFocusFallback:s}
69){let i=(0,R.useRef)(null),n=th(!!(1&e),"focus-trap#initial-focus"),l=as();return al(()=>{if(0===e)return;if(!n){null!=s&&s.current&&t_(s.current);return}let o=a.current;o&&tg(()=>{if(!l.current)return;let a=null==t?void 0:t.activeElement;if(null!=r&&r.current){if((null==r?void 0:r.current)===a){i.current=a;return}}else if(o.contains(a)){i.current=a;return}if(null!=r&&r.current)t_(r.current);else{if(16&e){if(tA(o,tC.First|tC.AutoFocus)!==tS.Error)return}else if(tA(o,tC.First)!==tS.Error)return;if(null!=s&&s.current&&(t_(s.current),(null==t?void 0:t.activeElement)===s.current))return;console.warn("There are no focusable elements inside the <FocusTrap />")}i.current=null==t?void 0:t.activeElement})},[s,n,e]),i}(o,{ownerDocument:c,container:r,initialFocus:i,initialFocusFallback:n});!function(e,{ownerDocument:t,container:a,containers:r,previousActiveElement:s}){let i=as(),n=!!(4&e);to(null==t?void 0:t.defaultView,"focus",e=>{if(!n||!i.current)return;let t=ac(r);a.current instanceof HTMLElement&&t.add(a.current);let l=s.current;if(!l)return;let o=e.target;o&&o instanceof HTMLElement?ah(t,o)?(s.current=o,t_(o)):(e.preventDefault(),e.stopPropagation(),t_(l)):t_(s.current)},!0)}(o,{ownerDocument:c,container:r,containers:l,previousActiveElement:m});let u=(a=(0,R.useRef)(0),tR(!0,"keydown",e=>{"Tab"===e.key&&(a.current=+!!e.shiftKey)},!0),a),h=tx(e=>{let t=r.current;t&&tk(u.current,{[an.Forwards]:()=>{tA(t,tC.First,{skipElements:[e.relatedTarget,n]})},[an.Backwards]:()=>{tA(t,tC.Last,{skipElements:[e.relatedTarget,n]})}})}),x=th(!!(2&o),"focus-trap#tab-lock"),g=ar(),p=(0,R.useRef)(!1),b=tO();return R.default.createElement(R.default.Fragment,null,x&&R.default.createElement(tW,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:h,features:tG.Focusable}),b({ourProps:{ref:s,onKeyDown(e){"Tab"==e.key&&(p.current=!0,g.requestAnimationFrame(()=>{p.current=!1}))},onBlur(e){if(!(4&o))return;let t=ac(l);r.current instanceof HTMLElement&&t.add(r.current);let a=e.relatedTarget;a instanceof HTMLElement&&"true"!==a.dataset.headlessuiFocusGuard&&(ah(t,a)||(p.current?tA(r.current,tk(u.current,{[an.Forwards]:()=>tC.Next,[an.Backwards]:()=>tC.Previous})|tC.WrapAround,{relativeTo:e.target}):e.target instanceof HTMLElement&&t_(e.target)))}},theirProps:d,defaultTag:"div",name:"FocusTrap"}),x&&R.default.createElement(tW,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:h,features:tG.Focusable}))}),{features:am});function ah(e,t){for(let a of e)if(a.contains(t))return!0;return!1}var ax=e.i(174080);let ag=R.Fragment,ap=tz(function(e,t){let{ownerDocument:a=null,...r}=e,s=(0,R.useRef)(null),i=t0(function(e,t=!0){return Object.assign(e,{[tZ]:t})}(e=>{s.current=e}),t),n=tM(s),l=null!=a?a:n,o=function(e){let t=(0,R.useContext)(t9),a=(0,R.useContext)(af),[r,s]=(0,R.useState)(()=>{var r;if(!t&&null!==a)return null!=(r=a.current)?r:null;if(ti.isServer)return null;let s=null==e?void 0:e.getElementById("headlessui-portal-root");if(s)return s;if(null===e)return null;let i=e.createElement("div");return i.setAttribute("id","headlessui-portal-root"),e.body.appendChild(i)});return(0,R.useEffect)(()=>{null!==r&&(null!=e&&e.body.contains(r)||null==e||e.body.appendChild(r))},[r,e]),(0,R.useEffect)(()=>{t||null!==a&&s(a.current)},[a,s,t]),r}(l),[d]=(0,R.useState)(()=>{var e;return ti.isServer?null:null!=(e=null==l?void 0:l.createElement("div"))?e:null}),c=(0,R.useContext)(ay),m=tX();tn(()=>{!o||!d||o.contains(d)||(d.setAttribute("data-headlessui-portal",""),o.appendChild(d))},[o,d]),tn(()=>{if(d&&c)return c.register(d)},[c,d]),ai(()=>{var e;o&&d&&(d instanceof Node&&o.contains(d)&&o.removeChild(d),o.childNodes.length<=0&&(null==(e=o.parentElement)||e.removeChild(o)))});let u=tO();return m&&o&&d?(0,ax.createPortal)(u({ourProps:{ref:i},theirProps:r,slot:{},defaultTag:ag,name:"Portal"}),d):null}),ab=R.Fragment,af=(0,R.createContext)(null),ay=(0,R.createContext)(null),aw=tz(function(e,t){let a=t0(t),{enabled:r=!0,ownerDocument:s,...i}=e,n=tO();return r?R.default.createElement(ap,{...i,ownerDocument:s,ref:a}):n({ourProps:{ref:a},theirProps:i,slot:{},defaultTag:ag,name:"Portal"})}),av=tz(function(e,t){let{target:a,...r}=e,s={ref:t0(t)},i=tO();return R.default.createElement(af.Provider,{value:a},i({ourProps:s,theirProps:r,defaultTag:ab,name:"Popover.Group"}))}),ak=Object.assign(aw,{Group:av});void 0!==Y.default&&"u">typeof globalThis&&"u">typeof Element&&(null==(b=null==Y.default?void 0:Y.default.env)?void 0:b.NODE_ENV)==="test"&&void 0===(null==(f=null==Element?void 0:Element.prototype)?void 0:f.getAnimations)&&(Element.prototype.getAnimations=function(){return console.warn(["Headless UI has polyfilled `Element.prototype.getAnimations` for your tests.","Please install a proper polyfill e.g. `jsdom-testing-mocks`, to silence these warnings.","","Example usage:","```js","import { mockAnimationsApi } from 'jsdom-testing-mocks'","mockAnimationsApi()","```"].join(` 70`)),[]});var aj=((h=aj||{})[h.None=0]="None",h[h.Closed=1]="Closed",h[h.Enter=2]="Enter",h[h.Leave=4]="Leave",h);function aN(e){var t;return!!(e.enter||e.enterFrom||e.enterTo||e.leave||e.leaveFrom||e.leaveTo)||(null!=(t=e.as)?t:a_)!==R.Fragment||1===R.default.Children.count(e.children)}let aC=(0,R.createContext)(null);aC.displayName="TransitionContext";var aS=((x=aS||{}).Visible="visible",x.Hidden="hidden",x);let aE=(0,R.createContext)(null);function aI(e){return"children"in e?aI(e.children):e.current.filter(({el:e})=>null!==e.current).filter(({state:e})=>"visible"===e).length>0}function aT(e,t){let a=tl(e),r=(0,R.useRef)([]),s=as(),i=ar(),n=tx((e,t=t$.Hidden)=>{let n=r.current.findIndex(({el:t})=>t===e);-1!==n&&(tk(t,{[t$.Unmount](){r.current.splice(n,1)},[t$.Hidden](){r.current[n].state="hidden"}}),i.microTask(()=>{var e;!aI(r)&&s.current&&(null==(e=a.current)||e.call(a))}))}),l=tx(e=>{let t=r.current.find(({el:t})=>t===e);return t?"visible"!==t.state&&(t.state="visible"):r.current.push({el:e,state:"visible"}),()=>n(e,t$.Unmount)}),o=(0,R.useRef)([]),d=(0,R.useRef)(Promise.resolve()),c=(0,R.useRef)({enter:[],leave:[]}
70),m=tx((e,a,r)=>{o.current.splice(0),t&&(t.chains.current[a]=t.chains.current[a].filter(([t])=>t!==e)),null==t||t.chains.current[a].push([e,new Promise(e=>{o.current.push(e)})]),null==t||t.chains.current[a].push([e,new Promise(e=>{Promise.all(c.current[a].map(([e,t])=>t)).then(()=>e())})]),"enter"===a?d.current=d.current.then(()=>null==t?void 0:t.wait.current).then(()=>r(a)):r(a)}),u=tx((e,t,a)=>{Promise.all(c.current[t].splice(0).map(([e,t])=>t)).then(()=>{var e;null==(e=o.current.shift())||e()}).then(()=>a(t))});return(0,R.useMemo)(()=>({children:r,register:l,unregister:n,onStart:m,onStop:u,wait:d,chains:c}),[l,n,r,m,u,c,d])}aE.displayName="NestingContext";let a_=R.Fragment,aA=tL.RenderStrategy,aD=tz(function(e,t){let{show:a,appear:r=!1,unmount:s=!0,...i}=e,n=(0,R.useRef)(null),l=t0(...aN(e)?[n,t]:null===t?[]:[t]);tX();let o=t3();if(void 0===a&&null!==o&&(a=(o&t4.Open)===t4.Open),void 0===a)throw Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[d,c]=(0,R.useState)(a?"visible":"hidden"),m=aT(()=>{a||c("hidden")}),[u,h]=(0,R.useState)(!0),x=(0,R.useRef)([a]);tn(()=>{!1!==u&&x.current[x.current.length-1]!==a&&(x.current.push(a),h(!1))},[x,a]);let g=(0,R.useMemo)(()=>({show:a,appear:r,initial:u}),[a,r,u]);tn(()=>{a?c("visible"):aI(m)||null===n.current||c("hidden")},[a,m]);let p={unmount:s},b=tx(()=>{var t;u&&h(!1),null==(t=e.beforeEnter)||t.call(e)}),f=tx(()=>{var t;u&&h(!1),null==(t=e.beforeLeave)||t.call(e)}),y=tO();return R.default.createElement(aE.Provider,{value:m},R.default.createElement(aC.Provider,{value:g},y({ourProps:{...p,as:R.Fragment,children:R.default.createElement(aP,{ref:l,...p,...i,beforeEnter:b,beforeLeave:f})},theirProps:{},defaultTag:R.Fragment,features:aA,visible:"visible"===d,name:"Transition"})))}),aP=tz(function(e,t){var a,r;let{transition:s=!0,beforeEnter:i,afterEnter:n,beforeLeave:l,afterLeave:o,enter:d,enterFrom:c,enterTo:m,entered:u,leave:h,leaveFrom:x,leaveTo:g,...p}=e,[b,f]=(0,R.useState)(null),y=(0,R.useRef)(null),w=aN(e),v=t0(...w?[y,t,f]:null===t?[]:[t]),k=null==(a=p.unmount)||a?t$.Unmount:t$.Hidden,{show:j,appear:N,initial:C}=function(){let e=(0,R.useContext)(aC);if(null===e)throw Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}(),[S,E]=(0,R.useState)(j?"visible":"hidden"),I=function(){let e=(0,R.useContext)(aE);if(null===e)throw Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}(),{register:T,unregister:_}=I;tn(()=>T(y),[T,y]),tn(()=>{if(k===t$.Hidden&&y.current)return j&&"visible"!==S?void E("visible"):tk(S,{hidden:()=>_(y),visible:()=>T(y)})},[S,y,T,_,j,k]);let A=tX();tn(()=>{if(w&&A&&"visible"===S&&null===y.current)throw Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[y,S,A,w]);let D=C&&!N,P=N&&j&&C,M=(0,R.useRef)(!1),F=aT(()=>{M.current||(E("hidden"),_(y))},I),L=tx(e=>{M.current=!0,F.onStart(y,e?"enter":"leave",e=>{"enter"===e?null==i||i():"leave"===e&&(null==l||l())})}),$=tx(e=>{let t=e?"enter":"leave";M.current=!1,F.onStop(y,t,e=>{"enter"===e?null==n||n():"leave"===e&&(null==o||o())}),"leave"!==t||aI(F)||(E("hidden"),_(y))});(0,R.useEffect)(()=>{w&&s||(L(j),$(j))},[j,w,s]);let[,O]=function(e,t,a,r){let[s,i]=(0,R.useState)(a),{hasFlag:n,addFlag:l,removeFlag:o}=function(e=0){let[t,a]=(0,R.useState)(e),r=(0,R.useCallback)(e=>a(e),[t]),s=(0,R.useCallback)(e=>a(t=>t|e),[t]),i=(0,R.useCallback)(e=>(t&e)===e,[t]);return{flags:t,setFlag:r,addFlag:s,hasFlag:i,removeFlag:(0,R.useCallback)(e=>a(t=>t&~e),[a]),toggleFlag:(0,R.useCallback)(e=>a(t=>t^e),[a])}}(e&&s?3:0),d=(0,R.useRef)(!1),c=(0,R.useRef)(!1);return tn(()=>{var s;if(e){if(a&&i(!0),!t){a&&l(3);return}return null==(s=null==r?void 0:r.start)||s.call(r,a),function(e,{prepare:t,run:a,done:r,inFlight:s}){let i=tp();return function(e,{inFlight:t,prepare:a}){if(null!=t&&t.current)return a();let r=e.style.transition;e.style.transition="none",a(),e.offsetHeight,e.style.transition=r}(e,{prepare:t,inFlight:s}),i.nextFrame(()=>{a(),i.requestAnimationFrame(()=>{i.add(function(e,t){var a,r;let s=tp();if(!e)return s.dispose;let i=!1;s.add(()=>{i=!0});let n=null!=(r=null==(a=e.getAnimations)?void 0:a.call(e).filter(e=>e instanceof CSSTransition))?r:[];return 0===n.length?t():Promise.allSettled(n.map(e=>e.finished)).then(()=>{i||t()}),s.dispose}(e,r))})}),i.dispose}(t,{inFlight:d,prepare(){c.current?c.current=!1:c.current=d.current,d.current=!0,
70c.current||(a?(l(3),o(4)):(l(4),o(2)))},run(){c.current?a?(o(3),l(4)):(o(4),l(3)):a?o(1):l(1)},done(){var e;c.current&&"function"==typeof t.getAnimations&&t.getAnimations().length>0||(d.current=!1,o(7),a||i(!1),null==(e=null==r?void 0:r.end)||e.call(r,a))}})}},[e,a,t,ar()]),e?[s,{closed:n(1),enter:n(2),leave:n(4),transition:n(2)||n(4)}]:[a,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}(!(!s||!w||!A||D),b,j,{start:L,end:$}),U=tH({ref:v,className:(null==(r=tF(p.className,P&&d,P&&c,O.enter&&d,O.enter&&O.closed&&c,O.enter&&!O.closed&&m,O.leave&&h,O.leave&&!O.closed&&x,O.leave&&O.closed&&g,!O.transition&&j&&u))?void 0:r.trim())||void 0,...function(e){let t={};for(let a in e)!0===e[a]&&(t[`data-${a}`]="");return t}(O)}),B=0;"visible"===S&&(B|=t4.Open),"hidden"===S&&(B|=t4.Closed),j&&"hidden"===S&&(B|=t4.Opening),j||"visible"!==S||(B|=t4.Closing);let q=tO();return R.default.createElement(aE.Provider,{value:F},R.default.createElement(t6,{value:B},q({ourProps:U,theirProps:p,defaultTag:a_,features:aA,visible:"visible"===S,name:"Transition.Child"})))}),aR=tz(function(e,t){let a=null!==(0,R.useContext)(aC),r=null!==t3();return R.default.createElement(R.default.Fragment,null,!a&&r?R.default.createElement(aD,{ref:t,...e}):R.default.createElement(aP,{ref:t,...e}))}),aM=Object.assign(aD,{Child:aR,Root:aD});var aF=((g=aF||{})[g.Open=0]="Open",g[g.Closed=1]="Closed",g),aL=((p=aL||{})[p.SetTitleId=0]="SetTitleId",p);let a$={0:(e,t)=>e.titleId===t.id?e:{...e,titleId:t.id}},aO=(0,R.createContext)(null);function aU(e){let t=(0,R.useContext)(aO);if(null===t){let t=Error(`<${e} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,aU),t}return t}function aB(e,t){return tk(t.type,a$,e,t)}aO.displayName="DialogContext";let aq=tz(function(e,t){let a,r,s,i,n,l,o,d,c,m,u,h=(0,R.useId)(),{id:x=`headlessui-dialog-${h}`,open:g,onClose:p,initialFocus:b,role:f="dialog",autoFocus:y=!0,__demoMode:w=!1,unmount:v=!1,...k}=e,j=(0,R.useRef)(!1);f="dialog"===f||"alertdialog"===f?f:(j.current||(j.current=!0,console.warn(`Invalid role [${f}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),"dialog");let N=t3();void 0===g&&null!==N&&(g=(N&t4.Open)===t4.Open);let C=(0,R.useRef)(null),S=t0(C,t),E=tM(C),I=+!g,[T,_]=(0,R.useReducer)(aB,{titleId:null,descriptionId:null,panelRef:(0,R.createRef)()}),A=tx(()=>p(!1)),D=tx(e=>_({type:0,id:e})),P=!!tX()&&0===I,[M,F]=(a=(0,R.useContext)(ay),r=(0,R.useRef)([]),s=tx(e=>(r.current.push(e),a&&a.register(e),()=>i(e))),i=tx(e=>{let t=r.current.indexOf(e);-1!==t&&r.current.splice(t,1),a&&a.unregister(e)}),n=(0,R.useMemo)(()=>({register:s,unregister:i,portals:r}),[s,i,r]),[r,(0,R.useMemo)(()=>function({children:e}){return R.default.createElement(ay.Provider,{value:n},e)},[n])]),L=tJ(),{resolveContainers:$}=function({defaultContainers:e=[],portals:t,mainTreeNode:a}={}){let r=tM(a),s=tx(()=>{var s,i;let n=[];for(let t of e)null!==t&&(t instanceof HTMLElement?n.push(t):"current"in t&&t.current instanceof HTMLElement&&n.push(t.current));if(null!=t&&t.current)for(let e of t.current)n.push(e);for(let e of null!=(s=null==r?void 0:r.querySelectorAll("html > *, body > *"))?s:[])e!==document.body&&e!==document.head&&e instanceof HTMLElement&&"headlessui-portal-root"!==e.id&&(a&&(e.contains(a)||e.contains(null==(i=null==a?void 0:a.getRootNode())?void 0:i.host))||n.some(t=>e.contains(t))||n.push(e));return n});
70return{resolveContainers:s,contains:tx(e=>s().some(t=>t.contains(e)))}}({mainTreeNode:L,portals:M,defaultContainers:[{get current(){var O;return null!=(O=T.panelRef.current)?O:C.current}}]}),U=null!==N&&(N&t4.Closing)===t4.Closing;(function(e,{allowed:t,disallowed:a}={}){let r=th(e,"inert-others");tn(()=>{var e,s;if(!r)return;let i=tp();for(let t of null!=(e=null==a?void 0:a())?e:[])t&&i.add(tw(t));let n=null!=(s=null==t?void 0:t())?s:[];for(let e of n){if(!e)continue;let t=tb(e);if(!t)continue;let a=e.parentElement;for(;a&&a!==t.body;){for(let e of a.children)n.some(t=>e.contains(t))||i.add(tw(e));a=a.parentElement}}return i.dispose},[r,t,a])})(!w&&!U&&P,{allowed:tx(()=>{var e,t;return[null!=(t=null==(e=C.current)?void 0:e.closest("[data-headlessui-portal]"))?t:null]}),disallowed:tx(()=>{var e;return[null!=(e=null==L?void 0:L.closest("body > *:not(#headlessui-portal-root)"))?e:null]})}),l=th(P,"outside-click"),o=tl(e=>{e.preventDefault(),A()}),d=(0,R.useCallback)(function(e,t){if(e.defaultPrevented)return;let a=t(e);if(null!==a&&a.getRootNode().contains(a)&&a.isConnected){for(let t of function e(t){return"function"==typeof t?e(t()):Array.isArray(t)||t instanceof Set?t:[t]}($))if(null!==t&&(t.contains(a)||e.composed&&e.composedPath().includes(t)))return;return function(e,t=0){var a;return e!==(null==(a=tb(e))?void 0:a.body)&&tk(t,{0:()=>e.matches(tj),1(){let t=e;for(;null!==t;){if(t.matches(tj))return!0;t=t.parentElement}return!1}})}(a,tI.Loose)||-1===a.tabIndex||e.preventDefault(),o.current(e,a)}},[o,$]),c=(0,R.useRef)(null),tP(l,"pointerdown",e=>{var t,a;c.current=(null==(a=null==(t=e.composedPath)?void 0:t.call(e))?void 0:a[0])||e.target},!0),tP(l,"mousedown",e=>{var t,a;c.current=(null==(a=null==(t=e.composedPath)?void 0:t.call(e))?void 0:a[0])||e.target},!0),tP(l,"click",e=>{tD()||/Android/gi.test(window.navigator.userAgent)||c.current&&(d(e,()=>c.current),c.current=null)},!0),m=(0,R.useRef)({x:0,y:0}),tP(l,"touchstart",e=>{m.current.x=e.touches[0].clientX,m.current.y=e.touches[0].clientY},!0),tP(l,"touchend",e=>{let t={x:e.changedTouches[0].clientX,y:e.changedTouches[0].clientY};if(!(Math.abs(t.x-m.current.x)>=30||Math.abs(t.y-m.current.y)>=30))return d(e,()=>e.target instanceof HTMLElement?e.target:null)},!0),tR(l,"blur",e=>d(e,()=>window.document.activeElement instanceof HTMLIFrameElement?window.document.activeElement:null),!0),function(e,t="u">typeof document?document.defaultView:null,a){let r=th(e,"escape");to(t,"keydown",e=>{r&&(e.defaultPrevented||e.key===ta.Escape&&a(e))})}(P,null==E?void 0:E.defaultView,e=>{e.preventDefault(),e.stopPropagation(),document.activeElement&&"blur"in document.activeElement&&"function"==typeof document.activeElement.blur&&document.activeElement.blur(),A()}),function(e,t,a=()=>[document.body]){!function(e,t,a=()=>({containers:[]})){let r=tm(tQ),s=t?r.get(t):void 0;s&&s.count,tn(()=>{if(!(!t||!e))return tQ.dispatch("PUSH",t,a),()=>tQ.dispatch("POP",t,a)},[e,t])}(th(e,"scroll-lock"),t,e=>{var t;return{containers:[...null!=(t=e.containers)?t:[],a]}})}(!w&&!U&&P,E,$),u=tl(e=>{let t=e.getBoundingClientRect();0===t.x&&0===t.y&&0===t.width&&0===t.height&&A()}),(0,R.useEffect)(()=>{if(!P)return;let e=null===C?null:C instanceof HTMLElement?C:C.current;if(!e)return;let t=tp();if("u">typeof ResizeObserver){let a=new ResizeObserver(()=>u.current(e));a.observe(e),t.add(()=>a.disconnect())}if("u">typeof IntersectionObserver){let a=new IntersectionObserver(()=>u.current(e));a.observe(e),t.add(()=>a.disconnect())}return()=>t.dispose()},[C,u,P]);let[B,q]=function(){let[e,t]=(0,R.useState)([]);return[e.length>0?e.join(" "):void 0,(0,R.useMemo)(()=>function(e){let a=tx(e=>(t(t=>[...t,e]),()=>t(t=>{let a=t.slice(),r=a.indexOf(e);return -1!==r&&a.splice(r,1),a}))),r=(0,R.useMemo)(()=>({register:a,slot:e.slot,name:e.name,props:e.props,value:e.value}),[a,e.slot,e.name,e.props,e.value]);return R.default.createElement(at.Provider,{value:r},e.children)},[t])]}(),z=(0,R.useMemo)(()=>[{dialogState:I,close:A,setTitleId:D,unmount:v},T],[I,T,A,D,v]),H=(0,R.useMemo)(()=>({open:0===I}),[I]),V={ref:S,id:x,role:f,tabIndex:-1,"aria-modal":w?void 0:0===I||void 0,"aria-labelledby":T.titleId,"aria-describedby":B,unmount:v},G=!function(){var e;let[t]=(0,R.useState)(()=>"u">typeof window&&"function"==typeof window.matchMedia?window.matchMedia("(pointer: coarse)"):null),[a,r]=(0,R.useState)(null!=(e=null==t?void 0:t.matches)&&e);return tn(()=>
70{if(t)return t.addEventListener("change",e),()=>t.removeEventListener("change",e);function e(e){r(e.matches)}},[t]),a}(),W=am.None;P&&!w&&(W|=am.RestoreFocus,W|=am.TabLock,y&&(W|=am.AutoFocus),G&&(W|=am.InitialFocus));let K=tO();return R.default.createElement(t8,null,R.default.createElement(t7,{force:!0},R.default.createElement(ak,null,R.default.createElement(aO.Provider,{value:z},R.default.createElement(av,{target:C},R.default.createElement(t7,{force:!1},R.default.createElement(q,{slot:H},R.default.createElement(F,null,R.default.createElement(au,{initialFocus:b,initialFocusFallback:C,containers:$,features:W},R.default.createElement(t2,{value:A},K({ourProps:V,theirProps:k,slot:H,defaultTag:az,features:aH,visible:0===I,name:"Dialog"})))))))))))}),az="div",aH=tL.RenderStrategy|tL.Static,aV=Object.assign(tz(function(e,t){let{transition:a=!1,open:r,...s}=e,i=t3(),n=e.hasOwnProperty("open")||null!==i,l=e.hasOwnProperty("onClose");if(!n&&!l)throw Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!n)throw Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!l)throw Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if(!i&&"boolean"!=typeof e.open)throw Error(`You provided an \`open\` prop to the \`Dialog\`, but the value is not a boolean. Received: ${e.open}`);if("function"!=typeof e.onClose)throw Error(`You provided an \`onClose\` prop to the \`Dialog\`, but the value is not a function. Received: ${e.onClose}`);return(void 0!==r||a)&&!s.static?R.default.createElement(tY,null,R.default.createElement(aM,{show:r,transition:a,unmount:s.unmount},R.default.createElement(aq,{ref:t,...s}))):R.default.createElement(tY,null,R.default.createElement(aq,{ref:t,open:r,...s}))}),{Panel:tz(function(e,t){let a=(0,R.useId)(),{id:r=`headlessui-dialog-panel-${a}`,transition:s=!1,...i}=e,[{dialogState:n,unmount:l},o]=aU("Dialog.Panel"),d=t0(t,o.panelRef),c=(0,R.useMemo)(()=>({open:0===n}),[n]),m=tx(e=>{e.stopPropagation()}),u=s?aR:R.Fragment,h=tO();return R.default.createElement(u,{...s?{unmount:l}:{}},h({ourProps:{ref:d,id:r,onClick:m},theirProps:i,slot:c,defaultTag:"div",name:"Dialog.Panel"}))}),Title:(tz(function(e,t){let{transition:a=!1,...r}=e,[{dialogState:s,unmount:i}]=aU("Dialog.Backdrop"),n=(0,R.useMemo)(()=>({open:0===s}),[s]),l=a?aR:R.Fragment,o=tO();return R.default.createElement(l,{...a?{unmount:i}:{}},o({ourProps:{ref:t,"aria-hidden":!0},theirProps:r,slot:n,defaultTag:"div",name:"Dialog.Backdrop"}))}),tz(function(e,t){let a=(0,R.useId)(),{id:r=`headlessui-dialog-title-${a}`,...s}=e,[{dialogState:i,setTitleId:n}]=aU("Dialog.Title"),l=t0(t);(0,R.useEffect)(()=>(n(r),()=>n(null)),[r,n]);let o=(0,R.useMemo)(()=>({open:0===i}),[i]);return tO()({ourProps:{ref:l,id:r},theirProps:s,slot:o,defaultTag:"h2",name:"Dialog.Title"})})),Description:aa});e.s(["Dialog",0,aV],854878);var aG=/[\\\/_+.#"@\[\(\{&]/,aW=/[\\\/_+.#"@\[\(\{&]/g,aK=/[\s-]/,aY=/[\s-]/g;function aJ(e){return e.toLowerCase().replace(aY," ")}var aQ=e.i(326999),aX=e.i(248425),aZ=e.i(610772),a0=e.i(820783),a1='[cmdk-group=""]',a2='[cmdk-group-items=""]',a5='[cmdk-item=""]',a4=`${a5}:not([aria-disabled="true"])`,a3="cmdk-item-select",a6="data-value",a8=(e,t,a)=>{var r;return r=e,function e(t,a,r,s,i,n,l){if(n===a.length)return i===t.length?1:.99;var o=`${i},${n}`;if(void 0!==l[o])return l[o];for(var d,c,m,u,h=s.charAt(n),x=r.indexOf(h,i),g=0;x>=0;)(d=e(t,a,r,s,x+1,n+1,l))>g&&(x===i?d*=1:aG.test(t.charAt(x-1))?(d*=.8,(m=t.slice(i,x-1).match(aW))&&i>0&&(d*=Math.pow(.999,m.length))):aK.test(t.charAt(x-1))?(d*=.9,(u=t.slice(i,x-1).match(aY))&&i>0&&(d*=Math.pow(.999,u.length))):(d*=.17,i>0&&(d*=Math.pow(.999,x-i))),t.charAt(x)!==a.charAt(n)&&(d*=.9999)),(d<.1&&r.charAt(x-1)===s.charAt(n+1)||s.charAt(n+1)===s.charAt(n)&&r.charAt(x-1)!==s.charAt(n))&&.1*(c=e(t,a,r,s,x+1,n+2,l))>d&&(d=.1*c),d>g&&(g=d),x=r.indexOf(h,x+1);return l[o]=g,g}(r=a&&a.length>0?`${r+" "+a.join(" ")}`:r,t,aJ(r),aJ(t),0,0,{})},a9=R.createContext(void 0),a7=R.createContext(void 0),re=R.createContext(void 0),rt=R.forwardRef((e,t)=>
70{let a=rm(()=>{var t,a;return{search:"",value:null!=(a=null!=(t=e.value)?t:e.defaultValue)?a:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=rm(()=>new Set),s=rm(()=>new Map),i=rm(()=>new Map),n=rm(()=>new Set),l=rd(e),{label:o,children:d,value:c,onValueChange:m,filter:u,shouldFilter:h,loop:x,disablePointerSelection:g=!1,vimBindings:p=!0,...b}=e,f=(0,aZ.useId)(),y=(0,aZ.useId)(),w=(0,aZ.useId)(),v=R.useRef(null),k=rx();rc(()=>{if(void 0!==c){let e=c.trim();a.current.value=e,j.emit()}},[c]),rc(()=>{k(6,T)},[]);let j=R.useMemo(()=>({subscribe:e=>(n.current.add(e),()=>n.current.delete(e)),snapshot:()=>a.current,setState:(e,t,r)=>{var s,i,n,o;if(!Object.is(a.current[e],t)){if(a.current[e]=t,"search"===e)I(),S(),k(1,E);else if("value"===e){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let e=document.getElementById(w);e?e.focus():null==(s=document.getElementById(f))||s.focus()}if(k(7,()=>{var e;a.current.selectedItemId=null==(e=_())?void 0:e.id,j.emit()}),r||k(5,T),(null==(i=l.current)?void 0:i.value)!==void 0){null==(o=(n=l.current).onValueChange)||o.call(n,null!=t?t:"");return}}j.emit()}},emit:()=>{n.current.forEach(e=>e())}}),[]),N=R.useMemo(()=>({value:(e,t,r)=>{var s;t!==(null==(s=i.current.get(e))?void 0:s.value)&&(i.current.set(e,{value:t,keywords:r}),a.current.filtered.items.set(e,C(t,r)),k(2,()=>{S(),j.emit()}))},item:(e,t)=>(r.current.add(e),t&&(s.current.has(t)?s.current.get(t).add(e):s.current.set(t,new Set([e]))),k(3,()=>{I(),S(),a.current.value||E(),j.emit()}),()=>{i.current.delete(e),r.current.delete(e),a.current.filtered.items.delete(e);let t=_();k(4,()=>{I(),(null==t?void 0:t.getAttribute("id"))===e&&E(),j.emit()})}),group:e=>(s.current.has(e)||s.current.set(e,new Set),()=>{i.current.delete(e),s.current.delete(e)}),filter:()=>l.current.shouldFilter,label:o||e["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:f,inputId:w,labelId:y,listInnerRef:v}),[]);function C(e,t){var r,s;let i=null!=(s=null==(r=l.current)?void 0:r.filter)?s:a8;return e?i(e,a.current.search,t):0}function S(){if(!a.current.search||!1===l.current.shouldFilter)return;let e=a.current.filtered.items,t=[];a.current.filtered.groups.forEach(a=>{let r=s.current.get(a),i=0;r.forEach(t=>{i=Math.max(e.get(t),i)}),t.push([a,i])});let r=v.current;A().sort((t,a)=>{var r,s;let i=t.getAttribute("id"),n=a.getAttribute("id");return(null!=(r=e.get(n))?r:0)-(null!=(s=e.get(i))?s:0)}).forEach(e=>{let t=e.closest(a2);t?t.appendChild(e.parentElement===t?e:e.closest(`${a2} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${a2} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{var t;let a=null==(t=v.current)?void 0:t.querySelector(`${a1}[${a6}="${encodeURIComponent(e[0])}"]`);null==a||a.parentElement.appendChild(a)})}function E(){let e=A().find(e=>"true"!==e.getAttribute("aria-disabled")),t=null==e?void 0:e.getAttribute(a6);j.setState("value",t||void 0)}function I(){var e,t,n,o;if(!a.current.search||!1===l.current.shouldFilter){a.current.filtered.count=r.current.size;return}a.current.filtered.groups=new Set;let d=0;for(let s of r.current){let r=C(null!=(t=null==(e=i.current.get(s))?void 0:e.value)?t:"",null!=(o=null==(n=i.current.get(s))?void 0:n.keywords)?o:[]);a.current.filtered.items.set(s,r),r>0&&d++}for(let[e,t]of s.current)for(let r of t)if(a.current.filtered.items.get(r)>0){a.current.filtered.groups.add(e);break}a.current.filtered.count=d}function T(){var e,t,a;let r=_();r&&((null==(e=r.parentElement)?void 0:e.firstChild)===r&&(null==(a=null==(t=r.closest(a1))?void 0:t.querySelector('[cmdk-group-heading=""]'))||a.scrollIntoView({block:"nearest"})),r.scrollIntoView({block:"nearest"}))}function _(){var e;return null==(e=v.current)?void 0:e.querySelector(`${a5}[aria-selected="true"]`)}function A(){var e;return Array.from((null==(e=v.current)?void 0:e.querySelectorAll(a4))||[])}function D(e){let t=A()[e];t&&j.setState("value",t.getAttribute(a6))}function P(e){var t;let a=_(),r=A(),s=r.findIndex(e=>e===a),i=r[s+e];null!=(t=l.current)&&t.loop&&(i=s+e<0?r[r.length-1]:s+e===r.length?r[0]:r[s+e]),i&&j.setState("value",i.getAttribute(a6))}function M(e){let t=_(),a=null==t?void 0:t.closest(a1),r;for(;a&&!r;)r=null==(a=e>0?function(e,t){let a=e.nextElementSibling;for(;a;){if(a.matches(t))return a;a=a.nextElementSibling}}(a,a1):function(e,t){let a=e.previousElementSibling;for(;a;){if(a.matches(t))return a;a=a.previousElementSibling}}(a,a1))?void 0:a.querySelector(a4);r?j.setState("value",r.getAttribute(a6)):P(e)}let F=()=>D(A().length-1),L=e=>{e.preventDefault(),e.metaKey?F():e.altKey?M(1):P(1)},$=e=>{e.preventDefault(),e.metaKey?D(0):e.altKey?M(-1):P(-1)};return R.createElement(aX.Primitive.div,{ref:t,tabIndex:-1,...b,"cmdk-root":"",onKeyDown:e=>{var t;null==(t=b.onKeyDown)||t.call(b,e);let a=e.nativeEvent.isComposing||229===e.keyCode;if(!(e.defaultPrevented||a))switch(e.key){case"n":case"j":p&&e.ctrlKey&&L(e);break;case"ArrowDown":L(e);break;case"p":case"k":p&&e.ctrlKey&&$(e);break;case"ArrowUp":$(e);break;case"Home":e.preventDefault(),D(0);break;case"End":e.preventDefault(),F();break;case"Enter":{e.preventDefault();let t=_();if(t){let e=new Event(a3);t.dispatchEvent(e)}}}}},R.createElement("label",{"cmdk-label":"",htmlFor:N.inputId,id:N.labelId,style:rp},o),rg(e,e=>R.createElement(a7.Provider,{value:j},R.createElement(a9.Provider,{value:N},e))))}),ra=R.forwardRef((e,t)=>
70{var a,r;let s=(0,aZ.useId)(),i=R.useRef(null),n=R.useContext(re),l=R.useContext(a9),o=rd(e),d=null!=(r=null==(a=o.current)?void 0:a.forceMount)?r:null==n?void 0:n.forceMount;rc(()=>{if(!d)return l.item(s,null==n?void 0:n.id)},[d]);let c=rh(s,i,[e.value,e.children,i],e.keywords),m=R.useContext(a7),u=ru(e=>e.value&&e.value===c.current),h=ru(e=>!!d||!1===l.filter()||!e.search||e.filtered.items.get(s)>0);function x(){var e,t;g(),null==(t=(e=o.current).onSelect)||t.call(e,c.current)}function g(){m.setState("value",c.current,!0)}if(R.useEffect(()=>{let t=i.current;if(!(!t||e.disabled))return t.addEventListener(a3,x),()=>t.removeEventListener(a3,x)},[h,e.onSelect,e.disabled]),!h)return null;let{disabled:p,value:b,onSelect:f,forceMount:y,keywords:w,...v}=e;return R.createElement(aX.Primitive.div,{ref:(0,a0.composeRefs)(i,t),...v,id:s,"cmdk-item":"",role:"option","aria-disabled":!!p,"aria-selected":!!u,"data-disabled":!!p,"data-selected":!!u,onPointerMove:p||l.getDisablePointerSelection()?void 0:g,onClick:p?void 0:x},e.children)}),rr=R.forwardRef((e,t)=>{let{heading:a,children:r,forceMount:s,...i}=e,n=(0,aZ.useId)(),l=R.useRef(null),o=R.useRef(null),d=(0,aZ.useId)(),c=R.useContext(a9),m=ru(e=>!!s||!1===c.filter()||!e.search||e.filtered.groups.has(n));rc(()=>c.group(n),[]),rh(n,l,[e.value,e.heading,o]);let u=R.useMemo(()=>({id:n,forceMount:s}),[s]);return R.createElement(aX.Primitive.div,{ref:(0,a0.composeRefs)(l,t),...i,"cmdk-group":"",role:"presentation",hidden:!m||void 0},a&&R.createElement("div",{ref:o,"cmdk-group-heading":"","aria-hidden":!0,id:d},a),rg(e,e=>R.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":a?d:void 0},R.createElement(re.Provider,{value:u},e))))}),rs=R.forwardRef((e,t)=>{let{alwaysRender:a,...r}=e,s=R.useRef(null),i=ru(e=>!e.search);return a||i?R.createElement(aX.Primitive.div,{ref:(0,a0.composeRefs)(s,t),...r,"cmdk-separator":"",role:"separator"}):null}),ri=R.forwardRef((e,t)=>{let{onValueChange:a,...r}=e,s=null!=e.value,i=R.useContext(a7),n=ru(e=>e.search),l=ru(e=>e.selectedItemId),o=R.useContext(a9);return R.useEffect(()=>{null!=e.value&&i.setState("search",e.value)},[e.value]),R.createElement(aX.Primitive.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":o.listId,"aria-labelledby":o.labelId,"aria-activedescendant":l,id:o.inputId,type:"text",value:s?e.value:n,onChange:e=>{s||i.setState("search",e.target.value),null==a||a(e.target.value)}})}),rn=R.forwardRef((e,t)=>{let{children:a,label:r="Suggestions",...s}=e,i=R.useRef(null),n=R.useRef(null),l=ru(e=>e.selectedItemId),o=R.useContext(a9);return R.useEffect(()=>{if(n.current&&i.current){let e=n.current,t=i.current,a,r=new ResizeObserver(()=>{a=requestAnimationFrame(()=>{let a=e.offsetHeight;t.style.setProperty("--cmdk-list-height",a.toFixed(1)+"px")})});return r.observe(e),()=>{cancelAnimationFrame(a),r.unobserve(e)}}},[]),R.createElement(aX.Primitive.div,{ref:(0,a0.composeRefs)(i,t),...s,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":r,id:o.listId},rg(e,e=>R.createElement("div",{ref:(0,a0.composeRefs)(n,o.listInnerRef),"cmdk-list-sizer":""},e)))}),rl=R.forwardRef((e,t)=>{let{open:a,onOpenChange:r,overlayClassName:s,contentClassName:i,container:n,...l}=e;return R.createElement(aQ.Root,{open:a,onOpenChange:r},R.createElement(aQ.Portal,{container:n},R.createElement(aQ.Overlay,{"cmdk-overlay":"",className:s}),R.createElement(aQ.Content,{"aria-label":e.label,"cmdk-dialog":"",className:i},R.createElement(rt,{ref:t,...l}))))}),ro=Object.assign(rt,{List:rn,Item:ra,Input:ri,Group:rr,Separator:rs,Dialog:rl,Empty:R.forwardRef((e,t)=>ru(e=>0===e.filtered.count)?R.createElement(aX.Primitive.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Loading:R.forwardRef((e,t)=>{let{progress:a,children:r,label:s="Loading...",...i}=e;return R.createElement(aX.Primitive.div,{ref:t,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":100,"aria-label":s},rg(e,e=>R.createElement("div",{"aria-hidden":!0},e)))})});function rd(e){let t=R.useRef(e);return rc(()=>{t.current=e}),t}var rc="u"<typeof window?R.useEffect:R.useLayoutEffect;function rm(e){let t=R.useRef();return void 0===t.current&&(t.current=e()),t}function ru(e){let t=R.useContext(a7),a=()=>e(t.snapshot());return R.useSyncExternalStore(t.subscribe,a,a)}function rh(e,t,a,r=[]){let s=R.useRef(),i=R.useContext(a9);return rc(()=>{var n;let l=(()=>{var e;
70for(let t of a){if("string"==typeof t)return t.trim();if("object"==typeof t&&"current"in t)return t.current?null==(e=t.current.textContent)?void 0:e.trim():s.current}})(),o=r.map(e=>e.trim());i.value(e,l,o),null==(n=t.current)||n.setAttribute(a6,l),s.current=l}),s}var rx=()=>{let[e,t]=R.useState(),a=rm(()=>new Map);return rc(()=>{a.current.forEach(e=>e()),a.current=new Map},[e]),(e,r)=>{a.current.set(e,r),t({})}};function rg({asChild:e,children:t},a){let r;return e&&R.isValidElement(t)?R.cloneElement("function"==typeof(r=t.type)?r(t.props):"render"in r?r.render(t.props):t,{ref:t.ref},a(t.props.children)):a(t)}var rp={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};e.s(["Command",0,ro,"CommandGroup",0,rr],770352);var rb=e.i(871689);e.s(["CommandPaletteHeader",0,function(e){let{search:t,setSearch:a,activeCommand:r,stepState:s,onBack:i,inputRef:n,onSearchChange:l}=e,{placeholder:o,type:d}=(0,ev.useCommandPalette)(),{productConfig:c}=(0,eO.useProductSafe)();return(0,A.jsxs)("div",{className:"flex-none",children:[(0,A.jsx)("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-white/[0.08]",children:(0,A.jsx)("h2",{className:"text-sm font-medium text-gray-500 dark:text-white/60",children:r?r.name:"reminder"===d?"Remind me or another team member":`Ask ${c.name} anything`})}),(0,A.jsxs)("div",{className:"flex items-center px-3 border-b border-gray-200 dark:border-white/[0.08]",children:[r?(0,A.jsx)("button",{onClick:i,className:(0,ew.cn)("flex items-center justify-center","w-8 h-8 mr-2","rounded-full","bg-gray-100 dark:bg-white/[0.06] hover:bg-gray-200 dark:hover:bg-white/[0.08]","text-gray-500 dark:text-white/60 hover:text-gray-900 dark:hover:text-white","transition-colors duration-200"),"aria-label":"Go back",children:(0,A.jsx)(rb.ArrowLeft,{className:"w-4 h-4"})}):null,(0,A.jsx)(Z.Search,{className:"w-4 h-4 text-gray-400 dark:text-white/40"}),(0,A.jsx)(ro.Input,{ref:n,value:t,onValueChange:e=>{a(e),l?.(e)},placeholder:r&&s.currentStep?s.currentStep.placeholder:"reminder"===d?"Try: 8am, 3 days, aug 7 or @ivan 3d to remind a teammate":o||"Type a command or search...",className:(0,ew.cn)("w-full py-4 px-3 bg-transparent","text-[17px] text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-white/40","focus:outline-none")}),s.data.recipient&&(0,A.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 ml-auto\n bg-gray-100 dark:bg-white/[0.06] rounded-lg",children:[(0,A.jsx)(e_.Calendar,{className:"w-4 h-4 text-gray-400 dark:text-white/40"}),(0,A.jsx)("span",{className:"text-sm text-gray-600 dark:text-white/80",children:s.data.recipient.name})]})]})]})}],325854);var rf=e.i(639907),ry=e.i(542027),rw=e.i(49748),rv=e.i(420939),rk=e.i(358846),rj=e.i(861593),rN=e.i(307703),rC=e.i(65433);function rS(e,t){(0,rN.default)(2,arguments);var a=(0,rC.default)(e),r=(0,rk.default)(t);return a.setHours(r),a}function rE(e,t){(0,rN.default)(2,arguments);var a=(0,rC.default)(e),r=(0,rk.default)(t);return a.setMinutes(r),a}var rI=e.i(668987);function rT(e,t){(0,rN.default)(2,arguments);var a=t-function(e){return(0,rN.default)(1,arguments),(0,rC.default)(e).getDay()}(e);return a<=0&&(a+=7),(0,rI.default)(e,a)}function r_(e){return(0,rN.default)(1,arguments),rT(e,1)}function rA(e){return(0,rN.default)(1,arguments),rT(e,6)}var rD=e.i(801601),rP=e.i(303293),rR=e.i(897250),rM=e.i(489853),rF=e.i(445433);e.s(["Coffee",()=>rF.default],296139);var rF=rF;function rL({search:e}){let t=(0,R.useMemo)(()=>{let e,t;return e=new Date,t=(0,rw.addDays)(e,1),[{id:"later-today",label:"Later today",date:rS(rE(e,0),Math.max(e.getHours()+3,18)),description:(0,ry.format)(rS(rE(e,0),Math.max(e.getHours()+3,18)),"h:mm a"),icon:rF.default},{id:"tomorrow",label:"Tomorrow",date:rS(rE(t,0),8),description:(0,ry.format)(rS(rE(t,0),8),"EEE, h:mm a"),icon:rR.Sun},{id:"next-week",label:"Next week",date:rS(rE(r_(e),0),8),description:(0,ry.format)(rS(rE(r_(e),0),8),"EEE, MMM d"),icon:rM.CalendarDays},{id:"this-weekend",label:"This weekend",date:rS(rE(rA(e),0),9),description:(0,ry.format)(rS(rE(rA(e),0),9),"EEE, MMM d"),icon:eT.Clock}]},[]),[a,r]=(0,R.useState)(0),{onSelect:s}=(0,ev.useCommandPalette)(),i=(0,R.useMemo)(()=>
70{if(!e?.trim())return null;let t=function(e){let t=e.trim().toLowerCase();if(!t)return null;let a=new Date,r=t.match(/^(\d+)\s*(m|min|mins|minutes?|h|hr|hrs|hours?|d|days?|w|wk|wks|weeks?)$/);if(r){let e=parseInt(r[1]),t=r[2][0];if("m"===t)return function(e,t){(0,rN.default)(2,arguments);var a=(0,rk.default)(t);return(0,rj.default)(e,6e4*a)}(a,e);if("h"===t)return function(e,t){(0,rN.default)(2,arguments);var a=(0,rk.default)(t);return(0,rj.default)(e,36e5*a)}(a,e);if("d"===t)return rS(rE((0,rw.addDays)(a,e),0),8);if("w"===t)return rS(rE((0,rv.addWeeks)(a,e),0),8)}let s=t.match(/^(\d{1,2})(?::(\d{2}))?\s*(am|pm)?$/);if(s){let e=parseInt(s[1]),t=s[2]?parseInt(s[2]):0,r=s[3];"pm"===r&&e<12&&(e+=12),"am"===r&&12===e&&(e=0);let i=rS(rE(a,t),e);return i<=a&&(i=(0,rw.addDays)(i,1)),i}let i={sun:0,sunday:0,mon:1,monday:1,tue:2,tuesday:2,wed:3,wednesday:3,thu:4,thursday:4,fri:5,friday:5,sat:6,saturday:6};if(void 0!==i[t]){let e=i[t]-a.getDay();return e<=0&&(e+=7),rS(rE((0,rw.addDays)(a,e),0),8)}if("tonight"===t||"evening"===t)return rS(rE(a,0),18);if("noon"===t||"midday"===t){let e=rS(rE(a,0),12);return e<=a&&(e=(0,rw.addDays)(e,1)),e}let n=(0,rD.parse)(t,"MMM d",a);if((0,rP.isValid)(n)){let e=rS(rE(n,0),8);return e<=a&&(e=(0,rw.addDays)(e,365)),e}let l=(0,rD.parse)(t,"M/d",a);if((0,rP.isValid)(l)){let e=rS(rE(l,0),8);return e<=a&&(e=(0,rw.addDays)(e,365)),e}return null}(e);return t?{id:"custom",label:e.trim(),date:t,description:(0,ry.format)(t,"EEE, MMM d, h:mm a"),icon:eT.Clock}:null},[e]),n=(0,R.useMemo)(()=>{if(!e?.trim())return t;let a=t.filter(t=>t.label.toLowerCase().includes(e.toLowerCase()));return i?[i,...a]:a.length>0?a:t},[e,i,t]);(0,R.useEffect)(()=>{r(0)},[n]);let l=e=>{s?.({type:"reminder",date:e.date,label:e.label})};return(0,R.useEffect)(()=>{let e=e=>{if("ArrowUp"===e.key)e.preventDefault(),r(e=>e>0?e-1:n.length-1);else if("ArrowDown"===e.key)e.preventDefault(),r(e=>e<n.length-1?e+1:0);else if("Enter"===e.key){e.preventDefault();let t=n[a];t&&l(t)}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a,n]),(0,A.jsxs)("div",{className:"p-1.5",children:[i&&e?.trim()&&(0,A.jsx)("div",{className:"px-2 pb-1.5 pt-1",children:(0,A.jsx)("span",{className:"text-[11px] font-medium uppercase tracking-wider text-gray-400 dark:text-white/30",children:"Parsed"})}),n.map((e,t)=>{let r=e.icon;return(0,A.jsxs)("button",{onClick:()=>l(e),className:(0,ew.cn)("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors",a===t?"bg-gray-100 dark:bg-white/[0.08]":"hover:bg-gray-50 dark:hover:bg-white/[0.04]"),children:[(0,A.jsx)(r,{className:(0,ew.cn)("w-4 h-4 flex-shrink-0",a===t?"text-gray-700 dark:text-white/80":"text-gray-400 dark:text-white/40")}),(0,A.jsx)("span",{className:(0,ew.cn)("text-sm font-medium flex-1 text-left",a===t?"text-gray-900 dark:text-white":"text-gray-700 dark:text-white/80"),children:e.label}),(0,A.jsx)("span",{className:"text-xs text-gray-400 dark:text-white/40",children:e.description})]},e.id)}),e?.trim()&&!i&&0===n.length&&(0,A.jsx)("div",{className:"px-3 py-4 text-center text-sm text-gray-400 dark:text-white/40",children:"Couldn't parse that. Try: 3h, 2d, 8am, monday, aug 7"})]})}var r$=e.i(922037),rO=e.i(694351),rU=e.i(263457),rB=e.i(178583),rq=e.i(761911),rz=e.i(260289),rH=e.i(834161),rV=e.i(373884),rG=e.i(688511),rW=e.i(98962),rK=e.i(466261),rY=e.i(269638),rJ=e.i(342920),rQ=e.i(26512),rX=e.i(561659),rZ=e.i(626805),rZ=rZ,r0=e.i(88081),r1=e.i(270756),r2=e.i(263488),r5=e.i(801073),r4=e.i(343432),r3=e.i(350627),r6=e.i(16715),r8=e.i(870273),r9=e.i(879002),r7=e.i(153305);let se={Plus:ea.Plus,Home:rO.Home,Calendar:e_.Calendar,CalendarRange:rU.CalendarRange,MessageSquare:eE.MessageSquare,FileText:rB.FileText,Users:rq.Users,Settings:et.Settings,Tag:eK.Tag,LayoutDashboard:rz.LayoutDashboard,Search:Z.Search,Clock:eT.Clock,Check:em.Check,Key:rH.Key,X:ei.X,XCircle:rV.XCircle,Edit:rG.Edit,UserX:rW.UserX,AlertTriangle:es.AlertTriangle,ExternalLink:eS.ExternalLink,ArrowRightLeft:rK.ArrowRightLeft,CheckCircle:rY.CheckCircle,Building:rJ.Building,ClipboardPlus:rQ.ClipboardPlus,CreditCard:rX.CreditCard,GitMerge:rZ.default,Hash:r0.Hash,Lock:r1.Lock,Mail:r2.Mail,PauseCircle:r5.PauseCircle,Phone:r4.Phone,Receipt:r3.Receipt,RefreshCw:r6.RefreshCw,Star:r8.Star,UserPlus:r9.UserPlus,Webhook:r7.Webhook};var st=e.i(85507);function sa({filteredCommands:e,selectedIndex:t,search:a,renderExtraSections:r}){let s,{closeCommandPalette:i}
70=(0,ev.useCommandPalette)(),{productConfig:n,productNavKeys:l}=(0,eO.useProductSafe)(),o=(s={},e.reminders?.length&&(s.Reminders=e.reminders),e.create?.length&&(s.Create=e.create),e.navigation?.length&&(s.Navigation=e.navigation),e.general?.length&&(s.General=e.general),e.reservations?.length&&(s.Reservations=e.reservations.map(e=>({id:String(e.id),name:e.name,description:e.description||"",icon:e.icon||void 0,shortcut:e.shortcut||void 0,configuration:e.configuration,action:e.action||{type:"direct",topic:"reservation",event:e.configuration?.type,payload:{}},contexts:e.contexts}))),e.messages&&(e.messages.guest?.length&&(s["Guest Messages"]=e.messages.guest),e.messages.team?.length&&(s["Team Messages"]=e.messages.team),e.messages.thread?.length&&(s["Thread Actions"]=e.messages.thread),e.messages.contact?.length&&(s["Contact Messages"]=e.messages.contact),e.messages.channel?.length&&(s["Channel Actions"]=e.messages.channel)),s);if(l.length>0&&o.Navigation&&(o.Navigation=o.Navigation.filter(e=>{let t=e.action?.url||"";return l.some(e=>t===`/${e}`||t.startsWith(`/${e}/`)||"/"===t)})),!Object.values(o).some(e=>Array.isArray(e)&&e.length>0)){let e=a?.trim();return e?(0,A.jsxs)(A.Fragment,{children:[r?.({hasCommands:!1}),(0,A.jsx)(ro.Group,{heading:n.name,className:(0,ew.cn)("pb-2","[&>[cmdk-group-heading]]:text-xs","[&>[cmdk-group-heading]]:font-medium","[&>[cmdk-group-heading]]:text-gray-500 [&>[cmdk-group-heading]]:dark:text-white/40","[&>[cmdk-group-heading]]:px-2","[&>[cmdk-group-heading]]:pb-1"),children:(0,A.jsxs)(ro.Item,{value:"vanio-ai-ask",onSelect:()=>{i(),window.dispatchEvent(new CustomEvent("vanio-chat:open",{detail:{query:e}}))},className:(0,ew.cn)("flex items-center px-3 py-2.5","text-sm text-gray-600 dark:text-white/80 cursor-pointer","hover:bg-gray-100 dark:hover:bg-white/[0.08]",0===t&&"bg-gray-50 dark:bg-white/[0.06]"),children:[(0,A.jsxs)("div",{className:"flex items-center gap-2.5 flex-1",children:[(0,A.jsx)("div",{className:"flex items-center justify-center w-6 h-6",children:(0,A.jsx)(X.default,{src:n.logo,alt:n.name,width:18,height:18,className:"rounded-sm"})}),(0,A.jsxs)("span",{children:["Ask ",n.name,": ",(0,A.jsxs)("span",{className:"text-gray-500 dark:text-white/50",children:['"',e,'"']})]})]}),(0,A.jsx)("span",{className:"text-gray-400 dark:text-white/30 text-xs ml-auto hidden md:inline",children:"Opens chat sidebar"})]})})]}):(0,A.jsxs)("div",{className:"px-4 py-8 text-center",children:[(0,A.jsx)("div",{className:"text-gray-400 dark:text-white/40 text-sm mb-2",children:"No matching commands found"}),(0,A.jsxs)("div",{className:"text-gray-500 dark:text-white/60 text-xs",children:["Try a different search term or press ",(0,A.jsx)("kbd",{className:"px-1.5 py-0.5 bg-gray-100 dark:bg-white/10 rounded text-xs",children:"Esc"})," to clear"]})]})}let d=0,c=a?.trim();return(0,A.jsxs)(A.Fragment,{children:[Object.entries(o).map(([e,a])=>a?.length?(0,A.jsx)(ro.Group,{heading:e,className:(0,ew.cn)("pb-2","[&>[cmdk-group-heading]]:text-xs","[&>[cmdk-group-heading]]:font-medium","[&>[cmdk-group-heading]]:text-gray-500 [&>[cmdk-group-heading]]:dark:text-white/40","[&>[cmdk-group-heading]]:px-2","[&>[cmdk-group-heading]]:pb-1"),children:a.map(e=>{var a,r;let s,i=(a=e,r=d,a.action?.metadata?.listing?(0,A.jsx)(ro.Item,{value:a.id,"data-command-id":a.id,"data-index":r,"data-selected":t===r,className:(0,ew.cn)("px-3 py-2","cursor-pointer","hover:bg-gray-100 dark:hover:bg-white/[0.08]",t===r&&"bg-gray-50 dark:bg-white/[0.06]"),children:(0,A.jsx)("div",{className:"flex items-center gap-2",children:(0,A.jsx)("div",{className:"flex-1",children:(0,A.jsx)(st.ReservationListing,{data:{listing:a.action.metadata.listing,host:a.action.metadata.host}})})})},a.id):(0,A.jsxs)(ro.Item,{value:a.id,"data-command-id":a.id,"data-index":r,"data-selected":t===r,onSelect:()=>{let e=new CustomEvent("command-select",{detail:{command:a}});document.dispatchEvent(e)},className:(0,ew.cn)("flex items-center px-3 py-2","text-sm text-gray-600 dark:text-white/80 cursor-pointer","hover:bg-gray-100 dark:hover:bg-white/[0.08]",t===r&&"bg-gray-50 dark:bg-white/[0.06]"),children:[(0,A.jsxs)("div",{className:"flex items-center gap-2 flex-1",children:[a.icon&&(0,A.jsx)("div",{className:"flex items-center justify-center w-6 h-6",children:"string"==typeof a.icon?(s=se[a.icon])?(0,A.jsx)(s,{className:"w-4 h-4 text-gray-500 dark:text-white/60"}):null:(0,A.jsx)(a.icon,{className:"w-4 h-4 text-gray-500 dark:text-white/60"})}),(0,A.jsx)("span",{children:a.name})]}),a.description&&(0,A.jsx)("span",{className:"text-gray-400 dark:text-white/40 ml-2 hidden md:inline",children:a.description}),a.configuration?.setupHint&&(0,A.jsx)("span",{className:"text-[10px] text-amber-500/70 ml-2 hidden lg:inline",children:"âï¸ Setup required"}),a.shortcut&&(0,A.jsx)("div",{className:"flex-shrink-0 ml-auto hidden md:block",children:(0,A.jsx)(r$.KeyboardShortcut,{children:a.shortcut})})]},a.id));return d++,i})},e):null),r?.({hasCommands:!0}),c&&(0,A.jsx)(ro.Group,{heading:n.name,className:(0,ew.cn)("pb-2 border-t border-gray-200 dark:border-white/[0.06] pt-1","[&>[cmdk-group-heading]]:text-xs","[&>[cmdk-group-heading]]:font-medium","[&>[cmdk-group-heading]]:text-gray-500 [&>[cmdk-group-heading]]:dark:text-white/40","[&>[cmdk-group-heading]]:px-2","[&>[cmdk-group-heading]]:pb-1"),children:(0,A.jsx)(ro.Item,{value:"vanio-ai-ask",onSelect:()=>{i(),window.dispatchEvent(new CustomEvent("vanio-chat:open",{detail:{query:c}}))},className:(0,ew.cn)("flex items-center px-3 py-2","text-sm text-gray-600 dark:text-white/80 curs
70or-pointer","hover:bg-gray-100 dark:hover:bg-white/[0.08]"),children:(0,A.jsxs)("div",{className:"flex items-center gap-2.5 flex-1",children:[(0,A.jsx)("div",{className:"flex items-center justify-center w-6 h-6",children:(0,A.jsx)(X.default,{src:n.logo,alt:n.name,width:18,height:18,className:"rounded-sm"})}),(0,A.jsxs)("span",{children:["Ask ",n.name,": ",(0,A.jsxs)("span",{className:"text-gray-500 dark:text-white/50",children:['"',c,'"']})]})]})})})]})}var sr=e.i(678745),sr=sr,sr=sr,ss=e.i(911794),si=e.i(594436);function sn({stepState:e,selectedIndex:t,selectedId:a,onSuggestionClick:r,search:s,showCountBadge:i=!1,onCountChange:n,onLoadingChange:l,hideLoadingSpinner:o=!1,limitResults:d=50,hideWhenEmpty:c=!1}){let{currentCustomerId:m}=(0,e8.useCustomer)(),[u,h]=R.default.useState([]),[x,g]=R.default.useState(!1),{groups:p,isLoading:b,error:f,truncated:y}=(0,ss.useListings)(s?void 0:m||void 0,{limit:200,activeOnly:!0}),w=R.default.useMemo(()=>{let t=e.data?.reservation||e.metadata?.reservation,a=t?.listingId||t?.listing?.id||t?.platform?.listingId;return a?Number(a):void 0},[e]);R.default.useEffect(()=>{if(!s||!m||(0,si.normalizeSearchQuery)(s).length<2){h([]),g(!1);return}let e=!0;g(!0);let t=setTimeout(async()=>{try{let t=await fetch(`/api/listings?customerId=${m}&query=${encodeURIComponent(s)}&withGroups=false&activeOnly=true`);if(!t.ok)throw Error("Search failed");let a=await t.json();e&&h(Array.isArray(a)?a:[])}catch(t){console.error("Listings search error:",t),e&&h([])}finally{e&&g(!1)}},300);return()=>{e=!1,clearTimeout(t)}},[s,m]);let v=s?x:b,k=R.default.useMemo(()=>(0,si.normalizeSearchQuery)(s),[s]),j=R.default.useMemo(()=>s&&u.length>0?[{id:"search-results",name:"Listings",listings:u.slice(0,d)}]:!s&&p?p:[],[s,u,p,d]),N=R.default.useMemo(()=>j.reduce((e,t)=>e+t.listings.length,0),[j]);return(R.default.useEffect(()=>{n&&n(N)},[N,n]),R.default.useEffect(()=>{l&&l(v)},[v,l]),v&&!o)?(0,A.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,A.jsx)(rf.Spinner,{className:"w-6 h-6"})}):v&&o&&!j.length?null:f?(0,A.jsxs)("div",{className:"px-4 py-3 text-sm text-red-400",children:["Failed to load listings: ",f]}):c&&!j.length?null:j.length||v?(0,A.jsxs)("div",{className:"space-y-2",children:[!s&&y&&(0,A.jsxs)("div",{className:"px-4 py-2 text-xs text-gray-500 dark:text-white/40",children:["Showing the first ",200," properties â type to search all of them."]}),j.map(s=>(0,A.jsx)(ro.Group,{heading:s.name,className:(0,ew.cn)("pb-2","[&>[cmdk-group-heading]]:text-xs","[&>[cmdk-group-heading]]:font-medium","[&>[cmdk-group-heading]]:text-gray-500 [&>[cmdk-group-heading]]:dark:text-white/40","[&>[cmdk-group-heading]]:px-2","[&>[cmdk-group-heading]]:pb-1"),children:s.listings.map((s,i)=>{let n=(0,si.listingDisplayName)(s,k),l={id:s.id.toString(),name:n,label:n,metadata:{listing:{id:s.id,name:n,location:{city:s.city,address:s.city},thumbnail:s.thumbnail,details:{},businessDetails:s.businessDetails}}},o=w===Number(s.id),d=e.data[e.currentStep?.id||""]?.selections?.some(e=>e.id===l.id);return(0,A.jsx)(ro.Item,{value:l.id,"data-suggestion-id":l.id,"data-index":i,"data-selected":t===i,onSelect:()=>r(l),className:(0,ew.cn)("flex items-center gap-3 px-4 py-2","transition-colors duration-200",!o&&"cursor-pointer hover:bg-gray-50 dark:hover:bg-white/[0.06]",o&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-white/[0.02]",t===i&&"bg-gray-50 dark:bg-white/[0.06]",a===l.id&&"bg-gray-100 dark:bg-white/[0.08]",d&&"bg-gray-100 dark:bg-white/[0.12]"),children:(0,A.jsxs)("div",{className:"flex items-center gap-2 w-full relative",children:[d&&(0,A.jsx)("div",{className:"absolute left-2",children:(0,A.jsx)(sr.default,{className:"w-4 h-4 text-blue-400"})}),o&&(0,A.jsx)("div",{className:"absolute right-3 bg-gray-100 dark:bg-white/10 px-2 py-0.5 rounded text-xs",children:"Current listing"}),(0,A.jsx)("div",{className:(0,ew.cn)("flex-1",d&&"pl-6"),children:(0,A.jsx)(st.ReservationListing,{data:{listing:{...l.metadata?.listing,businessDetails:s.businessDetails}},compact:!0,showActionButtons:!1,enableLinks:!1})})]})},l.id)})},s.id))]}):(0,A.jsxs)("div",{className:"px-4 py-3",children:[(0,A.jsx)("div",{className:"text-sm text-gray-500 dark:text-white/60",children:s?"No listings match your search":"No listings available"}),s&&(0,A.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/40 mt-1",children:"Try adjusting your search terms"})]})}e.s(["INLINE_LISTING_CAP",0,5,"ListingSuggestions",0,sn,"resolveBareListingQuery",0,function(e,t){return t||!e||e.startsWith("/")||e.startsWith(">")?"":(0,si.normalizeSearchQuery)(e).length>=2?e.trim():""}],910183);var sr=sr;function sl(e){if(e.includes("T")&&(e.includes("Z")||e.includes("+")||e.includes("-")))return new Date(e);if(e.match(/^\d{4}-\d{2}-\d{2}$/)){let[t,a,r]=e.split("-").map(Number);return new Date(t,a-1,r)}return new Date(e)}function so({guestName:e,confirmationCode:t,listingName:a,listingThumbnail:r,checkIn:s,checkOut:i,className:n,onClick:l}){let o,d,c,m;return(0,A.jsxs)("div",{onClick:e=>{l&&(e.stopPropagation(),l(e))},className:(0,ew.cn)("flex items-center gap-4 px-4 py-1.5","rounded-xl cursor-pointer transition-colors duration-200",n),children:[(0,A.jsx)("div",{className:"relative w-12 h-12 rounded-lg overflow-hidden flex-shrink-0 bg-gray-800",children:r?(0,A.jsx)(X.default,{src:r,alt:a||"Listing",fill:!0,sizes:"(max-width: 768px) 48px, 48px",className:"object-cover"}):(0,A.jsx)("div",{className:"w-full h-full bg-gray-800"})}),(0,A.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,A.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,A.jsx)("h3",{className:"font-medium text-gray-900 dark:text-white truncate",children:e}),(0,A.jsx)("span",{className:"text-sm text-gray-400 dark:text-white/40",children:t})]}),(a||s&&i)&&(0,A.jsxs)("div",{className:"text-sm text-gray-400 dark:text-white/60 truncate",children:[a&&(0,A.jsx)("span",{children:a}),a&&s&&i&&(0,A.jsx)("span",{className:"mx-1",children:"â¢"}),s&&i&&(0,A.jsx)("span",{children:(o=sl(s),d=sl(i),c=(0,ry.format)(o,"MMM d"),m=(0,ry.format)(d,"MMM d"),`${c} - ${m}`)})]})]})]})}var sd=e.i(952999);function sc(e=[]){return Array.isArray(e)?e.map(e=>({id:e.id.toString(),name:e.guestName,description:e.listingName,type:"reservation",value:e.id,icon:"calendar",shortcut:null,groupName:"Reservations",contexts:[],configuration:{},label:e.guestName,metadata:{confirmationCode:e.confirmationCode,guestId:e.guestId,listingId:e.listingId,guestContact:e.guestContact,checkIn:e.checkIn,checkOut:e.checkOut,thumbnail:e.listingThumbnail,reservationContext:{id:e.id,confirmationCode:e.confirmationCode,guestName:e.guestName,guestId:e.guestId,listingId:e.listingId,listingName:e.listingName,checkIn:e.checkIn,checkOut:e.checkOut}}})):[]}let sm=(0,R.createContext)(void 0),su=()=>{let e=(0,R.useContext)(sm);if(void 0===e)throw Error("useStepFooter must be used within a StepFooterProvider");return e};function sh({suggestions:e,stepState:t,selectedIndex:a,selectedId:r,search:s="",onSuggestionClick:i,isSearch:n=!1,commandType:l,onStepProgression:o,showCountBadge:d=!1,limitResults:c,onCountChange:m,onLoadingChange:u,hideLoadingSpinner:h=!1}){let{registerFooter:x,unregisterFooter:g}=su(),[p,b]=(0,R.useState)(!1),f=t?.data?.listing||t?.metadata?.listing,y=f?.id,w=l?.includes("task")||t?.type?.includes("task"),{query:v,setQuery:k,results:j,isLoading:N}=function(e,t){let[a,r]=(0,R.useState)(""),[s,i]=(0,R.useState)([]),[n,l]=(0,R.useState)(!1),o=(0,sd.useDebounce)(a,200),{data:d}=(0,P.useSession)();return(0,R.useEffect)(()=>{let a=!0;async function r(){l(!0);try{let r;if(e){(r=new URL("/api/reservations",window.location.origin)).searchParams.set("listingIds",e.toString()),r.searchParams.set("limit","10"),t||r.searchParams.set("mode","current"),o&&r.searchParams.set("q",o),d?.user?.id&&r.searchParams.set("userId",d.user.id);let s=await fetch(r.toString()),n=await s.json(),l=Array.isArray(n.reservations)?n.reservations:[];if(o&&l.length>0){let e=o.toLowerCase();l=l.filter(t=>t.guestName?.toLowerCase().includes(e)||t.confirmationCode?.toLowerCase().includes(e)||t.listingName?.toLowerCase().includes(e)||t.id?.toString()===o.trim())}l=l.map(e=>({id:e.id.toString(),guestName:e.guestDetails?.name||e.guestName||"Unknown Guest",listingName:e.listingDetails?.name||e.listingName||"Unknown Listing",listingThumbnail:e.listingDetails?.thumbnailUrl||e.listingThumbnail,checkIn:e.checkIn,checkOut:e.checkOut,status:e.status,guestId:e.guestDetails?.id?.toString()||e.guestId?.toString()||"0",listingId:e.listingDetails?.id?.toString()||e.listingId?.toString()||"0",confirmationCode:e.confirmationCode,dashboardItemId:e.dashboardItemId}));let c=sc(l);a&&i(c)}
70else{r=new URL(o?"/api/search/reservations":"/api/search/reservations?current=true",window.location.origin),o&&r.searchParams.set("q",o),d?.user?.id&&r.searchParams.set("userId",d.user.id);let e=await fetch(r.toString()),t=await e.json(),s=Array.isArray(t.results)?t.results:t.results?.results||[],n=sc(s);a&&i(n)}}catch(e){console.error("[useReservationSearch] ERROR:",e),a&&i([])}finally{a&&l(!1)}}return(e||void 0!==o)&&r(),()=>{a=!1}},[e,o,d?.user?.id]),{query:a,setQuery:r,results:s,isLoading:n}}(w&&y?y:void 0,w),C=(0,eP.useDashboard)(),{closeCommandPalette:S}=(0,ev.useCommandPalette)(),E=(0,R.useRef)(t),I=(0,R.useRef)(o),T=(0,R.useRef)(i),_=(0,R.useRef)(f);E.current=t,I.current=o,T.current=i,_.current=f,(0,R.useEffect)(()=>{s!==v&&k(s)},[s,v,k]),(0,R.useEffect)(()=>{m&&m(j.length)},[j.length,m]),(0,R.useEffect)(()=>{u&&u(N)},[N,u]);let D=(0,R.useMemo)(()=>w&&t.currentStep&&!n?(0,A.jsx)("div",{className:"p-4",children:(0,A.jsx)("div",{className:"flex items-center justify-center",children:(0,A.jsx)("button",{onClick:()=>{let e=E.current.currentStep;if(!e)return;let t={id:"skip-reservation",name:"Skip - No reservation",label:"Create task without linking to a specific reservation",metadata:{skipped:!0,listingId:_.current?.id}};if(I.current){let a={...E.current,data:{...E.current.data,[e.id]:t,reservation:{id:"skip-reservation",skipped:!0}},history:[...E.current.history,e.id]};I.current(a)}else T.current&&T.current(t)},className:(0,ew.cn)("px-4 py-2 rounded-md","bg-gray-50 dark:bg-white/[0.04] hover:bg-gray-100 dark:hover:bg-white/[0.08]","text-sm text-gray-600 dark:text-white/80 font-medium","transition-colors duration-200","border border-gray-200 dark:border-white/[0.08]"),children:"Skip - Create task without reservation"})})}):null,[w,t.currentStep?.id,n]);(0,R.useEffect)(()=>{if(D)return x(D),()=>{g()}},[D,x,g]);let M=e=>{if(n){let t=e.metadata?.dashboardItemId,a=e.metadata?.reservationId||e.id;try{t?C.openModal(Number(t)):a&&C.openModalByReservation(String(a)),S()}catch(e){console.error("[ReservationSuggestions] Error opening dashboard:",e)}}else i&&i(e)},F=(0,R.useMemo)(()=>!c||p?j:j.slice(0,c),[j,c,p]),L=c&&j.length>c,$=L?j.length-c:0;return N&&!h?(0,A.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,A.jsx)(rf.Spinner,{className:"w-6 h-6"})}):N&&h&&0===j.length?null:(0,A.jsx)(ro.Group,{heading:t.currentStep?.heading||"Select a reservation",className:(0,ew.cn)("pb-2","[&>[cmdk-group-heading]]:text-xs","[&>[cmdk-group-heading]]:font-medium","[&>[cmdk-group-heading]]:text-gray-500 [&>[cmdk-group-heading]]:dark:text-white/40","[&>[cmdk-group-heading]]:px-2","[&>[cmdk-group-heading]]:pb-1"),children:0!==j.length||N?j.length>0?(0,A.jsxs)(A.Fragment,{children:[F.map((e,s)=>{let i=t.data[t.currentStep?.id||""]?.selections?.some(t=>t.id===e.id);return(0,A.jsx)(ro.Item,{value:e.id,"data-suggestion-id":e.id,"data-index":s,"data-selected":a===s,onSelect:()=>M(e),className:(0,ew.cn)("flex items-center gap-3 px-4 py-3 rounded-lg","transition-colors duration-200","cursor-pointer","hover:bg-gray-50 dark:hover:bg-white/[0.06]",a===s&&"bg-gray-50 dark:bg-white/[0.06]",r===e.id&&"bg-gray-100 dark:bg-white/[0.08]",i&&"bg-gray-100 dark:bg-white/[0.12]"),children:(0,A.jsxs)("div",{className:"flex items-center gap-2 w-full",children:[i&&(0,A.jsx)("div",{className:"absolute left-2",children:(0,A.jsx)(sr.default,{className:"w-4 h-4 text-blue-400"})}),(0,A.jsx)("div",{className:(0,ew.cn)("flex-1",i&&"pl-6"),children:(0,A.jsx)(so,{guestName:e.name,confirmationCode:e.metadata?.confirmationCode,listingName:e.description||"",listingThumbnail:e.metadata?.thumbnail,checkIn:e.metadata?.checkIn,checkOut:e.metadata?.checkOut,onClick:()=>M(e)})})]})},e.id)}),L&&!p&&(0,A.jsx)("div",{className:"px-4 py-2 flex justify-center",children:(0,A.jsxs)("button",{onClick:()=>b(!0),className:(0,ew.cn)("px-3 py-2 rounded-lg","bg-gray-50 dark:bg-white/[0.04] hover:bg-gray-100 dark:hover:bg-white/[0.08]","text-sm text-gray-500 dark:text-white/60 font-medium","transition-colors duration-200","border border-gray-200 dark:border-white/[0.08]"),children:["Show ",$," more reservation",1!==$?"s":""]})})]}):null:(0,A.jsxs)("div",{className:"px-4 py-3",children:[(0,A.jsx)("div",{className:"text-sm text-gray-500 dark:text-white/60",children:s?`No reservations foun
70d for "${s}"`:f?`No current reservations found for ${f.name||"this listing"}`:"No reservations found"}),s&&(0,A.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/40 mt-1",children:"Try adjusting your search terms"})]})})}e.s(["StepFooterProvider",0,({children:e})=>{let[t,a]=(0,R.useState)(null),r=(0,R.useCallback)(e=>{a(e)},[]),s=(0,R.useCallback)(()=>{a(null)},[]);return(0,A.jsx)(sm.Provider,{value:{footerComponent:t,registerFooter:r,unregisterFooter:s},children:e})},"useStepFooter",0,su],134969),e.s(["ReservationSuggestions",0,sh],724338);var sx=e.i(212426),sg=e.i(63209),sp=e.i(811998);let sb=e=>{if(null==e)return 0;if("number"==typeof e)return isNaN(e)?0:e;if("string"==typeof e){let t=parseFloat(e);return isNaN(t)?0:t}return 0},sf=e=>(e||[]).reduce((e,t)=>e+sb(t?.amount),0);function sy(e,t){return"vrbo"!==(t||"").toLowerCase()?0:sb(e?.host_fee)}function sw(e,t){let a=sb(e?.base_price)+sb(e?.cleaning_fee)+sb(e?.pet_fee)+sb(e?.extra_guest_fee)+sb(e?.service_fee)+sb(e?.platform_fee)+sb(e?.totalTaxes)+sf(e?.addOns)-sf(e?.discounts);return{total:a,hostPayout:a-sb(e?.processing_fee)-sy(e,t)}}function sv({stepState:e,selectedIndex:t,selectedId:a,search:r,reservation:s,onSelect:i,onBack:n,onError:l}){let o,[d,c]=(0,R.useState)({dates:{enabled:!1,checkIn:"",checkOut:"",checkInTime:"",checkOutTime:""},guestCount:{enabled:!1,total:1,adults:1,children:0,infants:0,pets:0},pricing:{enabled:!1,total:0,host_payout:0,currency:"USD",base_price:0,cleaning_fee:0,pet_fee:0,extra_guest_fee:0,service_fee:0,platform_fee:0,host_fee:0,host_fee_vat:0,processing_fee:0,totalTaxes:0,discounts:[],addOns:[]}});(0,R.useEffect)(()=>{if(s){let e=e=>{if(!e)return"";if(e.match(/^\d{4}-\d{2}-\d{2}$/))return e;if(e.includes("T"))return e.split("T")[0];try{let t=new Date(e+"T00:00:00");return(0,ry.format)(t,"yyyy-MM-dd")}catch{return""}},t={dates:{enabled:!1,checkIn:e(s.dates?.checkIn||""),checkOut:e(s.dates?.checkOut||""),checkInTime:s.dates?.checkInTime||"15:00",checkOutTime:s.dates?.checkOutTime||"11:00"},guestCount:{enabled:!1,total:s.guests?.total||1,adults:s.guests?.adults||1,children:s.guests?.children||0,infants:s.guests?.infants||0,pets:s.guests?.pets||0},pricing:{enabled:!1,total:s.pricing?.totals?.total||0,host_payout:s.pricing?.totals?.hostPayout||0,currency:s.pricing?.totals?.currency||"USD",base_price:s.pricing?.base?.amount||0,cleaning_fee:s.pricing?.fees?.cleaning||0,pet_fee:s.pricing?.fees?.pet||0,extra_guest_fee:s.pricing?.fees?.extraGuest||0,service_fee:s.pricing?.fees?.service||0,platform_fee:s.pricing?.fees?.platform||0,host_fee:s.pricing?.fees?.host||0,host_fee_vat:s.pricing?.fees?.host_fee_vat||0,processing_fee:s.pricing?.fees?.processing||0,totalTaxes:s.pricing?.totals?.totalTaxes||0,discounts:(s.pricing?.discounts||[]).map(e=>({name:e.name||"Discount",amount:e.amount||0,type:e.type||"promotional"})),addOns:(s.pricing?.addOns||[]).map(e=>({name:e.name||"Add-on",amount:e.amount||0,description:e.description||""}))}};c(e=>({...e,...t}))}},[s]);let m=(0,R.useCallback)(()=>d.pricing.enabled?sw(d.pricing).total:Number(d.pricing.total||0),[d.pricing]),u=(0,R.useRef)(null),h=(0,R.useRef)(null),x="string"==typeof s?.platform?s.platform:s?.platform?.source??null;(0,R.useEffect)(()=>{if(!d.pricing.enabled){u.current=null,h.current=null;return}let e=Number(d.pricing.processing_fee||0),t=Number.isFinite(e)?e:0,{total:a,hostPayout:r}=sw({...d.pricing,processing_fee:t},x),s=null!==u.current&&u.current!==t;u.current=t;let i=sy(d.pricing,x),n=Number.isFinite(i)?i:0,l=null!==h.current&&h.current!==n;
70h.current=n,(a!==d.pricing.total||s||l)&&c(e=>({...e,pricing:{...e.pricing,total:a,host_payout:r}}))},[d.pricing.enabled,d.pricing.base_price,d.pricing.cleaning_fee,d.pricing.pet_fee,d.pricing.extra_guest_fee,d.pricing.service_fee,d.pricing.platform_fee,d.pricing.host_fee,d.pricing.host_fee_vat,d.pricing.processing_fee,d.pricing.totalTaxes,d.pricing.total,m,x]);let g=d.dates.enabled||d.guestCount.enabled||d.pricing.enabled;return(0,R.useMemo)(()=>!!g&&(!d.pricing.enabled||!(d.pricing.base_price<0)&&!(d.pricing.cleaning_fee<0)&&!(d.pricing.pet_fee<0)&&!(d.pricing.extra_guest_fee<0)&&!(d.pricing.service_fee<0)&&!(d.pricing.platform_fee<0)&&!(d.pricing.host_fee<0)&&!(d.pricing.host_fee_vat<0)&&!(d.pricing.processing_fee<0)&&!(d.pricing.totalTaxes<0))&&!0,[g,d.pricing.enabled,d.pricing.base_price,d.pricing.cleaning_fee,d.pricing.pet_fee,d.pricing.extra_guest_fee,d.pricing.service_fee,d.pricing.platform_fee,d.pricing.host_fee,d.pricing.host_fee_vat,d.pricing.processing_fee,d.pricing.totalTaxes]),(0,A.jsx)(A.Fragment,{children:(0,A.jsx)(ro.Group,{heading:"Modify Reservation",className:(0,ew.cn)("pb-2","[&>[cmdk-group-heading]]:text-xs","[&>[cmdk-group-heading]]:font-medium","[&>[cmdk-group-heading]]:text-gray-500 [&>[cmdk-group-heading]]:dark:text-white/40","[&>[cmdk-group-heading]]:px-2","[&>[cmdk-group-heading]]:pb-1"),children:(0,A.jsxs)("div",{className:"relative flex flex-col min-h-[400px] max-h-[600px]",children:[(0,A.jsxs)("div",{className:"flex-1 overflow-y-auto px-4 py-3",children:[s&&e?.metadata?.listing&&(0,A.jsx)("div",{className:"mb-4",children:(0,A.jsx)(st.ReservationListing,{data:{listing:e.metadata.listing,host:e.metadata.host,reservation:{id:s.id,dates:{checkIn:s.dates?.checkIn||s.checkIn,checkOut:s.dates?.checkOut||s.checkOut},platformInquiryId:s.platformInquiryId}},compact:!0,showFullAddress:!1,showCalendarFeature:!0,currentReservationId:s.id,showActionButtons:!0,isStatic:!0,enableLinks:!1,fromCommandPalette:!0})}),s&&(0,A.jsxs)("div",{className:"mb-4 p-3 bg-white dark:bg-white/[0.03] rounded-lg",children:[(0,A.jsx)("div",{className:"text-xs text-gray-500 dark:text-white/60 mb-2",children:"Current Details"}),(0,A.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,A.jsxs)("div",{className:"flex justify-between",children:[(0,A.jsx)("span",{className:"text-gray-500 dark:text-white/60",children:"Confirmation:"}),(0,A.jsx)("span",{className:"text-gray-900 dark:text-white",children:s.confirmationCode||"N/A"})]}),(0,A.jsxs)("div",{className:"flex justify-between",children:[(0,A.jsx)("span",{className:"text-gray-500 dark:text-white/60",children:"Dates:"}),(0,A.jsx)("span",{className:"text-gray-900 dark:text-white",children:(()=>{let e=s.dates?.checkIn||s.checkIn,t=s.dates?.checkOut||s.checkOut,a=s.dates?.checkInTime||s.checkInTime||"",r=s.dates?.checkOutTime||s.checkOutTime||"";if(!e||!t)return"N/A";try{let s=(0,ry.format)(new Date(e+"T00:00:00"),"MMM d"),i=(0,ry.format)(new Date(t+"T00:00:00"),"MMM d, yyyy");return`${s} ${a} - ${i} ${r}`}catch{return"N/A"}})()})]}),(0,A.jsxs)("div",{className:"flex justify-between",children:[(0,A.jsx)("span",{className:"text-gray-500 dark:text-white/60",children:"Guests:"}),(0,A.jsx)("span",{className:"text-gray-900 dark:text-white",children:(()=>{let e=s.guests?.total||s.guest_details?.number_of_guests||s.guestDetails?.number_of_guests||s.guestCount?.total,t=s.guests?.adults||s.guest_details?.number_of_adults||s.guestDetails?.number_of_adults,a=s.guests?.children||s.guest_details?.number_of_children||s.guestDetails?.number_of_children,r=s.guests?.infants||s.guest_details?.number_of_infants||s.guestDetails?.number_of_infants,i=s.guests?.pets||s.guest_details?.number_of_pets||s.guestDetails?.number_of_pets;if(!e)return"N/A";let n=[];t&&n.push(`${t} adult${1!==t?"s":""}`),a&&n.push(`${a} child${1!==a?"ren":""}`),r&&n.push(`${r} infant${1!==r?"s":""}`);let l=`${e} guest${1!==e?"s":""}`;return n.length>0&&(l+=` (${n.join(", ")})`),i>0&&(l+=` + ${i} pet${1!==i?"s":""}`),l})()})]}),(0,A.jsxs)("div",{className:"flex justify-between",children:[(0,A.jsx)("span",{className:"text-gray-500 dark:text-white/60",children:"Total:"}),(0,A.jsx)("span",{className:"text-gray-900 dark:text-white",children:(0,sp.formatCurrency)((0,sp.getMoneyAmount)(s.pricing?.totals?.total||s.priceBreakdown?.total||s.price_breakdown?.total||0),s.pricing?.totals?.currency||s.priceBreakdown?.currency||s.price_breakdown?.currency||"USD")})]}),d.pricing.processing_fee>0&&(0,A.jsxs)("div",{className:"flex justify-between",children:[(0,A.jsx)("span",{className:"text-gray-500 dark:text-white/60",children:"Processing Fee:"}),(0,A.jsx)("span",{className:"text-gray-900 dark:text-white",children:(0,sp.formatCurrency)(d.pricing.processing_fee,d.pricing.currency)})]}),d.pricing.totalTaxes>0&&(0,A.jsxs)("div",{className:"flex justify-between",children:[(0,A.jsx)("span",{className:"text-gray-500 dark:text-white/60",children:"Total Taxes:"}),(0,A.jsx)("span",{className:"text-gray-900 dark:text-white",children:(0,sp.formatCurrency)(d.pricing.totalTaxes,d.pricing.currency)})]}),(o=(s?.pricing?.fees?.other||[]).filter(e=>"extra_guest"===e.type).reduce((e,t)=>
70e+(0,sp.getMoneyAmount)(t.amount),0))>0?(0,A.jsxs)("div",{className:"flex justify-between",children:[(0,A.jsx)("span",{className:"text-gray-500 dark:text-white/60",children:"Extra Guest Fees (in base):"}),(0,A.jsx)("span",{className:"text-gray-400 dark:text-white/40",children:(0,sp.formatCurrency)(o,d.pricing.currency)})]}):null]})]}),(0,A.jsxs)("div",{className:"mb-4",children:[(0,A.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,A.jsxs)("div",{className:"flex items-center gap-2",children:[(0,A.jsx)(e_.Calendar,{className:"w-4 h-4 text-gray-500 dark:text-white/60"}),(0,A.jsx)("span",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:"Modify Dates"})]}),(0,A.jsx)("button",{type:"button",onClick:()=>c(e=>({...e,dates:{...e.dates,enabled:!e.dates.enabled}})),className:(0,ew.cn)("px-3 py-1 rounded-md text-xs font-medium transition-colors",d.dates.enabled?"bg-blue-500 text-gray-900 dark:text-white":"bg-gray-100 dark:bg-white/[0.08] text-gray-500 dark:text-white/60 hover:bg-gray-200 dark:hover:bg-white/[0.12]"),children:d.dates.enabled?"Enabled":"Enable"})]}),d.dates.enabled&&(0,A.jsxs)("div",{className:"pl-6 space-y-3",children:[(0,A.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60",children:"Check-in Date"}),(0,A.jsx)("input",{type:"date",value:d.dates.checkIn,onChange:e=>c(t=>({...t,dates:{...t.dates,checkIn:e.target.value}})),className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.03] rounded-lg text-sm text-gray-900 dark:text-white border border-gray-200 dark:border-white/[0.08] focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60",children:"Check-out Date"}),(0,A.jsx)("input",{type:"date",value:d.dates.checkOut,onChange:e=>c(t=>({...t,dates:{...t.dates,checkOut:e.target.value}})),className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.03] rounded-lg text-sm text-gray-900 dark:text-white border border-gray-200 dark:border-white/[0.08] focus:outline-none focus:ring-1 focus:ring-blue-500"})]})]}),(0,A.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60",children:"Check-in Time"}),(0,A.jsx)("input",{type:"time",value:d.dates.checkInTime,onChange:e=>c(t=>({...t,dates:{...t.dates,checkInTime:e.target.value}})),className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.03] rounded-lg text-sm text-gray-900 dark:text-white border border-gray-200 dark:border-white/[0.08] focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60",children:"Check-out Time"}),(0,A.jsx)("input",{type:"time",value:d.dates.checkOutTime,onChange:e=>c(t=>({...t,dates:{...t.dates,checkOutTime:e.target.value}})),className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.03] rounded-lg text-sm text-gray-900 dark:text-white border border-gray-200 dark:border-white/[0.08] focus:outline-none focus:ring-1 focus:ring-blue-500"})]})]})]})]}),(0,A.jsxs)("div",{className:"mb-4",children:[(0,A.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,A.jsxs)("div",{className:"flex items-center gap-2",children:[(0,A.jsx)(rq.Users,{className:"w-4 h-4 text-gray-500 dark:text-white/60"}),(0,A.jsx)("span",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:"Modify Guest Count"})]}),(0,A.jsx)("button",{type:"button",onClick:()=>c(e=>({...e,guestCount:{...e.guestCount,enabled:!e.guestCount.enabled}})),className:(0,ew.cn)("px-3 py-1 rounded-md text-xs font-medium transition-colors",d.guestCount.enabled?"bg-blue-500 text-gray-900 dark:text-white":"bg-gray-100 dark:bg-white/[0.08] text-gray-500 dark:text-white/60 hover:bg-gray-200 dark:hover:bg-white/[0.12]"),children:d.guestCount.enabled?"Enabled":"Enable"})]}),d.guestCount.enabled&&(0,A.jsxs)("div",{className:"pl-6 space-y-3",children:[(0,A.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60",children:"Adults"}),(0,A.jsx)("input",{type:"number",min:"1",max:"20",value:d.guestCount.adults||1,onChange:e=>{let t=parseInt(e.target.value)||1;c(e=>({...e,guestCount:{...e.guestCount,adults:t,total:t+(e.guestCount.children||0)+(e.guestCount.infants||0)}}))},className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.03] rounded-lg text-sm text-gray-900 dark:text-white border border-gray-200 dark:border-white/[0.08] focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60",children:"Children (2-12)"}),(0,A.jsx)("input",{type:"number",min:"0",max:"10",value:d.guestCount.children||0,onChange:e=>{let t=parseInt(e.target.value)||0;c(e=>({...e,guestCount:{...e.guestCount,children:t,total:(e.guestCount.adults||1)+t+(e.guestCount.infants||0)}}))},className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.03] rounded-lg text-sm text-gray-900 dark:text-white border border-gray-200 dark:border-white/[0.08] focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60",children:"Infants (Under 2)"}),(0,A.jsx)("input",{type:"number",min:"0",max:"5",value:d.guestCount.infants||0,onChange:e=>{let t=parseInt(e.target.value)||0;c(e=>({...e,guestCount:{...e.guestCount,infants:t,total:(e.guestCount.adults||1)+(e.guestCount.children||0)+t}}))},className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.03] rounded-lg text-sm text-gray-900 dark:text-white border border-gray-200 dark:border-white/[0.08] focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60",children:"Pets"}),(0,A.jsx)("input",{type:"number",min:"0",max:"5",value:d.guestCount.pets||0,onChange:e=>{let t=parseInt(e.target.value)||0;c(e=>({...e,guestCount:{...e.guestCount,pets:t}}))},className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.03] rounded-lg text-sm text-gray-900 dark:text-white border border-gray-200 dark:border-white/[0.08] focus:outline-none focus:ring-1 focus:ring-blue-500"})]})]}),(0,A.jsxs)("div",{className:"p-2 bg-gray-50 dark:bg-white/[0.02] rounded-lg",children:[(0,A.jsx)("div",{className:"text-xs text-gray-500 dark:text-white/60 mb-1",children:"Total Guests"}),(0,A.jsxs)("div",{className:"text-sm text-gray-900 dark:text-white font-medium",children:[d.guestCount.total," guest",1!==d.guestCount.total?"s":"",(d.guestCount.pets||0)>0&&` + ${d.guestCount.pets} pet${1!==d.guestCount.pets?"s":""}`]})]})]})]}),(0,A.jsxs)("div",{className:"mb-4",children:[(0,A.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,A.jsxs)("div",{className:"flex items-center gap-2",children:[(0,A.jsx)(sx.DollarSign,{className:"w-4 h-4 text-gray-500 dark:text-white/60"}),(0,A.jsx)("span",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:"Modify Pricing"})]}),(0,A.jsx)("button",{type:"button",onClick:()=>c(e=>({...e,pricing:{...e.pricing,enabled:!e.pricing.enabled}})),className:(0,ew.cn)("px-3 py-1 rounded-md text-xs font-medium transition-colors",d.pricing.enabled?"bg-blue-500 text-gray-900 dark:text-white":"bg-gray-100 dark:bg-white/[0.08] text-gray-500 dark:text-white/60 hover:bg-gray-200 dark:hover:bg-white/[0.12]"),children:d.pricing.enabled?"Enabled":"Enable"})]}),d.pricing.enabled&&(0,A.jsxs)("div",{className:"pl-6 space-y-3",children:[(0,A.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60",children:"Total Amount"}),(0,A.jsx)("input",{type:"number",step:"0.01",min:"0",value:Number(d.pricing.total||0),onChange:e=>c(t=>({...t,pricing:{...t.pricing,total:parseFloat(e.target.value)||0}})),className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.03] rounded-lg text-sm text-gray-900 dark:text-white border border-gray-200 dark:border-white/[0.08] focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60",children:"Host Payout"}),(0,A.jsx)("input",{type:"number",step:"0.01",min:"0",value:Number(d.pricing.host_payout||0),onChange:e=>c(t=>({...t,pricing:{...t.pricing,host_payout:parseFloat(e.target.value)||0}})),className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.03] rounded-lg text-sm text-gray-900 dark:text-white border border-gray-200 dark:border-white/[0.08] focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60",children:"Base Price"}),(0,A.jsx)("input",{type:"number",step:"0.01",min:"0",value:d.pricing.base_price,onChange:e=>c(t=>({...t,pricing:{...t.pricing,base_price:parseFloat(e.target.value)||0}})),className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.03] rounded-lg text-sm text-gray-900 dark:text-white border border-gray-200 dark:border-white/[0.08] focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60",children:"Cleaning Fee"}),(0,A.jsx)("input",{type:"number",step:"0.01",min:"0",value:d.pricing.cleaning_fee,onChange:e=>c(t=>({...t,pricing:{...t.pricing,cleaning_fee:parseFloat(e.target.value)||0}})),className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.03] rounded-lg text-sm text-gray-900 dark:text-white border border-gray-200 dark:border-white/[0.08] focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60",children:"Pet Fee"}),(0,A.jsx)("input",{type:"number",step:"0.01",min:"0",value:d.pricing.pet_fee,onChange:e=>c(t=>({...t,pricing:{...t.pricing,pet_fee:parseFloat(e.target.value)||0}})),className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.03] rounded-lg text-sm text-gray-900 dark:text-white border border-gray-200 dark:border-white/[0.08] focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60",children:"Extra Guest Fee"}),(0,A.jsx)("input",{type:"number",step:"0.01",min:"0",value:d.pricing.extra_guest_fee,onChange:e=>c(t=>({...t,pricing:{...t.pricing,extra_guest_fee:parseFloat(e.target.value)||0}})),className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.03] rounded-lg text-sm text-gray-900 dark:text-white border border-gray-200 dark:border-white/[0.08] focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60",children:"Service Fee"}),(0,A.jsx)("input",{type:"number",step:"0.01",min:"0",value:d.pricing.service_fee,onChange:e=>c(t=>({...t,pricing:{...t.pricing,service_fee:parseFloat(e.target.value)||0}})),className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.03] rounded-lg text-sm text-gray-900 dark:text-white border border-gray-200 dark:border-white/[0.08] focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60",children:"Platform Fee"}),(0,A.jsx)("input",{type:"number",step:"0.01",min:"0",value:d.pricing.platform_fee,onChange:e=>c(t=>({...t,pricing:{...t.pricing,platform_fee:parseFloat(e.target.value)||0}})),className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.03] rounded-lg text-sm text-gray-900 dark:text-white border border-gray-200 dark:border-white/[0.08] focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60",children:"Host Fee"}),(0,A.jsx)("input",{type:"number",step:"0.01",min:"0",value:d.pricing.host_fee,onChange:e=>c(t=>({...t,pricing:{...t.pricing,host_fee:parseFloat(e.target.value)||0}})),className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.03] rounded-lg text-sm text-gray-900 dark:text-white border border-gray-200 dark:border-white/[0.08] focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60",children:"Processing Fee"}),(0,A.jsx)("input",{type:"number",step:"0.01",min:"0",value:d.pricing.processing_fee,onChange:e=>c(t=>({...t,pricing:{...t.pricing,processing_fee:parseFloat(e.target.value)||0}})),className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.03] rounded-lg text-sm text-gray-900 dark:text-white border border-gray-200 dark:border-white/[0.08] focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60",children:"Total Taxes"}),(0,A.jsx)("input",{type:"number",step:"0.01",min:"0",value:d.pricing.totalTaxes,onChange:e=>c(t=>({...t,pricing:{...t.pricing,totalTaxes:parseFloat(e.target.value)||0}})),className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.03] rounded-lg text-sm text-gray-900 dark:text-white border border-gray-200 dark:border-white/[0.08] focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60",children:"Currency"}),(0,A.jsx)("input",{type:"text",value:d.pricing.currency,onChange:e=>c(t=>({...t,pricing:{...t.pricing,currency:e.target.value}})),className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.03] rounded-lg text-sm text-gray-900 dark:text-white border border-gray-200 dark:border-white/[0.08] focus:outline-none focus:ring-1 focus:ring-blue-500"})]})]}),(0,A.jsxs)("div",{className:"mt-4",children:[(0,A.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,A.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60 font-medium",children:"Discounts"}),(0,A.jsx)("button",{type:"button",onClick:()=>c(e=>({...e,pricing:{...e.pricing,discounts:[...e.pricing.discounts,{name:"",amount:0,type:"manual"}]}})),className:"text-xs text-blue-400 hover:text-blue-300",children:"+ Add Discount"})]}),d.pricing.discounts.length>0?(0,A.jsx)("div",{className:"space-y-2",children:d.pricing.discounts.map((e,t)=>(0,A.jsxs)("div",{className:"flex items-center gap-2",children:[(0,A.jsx)("input",{type:"text",placeholder:"Name",value:e.name,onChange:e=>{let a=[...d.pricing.discounts];a[t]={...a[t],name:e.target.value},c(e=>({...e,pricing:{...e.pricing,discounts:a}}))},className:"flex-1 px-2 py-1.5 bg-gray-50 dark:bg-white/[0.03] rounded-lg text-xs text-gray-900 dark:text-white border border-gray-200 dark:border-white/[0.08] focus:outline-none focus:ring-1 focus:ring-blue-500"}),(0,A.jsx)("input",{type:"number",step:"0.01",min:"0",placeholder:"Amount",value:e.amount||"",onChange:e=>{let a=[...d.pricing.discounts];a[t]={...a[t],amount:parseFloat(e.target.value)||0},c(e=>({...e,pricing:{...e.pricing,discounts:a}}))},className:"w-24 px-2 py-1.5 bg-gray-50 dark:bg-white/[0.03] rounded-lg text-xs text-gray-900 dark:text-white border border-gray-200 dark:border-white/[0.08] focus:outline-none focus:ring-1 focus:ring-blue-500"}),(0,A.jsx)("button",{type:"button",onClick:()=>{let e=d.pricing.discounts.filter((e,a)=>a!==t);c(t=>({...t,pricing:{...t.pricing,discounts:e}}))},className:"text-red-400 hover:text-red-300 p-1",children:(0,A.jsx)(ei.X,{className:"w-3 h-3"})})]},t))}):(0,A.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/30 italic",children:"No discounts"})]}),(0,A.jsxs)("div",{className:"mt-4",children:[(0,A.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,A.jsx)("label",{className:"text-xs t
70ext-gray-500 dark:text-white/60 font-medium",children:"Add-Ons"}),(0,A.jsx)("button",{type:"button",onClick:()=>c(e=>({...e,pricing:{...e.pricing,addOns:[...e.pricing.addOns,{name:"",amount:0,description:""}]}})),className:"text-xs text-blue-400 hover:text-blue-300",children:"+ Add Add-On"})]}),d.pricing.addOns.length>0?(0,A.jsx)("div",{className:"space-y-2",children:d.pricing.addOns.map((e,t)=>(0,A.jsxs)("div",{className:"flex items-center gap-2",children:[(0,A.jsx)("input",{type:"text",placeholder:"Name",value:e.name,onChange:e=>{let a=[...d.pricing.addOns];a[t]={...a[t],name:e.target.value},c(e=>({...e,pricing:{...e.pricing,addOns:a}}))},className:"flex-1 px-2 py-1.5 bg-gray-50 dark:bg-white/[0.03] rounded-lg text-xs text-gray-900 dark:text-white border border-gray-200 dark:border-white/[0.08] focus:outline-none focus:ring-1 focus:ring-blue-500"}),(0,A.jsx)("input",{type:"number",step:"0.01",min:"0",placeholder:"Amount",value:e.amount||"",onChange:e=>{let a=[...d.pricing.addOns];a[t]={...a[t],amount:parseFloat(e.target.value)||0},c(e=>({...e,pricing:{...e.pricing,addOns:a}}))},className:"w-24 px-2 py-1.5 bg-gray-50 dark:bg-white/[0.03] rounded-lg text-xs text-gray-900 dark:text-white border border-gray-200 dark:border-white/[0.08] focus:outline-none focus:ring-1 focus:ring-blue-500"}),(0,A.jsx)("button",{type:"button",onClick:()=>{let e=d.pricing.addOns.filter((e,a)=>a!==t);c(t=>({...t,pricing:{...t.pricing,addOns:e}}))},className:"text-red-400 hover:text-red-300 p-1",children:(0,A.jsx)(ei.X,{className:"w-3 h-3"})})]},t))}):(0,A.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/30 italic",children:"No add-ons"})]})]})]}),g&&(0,A.jsxs)("div",{className:"mb-4 p-3 bg-white dark:bg-white/[0.03] rounded-lg",children:[(0,A.jsx)("div",{className:"text-xs text-gray-500 dark:text-white/60 mb-2",children:"Modification Summary"}),(0,A.jsxs)("div",{className:"space-y-1",children:[d.dates.enabled&&(0,A.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,A.jsx)("div",{className:"w-2 h-2 rounded-full bg-blue-400"}),(0,A.jsx)("span",{className:"text-gray-600 dark:text-white/80",children:"Date Changes:"}),(0,A.jsx)("span",{className:"text-gray-500 dark:text-white/60",children:(()=>{try{let e=(0,ry.format)(new Date(d.dates.checkIn+"T00:00:00"),"MMM d"),t=(0,ry.format)(new Date(d.dates.checkOut+"T00:00:00"),"MMM d, yyyy");return`${e} ${d.dates.checkInTime} to ${t} ${d.dates.checkOutTime}`}catch{return`${d.dates.checkIn} ${d.dates.checkInTime} to ${d.dates.checkOut} ${d.dates.checkOutTime}`}})()})]}),d.guestCount.enabled&&(0,A.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,A.jsx)("div",{className:"w-2 h-2 rounded-full bg-green-400"}),(0,A.jsx)("span",{className:"text-gray-600 dark:text-white/80",children:"Guest Count:"}),(0,A.jsxs)("span",{className:"text-gray-500 dark:text-white/60",children:[d.guestCount.total," guest",1!==d.guestCount.total?"s":"",d.guestCount.pets>0&&` + ${d.guestCount.pets} pet${1!==d.guestCount.pets?"s":""}`,` (${d.guestCount.adults||1} adult${1!==(d.guestCount.adults||1)?"s":""}${(d.guestCount.children||0)>0?`, ${d.guestCount.children} child${1!==d.guestCount.children?"ren":""}`:""}${(d.guestCount.infants||0)>0?`, ${d.guestCount.infants} infant${1!==d.guestCount.infants?"s":""}`:""})`]})]}),d.pricing.enabled&&(0,A.jsxs)("div",{className:"space-y-1",children:[(0,A.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,A.jsx)("div",{className:"w-2 h-2 rounded-full bg-yellow-400"}),(0,A.jsx)("span",{className:"text-gray-600 dark:text-white/80",children:"Total:"}),(0,A.jsxs)("span",{className:"text-gray-500 dark:text-white/60",children:[d.pricing.currency,Number(d.pricing.total||0).toFixed(2)]})]}),d.pricing.discounts.length>0&&(0,A.jsx)("div",{className:"flex items-center gap-2 text-xs pl-4",children:(0,A.jsxs)("span",{className:"text-gray-500 dark:text-white/60",children:["Discounts: -",d.pricing.currency,d.pricing.discounts.reduce((e,t)=>e+(t.amount||0),0).toFixed(2)]})}),d.pricing.addOns.length>0&&(0,A.jsx)("div",{className:"flex items-center gap-2 text-xs pl-4",children:(0,A.jsxs)("span",{className:"text-gray-500 dark:text-white/60",children:["Add-ons: +",d.pricing.currency,d.pricing.addOns.reduce((e,t)=>
70e+(t.amount||0),0).toFixed(2)]})})]})]})]}),e?.error&&!e?.isLoading&&(0,A.jsxs)("div",{className:"mt-3 p-3 bg-red-950/30 border border-red-500/30 rounded-lg flex items-start",children:[(0,A.jsx)("div",{className:"mr-2 mt-0.5 text-red-400 flex-shrink-0",children:(0,A.jsx)(sg.AlertCircle,{className:"w-4 h-4"})}),(0,A.jsxs)("div",{className:"flex-1",children:[(0,A.jsx)("div",{className:"text-sm font-medium text-red-400",children:"Error"}),(0,A.jsx)("div",{className:"text-xs text-red-300/90",children:e.error})]})]}),e?.successMessage&&(0,A.jsxs)("div",{className:"mt-3 p-3 bg-green-950/30 border border-green-500/30 rounded-lg flex items-start",children:[(0,A.jsx)("div",{className:"mr-2 mt-0.5 text-green-400 flex-shrink-0",children:(0,A.jsx)(em.Check,{className:"w-4 h-4"})}),(0,A.jsxs)("div",{className:"flex-1",children:[(0,A.jsx)("div",{className:"text-sm font-medium text-green-400",children:"Success"}),(0,A.jsx)("div",{className:"text-xs text-green-300/90",children:e.successMessage})]})]}),(0,A.jsx)("div",{className:"h-16"})]}),(0,A.jsx)("div",{className:"absolute bottom-0 left-0 right-0 p-4 bg-white dark:bg-[#1c1c1e] border-t border-gray-200 dark:border-white/[0.08] z-50",children:(0,A.jsx)("div",{className:"flex justify-end",children:(0,A.jsx)("button",{onClick:()=>{d.dates.enabled||d.guestCount.enabled||d.pricing.enabled?d.pricing.enabled&&(d.pricing.base_price<0||d.pricing.cleaning_fee<0||d.pricing.pet_fee<0||d.pricing.extra_guest_fee<0||d.pricing.service_fee<0||d.pricing.platform_fee<0||d.pricing.host_fee<0||d.pricing.host_fee_vat<0||d.pricing.processing_fee<0||d.pricing.totalTaxes<0)?l?.("Pricing values cannot be negative."):i({type:"pricing_update",modifications:{...d.dates.enabled&&{dates:{checkIn:d.dates.checkIn,checkOut:d.dates.checkOut,checkInTime:d.dates.checkInTime,checkOutTime:d.dates.checkOutTime}},...d.guestCount.enabled&&{guestCount:{total:d.guestCount.total,adults:d.guestCount.adults,children:d.guestCount.children,infants:d.guestCount.infants,pets:d.guestCount.pets}},...d.pricing.enabled&&{pricing:{total:d.pricing.total,host_payout:d.pricing.host_payout,currency:d.pricing.currency,base_price:d.pricing.base_price,cleaning_fee:d.pricing.cleaning_fee,pet_fee:d.pricing.pet_fee,extra_guest_fee:d.pricing.extra_guest_fee,service_fee:d.pricing.service_fee,platform_fee:d.pricing.platform_fee,host_fee:d.pricing.host_fee,host_fee_vat:d.pricing.host_fee_vat,processing_fee:d.pricing.processing_fee,totalTaxes:d.pricing.totalTaxes}}},metadata:{source:"manual_modification",timestamp:new Date().toISOString(),reservationId:s?.id}}):l?.("Please enable at least one modification type.")},disabled:!g||e?.commandInProgress,className:(0,ew.cn)("px-4 py-2 rounded-md","bg-white hover:bg-white/90","text-sm text-black font-medium","transition-colors duration-200",(!g||e?.commandInProgress)&&"opacity-50 cursor-not-allowed"),children:e?.commandInProgress?(0,A.jsxs)("span",{className:"flex items-center",children:[(0,A.jsx)(rf.Spinner,{className:"h-4 w-4 text-black mr-2"}),"Applying Changes..."]}):"Apply Modifications"})})})]})})})}var sr=sr,sk=e.i(269780),sj=e.i(289562);function sN({name:e,email:t,role:a,image:r,active:s=!0}){return(0,A.jsxs)("div",{className:"flex items-center gap-3 w-full",children:[(0,A.jsx)(sj.Avatar,{src:r||void 0,alt:e,fallback:e.charAt(0),className:(0,ew.cn)("w-10 h-10",!s&&"opacity-50")}),(0,A.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,A.jsxs)("div",{className:"flex items-center gap-2",children:[(0,A.jsx)("span",{className:"font-medium text-gray-900 dark:text-white truncate",children:e}),a&&(0,A.jsx)("span",{className:"px-2 py-0.5 text-xs rounded-full bg-white/10 text-gray-400 dark:text-white/60",children:(0,sk.userRoleLabel)(a)}),!s&&(0,A.jsx)("span",{className:"px-2 py-0.5 text-xs rounded-full bg-red-500/10 text-red-500",children:"Inactive"})]}),(0,A.jsx)("div",{className:"text-sm text-gray-400 dark:text-white/40 truncate",children:t})]})]})}function sC({suggestions:e,stepState:t,selectedIndex:a,selectedId:r,onSuggestionClick:s}){return e.length?(0,A.jsx)(ro.Group,{heading:t.currentStep?.heading||"Select a team member",className:(0,ew.cn)("pb-2","[&>[cmdk-group-heading]]:text-xs","[&>[cmdk-group-heading]]:font-medium","[&>[cmdk-group-heading]]:text-gray-500 [&>[cmdk-group-heading]]:dark:text-white/40","[&>[cmdk-group-heading]]:px-2","[&>[cmdk-group-heading]]:pb-1"),children:e.map((e,i)=>{let n=t.data[t.currentStep?.id||""]?.selections?.some(t=>t.id===e.id);return(0,A.jsx)(ro.Item,{value:e.id,"data-suggestion-id":e.id,"data-index":i,"data-selected":a===i,onSelect:()=>s(e),className:(0,ew.cn)("flex items-center gap-3 px-4 py-3 rounded-lg","transition-colors duration-200","cursor-pointer","hover:bg-gray-50 dark:hover:bg-white/[0.06]",a===i&&"bg-gray-50 dark:bg-white/[0.06]",r===e.id&&"bg-gray-100 dark:bg-white/[0.08]",n&&"bg-gray-100 dark:bg-white/[0.12]"),children:(0,A.jsxs)("div",{className:"flex items-center gap-2 w-full",children:[n&&(0,A.jsx)("div",{className:"absolute left-2",children:(0,A.jsx)(sr.default,{className:"w-4 h-4 text-blue-400"})}),(0,A.jsx)("div",{className:(0,ew.cn)("flex-1",n&&"pl-6"),children:(0,A.jsx)(sN,{name:e.name,email:e.metadata?.email||"",role:e.metadata?.role,image:e.metadata?.image,active:e.metadata?.active})})]})},e.id)})}):(0,A.jsx)("div",{className:"px-4 py-3 text-sm text-gray-500 dark:text-white/60",children:"No team members found"})}var sr=sr,sS=e.i(248256);let sE={airbnb:"/icons/airbnb.svg",booking:"/icons/booking.svg",whatsapp:"/icons/whatsapp.svg",telegram:eE.MessageSquare,viber:eE.MessageSquare,messenger:eE.MessageSquare,instagram:eE.MessageSquare,owner:eE.MessageSquare,sms:r4.Phone,twilio:r4.Phone,email:r2.Mail,internal:eE.MessageSquare,website:sS.Globe};function sI({channelId:e,name:t,description:a,selected:r,disabled:s}){let i=sE[e];return(0,A.jsxs)("div",{className:(0,ew.cn)("flex items-center gap-3 w-full p-3 rounded-lg transition-colors",r&&"bg-white/10",s&&"opacity-50 cursor-not-allowed",!s&&"hover:bg-white/[0.06] cursor-pointer"),children:[(0,A.jsx)("div",{className:"flex items-center justify-center w-10 h-10 rounded-lg bg-gray-100 dark:bg-white/[0.06]",children:"string"==typeof i?(0,A.jsx)(X.default,{src:i,alt:t,width:20,height:20,className:"opacity-60"}):i&&R.default.createElement(i,{className:"w-5 h-5 text-gray-400 dark:text-white/60"})}),(0,A.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,A.jsx)("div",{className:"font-medium text-gray-900 dark:text-white truncate",children:t}),(0,A.jsx)("div",{className:"text-sm text-gray-400 dark:text-white/40 truncate",children:a})]})]})}function sT({suggestions:e,stepState:t,selectedIndex:a,selectedId:r,onSuggestionClick:s}){return e.length?(0,A.jsx)(ro.Group,{heading:t.currentStep?.heading||"Select a channel",className:(0,ew.cn)("pb-2","[&>[cmdk-group-heading]]:text-xs","[&>[cmdk-group-heading]]:font-medium","[&>[cmdk-group-heading]]:text-gray-500 [&>[cmdk-group-heading]]:dark:text-white/40","[&>[cmdk-group-heading]]:px-2","[&>[cmdk-group-heading]]:pb-1"),children:e.map((e,i)=>{let n=t.data[t.currentStep?.id||""]?.selections?.some(t=>t.id===e.id);return(0,A.jsx)(ro.Item,{value:e.id,"data-suggestion-id":e.id,"data-index":i,"data-selected":a===i,onSelect:()=>s(e),className:(0,ew.cn)("flex items-center gap-3 px-4 py-3 rounded-lg","transition-colors duration-200","cursor-pointer","hover:bg-gray-50 dark:hover:bg-white/[0.06]",a===i&&"bg-gray-50 dark:bg-white/[0.06]",r===e.id&&"bg-gray-100 dark:bg-white/[0.08]",n&&"bg-gray-100 dark:bg-white/[0.12]"),children:(0,A.jsxs)("div",{className:"flex items-center gap-2 w-full",children:[n&&(0,A.jsx)("div",{className:"absolute left-2",children:(0,A.jsx)(sr.default,{className:"w-4 h-4 text-blue-400"})}),(0,A.jsx)("div",{className:(0,ew.cn)("flex-1",n&&"pl-6"),children:(0,A.jsx)(sI,{channelId:e.id,name:e.name,description:e.description||"",disabled:e.metadata?.disabled})})]})},e.id)})}):(0,A.jsx)("div",{className:"px-4 py-3 text-sm text-gray-500 dark:text-white/60",children:"No channels found"})}var s_=e.i(292270),sA=e.i(941077);
70function sD({value:e,onChange:t,className:a}){let r=e.getHours(),s=e.getMinutes(),i=r>=12?"PM":"AM",n=s.toString().padStart(2,"0");return(0,A.jsxs)("div",{className:(0,ew.cn)("flex items-center gap-2",a),children:[(0,A.jsx)("select",{value:r%12||12,onChange:a=>{let r=parseInt(a.target.value,10),s="PM"===i,n=new Date(e);n.setHours(12===r?12*!!s:s?r+12:r),t(n)},className:"bg-white/[0.03] border border-gray-200 dark:border-white/[0.08] rounded-md px-2 py-1 text-gray-900 dark:text-white",children:Array.from({length:12},(e,t)=>t+1).map(e=>(0,A.jsx)("option",{value:e,children:e},e))}),(0,A.jsx)("span",{className:"text-white",children:":"}),(0,A.jsx)("select",{value:n,onChange:a=>{let r=parseInt(a.target.value,10),s=new Date(e);s.setMinutes(r),t(s)},className:"bg-white/[0.03] border border-gray-200 dark:border-white/[0.08] rounded-md px-2 py-1 text-gray-900 dark:text-white",children:Array.from({length:60},(e,t)=>t).map(e=>(0,A.jsx)("option",{value:e.toString().padStart(2,"0"),children:e.toString().padStart(2,"0")},e))}),(0,A.jsxs)("select",{value:i,onChange:a=>{let r=a.target.value,s=e.getHours(),i=s;"AM"===r&&s>=12?i=s-12:"PM"===r&&s<12&&(i=s+12);let n=new Date(e);n.setHours(i),t(n)},className:"bg-white/[0.03] border border-gray-200 dark:border-white/[0.08] rounded-md px-2 py-1 text-gray-900 dark:text-white",children:[(0,A.jsx)("option",{value:"AM",children:"AM"}),(0,A.jsx)("option",{value:"PM",children:"PM"})]})]})}var sP=e.i(816933),sR=e.i(617921);function sM(e){let t=e.activeModifiers.checkIn,a=e.activeModifiers.checkOut;return(0,A.jsxs)("div",{className:"relative flex h-full w-full items-center justify-center",children:[(0,A.jsx)("span",{children:e.date.getDate()}),(t||a)&&(0,A.jsxs)("span",{className:"pointer-events-none absolute bottom-0.5 left-1/2 flex -translate-x-1/2 gap-0.5",children:[t&&(0,A.jsx)("span",{className:"h-1 w-1 rounded-full bg-emerald-500"}),a&&(0,A.jsx)("span",{className:"h-1 w-1 rounded-full bg-amber-500"})]})]})}function sF({date:e,setDate:t,className:a,displayFormat:r="MMM d, yyyy HH:mm",rawValue:s,checkInDates:i,checkOutDates:n,nextCheckout:l,nextCheckoutReservationId:o,nextCheckoutListingId:d}){let[c,m]=(0,R.useState)(!1),[u,h]=(0,R.useState)("date"),[x,g]=(0,R.useState)(new Date(s||e)),[p,b]=(0,R.useState)(!1),f=!!(i?.length||n?.length);(0,R.useEffect)(()=>{c&&g(new Date(s||e))},[c,s,e]);let y=s?(0,ry.format)(new Date(s),r):(0,ry.format)(e,r),w=async()=>{try{b(!0),await t(x,null),m(!1)}catch(e){console.error("Error saving date:",e)}finally{b(!1)}},v=async()=>{if(!l)return;let a=new Date(s||e),r=new Date(l);r.setHours(a.getHours()),r.setMinutes(a.getMinutes()),g(r);try{b(!0),await t(r,null!=o?{reservationId:o,listingId:d??null}:void 0),m(!1)}catch(e){console.error("Error saving next-checkout date:",e)}finally{b(!1)}};return(0,A.jsx)("div",{className:"relative z-[200]",children:(0,A.jsxs)(sP.Popover,{open:c,onOpenChange:m,children:[(0,A.jsx)(sP.PopoverTrigger,{asChild:!0,children:(0,A.jsx)("button",{type:"button",className:(0,ew.cn)("w-full flex items-center px-3 py-2 bg-gray-50/80 dark:bg-white/[0.03] rounded-lg","text-sm text-gray-900 dark:text-white border border-gray-200 dark:border-white/[0.08]","focus:outline-none focus:ring-1 focus:ring-blue-500","hover:bg-gray-100 dark:hover:bg-white/[0.05]",p&&"opacity-50 cursor-not-allowed",a),disabled:p,children:(0,A.jsxs)("div",{className:"flex items-center gap-2 w-full",children:[p?(0,A.jsx)("div",{className:"w-4 h-4 border-2 border-gray-300 dark:border-white/20 border-t-white rounded-full animate-spin"}):(0,A.jsx)(e_.Calendar,{className:"w-4 h-4 text-gray-400 dark:text-white/40"}),(0,A.jsx)("span",{className:"flex-1 text-left",children:y})]})})}),(0,A.jsx)(sP.PopoverContent,{className:(0,ew.cn)("w-auto p-0 bg-white dark:bg-[#1D1D1F] border border-gray-200 dark:border-white/[0.08] text-gray-900 dark:text-white","z-[200]"),align:"start",sideOffset:4,side:"bottom",alignOffset:0,children:(0,A.jsxs)(sR.Tabs,{defaultValue:u,value:u,onValueChange:e=>h(e),className:"w-full",children:[(0,A.jsxs)(sR.TabsList,{className:"grid grid-cols-2 w-full bg-gray-100 dark:bg-white/[0.03]",children:[(0,A.jsx)(sR.TabsTrigger,{value:"date",className:"text-gray-600 dark:text-white/80",children:"Date"}),(0,A.jsx)(sR.TabsTrigger,{value:"time",className:"text-gray-600 dark:text-white/80",children:"Time"})]}),(0,A.jsxs)(sR.TabsContent,{value:"date",className:"p-0",children:[l&&(0,A.jsxs)("button",{type:"button",onClick:v,disabled:p,className:(0,ew.cn)("flex w-full items-center gap-2 border-b border-gray-200 dark:border-white/[0.08] px-3 py-2.5 text-left text-[13px]","text-gray-700 dark:text-white/80 hover:bg-gray-50 dark:hover:bg-white/[0.04] transition-colors",p&&"opacity-50 cursor-not-allowed"),children:[(0,A.jsx)(s_.LogOut,{className:"h-3.5 w-3.5 text-amber-500"}),(0,A.jsx)("span",{className:"flex-1",children:"Next checkout"}),(0,A.jsx)("span",{className:"text-gray-400 dark:text-white/40",children:(0,ry.format)(l,"
70EEE, MMM d")})]}),(0,A.jsx)(sA.Calendar,{mode:"single",selected:x,onSelect:t=>{if(t){let a=new Date(t),r=new Date(s||e);a.setHours(r.getHours()),a.setMinutes(r.getMinutes()),g(a),h("time")}},initialFocus:!0,className:"bg-white dark:bg-[#1D1D1F] text-gray-900 dark:text-white",modifiers:f?{checkIn:i||[],checkOut:n||[]}:void 0,components:f?{DayContent:sM}:void 0}),f&&(0,A.jsxs)("div",{className:"flex items-center gap-3 border-t border-gray-200 dark:border-white/[0.08] px-3 py-2 text-[11px] text-gray-500 dark:text-white/50",children:[(0,A.jsxs)("span",{className:"flex items-center gap-1",children:[(0,A.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500"})," Check-in"]}),(0,A.jsxs)("span",{className:"flex items-center gap-1",children:[(0,A.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-amber-500"})," Check-out"]})]})]}),(0,A.jsx)(sR.TabsContent,{value:"time",className:"p-4",children:(0,A.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,A.jsxs)("div",{className:"flex items-center gap-2",children:[(0,A.jsx)(eT.Clock,{className:"w-4 h-4 text-gray-400 dark:text-white/40"}),(0,A.jsx)("span",{className:"text-sm text-gray-600 dark:text-white/80",children:"Select time"})]}),(0,A.jsx)(sD,{value:x,onChange:e=>{let t=new Date(x);t.setHours(e.getHours()),t.setMinutes(e.getMinutes()),g(t)},className:"w-full"}),(0,A.jsx)("div",{className:"flex justify-end",children:(0,A.jsx)("button",{onClick:w,disabled:p,className:(0,ew.cn)("px-3 py-1.5 bg-blue-500 text-gray-900 dark:text-white text-sm rounded-md","flex items-center gap-2",p&&"opacity-50 cursor-not-allowed"),children:p?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("div",{className:"w-3 h-3 border-2 border-gray-300 dark:border-white/20 border-t-white rounded-full animate-spin"}),(0,A.jsx)("span",{children:"Saving..."})]}):"Done"})})]})})]})})]})})}function sL({stepState:e,selectedIndex:t,selectedId:a,search:r,onSubmit:s,onStepStateChange:i=e=>{}}){let n,l,[o,d]=(0,R.useState)(!1),[c,m]=(0,R.useState)(!1),[u,h]=(0,R.useState)([]),[x,g]=(0,R.useState)(null),[p,b]=(0,R.useState)(null),[f,y]=(0,R.useState)(!1),[w,v]=(0,R.useState)(!1),[k,j]=(0,R.useState)(!1),N=e?.metadata||("object"==typeof e?.context&&e?.context!==null&&"metadata"in e.context?e.context.metadata:null),C=e?.data?.reservation||N?.reservation||{},S=C?.id,E=e?.type||"";(0,R.useEffect)(()=>{S&&E.includes("edit")&&(d(!0),m(!0),fetch(`/api/reservations/access?reservationId=${S}`).then(e=>e.json()).then(e=>{h(e.accessCodes||[]),m(!1)}).catch(e=>{console.error("Error fetching access codes:",e),m(!1)}))},[S,E]);let I=e?.data?.reservation?.listing||C?.listing||N?.listing||{},T=I?.id||C?.listingId||C?.listing?.id;(0,R.useEffect)(()=>{T&&fetch(`/api/apps/iot/lock-settings?listingId=${T}`).then(e=>e.json()).then(e=>{e.settings?.offlineCodesEnabled&&!0!==e.deviceOnline&&j(!0)}).catch(()=>{})},[T]);let _=C?.checkIn?C.checkIn:C?.dates?.checkIn?C.dates.checkIn:new Date().toISOString(),D=C?.checkOut?C.checkOut:C?.dates?.checkOut?C.dates.checkOut:(0,rw.addDays)(new Date,7).toISOString();if("string"==typeof _&&_.length<=10){let[e,t,a]=_.split("-").map(Number);n=new Date(e,t-1,a,0,0,0)}else n=new Date(_);if("string"==typeof D&&D.length<=10){let[e,t,a]=D.split("-").map(Number);l=new Date(e,t-1,a,0,0,0)}else l=new Date(D);let P=C?.dates?.checkInTime||"",M=C?.dates?.checkOutTime||"",F=e=>{if(!e)return null;let t=e.split(":");return t.length>=2?{hours:parseInt(t[0],10),minutes:parseInt(t[1].split("-")[0],10)}:null},L=F(P),$=F(M),O=L?new Date(n.setHours(L.hours,L.minutes)):n,U=$?new Date(l.setHours($.hours,$.minutes)):l,B=C?.guestName||C?.guest?.name?.full||N?.guest?.name?.full||"Guest",q=I?.name||"",z=I?.thumbnailUrl||I?.thumbnail,[H,V]=(0,R.useState)({name:`${B}'s Access Code`,code:"",startsAt:O,endsAt:U,isMissingField:!1,codeError:"",codeId:""});(0,R.useEffect)(()=>{V(e=>({...e,name:`${B}'s Access Code`}))},[B]),(0,R.useEffect)(()=>{V(e=>({...e,startsAt:O,endsAt:U}))},[]);let G=(e,t)=>{if("code"===e){let e="";t&&(t.length<4||t.length>8)&&(e=`Access code must be ${t.length<4?"at least 4":"at most 8"} digits`),V(a=>({...a,code:t,codeError:e,isMissingField:!1}))}else V(a=>{let r={...a};return"name"===e?r.name=t:("startsAt"===e||"endsAt"===e)&&(r[e]=t),r.isMissingField=!1,r})},[W,K]=(0,R.useState)(!1);(0,R.useEffect)(()=>{(e.error||e.successMessage)&&K(!1)},[e.error,e.successMessage]);let Y=async()=>{let e=C?.id,t=I?.id||C?.listingId||C?.listing?.id;if(e&&t){for(let a of(y(!0),v(!1),[...u])){let r={type:"direct",topic:"seam",event:"seam.accessCode.delete",payload:{accessCodeId:a.id,reservationId:e,listingId:t,customerId:N?.customerId||1,userId:N?.userId||"",userName:N?.userName||""}};await new Promise(e=>{let t=r=>{let{action:s,success:i}=r.detail;"seam.accessCode.delete"===s.event&&(document.removeEventListener("command:result",t),i&&h(e=>e.filter(e=>e.id!==a.id)),e())};document.addEventListener("command:result",t),document.dispatchEvent(new CustomEvent("command-action",{detail:{command:r}}))})}g(null),V({name:`${B}'s Access Code`,code:"",startsAt:O,endsAt:U,isMissingField:!1,co
70deError:"",codeId:""}),y(!1)}};return(0,A.jsx)(A.Fragment,{children:(0,A.jsxs)(ro.Group,{heading:o?"Edit Access Code":"Create Access Code",className:(0,ew.cn)("pb-2","[&>[cmdk-group-heading]]:text-xs","[&>[cmdk-group-heading]]:font-medium","[&>[cmdk-group-heading]]:text-gray-500 [&>[cmdk-group-heading]]:dark:text-white/40","[&>[cmdk-group-heading]]:px-2","[&>[cmdk-group-heading]]:pb-1"),children:[w&&(0,A.jsx)("div",{className:"mx-4 mt-2 mb-3 p-3 bg-red-950/30 border border-red-500/30 rounded-lg",children:(0,A.jsxs)("div",{className:"flex items-start",children:[(0,A.jsx)("div",{className:"mr-2 mt-0.5 text-red-400 flex-shrink-0",children:(0,A.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,A.jsx)("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),(0,A.jsx)("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),(0,A.jsx)("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}),(0,A.jsxs)("div",{className:"flex-1",children:[(0,A.jsx)("div",{className:"text-sm font-medium text-red-400",children:"Delete All Codes"}),(0,A.jsxs)("div",{className:"text-xs text-red-300/90 mt-1",children:["Delete all ",u.length," access codes for this reservation? This cannot be undone."]}),(0,A.jsxs)("div",{className:"flex gap-2 mt-3",children:[(0,A.jsx)("button",{onClick:()=>v(!1),className:"px-3 py-1.5 text-xs bg-gray-100 dark:bg-white/10 hover:bg-gray-200 dark:hover:bg-white/20 text-gray-900 dark:text-white rounded-md",children:"Cancel"}),(0,A.jsx)("button",{onClick:Y,className:"px-3 py-1.5 text-xs bg-red-500 hover:bg-red-600 text-gray-900 dark:text-white rounded-md",children:"Delete All"})]})]})]})}),p&&(0,A.jsx)("div",{className:"mx-4 mt-2 mb-3 p-3 bg-red-950/30 border border-red-500/30 rounded-lg",children:(0,A.jsxs)("div",{className:"flex items-start",children:[(0,A.jsx)("div",{className:"mr-2 mt-0.5 text-red-400 flex-shrink-0",children:(0,A.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,A.jsx)("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),(0,A.jsx)("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),(0,A.jsx)("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}),(0,A.jsxs)("div",{className:"flex-1",children:[(0,A.jsx)("div",{className:"text-sm font-medium text-red-400",children:"Confirm Deletion"}),(0,A.jsxs)("div",{className:"text-xs text-red-300/90 mt-1",children:['Are you sure you want to delete "',p.name,'"? This action cannot be undone.']}),(0,A.jsxs)("div",{className:"flex gap-2 mt-3",children:[(0,A.jsx)("button",{onClick:()=>{b(null)},className:"px-3 py-1.5 text-xs bg-gray-100 dark:bg-white/10 hover:bg-gray-200 dark:hover:bg-white/20 text-gray-900 dark:text-white rounded-md",children:"Cancel"}),(0,A.jsx)("button",{onClick:()=>{if(!p?.id)return void console.error("Cannot delete access code: Missing code ID");let t=C?.id,a=I?.id||C?.listingId||C?.listing?.id;if(!t||!a){console.error("Cannot delete access code: Missing reservation or listing ID"),V(e=>({...e,error:"Missing required information to delete the access code"})),b(null);return}m(!0);let r=new CustomEvent("command-action",{detail:{command:{type:"direct",topic:"seam",event:"seam.accessCode.delete",payload:{accessCodeId:p.id,reservationId:t,listingId:a,customerId:N?.customerId||1,userId:N?.userId||"",userName:N?.userName||""}}}});document.dispatchEvent(r);let s=t=>{let{action:a,success:r,error:n}=t.detail;"seam.accessCode.delete"===a.event&&(r?(h(e=>e.filter(e=>e.id!==p.id)),x===p.id&&(g(null),V({name:`${B}'s Access Code`,code:"",startsAt:O,endsAt:U,isMissingField:!1,codeError:"",codeId:""}))):i({...e,error:n||"Failed to delete access code"}),m(!1),b(null),document.removeEventListener("command:result",s))};document.addEventListener("command:result",s)},className:"px-3 py-1.5 text-xs bg-red-500 hover:bg-red-600 text-gray-900 dark:text-white rounded-md",children:"Delete"})]})]})]})}),(0,A.jsxs)("div",{className:"relative flex flex-col min-h-[400px] max-h-[600px]",children:[(0,A.jsxs)("div",{className:"flex-1 overflow-y-auto px-4 py-3",children:[C&&
70(0,A.jsx)("div",{className:"mb-4 p-3 bg-white dark:bg-white/[0.03] rounded-lg",children:(0,A.jsxs)("div",{className:"flex items-start gap-3 mb-3",children:[(0,A.jsx)("div",{className:"relative w-16 h-16 rounded-lg overflow-hidden flex-shrink-0 bg-gray-800",children:z?(0,A.jsx)(X.default,{src:z,alt:q||"Listing",fill:!0,sizes:"(max-width: 768px) 64px, 64px",className:"object-cover"}):(0,A.jsx)("div",{className:"w-full h-full bg-gray-800"})}),(0,A.jsxs)("div",{className:"flex-1",children:[(0,A.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,A.jsx)("h3",{className:"font-medium text-gray-900 dark:text-white",children:B}),(0,A.jsx)("span",{className:"text-sm text-gray-400 dark:text-white/40",children:C.confirmationCode})]}),q&&(0,A.jsx)("div",{className:"text-sm text-gray-500 dark:text-white/60 mb-1",children:q}),(0,A.jsxs)("div",{className:"flex items-center text-xs text-gray-500 dark:text-white/50 gap-1",children:[(0,A.jsx)(e_.Calendar,{className:"w-3 h-3"}),(0,A.jsxs)("span",{children:[(0,ry.format)(n,"MMM d"),"Â ",L&&(0,A.jsxs)("span",{className:"text-gray-400 dark:text-white/40",children:["(",L.hours,":",L.minutes.toString().padStart(2,"0"),")"]}),"Â -Â ",(0,ry.format)(l,"MMM d, yyyy"),"Â ",$&&(0,A.jsxs)("span",{className:"text-gray-400 dark:text-white/40",children:["(",$.hours,":",$.minutes.toString().padStart(2,"0"),")"]})]})]})]})]})}),o&&k&&(0,A.jsx)("div",{className:"mb-4 p-3 bg-amber-500/5 border border-amber-500/20 rounded-lg",children:(0,A.jsxs)("div",{className:"flex items-start gap-2",children:[(0,A.jsx)(sg.AlertCircle,{className:"w-4 h-4 text-amber-400 mt-0.5 flex-shrink-0"}),(0,A.jsxs)("div",{children:[(0,A.jsx)("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Offline codes cannot be edited"}),(0,A.jsx)("div",{className:"text-xs text-gray-500 dark:text-white/60 mt-0.5",children:"This lock uses AlgoPIN. Once created, offline access codes cannot be modified. Delete the code and create a new one instead."})]})]})}),o&&(0,A.jsxs)("div",{className:"mb-4",children:[(0,A.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,A.jsx)("label",{className:"text-xs text-gray-500 dark:text-white/60",children:"Select Access Code to Edit"}),u.length>1&&!f&&(0,A.jsxs)("button",{onClick:()=>v(!0),className:"text-[10px] px-2 py-0.5 rounded text-red-400 hover:text-red-300 hover:bg-red-500/10 transition-colors",children:["Delete All (",u.length,")"]}),f&&(0,A.jsxs)("span",{className:"flex items-center gap-1.5 text-[10px] text-red-400",children:[(0,A.jsx)(rf.Spinner,{className:"w-3 h-3"}),"Deleting..."]})]}),c?(0,A.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,A.jsx)(rf.Spinner,{className:"w-4 h-4"})}):0===u.length?(0,A.jsx)("div",{className:"p-3 bg-white dark:bg-white/[0.03] rounded-lg text-sm text-gray-500 dark:text-white/60",children:"No access codes found for this reservation"}):(0,A.jsx)("div",{className:"space-y-2",children:u.map(e=>(0,A.jsxs)("div",{onClick:()=>{g(e.id),V({name:e.name,code:e.code||"",startsAt:e.startsAt?new Date(e.startsAt):O,endsAt:e.endsAt?new Date(e.endsAt):U,isMissingField:!1,codeError:"",codeId:e.id})},className:(0,ew.cn)("p-3 bg-white dark:bg-white/[0.03] rounded-lg cursor-pointer border border-transparent",x===e.id?"border-blue-500":"hover:border-gray-200 dark:hover:border-white/10"),children:[(0,A.jsxs)("div",{className:"flex justify-between items-center",children:[(0,A.jsxs)("div",{className:"flex items-center gap-2",children:[(0,A.jsx)(rH.Key,{className:"w-4 h-4 text-gray-500 dark:text-white/60"}),(0,A.jsx)("span",{className:"font-medium text-gray-900 dark:text-white",children:e.name})]}),(0,A.jsxs)("div",{className:"flex items-center gap-2",children:[(0,A.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/40",children:e.code||"No code"}),(0,A.jsx)("button",{onClick:t=>{var a;return a={id:e.id,name:e.name},void(t.stopPropagation(),b({id:a.id,name:a.name}))},className:"p-1 hover:bg-gray-100 dark:hover:bg-white/10 rounded-full text-gray-500 dark:text-white/60 hover:text-red-400 transition-colors",title:"Delete access code",children:(0,A.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,A.jsx)("path",{d:"M3 6h18"}),(0,A.jsx)("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}
70),(0,A.jsx)("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})})]})]}),(0,A.jsxs)("div",{className:"mt-1 flex items-center gap-2 text-xs text-gray-500 dark:text-white/60",children:[(0,A.jsx)(e_.Calendar,{className:"w-3 h-3"}),(0,A.jsxs)("span",{children:[e.startsAt?(0,ry.format)(new Date(e.startsAt),"MMM d, yyyy h:mm a"):"No start date"," -",e.endsAt?(0,ry.format)(new Date(e.endsAt),"MMM d, yyyy h:mm a"):"No end date"]})]})]},e.id))})]}),(0,A.jsxs)("div",{className:"mb-3",children:[(0,A.jsx)("label",{className:"block text-xs text-gray-500 dark:text-white/60 mb-1",children:"Code Name"}),(0,A.jsx)("input",{type:"text",value:H.name,onChange:e=>G("name",e.target.value),placeholder:"Enter a name for this code",className:(0,ew.cn)("w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.03] rounded-lg","text-sm text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-white/40","border border-gray-200 dark:border-white/[0.08]","focus:outline-none focus:ring-1 focus:ring-blue-500",H.isMissingField&&!H.name&&"border-red-500")}),H.isMissingField&&!H.name&&(0,A.jsxs)("div",{className:"mt-1 text-xs text-red-400 flex items-center",children:[(0,A.jsx)(sg.AlertCircle,{className:"w-3 h-3 mr-1"}),(0,A.jsx)("span",{children:"Required field"})]})]}),k?(0,A.jsx)("div",{className:"mb-3 p-3 bg-blue-500/5 border border-blue-500/20 rounded-lg",children:(0,A.jsxs)("div",{className:"flex items-start gap-2",children:[(0,A.jsx)(rH.Key,{className:"w-4 h-4 text-blue-400 mt-0.5 flex-shrink-0"}),(0,A.jsxs)("div",{children:[(0,A.jsx)("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Code auto-generated"}),(0,A.jsx)("div",{className:"text-xs text-gray-500 dark:text-white/60 mt-0.5",children:"This lock uses AlgoPIN â the code is generated automatically and will appear once the lock processes it."})]})]})}):(0,A.jsxs)("div",{className:"mb-3",children:[(0,A.jsx)("label",{className:"block text-xs text-gray-500 dark:text-white/60 mb-1",children:"Access Code (Optional)"}),(0,A.jsxs)("div",{className:"relative",children:[(0,A.jsx)("input",{type:"text",value:H.code,onChange:e=>{G("code",e.target.value.replace(/[^0-9]/g,"").slice(0,8))},placeholder:"123456 (leave empty for random)",className:(0,ew.cn)("w-full px-3 py-2 pl-9 bg-gray-50 dark:bg-white/[0.03] rounded-lg","text-sm text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-white/40","border border-gray-200 dark:border-white/[0.08]","focus:outline-none focus:ring-1 focus:ring-blue-500",H.codeError&&"border-red-500")}),(0,A.jsx)(rH.Key,{className:"absolute left-3 top-2.5 w-4 h-4 text-gray-400 dark:text-white/40"})]}),H.codeError?(0,A.jsxs)("div",{className:"mt-1 text-xs text-red-400 flex items-center",children:[(0,A.jsx)(sg.AlertCircle,{className:"w-3 h-3 mr-1"}),(0,A.jsx)("span",{children:H.codeError})]}):(0,A.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/40 mt-1",children:"4-8 digits, leave blank to generate randomly"})]}),(0,A.jsx)("div",{className:"mb-3 relative",style:{zIndex:1},children:(0,A.jsxs)("div",{className:"flex flex-row gap-3",children:[(0,A.jsxs)("div",{className:"flex-1",children:[(0,A.jsx)("label",{className:"block text-xs text-gray-500 dark:text-white/60 mb-1",children:"Valid From"}),(0,A.jsx)(sF,{date:H.startsAt,setDate:e=>G("startsAt",e),className:(0,ew.cn)("w-full",H.isMissingField&&!H.startsAt&&"border-red-500")}),H.isMissingField&&!H.startsAt&&(0,A.jsxs)("div",{className:"mt-1 text-xs text-red-400 flex items-center",children:[(0,A.jsx)(sg.AlertCircle,{className:"w-3 h-3 mr-1"}),(0,A.jsx)("span",{children:"Required field"})]})]}),(0,A.jsxs)("div",{className:"flex-1",children:[(0,A.jsx)("label",{className:"block text-xs text-gray-500 dark:text-white/60 mb-1",children:"Valid Until"}),(0,A.jsx)(sF,{date:H.endsAt,setDate:e=>G("endsAt",e),className:(0,ew.cn)("w-full",H.isMissingField&&!H.endsAt&&"border-red-500")}),H.isMissingField&&!H.endsAt&&(0,A.jsxs)("div",{className:"mt-1 text-xs text-red-400 flex items-center",children:[(0,A.jsx)(sg.AlertCircle,{className:"w-3 h-3 mr-1"}),(0,A.jsx)("span",{children:"Required field"})]})]})]})}),H.isMissingField&&(0,A.jsxs)("div",{className:"p-2.5 mb-3 bg-red-950/30 border border-red-500/30 rounded-lg flex items-center",children:[(0,A.jsx)(sg.AlertCircle,{className:"w-4 h-4 text-red-400 mr-2 flex-shrink-0"}),(0,A.jsx)("div",{className:"text-xs text-red-400",children:"Please fill in all required fields"})]}),e.error&&!e.isLoading&&(0,A.jsxs)("div",{className:"mt-3 p-3 bg-red-950/30 border border-red-500/30 rounded-lg flex items-start",children:[(0,A.jsx)("div",{className:"mr-2 mt
70-0.5 text-red-400 flex-shrink-0",children:(0,A.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,A.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,A.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,A.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}),(0,A.jsxs)("div",{className:"flex-1",children:[(0,A.jsx)("div",{className:"text-sm font-medium text-red-400",children:"Error"}),(0,A.jsx)("div",{className:"text-xs text-red-300/90",children:e.error})]})]}),e.successMessage&&(0,A.jsxs)("div",{className:"mt-3 p-3 bg-green-950/30 border border-green-500/30 rounded-lg flex items-start",children:[(0,A.jsx)("div",{className:"mr-2 mt-0.5 text-green-400 flex-shrink-0",children:(0,A.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,A.jsx)("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),(0,A.jsx)("polyline",{points:"22 4 12 14.01 9 11.01"})]})}),(0,A.jsxs)("div",{className:"flex-1",children:[(0,A.jsx)("div",{className:"text-sm font-medium text-green-400",children:"Success"}),(0,A.jsx)("div",{className:"text-xs text-green-300/90",children:e.successMessage})]})]}),(0,A.jsx)("div",{className:"h-16"})]}),(0,A.jsx)("div",{className:"absolute bottom-0 left-0 right-0 p-4 bg-white dark:bg-[#1c1c1e] border-t border-gray-200 dark:border-white/[0.08] z-50",children:(0,A.jsx)("div",{className:"flex justify-end",children:(0,A.jsx)("button",{onClick:()=>{H.name&&H.startsAt&&H.endsAt?H.code&&(H.code.length<4||H.code.length>8)?V(e=>({...e,codeError:`Access code must be ${H.code.length<4?"at least 4":"at most 8"} digits`})):(K(!0),s({name:H.name,code:H.code||void 0,startsAt:H.startsAt,endsAt:H.endsAt,isEdit:o,accessCodeId:o?x:void 0,codeId:o?x:void 0})):V(e=>({...e,isMissingField:!0}))},disabled:e.commandInProgress||!!H.codeError||o&&k,className:(0,ew.cn)("px-4 py-2 rounded-md","bg-white hover:bg-white/90","text-sm text-black font-medium","transition-colors duration-200",(e.commandInProgress||!!H.codeError||o&&k)&&"opacity-50 cursor-not-allowed"),children:e.commandInProgress?(0,A.jsxs)("span",{className:"flex items-center",children:[(0,A.jsx)(rf.Spinner,{className:"h-4 w-4 text-black mr-2"}),o?"Updating...":"Creating..."]}):o?"Update Access Code":"Create Access Code"})})})]})]})})}function s$({stepState:e,onSubmit:t,onStepStateChange:a=()=>{}}){let[r,s]=(0,R.useState)(""),[i,n]=(0,R.useState)(""),[l,o]=(0,R.useState)(!1),[d,c]=(0,R.useState)(""),m=e?.data?.listing,u=m?.metadata?.id||m?.metadata?.listingId||m?.id,h=m?.metadata?.name||m?.name||"",x=m?.metadata?.thumbnail||m?.metadata?.thumbnailUrl||"",g=e?.metadata||{},p=e?.data?.reservation||g?.reservation||{},b=u||g?.listing?.id||p?.listing?.id||p?.listingId,f=h||g?.listing?.name||p?.listing?.name||"",y=p?.dates||{},w=g?.guest?.name?.full||"",[v,k]=(0,R.useState)(()=>y.checkIn?new Date(y.checkIn+"T12:00:00"):new Date),[j,N]=(0,R.useState)(y.numberOfNights||1),[C,S]=(0,R.useState)(w),[E,I]=(0,R.useState)(""),[T,_]=(0,R.useState)(!1),[D,P]=(0,R.useState)(!1);(0,R.useEffect)(()=>{b&&(o(!0),c(""),fetch(`https://api.vanio.ai/settings/variables/resolve?listingId=${b}`,{credentials:"include"}).then(e=>e.ok?e.json():null).then(e=>{let t=e?.variables||{};t.signature_username&&s(t.signature_username),t.signature_password&&n(t.signature_password)}).catch(()=>c("Failed to load credentials")).finally(()=>o(!1)))},[b]),(0,R.useEffect)(()=>{(e.error||e.successMessage)&&P(!1)},[e.error,e.successMessage]);let M=r&&i&&v&&j>0&&!D,F=(0,ew.cn)("w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.03] rounded-lg","text-sm text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-white/40","border border-gray-200 dark:border-white/[0.08]","focus:outline-none focus:ring-1 focus:ring-blue-500");return(0,A.jsx)(A.Fragment,{children:(0,A.jsxs)(ro.Group,{heading:"Create Signature Reservation",className:(0,ew.cn)("pb-2","[&>[cmdk-group-heading]]:text-xs","[&>[cmdk-group-heading]]:font-medium","[&>[cmdk-group-heading]]:text-gray-500 [&>[cmdk-group-heading]]:dark:text-white/40","[&>[cmdk-group-heading]]:px-2","[&>[cmdk-group-heading]]:pb-1"),children:[(0,A.jsxs)("div",{className:"px-4 py-2 space-y-3",children:[f&&(0,A.jsxs)("div",{className:"flex items-center gap-3 p-3 bg-gray-50 dark:bg-white/[0.03] rounded-lg border border-gray-200 dark:border-white/[0.06]",children:[x?(0,A.jsx)("div",{className:"relative w-12 h-12 rounded-lg overflow-hidden flex-shrink-0 bg-gray-800",children:(0,A.jsx)(X.default,{src:x,alt:f,fill:!0,sizes:"48px",className:"object-cover"})}):(0,A.jsx)("div",{className:"w-12 h-12 rounded-lg bg-gray-100 dark:bg-white/[0.06] flex items-center justify-center flex-shrink-0",children:(0,A.jsx)(rJ.Building,{className:"w-5 h-5 text-gray-400 dark:text-white/30"})}),(0,A.jsxs)("div",{className:"flex-1",children:[(0,A.jsx)("div",{className:"font-medium text-sm text-gray-900 dark:text-white",children:f}),l?(0,A.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-gray-400 dark:text-white/30 mt-0.5",children:[(0,A.jsx)(rf.Spinner,{className:"w-3 h-3"})," Loading credentials..."]}):r?(0,A.jsxs)("div",{className:"flex items-center gap-1 text-xs text-emerald-500 mt-0.5",children:[(0,A.jsx)(em.Check,{className:"w-3 h-3"})," Portal: ",r]}):null]})]}),!r&&!l&&(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsxs)("div",{className:"flex gap-2",children:[(0,A.jsxs)("div",{className:"flex-1",children:[(0,A.jsx)("label",{className:"block text-xs text-gray-500 dark:text-white/60 mb-1",children:"Portal Username"}),(0,A.jsx)("input",{type:"text",value:r,onChange:e=>s(e.target.value),placeholder:"005HA26704",className:(0,ew.cn)(F,T&&!r&&"border-red-500")})]}),(0,A.jsxs)("div",{className:"flex-1",children:[(0,A.jsx)("label",{className:"block text-xs text-gray-500 dark:text-white/60 mb-1",children:"Portal Password"}),(0,A.jsx)("input",{type:"password",value:i,onChange:e=>n(e.target.value),placeholder:"â¢â¢â¢â¢â¢â¢",className:(0,ew.cn)(F,T&&!i&&"border-red-500")})]})]}),(0,A.jsxs)("div",{className:"text-[11px] text-gray-400 dark:text-white/30",children:["Tip: set ",(0,A.jsx)("span",{className:"font-mono",children:"signature_username"})," / ",(0,A.jsx)("span",{className:"font-mono",children:"signature_password"})," in"," ",(0,A.jsx)("a",{href:"/settings/variables",className:"text-blue-400 hover:text-blue-300 underline",children:"Custom Variables"})," to auto-fill per listing."]})]}),(0,A.jsxs)("div",{className:"relative",style:{zIndex:1},children:[(0,A.jsx)("label",{className:"block text-xs text-gray-500 dark:text-white/60 mb-1",children:"Arrival Date"}),(0,A.jsx)(sF,{date:v,setDate:e=>k(e),className:(0,ew.cn)("w-full",T&&!v&&"border-red-500")})]}),(0,A.jsxs)("div",{children:[(0,A.jsx)("label",{className:"block text-xs text-gray-500 dark:text-white/60 mb-1",children:"Nights"}),(0,A.jsxs)("div",{className:"relative",children:[(0,A.jsx)("input",{type:"number",min:1,value:j,onChange:e=>N(parseInt(e.target.value)||1),className:(0,ew.cn)(F,"pl-9")}),(0,A.jsx)(e_.Calendar,{className:"absolute left-3 top-2.5 w-4 h-4 text-gray-400 dark:text-white/40"})]})]}),(0,A.jsxs)("div",{children:[(0,A.jsx)("label",{className:"block text-xs text-gray-500 dark:text-white/60 mb-1",children:"Guest Name"}),(0,A.jsxs)("div",{className:"relative",children:[(0,A.jsx)("input",{type:"text",value:C,onChange:e=>S(e.target.value),placeholder:'Leave empty for "Myself"',className:(0,ew.cn)(F,"pl-9")}),(0,A.jsx)(rq.Users,{className:"absolute left-3 top-2.5 w-4 h-4 text-gray-400 dark:text-white/40"})]}),(0,A.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/40 mt-1",children:"Select from Friends & Family profiles or leave empty"})]}),(0,A.jsxs)("div",{children:[(0,A.jsx)("label",{className:"block text-xs text-gray-500 dark:text-white/60 mb-1",children:"Comments (optional)"}),(0,A.jsx)("textarea",{value:E,onChange:e=>I(e.target.value),placeholder:"Notes for the reservation...",rows:2,className:(0,ew.cn)(F,"resize-none min-h-[52px]")})]}),T&&(!r||!i)&&(0,A.jsxs)("div",{className:"flex items-center text-xs text-red-400 gap-1",children:[(0,A.jsx)(sg.AlertCircle,{className:"w-3 h-3"}),(0,A.jsx)("span",{children:"Portal credentials are required"})]}),(0,A.jsx)("div",{className:"h-16"})]}),(0,A.jsx)("div",{className:"absolute bottom-0 left-0 right-0 p-4 bg-white dark:bg-[#1c1c1e] border-t border-gray-200 dark:border-white/[0.08] z-50",children:(0,A.jsx)("div",{className:"flex justify-end",children:(0,A.jsx)("button",{onClick:()=>
70{if(!M)return void _(!0);P(!0),_(!1);let e=v.getMonth()+1,a=v.getDate(),s=v.getFullYear();t({username:r,password:i,arrivalDate:`${e}/${a}/${s}`,numNights:j,numGuests:1,guestName:C||void 0,comments:E||void 0,listingId:b})},disabled:!M,className:(0,ew.cn)("px-4 py-2 rounded-md","bg-white hover:bg-white/90","text-sm text-black font-medium","transition-colors duration-200",!M&&"opacity-50 cursor-not-allowed"),children:D?(0,A.jsxs)("span",{className:"flex items-center",children:[(0,A.jsx)(rf.Spinner,{className:"h-4 w-4 text-black mr-2"}),"Creating..."]}):"Create Reservation"})})})]})})}e.s(["DateTimePicker",0,sF],406671);var sO=e.i(727612),sU=e.i(284614);function sB({stepState:e,commandEvent:t,onStepStateChange:a=()=>{}}){let[r,s]=(0,R.useState)(""),[i,n]=(0,R.useState)(""),[l,o]=(0,R.useState)(!1),[d,c]=(0,R.useState)(""),[m,u]=(0,R.useState)(!1),[h,x]=(0,R.useState)(""),[g,p]=(0,R.useState)([]),[b,f]=(0,R.useState)([]),[y,w]=(0,R.useState)(null),[v,k]=(0,R.useState)(new Set),j=e?.data?.listing,N=j?.metadata?.id||j?.metadata?.listingId||j?.id,C=j?.metadata?.name||j?.name||"",S=j?.metadata?.thumbnail||j?.metadata?.thumbnailUrl||"",E=e?.metadata||{},I=e?.data?.reservation||E?.reservation||{},T=N||E?.listing?.id||I?.listing?.id||I?.listingId,_=C||E?.listing?.name||I?.listing?.name||"",D="signature.reservation.cancel"===t,P="signature.profiles.list"===t;(0,R.useEffect)(()=>{T&&(o(!0),c(""),fetch(`https://api.vanio.ai/settings/variables/resolve?listingId=${T}`,{credentials:"include"}).then(e=>e.ok?e.json():null).then(e=>{let t=e?.variables||{};t.signature_username&&s(t.signature_username),t.signature_password&&n(t.signature_password)}).catch(()=>c("Failed to load credentials")).finally(()=>o(!1)))},[T]),(0,R.useEffect)(()=>{!r||!i||m||h||g.length>0||b.length>0||M()},[r,i]);let M=()=>{u(!0),x("");let a=D?"signature.reservation.list":t,s={type:"direct",topic:"signature",event:a,payload:{username:r,password:i,customerId:e.metadata?.customerId||e.metadata?.listing?.customerId||1,metadata:e.metadata}};document.dispatchEvent(new CustomEvent("command-action",{detail:{command:s}}));let n=e=>{let{action:t,success:r,error:s,response:i}=e.detail;t.event===a&&(u(!1),r&&i?P?f(i.data?.profiles||[]):p(i.data?.reservations||[]):x(s||"Command failed"),document.removeEventListener("command:result",n))};document.addEventListener("command:result",n)},F=(0,ew.cn)("pb-2","[&>[cmdk-group-heading]]:text-xs","[&>[cmdk-group-heading]]:font-medium","[&>[cmdk-group-heading]]:text-gray-500 [&>[cmdk-group-heading]]:dark:text-white/40","[&>[cmdk-group-heading]]:px-2","[&>[cmdk-group-heading]]:pb-1");return(0,A.jsx)(ro.Group,{heading:P?"Signature Guest Profiles":D?"Cancel Signature Reservation":"Signature Reservations",className:F,children:(0,A.jsxs)("div",{className:"px-4 py-2 space-y-3",children:[_&&(0,A.jsxs)("div",{className:"flex items-center gap-3 p-3 bg-gray-50 dark:bg-white/[0.03] rounded-lg border border-gray-200 dark:border-white/[0.06]",children:[S?(0,A.jsx)("div",{className:"relative w-10 h-10 rounded-lg overflow-hidden flex-shrink-0 bg-gray-800",children:(0,A.jsx)(X.default,{src:S,alt:_,fill:!0,sizes:"40px",className:"object-cover"})}):(0,A.jsx)("div",{className:"w-10 h-10 rounded-lg bg-gray-100 dark:bg-white/[0.06] flex items-center justify-center flex-shrink-0",children:(0,A.jsx)(rJ.Building,{className:"w-4 h-4 text-gray-400 dark:text-white/30"})}),(0,A.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,A.jsx)("div",{className:"font-medium text-sm text-gray-900 dark:text-white truncate",children:_}),r&&(0,A.jsxs)("div",{className:"text-xs text-gray-400 dark:text-white/40 mt-0.5",children:["Portal: ",r]})]})]}),!l&&!r&&!d&&(0,A.jsx)("div",{className:"p-3 bg-gray-50 dark:bg-white/[0.03] border border-gray-200 dark:border-white/[0.06] rounded-lg",children:(0,A.jsxs)("div",{className:"text-xs text-gray-500 dark:text-white/50",children:["No Signature credentials found for this listing. Set ",(0,A.jsx)("span",{className:"font-mono text-[10px]",children:"signature_username"})," / ",(0,A.jsx)("span",{className:"font-mono text-[10px]",children:"signature_password"})," in"," ",(0,A.jsx)("a",{href:"/settings/variables",className:"text-blue-400 hover:text-blue-300 underline",children:"Custom Variables"}),"."]})}),d&&(0,A.jsx)("div",{className:"p-3 bg-red-500/5 border border-red-500/20 rounded-lg",children:(0,A.jsx)("div",{className:"text-xs text-red-400",children:d})}),(l||m)&&(0,A.jsxs)("div",{className:"flex items-center justify-center py-8 gap-2",children:[(0,A.jsx)(rf.Spinner,{className:"w-5 h-5 text-gray-400 dark:text-white/40"}),(0,A.jsx)("span",{className:"text-sm text-gray-500 dark:text-white/50",children:l?"Loading credentials...":"Fetching from Signature portal..."})]}),h&&(0,A.jsx)("div",{className:"p-3 bg-red-500/5 border border-red-500/20 rounded-lg",children:(0,A.jsxs)("div",{className:"flex items-start gap-2",children:[(0,A.jsx)(sg.AlertCircle,{className:"w-4 h-4 text-red-400 mt-0.5 flex-shrink-0"}),(0,A.jsx)("div",{className:"text-sm text-red-400",children:h})]})}),!m&&!l&&g.length>0&&(0,A.jsx)("div",{className:"space-y-2",children:g.map((t,a)=>{let s=v.has(a),n=y===a;return(0,A.jsx)("div",{className:(0,ew.cn)("p-3 rounded-lg border transition-all",s?"bg-red-500/5 border-red-500/20 opacity-60":"bg-gray-50 dark:bg-white/[0.03] border-gray-200 dark:border-white/[0.06]"),children:(0,A.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,A.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,A.jsxs)("div",{className:"flex items-center gap-2",children:[(0,A.jsx)("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:t.guestName||"Unknown Guest"}),s&&(0,A.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-red-500/10 text-red-400",children:"Cancelled"})]}),(0,A.jsxs)("div",{className:"flex items-center gap-3 mt-1 text-xs text-gray-500 dark:text-white/50",children:[(0,A.jsxs)("span",{className:"flex items-center gap-1",children:[(0,A.jsx)(e_.Calendar,{className:"w-3 h-3"}),t.arrivalDate]}),t.departureDate&&(0,A.jsxs)("span",{children:["â ",t.departureDate]})]}),t.numNights>0&&(0,A.jsxs)("div",{className:"text-xs text-gray-400 dark:text-white/40 mt-0.5",children:[t.numNights," night(s) · ",t.numGuests," guest(s)"]}),t.comments&&(0,A.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/40 mt-1 italic",children:t.comments})]}),!s&&(0,A.jsx)("button",{onClick:()=>{let t,s;return w(a),t={type:"direct",topic:"signature",event:"signature.reservation.cancel",payload:{username:r,password:i,reservationId:String(a),customerId:e.metadata?.customerId||e.metadata?.listing?.customerId||1,metadata:e.metadata}},document.dispatchEvent(new CustomEvent("command-action",{detail:{command:t}})),s=e=>{let{action:t,success:r,error:i}=e.detail;"signature.reservation.cancel"===t.event&&(w(null),r?k(e=>new Set([...e,a])):x(i||"Failed to cancel reservation"),document.removeEventListener("command:result",s))},void document.addEventListener("command:result",s)},disabled:n||null!==y,className:(0,ew.cn)("px-3 py-1.5 rounded-md text-xs font-medium transition-colors flex items-center gap-1.5","bg-red-500/10 text-red-400 hover:bg-red-500/20 border border-red-500/20",(n||null!==y)&&"opacity-50 cursor-not-allowed"),children:n?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(rf.Spinner,{className:"w-3 h-3"})," Cancelling..."]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(sO.Trash2,{className:"w-3 h-3"})," Cancel"]})})]})},t.portalId||a)})}),!m&&!l&&!h&&("signature.reservation.list"===t||D)&&0===g.length&&r&&(0,A.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 text-gray-400 dark:text-white/40",children:[(0,A.jsx)(e_.Calendar,{className:"w-8 h-8 mb-2 opacity-50"}),(0,A.jsx)("span",{className:"text-sm",children:"No upcoming reservations"})]}),!m&&!l&&b.length>0&&(0,A.jsxs)("div",{className:"space-y-1",children:[(0,A.jsxs)("div",{className:"text-xs text-gray-400 dark:text-white/40 px-1 mb-2",children:[b.length," profile(s) â Friends & Family"]}),(0,A.jsx)("div",{className:"max-h-[300px] overflow-y-auto space-y-1",style:{overscrollBehavior:"contain"},children:b.map(e=>(0,A.jsxs)("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-gray-50 dark:bg-white/[0.03] border border-gray-200 dark:border-white/[0.06]",children:[(0,A.jsx)("div",{className:"w-7 h-7 rounded-full bg-gray-100 dark:bg-white/[0.06] flex items-center justify-center flex-shrink-0",children:(0,A.jsx)(sU.User,{className:"w-3.5 h-3.5 text-gray-400 dark:text-white/30"})}),(0,A.jsx)("div",{className:"flex-1 min-w-0",children:(0,A.jsx)("div",{className:"text-sm text-gray-900 dark:text-white truncate",children:e.name})}),(0,A.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/30 font-mono",children:e.id})]},e.id))})]}),!m&&!l&&!h&&P&&0===b.length&&r&&(0,A.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 text-gray-400 dark:text-white/40",children:[(0,A.jsx)(rq.Users,{className:"w-8 h-8 mb-2 opacity-50"}),(0,A.jsx)("span",{className:"text-sm",children:"No guest profiles found"})]})]})})}function sq({stepState:e,onSubmit:t,onCancel:a}){let r,s,[i,n]=(0,R.useState)(!1),[l,o]=(0,R.useState)(null),d=e.currentStep,c=async(e=null)=>{if(e&&e.preventDefault(),!i)try{n(!0),await t()}catch(e){console.error("[ConfirmationSuggestions] Error:",e),o(e instanceof Error?e.message:"An error occurred")}finally{n(!1)}};return(0,R.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&(e.preventDefault(),c())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[c]),(0,A.jsxs)("div",{className:"px-4 py-3",children:[(0,A.jsxs)("div",{className:"flex items-start gap-3 mb-4",children:[d.dangerousAction&&(0,A.jsx)(es.AlertTriangle,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),(0,A.jsxs)("div",{children:[(0,A.jsx)("div",{className:"font-medium text-gray-900 dark:text-white mb-1",children:d.title}),(0,A.jsx)("div",{className:"text-sm text-gray-600 dark:text-white/70",children:(r=d.message,s=e.data.listing||e.data.newListing,r.includes("{{listingName}}")&&s?.name&&(r=r.replace("{{listingName}}",s.name)),r)})]})]}),l&&(0,A.jsx)("div",{className:"mb-4 p-3 text-sm text-red-500 bg-red-500/10 rounded-md error-message",children:l}),(0,A.jsxs)("div",{className:"flex items-center justify-end gap-2 mt-4",children:[(0,A.jsx)("button",{type:"button",onClick:a,disabled:i,className:(0,ew.cn)("px-3 py-1.5 text-sm","text-gray-600 dark:text-white/70 hover:text-gray-900 dark:hover:text-white transition-colors",i&&"opacity-50 cursor-not-allowed"),children:d.cancelLabel||"Cancel"}),(0,A.jsx)("button",{type:"button",onClick:e=>c(e),disabled:i,className:(0,ew.cn)("px-4 py-1.5 rounded-md text-sm font-medium","flex items-center justify-center min-w-[100px]",d.dangerousAction?"bg-red-500 hover:bg-red-600":"bg-blue-500 hover:bg-blue-600","text-gray-900 dark:text-white transition-colors",i&&"opacity-50 cursor-not-allowed"),children:i?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(rf.Spinner,{className:"w-4 h-4 mr-2"}),"Processing..."]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("span",{children:d.confirmLabel||"Confirm"}),(0,A.jsxs)("div",{className:"ml-2 flex items-center gap-1 bg-gray-200 dark:bg-white/20 dark:bg-white/10 px-1.5 py-0.5 rounded text-xs text-gray-600 dark:text-white/80 dark:text-white/70",children:[(0,A.jsx)(er.Command,{className:"w-3 h-3"}),(0,A.jsx)("span",{children:"+"}),(0,A.jsx)("span",{children:"âµ"})]})]})})]})]})}var sz=e.i(719708),sH=e.i(526050);function sV({heading:e="Enter reason",placeholder:t="Type your reason here...",required:a=!0,checkboxLabel:r,checkboxKey:s,onSelect:i,className:n}){let[l,o]=(0,R.useState)(""),[d,c]=(0,R.useState)(!1),m=(0,R.useCallback)(()=>
70{if(!l.trim()&&a)return;let e={reason:l.trim()};s&&(e[s]=d),i(e)},[l,a,d,s,i]);return(0,A.jsxs)(rr,{className:(0,ew.cn)("px-2 pb-2 flex flex-col gap-2",n),children:[e&&(0,A.jsx)("div",{className:"text-sm text-gray-500 dark:text-white/60 px-2 pb-2 border-b border-gray-200 dark:border-white/10",children:e}),(0,A.jsxs)("div",{className:"space-y-4",children:[(0,A.jsx)(sH.Textarea,{value:l,onChange:e=>o(e.target.value),placeholder:t,className:"min-h-[100px] bg-gray-50 dark:bg-white/5 border-gray-200 dark:border-white/10 resize-none",onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&(e.preventDefault(),m())}}),r&&(0,A.jsxs)("label",{className:"flex items-center gap-2 px-2 cursor-pointer select-none",children:[(0,A.jsx)("input",{type:"checkbox",checked:d,onChange:e=>c(e.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-white/20 text-blue-500 focus:ring-blue-500/20"}),(0,A.jsx)("span",{className:"text-sm text-gray-600 dark:text-white/70",children:r})]}),(0,A.jsxs)("div",{className:"flex items-center justify-between px-2",children:[(0,A.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/40",children:a&&!l.trim()?(0,A.jsx)("span",{className:"text-red-400",children:"* Required"}):(0,A.jsxs)("span",{children:["Press ",navigator.platform.includes("Mac")?"â":"Ctrl"," + Enter to submit"]})}),(0,A.jsx)(sz.Button,{size:"sm",onClick:m,disabled:a&&!l.trim(),children:"Continue"})]})]})]})}var sG=e.i(56443),sW=e.i(75998);function sK(e,t){return e?e.replace(/\{\{\s*([\w.-]+)\s*\}\}/g,(e,a)=>t&&Object.prototype.hasOwnProperty.call(t,a)?t[a]??"":e):""}function sY(e,t){let a={};if(!e||0===e.length)return a;let r=t||{};for(let t of e){if(!t||!t.key)continue;let e=r[t.key],s="string"==typeof e&&""!==e.trim();a[t.key]=s?e:t.defaultValue??""}return a}var sJ=e.i(950086),sQ=e.i(173922),sX=e.i(560491);function sZ(e){let[t,a,r]=e.substring(0,10).split("-").map(Number);return new Date(t,(a||1)-1,r||1)}function s0(e){let{data:t,isLoading:a}=(0,sX.default)(e?["/api/tasks/listing-bookings",e]:null,async([e,t])=>{let a=await fetch(`${e}?listingId=${t}`,{headers:{"Content-Type":"application/json"}});if(!a.ok)throw Error("Failed to fetch listing bookings");return a.json()},{revalidateOnFocus:!1,revalidateIfStale:!1,dedupingInterval:6e4});return(0,R.useMemo)(()=>({checkInDates:(t?.checkInDates||[]).map(sZ),checkOutDates:(t?.checkOutDates||[]).map(sZ),nextCheckout:t?.nextCheckout?sZ(t.nextCheckout):null,nextCheckoutReservationId:t?.nextCheckoutReservationId??null,isLoading:!!e&&a}),[t,a,e])}e.s(["useListingBookings",0,s0],719910);var s1=e.i(45393),s2=e.i(283390),s5=e.i(201795),s4=e.i(286536),s3=e.i(201928),s6=e.i(194983),s8=e.i(358519),s9=e.i(548433),s7=e.i(354385),ie=e.i(656272),it=e.i(968553),ia=e.i(387951),ir=e.i(908821),ir=ir;let is=[{value:"cleaning",label:"Cleaning",icon:eH.Sparkles},{value:"maintenance",label:"Maintenance",icon:eV.Wrench},{value:"inspection",label:"Inspection",icon:s4.Eye},{value:"turnover",label:"Turnover",icon:r6.RefreshCw},{value:"deep_cleaning",label:"Deep Cleaning",icon:s8.Brush},{value:"laundry",label:"Laundry",icon:s9.Bed},{value:"purchase",label:"Purchase",icon:s3.ShoppingCart},{value:"communication",label:"Communication",icon:s6.MessageCircle},{value:"documentation",label:"Documentation",icon:rB.FileText},{value:"other",label:"Other",icon:s7.ClipboardCheck}],ii=[{value:"low",label:"Low",color:"text-blue-400"},{value:"medium",label:"Medium",color:"text-yellow-400"},{value:"high",label:"High",color:"text-orange-400"},{value:"urgent",label:"Urgent",color:"text-red-400"}],il=[{value:"none",label:"Doesn't repeat"},{value:"daily",label:"Daily"},{value:"weekly",label:"Weekly"},{value:"monthly",label:"Monthly"},{value:"custom",label:"Custom"}],io=[{value:"day",label:"Days"},{value:"week",label:"Weeks"},{value:"month",label:"Months"}],id={daily:{every:1,unit:"day"},weekly:{every:1,unit:"week"},monthly:{every:1,unit:"month"}},ic=({value:e,onChange:t,options:a,placeholder:r,className:s})=>{let[i,n]=(0,R.useState)(!1),l=(0,R.useRef)(null),o=a.find(t=>t.value===e);return(0,R.useEffect)(()=>{let e=e=>{l.current&&!l.current.contains(e.target)&&(n(!1),e.stopPropagation())};return i&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[i]),(0,A.jsxs)("div",{className:(0,ew.cn)("relative",s),ref:l,children:[(0,A.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),n(!i)},className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-md text-gray-900 dark:text-white text-sm focus:outline-none focus:ring-1 focus:ring-blue-500 flex items-center justify-between hover:bg-gray-100 dark:hover:bg-white/[0.04] transition-colors",children:[(0,A.jsxs)("div",{className:"flex items-center gap-2",children:[o?.icon&&(0,A.jsx)(o.icon,{className:(0,ew.cn)("w-4 h-4",o.color)}),o?.dotColor&&(0,A.jsx)("div",{className:(0,ew.cn)("w-2 h-2 rounded-full",o.dotColor)}),(0,A.jsx)("span",{children:o?.label||r})]}),i?(0,A.jsx)(eC.ChevronUp,{className:"w-4 h-4"}):(0,A.jsx)(ec.ChevronDown,{className:"w-4 h-4"})]}),i&&(0,A.jsx)("div",{className:"absolute top-full left-0 right-0 mt-1 bg-white dark:bg-[#1C1C1E] border border-gray-200 dark:border-white/[0.08] rounded-md shadow-lg z-[10000] max-h-60 overflow-y-auto",children:a.map(e=>(0,A.jsxs)("button",{type:"button",onClick:()=>{t(e.value),n(!1)},onMouseDown:e=>e.stopPropagation(),className:"w-full px-3 py-2 text-left hover:bg-gray-100 dark:hover:bg-white/[0.06] transition-colors flex items-center gap-2 text-sm",children:[e.icon&&(0,A.jsx)(e.icon,{className:"w-4 h-4 text-gray-900 dark:text-white"}),e.dotColor&&(0,A.jsx)("div",{className:(0,ew.cn)("w-2 h-2 rounded-full",e.dotColor)}),(0,A.jsxs)("div",{children:[(0,A.jsx)("div",{className:"text-gray-900 dark:text-white",children:e.label}),e.description&&(0,A.jsx)("div",{className:"text-xs text-gray-500 dark:text-white/60",children:e.description})]})]},e.value))})]})},im=({mode:e,userId:t,currentUserId:a,users:r,onChange:s})=>{let[i,n]=(0,R.useState)(!1),[l,o]=(0,R.useState)(""),d=(0,R.useRef)(null);(0,R.useEffect)(()=>{let e=e=>{d.current&&!d.current.contains(e.target)&&(n(!1),e.stopPropagation())};return i&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[i]);let c="user"===e&&t?r.find(e=>e.id===t):void 0,m=(0,R.useMemo)(()=>[...r].filter(e=>!1!==e.active).sort((e,t)=>
70e.id===a?-1:t.id===a?1:(e.name||"").localeCompare(t.name||"")),[r,a]),u=l.trim().toLowerCase(),h=u?m.filter(e=>(e.name||"").toLowerCase().includes(u)||(e.email||"").toLowerCase().includes(u)):m,x=(e,t="w-6 h-6")=>{let a=e.image||e.avatar;return a?(0,A.jsx)("img",{src:a,alt:e.name,className:(0,ew.cn)(t,"rounded-full object-cover flex-shrink-0")}):(0,A.jsx)("div",{className:(0,ew.cn)(t,"rounded-full bg-blue-500/20 text-blue-600 dark:text-blue-300 flex items-center justify-center text-[10px] font-medium uppercase flex-shrink-0"),children:(e.name||"?").charAt(0)})},g="auto"===e?"Auto-assign":"none"===e?"Unassigned":c?c.id===a?`${c.name} (me)`:c.name:t&&t===a?"Me":t?"Selected team member":"Select assignee",p=(e,t)=>{s(e,t),n(!1),o("")},b=(e,t,a,r,s)=>(0,A.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),s()},className:"w-full min-h-[44px] px-3 py-2 text-left hover:bg-gray-100 dark:hover:bg-white/[0.06] transition-colors flex items-center gap-2 border-b border-gray-200 dark:border-white/[0.04]",children:[(0,A.jsx)("div",{className:"w-6 h-6 rounded-full bg-gray-100 dark:bg-white/[0.08] flex items-center justify-center flex-shrink-0",children:e}),(0,A.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,A.jsx)("div",{className:"text-sm text-gray-900 dark:text-white",children:t}),(0,A.jsx)("div",{className:"text-xs text-gray-500 dark:text-white/60 truncate",children:a})]}),r&&(0,A.jsx)(em.Check,{className:"w-4 h-4 text-blue-500 flex-shrink-0"})]});return(0,A.jsxs)("div",{className:"relative",ref:d,children:[(0,A.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),n(!i)},className:"w-full min-h-[44px] px-3 py-2 bg-gray-50 dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-md text-gray-900 dark:text-white text-sm focus:outline-none focus:ring-1 focus:ring-blue-500 flex items-center justify-between hover:bg-gray-100 dark:hover:bg-white/[0.04] transition-colors",children:[(0,A.jsxs)("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:["auto"===e&&(0,A.jsx)(ir.default,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}),"none"===e&&(0,A.jsx)(rW.UserX,{className:"w-4 h-4 text-gray-400 dark:text-white/40 flex-shrink-0"}),"user"===e&&(c?x(c,"w-5 h-5"):(0,A.jsx)(sU.User,{className:"w-4 h-4 text-gray-400 dark:text-white/40 flex-shrink-0"})),(0,A.jsx)("span",{className:"truncate",children:g})]}),i?(0,A.jsx)(eC.ChevronUp,{className:"w-4 h-4 flex-shrink-0"}):(0,A.jsx)(ec.ChevronDown,{className:"w-4 h-4 flex-shrink-0"})]}),i&&(0,A.jsxs)("div",{className:"absolute top-full left-0 right-0 mt-1 bg-white dark:bg-[#1C1C1E] border border-gray-200 dark:border-white/[0.08] rounded-md shadow-lg z-[10000] max-h-80 overflow-hidden",children:[(0,A.jsx)("div",{className:"p-2 border-b border-gray-200 dark:border-white/[0.08]",children:(0,A.jsxs)("div",{className:"relative",children:[(0,A.jsx)(Z.Search,{className:"absolute left-2 top-2.5 w-4 h-4 text-gray-400 dark:text-white/40"}),(0,A.jsx)("input",{type:"text",placeholder:"Search team members...",value:l,onChange:e=>o(e.target.value),onClick:e=>e.stopPropagation(),autoFocus:!0,className:"w-full pl-8 pr-3 py-2 bg-gray-50 dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded text-sm text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-white/40 focus:outline-none focus:ring-1 focus:ring-blue-500"})]})}),(0,A.jsxs)("div",{className:"max-h-60 overflow-y-auto",style:{overscrollBehavior:"contain"},children:[!u&&(0,A.jsxs)(A.Fragment,{children:[b((0,A.jsx)(ir.default,{className:"w-3.5 h-3.5 text-blue-500"}),"Auto-assign","Pick the best available team member automatically","auto"===e,()=>p("auto",null)),b((0,A.jsx)(rW.UserX,{className:"w-3.5 h-3.5 text-gray-400 dark:text-white/40"}),"Unassigned","Create the task without an assignee","none"===e,()=>p("none",null))]}),h.map(r=>{let s="user"===e&&t===r.id;return(0,A.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),p("user",r.id)},className:"w-full min-h-[44px] px-3 py-2 text-left hover:bg-gray-100 dark:hover:bg-white/[0.06] transition-colors flex items-center gap-2 border-b border-gray-200 dark:border-white/[0.04] last:border-b-0",children:[x(r),(0,A.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,A.jsxs)("div",{className:"text-sm text-gray-900 dark:text-white truncate",children:[r.name,r.id===a&&(0,A.jsx)("span",{className:"text-gray-400 dark:text-white/40",children:" (me)"})]}),(0,A.jsxs)("div",{className:"text-xs text-gray-500 dark:text-white/60 truncate",children:[r.roles?.[0]?`${r.roles[0]}${r.email?" · ":""}`:"",r.email]})]}),s&&(0,A.jsx)(em.Check,{className:"w-4 h-4 text-blue-500 flex-shrink-0"})]},r.id)}),0===h.length&&(0,A.jsx)("div",{className:"px-3 py-4 text-center text-gray-500 dark:text-white/60 text-sm",children:0===r.length?"No team members available":"No team members found"})]})]})]})},iu=({customerId:e,workspaceType:t,selectedListingId:a,selectedLabel:r,onChange:s})=>{let[i,n]=(0,R.useState)(!1),[l,o]=(0,R.useState)(""),[d,c]=(0,R.useState)([]),[m,u]=(0,R.useState)(!1),[h,x]=(0,R.useState)(!1),g=(0,R.useRef)(null);(0,R.useEffect)(()=>{let e=e=>{g.current&&!g.current.contains(e.target)&&(n(!1),e.stopPropagation())};return i&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]),(0,R.useEffect)(()=>
70{if(!i||h||!e)return;let a=!1;return u(!0),(async()=>{try{if("service_provider"===t){let e=await fetch("/api/operations/shared-listings",{credentials:"include"}),t=((e.ok?await e.json():{hosts:[]}).hosts||[]).map(e=>({label:e.hostName,items:(e.listings||[]).map(t=>({id:t.id,name:t.name,city:t.city,hostName:e.hostName}))}));a||c(t)}else{let t=await fetch(`/api/listings?customerId=${e}&withGroups=true`,{credentials:"include"}),r=t.ok?await t.json():{groups:[]},s=Array.isArray(r?.groups)?r.groups:[],i=s.map(e=>({label:s.length>1?e.name:null,items:(e.listings||[]).map(e=>({id:e.id,name:e.name,city:e.city}))}));a||c(i)}}catch(e){console.error("Failed to load properties for task picker:",e)}finally{a||(u(!1),x(!0))}})(),()=>{a=!0}},[i,h,e,t]);let p=l.trim().toLowerCase(),b=(0,R.useMemo)(()=>p?d.map(e=>({...e,items:e.items.filter(e=>e.name.toLowerCase().includes(p)||(e.city||"").toLowerCase().includes(p))})).filter(e=>e.items.length>0):d,[d,p]),f=(0,R.useMemo)(()=>d.reduce((e,t)=>e+t.items.length,0),[d]),y=e=>{s(e?.id??null,e?.name??null),n(!1),o("")};return(0,A.jsxs)("div",{className:"relative",ref:g,children:[(0,A.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),n(!i)},className:"w-full min-h-[44px] px-3 py-2 bg-gray-50 dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-md text-gray-900 dark:text-white text-sm focus:outline-none focus:ring-1 focus:ring-blue-500 flex items-center justify-between hover:bg-gray-100 dark:hover:bg-white/[0.04] transition-colors",children:[(0,A.jsxs)("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[(0,A.jsx)(Z.Search,{className:"w-4 h-4 text-gray-400 dark:text-white/40 flex-shrink-0"}),(0,A.jsx)("span",{className:(0,ew.cn)("truncate",!r&&"text-gray-400 dark:text-white/40"),children:r||"Select a property (optional)"})]}),i?(0,A.jsx)(eC.ChevronUp,{className:"w-4 h-4 flex-shrink-0"}):(0,A.jsx)(ec.ChevronDown,{className:"w-4 h-4 flex-shrink-0"})]}),i&&(0,A.jsxs)("div",{className:"absolute top-full left-0 right-0 mt-1 bg-white dark:bg-[#1C1C1E] border border-gray-200 dark:border-white/[0.08] rounded-md shadow-lg z-[10000] max-h-80 overflow-hidden",children:[(0,A.jsx)("div",{className:"p-2 border-b border-gray-200 dark:border-white/[0.08]",children:(0,A.jsxs)("div",{className:"relative",children:[(0,A.jsx)(Z.Search,{className:"absolute left-2 top-2.5 w-4 h-4 text-gray-400 dark:text-white/40"}),(0,A.jsx)("input",{type:"text",placeholder:"Search properties...",value:l,onChange:e=>o(e.target.value),onClick:e=>e.stopPropagation(),autoFocus:!0,className:"w-full pl-8 pr-3 py-2 bg-gray-50 dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded text-sm text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-white/40 focus:outline-none focus:ring-1 focus:ring-blue-500"})]})}),(0,A.jsxs)("div",{className:"max-h-60 overflow-y-auto",style:{overscrollBehavior:"contain"},children:[a&&!p&&(0,A.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),y(null)},className:"w-full min-h-[44px] px-3 py-2 text-left hover:bg-gray-100 dark:hover:bg-white/[0.06] transition-colors flex items-center gap-2 border-b border-gray-200 dark:border-white/[0.04]",children:[(0,A.jsx)("div",{className:"w-6 h-6 rounded-full bg-gray-100 dark:bg-white/[0.08] flex items-center justify-center flex-shrink-0",children:(0,A.jsx)(ei.X,{className:"w-3.5 h-3.5 text-gray-400 dark:text-white/40"})}),(0,A.jsx)("span",{className:"text-sm text-gray-900 dark:text-white",children:"No property"})]}),m&&(0,A.jsxs)("div",{className:"px-3 py-4 flex items-center justify-center gap-2 text-gray-500 dark:text-white/60 text-sm",children:[(0,A.jsx)(rf.Spinner,{className:"w-4 h-4"})," Loading properties..."]}),!m&&b.map((e,t)=>(0,A.jsxs)("div",{children:[e.label&&(0,A.jsx)("div",{className:"px-3 py-1.5 text-xs font-medium text-gray-500 dark:text-white/50 bg-gray-50 dark:bg-white/[0.02] sticky top-0",children:e.label}),e.items.map(e=>{let t=a===e.id;return(0,A.jsxs)("button",{type:"button",onClick:t=>{t.stopPropagation(),y(e)},className:"w-full min-h-[44px] px-3 py-2 text-left hover:bg-gray-100 dark:hover:bg-white/[0.06] transition-colors flex items-center gap-2 border-b border-gray-200 dark:border-white/[0.04] last:border-b-0",children:[(0,A.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,A.jsx)("div",{className:"text-sm text-gray-900 dark:text-white truncate",children:e.name}),e.city&&(0,A.jsx)("div",{className:"text-xs text-gray-500 dark:text-white/60 truncate",children:e.city})]}),t&&(0,A.jsx)(em.Check,{className:"w-4 h-4 text-blue-500 flex-shrink-0"})]},e.id)})]},`${e.label||"grp"}-${t}`)),!m&&0===b.length&&(0,A.jsx)("div",{className:"px-3 py-4 text-center text-gray-500 dark:text-white/60 text-sm",children:0===f?"No properties available":"No properties found"})]})]})]})}
70,ih=({value:e,onChange:t,listingId:a,customerId:r,reservationId:s,reservationData:i})=>{let[n,l]=(0,R.useState)(!1),[o,d]=(0,R.useState)(""),[c,m]=(0,R.useState)([]),[u,h]=(0,R.useState)(!1),x=(0,R.useRef)(null),g=c.find(t=>t.id===e),p=(0,R.useCallback)(async()=>{if(a&&r){h(!0);try{let e=await fetch(`/api/tasks?customerId=${r}&listings=${a}&limit=50`);if(e.ok){let t=await e.json();m(t.tasks||[])}}catch(e){console.error("Failed to fetch tasks:",e)}finally{h(!1)}}},[a,r]);(0,R.useEffect)(()=>{n&&a&&p()},[n,a,p]);let{reservationTasks:b,otherTasks:f}=(e=>{if(!s)return{reservationTasks:[],otherTasks:e};let t=[],a=[];return e.forEach((e,r)=>{e.reservationId===s||e.metadata?.reservationId===s||e.metadata?.reservation?.id===s||e.relations?.some(e=>"reservation"===e.entityType&&e.entityId===s)||e.metadata&&JSON.stringify(e.metadata).includes(s.toString())||i&&e.dueDate&&((e,t)=>{if(!t)return!1;let a=new Date(e),r=new Date(t.checkIn||t.dates?.checkIn),s=new Date(new Date(t.checkOut||t.dates?.checkOut));return s.setDate(s.getDate()+3),a>=r&&a<=s})(e.dueDate,i)?t.push(e):a.push(e)}),{reservationTasks:t,otherTasks:a}})(c.filter(e=>e.title.toLowerCase().includes(o.toLowerCase())||e.category.toLowerCase().includes(o.toLowerCase())));(0,R.useEffect)(()=>{let e=e=>{x.current&&!x.current.contains(e.target)&&(l(!1),e.stopPropagation())};return n&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[n]);let y=e=>{let a=is.find(t=>t.value===e.category),r=ii.find(t=>t.value===e.priority);return(0,A.jsx)("button",{type:"button",onClick:a=>{a.stopPropagation(),t(e.id,e),l(!1)},className:"w-full px-3 py-2 text-left hover:bg-gray-100 dark:hover:bg-white/[0.06] transition-colors border-b border-gray-200 dark:border-white/[0.04] last:border-b-0",children:(0,A.jsx)("div",{className:"flex items-start justify-between",children:(0,A.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,A.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[a?.icon&&(0,A.jsx)(a.icon,{className:"w-3 h-3 text-gray-900 dark:text-white"}),(0,A.jsx)("span",{className:"text-sm text-gray-900 dark:text-white truncate",children:e.title})]}),(0,A.jsxs)("div",{className:"flex items-center gap-3 text-xs text-gray-500 dark:text-white/60",children:[(0,A.jsxs)("div",{className:"flex items-center gap-1",children:[r&&(0,A.jsx)("div",{className:"w-1.5 h-1.5 rounded-full bg-gray-400 dark:bg-white/40"}),(0,A.jsx)("span",{children:r?.label})]}),(0,A.jsxs)("div",{className:"flex items-center gap-1",children:[(0,A.jsx)(e_.Calendar,{className:"w-3 h-3"}),(0,A.jsx)("span",{children:(e=>{let[t,a,r]=e.split("T")[0].split("-").map(Number);return new Date(t,a-1,r).toLocaleDateString("en-US",{month:"short",day:"numeric"})})(e.dueDate)})]}),(0,A.jsx)("span",{className:"capitalize",children:e.status})]})]})})},e.id)};return(0,A.jsxs)("div",{className:"relative",ref:x,children:[(0,A.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),l(!n)},className:"w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-md text-gray-900 dark:text-white text-sm focus:outline-none focus:ring-1 focus:ring-blue-500 flex items-center justify-between hover:bg-gray-100 dark:hover:bg-white/[0.04] transition-colors",children:[(0,A.jsx)("span",{className:"truncate",children:g?g.title:"Select a task to create subtask of (optional)"}),n?(0,A.jsx)(eC.ChevronUp,{className:"w-4 h-4"}):(0,A.jsx)(ec.ChevronDown,{className:"w-4 h-4"})]}),n&&(0,A.jsxs)("div",{className:"absolute top-full left-0 right-0 mt-1 bg-white dark:bg-[#1C1C1E] border border-gray-200 dark:border-white/[0.08] rounded-md shadow-lg z-[10000] max-h-80 overflow-hidden",children:[(0,A.jsx)("div",{className:"p-2 border-b border-gray-200 dark:border-white/[0.08]",children:(0,A.jsxs)("div",{className:"relative",children:[(0,A.jsx)(Z.Search,{className:"absolute left-2 top-2.5 w-4 h-4 text-gray-400 dark:text-white/40"}),(0,A.jsx)("input",{type:"text",placeholder:"Search tasks...",value:o,onChange:e=>d(e.target.value),onClick:e=>e.stopPropagation(),className:"w-full pl-8 pr-3 py-2 bg-gray-50 dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded text-sm text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-white/40 focus:outline-none focus:ring-1 focus:ring-blue-500"})]})}),(0,A.jsxs)("div",{className:"max-h-60 overflow-y-auto",children:[(0,A.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),t(null,null),l(!1)},className:"w-full px-3 py-2 text-left hover:bg-gray-100 dark:hover:bg-white/[0.06] transition-colors text-sm text-gray-500 dark:text-white/60",children:"No parent task - create as standalone task"}),u?(0,A.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,A.jsx)(rf.Spinner,{className:"w-4 h-4"})}):(0,A.jsxs)(A.Fragment,{children:[b.length>0&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)("div",{className:"px-3 py-2 text-xs font-medium text-gray-500 dark:text-white/60 bg-gray-50 dark:bg-white/[0.02] border-b border-gray-200 dark:border-white/[0.04]",children:["This Reservation (",b.length,")"]}),b.map(y)]}),f.length>0&&(0,A.jsxs)(A.Fragment,{children:[b.length>0&&(0,A.jsxs)("div",{className:"px-3 py-2 text-xs font-medium text-gray-500 dark:text-white/60 bg-gray-50 dark:bg-white/[0.02] border-b border-gray-200 dark:border-white/[0.04]",children:["Other Property Tasks (",f.length,")"]}),f.map(y)]}),!u&&0===b.length&&0===f.length&&(0,A.jsx)("div",{className:"px-3 py-4 text-center text-gray-500 dark:text-white/60 text-sm",children:0===c.length?"No tasks available":"No tasks foun
70d matching your search"})]})]})]})]})},ix=({templates:e,onSelect:t,onClear:a,selectedTemplate:r,isLoading:s})=>{let i,[n,l]=(0,R.useState)(!1),[o,d]=(0,R.useState)(""),c=(0,R.useRef)(null),m=e.filter(e=>e.name.toLowerCase().includes(o.toLowerCase())||e.description.toLowerCase().includes(o.toLowerCase())||e.category.toLowerCase().includes(o.toLowerCase()));return(0,R.useEffect)(()=>{let e=e=>{c.current&&!c.current.contains(e.target)&&(l(!1),e.stopPropagation())};return n&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[n]),(0,A.jsxs)("div",{className:"relative",ref:c,children:[(0,A.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),s||l(!n)},disabled:s,className:(0,ew.cn)("w-full px-3 py-2 bg-gray-50 dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-md text-gray-900 dark:text-white text-sm focus:outline-none focus:ring-1 focus:ring-blue-500 flex items-center justify-between hover:bg-gray-100 dark:hover:bg-white/[0.04] transition-colors",s&&"opacity-50 cursor-not-allowed"),children:[(0,A.jsxs)("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[r&&(0,A.jsxs)(A.Fragment,{children:[(i=is.find(e=>e.value===r.category),i?.icon&&(0,A.jsx)(i.icon,{className:"w-4 h-4 text-gray-900 dark:text-white flex-shrink-0"})),(0,A.jsx)("span",{className:"truncate",children:r.name})]}),!r&&(0,A.jsx)("span",{className:"truncate text-gray-500 dark:text-white/60",children:s?"Loading templates...":"Select a task template (optional)"})]}),r&&(0,A.jsx)("div",{onClick:e=>{e.stopPropagation(),a()},className:"p-1 hover:bg-gray-100 dark:hover:bg-white/[0.08] rounded-md text-gray-400 dark:text-white/40 hover:text-gray-700 dark:hover:text-white/70 flex-shrink-0 cursor-pointer",children:(0,A.jsx)(ei.X,{className:"w-3 h-3"})}),s?(0,A.jsx)(rf.Spinner,{className:"w-4 h-4"}):n?(0,A.jsx)(eC.ChevronUp,{className:"w-4 h-4"}):(0,A.jsx)(ec.ChevronDown,{className:"w-4 h-4"})]}),n&&(0,A.jsxs)("div",{className:"absolute top-full left-0 right-0 mt-1 bg-white dark:bg-[#1C1C1E] border border-gray-200 dark:border-white/[0.08] rounded-md shadow-lg z-[10000] max-h-80 overflow-hidden",children:[(0,A.jsx)("div",{className:"p-2 border-b border-gray-200 dark:border-white/[0.08]",children:(0,A.jsxs)("div",{className:"relative",children:[(0,A.jsx)(Z.Search,{className:"absolute left-2 top-2.5 w-4 h-4 text-gray-400 dark:text-white/40"}),(0,A.jsx)("input",{type:"text",placeholder:"Search templates...",value:o,onChange:e=>d(e.target.value),onClick:e=>e.stopPropagation(),className:"w-full pl-8 pr-3 py-2 bg-gray-50 dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded text-sm text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-white/40 focus:outline-none focus:ring-1 focus:ring-blue-500"})]})}),(0,A.jsxs)("div",{className:"max-h-60 overflow-y-auto",children:[r&&(0,A.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),a(),l(!1)},className:"w-full px-3 py-2 text-left hover:bg-gray-100 dark:hover:bg-white/[0.06] transition-colors text-sm text-gray-500 dark:text-white/60 border-b border-gray-200 dark:border-white/[0.04]",children:"Clear template selection"}),s?(0,A.jsxs)("div",{className:"px-3 py-4 text-center text-gray-500 dark:text-white/60 text-sm",children:[(0,A.jsx)(rf.Spinner,{className:"w-4 h-4 mx-auto mb-2"}),"Loading templates..."]}):0===m.length?(0,A.jsx)("div",{className:"px-3 py-4 text-center text-gray-500 dark:text-white/60 text-sm",children:0===e.length?"No templates available":"No templates found"}):m.map(e=>{let a=is.find(t=>t.value===e.category);return(0,A.jsx)("button",{type:"button",onClick:a=>{a.stopPropagation(),t(e),l(!1)},className:"w-full px-3 py-3 text-left hover:bg-gray-100 dark:hover:bg-white/[0.06] transition-colors border-b border-gray-200 dark:border-white/[0.04] last:border-b-0",children:(0,A.jsx)("div",{className:"flex items-start justify-between",children:(0,A.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,A.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[a?.icon&&(0,A.jsx)(a.icon,{className:"w-4 h-4 text-gray-900 dark:text-white"}),(0,A.jsx)("span",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:e.name}),(0,A.jsx)("span",{className:"text-xs px-2 py-1 bg-gray-100 dark:bg-white/[0.1] rounded-full text-gray-500 dark:text-white/60 capitalize",children:e.category.replace("_"," ")})]}),(0,A.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/60 line-clamp-2",children:e.description}),e.checklist&&e.checklist.length>0&&(0,A.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,A.jsx)(ie.CheckSquare,{className:"w-3 h-3 text-gray-400 dark:text-white/40"}),(0,A.jsxs)("span",{className:"text-xs text-gray-400 dark:text-white/40",children:[e.checklist.length," checklist items"]})]})]})})},e.id)})]})]})]})};function ig({stepState:e,selectedIndex:t,selectedId:a,onSuggestionClick:r,search:s}
70){let i,n,l,{data:o}=(0,P.useSession)(),d=(0,q.useRouter)(),c=(0,q.useSearchParams)(),{openSidebar:m}=(0,s5.useTaskSidebar)(),[u,h]=(0,R.useState)({title:"",description:"",category:"maintenance",priority:"medium",dueDate:function(e=new Date){let t=new Date(e);return t.setHours(11,0,0,0),t}(),marketplaceEligible:!1,subtaskOf:null,checklistTemplateId:null,taskTemplateId:null,repeat:"none",repeatEvery:"1",repeatUnit:"week",repeatEndDate:"",assigneeMode:"user",assigneeUserId:null}),x=(0,R.useRef)(u),g=(0,R.useRef)(null),p=(0,R.useRef)(null);(0,R.useEffect)(()=>{x.current=u},[u]);let[b,f]=(0,R.useState)([]),[y,w]=(0,R.useState)([]),[v,k]=(0,R.useState)(!1),[j,N]=(0,R.useState)(null),[C,S]=(0,R.useState)(null),[E,I]=(0,R.useState)({}),[T,_]=(0,R.useState)([]),[D,M]=(0,R.useState)([]),[F,L]=(0,R.useState)(!1),[$,O]=(0,R.useState)([]),[U,B]=(0,R.useState)(!1),z=(0,R.useRef)(null),H=(0,R.useRef)([]);(0,R.useEffect)(()=>{H.current=$},[$]);let V=e.data?.listing||e.metadata?.listing,G=e.data?.reservation||e.metadata?.reservation,W=e.metadata?.task,K=V?.id||e.metadata?.listingId||e.data?.listingId,Y=e.metadata?.customerId||1,J=function(){try{return(0,e8.useCustomer)()}catch{return null}}(),Q=J?.users?.users,[X,Z]=(0,R.useState)([]),ee=Array.isArray(Q)&&Q.length>0,et=J?.workspaceType,[er,es]=(0,R.useState)(null),[en,el]=(0,R.useState)(null),eo=K||er;(0,R.useEffect)(()=>{if(J||!Y)return;let e=!1;return fetch(`/api/user/users?customerId=${Y}`,{credentials:"include"}).then(e=>e.ok?e.json():null).then(t=>{!e&&Array.isArray(t?.users)&&Z(t.users)}).catch(e=>console.error("[TaskSuggestions] Failed to fetch team members:",e)),()=>{e=!0}},[J,Y]);let ed=ee?Q:X,ec=(0,R.useRef)(!1),em=o?.user?.id;(0,R.useEffect)(()=>{!ec.current&&em&&h(e=>"user"!==e.assigneeMode||e.assigneeUserId?e:{...e,assigneeUserId:em})},[em]);let{listing:eu,isLoading:eh,error:ex}=(0,sQ.useListing)(K?Number(K):void 0),{checkInDates:eg,checkOutDates:ep,nextCheckout:eb,nextCheckoutReservationId:ef}=s0(eo?Number(eo):void 0),ey=eu?{listing:{id:eu.id,name:(i=eu.name?.split("·")[0].trim()||"").length>25?i.slice(0,25)+"...":i,thumbnail:eu.thumbnailUrl,location:{street:eu.location?.address,city:eu.location?.city,state:eu.location?.state,address:eu.location?.address},details:{guests:eu.details?.guests,bedrooms:eu.details?.bedrooms,beds:eu.details?.beds,bathrooms:eu.details?.baths,propertyType:eu.propertyTypeCategory,roomType:eu.roomTypeCategory},businessDetails:eu.businessDetails,platformData:eu.platformData}}:null;(0,R.useEffect)(()=>{(async()=>{k(!0);try{let e=await fetch("/api/tasks/templates");if(e.ok){let t=(await e.json()).templates||[];if(t.length>0){let e=t.map(e=>({id:e.id.toString(),name:e.name,description:e.description||"",eventType:"manual",category:e.category||"other",isActive:e.isActive??!0,isDefault:!1,titleTemplate:e.titleTemplate||e.name,descriptionTemplate:e.descriptionTemplate||"",priority:e.priority||"medium",dueDate:{baseDate:"checkOut"===e.dueDateBase?"checkOut":"checkIn",offsetHours:e.dueDateOffsetHours??0},checklist:e.checklist||[],subtasks:e.subtasks||[],marketplaceEligible:e.marketplaceEligible??!0,tags:Array.isArray(e.tags)?e.tags:[],customVariables:Array.isArray(e.customVariables)?e.customVariables:[]}));f(e.filter(e=>e.isActive))}else f([])}let t=await fetch("/api/tasks/checklists/templates");if(t.ok){let e=((await t.json()).templates||[]).map(e=>({id:e.id.toString(),name:e.title||e.name,category:e.category,items:e.checklist||e.items||[],isGlobal:e.isGlobal}));w(e)}}catch(e){console.error("Failed to fetch templates:",e)}finally{k(!1)}})()},[]),(0,R.useEffect)(()=>{if(e.metadata){let t=e.metadata;if(h(e=>({...e,title:""===e.title&&t.suggestedTitle?t.suggestedTitle:e.title,description:""===e.description&&t.suggestedDescription?t.suggestedDescription:e.description,category:t.suggestedCategory||e.category,priority:t.suggestedPriority||e.priority})),t.issueAttachments){let e=t.issueAttachments,a=[],r=e=>{if(!e)return"";let t=new Date(e);return isNaN(t.getTime())?"":t.toLocaleString()};e.photos?.length>0&&a.push(...e.photos.map((e,t)=>{let a=r(e.uploadedAt);return{url:e.url,name:e.caption||`Issue Photo ${t+1}${a?` (${a})`:""}`,type:"image/jpeg",metadata:{source:"issue",originalCaption:e.caption,uploadedAt:e.uploadedAt}}}
70)),e.voiceRecordings?.length>0&&a.push(...e.voiceRecordings.map((e,t)=>{let a=r(e.uploadedAt);return{url:e.url,name:`Issue Voice Recording ${t+1}${a?` (${a})`:""}`,type:"audio/webm",metadata:{source:"issue",duration:e.duration,uploadedAt:e.uploadedAt},transcription:e.transcription}})),e.videos?.length>0&&a.push(...e.videos.map((e,t)=>{let a=r(e.uploadedAt);return{url:e.url,name:e.caption||`Issue Video ${t+1}${a?` (${a})`:""}`,type:"video/mp4",metadata:{source:"issue",duration:e.duration,thumbnail:e.thumbnail,originalCaption:e.caption,uploadedAt:e.uploadedAt}}})),a.length>0&&O(a)}}},[]);let ev=(0,R.useCallback)((e,t)=>{h(a=>({...a,[e]:t}))},[]),ek=async e=>{if(e?.length&&!($.length+e.length>10))try{B(!0);let t=new FormData;t.append("taskId","new"),Array.from(e).forEach(e=>{e.type.startsWith("audio/")?(t.append("file",e,e.name),t.append(`metadata_${e.name}`,JSON.stringify({duration:e.metadata?.duration||0,mimeType:e.type,size:e.size}))):t.append("file",e)});let a=await fetch("/api/tasks/messages",{method:"POST",credentials:"include",body:t}),r=await a.json();if(!r.success)throw Error("Failed to upload files");O(t=>{let a=r.attachments.map((t,a)=>({url:t.url,name:e[a].name,type:e[a].type,metadata:t.metadata,transcription:t.transcription,originalTranscription:t.originalTranscription}));return[...t,...a]}),r.attachments.forEach((t,a)=>{e[a].type.startsWith("audio/")&&t.transcription&&h(e=>({...e,description:e.description.trim()?e.description.trim()+"\n\n"+t.transcription:t.transcription}))})}catch(e){console.error("[TaskSuggestions] Error uploading files:",e)}finally{B(!1)}},ej=async e=>{try{B(!0);let t=new FormData;t.append("taskId","new"),t.append("file",e,e.name),e.type.startsWith("audio/")&&t.append(`metadata_${e.name}`,JSON.stringify({duration:e.metadata?.duration||0,mimeType:e.type,size:e.size}));let a=await fetch("/api/tasks/messages",{method:"POST",credentials:"include",body:t}),r=await a.json();if(!r.success||!r.attachments||0===r.attachments.length)throw Error("Voice note uploaded but attachment not found in response");let s=r.attachments[0];e.type.startsWith("audio/")&&s.transcription&&h(e=>({...e,description:e.description.trim()?e.description.trim()+"\n\n"+s.transcription:s.transcription})),O(t=>[...t,{url:s.url,name:e.name,type:e.type,metadata:{duration:s.metadata?.duration||0,mimeType:s.metadata?.mimeType||e.type},transcription:s.transcription,originalTranscription:s.originalTranscription}])}catch(e){console.error("[TaskSuggestions] Error uploading voice note:",e)}finally{B(!1)}},eN=(0,R.useCallback)(()=>{let t,a,s,i,n,l,o,d,c={...x.current};g.current=c;let m=H.current;if(!c.title.trim())return;L(!0);let u=G?.skipped?void 0:G?.id&&"skip-reservation"!==G.id?G.id:void 0,h="none"===(t=c.repeat)?void 0:"custom"!==t?id[t]:{every:Math.min(99,Math.max(1,Math.round(Number(c.repeatEvery)||1))),unit:c.repeatUnit,...c.repeatEndDate?{endDate:c.repeatEndDate}:{}},p=sY(C?.customVariables||[],E),b=sK(c.title,p);r({id:"task-create",name:b,label:b,metadata:{task:{title:b,description:sK(c.description,p),category:c.category,priority:c.priority,dueDate:(s=(a=c.dueDate).getFullYear(),i=String(a.getMonth()+1).padStart(2,"0"),n=String(a.getDate()).padStart(2,"0"),l=String(a.getHours()).padStart(2,"0"),o=String(a.getMinutes()).padStart(2,"0"),d=String(a.getSeconds()).padStart(2,"0"),`${s}-${i}-${n}T${l}:${o}:${d}`),marketplaceEligible:c.marketplaceEligible,...h&&{recurrence:h},..."user"===c.assigneeMode&&!c.assigneeUserId?{}:{assigneeMode:c.assigneeMode,assigneeUserId:"user"===c.assigneeMode?c.assigneeUserId:null},listingId:eo,reservationId:u,subtaskOf:c.subtaskOf,checklistTemplateId:c.checklistTemplateId,taskTemplateId:c.taskTemplateId,templateId:c.taskTemplateId,...T.length>0?{tags:T}:{},...Object.keys(p).length>0?{customVariables:p}:{},subtasks:C?.subtasks||[],checklist:D.length>0?D:j?.items||[],relatedIssueId:e.metadata?.relatedIssueId,issueType:e.metadata?.issueType,location:e.metadata?.location,allAttachments:m.length>0?m:void 0,hasAttachments:m.length>0}}})},[r,K,eo,G?.id,G?.skipped,C?.subtasks,C?.customVariables,E,T,D,j?.items,e.metadata?.relatedIssueId,e.metadata?.issueType,e.metadata?.location]);(0,R.useEffect)(()=>
70{if((e.error||e.successMessage)&&L(!1),e.successMessage&&e.data?.task?.id){let t=e.data.task.id,a=new URLSearchParams(c?.toString()||"");a.set("task",t.toString()),d.push(`${window.location.pathname}?${a.toString()}`),m(String(t));let r=e.metadata?.reviewContext;r?.reviewId&&r?.listingId!=null&&r?.issueIndex!=null&&fetch(`/api/listings/${r.listingId}/reviews`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({reviewId:String(r.reviewId),issueIndex:r.issueIndex,updates:{dismissed:!0,taskCreated:!0,taskId:String(t)}})}).catch(e=>console.error("Failed to auto-dismiss review issue:",e))}},[e.error,e.successMessage,e.data,e.metadata,d,c,m]);let eC=u.title.trim().length>0;return(0,A.jsxs)("div",{className:"relative flex flex-col h-full",children:[(0,A.jsxs)("div",{className:"flex-1 overflow-y-auto px-4 py-3",children:[K&&(0,A.jsx)("div",{className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-3 mb-4",children:eh?(0,A.jsxs)("div",{className:"flex items-center justify-center py-4",children:[(0,A.jsx)(rf.Spinner,{className:"w-4 h-4"}),(0,A.jsx)("span",{className:"ml-2 text-sm text-gray-500 dark:text-white/60",children:"Loading property..."})]}):ex?(0,A.jsxs)("div",{className:"text-sm text-red-400 py-2",children:["Error loading property: ",ex]}):ey?(0,A.jsx)(st.ReservationListing,{data:ey,showCalendarFeature:!1,showActionButtons:!1,compact:!0,isStatic:!0}):null}),!K&&(0,A.jsxs)("div",{className:"mb-4",children:[(0,A.jsx)("label",{className:"block text-sm font-medium text-gray-600 dark:text-white/80 mb-1.5",children:"Property"}),(0,A.jsx)(iu,{customerId:Number(J?.currentCustomerId||Y),workspaceType:et,selectedListingId:er,selectedLabel:en,onChange:(e,t)=>
70{es(e),el(t)}})]}),(G||W)&&(0,A.jsxs)("div",{className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-3 space-y-2 mb-4",children:[(0,A.jsx)("div",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:"Additional Context"}),G&&(0,A.jsxs)("div",{className:"text-xs text-gray-500 dark:text-white/60 space-y-1",children:[G.confirmationCode&&(0,A.jsxs)("div",{children:["Confirmation: ",G.confirmationCode]}),G.guestName&&(0,A.jsxs)("div",{children:["Guest: ",G.guestName]}),(G.checkIn||G.checkOut||G.dates?.checkIn||G.dates?.checkOut)&&(0,A.jsxs)("div",{children:["Stay: ",(()=>{let e=G.checkIn||G.dates?.checkIn;if(!e)return"N/A";let[t,a,r]=e.split("T")[0].split("-").map(Number);return new Date(t,a-1,r).toLocaleDateString()})()," - ",(()=>{let e=G.checkOut||G.dates?.checkOut;if(!e)return"N/A";let[t,a,r]=e.split("T")[0].split("-").map(Number);return new Date(t,a-1,r).toLocaleDateString()})()]})]}),W&&(0,A.jsxs)("div",{className:"text-xs text-gray-500 dark:text-white/60",children:[(0,A.jsx)("span",{className:"font-medium",children:"Related to Task:"})," ",W.title||`Task #${W.id}`]})]}),(0,A.jsxs)("div",{className:"mb-4",children:[(0,A.jsx)("label",{className:"block text-sm font-medium text-gray-600 dark:text-white/80 mb-2",children:"Task Templates"}),(0,A.jsx)(ix,{templates:b,onSelect:e=>{S(e);let t=e.customVariables||[],a={};for(let e of t)e?.key&&(a[e.key]=e.defaultValue??"");I(a),_(e.tags||[]);let r=e.titleTemplate||e.name||"",s=e.descriptionTemplate||e.description||"";p.current={title:r,description:s};let i=sY(t,a);if(h(t=>({...t,title:sK(r,i),description:sK(s,i),category:e.category,priority:e.priority,marketplaceEligible:e.marketplaceEligible??t.marketplaceEligible,taskTemplateId:e.id})),e.checklist&&e.checklist.length>0&&(M(e.checklist.map((t,a)=>({id:t.id||`template_${e.id}_${a}_${Date.now()}`,title:t.title||t.text||"",text:t.text||t.title||"",required:t.required||!1,section:t.section||""}))),N(null),h(e=>({...e,checklistTemplateId:null}))),e.dueDate&&void 0!==e.dueDate.offsetHours){let t=new Date;"checkOut"===e.dueDate.baseDate&&t.setDate(t.getDate()+1),t.setHours(t.getHours()+e.dueDate.offsetHours),h(e=>({...e,dueDate:t}))}},onClear:()=>{S(null),I({}),_([]),p.current=null,h(e=>({...e,taskTemplateId:null,title:"",description:""})),M([])},selectedTemplate:C,isLoading:v}),C&&(C.customVariables?.length??0)>0&&(0,A.jsxs)("div",{className:"mt-2 p-3 bg-blue-950/20 border border-blue-500/30 rounded-lg space-y-2",children:[(0,A.jsx)("div",{className:"text-xs font-medium text-blue-300",children:"Fill in template variables"}),(0,A.jsx)("div",{className:"space-y-2",children:C.customVariables.map(e=>(0,A.jsxs)("div",{className:"space-y-1",children:[(0,A.jsx)("label",{className:"block text-[11px] text-blue-200/80",children:e.label||e.key}),(0,A.jsx)(sW.Input,{value:E[e.key]??"",placeholder:e.defaultValue||`{{${e.key}}}`,onChange:t=>{var a,r;return a=e.key,r=t.target.value,void I(e=>{let t={...e,[a]:r},s=p.current;if(s){let e=sY(C?.customVariables||[],t);h(t=>({...t,title:sK(s.title,e),description:sK(s.description,e)}))}return t})},className:"bg-gray-50 dark:bg-white/[0.02] border-gray-200 dark:border-white/[0.08] text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-white/40 h-8 text-sm"})]},e.key))}),(0,A.jsxs)("div",{className:"text-[11px] text-blue-300/70",children:["These values fill ","{{placeholders}}"," in the title and description."]})]}),C&&T.length>0&&(0,A.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-1.5",children:[(0,A.jsx)("span",{className:"text-[11px] text-gray-500 dark:text-white/50",children:"Tags:"}),T.map(e=>(0,A.jsx)("span",{className:"inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-medium",style:e.color?{backgroundColor:`${e.color}22`,color:e.color}:void 0,children:e.name},e.name))]})]}),(0,A.jsxs)("div",{className:"space-y-4",children:[(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:"Create as Subtask of"}),(0,A.jsx)(ih,{value:u.subtaskOf,onChange:(e,t)=>
70{if(ev("subtaskOf",e),t&&t.dueDate){let e=new Date(new Date(t.dueDate));e.setDate(e.getDate()-1);let a=new Date;e<a&&e.setTime(a.getTime()),ev("dueDate",e)}},listingId:K,customerId:Number(J?.currentCustomerId||Y),reservationId:G?.id,reservationData:G})]}),(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:"Title *"}),(0,A.jsx)(sW.Input,{placeholder:"What needs to be done?",value:u.title,onChange:e=>ev("title",e.target.value),className:"bg-gray-50 dark:bg-white/[0.02] border-gray-200 dark:border-white/[0.08] text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-white/40"})]}),(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:"Description"}),(0,A.jsx)(sH.Textarea,{placeholder:"Add more details about this task...",value:u.description,onChange:e=>ev("description",e.target.value),className:"bg-gray-50 dark:bg-white/[0.02] border-gray-200 dark:border-white/[0.08] text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-white/40 min-h-[80px]"})]}),(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:"Due Date"}),(0,A.jsx)(sF,{date:u.dueDate,setDate:e=>ev("dueDate",e),className:"bg-gray-50 dark:bg-white/[0.02] border-gray-200 dark:border-white/[0.08] text-gray-900 dark:text-white",checkInDates:eg,checkOutDates:ep,nextCheckout:eb,nextCheckoutReservationId:ef,nextCheckoutListingId:eo?Number(eo):null})]}),(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:"Repeat"}),(0,A.jsx)("div",{className:"flex flex-wrap gap-2",children:il.map(e=>(0,A.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),ev("repeat",e.value)},className:(0,ew.cn)("min-h-[44px] px-3 rounded-md border text-sm transition-colors",u.repeat===e.value?"border-blue-500 bg-blue-500/10 text-blue-600 dark:text-blue-400":"border-gray-200 dark:border-white/[0.08] bg-gray-50 dark:bg-white/[0.02] text-gray-600 dark:text-white/80 hover:bg-gray-100 dark:hover:bg-white/[0.04]"),children:e.label},e.value))}),"custom"===u.repeat&&(0,A.jsxs)("div",{className:"space-y-2 p-3 bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg",children:[(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,A.jsx)("span",{className:"text-sm text-gray-600 dark:text-white/80",children:"Every"}),(0,A.jsx)("input",{type:"number",inputMode:"numeric",min:1,max:99,value:u.repeatEvery,onChange:e=>{let t=e.target.value;""===t?ev("repeatEvery",""):ev("repeatEvery",String(Math.min(99,Math.max(1,Math.round(Number(t)||1)))))},onClick:e=>e.stopPropagation(),className:"w-16 min-h-[44px] px-2 bg-gray-50 dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-md text-sm text-center text-gray-900 dark:text-white focus:outline-none focus:ring-1 focus:ring-blue-500"}),(0,A.jsx)(ic,{value:u.repeatUnit,onChange:e=>ev("repeatUnit",e),options:io,placeholder:"Select unit",className:"flex-1 min-w-[120px]"})]}),(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,A.jsx)("span",{className:"text-sm text-gray-600 dark:text-white/80",children:"Ends"}),(0,A.jsx)("input",{type:"date",value:u.repeatEndDate,onChange:e=>ev("repeatEndDate",e.target.value),onClick:e=>e.stopPropagation(),className:"flex-1 min-w-[150px] min-h-[44px] px-2 bg-gray-50 dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-md text-sm text-gray-900 dark:text-white focus:outline-none focus:ring-1 focus:ring-blue-500 [color-scheme:light] dark:[color-scheme:dark]"}),u.repeatEndDate?(0,A.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),ev("repeatEndDate","")},className:"min-h-[44px] min-w-[44px] flex items-center justify-center rounded-md hover:bg-gray-100 dark:hover:bg-white/[0.08] text-gray-400 dark:text-white/40 hover:text-gray-700 dark:hover:text-white/70 transition-colors",title:"Clear end date",children:(0,A.jsx)(ei.X,{className:"w-4 h-4"})}):(0,A.jsx)("span",{className:"text-xs text-gray-400 dark:text-white/40",children:"optional"})]})]}),"none"!==u.repeat&&"custom"!==u.repeat&&(0,A.jsxs)("div",{className:"text-xs text-gray-400 dark:text-white/40",children:["A new task will be created ","daily"===u.repeat?"every day":"weekly"===u.repeat?"every week":"every month"," after the first due date."]})]}),(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:"Assignee"}),(0,A.jsx)(im,{mode:u.assigneeMode,userId:u.assigneeUserId,currentUserId:em||null,users:ed,onChange:(e,t)=>
70{ec.current=!0,h(a=>({...a,assigneeMode:e,assigneeUserId:t}))}}),"auto"===u.assigneeMode&&(0,A.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/40",children:"The best available team member will be assigned automatically."}),"none"===u.assigneeMode&&(0,A.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/40",children:"The task will be created without an assignee."})]}),(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsxs)("div",{className:"flex items-center justify-between",children:[(0,A.jsx)("label",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:"Attachments"}),(0,A.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,A.jsx)("button",{type:"button",onClick:()=>{(0,sG.openFilePicker)(z.current,{accept:"image/*,video/*",capture:"environment"})},disabled:U,className:"p-1.5 rounded-md hover:bg-gray-100 dark:hover:bg-white/[0.08] text-gray-400 dark:text-white/40 hover:text-gray-700 dark:hover:text-white/70 transition-colors disabled:opacity-50",title:"Take photo/video",children:(0,A.jsx)(it.Camera,{className:"w-4 h-4"})}),(0,A.jsx)("button",{type:"button",onClick:()=>{(0,sG.openFilePicker)(z.current,{accept:null,capture:null,multiple:!0})},disabled:U,className:"p-1.5 rounded-md hover:bg-gray-100 dark:hover:bg-white/[0.08] text-gray-400 dark:text-white/40 hover:text-gray-700 dark:hover:text-white/70 transition-colors disabled:opacity-50",title:"Attach files",children:(0,A.jsx)(ea.Plus,{className:"w-4 h-4"})}),(0,A.jsx)(function({onUpload:e}){let[t,a]=(0,R.useState)(!1),[r,s]=(0,R.useState)(null),[i,n]=(0,R.useState)(0),l=(0,R.useRef)(null),o=(0,R.useRef)([]),d=(0,R.useRef)(0);(0,R.useEffect)(()=>(t?(n(0),d.current=0,l.current=setInterval(()=>{n(e=>(d.current=e+1,e+1))},1e3)):l.current&&clearInterval(l.current),()=>{l.current&&clearInterval(l.current)}),[t]);let c=async()=>{try{let t=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),r=new MediaRecorder(t,{mimeType:MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":"audio/webm"});o.current=[],r.ondataavailable=e=>{e.data.size>0&&o.current.push(e.data)},r.onstop=async()=>{try{await new Promise(e=>setTimeout(e,100));let t=o.current;if(0===t.length)return void console.error("No audio chunks recorded");let a=new Blob(t,{type:r.mimeType});if(0===a.size)return void console.error("Created blob has zero size");let s=new File([a],`voice-note-${Date.now()}.webm`,{type:r.mimeType,lastModified:Date.now()});if(0===s.size)return void console.error("Created file has zero size");let i=Object.assign(s,{metadata:{duration:d.current,mimeType:r.mimeType,size:s.size}});e(i)}catch(e){console.error("Error processing audio:",e)}finally{t.getTracks().forEach(e=>e.stop()),s(null),n(0),l.current&&(clearInterval(l.current),l.current=null)}},r.start(100),s(r),a(!0)}catch(e){console.error("Error starting recording:",e)}};if(t){let e;return(0,A.jsxs)("button",{onClick:()=>{r&&"recording"===r.state&&(r.stop(),a(!1))},className:"p-1.5 rounded-md bg-red-500/10 text-red-400 hover:bg-red-500/20 transition-colors flex items-center space-x-1",title:"Stop recording",children:[(0,A.jsx)("div",{className:"w-2 h-2 bg-red-500 rounded-full animate-pulse"}),(0,A.jsx)("span",{className:"text-xs font-mono",children:(e=Math.floor(i/60),`${e}:${(i%60).toString().padStart(2,"0")}`)})]})}return(0,A.jsx)("button",{onClick:c,className:"p-1.5 rounded-md hover:bg-gray-100 dark:hover:bg-white/[0.08] text-gray-400 dark:text-white/40 hover:text-gray-700 dark:hover:text-white/70 transition-colors",title:"Record voice note",children:(0,A.jsx)(ia.Mic,{className:"w-4 h-4"})})},{onUpload:ej})]})]}),$.length>0&&(0,A.jsxs)("div",{className:"bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg p-3",children:[(0,A.jsx)("div",{className:"space-y-2",children:$.map((e,t)=>(0,A.jsx)("div",{children:e.type?.startsWith("audio/")?(0,A.jsx)(s2.VoiceNotePlayer,{url:e.url,name:e.name,metadata:e.metadata,transcription:e.transcription,onRemove:()=>O(e=>e.filter((e,a)=>a!==t)),variant:"default",className:"w-full",showExternalLink:!1},t):e.type?.startsWith("image/")?(0,A.jsxs)("div",{className:"relative aspect-video bg-gray-100 dark:bg-white/5 rounded-lg overflow-hidden border border-gray-200 dark:border-white/10",children:[(0,A.jsx)("img",{src:e.url,alt:e.name,className:"w-full h-full object-cover cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>window.open(e.url,"_blank")}),(0,A.jsx)("button",{onClick:()=>O(e=>e.filter((e,a)=>a!==t)),className:"absolute top-2 right-2 p-1 bg-black/50 hover:bg-black/70 rounded-full text-gray-900 dark:text-white",children:(0,A.jsx)(ei.X,{className:"w-3 h-3"})}),(0,A.jsx)("div",{className:"absolute bottom-0 left-0 right-0 bg-black/50 text-gray-900 dark:text-white text-xs p-1 truncate",children:e.name})]}):e.type?.startsWith("video/")?(0,A.jsxs)("div",{className:"relative bg-gray-100 dark:bg-white/5 rounded-lg overflow-hidden border border-gray-200 dark:border-white/10",children:[(0,A.jsxs)("video",{controls:!0,className:"w-full aspect-video",children:[(0,A.jsx)("source",{src:e.url,type:"video/mp4"}),(0,A.jsx)("source",{src:e.url,type:"video/webm"}),"Your browser does not support the video element."]}),(0,A.jsx)("button",{onClick:()=>O(e=>e.filter((e,a)=>a!==t)),className:"absolute top-2 right-2 p-1 bg-black/50 hover:bg-black/70 rounded-full text-gray-900 dark:text-white",children:(0,A.jsx)(ei.X,{className:"w-3 h-3"})}),(0,A.jsx)("div",{className:"absolute bottom-0 left-0 right-0 bg-black/50 text-gray-900 dark:text-white text-xs p-1 truncate",children:e.name})]}):(0,A.jsxs)("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08]",children:[(0,A.jsx)(rB.FileText,{className:"w-4 h-4 text-gray-500 dark:text-white/60"}),(0,A.jsx)("span",{className:"text-sm text-gray-600 dark:text-white/80 flex-1 truncate",children:e.name}),(0,A.jsx)("button",{onClick:()=>O(e=>e.filter((e,a)=>a!==t)),className:"p-1 hover:bg-gray-100 dark:hover:bg-white/[0.08] rounded-md text-gray-400 dark:text-white/40 hover:text-gray-700 dark:hover:text-white/70",children:(0,A.jsx)(ei.X,{className:"w-4 h-4"})})]})},t))}),(0,A.jsxs)("div",{className:"text-xs text-gray-400 dark:text-white/40 mt-2",children:[$.length," file",1!==$.length?"s":""," attached (max 10)"]})]}),U&&(0,A.jsxs)("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-white/60 p-2 bg-gray-50 dark:bg-white/[0.02] rounded-lg",children:[(0,A.jsx)("div",{className:"w-3 h-3 border-2 border-gray-300 dark:border-white/20 border-t-gray-500 dark:border-t-white/60 rounded-full animate-spin"}),"Uploading..."]}),0===$.length&&!U&&(0,A.jsx)("div",{className:"text-xs text-gray-400 dark:text-white/40 text-center py-2",children:"Add photos, files, or voice notes to include with this task"})]}),(0,A.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:"Category"}),(0,A.jsx)(ic,{value:u.category,onChange:e=>ev("category",e),options:is,placeholder:"Select category"})]}),(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:"Priority"}),(0,A.jsx)(ic,{value:u.priority,onChange:e=>ev("priority",e),options:ii,placeholder:"Select priority"})]})]}),y.length>0&&(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("label",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:"Checklist Template"}),(0,A.jsx)(ic,{value:u.checklistTemplateId||"",onChange:e=>{let t=e||null,a=y.find(e=>e.id===t);if(a)N(a),h(e=>({...e,checklistTemplateId:a.id})),a.items&&M(a.items.map((e,t)=>({...e,id:e.id||`template_item_${a.id}_${t}_${Date.now()}`})));else N(null),M([]),ev("checklistTemplateId",null)},options:[{value:"",label:"No checklist template"},...y.map(e=>({value:e.id,label:e.name,description:e.items?`${e.items.length} items`:"No items",icon:ie.CheckSquare}))],placeholder:"Select checklist template"})]}),(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsxs)("label",{className:"text-sm font-medium text-gray-600 dark:text-white/80",children:["Checklist Items",C&&C.checklist&&C.checklist.length>0&&(0,A.jsxs)("span",{className:"text-xs text-gray-500 dark:text-white/60 ml-2",children:["(from task template: ",C.name,")"]}),j&&!C&&(0,A.jsxs)("span",{className:"text-xs text-gray-500 dark:text-white/60 ml-2",children:["(from checklist template: ",j.name,")"]})]}),(0,A.jsx)("div",{className:"p-3 bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg",children:(0,A.jsx)(s1.ChecklistEditor,{items:D,onItemsChange:M,isReadOnly:!1})})]})]}),(0,A.jsx)("div",{className:"mt-6 p-4 bg-white dark:bg-white/[0.02] border border-gray-200 dark:border-white/[0.08] rounded-lg",children:(0,A.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,A.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,A.jsx)(sJ.Checkbox,{id:"marketplace",checked:u.marketplaceEligible,onCheckedChange:e=>ev("marketplaceEligible",e),className:"border-gray-200 dark:border-white/[0.08] data-[state=checked]:bg-blue-500",disabled:F||e.commandInProgress}),(0,A.jsx)("label",{htmlFor:"marketplace",className:(0,ew.cn)("text-sm cursor-pointer",F||e.commandInProgress?"text-gray-400 dark:text-white/40":"text-gray-600 dark:text-white/80"),children:"Make available on marketplace"})]}),(0,A.jsx)("button",{onClick:eN,disabled:!eC||F||e.commandInProgress,className:(0,ew.cn)("px-4 py-2 rounded-md","bg-white hover:bg-white/90","text-sm text-black font-medium","transition-colors duration-200",(!eC||F||e.commandInProgress)&&"opacity-50 cursor-not-allowed"),children:F||e.commandInProgress?(0,A.jsxs)("span",{className:"flex items-center",children:[(0,A.jsx)(rf.Spinner,{className:"h-4 w-4 text-black mr-2"}),(n=C?.subtasks?.length||0)>0?`Creating Task and ${n} subtask${1!==n?"s":""}...`:"Creating Task..."]}):(l=C?.subtasks?.length||0)>0?`Create Task and ${l} subtask${1!==l?"s":""}`:"Create Task"})]})}),e.error&&!e.isLoading&&(0,A.jsxs)("div",{className:"mt-3 p-3 bg-red-950/30 border border-red-500/30 rounded-lg flex items-start",children:[(0,A.jsx)("div",{className:"mr-2 mt
70-0.5 text-red-400 flex-shrink-0",children:(0,A.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,A.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,A.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,A.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}),(0,A.jsxs)("div",{className:"flex-1",children:[(0,A.jsx)("div",{className:"text-sm font-medium text-red-400",children:"Error"}),(0,A.jsx)("div",{className:"text-xs text-red-300/90",children:e.error})]})]}),e.successMessage&&(0,A.jsxs)("div",{className:"mt-3 p-3 bg-green-950/30 border border-green-500/30 rounded-lg flex items-start",children:[(0,A.jsx)("div",{className:"mr-2 mt-0.5 text-green-400 flex-shrink-0",children:(0,A.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,A.jsx)("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),(0,A.jsx)("polyline",{points:"22 4 12 14.01 9 11.01"})]})}),(0,A.jsxs)("div",{className:"flex-1",children:[(0,A.jsx)("div",{className:"text-sm font-medium text-green-400",children:"Success"}),(0,A.jsx)("div",{className:"text-xs text-green-300/90",children:e.successMessage})]})]})]}),(0,A.jsx)("input",{type:"file",ref:z,className:"hidden",onChange:e=>ek(e.target.files)})]})}var ip=e.i(991799);function ib({stepState:e,onStepStateChange:t,onSubmit:a}){let r=e.metadata||{},s=r.reservation||r.inquiry||{},[i,n]=(0,R.useState)(s.checkIn?.split("T")[0]||s.dates?.checkIn?.split("T")[0]||""),[l,o]=(0,R.useState)(s.numberOfNights||s.dates?.numberOfNights||""),[d,c]=(0,R.useState)(s.expectedAmount||s.pricing?.totals?.total||""),[m,u]=(0,R.useState)(s.guestCount||s.guests?.total||1),[h,x]=(0,R.useState)(!1),[g,p]=(0,R.useState)(null),[b,f]=(0,R.useState)(!1),y=document.documentElement.classList.contains("dark");return((0,R.useEffect)(()=>{let e=e=>{let t=e.detail;t?.action?.event==="message.guest.special_offer"&&(x(!1),t.success?(f(!0),p(null)):p(t.error||t.response?.error||"Failed to send special offer"))};return window.addEventListener("command:result",e),()=>window.removeEventListener("command:result",e)},[]),(0,R.useEffect)(()=>{e.error&&p(e.error),e.successMessage&&(f(!0),p(null))},[e.error,e.successMessage]),b)?(0,A.jsxs)("div",{className:"p-4 text-center",children:[(0,A.jsx)(rY.CheckCircle,{className:"w-8 h-8 text-emerald-500 mx-auto mb-2"}),(0,A.jsx)("p",{className:(0,ew.cn)("text-sm font-medium",y?"text-white":"text-gray-900"),children:"Special offer sent!"}),(0,A.jsx)("p",{className:(0,ew.cn)("text-xs mt-1",y?"text-white/40":"text-gray-400"),children:"Guest has 24 hours to accept"})]}):(0,A.jsxs)("div",{className:"p-4 space-y-4",children:[(0,A.jsx)("p",{className:(0,ew.cn)("text-xs",y?"text-white/40":"text-gray-400"),children:"Set a custom price and dates for this guest. They have 24 hours to accept. Include cleaning fee and standard fees in the price â do not include taxes."}),g&&(0,A.jsxs)("div",{className:"flex items-start gap-2 p-3 rounded-lg bg-red-500/10 text-red-400 text-xs",children:[(0,A.jsx)(es.AlertTriangle,{className:"w-4 h-4 shrink-0 mt-0.5"}),(0,A.jsx)("span",{children:g})]}),(0,A.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,A.jsxs)("div",{children:[(0,A.jsxs)("label",{className:(0,ew.cn)("text-xs font-medium mb-1 block",y?"text-white/60":"text-gray-600"),children:[(0,A.jsx)(e_.Calendar,{className:"w-3 h-3 inline mr-1"})," Check-in Date"]}),(0,A.jsx)("input",{type:"date",value:i,onChange:e=>n(e.target.value),className:(0,ew.cn)("w-full px-3 py-2 text-sm rounded-lg border",y?"border-white/[0.1] bg-white/[0.05] text-white":"border-gray-200 bg-white text-gray-900")})]}),(0,A.jsxs)("div",{children:[(0,A.jsxs)("label",{className:(0,ew.cn)("text-xs font-medium mb-1 block",y?"text-white/60":"text-gray-600"),children:[(0,A.jsx)(ip.Moon,{className:"w-3 h-3 inline mr-1"})," Nights"]}),(0,A.jsx)("input",{type:"number",min:1,value:l,onChange:e=>o(e.target.value),placeholder:"e.g. 3",className:(0,ew.cn)("w-full px-3 py-2 text-sm rounded-lg border",y?"border-white/[0.1] bg-white/[0.05] text-white":"border-gray-200 bg-white text-gray-900")})]})]}),(0,A.jsxs)("div",{children:[(0,A.jsxs)("label",{className:(0,ew.cn)("text-xs font-medium mb-1 block",y?"text-white/60":"text-gray-600"),children:[(0,A.jsx)(sx.DollarSign,{className:"w-3 h-3 inline mr-1"})," Total Price"]}),(0,A.jsx)("input",{type:"number",min:1,value:d,onChange:e=>c(e.target.value),placeholder:"Total including fees",className:(0,ew.cn)("w-full px-3 py-2 text-sm rounded-lg border",y?"border-white/[0.1] bg-white/[0.05] text-white":"border-gray-200 bg-white text-gray-900")})]}),(0,A.jsxs)("div",{children:[(0,A.jsxs)("label",{className:(0,ew.cn)("text-xs font-medium mb-1 block",y?"text-white/60":"text-gray-600"),children:[(0,A.jsx)(rq.Users,{className:"w-3 h-3 inline mr-1"})," Guests"]}),(0,A.jsx)("input",{type:"number",min:1,value:m,onChange:e=>u(e.target.value),className:(0,ew.cn)("w-full px-3 py-2 text-sm rounded-lg border",y?"border-white/[0.1] bg-white/[0.05] text-white":"border-gray-200 bg-white text-gray-900")})]}),(0,A.jsxs)("button",{onClick:()=>{i&&l&&d&&(x(!0),p(null),a({startDate:i,nights:parseInt(String(l)),totalPrice:parseInt(String(d)),guestDetails:{number_of_adults:parseInt(String(m))||1}}))},disabled:h||!i||!l||!d,className:"w-full py-2 text-sm font-medium bg-indigo-600 text-white rounded-lg hover:bg-indigo-500 disabled:opacity-50 flex items-center justify-center gap-2",children:[h?(0,A.jsx)(eu.Loader2,{className:"w-4 h-4 animate-spin"}):(0,A.jsx)(sx.DollarSign,{className:"w-4 h-4"}),g?"Retry":"Send Special Offer"]})]})}var iy=e.i(500110);function iw({stepState:e,onSubmit:t}){let[a,r]=(0,R.useState)(!1),[s,i]=(0,R.useState)(!1),[n,l]=(0,R.useState)(null),[o,d]=(0,R.useState)(!1),c=e.metadata||{},m=c.reservation||c.inquiry||{},u=c.guest?.name,h="string"==typeof u?u:u?.full||u?.first||m.guestName||"Guest",x=document.documentElement.classList.contains("dark");return((0,R.useEffect)(()=>{let e=e=>{let t=e.detail;t?.action?.event==="message.guest.preapproval"&&(i(!1),t.success?(d(!0),l(null)):l(t.error||t.response?.error||"Pre-approval failed"))};return window.addEventListener("command:result",e),()=>window.removeEventListener("command:result",e)},[]),(0,R.useEffect)(()=>{e.error&&l(e.error),e.successMessage&&(d(!0),l(null))},[e.error,e.successMessage]),o)?(0,A.jsxs)("div",{className:"p-4 text-center",children:[(0,A.jsx)(rY.CheckCircle,{className:"w-8 h-8 text-emerald-500 mx-auto mb-2"}),(0,A.jsx)("p",{className:(0,ew.cn)("text-sm font-medium",x?"text-white":"text-gray-900"),children:"Pre-approval sent!"}),(0,A.jsxs)("p",{className:(0,ew.cn)("text-xs mt-1",x?"text-white/40":"text-gray-400"),children:[h," has 24 hours to accept"]})]}):(0,A.jsxs)("div",{className:"p-4 space-y-4",children:[(0,A.jsxs)("p",{className:(0,ew.cn)("text-sm",x?"text-white/70":"text-gray-600"),children:["Pre-approve ",(0,A.jsx)("strong",{children:h}),"'s inquiry? They'll have 24 hours to complete the booking at the listing's current price."]}),m.dates&&(0,A.jsxs)("div",{className:(0,ew.cn)("text-xs p-3 rounded-lg",x?"bg-white/[0.03] text-white/50":"bg-gray-50 text-gray-500"),children:[m.dates.checkIn&&`${new Date(m.dates.checkIn).toLocaleDateString()} â ${new Date(m.dates.checkOut).toLocaleDateString()}`,m.dates.numberOfNights&&` (${m.dates.numberOfNights} nights)`]}),n&&(0,A.jsxs)("div",{className:"flex items-start gap-2 p-3 rounded-lg bg-red-500/10 text-red-400 text-xs",children:[(0,A.jsx)(es.AlertTriangle,{className:"w-4 h-4 shrink-0 mt-0.5"}),(0,A.jsx)("span",{children:n})]}),(0,A.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,A.jsx)("input",{type:"checkbox",checked:a,onChange:e=>r(e.target.checked),className:"rounded border-gray-300"}),(0,A.jsxs)("div",{children:[(0,A.jsxs)("span",{className:(0,ew.cn)("text-sm",x?"text-white/70":"text-gray-700"),children:[(0,A.jsx)(iy.ShieldOff,{className:"w-3.5 h-3.5 inline mr-1"}),"Block instant bookings"]}),(0,A.jsx)("p",{className:(0,ew.cn)("text-xs",x?"text-white/30":"text-gray-400"),children:"Prevent the guest from booking without approval after pre-approval"})]})]}),(0,A.jsxs)("button",{onClick:()=>{i(!0),l(null),t({blockInstantBooking:a})},disabled:s,className:"w-full py-2 text-sm font-medium bg-emerald-600 text-white rounded-lg hover:bg-emerald-500 disabled:opacity-50 flex items-center justify-center gap-2",children:[s?(0,A.jsx)(eu.Loader2,{className:"w-4 h-4 animate-spin"}):(0,A.jsx)(rY.CheckCircle,{className:"w-4 h-4"}),n?"Retry Pre-approve":"Pre-approve Inquiry"]})]})}function iv(e){return`${e.getFullYear()}-${(e.getMonth()+1).toString().padStart(2,"0")}-${e.getDate().toString().padStart(2,"0")} ${e.getHours().toString().padStart(2,"0")}:${e.getMinutes().toString().padStart(2,"0")}`}function ik({activeCommand:e,stepState:t,selectedIndex:a,selectedId:r,search:s,onStepStateChange:i,onContinue:n}){let{data:l}=(0,P.useSession)(),o="host";try{o=(0,e8.useCustomer)().workspaceType}catch{}(0,R.useEffect)(()=>
70{if("service_provider"!==o)return;let e=t.currentStep?.type;if("listing-suggestion"!==e&&"listing"!==e&&"reservation-suggestion"!==e&&"reservation"!==e)return;let a=d().find(e=>"task-suggestion"===e.type);a&&i({...t,currentStep:a,data:{...t.data},history:[...t.history,...t.currentStep?.id?[t.currentStep.id]:[]]})},[t.currentStep?.id,o]),(0,R.useEffect)(()=>{if(t.currentStep?.type==="reservation"&&t.metadata?.reservation){let e=d(),a=e.findIndex(e=>e.id===t.currentStep?.id),r=e[a+1];r&&i({...t,currentStep:r,data:{...t.data,[t.currentStep.id]:t.metadata.reservation},history:[...t.history,t.currentStep.id]})}},[t.currentStep?.id]);let d=()=>e?.configuration?.steps||e?.action?.steps||[],c=(0,R.useCallback)(e=>{if(t.currentStep?.multiSelect){let a,r=t.data[t.currentStep.id]?.selections||[];if(r.some(t=>t.id===e.id))a=r.filter(t=>t.id!==e.id);else{if(t.currentStep.maxSelections&&r.length>=t.currentStep.maxSelections)return;a=[...r,e]}i({...t,data:{...t.data,[t.currentStep.id]:{selections:a}}})}},[t,i]);return(0,A.jsxs)(A.Fragment,{children:[(()=>{let n=t.currentStep?.type;if(t.currentStep?.snippetType,t.isLoading)return(0,A.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,A.jsx)(rf.Spinner,{className:"w-6 h-6"})});switch(n){case"access-code":return(0,A.jsx)(sL,{stepState:t,selectedIndex:a,selectedId:r,search:s,onSubmit:e=>{let a=t.data?.reservation||t.metadata?.reservation;if(!a){console.error("[StepSuggestions] No reservation data found for access code operation"),i({...t,error:"Missing reservation information",isLoading:!1});return}let r=a?.listing||t.metadata?.listing,s=Number(r?.id||a?.listingId||0),n=Number(a?.id||0);if(!s||!n){console.error("[StepSuggestions] Missing required IDs:",{listingId:s,reservationId:n}),i({...t,error:"Missing required listing or reservation information",isLoading:!1});return}let l=t.type?.includes("edit")||!1,o=l&&e.accessCodeId?"seam.accessCode.update":"seam.accessCode.create",d=e.code;d||l||(d=Math.floor(1e5+9e5*Math.random()).toString()),console.log("[StepSuggestions] PAYLOAD DEBUG - Raw dates from form:",{startsAtDate:e.startsAt,startsAtType:typeof e.startsAt,startsAtIsDate:e.startsAt instanceof Date,startsAtToString:e.startsAt?e.startsAt.toString():"null",endsAtDate:e.endsAt,endsAtType:typeof e.endsAt,endsAtIsDate:e.endsAt instanceof Date,endsAtToString:e.endsAt?e.endsAt.toString():"null"});let c=new CustomEvent("command-action",{detail:{command:{type:"direct",topic:"seam",event:o,payload:{name:e.name,code:d,startsAt:iv(e.startsAt),endsAt:iv(e.endsAt),reservationId:n,listingId:s,...l&&e.accessCodeId?{accessCodeId:e.accessCodeId}:{},metadata:{reservationCode:a?.confirmationCode,guestName:a?.guestName||a?.guest?.name?.full,customerId:t.metadata?.customerId||1}}}}});document.dispatchEvent(c),i({...t,commandInProgress:!0});let m=e=>{let{action:a,success:r,error:s}=e.detail;a.event===o&&(i({...t,commandInProgress:!1,error:r?void 0:s||`Failed to ${l?"update":"create"} access code`,successMessage:r?`Access code ${l?"updated":"created"} successfully!`:void 0}),document.removeEventListener("command:result",m))};document.addEventListener("command:result",m)}});case"signature-booking":return(0,A.jsx)(s$,{stepState:t,onStepStateChange:i,onSubmit:e=>{let a={type:"direct",topic:"signature",event:"signature.reservation.create",payload:{...e,reservation:{arrivalDate:e.arrivalDate,numNights:e.numNights,numGuests:e.numGuests,guestName:e.guestName,comments:e.comments},customerId:t.metadata?.customerId||t.metadata?.listing?.customerId||1,metadata:t.metadata}};document.dispatchEvent(new CustomEvent("command-action",{detail:{command:a}})),i({...t,commandInProgress:!0});let r=e=>{let{action:a,success:s,error:n}=e.detail;"signature.reservation.create"===a.event&&(i({...t,commandInProgress:!1,error:s?void 0:n||"Failed to create reservation",successMessage:s?"Signature reservation created!":void 0}),document.removeEventListener("command:result",r))};document.addEventListener("command:result",r)}});case"signature-list":return(0,A.jsx)(sB,{stepState:t,commandEvent:"signature.reservation.list",onStepStateChange:i});case"signature-cancel":return(0,A.jsx)(sB,{stepState:t,commandEvent:"signature.reservation.cancel",onStepStateChange:i});case"signature-profiles":return(0,A.jsx)(sB,{stepState:t,commandEvent:"signature.profiles.list",onStepStateChange:i});case"listing-suggestion":case"listing":return(0,A.jsx)(sn,{suggestions:t.currentStep?.suggestions||[],stepState:t,selectedIndex:a,selectedId:r,search:s,onSuggestionClick:a=>{let r=t.currentStep,s=e?.configuration?.completionAction,n=d();if(s?.action==="openPopover"&&s?.popover==="createReservation"){let e=new CustomEvent("ui-action",{detail:{type:"openPopover",popover:"createReservation",data:{listing:a.metadata?.listing,listingId:a.metadata?.listing?.id}}});document.dispatchEvent(e);return}let l=t.data?.reservation||t.metadata?.reservation;if((l?.listingId||l?.listing?.id)===Number(a.id))return void i({...t,error:"Cannot move reservation to the same listing"});if(e?.configuration?.event==="reservation.create"||e?.action?.event==="reservation.create"){let e=new CustomEvent("command-action",{detail:{command:{type:"direct",topic:"reservation",event:"reservation.create",payload:{listing:a.metadata?.listing,listingId:a.metadata?.listing?.id}}}});document.dispatchEvent(e);return}if(!r||!n.length)return void console.error("[StepSuggestions] Missing current step or steps array");let o=n.findIndex(e=>e.id===r.id),c=o>=0&&o<n.length-1?n[o+1]:null,m={...t,data:{...t.data,[r.id]:a},history:[...t.history,r.id],error:void 0};c&&(m.currentStep=c),i(m)}});case"reservation":case"reservation-suggestion":return(0,A.jsx)(sh,{suggestions:t.currentStep?.suggestions||[],stepState:t,selectedIndex:a,selectedId:r,search:s,onSuggestionClick:e=>{let a=t.currentStep,r=d();if(!a||!r.length)return void console.error("[StepSuggestions] Missing current step or steps array");let s=r.findIndex(e=>e.id===a.id),n=s>=0&&s<r.length-1?r[s+1]:null,l=e.metadata?.reservationContext||{id:e.id,confirmationCode:e.metadata?.confirmationCode,guestName:e.name,guestId:e.metadata?.guestId,listingId:e.metadata?.listingId,listingName:e.description,checkIn:e.metadata?.checkIn,checkOut:e.metadata?.checkOut};i({...t,currentStep:n||void 0,data:{...t.data,[a.id]:e,reservation:l},history:[...t.history,a.id]})},commandType:e.configuration?.type||e.type,onStepProgression:e=>{let a=d(),r=e.currentStep||t.currentStep;if(r&&a.length){let t=a.findIndex(e=>e.id===r.id),s=t>=0&&t<a.length-1?a[t+1]:null;i({...e,currentStep:s||void 0})}else i(e)}});case"reservation-modification":return(0,A.jsx)(sv,{stepState:t,selectedIndex:a,selectedId:r,search:s,reservation:t.data?.reservation||t.metadata?.reservation,onSelect:e=>{let a=t.currentStep,r=d();if(!a||!r.length)return void console.error("[StepSuggestions] Missing current step or steps array");let s=r.findIndex(e=>e.id===a.id),n=s>=0&&s<r.length-1?r[s+1]:null;i({...t,currentStep:n||void 0,data:{...t.data,[a.id]:e},history:[...t.history,a.id]})},onError:e=>
70{console.log("[StepSuggestions] Reservation modification error:",e),i({...t,error:e})}});case"team-member":return(0,A.jsx)(sC,{suggestions:t.currentStep?.suggestions||[],stepState:t,selectedIndex:a,selectedId:r,onSuggestionClick:c});case"channel":return(0,A.jsx)(sT,{suggestions:t.currentStep?.suggestions||[],stepState:t,selectedIndex:a,selectedId:r,onSuggestionClick:c});case"task-suggestion":return(0,A.jsx)(ig,{stepState:t,selectedIndex:a,selectedId:r,search:s,onSuggestionClick:e=>{let a=new CustomEvent("command-action",{detail:{command:{type:"direct",topic:"task",event:"task.create",payload:{title:e.metadata?.task?.title,description:e.metadata?.task?.description,category:e.metadata?.task?.category,priority:e.metadata?.task?.priority,dueDate:e.metadata?.task?.dueDate,marketplaceEligible:e.metadata?.task?.marketplaceEligible,recurrence:e.metadata?.task?.recurrence,assigneeUserId:e.metadata?.task?.assigneeUserId,assigneeMode:e.metadata?.task?.assigneeMode,listingId:e.metadata?.task?.listingId,reservationId:e.metadata?.task?.reservationId,subtaskOf:e.metadata?.task?.subtaskOf,checklistTemplateId:e.metadata?.task?.checklistTemplateId,taskTemplateId:e.metadata?.task?.taskTemplateId,templateId:e.metadata?.task?.templateId,subtasks:e.metadata?.task?.subtasks||[],checklist:e.metadata?.task?.checklist,relatedIssueId:e.metadata?.task?.relatedIssueId,issueType:e.metadata?.task?.issueType,allAttachments:e.metadata?.task?.allAttachments,hasAttachments:e.metadata?.task?.hasAttachments,metadata:{task:{allAttachments:e.metadata?.task?.allAttachments},customerId:t.metadata?.customerId}}}}});document.dispatchEvent(a),i({...t,commandInProgress:!0});let r=e=>{if("task.create"===e.detail.action.event){document.removeEventListener("command:result",r);let a=e.detail.data?.taskId??e.detail.response?.data?.taskId,s=e.detail.success&&e.detail.response?.success!==!1;i({...t,commandInProgress:!1,error:s?void 0:e.detail.error,successMessage:s?"Task created successfully!":void 0,...s&&a?{data:{...t.data,task:{id:a}}}:{}})}};document.addEventListener("command:result",r)}});case"inquiry-preapprove":return(0,A.jsx)(iw,{stepState:t,onSubmit:e=>{let a=t.metadata?.thread?.metadata?.bookingDetails?.thread_id||t.metadata?.thread?.externalThreadId||t.metadata?.airbnbThreadId||"",r={type:"direct",topic:"message",event:"message.guest.preapproval",payload:{metadata:{airbnbThreadId:a,threadId:a,host:{id:t.metadata?.host?.id||t.metadata?.thread?.metadata?.hostInfo?.airbnbId||""},customerId:t.metadata?.thread?.metadata?.hostInfo?.customerId||t.metadata?.listing?.customerId||t.metadata?.customerId},blockInstantBooking:e.blockInstantBooking}};document.dispatchEvent(new CustomEvent("command-action",{detail:{command:r}})),i({...t,commandInProgress:!0});let s=e=>{e.detail?.action?.event==="message.guest.preapproval"&&(document.removeEventListener("command:result",s),i({...t,commandInProgress:!1,error:e.detail.success?void 0:e.detail.error,successMessage:e.detail.success?"Pre-approval sent!":void 0}))};document.addEventListener("command:result",s)}});case"special-offer":return(0,A.jsx)(ib,{stepState:t,onStepStateChange:i,onSubmit:e=>{let a={type:"direct",topic:"message",event:"message.guest.special_offer",payload:{metadata:{airbnbThreadId:t.metadata?.thread?.metadata?.bookingDetails?.thread_id||t.metadata?.thread?.externalThreadId||"",threadId:t.metadata?.thread?.metadata?.bookingDetails?.thread_id||t.metadata?.thread?.externalThreadId||"",host:{id:t.metadata?.host?.id||t.metadata?.thread?.metadata?.hostInfo?.airbnbId||""},customerId:t.metadata?.thread?.metadata?.hostInfo?.customerId||t.metadata?.listing?.customerId||t.metadata?.customerId,listingId:t.metadata?.listing?.id},listingId:t.metadata?.thread?.metadata?.bookingDetails?.listing_id||t.metadata?.listing?.airbnbListingId||t.metadata?.listing?.id,startDate:e.startDate,nights:e.nights,totalPrice:e.totalPrice,guestDetails:e.guestDetails}};document.dispatchEvent(new CustomEvent("command-action",{detail:{command:a}})),i({...t,commandInProgress:!0});let r=e=>{e.detail?.action?.event==="message.guest.special_offer"&&(document.removeEventListener("command:result",r),i({...t,commandInProgress:!1,error:e.detail.success?void 0:e.detail.error,successMessage:e.detail.success?"Special offer sent! Guest has 24 hours to accept.":void 0}))};document.addEventListener("command:result",r)}});case"confirmation":return(0,A.jsx)(sq,{stepState:t,onSubmit:async()=>{let a=t.data?.reservation||t.metadata?.reservation,r={type:"direct",topic:e.action.topic,event:e.action.event,payload:{confirmationCode:a?.confirmationCode,...Object.entries(t.data).reduce((t,[a,r])=>{let s=e.action.steps.find(e=>e.id===a);if(s)switch(s.type){case"reservation":t.confirmationCode=r?.confirmationCode||r?.reservation?.confirmationCode;break;case"reason":case"text":t.reason="string"==typeof r.reason?r.reason:r.reason?.reason,void 0!==r.revenueRetained&&(t.revenueRetained=r.revenueRetained);break;case"reservation-modification":t.modifications=r.modifications;break;default:t[a]=r}return t},{}),metadata:{...t.metadata}}},s=new CustomEvent("command-action",{detail:{command:r}});return document.dispatchEvent(s),i({...t,commandInProgress:!0}),new Promise((e,a)=>{let s=n=>{n.detail.action.event===r.event&&(document.removeEventListener("command:result",s),i({...t,commandInProgress:!1,error:n.detail.success?void 0:n.detail.error}),n.detail.success?e():a(Error(n.detail.error)))};setTimeout(()=>{document.removeEventListener("command:result",s),a(Error("Command execution timed out"))},12e4),document.addEventListener("command:result",s)})},onCancel:()=>{let e=d(),a=e.findIndex(e=>e.id===t.currentStep?.id);a>0&&i({...t,currentStep:e[a-1],error:void 0})}});case"text":case"reason":{let e={heading:t.currentStep?.heading,placeholder:t.currentStep?.placeholder,required:!0,...t.currentStep};return(0,A.jsx)(sV,{heading:e.heading,placeholder:e.placeholder,required:e.required,
70checkboxLabel:e.checkboxLabel,checkboxKey:e.checkboxKey,onSelect:e=>{((e,a)=>{let r=t.currentStep,s=d();if(!r||!s.length)return console.error("[StepSuggestions] Missing current step or steps array");let n=s.findIndex(e=>e.id===r.id),l=n>=0&&n<s.length-1?s[n+1]:null;i({...t,currentStep:l||void 0,data:{...t.data,[e]:a},history:[...t.history,e],error:void 0})})(t.currentStep?.id||"",e)}})}default:if(!t.currentStep?.suggestions)return null;return(0,A.jsx)(ro.Group,{heading:t.currentStep.heading||"Select an option",className:(0,ew.cn)("pb-2","[&>[cmdk-group-heading]]:text-xs","[&>[cmdk-group-heading]]:font-medium","[&>[cmdk-group-heading]]:text-gray-500 [&>[cmdk-group-heading]]:dark:text-white/40","[&>[cmdk-group-heading]]:px-2","[&>[cmdk-group-heading]]:pb-1"),children:t.currentStep.suggestions.map((e,r)=>{let s=t.data[t.currentStep?.id||""]?.selections?.some(t=>t.id===e.id);return(0,A.jsx)(ro.Item,{value:e.id,"data-suggestion-id":e.id,"data-index":r,"data-selected":a===r,onSelect:()=>c(e),className:(0,ew.cn)("flex items-center gap-3 px-4 py-3 rounded-lg","transition-colors duration-200","cursor-pointer","hover:bg-gray-50 dark:hover:bg-white/[0.06]",a===r&&"bg-gray-50 dark:bg-white/[0.06]",s&&"bg-gray-100 dark:bg-white/[0.12]"),children:(0,A.jsxs)("div",{className:"flex items-center gap-2 w-full",children:[s&&(0,A.jsx)("div",{className:"absolute left-2",children:(0,A.jsx)(sr.default,{className:"w-4 h-4 text-blue-400"})}),(0,A.jsxs)("div",{className:(0,ew.cn)("flex-1",s&&"pl-6"),children:[(0,A.jsx)("div",{className:"font-medium text-gray-900 dark:text-white truncate",children:e.name}),e.description&&(0,A.jsx)("div",{className:"text-sm text-gray-400 dark:text-white/40 truncate hidden md:block",children:e.description})]})]})},e.id)})})}})(),t.currentStep?.multiSelect&&(()=>{if(!e?.action?.steps||!t.currentStep?.multiSelect)return null;let a=t.data[t.currentStep.id]?.selections||[];return(0,A.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-t border-gray-200 dark:border-white/10",children:[(0,A.jsxs)("div",{className:"text-sm text-gray-500 dark:text-white/60",children:[a.length," selected"]}),(0,A.jsx)("button",{onClick:n,className:(0,ew.cn)("px-4 py-1.5 rounded-md text-sm font-medium","bg-blue-500 text-gray-900 dark:text-white","hover:bg-blue-600 transition-colors",0===a.length&&"opacity-50 cursor-not-allowed"),disabled:0===a.length,children:"Continue"})]})})()]})}function ij({loading:e,activeCommand:t,stepState:a,selectedIndex:r,filteredCommands:s,rawCommands:i,selectedId:n,onContinue:l,search:o,onStepStateChange:d,renderExtraSections:c}){let{type:m,state:u}=(0,ev.useCommandPalette)();return"reminder"===m?(0,A.jsx)(rL,{search:o}):(0,A.jsx)(ro.List,{className:(0,ew.cn)("overflow-y-auto w-full","min-h-[100px]","py-2"),children:e&&!t?(0,A.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,A.jsx)(rf.Spinner,{className:"w-6 h-6"})}):(0,A.jsx)(A.Fragment,{children:t&&a.currentStep?(0,A.jsx)(A.Fragment,{children:(0,A.jsx)(ik,{activeCommand:t,stepState:{...a,isLoading:a.isLoading},selectedIndex:r,selectedId:n,onStepStateChange:d,onContinue:l,search:o})}):(0,A.jsx)(sa,{filteredCommands:s,selectedIndex:r,search:o,renderExtraSections:c})})})}let iN="reservation.resync.airbnb",iC=[iN];e.s(["RESYNC_BOOKING_EVENT",0,iN,"paletteContextPayloadForCommand",0,function(e,t){let a=String(e??"").trim();return a&&iC.includes(a)?function(e){let t=e?.reservation;if(!t)return{};let a={},r=t.id,s="number"==typeof r?r:Number(String(r??"").trim());Number.isFinite(s)&&s>0&&(a.reservationId=s);let i=t.platform?.reservationId??t.confirmationCode;i&&(a.confirmationCode=String(i));let n=t.platform?.listingId;n&&(a.listingId=String(n));let l=t.platform?.source;return l&&(a.platform=String(l)),a}(t):{}},"paletteDispatchTypeForCommand",0,function(e,t){let a=String(e??"").trim();return a&&iC.includes(a)&&t?String(t):"general"},"paletteReservationIsAirbnb",0,function(e){return"airbnb"===String(e?.reservation?.platform?.source||"").trim().toLowerCase()}],294082);let iS={"reservation.resync.airbnb":"Resyncing from Airbnbâ¦"};async function iE(e,t,a){t(e?iS[e]??null:null);try{return await a()}finally{t(null)}}e.s(["withCommandInFlight",0,iE],121798),e.s(["CommandInFlightRow",0,function({label:e,className:t}){return(0,A.jsxs)("div",{role:"status","aria-live":"polite","data-testid":"command-in-flight",className:(0,ew.cn)("flex items-center gap-3 px-4 py-6","text-sm text-gray-600 dark:text-white/70",t),children:[(0,A.jsx)(eu.Loader2,{className:"w-4 h-4 animate-spin text-gray-400 dark:text-white/40"}),(0,A.jsx)("span",{children:e}),(0,A.jsx)("span",{className:"ml-auto text-xs text-gray-400 dark:text-white/30 hidden sm:inline",children:"This can take a few seconds"})]})}],490446)},280411,e=>{e.v({className:"geistsans_d5a4f12f-module__Ur3q_a__className",variable:"geistsans_d5a4f12f-module__Ur3q_a__variable"})},593843,43605,e=>{"use strict";var t=e.i(280411);let a={className:t.default.className,style:{fontFamily:"'GeistSans', 'GeistSans Fallback'"}};null!=t.default.variable&&(a.variable=t.default.variable),e.s([],593843),e.s(["GeistSans",0,a],43605)},347548,e=>{"use strict";var t=e.i(879908);e.s(["SkipForward",()=>t.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.