1import{d as I}from"./fr3g8E3O.js";import{r as T}from"./CJSe-VKO.js";import{H as D,aC as N,x as M,E as _,M as z}from"./h9yQLS9B.js";const b=new Uint32Array(65536),E=(l,s)=>{const i=l.length,d=s.length,u=1<<i-1;let t=-1,o=0,m=i,n=i;for(;n--;)b[l.charCodeAt(n)]|=1<<n;for(n=0;n<d;n++){let c=b[s.charCodeAt(n)];const p=c|o;c|=(c&t)+t^t,o|=~(c|t),t&=c,o&u&&m++,t&u&&m--,o=o<<1|1,t=t<<1|~(p|o),o&=p}for(n=i;n--;)b[l.charCodeAt(n)]=0;return m},F=(l,s)=>{const i=s.length,d=l.length,u=[],t=[],o=Math.ceil(i/32),m=Math.ceil(d/32);for(let e=0;e<o;e++)t[e]=-1,u[e]=0;let n=0;for(;n<m-1;n++){let e=0,h=-1;const y=n*32,v=Math.min(32,d)+y;for(let r=y;r<v;r++)b[l.charCodeAt(r)]|=1<<r;for(let r=0;r<i;r++){const A=b[s.charCodeAt(r)],x=t[r/32|0]>>>r&1,C=u[r/32|0]>>>r&1,L=A|e,$=((A|C)&h)+h^h|A|C;let S=e|~($|h),q=h&$;S>>>31^x&&(t[r/32|0]^=1<<r),q>>>31^C&&(u[r/32|0]^=1<<r),S=S<<1|x,q=q<<1|C,h=q|~(L|S),e=S&L}for(let r=y;r<v;r++)b[l.charCodeAt(r)]=0}let c=0,p=-1;const a=n*32,g=Math.min(32,d-a)+a;for(let e=a;e<g;e++)b[l.charCodeAt(e)]|=1<<e;let f=d;for(let e=0;e<i;e++){const h=b[s.charCodeAt(e)],y=t[e/32|0]>>>e&1,v=u[e/32|0]>>>e&1,r=h|c,A=((h|v)&p)+p^p|h|v;let x=c|~(A|p),C=p&A;f+=x>>>d-1&1,f-=C>>>d-1&1,x>>>31^y&&(t[e/32|0]^=1<<e),C>>>31^v&&(u[e/32|0]^=1<<e),x=x<<1|y,C=C<<1|v,p=C|~(r|x),c=x&r}for(let e=a;e<g;e++)b[l.charCodeAt(e)]=0;return f},W=(l,s)=>{if(l.length<s.length){const i=s;s=l,l=i}return s.length===0?l.length:l.length<=32?E(l,s):F(l,s)},P="https://api-adresse.data.gouv.fr/search/",R=(l,s,i=null,d=M(!1))=>{const u=M([]);D(l,o=>{u.value=[],o&&o.length>3&&s&&s.value==="France"&&d.value&&N(()=>{$fetch(`${P}?q=${o}&type=housenumber&autocomplete=true`).then(m=>{u.value=m.features.splice(0,4)}).catch(()=>{_.new({type:"alert",text:"Une erreur est survenue.",delay:3e3})})})});const t=z(()=>{if(u.value.length===0||!s?.value||s.value!=="France"||!d.value)return!1;if(u.value.length===1&&i?.value){const o=u.value[0],m=i.value.ADRESSE_PRINCIPAL_1,n=i.value.CODE_POSTAL_PRINCIPAL,c=i.value.COMMUNE_PRINCIPAL;if(`${m} ${n} ${c}`.toLowerCase()===o.properties.label.toLowerCase())return!1}return!0});return{dataAddressesAutocomplete:u,isShowAutocomplete:t}},U=l=>{const s=M([]),i=t=>t.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[-']/g," ").replace(/\s+/g," ").trim(),d=(t,o)=>{const m=i(t),n=i(o);if(m.includes(n))return 0;if(n.length<=3)return 1/0;const c=m.split(" "),p=n.split(" ");let a=1/0;for(const g of p)if(!(g.length<=3))for(const f of c){const e=W(g,f),h=Math.floor(g.length/4);e<=h&&e<=2&&(a=Math.min(a,e))}return a},u=({items:t,query:o,nameField:m,slugField:n,type:c,limit:p})=>t.map(a=>{const g=d(a[m],o),f=n?d(a[n]||"",o):1/0,e=Math.min(g,f);return{...a,score:e}}).filter(a=>a.score!==1/0).sort((a,g)=>a.score-g.score).slice(0,p).map(a=>({...a,type:c,delegationType:c,...c==="region"&&{number:""}}));return D(l,t=>{s.value=[],!(!t||t.length<=3)&&N(()=>{const o=u({items:T,query:t,nameField:"name",slugField:"slug",type:"region",limit:3}),m=u({items:I,query:t,nameField:"name",slugField:"slugDepartment",type:"department",limit:4});$fetch(`${P}?q=${t}&autocomplete=true`).then(n=>{const c=[],p=new Set;n.features.filter(f=>f.properties.type==="municipality").slice(0,4).forEach(f=>{const e=f.properties.postcode,h=e.startsWith("97")?e.substr(0,3):e.substr(0,2),y=I.find(v=>v.number===h);if(y&&!p.has(h)&&(c.push({...y,type:"department",delegationType:"department"}),p.add(h),h==="75")){const v=I.find(A=>A.number==="751"),r=I.find(A=>A.number==="75A");v&&c.push({...v,type:"department",delegationType:"department"}),r&&c.push({...r,type:"department",delegationType:"department"})}});const a=new Set(m.map(f=>f.number)),g=c.filter(f=>!a.has(f.number));s.value=[...o,...m,...g].slice(0,6)}).catch(()=>{s.value=[...o,...m].slice(0,6)})})},{immediate:!0}),s};export{R as a,U as u};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.