@daybook/feedback 1.2.2 → 1.3.0

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
@@ -225,9 +225,33 @@ three days later when the reporter has moved on.
225
225
  - **Page and device** — route, title, referrer, locale, timezone, viewport with DPR, and a readable
226
226
  browser and OS rather than a raw user-agent string.
227
227
  - **Breadcrumbs** — the last 40 navigations, clicks, console errors and failed or slow requests.
228
+ - **The page itself**, as `page-snapshot.json`: the markup with its classes and attributes, the
229
+ computed style of the pinned element and its ancestors, everything floating over the page at that
230
+ moment, what had focus, where the page was scrolled to, and which stylesheets were readable.
231
+
232
+ This is the half of a report a screenshot cannot give you, and it needs no permission — it is the
233
+ page's own state, read by script that is already running on it. A picture is for a person; most
234
+ feedback now passes an assistant first, and to an assistant a PNG is nearly opaque where a DOM is
235
+ the whole answer.
236
+
237
+ It obeys `redact` exactly as everything else does: field values are described rather than
238
+ reproduced, and `data-daybook-private` subtrees are replaced by a marker. Script bodies are
239
+ dropped, attributes and text are capped, and the whole thing truncates rather than growing.
240
+
241
+ **What it does carry is the page's visible text**, because that is what the page is. On screens
242
+ showing personal data, decide whether that belongs in a report — `dom: false` turns it off, and
243
+ `data-daybook-private` withholds a subtree without turning the whole thing off.
228
244
  - **A screenshot**, if the reporter ticks "Capture the screen" and consents to the browser's share
229
245
  prompt. The widget hides itself for the frame, so the picture is of the page underneath rather
230
- than of the form that was just filled in.
246
+ than of the form that was just filled in — and if the reporter pinned an element, that element is
247
+ ringed in the picture.
248
+
249
+ The ring is the difference between a report you can act on and one you have to reconstruct. A
250
+ selector and a text snapshot tell you which node; they do not tell you which of the forty things
251
+ on that screen the sentence is about. It is drawn in the widget's own layer, never on your page:
252
+ no style of yours is touched, nothing reflows, and there is no undo to get wrong. The rest of the
253
+ page is left exactly as it was — no dimming — because the screenshot is also the record of what
254
+ the page looked like, and a report about a colour should not arrive with the colours changed.
231
255
 
232
256
  `screenshots` decides what the composer offers, and takes three values:
233
257
 
