PageSourceSearch

https://www.stock-car.pt/assets/FormPesquisaRapida-DoXVkAG5.js

js stock-car.pt collected 2026-10-04 19:33:09 UTC 5,361 bytes, 1 lines download raw bytes

1import{r as i,j as t,cG as A,x as J,E as ee,q as se,F as ae,cH as te,cI as H,ch as I,cJ as oe,l as ie,a as N,cf as $,cK as re,ca as K}from"./index-D88v5eF8.js";import{p as ne}from"./pesquisa-1ELdbObQ.js";import{S as ue}from"./pesquisar_big-xiC-EmVZ.js";import{S as le}from"./react-select.esm-CTopE9-m.js";import{F as ce}from"./Form-CjuVNTwt.js";import"./unsupportedIterableToArray-SCsxY82q.js";import"./FormControl-CNAwxP-X.js";import"./warning-Chyh3cYM.js";function pe({Array:o,onChange:a,infoJson:c,ArraySelect:e}){const[q,p]=i.useState([]),[P,d]=i.useState([]),[x,m]=i.useState(0),n=i.useCallback(u=>u.Codigo,[]),k=i.useCallback(u=>u.Nome,[]),L=u=>{const l=u||[];d(u),a(l)};i.useEffect(()=>{p(o)},[o]),i.useEffect(()=>{x===0&&q.length>0&&(d(e),m(1))},[x,q,e]);const j=()=>null,C=()=>null,T=()=>null;return t.jsx(t.Fragment,{children:x!==0&&t.jsx(le,{isMulti:!0,isClearable:!1,isSearchable:!0,options:q,value:P,placeholder:"SUV a gasóleo de 7 lugares",onChange:L,getOptionValue:n,getOptionLabel:k,openMenuOnClick:!0,blurInputOnSelect:!1,hideSelectedOptions:!0,closeMenuOnSelect:!1,filterOption:(u,l)=>{const v=u.label.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,""),r=l.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"");return v.includes(r)},noOptionsMessage:()=>"Não existe",components:{DropdownIndicator:j,IndicatorSeparator:C,ClearIndicator:T},styles:A(c)})})}const W=o=>{const a={PesquisaMarcas:[],PesquisaModelos:[],PesquisaCombustivel:[],PesquisaSegmento:[],PesquisaLotacao:[],PesquisaTransmissao:[],PesquisaExtras:[],PesquisaTitulo:[],PesquisaCombustivelText:[],PesquisaCategoria:[],PesquisaSubCategoria:[],PesquisaMarcaText:[]};return o.forEach(c=>{const e=c.Codigo.split(":");switch(e[0]){case"1":a.PesquisaExtras.push(e[1]);break;case"2":a.PesquisaMarcas.push({Id:parseInt(e[1]),Nome:c.Nome});break;case"3":a.PesquisaModelos.push({Id:parseInt(e[1]),Nome:c.Modelo});break;case"4":a.PesquisaCombustivel.push(parseInt(e[1]));break;case"5":a.PesquisaSegmento.push(parseInt(e[1]));break;case"6":a.PesquisaLotacao.push(parseInt(e[1]));break;case"7":a.PesquisaTransmissao.push(parseInt(e[1]));break;case"8":a.PesquisaTitulo.push(e[1]);break;case"9":a.PesquisaCombustivelText.push(e[1]);break;case"10":a.PesquisaCategoria.push(parseInt(e[1]));break;case"11":a.PesquisaSubCategoria.push(parseInt(e[1]));break;case"12":a.PesquisaMarcaText.push(e[1]);break}}),a};function be({Array:o,setFilteredCarros:a,tipo:c,infoJson:e,avancada:q}){const{state:p}=i.useContext(J),{marca:P,modelo:d}=ee(),x=se(),[m]=ae(),[n,k]=i.useState([]),[L,j]=i.useState([]),[C,T]=i.useState([]),[u,l]=i.useState(0),v=r=>{var _,B,Z,G;r.preventDefault();let s=new URLSearchParams;const g=E=>m.get(E),{PesquisaMarcas:b,PesquisaModelos:S,PesquisaCombustivel:f,PesquisaSegmento:h,PesquisaLotacao:M,PesquisaTransmissao:y,PesquisaExtras:O,PesquisaTitulo:R,PesquisaCombustivelText:w,PesquisaCategoria:F,PesquisaSubCategoria:V,PesquisaMarcaText:U}=W(n);f.length&&s.append("Combustivel",f),h.length&&s.append("Segmento",h),M.length&&s.append("Lotacao",M),y.length&&s.append("Transmissao",y),O.length&&s.append("Extras",O),R.length&&s.append("Titulo",R),w.length&&s.append("CombustivelText",w),F.length&&s.append("Categoria",F),V.length&&s.append("SubCategoria",V),U.length&&s.append("MarcaText",U);const X=re(o,S),D=[...b,...X],z=K(g("Order")),Q=K(g("PntVenda"));z!==""&&s.append("Order",z),Q!==""&&s.append("PntVenda",Q);const Y=`${(_=p.Zonas)!=null&&_.Layout.Carros.existe?`${(Z=(B=e.Layout)==null?void 0:B.LandingPage)!=null&&Z.existe?"/home/usadas/":"/usadas/"}`:"/viaturas/usadas/"}${D.length?`${I(D)}/`:""}${S.length?`${I(S)}/`:""}${s.toString()||n.length?"?":""}${s.toString()?`${s.toString()}`:""}${s.toString()?"&":""}${n.length?`query=${n.map(E=>E.Codigo).toString()}`:""}${(G=p.Zonas)!=null&&G.Layout.Carros.existe?"#listagem_viaturas":""}`;x(`${Y}`,{replace:!0})};return i.useEffect(()=>{const r=m.get("query"),s=m.get("Order"),g=s?parseInt(s):"";if(r){const b=r.split(",").map(h=>({Codigo:h})),S=C.filter(h=>b.some(M=>h.Codigo===M.Codigo));j(S);const f=r.split(",");te({marca:P,modelo:d},f,g,o,a,{...e,Layout:{...e.Layout,Carros:{...e.Layout.Carros,ordenar:p.tipoListagem.Carros.ordenar}}}),l(H({marca:P,modelo:d},f,o))}else l(o.filter(b=>b.Vendido===!1).length)},[m,C,a,o,e,p.tipoListagem,P,d]),i.useEffect(()=>{if(n.length){const{PesquisaMarcas:r,PesquisaModelos:s}=W(n);l(H({marca:I(r),modelo:I(s)},n.map(g=>g.Codigo),o))}else l(o.filter(r=>r.Vendido===!1).length)},[n,o]),i.useEffect(()=>{T(oe(o).sort((r,s)=>r.Nome.localeCompare(s.Nome)))},[o]),t.jsx(ce,{onSubmit:v,action:c,className:q?"d-none":"d-block",children:t.jsxs(ie,{className:"align-items-center ",children:[t.jsx(N,{xs:12,lg:3,className:`d-none  d-lg-block titulo-page ${$.titulo_nome}`,children:"Pesquise pelo nome"}),t.jsxs(N,{xs:9,sm:10,md:11,lg:8,className:`${$.barraPesquisa}`,children:[t.jsx(N,{xs:12,className:`d-block  d-lg-none ${$.titulo_nome}`,children:"Pesquise pelo nome"}),t.jsx(pe,{Array:C,onChange:k,infoJson:e,ArraySelect:L})]}),t.jsx(N,{xs:"auto",sm:1,md:1,children:t.jsx("button",{className:` btnPesquisa ${$.btnPesquisa}`,type:"submit",children:e.Layout.Carros.NumeroCarros?t.jsxs(t.Fragment,{children:[t.jsx(ue,{height:"35px",width:"35px"}),t.jsx("span",{children:u})]}):t.jsx("img",{height:"25px",width:"25px",src:ne,alt:"pesquisar"})})})]})})}export{be as default};

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.