@makefully/notefully 0.1.59 → 0.1.60

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/README.md CHANGED
@@ -31,8 +31,13 @@ Notefully.init({
31
31
  // Optional canvas-game hooks for the automatic (DOM) capture path:
32
32
  // onBeforeCapture: async () => { engine.render(); },
33
33
  // capture: async () => engine.screenshotCanvas(), // data URL | Blob | HTMLCanvasElement
34
+ // Pause host shortcuts / game input while the dialog is open:
35
+ // onOpen: () => engine.pauseInput(),
36
+ // onClose: () => engine.resumeInput(),
34
37
  });
35
38
 
39
+ // Notefully.isOpen() — true from open() start until close() (incl. capture / sticky success)
40
+
36
41
  // Update settings later without remounting (theme, hideLauncher, video, …):
37
42
  Notefully.configure({ theme: 'quiet-night' });
38
43
  Notefully.setTheme('all-business');
@@ -1,11 +1,11 @@
1
- var Notefully=(function(A){"use strict";function sn(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const n=document.implementation.createHTMLDocument(),r=n.createElement("base"),i=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(i),t&&(r.href=t),i.href=e,i.href}const cn=(()=>{let e=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function _(e){const t=[];for(let n=0,r=e.length;n<r;n++)t.push(e[n]);return t}let Q=null;function Ge(e={}){return Q||(e.includeStyleProperties?(Q=e.includeStyleProperties,Q):(Q=_(window.getComputedStyle(document.documentElement)),Q))}function le(e,t){const r=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}function ln(e){const t=le(e,"border-left-width"),n=le(e,"border-right-width");return e.clientWidth+t+n}function un(e){const t=le(e,"border-top-width"),n=le(e,"border-bottom-width");return e.clientHeight+t+n}function Je(e,t={}){const n=t.width||ln(e),r=t.height||un(e);return{width:n,height:r}}function dn(){let e,t;try{t=process}catch{}const n=t&&t.env?t.env.devicePixelRatio:null;return n&&(e=parseInt(n,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}const C=16384;function fn(e){(e.width>C||e.height>C)&&(e.width>C&&e.height>C?e.width>e.height?(e.height*=C/e.width,e.width=C):(e.width*=C/e.height,e.height=C):e.width>C?(e.height*=C/e.width,e.width=C):(e.width*=C/e.height,e.height=C))}function ue(e){return new Promise((t,n)=>{const r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=n,r.crossOrigin="anonymous",r.decoding="async",r.src=e})}async function hn(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function pn(e,t,n){const r="http://www.w3.org/2000/svg",i=document.createElementNS(r,"svg"),a=document.createElementNS(r,"foreignObject");return i.setAttribute("width",`${t}`),i.setAttribute("height",`${n}`),i.setAttribute("viewBox",`0 0 ${t} ${n}`),a.setAttribute("width","100%"),a.setAttribute("height","100%"),a.setAttribute("x","0"),a.setAttribute("y","0"),a.setAttribute("externalResourcesRequired","true"),i.appendChild(a),a.appendChild(e),hn(i)}const E=(e,t)=>{if(e instanceof t)return!0;const n=Object.getPrototypeOf(e);return n===null?!1:n.constructor.name===t.name||E(n,t)};function yn(e){const t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function mn(e,t){return Ge(t).map(n=>{const r=e.getPropertyValue(n),i=e.getPropertyPriority(n);return`${n}: ${r}${i?" !important":""};`}).join(" ")}function gn(e,t,n,r){const i=`.${e}:${t}`,a=n.cssText?yn(n):mn(n,r);return document.createTextNode(`${i}{${a}}`)}function Qe(e,t,n,r){const i=window.getComputedStyle(e,n),a=i.getPropertyValue("content");if(a===""||a==="none")return;const o=cn();try{t.className=`${t.className} ${o}`}catch{return}const c=document.createElement("style");c.appendChild(gn(o,n,i,r)),t.appendChild(c)}function wn(e,t,n){Qe(e,t,":before",n),Qe(e,t,":after",n)}const Ze="application/font-woff",et="image/jpeg",vn={woff:Ze,woff2:Ze,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:et,jpeg:et,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function bn(e){const t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function Le(e){const t=bn(e).toLowerCase();return vn[t]||""}function Sn(e){return e.split(/,/)[1]}function Ae(e){return e.search(/^(data:)/)!==-1}function xn(e,t){return`data:${t};base64,${e}`}async function tt(e,t,n){const r=await fetch(e,t);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);const i=await r.blob();return new Promise((a,o)=>{const c=new FileReader;c.onerror=o,c.onloadend=()=>{try{a(n({res:r,result:c.result}))}catch(l){o(l)}},c.readAsDataURL(i)})}const Me={};function En(e,t,n){let r=e.replace(/\?.*/,"");return n&&(r=e),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),t?`[${t}]${r}`:r}async function Re(e,t,n){const r=En(e,t,n.includeQueryParams);if(Me[r]!=null)return Me[r];n.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let i;try{const a=await tt(e,n.fetchRequestInit,({res:o,result:c})=>(t||(t=o.headers.get("Content-Type")||""),Sn(c)));i=xn(a,t)}catch(a){i=n.imagePlaceholder||"";let o=`Failed to fetch resource: ${e}`;a&&(o=typeof a=="string"?a:a.message),o&&console.warn(o)}return Me[r]=i,i}async function Cn(e){const t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):ue(t)}async function kn(e,t){if(e.currentSrc){const a=document.createElement("canvas"),o=a.getContext("2d");a.width=e.clientWidth,a.height=e.clientHeight,o==null||o.drawImage(e,0,0,a.width,a.height);const c=a.toDataURL();return ue(c)}const n=e.poster,r=Le(n),i=await Re(n,r,t);return ue(i)}async function Ln(e,t){var n;try{if(!((n=e==null?void 0:e.contentDocument)===null||n===void 0)&&n.body)return await de(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function An(e,t){return E(e,HTMLCanvasElement)?Cn(e):E(e,HTMLVideoElement)?kn(e,t):E(e,HTMLIFrameElement)?Ln(e,t):e.cloneNode(nt(e))}const Mn=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",nt=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function Rn(e,t,n){var r,i;if(nt(t))return t;let a=[];return Mn(e)&&e.assignedNodes?a=_(e.assignedNodes()):E(e,HTMLIFrameElement)&&(!((r=e.contentDocument)===null||r===void 0)&&r.body)?a=_(e.contentDocument.body.childNodes):a=_(((i=e.shadowRoot)!==null&&i!==void 0?i:e).childNodes),a.length===0||E(e,HTMLVideoElement)||await a.reduce((o,c)=>o.then(()=>de(c,n)).then(l=>{l&&t.appendChild(l)}),Promise.resolve()),t}function $n(e,t,n){const r=t.style;if(!r)return;const i=window.getComputedStyle(e);i.cssText?(r.cssText=i.cssText,r.transformOrigin=i.transformOrigin):Ge(n).forEach(a=>{let o=i.getPropertyValue(a);a==="font-size"&&o.endsWith("px")&&(o=`${Math.floor(parseFloat(o.substring(0,o.length-2)))-.1}px`),E(e,HTMLIFrameElement)&&a==="display"&&o==="inline"&&(o="block"),a==="d"&&t.getAttribute("d")&&(o=`path(${t.getAttribute("d")})`),r.setProperty(a,o,i.getPropertyPriority(a))})}function Tn(e,t){E(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),E(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function Pn(e,t){if(E(e,HTMLSelectElement)){const r=Array.from(t.children).find(i=>e.value===i.getAttribute("value"));r&&r.setAttribute("selected","")}}function In(e,t,n){return E(t,Element)&&($n(e,t,n),wn(e,t,n),Tn(e,t),Pn(e,t)),t}async function On(e,t){const n=e.querySelectorAll?e.querySelectorAll("use"):[];if(n.length===0)return e;const r={};for(let a=0;a<n.length;a++){const c=n[a].getAttribute("xlink:href");if(c){const l=e.querySelector(c),u=document.querySelector(c);!l&&u&&!r[c]&&(r[c]=await de(u,t,!0))}}const i=Object.values(r);if(i.length){const a="http://www.w3.org/1999/xhtml",o=document.createElementNS(a,"svg");o.setAttribute("xmlns",a),o.style.position="absolute",o.style.width="0",o.style.height="0",o.style.overflow="hidden",o.style.display="none";const c=document.createElementNS(a,"defs");o.appendChild(c);for(let l=0;l<i.length;l++)c.appendChild(i[l]);e.appendChild(o)}return e}async function de(e,t,n){return!n&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(r=>An(r,t)).then(r=>Rn(e,r,t)).then(r=>In(e,r,t)).then(r=>On(r,t))}const rt=/url\((['"]?)([^'"]+?)\1\)/g,Bn=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Dn=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Hn(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function Fn(e){const t=[];return e.replace(rt,(n,r,i)=>(t.push(i),n)),t.filter(n=>!Ae(n))}async function Un(e,t,n,r,i){try{const a=n?sn(t,n):t,o=Le(t);let c;return i||(c=await Re(a,o,r)),e.replace(Hn(t),`$1${c}$3`)}catch{}return e}function Nn(e,{preferredFontFormat:t}){return t?e.replace(Dn,n=>{for(;;){const[r,,i]=Bn.exec(n)||[];if(!i)return"";if(i===t)return`src: ${r};`}}):e}function it(e){return e.search(rt)!==-1}async function at(e,t,n){if(!it(e))return e;const r=Nn(e,n);return Fn(r).reduce((a,o)=>a.then(c=>Un(c,o,t,n)),Promise.resolve(r))}async function Z(e,t,n){var r;const i=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(e);if(i){const a=await at(i,null,n);return t.style.setProperty(e,a,t.style.getPropertyPriority(e)),!0}return!1}async function _n(e,t){await Z("background",e,t)||await Z("background-image",e,t),await Z("mask",e,t)||await Z("-webkit-mask",e,t)||await Z("mask-image",e,t)||await Z("-webkit-mask-image",e,t)}async function jn(e,t){const n=E(e,HTMLImageElement);if(!(n&&!Ae(e.src))&&!(E(e,SVGImageElement)&&!Ae(e.href.baseVal)))return;const r=n?e.src:e.href.baseVal,i=await Re(r,Le(r),t);await new Promise((a,o)=>{e.onload=a,e.onerror=t.onImageErrorHandler?(...l)=>{try{a(t.onImageErrorHandler(...l))}catch(u){o(u)}}:o;const c=e;c.decode&&(c.decode=a),c.loading==="lazy"&&(c.loading="eager"),n?(e.srcset="",e.src=i):e.href.baseVal=i})}async function Vn(e,t){const r=_(e.childNodes).map(i=>ot(i,t));await Promise.all(r).then(()=>e)}async function ot(e,t){E(e,Element)&&(await _n(e,t),await jn(e,t),await Vn(e,t))}function Wn(e,t){const{style:n}=e;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=`${t.width}px`),t.height&&(n.height=`${t.height}px`);const r=t.style;return r!=null&&Object.keys(r).forEach(i=>{n[i]=r[i]}),e}const st={};async function ct(e){let t=st[e];if(t!=null)return t;const r=await(await fetch(e)).text();return t={url:e,cssText:r},st[e]=t,t}async function lt(e,t){let n=e.cssText;const r=/url\(["']?([^"')]+)["']?\)/g,a=(n.match(/url\([^)]+\)/g)||[]).map(async o=>{let c=o.replace(r,"$1");return c.startsWith("https://")||(c=new URL(c,e.url).href),tt(c,t.fetchRequestInit,({result:l})=>(n=n.replace(o,`url(${l})`),[o,l]))});return Promise.all(a).then(()=>n)}function ut(e){if(e==null)return[];const t=[],n=/(\/\*[\s\S]*?\*\/)/gi;let r=e.replace(n,"");const i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const l=i.exec(r);if(l===null)break;t.push(l[0])}r=r.replace(i,"");const a=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",c=new RegExp(o,"gi");for(;;){let l=a.exec(r);if(l===null){if(l=c.exec(r),l===null)break;a.lastIndex=c.lastIndex}else c.lastIndex=a.lastIndex;t.push(l[0])}return t}async function zn(e,t){const n=[],r=[];return e.forEach(i=>{if("cssRules"in i)try{_(i.cssRules||[]).forEach((a,o)=>{if(a.type===CSSRule.IMPORT_RULE){let c=o+1;const l=a.href,u=ct(l).then(f=>lt(f,t)).then(f=>ut(f).forEach(y=>{try{i.insertRule(y,y.startsWith("@import")?c+=1:i.cssRules.length)}catch(g){console.error("Error inserting rule from remote css",{rule:y,error:g})}})).catch(f=>{console.error("Error loading remote css",f.toString())});r.push(u)}})}catch(a){const o=e.find(c=>c.href==null)||document.styleSheets[0];i.href!=null&&r.push(ct(i.href).then(c=>lt(c,t)).then(c=>ut(c).forEach(l=>{o.insertRule(l,o.cssRules.length)})).catch(c=>{console.error("Error loading remote stylesheet",c)})),console.error("Error inlining remote css file",a)}}),Promise.all(r).then(()=>(e.forEach(i=>{if("cssRules"in i)try{_(i.cssRules||[]).forEach(a=>{n.push(a)})}catch(a){console.error(`Error while reading CSS rules from ${i.href}`,a)}}),n))}function Kn(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>it(t.style.getPropertyValue("src")))}async function qn(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const n=_(e.ownerDocument.styleSheets),r=await zn(n,t);return Kn(r)}function dt(e){return e.trim().replace(/["']/g,"")}function Xn(e){const t=new Set;function n(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(a=>{t.add(dt(a))}),Array.from(r.children).forEach(a=>{a instanceof HTMLElement&&n(a)})}return n(e),t}async function Yn(e,t){const n=await qn(e,t),r=Xn(e);return(await Promise.all(n.filter(a=>r.has(dt(a.style.fontFamily))).map(a=>{const o=a.parentStyleSheet?a.parentStyleSheet.href:null;return at(a.cssText,o,t)}))).join(`
2
- `)}async function Gn(e,t){const n=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await Yn(e,t);if(n){const r=document.createElement("style"),i=document.createTextNode(n);r.appendChild(i),e.firstChild?e.insertBefore(r,e.firstChild):e.appendChild(r)}}async function Jn(e,t={}){const{width:n,height:r}=Je(e,t),i=await de(e,t,!0);return await Gn(i,t),await ot(i,t),Wn(i,t),await pn(i,n,r)}async function Qn(e,t={}){const{width:n,height:r}=Je(e,t),i=await Jn(e,t),a=await ue(i),o=document.createElement("canvas"),c=o.getContext("2d"),l=t.pixelRatio||dn(),u=t.canvasWidth||n,f=t.canvasHeight||r;return o.width=u*l,o.height=f*l,t.skipAutoScale||fn(o),o.style.width=`${u}`,o.style.height=`${f}`,t.backgroundColor&&(c.fillStyle=t.backgroundColor,c.fillRect(0,0,o.width,o.height)),c.drawImage(a,0,0,o.width,o.height),o}async function ft(e,t={}){return(await Qn(e,t)).toDataURL()}const fe="data-nf-capture-chrome",Zn="data-nf-canvas-snap",er="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==";function ht(e){return e instanceof Element&&(e.hasAttribute(fe)||e.hasAttribute("data-nf-mask-cover")||e.id==="notefully")}function tr(){const e=[];return Array.from(document.styleSheets).forEach(t=>{try{t.cssRules}catch{try{if(t.disabled)return;t.disabled=!0,e.push(t)}catch{const n=t.ownerNode;n&&"disabled"in n&&!n.disabled&&(n.disabled=!0,e.push({node:n}))}}}),()=>{e.forEach(t=>{try{t&&t.node?t.node.disabled=!1:t&&(t.disabled=!1)}catch{}})}}function nr(){const e=[];return document.querySelectorAll('input[type="password"], [data-notefully-mask]').forEach(n=>{const r=n.getBoundingClientRect(),i=document.createElement("div");i.setAttribute("data-nf-mask-cover","1"),i.style.cssText=["position:fixed",`left:${r.left}px`,`top:${r.top}px`,`width:${Math.max(r.width,4)}px`,`height:${Math.max(r.height,4)}px`,"background:#111","z-index:2147483646","pointer-events:none"].join(";"),document.body.appendChild(i),e.push(i)}),()=>e.forEach(n=>n.remove())}function rr(){const e=document.querySelector(`[${fe}]`);if(e)return e;const t=document.createElement("div");return t.setAttribute(fe,"1"),t.className="nf-capture-chrome",t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.innerHTML='<span class="nf-capture-chrome-pill">Capturing…</span>',document.body.appendChild(t),t}function ir(){document.querySelectorAll(`[${fe}]`).forEach(e=>e.remove())}function $e(){return new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(e))})}function j(e){if(typeof e!="string"||!e.startsWith("data:image/"))return!1;const t=e.indexOf(",");return t>0&&t<e.length-1}function ar(){const e=document.documentElement,t=document.body,n=Math.max(window.innerWidth||0,(e==null?void 0:e.clientWidth)||0,(e==null?void 0:e.scrollWidth)||0,(t==null?void 0:t.scrollWidth)||0,1),r=Math.max(window.innerHeight||0,(e==null?void 0:e.clientHeight)||0,(e==null?void 0:e.scrollHeight)||0,(t==null?void 0:t.scrollHeight)||0,1);return{width:n,height:r}}async function or(){const e=[],t=Array.from(document.querySelectorAll("canvas"));for(const n of t){if(n.closest("#notefully")||ht(n))continue;let r="";try{r=n.toDataURL("image/png")}catch{continue}if(!r||r==="data:,")continue;const i=document.createElement("img"),a=getComputedStyle(n);i.setAttribute(Zn,"1"),i.alt="",i.src=r,i.className=n.className,i.style.cssText=n.style.cssText,i.style.width=a.width,i.style.height=a.height,i.style.maxWidth=a.maxWidth,i.style.maxHeight=a.maxHeight,i.style.objectFit="fill",i.style.display=a.display==="inline"?"inline-block":a.display,n.replaceWith(i),e.push({canvas:n,img:i})}return await Promise.all(e.map(({img:n})=>{if(!n.complete)return new Promise(r=>{n.onload=()=>r(),n.onerror=()=>r()})})),()=>{e.forEach(({canvas:n,img:r})=>{try{r.parentNode&&r.replaceWith(n)}catch{}})}}async function sr(e){if(!e)return null;if(typeof e=="string")return j(e)?e:null;if(typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement)try{const t=e.toDataURL("image/png");return j(t)?t:null}catch{return null}if(typeof Blob<"u"&&e instanceof Blob){const t=await cr(e);return j(t)?t:null}return null}async function cr(e){if(typeof FileReader=="function")return new Promise((r,i)=>{const a=new FileReader;a.onload=()=>r(String(a.result||"")),a.onerror=()=>i(a.error||new Error("Could not read capture blob")),a.readAsDataURL(e)});const t=Buffer.from(await e.arrayBuffer());return`data:${e.type||"application/octet-stream"};base64,${t.toString("base64")}`}async function lr(){var t;if(!((t=navigator.mediaDevices)!=null&&t.getDisplayMedia))throw new Error("Screen capture is not supported in this browser.");const e=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include"});try{const n=document.createElement("video");n.muted=!0,n.playsInline=!0,n.srcObject=e,await n.play(),n.videoWidth||await new Promise(c=>{n.onloadedmetadata=()=>c()}),await $e();const r=n.videoWidth||1,i=n.videoHeight||1,a=document.createElement("canvas");a.width=r,a.height=i,a.getContext("2d").drawImage(n,0,0,r,i);const o=a.toDataURL("image/png");if(!j(o))throw new Error("Screen capture produced an empty image.");return o}finally{e.getTracks().forEach(n=>n.stop())}}async function pt(e={}){const t=document.getElementById("notefully"),n=t?t.style.display:"",r=rr(),i=tr();let a=()=>{};t&&(t.style.display="none");const o=nr();try{if(typeof e.onBeforeCapture=="function"&&await e.onBeforeCapture(),await $e(),typeof e.capture=="function"){const y=await sr(await e.capture());if(y)return y}a=await or(),await $e();const{width:c,height:l}=ar(),u={cacheBust:!0,width:c,height:l,pixelRatio:Math.min(window.devicePixelRatio||1,2),filter:y=>!ht(y),imagePlaceholder:er,onImageErrorHandler:()=>{}};let f="";try{f=await ft(document.body,u)}catch{f=await ft(document.body,{...u,skipFonts:!0})}if(!j(f))throw new Error("Screenshot capture produced an empty image.");return f}finally{try{a()}catch{}o(),i(),r.remove(),ir(),t&&(t.style.display=n)}}function ur(e=""){const t=String(e||"");return t?/Windows NT/i.test(t)?"Windows":/iPhone|iPad|iPod/i.test(t)?"iOS":/Mac OS X|Macintosh/i.test(t)?"macOS":/Android/i.test(t)?"Android":/CrOS/i.test(t)?"ChromeOS":/Linux/i.test(t)?"Linux":"Other":""}function dr(e=""){const t=String(e||"");return t?/Edg\//i.test(t)?"Edge":/OPR\/|Opera/i.test(t)?"Opera":/Firefox\//i.test(t)?"Firefox":/Chrome\//i.test(t)||/CriOS\//i.test(t)?"Chrome":/Safari\//i.test(t)?"Safari":"Other":""}function fr(e={}){const t=navigator.userAgent;return{url:location.href,title:document.title,userAgent:t,os:ur(t),browser:dr(t),language:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,viewport:{width:window.innerWidth,height:window.innerHeight,dpr:window.devicePixelRatio||1},user:{userId:e.userId||null,email:e.email||null,displayName:e.displayName||null}}}const yt=new Set(["userId","email","displayName"]),mt={id:"userId",username:"displayName",name:"displayName"},gt=new Set(["endpoint","projectKey","version","name","targets","hideLauncher","theme","video","consoleLogLimit","kinds","capture","onBeforeCapture","displayLink"]),wt={slug:"Use init({ name }) for a per-app report prefix (same idea as package.json name). slug is not a widget option.",projectSlug:"Use init({ name }) for a per-app report prefix. projectSlug is not a widget option.",project:"Pass projectKey (nfk_…) from Showfully Notefully settings — there is no project option on the widget.",username:"Pass people via Notefully.identify({ displayName }) (username is an identify alias), not init().",userId:"Pass people via Notefully.identify({ userId, email, displayName }), not init().",email:"Pass people via Notefully.identify({ userId, email, displayName }), not init().",displayName:"Pass people via Notefully.identify({ userId, email, displayName }), not init()."};function hr(e={},t={}){const n=t.warn||vt,r=e&&typeof e=="object"?e:{},i={},a=[];for(const o of yt)Object.prototype.hasOwnProperty.call(r,o)&&(i[o]=r[o]);for(const[o,c]of Object.entries(mt))Object.prototype.hasOwnProperty.call(r,o)&&(Object.prototype.hasOwnProperty.call(i,c)||(i[c]=r[o]));for(const o of Object.keys(r))yt.has(o)||Object.prototype.hasOwnProperty.call(mt,o)||a.push(o);if(a.length){const o=a.some(c=>c==="name"||c==="slug"||c==="projectSlug")?" Pass the package/report name via Notefully.init({ name }), not identify().":"";n(`Notefully.identify: ignoring unknown key(s): ${a.join(", ")}. Supported: userId, email, displayName (aliases: id → userId; username/name → displayName).`+o)}return i}function pr(e={},t={}){const n=t.warn||vt,r=e&&typeof e=="object"?e:{},i=Object.keys(r).filter(a=>!gt.has(a));if(i.length)for(const a of i){if(wt[a]){n(`Notefully.init: ignoring "${a}". ${wt[a]}`);continue}n(`Notefully.init: ignoring unknown key "${a}". Supported: ${[...gt].join(", ")}.`)}}function vt(e){typeof console<"u"&&typeof console.warn=="function"&&console.warn(e)}const yr=80;function mr(){const e=[],t={};let n=!1;const r=(a,o)=>{let c="";try{c=o.map(l=>l instanceof Error?l.stack||l.message:typeof l=="string"?l:JSON.stringify(l)).join(" ")}catch{c=String(o[0])}e.push({level:a,text:c.slice(0,2e3),at:Date.now()}),e.length>yr&&e.shift()};return{hook:()=>{n||typeof window>"u"||(n=!0,["log","info","warn","error"].forEach(a=>{t[a]=console[a].bind(console),console[a]=(...o)=>{r(a,o),t[a](...o)}}),window.addEventListener("error",a=>{r("error",[a.message||"window.error"])}),window.addEventListener("unhandledrejection",a=>{r("error",[a.reason||"unhandledrejection"])}))},snapshot(){return e.slice()}}}function gr(e){const t=window.SpeechRecognition||window.webkitSpeechRecognition;let n=null,r=!1;const i=()=>{if(r=!1,n)try{n.stop()}catch{}};return{start:()=>{if(!t)throw new Error("Speech recognition is not supported in this browser.");return r?(i(),!1):(n=new t,n.continuous=!0,n.interimResults=!0,n.lang=navigator.language||"en-US",n.onresult=o=>{let c="";for(let l=o.resultIndex;l<o.results.length;l+=1)o.results[l].isFinal&&(c+=o.results[l][0].transcript);c&&e(c)},n.onerror=()=>{r=!1},n.onend=()=>{r=!1},n.start(),r=!0,!0)},stop:i,isSupported:()=>!!t,isActive:()=>r}}const wr=60*1e3;function vr({onStart:e,onStop:t,onError:n}){let r=null,i=null,a=[],o=null;const c=()=>{if(o&&(clearTimeout(o),o=null),i&&i.state!=="inactive")try{i.stop()}catch{}r&&(r.getTracks().forEach(f=>f.stop()),r=null)},l=()=>{if(i&&i.state==="recording"){i.stop();return}c(),t(null)};return{start:async()=>{var f,y;if(!((f=navigator.mediaDevices)!=null&&f.getDisplayMedia))throw new Error("Screen recording is not supported in this browser.");r=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include"}),a=[],i=new MediaRecorder(r,{mimeType:MediaRecorder.isTypeSupported("video/webm;codecs=vp9")?"video/webm;codecs=vp9":"video/webm"}),i.ondataavailable=g=>{g.data&&g.data.size&&a.push(g.data)},i.onstop=()=>{const g=a.length?new Blob(a,{type:i.mimeType||"video/webm"}):null;c(),t(g)},(y=r.getVideoTracks()[0])==null||y.addEventListener("ended",()=>l()),i.start(),o=setTimeout(l,wr)},stop:l}}function br(){const e=new Set;return{alloc(){let t=1;for(;e.has(t);)t+=1;return e.add(t),t},free(t){const n=Number(t);Number.isInteger(n)&&n>0&&e.delete(n)},peekUsed(){return[...e].sort((t,n)=>t-n)}}}const Te={x:0,y:0,w:1,h:1};function Pe(){const e=br();let t=[],n={...Te},r=1;return{list:()=>t.filter(a=>xr(a,n)),all:()=>t.slice(),crop:()=>({...n}),setCrop(a){return n=Sr(a),n},resetCrop(){return n={...Te},n},isCropped(){return n.x>1e-6||n.y>1e-6||n.w<.999999||n.h<.999999},add(a,o){const c={id:`s${r++}`,type:a,number:e.alloc(),x:.2,y:.2,w:a==="arrow"?.2:.22,h:a==="arrow"?.05:.16,x2:.4,y2:.28,...o};return t.push(c),c},update(a,o){const c=t.find(l=>l.id===a);return c?(Object.assign(c,o),c):null},remove(a){const o=t.findIndex(l=>l.id===a);if(o<0)return null;const[c]=t.splice(o,1);return e.free(c.number),c},reset(){for(t=[],n={...Te},r=1;e.peekUsed().length;)e.free(e.peekUsed()[0])}}}function Sr(e){const t=Math.min(Math.max(e.x,0),.95),n=Math.min(Math.max(e.y,0),.95),r=Math.min(Math.max(e.w,.05),1-t),i=Math.min(Math.max(e.h,.05),1-n);return{x:t,y:n,w:r,h:i}}function xr(e,t){const n=e.type==="arrow"?(e.x+(e.x2??e.x))/2:e.x+(e.w||0)/2,r=e.type==="arrow"?(e.y+(e.y2??e.y))/2:e.y+(e.h||0)/2;return n>=t.x&&r>=t.y&&n<=t.x+t.w&&r<=t.y+t.h}function Ie(e){const t=Math.max(1,Number(e)||1);return{stroke:Math.max(2,t*.0075),badgeRadius:Math.max(8,t*.025),fontSize:Math.max(10,t*.0275),arrowHead:Math.max(8,t*.035),arrowHeadAngle:.4}}function Er(e,{stickers:t=[],crop:n={x:0,y:0,w:1,h:1},width:r,height:i,colors:a={}}){const o=a.mark||"#fdd341",c=a.markText||"#2a2140",l=Ie(r);e.save(),e.lineWidth=l.stroke,e.lineCap="round",e.lineJoin="round",e.strokeStyle=o,e.fillStyle=o,e.font=`700 ${Math.round(l.fontSize)}px ui-sans-serif, system-ui, sans-serif`,t.forEach(u=>{const f=Oe(u.x,n,r),y=Be(u.y,n,i),g=u.w/n.w*r,w=u.h/n.h*i,x=l.stroke/2;if(u.type==="rect")e.strokeRect(f+x,y+x,Math.max(0,g-l.stroke),Math.max(0,w-l.stroke));else if(u.type==="circle")e.beginPath(),e.ellipse(f+g/2,y+w/2,Math.max(.5,g/2-x),Math.max(.5,w/2-x),0,0,Math.PI*2),e.stroke();else if(u.type==="arrow"){const $=Oe(u.x2??u.x+u.w,n,r),N=Be(u.y2??u.y,n,i);kr(e,f,y,$,N,l)}if(u.number==null||u.number==="")return;const L=Cr(u,n,r,i,f,y,g),H=String(u.number);e.beginPath(),e.arc(L.x,L.y,l.badgeRadius,0,Math.PI*2),e.fillStyle=o,e.fill(),e.fillStyle=c,e.textAlign="center",e.textBaseline="middle",e.fillText(H,L.x,L.y+.5),e.fillStyle=o}),e.restore()}function Oe(e,t,n){return(e-t.x)/t.w*n}function Be(e,t,n){return(e-t.y)/t.h*n}function Cr(e,t,n,r,i,a,o){if(e.type==="arrow"){const c=Oe(e.x2??e.x+e.w,t,n),l=Be(e.y2??e.y,t,r);return{x:(i+c)/2,y:(a+l)/2}}return{x:i+o/2,y:a}}function bt(e,t,n,r,i){const a=Math.atan2(r-t,n-e),o=i.arrowHead,c=Math.min(i.stroke,o*.2),l=n,u=r,f=n-Math.cos(a)*o,y=r-Math.sin(a)*o,g={x:l-o*Math.cos(a-i.arrowHeadAngle),y:u-o*Math.sin(a-i.arrowHeadAngle)},w={x:l-o*Math.cos(a+i.arrowHeadAngle),y:u-o*Math.sin(a+i.arrowHeadAngle)},x={x:n-Math.cos(a)*c,y:r-Math.sin(a)*c};return{angle:a,tipX:l,tipY:u,baseX:f,baseY:y,left:g,right:w,shaftEnd:x}}function kr(e,t,n,r,i,a){const o=bt(t,n,r,i,a);e.beginPath(),e.moveTo(t,n),e.lineTo(o.shaftEnd.x,o.shaftEnd.y),e.stroke(),e.beginPath(),e.moveTo(o.tipX,o.tipY),e.lineTo(o.left.x,o.left.y),e.lineTo(o.right.x,o.right.y),e.closePath(),e.fill()}function Lr(e,t,n,r={}){return new Promise((i,a)=>{const o=new Image;o.onload=()=>{const c=Math.round(t.x*o.width),l=Math.round(t.y*o.height),u=Math.max(1,Math.round(t.w*o.width)),f=Math.max(1,Math.round(t.h*o.height)),y=document.createElement("canvas");y.width=u,y.height=f;const g=y.getContext("2d");g.drawImage(o,c,l,u,f,0,0,u,f),Er(g,{stickers:n,crop:t,width:u,height:f,colors:r}),y.toBlob(w=>{if(!w){a(new Error("Could not encode screenshot"));return}i(w)},"image/png")},o.onerror=()=>a(new Error("Could not load screenshot")),o.src=e})}const Ar=[{key:"url",label:"URL"},{key:"title",label:"Title"},{key:"userAgent",label:"User agent"},{key:"os",label:"OS"},{key:"browser",label:"Browser"},{key:"language",label:"Language"},{key:"timezone",label:"Timezone"},{key:"viewport",label:"Viewport"},{key:"user",label:"User"}];function Mr(e){return!e||typeof e!="object"?!1:!!(e.userId||e.email||e.displayName)}function Rr(e={}){const t=[];for(const n of Ar){const r=e[n.key];r==null||r===""||n.key==="user"&&!Mr(r)||t.push({key:n.key,label:n.label,value:r,redacted:!1})}return t}function $r(e=[]){return e.map((t,n)=>({id:`log-${n}-${t.at||0}`,level:t.level||"log",text:String(t.text||""),at:t.at||0,redacted:!1}))}function Tr(e=[]){if(!e.length)return{checked:!1,indeterminate:!1};const t=e.filter(n=>n.redacted).length;return t===0?{checked:!1,indeterminate:!1}:t===e.length?{checked:!0,indeterminate:!1}:{checked:!1,indeterminate:!0}}function he(e,t){e.forEach(n=>{n.redacted=!!t})}function Pr(e={}){const t=e.diagnostics||[],n=e.logs||[],r=t.some(a=>!a.redacted),i=n.length>0&&n.some(a=>!a.redacted);return r&&i?"Also sending logs and diagnostic information":r?"Also sending diagnostic information":i?"Also sending logs":""}function Ir(e){if(e==null)return"";if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function Or(e={}){const t={};e.author!=null&&e.author!==""&&(t.author=e.author);for(const r of e.diagnostics||[])r.redacted||(t[r.key]=r.value);const n=(e.logs||[]).filter(r=>!r.redacted).map(r=>({level:r.level,text:r.text,at:r.at}));return t.console=n,t}const V=[{id:"bug",label:"Bug"},{id:"idea",label:"Idea"},{id:"other",label:"Other"}];function St(e){return String(e||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32)}function De(e){const t=String(e||"").trim();return t?t.split(/[-_\s]+/).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" "):""}function Br(e){if(!Array.isArray(e)||!e.length)return V.map(r=>({...r}));const t=new Set,n=[];for(const r of e){let i="",a="";typeof r=="string"||typeof r=="number"?(i=St(r),a=De(i)):r&&typeof r=="object"&&(i=St(r.id??r.value??r.kind),a=String(r.label||r.name||De(i)).trim()||De(i)),!(!i||t.has(i))&&(t.add(i),n.push({id:i,label:a}))}return n.length?n:V.map(r=>({...r}))}function pe(e){var n;const t=Array.isArray(e)&&e.length?e:V;return t.some(r=>r.id==="bug")?"bug":((n=t[0])==null?void 0:n.id)||"other"}const Dr=["maker","all-business","brighter-day","quiet-night"],xt="maker",Hr=new Set(["crop","arrow","rect","circle"]),He=.02,Et=.05,Fr=`
1
+ var Notefully=(function(C){"use strict";function dn(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const n=document.implementation.createHTMLDocument(),r=n.createElement("base"),a=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(a),t&&(r.href=t),a.href=e,a.href}const fn=(()=>{let e=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function _(e){const t=[];for(let n=0,r=e.length;n<r;n++)t.push(e[n]);return t}let Q=null;function Je(e={}){return Q||(e.includeStyleProperties?(Q=e.includeStyleProperties,Q):(Q=_(window.getComputedStyle(document.documentElement)),Q))}function ue(e,t){const r=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}function hn(e){const t=ue(e,"border-left-width"),n=ue(e,"border-right-width");return e.clientWidth+t+n}function pn(e){const t=ue(e,"border-top-width"),n=ue(e,"border-bottom-width");return e.clientHeight+t+n}function Qe(e,t={}){const n=t.width||hn(e),r=t.height||pn(e);return{width:n,height:r}}function yn(){let e,t;try{t=process}catch{}const n=t&&t.env?t.env.devicePixelRatio:null;return n&&(e=parseInt(n,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}const A=16384;function mn(e){(e.width>A||e.height>A)&&(e.width>A&&e.height>A?e.width>e.height?(e.height*=A/e.width,e.width=A):(e.width*=A/e.height,e.height=A):e.width>A?(e.height*=A/e.width,e.width=A):(e.width*=A/e.height,e.height=A))}function de(e){return new Promise((t,n)=>{const r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=n,r.crossOrigin="anonymous",r.decoding="async",r.src=e})}async function gn(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function wn(e,t,n){const r="http://www.w3.org/2000/svg",a=document.createElementNS(r,"svg"),i=document.createElementNS(r,"foreignObject");return a.setAttribute("width",`${t}`),a.setAttribute("height",`${n}`),a.setAttribute("viewBox",`0 0 ${t} ${n}`),i.setAttribute("width","100%"),i.setAttribute("height","100%"),i.setAttribute("x","0"),i.setAttribute("y","0"),i.setAttribute("externalResourcesRequired","true"),a.appendChild(i),i.appendChild(e),gn(a)}const E=(e,t)=>{if(e instanceof t)return!0;const n=Object.getPrototypeOf(e);return n===null?!1:n.constructor.name===t.name||E(n,t)};function vn(e){const t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function bn(e,t){return Je(t).map(n=>{const r=e.getPropertyValue(n),a=e.getPropertyPriority(n);return`${n}: ${r}${a?" !important":""};`}).join(" ")}function Sn(e,t,n,r){const a=`.${e}:${t}`,i=n.cssText?vn(n):bn(n,r);return document.createTextNode(`${a}{${i}}`)}function Ze(e,t,n,r){const a=window.getComputedStyle(e,n),i=a.getPropertyValue("content");if(i===""||i==="none")return;const o=fn();try{t.className=`${t.className} ${o}`}catch{return}const c=document.createElement("style");c.appendChild(Sn(o,n,a,r)),t.appendChild(c)}function xn(e,t,n){Ze(e,t,":before",n),Ze(e,t,":after",n)}const et="application/font-woff",tt="image/jpeg",En={woff:et,woff2:et,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:tt,jpeg:tt,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function Cn(e){const t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function ke(e){const t=Cn(e).toLowerCase();return En[t]||""}function An(e){return e.split(/,/)[1]}function Me(e){return e.search(/^(data:)/)!==-1}function Ln(e,t){return`data:${t};base64,${e}`}async function nt(e,t,n){const r=await fetch(e,t);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);const a=await r.blob();return new Promise((i,o)=>{const c=new FileReader;c.onerror=o,c.onloadend=()=>{try{i(n({res:r,result:c.result}))}catch(l){o(l)}},c.readAsDataURL(a)})}const $e={};function kn(e,t,n){let r=e.replace(/\?.*/,"");return n&&(r=e),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),t?`[${t}]${r}`:r}async function Re(e,t,n){const r=kn(e,t,n.includeQueryParams);if($e[r]!=null)return $e[r];n.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let a;try{const i=await nt(e,n.fetchRequestInit,({res:o,result:c})=>(t||(t=o.headers.get("Content-Type")||""),An(c)));a=Ln(i,t)}catch(i){a=n.imagePlaceholder||"";let o=`Failed to fetch resource: ${e}`;i&&(o=typeof i=="string"?i:i.message),o&&console.warn(o)}return $e[r]=a,a}async function Mn(e){const t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):de(t)}async function $n(e,t){if(e.currentSrc){const i=document.createElement("canvas"),o=i.getContext("2d");i.width=e.clientWidth,i.height=e.clientHeight,o==null||o.drawImage(e,0,0,i.width,i.height);const c=i.toDataURL();return de(c)}const n=e.poster,r=ke(n),a=await Re(n,r,t);return de(a)}async function Rn(e,t){var n;try{if(!((n=e==null?void 0:e.contentDocument)===null||n===void 0)&&n.body)return await fe(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function Tn(e,t){return E(e,HTMLCanvasElement)?Mn(e):E(e,HTMLVideoElement)?$n(e,t):E(e,HTMLIFrameElement)?Rn(e,t):e.cloneNode(rt(e))}const Pn=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",rt=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function In(e,t,n){var r,a;if(rt(t))return t;let i=[];return Pn(e)&&e.assignedNodes?i=_(e.assignedNodes()):E(e,HTMLIFrameElement)&&(!((r=e.contentDocument)===null||r===void 0)&&r.body)?i=_(e.contentDocument.body.childNodes):i=_(((a=e.shadowRoot)!==null&&a!==void 0?a:e).childNodes),i.length===0||E(e,HTMLVideoElement)||await i.reduce((o,c)=>o.then(()=>fe(c,n)).then(l=>{l&&t.appendChild(l)}),Promise.resolve()),t}function On(e,t,n){const r=t.style;if(!r)return;const a=window.getComputedStyle(e);a.cssText?(r.cssText=a.cssText,r.transformOrigin=a.transformOrigin):Je(n).forEach(i=>{let o=a.getPropertyValue(i);i==="font-size"&&o.endsWith("px")&&(o=`${Math.floor(parseFloat(o.substring(0,o.length-2)))-.1}px`),E(e,HTMLIFrameElement)&&i==="display"&&o==="inline"&&(o="block"),i==="d"&&t.getAttribute("d")&&(o=`path(${t.getAttribute("d")})`),r.setProperty(i,o,a.getPropertyPriority(i))})}function Bn(e,t){E(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),E(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function Dn(e,t){if(E(e,HTMLSelectElement)){const r=Array.from(t.children).find(a=>e.value===a.getAttribute("value"));r&&r.setAttribute("selected","")}}function Hn(e,t,n){return E(t,Element)&&(On(e,t,n),xn(e,t,n),Bn(e,t),Dn(e,t)),t}async function Fn(e,t){const n=e.querySelectorAll?e.querySelectorAll("use"):[];if(n.length===0)return e;const r={};for(let i=0;i<n.length;i++){const c=n[i].getAttribute("xlink:href");if(c){const l=e.querySelector(c),u=document.querySelector(c);!l&&u&&!r[c]&&(r[c]=await fe(u,t,!0))}}const a=Object.values(r);if(a.length){const i="http://www.w3.org/1999/xhtml",o=document.createElementNS(i,"svg");o.setAttribute("xmlns",i),o.style.position="absolute",o.style.width="0",o.style.height="0",o.style.overflow="hidden",o.style.display="none";const c=document.createElementNS(i,"defs");o.appendChild(c);for(let l=0;l<a.length;l++)c.appendChild(a[l]);e.appendChild(o)}return e}async function fe(e,t,n){return!n&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(r=>Tn(r,t)).then(r=>In(e,r,t)).then(r=>Hn(e,r,t)).then(r=>Fn(r,t))}const it=/url\((['"]?)([^'"]+?)\1\)/g,Nn=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Un=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function _n(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function jn(e){const t=[];return e.replace(it,(n,r,a)=>(t.push(a),n)),t.filter(n=>!Me(n))}async function Vn(e,t,n,r,a){try{const i=n?dn(t,n):t,o=ke(t);let c;return a||(c=await Re(i,o,r)),e.replace(_n(t),`$1${c}$3`)}catch{}return e}function zn(e,{preferredFontFormat:t}){return t?e.replace(Un,n=>{for(;;){const[r,,a]=Nn.exec(n)||[];if(!a)return"";if(a===t)return`src: ${r};`}}):e}function at(e){return e.search(it)!==-1}async function ot(e,t,n){if(!at(e))return e;const r=zn(e,n);return jn(r).reduce((i,o)=>i.then(c=>Vn(c,o,t,n)),Promise.resolve(r))}async function Z(e,t,n){var r;const a=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(e);if(a){const i=await ot(a,null,n);return t.style.setProperty(e,i,t.style.getPropertyPriority(e)),!0}return!1}async function Wn(e,t){await Z("background",e,t)||await Z("background-image",e,t),await Z("mask",e,t)||await Z("-webkit-mask",e,t)||await Z("mask-image",e,t)||await Z("-webkit-mask-image",e,t)}async function Kn(e,t){const n=E(e,HTMLImageElement);if(!(n&&!Me(e.src))&&!(E(e,SVGImageElement)&&!Me(e.href.baseVal)))return;const r=n?e.src:e.href.baseVal,a=await Re(r,ke(r),t);await new Promise((i,o)=>{e.onload=i,e.onerror=t.onImageErrorHandler?(...l)=>{try{i(t.onImageErrorHandler(...l))}catch(u){o(u)}}:o;const c=e;c.decode&&(c.decode=i),c.loading==="lazy"&&(c.loading="eager"),n?(e.srcset="",e.src=a):e.href.baseVal=a})}async function qn(e,t){const r=_(e.childNodes).map(a=>st(a,t));await Promise.all(r).then(()=>e)}async function st(e,t){E(e,Element)&&(await Wn(e,t),await Kn(e,t),await qn(e,t))}function Xn(e,t){const{style:n}=e;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=`${t.width}px`),t.height&&(n.height=`${t.height}px`);const r=t.style;return r!=null&&Object.keys(r).forEach(a=>{n[a]=r[a]}),e}const ct={};async function lt(e){let t=ct[e];if(t!=null)return t;const r=await(await fetch(e)).text();return t={url:e,cssText:r},ct[e]=t,t}async function ut(e,t){let n=e.cssText;const r=/url\(["']?([^"')]+)["']?\)/g,i=(n.match(/url\([^)]+\)/g)||[]).map(async o=>{let c=o.replace(r,"$1");return c.startsWith("https://")||(c=new URL(c,e.url).href),nt(c,t.fetchRequestInit,({result:l})=>(n=n.replace(o,`url(${l})`),[o,l]))});return Promise.all(i).then(()=>n)}function dt(e){if(e==null)return[];const t=[],n=/(\/\*[\s\S]*?\*\/)/gi;let r=e.replace(n,"");const a=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const l=a.exec(r);if(l===null)break;t.push(l[0])}r=r.replace(a,"");const i=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",c=new RegExp(o,"gi");for(;;){let l=i.exec(r);if(l===null){if(l=c.exec(r),l===null)break;i.lastIndex=c.lastIndex}else c.lastIndex=i.lastIndex;t.push(l[0])}return t}async function Yn(e,t){const n=[],r=[];return e.forEach(a=>{if("cssRules"in a)try{_(a.cssRules||[]).forEach((i,o)=>{if(i.type===CSSRule.IMPORT_RULE){let c=o+1;const l=i.href,u=lt(l).then(f=>ut(f,t)).then(f=>dt(f).forEach(y=>{try{a.insertRule(y,y.startsWith("@import")?c+=1:a.cssRules.length)}catch(g){console.error("Error inserting rule from remote css",{rule:y,error:g})}})).catch(f=>{console.error("Error loading remote css",f.toString())});r.push(u)}})}catch(i){const o=e.find(c=>c.href==null)||document.styleSheets[0];a.href!=null&&r.push(lt(a.href).then(c=>ut(c,t)).then(c=>dt(c).forEach(l=>{o.insertRule(l,o.cssRules.length)})).catch(c=>{console.error("Error loading remote stylesheet",c)})),console.error("Error inlining remote css file",i)}}),Promise.all(r).then(()=>(e.forEach(a=>{if("cssRules"in a)try{_(a.cssRules||[]).forEach(i=>{n.push(i)})}catch(i){console.error(`Error while reading CSS rules from ${a.href}`,i)}}),n))}function Gn(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>at(t.style.getPropertyValue("src")))}async function Jn(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const n=_(e.ownerDocument.styleSheets),r=await Yn(n,t);return Gn(r)}function ft(e){return e.trim().replace(/["']/g,"")}function Qn(e){const t=new Set;function n(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(i=>{t.add(ft(i))}),Array.from(r.children).forEach(i=>{i instanceof HTMLElement&&n(i)})}return n(e),t}async function Zn(e,t){const n=await Jn(e,t),r=Qn(e);return(await Promise.all(n.filter(i=>r.has(ft(i.style.fontFamily))).map(i=>{const o=i.parentStyleSheet?i.parentStyleSheet.href:null;return ot(i.cssText,o,t)}))).join(`
2
+ `)}async function er(e,t){const n=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await Zn(e,t);if(n){const r=document.createElement("style"),a=document.createTextNode(n);r.appendChild(a),e.firstChild?e.insertBefore(r,e.firstChild):e.appendChild(r)}}async function tr(e,t={}){const{width:n,height:r}=Qe(e,t),a=await fe(e,t,!0);return await er(a,t),await st(a,t),Xn(a,t),await wn(a,n,r)}async function nr(e,t={}){const{width:n,height:r}=Qe(e,t),a=await tr(e,t),i=await de(a),o=document.createElement("canvas"),c=o.getContext("2d"),l=t.pixelRatio||yn(),u=t.canvasWidth||n,f=t.canvasHeight||r;return o.width=u*l,o.height=f*l,t.skipAutoScale||mn(o),o.style.width=`${u}`,o.style.height=`${f}`,t.backgroundColor&&(c.fillStyle=t.backgroundColor,c.fillRect(0,0,o.width,o.height)),c.drawImage(i,0,0,o.width,o.height),o}async function ht(e,t={}){return(await nr(e,t)).toDataURL()}const he="data-nf-capture-chrome",rr="data-nf-canvas-snap",ir="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==";function pt(e){return e instanceof Element&&(e.hasAttribute(he)||e.hasAttribute("data-nf-mask-cover")||e.id==="notefully")}function ar(){const e=[];return Array.from(document.styleSheets).forEach(t=>{try{t.cssRules}catch{try{if(t.disabled)return;t.disabled=!0,e.push(t)}catch{const n=t.ownerNode;n&&"disabled"in n&&!n.disabled&&(n.disabled=!0,e.push({node:n}))}}}),()=>{e.forEach(t=>{try{t&&t.node?t.node.disabled=!1:t&&(t.disabled=!1)}catch{}})}}function or(){const e=[];return document.querySelectorAll('input[type="password"], [data-notefully-mask]').forEach(n=>{const r=n.getBoundingClientRect(),a=document.createElement("div");a.setAttribute("data-nf-mask-cover","1"),a.style.cssText=["position:fixed",`left:${r.left}px`,`top:${r.top}px`,`width:${Math.max(r.width,4)}px`,`height:${Math.max(r.height,4)}px`,"background:#111","z-index:2147483646","pointer-events:none"].join(";"),document.body.appendChild(a),e.push(a)}),()=>e.forEach(n=>n.remove())}function sr(){const e=document.querySelector(`[${he}]`);if(e)return e;const t=document.createElement("div");return t.setAttribute(he,"1"),t.className="nf-capture-chrome",t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.innerHTML='<span class="nf-capture-chrome-pill">Capturing…</span>',document.body.appendChild(t),t}function cr(){document.querySelectorAll(`[${he}]`).forEach(e=>e.remove())}function Te(){return new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(e))})}function j(e){if(typeof e!="string"||!e.startsWith("data:image/"))return!1;const t=e.indexOf(",");return t>0&&t<e.length-1}function lr(){const e=document.documentElement,t=document.body,n=Math.max(window.innerWidth||0,(e==null?void 0:e.clientWidth)||0,(e==null?void 0:e.scrollWidth)||0,(t==null?void 0:t.scrollWidth)||0,1),r=Math.max(window.innerHeight||0,(e==null?void 0:e.clientHeight)||0,(e==null?void 0:e.scrollHeight)||0,(t==null?void 0:t.scrollHeight)||0,1);return{width:n,height:r}}async function ur(){const e=[],t=Array.from(document.querySelectorAll("canvas"));for(const n of t){if(n.closest("#notefully")||pt(n))continue;let r="";try{r=n.toDataURL("image/png")}catch{continue}if(!r||r==="data:,")continue;const a=document.createElement("img"),i=getComputedStyle(n);a.setAttribute(rr,"1"),a.alt="",a.src=r,a.className=n.className,a.style.cssText=n.style.cssText,a.style.width=i.width,a.style.height=i.height,a.style.maxWidth=i.maxWidth,a.style.maxHeight=i.maxHeight,a.style.objectFit="fill",a.style.display=i.display==="inline"?"inline-block":i.display,n.replaceWith(a),e.push({canvas:n,img:a})}return await Promise.all(e.map(({img:n})=>{if(!n.complete)return new Promise(r=>{n.onload=()=>r(),n.onerror=()=>r()})})),()=>{e.forEach(({canvas:n,img:r})=>{try{r.parentNode&&r.replaceWith(n)}catch{}})}}async function dr(e){if(!e)return null;if(typeof e=="string")return j(e)?e:null;if(typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement)try{const t=e.toDataURL("image/png");return j(t)?t:null}catch{return null}if(typeof Blob<"u"&&e instanceof Blob){const t=await fr(e);return j(t)?t:null}return null}async function fr(e){if(typeof FileReader=="function")return new Promise((r,a)=>{const i=new FileReader;i.onload=()=>r(String(i.result||"")),i.onerror=()=>a(i.error||new Error("Could not read capture blob")),i.readAsDataURL(e)});const t=Buffer.from(await e.arrayBuffer());return`data:${e.type||"application/octet-stream"};base64,${t.toString("base64")}`}async function hr(){var t;if(!((t=navigator.mediaDevices)!=null&&t.getDisplayMedia))throw new Error("Screen capture is not supported in this browser.");const e=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include"});try{const n=document.createElement("video");n.muted=!0,n.playsInline=!0,n.srcObject=e,await n.play(),n.videoWidth||await new Promise(c=>{n.onloadedmetadata=()=>c()}),await Te();const r=n.videoWidth||1,a=n.videoHeight||1,i=document.createElement("canvas");i.width=r,i.height=a,i.getContext("2d").drawImage(n,0,0,r,a);const o=i.toDataURL("image/png");if(!j(o))throw new Error("Screen capture produced an empty image.");return o}finally{e.getTracks().forEach(n=>n.stop())}}async function yt(e={}){const t=document.getElementById("notefully"),n=t?t.style.display:"",r=sr(),a=ar();let i=()=>{};t&&(t.style.display="none");const o=or();try{if(typeof e.onBeforeCapture=="function"&&await e.onBeforeCapture(),await Te(),typeof e.capture=="function"){const y=await dr(await e.capture());if(y)return y}i=await ur(),await Te();const{width:c,height:l}=lr(),u={cacheBust:!0,width:c,height:l,pixelRatio:Math.min(window.devicePixelRatio||1,2),filter:y=>!pt(y),imagePlaceholder:ir,onImageErrorHandler:()=>{}};let f="";try{f=await ht(document.body,u)}catch{f=await ht(document.body,{...u,skipFonts:!0})}if(!j(f))throw new Error("Screenshot capture produced an empty image.");return f}finally{try{i()}catch{}o(),a(),r.remove(),cr(),t&&(t.style.display=n)}}function pr(e=""){const t=String(e||"");return t?/Windows NT/i.test(t)?"Windows":/iPhone|iPad|iPod/i.test(t)?"iOS":/Mac OS X|Macintosh/i.test(t)?"macOS":/Android/i.test(t)?"Android":/CrOS/i.test(t)?"ChromeOS":/Linux/i.test(t)?"Linux":"Other":""}function yr(e=""){const t=String(e||"");return t?/Edg\//i.test(t)?"Edge":/OPR\/|Opera/i.test(t)?"Opera":/Firefox\//i.test(t)?"Firefox":/Chrome\//i.test(t)||/CriOS\//i.test(t)?"Chrome":/Safari\//i.test(t)?"Safari":"Other":""}function mr(e={}){const t=navigator.userAgent;return{url:location.href,title:document.title,userAgent:t,os:pr(t),browser:yr(t),language:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,viewport:{width:window.innerWidth,height:window.innerHeight,dpr:window.devicePixelRatio||1},user:{userId:e.userId||null,email:e.email||null,displayName:e.displayName||null}}}const mt=new Set(["userId","email","displayName"]),gt={id:"userId",username:"displayName",name:"displayName"},wt=new Set(["endpoint","projectKey","version","name","targets","hideLauncher","theme","video","consoleLogLimit","kinds","capture","onBeforeCapture","onOpen","onClose","displayLink"]),vt={slug:"Use init({ name }) for a per-app report prefix (same idea as package.json name). slug is not a widget option.",projectSlug:"Use init({ name }) for a per-app report prefix. projectSlug is not a widget option.",project:"Pass projectKey (nfk_…) from Showfully Notefully settings — there is no project option on the widget.",username:"Pass people via Notefully.identify({ displayName }) (username is an identify alias), not init().",userId:"Pass people via Notefully.identify({ userId, email, displayName }), not init().",email:"Pass people via Notefully.identify({ userId, email, displayName }), not init().",displayName:"Pass people via Notefully.identify({ userId, email, displayName }), not init()."};function gr(e={},t={}){const n=t.warn||bt,r=e&&typeof e=="object"?e:{},a={},i=[];for(const o of mt)Object.prototype.hasOwnProperty.call(r,o)&&(a[o]=r[o]);for(const[o,c]of Object.entries(gt))Object.prototype.hasOwnProperty.call(r,o)&&(Object.prototype.hasOwnProperty.call(a,c)||(a[c]=r[o]));for(const o of Object.keys(r))mt.has(o)||Object.prototype.hasOwnProperty.call(gt,o)||i.push(o);if(i.length){const o=i.some(c=>c==="name"||c==="slug"||c==="projectSlug")?" Pass the package/report name via Notefully.init({ name }), not identify().":"";n(`Notefully.identify: ignoring unknown key(s): ${i.join(", ")}. Supported: userId, email, displayName (aliases: id → userId; username/name → displayName).`+o)}return a}function wr(e={},t={}){const n=t.warn||bt,r=e&&typeof e=="object"?e:{},a=Object.keys(r).filter(i=>!wt.has(i));if(a.length)for(const i of a){if(vt[i]){n(`Notefully.init: ignoring "${i}". ${vt[i]}`);continue}n(`Notefully.init: ignoring unknown key "${i}". Supported: ${[...wt].join(", ")}.`)}}function bt(e){typeof console<"u"&&typeof console.warn=="function"&&console.warn(e)}const vr=80;function br(){const e=[],t={};let n=!1;const r=(i,o)=>{let c="";try{c=o.map(l=>l instanceof Error?l.stack||l.message:typeof l=="string"?l:JSON.stringify(l)).join(" ")}catch{c=String(o[0])}e.push({level:i,text:c.slice(0,2e3),at:Date.now()}),e.length>vr&&e.shift()};return{hook:()=>{n||typeof window>"u"||(n=!0,["log","info","warn","error"].forEach(i=>{t[i]=console[i].bind(console),console[i]=(...o)=>{r(i,o),t[i](...o)}}),window.addEventListener("error",i=>{r("error",[i.message||"window.error"])}),window.addEventListener("unhandledrejection",i=>{r("error",[i.reason||"unhandledrejection"])}))},snapshot(){return e.slice()}}}function Sr(e){const t=window.SpeechRecognition||window.webkitSpeechRecognition;let n=null,r=!1;const a=()=>{if(r=!1,n)try{n.stop()}catch{}};return{start:()=>{if(!t)throw new Error("Speech recognition is not supported in this browser.");return r?(a(),!1):(n=new t,n.continuous=!0,n.interimResults=!0,n.lang=navigator.language||"en-US",n.onresult=o=>{let c="";for(let l=o.resultIndex;l<o.results.length;l+=1)o.results[l].isFinal&&(c+=o.results[l][0].transcript);c&&e(c)},n.onerror=()=>{r=!1},n.onend=()=>{r=!1},n.start(),r=!0,!0)},stop:a,isSupported:()=>!!t,isActive:()=>r}}const xr=60*1e3;function Er({onStart:e,onStop:t,onError:n}){let r=null,a=null,i=[],o=null;const c=()=>{if(o&&(clearTimeout(o),o=null),a&&a.state!=="inactive")try{a.stop()}catch{}r&&(r.getTracks().forEach(f=>f.stop()),r=null)},l=()=>{if(a&&a.state==="recording"){a.stop();return}c(),t(null)};return{start:async()=>{var f,y;if(!((f=navigator.mediaDevices)!=null&&f.getDisplayMedia))throw new Error("Screen recording is not supported in this browser.");r=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include"}),i=[],a=new MediaRecorder(r,{mimeType:MediaRecorder.isTypeSupported("video/webm;codecs=vp9")?"video/webm;codecs=vp9":"video/webm"}),a.ondataavailable=g=>{g.data&&g.data.size&&i.push(g.data)},a.onstop=()=>{const g=i.length?new Blob(i,{type:a.mimeType||"video/webm"}):null;c(),t(g)},(y=r.getVideoTracks()[0])==null||y.addEventListener("ended",()=>l()),a.start(),o=setTimeout(l,xr)},stop:l}}function Cr(){const e=new Set;return{alloc(){let t=1;for(;e.has(t);)t+=1;return e.add(t),t},free(t){const n=Number(t);Number.isInteger(n)&&n>0&&e.delete(n)},peekUsed(){return[...e].sort((t,n)=>t-n)}}}const Pe={x:0,y:0,w:1,h:1};function Ie(){const e=Cr();let t=[],n={...Pe},r=1;return{list:()=>t.filter(i=>kr(i,n)),all:()=>t.slice(),crop:()=>({...n}),setCrop(i){return n=Lr(i),n},resetCrop(){return n={...Pe},n},isCropped(){return n.x>1e-6||n.y>1e-6||n.w<.999999||n.h<.999999},add(i,o){const c={id:`s${r++}`,type:i,number:e.alloc(),x:.2,y:.2,w:i==="arrow"?.2:.22,h:i==="arrow"?.05:.16,x2:.4,y2:.28,...o};return t.push(c),c},update(i,o){const c=t.find(l=>l.id===i);return c?(Object.assign(c,o),c):null},remove(i){const o=t.findIndex(l=>l.id===i);if(o<0)return null;const[c]=t.splice(o,1);return e.free(c.number),c},reset(){for(t=[],n={...Pe},r=1;e.peekUsed().length;)e.free(e.peekUsed()[0])}}}function Ar(e,t){const n=Number(t==null?void 0:t.w)||1,r=Number(t==null?void 0:t.h)||1,a=Number(t==null?void 0:t.x)||0,i=Number(t==null?void 0:t.y)||0;return(Array.isArray(e)?e:[]).map(o=>{const c={...o,x:(o.x-a)/n,y:(o.y-i)/r,w:(o.w||0)/n,h:(o.h||0)/r};return Number.isFinite(o.x2)&&(c.x2=(o.x2-a)/n),Number.isFinite(o.y2)&&(c.y2=(o.y2-i)/r),c})}function Lr(e){const t=Math.min(Math.max(e.x,0),.95),n=Math.min(Math.max(e.y,0),.95),r=Math.min(Math.max(e.w,.05),1-t),a=Math.min(Math.max(e.h,.05),1-n);return{x:t,y:n,w:r,h:a}}function kr(e,t){const n=e.type==="arrow"?(e.x+(e.x2??e.x))/2:e.x+(e.w||0)/2,r=e.type==="arrow"?(e.y+(e.y2??e.y))/2:e.y+(e.h||0)/2;return n>=t.x&&r>=t.y&&n<=t.x+t.w&&r<=t.y+t.h}function Oe(e){const t=Math.max(1,Number(e)||1);return{stroke:Math.max(2,t*.0075),badgeRadius:Math.max(8,t*.025),fontSize:Math.max(10,t*.0275),arrowHead:Math.max(8,t*.035),arrowHeadAngle:.4}}function Mr(e,{stickers:t=[],crop:n={x:0,y:0,w:1,h:1},width:r,height:a,colors:i={}}){const o=i.mark||"#fdd341",c=i.markText||"#2a2140",l=Oe(r);e.save(),e.lineWidth=l.stroke,e.lineCap="round",e.lineJoin="round",e.strokeStyle=o,e.fillStyle=o,e.font=`700 ${Math.round(l.fontSize)}px ui-sans-serif, system-ui, sans-serif`,t.forEach(u=>{const f=Be(u.x,n,r),y=De(u.y,n,a),g=u.w/n.w*r,w=u.h/n.h*a,x=l.stroke/2;if(u.type==="rect")e.strokeRect(f+x,y+x,Math.max(0,g-l.stroke),Math.max(0,w-l.stroke));else if(u.type==="circle")e.beginPath(),e.ellipse(f+g/2,y+w/2,Math.max(.5,g/2-x),Math.max(.5,w/2-x),0,0,Math.PI*2),e.stroke();else if(u.type==="arrow"){const R=Be(u.x2??u.x+u.w,n,r),U=De(u.y2??u.y,n,a);Rr(e,f,y,R,U,l)}if(u.number==null||u.number==="")return;const k=$r(u,n,r,a,f,y,g),H=String(u.number);e.beginPath(),e.arc(k.x,k.y,l.badgeRadius,0,Math.PI*2),e.fillStyle=o,e.fill(),e.fillStyle=c,e.textAlign="center",e.textBaseline="middle",e.fillText(H,k.x,k.y+.5),e.fillStyle=o}),e.restore()}function Be(e,t,n){return(e-t.x)/t.w*n}function De(e,t,n){return(e-t.y)/t.h*n}function $r(e,t,n,r,a,i,o){if(e.type==="arrow"){const c=Be(e.x2??e.x+e.w,t,n),l=De(e.y2??e.y,t,r);return{x:(a+c)/2,y:(i+l)/2}}return{x:a+o/2,y:i}}function St(e,t,n,r,a){const i=Math.atan2(r-t,n-e),o=a.arrowHead,c=Math.min(a.stroke,o*.2),l=n,u=r,f=n-Math.cos(i)*o,y=r-Math.sin(i)*o,g={x:l-o*Math.cos(i-a.arrowHeadAngle),y:u-o*Math.sin(i-a.arrowHeadAngle)},w={x:l-o*Math.cos(i+a.arrowHeadAngle),y:u-o*Math.sin(i+a.arrowHeadAngle)},x={x:n-Math.cos(i)*c,y:r-Math.sin(i)*c};return{angle:i,tipX:l,tipY:u,baseX:f,baseY:y,left:g,right:w,shaftEnd:x}}function Rr(e,t,n,r,a,i){const o=St(t,n,r,a,i);e.beginPath(),e.moveTo(t,n),e.lineTo(o.shaftEnd.x,o.shaftEnd.y),e.stroke(),e.beginPath(),e.moveTo(o.tipX,o.tipY),e.lineTo(o.left.x,o.left.y),e.lineTo(o.right.x,o.right.y),e.closePath(),e.fill()}function Tr(e,t){return xt(e,t,[],{})}function Pr(e,t,n,r={}){return xt(e,t,n,r)}function xt(e,t,n,r){return new Promise((a,i)=>{const o=new Image;o.onload=()=>{const c=Math.round(t.x*o.width),l=Math.round(t.y*o.height),u=Math.max(1,Math.round(t.w*o.width)),f=Math.max(1,Math.round(t.h*o.height)),y=document.createElement("canvas");y.width=u,y.height=f;const g=y.getContext("2d");g.drawImage(o,c,l,u,f,0,0,u,f),n!=null&&n.length&&Mr(g,{stickers:n,crop:t,width:u,height:f,colors:r}),y.toBlob(w=>{if(!w){i(new Error("Could not encode screenshot"));return}a(w)},"image/png")},o.onerror=()=>i(new Error("Could not load screenshot")),o.src=e})}const Ir=[{key:"url",label:"URL"},{key:"title",label:"Title"},{key:"userAgent",label:"User agent"},{key:"os",label:"OS"},{key:"browser",label:"Browser"},{key:"language",label:"Language"},{key:"timezone",label:"Timezone"},{key:"viewport",label:"Viewport"},{key:"user",label:"User"}];function Or(e){return!e||typeof e!="object"?!1:!!(e.userId||e.email||e.displayName)}function Br(e={}){const t=[];for(const n of Ir){const r=e[n.key];r==null||r===""||n.key==="user"&&!Or(r)||t.push({key:n.key,label:n.label,value:r,redacted:!1})}return t}function Dr(e=[]){return e.map((t,n)=>({id:`log-${n}-${t.at||0}`,level:t.level||"log",text:String(t.text||""),at:t.at||0,redacted:!1}))}function Hr(e=[]){if(!e.length)return{checked:!1,indeterminate:!1};const t=e.filter(n=>n.redacted).length;return t===0?{checked:!1,indeterminate:!1}:t===e.length?{checked:!0,indeterminate:!1}:{checked:!1,indeterminate:!0}}function pe(e,t){e.forEach(n=>{n.redacted=!!t})}function Fr(e={}){const t=e.diagnostics||[],n=e.logs||[],r=t.some(i=>!i.redacted),a=n.length>0&&n.some(i=>!i.redacted);return r&&a?"Also sending logs and diagnostic information":r?"Also sending diagnostic information":a?"Also sending logs":""}function Nr(e){if(e==null)return"";if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function Ur(e={}){const t={};e.author!=null&&e.author!==""&&(t.author=e.author);for(const r of e.diagnostics||[])r.redacted||(t[r.key]=r.value);const n=(e.logs||[]).filter(r=>!r.redacted).map(r=>({level:r.level,text:r.text,at:r.at}));return t.console=n,t}const V=[{id:"bug",label:"Bug"},{id:"idea",label:"Idea"},{id:"other",label:"Other"}];function Et(e){return String(e||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32)}function He(e){const t=String(e||"").trim();return t?t.split(/[-_\s]+/).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" "):""}function _r(e){if(!Array.isArray(e)||!e.length)return V.map(r=>({...r}));const t=new Set,n=[];for(const r of e){let a="",i="";typeof r=="string"||typeof r=="number"?(a=Et(r),i=He(a)):r&&typeof r=="object"&&(a=Et(r.id??r.value??r.kind),i=String(r.label||r.name||He(a)).trim()||He(a)),!(!a||t.has(a))&&(t.add(a),n.push({id:a,label:i}))}return n.length?n:V.map(r=>({...r}))}function ye(e){var n;const t=Array.isArray(e)&&e.length?e:V;return t.some(r=>r.id==="bug")?"bug":((n=t[0])==null?void 0:n.id)||"other"}const jr=["maker","all-business","brighter-day","quiet-night"],Ct="maker",Vr=new Set(["crop","arrow","rect","circle"]),Fe=.02,At=.05,zr=`
3
3
  <svg class="nf-launcher-icon" viewBox="0 0 24 24" aria-hidden="true">
4
4
  <path fill="currentColor" d="M5.2 2.8h9.1A2.7 2.7 0 0 1 17 5.5v8.2c0 .4-.3.7-.7.7h-.1a.7.7 0 0 1-.7-.7V5.5c0-.7-.6-1.3-1.3-1.3H5.2c-.7 0-1.3.6-1.3 1.3v12.2c0 .7.6 1.3 1.3 1.3h6.4a.7.7 0 0 1 0 1.4H5.2A2.7 2.7 0 0 1 2.5 17.7V5.5A2.7 2.7 0 0 1 5.2 2.8zm1.6 4.2a.7.7 0 0 0 0 1.4h6.2a.7.7 0 0 0 0-1.4H6.8zm0 3.2a.7.7 0 0 0 0 1.4h6.2a.7.7 0 0 0 0-1.4H6.8zm0 3.2a.7.7 0 0 0 0 1.4h3.6a.7.7 0 0 0 0-1.4H6.8z"/>
5
5
  <path fill="currentColor" d="M14.7 13.05 20.2 7.55a1.55 1.55 0 0 1 2.2 2.2l-5.5 5.5-.45 1.9a.6.6 0 0 1-.72.45l-1.9-.45.87-1.9z"/>
6
6
  </svg>
7
- `;function T(e){return`<svg class="nf-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e}</svg>`}const M={crop:T('<path d="M6 3v5H1M18 21v-5h5M8 5h8a2 2 0 0 1 2 2v8M16 19H8a2 2 0 0 1-2-2V8"/>'),resetCrop:T('<path d="M3 12a9 9 0 1 0 3-6.7L3 8"/><path d="M3 3v5h5"/>'),arrow:T('<path d="M5 19 19 5"/><path d="M9 5h10v10"/>'),rect:T('<rect x="4" y="6" width="16" height="12" rx="1.5"/>'),circle:T('<circle cx="12" cy="12" r="8"/>'),discard:T('<path d="M4 7h16"/><path d="M9 7V5h6v2"/><path d="M6 7l1 13h10l1-13"/>'),recapture:T('<path d="M4 8h3l2-2h6l2 2h3v11H4z"/><circle cx="12" cy="13" r="3.5"/>'),privacy:T('<path d="M8 6h13M8 12h13M8 18h13"/><path d="M3 6h.01M3 12h.01M3 18h.01"/>'),audio:T('<rect x="9" y="3" width="6" height="11" rx="3"/><path d="M5 11a7 7 0 0 0 14 0"/><path d="M12 18v3"/>'),video:T('<rect x="3" y="7" width="13" height="10" rx="2"/><path d="M16 10.5 21 8v8l-5-2.5z"/>'),openArrow:T('<path d="M5 12h14"/><path d="m13 6 6 6-6 6"/>')},Ct=mr();Ct.hook();const kt=10,Ur=80,Lt="notefully.author",At="notefully.kind",Mt="notefully.redactSections",Fe="Anonymous";let d={endpoint:"",projectKey:"",version:"0.0.0",name:"",targets:null,hideLauncher:!1,theme:xt,video:!1,consoleLogLimit:kt,kinds:V.map(e=>({...e})),capture:null,onBeforeCapture:null,displayLink:!1},Ue=!1,O={},h=null,s={},m=Pe(),B="",ee="",D=null,W=pe(V),z=null,P=null,v=null,b=null,ye=null,X=null,ie=null,F={w:0,h:0},Ne=!1,me=!1,ge=!1,U=[],I=[],Y=!1;function p(e){return h.querySelector(e)}function Rt(e){const t=String(e||"").trim().toLowerCase().replace(/\s+/g,"-");return Dr.includes(t)?t:xt}function $t(e,t){return h&&getComputedStyle(h).getPropertyValue(e).trim()||t}async function Nr(e){return(await fetch(e)).blob()}function S(e,t=!1){s.status&&(s.status.textContent=e||"",ye&&(clearTimeout(ye),ye=null),e&&!t&&(ye=setTimeout(()=>{s.status.textContent=""},4e3)))}function _e(){return h&&document.body.contains(h)||(h=document.createElement("div"),h.id="notefully",h.innerHTML=`
8
- <button class="nf-launcher" type="button" title="Leave a note…" aria-label="Leave a note…">${Fr}</button>
7
+ `;function T(e){return`<svg class="nf-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e}</svg>`}const M={crop:T('<path d="M6 3v5H1M18 21v-5h5M8 5h8a2 2 0 0 1 2 2v8M16 19H8a2 2 0 0 1-2-2V8"/>'),resetCrop:T('<path d="M3 12a9 9 0 1 0 3-6.7L3 8"/><path d="M3 3v5h5"/>'),arrow:T('<path d="M5 19 19 5"/><path d="M9 5h10v10"/>'),rect:T('<rect x="4" y="6" width="16" height="12" rx="1.5"/>'),circle:T('<circle cx="12" cy="12" r="8"/>'),discard:T('<path d="M4 7h16"/><path d="M9 7V5h6v2"/><path d="M6 7l1 13h10l1-13"/>'),recapture:T('<path d="M4 8h3l2-2h6l2 2h3v11H4z"/><circle cx="12" cy="13" r="3.5"/>'),privacy:T('<path d="M8 6h13M8 12h13M8 18h13"/><path d="M3 6h.01M3 12h.01M3 18h.01"/>'),audio:T('<rect x="9" y="3" width="6" height="11" rx="3"/><path d="M5 11a7 7 0 0 0 14 0"/><path d="M12 18v3"/>'),video:T('<rect x="3" y="7" width="13" height="10" rx="2"/><path d="M16 10.5 21 8v8l-5-2.5z"/>'),openArrow:T('<path d="M5 12h14"/><path d="m13 6 6 6-6 6"/>')},Lt=br();Lt.hook();const kt=10,Wr=80,Mt="notefully.author",$t="notefully.kind",Rt="notefully.redactSections",Ne="Anonymous";let d={endpoint:"",projectKey:"",version:"0.0.0",name:"",targets:null,hideLauncher:!1,theme:Ct,video:!1,consoleLogLimit:kt,kinds:V.map(e=>({...e})),capture:null,onBeforeCapture:null,onOpen:null,onClose:null,displayLink:!1},ie=!1,Ue=!1,B={},h=null,s={},m=Ie(),P="",ee="",D=null,z=ye(V),W=null,I=null,v=null,b=null,me=null,X=null,ae=null,F={w:0,h:0},_e=!1,ge=!1,we=!1,N=[],O=[],Y=!1;function p(e){return h.querySelector(e)}function Tt(e){const t=String(e||"").trim().toLowerCase().replace(/\s+/g,"-");return jr.includes(t)?t:Ct}function Pt(e,t){return h&&getComputedStyle(h).getPropertyValue(e).trim()||t}async function Kr(e){return(await fetch(e)).blob()}function S(e,t=!1){s.status&&(s.status.textContent=e||"",me&&(clearTimeout(me),me=null),e&&!t&&(me=setTimeout(()=>{s.status.textContent=""},4e3)))}function je(){return h&&document.body.contains(h)||(h=document.createElement("div"),h.id="notefully",h.innerHTML=`
8
+ <button class="nf-launcher" type="button" title="Leave a note…" aria-label="Leave a note…">${zr}</button>
9
9
  <div class="nf-dialog" hidden>
10
10
  <div class="nf-panel">
11
11
  <div class="nf-panel-body">
@@ -52,28 +52,28 @@ var Notefully=(function(A){"use strict";function sn(e,t){if(e.match(/^[a-z]+:\/\
52
52
  </div>
53
53
  </div>
54
54
  <button class="nf-stop-video" type="button" hidden>Stop</button>
55
- `,document.body.appendChild(h),s={launcher:p(".nf-launcher"),dialog:p(".nf-dialog"),panel:p(".nf-panel"),panelBody:p(".nf-panel-body"),successMsg:p(".nf-success-msg"),successLink:p(".nf-success-link"),stage:p(".nf-stage"),palette:p(".nf-palette"),canvas:p(".nf-canvas"),text:p(".nf-text"),author:p(".nf-author"),kindRow:p(".nf-kind-row"),kind:p(".nf-kind"),privacy:p(".nf-privacy"),privacySummary:p(".nf-privacy-summary"),privacyText:p(".nf-privacy-text"),privacyChange:p(".nf-privacy-change"),privacyPanel:p(".nf-privacy-panel"),privacyScroll:p(".nf-privacy-scroll"),privacyDone:p(".nf-privacy-done"),actions:p(".nf-actions"),restore:p(".nf-restore"),status:p(".nf-status"),audio:p(".nf-audio"),video:p(".nf-video"),discard:p(".nf-discard-shot"),recapture:p(".nf-recapture"),stop:p(".nf-stop-video"),resetCrop:p(".nf-reset-crop"),submit:p(".nf-submit"),shot:null},_r(),ae()),h}function ae(){var e;h&&(h.dataset.theme=Rt(d.theme),d.hideLauncher?h.setAttribute("data-nf-hidden-launcher",""):h.removeAttribute("data-nf-hidden-launcher"),s.video&&(s.video.hidden=!d.video),Tt(),(e=s.dialog)!=null&&e.hidden&&we())}function we(){s.launcher&&(s.launcher.hidden=!!d.hideLauncher)}function _r(){s.launcher.addEventListener("click",()=>Xe()),p(".nf-dialog").addEventListener("click",t=>{me&&!ge||t.target===s.dialog&&J()}),document.addEventListener("keydown",Kt),h.querySelectorAll(".nf-tool").forEach(t=>{t.addEventListener("click",()=>oe(t.dataset.tool))}),s.resetCrop.addEventListener("click",Jr),s.canvas.addEventListener("pointerdown",Kr),s.canvas.addEventListener("dragstart",t=>t.preventDefault());const e=p(".nf-kind");e&&e.addEventListener("click",t=>{const n=t.target.closest("[data-kind]");n&&je(n.dataset.kind)}),s.discard.addEventListener("click",Qr),s.recapture.addEventListener("click",()=>{ei().catch(t=>S(t.message||"Recapture failed."))}),s.restore.addEventListener("click",Zr),s.audio.addEventListener("click",ti),s.video.addEventListener("click",ni),s.stop.addEventListener("click",()=>ie==null?void 0:ie.stop()),s.privacyChange.addEventListener("click",()=>Ce(!Y)),s.privacyDone.addEventListener("click",()=>Ce(!1)),s.privacyScroll.addEventListener("change",li),p(".nf-submit").addEventListener("click",()=>{Ye().catch(t=>S(t.message||"Submit failed."))}),Tt(),oe(null)}function k(e){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Tt(){const e=h==null?void 0:h.querySelector(".nf-kind");if(!e)return;const t=Array.isArray(d.kinds)&&d.kinds.length?d.kinds:V;e.innerHTML=t.map(i=>`<button type="button" data-kind="${k(i.id)}">${k(i.label)}</button>`).join("");const r=t.map(i=>i.id).includes(W)?W:pe(t);je(r)}function je(e){W=(d.kinds||V).map(n=>n.id).includes(e)?e:pe(d.kinds),h==null||h.querySelectorAll("[data-kind]").forEach(n=>{n.dataset.active=String(n.dataset.kind===W)}),Vr(W)}function jr(){try{return String(localStorage.getItem(At)||"").trim().toLowerCase()}catch{return""}}function Vr(e){const t=String(e||"").trim().toLowerCase();if(t)try{localStorage.setItem(At,t)}catch{}}function Wr(){const e=(d.kinds||V).map(n=>n.id),t=jr();return t&&e.includes(t)?t:pe(d.kinds)}function oe(e){z=Hr.has(e)?e:null,P=null,h.querySelectorAll(".nf-tool").forEach(t=>{t.dataset.active=String(t.dataset.tool===z)}),s.canvas&&(s.canvas.dataset.draw=z?"true":"false"),K()&&R()}function Pt(e){return Math.min(1,Math.max(0,e))}function se(){return s.shot||s.canvas}function ve(e){const t=se().getBoundingClientRect();return{x:Pt((e.clientX-t.left)/Math.max(t.width,1)),y:Pt((e.clientY-t.top)/Math.max(t.height,1))}}function zr(e){const t=se().getBoundingClientRect();return e.clientX>=t.left&&e.clientX<=t.right&&e.clientY>=t.top&&e.clientY<=t.bottom}function It(e){const t=ve(e),n=m.crop();return{x:n.x+t.x*n.w,y:n.y+t.y*n.h}}function be(e,t){const n=Math.min(e.x,t.x),r=Math.min(e.y,t.y);return{x:n,y:r,w:Math.max(He,Math.abs(t.x-e.x)),h:Math.max(He,Math.abs(t.y-e.y))}}function Ve(e){h&&(e?h.dataset.grabbing="true":delete h.dataset.grabbing)}function We(e){try{s.canvas.setPointerCapture(e.pointerId)}catch{}}function ze(){window.addEventListener("pointermove",Bt),window.addEventListener("pointerup",Se),window.addEventListener("pointercancel",Se)}function Ot(){window.removeEventListener("pointermove",Bt),window.removeEventListener("pointerup",Se),window.removeEventListener("pointercancel",Se)}function Kr(e){if(e.button!==0||!K())return;if(!e.target.closest(".nf-sticker")&&!zr(e)){P=null,R();return}const t=e.target.closest(".nf-handle"),n=e.target.closest(".nf-sticker");if(n&&n.dataset.preview!=="true"){e.preventDefault(),e.stopPropagation(),P=n.dataset.id,We(e),qr({kind:"sticker",id:P,dir:(t==null?void 0:t.dataset.dir)||"move"},e),R();return}if(P=null,z==="crop"){e.preventDefault(),We(e),v={kind:"crop",start:ve(e),current:ve(e)},ze(),R();return}if(z==="arrow"||z==="rect"||z==="circle"){e.preventDefault(),We(e);const r=It(e);v={kind:"sticker",type:z,start:r,current:r},ze(),R();return}R()}function qr(e,t){t.preventDefault(),t.stopPropagation();const n=se().getBoundingClientRect(),r=m.list().find(i=>i.id===e.id);b={...e,startX:t.clientX,startY:t.clientY,crop:m.crop(),sticker:r?{...r}:null,rect:n},Ve(e.dir==="move"||e.dir==="start"||e.dir==="end"),ze()}function Bt(e){if(v){v.current=v.kind==="crop"?ve(e):It(e),R();return}if(!b)return;const t=(e.clientX-b.startX)/b.rect.width*b.crop.w,n=(e.clientY-b.startY)/b.rect.height*b.crop.h,r=b.sticker;if(r){if(b.dir==="end")m.update(r.id,{x2:r.x2+t,y2:r.y2+n});else if(b.dir==="start")m.update(r.id,{x:r.x+t,y:r.y+n});else if(b.dir==="move")m.update(r.id,{x:r.x+t,y:r.y+n,x2:(r.x2||r.x)+t,y2:(r.y2||r.y)+n});else{const i={x:r.x,y:r.y,w:r.w,h:r.h};Xr(i,b.dir,t,n),m.update(r.id,i)}R()}}function Xr(e,t,n,r){if(t.includes("e")&&(e.w=Math.max(.04,e.w+n)),t.includes("s")&&(e.h=Math.max(.04,e.h+r)),t.includes("w")){const i=Math.max(.04,e.w-n);e.x+=e.w-i,e.w=i}if(t.includes("n")){const i=Math.max(.04,e.h-r);e.y+=e.h-i,e.h=i}}function Se(e){if(Ot(),Ve(!1),v){Yr();return}if(b){if(b.kind==="sticker"){const t=s.canvas.getBoundingClientRect();(e.clientX<t.left-24||e.clientX>t.right+24||e.clientY<t.top-24||e.clientY>t.bottom+24)&&(m.remove(b.id),P=null)}b=null,R()}}function Yr(){const e=v;if(v=null,!e)return;if(e.kind==="crop"){const n=be(e.start,e.current);if(Math.abs(e.current.x-e.start.x)<Et||Math.abs(e.current.y-e.start.y)<Et){R();return}const i=m.crop();m.setCrop({x:i.x+n.x*i.w,y:i.y+n.y*i.h,w:n.w*i.w,h:n.h*i.h}),G();return}const t=Gr(e);t&&(P=t.id),R()}function Gr(e){if(e.type==="arrow"){const t=e.current.x-e.start.x,n=e.current.y-e.start.y;return Math.hypot(t,n)<He?m.add("arrow",{x:e.start.x,y:e.start.y,x2:e.start.x+.12,y2:e.start.y,w:.12,h:.02}):m.add("arrow",{x:e.start.x,y:e.start.y,x2:e.current.x,y2:e.current.y,w:Math.abs(t),h:Math.abs(n)})}return m.add(e.type,be(e.start,e.current))}function Jr(){m.resetCrop(),P=null,G()}function xe(){s.resetCrop&&(s.resetCrop.hidden=!m.isCropped())}function Ke(e){if(!s.audio)return;const t=e?"Stop audio":"Record audio";s.audio.title=t,s.audio.setAttribute("aria-label",t),s.audio.dataset.active=String(!!e)}function K(){return j(B)}function ce(){if(!s.stage||!s.palette||!s.actions||!s.recapture)return;const e=K();s.stage.hidden=!e&&!D,s.palette.hidden=!e,s.discard&&(s.discard.hidden=!e),s.restore&&(s.restore.hidden=e||!ee),e?(s.palette.appendChild(s.discard),s.palette.appendChild(s.recapture)):s.audio?s.audio.after(s.recapture):s.actions.insertBefore(s.recapture,s.submit||null),s.recapture.hidden=!1}function Qr(){K()&&(ee=B),B="",oe(null),ce(),G()}function Zr(){j(ee)&&(B=ee,ce(),G())}function Dt(){return{capture:typeof d.capture=="function"?d.capture:void 0,onBeforeCapture:typeof d.onBeforeCapture=="function"?d.onBeforeCapture:void 0}}function Ht(e){if(!j(e))throw new Error("Screenshot failed; you can still send text.");B=e,ee=e,m=Pe(),F={w:0,h:0},P=null,v=null,b=null,oe(null)}async function ei(){if(!(Ue||!s.dialog||s.dialog.hidden)){Ue=!0,s.recapture.disabled=!0,S("Capturing…",!0),s.dialog.hidden=!0;try{let e="";try{e=await lr()}catch{e=await pt(Dt())}Ht(e),S("")}catch(e){S((e==null?void 0:e.message)||"Screenshot failed; you can still send text.")}finally{s.dialog.hidden=!1,s.recapture.disabled=!1,Ue=!1,ce(),G()}}}function ti(){try{if(X||(X=gr(t=>{const n=s.text.value.trim();s.text.value=n?`${n} ${t}`:t})),!X.isSupported()){S("Audio-to-text is not supported in this browser.");return}const e=X.start();Ke(e),S(e?"Listening…":"")}catch(e){S(e.message)}}async function ni(){if(!d.video){S("Video is disabled on this host.");return}s.dialog.hidden=!0,s.stop.hidden=!1,ae(),s.launcher.hidden=!0,ie=vr({onStart(){},onStop(e){D=e,s.stop.hidden=!0,we(),s.dialog.hidden=!1,ce(),G(),S(e?"Video attached.":"Recording cancelled.")},onError(e){S(e.message)}});try{await ie.start()}catch(e){s.stop.hidden=!0,we(),s.dialog.hidden=!1,S(e.message)}}function G(){if(s.shot=null,!K()){s.canvas.style.removeProperty("--nf-shot-aspect"),s.canvas.style.removeProperty("aspect-ratio"),s.canvas.innerHTML=D?`<video class="nf-recording-preview" controls src="${URL.createObjectURL(D)}"></video>`:"",xe();return}s.canvas.innerHTML=`<div class="nf-shot"><img alt="Screenshot" src="${B}" draggable="false"></div>`,s.shot=s.canvas.querySelector(".nf-shot");const e=s.shot.querySelector("img");e.draggable=!1,e.addEventListener("dragstart",n=>n.preventDefault());const t=()=>{ri(e),R()};e.addEventListener("load",t),e.complete&&e.naturalWidth&&t(),xe()}function ri(e){const t=e.naturalWidth||F.w,n=e.naturalHeight||F.h;if(t&&n&&(F={w:t,h:n},s.canvas.style.setProperty("--nf-shot-aspect",String(t/n)),s.canvas.style.aspectRatio=`${t} / ${n}`),!s.shot||!F.w||!F.h)return;const r=m.crop(),i=F.w/F.h,a=r.w/r.h*i,o=Math.min(1,a/i),c=Math.min(1,i/a);s.shot.style.left=`${(1-o)/2*100}%`,s.shot.style.top=`${(1-c)/2*100}%`,s.shot.style.width=`${o*100}%`,s.shot.style.height=`${c*100}%`,e.style.width=`${100/r.w}%`,e.style.height=`${100/r.h}%`,e.style.left=`${-r.x/r.w*100}%`,e.style.top=`${-r.y/r.h*100}%`}function ii(e){return e.type==="arrow"?{id:"preview",type:"arrow",number:"",x:e.start.x,y:e.start.y,x2:e.current.x,y2:e.current.y,w:Math.abs(e.current.x-e.start.x),h:Math.abs(e.current.y-e.start.y)}:{id:"preview",type:e.type,number:"",...be(e.start,e.current)}}function R(){if((s.shot||s.canvas).querySelectorAll(".nf-sticker, .nf-crop").forEach(a=>a.remove()),!K()||!s.shot){xe();return}const t=m.crop(),n=se(),r=Ie(n.clientWidth||400);if(s.shot.style.setProperty("--nf-anno-stroke",`${r.stroke}px`),s.shot.style.setProperty("--nf-anno-badge",`${r.badgeRadius*2}px`),s.shot.style.setProperty("--nf-anno-badge-font",`${r.fontSize}px`),s.shot.style.setProperty("--nf-anno-handle",`${Math.max(8,r.stroke*2.5)}px`),(v==null?void 0:v.kind)==="crop"){const a=document.createElement("div");a.className="nf-crop",Ft(a,be(v.start,v.current),{x:0,y:0,w:1,h:1}),s.shot.appendChild(a)}const i=m.list().slice();if((v==null?void 0:v.kind)==="sticker"&&i.push(ii(v)),i.forEach(a=>{const o=a.id==="preview",c=!o&&a.id===P,l=document.createElement("div");if(l.className=`nf-sticker nf-${a.type}`,l.dataset.id=a.id,c&&(l.dataset.selected="true"),o&&(l.dataset.preview="true"),a.type==="arrow"?ai(l,a,t,c,r):(Ft(l,a,t),c&&["nw","ne","sw","se"].forEach(u=>qe(l,u))),!o&&a.number){const u=document.createElement("span");u.className="nf-badge",u.textContent=String(a.number),l.appendChild(u)}s.shot.appendChild(l)}),s.canvas.querySelectorAll(":scope > .nf-recording-preview").forEach(a=>a.remove()),D){const a=document.createElement("video");a.className="nf-recording-preview",a.controls=!0,a.src=URL.createObjectURL(D),a.style.position="absolute",a.style.right="8px",a.style.bottom="8px",a.style.width="160px",s.canvas.appendChild(a)}xe()}function ai(e,t,n,r,i=Ie(400)){const a=se(),o=a.clientWidth,c=a.clientHeight,l=(t.x-n.x)/n.w*o,u=(t.y-n.y)/n.h*c,f=((t.x2??t.x+t.w)-n.x)/n.w*o,y=((t.y2??t.y)-n.y)/n.h*c,g=Math.max(18,i.arrowHead+i.stroke*2),w=Math.min(l,f)-g,x=Math.min(u,y)-g,L=Math.max(2,Math.abs(f-l))+g*2,H=Math.max(2,Math.abs(y-u))+g*2,$=l-w,N=u-x,te=f-w,ne=y-x,q=bt($,N,te,ne,i),re=document.createElementNS("http://www.w3.org/2000/svg","svg");e.style.left=`${w}px`,e.style.top=`${x}px`,e.style.width=`${L}px`,e.style.height=`${H}px`,re.setAttribute("class","nf-arrow-svg"),re.setAttribute("viewBox",`0 0 ${L} ${H}`),re.setAttribute("width",String(L)),re.setAttribute("height",String(H)),re.innerHTML=`
56
- <line class="nf-arrow-hit" x1="${$}" y1="${N}" x2="${te}" y2="${ne}" />
57
- <line class="nf-arrow-shaft" x1="${$}" y1="${N}" x2="${q.shaftEnd.x}" y2="${q.shaftEnd.y}" />
55
+ `,document.body.appendChild(h),s={launcher:p(".nf-launcher"),dialog:p(".nf-dialog"),panel:p(".nf-panel"),panelBody:p(".nf-panel-body"),successMsg:p(".nf-success-msg"),successLink:p(".nf-success-link"),stage:p(".nf-stage"),palette:p(".nf-palette"),canvas:p(".nf-canvas"),text:p(".nf-text"),author:p(".nf-author"),kindRow:p(".nf-kind-row"),kind:p(".nf-kind"),privacy:p(".nf-privacy"),privacySummary:p(".nf-privacy-summary"),privacyText:p(".nf-privacy-text"),privacyChange:p(".nf-privacy-change"),privacyPanel:p(".nf-privacy-panel"),privacyScroll:p(".nf-privacy-scroll"),privacyDone:p(".nf-privacy-done"),actions:p(".nf-actions"),restore:p(".nf-restore"),status:p(".nf-status"),audio:p(".nf-audio"),video:p(".nf-video"),discard:p(".nf-discard-shot"),recapture:p(".nf-recapture"),stop:p(".nf-stop-video"),resetCrop:p(".nf-reset-crop"),submit:p(".nf-submit"),shot:null},qr(),oe()),h}function oe(){var e;h&&(h.dataset.theme=Tt(d.theme),d.hideLauncher?h.setAttribute("data-nf-hidden-launcher",""):h.removeAttribute("data-nf-hidden-launcher"),s.video&&(s.video.hidden=!d.video),It(),(e=s.dialog)!=null&&e.hidden&&ve())}function ve(){s.launcher&&(s.launcher.hidden=!!d.hideLauncher)}function qr(){s.launcher.addEventListener("click",()=>Ye()),p(".nf-dialog").addEventListener("click",t=>{ge&&!we||t.target===s.dialog&&J()}),document.addEventListener("keydown",Xt),h.querySelectorAll(".nf-tool").forEach(t=>{t.addEventListener("click",()=>se(t.dataset.tool))}),s.resetCrop.addEventListener("click",ri),s.canvas.addEventListener("pointerdown",Qr),s.canvas.addEventListener("dragstart",t=>t.preventDefault());const e=p(".nf-kind");e&&e.addEventListener("click",t=>{const n=t.target.closest("[data-kind]");n&&Ve(n.dataset.kind)}),s.discard.addEventListener("click",ii),s.recapture.addEventListener("click",()=>{oi().catch(t=>S(t.message||"Recapture failed."))}),s.restore.addEventListener("click",ai),s.audio.addEventListener("click",si),s.video.addEventListener("click",ci),s.stop.addEventListener("click",()=>ae==null?void 0:ae.stop()),s.privacyChange.addEventListener("click",()=>Ae(!Y)),s.privacyDone.addEventListener("click",()=>Ae(!1)),s.privacyScroll.addEventListener("change",yi),p(".nf-submit").addEventListener("click",()=>{Ge().catch(t=>S(t.message||"Submit failed."))}),It(),se(null)}function L(e){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function It(){const e=h==null?void 0:h.querySelector(".nf-kind");if(!e)return;const t=Array.isArray(d.kinds)&&d.kinds.length?d.kinds:V;e.innerHTML=t.map(a=>`<button type="button" data-kind="${L(a.id)}">${L(a.label)}</button>`).join("");const r=t.map(a=>a.id).includes(z)?z:ye(t);Ve(r)}function Ve(e){z=(d.kinds||V).map(n=>n.id).includes(e)?e:ye(d.kinds),h==null||h.querySelectorAll("[data-kind]").forEach(n=>{n.dataset.active=String(n.dataset.kind===z)}),Yr(z)}function Xr(){try{return String(localStorage.getItem($t)||"").trim().toLowerCase()}catch{return""}}function Yr(e){const t=String(e||"").trim().toLowerCase();if(t)try{localStorage.setItem($t,t)}catch{}}function Gr(){const e=(d.kinds||V).map(n=>n.id),t=Xr();return t&&e.includes(t)?t:ye(d.kinds)}function se(e){W=Vr.has(e)?e:null,I=null,h.querySelectorAll(".nf-tool").forEach(t=>{t.dataset.active=String(t.dataset.tool===W)}),s.canvas&&(s.canvas.dataset.draw=W?"true":"false"),K()&&$()}function Ot(e){return Math.min(1,Math.max(0,e))}function ce(){return s.shot||s.canvas}function be(e){const t=ce().getBoundingClientRect();return{x:Ot((e.clientX-t.left)/Math.max(t.width,1)),y:Ot((e.clientY-t.top)/Math.max(t.height,1))}}function Jr(e){const t=ce().getBoundingClientRect();return e.clientX>=t.left&&e.clientX<=t.right&&e.clientY>=t.top&&e.clientY<=t.bottom}function Bt(e){const t=be(e),n=m.crop();return{x:n.x+t.x*n.w,y:n.y+t.y*n.h}}function Se(e,t){const n=Math.min(e.x,t.x),r=Math.min(e.y,t.y);return{x:n,y:r,w:Math.max(Fe,Math.abs(t.x-e.x)),h:Math.max(Fe,Math.abs(t.y-e.y))}}function ze(e){h&&(e?h.dataset.grabbing="true":delete h.dataset.grabbing)}function We(e){try{s.canvas.setPointerCapture(e.pointerId)}catch{}}function Ke(){window.addEventListener("pointermove",Ht),window.addEventListener("pointerup",xe),window.addEventListener("pointercancel",xe)}function Dt(){window.removeEventListener("pointermove",Ht),window.removeEventListener("pointerup",xe),window.removeEventListener("pointercancel",xe)}function Qr(e){if(e.button!==0||!K())return;if(!e.target.closest(".nf-sticker")&&!Jr(e)){I=null,$();return}const t=e.target.closest(".nf-handle"),n=e.target.closest(".nf-sticker");if(n&&n.dataset.preview!=="true"){e.preventDefault(),e.stopPropagation(),I=n.dataset.id,We(e),Zr({kind:"sticker",id:I,dir:(t==null?void 0:t.dataset.dir)||"move"},e),$();return}if(I=null,W==="crop"){e.preventDefault(),We(e),v={kind:"crop",start:be(e),current:be(e)},Ke(),$();return}if(W==="arrow"||W==="rect"||W==="circle"){e.preventDefault(),We(e);const r=Bt(e);v={kind:"sticker",type:W,start:r,current:r},Ke(),$();return}$()}function Zr(e,t){t.preventDefault(),t.stopPropagation();const n=ce().getBoundingClientRect(),r=m.list().find(a=>a.id===e.id);b={...e,startX:t.clientX,startY:t.clientY,crop:m.crop(),sticker:r?{...r}:null,rect:n},ze(e.dir==="move"||e.dir==="start"||e.dir==="end"),Ke()}function Ht(e){if(v){v.current=v.kind==="crop"?be(e):Bt(e),$();return}if(!b)return;const t=(e.clientX-b.startX)/b.rect.width*b.crop.w,n=(e.clientY-b.startY)/b.rect.height*b.crop.h,r=b.sticker;if(r){if(b.dir==="end")m.update(r.id,{x2:r.x2+t,y2:r.y2+n});else if(b.dir==="start")m.update(r.id,{x:r.x+t,y:r.y+n});else if(b.dir==="move")m.update(r.id,{x:r.x+t,y:r.y+n,x2:(r.x2||r.x)+t,y2:(r.y2||r.y)+n});else{const a={x:r.x,y:r.y,w:r.w,h:r.h};ei(a,b.dir,t,n),m.update(r.id,a)}$()}}function ei(e,t,n,r){if(t.includes("e")&&(e.w=Math.max(.04,e.w+n)),t.includes("s")&&(e.h=Math.max(.04,e.h+r)),t.includes("w")){const a=Math.max(.04,e.w-n);e.x+=e.w-a,e.w=a}if(t.includes("n")){const a=Math.max(.04,e.h-r);e.y+=e.h-a,e.h=a}}function xe(e){if(Dt(),ze(!1),v){ti();return}if(b){if(b.kind==="sticker"){const t=s.canvas.getBoundingClientRect();(e.clientX<t.left-24||e.clientX>t.right+24||e.clientY<t.top-24||e.clientY>t.bottom+24)&&(m.remove(b.id),I=null)}b=null,$()}}function ti(){const e=v;if(v=null,!e)return;if(e.kind==="crop"){const n=Se(e.start,e.current);if(Math.abs(e.current.x-e.start.x)<At||Math.abs(e.current.y-e.start.y)<At){$();return}const a=m.crop();m.setCrop({x:a.x+n.x*a.w,y:a.y+n.y*a.h,w:n.w*a.w,h:n.h*a.h}),G();return}const t=ni(e);t&&(I=t.id),$()}function ni(e){if(e.type==="arrow"){const t=e.current.x-e.start.x,n=e.current.y-e.start.y;return Math.hypot(t,n)<Fe?m.add("arrow",{x:e.start.x,y:e.start.y,x2:e.start.x+.12,y2:e.start.y,w:.12,h:.02}):m.add("arrow",{x:e.start.x,y:e.start.y,x2:e.current.x,y2:e.current.y,w:Math.abs(t),h:Math.abs(n)})}return m.add(e.type,Se(e.start,e.current))}function ri(){m.resetCrop(),I=null,G()}function Ee(){s.resetCrop&&(s.resetCrop.hidden=!m.isCropped())}function qe(e){if(!s.audio)return;const t=e?"Stop audio":"Record audio";s.audio.title=t,s.audio.setAttribute("aria-label",t),s.audio.dataset.active=String(!!e)}function K(){return j(P)}function le(){if(!s.stage||!s.palette||!s.actions||!s.recapture)return;const e=K();s.stage.hidden=!e&&!D,s.palette.hidden=!e,s.discard&&(s.discard.hidden=!e),s.restore&&(s.restore.hidden=e||!ee),e?(s.palette.appendChild(s.discard),s.palette.appendChild(s.recapture)):s.audio?s.audio.after(s.recapture):s.actions.insertBefore(s.recapture,s.submit||null),s.recapture.hidden=!1}function ii(){K()&&(ee=P),P="",se(null),le(),G()}function ai(){j(ee)&&(P=ee,le(),G())}function Ft(){return{capture:typeof d.capture=="function"?d.capture:void 0,onBeforeCapture:typeof d.onBeforeCapture=="function"?d.onBeforeCapture:void 0}}function Nt(e){if(!j(e))throw new Error("Screenshot failed; you can still send text.");P=e,ee=e,m=Ie(),F={w:0,h:0},I=null,v=null,b=null,se(null)}async function oi(){if(!(Ue||!s.dialog||s.dialog.hidden)){Ue=!0,s.recapture.disabled=!0,S("Capturing…",!0),s.dialog.hidden=!0;try{let e="";try{e=await hr()}catch{e=await yt(Ft())}Nt(e),S("")}catch(e){S((e==null?void 0:e.message)||"Screenshot failed; you can still send text.")}finally{s.dialog.hidden=!1,s.recapture.disabled=!1,Ue=!1,le(),G()}}}function si(){try{if(X||(X=Sr(t=>{const n=s.text.value.trim();s.text.value=n?`${n} ${t}`:t})),!X.isSupported()){S("Audio-to-text is not supported in this browser.");return}const e=X.start();qe(e),S(e?"Listening…":"")}catch(e){S(e.message)}}async function ci(){if(!d.video){S("Video is disabled on this host.");return}s.dialog.hidden=!0,s.stop.hidden=!1,oe(),s.launcher.hidden=!0,ae=Er({onStart(){},onStop(e){D=e,s.stop.hidden=!0,ve(),s.dialog.hidden=!1,le(),G(),S(e?"Video attached.":"Recording cancelled.")},onError(e){S(e.message)}});try{await ae.start()}catch(e){s.stop.hidden=!0,ve(),s.dialog.hidden=!1,S(e.message)}}function G(){if(s.shot=null,!K()){s.canvas.style.removeProperty("--nf-shot-aspect"),s.canvas.style.removeProperty("aspect-ratio"),s.canvas.innerHTML=D?`<video class="nf-recording-preview" controls src="${URL.createObjectURL(D)}"></video>`:"",Ee();return}s.canvas.innerHTML=`<div class="nf-shot"><img alt="Screenshot" src="${P}" draggable="false"></div>`,s.shot=s.canvas.querySelector(".nf-shot");const e=s.shot.querySelector("img");e.draggable=!1,e.addEventListener("dragstart",n=>n.preventDefault());const t=()=>{li(e),$()};e.addEventListener("load",t),e.complete&&e.naturalWidth&&t(),Ee()}function li(e){const t=e.naturalWidth||F.w,n=e.naturalHeight||F.h;if(t&&n&&(F={w:t,h:n},s.canvas.style.setProperty("--nf-shot-aspect",String(t/n)),s.canvas.style.aspectRatio=`${t} / ${n}`),!s.shot||!F.w||!F.h)return;const r=m.crop(),a=F.w/F.h,i=r.w/r.h*a,o=Math.min(1,i/a),c=Math.min(1,a/i);s.shot.style.left=`${(1-o)/2*100}%`,s.shot.style.top=`${(1-c)/2*100}%`,s.shot.style.width=`${o*100}%`,s.shot.style.height=`${c*100}%`,e.style.width=`${100/r.w}%`,e.style.height=`${100/r.h}%`,e.style.left=`${-r.x/r.w*100}%`,e.style.top=`${-r.y/r.h*100}%`}function ui(e){return e.type==="arrow"?{id:"preview",type:"arrow",number:"",x:e.start.x,y:e.start.y,x2:e.current.x,y2:e.current.y,w:Math.abs(e.current.x-e.start.x),h:Math.abs(e.current.y-e.start.y)}:{id:"preview",type:e.type,number:"",...Se(e.start,e.current)}}function $(){if((s.shot||s.canvas).querySelectorAll(".nf-sticker, .nf-crop").forEach(i=>i.remove()),!K()||!s.shot){Ee();return}const t=m.crop(),n=ce(),r=Oe(n.clientWidth||400);if(s.shot.style.setProperty("--nf-anno-stroke",`${r.stroke}px`),s.shot.style.setProperty("--nf-anno-badge",`${r.badgeRadius*2}px`),s.shot.style.setProperty("--nf-anno-badge-font",`${r.fontSize}px`),s.shot.style.setProperty("--nf-anno-handle",`${Math.max(8,r.stroke*2.5)}px`),(v==null?void 0:v.kind)==="crop"){const i=document.createElement("div");i.className="nf-crop",Ut(i,Se(v.start,v.current),{x:0,y:0,w:1,h:1}),s.shot.appendChild(i)}const a=m.list().slice();if((v==null?void 0:v.kind)==="sticker"&&a.push(ui(v)),a.forEach(i=>{const o=i.id==="preview",c=!o&&i.id===I,l=document.createElement("div");if(l.className=`nf-sticker nf-${i.type}`,l.dataset.id=i.id,c&&(l.dataset.selected="true"),o&&(l.dataset.preview="true"),i.type==="arrow"?di(l,i,t,c,r):(Ut(l,i,t),c&&["nw","ne","sw","se"].forEach(u=>Xe(l,u))),!o&&i.number){const u=document.createElement("span");u.className="nf-badge",u.textContent=String(i.number),l.appendChild(u)}s.shot.appendChild(l)}),s.canvas.querySelectorAll(":scope > .nf-recording-preview").forEach(i=>i.remove()),D){const i=document.createElement("video");i.className="nf-recording-preview",i.controls=!0,i.src=URL.createObjectURL(D),i.style.position="absolute",i.style.right="8px",i.style.bottom="8px",i.style.width="160px",s.canvas.appendChild(i)}Ee()}function di(e,t,n,r,a=Oe(400)){const i=ce(),o=i.clientWidth,c=i.clientHeight,l=(t.x-n.x)/n.w*o,u=(t.y-n.y)/n.h*c,f=((t.x2??t.x+t.w)-n.x)/n.w*o,y=((t.y2??t.y)-n.y)/n.h*c,g=Math.max(18,a.arrowHead+a.stroke*2),w=Math.min(l,f)-g,x=Math.min(u,y)-g,k=Math.max(2,Math.abs(f-l))+g*2,H=Math.max(2,Math.abs(y-u))+g*2,R=l-w,U=u-x,te=f-w,ne=y-x,q=St(R,U,te,ne,a),re=document.createElementNS("http://www.w3.org/2000/svg","svg");e.style.left=`${w}px`,e.style.top=`${x}px`,e.style.width=`${k}px`,e.style.height=`${H}px`,re.setAttribute("class","nf-arrow-svg"),re.setAttribute("viewBox",`0 0 ${k} ${H}`),re.setAttribute("width",String(k)),re.setAttribute("height",String(H)),re.innerHTML=`
56
+ <line class="nf-arrow-hit" x1="${R}" y1="${U}" x2="${te}" y2="${ne}" />
57
+ <line class="nf-arrow-shaft" x1="${R}" y1="${U}" x2="${q.shaftEnd.x}" y2="${q.shaftEnd.y}" />
58
58
  <polygon class="nf-arrow-head" points="${q.tipX},${q.tipY} ${q.left.x},${q.left.y} ${q.right.x},${q.right.y}" />
59
- `,e.appendChild(re),r&&(qe(e,"start",{left:$-5,top:N-5}),qe(e,"end",{left:te-5,top:ne-5}))}function qe(e,t,n){const r=document.createElement("span");r.className="nf-handle",r.dataset.dir=t,n&&(r.style.left=`${n.left}px`,r.style.top=`${n.top}px`),e.appendChild(r)}function Ft(e,t,n){e.style.left=`${(t.x-n.x)/n.w*100}%`,e.style.top=`${(t.y-n.y)/n.h*100}%`,e.style.width=`${t.w/n.w*100}%`,e.style.height=`${t.h/n.h*100}%`}function Ut(){try{return String(localStorage.getItem(Lt)||"").trim()}catch{return""}}function oi(e){const t=String(e||"").trim();if(!(!t||t===Fe))try{localStorage.setItem(Lt,t)}catch{}}function Nt(){try{const e=localStorage.getItem(Mt);if(!e)return{diagnostics:!1,logs:!1};const t=JSON.parse(e);return{diagnostics:!!(t!=null&&t.diagnostics),logs:!!(t!=null&&t.logs)}}catch{return{diagnostics:!1,logs:!1}}}function _t(e={}){const t={...Nt(),...e};try{localStorage.setItem(Mt,JSON.stringify({diagnostics:!!t.diagnostics,logs:!!t.logs}))}catch{}}function jt(){return!!(String(O.userId||"").trim()||String(O.email||"").trim()||String(O.displayName||"").trim())}function Vt(){return String(O.displayName||O.email||O.userId||"").trim()}function si(){var t;if(jt())return Vt()||Fe;const e=String(((t=s.author)==null?void 0:t.value)||"").trim();return e?(oi(e),e):Fe}function Wt(){if(!s.author)return;const e=jt();if(s.author.hidden=e,e){s.author.value="";return}s.author.value=Ut()}function zt(e,t=kt){const n=Number(e);return Number.isFinite(n)?Math.min(Ur,Math.max(0,Math.floor(n))):t}function Kt(e){e.key!=="Escape"||!s.dialog||s.dialog.hidden||me&&!ge||J()}function qt(e={}){pr(e);const t=Object.prototype.hasOwnProperty.call(e,"kinds");d={...d,endpoint:String(e.endpoint||d.endpoint||"").replace(/\/$/,""),projectKey:e.projectKey==null?d.projectKey:String(e.projectKey),version:e.version==null?d.version:String(e.version),name:e.name==null?d.name:String(e.name||""),targets:e.targets===void 0?d.targets:e.targets,hideLauncher:e.hideLauncher==null?d.hideLauncher:!!e.hideLauncher,theme:Rt(e.theme??d.theme),video:e.video==null?d.video:!!e.video,consoleLogLimit:e.consoleLogLimit==null?d.consoleLogLimit:zt(e.consoleLogLimit,d.consoleLogLimit),kinds:t?Br(e.kinds):d.kinds,capture:e.capture===void 0?d.capture:e.capture,onBeforeCapture:e.onBeforeCapture===void 0?d.onBeforeCapture:e.onBeforeCapture,displayLink:e.displayLink==null?d.displayLink:!!e.displayLink}}function Ee(e={}){return qt(e),h&&ae(),ke}function Xt(e={}){return qt(e),_e(),ae(),ke}function Yt(e){return Ee({theme:e})}function Gt(e){const t=!!e;return!t&&h&&s.dialog&&!s.dialog.hidden&&J(),Ee({hideLauncher:!t})}function ci(){const e=Vt()||Ut()||void 0,t=fr({...O,displayName:O.displayName||e});U=Rr(t),I=$r(Ct.snapshot().slice(-zt(d.consoleLogLimit)));const n=Nt();n.diagnostics&&he(U,!0),n.logs&&I.length&&he(I,!0),Y=!1}function Ce(e){Y=!!e,s.privacyPanel&&(s.privacyPanel.hidden=!Y),s.privacyChange&&(s.privacyChange.setAttribute("aria-expanded",Y?"true":"false"),s.privacyChange.dataset.active=String(Y)),Y&&tn()}function Jt(){if(!s.privacy||!s.privacyText||!s.privacyChange)return;const e=Pr({diagnostics:U,logs:I});s.privacyText.textContent=e,s.privacyText.hidden=!e;const t=U.length===0&&I.length===0;s.privacySummary&&(s.privacySummary.hidden=t),s.privacy.hidden=t,s.privacyChange.hidden=!1}function Qt(e,t,n){return`<label class="nf-privacy-toggle">
59
+ `,e.appendChild(re),r&&(Xe(e,"start",{left:R-5,top:U-5}),Xe(e,"end",{left:te-5,top:ne-5}))}function Xe(e,t,n){const r=document.createElement("span");r.className="nf-handle",r.dataset.dir=t,n&&(r.style.left=`${n.left}px`,r.style.top=`${n.top}px`),e.appendChild(r)}function Ut(e,t,n){e.style.left=`${(t.x-n.x)/n.w*100}%`,e.style.top=`${(t.y-n.y)/n.h*100}%`,e.style.width=`${t.w/n.w*100}%`,e.style.height=`${t.h/n.h*100}%`}function _t(){try{return String(localStorage.getItem(Mt)||"").trim()}catch{return""}}function fi(e){const t=String(e||"").trim();if(!(!t||t===Ne))try{localStorage.setItem(Mt,t)}catch{}}function jt(){try{const e=localStorage.getItem(Rt);if(!e)return{diagnostics:!1,logs:!1};const t=JSON.parse(e);return{diagnostics:!!(t!=null&&t.diagnostics),logs:!!(t!=null&&t.logs)}}catch{return{diagnostics:!1,logs:!1}}}function Vt(e={}){const t={...jt(),...e};try{localStorage.setItem(Rt,JSON.stringify({diagnostics:!!t.diagnostics,logs:!!t.logs}))}catch{}}function zt(){return!!(String(B.userId||"").trim()||String(B.email||"").trim()||String(B.displayName||"").trim())}function Wt(){return String(B.displayName||B.email||B.userId||"").trim()}function hi(){var t;if(zt())return Wt()||Ne;const e=String(((t=s.author)==null?void 0:t.value)||"").trim();return e?(fi(e),e):Ne}function Kt(){if(!s.author)return;const e=zt();if(s.author.hidden=e,e){s.author.value="";return}s.author.value=_t()}function qt(e,t=kt){const n=Number(e);return Number.isFinite(n)?Math.min(Wr,Math.max(0,Math.floor(n))):t}function Xt(e){e.key!=="Escape"||!s.dialog||s.dialog.hidden||ge&&!we||J()}function Yt(e={}){wr(e);const t=Object.prototype.hasOwnProperty.call(e,"kinds");d={...d,endpoint:String(e.endpoint||d.endpoint||"").replace(/\/$/,""),projectKey:e.projectKey==null?d.projectKey:String(e.projectKey),version:e.version==null?d.version:String(e.version),name:e.name==null?d.name:String(e.name||""),targets:e.targets===void 0?d.targets:e.targets,hideLauncher:e.hideLauncher==null?d.hideLauncher:!!e.hideLauncher,theme:Tt(e.theme??d.theme),video:e.video==null?d.video:!!e.video,consoleLogLimit:e.consoleLogLimit==null?d.consoleLogLimit:qt(e.consoleLogLimit,d.consoleLogLimit),kinds:t?_r(e.kinds):d.kinds,capture:e.capture===void 0?d.capture:e.capture,onBeforeCapture:e.onBeforeCapture===void 0?d.onBeforeCapture:e.onBeforeCapture,onOpen:e.onOpen===void 0?d.onOpen:e.onOpen,onClose:e.onClose===void 0?d.onClose:e.onClose,displayLink:e.displayLink==null?d.displayLink:!!e.displayLink}}function Gt(e){const t=d[e];if(typeof t=="function")try{t()}catch(n){console.warn(`Notefully.${e} failed:`,n)}}function Jt(){return ie}function Ce(e={}){return Yt(e),h&&oe(),Le}function Qt(e={}){return Yt(e),je(),oe(),Le}function Zt(e){return Ce({theme:e})}function en(e){const t=!!e;return!t&&h&&s.dialog&&!s.dialog.hidden&&J(),Ce({hideLauncher:!t})}function pi(){const e=Wt()||_t()||void 0,t=mr({...B,displayName:B.displayName||e});N=Br(t),O=Dr(Lt.snapshot().slice(-qt(d.consoleLogLimit)));const n=jt();n.diagnostics&&pe(N,!0),n.logs&&O.length&&pe(O,!0),Y=!1}function Ae(e){Y=!!e,s.privacyPanel&&(s.privacyPanel.hidden=!Y),s.privacyChange&&(s.privacyChange.setAttribute("aria-expanded",Y?"true":"false"),s.privacyChange.dataset.active=String(Y)),Y&&on()}function tn(){if(!s.privacy||!s.privacyText||!s.privacyChange)return;const e=Fr({diagnostics:N,logs:O});s.privacyText.textContent=e,s.privacyText.hidden=!e;const t=N.length===0&&O.length===0;s.privacySummary&&(s.privacySummary.hidden=t),s.privacy.hidden=t,s.privacyChange.hidden=!1}function nn(e,t,n){return`<label class="nf-privacy-toggle">
60
60
  <span class="nf-privacy-toggle-label">Redact</span>
61
- <input type="checkbox" ${e?"checked":""} ${t?'data-indeterminate="true"':""} aria-label="${k(n)}">
62
- </label>`}function Zt(e,t,n,r,i){const a=Qt(i,!1,`Redact ${n}`);if(i){const o=r?`${n}: ${r}`:n;return`<div class="nf-privacy-row" data-kind="${k(e)}" data-id="${k(t)}" data-redacted="true">
61
+ <input type="checkbox" ${e?"checked":""} ${t?'data-indeterminate="true"':""} aria-label="${L(n)}">
62
+ </label>`}function rn(e,t,n,r,a){const i=nn(a,!1,`Redact ${n}`);if(a){const o=r?`${n}: ${r}`:n;return`<div class="nf-privacy-row" data-kind="${L(e)}" data-id="${L(t)}" data-redacted="true">
63
63
  <div class="nf-privacy-row-text">
64
- <div class="nf-privacy-row-summary" title="${k(o)}">${k(o)}</div>
64
+ <div class="nf-privacy-row-summary" title="${L(o)}">${L(o)}</div>
65
65
  </div>
66
- ${a}
67
- </div>`}return`<div class="nf-privacy-row" data-kind="${k(e)}" data-id="${k(t)}">
66
+ ${i}
67
+ </div>`}return`<div class="nf-privacy-row" data-kind="${L(e)}" data-id="${L(t)}">
68
68
  <div class="nf-privacy-row-text">
69
- <div class="nf-privacy-row-title">${k(n)}</div>
70
- <div class="nf-privacy-row-detail">${k(r)}</div>
69
+ <div class="nf-privacy-row-title">${L(n)}</div>
70
+ <div class="nf-privacy-row-detail">${L(r)}</div>
71
71
  </div>
72
- ${a}
73
- </div>`}function en(e,t,n,r){if(!n.length)return"";const i=Tr(n),a=i.checked&&!i.indeterminate;return`<section class="nf-privacy-section" data-section="${k(e)}"${a?' data-redacted="true"':""}>
72
+ ${i}
73
+ </div>`}function an(e,t,n,r){if(!n.length)return"";const a=Hr(n),i=a.checked&&!a.indeterminate;return`<section class="nf-privacy-section" data-section="${L(e)}"${i?' data-redacted="true"':""}>
74
74
  <div class="nf-privacy-section-head">
75
- <h3 class="nf-privacy-section-title">${k(t)}</h3>
76
- ${Qt(i.checked,i.indeterminate,`Redact all ${t.toLowerCase()}`)}
75
+ <h3 class="nf-privacy-section-title">${L(t)}</h3>
76
+ ${nn(a.checked,a.indeterminate,`Redact all ${t.toLowerCase()}`)}
77
77
  </div>
78
- <div class="nf-privacy-rows"${a?" hidden":""}>${r}</div>
79
- </section>`}function tn(){if(!s.privacyScroll)return;const e=U.map(n=>Zt("diagnostic",n.key,n.label,Ir(n.value),n.redacted)).join(""),t=I.map(n=>Zt("log",n.id,n.level,n.text,n.redacted)).join("");s.privacyScroll.innerHTML=[en("diagnostics","Diagnostics",U,e),I.length?en("logs","Logs",I,t):""].join(""),s.privacyScroll.querySelectorAll('input[data-indeterminate="true"]').forEach(n=>{n.indeterminate=!0,n.removeAttribute("data-indeterminate")}),Jt()}function li(e){const t=e.target;if(!(t instanceof HTMLInputElement)||t.type!=="checkbox")return;const n=t.closest("[data-section]"),r=t.closest(".nf-privacy-row"),i=t.checked;if(r){const a=r.dataset.kind,o=r.dataset.id;if(a==="diagnostic"){const c=U.find(l=>l.key===o);c&&(c.redacted=i)}else if(a==="log"){const c=I.find(l=>l.id===o);c&&(c.redacted=i)}}else if(n){const a=n.dataset.section;a==="diagnostics"?(he(U,i),_t({diagnostics:i})):a==="logs"&&(he(I,i),_t({logs:i}))}else return;tn()}async function Xe(){_e(),nn(),ae(),s.launcher.hidden=!0,m=Pe(),F={w:0,h:0},D=null,B="",ee="",P=null,v=null,b=null,W=Wr(),je(W),oe(null),Ke(!1),s.text.value="",Wt(),S(""),ci();try{Ht(await pt(Dt())),S("")}catch(e){B="",S((e==null?void 0:e.message)||"Screenshot failed; you can still send text.")}ce(),Ce(!1),Jt(),s.dialog.hidden=!1,G(),s.text.focus()}function J(){h&&(X==null||X.stop(),Ke(!1),Ot(),v=null,b=null,Ve(!1),nn(),Ce(!1),s.dialog.hidden=!0,s.stop.hidden=!0,we())}function ui(e=""){const t=s.dialog,n=s.panel,r=s.panelBody,i=s.successMsg,a=s.successLink,o=String(e||"").trim(),c=!!(d.displayLink&&o);if(!t||!n||!r||!i)return Promise.resolve(!1);me=!0,ge=c,S("");const l=typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,u=n.getBoundingClientRect();if(r.hidden=!0,i.hidden=!1,t.classList.add("nf-success"),t.classList.toggle("nf-success-sticky",c),t.style.opacity="1",a&&(c?(a.hidden=!1,a.href=o):(a.hidden=!0,a.removeAttribute("href"))),c){if(l)return Promise.resolve(!0);const w=n.getBoundingClientRect(),x=w.width>0?u.width/w.width:1,L=w.height>0?u.height/w.height:1;return n.style.transformOrigin="center center",n.style.transition="none",n.style.transform=`scale(${x}, ${L})`,n.getBoundingClientRect(),new Promise(H=>{let $=!1;const N=()=>{$||($=!0,n.removeEventListener("transitionend",te),H(!0))},te=ne=>{ne.target!==n||ne.propertyName!=="transform"||N()};n.addEventListener("transitionend",te),requestAnimationFrame(()=>{n.style.transition="transform 0.48s cubic-bezier(0.22, 1, 0.36, 1)",n.style.transform="scale(1)"}),window.setTimeout(N,700)})}if(l)return new Promise(w=>{window.setTimeout(()=>w(!1),1e3)});const f=n.getBoundingClientRect(),y=f.width>0?u.width/f.width:1,g=f.height>0?u.height/f.height:1;return n.style.transformOrigin="center center",n.style.transition="none",n.style.transform=`scale(${y}, ${g})`,n.getBoundingClientRect(),new Promise(w=>{let x=!1;const L=()=>{x||(x=!0,n.removeEventListener("transitionend",H),window.setTimeout(()=>{t.style.transition="opacity 0.28s ease",t.style.opacity="0",window.setTimeout(()=>w(!1),280)},1e3))},H=$=>{$.target!==n||$.propertyName!=="transform"||L()};n.addEventListener("transitionend",H),requestAnimationFrame(()=>{n.style.transition="transform 0.48s cubic-bezier(0.22, 1, 0.36, 1)",n.style.transform="scale(1)"}),window.setTimeout(L,700)})}function nn(){me=!1,ge=!1,s.dialog&&(s.dialog.classList.remove("nf-success","nf-success-sticky"),s.dialog.style.opacity="",s.dialog.style.transition="",s.panel&&(s.panel.style.transform="",s.panel.style.transition="",s.panel.style.transformOrigin=""),s.panelBody&&(s.panelBody.hidden=!1),s.successMsg&&(s.successMsg.hidden=!0),s.successLink&&(s.successLink.hidden=!0,s.successLink.removeAttribute("href")))}function rn(e={}){O={...O,...hr(e)},Wt()}async function Ye(){if(_e(),Ne)return null;const e=s.text.value.trim();if(!e&&!K()&&!D)return S("Add a note, screenshot, or video first."),null;if(!d.endpoint||!d.projectKey)return S("Notefully is missing endpoint or projectKey."),null;Ne=!0,an(!0),S("Submitting…",!0);try{const t=si(),n=new FormData;if(n.append("message",e),n.append("kind",W),n.append("version",d.version||"0.0.0"),n.append("author",t),d.name&&n.append("name",d.name),n.append("context",JSON.stringify(Or({author:t,diagnostics:U,logs:I}))),n.append("annotations",JSON.stringify(m.list())),n.append("crop",JSON.stringify(m.crop())),Array.isArray(d.targets)&&n.append("targets",JSON.stringify(d.targets)),K()){const o=await Nr(B);if(n.append("screenshot",o,"screenshot.png"),m.list().length||m.isCropped()){const c=await Lr(B,m.crop(),m.list(),{mark:$t("--nf-mark","#fdd341"),markText:$t("--nf-mark-text","#2a2140")});n.append("screenshotBaked",c,"screenshot.baked.png")}}D&&n.append("recording",D,"recording.webm");const r=await fetch(`${d.endpoint}/v1/reports`,{method:"POST",headers:{"X-Notefully-Key":d.projectKey},body:n});let i=null;try{i=await r.json()}catch{i=null}if(!r.ok)throw S((i==null?void 0:i.error)||"Submit failed."),new Error((i==null?void 0:i.error)||`Submit failed (${r.status})`);return await ui((i==null?void 0:i.trackerUrl)||"")||J(),i}finally{Ne=!1,an(!1)}}function an(e){s.submit&&(s.submit.disabled=!!e,s.submit.setAttribute("aria-busy",e?"true":"false"))}function on(){J(),document.removeEventListener("keydown",Kt),h==null||h.remove(),h=null,s={}}const ke={init:Xt,configure:Ee,setTheme:Yt,setVisible:Gt,open:Xe,close:J,identify:rn,submit:Ye,destroy:on};return typeof window<"u"&&(window.Notefully=ke),A.close=J,A.configure=Ee,A.default=ke,A.destroy=on,A.identify=rn,A.init=Xt,A.open=Xe,A.setTheme=Yt,A.setVisible=Gt,A.submit=Ye,Object.defineProperties(A,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),A})({});
78
+ <div class="nf-privacy-rows"${i?" hidden":""}>${r}</div>
79
+ </section>`}function on(){if(!s.privacyScroll)return;const e=N.map(n=>rn("diagnostic",n.key,n.label,Nr(n.value),n.redacted)).join(""),t=O.map(n=>rn("log",n.id,n.level,n.text,n.redacted)).join("");s.privacyScroll.innerHTML=[an("diagnostics","Diagnostics",N,e),O.length?an("logs","Logs",O,t):""].join(""),s.privacyScroll.querySelectorAll('input[data-indeterminate="true"]').forEach(n=>{n.indeterminate=!0,n.removeAttribute("data-indeterminate")}),tn()}function yi(e){const t=e.target;if(!(t instanceof HTMLInputElement)||t.type!=="checkbox")return;const n=t.closest("[data-section]"),r=t.closest(".nf-privacy-row"),a=t.checked;if(r){const i=r.dataset.kind,o=r.dataset.id;if(i==="diagnostic"){const c=N.find(l=>l.key===o);c&&(c.redacted=a)}else if(i==="log"){const c=O.find(l=>l.id===o);c&&(c.redacted=a)}}else if(n){const i=n.dataset.section;i==="diagnostics"?(pe(N,a),Vt({diagnostics:a})):i==="logs"&&(pe(O,a),Vt({logs:a}))}else return;on()}async function Ye(){je(),ie||(ie=!0,Gt("onOpen")),sn(),oe(),s.launcher.hidden=!0,m=Ie(),F={w:0,h:0},D=null,P="",ee="",I=null,v=null,b=null,z=Gr(),Ve(z),se(null),qe(!1),s.text.value="",Kt(),S(""),pi();try{Nt(await yt(Ft())),S("")}catch(t){P="",S((t==null?void 0:t.message)||"Screenshot failed; you can still send text.")}le(),Ae(!1),tn(),s.dialog.hidden=!1,G(),s.text.focus()}function J(){if(!h)return;const e=ie;X==null||X.stop(),qe(!1),Dt(),v=null,b=null,ze(!1),sn(),Ae(!1),s.dialog.hidden=!0,s.stop.hidden=!0,ve(),e&&(ie=!1,Gt("onClose"))}function mi(e=""){const t=s.dialog,n=s.panel,r=s.panelBody,a=s.successMsg,i=s.successLink,o=String(e||"").trim(),c=!!(d.displayLink&&o);if(!t||!n||!r||!a)return Promise.resolve(!1);ge=!0,we=c,S("");const l=typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,u=n.getBoundingClientRect();if(r.hidden=!0,a.hidden=!1,t.classList.add("nf-success"),t.classList.toggle("nf-success-sticky",c),t.style.opacity="1",i&&(c?(i.hidden=!1,i.href=o):(i.hidden=!0,i.removeAttribute("href"))),c){if(l)return Promise.resolve(!0);const w=n.getBoundingClientRect(),x=w.width>0?u.width/w.width:1,k=w.height>0?u.height/w.height:1;return n.style.transformOrigin="center center",n.style.transition="none",n.style.transform=`scale(${x}, ${k})`,n.getBoundingClientRect(),new Promise(H=>{let R=!1;const U=()=>{R||(R=!0,n.removeEventListener("transitionend",te),H(!0))},te=ne=>{ne.target!==n||ne.propertyName!=="transform"||U()};n.addEventListener("transitionend",te),requestAnimationFrame(()=>{n.style.transition="transform 0.48s cubic-bezier(0.22, 1, 0.36, 1)",n.style.transform="scale(1)"}),window.setTimeout(U,700)})}if(l)return new Promise(w=>{window.setTimeout(()=>w(!1),1e3)});const f=n.getBoundingClientRect(),y=f.width>0?u.width/f.width:1,g=f.height>0?u.height/f.height:1;return n.style.transformOrigin="center center",n.style.transition="none",n.style.transform=`scale(${y}, ${g})`,n.getBoundingClientRect(),new Promise(w=>{let x=!1;const k=()=>{x||(x=!0,n.removeEventListener("transitionend",H),window.setTimeout(()=>{t.style.transition="opacity 0.28s ease",t.style.opacity="0",window.setTimeout(()=>w(!1),280)},1e3))},H=R=>{R.target!==n||R.propertyName!=="transform"||k()};n.addEventListener("transitionend",H),requestAnimationFrame(()=>{n.style.transition="transform 0.48s cubic-bezier(0.22, 1, 0.36, 1)",n.style.transform="scale(1)"}),window.setTimeout(k,700)})}function sn(){ge=!1,we=!1,s.dialog&&(s.dialog.classList.remove("nf-success","nf-success-sticky"),s.dialog.style.opacity="",s.dialog.style.transition="",s.panel&&(s.panel.style.transform="",s.panel.style.transition="",s.panel.style.transformOrigin=""),s.panelBody&&(s.panelBody.hidden=!1),s.successMsg&&(s.successMsg.hidden=!0),s.successLink&&(s.successLink.hidden=!0,s.successLink.removeAttribute("href")))}function cn(e={}){B={...B,...gr(e)},Kt()}async function Ge(){if(je(),_e)return null;const e=s.text.value.trim();if(!e&&!K()&&!D)return S("Add a note, screenshot, or video first."),null;if(!d.endpoint||!d.projectKey)return S("Notefully is missing endpoint or projectKey."),null;_e=!0,ln(!0),S("Submitting…",!0);try{const t=hi(),n=new FormData;n.append("message",e),n.append("kind",z),n.append("version",d.version||"0.0.0"),n.append("author",t),d.name&&n.append("name",d.name),n.append("context",JSON.stringify(Ur({author:t,diagnostics:N,logs:O})));const r=m.crop(),a=m.list(),i=m.isCropped()?Ar(a,r):a;if(n.append("annotations",JSON.stringify(i)),Array.isArray(d.targets)&&n.append("targets",JSON.stringify(d.targets)),K()){const u=m.isCropped()?await Tr(P,r):await Kr(P);if(n.append("screenshot",u,"screenshot.png"),a.length){const f=await Pr(P,r,a,{mark:Pt("--nf-mark","#fdd341"),markText:Pt("--nf-mark-text","#2a2140")});n.append("screenshotBaked",f,"screenshot.baked.png")}}D&&n.append("recording",D,"recording.webm");const o=await fetch(`${d.endpoint}/v1/reports`,{method:"POST",headers:{"X-Notefully-Key":d.projectKey},body:n});let c=null;try{c=await o.json()}catch{c=null}if(!o.ok)throw S((c==null?void 0:c.error)||"Submit failed."),new Error((c==null?void 0:c.error)||`Submit failed (${o.status})`);return await mi((c==null?void 0:c.trackerUrl)||"")||J(),c}finally{_e=!1,ln(!1)}}function ln(e){s.submit&&(s.submit.disabled=!!e,s.submit.setAttribute("aria-busy",e?"true":"false"))}function un(){J(),document.removeEventListener("keydown",Xt),h==null||h.remove(),h=null,s={}}const Le={init:Qt,configure:Ce,setTheme:Zt,setVisible:en,open:Ye,close:J,isOpen:Jt,identify:cn,submit:Ge,destroy:un};return typeof window<"u"&&(window.Notefully=Le),C.close=J,C.configure=Ce,C.default=Le,C.destroy=un,C.identify=cn,C.init=Qt,C.isOpen=Jt,C.open=Ye,C.setTheme=Zt,C.setVisible=en,C.submit=Ge,Object.defineProperties(C,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),C})({});