1import{d as ae,w as se,o as Pe,A as Ne,c as i,l as n,p as T,t as v,g as C,h as f,v as ie,L as Ie,a3 as Ke,al as He,a5 as Re,i as H,f as Q,W as J,F as S,r as z,a1 as Ge,B as $,C as Te,j as a,q as xe,e as s,a4 as X,ah as ze,k as M,z as We,R as U,b as Ye,u as Je}from"./BwpTFavE.js";import{_ as N}from"./BxHuDusB.js";import{V as oe}from"./DR3G3xu3.js";import{V as le}from"./D01OON3s.js";import{_ as ye}from"./DyBq7sQ2.js";import{V as Qe}from"./zzEXrOAK.js";import{V as qe}from"./DUOfR02T.js";import{_ as Xe}from"./iTyJZpeK.js";import{u as Ze}from"./BDqZa_LX.js";import"./CkHYmywM.js";const et={key:0,class:"group flex items-center gap-1.5 min-w-0"},tt=["disabled","title"],nt={key:0,class:"text-xs text-[#888EA3]"},st=["disabled","aria-label"],lt=["placeholder","disabled","onKeydown"],ot={key:0,class:"py-1"},at=["onClick"],it={class:"flex items-center gap-2 min-w-0"},rt={class:"flex-1 min-w-0 truncate text-sm text-[#1B2441]"},ut={key:0,class:"shrink-0 text-[10px] uppercase tracking-wide text-[#888EA3] border border-[#D9DBE1] rounded px-1 py-0.5"},ct={key:0,class:"text-xs text-[#888EA3] truncate"},dt={key:1,class:"px-3 py-4 text-center text-sm text-[#888EA3]"},pt=300,Le=ae({__name:"VPStructurePicker",props:{current:{},fetcher:{},placeholder:{default:"Rechercherâ¦"},disabled:{type:Boolean,default:!1}},emits:["select"],setup(b,{emit:r}){const c=b,D=r,B=$(null),R=$(null),g=$(null),k=$(null),L=$(""),y=$([]),F=$(!1),j=$(!1),d=$(!1),K=$({});let V=null;function w(){if(!R.value)return;const x=R.value.getBoundingClientRect();K.value={position:"fixed",top:`${x.bottom+4}px`,left:`${x.left}px`,width:`${Math.max(x.width,280)}px`,zIndex:"10000"}}async function Z(){c.disabled||(d.value=!0,await Te(),k.value?.focus(),w())}function P(){j.value=!1,d.value=!1,L.value="",y.value=[]}function G(x){P(),D("select",x)}se(L,x=>{if(V&&clearTimeout(V),x.length<2){y.value=[];return}V=setTimeout(async()=>{F.value=!0;try{y.value=await c.fetcher(x)}finally{F.value=!1,j.value=!0,Te(w)}},pt)}),se(j,x=>{x?(Te(w),window.addEventListener("scroll",w,!0),window.addEventListener("resize",w)):(window.removeEventListener("scroll",w,!0),window.removeEventListener("resize",w))}),se(()=>c.current,()=>P());function ee(x){const m=x.target;B.value?.contains(m)||g.value?.contains(m)||P()}return Pe(()=>document.addEventListener("mousedown",ee)),Ne(()=>{document.removeEventListener("mousedown",ee),window.removeEventListener("scroll",w,!0),window.removeEventListener("resize",w),V&&clearTimeout(V)}),(x,m)=>{const O=ie;return a(),i("div",{ref_key:"root",ref:B,class:"relative"},[b.current&&!d.value?(a(),i("div",et,[n("button",{type:"button",class:"flex-1 min-w-0 text-left truncate text-sm text-[#1B2441] hover:text-[#2EC07E] disabled:opacity-50",disabled:b.disabled,title:`${b.current.label}${b.current.hint?" â "+b.current.hint:""}`,onClick:Z},[T(v(b.current.label)+" ",1),b.current.hint?(a(),i("span",nt,"· "+v(b.current.hint),1)):C("",!0)],8,tt),n("button",{type:"button",class:"shrink-0 text-[#B3B7C3] hover:text-[#F73438] disabled:opacity-40",disabled:b.disabled,"aria-label":`Retirer ${b.current.label}`,title:"Retirer le rattachement",onClick:m[0]||(m[0]=_=>D("select",null))},[f(O,{name:"heroicons:x-mark",class:"w-4 h-4"})],8,st)])):(a(),i("div",{key:1,ref_key:"anchor",ref:R,class:"relative flex items-center"},[Ie(n("input",{ref_key:"input",ref:k,"onUpdate:modelValue":m[1]||(m[1]=_=>L.value=_),type:"text",placeholder:b.placeholder,disabled:b.disabled,class:"w-full bg-[#F7F8FA] border border-[#D9DBE1] rounded px-2 py-1.5 pr-7 text-sm text-[#1B2441] outline-none focus:border-[#2EC07E] placeholder:text-[#B3B7C3] disabled:opacity-50",onFocus:m[2]||(m[2]=_=>j.value=!0),onKeydown:He(Re(P,["stop"]),["escape"])},null,40,lt),[[Ke,L.value]]),f(O,{name:F.value?"heroicons:arrow-path":"heroicons:magnifying-glass",class:H(["absolute right-2 w-4 h-4 text-[#B3B7C3] pointer-events-none",F.value?"animate-spin text-[#2EC07E]":""])},null,8,["name","class"])],512)),(a(),Q(Ge,{to:"body"},[j.value&&L.value.length>=2&&!F.value?(a(),i("div",{key:0,ref_key:"dropdown",ref:g,class:"bg-white rounded shadow-lg border border-[#D9DBE1] max-h-72 overflow-y-auto",style:J(K.value)},[y.value.length?(a(),i("ul",ot,[(a(!0),i(S,null,z(y.value,_=>(a(),i("li",{key:_.id},[n("button",{type:"button",class:"w-full px-3 py-2 text-left hover:bg-[#F3F4F6]",onClick:A=>G(_)},[n("div",it,[n("span",rt,v(_.label),1),_.claimed?C("",!0):(a(),i("span",ut,"Sans club"))]),_.hint?(a(),i("div",ct,v(_.hint),1)):C("",!0)],8,at)]))),128))])):(a(),i("p",dt,"Aucune structure trouvée."))],4)):C("",!0)]))],512)}}}),mt={class:"space-y-4"},ft={class:"bg-[#F7F8FA] border border-[#D9DBE1] rounded-lg p-4"},bt={class:"flex items-center justify-between mb-3"},vt={class:"text-sm font-semibold text-[#1B2441]"},xt={class:"grid grid-cols-1 md:grid-cols-3 gap-3"},yt={key:1,class:"flex flex-col"},ht={class:"flex flex-wrap items-center gap-5 mt-3"},gt={class:"ml-auto flex gap-2"},kt={class:"text-xs font-semibold uppercase tracking-wide text-[#666F87]"},_t={class:"border border-[#D9DBE1] rounded-lg overflow-hidden"},Ct={class:"w-full text-sm"},$t={class:"px-3 py-2"},Bt={class:"px-3 py-2"},Et={key:0,class:"text-xs"},Ft={class:"px-3 py-2"},wt={class:"px-3 py-2"},At={class:"px-3 py-2 text-right"},St={class:"px-3 py-2 text-right"}
1,Dt=["aria-label","onClick"],Vt="Le code est recopié dans les types des clubs : le renommer les laisserait pointer dans le vide.",Tt=ae({__name:"TypesModal",props:{modelValue:{type:Boolean},types:{},saveType:{type:Function},deleteType:{type:Function}},emits:["update:modelValue"],setup(b,{emit:r}){const c=b,D=r,B={federation:"Fédérations",structure:"Maillage territorial",section:"Commissions et mini-sites",legal:"Nature juridique"},R=Object.entries(B).map(([x,m])=>({value:x,label:m})),g=$(null),k=$(!1);function L(){return{code:"",label:"",short_label:"",category:"structure",ownable:!1,active:!0,position:0}}const y=ze(L()),F=$(""),j=$("#2EC07E"),d=M(()=>{const x=y.code.trim().toLowerCase();return x===""?"":/^[a-z0-9_]+$/.test(x)?c.types.some(m=>m.code===x)?"Ce code existe déjà .":"":"Lettres minuscules, chiffres et tirets bas uniquement."}),K=M(()=>y.label.trim()!==""&&(g.value!==null||y.code.trim()!==""&&d.value==="")),V=M(()=>Object.keys(B).map(x=>({category:x,label:B[x],types:c.types.filter(m=>m.category===x)})).filter(x=>x.types.length>0));function w(){g.value=null,Object.assign(y,L()),F.value="",j.value="#2EC07E"}function Z(x){g.value=x,y.code=x.code,y.label=x.label,y.short_label=x.short_label===x.label?"":x.short_label,y.category=x.category,y.ownable=x.ownable,y.active=x.active,y.position=x.position,F.value=x.hierarchy_level===null?"":String(x.hierarchy_level),j.value=x.color??"#2EC07E"}function P(){const x=F.value.trim();return{...g.value?{}:{code:y.code.trim().toLowerCase()},label:y.label.trim(),short_label:y.short_label.trim(),category:y.category,hierarchy_level:x===""?null:Number(x),ownable:y.ownable,color:j.value||null,position:y.position,active:y.active}}async function G(){if(K.value){k.value=!0;try{await c.saveType(g.value,P())&&w()}finally{k.value=!1}}}async function ee(){g.value&&await c.deleteType(g.value)&&w()}return se(()=>c.modelValue,x=>{x&&w()}),(x,m)=>{const O=ie;return a(),Q(ye,{"model-value":b.modelValue,title:"Types de structure et fédérations",size:"xl","max-width-class":"sm:max-w-[64rem]","onUpdate:modelValue":m[11]||(m[11]=_=>D("update:modelValue",_))},{default:xe(()=>[n("div",mt,[m[15]||(m[15]=n("p",{class:"text-sm text-[#444B64]"}," Les types décrivent ce qu'est une structure : sa fédération, son échelon dans le maillage, sa nature juridique. Le niveau hiérarchique remplace les règles écrites en dur â un parent doit être strictement au-dessus de son enfant, et c'est tout ce que l'écran vérifie. ",-1)),n("div",ft,[n("div",bt,[n("h3",vt,v(s(g)?`Modifier « ${s(g).label} »`:"Nouveau type"),1),s(g)?(a(),Q(N,{key:0,text:"Annuler",variant:"outlined",color:"info",size:"xs",onClick:m[0]||(m[0]=_=>w())})):C("",!0)]),n("div",xt,[s(g)?(a(),i("div",yt,[m[12]||(m[12]=n("span",{class:"text-sm text-[#666F87] mb-2"},"Code",-1)),n("span",{class:"px-3 py-2.5 bg-[#ECEDF0] rounded-sm text-sm text-[#888EA3]",title:Vt},v(s(g).code),1)])):(a(),Q(oe,{key:0,modelValue:s(y).code,"onUpdate:modelValue":m[1]||(m[1]=_=>s(y).code=_),label:"Code",placeholder:"flassa",error:s(d)},null,8,["modelValue","error"])),f(oe,{modelValue:s(y).label,"onUpdate:modelValue":m[2]||(m[2]=_=>s(y).label=_),label:"Libellé",placeholder:"Fédération Libre des Activités Subaquatiques"},null,8,["modelValue"]),f(oe,{modelValue:s(y).short_label,"onUpdate:modelValue":m[3]||(m[3]=_=>s(y).short_label=_),label:"Libellé court",placeholder:"FLASSA"},null,8,["modelValue"]),f(le,{modelValue:s(y).category,"onUpdate:modelValue":m[4]||(m[4]=_=>s(y).category=_),label:"Catégorie",options:s(R)},null,8,["modelValue","options"]),f(oe,{modelValue:s(F),"onUpdate:modelValue":m[5]||(m[5]=_=>X(F)?F.value=_:null),label:"Niveau hiérarchique",type:"number",placeholder:"vide = hors maillage"},null,8,["modelValue"]),f(Xe,{modelValue:s(j),"onUpdate:modelValue":m[6]||(m[6]=_=>X(j)?j.value=_:null),label:"Couleur"},null,8,["modelValue"])]),n("div",ht,[f(qe,{modelValue:s(y).ownable,"onUpdate:modelValue":m[7]||(m[7]=_=>s(y).ownable=_),label:"Section d'une autre structure (rattachée par « appartient à »)"},null,8,["modelValue"]),f(qe,{modelValue:s(y).active,"onUpdate:modelValue":m[8]||(m[8]=_=>s(y).active=_),label:"Proposé à l'affectation"}
1,null,8,["modelValue"]),n("div",gt,[s(g)&&s(g).usage===0?(a(),Q(N,{key:0,text:"Supprimer",variant:"outlined",color:"danger",size:"sm",onClick:m[9]||(m[9]=_=>ee())})):C("",!0),f(N,{text:s(g)?"Enregistrer":"Créer le type",color:"primary",size:"sm",disabled:!s(K)||s(k),onClick:m[10]||(m[10]=_=>G())},null,8,["text","disabled"])])]),m[13]||(m[13]=n("p",{class:"text-xs text-[#888EA3] mt-2"}," Niveau : 10 national, 20 régional, 30 départemental, 40 club. Laissé vide, le type n'intervient pas dans le contrôle des rattachements. ",-1))]),(a(!0),i(S,null,z(s(V),_=>(a(),i("div",{key:_.category,class:"space-y-1.5"},[n("h4",kt,v(_.label),1),n("div",_t,[n("table",Ct,[m[14]||(m[14]=n("thead",{class:"bg-[#F3F4F6] text-[#666F87]"},[n("tr",null,[n("th",{class:"text-left font-medium px-3 py-2"},"Code"),n("th",{class:"text-left font-medium px-3 py-2"},"Libellé"),n("th",{class:"text-left font-medium px-3 py-2 w-24"},"Niveau"),n("th",{class:"text-left font-medium px-3 py-2 w-24"},"Section"),n("th",{class:"text-right font-medium px-3 py-2 w-28"},"Clubs"),n("th",{class:"px-3 py-2 w-20"})])],-1)),n("tbody",null,[(a(!0),i(S,null,z(_.types,A=>(a(),i("tr",{key:A.id,class:H(["border-t border-[#ECEDF0]",A.active?"":"bg-[#FAFAFB] text-[#B3B7C3]"])},[n("td",$t,[n("span",{class:"inline-flex items-center gap-1.5 font-mono text-xs",style:J(A.color?{color:A.color}:void 0)},[n("span",{class:"w-2 h-2 rounded-full shrink-0",style:J({backgroundColor:A.color||"#D9DBE1"})},null,4),T(" "+v(A.code),1)],4)]),n("td",Bt,[T(v(A.label)+" ",1),A.active?C("",!0):(a(),i("span",Et," â désactivé"))]),n("td",Ft,v(A.hierarchy_level??"â"),1),n("td",wt,v(A.ownable?"Oui":"â"),1),n("td",At,v(A.usage),1),n("td",St,[n("button",{type:"button",class:"text-[#666F87] hover:text-[#2EC07E]","aria-label":`Modifier ${A.label}`,onClick:te=>Z(A)},[f(O,{name:"heroicons:pencil-square",class:"w-4 h-4"})],8,Dt)])],2))),128))])])])]))),128))])]),_:1},8,["model-value"])}}}),Rt={class:"space-y-1"},Lt=["title"],qt={key:0,class:"text-[11px]"},Ut=["title"],jt={key:1,class:"shrink-0 text-[10px] uppercase tracking-wide text-[#9A5612] border border-[#FFCB91] bg-[#FFF3E6] rounded px-1"},Pt=["disabled","aria-label","onClick"],zt={key:0,class:"text-xs text-[#B3B7C3]"},be=ae({__name:"LinkCollection",props:{links:{},fetcher:{},placeholder:{default:"Ajouterâ¦"},allowAdd:{type:Boolean,default:!0},emptyLabel:{default:"â"},disabled:{type:Boolean,default:!1}},emits:["add","remove"],setup(b,{emit:r}){const c=r;function D(B){return[B.club_name||B.location_name,[B.zip,B.city].filter(Boolean).join(" ")].filter(Boolean).join(" â ")}return(B,R)=>{const g=ie;return a(),i("div",Rt,[(a(!0),i(S,null,z(b.links,k=>(a(),i("div",{key:k.rel_id,class:"flex items-center gap-1 min-w-0 group"},[n("span",{class:H(["flex-1 min-w-0 truncate text-sm",k.club_id?"text-[#1B2441]":"text-[#888EA3] italic"]),title:D(k)},[T(v(k.club_name||k.location_name||`Location ${k.location_id}`)+" ",1),k.club_id?C("",!0):(a(),i("span",qt," · sans club"))],10,Lt),k.analytics&&k.analytics.descendants>0?(a(),i("span",{key:0,class:"shrink-0 text-[10px] text-[#666F87]",title:`${k.analytics.descendants} structures sous celle-ci`},v(k.analytics.descendants)+" sous elle",9,Ut)):C("",!0),k.relations&&k.relations.length?(a(),i("span",jt,v(k.relations.join(", ")),1)):C("",!0),n("button",{type:"button",class:"shrink-0 text-[#D9DBE1] group-hover:text-[#B3B7C3] hover:!text-[#F73438] disabled:opacity-40",disabled:b.disabled,"aria-label":`Retirer ${k.club_name||k.location_name}`,title:"Retirer ce lien",onClick:L=>c("remove",k.rel_id)},[f(g,{name:"heroicons:x-mark",class:"w-4 h-4"})],8,Pt)]))),128)),b.links.length===0&&!b.allowAdd?(a(),i("p",zt,v(b.emptyLabel),1)):C("",!0),b.allowAdd?(a(),Q(Le,{key:1,current:null,disabled:b.disabled,placeholder:b.placeholder,fetcher:b.fetcher,onSelect:R[0]||(R[0]=k=>k&&c("add",k))},null,8,["disabled","placeholder","fetcher"])):C("",!0)])}}}),Mt={key:0,class:"text-xs text-[#888EA3]"},Ot={key:1,class:"space-y-3"},Nt={key:0,class:"flex items-center flex-wrap gap-1 text-xs text-[#444B64]"},It={class:"px-1.5 py-0.5 rounded bg-white border border-[#D9DBE1]"},Kt={key:0,class:"text-[#1B2441] font-medium"},Ht={key:1,class:"text-xs text-[#888EA3]"},Gt={class:"grid grid-cols-1 lg:grid-cols-2 gap-4"},Wt={class:"text-xs font-semibold uppercase tracking-wide text-[#666F87] mb-1.5"}
1,Yt={class:"bg-white border border-[#ECEDF0] rounded p-2 max-h-72 overflow-y-auto"},Jt={class:"text-xs font-semibold uppercase tracking-wide text-[#666F87] mb-1.5"},Qt={class:"bg-white border border-[#ECEDF0] rounded p-2 max-h-72 overflow-y-auto"},Xt=ae({__name:"BranchPanel",props:{branch:{},fetcher:{type:Function},disabled:{type:Boolean}},emits:["add","remove"],setup(b,{emit:r}){const c=r;return(D,B)=>{const R=ie;return b.branch?(a(),i("div",Ot,[b.branch.ancestors.length?(a(),i("div",Nt,[B[4]||(B[4]=n("span",{class:"text-[#888EA3]"},"Chaîne :",-1)),(a(!0),i(S,null,z(b.branch.ancestors,(g,k)=>(a(),i(S,{key:g.rel_id},[n("span",It,v(g.club_name||g.location_name),1),f(R,{name:g.relation==="owner"?"heroicons:square-2-stack":"heroicons:chevron-right",class:"w-3 h-3 text-[#B3B7C3]",title:g.relation==="owner"?"appartient à ":"enfant de"},null,8,["name","title"]),k===b.branch.ancestors.length-1?(a(),i("span",Kt,"ici")):C("",!0)],64))),128))])):(a(),i("div",Ht,"Aucun rattachement au-dessus de cette structure.")),n("div",Gt,[n("div",null,[n("div",Wt," Enfants ("+v(b.branch.children.length)+") ",1),n("div",Yt,[f(be,{links:b.branch.children,disabled:b.disabled,placeholder:"Ajouter un enfantâ¦","empty-label":"Aucun enfant.",fetcher:b.fetcher,onAdd:B[0]||(B[0]=g=>c("add",{relation:"parent",targetId:g.id})),onRemove:B[1]||(B[1]=g=>c("remove",g))},null,8,["links","disabled","fetcher"])])]),n("div",null,[n("div",Jt," Sections possédées ("+v(b.branch.sections.length)+") ",1),n("div",Qt,[f(be,{links:b.branch.sections,disabled:b.disabled,placeholder:"Ajouter une sectionâ¦","empty-label":"Aucune section.",fetcher:b.fetcher,onAdd:B[2]||(B[2]=g=>c("add",{relation:"owner",targetId:g.id})),onRemove:B[3]||(B[3]=g=>c("remove",g))},null,8,["links","disabled","fetcher"])])])])])):(a(),i("div",Mt,"Chargement de la brancheâ¦"))}}}),fe=ae({__name:"SortCaret",props:{column:{},sort:{},direction:{}},setup(b){return(r,c)=>{const D=ie;return b.column===b.sort?(a(),Q(D,{key:0,name:b.direction==="asc"?"heroicons:chevron-up":"heroicons:chevron-down",class:"w-3 h-3 inline-block"},null,8,["name"])):C("",!0)}}}),Zt=350,Ue={danger:{bg:"#FDECEC",text:"#B4262A",border:"#F7A7A9"},warning:{bg:"#FFF3E6",text:"#9A5612",border:"#FFCB91"},info:{bg:"#F1F2F5",text:"#444B64",border:"#D9DBE1"}};function en(b){return Ue[b??"info"]??Ue.info}function je(){return{search:"",federation:"",types:[],kinds:["structure","club_without_location","orphan_location"],alert:"",link:"",includeDeleted:!1,ignored:"hide",sort:"alerts",direction:"desc",page:1,limit:50}}function tn(){const b=We(),r=$(!1),c=$(!1),D=$(null),B=$([]),R=$(0),g=$(1),k=$([]),L=$([]),y=$(null),F=$([]),j=$(null),d=ze(je()),K=$(new Set),V=$({}),w=$(new Set),Z=M(()=>k.value.filter(l=>l.category==="federation")),P=M(()=>k.value.filter(l=>l.active)),G=M(()=>{const l={};return k.value.forEach(p=>{l[p.code]=p}),l}),ee=M(()=>d.search!==""||d.federation!==""||d.types.length>0||d.alert!==""||d.link!==""||d.includeDeleted||d.ignored!=="hide"||d.kinds.length!==3);function x(){const l=new URLSearchParams;return d.search&&l.set("search",d.search),d.federation&&l.set("federation",d.federation),d.alert&&l.set("alert",d.alert),d.link&&l.set("link",d.link),d.includeDeleted&&l.set("include_deleted","1"),d.ignored!=="hide"&&l.set("ignored",d.ignored),d.types.length&&l.set("types",d.types.join(",")),d.kinds.length&&d.kinds.length<3&&l.set("kinds",d.kinds.join(",")),l.set("sort",d.sort),l.set("direction",d.direction),l.set("page",String(d.page)),l.set("limit",String(d.limit)),l.toString()}async function m(){c.value=!0;try{const l=await U(`/api/structure-network/referential${d.includeDeleted?"?include_deleted=1":""}`);k.value=l?.types??[],L.value=l?.alerts??[],y.value=l?.stats?.global??null,F.value=l?.stats?.federations??[],j.value=l?.stats?.premium_date??null}catch{}finally{c.value=!1}}async function O(){r.value=!0,D.value=null;try{const l=await U(`/api/structure-network/rows?${x()}`);B.value=l?.rows??[],R.value=l?.total??0,g.value=l?.pages??1,l?.page&&l.page!==d.page&&(d.page=l.page)}catch(l){D.value=l?.response?.data?.message??"Le réseau des structures n'a pas pu être chargé.",B.value=[],R.value=0}finally{r.value=!1}}async function _(){V.value={},await Promise.all([O(),m()])}let A=null;se(()=>d.search,()=>{A&&clearTimeout(A),A=setTimeout(()=>{d.page=1,O()},Zt)}),se(()=>[d.federation,d.types.join(","),d.kinds.join(","),d.alert,d.link,d.includeDeleted,d.ignored,d.sort,d.direction],()=>{d.page=1,O()}),se(()=>[d.page,d.limit],()=>O());function te(){Object.assign(d,je()),O()}function re(l){const p=d.types.indexOf(l);p===-1?d.types.push(l):d.types.splice(p,1)}function he(l){const p=d.kinds.indexOf(l);p===-1?d.kinds.push(l):d.kinds.length>1&&d.kinds.splice(p,1)}function ge(l){d.sort===l?d.direction=d.direction==="asc"?"desc":"asc":(d.sort=l,d.direction=l==="name"?"asc":"desc")}function q(l,p){const E=new Set(K.value);p?E.add(l):E.delete(l),K.value=E}function ke(l){return K.value.has(l)}async function Y(l){const p=B.value.findIndex(t=>t.key===l);if(p===-1){await Promise.all([O(),m()]);return}const E=B.value[p],I=E.club?"club":"location",W=E.club?E.club.id:E.location?.id;if(!W)return;const De=x();let ne=null;try{ne=await U(`/api/structure-network/rows/${I}/${W}?${De}`)}catch{await Promise.all([O(),m()]);return}const me=[...B.value];ne?.row&&ne.matches?me[p]=ne.row:(me.splice(p,1),R.value=Math.max(0,R.value-1)),B.value=me;const o=ne?.row?.location??E.location;if(o&&w.value.has(l)){const t={...V.value};delete t[o.id],V.value=t,await pe(o.id)}m()}async function _e(l,p){if(!l.club)return!1;q(`${l.key}:types`,!0);try{return await U(`/api/structure-network/clubs/${l.club.id}/types`,{method:"PUT",data:{types:p}}),await Y(l.key),!0}catch{return!1}finally{q(`${l.key}:types`,!1)}}async function ue(l,p){q(`${l.key}:federations`,!0);try{if(l.club){const E=new Set(Z.value.map(W=>W.code)),I=l.types.filter(W=>!E.has(W));await U(`/api/structure-network/clubs/${l.club.id}/types`,{method:"PUT",data:{types:[...I,...p]}})}else if(l.location)await U(`/api/structure-network/locations/${l.location.id}/affiliation`,{method:"PUT",data:{federations:p}});else return!1;return await Y(l.key),b.add({title:"Fédérations enregistrées",description:l.name,icon:"heroicons:check-circle",color:"green"}),!0}catch{return!1}finally{q(`${l.key}:federations`,!1)}}async function ce(l,p,E){if(!l.location)return!1;q(`${l.key}:${p}`,!0);try{return await U(`/api/structure-network/locations/${l.location.id}/${p}`,{method:"PUT",data:{location_id:E}}),await Y(l.key),b.add({title:p==="parent"?"Rattachement enregistré":"Appartenance enregistrée",description:E===null?`${l.name} n'est plus rattaché.`:`${l.name} est à jour.`,icon:"heroicons:check-circle",color:"green"}),!0}catch{return!1}finally{q(`${l.key}:${p}`,!1)}}async function de(l,p){if(!l.location)return!1;q(`${l.key}:club`,!0);try{return await U(`/api/structure-network/locations/${l.location.id}/club`,{method:"PUT",data:{club_id:p}}),await Y(l.key),b.add({title:p===null?"Location libérée":"Location revendiquée",description:l.location.name??"",icon:"heroicons:check-circle",color:"green"}),!0}catch{return!1}finally{q(`${l.key}:club`,!1)}}async function Ce(l,p){if(!l.club)return!1;q(`${l.key}:club`,!0);try{return await U(`/api/structure-network/locations/${p}/club`,{method:"PUT",data:{club_id:l.club.id}}),await Y(l.key),b.add({title:"Club rattaché à sa location",description:l.name,icon:"heroicons:check-circle",color:"green"}),!0}catch{return!1}finally{q(`${l.key}:club`,!1)}}async function ve(l,p,E){const I=l.club?"club":"location",W=l.club?l.club.id:l.location?.id;if(!W)return!1;q(`${l.key}:ignore`,!0);try{return await U(`/api/structure-network/rows/${I}/${W}/ignore`,{method:"PUT",data:{ignored:p,reason:E}}),await Y(l.key),b.add({title:p?"Structure mise de côté":"Structure remise dans la vue",description:l.name,icon:"heroicons:check-circle",color:"green"}),!0}catch{return!1}finally{q(`${l.key}:ignore`,!1)}}async function $e(l,p,E,I){q(`${l.key}:${I}`,!0);try{return await U("/api/structure-network/relations",{method:"POST",data:{rel1:p,rel2:E,relation:I}}),await Y(l.key),!0}catch{return!1}finally{q(`${l.key}:${I}`,!1)}}async function Be(l,p){q(`${l.key}:rel-${p}`,!0);try{return await U(`/api/structure-network/relations/${p}`,{method:"DELETE"}),await Y(l.key),!0}catch{return!1}finally{q(`${l.key}:rel-${p}`,!1)}}async function pe(l){if(!V.value[l])try{const p=await U(`/api/structure-network/locations/${l}/branch`);V.value={...V.value,[l]:p}}catch{}}function Ee(l){const p=new Set(w.value);
1p.has(l.key)?p.delete(l.key):(p.add(l.key),l.location&&pe(l.location.id)),w.value=p}async function Fe(l,p){const E=new URLSearchParams({term:l});p&&E.set("exclude",String(p));try{const I=await U(`/api/structure-network/autocomplete?${E.toString()}`,{silentErrorCodes:[400,404]});return Array.isArray(I)?I:[]}catch{return[]}}async function we(l){try{const p=await U(`/api/structure-network/clubs/autocomplete?term=${encodeURIComponent(l)}`,{silentErrorCodes:[400,404]});return Array.isArray(p)?p:[]}catch{return[]}}async function Ae(l,p){try{return l?await U(`/api/structure-network/types/${l.id}`,{method:"PUT",data:p}):await U("/api/structure-network/types",{method:"POST",data:p}),await _(),b.add({title:l?"Type mis à jour":"Type créé",description:p.label,icon:"heroicons:check-circle",color:"green"}),!0}catch{return!1}}async function Se(l){try{return await U(`/api/structure-network/types/${l.id}`,{method:"DELETE"}),await _(),b.add({title:"Type supprimé",description:l.label,icon:"heroicons:check-circle",color:"green"}),!0}catch{return!1}}return{loading:r,loadingReferential:c,error:D,rows:B,total:R,pages:g,types:k,assignableTypes:P,typeByCode:G,federations:Z,alertCatalog:L,stats:y,federationStats:F,premiumDate:j,filters:d,hasFilters:ee,branches:V,expanded:w,fetchRows:O,fetchReferential:m,refresh:_,resetFilters:te,toggleType:re,toggleKind:he,sortBy:ge,isSaving:ke,setClubTypes:_e,setFederations:ue,setLink:ce,addRelation:$e,setLocationClub:de,claimLocationForClub:Ce,setIgnored:ve,deleteRelation:Be,toggleExpanded:Ee,loadBranch:pe,searchStructures:Fe,searchClubs:we,saveType:Ae,deleteType:Se}}const nn={class:"font-sans min-h-screen bg-[#ECEDF0]"},sn={class:"w-full px-4 sm:px-6 py-5"},ln={class:"flex justify-between items-start gap-4 mb-4 flex-wrap"},on={key:0,class:"text-xs text-[#888EA3] mt-1"},an={class:"flex gap-2.5 flex-wrap"},rn={key:0,class:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-6 gap-3 mb-4"},un=["title","onClick"],cn={class:"text-xs text-[#666F87]"},dn={class:"text-[11px] text-[#888EA3] mt-0.5"},pn={class:"bg-white border border-[#D9DBE1] rounded-lg p-3 mb-4 shadow-sm"},mn={class:"flex items-center justify-between mb-2"},fn={class:"flex flex-wrap gap-2"},bn={class:"opacity-70"},vn=["title","onClick"],xn={class:"opacity-70"},yn={key:0,class:"opacity-70"},hn={class:"bg-white border border-[#D9DBE1] rounded-lg p-4 mb-4 shadow-sm"},gn={class:"grid grid-cols-1 md:grid-cols-[2fr_1fr_1fr_auto] gap-3 items-end mb-3"},kn={class:"flex flex-wrap gap-3 items-start"},_n={class:"rounded-lg px-3 py-2",style:{"background-color":"#F3F3F4C2"}},Cn={class:"flex flex-wrap gap-1.5"},$n=["onClick"],Bn={class:"rounded-lg px-3 py-2 flex-1 min-w-[22rem]",style:{"background-color":"#F3F3F4C2"}},En={class:"space-y-1.5"},Fn={class:"text-[10px] uppercase tracking-wide text-[#B3B7C3] w-24 shrink-0"},wn=["title","onClick"],An={class:"rounded-lg px-3 py-2",style:{"background-color":"#F3F3F4C2"}},Sn={class:"flex flex-wrap gap-1.5"},Dn=["title","onClick"],Vn={key:0},Tn={class:"bg-white border border-[#D9DBE1] rounded-lg shadow-sm overflow-hidden"},Rn={class:"flex items-center justify-between px-4 py-2.5 border-b border-[#ECEDF0]"},Ln={class:"text-sm text-[#444B64]"},qn={class:"text-[#1B2441]"},Un={class:"flex items-center gap-2"},jn={key:0,class:"p-10 text-center text-sm text-[#888EA3]"},Pn={key:1,class:"p-10 text-center"},zn={class:"text-sm text-[#F73438] mb-4"},Mn={key:2,class:"p-10 text-center text-sm text-[#888EA3]"},On={key:3,class:"overflow-x-auto"},Nn={class:"w-full text-sm"},In={class:"bg-[#F7F8FA] text-[#666F87]"},Kn={class:"text-left font-medium px-3 py-2.5 min-w-[18rem]"},Hn={class:"text-left font-medium px-3 py-2.5 w-28"},Gn={class:"text-left font-medium px-3 py-2.5 min-w-[14rem]"},Wn={class:"text-left font-medium px-3 py-2.5 min-w-[13rem]"},Yn={class:"text-left font-medium px-3 py-2.5 min-w-[16rem]"},Jn={class:"px-1 py-2.5"},Qn=["aria-label","onClick"],Xn={class:"px-3 py-2.5"},Zn={class:"flex items-center gap-1.5 flex-wrap"},es=["title"],ts=["href","title"],ns=["href","title"],ss={key:3,class:"text-[10px] uppercase tracking-wide text-white bg-[#F73438] rounded px-1.5 py-0.5"},ls=["title"],os={key:5,class:"text-[10px] uppercase tracking-wide text-[#888EA3] border border-[#D9DBE1] rounded px-1"},as={key:6,class:"text-[10px] uppercase tracking-wide text-[#B4262A] border border-[#F7A7A9] rounded px-1"},is={class:"text-xs text-[#888EA3] mt-0.5"},rs={key:0},us={key:1},cs={key:2},ds={key:0,class:"mt-1.5 max-w-xs"}
1,ps={key:1,class:"mt-1.5 max-w-xs"},ms={class:"px-3 py-2.5"},fs=["disabled","onClick"],bs={key:0,class:"text-xs text-[#B3B7C3] group-hover:text-[#2EC07E]"},vs={key:1,class:"text-xs text-[#B3B7C3]"},xs={class:"px-3 py-2.5"},ys=["disabled","onClick"],hs={key:0,class:"text-xs text-[#B3B7C3] group-hover:text-[#2EC07E]"},gs={key:0,class:"text-[10px] text-[#888EA3] mt-0.5"},ks={class:"px-3 py-2.5"},_s={key:0,class:"min-w-0"},Cs={class:"text-[#1B2441] truncate"},$s=["href","title"],Bs={key:1,class:"text-xs text-[#B3B7C3]"},Es={key:2,class:"text-xs text-[#B3B7C3]"},Fs={key:3,class:"flex flex-wrap gap-1 mt-1"},ws=["title"],As=["title"],Ss={class:"px-3 py-2.5"},Ds={key:1,class:"text-xs text-[#B3B7C3]"},Vs={class:"px-3 py-2.5"},Ts={key:1,class:"text-xs text-[#B3B7C3]"},Rs={class:"px-3 py-2.5"},Ls={key:1,class:"text-xs text-[#B3B7C3]"},qs={class:"px-3 py-2.5"},Us={key:0,class:"flex flex-wrap gap-1"},js=["title"],Ps=["title"],zs={key:1,class:"text-xs text-[#B3B7C3]"},Ms={class:"px-3 py-2.5"},Os={key:0,class:"flex flex-col gap-1"},Ns={key:1,class:"inline-flex items-center gap-1 text-[11px] text-[#259A65]"},Is={class:"px-1 py-2.5 text-right"},Ks=["disabled","aria-label","title","onClick"],Hs={key:0,class:"border-t border-[#ECEDF0] bg-[#FAFBFC]"},Gs={colspan:"10",class:"px-3 py-3"},Ws={key:4,class:"flex items-center justify-between px-4 py-3 border-t border-[#ECEDF0]"},Ys={class:"text-xs text-[#888EA3]"},Js={class:"flex gap-2"},Qs={class:"space-y-3"},Xs={class:"flex justify-end gap-2 pt-2"},Zs={class:"space-y-3"},el={class:"text-sm text-[#444B64]"},tl={class:"flex justify-end gap-2 pt-1"},nl={class:"space-y-3"},sl={class:"flex justify-end gap-2 pt-1"},fl=ae({__name:"index",setup(b){Ye({title:"Réseau des structures"});const r=tn(),c=r.filters,D=M(()=>r.stats.value),B=Ze(),R=Je();Pe(async()=>{if(!await B.hasPermissionAsync("user.is_webmaster")){R.push("/app");return}await r.refresh()});const g=$(!1),k=$(null),L=$([]),y=$(null),F=$(""),j={"vpdive.com":"vpdive.com","www.vpdive.com":"vpdive.com",vpdive5:"vpdive5",vpdive:"vpdive",localhost:"vpdive","127.0.0.1":"vpdive"};function d(o){const t=o.club?.unique_name;if(!t||typeof window>"u")return null;const{hostname:h,port:e,protocol:u}=window.location,Ve=j[h.toLowerCase()]??"vpdive.com",Me=e?`:${e}`:"",Oe=t==="vpdive"?Ve:`${t}.${Ve}`;return`${u}//${Oe}${Me}/`}function K(o){const t=o.club?.domain;return t?/^https?:\/\//.test(t)?t:`https://${t}`:null}function V(o){if(!o)return"â";const[t]=o.split(" "),[h,e,u]=t.split("T")[0].split("-");return u&&e&&h?`${u}/${e}/${h}`:o}function w(o){const t=o.comptes>0?(o.actifs??0)/o.comptes:0;return t>=.5?{color:"#1C734C",backgroundColor:"#E6F9F0",borderColor:"#CCF3E1"}:t>=.25?{color:"#9A5612",backgroundColor:"#FFF3E6",borderColor:"#FFCB91"}:{color:"#B4262A",backgroundColor:"#FDECEC",borderColor:"#F7A7A9"}}const Z=[{value:"only",label:"Mises de côté",hint:"Ne montrer que les structures écartées, pour les relire ou les réintégrer"},{value:"all",label:"Tout, écartées comprises",hint:"Montrer la vue courante et les structures écartées ensemble"}],P=$(null),G=$([]),ee=M(()=>r.federations.value.map(o=>({value:o.code,label:o.label})));function x(o){P.value=o,G.value=o.federation_source==="inherited"?[]:[...o.federations]}async function m(){const o=P.value;o&&await r.setFederations(o,G.value)&&(P.value=null)}function O(o){y.value=o,F.value=o.ignore_reason??""}async function _(){const o=y.value;o&&await r.setIgnored(o,!0,F.value.trim()||null)&&(y.value=null)}const A=M(()=>{const o=D.value;return o?[{key:"structures",label:"Structures",value:o.structures,color:"#1B2441",hint:"Un club et sa location",active:te("structure"),apply:()=>re(["structure"])},{key:"clubs_without_location",label:"Clubs sans location",value:o.clubs_without_location,color:"#F73438",hint:"Hors du maillage",active:te("club_without_location"),apply:()=>re(["club_without_location"])},{key:"orphan_locations",label:"Locations non revendiquées",value:o.orphan_locations,color:"#888EA3",hint:"Fiches sans club",active:te("orphan_location"),apply:()=>re(["orphan_location"])},{key:"unlinked",label:"Non rattachées",value:o.unlinked,color:"#FF8822",hint:"Ni enfant ni possédée",active:c.link==="orphan",apply:()=>{c.link=c.link==="orphan"?"":"orphan"}},{key:"alerts",label:"à corriger",value:o.danger+o.warning,color:"#B4262A",hint:`${o.danger} bloquantes, ${o.warning} à vérifier`,active:c.alert==="actionable",apply:()=>{c.alert=c.alert==="actionable"?"":"actionable"}},{key:"claim_rate",label:"Taux de revendication",value:o.claim_rate===null?"â":`${o.claim_rate}%`,color:"#2EC07E",hint:`${o.structures} clubs pour ${o.locations} locations`,active:!1,apply:()=>{}}]:[]});function te(o){return c.kinds.length===1&&c.kinds[0]===o}function re(o){c.kinds=te(o[0])?["structure","club_without_location","orphan_location"]:[...o]}const he=[{value:"structure",label:"Structures"},{value:"club_without_location",label:"Clubs sans location"},{value:"orphan_location",label:"Locations non revendiquées"}],ge=[{category:"structure",label:"Maillage"},{category:"section",label:"Sections"},{category:"legal",label:"Nature"}],q=M(()=>ge.map(o=>({...o,types:r.types.value.filter(t=>t.category===o.category)})).filter(o=>o.types.length>0)),ke=M(()=>[{value:"actionable",label:"à corriger (bloquantes et à vérifier)"},{value:"any",label:"Toutes les anomalies"},{value:"danger",label:"Bloquantes"},{value:"warning",label:"à vérifier"},{value:"info",label:"Informations"},...r.alertCatalog.value.map(o=>({value:o.code,label:o.label}))]),Y=[{value:"orphan",label:"Rattachée à rien"},{value:"parent",label:"A un parent"},{value:"owner",label:"A un propriétaire"}],_e=[25,50,100,200].map(o=>({value:o,label:String(o)})),ue=M({get:()=>c.alert||null,set:o=>{c.alert=o??""}}),ce=M({get:()=>c.link||null,set:o=>{c.link=o??""}}),de=M({get:()=>c.limit,set:o=>{c.limit=Number(o)||50}});function Ce(o){return o.club?.deleted?"bg-[#FBFBFC] text-[#888EA3]":o.alert_level==="danger"?"bg-[#FFF8F8]":""}function ve(o){const t=o||"#666F87";return{color:t,borderColor:`${t}55`,backgroundColor:`${t}14`}}function $e(o){const t=en(o);return{color:t.text,backgroundColor:t.bg,borderColor:t.border}}function Be(o){return o==="danger"?"heroicons:exclamation-circle":o==="warning"?"heroicons:exclamation-triangle":"heroicons:information-circle"}function pe(o){return o>=75?{color:"#1C734C",backgroundColor:"#E6F9F0",borderColor:"#CCF3E1"}:o>=50?{color:"#9A5612",backgroundColor:"#FFF3E6",borderColor:"#FFCB91"}:{color:"#B4262A",backgroundColor:"#FDECEC",borderColor:"#F7A7A9"}}function Ee(o){const t=o.analytics,h=[];return t.coreg&&h.push({label:`${t.coreg} coreg`,hint:"Comités régionaux sous cette structure"}),t.codep&&h.push({label:`${t.codep} codep`,hint:"Comités départementaux sous cette structure"}),t.clubs&&h.push({label:`${t.clubs} clubs`,hint:"Clubs dans toute la descendance"}),t.sections&&h.push({label:`${t.sections} sections`,hint:"Commissions et mini-sites possédés"}),h.length===0&&h.push({label:`${t.descendants} rattachées`,hint:"Structures dans toute la descendance"}),h}function Fe(o){return r.typeByCode.value[o]?.short_label??o}function we(o){return r.typeByCode.value[o]?.color??null}function Ae(o){return{club:"types du club",location:"affiliation de la location",inherited:"héritée du parent"}[o.federation_source??""]??""}function Se(o){return o.parent?[o.parent,...o.extra_parents]:[]}function l(o){return o.owner?[o.owner,...o.extra_owners]:[]}async function p(){return[]}async function E(o,t){return(await r.searchStructures(o,t)).map(e=>({id:e.location_id,label:e.club_name||e.name||`Location ${e.location_id}
1`,hint:[[e.zip,e.city].filter(Boolean).join(" "),e.types.map(u=>u.short_label).join(", ")].filter(Boolean).join(" · ")||null,claimed:e.claimed}))}async function I(o){return(await r.searchStructures(o,null)).filter(h=>!h.claimed).map(h=>({id:h.location_id,label:h.name||`Location ${h.location_id}`,hint:[h.zip,h.city].filter(Boolean).join(" ")||null,claimed:!1}))}async function W(o){return(await r.searchClubs(o)).filter(h=>h.location_id===null).map(h=>({id:h.club_id,label:h.name||h.unique_name||`Club ${h.club_id}`,hint:h.unique_name,claimed:!0}))}const De=M(()=>{const o=[{category:"federation",label:"Fédérations"},{category:"structure",label:"Maillage territorial"},{category:"section",label:"Commissions et mini-sites"},{category:"legal",label:"Nature juridique"}],t=[];return o.forEach(h=>{const e=r.assignableTypes.value.filter(u=>u.category===h.category);e.length!==0&&(t.push({value:`__${h.category}`,label:h.label.toUpperCase(),disabled:!0}),e.forEach(u=>t.push({value:u.code,label:u.label})))}),t});function ne(o){k.value=o,L.value=[...o.types]}async function me(){const o=k.value;if(!o)return;const t=L.value.filter(h=>!h.startsWith("__"));await r.setClubTypes(o,t)&&(k.value=null)}return(o,t)=>{const h=ie;return a(),i("div",nn,[n("div",sn,[n("div",ln,[n("div",null,[t[33]||(t[33]=n("h1",{class:"text-xl sm:text-2xl font-bold text-[#1B2441]"},"Réseau des structures",-1)),t[34]||(t[34]=n("p",{class:"text-sm text-[#444B64] mt-1"}," Clubs, locations et rattachements : qui est enfant de qui, qui appartient à qui, et ce qui n'est relié à rien. ",-1)),s(r).premiumDate.value?(a(),i("p",on," Comptes et actifs au "+v(V(s(r).premiumDate.value))+", relevés de l'export VPDive+. ",1)):C("",!0)]),n("div",an,[f(N,{text:"Types et fédérations",icon:"heroicons:tag","icon-position":"left",variant:"outlined",color:"info",size:"md",onClick:t[0]||(t[0]=e=>g.value=!0)}),f(N,{text:"Actualiser",icon:"heroicons:arrow-path","icon-position":"left",variant:"outlined",color:"info",size:"md",onClick:t[1]||(t[1]=e=>s(r).refresh())})])]),s(D)?(a(),i("div",rn,[(a(!0),i(S,null,z(s(A),e=>(a(),i("button",{key:e.key,type:"button",class:H(["text-left bg-white border rounded-lg px-4 py-3 shadow-sm transition-colors",e.active?"border-[#1B2441] ring-1 ring-[#1B2441]":"border-[#D9DBE1] hover:border-[#B3B7C3]"]),title:e.hint,onClick:u=>e.apply()},[n("div",cn,v(e.label),1),n("div",{class:"text-2xl font-semibold mt-0.5",style:J({color:e.color})},v(e.value),5),n("div",dn,v(e.hint),1)],10,un))),128))])):C("",!0),n("div",pn,[n("div",mn,[t[35]||(t[35]=n("span",{class:"text-xs font-semibold uppercase tracking-wide text-[#666F87]"},"Fédération",-1)),n("button",{type:"button",class:"text-xs text-[#2EC07E] hover:underline",onClick:t[2]||(t[2]=e=>g.value=!0)},"Ajouter une fédération")]),n("div",fn,[n("button",{type:"button",class:H(["px-3 py-1.5 rounded-lg text-xs font-medium border transition-colors",s(c).federation===""?"border-[#1B2441] bg-[#1B2441] text-white":"border-[#D9DBE1] bg-white text-[#1B2441]"]),onClick:t[3]||(t[3]=e=>s(c).federation="")},[t[36]||(t[36]=T(" Toutes ",-1)),n("span",bn,"· "+v(s(D)?.structures??0)+" structures",1)],2),(a(!0),i(S,null,z(s(r).federationStats.value,e=>(a(),i("button",{key:e.code,type:"button",class:H(["px-3 py-1.5 rounded-lg text-xs font-medium border transition-colors text-left",s(c).federation===e.code?"border-[#1B2441] bg-[#1B2441] text-white":"border-[#D9DBE1] bg-white text-[#1B2441]"]),title:`${e.structures} structures · ${e.coreg} coreg · ${e.codep} codep · ${e.orphan_locations} locations non revendiquées`,onClick:u=>s(c).federation=s(c).federation===e.code?"":e.code},[T(v(e.label)+" ",1),n("span",xn,"· "+v(e.structures),1),e.claim_rate!==null?(a(),i("span",yn," · "+v(e.claim_rate)+"% revendiqué",1)):C("",!0)],10,vn))),128))])]),n("div",hn,[n("div",gn,[f(oe,{modelValue:s(c).search,"onUpdate:modelValue":t[4]||(t[4]=e=>s(c).search=e),label:"Rechercher",placeholder:"Nom, ville, code postal, numéro fédéralâ¦"},null,8,["modelValue"]),f(le,{modelValue:s(ue),"onUpdate:modelValue":t[5]||(t[5]=e=>X(ue)?ue.value=e:null),label:"Anomalie",options:s(ke),clearable:""},null,8,["modelValue","options"]),f(le,{modelValue:s(ce),"onUpdate:modelValue":t[6]||(t[6]=e=>X(ce)?ce.value=e:null),label:"Rattachement",options:Y,clearable:""},null,8,["modelValue"]),f(N,{text:"Réinitialiser",variant:"outlined",color:"info",size:"sm",disabled:!s(r).hasFilters.value,onClick:t[7]||(t[7]=e=>s(r).resetFilters())},null,8,["disabled"])]),n("div",kn,[n("div",_n,[t[37]||(t[37]=n("div",{class:"text-xs text-[#666F87] mb-1.5"},"Nature de la ligne",-1)),n("div",Cn,[(a(),i(S,null,z(he,e=>n("button",{key:e.value,type:"button",class:H(["px-2.5 py-1 rounded-full text-xs font-medium border transition-colors",s(c).kinds.includes(e.value)?"border-[#1B2441] bg-[#1B2441] text-white":"border-[#D9DBE1] bg-white text-[#1B2441]"]),onClick:u=>s(r).toggleKind(e.value)},v(e.label),11,$n)),64))])]),n("div",Bn,[t[38]||(t[38]=n("div",{class:"text-xs text-[#666F87] mb-1.5"},[T(" Types "),n("span",{class:"text-[#B3B7C3]"},"â la fédération se filtre au-dessus")],-1)),n("div",En,[(a(!0),i(S,null,z(s(q),e=>(a(),i("div",{key:e.category,class:"flex flex-wrap items-center gap-1.5"},[n("span",Fn,v(e.label),1),(a(!0),i(S,null,z(e.types,u=>(a(),i("button",{key:u.code,type:"button",class:H(["px-2.5 py-1 rounded-full text-xs font-medium border transition-colors",s(c).types.includes(u.code)?"border-[#1B2441] bg-[#1B2441] text-white":"border-[#D9DBE1] bg-white text-[#1B2441]"]),title:u.label,onClick:Ve=>s(r).toggleType(u.code)},v(u.short_label),11,wn))),128))]))),128))])]),n("div",An,[t[39]||(t[39]=n("div",{class:"text-xs text-[#666F87] mb-1.5"},"Périmètre",-1)),n("div",Sn,[n("button",{type:"button",class:H(["px-2.5 py-1 rounded-full text-xs font-medium border transition-colors",s(c).includeDeleted?"border-[#444B64] bg-[#444B64] text-white":"border-[#D9DBE1] bg-white text-[#1B2441]"]),title:"Montrer aussi les clubs supprimés qui gardent une location. Ceux qui n'en ont plus ne sont jamais listés : il n'y a plus rien à y piloter.",onClick:t[8]||(t[8]=e=>s(c).includeDeleted=!s(c).includeDeleted)},"Clubs supprimés",2),(a(),i(S,null,z(Z,e=>n("button",{key:e.value,type:"button",class:H(["px-2.5 py-1 rounded-full text-xs font-medium border transition-colors",s(c).ignored===e.value?"border-[#444B64] bg-[#444B64] text-white":"border-[#D9DBE1] bg-white text-[#1B2441]"]),title:e.hint,onClick:u=>s(c).ignored=s(c).ignored===e.value?"hide":e.value},[T(v(e.label),1),e.value!=="hide"&&s(D)?.ignored?(a(),i("span",Vn," · "+v(s(D).ignored),1)):C("",!0)],10,Dn)),64))])])])]),n("div",Tn,[n("div",Rn,[n("span",Ln,[n("strong",qn,v(s(r).total.value),1),T(" "+v(s(r).total.value>1?"lignes":"ligne"),1)]),n("div",Un,[t[40]||(t[40]=n("span",{class:"text-xs text-[#888EA3]"},"Par page",-1)),f(le,{modelValue:s(de),"onUpdate:modelValue":t[9]||(t[9]=e=>X(de)?de.value=e:null),options:s(_e),class:"w-24"},null,8,["modelValue","options"])])]),s(r).loading.value?(a(),i("div",jn," Chargement du réseau⦠")):s(r).error.value?(a(),i("div",Pn,[n("p",zn,v(s(r).error.value),1),f(N,{text:"Réessayer",variant:"outlined",color:"danger",size:"sm",onClick:t[10
1]||(t[10]=e=>s(r).fetchRows())})])):s(r).rows.value.length===0?(a(),i("div",Mn," Aucune structure ne correspond à ces filtres. ")):(a(),i("div",On,[n("table",Nn,[n("thead",In,[n("tr",null,[t[46]||(t[46]=n("th",{class:"w-8"},null,-1)),n("th",Kn,[n("button",{type:"button",class:"hover:text-[#1B2441]",onClick:t[11]||(t[11]=e=>s(r).sortBy("name"))},[t[41]||(t[41]=T(" Structure ",-1)),f(fe,{column:"name",sort:s(c).sort,direction:s(c).direction},null,8,["sort","direction"])])]),t[47]||(t[47]=n("th",{class:"text-left font-medium px-3 py-2.5 min-w-[13rem]"},"Types",-1)),n("th",Hn,[n("button",{type:"button",class:"hover:text-[#1B2441]",onClick:t[12]||(t[12]=e=>s(r).sortBy("federation"))},[t[42]||(t[42]=T(" Fédé ",-1)),f(fe,{column:"federation",sort:s(c).sort,direction:s(c).direction},null,8,["sort","direction"])])]),n("th",Gn,[n("button",{type:"button",class:"hover:text-[#1B2441]",onClick:t[13]||(t[13]=e=>s(r).sortBy("accounts"))},[t[43]||(t[43]=T(" Responsable & comptes ",-1)),f(fe,{column:"accounts",sort:s(c).sort,direction:s(c).direction},null,8,["sort","direction"])])]),t[48]||(t[48]=n("th",{class:"text-left font-medium px-3 py-2.5 min-w-[14rem]"},"Enfant de",-1)),t[49]||(t[49]=n("th",{class:"text-left font-medium px-3 py-2.5 min-w-[14rem]"},"Appartient à ",-1)),t[50]||(t[50]=n("th",{class:"text-left font-medium px-3 py-2.5 min-w-[11rem]"},"Autres liens",-1)),n("th",Wn,[n("button",{type:"button",class:"hover:text-[#1B2441]",onClick:t[14]||(t[14]=e=>s(r).sortBy("children"))},[t[44]||(t[44]=T(" Réseau ",-1)),f(fe,{column:"children",sort:s(c).sort,direction:s(c).direction},null,8,["sort","direction"])])]),n("th",Yn,[n("button",{type:"button",class:"hover:text-[#1B2441]",onClick:t[15]||(t[15]=e=>s(r).sortBy("alerts"))},[t[45]||(t[45]=T(" Alertes ",-1)),f(fe,{column:"alerts",sort:s(c).sort,direction:s(c).direction},null,8,["sort","direction"])])]),t[51]||(t[51]=n("th",{class:"w-10"},null,-1))])]),n("tbody",null,[(a(!0),i(S,null,z(s(r).rows.value,e=>(a(),i(S,{key:e.key},[n("tr",{class:H(["border-t border-[#ECEDF0] align-top",Ce(e)])},[n("td",Jn,[e.location?(a(),i("button",{key:0,type:"button",class:"text-[#B3B7C3] hover:text-[#1B2441]","aria-label":`Déplier ${e.name}`,onClick:u=>s(r).toggleExpanded(e)},[f(h,{name:s(r).expanded.value.has(e.key)?"heroicons:chevron-down":"heroicons:chevron-right",class:"w-4 h-4"},null,8,["name"])],8,Qn)):C("",!0)]),n("td",Xn,[n("div",Zn,[e.club?(a(),i("span",{key:0,class:"w-2 h-2 rounded-full shrink-0",style:J({backgroundColor:e.club.deleted?"#F73438":"#2EC07E"}),title:e.club.deleted?"Site supprimé":"Site en service"},null,12,es)):C("",!0),n("span",{class:H(["font-medium",e.club?.deleted?"text-[#B4262A] line-through":"text-[#1B2441]"])},v(e.name||"Sans nom"),3),d(e)?(a(),i("a",{key:1,href:d(e),target:"_blank",rel:"noopener",class:"text-[#B3B7C3] hover:text-[#2EC07E]",title:`Ouvrir ${d(e)} dans un nouvel onglet`,onClick:t[16]||(t[16]=Re(()=>{},["stop"]))},[f(h,{name:"heroicons:arrow-top-right-on-square",class:"w-3.5 h-3.5"})],8,ts)):C("",!0),K(e)?(a(),i("a",{key:2,href:K(e),target:"_blank",rel:"noopener",class:"text-[#B3B7C3] hover:text-[#2EC07E]",title:`Domaine propre : ${e.club?.domain}`,onClick:t[17]||(t[17]=Re(()=>{},["stop"]))},[f(h,{name:"heroicons:globe-alt",class:"w-3.5 h-3.5"})],8,ns)):C("",!0),e.club?.deleted?(a(),i("span",ss,"Supprimé"+v(e.club.deleted_at?" le "+V(e.club.deleted_at):""),1)):C("",!0),e.ignored?(a(),i("span",{key:4,class:"text-[10px] uppercase tracking-wide text-[#444B64] bg-[#ECEDF0] border border-[#D9DBE1] rounded px-1.5 py-0.5",title:e.ignore_reason||"Mise de côté"},"Mise de côté",8,ls)):C("",!0),e.kind==="orphan_location"?(a(),i("span",os,"Location seule")):C("",!0),e.kind==="club_without_location"?(a(),i("span",as,"Club sans location")):C("",!0)]),n("div",is,[e.zip||e.city?(a(),i("span",rs,v([e.zip,e.city].filter(Boolean).join(" ")),1)):C("",!0),e.location?.ffessm_nbr?(a(),i("span",us," · n° "+v(e.location.ffessm_nbr),1)):C("",!0),e.club?.unique_name?(a(),i("span",cs," · "+v(e.club.unique_name),1)):C("",!0)]),e.kind==="orphan_location"?(a(),i("div",ds,[f(Le,{current:null,disabled:s(r).isSaving(`${e.key}:club`),placeholder:"Rattacher à un clubâ¦",fetcher:u=>W(u),onSelect:u=>
1u&&s(r).setLocationClub(e,u.id)},null,8,["disabled","fetcher","onSelect"])])):e.kind==="club_without_location"?(a(),i("div",ps,[f(Le,{current:null,disabled:s(r).isSaving(`${e.key}:club`),placeholder:"Lui donner une locationâ¦",fetcher:u=>I(u),onSelect:u=>u&&s(r).claimLocationForClub(e,u.id)},null,8,["disabled","fetcher","onSelect"])])):C("",!0)]),n("td",ms,[e.club?(a(),i("button",{key:0,type:"button",class:"flex flex-wrap gap-1 text-left min-h-[1.5rem] w-full group",disabled:s(r).isSaving(`${e.key}:types`),title:"Modifier les types",onClick:u=>ne(e)},[(a(!0),i(S,null,z(e.type_badges,u=>(a(),i("span",{key:u.code,class:"px-1.5 py-0.5 rounded text-[11px] font-medium border",style:J(ve(u.color))},v(u.short_label),5))),128)),e.type_badges.length===0?(a(),i("span",bs,"Aucun type â en ajouter")):C("",!0),f(h,{name:"heroicons:pencil-square",class:"w-3.5 h-3.5 text-transparent group-hover:text-[#B3B7C3] self-center"})],8,fs)):(a(),i("span",vs,"â"))]),n("td",xs,[n("button",{type:"button",class:"flex flex-wrap gap-1 text-left min-h-[1.5rem] w-full group",disabled:s(r).isSaving(`${e.key}:federations`),title:"Modifier les fédérations",onClick:u=>x(e)},[(a(!0),i(S,null,z(e.federations,u=>(a(),i("span",{key:u,class:"px-1.5 py-0.5 rounded text-[11px] font-medium border",style:J(ve(we(u)))},v(Fe(u)),5))),128)),e.federations.length===0?(a(),i("span",hs,"Aucune â en ajouter")):C("",!0),f(h,{name:"heroicons:pencil-square",class:"w-3.5 h-3.5 text-transparent group-hover:text-[#B3B7C3] self-center"})],8,ys),e.federation_source?(a(),i("div",gs,v(Ae(e)),1)):C("",!0)]),n("td",ks,[e.club?.owner?(a(),i("div",_s,[n("div",Cs,v(e.club.owner.name||"Sans nom"),1),e.club.owner.email?(a(),i("a",{key:0,href:`mailto:${e.club.owner.email}`,class:"text-xs text-[#666F87] hover:text-[#2EC07E] truncate block",title:e.club.owner.email},v(e.club.owner.email),9,$s)):C("",!0)])):e.club?(a(),i("div",Bs,"Aucun propriétaire")):(a(),i("div",Es,"â")),e.premium?(a(),i("div",Fs,[n("span",{class:"px-1.5 py-0.5 rounded text-[11px] font-medium bg-[#F1F2F5] text-[#444B64] border border-[#E3E5EA]",title:`${e.premium.comptes_membres} membres et ${e.premium.comptes_invites} invités`},v(e.premium.comptes)+" comptes",9,ws),e.premium.actifs!==null?(a(),i("span",{key:0,class:"px-1.5 py-0.5 rounded text-[11px] font-medium border",style:J(w(e.premium)),title:`Comptes connectés depuis moins d'un mois${s(r).premiumDate.value?" â relevé du "+V(s(r).premiumDate.value):""}`},v(e.premium.actifs)+" actifs",13,As)):C("",!0)])):C("",!0)]),n("td",Ss,[e.location?(a(),Q(be,{key:0,links:Se(e),disabled:s(r).isSaving(`${e.key}:parent`),placeholder:"Ajouter un parentâ¦",fetcher:u=>E(u,e.location.id),onAdd:u=>s(r).addRelation(e,u.id,e.location.id,"parent"),onRemove:u=>s(r).deleteRelation(e,u)},null,8,["links","disabled","fetcher","onAdd","onRemove"])):(a(),i("span",Ds,"Pas de location"))]),n("td",Vs,[e.location?(a(),Q(be,{key:0,links:l(e),disabled:s(r).isSaving(`${e.key}:owner`),placeholder:"Ajouter un propriétaireâ¦",fetcher:u=>E(u,e.location.id),onAdd:u=>s(r).addRelation(e,u.id,e.location.id,"owner"),onRemove:u=>s(r).deleteRelation(e,u)},null,8,["links","disabled","fetcher","onAdd","onRemove"])):(a(),i("span",Ts,"Pas de location"))]),n("td",Rs,[e.other_relations.length?(a(),Q(be,{key:0,links:e.other_relations,"allow-add":!1,fetcher:p,onRemove:u=>s(r).deleteRelation(e,u)},null,8,["links","onRemove"])):(a(),i("span",Ls,"â"))]),n("td",qs,[e.analytics.descendants>0?(a(),i("div",Us,[(a(!0),i(S,null,z(Ee(e),u=>(a(),i("span",{key:u.label,class:"px-1.5 py-0.5 rounded text-[11px] font-medium bg-[#F1F2F5] text-[#444B64] border border-[#E3E5EA]",title:u.hint},v(u.label),9,js))),128)),e.analytics.claim_rate!==null?(a(),i("span",{key:0,class:"px-1.5 py-0.5 rounded text-[11px] font-semibold border",style:J(pe(e.analytics.claim_rate)),title:`${e.analytics.locations_claimed} des ${e.analytics.locations} locations rattachées sont revendiquées par un club`},v(e.analytics.claim_rate)+"% revendiqué",13,Ps)):C("",!0)])):(a(),i("span",zs,"â"))]),n("td",Ms,[e.alerts.length?(a(),i("div",Os,[(a(!0),i(S,null,z(e.alerts,u=>(a(),i("span",{key:u.code,class:"inline-flex items-start gap-1 text-[11px] leading-snug px-1.5 py-0.5 rounded border",style:J($e(u.level))},[f(h,{name:Be(u.level),class:"w-3 h-3 mt-[1px] shrink-0"},null,8,["name"]),T(" "+v(u.message),1)],4))),128))])):(a(),i("span",Ns,[f(h,{name:"heroicons:check-circle",class:"w-3.5 h-3.5"}),t[52]||(t[52]=T(" Conforme ",-1))]))]),n("td",Is,[n("button",{type:"button",class:"text-[#B3B7C3] hover:text-[#1B2441] disabled:opacity-40",disabled:s(r).isSaving(`${e.key}:ignore`),"aria-label":e.ignored?`Remettre ${e.name} dans la vue`:`Mettre ${e.name} de côté`,title:e.ignored?e.ignore_reason?`Mise de côté : ${e.ignore_reason}`:"Mise de côté":"Mettre cette structure de côté",onClick:u=>e.ignored?s(r).setIgnored(e,!1,null):O(e)},[f(h,{name:e.ignored?"heroicons:eye":"heroicons:eye-slash",class:"w-4 h-4"},null,8,["name"])],8,Ks)])],2),e.location&&s(r).expanded.value.has(e.key)?(a(),i("tr",Hs,[t[53]||(t[53]=n("td",null,null,-1)),n("td",Gs,[f(Xt,{branch:s(r).branches.value[e.location.id],disabled:s(r).isSaving(`${e.key}:parent`)||s(r).isSaving(`${e.key}:owner`),fetcher:u=>E(u,e.location.id),onAdd:u=>s(r).addRelation(e,e.location.id,u.targetId,u.relation),onRemove:u=>s(r).deleteRelation(e,u)},null,8,["branch","disabled","fetcher","onAdd","onRemove"])])])):C("",!0)],64))),128))])])])),s(r).pages.value>1?(a(),i("div",Ws,[n("span",Ys,"Page "+v(s(c).page)+" sur "+v(s(r).pages.value),1),n("div",Js,[f(N,{text:"Précédente",variant:"outlined",color:"info",size:"sm",disabled:s(c).page<=1,onClick:t[18]||(t[18]=e=>s(c).page=s(c).page-1)},null,8,["disabled"]),f(N,{text:"Suivante",variant:"outlined",color:"info",size:"sm",disabled:s(c).page>=s(r).pages.value,onClick:t[19]||(t[19]=e=>s(c).page=s(c).page+1)},null,8,["disabled"])])])):C("",!0)])]),f(ye,{"model-value":s(k)!==null,title:`Types de « ${s(k)?.name??""} »`,size:"lg","onUpdate:modelValue":t[23]||(t[23]=e=>{e||(k.value=null)})},{default:xe(()=>[n("div",Qs,[t[54]||(t[54]=n("p",{class:"text-sm text-[#444B64]"}," Le type dit à quel échelon se situe la structure et à quelle fédération elle appartient. C'est lui qui détermine les rattachements que l'écran considère comme cohérents. ",-1)),f(le,{modelValue:s(L),"onUpdate:modelValue":t[20]||(t[20]=e=>X(L)?L.value=e:null),label:"Types",options:s(De),multiple:"","can-search":""},null,8,["modelValue","options"]),n("div",Xs,[f(N,{text:"Annuler",variant:"outlined",color:"info",size:"sm",onClick:t[21]||(t[21]=e=>k.value=null)}),f(N,{text:"Enregistrer",color:"primary",size:"sm",onClick:t[22]||(t[22]=e=>me())})])])]),_:1},8,["model-value","title"]),f(ye,{"model-value":s(P)!==null,title:`Fédérations de « ${s(P)?.name??""} »`,size:"md","onUpdate:modelValue":t[27]||(t[27]=e=>{e||(P.value=null)})},{default:xe(()=>[n("div",Zs,[n("p",el,[t[55]||(t[55]=T(" Une structure peut relever de plusieurs fédérations à la fois â un club affilié FFESSM et FCD en déclare deux. ",-1)),s(P)?.club?(a(),i(S,{key:0},[T(" Elles sont enregistrées avec les types du club ; le reste de ses types n'est pas touché. ")],64)):(a(),i(S,{key:1},[T(" Cette fiche n'a pas de club : elles sont enregistrées sur son affiliation. ")],64))]),f(le,{modelValue:s(G),"onUpdate:modelValue":t[24]||(t[24]=e=>X(G)?G.value=e:null),label:"Fédérations",options:s(ee),multiple:"",clearable:""},null,8,["modelValue","options"]),n("div",tl,[f(N,{text:"Annuler",variant:"outlined",color:"info",size:"sm",onClick:t[25]||(t[25]=e=>P.value=null)}),f(N,{text:"Enregistrer",color:"primary",size:"sm",onClick:t[26]||(t[26]=e=>m())})])])]),_:1},8,["model-value","title"]),f(ye,{"model-value":s(y)!==null,title:`Mettre « ${s(y)?.name??""} » de côté`,size:"md","onUpdate:modelValue":t[31]||(t[31]=e=>{e||(y.value=null)})},{default:xe(()=>[n("div",nl,[t[56]||(t[56]=n("p",{class:"text-sm text-[#444B64]"}," La structure sortira du tableau et de tous les compteurs. Rien n'est modifié de ce qu'elle décrit â ni son club, ni sa location, ni ses rattachements. ",-1)),f(oe,{modelValue:s(F),"onUpdate:modelValue":t[28]||(t[28]=e=>X(F)?F.value=e:null),label:"Motif",placeholder:"Club de démonstration, doublon connu, fiche à archiverâ¦",help:"Facultatif, mais c'est lui qui rendra la décision lisible dans six mois."},null,8,["modelValue"]),n("div",sl,[f(N,{text:"Annuler",variant:"outlined",color:"info",size:"sm",onClick:t[29]||(t[29]=e=>y.value=null)}),f(N,{text:"Mettre de côté",color:"primary",size:"sm",onClick:t[30]||(t[30]=e=>_())})])])]),_:1},8,["model-value","title"]),f(Tt,{modelValue:s(g),"onUpdate:modelValue":t[32]||(t[32]=e=>X(g)?g.value=e:null),types:s(r).types.value,"save-type":s(r).saveType,"delete-type":s(r).deleteType},null,8,["modelValue","types","save-type","delete-type"]),f(Qe)])}}});
1export{fl 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.