@getpinax/widget 0.0.0-stage → 1.0.0-beta.1
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/LICENSE +21 -0
- package/README.md +267 -2
- package/dist/api.d.ts +62 -0
- package/dist/capture/breadcrumbs.d.ts +49 -0
- package/dist/capture/console.d.ts +17 -0
- package/dist/capture/env.d.ts +25 -0
- package/dist/capture/network.d.ts +23 -0
- package/dist/capture/ring.d.ts +14 -0
- package/dist/capture/signature.d.ts +2 -0
- package/dist/capture/text.d.ts +7 -0
- package/dist/capture/ua.d.ts +13 -0
- package/dist/chunks/editor-DbHLGwOA.mjs +1368 -0
- package/dist/chunks/privacy-DmU6v5Fr.mjs +39 -0
- package/dist/chunks/recorder-BUtEB_em.mjs +2859 -0
- package/dist/chunks/text-8QYEyRYs.mjs +18 -0
- package/dist/chunks/widget-CkR1Ptzb.mjs +961 -0
- package/dist/editor/annotator.d.ts +20 -0
- package/dist/editor/capture.d.ts +28 -0
- package/dist/editor/encode.d.ts +7 -0
- package/dist/editor/index.d.ts +5 -0
- package/dist/editor/mask.d.ts +29 -0
- package/dist/editor/pii.d.ts +22 -0
- package/dist/editor/shapes.d.ts +31 -0
- package/dist/editor-loader.d.ts +6 -0
- package/dist/editor-loader.embed.d.ts +5 -0
- package/dist/fixcheck.d.ts +31 -0
- package/dist/index.d.ts +46 -0
- package/dist/mount.d.ts +8 -0
- package/dist/navigation.d.ts +1 -0
- package/dist/paths.d.ts +4 -0
- package/dist/pinax-editor.js +1417 -0
- package/dist/pinax-recorder.js +2902 -0
- package/dist/pinax.js +113 -0
- package/dist/pinax.mjs +1041 -0
- package/dist/preview.d.ts +35 -0
- package/dist/preview.mjs +54 -0
- package/dist/privacy.d.ts +22 -0
- package/dist/queue.d.ts +9 -0
- package/dist/replay/buffer.d.ts +40 -0
- package/dist/replay/recorder.d.ts +15 -0
- package/dist/replay/sanitize.d.ts +13 -0
- package/dist/report.d.ts +109 -0
- package/dist/segment.d.ts +31 -0
- package/dist/settings.d.ts +31 -0
- package/dist/types.d.ts +137 -0
- package/dist/ui/color.d.ts +7 -0
- package/dist/ui/dom.d.ts +14 -0
- package/dist/ui/styles.d.ts +3 -0
- package/dist/ui/widget.d.ts +161 -0
- package/package.json +73 -4
package/dist/pinax.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
(function(){var e=``;function t(t){e=t}var n=new Map;function r(t){let r=n.get(t);return r||(r=import(new URL(`${t}?v=1.0.0-beta.1`,e||document.baseURI).href),n.set(t,r),r.catch(()=>{n.delete(t)})),r}function i(){return r(`pinax-editor.js`)}function a(){return r(`pinax-recorder.js`)}function o(e,t){return e.length>t?`${e.slice(0,t-1)}…`:e}var s=/^(access_?token|token|id_token|refresh_token|auth|authorization|api_?key|key|secret|password|passwd|pwd|session|sessionid|sid|code|signature|sig)$/i;function c(e,t){try{let n=new URL(e,t);n.hash=``,n.username=``,n.password=``;for(let e of[...n.searchParams.keys()])s.test(e)&&n.searchParams.set(e,`[hidden]`);return n.toString()}catch{return String(e)}}function l(e){return(e||`https://api.getpinax.com`).replace(/\/+$/,``)}function u(e,t){let n=e??(t?``:`https://cdn.getpinax.com`);return n?n.replace(/\/+$/,``):null}function d(e,t){return`${e}/config/${encodeURIComponent(t)}.json`}function f(e,t,n){return`${e}/v1/widget/${encodeURIComponent(t)}/${n}`}async function p(e,t){let n=await e(t,{credentials:`omit`});if(!n.ok)return{status:n.status,config:null};let r=await n.json();return{status:n.status,config:r?.data??null}}async function ee(e,t,n,r=null){if(r)try{let{config:t}=await p(e,d(r,n));if(t)return t}catch{}return(await p(e,f(t,n,`config`))).config}function te(e,t,n,r){try{if(!new URL(r).searchParams.has(`pinax_verify`))return;e(f(t,n,`ping`),{method:`POST`,credentials:`omit`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:c(r)})}).catch(()=>{})}catch{}}var ne={403:`Feedback isn't switched on for this website yet.`,404:`Feedback isn't switched on for this website yet.`,413:`That screenshot is too big to send. Remove it and try again.`,429:`Too many reports from this device. Please try again in a few minutes.`};async function re(e,t,n,r){let i;try{i=await e(f(t,n,`reports`),{method:`POST`,credentials:`omit`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)})}catch{return{ok:!1,retry:!0,status:0,message:`You're offline. We'll send it when you're back.`}}let a=null;try{a=await i.json()}catch{}if(i.ok)return{ok:!0,id:a?.data?.id??``};let o=i.status;return{ok:!1,retry:o>=500,status:o,message:ne[o]??(o===400&&a?.message?a.message:`Something went wrong. Please try again.`)}}var ie=4e3;async function ae(e,t,n,r,i=ie){let a=typeof AbortController==`function`?new AbortController:null,o,s=new Promise(e=>{o=setTimeout(()=>{a?.abort(),e(null)},i)}),c=(async()=>{try{let i=await e(f(t,n,`follow-up`),{method:`POST`,credentials:`omit`,headers:{"Content-Type":`application/json`},body:JSON.stringify({type:r.type,message:r.message.trim().slice(0,2e3),pagePath:r.pagePath.slice(0,500)||`/`}),signal:a?.signal});if(!i.ok)return null;let o=(await i.json())?.data?.question;return typeof o==`string`&&o.trim()?o.trim().slice(0,300):null}catch{return null}})();try{return await Promise.race([c,s])}finally{clearTimeout(o)}}function oe(e,t,n,r){try{e(f(t,n,`fix-check`),{method:`POST`,credentials:`omit`,keepalive:!0,headers:{"Content-Type":`application/json`},body:JSON.stringify({checkId:r.checkId.slice(0,64),signature:r.signature.slice(0,300)})}).catch(()=>{})}catch{}}var se=`input,textarea,select,[contenteditable]:not([contenteditable=false]),[data-pinax-mask],.pinax-mask`,ce=`[data-pinax-mask],.pinax-mask`,le=`a[href],button,input,select,textarea,summary,[role=button],[role=link],[role=tab],[role=menuitem],[role=checkbox],[role=radio],[role=switch],[role=option],[contenteditable]:not([contenteditable=false])`,ue={button:`button`,submit:`button`,reset:`button`,image:`button`,checkbox:`checkbox`,radio:`radio`,range:`slider`,search:`searchbox`};function m(e,t){try{return e.matches(t)}catch{return!1}}function h(e,t){try{return e.closest(t)}catch{return null}}var g=e=>e.replace(/\s+/g,` `).trim();function de(e){if(e.tagName!==`INPUT`)return!1;let t=e,n=(t.getAttribute(`autocomplete`)??``).toLowerCase(),r=`${t.name} ${t.id}`.toLowerCase();return t.type===`password`||n.includes(`cc-`)||n.includes(`password`)||/\b(card|cc|cvc|cvv|iban)/.test(r)}function fe(e){let t=e.getAttribute(`role`)?.trim().split(/\s+/)[0];if(t)return t;let n=e.tagName.toLowerCase();switch(n){case`a`:return e.hasAttribute(`href`)?`link`:`text`;case`button`:case`summary`:return`button`;case`input`:return ue[e.type?.toLowerCase()]??`textbox`;case`textarea`:return`textbox`;case`select`:return`combobox`;case`img`:return`image`;case`h1`:case`h2`:case`h3`:case`h4`:case`h5`:case`h6`:return`heading`;default:return m(e,`[contenteditable]:not([contenteditable=false])`)?`textbox`:n}}function _(e,t=120){if(m(e,se)||h(e,ce))return``;let n=``,r=e=>{if(n.length>t)return;if(e.nodeType===3){n+=e.nodeValue??``;return}if(e.nodeType!==1)return;let i=e,a=i.tagName;if(a!==`SCRIPT`&&a!==`STYLE`&&a!==`TEMPLATE`&&!m(i,se)&&i.getAttribute(`aria-hidden`)!==`true`){if(a===`IMG`)n+=` ${i.getAttribute(`alt`)??``} `;else{for(let e of i.childNodes)r(e);/^(P|DIV|LI|BR|TD|TH|DT|DD)$/.test(a)&&(n+=` `)}}};for(let t of e.childNodes)r(t);return g(n)}function pe(e){let t=e.getAttribute(`aria-labelledby`);if(!t)return``;let n=e.ownerDocument;return g(t.split(/\s+/).map(e=>{let t=n.getElementById(e);return t?_(t):``}).join(` `))}function me(e){let t=e;return g((t.labels?[...t.labels]:[]).map(e=>_(e)).join(` `))||g(t.getAttribute(`placeholder`)??``)||g(t.getAttribute(`title`)??``)||g(t.getAttribute(`name`)??``)}function he(e){if(h(e,ce))return``;let t=g(e.getAttribute(`aria-label`)??``);if(t)return t;let n=pe(e);if(n)return n;let r=e.tagName;if(r===`INPUT`){let t=e.type?.toLowerCase();return t===`submit`||t===`button`||t===`reset`?g(e.getAttribute(`value`)??``):t===`image`?g(e.getAttribute(`alt`)??``):me(e)}return r===`TEXTAREA`||r===`SELECT`?me(e):m(e,`[contenteditable]:not([contenteditable=false])`)?g(e.getAttribute(`title`)??``):r===`IMG`?g(e.getAttribute(`alt`)??``):_(e)||g(e.getAttribute(`title`)??``)}function ge(e){let t=h(e,le);if(!t)return o(fe(e),200);let n=t;if(de(n))return n.type===`password`?`password field`:`card field`;let r=fe(n),i=o(he(n),60).replace(/"/g,`'`);return o(i?`${r} "${i}"`:r,200)}function v(e=location.href){try{let t=new URL(c(e));return o(`${t.pathname}${t.search}`,500)}catch{return`/`}}function _e(e,t={}){let n=t.doc??document,r=t.ignore??(()=>!1),i=``,a=null,o=t=>{try{e.push(t)}catch{}},s=e=>{if(!e||typeof e.nodeType!=`number`)return null;let t=e;return t.nodeType===1?t:t.parentElement},c=e=>{try{if(r(e.target))return;let t=s(e.target);if(!t)return;a=null,o({kind:`click`,at:new Date().toISOString(),path:v(),target:ge(t)})}catch{}},l=e=>{try{if(r(e.target))return;let t=s(e.target);if(!t)return;let n=h(t,le)??t;if(n.tagName===`INPUT`&&/^(checkbox|radio)$/i.test(n.type)||n===a)return;a=n,o({kind:`input`,at:new Date().toISOString(),path:v(),target:ge(n)})}catch{}},u=()=>{try{let e=v();if(e===i)return;i=e,a=null,o({kind:`navigation`,at:new Date().toISOString(),path:e})}catch{}};return n.addEventListener(`click`,c,!0),n.addEventListener(`input`,l,!0),u(),{navigated:u,stop:()=>{n.removeEventListener(`click`,c,!0),n.removeEventListener(`input`,l,!0)}}}var ve=[`error`,`warn`,`log`,`info`,`debug`],y=2e3,b=4e3;function x(e,t=0){if(typeof e==`string`)return e;if(e instanceof Error)return`${e.name}: ${e.message}`;if(e==null)return String(e);if(typeof e==`function`)return`[function ${e.name||``}]`;if(typeof e!=`object`)return String(e);if(typeof Node<`u`&&e instanceof Node)return`[${e.nodeName.toLowerCase()}]`;if(t>0)return Array.isArray(e)?`[…]`:`{…}`;try{let t=new WeakSet;return o(JSON.stringify(e,(e,n)=>{if(n&&typeof n==`object`){if(t.has(n))return`[circular]`;t.add(n)}return n})??String(e),y)}catch{return Object.prototype.toString.call(e)}}function ye(e){return o(e.map(e=>x(e)).join(` `),y)}function be(e){let t=e.find(e=>e instanceof Error);return t?.stack?o(t.stack,b):void 0}function xe(){let e=Error().stack;if(!e)return;let t=e.split(`
|
|
2
|
+
`),n=t[0].startsWith(`Error`)?3:2,r=t.slice(n).join(`
|
|
3
|
+
`);return r?o(r,b):void 0}function Se(e,t=window){let n=t.console,r=new Map,i=new Map,a=!1,s=t=>{try{e.push(t)}catch{}};for(let e of ve){let t=n?.[e];if(typeof t!=`function`)continue;let o=function(...n){if(!a){a=!0;try{s({level:e,message:ye(n),stack:be(n)??(e===`error`||e===`warn`?xe():void 0),at:new Date().toISOString()})}catch{}finally{a=!1}}return t.apply(this,n)};o.__pinaxOriginal=t,r.set(e,t),i.set(e,o);try{n[e]=o}catch{}}let c=e=>{try{if(!e.message&&!e.error)return;let t=e.error,n=e.filename?` (${e.filename}:${e.lineno}:${e.colno})`:``;s({level:`error`,message:o(`Uncaught ${t?.name?`${t.name}: ${t.message}`:e.message}${n}`,y),stack:t?.stack?o(t.stack,b):void 0,at:new Date().toISOString()})}catch{}},l=e=>{try{let t=e.reason;s({level:`error`,message:o(`Unhandled promise rejection: ${x(t)}`,y),stack:t instanceof Error&&t.stack?o(t.stack,b):void 0,at:new Date().toISOString()})}catch{}};return t.addEventListener(`error`,c),t.addEventListener(`unhandledrejection`,l),()=>{t.removeEventListener(`error`,c),t.removeEventListener(`unhandledrejection`,l);for(let[e,t]of r)try{n[e]===i.get(e)&&(n[e]=t)}catch{}}}var Ce={"10.0":`10/11`,"6.3":`8.1`,"6.2":`8`,"6.1":`7`};function S(e,t){return t.exec(e)?.[1]}function C(e){if(e)return e.replace(/_/g,`.`).split(`.`).slice(0,2).join(`.`)}function we(e,t=0){let n={deviceType:`desktop`};for(let[t,r]of[[`Edge`,/Edg(?:e|A|iOS)?\/([\d.]+)/],[`Opera`,/(?:OPR|OPiOS)\/([\d.]+)/],[`Samsung Internet`,/SamsungBrowser\/([\d.]+)/],[`Firefox`,/(?:Firefox|FxiOS)\/([\d.]+)/],[`Chrome`,/(?:Chrome|CriOS)\/([\d.]+)/],[`Safari`,/Version\/([\d.]+).*Safari\//]]){let i=S(e,r);if(i){n.browser=t,n.browserVersion=C(i);break}}!n.browser&&/AppleWebKit/.test(e)&&/Mobile\//.test(e)&&(n.browser=`Safari (in-app)`);let r=/iPad/.test(e)||/Macintosh/.test(e)&&t>1;if(/iPhone|iPod/.test(e))n.os=`iOS ${C(S(e,/OS ([\d_]+) like Mac/))??``}`.trim(),n.deviceType=`mobile`,n.deviceModel=/iPod/.test(e)?`iPod`:`iPhone`;else if(r){let t=C(S(e,/OS ([\d_]+) like Mac/));n.os=t?`iPadOS ${t}`:`iPadOS`,n.deviceType=`tablet`,n.deviceModel=`iPad`}else if(/Android/.test(e)){n.os=`Android ${S(e,/Android ([\d.]+)/)??``}`.trim(),n.deviceType=/Mobile/.test(e)?`mobile`:`tablet`;let t=S(e,/Android [\d.]+;(?: [a-z]{2}[-_][a-z]{2};)? ([^;)]+?)(?: Build\/[^;)]*)?\)/i);t&&t!==`K`&&!/^wv$/.test(t)&&(n.deviceModel=t.trim())}else if(/CrOS/.test(e))n.os=`ChromeOS`;else if(/Windows NT/.test(e)){let t=S(e,/Windows NT ([\d.]+)/);n.os=t&&Ce[t]?`Windows ${Ce[t]}`:`Windows`}else/Mac OS X/.test(e)?n.os=`macOS ${C(S(e,/Mac OS X ([\d_.]+)/))??``}`.trim():/Linux/.test(e)&&(n.os=`Linux`);return n.deviceType===`desktop`&&/Mobi|Tablet|Kindle|Silk/.test(e)&&(n.deviceType=/Tablet|Kindle|Silk/.test(e)?`tablet`:`mobile`),n}var w=e=>typeof e==`number`&&Number.isFinite(e)?Math.max(0,Math.round(e)):0;function Te(e=new Date){let t=(e,t=2)=>String(Math.abs(e)).padStart(t,`0`),n=-e.getTimezoneOffset(),r=n>=0?`+`:`-`;return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}.${t(e.getMilliseconds(),3)}${r}${t(Math.trunc(n/60))}:${t(n%60)}`}function Ee(e=window){let t=e.navigator,n=t?.userAgent??``,r=we(n,t?.maxTouchPoints??0),i=`UTC`;try{i=Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}catch{}let a=(e,t)=>e?o(e,t):void 0;return{userAgent:o(n,1e3),browser:a(r.browser,100),browserVersion:a(r.browserVersion,50),os:a(r.os,100),deviceType:r.deviceType,deviceModel:a(r.deviceModel,100),screen:{w:w(e.screen?.width),h:w(e.screen?.height)},viewport:{w:w(e.innerWidth),h:w(e.innerHeight)},pixelRatio:Math.min(10,Math.max(0,e.devicePixelRatio||1)),timeZone:o(i,100),language:a(t?.language,35),occurredAt:Te()}}function De(e,t){return e===0||e>=400||t>2e3}function Oe(e,t=window,n={}){let r=n.now??(()=>typeof performance<`u`?performance.now():Date.now()),i=t.location?.href,a=n.ignore??(()=>!1),s=(t,n,s,l,u)=>{try{let d=Math.max(0,Math.round(r()-l));if(!De(s,d))return;let f=c(n,i);if(a(f))return;e.push({method:o(t.toUpperCase(),10),url:o(f,2e3),status:Math.min(999,Math.max(0,s|0)),durationMs:Math.min(6e5,d),at:u})}catch{}},l=[],u=t.fetch;if(typeof u==`function`){let e=(e,n)=>{let i=`GET`,a=``,o=r(),c=new Date().toISOString();try{typeof e==`string`?a=e:e instanceof URL?a=e.href:e&&typeof e.url==`string`&&(a=e.url,i=e.method||i),n?.method&&(i=n.method)}catch{}let l=u.call(t,e,n);try{l.then(e=>s(i,a,e?.status??0,o,c),()=>s(i,a,0,o,c))}catch{}return l};try{t.fetch=e,l.push(()=>{t.fetch===e&&(t.fetch=u)})}catch{}}let d=t.XMLHttpRequest;if(d?.prototype){let e=d.prototype,t=e.open,n=e.send,i=new WeakMap,a=new WeakMap,o=new WeakSet,c=function(e,n,...r){try{i.set(this,{method:String(e),url:String(n)})}catch{}return t.call(this,e,n,...r)},u=function(e){try{let e=i.get(this);e&&(a.set(this,{m:e,start:r(),startedAt:new Date().toISOString(),aborted:!1}),o.has(this)||(o.add(this),this.addEventListener(`abort`,()=>{let e=a.get(this);e&&(e.aborted=!0)}),this.addEventListener(`loadend`,()=>{let e=a.get(this);a.delete(this),e&&!e.aborted&&s(e.m.method,e.m.url,this.status,e.start,e.startedAt)})))}catch{}return n.call(this,e)};e.open=c,e.send=u,l.push(()=>{e.open===c&&(e.open=t),e.send===u&&(e.send=n)})}return()=>{for(let e of l)try{e()}catch{}}}var T=class{constructor(e){this.capacity=e,this.items=[],this.listeners=new Set}push(e){this.items.push(e),this.items.length>this.capacity&&this.items.shift();for(let t of this.listeners)try{t(e)}catch{}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}toArray(){return this.items.slice()}clear(){this.items=[]}get size(){return this.items.length}};function ke(e){return e.replace(/https?:\/\/\S+/g,`<url>`).replace(/\b[0-9a-f]{8,}\b/gi,`<id>`).replace(/\d+/g,`<n>`).replace(/\s+/g,` `).trim().slice(0,200)}function Ae(e,t){let n=(Array.isArray(e)?e:[]).filter(e=>e.level===`error`);if(n[0]?.message)return`console:${ke(n[0].message)}`;let r=(Array.isArray(t)?t:[]).find(e=>e.status===0||e.status>=500);if(r){let e=r.url;try{e=new URL(r.url).pathname}catch{}return`network:${r.method.toUpperCase()} ${ke(e)} ${r.status===0?`failed`:`5xx`}`}return null}function je(e){return e.level===`error`?Ae([e],[]):null}function Me(e){return Ae([],[e])}function Ne(e){let t=e.path??(()=>location.pathname),n=e.random??Math.random,r=e.now??Date.now,i=[],a=new Set,o=r(),s=null,c=t=>{if(t){for(let n of i)if(!(n.signature!==t||a.has(n.id))){a.add(n.id);try{e.report(n)}catch{}}}},l=e=>{let t=Date.parse(e);return Number.isNaN(t)||t>=o-1},u=r=>{let u=t();if(s=u,o=r,a=new Set,i=e.checks.filter(t=>Pe(t.path,u)&&e.sampleRate>0&&n()<e.sampleRate),i.length){for(let t of e.console.toArray())l(t.at)&&c(je(t));for(let t of e.network.toArray())l(t.at)&&c(Me(t))}},d=e.console.subscribe(e=>{i.length&&c(je(e))}),f=e.network.subscribe(e=>{i.length&&c(Me(e))}),p=typeof performance<`u`&&performance.timeOrigin?performance.timeOrigin:r();return u(Math.min(p,r())),{navigated:()=>{t()!==s&&u(r())},stop:()=>{d(),f(),i=[]}}}function Pe(e,t){let n=e=>e.length>1?e.replace(/\/+$/,``):e;return n(e)===n(t)}var E=`pinax-widget-root`;function Fe(e=document){let t=e.getElementById(E);if(t?.shadowRoot)return t.shadowRoot;let n=e.createElement(`div`);return n.id=E,n.className=`ph-no-capture fs-exclude`,n.setAttribute(`data-hj-suppress`,``),n.setAttribute(`data-clarity-mask`,`true`),n.setAttribute(`data-private`,``),n.style.cssText=`all: initial; position: fixed; z-index: 2147483647;`,e.body.appendChild(n),n.attachShadow({mode:`open`})}function Ie(e=document){e.getElementById(E)?.remove()}function Le(e,t=window){let n=!0,r=!1,i=()=>{if(!n||r)return;r=!0;let t=()=>{if(r=!1,n)try{e()}catch{}};try{queueMicrotask(t)}catch{setTimeout(t,0)}},a=[],o=t.history;for(let e of[`pushState`,`replaceState`]){let t=o?.[e];if(typeof t!=`function`)continue;let n=function(...e){let n=t.apply(this,e);return i(),n};try{o[e]=n,a.push(()=>{o[e]===n&&(o[e]=t)})}catch{}}return t.addEventListener(`popstate`,i),a.push(()=>t.removeEventListener(`popstate`,i)),()=>{n=!1;for(let e of a)try{e()}catch{}}}var D=new Map;function Re(e){let t=D.get(e);if(!t){let n=ze(e.trim()).split(`*`).map(e=>e.replace(/[.+?^${}()|[\]\\]/g,`\\$&`)).join(`.*`);t=RegExp(`^${n}$`),D.size>200&&D.clear(),D.set(e,t)}return t}function ze(e){return e.length>1?e.replace(/\/+$/,``)||`/`:e}function Be(e){try{return decodeURI(e)}catch{return e}}function Ve(e,t){if(typeof e!=`string`||!e.trim())return!1;let n=Re(e),r=ze(t||`/`),i=[r,`${r===`/`?``:r}/`],a=Be(r);return a!==r&&i.push(a,`${a}/`),i.some(e=>n.test(e))}function He(e,t){return e?.length?e.some(e=>Ve(e,t)):!1}var O={message:5e3,email:320,entries:50,annotations:200,screenshotChars:6e6,screenshotBytes:4718592,breadcrumbs:20,followUpQuestion:300,followUpAnswer:2e3,replayChars:45e5,fields:10,fieldId:40,fieldText:200,bodyBytes:11534336},Ue=65536,We=/^[A-Za-z0-9+/=]+$/,Ge=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9-]*\.)+[A-Za-z]{2,}$/,Ke=/^data:image\/(png|jpeg|webp);base64,[A-Za-z0-9+/=]+$/;function k(e){return e.length<=O.email&&Ge.test(e)}function qe(e){let t=e.slice(e.indexOf(`,`)+1),n=t.endsWith(`==`)?2:+!!t.endsWith(`=`);return Math.floor(t.length*3/4)-n}function Je(e){return e.length<=O.screenshotChars&&Ke.test(e)&&qe(e)<=O.screenshotBytes}function Ye(e){return e.message.trim().length>0||e.type===`GENERAL`&&e.rating!==void 0||e.screenshot!==void 0}var A=(e,t)=>Number.isFinite(e)?Math.round(Math.min(1,Math.max(t,e))*1e4)/1e4:0;function Xe(e){let t=c(e);if(t.length<=2e3)return t;try{let e=new URL(t);return e.toString().length>2e3&&(e.search=``),o(e.toString(),2e3)}catch{return t.slice(0,2e3)}}function Ze(e){if(!e)return;let t={};e.id!=null&&String(e.id)&&(t.id=o(String(e.id),200)),e.name&&(t.name=o(String(e.name),200));let n=e.email?.trim();return n&&k(n)&&(t.email=n),Object.keys(t).length?t:void 0}function Qe(e,t){let n={type:e.type,message:o(e.message.trim(),O.message),page:{url:Xe(t.page.url),title:t.page.title?o(t.page.title,500):void 0},environment:t.environment};e.type===`GENERAL`&&e.rating!==void 0&&Number.isInteger(e.rating)&&e.rating>=1&&e.rating<=5&&(n.rating=e.rating);let r=e.email?.trim().toLowerCase();r&&k(r)&&(n.email=r);let i=Ze(e.user);i&&(n.user=i),t.console.length&&(n.console=t.console.slice(-O.entries)),t.network.length&&(n.network=t.network.slice(-O.entries)),t.breadcrumbs?.length&&(n.breadcrumbs=t.breadcrumbs.slice(-O.breadcrumbs).map(e=>{let t={kind:e.kind,at:o(e.at,40),path:o(e.path,500)};return e.target&&(t.target=o(e.target,200)),t}));let a=e.followUp?.question.trim(),s=e.followUp?.answer.trim();a&&s&&(n.followUp={question:o(a,O.followUpQuestion),answer:o(s,O.followUpAnswer)});let c=(e.fields??[]).filter(e=>typeof e.id==`string`&&e.id.length<=O.fieldId&&(typeof e.value==`boolean`||typeof e.value==`string`&&e.value.trim())).slice(0,O.fields).map(e=>({id:e.id,value:typeof e.value==`boolean`?e.value:o(e.value.trim(),O.fieldText)}));return c.length&&(n.fields=c),e.hp&&(n.hp=o(e.hp,500)),e.elapsedMs!==void 0&&Number.isFinite(e.elapsedMs)&&e.elapsedMs>=0&&(n.elapsedMs=Math.min(Math.round(e.elapsedMs),864e5)),e.screenshot&&Je(e.screenshot)&&(n.screenshot=e.screenshot,e.annotations?.length&&(n.annotations=e.annotations.slice(0,O.annotations).map(e=>{let t=e.type===`arrow`?-1:0,n={type:e.type,x:A(e.x,0),y:A(e.y,0),w:A(e.w,t),h:A(e.h,t)};return e.type===`text`&&e.text&&(n.text=o(e.text,500)),n}))),n}function $e(e){return new TextEncoder().encode(JSON.stringify(e)).length}function et(e,t){return!t||t.length>O.replayChars||!We.test(t)||$e(e)+t.length+12>O.bodyBytes-Ue?!1:(e.replay=t,!0)}var tt=864e5,nt=8,j=e=>`pinax:queue:${e}`;function M(e,t){try{let n=e.getItem(j(t)),r=n?JSON.parse(n):[];return Array.isArray(r)?r:[]}catch{return[]}}function rt(e,t,n){try{return n.length?e.setItem(j(t),JSON.stringify(n)):e.removeItem(j(t)),!0}catch{return!1}}function N(){try{return window.localStorage}catch{return null}}function it(e){let{user:t,console:n,screenshot:r,annotations:i,replay:a,...o}=e;return{...o,page:{...o.page,url:Xe(o.page.url)}}}function at(e,t){let n=N();return n?rt(n,e,[...M(n,e).slice(-4),{body:it(t),queuedAt:Date.now(),tries:0}]):!1}function ot(e){let t=N();return t?M(t,e).length:0}var P=!1;async function st(e,t,n){let r=N();if(r&&!P&&(typeof navigator>`u`||navigator.onLine!==!1)){P=!0;try{let i=M(r,n),a=[];for(let r of i){if(Date.now()-r.queuedAt>tt)continue;let i=await re(e,t,n,r.body);!i.ok&&i.retry&&r.tries+1<nt&&a.push({...r,tries:r.tries+1})}let o=M(r,n).slice(i.length);rt(r,n,[...a,...o])}finally{P=!1}}}var ct={opened:`Pinax Widget Opened`,submitted:`Feedback Submitted`};function F(e=window){try{let t=e.analytics;return!t||typeof t!=`object`&&typeof t!=`function`?null:typeof t.track==`function`?t:null}catch{return null}}function lt(e,t){return typeof e==`boolean`?e:t===!0}function ut(e,t){try{F()?.track?.(e,t)}catch{}}function dt(){ut(ct.opened,{source:`pinax`})}function ft(e){let t={source:`pinax`,type:e.type.toLowerCase()};typeof e.rating==`number`&&(t.rating=e.rating),e.reportId&&(t.reportId=e.reportId),e.queued&&(t.queued=!0),ut(ct.submitted,t)}function pt(){try{let e=F()?.user?.()?.id?.();return typeof e==`string`&&e.trim()?e.trim().slice(0,200):typeof e==`number`&&Number.isFinite(e)?String(e):null}catch{return null}}var mt={color:`#B8F35C`,text:`Feedback`,position:`bottom-right`,types:{problem:!0,idea:!0,general:!0},rating:!0,hidePaths:[],smallOnMobile:!1,hideButton:!1,segment:!1,wording:{chooserTitle:``,problemTitle:``,ideaTitle:``,generalTitle:``,messagePlaceholder:``,confirmation:``},fields:[],capture:{console:!0,network:!0}},I={fields:10,label:80,options:20,option:80,text:200},ht=[`bottom-right`,`bottom-left`,`right-edge`],gt=Object.keys(mt.wording),L=(e,t)=>typeof e==`string`?e.trim().slice(0,t):``,R=(e,t)=>typeof e==`boolean`?e:t,_t=[`select`,`text`,`checkbox`];function vt(e){if(!Array.isArray(e))return[];let t=[],n=new Set;for(let r of e){if(!r||typeof r!=`object`)continue;let e=r,i=typeof e.id==`string`?e.id.slice(0,40):``,a=e.type,o=L(e.label,I.label);if(!i||n.has(i)||!_t.includes(a)||!o)continue;let s=a===`select`&&Array.isArray(e.options)?[...new Set(e.options.map(e=>L(e,I.option)).filter(Boolean))].slice(0,I.options):[];if(a===`select`&&!s.length)continue;let c=e.types??{};if(n.add(i),t.push({id:i,type:a,label:o,required:e.required===!0,options:s,types:{problem:R(c.problem,!0),idea:R(c.idea,!0),general:R(c.general,!0)}}),t.length>=I.fields)break}return t}function yt(e){let t=e??{},n=mt,r=t.types??{},i={problem:R(r.problem,!0),idea:R(r.idea,!0),general:R(r.general,!0)},a=i.problem||i.idea||i.general,o=t.wording??{},s={...n.wording};for(let e of gt)s[e]=L(o[e],120);return{color:typeof t.color==`string`?t.color:n.color,text:L(t.text,40)||n.text,position:ht.includes(t.position)?t.position:n.position,types:a?i:{...n.types},rating:R(t.rating,n.rating),hidePaths:Array.isArray(t.hidePaths)?t.hidePaths.filter(e=>typeof e==`string`):[],smallOnMobile:R(t.smallOnMobile,n.smallOnMobile),hideButton:R(t.hideButton,n.hideButton),segment:R(t.segment,n.segment),wording:s,fields:vt(t.fields),capture:{console:R(t.capture?.console,!0),network:R(t.capture?.network,!0)}}}var bt=/^#[0-9a-fA-F]{6}$/,xt=e=>typeof e==`string`&&bt.test(e)?e:null;function St(e){let t=e&&typeof e==`object`?e:{},n=typeof t.logoUrl==`string`&&/^https?:\/\//i.test(t.logoUrl)?t.logoUrl.slice(0,2e3):null;return{poweredBy:t.poweredBy===!0,logoUrl:n,primary:xt(t.primary),accent:xt(t.accent)}}var z=e=>typeof e==`number`&&Number.isFinite(e)?Math.min(1,Math.max(0,e)):0;function Ct(e,t){let n=e&&typeof e==`object`?e:{},r=typeof t==`number`?z(t):1,i=Array.isArray(n.fixChecks)?n.fixChecks:[];return{followUp:n.followUp===!0,autoBlur:n.autoBlur===!0,replay:n.replay===!0,replaySampleRate:Math.min(n.replaySampleRate===void 0?1:z(n.replaySampleRate),r),fixChecks:i.filter(e=>!!e&&typeof e.id==`string`&&typeof e.path==`string`&&typeof e.signature==`string`),fixCheckSampleRate:Math.min(z(n.fixCheckSampleRate),r)}}function B(e){let t=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!t)return null;let n=t[1];n.length===3&&(n=[...n].map(e=>e+e).join(``));let[r,i,a]=[0,2,4].map(e=>{let t=Number.parseInt(n.slice(e,e+2),16)/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return .2126*r+.7152*i+.0722*a}function wt(e,t){let[n,r]=e>t?[e,t]:[t,e];return(n+.05)/(r+.05)}function V(e){let t=B(e);return t===null?`#FFFFFF`:wt(t,B(`#0B1300`))>=wt(t,1)?`#0B1300`:`#FFFFFF`}function H(e,t=`#B8F35C`){return typeof e==`string`&&B(e)!==null?e.trim():t}function U(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))n!=null&&n!==!1&&r.setAttribute(e,n===!0?``:String(n));for(let e of n)e!=null&&e!==!1&&r.append(e);return r}var Tt=`http://www.w3.org/2000/svg`;function W(e,t=16){let n=document.createElementNS(Tt,`svg`);n.setAttribute(`width`,String(t)),n.setAttribute(`height`,String(t)),n.setAttribute(`viewBox`,`0 0 24 24`),n.setAttribute(`fill`,`none`),n.setAttribute(`stroke`,`currentColor`),n.setAttribute(`stroke-width`,`2.2`),n.setAttribute(`stroke-linecap`,`round`),n.setAttribute(`stroke-linejoin`,`round`),n.setAttribute(`aria-hidden`,`true`);let r=document.createElementNS(Tt,`path`);return r.setAttribute(`d`,e),n.append(r),n}var G={close:`M18 6L6 18M6 6l12 12`,back:`M15 18l-6-6 6-6`,pen:`M12 20h9M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z`,camera:`M23 19a2 2 0 01-2 2H3a2 2 0 01-2-2V8a2 2 0 012-2h4l2-3h6l2 3h4a2 2 0 012 2zM12 17a4 4 0 100-8 4 4 0 000 8z`,trash:`M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6`},Et=`
|
|
4
|
+
$ .panel, $.pos-bottom-right .panel, $.pos-bottom-left .panel, $.pos-right-edge .panel { left: 0; right: 0; bottom: 0; width: 100%; max-width: none; max-height: 88vh; border-radius: 16px 16px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); }
|
|
5
|
+
$.open .launcher { display: none; }
|
|
6
|
+
$ .field textarea, $ .field input, $ .field select { font-size: 16px; }
|
|
7
|
+
$ .launcher { padding: 11px 16px; font-size: 14px; }
|
|
8
|
+
$.pos-bottom-right .launcher { right: 16px; bottom: 16px; }
|
|
9
|
+
$.pos-bottom-left .launcher { left: 16px; bottom: 16px; }
|
|
10
|
+
$.small .launcher { padding: 8px 12px; font-size: 13px; box-shadow: 0 8px 20px -6px rgba(0,0,0,0.35); }
|
|
11
|
+
$.small.pos-bottom-right .launcher { right: 12px; bottom: 12px; }
|
|
12
|
+
$.small.pos-bottom-left .launcher { left: 12px; bottom: 12px; }
|
|
13
|
+
$.small.pos-right-edge .launcher { padding: 8px 10px; }
|
|
14
|
+
`;function Dt(e,t){let n=Et.replace(/\$/g,t);return e?`${e}${n}}`:n}var Ot=`
|
|
15
|
+
:host { all: initial; }
|
|
16
|
+
* { box-sizing: border-box; }
|
|
17
|
+
.pnx { font-family: Manrope, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #111827; font-size: 14px; line-height: 1.4; -webkit-font-smoothing: antialiased; }
|
|
18
|
+
button { font: inherit; color: inherit; cursor: pointer; }
|
|
19
|
+
button:disabled { cursor: default; }
|
|
20
|
+
:focus-visible { outline: 3px solid #2E46BF; outline-offset: 2px; }
|
|
21
|
+
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
22
|
+
|
|
23
|
+
.launcher { position: fixed; z-index: 2; border: 0; padding: 13px 20px; border-radius: 999px; font-weight: 700; font-size: 15px; line-height: 1.2; box-shadow: 0 12px 30px -8px rgba(0,0,0,0.35); background: var(--pnx-brand); color: var(--pnx-ink); transition: transform .15s ease; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
24
|
+
.launcher:hover { transform: translateY(-1px); }
|
|
25
|
+
.pos-bottom-right .launcher { right: 24px; bottom: 24px; }
|
|
26
|
+
.pos-bottom-left .launcher { left: 24px; bottom: 24px; }
|
|
27
|
+
.pos-right-edge .launcher { right: 0; top: 45%; border-radius: 10px 0 0 10px; }
|
|
28
|
+
.pos-right-edge .launcher:hover { transform: translateX(-2px); }
|
|
29
|
+
.pos-right-edge.open .launcher { visibility: hidden; }
|
|
30
|
+
.launcher[hidden] { display: none; }
|
|
31
|
+
|
|
32
|
+
.panel { position: fixed; z-index: 3; bottom: 84px; width: 300px; max-width: calc(100vw - 32px); max-height: calc(100vh - 108px); overflow: auto; padding: 18px; border-radius: 16px; background: #FFFFFF; color: #111827; box-shadow: 0 30px 60px -18px rgba(0,0,0,0.45), 0 0 0 1px rgba(17,24,39,0.06); display: flex; flex-direction: column; gap: 12px; }
|
|
33
|
+
.panel[hidden] { display: none; }
|
|
34
|
+
.pos-bottom-right .panel { right: 24px; }
|
|
35
|
+
.pos-bottom-left .panel { left: 24px; }
|
|
36
|
+
.pos-right-edge .panel { right: 24px; bottom: 24px; max-height: calc(100vh - 48px); }
|
|
37
|
+
.no-button .panel { bottom: 24px; max-height: calc(100vh - 48px); }
|
|
38
|
+
|
|
39
|
+
.head { display: flex; align-items: center; gap: 8px; }
|
|
40
|
+
.title { margin: 0; flex: 1; font-size: 15px; font-weight: 700; }
|
|
41
|
+
.icon-btn { flex: none; width: 32px; height: 32px; margin: -6px; border: 0; border-radius: 8px; background: transparent; color: #5B6474; display: inline-flex; align-items: center; justify-content: center; }
|
|
42
|
+
.icon-btn:hover { background: #F2F4F8; color: #111827; }
|
|
43
|
+
.head .icon-btn:first-child { margin-right: 0; }
|
|
44
|
+
|
|
45
|
+
.choices { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
|
|
46
|
+
.choice { width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px 12px; border: 0; border-radius: 10px; background: #F2F4F8; font-size: 14px; font-weight: 600; text-align: left; }
|
|
47
|
+
.choice:hover { background: #FFF1EC; box-shadow: inset 0 0 0 2px var(--dot); }
|
|
48
|
+
.dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--dot); }
|
|
49
|
+
.choice small { display: block; font-size: 12px; font-weight: 500; color: #5B6474; }
|
|
50
|
+
|
|
51
|
+
.shot { position: relative; border-radius: 10px; background: #F4EDE2; overflow: hidden; min-height: 72px; display: flex; align-items: center; justify-content: center; }
|
|
52
|
+
.shot img { display: block; width: 100%; height: auto; max-height: 160px; object-fit: contain; background: #F2F4F8; }
|
|
53
|
+
.shot .tag { position: absolute; right: 8px; top: 8px; padding: 3px 7px; border-radius: 6px; background: #111827; color: #FFFFFF; font-size: 11px; font-weight: 700; }
|
|
54
|
+
.shot .wait { font-size: 13px; color: #5B6474; padding: 20px; }
|
|
55
|
+
.shot-actions { display: flex; gap: 8px; flex-wrap: wrap; }
|
|
56
|
+
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 7px 11px; border: 0; border-radius: 8px; background: #F2F4F8; color: #111827; font-size: 13px; font-weight: 700; }
|
|
57
|
+
.chip:hover { background: #E3E8F0; }
|
|
58
|
+
.chip.primary { background: #111827; color: #FFFFFF; }
|
|
59
|
+
.chip.primary:hover { background: #1F2937; }
|
|
60
|
+
|
|
61
|
+
.field { display: flex; flex-direction: column; gap: 6px; }
|
|
62
|
+
.field label, .legend { font-size: 12px; font-weight: 600; color: #5B6474; }
|
|
63
|
+
.field textarea, .field input { width: 100%; border: 0; border-radius: 10px; padding: 11px 12px; background: #F2F4F8; color: #111827; font: inherit; font-size: 14px; line-height: 1.5; box-shadow: inset 0 0 0 1px transparent; }
|
|
64
|
+
.field textarea { min-height: 84px; resize: vertical; }
|
|
65
|
+
.field textarea::placeholder, .field input::placeholder { color: #5B6474; opacity: 1; }
|
|
66
|
+
.field textarea:focus, .field input:focus { outline: none; box-shadow: inset 0 0 0 2px #2E46BF; background: #FFFFFF; }
|
|
67
|
+
.field .hint { font-size: 12px; color: #5B6474; }
|
|
68
|
+
.field select { width: 100%; border: 0; border-radius: 10px; padding: 11px 12px; background: #F2F4F8; color: #111827; font: inherit; font-size: 14px; line-height: 1.5; }
|
|
69
|
+
.field select:focus { outline: none; box-shadow: inset 0 0 0 2px #2E46BF; background: #FFFFFF; }
|
|
70
|
+
.field [aria-invalid="true"] { box-shadow: inset 0 0 0 2px #B42318; }
|
|
71
|
+
.field .optional { font-weight: 500; }
|
|
72
|
+
.field.check { flex-direction: row; align-items: flex-start; gap: 10px; }
|
|
73
|
+
.field.check input { flex: none; width: 20px; height: 20px; margin: 0; padding: 0; accent-color: #2E46BF; box-shadow: none; }
|
|
74
|
+
.field.check label { font-size: 13px; color: #111827; font-weight: 600; line-height: 1.45; }
|
|
75
|
+
.field.check input[aria-invalid="true"] { outline: 2px solid #B42318; outline-offset: 2px; }
|
|
76
|
+
.brand { display: flex; align-items: center; min-height: 28px; }
|
|
77
|
+
.brand .logo { display: block; max-height: 32px; max-width: 160px; width: auto; height: auto; object-fit: contain; }
|
|
78
|
+
.accented .panel { border-top: 4px solid var(--pnx-accent); }
|
|
79
|
+
.accented .choice:hover { box-shadow: inset 0 0 0 2px var(--pnx-accent); }
|
|
80
|
+
.accented .tick { background: var(--pnx-accent); color: var(--pnx-accent-ink); }
|
|
81
|
+
|
|
82
|
+
.stars { display: flex; gap: 4px; border: 0; margin: 0; padding: 0; }
|
|
83
|
+
.star { width: 40px; height: 40px; border: 0; border-radius: 10px; font-size: 24px; line-height: 1; background: #F2F4F8; color: #6B7280; }
|
|
84
|
+
.star.on { background: #FFF6DF; color: #B9800F; }
|
|
85
|
+
|
|
86
|
+
.error { margin: 0; font-size: 13px; color: #B42318; font-weight: 600; }
|
|
87
|
+
.error:empty { display: none; }
|
|
88
|
+
.send { width: 100%; padding: 12px; border: 0; border-radius: 10px; font-size: 14px; font-weight: 800; background: var(--type); color: var(--type-ink); }
|
|
89
|
+
.send:disabled { opacity: .7; }
|
|
90
|
+
.powered { font-size: 11px; color: #5B6474; text-align: center; }
|
|
91
|
+
.powered a { color: inherit; text-decoration: none; }
|
|
92
|
+
.powered a:hover { text-decoration: underline; }
|
|
93
|
+
|
|
94
|
+
.done { text-align: center; padding: 18px 0 6px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
|
|
95
|
+
.tick { width: 46px; height: 46px; border-radius: 50%; background: #B8F35C; color: #0B1300; font-size: 22px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
|
|
96
|
+
.done p { margin: 0; font-size: 13px; color: #5B6474; }
|
|
97
|
+
.link { border: 0; background: transparent; color: #5B6474; font-size: 13px; font-weight: 700; padding: 6px 8px; border-radius: 6px; }
|
|
98
|
+
.link:hover { color: #111827; }
|
|
99
|
+
|
|
100
|
+
.note { display: flex; align-items: baseline; gap: 8px; padding: 10px 12px; border-radius: 10px; background: #F2F4F8; color: #5B6474; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
|
|
101
|
+
.note .dot { transform: translateY(-1px); }
|
|
102
|
+
.field label.question { font-size: 14px; font-weight: 700; color: #111827; line-height: 1.4; }
|
|
103
|
+
.field textarea.answer { min-height: 64px; }
|
|
104
|
+
.skip { width: 100%; padding: 8px; text-align: center; }
|
|
105
|
+
.skip:disabled, .send:disabled + .skip { opacity: .7; }
|
|
106
|
+
.hint.auto-blur { display: flex; align-items: center; gap: 6px; }
|
|
107
|
+
.hint.auto-blur i { flex: none; width: 16px; height: 10px; border-radius: 3px; background: repeating-linear-gradient(90deg, #D8DEE9 0 4px, #C7CFDC 4px 8px); box-shadow: 0 0 0 1px #C7CFDC; }
|
|
108
|
+
|
|
109
|
+
${Dt(`@media (max-width: 520px) {`,`.pnx`)}
|
|
110
|
+
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
|
|
111
|
+
@media (forced-colors: active) { .launcher, .choice, .send, .chip, .star { border: 1px solid ButtonText; } }
|
|
112
|
+
`,kt=[{type:`PROBLEM`,key:`problem`,label:`Report a problem`,desc:`Point at what is broken`,dot:`#FF5C35`,send:`#CC3F1B`,ink:`#FFFFFF`},{type:`IDEA`,key:`idea`,label:`Share an idea`,desc:`Suggest something better`,dot:`#7C9CFF`,send:`#7C9CFF`,ink:`#0B1122`},{type:`GENERAL`,key:`general`,label:`General feedback`,desc:`A rating and a few words`,dot:`#3DBF6E`,send:`#3DBF6E`,ink:`#0B1300`}],At=4e3,jt=`What would you like to do?`,Mt=`Thanks! We've got it.`,Nt={problem:`problemTitle`,idea:`ideaTitle`,general:`generalTitle`},Pt=class{constructor(e,t,n,r={}){this.root=e,this.config=t,this.handlers=n,this.kind=null,this.shot={kind:`none`},this.message=``,this.email=``,this.answers={},this.sendColour=null,this.sending=!1,this.openedAt=0,this.hp=``,this.uid=Math.random().toString(36).slice(2,8),this.pathHidden=!1,this.returnFocus=null,this.view=`choose`,this.queued=!1,this.asked=null,this.answer=``;let i=t.settings,a=t.branding?.primary?H(t.branding.primary,``):``,o=t.branding?.accent?H(t.branding.accent,``):``,s=a||H(i.color);this.sendColour=a||null,this.kinds=kt.filter(e=>i.types?.[e.key]!==!1),this.kinds.length||(this.kinds=kt);let c=U(`style`);c.textContent=r.css?Ot+r.css:Ot,this.launcher=U(`button`,{type:`button`,class:`launcher`,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-controls":`pnx-panel-${this.uid}`},(i.text||`Feedback`).slice(0,40)),this.launcher.addEventListener(`click`,()=>this.isOpen()?this.close():this.open()),this.panel=U(`div`,{class:`panel`,id:`pnx-panel-${this.uid}`,role:`dialog`,"aria-modal":`false`,"aria-labelledby":`pnx-title-${this.uid}`,hidden:!0}),this.panel.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.stopPropagation(),this.close())}),this.panel.addEventListener(`pointerdown`,()=>this.holdOpen()),this.panel.addEventListener(`focusin`,()=>this.holdOpen()),this.live=U(`div`,{class:`sr`,role:`status`,"aria-live":`polite`});let l=[`bottom-right`,`bottom-left`,`right-edge`].includes(i.position)?i.position:`bottom-right`;this.wrap=U(`div`,{class:`pnx pos-${l}${r.className?` ${r.className}`:``}`}),i.smallOnMobile&&this.wrap.classList.add(`small`),this.updateButton(),this.wrap.style.setProperty(`--pnx-brand`,s),this.wrap.style.setProperty(`--pnx-ink`,V(s)),o&&(this.wrap.classList.add(`accented`),this.wrap.style.setProperty(`--pnx-accent`,o),this.wrap.style.setProperty(`--pnx-accent-ink`,V(o))),this.wrap.append(this.launcher,this.panel,this.live),e.append(c,this.wrap)}isOpen(){return!this.panel.hidden}hasButton(){return!this.launcher.hidden}setPathHidden(e){this.pathHidden=e,this.updateButton()}updateButton(){let e=this.config.settings.hideButton||this.pathHidden;this.launcher.hidden=e,this.wrap.classList.toggle(`no-button`,e)}open(e=!0){if(this.isOpen()){e&&this.focusFirst();return}let t=document.activeElement;this.returnFocus=t instanceof HTMLElement&&t!==this.root.host?t:null,this.openedAt||(this.openedAt=Date.now()),this.panel.hidden=!1,this.wrap.classList.add(`open`),this.launcher.setAttribute(`aria-expanded`,`true`),!this.kind&&this.kinds.length===1&&this.pick(this.kinds[0],!1),this.render(),e&&this.focusFirst();try{this.handlers.opened?.()}catch{}}close(e=!0){clearTimeout(this.closeTimer),this.isOpen()&&(this.panel.hidden=!0,this.wrap.classList.remove(`open`),this.launcher.setAttribute(`aria-expanded`,`false`),this.view===`done`&&this.reset(),e&&(this.hasButton()?this.launcher.focus():this.returnFocus?.isConnected&&this.returnFocus.focus(),this.returnFocus=null))}currentView(){return this.isOpen()?this.view===`done`?`done`:(this.view===`form`||this.view===`question`)&&this.kind?this.kind.key:`choose`:`button`}showView(e){if(clearTimeout(this.closeTimer),e===`button`)this.close(!1);else{if(this.reset(),e===`done`)this.view=`done`;else if(e!==`choose`){let t=this.kinds.find(t=>t.key===e);t&&this.pick(t,!1)}this.isOpen()?this.render():this.open(!1)}}word(e,t){return this.config.settings.wording?.[e]?.trim()||t}kindTitle(e,t=e.label){return this.word(Nt[e.key],t)}setSuspended(e){this.wrap.style.display=e?`none`:``}destroy(){clearTimeout(this.closeTimer),this.wrap.remove()}reset(){this.view=`choose`,this.kind=null,this.shot={kind:`none`},this.message=``,this.rating=void 0,this.answers={},this.queued=!1,this.asked=null,this.answer=``,this.openedAt=this.isOpen()?Date.now():0,this.hp=``,this.kinds.length===1&&this.pick(this.kinds[0],!1)}holdOpen(){clearTimeout(this.closeTimer)}focusFirst(){for(let e of[`[data-autofocus]`,`.choice`,`textarea`,`button`]){let t=this.panel.querySelector(e);if(t){t.focus();return}}}announce(e){this.live.textContent=``,setTimeout(()=>{this.live.textContent=e},30)}pick(e,t=!0){this.kind=e,this.view=`form`,this.rating=void 0,this.email=this.email||this.handlers.user()?.email||``,e.type===`PROBLEM`&&this.shot.kind===`none`&&this.capture(),e.type!==`PROBLEM`&&this.shot.kind===`busy`&&(this.shot={kind:`none`}),t&&(this.render(),this.focusFirst())}async capture(){this.shot={kind:`busy`},this.render();try{let e=await this.handlers.takeScreenshot();if(this.shot.kind!==`busy`)return;this.shot={kind:`ready`,shot:e},this.announce(`Screenshot added.`)}catch{if(this.shot.kind!==`busy`)return;this.shot={kind:`failed`},this.announce(`Couldn't take a screenshot.`)}this.renderKeepingFocus()}async markUp(){if(this.shot.kind===`ready`){this.setSuspended(!0);try{let e=await this.handlers.markUp(this.shot.shot);e&&(this.shot={kind:`ready`,shot:e},this.announce(e.annotations.length?`Screenshot marked up with ${e.annotations.length} ${e.annotations.length===1?`mark`:`marks`}.`:`Screenshot updated.`))}catch{}finally{this.setSuspended(!1),this.render(),this.panel.querySelector(`[data-markup]`)?.focus()}}}renderKeepingFocus(){let e=this.root.activeElement,t=e?.dataset?.key,n=e?.tagName===`TEXTAREA`?[e.selectionStart,e.selectionEnd]:null;if(this.render(),t){let e=this.panel.querySelector(`[data-key="${t}"]`);e?.focus(),n&&e instanceof HTMLTextAreaElement&&e.setSelectionRange(n[0],n[1])}}header(e,t,n){let r=U(`div`,{class:`head`});if(t){let e=U(`button`,{type:`button`,class:`icon-btn`,"aria-label":`Back`,"data-key":`back`});e.append(W(G.back)),e.addEventListener(`click`,()=>{n?n():(this.view=`choose`,this.kind=null,this.render(),this.focusFirst())}),r.append(e)}r.append(U(`h2`,{class:`title`,id:`pnx-title-${this.uid}`},e));let i=U(`button`,{type:`button`,class:`icon-btn`,"aria-label":`Close feedback`,"data-key":`close`});return i.append(W(G.close)),i.addEventListener(`click`,()=>this.close()),r.append(i),r}powered(){return this.config.branding?.poweredBy?U(`div`,{class:`powered`},U(`a`,{href:`https://getpinax.com`,target:`_blank`,rel:`noopener`},`Powered by Pinax`)):null}logo(){let e=this.config.branding?.logoUrl;if(!e||!/^https?:\/\//i.test(e))return null;let t=U(`img`,{src:e,alt:``,class:`logo`,referrerpolicy:`no-referrer`});return t.addEventListener(`error`,()=>t.remove()),U(`div`,{class:`brand`},t)}render(){let e=[],t=this.logo();t&&e.push(t),this.view===`done`?e.push(...this.renderDone()):this.view===`question`&&this.kind&&this.asked?.question?e.push(...this.renderQuestion(this.kind,this.asked.question)):this.view===`form`&&this.kind?e.push(...this.renderForm(this.kind)):e.push(...this.renderChoose());let n=this.powered();n&&e.push(n),this.panel.replaceChildren(...e)}renderChoose(){let e=U(`ul`,{class:`choices`});for(let t of this.kinds){let n=U(`button`,{type:`button`,class:`choice`},U(`span`,{class:`dot`,"aria-hidden":`true`}),U(`span`,{},this.kindTitle(t),U(`small`,{},t.desc)));n.style.setProperty(`--dot`,t.dot),n.addEventListener(`click`,()=>this.pick(t)),e.append(U(`li`,{},n))}return[this.header(this.word(`chooserTitle`,jt),!1),e]}renderShot(e){let t=this.shot;if(t.kind===`none`){if(e.type===`GENERAL`)return null;let t=U(`button`,{type:`button`,class:`chip`,"data-key":`add-shot`},W(G.camera),`Add a screenshot`);return t.addEventListener(`click`,()=>this.capture()),U(`div`,{class:`shot-actions`},t)}if(t.kind===`busy`)return U(`div`,{class:`shot`,"aria-busy":`true`},U(`span`,{class:`wait`},`Taking a screenshot…`));if(t.kind===`failed`){let e=U(`button`,{type:`button`,class:`chip`,"data-key":`retry-shot`},`Try again`);return e.addEventListener(`click`,()=>this.capture()),U(`div`,{class:`field`},U(`span`,{class:`hint`},`Couldn't take a screenshot of this page.`),U(`div`,{class:`shot-actions`},e))}let n=t.shot.annotations.length,r=t.shot.autoBlurred??0,i=U(`img`,{src:t.shot.dataUrl,alt:`Screenshot of this page${n?` with ${n} ${n===1?`mark`:`marks`}`:``}${r?`, ${r} private ${r===1?`detail`:`details`} blurred`:``}`}),a=U(`button`,{type:`button`,class:`chip primary`,"data-markup":!0,"data-key":`markup`},W(G.pen),n?`Edit marks`:`Mark up`);a.addEventListener(`click`,()=>this.markUp());let o=U(`button`,{type:`button`,class:`chip`,"data-key":`remove-shot`},W(G.trash),`Remove`);return o.addEventListener(`click`,()=>{this.shot={kind:`none`},this.announce(`Screenshot removed.`),this.render(),this.panel.querySelector(`[data-key="add-shot"]`)?.focus()}),U(`div`,{class:`field`},U(`div`,{class:`shot`},i,U(`span`,{class:`tag`,"aria-hidden":`true`},`Screenshot`)),U(`div`,{class:`shot-actions`},a,o),r?U(`span`,{class:`hint auto-blur`},U(`i`,{"aria-hidden":`true`}),`We blurred ${r===1?`1 private detail`:`${r} private details`} for you.`):null)}renderStars(){let e=U(`div`,{class:`stars`,role:`radiogroup`,"aria-labelledby":`pnx-rate-${this.uid}`}),t=[],n=(this.rating??1)-1;for(let e=1;e<=5;e++){let r=U(`button`,{type:`button`,class:this.rating!==void 0&&e<=this.rating?`star on`:`star`,role:`radio`,"aria-checked":this.rating===e?`true`:`false`,"aria-label":`${e} ${e===1?`star`:`stars`}`,tabindex:e-1===n?0:-1,"data-key":`star-${e}`},`★`);r.addEventListener(`click`,()=>{this.rating=this.rating===e?void 0:e,this.renderKeepingFocus()}),r.addEventListener(`keydown`,e=>{let t=e.key===`ArrowRight`||e.key===`ArrowUp`?1:e.key===`ArrowLeft`||e.key===`ArrowDown`?-1:0;if(!t)return;e.preventDefault();let n=Math.min(5,Math.max(1,(this.rating??0)+t||1));this.rating=n,this.render(),this.panel.querySelector(`[data-key="star-${n}"]`)?.focus()}),t.push(r)}return e.append(...t),U(`div`,{class:`field`},U(`span`,{class:`legend`,id:`pnx-rate-${this.uid}`},`How's your visit so far? (optional)`),e)}renderForm(e){let t=e.type===`GENERAL`&&this.config.settings.rating!==!1,n=this.kindTitle(e,t?`How was your visit?`:e.label),r=[this.header(n,this.kinds.length>1)],i=this.renderShot(e);i&&r.push(i),t&&r.push(this.renderStars());let a=`pnx-msg-${this.uid}`,o=U(`textarea`,{id:a,maxlength:5e3,"data-key":`message`,"data-autofocus":e.type!==`PROBLEM`&&!t||void 0,placeholder:this.word(`messagePlaceholder`,e.type===`PROBLEM`?`What happened?`:e.type===`IDEA`?`What would make this better?`:`Tell us what you think`)});o.value=this.message,o.addEventListener(`input`,()=>{this.message=o.value}),r.push(U(`div`,{class:`field`},U(`label`,{for:a},e.type===`PROBLEM`?`What went wrong?`:e.type===`IDEA`?`Your idea`:`Anything to add?`),o)),r.push(...this.renderFields(e));let s=`pnx-email-${this.uid}`,c=`pnx-email-hint-${this.uid}`,l=U(`input`,{id:s,type:`email`,inputmode:`email`,autocomplete:`email`,maxlength:320,"aria-describedby":c,"data-key":`email`,placeholder:`you@example.com`});l.value=this.email,l.addEventListener(`input`,()=>{this.email=l.value}),r.push(U(`div`,{class:`field`},U(`label`,{for:s},`Your email (optional)`),l,U(`span`,{class:`hint`,id:c},`So we can let you know when it's sorted.`)));let u=U(`p`,{class:`error`,role:`alert`,id:`pnx-err-${this.uid}`}),d=U(`button`,{type:`button`,class:`send`,"data-key":`send`,disabled:this.sending},this.sending?`Sending…`:`Send`);return this.colourSend(d,e),d.addEventListener(`click`,()=>this.send(e,u,l,o)),r.push(this.honeypot(),u,d),r}honeypot(){let e=U(`input`,{type:`text`,name:`website`,tabindex:-1,autocomplete:`off`,"aria-label":`Leave this empty`});e.value=this.hp,e.addEventListener(`input`,()=>{this.hp=e.value});let t=U(`div`,{"aria-hidden":`true`},e);return t.style.cssText=`position:absolute;left:-10000px;top:auto;width:1px;height:1px;overflow:hidden`,t}async send(e,t,n,r){if(this.sending)return;t.textContent=``,n.removeAttribute(`aria-invalid`);let i=this.email.trim();if(i&&!k(i)){t.textContent=`Please check your email address, or leave it empty.`,n.setAttribute(`aria-invalid`,`true`),n.setAttribute(`aria-errormessage`,t.id),n.focus();return}if(this.shot.kind===`busy`){t.textContent=`One moment, the screenshot is still being taken.`;return}for(let n of this.fieldsFor(e)){let e=this.answers[n.id];if(!n.required||(n.type===`checkbox`?e===!0:e))continue;let r=this.panel.querySelector(`[data-key="field-${n.id}"]`);t.textContent=n.type===`checkbox`?`Please tick “${n.label}”.`:n.type===`select`?`Please choose an answer for “${n.label}”.`:`Please fill in “${n.label}”.`,r?.setAttribute(`aria-invalid`,`true`),r?.setAttribute(`aria-errormessage`,t.id),r?.focus();return}let a=this.shot.kind===`ready`?this.shot.shot:void 0,o=e.type===`GENERAL`?this.rating:void 0;if(!Ye({type:e.type,message:this.message,rating:o,screenshot:a?.dataUrl})){t.textContent=e.type===`GENERAL`&&this.config.settings.rating!==!1?`Add a few words or a star rating.`:`Add a few words so we know what you mean.`,r.focus();return}this.sending=!0,this.renderKeepingFocus(),this.announce(`Sending…`);let s=await this.askFollowUp(e);this.view!==`form`||this.kind!==e||!this.isOpen()?(this.sending=!1,this.isOpen()&&this.renderKeepingFocus()):s?(this.sending=!1,this.view=`question`,this.render(),this.focusFirst()):await this.submitNow(e,i,o,a)}async askFollowUp(e){let t=this.handlers.followUp,n=this.message.trim();if(!t||e.type===`GENERAL`||!n||n.length>140)return null;if(this.asked?.message===n)return this.asked.question;let r=null;try{r=(await t({type:e.type,message:n}))?.trim()||null}catch{r=null}return this.asked={message:n,question:r?.slice(0,300)||null},this.asked.question}async submitNow(e,t,n,r,i){this.sending=!0,this.renderKeepingFocus();let a;try{a=await this.handlers.submit({type:e.type,message:this.message,rating:n,email:t||void 0,shot:r,followUp:i,fields:this.fieldAnswers(e),hp:this.hp||void 0,elapsedMs:this.openedAt?Math.max(0,Date.now()-this.openedAt):void 0})}catch{a={status:`error`,message:`Something went wrong. Please try again.`}}if(this.sending=!1,a.status===`error`){this.view=`form`,this.render();let e=this.panel.querySelector(`.error`);e&&(e.textContent=a.message),this.panel.querySelector(`[data-key="send"]`)?.focus()}else this.queued=a.status===`queued`,this.view=`done`,this.render(),this.focusFirst(),this.announce(this.queued?`Saved. We'll send it when you're back online.`:this.word(`confirmation`,Mt)),this.closeTimer=setTimeout(()=>this.close(this.panel.contains(this.root.activeElement)),At)}renderQuestion(e,t){let n=[this.header(`One quick question`,!0,()=>{this.view=`form`,this.render(),this.panel.querySelector(`[data-key="message"]`)?.focus()})],r=U(`div`,{class:`note`},U(`span`,{class:`dot`,"aria-hidden":`true`}),U(`span`,{},U(`span`,{class:`sr`},`Your note: `),`“${this.message.trim()}”`));r.style.setProperty(`--dot`,e.dot),n.push(r);let i=`pnx-answer-${this.uid}`,a=`pnx-answer-hint-${this.uid}`,o=U(`textarea`,{id:i,class:`answer`,maxlength:2e3,"data-key":`answer`,"data-autofocus":!0,"aria-describedby":a,placeholder:`Your answer`});o.value=this.answer,o.addEventListener(`input`,()=>{this.answer=o.value}),n.push(U(`div`,{class:`field`},U(`label`,{for:i,class:`question`},t),o,U(`span`,{class:`hint`,id:a},`Optional. It helps us fix it faster.`)));let s=U(`p`,{class:`error`,role:`alert`}),c=this.email.trim(),l=e.type===`GENERAL`?this.rating:void 0,u=this.shot.kind===`ready`?this.shot.shot:void 0,d=U(`button`,{type:`button`,class:`send`,"data-key":`send`,disabled:this.sending},this.sending?`Sending…`:`Send`);this.colourSend(d,e),d.addEventListener(`click`,()=>{if(this.sending)return;let n=this.answer.trim();this.announce(`Sending…`),this.submitNow(e,c,l,u,n?{question:t,answer:n.slice(0,2e3)}:void 0)});let f=U(`button`,{type:`button`,class:`link skip`,"data-key":`skip`,disabled:this.sending},`Skip and send`);return f.addEventListener(`click`,()=>{this.sending||(this.announce(`Sending…`),this.submitNow(e,c,l,u))}),n.push(s,d,f),n}colourSend(e,t){let n=this.sendColour??t.send;e.style.setProperty(`--type`,n),e.style.setProperty(`--type-ink`,this.sendColour?V(n):t.ink)}fieldsFor(e){return(this.config.settings.fields??[]).filter(t=>t.types?.[e.key]!==!1)}fieldAnswers(e){let t=[];for(let n of this.fieldsFor(e)){let e=this.answers[n.id];n.type===`checkbox`?t.push({id:n.id,value:e===!0}):typeof e==`string`&&e.trim()&&t.push({id:n.id,value:e.trim()})}return t.length?t:void 0}renderFields(e){return this.fieldsFor(e).map((e,t)=>{let n=`pnx-f${t}-${this.uid}`,r=`field-${e.id}`,i=e=>{e.removeAttribute(`aria-invalid`),e.removeAttribute(`aria-errormessage`)},a=t=>U(`label`,{for:n,class:t},e.label,e.required?null:U(`span`,{class:`optional`},` (optional)`));if(e.type===`checkbox`){let t=U(`input`,{id:n,type:`checkbox`,"data-key":r,"aria-required":e.required?`true`:void 0});return t.checked=this.answers[e.id]===!0,t.addEventListener(`change`,()=>{this.answers[e.id]=t.checked,i(t)}),U(`div`,{class:`field check`},t,a())}if(e.type===`select`){let t=U(`select`,{id:n,"data-key":r,"aria-required":e.required?`true`:void 0},U(`option`,{value:``},`Choose…`),...e.options.map(e=>U(`option`,{value:e},e)));return t.value=String(this.answers[e.id]??``),t.addEventListener(`change`,()=>{this.answers[e.id]=t.value,i(t)}),U(`div`,{class:`field`},a(),t)}let o=U(`input`,{id:n,type:`text`,maxlength:200,"data-key":r,"aria-required":e.required?`true`:void 0});return o.value=String(this.answers[e.id]??``),o.addEventListener(`input`,()=>{this.answers[e.id]=o.value,i(o)}),U(`div`,{class:`field`},a(),o)})}renderDone(){let e=U(`button`,{type:`button`,class:`link`,"data-key":`again`},`Send another`);e.addEventListener(`click`,()=>{this.reset(),this.render(),this.focusFirst()});let t=U(`div`,{class:`head`});t.append(U(`span`,{class:`title`}));let n=U(`button`,{type:`button`,class:`icon-btn`,"aria-label":`Close feedback`});return n.append(W(G.close)),n.addEventListener(`click`,()=>this.close()),t.append(n),[t,U(`div`,{class:`done`},U(`span`,{class:`tick`,"aria-hidden":`true`},`✓`),U(`h2`,{class:`title`,id:`pnx-title-${this.uid}`,tabindex:-1,"data-autofocus":!0},this.queued?`Saved for later`:this.word(`confirmation`,Mt)),this.queued?U(`p`,{},`You're offline. We'll send it as soon as you're back.`):null,e)]}},K=null,q,Ft,J=(e,t)=>(Ft??window.fetch).call(window,e,t);function Y(e,t){try{(console.warn.__pinaxOriginal??console.warn).call(console,`Pinax: ${e}`,t??``)}catch{}}function X(e){try{e()}catch(e){Y(`capture could not start`,e)}}function It(e){if(K)return;if(!e?.key)throw Error(`Pinax: init() needs a website key`);let t=l(e.apiUrl),n=u(e.cdnUrl,e.apiUrl);Ft=typeof window.fetch==`function`?window.fetch:void 0;let r={options:e,api:t,root:Fe(),user:q,console:new T(50),network:new T(50),breadcrumbs:new T(20),stopCapture:{},onNavigate:[],cleanups:[],openWhenReady:!1,alive:!0};K=r,q=void 0,X(()=>{let e=Lt(Se(r.console));r.stopCapture.console=e,r.cleanups.push(e)}),X(()=>{let i=Lt(Oe(r.network,window,{ignore:r=>r.startsWith(`${t}/v1/widget/`)||n!==null&&r.startsWith(d(n,e.key))}));r.stopCapture.network=i,r.cleanups.push(i)});let a=r.root.host;X(()=>{let e=_e(r.breadcrumbs,{ignore:e=>e instanceof Node&&a.contains(e)});r.onNavigate.push(e.navigated),r.cleanups.push(e.stop)}),X(()=>r.cleanups.push(Le(()=>{for(let e of r.onNavigate)try{e()}catch{}})));let o=()=>{st(J,t,e.key).catch(()=>{})};window.addEventListener(`online`,o),r.cleanups.push(()=>window.removeEventListener(`online`,o)),ee(J,t,e.key,n).then(n=>{if(!r.alive)return;if(!n){Y(`this website key was not found`);return}let a=Ct(n.ai,n.samplingRate);if(r.config={...n,settings:yt(n.settings),branding:St(n.branding),ai:a},Rt(r),te(J,t,e.key,location.href),ot(e.key)&&o(),!n.enabled)return;if(!qt(n.allowedDomains,location.hostname)){Y(`${location.hostname} isn't one of this website's allowed domains, so the button is hidden. Add it under Websites in Pinax.`);return}zt(r);let s=lt(e.segment,r.config.settings.segment);a.replay&&Math.random()<a.replaySampleRate&&Vt(r);let c=new Pt(r.root,r.config,{takeScreenshot:async()=>(await i()).takeScreenshot(r.root.host,{autoBlur:a.autoBlur}),markUp:async e=>(await i()).markUp(r.root,e),submit:e=>Ut(r,e,s),user:()=>r.user,opened:s?dt:void 0,followUp:a.followUp?({type:n,message:r})=>ae(J,t,e.key,{type:n,message:r,pagePath:location.pathname}):void 0});r.ui=c;let{hidePaths:l,hideButton:u}=r.config.settings;if(l.length&&!u){let e=()=>c.setPathHidden(He(l,location.pathname));e(),r.onNavigate.push(e)}r.openWhenReady&&c.open()}).catch(e=>{r.alive&&Y(`could not load widget settings`,e)})}function Lt(e){let t=!1;return()=>{t||(t=!0,e())}}function Rt(e){let t=e.config?.settings.capture;t&&(t.console||(X(()=>e.stopCapture.console?.()),e.console.clear()),t.network||(X(()=>e.stopCapture.network?.()),e.network.clear()))}function zt(e){let t=e.config?.ai;!t?.fixChecks.length||t.fixCheckSampleRate<=0||X(()=>{let n=Ne({checks:t.fixChecks,sampleRate:t.fixCheckSampleRate,console:e.console,network:e.network,report:t=>oe(J,e.api,e.options.key,{checkId:t.id,signature:t.signature})});e.onNavigate.push(n.navigated),e.cleanups.push(n.stop)})}function Bt(e){let t=()=>{let t=window.requestIdleCallback;typeof t==`function`?t(e,{timeout:3e3}):setTimeout(e,200)};document.readyState===`complete`?t():window.addEventListener(`load`,t,{once:!0})}function Vt(e){Bt(()=>{e.alive&&a().then(t=>{if(!e.alive)return;let n=t.startRecorder({exclude:`#${e.root.host.id}`});e.recorder=n,e.cleanups.push(()=>n.stop())}).catch(e=>Y(`session replay could not start`,e))})}async function Ht(e){if(!e.recorder)return null;let t;try{return await Promise.race([e.recorder.exportReplay(O.replayChars).catch(()=>null),new Promise(e=>{t=setTimeout(()=>e(null),5e3)})])}finally{clearTimeout(t)}}async function Ut(e,t,n=!1){let r=n&&!e.user?.id?pt():null,i=r?{...e.user,id:r}:e.user,a=e.config?.settings.capture,o=Qe({type:t.type,message:t.message,rating:t.rating,email:t.email,user:i,screenshot:t.shot?.dataUrl,annotations:t.shot?.annotations,followUp:t.followUp,fields:t.fields,hp:t.hp,elapsedMs:t.elapsedMs},{page:{url:c(location.href),title:document.title||void 0},environment:Ee(),console:a?.console===!1?[]:e.console.toArray(),network:a?.network===!1?[]:e.network.toArray(),breadcrumbs:e.breadcrumbs.toArray()});et(o,await Ht(e));let s=await re(J,e.api,e.options.key,o),l=(e,r)=>{n&&ft({type:t.type,rating:t.rating,reportId:r,queued:e})};return s.ok?(l(!1,s.id||void 0),{status:`sent`}):s.retry&&at(e.options.key,o)?(l(!0),{status:`queued`}):{status:`error`,message:s.message}}function Wt(){K?K.ui?K.ui.open():K.config||(K.openWhenReady=!0):Y(`call init() before open()`)}function Gt(e){let t=e?{...e}:void 0;K?K.user=t:q=t}function Kt(){if(K){K.alive=!1,K.ui?.destroy();for(let e of K.cleanups.reverse())try{e()}catch{}}Ie(),K=null,q=void 0}function qt(e,t){if(!e)return!0;let n=t.toLowerCase();return e.some(e=>e.toLowerCase()===n)}var Z=document.currentScript;Z?.src&&t(Z.src);var Q=Z?.dataset.key,Jt=Z?.dataset.api,Yt=Z?.dataset.segment,Xt=Yt===`true`||Yt!==`false`&&void 0,Zt=Z?.dataset.cdn,$=()=>{Q&&It({key:Q,apiUrl:Jt,cdnUrl:Zt,segment:Xt})},Qt={init:It,open:()=>{$(),Wt()},identify:Gt,destroy:Kt},$t=Array.isArray(window.Pinax?.q)?window.Pinax.q:[];window.Pinax=Qt;for(let[e,t]of $t){let n=Qt[e];try{n?.(...t)}catch{}}Q&&(document.readyState===`complete`?$():window.addEventListener(`load`,$,{once:!0}))})();
|
|
113
|
+
//# sourceMappingURL=pinax.js.map
|