@@ -325,6 +349,32 @@ await pm.report('Checkout threw', { // a caught error, no user present
325
349
 
326
350
  `report()` takes no screenshot: there is nobody there to consent to a screen share.
327
351
 
352
+ ## The look is set in Daybook, not in code
353
+
354
+ Everything about the widget's appearance lives on the integration, so it is changed on the Feedback
355
+ widget page in Daybook and takes effect on every install of that key without a deploy:
356
+
357
+ | | |
358
+ |---|---|
359
+ | Button style | `pill`, `pill-icon`, `icon`, `text`, `outline` |
360
+ | Button text | Anything up to 24 characters. Defaults to "Feedback" |
361
+ | Colour scheme | `auto` (the default), `light`, `dark` |
362
+ | Corner | Bottom right by default — and `placement` in `init()` overrides it |
363
+ | Accent | Any CSS colour |
364
+
365
+ **Auto is the default and is the one to keep.** The widget is a guest on your page, and your page is
366
+ already light or dark for that reader; following their own setting is almost always right. Pin it
367
+ only when your app is one or the other regardless of the system.
368
+
369
+ The five button styles exist because one button cannot be right for every page. A product with its
370
+ own bold chat bubble does not want a second bold pill beside it; a spare documentation site does not
371
+ want a filled button at all; a dense application usually wants the smallest possible mark. All five
372
+ keep the same hit area in the same corner, so nothing else about the widget changes with the choice.
373
+
374
+ If you are building your own settings screen, `previewLauncher(element, theme)` draws the real
375
+ button — the real stylesheet, in a shadow root — so a preview cannot drift from the thing it
376
+ previews.
377
+
328
378
  ## Theming, but not styling
329
379
 
330
380
  The widget renders in a shadow root. A host page's `* { }` reset, its `button { all: unset }`, or its
package/dist/feedback.js CHANGED
@@ -1,22 +1,23 @@
1
- "use strict";var DaybookFeedback=(()=>{var P=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var me=Object.getOwnPropertyNames;var ge=Object.prototype.hasOwnProperty;var be=(n,e)=>{for(var t in e)P(n,t,{get:e[t],enumerable:!0})},ye=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of me(e))!ge.call(n,i)&&i!==t&&P(n,i,{get:()=>e[i],enumerable:!(o=fe(e,i))||o.enumerable});return n};var we=n=>ye(P({},"__esModule",{value:!0}),n);var ze={};be(ze,{DEFAULT_API_URL:()=>ue,DaybookFeedback:()=>R,captureAnchor:()=>_,init:()=>Be,resolveAnchor:()=>ae});function v(n){var e;try{let t=new URL(n,location.href);return t.origin===location.origin?t.pathname:`${t.origin}${t.pathname}`}catch{return(e=n.split("?")[0])!=null?e:n}}function F(n){var o,i,r,s,a,c;let e=n.tagName.toLowerCase();if(!n.getAttribute("aria-label")&&!n.getAttribute("data-testid")&&!((o=n.textContent)!=null?o:"").trim()){let l=n.closest("button, a, [role=button], [data-testid], label");if(l&&l!==n)return F(l)}if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement||n instanceof HTMLSelectElement){let l=(r=(i=n.getAttribute("name"))!=null?i:n.id)!=null?r:"",h=n instanceof HTMLInputElement?n.type:e;return`${e}[${h}]${l?` name=${l}`:""}`}let t=(c=(s=n.getAttribute("aria-label"))!=null?s:n.getAttribute("data-testid"))!=null?c:((a=n.textContent)!=null?a:"").replace(/\s+/g," ").trim().slice(0,40);return t?`${e} "${t}"`:e}function Q(n){return n.replace(/[\w.+-]+@[\w-]+\.[\w.]+/g,"[email]").replace(/\b[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g,"[jwt]").replace(/\bBearer\s+[\w.-]+/gi,"Bearer [redacted]").replace(/\b\d{12,19}\b/g,"[number]").slice(0,500)}var J="data-daybook-private";var k=class{constructor(e=40,t=!0){this.limit=e;this.redact=t;this.entries=[];this.detach=[]}list(){return[...this.entries]}add(e,t){for(this.entries.push({at:new Date().toISOString(),type:e,message:this.redact?Q(t):t.slice(0,500)});this.entries.length>this.limit;)this.entries.shift()}start(){let e=a=>{let c=a.target;c instanceof Element&&(c.closest("[data-daybook-feedback]")||this.add("click",F(c)))};document.addEventListener("click",e,{capture:!0,passive:!0}),this.detach.push(()=>document.removeEventListener("click",e,{capture:!0}));let t=history.pushState,o=history.replaceState,i=()=>this.add("nav",v(location.href));history.pushState=(...a)=>{t.apply(history,a),i()},history.replaceState=(...a)=>{o.apply(history,a),i()},window.addEventListener("popstate",i),this.detach.push(()=>{history.pushState=t,history.replaceState=o,window.removeEventListener("popstate",i)});for(let a of["error","warn"]){let c=console[a];console[a]=(...l)=>{this.add("console",`${a}: ${l.map(I).join(" ")}`),c.apply(console,l)},this.detach.push(()=>{console[a]=c})}let r=a=>this.add("console",`uncaught: ${a.message}`),s=a=>this.add("console",`unhandled rejection: ${I(a.reason)}`);window.addEventListener("error",r),window.addEventListener("unhandledrejection",s),this.detach.push(()=>{window.removeEventListener("error",r),window.removeEventListener("unhandledrejection",s)}),this.watchFetch()}stop(){for(let e of this.detach.splice(0))e()}watchFetch(){if(typeof window.fetch!="function")return;let e=window.fetch;window.fetch=async(...t)=>{let o=performance.now();try{let i=await e.apply(window,t),r=Math.round(performance.now()-o);return(!i.ok||r>3e3)&&this.add("network",`${i.status} ${v(G(t[0]))} ${r}ms`),i}catch(i){throw this.add("network",`failed ${v(G(t[0]))}: ${I(i)}`),i}},this.detach.push(()=>{window.fetch=e})}};function G(n){return typeof n=="string"?n:n instanceof URL?n.href:n.url}function I(n){var e,t;if(typeof n=="string")return n;if(n instanceof Error)return`${n.name}: ${n.message}`;try{return(t=(e=JSON.stringify(n))==null?void 0:e.slice(0,200))!=null?t:String(n)}catch{return String(n)}}var O="pm.feedback.queue";var T=class{constructor(e,t){this.apiUrl=e;this.ingestKey=t;this.session=null;this.identityToken=null}setSession(e){this.session=e}async send(e,t=[],o){var c,l,h;let i={idempotencyKey:(c=e.idempotencyKey)!=null?c:Z(),...e,attachments:[...(l=e.attachments)!=null?l:[],...t.map(p=>({filename:p.filename,contentType:p.contentType,size:p.blob.size}))]},r=await this.post("/ingest/v1",i);if(!r.ok)throw await E(r);let s=await r.json(),a=((h=e.attachments)!=null?h:[]).length;return await Promise.all(t.map(async(p,g)=>{let b=ve(s,a+g);if(!b){o==null||o(p,new Error("The server would not accept that file."));return}try{await this.upload(b,p)}catch(w){o==null||o(p,w)}})),s}async flush(){let e=te();if(e.length!==0){ne([]);for(let t of e)try{let o=await this.post("/ingest/v1",t);!o.ok&&(o.status===429||o.status>=500)&&j(t)}catch{j(t)}}}queue(e){var t;j({...e,idempotencyKey:(t=e.idempotencyKey)!=null?t:Z(),attachments:void 0})}async signIn(){let e=ee(64),t=await xe(e),o=ee(16),i=`${this.base()}/ingest/v1/authorize?key=${encodeURIComponent(this.ingestKey)}&origin=${encodeURIComponent(location.origin)}&code_challenge=${encodeURIComponent(t)}&state=${encodeURIComponent(o)}`,r=window.open(i,"daybook-feedback","width=460,height=640");if(!r)throw Object.assign(new Error("Popup blocked"),{code:"popup_blocked"});let s=await new Promise((l,h)=>{let p=setInterval(()=>{r.closed&&(b(),h(Object.assign(new Error("Sign-in cancelled"),{code:"cancelled"})))},400),g=w=>{if(w.origin!==new URL(this.base()).origin)return;let m=w.data;if((m==null?void 0:m.source)==="daybook-feedback"&&m.state===o){if(b(),m.error||!m.code){h(Object.assign(new Error("Sign-in was refused"),{code:m.error||"refused"}));return}l(m.code)}},b=()=>{clearInterval(p),window.removeEventListener("message",g)};window.addEventListener("message",g)}),a=await this.post("/ingest/v1/token",{code:s,codeVerifier:e});if(!a.ok)throw await E(a);let{identityToken:c}=await a.json();return this.identityToken=c,c}base(){return this.apiUrl.replace(/\/$/,"")}resolve(e){try{let t=new URL(this.base()),o=new URL(e,t);return o.hostname===t.hostname?new URL(o.pathname+o.search,t).toString():o.toString()}catch{return e}}async handshake(e){var i,r;let t=await this.post("/ingest/v1/session",{...e,identityToken:(i=this.identityToken)!=null?i:void 0});if(!t.ok)throw await E(t);let o=await t.json();return this.session=(r=o.sessionToken)!=null?r:null,o}post(e,t){let o={"Content-Type":"application/json","X-Ingest-Key":this.ingestKey};return this.session&&(o["X-Feedback-Session"]=this.session),fetch(`${this.base()}${e}`,{method:"POST",headers:o,body:JSON.stringify(t),credentials:"omit"})}async upload(e,t){let o=await fetch(this.resolve(e.uploadUrl),{method:e.method,headers:{"Content-Type":e.contentType,"X-Ingest-Key":this.ingestKey},body:t.blob,credentials:"omit"});if(!o.ok)throw await E(o);await this.post(`/ingest/v1/attachments/${e.id}/confirm`,{})}};function ve(n,e){let t=n.attachments.find(o=>o.index===e);return t!=null?t:n.attachments.some(o=>typeof o.index=="number")?void 0:n.attachments[e]}function j(n){let e=te();e.push(n),ne(e.slice(-20))}function te(){try{let n=localStorage.getItem(O);return n?JSON.parse(n):[]}catch{return[]}}function ne(n){try{n.length===0?localStorage.removeItem(O):localStorage.setItem(O,JSON.stringify(n))}catch{}}async function E(n){let e=`http_${n.status}`;try{let t=await n.json();if(t.code&&(e=t.code),t.message)return Object.assign(new Error(t.message),{code:e})}catch{}return Object.assign(new Error(`Ingest failed (${n.status})`),{code:e})}function Z(){return typeof crypto!="undefined"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function ee(n){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",t=new Uint8Array(n);return crypto.getRandomValues(t),Array.from(t,o=>e[o%e.length]).join("")}async function xe(n){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(n));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function q(n){var t;let e={platform:"web",route:location.pathname,title:document.title.slice(0,200),locale:navigator.language,timezone:Ee(),viewport:{width:window.innerWidth,height:window.innerHeight,dpr:(t=window.devicePixelRatio)!=null?t:1},device:ke()};return document.referrer&&(e.referrer=v(document.referrer)),n.app&&(e.app=n.app),n.anchor&&(e.anchor=n.anchor),n.breadcrumbs&&n.breadcrumbs.length>0&&(e.breadcrumbs=n.breadcrumbs),e}function ke(){var i;let n=navigator.userAgent,e=/Edg\//.test(n)?"Edge":/OPR\//.test(n)?"Opera":/Firefox\//.test(n)?"Firefox":/Chrome\//.test(n)?"Chrome":/Safari\//.test(n)?"Safari":"Unknown",t=/Windows NT/.test(n)?"Windows":/iPhone|iPad|iPod/.test(n)?"iOS":/Mac OS X/.test(n)?"macOS":/Android/.test(n)?"Android":/Linux/.test(n)?"Linux":"Unknown",o=(i=n.match(/(?:Edg|OPR|Firefox|Chrome|Version)\/(\d+)/))==null?void 0:i[1];return{browser:o?`${e} ${o}`:e,os:t,touch:navigator.maxTouchPoints>0,userAgent:n.slice(0,300)}}function Ee(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return`UTC${-new Date().getTimezoneOffset()/60}`}}async function re(n,e=()=>()=>{}){var r;if(typeof((r=navigator.mediaDevices)==null?void 0:r.getDisplayMedia)!="function")return null;let t=n?_e():()=>{},o=e(),i=null;try{return i=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude",monitorTypeSurfaces:"exclude"}),i.getVideoTracks()[0]?(await new Promise(a=>setTimeout(a,250)),await Le(i)):null}catch{return null}finally{i==null||i.getTracks().forEach(s=>s.stop()),o(),t()}}var oe=1920,Te=.82;async function Le(n){let e=document.createElement("video");e.srcObject=n,e.muted=!0,await e.play().catch(()=>{});let t=e.videoWidth||window.innerWidth,o=e.videoHeight||window.innerHeight,i=t>oe?oe/t:1,r=document.createElement("canvas");r.width=Math.round(t*i),r.height=Math.round(o*i);let s=r.getContext("2d");if(!s)return null;s.imageSmoothingQuality="high",s.drawImage(e,0,0,r.width,r.height),e.pause(),e.srcObject=null;let a=await Se(r);if(!a)return null;let c=a.type||"image/png";return{blob:a,filename:`screenshot.${c==="image/webp"?"webp":c==="image/jpeg"?"jpg":"png"}`,contentType:c}}async function Se(n){for(let e of["image/webp","image/jpeg"]){let t=await ie(n,e,Te);if((t==null?void 0:t.type)===e)return t}return ie(n,"image/png")}function ie(n,e,t){return new Promise(o=>n.toBlob(i=>o(i),e,t))}function _e(){let n=[...document.querySelectorAll(`[${J}]`),...document.querySelectorAll('input[type="password"]')],e=n.map(t=>t.style.filter);return n.forEach(t=>{t.style.filter="blur(12px)"}),()=>{n.forEach((t,o)=>{var i;t.style.filter=(i=e[o])!=null?i:""})}}function _(n,e){let t=document.elementFromPoint(n,e);if(!(t instanceof HTMLElement))return{selector:null,offsetX:S(n/window.innerWidth),offsetY:S(e/window.innerHeight),elementText:null};let o=t.getBoundingClientRect();return{selector:Me(t),offsetX:o.width>0?S((n-o.left)/o.width):0,offsetY:o.height>0?S((e-o.top)/o.height):0,elementText:$e(t)}}function ae(n){if(!n.selector)return{x:n.offsetX*window.innerWidth,y:n.offsetY*window.innerHeight};let e=null;try{e=document.querySelector(n.selector)}catch{return null}if(!e)return null;let t=e.getBoundingClientRect();return{x:t.left+n.offsetX*t.width,y:t.top+n.offsetY*t.height}}function Me(n){if(n===document.body)return"body";for(let i of["data-testid","data-test","data-daybook-id","data-cy"]){let r=n.getAttribute(i);if(r){let s=`[${i}="${B(r)}"]`;if(L(s))return s}}if(n.id&&!se(n.id)){let i=`#${B(n.id)}`;if(L(i))return i}let e=[],t=n;for(;t&&t!==document.body&&e.length<8;){let i=t.tagName.toLowerCase(),r=Array.from(t.classList).filter(c=>!se(c)).slice(0,2);r.length>0&&(i+=r.map(c=>`.${B(c)}`).join(""));let s=t.parentElement;if(s){let c=Array.from(s.children).filter(l=>l.tagName===t.tagName);c.length>1&&(i+=`:nth-of-type(${c.indexOf(t)+1})`)}e.unshift(i);let a=e.join(" > ");if(L(a))return a;t=s}let o=e.length>0?`body > ${e.join(" > ")}`:null;return o&&L(o)?o:null}function L(n){try{return document.querySelectorAll(n).length===1}catch{return!1}}function se(n){return/^[a-z]{1,3}[0-9a-f]{5,}$/i.test(n)||/--[0-9a-f]{5,}$/i.test(n)||/^_[0-9a-z]{5,}/i.test(n)||/^v-[0-9a-f]{6,}$/i.test(n)||/^ng-/.test(n)||/[0-9a-f]{8,}/i.test(n)}function $e(n){var o,i,r;let t=((i=(o=n.innerText)!=null?o:n.textContent)!=null?i:"").replace(/\s+/g," ").trim();if(!t){let s=(r=n.getAttribute("aria-label"))!=null?r:n.getAttribute("title");return(s==null?void 0:s.trim())||null}return t.length>80?`${t.slice(0,77)}\u2026`:t}function S(n){return Number.isFinite(n)?Math.max(0,Math.min(1,n)):0}function B(n){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(n):n.replace(/([^\w-])/g,"\\$1")}var Ae=/^(image\/(png|jpeg|gif|webp)|video\/(mp4|quicktime|webm))$/;function ce(n,e){let t=[];for(let o of n){if(e+t.length>=5)break;let i=Ae.test(o.type)?o.size>26214400?`Too large (${(o.size/1048576).toFixed(1)} MB, max 25).`:null:"Only images and short videos.";t.push({blob:o,filename:o.name||`pasted-${t.length+1}.${Re(o.type)}`,contentType:o.type,preview:i?null:URL.createObjectURL(o),error:i})}return t}function le(n){var o;let e=(o=n.clipboardData)==null?void 0:o.items;if(!e)return[];let t=[];for(let i of e){if(i.kind!=="file")continue;let r=i.getAsFile();r&&t.push(r)}return t}function M(n){for(let e of n)e.preview&&URL.revokeObjectURL(e.preview)}function Re(n){var e,t;return(t=(e=n.split("/")[1])==null?void 0:e.replace("quicktime","mov"))!=null?t:"bin"}function de(n){var o;let t=(o=(typeof n.composedPath=="function"?n.composedPath():[])[0])!=null?o:n.target;return!t||t.nodeType!==1?!1:/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)?!0:typeof t.closest=="function"&&t.closest('[contenteditable=""], [contenteditable="true"]')!==null}function He(n,e,t){let o=0;for(let s of e){if(s.right<=n.left||s.left>=n.right)continue;let a=n.v==="bottom"?t.height-s.top:s.bottom;a>o&&(o=a)}if(o===0)return 0;let i=n.v==="bottom"?t.height-n.bottom:n.top,r=Math.round(o+12-i);return r<=0||r>t.height*.35?0:r}function Ce(n,e,t){if(n===e||e.contains(n)||n.contains(e)||n===document.body||n===document.documentElement)return!1;let o=getComputedStyle(n);if(o.position!=="fixed"&&o.position!=="sticky"||o.visibility==="hidden"||o.display==="none"||Number(o.opacity)===0)return!1;let i=n.getBoundingClientRect();return!(i.width<8||i.height<8||i.width*i.height>t.width*t.height*.25)}function Pe(n,e,t){if(typeof document.elementsFromPoint!="function")return[];let o=new Map,i=[];for(let s=n.left+4;s<n.right;s+=32)i.push(s);i.push(n.right-4);let r=t.height*.35;for(let s=0;s<=r;s+=32){let a=n.v==="bottom"?n.bottom-s:n.top+s;if(a<0||a>t.height)break;for(let c of i)if(!(c<0||c>t.width))for(let l of document.elementsFromPoint(c,a)){if(o.has(l)||!Ce(l,e,t))continue;let h=l.getBoundingClientRect();o.set(l,{top:h.top,bottom:h.bottom,left:h.left,right:h.right})}}return[...o.values()]}function pe(n,e){let t={width:window.innerWidth,height:window.innerHeight};return He(n,Pe(n,e,t),t)}var A=class{constructor(e,t){this.options=e;this.onSubmit=t;this.mode="idle";this.anchor=null;this.detach=[];this.clearance=0;this.state="ready";this.policy=null;this.dragged=null;this.reference=null;this.uploadsFailed=0;this.host=document.createElement("div"),this.host.setAttribute("data-daybook-feedback",""),this.host.style.cssText="position:fixed;inset:0;z-index:2147483000;pointer-events:none",this.root=this.host.attachShadow({mode:"open"}),this.root.innerHTML=`<style>${qe}</style><style id="theme"></style><style id="place"></style><div id="layer"></div>`}setTheme(e){var r;let t=this.root.getElementById("theme");if(!t)return;if(!e){t.textContent="";return}let o=[];Oe(e.accent)&&o.push(`--pm-accent: ${e.accent}`);let i={none:"0",sm:"6px",md:"12px",lg:"18px"}[(r=e.cornerRadius)!=null?r:"md"];i&&o.push(`--pm-radius: ${i}`),t.textContent=o.length>0?`:host { ${o.join("; ")} }`:"",this.themePlacement=e.position,this.applyPlacement(),this.launcherLabel=typeof e.launcherLabel=="string"&&e.launcherLabel.length>0?e.launcherLabel.slice(0,24):void 0}get placement(){var e,t;return(t=(e=this.options.placement)!=null?e:this.themePlacement)!=null?t:"bottom-right"}applyPlacement(){let e=this.root.getElementById("place");if(!e)return;let t=this.placement,o=t.startsWith("bottom")?"bottom":"top",i=t.endsWith("right")?"right":"left",r=f+this.clearance;e.textContent=`:host {
2
- --pm-${i}: ${f}px; --pm-${i==="right"?"left":"right"}: auto;
3
- --pm-${o}: ${r}px; --pm-${o==="bottom"?"top":"bottom"}: auto;
4
- }`}homeSlot(){let e=this.placement,t=220,o=48,i=e.endsWith("right")?window.innerWidth-f:f+t,r=e.startsWith("bottom")?window.innerHeight-f:f+o;return{left:i-t,right:i,top:r-o,bottom:r,v:e.startsWith("bottom")?"bottom":"top"}}watchClearance(){if(this.options.avoidOverlap===!1)return;let e=!1,t=()=>{if(e=!1,this.mode==="idle")try{let r=pe(this.homeSlot(),this.host);if(Math.abs(r-this.clearance)<4)return;this.clearance=r,this.applyPlacement()}catch{}},o=typeof requestAnimationFrame=="function"?r=>requestAnimationFrame(r):r=>setTimeout(r,16),i=()=>{e||(e=!0,o(t))};if(window.addEventListener("scroll",i,{passive:!0,capture:!0}),window.addEventListener("resize",i),this.detach.push(()=>{window.removeEventListener("scroll",i,{capture:!0}),window.removeEventListener("resize",i)}),typeof MutationObserver=="function"){let r=new MutationObserver(i);r.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class","hidden"]}),this.detach.push(()=>r.disconnect())}i()}setState(e){this.state=e,this.host.isConnected&&this.render()}mount(){var e;if(document.body.appendChild(this.host),this.applyPlacement(),this.render(),this.watchClearance(),this.options.hotkey!==null){let t=((e=this.options.hotkey)!=null?e:"f").toLowerCase(),o=i=>{if(i.key==="Escape"){this.mode==="picking"&&(this.mode="idle",this.anchor=null,this.dragged=null,this.render());return}i.metaKey||i.ctrlKey||i.altKey||de(i)||this.mode!=="composing"&&i.key.toLowerCase()===t&&(this.mode=this.mode==="picking"?"idle":"picking",this.render())};window.addEventListener("keydown",o),this.detach.push(()=>window.removeEventListener("keydown",o))}}unmount(){for(let e of this.detach.splice(0))e();this.host.remove()}open(){this.mode="picking",this.render()}setReporter(e){this.reporter=e}setPolicy(e){this.policy=e}capture(){var t,o;let e=(t=this.options.screenshots)!=null?t:!0;return e===!1||((o=this.policy)==null?void 0:o.screenshots)===!1?{offered:!1,checked:!1}:{offered:!0,checked:e!=="optional"}}conceal(){let e=this.host.style.visibility;return this.host.style.visibility="hidden",()=>{this.host.style.visibility=e}}movable(e,t){this.place(e),t.classList.add("drag"),t.title="Drag to move \xB7 double-click to reset",t.addEventListener("dblclick",()=>{this.dragged=null,this.place(e)}),t.addEventListener("pointerdown",o=>{if(o.target.closest("button")||o.button!==0)return;o.preventDefault();let i=e.getBoundingClientRect(),r=o.clientX-i.left,s=o.clientY-i.top;t.setPointerCapture(o.pointerId),e.classList.add("panel--dragging");let a=l=>{let h=$(l.clientX-r,f-i.width+U,window.innerWidth-U),p=$(l.clientY-s,0,window.innerHeight-U);e.style.left=`${h}px`,e.style.top=`${p}px`,e.style.right="auto",e.style.bottom="auto"},c=()=>{t.releasePointerCapture(o.pointerId),t.removeEventListener("pointermove",a),t.removeEventListener("pointerup",c),t.removeEventListener("pointercancel",c),e.classList.remove("panel--dragging"),this.dragged=je(e.getBoundingClientRect()),this.place(e)};t.addEventListener("pointermove",a),t.addEventListener("pointerup",c),t.addEventListener("pointercancel",c)})}place(e){let t=this.dragged;if(!t){e.style.left=e.style.right=e.style.top=e.style.bottom="";return}let o=e.offsetWidth||380,i=e.offsetHeight||240,r=$(t.dx,f,Math.max(f,window.innerWidth-o-f)),s=$(t.dy,f,Math.max(f,window.innerHeight-i-f));e.style.left=t.h==="left"?`${r}px`:"auto",e.style.right=t.h==="right"?`${r}px`:"auto",e.style.top=t.v==="top"?`${s}px`:"auto",e.style.bottom=t.v==="bottom"?`${s}px`:"auto"}render(){let e=this.root.getElementById("layer");if(e.innerHTML="",this.mode==="idle"){e.appendChild(this.state==="pending"?this.pending():this.launcher());return}if(this.mode==="sent"){this.dragged=null,e.appendChild(this.sent());return}if(this.mode==="picking"){e.appendChild(this.picker());return}let t=this.composer();e.appendChild(t),this.place(t)}pending(){let e=document.createElement("div");return e.className="launcher launcher--pending",e.setAttribute("role","status"),e.textContent="Feedback access pending approval",e}sent(){var c;let e=document.createElement("div");e.className="panel panel--sent",e.setAttribute("role","status");let t=this.reference,o=this.uploadsFailed;e.innerHTML=`
1
+ "use strict";var DaybookFeedback=(()=>{var P=Object.defineProperty;var Ce=Object.getOwnPropertyDescriptor;var He=Object.getOwnPropertyNames;var Ie=Object.prototype.hasOwnProperty;var Fe=(n,e)=>{for(var t in e)P(n,t,{get:e[t],enumerable:!0})},Pe=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of He(e))!Ie.call(n,r)&&r!==t&&P(n,r,{get:()=>e[r],enumerable:!(o=Ce(e,r))||o.enumerable});return n};var je=n=>Pe(P({},"__esModule",{value:!0}),n);var gt={};Fe(gt,{DEFAULT_API_URL:()=>Re,DaybookFeedback:()=>I,captureAnchor:()=>$,init:()=>mt,previewLauncher:()=>_e,resolveAnchor:()=>ye});function x(n){var e;try{let t=new URL(n,location.href);return t.origin===location.origin?t.pathname:`${t.origin}${t.pathname}`}catch{return(e=n.split("?")[0])!=null?e:n}}var Be=/pass|secret|token|auth|cvv|card|ssn|pin|otp|key/i;function ne(n,e){return n.length===0?"":e&&Be.test(e)?"[redacted]":`[${n.length} chars]`}function j(n){var o,r,i,s,a,c;let e=n.tagName.toLowerCase();if(!n.getAttribute("aria-label")&&!n.getAttribute("data-testid")&&!((o=n.textContent)!=null?o:"").trim()){let l=n.closest("button, a, [role=button], [data-testid], label");if(l&&l!==n)return j(l)}if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement||n instanceof HTMLSelectElement){let l=(i=(r=n.getAttribute("name"))!=null?r:n.id)!=null?i:"",u=n instanceof HTMLInputElement?n.type:e;return`${e}[${u}]${l?` name=${l}`:""}`}let t=(c=(s=n.getAttribute("aria-label"))!=null?s:n.getAttribute("data-testid"))!=null?c:((a=n.textContent)!=null?a:"").replace(/\s+/g," ").trim().slice(0,40);return t?`${e} "${t}"`:e}function oe(n){return n.replace(/[\w.+-]+@[\w-]+\.[\w.]+/g,"[email]").replace(/\b[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g,"[jwt]").replace(/\bBearer\s+[\w.-]+/gi,"Bearer [redacted]").replace(/\b\d{12,19}\b/g,"[number]").slice(0,500)}var k="data-daybook-private";var T=class{constructor(e=40,t=!0){this.limit=e;this.redact=t;this.entries=[];this.detach=[]}list(){return[...this.entries]}add(e,t){for(this.entries.push({at:new Date().toISOString(),type:e,message:this.redact?oe(t):t.slice(0,500)});this.entries.length>this.limit;)this.entries.shift()}start(){let e=a=>{let c=a.target;c instanceof Element&&(c.closest("[data-daybook-feedback]")||this.add("click",j(c)))};document.addEventListener("click",e,{capture:!0,passive:!0}),this.detach.push(()=>document.removeEventListener("click",e,{capture:!0}));let t=history.pushState,o=history.replaceState,r=()=>this.add("nav",x(location.href));history.pushState=(...a)=>{t.apply(history,a),r()},history.replaceState=(...a)=>{o.apply(history,a),r()},window.addEventListener("popstate",r),this.detach.push(()=>{history.pushState=t,history.replaceState=o,window.removeEventListener("popstate",r)});for(let a of["error","warn"]){let c=console[a];console[a]=(...l)=>{this.add("console",`${a}: ${l.map(B).join(" ")}`),c.apply(console,l)},this.detach.push(()=>{console[a]=c})}let i=a=>this.add("console",`uncaught: ${a.message}`),s=a=>this.add("console",`unhandled rejection: ${B(a.reason)}`);window.addEventListener("error",i),window.addEventListener("unhandledrejection",s),this.detach.push(()=>{window.removeEventListener("error",i),window.removeEventListener("unhandledrejection",s)}),this.watchFetch()}stop(){for(let e of this.detach.splice(0))e()}watchFetch(){if(typeof window.fetch!="function")return;let e=window.fetch;window.fetch=async(...t)=>{let o=performance.now();try{let r=await e.apply(window,t),i=Math.round(performance.now()-o);return(!r.ok||i>3e3)&&this.add("network",`${r.status} ${x(re(t[0]))} ${i}ms`),r}catch(r){throw this.add("network",`failed ${x(re(t[0]))}: ${B(r)}`),r}},this.detach.push(()=>{window.fetch=e})}};function re(n){return typeof n=="string"?n:n instanceof URL?n.href:n.url}function B(n){var e,t;if(typeof n=="string")return n;if(n instanceof Error)return`${n.name}: ${n.message}`;try{return(t=(e=JSON.stringify(n))==null?void 0:e.slice(0,200))!=null?t:String(n)}catch{return String(n)}}var q="pm.feedback.queue";var L=class{constructor(e,t){this.apiUrl=e;this.ingestKey=t;this.session=null;this.identityToken=null}setSession(e){this.session=e}async send(e,t=[],o){var c,l,u;let r={idempotencyKey:(c=e.idempotencyKey)!=null?c:ie(),...e,attachments:[...(l=e.attachments)!=null?l:[],...t.map(h=>({filename:h.filename,contentType:h.contentType,size:h.blob.size}))]},i=await this.post("/ingest/v1",r);if(!i.ok)throw await S(i);let s=await i.json(),a=((u=e.attachments)!=null?u:[]).length;return await Promise.all(t.map(async(h,d)=>{let m=Oe(s,a+d);if(!m){o==null||o(h,new Error("The server would not accept that file."));return}try{await this.upload(m,h)}catch(y){o==null||o(h,y)}})),s}async flush(){let e=ae();if(e.length!==0){ce([]);for(let t of e)try{let o=await this.post("/ingest/v1",t);!o.ok&&(o.status===429||o.status>=500)&&O(t)}catch{O(t)}}}queue(e){var t;O({...e,idempotencyKey:(t=e.idempotencyKey)!=null?t:ie(),attachments:void 0})}async signIn(){let e=se(64),t=await qe(e),o=se(16),r=`${this.base()}/ingest/v1/authorize?key=${encodeURIComponent(this.ingestKey)}&origin=${encodeURIComponent(location.origin)}&code_challenge=${encodeURIComponent(t)}&state=${encodeURIComponent(o)}`,i=window.open(r,"daybook-feedback","width=460,height=640");if(!i)throw Object.assign(new Error("Popup blocked"),{code:"popup_blocked"});let s=await new Promise((l,u)=>{let h=setInterval(()=>{i.closed&&(m(),u(Object.assign(new Error("Sign-in cancelled"),{code:"cancelled"})))},400),d=y=>{if(y.origin!==new URL(this.base()).origin)return;let b=y.data;if((b==null?void 0:b.source)==="daybook-feedback"&&b.state===o){if(m(),b.error||!b.code){u(Object.assign(new Error("Sign-in was refused"),{code:b.error||"refused"}));return}l(b.code)}},m=()=>{clearInterval(h),window.removeEventListener("message",d)};window.addEventListener("message",d)}),a=await this.post("/ingest/v1/token",{code:s,codeVerifier:e});if(!a.ok)throw await S(a);let{identityToken:c}=await a.json();return this.identityToken=c,c}base(){return this.apiUrl.replace(/\/$/,"")}resolve(e){try{let t=new URL(this.base()),o=new URL(e,t);return o.hostname===t.hostname?new URL(o.pathname+o.search,t).toString():o.toString()}catch{return e}}async handshake(e){var r,i;let t=await this.post("/ingest/v1/session",{...e,identityToken:(r=this.identityToken)!=null?r:void 0});if(!t.ok)throw await S(t);let o=await t.json();return this.session=(i=o.sessionToken)!=null?i:null,o}post(e,t){let o={"Content-Type":"application/json","X-Ingest-Key":this.ingestKey};return this.session&&(o["X-Feedback-Session"]=this.session),fetch(`${this.base()}${e}`,{method:"POST",headers:o,body:JSON.stringify(t),credentials:"omit"})}async upload(e,t){let o=await fetch(this.resolve(e.uploadUrl),{method:e.method,headers:{"Content-Type":e.contentType,"X-Ingest-Key":this.ingestKey},body:t.blob,credentials:"omit"});if(!o.ok)throw await S(o);await this.post(`/ingest/v1/attachments/${e.id}/confirm`,{})}};function Oe(n,e){let t=n.attachments.find(o=>o.index===e);return t!=null?t:n.attachments.some(o=>typeof o.index=="number")?void 0:n.attachments[e]}function O(n){let e=ae();e.push(n),ce(e.slice(-20))}function ae(){try{let n=localStorage.getItem(q);return n?JSON.parse(n):[]}catch{return[]}}function ce(n){try{n.length===0?localStorage.removeItem(q):localStorage.setItem(q,JSON.stringify(n))}catch{}}async function S(n){let e=`http_${n.status}`;try{let t=await n.json();if(t.code&&(e=t.code),t.message)return Object.assign(new Error(t.message),{code:e})}catch{}return Object.assign(new Error(`Ingest failed (${n.status})`),{code:e})}function ie(){return typeof crypto!="undefined"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function se(n){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",t=new Uint8Array(n);return crypto.getRandomValues(t),Array.from(t,o=>e[o%e.length]).join("")}async function qe(n){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(n));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function U(n){var t;let e={platform:"web",route:location.pathname,title:document.title.slice(0,200),locale:navigator.language,timezone:Ne(),viewport:{width:window.innerWidth,height:window.innerHeight,dpr:(t=window.devicePixelRatio)!=null?t:1},device:Ue()};return document.referrer&&(e.referrer=x(document.referrer)),n.app&&(e.app=n.app),n.anchor&&(e.anchor=n.anchor),n.breadcrumbs&&n.breadcrumbs.length>0&&(e.breadcrumbs=n.breadcrumbs),e}function Ue(){var r;let n=navigator.userAgent,e=/Edg\//.test(n)?"Edge":/OPR\//.test(n)?"Opera":/Firefox\//.test(n)?"Firefox":/Chrome\//.test(n)?"Chrome":/Safari\//.test(n)?"Safari":"Unknown",t=/Windows NT/.test(n)?"Windows":/iPhone|iPad|iPod/.test(n)?"iOS":/Mac OS X/.test(n)?"macOS":/Android/.test(n)?"Android":/Linux/.test(n)?"Linux":"Unknown",o=(r=n.match(/(?:Edg|OPR|Firefox|Chrome|Version)\/(\d+)/))==null?void 0:r[1];return{browser:o?`${e} ${o}`:e,os:t,touch:navigator.maxTouchPoints>0,userAgent:n.slice(0,300)}}function Ne(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return`UTC${-new Date().getTimezoneOffset()/60}`}}async function pe(n,e=()=>()=>{}){var i;if(typeof((i=navigator.mediaDevices)==null?void 0:i.getDisplayMedia)!="function")return null;let t=n?Ke():()=>{},o=e(),r=null;try{return r=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude",monitorTypeSurfaces:"exclude"}),r.getVideoTracks()[0]?(await new Promise(a=>setTimeout(a,250)),await De(r)):null}catch{return null}finally{r==null||r.getTracks().forEach(s=>s.stop()),o(),t()}}var le=1920,ze=.82;async function De(n){let e=document.createElement("video");e.srcObject=n,e.muted=!0,await e.play().catch(()=>{});let t=e.videoWidth||window.innerWidth,o=e.videoHeight||window.innerHeight,r=t>le?le/t:1,i=document.createElement("canvas");i.width=Math.round(t*r),i.height=Math.round(o*r);let s=i.getContext("2d");if(!s)return null;s.imageSmoothingQuality="high",s.drawImage(e,0,0,i.width,i.height),e.pause(),e.srcObject=null;let a=await Xe(i);if(!a)return null;let c=a.type||"image/png";return{blob:a,filename:`screenshot.${c==="image/webp"?"webp":c==="image/jpeg"?"jpg":"png"}`,contentType:c}}async function Xe(n){for(let e of["image/webp","image/jpeg"]){let t=await de(n,e,ze);if((t==null?void 0:t.type)===e)return t}return de(n,"image/png")}function de(n,e,t){return new Promise(o=>n.toBlob(r=>o(r),e,t))}function Ke(){let n=[...document.querySelectorAll(`[${k}]`),...document.querySelectorAll('input[type="password"]')],e=n.map(t=>t.style.filter);return n.forEach(t=>{t.style.filter="blur(12px)"}),()=>{n.forEach((t,o)=>{var r;t.style.filter=(r=e[o])!=null?r:""})}}var z=4e5,ue=300,he=600,me=8e3,We=new Set(["SCRIPT","NOSCRIPT","TEMPLATE"]),Ve=["display","position","z-index","opacity","visibility","overflow","width","height","margin","padding","box-sizing","color","background-color","border","border-radius","box-shadow","font-family","font-size","font-weight","line-height","text-align","white-space","flex-direction","justify-content","align-items","gap","grid-template-columns","transform","transition","pointer-events","cursor"],Ye="The page at the moment this was reported. Field values are described rather than reproduced when redacted is true, and data-daybook-private subtrees are withheld. html is last because only the head of this file is inlined beside the report \u2014 download the attachment for the rest of it.";function D(n){let e=[],t=n;for(let o=0;t&&o<4&&t.nodeType===1;o+=1){let r=t.localName;if(t.id){e.unshift(`${r}#${t.id}`);break}let i=Array.from(t.classList).slice(0,3).join(".");i&&(r+=`.${i}`),e.unshift(r),t=t.parentElement}return e.join(" > ")}var Je=(n,e)=>e.length>ue?`${e.slice(0,ue)}\u2026[${e.length}]`:e,N=n=>n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function Qe(n,e){let t=n;if(n.localName==="input"&&(t.type==="checkbox"||t.type==="radio"))return t.checked?"checked":"unchecked";let o=t.value;return typeof o!="string"||o===""?null:e?ne(o,t.name||t.id||t.type):o}function fe(n,e,t,o){var u,h;if(t.used>z)return!1;if(n.nodeType===3){let d=((u=n.textContent)!=null?u:"").replace(/\s+/g," ");if(!d.trim())return!0;let m=d.length>he?`${d.slice(0,he)}\u2026`:d;return e.push(N(m)),t.used+=m.length,!0}if(n.nodeType!==1)return!0;let r=n,i=r.tagName;if(r.hasAttribute("data-daybook-feedback")||We.has(i))return!0;let s=r.localName;if(o&&r.hasAttribute(k))return e.push(`<${s} ${k}>[withheld]</${s}>`),t.used+=32,!0;let a=[];for(let d of Array.from(r.attributes))d.name!=="value"&&a.push(`${d.name}="${N(Je(d.name,d.value))}"`);let c=Qe(r,o);c!==null&&a.push(`value="${N(c)}"`);let l=a.length>0?`<${s} ${a.join(" ")}>`:`<${s}>`;if(e.push(l),t.used+=l.length,s==="style"){let d=(h=r.textContent)!=null?h:"",m=d.length>me?`${d.slice(0,me)}
2
+ /* \u2026${d.length} chars */`:d;e.push(m),t.used+=m.length}else for(let d of Array.from(r.childNodes))if(!fe(d,e,t,o))break;return e.push(`</${s}>`),t.used+=s.length+3,t.used<=z}function Ge(){var e,t;let n=[];for(let o of Array.from((t=(e=document.body)==null?void 0:e.querySelectorAll("*"))!=null?t:[]).slice(0,4e3)){let r=getComputedStyle(o);if(r.position!=="fixed"&&r.position!=="sticky"||r.visibility==="hidden"||r.display==="none"||Number(r.opacity)===0)continue;let i=o.getBoundingClientRect();if(!(i.width<4||i.height<4)&&!o.closest("[data-daybook-feedback]")&&(n.push({selector:D(o),zIndex:r.zIndex,rect:{x:Math.round(i.x),y:Math.round(i.y),w:Math.round(i.width),h:Math.round(i.height)}}),n.length>=20))break}return n}function Ze(n){if(!(n!=null&&n.selector))return;let e=null;try{e=document.querySelector(n.selector)}catch{return}if(!e)return;let t=[];for(let o=e;o&&t.length<5;o=o.parentElement){let r=getComputedStyle(o),i={};for(let s of Ve){let a=r.getPropertyValue(s);a&&(i[s]=a)}t.push({selector:D(o),computed:i})}return{selector:n.selector,path:t}}function et(){return Array.from(document.styleSheets).slice(0,40).map(n=>{try{return{href:n.href,rules:n.cssRules.length}}catch{return{href:n.href,rules:"unreadable"}}})}function ge(n,e){try{let t=[],o={used:0};return fe(document.documentElement,t,o,e),{note:Ye,capturedAtUtc:new Date().toISOString(),url:location.href,title:document.title,redacted:e,truncated:o.used>z,scroll:{x:Math.round(window.scrollX),y:Math.round(window.scrollY)},focus:document.activeElement&&document.activeElement!==document.body?D(document.activeElement):null,anchor:Ze(n),layers:Ge(),stylesheets:et(),html:t.join("")}}catch{return null}}function $(n,e){let t=document.elementFromPoint(n,e);if(!(t instanceof HTMLElement))return{selector:null,offsetX:A(n/window.innerWidth),offsetY:A(e/window.innerHeight),elementText:null};let o=t.getBoundingClientRect();return{selector:tt(t),offsetX:o.width>0?A((n-o.left)/o.width):0,offsetY:o.height>0?A((e-o.top)/o.height):0,elementText:nt(t)}}function ye(n){if(!n.selector)return{x:n.offsetX*window.innerWidth,y:n.offsetY*window.innerHeight};let e=null;try{e=document.querySelector(n.selector)}catch{return null}if(!e)return null;let t=e.getBoundingClientRect();return{x:t.left+n.offsetX*t.width,y:t.top+n.offsetY*t.height}}function tt(n){if(n===document.body)return"body";for(let r of["data-testid","data-test","data-daybook-id","data-cy"]){let i=n.getAttribute(r);if(i){let s=`[${r}="${X(i)}"]`;if(_(s))return s}}if(n.id&&!be(n.id)){let r=`#${X(n.id)}`;if(_(r))return r}let e=[],t=n;for(;t&&t!==document.body&&e.length<8;){let r=t.tagName.toLowerCase(),i=Array.from(t.classList).filter(c=>!be(c)).slice(0,2);i.length>0&&(r+=i.map(c=>`.${X(c)}`).join(""));let s=t.parentElement;if(s){let c=Array.from(s.children).filter(l=>l.tagName===t.tagName);c.length>1&&(r+=`:nth-of-type(${c.indexOf(t)+1})`)}e.unshift(r);let a=e.join(" > ");if(_(a))return a;t=s}let o=e.length>0?`body > ${e.join(" > ")}`:null;return o&&_(o)?o:null}function _(n){try{return document.querySelectorAll(n).length===1}catch{return!1}}function be(n){return/^[a-z]{1,3}[0-9a-f]{5,}$/i.test(n)||/--[0-9a-f]{5,}$/i.test(n)||/^_[0-9a-z]{5,}/i.test(n)||/^v-[0-9a-f]{6,}$/i.test(n)||/^ng-/.test(n)||/[0-9a-f]{8,}/i.test(n)}function nt(n){var o,r,i;let t=((r=(o=n.innerText)!=null?o:n.textContent)!=null?r:"").replace(/\s+/g," ").trim();if(!t){let s=(i=n.getAttribute("aria-label"))!=null?i:n.getAttribute("title");return(s==null?void 0:s.trim())||null}return t.length>80?`${t.slice(0,77)}\u2026`:t}function A(n){return Number.isFinite(n)?Math.max(0,Math.min(1,n)):0}function X(n){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(n):n.replace(/([^\w-])/g,"\\$1")}var ot=/^(image\/(png|jpeg|gif|webp)|video\/(mp4|quicktime|webm))$/;function we(n,e){let t=[];for(let o of n){if(e+t.length>=5)break;let r=ot.test(o.type)?o.size>26214400?`Too large (${(o.size/1048576).toFixed(1)} MB, max 25).`:null:"Only images and short videos.";t.push({blob:o,filename:o.name||`pasted-${t.length+1}.${rt(o.type)}`,contentType:o.type,preview:r?null:URL.createObjectURL(o),error:r})}return t}function ve(n){var o;let e=(o=n.clipboardData)==null?void 0:o.items;if(!e)return[];let t=[];for(let r of e){if(r.kind!=="file")continue;let i=r.getAsFile();i&&t.push(i)}return t}function M(n){for(let e of n)e.preview&&URL.revokeObjectURL(e.preview)}function rt(n){var e,t;return(t=(e=n.split("/")[1])==null?void 0:e.replace("quicktime","mov"))!=null?t:"bin"}function xe(n){var o;let t=(o=(typeof n.composedPath=="function"?n.composedPath():[])[0])!=null?o:n.target;return!t||t.nodeType!==1?!1:/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)?!0:typeof t.closest=="function"&&t.closest('[contenteditable=""], [contenteditable="true"]')!==null}function it(n,e,t){let o=0;for(let s of e){if(s.right<=n.left||s.left>=n.right)continue;let a=n.v==="bottom"?t.height-s.top:s.bottom;a>o&&(o=a)}if(o===0)return 0;let r=n.v==="bottom"?t.height-n.bottom:n.top,i=Math.round(o+12-r);return i<=0||i>t.height*.35?0:i}function st(n,e,t){if(n===e||e.contains(n)||n.contains(e)||n===document.body||n===document.documentElement)return!1;let o=getComputedStyle(n);if(o.position!=="fixed"&&o.position!=="sticky"||o.visibility==="hidden"||o.display==="none"||Number(o.opacity)===0)return!1;let r=n.getBoundingClientRect();return!(r.width<8||r.height<8||r.width*r.height>t.width*t.height*.25)}function at(n,e,t){if(typeof document.elementsFromPoint!="function")return[];let o=new Map,r=[];for(let s=n.left+4;s<n.right;s+=32)r.push(s);r.push(n.right-4);let i=t.height*.35;for(let s=0;s<=i;s+=32){let a=n.v==="bottom"?n.bottom-s:n.top+s;if(a<0||a>t.height)break;for(let c of r)if(!(c<0||c>t.width))for(let l of document.elementsFromPoint(c,a)){if(o.has(l)||!st(l,e,t))continue;let u=l.getBoundingClientRect();o.set(l,{top:u.top,bottom:u.bottom,left:u.left,right:u.right})}}return[...o.values()]}function ke(n,e){let t={width:window.innerWidth,height:window.innerHeight};return it(n,at(n,e,t),t)}var H=class{constructor(e,t){this.options=e;this.onSubmit=t;this.mode="idle";this.anchor=null;this.detach=[];this.buttonStyle="pill";this.clearance=0;this.state="ready";this.policy=null;this.dragged=null;this.reference=null;this.uploadsFailed=0;this.host=document.createElement("div"),this.host.setAttribute("data-daybook-feedback",""),this.host.style.cssText="position:fixed;inset:0;z-index:2147483000;pointer-events:none",this.root=this.host.attachShadow({mode:"open"}),this.root.innerHTML=`<style>${Me}</style><style id="theme"></style><style id="place"></style><div id="layer"></div>`}setTheme(e){let t=this.root.getElementById("theme");if(t){if(!e){t.textContent="";return}t.textContent=Te(e),this.buttonStyle=Se(e),this.themePlacement=e.position,this.applyPlacement(),this.launcherLabel=typeof e.launcherLabel=="string"&&e.launcherLabel.length>0?e.launcherLabel.slice(0,24):void 0}}get placement(){var e,t;return(t=(e=this.options.placement)!=null?e:this.themePlacement)!=null?t:"bottom-right"}applyPlacement(){let e=this.root.getElementById("place");if(!e)return;let t=this.placement,o=t.startsWith("bottom")?"bottom":"top",r=t.endsWith("right")?"right":"left",i=g+this.clearance;e.textContent=`:host {
3
+ --pm-${r}: ${g}px; --pm-${r==="right"?"left":"right"}: auto;
4
+ --pm-${o}: ${i}px; --pm-${o==="bottom"?"top":"bottom"}: auto;
5
+ }`}homeSlot(){let e=this.placement,t=220,o=48,r=e.endsWith("right")?window.innerWidth-g:g+t,i=e.startsWith("bottom")?window.innerHeight-g:g+o;return{left:r-t,right:r,top:i-o,bottom:i,v:e.startsWith("bottom")?"bottom":"top"}}watchClearance(){if(this.options.avoidOverlap===!1)return;let e=!1,t=()=>{if(e=!1,this.mode==="idle")try{let i=ke(this.homeSlot(),this.host);if(Math.abs(i-this.clearance)<4)return;this.clearance=i,this.applyPlacement()}catch{}},o=typeof requestAnimationFrame=="function"?i=>requestAnimationFrame(i):i=>setTimeout(i,16),r=()=>{e||(e=!0,o(t))};if(window.addEventListener("scroll",r,{passive:!0,capture:!0}),window.addEventListener("resize",r),this.detach.push(()=>{window.removeEventListener("scroll",r,{capture:!0}),window.removeEventListener("resize",r)}),typeof MutationObserver=="function"){let i=new MutationObserver(r);i.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class","hidden"]}),this.detach.push(()=>i.disconnect())}r()}setState(e){this.state=e,this.host.isConnected&&this.render()}mount(){var e;if(document.body.appendChild(this.host),this.applyPlacement(),this.render(),this.watchClearance(),this.options.hotkey!==null){let t=((e=this.options.hotkey)!=null?e:"f").toLowerCase(),o=r=>{if(r.key==="Escape"){this.mode==="picking"&&(this.mode="idle",this.anchor=null,this.dragged=null,this.render());return}r.metaKey||r.ctrlKey||r.altKey||xe(r)||this.mode!=="composing"&&r.key.toLowerCase()===t&&(this.mode=this.mode==="picking"?"idle":"picking",this.render())};window.addEventListener("keydown",o),this.detach.push(()=>window.removeEventListener("keydown",o))}}unmount(){for(let e of this.detach.splice(0))e();this.host.remove()}open(){this.mode="picking",this.render()}setReporter(e){this.reporter=e}setPolicy(e){this.policy=e}capture(){var t,o;let e=(t=this.options.screenshots)!=null?t:!0;return e===!1||((o=this.policy)==null?void 0:o.screenshots)===!1?{offered:!1,checked:!1}:{offered:!0,checked:e!=="optional"}}conceal(){let e=this.root.getElementById("layer"),t=e.style.visibility;e.style.visibility="hidden";let o=this.ringAnchor();return()=>{e.style.visibility=t,o==null||o.remove()}}ringAnchor(){var i;let e=(i=this.anchor)==null?void 0:i.selector;if(!e)return null;let t=null;try{t=document.querySelector(e)}catch{return null}if(!t)return null;let o=t.getBoundingClientRect();if(o.width<1||o.height<1)return null;let r=document.createElement("div");return r.className="ring",r.style.left=`${o.left-R}px`,r.style.top=`${o.top-R}px`,r.style.width=`${o.width+R*2}px`,r.style.height=`${o.height+R*2}px`,this.root.appendChild(r),r}movable(e,t){this.place(e),t.classList.add("drag"),t.title="Drag to move \xB7 double-click to reset",t.addEventListener("dblclick",()=>{this.dragged=null,this.place(e)}),t.addEventListener("pointerdown",o=>{if(o.target.closest("button")||o.button!==0)return;o.preventDefault();let r=e.getBoundingClientRect(),i=o.clientX-r.left,s=o.clientY-r.top;t.setPointerCapture(o.pointerId),e.classList.add("panel--dragging");let a=l=>{let u=C(l.clientX-i,g-r.width+K,window.innerWidth-K),h=C(l.clientY-s,0,window.innerHeight-K);e.style.left=`${u}px`,e.style.top=`${h}px`,e.style.right="auto",e.style.bottom="auto"},c=()=>{t.releasePointerCapture(o.pointerId),t.removeEventListener("pointermove",a),t.removeEventListener("pointerup",c),t.removeEventListener("pointercancel",c),e.classList.remove("panel--dragging"),this.dragged=dt(e.getBoundingClientRect()),this.place(e)};t.addEventListener("pointermove",a),t.addEventListener("pointerup",c),t.addEventListener("pointercancel",c)})}place(e){let t=this.dragged;if(!t){e.style.left=e.style.right=e.style.top=e.style.bottom="";return}let o=e.offsetWidth||380,r=e.offsetHeight||240,i=C(t.dx,g,Math.max(g,window.innerWidth-o-g)),s=C(t.dy,g,Math.max(g,window.innerHeight-r-g));e.style.left=t.h==="left"?`${i}px`:"auto",e.style.right=t.h==="right"?`${i}px`:"auto",e.style.top=t.v==="top"?`${s}px`:"auto",e.style.bottom=t.v==="bottom"?`${s}px`:"auto"}render(){let e=this.root.getElementById("layer");if(e.innerHTML="",this.mode==="idle"){e.appendChild(this.state==="pending"?this.pending():this.launcher());return}if(this.mode==="sent"){this.dragged=null,e.appendChild(this.sent());return}if(this.mode==="picking"){e.appendChild(this.picker());return}let t=this.composer();e.appendChild(t),this.place(t)}pending(){let e=document.createElement("div");return e.className="launcher launcher--pending",e.setAttribute("role","status"),e.textContent="Feedback access pending approval",e}sent(){var c;let e=document.createElement("div");e.className="panel panel--sent",e.setAttribute("role","status");let t=this.reference,o=this.uploadsFailed;e.innerHTML=`
5
6
  <div class="sent__tick" aria-hidden="true">&check;</div>
6
7
  <div class="sent__body">
7
8
  <div class="panel__title">Thank you \u2014 that is on its way.</div>
8
9
  ${t?`<div class="sent__ref">
9
- <code class="sent__id">${he(t)}</code>
10
+ <code class="sent__id">${W(t)}</code>
10
11
  <button type="button" class="sent__copy" data-copy>Copy</button>
11
12
  </div>
12
13
  <div class="panel__anchor">Quote it if you follow it up.</div>`:""}
13
14
  ${o>0?`<div class="sent__warn">${o===1?"One attachment could not be uploaded.":`${o} attachments could not be uploaded.`} The report was filed without it.</div>`:""}
14
15
  </div>
15
- ${t?'<button type="button" class="panel__close" data-dismiss aria-label="Dismiss">&times;</button>':""}`;let i=()=>{this.mode==="sent"&&(this.mode="idle",this.render())},r=window.setTimeout(i,o>0?2e4:t?12e3:6e3),s=()=>window.clearTimeout(r);if(this.detach.push(()=>window.clearTimeout(r)),this.contain(e),this.place(e),!t)return e;e.addEventListener("pointerenter",s),e.addEventListener("focusin",s),(c=e.querySelector("[data-dismiss]"))==null||c.addEventListener("click",i);let a=e.querySelector("[data-copy]");return a&&(a.onclick=async()=>{s();let l=await Ie(t);a.textContent=l?"Copied":"Copy failed",a.classList.toggle("sent__copy--done",l)}),e}launcher(){var t,o;let e=document.createElement("button");return e.className="launcher",e.textContent=(t=this.launcherLabel)!=null?t:"Feedback",e.title=this.options.hotkey===null?"Report a problem":`Report a problem (${((o=this.options.hotkey)!=null?o:"f").toUpperCase()})`,e.onclick=()=>{this.mode="picking",this.render()},e}picker(){let e=document.createElement("div");return e.className="mask",e.innerHTML='<div class="hint">Click the thing that is wrong \xB7 <kbd>Esc</kbd> to cancel</div>',e.onclick=t=>{e.style.pointerEvents="none",this.anchor=_(t.clientX,t.clientY),e.style.pointerEvents="",this.mode="composing",this.render()},e}composer(){var N,K,X,W,V;let e=document.createElement("div");e.className="panel";let t=(N=this.anchor)!=null&&N.elementText?`on \u201C${this.anchor.elementText}\u201D`:(K=this.anchor)!=null&&K.selector?`on ${this.anchor.selector}`:"on this page",o=this.capture();e.innerHTML=`
16
+ ${t?'<button type="button" class="panel__close" data-dismiss aria-label="Dismiss">&times;</button>':""}`;let r=()=>{this.mode==="sent"&&(this.mode="idle",this.render())},i=window.setTimeout(r,o>0?2e4:t?12e3:6e3),s=()=>window.clearTimeout(i);if(this.detach.push(()=>window.clearTimeout(i)),this.contain(e),this.place(e),!t)return e;e.addEventListener("pointerenter",s),e.addEventListener("focusin",s),(c=e.querySelector("[data-dismiss]"))==null||c.addEventListener("click",r);let a=e.querySelector("[data-copy]");return a&&(a.onclick=async()=>{s();let l=await lt(t);a.textContent=l?"Copied":"Copy failed",a.classList.toggle("sent__copy--done",l)}),e}launcher(){var t,o;let e=Le(this.buttonStyle,(t=this.launcherLabel)!=null?t:"Feedback");return e.title=this.options.hotkey===null?"Report a problem":`Report a problem (${((o=this.options.hotkey)!=null?o:"f").toUpperCase()})`,e.onclick=()=>{this.mode="picking",this.render()},e}picker(){let e=document.createElement("div");return e.className="mask",e.innerHTML='<div class="hint">Click the thing that is wrong \xB7 <kbd>Esc</kbd> to cancel</div>',e.onclick=t=>{e.style.pointerEvents="none",this.anchor=$(t.clientX,t.clientY),e.style.pointerEvents="",this.mode="composing",this.render()},e}composer(){var J,Q,G,Z,ee;let e=document.createElement("div");e.className="panel";let t=(J=this.anchor)!=null&&J.elementText?`on \u201C${this.anchor.elementText}\u201D`:(Q=this.anchor)!=null&&Q.selector?`on ${this.anchor.selector}`:"on this page",o=this.capture();e.innerHTML=`
16
17
  <div class="panel__head" id="head">
17
18
  <span class="panel__grip" aria-hidden="true">\u283F</span>
18
19
  <div class="panel__heading">
19
- <div class="panel__anchor">${he(t)}</div>
20
+ <div class="panel__anchor">${W(t)}</div>
20
21
  <div class="panel__title">Report a problem</div>
21
22
  </div>
22
23
  <button id="close" class="panel__close" aria-label="Close">&times;</button>
@@ -30,7 +31,7 @@
30
31
  what somebody came here to do is type.
31
32
  -->
32
33
  <div class="panel__kinds">
33
- ${["bug","idea","praise","question"].map((d,u)=>`<button class="kind${u===0?" kind--on":""}" data-kind="${d}">${d}</button>`).join("")}
34
+ ${["bug","idea","praise","question"].map((p,f)=>`<button class="kind${f===0?" kind--on":""}" data-kind="${p}">${p}</button>`).join("")}
34
35
  </div>
35
36
 
36
37
  <input id="email" type="email" placeholder="Email (optional, so we can reply)" autocomplete="email" />
@@ -53,23 +54,47 @@
53
54
  <div id="status" class="status"></div>
54
55
 
55
56
  <div class="panel__foot">
56
- <span class="panel__note">Sends the page, your browser, and recent errors.</span>
57
+ <span class="panel__note">Sends this page's contents, your browser, and recent errors.</span>
57
58
  <button id="cancel" class="ghost">Cancel</button>
58
59
  <button id="send" class="primary">Send</button>
59
- </div>`;let i=[],r=e.querySelector("#files"),s=e.querySelector("#drop"),a=e.querySelector("#file"),c=()=>{r.innerHTML="",i.forEach((d,u)=>{var Y;let y=document.createElement("div");y.className=d.error?"file file--bad":"file",y.innerHTML=d.preview?`<img src="${d.preview}" alt="" />`:'<span class="file__icon">\u25A6</span>';let C=document.createElement("span");C.className="file__name",C.textContent=(Y=d.error)!=null?Y:d.filename,y.appendChild(C);let x=document.createElement("button");x.className="link",x.textContent="\xD7",x.onclick=()=>{M([d]),i.splice(u,1),c()},y.appendChild(x),r.appendChild(y)}),s.style.display=i.length>=5?"none":""},l=d=>{i.push(...ce(d,i.length)),c()};a.onchange=()=>{a.files&&l(a.files)},e.querySelector("#browse").onclick=()=>a.click(),e.addEventListener("paste",d=>{let u=le(d);u.length>0&&(d.preventDefault(),l(u))}),s.addEventListener("dragover",d=>{d.preventDefault(),s.classList.add("drop--over")}),s.addEventListener("dragleave",()=>s.classList.remove("drop--over")),s.addEventListener("drop",d=>{var u,y;d.preventDefault(),s.classList.remove("drop--over"),l(Array.from((y=(u=d.dataTransfer)==null?void 0:u.files)!=null?y:[]))});let h="bug";e.querySelectorAll(".kind").forEach(d=>{d.onclick=()=>{var u;h=(u=d.dataset.kind)!=null?u:"bug",e.querySelectorAll(".kind").forEach(y=>y.classList.remove("kind--on")),d.classList.add("kind--on")}});let p=e.querySelector("#message"),g=e.querySelector("#email"),b=(V=(X=this.reporter)==null?void 0:X.email)!=null?V:(W=this.options.reporter)==null?void 0:W.email;b&&!g.value&&(g.value=b);let w=e.querySelector("#shot"),m=e.querySelector("#status"),H=e.querySelector("#send"),z=()=>{M(i),this.mode="idle",this.anchor=null,this.dragged=null,this.render()};e.querySelector("#cancel").onclick=z,e.querySelector("#close").onclick=z;let D=async()=>{var d;if(!p.value.trim()){m.textContent="Say what happened first.";return}H.disabled=!0,m.textContent="Sending\u2026";try{let u=await this.onSubmit({message:p.value.trim(),kind:h,email:g.value.trim()||void 0,anchor:this.anchor,withScreenshot:(d=w==null?void 0:w.checked)!=null?d:!1,files:i.filter(y=>!y.error)});this.reference=u.reference,this.uploadsFailed=u.uploadsFailed,M(i),this.mode="sent",this.anchor=null,this.render()}catch(u){H.disabled=!1,m.textContent=u instanceof Error?`${u.message} \u2014 saved, will retry.`:"Failed, saved and will retry."}};return H.onclick=D,p.onkeydown=d=>{(d.metaKey||d.ctrlKey)&&d.key==="Enter"&&D()},setTimeout(()=>p.focus(),0),this.contain(e),this.movable(e,e.querySelector("#head")),e}contain(e){for(let t of["pointerdown","mousedown","click"])e.addEventListener(t,o=>o.stopPropagation())}};async function Ie(n){var t;try{if((t=navigator.clipboard)!=null&&t.writeText)return await navigator.clipboard.writeText(n),!0}catch{}let e=document.createElement("textarea");e.value=n,e.setAttribute("readonly",""),e.style.cssText="position:fixed;top:0;left:0;width:1px;height:1px;opacity:0",document.body.appendChild(e);try{return e.select(),document.execCommand("copy")}catch{return!1}finally{e.remove()}}var f=16,U=56;function je(n){let e={left:n.left,right:window.innerWidth-n.right,top:n.top,bottom:window.innerHeight-n.bottom},t=Object.keys(e).reduce((r,s)=>e[s]<e[r]?s:r),o=t==="left"||t==="right"?t:e.left<=e.right?"left":"right",i=t==="top"||t==="bottom"?t:e.top<=e.bottom?"top":"bottom";return{h:o,v:i,dx:t===o?f:Math.max(f,Math.round(e[o])),dy:t===i?f:Math.max(f,Math.round(e[i]))}}function $(n,e,t){return Math.min(Math.max(n,e),t)}function he(n){return n.replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e])}function Oe(n){return typeof n=="string"&&/^(#[0-9a-f]{3,8}|rgba?\([\d\s.,%/]+\)|hsla?\([\d\s.,%/deg]+\)|[a-z]{3,20})$/i.test(n.trim())}var qe=`
60
+ </div>`;let r=[],i=e.querySelector("#files"),s=e.querySelector("#drop"),a=e.querySelector("#file"),c=()=>{i.innerHTML="",r.forEach((p,f)=>{var te;let w=document.createElement("div");w.className=p.error?"file file--bad":"file",w.innerHTML=p.preview?`<img src="${p.preview}" alt="" />`:'<span class="file__icon">\u25A6</span>';let F=document.createElement("span");F.className="file__name",F.textContent=(te=p.error)!=null?te:p.filename,w.appendChild(F);let E=document.createElement("button");E.className="link",E.textContent="\xD7",E.onclick=()=>{M([p]),r.splice(f,1),c()},w.appendChild(E),i.appendChild(w)}),s.style.display=r.length>=5?"none":""},l=p=>{r.push(...we(p,r.length)),c()};a.onchange=()=>{a.files&&l(a.files)},e.querySelector("#browse").onclick=()=>a.click(),e.addEventListener("paste",p=>{let f=ve(p);f.length>0&&(p.preventDefault(),l(f))}),s.addEventListener("dragover",p=>{p.preventDefault(),s.classList.add("drop--over")}),s.addEventListener("dragleave",()=>s.classList.remove("drop--over")),s.addEventListener("drop",p=>{var f,w;p.preventDefault(),s.classList.remove("drop--over"),l(Array.from((w=(f=p.dataTransfer)==null?void 0:f.files)!=null?w:[]))});let u="bug";e.querySelectorAll(".kind").forEach(p=>{p.onclick=()=>{var f;u=(f=p.dataset.kind)!=null?f:"bug",e.querySelectorAll(".kind").forEach(w=>w.classList.remove("kind--on")),p.classList.add("kind--on")}});let h=e.querySelector("#message"),d=e.querySelector("#email"),m=(ee=(G=this.reporter)==null?void 0:G.email)!=null?ee:(Z=this.options.reporter)==null?void 0:Z.email;m&&!d.value&&(d.value=m);let y=e.querySelector("#shot"),b=e.querySelector("#status"),v=e.querySelector("#send"),V=()=>{M(r),this.mode="idle",this.anchor=null,this.dragged=null,this.render()};e.querySelector("#cancel").onclick=V,e.querySelector("#close").onclick=V;let Y=async()=>{var p;if(!h.value.trim()){b.textContent="Say what happened first.";return}v.disabled=!0,b.textContent="Sending\u2026";try{let f=await this.onSubmit({message:h.value.trim(),kind:u,email:d.value.trim()||void 0,anchor:this.anchor,withScreenshot:(p=y==null?void 0:y.checked)!=null?p:!1,files:r.filter(w=>!w.error)});this.reference=f.reference,this.uploadsFailed=f.uploadsFailed,M(r),this.mode="sent",this.anchor=null,this.render()}catch(f){v.disabled=!1,b.textContent=f instanceof Error?`${f.message} \u2014 saved, will retry.`:"Failed, saved and will retry."}};return v.onclick=Y,h.onkeydown=p=>{(p.metaKey||p.ctrlKey)&&p.key==="Enter"&&Y()},setTimeout(()=>h.focus(),0),this.contain(e),this.movable(e,e.querySelector("#head")),e}contain(e){for(let t of["pointerdown","mousedown","click"])e.addEventListener(t,o=>o.stopPropagation())}};async function lt(n){var t;try{if((t=navigator.clipboard)!=null&&t.writeText)return await navigator.clipboard.writeText(n),!0}catch{}let e=document.createElement("textarea");e.value=n,e.setAttribute("readonly",""),e.style.cssText="position:fixed;top:0;left:0;width:1px;height:1px;opacity:0",document.body.appendChild(e);try{return e.select(),document.execCommand("copy")}catch{return!1}finally{e.remove()}}var g=16,R=3,K=56;function dt(n){let e={left:n.left,right:window.innerWidth-n.right,top:n.top,bottom:window.innerHeight-n.bottom},t=Object.keys(e).reduce((i,s)=>e[s]<e[i]?s:i),o=t==="left"||t==="right"?t:e.left<=e.right?"left":"right",r=t==="top"||t==="bottom"?t:e.top<=e.bottom?"top":"bottom";return{h:o,v:r,dx:t===o?g:Math.max(g,Math.round(e[o])),dy:t===r?g:Math.max(g,Math.round(e[r]))}}function C(n,e,t){return Math.min(Math.max(n,e),t)}function W(n){return n.replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e])}function pt(n){return typeof n=="string"&&/^(#[0-9a-f]{3,8}|rgba?\([\d\s.,%/]+\)|hsla?\([\d\s.,%/deg]+\)|[a-z]{3,20})$/i.test(n.trim())}var Ee='<svg class="launcher__icon" viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M2 6.2C2 4.4 3.4 3 5.2 3h5.6C12.6 3 14 4.4 14 6.2v2.6c0 1.8-1.4 3.2-3.2 3.2H7l-3 2.4v-2.5A3.2 3.2 0 0 1 2 8.8V6.2Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>';function Te(n){var o;let e=[];pt(n.accent)&&e.push(`--pm-accent: ${n.accent}`);let t={none:"0",sm:"6px",md:"12px",lg:"18px"}[(o=n.cornerRadius)!=null?o:"md"];return t&&e.push(`--pm-radius: ${t}`),n.colorScheme==="dark"?e.push($e):n.colorScheme==="light"&&e.push(Ae),e.length>0?`:host { ${e.join("; ")} }`:""}var Se=n=>ut.includes(n.buttonStyle)?n.buttonStyle:"pill";function Le(n,e){let t=document.createElement("button");return t.className=`launcher launcher--${n}`,n==="icon"?(t.innerHTML=Ee,t.setAttribute("aria-label",e)):n==="pill-icon"?t.innerHTML=`${Ee}<span>${W(e)}</span>`:t.textContent=e,t}function _e(n,e={}){var i;let t=(i=n.shadowRoot)!=null?i:n.attachShadow({mode:"open"}),o=typeof e.launcherLabel=="string"&&e.launcherLabel.length>0?e.launcherLabel.slice(0,24):"Feedback";t.innerHTML=`<style>${Me}</style><style>${Te(e)}</style>`;let r=Le(Se(e),o);r.classList.add("launcher--preview"),r.disabled=!0,t.appendChild(r)}var ut=["pill","pill-icon","icon","text","outline"],Ae="--pm-surface: #fff; --pm-ink: #171717; --pm-muted: #525252; --pm-faint: #a3a3a3; --pm-line: #e5e5e5; --pm-line-strong: #d4d4d4; --pm-sunken: #f5f5f5; --pm-kbd: #404040; --pm-warn: #b45309; --pm-good: #047857; --pm-good-bg: #ecfdf5; --pm-good-line: #a7f3d0; --pm-accent: #171717; --pm-on-accent: #fafafa;",$e="--pm-surface: #1c1c1c; --pm-ink: #fafafa; --pm-muted: #a3a3a3; --pm-faint: #737373; --pm-line: #333; --pm-line-strong: #454545; --pm-sunken: #262626; --pm-kbd: #d4d4d4; --pm-warn: #fbbf24; --pm-good: #34d399; --pm-good-bg: #05271f; --pm-good-line: #065f46; --pm-accent: #fafafa; --pm-on-accent: #171717;",Me=`
61
+ /*
62
+ Every colour in this file is one of these, and there are two sets of them.
63
+
64
+ Not for fashion: the widget is a panel laid over somebody else's page, and a white card on a dark
65
+ application is a flashbang. It followed the host's scheme in exactly one respect before \u2014 it did
66
+ not, and was always light.
67
+
68
+ System is the default and costs no JavaScript: the media query below is in the base stylesheet, so
69
+ a widget nobody has configured tracks the reader's own setting. A workspace that picks light or
70
+ dark gets those values written into the theme block instead, which is a later stylesheet at the
71
+ same specificity and therefore wins over the query.
72
+
73
+ The accent pair is inverse emphasis \u2014 a dark pill on a light page, a light pill on a dark one \u2014
74
+ because the launcher sits on the HOST page rather than on our panel, and a near-black button on a
75
+ near-black application is a button nobody finds. A host that sets its own accent gets white text
76
+ on it, unchanged from before; we cannot compute contrast in CSS and guessing wrong is worse than
77
+ the one case where a very pale brand colour needs its own care.
78
+ */
60
79
  :host {
61
80
  all: initial;
62
81
 
63
- /* Defaults, overridden by the theme block the handshake fills in.
64
- Offsets rather than a keyword: a custom property can hold a value, not a property name, so
65
- "put it on the left" has to be four numbers and not one word. */
66
- --pm-accent: #171717;
82
+ ${Ae}
83
+
67
84
  --pm-radius: 12px;
85
+
86
+ /* Offsets rather than a keyword: a custom property can hold a value, not a property name, so
87
+ "put it on the left" has to be four numbers and not one word. */
68
88
  --pm-left: auto;
69
89
  --pm-right: 16px;
70
90
  --pm-top: auto;
71
91
  --pm-bottom: 16px;
72
92
  }
93
+
94
+ @media (prefers-color-scheme: dark) {
95
+ :host { ${$e} }
96
+ }
97
+ }
73
98
  * { box-sizing: border-box; font-family: system-ui, -apple-system, sans-serif }
74
99
  @media (prefers-reduced-motion: reduce) { .launcher { transition: none } }
75
100
  #layer { position: fixed; inset: 0; pointer-events: none }
@@ -81,16 +106,67 @@
81
106
  reads as a bug. Honoured only where motion is welcome. */
82
107
  transition: bottom .18s ease, top .18s ease;
83
108
  padding: 9px 14px; border: 0; border-radius: 999px; cursor: pointer;
84
- background: var(--pm-accent); color: #fafafa; font-size: 13px; font-weight: 500;
109
+ background: var(--pm-accent); color: var(--pm-on-accent); font-size: 13px; font-weight: 500;
85
110
  box-shadow: 0 2px 12px rgba(0,0,0,.3);
86
111
  }
87
112
  .launcher:hover { filter: brightness(1.15) }
88
113
  .launcher--pending { cursor: default; opacity: .85 }
89
114
  .launcher--pending:hover { filter: none }
115
+ .launcher__icon { flex: none; width: 15px; height: 15px; display: block }
116
+ /* For previewLauncher: in the flow of a settings page rather than pinned to a corner. */
117
+ .launcher--preview { position: static; cursor: default; opacity: 1 }
118
+
119
+ /*
120
+ Five buttons, because one button cannot be right for every page it is a guest on.
121
+
122
+ A product with its own bold chat bubble does not want a second bold pill beside it; a spare
123
+ documentation site does not want a filled button at all; a dense application often wants the
124
+ smallest possible mark. The set is deliberately small \u2014 five things somebody can look at and
125
+ choose between in a moment, rather than a colour picker and a padding field.
126
+
127
+ Every one of them keeps the same hit area at the same corner, so the clearance measurement and
128
+ the placement work unchanged whichever is picked.
129
+ */
130
+ .launcher { display: inline-flex; align-items: center; gap: 7px }
131
+
132
+ /* Filled and round. The default, and the one that reads as a product feature. */
133
+ .launcher--pill {}
134
+
135
+ /* The same, with the icon in front for pages where a word alone reads as body text. */
136
+ .launcher--pill-icon {}
137
+
138
+ /* The mark on its own, for a corner that is already busy. */
139
+ .launcher--icon { padding: 10px; border-radius: 999px }
140
+
141
+ /* No fill at all. For a page whose own furniture is quiet and would be shouted over. */
142
+ .launcher--text {
143
+ background: transparent; color: var(--pm-ink); box-shadow: none;
144
+ padding: 6px 8px; text-decoration: underline; text-underline-offset: 3px;
145
+ }
146
+ .launcher--text:hover { filter: none; color: var(--pm-accent) }
147
+
148
+ /* Outlined: present without being loud, and it inherits the accent rather than filling with it. */
149
+ .launcher--outline {
150
+ background: transparent; color: var(--pm-accent);
151
+ border: 1px solid currentColor; box-shadow: none;
152
+ }
153
+ .launcher--outline:hover { filter: none; background: var(--pm-sunken) }
90
154
  .mask {
91
155
  position: fixed; inset: 0; pointer-events: auto; cursor: crosshair;
92
156
  background: rgba(23,23,23,.12);
93
157
  }
158
+ /*
159
+ The pinned element, ringed for the screenshot.
160
+
161
+ Three rings rather than one: a red line alone disappears against a red button, and a white one
162
+ disappears against a white card. Red, then white, then a soft red \u2014 one of the three is always
163
+ against something it contrasts with, on any page, without touching that page's own colours.
164
+ */
165
+ .ring {
166
+ position: fixed; pointer-events: none; border-radius: 3px;
167
+ border: 2px solid #ef4444;
168
+ box-shadow: 0 0 0 2px rgba(255,255,255,.85), 0 0 0 5px rgba(239,68,68,.35);
169
+ }
94
170
  /*
95
171
  Bottom, not top.
96
172
 
@@ -102,18 +178,18 @@
102
178
  */
103
179
  .hint {
104
180
  position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%);
105
- padding: 7px 12px; border-radius: 8px; background: #171717; color: #fafafa;
181
+ padding: 7px 12px; border-radius: 8px; background: var(--pm-ink); color: var(--pm-on-accent);
106
182
  font-size: 12px; white-space: nowrap;
107
183
  }
