PageSourceSearch

https://myelite.app/assets/useMobilityTemplates-Cy5_pLHL.js

js myelite.app collected 2026-10-09 22:02:31 UTC 5,167 bytes, 4 lines download raw bytes

1import{u as f,a as y,b as _}from"./vendor-query-MRsttINt.js";import{aF as m,at as a}from"./index-CQjtNSF2.js";const g=["Full Body","Upper Body","Lower Body","Core","Spine","Hips","Shoulders","Neck","Ankles","Wrists"],h=["None","Foam Roller","Resistance Band","Yoga Block","Lacrosse Ball","Massage Ball","Yoga Strap","Mat"];function q(){return f({queryKey:["mobility-templates"],queryFn:async()=>{const{data:t,error:e}=await a.from("mobility_templates").select("*").order("created_at",{ascending:!1});if(e)throw e;return t}})}function v(t){return f({queryKey:["mobility-template",t],queryFn:async()=>{if(!t)return null;const{data:e,error:i}=await a.from("mobility_templates").select("*").eq("id",t).single();if(i)throw i;return e},enabled:!!t})}function E(t){return f({queryKey:["mobility-template-exercises",t],queryFn:async()=>{if(!t)return[];const{data:e,error:i}=await a.from("mobility_template_exercises").select(`
2          *,
3          exercise:exercises(id, name, muscle_group, equipment, difficulty)
4        `).eq("template_id",t).order("order_index",{ascending:!0});if(i)throw i;return e},enabled:!!t})}function F(){const t=y();return _({mutationFn:async e=>{const{data:i}=await a.auth.getUser();if(!i.user)throw new Error("Not authenticated");const{exercises:r,...n}=e,{data:l,error:u}=await a.from("mobility_templates").insert({coach_id:i.user.id,...n}).select().single();if(u)throw u;if(r&&r.length>0){const d=r.map((s,p)=>({template_id:l.id,exercise_id:s.exercise_id,name:s.name,description:s.description,duration_seconds:s.duration_seconds,reps:s.reps,sets:s.sets,order_index:p,notes:s.notes,video_url:s.video_url,image_url:s.image_url})),{error:c}=await a.from("mobility_template_exercises").insert(d);if(c)throw c}return l},onMutate:async e=>{await t.cancelQueries({queryKey:["mobility-templates"]});const i=t.getQueryData(["mobility-templates"]),r={id:`temp-${Date.now()}`,coach_id:"",name:e.name,description:e.description||null,difficulty_level:e.difficulty_level||null,estimated_duration_minutes:e.estimated_duration_minutes||null,body_focus:e.body_focus||null,equipment:e.equipment||null,is_public:e.is_public||!1,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return t.setQueryData(["mobility-templates"],n=>[r,...n||[]]),{previousTemplates:i}},onSuccess:e=>{t.setQueryData(["mobility-templates"],i=>i?.map(r=>r.id.startsWith("temp-")?e:r)||[e]),m.success("Mobility template created")},onError:(e,i,r)=>{r?.previousTemplates&&t.setQueryData(["mobility-templates"],r.previousTemplates),m.error("Failed to create template: "+e.message)}})}function S(){const t=y();return _({mutationFn:async({id:e,data:i})=>{const{exercises:r,...n}=i,{error:l}=await a.from("mobility_templates").update({...n,updated_at:new Date().toISOString()}).eq("id",e);if(l)throw l;if(r!==void 0){const{error:u}=await a.from("mobility_template_exercises").delete().eq("template_id",e);if(u)throw u;if(r.length>0){const d=r.map((s,p)=>({template_id:e,exercise_id:s.exercise_id,name:s.name,description:s.description,duration_seconds:s.duration_seconds,reps:s.reps,sets:s.sets,order_index:p,notes:s.notes,video_url:s.video_url,image_url:s.image_url})),{error:c}=await a.from("mobility_template_exercises").insert(d);if(c)throw c}}},onSuccess:(e,{id:i})=>{t.invalidateQueries({queryKey:["mobility-templates"]}),t.invalidateQueries({queryKey:["mobility-template",i]}),t.invalidateQueries({queryKey:["mobility-template-exercises",i]}),m.success("Mobility template updated")},onError:e=>{m.error("Failed to update template: "+e.message)}})}function D(){const t=y();return _({mutationFn:async e=>{const{error:i}=await a.from("mobility_templates").delete().eq("id",e);if(i)throw i},onSuccess:()=>{t.invalidateQueries({queryKey:["mobility-templates"]}),m.success("Mobility template deleted")},onError:e=>{m.error("Failed to delete template: "+e.message)}})}function M(){const t=y();return _({mutationFn:async e=>{const{data:i}=await a.auth.getUser();if(!i.user)throw new Error("Not authenticated");const{data:r,error:n}=await a.from("mobility_templates").select("*").eq("id",e).single();if(n)throw n;const{data:l,error:u}=await a.from("mobility_templates").insert({coach_id:i.user.id,name:`${r.name} (Copy)`,description:r.description,difficulty_level:r.difficulty_level,estimated_duration_minutes:r.estimated_duration_minutes,body_focus:r.body_focus,equipment:r.equipment,is_public:!1}).select().single();if(u)throw u;const{data:d,error:c}=await a.from("mobility_template_exercises").select("*").eq("template_id",e).order("order_index",{ascending:!0});if(c)throw c;if(d&&d.length>0){const s=d.map(o=>({template_id:l.id,exercise_id:o.exercise_id,name:o.name,description:o.description,duration_seconds:o.duration_seconds,reps:o.reps,sets:o.sets,order_index:o.order_index,notes:o.notes,video_url:o.video_url,image_url:o.image_url})),{error:p}=await a.from("mobility_template_exercises").insert(s);if(p)throw p}return l},onSuccess:()=>{t.invalidateQueries({queryKey:["mobility-templates"]}),m.success("Template duplicated")},onError:e=>{m.error("Failed to duplicate template: "+e.message)}})}export{g as B,h as E,D as a,M as b,v as c,E as d,F as e,S as f,q 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.