blocfeed 0.15.1 → 0.15.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.15.3 — 2026-04-24
4
+
5
+ ### Improvements
6
+ - **Parent component hierarchy on rage-click events.** Detectors now capture the chain of `data-blocfeed-component` / React fiber component names from the clicked element up the DOM (up to 5 levels, deduplicated). Emitted as `event_data.parent_components: string[]` (inner → outer). Dashboard signal detail panels can now show `HeroSection → CTARow → DownloadButton` instead of just a single component name. Same treatment on HTTP-fail events for the submit button's ancestor chain.
7
+
8
+ ---
9
+
10
+ ## 0.15.2 — 2026-04-24
11
+
12
+ ### Improvements
13
+ - **Rich element context on behavioral events.** Widget detectors now capture `element_text`, `tag_name`, `element_id`, and `component_name` (React fiber) on rage-click events, plus `button_text` on HTTP-fail events. Dashboards can now display "Download for free" instead of just `div > aside > div > a`.
14
+
15
+ ---
16
+
3
17
  ## 0.15.1 — 2026-04-23
4
18
 
5
19
  ### Bug fixes
@@ -0,0 +1,2 @@
1
+ function y(){return typeof window<"u"&&typeof document<"u"}function Ue(e){let t=globalThis.CSS;return typeof t?.escape=="function"?t.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,n=>{let o=n.codePointAt(0);return o===void 0?"":`\\${o.toString(16)} `})}function we(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function Lt(e){return {x:e.x+window.scrollX,y:e.y+window.scrollY,width:e.width,height:e.height}}function Bt(e){return e.replace(/\s+/g," ").trim()}function X(e,t=140){let n=e.textContent;if(!n)return;let o=Bt(n);if(o)return o.length<=t?o:`${o.slice(0,t-1)}\u2026`}function It(e){let t=1;for(let n=e.previousElementSibling;n;n=n.previousElementSibling)n.tagName===e.tagName&&(t+=1);return t}var Xe=["data-testid","data-test-id","data-test","data-qa","data-cy"],He="data-blocfeed-component";function z(e){let t=e.closest(`[${He}]`);if(!t)return;let o=t.getAttribute(He)?.trim();return o||void 0}function oe(e,t=5){let n=[],o=e,r=0;for(;o&&r<t*4;){let i=z(o);if(i&&n[n.length-1]!==i&&(n.push(i),n.length>=t))break;o=o.parentElement,r++;}return n}function Dt(e){for(let t of Xe){let n=e.closest(`[${t}]`);if(!n)continue;let r=n.getAttribute(t)?.trim();if(r)return r}}function Ve(e){try{let t=e,n=Object.getOwnPropertyNames(t);for(let o of n)if(o.startsWith("__reactFiber$")||o.startsWith("__reactInternalInstance$")){let r=t[o];if(r&&typeof r=="object")return r}}catch{}return null}function q(e){if(e.length<=1||e.length===2&&e[0]===e[0].toLowerCase()||e.startsWith("__")&&e.endsWith("__"))return true;let t=e[0];return t>="a"&&t<="z"}function Z(e){if(e){for(let t of e)if(typeof t.name=="string"&&t.name&&!q(t.name))return t.name}}function F(e){if(e&&typeof e!="string"){if(typeof e=="function"){let t=e;return typeof t.displayName=="string"&&t.displayName?t.displayName:typeof t.name=="string"&&t.name?t.name:void 0}if(typeof e=="object"){let t=e,n=t.displayName;if(typeof n=="string"&&n)return n;let o=t.render;if(typeof o=="function"){let i=o;if(typeof i.displayName=="string"&&i.displayName)return i.displayName;if(typeof i.name=="string"&&i.name)return i.name}let r=t.type;return F(r)}}}function ve(e){let t=Ve(e);if(!t)return;let n=Z(t._debugInfo);if(n)return n;let o=t._debugOwner!==void 0;if(o){let f=t._debugOwner;for(let a=0;f&&a<50;a+=1){let d=Z(f._debugInfo);if(d)return d;let l=F(f.type)??F(f.elementType);if(l&&!q(l))return l;f=f._debugOwner;}}if(t._owner!==void 0&&t._owner!==t._debugOwner){let f=t._owner;for(let a=0;f&&a<50;a+=1){let d=Z(f._debugInfo);if(d)return d;let l=F(f.type)??F(f.elementType);if(l&&!q(l))return l;f=f._owner;}}let i=t,c=o?80:25;for(let f=0;i&&f<c;f+=1){let a=Z(i._debugInfo);if(a)return a;let d=F(i.type)??F(i.elementType);if(d&&!q(d))return d;i=i.return;}let s=e.parentElement;for(let f=0;s&&f<15;f+=1){let a=Ve(s);if(a){let d=Z(a._debugInfo);if(d)return d;let l=F(a.type)??F(a.elementType);if(l&&!q(l))return l;if(a._debugOwner){let p=F(a._debugOwner.type)??F(a._debugOwner.elementType);if(p&&!q(p))return p}if(a._owner&&a._owner!==a._debugOwner){let p=F(a._owner.type)??F(a._owner.elementType);if(p&&!q(p))return p}}s=s.parentElement;}}function Nt(e){let t=e.tagName.toLowerCase(),n=e.getAttribute("id");if(n)return `#${Ue(n)}`;for(let o of Xe){let r=e.getAttribute(o);if(r)return `${t}[${o}="${Ue(r)}"]`}return `${t}:nth-of-type(${It(e)})`}function G(e,t=10){let n=[],o=e;for(;o&&n.length<t;){let r=Nt(o);if(n.unshift(r),r.startsWith("#"))break;o=o.parentElement;}return n.join(" > ")}function qe(e,t){if(!t||t.length===0)return false;for(let n of t)if(e.closest(n))return true;return false}function ye(e,t){if(!e||qe(e,t.ignoreSelectors))return null;let n=e;for(;n;){if(qe(n,t.ignoreSelectors))return null;if(t.isSelectable?t.isSelectable(n):Ot(n))return n;n=n.parentElement;}return null}function Ot(e){let t=e.tagName;return !(t==="HTML"||t==="BODY")}function $e(e){let t=e.getBoundingClientRect(),n={selector:G(e),tagName:e.tagName.toLowerCase(),rect:we(t),pageRect:Lt(t)},o=e.getAttribute("id");o&&(n.id=o);let r=e.className;typeof r=="string"&&r.trim()&&(n.className=r);let i=X(e);i&&(n.textSnippet=i);let c=z(e)??ve(e);c&&(n.componentName=c);let s=Dt(e);return s&&(n.testId=s),n}var Ee=null;async function ze(){return Ee||(Ee=import('html-to-image')),Ee}async function Ut(e){return await new Promise((t,n)=>{let o=new Image;o.onload=()=>t({width:o.naturalWidth,height:o.naturalHeight}),o.onerror=()=>n(new Error("Failed to load generated screenshot")),o.src=e;})}async function je(e,t){let{width:n,height:o}=await Ut(e);return {dataUrl:e,mime:t,width:n,height:o}}function j(e){if(e?.aborted)throw new Error("Aborted")}function Ke(){return {async captureElement(e,t){if(!y())throw new Error("captureElement can only run in the browser");j(t.signal);let n=await ze();j(t.signal);let o=t.mime==="image/jpeg"?await n.toJpeg(e,{quality:t.quality??.92,pixelRatio:t.pixelRatio}):await n.toPng(e,{pixelRatio:t.pixelRatio});return j(t.signal),await je(o,t.mime)},async captureFullPage(e){if(!y())throw new Error("captureFullPage can only run in the browser");j(e.signal);let t=document.documentElement,n=Math.max(t.scrollWidth,t.clientWidth),o=Math.max(t.scrollHeight,t.clientHeight),r=Math.min(1,e.maxDimension/Math.max(n,o)),i=Math.max(1,Math.round(n*r)),c=Math.max(1,Math.round(o*r)),s=await ze();j(e.signal);let f=e.mime==="image/jpeg"?await s.toJpeg(t,{width:i,height:c,quality:e.quality??.92,pixelRatio:e.pixelRatio}):await s.toPng(t,{width:i,height:c,pixelRatio:e.pixelRatio});return j(e.signal),await je(f,e.mime)}}}function Ht(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return "Unknown error"}}function w(e,t,n){let o={kind:e,message:Ht(t)};return n&&(o.detail=n),o}var Vt=12e3,qt=2048,Xt=.92;function We(){return Date.now()}function $t(e){return new Promise((t,n)=>{let o=()=>n(new Error("Aborted"));if(e.aborted){o();return}e.addEventListener("abort",o,{once:true});})}async function Ze(e,t,n){let o=new Promise((i,c)=>{let s=setTimeout(()=>c(new Error("Timeout")),t);typeof s.unref=="function"&&s.unref();}),r=[e,o];return n&&r.push($t(n)),await Promise.race(r)}function zt(e){if(!y())return 1;let t=window.devicePixelRatio||1,n=e?.pixelRatio??Math.min(t,2);return Math.max(.1,n)}function jt(e){return !!(e?.element||e?.fullPage)}function Ge(e){let t={mime:e.mime,pixelRatio:e.pixelRatio,maxDimension:e.maxDimension};return e.includeQuality&&(t.quality=e.quality),e.signal&&(t.signal=e.signal),t}async function Ye(e){let{selectionElement:t,capture:n,signal:o}=e;if(!y()||!jt(n))return;let r=We(),i=[],c=n?.timeoutMs??Vt,s=n?.maxDimension??qt,f=n?.mime??"image/png",a=n?.quality??Xt,d=n?.adapter??Ke(),l={},p=zt(n);if(n?.element&&t)try{let m=t.getBoundingClientRect(),h=Math.min(1,s/Math.max(m.width,m.height)),S=Math.min(p,p*h),v=await Ze(Promise.resolve(d.captureElement(t,{...Ge({mime:f,quality:a,pixelRatio:S,maxDimension:s,includeQuality:f==="image/jpeg",...o?{signal:o}:{}})})),c,o);l.element=v;}catch(m){if(o?.aborted)throw m;i.push(w("capture_failed",m,{target:"element"}));}if(n?.fullPage)try{let m=await Ze(Promise.resolve(d.captureFullPage(Ge({mime:f,quality:a,pixelRatio:p,maxDimension:s,includeQuality:f==="image/jpeg",...o?{signal:o}:{}}))),c,o);l.fullPage=m;}catch(m){if(o?.aborted)throw m;i.push(w("capture_failed",m,{target:"fullPage"}));}let g=We(),u={startedAt:r,finishedAt:g,durationMs:Math.max(0,g-r)};return i.length>0&&(u.errors=i),{...l,diagnostics:u}}function Kt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Wt(){return y()?{url:window.location.href,title:document.title,referrer:document.referrer||void 0,userAgent:navigator.userAgent,language:navigator.language,platform:navigator.platform,viewport:{width:window.innerWidth,height:window.innerHeight},screen:{width:window.screen.width,height:window.screen.height},scroll:{x:window.scrollX,y:window.scrollY},devicePixelRatio:window.devicePixelRatio||1,timezone:Kt()}:{}}function Zt(e){if(!e)return {};let t={};return e.id&&(t.userId=e.id),e.email&&(t.userEmail=e.email),e.name&&(t.userName=e.name),t}async function Qe(e){let{config:t,context:n,user:o}=e;if(t?.enabled===false)return {};let r={...Wt(),...Zt(o)},i=t?.enrich;if(!i)return r;try{let c=await i(n);return {...r,...c}}catch(c){let s=w("unknown",c);return {...r,blocfeedMetadataError:s.message}}}var Y="blocfeed-queue",Gt=50;function _e(){if(!y())return [];try{let e=localStorage.getItem(Y);if(!e)return [];let t=JSON.parse(e);if(Array.isArray(t))return t;console.warn("[BlocFeed] offline queue was corrupt (non-array) \u2014 resetting");try{localStorage.removeItem(Y);}catch{}return []}catch(e){console.warn("[BlocFeed] offline queue could not be read \u2014 resetting",e);try{localStorage.removeItem(Y);}catch{}return []}}function Se(e){if(y())try{e.length===0?localStorage.removeItem(Y):localStorage.setItem(Y,JSON.stringify(e));}catch(t){let n=t instanceof DOMException?t.name:"";console.warn(`[BlocFeed] failed to persist offline queue${n?` (${n})`:""} \u2014 feedback may be lost if page is closed`);}}function Yt(e){let t={...e};if(t.screenshots){let n={...t.screenshots};n.element&&(n.element={...n.element,dataUrl:""}),n.fullPage&&(n.fullPage={...n.fullPage,dataUrl:""}),t.screenshots=n;}return delete t.video,t}function ke(e){let t=_e(),n=Yt(e);for(n.metadata={...n.metadata,_queued:true},t.push({payload:n,timestamp:Date.now()});t.length>Gt;)t.shift();Se(t);}function Je(){let e=_e();return e.length===0?[]:(Se([]),e.map(t=>t.payload))}function no(){Se([]);}function oo(){return _e().length}var Qt=200,Q=[],et=0,re=false;function tt(e){let t=e.target;if(!(t instanceof Element)||t.closest("[data-blocfeed-ui]"))return;let n={timestampMs:Date.now()-et,path:window.location.pathname,tagName:t.tagName.toLowerCase()},o=X(t,100);o&&(n.textSnippet=o);let r=z(t)??ve(t);r&&(n.componentName=r),Q.length<Qt&&Q.push(n);}var nt={capture:true,passive:true};function ot(){re||!y()||(re=true,Q=[],et=Date.now(),document.addEventListener("click",tt,nt));}function rt(){re&&(re=false,document.removeEventListener("click",tt,nt));}function Jt(){return [...Q]}function en(){Q=[];}var tn=3e4,nn=25e5,it="video/webm",on=250,rn=1e3,sn=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"];function st(){if(typeof MediaRecorder>"u")return null;for(let e of sn)if(MediaRecorder.isTypeSupported(e))return e;return null}function an(){return !y()||typeof navigator?.mediaDevices?.getDisplayMedia!="function"?false:st()!==null}async function Te(e){let{config:t,signal:n}=e;if(!y()||typeof navigator?.mediaDevices?.getDisplayMedia!="function")throw w("recording_failed",new Error("Screen recording is not supported in this browser"));let o=st();if(!o)throw w("recording_failed",new Error("No supported video codec found (WebM required)"));if(n?.aborted)throw w("aborted",new Error("Recording aborted before start"));let r;try{r=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1});}catch(h){let S=h instanceof DOMException&&h.name==="NotAllowedError"?"Screen share permission denied":"Failed to start screen share";throw w("recording_failed",new Error(S))}if(n?.aborted)throw r.getTracks().forEach(h=>h.stop()),w("aborted",new Error("Recording aborted after permission"));let i=t?.maxDurationMs??tn,c=t?.videoBitsPerSecond??nn,s=new MediaRecorder(r,{mimeType:o,videoBitsPerSecond:c}),f=[],a=[],d=0,l=null,p=null,g=false,u=()=>{rt(),l!==null&&(clearInterval(l),l=null),p!==null&&(clearTimeout(p),p=null),r.getTracks().forEach(h=>h.stop());},m=new Promise((h,S)=>{s.ondataavailable=R=>{R.data.size>0&&f.push(R.data);},s.onstop=()=>{if(g)return;g=true,u();let R=Date.now()-d,P=new Blob(f,{type:it}),_=URL.createObjectURL(P);h({mime:it,blobUrl:_,blob:P,durationMs:R,sizeBytes:P.size});},s.onerror=()=>{g||(g=true,u(),S(w("recording_failed",new Error("MediaRecorder error"))));};let v=r.getVideoTracks()[0];if(v&&v.addEventListener("ended",()=>{s.state!=="inactive"&&s.stop();}),n){let R=()=>{g||(g=true,s.state!=="inactive"&&s.stop(),u(),S(w("aborted",new Error("Recording aborted"))));};n.addEventListener("abort",R,{once:true});}});return s.start(rn),ot(),d=Date.now(),l=setInterval(()=>{let h=Date.now()-d;for(let S of a)S(h);},on),p=setTimeout(()=>{!g&&s.state!=="inactive"&&s.stop();},i),{result:m,stop(){!g&&s.state!=="inactive"&&s.stop();},onTick(h){a.push(h);},abort(){g||(g=true,s.state!=="inactive"&&s.stop(),u());}}}var cn=6e4,at="audio/webm",ln=250,dn=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus"];function ct(){if(typeof MediaRecorder>"u")return null;for(let e of dn)if(MediaRecorder.isTypeSupported(e))return e;return null}function un(){return !y()||typeof navigator?.mediaDevices?.getUserMedia!="function"?false:ct()!==null}async function Re(e){let{config:t,signal:n}=e;if(!y()||typeof navigator?.mediaDevices?.getUserMedia!="function")throw w("recording_failed",new Error("Microphone recording is not supported in this browser"));let o=ct();if(!o)throw w("recording_failed",new Error("No supported audio codec found"));if(n?.aborted)throw w("aborted",new Error("Voice recording aborted before start"));let r;try{r=await navigator.mediaDevices.getUserMedia({audio:!0});}catch(m){let h=m instanceof DOMException&&m.name==="NotAllowedError"?"Microphone permission denied":"Failed to access microphone";throw w("recording_failed",new Error(h))}if(n?.aborted)throw r.getTracks().forEach(m=>m.stop()),w("aborted",new Error("Voice recording aborted after permission"));let i=t?.maxDurationMs??cn,c=new MediaRecorder(r,{mimeType:o}),s=[],f=[],a=0,d=null,l=null,p=false,g=()=>{d!==null&&(clearInterval(d),d=null),l!==null&&(clearTimeout(l),l=null),r.getTracks().forEach(m=>m.stop());},u=new Promise((m,h)=>{if(c.ondataavailable=S=>{S.data.size>0&&s.push(S.data);},c.onstop=()=>{if(p)return;p=true,g();let S=Date.now()-a,v=new Blob(s,{type:at});m({blob:v,mime:at,durationMs:S});},c.onerror=()=>{p||(p=true,g(),h(w("recording_failed",new Error("MediaRecorder error"))));},n){let S=()=>{p||(p=true,c.state!=="inactive"&&c.stop(),g(),h(w("aborted",new Error("Voice recording aborted"))));};n.addEventListener("abort",S,{once:true});}});return c.start(1e3),a=Date.now(),d=setInterval(()=>{let m=Date.now()-a;for(let h of f)h(m);},ln),l=setTimeout(()=>{l=null,!p&&c.state!=="inactive"&&c.stop();},i),{result:u,stop(){!p&&c.state!=="inactive"&&c.stop();},onTick(m){f.push(m);},abort(){p||(p=true,c.state!=="inactive"&&c.stop(),g());}}}var fn=12e3,pn=2,mn=500,gn=2e3,Ce="https://blocfeed.com/api/feedback",hn="https://blocfeed.com/api/feedback/voice",lt=0,ft="blocfeed-viewer-token",pt="blocfeed-my-feedback-url";function bn(){try{return localStorage.getItem(ft)}catch{return null}}function Eo(){try{return localStorage.getItem(pt)}catch{return null}}function wn(e,t){try{localStorage.setItem(ft,e),t&&localStorage.setItem(pt,t);}catch{}}function dt(e,t){return new Promise((n,o)=>{if(t?.aborted){o(new Error("Aborted"));return}let r=setTimeout(n,e),i=()=>{clearTimeout(r),o(new Error("Aborted"));};t?.addEventListener("abort",i,{once:true});})}function vn(e){return e>=500&&e<=599}function yn(e){let[t,n]=e.split(",",2);if(!t||!n)throw new Error("Invalid data URL");let r=/data:(.*?);base64/.exec(t)?.[1]||"application/octet-stream",i=atob(n),c=new Uint8Array(i.length);for(let s=0;s<i.length;s+=1)c[s]=i.charCodeAt(s);return new Blob([c],{type:r})}function En(e){let t={},n={},o={...e};if(o.screenshots){let r={},i={...o.screenshots};i.element&&(t.element=i.element.dataUrl,r.element={mime:i.element.mime,width:i.element.width,height:i.element.height},i.element={...i.element,dataUrl:""}),i.fullPage&&(t.fullPage=i.fullPage.dataUrl,r.fullPage={mime:i.fullPage.mime,width:i.fullPage.width,height:i.fullPage.height},i.fullPage={...i.fullPage,dataUrl:""}),o.screenshots=i,(r.element||r.fullPage)&&(o.screenshot_intent=r);}return o.video&&(n.blob=o.video.blob,o.video_intent={mime:o.video.mime,durationMs:o.video.durationMs,sizeBytes:o.video.sizeBytes},delete o.video),{lean:o,extracted:t,extractedVideo:n}}async function ut(e,t,n){let o=yn(t);await fetch(e,{method:"PUT",body:o,headers:{"content-type":o.type},...n?{signal:n}:{}});}async function _n(e){let{feedbackId:t,extracted:n,screenshots:o,signal:r}=e,i={};n.element&&o?.element&&(i.element={dataUrl:n.element,mime:o.element.mime,width:o.element.width,height:o.element.height}),n.fullPage&&o?.fullPage&&(i.fullPage={dataUrl:n.fullPage,mime:o.fullPage.mime,width:o.fullPage.width,height:o.fullPage.height}),Object.keys(i).length!==0&&await fetch(`${Ce}/${t}/screenshots`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i),...r?{signal:r}:{}});}async function Sn(e){await fetch(`${Ce}/${e.feedbackId}/video`,{method:"POST",body:e.blob,headers:{"content-type":e.blob.type},...e.signal?{signal:e.signal}:{}});}async function mt(e){let{signal:t,transport:n}=e;if(Date.now()-lt<gn)return {ok:false,error:w("configuration",new Error("Please wait before submitting again"))};let r=n?.timeoutMs??fn,i=n?.maxAttempts??pn,c=n?.backoffMs??mn,s=!!(e.payload.screenshots?.element?.dataUrl||e.payload.screenshots?.fullPage?.dataUrl),f=!!e.payload.video?.blob,a=s||f,{lean:d,extracted:l,extractedVideo:p}=a?En(e.payload):{lean:e.payload,extracted:{},extractedVideo:{}},g=bn();g&&(d.viewer_token=g);let u={...l,...e.screenshotDataUrls};for(let m=1;m<=i;m+=1){let h=new AbortController,S=setTimeout(()=>h.abort(),r),v=()=>h.abort();t&&t.addEventListener("abort",v,{once:true});try{let R=await fetch(Ce,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(d),signal:h.signal});if(R.ok){lt=Date.now();let _;try{_=await R.json();}catch{}if(_?.viewer_token&&wn(_.viewer_token,_.my_feedback_url),(u.element||u.fullPage)&&_){let M=_.upload_urls;if(M){let U=[];u.element&&M.element&&U.push(ut(M.element,u.element,t)),u.fullPage&&M.fullPage&&U.push(ut(M.fullPage,u.fullPage,t));try{await Promise.all(U);}catch{}}else if(_.feedback_id)try{await _n({feedbackId:_.feedback_id,extracted:u,screenshots:e.payload.screenshots,...t?{signal:t}:{}});}catch{}}if(p.blob&&_){let M=_.upload_urls;if(M?.video)try{await fetch(M.video,{method:"PUT",body:p.blob,headers:{"content-type":p.blob.type},...t?{signal:t}:{}});}catch{}else if(_.feedback_id)try{await Sn({feedbackId:_.feedback_id,blob:p.blob,...t?{signal:t}:{}});}catch{}}let B={ok:!0,status:R.status};return _&&(B.apiResponse=_),B}if(m<i&&vn(R.status)){let _=.85+Math.random()*.3,ne=Math.round(c*2**(m-1)*_);await dt(ne,t);continue}let P=`HTTP ${R.status}`;try{let _=await R.json();_?.error&&(P=_.error);}catch{}return {ok:!1,status:R.status,error:w("api_failed",new Error(P))}}catch(R){if(h.signal.aborted||t?.aborted)return {ok:false,error:w("aborted",R)};if(m<i){let P=.85+Math.random()*.3,_=Math.round(c*2**(m-1)*P);await dt(_,t);continue}return {ok:false,error:w("api_failed",R)}}finally{clearTimeout(S),t&&t.removeEventListener("abort",v);}}return {ok:false,error:w("api_failed",new Error("Failed"))}}async function gt(e){let{blob:t,mime:n,blocfeedId:o,signal:r}=e,i=await fetch(hn,{method:"POST",headers:{"Content-Type":n,"X-Blocfeed-Id":o},body:t,...r?{signal:r}:{}});if(!i.ok){let s=await i.json().catch(()=>({error:"Unknown error"}));throw w("api_failed",new Error(s?.error??`Voice API returned ${i.status}`))}let c=await i.json();return {text:c.text??"",warning:c.warning}}var kn={enabled:true,sampling:1,ignoreSelectors:["[data-blocfeed-ui]","[data-blocfeed-ignore]"],rageClick:{enabled:true,threshold:3,windowMs:1e3},httpFail:{enabled:true,statusCodes:[400,401,403,422,500,502,503,504],ignoreUrls:["/api/behavioral-events","/api/feedback"]},redirectLoop:{enabled:true,threshold:3,windowMs:2e3},formDataLoss:{enabled:true}};function ht(e){let t=kn;return {enabled:e?.enabled??t.enabled,sampling:e?.sampling??t.sampling,ignoreSelectors:e?.ignoreSelectors??t.ignoreSelectors,rageClick:{...t.rageClick,...e?.rageClick??{}},httpFail:{...t.httpFail,...e?.httpFail??{}},redirectLoop:{...t.redirectLoop,...e?.redirectLoop??{}},formDataLoss:{...t.formDataLoss,...e?.formDataLoss??{}}}}function bt(e){let t=[];async function n(){if(t.length===0)return;let r=t.splice(0,50);try{await fetch(e.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-blocfeed-id":e.blocfeedId},body:JSON.stringify({events:r}),keepalive:!0});}catch{}}function o(){if(t.length===0)return;if(typeof navigator>"u"||typeof navigator.sendBeacon!="function"){n();return}let r=t.splice(0,50),i=new Blob([JSON.stringify({events:r})],{type:"application/json"}),c=`${e.endpoint}?_bfid=${encodeURIComponent(e.blocfeedId)}`;try{navigator.sendBeacon(c,i);}catch{}}return {enqueue(r){t.push(r);},flush:n,flushBeacon:o,size(){return t.length}}}var wt="bf_behavioral_session",ie=null;function O(){try{let e=sessionStorage.getItem(wt);if(e)return e;let t=vt();return sessionStorage.setItem(wt,t),t}catch{return ie||(ie=vt(),ie)}}function vt(){let e=Math.random().toString(36).slice(2,10).padEnd(8,"0");return `bf_${Date.now()}_${e}`}function yt(e,t){if(!e.rageClick.enabled)return ()=>{};let{threshold:n,windowMs:o}=e.rageClick,r=new Map;function i(c){try{let s=c.target;if(!s||!(s instanceof Element)||Rn(s,e.ignoreSelectors))return;let f=G(s,4);if(!f)return;let a=Date.now(),l=(r.get(f)??[]).filter(p=>a-p<=o);if(l.push(a),r.set(f,l),l.length>=n){let p=Tn(s),g=X(s,200)??null,u=s.tagName.toLowerCase(),m=s.id||null,h=z(s)??null,S=oe(s,5),v={session_id:O(),event_type:"rage_click",page_url:typeof window>"u"?"":window.location.href,selector:f,element_text:g,event_data:{click_count:l.length,window_ms:o,...p?{disabled:!0}:{},tag_name:u,...m?{element_id:m}:{},...h?{component_name:h}:{},...S.length>0?{parent_components:S}:{}},created_at:new Date().toISOString()};t(v),r.set(f,[]);}}catch{}}return document.addEventListener("click",i,{capture:true,passive:true}),()=>document.removeEventListener("click",i,{capture:true})}function Tn(e){if(e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true")return true;try{if(window.getComputedStyle(e).pointerEvents==="none")return !0}catch{}return false}function Rn(e,t){if(t.length===0)return false;for(let n of t)try{if(e.matches(n)||e.closest(n))return !0}catch{}return false}var _t=0,St=null,se=null,ae=[],Cn=1500;function An(){function e(t){try{let n=t.target;if(!n)return;let o=n.closest('button[type="submit"], input[type="submit"], [data-blocfeed-submit]');if(!o)return;_t=Date.now();let r=o.closest("form");St=(r?G(r,3):"")||null,se=X(o,100)??null,ae=oe(o,5);}catch{}}return document.addEventListener("click",e,{capture:true,passive:true}),()=>document.removeEventListener("click",e,{capture:true})}function kt(e,t){if(!e.httpFail.enabled)return ()=>{};let{statusCodes:n,ignoreUrls:o}=e.httpFail,r=new Set(n),i=An(),c=globalThis.fetch,s=async(l,p)=>{let g=typeof l=="string"?l:l instanceof URL?l.toString():l.url,u=(p?.method??l.method??"GET").toUpperCase(),m=await c.call(globalThis,l,p);try{!Et(g,o)&&r.has(m.status)&&t(d(m.status,g,u));}catch{}return m};globalThis.fetch=s;let f=XMLHttpRequest.prototype.open,a=XMLHttpRequest.prototype.send;return XMLHttpRequest.prototype.open=function(l,p,...g){return this.__bf_url=p,this.__bf_method=l.toUpperCase(),f.call(this,l,p,...g)},XMLHttpRequest.prototype.send=function(l){let p=()=>{try{let g=this.__bf_url??"",u=this.__bf_method??"GET";!Et(g,o)&&r.has(this.status)&&t(d(this.status,g,u));}catch{}};return this.__bf_handler=p,this.addEventListener("loadend",p),a.call(this,l??null)},()=>{globalThis.fetch=c,XMLHttpRequest.prototype.open=f,XMLHttpRequest.prototype.send=a,i(),se=null,ae=[];};function d(l,p,g){let m=Date.now()-_t<Cn;return {session_id:O(),event_type:"error",page_url:typeof window>"u"?"":window.location.href,selector:null,element_text:null,event_data:{http_status:l,request_url:p,method:g,form_selector:m?St:null,...m&&se?{button_text:se}:{},...m&&ae.length>0?{parent_components:ae}:{}},created_at:new Date().toISOString()}}}function Et(e,t){if(t.length===0)return false;for(let n of t)if(e.includes(n))return true;return false}var xn=3e4;function Tt(e,t){if(!e.redirectLoop.enabled)return ()=>{};if(typeof window>"u")return ()=>{};let{threshold:n,windowMs:o}=e.redirectLoop,r=new Map,i=new Map,c=history.pushState,s=history.replaceState;function f(d){try{let l=Date.now(),p=i.get(d)??0;if(l<p)return;let u=(r.get(d)??[]).filter(m=>l-m<=o);if(u.push(l),r.set(d,u),u.length>=n){let m={session_id:O(),event_type:"thrashing",page_url:window.location.href,selector:null,element_text:null,event_data:{count:u.length,url:d,window_ms:o},created_at:new Date().toISOString()};t(m),i.set(d,l+xn),r.set(d,[]);}}catch{}}function a(){let d=window.location.pathname+window.location.search;f(d);}return history.pushState=function(...d){let l=c.apply(this,d);return a(),l},history.replaceState=function(...d){let l=s.apply(this,d);return a(),l},window.addEventListener("popstate",a),()=>{history.pushState=c,history.replaceState=s,window.removeEventListener("popstate",a);}}function Rt(e,t){if(!e.formDataLoss.enabled)return ()=>{};if(typeof window>"u")return ()=>{};let n=new Set,o=0;function r(a){let d=a.closest("form");return d?d.id?`#${d.id}`:"form":null}function i(a){try{let d=a.target;if(!d||!(d instanceof HTMLInputElement||d instanceof HTMLTextAreaElement||d instanceof HTMLSelectElement))return;let l=r(d);if(!l)return;n.has(l)||n.add(l),o++;}catch{}}function c(a){if(n.size===0)return;let d=Array.from(n),l={session_id:O(),event_type:"form_abandonment",page_url:window.location.href,selector:d[0]??null,element_text:null,event_data:{cause:a,field_count:o,forms:d},created_at:new Date().toISOString()};t(l);}function s(a){a.persisted&&c("bfcache_restore");}function f(){c("beforeunload_after_edit");}return document.addEventListener("input",i,{capture:true,passive:true}),window.addEventListener("pageshow",s),window.addEventListener("beforeunload",f),()=>{document.removeEventListener("input",i,{capture:true}),window.removeEventListener("pageshow",s),window.removeEventListener("beforeunload",f);}}var Fn=5e3,ce=class{constructor(t){this.submitter=null;this.detectorUninstallers=[];this.flushTimer=null;this.pageHideHandler=null;this.installed=false;this.opts=t,this.resolved=ht(t.config);}install(){if(this.installed||!this.resolved.enabled||!(this.opts.passiveSampler??(()=>Math.random()<this.resolved.sampling))())return;let n=this.opts.endpoint??"https://blocfeed.com/api/behavioral-events";this.submitter=this.opts.submitter??bt({endpoint:n,blocfeedId:this.opts.blocfeedId});let o=r=>{this.submitter?.enqueue(r);};this.detectorUninstallers.push(yt(this.resolved,o)),this.detectorUninstallers.push(kt(this.resolved,o)),this.detectorUninstallers.push(Tt(this.resolved,o)),this.detectorUninstallers.push(Rt(this.resolved,o)),this.flushTimer=setInterval(()=>{this.submitter?.flush();},Fn),this.pageHideHandler=()=>{this.submitter?.flushBeacon();},typeof window<"u"&&window.addEventListener("pagehide",this.pageHideHandler),this.installed=true;}uninstall(){if(this.installed){for(let t of this.detectorUninstallers)try{t();}catch{}this.detectorUninstallers=[],this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null),this.pageHideHandler&&typeof window<"u"&&(window.removeEventListener("pagehide",this.pageHideHandler),this.pageHideHandler=null);try{this.submitter?.flush();}catch{}this.submitter=null,this.installed=false;}}};function Ae(e){let t=null,n=null,o=(...r)=>{n=r,t===null&&(t=requestAnimationFrame(()=>{if(t=null,!n)return;let i=n;n=null,e(...i);}));};return o.cancel=()=>{t!==null&&cancelAnimationFrame(t),t=null,n=null;},o}function le(e){return e instanceof Element?!!e.closest("[data-blocfeed-ui]"):false}function de(e){e.stopPropagation(),e.stopImmediatePropagation?.();}function Ct(e,t){if(!y())throw new Error("BlocFeed picker can only run in a browser environment.");let n=e.ignoreSelectors,o=e.isSelectable,r={};n&&n.length>0&&(r.ignoreSelectors=n),o&&(r.isSelectable=o);let i=null,c=null,s=(u,m=false)=>{if(!u){i=null,c=null,t.onHover(null);return}let h=we(u.getBoundingClientRect()),S=`${Math.round(h.x)}:${Math.round(h.y)}:${Math.round(h.width)}:${Math.round(h.height)}`;!m&&u===i&&S===c||(i=u,c=S,t.onHover({element:u,rect:h}));},f=Ae(u=>{if(le(u.target))return;let m=document.elementFromPoint(u.clientX,u.clientY),h=ye(m,r);s(h);}),a=Ae(()=>{i&&s(i,true);}),d=u=>{le(u.target)||(de(u),u.pointerType==="mouse"&&u.preventDefault());},l=u=>{le(u.target)||(de(u),u.pointerType==="mouse"&&u.preventDefault());},p=u=>{if(le(u.target))return;de(u),u.preventDefault();let m=document.elementFromPoint(u.clientX,u.clientY),h=ye(m,r);h&&t.onSelect({element:h,descriptor:$e(h)});},g=u=>{u.key==="Escape"&&(de(u),u.preventDefault(),t.onCancel());};return window.addEventListener("pointermove",f,{capture:true,passive:true}),window.addEventListener("pointerdown",d,{capture:true}),window.addEventListener("pointerup",l,{capture:true}),window.addEventListener("click",p,{capture:true}),window.addEventListener("keydown",g,{capture:true}),window.addEventListener("scroll",a,{capture:true,passive:true}),window.addEventListener("resize",a,{passive:true}),{stop(){window.removeEventListener("pointermove",f,{capture:true}),window.removeEventListener("pointerdown",d,{capture:true}),window.removeEventListener("pointerup",l,{capture:true}),window.removeEventListener("click",p,{capture:true}),window.removeEventListener("keydown",g,{capture:true}),window.removeEventListener("scroll",a,{capture:true}),window.removeEventListener("resize",a),f.cancel(),a.cancel(),t.onHover(null);}}}async function xe(e){let{signal:t,transport:n}=e,o={ok:false};try{let r={payload:e.payload,...t?{signal:t}:{},...n?{transport:n}:{}};o.api=await mt(r),o.ok=!!o.api?.ok;}catch(r){o.api={ok:false,error:w("api_failed",r)},o.ok=false;}return {payload:e.payload,result:o}}var Pn=["[data-blocfeed-ui]","[data-blocfeed-ignore]"];function Mn(e){let t=[...Pn,...e?.ignoreSelectors??[]],n=Array.from(new Set(t));return {...e,ignoreSelectors:n}}function At(){return {phase:"idle"}}function Ln(e){if(e.ok)return false;let t=e.api;return t?t.status&&t.status>=400&&t.status<500||t.error?.kind==="aborted"||t.error?.kind==="configuration"?false:!t.ok:true}function cr(e){let t=e,n=new ce({blocfeedId:t.blocfeed_id??"",...t.behavioral!==void 0?{config:t.behavioral}:{}});n.install();let o=At(),r=new Set,i=new Set,c=null,s=null,f=null,a=null,d=0,l=null,p=null,g=null,u=null,m=false,h=()=>{for(let b of r)b(o);},S=b=>{for(let E of i)E(b);},v=b=>{o=b,h();},R=()=>{d+=1,a?.abort(),a=null;},P=()=>{c?.stop(),c=null,S(null),f!==null&&y()&&(document.documentElement.style.cursor=f,f=null);},_=()=>{if(g){try{URL.revokeObjectURL(g.blobUrl);}catch{}g=null;}},ne=()=>{p&&(p.abort(),p=null),_();},B=null,M=()=>{u&&(u.abort(),u=null),B&&(B.abort(),B=null);},U=()=>{R(),P(),ne(),M(),s=null,v(At());},De=()=>{if(!y())return;P(),s=null;let b=Mn(t.picker);f=document.documentElement.style.cursor,document.documentElement.style.cursor="crosshair",v({phase:"picking"}),c=Ct(b,{onHover:S,onSelect:({element:E,descriptor:x})=>{s=E,P(),v({phase:"review",selection:x});},onCancel:()=>{U();}});},Ne=()=>{let b=Je();if(b.length!==0)for(let E of b)xe({payload:E,...t.transport?{transport:t.transport}:{}}).catch(()=>{ke(E);});};if(y()){setTimeout(Ne,1e3);let b=()=>Ne();window.addEventListener("online",b),l=()=>window.removeEventListener("online",b);}return {getState:()=>o,getConfig:()=>t,subscribe(b){return r.add(b),()=>r.delete(b)},subscribeHover(b){return i.add(b),()=>i.delete(b)},start(){o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording"||o.phase!=="picking"&&De();},stop(){U();},clearSelection(){o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording"||De();},setConfig(b){t=b;},async submit(b,E){if(!y()){let T=w("configuration",new Error("BlocFeed submit can only run in the browser"));return v({phase:"error",lastError:T}),{ok:false}}let x=t.blocfeed_id?.trim?.()??"";if(!x){let L={phase:"error",lastError:w("configuration",new Error("Missing blocfeed_id. Create a project in BlocFeed and pass its blocfeed_id."))};return o.selection&&(L.selection=o.selection),v(L),{ok:false}}if(m)return {ok:false};if(o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording")return {ok:false};m=true;let A=d+1;d=A,a?.abort(),a=new AbortController;let C=a.signal,k=o.selection,I=E?.capture?{...t.capture,...E.capture}:t.capture,H=!!(I?.element||I?.fullPage),K={phase:H?"capturing":"submitting"};k&&(K.selection=k),v(K);try{let T=H?await Ye({selectionElement:s,capture:I,signal:C}):void 0;if(C.aborted||d!==A)return {ok:!1};let L={phase:"submitting"};k&&(L.selection=k),T&&(L.capture=T),v(L);let D={};k&&(D.selection=k),T&&(D.capture=T);let W=await Qe({config:t.metadata,context:D,...t.user?{user:t.user}:{}}),V={version:1,createdAt:new Date().toISOString(),blocfeed_id:x,message:b,metadata:W};E?.category&&(V.category=E.category),t.user&&(V.user=t.user),k&&(V.selection=k),T&&(V.screenshots=T),g&&(V.video=g);let{result:N}=await xe({payload:V,signal:C,...t.transport?{transport:t.transport}:{}});if(C.aborted||d!==A)return N;if(N.ok){_(),s=null;let be={phase:"success",lastSubmit:N};return k&&(be.selection=k),T&&(be.capture=T),v(be),N}Ln(N)&&ke(V);let Mt=N.api?.error??w("unknown",new Error("Submission failed")),he={phase:"error",lastSubmit:N,lastError:Mt};return k&&(he.selection=k),T&&(he.capture=T),v(he),N}catch(T){if(C.aborted||d!==A)return {ok:false};let D={phase:"error",lastError:C.aborted?w("aborted",T):w("unknown",T)};return k&&(D.selection=k),v(D),{ok:false}}finally{m=false,d===A&&(a=null);}},async startRecording(){if(o.phase!=="review"||!t.recording?.enabled||u||p)return;let b=o.selection,E={phase:"recording",recordingElapsedMs:0};b&&(E.selection=b),v(E);try{let x={config:t.recording};a&&(x.signal=a.signal);let A=await Te(x);p=A,A.onTick(I=>{if(o.phase==="recording"){let H={phase:"recording",recordingElapsedMs:I};b&&(H.selection=b),v(H);}});let C=await A.result;p=null,g=C;let k={phase:"review",video:C};b&&(k.selection=b),v(k);}catch(x){p=null;let C={phase:"review",lastError:x?.kind?x:w("recording_failed",x)};b&&(C.selection=b),v(C);}},stopRecording(){o.phase!=="recording"||!p||p.stop();},removeVideo(){_();let b=o.selection,E={phase:"review"};b&&(E.selection=b),v(E);},async startVoice(){if(o.phase!=="review"){console.warn("[BlocFeed] startVoice: ignored \u2014 phase is",o.phase,'(expected "review")');return}let b=t.voice;if(!b?.enabled){console.warn("[BlocFeed] startVoice: ignored \u2014 voice is not enabled in config");return}if(p){console.warn("[BlocFeed] startVoice: ignored \u2014 a screen recording is already in progress");return}M();let E=o.selection,x={phase:"review",voiceRecording:true,voiceElapsedMs:0};E&&(x.selection=E),g&&(x.video=g),v(x);try{let A={config:b};a&&(A.signal=a.signal);let C=await Re(A);u=C,C.onTick(D=>{let W={phase:"review",voiceRecording:!0,voiceElapsedMs:D};E&&(W.selection=E),g&&(W.video=g),v(W);});let k=await C.result;u=null;let I={phase:"review",voiceRecording:!1,voiceTranscribing:!0};E&&(I.selection=E),g&&(I.video=g),v(I),B=new AbortController;let H={blob:k.blob,mime:k.mime,blocfeedId:t.blocfeed_id,signal:B.signal},{text:Oe,warning:K}=await gt(H);B=null;let T={phase:"review",voiceRecording:!1,voiceTranscribing:!1};E&&(T.selection=E),g&&(T.video=g),v(T);let L={text:Oe};return K&&(L.warning=K),L}catch(A){M();let C=A?.kind?A:w("recording_failed",A);console.warn("[BlocFeed] Voice error:",C.message);let k={phase:"review",voiceRecording:false,voiceTranscribing:false,lastError:C};E&&(k.selection=E),g&&(k.video=g),v(k);return}},stopVoice(){u&&u.stop();},__unsafeGetSelectedElement(){return s},destroy(){n.uninstall(),U(),r.clear(),i.clear(),l?.(),l=null;}}}var J=[],ee=[],xt=20,Ft=15,ue=[],Pt=typeof console<"u"?{log:console.log?.bind(console),warn:console.warn?.bind(console),error:console.error?.bind(console),info:console.info?.bind(console),debug:console.debug?.bind(console)}:{},fe=typeof globalThis<"u"&&typeof globalThis.fetch=="function"?globalThis.fetch:void 0,pe=typeof XMLHttpRequest<"u"?XMLHttpRequest.prototype.open:void 0,me=typeof XMLHttpRequest<"u"?XMLHttpRequest.prototype.send:void 0,Pe=new Set,Me=false,Le=false,ge=false,Bn=["blocfeed.com","google-analytics.com","googletagmanager.com","analytics.google.com","googleads.g.doubleclick.net","googlesyndication.com","googleadservices.com","google.com/pagead","google.com/ads","facebook.net","facebook.com/tr","connect.facebook.net","graph.facebook.com","api.mixpanel.com","api-js.mixpanel.com","api.amplitude.com","api2.amplitude.com","api.segment.io","cdn.segment.com","vars.hotjar.com","in.hotjar.com","script.hotjar.com","heapanalytics.com","fullstory.com/s/fs.js","rs.fullstory.com","app.posthog.com","us.posthog.com","eu.posthog.com","api-iam.intercom.io","widget.intercom.io","sentry.io/api","browser.sentry-cdn.com","browser-intake-datadoghq.com","clarity.ms","js.hs-analytics.net","api.hubapi.com","forms.hubspot.com","plausible.io/api","client.crisp.chat","js.driftt.com","r.logrocket.com","app.pendo.io","events.launchdarkly.com","app.launchdarkly.com","grammarly.com","gnar.grammarly.com","capi.grammarly.com","api.languagetool.org","api.languagetoolplus.com","fonts.googleapis.com","fonts.gstatic.com","cdn.cookielaw.org","consent.cookiebot.com","js.stripe.com","api.stripe.com/v1/tokens","google.com/recaptcha","hcaptcha.com","bam.nr-data.net","rec.smartlook.com","o2.mouseflow.com","api.luckyorange.com","static.zdassets.com","ekr.zdassets.com"];function In(e){if(e instanceof Error)return e.name&&e.name!=="Error"?`${e.name}: ${e.message}`:e.message||String(e);if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function Dn(e,t){let n=t.map(In).join(" "),o=t.find(i=>i instanceof Error),r={level:e,message:n.slice(0,2e3),timestamp:Date.now()};for(o?.stack&&(r.stack=o.stack.slice(0,2e3)),J.push(r);J.length>xt;)J.shift();}function Fe(e){let t=e.url.toLowerCase();for(let n of ue)if(t.includes(n))return;for(ee.push(e);ee.length>Ft;)ee.shift();}function ur(e={}){if(ge||!y())return;ge=true,xt=e.consoleLimit??20,Ft=e.networkLimit??15;let t=e.ignoreUrls;if(t!==void 0?ue=t.map(n=>n.toLowerCase()):ue=[...Bn],e.console!==false){let n=e.consoleLevels??["error","warn"];for(let o of n){let r=Pt[o];r&&(Pe.add(o),console[o]=(...i)=>{Dn(o,i),r.apply(console,i);});}}if(e.network!==false&&fe){let n=fe;Me=true,window.fetch=async function(r,i){let c=typeof r=="string"?r:r instanceof URL?r.toString():r.url,s=(i?.method??"GET").toUpperCase(),f=Date.now();try{let a=await n.call(window,r,i);return a.ok||Fe({url:c.slice(0,500),method:s,status:a.status,statusText:a.statusText,timestamp:f,durationMs:Date.now()-f}),a}catch(a){throw Fe({url:c.slice(0,500),method:s,status:0,statusText:a instanceof Error?a.message:"Network error",timestamp:f,durationMs:Date.now()-f}),a}};}if(e.network!==false&&pe&&me){let n=pe,o=me;Le=true,XMLHttpRequest.prototype.open=function(r,i,...c){return this.__bf_method=r.toUpperCase(),this.__bf_url=String(i),n.apply(this,[r,i,...c])},XMLHttpRequest.prototype.send=function(...r){let i=this.__bf_method||"GET",c=this.__bf_url||"",s=Date.now();return this.addEventListener("loadend",function(){if(this.status>=400||this.status===0){let f={url:c.slice(0,500),method:i,status:this.status,timestamp:s,durationMs:Date.now()-s};this.statusText&&(f.statusText=this.statusText),Fe(f);}},{once:true}),o.apply(this,r)};}}function fr(){if(ge){for(let e of Pe){let t=Pt[e];t&&(console[e]=t);}Pe.clear(),Me&&fe&&(window.fetch=fe,Me=false),Le&&pe&&me&&(XMLHttpRequest.prototype.open=pe,XMLHttpRequest.prototype.send=me,Le=false),ue=[],ge=false;}}function pr(){return {consoleLogs:[...J],networkErrors:[...ee]}}function mr(){J=[],ee=[];}var Nn=[{name:"supabase_service_role_key",pattern:/SUPABASE_SERVICE_ROLE_KEY["'=:\s]{1,8}[A-Za-z0-9_.=-]{30,400}/},{name:"supabase_db_password",pattern:/SUPABASE_DB_PASSWORD["'=:\s]{1,8}[^\s"']{6,200}/},{name:"postgres_password",pattern:/POSTGRES_PASSWORD["'=:\s]{1,8}[^\s"']{6,200}/},{name:"database_url_with_creds",pattern:/(?:postgres|postgresql|mysql|mongodb|redis|amqp):\/\/[^:\s"']{1,100}:[^@\s"']{1,200}@/},{name:"aws_access_key",pattern:/AKIA[0-9A-Z]{16}/},{name:"aws_secret_key",pattern:/AWS_SECRET_ACCESS_KEY["'=:\s]{1,8}[A-Za-z0-9/+=]{30,200}/},{name:"aws_session_token",pattern:/AWS_SESSION_TOKEN["'=:\s]{1,8}[A-Za-z0-9/+=]{30,600}/},{name:"stripe_secret_key",pattern:/sk_live_[a-zA-Z0-9]{10,200}/},{name:"stripe_secret_key_test",pattern:/sk_test_[a-zA-Z0-9]{10,200}/},{name:"stripe_restricted_key",pattern:/rk_(?:live|test)_[a-zA-Z0-9]{10,200}/},{name:"github_pat",pattern:/ghp_[A-Za-z0-9_]{36,100}/},{name:"github_oauth",pattern:/gho_[A-Za-z0-9_]{36,100}/},{name:"github_user_token",pattern:/ghu_[A-Za-z0-9_]{36,100}/},{name:"github_server_token",pattern:/ghs_[A-Za-z0-9_]{36,100}/},{name:"github_fine_grained",pattern:/github_pat_[A-Za-z0-9_]{22,200}/},{name:"openai_api_key",pattern:/sk-[a-zA-Z0-9]{20,200}(?![a-zA-Z0-9_])/},{name:"anthropic_api_key",pattern:/sk-ant-[a-zA-Z0-9\-_]{20,200}/},{name:"private_key",pattern:/-----BEGIN (?:RSA |EC |DSA |OPENSSH |PGP )?PRIVATE KEY-----/},{name:"sendgrid_api_key",pattern:/SG\.[a-zA-Z0-9_-]{22,100}\.[a-zA-Z0-9_-]{22,100}/},{name:"twilio_auth_token",pattern:/TWILIO_AUTH_TOKEN["'=:\s]{1,8}[a-f0-9]{32}/},{name:"generic_secret_key",pattern:/[A-Z_]{2,60}_SECRET_KEY["'=:\s]{1,8}[^\s"']{8,200}/},{name:"generic_secret",pattern:/[A-Z_]{2,60}_SECRET["'=:\s]{1,8}[^\s"']{8,200}/},{name:"generic_password",pattern:/[A-Z_]{2,60}_PASSWORD["'=:\s]{1,8}[^\s"']{6,200}/},{name:"generic_private_key_var",pattern:/[A-Z_]{2,60}_PRIVATE_KEY["'=:\s]{1,8}[^\s"']{8,400}/}],$=[],Ie=0,Be=false;function On(e){let t=e.slice(0,80);return t.length<=6?"***":t.slice(0,6)+"***"}function Un(e,t,n,o){if($.some(c=>c.rule===e&&c.source===t))return;let i={rule:e,source:t,hint:On(n),timestamp:Date.now()};o&&(i.location=o),$.push(i);}function te(e,t,n,o){for(let{name:r,pattern:i}of n){let c=i.exec(e);c&&Un(r,t,c[0],o);}}function Hn(e){try{let t=window;if(t.__NEXT_DATA__){let n=JSON.stringify(t.__NEXT_DATA__);te(n,"hydration",e,"__NEXT_DATA__");}if(t.__NUXT__){let n=JSON.stringify(t.__NUXT__);te(n,"hydration",e,"__NUXT__");}}catch{}}function Vn(e){try{document.querySelectorAll("script:not([src])").forEach((n,o)=>{let r=n.textContent;r&&r.length>0&&te(r,"scripts",e,`inline-script[${o}]`);});}catch{}}function qn(e){try{document.querySelectorAll("meta[content]").forEach(n=>{let o=n.getAttribute("content"),r=n.getAttribute("name")||n.getAttribute("property")||"";o&&o.length>10&&te(o,"meta",e,r?`meta[${r}]`:void 0);});}catch{}}function Xn(e){try{document.querySelectorAll("[data-api-key], [data-secret], [data-token], [data-password]").forEach(n=>{let o=n.attributes;for(let r=0;r<o.length;r++){let i=o[r];i.name.startsWith("data-")&&i.value.length>10&&te(i.value,"dom",e,`${n.tagName.toLowerCase()}[${i.name}]`);}});}catch{}}function br(e={}){if(Be||!y()||(Be=true,e.secretScan===false))return;let t=[...Nn,...e.customPatterns??[]],n=e.scanTargets??["hydration","scripts","meta","dom"];setTimeout(()=>{Ie=Date.now(),n.includes("hydration")&&Hn(t),n.includes("scripts")&&Vn(t),n.includes("meta")&&qn(t),n.includes("dom")&&Xn(t);let o=e.notify??"both";$.length>0&&(o==="console"||o==="both")&&console.warn(`[BlocFeed Security] Found ${$.length} potential secret(s) exposed in client code:`,$.map(r=>`${r.rule} (${r.source}${r.location?`: ${r.location}`:""})`));},100);}function wr(){return {findings:[...$],scannedAt:Ie}}function vr(){$=[],Ie=0,Be=false;}
2
+ export{vr as A,y as a,we as b,Ke as c,Ye as d,Qe as e,ke as f,Je as g,no as h,oo as i,Jt as j,en as k,an as l,Te as m,un as n,Re as o,bn as p,Eo as q,gt as r,ce as s,cr as t,ur as u,fr as v,pr as w,mr as x,br as y,wr as z};
@@ -0,0 +1,2 @@
1
+ 'use strict';function y(){return typeof window<"u"&&typeof document<"u"}function Ue(e){let t=globalThis.CSS;return typeof t?.escape=="function"?t.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,n=>{let o=n.codePointAt(0);return o===void 0?"":`\\${o.toString(16)} `})}function we(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function Lt(e){return {x:e.x+window.scrollX,y:e.y+window.scrollY,width:e.width,height:e.height}}function Bt(e){return e.replace(/\s+/g," ").trim()}function X(e,t=140){let n=e.textContent;if(!n)return;let o=Bt(n);if(o)return o.length<=t?o:`${o.slice(0,t-1)}\u2026`}function It(e){let t=1;for(let n=e.previousElementSibling;n;n=n.previousElementSibling)n.tagName===e.tagName&&(t+=1);return t}var Xe=["data-testid","data-test-id","data-test","data-qa","data-cy"],He="data-blocfeed-component";function z(e){let t=e.closest(`[${He}]`);if(!t)return;let o=t.getAttribute(He)?.trim();return o||void 0}function oe(e,t=5){let n=[],o=e,r=0;for(;o&&r<t*4;){let i=z(o);if(i&&n[n.length-1]!==i&&(n.push(i),n.length>=t))break;o=o.parentElement,r++;}return n}function Dt(e){for(let t of Xe){let n=e.closest(`[${t}]`);if(!n)continue;let r=n.getAttribute(t)?.trim();if(r)return r}}function Ve(e){try{let t=e,n=Object.getOwnPropertyNames(t);for(let o of n)if(o.startsWith("__reactFiber$")||o.startsWith("__reactInternalInstance$")){let r=t[o];if(r&&typeof r=="object")return r}}catch{}return null}function q(e){if(e.length<=1||e.length===2&&e[0]===e[0].toLowerCase()||e.startsWith("__")&&e.endsWith("__"))return true;let t=e[0];return t>="a"&&t<="z"}function Z(e){if(e){for(let t of e)if(typeof t.name=="string"&&t.name&&!q(t.name))return t.name}}function F(e){if(e&&typeof e!="string"){if(typeof e=="function"){let t=e;return typeof t.displayName=="string"&&t.displayName?t.displayName:typeof t.name=="string"&&t.name?t.name:void 0}if(typeof e=="object"){let t=e,n=t.displayName;if(typeof n=="string"&&n)return n;let o=t.render;if(typeof o=="function"){let i=o;if(typeof i.displayName=="string"&&i.displayName)return i.displayName;if(typeof i.name=="string"&&i.name)return i.name}let r=t.type;return F(r)}}}function ve(e){let t=Ve(e);if(!t)return;let n=Z(t._debugInfo);if(n)return n;let o=t._debugOwner!==void 0;if(o){let f=t._debugOwner;for(let a=0;f&&a<50;a+=1){let d=Z(f._debugInfo);if(d)return d;let l=F(f.type)??F(f.elementType);if(l&&!q(l))return l;f=f._debugOwner;}}if(t._owner!==void 0&&t._owner!==t._debugOwner){let f=t._owner;for(let a=0;f&&a<50;a+=1){let d=Z(f._debugInfo);if(d)return d;let l=F(f.type)??F(f.elementType);if(l&&!q(l))return l;f=f._owner;}}let i=t,c=o?80:25;for(let f=0;i&&f<c;f+=1){let a=Z(i._debugInfo);if(a)return a;let d=F(i.type)??F(i.elementType);if(d&&!q(d))return d;i=i.return;}let s=e.parentElement;for(let f=0;s&&f<15;f+=1){let a=Ve(s);if(a){let d=Z(a._debugInfo);if(d)return d;let l=F(a.type)??F(a.elementType);if(l&&!q(l))return l;if(a._debugOwner){let p=F(a._debugOwner.type)??F(a._debugOwner.elementType);if(p&&!q(p))return p}if(a._owner&&a._owner!==a._debugOwner){let p=F(a._owner.type)??F(a._owner.elementType);if(p&&!q(p))return p}}s=s.parentElement;}}function Nt(e){let t=e.tagName.toLowerCase(),n=e.getAttribute("id");if(n)return `#${Ue(n)}`;for(let o of Xe){let r=e.getAttribute(o);if(r)return `${t}[${o}="${Ue(r)}"]`}return `${t}:nth-of-type(${It(e)})`}function G(e,t=10){let n=[],o=e;for(;o&&n.length<t;){let r=Nt(o);if(n.unshift(r),r.startsWith("#"))break;o=o.parentElement;}return n.join(" > ")}function qe(e,t){if(!t||t.length===0)return false;for(let n of t)if(e.closest(n))return true;return false}function ye(e,t){if(!e||qe(e,t.ignoreSelectors))return null;let n=e;for(;n;){if(qe(n,t.ignoreSelectors))return null;if(t.isSelectable?t.isSelectable(n):Ot(n))return n;n=n.parentElement;}return null}function Ot(e){let t=e.tagName;return !(t==="HTML"||t==="BODY")}function $e(e){let t=e.getBoundingClientRect(),n={selector:G(e),tagName:e.tagName.toLowerCase(),rect:we(t),pageRect:Lt(t)},o=e.getAttribute("id");o&&(n.id=o);let r=e.className;typeof r=="string"&&r.trim()&&(n.className=r);let i=X(e);i&&(n.textSnippet=i);let c=z(e)??ve(e);c&&(n.componentName=c);let s=Dt(e);return s&&(n.testId=s),n}var Ee=null;async function ze(){return Ee||(Ee=import('html-to-image')),Ee}async function Ut(e){return await new Promise((t,n)=>{let o=new Image;o.onload=()=>t({width:o.naturalWidth,height:o.naturalHeight}),o.onerror=()=>n(new Error("Failed to load generated screenshot")),o.src=e;})}async function je(e,t){let{width:n,height:o}=await Ut(e);return {dataUrl:e,mime:t,width:n,height:o}}function j(e){if(e?.aborted)throw new Error("Aborted")}function Ke(){return {async captureElement(e,t){if(!y())throw new Error("captureElement can only run in the browser");j(t.signal);let n=await ze();j(t.signal);let o=t.mime==="image/jpeg"?await n.toJpeg(e,{quality:t.quality??.92,pixelRatio:t.pixelRatio}):await n.toPng(e,{pixelRatio:t.pixelRatio});return j(t.signal),await je(o,t.mime)},async captureFullPage(e){if(!y())throw new Error("captureFullPage can only run in the browser");j(e.signal);let t=document.documentElement,n=Math.max(t.scrollWidth,t.clientWidth),o=Math.max(t.scrollHeight,t.clientHeight),r=Math.min(1,e.maxDimension/Math.max(n,o)),i=Math.max(1,Math.round(n*r)),c=Math.max(1,Math.round(o*r)),s=await ze();j(e.signal);let f=e.mime==="image/jpeg"?await s.toJpeg(t,{width:i,height:c,quality:e.quality??.92,pixelRatio:e.pixelRatio}):await s.toPng(t,{width:i,height:c,pixelRatio:e.pixelRatio});return j(e.signal),await je(f,e.mime)}}}function Ht(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return "Unknown error"}}function w(e,t,n){let o={kind:e,message:Ht(t)};return n&&(o.detail=n),o}var Vt=12e3,qt=2048,Xt=.92;function We(){return Date.now()}function $t(e){return new Promise((t,n)=>{let o=()=>n(new Error("Aborted"));if(e.aborted){o();return}e.addEventListener("abort",o,{once:true});})}async function Ze(e,t,n){let o=new Promise((i,c)=>{let s=setTimeout(()=>c(new Error("Timeout")),t);typeof s.unref=="function"&&s.unref();}),r=[e,o];return n&&r.push($t(n)),await Promise.race(r)}function zt(e){if(!y())return 1;let t=window.devicePixelRatio||1,n=e?.pixelRatio??Math.min(t,2);return Math.max(.1,n)}function jt(e){return !!(e?.element||e?.fullPage)}function Ge(e){let t={mime:e.mime,pixelRatio:e.pixelRatio,maxDimension:e.maxDimension};return e.includeQuality&&(t.quality=e.quality),e.signal&&(t.signal=e.signal),t}async function Ye(e){let{selectionElement:t,capture:n,signal:o}=e;if(!y()||!jt(n))return;let r=We(),i=[],c=n?.timeoutMs??Vt,s=n?.maxDimension??qt,f=n?.mime??"image/png",a=n?.quality??Xt,d=n?.adapter??Ke(),l={},p=zt(n);if(n?.element&&t)try{let m=t.getBoundingClientRect(),h=Math.min(1,s/Math.max(m.width,m.height)),S=Math.min(p,p*h),v=await Ze(Promise.resolve(d.captureElement(t,{...Ge({mime:f,quality:a,pixelRatio:S,maxDimension:s,includeQuality:f==="image/jpeg",...o?{signal:o}:{}})})),c,o);l.element=v;}catch(m){if(o?.aborted)throw m;i.push(w("capture_failed",m,{target:"element"}));}if(n?.fullPage)try{let m=await Ze(Promise.resolve(d.captureFullPage(Ge({mime:f,quality:a,pixelRatio:p,maxDimension:s,includeQuality:f==="image/jpeg",...o?{signal:o}:{}}))),c,o);l.fullPage=m;}catch(m){if(o?.aborted)throw m;i.push(w("capture_failed",m,{target:"fullPage"}));}let g=We(),u={startedAt:r,finishedAt:g,durationMs:Math.max(0,g-r)};return i.length>0&&(u.errors=i),{...l,diagnostics:u}}function Kt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Wt(){return y()?{url:window.location.href,title:document.title,referrer:document.referrer||void 0,userAgent:navigator.userAgent,language:navigator.language,platform:navigator.platform,viewport:{width:window.innerWidth,height:window.innerHeight},screen:{width:window.screen.width,height:window.screen.height},scroll:{x:window.scrollX,y:window.scrollY},devicePixelRatio:window.devicePixelRatio||1,timezone:Kt()}:{}}function Zt(e){if(!e)return {};let t={};return e.id&&(t.userId=e.id),e.email&&(t.userEmail=e.email),e.name&&(t.userName=e.name),t}async function Qe(e){let{config:t,context:n,user:o}=e;if(t?.enabled===false)return {};let r={...Wt(),...Zt(o)},i=t?.enrich;if(!i)return r;try{let c=await i(n);return {...r,...c}}catch(c){let s=w("unknown",c);return {...r,blocfeedMetadataError:s.message}}}var Y="blocfeed-queue",Gt=50;function _e(){if(!y())return [];try{let e=localStorage.getItem(Y);if(!e)return [];let t=JSON.parse(e);if(Array.isArray(t))return t;console.warn("[BlocFeed] offline queue was corrupt (non-array) \u2014 resetting");try{localStorage.removeItem(Y);}catch{}return []}catch(e){console.warn("[BlocFeed] offline queue could not be read \u2014 resetting",e);try{localStorage.removeItem(Y);}catch{}return []}}function Se(e){if(y())try{e.length===0?localStorage.removeItem(Y):localStorage.setItem(Y,JSON.stringify(e));}catch(t){let n=t instanceof DOMException?t.name:"";console.warn(`[BlocFeed] failed to persist offline queue${n?` (${n})`:""} \u2014 feedback may be lost if page is closed`);}}function Yt(e){let t={...e};if(t.screenshots){let n={...t.screenshots};n.element&&(n.element={...n.element,dataUrl:""}),n.fullPage&&(n.fullPage={...n.fullPage,dataUrl:""}),t.screenshots=n;}return delete t.video,t}function ke(e){let t=_e(),n=Yt(e);for(n.metadata={...n.metadata,_queued:true},t.push({payload:n,timestamp:Date.now()});t.length>Gt;)t.shift();Se(t);}function Je(){let e=_e();return e.length===0?[]:(Se([]),e.map(t=>t.payload))}function no(){Se([]);}function oo(){return _e().length}var Qt=200,Q=[],et=0,re=false;function tt(e){let t=e.target;if(!(t instanceof Element)||t.closest("[data-blocfeed-ui]"))return;let n={timestampMs:Date.now()-et,path:window.location.pathname,tagName:t.tagName.toLowerCase()},o=X(t,100);o&&(n.textSnippet=o);let r=z(t)??ve(t);r&&(n.componentName=r),Q.length<Qt&&Q.push(n);}var nt={capture:true,passive:true};function ot(){re||!y()||(re=true,Q=[],et=Date.now(),document.addEventListener("click",tt,nt));}function rt(){re&&(re=false,document.removeEventListener("click",tt,nt));}function Jt(){return [...Q]}function en(){Q=[];}var tn=3e4,nn=25e5,it="video/webm",on=250,rn=1e3,sn=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"];function st(){if(typeof MediaRecorder>"u")return null;for(let e of sn)if(MediaRecorder.isTypeSupported(e))return e;return null}function an(){return !y()||typeof navigator?.mediaDevices?.getDisplayMedia!="function"?false:st()!==null}async function Te(e){let{config:t,signal:n}=e;if(!y()||typeof navigator?.mediaDevices?.getDisplayMedia!="function")throw w("recording_failed",new Error("Screen recording is not supported in this browser"));let o=st();if(!o)throw w("recording_failed",new Error("No supported video codec found (WebM required)"));if(n?.aborted)throw w("aborted",new Error("Recording aborted before start"));let r;try{r=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1});}catch(h){let S=h instanceof DOMException&&h.name==="NotAllowedError"?"Screen share permission denied":"Failed to start screen share";throw w("recording_failed",new Error(S))}if(n?.aborted)throw r.getTracks().forEach(h=>h.stop()),w("aborted",new Error("Recording aborted after permission"));let i=t?.maxDurationMs??tn,c=t?.videoBitsPerSecond??nn,s=new MediaRecorder(r,{mimeType:o,videoBitsPerSecond:c}),f=[],a=[],d=0,l=null,p=null,g=false,u=()=>{rt(),l!==null&&(clearInterval(l),l=null),p!==null&&(clearTimeout(p),p=null),r.getTracks().forEach(h=>h.stop());},m=new Promise((h,S)=>{s.ondataavailable=R=>{R.data.size>0&&f.push(R.data);},s.onstop=()=>{if(g)return;g=true,u();let R=Date.now()-d,P=new Blob(f,{type:it}),_=URL.createObjectURL(P);h({mime:it,blobUrl:_,blob:P,durationMs:R,sizeBytes:P.size});},s.onerror=()=>{g||(g=true,u(),S(w("recording_failed",new Error("MediaRecorder error"))));};let v=r.getVideoTracks()[0];if(v&&v.addEventListener("ended",()=>{s.state!=="inactive"&&s.stop();}),n){let R=()=>{g||(g=true,s.state!=="inactive"&&s.stop(),u(),S(w("aborted",new Error("Recording aborted"))));};n.addEventListener("abort",R,{once:true});}});return s.start(rn),ot(),d=Date.now(),l=setInterval(()=>{let h=Date.now()-d;for(let S of a)S(h);},on),p=setTimeout(()=>{!g&&s.state!=="inactive"&&s.stop();},i),{result:m,stop(){!g&&s.state!=="inactive"&&s.stop();},onTick(h){a.push(h);},abort(){g||(g=true,s.state!=="inactive"&&s.stop(),u());}}}var cn=6e4,at="audio/webm",ln=250,dn=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus"];function ct(){if(typeof MediaRecorder>"u")return null;for(let e of dn)if(MediaRecorder.isTypeSupported(e))return e;return null}function un(){return !y()||typeof navigator?.mediaDevices?.getUserMedia!="function"?false:ct()!==null}async function Re(e){let{config:t,signal:n}=e;if(!y()||typeof navigator?.mediaDevices?.getUserMedia!="function")throw w("recording_failed",new Error("Microphone recording is not supported in this browser"));let o=ct();if(!o)throw w("recording_failed",new Error("No supported audio codec found"));if(n?.aborted)throw w("aborted",new Error("Voice recording aborted before start"));let r;try{r=await navigator.mediaDevices.getUserMedia({audio:!0});}catch(m){let h=m instanceof DOMException&&m.name==="NotAllowedError"?"Microphone permission denied":"Failed to access microphone";throw w("recording_failed",new Error(h))}if(n?.aborted)throw r.getTracks().forEach(m=>m.stop()),w("aborted",new Error("Voice recording aborted after permission"));let i=t?.maxDurationMs??cn,c=new MediaRecorder(r,{mimeType:o}),s=[],f=[],a=0,d=null,l=null,p=false,g=()=>{d!==null&&(clearInterval(d),d=null),l!==null&&(clearTimeout(l),l=null),r.getTracks().forEach(m=>m.stop());},u=new Promise((m,h)=>{if(c.ondataavailable=S=>{S.data.size>0&&s.push(S.data);},c.onstop=()=>{if(p)return;p=true,g();let S=Date.now()-a,v=new Blob(s,{type:at});m({blob:v,mime:at,durationMs:S});},c.onerror=()=>{p||(p=true,g(),h(w("recording_failed",new Error("MediaRecorder error"))));},n){let S=()=>{p||(p=true,c.state!=="inactive"&&c.stop(),g(),h(w("aborted",new Error("Voice recording aborted"))));};n.addEventListener("abort",S,{once:true});}});return c.start(1e3),a=Date.now(),d=setInterval(()=>{let m=Date.now()-a;for(let h of f)h(m);},ln),l=setTimeout(()=>{l=null,!p&&c.state!=="inactive"&&c.stop();},i),{result:u,stop(){!p&&c.state!=="inactive"&&c.stop();},onTick(m){f.push(m);},abort(){p||(p=true,c.state!=="inactive"&&c.stop(),g());}}}var fn=12e3,pn=2,mn=500,gn=2e3,Ce="https://blocfeed.com/api/feedback",hn="https://blocfeed.com/api/feedback/voice",lt=0,ft="blocfeed-viewer-token",pt="blocfeed-my-feedback-url";function bn(){try{return localStorage.getItem(ft)}catch{return null}}function Eo(){try{return localStorage.getItem(pt)}catch{return null}}function wn(e,t){try{localStorage.setItem(ft,e),t&&localStorage.setItem(pt,t);}catch{}}function dt(e,t){return new Promise((n,o)=>{if(t?.aborted){o(new Error("Aborted"));return}let r=setTimeout(n,e),i=()=>{clearTimeout(r),o(new Error("Aborted"));};t?.addEventListener("abort",i,{once:true});})}function vn(e){return e>=500&&e<=599}function yn(e){let[t,n]=e.split(",",2);if(!t||!n)throw new Error("Invalid data URL");let r=/data:(.*?);base64/.exec(t)?.[1]||"application/octet-stream",i=atob(n),c=new Uint8Array(i.length);for(let s=0;s<i.length;s+=1)c[s]=i.charCodeAt(s);return new Blob([c],{type:r})}function En(e){let t={},n={},o={...e};if(o.screenshots){let r={},i={...o.screenshots};i.element&&(t.element=i.element.dataUrl,r.element={mime:i.element.mime,width:i.element.width,height:i.element.height},i.element={...i.element,dataUrl:""}),i.fullPage&&(t.fullPage=i.fullPage.dataUrl,r.fullPage={mime:i.fullPage.mime,width:i.fullPage.width,height:i.fullPage.height},i.fullPage={...i.fullPage,dataUrl:""}),o.screenshots=i,(r.element||r.fullPage)&&(o.screenshot_intent=r);}return o.video&&(n.blob=o.video.blob,o.video_intent={mime:o.video.mime,durationMs:o.video.durationMs,sizeBytes:o.video.sizeBytes},delete o.video),{lean:o,extracted:t,extractedVideo:n}}async function ut(e,t,n){let o=yn(t);await fetch(e,{method:"PUT",body:o,headers:{"content-type":o.type},...n?{signal:n}:{}});}async function _n(e){let{feedbackId:t,extracted:n,screenshots:o,signal:r}=e,i={};n.element&&o?.element&&(i.element={dataUrl:n.element,mime:o.element.mime,width:o.element.width,height:o.element.height}),n.fullPage&&o?.fullPage&&(i.fullPage={dataUrl:n.fullPage,mime:o.fullPage.mime,width:o.fullPage.width,height:o.fullPage.height}),Object.keys(i).length!==0&&await fetch(`${Ce}/${t}/screenshots`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i),...r?{signal:r}:{}});}async function Sn(e){await fetch(`${Ce}/${e.feedbackId}/video`,{method:"POST",body:e.blob,headers:{"content-type":e.blob.type},...e.signal?{signal:e.signal}:{}});}async function mt(e){let{signal:t,transport:n}=e;if(Date.now()-lt<gn)return {ok:false,error:w("configuration",new Error("Please wait before submitting again"))};let r=n?.timeoutMs??fn,i=n?.maxAttempts??pn,c=n?.backoffMs??mn,s=!!(e.payload.screenshots?.element?.dataUrl||e.payload.screenshots?.fullPage?.dataUrl),f=!!e.payload.video?.blob,a=s||f,{lean:d,extracted:l,extractedVideo:p}=a?En(e.payload):{lean:e.payload,extracted:{},extractedVideo:{}},g=bn();g&&(d.viewer_token=g);let u={...l,...e.screenshotDataUrls};for(let m=1;m<=i;m+=1){let h=new AbortController,S=setTimeout(()=>h.abort(),r),v=()=>h.abort();t&&t.addEventListener("abort",v,{once:true});try{let R=await fetch(Ce,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(d),signal:h.signal});if(R.ok){lt=Date.now();let _;try{_=await R.json();}catch{}if(_?.viewer_token&&wn(_.viewer_token,_.my_feedback_url),(u.element||u.fullPage)&&_){let M=_.upload_urls;if(M){let U=[];u.element&&M.element&&U.push(ut(M.element,u.element,t)),u.fullPage&&M.fullPage&&U.push(ut(M.fullPage,u.fullPage,t));try{await Promise.all(U);}catch{}}else if(_.feedback_id)try{await _n({feedbackId:_.feedback_id,extracted:u,screenshots:e.payload.screenshots,...t?{signal:t}:{}});}catch{}}if(p.blob&&_){let M=_.upload_urls;if(M?.video)try{await fetch(M.video,{method:"PUT",body:p.blob,headers:{"content-type":p.blob.type},...t?{signal:t}:{}});}catch{}else if(_.feedback_id)try{await Sn({feedbackId:_.feedback_id,blob:p.blob,...t?{signal:t}:{}});}catch{}}let B={ok:!0,status:R.status};return _&&(B.apiResponse=_),B}if(m<i&&vn(R.status)){let _=.85+Math.random()*.3,ne=Math.round(c*2**(m-1)*_);await dt(ne,t);continue}let P=`HTTP ${R.status}`;try{let _=await R.json();_?.error&&(P=_.error);}catch{}return {ok:!1,status:R.status,error:w("api_failed",new Error(P))}}catch(R){if(h.signal.aborted||t?.aborted)return {ok:false,error:w("aborted",R)};if(m<i){let P=.85+Math.random()*.3,_=Math.round(c*2**(m-1)*P);await dt(_,t);continue}return {ok:false,error:w("api_failed",R)}}finally{clearTimeout(S),t&&t.removeEventListener("abort",v);}}return {ok:false,error:w("api_failed",new Error("Failed"))}}async function gt(e){let{blob:t,mime:n,blocfeedId:o,signal:r}=e,i=await fetch(hn,{method:"POST",headers:{"Content-Type":n,"X-Blocfeed-Id":o},body:t,...r?{signal:r}:{}});if(!i.ok){let s=await i.json().catch(()=>({error:"Unknown error"}));throw w("api_failed",new Error(s?.error??`Voice API returned ${i.status}`))}let c=await i.json();return {text:c.text??"",warning:c.warning}}var kn={enabled:true,sampling:1,ignoreSelectors:["[data-blocfeed-ui]","[data-blocfeed-ignore]"],rageClick:{enabled:true,threshold:3,windowMs:1e3},httpFail:{enabled:true,statusCodes:[400,401,403,422,500,502,503,504],ignoreUrls:["/api/behavioral-events","/api/feedback"]},redirectLoop:{enabled:true,threshold:3,windowMs:2e3},formDataLoss:{enabled:true}};function ht(e){let t=kn;return {enabled:e?.enabled??t.enabled,sampling:e?.sampling??t.sampling,ignoreSelectors:e?.ignoreSelectors??t.ignoreSelectors,rageClick:{...t.rageClick,...e?.rageClick??{}},httpFail:{...t.httpFail,...e?.httpFail??{}},redirectLoop:{...t.redirectLoop,...e?.redirectLoop??{}},formDataLoss:{...t.formDataLoss,...e?.formDataLoss??{}}}}function bt(e){let t=[];async function n(){if(t.length===0)return;let r=t.splice(0,50);try{await fetch(e.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-blocfeed-id":e.blocfeedId},body:JSON.stringify({events:r}),keepalive:!0});}catch{}}function o(){if(t.length===0)return;if(typeof navigator>"u"||typeof navigator.sendBeacon!="function"){n();return}let r=t.splice(0,50),i=new Blob([JSON.stringify({events:r})],{type:"application/json"}),c=`${e.endpoint}?_bfid=${encodeURIComponent(e.blocfeedId)}`;try{navigator.sendBeacon(c,i);}catch{}}return {enqueue(r){t.push(r);},flush:n,flushBeacon:o,size(){return t.length}}}var wt="bf_behavioral_session",ie=null;function O(){try{let e=sessionStorage.getItem(wt);if(e)return e;let t=vt();return sessionStorage.setItem(wt,t),t}catch{return ie||(ie=vt(),ie)}}function vt(){let e=Math.random().toString(36).slice(2,10).padEnd(8,"0");return `bf_${Date.now()}_${e}`}function yt(e,t){if(!e.rageClick.enabled)return ()=>{};let{threshold:n,windowMs:o}=e.rageClick,r=new Map;function i(c){try{let s=c.target;if(!s||!(s instanceof Element)||Rn(s,e.ignoreSelectors))return;let f=G(s,4);if(!f)return;let a=Date.now(),l=(r.get(f)??[]).filter(p=>a-p<=o);if(l.push(a),r.set(f,l),l.length>=n){let p=Tn(s),g=X(s,200)??null,u=s.tagName.toLowerCase(),m=s.id||null,h=z(s)??null,S=oe(s,5),v={session_id:O(),event_type:"rage_click",page_url:typeof window>"u"?"":window.location.href,selector:f,element_text:g,event_data:{click_count:l.length,window_ms:o,...p?{disabled:!0}:{},tag_name:u,...m?{element_id:m}:{},...h?{component_name:h}:{},...S.length>0?{parent_components:S}:{}},created_at:new Date().toISOString()};t(v),r.set(f,[]);}}catch{}}return document.addEventListener("click",i,{capture:true,passive:true}),()=>document.removeEventListener("click",i,{capture:true})}function Tn(e){if(e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true")return true;try{if(window.getComputedStyle(e).pointerEvents==="none")return !0}catch{}return false}function Rn(e,t){if(t.length===0)return false;for(let n of t)try{if(e.matches(n)||e.closest(n))return !0}catch{}return false}var _t=0,St=null,se=null,ae=[],Cn=1500;function An(){function e(t){try{let n=t.target;if(!n)return;let o=n.closest('button[type="submit"], input[type="submit"], [data-blocfeed-submit]');if(!o)return;_t=Date.now();let r=o.closest("form");St=(r?G(r,3):"")||null,se=X(o,100)??null,ae=oe(o,5);}catch{}}return document.addEventListener("click",e,{capture:true,passive:true}),()=>document.removeEventListener("click",e,{capture:true})}function kt(e,t){if(!e.httpFail.enabled)return ()=>{};let{statusCodes:n,ignoreUrls:o}=e.httpFail,r=new Set(n),i=An(),c=globalThis.fetch,s=async(l,p)=>{let g=typeof l=="string"?l:l instanceof URL?l.toString():l.url,u=(p?.method??l.method??"GET").toUpperCase(),m=await c.call(globalThis,l,p);try{!Et(g,o)&&r.has(m.status)&&t(d(m.status,g,u));}catch{}return m};globalThis.fetch=s;let f=XMLHttpRequest.prototype.open,a=XMLHttpRequest.prototype.send;return XMLHttpRequest.prototype.open=function(l,p,...g){return this.__bf_url=p,this.__bf_method=l.toUpperCase(),f.call(this,l,p,...g)},XMLHttpRequest.prototype.send=function(l){let p=()=>{try{let g=this.__bf_url??"",u=this.__bf_method??"GET";!Et(g,o)&&r.has(this.status)&&t(d(this.status,g,u));}catch{}};return this.__bf_handler=p,this.addEventListener("loadend",p),a.call(this,l??null)},()=>{globalThis.fetch=c,XMLHttpRequest.prototype.open=f,XMLHttpRequest.prototype.send=a,i(),se=null,ae=[];};function d(l,p,g){let m=Date.now()-_t<Cn;return {session_id:O(),event_type:"error",page_url:typeof window>"u"?"":window.location.href,selector:null,element_text:null,event_data:{http_status:l,request_url:p,method:g,form_selector:m?St:null,...m&&se?{button_text:se}:{},...m&&ae.length>0?{parent_components:ae}:{}},created_at:new Date().toISOString()}}}function Et(e,t){if(t.length===0)return false;for(let n of t)if(e.includes(n))return true;return false}var xn=3e4;function Tt(e,t){if(!e.redirectLoop.enabled)return ()=>{};if(typeof window>"u")return ()=>{};let{threshold:n,windowMs:o}=e.redirectLoop,r=new Map,i=new Map,c=history.pushState,s=history.replaceState;function f(d){try{let l=Date.now(),p=i.get(d)??0;if(l<p)return;let u=(r.get(d)??[]).filter(m=>l-m<=o);if(u.push(l),r.set(d,u),u.length>=n){let m={session_id:O(),event_type:"thrashing",page_url:window.location.href,selector:null,element_text:null,event_data:{count:u.length,url:d,window_ms:o},created_at:new Date().toISOString()};t(m),i.set(d,l+xn),r.set(d,[]);}}catch{}}function a(){let d=window.location.pathname+window.location.search;f(d);}return history.pushState=function(...d){let l=c.apply(this,d);return a(),l},history.replaceState=function(...d){let l=s.apply(this,d);return a(),l},window.addEventListener("popstate",a),()=>{history.pushState=c,history.replaceState=s,window.removeEventListener("popstate",a);}}function Rt(e,t){if(!e.formDataLoss.enabled)return ()=>{};if(typeof window>"u")return ()=>{};let n=new Set,o=0;function r(a){let d=a.closest("form");return d?d.id?`#${d.id}`:"form":null}function i(a){try{let d=a.target;if(!d||!(d instanceof HTMLInputElement||d instanceof HTMLTextAreaElement||d instanceof HTMLSelectElement))return;let l=r(d);if(!l)return;n.has(l)||n.add(l),o++;}catch{}}function c(a){if(n.size===0)return;let d=Array.from(n),l={session_id:O(),event_type:"form_abandonment",page_url:window.location.href,selector:d[0]??null,element_text:null,event_data:{cause:a,field_count:o,forms:d},created_at:new Date().toISOString()};t(l);}function s(a){a.persisted&&c("bfcache_restore");}function f(){c("beforeunload_after_edit");}return document.addEventListener("input",i,{capture:true,passive:true}),window.addEventListener("pageshow",s),window.addEventListener("beforeunload",f),()=>{document.removeEventListener("input",i,{capture:true}),window.removeEventListener("pageshow",s),window.removeEventListener("beforeunload",f);}}var Fn=5e3,ce=class{constructor(t){this.submitter=null;this.detectorUninstallers=[];this.flushTimer=null;this.pageHideHandler=null;this.installed=false;this.opts=t,this.resolved=ht(t.config);}install(){if(this.installed||!this.resolved.enabled||!(this.opts.passiveSampler??(()=>Math.random()<this.resolved.sampling))())return;let n=this.opts.endpoint??"https://blocfeed.com/api/behavioral-events";this.submitter=this.opts.submitter??bt({endpoint:n,blocfeedId:this.opts.blocfeedId});let o=r=>{this.submitter?.enqueue(r);};this.detectorUninstallers.push(yt(this.resolved,o)),this.detectorUninstallers.push(kt(this.resolved,o)),this.detectorUninstallers.push(Tt(this.resolved,o)),this.detectorUninstallers.push(Rt(this.resolved,o)),this.flushTimer=setInterval(()=>{this.submitter?.flush();},Fn),this.pageHideHandler=()=>{this.submitter?.flushBeacon();},typeof window<"u"&&window.addEventListener("pagehide",this.pageHideHandler),this.installed=true;}uninstall(){if(this.installed){for(let t of this.detectorUninstallers)try{t();}catch{}this.detectorUninstallers=[],this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null),this.pageHideHandler&&typeof window<"u"&&(window.removeEventListener("pagehide",this.pageHideHandler),this.pageHideHandler=null);try{this.submitter?.flush();}catch{}this.submitter=null,this.installed=false;}}};function Ae(e){let t=null,n=null,o=(...r)=>{n=r,t===null&&(t=requestAnimationFrame(()=>{if(t=null,!n)return;let i=n;n=null,e(...i);}));};return o.cancel=()=>{t!==null&&cancelAnimationFrame(t),t=null,n=null;},o}function le(e){return e instanceof Element?!!e.closest("[data-blocfeed-ui]"):false}function de(e){e.stopPropagation(),e.stopImmediatePropagation?.();}function Ct(e,t){if(!y())throw new Error("BlocFeed picker can only run in a browser environment.");let n=e.ignoreSelectors,o=e.isSelectable,r={};n&&n.length>0&&(r.ignoreSelectors=n),o&&(r.isSelectable=o);let i=null,c=null,s=(u,m=false)=>{if(!u){i=null,c=null,t.onHover(null);return}let h=we(u.getBoundingClientRect()),S=`${Math.round(h.x)}:${Math.round(h.y)}:${Math.round(h.width)}:${Math.round(h.height)}`;!m&&u===i&&S===c||(i=u,c=S,t.onHover({element:u,rect:h}));},f=Ae(u=>{if(le(u.target))return;let m=document.elementFromPoint(u.clientX,u.clientY),h=ye(m,r);s(h);}),a=Ae(()=>{i&&s(i,true);}),d=u=>{le(u.target)||(de(u),u.pointerType==="mouse"&&u.preventDefault());},l=u=>{le(u.target)||(de(u),u.pointerType==="mouse"&&u.preventDefault());},p=u=>{if(le(u.target))return;de(u),u.preventDefault();let m=document.elementFromPoint(u.clientX,u.clientY),h=ye(m,r);h&&t.onSelect({element:h,descriptor:$e(h)});},g=u=>{u.key==="Escape"&&(de(u),u.preventDefault(),t.onCancel());};return window.addEventListener("pointermove",f,{capture:true,passive:true}),window.addEventListener("pointerdown",d,{capture:true}),window.addEventListener("pointerup",l,{capture:true}),window.addEventListener("click",p,{capture:true}),window.addEventListener("keydown",g,{capture:true}),window.addEventListener("scroll",a,{capture:true,passive:true}),window.addEventListener("resize",a,{passive:true}),{stop(){window.removeEventListener("pointermove",f,{capture:true}),window.removeEventListener("pointerdown",d,{capture:true}),window.removeEventListener("pointerup",l,{capture:true}),window.removeEventListener("click",p,{capture:true}),window.removeEventListener("keydown",g,{capture:true}),window.removeEventListener("scroll",a,{capture:true}),window.removeEventListener("resize",a),f.cancel(),a.cancel(),t.onHover(null);}}}async function xe(e){let{signal:t,transport:n}=e,o={ok:false};try{let r={payload:e.payload,...t?{signal:t}:{},...n?{transport:n}:{}};o.api=await mt(r),o.ok=!!o.api?.ok;}catch(r){o.api={ok:false,error:w("api_failed",r)},o.ok=false;}return {payload:e.payload,result:o}}var Pn=["[data-blocfeed-ui]","[data-blocfeed-ignore]"];function Mn(e){let t=[...Pn,...e?.ignoreSelectors??[]],n=Array.from(new Set(t));return {...e,ignoreSelectors:n}}function At(){return {phase:"idle"}}function Ln(e){if(e.ok)return false;let t=e.api;return t?t.status&&t.status>=400&&t.status<500||t.error?.kind==="aborted"||t.error?.kind==="configuration"?false:!t.ok:true}function cr(e){let t=e,n=new ce({blocfeedId:t.blocfeed_id??"",...t.behavioral!==void 0?{config:t.behavioral}:{}});n.install();let o=At(),r=new Set,i=new Set,c=null,s=null,f=null,a=null,d=0,l=null,p=null,g=null,u=null,m=false,h=()=>{for(let b of r)b(o);},S=b=>{for(let E of i)E(b);},v=b=>{o=b,h();},R=()=>{d+=1,a?.abort(),a=null;},P=()=>{c?.stop(),c=null,S(null),f!==null&&y()&&(document.documentElement.style.cursor=f,f=null);},_=()=>{if(g){try{URL.revokeObjectURL(g.blobUrl);}catch{}g=null;}},ne=()=>{p&&(p.abort(),p=null),_();},B=null,M=()=>{u&&(u.abort(),u=null),B&&(B.abort(),B=null);},U=()=>{R(),P(),ne(),M(),s=null,v(At());},De=()=>{if(!y())return;P(),s=null;let b=Mn(t.picker);f=document.documentElement.style.cursor,document.documentElement.style.cursor="crosshair",v({phase:"picking"}),c=Ct(b,{onHover:S,onSelect:({element:E,descriptor:x})=>{s=E,P(),v({phase:"review",selection:x});},onCancel:()=>{U();}});},Ne=()=>{let b=Je();if(b.length!==0)for(let E of b)xe({payload:E,...t.transport?{transport:t.transport}:{}}).catch(()=>{ke(E);});};if(y()){setTimeout(Ne,1e3);let b=()=>Ne();window.addEventListener("online",b),l=()=>window.removeEventListener("online",b);}return {getState:()=>o,getConfig:()=>t,subscribe(b){return r.add(b),()=>r.delete(b)},subscribeHover(b){return i.add(b),()=>i.delete(b)},start(){o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording"||o.phase!=="picking"&&De();},stop(){U();},clearSelection(){o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording"||De();},setConfig(b){t=b;},async submit(b,E){if(!y()){let T=w("configuration",new Error("BlocFeed submit can only run in the browser"));return v({phase:"error",lastError:T}),{ok:false}}let x=t.blocfeed_id?.trim?.()??"";if(!x){let L={phase:"error",lastError:w("configuration",new Error("Missing blocfeed_id. Create a project in BlocFeed and pass its blocfeed_id."))};return o.selection&&(L.selection=o.selection),v(L),{ok:false}}if(m)return {ok:false};if(o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording")return {ok:false};m=true;let A=d+1;d=A,a?.abort(),a=new AbortController;let C=a.signal,k=o.selection,I=E?.capture?{...t.capture,...E.capture}:t.capture,H=!!(I?.element||I?.fullPage),K={phase:H?"capturing":"submitting"};k&&(K.selection=k),v(K);try{let T=H?await Ye({selectionElement:s,capture:I,signal:C}):void 0;if(C.aborted||d!==A)return {ok:!1};let L={phase:"submitting"};k&&(L.selection=k),T&&(L.capture=T),v(L);let D={};k&&(D.selection=k),T&&(D.capture=T);let W=await Qe({config:t.metadata,context:D,...t.user?{user:t.user}:{}}),V={version:1,createdAt:new Date().toISOString(),blocfeed_id:x,message:b,metadata:W};E?.category&&(V.category=E.category),t.user&&(V.user=t.user),k&&(V.selection=k),T&&(V.screenshots=T),g&&(V.video=g);let{result:N}=await xe({payload:V,signal:C,...t.transport?{transport:t.transport}:{}});if(C.aborted||d!==A)return N;if(N.ok){_(),s=null;let be={phase:"success",lastSubmit:N};return k&&(be.selection=k),T&&(be.capture=T),v(be),N}Ln(N)&&ke(V);let Mt=N.api?.error??w("unknown",new Error("Submission failed")),he={phase:"error",lastSubmit:N,lastError:Mt};return k&&(he.selection=k),T&&(he.capture=T),v(he),N}catch(T){if(C.aborted||d!==A)return {ok:false};let D={phase:"error",lastError:C.aborted?w("aborted",T):w("unknown",T)};return k&&(D.selection=k),v(D),{ok:false}}finally{m=false,d===A&&(a=null);}},async startRecording(){if(o.phase!=="review"||!t.recording?.enabled||u||p)return;let b=o.selection,E={phase:"recording",recordingElapsedMs:0};b&&(E.selection=b),v(E);try{let x={config:t.recording};a&&(x.signal=a.signal);let A=await Te(x);p=A,A.onTick(I=>{if(o.phase==="recording"){let H={phase:"recording",recordingElapsedMs:I};b&&(H.selection=b),v(H);}});let C=await A.result;p=null,g=C;let k={phase:"review",video:C};b&&(k.selection=b),v(k);}catch(x){p=null;let C={phase:"review",lastError:x?.kind?x:w("recording_failed",x)};b&&(C.selection=b),v(C);}},stopRecording(){o.phase!=="recording"||!p||p.stop();},removeVideo(){_();let b=o.selection,E={phase:"review"};b&&(E.selection=b),v(E);},async startVoice(){if(o.phase!=="review"){console.warn("[BlocFeed] startVoice: ignored \u2014 phase is",o.phase,'(expected "review")');return}let b=t.voice;if(!b?.enabled){console.warn("[BlocFeed] startVoice: ignored \u2014 voice is not enabled in config");return}if(p){console.warn("[BlocFeed] startVoice: ignored \u2014 a screen recording is already in progress");return}M();let E=o.selection,x={phase:"review",voiceRecording:true,voiceElapsedMs:0};E&&(x.selection=E),g&&(x.video=g),v(x);try{let A={config:b};a&&(A.signal=a.signal);let C=await Re(A);u=C,C.onTick(D=>{let W={phase:"review",voiceRecording:!0,voiceElapsedMs:D};E&&(W.selection=E),g&&(W.video=g),v(W);});let k=await C.result;u=null;let I={phase:"review",voiceRecording:!1,voiceTranscribing:!0};E&&(I.selection=E),g&&(I.video=g),v(I),B=new AbortController;let H={blob:k.blob,mime:k.mime,blocfeedId:t.blocfeed_id,signal:B.signal},{text:Oe,warning:K}=await gt(H);B=null;let T={phase:"review",voiceRecording:!1,voiceTranscribing:!1};E&&(T.selection=E),g&&(T.video=g),v(T);let L={text:Oe};return K&&(L.warning=K),L}catch(A){M();let C=A?.kind?A:w("recording_failed",A);console.warn("[BlocFeed] Voice error:",C.message);let k={phase:"review",voiceRecording:false,voiceTranscribing:false,lastError:C};E&&(k.selection=E),g&&(k.video=g),v(k);return}},stopVoice(){u&&u.stop();},__unsafeGetSelectedElement(){return s},destroy(){n.uninstall(),U(),r.clear(),i.clear(),l?.(),l=null;}}}var J=[],ee=[],xt=20,Ft=15,ue=[],Pt=typeof console<"u"?{log:console.log?.bind(console),warn:console.warn?.bind(console),error:console.error?.bind(console),info:console.info?.bind(console),debug:console.debug?.bind(console)}:{},fe=typeof globalThis<"u"&&typeof globalThis.fetch=="function"?globalThis.fetch:void 0,pe=typeof XMLHttpRequest<"u"?XMLHttpRequest.prototype.open:void 0,me=typeof XMLHttpRequest<"u"?XMLHttpRequest.prototype.send:void 0,Pe=new Set,Me=false,Le=false,ge=false,Bn=["blocfeed.com","google-analytics.com","googletagmanager.com","analytics.google.com","googleads.g.doubleclick.net","googlesyndication.com","googleadservices.com","google.com/pagead","google.com/ads","facebook.net","facebook.com/tr","connect.facebook.net","graph.facebook.com","api.mixpanel.com","api-js.mixpanel.com","api.amplitude.com","api2.amplitude.com","api.segment.io","cdn.segment.com","vars.hotjar.com","in.hotjar.com","script.hotjar.com","heapanalytics.com","fullstory.com/s/fs.js","rs.fullstory.com","app.posthog.com","us.posthog.com","eu.posthog.com","api-iam.intercom.io","widget.intercom.io","sentry.io/api","browser.sentry-cdn.com","browser-intake-datadoghq.com","clarity.ms","js.hs-analytics.net","api.hubapi.com","forms.hubspot.com","plausible.io/api","client.crisp.chat","js.driftt.com","r.logrocket.com","app.pendo.io","events.launchdarkly.com","app.launchdarkly.com","grammarly.com","gnar.grammarly.com","capi.grammarly.com","api.languagetool.org","api.languagetoolplus.com","fonts.googleapis.com","fonts.gstatic.com","cdn.cookielaw.org","consent.cookiebot.com","js.stripe.com","api.stripe.com/v1/tokens","google.com/recaptcha","hcaptcha.com","bam.nr-data.net","rec.smartlook.com","o2.mouseflow.com","api.luckyorange.com","static.zdassets.com","ekr.zdassets.com"];function In(e){if(e instanceof Error)return e.name&&e.name!=="Error"?`${e.name}: ${e.message}`:e.message||String(e);if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function Dn(e,t){let n=t.map(In).join(" "),o=t.find(i=>i instanceof Error),r={level:e,message:n.slice(0,2e3),timestamp:Date.now()};for(o?.stack&&(r.stack=o.stack.slice(0,2e3)),J.push(r);J.length>xt;)J.shift();}function Fe(e){let t=e.url.toLowerCase();for(let n of ue)if(t.includes(n))return;for(ee.push(e);ee.length>Ft;)ee.shift();}function ur(e={}){if(ge||!y())return;ge=true,xt=e.consoleLimit??20,Ft=e.networkLimit??15;let t=e.ignoreUrls;if(t!==void 0?ue=t.map(n=>n.toLowerCase()):ue=[...Bn],e.console!==false){let n=e.consoleLevels??["error","warn"];for(let o of n){let r=Pt[o];r&&(Pe.add(o),console[o]=(...i)=>{Dn(o,i),r.apply(console,i);});}}if(e.network!==false&&fe){let n=fe;Me=true,window.fetch=async function(r,i){let c=typeof r=="string"?r:r instanceof URL?r.toString():r.url,s=(i?.method??"GET").toUpperCase(),f=Date.now();try{let a=await n.call(window,r,i);return a.ok||Fe({url:c.slice(0,500),method:s,status:a.status,statusText:a.statusText,timestamp:f,durationMs:Date.now()-f}),a}catch(a){throw Fe({url:c.slice(0,500),method:s,status:0,statusText:a instanceof Error?a.message:"Network error",timestamp:f,durationMs:Date.now()-f}),a}};}if(e.network!==false&&pe&&me){let n=pe,o=me;Le=true,XMLHttpRequest.prototype.open=function(r,i,...c){return this.__bf_method=r.toUpperCase(),this.__bf_url=String(i),n.apply(this,[r,i,...c])},XMLHttpRequest.prototype.send=function(...r){let i=this.__bf_method||"GET",c=this.__bf_url||"",s=Date.now();return this.addEventListener("loadend",function(){if(this.status>=400||this.status===0){let f={url:c.slice(0,500),method:i,status:this.status,timestamp:s,durationMs:Date.now()-s};this.statusText&&(f.statusText=this.statusText),Fe(f);}},{once:true}),o.apply(this,r)};}}function fr(){if(ge){for(let e of Pe){let t=Pt[e];t&&(console[e]=t);}Pe.clear(),Me&&fe&&(window.fetch=fe,Me=false),Le&&pe&&me&&(XMLHttpRequest.prototype.open=pe,XMLHttpRequest.prototype.send=me,Le=false),ue=[],ge=false;}}function pr(){return {consoleLogs:[...J],networkErrors:[...ee]}}function mr(){J=[],ee=[];}var Nn=[{name:"supabase_service_role_key",pattern:/SUPABASE_SERVICE_ROLE_KEY["'=:\s]{1,8}[A-Za-z0-9_.=-]{30,400}/},{name:"supabase_db_password",pattern:/SUPABASE_DB_PASSWORD["'=:\s]{1,8}[^\s"']{6,200}/},{name:"postgres_password",pattern:/POSTGRES_PASSWORD["'=:\s]{1,8}[^\s"']{6,200}/},{name:"database_url_with_creds",pattern:/(?:postgres|postgresql|mysql|mongodb|redis|amqp):\/\/[^:\s"']{1,100}:[^@\s"']{1,200}@/},{name:"aws_access_key",pattern:/AKIA[0-9A-Z]{16}/},{name:"aws_secret_key",pattern:/AWS_SECRET_ACCESS_KEY["'=:\s]{1,8}[A-Za-z0-9/+=]{30,200}/},{name:"aws_session_token",pattern:/AWS_SESSION_TOKEN["'=:\s]{1,8}[A-Za-z0-9/+=]{30,600}/},{name:"stripe_secret_key",pattern:/sk_live_[a-zA-Z0-9]{10,200}/},{name:"stripe_secret_key_test",pattern:/sk_test_[a-zA-Z0-9]{10,200}/},{name:"stripe_restricted_key",pattern:/rk_(?:live|test)_[a-zA-Z0-9]{10,200}/},{name:"github_pat",pattern:/ghp_[A-Za-z0-9_]{36,100}/},{name:"github_oauth",pattern:/gho_[A-Za-z0-9_]{36,100}/},{name:"github_user_token",pattern:/ghu_[A-Za-z0-9_]{36,100}/},{name:"github_server_token",pattern:/ghs_[A-Za-z0-9_]{36,100}/},{name:"github_fine_grained",pattern:/github_pat_[A-Za-z0-9_]{22,200}/},{name:"openai_api_key",pattern:/sk-[a-zA-Z0-9]{20,200}(?![a-zA-Z0-9_])/},{name:"anthropic_api_key",pattern:/sk-ant-[a-zA-Z0-9\-_]{20,200}/},{name:"private_key",pattern:/-----BEGIN (?:RSA |EC |DSA |OPENSSH |PGP )?PRIVATE KEY-----/},{name:"sendgrid_api_key",pattern:/SG\.[a-zA-Z0-9_-]{22,100}\.[a-zA-Z0-9_-]{22,100}/},{name:"twilio_auth_token",pattern:/TWILIO_AUTH_TOKEN["'=:\s]{1,8}[a-f0-9]{32}/},{name:"generic_secret_key",pattern:/[A-Z_]{2,60}_SECRET_KEY["'=:\s]{1,8}[^\s"']{8,200}/},{name:"generic_secret",pattern:/[A-Z_]{2,60}_SECRET["'=:\s]{1,8}[^\s"']{8,200}/},{name:"generic_password",pattern:/[A-Z_]{2,60}_PASSWORD["'=:\s]{1,8}[^\s"']{6,200}/},{name:"generic_private_key_var",pattern:/[A-Z_]{2,60}_PRIVATE_KEY["'=:\s]{1,8}[^\s"']{8,400}/}],$=[],Ie=0,Be=false;function On(e){let t=e.slice(0,80);return t.length<=6?"***":t.slice(0,6)+"***"}function Un(e,t,n,o){if($.some(c=>c.rule===e&&c.source===t))return;let i={rule:e,source:t,hint:On(n),timestamp:Date.now()};o&&(i.location=o),$.push(i);}function te(e,t,n,o){for(let{name:r,pattern:i}of n){let c=i.exec(e);c&&Un(r,t,c[0],o);}}function Hn(e){try{let t=window;if(t.__NEXT_DATA__){let n=JSON.stringify(t.__NEXT_DATA__);te(n,"hydration",e,"__NEXT_DATA__");}if(t.__NUXT__){let n=JSON.stringify(t.__NUXT__);te(n,"hydration",e,"__NUXT__");}}catch{}}function Vn(e){try{document.querySelectorAll("script:not([src])").forEach((n,o)=>{let r=n.textContent;r&&r.length>0&&te(r,"scripts",e,`inline-script[${o}]`);});}catch{}}function qn(e){try{document.querySelectorAll("meta[content]").forEach(n=>{let o=n.getAttribute("content"),r=n.getAttribute("name")||n.getAttribute("property")||"";o&&o.length>10&&te(o,"meta",e,r?`meta[${r}]`:void 0);});}catch{}}function Xn(e){try{document.querySelectorAll("[data-api-key], [data-secret], [data-token], [data-password]").forEach(n=>{let o=n.attributes;for(let r=0;r<o.length;r++){let i=o[r];i.name.startsWith("data-")&&i.value.length>10&&te(i.value,"dom",e,`${n.tagName.toLowerCase()}[${i.name}]`);}});}catch{}}function br(e={}){if(Be||!y()||(Be=true,e.secretScan===false))return;let t=[...Nn,...e.customPatterns??[]],n=e.scanTargets??["hydration","scripts","meta","dom"];setTimeout(()=>{Ie=Date.now(),n.includes("hydration")&&Hn(t),n.includes("scripts")&&Vn(t),n.includes("meta")&&qn(t),n.includes("dom")&&Xn(t);let o=e.notify??"both";$.length>0&&(o==="console"||o==="both")&&console.warn(`[BlocFeed Security] Found ${$.length} potential secret(s) exposed in client code:`,$.map(r=>`${r.rule} (${r.source}${r.location?`: ${r.location}`:""})`));},100);}function wr(){return {findings:[...$],scannedAt:Ie}}function vr(){$=[],Ie=0,Be=false;}
2
+ exports.A=vr;exports.a=y;exports.b=we;exports.c=Ke;exports.d=Ye;exports.e=Qe;exports.f=ke;exports.g=Je;exports.h=no;exports.i=oo;exports.j=Jt;exports.k=en;exports.l=an;exports.m=Te;exports.n=un;exports.o=Re;exports.p=bn;exports.q=Eo;exports.r=gt;exports.s=ce;exports.t=cr;exports.u=ur;exports.v=fr;exports.w=pr;exports.x=mr;exports.y=br;exports.z=wr;
@@ -8,6 +8,7 @@ interface BehavioralEvent {
8
8
  event_type: BehavioralEventType;
9
9
  page_url: string;
10
10
  selector: string | null;
11
+ element_text: string | null;
11
12
  event_data: Record<string, unknown> | null;
12
13
  created_at: string;
13
14
  }
@@ -8,6 +8,7 @@ interface BehavioralEvent {
8
8
  event_type: BehavioralEventType;
9
9
  page_url: string;
10
10
  selector: string | null;
11
+ element_text: string | null;
11
12
  event_data: Record<string, unknown> | null;
12
13
  created_at: string;
13
14
  }
package/dist/engine.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var chunkNLL5DECC_cjs=require('./chunk-NLL5DECC.cjs');function s(o){if(o?.aborted)throw new Error("Aborted")}async function v(o){return await new Promise((t,e)=>{let r=new Image;r.onload=()=>t({width:r.naturalWidth,height:r.naturalHeight}),r.onerror=()=>e(new Error("Failed to load generated screenshot")),r.src=o;})}async function l(o,t){let{width:e,height:r}=await v(o);return {dataUrl:o,mime:t,width:e,height:r}}function U(o){return {async captureElement(t,e){if(!chunkNLL5DECC_cjs.a())throw new Error("captureElement can only run in the browser");s(e.signal);let r={scale:e.pixelRatio},n=e.mime==="image/jpeg"?await o.domToJpeg(t,{...r,quality:e.quality??.92}):await o.domToPng(t,r);return s(e.signal),await l(n,e.mime)},async captureFullPage(t){if(!chunkNLL5DECC_cjs.a())throw new Error("captureFullPage can only run in the browser");s(t.signal);let e=document.documentElement,r=Math.max(e.scrollWidth,e.clientWidth),n=Math.max(e.scrollHeight,e.clientHeight),i=Math.min(1,t.maxDimension/Math.max(r,n)),c={width:Math.max(1,Math.round(r*i)),height:Math.max(1,Math.round(n*i)),scale:t.pixelRatio},a=t.mime==="image/jpeg"?await o.domToJpeg(e,{...c,quality:t.quality??.92}):await o.domToPng(e,c);return s(t.signal),await l(a,t.mime)}}}function O(o){let[t,e]=o.split(",",2);if(!t||!e)throw new Error("Invalid data URL");let n=/data:(.*?);base64/.exec(t)?.[1]||"application/octet-stream",i=atob(e),c=new Uint8Array(i.length);for(let a=0;a<i.length;a+=1)c[a]=i.charCodeAt(a);return new Blob([c],{type:n})}Object.defineProperty(exports,"clearClickEvents",{enumerable:true,get:function(){return chunkNLL5DECC_cjs.k}});Object.defineProperty(exports,"clearDiagnostics",{enumerable:true,get:function(){return chunkNLL5DECC_cjs.x}});Object.defineProperty(exports,"clearQueue",{enumerable:true,get:function(){return chunkNLL5DECC_cjs.h}});Object.defineProperty(exports,"clearSecurityFindings",{enumerable:true,get:function(){return chunkNLL5DECC_cjs.A}});Object.defineProperty(exports,"collectMetadata",{enumerable:true,get:function(){return chunkNLL5DECC_cjs.e}});Object.defineProperty(exports,"createBlocFeedController",{enumerable:true,get:function(){return chunkNLL5DECC_cjs.t}});Object.defineProperty(exports,"createHtmlToImageAdapter",{enumerable:true,get:function(){return chunkNLL5DECC_cjs.c}});Object.defineProperty(exports,"dequeueAll",{enumerable:true,get:function(){return chunkNLL5DECC_cjs.g}});Object.defineProperty(exports,"drainClickEvents",{enumerable:true,get:function(){return chunkNLL5DECC_cjs.j}});Object.defineProperty(exports,"drainDiagnostics",{enumerable:true,get:function(){return chunkNLL5DECC_cjs.w}});Object.defineProperty(exports,"enqueue",{enumerable:true,get:function(){return chunkNLL5DECC_cjs.f}});Object.defineProperty(exports,"getMyFeedbackUrl",{enumerable:true,get:function(){return chunkNLL5DECC_cjs.q}});Object.defineProperty(exports,"getQueueSize",{enumerable:true,get:function(){return chunkNLL5DECC_cjs.i}});Object.defineProperty(exports,"getSecurityFindings",{enumerable:true,get:function(){return chunkNLL5DECC_cjs.z}});Object.defineProperty(exports,"getViewerToken",{enumerable:true,get:function(){return chunkNLL5DECC_cjs.p}});Object.defineProperty(exports,"installDiagnostics",{enumerable:true,get:function(){return chunkNLL5DECC_cjs.u}});Object.defineProperty(exports,"isRecordingSupported",{enumerable:true,get:function(){return chunkNLL5DECC_cjs.l}});Object.defineProperty(exports,"isVoiceSupported",{enumerable:true,get:function(){return chunkNLL5DECC_cjs.n}});Object.defineProperty(exports,"runCapture",{enumerable:true,get:function(){return chunkNLL5DECC_cjs.d}});Object.defineProperty(exports,"runSecretScan",{enumerable:true,get:function(){return chunkNLL5DECC_cjs.y}});Object.defineProperty(exports,"startRecording",{enumerable:true,get:function(){return chunkNLL5DECC_cjs.m}});Object.defineProperty(exports,"startVoiceRecording",{enumerable:true,get:function(){return chunkNLL5DECC_cjs.o}});Object.defineProperty(exports,"transcribeAudio",{enumerable:true,get:function(){return chunkNLL5DECC_cjs.r}});Object.defineProperty(exports,"uninstallDiagnostics",{enumerable:true,get:function(){return chunkNLL5DECC_cjs.v}});exports.createModernScreenshotAdapter=U;exports.dataUrlToBlob=O;
1
+ 'use strict';var chunkUMYASFYV_cjs=require('./chunk-UMYASFYV.cjs');function s(o){if(o?.aborted)throw new Error("Aborted")}async function v(o){return await new Promise((t,e)=>{let r=new Image;r.onload=()=>t({width:r.naturalWidth,height:r.naturalHeight}),r.onerror=()=>e(new Error("Failed to load generated screenshot")),r.src=o;})}async function l(o,t){let{width:e,height:r}=await v(o);return {dataUrl:o,mime:t,width:e,height:r}}function U(o){return {async captureElement(t,e){if(!chunkUMYASFYV_cjs.a())throw new Error("captureElement can only run in the browser");s(e.signal);let r={scale:e.pixelRatio},n=e.mime==="image/jpeg"?await o.domToJpeg(t,{...r,quality:e.quality??.92}):await o.domToPng(t,r);return s(e.signal),await l(n,e.mime)},async captureFullPage(t){if(!chunkUMYASFYV_cjs.a())throw new Error("captureFullPage can only run in the browser");s(t.signal);let e=document.documentElement,r=Math.max(e.scrollWidth,e.clientWidth),n=Math.max(e.scrollHeight,e.clientHeight),i=Math.min(1,t.maxDimension/Math.max(r,n)),c={width:Math.max(1,Math.round(r*i)),height:Math.max(1,Math.round(n*i)),scale:t.pixelRatio},a=t.mime==="image/jpeg"?await o.domToJpeg(e,{...c,quality:t.quality??.92}):await o.domToPng(e,c);return s(t.signal),await l(a,t.mime)}}}function O(o){let[t,e]=o.split(",",2);if(!t||!e)throw new Error("Invalid data URL");let n=/data:(.*?);base64/.exec(t)?.[1]||"application/octet-stream",i=atob(e),c=new Uint8Array(i.length);for(let a=0;a<i.length;a+=1)c[a]=i.charCodeAt(a);return new Blob([c],{type:n})}Object.defineProperty(exports,"clearClickEvents",{enumerable:true,get:function(){return chunkUMYASFYV_cjs.k}});Object.defineProperty(exports,"clearDiagnostics",{enumerable:true,get:function(){return chunkUMYASFYV_cjs.x}});Object.defineProperty(exports,"clearQueue",{enumerable:true,get:function(){return chunkUMYASFYV_cjs.h}});Object.defineProperty(exports,"clearSecurityFindings",{enumerable:true,get:function(){return chunkUMYASFYV_cjs.A}});Object.defineProperty(exports,"collectMetadata",{enumerable:true,get:function(){return chunkUMYASFYV_cjs.e}});Object.defineProperty(exports,"createBlocFeedController",{enumerable:true,get:function(){return chunkUMYASFYV_cjs.t}});Object.defineProperty(exports,"createHtmlToImageAdapter",{enumerable:true,get:function(){return chunkUMYASFYV_cjs.c}});Object.defineProperty(exports,"dequeueAll",{enumerable:true,get:function(){return chunkUMYASFYV_cjs.g}});Object.defineProperty(exports,"drainClickEvents",{enumerable:true,get:function(){return chunkUMYASFYV_cjs.j}});Object.defineProperty(exports,"drainDiagnostics",{enumerable:true,get:function(){return chunkUMYASFYV_cjs.w}});Object.defineProperty(exports,"enqueue",{enumerable:true,get:function(){return chunkUMYASFYV_cjs.f}});Object.defineProperty(exports,"getMyFeedbackUrl",{enumerable:true,get:function(){return chunkUMYASFYV_cjs.q}});Object.defineProperty(exports,"getQueueSize",{enumerable:true,get:function(){return chunkUMYASFYV_cjs.i}});Object.defineProperty(exports,"getSecurityFindings",{enumerable:true,get:function(){return chunkUMYASFYV_cjs.z}});Object.defineProperty(exports,"getViewerToken",{enumerable:true,get:function(){return chunkUMYASFYV_cjs.p}});Object.defineProperty(exports,"installDiagnostics",{enumerable:true,get:function(){return chunkUMYASFYV_cjs.u}});Object.defineProperty(exports,"isRecordingSupported",{enumerable:true,get:function(){return chunkUMYASFYV_cjs.l}});Object.defineProperty(exports,"isVoiceSupported",{enumerable:true,get:function(){return chunkUMYASFYV_cjs.n}});Object.defineProperty(exports,"runCapture",{enumerable:true,get:function(){return chunkUMYASFYV_cjs.d}});Object.defineProperty(exports,"runSecretScan",{enumerable:true,get:function(){return chunkUMYASFYV_cjs.y}});Object.defineProperty(exports,"startRecording",{enumerable:true,get:function(){return chunkUMYASFYV_cjs.m}});Object.defineProperty(exports,"startVoiceRecording",{enumerable:true,get:function(){return chunkUMYASFYV_cjs.o}});Object.defineProperty(exports,"transcribeAudio",{enumerable:true,get:function(){return chunkUMYASFYV_cjs.r}});Object.defineProperty(exports,"uninstallDiagnostics",{enumerable:true,get:function(){return chunkUMYASFYV_cjs.v}});exports.createModernScreenshotAdapter=U;exports.dataUrlToBlob=O;
package/dist/engine.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { r as ScreenshotAdapter, C as CaptureConfig, k as CaptureResult, V as VideoAsset, R as RecordingConfig, L as ClickEvent, K as VoiceConfig, o as MetadataConfig, p as MetadataContext, i as BlocFeedUser, n as FeedbackPayload, x as SecuritySnapshot, v as SecurityConfig } from './controller-6fm9oK63.cjs';
2
- export { B as BlocFeedConfig, c as BlocFeedController, g as BlocFeedError, a as BlocFeedHandle, b as BlocFeedState, h as BlocFeedStrings, l as ConsoleEntry, D as DiagnosticsConfig, E as ElementDescriptor, m as FeedbackApiResponse, F as FeedbackCategory, O as HoverListener, I as ImageAsset, N as NetworkEntry, q as Rect, s as ScreenshotAdapterOptions, t as ScreenshotIntent, u as ScreenshotMime, w as SecurityFinding, y as SessionPhase, Q as StateListener, S as SubmitResult, T as ThemeConfig, z as TransportConfig, G as TriggerStyle, H as VideoIntent, J as VideoMime, W as WidgetPosition, U as createBlocFeedController } from './controller-6fm9oK63.cjs';
1
+ import { r as ScreenshotAdapter, C as CaptureConfig, k as CaptureResult, V as VideoAsset, R as RecordingConfig, L as ClickEvent, K as VoiceConfig, o as MetadataConfig, p as MetadataContext, i as BlocFeedUser, n as FeedbackPayload, x as SecuritySnapshot, v as SecurityConfig } from './controller-DCtQ8rTh.cjs';
2
+ export { B as BlocFeedConfig, c as BlocFeedController, g as BlocFeedError, a as BlocFeedHandle, b as BlocFeedState, h as BlocFeedStrings, l as ConsoleEntry, D as DiagnosticsConfig, E as ElementDescriptor, m as FeedbackApiResponse, F as FeedbackCategory, O as HoverListener, I as ImageAsset, N as NetworkEntry, q as Rect, s as ScreenshotAdapterOptions, t as ScreenshotIntent, u as ScreenshotMime, w as SecurityFinding, y as SessionPhase, Q as StateListener, S as SubmitResult, T as ThemeConfig, z as TransportConfig, G as TriggerStyle, H as VideoIntent, J as VideoMime, W as WidgetPosition, U as createBlocFeedController } from './controller-DCtQ8rTh.cjs';
3
3
 
4
4
  declare function createHtmlToImageAdapter(): ScreenshotAdapter;
5
5
 
package/dist/engine.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { r as ScreenshotAdapter, C as CaptureConfig, k as CaptureResult, V as VideoAsset, R as RecordingConfig, L as ClickEvent, K as VoiceConfig, o as MetadataConfig, p as MetadataContext, i as BlocFeedUser, n as FeedbackPayload, x as SecuritySnapshot, v as SecurityConfig } from './controller-6fm9oK63.js';
2
- export { B as BlocFeedConfig, c as BlocFeedController, g as BlocFeedError, a as BlocFeedHandle, b as BlocFeedState, h as BlocFeedStrings, l as ConsoleEntry, D as DiagnosticsConfig, E as ElementDescriptor, m as FeedbackApiResponse, F as FeedbackCategory, O as HoverListener, I as ImageAsset, N as NetworkEntry, q as Rect, s as ScreenshotAdapterOptions, t as ScreenshotIntent, u as ScreenshotMime, w as SecurityFinding, y as SessionPhase, Q as StateListener, S as SubmitResult, T as ThemeConfig, z as TransportConfig, G as TriggerStyle, H as VideoIntent, J as VideoMime, W as WidgetPosition, U as createBlocFeedController } from './controller-6fm9oK63.js';
1
+ import { r as ScreenshotAdapter, C as CaptureConfig, k as CaptureResult, V as VideoAsset, R as RecordingConfig, L as ClickEvent, K as VoiceConfig, o as MetadataConfig, p as MetadataContext, i as BlocFeedUser, n as FeedbackPayload, x as SecuritySnapshot, v as SecurityConfig } from './controller-DCtQ8rTh.js';
2
+ export { B as BlocFeedConfig, c as BlocFeedController, g as BlocFeedError, a as BlocFeedHandle, b as BlocFeedState, h as BlocFeedStrings, l as ConsoleEntry, D as DiagnosticsConfig, E as ElementDescriptor, m as FeedbackApiResponse, F as FeedbackCategory, O as HoverListener, I as ImageAsset, N as NetworkEntry, q as Rect, s as ScreenshotAdapterOptions, t as ScreenshotIntent, u as ScreenshotMime, w as SecurityFinding, y as SessionPhase, Q as StateListener, S as SubmitResult, T as ThemeConfig, z as TransportConfig, G as TriggerStyle, H as VideoIntent, J as VideoMime, W as WidgetPosition, U as createBlocFeedController } from './controller-DCtQ8rTh.js';
3
3
 
4
4
  declare function createHtmlToImageAdapter(): ScreenshotAdapter;
5
5
 
package/dist/engine.js CHANGED
@@ -1 +1 @@
1
- import {a}from'./chunk-CYITSKBK.js';export{k as clearClickEvents,x as clearDiagnostics,h as clearQueue,A as clearSecurityFindings,e as collectMetadata,t as createBlocFeedController,c as createHtmlToImageAdapter,g as dequeueAll,j as drainClickEvents,w as drainDiagnostics,f as enqueue,q as getMyFeedbackUrl,i as getQueueSize,z as getSecurityFindings,p as getViewerToken,u as installDiagnostics,l as isRecordingSupported,n as isVoiceSupported,d as runCapture,y as runSecretScan,m as startRecording,o as startVoiceRecording,r as transcribeAudio,v as uninstallDiagnostics}from'./chunk-CYITSKBK.js';function s(o){if(o?.aborted)throw new Error("Aborted")}async function v(o){return await new Promise((t,e)=>{let r=new Image;r.onload=()=>t({width:r.naturalWidth,height:r.naturalHeight}),r.onerror=()=>e(new Error("Failed to load generated screenshot")),r.src=o;})}async function l(o,t){let{width:e,height:r}=await v(o);return {dataUrl:o,mime:t,width:e,height:r}}function U(o){return {async captureElement(t,e){if(!a())throw new Error("captureElement can only run in the browser");s(e.signal);let r={scale:e.pixelRatio},n=e.mime==="image/jpeg"?await o.domToJpeg(t,{...r,quality:e.quality??.92}):await o.domToPng(t,r);return s(e.signal),await l(n,e.mime)},async captureFullPage(t){if(!a())throw new Error("captureFullPage can only run in the browser");s(t.signal);let e=document.documentElement,r=Math.max(e.scrollWidth,e.clientWidth),n=Math.max(e.scrollHeight,e.clientHeight),i=Math.min(1,t.maxDimension/Math.max(r,n)),c={width:Math.max(1,Math.round(r*i)),height:Math.max(1,Math.round(n*i)),scale:t.pixelRatio},a$1=t.mime==="image/jpeg"?await o.domToJpeg(e,{...c,quality:t.quality??.92}):await o.domToPng(e,c);return s(t.signal),await l(a$1,t.mime)}}}function O(o){let[t,e]=o.split(",",2);if(!t||!e)throw new Error("Invalid data URL");let n=/data:(.*?);base64/.exec(t)?.[1]||"application/octet-stream",i=atob(e),c=new Uint8Array(i.length);for(let a=0;a<i.length;a+=1)c[a]=i.charCodeAt(a);return new Blob([c],{type:n})}export{U as createModernScreenshotAdapter,O as dataUrlToBlob};
1
+ import {a}from'./chunk-E3AHWKZQ.js';export{k as clearClickEvents,x as clearDiagnostics,h as clearQueue,A as clearSecurityFindings,e as collectMetadata,t as createBlocFeedController,c as createHtmlToImageAdapter,g as dequeueAll,j as drainClickEvents,w as drainDiagnostics,f as enqueue,q as getMyFeedbackUrl,i as getQueueSize,z as getSecurityFindings,p as getViewerToken,u as installDiagnostics,l as isRecordingSupported,n as isVoiceSupported,d as runCapture,y as runSecretScan,m as startRecording,o as startVoiceRecording,r as transcribeAudio,v as uninstallDiagnostics}from'./chunk-E3AHWKZQ.js';function s(o){if(o?.aborted)throw new Error("Aborted")}async function v(o){return await new Promise((t,e)=>{let r=new Image;r.onload=()=>t({width:r.naturalWidth,height:r.naturalHeight}),r.onerror=()=>e(new Error("Failed to load generated screenshot")),r.src=o;})}async function l(o,t){let{width:e,height:r}=await v(o);return {dataUrl:o,mime:t,width:e,height:r}}function U(o){return {async captureElement(t,e){if(!a())throw new Error("captureElement can only run in the browser");s(e.signal);let r={scale:e.pixelRatio},n=e.mime==="image/jpeg"?await o.domToJpeg(t,{...r,quality:e.quality??.92}):await o.domToPng(t,r);return s(e.signal),await l(n,e.mime)},async captureFullPage(t){if(!a())throw new Error("captureFullPage can only run in the browser");s(t.signal);let e=document.documentElement,r=Math.max(e.scrollWidth,e.clientWidth),n=Math.max(e.scrollHeight,e.clientHeight),i=Math.min(1,t.maxDimension/Math.max(r,n)),c={width:Math.max(1,Math.round(r*i)),height:Math.max(1,Math.round(n*i)),scale:t.pixelRatio},a$1=t.mime==="image/jpeg"?await o.domToJpeg(e,{...c,quality:t.quality??.92}):await o.domToPng(e,c);return s(t.signal),await l(a$1,t.mime)}}}function O(o){let[t,e]=o.split(",",2);if(!t||!e)throw new Error("Invalid data URL");let n=/data:(.*?);base64/.exec(t)?.[1]||"application/octet-stream",i=atob(e),c=new Uint8Array(i.length);for(let a=0;a<i.length;a+=1)c[a]=i.charCodeAt(a);return new Blob([c],{type:n})}export{U as createModernScreenshotAdapter,O as dataUrlToBlob};
package/dist/main.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- 'use strict';var chunkNLL5DECC_cjs=require('./chunk-NLL5DECC.cjs'),react=require('react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom'),framerMotion=require('framer-motion');var Y=react.createContext(null);function ie(t){let e=react.useMemo(()=>chunkNLL5DECC_cjs.t({...t.config??{},blocfeed_id:t.blocfeed_id}),[]),[i,r]=react.useState(()=>e.getState());return react.useEffect(()=>e.subscribe(r),[e]),react.useEffect(()=>e.setConfig({...t.config??{},blocfeed_id:t.blocfeed_id}),[e,t.config,t.blocfeed_id]),react.useEffect(()=>()=>e.destroy(),[e]),jsxRuntime.jsx(Y.Provider,{value:{controller:e,state:i},children:t.children})}var Re="blocfeed-styles-v1",It=`
2
+ 'use strict';var chunkUMYASFYV_cjs=require('./chunk-UMYASFYV.cjs'),react=require('react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom'),framerMotion=require('framer-motion');var Y=react.createContext(null);function ie(t){let e=react.useMemo(()=>chunkUMYASFYV_cjs.t({...t.config??{},blocfeed_id:t.blocfeed_id}),[]),[i,r]=react.useState(()=>e.getState());return react.useEffect(()=>e.subscribe(r),[e]),react.useEffect(()=>e.setConfig({...t.config??{},blocfeed_id:t.blocfeed_id}),[e,t.config,t.blocfeed_id]),react.useEffect(()=>()=>e.destroy(),[e]),jsxRuntime.jsx(Y.Provider,{value:{controller:e,state:i},children:t.children})}var Re="blocfeed-styles-v1",It=`
3
3
  :where([data-blocfeed-ui-root]),
4
4
  :where([data-blocfeed-ui-root]) * {
5
5
  box-sizing: border-box;
@@ -881,5 +881,5 @@
881
881
  animation: none;
882
882
  }
883
883
  }
884
- `;function Me(){if(!chunkNLL5DECC_cjs.a()||document.getElementById(Re))return;let t=document.createElement("style");t.id=Re,t.textContent=It,document.head.appendChild(t);}var Le={triggerLabel:"Feedback",panelTitle:"Feedback",hintText:"Click an element to attach your feedback. Press Esc to cancel.",cancelButton:"Cancel",rePickButton:"Re-pick",closeButton:"Close",textareaPlaceholder:"What's happening? What did you expect?",screenshotElement:"Screenshot element",screenshotFullPage:"Full page",capturingText:"Capturing screenshots\u2026",submittingText:"Submitting\u2026",successText:"Sent. Thank you!",toastText:"Feedback sent",sendButton:"Send",categoryBug:"Bug",categoryFeature:"Feature",categoryUx:"UX",categoryGeneral:"General",recordButton:"Record",stopRecordButton:"Stop",recordingText:"Recording\u2026",recordingDeniedText:"Screen share was denied",videoPreviewLabel:"Video attached",removeVideoButton:"Remove",voiceButton:"Voice",voiceStopButton:"Stop",voiceRecordingText:"Recording\u2026",voiceTranscribingText:"Transcribing\u2026",voiceDeniedText:"Microphone access was denied",voiceErrorText:"Voice transcription failed. Please type instead.",voiceEmptyText:"No speech detected. Try again or type instead."};function ze(t){return t?{...Le,...t}:Le}function ae(){let t=react.useContext(Y);if(!t)throw new Error("useBlocFeed must be used within a <BlocFeedProvider />");return {state:t.state,controller:t.controller,start:t.controller.start,stop:t.controller.stop,clearSelection:t.controller.clearSelection,submit:t.controller.submit,startRecording:t.controller.startRecording,stopRecording:t.controller.stopRecording,removeVideo:t.controller.removeVideo}}function y(t){switch(t){case "bottom-left":return "bf-trigger bf-trigger-bl";case "top-right":return "bf-trigger bf-trigger-tr";case "top-left":return "bf-trigger bf-trigger-tl";default:return "bf-trigger"}}function g({size:t=14}){return jsxRuntime.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M20 6L9 17l-5-5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ie({size:t=14}){return jsxRuntime.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M21 11.5a8.38 8.38 0 01-.9 3.8 8.5 8.5 0 01-7.6 4.7 8.38 8.38 0 01-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 01-.9-3.8 8.5 8.5 0 014.7-7.6 8.38 8.38 0 013.8-.9h.5a8.48 8.48 0 018 8v.5z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ae({size:t=16}){return jsxRuntime.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[jsxRuntime.jsx("path",{d:"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx("path",{d:"M22 6l-10 7L2 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function _e({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){return i?jsxRuntime.jsxs("button",{className:y(t),type:"button",onClick:e,"aria-label":r,children:[p?jsxRuntime.jsx("span",{style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:14})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"bf-dot","aria-hidden":"true"}),r]}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]}):null}function h(){let[t,e]=react.useState(()=>typeof window>"u"?false:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return react.useEffect(()=>{let i=window.matchMedia("(prefers-reduced-motion: reduce)"),r=a=>e(a.matches);return i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[]),t}var Vt={duration:.18,ease:"easeOut"},$t={duration:0};function Oe({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=h(),c=o?$t:Vt;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:y(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:c,whileTap:{scale:.92},style:{overflow:"hidden"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(framerMotion.motion.span,{className:"bf-dot","aria-hidden":"true",animate:o?{}:{scale:n?1:[1,1.2,1],boxShadow:n?"0 0 0 4px rgba(99, 102, 241, 0.18)":["0 0 0 4px rgba(99, 102, 241, 0.18)","0 0 0 8px rgba(99, 102, 241, 0.28)","0 0 0 4px rgba(99, 102, 241, 0.18)"]},transition:n||o?c:{duration:2,repeat:1/0,ease:"easeInOut"}}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:o?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:o?0:-6},transition:c,style:{whiteSpace:"nowrap"},children:r},"label")}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"dot")})}var Yt={duration:.18,ease:"easeOut"},Ve={duration:0};function Ke({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=h(),c=o?Ve:Yt;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsxs(framerMotion.motion.div,{className:y(t),initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{y:8,opacity:0},transition:c,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),style:{background:"transparent",border:"none",boxShadow:"none",padding:0},children:[jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:o?0:4},animate:{opacity:1,y:0},exit:{opacity:0,y:o?0:4},transition:c,style:{position:"absolute",bottom:"calc(100% + 8px)",left:"50%",transform:"translateX(-50%)",padding:"6px 12px",borderRadius:"8px",background:"var(--bf-panel-bg)",border:"1px solid var(--bf-border)",boxShadow:"var(--bf-shadow)",whiteSpace:"nowrap",fontSize:"12px",color:"var(--bf-panel-fg)",pointerEvents:"none"},children:r},"tooltip")}),jsxRuntime.jsxs(framerMotion.motion.button,{type:"button",onClick:e,"aria-label":r,style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:"40px",height:"40px",borderRadius:"50%",border:"1px solid var(--bf-border)",background:"var(--bf-panel-bg)",color:"var(--bf-panel-fg)",boxShadow:"var(--bf-shadow)",cursor:"pointer",padding:0},animate:o?{}:{y:[0,-3,0]},transition:o?Ve:{y:{duration:3,repeat:1/0,ease:"easeInOut"}},whileHover:{scale:1.1,borderColor:"var(--bf-accent)"},whileTap:{scale:.9},children:[p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:16})},"success"):jsxRuntime.jsx(Ie,{size:16}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge bf-badge-float","aria-label":`${a} queued`,children:a})]})]},"bubble")})}var Qt={duration:.2,ease:"easeOut"},qt={duration:0};function Xe(t){return t==="bottom-left"||t==="top-left"}function Jt(t){return `bf-trigger-edge ${Xe(t)?"bf-trigger-edge-left":"bf-trigger-edge-right"}`}function Ye({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=Xe(t),c=h(),x=c?qt:Qt;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:Jt(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{opacity:0,width:0},animate:{opacity:1,width:n?140:22,height:n?40:90},exit:{width:0,opacity:0},transition:x,whileTap:{scale:.97},style:{top:"50%",translateY:"-50%"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:x,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(framerMotion.motion.span,{animate:{rotate:c||n?0:o?-90:90,opacity:n?1:.6},transition:x,style:{display:"flex",alignItems:"center",gap:"8px",whiteSpace:"nowrap",fontSize:"12px",letterSpacing:"0.5px",textTransform:"uppercase"},children:[n&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:{duration:.12},style:{width:"6px",height:"6px",borderRadius:"50%",background:"var(--bf-accent)",flexShrink:0}}),r]}),jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",animate:{opacity:n?1:0},transition:{duration:.12},style:{position:"absolute",top:0,bottom:0,[o?"left":"right"]:0,width:"2px",background:"var(--bf-accent)"}}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"edge-tab")})}var to={duration:.18,ease:"easeOut"},oo={duration:0};function je({delay:t,hovered:e,reduced:i}){return i?null:jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",style:{position:"absolute",width:"10px",height:"10px",borderRadius:"50%",border:"2px solid var(--bf-accent)",pointerEvents:"none"},animate:e?{scale:1,opacity:0}:{scale:[1,1.8],opacity:[.5,0]},transition:e?{duration:.15}:{duration:2,repeat:1/0,delay:t,ease:"easeOut"}})}function qe({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=h(),c=o?oo:to;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:y(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:c,whileTap:{scale:.92},style:{overflow:"hidden"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:"10px",height:"10px",flexShrink:0},children:[jsxRuntime.jsx(je,{delay:0,hovered:n,reduced:o}),jsxRuntime.jsx(je,{delay:.7,hovered:n,reduced:o}),jsxRuntime.jsx(framerMotion.motion.span,{className:"bf-dot","aria-hidden":"true",style:{position:"relative",zIndex:1}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:o?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:o?0:-6},transition:c,style:{whiteSpace:"nowrap"},children:r},"label")}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"pulse-ring")})}var no={duration:.18,ease:"easeOut"},so={duration:0};function co(t){switch(t){case "bottom-left":return "bf-trigger-minimal bf-trigger-bl";case "top-right":return "bf-trigger-minimal bf-trigger-tr";case "top-left":return "bf-trigger-minimal bf-trigger-tl";default:return "bf-trigger-minimal"}}function et({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=h(),c=o?so:no;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsxs(framerMotion.motion.button,{className:co(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{opacity:0,y:o?0:5},animate:{opacity:n?1:.65,y:0},exit:{opacity:0,y:o?0:5},transition:c,whileTap:{scale:.95},children:[p?jsxRuntime.jsx("span",{style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:14})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:r}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge",style:{marginLeft:"4px"},"aria-label":`${a} queued`,children:a})]}),!o&&jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",style:{position:"absolute",bottom:4,left:4,right:4,height:"2px",background:"var(--bf-accent)",borderRadius:"1px",transformOrigin:"left"},initial:false,animate:{scaleX:n?1:0},transition:c})]},"minimal")})}var po={duration:.18,ease:"easeOut"},uo={duration:0};function ot({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=h(),c=o?uo:po;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:y(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:c,whileTap:{scale:.9},style:{overflow:"hidden"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(framerMotion.motion.span,{style:{display:"inline-flex",flexShrink:0},animate:o?{}:n?{scale:1.2,rotate:0}:{rotate:[-5,5,-5]},transition:n||o?c:{duration:3,repeat:1/0,ease:"easeInOut"},children:jsxRuntime.jsx(Ae,{size:16})}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:o?0:-8},animate:{opacity:1,x:0},exit:{opacity:0,x:o?0:-8},transition:c,style:{whiteSpace:"nowrap"},children:r},"label")}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"icon-pop")})}var ho={duration:.18,ease:"easeOut"},xo={duration:0};function at({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=h(),c=o?xo:ho;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:y(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:c,whileTap:{scale:.92},style:{overflow:"hidden"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"10px",height:"10px",flexShrink:0},children:[jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",style:{width:"10px",height:"10px",borderRadius:"50%",background:"var(--bf-accent)",position:"relative",zIndex:1},animate:o?{}:{opacity:n?1:[.5,1,.5],boxShadow:n?"0 0 8px 2px var(--bf-accent)":["0 0 4px 1px var(--bf-accent)","0 0 12px 4px var(--bf-accent)","0 0 4px 1px var(--bf-accent)"]},transition:n||o?c:{duration:2,repeat:1/0,ease:"easeInOut"}}),!n&&!o&&jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",style:{position:"absolute",width:"18px",height:"2px",background:"linear-gradient(90deg, var(--bf-accent), transparent)",transformOrigin:"left center",left:"5px",top:"4px"},animate:{rotate:[0,360]},transition:{duration:4,repeat:1/0,ease:"linear"}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:o?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:o?0:-6},transition:c,style:{whiteSpace:"nowrap"},children:r},"label")}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"beacon")})}var To={duration:.18,ease:"easeOut"},Eo={duration:0};function lt({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),[o,c]=react.useState(0),x=h(),z=x?Eo:To,f=react.useRef(null);react.useEffect(()=>{if(f.current&&(clearInterval(f.current),f.current=null),!i||n||x){c(n||x?r.length:0);return}let b=8,T=r.length*2+b*2,m=0;return f.current=setInterval(()=>{m=(m+1)%T,m<=r.length?c(m):m<=r.length+b?c(r.length):m<=r.length*2+b?c(r.length*2+b-m):c(0);},100),()=>{f.current&&(clearInterval(f.current),f.current=null);}},[i,n,x,r]);let S=r.slice(0,o);return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:y(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{opacity:0,y:x?0:5},animate:{opacity:1,y:0},exit:{opacity:0,y:x?0:5},transition:z,whileTap:{scale:.95},style:{minWidth:"44px"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:z,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"bf-dot","aria-hidden":"true"}),jsxRuntime.jsxs("span",{style:{whiteSpace:"nowrap",minWidth:"1ch"},children:[S,jsxRuntime.jsx("span",{className:"bf-cursor","aria-hidden":"true"})]}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"typewriter")})}function dt(t){switch(t){case "dot":return Oe;case "bubble":return Ke;case "edge-tab":return Ye;case "pulse-ring":return qe;case "minimal":return et;case "icon-pop":return ot;case "beacon":return at;case "typewriter":return lt;default:return _e}}function ft(t,e,i){return Math.max(e,Math.min(i,t))}function No(t,e,i="bottom-right"){let a=window.innerWidth,p=window.innerHeight,n;n=ft(t.x,12,Math.max(12,a-e-12));let l=t.y+t.height+12,o=Math.max(12,t.y-240);return {top:l+240<=p?l:o,left:n}}function Fo(t){let{rect:e}=t,i={left:`${e.x}px`,top:`${e.y}px`,width:`${Math.max(0,e.width)}px`,height:`${Math.max(0,e.height)}px`};return jsxRuntime.jsx("div",{className:"bf-highlight",style:i,"aria-hidden":"true"})}function Ro(t){let e=react.useRef(null);return react.useEffect(()=>{if(!t||!e.current)return;let i=e.current,r=i.querySelector(".bf-textarea");r?.focus();let a=n=>{if(n.key!=="Tab")return;let l=i.querySelectorAll('button:not([disabled]), textarea:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(l.length===0)return;let o=l[0],c=l[l.length-1];n.shiftKey&&document.activeElement===o?(n.preventDefault(),c.focus()):!n.shiftKey&&document.activeElement===c&&(n.preventDefault(),o.focus());},p=n=>{let l=n.target;l&&(i.contains(l)||(n.stopImmediatePropagation(),r?.focus()));};return document.addEventListener("keydown",a,{capture:true}),document.addEventListener("focusin",p,{capture:true}),()=>{document.removeEventListener("keydown",a,{capture:true}),document.removeEventListener("focusin",p,{capture:true});}},[t]),e}function Mo(t,e){return t?typeof t=="function"?t(e):t.some(i=>i.endsWith("*")?e.startsWith(i.slice(0,-1)):e===i):true}var ce=new Set,pt=false;function Lo(){if(pt||typeof window>"u")return;pt=true;let t=history.pushState,e=history.replaceState,i=()=>{for(let r of ce)r();};history.pushState=function(...r){t.apply(this,r),setTimeout(i,0);},history.replaceState=function(...r){e.apply(this,r),setTimeout(i,0);};}function zo(t){let[e,i]=react.useState(()=>typeof window<"u"?window.location.pathname:"/");return react.useEffect(()=>{if(typeof window>"u")return;let r=()=>i(window.location.pathname);return window.addEventListener("popstate",r),Lo(),ce.add(r),()=>{window.removeEventListener("popstate",r),ce.delete(r);}},[]),Mo(t,e)}function Io(t){let[e,i]=react.useState(()=>!t||t==="dark"?"dark":t==="light"?"light":typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return react.useEffect(()=>{if(t!=="auto"){i(t==="light"?"light":"dark");return}let r=window.matchMedia("(prefers-color-scheme: dark)"),a=p=>i(p.matches?"dark":"light");return i(r.matches?"dark":"light"),r.addEventListener("change",a),()=>r.removeEventListener("change",a)},[t]),e}var Ao=["bug","feature","ux","general"],Wo={bug:"categoryBug",feature:"categoryFeature",ux:"categoryUx",general:"categoryGeneral"};function X(t){let e=Math.floor(t/1e3),i=Math.floor(e/60),r=e%60;return `${i}:${String(r).padStart(2,"0")}`}function _o(t){return t<1024*1024?`${Math.round(t/1024)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Ho(t){let{state:e,controller:i,start:r,stop:a,clearSelection:p,submit:n}=ae(),l=t.config.ui?.position,o=ze(t.config.ui?.strings),c=t.config.ui?.branding!==false,[x,z]=react.useState(null),[f,S]=react.useState(""),[b,T]=react.useState(t.config.capture?.element??true),[m,C]=react.useState(t.config.capture?.fullPage??false),[bt,de]=react.useState(null),[D,fe]=react.useState(void 0),pe=t.config.ui?.categories??Ao,gt=t.config.recording?.enabled===true&&chunkNLL5DECC_cjs.l(),mt=t.config.recording?.maxDurationMs??3e4,ue=i.getConfig().voice,ht=ue?.enabled===true&&chunkNLL5DECC_cjs.n(),xt=ue?.maxDurationMs??6e4,[vt,yt]=react.useState(false),[J,wt]=react.useState(0);react.useEffect(()=>{let s=window.setTimeout(()=>{let v=chunkNLL5DECC_cjs.z();wt(v.findings.length);},500);return ()=>window.clearTimeout(s)},[]),react.useImperativeHandle(t.handleRef,()=>({open:r,close:a,submit:s=>n(s),startRecording:()=>i.startRecording(),stopRecording:()=>i.stopRecording(),get isOpen(){return e.phase!=="idle"}}),[r,a,n,i,e.phase]);let be=e.phase==="review"||e.phase==="capturing"||e.phase==="submitting"||e.phase==="error"||e.phase==="success",kt=Ro(be),[Tt,Et]=react.useState(0);react.useEffect(()=>{e.phase==="idle"&&Et(chunkNLL5DECC_cjs.i());},[e.phase]);let[St,ge]=react.useState(false),me=react.useRef(e.phase);react.useEffect(()=>{if(me.current==="success"&&e.phase==="idle"){ge(true);let s=window.setTimeout(()=>ge(false),1500);return ()=>window.clearTimeout(s)}me.current=e.phase;},[e.phase]),react.useEffect(()=>{let s=t.config.ui?.shortcut;if(!s)return;let v=s.toLowerCase().split("+").map(N=>N.trim()),B=v[v.length-1]||"",I=new Set(v.slice(0,-1)),ve=N=>{let Nt=/Mac|iPod|iPhone|iPad/.test(navigator.platform);if(I.has("mod")){if(Nt?!N.metaKey:!N.ctrlKey)return}else if(I.has("ctrl")&&!N.ctrlKey||(I.has("meta")||I.has("cmd"))&&!N.metaKey)return;I.has("shift")&&!N.shiftKey||(I.has("alt")||I.has("option"))&&!N.altKey||N.key.toLowerCase()===B&&(N.preventDefault(),e.phase==="idle"?r():a());};return document.addEventListener("keydown",ve),()=>document.removeEventListener("keydown",ve)},[t.config.ui?.shortcut,e.phase,r,a]),react.useEffect(()=>i.subscribeHover(z),[i]),react.useEffect(()=>{let s=i.__unsafeGetSelectedElement();if(!s||e.phase==="idle"||e.phase==="picking"){de(null);return}let v=()=>{de(chunkNLL5DECC_cjs.b(s.getBoundingClientRect()));};v();let B=()=>v();return window.addEventListener("scroll",B,{capture:true,passive:true}),window.addEventListener("resize",B,{passive:true}),()=>{window.removeEventListener("scroll",B,{capture:true}),window.removeEventListener("resize",B);}},[i,e.phase,e.selection?.selector]),react.useEffect(()=>{e.phase==="review"&&(S(""),T(t.config.capture?.element??true),C(t.config.capture?.fullPage??false),fe(void 0),V(null));},[e.phase,e.selection?.selector,t.config.capture?.element,t.config.capture?.fullPage]),react.useEffect(()=>{if(e.phase!=="success")return;let s=window.setTimeout(()=>a(),1200);return ()=>window.clearTimeout(s)},[e.phase,a]);let E=e.phase==="capturing"||e.phase==="submitting",M=e.phase==="picking"?x?.rect??null:bt??e.selection?.rect??null,Z=react.useMemo(()=>M?No(M,360,l):null,[M?.x,M?.y,M?.width,M?.height,l]),he=e.lastError?.message,ee=react.useCallback(()=>{let s={capture:{element:b,fullPage:m}};D&&(s.category=D),n(f,s);},[n,f,b,m,D]),Ct=react.useCallback(s=>{(s.metaKey||s.ctrlKey)&&s.key==="Enter"&&f.trim().length>0&&!E&&(s.preventDefault(),ee());},[ee,f,E]),[xe,V]=react.useState(null),Pt=react.useCallback(async()=>{if(e.voiceRecording){i.stopVoice();return}V(null);let s=await i.startVoice();if(s?.text)S(v=>v?v+" "+s.text:s.text);else if(s?.warning)V(o.voiceEmptyText);else if(!s){let v=i.getState().lastError;if(v){let B=v.message?.toLowerCase()??"";B.includes("denied")||B.includes("permission")||B.includes("not allowed")?V(o.voiceDeniedText):V(o.voiceErrorText);}}},[e.voiceRecording,i,o]),Bt=dt(t.config.ui?.triggerStyle);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Bt,{position:l,onClick:()=>r(),isVisible:e.phase==="idle",label:t.config.ui?.triggerLabel??o.triggerLabel,queueCount:Tt,showSuccess:St}),e.phase!=="idle"&&e.phase!=="recording"&&jsxRuntime.jsxs("div",{className:"bf-overlay",role:"presentation",children:[e.phase!=="picking"&&jsxRuntime.jsx("div",{className:"bf-blocker",role:"presentation",onClick:()=>a()}),M&&jsxRuntime.jsx(Fo,{rect:M}),e.phase==="picking"&&jsxRuntime.jsxs("div",{className:"bf-hint",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("p",{id:"bf-hint-text",children:o.hintText}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>a(),"aria-label":o.cancelButton,children:o.cancelButton})]}),be&&Z&&jsxRuntime.jsxs("div",{ref:kt,className:"bf-panel",style:{left:Z.left,top:Z.top},role:"dialog","aria-modal":"true","aria-label":"Feedback form",children:[jsxRuntime.jsxs("div",{className:"bf-panelHeader",children:[jsxRuntime.jsx("div",{className:"bf-title",id:"bf-panel-title",children:o.panelTitle}),jsxRuntime.jsxs("div",{className:"bf-row",style:{justifyContent:"flex-end"},children:[jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>p(),disabled:E,"aria-label":o.rePickButton,children:o.rePickButton}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>a(),disabled:E,"aria-label":o.closeButton,children:o.closeButton})]})]}),jsxRuntime.jsxs("div",{className:"bf-panelBody",children:[jsxRuntime.jsx("textarea",{className:"bf-textarea",placeholder:o.textareaPlaceholder,value:f,onChange:s=>S(s.target.value),onKeyDown:Ct,disabled:E,"aria-label":o.panelTitle}),pe.length>0&&jsxRuntime.jsx("div",{className:"bf-pills",role:"group","aria-label":"Feedback category",children:pe.map(s=>jsxRuntime.jsx("button",{type:"button",className:`bf-pill${D===s?" bf-pill-active":""}`,onClick:()=>fe(D===s?void 0:s),disabled:E,children:o[Wo[s]]},s))}),jsxRuntime.jsxs("div",{className:"bf-row",role:"group","aria-label":o.screenshotElement,children:[jsxRuntime.jsxs("label",{children:[jsxRuntime.jsx("input",{type:"checkbox",checked:b,onChange:s=>T(s.target.checked),disabled:E}),o.screenshotElement]}),jsxRuntime.jsxs("label",{children:[jsxRuntime.jsx("input",{type:"checkbox",checked:m,onChange:s=>C(s.target.checked),disabled:E}),o.screenshotFullPage]})]}),ht&&e.phase==="review"&&!e.voiceTranscribing&&jsxRuntime.jsx("button",{type:"button",className:`bf-voice-btn${e.voiceRecording?" bf-voice-btn-active":""}`,onClick:Pt,disabled:E,"aria-label":e.voiceRecording?o.voiceStopButton:o.voiceButton,children:e.voiceRecording?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"bf-rec-dot bf-rec-dot-pulse","aria-hidden":"true"}),o.voiceRecordingText," ",X(e.voiceElapsedMs??0)," / ",X(xt)," \u2014 ",o.voiceStopButton]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{className:"bf-mic-icon",viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[jsxRuntime.jsx("rect",{x:"9",y:"1",width:"6",height:"11",rx:"3"}),jsxRuntime.jsx("path",{d:"M19 10v1a7 7 0 0 1-14 0v-1"}),jsxRuntime.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),jsxRuntime.jsx("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]}),o.voiceButton]})}),e.voiceTranscribing&&jsxRuntime.jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("span",{className:"bf-spinner","aria-hidden":"true"}),o.voiceTranscribingText]}),xe&&!e.voiceRecording&&!e.voiceTranscribing&&jsxRuntime.jsx("div",{className:"bf-error",role:"alert",children:xe}),gt&&e.phase==="review"&&!e.video&&jsxRuntime.jsxs("button",{type:"button",className:"bf-record-btn",onClick:()=>i.startRecording(),disabled:E,"aria-label":o.recordButton,children:[jsxRuntime.jsx("span",{className:"bf-rec-dot","aria-hidden":"true"}),o.recordButton]}),e.video&&e.phase==="review"&&jsxRuntime.jsxs("div",{className:"bf-video-preview",children:[jsxRuntime.jsx("video",{src:e.video.blobUrl,controls:true,muted:true,playsInline:true}),jsxRuntime.jsx("button",{type:"button",className:"bf-video-remove",onClick:()=>i.removeVideo(),"aria-label":o.removeVideoButton,children:"\xD7"}),jsxRuntime.jsxs("div",{className:"bf-video-meta",children:[o.videoPreviewLabel," (",X(e.video.durationMs),", ",_o(e.video.sizeBytes),")"]})]}),e.phase==="capturing"&&jsxRuntime.jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("span",{className:"bf-spinner","aria-hidden":"true"}),o.capturingText]}),e.phase==="submitting"&&jsxRuntime.jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("span",{className:"bf-spinner","aria-hidden":"true"}),o.submittingText]}),e.phase==="success"&&jsxRuntime.jsx("div",{className:"bf-status",role:"status","aria-live":"polite",children:o.successText}),e.phase==="error"&&he&&jsxRuntime.jsx("div",{className:"bf-error",role:"alert",children:he}),jsxRuntime.jsxs("div",{className:"bf-actions",children:[jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>a(),disabled:E,"aria-label":o.cancelButton,children:o.cancelButton}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn bf-btnPrimary",onClick:ee,disabled:E||f.trim().length===0,"aria-label":o.sendButton,children:o.sendButton})]})]}),c&&jsxRuntime.jsxs("div",{className:"bf-watermark",children:[(()=>{let s=chunkNLL5DECC_cjs.q();return s?jsxRuntime.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"bf-my-feedback-link",children:"View my feedback"}):null})(),jsxRuntime.jsx("a",{href:"https://blocfeed.com",target:"_blank",rel:"noopener noreferrer",children:"Powered by BlocFeed"})]})]})]}),e.phase==="recording"&&jsxRuntime.jsxs("div",{className:`bf-recording-bar bf-pos-${l}`,role:"status","aria-live":"polite","data-blocfeed-ui":"true",children:[jsxRuntime.jsx("span",{className:"bf-rec-dot bf-rec-dot-pulse","aria-hidden":"true"}),jsxRuntime.jsxs("span",{className:"bf-recording-bar-timer",children:[o.recordingText," ",X(e.recordingElapsedMs??0)," / ",X(mt)]}),jsxRuntime.jsx("button",{type:"button",className:"bf-recording-bar-stop",onClick:()=>i.stopRecording(),"aria-label":o.stopRecordButton,children:o.stopRecordButton})]}),e.phase==="success"&&jsxRuntime.jsxs("div",{className:"bf-toast",role:"status","aria-live":"polite",children:[o.toastText,(()=>{let s=chunkNLL5DECC_cjs.q();return s?jsxRuntime.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"bf-toast-link",children:"View my feedback"}):null})()]}),J>0&&!vt&&jsxRuntime.jsxs("div",{className:"bf-security-banner",role:"alert",children:[jsxRuntime.jsx("button",{type:"button",className:"bf-security-banner-dismiss",onClick:()=>yt(true),"aria-label":"Dismiss",children:"\xD7"}),jsxRuntime.jsx("strong",{children:"Security Warning"}),J," potential secret",J>1?"s":""," exposed in client code. Check your environment variables."]})]})}var Oo=react.forwardRef(function(e,i){let r={...e.config??{},blocfeed_id:e.blocfeed_id},[a,p]=react.useState(null),n=zo(r.ui?.showOn),l=Io(r.ui?.theme?.mode),o=!!r.diagnostics;react.useEffect(()=>{if(o)return chunkNLL5DECC_cjs.u(r.diagnostics),()=>chunkNLL5DECC_cjs.v()},[o]);let c=!!r.security;react.useEffect(()=>{c&&chunkNLL5DECC_cjs.y(r.security);},[c]);let x=react.useRef(e.config?.metadata?.enrich);x.current=e.config?.metadata?.enrich;let z=react.useMemo(()=>{if(e.config)return {...e.config,metadata:{...e.config.metadata,enrich:async f=>{let S=x.current,b=S?await S(f):{},T=chunkNLL5DECC_cjs.w(),m=chunkNLL5DECC_cjs.z(),C=chunkNLL5DECC_cjs.j();return {...b,...T.consoleLogs.length>0?{_consoleLogs:T.consoleLogs}:{},...T.networkErrors.length>0?{_networkErrors:T.networkErrors}:{},...m.findings.length>0?{_securityFindings:m.findings}:{},...C.length>0?{_clickEvents:C}:{}}}}}},[]);return react.useEffect(()=>{Me();let f=document.createElement("div");f.setAttribute("data-blocfeed-ui-root","true"),f.setAttribute("data-blocfeed-ui","true"),f.setAttribute("data-bf-theme",l);let S=r.ui?.zIndex;typeof S=="number"&&f.style.setProperty("--bf-z",String(S));let b=r.ui?.theme;b&&(b.accentColor&&f.style.setProperty("--bf-accent",b.accentColor),b.panelBackground&&f.style.setProperty("--bf-panel-bg",b.panelBackground),b.panelForeground&&f.style.setProperty("--bf-panel-fg",b.panelForeground),b.fontFamily&&f.style.setProperty("--bf-font",b.fontFamily));let T=C=>C.stopPropagation(),m=["pointerdown","pointerup","mousedown","mouseup","click","touchstart","touchend"];for(let C of m)f.addEventListener(C,T);try{document.body.appendChild(f);}catch{return}return p(f),()=>{for(let C of m)f.removeEventListener(C,T);f.remove(),p(null);}},[r.ui?.zIndex,r.ui?.theme?.accentColor,r.ui?.theme?.panelBackground,r.ui?.theme?.panelForeground,r.ui?.theme?.fontFamily,l]),!n||!a?null:reactDom.createPortal(jsxRuntime.jsx(ie,{blocfeed_id:r.blocfeed_id,...z?{config:z}:{},children:jsxRuntime.jsx(Ho,{config:r,handleRef:i})}),a)});
885
- Object.defineProperty(exports,"BehavioralTracker",{enumerable:true,get:function(){return chunkNLL5DECC_cjs.s}});exports.BlocFeedProvider=ie;exports.BlocFeedWidget=Oo;exports.useBlocFeed=ae;
884
+ `;function Me(){if(!chunkUMYASFYV_cjs.a()||document.getElementById(Re))return;let t=document.createElement("style");t.id=Re,t.textContent=It,document.head.appendChild(t);}var Le={triggerLabel:"Feedback",panelTitle:"Feedback",hintText:"Click an element to attach your feedback. Press Esc to cancel.",cancelButton:"Cancel",rePickButton:"Re-pick",closeButton:"Close",textareaPlaceholder:"What's happening? What did you expect?",screenshotElement:"Screenshot element",screenshotFullPage:"Full page",capturingText:"Capturing screenshots\u2026",submittingText:"Submitting\u2026",successText:"Sent. Thank you!",toastText:"Feedback sent",sendButton:"Send",categoryBug:"Bug",categoryFeature:"Feature",categoryUx:"UX",categoryGeneral:"General",recordButton:"Record",stopRecordButton:"Stop",recordingText:"Recording\u2026",recordingDeniedText:"Screen share was denied",videoPreviewLabel:"Video attached",removeVideoButton:"Remove",voiceButton:"Voice",voiceStopButton:"Stop",voiceRecordingText:"Recording\u2026",voiceTranscribingText:"Transcribing\u2026",voiceDeniedText:"Microphone access was denied",voiceErrorText:"Voice transcription failed. Please type instead.",voiceEmptyText:"No speech detected. Try again or type instead."};function ze(t){return t?{...Le,...t}:Le}function ae(){let t=react.useContext(Y);if(!t)throw new Error("useBlocFeed must be used within a <BlocFeedProvider />");return {state:t.state,controller:t.controller,start:t.controller.start,stop:t.controller.stop,clearSelection:t.controller.clearSelection,submit:t.controller.submit,startRecording:t.controller.startRecording,stopRecording:t.controller.stopRecording,removeVideo:t.controller.removeVideo}}function y(t){switch(t){case "bottom-left":return "bf-trigger bf-trigger-bl";case "top-right":return "bf-trigger bf-trigger-tr";case "top-left":return "bf-trigger bf-trigger-tl";default:return "bf-trigger"}}function g({size:t=14}){return jsxRuntime.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M20 6L9 17l-5-5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ie({size:t=14}){return jsxRuntime.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M21 11.5a8.38 8.38 0 01-.9 3.8 8.5 8.5 0 01-7.6 4.7 8.38 8.38 0 01-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 01-.9-3.8 8.5 8.5 0 014.7-7.6 8.38 8.38 0 013.8-.9h.5a8.48 8.48 0 018 8v.5z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ae({size:t=16}){return jsxRuntime.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[jsxRuntime.jsx("path",{d:"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx("path",{d:"M22 6l-10 7L2 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function _e({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){return i?jsxRuntime.jsxs("button",{className:y(t),type:"button",onClick:e,"aria-label":r,children:[p?jsxRuntime.jsx("span",{style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:14})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"bf-dot","aria-hidden":"true"}),r]}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]}):null}function h(){let[t,e]=react.useState(()=>typeof window>"u"?false:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return react.useEffect(()=>{let i=window.matchMedia("(prefers-reduced-motion: reduce)"),r=a=>e(a.matches);return i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[]),t}var Vt={duration:.18,ease:"easeOut"},$t={duration:0};function Oe({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=h(),c=o?$t:Vt;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:y(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:c,whileTap:{scale:.92},style:{overflow:"hidden"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(framerMotion.motion.span,{className:"bf-dot","aria-hidden":"true",animate:o?{}:{scale:n?1:[1,1.2,1],boxShadow:n?"0 0 0 4px rgba(99, 102, 241, 0.18)":["0 0 0 4px rgba(99, 102, 241, 0.18)","0 0 0 8px rgba(99, 102, 241, 0.28)","0 0 0 4px rgba(99, 102, 241, 0.18)"]},transition:n||o?c:{duration:2,repeat:1/0,ease:"easeInOut"}}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:o?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:o?0:-6},transition:c,style:{whiteSpace:"nowrap"},children:r},"label")}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"dot")})}var Yt={duration:.18,ease:"easeOut"},Ve={duration:0};function Ke({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=h(),c=o?Ve:Yt;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsxs(framerMotion.motion.div,{className:y(t),initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{y:8,opacity:0},transition:c,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),style:{background:"transparent",border:"none",boxShadow:"none",padding:0},children:[jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:o?0:4},animate:{opacity:1,y:0},exit:{opacity:0,y:o?0:4},transition:c,style:{position:"absolute",bottom:"calc(100% + 8px)",left:"50%",transform:"translateX(-50%)",padding:"6px 12px",borderRadius:"8px",background:"var(--bf-panel-bg)",border:"1px solid var(--bf-border)",boxShadow:"var(--bf-shadow)",whiteSpace:"nowrap",fontSize:"12px",color:"var(--bf-panel-fg)",pointerEvents:"none"},children:r},"tooltip")}),jsxRuntime.jsxs(framerMotion.motion.button,{type:"button",onClick:e,"aria-label":r,style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:"40px",height:"40px",borderRadius:"50%",border:"1px solid var(--bf-border)",background:"var(--bf-panel-bg)",color:"var(--bf-panel-fg)",boxShadow:"var(--bf-shadow)",cursor:"pointer",padding:0},animate:o?{}:{y:[0,-3,0]},transition:o?Ve:{y:{duration:3,repeat:1/0,ease:"easeInOut"}},whileHover:{scale:1.1,borderColor:"var(--bf-accent)"},whileTap:{scale:.9},children:[p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:16})},"success"):jsxRuntime.jsx(Ie,{size:16}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge bf-badge-float","aria-label":`${a} queued`,children:a})]})]},"bubble")})}var Qt={duration:.2,ease:"easeOut"},qt={duration:0};function Xe(t){return t==="bottom-left"||t==="top-left"}function Jt(t){return `bf-trigger-edge ${Xe(t)?"bf-trigger-edge-left":"bf-trigger-edge-right"}`}function Ye({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=Xe(t),c=h(),x=c?qt:Qt;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:Jt(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{opacity:0,width:0},animate:{opacity:1,width:n?140:22,height:n?40:90},exit:{width:0,opacity:0},transition:x,whileTap:{scale:.97},style:{top:"50%",translateY:"-50%"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:x,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(framerMotion.motion.span,{animate:{rotate:c||n?0:o?-90:90,opacity:n?1:.6},transition:x,style:{display:"flex",alignItems:"center",gap:"8px",whiteSpace:"nowrap",fontSize:"12px",letterSpacing:"0.5px",textTransform:"uppercase"},children:[n&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:{duration:.12},style:{width:"6px",height:"6px",borderRadius:"50%",background:"var(--bf-accent)",flexShrink:0}}),r]}),jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",animate:{opacity:n?1:0},transition:{duration:.12},style:{position:"absolute",top:0,bottom:0,[o?"left":"right"]:0,width:"2px",background:"var(--bf-accent)"}}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"edge-tab")})}var to={duration:.18,ease:"easeOut"},oo={duration:0};function je({delay:t,hovered:e,reduced:i}){return i?null:jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",style:{position:"absolute",width:"10px",height:"10px",borderRadius:"50%",border:"2px solid var(--bf-accent)",pointerEvents:"none"},animate:e?{scale:1,opacity:0}:{scale:[1,1.8],opacity:[.5,0]},transition:e?{duration:.15}:{duration:2,repeat:1/0,delay:t,ease:"easeOut"}})}function qe({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=h(),c=o?oo:to;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:y(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:c,whileTap:{scale:.92},style:{overflow:"hidden"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:"10px",height:"10px",flexShrink:0},children:[jsxRuntime.jsx(je,{delay:0,hovered:n,reduced:o}),jsxRuntime.jsx(je,{delay:.7,hovered:n,reduced:o}),jsxRuntime.jsx(framerMotion.motion.span,{className:"bf-dot","aria-hidden":"true",style:{position:"relative",zIndex:1}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:o?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:o?0:-6},transition:c,style:{whiteSpace:"nowrap"},children:r},"label")}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"pulse-ring")})}var no={duration:.18,ease:"easeOut"},so={duration:0};function co(t){switch(t){case "bottom-left":return "bf-trigger-minimal bf-trigger-bl";case "top-right":return "bf-trigger-minimal bf-trigger-tr";case "top-left":return "bf-trigger-minimal bf-trigger-tl";default:return "bf-trigger-minimal"}}function et({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=h(),c=o?so:no;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsxs(framerMotion.motion.button,{className:co(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{opacity:0,y:o?0:5},animate:{opacity:n?1:.65,y:0},exit:{opacity:0,y:o?0:5},transition:c,whileTap:{scale:.95},children:[p?jsxRuntime.jsx("span",{style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:14})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:r}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge",style:{marginLeft:"4px"},"aria-label":`${a} queued`,children:a})]}),!o&&jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",style:{position:"absolute",bottom:4,left:4,right:4,height:"2px",background:"var(--bf-accent)",borderRadius:"1px",transformOrigin:"left"},initial:false,animate:{scaleX:n?1:0},transition:c})]},"minimal")})}var po={duration:.18,ease:"easeOut"},uo={duration:0};function ot({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=h(),c=o?uo:po;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:y(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:c,whileTap:{scale:.9},style:{overflow:"hidden"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(framerMotion.motion.span,{style:{display:"inline-flex",flexShrink:0},animate:o?{}:n?{scale:1.2,rotate:0}:{rotate:[-5,5,-5]},transition:n||o?c:{duration:3,repeat:1/0,ease:"easeInOut"},children:jsxRuntime.jsx(Ae,{size:16})}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:o?0:-8},animate:{opacity:1,x:0},exit:{opacity:0,x:o?0:-8},transition:c,style:{whiteSpace:"nowrap"},children:r},"label")}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"icon-pop")})}var ho={duration:.18,ease:"easeOut"},xo={duration:0};function at({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=h(),c=o?xo:ho;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:y(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:c,whileTap:{scale:.92},style:{overflow:"hidden"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"10px",height:"10px",flexShrink:0},children:[jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",style:{width:"10px",height:"10px",borderRadius:"50%",background:"var(--bf-accent)",position:"relative",zIndex:1},animate:o?{}:{opacity:n?1:[.5,1,.5],boxShadow:n?"0 0 8px 2px var(--bf-accent)":["0 0 4px 1px var(--bf-accent)","0 0 12px 4px var(--bf-accent)","0 0 4px 1px var(--bf-accent)"]},transition:n||o?c:{duration:2,repeat:1/0,ease:"easeInOut"}}),!n&&!o&&jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",style:{position:"absolute",width:"18px",height:"2px",background:"linear-gradient(90deg, var(--bf-accent), transparent)",transformOrigin:"left center",left:"5px",top:"4px"},animate:{rotate:[0,360]},transition:{duration:4,repeat:1/0,ease:"linear"}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:o?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:o?0:-6},transition:c,style:{whiteSpace:"nowrap"},children:r},"label")}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"beacon")})}var To={duration:.18,ease:"easeOut"},Eo={duration:0};function lt({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),[o,c]=react.useState(0),x=h(),z=x?Eo:To,f=react.useRef(null);react.useEffect(()=>{if(f.current&&(clearInterval(f.current),f.current=null),!i||n||x){c(n||x?r.length:0);return}let b=8,T=r.length*2+b*2,m=0;return f.current=setInterval(()=>{m=(m+1)%T,m<=r.length?c(m):m<=r.length+b?c(r.length):m<=r.length*2+b?c(r.length*2+b-m):c(0);},100),()=>{f.current&&(clearInterval(f.current),f.current=null);}},[i,n,x,r]);let S=r.slice(0,o);return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:y(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{opacity:0,y:x?0:5},animate:{opacity:1,y:0},exit:{opacity:0,y:x?0:5},transition:z,whileTap:{scale:.95},style:{minWidth:"44px"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:z,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"bf-dot","aria-hidden":"true"}),jsxRuntime.jsxs("span",{style:{whiteSpace:"nowrap",minWidth:"1ch"},children:[S,jsxRuntime.jsx("span",{className:"bf-cursor","aria-hidden":"true"})]}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"typewriter")})}function dt(t){switch(t){case "dot":return Oe;case "bubble":return Ke;case "edge-tab":return Ye;case "pulse-ring":return qe;case "minimal":return et;case "icon-pop":return ot;case "beacon":return at;case "typewriter":return lt;default:return _e}}function ft(t,e,i){return Math.max(e,Math.min(i,t))}function No(t,e,i="bottom-right"){let a=window.innerWidth,p=window.innerHeight,n;n=ft(t.x,12,Math.max(12,a-e-12));let l=t.y+t.height+12,o=Math.max(12,t.y-240);return {top:l+240<=p?l:o,left:n}}function Fo(t){let{rect:e}=t,i={left:`${e.x}px`,top:`${e.y}px`,width:`${Math.max(0,e.width)}px`,height:`${Math.max(0,e.height)}px`};return jsxRuntime.jsx("div",{className:"bf-highlight",style:i,"aria-hidden":"true"})}function Ro(t){let e=react.useRef(null);return react.useEffect(()=>{if(!t||!e.current)return;let i=e.current,r=i.querySelector(".bf-textarea");r?.focus();let a=n=>{if(n.key!=="Tab")return;let l=i.querySelectorAll('button:not([disabled]), textarea:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(l.length===0)return;let o=l[0],c=l[l.length-1];n.shiftKey&&document.activeElement===o?(n.preventDefault(),c.focus()):!n.shiftKey&&document.activeElement===c&&(n.preventDefault(),o.focus());},p=n=>{let l=n.target;l&&(i.contains(l)||(n.stopImmediatePropagation(),r?.focus()));};return document.addEventListener("keydown",a,{capture:true}),document.addEventListener("focusin",p,{capture:true}),()=>{document.removeEventListener("keydown",a,{capture:true}),document.removeEventListener("focusin",p,{capture:true});}},[t]),e}function Mo(t,e){return t?typeof t=="function"?t(e):t.some(i=>i.endsWith("*")?e.startsWith(i.slice(0,-1)):e===i):true}var ce=new Set,pt=false;function Lo(){if(pt||typeof window>"u")return;pt=true;let t=history.pushState,e=history.replaceState,i=()=>{for(let r of ce)r();};history.pushState=function(...r){t.apply(this,r),setTimeout(i,0);},history.replaceState=function(...r){e.apply(this,r),setTimeout(i,0);};}function zo(t){let[e,i]=react.useState(()=>typeof window<"u"?window.location.pathname:"/");return react.useEffect(()=>{if(typeof window>"u")return;let r=()=>i(window.location.pathname);return window.addEventListener("popstate",r),Lo(),ce.add(r),()=>{window.removeEventListener("popstate",r),ce.delete(r);}},[]),Mo(t,e)}function Io(t){let[e,i]=react.useState(()=>!t||t==="dark"?"dark":t==="light"?"light":typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return react.useEffect(()=>{if(t!=="auto"){i(t==="light"?"light":"dark");return}let r=window.matchMedia("(prefers-color-scheme: dark)"),a=p=>i(p.matches?"dark":"light");return i(r.matches?"dark":"light"),r.addEventListener("change",a),()=>r.removeEventListener("change",a)},[t]),e}var Ao=["bug","feature","ux","general"],Wo={bug:"categoryBug",feature:"categoryFeature",ux:"categoryUx",general:"categoryGeneral"};function X(t){let e=Math.floor(t/1e3),i=Math.floor(e/60),r=e%60;return `${i}:${String(r).padStart(2,"0")}`}function _o(t){return t<1024*1024?`${Math.round(t/1024)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Ho(t){let{state:e,controller:i,start:r,stop:a,clearSelection:p,submit:n}=ae(),l=t.config.ui?.position,o=ze(t.config.ui?.strings),c=t.config.ui?.branding!==false,[x,z]=react.useState(null),[f,S]=react.useState(""),[b,T]=react.useState(t.config.capture?.element??true),[m,C]=react.useState(t.config.capture?.fullPage??false),[bt,de]=react.useState(null),[D,fe]=react.useState(void 0),pe=t.config.ui?.categories??Ao,gt=t.config.recording?.enabled===true&&chunkUMYASFYV_cjs.l(),mt=t.config.recording?.maxDurationMs??3e4,ue=i.getConfig().voice,ht=ue?.enabled===true&&chunkUMYASFYV_cjs.n(),xt=ue?.maxDurationMs??6e4,[vt,yt]=react.useState(false),[J,wt]=react.useState(0);react.useEffect(()=>{let s=window.setTimeout(()=>{let v=chunkUMYASFYV_cjs.z();wt(v.findings.length);},500);return ()=>window.clearTimeout(s)},[]),react.useImperativeHandle(t.handleRef,()=>({open:r,close:a,submit:s=>n(s),startRecording:()=>i.startRecording(),stopRecording:()=>i.stopRecording(),get isOpen(){return e.phase!=="idle"}}),[r,a,n,i,e.phase]);let be=e.phase==="review"||e.phase==="capturing"||e.phase==="submitting"||e.phase==="error"||e.phase==="success",kt=Ro(be),[Tt,Et]=react.useState(0);react.useEffect(()=>{e.phase==="idle"&&Et(chunkUMYASFYV_cjs.i());},[e.phase]);let[St,ge]=react.useState(false),me=react.useRef(e.phase);react.useEffect(()=>{if(me.current==="success"&&e.phase==="idle"){ge(true);let s=window.setTimeout(()=>ge(false),1500);return ()=>window.clearTimeout(s)}me.current=e.phase;},[e.phase]),react.useEffect(()=>{let s=t.config.ui?.shortcut;if(!s)return;let v=s.toLowerCase().split("+").map(N=>N.trim()),B=v[v.length-1]||"",I=new Set(v.slice(0,-1)),ve=N=>{let Nt=/Mac|iPod|iPhone|iPad/.test(navigator.platform);if(I.has("mod")){if(Nt?!N.metaKey:!N.ctrlKey)return}else if(I.has("ctrl")&&!N.ctrlKey||(I.has("meta")||I.has("cmd"))&&!N.metaKey)return;I.has("shift")&&!N.shiftKey||(I.has("alt")||I.has("option"))&&!N.altKey||N.key.toLowerCase()===B&&(N.preventDefault(),e.phase==="idle"?r():a());};return document.addEventListener("keydown",ve),()=>document.removeEventListener("keydown",ve)},[t.config.ui?.shortcut,e.phase,r,a]),react.useEffect(()=>i.subscribeHover(z),[i]),react.useEffect(()=>{let s=i.__unsafeGetSelectedElement();if(!s||e.phase==="idle"||e.phase==="picking"){de(null);return}let v=()=>{de(chunkUMYASFYV_cjs.b(s.getBoundingClientRect()));};v();let B=()=>v();return window.addEventListener("scroll",B,{capture:true,passive:true}),window.addEventListener("resize",B,{passive:true}),()=>{window.removeEventListener("scroll",B,{capture:true}),window.removeEventListener("resize",B);}},[i,e.phase,e.selection?.selector]),react.useEffect(()=>{e.phase==="review"&&(S(""),T(t.config.capture?.element??true),C(t.config.capture?.fullPage??false),fe(void 0),V(null));},[e.phase,e.selection?.selector,t.config.capture?.element,t.config.capture?.fullPage]),react.useEffect(()=>{if(e.phase!=="success")return;let s=window.setTimeout(()=>a(),1200);return ()=>window.clearTimeout(s)},[e.phase,a]);let E=e.phase==="capturing"||e.phase==="submitting",M=e.phase==="picking"?x?.rect??null:bt??e.selection?.rect??null,Z=react.useMemo(()=>M?No(M,360,l):null,[M?.x,M?.y,M?.width,M?.height,l]),he=e.lastError?.message,ee=react.useCallback(()=>{let s={capture:{element:b,fullPage:m}};D&&(s.category=D),n(f,s);},[n,f,b,m,D]),Ct=react.useCallback(s=>{(s.metaKey||s.ctrlKey)&&s.key==="Enter"&&f.trim().length>0&&!E&&(s.preventDefault(),ee());},[ee,f,E]),[xe,V]=react.useState(null),Pt=react.useCallback(async()=>{if(e.voiceRecording){i.stopVoice();return}V(null);let s=await i.startVoice();if(s?.text)S(v=>v?v+" "+s.text:s.text);else if(s?.warning)V(o.voiceEmptyText);else if(!s){let v=i.getState().lastError;if(v){let B=v.message?.toLowerCase()??"";B.includes("denied")||B.includes("permission")||B.includes("not allowed")?V(o.voiceDeniedText):V(o.voiceErrorText);}}},[e.voiceRecording,i,o]),Bt=dt(t.config.ui?.triggerStyle);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Bt,{position:l,onClick:()=>r(),isVisible:e.phase==="idle",label:t.config.ui?.triggerLabel??o.triggerLabel,queueCount:Tt,showSuccess:St}),e.phase!=="idle"&&e.phase!=="recording"&&jsxRuntime.jsxs("div",{className:"bf-overlay",role:"presentation",children:[e.phase!=="picking"&&jsxRuntime.jsx("div",{className:"bf-blocker",role:"presentation",onClick:()=>a()}),M&&jsxRuntime.jsx(Fo,{rect:M}),e.phase==="picking"&&jsxRuntime.jsxs("div",{className:"bf-hint",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("p",{id:"bf-hint-text",children:o.hintText}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>a(),"aria-label":o.cancelButton,children:o.cancelButton})]}),be&&Z&&jsxRuntime.jsxs("div",{ref:kt,className:"bf-panel",style:{left:Z.left,top:Z.top},role:"dialog","aria-modal":"true","aria-label":"Feedback form",children:[jsxRuntime.jsxs("div",{className:"bf-panelHeader",children:[jsxRuntime.jsx("div",{className:"bf-title",id:"bf-panel-title",children:o.panelTitle}),jsxRuntime.jsxs("div",{className:"bf-row",style:{justifyContent:"flex-end"},children:[jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>p(),disabled:E,"aria-label":o.rePickButton,children:o.rePickButton}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>a(),disabled:E,"aria-label":o.closeButton,children:o.closeButton})]})]}),jsxRuntime.jsxs("div",{className:"bf-panelBody",children:[jsxRuntime.jsx("textarea",{className:"bf-textarea",placeholder:o.textareaPlaceholder,value:f,onChange:s=>S(s.target.value),onKeyDown:Ct,disabled:E,"aria-label":o.panelTitle}),pe.length>0&&jsxRuntime.jsx("div",{className:"bf-pills",role:"group","aria-label":"Feedback category",children:pe.map(s=>jsxRuntime.jsx("button",{type:"button",className:`bf-pill${D===s?" bf-pill-active":""}`,onClick:()=>fe(D===s?void 0:s),disabled:E,children:o[Wo[s]]},s))}),jsxRuntime.jsxs("div",{className:"bf-row",role:"group","aria-label":o.screenshotElement,children:[jsxRuntime.jsxs("label",{children:[jsxRuntime.jsx("input",{type:"checkbox",checked:b,onChange:s=>T(s.target.checked),disabled:E}),o.screenshotElement]}),jsxRuntime.jsxs("label",{children:[jsxRuntime.jsx("input",{type:"checkbox",checked:m,onChange:s=>C(s.target.checked),disabled:E}),o.screenshotFullPage]})]}),ht&&e.phase==="review"&&!e.voiceTranscribing&&jsxRuntime.jsx("button",{type:"button",className:`bf-voice-btn${e.voiceRecording?" bf-voice-btn-active":""}`,onClick:Pt,disabled:E,"aria-label":e.voiceRecording?o.voiceStopButton:o.voiceButton,children:e.voiceRecording?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"bf-rec-dot bf-rec-dot-pulse","aria-hidden":"true"}),o.voiceRecordingText," ",X(e.voiceElapsedMs??0)," / ",X(xt)," \u2014 ",o.voiceStopButton]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{className:"bf-mic-icon",viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[jsxRuntime.jsx("rect",{x:"9",y:"1",width:"6",height:"11",rx:"3"}),jsxRuntime.jsx("path",{d:"M19 10v1a7 7 0 0 1-14 0v-1"}),jsxRuntime.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),jsxRuntime.jsx("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]}),o.voiceButton]})}),e.voiceTranscribing&&jsxRuntime.jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("span",{className:"bf-spinner","aria-hidden":"true"}),o.voiceTranscribingText]}),xe&&!e.voiceRecording&&!e.voiceTranscribing&&jsxRuntime.jsx("div",{className:"bf-error",role:"alert",children:xe}),gt&&e.phase==="review"&&!e.video&&jsxRuntime.jsxs("button",{type:"button",className:"bf-record-btn",onClick:()=>i.startRecording(),disabled:E,"aria-label":o.recordButton,children:[jsxRuntime.jsx("span",{className:"bf-rec-dot","aria-hidden":"true"}),o.recordButton]}),e.video&&e.phase==="review"&&jsxRuntime.jsxs("div",{className:"bf-video-preview",children:[jsxRuntime.jsx("video",{src:e.video.blobUrl,controls:true,muted:true,playsInline:true}),jsxRuntime.jsx("button",{type:"button",className:"bf-video-remove",onClick:()=>i.removeVideo(),"aria-label":o.removeVideoButton,children:"\xD7"}),jsxRuntime.jsxs("div",{className:"bf-video-meta",children:[o.videoPreviewLabel," (",X(e.video.durationMs),", ",_o(e.video.sizeBytes),")"]})]}),e.phase==="capturing"&&jsxRuntime.jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("span",{className:"bf-spinner","aria-hidden":"true"}),o.capturingText]}),e.phase==="submitting"&&jsxRuntime.jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("span",{className:"bf-spinner","aria-hidden":"true"}),o.submittingText]}),e.phase==="success"&&jsxRuntime.jsx("div",{className:"bf-status",role:"status","aria-live":"polite",children:o.successText}),e.phase==="error"&&he&&jsxRuntime.jsx("div",{className:"bf-error",role:"alert",children:he}),jsxRuntime.jsxs("div",{className:"bf-actions",children:[jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>a(),disabled:E,"aria-label":o.cancelButton,children:o.cancelButton}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn bf-btnPrimary",onClick:ee,disabled:E||f.trim().length===0,"aria-label":o.sendButton,children:o.sendButton})]})]}),c&&jsxRuntime.jsxs("div",{className:"bf-watermark",children:[(()=>{let s=chunkUMYASFYV_cjs.q();return s?jsxRuntime.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"bf-my-feedback-link",children:"View my feedback"}):null})(),jsxRuntime.jsx("a",{href:"https://blocfeed.com",target:"_blank",rel:"noopener noreferrer",children:"Powered by BlocFeed"})]})]})]}),e.phase==="recording"&&jsxRuntime.jsxs("div",{className:`bf-recording-bar bf-pos-${l}`,role:"status","aria-live":"polite","data-blocfeed-ui":"true",children:[jsxRuntime.jsx("span",{className:"bf-rec-dot bf-rec-dot-pulse","aria-hidden":"true"}),jsxRuntime.jsxs("span",{className:"bf-recording-bar-timer",children:[o.recordingText," ",X(e.recordingElapsedMs??0)," / ",X(mt)]}),jsxRuntime.jsx("button",{type:"button",className:"bf-recording-bar-stop",onClick:()=>i.stopRecording(),"aria-label":o.stopRecordButton,children:o.stopRecordButton})]}),e.phase==="success"&&jsxRuntime.jsxs("div",{className:"bf-toast",role:"status","aria-live":"polite",children:[o.toastText,(()=>{let s=chunkUMYASFYV_cjs.q();return s?jsxRuntime.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"bf-toast-link",children:"View my feedback"}):null})()]}),J>0&&!vt&&jsxRuntime.jsxs("div",{className:"bf-security-banner",role:"alert",children:[jsxRuntime.jsx("button",{type:"button",className:"bf-security-banner-dismiss",onClick:()=>yt(true),"aria-label":"Dismiss",children:"\xD7"}),jsxRuntime.jsx("strong",{children:"Security Warning"}),J," potential secret",J>1?"s":""," exposed in client code. Check your environment variables."]})]})}var Oo=react.forwardRef(function(e,i){let r={...e.config??{},blocfeed_id:e.blocfeed_id},[a,p]=react.useState(null),n=zo(r.ui?.showOn),l=Io(r.ui?.theme?.mode),o=!!r.diagnostics;react.useEffect(()=>{if(o)return chunkUMYASFYV_cjs.u(r.diagnostics),()=>chunkUMYASFYV_cjs.v()},[o]);let c=!!r.security;react.useEffect(()=>{c&&chunkUMYASFYV_cjs.y(r.security);},[c]);let x=react.useRef(e.config?.metadata?.enrich);x.current=e.config?.metadata?.enrich;let z=react.useMemo(()=>{if(e.config)return {...e.config,metadata:{...e.config.metadata,enrich:async f=>{let S=x.current,b=S?await S(f):{},T=chunkUMYASFYV_cjs.w(),m=chunkUMYASFYV_cjs.z(),C=chunkUMYASFYV_cjs.j();return {...b,...T.consoleLogs.length>0?{_consoleLogs:T.consoleLogs}:{},...T.networkErrors.length>0?{_networkErrors:T.networkErrors}:{},...m.findings.length>0?{_securityFindings:m.findings}:{},...C.length>0?{_clickEvents:C}:{}}}}}},[]);return react.useEffect(()=>{Me();let f=document.createElement("div");f.setAttribute("data-blocfeed-ui-root","true"),f.setAttribute("data-blocfeed-ui","true"),f.setAttribute("data-bf-theme",l);let S=r.ui?.zIndex;typeof S=="number"&&f.style.setProperty("--bf-z",String(S));let b=r.ui?.theme;b&&(b.accentColor&&f.style.setProperty("--bf-accent",b.accentColor),b.panelBackground&&f.style.setProperty("--bf-panel-bg",b.panelBackground),b.panelForeground&&f.style.setProperty("--bf-panel-fg",b.panelForeground),b.fontFamily&&f.style.setProperty("--bf-font",b.fontFamily));let T=C=>C.stopPropagation(),m=["pointerdown","pointerup","mousedown","mouseup","click","touchstart","touchend"];for(let C of m)f.addEventListener(C,T);try{document.body.appendChild(f);}catch{return}return p(f),()=>{for(let C of m)f.removeEventListener(C,T);f.remove(),p(null);}},[r.ui?.zIndex,r.ui?.theme?.accentColor,r.ui?.theme?.panelBackground,r.ui?.theme?.panelForeground,r.ui?.theme?.fontFamily,l]),!n||!a?null:reactDom.createPortal(jsxRuntime.jsx(ie,{blocfeed_id:r.blocfeed_id,...z?{config:z}:{},children:jsxRuntime.jsx(Ho,{config:r,handleRef:i})}),a)});
885
+ Object.defineProperty(exports,"BehavioralTracker",{enumerable:true,get:function(){return chunkUMYASFYV_cjs.s}});exports.BlocFeedProvider=ie;exports.BlocFeedWidget=Oo;exports.useBlocFeed=ae;
package/dist/main.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { B as BlocFeedConfig, a as BlocFeedHandle, b as BlocFeedState, c as BlocFeedController, C as CaptureConfig, F as FeedbackCategory, S as SubmitResult, d as BehavioralEvent, e as BehavioralConfig } from './controller-6fm9oK63.cjs';
2
- export { f as BehavioralEventType, g as BlocFeedError, h as BlocFeedStrings, i as BlocFeedUser, j as CaptureDiagnostics, k as CaptureResult, l as ConsoleEntry, D as DiagnosticsConfig, E as ElementDescriptor, m as FeedbackApiResponse, n as FeedbackPayload, I as ImageAsset, M as MaybePromise, o as MetadataConfig, p as MetadataContext, N as NetworkEntry, P as PickerConfig, R as RecordingConfig, q as Rect, r as ScreenshotAdapter, s as ScreenshotAdapterOptions, t as ScreenshotIntent, u as ScreenshotMime, v as SecurityConfig, w as SecurityFinding, x as SecuritySnapshot, y as SessionPhase, T as ThemeConfig, z as TransportConfig, A as TransportResult, G as TriggerStyle, V as VideoAsset, H as VideoIntent, J as VideoMime, K as VoiceConfig, W as WidgetPosition } from './controller-6fm9oK63.cjs';
1
+ import { B as BlocFeedConfig, a as BlocFeedHandle, b as BlocFeedState, c as BlocFeedController, C as CaptureConfig, F as FeedbackCategory, S as SubmitResult, d as BehavioralEvent, e as BehavioralConfig } from './controller-DCtQ8rTh.cjs';
2
+ export { f as BehavioralEventType, g as BlocFeedError, h as BlocFeedStrings, i as BlocFeedUser, j as CaptureDiagnostics, k as CaptureResult, l as ConsoleEntry, D as DiagnosticsConfig, E as ElementDescriptor, m as FeedbackApiResponse, n as FeedbackPayload, I as ImageAsset, M as MaybePromise, o as MetadataConfig, p as MetadataContext, N as NetworkEntry, P as PickerConfig, R as RecordingConfig, q as Rect, r as ScreenshotAdapter, s as ScreenshotAdapterOptions, t as ScreenshotIntent, u as ScreenshotMime, v as SecurityConfig, w as SecurityFinding, x as SecuritySnapshot, y as SessionPhase, T as ThemeConfig, z as TransportConfig, A as TransportResult, G as TriggerStyle, V as VideoAsset, H as VideoIntent, J as VideoMime, K as VoiceConfig, W as WidgetPosition } from './controller-DCtQ8rTh.cjs';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as react from 'react';
5
5
  import { ReactNode } from 'react';
