import{K as d}from"./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a55.js";import{c as g}from"./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a52.js";import{s as u}from"./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a543.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};
