(function(){ 'use strict'; const normalize=value=>String(value||'').normalize('NFD').replace(/\p{M}/gu,'').toLowerCase().replace(/[٠-٩]/g,c=>String(c.charCodeAt(0)-1632)).replace(/٫/g,'.'); const groups={ categories:{ 'Real estate':['real estate','property','properties','residential','imovel','imoveis','imobiliario','inmueble','inmuebles','inmobiliario','immobilier','immobiliers','عقار','عقارات','عقاري','房地产','房产','住宅'], 'Private credit':['private credit','receivables','credit','credito','recebiveis','credito privado','credit prive','creances','الائتمان','ائتمان','ذمم','信贷','应收账款','私募信贷'], 'Treasury':['treasury','treasuries','treasury bills','tesouro','tesoro','tresor','bons du tresor','الخزانة','سندات حكومية','国债','国库券'], 'Commodities':['commodities','commodity','gold','ouro','oro','matieres premieres','黄金','大宗商品','ذهب','سلع'] }, countries:{AE:['dubai','uae','emirates','emirados','emiratos','abu dhabi','emirats','دبي','الامارات','أبوظبي','迪拜','阿联酋'],SG:['singapore','singapura','singapur','singapour','سنغافورة','新加坡'],US:['united states','usa','estados unidos','etats unis','new york','الولايات المتحدة','امريكا','美国'],HK:['hong kong','hongkong','هونغ كونغ','香港'],GB:['united kingdom','uk','reino unido','royaume uni','london','londres','بريطانيا','لندن','英国','伦敦']} }; const escape=value=>value.replace(/[.*+?^${}()|[\]\\]/g,'\\$&'); function aliasPattern(alias){return new RegExp((/^[a-z]/.test(alias)?'\\b':'')+escape(alias)+(/[a-z]$/.test(alias)?'\\b':''),'gu');} function parse(query){ let text=normalize(query),residual=text; const result={categories:[],countries:[],excludedCategories:[],excludedCountries:[],ticketCents:null,ticketMaximum:false,terms:[],unsupportedCurrency:/(?:r\$|\b(?:brl|eur|gbp|aed|sgd|hkd|cny|rmb)\b|[€£¥])/u.test(text)}; for(const [kind,values]of Object.entries(groups))for(const [value,aliases]of Object.entries(values)){ for(const alias of [...aliases].sort((a,b)=>b.length-a.length)){ const regex=aliasPattern(normalize(alias)); for(const match of text.matchAll(regex)){ const prefix=text.slice(Math.max(0,match.index-24),match.index); const excluded=/(?:\b(?:not|except|without|sem|exceto|sin|excepto|sans|hors)\s+|不要|不含|بدون\s*)$/u.test(prefix); const key=excluded?(kind==='categories'?'excludedCategories':'excludedCountries'):kind; if(!result[key].includes(value))result[key].push(value); } residual=residual.replace(regex,' '); } } const amount=text.match(/(?:us\s*\$|usd|\$|ticket\s*(?:ate|hasta|max(?:imum)?|up to)?\s*)\s*([0-9]+(?:[.,][0-9]+)*)(?:\s*(milhoes|milhao|millions?|million|millones|mil|thousand|miles|k|mi|m|万|百万))?/u); if(amount){ let raw=amount[1]; if(/^[0-9]{1,3}(?:[.,][0-9]{3})+$/.test(raw))raw=raw.replace(/[.,]/g,''); else raw=raw.replace(',','.'); const unit=amount[2]||'',factor=/^(?:mil|thousand|miles|k)$/.test(unit)?1000:/^(?:milhoes|milhao|millions?|million|millones|mi|m|百万)$/.test(unit)?1000000:unit==='万'?10000:1; const cents=Math.round(Number(raw)*factor*100); if(Number.isSafeInteger(cents)&¢s>0)result.ticketCents=cents; result.ticketMaximum=/(?:\b(?:ate|up to|under|below|maximum|hasta|moins de|jusqu|max)\b|حتى|不超过|以内)/u.test(text); residual=residual.replace(amount[0],' '); } residual=residual.replace(/我想购买|我想投资|我想买|想要|购买|投资|位于|代币化|资产|请|寻找|的|在/gu,' '); const stop=new Set('i we want would like buy buying invest investment in the a an for with and or of from show me looking please eu quero gostaria comprar investir investimento em no na nos nas o os as um uma para por com e de do da que ate ativos ativo tokenizado tokenizados renta renda dolares dolar buscar busco quiero comprar invertir en los las una del des le les la un je cherche acheter dans du au aux et pour avec jusqu moins voudrais souhaite aimerais type asset assets tokenized interest ticket to up under below maximum hasta max اريد شراء استثمار في اصول من'.split(' ')); result.terms=residual.replace(/[.,$'’]/g,' ').split(/\s+/u).filter(word=>word.length>1&&!stop.has(word)&&!/^\d+$/.test(word)); result.categories=result.categories.filter(v=>!result.excludedCategories.includes(v)); result.countries=result.countries.filter(v=>!result.excludedCountries.includes(v)); return result; } function match(offer,query){ if(!String(query||'').trim())return true; const intent=parse(query); if(intent.unsupportedCurrency)return false; if(intent.excludedCategories.includes(offer.category)||intent.excludedCountries.includes(offer.country))return false; if(intent.categories.length&&!intent.categories.includes(offer.category)||intent.countries.length&&!intent.countries.includes(offer.country))return false; if(intent.ticketCents&&(intent.ticketCentsoffer.maximumTicketCents))return false; const haystack=normalize([offer.name,offer.id,offer.city,offer.country,offer.category].join(' ')); return intent.terms.every(term=>haystack.includes(term)); } function related(offers,query,{country='',category='',excludeIds=[],limit=3,now=Date.now()}={}){ const intent=parse(query),excluded=new Set(excludeIds); if(intent.unsupportedCurrency||(!intent.categories.length&&!intent.countries.length&&!country&&!category))return []; return offers.filter(o=>!excluded.has(o.id)&&(!country||o.country===country)&&(!category||o.category===category)&& !intent.excludedCategories.includes(o.category)&&!intent.excludedCountries.includes(o.country)&& (!intent.categories.length||intent.categories.includes(o.category))&&(!intent.countries.length||intent.countries.includes(o.country))&& (!o.commercial?.endsAt||Number.isFinite(Date.parse(o.commercial.endsAt))&&Date.parse(o.commercial.endsAt)>now)) .map(offer=>{ const reasons=[]; if(intent.categories.includes(offer.category)||category===offer.category)reasons.push('sourcingSameAsset'); if(intent.countries.includes(offer.country)||country===offer.country)reasons.push('sourcingSameMarket'); if(intent.ticketCents&&(intent.ticketCentsoffer.maximumTicketCents))reasons.push('sourcingDifferentTicket'); if(intent.terms.length)reasons.push('sourcingReviewCriteria'); return {offer,reasons,score:reasons.filter(r=>r!=='sourcingDifferentTicket'&&r!=='sourcingReviewCriteria').length}; }).sort((a,b)=>b.score-a.score||a.offer.id.localeCompare(b.offer.id)).slice(0,Math.max(0,Math.min(6,limit))); } function explore(offers,query,{country='',category='',limit=3,now=Date.now()}={}){ const intent=parse(query); return offers.filter(o=>(!country||o.country===country)&&(!category||o.category===category)&& !intent.excludedCategories.includes(o.category)&&!intent.excludedCountries.includes(o.country)&& !['reconciled','cancelled','expired','rejected'].includes(o.stage)&& (!o.commercial?.endsAt||Number.isFinite(Date.parse(o.commercial.endsAt))&&Date.parse(o.commercial.endsAt)>now)) .sort((a,b)=>{ const score=o=>4*Number(intent.categories.includes(o.category))+4*Number(intent.countries.includes(o.country))+Number(!!o.commercial); return score(b)-score(a)||a.id.localeCompare(b.id); }).slice(0,Math.max(0,Math.min(6,limit))); } let recognition=null; function startVoice({lang,onText,onStatus,confirmConsent}){ const Speech=window.SpeechRecognition||window.webkitSpeechRecognition; if(!Speech){onStatus('searchVoiceUnavailable');return;} if(recognition){recognition.stop();return;} if(!confirmConsent()){onStatus('searchVoiceCancelled');return;} try{ recognition=new Speech();recognition.lang={en:'en-US',pt:'pt-BR',es:'es-ES',fr:'fr-FR',ar:'ar-AE',zh:'zh-CN'}[lang]||'en-US'; recognition.continuous=false;recognition.interimResults=false; recognition.onstart=()=>onStatus('searchListening'); recognition.onresult=event=>{const text=event.results?.[0]?.[0]?.transcript;if(text?.trim())onText(text.trim().slice(0,100));}; recognition.onerror=event=>onStatus(['not-allowed','service-not-allowed','permission-denied'].includes(event.error)?'searchVoiceDenied':'searchVoiceFailed'); recognition.onend=()=>{recognition=null;}; recognition.start(); }catch(_){recognition=null;onStatus('searchVoiceFailed');} } const stopVoice=()=>{if(recognition){recognition.abort();recognition=null;}}; window.addEventListener?.('pagehide',stopVoice); window.GlemoSearch={parse,match,related,explore,startVoice,stopVoice}; })();