package/dist/main.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { B as BlocFeedConfig, a as BlocFeedHandle, b as BlocFeedState, c as BlocFeedController, C as CaptureConfig, F as FeedbackCategory, S as SubmitResult, d as BehavioralEvent, e as BehavioralConfig } from './controller-6fm9oK63.js';
2
- export { f as BehavioralEventType, g as BlocFeedError, h as BlocFeedStrings, i as BlocFeedUser, j as CaptureDiagnostics, k as CaptureResult, l as ConsoleEntry, D as DiagnosticsConfig, E as ElementDescriptor, m as FeedbackApiResponse, n as FeedbackPayload, I as ImageAsset, M as MaybePromise, o as MetadataConfig, p as MetadataContext, N as NetworkEntry, P as PickerConfig, R as RecordingConfig, q as Rect, r as ScreenshotAdapter, s as ScreenshotAdapterOptions, t as ScreenshotIntent, u as ScreenshotMime, v as SecurityConfig, w as SecurityFinding, x as SecuritySnapshot, y as SessionPhase, T as ThemeConfig, z as TransportConfig, A as TransportResult, G as TriggerStyle, V as VideoAsset, H as VideoIntent, J as VideoMime, K as VoiceConfig, W as WidgetPosition } from './controller-6fm9oK63.js';
1
+ import { B as BlocFeedConfig, a as BlocFeedHandle, b as BlocFeedState, c as BlocFeedController, C as CaptureConfig, F as FeedbackCategory, S as SubmitResult, d as BehavioralEvent, e as BehavioralConfig } from './controller-DCtQ8rTh.js';
2
+ export { f as BehavioralEventType, g as BlocFeedError, h as BlocFeedStrings, i as BlocFeedUser, j as CaptureDiagnostics, k as CaptureResult, l as ConsoleEntry, D as DiagnosticsConfig, E as ElementDescriptor, m as FeedbackApiResponse, n as FeedbackPayload, I as ImageAsset, M as MaybePromise, o as MetadataConfig, p as MetadataContext, N as NetworkEntry, P as PickerConfig, R as RecordingConfig, q as Rect, r as ScreenshotAdapter, s as ScreenshotAdapterOptions, t as ScreenshotIntent, u as ScreenshotMime, v as SecurityConfig, w as SecurityFinding, x as SecuritySnapshot, y as SessionPhase, T as ThemeConfig, z as TransportConfig, A as TransportResult, G as TriggerStyle, V as VideoAsset, H as VideoIntent, J as VideoMime, K as VoiceConfig, W as WidgetPosition } from './controller-DCtQ8rTh.js';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as react from 'react';
5
5
  import { ReactNode } from 'react';
