@daybook/feedback 1.2.1 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -3
- package/dist/clearance.d.ts +73 -0
- package/dist/clearance.js +154 -0
- package/dist/feedback.js +128 -46
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/types.d.ts +32 -0
- package/dist/widget.d.ts +90 -10
- package/dist/widget.js +457 -132
- package/package.json +1 -1
package/dist/feedback.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
"use strict";var DaybookFeedback=(()=>{var C=Object.defineProperty;var ge=Object.getOwnPropertyDescriptor;var be=Object.getOwnPropertyNames;var ye=Object.prototype.hasOwnProperty;var we=(n,e)=>{for(var t in e)C(n,t,{get:e[t],enumerable:!0})},ve=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of be(e))!ye.call(n,r)&&r!==t&&C(n,r,{get:()=>e[r],enumerable:!(o=ge(e,r))||o.enumerable});return n};var xe=n=>ve(C({},"__esModule",{value:!0}),n);var Ne={};we(Ne,{DEFAULT_API_URL:()=>me,DaybookFeedback:()=>A,captureAnchor:()=>_,init:()=>ze,resolveAnchor:()=>ce});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 P(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 P(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 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 Z="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",P(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",v(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(F).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: ${F(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} ${v(G(t[0]))} ${i}ms`),r}catch(r){throw this.add("network",`failed ${v(G(t[0]))}: ${F(r)}`),r}},this.detach.push(()=>{window.fetch=e})}};function G(n){return typeof n=="string"?n:n instanceof URL?n.href:n.url}function F(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 j="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,u;let r={idempotencyKey:(c=e.idempotencyKey)!=null?c:ee(),...e,attachments:[...(l=e.attachments)!=null?l:[],...t.map(p=>({filename:p.filename,contentType:p.contentType,size:p.blob.size}))]},i=await this.post("/ingest/v1",r);if(!i.ok)throw await E(i);let s=await i.json(),a=((u=e.attachments)!=null?u:[]).length;return await Promise.all(t.map(async(p,m)=>{let g=ke(s,a+m);if(!g){o==null||o(p,new Error("The server would not accept that file."));return}try{await this.upload(g,p)}catch(y){o==null||o(p,y)}})),s}async flush(){let e=ne();if(e.length!==0){oe([]);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:ee(),attachments:void 0})}async signIn(){let e=te(64),t=await Ee(e),o=te(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 p=setInterval(()=>{i.closed&&(g(),u(Object.assign(new Error("Sign-in cancelled"),{code:"cancelled"})))},400),m=y=>{if(y.origin!==new URL(this.base()).origin)return;let f=y.data;if((f==null?void 0:f.source)==="daybook-feedback"&&f.state===o){if(g(),f.error||!f.code){u(Object.assign(new Error("Sign-in was refused"),{code:f.error||"refused"}));return}l(f.code)}},g=()=>{clearInterval(p),window.removeEventListener("message",m)};window.addEventListener("message",m)}),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 r,i;let t=await this.post("/ingest/v1/session",{...e,identityToken:(r=this.identityToken)!=null?r:void 0});if(!t.ok)throw await E(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 E(o);await this.post(`/ingest/v1/attachments/${e.id}/confirm`,{})}};function ke(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=ne();e.push(n),oe(e.slice(-20))}function ne(){try{let n=localStorage.getItem(j);return n?JSON.parse(n):[]}catch{return[]}}function oe(n){try{n.length===0?localStorage.removeItem(j):localStorage.setItem(j,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 ee(){return typeof crypto!="undefined"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function te(n){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",t=new Uint8Array(n);return crypto.getRandomValues(t),Array.from(t,o=>e[o%e.length]).join("")}async function Ee(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:Le(),viewport:{width:window.innerWidth,height:window.innerHeight,dpr:(t=window.devicePixelRatio)!=null?t:1},device:Te()};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 Te(){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 Le(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return`UTC${-new Date().getTimezoneOffset()/60}`}}async function se(n,e=()=>()=>{}){var i;if(typeof((i=navigator.mediaDevices)==null?void 0:i.getDisplayMedia)!="function")return null;let t=n?Re():()=>{},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 _e(r)):null}catch{return null}finally{r==null||r.getTracks().forEach(s=>s.stop()),o(),t()}}var re=1920,Se=.82;async function _e(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>re?re/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 $e(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 $e(n){for(let e of["image/webp","image/jpeg"]){let t=await ie(n,e,Se);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(r=>o(r),e,t))}function Re(){let n=[...document.querySelectorAll(`[${Z}]`),...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:""})}}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:Ae(t)}}function ce(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 r of["data-testid","data-test","data-daybook-id","data-cy"]){let i=n.getAttribute(r);if(i){let s=`[${r}="${U(i)}"]`;if(L(s))return s}}if(n.id&&!ae(n.id)){let r=`#${U(n.id)}`;if(L(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=>!ae(c)).slice(0,2);i.length>0&&(r+=i.map(c=>`.${U(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(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 ae(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 Ae(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 S(n){return Number.isFinite(n)?Math.max(0,Math.min(1,n)):0}function U(n){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(n):n.replace(/([^\w-])/g,"\\$1")}var He=/^(image\/(png|jpeg|gif|webp)|video\/(mp4|quicktime|webm))$/;function le(n,e){let t=[];for(let o of n){if(e+t.length>=5)break;let r=He.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}.${Ie(o.type)}`,contentType:o.type,preview:r?null:URL.createObjectURL(o),error:r})}return t}function de(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 $(n){for(let e of n)e.preview&&URL.revokeObjectURL(e.preview)}function Ie(n){var e,t;return(t=(e=n.split("/")[1])==null?void 0:e.replace("quicktime","mov"))!=null?t:"bin"}function pe(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}var M=class{constructor(e,t){this.options=e;this.onSubmit=t;this.mode="idle";this.anchor=null;this.detach=[];this.state="ready";this.policy=null;this.placement=Oe();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>${Ue}</style><style id="theme"></style><div id="layer"></div>`}setTheme(e){var s,a;let t=this.root.getElementById("theme");if(!t)return;if(!e){t.textContent="";return}let o=[];qe(e.accent)&&o.push(`--pm-accent: ${e.accent}`);let r={none:"0",sm:"6px",md:"12px",lg:"18px"}[(s=e.cornerRadius)!=null?s:"md"];r&&o.push(`--pm-radius: ${r}`);let i=je[(a=e.position)!=null?a:"bottom-right"];i&&o.push(i),t.textContent=o.length>0?`:host { ${o.join("; ")} }`:"",this.launcherLabel=typeof e.launcherLabel=="string"&&e.launcherLabel.length>0?e.launcherLabel.slice(0,24):void 0}setState(e){this.state=e,this.host.isConnected&&this.render()}mount(){var e;if(document.body.appendChild(this.host),this.render(),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.render());return}r.metaKey||r.ctrlKey||r.altKey||pe(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.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.placement=null,ue(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=R(l.clientX-i,w-r.width+z,window.innerWidth-z),p=R(l.clientY-s,0,window.innerHeight-z);e.style.left=`${u}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.placement=Fe(e.getBoundingClientRect()),ue(this.placement),this.place(e)};t.addEventListener("pointermove",a),t.addEventListener("pointerup",c),t.addEventListener("pointercancel",c)})}place(e){let t=this.placement;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=R(t.dx,w,Math.max(w,window.innerWidth-o-w)),s=R(t.dy,w,Math.max(w,window.innerHeight-r-w));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"){let o=this.sent();e.appendChild(o),this.place(o);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 I=Object.defineProperty;var Ee=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var Se=Object.prototype.hasOwnProperty;var Le=(n,e)=>{for(var t in e)I(n,t,{get:e[t],enumerable:!0})},_e=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Te(e))!Se.call(n,r)&&r!==t&&I(n,r,{get:()=>e[r],enumerable:!(o=Ee(e,r))||o.enumerable});return n};var $e=n=>_e(I({},"__esModule",{value:!0}),n);var Je={};Le(Je,{DEFAULT_API_URL:()=>ke,DaybookFeedback:()=>H,captureAnchor:()=>_,init:()=>Ye,previewLauncher:()=>ye,resolveAnchor:()=>le});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 P(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 P(l)}if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement||n instanceof HTMLSelectElement){let l=(i=(r=n.getAttribute("name"))!=null?r:n.id)!=null?i:"",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 G(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 Z="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?G(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",P(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",v(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} ${v(ee(t[0]))} ${i}ms`),r}catch(r){throw this.add("network",`failed ${v(ee(t[0]))}: ${B(r)}`),r}},this.detach.push(()=>{window.fetch=e})}};function ee(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 j="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 r={idempotencyKey:(c=e.idempotencyKey)!=null?c:te(),...e,attachments:[...(l=e.attachments)!=null?l:[],...t.map(p=>({filename:p.filename,contentType:p.contentType,size:p.blob.size}))]},i=await this.post("/ingest/v1",r);if(!i.ok)throw await E(i);let s=await i.json(),a=((h=e.attachments)!=null?h:[]).length;return await Promise.all(t.map(async(p,g)=>{let b=Me(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=oe();if(e.length!==0){re([]);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:te(),attachments:void 0})}async signIn(){let e=ne(64),t=await Ae(e),o=ne(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,h)=>{let p=setInterval(()=>{i.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 f=w.data;if((f==null?void 0:f.source)==="daybook-feedback"&&f.state===o){if(b(),f.error||!f.code){h(Object.assign(new Error("Sign-in was refused"),{code:f.error||"refused"}));return}l(f.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 r,i;let t=await this.post("/ingest/v1/session",{...e,identityToken:(r=this.identityToken)!=null?r:void 0});if(!t.ok)throw await E(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 E(o);await this.post(`/ingest/v1/attachments/${e.id}/confirm`,{})}};function Me(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=oe();e.push(n),re(e.slice(-20))}function oe(){try{let n=localStorage.getItem(j);return n?JSON.parse(n):[]}catch{return[]}}function re(n){try{n.length===0?localStorage.removeItem(j):localStorage.setItem(j,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 te(){return typeof crypto!="undefined"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function ne(n){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",t=new Uint8Array(n);return crypto.getRandomValues(t),Array.from(t,o=>e[o%e.length]).join("")}async function Ae(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:He(),viewport:{width:window.innerWidth,height:window.innerHeight,dpr:(t=window.devicePixelRatio)!=null?t:1},device:Re()};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 Re(){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 He(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return`UTC${-new Date().getTimezoneOffset()/60}`}}async function ae(n,e=()=>()=>{}){var i;if(typeof((i=navigator.mediaDevices)==null?void 0:i.getDisplayMedia)!="function")return null;let t=n?Pe():()=>{},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 Fe(r)):null}catch{return null}finally{r==null||r.getTracks().forEach(s=>s.stop()),o(),t()}}var ie=1920,Ce=.82;async function Fe(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>ie?ie/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 Ie(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 Ie(n){for(let e of["image/webp","image/jpeg"]){let t=await se(n,e,Ce);if((t==null?void 0:t.type)===e)return t}return se(n,"image/png")}function se(n,e,t){return new Promise(o=>n.toBlob(r=>o(r),e,t))}function Pe(){let n=[...document.querySelectorAll(`[${Z}]`),...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:""})}}function _(n,e){let t=document.elementFromPoint(n,e);if(!(t instanceof HTMLElement))return{selector:null,offsetX:L(n/window.innerWidth),offsetY:L(e/window.innerHeight),elementText:null};let o=t.getBoundingClientRect();return{selector:Be(t),offsetX:o.width>0?L((n-o.left)/o.width):0,offsetY:o.height>0?L((e-o.top)/o.height):0,elementText:Oe(t)}}function le(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 Be(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}="${U(i)}"]`;if(S(s))return s}}if(n.id&&!ce(n.id)){let r=`#${U(n.id)}`;if(S(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=>!ce(c)).slice(0,2);i.length>0&&(r+=i.map(c=>`.${U(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(S(a))return a;t=s}let o=e.length>0?`body > ${e.join(" > ")}`:null;return o&&S(o)?o:null}function S(n){try{return document.querySelectorAll(n).length===1}catch{return!1}}function ce(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 Oe(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 L(n){return Number.isFinite(n)?Math.max(0,Math.min(1,n)):0}function U(n){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(n):n.replace(/([^\w-])/g,"\\$1")}var je=/^(image\/(png|jpeg|gif|webp)|video\/(mp4|quicktime|webm))$/;function de(n,e){let t=[];for(let o of n){if(e+t.length>=5)break;let r=je.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}.${qe(o.type)}`,contentType:o.type,preview:r?null:URL.createObjectURL(o),error:r})}return t}function pe(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 $(n){for(let e of n)e.preview&&URL.revokeObjectURL(e.preview)}function qe(n){var e,t;return(t=(e=n.split("/")[1])==null?void 0:e.replace("quicktime","mov"))!=null?t:"bin"}function he(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 Ue(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 ze(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 Ne(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)||!ze(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 ue(n,e){let t={width:window.innerWidth,height:window.innerHeight};return Ue(n,Ne(n,e,t),t)}var R=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>${xe}</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=fe(e),this.buttonStyle=ge(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=m+this.clearance;e.textContent=`:host {
|
|
2
|
+
--pm-${r}: ${m}px; --pm-${r==="right"?"left":"right"}: auto;
|
|
3
|
+
--pm-${o}: ${i}px; --pm-${o==="bottom"?"top":"bottom"}: auto;
|
|
4
|
+
}`}homeSlot(){let e=this.placement,t=220,o=48,r=e.endsWith("right")?window.innerWidth-m:m+t,i=e.startsWith("bottom")?window.innerHeight-m:m+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=ue(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||he(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-M}px`,r.style.top=`${o.top-M}px`,r.style.width=`${o.width+M*2}px`,r.style.height=`${o.height+M*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 h=A(l.clientX-i,m-r.width+z,window.innerWidth-z),p=A(l.clientY-s,0,window.innerHeight-z);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=Xe(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=A(t.dx,m,Math.max(m,window.innerWidth-o-m)),s=A(t.dy,m,Math.max(m,window.innerHeight-r-m));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=`
|
|
2
5
|
<div class="sent__tick" aria-hidden="true">✓</div>
|
|
3
6
|
<div class="sent__body">
|
|
4
7
|
<div class="panel__title">Thank you \u2014 that is on its way.</div>
|
|
5
8
|
${t?`<div class="sent__ref">
|
|
6
|
-
<code class="sent__id">${
|
|
9
|
+
<code class="sent__id">${N(t)}</code>
|
|
7
10
|
<button type="button" class="sent__copy" data-copy>Copy</button>
|
|
8
11
|
</div>
|
|
9
12
|
<div class="panel__anchor">Quote it if you follow it up.</div>`:""}
|
|
10
13
|
${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>`:""}
|
|
11
14
|
</div>
|
|
12
|
-
${t?'<button type="button" class="panel__close" data-dismiss aria-label="Dismiss">×</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
|
|
15
|
+
${t?'<button type="button" class="panel__close" data-dismiss aria-label="Dismiss">×</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 Ke(t);a.textContent=l?"Copied":"Copy failed",a.classList.toggle("sent__copy--done",l)}),e}launcher(){var t,o;let e=be(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 X,W,V,Y,Q;let e=document.createElement("div");e.className="panel";let t=(X=this.anchor)!=null&&X.elementText?`on \u201C${this.anchor.elementText}\u201D`:(W=this.anchor)!=null&&W.selector?`on ${this.anchor.selector}`:"on this page",o=this.capture();e.innerHTML=`
|
|
13
16
|
<div class="panel__head" id="head">
|
|
14
17
|
<span class="panel__grip" aria-hidden="true">\u283F</span>
|
|
15
18
|
<div class="panel__heading">
|
|
16
|
-
<div class="panel__anchor">${
|
|
19
|
+
<div class="panel__anchor">${N(t)}</div>
|
|
17
20
|
<div class="panel__title">Report a problem</div>
|
|
18
21
|
</div>
|
|
19
22
|
<button id="close" class="panel__close" aria-label="Close">×</button>
|
|
@@ -27,7 +30,7 @@
|
|
|
27
30
|
what somebody came here to do is type.
|
|
28
31
|
-->
|
|
29
32
|
<div class="panel__kinds">
|
|
30
|
-
${["bug","idea","praise","question"].map((d,
|
|
33
|
+
${["bug","idea","praise","question"].map((d,u)=>`<button class="kind${u===0?" kind--on":""}" data-kind="${d}">${d}</button>`).join("")}
|
|
31
34
|
</div>
|
|
32
35
|
|
|
33
36
|
<input id="email" type="email" placeholder="Email (optional, so we can reply)" autocomplete="email" />
|
|
@@ -53,37 +56,116 @@
|
|
|
53
56
|
<span class="panel__note">Sends the page, your browser, and recent errors.</span>
|
|
54
57
|
<button id="cancel" class="ghost">Cancel</button>
|
|
55
58
|
<button id="send" class="primary">Send</button>
|
|
56
|
-
</div>`;let r=[],i=e.querySelector("#files"),s=e.querySelector("#drop"),a=e.querySelector("#file"),c=()=>{i.innerHTML="",r.forEach((d,
|
|
59
|
+
</div>`;let r=[],i=e.querySelector("#files"),s=e.querySelector("#drop"),a=e.querySelector("#file"),c=()=>{i.innerHTML="",r.forEach((d,u)=>{var J;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 F=document.createElement("span");F.className="file__name",F.textContent=(J=d.error)!=null?J:d.filename,y.appendChild(F);let x=document.createElement("button");x.className="link",x.textContent="\xD7",x.onclick=()=>{$([d]),r.splice(u,1),c()},y.appendChild(x),i.appendChild(y)}),s.style.display=r.length>=5?"none":""},l=d=>{r.push(...de(d,r.length)),c()};a.onchange=()=>{a.files&&l(a.files)},e.querySelector("#browse").onclick=()=>a.click(),e.addEventListener("paste",d=>{let u=pe(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=(Q=(V=this.reporter)==null?void 0:V.email)!=null?Q:(Y=this.options.reporter)==null?void 0:Y.email;b&&!g.value&&(g.value=b);let w=e.querySelector("#shot"),f=e.querySelector("#status"),C=e.querySelector("#send"),D=()=>{$(r),this.mode="idle",this.anchor=null,this.dragged=null,this.render()};e.querySelector("#cancel").onclick=D,e.querySelector("#close").onclick=D;let K=async()=>{var d;if(!p.value.trim()){f.textContent="Say what happened first.";return}C.disabled=!0,f.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:r.filter(y=>!y.error)});this.reference=u.reference,this.uploadsFailed=u.uploadsFailed,$(r),this.mode="sent",this.anchor=null,this.render()}catch(u){C.disabled=!1,f.textContent=u instanceof Error?`${u.message} \u2014 saved, will retry.`:"Failed, saved and will retry."}};return C.onclick=K,p.onkeydown=d=>{(d.metaKey||d.ctrlKey)&&d.key==="Enter"&&K()},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 Ke(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 m=16,M=3,z=56;function Xe(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?m:Math.max(m,Math.round(e[o])),dy:t===r?m:Math.max(m,Math.round(e[r]))}}function A(n,e,t){return Math.min(Math.max(n,e),t)}function N(n){return n.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[e])}function We(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 me='<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 fe(n){var o;let e=[];We(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(ve):n.colorScheme==="light"&&e.push(we),e.length>0?`:host { ${e.join("; ")} }`:""}var ge=n=>Ve.includes(n.buttonStyle)?n.buttonStyle:"pill";function be(n,e){let t=document.createElement("button");return t.className=`launcher launcher--${n}`,n==="icon"?(t.innerHTML=me,t.setAttribute("aria-label",e)):n==="pill-icon"?t.innerHTML=`${me}<span>${N(e)}</span>`:t.textContent=e,t}function ye(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>${xe}</style><style>${fe(e)}</style>`;let r=be(ge(e),o);r.classList.add("launcher--preview"),r.disabled=!0,t.appendChild(r)}var Ve=["pill","pill-icon","icon","text","outline"],we="--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;",ve="--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;",xe=`
|
|
60
|
+
/*
|
|
61
|
+
Every colour in this file is one of these, and there are two sets of them.
|
|
62
|
+
|
|
63
|
+
Not for fashion: the widget is a panel laid over somebody else's page, and a white card on a dark
|
|
64
|
+
application is a flashbang. It followed the host's scheme in exactly one respect before \u2014 it did
|
|
65
|
+
not, and was always light.
|
|
66
|
+
|
|
67
|
+
System is the default and costs no JavaScript: the media query below is in the base stylesheet, so
|
|
68
|
+
a widget nobody has configured tracks the reader's own setting. A workspace that picks light or
|
|
69
|
+
dark gets those values written into the theme block instead, which is a later stylesheet at the
|
|
70
|
+
same specificity and therefore wins over the query.
|
|
71
|
+
|
|
72
|
+
The accent pair is inverse emphasis \u2014 a dark pill on a light page, a light pill on a dark one \u2014
|
|
73
|
+
because the launcher sits on the HOST page rather than on our panel, and a near-black button on a
|
|
74
|
+
near-black application is a button nobody finds. A host that sets its own accent gets white text
|
|
75
|
+
on it, unchanged from before; we cannot compute contrast in CSS and guessing wrong is worse than
|
|
76
|
+
the one case where a very pale brand colour needs its own care.
|
|
77
|
+
*/
|
|
57
78
|
:host {
|
|
58
79
|
all: initial;
|
|
59
80
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
"put it on the left" has to be four numbers and not one word. */
|
|
63
|
-
--pm-accent: #171717;
|
|
81
|
+
${we}
|
|
82
|
+
|
|
64
83
|
--pm-radius: 12px;
|
|
84
|
+
|
|
85
|
+
/* Offsets rather than a keyword: a custom property can hold a value, not a property name, so
|
|
86
|
+
"put it on the left" has to be four numbers and not one word. */
|
|
65
87
|
--pm-left: auto;
|
|
66
88
|
--pm-right: 16px;
|
|
67
89
|
--pm-top: auto;
|
|
68
90
|
--pm-bottom: 16px;
|
|
69
91
|
}
|
|
92
|
+
|
|
93
|
+
@media (prefers-color-scheme: dark) {
|
|
94
|
+
:host { ${ve} }
|
|
95
|
+
}
|
|
96
|
+
}
|
|
70
97
|
* { box-sizing: border-box; font-family: system-ui, -apple-system, sans-serif }
|
|
98
|
+
@media (prefers-reduced-motion: reduce) { .launcher { transition: none } }
|
|
71
99
|
#layer { position: fixed; inset: 0; pointer-events: none }
|
|
72
100
|
.launcher {
|
|
73
101
|
position: fixed; pointer-events: auto;
|
|
74
102
|
left: var(--pm-left); right: var(--pm-right);
|
|
75
103
|
top: var(--pm-top); bottom: var(--pm-bottom);
|
|
104
|
+
/* A back-to-top button appearing on scroll moves us; gliding reads as making room, and jumping
|
|
105
|
+
reads as a bug. Honoured only where motion is welcome. */
|
|
106
|
+
transition: bottom .18s ease, top .18s ease;
|
|
76
107
|
padding: 9px 14px; border: 0; border-radius: 999px; cursor: pointer;
|
|
77
|
-
background: var(--pm-accent); color:
|
|
108
|
+
background: var(--pm-accent); color: var(--pm-on-accent); font-size: 13px; font-weight: 500;
|
|
78
109
|
box-shadow: 0 2px 12px rgba(0,0,0,.3);
|
|
79
110
|
}
|
|
80
111
|
.launcher:hover { filter: brightness(1.15) }
|
|
81
112
|
.launcher--pending { cursor: default; opacity: .85 }
|
|
82
113
|
.launcher--pending:hover { filter: none }
|
|
114
|
+
.launcher__icon { flex: none; width: 15px; height: 15px; display: block }
|
|
115
|
+
/* For previewLauncher: in the flow of a settings page rather than pinned to a corner. */
|
|
116
|
+
.launcher--preview { position: static; cursor: default; opacity: 1 }
|
|
117
|
+
|
|
118
|
+
/*
|
|
119
|
+
Five buttons, because one button cannot be right for every page it is a guest on.
|
|
120
|
+
|
|
121
|
+
A product with its own bold chat bubble does not want a second bold pill beside it; a spare
|
|
122
|
+
documentation site does not want a filled button at all; a dense application often wants the
|
|
123
|
+
smallest possible mark. The set is deliberately small \u2014 five things somebody can look at and
|
|
124
|
+
choose between in a moment, rather than a colour picker and a padding field.
|
|
125
|
+
|
|
126
|
+
Every one of them keeps the same hit area at the same corner, so the clearance measurement and
|
|
127
|
+
the placement work unchanged whichever is picked.
|
|
128
|
+
*/
|
|
129
|
+
.launcher { display: inline-flex; align-items: center; gap: 7px }
|
|
130
|
+
|
|
131
|
+
/* Filled and round. The default, and the one that reads as a product feature. */
|
|
132
|
+
.launcher--pill {}
|
|
133
|
+
|
|
134
|
+
/* The same, with the icon in front for pages where a word alone reads as body text. */
|
|
135
|
+
.launcher--pill-icon {}
|
|
136
|
+
|
|
137
|
+
/* The mark on its own, for a corner that is already busy. */
|
|
138
|
+
.launcher--icon { padding: 10px; border-radius: 999px }
|
|
139
|
+
|
|
140
|
+
/* No fill at all. For a page whose own furniture is quiet and would be shouted over. */
|
|
141
|
+
.launcher--text {
|
|
142
|
+
background: transparent; color: var(--pm-ink); box-shadow: none;
|
|
143
|
+
padding: 6px 8px; text-decoration: underline; text-underline-offset: 3px;
|
|
144
|
+
}
|
|
145
|
+
.launcher--text:hover { filter: none; color: var(--pm-accent) }
|
|
146
|
+
|
|
147
|
+
/* Outlined: present without being loud, and it inherits the accent rather than filling with it. */
|
|
148
|
+
.launcher--outline {
|
|
149
|
+
background: transparent; color: var(--pm-accent);
|
|
150
|
+
border: 1px solid currentColor; box-shadow: none;
|
|
151
|
+
}
|
|
152
|
+
.launcher--outline:hover { filter: none; background: var(--pm-sunken) }
|
|
83
153
|
.mask {
|
|
84
154
|
position: fixed; inset: 0; pointer-events: auto; cursor: crosshair;
|
|
85
155
|
background: rgba(23,23,23,.12);
|
|
86
156
|
}
|
|
157
|
+
/*
|
|
158
|
+
The pinned element, ringed for the screenshot.
|
|
159
|
+
|
|
160
|
+
Three rings rather than one: a red line alone disappears against a red button, and a white one
|
|
161
|
+
disappears against a white card. Red, then white, then a soft red \u2014 one of the three is always
|
|
162
|
+
against something it contrasts with, on any page, without touching that page's own colours.
|
|
163
|
+
*/
|
|
164
|
+
.ring {
|
|
165
|
+
position: fixed; pointer-events: none; border-radius: 3px;
|
|
166
|
+
border: 2px solid #ef4444;
|
|
167
|
+
box-shadow: 0 0 0 2px rgba(255,255,255,.85), 0 0 0 5px rgba(239,68,68,.35);
|
|
168
|
+
}
|
|
87
169
|
/*
|
|
88
170
|
Bottom, not top.
|
|
89
171
|
|
|
@@ -95,18 +177,18 @@
|
|
|
95
177
|
*/
|
|
96
178
|
.hint {
|
|
97
179
|
position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%);
|
|
98
|
-
padding: 7px 12px; border-radius: 8px; background:
|
|
180
|
+
padding: 7px 12px; border-radius: 8px; background: var(--pm-ink); color: var(--pm-on-accent);
|
|
99
181
|
font-size: 12px; white-space: nowrap;
|
|
100
182
|
}
|
|
101
183
|
kbd {
|
|
102
|
-
padding: 1px 5px; border-radius: 4px; background:
|
|
184
|
+
padding: 1px 5px; border-radius: 4px; background: var(--pm-kbd); color: var(--pm-surface);
|
|
103
185
|
font-family: ui-monospace, monospace; font-size: 11px;
|
|
104
186
|
}
|
|
105
187
|
.panel {
|
|
106
188
|
position: fixed; width: 380px; max-width: calc(100vw - 32px); pointer-events: auto;
|
|
107
189
|
left: var(--pm-left); right: var(--pm-right);
|
|
108
190
|
top: var(--pm-top); bottom: var(--pm-bottom);
|
|
109
|
-
padding: 16px; border-radius: var(--pm-radius); background:
|
|
191
|
+
padding: 16px; border-radius: var(--pm-radius); background: var(--pm-surface); color: var(--pm-ink);
|
|
110
192
|
box-shadow: 0 8px 32px rgba(0,0,0,.24); font-size: 13px;
|
|
111
193
|
}
|
|
112
194
|
.panel__head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px }
|
|
@@ -122,29 +204,29 @@ kbd {
|
|
|
122
204
|
*/
|
|
123
205
|
.drag { cursor: grab; touch-action: none; user-select: none }
|
|
124
206
|
.drag:active { cursor: grabbing }
|
|
125
|
-
.panel__grip { flex: none; color:
|
|
126
|
-
.drag:hover .panel__grip { color:
|
|
207
|
+
.panel__grip { flex: none; color: var(--pm-faint); font-size: 15px; line-height: 16px; letter-spacing: -1px }
|
|
208
|
+
.drag:hover .panel__grip { color: var(--pm-muted) }
|
|
127
209
|
.panel--dragging { box-shadow: 0 16px 48px rgba(0,0,0,.32); opacity: .92 }
|
|
128
210
|
|
|
129
211
|
/* An incomplete report, said plainly. Amber rather than red: the words arrived. */
|
|
130
|
-
.sent__warn { margin-top: 6px; color:
|
|
212
|
+
.sent__warn { margin-top: 6px; color: var(--pm-warn); font-size: 11px; line-height: 1.4 }
|
|
131
213
|
|
|
132
214
|
/* The anchor leads: it is what the reporter pointed at, and the part they need to recognise. */
|
|
133
215
|
.panel__anchor {
|
|
134
|
-
color:
|
|
216
|
+
color: var(--pm-muted); font-size: 11px;
|
|
135
217
|
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
|
136
218
|
}
|
|
137
219
|
.panel__close {
|
|
138
220
|
margin-left: auto; border: 0; background: none; cursor: pointer;
|
|
139
|
-
color:
|
|
221
|
+
color: var(--pm-faint); font-size: 20px; line-height: 1; padding: 0 2px;
|
|
140
222
|
}
|
|
141
|
-
.panel__close:hover { color:
|
|
223
|
+
.panel__close:hover { color: var(--pm-ink) }
|
|
142
224
|
|
|
143
225
|
/* A confirmation, not a form. */
|
|
144
226
|
.panel--sent { display: flex; align-items: flex-start; gap: 10px }
|
|
145
227
|
.sent__tick {
|
|
146
228
|
flex: none; width: 24px; height: 24px; border-radius: 999px;
|
|
147
|
-
background:
|
|
229
|
+
background: var(--pm-good-bg); color: var(--pm-good);
|
|
148
230
|
display: grid; place-items: center; font-size: 14px;
|
|
149
231
|
}
|
|
150
232
|
.sent__body { min-width: 0 }
|
|
@@ -153,28 +235,28 @@ kbd {
|
|
|
153
235
|
.sent__ref { display: flex; align-items: center; gap: 6px; margin: 4px 0 2px }
|
|
154
236
|
.sent__id {
|
|
155
237
|
font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
|
|
156
|
-
color:
|
|
238
|
+
color: var(--pm-ink); background: var(--pm-sunken); border-radius: 5px; padding: 2px 6px;
|
|
157
239
|
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
|
158
240
|
}
|
|
159
241
|
.sent__copy {
|
|
160
|
-
flex: none; border: 1px solid
|
|
161
|
-
color:
|
|
242
|
+
flex: none; border: 1px solid var(--pm-line); border-radius: 6px; background: var(--pm-surface);
|
|
243
|
+
color: var(--pm-muted); cursor: pointer; font-size: 11px; padding: 3px 8px;
|
|
162
244
|
}
|
|
163
|
-
.sent__copy:hover { border-color:
|
|
164
|
-
.sent__copy--done { border-color:
|
|
245
|
+
.sent__copy:hover { border-color: var(--pm-faint); color: var(--pm-ink) }
|
|
246
|
+
.sent__copy--done { border-color: var(--pm-good-line); background: var(--pm-good-bg); color: var(--pm-good) }
|
|
165
247
|
|
|
166
248
|
.panel__kinds { display: flex; gap: 6px; margin: 8px 0 }
|
|
167
249
|
.kind {
|
|
168
|
-
flex: 1; padding: 5px 0; border: 1px solid
|
|
169
|
-
background:
|
|
250
|
+
flex: 1; padding: 5px 0; border: 1px solid var(--pm-line); border-radius: 7px;
|
|
251
|
+
background: var(--pm-surface); color: var(--pm-muted); cursor: pointer; font-size: 12px; text-transform: capitalize;
|
|
170
252
|
}
|
|
171
|
-
.kind--on { border-color:
|
|
253
|
+
.kind--on { border-color: var(--pm-ink); background: var(--pm-ink); color: var(--pm-surface) }
|
|
172
254
|
textarea, input[type=email] {
|
|
173
|
-
width: 100%; padding: 8px; margin-bottom: 8px; border: 1px solid
|
|
174
|
-
border-radius: 8px; font-size: 13px; resize: vertical; color:
|
|
255
|
+
width: 100%; padding: 8px; margin-bottom: 8px; border: 1px solid var(--pm-line);
|
|
256
|
+
border-radius: 8px; font-size: 13px; resize: vertical; color: var(--pm-ink); background: var(--pm-surface);
|
|
175
257
|
}
|
|
176
|
-
textarea:focus, input:focus { outline: 2px solid
|
|
177
|
-
.shot { display: flex; align-items: center; gap: 6px; color:
|
|
258
|
+
textarea:focus, input:focus { outline: 2px solid var(--pm-ink); outline-offset: -1px }
|
|
259
|
+
.shot { display: flex; align-items: center; gap: 6px; color: var(--pm-muted); font-size: 12px }
|
|
178
260
|
|
|
179
261
|
/*
|
|
180
262
|
One row. Cancel used to sit ABOVE Send in a stacked span, which read as a label for it rather than
|
|
@@ -182,16 +264,16 @@ textarea:focus, input:focus { outline: 2px solid #171717; outline-offset: -1px }
|
|
|
182
264
|
*/
|
|
183
265
|
.panel__foot {
|
|
184
266
|
display: flex; align-items: center; gap: 8px; margin-top: 12px;
|
|
185
|
-
padding-top: 12px; border-top: 1px solid
|
|
267
|
+
padding-top: 12px; border-top: 1px solid var(--pm-sunken);
|
|
186
268
|
}
|
|
187
|
-
.panel__note { flex: 1; color:
|
|
269
|
+
.panel__note { flex: 1; color: var(--pm-faint); font-size: 10px; line-height: 1.3 }
|
|
188
270
|
.primary, .ghost {
|
|
189
271
|
padding: 6px 12px; border-radius: 7px; cursor: pointer; font-size: 12px; font-weight: 500;
|
|
190
272
|
}
|
|
191
|
-
.primary { border: 0; background:
|
|
273
|
+
.primary { border: 0; background: var(--pm-ink); color: var(--pm-surface) }
|
|
192
274
|
.primary:disabled { opacity: .5; cursor: default }
|
|
193
|
-
.ghost { border: 0; background: transparent; color:
|
|
194
|
-
.status { margin-top: 6px; color:
|
|
275
|
+
.ghost { border: 0; background: transparent; color: var(--pm-muted) }
|
|
276
|
+
.status { margin-top: 6px; color: var(--pm-warn); font-size: 11px; min-height: 0 }
|
|
195
277
|
/*
|
|
196
278
|
One attachment area, holding both ways of adding a picture. They were a checkbox and a dropzone
|
|
197
279
|
stacked \u2014 two affordances for one job, and together the busiest part of a panel whose busiest part
|
|
@@ -199,16 +281,16 @@ textarea:focus, input:focus { outline: 2px solid #171717; outline-offset: -1px }
|
|
|
199
281
|
*/
|
|
200
282
|
.drop {
|
|
201
283
|
display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
|
|
202
|
-
margin-top: 8px; padding: 8px 10px; border: 1px dashed
|
|
203
|
-
color:
|
|
284
|
+
margin-top: 8px; padding: 8px 10px; border: 1px dashed var(--pm-line-strong); border-radius: 8px;
|
|
285
|
+
color: var(--pm-faint); font-size: 11px;
|
|
204
286
|
}
|
|
205
|
-
.drop__or { color:
|
|
206
|
-
.drop--over { border-color:
|
|
287
|
+
.drop__or { color: var(--pm-faint) }
|
|
288
|
+
.drop--over { border-color: var(--pm-ink); color: var(--pm-ink); background: var(--pm-sunken) }
|
|
207
289
|
.files { display: flex; flex-direction: column; gap: 4px; margin-top: 8px }
|
|
208
|
-
.file { display: flex; align-items: center; gap: 6px; font-size: 11px; color:
|
|
209
|
-
.file--bad { color:
|
|
290
|
+
.file { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--pm-muted) }
|
|
291
|
+
.file--bad { color: var(--pm-warn) }
|
|
210
292
|
.file img { width: 28px; height: 28px; object-fit: cover; border-radius: 4px }
|
|
211
293
|
.file__icon { width: 28px; text-align: center }
|
|
212
294
|
.file__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
|
|
213
|
-
.link { border: 0; background: transparent; color:
|
|
214
|
-
`;var
|
|
295
|
+
.link { border: 0; background: transparent; color: var(--pm-muted); cursor: pointer; font-size: 11px; text-decoration: underline }
|
|
296
|
+
`;var ke="https://api.daybook.team",H=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:ke,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 R(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(Qe(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:{...q({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 s,a,c,l,h;let t=e.withScreenshot?await ae(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]:[]],r={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})},i=[];try{let p=await this.client.send(r,o,(g,b)=>{var w,f;i.push(b),console.warn(`[feedback] "${g.filename}" did not upload`,b),(f=(w=this.options).onError)==null||f.call(w,b)});return p.uploadsFailed=i.length,(c=(a=this.options).onSent)==null||c.call(a,p),{reference:p.reference,uploadsFailed:i.length}}catch(p){throw this.client.queue(r),(h=(l=this.options).onError)==null||h.call(l,p),p}}};function Ye(n){return new H(n).start()}function Qe(n){if(!n)return null;try{let e=JSON.parse(n);return e&&typeof e=="object"?e:null}catch{return null}}return $e(Je);})();
|
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
|
*
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,8 @@ import { FeedbackWidget } from './widget.js';
|
|
|
16
16
|
*/
|
|
17
17
|
export const DEFAULT_API_URL = 'https://api.daybook.team';
|
|
18
18
|
export { captureAnchor, resolveAnchor } from './anchor.js';
|
|
19
|
+
/** Draws the launcher into an element you own, for a settings screen that previews a theme. */
|
|
20
|
+
export { previewLauncher } from './widget.js';
|
|
19
21
|
/**
|
|
20
22
|
* In-app feedback for the web.
|
|
21
23
|
*
|
package/dist/types.d.ts
CHANGED
|
@@ -106,8 +106,20 @@ export type ReporterStatus = 'Approved' | 'Pending' | 'Blocked' | 'Anonymous';
|
|
|
106
106
|
export interface FeedbackTheme {
|
|
107
107
|
accent?: string;
|
|
108
108
|
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
109
|
+
/** The word on the button. Defaults to "Feedback". */
|
|
109
110
|
launcherLabel?: string;
|
|
110
111
|
cornerRadius?: 'none' | 'sm' | 'md' | 'lg';
|
|
112
|
+
/**
|
|
113
|
+
* The shape of the launcher.
|
|
114
|
+
*
|
|
115
|
+
* pill filled and round, with the label — the default
|
|
116
|
+
* pill-icon the same, with a speech bubble in front of it
|
|
117
|
+
* icon the bubble on its own, for a corner that is already busy
|
|
118
|
+
* text no fill, underlined label, for a page that would be shouted over
|
|
119
|
+
* outline the accent as a border rather than a fill
|
|
120
|
+
*/
|
|
121
|
+
buttonStyle?: 'pill' | 'pill-icon' | 'icon' | 'text' | 'outline';
|
|
122
|
+
/** Follows the reader's own setting unless overruled. Defaults to auto. */
|
|
111
123
|
colorScheme?: 'auto' | 'light' | 'dark';
|
|
112
124
|
}
|
|
113
125
|
export interface FeedbackOptions {
|
|
@@ -175,6 +187,26 @@ export interface FeedbackOptions {
|
|
|
175
187
|
breadcrumbs?: boolean;
|
|
176
188
|
/** Keyboard shortcut to enter pick mode. Defaults to "f". Set null to disable. */
|
|
177
189
|
hotkey?: string | null;
|
|
190
|
+
/**
|
|
191
|
+
* Which corner the widget lives in. Defaults to the workspace's own setting, then bottom-right.
|
|
192
|
+
*
|
|
193
|
+
* Set here it wins over the workspace setting, and that is the right way round: the workspace
|
|
194
|
+
* owner is choosing a default for every install, while whoever writes this line is looking at the
|
|
195
|
+
* page and knows what else is in that corner.
|
|
196
|
+
*
|
|
197
|
+
* It is a home rather than a fixed position. The reporter can drag the composer off whatever they
|
|
198
|
+
* are documenting, and it comes back here for the next report — see the widget's own notes on why
|
|
199
|
+
* that is not remembered.
|
|
200
|
+
*/
|
|
201
|
+
placement?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
202
|
+
/**
|
|
203
|
+
* Whether to stack above the host page's own floating buttons — a chat bubble, a back-to-top
|
|
204
|
+
* arrow — instead of landing on them. On by default.
|
|
205
|
+
*
|
|
206
|
+
* Turn it off if the page positions things by measuring OUR corner, or if the movement is more
|
|
207
|
+
* distracting than the overlap it avoids.
|
|
208
|
+
*/
|
|
209
|
+
avoidOverlap?: boolean;
|
|
178
210
|
/** Called after a successful report, e.g. to show your own confirmation. */
|
|
179
211
|
onSent?: (response: IngestResponse) => void;
|
|
180
212
|
/**
|