PageSourceSearch

https://app.pawsitivefoster.com/assets/SchedulingDemo-CT2mPogu.js

js pawsitivefoster.com collected 2026-10-02 01:41:57 UTC 12,365 bytes, 1 lines download raw bytes

1var t=Object.defineProperty,e=(e,i,o)=>((e,i,o)=>i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[i]=o)(e,"symbol"!=typeof i?i+"":i,o);import{D as i,I as o}from"./luxon-D8LvV7_N.js";import{aQ as a,r as n,E as r,aR as s,aS as d,u as l,aT as c,aV as p,aW as _,bs as u,bp as m,aZ as f,bn as y,bu as g,bv as h,de as v,dd as k,e9 as w,ca as S,cW as b,bo as I,bt as O,cm as E,bx as T,bz as A,bA as B,by as P,a$ as D,b1 as V,bm as Z}from"./index-B0wWhsKS.js";const j={animal_pickup:"coordinator",return_to_shelter:"coordinator",supply_pickup:"coordinator",vet_emergency:"medical",spay_neuter:"medical",vet_non_emergency:"medical",vaccines:"medical"},x={animal_pickup:0,return_to_shelter:2,supply_pickup:3,vet_emergency:0,spay_neuter:1,vet_non_emergency:2,vaccines:1};class F{constructor(t){e(this,"store"),e(this,"notify"),this.store=t.store,this.notify=t.notify}static validateIsoRange(t,e){const o=i.fromISO(t),a=i.fromISO(e);if(!o.isValid||!a.isValid)throw new Error("Invalid ISO datetime");if(a<=o)throw new Error("End must be after start")}static overlaps(t,e){const a=o.fromDateTimes(i.fromISO(t.start),i.fromISO(t.end)),n=o.fromDateTimes(i.fromISO(e.start),i.fromISO(e.end));return a.overlaps(n)}async createSlot(t){var e,i;if(F.validateIsoRange(t.start,t.end),!t.location_id)throw new Error("location_id required");if(!t.org_id)throw new Error("org_id required");return await this.store.createSlot({...t,source:null!=(e=t.source)?e:"ad_hoc",capacity:null!=(i=t.capacity)?i:1})}async listSlots(t){return this.store.getSlots(t)}async listBookings(t){return this.store.getBookings(t)}capacityForType(t){return"animal_pickup"===t?2:1}isEligibleForAnimalPickup(t){return"animal_pickup"!==t.appointment_type||(!!t.animal_id||Array.isArray(t.animal_ids)&&t.animal_ids.length>0)}teamForType(t){return j[t]}priority(t){return x[t]}async createBooking(t){var e,a,n,r,s,d,l;if(F.validateIsoRange(t.start,t.end),!t.location_id)throw new Error("location_id required");if(!t.org_id)throw new Error("org_id required");if(!this.isEligibleForAnimalPickup(t))throw new Error("Animal pickup requires confirmed assignment");if(!(await this.store.getSlots({org_id:t.org_id,location_id:t.location_id,appointment_type:t.appointment_type,from:t.start,to:t.end})).some(e=>o.fromDateTimes(i.fromISO(e.start),i.fromISO(e.end)).contains(i.fromISO(t.start))&&o.fromDateTimes(i.fromISO(e.start),i.fromISO(e.end)).contains(i.fromISO(t.end))))throw new Error("No availability for requested time");const c=(await this.store.getBookings({org_id:t.org_id,location_id:t.location_id,from:t.start,to:t.end})).filter(e=>F.overlaps(e,t)),p=this.teamForType(t.appointment_type);if("animal_pickup"===t.appointment_type){if(c.filter(t=>"animal_pickup"===t.appointment_type).length>=this.capacityForType("animal_pickup"))throw new Error("Max overlapping pickups reached");const i=c.filter(t=>"coordinator"===this.teamForType(t.appointment_type)&&"animal_pickup"!==t.appointment_type),o={org_id:t.org_id,location_id:t.location_id,appointment_type:t.appointment_type,foster_id:t.foster_id,animal_id:t.animal_id,animal_ids:t.animal_ids,start:t.start,end:t.end,status:"confirmed",created_by:t.created_by,created_at:(new Date).toISOString()},r=await this.store.createBooking(o);for(const t of i)await this.store.updateBooking(t.id,{status:"overridden",conflict_group_id:r.id,override_of_booking_id:r.id}),await this.store.createOverrideEvent({org_id:t.org_id,location_id:t.location_id,pickup_booking_id:r.id,displaced_booking_id:t.id,created_at:(new Date).toISOString()}),await(null==(e=this.notify)?void 0:e.send({to:"coordinator",type:"conflict_alert",subject:"Animal pickup override created",message:"Pickup ".concat(r.id," overrides booking ").concat(t.id,". Review and reschedule."),metadata:{pickup_booking_id:r.id,displaced_booking_id:t.id}}));return await(null==(a=this.notify)?void 0:a.send({to:"foster",type:"confirmation",subject:"Pickup confirmed",message:"Your animal pickup is booked."})),await(null==(n=this.notify)?void 0:n.send({to:"coordinator",type:"confirmation",subject:"New pickup booked",message:"A foster booked a pickup."})),r}if(c.some(t=>
1"animal_pickup"===t.appointment_type))throw new Error("Conflicts with an animal pickup");if("medical"===p){if("vet_emergency"===t.appointment_type){const e=c.filter(t=>"medical"===this.teamForType(t.appointment_type)).filter(e=>this.priority(t.appointment_type)<this.priority(e.appointment_type)),i=await this.store.createBooking({org_id:t.org_id,location_id:t.location_id,appointment_type:t.appointment_type,foster_id:t.foster_id,animal_id:t.animal_id,start:t.start,end:t.end,status:"confirmed",created_by:t.created_by,created_at:(new Date).toISOString()});for(const t of e)await this.store.updateBooking(t.id,{status:"overridden",conflict_group_id:i.id,override_of_booking_id:i.id}),await this.store.createOverrideEvent({org_id:t.org_id,location_id:t.location_id,pickup_booking_id:i.id,displaced_booking_id:t.id,created_at:(new Date).toISOString()}),await(null==(r=this.notify)?void 0:r.send({to:"medical_team",type:"emergency_alert",subject:"Emergency vet override",message:"Emergency ".concat(i.id," overrides ").concat(t.id)}));return await(null==(s=this.notify)?void 0:s.send({to:"foster",type:"confirmation",subject:"Emergency visit confirmed",message:"Your emergency vet visit is booked."})),i}if(c.some(t=>"vet_emergency"===t.appointment_type))throw new Error("Conflicts with an emergency vet visit");if(c.length>=this.capacityForType(t.appointment_type))throw new Error("No capacity left for this time");const e=await this.store.createBooking({org_id:t.org_id,location_id:t.location_id,appointment_type:t.appointment_type,foster_id:t.foster_id,animal_id:t.animal_id,start:t.start,end:t.end,status:"confirmed",created_by:t.created_by,created_at:(new Date).toISOString()});return await(null==(d=this.notify)?void 0:d.send({to:"foster",type:"confirmation",subject:"Vet visit confirmed",message:"Your vet visit is booked."})),e}if(c.length>=this.capacityForType(t.appointment_type))throw new Error("No capacity left for this time");const _=await this.store.createBooking({org_id:t.org_id,location_id:t.location_id,appointment_type:t.appointment_type,foster_id:t.foster_id,animal_id:t.animal_id,start:t.start,end:t.end,status:"confirmed",created_by:t.created_by,created_at:(new Date).toISOString()});return await(null==(l=this.notify)?void 0:l.send({to:"foster",type:"confirmation",subject:"Appointment confirmed",message:"Your appointment is booked."})),_}}let W=0;function C(t){return"".concat(t,"_").concat(++W)}const U=new class{constructor(t){e(this,"locations",[]),e(this,"slots",[]),e(this,"exceptions",[]),e(this,"bookings",[]),e(this,"overrideEvents",[]),Object.assign(this,t)}async getLocations(t){return this.locations.filter(e=>e.org_id===t)}async getSlots(t){const e=new Date(t.from).toISOString(),i=new Date(t.to).toISOString();return this.slots.filter(o=>!(o.org_id!==t.org_id||t.location_id&&o.location_id!==t.location_id||t.appointment_type&&o.appointment_type!==t.appointment_type||o.end<=e||o.start>=i))}async createSlot(t){var e,i;const o={id:C("slot"),capacity:null!=(e=t.capacity)?e:1,source:null!=(i=t.source)?i:"ad_hoc",...t};return this.slots.push(o),o}async updateSlot(t,e){const i=this.slots.findIndex(e=>e.id===t);i>=0&&(this.slots[i]={...this.slots[i],...e})}async getExceptions(t,e){return this.exceptions.filter(i=>i.org_id===t&&(!e||i.location_id===e))}async getBookings(t){return this.bookings.filter(e=>!(e.org_id!==t.org_id||t.location_id&&e.location_id!==t.location_id||t.foster_id&&e.foster_id!==t.foster_id||t.from&&e.end<=t.from||t.to&&e.start>=t.to))}async createBooking(t){const e={id:C("booking"),...t};return this.bookings.push(e),e}async updateBooking(t,e){const i=this.bookings.findIndex(e=>e.id===t);i>=0&&(this.bookings[i]={...this.bookings[i],...e})}async createOverrideEvent(t){const e={id:C("ovr"),...t};return this.overrideEvents.push(e),e}};U.slots.length||function(t){t.locations.push({id:"loc1",org_id:"PAWS",name:"Main Shelter",address:"123 Paw Ave"});let e=1;for(let o=0;o<3;o++){const a=i.now().setZone("America/Los_Angeles").startOf("day").plus({days:o}),n=a.plus({hours:9}).toUTC().toISO(),r=a.plus({hours:15}).toUTC().toISO(),s=a.plus({hours:10}).toUTC().toISO(),d=a.plus({hours:15}).toUTC().toISO();t.slots.push({id:"s".concat(e++),org_id:"PAWS",location_id:"loc1",appointment_type:"animal_pickup",start:n,end:r,capacity:2,source:"ad_hoc"},{id:"s".concat(e++),org_id:"PAWS",location_id:"loc1",appointment_type:"supply_pickup",start:n,end:r,capacity:1,source:"ad_hoc"},{id:"s".concat(e++),org_id:"PAWS",location_id:"loc1",appointment_type:"vet_non_emergency",start:s,end:d,capacity:1,source:"ad_hoc"},{id:"s".concat(e++),org_id:"PAWS",location_id:"loc1",appointment_type:"spay_neuter",start:s,end:d,capacity:1,source:"ad_hoc"},{id:"s".concat(e++),org_id:"PAWS",location_id:"loc1",appointment_type:"vet_emergency",start:s,end:d,capacity:1,source:"ad_hoc"})}}(U);const q=new F({store:U}),N=t=>q.listSlots(t),L=t=>q.createBooking(t),R=t=>q.listBookings(t),Y={class:"controls"},M="PAWS",z="loc1",Q=Z(a({__name:"SchedulingDemo",setup(t){var e,o;const a=n("animal_pickup"),Z=n(null!=(e=i.fromISO("2025-08-15T17:00:00Z").toISO())?e:""),j=n(null!=(o=i.fromISO("2025-08-15T17:30:00Z").toISO())?o:""),x=n([]),F=n([]);function W(t){return i.fromISO(t).toFormat("ccc LLL d, h:mm a ZZZZ")}async function C(){x.value=await N({org_id:M,location_id:z,from:"2025-08-15T00:00:00Z",to:"2025-08-16T00:00:00Z",appointment_type:void 0}),F.value=await R({org_id:M,location_id:z,from:"2025-08-15T00:00:00Z",to:"2025-08-16T00:00:00Z"})}async function U(){try{await L({org_id:M,location_id:z,appointment_type:a.value,foster_id:"demo-foster",start:Z.value,end:j.value,created_by:"foster",animal_id:"animal_pickup"===a.value?"demo-animal"
1:void 0}),await C()}catch(t){alert(t.message||"Error")}}return r(C),(t,e)=>(V(),s(l(c),null,{default:d(()=>[p(l(f),null,{default:d(()=>[p(l(_),null,{default:d(()=>[p(l(u),null,{default:d(()=>[...e[3]||(e[3]=[m("Scheduling Demo",-1)])]),_:1})]),_:1})]),_:1}),p(l(D),{class:"ion-padding"},{default:d(()=>[y("div",Y,[p(l(g),null,{default:d(()=>[p(l(h),null,{default:d(()=>[...e[4]||(e[4]=[m("Appointment Type",-1)])]),_:1}),p(l(v),{modelValue:a.value,"onUpdate:modelValue":e[0]||(e[0]=t=>a.value=t),interface:"popover"},{default:d(()=>[p(l(k),{value:"animal_pickup"},{default:d(()=>[...e[5]||(e[5]=[m("Animal Pickup",-1)])]),_:1}),p(l(k),{value:"supply_pickup"},{default:d(()=>[...e[6]||(e[6]=[m("Supply Pickup",-1)])]),_:1}),p(l(k),{value:"vet_non_emergency"},{default:d(()=>[...e[7]||(e[7]=[m("Vet (Non-Emergency)",-1)])]),_:1}),p(l(k),{value:"spay_neuter"},{default:d(()=>[...e[8]||(e[8]=[m("Spay/Neuter",-1)])]),_:1}),p(l(k),{value:"vet_emergency"},{default:d(()=>[...e[9]||(e[9]=[m("Vet Emergency",-1)])]),_:1})]),_:1},8,["modelValue"])]),_:1}),p(l(g),null,{default:d(()=>[p(l(h),null,{default:d(()=>[...e[10]||(e[10]=[m("Start",-1)])]),_:1}),p(l(w),{datetime:"start"}),p(l(S),{"keep-contents-mounted":""},{default:d(()=>[p(l(b),{id:"start",presentation:"date-time",modelValue:Z.value,"onUpdate:modelValue":e[1]||(e[1]=t=>Z.value=t)},null,8,["modelValue"])]),_:1})]),_:1}),p(l(g),null,{default:d(()=>[p(l(h),null,{default:d(()=>[...e[11]||(e[11]=[m("End",-1)])]),_:1}),p(l(w),{datetime:"end"}),p(l(S),{"keep-contents-mounted":""},{default:d(()=>[p(l(b),{id:"end",presentation:"date-time",modelValue:j.value,"onUpdate:modelValue":e[2]||(e[2]=t=>j.value=t)},null,8,["modelValue"])]),_:1})]),_:1}),p(l(I),{expand:"block",onClick:U},{default:d(()=>[...e[12]||(e[12]=[m("Book",-1)])]),_:1})]),p(l(O),null,{default:d(()=>[p(l(E),null,{default:d(()=>[...e[13]||(e[13]=[m("Sample Slots (loc1 / PAWS)",-1)])]),_:1}),(V(!0),T(P,null,A(x.value,t=>(V(),s(l(g),{key:t.id},{default:d(()=>[p(l(h),null,{default:d(()=>[y("h3",null,B(t.appointment_type),1),y("p",null,B(W(t.start))+" – "+B(W(t.end)),1)]),_:2},1024)]),_:2},1024))),128))]),_:1}),p(l(O),null,{default:d(()=>[p(l(E),null,{default:d(()=>[...e[14]||(e[14]=[m("Bookings",-1)])]),_:1}),(V(!0),T(P,null,A(F.value,t=>(V(),s(l(g),{key:t.id},{default:d(()=>[p(l(h),null,{default:d(()=>[y("h3",null,B(t.appointment_type)+" ("+B(t.status)+")",1),y("p",null,B(W(t.start))+" – "+B(W(t.end)),1)]),_:2},1024)]),_:2},1024))),128))]),_:1})]),_:1})]),_:1}))}}),[["__scopeId","data-v-fee5332f"]]);export{Q as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.