PageSourceSearch

https://withhark.com/widget.js

js withhark.com collected 2026-10-02 03:55:54 UTC 14,365 bytes, 176 lines download raw bytes

1"use strict";var Hark=(()=>{(function(){let m=document.currentScript?.getAttribute("data-store-id")??"",f="https://withhark.com";if(!m)return;function b(t,g){try{let k=JSON.stringify({event:t,store_id:m,properties:g});navigator.sendBeacon?navigator.sendBeacon(`${f}/api/events`,new Blob([k],{type:"application/json"})):fetch(`${f}/api/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:k,keepalive:!0}).catch(()=>{})}catch{}}if(document.getElementById("hark-widget"))return;function d(t){let g=document.createElement("div");return g.textContent=t,g.innerHTML}let c={};fetch(`${f}/api/stores/config/${m}`).then(t=>t.ok?t.json():{}).then(t=>{c=t,t.button_text&&(w.querySelector("span").textContent=t.button_text)}).catch(()=>{}),b("widget_loaded");let x=document.createElement("div");x.id="hark-widget",x.style.cssText="position:fixed;top:0;left:0;width:0;height:0;z-index:999998;pointer-events:none;",document.body.appendChild(x);let v=x.attachShadow({mode:"closed"}),z=`
2    :host { all: initial; }
3
4    @keyframes sw-overlay-in {
5      from { opacity: 0; }
6      to { opacity: 1; }
7    }
8    @keyframes sw-overlay-out {
9      from { opacity: 1; }
10      to { opacity: 0; }
11    }
12    @keyframes sw-modal-in {
13      from { opacity: 0; transform: scale(0.96) translateY(10px); }
14      to { opacity: 1; transform: scale(1) translateY(0); }
15    }
16    @keyframes sw-modal-out {
17      from { opacity: 1; transform: scale(1) translateY(0); }
18      to { opacity: 0; transform: scale(0.96) translateY(10px); }
19    }
20
21    #sw-btn {
22      pointer-events: auto;
23      position: fixed; bottom: var(--hark-btn-bottom, 20px); left: 50%; transform: translateX(-50%); z-index: 999998;
24      background: #1c1917; color: #fafaf9;
25      border: 1px solid rgba(255,255,255,0.15); border-radius: 24px;
26      padding: 10px 18px; font-size: 13px;
27      font-family: system-ui, -apple-system, sans-serif;
28      cursor: pointer; box-shadow: 0 2px 12px rgba(0,0,0,0.2);
29      transition: bottom 0.3s ease, opacity 0.15s, transform 0.15s;
30      display: inline-flex; align-items: center; gap: 6px;
31    }
32    #sw-btn:hover { opacity: 0.85; transform: translateX(-50%) scale(1.03); }
33    #sw-btn:focus-visible { outline: 2px solid #fafaf9; outline-offset: 2px; }
34    #sw-btn:active { transform: translateX(-50%) scale(0.97); }
35    #sw-btn svg { flex-shrink: 0; }
36
37    #sw-overlay {
38      pointer-events: auto;
39      position: fixed; inset: 0; z-index: 999999;
40      background: rgba(28,25,23,0.45);
41      backdrop-filter: blur(6px);
42      -webkit-backdrop-filter: blur(6px);
43      display: flex; align-items: center; justify-content: center;
44      padding: 16px;
45      font-family: system-ui, -apple-system, sans-serif;
46      animation: sw-overlay-in 0.2s ease-out both;
47    }
48    #sw-overlay.sw-closing {
49      animation: sw-overlay-out 0.15s ease-in forwards;
50    }
51
52    #sw-modal {
53      background: #fafaf9; border-radius: 12px;
54      padding: 28px; width: 100%; max-width: 400px;
55      position: relative;
56      box-shadow: 0 24px 48px -12px rgba(0,0,0,0.25), 0 0 0 1px rgba(0,0,0,0.05);
57      animation: sw-modal-in 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
58    }
59    #sw-overlay.sw-closing #sw-modal {
60      animation: sw-modal-out 0.15s ease-in forwards;
61    }
62
63    #sw-modal h2 { margin: 0 0 4px; font-size: 16px; font-weight: 600; color: #1c1917; display: inline-flex; align-items: center; gap: 6px; }
64    #sw-modal .sw-subtitle { margin: 0 0 20px; font-size: 13px; color: #78716c; }
65
66    .sw-label {
67      display: block; font-size: 11px; font-weight: 500;
68      color: #57534e; text-transform: uppercase;
69      letter-spacing: 0.05em; margin-bottom: 6px;
70    }
71    .sw-label-note { font-weight: 400; text-transform: none; letter-spacing: 0; }
72    .sw-sms-consent { display: block; font-size: 10px; color: #a8a29e; line-height: 1.4; margin-top: 4px; }
73
74    .sw-input {
75      width: 100%; box-sizing: border-box;
76      border: 1px solid #d6d3d1; border-radius: 4px;
77      padding: 8px 10px; font-size: 14px; color: #1c1917;
78      background: #fff; outline: none;
79      font-family: inherit; transition: border-color 0.15s;
80    }
81    .sw-input:focus { border-color: #1c1917; box-shadow: 0 0 0 2px rgba(28,25,23,0.15); }
82
83    #sw-product-wrap { position: relative; margin-bottom: 14px; }
84    #sw-email-wrap { margin-bottom: 14px; }
85    #sw-phone-wrap { margin-bottom: 22px; }
86    #sw-marketing-wrap {
87      display: none; margin-bottom: 18px;
88    }
89    #sw-marketing-wrap label {
90      display: flex; align-items: flex-start; gap: 8px;
91      font-size: 12px; color: #57534e; line-height: 1.4; cursor: pointer;
92    }
93    #sw-marketing-wrap input[type="checkbox"] {
94      margin-top: 2px; flex-shrink: 0; accent-color: #1c1917;
95    }
96
97    #sw-autocomplete {
98      position: absolute; left: 0; right: 0; top: 100%; margin-top: 2px;
99      background: #fff; border: 1px solid #d6d3d1; border-radius: 4px;
100      z-index: 10; max-height: 220px; overflow-y: auto;
101      box-shadow: 0 4px 12px rgba(0,0,0,0.08);
102    }
103    .sw-ac-item {
104      padding: 8px 10px; font-size: 13px; color: #1c1917; cursor: pointer;
105    }
106    .sw-ac-item:hover, .sw-ac-item[aria-selected="true"] { background: #f5f5f4; }
107
108    #sw-submit {
109      background: #1c1917; color: #fafaf9;
110      border: none; border-radius: 4px;
111      padding: 10px 16px; font-size: 13px;
112      font-family: inherit; cursor: pointer; width: 100%;
113      transition: opacity 0.15s;
114    }
115    #sw-submit:hover { opacity: 0.85; }
116    #sw-submit:disabled { opacity: 0.45;
116 cursor: not-allowed; }
117
118    #sw-close {
119      position: absolute; top: 14px; right: 16px;
120      background: none; border: none; font-size: 20px;
121      color: #a8a29e; cursor: pointer; line-height: 1; padding: 4px;
122      transition: color 0.15s;
123    }
124    #sw-close:hover { color: #1c1917; }
125
126    #sw-error {
127      background: #fef2f2; border: 1px solid #fecaca; border-radius: 4px;
128      padding: 8px 10px; font-size: 12px; color: #991b1b; line-height: 1.4;
129      margin-bottom: 14px; display: none;
130    }
131
132    #sw-thanks { text-align: center; padding: 12px 0; }
133    #sw-thanks h2 { margin: 0 0 8px; font-size: 16px; color: #1c1917; }
134    #sw-thanks p { margin: 0; font-size: 13px; color: #78716c; }
135  `,_=document.createElement("style");_.textContent=z,v.appendChild(_);let w=document.createElement("button");w.id="sw-btn",w.innerHTML='<svg width="14" height="14" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><rect x="40.96" y="40.96" width="430.08" height="430.08" rx="30.72" fill="#fafaf9"/><rect x="112" y="92" width="121" height="126" rx="10" fill="#1c1917"/><rect x="279" y="92" width="121" height="126" rx="10" fill="#1c1917"/><rect x="112" y="295" width="121" height="125" rx="10" fill="#1c1917"/><rect x="279" y="295" width="121" height="125" rx="10" fill="#1c1917"/></svg><span>Suggest a product</span>',v.appendChild(w);let r=null,y=null,I=0;function q(){I=window.scrollY,document.documentElement.style.overflow="hidden",document.body.style.overflow="hidden"}function H(){document.documentElement.style.overflow="",document.body.style.overflow=""}function B(){if(r)return;b("widget_opened"),q();let t=document.createElement("div");t.id="sw-overlay",t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label","Suggest a product");let g=c.has_logo?`<img src="${d(f+"/api/stores/"+m+"/logo")}" alt="" style="width:24px;height:24px;border-radius:6px;object-fit:cover;flex-shrink:0;" />`:"";t.innerHTML=`
136      <div id="sw-modal">
137        <button id="sw-close" aria-label="Close">&times;</button>
138        <div id="sw-form-view">
139          <h2>${g}${d(c.heading||"Suggest a product")}</h2>
140          <p class="sw-subtitle">${d(c.subheading||"Tell us what you're looking for. If enough people ask, we'll stock it.")}</p>
141          <div id="sw-product-wrap">
142            <label class="sw-label" for="sw-product">${d(c.input_label||"Product name")}</label>
143            <input id="sw-product" class="sw-input" type="text"
144              placeholder="${d(c.input_placeholder||"The thing you came here looking for...")}"
145              autocomplete="off" autocorrect="off" spellcheck="false"
146              role="combobox" aria-expanded="false" aria-controls="sw-autocomplete" aria-autocomplete="list" />
147            <div id="sw-autocomplete" role="listbox" aria-label="Suggestions" style="display:none"></div>
148          </div>
149          <div id="sw-email-wrap">
150            <label class="sw-label" for="sw-email">
151              Email <span class="sw-label-note">(optional \u2014 we'll tell you when it lands)</span>
152            </label>
153            <input id="sw-email" class="sw-input" type="email" placeholder="[email protected]" />
154          </div>
155          <div id="sw-marketing-wrap">
156            <label>
157              <input id="sw-marketing" type="checkbox" />
158              Keep me in the loop on new products and store updates
159            </label>
160          </div>
161          <div id="sw-phone-wrap">
162            <label class="sw-label" for="sw-phone">
163              Phone <span class="sw-label-note">(optional \u2014 we'll text you when it lands)</span>
164            </label>
165            <input id="sw-phone" class="sw-input" type="tel" placeholder="(555) 123-4567" />
166            <span class="sw-sms-consent">By entering your number, you consent to receive a one-time text when this item is stocked. Msg &amp; data rates may apply. Reply STOP to opt out.</span>
167          </div>
168          <div id="sw-error" role="alert"></div>
169          <button id="sw-submit" type="button">Send it</button>
170        </div>
171        <div id="sw-thanks" style="display:none">
172          <h2>${d(c.confirmation_heading||"Heard!")}</h2>
173          <p>${d(c.confirmation_body||"We'll look into stocking this. Thanks for speaking up!")}</p>
174        </div>
175      </div>
176    `,t.addEventListener("touchmove",e=>{let o=e.target,i=v.getElementById("sw-autocomplete");i&&i.contains(o)||e.preventDefault()},{passive:!1}),v.appendChild(t),r=t;let k=t.querySelector("#sw-close"),n=t.querySelector("#sw-product"),T=t.querySelector("#sw-email"),P=t.querySelector("#sw-marketing-wrap"),D=t.querySelector("#sw-marketing"),p=t.querySelector("#sw-phone"),u=t.querySelector("#sw-submit"),a=t.querySelector("#sw-autocomplete"),j=t.querySelector("#sw-form-view"),O=t.querySelector("#sw-thanks"),A=[],l=-1,M;function R(e){if(A=e,l=-1,e.length===0){a.style.display="none",n.setAttribute("aria-expanded","fal
176se"),n.removeAttribute("aria-activedescendant");return}a.textContent="",e.forEach((o,i)=>{let s=document.createElement("div");s.className="sw-ac-item",s.id=`sw-ac-item-${i}`,s.setAttribute("role","option"),s.setAttribute("aria-selected","false"),s.textContent=o,s.addEventListener("mousedown",h=>{h.preventDefault(),n.value=o,a.style.display="none",n.setAttribute("aria-expanded","false"),n.removeAttribute("aria-activedescendant")}),a.appendChild(s)}),a.style.display="block",n.setAttribute("aria-expanded","true")}function $(){a.querySelectorAll(".sw-ac-item").forEach((e,o)=>{e.setAttribute("aria-selected",String(o===l))}),l>=0?n.setAttribute("aria-activedescendant",`sw-ac-item-${l}`):n.removeAttribute("aria-activedescendant")}n.addEventListener("input",()=>{clearTimeout(M);let e=n.value.trim();if(!e){a.style.display="none",n.setAttribute("aria-expanded","false"),n.removeAttribute("aria-activedescendant");return}M=setTimeout(async()=>{try{let i=await(await fetch(`${f}/api/suggestions/autocomplete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({q:e,store_id:m})})).json();R(i)}catch{}},300)}),n.addEventListener("keydown",e=>{a.style.display!=="none"&&(e.key==="ArrowDown"?(e.preventDefault(),l=Math.min(l+1,A.length-1),$()):e.key==="ArrowUp"?(e.preventDefault(),l=Math.max(l-1,-1),$()):e.key==="Enter"&&l>=0?(e.preventDefault(),n.value=A[l],a.style.display="none",n.setAttribute("aria-expanded","false"),n.removeAttribute("aria-activedescendant")):e.key==="Escape"&&(a.style.display="none",n.setAttribute("aria-expanded","false"),n.removeAttribute("aria-activedescendant")))}),n.addEventListener("blur",()=>{setTimeout(()=>{a.style.display="none",n.setAttribute("aria-expanded","false"),n.removeAttribute("aria-activedescendant")},150)}),T.addEventListener("input",()=>{P.style.display=T.value.trim()?"block":"none"}),p.addEventListener("input",()=>{let e=p.value.replace(/\D/g,"");if(e.length===0){p.value="";return}if(e.length<=3){p.value=`(${e}`;return}if(e.length<=6){p.value=`(${e.slice(0,3)}) ${e.slice(3)}`;return}p.value=`(${e.slice(0,3)}) ${e.slice(3,6)}-${e.slice(6,10)}`});let L=t.querySelector("#sw-error");function C(e){L.textContent=e,L.style.display="block"}u.addEventListener("click",async()=>{let e=n.value.trim();if(!e){n.focus();return}L.style.display="none",u.disabled=!0,u.textContent="Sending\u2026";try{let o={store_id:m,product_name:e},i=T.value.trim();i&&(o.customer_email=i);let s=p.value.trim();s&&(o.customer_phone=s),D.checked&&i&&(o.marketing_opt_in="true");let h=await fetch(`${f}/api/suggestions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(h.ok)b("widget_submitted"),j.style.display="none",O.style.display="block",setTimeout(S,5e3);else{let K=h.status===403?"origin_blocked":`http_${h.status}`;b("widget_error",{type:K,origin:window.location.origin}),C("Something went wrong. Please try submitting on our website instead."),u.disabled=!1,u.textContent="Send it"}}catch{b("widget_error",{type:"network",origin:window.location.origin}),C("Could not connect. Please check your internet connection or try our website."),u.disabled=!1,u.textContent="Send it"}});let E=!1;function S(){!r||E||(E=!0,r.classList.add("sw-closing"),r.addEventListener("animationend",()=>{r?.remove(),r=null,E=!1,H(),w.focus()},{once:!0}),setTimeout(()=>{r?.parentNode&&(r.remove(),r=null,E=!1,H())},500),y&&document.removeEventListener("keydown",y),y=null)}k.addEventListener("click",S),t.addEventListener("click",e=>{e.target===t&&S()}),y=e=>{e.key==="Escape"&&S()},document.addEventListener("keydown",y),n.focus(),t.addEventListener("keydown",e=>{if(e.key!=="Tab")return;let o=t.querySelectorAll('button, input, [tabindex]:not([tabindex="-1"])'),i=o[0],s=o[o.length-1];e.shiftKey?e.target===i&&(e.preventDefault(),s.focus()):e.target===s&&(e.preventDefault(),i.focus())})}w.addEventListener("click",B)})();})();

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.