import{K as d}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89265.js";import{c as g}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89262.js";import{s as u}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c892643.js";const L=g((o,c)=>({labels:[],setLabels:e=>{o({labels:e}),c().setOrganizedLabels(e,d.getState().orderLabels)},organizedLabels:[],setOrganizedLabels:(e,s)=>{const a=[...e];a.sort((r,n)=>s.indexOf(r.id)-s.indexOf(n.id)),o({organizedLabels:a})},orderLabels:e=>{const{orderLabels:s,setOrderLabels:a}=d.getState();c().setLabels(e);const r=e.length,n=new Set;for(let t=0;t<r;t++)n.add(e[t].id);const f=new Set(s),l=[];let b=!1;for(let t=0;t<s.length;t++){const i=s[t];n.has(i)?l.push(i):b=!0}for(let t=0;t<r;t++){const i=e[t].id;f.has(i)||(l.push(i),b=!0)}b&&a(l)},onDragLabels:e=>{if(!e.destination)return;const{orderLabels:s,setOrderLabels:a}=d.getState(),r=Array.from(s),[n]=r.splice(e.source.index,1);r.splice(e.destination.index,0,n),a(r)}})),m=d.subscribe(o=>o.orderLabels,o=>{L.getState().setOrganizedLabels(L.getState().labels,o)},{equalityFn:u,fireImmediately:!0});window.addEventListener("beforeunload",()=>{m()});export{L as u};