package/dist/main.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import {u,v,y as y$1,w,z,j,a,t,l,n,i,q,b}from'./chunk-CYITSKBK.js';export{s as BehavioralTracker}from'./chunk-CYITSKBK.js';import {createContext,forwardRef,useState,useEffect,useRef,useMemo,useImperativeHandle,useCallback,useContext}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';import {AnimatePresence,motion}from'framer-motion';var Y=createContext(null);function ie(t$1){let e=useMemo(()=>t({...t$1.config??{},blocfeed_id:t$1.blocfeed_id}),[]),[i,r]=useState(()=>e.getState());return useEffect(()=>e.subscribe(r),[e]),useEffect(()=>e.setConfig({...t$1.config??{},blocfeed_id:t$1.blocfeed_id}),[e,t$1.config,t$1.blocfeed_id]),useEffect(()=>()=>e.destroy(),[e]),jsx(Y.Provider,{value:{controller:e,state:i},children:t$1.children})}var Re="blocfeed-styles-v1",It=`
2
+ import {u,v,y as y$1,w,z,j,a,t,l,n,i,q,b}from'./chunk-E3AHWKZQ.js';export{s as BehavioralTracker}from'./chunk-E3AHWKZQ.js';import {createContext,forwardRef,useState,useEffect,useRef,useMemo,useImperativeHandle,useCallback,useContext}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';import {AnimatePresence,motion}from'framer-motion';var Y=createContext(null);function ie(t$1){let e=useMemo(()=>t({...t$1.config??{},blocfeed_id:t$1.blocfeed_id}),[]),[i,r]=useState(()=>e.getState());return useEffect(()=>e.subscribe(r),[e]),useEffect(()=>e.setConfig({...t$1.config??{},blocfeed_id:t$1.blocfeed_id}),[e,t$1.config,t$1.blocfeed_id]),useEffect(()=>()=>e.destroy(),[e]),jsx(Y.Provider,{value:{controller:e,state:i},children:t$1.children})}var Re="blocfeed-styles-v1",It=`
3
3
  :where([data-blocfeed-ui-root]),
