PageSourceSearch

https://care.soberpedia.ai/assets/resourcesApi-C8zfi_q2.js

js soberpedia.ai collected 2026-10-05 15:11:04 UTC 2,994 bytes, 1 lines download raw bytes

1import{R as l}from"./chartPalette-CFmN-0p5.js";import{h as D,s as p,d as C,g as T,i as h,c as O,t as I,e as U}from"./firebase-w6DYUbFN.js";import{cF as E,cG as m,cH as f,as as R}from"./index-DEXJEDAi.js";import"./react-vendor-CU6Sz31W.js";import"./payment-icons-Daq1K3F1.js";const _=new Set(["room","chair","equipment","machine","other"]),B=new Set(["active","inactive"]);function s(t,e=500){return typeof t!="string"?"":t.trim().slice(0,e)}function d(t,e=500){return s(t,e)||null}function L(t){return Array.isArray(t)?[...new Set(t.filter(e=>typeof e=="string"&&e.trim()).map(e=>e.trim()))]:[]}function q(t){const e=s(t,20).toLowerCase();return l.includes(e)?e:l[l.length-1]}function g(t){const e=_.has(s(t.category,20))?s(t.category,20):"room",r=B.has(s(t.status,20))?s(t.status,20):"active";return{name:s(t.name,200),category:e,resourceCategoryId:d(t.resourceCategoryId,128),description:d(t.description,500),serviceIds:L(t.serviceIds),locationId:d(t.locationId,128),calendarColor:q(t.calendarColor),useLocationHours:t.useLocationHours!==!1,availabilityNotes:d(t.availabilityNotes,500),status:r}}function A(t){return U(R,"Businesses",t,"Resources")}async function Y(t){return t?(await O(A(t))).docs.map(r=>{var n,o,i,w,c,S,u,y;const a=r.data()||{};return{id:r.id,...a,createdAt:((w=(i=(o=(n=a.createdAt)==null?void 0:n.toDate)==null?void 0:o.call(n))==null?void 0:i.toISOString)==null?void 0:w.call(i))||null,updatedAt:((y=(u=(S=(c=a.updatedAt)==null?void 0:c.toDate)==null?void 0:S.call(c))==null?void 0:u.toISOString)==null?void 0:y.call(u))||null}}).sort((r,a)=>String(r.name||"").localeCompare(String(a.name||""))):[]}async function F({businessId:t,actor:e,...r}){const a=g(r);if(!a.name)throw new Error("name is required");const n=await D(A(t),{businessId:t,...a,createdAt:p(),updatedAt:p(),createdBy:(e==null?void 0:e.id)||null});return await E({businessId:t,actor:e,actionType:m.RESOURCE_CREATED,entityType:f.RESOURCE,entity
1Id:n.id,description:`Created ${a.category} "${a.name}"`,locationId:a.locationId}),n.id}async function G({businessId:t,actor:e,resourceId:r,...a}){if(!r)throw new Error("resourceId is required");const n=C(R,"Businesses",t,"Resources",r),o=await T(n);if(!o.exists())throw new Error("Resource not found");const i=g({...o.data(),...a});if(!i.name)throw new Error("name is required");await I(n,{...i,updatedAt:p()}),await E({businessId:t,actor:e,actionType:m.RESOURCE_EDITED,entityType:f.RESOURCE,entityId:r,description:`Edited resource "${i.name}"`})}async function P({businessId:t,actor:e,resourceId:r}){var o;if(!r)throw new Error("resourceId is required");const a=C(R,"Businesses",t,"Resources",r),n=await T(a);if(!n.exists())throw new Error("Resource not found");await h(a),await E({businessId:t,actor:e,actionType:m.RESOURCE_DELETED,entityType:f.RESOURCE,entityId:r,description:`Deleted resource "${((o=n.data())==null?void 0:o.name)||r}"`})}export{l as RESOURCE_CALENDAR_COLORS,F as createResource,P as deleteResource,Y as listResources,G as updateResource};

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.