function o(o){return!!o&&"object"==typeof o&&"group"===o.type&&Array.isArray(o.options)}function n(n){if(!Array.isArray(n))return!1;for(const t of n)if(o(t))return!0;return!1}function t(n){let r=0;for(const i of n.options)o(i)?r+=t(i):r+=1;return r}function r(n){const r=[],i=(n,e,f)=>{for(const u of n)o(u)?(r.push({kind:"header",id:u.id,label:u.label,prefix:u.prefix,depth:e,optionCount:t(u)}),i(u.options,e+1,[...f,u.id])):r.push({kind:"option",item:u,depth:e,parentIds:f})};return i(Array.isArray(n)?n:[],0,[]),r}function i(o){const n=[];for(const t of o)"option"===t.kind&&n.push(t);return n}function e(n,e,f){const u=(e||"").trim().toLowerCase();if(!u){const o=r(n);return{rows:o,visibleOptionCount:i(o).length}}const s=(n,t)=>{if(o(n)){const o=n.label.toLowerCase().includes(u)||t,r=[];for(const t of n.options){const n=s(t,o);n&&r.push(n)}return 0!==r.length||o?{kind:"group",group:n,children:r}:null}return t||(o=>(f(o)||"").toString().toLowerCase().includes(u))(n)?{kind:"option",item:n}:null},c=[];for(const o of n){const n=s(o,!1);n&&c.push(n)}const p=[],d=(o,n,r)=>{for(const i of o)i&&("group"===i.kind?(p.push({kind:"header",id:i.group.id,label:i.group.label,prefix:i.group.prefix,depth:n,optionCount:t(i.group)}),d(i.children,n+1,[...r,i.group.id])):p.push({kind:"option",item:i.item,depth:n,parentIds:r}))};return d(c,0,[]),{rows:p,visibleOptionCount:i(p).length}}export{e as a,r as f,i as g,n as h};
