PageSourceSearch

https://www.birdsnest.com.au/cdn/shop/t/59/assets/klaviyo-newsletter-form.js?v=142980726972552213161774326546

js birdsnest.com.au collected 2026-09-25 23:55:34 UTC 3,877 bytes, 2 lines download raw bytes

1(function(){"use strict";var KLAVIYO_SUBSCRIPTIONS_URL="https://a.klaviyo.com/client/subscriptions",KLAVIYO_REVISION="2025-10-15",MSG_EMAIL="Please enter your email address.",MSG_COMPANY_ID="Sign-up is unavailable right now.",MSG_LIST_ID="Sign-up is unavailable right now.";function getKlaviyoCompanyIdFromScript(){var el=document.querySelector('script[src*="klaviyo.js"]');if(!el||!el.src)return"";var after=el.src.split("company_id=")[1];return after?(after.split("&")[0]||"").trim():""}function showFrontEndError(form,message){var errEl=form.querySelector(".errors");errEl&&(errEl.textContent=message),form.classList.add("has-error"),form.classList.remove("has-success")}function clearFrontEndError(form){var errEl=form.querySelector(".errors");errEl&&(errEl.textContent=""),form.classList.remove("has-error"),form.classList.remove("has-success")}customElements.get("klaviyo-newsletter-form")||customElements.define("klaviyo-newsletter-form",class extends HTMLElement{constructor(){super(),this.newsletter=null,this.inputs=[],this.popup=null,this.handleSubmit=function(e){this.onSubmit(e)}.bind(this),this.refreshRefs()}connectedCallback(){this.removeEventListener("submit",this.handleSubmit,!0),this.addEventListener("submit",this.handleSubmit,!0),this.refreshRefs(),this.newsletter||console.warn("klaviyo-newsletter-form: expected a child form.newsletter-form inside <klaviyo-newsletter-form>")}disconnectedCallback(){this.removeEventListener("submit",this.handleSubmit,!0)}refreshRefs(){this.newsletter=this.querySelector("form.newsletter-form"),this.inputs=this.newsletter?Array.from(this.newsletter.querySelectorAll("input, select, textarea")):[],this.popup=this.newsletter&&this.newsletter.closest?this.newsletter.closest("[data-popup]"):null}onSubmit(event){this.refreshRefs();var form=this.newsletter;if(!(!form||event.target!==form||!(event.target instanceof HTMLFormElement))){event.preventDefault(),event.stopPropagation(),clearFrontEndError(form);var companyId=getKlaviyoCompanyIdFromScript(),listId=this.getAttribute("data-klaviyo-list-id")||"",fd=new FormData(form),email=String(fd.get("contact[email]")||"").trim(),firstName=String(fd.get("contact[first_name]")||"").trim(),lastName=String(fd.get("contact[last_name]")||"").trim();if(!email){console.error("[klaviyo-newsletter-form] email: missing or empty contact[email]"),showFrontEndError(form,MSG_EMAIL);return}if(!companyId){console.error('[klaviyo-newsletter-form] companyId: could not parse company_id from a script matching [src*="klaviyo.js"]'),showFrontEndError(form,MSG_COMPANY_ID);return}if(!listId){console.error("[klaviyo-newsletter-form] listId: missing or empty data-klaviyo-list-id on <klaviyo-newsletter-form>"),showFrontEndError(form,MSG_LIST_ID);return}var profileAttributes={email,subscriptions:{email:{marketing:{consent:"SUBSCRIBED"}}}};firstName&&(profileAttributes.first_name=firstName),lastName&&(profileAttributes.last_name=lastName);var payload={data:{type:"subscription",attributes:{profile:{data:{type:"profile",attributes:profileAttributes}}},relationships:{list:{data:{type:"list",id:listId}}}}},url=KLAVIYO_SUBSCRIPTIONS_URL+"?company_id="+encodeURIComponent(companyId);fetch(url,{method:"POST",headers:{"content-type":"application/vnd.api+json",accept:"application/vnd.api+json",revision:KLAVIYO_REVISION},body:JSON.stringify(payload)}).then(function(res){if(res.ok||res.status===202){clearFrontEndError(form),form.classList.add("has-success"),form.reset();return}console.error("[klaviyo-newsletter-form] API error:",res.status,res.statusText),showFrontEndError(form,"Something went wrong. Please try again later.")}).catch(function(err){console.error("[klaviyo-newsletter-form]",err),showFrontEndError(form,"Something went wrong. Please try again later.")})}}})})();
2//# sourceMappingURL=/cdn/shop/t/59/assets/klaviyo-newsletter-form.js.map?v=142980726972552213161774326546

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.