1import{i as D}from"./apollo-B1TfImlk.js";const y=({properties:e,sortOccupancy:t,sortProperties:o})=>[...e].map(r=>{const n=r?.occupancyPeriods?.map(f=>({...f,effectiveFrom:f?.effectiveFrom?f.effectiveFrom:void 0,effectiveTo:f?.effectiveTo?f?.effectiveTo:void 0}))?.sort(t);return{...r,id:r?.id??"",occupancy:n}}).filter(r=>(r.occupancy?.length??0)>0).map(r=>{const n=r.occupancy?.[r.occupancy.length-1];return{...r,effectiveFrom:n?.effectiveFrom??new Date().toISOString(),effectiveTo:n?.effectiveTo??void 0}}).sort(o)??[],w=e=>y({properties:e,sortOccupancy:O,sortProperties:O}),M=e=>y({properties:e,sortOccupancy:P,sortProperties:P}),O=(e,t)=>e.effectiveFrom?t.effectiveFrom&&e.effectiveFrom<t.effectiveFrom?-1:1:-1,P=(e,t)=>e.effectiveTo?t.effectiveTo?e.effectiveTo<t.effectiveTo?-1:1:-1:1,h=(e,t)=>t.find(o=>!!o.effectiveFrom&&new Date(o.effectiveFrom)<e&&!(o.effectiveTo&&new Date(o.effectiveTo)<e)),l=(e,t,o,r)=>{if(r){const c=o.find(i=>i.id===r);if(c?.effectiveTo&&new Date(c.effectiveTo)<e)return{moveOutProperty:c,hasMovedOut:!0}}if(h(e,t))return{moveOutProperty:o.find(c=>!!c?.effectiveTo&&new Date(c.effectiveTo)>e),hasMovedOut:!1};const f=o.filter(c=>!!c.effectiveTo&&new Date(c.effectiveTo)<e);return{moveOutProperty:f?.[f.length-1],hasMovedOut:!0}},T=e=>e.splitAddress?.[0]||(e.address??""),g=({property:e})=>e?.occupancyPeriods?.some(t=>new Date(t?.effectiveFrom??"")<new Date&&(!t?.effectiveTo||t.effectiveTo&&new Date(t.effectiveTo)>new Date))??!1,{useMemo:p}=await D("react"),I=({properties:e,selectedPropertyId:t})=>{const{moveInProperty:o,moveOutProperty:r,hasMovedOut:n}=p(()=>{const s=new Date,u=w(e),F=M(e),{moveOutProperty:v,hasMovedOut:a}=l(s,u,F,t);if(!v)return{moveInProperty:void 0,moveOutProperty:v,hasMovedOut:a};const m=u.find(d=>!!d.effectiveFrom&&new Date(d.effectiveFrom)>s);return{moveInProperty:m,moveOutProperty:m?.address===v.address?void 0:v,hasMovedOut:a}},[e,t]),f=o&&!!o?.effectiveFrom&&new Date(o.effectiveFrom)<new Date,c=r&&T(r);return{moveInAddress:o&&T(o),moveInProperty:o,moveOutAddress:c,moveOutProperty:r,alreadyMovedOut:n,alreadyMovedIn:f}};export{g as i,I as u};
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.