import{n as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-C21x__mS.js";import{n}from"./iframe-GrlyTB2d.js";import{c as r,d as i,f as a,i as o,r as s,s as c}from"./defaultRenderers-Dc4yWvu_.js";import{a as l,c as u,d,i as f,l as p,n as m,r as h,s as g,t as _}from"./TreePickerBase-DPVMwILr.js";function v(e,t){let n=d(e,t),r=Object.values(n).reduce((e,t)=>e+t.length,0);if(r!==0){if(r===1){let n=[...e].sort((e,n)=>(t.preorderIndexById.get(e)??2**53-1)-(t.preorderIndexById.get(n)??2**53-1))[0],r=t.nodeById.get(n);return r?r.label:void 0}return s(r)}}function y(e,t,n){let r=p(e,n),i=p(t,n);return r.size===i.size&&[...r].every(e=>i.has(e))}function b({label:e,description:t,disabled:n,placeholder:r=`Выберите значения`,size:i,nodes:o,value:s,onChange:m,query:b,defaultQuery:C,onQuery:w,isLoading:T,error:E,optionsLayout:D=`tree`,defaultExpandedCodeKeys:O}){let[k,A]=(0,x.useState)(!1),j=(0,x.useMemo)(()=>h(o),[o]),{draftValue:M,setDraftValue:N,prepareOpen:P}=a({value:s,open:k,onCommit:m,isEqual:(e,t)=>y(e,t,j)}),F=k?M:s,I=(0,x.useMemo)(()=>p(F,j),[F,j]),L=(0,x.useMemo)(()=>l(I,j),[I,j]),R=(0,x.useMemo)(()=>new Set([...j.nodeById.keys()].filter(e=>j.nodeById.get(e)?.disabled!==!0&&!g(e,I,j)&&!L.selectedIds.has(e)&&f(j,[e]).size===0)),[I,L.selectedIds,j]),z=(0,x.useMemo)(()=>v(I,j),[I,j]);return(0,S.jsx)(_,{label:e,description:t,disabled:n,placeholder:r,size:i,nodes:o,selectedIds:L.selectedIds,partialIds:L.partialIds,selectionMode:`multi`,optionsLayout:D,defaultExpandedCodeKeys:O,unavailableNodeIds:R,open:k,onOpenChange:e=>{e&&!k&&P(),A(e)},bulkActions:{onSelectAll:()=>{N(d(f(j),j))},onDeselectAll:()=>N({})},triggerMode:`search`,selectedSummary:z?(0,S.jsx)(c,{value:z}):void 0,query:b,defaultQuery:C,onQuery:w,onNodeActivate:e=>{N(t=>u(t,e.id,j))},onClearSelection:()=>{N({}),k||m({})},isLoading:T,error:E})}var x,S;function C(){return(C=e((()=>{x=t(),r(),o(),i(),m(),S=n(),b.__docgenInfo={description:``,methods:[],displayName:`TreeMultiSelect`,props:{nodes:{required:!0,tsType:{name:`unknown`},description:``},placeholder:{required:!1,tsType:{name:`string`},description:``,defaultValue:{value:`"Выберите значения"`,computed:!1}},query:{required:!1,tsType:{name:`string`},description:``},defaultQuery:{required:!1,tsType:{name:`string`},description:``},onQuery:{required:!1,tsType:{name:`signature`,type:`function`,raw:`(value: string) => void`,signature:{arguments:[{type:{name:`string`},name:`value`}],return:{name:`void`}}},description:``},isLoading:{required:!1,tsType:{name:`boolean`},description:``},error:{required:!1,tsType:{name:`string`},description:``},optionsLayout:{required:!1,tsType:{name:`union`,raw:`"tree" | "columns"`,elements:[{name:`literal`,value:`"tree"`},{name:`literal`,value:`"columns"`}]},description:`Определяет обычное раскрываемое дерево или полностью открытый адаптивный набор колонок.`,defaultValue:{value:`"tree"`,computed:!1}},defaultExpandedCodeKeys:{required:!1,tsType:{name:`unknown`},description:"Ключи уровней, узлы которых раскрываются до ручного действия пользователя.\nВ режиме `columns` дерево по-прежнему отображается полностью раскрытым."}},composes:[`Omit`]}})))()}export{C as n,b as t};