PageSourceSearch

https://www.comfama.com/portal-servicios/63c7f9c17742ee4aedf7892b451aae7895fa3867-4c36846c6c2ded079271.js

js comfama.com collected 2026-09-24 17:17:32 UTC 14,741 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunkcomfama_portalservicios_archetype=self.webpackChunkcomfama_portalservicios_archetype||[]).push([[4398],{14203:function(e,t,r){r.d(t,{OU:function(){return N},sD:function(){return O},HX:function(){return I},gD:function(){return w},FB:function(){return s},ft:function(){return P}});const s={elastic:{get baseUrl(){return""},get apiKey(){return""},indexQuery:"*,-cda_contentful_projects_ai",boostIndex:["portal_servicios_contentful_logstash"],selectedFields:["id","origin","category","title","description","tags","centrosCulturales","municipality"]},topContent:{get apiKey(){return""},docPath:"search_top_content/_doc/top_content_portal_servicios"},resultsRoute:"/resultados-busqueda/",metaIndex:{outDir:"meta",fileName:"meta-portal-servicios.json",imageWidth:{homeServicio:700}},recentSearches:{storageKey:"recent_searches",maxItems:2,icon:"icon-Search"},filterMapping:{"categorías":"tags"},mobileBreakpoint:640,seo:{title:"Portal de servicios | Resultados de búsqueda",description:"Encuentra fácilmente lo que necesitas en el Portal de Servicios de Comfama.",noIndex:!0}},o=()=>({apikeyElastic:s.elastic.apiKey,urlElastic:`${s.elastic.baseUrl}/_search?index=${s.elastic.indexQuery}`,selectedFields:s.elastic.selectedFields,boostIndex:s.elastic.boostIndex});var i=r(96540),n=r(8450),a=r(65330);function c(e){var t;const[r,s]=(0,i.useState)({result:null,isLoading:!0,errorMsg:null,currentPage:null!==(t=e.currentPage)&&void 0!==t?t:1,totalPages:0,totalResults:0}),o=(0,i.useRef)(null);return o.current||(o.current=new a.WQ(e)),(0,i.useEffect)(()=>o.current.subscribe(s),[]),(0,i.useEffect)(()=>{r.errorMsg&&console.error(`Error en hook useElasticSearch: ${r.errorMsg}`)},[r.errorMsg]),{state:r,doSearch:(e,t,r,s)=>{o.current.doSearch(e,t,r,s)},nextPage:()=>o.current.nextPage(),prevPage:()=>o.current.prevPage(),goToPage:e=>o.current.goToPage(e),reset:()=>o.current.reset()}}const{storageKey:l,maxItems:u,icon:h}=s.recentSearches,d=e=>{if(e&&"undefined"!=typeof window)try{const t=localStorage.getItem(l);let r=t?JSON.parse(t):[];r=r.filter(t=>t.value!==e),r.unshift({label:e,value:e,icon:h}),r.length>u&&(r=r.slice(0,u)),localStorage.setItem(l,JSON.stringify(r))}catch(t){console.error("Error saving search term to localStorage",t)}},f=e=>e.map(e=>{const t=e;return{id:t.id||"",title:t.title,description:t.description,icon:t.iconType,slug:t.slug,origin:t.origin}}),g=/[̀-ͯ]/g,p=e=>e.normalize("NFD").replace(g,"").trim().toLowerCase().replace(/\s+/g,"-"),m=async e=>{try{const t=await fetch(`${s.elastic.baseUrl}/${s.topContent.docPath}`,{method:"GET",headers:{Authorization:s.topContent.apiKey,"Content-Type":"application/json"},signal:e});if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);const r=await t.json();return r.found&&r._source?r._source:null}catch(t){return"AbortError"!==(null==t?void 0:t.name)&&console.error("Error fetching top content:",t),null}},y={name:"Categorías",options:[],type:"checkbox"};var b=()=>{const[e,t]=(0,i.useState)(y);return(0,i.useEffect)(()=>{const e=new AbortController;return m(e.signal).then(e=>{null!=e&&e.mainFilter&&t((e=>({...e,options:e.options.map(e=>({...e,value:e.label}))}))(e.mainFilter))}),()=>e.abort()},[]),e},v=r(74848);var w=({location:e})=>{const t=b(),[r,a]=i.useState(""),[l,u]=i.useState(!1),[h,g]=i.useState([]),{doSearch:m,state:y,goToPage:w}=c(o());i.useEffect(()=>{var t;const r=null!==(t=null==e?void 0:e.search)&&void 0!==t?t:"undefined"!=typeof window?window.location.search:"",o=new URLSearchParams(r),i=o.get("q")||o.get("search")||"";if(!i.trim())return;a(i),u(!0);const n=s.elastic.boostIndex[0];m(i,{},[{_script:{type:"number",script:{source:`return doc['_index'].value == '${n}' ? 0 : 1;`},order:"asc"}}],1)},[]);const S=f(y.result||[]);return i.useEffect(()=>{if(l){const r=(e=y.result||[],t={},e.map(e=>{var r;const s=e,o=s.urlImageCard||"",i=t[o],n=s.origin.charAt(0).toUpperCase()+s.origin.slice(1);return{title:s.title,description:s.description,image:i||o,category:n+" / "+(Array.isArray(s.category)?null===(r=s.category)||void 0===r?void 0:r[0]:s.category||""),tags:s.dynamicFields||[],slug:s.slug,origin:s.origin}}));g(r),u(!1)}var e,t},[y.result]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"cfm:max-w-7xl cfm:mx-auto cfm:px-4 cfm:pt-8",children:(0,v.jsxs)(n.o5,{variant:"h2",as:"h1",className:"cfm:text-typography",children:[r&&"Tus resultados para",r&&(0,v.jsxs)(n.o5,{variant:"h2",className:"cfm:text-primary",as:"span",children:[" ",'"',r,'"']})]})}),(0,v.jsx)(n.RP,{currentPage:y.currentPage,filters:{fields:[],selectedValues:{},hiddenFields:[]},goToPage:w,mainFilter:t,onSearch:e=>{e.trim()&&m(e,{})},searchSuggestions:S,isLoadingSuggestions:y.isLoading,onSearchFull:({query:e,selectedFilters:t,setLoading:r,currentPage:o})=>{e&&(d(e),a(e)),u(!0),r(!1);const i=[],n=[];
1t&&Object.keys(t).forEach(e=>{const r=t[e],o=s.filterMapping[e];o&&r.length>0&&(n.push({terms:{[o]:r.map(p)}}),i.push({[o]:{order:"asc",unmapped_type:"keyword"}}))});const[c]=s.elastic.boostIndex;i.push({_script:{type:"number",script:{source:`return doc['_index'].value == '${c}' ? 0 : 1;`},order:"asc"}}),m(e||"*",{filter:n},i,o)},results:h,totalPages:y.totalPages,totalResults:y.totalResults,hiddenTitle:!0})]})},S=r(64810);var x=(e=s.mobileBreakpoint)=>{const[t,r]=(0,i.useState)(!1);return(0,i.useEffect)(()=>{const t=window.matchMedia(`(max-width: ${e-1}px)`);r(t.matches);const s=e=>{r(e.matches)};return t.addEventListener("change",s),()=>t.removeEventListener("change",s)},[e]),t};var P=()=>{const[e,t]=(0,i.useState)(!1),[r,n]=(0,i.useState)(null),[a,u]=(0,i.useState)([]),h=x(),{doSearch:g,state:p}=c(o()),y=f(p.result||[]);(0,i.useEffect)(()=>{u((()=>{if("undefined"==typeof window)return[];try{const e=localStorage.getItem(l);return e?JSON.parse(e):[]}catch(e){return console.error("Error retrieving search terms from localStorage",e),[]}})())},[]),(0,i.useEffect)(()=>{m().then(e=>n(e))},[]);const b=[...a,...(null==r?void 0:r.hot_words)||[]],v=(null==r?void 0:r.most_wanted)||[],w=h?v.slice(0,3):v,P=(null==r?void 0:r.content_for_you)||[];return{isOpen:e,open:()=>t(!0),close:()=>t(!1),search:{mostSearched:w,contents:h?P.slice(0,3):P,onSearch:e=>{e.trim()&&g(e)},onSearchFull:e=>{if(e.trim()){d(e);const t=new URLSearchParams({q:e}),r=`${s.resultsRoute}?${t.toString()}`;"undefined"!=typeof window&&window.location.pathname===(0,S.withPrefix)(s.resultsRoute)?window.location.href=(0,S.withPrefix)(r):(0,S.navigate)(r)}},searchSuggestions:y,isLoadingSuggestions:p.isLoading,filters:b}}};const j={background:"transparent",border:"none",cursor:"pointer",padding:0,display:"flex",alignItems:"center",gap:"6px"},C={color:"#ffffff",fontSize:"20px"},E={color:"#ffffff",fontWeight:"bold",fontSize:"16px",whiteSpace:"nowrap"};var O=({onClick:e,showLabel:t=!1,className:r=""})=>(0,v.jsxs)("button",{type:"button",onClick:e,"aria-label":"Abrir buscador",style:j,className:r,children:[(0,v.jsx)("i",{className:"icon-Search",style:C}),t&&(0,v.jsx)("span",{style:E,children:"Buscador"})]}),_=r(30037);const T={position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9999,backgroundColor:"#ffffff",overflowY:"auto"},k={maxWidth:"1152px",margin:"0 auto",padding:"16px"},L={display:"flex",justifyContent:"flex-end",paddingTop:"16px",paddingBottom:"8px"},R={background:"transparent",border:"none",cursor:"pointer",padding:"8px",display:"flex",alignItems:"center",justifyContent:"center"};var N=({isOpen:e,onClose:t,search:r})=>((0,i.useEffect)(()=>(document.body.style.overflow=e?"hidden":"",()=>{document.body.style.overflow=""}),[e]),e?(0,v.jsx)("div",{style:T,"data-testid":"header-search-overlay",children:(0,v.jsxs)("div",{style:k,children:[(0,v.jsx)("div",{style:L,children:(0,v.jsx)("button",{type:"button",onClick:t,style:R,"aria-label":"Cerrar búsqueda",children:(0,v.jsx)(_.SXS,{size:28})})}),(0,v.jsx)(n.yT,{mostSearched:r.mostSearched,contents:r.contents,onSearch:r.onSearch,isLoadingSuggestions:r.isLoadingSuggestions,searchSuggestions:r.searchSuggestions,onSearchFull:r.onSearchFull,filters:r.filters})]})}):null);var I=()=>((0,i.useEffect)(()=>{if("undefined"==typeof window)return;const{search:e}=window.location;window.location.replace(`${(0,S.withPrefix)(s.resultsRoute)}${e}`)},[]),null)},62225:function(e,t,r){r.d(t,{k5:function(){return d}});var s=r(96540),o={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},i=s.createContext&&s.createContext(o),n=["attr","size","title"];function a(){return a=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)({}
1).hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},a.apply(null,arguments)}function c(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,s)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?c(Object(r),!0).forEach(function(t){u(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):c(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function u(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var s=r.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function h(e){return e&&e.map((e,t)=>s.createElement(e.tag,l({key:t},e.attr),h(e.child)))}function d(e){return t=>s.createElement(f,a({attr:l({},e.attr)},t),h(e.child))}function f(e){var t=t=>{var r,{attr:o,size:i,title:c}=e,u=function(e,t){if(null==e)return{};var r,s,o=function(e,t){if(null==e)return{};var r={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(-1!==t.indexOf(s))continue;r[s]=e[s]}return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)r=i[s],-1===t.indexOf(r)&&{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(e,n),h=i||t.size||"1em";return t.className&&(r=t.className),e.className&&(r=(r?r+" ":"")+e.className),s.createElement("svg",a({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,o,u,{className:r,style:l(l({color:e.color||t.color},t.style),e.style),height:h,width:h,xmlns:"http://www.w3.org/2000/svg"}),c&&s.createElement("title",null,c),e.children)};return void 0!==i?s.createElement(i.Consumer,null,e=>t(e)):t(o)}},65330:function(e,t,r){r.d(t,{D8:function(){return h},WQ:function(){return s}});var s=class{constructor(e){this.options=e,this.searchText="",this.boolClauses={},this.sort=[],this.totalPages=0,this.totalResults=0,this.result=null,this.indexBoostList=[],this.isLoading=!1,this.errorMsg=null,this.debounceTimer=null,this.subscribers=[],this.currentPageSearch=e.currentPage??1,this.initBoost()}initBoost(){let{boostIndex:e=[]}=this.options;this.indexBoostList=e.map(e=>({[e]:10})),this.indexBoostList.push({"*":1})}notify(){let e=this.getState();this.subscribers.forEach(t=>{t(e)})}getState(){return{result:this.result,isLoading:this.isLoading,errorMsg:this.errorMsg,currentPage:this.currentPageSearch,totalPages:this.totalPages,totalResults:this.totalResults}}reset(){this.result=null,this.isLoading=!1,this.errorMsg=null,this.searchText="",this.currentPageSearch=1,this.totalPages=0,this.totalResults=0,this.notify()}nextPage(){this.currentPageSearch+=1,this.fetchResults()}prevPage(){this.currentPageSearch>1&&(this.currentPageSearch-=1,this.fetchResults())}goToPage(e){this.currentPageSearch=e,this.fetchResults()}doSearch(e,t={},r=[],s=1){this.searchText=e,this.currentPageSearch=s,this.boolClauses=t,this.sort=r,this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>this.fetchResults(),this.options.debounceTime??500)}async fetchResults(){if((!this.searchText.trim()||this.searchText.length<=2)&&"*"!==this.searchText)return this.result=null,void this.notify();this.isLoading=!0,this.errorMsg=null,this.notify();let{urlElastic:e,apikeyElastic:t,selectedFields:r,limitPerPage:s=10,onNoResults:o}=this.options;try{let i=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`ApiKey ${t}`},body:JSON.stringify({from:(this.currentPageSearch-1)*s,size:s,query:{bool:{must:[...this.boolClauses.must??[],{query_string:{query:`${this.searchText}~`,...r&&{fields:r}}}],...this.boolClauses.should?.length&&{should:this.boolClauses.should},...this.boolClauses.must_not?.length&&{must_not:this.boolClauses.must_not},...this.boolClauses.filter?.length&&{filter:this.boolClauses.filter}}},sort:this.sort,indices_boost:this.indexBoostList})});if(!i.ok)throw new Error(`Error: ${i.statusText}`);let n=await i.json();if(!n.hits)throw new Error(`Error: ${JSON.stringify(n)}`);0===n.hits.total.value?(this.result=[],this.totalResults=0,this.totalPages=0,o?.()):(this.result=n.hits.hits.map(e=>e._source),this.totalResults=n.hits.total.value,this.totalPages=Math.ceil(this.totalResults/s))}catch(i){this.errorMsg=i instanceof Error?i.message:"An unknown error occurred"}finally{this.isLoading=!1,this.notify()}}subscribe(e){return this.subscribers.push(e),e(this.getState()),()=>{let t=this.subscribers.indexOf(e);-1!==t&&this.subscribers.splice(t,1)}}},o="serviceChannelsData",i="dev",n="qa",a="www",c=["localhost","127","dev"],l=["qa"],u=e=>e.map(e=>
1({title:e.title,description:e.description,action:e.action,icon:e.icon,target:"_blank",visibility:e.visibility??void 0})),h=class{constructor(){this.apiUrl=(()=>{if(typeof window>"u")return`https://${a}.comfama.com/components/canales-servicios-info.json`;let e=window.location.hostname.split(".")[0]?.toLowerCase()||a;return`https://${c.some(t=>e.includes(t))?i:l.some(t=>e.includes(t))?n:a}.comfama.com/components/canales-servicios-info.json`})()}getCachedData(){if(typeof window>"u")return null;let e=sessionStorage.getItem(o);if(!e)return null;try{let t=JSON.parse(e);return u(t)}catch{return sessionStorage.removeItem(o),null}}setCacheData(e){typeof window<"u"&&sessionStorage.setItem(o,JSON.stringify(e))}async fetch(){let e=this.getCachedData();if(e)return e;try{let e=await fetch(this.apiUrl);if(!e.ok)throw new Error(`Network response was not ok (${e.status})`);let t=await e.json();return Array.isArray(t)?(this.setCacheData(t),u(t)):(console.error("Unexpected API response format"),[])}catch(t){return console.error("Failed to fetch service channels:",t),[]}}}}}]);
2//# sourceMappingURL=63c7f9c17742ee4aedf7892b451aae7895fa3867-4c36846c6c2ded079271.js.map

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.