PageSourceSearch

https://www.anniesannuals.com/cdn/shop/t/26/assets/go-climate.js?v=94485285154817001301789528465

js anniesannuals.com collected 2026-10-02 04:20:22 UTC 8,292 bytes, 2 lines download raw bytes

1(()=>{"use strict";const FROST_TYPES={"groworganic-usd.myshopify.com":new Set(["Vegetable Seeds","Herb Seeds","Flower Seeds","Cover Crop"]),"annies-annuals-prod.myshopify.com":new Set(["Annie's Annuals","Flower Seeds"])},showProductFrost=(shop,type)=>FROST_TYPES[shop]?.has(type)===!0,majorZone=zone=>String(zone||"").replace(/[ab]$/i,""),ZIP_KEY="go_planting_zip",normalize=value=>/^\d{5}(?:-\d{4})?$/.test(value.trim())?value.trim().slice(0,5):null;let zonePromise;async function zoneLookup(zip){return window.GO_CLIMATE_PREVIEW?window.GO_CLIMATE_PREVIEW[zip]||null:(zonePromise||(zonePromise=fetch("https://cdn.shopify.com/s/files/1/0061/1391/9089/files/usda_zone.csv",{signal:AbortSignal.timeout(6e3)}).then(r=>{if(!r.ok)throw Error("Could not load zones");return r.text()}).then(csv=>new Map(csv.trim().split(/\r?\n/).slice(1).map(row=>{const[z,zone,city,state]=row.split(",");return[z.padStart(5,"0"),{zip:z.padStart(5,"0"),zone,city,state}]}))).catch(e=>{throw zonePromise=null,e})),(await zonePromise).get(zip)||null)}async function lookup(zip,endpoint){if(!endpoint)return zoneLookup(zip);try{const url=new URL("/v1/climate",endpoint);url.searchParams.set("zip",zip);const r=await fetch(url,{signal:AbortSignal.timeout(6e3)});if(r.status===404)return null;if(!r.ok)throw Error("Climate unavailable");return await r.json()}catch{const p=await zoneLookup(zip);return p?{...p,climateUnavailable:!0}:null}}function set(root,selector,value){const el=root.querySelector(selector);el&&(el.textContent=value||"")}function toggle(root,selector,show){const el=root.querySelector(selector);el&&(el.classList.toggle("hidden",!show),el.hidden=!show)}function date(value){return value?new Date(`2000-${value}T12:00:00Z`).toLocaleDateString("en-US",{month:"long",day:"numeric",timeZone:"UTC"}):"Not available"}function line(parent,label,value){const p=document.createElement("p"),strong=document.createElement("strong");strong.textContent=label+": ",p.append(strong,document.createTextNode(value)),parent.append(p)}class ClimateFinder extends HTMLElement{connectedCallback(){if(this.initialized)return;this.initialized=!0;const input=this.querySelector("[data-zip-code]"),button=this.querySelector("button");if(!input||!button)return;if(this.product=this.tagName.toLowerCase()==="get-my-zone",this.showFrost=!this.product||showProductFrost(this.dataset.shop||"groworganic-usd.myshopify.com",this.dataset.productType),this.product&&!this.dataset.zones&&!this.showFrost&&!this.dataset.chillRequirement?.trim()){this.hidden=!0;return}
1if(this.showFrost){const title=this.querySelector("[data-climate-heading]");title&&(title.textContent="Your growing zone and frost dates"),button.textContent="Check ZIP"}this.classList.add("go-climate"),this.compact=this.showFrost&&this.dataset.frostLayout==="compact";const container=this.querySelector(".zone-wrapper")||this;this.details=document.createElement("div"),this.details.className="go-climate-results",this.details.setAttribute("aria-live","polite"),container.append(this.details),this.message=document.createElement("p"),this.message.setAttribute("role","status"),container.append(this.message);try{input.value=localStorage.getItem(ZIP_KEY)||input.value}catch{}const run=async event=>{if(event.preventDefault(),button.disabled)return;const zip=normalize(input.value);if(this.details.replaceChildren(),this.classList.remove("go-climate-has-summary"),["[data-result-box]","[data-error]","[data-success]","[data-error-box]","[data-result-error]"].forEach(s=>toggle(this,s,!1)),!zip){this.message.textContent="Please enter a five-digit US ZIP code.";return}input.value=zip,button.disabled=!0,this.message.textContent="Finding your growing conditions\u2026";try{const p=await lookup(zip,this.dataset.climateEndpoint||window.GO_CLIMATE_ENDPOINT||"");if(!p){this.message.textContent="ZIP code not found. Please check the planting location ZIP.";return}try{localStorage.setItem(ZIP_KEY,zip)}catch{}this.message.textContent="",set(this,"[data-result-zip]",zip),set(this,"[data-result-zone]",majorZone(p.zone)),set(this,"[data-result-city]",p.city),set(this,"[data-result-state]",p.state),toggle(this,"[data-result-box]",!0);const zoneBox=this.querySelector("[data-zone-results]");if(zoneBox&&(zoneBox.className="_"+majorZone(p.zone)),this.product&&this.dataset.zones){const zones=this.dataset.zones.split(",").map(x=>x.trim()),match=zones.includes(p.zone)||zones.includes(p.zone.replace(/[ab]$/,"")),result=this.querySelector("[data-result-box]");result&&result.classList.toggle("success",match),set(this,match?"[data-success]":"[data-error]",match?"Within this plant\u2019s listed USDA zone range.":`Outside this plant\u2019s listed USDA zone range (Zone ${majorZone(p.zone)}).`),toggle(this,match?"[data-success]":"[data-error]",!0)}if(this.compact){this.classList.add("go-climate-has-summary");const place=document.createElement("p");place.className="go-climate-place",place.textContent=[p.city,p.state].filter(Boolean).join(", ")+" "+zip,this.details.append(place);const grid=document.createElement("div");grid.className="go-climate-grid";const entries=[["USDA zone",majorZone(p.zone)]];p.frost&&entries.push(["Last spring frost",date(p.frost.last_spring)],["First fall frost",date(p.frost.first_fall)]);for(const[label,value]of entries){const tile=document.createElement("div");tile.className="go-climate-tile";const heading=document.createElement("span");heading.className="go-climate-label",heading.textContent=label;const val=document.createElement("strong");val.textContent=value,tile.append(heading,val),grid.append(tile)}this.details.append(grid)}
1if(this.showFrost)if(p.frost){this.compact||(line(this.details,"Last spring freeze (30% risk)",date(p.frost.last_spring)),line(this.details,"First fall freeze (30% risk)",date(p.frost.first_fall)));const more=document.createElement("details"),summary=document.createElement("summary");summary.textContent="Nearby station estimate \xB7 About these dates",more.append(summary);const explanation=document.createElement("p");explanation.textContent="At this station, the historical chance of a freeze at or below 32\xB0F after the spring date is about 30%; the chance before the fall date is also about 30%. These are separate seasonal risks, not a forecast or a guarantee of safe planting. In mild climates, the fall/winter date can occur in January.",more.append(explanation);for(const risk of[10,50])p.frost[`spring_${risk}pct_risk`]&&line(more,`Spring date (${risk}% later-freeze risk)`,date(p.frost[`spring_${risk}pct_risk`])),p.frost[`fall_${risk}pct_risk`]&&line(more,`Fall date (${risk}% earlier-freeze risk)`,date(p.frost[`fall_${risk}pct_risk`]));this.details.append(more);const note=document.createElement("small");note.textContent=`NOAA ${p.frost.period}; ${p.frost.station.name}, ${p.frost.distance_km} km from the ZIP reference point. ${p.frost.note||"Local elevation and conditions affect timing."}`,more.append(note)}else line(this.details,"Frost dates","Not yet available for this ZIP.");if(this.dataset.chillEnabled==="true"&&(!this.product||this.dataset.chillRequirement?.trim())){const section=document.createElement("div");section.dataset.chillSection="",this.product&&line(section,"This plant\u2019s listed chill requirement",this.dataset.chillRequirement.trim()),p.chill?.status==="validated"?line(section,"Estimated winter chill",`${p.chill.low_hours}\u2013${p.chill.high_hours} hours. ${p.chill.model}, ${p.chill.period}.`):line(section,"Estimated winter chill","Not yet available for this ZIP."),this.details.append(section)}p.climateUnavailable&&(this.message.textContent="Your USDA zone is available. Additional climate information is temporarily unavailable."),window.dispatchEvent(new CustomEvent("go:climate-result",{detail:{zip,zone:p.zone}}))}catch{this.message.textContent="Growing conditions are temporarily unavailable. Please try again."}finally{button.disabled=!1}};button.addEventListener("click",run),input.addEventListener("keydown",e=>{e.key==="Enter"&&run(e)})}}customElements.get("find-my-zone")||customElements.define("find-my-zone",class extends ClimateFinder{}),customElements.get("get-my-zone")||customElements.define("get-my-zone",class extends ClimateFinder{})})();
2//# sourceMappingURL=/cdn/shop/t/26/assets/go-climate.js.map?v=94485285154817001301789528465

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.