4
4
  :where([data-blocfeed-ui-root]) * {
5
5
  box-sizing: border-box;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blocfeed",
3
- "version": "0.15.1",
3
+ "version": "0.15.3",
4
4
  "description": "Drop-in feedback widget for React — element picking, screenshots, video recording, and voice feedback.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,2 +0,0 @@
1
- function y(){return typeof window<"u"&&typeof document<"u"}function De(e){let t=globalThis.CSS;return typeof t?.escape=="function"?t.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,n=>{let o=n.codePointAt(0);return o===void 0?"":`\\${o.toString(16)} `})}function pe(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function Ft(e){return {x:e.x+window.scrollX,y:e.y+window.scrollY,width:e.width,height:e.height}}function Pt(e){return e.replace(/\s+/g," ").trim()}function me(e,t=140){let n=e.textContent;if(!n)return;let o=Pt(n);if(o)return o.length<=t?o:`${o.slice(0,t-1)}\u2026`}function Mt(e){let t=1;for(let n=e.previousElementSibling;n;n=n.previousElementSibling)n.tagName===e.tagName&&(t+=1);return t}var He=["data-testid","data-test-id","data-test","data-qa","data-cy"],Ne="data-blocfeed-component";function ge(e){let t=e.closest(`[${Ne}]`);if(!t)return;let o=t.getAttribute(Ne)?.trim();return o||void 0}function Lt(e){for(let t of He){let n=e.closest(`[${t}]`);if(!n)continue;let r=n.getAttribute(t)?.trim();if(r)return r}}function Oe(e){try{let t=e,n=Object.getOwnPropertyNames(t);for(let o of n)if(o.startsWith("__reactFiber$")||o.startsWith("__reactInternalInstance$")){let r=t[o];if(r&&typeof r=="object")return r}}catch{}return null}function q(e){if(e.length<=1||e.length===2&&e[0]===e[0].toLowerCase()||e.startsWith("__")&&e.endsWith("__"))return true;let t=e[0];return t>="a"&&t<="z"}function K(e){if(e){for(let t of e)if(typeof t.name=="string"&&t.name&&!q(t.name))return t.name}}function F(e){if(e&&typeof e!="string"){if(typeof e=="function"){let t=e;return typeof t.displayName=="string"&&t.displayName?t.displayName:typeof t.name=="string"&&t.name?t.name:void 0}if(typeof e=="object"){let t=e,n=t.displayName;if(typeof n=="string"&&n)return n;let o=t.render;if(typeof o=="function"){let i=o;if(typeof i.displayName=="string"&&i.displayName)return i.displayName;if(typeof i.name=="string"&&i.name)return i.name}let r=t.type;return F(r)}}}function he(e){let t=Oe(e);if(!t)return;let n=K(t._debugInfo);if(n)return n;let o=t._debugOwner!==void 0;if(o){let f=t._debugOwner;for(let s=0;f&&s<50;s+=1){let d=K(f._debugInfo);if(d)return d;let l=F(f.type)??F(f.elementType);if(l&&!q(l))return l;f=f._debugOwner;}}if(t._owner!==void 0&&t._owner!==t._debugOwner){let f=t._owner;for(let s=0;f&&s<50;s+=1){let d=K(f._debugInfo);if(d)return d;let l=F(f.type)??F(f.elementType);if(l&&!q(l))return l;f=f._owner;}}let i=t,c=o?80:25;for(let f=0;i&&f<c;f+=1){let s=K(i._debugInfo);if(s)return s;let d=F(i.type)??F(i.elementType);if(d&&!q(d))return d;i=i.return;}let a=e.parentElement;for(let f=0;a&&f<15;f+=1){let s=Oe(a);if(s){let d=K(s._debugInfo);if(d)return d;let l=F(s.type)??F(s.elementType);if(l&&!q(l))return l;if(s._debugOwner){let p=F(s._debugOwner.type)??F(s._debugOwner.elementType);if(p&&!q(p))return p}if(s._owner&&s._owner!==s._debugOwner){let p=F(s._owner.type)??F(s._owner.elementType);if(p&&!q(p))return p}}a=a.parentElement;}}function Bt(e){let t=e.tagName.toLowerCase(),n=e.getAttribute("id");if(n)return `#${De(n)}`;for(let o of He){let r=e.getAttribute(o);if(r)return `${t}[${o}="${De(r)}"]`}return `${t}:nth-of-type(${Mt(e)})`}function W(e,t=10){let n=[],o=e;for(;o&&n.length<t;){let r=Bt(o);if(n.unshift(r),r.startsWith("#"))break;o=o.parentElement;}return n.join(" > ")}function Ue(e,t){if(!t||t.length===0)return false;for(let n of t)if(e.closest(n))return true;return false}function be(e,t){if(!e||Ue(e,t.ignoreSelectors))return null;let n=e;for(;n;){if(Ue(n,t.ignoreSelectors))return null;if(t.isSelectable?t.isSelectable(n):It(n))return n;n=n.parentElement;}return null}function It(e){let t=e.tagName;return !(t==="HTML"||t==="BODY")}function Ve(e){let t=e.getBoundingClientRect(),n={selector:W(e),tagName:e.tagName.toLowerCase(),rect:pe(t),pageRect:Ft(t)},o=e.getAttribute("id");o&&(n.id=o);let r=e.className;typeof r=="string"&&r.trim()&&(n.className=r);let i=me(e);i&&(n.textSnippet=i);let c=ge(e)??he(e);c&&(n.componentName=c);let a=Lt(e);return a&&(n.testId=a),n}var we=null;async function qe(){return we||(we=import('html-to-image')),we}async function Dt(e){return await new Promise((t,n)=>{let o=new Image;o.onload=()=>t({width:o.naturalWidth,height:o.naturalHeight}),o.onerror=()=>n(new Error("Failed to load generated screenshot")),o.src=e;})}async function Xe(e,t){let{width:n,height:o}=await Dt(e);return {dataUrl:e,mime:t,width:n,height:o}}function $(e){if(e?.aborted)throw new Error("Aborted")}function $e(){return {async captureElement(e,t){if(!y())throw new Error("captureElement can only run in the browser");$(t.signal);let n=await qe();$(t.signal);let o=t.mime==="image/jpeg"?await n.toJpeg(e,{quality:t.quality??.92,pixelRatio:t.pixelRatio}):await n.toPng(e,{pixelRatio:t.pixelRatio});return $(t.signal),await Xe(o,t.mime)},async captureFullPage(e){if(!y())throw new Error("captureFullPage can only run in the browser");$(e.signal);let t=document.documentElement,n=Math.max(t.scrollWidth,t.clientWidth),o=Math.max(t.scrollHeight,t.clientHeight),r=Math.min(1,e.maxDimension/Math.max(n,o)),i=Math.max(1,Math.round(n*r)),c=Math.max(1,Math.round(o*r)),a=await qe();$(e.signal);let f=e.mime==="image/jpeg"?await a.toJpeg(t,{width:i,height:c,quality:e.quality??.92,pixelRatio:e.pixelRatio}):await a.toPng(t,{width:i,height:c,pixelRatio:e.pixelRatio});return $(e.signal),await Xe(f,e.mime)}}}function Nt(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return "Unknown error"}}function w(e,t,n){let o={kind:e,message:Nt(t)};return n&&(o.detail=n),o}var Ot=12e3,Ut=2048,Ht=.92;function ze(){return Date.now()}function Vt(e){return new Promise((t,n)=>{let o=()=>n(new Error("Aborted"));if(e.aborted){o();return}e.addEventListener("abort",o,{once:true});})}async function je(e,t,n){let o=new Promise((i,c)=>{let a=setTimeout(()=>c(new Error("Timeout")),t);typeof a.unref=="function"&&a.unref();}),r=[e,o];return n&&r.push(Vt(n)),await Promise.race(r)}function qt(e){if(!y())return 1;let t=window.devicePixelRatio||1,n=e?.pixelRatio??Math.min(t,2);return Math.max(.1,n)}function Xt(e){return !!(e?.element||e?.fullPage)}function Ke(e){let t={mime:e.mime,pixelRatio:e.pixelRatio,maxDimension:e.maxDimension};return e.includeQuality&&(t.quality=e.quality),e.signal&&(t.signal=e.signal),t}async function We(e){let{selectionElement:t,capture:n,signal:o}=e;if(!y()||!Xt(n))return;let r=ze(),i=[],c=n?.timeoutMs??Ot,a=n?.maxDimension??Ut,f=n?.mime??"image/png",s=n?.quality??Ht,d=n?.adapter??$e(),l={},p=qt(n);if(n?.element&&t)try{let g=t.getBoundingClientRect(),h=Math.min(1,a/Math.max(g.width,g.height)),k=Math.min(p,p*h),v=await je(Promise.resolve(d.captureElement(t,{...Ke({mime:f,quality:s,pixelRatio:k,maxDimension:a,includeQuality:f==="image/jpeg",...o?{signal:o}:{}})})),c,o);l.element=v;}catch(g){if(o?.aborted)throw g;i.push(w("capture_failed",g,{target:"element"}));}if(n?.fullPage)try{let g=await je(Promise.resolve(d.captureFullPage(Ke({mime:f,quality:s,pixelRatio:p,maxDimension:a,includeQuality:f==="image/jpeg",...o?{signal:o}:{}}))),c,o);l.fullPage=g;}catch(g){if(o?.aborted)throw g;i.push(w("capture_failed",g,{target:"fullPage"}));}let m=ze(),u={startedAt:r,finishedAt:m,durationMs:Math.max(0,m-r)};return i.length>0&&(u.errors=i),{...l,diagnostics:u}}function $t(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function zt(){return y()?{url:window.location.href,title:document.title,referrer:document.referrer||void 0,userAgent:navigator.userAgent,language:navigator.language,platform:navigator.platform,viewport:{width:window.innerWidth,height:window.innerHeight},screen:{width:window.screen.width,height:window.screen.height},scroll:{x:window.scrollX,y:window.scrollY},devicePixelRatio:window.devicePixelRatio||1,timezone:$t()}:{}}function jt(e){if(!e)return {};let t={};return e.id&&(t.userId=e.id),e.email&&(t.userEmail=e.email),e.name&&(t.userName=e.name),t}async function Ze(e){let{config:t,context:n,user:o}=e;if(t?.enabled===false)return {};let r={...zt(),...jt(o)},i=t?.enrich;if(!i)return r;try{let c=await i(n);return {...r,...c}}catch(c){let a=w("unknown",c);return {...r,blocfeedMetadataError:a.message}}}var Z="blocfeed-queue",Kt=50;function ve(){if(!y())return [];try{let e=localStorage.getItem(Z);if(!e)return [];let t=JSON.parse(e);if(Array.isArray(t))return t;console.warn("[BlocFeed] offline queue was corrupt (non-array) \u2014 resetting");try{localStorage.removeItem(Z);}catch{}return []}catch(e){console.warn("[BlocFeed] offline queue could not be read \u2014 resetting",e);try{localStorage.removeItem(Z);}catch{}return []}}function ye(e){if(y())try{e.length===0?localStorage.removeItem(Z):localStorage.setItem(Z,JSON.stringify(e));}catch(t){let n=t instanceof DOMException?t.name:"";console.warn(`[BlocFeed] failed to persist offline queue${n?` (${n})`:""} \u2014 feedback may be lost if page is closed`);}}function Wt(e){let t={...e};if(t.screenshots){let n={...t.screenshots};n.element&&(n.element={...n.element,dataUrl:""}),n.fullPage&&(n.fullPage={...n.fullPage,dataUrl:""}),t.screenshots=n;}return delete t.video,t}function Ee(e){let t=ve(),n=Wt(e);for(n.metadata={...n.metadata,_queued:true},t.push({payload:n,timestamp:Date.now()});t.length>Kt;)t.shift();ye(t);}function Ge(){let e=ve();return e.length===0?[]:(ye([]),e.map(t=>t.payload))}function Jn(){ye([]);}function eo(){return ve().length}var Zt=200,G=[],Ye=0,te=false;function Qe(e){let t=e.target;if(!(t instanceof Element)||t.closest("[data-blocfeed-ui]"))return;let n={timestampMs:Date.now()-Ye,path:window.location.pathname,tagName:t.tagName.toLowerCase()},o=me(t,100);o&&(n.textSnippet=o);let r=ge(t)??he(t);r&&(n.componentName=r),G.length<Zt&&G.push(n);}var Je={capture:true,passive:true};function et(){te||!y()||(te=true,G=[],Ye=Date.now(),document.addEventListener("click",Qe,Je));}function tt(){te&&(te=false,document.removeEventListener("click",Qe,Je));}function Gt(){return [...G]}function Yt(){G=[];}var Qt=3e4,Jt=25e5,nt="video/webm",en=250,tn=1e3,nn=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"];function ot(){if(typeof MediaRecorder>"u")return null;for(let e of nn)if(MediaRecorder.isTypeSupported(e))return e;return null}function on(){return !y()||typeof navigator?.mediaDevices?.getDisplayMedia!="function"?false:ot()!==null}async function _e(e){let{config:t,signal:n}=e;if(!y()||typeof navigator?.mediaDevices?.getDisplayMedia!="function")throw w("recording_failed",new Error("Screen recording is not supported in this browser"));let o=ot();if(!o)throw w("recording_failed",new Error("No supported video codec found (WebM required)"));if(n?.aborted)throw w("aborted",new Error("Recording aborted before start"));let r;try{r=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1});}catch(h){let k=h instanceof DOMException&&h.name==="NotAllowedError"?"Screen share permission denied":"Failed to start screen share";throw w("recording_failed",new Error(k))}if(n?.aborted)throw r.getTracks().forEach(h=>h.stop()),w("aborted",new Error("Recording aborted after permission"));let i=t?.maxDurationMs??Qt,c=t?.videoBitsPerSecond??Jt,a=new MediaRecorder(r,{mimeType:o,videoBitsPerSecond:c}),f=[],s=[],d=0,l=null,p=null,m=false,u=()=>{tt(),l!==null&&(clearInterval(l),l=null),p!==null&&(clearTimeout(p),p=null),r.getTracks().forEach(h=>h.stop());},g=new Promise((h,k)=>{a.ondataavailable=R=>{R.data.size>0&&f.push(R.data);},a.onstop=()=>{if(m)return;m=true,u();let R=Date.now()-d,P=new Blob(f,{type:nt}),_=URL.createObjectURL(P);h({mime:nt,blobUrl:_,blob:P,durationMs:R,sizeBytes:P.size});},a.onerror=()=>{m||(m=true,u(),k(w("recording_failed",new Error("MediaRecorder error"))));};let v=r.getVideoTracks()[0];if(v&&v.addEventListener("ended",()=>{a.state!=="inactive"&&a.stop();}),n){let R=()=>{m||(m=true,a.state!=="inactive"&&a.stop(),u(),k(w("aborted",new Error("Recording aborted"))));};n.addEventListener("abort",R,{once:true});}});return a.start(tn),et(),d=Date.now(),l=setInterval(()=>{let h=Date.now()-d;for(let k of s)k(h);},en),p=setTimeout(()=>{!m&&a.state!=="inactive"&&a.stop();},i),{result:g,stop(){!m&&a.state!=="inactive"&&a.stop();},onTick(h){s.push(h);},abort(){m||(m=true,a.state!=="inactive"&&a.stop(),u());}}}var rn=6e4,rt="audio/webm",sn=250,an=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus"];function it(){if(typeof MediaRecorder>"u")return null;for(let e of an)if(MediaRecorder.isTypeSupported(e))return e;return null}function cn(){return !y()||typeof navigator?.mediaDevices?.getUserMedia!="function"?false:it()!==null}async function Se(e){let{config:t,signal:n}=e;if(!y()||typeof navigator?.mediaDevices?.getUserMedia!="function")throw w("recording_failed",new Error("Microphone recording is not supported in this browser"));let o=it();if(!o)throw w("recording_failed",new Error("No supported audio codec found"));if(n?.aborted)throw w("aborted",new Error("Voice recording aborted before start"));let r;try{r=await navigator.mediaDevices.getUserMedia({audio:!0});}catch(g){let h=g instanceof DOMException&&g.name==="NotAllowedError"?"Microphone permission denied":"Failed to access microphone";throw w("recording_failed",new Error(h))}if(n?.aborted)throw r.getTracks().forEach(g=>g.stop()),w("aborted",new Error("Voice recording aborted after permission"));let i=t?.maxDurationMs??rn,c=new MediaRecorder(r,{mimeType:o}),a=[],f=[],s=0,d=null,l=null,p=false,m=()=>{d!==null&&(clearInterval(d),d=null),l!==null&&(clearTimeout(l),l=null),r.getTracks().forEach(g=>g.stop());},u=new Promise((g,h)=>{if(c.ondataavailable=k=>{k.data.size>0&&a.push(k.data);},c.onstop=()=>{if(p)return;p=true,m();let k=Date.now()-s,v=new Blob(a,{type:rt});g({blob:v,mime:rt,durationMs:k});},c.onerror=()=>{p||(p=true,m(),h(w("recording_failed",new Error("MediaRecorder error"))));},n){let k=()=>{p||(p=true,c.state!=="inactive"&&c.stop(),m(),h(w("aborted",new Error("Voice recording aborted"))));};n.addEventListener("abort",k,{once:true});}});return c.start(1e3),s=Date.now(),d=setInterval(()=>{let g=Date.now()-s;for(let h of f)h(g);},sn),l=setTimeout(()=>{l=null,!p&&c.state!=="inactive"&&c.stop();},i),{result:u,stop(){!p&&c.state!=="inactive"&&c.stop();},onTick(g){f.push(g);},abort(){p||(p=true,c.state!=="inactive"&&c.stop(),m());}}}var ln=12e3,dn=2,un=500,fn=2e3,ke="https://blocfeed.com/api/feedback",pn="https://blocfeed.com/api/feedback/voice",st=0,lt="blocfeed-viewer-token",dt="blocfeed-my-feedback-url";function mn(){try{return localStorage.getItem(lt)}catch{return null}}function wo(){try{return localStorage.getItem(dt)}catch{return null}}function gn(e,t){try{localStorage.setItem(lt,e),t&&localStorage.setItem(dt,t);}catch{}}function at(e,t){return new Promise((n,o)=>{if(t?.aborted){o(new Error("Aborted"));return}let r=setTimeout(n,e),i=()=>{clearTimeout(r),o(new Error("Aborted"));};t?.addEventListener("abort",i,{once:true});})}function hn(e){return e>=500&&e<=599}function bn(e){let[t,n]=e.split(",",2);if(!t||!n)throw new Error("Invalid data URL");let r=/data:(.*?);base64/.exec(t)?.[1]||"application/octet-stream",i=atob(n),c=new Uint8Array(i.length);for(let a=0;a<i.length;a+=1)c[a]=i.charCodeAt(a);return new Blob([c],{type:r})}function wn(e){let t={},n={},o={...e};if(o.screenshots){let r={},i={...o.screenshots};i.element&&(t.element=i.element.dataUrl,r.element={mime:i.element.mime,width:i.element.width,height:i.element.height},i.element={...i.element,dataUrl:""}),i.fullPage&&(t.fullPage=i.fullPage.dataUrl,r.fullPage={mime:i.fullPage.mime,width:i.fullPage.width,height:i.fullPage.height},i.fullPage={...i.fullPage,dataUrl:""}),o.screenshots=i,(r.element||r.fullPage)&&(o.screenshot_intent=r);}return o.video&&(n.blob=o.video.blob,o.video_intent={mime:o.video.mime,durationMs:o.video.durationMs,sizeBytes:o.video.sizeBytes},delete o.video),{lean:o,extracted:t,extractedVideo:n}}async function ct(e,t,n){let o=bn(t);await fetch(e,{method:"PUT",body:o,headers:{"content-type":o.type},...n?{signal:n}:{}});}async function vn(e){let{feedbackId:t,extracted:n,screenshots:o,signal:r}=e,i={};n.element&&o?.element&&(i.element={dataUrl:n.element,mime:o.element.mime,width:o.element.width,height:o.element.height}),n.fullPage&&o?.fullPage&&(i.fullPage={dataUrl:n.fullPage,mime:o.fullPage.mime,width:o.fullPage.width,height:o.fullPage.height}),Object.keys(i).length!==0&&await fetch(`${ke}/${t}/screenshots`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i),...r?{signal:r}:{}});}async function yn(e){await fetch(`${ke}/${e.feedbackId}/video`,{method:"POST",body:e.blob,headers:{"content-type":e.blob.type},...e.signal?{signal:e.signal}:{}});}async function ut(e){let{signal:t,transport:n}=e;if(Date.now()-st<fn)return {ok:false,error:w("configuration",new Error("Please wait before submitting again"))};let r=n?.timeoutMs??ln,i=n?.maxAttempts??dn,c=n?.backoffMs??un,a=!!(e.payload.screenshots?.element?.dataUrl||e.payload.screenshots?.fullPage?.dataUrl),f=!!e.payload.video?.blob,s=a||f,{lean:d,extracted:l,extractedVideo:p}=s?wn(e.payload):{lean:e.payload,extracted:{},extractedVideo:{}},m=mn();m&&(d.viewer_token=m);let u={...l,...e.screenshotDataUrls};for(let g=1;g<=i;g+=1){let h=new AbortController,k=setTimeout(()=>h.abort(),r),v=()=>h.abort();t&&t.addEventListener("abort",v,{once:true});try{let R=await fetch(ke,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(d),signal:h.signal});if(R.ok){st=Date.now();let _;try{_=await R.json();}catch{}if(_?.viewer_token&&gn(_.viewer_token,_.my_feedback_url),(u.element||u.fullPage)&&_){let M=_.upload_urls;if(M){let U=[];u.element&&M.element&&U.push(ct(M.element,u.element,t)),u.fullPage&&M.fullPage&&U.push(ct(M.fullPage,u.fullPage,t));try{await Promise.all(U);}catch{}}else if(_.feedback_id)try{await vn({feedbackId:_.feedback_id,extracted:u,screenshots:e.payload.screenshots,...t?{signal:t}:{}});}catch{}}if(p.blob&&_){let M=_.upload_urls;if(M?.video)try{await fetch(M.video,{method:"PUT",body:p.blob,headers:{"content-type":p.blob.type},...t?{signal:t}:{}});}catch{}else if(_.feedback_id)try{await yn({feedbackId:_.feedback_id,blob:p.blob,...t?{signal:t}:{}});}catch{}}let B={ok:!0,status:R.status};return _&&(B.apiResponse=_),B}if(g<i&&hn(R.status)){let _=.85+Math.random()*.3,ee=Math.round(c*2**(g-1)*_);await at(ee,t);continue}let P=`HTTP ${R.status}`;try{let _=await R.json();_?.error&&(P=_.error);}catch{}return {ok:!1,status:R.status,error:w("api_failed",new Error(P))}}catch(R){if(h.signal.aborted||t?.aborted)return {ok:false,error:w("aborted",R)};if(g<i){let P=.85+Math.random()*.3,_=Math.round(c*2**(g-1)*P);await at(_,t);continue}return {ok:false,error:w("api_failed",R)}}finally{clearTimeout(k),t&&t.removeEventListener("abort",v);}}return {ok:false,error:w("api_failed",new Error("Failed"))}}async function ft(e){let{blob:t,mime:n,blocfeedId:o,signal:r}=e,i=await fetch(pn,{method:"POST",headers:{"Content-Type":n,"X-Blocfeed-Id":o},body:t,...r?{signal:r}:{}});if(!i.ok){let a=await i.json().catch(()=>({error:"Unknown error"}));throw w("api_failed",new Error(a?.error??`Voice API returned ${i.status}`))}let c=await i.json();return {text:c.text??"",warning:c.warning}}var En={enabled:true,sampling:1,ignoreSelectors:["[data-blocfeed-ui]","[data-blocfeed-ignore]"],rageClick:{enabled:true,threshold:3,windowMs:1e3},httpFail:{enabled:true,statusCodes:[400,401,403,422,500,502,503,504],ignoreUrls:["/api/behavioral-events","/api/feedback"]},redirectLoop:{enabled:true,threshold:3,windowMs:2e3},formDataLoss:{enabled:true}};function pt(e){let t=En;return {enabled:e?.enabled??t.enabled,sampling:e?.sampling??t.sampling,ignoreSelectors:e?.ignoreSelectors??t.ignoreSelectors,rageClick:{...t.rageClick,...e?.rageClick??{}},httpFail:{...t.httpFail,...e?.httpFail??{}},redirectLoop:{...t.redirectLoop,...e?.redirectLoop??{}},formDataLoss:{...t.formDataLoss,...e?.formDataLoss??{}}}}function mt(e){let t=[];async function n(){if(t.length===0)return;let r=t.splice(0,50);try{await fetch(e.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-blocfeed-id":e.blocfeedId},body:JSON.stringify({events:r}),keepalive:!0});}catch{}}function o(){if(t.length===0)return;if(typeof navigator>"u"||typeof navigator.sendBeacon!="function"){n();return}let r=t.splice(0,50),i=new Blob([JSON.stringify({events:r})],{type:"application/json"}),c=`${e.endpoint}?_bfid=${encodeURIComponent(e.blocfeedId)}`;try{navigator.sendBeacon(c,i);}catch{}}return {enqueue(r){t.push(r);},flush:n,flushBeacon:o,size(){return t.length}}}var gt="bf_behavioral_session",ne=null;function O(){try{let e=sessionStorage.getItem(gt);if(e)return e;let t=ht();return sessionStorage.setItem(gt,t),t}catch{return ne||(ne=ht(),ne)}}function ht(){let e=Math.random().toString(36).slice(2,10).padEnd(8,"0");return `bf_${Date.now()}_${e}`}function bt(e,t){if(!e.rageClick.enabled)return ()=>{};let{threshold:n,windowMs:o}=e.rageClick,r=new Map;function i(c){try{let a=c.target;if(!a||!(a instanceof Element)||Sn(a,e.ignoreSelectors))return;let f=W(a,4);if(!f)return;let s=Date.now(),l=(r.get(f)??[]).filter(p=>s-p<=o);if(l.push(s),r.set(f,l),l.length>=n){let p=_n(a),m={session_id:O(),event_type:"rage_click",page_url:typeof window>"u"?"":window.location.href,selector:f,event_data:{click_count:l.length,window_ms:o,disabled:p||void 0},created_at:new Date().toISOString()};t(m),r.set(f,[]);}}catch{}}return document.addEventListener("click",i,{capture:true,passive:true}),()=>document.removeEventListener("click",i,{capture:true})}function _n(e){if(e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true")return true;try{if(window.getComputedStyle(e).pointerEvents==="none")return !0}catch{}return false}function Sn(e,t){if(t.length===0)return false;for(let n of t)try{if(e.matches(n)||e.closest(n))return !0}catch{}return false}var vt=0,yt=null,kn=1500;function Tn(){function e(t){try{let n=t.target;if(!n)return;let o=n.closest('button[type="submit"], input[type="submit"], [data-blocfeed-submit]');if(!o)return;vt=Date.now();let r=o.closest("form");yt=(r?W(r,3):"")||null;}catch{}}return document.addEventListener("click",e,{capture:true,passive:true}),()=>document.removeEventListener("click",e,{capture:true})}function Et(e,t){if(!e.httpFail.enabled)return ()=>{};let{statusCodes:n,ignoreUrls:o}=e.httpFail,r=new Set(n),i=Tn(),c=globalThis.fetch,a=async(l,p)=>{let m=typeof l=="string"?l:l instanceof URL?l.toString():l.url,u=(p?.method??l.method??"GET").toUpperCase(),g=await c.call(globalThis,l,p);try{!wt(m,o)&&r.has(g.status)&&t(d(g.status,m,u));}catch{}return g};globalThis.fetch=a;let f=XMLHttpRequest.prototype.open,s=XMLHttpRequest.prototype.send;return XMLHttpRequest.prototype.open=function(l,p,...m){return this.__bf_url=p,this.__bf_method=l.toUpperCase(),f.call(this,l,p,...m)},XMLHttpRequest.prototype.send=function(l){let p=()=>{try{let m=this.__bf_url??"",u=this.__bf_method??"GET";!wt(m,o)&&r.has(this.status)&&t(d(this.status,m,u));}catch{}};return this.__bf_handler=p,this.addEventListener("loadend",p),s.call(this,l??null)},()=>{globalThis.fetch=c,XMLHttpRequest.prototype.open=f,XMLHttpRequest.prototype.send=s,i();};function d(l,p,m){let g=Date.now()-vt<kn;return {session_id:O(),event_type:"error",page_url:typeof window>"u"?"":window.location.href,selector:null,event_data:{http_status:l,request_url:p,method:m,form_selector:g?yt:null},created_at:new Date().toISOString()}}}function wt(e,t){if(t.length===0)return false;for(let n of t)if(e.includes(n))return true;return false}var Rn=3e4;function _t(e,t){if(!e.redirectLoop.enabled)return ()=>{};if(typeof window>"u")return ()=>{};let{threshold:n,windowMs:o}=e.redirectLoop,r=new Map,i=new Map,c=history.pushState,a=history.replaceState;function f(d){try{let l=Date.now(),p=i.get(d)??0;if(l<p)return;let u=(r.get(d)??[]).filter(g=>l-g<=o);if(u.push(l),r.set(d,u),u.length>=n){let g={session_id:O(),event_type:"thrashing",page_url:window.location.href,selector:null,event_data:{count:u.length,url:d,window_ms:o},created_at:new Date().toISOString()};t(g),i.set(d,l+Rn),r.set(d,[]);}}catch{}}function s(){let d=window.location.pathname+window.location.search;f(d);}return history.pushState=function(...d){let l=c.apply(this,d);return s(),l},history.replaceState=function(...d){let l=a.apply(this,d);return s(),l},window.addEventListener("popstate",s),()=>{history.pushState=c,history.replaceState=a,window.removeEventListener("popstate",s);}}function St(e,t){if(!e.formDataLoss.enabled)return ()=>{};if(typeof window>"u")return ()=>{};let n=new Set,o=0;function r(s){let d=s.closest("form");return d?d.id?`#${d.id}`:"form":null}function i(s){try{let d=s.target;if(!d||!(d instanceof HTMLInputElement||d instanceof HTMLTextAreaElement||d instanceof HTMLSelectElement))return;let l=r(d);if(!l)return;n.has(l)||n.add(l),o++;}catch{}}function c(s){if(n.size===0)return;let d=Array.from(n),l={session_id:O(),event_type:"form_abandonment",page_url:window.location.href,selector:d[0]??null,event_data:{cause:s,field_count:o,forms:d},created_at:new Date().toISOString()};t(l);}function a(s){s.persisted&&c("bfcache_restore");}function f(){c("beforeunload_after_edit");}return document.addEventListener("input",i,{capture:true,passive:true}),window.addEventListener("pageshow",a),window.addEventListener("beforeunload",f),()=>{document.removeEventListener("input",i,{capture:true}),window.removeEventListener("pageshow",a),window.removeEventListener("beforeunload",f);}}var Cn=5e3,oe=class{constructor(t){this.submitter=null;this.detectorUninstallers=[];this.flushTimer=null;this.pageHideHandler=null;this.installed=false;this.opts=t,this.resolved=pt(t.config);}install(){if(this.installed||!this.resolved.enabled||!(this.opts.passiveSampler??(()=>Math.random()<this.resolved.sampling))())return;let n=this.opts.endpoint??"https://blocfeed.com/api/behavioral-events";this.submitter=this.opts.submitter??mt({endpoint:n,blocfeedId:this.opts.blocfeedId});let o=r=>{this.submitter?.enqueue(r);};this.detectorUninstallers.push(bt(this.resolved,o)),this.detectorUninstallers.push(Et(this.resolved,o)),this.detectorUninstallers.push(_t(this.resolved,o)),this.detectorUninstallers.push(St(this.resolved,o)),this.flushTimer=setInterval(()=>{this.submitter?.flush();},Cn),this.pageHideHandler=()=>{this.submitter?.flushBeacon();},typeof window<"u"&&window.addEventListener("pagehide",this.pageHideHandler),this.installed=true;}uninstall(){if(this.installed){for(let t of this.detectorUninstallers)try{t();}catch{}this.detectorUninstallers=[],this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null),this.pageHideHandler&&typeof window<"u"&&(window.removeEventListener("pagehide",this.pageHideHandler),this.pageHideHandler=null);try{this.submitter?.flush();}catch{}this.submitter=null,this.installed=false;}}};function Te(e){let t=null,n=null,o=(...r)=>{n=r,t===null&&(t=requestAnimationFrame(()=>{if(t=null,!n)return;let i=n;n=null,e(...i);}));};return o.cancel=()=>{t!==null&&cancelAnimationFrame(t),t=null,n=null;},o}function re(e){return e instanceof Element?!!e.closest("[data-blocfeed-ui]"):false}function ie(e){e.stopPropagation(),e.stopImmediatePropagation?.();}function kt(e,t){if(!y())throw new Error("BlocFeed picker can only run in a browser environment.");let n=e.ignoreSelectors,o=e.isSelectable,r={};n&&n.length>0&&(r.ignoreSelectors=n),o&&(r.isSelectable=o);let i=null,c=null,a=(u,g=false)=>{if(!u){i=null,c=null,t.onHover(null);return}let h=pe(u.getBoundingClientRect()),k=`${Math.round(h.x)}:${Math.round(h.y)}:${Math.round(h.width)}:${Math.round(h.height)}`;!g&&u===i&&k===c||(i=u,c=k,t.onHover({element:u,rect:h}));},f=Te(u=>{if(re(u.target))return;let g=document.elementFromPoint(u.clientX,u.clientY),h=be(g,r);a(h);}),s=Te(()=>{i&&a(i,true);}),d=u=>{re(u.target)||(ie(u),u.pointerType==="mouse"&&u.preventDefault());},l=u=>{re(u.target)||(ie(u),u.pointerType==="mouse"&&u.preventDefault());},p=u=>{if(re(u.target))return;ie(u),u.preventDefault();let g=document.elementFromPoint(u.clientX,u.clientY),h=be(g,r);h&&t.onSelect({element:h,descriptor:Ve(h)});},m=u=>{u.key==="Escape"&&(ie(u),u.preventDefault(),t.onCancel());};return window.addEventListener("pointermove",f,{capture:true,passive:true}),window.addEventListener("pointerdown",d,{capture:true}),window.addEventListener("pointerup",l,{capture:true}),window.addEventListener("click",p,{capture:true}),window.addEventListener("keydown",m,{capture:true}),window.addEventListener("scroll",s,{capture:true,passive:true}),window.addEventListener("resize",s,{passive:true}),{stop(){window.removeEventListener("pointermove",f,{capture:true}),window.removeEventListener("pointerdown",d,{capture:true}),window.removeEventListener("pointerup",l,{capture:true}),window.removeEventListener("click",p,{capture:true}),window.removeEventListener("keydown",m,{capture:true}),window.removeEventListener("scroll",s,{capture:true}),window.removeEventListener("resize",s),f.cancel(),s.cancel(),t.onHover(null);}}}async function Re(e){let{signal:t,transport:n}=e,o={ok:false};try{let r={payload:e.payload,...t?{signal:t}:{},...n?{transport:n}:{}};o.api=await ut(r),o.ok=!!o.api?.ok;}catch(r){o.api={ok:false,error:w("api_failed",r)},o.ok=false;}return {payload:e.payload,result:o}}var An=["[data-blocfeed-ui]","[data-blocfeed-ignore]"];function xn(e){let t=[...An,...e?.ignoreSelectors??[]],n=Array.from(new Set(t));return {...e,ignoreSelectors:n}}function Tt(){return {phase:"idle"}}function Fn(e){if(e.ok)return false;let t=e.api;return t?t.status&&t.status>=400&&t.status<500||t.error?.kind==="aborted"||t.error?.kind==="configuration"?false:!t.ok:true}function ir(e){let t=e,n=new oe({blocfeedId:t.blocfeed_id??"",...t.behavioral!==void 0?{config:t.behavioral}:{}});n.install();let o=Tt(),r=new Set,i=new Set,c=null,a=null,f=null,s=null,d=0,l=null,p=null,m=null,u=null,g=false,h=()=>{for(let b of r)b(o);},k=b=>{for(let E of i)E(b);},v=b=>{o=b,h();},R=()=>{d+=1,s?.abort(),s=null;},P=()=>{c?.stop(),c=null,k(null),f!==null&&y()&&(document.documentElement.style.cursor=f,f=null);},_=()=>{if(m){try{URL.revokeObjectURL(m.blobUrl);}catch{}m=null;}},ee=()=>{p&&(p.abort(),p=null),_();},B=null,M=()=>{u&&(u.abort(),u=null),B&&(B.abort(),B=null);},U=()=>{R(),P(),ee(),M(),a=null,v(Tt());},Le=()=>{if(!y())return;P(),a=null;let b=xn(t.picker);f=document.documentElement.style.cursor,document.documentElement.style.cursor="crosshair",v({phase:"picking"}),c=kt(b,{onHover:k,onSelect:({element:E,descriptor:x})=>{a=E,P(),v({phase:"review",selection:x});},onCancel:()=>{U();}});},Be=()=>{let b=Ge();if(b.length!==0)for(let E of b)Re({payload:E,...t.transport?{transport:t.transport}:{}}).catch(()=>{Ee(E);});};if(y()){setTimeout(Be,1e3);let b=()=>Be();window.addEventListener("online",b),l=()=>window.removeEventListener("online",b);}return {getState:()=>o,getConfig:()=>t,subscribe(b){return r.add(b),()=>r.delete(b)},subscribeHover(b){return i.add(b),()=>i.delete(b)},start(){o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording"||o.phase!=="picking"&&Le();},stop(){U();},clearSelection(){o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording"||Le();},setConfig(b){t=b;},async submit(b,E){if(!y()){let T=w("configuration",new Error("BlocFeed submit can only run in the browser"));return v({phase:"error",lastError:T}),{ok:false}}let x=t.blocfeed_id?.trim?.()??"";if(!x){let L={phase:"error",lastError:w("configuration",new Error("Missing blocfeed_id. Create a project in BlocFeed and pass its blocfeed_id."))};return o.selection&&(L.selection=o.selection),v(L),{ok:false}}if(g)return {ok:false};if(o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording")return {ok:false};g=true;let A=d+1;d=A,s?.abort(),s=new AbortController;let C=s.signal,S=o.selection,I=E?.capture?{...t.capture,...E.capture}:t.capture,H=!!(I?.element||I?.fullPage),z={phase:H?"capturing":"submitting"};S&&(z.selection=S),v(z);try{let T=H?await We({selectionElement:a,capture:I,signal:C}):void 0;if(C.aborted||d!==A)return {ok:!1};let L={phase:"submitting"};S&&(L.selection=S),T&&(L.capture=T),v(L);let D={};S&&(D.selection=S),T&&(D.capture=T);let j=await Ze({config:t.metadata,context:D,...t.user?{user:t.user}:{}}),V={version:1,createdAt:new Date().toISOString(),blocfeed_id:x,message:b,metadata:j};E?.category&&(V.category=E.category),t.user&&(V.user=t.user),S&&(V.selection=S),T&&(V.screenshots=T),m&&(V.video=m);let{result:N}=await Re({payload:V,signal:C,...t.transport?{transport:t.transport}:{}});if(C.aborted||d!==A)return N;if(N.ok){_(),a=null;let fe={phase:"success",lastSubmit:N};return S&&(fe.selection=S),T&&(fe.capture=T),v(fe),N}Fn(N)&&Ee(V);let xt=N.api?.error??w("unknown",new Error("Submission failed")),ue={phase:"error",lastSubmit:N,lastError:xt};return S&&(ue.selection=S),T&&(ue.capture=T),v(ue),N}catch(T){if(C.aborted||d!==A)return {ok:false};let D={phase:"error",lastError:C.aborted?w("aborted",T):w("unknown",T)};return S&&(D.selection=S),v(D),{ok:false}}finally{g=false,d===A&&(s=null);}},async startRecording(){if(o.phase!=="review"||!t.recording?.enabled||u||p)return;let b=o.selection,E={phase:"recording",recordingElapsedMs:0};b&&(E.selection=b),v(E);try{let x={config:t.recording};s&&(x.signal=s.signal);let A=await _e(x);p=A,A.onTick(I=>{if(o.phase==="recording"){let H={phase:"recording",recordingElapsedMs:I};b&&(H.selection=b),v(H);}});let C=await A.result;p=null,m=C;let S={phase:"review",video:C};b&&(S.selection=b),v(S);}catch(x){p=null;let C={phase:"review",lastError:x?.kind?x:w("recording_failed",x)};b&&(C.selection=b),v(C);}},stopRecording(){o.phase!=="recording"||!p||p.stop();},removeVideo(){_();let b=o.selection,E={phase:"review"};b&&(E.selection=b),v(E);},async startVoice(){if(o.phase!=="review"){console.warn("[BlocFeed] startVoice: ignored \u2014 phase is",o.phase,'(expected "review")');return}let b=t.voice;if(!b?.enabled){console.warn("[BlocFeed] startVoice: ignored \u2014 voice is not enabled in config");return}if(p){console.warn("[BlocFeed] startVoice: ignored \u2014 a screen recording is already in progress");return}M();let E=o.selection,x={phase:"review",voiceRecording:true,voiceElapsedMs:0};E&&(x.selection=E),m&&(x.video=m),v(x);try{let A={config:b};s&&(A.signal=s.signal);let C=await Se(A);u=C,C.onTick(D=>{let j={phase:"review",voiceRecording:!0,voiceElapsedMs:D};E&&(j.selection=E),m&&(j.video=m),v(j);});let S=await C.result;u=null;let I={phase:"review",voiceRecording:!1,voiceTranscribing:!0};E&&(I.selection=E),m&&(I.video=m),v(I),B=new AbortController;let H={blob:S.blob,mime:S.mime,blocfeedId:t.blocfeed_id,signal:B.signal},{text:Ie,warning:z}=await ft(H);B=null;let T={phase:"review",voiceRecording:!1,voiceTranscribing:!1};E&&(T.selection=E),m&&(T.video=m),v(T);let L={text:Ie};return z&&(L.warning=z),L}catch(A){M();let C=A?.kind?A:w("recording_failed",A);console.warn("[BlocFeed] Voice error:",C.message);let S={phase:"review",voiceRecording:false,voiceTranscribing:false,lastError:C};E&&(S.selection=E),m&&(S.video=m),v(S);return}},stopVoice(){u&&u.stop();},__unsafeGetSelectedElement(){return a},destroy(){n.uninstall(),U(),r.clear(),i.clear(),l?.(),l=null;}}}var Y=[],Q=[],Rt=20,Ct=15,se=[],At=typeof console<"u"?{log:console.log?.bind(console),warn:console.warn?.bind(console),error:console.error?.bind(console),info:console.info?.bind(console),debug:console.debug?.bind(console)}:{},ae=typeof globalThis<"u"&&typeof globalThis.fetch=="function"?globalThis.fetch:void 0,ce=typeof XMLHttpRequest<"u"?XMLHttpRequest.prototype.open:void 0,le=typeof XMLHttpRequest<"u"?XMLHttpRequest.prototype.send:void 0,Ae=new Set,xe=false,Fe=false,de=false,Pn=["blocfeed.com","google-analytics.com","googletagmanager.com","analytics.google.com","googleads.g.doubleclick.net","googlesyndication.com","googleadservices.com","google.com/pagead","google.com/ads","facebook.net","facebook.com/tr","connect.facebook.net","graph.facebook.com","api.mixpanel.com","api-js.mixpanel.com","api.amplitude.com","api2.amplitude.com","api.segment.io","cdn.segment.com","vars.hotjar.com","in.hotjar.com","script.hotjar.com","heapanalytics.com","fullstory.com/s/fs.js","rs.fullstory.com","app.posthog.com","us.posthog.com","eu.posthog.com","api-iam.intercom.io","widget.intercom.io","sentry.io/api","browser.sentry-cdn.com","browser-intake-datadoghq.com","clarity.ms","js.hs-analytics.net","api.hubapi.com","forms.hubspot.com","plausible.io/api","client.crisp.chat","js.driftt.com","r.logrocket.com","app.pendo.io","events.launchdarkly.com","app.launchdarkly.com","grammarly.com","gnar.grammarly.com","capi.grammarly.com","api.languagetool.org","api.languagetoolplus.com","fonts.googleapis.com","fonts.gstatic.com","cdn.cookielaw.org","consent.cookiebot.com","js.stripe.com","api.stripe.com/v1/tokens","google.com/recaptcha","hcaptcha.com","bam.nr-data.net","rec.smartlook.com","o2.mouseflow.com","api.luckyorange.com","static.zdassets.com","ekr.zdassets.com"];function Mn(e){if(e instanceof Error)return e.name&&e.name!=="Error"?`${e.name}: ${e.message}`:e.message||String(e);if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function Ln(e,t){let n=t.map(Mn).join(" "),o=t.find(i=>i instanceof Error),r={level:e,message:n.slice(0,2e3),timestamp:Date.now()};for(o?.stack&&(r.stack=o.stack.slice(0,2e3)),Y.push(r);Y.length>Rt;)Y.shift();}function Ce(e){let t=e.url.toLowerCase();for(let n of se)if(t.includes(n))return;for(Q.push(e);Q.length>Ct;)Q.shift();}function cr(e={}){if(de||!y())return;de=true,Rt=e.consoleLimit??20,Ct=e.networkLimit??15;let t=e.ignoreUrls;if(t!==void 0?se=t.map(n=>n.toLowerCase()):se=[...Pn],e.console!==false){let n=e.consoleLevels??["error","warn"];for(let o of n){let r=At[o];r&&(Ae.add(o),console[o]=(...i)=>{Ln(o,i),r.apply(console,i);});}}if(e.network!==false&&ae){let n=ae;xe=true,window.fetch=async function(r,i){let c=typeof r=="string"?r:r instanceof URL?r.toString():r.url,a=(i?.method??"GET").toUpperCase(),f=Date.now();try{let s=await n.call(window,r,i);return s.ok||Ce({url:c.slice(0,500),method:a,status:s.status,statusText:s.statusText,timestamp:f,durationMs:Date.now()-f}),s}catch(s){throw Ce({url:c.slice(0,500),method:a,status:0,statusText:s instanceof Error?s.message:"Network error",timestamp:f,durationMs:Date.now()-f}),s}};}if(e.network!==false&&ce&&le){let n=ce,o=le;Fe=true,XMLHttpRequest.prototype.open=function(r,i,...c){return this.__bf_method=r.toUpperCase(),this.__bf_url=String(i),n.apply(this,[r,i,...c])},XMLHttpRequest.prototype.send=function(...r){let i=this.__bf_method||"GET",c=this.__bf_url||"",a=Date.now();return this.addEventListener("loadend",function(){if(this.status>=400||this.status===0){let f={url:c.slice(0,500),method:i,status:this.status,timestamp:a,durationMs:Date.now()-a};this.statusText&&(f.statusText=this.statusText),Ce(f);}},{once:true}),o.apply(this,r)};}}function lr(){if(de){for(let e of Ae){let t=At[e];t&&(console[e]=t);}Ae.clear(),xe&&ae&&(window.fetch=ae,xe=false),Fe&&ce&&le&&(XMLHttpRequest.prototype.open=ce,XMLHttpRequest.prototype.send=le,Fe=false),se=[],de=false;}}function dr(){return {consoleLogs:[...Y],networkErrors:[...Q]}}function ur(){Y=[],Q=[];}var Bn=[{name:"supabase_service_role_key",pattern:/SUPABASE_SERVICE_ROLE_KEY["'=:\s]{1,8}[A-Za-z0-9_.=-]{30,400}/},{name:"supabase_db_password",pattern:/SUPABASE_DB_PASSWORD["'=:\s]{1,8}[^\s"']{6,200}/},{name:"postgres_password",pattern:/POSTGRES_PASSWORD["'=:\s]{1,8}[^\s"']{6,200}/},{name:"database_url_with_creds",pattern:/(?:postgres|postgresql|mysql|mongodb|redis|amqp):\/\/[^:\s"']{1,100}:[^@\s"']{1,200}@/},{name:"aws_access_key",pattern:/AKIA[0-9A-Z]{16}/},{name:"aws_secret_key",pattern:/AWS_SECRET_ACCESS_KEY["'=:\s]{1,8}[A-Za-z0-9/+=]{30,200}/},{name:"aws_session_token",pattern:/AWS_SESSION_TOKEN["'=:\s]{1,8}[A-Za-z0-9/+=]{30,600}/},{name:"stripe_secret_key",pattern:/sk_live_[a-zA-Z0-9]{10,200}/},{name:"stripe_secret_key_test",pattern:/sk_test_[a-zA-Z0-9]{10,200}/},{name:"stripe_restricted_key",pattern:/rk_(?:live|test)_[a-zA-Z0-9]{10,200}/},{name:"github_pat",pattern:/ghp_[A-Za-z0-9_]{36,100}/},{name:"github_oauth",pattern:/gho_[A-Za-z0-9_]{36,100}/},{name:"github_user_token",pattern:/ghu_[A-Za-z0-9_]{36,100}/},{name:"github_server_token",pattern:/ghs_[A-Za-z0-9_]{36,100}/},{name:"github_fine_grained",pattern:/github_pat_[A-Za-z0-9_]{22,200}/},{name:"openai_api_key",pattern:/sk-[a-zA-Z0-9]{20,200}(?![a-zA-Z0-9_])/},{name:"anthropic_api_key",pattern:/sk-ant-[a-zA-Z0-9\-_]{20,200}/},{name:"private_key",pattern:/-----BEGIN (?:RSA |EC |DSA |OPENSSH |PGP )?PRIVATE KEY-----/},{name:"sendgrid_api_key",pattern:/SG\.[a-zA-Z0-9_-]{22,100}\.[a-zA-Z0-9_-]{22,100}/},{name:"twilio_auth_token",pattern:/TWILIO_AUTH_TOKEN["'=:\s]{1,8}[a-f0-9]{32}/},{name:"generic_secret_key",pattern:/[A-Z_]{2,60}_SECRET_KEY["'=:\s]{1,8}[^\s"']{8,200}/},{name:"generic_secret",pattern:/[A-Z_]{2,60}_SECRET["'=:\s]{1,8}[^\s"']{8,200}/},{name:"generic_password",pattern:/[A-Z_]{2,60}_PASSWORD["'=:\s]{1,8}[^\s"']{6,200}/},{name:"generic_private_key_var",pattern:/[A-Z_]{2,60}_PRIVATE_KEY["'=:\s]{1,8}[^\s"']{8,400}/}],X=[],Me=0,Pe=false;function In(e){let t=e.slice(0,80);return t.length<=6?"***":t.slice(0,6)+"***"}function Dn(e,t,n,o){if(X.some(c=>c.rule===e&&c.source===t))return;let i={rule:e,source:t,hint:In(n),timestamp:Date.now()};o&&(i.location=o),X.push(i);}function J(e,t,n,o){for(let{name:r,pattern:i}of n){let c=i.exec(e);c&&Dn(r,t,c[0],o);}}function Nn(e){try{let t=window;if(t.__NEXT_DATA__){let n=JSON.stringify(t.__NEXT_DATA__);J(n,"hydration",e,"__NEXT_DATA__");}if(t.__NUXT__){let n=JSON.stringify(t.__NUXT__);J(n,"hydration",e,"__NUXT__");}}catch{}}function On(e){try{document.querySelectorAll("script:not([src])").forEach((n,o)=>{let r=n.textContent;r&&r.length>0&&J(r,"scripts",e,`inline-script[${o}]`);});}catch{}}function Un(e){try{document.querySelectorAll("meta[content]").forEach(n=>{let o=n.getAttribute("content"),r=n.getAttribute("name")||n.getAttribute("property")||"";o&&o.length>10&&J(o,"meta",e,r?`meta[${r}]`:void 0);});}catch{}}function Hn(e){try{document.querySelectorAll("[data-api-key], [data-secret], [data-token], [data-password]").forEach(n=>{let o=n.attributes;for(let r=0;r<o.length;r++){let i=o[r];i.name.startsWith("data-")&&i.value.length>10&&J(i.value,"dom",e,`${n.tagName.toLowerCase()}[${i.name}]`);}});}catch{}}function mr(e={}){if(Pe||!y()||(Pe=true,e.secretScan===false))return;let t=[...Bn,...e.customPatterns??[]],n=e.scanTargets??["hydration","scripts","meta","dom"];setTimeout(()=>{Me=Date.now(),n.includes("hydration")&&Nn(t),n.includes("scripts")&&On(t),n.includes("meta")&&Un(t),n.includes("dom")&&Hn(t);let o=e.notify??"both";X.length>0&&(o==="console"||o==="both")&&console.warn(`[BlocFeed Security] Found ${X.length} potential secret(s) exposed in client code:`,X.map(r=>`${r.rule} (${r.source}${r.location?`: ${r.location}`:""})`));},100);}function gr(){return {findings:[...X],scannedAt:Me}}function hr(){X=[],Me=0,Pe=false;}
2
- export{hr as A,y as a,pe as b,$e as c,We as d,Ze as e,Ee as f,Ge as g,Jn as h,eo as i,Gt as j,Yt as k,on as l,_e as m,cn as n,Se as o,mn as p,wo as q,ft as r,oe as s,ir as t,cr as u,lr as v,dr as w,ur as x,mr as y,gr as z};
@@ -1,2 +0,0 @@
1
- 'use strict';function y(){return typeof window<"u"&&typeof document<"u"}function De(e){let t=globalThis.CSS;return typeof t?.escape=="function"?t.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,n=>{let o=n.codePointAt(0);return o===void 0?"":`\\${o.toString(16)} `})}function pe(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function Ft(e){return {x:e.x+window.scrollX,y:e.y+window.scrollY,width:e.width,height:e.height}}function Pt(e){return e.replace(/\s+/g," ").trim()}function me(e,t=140){let n=e.textContent;if(!n)return;let o=Pt(n);if(o)return o.length<=t?o:`${o.slice(0,t-1)}\u2026`}function Mt(e){let t=1;for(let n=e.previousElementSibling;n;n=n.previousElementSibling)n.tagName===e.tagName&&(t+=1);return t}var He=["data-testid","data-test-id","data-test","data-qa","data-cy"],Ne="data-blocfeed-component";function ge(e){let t=e.closest(`[${Ne}]`);if(!t)return;let o=t.getAttribute(Ne)?.trim();return o||void 0}function Lt(e){for(let t of He){let n=e.closest(`[${t}]`);if(!n)continue;let r=n.getAttribute(t)?.trim();if(r)return r}}function Oe(e){try{let t=e,n=Object.getOwnPropertyNames(t);for(let o of n)if(o.startsWith("__reactFiber$")||o.startsWith("__reactInternalInstance$")){let r=t[o];if(r&&typeof r=="object")return r}}catch{}return null}function q(e){if(e.length<=1||e.length===2&&e[0]===e[0].toLowerCase()||e.startsWith("__")&&e.endsWith("__"))return true;let t=e[0];return t>="a"&&t<="z"}function K(e){if(e){for(let t of e)if(typeof t.name=="string"&&t.name&&!q(t.name))return t.name}}function F(e){if(e&&typeof e!="string"){if(typeof e=="function"){let t=e;return typeof t.displayName=="string"&&t.displayName?t.displayName:typeof t.name=="string"&&t.name?t.name:void 0}if(typeof e=="object"){let t=e,n=t.displayName;if(typeof n=="string"&&n)return n;let o=t.render;if(typeof o=="function"){let i=o;if(typeof i.displayName=="string"&&i.displayName)return i.displayName;if(typeof i.name=="string"&&i.name)return i.name}let r=t.type;return F(r)}}}function he(e){let t=Oe(e);if(!t)return;let n=K(t._debugInfo);if(n)return n;let o=t._debugOwner!==void 0;if(o){let f=t._debugOwner;for(let s=0;f&&s<50;s+=1){let d=K(f._debugInfo);if(d)return d;let l=F(f.type)??F(f.elementType);if(l&&!q(l))return l;f=f._debugOwner;}}if(t._owner!==void 0&&t._owner!==t._debugOwner){let f=t._owner;for(let s=0;f&&s<50;s+=1){let d=K(f._debugInfo);if(d)return d;let l=F(f.type)??F(f.elementType);if(l&&!q(l))return l;f=f._owner;}}let i=t,c=o?80:25;for(let f=0;i&&f<c;f+=1){let s=K(i._debugInfo);if(s)return s;let d=F(i.type)??F(i.elementType);if(d&&!q(d))return d;i=i.return;}let a=e.parentElement;for(let f=0;a&&f<15;f+=1){let s=Oe(a);if(s){let d=K(s._debugInfo);if(d)return d;let l=F(s.type)??F(s.elementType);if(l&&!q(l))return l;if(s._debugOwner){let p=F(s._debugOwner.type)??F(s._debugOwner.elementType);if(p&&!q(p))return p}if(s._owner&&s._owner!==s._debugOwner){let p=F(s._owner.type)??F(s._owner.elementType);if(p&&!q(p))return p}}a=a.parentElement;}}function Bt(e){let t=e.tagName.toLowerCase(),n=e.getAttribute("id");if(n)return `#${De(n)}`;for(let o of He){let r=e.getAttribute(o);if(r)return `${t}[${o}="${De(r)}"]`}return `${t}:nth-of-type(${Mt(e)})`}function W(e,t=10){let n=[],o=e;for(;o&&n.length<t;){let r=Bt(o);if(n.unshift(r),r.startsWith("#"))break;o=o.parentElement;}return n.join(" > ")}function Ue(e,t){if(!t||t.length===0)return false;for(let n of t)if(e.closest(n))return true;return false}function be(e,t){if(!e||Ue(e,t.ignoreSelectors))return null;let n=e;for(;n;){if(Ue(n,t.ignoreSelectors))return null;if(t.isSelectable?t.isSelectable(n):It(n))return n;n=n.parentElement;}return null}function It(e){let t=e.tagName;return !(t==="HTML"||t==="BODY")}function Ve(e){let t=e.getBoundingClientRect(),n={selector:W(e),tagName:e.tagName.toLowerCase(),rect:pe(t),pageRect:Ft(t)},o=e.getAttribute("id");o&&(n.id=o);let r=e.className;typeof r=="string"&&r.trim()&&(n.className=r);let i=me(e);i&&(n.textSnippet=i);let c=ge(e)??he(e);c&&(n.componentName=c);let a=Lt(e);return a&&(n.testId=a),n}var we=null;async function qe(){return we||(we=import('html-to-image')),we}async function Dt(e){return await new Promise((t,n)=>{let o=new Image;o.onload=()=>t({width:o.naturalWidth,height:o.naturalHeight}),o.onerror=()=>n(new Error("Failed to load generated screenshot")),o.src=e;})}async function Xe(e,t){let{width:n,height:o}=await Dt(e);return {dataUrl:e,mime:t,width:n,height:o}}function $(e){if(e?.aborted)throw new Error("Aborted")}function $e(){return {async captureElement(e,t){if(!y())throw new Error("captureElement can only run in the browser");$(t.signal);let n=await qe();$(t.signal);let o=t.mime==="image/jpeg"?await n.toJpeg(e,{quality:t.quality??.92,pixelRatio:t.pixelRatio}):await n.toPng(e,{pixelRatio:t.pixelRatio});return $(t.signal),await Xe(o,t.mime)},async captureFullPage(e){if(!y())throw new Error("captureFullPage can only run in the browser");$(e.signal);let t=document.documentElement,n=Math.max(t.scrollWidth,t.clientWidth),o=Math.max(t.scrollHeight,t.clientHeight),r=Math.min(1,e.maxDimension/Math.max(n,o)),i=Math.max(1,Math.round(n*r)),c=Math.max(1,Math.round(o*r)),a=await qe();$(e.signal);let f=e.mime==="image/jpeg"?await a.toJpeg(t,{width:i,height:c,quality:e.quality??.92,pixelRatio:e.pixelRatio}):await a.toPng(t,{width:i,height:c,pixelRatio:e.pixelRatio});return $(e.signal),await Xe(f,e.mime)}}}function Nt(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return "Unknown error"}}function w(e,t,n){let o={kind:e,message:Nt(t)};return n&&(o.detail=n),o}var Ot=12e3,Ut=2048,Ht=.92;function ze(){return Date.now()}function Vt(e){return new Promise((t,n)=>{let o=()=>n(new Error("Aborted"));if(e.aborted){o();return}e.addEventListener("abort",o,{once:true});})}async function je(e,t,n){let o=new Promise((i,c)=>{let a=setTimeout(()=>c(new Error("Timeout")),t);typeof a.unref=="function"&&a.unref();}),r=[e,o];return n&&r.push(Vt(n)),await Promise.race(r)}function qt(e){if(!y())return 1;let t=window.devicePixelRatio||1,n=e?.pixelRatio??Math.min(t,2);return Math.max(.1,n)}function Xt(e){return !!(e?.element||e?.fullPage)}function Ke(e){let t={mime:e.mime,pixelRatio:e.pixelRatio,maxDimension:e.maxDimension};return e.includeQuality&&(t.quality=e.quality),e.signal&&(t.signal=e.signal),t}async function We(e){let{selectionElement:t,capture:n,signal:o}=e;if(!y()||!Xt(n))return;let r=ze(),i=[],c=n?.timeoutMs??Ot,a=n?.maxDimension??Ut,f=n?.mime??"image/png",s=n?.quality??Ht,d=n?.adapter??$e(),l={},p=qt(n);if(n?.element&&t)try{let g=t.getBoundingClientRect(),h=Math.min(1,a/Math.max(g.width,g.height)),k=Math.min(p,p*h),v=await je(Promise.resolve(d.captureElement(t,{...Ke({mime:f,quality:s,pixelRatio:k,maxDimension:a,includeQuality:f==="image/jpeg",...o?{signal:o}:{}})})),c,o);l.element=v;}catch(g){if(o?.aborted)throw g;i.push(w("capture_failed",g,{target:"element"}));}if(n?.fullPage)try{let g=await je(Promise.resolve(d.captureFullPage(Ke({mime:f,quality:s,pixelRatio:p,maxDimension:a,includeQuality:f==="image/jpeg",...o?{signal:o}:{}}))),c,o);l.fullPage=g;}catch(g){if(o?.aborted)throw g;i.push(w("capture_failed",g,{target:"fullPage"}));}let m=ze(),u={startedAt:r,finishedAt:m,durationMs:Math.max(0,m-r)};return i.length>0&&(u.errors=i),{...l,diagnostics:u}}function $t(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function zt(){return y()?{url:window.location.href,title:document.title,referrer:document.referrer||void 0,userAgent:navigator.userAgent,language:navigator.language,platform:navigator.platform,viewport:{width:window.innerWidth,height:window.innerHeight},screen:{width:window.screen.width,height:window.screen.height},scroll:{x:window.scrollX,y:window.scrollY},devicePixelRatio:window.devicePixelRatio||1,timezone:$t()}:{}}function jt(e){if(!e)return {};let t={};return e.id&&(t.userId=e.id),e.email&&(t.userEmail=e.email),e.name&&(t.userName=e.name),t}async function Ze(e){let{config:t,context:n,user:o}=e;if(t?.enabled===false)return {};let r={...zt(),...jt(o)},i=t?.enrich;if(!i)return r;try{let c=await i(n);return {...r,...c}}catch(c){let a=w("unknown",c);return {...r,blocfeedMetadataError:a.message}}}var Z="blocfeed-queue",Kt=50;function ve(){if(!y())return [];try{let e=localStorage.getItem(Z);if(!e)return [];let t=JSON.parse(e);if(Array.isArray(t))return t;console.warn("[BlocFeed] offline queue was corrupt (non-array) \u2014 resetting");try{localStorage.removeItem(Z);}catch{}return []}catch(e){console.warn("[BlocFeed] offline queue could not be read \u2014 resetting",e);try{localStorage.removeItem(Z);}catch{}return []}}function ye(e){if(y())try{e.length===0?localStorage.removeItem(Z):localStorage.setItem(Z,JSON.stringify(e));}catch(t){let n=t instanceof DOMException?t.name:"";console.warn(`[BlocFeed] failed to persist offline queue${n?` (${n})`:""} \u2014 feedback may be lost if page is closed`);}}function Wt(e){let t={...e};if(t.screenshots){let n={...t.screenshots};n.element&&(n.element={...n.element,dataUrl:""}),n.fullPage&&(n.fullPage={...n.fullPage,dataUrl:""}),t.screenshots=n;}return delete t.video,t}function Ee(e){let t=ve(),n=Wt(e);for(n.metadata={...n.metadata,_queued:true},t.push({payload:n,timestamp:Date.now()});t.length>Kt;)t.shift();ye(t);}function Ge(){let e=ve();return e.length===0?[]:(ye([]),e.map(t=>t.payload))}function Jn(){ye([]);}function eo(){return ve().length}var Zt=200,G=[],Ye=0,te=false;function Qe(e){let t=e.target;if(!(t instanceof Element)||t.closest("[data-blocfeed-ui]"))return;let n={timestampMs:Date.now()-Ye,path:window.location.pathname,tagName:t.tagName.toLowerCase()},o=me(t,100);o&&(n.textSnippet=o);let r=ge(t)??he(t);r&&(n.componentName=r),G.length<Zt&&G.push(n);}var Je={capture:true,passive:true};function et(){te||!y()||(te=true,G=[],Ye=Date.now(),document.addEventListener("click",Qe,Je));}function tt(){te&&(te=false,document.removeEventListener("click",Qe,Je));}function Gt(){return [...G]}function Yt(){G=[];}var Qt=3e4,Jt=25e5,nt="video/webm",en=250,tn=1e3,nn=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"];function ot(){if(typeof MediaRecorder>"u")return null;for(let e of nn)if(MediaRecorder.isTypeSupported(e))return e;return null}function on(){return !y()||typeof navigator?.mediaDevices?.getDisplayMedia!="function"?false:ot()!==null}async function _e(e){let{config:t,signal:n}=e;if(!y()||typeof navigator?.mediaDevices?.getDisplayMedia!="function")throw w("recording_failed",new Error("Screen recording is not supported in this browser"));let o=ot();if(!o)throw w("recording_failed",new Error("No supported video codec found (WebM required)"));if(n?.aborted)throw w("aborted",new Error("Recording aborted before start"));let r;try{r=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1});}catch(h){let k=h instanceof DOMException&&h.name==="NotAllowedError"?"Screen share permission denied":"Failed to start screen share";throw w("recording_failed",new Error(k))}if(n?.aborted)throw r.getTracks().forEach(h=>h.stop()),w("aborted",new Error("Recording aborted after permission"));let i=t?.maxDurationMs??Qt,c=t?.videoBitsPerSecond??Jt,a=new MediaRecorder(r,{mimeType:o,videoBitsPerSecond:c}),f=[],s=[],d=0,l=null,p=null,m=false,u=()=>{tt(),l!==null&&(clearInterval(l),l=null),p!==null&&(clearTimeout(p),p=null),r.getTracks().forEach(h=>h.stop());},g=new Promise((h,k)=>{a.ondataavailable=R=>{R.data.size>0&&f.push(R.data);},a.onstop=()=>{if(m)return;m=true,u();let R=Date.now()-d,P=new Blob(f,{type:nt}),_=URL.createObjectURL(P);h({mime:nt,blobUrl:_,blob:P,durationMs:R,sizeBytes:P.size});},a.onerror=()=>{m||(m=true,u(),k(w("recording_failed",new Error("MediaRecorder error"))));};let v=r.getVideoTracks()[0];if(v&&v.addEventListener("ended",()=>{a.state!=="inactive"&&a.stop();}),n){let R=()=>{m||(m=true,a.state!=="inactive"&&a.stop(),u(),k(w("aborted",new Error("Recording aborted"))));};n.addEventListener("abort",R,{once:true});}});return a.start(tn),et(),d=Date.now(),l=setInterval(()=>{let h=Date.now()-d;for(let k of s)k(h);},en),p=setTimeout(()=>{!m&&a.state!=="inactive"&&a.stop();},i),{result:g,stop(){!m&&a.state!=="inactive"&&a.stop();},onTick(h){s.push(h);},abort(){m||(m=true,a.state!=="inactive"&&a.stop(),u());}}}var rn=6e4,rt="audio/webm",sn=250,an=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus"];function it(){if(typeof MediaRecorder>"u")return null;for(let e of an)if(MediaRecorder.isTypeSupported(e))return e;return null}function cn(){return !y()||typeof navigator?.mediaDevices?.getUserMedia!="function"?false:it()!==null}async function Se(e){let{config:t,signal:n}=e;if(!y()||typeof navigator?.mediaDevices?.getUserMedia!="function")throw w("recording_failed",new Error("Microphone recording is not supported in this browser"));let o=it();if(!o)throw w("recording_failed",new Error("No supported audio codec found"));if(n?.aborted)throw w("aborted",new Error("Voice recording aborted before start"));let r;try{r=await navigator.mediaDevices.getUserMedia({audio:!0});}catch(g){let h=g instanceof DOMException&&g.name==="NotAllowedError"?"Microphone permission denied":"Failed to access microphone";throw w("recording_failed",new Error(h))}if(n?.aborted)throw r.getTracks().forEach(g=>g.stop()),w("aborted",new Error("Voice recording aborted after permission"));let i=t?.maxDurationMs??rn,c=new MediaRecorder(r,{mimeType:o}),a=[],f=[],s=0,d=null,l=null,p=false,m=()=>{d!==null&&(clearInterval(d),d=null),l!==null&&(clearTimeout(l),l=null),r.getTracks().forEach(g=>g.stop());},u=new Promise((g,h)=>{if(c.ondataavailable=k=>{k.data.size>0&&a.push(k.data);},c.onstop=()=>{if(p)return;p=true,m();let k=Date.now()-s,v=new Blob(a,{type:rt});g({blob:v,mime:rt,durationMs:k});},c.onerror=()=>{p||(p=true,m(),h(w("recording_failed",new Error("MediaRecorder error"))));},n){let k=()=>{p||(p=true,c.state!=="inactive"&&c.stop(),m(),h(w("aborted",new Error("Voice recording aborted"))));};n.addEventListener("abort",k,{once:true});}});return c.start(1e3),s=Date.now(),d=setInterval(()=>{let g=Date.now()-s;for(let h of f)h(g);},sn),l=setTimeout(()=>{l=null,!p&&c.state!=="inactive"&&c.stop();},i),{result:u,stop(){!p&&c.state!=="inactive"&&c.stop();},onTick(g){f.push(g);},abort(){p||(p=true,c.state!=="inactive"&&c.stop(),m());}}}var ln=12e3,dn=2,un=500,fn=2e3,ke="https://blocfeed.com/api/feedback",pn="https://blocfeed.com/api/feedback/voice",st=0,lt="blocfeed-viewer-token",dt="blocfeed-my-feedback-url";function mn(){try{return localStorage.getItem(lt)}catch{return null}}function wo(){try{return localStorage.getItem(dt)}catch{return null}}function gn(e,t){try{localStorage.setItem(lt,e),t&&localStorage.setItem(dt,t);}catch{}}function at(e,t){return new Promise((n,o)=>{if(t?.aborted){o(new Error("Aborted"));return}let r=setTimeout(n,e),i=()=>{clearTimeout(r),o(new Error("Aborted"));};t?.addEventListener("abort",i,{once:true});})}function hn(e){return e>=500&&e<=599}function bn(e){let[t,n]=e.split(",",2);if(!t||!n)throw new Error("Invalid data URL");let r=/data:(.*?);base64/.exec(t)?.[1]||"application/octet-stream",i=atob(n),c=new Uint8Array(i.length);for(let a=0;a<i.length;a+=1)c[a]=i.charCodeAt(a);return new Blob([c],{type:r})}function wn(e){let t={},n={},o={...e};if(o.screenshots){let r={},i={...o.screenshots};i.element&&(t.element=i.element.dataUrl,r.element={mime:i.element.mime,width:i.element.width,height:i.element.height},i.element={...i.element,dataUrl:""}),i.fullPage&&(t.fullPage=i.fullPage.dataUrl,r.fullPage={mime:i.fullPage.mime,width:i.fullPage.width,height:i.fullPage.height},i.fullPage={...i.fullPage,dataUrl:""}),o.screenshots=i,(r.element||r.fullPage)&&(o.screenshot_intent=r);}return o.video&&(n.blob=o.video.blob,o.video_intent={mime:o.video.mime,durationMs:o.video.durationMs,sizeBytes:o.video.sizeBytes},delete o.video),{lean:o,extracted:t,extractedVideo:n}}async function ct(e,t,n){let o=bn(t);await fetch(e,{method:"PUT",body:o,headers:{"content-type":o.type},...n?{signal:n}:{}});}async function vn(e){let{feedbackId:t,extracted:n,screenshots:o,signal:r}=e,i={};n.element&&o?.element&&(i.element={dataUrl:n.element,mime:o.element.mime,width:o.element.width,height:o.element.height}),n.fullPage&&o?.fullPage&&(i.fullPage={dataUrl:n.fullPage,mime:o.fullPage.mime,width:o.fullPage.width,height:o.fullPage.height}),Object.keys(i).length!==0&&await fetch(`${ke}/${t}/screenshots`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i),...r?{signal:r}:{}});}async function yn(e){await fetch(`${ke}/${e.feedbackId}/video`,{method:"POST",body:e.blob,headers:{"content-type":e.blob.type},...e.signal?{signal:e.signal}:{}});}async function ut(e){let{signal:t,transport:n}=e;if(Date.now()-st<fn)return {ok:false,error:w("configuration",new Error("Please wait before submitting again"))};let r=n?.timeoutMs??ln,i=n?.maxAttempts??dn,c=n?.backoffMs??un,a=!!(e.payload.screenshots?.element?.dataUrl||e.payload.screenshots?.fullPage?.dataUrl),f=!!e.payload.video?.blob,s=a||f,{lean:d,extracted:l,extractedVideo:p}=s?wn(e.payload):{lean:e.payload,extracted:{},extractedVideo:{}},m=mn();m&&(d.viewer_token=m);let u={...l,...e.screenshotDataUrls};for(let g=1;g<=i;g+=1){let h=new AbortController,k=setTimeout(()=>h.abort(),r),v=()=>h.abort();t&&t.addEventListener("abort",v,{once:true});try{let R=await fetch(ke,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(d),signal:h.signal});if(R.ok){st=Date.now();let _;try{_=await R.json();}catch{}if(_?.viewer_token&&gn(_.viewer_token,_.my_feedback_url),(u.element||u.fullPage)&&_){let M=_.upload_urls;if(M){let U=[];u.element&&M.element&&U.push(ct(M.element,u.element,t)),u.fullPage&&M.fullPage&&U.push(ct(M.fullPage,u.fullPage,t));try{await Promise.all(U);}catch{}}else if(_.feedback_id)try{await vn({feedbackId:_.feedback_id,extracted:u,screenshots:e.payload.screenshots,...t?{signal:t}:{}});}catch{}}if(p.blob&&_){let M=_.upload_urls;if(M?.video)try{await fetch(M.video,{method:"PUT",body:p.blob,headers:{"content-type":p.blob.type},...t?{signal:t}:{}});}catch{}else if(_.feedback_id)try{await yn({feedbackId:_.feedback_id,blob:p.blob,...t?{signal:t}:{}});}catch{}}let B={ok:!0,status:R.status};return _&&(B.apiResponse=_),B}if(g<i&&hn(R.status)){let _=.85+Math.random()*.3,ee=Math.round(c*2**(g-1)*_);await at(ee,t);continue}let P=`HTTP ${R.status}`;try{let _=await R.json();_?.error&&(P=_.error);}catch{}return {ok:!1,status:R.status,error:w("api_failed",new Error(P))}}catch(R){if(h.signal.aborted||t?.aborted)return {ok:false,error:w("aborted",R)};if(g<i){let P=.85+Math.random()*.3,_=Math.round(c*2**(g-1)*P);await at(_,t);continue}return {ok:false,error:w("api_failed",R)}}finally{clearTimeout(k),t&&t.removeEventListener("abort",v);}}return {ok:false,error:w("api_failed",new Error("Failed"))}}async function ft(e){let{blob:t,mime:n,blocfeedId:o,signal:r}=e,i=await fetch(pn,{method:"POST",headers:{"Content-Type":n,"X-Blocfeed-Id":o},body:t,...r?{signal:r}:{}});if(!i.ok){let a=await i.json().catch(()=>({error:"Unknown error"}));throw w("api_failed",new Error(a?.error??`Voice API returned ${i.status}`))}let c=await i.json();return {text:c.text??"",warning:c.warning}}var En={enabled:true,sampling:1,ignoreSelectors:["[data-blocfeed-ui]","[data-blocfeed-ignore]"],rageClick:{enabled:true,threshold:3,windowMs:1e3},httpFail:{enabled:true,statusCodes:[400,401,403,422,500,502,503,504],ignoreUrls:["/api/behavioral-events","/api/feedback"]},redirectLoop:{enabled:true,threshold:3,windowMs:2e3},formDataLoss:{enabled:true}};function pt(e){let t=En;return {enabled:e?.enabled??t.enabled,sampling:e?.sampling??t.sampling,ignoreSelectors:e?.ignoreSelectors??t.ignoreSelectors,rageClick:{...t.rageClick,...e?.rageClick??{}},httpFail:{...t.httpFail,...e?.httpFail??{}},redirectLoop:{...t.redirectLoop,...e?.redirectLoop??{}},formDataLoss:{...t.formDataLoss,...e?.formDataLoss??{}}}}function mt(e){let t=[];async function n(){if(t.length===0)return;let r=t.splice(0,50);try{await fetch(e.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-blocfeed-id":e.blocfeedId},body:JSON.stringify({events:r}),keepalive:!0});}catch{}}function o(){if(t.length===0)return;if(typeof navigator>"u"||typeof navigator.sendBeacon!="function"){n();return}let r=t.splice(0,50),i=new Blob([JSON.stringify({events:r})],{type:"application/json"}),c=`${e.endpoint}?_bfid=${encodeURIComponent(e.blocfeedId)}`;try{navigator.sendBeacon(c,i);}catch{}}return {enqueue(r){t.push(r);},flush:n,flushBeacon:o,size(){return t.length}}}var gt="bf_behavioral_session",ne=null;function O(){try{let e=sessionStorage.getItem(gt);if(e)return e;let t=ht();return sessionStorage.setItem(gt,t),t}catch{return ne||(ne=ht(),ne)}}function ht(){let e=Math.random().toString(36).slice(2,10).padEnd(8,"0");return `bf_${Date.now()}_${e}`}function bt(e,t){if(!e.rageClick.enabled)return ()=>{};let{threshold:n,windowMs:o}=e.rageClick,r=new Map;function i(c){try{let a=c.target;if(!a||!(a instanceof Element)||Sn(a,e.ignoreSelectors))return;let f=W(a,4);if(!f)return;let s=Date.now(),l=(r.get(f)??[]).filter(p=>s-p<=o);if(l.push(s),r.set(f,l),l.length>=n){let p=_n(a),m={session_id:O(),event_type:"rage_click",page_url:typeof window>"u"?"":window.location.href,selector:f,event_data:{click_count:l.length,window_ms:o,disabled:p||void 0},created_at:new Date().toISOString()};t(m),r.set(f,[]);}}catch{}}return document.addEventListener("click",i,{capture:true,passive:true}),()=>document.removeEventListener("click",i,{capture:true})}function _n(e){if(e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true")return true;try{if(window.getComputedStyle(e).pointerEvents==="none")return !0}catch{}return false}function Sn(e,t){if(t.length===0)return false;for(let n of t)try{if(e.matches(n)||e.closest(n))return !0}catch{}return false}var vt=0,yt=null,kn=1500;function Tn(){function e(t){try{let n=t.target;if(!n)return;let o=n.closest('button[type="submit"], input[type="submit"], [data-blocfeed-submit]');if(!o)return;vt=Date.now();let r=o.closest("form");yt=(r?W(r,3):"")||null;}catch{}}return document.addEventListener("click",e,{capture:true,passive:true}),()=>document.removeEventListener("click",e,{capture:true})}function Et(e,t){if(!e.httpFail.enabled)return ()=>{};let{statusCodes:n,ignoreUrls:o}=e.httpFail,r=new Set(n),i=Tn(),c=globalThis.fetch,a=async(l,p)=>{let m=typeof l=="string"?l:l instanceof URL?l.toString():l.url,u=(p?.method??l.method??"GET").toUpperCase(),g=await c.call(globalThis,l,p);try{!wt(m,o)&&r.has(g.status)&&t(d(g.status,m,u));}catch{}return g};globalThis.fetch=a;let f=XMLHttpRequest.prototype.open,s=XMLHttpRequest.prototype.send;return XMLHttpRequest.prototype.open=function(l,p,...m){return this.__bf_url=p,this.__bf_method=l.toUpperCase(),f.call(this,l,p,...m)},XMLHttpRequest.prototype.send=function(l){let p=()=>{try{let m=this.__bf_url??"",u=this.__bf_method??"GET";!wt(m,o)&&r.has(this.status)&&t(d(this.status,m,u));}catch{}};return this.__bf_handler=p,this.addEventListener("loadend",p),s.call(this,l??null)},()=>{globalThis.fetch=c,XMLHttpRequest.prototype.open=f,XMLHttpRequest.prototype.send=s,i();};function d(l,p,m){let g=Date.now()-vt<kn;return {session_id:O(),event_type:"error",page_url:typeof window>"u"?"":window.location.href,selector:null,event_data:{http_status:l,request_url:p,method:m,form_selector:g?yt:null},created_at:new Date().toISOString()}}}function wt(e,t){if(t.length===0)return false;for(let n of t)if(e.includes(n))return true;return false}var Rn=3e4;function _t(e,t){if(!e.redirectLoop.enabled)return ()=>{};if(typeof window>"u")return ()=>{};let{threshold:n,windowMs:o}=e.redirectLoop,r=new Map,i=new Map,c=history.pushState,a=history.replaceState;function f(d){try{let l=Date.now(),p=i.get(d)??0;if(l<p)return;let u=(r.get(d)??[]).filter(g=>l-g<=o);if(u.push(l),r.set(d,u),u.length>=n){let g={session_id:O(),event_type:"thrashing",page_url:window.location.href,selector:null,event_data:{count:u.length,url:d,window_ms:o},created_at:new Date().toISOString()};t(g),i.set(d,l+Rn),r.set(d,[]);}}catch{}}function s(){let d=window.location.pathname+window.location.search;f(d);}return history.pushState=function(...d){let l=c.apply(this,d);return s(),l},history.replaceState=function(...d){let l=a.apply(this,d);return s(),l},window.addEventListener("popstate",s),()=>{history.pushState=c,history.replaceState=a,window.removeEventListener("popstate",s);}}function St(e,t){if(!e.formDataLoss.enabled)return ()=>{};if(typeof window>"u")return ()=>{};let n=new Set,o=0;function r(s){let d=s.closest("form");return d?d.id?`#${d.id}`:"form":null}function i(s){try{let d=s.target;if(!d||!(d instanceof HTMLInputElement||d instanceof HTMLTextAreaElement||d instanceof HTMLSelectElement))return;let l=r(d);if(!l)return;n.has(l)||n.add(l),o++;}catch{}}function c(s){if(n.size===0)return;let d=Array.from(n),l={session_id:O(),event_type:"form_abandonment",page_url:window.location.href,selector:d[0]??null,event_data:{cause:s,field_count:o,forms:d},created_at:new Date().toISOString()};t(l);}function a(s){s.persisted&&c("bfcache_restore");}function f(){c("beforeunload_after_edit");}return document.addEventListener("input",i,{capture:true,passive:true}),window.addEventListener("pageshow",a),window.addEventListener("beforeunload",f),()=>{document.removeEventListener("input",i,{capture:true}),window.removeEventListener("pageshow",a),window.removeEventListener("beforeunload",f);}}var Cn=5e3,oe=class{constructor(t){this.submitter=null;this.detectorUninstallers=[];this.flushTimer=null;this.pageHideHandler=null;this.installed=false;this.opts=t,this.resolved=pt(t.config);}install(){if(this.installed||!this.resolved.enabled||!(this.opts.passiveSampler??(()=>Math.random()<this.resolved.sampling))())return;let n=this.opts.endpoint??"https://blocfeed.com/api/behavioral-events";this.submitter=this.opts.submitter??mt({endpoint:n,blocfeedId:this.opts.blocfeedId});let o=r=>{this.submitter?.enqueue(r);};this.detectorUninstallers.push(bt(this.resolved,o)),this.detectorUninstallers.push(Et(this.resolved,o)),this.detectorUninstallers.push(_t(this.resolved,o)),this.detectorUninstallers.push(St(this.resolved,o)),this.flushTimer=setInterval(()=>{this.submitter?.flush();},Cn),this.pageHideHandler=()=>{this.submitter?.flushBeacon();},typeof window<"u"&&window.addEventListener("pagehide",this.pageHideHandler),this.installed=true;}uninstall(){if(this.installed){for(let t of this.detectorUninstallers)try{t();}catch{}this.detectorUninstallers=[],this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null),this.pageHideHandler&&typeof window<"u"&&(window.removeEventListener("pagehide",this.pageHideHandler),this.pageHideHandler=null);try{this.submitter?.flush();}catch{}this.submitter=null,this.installed=false;}}};function Te(e){let t=null,n=null,o=(...r)=>{n=r,t===null&&(t=requestAnimationFrame(()=>{if(t=null,!n)return;let i=n;n=null,e(...i);}));};return o.cancel=()=>{t!==null&&cancelAnimationFrame(t),t=null,n=null;},o}function re(e){return e instanceof Element?!!e.closest("[data-blocfeed-ui]"):false}function ie(e){e.stopPropagation(),e.stopImmediatePropagation?.();}function kt(e,t){if(!y())throw new Error("BlocFeed picker can only run in a browser environment.");let n=e.ignoreSelectors,o=e.isSelectable,r={};n&&n.length>0&&(r.ignoreSelectors=n),o&&(r.isSelectable=o);let i=null,c=null,a=(u,g=false)=>{if(!u){i=null,c=null,t.onHover(null);return}let h=pe(u.getBoundingClientRect()),k=`${Math.round(h.x)}:${Math.round(h.y)}:${Math.round(h.width)}:${Math.round(h.height)}`;!g&&u===i&&k===c||(i=u,c=k,t.onHover({element:u,rect:h}));},f=Te(u=>{if(re(u.target))return;let g=document.elementFromPoint(u.clientX,u.clientY),h=be(g,r);a(h);}),s=Te(()=>{i&&a(i,true);}),d=u=>{re(u.target)||(ie(u),u.pointerType==="mouse"&&u.preventDefault());},l=u=>{re(u.target)||(ie(u),u.pointerType==="mouse"&&u.preventDefault());},p=u=>{if(re(u.target))return;ie(u),u.preventDefault();let g=document.elementFromPoint(u.clientX,u.clientY),h=be(g,r);h&&t.onSelect({element:h,descriptor:Ve(h)});},m=u=>{u.key==="Escape"&&(ie(u),u.preventDefault(),t.onCancel());};return window.addEventListener("pointermove",f,{capture:true,passive:true}),window.addEventListener("pointerdown",d,{capture:true}),window.addEventListener("pointerup",l,{capture:true}),window.addEventListener("click",p,{capture:true}),window.addEventListener("keydown",m,{capture:true}),window.addEventListener("scroll",s,{capture:true,passive:true}),window.addEventListener("resize",s,{passive:true}),{stop(){window.removeEventListener("pointermove",f,{capture:true}),window.removeEventListener("pointerdown",d,{capture:true}),window.removeEventListener("pointerup",l,{capture:true}),window.removeEventListener("click",p,{capture:true}),window.removeEventListener("keydown",m,{capture:true}),window.removeEventListener("scroll",s,{capture:true}),window.removeEventListener("resize",s),f.cancel(),s.cancel(),t.onHover(null);}}}async function Re(e){let{signal:t,transport:n}=e,o={ok:false};try{let r={payload:e.payload,...t?{signal:t}:{},...n?{transport:n}:{}};o.api=await ut(r),o.ok=!!o.api?.ok;}catch(r){o.api={ok:false,error:w("api_failed",r)},o.ok=false;}return {payload:e.payload,result:o}}var An=["[data-blocfeed-ui]","[data-blocfeed-ignore]"];function xn(e){let t=[...An,...e?.ignoreSelectors??[]],n=Array.from(new Set(t));return {...e,ignoreSelectors:n}}function Tt(){return {phase:"idle"}}function Fn(e){if(e.ok)return false;let t=e.api;return t?t.status&&t.status>=400&&t.status<500||t.error?.kind==="aborted"||t.error?.kind==="configuration"?false:!t.ok:true}function ir(e){let t=e,n=new oe({blocfeedId:t.blocfeed_id??"",...t.behavioral!==void 0?{config:t.behavioral}:{}});n.install();let o=Tt(),r=new Set,i=new Set,c=null,a=null,f=null,s=null,d=0,l=null,p=null,m=null,u=null,g=false,h=()=>{for(let b of r)b(o);},k=b=>{for(let E of i)E(b);},v=b=>{o=b,h();},R=()=>{d+=1,s?.abort(),s=null;},P=()=>{c?.stop(),c=null,k(null),f!==null&&y()&&(document.documentElement.style.cursor=f,f=null);},_=()=>{if(m){try{URL.revokeObjectURL(m.blobUrl);}catch{}m=null;}},ee=()=>{p&&(p.abort(),p=null),_();},B=null,M=()=>{u&&(u.abort(),u=null),B&&(B.abort(),B=null);},U=()=>{R(),P(),ee(),M(),a=null,v(Tt());},Le=()=>{if(!y())return;P(),a=null;let b=xn(t.picker);f=document.documentElement.style.cursor,document.documentElement.style.cursor="crosshair",v({phase:"picking"}),c=kt(b,{onHover:k,onSelect:({element:E,descriptor:x})=>{a=E,P(),v({phase:"review",selection:x});},onCancel:()=>{U();}});},Be=()=>{let b=Ge();if(b.length!==0)for(let E of b)Re({payload:E,...t.transport?{transport:t.transport}:{}}).catch(()=>{Ee(E);});};if(y()){setTimeout(Be,1e3);let b=()=>Be();window.addEventListener("online",b),l=()=>window.removeEventListener("online",b);}return {getState:()=>o,getConfig:()=>t,subscribe(b){return r.add(b),()=>r.delete(b)},subscribeHover(b){return i.add(b),()=>i.delete(b)},start(){o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording"||o.phase!=="picking"&&Le();},stop(){U();},clearSelection(){o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording"||Le();},setConfig(b){t=b;},async submit(b,E){if(!y()){let T=w("configuration",new Error("BlocFeed submit can only run in the browser"));return v({phase:"error",lastError:T}),{ok:false}}let x=t.blocfeed_id?.trim?.()??"";if(!x){let L={phase:"error",lastError:w("configuration",new Error("Missing blocfeed_id. Create a project in BlocFeed and pass its blocfeed_id."))};return o.selection&&(L.selection=o.selection),v(L),{ok:false}}if(g)return {ok:false};if(o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording")return {ok:false};g=true;let A=d+1;d=A,s?.abort(),s=new AbortController;let C=s.signal,S=o.selection,I=E?.capture?{...t.capture,...E.capture}:t.capture,H=!!(I?.element||I?.fullPage),z={phase:H?"capturing":"submitting"};S&&(z.selection=S),v(z);try{let T=H?await We({selectionElement:a,capture:I,signal:C}):void 0;if(C.aborted||d!==A)return {ok:!1};let L={phase:"submitting"};S&&(L.selection=S),T&&(L.capture=T),v(L);let D={};S&&(D.selection=S),T&&(D.capture=T);let j=await Ze({config:t.metadata,context:D,...t.user?{user:t.user}:{}}),V={version:1,createdAt:new Date().toISOString(),blocfeed_id:x,message:b,metadata:j};E?.category&&(V.category=E.category),t.user&&(V.user=t.user),S&&(V.selection=S),T&&(V.screenshots=T),m&&(V.video=m);let{result:N}=await Re({payload:V,signal:C,...t.transport?{transport:t.transport}:{}});if(C.aborted||d!==A)return N;if(N.ok){_(),a=null;let fe={phase:"success",lastSubmit:N};return S&&(fe.selection=S),T&&(fe.capture=T),v(fe),N}Fn(N)&&Ee(V);let xt=N.api?.error??w("unknown",new Error("Submission failed")),ue={phase:"error",lastSubmit:N,lastError:xt};return S&&(ue.selection=S),T&&(ue.capture=T),v(ue),N}catch(T){if(C.aborted||d!==A)return {ok:false};let D={phase:"error",lastError:C.aborted?w("aborted",T):w("unknown",T)};return S&&(D.selection=S),v(D),{ok:false}}finally{g=false,d===A&&(s=null);}},async startRecording(){if(o.phase!=="review"||!t.recording?.enabled||u||p)return;let b=o.selection,E={phase:"recording",recordingElapsedMs:0};b&&(E.selection=b),v(E);try{let x={config:t.recording};s&&(x.signal=s.signal);let A=await _e(x);p=A,A.onTick(I=>{if(o.phase==="recording"){let H={phase:"recording",recordingElapsedMs:I};b&&(H.selection=b),v(H);}});let C=await A.result;p=null,m=C;let S={phase:"review",video:C};b&&(S.selection=b),v(S);}catch(x){p=null;let C={phase:"review",lastError:x?.kind?x:w("recording_failed",x)};b&&(C.selection=b),v(C);}},stopRecording(){o.phase!=="recording"||!p||p.stop();},removeVideo(){_();let b=o.selection,E={phase:"review"};b&&(E.selection=b),v(E);},async startVoice(){if(o.phase!=="review"){console.warn("[BlocFeed] startVoice: ignored \u2014 phase is",o.phase,'(expected "review")');return}let b=t.voice;if(!b?.enabled){console.warn("[BlocFeed] startVoice: ignored \u2014 voice is not enabled in config");return}if(p){console.warn("[BlocFeed] startVoice: ignored \u2014 a screen recording is already in progress");return}M();let E=o.selection,x={phase:"review",voiceRecording:true,voiceElapsedMs:0};E&&(x.selection=E),m&&(x.video=m),v(x);try{let A={config:b};s&&(A.signal=s.signal);let C=await Se(A);u=C,C.onTick(D=>{let j={phase:"review",voiceRecording:!0,voiceElapsedMs:D};E&&(j.selection=E),m&&(j.video=m),v(j);});let S=await C.result;u=null;let I={phase:"review",voiceRecording:!1,voiceTranscribing:!0};E&&(I.selection=E),m&&(I.video=m),v(I),B=new AbortController;let H={blob:S.blob,mime:S.mime,blocfeedId:t.blocfeed_id,signal:B.signal},{text:Ie,warning:z}=await ft(H);B=null;let T={phase:"review",voiceRecording:!1,voiceTranscribing:!1};E&&(T.selection=E),m&&(T.video=m),v(T);let L={text:Ie};return z&&(L.warning=z),L}catch(A){M();let C=A?.kind?A:w("recording_failed",A);console.warn("[BlocFeed] Voice error:",C.message);let S={phase:"review",voiceRecording:false,voiceTranscribing:false,lastError:C};E&&(S.selection=E),m&&(S.video=m),v(S);return}},stopVoice(){u&&u.stop();},__unsafeGetSelectedElement(){return a},destroy(){n.uninstall(),U(),r.clear(),i.clear(),l?.(),l=null;}}}var Y=[],Q=[],Rt=20,Ct=15,se=[],At=typeof console<"u"?{log:console.log?.bind(console),warn:console.warn?.bind(console),error:console.error?.bind(console),info:console.info?.bind(console),debug:console.debug?.bind(console)}:{},ae=typeof globalThis<"u"&&typeof globalThis.fetch=="function"?globalThis.fetch:void 0,ce=typeof XMLHttpRequest<"u"?XMLHttpRequest.prototype.open:void 0,le=typeof XMLHttpRequest<"u"?XMLHttpRequest.prototype.send:void 0,Ae=new Set,xe=false,Fe=false,de=false,Pn=["blocfeed.com","google-analytics.com","googletagmanager.com","analytics.google.com","googleads.g.doubleclick.net","googlesyndication.com","googleadservices.com","google.com/pagead","google.com/ads","facebook.net","facebook.com/tr","connect.facebook.net","graph.facebook.com","api.mixpanel.com","api-js.mixpanel.com","api.amplitude.com","api2.amplitude.com","api.segment.io","cdn.segment.com","vars.hotjar.com","in.hotjar.com","script.hotjar.com","heapanalytics.com","fullstory.com/s/fs.js","rs.fullstory.com","app.posthog.com","us.posthog.com","eu.posthog.com","api-iam.intercom.io","widget.intercom.io","sentry.io/api","browser.sentry-cdn.com","browser-intake-datadoghq.com","clarity.ms","js.hs-analytics.net","api.hubapi.com","forms.hubspot.com","plausible.io/api","client.crisp.chat","js.driftt.com","r.logrocket.com","app.pendo.io","events.launchdarkly.com","app.launchdarkly.com","grammarly.com","gnar.grammarly.com","capi.grammarly.com","api.languagetool.org","api.languagetoolplus.com","fonts.googleapis.com","fonts.gstatic.com","cdn.cookielaw.org","consent.cookiebot.com","js.stripe.com","api.stripe.com/v1/tokens","google.com/recaptcha","hcaptcha.com","bam.nr-data.net","rec.smartlook.com","o2.mouseflow.com","api.luckyorange.com","static.zdassets.com","ekr.zdassets.com"];function Mn(e){if(e instanceof Error)return e.name&&e.name!=="Error"?`${e.name}: ${e.message}`:e.message||String(e);if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function Ln(e,t){let n=t.map(Mn).join(" "),o=t.find(i=>i instanceof Error),r={level:e,message:n.slice(0,2e3),timestamp:Date.now()};for(o?.stack&&(r.stack=o.stack.slice(0,2e3)),Y.push(r);Y.length>Rt;)Y.shift();}function Ce(e){let t=e.url.toLowerCase();for(let n of se)if(t.includes(n))return;for(Q.push(e);Q.length>Ct;)Q.shift();}function cr(e={}){if(de||!y())return;de=true,Rt=e.consoleLimit??20,Ct=e.networkLimit??15;let t=e.ignoreUrls;if(t!==void 0?se=t.map(n=>n.toLowerCase()):se=[...Pn],e.console!==false){let n=e.consoleLevels??["error","warn"];for(let o of n){let r=At[o];r&&(Ae.add(o),console[o]=(...i)=>{Ln(o,i),r.apply(console,i);});}}if(e.network!==false&&ae){let n=ae;xe=true,window.fetch=async function(r,i){let c=typeof r=="string"?r:r instanceof URL?r.toString():r.url,a=(i?.method??"GET").toUpperCase(),f=Date.now();try{let s=await n.call(window,r,i);return s.ok||Ce({url:c.slice(0,500),method:a,status:s.status,statusText:s.statusText,timestamp:f,durationMs:Date.now()-f}),s}catch(s){throw Ce({url:c.slice(0,500),method:a,status:0,statusText:s instanceof Error?s.message:"Network error",timestamp:f,durationMs:Date.now()-f}),s}};}if(e.network!==false&&ce&&le){let n=ce,o=le;Fe=true,XMLHttpRequest.prototype.open=function(r,i,...c){return this.__bf_method=r.toUpperCase(),this.__bf_url=String(i),n.apply(this,[r,i,...c])},XMLHttpRequest.prototype.send=function(...r){let i=this.__bf_method||"GET",c=this.__bf_url||"",a=Date.now();return this.addEventListener("loadend",function(){if(this.status>=400||this.status===0){let f={url:c.slice(0,500),method:i,status:this.status,timestamp:a,durationMs:Date.now()-a};this.statusText&&(f.statusText=this.statusText),Ce(f);}},{once:true}),o.apply(this,r)};}}function lr(){if(de){for(let e of Ae){let t=At[e];t&&(console[e]=t);}Ae.clear(),xe&&ae&&(window.fetch=ae,xe=false),Fe&&ce&&le&&(XMLHttpRequest.prototype.open=ce,XMLHttpRequest.prototype.send=le,Fe=false),se=[],de=false;}}function dr(){return {consoleLogs:[...Y],networkErrors:[...Q]}}function ur(){Y=[],Q=[];}var Bn=[{name:"supabase_service_role_key",pattern:/SUPABASE_SERVICE_ROLE_KEY["'=:\s]{1,8}[A-Za-z0-9_.=-]{30,400}/},{name:"supabase_db_password",pattern:/SUPABASE_DB_PASSWORD["'=:\s]{1,8}[^\s"']{6,200}/},{name:"postgres_password",pattern:/POSTGRES_PASSWORD["'=:\s]{1,8}[^\s"']{6,200}/},{name:"database_url_with_creds",pattern:/(?:postgres|postgresql|mysql|mongodb|redis|amqp):\/\/[^:\s"']{1,100}:[^@\s"']{1,200}@/},{name:"aws_access_key",pattern:/AKIA[0-9A-Z]{16}/},{name:"aws_secret_key",pattern:/AWS_SECRET_ACCESS_KEY["'=:\s]{1,8}[A-Za-z0-9/+=]{30,200}/},{name:"aws_session_token",pattern:/AWS_SESSION_TOKEN["'=:\s]{1,8}[A-Za-z0-9/+=]{30,600}/},{name:"stripe_secret_key",pattern:/sk_live_[a-zA-Z0-9]{10,200}/},{name:"stripe_secret_key_test",pattern:/sk_test_[a-zA-Z0-9]{10,200}/},{name:"stripe_restricted_key",pattern:/rk_(?:live|test)_[a-zA-Z0-9]{10,200}/},{name:"github_pat",pattern:/ghp_[A-Za-z0-9_]{36,100}/},{name:"github_oauth",pattern:/gho_[A-Za-z0-9_]{36,100}/},{name:"github_user_token",pattern:/ghu_[A-Za-z0-9_]{36,100}/},{name:"github_server_token",pattern:/ghs_[A-Za-z0-9_]{36,100}/},{name:"github_fine_grained",pattern:/github_pat_[A-Za-z0-9_]{22,200}/},{name:"openai_api_key",pattern:/sk-[a-zA-Z0-9]{20,200}(?![a-zA-Z0-9_])/},{name:"anthropic_api_key",pattern:/sk-ant-[a-zA-Z0-9\-_]{20,200}/},{name:"private_key",pattern:/-----BEGIN (?:RSA |EC |DSA |OPENSSH |PGP )?PRIVATE KEY-----/},{name:"sendgrid_api_key",pattern:/SG\.[a-zA-Z0-9_-]{22,100}\.[a-zA-Z0-9_-]{22,100}/},{name:"twilio_auth_token",pattern:/TWILIO_AUTH_TOKEN["'=:\s]{1,8}[a-f0-9]{32}/},{name:"generic_secret_key",pattern:/[A-Z_]{2,60}_SECRET_KEY["'=:\s]{1,8}[^\s"']{8,200}/},{name:"generic_secret",pattern:/[A-Z_]{2,60}_SECRET["'=:\s]{1,8}[^\s"']{8,200}/},{name:"generic_password",pattern:/[A-Z_]{2,60}_PASSWORD["'=:\s]{1,8}[^\s"']{6,200}/},{name:"generic_private_key_var",pattern:/[A-Z_]{2,60}_PRIVATE_KEY["'=:\s]{1,8}[^\s"']{8,400}/}],X=[],Me=0,Pe=false;function In(e){let t=e.slice(0,80);return t.length<=6?"***":t.slice(0,6)+"***"}function Dn(e,t,n,o){if(X.some(c=>c.rule===e&&c.source===t))return;let i={rule:e,source:t,hint:In(n),timestamp:Date.now()};o&&(i.location=o),X.push(i);}function J(e,t,n,o){for(let{name:r,pattern:i}of n){let c=i.exec(e);c&&Dn(r,t,c[0],o);}}function Nn(e){try{let t=window;if(t.__NEXT_DATA__){let n=JSON.stringify(t.__NEXT_DATA__);J(n,"hydration",e,"__NEXT_DATA__");}if(t.__NUXT__){let n=JSON.stringify(t.__NUXT__);J(n,"hydration",e,"__NUXT__");}}catch{}}function On(e){try{document.querySelectorAll("script:not([src])").forEach((n,o)=>{let r=n.textContent;r&&r.length>0&&J(r,"scripts",e,`inline-script[${o}]`);});}catch{}}function Un(e){try{document.querySelectorAll("meta[content]").forEach(n=>{let o=n.getAttribute("content"),r=n.getAttribute("name")||n.getAttribute("property")||"";o&&o.length>10&&J(o,"meta",e,r?`meta[${r}]`:void 0);});}catch{}}function Hn(e){try{document.querySelectorAll("[data-api-key], [data-secret], [data-token], [data-password]").forEach(n=>{let o=n.attributes;for(let r=0;r<o.length;r++){let i=o[r];i.name.startsWith("data-")&&i.value.length>10&&J(i.value,"dom",e,`${n.tagName.toLowerCase()}[${i.name}]`);}});}catch{}}function mr(e={}){if(Pe||!y()||(Pe=true,e.secretScan===false))return;let t=[...Bn,...e.customPatterns??[]],n=e.scanTargets??["hydration","scripts","meta","dom"];setTimeout(()=>{Me=Date.now(),n.includes("hydration")&&Nn(t),n.includes("scripts")&&On(t),n.includes("meta")&&Un(t),n.includes("dom")&&Hn(t);let o=e.notify??"both";X.length>0&&(o==="console"||o==="both")&&console.warn(`[BlocFeed Security] Found ${X.length} potential secret(s) exposed in client code:`,X.map(r=>`${r.rule} (${r.source}${r.location?`: ${r.location}`:""})`));},100);}function gr(){return {findings:[...X],scannedAt:Me}}function hr(){X=[],Me=0,Pe=false;}
2
- exports.A=hr;exports.a=y;exports.b=pe;exports.c=$e;exports.d=We;exports.e=Ze;exports.f=Ee;exports.g=Ge;exports.h=Jn;exports.i=eo;exports.j=Gt;exports.k=Yt;exports.l=on;exports.m=_e;exports.n=cn;exports.o=Se;exports.p=mn;exports.q=wo;exports.r=ft;exports.s=oe;exports.t=ir;exports.u=cr;exports.v=lr;exports.w=dr;exports.x=ur;exports.y=mr;exports.z=gr;