// @bun
var{defineProperty:K,getOwnPropertyNames:R,getOwnPropertyDescriptor:T}=Object,U=Object.prototype.hasOwnProperty;function V(A){return this[A]}var Z=(A)=>{var z=(Q??=new WeakMap).get(A),B;if(z)return z;if(z=K({},"__esModule",{value:!0}),A&&typeof A==="object"||typeof A==="function"){for(var C of R(A))if(!U.call(z,C))K(z,C,{get:V.bind(A,C),enumerable:!(B=T(A,C))||B.enumerable})}return Q.set(A,z),z},Q;var W=(A)=>A;function X(A,z){this[A]=W.bind(null,z)}var _=(A,z)=>{for(var B in z)K(A,B,{get:z[B],enumerable:!0,configurable:!0,set:X.bind(z,B)})};var $=(A,z)=>()=>(A&&(z=A(A=0)),z);var J=import.meta.require;var E=[];function N(A){E=[];for(let z of A.storyFiles)if(E.push({text:z.fileName.toLowerCase(),original:z.fileName,type:"story",storyId:z.id}),E.push({text:z.relativePath.toLowerCase(),original:z.relativePath,type:"story",storyId:z.id}),z.story)for(let B of z.story.variants)E.push({text:B.title.toLowerCase(),original:B.title,type:"story",storyId:z.id,variantId:B.id})}function O(A){for(let z of A){let B=z.name.toLowerCase().replace(/[^a-z0-9]+/g,"-");if(E.push({text:z.name.toLowerCase(),original:z.name,type:"component",storyId:B}),z.description)E.push({text:z.description.toLowerCase(),original:z.description,type:"component",storyId:B});for(let C of z.props)if(E.push({text:C.name.toLowerCase(),original:C.name,type:"prop",storyId:B,meta:{propType:C.type}}),C.description)E.push({text:C.description.toLowerCase(),original:C.description,type:"prop",storyId:B,meta:{propName:C.name}});for(let C of z.slots)E.push({text:C.name.toLowerCase(),original:C.name,type:"slot",storyId:B});if(z.tags)for(let C of z.tags)E.push({text:C.toLowerCase(),original:C,type:"component",storyId:B,meta:{tag:!0}})}}function S(A,z=20){if(!A||A.length<2)return[];let B=A.toLowerCase(),C=[],H=new Set;for(let D of E){let F=D.text.indexOf(B);if(F===-1)continue;let G=100;if(D.text===B)G+=50;if(F===0)G+=30;if(F===0||D.text[F-1]===" "||D.text[F-1]==="-")G+=20;if(D.type==="story")G+=10;if(D.type==="component")G+=5;G-=D.text.length*0.5;let P=`${D.storyId}-${D.variantId||""}-${D.type}`;if(H.has(P))continue;H.add(P),C.push({type:D.type,title:D.original,storyId:D.storyId,variantId:D.variantId,score:G,match:Y(D.original,A)})}return C.sort((D,F)=>F.score-D.score),C.slice(0,z)}function Y(A,z){let B=A.toLowerCase().indexOf(z.toLowerCase());if(B===-1)return A;let C=A.slice(0,B),H=A.slice(B,B+z.length),D=A.slice(B+z.length);return`${C}<mark>${H}</mark>${D}`}function j(){return[]}function k(){E=[]}function w(){return E.length}function L(){return JSON.stringify(E)}function b(A){try{E=JSON.parse(A)}catch{E=[]}}export{S as search,b as importSearchIndex,w as getSearchIndexSize,j as getRecentSearches,L as exportSearchIndex,k as clearSearchIndex,N as buildSearchIndex,O as buildComponentSearchIndex};
