import{U as e}from"./protobuf.DC2L68b9.js";import{t}from"./sortBy.BN5z75-Y.js";var n=-1/0,r=1/0,i=-.005,a=-.005,o=-.01,s=.9,c=.8,l=.7,u=.6;function d(e){return e.toLowerCase()===e}function f(e){return e.toUpperCase()===e}function p(e){let t=e.length,n=Array(t),r=`/`;for(let i=0;i<t;i++){let t=e[i];r===`/`?n[i]=s:r===`-`||r===`_`||r===` `?n[i]=c:r===`.`?n[i]=u:d(r)&&f(t)?n[i]=l:n[i]=0,r=t}return n}function m(e,t,r,s,c=!1){let l=e.length,u=t.length,d=c?e:e.toLowerCase(),f=c?t:t.toLowerCase(),m=p(t);for(let e=0;e<l;e++){r[e]=Array(u),s[e]=Array(u);let t=n,c=e===l-1?a:o;for(let a=0;a<u;a++)if(d[e]===f[a]){let o=n;e?a&&(o=Math.max(s[e-1][a-1]+m[a],r[e-1][a-1]+1)):o=a*i+m[a],r[e][a]=o,s[e][a]=t=Math.max(o,t+c)}else r[e][a]=n,s[e][a]=t+=c}}function h(e,t,i=!1){let a=e.length,o=t.length;if(!a||!o)return n;if(e===t||!i&&o===a)return r;if(o>1024)return n;let s=Array(a),c=Array(a);return m(e,t,s,c,i),c[a-1][o-1]}function g(e,t){e=e.toLowerCase(),t=t.toLowerCase();let n=e.length;for(let r=0,i=0;r<n;r+=1)if(i=t.indexOf(e[r],i)+1,i===0)return!1;return!0}var _=e=>e.toLowerCase();function v(t){return t??e.SelectWidgetFilterMode.FILTER_MODE_FUZZY}function y(e,n){return n?t(e.filter(e=>g(n,e.label)),e=>-h(n,e.label)):e}function b(t,n,r){if(!n||r===e.SelectWidgetFilterMode.FILTER_MODE_NONE)return t;if(r===e.SelectWidgetFilterMode.FILTER_MODE_FUZZY)return y(t,n);let i=_(n);return r===e.SelectWidgetFilterMode.FILTER_MODE_CONTAINS?t.filter(e=>_(e.label).includes(i)):r===e.SelectWidgetFilterMode.FILTER_MODE_PREFIX?t.filter(e=>_(e.label).startsWith(i)):t}export{v as n,b as t};