108
184
  kbd {
109
- padding: 1px 5px; border-radius: 4px; background: #404040;
185
+ padding: 1px 5px; border-radius: 4px; background: var(--pm-kbd); color: var(--pm-surface);
110
186
  font-family: ui-monospace, monospace; font-size: 11px;
111
187
  }
112
188
  .panel {
113
189
  position: fixed; width: 380px; max-width: calc(100vw - 32px); pointer-events: auto;
114
190
  left: var(--pm-left); right: var(--pm-right);
115
191
  top: var(--pm-top); bottom: var(--pm-bottom);
116
- padding: 16px; border-radius: var(--pm-radius); background: #fff; color: #171717;
192
+ padding: 16px; border-radius: var(--pm-radius); background: var(--pm-surface); color: var(--pm-ink);
117
193
  box-shadow: 0 8px 32px rgba(0,0,0,.24); font-size: 13px;
118
194
  }
119
195
  .panel__head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px }
@@ -129,29 +205,29 @@ kbd {
129
205
  */
130
206
  .drag { cursor: grab; touch-action: none; user-select: none }
131
207
  .drag:active { cursor: grabbing }
132
- .panel__grip { flex: none; color: #bdbdbd; font-size: 15px; line-height: 16px; letter-spacing: -1px }
133
- .drag:hover .panel__grip { color: #a3a3a3 }
208
+ .panel__grip { flex: none; color: var(--pm-faint); font-size: 15px; line-height: 16px; letter-spacing: -1px }
209
+ .drag:hover .panel__grip { color: var(--pm-muted) }
134
210
  .panel--dragging { box-shadow: 0 16px 48px rgba(0,0,0,.32); opacity: .92 }
135
211
 
136
212
  /* An incomplete report, said plainly. Amber rather than red: the words arrived. */
137
- .sent__warn { margin-top: 6px; color: #b45309; font-size: 11px; line-height: 1.4 }
213
+ .sent__warn { margin-top: 6px; color: var(--pm-warn); font-size: 11px; line-height: 1.4 }
138
214
 
139
215
  /* The anchor leads: it is what the reporter pointed at, and the part they need to recognise. */
140
216
  .panel__anchor {
141
- color: #737373; font-size: 11px;
217
+ color: var(--pm-muted); font-size: 11px;
142
218
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
143
219
  }
144
220
  .panel__close {
145
221
  margin-left: auto; border: 0; background: none; cursor: pointer;
146
- color: #a3a3a3; font-size: 20px; line-height: 1; padding: 0 2px;
222
+ color: var(--pm-faint); font-size: 20px; line-height: 1; padding: 0 2px;
147
223
  }
148
- .panel__close:hover { color: #171717 }
224
+ .panel__close:hover { color: var(--pm-ink) }
149
225
 
150
226
  /* A confirmation, not a form. */
151
227
  .panel--sent { display: flex; align-items: flex-start; gap: 10px }
152
228
  .sent__tick {
153
229
  flex: none; width: 24px; height: 24px; border-radius: 999px;
154
- background: #ecfdf5; color: #047857;
230
+ background: var(--pm-good-bg); color: var(--pm-good);
155
231
  display: grid; place-items: center; font-size: 14px;
156
232
  }
157
233
  .sent__body { min-width: 0 }
@@ -160,28 +236,28 @@ kbd {
160
236
  .sent__ref { display: flex; align-items: center; gap: 6px; margin: 4px 0 2px }
161
237
  .sent__id {
162
238
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
163
- color: #171717; background: #f5f5f5; border-radius: 5px; padding: 2px 6px;
239
+ color: var(--pm-ink); background: var(--pm-sunken); border-radius: 5px; padding: 2px 6px;
164
240
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
165
241
  }
166
242
  .sent__copy {
167
- flex: none; border: 1px solid #e5e5e5; border-radius: 6px; background: #fff;
168
- color: #525252; cursor: pointer; font-size: 11px; padding: 3px 8px;
243
+ flex: none; border: 1px solid var(--pm-line); border-radius: 6px; background: var(--pm-surface);
244
+ color: var(--pm-muted); cursor: pointer; font-size: 11px; padding: 3px 8px;
169
245
  }
170
- .sent__copy:hover { border-color: #a3a3a3; color: #171717 }
171
- .sent__copy--done { border-color: #a7f3d0; background: #ecfdf5; color: #047857 }
246
+ .sent__copy:hover { border-color: var(--pm-faint); color: var(--pm-ink) }
247
+ .sent__copy--done { border-color: var(--pm-good-line); background: var(--pm-good-bg); color: var(--pm-good) }
172
248
 
173
249
  .panel__kinds { display: flex; gap: 6px; margin: 8px 0 }
174
250
  .kind {
175
- flex: 1; padding: 5px 0; border: 1px solid #e5e5e5; border-radius: 7px;
176
- background: #fff; color: #525252; cursor: pointer; font-size: 12px; text-transform: capitalize;
251
+ flex: 1; padding: 5px 0; border: 1px solid var(--pm-line); border-radius: 7px;
252
+ background: var(--pm-surface); color: var(--pm-muted); cursor: pointer; font-size: 12px; text-transform: capitalize;
177
253
  }
178
- .kind--on { border-color: #171717; background: #171717; color: #fff }
254
+ .kind--on { border-color: var(--pm-ink); background: var(--pm-ink); color: var(--pm-surface) }
179
255
  textarea, input[type=email] {
180
- width: 100%; padding: 8px; margin-bottom: 8px; border: 1px solid #e5e5e5;
181
- border-radius: 8px; font-size: 13px; resize: vertical; color: #171717; background: #fff;
256
+ width: 100%; padding: 8px; margin-bottom: 8px; border: 1px solid var(--pm-line);
257
+ border-radius: 8px; font-size: 13px; resize: vertical; color: var(--pm-ink); background: var(--pm-surface);
182
258
  }
183
- textarea:focus, input:focus { outline: 2px solid #171717; outline-offset: -1px }
184
- .shot { display: flex; align-items: center; gap: 6px; color: #525252; font-size: 12px }
259
+ textarea:focus, input:focus { outline: 2px solid var(--pm-ink); outline-offset: -1px }
260
+ .shot { display: flex; align-items: center; gap: 6px; color: var(--pm-muted); font-size: 12px }
185
261
 
186
262
  /*
187
263
  One row. Cancel used to sit ABOVE Send in a stacked span, which read as a label for it rather than
@@ -189,16 +265,16 @@ textarea:focus, input:focus { outline: 2px solid #171717; outline-offset: -1px }
189
265
  */
190
266
  .panel__foot {
191
267
  display: flex; align-items: center; gap: 8px; margin-top: 12px;
192
- padding-top: 12px; border-top: 1px solid #f0f0f0;
268
+ padding-top: 12px; border-top: 1px solid var(--pm-sunken);
193
269
  }
194
- .panel__note { flex: 1; color: #a3a3a3; font-size: 10px; line-height: 1.3 }
270
+ .panel__note { flex: 1; color: var(--pm-faint); font-size: 10px; line-height: 1.3 }
195
271
  .primary, .ghost {
196
272
  padding: 6px 12px; border-radius: 7px; cursor: pointer; font-size: 12px; font-weight: 500;
197
273
  }
198
- .primary { border: 0; background: #171717; color: #fff }
274
+ .primary { border: 0; background: var(--pm-ink); color: var(--pm-surface) }
199
275
  .primary:disabled { opacity: .5; cursor: default }
200
- .ghost { border: 0; background: transparent; color: #737373 }
201
- .status { margin-top: 6px; color: #b45309; font-size: 11px; min-height: 0 }
276
+ .ghost { border: 0; background: transparent; color: var(--pm-muted) }
277
+ .status { margin-top: 6px; color: var(--pm-warn); font-size: 11px; min-height: 0 }
202
278
  /*
203
279
  One attachment area, holding both ways of adding a picture. They were a checkbox and a dropzone
204
280
  stacked \u2014 two affordances for one job, and together the busiest part of a panel whose busiest part
@@ -206,16 +282,16 @@ textarea:focus, input:focus { outline: 2px solid #171717; outline-offset: -1px }
206
282
  */
207
283
  .drop {
208
284
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
209
- margin-top: 8px; padding: 8px 10px; border: 1px dashed #d4d4d4; border-radius: 8px;
210
- color: #a3a3a3; font-size: 11px;
285
+ margin-top: 8px; padding: 8px 10px; border: 1px dashed var(--pm-line-strong); border-radius: 8px;
286
+ color: var(--pm-faint); font-size: 11px;
211
287
  }
212
- .drop__or { color: #a3a3a3 }
213
- .drop--over { border-color: #171717; color: #171717; background: #fafafa }
288
+ .drop__or { color: var(--pm-faint) }
289
+ .drop--over { border-color: var(--pm-ink); color: var(--pm-ink); background: var(--pm-sunken) }
214
290
  .files { display: flex; flex-direction: column; gap: 4px; margin-top: 8px }
215
- .file { display: flex; align-items: center; gap: 6px; font-size: 11px; color: #525252 }
216
- .file--bad { color: #b45309 }
291
+ .file { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--pm-muted) }
292
+ .file--bad { color: var(--pm-warn) }
217
293
  .file img { width: 28px; height: 28px; object-fit: cover; border-radius: 4px }
218
294
  .file__icon { width: 28px; text-align: center }
219
295
  .file__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
220
- .link { border: 0; background: transparent; color: #525252; cursor: pointer; font-size: 11px; text-decoration: underline }
221
- `;var ue="https://api.daybook.team",R=class{constructor(e){this.options=e;this.widget=null;this.started=!1;this.inFlight=null;this.epoch=0;this.ready=null;this.stopped=!1;var t;if(!e.ingestKey)throw new Error("ingestKey is required");this.client=new T((t=e.apiUrl)!=null?t:ue,e.ingestKey),this.trail=e.breadcrumbs===!1?null:new k(40,e.redact!==!1)}start(){var e;return this.stopped=!1,(e=this.trail)==null||e.start(),this.mount(),this.started||(this.started=!0,this.client.flush()),this.handshake(),this}mount(){this.widget||this.stopped||(this.widget=new A(this.options,e=>this.submit(e)),this.widget.setReporter(this.options.reporter),this.widget.mount())}handshake(){var o,i,r;let e=JSON.stringify([(o=this.options.reporter)!=null?o:null,(i=this.options.signature)!=null?i:null,this.epoch]);if(((r=this.inFlight)==null?void 0:r.key)===e)return this.inFlight.promise;let t=this.runHandshake().finally(()=>{var s;((s=this.inFlight)==null?void 0:s.promise)===t&&(this.inFlight=null)});return this.inFlight={key:e,promise:t},t}async runHandshake(){var e,t,o,i,r,s,a;try{let c=await this.client.handshake({identity:this.options.reporter,signature:this.options.signature,locale:typeof navigator!="undefined"?navigator.language:void 0});if(this.ready=c,(t=(e=this.options).onReady)==null||t.call(e,c),c.reporterStatus==="Blocked"){(o=this.widget)==null||o.unmount(),this.widget=null;return}this.mount(),this.widget.setTheme(Ue(c.theme)),this.widget.setPolicy((i=c.policy)!=null?i:null),this.widget.setState(c.reporterStatus==="Pending"?"pending":"ready")}catch(c){(s=(r=this.options).onError)==null||s.call(r,c),console.warn("[feedback] handshake failed; the widget will not appear",c),(a=this.widget)==null||a.unmount(),this.widget=null}}identify(e){var t;this.options={...this.options,reporter:e?{...this.options.reporter,...e}:void 0},(t=this.widget)==null||t.setReporter(this.options.reporter),this.widget&&this.handshake()}async signIn(){await this.client.signIn(),this.epoch++,await this.handshake()}authenticate(e){this.options={...this.options,signature:e!=null?e:void 0},this.widget&&this.handshake()}stop(){var e,t;this.started=!1,this.stopped=!0,(e=this.trail)==null||e.stop(),(t=this.widget)==null||t.unmount(),this.widget=null}open(){var e;(e=this.widget)==null||e.open()}async report(e,t={}){var o,i,r;return this.client.send({message:e,surface:this.options.surface,...t,context:{...q({breadcrumbs:(o=this.trail)==null?void 0:o.list(),app:this.options.app}),...(i=t.context)!=null?i:{}},reporter:(r=t.reporter)!=null?r:this.options.reporter})}async submit(e){var s,a,c,l,h;let t=e.withScreenshot?await re(this.options.redact!==!1,()=>{var p,g;return(g=(p=this.widget)==null?void 0:p.conceal())!=null?g:(()=>{})}):null,o=[...e.files,...t?[t]:[]],i={message:e.message,kind:e.kind,app:this.options.app,surface:this.options.surface,reporter:e.email?{...this.options.reporter,email:e.email}:this.options.reporter,context:q({anchor:e.anchor,breadcrumbs:(s=this.trail)==null?void 0:s.list(),app:this.options.app})},r=[];try{let p=await this.client.send(i,o,(g,b)=>{var w,m;r.push(b),console.warn(`[feedback] "${g.filename}" did not upload`,b),(m=(w=this.options).onError)==null||m.call(w,b)});return p.uploadsFailed=r.length,(c=(a=this.options).onSent)==null||c.call(a,p),{reference:p.reference,uploadsFailed:r.length}}catch(p){throw this.client.queue(i),(h=(l=this.options).onError)==null||h.call(l,p),p}}};function Be(n){return new R(n).start()}function Ue(n){if(!n)return null;try{let e=JSON.parse(n);return e&&typeof e=="object"?e:null}catch{return null}}return we(ze);})();
296
+ .link { border: 0; background: transparent; color: var(--pm-muted); cursor: pointer; font-size: 11px; text-decoration: underline }
297
+ `;var Re="https://api.daybook.team",I=class{constructor(e){this.options=e;this.widget=null;this.started=!1;this.inFlight=null;this.epoch=0;this.ready=null;this.stopped=!1;var t;if(!e.ingestKey)throw new Error("ingestKey is required");this.client=new L((t=e.apiUrl)!=null?t:Re,e.ingestKey),this.trail=e.breadcrumbs===!1?null:new T(40,e.redact!==!1)}start(){var e;return this.stopped=!1,(e=this.trail)==null||e.start(),this.mount(),this.started||(this.started=!0,this.client.flush()),this.handshake(),this}mount(){this.widget||this.stopped||(this.widget=new H(this.options,e=>this.submit(e)),this.widget.setReporter(this.options.reporter),this.widget.mount())}handshake(){var o,r,i;let e=JSON.stringify([(o=this.options.reporter)!=null?o:null,(r=this.options.signature)!=null?r:null,this.epoch]);if(((i=this.inFlight)==null?void 0:i.key)===e)return this.inFlight.promise;let t=this.runHandshake().finally(()=>{var s;((s=this.inFlight)==null?void 0:s.promise)===t&&(this.inFlight=null)});return this.inFlight={key:e,promise:t},t}async runHandshake(){var e,t,o,r,i,s,a;try{let c=await this.client.handshake({identity:this.options.reporter,signature:this.options.signature,locale:typeof navigator!="undefined"?navigator.language:void 0});if(this.ready=c,(t=(e=this.options).onReady)==null||t.call(e,c),c.reporterStatus==="Blocked"){(o=this.widget)==null||o.unmount(),this.widget=null;return}this.mount(),this.widget.setTheme(ft(c.theme)),this.widget.setPolicy((r=c.policy)!=null?r:null),this.widget.setState(c.reporterStatus==="Pending"?"pending":"ready")}catch(c){(s=(i=this.options).onError)==null||s.call(i,c),console.warn("[feedback] handshake failed; the widget will not appear",c),(a=this.widget)==null||a.unmount(),this.widget=null}}identify(e){var t;this.options={...this.options,reporter:e?{...this.options.reporter,...e}:void 0},(t=this.widget)==null||t.setReporter(this.options.reporter),this.widget&&this.handshake()}async signIn(){await this.client.signIn(),this.epoch++,await this.handshake()}authenticate(e){this.options={...this.options,signature:e!=null?e:void 0},this.widget&&this.handshake()}stop(){var e,t;this.started=!1,this.stopped=!0,(e=this.trail)==null||e.stop(),(t=this.widget)==null||t.unmount(),this.widget=null}open(){var e;(e=this.widget)==null||e.open()}async report(e,t={}){var o,r,i;return this.client.send({message:e,surface:this.options.surface,...t,context:{...U({breadcrumbs:(o=this.trail)==null?void 0:o.list(),app:this.options.app}),...(r=t.context)!=null?r:{}},reporter:(i=t.reporter)!=null?i:this.options.reporter})}async submit(e){var a,c,l,u,h;let t=e.withScreenshot?await pe(this.options.redact!==!1,()=>{var d,m;return(m=(d=this.widget)==null?void 0:d.conceal())!=null?m:(()=>{})}):null,o=this.options.dom===!1?null:ge(e.anchor,this.options.redact!==!1),r=[...e.files,...t?[t]:[],...o?[ht(o)]:[]],i={message:e.message,kind:e.kind,app:this.options.app,surface:this.options.surface,reporter:e.email?{...this.options.reporter,email:e.email}:this.options.reporter,context:U({anchor:e.anchor,breadcrumbs:(a=this.trail)==null?void 0:a.list(),app:this.options.app})},s=[];try{let d=await this.client.send(i,r,(m,y)=>{var b,v;s.push(y),console.warn(`[feedback] "${m.filename}" did not upload`,y),(v=(b=this.options).onError)==null||v.call(b,y)});return d.uploadsFailed=s.length,(l=(c=this.options).onSent)==null||l.call(c,d),{reference:d.reference,uploadsFailed:s.length}}catch(d){throw this.client.queue(i),(h=(u=this.options).onError)==null||h.call(u,d),d}}};function ht(n){let e=JSON.stringify(n);return{blob:new Blob([e],{type:"application/json"}),filename:"page-snapshot.json",contentType:"application/json"}}function mt(n){return new I(n).start()}function ft(n){if(!n)return null;try{let e=JSON.parse(n);return e&&typeof e=="object"?e:null}catch{return null}}return je(gt);})();
package/dist/index.d.ts CHANGED
@@ -13,6 +13,8 @@ export type { Anchor, Breadcrumb, FeedbackKind, FeedbackTheme, HandshakeRequest,
13
13
  */
14
14
  export declare const DEFAULT_API_URL = "https://api.daybook.team";
15
15
  export { captureAnchor, resolveAnchor } from './anchor.js';
16
+ /** Draws the launcher into an element you own, for a settings screen that previews a theme. */
17
+ export { previewLauncher, type ButtonStyle } from './widget.js';
16
18
  /**
17
19
  * In-app feedback for the web.
18
20
  *