1"use strict";(self.webpackChunkreact_app=self.webpackChunkreact_app||[]).push([[4298,8924],{7632:function(e,t,n){n.r(t),n.d(t,{default:function(){return ye}});var a=n(1413),o=n(9439),r=n(2791),i=n(9259),l=n(1221),c=n(6138),s=n(4164),u=n(9243),d=n(649),f=n(5146),p=n(9647),v=n(5100),m=n(6407),g=n(3027),_=n(184),h=function(e){var t=e.contractors,n=e.ctaLink,a=e.onRemove,o=e.contratorAddLink,i=e.onToggleCoupon,l="m-selected-contractors",c=Drupal.t("Add another contractor"),s=(0,r.useMemo)((function(){var e=[void 0,void 0,void 0];return t&&t.forEach((function(t,n){e[n]=t})),e}),[t]),u=(0,_.jsx)(m.Z,{iconName:"plus",width:16,height:16}),d=function(e){o?window.location.href=o:(0,g.C)(e,"contractors-tray-opened")},f=function(){return n?(0,_.jsxs)("a",{href:n,className:(0,p.Z)("add-btn",[],l,[]),children:[c," ",u]}):(0,_.jsxs)("button",{type:"button",className:(0,p.Z)("add-btn",[],l,[]),onClick:d,children:[c," ",u]})},h=s.map((function(e,t){return e?(0,_.jsx)(v.Z,{contractorData:e,isFindAPro:!0,isSmall:!0,showRemove:!0,className:(0,p.Z)("card",[],l),onRemove:function(){return a(e.id)},showDefaultImage:!0,coupons:e.coupons||[],onToggleCoupon:i},e.id):(0,_.jsx)(f,{},"cta-btn-".concat(t))}));return(0,_.jsx)("div",{className:(0,p.Z)("list",[],l),children:h})},y=n(7523),b=n(6056),S=n(2692),w=n(485),Z=function(e){var t,n=e.locationStateWeb,a=(0,r.useState)(),i=(0,o.Z)(a,2),l=i[0],c=i[1],s=document.querySelector('input[name="location"]'),u=document.querySelector('input[name="sf_location"]');(0,r.useEffect)((function(){var e=localStorage.getItem("_ct_app_fap_geo");if(e)try{var t,n,a=JSON.parse(e);if(Array.isArray(a)&&null!==(t=a[0])&&void 0!==t&&t.address_components&&null!==(n=a[0])&&void 0!==n&&n.formatted_address){var o=a[0].address_components,r=a[0].formatted_address,i=o.find((function(e){return e.types.includes("postal_code")})),l=i?i.long_name:"";c(a),s&&(s.value=r),u&&(u.value=l),"function"===typeof window.setFapGeoLocation&&window.setFapGeoLocation(r,l)}}catch(d){console.error("Error parsing _ct_app_fap_geo:",d)}}),[]),(0,r.useEffect)((function(){s&&s.value?c(s.value):n.placeId&&(0,S.Z)(n.placeId).then((function(e){c(e)})).catch((function(e){return console.error(e)}))}),[null===n||void 0===n?void 0:n.placeId]);var d,f=function(e){c(e)};if("object"===typeof l&&s)s.value=null===l||void 0===l||null===(d=l[0])||void 0===d?void 0:d.formatted_address,u.value=(0,w.BW)(l);else if("string"===typeof l)return(0,_.jsx)(b.Z,{onPlaceSelected:function(e){return f(e)},inputDefaultValue:s.value});return(0,_.jsx)(b.Z,{onPlaceSelected:function(e){return f(e)},inputDefaultValue:null===l||void 0===l||null===(t=l[0])||void 0===t?void 0:t.formatted_address})},x=n(6914),j="_ct_app_fap_reset_on_home",N=function(){var e=(0,y.wf)(),t=(0,r.useContext)(c.a),n=t.selectedLocation,a=t.qualifications,o=t.agentServices,i=t.contractorsTray,l=t.setContractorsTray,v=t.commonSettings,m=(0,u.T)().locationState,g=function(e){null!==e&&void 0!==e&&e.ctFapReactRoot&&e.ctFapReactRoot.unmount();var t=s.createRoot(e);e.ctFapReactRoot=t,t.render((0,_.jsx)(x.Z,{}))};if(Drupal.behaviors.globalReactApp={attach:function(){var e=document.querySelector(".webform-submission-get-an-estimate-form"),t=document.getElementById("ct-project-location-autocomplete-step"),n=document.getElementById("ct-project-full-address-autocomplete-step");if(e&&t){e.ctFapEstimateResetListenerAttached||(e.addEventListener("submit",(function(){try{sessionStorage.setItem(j,"1")}catch(e){}})),e.ctFapEstimateResetListenerAttached=!0);var a=JSON.parse(localStorage.getItem("_ct_app_fap_prod_category"));if(a=a.label){"Siding & Trim"===a?a="Siding":"Solar Roofing"===a?a="Solar":"Insulation Products & Systems"===a&&(a="Residential Insulation");var o=document.querySelector('input[name="products_needed"][value="'.concat(a,'"]'));o&&(o.checked=!0)}!function(){try{var e,t,n,a,o=localStorage.getItem("_ct_app_fap_geo_full_address");if(o&&"null"!==o)return;var r=localStorage.getItem("_ct_app_fap_geo");if(!r)return;var i=JSON.parse(r),l=Array.isArray(i)?null===i||void 0===i?void 0:i[0]:null,c=null===l||void 0===l?void 0:l.formatted_address,s=null===l||void 0===l?void 0:l.place_id,u=null===l||void 0===l||null===(e=l.geometry)||void 0===e||null===(t=e.location)||void 0===t?void 0:t.lat,d=null===l||void 0===l||null===(n=l.geometry)||void 0===n||null===(a=n.location)||void 0===a?void 0:a.lng,f=(null===l||void 0===l?void 0:l.address_components)||[];if(!c||!s||null==u||null==d)return;var p={formatted_address:c,place_id:s,lat:u,lng:d,address_components:f};localStorage.setItem("_ct_app_fap_geo_full_address",JSON.stringify(p))}catch(v){}}(),setTimeout((function(){if(function(e){null!==e&&void 0!==e&&e.ctFapReactRoot&&e.ctFapReactRoot.unmount();var t=s.createRoot(e);e.ctFapReactRoot=t,t.render((0,_.jsx)(Z,{locationStateWeb:m}))}(t),v.display_full_address_home_page)if(n)g(n);else{var a=Number(e.ctFapFullAddressMountAttempts||0);a<30&&(e.ctFapFullAddressMountAttempts=a+1,setTimeout((function(){var e=document.getElementById("ct-project-full-address-autocomplete-step");e&&g(e)}),250))}}),100)}}}
1,(0,r.useEffect)((function(){try{sessionStorage.setItem(j,"1")}catch(t){}document.querySelector(".webform-submission-get-an-estimate-form")&&e({event:"form_opened",event_origin:"front_end",form_name:"find_a_pro_get_estimate"})}),[]),!i||!i.length)return(0,f.Z)(d.kD),null;var b="fap-estimate-page";return(0,_.jsx)("div",{className:"container",children:(0,_.jsxs)("div",{className:(0,p.Z)(b),children:[(0,_.jsx)("h4",{className:(0,p.Z)("subtitle",[],b,["h","h4"]),children:Drupal.t("Contractors you've selected:")}),(0,_.jsx)(h,{contractors:i,onRemove:function(e){return function(e){var t=i;if(t.length){var r=t.filter((function(t){return t.id!==e}));l(r,o,a,n)}}(e)},ctaLink:"".concat(d.kD,"/results")})]})})},C=n(3433),R=n(1444),k=n(1230),I=n(9315),D="_ct_app_fap_reset_on_home",P=function(){var e=(0,r.useContext)(c.a),t=e.categories,n=e.selectedCategory,i=e.setSelectedCategory,l=e.selectedLocation,f=e.setSelectedLocation,v=e.commonSettings;l&&!v.display_existing_zip_code_home_page&&(f(null),localStorage.setItem("_ct_app_fap_geo_full_address","null"));var g=(0,r.useRef)(!1),h=(0,u.T)().locationState,j=(0,r.useState)(!1),N=(0,o.Z)(j,2),P=N[0],A=N[1],E=(0,r.useState)(null),L=(0,o.Z)(E,2),F=L[0],T=L[1],O=(0,r.useState)(null),M=(0,o.Z)(O,2),q=M[0],H=M[1],z=(0,r.useState)(!1),J=(0,o.Z)(z,2),B=J[0],W=J[1],U=(0,r.useRef)(!1),V=(0,r.useState)(null),G=(0,o.Z)(V,2),Y=G[0],K=G[1],Q=new CustomEvent("fap:prodCategoryUpdated",{detail:{key:"_ct_app_fap_prod_category"}}),$=new CustomEvent("fap:locationUpdated",{detail:{key:"_ct_app_fap_geo"}}),X=function(e,t){var n=void 0===t||t;switch(e){case 1:v.display_full_address_home_page&&W(n);break;case 3:A(n);break;default:A(!1),W(!1)}0===e&&window.dispatchEvent(Q),1===e&&window.dispatchEvent($)};localStorage.removeItem("qualificationIds"),(0,r.useEffect)((function(){try{"1"===sessionStorage.getItem(D)&&(sessionStorage.removeItem(D),i(null),f(null),W(!1),A(!1),K(null),localStorage.removeItem("_ct_app_fap_geo"),localStorage.removeItem("_ct_app_fap_prod_category"),localStorage.removeItem("_ct_app_fap_geo_full_address"),localStorage.removeItem("search_query"))}catch(e){}localStorage.setItem("_ct_app_fap_geo_full_address","null"),setTimeout((function(){i(null),f(null)}),500)}),[]),(0,r.useEffect)((function(){if(!g.current){g.current=!0,f(null);try{localStorage.setItem("_ct_app_fap_geo","null"),localStorage.setItem("_ct_app_fap_geo_full_address","null"),localStorage.removeItem("_ct_app_fap_geo"),localStorage.removeItem("_ct_app_fap_geo_full_address")}catch(e){}X(1,!1)}}),[]),(0,r.useEffect)((function(){null!==h&&void 0!==h&&h.zip&&0!==h.zip.length||v.display_existing_zip_code_home_page||(f(null),X(1,!1))}),[h]),(0,r.useEffect)((function(){h.placeId&&(0,S.Z)(h.placeId).then((function(e){f(e),v.display_full_address_home_page?X(1,!1):X(1,!0)})).catch((function(e){return console.error(e)}))}),[h.placeId]),(0,r.useEffect)((function(){if(!F){var e=null===n||void 0===n?void 0:n.label;T(e)}if(!q){var t,a=null===l||void 0===l||null===(t=l[0])||void 0===t?void 0:t.formatted_address;H(a)}}),[]);var ee=(0,y.wf)(),te="find_a_pro";(0,r.useEffect)((function(){try{if("1"===sessionStorage.getItem(D))return window.history.replaceState({},document.title,window.location.pathname),void sessionStorage.removeItem(D)}catch(r){}if(window.location.search.includes("product_category")&&"1"!==sessionStorage.getItem(D)){var e=new URL(document.location).searchParams.get("product_category"),n=v.product_category_to_product_options.find((function(t){return t.split("|")[0]===e}));if(n){var a=n.split("|")[1];if(a){var o=t.find((function(e){return e.label===a}));i(o)}}}}),[]),(0,r.useEffect)((function(){U.current||(U.current=!0,ee((0,w.HM)({contentType:"find_a_pro",productCategory:null===n||void 0===n?void 0:n.label}),!0))}),[]),(0,r.useEffect)((function(){localStorage.setItem("hasSelectedCategory","false")}),[]);var ne="fap-redesign-page",ae=function(e){var t;f(e),X(1,!0),ee((0,w.dr)({contentType:te,filterName:"location",filterValue:null===e||void 0===e||null===(t=e[0])||void 0===t?void 0:t.formatted_address}),!0)};Drupal.behaviors.globalReactApp={attach:function(){var e=document.querySelector(".webform-submission-get-an-estimate-form"),t=document.getElementById("ct-project-location-autocomplete-step"),n=document.getElementById("ct-project-full-address-autocomplete-step");if(e&&t&&n){var a,o=JSON.parse(localStorage.getItem("_ct_app_fap_prod_category")),r=Array.isArray(o)?null===(a=o[0])||void 0===a?void 0:a.label:null===o||void 0===o?void 0:o.label;if(r){"Siding & Trim"===r?r="Siding":"Solar Roofing"===r?r="Solar":"Insulation Products & Systems"===r&&(r="Residential Insulation");var i=document.querySelector('input[name="products_needed"][value="'.concat(r,'"]'));i&&(i.checked=!0)}s.createRoot(t).render((0,_.jsx)(Z,{locationStateWeb:h})),s.createRoot(n).render((0,_.jsx)(x.Z,{clearOnLoad:!0}))}}};var oe=document.querySelector(".section-cc-findaproredesign--cta-banner .btn"),re={"Insulation Products & Systems":"Insulation","Solar Roofing":"Solar"},ie={"Residential Roofing":1,"Commercial Roofing":2,"Siding & Trim":3,"S
1olar Roofing":4,"Insulation Products & Systems":5},le=t.map((function(e){return(0,a.Z)((0,a.Z)({},e),{},{displayLabel:re[e.label]||e.label})})).sort((function(e,t){return ie[e.label]-ie[t.label]}));(0,r.useEffect)((function(){var e=document.querySelector(".section-cc-findaproredesign--cta-banner .btn"),t=document.querySelector(".section-cc-findaproredesign--cta-banner ");e&&!e.dataset.bound&&(e.dataset.bound="true",e.removeAttribute("href"),e.addEventListener("click",(function(e){e.preventDefault();var n=document.querySelector(".webform-submission-get-an-estimate-form");if(n&&oe&&t){n.style.display="block",n.classList.add("cta-form-visible"),n.classList.remove("hidden","visually-hidden"),n.scrollIntoView({behavior:"smooth",block:"start"});var a=n.querySelector("input, textarea, select");a&&a.focus()}})))}),[]);var ce=v.display_full_address_home_page?B:!!l,se=Array.isArray(n)&&n.length>0&&ce&&P;return(0,_.jsx)("div",{className:"container fap-redesign-header",children:(0,_.jsxs)("div",{className:(0,p.Z)(ne),children:[(0,_.jsxs)("div",{className:(0,p.Z)("cards",[],ne),children:[(0,_.jsx)("div",{className:(0,p.Z)("process-card h3",[]),children:Drupal.t("Find a Credentialed ")}),(0,_.jsx)("div",{className:(0,p.Z)("process-card h3",[]),children:Drupal.t("Contractor Near You ")}),t&&t.length>0&&(0,_.jsxs)(k.Z,{completed:n,data:n,className:(0,p.Z)("card",[],ne),tooltip:v.home_product_tooltip,children:[(0,_.jsx)("h5",{className:(0,p.Z)("card-title",[],ne),children:Drupal.t("I need...")}),(0,_.jsx)("fieldset",{className:(0,p.Z)("card-options",["in-cols"],ne),children:le.map((function(e){return(0,_.jsx)(R.Z,{type:"checkbox",name:"product",value:e.value,extraInput:["small"],extraLabel:(0,p.Z)("card-option",[],ne),onChange:function(){return function(e){var t,a=Array.isArray(n)?n:[];if(0===(t=a.some((function(t){return t.label===e.label}))?a.filter((function(t){return t.label!==e.label})):[].concat((0,C.Z)(a),[e])).length)return i(null),localStorage.setItem("hasSelectedCategory","false"),void window.dispatchEvent(Q);i(t),localStorage.setItem("hasSelectedCategory","true"),X(0),window.dispatchEvent(new CustomEvent("fap:prodCategoryUpdated",{detail:{key:"_ct_app_fap_prod_category"}})),ee((0,w.dr)({contentType:te,filterName:"product",filterValue:t.map((function(e){return e.label})).join(", ")}),!0)}(e)},checked:Array.isArray(n)&&n.some((function(t){return t.label===e.label})),children:e.displayLabel},e.label)}))})]}),(0,_.jsx)(k.Z,{className:(0,p.Z)("card",[],ne),completed:v.display_full_address_home_page?!!B:l,tooltip:v.home_location_tooltip,children:function(){var e,t,n;return v.display_existing_zip_code_home_page&&v.display_full_address_home_page?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(b.Z,{clearOnLoad:!0,className:(0,p.Z)("zip",[],ne),inputDefaultValue:null===l||void 0===l||null===(e=l[0])||void 0===e?void 0:e.formatted_address,onPlaceSelected:function(e){return ae(e)}}),(0,_.jsx)(x.Z,{clearOnLoad:!0,onFullAddressSelected:function(e){W(!!e),X(1,!!e)}})]}):v.display_existing_zip_code_home_page?(0,_.jsx)(b.Z,{clearOnLoad:!0,className:(0,p.Z)("zip",[],ne),inputDefaultValue:null===l||void 0===l||null===(t=l[0])||void 0===t?void 0:t.formatted_address,onPlaceSelected:function(e){return ae(e)}}):v.display_full_address_home_page?(0,_.jsx)(x.Z,{inputDefaultValue:null===l||void 0===l||null===(n=l[0])||void 0===n?void 0:n.formatted_address,clearOnLoad:!0,onFullAddressSelected:function(e){W(!!e),X(1,!!e)}}):null}()})]}),"contact"!==Y&&(0,_.jsxs)("div",{className:"fap-footer",children:[(0,_.jsx)("div",{className:(0,p.Z)("legal",[],ne),children:(0,_.jsxs)(R.Z,{type:"checkbox",name:"agree",value:"agreed",extraInput:["small"],checked:P,onChange:function(e){X(3,e.target.checked)},children:[Drupal.t("I Have Read And Agree to The "),(0,_.jsx)(I.Z,{url:"/terms-and-conditions-where-buy/find-pro/get-quote",children:Drupal.t("Terms & Conditions")})]})}),(0,_.jsxs)("a",{href:se?"".concat(d.kD,"/results"):void 0,className:[(0,p.Z)("cta",[],ne,["btn btn--primary btn--white btn--m",se?"":"disabled"])],"aria-disabled":!se,tabIndex:se?0:-1,onClick:function(e){se||e.preventDefault()},children:[(0,_.jsx)(m.Z,{className:"search-icon",iconName:"search-blue"}),Drupal.t("Search")]})]})]})})},A=n(7413),E=n(4084),L=n(1006),F=n(9286),T=n(2285),O=n(8001),M=function(e){var t=e.contractors,n=e.estimateLink,a=e.className,o=e.onRemove,i=e.contratorAddLink,l=e.onToggleCoupon,s=(0,r.useRef)(null),u=(0,r.useContext)(c.a)||{},d=u.selectedCategory,f=u.selectedLocation;(0,r.useEffect)((function(){var e,t;window&&null!==(e=Drupal)&&void 0!==e&&null!==(t=e.behaviors)&&void 0!==t&&t.modalJs&&Drupal.behaviors.modalJs.attach(s.current)}),[t.length,s.current]);var p={event:"fap_get_estimate_clicked",event_origin:"front-end",zip_code:(0,w.BW)(f)||"undefined",vendor_name:(null===t||void 0===t?void 0:t.length)>0?t.map((function(e){return(null===e||void 0===e?void 0:e.title)||""}
1)).filter(Boolean).join(" | "):"undefined",business_unit_by_user:(null===d||void 0===d?void 0:d.label)||"undefined"};return(0,_.jsxs)("div",{className:a,ref:s,children:[(0,_.jsx)("h2",{className:"h h3 text-blue",children:Drupal.t("Get an Estimate")}),(0,_.jsx)("p",{className:"modal-content-subtle",children:Drupal.t("Select up to three contractors to contact for a project estimate.")}),t.length>0?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("h3",{className:"h h5",children:Drupal.t("Contractors you\u2019ve selected")}),(0,_.jsx)(h,{contractors:t,onRemove:function(e){return o(e)},contratorAddLink:i,onToggleCoupon:l}),(0,_.jsx)(O.Z,{fieldCta:[{title:Drupal.t("Get an Estimate"),url:function(){var e=(t||[]).filter((function(e){return e&&Array.isArray(e.coupons)&&e.coupons.length>0})).map((function(e){return e.id})).join(",");if(!e)return n;var a=n.includes("?")?"&":"?";return"".concat(n).concat(a,"coupons_selected=").concat(encodeURIComponent(e))}()}],mods:["primary"],extra:["modal-content-cta-btn"],onClickAnalyticData:p})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)("p",{className:"no-contractors-msg h h5",children:[Drupal.t("No contractors added yet."),(0,_.jsx)("br",{}),Drupal.t("Select contractors from your results to get an estimate.")]}),(0,_.jsx)(T.Z,{mods:["primary"],extra:["js-modal-close","modal-content-no-contractors-btn"],children:Drupal.t("See contractor results")})]})]})};var q=function(e){var t=e.contractors,n=void 0===t?[]:t,a=e.className,i=e.onRemove,l=e.estimateLink,c=e.offsetSelectors,s=e.contratorAddLink,u=e.setTray,d=void 0===u?function(){}:u,f=e.onToggleCoupon,v=(0,r.useRef)(null),h=(0,r.useState)(0),b=(0,o.Z)(h,2),S=b[0],w=b[1],Z=(0,r.useState)(!1),x=(0,o.Z)(Z,2),j=x[0],N=x[1],C=(0,A.Z)().breakpoint,R=null===C||void 0===C?void 0:C.isMobile;(0,r.useEffect)((function(){if(window){var e=document.querySelectorAll(c);if(e.length){var t=0;e.forEach((function(e){t+=e.offsetHeight})),w(t)}}}),[c]);var k,I=function(e,t){var n=t.threshold,a=void 0===n?0:n,i=t.root,l=void 0===i?null:i,c=t.rootMargin,s=void 0===c?"0%":c,u=t.freezeOnceVisible,d=void 0!==u&&u,f=(0,r.useState)(),p=(0,o.Z)(f,2),v=p[0],m=p[1],g=(null===v||void 0===v?void 0:v.isIntersecting)&&d,_=function(e){var t=(0,o.Z)(e,1)[0];m(t)};return(0,r.useEffect)((function(){var t=null===e||void 0===e?void 0:e.current;if(window.IntersectionObserver&&!g&&t){var n=new IntersectionObserver(_,{threshold:a,root:l,rootMargin:s});return n.observe(t),function(){return n.disconnect()}}}),[null===e||void 0===e?void 0:e.current,JSON.stringify(a),l,s,g]),v}(v,{rootMargin:"-".concat(S,"px")}),D="o-contractor-tray",P=1===n.length?Drupal.t("Contractor"):Drupal.t("Contractors"),E=Drupal.t("Get an Estimate"),L=Drupal.t("Added"),T="contractors-tray-modal",O=(0,y.wf)();return(0,r.useEffect)((function(){var e;return n.length&&window?(N(!0),e=setTimeout((function(){N(!1)}),600),d(!0)):d(!1),function(){return clearTimeout(e)}}),[n]),(0,_.jsxs)("div",{ref:v,className:(0,p.Z)(D,[],"",[I&&(k=I,!k.isIntersecting&&k.boundingClientRect.y<k.rootBounds.y&&k.intersectionRatio>=0&&k.intersectionRatio<1?"is--sticky":""),a,n.length,j&&"animate"]),children:[(0,_.jsx)("button",{type:"button",className:(0,p.Z)("button",[],D),"data-modal-id":T,style:{top:S},onClick:function(e){return function(e){return(0,g.Q)(e,"contractors-tray-opened",(function(){O({event:"estimate_tray_opened",event_origin:"front_end"})}))}(e)},children:(0,_.jsxs)("span",{className:(0,p.Z)("title",[],D),children:[E,"\xa0",(0,_.jsx)("br",{}),"(".concat(n.length," ").concat(P," ").concat(L,")"),(0,_.jsxs)("span",{className:"icon-wrapper block",children:[(0,_.jsx)(m.Z,{iconName:"expand-bottom",width:9,height:9,style:{pointerEvents:"none"},className:"icon-bottom"}),(0,_.jsx)(m.Z,{iconName:"expand-top",width:9,height:9,style:{pointerEvents:"none"},className:"icon-top"})]})]})}),(0,_.jsx)(F.Z,{modal_id:T,modal_modifiers:["variant-classic"],closeIn:!R,onCloseHandler:function(e){return function(e){return(0,g.C)(e,"contractors-tray-opened")}(e)},children:(0,_.jsx)(M,{className:(0,p.Z)("modal-content",[],D),contractors:n,onRemove:function(e){return i(e)},estimateLink:l,contratorAddLink:s,onToggleCoupon:f})})]})},H=n(786),z=n(7939),J=function(){var e=(0,r.useContext)(c.a),t=e.selectedLocation,n=e.agentServices,i=e.qualifications,l=e.contractorsTray,u=e.setContractorsTray,f=e.commonSettings,v=e.algoliaSettings,m=e.addToEstimateAnalytics,h=(0,A.Z)().breakpoint,y=(0,r.useState)(null),b=(0,o.Z)(y,2),S=b[0],w=b[1],Z=(0,r.useState)(null),x=(0,o.Z)(Z,2),j=x[0],N=x[1];(0,r.useEffect)((function(){var e=(0,E.zu)(v.algolia_index);return null!==f&&void 0!==f&&f.currentNodeId&&n&&i&&e.search("",{filters:"nid=".concat(f.currentNodeId.trim())}).then((function(e){var a=e.hits.map((function(e){var a,o;return(0,L.Z)(e,n,i,t?null===t||void 0===t||null===(a=t[0])||void 0===a||null===(o=a.geometry)||void 0===o?void 0:o.location:"")}));N(a[0])})),function(){!0}}),[]),(0,r.useEffect)((function(){var e=h.isMobile?"add-company-button-mobile":"add-company-button-desktop",t=document.getElementById(e);w(t)}),[h.isMobile]);var R=Number(null===f||void 0===f?void 0:f.currentNodeId),k=l&&l.find((function(e){return e.id===R})),I=l&&l.length>=d.wF,D="fap-node-page",P=function(e){var a=l;if(a.length){var o=a.filter((function(t){return t.id!==e}));u(o,n,i,t)}},F=function(e){e&&(!function(){var e=l,a=[].concat((0,C.Z)(e),[j]);u(a,n,i,t)}(),m(j.title,"find_a_pro_contractor_profile"))},T=localStorage.getItem("search_query"),O=function(e){return(0,g.C)(e)},M=k?"modal__remove-contractor--".concat(R,"-checkbox"):"contractors-tray-modal",J=function(e){e&&!k?function(e){(0,g.Q)(e,"contractors-tray-opened","contractor-remove-opened")}(e):function(e){(0,g.Q)(e,"modal__remove-contractor--".concat(R,"-checkbox"))}(e)},B=function(){var e;return(0,_.jsxs)("div",{className:(0,p.Z)("check-btn",[],D),children:[(0,_.jsx)(H.Z,{id:"add-to-compare-".concat(R),onChange:function(e){return F(e)},disabled:!j||!k&&I,isSelected:k,tooltip:f.contractor_tray_tooltip,modalId:M,inputExtra:[k?"js-modal-open":""],inputOnClick:function(e){return J(e)}}),(0,_.jsx)(z.Z,{onRemoveHandler:function(){return P(R)},title:null===(e=l.find((function(e){return e.id===R})))||void 0===e?void 0:e.title,modalId:"modal__remove-contractor--".concat(R,"-checkbox"),onCancelHandler:function(e){return O(e)},onCloseHandler:function(e){return O(e)}})]})};return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(q,{contractors:l,onRemove:function(e){return P(e)},onToggleCoupon:function(e,o){var r=(l||[]).map((function(t){return t&&t.id===e?(0,a.Z)((0,a.Z)({},t),{},{coupons:o?["premier-default"]:[]}):t}));u(r,n,i,t)},estimateLink:"".concat(d.kD,"/get-an-estimate"),contratorAddLink:"".concat(d.kD,"/results").concat(T),className:(0,p.Z)("contractor-tray",[],D,[]),offsetSelectors:"#toolbar-bar, #toolbar-item-administration-tray, .header"}),S&&(0,s.createPortal)((0,_.jsx)(B,{}),S)]})},B=n(4165),W=n(5861),U=n(9745),V=n(4182),G=n(8132),Y=[{name:"field_geofield",label:Drupal.t("Location"),type:"geolocation",options:d.nW.map((function(e){return{label:(0,U.Z)(e,!0),value:e}})),wrapInAccordion:!0},{name:"field_agent_services",label:Drupal.t("Additional Services"),type:"checkboxes",viewAllButton:!0,options:[],wrapInAccordion:!0,isFacet:!0,forceTabletViewAll:!0},{name:"rating",label:Drupal.t("Rating"),type:"radios",options:[{label:(0,_.jsxs)("span",{className:"fap-star-rating-filter",children:[(0,_.jsx)(V.Z,{srId:1,rating:4.5,showNumbers:!1})," ",Drupal.t("& up")]}),value:"4.5"},{label:(0,_.jsxs)("span",{className:"fap-star-rating-filter",children:[(0,_.jsx)(V.Z,{srId:2,rating:4,showNumbers:!1})," ",Drupal.t("& up")]}),value:"4"},{label:(0,_.jsx)("span",{className:"fap-star-rating-filter",children:Drupal.t("All ratings")}),value:"all",checked:!0}],defaultValue:"all",wrapInAccordion:!0}];function K(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,o=(0,G.Dr)(e,a).map((function(e){var o=(0,G.wV)(e,t,a);return{name:"certifications",sectionKey:e.key,label:Drupal.t(e.label),type:"checkboxes",viewAllButton:!0,options:(0,G.fH)(n,o),wrapInAccordion:!0,isFacet:!0,forceTabletViewAll:!0,showZeroCountOptions:!0}}));return[].concat(Y,(0,C.Z)(o))}K();var Q=n(4489),$=n(6066),X=n(7571);function ee(e,t){var n,a=(e||0)+((n=t)<=0||n>
110?0:5.5-.5*n)/5*.143*1e3;return Math.round(a)}var te=n(5480),ne=n(211),ae=n(27),oe=n(6922),re=n(7065),ie=n(5178),le=n(5871),ce=function(e){var t,n=e.filtersState,i=e.index,l=e.facets,s=e.maxRadius,u=e.onCtaClick,d=(0,r.useState)(null),f=(0,o.Z)(d,2),p=f[0],v=f[1],m=(0,r.useContext)(c.a),g=m.selectedCategory,h=m.selectedLocation,y=m.agentServices,b=m.qualifications;(0,r.useEffect)((function(){var e,t;return i.search("",{page:0,hitsPerPage:2,facets:l,facetFilters:[].concat((0,C.Z)(null!==n&&void 0!==n&&null!==(e=n.field_agent_services)&&void 0!==e&&e.length?[n.field_agent_services]:[]),(0,C.Z)(null!==n&&void 0!==n&&null!==(t=n.certifications)&&void 0!==t&&t.length?[n.certifications]:[])),aroundLatLng:null===n||void 0===n?void 0:n.location,aroundRadius:s}).then((function(e){v(e)})),function(){!0}}),[n.field_agent_services,n.location,n.certifications]);var S={title:Drupal.t("Continue your search"),zipCode:null===(t=h[0])||void 0===t?void 0:t.address_components[0].short_name,productCategory:Array.isArray(g)?g.map((function(e){return e.label})).join(", "):null===g||void 0===g?void 0:g.label,isFap:!0,extra:["listing__no-results-continue-search"],contractors:p&&p.hits.length>0?p.hits.map((function(e){var t,n;return(0,L.Z)(e,y,b,null===(t=h[0])||void 0===t||null===(n=t.geometry)||void 0===n?void 0:n.location)})):[],total:null===p||void 0===p?void 0:p.nbHits,maxRadius:(0,U.Z)(s,!0),onCtaClick:u};return(0,_.jsx)(le.Z,(0,a.Z)({},S))},se=n(7557),ue=n(9957),de=Drupal.t("Please adjust your location radius or search for contractors in one of the selected product categories.");function fe(e){return e.reduce((function(e,t){return e[t.id]=0,e}),{})}function pe(e,t,n){var a,o=n.map((function(e){return e.id})),r=(0,$.yl)({name:"selectedContractors",value:o.join(",")}),i=[{filters:e,category:t,selectedContractors:o},"","".concat(window.location.pathname,"?").concat(r.toString().replaceAll(/\+/g,"%20"))];(a=window.history).replaceState.apply(a,i)}function ve(e){var t,n,o,r,i="",l=null===(t=window)||void 0===t||null===(n=t.drupalSettings)||void 0===n||null===(o=n.findAProData)||void 0===o||null===(r=o.settings)||void 0===r?void 0:r.display_full_address_home_page;try{var c=localStorage.getItem("_ct_app_fap_geo_full_address");if(!0===l&&c&&"null"!==c){var s=JSON.parse(c);s.lat&&s.lng&&(i="".concat(s.lat,",").concat(s.lng))}}catch(u){console.error("Failed to read full address from localStorage",u)}return!i&&e&&(i=(0,ae.rb)(e)),(0,a.Z)((0,a.Z)({},d.vf),{},{rating:"all"},i?{location:i}:{})}function me(e){return e?(Array.isArray(e)?e:[e]).map((function(e){if(!e)return null;if("string"===typeof e)try{return JSON.parse(e)}catch(t){return null}return e})).filter(Boolean):[]}function ge(e,t,n){var a=me(e).filter((function(e){return!n||n(e)})).map((function(e){return t.get(Number(null===e||void 0===e?void 0:e.field_qualification))})).filter((function(e){return Number.isFinite(e)}));return a.length?Math.min.apply(Math,(0,C.Z)(a)):null}var _e=function(){var e,t,n,i,l,s,m,g,h=(0,r.useContext)(c.a),b=h.selectedCategory,Z=h.selectedLocation,x=h.agentServices,j=h.qualifications,N=h.contractorsTray,R=h.commonSettings,k=h.algoliaSettings,I=h.setAgentType,D=h.setSelectedLocation,P=h.setSelectedCategory,A=h.setContractorsTray,F=h.setSavedFilters,T=(0,u.T)().locationDetails,O=(0,r.useRef)(null),M=(0,r.useRef)(null),H=(0,r.useRef)({key:null,hits:[],firstRes:null,displayableFacetCounts:null}),z=(0,r.useRef)({key:null,counts:null});if(!b||!b.length)return(0,f.Z)(d.kD),null;var J,U=(0,G.n3)(),V=(0,G.dk)(U),Y=(0,r.useCallback)((0,X.zC)({field_agent_type:d.AL.contractor,field_agent_services:null===b||void 0===b?void 0:b.flatMap((function(e){return e.value}))}),[b]),le=(0,y.z$)(),_e=le.pushEvent,he=le.pushEventWithGlobalData,ye=(0,ue.Z)(he),be=ye.trackFilterResults,Se=ye.initialTotalCountRef,we=ye.filterEventData,Ze="fap-results-page",xe=(0,w.BW)(Z),je=(0,r.useState)(!1),Ne=(0,o.Z)(je,2),Ce=Ne[0],Re=Ne[1],ke=(0,r.useState)(!1),Ie=(0,o.Z)(ke,2),De=Ie[0],Pe=Ie[1],Ae=(0,r.useState)(ve(Z)),Ee=(0,o.Z)(Ae,1)[0],Le=(0,r.useState)((function(){return(0,a.Z)({},ve(Z))})),Fe=(0,o.Z)(Le,2),Te=Fe[0],Oe=Fe[1],Me=(0,r.useCallback)((function(e){Oe((function(t){var n="function"===typeof e?e(t):e;return(0,G.fF)(t,n)?(0,a.Z)((0,a.Z)({},n),{},{page:0,fromHistory:void 0}):n}))}),[]),qe=(0,r.useState)({page:0,nbHits:0,totalPages:0,nbPages:0,hitsPerPage:8}),He=(0,o.Z)(qe,2),ze=He[0],Je=He[1],Be=(0,r.useState)([]),We=(0,o.Z)(Be,2),Ue=We[0],Ve=We[1],Ge=(0,r.useState)((function(){return K(b,j,{},U)})),Ye=(0,o.Z)(Ge,2),Ke=Ye[0],Qe=Ye[1],$e=(0,r.useMemo)((function(){return(0,G.qp)(j,b,ne.Z,U)}),[j,b]),Xe={field_agent_services:fe(x),certifications:fe($e)};if(1===b.length){var et=b[0].label;J="Residential Roofing"===et?"company_location_roofing":"Commercial Roofing"===et?"company_location_commercial_roofing":"Solar Roofing"===et?"company_location_solar_roofing":"Siding & Trim"===et||"Siding and Trim"===et?"company_location_siding_and_trim":"Insulation Products & Systems"===et||"Insulation Products and Systems"===et?"company_location_insulation":"company_location"}else J=null;var tt,nt=J?k.replicas.find((function(e){return e.endsWith(J)})):void 0;tt=nt||k.algolia_index;var at=k.replicas,ot=(0,r.useState)(tt),rt=(0,o.Z)(ot,2),it=rt[0],lt=rt[1],ct=(0,r.useMemo)((function(){return new Map((j||[]).map((function(e){return[Number(null===e||void 0===e?void 0:e.id),Number(null===e||void 0===e?void 0:e.weight)]})).filter((function(e){var t=(0,o.Z)(e,2),n=t[0],a=t[1];return Number.isFinite(n)&&Number.isFinite(a)})))}),[j]),st=(0,r.useMemo)((function(){return new Map((j||[]).map((function(e){return[Number(null===e||void 0===e?void 0:e.id),null===e||void 0===e?void 0:e.name]})).filter((function(e){var t=(0,o.Z)(e,2),n=t[0],a=t[1];return Number.isFinite(n)&&a})))}),[j]),ut=(0,r.useMemo)((function(){return new Map((j||[]).map((function(e){return[Number(null===e||void 0===e?void 0:e.id),((null===e||void 0===e?void 0:e.country)||"").toLowerCase()]})).filter((function(e){var t=(0,o.Z)(e,1)[0];return Number.isFinite(t)}
1)))}),[j]),dt=(0,r.useMemo)((function(){var e=Array.isArray(b)?b.flatMap((function(e){return e.value||[]})):[];if(!e.length)return null;var t=Object.values(ne.Z).filter((function(t){return e.includes(t.id)})),n=new Set;return t.forEach((function(e){(e.qualifications||[]).forEach((function(e){(0,G.JR)(null===e||void 0===e?void 0:e.id,U)&&(Array.isArray(e.label)?e.label:[e.label]).forEach((function(e){e&&n.add(e)}))}))})),n}),[b]),ft=(0,r.useState)((0,E.zu)(nt||tt)),pt=(0,o.Z)(ft,2),vt=pt[0],mt=pt[1],gt={field_agent_services:x,certifications:$e},_t={event:"vendor_details_expanded",event_origin:"front_end",business_unit_by_user:b.map((function(e){return e.label})).join(", "),vendor_type:"contractor"};(0,r.useEffect)((function(){Qe(K(b,j,{},U))}),[JSON.stringify(b),j]),(0,r.useEffect)((function(){var e=$e.map((function(e){return e.id}));localStorage.setItem("qualificationIds",e.join(","));var t=new URL(document.location).searchParams;if(t.get("agentType")&&I(t.get("agentType")),window.location.search.includes("companyLocation")){var n=t.get("field_rating")||"all",a=at.find((function(e){return e.includes(t.get("sort"))}))||tt;lt(a),mt((0,E.zu)(a)),Oe({rating:n,location:t.get("aroundLatLng"),field_agent_services:JSON.parse(t.get("facetFilters")).filter((function(e){return e.includes("field_agent_services")})),radius:JSON.parse(t.get("aroundRadius")),certifications:JSON.parse(t.get("facetFilters")).filter((function(e){return e.includes("certifications")})),page:Number(t.get("page")),hitsPerPage:Number(t.get("hitsPerPage"))})}else Oe(Ee)}),[]),localStorage.setItem("search_query",window.location.search),(0,r.useEffect)((function(){var e=function(e){var t=e.state;Object.keys(t).length?Oe((0,a.Z)((0,a.Z)({},t.filters),{},{fromHistory:!0})):Oe(Ee)};return window.addEventListener("popstate",e),function(){return window.removeEventListener("popstate",e)}}),[]),(0,r.useEffect)((function(){if(T)D(T),Oe((function(e){var t;return(0,a.Z)((0,a.Z)({},e),{},{location:(0,ae.b$)(T),placeId:null===(t=T[0])||void 0===t?void 0:t.place_id})}));else{var e=localStorage.getItem("search_query");if((e=e.slice(1)).includes("placeId")){var t=Object.fromEntries(new URLSearchParams(e));(0,S.Z)(t.placeId).then((function(e){D(e)})).catch((function(e){return console.error(e)}))}}}),[T]),(0,r.useEffect)((function(){var e=!1,t=function(){var t=(0,W.Z)((0,B.Z)().mark((function t(){var n,o,r,i,l,c,s,u,f,p,v,m,g,_,h,y,S,N,C,R,k,I,D,P,A,E,T,O,q,J,W,K,X,ae,oe,re,ie,le,ce,se,ue,de,fe,pe,ve,he,ye,Se,we,Ze,je,Ne,Ce,ke,Ie,De,Ae,Ee,Le,Fe,Me,qe,He,ze;return(0,B.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Te&&b&&Z){t.next=2;break}return t.abrupt("return");case 2:if(Re(!0),(n="fap"===new URLSearchParams(window.location.search).get("debug"))&&sessionStorage.setItem("fapDebug","1"),o=!!document.querySelector("#toolbar-administration"),r=n||o||"1"===sessionStorage.getItem("fapDebug"),i=null===Te||void 0===Te?void 0:Te.location,l=encodeURIComponent((null===Te||void 0===Te?void 0:Te.location)||""),c=localStorage.getItem("_ct_app_fap_geo_full_address"))try{(s=JSON.parse(c)).lat&&s.lng&&(i="".concat(s.lat,",").concat(s.lng),l=encodeURIComponent("".concat(s.lat,",").concat(s.lng)))}catch(B){console.error("Invalid _ct_app_fap_geo_full_address JSON",B)}u=[],"4.5"===Te.rating?u.push("field_rating>=4.5"):"4"===Te.rating&&u.push("field_rating>=4"),f=(0,G.jG)({savedCategory:b,filtersState:Te,qualifications:j,tagMapping:ne.Z,country:U}),p=(0,G.Nz)(null===Te||void 0===Te?void 0:Te.hitsPerPage),v=(0,G.qF)(null===Te||void 0===Te?void 0:Te.page),m=(0,G.qI)(b),g=(0,G.rC)(it,tt),_={page:0,hitsPerPage:p,facets:d.Ee,filters:Y,numericFilters:u,facetFilters:f,aroundLatLng:i,aroundRadius:null===Te||void 0===Te?void 0:Te.radius,attributesToRetrieve:["nid","title","url","field_number_of_reviews","field_rating","field_address","field_mail","field_phone","field_site","field_agent_services","certifications","field_company_certifications","_geoloc","field_image","fap_base_score","fap_credential_score_raw","fap_profile_score_raw","highest_level_credential","awards_score","fap_profile_score_raw","field_ctr_overall_rating","field_ctr_professionalism_rating","field_program_since","field_effective_tenure_years"]},h=null,y=null;try{(S=localStorage.getItem("_ct_app_fap_geo_full_address"))&&(N=JSON.parse(S)).lat&&N.lng&&(h=N.lat,y=N.lng)}catch(B){}if(null!==h&&null!==y||(k=(null===Z||void 0===Z||null===(C=Z[0])||void 0===C||null===(R=C.geometry)||void 0===R?void 0:R.location)||Z)&&(h="function"===typeof k.lat?k.lat():k.lat,y="function"===typeof k.lng?k.lng():k.lng),I=function(e){var t={event_origin:"front_end",vendor_name:e.title,vendor_type:"contractor",zip_code:xe,contentType:"find_a_pro_listing",business_unit_by_user:b.map((function(e){return e.label})).join(", "),includeGlobalData:!0}
1,n={vendor_called:(0,a.Z)({event:"vendor_called"},t),vendor_website_clicked:(0,a.Z)({event:"vendor_website_clicked"},t)},o=(0,L.H)(e,x,j,Z,b,xe,n),i=null;try{var l,c=JSON.parse(e.field_address||"{}");i={us:"united states",ca:"canada"}[null===c||void 0===c||null===(l=c.field_address_country)||void 0===l?void 0:l.toLowerCase()]||null}catch(B){i=null}var s=function(e){var t=Number(null===e||void 0===e?void 0:e.field_qualification);if(dt){var n=st.get(t);if(!n||!dt.has(n))return!1}if(i){var a=ut.get(t);if(a&&"international"!==a&&a!==i)return!1}return!0},u=ge(e.field_company_certifications,ct,s);if(r){o.credentialNames=me(e.field_company_certifications).map((function(e){var t=Number(null===e||void 0===e?void 0:e.field_qualification),n=st.get(t),a=ct.get(t);return n?"".concat(n,"@").concat(null!==a&&void 0!==a?a:"?"):"tid:".concat(t)})).join(" | ");var d=me(e.field_company_certifications).filter(s).map((function(e){return st.get(Number(null===e||void 0===e?void 0:e.field_qualification))})).filter(Boolean),f=function(){return"resilience360"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").toLowerCase().replace(/[^a-z0-9]+/g,"")},p=d.filter((function(e){return!f(e)})),v=p.reduce((function(e,t){return Math.max(e,function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").toUpperCase();return e.includes("PREMIER")?4.5:/\bPRO\b/.test(e)?3:e.includes("MASTER")?2:0}(t))}),0);v>0&&p.length>1&&(v+=.5),v>0&&d.some(f)&&(v+=.75),v=Math.min(v,5);var m=Number(e.fap_profile_score_raw)||0,g=Number(e.awards_score)||0,_=Number(e.field_ctr_overall_rating)||0,S=Number(e.field_ctr_professionalism_rating)||0,w=Number(e.field_program_since)||null,N=null!=e.field_effective_tenure_years?Math.floor(parseFloat(e.field_effective_tenure_years)):null,C=0;N&&N>=10&&(C=N>=30?5:N>=25?4:N>=20?3:N>=15?2:1);var R={credential:.286,profile:.238,awards:.19,ctrOverall:.095,ctrProf:.048,proximity:.143},k=function(e,t){return Math.round(e/5*t*1e3)};o.fapDebugDetails={programSince:w,tenureYears:N,ctrOverallRating:_,ctrProfessionalismRating:S,awardsScore:g,credTier:v,profileRaw:m,weights:R,ptsFn:k,breakdown:{Credential:{raw:v,weight:"28.6%",contribution:k(v,R.credential)},Profile:{raw:m,weight:"23.8%",contribution:k(m,R.profile)},Awards:{raw:g,tenureYears:N,tenurePoints:C,weight:"19.0%",contribution:k(g,R.awards)},CTROverall:{raw:_,weight:"9.5%",contribution:k(_,R.ctrOverall)},Professionalism:{raw:S,weight:"4.8%",contribution:k(S,R.ctrProf)}}}}if(h&&y&&e._geoloc){var I,D=(0,te.Z)(e._geoloc.lat,e._geoloc.lng,h,y);o.baseScore=e.fap_base_score||0,o.distanceMeters=D,o.credentialScore=null!==(I=null!==u&&void 0!==u?u:e.highest_level_credential)&&void 0!==I?I:999,o.awardsScore=e.awards_score||0,o.ratingScore=e.field_rating||0}return o},t.prev=24,q=v,J=null,!g){t.next=47;break}if(W=(0,G.Di)(Te,b,it,tt,m),H.current.key===W){t.next=37;break}return t.next=32,(0,G.MI)(vt,_,I,{filterDisplayable:m});case 32:K=t.sent,X=K.allHits,ae=K.firstRes,oe=K.displayableFacetCounts,H.current={key:W,hits:X,firstRes:ae,displayableFacetCounts:oe};case 37:re=H.current,ie=re.hits,le=re.firstRes,ce=re.displayableFacetCounts,J=ce,A=le,se=(0,G.go)(ie,v,p,it,tt,ee),E=se.pageHits,T=se.totalDisplayable,O=se.nbPages,q=se.pageIndex,t.next=55;break;case 47:return t.next=49,vt.search("",(0,a.Z)((0,a.Z)({},_),{},{page:v,hitsPerPage:p}));case 49:A=t.sent,ue=A.hits.map(I),m&&(ue=ue.filter(G.Sr)),E=ue,T=A.nbHits,O=A.nbPages;case 55:if(!e){t.next=57;break}return t.abrupt("return");case 57:if(!g||q===v){t.next=60;break}return Oe((function(e){return(0,a.Z)((0,a.Z)({},e),{},{page:q})})),t.abrupt("return");case 60:if(de=A.facets,fe=null!==(D=null===(P=J)||void 0===P?void 0:P.certifications)&&void 0!==D?D:null,!(g&&m&&(0,G.YW)(Te))){t.next=71;break}if(pe=(0,G.$W)(Te,b,it,tt,m),z.current.key===pe){t.next=70;break}return t.next=67,(0,G.MI)(vt,(0,a.Z)((0,a.Z)({},_),{},{facetFilters:(0,G.jG)({savedCategory:b,filtersState:(0,a.Z)((0,a.Z)({},Te),{},{certifications:[]}),qualifications:j,tagMapping:ne.Z,country:U})}),I,{filterDisplayable:m,storeHits:!1});case 67:he=t.sent,ye=he.displayableFacetCounts,z.current={key:pe,counts:null!==(ve=null===ye||void 0===ye?void 0:ye.certifications)&&void 0!==ve?ve:null};case 70:fe=z.current.counts;case 71:Se=(0,G.b0)(de,J,m,fe),we=E,r&&(Ze=it===tt,console.log("[FaP Debug] sortByState:",it,"defaultIndex:",tt,"isDefaultSort:",Ze,"userLat:",h,"userLng:",y),we.forEach((function(e){var t=e.fapDebugDetails;if(t){var n=!e.proximityRank||e.proximityRank<=0||e.proximityRank>10?0:5.5-.5*e.proximityRank,o={title:e.title,baseScore:e.baseScore,finalScore:e.finalScore,proximityRank:e.proximityRank,distanceMeters:e.distanceMeters,programSince:t.programSince,tenureYears:t.tenureYears,ctrOverallRating:t.ctrOverallRating,ctrProfessionalismRating:t.ctrProfessionalismRating,awardsScore:t.awardsScore,credentialScore:e.credentialScore,credentialNames:e.credentialNames,breakdown:(0,a.Z)((0,a.Z)({},t.breakdown),{},{Proximity:{raw:n,rank:e.proximityRank,weight:"14.3%",contribution:t.ptsFn(n,t.weights.proximity)}})};console.log("[FaP Raw Data]",e.title,o)}})),je={client_sort_credential:"Credential Level",client_sort_rating:"Highest Rating",client_sort_awards:"Awards Won",client_sort_distance:"Shortest Distance"},Ne=Ze?"Default (weighted)":je[it]||it,console.log("[FaP Sort] ".concat(Ne,":"),we)),Ce=(0,a.Z)((0,a.Z)({},A),{},{hits:we,nbHits:T,nbPages:O,page:g?q:v,hitsPerPage:p}),Je(Ce),Ve(we),Qe((function(e){return e.map((function(e){if("certifications"===e.name&&e.sectionKey){var t=V[e.sectionKey],n=(0,G.wV)(t,j,U);e.options=(0,G.fH)((null===Se||void 0===Se?void 0:Se.certifications)||{},n)}else"object"===typeof de&&Object.keys(de).length&&d.Ee.includes(e.name)?e.options=(0,Q.Z)(Se[e.name],gt[e.name],b,Xe?null===Xe||void 0===Xe?void 0:Xe[e.name]:Se[e.name]):"field_geofield"!==e.name&&"rating"!==e.name&&(e.options=[]);return e}))})),null!==Te&&void 0!==Te&&Te.fromHistory||(De=encodeURIComponent(b.map((function(e){return e.label})).join("|").replaceAll(/&/g,"and")),Ae=encodeURIComponent(JSON.stringify(b.map((function(e){return e.value})))),Ee=it===tt?"default":it.split("_").pop(),Le=Te.rating&&"all"!==Te.rating?"field_rating=".concat(Te.rating):"",Fe=[A.params,"categoryName=".concat(De),"categoryValue=".concat(Ae),"placeId=".concat(null===(ke=Z[0])||void 0===ke?void 0:ke.place_id),"aroundLatLng=".concat(l),"sort=".concat(Ee),Le,"companyLocation=1"].filter(
1Boolean).join("&"),Me=(0,$.uD)(Fe),qe=[{filters:Te,category:b},"","".concat(window.location.pathname,"?").concat(Me.toString())],(Ie=window.history).pushState.apply(Ie,qe),F(Me.toString())),He="".concat(b.map((function(e){return e.label})).join(", "),"-").concat(xe,"-").concat(T),M.current!==He&&(ze=(0,w.H)({productCategory:b.map((function(e){return e.label})).join(", "),contentType:"find_a_pro",zipCode:xe,vendorType:"contractor",numberOfResults:T}),_e(ze,!0),M.current=He),be(T);case 82:return t.prev=82,e||(Re(!1),Pe(!0)),t.finish(82);case 85:case"end":return t.stop()}}),t,null,[[24,,82,85]])})));return function(){return t.apply(this,arguments)}}();return t(),function(){e=!0}}),[Te,JSON.stringify(b),null===Z||void 0===Z?void 0:Z[0].place_id,vt,it]);(0,r.useEffect)((function(){ze&&0===Se.current&&(Se.current=ze.nbHits)}),[ze]);var ht={analyticData:{listingType:"find_a_pro"},meta:{totalRows:ze.nbHits,pageSize:ze.hitsPerPage,totalPages:ze.nbPages,pageNumber:ze.page},activePage:ze.page,changePage:function(e){Oe((function(t){return(0,a.Z)((0,a.Z)({},t),{},{page:e})}))},itemsPerPage:{settings:{name:"itemsPerPage",label:Drupal.t("Items per page"),hideLabel:!0,options:[{value:8,label:"8 ".concat(Drupal.t("results per page"))},{value:12,label:"12 ".concat(Drupal.t("results per page"))},{value:16,label:"16 ".concat(Drupal.t("results per page"))}],state:{itemsPerPage:null===Te||void 0===Te?void 0:Te.hitsPerPage}},onChange:function(e){Me((function(t){return(0,a.Z)((0,a.Z)({},t),{},{hitsPerPage:(0,G.Nz)(e.target.value)})}))}}},yt=(0,r.useMemo)((function(){return[{label:Drupal.t("Default"),value:tt},{label:Drupal.t("Credential Level"),value:"client_sort_credential"},{label:Drupal.t("Highest Rating"),value:"client_sort_rating"},{label:Drupal.t("Awards Won"),value:"client_sort_awards"},{label:Drupal.t("Shortest Distance"),value:"client_sort_distance"}]}),[]),bt={itemsPerPage:ze.hitsPerPage,totalResults:ze.nbHits,sortByState:it,sortByOptions:yt,setSortByState:function(e){e.startsWith("client_sort_")||mt((0,E.zu)(e)),lt(e)},showResults:!1,bottomSort:!0,showAppliedFilters:!1,showFiltersText:"More Filters",showFiltersAnalytic:function(){_e({event:"show_filter_clicked",event_origin:"front_end",content_type:"find_a_pro"})}},St=null===(e=window)||void 0===e||null===(t=e.drupalSettings)||void 0===t||null===(n=t.findAProData)||void 0===n||null===(i=n.settings)||void 0===i?void 0:i.display_full_address_home_page,wt=St?null===Z||void 0===Z||null===(l=Z[0])||void 0===l?void 0:l.formatted_address:null===Z||void 0===Z||null===(s=Z[0])||void 0===s||null===(m=s.address_components)||void 0===m||null===(g=m[0])||void 0===g?void 0:g.long_name,Zt={headline:Drupal.t("We\u2019re here to help"),description:R.no_results_text,cta:{link_url:R.no_results_button_url,link_content:R.no_results_button_label},extra:["listing__no-results-cta-banner"]},xt=function(e){var t=N;if(t.length){var n=t.filter((function(t){return t.id!==e}));A(n,x,j,Z),pe(Te,b,n)}},jt=function(){Oe((function(e){return(0,a.Z)((0,a.Z)({},e),{},{radius:d.C7})})),(0,oe.Z)(100,O.current.offsetTop-function(){for(var e=parseInt(document.querySelector("body").style.paddingTop,10)||0,t=[".header",".o-contractor-tray__title"],n=0,a=0;a<t.length;a+=1){var o=document.querySelector(t[a]);n+=!o||window.innerWidth<960?0:parseInt(o.offsetHeight,10)}return e+n}())};return(0,_.jsxs)("div",{className:(0,p.Z)(Ze,["tray--is-visible"]),children:[(0,_.jsx)(q,{contractors:N,onRemove:function(e){return xt(e)},onToggleCoupon:function(e,t){var n=(N||[]).map((function(n){return n&&n.id===e?(0,a.Z)((0,a.Z)({},n),{},{coupons:t?["premier-default"]:[]}):n}));A(n,x,j,Z)},estimateLink:"".concat(d.kD,"/get-an-estimate"),className:(0,p.Z)("contractor-tray",[],Ze,[]),offsetSelectors:"#toolbar-bar, #toolbar-item-administration-tray, .header"}),(0,_.jsxs)("div",{ref:O,className:"container",children:[(0,_.jsx)(se.Z,{title:Drupal.t("Find a Pro Results"),description:null===R||void 0===R?void 0:R.results_page_tooltip,bemBlock:Ze,onResetSearch:function(){localStorage.setItem("_ct_app_fap_geo_full_address","null"),D(null),P(null),localStorage.removeItem("_ct_app_fap_geo_full_address"),A([]),(0,f.Z)(d.kD)}}),(0,_.jsxs)(re.Z,{metaSettings:ze.hits&&ze.hits.length>0&&bt,filtersConfig:Ke,filtersClearAllBottom:!0,filtersState:Te,setFiltersState:Me,setSelectedLocation:D,clearAllCallback:function(){Oe(Ee)},pagerData:ht,resultsHeading:De&&function(){var e,t=(null===Z||void 0===Z||null===(e=Z[0])||void 0===e?void 0:e.formatted_address)||"";try{var n=localStorage.getItem("_ct_app_fap_geo_full_address");if(!0===St&&n&&"null"!==n){var a=JSON.parse(n);null!==a&&void 0!==a&&a.formatted_address&&(t=a.formatted_address)}}catch(r){console.error("Error reading full address from localStorage",r)}var o="".concat(ze.nbHits>0?"".concat(ze.nbHits," ").concat(Drupal.t("Contractors found")):Drupal.t("No results found")," ").concat(b?"".concat(Drupal.t("in")," ").concat(b.map((function(e){return e.label})).join(", ")):"");return{heading:ze.nbHits?Drupal.t("Results"):Drupal.t("No Results"),description:"".concat(o," ").concat(t?"".concat(Drupal.t("near")," ").concat(t):"",". ").concat(ze.nbHits?"":de),descriptionMobile:"<h4>".concat(o," ").concat(t?"".concat(Drupal.t("near")," ").concat(t):"","</h4>").concat(ze.nbHits?"":'<p class="results-heading__mobile-p">'.concat(de,"</p>"))}}(),showSeparateLocation:!0,showSelectedSort:!0,mods:["fap-results"],defaultLocation:wt,filtersAnalyticsData:we,children:[De&&Ue.length>0&&(0,_.jsx)("ul",{className:"fap-results-list",children:Ue.map((function(e){return(0,_.jsx)("li",{className:"fap-results-list__item",children:(0,_.jsx)(v.Z,{contractorData:e,isFindAPro:!0,showCheckBox:!0,showDefaultImage:!0,onRemove:function(){return xt(e.id)},onAdd:function(){return function(e){var t=N,n=[].concat((0,C.Z)(t),[e]);
1A(n,x,j,Z),pe(Te,b,n)}(e)},isSelected:N&&N.find((function(t){return t.id===e.id})),isButtonDisabled:N&&N.length>=d.wF,checkBockTooltip:R.contractor_tray_tooltip,analytics:{vendorDetailsExpandedAnalytics:_t}})},e.id)}))}),!Ce&&De&&!ze.hits.length&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(ie.Z,(0,a.Z)({},Zt)),Te.radius<d.C7&&(0,_.jsx)(ce,{filtersState:Te,index:vt,facets:d.Ee,maxRadius:d.C7,onCtaClick:function(){return jt()}})]})]})]})]})},he=function(){var e=(0,r.useContext)(c.a).contractorsTray,t="fap-thank-you-page";if(!e||!e.length)return null;var n=(0,A.Z)().breakpoint,a=e.map((function(){return"1fr"})).join(" ");return(0,_.jsx)("div",{className:"container",children:(0,_.jsxs)("div",{className:(0,p.Z)(t),children:[(0,_.jsx)("h5",{className:(0,p.Z)("subtitle",[],t,["h","h5"]),children:Drupal.t("Learn more about the contractors you've selected")}),(0,_.jsx)("div",{className:(0,p.Z)("contractors",[],t,[]),style:{gridTemplateColumns:n.isMobile?"1fr":a},children:e.map((function(e){return(0,_.jsx)(v.Z,{contractorData:e,isFindAPro:!0,isSmall:!0,showDefaultImage:!0,showProfileBtn:!0},e.id)}))})]})})};"undefined"!==typeof window&&"fap"===new URLSearchParams(window.location.search).get("debug")&&sessionStorage.setItem("fapDebug","1");var ye=function(e){var t,n,s,u,d=e.page,f=(0,r.useState)(null),p=(0,o.Z)(f,2),v=p[0],m=p[1],g=d||(null===(t=window)||void 0===t||null===(n=t.drupalSettings)||void 0===n||null===(s=n.findAProData)||void 0===s||null===(u=s.settings)||void 0===u?void 0:u.currentPage.split("/").pop());return(0,_.jsx)(i.Wrapper,(0,a.Z)((0,a.Z)({},l.Z),{},{callback:function(e){return m(e)},children:"SUCCESS"===v&&(0,_.jsxs)(c.Z,{children:["find-a-pro"===g&&(0,_.jsx)(P,{}),"results"===g&&(0,_.jsx)(_e,{}),"get-an-estimate"===g&&(0,_.jsx)(N,{}),"thank-you"===g&&(0,_.jsx)(he,{}),"node-page"===g&&(0,_.jsx)(J,{})]})}))}},5755:function(e,t,n){n.d(t,{Z:function(){return i}});var a=n(2791),o=function(){};var r="undefined"!==typeof window,i=function(e,t,n){if(!r)return[t,o,o];if(!e)throw new Error("useLocalStorage key may not be falsy");var i=n?n.raw?function(e){return e}:n.deserializer:JSON.parse,l=(0,a.useRef)((function(e){try{var a=n?n.raw?String:n.serializer:JSON.stringify,o=localStorage.getItem(e);return null!==o?i(o):(t&&localStorage.setItem(e,a(t)),t)}catch(c){return t}})),c=(0,a.useState)((function(){return l.current(e)})),s=c[0],u=c[1];(0,a.useLayoutEffect)((function(){return u(l.current(e))}),[e]);var d=(0,a.useCallback)((function(t){try{var a="function"===typeof t?t(s):t;if("undefined"===typeof a)return;var o=void 0;o=n?n.raw?"string"===typeof a?a:JSON.stringify(a):n.serializer?n.serializer(a):JSON.stringify(a):JSON.stringify(a),localStorage.setItem(e,o),u(i(o))}catch(c){}}),[e,u]),f=(0,a.useCallback)((function(){try{localStorage.removeItem(e),u(void 0)}catch(c){}}),[e,u]);return[s,d,f]}},8924:function(e,t,n){var a=n(4678);t.Z=function(e,t){return(0,a.Z)(e,t)}}}]); 2//# sourceMappingURL=4298.87f4878b.chunk.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.