@vitrinka/web 0.8.2 → 0.9.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/CHANGELOG.md +55 -0
- package/README.md +15 -8
- package/build/recorder/version.d.ts +2 -2
- package/build/recorder/version.js +1 -1
- package/build/report/i18n.d.ts +10 -2
- package/build/report/i18n.js +22 -6
- package/build/report/keybind.d.ts +10 -0
- package/build/report/keybind.js +23 -9
- package/build/report/place.d.ts +11 -0
- package/build/report/place.js +14 -0
- package/build/report/settings.d.ts +7 -1
- package/build/report/settings.js +8 -0
- package/build/report/styles.d.ts +1 -1
- package/build/report/styles.js +32 -14
- package/build/report/widget.d.ts +6 -2
- package/build/report/widget.js +135 -54
- package/build/report-widget.mjs +38 -20
- package/package.json +1 -1
package/build/report-widget.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
function R(x,$,z,Q={}){let Z=x,V=Z.__zone_symbol__addEventListener??x.addEventListener,J=Z.__zone_symbol__removeEventListener??x.removeEventListener,X=Q.capture??!1;return V.call(x,$,z,{capture:X,passive:!1}),()=>J.call(x,$,z,X)}class w0 extends Error{constructor(x="link code expired"){super(x);this.name="LinkExpired"}}class x4 extends Error{constructor(x,$){super(`linked into ${x} — this app records into ${$}; link again and pick ${$}`);this.linked=x,this.expected=$,this.name="LinkWorkspaceMismatch"}}class W0 extends Error{constructor(x,$){super(x);this.status=$,this.name="LinkError"}}class g extends Error{constructor(x,$){super(x);this.status=$,this.name="VitrinkaApiError"}}function m(x){return x>=400&&x<500&&x!==408&&x!==429}function $4(x){return new URL(x).origin}function X1(x){let $=/^\/w\/([^/]+)/.exec(new URL(x).pathname);if(!$?.[1])return;try{return decodeURIComponent($[1])}catch{return $[1]}}function sx(x,$){if(!$)return x;let z=new URL(x);return z.searchParams.set("workspace",$),z.href}function z4(x){return x===401}function Q4(x){let $=x.fetch??globalThis.fetch;if(typeof $!=="function")throw Error("vitrinka link: no fetch available");return $}function ex(x,$,z,Q){let Z=(V)=>{if(!V)return;try{let J=new URL(V,x);if(J.protocol!=="http:"&&J.protocol!=="https:")return;if(J.origin===x)return J.href;return x+J.pathname+J.search}catch{return}};return Z($)??Z(z)??x+Q}function V1(x,$,z){let Q=x[$];if(typeof Q!=="string"||Q==="")throw new W0(`link start → malformed payload (${$})`,z);return Q}async function Z4(x,$){let z=$4(x),Q=await Q4($)(`${z}/api/v1/cli/auth`,{method:"POST",mode:"cors",credentials:"omit",headers:{"content-type":"application/json"},body:JSON.stringify({kind:"recorder",label:$.label})});if(Q.status!==201&&Q.status!==200)throw new W0(`link start → ${Q.status}`,Q.status);let Z;try{Z=await Q.json()}catch{throw new W0("link start → malformed payload (not JSON)",Q.status)}if(typeof Z!=="object"||Z===null)throw new W0("link start → malformed payload",Q.status);let V=Z,J=V1(V,"device_code",Q.status),X=V1(V,"user_code",Q.status),G=V1(V,"verify_path",Q.status),Y=V1(V,"qr_path",Q.status);return{base:x,device_code:J,user_code:X,verify_path:G,verifyUrl:sx(ex(z,typeof V.verify_url==="string"?V.verify_url:void 0,G,`/cli-auth?code=${encodeURIComponent(X)}`),$.workspace),qrUrl:sx(ex(z,Y,Y,`/cli-auth/qr?code=${encodeURIComponent(X)}`),$.workspace),interval:Math.max(2,Number(V.interval)||2),expires_in:Number(V.expires_in)||0}}var K8=600,D8=30000;function H8(x){return x>=500||x===408||x===429}function P8(x,$){let z=x.headers.get("retry-after");if(!z)return;let Q=Number(z);if(Number.isFinite(Q)&&Q>=0)return Q*1000;let Z=Date.parse(z);return Number.isNaN(Z)?void 0:Math.max(0,Z-$)}function N8(x,$){return new Promise((z,Q)=>{if($?.aborted)return Q(z2());let Z=setTimeout(()=>{$?.removeEventListener("abort",V),z()},x),V=()=>{clearTimeout(Z),Q(z2())};$?.addEventListener("abort",V,{once:!0})})}function z2(){let x=Error("link polling aborted");return x.name="AbortError",x}async function J4(x,$,z={}){let Q=$4(x),Z=Q4(z),V=z.sleep??N8,J=z.now??Date.now,X=Math.max(2,z.interval??2),G=J()+(z.expiresIn&&z.expiresIn>0?z.expiresIn:K8)*1000,Y=0,F=async(q,U)=>{Y++;let W=G-J();if(W<=0)throw new w0(`link code expired (last claim: ${q})`);let M=Math.max(Math.min(D8,X*1000*2**Y),U??0);await V(Math.min(M,W),z.signal)};for(;;){if(z.signal?.aborted)throw z2();let q;try{q=await Z(`${Q}/api/v1/cli/auth/claim`,{method:"POST",mode:"cors",credentials:"omit",headers:{"content-type":"application/json"},body:JSON.stringify({device_code:$}),signal:z.signal})}catch(U){if(z.signal?.aborted||!(U instanceof TypeError))throw U;await F(U.message);continue}if(H8(q.status)){await F(String(q.status),P8(q,J()));continue}if(Y=0,q.status===200){let U=await q.json();if(z.workspace&&U.workspace!==z.workspace){let W=typeof U.workspace==="string"&&U.workspace?U.workspace:"(no workspace)";throw new x4(W,z.workspace)}return U}if(q.status===404||q.status===410)throw new w0;if(q.status!==202)throw new W0(`link claim → ${q.status}`,q.status);await V(X*1000,z.signal)}}var O={tabId:"root",tabHost:"/",pathname:"/"};function V4(){try{let x=globalThis.sessionStorage,$=x.getItem("vitrinka.tab");if($)return $;let z=Math.random().toString(36).slice(2,10);return x.setItem("vitrinka.tab",z),z}catch{return"root"}}function X4(x,$){O.tabId=x,O.tabHost=$}var y0={following:null},k0="__vitrinkaCaptureOwner";function G4(x,$){let z=globalThis,Q=z[k0];if(Q){if(x==="report")return null;if(Q.face==="report")z[k0]=null,Q.yieldTo?.()}let Z=`${x}:${Date.now().toString(36)}.${Math.random().toString(36).slice(2,10)}`;return z[k0]={face:x,token:Z,...$?{yieldTo:$}:{}},Z}function j4(x){let $=globalThis;if(x&&$[k0]?.token===x)$[k0]=null}var Q2=new Set;function Y4(x){return Q2.add(x),()=>Q2.delete(x)}function o(){for(let x of Q2)x()}async function W4(x,$){let z=`vitrinka.recorder.${x}`;if(globalThis.navigator?.locks){await navigator.locks.request(z,{signal:AbortSignal.timeout(5000)},$);return}let Q={area:L8(),key:`vitrinka.recorder.lock.${x}`},Z=await R8(),V={fence:void 0,since:0};while(!await C8(Z,z,Q,$,V))await O8()}var F4=1000,B8=5,O8=()=>new Promise((x)=>setTimeout(x,B8));function L8(){try{return globalThis.localStorage??null}catch{return null}}function g8(x,$){return typeof $!=="string"||!x.area||x.area.getItem(x.key)===$}function _8(x){if(!x.area)return null;let $=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2)}`;try{return x.area.setItem(x.key,$),$}catch(z){return console.warn("vitrinka: recorder lock fence not stored — the next tab may not see this allocation",z),null}}function A8(x,$){let z=Date.now();if(x.fence!==$)return x.fence=$,x.since=z,!1;if(z-x.since<F4)return!1;return I8(),!0}var U4=!1;function I8(){if(U4)return;U4=!0,console.warn(`vitrinka: this tab did not hear the last recorder lock holder within ${F4} ms — numbering anyway`)}function C8(x,$,z,Q,Z){return new Promise((V,J)=>{let X=x.transaction("locks","readwrite"),G=X.objectStore("locks"),Y=!1;X.oncomplete=()=>V(Y),X.onabort=()=>J(X.error??Error("vitrinka: recorder lock transaction aborted"));let F=G.get($);F.onsuccess=()=>{if(!g8(z,F.result)&&!A8(Z,F.result))return;try{Q()}catch(U){J(U),X.abort();return}Y=!0;let q=_8(z);if(q)G.put(q,$)}})}var p0;function R8(){if(!p0)p0=new Promise((x,$)=>{let z=indexedDB.open("vitrinka.recorder.locks",1);z.onupgradeneeded=()=>z.result.createObjectStore("locks"),z.onerror=()=>$(z.error),z.onsuccess=()=>{let Q=z.result;Q.onversionchange=()=>{Q.close(),p0=void 0},x(Q)}}).catch((x)=>{throw p0=void 0,x});return p0}var Z0="vitrinka.recorder.",Z2=null,S8=!1;function S(){if(!Z2)Z2=T8()??b8();return S8=!0,Z2}function T8(){try{let x=globalThis.localStorage;if(!x)return null;let $=`${Z0}probe`;return x.setItem($,"1"),x.removeItem($),{getString:(z)=>x.getItem(Z0+z),set:(z,Q)=>x.setItem(Z0+z,Q),remove:(z)=>x.removeItem(Z0+z),withLock:W4,keys:()=>Array.from({length:x.length},(z,Q)=>x.key(Q)).filter((z)=>z!==null&&z.startsWith(Z0)).map((z)=>z.slice(Z0.length)),watch:(z,Q)=>{let Z=(V)=>{if(V.storageArea===x&&V.key===Z0+z)Q(V.newValue)};return globalThis.addEventListener("storage",Z),()=>globalThis.removeEventListener("storage",Z)}}}catch{return console.warn("vitrinka: localStorage unavailable — the recorder queue will not survive a reload"),null}}function b8(){let x=new Map;return{getString:($)=>x.get($)??null,set:($,z)=>void x.set($,z),remove:($)=>void x.delete($),keys:()=>[...x.keys()]}}var F0={url:"",key:""};function G1(){return F0}var J2=new Set;function q4(x){let $=x.replace(/\/+$/,"");return J2.add($),()=>J2.delete($)}function V2(x){if(F0.url!==""&&x.startsWith(F0.url))return!0;for(let $ of J2)if($!==""&&x.startsWith($))return!0;return!1}var v0="link";function h0(){let x=S().getString(v0);if(!x)return null;try{let $=JSON.parse(x);return typeof $.token==="string"&&$.token?$:null}catch{return null}}function M4(x){S().set(v0,JSON.stringify(x)),o()}function K4(){S().remove(v0),o()}function D4(){return F0.key||h0()?.token||""}function H4(){if(F0.label)return F0.label;let x=globalThis.navigator?.userAgent??"",$=/Edg\//.test(x)?"Edge":/OPR\//.test(x)?"Opera":/Chrome\//.test(x)?"Chrome":/Firefox\//.test(x)?"Firefox":/Safari\//.test(x)?"Safari":"Browser",z=/iPhone|iPad/.test(x)?"iOS":/Android/.test(x)?"Android":/Mac OS X/.test(x)?"macOS":/Windows/.test(x)?"Windows":/Linux/.test(x)?"Linux":"unknown OS",Q=globalThis.location?.host??"";return`${$} on ${z}${Q?` · ${Q}`:""}`}function P4(x){return`${x}.${Math.random().toString(36).slice(2,10)}`}var E8=null;function N4(x){if(z4(x))E8?.()}function B4(x){return x??{url:G1().url,key:D4()}}async function n(x,$,z,Q={}){let{url:Z,key:V}=B4(Q.target),J=await fetch(Z+$,{method:x,mode:"cors",credentials:"omit",keepalive:Q.keepalive??!1,...Q.signal?{signal:Q.signal}:{},headers:{authorization:`Bearer ${V}`,...z!==void 0?{"content-type":"application/json"}:{}},body:z===void 0?void 0:JSON.stringify(z)}),X=await J.text();if(!J.ok){if(!Q.target)N4(J.status);throw new g(`${x} ${$} → ${J.status}: ${X}`,J.status)}return X?JSON.parse(X):{}}function O4(x,$,z){return g4(x,"chunk",$,"application/json",z)}function L4(x,$,z){return g4(x,"shot",$,z.type,z)}function g4(x,$,z,Q,Z){return X2(`/api/v1/sessions/${x}/${$}?seq=${z}`,Q,Z)}async function X2(x,$,z,Q,Z){let{url:V,key:J}=B4(Q),X=await fetch(V+x,{method:"POST",mode:"cors",credentials:"omit",...Z?{signal:Z}:{},headers:{authorization:`Bearer ${J}`,"content-type":$},body:z}),G=await X.text();if(!X.ok){if(!Q)N4(X.status);throw new g(`POST ${x} → ${X.status}: ${G}`,X.status)}try{return JSON.parse(G)}catch{return{}}}var I4="[redacted]",f8=["authorization","proxyauthorization","cookie","setcookie","xapikey","xauthtoken","xcsrftoken","xamzsecuritytoken"],w8=["password","passwd","secret","token","accesstoken","refreshtoken","idtoken","authorization","apikey","clientsecret","card","cardnumber","cvv","cvc","pin","ssn"];function q0(x){return String(x).toLowerCase().replace(/[-_]/g,"")}var G2=null;function j2(x){let $=JSON.stringify(x??null);if(G2?.src===$)return G2.rules;let z=new Set(f8),Q=new Set(w8),Z=[];for(let J of x?.extraHeaders??[]){let X=q0(J);if(X)z.add(X)}for(let J of x?.extraBodyKeys??[]){let X=q0(J);if(X)Q.add(X)}for(let J of x?.patterns??[])try{Z.push(new RegExp(J,"g"))}catch(X){console.warn("vitrinka redact: unsupported pattern skipped",J,X)}let V={full:x?.fullFidelity===!0,maskAllText:x?.maskAllText===!0,headers:z,bodyKeys:Q,patterns:Z};return G2={src:$,rules:V},V}var k8=new Set(["password","passwd","pwd","secret","token","auth","authorization","otp","pin","apikey","credential","credentials","cookie","cvv","cvc","iban","ssn"]),y8=["apikey","privatekey","secretkey","sessionid","cardnumber","birthnumber","rodnecislo","accesstoken","refreshtoken","idtoken"];function p8(x){return x.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map(($)=>$.toLowerCase())}function C4(x){let $=p8(x);if($.some((z)=>k8.has(z)))return!0;for(let z=0;z<$.length;z++){let Q="";for(let Z=z;Z<$.length;Z++){if(Q+=$[Z],y8.includes(Q))return!0;if(Q.length>24)break}}return!1}function R4(x,$){let z=q0($);return x.headers.has(z)||z.endsWith("apikey")||z.endsWith("token")||C4($)}function a(x,$){return x.bodyKeys.has(q0($))||C4($)}function S4(x,$){if(a(x,$))return!0;let z=q0($);return z.endsWith("apikey")||z.endsWith("token")}var v8=/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g,h8=/-----BEGIN[A-Z +]*PRIVATE[ +]KEY-----/;function T4(x){return x.includes("PRIVATE KEY-----")?x.replace(v8,"[redacted]"):x}function M0(x,$){let z=T4($);for(let Q of x.patterns)Q.lastIndex=0,z=z.replace(Q,"[redacted]");return z}function b4(x,$){if(h8.test($))return!0;for(let z of $.matchAll(/([A-Za-z][A-Za-z0-9_.\-[\]]{0,60})\s*[:=]/g))if(a(x,z[1]))return!0;return!1}function j1(x){let $=x;for(let z=0;z<3;z++){let Q=m8($);if(Q===$)break;$=Q}return $}function m8(x){if(!x.includes("%"))return x;try{return decodeURIComponent(x)}catch{return x.replace(/(%[0-9A-Fa-f]{2})+/g,($)=>{try{return decodeURIComponent($)}catch{return $.replace(/%([0-9A-Fa-f]{2})/g,(z,Q)=>{let Z=Number.parseInt(Q,16);return Z<128?String.fromCharCode(Z):z})}})}}function E4(x,$,z){let Q=!1,Z=z.split(/[&;]/).map((V)=>{if(V==="")return V;let J=V.indexOf("="),X=J>=0?V.slice(0,J):V,G=j1(X.replace(/\+/g," ")),Y=G.lastIndexOf("?"),F=Y>=0?G.slice(Y+1):null;if($(x,G)||F!==null&&$(x,F))return Q=!0,`${X}=[redacted]`;if(J>=0&&b4(x,j1(V.slice(J+1))))return Q=!0,`${X}=[redacted]`;return V});return Q?Z.join("&"):z}function Y2(x,$){if(x.full||!$)return $;let z=$.search(/[?#]/);if(z<0)return M0(x,$);let Q=$.slice(z+1).split("#").map((Z)=>E4(x,S4,Z)).join("#");return M0(x,$.slice(0,z+1)+Q)}var u8=/([A-Za-z][A-Za-z0-9_.\-[\]]{0,60})("?\s*[:=]\s*(?!\/\/))("?)([^&?"'\s,}]*)\3/g,c8=/([?&])([^=&#\s]{1,120})=([^&#\s]*)/g,d8=/^([A-Za-z][A-Za-z0-9_.-]{0,60})[ \t]*:[ \t]*(.+)$/gm,i8=131072;function Y1(x,$){if($.length>i8)return`[body omitted: ${$.length} bytes, unmaskable]`;let z=T4($).replace(d8,(Q,Z)=>R4(x,Z)?`${Z}: [redacted]`:Q).replace(/\b((?:proxy-)?authorization|www-authenticate)(\s*[:=]\s*)[^\r\n]+/gi,(Q,Z,V)=>`${Z}${V}[redacted]`).replace(/\b(Digest|Negotiate|NTLM)\s+(?=[A-Za-z][A-Za-z-]{0,30}\s*=)[^\r\n]+/gi,(Q,Z)=>`${Z} [redacted]`).replace(/\b(Bearer|Basic)\s+[A-Za-z0-9._~+/=-]+/gi,"$1 [redacted]").replace(/\beyJ[A-Za-z0-9._-]{10,}/g,"[redacted]").replace(c8,(Q,Z,V,J)=>{if(S4(x,j1(V)))return`${Z}${V}=[redacted]`;if(b4(x,j1(J)))return`${Z}${V}=[redacted]`;return Q}).replace(u8,(Q,Z,V,J,X)=>{if(X==="[redacted]")return Q;return a(x,Z)?`${Z}${V}${J}[redacted]${J}`:Q});return M0(x,z)}function l8(x){switch(q0(x)){case"url":case"href":case"uri":case"location":return!0;default:return!1}}var o8=64;function U1(x,$,z){if(z>o8)return"[redacted]";if(Array.isArray($))return $.map((Q)=>U1(x,Q,z+1));if($!==null&&typeof $==="object"){let Q={};for(let[Z,V]of Object.entries($))if(a(x,Z))Q[Z]="[redacted]";else if(typeof V==="string"&&l8(Z))Q[Z]=Y2(x,V);else Q[Z]=U1(x,V,z+1);return Q}return typeof $==="string"?M0(x,$):$}function _4(x){if(!x.includes("\\"))return x;return x.replace(/\\u([0-9A-Fa-f]{4})|\\(.)/g,($,z,Q)=>z!==void 0?String.fromCharCode(Number.parseInt(z,16)):Q)}function n8(x,$){for(let z of $.matchAll(/"((?:[^"\\\r\n]|\\.)*)"\s*:\s*[{\[]/g))if(a(x,_4(z[1])))return"";return $.replace(/("((?:[A-Za-z0-9_-]|\\u[0-9A-Fa-f]{4}|\\.)+)"\s*:\s*)("(?:[^"\\]|\\.)*"?|[^,{}[\]"\r\n]*)/g,(z,Q,Z)=>a(x,_4(Z))?`${Q}"[redacted]"`:z)}function U2(x){let $=x.trimStart();return $.startsWith("{")||$.startsWith("[")}function a8(x,$,z){let Q=/boundary="?([^";]+)"?/i.exec(z);if(!Q)return null;let Z=`--${Q[1]}`,V=$.split(Z);if(V.length<3||V[0]!=="")return null;if(!V[V.length-1].startsWith("--"))return null;let J=[V[0]];for(let X=1;X<V.length-1;X++){let G=V[X];if(!G.startsWith(`\r
|
|
1
|
+
function C(x,$,z,Q={}){let Z=x,J=Z.__zone_symbol__addEventListener??x.addEventListener,V=Z.__zone_symbol__removeEventListener??x.removeEventListener,X=Q.capture??!1;return J.call(x,$,z,{capture:X,passive:!1}),()=>V.call(x,$,z,X)}class f0 extends Error{constructor(x="link code expired"){super(x);this.name="LinkExpired"}}class X4 extends Error{constructor(x,$){super(`linked into ${x} — this app records into ${$}; link again and pick ${$}`);this.linked=x,this.expected=$,this.name="LinkWorkspaceMismatch"}}class U0 extends Error{constructor(x,$){super(x);this.status=$,this.name="LinkError"}}class L extends Error{constructor(x,$){super(x);this.status=$,this.name="VitrinkaApiError"}}function m(x){return x>=400&&x<500&&x!==408&&x!==429}function G4(x){return new URL(x).origin}function Y1(x){let $=/^\/w\/([^/]+)/.exec(new URL(x).pathname);if(!$?.[1])return;try{return decodeURIComponent($[1])}catch{return $[1]}}function J4(x,$){if(!$)return x;let z=new URL(x);return z.searchParams.set("workspace",$),z.href}function j4(x){return x===401}function Y4(x){let $=x.fetch??globalThis.fetch;if(typeof $!=="function")throw Error("vitrinka link: no fetch available");return $}function V4(x,$,z,Q){let Z=(J)=>{if(!J)return;try{let V=new URL(J,x);if(V.protocol!=="http:"&&V.protocol!=="https:")return;if(V.origin===x)return V.href;return x+V.pathname+V.search}catch{return}};return Z($)??Z(z)??x+Q}function j1(x,$,z){let Q=x[$];if(typeof Q!=="string"||Q==="")throw new U0(`link start → malformed payload (${$})`,z);return Q}async function W4(x,$){let z=G4(x),Q=await Y4($)(`${z}/api/v1/cli/auth`,{method:"POST",mode:"cors",credentials:"omit",headers:{"content-type":"application/json"},body:JSON.stringify({kind:"recorder",label:$.label})});if(Q.status!==201&&Q.status!==200)throw new U0(`link start → ${Q.status}`,Q.status);let Z;try{Z=await Q.json()}catch{throw new U0("link start → malformed payload (not JSON)",Q.status)}if(typeof Z!=="object"||Z===null)throw new U0("link start → malformed payload",Q.status);let J=Z,V=j1(J,"device_code",Q.status),X=j1(J,"user_code",Q.status),G=j1(J,"verify_path",Q.status),Y=j1(J,"qr_path",Q.status);return{base:x,device_code:V,user_code:X,verify_path:G,verifyUrl:J4(V4(z,typeof J.verify_url==="string"?J.verify_url:void 0,G,`/cli-auth?code=${encodeURIComponent(X)}`),$.workspace),qrUrl:J4(V4(z,Y,Y,`/cli-auth/qr?code=${encodeURIComponent(X)}`),$.workspace),interval:Math.max(2,Number(J.interval)||2),expires_in:Number(J.expires_in)||0}}var S8=600,T8=30000;function b8(x){return x>=500||x===408||x===429}function E8(x,$){let z=x.headers.get("retry-after");if(!z)return;let Q=Number(z);if(Number.isFinite(Q)&&Q>=0)return Q*1000;let Z=Date.parse(z);return Number.isNaN(Z)?void 0:Math.max(0,Z-$)}function w8(x,$){return new Promise((z,Q)=>{if($?.aborted)return Q($2());let Z=setTimeout(()=>{$?.removeEventListener("abort",J),z()},x),J=()=>{clearTimeout(Z),Q($2())};$?.addEventListener("abort",J,{once:!0})})}function $2(){let x=Error("link polling aborted");return x.name="AbortError",x}async function U4(x,$,z={}){let Q=G4(x),Z=Y4(z),J=z.sleep??w8,V=z.now??Date.now,X=Math.max(2,z.interval??2),G=V()+(z.expiresIn&&z.expiresIn>0?z.expiresIn:S8)*1000,Y=0,U=async(q,W)=>{Y++;let F=G-V();if(F<=0)throw new f0(`link code expired (last claim: ${q})`);let M=Math.max(Math.min(T8,X*1000*2**Y),W??0);await J(Math.min(M,F),z.signal)};for(;;){if(z.signal?.aborted)throw $2();let q;try{q=await Z(`${Q}/api/v1/cli/auth/claim`,{method:"POST",mode:"cors",credentials:"omit",headers:{"content-type":"application/json"},body:JSON.stringify({device_code:$}),signal:z.signal})}catch(W){if(z.signal?.aborted||!(W instanceof TypeError))throw W;await U(W.message);continue}if(b8(q.status)){await U(String(q.status),E8(q,V()));continue}if(Y=0,q.status===200){let W=await q.json();if(z.workspace&&W.workspace!==z.workspace){let F=typeof W.workspace==="string"&&W.workspace?W.workspace:"(no workspace)";throw new X4(F,z.workspace)}return W}if(q.status===404||q.status===410)throw new f0;if(q.status!==202)throw new U0(`link claim → ${q.status}`,q.status);await J(X*1000,z.signal)}}var g={tabId:"root",tabHost:"/",pathname:"/"};function F4(){try{let x=globalThis.sessionStorage,$=x.getItem("vitrinka.tab");if($)return $;let z=Math.random().toString(36).slice(2,10);return x.setItem("vitrinka.tab",z),z}catch{return"root"}}function q4(x,$){g.tabId=x,g.tabHost=$}var y0={following:null},k0="__vitrinkaCaptureOwner";function M4(x,$){let z=globalThis,Q=z[k0];if(Q){if(x==="report")return null;if(Q.face==="report")z[k0]=null,Q.yieldTo?.()}let Z=`${x}:${Date.now().toString(36)}.${Math.random().toString(36).slice(2,10)}`;return z[k0]={face:x,token:Z,...$?{yieldTo:$}:{}},Z}function K4(x){let $=globalThis;if(x&&$[k0]?.token===x)$[k0]=null}var z2=new Set;function D4(x){return z2.add(x),()=>z2.delete(x)}function o(){for(let x of z2)x()}async function H4(x,$){let z=`vitrinka.recorder.${x}`;if(globalThis.navigator?.locks){await navigator.locks.request(z,{signal:AbortSignal.timeout(5000)},$);return}let Q={area:y8(),key:`vitrinka.recorder.lock.${x}`},Z=await d8(),J={fence:void 0,since:0};while(!await u8(Z,z,Q,$,J))await k8()}var N4=1000,f8=5,k8=()=>new Promise((x)=>setTimeout(x,f8));function y8(){try{return globalThis.localStorage??null}catch{return null}}function p8(x,$){return typeof $!=="string"||!x.area||x.area.getItem(x.key)===$}function v8(x){if(!x.area)return null;let $=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2)}`;try{return x.area.setItem(x.key,$),$}catch(z){return console.warn("vitrinka: recorder lock fence not stored — the next tab may not see this allocation",z),null}}function h8(x,$){let z=Date.now();if(x.fence!==$)return x.fence=$,x.since=z,!1;if(z-x.since<N4)return!1;return m8(),!0}var P4=!1;function m8(){if(P4)return;P4=!0,console.warn(`vitrinka: this tab did not hear the last recorder lock holder within ${N4} ms — numbering anyway`)}function u8(x,$,z,Q,Z){return new Promise((J,V)=>{let X=x.transaction("locks","readwrite"),G=X.objectStore("locks"),Y=!1;X.oncomplete=()=>J(Y),X.onabort=()=>V(X.error??Error("vitrinka: recorder lock transaction aborted"));let U=G.get($);U.onsuccess=()=>{if(!p8(z,U.result)&&!h8(Z,U.result))return;try{Q()}catch(W){V(W),X.abort();return}Y=!0;let q=v8(z);if(q)G.put(q,$)}})}var p0;function d8(){if(!p0)p0=new Promise((x,$)=>{let z=indexedDB.open("vitrinka.recorder.locks",1);z.onupgradeneeded=()=>z.result.createObjectStore("locks"),z.onerror=()=>$(z.error),z.onsuccess=()=>{let Q=z.result;Q.onversionchange=()=>{Q.close(),p0=void 0},x(Q)}}).catch((x)=>{throw p0=void 0,x});return p0}var Z0="vitrinka.recorder.",Q2=null,c8=!1;function S(){if(!Q2)Q2=i8()??l8();return c8=!0,Q2}function i8(){try{let x=globalThis.localStorage;if(!x)return null;let $=`${Z0}probe`;return x.setItem($,"1"),x.removeItem($),{getString:(z)=>x.getItem(Z0+z),set:(z,Q)=>x.setItem(Z0+z,Q),remove:(z)=>x.removeItem(Z0+z),withLock:H4,keys:()=>Array.from({length:x.length},(z,Q)=>x.key(Q)).filter((z)=>z!==null&&z.startsWith(Z0)).map((z)=>z.slice(Z0.length)),watch:(z,Q)=>{let Z=(J)=>{if(J.storageArea===x&&J.key===Z0+z)Q(J.newValue)};return globalThis.addEventListener("storage",Z),()=>globalThis.removeEventListener("storage",Z)}}}catch{return console.warn("vitrinka: localStorage unavailable — the recorder queue will not survive a reload"),null}}function l8(){let x=new Map;return{getString:($)=>x.get($)??null,set:($,z)=>void x.set($,z),remove:($)=>void x.delete($),keys:()=>[...x.keys()]}}var F0={url:"",key:""};function W1(){return F0}var Z2=new Set;function B4(x){let $=x.replace(/\/+$/,"");return Z2.add($),()=>Z2.delete($)}function J2(x){if(F0.url!==""&&x.startsWith(F0.url))return!0;for(let $ of Z2)if($!==""&&x.startsWith($))return!0;return!1}var v0="link";function h0(){let x=S().getString(v0);if(!x)return null;try{let $=JSON.parse(x);return typeof $.token==="string"&&$.token?$:null}catch{return null}}function g4(x){S().set(v0,JSON.stringify(x)),o()}function O4(){S().remove(v0),o()}function L4(){return F0.key||h0()?.token||""}function _4(){if(F0.label)return F0.label;let x=globalThis.navigator?.userAgent??"",$=/Edg\//.test(x)?"Edge":/OPR\//.test(x)?"Opera":/Chrome\//.test(x)?"Chrome":/Firefox\//.test(x)?"Firefox":/Safari\//.test(x)?"Safari":"Browser",z=/iPhone|iPad/.test(x)?"iOS":/Android/.test(x)?"Android":/Mac OS X/.test(x)?"macOS":/Windows/.test(x)?"Windows":/Linux/.test(x)?"Linux":"unknown OS",Q=globalThis.location?.host??"";return`${$} on ${z}${Q?` · ${Q}`:""}`}function I4(x){return`${x}.${Math.random().toString(36).slice(2,10)}`}var o8=null;function A4(x){if(j4(x))o8?.()}function R4(x){return x??{url:W1().url,key:L4()}}async function n(x,$,z,Q={}){let{url:Z,key:J}=R4(Q.target),V=await fetch(Z+$,{method:x,mode:"cors",credentials:"omit",keepalive:Q.keepalive??!1,...Q.signal?{signal:Q.signal}:{},headers:{authorization:`Bearer ${J}`,...z!==void 0?{"content-type":"application/json"}:{}},body:z===void 0?void 0:JSON.stringify(z)}),X=await V.text();if(!V.ok){if(!Q.target)A4(V.status);throw new L(`${x} ${$} → ${V.status}: ${X}`,V.status)}return X?JSON.parse(X):{}}function C4(x,$,z){return T4(x,"chunk",$,"application/json",z)}function S4(x,$,z){return T4(x,"shot",$,z.type,z)}function T4(x,$,z,Q,Z){return V2(`/api/v1/sessions/${x}/${$}?seq=${z}`,Q,Z)}async function V2(x,$,z,Q,Z){let{url:J,key:V}=R4(Q),X=await fetch(J+x,{method:"POST",mode:"cors",credentials:"omit",...Z?{signal:Z}:{},headers:{authorization:`Bearer ${V}`,"content-type":$},body:z}),G=await X.text();if(!X.ok){if(!Q)A4(X.status);throw new L(`POST ${x} → ${X.status}: ${G}`,X.status)}try{return JSON.parse(G)}catch{return{}}}var w4="[redacted]",n8=["authorization","proxyauthorization","cookie","setcookie","xapikey","xauthtoken","xcsrftoken","xamzsecuritytoken"],a8=["password","passwd","secret","token","accesstoken","refreshtoken","idtoken","authorization","apikey","clientsecret","card","cardnumber","cvv","cvc","pin","ssn"];function q0(x){return String(x).toLowerCase().replace(/[-_]/g,"")}var X2=null;function G2(x){let $=JSON.stringify(x??null);if(X2?.src===$)return X2.rules;let z=new Set(n8),Q=new Set(a8),Z=[];for(let V of x?.extraHeaders??[]){let X=q0(V);if(X)z.add(X)}for(let V of x?.extraBodyKeys??[]){let X=q0(V);if(X)Q.add(X)}for(let V of x?.patterns??[])try{Z.push(new RegExp(V,"g"))}catch(X){console.warn("vitrinka redact: unsupported pattern skipped",V,X)}let J={full:x?.fullFidelity===!0,maskAllText:x?.maskAllText===!0,headers:z,bodyKeys:Q,patterns:Z};return X2={src:$,rules:J},J}var r8=new Set(["password","passwd","pwd","secret","token","auth","authorization","otp","pin","apikey","credential","credentials","cookie","cvv","cvc","iban","ssn"]),t8=["apikey","privatekey","secretkey","sessionid","cardnumber","birthnumber","rodnecislo","accesstoken","refreshtoken","idtoken"];function s8(x){return x.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map(($)=>$.toLowerCase())}function f4(x){let $=s8(x);if($.some((z)=>r8.has(z)))return!0;for(let z=0;z<$.length;z++){let Q="";for(let Z=z;Z<$.length;Z++){if(Q+=$[Z],t8.includes(Q))return!0;if(Q.length>24)break}}return!1}function k4(x,$){let z=q0($);return x.headers.has(z)||z.endsWith("apikey")||z.endsWith("token")||f4($)}function a(x,$){return x.bodyKeys.has(q0($))||f4($)}function y4(x,$){if(a(x,$))return!0;let z=q0($);return z.endsWith("apikey")||z.endsWith("token")}var e8=/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g,x9=/-----BEGIN[A-Z +]*PRIVATE[ +]KEY-----/;function p4(x){return x.includes("PRIVATE KEY-----")?x.replace(e8,"[redacted]"):x}function M0(x,$){let z=p4($);for(let Q of x.patterns)Q.lastIndex=0,z=z.replace(Q,"[redacted]");return z}function v4(x,$){if(x9.test($))return!0;for(let z of $.matchAll(/([A-Za-z][A-Za-z0-9_.\-[\]]{0,60})\s*[:=]/g))if(a(x,z[1]))return!0;return!1}function U1(x){let $=x;for(let z=0;z<3;z++){let Q=$9($);if(Q===$)break;$=Q}return $}function $9(x){if(!x.includes("%"))return x;try{return decodeURIComponent(x)}catch{return x.replace(/(%[0-9A-Fa-f]{2})+/g,($)=>{try{return decodeURIComponent($)}catch{return $.replace(/%([0-9A-Fa-f]{2})/g,(z,Q)=>{let Z=Number.parseInt(Q,16);return Z<128?String.fromCharCode(Z):z})}})}}function h4(x,$,z){let Q=!1,Z=z.split(/[&;]/).map((J)=>{if(J==="")return J;let V=J.indexOf("="),X=V>=0?J.slice(0,V):J,G=U1(X.replace(/\+/g," ")),Y=G.lastIndexOf("?"),U=Y>=0?G.slice(Y+1):null;if($(x,G)||U!==null&&$(x,U))return Q=!0,`${X}=[redacted]`;if(V>=0&&v4(x,U1(J.slice(V+1))))return Q=!0,`${X}=[redacted]`;return J});return Q?Z.join("&"):z}function j2(x,$){if(x.full||!$)return $;let z=$.search(/[?#]/);if(z<0)return M0(x,$);let Q=$.slice(z+1).split("#").map((Z)=>h4(x,y4,Z)).join("#");return M0(x,$.slice(0,z+1)+Q)}var z9=/([A-Za-z][A-Za-z0-9_.\-[\]]{0,60})("?\s*[:=]\s*(?!\/\/))("?)([^&?"'\s,}]*)\3/g,Q9=/([?&])([^=&#\s]{1,120})=([^&#\s]*)/g,Z9=/^([A-Za-z][A-Za-z0-9_.-]{0,60})[ \t]*:[ \t]*(.+)$/gm,J9=131072;function F1(x,$){if($.length>J9)return`[body omitted: ${$.length} bytes, unmaskable]`;let z=p4($).replace(Z9,(Q,Z)=>k4(x,Z)?`${Z}: [redacted]`:Q).replace(/\b((?:proxy-)?authorization|www-authenticate)(\s*[:=]\s*)[^\r\n]+/gi,(Q,Z,J)=>`${Z}${J}[redacted]`).replace(/\b(Digest|Negotiate|NTLM)\s+(?=[A-Za-z][A-Za-z-]{0,30}\s*=)[^\r\n]+/gi,(Q,Z)=>`${Z} [redacted]`).replace(/\b(Bearer|Basic)\s+[A-Za-z0-9._~+/=-]+/gi,"$1 [redacted]").replace(/\beyJ[A-Za-z0-9._-]{10,}/g,"[redacted]").replace(Q9,(Q,Z,J,V)=>{if(y4(x,U1(J)))return`${Z}${J}=[redacted]`;if(v4(x,U1(V)))return`${Z}${J}=[redacted]`;return Q}).replace(z9,(Q,Z,J,V,X)=>{if(X==="[redacted]")return Q;return a(x,Z)?`${Z}${J}${V}[redacted]${V}`:Q});return M0(x,z)}function V9(x){switch(q0(x)){case"url":case"href":case"uri":case"location":return!0;default:return!1}}var X9=64;function q1(x,$,z){if(z>X9)return"[redacted]";if(Array.isArray($))return $.map((Q)=>q1(x,Q,z+1));if($!==null&&typeof $==="object"){let Q={};for(let[Z,J]of Object.entries($))if(a(x,Z))Q[Z]="[redacted]";else if(typeof J==="string"&&V9(Z))Q[Z]=j2(x,J);else Q[Z]=q1(x,J,z+1);return Q}return typeof $==="string"?M0(x,$):$}function b4(x){if(!x.includes("\\"))return x;return x.replace(/\\u([0-9A-Fa-f]{4})|\\(.)/g,($,z,Q)=>z!==void 0?String.fromCharCode(Number.parseInt(z,16)):Q)}function G9(x,$){for(let z of $.matchAll(/"((?:[^"\\\r\n]|\\.)*)"\s*:\s*[{\[]/g))if(a(x,b4(z[1])))return"";return $.replace(/("((?:[A-Za-z0-9_-]|\\u[0-9A-Fa-f]{4}|\\.)+)"\s*:\s*)("(?:[^"\\]|\\.)*"?|[^,{}[\]"\r\n]*)/g,(z,Q,Z)=>a(x,b4(Z))?`${Q}"[redacted]"`:z)}function Y2(x){let $=x.trimStart();return $.startsWith("{")||$.startsWith("[")}function j9(x,$,z){let Q=/boundary="?([^";]+)"?/i.exec(z);if(!Q)return null;let Z=`--${Q[1]}`,J=$.split(Z);if(J.length<3||J[0]!=="")return null;if(!J[J.length-1].startsWith("--"))return null;let V=[J[0]];for(let X=1;X<J.length-1;X++){let G=J[X];if(!G.startsWith(`\r
|
|
2
2
|
`)||!G.endsWith(`\r
|
|
3
3
|
`))return null;let Y=G.indexOf(`\r
|
|
4
4
|
\r
|
|
5
|
-
`);if(Y<0)return null;let
|
|
6
|
-
${
|
|
5
|
+
`);if(Y<0)return null;let U=G.slice(2,Y),q=G.slice(Y+4,-2),F=/content-disposition:[^\r\n]*;\s*name="([^"]*)"/i.exec(U)?.[1]??"",M=F!==""&&a(x,F)?"[redacted]":F1(x,q);V.push(`\r
|
|
6
|
+
${U}\r
|
|
7
7
|
\r
|
|
8
8
|
${M}\r
|
|
9
|
-
`)}return J.push(V[V.length-1]),J.join(Z)}var f4=262144;function A4(x,$,z){if(x.full||!$)return $;try{if(U2($)){if($.length<=f4)try{return JSON.stringify(U1(x,JSON.parse($),0))}catch{}return M0(x,n8(x,$))}let Q=(z??"").toLowerCase();if(Q.includes("x-www-form-urlencoded"))return Y1(x,E4(x,a,$));if(Q.includes("multipart/form-data")){let Z=a8(x,$,z??"");if(Z!==null)return Z;return`[multipart body omitted: unparseable (${$.length} chars)]`}return Y1(x,$)}catch{return"[redacted]"}}function w4(x,$){if($===void 0)return;if(x.full)return $;if(U2($))try{return JSON.stringify(U1(x,JSON.parse($),0))}catch{}try{return Y1(x,$)}catch{return"[redacted]"}}function k4(x,$,z,Q){if(x.full)return $.length>z?`${$.slice(0,z)}…[truncated]`:$;if($.length>z&&Q?.toLowerCase().includes("multipart/form-data"))return`[multipart body omitted: oversized (${$.length} chars)]`;if(U2($)&&$.length<=f4){let V=A4(x,$,Q);return V.length>z?`${V.slice(0,z)}…[truncated]`:V}let Z=$.length>z?`${$.slice(0,z)}…[truncated]`:$;return A4(x,Z,Q)}function y4(x,$,z){if(!$)return;let Q=z?.maxValueLen??1024,Z=z?.budget??8192,V={};for(let[J,X]of Object.entries($)){let Y=(x.full?String(X):R4(x,J)?"[redacted]":M0(x,String(X))).slice(0,Q);if(Z-=J.length+Y.length,Z<0){V["…"]="(truncated)";break}V[J]=Y}return V}function p4(x){if(x.full)return{maskAllInputs:!1,maskAllText:!1};return{maskAllInputs:!0,maskAllText:x.maskAllText,...x.maskAllText?{maskTextSelector:"*"}:{}}}var K0=j2(null);function h4(x){K0=j2(x??null)}function m4(x){return w4(K0,x)}function W2(x,$,z){return k4(K0,x,$,z)}var v4=null,u4=null;function F2(x){u4=x??null}function r8(x){let $=u4??G1().sanitizeUrl;if(!$)return x;let z;try{let Q=$(x);if(typeof Q==="string")return Q;z=`returned ${typeof Q}`}catch{z="threw"}if(v4!==$)v4=$,console.warn(`vitrinka: sanitizeUrl ${z} — such URLs are recorded as their origin only`);return t8(x)??I4}function t8(x){try{let{origin:$}=new URL(x);return $==="null"?null:$}catch{return null}}function J0(x){return Y2(K0,r8(x))}var s8=4;function q2(x){return x.type===s8}function M2(x){if(!q2(x))return x;return{...x,data:{...x.data,href:J0(x.data.href)}}}function m0(x){return y4(K0,x)}function c4(){return p4(K0)}var d4=30000,e8=4194304,x9=20000,H2=500,$9=2000,z9=2,i4={windowMs:d4,checkoutMs:d4,maxBytes:e8,maxEvents:x9,maxLaneEvents:H2},t=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2,8)}`;function P2(x,$){return $&&$.load===x.load?$.startMs:x.lastMs}var Q9=new TextEncoder,e=!1,l4=0,T=i4,N=[],E=[],u=[],r=[],Z9=0,H0=[],P0=new Map,N0=null,D0=null,u0=!1,J9=0,s=null,W1=null,D2=Promise.resolve();function o4(x=i4){if(B2(),e=!0,l4++,T=x,s=x.store??null,N=(x.prior??[]).filter(($)=>$.kind!=="lanes").map(($)=>({id:$.id,load:$.load,startMs:$.startMs,lastMs:$.lastMs,events:[],count:$.count,bytes:$.bytes,href:$.href,route:$.route,stored:!0})),E=(x.priorLanes??[]).slice(-x.maxLaneEvents),u=[],r=[],H0=(x.prior??[]).filter(($)=>$.kind==="lanes").map(($)=>({id:$.id,lastMs:$.lastMs})),P0.clear(),N0=null,q1(Date.now()),s)W1=setInterval(F1,$9)}function n4(){F1(),B2(),e=!1,s=null,N=[],E=[],u=[],r=[],H0=[],P0.clear(),N0=null}function a4(){return T}function N2(x){D0=x}function r4(){if(!e)return;N=[],E=[],u=[],r=[],H0=[],P0.clear(),N0=null;let x=O.tabId;V0(($)=>$.clear(x)),D0?.()}function t4(){return D2}function F1(){if(!e||!s)return;let x=Date.now();q1(x),O2(x);for(let $ of N){if($.stored)continue;let z=P0.get($.id)??{events:0,parts:0};if(z.events===$.events.length)continue;let Q=JSON.stringify($.events.slice(z.events)),Z=z.parts;P0.set($.id,{events:$.events.length,parts:Z+1});let V=s4($);V0((J)=>J.putWindowChunk(V,Z,Q,[]))}V9(x)}function V9(x){let $=x-T.windowMs;while(r.length>0&&r[0].lastMs<=$){let[X]=r.splice(0,1);if(X)V0((G)=>G.dropWindow(X.id))}for(let X of H0.filter((G)=>G.lastMs<=$))V0((G)=>G.dropWindow(X.id));H0=H0.filter((X)=>X.lastMs>$);let z=u;if(!z.length)return;u=[];let Q=r.at(-1);if(!Q||Q.startMs<=$)Q={id:`${t}.lanes.${++Z9}`,startMs:Date.parse(z[0].ts),lastMs:0,parts:0},r.push(Q);Q.lastMs=Date.parse(z.at(-1).ts);let Z=Q.parts++,V=Q,J={id:V.id,tab:O.tabId,scope:T.scope??"",kind:"lanes",load:t,startMs:V.startMs,lastMs:V.lastMs,count:0,bytes:0,href:"",route:""};V0((X)=>X.putWindowChunk(J,Z,"[]",z))}function B2(){if(W1)clearInterval(W1);W1=null}function s4(x){return{id:x.id,tab:O.tabId,scope:T.scope??"",load:x.load,startMs:x.startMs,lastMs:x.lastMs,count:x.count,bytes:x.bytes,href:x.href,route:x.route}}function V0(x){let $=s;if(!$)return;D2=D2.then(()=>x($)).catch((z)=>{if(s!==$)return;s=null,B2(),console.warn("vitrinka: browser capture storage failed — the capture stays in memory for this page",z)})}function K2(x){let[$]=N.splice(x,1);if(!$)return;P0.delete($.id),V0((z)=>z.dropWindow($.id))}function q1(x){while(N.length>0){let Q=N[0],Z=N[1];if(!Z&&Q.load===t)break;if(P2(Q,Z)>x-T.windowMs)break;K2(0)}if(u0)return;let $=N.at(-1);if($&&$.load===t&&D0&&$.lastMs<=x-T.windowMs){u0=!0;try{D0()}finally{u0=!1}let Q=N.indexOf($);if(Q>=0&&Q<N.length-1)for(let Z=Q;Z>=0;Z--)K2(Z)}let z=!1;while(N.length>0&&X9()){if(N.length===1&&N[0].load===t&&!z&&D0){z=!0,u0=!0;try{D0()}finally{u0=!1}if(N.length>1)continue}K2(0),N0=N[0]?.startMs??x}}function e4(){return e?`flight:${l4}`:null}function O2(x){let $=Math.min(N[0]?.startMs??Number.POSITIVE_INFINITY,x-T.windowMs),z=E.findIndex((Q)=>Date.parse(Q.ts)>=$);if(z===-1)E=[];else if(z>0)E=E.slice(z)}function X9(){let x=0,$=0;for(let z of N)x+=z.bytes,$+=z.count;return x>T.maxBytes||$>T.maxEvents}function x3(x){if(!e)return;let $=N[0];if(q2(x)){let Q=globalThis.location?.pathname??O.pathname,Z={id:`${t}.${++J9}`,load:t,startMs:x.timestamp,lastMs:x.timestamp,events:[],count:0,bytes:0,href:x.data.href,route:J0(Q)};N.push(Z);let V=s4(Z);V0((J)=>J.putWindow(V))}let z=N.at(-1);if(!z||z.load!==t)return;if(z.events.push(x),z.count++,z.lastMs=Math.max(z.lastMs,x.timestamp),z.bytes+=Q9.encode(JSON.stringify(x)).length,q1(x.timestamp),N[0]!==$)O2(x.timestamp)}function $3(x,$,z){if(!e)return null;let Q=T.keepLane?T.keepLane(x,$):$;if(Q===null)return null;let Z=new Date().toISOString(),V={ts:Z,tabId:z.tabId,tabHost:z.tabHost,kind:x,payload:Q},J=T.maxLaneEvents;if(E.push(V),E.length>J)E.splice(0,E.length-J);if(s){if(u.push(V),u.length>J)u.splice(0,u.length-J)}return Z}function M1(){if(!e)return null;let x=Date.now();return q1(x),O2(x),{windows:N.map(($)=>({...$,events:$.events.slice()})),lanes:E.slice(),truncated:N0!==null&&N0>x-T.windowMs}}function L2(x){return x.windows.some(($)=>$.events[1]?.type===z9)}var g2=null;function K1(){if(!g2)g2=typeof indexedDB>"u"?G9():j9();return g2}function G9(){let x=new Map;return{durable:!1,put:async($,z)=>void x.set($,z),get:async($)=>x.get($)??null,delete:async($)=>void x.delete($),keys:async()=>[...x.keys()]}}function j9(){let x,$=()=>{return x??=new Promise((Q,Z)=>{let V=indexedDB.open("vitrinka.recorder.blobs",1);V.onupgradeneeded=()=>V.result.createObjectStore("blobs"),V.onerror=()=>Z(V.error??Error("vitrinka: blob journal did not open")),V.onsuccess=()=>{let J=V.result;J.onversionchange=()=>{J.close(),x=void 0},J.onclose=()=>{x=void 0},Q(J)}}).catch((Q)=>{throw x=void 0,Q}),x},z=async(Q,Z)=>{let V=$(),J;try{J=(await V).transaction("blobs",Q)}catch(G){if(x===V)x=void 0;throw G}let X=Z(J.objectStore("blobs"));return new Promise((G,Y)=>{J.oncomplete=()=>G(X.result),J.onabort=J.onerror=()=>Y(J.error??X.error??Error("vitrinka: blob journal transaction failed"))})};return{durable:!0,put:async(Q,Z)=>void await z("readwrite",(V)=>V.put(Z,Q)),get:async(Q)=>{let Z=await z("readonly",(V)=>V.get(Q));return Z instanceof Blob?Z:null},delete:async(Q)=>void await z("readwrite",(Z)=>Z.delete(Q)),keys:async()=>(await z("readonly",(Q)=>Q.getAllKeys())).filter((Q)=>typeof Q==="string")}}var Y9=2000,C2=20000,U3=200,U9=4194304,W9=3145728,_1=500,F9=U9-1024,q9=12582912,M9=10485760,K9=q9-64,D9=1048576,H9=new TextEncoder;function S0(x){return H9.encode(x).length}var I=()=>S();function d(x,$){let z=I().getString(x);if(!z)return $;try{return JSON.parse(z)}catch{return $}}var z3=!1;function i(x,$){try{return I().set(x,$),!0}catch(z){if(!z3)z3=!0,console.warn("vitrinka: storage write failed — the queue tail is memory-only until it clears",z);return!1}}var P1="rec",j0;function A(){if(j0===void 0)j0=d(P1,null);return j0}function W3(x){if(j0=x,x===null)I().remove(P1),I().remove(P9);else i(P1,JSON.stringify(N9(x)))}var P9="notes";var d0=null;function N9(x){if(d0?.sessionId!==x.sessionId)return x;return{...x,paused:!0,activeMs:d0.activeMs,resumeAt:null,stopping:d0.at}}var B9=new Set;function O9(){for(let x of B9)try{x()}catch($){console.warn("vitrinka: before-stop hook failed",$)}}function L9(x){let $=null;if(x)try{$=JSON.parse(x)}catch{return"unchanged"}let z=A();if($?.stopping&&$.sessionId===z?.sessionId&&!z.paused&&d0?.sessionId!==$.sessionId)O9();if(!$){if(!z)return"unchanged";return j0=null,Y3(),w9(),"ended"}if(z?.sessionId===$.sessionId){if($.seq=Math.max($.seq,z.seq),$.policy===void 0&&z.policy!==void 0)$.policy=z.policy;if($.attachments===void 0&&z.attachments!==void 0)$.attachments=z.attachments;if(d0?.sessionId===$.sessionId)$.paused=z.paused,$.activeMs=z.activeMs,$.resumeAt=z.resumeAt,delete $.stopping;return j0=$,"updated"}return j0=$,Y3(),"joined"}var g9=700,Y0,c=null,z0=!1;function O0(){if(Y0===void 0)Y0=d("buffer",[]);return Y0}function A1(){if(c)clearTimeout(c),c=null;if(Y0!==void 0&&!z0)i("buffer",JSON.stringify(Y0))}function F3(){if(z0=!1,c)return;c=setTimeout(()=>{c=null,A1(),q3()},g9)}function Q3(x){Y0=x,z0=!1,A1()}var B0,g0=0;function X0(){if(B0===void 0)B0=d("chunks",[]),g0=B0.reduce((x,$)=>x+$.body.length,0);return B0}function q3(){if(z0)return;let x=X0();if(x.length===0){I().remove("chunks");return}if(g0>D9){I().remove("chunks");return}i("chunks",JSON.stringify(x))}function _9(x){B0=x,g0=x.reduce(($,z)=>$+z.body.length,0),z0=!1,q3()}var N1,_0=new Map,L0=new Set,A0=new Map,D1=new Map,Z3=5,A9=200,I9=67108864,C9=0,J3=!1,R9="blobs";function f(){return N1??=d("images",[]),N1}function M3(){if(z0)return;let x=f().filter(($)=>!L0.has($.blob));if(x.length===0)I().remove("images");else i("images",JSON.stringify(x))}function K3(x){N1=x,z0=!1,M3()}function S9(x,$){let z=K1();if(!z.durable&&!J3)J3=!0,console.warn("vitrinka: no IndexedDB — an attached image will not survive a reload");i(R9,"1");let Q=[];return{drafts:$.map(({blob:V,payload:J})=>{let X=`${x}/${N3}.${++C9}`;return _0.set(X,V),L0.add(X),Q.push(z.put(X,V).then(()=>{if(!(_0.has(X)||f().some((Y)=>Y.blob===X)||[...A0.values()].includes(X)))return L0.delete(X),R2(X),!1;if(!z.durable)return!1;if(L0.delete(X),f().some((Y)=>Y.blob===X))M3();return!0},(G)=>{return console.warn("vitrinka: an attached image could not be journaled — it will not survive a reload",G),!1})),{blob:X,payload:J}}),journaled:Promise.all(Q).then((V)=>V.every(Boolean))}}function R2(x){K1().delete(x).catch(($)=>console.warn("vitrinka: blob journal delete failed",$))}function I0(x,$){for(let z of x)if(_0.delete(z),L0.delete(z),D1.delete(z),$)R2(z)}var B1=(x)=>x.kind==="event"?(x.images??[]).map(($)=>$.blob):[];var T9=0,D3="",H3=0,V3=-1;function S2(){T9=Date.now(),H3=0,D3=""}function C0(x){H3++,D3=String(x instanceof Error?x.message:x).slice(0,200)}var X3={actions:0,pages:0,frames:0,notes:0},b9=new Set;function E9(x){let $={...X3};for(let z of x)if(z.kind==="click")$.actions++;else if(z.kind==="nav")$.pages++;else if(z.kind==="rrweb")$.frames+=typeof z.payload?.count==="number"?z.payload.count:1;else if(z.kind==="note"){if($.notes++,typeof z.payload?.cid==="string")b9.add(z.payload.cid)}X3=$}function f9(x){let $=A();if(!$||$.dead)return;if($.dead=!0,$.deadReason=x,!$.paused&&$.resumeAt)$.activeMs=($.activeMs||0)+(Date.now()-Date.parse($.resumeAt)),$.resumeAt=null;W3($),console.warn("vitrinka: session marked dead —",x),o()}var _2=null;function w9(){if(_2)clearInterval(_2);_2=null}function P3(x){let $=A();if(!$||$.dead||x<1)return null;let z=d("seq",null),Q=Math.max($.seq,z?.sessionId===$.sessionId?z.seq:0)+1;return I().set("seq",JSON.stringify({sessionId:$.sessionId,seq:Q+x-1})),$.seq=Q+x-1,W3($),{seq:Q,sessionId:$.sessionId}}var N3=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2)}`,O1="allocation.",k9=0,w=new Set,y9=16777216,L1=0,g1=0,R0=new Map;function I1(x){return x.kind==="event"?1+(x.images?.length??0):1}function p9(x,$){return new Set(Array.from({length:I1($)},(z,Q)=>x+Q))}function T2(x,$,z){return JSON.stringify(z&&z.size<I1(x)?{draft:x,seq:$,left:[...z]}:{draft:x,seq:$})}var G3=!1,c0=null;function H1(x){if(!w.delete(x))return;if(L1-=x.bytes,x.draft.kind==="chunk")g1--}function B3(x){if(w.add(x),L1+=x.bytes,x.draft.kind==="chunk")g1++;while(w.size>C2||L1>y9||g1>U3){let $=w.values().next().value;H1($),I().remove($.key),I0(B1($.draft),!0);let z=Error("vitrinka: pending allocation budget full — oldest capture dropped");C0(z),console.warn(z.message)}}function O3(x=!1){if(G3&&!x)return;G3=!0;let $=I();if(!$.withLock)return;let z=new Set([...w].map((Q)=>Q.key));for(let Q of $.keys?.()??[]){if(!Q.startsWith(O1)||z.has(Q)||R0.has(Q))continue;let Z=d(Q,null);if(Z&&Z.draft&&Z.draft.sessionId===A()?.sessionId)B3({...Z,key:Q,persisted:!0,bytes:S0(JSON.stringify(Z))})}}function L3(x,$,z){let{ts:Q,tabId:Z,tabHost:V,sessionId:J}=x,X=(G)=>!z||z.has(G);if(x.kind==="event"){let G=x.images??[],Y=$+G.length,F=G.length?{...x.event,payload:{...x.event.payload,attachments:G.map((U,W)=>$+W)}}:x.event,q=O0();if(X(Y)&&!q.some((U)=>U.seq===Y))q.push({seq:Y,ts:Q,tabId:Z,tabHost:V,...F});if(G.length){let U=f();G.forEach((M,H)=>{let D=$+H;if(!X(D)||U.some((P)=>P.seq===D))return;if(q.some((P)=>P.seq===D)){A0.set(D,M.blob);return}U.push({seq:D,ts:Q,tabId:Z,tabHost:V,sessionId:J,blob:M.blob,payload:M.payload})});let W=U.reduce((M,H)=>M+H.payload.bytes,0);while(U.length>A9||W>I9){let M=U.shift();W-=M.payload.bytes,$0(M.sessionId,new Set([M.seq])),I0([M.blob],!0),console.warn(`vitrinka: attached image queue full — dropped ${M.payload.name} (seq ${M.seq}); its note lands without it`)}K3(U)}if(q.length>C2){let U=q.splice(0,q.length-C2);$0(J,new Set(U.map((W)=>W.seq))),console.warn(`vitrinka: retry buffer full — dropped ${U.length} oldest events`)}}else{let G=X0();if(!G.some((Y)=>Y.seq===$)&&!O0().some((Y)=>Y.seq===$))G.push({seq:$,ts:Q,tabId:Z,tabHost:V,sessionId:J,...x.part}),g0+=x.part.body.length;while(G.length>U3){let Y=G.shift();g0-=Y.body.length,$0(J,new Set([Y.seq])),console.warn(`vitrinka: pending chunk queue full — dropped rrweb chunk seq ${Y.seq}`)}}F3(),G0()}function $0(x,$){for(let[z,Q]of R0){if(Q.sessionId!==x)continue;let Z=Q.seqs.size;for(let J of Q.seqs)if($.has(J))Q.seqs.delete(J);let V=Q.seqs.size&&Q.seqs.size<Z&&Q.persisted?d(z,null):null;if(V){let J=new Set([...Q.seqs].filter((X)=>!V.left||V.left.includes(X)));if(J.size)i(z,T2(V.draft,V.seq,J));else Q.seqs.clear()}if(Q.seqs.size===0){I().remove(z),R0.delete(z);let J=z.slice(O1.length,z.lastIndexOf(".")),X=`tab.${J}`,G=d(X,null);if(G?.departed&&G.recoverable&&!I().keys?.().some((Y)=>Y.startsWith(`${O1}${J}.`)))I().remove(X)}}}function g3(){if(c0)return c0;let x=I();return c0=b2(Promise.resolve().then(async()=>{for(let $ of w)await x.withLock("seq",()=>{if(!w.has($))return;if($.persisted){let Z=d($.key,null);if(!Z){H1($),I0(B1($.draft),!1);return}$.seq=Z.seq,$.left=Z.left}if(L9(x.getString(P1)??null),A()?.sessionId!==$.draft.sessionId){H1($),I0(B1($.draft),!0);return}let z=$.seq??P3(I1($.draft))?.seq;if(z===void 0)return;$.seq=z;let Q=$.left?new Set($.left):p9(z,$.draft);if($.persisted)x.set($.key,T2($.draft,z,Q));R0.set($.key,{sessionId:$.draft.sessionId,seqs:Q,persisted:$.persisted}),L3($.draft,z,Q),H1($)})}).catch(($)=>{throw C0($),console.warn("vitrinka: seq allocation failed — capture kept for retry",$),G0(),o(),$})).finally(()=>{c0=null}),c0}function _3(x,$){let z=A(),Q=x.kind==="event"&&x.event.kind==="note";if(!z||z.dead||z.paused&&!Q)return!1;if(O3(),I().withLock){let Z=`${O1}${N3}.${++k9}`,V=JSON.stringify({draft:x}),J={key:Z,draft:x,persisted:!$&&i(Z,V),bytes:S0(V)};B3(J),g3(),$?.then((X)=>{if(X)v9(J)})}else{let Z=P3(I1(x));if(Z)L3(x,Z.seq);else I0(B1(x),!0)}return!0}function v9(x){let $=R0.get(x.key);if($)$.persisted=i(x.key,T2(x.draft,x.seq,$.seqs));else if(w.has(x))x.persisted=i(x.key,JSON.stringify({draft:x.draft}))}var j3=new Set;function b2(x){return j3.add(x),x.catch(()=>{return}).finally(()=>{j3.delete(x)})}function x0(x){return A()?.sessionId!==x.sessionId}function i0(x,$,z,Q=[]){if(y0.following)return null;let Z=A();if(!Z)return $3(x,$,z);if(Z.dead||Z.paused&&x!=="note")return null;let V=new Date().toISOString(),{tabId:J,tabHost:X}=z,G=Q.length?S9(Z.sessionId,Q):null;return _3({sessionId:Z.sessionId,ts:V,tabId:J,tabHost:X,kind:"event",event:{kind:x,payload:$},...G?{images:G.drafts}:{}},G?.journaled),E2(),V}function A3(x){O0().push(x),E2(),F3(),G0()}var h9=Date.now();function E2(){h9=Date.now()}function f2(x,$=M9,z=K9){let Q=[],Z=[],V=[],J=2,X=()=>{if(!V.length)return;Q.push({count:V.length,body:`[${V.join(",")}]`}),V=[],J=2};for(let G of x){let Y=JSON.stringify(G),F=S0(Y)+1;if(F>z){Z.push(F);continue}if(F>$){X(),Q.push({count:1,body:`[${Y}]`});continue}if(V.length&&J+F>$)X();V.push(Y),J+=F}return X(),{parts:Q,dropped:Z}}function I3(x,$){if(!x.length)return 0;let z=A();if(!z||z.paused||z.dead||y0.following)return 0;let{parts:Q,dropped:Z}=f2(x);for(let G of Z)console.warn(`vitrinka: rrweb event (${G} bytes) exceeds the chunk cap — dropped`),i0("note",{text:`⚠ rrweb event dropped (${(G/1048576).toFixed(1)} MiB > chunk cap) — replay may be incomplete from here`},$);let V=new Date().toISOString(),{tabId:J,tabHost:X}=$;for(let G of Q)if(!_3({sessionId:z.sessionId,ts:V,tabId:J,tabHost:X,kind:"chunk",part:G}))return 0;return E2(),Q.length}async function m9(x=5){let $=X0();if($.length===0)return!0;let z=A(),Q=0,Z=new Set;for(let V of $){if(Q>=x)break;if(Q++,!z||V.sessionId!==z.sessionId){console.warn(`vitrinka: dropping rrweb chunk seq ${V.seq} from ended session ${V.sessionId}`),Z.add(V.seq);continue}try{let J=await O4(z.sessionId,V.seq,V.body);if(x0(z))return X0().length===0;A3({seq:V.seq,ts:V.ts,tabId:V.tabId,tabHost:V.tabHost,kind:"rrweb",payload:{count:V.count},blobKey:J.blobKey}),S2(),Z.add(V.seq)}catch(J){if(x0(z))return X0().length===0;if(J instanceof g&&m(J.status)){console.warn(`vitrinka: rrweb chunk seq ${V.seq} rejected permanently (${J.status}) — dropped`),$0(V.sessionId,new Set([V.seq])),Z.add(V.seq);continue}C0(J),console.warn("vitrinka: chunk upload failed",J);break}}if(Z.size)_9(X0().filter((V)=>!Z.has(V.seq)));return X0().length===0}async function u9(x=4){let $=f();if($.length===0)return!0;let z=A(),Q=0,Z=new Set,V=[];for(let J of $){if(Q>=x)break;if(Q++,!z||J.sessionId!==z.sessionId){console.warn(`vitrinka: dropping attachment seq ${J.seq} from ended session ${J.sessionId}`),Z.add(J.seq),V.push(J.blob);continue}let X=_0.get(J.blob)??null;if(!X){try{X=await K1().get(J.blob),D1.delete(J.blob)}catch(G){if(x0(z))return f().length===0;let Y=(D1.get(J.blob)??0)+1;if(console.warn(`vitrinka: blob journal read failed (${Y}/${Z3})`,G),Y<Z3){D1.set(J.blob,Y),C0(G);break}}if(x0(z))return f().length===0}if(!X){console.warn(`vitrinka: attachment seq ${J.seq} (${J.payload.name}) lost its bytes — its note lands without it`),$0(J.sessionId,new Set([J.seq])),Z.add(J.seq),V.push(J.blob);continue}try{let G=await L4(z.sessionId,J.seq,X);if(x0(z))return f().length===0;A3({seq:J.seq,ts:J.ts,tabId:J.tabId,tabHost:J.tabHost,kind:"attachment",payload:{...J.payload},blobKey:G.blobKey}),_0.delete(J.blob),A0.set(J.seq,J.blob),S2(),Z.add(J.seq)}catch(G){if(x0(z))return f().length===0;if(G instanceof g&&m(G.status)){console.warn(`vitrinka: attachment seq ${J.seq} rejected permanently (${G.status}) — dropped`),$0(J.sessionId,new Set([J.seq])),Z.add(J.seq),V.push(J.blob);continue}C0(G),console.warn("vitrinka: attachment upload failed",G);break}}if(Z.size)A1(),K3(f().filter((J)=>!Z.has(J.seq)));return I0(V,!0),f().length===0}var A2=null;function G0(){if(A2)return;A2=setTimeout(()=>{A2=null,c9()},Y9)}var I2=!1;async function c9(x={}){if(I2)return!1;I2=!0;try{return await d9(x)}finally{I2=!1}}async function d9(x){if(A()?.dead)return!1;if(O3(!0),w.size)await g3();if(w.size)return!1;let $=await m9(),z=x.keepalive?f().length===0:await u9(),Q=$&&z;if(!Q)G0();let Z=A(),V=O0();if(!Z||V.length===0)return Q;let J=[],X=new Set,G=0,Y=x.keepalive?61440:W9;for(let U of V){if(J.length>=_1)break;let W=S0(JSON.stringify(U))+1;if(W>F9){console.warn(`vitrinka: event seq ${U.seq} (${W} bytes) exceeds the wire cap — dropped`),X.add(U.seq);continue}if(W>Y){if(x.keepalive)break;if(J.length===0)J.push(U),G=W;break}if(J.length>0&&G+W>Y)break;J.push(U),G+=W}if(X.size){if($0(Z.sessionId,X),Q3(O0().filter((U)=>!X.has(U.seq))),!J.length)return G0(),!1}if(!J.length)return!1;A1();try{await n("POST",`/api/v1/sessions/${Z.sessionId}/events`,{events:J},x)}catch(U){if(x0(Z))return!1;if(U instanceof g&&m(U.status))return f9(`server rejected this session (${U.status})`),!1;return C0(U),o(),console.warn("vitrinka: flush failed, retrying",U),G0(),!1}if(x0(Z))return!0;S2(),V3=Math.max(V3,...J.map((U)=>U.seq)),E9(J);let F=new Set(J.map((U)=>U.seq));$0(Z.sessionId,F);let q=O0().filter((U)=>!F.has(U.seq));Q3(q),o();for(let U of F){let W=A0.get(U);if(W===void 0)continue;A0.delete(U),R2(W)}if(q.length)G0();return!0}function Y3(){if(c)clearTimeout(c),c=null;Y0=[],B0=[],g0=0,N1=[],_0.clear(),L0.clear(),A0.clear(),w.clear(),L1=g1=0,R0.clear(),z0=!0}var C3="0.8.2";var Gz={from:"page",inst:P4("p")};var i9=!1;function R3(){return i9}var T3="vitrinka.report.face",S3=(x)=>x.trim().replace(/\/+$/,"");function C1(){try{return globalThis.localStorage??null}catch{return null}}function l0(x){let $=h0();if(!$)return!1;if($.base)return S3($.base)===S3(x);try{let z=X1(x);return z===void 0||z===$.workspace}catch{return!1}}function l9(){let x=C1()?.getItem(T3);return x==="recorder"||x==="report"?x:null}function w2(x){try{C1()?.setItem(T3,x)}catch($){console.warn("vitrinka: the picked face could not be remembered — the next load starts on Report a problem",$)}}var b3="vitrinka.report.mode";function E3(x){try{if(x==="dev"||x==="regular")C1()?.setItem(b3,x)}catch($){console.warn("vitrinka: the display mode could not be remembered — the next load starts on Report a problem",$)}}function f3(x){if(!l0(x))return"report";let $=l9();if($)return $;return C1()?.getItem(b3)==="dev"?"recorder":"report"}function w3(){return A()!==null||R3()}function k3(x){let $=S().watch?.(v0,()=>x()),z=Y4(x);return()=>{$?.(),z()}}var y3=["bug","suggestion","question","other"];function T0(x,$,z,Q){if(x===1)return $;if(x>=2&&x<=4)return z;return Q}var o9={button:"Report a problem",title:"Report a problem",close:"Close",settings:"Settings",prompt:"What went wrong?",placeholder:"Tell us what happened and what you expected",attached:(x)=>{if(x<60)return`The last ${x} seconds are attached`;let $=Math.round(x/60);return $===1?"The last minute is attached":`The last ${$} minutes are attached`},included:"What’s included",incReplay:"A replay of what happened on this page",incReplayMasked:{strict:"Text on the page and anything you typed are hidden in it",balanced:"Anything you typed is hidden in it",full:"It shows the page as you saw it"},incErrors:"Errors the page ran into",incConsole:"Messages from the browser console",incNetwork:"Which addresses the page loaded, with their status",incFailedRequests:"Requests that failed — address and status only",incEnv:"Your browser, screen size, language and this page’s address",incIdentity:"Your name and email from this app",incMarks:"The places you marked, with your notes",showWhere:"Show us where",kinds:{bug:"Bug",suggestion:"Suggestion",question:"Question",other:"Other"},kindsLabel:"What is it?",linesEmpty:"Each place you mark gets a line here for its note.",notify:"Email me when it’s fixed",send:"Send",sending:"Sending…",retry:"Try again",errorCreate:"Couldn’t send — your text is safe, try again",errorCapture:"Your report arrived, the recording not yet — try again to attach it",sentTitle:"Thanks — we’ve got it",sentBody:"The team will take a look.",sentNotify:"We’ll email you when it’s fixed.",seeReport:"See your report",tools:{circle:"Circle",box:"Box",arrow:"Arrow",hide:"Hide"},toolbar:"Marking tools",barLead:"Mark where the problem is",cancelMarking:"Cancel",discardMarks:(x)=>x===1?"Discard 1 mark?":`Discard ${x} marks?`,discard:"Discard",keep:"Keep",coach:"Click, hold and move around the problem.",coachMore:"You can mark more than one place.",marking:"Marking",keyboardHint:"Keyboard: Enter to start, arrows to move, Shift+arrows to resize, Enter to place.",hidden:"Hidden",notePlaceholder:"Add a note (optional)",mark:(x)=>`Mark ${x}`,removeMark:(x)=>`Remove mark ${x}`,shortcut:"Keyboard shortcut",shortcutHint:"Opens Report a problem anywhere in this app.",notSet:"Not set",recordShortcut:"Record a new shortcut",pressKeys:"Press keys · Esc cancels",needModifier:"Add Ctrl, Alt or ⌘ — a key on its own would get in the way of typing",removeShortcut:"Remove",back:"Back",account:"Your account",menu:"Menu",anonymous:"Not signed in",anonymousHint:"The team checks your report before it’s filed.",signedInByApp:"Signed in by this app",linkVitrinka:"Link your vitrinka account",linkedAs:(x)=>`Linked to vitrinka as ${x}`,unlink:"Unlink",myReports:"My reports",recentRecordings:"Recent recordings",record:"Record",recordHasDraft:"Send or clear the report you started first",openVitrinka:"Open vitrinka",openPortal:"Open the report portal",loading:"Loading…",listFailed:"Couldn’t load — try again",noReports:"No reports yet.",noRecordings:"No recordings yet.",fromThisBrowser:"Sent from this browser",steps:{received:"Received",planned:"Planned",in_progress:"In progress",fixed:"Fixed",done:"Done"},waiting:"Waiting for approval",sentQueued:"The team checks it before it’s filed.",linkCode:"Your code",linkHint:"Approve this code in vitrinka — on this device or another one where you’re signed in.",linkWaiting:"Waiting for approval…",linkExpired:"The code expired.",linkFailed:"Linking didn’t work.",attach:"Attach a file",removeFile:(x)=>`Remove ${x}`,fileTooBig:(x,$)=>`${x} is over the ${$} limit`,tooManyFiles:(x)=>x===1?"Up to 1 file per report":`Up to ${x} files per report`,fileType:(x,$)=>`${x} can’t be attached — ${$} only`,typeNames:{image:"images",pdf:"PDF",text:"text files",office:"office documents"},incFiles:"The files you attached",errorFiles:"Your report arrived, a file not yet — try again to attach it",moveHint:"Click, hold and move it to another corner, or press Alt and an arrow key.",size:"Size",sizes:{sm:"Small",md:"Medium",lg:"Large"},techDetails:"Technical details",techVersion:"Version",techWindow:"Capture window",techCapture:"Capture",techBuffer:"Buffer",techServer:"Server",captureOn:"Running",captureOff:"Off",captureStarting:"Starting…",bufferMemory:"In memory",bufferBrowser:"In this browser",windowLength:(x)=>{if(x<60)return x===1?"1 second":`${x} seconds`;let $=Math.round(x/60);return $===1?"1 minute":`${$} minutes`}},n9={button:"Nahlásit problém",title:"Nahlásit problém",close:"Zavřít",settings:"Nastavení",prompt:"Co se pokazilo?",placeholder:"Napište, co se stalo a co jste čekali",attached:(x)=>{if(x<60)return T0(x,"Poslední sekunda je přiložena",`Poslední ${x} sekundy jsou přiloženy`,`Posledních ${x} sekund je přiloženo`);let $=Math.round(x/60);return T0($,"Poslední minuta je přiložena",`Poslední ${$} minuty jsou přiloženy`,`Posledních ${$} minut je přiloženo`)},included:"Co je přiloženo",incReplay:"Záznam toho, co se na stránce dělo",incReplayMasked:{strict:"Texty stránky i vše, co jste napsali, jsou v něm skryté",balanced:"Vše, co jste napsali, je v něm skryté",full:"Ukazuje stránku tak, jak jste ji viděli"},incErrors:"Chyby, na které stránka narazila",incConsole:"Zprávy z konzole prohlížeče",incNetwork:"Které adresy stránka načítala a s jakým výsledkem",incFailedRequests:"Požadavky, které selhaly — jen adresa a výsledek",incEnv:"Váš prohlížeč, velikost obrazovky, jazyk a adresa stránky",incIdentity:"Vaše jméno a e-mail z této aplikace",incMarks:"Místa, která jste označili, i s poznámkami",showWhere:"Ukažte nám kde",kinds:{bug:"Chyba",suggestion:"Návrh",question:"Dotaz",other:"Jiné"},kindsLabel:"Co to je?",linesEmpty:"Každé označené místo tu dostane řádek pro poznámku.",notify:"Pošlete mi e-mail, až to bude opravené",send:"Odeslat",sending:"Odesílám…",retry:"Zkusit znovu",errorCreate:"Nepodařilo se odeslat — váš text zůstal, zkuste to znovu",errorCapture:"Hlášení dorazilo, záznam zatím ne — zkuste to znovu a přiložíme ho",sentTitle:"Díky — máme to",sentBody:"Tým se na to podívá.",sentNotify:"Až to bude opravené, pošleme vám e-mail.",seeReport:"Zobrazit hlášení",tools:{circle:"Kruh",box:"Obdélník",arrow:"Šipka",hide:"Skrýt"},toolbar:"Nástroje pro označení",barLead:"Označte, kde je problém",cancelMarking:"Zrušit",discardMarks:(x)=>T0(x,"Zahodit 1 značku?",`Zahodit ${x} značky?`,`Zahodit ${x} značek?`),discard:"Zahodit",keep:"Ponechat",coach:"Klikněte, podržte a veďte kolem problému.",coachMore:"Označit můžete i více míst.",marking:"Označování",keyboardHint:"Klávesnice: Enter začne, šipky posouvají, Shift+šipky mění velikost, Enter umístí.",hidden:"Skryto",notePlaceholder:"Přidejte poznámku (nepovinné)",mark:(x)=>`Značka ${x}`,removeMark:(x)=>`Odebrat značku ${x}`,shortcut:"Klávesová zkratka",shortcutHint:"Otevře Nahlásit problém kdekoli v této aplikaci.",notSet:"Nenastavena",recordShortcut:"Nahrát novou zkratku",pressKeys:"Stiskněte klávesy · Esc zruší",needModifier:"Přidejte Ctrl, Alt nebo ⌘ — samotná klávesa by překážela při psaní",removeShortcut:"Odebrat",back:"Zpět",account:"Váš účet",menu:"Nabídka",anonymous:"Nepřihlášeno",anonymousHint:"Hlášení nejdřív zkontroluje tým.",signedInByApp:"Přihlášen touto aplikací",linkVitrinka:"Propojit s vitrinkou",linkedAs:(x)=>`Propojeno s vitrinkou jako ${x}`,unlink:"Odpojit",myReports:"Moje hlášení",recentRecordings:"Nedávné nahrávky",record:"Nahrávat",recordHasDraft:"Odešlete nebo smažte rozepsané hlášení",openVitrinka:"Otevřít vitrinku",openPortal:"Otevřít portál hlášení",loading:"Načítám…",listFailed:"Nepodařilo se načíst — zkuste to znovu",noReports:"Zatím žádná hlášení.",noRecordings:"Zatím žádné nahrávky.",fromThisBrowser:"Odesláno z tohoto prohlížeče",steps:{received:"Přijato",planned:"Naplánováno",in_progress:"Řešíme",fixed:"Opraveno",done:"Hotovo"},waiting:"Čeká na schválení",sentQueued:"Než ho zařadíme, tým ho zkontroluje.",linkCode:"Váš kód",linkHint:"Schvalte kód ve vitrince — na tomto nebo jiném zařízení, kde jste přihlášeni.",linkWaiting:"Čekám na schválení…",linkExpired:"Kód vypršel.",linkFailed:"Propojení se nepodařilo.",attach:"Přiložit soubor",removeFile:(x)=>`Odebrat ${x}`,fileTooBig:(x,$)=>`${x} přesahuje limit ${$}`,tooManyFiles:(x)=>T0(x,"Nejvýš 1 soubor na hlášení",`Nejvýš ${x} soubory na hlášení`,`Nejvýš ${x} souborů na hlášení`),fileType:(x,$)=>`${x} nelze přiložit — jen ${$}`,typeNames:{image:"obrázky",pdf:"PDF",text:"textové soubory",office:"kancelářské dokumenty"},incFiles:"Soubory, které jste přiložili",errorFiles:"Hlášení dorazilo, soubor zatím ne — zkuste to znovu a přiložíme ho",moveHint:"Klikněte, podržte a veďte ho do jiného rohu, nebo stiskněte Alt a šipku.",size:"Velikost",sizes:{sm:"Malá",md:"Střední",lg:"Velká"},techDetails:"Technické údaje",techVersion:"Verze",techWindow:"Okno záznamu",techCapture:"Záznam",techBuffer:"Vyrovnávací paměť",techServer:"Server",captureOn:"Běží",captureOff:"Vypnutý",captureStarting:"Spouští se…",bufferMemory:"V paměti",bufferBrowser:"V tomto prohlížeči",windowLength:(x)=>{if(x<60)return T0(x,"1 sekunda",`${x} sekundy`,`${x} sekund`);let $=Math.round(x/60);return T0($,"1 minuta",`${$} minuty`,`${$} minut`)}},a9={cs:n9,en:o9};function k2(x){return a9[x]}function o0(x){if(typeof x!=="string")return null;let $=x.trim().toLowerCase().split(/[-_]/)[0];return $==="cs"||$==="en"?$:null}function y2(){let x=globalThis.navigator,$=x?x.languages?.length?x.languages:[x.language]:[];for(let z of $){let Q=o0(z);if(Q)return Q}return"en"}var r9="recents",t9=5,s9=["recording","saved","unsaved","deleted"];function e9(x){if(!x||typeof x!=="object")return!1;let $=x;return typeof $.sessionId==="string"&&typeof $.title==="string"&&typeof $.startedAt==="number"&&s9.includes($.status)}var R1;function p3(){if(R1===void 0)try{let x=JSON.parse(S().getString(r9)??"[]");R1=Array.isArray(x)?x.filter(e9).slice(0,t9):[]}catch{R1=[]}return R1}var n0="data-vitrinka-recorder";var p2="all:initial;position:fixed;z-index:2147483647;inset:0 auto auto 0;margin:0;padding:0;border:0;background:transparent;overflow:visible;width:0;height:0;pointer-events:none;color-scheme:normal;",v3=p2;var x7=["pointerdown","pointerup","pointermove","pointerover","pointerout","pointercancel","mousedown","mouseup","mousemove","mouseover","mouseout","click","dblclick","auxclick","contextmenu","touchstart","touchend","touchmove","touchcancel","wheel","focusin","focusout","keydown","keyup","keypress","paste","dragenter","dragover","dragleave","drop"];function c3(x){for(let $ of x7)x.addEventListener($,(z)=>z.stopPropagation())}var $7=["keydown","keyup","keypress"],z7=["vitrinkaHud","vitrinkaSheet"],h3=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]),Q7=new Set(["KeyA","KeyC","KeyX","KeyV","KeyZ","KeyY"]),Z7=new Set(["text","search","email","url","tel","password","number"]);function J7(x){let $=x.key.length===1;if($&&x.getModifierState?.("AltGraph"))return!0;if(!x.altKey&&!x.ctrlKey&&!x.metaKey)return $||h3.has(x.key);if(h3.has(x.key))return!0;return(x.ctrlKey||x.metaKey)&&!x.altKey&&Q7.has(x.code)}function V7(x){if(typeof x!=="object"||x===null)return!1;if("isContentEditable"in x&&x.isContentEditable===!0)return!0;let $="tagName"in x&&typeof x.tagName==="string"?x.tagName:"";if($==="TEXTAREA")return!0;return $==="INPUT"&&"type"in x&&typeof x.type==="string"&&Z7.has(x.type)}function X7(x){if(typeof x!=="object"||x===null||!("dataset"in x))return!1;let $=x.dataset;return typeof $==="object"&&$!==null&&z7.some((z)=>(z in $))}function G7(x){if(!J7(x))return!1;let $=x.composedPath();return V7($[0])&&$.some(X7)}var m3=0,S1=null;function d3(){if(m3++,!S1&&typeof window<"u"){let $=(Q)=>{if(G7(Q))Q.stopImmediatePropagation()},z=$7.map((Q)=>R(window,Q,$,{capture:!0}));S1=()=>{for(let Q of z)Q()}}let x=!0;return()=>{if(!x)return;if(x=!1,--m3>0)return;S1?.(),S1=null}}function i3(){let x=document.createElement("div");x.setAttribute(n0,""),x.setAttribute("data-vitrinka-hud",""),x.style.cssText=p2;let $=x.attachShadow({mode:"open"}),z=document.createElement("div");$.append(z),c3(x);let Q=d3();document.documentElement.append(x);let Z=typeof x.showPopover==="function",V=()=>{if(!Z||!x.isConnected)return;try{x.hidePopover?.()}catch{}try{x.showPopover?.()}catch{}};if(Z)x.popover="manual";V();let J=!1,X=()=>{if(J)return;J=!0,queueMicrotask(()=>{J=!1,V()})},G=(W)=>{if(W.type==="attributes")return W.target instanceof Element&&u3(W.target);for(let M of[W.addedNodes,W.removedNodes])for(let H of M){if(!(H instanceof Element))continue;if(u3(H))return!0;if(H.childElementCount>0&&H.querySelector(l3))return!0}return!1},Y=[],F=0,q=()=>{F=0;let W=Y;if(Y=[],W.some(G))X()},U=new MutationObserver((W)=>{for(let M of W)Y.push(M);if(F===0)F=typeof requestAnimationFrame==="function"?requestAnimationFrame(q):setTimeout(q,16)});return U.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["open","data-state"]}),{host:x,mount:z,destroy:()=>{if(Q(),U.disconnect(),F!==0&&typeof cancelAnimationFrame==="function")cancelAnimationFrame(F);Y=[];try{x.hidePopover?.()}catch{}x.remove()}}}var l3='dialog,[role="dialog"]';function u3(x){return x.matches(l3)}function o3(){let x=document.querySelectorAll("dialog[open]"),$=x[x.length-1];if($)return $;let z=document.querySelectorAll('[role="dialog"][data-state="open"]');return z[z.length-1]??null}function n3(x){let $=document.createElement("div");$.setAttribute(n0,""),$.setAttribute("data-vitrinka-sheet",""),$.style.cssText=v3;let z=$.attachShadow({mode:"open"}),Q=document.createElement("div");z.append(Q),c3($);let Z=d3();return x.append($),{mount:Q,destroy:()=>{Z(),$.remove()}}}function a3(x){if(!(x instanceof Node))return!1;let $=x instanceof Element?x:x.parentElement;return Boolean($?.closest("[data-vitrinka-hud],[data-vitrinka-sheet]"))}var Q0={maxBytes:10485760,maxCount:5,types:["image/*","application/pdf","text/*"]};function j7(x,$){return typeof x==="number"&&Number.isInteger(x)&&x>0?x:$}function r3(x){if(typeof x!=="object"||x===null)return Q0;let $={...x},z=Array.isArray($.types)?$.types.filter((Q)=>typeof Q==="string"&&Q.trim()!=="").map((Q)=>Q.trim().toLowerCase()):[];return{maxBytes:j7($.maxBytes,Q0.maxBytes),maxCount:typeof $.maxCount==="number"&&Number.isInteger($.maxCount)&&$.maxCount>=0?$.maxCount:Q0.maxCount,types:z.length?z:Q0.types}}function Y7(x,$){let z=x.type.toLowerCase(),Q=x.name.toLowerCase();return $.some((Z)=>{if(Z==="*"||Z==="*/*")return!0;if(Z.startsWith("."))return Q.endsWith(Z);if(Z.endsWith("/*"))return z.startsWith(Z.slice(0,-1));return z===Z})}function U7(x,$){return x.name===$.name&&x.size===$.size&&x.lastModified===$.lastModified}function t3(x,$,z){let Q=[],Z=null;for(let V of $){if([...x,...Q].some((J)=>U7(J,V)))continue;if(!Y7(V,z.types))Z??={kind:"type",name:V.name};else if(V.size>z.maxBytes)Z??={kind:"size",name:V.name,cap:z.maxBytes};else if(x.length+Q.length>=z.maxCount)Z??={kind:"count",cap:z.maxCount};else Q.push(V)}return{files:Q,refusal:Z}}function a0(x,$){let z=(Q,Z,V)=>`${new Intl.NumberFormat($,{maximumFractionDigits:V}).format(Q)} ${Z}`;if(x<1024)return z(x,"B",0);if(x<1048576)return z(x/1024,"kB",0);return z(x/1048576,"MB",x<10485760?1:0)}function s3(x,$,z){let Q=(V)=>{if(V.startsWith("image/"))return $.image;if(V==="application/pdf"||V===".pdf")return $.pdf;if(V.startsWith("text/"))return $.text;if(/officedocument|msword|ms-excel|ms-powerpoint|opendocument/.test(V))return $.office;return V.startsWith(".")?V:V.split("/")[1]??V},Z=x.map(Q);return new Intl.ListFormat(z,{type:"conjunction"}).format([...new Set(Z)])}function e3(x,$){let z=/^image\.(\w+)$/i.exec(x);return z?`pasted-${$}.${z[1]}`:x}var v2=["sm","md","lg"],T1={sm:0.88,md:1,lg:1.18},h2="vitrinka.report.size";function x6(){try{return globalThis.localStorage??null}catch{return null}}function m2(x){return x6()?.getItem(x)??null}function b1(x,$){try{x6()?.setItem(x,$)}catch(z){console.warn(`vitrinka: could not remember ${x} on this browser`,z)}}function $6(){let x=m2(h2);return v2.find(($)=>$===x)??"md"}function z6(x,$){let z=x.config,Q=!x.engine||z?.capturing===!1?$.captureOff:z?$.captureOn:$.captureStarting,Z=x.base;try{Z=new URL(x.base).host}catch{}return[[$.techVersion,`@vitrinka/web ${x.version}`],[$.techWindow,z?$.windowLength(z.profile.windowSec):"—"],[$.techCapture,Q],[$.techBuffer,z?`${z.profile.storage==="browser"?$.bufferBrowser:$.bufferMemory} · ${a0(z.profile.maxBytes,x.locale)}`:"—"],[$.techServer,Z]]}var Q6="vitrinka.report.dock",Z6=6,u2={t:{l:"tl",r:"tr"},b:{l:"bl",r:"br"}},W7=["br","bl","tr","tl"];function F7(x){return x==="tl"||x==="tr"?"t":"b"}function q7(x){return x==="tl"||x==="bl"?"l":"r"}function J6(){let x=m2(Q6);return W7.find(($)=>$===x)??"br"}function V6(x){b1(Q6,x)}function X6(x,$,z){return u2[x.y<z/2?"t":"b"][x.x<$/2?"l":"r"]}function G6(x,$){if($==="ArrowLeft"||$==="ArrowRight")return u2[F7(x)][$==="ArrowLeft"?"l":"r"];if($==="ArrowUp"||$==="ArrowDown")return u2[$==="ArrowUp"?"t":"b"][q7(x)];return null}var M7=8192,r0="__vitrinkaRecorderConsolePatched";function E1(x){return x.map(($)=>{if(typeof $==="string")return $;if($ instanceof Error)return $.stack??$.message;try{return JSON.stringify($)}catch{return String($)}}).join(" ").slice(0,M7)}function f1(x,$="error"){if(!x||x.startsWith("vitrinka:"))return;i0("console",{level:$,text:m4(x)},{tabId:O.tabId,tabHost:O.tabHost})}var c2="__vitrinkaRecorderConsoleUnpatch",j6={};function Y6(){let x=globalThis;if(x[r0]!==void 0&&x[r0]!==j6)return;x[c2]?.()}function U6(x={}){let $=globalThis;if($[r0])return;$[r0]=j6;let z=console.error,Q=z.bind(console),Z=(...Y)=>{Q(...Y);try{f1(E1(Y))}catch{}};console.error=Z;let V=(x.levels??[]).map((Y)=>{let F=console[Y],q=F.bind(console),U=(...W)=>{q(...W);try{f1(E1(W),Y)}catch{}};return console[Y]=U,()=>{if(console[Y]===U)console[Y]=F}}),J=(Y)=>{try{f1(E1([Y.error??Y.message]))}catch{}},X=(Y)=>{try{f1(`unhandled rejection: ${E1([Y.reason])}`)}catch{}},G=typeof addEventListener==="function";if(G)addEventListener("error",J),addEventListener("unhandledrejection",X);$[c2]=()=>{if(console.error===Z)console.error=z;for(let Y of V)Y();if(G)removeEventListener("error",J),removeEventListener("unhandledrejection",X);delete $[r0],delete $[c2]}}var W6=65536,t0=524288,F6=3000;var d2="full";function l2(){if(y0.following)return null;let x=A();if(x)return!x.paused&&!x.dead?x.sessionId:null;return e4()}function s0(x){return x!==null&&l2()===x}function w1(x,$){if(typeof x==="string")return W2(x,W6,$);if(typeof URLSearchParams<"u"&&x instanceof URLSearchParams)return W2(x.toString(),W6,"application/x-www-form-urlencoded");return K7(x)}function K7(x){if(x==null)return;if(typeof FormData<"u"&&x instanceof FormData){let $=0;try{x.forEach(()=>$++)}catch{}return`[formdata body omitted: ${$} field(s)]`}if(typeof Blob<"u"&&x instanceof Blob)return`[blob body omitted: ${x.size} bytes${x.type?`, ${x.type}`:""}]`;if(x instanceof ArrayBuffer)return`[buffer body omitted: ${x.byteLength} bytes]`;if(ArrayBuffer.isView(x))return`[buffer body omitted: ${x.byteLength} bytes]`;if(typeof ReadableStream<"u"&&x instanceof ReadableStream)return"[stream body omitted]";return`[${typeof x} body omitted]`}function i2(x){for(let[$,z]of Object.entries(x??{}))if($.toLowerCase().replace(/[-_]/g,"")==="contenttype")return z;return""}function o2(x){return typeof x==="string"||x instanceof URL?{}:x}function e0(x){let $=typeof x.url==="string"?J0(x.url):x.url;i0("net",{...x,url:$},{tabId:O.tabId,tabHost:O.tabHost})}function n2(x){if(!x)return;try{let $={},z=x;if(typeof z.forEach==="function")if(Array.isArray(x)){for(let Q of x)if(Array.isArray(Q)&&Q.length>=2)$[String(Q[0])]=String(Q[1])}else z.forEach((Q,Z)=>{$[Z]=String(Q)});else if(typeof x==="object")for(let[Q,Z]of Object.entries(x))$[Q]=String(Z);return Object.keys($).length>0?$:void 0}catch{return}}function D7(x,$){let z=n2($?.headers);if(z)return z;let Q=o2(x);return n2(Q.headers)}function H7(x){if(!x)return;let $={};for(let z of x.split(/\r?\n/)){let Q=z.indexOf(":");if(Q>0)$[z.slice(0,Q).trim()]=z.slice(Q+1).trim()}return Object.keys($).length>0?$:void 0}function a2(x){try{x.body?.cancel?.().catch(()=>{return})}catch{}}function P7(x){let $=x.get("content-length");if(!$)return null;let z=Number($);return Number.isFinite(z)?z:null}async function N7(x,$){let z=await B7(x,$);if(z===void 0)return;let Q="";try{Q=$.get("content-type")??""}catch{}return w1(z,Q)}async function B7(x,$){let z=P7($);if(z!==null&&z>t0)return a2(x),`[body omitted: ${z} bytes]`;let Q=x.body;if(Q?.getReader){let Z=Q.getReader(),V=[],J=0,X=!1,G=!1,Y=Date.now()+F6;try{while(J<t0){let W=Y-Date.now();if(W<=0){G=!0;break}let M,H=await Promise.race([Z.read(),new Promise((B)=>{M=setTimeout(()=>B("timeout"),W)})]).finally(()=>{if(M!==void 0)clearTimeout(M)});if(H==="timeout"){G=!0;break}let{done:D,value:P}=H;if(D)break;if(P){let B=t0-J,K=P.byteLength>B?P.subarray(0,B):P;V.push(K),J+=K.byteLength}}X=J>=t0,Z.cancel().catch(()=>{return})}catch{return}let F=new Uint8Array(J),q=0;for(let W of V)F.set(W,q),q+=W.byteLength;let U;try{U=new TextDecoder().decode(F)}catch{return`[body omitted: ${J} bytes, undecodable]`}if(G)return`${U}…[body read timed out after ${F6}ms]`;return X?`${U}…[truncated at ${t0} bytes]`:U}if(z===null)return a2(x),"[body omitted: length-less response, no stream API]";try{return await x.text()}catch{return}}var x1="__vitrinkaRecorderNetPatched",r2="__vitrinkaRecorderNetUnpatch",q6={};function M6(){let x=globalThis;if(x[x1]!==void 0&&x[x1]!==q6)return;x[r2]?.()}function K6(x={}){let $=globalThis;if($[x1])return;$[x1]=q6,d2=x.detail??"full";let z=[];$[r2]=()=>{for(let U of z.splice(0))U();delete $[x1],delete $[r2]};let Q=globalThis.fetch,Z=async(U,W)=>{let M=typeof U==="string"?U:U instanceof URL?U.href:U.url,H=l2();if(V2(M)||H===null)return Q(U,W);let D=W?.method??("method"in o2(U)?o2(U).method:"GET"),P=Date.now();try{let B=await Q(U,W),K=Date.now()-P;if(d2==="meta"){if(s0(H))e0({method:D,url:M,status:B.status,ms:K,via:"fetch"});return B}let C;try{C=B.clone()}catch{C=void 0}let{headers:b0,status:E0}=B;return b2((async()=>{if(!s0(H)){if(C)a2(C);return}let J1=C?await N7(C,b0):void 0;if(!s0(H))return;let f0=D7(U,W);e0({method:D,url:M,status:E0,ms:K,reqHeaders:m0(f0),resHeaders:m0(n2(b0)),reqBody:w1(W?.body,i2(f0)),resBody:J1,via:"fetch"})})()),B}catch(B){if(s0(H))e0({method:D,url:M,error:String(B),ms:Date.now()-P,via:"fetch"});throw B}};globalThis.fetch=Z,z.push(()=>{if(globalThis.fetch===Z)globalThis.fetch=Q});let V=globalThis.XMLHttpRequest;if(!V?.prototype)return;let J=V.prototype.open,X=V.prototype.send,G=V.prototype.setRequestHeader;z.push(()=>{let U=V.prototype;if(U.open===Y)U.open=J;if(U.send===q)U.send=X;if(U.setRequestHeader===F)U.setRequestHeader=G});let Y=V.prototype.open=function(...U){return this.__vt={method:U[0],url:String(U[1])},J.apply(this,U)},F=V.prototype.setRequestHeader=function(U,W){let M=this.__vt;if(M)(M.reqHeaders??={})[U]=W;return G?.call(this,U,W)},q=V.prototype.send=function(U){let W=this.__vt,M=l2();if(W&&!V2(W.url)&&M!==null){let H=Date.now();this.addEventListener("loadend",()=>{if(!s0(M))return;if(d2==="meta"){e0({method:W.method,url:W.url,status:this.status,ms:Date.now()-H,via:"xhr"});return}let D;try{D=H7(this.getAllResponseHeaders())}catch{D=void 0}let P;try{P=this.responseType===""||this.responseType==="text"?w1(this.responseText,i2(D)):void 0}catch{P=void 0}e0({method:W.method,url:W.url,status:this.status,ms:Date.now()-H,reqHeaders:m0(W.reqHeaders),resHeaders:m0(D),reqBody:w1(U,i2(W.reqHeaders)),resBody:P,via:"xhr"})})}return X.call(this,U)}}var O7=2000,L7=300000,z1=null,Q1=null,$1=[],k1=null;function D6(){if(!$1.length)return;let x=$1;$1=[],I3(x,{tabId:O.tabId,tabHost:O.tabHost})}function Z1(){return Q1}function H6(x,$,z={}){if(z1)return;let Q=c4(),Z=z.unmaskSelector;try{z1=x({emit:$==="flight"?(J)=>x3(M2(J)):(J)=>{$1.push(M2(J))},checkoutEveryNms:$==="flight"?a4().checkoutMs:L7,inlineImages:!1,collectFonts:!0,maskAllInputs:Q.maskAllInputs,...Q.maskTextSelector?{maskTextSelector:Q.maskTextSelector}:{},...Q.maskTextSelector&&Z?{maskTextFn:(J,X)=>{try{if(X?.closest(Z))return J}catch{}return J.replace(/\S/g,"*")}}:{},blockSelector:`[${n0}]`})??null}catch(V){console.warn("vitrinka: rrweb failed to start",V);return}if(Q1=x,$==="flight")N2(y1);if($==="session")k1=setInterval(D6,O7)}function P6(){if(k1)clearInterval(k1);k1=null,D6();try{z1?.()}catch{}z1=null,Q1=null,N2(null),$1=[]}function y1(){if(!z1||!Q1)return;try{Q1.takeFullSnapshot?.(!0)}catch{}}var O6="vitrinka.capture",k="windows",y="chunks";function U0(x){return new Promise(($,z)=>{x.oncomplete=()=>$(),x.onabort=x.onerror=()=>z(x.error??Error("vitrinka: capture store transaction failed"))})}function t2(x){return new Promise(($,z)=>{x.onsuccess=()=>$(x.result),x.onerror=()=>z(x.error??Error("vitrinka: capture store request failed"))})}function N6(x){return IDBKeyRange.bound([x,0],[x,Number.MAX_SAFE_INTEGER])}function B6(x){if(typeof x!=="object"||x===null)return!1;let $=x;return typeof $.id==="string"&&typeof $.tab==="string"&&typeof $.startMs==="number"&&typeof $.lastMs==="number"}function L6(x=globalThis.indexedDB){if(!x)return Promise.reject(Error("vitrinka: IndexedDB is not available"));return new Promise(($,z)=>{let Q=x.open(O6,1);Q.onupgradeneeded=()=>{Q.result.createObjectStore(k,{keyPath:"id"}),Q.result.createObjectStore(y)},Q.onerror=()=>z(Q.error??Error("vitrinka: capture store did not open")),Q.onblocked=()=>z(Error("vitrinka: capture store is blocked by another tab")),Q.onsuccess=()=>$(Q.result)}).then(($)=>{$.onversionchange=()=>$.close();let z=(Z,V)=>{Z.objectStore(k).delete(V),Z.objectStore(y).delete(N6(V))};return{async putWindow(Z){let V=$.transaction(k,"readwrite");V.objectStore(k).put(Z),await U0(V)},async putChunk(Z,V,J,X){let G=$.transaction(y,"readwrite"),Y={events:J,lanes:[...X]};G.objectStore(y).put(Y,[Z,V]),await U0(G)},async putWindowChunk(Z,V,J,X){let G=$.transaction([k,y],"readwrite"),Y={events:J,lanes:[...X]};try{G.objectStore(y).put(Y,[Z.id,V]),G.objectStore(k).put(Z)}catch(F){throw G.abort(),F}await U0(G)},async dropWindow(Z){let V=$.transaction([k,y],"readwrite");z(V,Z),await U0(V)},async clear(Z){let V=$.transaction([k,y],"readwrite"),J=await t2(V.objectStore(k).getAll());for(let X of J)if(B6(X)&&X.tab===Z)z(V,X.id);await U0(V)},async sweep(Z,V,J,X){let G=$.transaction([k,y],"readwrite"),Y=(await t2(G.objectStore(k).getAll())).filter(B6),F=[],q=new Map;for(let U of Y)q.set(U.tab,[...q.get(U.tab)??[],U]);for(let[U,W]of q){let M=W.filter((D)=>D.kind!=="lanes").sort((D,P)=>D.startMs-P.startMs),H=(D)=>D.kind==="lanes"?D.lastMs:P2(D,M[M.indexOf(D)+1]);for(let D of W.sort((P,B)=>P.startMs-B.startMs))if(H(D)<=Z-V||U===J&&D.scope!==X)z(G,D.id);else if(U===J)F.push(D)}return await U0(G),F},async read(Z){let V=$.transaction(y,"readonly"),J=await t2(V.objectStore(y).getAll(N6(Z)));await U0(V);let X=[],G=[];for(let Y of J)X.push(...JSON.parse(Y.events)),G.push(...Y.lanes);return{events:X,lanes:G}},close:()=>$.close()}})}function g6(x=globalThis.indexedDB){try{x?.deleteDatabase(O6)}catch($){console.warn("vitrinka: could not delete the capture store",$)}}function s2(x,$){return{x:Math.min(x.x,$.x),y:Math.min(x.y,$.y),w:Math.abs($.x-x.x),h:Math.abs($.y-x.y)}}function e2(x,$){return`${$.y<x.y?"n":"s"}${$.x<x.x?"w":"e"}`}function x5(x,$){let z=x.x,Q=x.x+x.w,Z=x.y,V=x.y+x.h,J={x:$.endsWith("w")?z:Q,y:$.startsWith("n")?Z:V};return{tail:{x:$.endsWith("w")?Q:z,y:$.startsWith("n")?V:Z},tip:J}}function _6(x,$,z){if(x==="arrow")return Math.hypot(z.x-$.x,z.y-$.y)>=16;return Math.abs(z.x-$.x)>=8&&Math.abs(z.y-$.y)>=8}function A6(x){return x.map(($,z)=>({...$,n:z+1}))}function I6(x){return x.map(($)=>({n:$.n,shape:$.shape,rect:{x:Math.round($.rect.x),y:Math.round($.rect.y),w:Math.round($.rect.w),h:Math.round($.rect.h)},...$.note.trim()?{note:$.note.trim()}:{},...$.shape==="arrow"&&$.head?{head:$.head}:{}}))}var g7=2,_7=3,A7=0,I7=5,$5=2,C7=3,R7=2000000000,S7="data-vitrinka-hidden",T7="#1b1b1f";function b7(x,$){let z=`position:fixed;left:${Math.round(x.x)}px;top:${Math.round(x.y)}px;width:${Math.round(x.w)}px;height:${Math.round(x.h)}px;background:${T7};z-index:2147483647;pointer-events:none;`;return{type:$5,id:R7+$,tagName:"div",attributes:{[S7]:"",style:z},childNodes:[]}}function z5(x,$,z,Q){let Z={...x};if(x.type===C7&&$.has(x.id))Z.textContent="";if(x.attributes&&$.has(x.id)&&"value"in x.attributes)Z.attributes={...x.attributes,value:""};if(x.childNodes){if(Z.childNodes=x.childNodes.map((V)=>z5(V,$,z,Q)),!Q.done&&x.type===$5&&x.tagName==="body")Z.childNodes.push(...z),Q.done=!0}return Z}function E7(x,$){(x.childNodes?.find((Q)=>Q.type===$5)??x).childNodes?.push(...$)}function f7(x,$){return z5(x,$,[],{done:!0})}function C6(x,$,z){if(!$.length&&!z.size)return x.slice();let Q=$.map(b7);return x.map((Z)=>{let V=Z.data;if(Z.type===g7&&V.node){let J={done:!1},X=z5(V.node,z,Q,J);if(!J.done)E7(X,Q);return{...Z,data:{...Z.data,node:X}}}if(Z.type!==_7||!z.size)return Z;if(V.source===A7){let J=Z.data,X={...J,...J.texts?{texts:J.texts.map((G)=>z.has(G.id)?{...G,value:""}:G)}:{},...J.adds?{adds:J.adds.map((G)=>({...G,node:f7(G.node,z)}))}:{},...J.attributes?{attributes:J.attributes.map((G)=>z.has(G.id)&&("value"in G.attributes)?{...G,attributes:{...G.attributes,value:""}}:G)}:{}};return{...Z,data:X}}if(V.source===I7){let J=Z.data;if(z.has(J.id))return{...Z,data:{...J,text:""}}}return Z})}function w7(x,$){return x.x>=$.x&&x.x<=$.x+$.w&&x.y>=$.y&&x.y<=$.y+$.h}function k7(x){return{x:x.left+x.width/2,y:x.top+x.height/2}}function Q5(x,$,z=document){let Q=new Set;if(!x.length||!$||!z.body)return Q;let Z=(G)=>G.width>0&&G.height>0&&x.some((Y)=>w7(k7(G),Y)),V=(G)=>{let Y=$.getId(G);if(Y>0)Q.add(Y)},J=z.createTreeWalker(z.body,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT),X=z.createRange();for(let G=J.nextNode();G;G=J.nextNode())if(G.nodeType===Node.TEXT_NODE){if(!G.textContent?.trim())continue;if(X.selectNodeContents(G),Z(X.getBoundingClientRect()))V(G)}else if(G instanceof HTMLInputElement||G instanceof HTMLTextAreaElement||G instanceof HTMLSelectElement){if(Z(G.getBoundingClientRect()))V(G)}return X.detach(),Q}var y7=["errors","interactions","full","console","network"];var p1={storage:"memory",windowSec:300,maxBytes:12582912,classes:["errors","interactions"]};function m1(x){return{storage:"memory",windowSec:60,maxBytes:4194304,classes:x===!1?["errors"]:["errors","interactions"]}}function v1(x,$,z){return Math.min(z,Math.max($,x))}function p7(x){if(!Array.isArray(x))return null;return y7.filter(($)=>x.includes($))}function R6(x,$){if(typeof x!=="object"||x===null)return m1($);let z=x;return{storage:z.storage==="browser"?"browser":z.storage==="memory"?"memory":p1.storage,windowSec:typeof z.windowSec==="number"&&Number.isFinite(z.windowSec)?v1(Math.round(z.windowSec),10,3600):p1.windowSec,maxBytes:typeof z.maxBytes==="number"&&Number.isFinite(z.maxBytes)?v1(Math.round(z.maxBytes),262144,67108864):p1.maxBytes,classes:p7(z.classes)??p1.classes}}function h1(x){let $=x.includes("full");return{replay:$||x.includes("interactions"),errors:$||x.includes("errors"),console:$||x.includes("console"),network:$||x.includes("network")}}function v7(x){let $=[];if(x.errors)$.push("errors");if(x.replay)$.push("interactions");if(x.console)$.push("console");if(x.network)$.push("network");return $}function S6(x,$){if(!$)return x;let z=typeof $.windowSec==="number"&&$.windowSec>0?Math.min(x.windowSec,$.windowSec):x.windowSec,Q=typeof $.maxBytes==="number"&&$.maxBytes>0?Math.min(x.maxBytes,$.maxBytes):x.maxBytes,Z=x.classes;if($.classes){let V=h1(x.classes),J=h1($.classes);Z=v7({replay:V.replay&&J.replay,errors:V.errors&&J.errors,console:V.console&&J.console,network:V.network&&J.network})}return{storage:$.storage==="memory"?"memory":x.storage,windowSec:v1(z,10,3600),maxBytes:v1(Q,262144,67108864),classes:Z}}function T6(x){return x==="balanced"||x==="full"?x:"strict"}function b6(x){if(x==="full")return{fullFidelity:!0};if(x==="balanced")return{};return{maskAllText:!0}}var E6="[data-vitrinka-unmask]";var h7=3670016,f6=4194240,m7=2000,w6=500,u7=60000,c7=/[A-Za-z0-9_-]{20,}/g;function l(x,$=""){return typeof x==="string"?x:$}function d7(x){let $=l(x),z;try{z=new URL($,globalThis.location?.href??"http://localhost").pathname}catch{z=$.split(/[?#]/)[0]??""}return z.replace(c7,"•••").slice(0,300)}var i7=4;function l7(x,$){let z=[],Q=!1,Z=[],V=!1,J=()=>{if(V)Q=!0;else z.push(...Z);Z=[],V=!1};for(let X of x){if(X.type===i7&&Z.length)J();if(!V&&S0(JSON.stringify(X))+1>$)V=!0;Z.push(X)}return J(),{events:z,dropped:Q}}function o7(x){return($,z)=>{if($==="console"){let Q=l(z?.level,"error");if(Q==="error"?!(x.errors||x.console):!x.console)return null;return{level:Q,text:l(z?.text).slice(0,m7)}}if($==="net"){let Q=typeof z?.status==="number"?z.status:0,Z=Q===0||Q>=400||z?.error!==void 0;if(!(x.network||x.errors&&Z))return null;return{method:l(z?.method,"GET").toUpperCase(),path:d7(z?.url),status:Q,ms:typeof z?.ms==="number"?Math.max(0,Math.round(z.ms)):0}}return null}}async function n7(x){try{let $=await n("GET","/api/v1/report-config",void 0,{target:x}),z=typeof $.flightRecorder==="boolean"?$.flightRecorder:void 0;return{project:l($.project),profile:$.captureProfile==null?m1(z):R6($.captureProfile,z),masking:T6($.profile),reachable:!0,attachments:r3(typeof $.captureProfile==="object"&&$.captureProfile!==null&&"attachments"in $.captureProfile?$.captureProfile.attachments:$.attachments)}}catch($){return console.warn("vitrinka: report config unavailable — capturing the last minute, strictly masked",$),{project:"",profile:m1(),masking:"strict",reachable:!1,attachments:Q0}}}function k6(x){let $=x?.mirror;if(typeof $!=="object"||$===null)return null;let z=$.getId;return typeof z==="function"?{getId:(Q)=>Number(z.call($,Q))}:null}class y6{opts;ready;store=null;stopped=!1;claim=null;config=null;listeners=new Set;capturing=!1;offs=[];capture=[];constructor(x){this.opts=x;this.ready=this.start()}async start(){let{opts:x}=this;this.offs.push(q4(x.base));let $=await n7({url:x.base,key:x.key}),z=S6($.profile,x.capture),Q=h1(z.classes),Z={project:$.project,profile:z,lanes:Q,masking:$.masking,reachable:$.reachable,capturing:!1,attachments:$.attachments};if(this.stopped)return Z;if(this.config=Z,this.claim=G4("report",()=>this.standDown()),!this.claim)return console.warn("vitrinka: the recorder runs this page’s capture — Report a problem sends without one"),Z;this.capturing=!0,Z.capturing=!0,X4(V4(),globalThis.location?.host??""),O.pathname=globalThis.location?.pathname??"/",h4(b6(Z.masking)),F2(x.sanitizeUrl),this.capture.push(()=>F2(null));let V=z.windowSec*1000,J=[x.base,$.project,Z.masking,z.classes.join(",")].join("|"),X=[],G=[];if(z.storage==="browser")try{this.store=await L6();let Y=await this.store.sweep(Date.now(),V,O.tabId,J);X=Y;let F=this.store;G=(await Promise.all(Y.filter((U)=>U.kind==="lanes").map((U)=>F.read(U.id)))).flatMap((U)=>U.lanes).sort((U,W)=>Date.parse(U.ts)-Date.parse(W.ts))}catch(Y){console.warn("vitrinka: browser capture storage unavailable — keeping the capture in memory",Y),this.store=null,X=[],G=[]}else g6();if(!this.capturing)return this.store?.close(),this.store=null,Z;if(o4({windowMs:V,checkoutMs:Math.min(u7,V),maxBytes:z.maxBytes,maxEvents:Math.max(20000,Math.round(z.maxBytes/200)),maxLaneEvents:H2,keepLane:o7(Q),store:this.store,scope:J,prior:X,priorLanes:G}),this.capture.push(n4),this.store&&typeof window<"u"){let Y=()=>F1();this.capture.push(R(window,"pagehide",Y),R(document,"visibilitychange",Y))}if(Q.errors||Q.console)U6({levels:Q.console?["warn","info","log"]:[]}),this.capture.push(Y6);if(Q.errors||Q.network)K6({detail:"meta"}),this.capture.push(M6);if(Q.replay){let Y=await x.loadRecord(x.base).catch((F)=>{return console.warn("vitrinka: the page recorder did not load — reports go without a replay",F),null});if(Y&&this.capturing)H6(Y,"flight",{unmaskSelector:E6}),this.capture.push(P6)}return Z}onChange(x){return this.listeners.add(x),()=>this.listeners.delete(x)}standDown(){if(!this.capturing)return;if(this.capturing=!1,this.config)this.config.capturing=!1;for(let $ of this.capture.splice(0).reverse())$();let x=this.store;if(this.store=null,x)t4().then(()=>x.close());for(let $ of this.listeners)$()}freeze(){if(!this.capturing)return{clip:null,stored:Promise.resolve(new Map)};O.pathname=globalThis.location?.pathname??O.pathname;let x=M1();if(x&&Z1()&&!L2(x))y1(),x=M1();let $=this.store,z=x?.windows.filter((Z)=>Z.stored).map((Z)=>Z.id)??[],Q=$&&z.length?Promise.all(z.map(async(Z)=>[Z,await $.read(Z)])).then((Z)=>new Map(Z)):Promise.resolve(new Map);return Q.catch(()=>{return}),{clip:x,stored:Q}}withScreen(x){if(!this.capturing||!Z1()||x&&L2(x))return x;y1();let $=M1();if(!$)return x;return{windows:[...x?.windows.filter((z)=>z.stored)??[],...$.windows.filter((z)=>!z.stored)],lanes:x?.lanes??$.lanes,truncated:x?.truncated??$.truncated}}hiddenIdsAt(x){if(!this.capturing)return null;let $=k6(Z1());return $?Q5([x],$):null}async build(x,$,z=new Set){let Q=$.filter((K)=>K.shape==="hide").map((K)=>K.rect),Z=k6(Z1()),V=Q.length>0&&!Z;if(V)console.warn("vitrinka: this page recorder cannot name what a hide covers — the report goes without its replay");let J=new Set(z);if(Q.length&&Z)for(let K of Q5(Q,Z))J.add(K);let X=[],G=this.withScreen(x.clip),Y=G?.truncated??!1,F=await x.stored.catch((K)=>{return console.warn("vitrinka: the stored part of the capture could not be read — the replay starts later",K),null});for(let K of G?.windows??[]){if(!K.stored){X.push(...K.events);continue}let C=F?.get(K.id);if(!C?.events.length)Y=!0;else X.push(...C.events)}let q=G?.lanes??[],U=V?{events:[],dropped:!1}:l7(C6(X,Q,J),f6);if(U.dropped)Y=!0;let{parts:W,dropped:M}=f2(U.events,h7,f6),H=[],D=0;for(let K of W){D+=K.count;let C=U.events[D-1]?.timestamp??Date.now();H.push({seq:H.length+1,ts:new Date(C).toISOString(),count:K.count,body:K.body})}let P=q.filter((K)=>K.kind==="console").slice(-w6).map((K)=>({level:l(K.payload?.level,"error"),ts:K.ts,text:l(K.payload?.text)})),B=q.filter((K)=>K.kind==="net").slice(-w6).map((K)=>({method:l(K.payload?.method,"GET"),path:l(K.payload?.path),status:typeof K.payload?.status==="number"?K.payload.status:0,ms:typeof K.payload?.ms==="number"?K.payload.ms:0}));return{chunks:H,truncated:Y||M.length>0,console:P,network:B}}clear(){if(this.capturing)r4()}stop(){this.stopped=!0,this.listeners.clear(),this.standDown(),j4(this.claim),this.claim=null;for(let x of this.offs.splice(0).reverse())x()}}var v=null;function p6(x){if(v){let $=v.engine.opts;if(!($.base===x.base&&$.key===x.key&&$.sanitizeUrl===x.sanitizeUrl&&JSON.stringify($.capture??{})===JSON.stringify(x.capture??{})))return console.warn("vitrinka: one capture engine per page — this widget reports without a capture (another widget’s key, base, capture or sanitizeUrl owns it)"),null;return v.refs++,v.engine}return v={engine:new y6(x),refs:1},v.engine}function v6(x){if(!x||!v||v.engine!==x)return;if(--v.refs>0)return;v=null,x.stop()}var a7=/^[\w-]+\.[\w-]+\.[\w-]+$/;function u1(x){if(!x)return null;if("token"in x){let Q=typeof x.token==="string"?x.token.trim():"";if(Q.length>4096||!a7.test(Q))return console.warn("vitrinka: identify({token}) needs the compact JWS your server signed — reporting anonymously"),null;return{token:Q}}let $=typeof x.email==="string"?x.email.trim().slice(0,254):"";if(!$.includes("@"))return console.warn("vitrinka: identify({email}) needs an email address — reporting anonymously"),null;let z=typeof x.name==="string"?x.name.trim().slice(0,200):"";return z?{email:$,name:z}:{email:$}}var h6=null,Z5=new Set;function r7(x){h6=u1(x);for(let $ of Z5)$()}function m6(){return h6}function u6(x){return Z5.add(x),()=>Z5.delete(x)}var t7=new Set(["Shift","Control","Alt","Meta","AltGraph","OS","CapsLock","Fn","Hyper","Super"]),c1="report.keybind";function c6(x){if(t7.has(x.key))return{kind:"wait"};if(x.key==="Escape"&&!x.altKey&&!x.ctrlKey&&!x.metaKey&&!x.shiftKey)return{kind:"cancel"};if(!x.altKey&&!x.ctrlKey&&!x.metaKey)return{kind:"bare"};return{kind:"bind",bind:{code:x.code,alt:x.altKey,ctrl:x.ctrlKey,meta:x.metaKey,shift:x.shiftKey}}}function d6(x,$){return x.code===$.code&&x.altKey===$.alt&&x.ctrlKey===$.ctrl&&x.metaKey===$.meta&&x.shiftKey===$.shift}var s7={Space:"Space",Enter:"↵",Backspace:"⌫",Tab:"⇥",ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Slash:"/",Backslash:"\\",Period:".",Comma:",",Semicolon:";",Quote:"'",BracketLeft:"[",BracketRight:"]",Minus:"-",Equal:"=",Backquote:"`"};function e7(x){let $=/^Key([A-Z])$/.exec(x);if($)return $[1];let z=/^(?:Digit|Numpad)(\d)$/.exec(x);if(z)return z[1];return s7[x]??x}function x$(){let x=globalThis.navigator,$=x?.userAgentData?.platform??x?.platform??"";return/mac|iphone|ipad/i.test($)}function d1(x,$=x$()){let z=e7(x.code);if($)return`${x.ctrl?"⌃":""}${x.alt?"⌥":""}${x.shift?"⇧":""}${x.meta?"⌘":""}${z}`;return[x.ctrl&&"Ctrl",x.alt&&"Alt",x.shift&&"Shift",x.meta&&"Meta",z].filter(Boolean).join("+")}function i6(x){if(!x)return null;try{let $=JSON.parse(x);if(typeof $!=="object"||$===null)return null;let z=$;if(typeof z.code!=="string"||!z.code)return null;let Q={code:z.code,alt:z.alt===!0,ctrl:z.ctrl===!0,meta:z.meta===!0,shift:z.shift===!0};return Q.alt||Q.ctrl||Q.meta?Q:null}catch{return null}}function l6(){return i6(S().getString(c1))}function J5(x){let $=S();if(x)$.set(c1,JSON.stringify(x));else $.remove(c1)}function o6(x){let $=S();return $.watch?$.watch(c1,(z)=>x(i6(z))):()=>{return}}var $$=["br","bl","tr","tl"];function V5(x,$){let z=x==="br"||x==="tr"?$.vw-$.w-$.edge:$.edge,Q=x==="br"||x==="bl"?$.vh-$.h-$.bottom:$.top;return{x:Math.max($.edge,z),y:Math.max($.top,Q),w:$.w,h:$.h}}function z$(x,$){let z=Math.min(x.x+x.w,$.x+$.w+12)-Math.max(x.x,$.x-12),Q=Math.min(x.y+x.h,$.y+$.h+12)-Math.max(x.y,$.y-12);return z>0&&Q>0?z*Q:0}function n6(x,$,z){let Q=V5(x,z);return $.reduce((Z,V)=>Z+z$(Q,V),0)}function a6(x,$,z){let Q=n6(x,$,z);if(Q===0)return x;let Z=x,V=Q;for(let J of $$){let X=n6(J,$,z);if(X<V)Z=J,V=X}return Z}async function r6(x,$,z,Q,Z){let V=await fetch(z.url+$,{method:x,mode:"cors",credentials:"omit",headers:{authorization:`Bearer ${z.key}`,...Z?{"x-vitrinka-reporter":Z}:{},...Q!==void 0?{"content-type":"application/json"}:{}},body:Q===void 0?void 0:JSON.stringify(Q)}),J=await V.text();if(!V.ok)throw new g(`${x} ${$} → ${V.status}: ${J}`,V.status);return J?JSON.parse(J):{}}function t6(x,$){return r6("POST","/api/v1/report/session",x,{token:$})}function s6(x,$=Date.now()){return x!==null&&Date.parse(x.expiresAt)-$>60000}function X5(x,$,z){let Q=z?`?cursor=${encodeURIComponent(z)}`:"";return r6("GET",`/api/v1/report/mine${Q}`,x,void 0,$)}function e6(x,$){return`vitrinka.report.sent:${x}|${$}`}function x8(){try{return globalThis.localStorage??null}catch{return null}}function G5(x,$){let z=x8()?.getItem(e6(x,$));if(!z)return[];try{let Q=JSON.parse(z);if(!Array.isArray(Q))return[];return Q.filter((Z)=>typeof Z?.title==="string"&&typeof Z?.at==="number"&&(Z.status==="filed"||Z.status==="quarantined"))}catch{return[]}}function $8(x,$,z){let Q=x8();if(!Q)return;let Z=[z,...G5(x,$)].slice(0,20);try{Q.setItem(e6(x,$),JSON.stringify(Z))}catch(V){console.warn("vitrinka: could not remember the sent report on this browser",V)}}var z8=`
|
|
9
|
+
`)}return V.push(J[J.length-1]),V.join(Z)}var m4=262144;function E4(x,$,z){if(x.full||!$)return $;try{if(Y2($)){if($.length<=m4)try{return JSON.stringify(q1(x,JSON.parse($),0))}catch{}return M0(x,G9(x,$))}let Q=(z??"").toLowerCase();if(Q.includes("x-www-form-urlencoded"))return F1(x,h4(x,a,$));if(Q.includes("multipart/form-data")){let Z=j9(x,$,z??"");if(Z!==null)return Z;return`[multipart body omitted: unparseable (${$.length} chars)]`}return F1(x,$)}catch{return"[redacted]"}}function u4(x,$){if($===void 0)return;if(x.full)return $;if(Y2($))try{return JSON.stringify(q1(x,JSON.parse($),0))}catch{}try{return F1(x,$)}catch{return"[redacted]"}}function d4(x,$,z,Q){if(x.full)return $.length>z?`${$.slice(0,z)}…[truncated]`:$;if($.length>z&&Q?.toLowerCase().includes("multipart/form-data"))return`[multipart body omitted: oversized (${$.length} chars)]`;if(Y2($)&&$.length<=m4){let J=E4(x,$,Q);return J.length>z?`${J.slice(0,z)}…[truncated]`:J}let Z=$.length>z?`${$.slice(0,z)}…[truncated]`:$;return E4(x,Z,Q)}function c4(x,$,z){if(!$)return;let Q=z?.maxValueLen??1024,Z=z?.budget??8192,J={};for(let[V,X]of Object.entries($)){let Y=(x.full?String(X):k4(x,V)?"[redacted]":M0(x,String(X))).slice(0,Q);if(Z-=V.length+Y.length,Z<0){J["…"]="(truncated)";break}J[V]=Y}return J}function i4(x){if(x.full)return{maskAllInputs:!1,maskAllText:!1};return{maskAllInputs:!0,maskAllText:x.maskAllText,...x.maskAllText?{maskTextSelector:"*"}:{}}}var K0=G2(null);function o4(x){K0=G2(x??null)}function n4(x){return u4(K0,x)}function W2(x,$,z){return d4(K0,x,$,z)}var l4=null,a4=null;function U2(x){a4=x??null}function Y9(x){let $=a4??W1().sanitizeUrl;if(!$)return x;let z;try{let Q=$(x);if(typeof Q==="string")return Q;z=`returned ${typeof Q}`}catch{z="threw"}if(l4!==$)l4=$,console.warn(`vitrinka: sanitizeUrl ${z} — such URLs are recorded as their origin only`);return W9(x)??w4}function W9(x){try{let{origin:$}=new URL(x);return $==="null"?null:$}catch{return null}}function J0(x){return j2(K0,Y9(x))}var U9=4;function F2(x){return x.type===U9}function q2(x){if(!F2(x))return x;return{...x,data:{...x.data,href:J0(x.data.href)}}}function m0(x){return c4(K0,x)}function r4(){return i4(K0)}var t4=30000,F9=4194304,q9=20000,D2=500,M9=2000,K9=2,s4={windowMs:t4,checkoutMs:t4,maxBytes:F9,maxEvents:q9,maxLaneEvents:D2},t=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2,8)}`;function P2(x,$){return $&&$.load===x.load?$.startMs:x.lastMs}var D9=new TextEncoder,e=!1,e4=0,T=s4,N=[],E=[],u=[],r=[],P9=0,P0=[],H0=new Map,N0=null,D0=null,u0=!1,H9=0,s=null,M1=null,K2=Promise.resolve();function x3(x=s4){if(N2(),e=!0,e4++,T=x,s=x.store??null,N=(x.prior??[]).filter(($)=>$.kind!=="lanes").map(($)=>({id:$.id,load:$.load,startMs:$.startMs,lastMs:$.lastMs,events:[],count:$.count,bytes:$.bytes,href:$.href,route:$.route,stored:!0})),E=(x.priorLanes??[]).slice(-x.maxLaneEvents),u=[],r=[],P0=(x.prior??[]).filter(($)=>$.kind==="lanes").map(($)=>({id:$.id,lastMs:$.lastMs})),H0.clear(),N0=null,D1(Date.now()),s)M1=setInterval(K1,M9)}function $3(){K1(),N2(),e=!1,s=null,N=[],E=[],u=[],r=[],P0=[],H0.clear(),N0=null}function z3(){return T}function H2(x){D0=x}function Q3(){if(!e)return;N=[],E=[],u=[],r=[],P0=[],H0.clear(),N0=null;let x=g.tabId;V0(($)=>$.clear(x)),D0?.()}function Z3(){return K2}function K1(){if(!e||!s)return;let x=Date.now();D1(x),B2(x);for(let $ of N){if($.stored)continue;let z=H0.get($.id)??{events:0,parts:0};if(z.events===$.events.length)continue;let Q=JSON.stringify($.events.slice(z.events)),Z=z.parts;H0.set($.id,{events:$.events.length,parts:Z+1});let J=J3($);V0((V)=>V.putWindowChunk(J,Z,Q,[]))}N9(x)}function N9(x){let $=x-T.windowMs;while(r.length>0&&r[0].lastMs<=$){let[X]=r.splice(0,1);if(X)V0((G)=>G.dropWindow(X.id))}for(let X of P0.filter((G)=>G.lastMs<=$))V0((G)=>G.dropWindow(X.id));P0=P0.filter((X)=>X.lastMs>$);let z=u;if(!z.length)return;u=[];let Q=r.at(-1);if(!Q||Q.startMs<=$)Q={id:`${t}.lanes.${++P9}`,startMs:Date.parse(z[0].ts),lastMs:0,parts:0},r.push(Q);Q.lastMs=Date.parse(z.at(-1).ts);let Z=Q.parts++,J=Q,V={id:J.id,tab:g.tabId,scope:T.scope??"",kind:"lanes",load:t,startMs:J.startMs,lastMs:J.lastMs,count:0,bytes:0,href:"",route:""};V0((X)=>X.putWindowChunk(V,Z,"[]",z))}function N2(){if(M1)clearInterval(M1);M1=null}function J3(x){return{id:x.id,tab:g.tabId,scope:T.scope??"",load:x.load,startMs:x.startMs,lastMs:x.lastMs,count:x.count,bytes:x.bytes,href:x.href,route:x.route}}function V0(x){let $=s;if(!$)return;K2=K2.then(()=>x($)).catch((z)=>{if(s!==$)return;s=null,N2(),console.warn("vitrinka: browser capture storage failed — the capture stays in memory for this page",z)})}function M2(x){let[$]=N.splice(x,1);if(!$)return;H0.delete($.id),V0((z)=>z.dropWindow($.id))}function D1(x){while(N.length>0){let Q=N[0],Z=N[1];if(!Z&&Q.load===t)break;if(P2(Q,Z)>x-T.windowMs)break;M2(0)}if(u0)return;let $=N.at(-1);if($&&$.load===t&&D0&&$.lastMs<=x-T.windowMs){u0=!0;try{D0()}finally{u0=!1}let Q=N.indexOf($);if(Q>=0&&Q<N.length-1)for(let Z=Q;Z>=0;Z--)M2(Z)}let z=!1;while(N.length>0&&B9()){if(N.length===1&&N[0].load===t&&!z&&D0){z=!0,u0=!0;try{D0()}finally{u0=!1}if(N.length>1)continue}M2(0),N0=N[0]?.startMs??x}}function V3(){return e?`flight:${e4}`:null}function B2(x){let $=Math.min(N[0]?.startMs??Number.POSITIVE_INFINITY,x-T.windowMs),z=E.findIndex((Q)=>Date.parse(Q.ts)>=$);if(z===-1)E=[];else if(z>0)E=E.slice(z)}function B9(){let x=0,$=0;for(let z of N)x+=z.bytes,$+=z.count;return x>T.maxBytes||$>T.maxEvents}function X3(x){if(!e)return;let $=N[0];if(F2(x)){let Q=globalThis.location?.pathname??g.pathname,Z={id:`${t}.${++H9}`,load:t,startMs:x.timestamp,lastMs:x.timestamp,events:[],count:0,bytes:0,href:x.data.href,route:J0(Q)};N.push(Z);let J=J3(Z);V0((V)=>V.putWindow(J))}let z=N.at(-1);if(!z||z.load!==t)return;if(z.events.push(x),z.count++,z.lastMs=Math.max(z.lastMs,x.timestamp),z.bytes+=D9.encode(JSON.stringify(x)).length,D1(x.timestamp),N[0]!==$)B2(x.timestamp)}function G3(x,$,z){if(!e)return null;let Q=T.keepLane?T.keepLane(x,$):$;if(Q===null)return null;let Z=new Date().toISOString(),J={ts:Z,tabId:z.tabId,tabHost:z.tabHost,kind:x,payload:Q},V=T.maxLaneEvents;if(E.push(J),E.length>V)E.splice(0,E.length-V);if(s){if(u.push(J),u.length>V)u.splice(0,u.length-V)}return Z}function P1(){if(!e)return null;let x=Date.now();return D1(x),B2(x),{windows:N.map(($)=>({...$,events:$.events.slice()})),lanes:E.slice(),truncated:N0!==null&&N0>x-T.windowMs}}function g2(x){return x.windows.some(($)=>$.events[1]?.type===K9)}var O2=null;function H1(){if(!O2)O2=typeof indexedDB>"u"?g9():O9();return O2}function g9(){let x=new Map;return{durable:!1,put:async($,z)=>void x.set($,z),get:async($)=>x.get($)??null,delete:async($)=>void x.delete($),keys:async()=>[...x.keys()]}}function O9(){let x,$=()=>{return x??=new Promise((Q,Z)=>{let J=indexedDB.open("vitrinka.recorder.blobs",1);J.onupgradeneeded=()=>J.result.createObjectStore("blobs"),J.onerror=()=>Z(J.error??Error("vitrinka: blob journal did not open")),J.onsuccess=()=>{let V=J.result;V.onversionchange=()=>{V.close(),x=void 0},V.onclose=()=>{x=void 0},Q(V)}}).catch((Q)=>{throw x=void 0,Q}),x},z=async(Q,Z)=>{let J=$(),V;try{V=(await J).transaction("blobs",Q)}catch(G){if(x===J)x=void 0;throw G}let X=Z(V.objectStore("blobs"));return new Promise((G,Y)=>{V.oncomplete=()=>G(X.result),V.onabort=V.onerror=()=>Y(V.error??X.error??Error("vitrinka: blob journal transaction failed"))})};return{durable:!0,put:async(Q,Z)=>void await z("readwrite",(J)=>J.put(Z,Q)),get:async(Q)=>{let Z=await z("readonly",(J)=>J.get(Q));return Z instanceof Blob?Z:null},delete:async(Q)=>void await z("readwrite",(Z)=>Z.delete(Q)),keys:async()=>(await z("readonly",(Q)=>Q.getAllKeys())).filter((Q)=>typeof Q==="string")}}var L9=2000,A2=20000,P3=200,_9=4194304,I9=3145728,R1=500,A9=_9-1024,R9=12582912,C9=10485760,S9=R9-64,T9=1048576,b9=new TextEncoder;function S0(x){return b9.encode(x).length}var A=()=>S();function c(x,$){let z=A().getString(x);if(!z)return $;try{return JSON.parse(z)}catch{return $}}var j3=!1;function i(x,$){try{return A().set(x,$),!0}catch(z){if(!j3)j3=!0,console.warn("vitrinka: storage write failed — the queue tail is memory-only until it clears",z);return!1}}var g1="rec",j0;function I(){if(j0===void 0)j0=c(g1,null);return j0}function H3(x){if(j0=x,x===null)A().remove(g1),A().remove(E9);else i(g1,JSON.stringify(w9(x)))}var E9="notes";var c0=null;function w9(x){if(c0?.sessionId!==x.sessionId)return x;return{...x,paused:!0,activeMs:c0.activeMs,resumeAt:null,stopping:c0.at}}var f9=new Set;function k9(){for(let x of f9)try{x()}catch($){console.warn("vitrinka: before-stop hook failed",$)}}function y9(x){let $=null;if(x)try{$=JSON.parse(x)}catch{return"unchanged"}let z=I();if($?.stopping&&$.sessionId===z?.sessionId&&!z.paused&&c0?.sessionId!==$.sessionId)k9();if(!$){if(!z)return"unchanged";return j0=null,D3(),a9(),"ended"}if(z?.sessionId===$.sessionId){if($.seq=Math.max($.seq,z.seq),$.policy===void 0&&z.policy!==void 0)$.policy=z.policy;if($.attachments===void 0&&z.attachments!==void 0)$.attachments=z.attachments;if(c0?.sessionId===$.sessionId)$.paused=z.paused,$.activeMs=z.activeMs,$.resumeAt=z.resumeAt,delete $.stopping;return j0=$,"updated"}return j0=$,D3(),"joined"}var p9=700,Y0,d=null,z0=!1;function g0(){if(Y0===void 0)Y0=c("buffer",[]);return Y0}function C1(){if(d)clearTimeout(d),d=null;if(Y0!==void 0&&!z0)i("buffer",JSON.stringify(Y0))}function N3(){if(z0=!1,d)return;d=setTimeout(()=>{d=null,C1(),B3()},p9)}function Y3(x){Y0=x,z0=!1,C1()}var B0,L0=0;function X0(){if(B0===void 0)B0=c("chunks",[]),L0=B0.reduce((x,$)=>x+$.body.length,0);return B0}function B3(){if(z0)return;let x=X0();if(x.length===0){A().remove("chunks");return}if(L0>T9){A().remove("chunks");return}i("chunks",JSON.stringify(x))}function v9(x){B0=x,L0=x.reduce(($,z)=>$+z.body.length,0),z0=!1,B3()}var O1,_0=new Map,O0=new Set,I0=new Map,N1=new Map,W3=5,h9=200,m9=67108864,u9=0,U3=!1,d9="blobs";function w(){return O1??=c("images",[]),O1}function g3(){if(z0)return;let x=w().filter(($)=>!O0.has($.blob));if(x.length===0)A().remove("images");else i("images",JSON.stringify(x))}function O3(x){O1=x,z0=!1,g3()}function c9(x,$){let z=H1();if(!z.durable&&!U3)U3=!0,console.warn("vitrinka: no IndexedDB — an attached image will not survive a reload");i(d9,"1");let Q=[];return{drafts:$.map(({blob:J,payload:V})=>{let X=`${x}/${A3}.${++u9}`;return _0.set(X,J),O0.add(X),Q.push(z.put(X,J).then(()=>{if(!(_0.has(X)||w().some((Y)=>Y.blob===X)||[...I0.values()].includes(X)))return O0.delete(X),R2(X),!1;if(!z.durable)return!1;if(O0.delete(X),w().some((Y)=>Y.blob===X))g3();return!0},(G)=>{return console.warn("vitrinka: an attached image could not be journaled — it will not survive a reload",G),!1})),{blob:X,payload:V}}),journaled:Promise.all(Q).then((J)=>J.every(Boolean))}}function R2(x){H1().delete(x).catch(($)=>console.warn("vitrinka: blob journal delete failed",$))}function A0(x,$){for(let z of x)if(_0.delete(z),O0.delete(z),N1.delete(z),$)R2(z)}var L1=(x)=>x.kind==="event"?(x.images??[]).map(($)=>$.blob):[];var i9=0,L3="",_3=0,F3=-1;function C2(){i9=Date.now(),_3=0,L3=""}function R0(x){_3++,L3=String(x instanceof Error?x.message:x).slice(0,200)}var q3={actions:0,pages:0,frames:0,notes:0},l9=new Set;function o9(x){let $={...q3};for(let z of x)if(z.kind==="click")$.actions++;else if(z.kind==="nav")$.pages++;else if(z.kind==="rrweb")$.frames+=typeof z.payload?.count==="number"?z.payload.count:1;else if(z.kind==="note"){if($.notes++,typeof z.payload?.cid==="string")l9.add(z.payload.cid)}q3=$}function n9(x){let $=I();if(!$||$.dead)return;if($.dead=!0,$.deadReason=x,!$.paused&&$.resumeAt)$.activeMs=($.activeMs||0)+(Date.now()-Date.parse($.resumeAt)),$.resumeAt=null;H3($),console.warn("vitrinka: session marked dead —",x),o()}var L2=null;function a9(){if(L2)clearInterval(L2);L2=null}function I3(x){let $=I();if(!$||$.dead||x<1)return null;let z=c("seq",null),Q=Math.max($.seq,z?.sessionId===$.sessionId?z.seq:0)+1;return A().set("seq",JSON.stringify({sessionId:$.sessionId,seq:Q+x-1})),$.seq=Q+x-1,H3($),{seq:Q,sessionId:$.sessionId}}var A3=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2)}`,_1="allocation.",r9=0,f=new Set,t9=16777216,I1=0,A1=0,C0=new Map;function S1(x){return x.kind==="event"?1+(x.images?.length??0):1}function s9(x,$){return new Set(Array.from({length:S1($)},(z,Q)=>x+Q))}function S2(x,$,z){return JSON.stringify(z&&z.size<S1(x)?{draft:x,seq:$,left:[...z]}:{draft:x,seq:$})}var M3=!1,d0=null;function B1(x){if(!f.delete(x))return;if(I1-=x.bytes,x.draft.kind==="chunk")A1--}function R3(x){if(f.add(x),I1+=x.bytes,x.draft.kind==="chunk")A1++;while(f.size>A2||I1>t9||A1>P3){let $=f.values().next().value;B1($),A().remove($.key),A0(L1($.draft),!0);let z=Error("vitrinka: pending allocation budget full — oldest capture dropped");R0(z),console.warn(z.message)}}function C3(x=!1){if(M3&&!x)return;M3=!0;let $=A();if(!$.withLock)return;let z=new Set([...f].map((Q)=>Q.key));for(let Q of $.keys?.()??[]){if(!Q.startsWith(_1)||z.has(Q)||C0.has(Q))continue;let Z=c(Q,null);if(Z&&Z.draft&&Z.draft.sessionId===I()?.sessionId)R3({...Z,key:Q,persisted:!0,bytes:S0(JSON.stringify(Z))})}}function S3(x,$,z){let{ts:Q,tabId:Z,tabHost:J,sessionId:V}=x,X=(G)=>!z||z.has(G);if(x.kind==="event"){let G=x.images??[],Y=$+G.length,U=G.length?{...x.event,payload:{...x.event.payload,attachments:G.map((W,F)=>$+F)}}:x.event,q=g0();if(X(Y)&&!q.some((W)=>W.seq===Y))q.push({seq:Y,ts:Q,tabId:Z,tabHost:J,...U});if(G.length){let W=w();G.forEach((M,P)=>{let D=$+P;if(!X(D)||W.some((H)=>H.seq===D))return;if(q.some((H)=>H.seq===D)){I0.set(D,M.blob);return}W.push({seq:D,ts:Q,tabId:Z,tabHost:J,sessionId:V,blob:M.blob,payload:M.payload})});let F=W.reduce((M,P)=>M+P.payload.bytes,0);while(W.length>h9||F>m9){let M=W.shift();F-=M.payload.bytes,$0(M.sessionId,new Set([M.seq])),A0([M.blob],!0),console.warn(`vitrinka: attached image queue full — dropped ${M.payload.name} (seq ${M.seq}); its note lands without it`)}O3(W)}if(q.length>A2){let W=q.splice(0,q.length-A2);$0(V,new Set(W.map((F)=>F.seq))),console.warn(`vitrinka: retry buffer full — dropped ${W.length} oldest events`)}}else{let G=X0();if(!G.some((Y)=>Y.seq===$)&&!g0().some((Y)=>Y.seq===$))G.push({seq:$,ts:Q,tabId:Z,tabHost:J,sessionId:V,...x.part}),L0+=x.part.body.length;while(G.length>P3){let Y=G.shift();L0-=Y.body.length,$0(V,new Set([Y.seq])),console.warn(`vitrinka: pending chunk queue full — dropped rrweb chunk seq ${Y.seq}`)}}N3(),G0()}function $0(x,$){for(let[z,Q]of C0){if(Q.sessionId!==x)continue;let Z=Q.seqs.size;for(let V of Q.seqs)if($.has(V))Q.seqs.delete(V);let J=Q.seqs.size&&Q.seqs.size<Z&&Q.persisted?c(z,null):null;if(J){let V=new Set([...Q.seqs].filter((X)=>!J.left||J.left.includes(X)));if(V.size)i(z,S2(J.draft,J.seq,V));else Q.seqs.clear()}if(Q.seqs.size===0){A().remove(z),C0.delete(z);let V=z.slice(_1.length,z.lastIndexOf(".")),X=`tab.${V}`,G=c(X,null);if(G?.departed&&G.recoverable&&!A().keys?.().some((Y)=>Y.startsWith(`${_1}${V}.`)))A().remove(X)}}}function T3(){if(d0)return d0;let x=A();return d0=T2(Promise.resolve().then(async()=>{for(let $ of f)await x.withLock("seq",()=>{if(!f.has($))return;if($.persisted){let Z=c($.key,null);if(!Z){B1($),A0(L1($.draft),!1);return}$.seq=Z.seq,$.left=Z.left}if(y9(x.getString(g1)??null),I()?.sessionId!==$.draft.sessionId){B1($),A0(L1($.draft),!0);return}let z=$.seq??I3(S1($.draft))?.seq;if(z===void 0)return;$.seq=z;let Q=$.left?new Set($.left):s9(z,$.draft);if($.persisted)x.set($.key,S2($.draft,z,Q));C0.set($.key,{sessionId:$.draft.sessionId,seqs:Q,persisted:$.persisted}),S3($.draft,z,Q),B1($)})}).catch(($)=>{throw R0($),console.warn("vitrinka: seq allocation failed — capture kept for retry",$),G0(),o(),$})).finally(()=>{d0=null}),d0}function b3(x,$){let z=I(),Q=x.kind==="event"&&x.event.kind==="note";if(!z||z.dead||z.paused&&!Q)return!1;if(C3(),A().withLock){let Z=`${_1}${A3}.${++r9}`,J=JSON.stringify({draft:x}),V={key:Z,draft:x,persisted:!$&&i(Z,J),bytes:S0(J)};R3(V),T3(),$?.then((X)=>{if(X)e9(V)})}else{let Z=I3(S1(x));if(Z)S3(x,Z.seq);else A0(L1(x),!0)}return!0}function e9(x){let $=C0.get(x.key);if($)$.persisted=i(x.key,S2(x.draft,x.seq,$.seqs));else if(f.has(x))x.persisted=i(x.key,JSON.stringify({draft:x.draft}))}var K3=new Set;function T2(x){return K3.add(x),x.catch(()=>{return}).finally(()=>{K3.delete(x)})}function x0(x){return I()?.sessionId!==x.sessionId}function i0(x,$,z,Q=[]){if(y0.following)return null;let Z=I();if(!Z)return G3(x,$,z);if(Z.dead||Z.paused&&x!=="note")return null;let J=new Date().toISOString(),{tabId:V,tabHost:X}=z,G=Q.length?c9(Z.sessionId,Q):null;return b3({sessionId:Z.sessionId,ts:J,tabId:V,tabHost:X,kind:"event",event:{kind:x,payload:$},...G?{images:G.drafts}:{}},G?.journaled),b2(),J}function E3(x){g0().push(x),b2(),N3(),G0()}var x7=Date.now();function b2(){x7=Date.now()}function E2(x,$=C9,z=S9){let Q=[],Z=[],J=[],V=2,X=()=>{if(!J.length)return;Q.push({count:J.length,body:`[${J.join(",")}]`}),J=[],V=2};for(let G of x){let Y=JSON.stringify(G),U=S0(Y)+1;if(U>z){Z.push(U);continue}if(U>$){X(),Q.push({count:1,body:`[${Y}]`});continue}if(J.length&&V+U>$)X();J.push(Y),V+=U}return X(),{parts:Q,dropped:Z}}function w3(x,$){if(!x.length)return 0;let z=I();if(!z||z.paused||z.dead||y0.following)return 0;let{parts:Q,dropped:Z}=E2(x);for(let G of Z)console.warn(`vitrinka: rrweb event (${G} bytes) exceeds the chunk cap — dropped`),i0("note",{text:`⚠ rrweb event dropped (${(G/1048576).toFixed(1)} MiB > chunk cap) — replay may be incomplete from here`},$);let J=new Date().toISOString(),{tabId:V,tabHost:X}=$;for(let G of Q)if(!b3({sessionId:z.sessionId,ts:J,tabId:V,tabHost:X,kind:"chunk",part:G}))return 0;return b2(),Q.length}async function $7(x=5){let $=X0();if($.length===0)return!0;let z=I(),Q=0,Z=new Set;for(let J of $){if(Q>=x)break;if(Q++,!z||J.sessionId!==z.sessionId){console.warn(`vitrinka: dropping rrweb chunk seq ${J.seq} from ended session ${J.sessionId}`),Z.add(J.seq);continue}try{let V=await C4(z.sessionId,J.seq,J.body);if(x0(z))return X0().length===0;E3({seq:J.seq,ts:J.ts,tabId:J.tabId,tabHost:J.tabHost,kind:"rrweb",payload:{count:J.count},blobKey:V.blobKey}),C2(),Z.add(J.seq)}catch(V){if(x0(z))return X0().length===0;if(V instanceof L&&m(V.status)){console.warn(`vitrinka: rrweb chunk seq ${J.seq} rejected permanently (${V.status}) — dropped`),$0(J.sessionId,new Set([J.seq])),Z.add(J.seq);continue}R0(V),console.warn("vitrinka: chunk upload failed",V);break}}if(Z.size)v9(X0().filter((J)=>!Z.has(J.seq)));return X0().length===0}async function z7(x=4){let $=w();if($.length===0)return!0;let z=I(),Q=0,Z=new Set,J=[];for(let V of $){if(Q>=x)break;if(Q++,!z||V.sessionId!==z.sessionId){console.warn(`vitrinka: dropping attachment seq ${V.seq} from ended session ${V.sessionId}`),Z.add(V.seq),J.push(V.blob);continue}let X=_0.get(V.blob)??null;if(!X){try{X=await H1().get(V.blob),N1.delete(V.blob)}catch(G){if(x0(z))return w().length===0;let Y=(N1.get(V.blob)??0)+1;if(console.warn(`vitrinka: blob journal read failed (${Y}/${W3})`,G),Y<W3){N1.set(V.blob,Y),R0(G);break}}if(x0(z))return w().length===0}if(!X){console.warn(`vitrinka: attachment seq ${V.seq} (${V.payload.name}) lost its bytes — its note lands without it`),$0(V.sessionId,new Set([V.seq])),Z.add(V.seq),J.push(V.blob);continue}try{let G=await S4(z.sessionId,V.seq,X);if(x0(z))return w().length===0;E3({seq:V.seq,ts:V.ts,tabId:V.tabId,tabHost:V.tabHost,kind:"attachment",payload:{...V.payload},blobKey:G.blobKey}),_0.delete(V.blob),I0.set(V.seq,V.blob),C2(),Z.add(V.seq)}catch(G){if(x0(z))return w().length===0;if(G instanceof L&&m(G.status)){console.warn(`vitrinka: attachment seq ${V.seq} rejected permanently (${G.status}) — dropped`),$0(V.sessionId,new Set([V.seq])),Z.add(V.seq),J.push(V.blob);continue}R0(G),console.warn("vitrinka: attachment upload failed",G);break}}if(Z.size)C1(),O3(w().filter((V)=>!Z.has(V.seq)));return A0(J,!0),w().length===0}var _2=null;function G0(){if(_2)return;_2=setTimeout(()=>{_2=null,Q7()},L9)}var I2=!1;async function Q7(x={}){if(I2)return!1;I2=!0;try{return await Z7(x)}finally{I2=!1}}async function Z7(x){if(I()?.dead)return!1;if(C3(!0),f.size)await T3();if(f.size)return!1;let $=await $7(),z=x.keepalive?w().length===0:await z7(),Q=$&&z;if(!Q)G0();let Z=I(),J=g0();if(!Z||J.length===0)return Q;let V=[],X=new Set,G=0,Y=x.keepalive?61440:I9;for(let W of J){if(V.length>=R1)break;let F=S0(JSON.stringify(W))+1;if(F>A9){console.warn(`vitrinka: event seq ${W.seq} (${F} bytes) exceeds the wire cap — dropped`),X.add(W.seq);continue}if(F>Y){if(x.keepalive)break;if(V.length===0)V.push(W),G=F;break}if(V.length>0&&G+F>Y)break;V.push(W),G+=F}if(X.size){if($0(Z.sessionId,X),Y3(g0().filter((W)=>!X.has(W.seq))),!V.length)return G0(),!1}if(!V.length)return!1;C1();try{await n("POST",`/api/v1/sessions/${Z.sessionId}/events`,{events:V},x)}catch(W){if(x0(Z))return!1;if(W instanceof L&&m(W.status))return n9(`server rejected this session (${W.status})`),!1;return R0(W),o(),console.warn("vitrinka: flush failed, retrying",W),G0(),!1}if(x0(Z))return!0;C2(),F3=Math.max(F3,...V.map((W)=>W.seq)),o9(V);let U=new Set(V.map((W)=>W.seq));$0(Z.sessionId,U);let q=g0().filter((W)=>!U.has(W.seq));Y3(q),o();for(let W of U){let F=I0.get(W);if(F===void 0)continue;I0.delete(W),R2(F)}if(q.length)G0();return!0}function D3(){if(d)clearTimeout(d),d=null;Y0=[],B0=[],L0=0,O1=[],_0.clear(),O0.clear(),I0.clear(),f.clear(),I1=A1=0,C0.clear(),z0=!0}var f3="0.9.1";var Lz={from:"page",inst:I4("p")};var J7=!1;function k3(){return J7}var p3="vitrinka.report.face",y3=(x)=>x.trim().replace(/\/+$/,"");function T1(){try{return globalThis.localStorage??null}catch{return null}}function l0(x){let $=h0();if(!$)return!1;if($.base)return y3($.base)===y3(x);try{let z=Y1(x);return z===void 0||z===$.workspace}catch{return!1}}function V7(){let x=T1()?.getItem(p3);return x==="recorder"||x==="report"?x:null}function w2(x){try{T1()?.setItem(p3,x)}catch($){console.warn("vitrinka: the picked face could not be remembered — the next load starts on Report a problem",$)}}var v3="vitrinka.report.mode";function h3(x){try{if(x==="dev"||x==="regular")T1()?.setItem(v3,x)}catch($){console.warn("vitrinka: the display mode could not be remembered — the next load starts on Report a problem",$)}}function m3(x){if(!l0(x))return"report";let $=V7();if($)return $;return T1()?.getItem(v3)==="dev"?"recorder":"report"}function u3(){return I()!==null||k3()}function d3(x){let $=S().watch?.(v0,()=>x()),z=D4(x);return()=>{$?.(),z()}}var c3=["bug","suggestion","question","other"];function T0(x,$,z,Q){if(x===1)return $;if(x>=2&&x<=4)return z;return Q}var X7={button:"Report a problem",title:"Report a problem",close:"Close",settings:"Settings",prompt:"What went wrong?",placeholder:"Tell us what happened and what you expected",attached:(x)=>{if(x<60)return`The last ${x} seconds are attached`;let $=Math.round(x/60);return $===1?"The last minute is attached":`The last ${$} minutes are attached`},included:"What’s included",incReplay:"A replay of what happened on this page",incReplayMasked:{strict:"Text on the page and anything you typed are hidden in it",balanced:"Anything you typed is hidden in it",full:"It shows the page as you saw it"},incErrors:"Errors the page ran into",incConsole:"Messages from the browser console",incNetwork:"Which addresses the page loaded, with their status",incFailedRequests:"Requests that failed — address and status only",incEnv:"Your browser, screen size, language and this page’s address",incIdentity:"Your name and email from this app",incMarks:"The places you marked, with your notes",showWhere:"Show us where",kinds:{bug:"Bug",suggestion:"Suggestion",question:"Question",other:"Other"},kindsLabel:"What is it?",linesEmpty:"Each place you mark gets a line here for its note.",notify:"Email me when it’s fixed",send:"Send",sending:"Sending…",retry:"Try again",errorCreate:"Couldn’t send — your text is safe, try again",errorCapture:"Your report arrived, the recording not yet — try again to attach it",sentTitle:"Thanks — we’ve got it",sentBody:"The team will take a look.",sentNotify:"We’ll email you when it’s fixed.",seeReport:"See your report",tools:{circle:"Circle",box:"Box",arrow:"Arrow",hide:"Cover"},toolbar:"Marking tools",barLead:"Mark where the problem is",barLeadHide:"Cover what the team shouldn’t see",cancelMarking:"Cancel",discardMarks:(x)=>x===1?"Discard 1 mark?":`Discard ${x} marks?`,discard:"Discard",keep:"Keep",coach:{box:"Click, hold and move across the problem.",circle:"Click, hold and move around the problem.",arrow:"Click, hold and move from a clear spot to the problem.",hide:"Click, hold and move across anything private — it stays blank in what you send."},coachMore:"You can mark more than one place.",coachDismiss:"Got it, don’t show again",coachSetting:"Marking tips",marking:"Marking",keyboardHint:"Keyboard: Enter to start, arrows to move, Shift+arrows to resize, Enter to place.",hidden:"Covered — not sent",notePlaceholder:"Add a note (optional)",mark:(x)=>`Mark ${x}`,removeMark:(x)=>`Remove mark ${x}`,shortcut:"Keyboard shortcut",shortcutHint:"Opens Report a problem anywhere in this app.",notSet:"Not set",recordShortcut:"Record a new shortcut",pressKeys:"Press keys · Esc cancels",needModifier:"Add Ctrl, Alt or ⌘ — a key on its own would get in the way of typing",removeShortcut:"Remove",back:"Back",account:"Your account",menu:"Menu",anonymous:"Not signed in",anonymousHint:"The team checks your report before it’s filed.",signedInByApp:"Signed in by this app",linkVitrinka:"Link your vitrinka account",linkedAs:(x)=>`Linked to vitrinka as ${x}`,unlink:"Unlink",myReports:"My reports",recentRecordings:"Recent recordings",record:"Record",recordHasDraft:"Send or clear the report you started first",openVitrinka:"Open vitrinka",openPortal:"Open the report portal",loading:"Loading…",listFailed:"Couldn’t load — try again",noReports:"No reports yet.",noRecordings:"No recordings yet.",fromThisBrowser:"Sent from this browser",steps:{received:"Received",planned:"Planned",in_progress:"In progress",fixed:"Fixed",done:"Done"},waiting:"Waiting for approval",sentQueued:"The team checks it before it’s filed.",linkCode:"Your code",linkHint:"Approve this code in vitrinka — on this device or another one where you’re signed in.",linkWaiting:"Waiting for approval…",linkExpired:"The code expired.",linkFailed:"Linking didn’t work.",attach:"Attach a file",removeFile:(x)=>`Remove ${x}`,fileTooBig:(x,$)=>`${x} is over the ${$} limit`,tooManyFiles:(x)=>x===1?"Up to 1 file per report":`Up to ${x} files per report`,fileType:(x,$)=>`${x} can’t be attached — ${$} only`,typeNames:{image:"images",pdf:"PDF",text:"text files",office:"office documents"},incFiles:"The files you attached",errorFiles:"Your report arrived, a file not yet — try again to attach it",moveHint:"Click, hold and move it to another corner, or press Alt and an arrow key.",size:"Size",sizes:{sm:"Small",md:"Medium",lg:"Large"},techDetails:"Technical details",techVersion:"Version",techWindow:"Capture window",techCapture:"Capture",techBuffer:"Buffer",techServer:"Server",captureOn:"Running",captureOff:"Off",captureStarting:"Starting…",bufferMemory:"In memory",bufferBrowser:"In this browser",windowLength:(x)=>{if(x<60)return x===1?"1 second":`${x} seconds`;let $=Math.round(x/60);return $===1?"1 minute":`${$} minutes`}},G7={button:"Nahlásit problém",title:"Nahlásit problém",close:"Zavřít",settings:"Nastavení",prompt:"Co se pokazilo?",placeholder:"Napište, co se stalo a co jste čekali",attached:(x)=>{if(x<60)return T0(x,"Poslední sekunda je přiložena",`Poslední ${x} sekundy jsou přiloženy`,`Posledních ${x} sekund je přiloženo`);let $=Math.round(x/60);return T0($,"Poslední minuta je přiložena",`Poslední ${$} minuty jsou přiloženy`,`Posledních ${$} minut je přiloženo`)},included:"Co je přiloženo",incReplay:"Záznam toho, co se na stránce dělo",incReplayMasked:{strict:"Texty stránky i vše, co jste napsali, jsou v něm skryté",balanced:"Vše, co jste napsali, je v něm skryté",full:"Ukazuje stránku tak, jak jste ji viděli"},incErrors:"Chyby, na které stránka narazila",incConsole:"Zprávy z konzole prohlížeče",incNetwork:"Které adresy stránka načítala a s jakým výsledkem",incFailedRequests:"Požadavky, které selhaly — jen adresa a výsledek",incEnv:"Váš prohlížeč, velikost obrazovky, jazyk a adresa stránky",incIdentity:"Vaše jméno a e-mail z této aplikace",incMarks:"Místa, která jste označili, i s poznámkami",showWhere:"Ukažte nám kde",kinds:{bug:"Chyba",suggestion:"Návrh",question:"Dotaz",other:"Jiné"},kindsLabel:"Co to je?",linesEmpty:"Každé označené místo tu dostane řádek pro poznámku.",notify:"Pošlete mi e-mail, až to bude opravené",send:"Odeslat",sending:"Odesílám…",retry:"Zkusit znovu",errorCreate:"Nepodařilo se odeslat — váš text zůstal, zkuste to znovu",errorCapture:"Hlášení dorazilo, záznam zatím ne — zkuste to znovu a přiložíme ho",sentTitle:"Díky — máme to",sentBody:"Tým se na to podívá.",sentNotify:"Až to bude opravené, pošleme vám e-mail.",seeReport:"Zobrazit hlášení",tools:{circle:"Kruh",box:"Obdélník",arrow:"Šipka",hide:"Zakrýt"},toolbar:"Nástroje pro označení",barLead:"Označte, kde je problém",barLeadHide:"Zakryjte, co tým nemá vidět",cancelMarking:"Zrušit",discardMarks:(x)=>T0(x,"Zahodit 1 značku?",`Zahodit ${x} značky?`,`Zahodit ${x} značek?`),discard:"Zahodit",keep:"Ponechat",coach:{box:"Klikněte, podržte a veďte přes problém.",circle:"Klikněte, podržte a veďte kolem problému.",arrow:"Klikněte, podržte a veďte z volného místa k problému.",hide:"Klikněte, podržte a veďte přes vše soukromé — v hlášení zůstane prázdné."},coachMore:"Označit můžete i více míst.",coachDismiss:"Chápu, už nezobrazovat",coachSetting:"Nápověda při označování",marking:"Označování",keyboardHint:"Klávesnice: Enter začne, šipky posouvají, Shift+šipky mění velikost, Enter umístí.",hidden:"Zakryto — neodešle se",notePlaceholder:"Přidejte poznámku (nepovinné)",mark:(x)=>`Značka ${x}`,removeMark:(x)=>`Odebrat značku ${x}`,shortcut:"Klávesová zkratka",shortcutHint:"Otevře Nahlásit problém kdekoli v této aplikaci.",notSet:"Nenastavena",recordShortcut:"Nahrát novou zkratku",pressKeys:"Stiskněte klávesy · Esc zruší",needModifier:"Přidejte Ctrl, Alt nebo ⌘ — samotná klávesa by překážela při psaní",removeShortcut:"Odebrat",back:"Zpět",account:"Váš účet",menu:"Nabídka",anonymous:"Nepřihlášeno",anonymousHint:"Hlášení nejdřív zkontroluje tým.",signedInByApp:"Přihlášen touto aplikací",linkVitrinka:"Propojit s vitrinkou",linkedAs:(x)=>`Propojeno s vitrinkou jako ${x}`,unlink:"Odpojit",myReports:"Moje hlášení",recentRecordings:"Nedávné nahrávky",record:"Nahrávat",recordHasDraft:"Odešlete nebo smažte rozepsané hlášení",openVitrinka:"Otevřít vitrinku",openPortal:"Otevřít portál hlášení",loading:"Načítám…",listFailed:"Nepodařilo se načíst — zkuste to znovu",noReports:"Zatím žádná hlášení.",noRecordings:"Zatím žádné nahrávky.",fromThisBrowser:"Odesláno z tohoto prohlížeče",steps:{received:"Přijato",planned:"Naplánováno",in_progress:"Řešíme",fixed:"Opraveno",done:"Hotovo"},waiting:"Čeká na schválení",sentQueued:"Než ho zařadíme, tým ho zkontroluje.",linkCode:"Váš kód",linkHint:"Schvalte kód ve vitrince — na tomto nebo jiném zařízení, kde jste přihlášeni.",linkWaiting:"Čekám na schválení…",linkExpired:"Kód vypršel.",linkFailed:"Propojení se nepodařilo.",attach:"Přiložit soubor",removeFile:(x)=>`Odebrat ${x}`,fileTooBig:(x,$)=>`${x} přesahuje limit ${$}`,tooManyFiles:(x)=>T0(x,"Nejvýš 1 soubor na hlášení",`Nejvýš ${x} soubory na hlášení`,`Nejvýš ${x} souborů na hlášení`),fileType:(x,$)=>`${x} nelze přiložit — jen ${$}`,typeNames:{image:"obrázky",pdf:"PDF",text:"textové soubory",office:"kancelářské dokumenty"},incFiles:"Soubory, které jste přiložili",errorFiles:"Hlášení dorazilo, soubor zatím ne — zkuste to znovu a přiložíme ho",moveHint:"Klikněte, podržte a veďte ho do jiného rohu, nebo stiskněte Alt a šipku.",size:"Velikost",sizes:{sm:"Malá",md:"Střední",lg:"Velká"},techDetails:"Technické údaje",techVersion:"Verze",techWindow:"Okno záznamu",techCapture:"Záznam",techBuffer:"Vyrovnávací paměť",techServer:"Server",captureOn:"Běží",captureOff:"Vypnutý",captureStarting:"Spouští se…",bufferMemory:"V paměti",bufferBrowser:"V tomto prohlížeči",windowLength:(x)=>{if(x<60)return T0(x,"1 sekunda",`${x} sekundy`,`${x} sekund`);let $=Math.round(x/60);return T0($,"1 minuta",`${$} minuty`,`${$} minut`)}},j7={cs:G7,en:X7};function f2(x){return j7[x]}function o0(x){if(typeof x!=="string")return null;let $=x.trim().toLowerCase().split(/[-_]/)[0];return $==="cs"||$==="en"?$:null}function k2(){let x=globalThis.navigator,$=x?x.languages?.length?x.languages:[x.language]:[];for(let z of $){let Q=o0(z);if(Q)return Q}return"en"}var Y7="recents",W7=5,U7=["recording","saved","unsaved","deleted"];function F7(x){if(!x||typeof x!=="object")return!1;let $=x;return typeof $.sessionId==="string"&&typeof $.title==="string"&&typeof $.startedAt==="number"&&U7.includes($.status)}var b1;function i3(){if(b1===void 0)try{let x=JSON.parse(S().getString(Y7)??"[]");b1=Array.isArray(x)?x.filter(F7).slice(0,W7):[]}catch{b1=[]}return b1}var n0="data-vitrinka-recorder";var y2="all:initial;position:fixed;z-index:2147483647;inset:0 auto auto 0;margin:0;padding:0;border:0;background:transparent;overflow:visible;width:0;height:0;pointer-events:none;color-scheme:normal;",l3=y2;var q7=["pointerdown","pointerup","pointermove","pointerover","pointerout","pointercancel","mousedown","mouseup","mousemove","mouseover","mouseout","click","dblclick","auxclick","contextmenu","touchstart","touchend","touchmove","touchcancel","wheel","focusin","focusout","keydown","keyup","keypress","paste","dragenter","dragover","dragleave","drop"];function r3(x){for(let $ of q7)x.addEventListener($,(z)=>z.stopPropagation())}var M7=["keydown","keyup","keypress"],K7=["vitrinkaHud","vitrinkaSheet"],o3=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]),D7=new Set(["KeyA","KeyC","KeyX","KeyV","KeyZ","KeyY"]),P7=new Set(["text","search","email","url","tel","password","number"]);function H7(x){let $=x.key.length===1;if($&&x.getModifierState?.("AltGraph"))return!0;if(!x.altKey&&!x.ctrlKey&&!x.metaKey)return $||o3.has(x.key);if(o3.has(x.key))return!0;return(x.ctrlKey||x.metaKey)&&!x.altKey&&D7.has(x.code)}function N7(x){if(typeof x!=="object"||x===null)return!1;if("isContentEditable"in x&&x.isContentEditable===!0)return!0;let $="tagName"in x&&typeof x.tagName==="string"?x.tagName:"";if($==="TEXTAREA")return!0;return $==="INPUT"&&"type"in x&&typeof x.type==="string"&&P7.has(x.type)}function B7(x){if(typeof x!=="object"||x===null||!("dataset"in x))return!1;let $=x.dataset;return typeof $==="object"&&$!==null&&K7.some((z)=>(z in $))}function g7(x){if(!H7(x))return!1;let $=x.composedPath();return N7($[0])&&$.some(B7)}var n3=0,E1=null;function t3(){if(n3++,!E1&&typeof window<"u"){let $=(Q)=>{if(g7(Q))Q.stopImmediatePropagation()},z=M7.map((Q)=>C(window,Q,$,{capture:!0}));E1=()=>{for(let Q of z)Q()}}let x=!0;return()=>{if(!x)return;if(x=!1,--n3>0)return;E1?.(),E1=null}}function s3(){let x=document.createElement("div");x.setAttribute(n0,""),x.setAttribute("data-vitrinka-hud",""),x.style.cssText=y2;let $=x.attachShadow({mode:"open"}),z=document.createElement("div");$.append(z),r3(x);let Q=t3();document.documentElement.append(x);let Z=typeof x.showPopover==="function",J=()=>{if(!Z||!x.isConnected)return;try{x.hidePopover?.()}catch{}try{x.showPopover?.()}catch{}};if(Z)x.popover="manual";J();let V=!1,X=()=>{if(V)return;V=!0,queueMicrotask(()=>{V=!1,J()})},G=(F)=>{if(F.type==="attributes")return F.target instanceof Element&&a3(F.target);for(let M of[F.addedNodes,F.removedNodes])for(let P of M){if(!(P instanceof Element))continue;if(a3(P))return!0;if(P.childElementCount>0&&P.querySelector(e3))return!0}return!1},Y=[],U=0,q=()=>{U=0;let F=Y;if(Y=[],F.some(G))X()},W=new MutationObserver((F)=>{for(let M of F)Y.push(M);if(U===0)U=typeof requestAnimationFrame==="function"?requestAnimationFrame(q):setTimeout(q,16)});return W.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["open","data-state"]}),{host:x,mount:z,destroy:()=>{if(Q(),W.disconnect(),U!==0&&typeof cancelAnimationFrame==="function")cancelAnimationFrame(U);Y=[];try{x.hidePopover?.()}catch{}x.remove()}}}var e3='dialog,[role="dialog"]';function a3(x){return x.matches(e3)}function x6(){let x=document.querySelectorAll("dialog[open]"),$=x[x.length-1];if($)return $;let z=document.querySelectorAll('[role="dialog"][data-state="open"]');return z[z.length-1]??null}function $6(x){let $=document.createElement("div");$.setAttribute(n0,""),$.setAttribute("data-vitrinka-sheet",""),$.style.cssText=l3;let z=$.attachShadow({mode:"open"}),Q=document.createElement("div");z.append(Q),r3($);let Z=t3();return x.append($),{mount:Q,destroy:()=>{Z(),$.remove()}}}function z6(x){if(!(x instanceof Node))return!1;let $=x instanceof Element?x:x.parentElement;return Boolean($?.closest("[data-vitrinka-hud],[data-vitrinka-sheet]"))}var Q0={maxBytes:10485760,maxCount:5,types:["image/*","application/pdf","text/*"]};function O7(x,$){return typeof x==="number"&&Number.isInteger(x)&&x>0?x:$}function Q6(x){if(typeof x!=="object"||x===null)return Q0;let $={...x},z=Array.isArray($.types)?$.types.filter((Q)=>typeof Q==="string"&&Q.trim()!=="").map((Q)=>Q.trim().toLowerCase()):[];return{maxBytes:O7($.maxBytes,Q0.maxBytes),maxCount:typeof $.maxCount==="number"&&Number.isInteger($.maxCount)&&$.maxCount>=0?$.maxCount:Q0.maxCount,types:z.length?z:Q0.types}}function L7(x,$){let z=x.type.toLowerCase(),Q=x.name.toLowerCase();return $.some((Z)=>{if(Z==="*"||Z==="*/*")return!0;if(Z.startsWith("."))return Q.endsWith(Z);if(Z.endsWith("/*"))return z.startsWith(Z.slice(0,-1));return z===Z})}function _7(x,$){return x.name===$.name&&x.size===$.size&&x.lastModified===$.lastModified}function Z6(x,$,z){let Q=[],Z=null;for(let J of $){if([...x,...Q].some((V)=>_7(V,J)))continue;if(!L7(J,z.types))Z??={kind:"type",name:J.name};else if(J.size>z.maxBytes)Z??={kind:"size",name:J.name,cap:z.maxBytes};else if(x.length+Q.length>=z.maxCount)Z??={kind:"count",cap:z.maxCount};else Q.push(J)}return{files:Q,refusal:Z}}function a0(x,$){let z=(Q,Z,J)=>`${new Intl.NumberFormat($,{maximumFractionDigits:J}).format(Q)} ${Z}`;if(x<1024)return z(x,"B",0);if(x<1048576)return z(x/1024,"kB",0);return z(x/1048576,"MB",x<10485760?1:0)}function J6(x,$,z){let Q=(J)=>{if(J.startsWith("image/"))return $.image;if(J==="application/pdf"||J===".pdf")return $.pdf;if(J.startsWith("text/"))return $.text;if(/officedocument|msword|ms-excel|ms-powerpoint|opendocument/.test(J))return $.office;return J.startsWith(".")?J:J.split("/")[1]??J},Z=x.map(Q);return new Intl.ListFormat(z,{type:"conjunction"}).format([...new Set(Z)])}function V6(x,$){let z=/^image\.(\w+)$/i.exec(x);return z?`pasted-${$}.${z[1]}`:x}var p2=["sm","md","lg"],r0={sm:0.88,md:1,lg:1.18},v2="vitrinka.report.size";function X6(){try{return globalThis.localStorage??null}catch{return null}}function w1(x){return X6()?.getItem(x)??null}function t0(x,$){try{X6()?.setItem(x,$)}catch(z){console.warn(`vitrinka: could not remember ${x} on this browser`,z)}}function G6(){let x=w1(v2);return p2.find(($)=>$===x)??"md"}var h2="vitrinka.report.coach";function j6(){return w1(h2)!=="off"}function Y6(x,$){let z=x.config,Q=!x.engine||z?.capturing===!1?$.captureOff:z?$.captureOn:$.captureStarting,Z=x.base;try{Z=new URL(x.base).host}catch{}return[[$.techVersion,`@vitrinka/web ${x.version}`],[$.techWindow,z?$.windowLength(z.profile.windowSec):"—"],[$.techCapture,Q],[$.techBuffer,z?`${z.profile.storage==="browser"?$.bufferBrowser:$.bufferMemory} · ${a0(z.profile.maxBytes,x.locale)}`:"—"],[$.techServer,Z]]}var W6="vitrinka.report.dock",U6=6,m2={t:{l:"tl",r:"tr"},b:{l:"bl",r:"br"}},I7=["br","bl","tr","tl"];function A7(x){return x==="tl"||x==="tr"?"t":"b"}function R7(x){return x==="tl"||x==="bl"?"l":"r"}function F6(){let x=w1(W6);return I7.find(($)=>$===x)??"br"}function q6(x){t0(W6,x)}function M6(x,$,z){return m2[x.y<z/2?"t":"b"][x.x<$/2?"l":"r"]}function K6(x,$){if($==="ArrowLeft"||$==="ArrowRight")return m2[A7(x)][$==="ArrowLeft"?"l":"r"];if($==="ArrowUp"||$==="ArrowDown")return m2[$==="ArrowUp"?"t":"b"][R7(x)];return null}var C7=8192,s0="__vitrinkaRecorderConsolePatched";function f1(x){return x.map(($)=>{if(typeof $==="string")return $;if($ instanceof Error)return $.stack??$.message;try{return JSON.stringify($)}catch{return String($)}}).join(" ").slice(0,C7)}function k1(x,$="error"){if(!x||x.startsWith("vitrinka:"))return;i0("console",{level:$,text:n4(x)},{tabId:g.tabId,tabHost:g.tabHost})}var u2="__vitrinkaRecorderConsoleUnpatch",D6={};function P6(){let x=globalThis;if(x[s0]!==void 0&&x[s0]!==D6)return;x[u2]?.()}function H6(x={}){let $=globalThis;if($[s0])return;$[s0]=D6;let z=console.error,Q=z.bind(console),Z=(...Y)=>{Q(...Y);try{k1(f1(Y))}catch{}};console.error=Z;let J=(x.levels??[]).map((Y)=>{let U=console[Y],q=U.bind(console),W=(...F)=>{q(...F);try{k1(f1(F),Y)}catch{}};return console[Y]=W,()=>{if(console[Y]===W)console[Y]=U}}),V=(Y)=>{try{k1(f1([Y.error??Y.message]))}catch{}},X=(Y)=>{try{k1(`unhandled rejection: ${f1([Y.reason])}`)}catch{}},G=typeof addEventListener==="function";if(G)addEventListener("error",V),addEventListener("unhandledrejection",X);$[u2]=()=>{if(console.error===Z)console.error=z;for(let Y of J)Y();if(G)removeEventListener("error",V),removeEventListener("unhandledrejection",X);delete $[s0],delete $[u2]}}var N6=65536,e0=524288,B6=3000;var d2="full";function i2(){if(y0.following)return null;let x=I();if(x)return!x.paused&&!x.dead?x.sessionId:null;return V3()}function x1(x){return x!==null&&i2()===x}function y1(x,$){if(typeof x==="string")return W2(x,N6,$);if(typeof URLSearchParams<"u"&&x instanceof URLSearchParams)return W2(x.toString(),N6,"application/x-www-form-urlencoded");return S7(x)}function S7(x){if(x==null)return;if(typeof FormData<"u"&&x instanceof FormData){let $=0;try{x.forEach(()=>$++)}catch{}return`[formdata body omitted: ${$} field(s)]`}if(typeof Blob<"u"&&x instanceof Blob)return`[blob body omitted: ${x.size} bytes${x.type?`, ${x.type}`:""}]`;if(x instanceof ArrayBuffer)return`[buffer body omitted: ${x.byteLength} bytes]`;if(ArrayBuffer.isView(x))return`[buffer body omitted: ${x.byteLength} bytes]`;if(typeof ReadableStream<"u"&&x instanceof ReadableStream)return"[stream body omitted]";return`[${typeof x} body omitted]`}function c2(x){for(let[$,z]of Object.entries(x??{}))if($.toLowerCase().replace(/[-_]/g,"")==="contenttype")return z;return""}function l2(x){return typeof x==="string"||x instanceof URL?{}:x}function $1(x){let $=typeof x.url==="string"?J0(x.url):x.url;i0("net",{...x,url:$},{tabId:g.tabId,tabHost:g.tabHost})}function o2(x){if(!x)return;try{let $={},z=x;if(typeof z.forEach==="function")if(Array.isArray(x)){for(let Q of x)if(Array.isArray(Q)&&Q.length>=2)$[String(Q[0])]=String(Q[1])}else z.forEach((Q,Z)=>{$[Z]=String(Q)});else if(typeof x==="object")for(let[Q,Z]of Object.entries(x))$[Q]=String(Z);return Object.keys($).length>0?$:void 0}catch{return}}function T7(x,$){let z=o2($?.headers);if(z)return z;let Q=l2(x);return o2(Q.headers)}function b7(x){if(!x)return;let $={};for(let z of x.split(/\r?\n/)){let Q=z.indexOf(":");if(Q>0)$[z.slice(0,Q).trim()]=z.slice(Q+1).trim()}return Object.keys($).length>0?$:void 0}function n2(x){try{x.body?.cancel?.().catch(()=>{return})}catch{}}function E7(x){let $=x.get("content-length");if(!$)return null;let z=Number($);return Number.isFinite(z)?z:null}async function w7(x,$){let z=await f7(x,$);if(z===void 0)return;let Q="";try{Q=$.get("content-type")??""}catch{}return y1(z,Q)}async function f7(x,$){let z=E7($);if(z!==null&&z>e0)return n2(x),`[body omitted: ${z} bytes]`;let Q=x.body;if(Q?.getReader){let Z=Q.getReader(),J=[],V=0,X=!1,G=!1,Y=Date.now()+B6;try{while(V<e0){let F=Y-Date.now();if(F<=0){G=!0;break}let M,P=await Promise.race([Z.read(),new Promise((B)=>{M=setTimeout(()=>B("timeout"),F)})]).finally(()=>{if(M!==void 0)clearTimeout(M)});if(P==="timeout"){G=!0;break}let{done:D,value:H}=P;if(D)break;if(H){let B=e0-V,K=H.byteLength>B?H.subarray(0,B):H;J.push(K),V+=K.byteLength}}X=V>=e0,Z.cancel().catch(()=>{return})}catch{return}let U=new Uint8Array(V),q=0;for(let F of J)U.set(F,q),q+=F.byteLength;let W;try{W=new TextDecoder().decode(U)}catch{return`[body omitted: ${V} bytes, undecodable]`}if(G)return`${W}…[body read timed out after ${B6}ms]`;return X?`${W}…[truncated at ${e0} bytes]`:W}if(z===null)return n2(x),"[body omitted: length-less response, no stream API]";try{return await x.text()}catch{return}}var z1="__vitrinkaRecorderNetPatched",a2="__vitrinkaRecorderNetUnpatch",g6={};function O6(){let x=globalThis;if(x[z1]!==void 0&&x[z1]!==g6)return;x[a2]?.()}function L6(x={}){let $=globalThis;if($[z1])return;$[z1]=g6,d2=x.detail??"full";let z=[];$[a2]=()=>{for(let W of z.splice(0))W();delete $[z1],delete $[a2]};let Q=globalThis.fetch,Z=async(W,F)=>{let M=typeof W==="string"?W:W instanceof URL?W.href:W.url,P=i2();if(J2(M)||P===null)return Q(W,F);let D=F?.method??("method"in l2(W)?l2(W).method:"GET"),H=Date.now();try{let B=await Q(W,F),K=Date.now()-H;if(d2==="meta"){if(x1(P))$1({method:D,url:M,status:B.status,ms:K,via:"fetch"});return B}let R;try{R=B.clone()}catch{R=void 0}let{headers:b0,status:E0}=B;return T2((async()=>{if(!x1(P)){if(R)n2(R);return}let G1=R?await w7(R,b0):void 0;if(!x1(P))return;let w0=T7(W,F);$1({method:D,url:M,status:E0,ms:K,reqHeaders:m0(w0),resHeaders:m0(o2(b0)),reqBody:y1(F?.body,c2(w0)),resBody:G1,via:"fetch"})})()),B}catch(B){if(x1(P))$1({method:D,url:M,error:String(B),ms:Date.now()-H,via:"fetch"});throw B}};globalThis.fetch=Z,z.push(()=>{if(globalThis.fetch===Z)globalThis.fetch=Q});let J=globalThis.XMLHttpRequest;if(!J?.prototype)return;let V=J.prototype.open,X=J.prototype.send,G=J.prototype.setRequestHeader;z.push(()=>{let W=J.prototype;if(W.open===Y)W.open=V;if(W.send===q)W.send=X;if(W.setRequestHeader===U)W.setRequestHeader=G});let Y=J.prototype.open=function(...W){return this.__vt={method:W[0],url:String(W[1])},V.apply(this,W)},U=J.prototype.setRequestHeader=function(W,F){let M=this.__vt;if(M)(M.reqHeaders??={})[W]=F;return G?.call(this,W,F)},q=J.prototype.send=function(W){let F=this.__vt,M=i2();if(F&&!J2(F.url)&&M!==null){let P=Date.now();this.addEventListener("loadend",()=>{if(!x1(M))return;if(d2==="meta"){$1({method:F.method,url:F.url,status:this.status,ms:Date.now()-P,via:"xhr"});return}let D;try{D=b7(this.getAllResponseHeaders())}catch{D=void 0}let H;try{H=this.responseType===""||this.responseType==="text"?y1(this.responseText,c2(D)):void 0}catch{H=void 0}$1({method:F.method,url:F.url,status:this.status,ms:Date.now()-P,reqHeaders:m0(F.reqHeaders),resHeaders:m0(D),reqBody:y1(W,c2(F.reqHeaders)),resBody:H,via:"xhr"})})}return X.call(this,W)}}var k7=2000,y7=300000,Z1=null,J1=null,Q1=[],p1=null;function _6(){if(!Q1.length)return;let x=Q1;Q1=[],w3(x,{tabId:g.tabId,tabHost:g.tabHost})}function V1(){return J1}function I6(x,$,z={}){if(Z1)return;let Q=r4(),Z=z.unmaskSelector;try{Z1=x({emit:$==="flight"?(V)=>X3(q2(V)):(V)=>{Q1.push(q2(V))},checkoutEveryNms:$==="flight"?z3().checkoutMs:y7,inlineImages:!1,collectFonts:!0,maskAllInputs:Q.maskAllInputs,...Q.maskTextSelector?{maskTextSelector:Q.maskTextSelector}:{},...Q.maskTextSelector&&Z?{maskTextFn:(V,X)=>{try{if(X?.closest(Z))return V}catch{}return V.replace(/\S/g,"*")}}:{},blockSelector:`[${n0}]`})??null}catch(J){console.warn("vitrinka: rrweb failed to start",J);return}if(J1=x,$==="flight")H2(v1);if($==="session")p1=setInterval(_6,k7)}function A6(){if(p1)clearInterval(p1);p1=null,_6();try{Z1?.()}catch{}Z1=null,J1=null,H2(null),Q1=[]}function v1(){if(!Z1||!J1)return;try{J1.takeFullSnapshot?.(!0)}catch{}}var S6="vitrinka.capture",k="windows",y="chunks";function W0(x){return new Promise(($,z)=>{x.oncomplete=()=>$(),x.onabort=x.onerror=()=>z(x.error??Error("vitrinka: capture store transaction failed"))})}function r2(x){return new Promise(($,z)=>{x.onsuccess=()=>$(x.result),x.onerror=()=>z(x.error??Error("vitrinka: capture store request failed"))})}function R6(x){return IDBKeyRange.bound([x,0],[x,Number.MAX_SAFE_INTEGER])}function C6(x){if(typeof x!=="object"||x===null)return!1;let $=x;return typeof $.id==="string"&&typeof $.tab==="string"&&typeof $.startMs==="number"&&typeof $.lastMs==="number"}function T6(x=globalThis.indexedDB){if(!x)return Promise.reject(Error("vitrinka: IndexedDB is not available"));return new Promise(($,z)=>{let Q=x.open(S6,1);Q.onupgradeneeded=()=>{Q.result.createObjectStore(k,{keyPath:"id"}),Q.result.createObjectStore(y)},Q.onerror=()=>z(Q.error??Error("vitrinka: capture store did not open")),Q.onblocked=()=>z(Error("vitrinka: capture store is blocked by another tab")),Q.onsuccess=()=>$(Q.result)}).then(($)=>{$.onversionchange=()=>$.close();let z=(Z,J)=>{Z.objectStore(k).delete(J),Z.objectStore(y).delete(R6(J))};return{async putWindow(Z){let J=$.transaction(k,"readwrite");J.objectStore(k).put(Z),await W0(J)},async putChunk(Z,J,V,X){let G=$.transaction(y,"readwrite"),Y={events:V,lanes:[...X]};G.objectStore(y).put(Y,[Z,J]),await W0(G)},async putWindowChunk(Z,J,V,X){let G=$.transaction([k,y],"readwrite"),Y={events:V,lanes:[...X]};try{G.objectStore(y).put(Y,[Z.id,J]),G.objectStore(k).put(Z)}catch(U){throw G.abort(),U}await W0(G)},async dropWindow(Z){let J=$.transaction([k,y],"readwrite");z(J,Z),await W0(J)},async clear(Z){let J=$.transaction([k,y],"readwrite"),V=await r2(J.objectStore(k).getAll());for(let X of V)if(C6(X)&&X.tab===Z)z(J,X.id);await W0(J)},async sweep(Z,J,V,X){let G=$.transaction([k,y],"readwrite"),Y=(await r2(G.objectStore(k).getAll())).filter(C6),U=[],q=new Map;for(let W of Y)q.set(W.tab,[...q.get(W.tab)??[],W]);for(let[W,F]of q){let M=F.filter((D)=>D.kind!=="lanes").sort((D,H)=>D.startMs-H.startMs),P=(D)=>D.kind==="lanes"?D.lastMs:P2(D,M[M.indexOf(D)+1]);for(let D of F.sort((H,B)=>H.startMs-B.startMs))if(P(D)<=Z-J||W===V&&D.scope!==X)z(G,D.id);else if(W===V)U.push(D)}return await W0(G),U},async read(Z){let J=$.transaction(y,"readonly"),V=await r2(J.objectStore(y).getAll(R6(Z)));await W0(J);let X=[],G=[];for(let Y of V)X.push(...JSON.parse(Y.events)),G.push(...Y.lanes);return{events:X,lanes:G}},close:()=>$.close()}})}function b6(x=globalThis.indexedDB){try{x?.deleteDatabase(S6)}catch($){console.warn("vitrinka: could not delete the capture store",$)}}function t2(x,$){return{x:Math.min(x.x,$.x),y:Math.min(x.y,$.y),w:Math.abs($.x-x.x),h:Math.abs($.y-x.y)}}function s2(x,$){return`${$.y<x.y?"n":"s"}${$.x<x.x?"w":"e"}`}function e2(x,$){let z=x.x,Q=x.x+x.w,Z=x.y,J=x.y+x.h,V={x:$.endsWith("w")?z:Q,y:$.startsWith("n")?Z:J};return{tail:{x:$.endsWith("w")?Q:z,y:$.startsWith("n")?J:Z},tip:V}}function E6(x,$,z){if(x==="arrow")return Math.hypot(z.x-$.x,z.y-$.y)>=16;return Math.abs(z.x-$.x)>=8&&Math.abs(z.y-$.y)>=8}function w6(x){return x.map(($,z)=>({...$,n:z+1}))}function f6(x){return x.map(($)=>({n:$.n,shape:$.shape,rect:{x:Math.round($.rect.x),y:Math.round($.rect.y),w:Math.round($.rect.w),h:Math.round($.rect.h)},...$.note.trim()?{note:$.note.trim()}:{},...$.shape==="arrow"&&$.head?{head:$.head}:{}}))}var p7=2,v7=3,h7=0,m7=5,x5=2,u7=3,d7=2000000000,c7="data-vitrinka-hidden",i7="#1b1b1f";function l7(x,$){let z=`position:fixed;left:${Math.round(x.x)}px;top:${Math.round(x.y)}px;width:${Math.round(x.w)}px;height:${Math.round(x.h)}px;background:${i7};z-index:2147483647;pointer-events:none;`;return{type:x5,id:d7+$,tagName:"div",attributes:{[c7]:"",style:z},childNodes:[]}}function $5(x,$,z,Q){let Z={...x};if(x.type===u7&&$.has(x.id))Z.textContent="";if(x.attributes&&$.has(x.id)&&"value"in x.attributes)Z.attributes={...x.attributes,value:""};if(x.childNodes){if(Z.childNodes=x.childNodes.map((J)=>$5(J,$,z,Q)),!Q.done&&x.type===x5&&x.tagName==="body")Z.childNodes.push(...z),Q.done=!0}return Z}function o7(x,$){(x.childNodes?.find((Q)=>Q.type===x5)??x).childNodes?.push(...$)}function n7(x,$){return $5(x,$,[],{done:!0})}function k6(x,$,z){if(!$.length&&!z.size)return x.slice();let Q=$.map(l7);return x.map((Z)=>{let J=Z.data;if(Z.type===p7&&J.node){let V={done:!1},X=$5(J.node,z,Q,V);if(!V.done)o7(X,Q);return{...Z,data:{...Z.data,node:X}}}if(Z.type!==v7||!z.size)return Z;if(J.source===h7){let V=Z.data,X={...V,...V.texts?{texts:V.texts.map((G)=>z.has(G.id)?{...G,value:""}:G)}:{},...V.adds?{adds:V.adds.map((G)=>({...G,node:n7(G.node,z)}))}:{},...V.attributes?{attributes:V.attributes.map((G)=>z.has(G.id)&&("value"in G.attributes)?{...G,attributes:{...G.attributes,value:""}}:G)}:{}};return{...Z,data:X}}if(J.source===m7){let V=Z.data;if(z.has(V.id))return{...Z,data:{...V,text:""}}}return Z})}function a7(x,$){return x.x>=$.x&&x.x<=$.x+$.w&&x.y>=$.y&&x.y<=$.y+$.h}function r7(x){return{x:x.left+x.width/2,y:x.top+x.height/2}}function z5(x,$,z=document){let Q=new Set;if(!x.length||!$||!z.body)return Q;let Z=(G)=>G.width>0&&G.height>0&&x.some((Y)=>a7(r7(G),Y)),J=(G)=>{let Y=$.getId(G);if(Y>0)Q.add(Y)},V=z.createTreeWalker(z.body,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT),X=z.createRange();for(let G=V.nextNode();G;G=V.nextNode())if(G.nodeType===Node.TEXT_NODE){if(!G.textContent?.trim())continue;if(X.selectNodeContents(G),Z(X.getBoundingClientRect()))J(G)}else if(G instanceof HTMLInputElement||G instanceof HTMLTextAreaElement||G instanceof HTMLSelectElement){if(Z(G.getBoundingClientRect()))J(G)}return X.detach(),Q}var t7=["errors","interactions","full","console","network"];var h1={storage:"memory",windowSec:300,maxBytes:12582912,classes:["errors","interactions"]};function d1(x){return{storage:"memory",windowSec:60,maxBytes:4194304,classes:x===!1?["errors"]:["errors","interactions"]}}function m1(x,$,z){return Math.min(z,Math.max($,x))}function s7(x){if(!Array.isArray(x))return null;return t7.filter(($)=>x.includes($))}function y6(x,$){if(typeof x!=="object"||x===null)return d1($);let z=x;return{storage:z.storage==="browser"?"browser":z.storage==="memory"?"memory":h1.storage,windowSec:typeof z.windowSec==="number"&&Number.isFinite(z.windowSec)?m1(Math.round(z.windowSec),10,3600):h1.windowSec,maxBytes:typeof z.maxBytes==="number"&&Number.isFinite(z.maxBytes)?m1(Math.round(z.maxBytes),262144,67108864):h1.maxBytes,classes:s7(z.classes)??h1.classes}}function u1(x){let $=x.includes("full");return{replay:$||x.includes("interactions"),errors:$||x.includes("errors"),console:$||x.includes("console"),network:$||x.includes("network")}}function e7(x){let $=[];if(x.errors)$.push("errors");if(x.replay)$.push("interactions");if(x.console)$.push("console");if(x.network)$.push("network");return $}function p6(x,$){if(!$)return x;let z=typeof $.windowSec==="number"&&$.windowSec>0?Math.min(x.windowSec,$.windowSec):x.windowSec,Q=typeof $.maxBytes==="number"&&$.maxBytes>0?Math.min(x.maxBytes,$.maxBytes):x.maxBytes,Z=x.classes;if($.classes){let J=u1(x.classes),V=u1($.classes);Z=e7({replay:J.replay&&V.replay,errors:J.errors&&V.errors,console:J.console&&V.console,network:J.network&&V.network})}return{storage:$.storage==="memory"?"memory":x.storage,windowSec:m1(z,10,3600),maxBytes:m1(Q,262144,67108864),classes:Z}}function v6(x){return x==="balanced"||x==="full"?x:"strict"}function h6(x){if(x==="full")return{fullFidelity:!0};if(x==="balanced")return{};return{maskAllText:!0}}var m6="[data-vitrinka-unmask]";var x$=3670016,u6=4194240,$$=2000,d6=500,z$=60000,Q$=/[A-Za-z0-9_-]{20,}/g;function l(x,$=""){return typeof x==="string"?x:$}function Z$(x){let $=l(x),z;try{z=new URL($,globalThis.location?.href??"http://localhost").pathname}catch{z=$.split(/[?#]/)[0]??""}return z.replace(Q$,"•••").slice(0,300)}var J$=4;function V$(x,$){let z=[],Q=!1,Z=[],J=!1,V=()=>{if(J)Q=!0;else z.push(...Z);Z=[],J=!1};for(let X of x){if(X.type===J$&&Z.length)V();if(!J&&S0(JSON.stringify(X))+1>$)J=!0;Z.push(X)}return V(),{events:z,dropped:Q}}function X$(x){return($,z)=>{if($==="console"){let Q=l(z?.level,"error");if(Q==="error"?!(x.errors||x.console):!x.console)return null;return{level:Q,text:l(z?.text).slice(0,$$)}}if($==="net"){let Q=typeof z?.status==="number"?z.status:0,Z=Q===0||Q>=400||z?.error!==void 0;if(!(x.network||x.errors&&Z))return null;return{method:l(z?.method,"GET").toUpperCase(),path:Z$(z?.url),status:Q,ms:typeof z?.ms==="number"?Math.max(0,Math.round(z.ms)):0}}return null}}async function G$(x){try{let $=await n("GET","/api/v1/report-config",void 0,{target:x}),z=typeof $.flightRecorder==="boolean"?$.flightRecorder:void 0;return{project:l($.project),profile:$.captureProfile==null?d1(z):y6($.captureProfile,z),masking:v6($.profile),reachable:!0,attachments:Q6(typeof $.captureProfile==="object"&&$.captureProfile!==null&&"attachments"in $.captureProfile?$.captureProfile.attachments:$.attachments)}}catch($){return console.warn("vitrinka: report config unavailable — capturing the last minute, strictly masked",$),{project:"",profile:d1(),masking:"strict",reachable:!1,attachments:Q0}}}function c6(x){let $=x?.mirror;if(typeof $!=="object"||$===null)return null;let z=$.getId;return typeof z==="function"?{getId:(Q)=>Number(z.call($,Q))}:null}class i6{opts;ready;store=null;stopped=!1;claim=null;config=null;listeners=new Set;capturing=!1;offs=[];capture=[];constructor(x){this.opts=x;this.ready=this.start()}async start(){let{opts:x}=this;this.offs.push(B4(x.base));let $=await G$({url:x.base,key:x.key}),z=p6($.profile,x.capture),Q=u1(z.classes),Z={project:$.project,profile:z,lanes:Q,masking:$.masking,reachable:$.reachable,capturing:!1,attachments:$.attachments};if(this.stopped)return Z;if(this.config=Z,this.claim=M4("report",()=>this.standDown()),!this.claim)return console.warn("vitrinka: the recorder runs this page’s capture — Report a problem sends without one"),Z;this.capturing=!0,Z.capturing=!0,q4(F4(),globalThis.location?.host??""),g.pathname=globalThis.location?.pathname??"/",o4(h6(Z.masking)),U2(x.sanitizeUrl),this.capture.push(()=>U2(null));let J=z.windowSec*1000,V=[x.base,$.project,Z.masking,z.classes.join(",")].join("|"),X=[],G=[];if(z.storage==="browser")try{this.store=await T6();let Y=await this.store.sweep(Date.now(),J,g.tabId,V);X=Y;let U=this.store;G=(await Promise.all(Y.filter((W)=>W.kind==="lanes").map((W)=>U.read(W.id)))).flatMap((W)=>W.lanes).sort((W,F)=>Date.parse(W.ts)-Date.parse(F.ts))}catch(Y){console.warn("vitrinka: browser capture storage unavailable — keeping the capture in memory",Y),this.store=null,X=[],G=[]}else b6();if(!this.capturing)return this.store?.close(),this.store=null,Z;if(x3({windowMs:J,checkoutMs:Math.min(z$,J),maxBytes:z.maxBytes,maxEvents:Math.max(20000,Math.round(z.maxBytes/200)),maxLaneEvents:D2,keepLane:X$(Q),store:this.store,scope:V,prior:X,priorLanes:G}),this.capture.push($3),this.store&&typeof window<"u"){let Y=()=>K1();this.capture.push(C(window,"pagehide",Y),C(document,"visibilitychange",Y))}if(Q.errors||Q.console)H6({levels:Q.console?["warn","info","log"]:[]}),this.capture.push(P6);if(Q.errors||Q.network)L6({detail:"meta"}),this.capture.push(O6);if(Q.replay){let Y=await x.loadRecord(x.base).catch((U)=>{return console.warn("vitrinka: the page recorder did not load — reports go without a replay",U),null});if(Y&&this.capturing)I6(Y,"flight",{unmaskSelector:m6}),this.capture.push(A6)}return Z}onChange(x){return this.listeners.add(x),()=>this.listeners.delete(x)}standDown(){if(!this.capturing)return;if(this.capturing=!1,this.config)this.config.capturing=!1;for(let $ of this.capture.splice(0).reverse())$();let x=this.store;if(this.store=null,x)Z3().then(()=>x.close());for(let $ of this.listeners)$()}freeze(){if(!this.capturing)return{clip:null,stored:Promise.resolve(new Map)};g.pathname=globalThis.location?.pathname??g.pathname;let x=P1();if(x&&V1()&&!g2(x))v1(),x=P1();let $=this.store,z=x?.windows.filter((Z)=>Z.stored).map((Z)=>Z.id)??[],Q=$&&z.length?Promise.all(z.map(async(Z)=>[Z,await $.read(Z)])).then((Z)=>new Map(Z)):Promise.resolve(new Map);return Q.catch(()=>{return}),{clip:x,stored:Q}}withScreen(x){if(!this.capturing||!V1()||x&&g2(x))return x;v1();let $=P1();if(!$)return x;return{windows:[...x?.windows.filter((z)=>z.stored)??[],...$.windows.filter((z)=>!z.stored)],lanes:x?.lanes??$.lanes,truncated:x?.truncated??$.truncated}}hiddenIdsAt(x){if(!this.capturing)return null;let $=c6(V1());return $?z5([x],$):null}async build(x,$,z=new Set){let Q=$.filter((K)=>K.shape==="hide").map((K)=>K.rect),Z=c6(V1()),J=Q.length>0&&!Z;if(J)console.warn("vitrinka: this page recorder cannot name what a hide covers — the report goes without its replay");let V=new Set(z);if(Q.length&&Z)for(let K of z5(Q,Z))V.add(K);let X=[],G=this.withScreen(x.clip),Y=G?.truncated??!1,U=await x.stored.catch((K)=>{return console.warn("vitrinka: the stored part of the capture could not be read — the replay starts later",K),null});for(let K of G?.windows??[]){if(!K.stored){X.push(...K.events);continue}let R=U?.get(K.id);if(!R?.events.length)Y=!0;else X.push(...R.events)}let q=G?.lanes??[],W=J?{events:[],dropped:!1}:V$(k6(X,Q,V),u6);if(W.dropped)Y=!0;let{parts:F,dropped:M}=E2(W.events,x$,u6),P=[],D=0;for(let K of F){D+=K.count;let R=W.events[D-1]?.timestamp??Date.now();P.push({seq:P.length+1,ts:new Date(R).toISOString(),count:K.count,body:K.body})}let H=q.filter((K)=>K.kind==="console").slice(-d6).map((K)=>({level:l(K.payload?.level,"error"),ts:K.ts,text:l(K.payload?.text)})),B=q.filter((K)=>K.kind==="net").slice(-d6).map((K)=>({method:l(K.payload?.method,"GET"),path:l(K.payload?.path),status:typeof K.payload?.status==="number"?K.payload.status:0,ms:typeof K.payload?.ms==="number"?K.payload.ms:0}));return{chunks:P,truncated:Y||M.length>0,console:H,network:B}}clear(){if(this.capturing)Q3()}stop(){this.stopped=!0,this.listeners.clear(),this.standDown(),K4(this.claim),this.claim=null;for(let x of this.offs.splice(0).reverse())x()}}var v=null;function l6(x){if(v){let $=v.engine.opts;if(!($.base===x.base&&$.key===x.key&&$.sanitizeUrl===x.sanitizeUrl&&JSON.stringify($.capture??{})===JSON.stringify(x.capture??{})))return console.warn("vitrinka: one capture engine per page — this widget reports without a capture (another widget’s key, base, capture or sanitizeUrl owns it)"),null;return v.refs++,v.engine}return v={engine:new i6(x),refs:1},v.engine}function o6(x){if(!x||!v||v.engine!==x)return;if(--v.refs>0)return;v=null,x.stop()}var j$=/^[\w-]+\.[\w-]+\.[\w-]+$/;function c1(x){if(!x)return null;if("token"in x){let Q=typeof x.token==="string"?x.token.trim():"";if(Q.length>4096||!j$.test(Q))return console.warn("vitrinka: identify({token}) needs the compact JWS your server signed — reporting anonymously"),null;return{token:Q}}let $=typeof x.email==="string"?x.email.trim().slice(0,254):"";if(!$.includes("@"))return console.warn("vitrinka: identify({email}) needs an email address — reporting anonymously"),null;let z=typeof x.name==="string"?x.name.trim().slice(0,200):"";return z?{email:$,name:z}:{email:$}}var n6=null,Q5=new Set;function Y$(x){n6=c1(x);for(let $ of Q5)$()}function a6(){return n6}function r6(x){return Q5.add(x),()=>Q5.delete(x)}var W$=new Set(["Shift","Control","Alt","Meta","AltGraph","OS","CapsLock","Fn","Hyper","Super"]),Z5="report.keybind";function t6(x){if(W$.has(x.key))return{kind:"wait"};if(x.key==="Escape"&&!x.altKey&&!x.ctrlKey&&!x.metaKey&&!x.shiftKey)return{kind:"cancel"};if(!x.altKey&&!x.ctrlKey&&!x.metaKey)return{kind:"bare"};return{kind:"bind",bind:{code:x.code,alt:x.altKey,ctrl:x.ctrlKey,meta:x.metaKey,shift:x.shiftKey}}}function s6(x,$){return x.code===$.code&&x.altKey===$.alt&&x.ctrlKey===$.ctrl&&x.metaKey===$.meta&&x.shiftKey===$.shift}var U$={Space:"Space",Enter:"↵",Backspace:"⌫",Tab:"⇥",ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Slash:"/",Backslash:"\\",Period:".",Comma:",",Semicolon:";",Quote:"'",BracketLeft:"[",BracketRight:"]",Minus:"-",Equal:"=",Backquote:"`"};function e6(x){let $=/^Key([A-Z])$/.exec(x);if($)return $[1];let z=/^(?:Digit|Numpad)(\d)$/.exec(x);if(z)return z[1];return U$[x]??x}function F$(){let x=globalThis.navigator,$=x?.userAgentData?.platform??x?.platform??"";return/mac|iphone|ipad/i.test($)}function i1(x,$=F$()){let z=e6(x.code);if($)return`${x.ctrl?"⌃":""}${x.alt?"⌥":""}${x.shift?"⇧":""}${x.meta?"⌘":""}${z}`;return[x.ctrl&&"Ctrl",x.alt&&"Alt",x.shift&&"Shift",x.meta&&"Meta",z].filter(Boolean).join("+")}function x8(x){return[x.ctrl&&"Control",x.alt&&"Alt",x.shift&&"Shift",x.meta&&"Meta",e6(x.code)].filter(Boolean).join("+")}function q$(x){if(!x)return null;try{let $=JSON.parse(x);if(typeof $!=="object"||$===null)return null;let z=$;if(typeof z.code!=="string"||!z.code)return null;let Q={code:z.code,alt:z.alt===!0,ctrl:z.ctrl===!0,meta:z.meta===!0,shift:z.shift===!0};return Q.alt||Q.ctrl||Q.meta?Q:null}catch{return null}}var M$={code:"KeyA",alt:!0,ctrl:!1,meta:!1,shift:!0},$8="off";function z8(x){if(x===$8)return null;return q$(x)??M$}function Q8(){return z8(S().getString(Z5))}function J5(x){S().set(Z5,x?JSON.stringify(x):$8)}function Z8(x){let $=S();return $.watch?$.watch(Z5,(z)=>x(z8(z))):()=>{return}}var K$=["br","bl","tr","tl"];function V5(x,$){let z=x==="br"||x==="tr"?$.vw-$.w-$.edge:$.edge,Q=x==="br"||x==="bl"?$.vh-$.h-$.bottom:$.top;return{x:Math.max($.edge,z),y:Math.max($.top,Q),w:$.w,h:$.h}}function D$(x,$){let z=Math.min(x.x+x.w,$.x+$.w+12)-Math.max(x.x,$.x-12),Q=Math.min(x.y+x.h,$.y+$.h+12)-Math.max(x.y,$.y-12);return z>0&&Q>0?z*Q:0}function J8(x,$,z){let Q=V5(x,z);return $.reduce((Z,J)=>Z+D$(Q,J),0)}function V8(x,$,z){let Q=J8(x,$,z);if(Q===0)return x;let Z=x,J=Q;for(let V of K$){let X=J8(V,$,z);if(X<J)Z=V,J=X}return Z}function X8(x,$,z,Q){let Z=x==="br"||x==="bl";if($.vh-$.top-$.h-$.bottom>=z.h+Q)return Z?"above":"below";if($.vw-2*$.edge-$.w>=z.w+Q)return x==="br"||x==="tr"?"left":"right";return"over"}async function G8(x,$,z,Q,Z){let J=await fetch(z.url+$,{method:x,mode:"cors",credentials:"omit",headers:{authorization:`Bearer ${z.key}`,...Z?{"x-vitrinka-reporter":Z}:{},...Q!==void 0?{"content-type":"application/json"}:{}},body:Q===void 0?void 0:JSON.stringify(Q)}),V=await J.text();if(!J.ok)throw new L(`${x} ${$} → ${J.status}: ${V}`,J.status);return V?JSON.parse(V):{}}function j8(x,$){return G8("POST","/api/v1/report/session",x,{token:$})}function Y8(x,$=Date.now()){return x!==null&&Date.parse(x.expiresAt)-$>60000}function X5(x,$,z){let Q=z?`?cursor=${encodeURIComponent(z)}`:"";return G8("GET",`/api/v1/report/mine${Q}`,x,void 0,$)}function W8(x,$){return`vitrinka.report.sent:${x}|${$}`}function U8(){try{return globalThis.localStorage??null}catch{return null}}function G5(x,$){let z=U8()?.getItem(W8(x,$));if(!z)return[];try{let Q=JSON.parse(z);if(!Array.isArray(Q))return[];return Q.filter((Z)=>typeof Z?.title==="string"&&typeof Z?.at==="number"&&(Z.status==="filed"||Z.status==="quarantined"))}catch{return[]}}function F8(x,$,z){let Q=U8();if(!Q)return;let Z=[z,...G5(x,$)].slice(0,20);try{Q.setItem(W8(x,$),JSON.stringify(Z))}catch(J){console.warn("vitrinka: could not remember the sent report on this browser",J)}}var q8=`
|
|
10
10
|
:host { all: initial; }
|
|
11
11
|
.vr {
|
|
12
12
|
--ink: #f2f1ef;
|
|
@@ -264,6 +264,7 @@ a.row:hover { background: var(--faint); }
|
|
|
264
264
|
.settings .label { font-weight: 600; }
|
|
265
265
|
.size-row { margin-top: 18px; }
|
|
266
266
|
.size-row .seg button { padding: 0 12px; font-size: 13px; }
|
|
267
|
+
.tips-row { margin-top: 8px; }
|
|
267
268
|
.tech-wrap { margin-top: 18px; }
|
|
268
269
|
.tech { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--bg-deep); font-size: 12.5px; }
|
|
269
270
|
.tech dt { color: var(--dim); }
|
|
@@ -357,26 +358,46 @@ a.row:hover { background: var(--faint); }
|
|
|
357
358
|
.tb-discard { height: 32px; padding: 0 13px; border: 0; border-radius: 9px; background: var(--accent); color: #fff; font-size: 13.5px; font-weight: 650; }
|
|
358
359
|
.tb-discard:hover { background: #e43a57; }
|
|
359
360
|
|
|
360
|
-
/* -- the coach
|
|
361
|
+
/* -- the coach (D21, vt-8020): on the card's edge that faces the open page (place.ts coachSide), never over it -- */
|
|
361
362
|
.coach {
|
|
362
|
-
position:
|
|
363
|
+
position: absolute; z-index: 3; padding: 10px 12px 11px;
|
|
364
|
+
/* Drawing goes on through it (to the marking layer under the card): only its button takes a press. */
|
|
365
|
+
pointer-events: none;
|
|
363
366
|
background: #151417; color: #f2f1ef; border-radius: 14px;
|
|
364
367
|
box-shadow: 0 18px 44px rgba(0, 0, 0, .38), 0 0 0 1px rgba(255, 255, 255, .1) inset;
|
|
365
|
-
pointer-events: none;
|
|
366
368
|
transition: opacity .12s ease;
|
|
367
369
|
}
|
|
370
|
+
.coach[data-side="above"] { left: 0; right: 0; bottom: calc(100% + 10px); }
|
|
371
|
+
.coach[data-side="below"] { left: 0; right: 0; top: calc(100% + 10px); }
|
|
372
|
+
.coach[data-side="left"] { right: calc(100% + 10px); top: 0; width: 300px; }
|
|
373
|
+
.coach[data-side="right"] { left: calc(100% + 10px); top: 0; width: 300px; }
|
|
374
|
+
/* No room around the card (a phone): over its top, the words without the art. */
|
|
375
|
+
.coach[data-side="over"] { left: 10px; right: 10px; top: 58px; }
|
|
376
|
+
.coach[data-side="over"] .coach-art { display: none; }
|
|
368
377
|
.coach.pressing { opacity: .55; }
|
|
369
|
-
.coach svg { display: block; width: 100%; height:
|
|
370
|
-
.coach p { margin:
|
|
378
|
+
.coach svg { display: block; width: 100%; height: 52px; border-radius: 9px; background: #222126; }
|
|
379
|
+
.coach p { margin: 8px 0 0; font-size: 14.5px; line-height: 1.38; }
|
|
371
380
|
.coach p + p { margin-top: 2px; color: rgba(242, 241, 239, .66); font-size: 13px; }
|
|
372
|
-
.coach
|
|
381
|
+
.coach-ok {
|
|
382
|
+
pointer-events: auto; margin-top: 8px; height: 28px; padding: 0 12px; border: 0; border-radius: 8px;
|
|
383
|
+
background: rgba(255, 255, 255, .09); color: #f2f1ef; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
|
|
384
|
+
}
|
|
385
|
+
.coach-ok:hover { background: rgba(255, 255, 255, .14); }
|
|
373
386
|
.mark:focus { outline: none; }
|
|
374
387
|
.mark:focus-visible { outline: 3px solid rgba(230, 69, 95, .65); outline-offset: -3px; }
|
|
388
|
+
/* The art runs on SMIL (widget.ts coachArt): one clock moves the pointer and grows the shape. */
|
|
375
389
|
.coach .bar { fill: #5b5a61; }
|
|
376
|
-
.coach .loop { fill: none; stroke: #e6455f; stroke-width: 3; stroke-linecap: round; stroke-
|
|
377
|
-
.coach .
|
|
378
|
-
|
|
379
|
-
|
|
390
|
+
.coach .loop { fill: none; stroke: #e6455f; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
|
|
391
|
+
.coach .veil { fill: #3a3940; stroke: rgba(255, 255, 255, .2); stroke-width: 1; }
|
|
392
|
+
.coach .hold { fill: none; stroke: #fff; stroke-width: 1.5; }
|
|
393
|
+
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
|
|
394
|
+
.switch {
|
|
395
|
+
position: relative; flex: none; width: 38px; height: 22px; padding: 0; border: 0; border-radius: 999px;
|
|
396
|
+
background: rgba(255, 255, 255, .16); cursor: pointer; transition: background .15s ease;
|
|
397
|
+
}
|
|
398
|
+
.switch[aria-checked="true"] { background: var(--accent); }
|
|
399
|
+
.switch .knob { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: translate .15s ease; }
|
|
400
|
+
.switch[aria-checked="true"] .knob { translate: 16px 0; }
|
|
380
401
|
|
|
381
402
|
@media (max-width: 520px) {
|
|
382
403
|
.vr { --edge: 16px; --lift: calc(var(--edge) + 68px * var(--vr-scale)); }
|
|
@@ -384,16 +405,13 @@ a.row:hover { background: var(--faint); }
|
|
|
384
405
|
.tb { max-width: calc((100vw - 16px) / var(--vr-scale)); overflow-x: auto; }
|
|
385
406
|
.tb-lead { display: none; }
|
|
386
407
|
.seg button { padding: 0 9px; }
|
|
387
|
-
.coach { width: 260px; }
|
|
388
408
|
}
|
|
389
409
|
/* Every motion of the face stops here: the menu rises with the card's vr-in, the coach dims as you press, the chevron turns. */
|
|
390
410
|
@media (prefers-reduced-motion: reduce) {
|
|
391
411
|
.card, .pop { animation: none; }
|
|
392
|
-
.card.parked, .seg-ind, .seg button, .kinds button, .pin .rm, .link svg, .coach { transition: none; }
|
|
412
|
+
.card.parked, .seg-ind, .seg button, .kinds button, .pin .rm, .link svg, .coach, .switch, .switch .knob { transition: none; }
|
|
393
413
|
.card.busy .head::after { animation: none; }
|
|
394
414
|
.fab, .fab.gliding { transition: none; }
|
|
395
|
-
.coach .loop { animation: none; stroke-dashoffset: 0; }
|
|
396
|
-
.coach .hold { animation: none; opacity: .9; }
|
|
397
415
|
}
|
|
398
|
-
`;var Q8={ms:30000,bytesPerMs:32};class Z8 extends Error{constructor(x,$){super(`vitrinka: ${x} got no answer in ${Math.round($/1000)} s — Try again resumes it`);this.name="LegTimeout"}}async function j5(x,$,z){let Q=new AbortController,Z,V=new Promise((J,X)=>{Z=setTimeout(()=>{let G=new Z8(x,$);Q.abort(G),X(G)},$)});try{return await Promise.race([z(Q.signal),V])}finally{clearTimeout(Z)}}var Y5={chunks:[],truncated:!1,console:[],network:[]};function J8(x,$=Q8.ms){return j5("preparing the capture",$,x).catch((z)=>{return console.warn("vitrinka: the capture could not be prepared — the report goes without it",z),Y5})}class U5{capture;tabHost;target;files;limits;id="";custody="";sent="";blobKeys=new Map;rowsPosted=0;skipCapture=!1;filesDone=new Set;constructor(x,$,z,Q=[],Z=Q8){this.capture=x;this.tabHost=$;this.target=z;this.files=Q;this.limits=Z}call(x,$,z){return j5(`${x} ${$}`,this.limits.ms,(Q)=>n(x,$,z,{target:this.target,signal:Q}))}upload(x,$,z){let Q=typeof z==="string"?new TextEncoder().encode(z).byteLength:z.size,Z=this.limits.ms+Math.ceil(Q/this.limits.bytesPerMs);return j5(`POST ${x}`,Z,(V)=>X2(x,$,z,this.target,V))}get filesPending(){return this.filesDone.size<this.files.length}async run(x){let $={title:x.title,description:x.description,markers:x.markers,notify:x.notify??!1},z=JSON.stringify($);if(!this.id){let Z=await this.call("POST","/api/v1/reports",x).catch((V)=>{if(x.type===void 0||!(V instanceof g)||V.status!==400||!/\btype\b/.test(V.message))throw V;console.warn("vitrinka: this server takes no report type yet — sending the report without it");let{type:J,...X}=x;return this.call("POST","/api/v1/reports",X)});if(typeof Z.id!=="string"||!Z.id)throw Error("vitrinka: the server filed the report without an id");this.id=Z.id,this.custody=Z.custody==="direct"?"direct":"quarantined",this.sent=z}else if(this.sent!==z)await this.call("PATCH",`/api/v1/reports/${encodeURIComponent(this.id)}`,$),this.sent=z;if(await this.sendFiles(),!this.skipCapture)try{await this.sendCapture()}catch(Z){if(!(Z instanceof g)||!m(Z.status))throw Z;console.warn("vitrinka: the server refused the recording — the report goes without it",Z),this.skipCapture=!0}let Q=await this.call("POST",`/api/v1/reports/${encodeURIComponent(this.id)}/submit`,{});return{status:Q.status==="filed"?"filed":"quarantined",...typeof Q.reportUrl==="string"&&Q.reportUrl?{reportUrl:Q.reportUrl}:{}}}async sendFiles(){let x=encodeURIComponent(this.id);for(let[$,z]of this.files.entries()){if(this.filesDone.has($))continue;try{await this.upload(`/api/v1/reports/${x}/attachment?name=${encodeURIComponent(z.name)}`,z.type||"application/octet-stream",z)}catch(Q){if(!(Q instanceof g)||!m(Q.status))throw Q;console.warn(`vitrinka: the server refused ${z.name} — the report goes without it`,Q)}this.filesDone.add($)}}async sendCapture(){let x=encodeURIComponent(this.id),{chunks:$,truncated:z}=this.capture;for(let Z of $){if(this.blobKeys.has(Z.seq))continue;let V=await this.upload(`/api/v1/reports/${x}/chunk?seq=${Z.seq}`,"application/json",Z.body);if(!V.blobKey)throw Error(`vitrinka: chunk ${Z.seq} came back without a blob key`);this.blobKeys.set(Z.seq,V.blobKey)}let Q=$.map((Z)=>({seq:Z.seq,ts:Z.ts,tabHost:this.tabHost,kind:"rrweb",payload:{count:Z.count,source:"replay",truncated:z},blobKey:this.blobKeys.get(Z.seq)??""}));while(this.rowsPosted<Q.length){let Z=Q.slice(this.rowsPosted,this.rowsPosted+_1);await this.call("POST",`/api/v1/reports/${x}/events`,{events:Z}),this.rowsPosted+=Z.length}}}var Q$="http://www.w3.org/2000/svg",V8=100,Z$=["circle","box","arrow","hide"],W5={w:160,h:80},X8=16,G8={w:380,h:460},i1=72,F5=16,J$={ArrowLeft:[-10,0],ArrowRight:[10,0],ArrowUp:[0,-10],ArrowDown:[0,10]},L={close:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 4l8 8M12 4l-8 8" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>',gear:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M6.9 1.5h2.2l.35 1.75a5 5 0 011.3.75l1.7-.57 1.1 1.9-1.35 1.18a5 5 0 010 1.5l1.35 1.18-1.1 1.9-1.7-.57a5 5 0 01-1.3.75L9.1 14.5H6.9l-.35-1.75a5 5 0 01-1.3-.75l-1.7.57-1.1-1.9 1.35-1.18a5 5 0 010-1.5L2.45 6.81l1.1-1.9 1.7.57a5 5 0 011.3-.75z" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round"/><circle cx="8" cy="8" r="2" fill="none" stroke="currentColor" stroke-width="1.3"/></svg>',circle:'<svg viewBox="0 0 16 16" aria-hidden="true"><ellipse cx="8" cy="8" rx="6" ry="4.6" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>',box:'<svg viewBox="0 0 16 16" aria-hidden="true"><rect x="2.2" y="3.4" width="11.6" height="9.2" rx="1.8" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>',arrow:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3 13L12.5 3.5M7 3.5h5.5V9" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>',hide:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M2 8s2.3-4 6-4 6 4 6 4-2.3 4-6 4-6-4-6-4z" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linejoin="round"/><path d="M3 13L13 3" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg>',dots:'<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="3.5" cy="8" r="1.3" fill="currentColor"/><circle cx="8" cy="8" r="1.3" fill="currentColor"/><circle cx="12.5" cy="8" r="1.3" fill="currentColor"/></svg>',left:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M10 3.5L5.5 8l4.5 4.5" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>',ext:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M9 3h4v4M13 3L7.5 8.5M11 9.5V13H3V5h3.5" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/></svg>',list:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M5.5 4h8M5.5 8h8M5.5 12h8M2.5 4h.01M2.5 8h.01M2.5 12h.01" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>',clock:'<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="6" fill="none" stroke="currentColor" stroke-width="1.4"/><path d="M8 4.8V8l2.2 1.6" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg>',rec:'<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="6" fill="none" stroke="currentColor" stroke-width="1.4"/><circle cx="8" cy="8" r="2.8" fill="currentColor"/></svg>',link:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M7 9a3 3 0 004.2 0l2-2a3 3 0 00-4.2-4.2l-.8.8M9 7a3 3 0 00-4.2 0l-2 2a3 3 0 004.2 4.2l.8-.8" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg>',clip:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M10.5 4.5l-5 5a1.6 1.6 0 002.3 2.3l5.4-5.4a3 3 0 00-4.2-4.2L3.6 7.6a4.4 4.4 0 006.2 6.2l4-4" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"/></svg>',chevron:'<svg viewBox="0 0 12 12" aria-hidden="true"><path d="M3 4.5l3 3 3-3" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>',pen:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M10.8 2.7l2.5 2.5-7.6 7.6-3.1 0.6 0.6-3.1z" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linejoin="round"/></svg>',check:'<svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="10" fill="none" stroke="currentColor" stroke-width="1.8"/><path d="M7.5 12.3l3 3 6-6.3" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>'},j8="M 134 14 C 200 14, 214 50, 134 50 C 54 50, 68 14, 134 14";function V$(x){let $=x?"":`<animateMotion dur="2.8s" repeatCount="indefinite" keyPoints="0;0;1;1" keyTimes="0;0.18;0.72;1" calcMode="linear" path="${j8}"/>`;return`<svg viewBox="0 0 268 64" aria-hidden="true"><rect class="bar" x="84" y="27" width="100" height="10" rx="5"/><path class="loop" d="${j8}" pathLength="200"/><g class="pointer"${x?' transform="translate(134 14)"':""}><circle class="hold" r="9"/><path d="M0 0 L0 15 L4 11 L7 18 L10 16.6 L7 10 L12.5 10 Z" fill="#fff" stroke="#151417" stroke-width="1"/>${$}</g></svg>`}function j(x,$={},...z){let Q=document.createElement(x);for(let[Z,V]of Object.entries($))Q.setAttribute(Z,V);return Q.append(...z),Q}function _(x){let $=document.createElement("template");$.innerHTML=x;let z=$.content.firstElementChild;if(!z)throw Error("vitrinka: icon markup is empty");return z}function p(x,$){let z=document.createElementNS(Q$,x);for(let[Q,Z]of Object.entries($))z.setAttribute(Q,String(Z));return z}function Y8(x){let $=x.split(`
|
|
399
|
-
`)[0]?.trim()??"";return $.length>V8?`${$.slice(0,V8-1)}…`:$}function W8(){return globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1}function q5(){let x=document.activeElement;while(x?.shadowRoot?.activeElement)x=x.shadowRoot.activeElement;if(x===document.body)return null;return x instanceof HTMLElement||x instanceof SVGElement?x:null}function X$(x){return(x.split("@")[0]?.split(/[\s._-]+/).filter(Boolean)??[]).slice(0,2).map((z)=>z[0]?.toUpperCase()??"").join("")||"?"}function h(x,$){let z=x.querySelector("span");if(z)z.textContent=$}function U8(x,$,z,Q=!1){if(!z||!z.offsetWidth)return;let Z=Q||!x.classList.contains("measured");if(Z)$.style.transition="none";if($.style.width=`${z.offsetWidth}px`,$.style.transform=`translateX(${z.offsetLeft}px)`,x.classList.add("measured"),!Z)return;$.offsetWidth,$.style.removeProperty("transition")}function G$(){let x=q5();return x instanceof HTMLInputElement||x instanceof HTMLTextAreaElement||x instanceof HTMLElement&&x.isContentEditable}function M5(x,$){let z=x.target;if(!$||!(z instanceof Element))return!1;try{return z.closest($)!==null}catch{return!1}}function j$(x){let $=j("span"),z=j("kbd"),Q=j("button",{class:"fab",type:"button",part:"button","aria-haspopup":"dialog"},$,z),Z=j("h2",{id:"vr-title"}),V=j("span",{class:"av","aria-hidden":"true"}),J=j("span",{class:"who-name"}),X=j("button",{class:"who",type:"button","aria-haspopup":"dialog","aria-expanded":"false"},V,J),G=j("button",{class:"icon",type:"button","aria-haspopup":"menu","aria-expanded":"false"},_(L.dots)),Y=j("button",{class:"icon",type:"button"},_(L.close)),F=j("header",{class:"head"},Z,X,G,Y),q=j("strong"),U=j("span",{class:"acc-mail"}),W=j("p",{class:"acc-via"}),M=j("p",{class:"acc-linked"}),H=j("button",{class:"link",type:"button"}),D=j("button",{class:"pop-item",type:"button"},_(L.link),j("span")),P=j("a",{class:"pop-item",target:"_blank",rel:"noopener noreferrer"},_(L.ext),j("span")),B=j("div",{class:"pop acc",role:"dialog"},j("div",{class:"acc-who"},q,U,W),j("div",{class:"acc-member"},M,H),D,P),K=(b)=>j("button",{class:"pop-item",type:"button",role:"menuitem"},_(b),j("span")),C=K(L.list),b0=K(L.clock),E0=K(L.rec),J1=j("small",{class:"pop-why",id:"vr-record-why","aria-hidden":"true"});E0.append(J1);let f0=K(L.gear),H5=j("a",{class:"pop-item",role:"menuitem",target:"_blank",rel:"noopener noreferrer"},_(L.ext),j("span")),P5=j("div",{class:"pop more",role:"menu"},C,b0,E0,f0,H5),N5=j("span",{class:"sr",id:"vr-kinds"}),n1=new Map;for(let b of y3)n1.set(b,j("button",{type:"button",role:"radio","aria-checked":"false","data-kind":b}));let B5=j("div",{class:"kinds",role:"radiogroup","aria-labelledby":"vr-kinds"},N5,...n1.values()),O5=j("label",{class:"prompt",for:"vr-desc"}),L5=j("textarea",{class:"desc",id:"vr-desc",rows:"3"}),g5=j("ol",{class:"lines"}),_5=j("p",{class:"ln-empty"}),A5=j("span"),I5=j("span"),C5=j("button",{class:"link",type:"button","aria-expanded":"false","aria-controls":"vr-included"},I5,_(L.chevron)),R5=j("div",{class:"attached"},_(L.clip),A5,j("span",{"aria-hidden":"true"},"·"),C5),S5=j("ul",{class:"included",id:"vr-included"}),T5=j("input",{type:"checkbox"}),b5=j("span"),E5=j("label",{class:"notify"},T5,b5),f5=j("p",{class:"error",role:"alert"}),w5=j("span"),k5=j("button",{class:"where",type:"button","aria-pressed":"false"},_(L.pen),w5),y5=j("button",{class:"send",type:"button"}),p5=j("div",{class:"pane describe"},B5,O5,L5,j("div",{class:"lines-wrap"},g5,_5),R5,S5,E5,f5),v5=j("button",{class:"icon",type:"button"},_(L.clip)),h5=j("input",{type:"file",multiple:"",tabindex:"-1","aria-hidden":"true",hidden:""}),m5=j("p",{class:"file-note",role:"status"}),u5=j("ul",{class:"files"}),c5=j("div",{class:"tray"},m5,u5),d5=j("div",{class:"foot"},v5,h5,k5,y5),i5=j("span",{class:"label",id:"vr-bind-label"}),l5=j("button",{class:"bind",type:"button","aria-pressed":"false","aria-describedby":"vr-bind-label"}),o5=j("button",{class:"link",type:"button"}),n5=j("p",{class:"hint"}),a5=j("p",{class:"reason",role:"status"}),r5=j("button",{class:"link",type:"button"}),t5=j("span",{class:"label",id:"vr-size-label"}),a1=new Map;for(let b of v2)a1.set(b,j("button",{type:"button",role:"radio","aria-checked":"false","data-size":b}));let s5=j("span",{class:"seg-ind","aria-hidden":"true"}),e5=j("div",{class:"seg",role:"radiogroup","aria-labelledby":"vr-size-label"},s5,...a1.values()),xx=j("span"),$x=j("button",{class:"link",type:"button","aria-expanded":"false","aria-controls":"vr-tech"},xx,_(L.chevron)),zx=j("dl",{class:"tech",id:"vr-tech"}),Qx=j("div",{class:"pane settings"},j("div",{class:"row"},i5,l5),a5,n5,j("div",{class:"row size-row"},t5,e5),j("div",{class:"tech-wrap"},$x,zx),j("div",{class:"settings-foot"},r5,o5)),Zx=j("h3"),Jx=j("p",{class:"sent-body"}),Vx=j("span"),Xx=j("a",{class:"see",target:"_blank",rel:"noopener noreferrer"},Vx),Gx=j("button",{class:"link",type:"button"}),jx=j("div",{class:"pane sent",role:"status"},j("div",{class:"sent-head"},_(L.check),Zx),Jx,j("div",{class:"sent-actions"},Xx,Gx)),r1=()=>j("button",{class:"back",type:"button"},_(L.left),j("span")),Yx=r1(),Ux=j("p",{class:"list-status"}),Wx=j("ul",{class:"rows"}),Fx=j("p",{class:"list-note"}),qx=j("a",{class:"link",target:"_blank",rel:"noopener noreferrer"}),Mx=j("div",{class:"pane list"},Yx,Ux,Wx,Fx,qx),Kx=r1(),Dx=j("p",{class:"list-status"}),Hx=j("ul",{class:"rows"}),Px=j("div",{class:"pane list"},Kx,Dx,Hx),Nx=r1(),Bx=j("p",{class:"list-note"}),Ox=j("div",{class:"code"}),Lx=j("span"),gx=j("a",{class:"see",target:"_blank",rel:"noopener noreferrer"},Lx),_x=j("img",{class:"qr",alt:""}),Ax=j("p",{class:"hint"}),Ix=j("p",{class:"list-status",role:"status"}),Cx=j("button",{class:"link",type:"button"}),Rx=j("div",{class:"pane linking"},Nx,Bx,Ox,j("div",{class:"link-go"},gx,_x),Ax,Ix,Cx),Sx=j("div",{class:"body"},p5,Qx,jx,Mx,Px,Rx),Tx=j("section",{class:"card",role:"dialog","aria-modal":"false","aria-labelledby":"vr-title"},F,B,P5,Sx,c5,d5),t1=p("svg",{class:"ink","aria-hidden":"true"}),bx=p("defs",{}),Ex=p("marker",{id:"vr-head",viewBox:"0 0 10 10",refX:7,refY:5,markerWidth:5,markerHeight:5,orient:"auto-start-reverse"});Ex.append(p("path",{d:"M0 0L10 5L0 10z",fill:"#dc2f4c"})),bx.append(Ex);let fx=p("g",{}),wx=p("g",{class:"draft"});t1.append(bx,fx,wx);let kx=j("div",{class:"pins"}),yx=j("p"),px=j("p"),vx=j("p",{class:"keys",id:"vr-keys"}),s1=j("div",{class:"coach",role:"status"});s1.append(_(V$(W8())),yx,px,vx);let e1=new Map,hx=new Map;for(let b of Z$){let tx=j("span");hx.set(b,tx),e1.set(b,j("button",{type:"button",role:"radio","aria-checked":"false","data-tool":b},_(L[b]),tx))}let mx=j("span",{class:"seg-ind","aria-hidden":"true"}),ux=j("div",{class:"seg",role:"radiogroup"},mx,...e1.values()),cx=j("span",{class:"tb-lead"}),dx=j("button",{type:"button",class:"tb-quiet"}),ix=j("span",{class:"tb-ask"}),lx=j("button",{type:"button",class:"tb-discard"}),ox=j("button",{type:"button",class:"tb-quiet"}),nx=j("span",{class:"tb-confirm",role:"group"},ix,lx,ox),ax=j("div",{class:"tb",role:"toolbar"},cx,ux,j("span",{class:"tb-sep","aria-hidden":"true"}),dx,nx),x2=j("div",{class:"mark",tabindex:"0",role:"application","aria-describedby":"vr-keys"},kx,s1,ax);x2.prepend(t1);let $2=j("div",{class:"vr"},Q,x2,Tx),rx=j("style");return rx.textContent=z8,$2.prepend(rx),x.append($2),{root:$2,fab:Q,fabLabel:$,fabKbd:z,card:Tx,head:F,title:Z,whoBtn:X,whoAv:V,whoName:J,more:G,closeBtn:Y,body:Sx,foot:d5,accountPop:B,accName:q,accMail:U,accVia:W,accLinked:M,accUnlink:H,accLink:D,accPortal:P,morePop:P5,mReports:C,mRecents:b0,mRecord:E0,mRecordWhy:J1,mSettings:f0,mOpen:H5,reports:Mx,repBack:Yx,repStatus:Ux,repRows:Wx,repLocal:Fx,repPortal:qx,recents:Px,recBack:Kx,recStatus:Dx,recRows:Hx,linking:Rx,linkBack:Nx,linkLabel:Bx,linkCode:Ox,linkOpen:gx,linkOpenText:Lx,linkQr:_x,linkHint:Ax,linkWait:Ix,linkRetry:Cx,describe:p5,kinds:B5,kindsLabel:N5,kindButtons:n1,prompt:O5,desc:L5,lines:g5,linesEmpty:_5,attached:R5,attachedText:A5,disclose:C5,discloseText:I5,included:S5,notify:E5,notifyBox:T5,notifyText:b5,error:f5,where:k5,whereText:w5,send:y5,attach:v5,fileInput:h5,fileNote:m5,files:u5,tray:c5,settings:Qx,bindLabel:i5,bindBtn:l5,unbind:o5,bindHint:n5,bindReason:a5,back:r5,sizeLabel:t5,sizeButtons:a1,sizeInd:s5,sizeSeg:e5,techText:xx,techBtn:$x,tech:zx,sent:jx,sentTitle:Zx,sentBody:Jx,see:Xx,seeText:Vx,sentClose:Gx,mark:x2,ink:t1,shapes:fx,draft:wx,pins:kx,coach:s1,coachText:yx,coachMore:px,coachKeys:vx,toolbar:ax,barLead:cx,seg:ux,segInd:mx,toolButtons:e1,toolLabels:hx,cancel:dx,ask:nx,askText:ix,discard:lx,keep:ox}}class K5{opts;hud;engine;config=null;locale;s;button;openSelector;identity;keybind;isOpen=!1;opener=null;view="describe";marking=!1;markers=[];nextKey=1;tool="circle";frozen=null;job=null;sending=!1;error="";result=null;notify=!1;sentNotify=!1;includedOpen=!1;recordingBind=!1;bindRefused=!1;kind=null;passKeys=new Set;confirming=!1;parked=null;parkInsets=null;dock=J6();size=$6();techOpen=!1;fabDrag=null;swallowClick=!1;glide=null;files=[];fileRefusal=null;pastes=0;chips=new Map;recordSwitch=null;menu=null;session=null;sessionToken="";member=null;mine={rows:[],state:"ok"};linkFlow=null;drawing=null;offs=[];pins=new Map;lines=new Map;hideIds=new Map;dialogOrder=[...document.querySelectorAll("dialog[open]")].filter((x)=>x instanceof HTMLDialogElement);activeDialog(){this.dialogOrder=this.dialogOrder.filter((z)=>z.isConnected&&z.open);let x=(z)=>{try{return z.matches(":modal")}catch{return!1}};return[...this.dialogOrder].reverse().find(x)??this.dialogOrder.at(-1)??o3()}sheet=null;e;constructor(x){this.opts=x;this.locale=x.locale??y2(),this.s=k2(this.locale),this.button=x.button,this.openSelector=x.openSelector??null,this.identity=x.identity===void 0?void 0:u1(x.identity),this.keybind=l6(),this.hud=i3(),this.e=j$(this.hud.mount),this.engine=p6({base:x.base,key:x.key,appVersion:x.appVersion,capture:x.capture,sanitizeUrl:x.sanitizeUrl,loadRecord:x.loadRecord}),this.engine?.ready.then(($)=>{this.config=$,this.paint()}),this.bind(),this.paint(),this.followDialog()}followDialog(){let x=this.activeDialog();if((this.sheet?.target??null)===x)return;let $=this.e.root.getRootNode(),z=$ instanceof ShadowRoot&&$.activeElement instanceof HTMLElement?$.activeElement:null,Q=this.sheet;if(x){let Z=n3(x);Z.mount.append(this.e.root),this.sheet={target:x,host:Z}}else this.hud.mount.append(this.e.root),this.sheet=null;Q?.host.destroy(),z?.focus()}open(){if(this.isOpen)return;if(this.isOpen=!0,this.opener=a3(document.activeElement)?null:q5(),this.view!=="describe")this.view="describe";if(this.result=null,!this.job)this.frozen=this.engine?.freeze()??null;this.paint(),requestAnimationFrame(()=>this.e.desc.focus()),this.refreshWho(),this.refreshMember()}close(){if(!this.isOpen)return;if(this.marking)this.endMarking(!1);this.stopRecordingBind(),this.isOpen=!1,this.view="describe",this.unpark(),this.paint();let x=this.opener;if(this.opener=null,x?.focus(),x&&q5()===x)return;if(this.button)this.e.fab.focus()}setLocale(x){let $=o0(x)??y2();if($===this.locale)return;this.locale=$,this.s=k2($),this.paint()}setButton(x){this.button=x,this.paint()}setOpenSelector(x){this.openSelector=x||null}setRecordSwitch(x){this.recordSwitch=x,this.paint()}identify(x){this.identity=x===void 0?void 0:u1(x),this.whoChanged()}unmount(){this.stopRecordingBind(),this.linkFlow?.abort.abort();for(let x of this.offs.splice(0).reverse())x();v6(this.engine),this.sheet?.host.destroy(),this.sheet=null,this.hud.destroy()}bind(){let x=this.e,$=(J,X,G)=>{J.addEventListener(X,G)};$(x.fab,"click",()=>{if(this.swallowClick){this.swallowClick=!1;return}if(this.isOpen)this.close();else this.open()}),$(x.fab,"pointerdown",(J)=>this.fabDown(J)),$(x.fab,"pointermove",(J)=>this.fabMove(J)),$(x.fab,"pointerup",(J)=>this.fabUp(J,!0)),$(x.fab,"pointercancel",(J)=>this.fabUp(J,!1)),$(x.fab,"keydown",(J)=>{if(!J.altKey||J.ctrlKey||J.metaKey||J.shiftKey)return;let X=G6(this.dock,J.key);if(!X)return;if(J.preventDefault(),X!==this.dock)this.moveDock(X)}),$(x.attach,"click",()=>x.fileInput.click()),$(x.fileInput,"change",()=>{this.addFiles([...x.fileInput.files??[]]),x.fileInput.value=""}),$(x.card,"paste",(J)=>{let X=[...J.clipboardData?.files??[]];if(!X.length||!this.canAttach())return;let G=J.clipboardData?.getData("text/plain").trim()??"";if(G&&!X.some((Y)=>Y.name&&G.includes(Y.name)))return;J.preventDefault(),this.addFiles(X.map((Y)=>{let F=e3(Y.name,++this.pastes);return F===Y.name?Y:new File([Y],F,{type:Y.type,lastModified:Y.lastModified})}))}),$(x.card,"dragover",(J)=>{if(!J.dataTransfer?.types.includes("Files")||!this.canAttach())return;J.preventDefault(),J.dataTransfer.dropEffect="copy",x.card.classList.add("dropping")}),$(x.card,"dragleave",(J)=>{if(J.relatedTarget instanceof Node&&x.card.contains(J.relatedTarget))return;x.card.classList.remove("dropping")}),$(x.card,"drop",(J)=>{x.card.classList.remove("dropping");let X=[...J.dataTransfer?.files??[]];if(!X.length||!this.canAttach())return;J.preventDefault(),this.addFiles(X)});for(let[J,X]of x.sizeButtons)$(X,"click",()=>{if(this.size=J,b1(h2,J),this.paint(),this.parked)this.placeCard(!0)});$(x.techBtn,"click",()=>{this.techOpen=!this.techOpen,this.paint()}),$(x.closeBtn,"click",()=>this.close()),$(x.whoBtn,"click",()=>this.toggleMenu("account")),$(x.more,"click",()=>this.toggleMenu("more"));let z=(J)=>()=>{this.menu=null,J(),this.paint()};$(x.morePop,"keydown",(J)=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(J.key))return;let X=[...x.morePop.querySelectorAll('[role="menuitem"]')].filter((W)=>!W.hidden&&!(W instanceof HTMLButtonElement&&W.disabled));if(!X.length)return;J.preventDefault();let G=x.morePop.getRootNode(),Y=X.indexOf(G.activeElement),F=X.length-1,q=J.key==="ArrowDown",U=J.key==="Home"?0:J.key==="End"?F:Y<0?q?0:F:(Y+(q?1:-1)+X.length)%X.length;X[U]?.focus()}),$(x.mReports,"click",z(()=>void this.openReports())),$(x.mRecents,"click",z(()=>this.show("recents")));let Q=z(()=>this.recordSwitch?.());$(x.mRecord,"click",()=>{if(!this.recordWaits())Q()}),$(x.mSettings,"click",z(()=>this.show("settings"))),$(x.mOpen,"click",z(()=>{return})),$(x.accPortal,"click",z(()=>{return})),$(x.accLink,"click",z(()=>this.startLinkFlow())),$(x.accUnlink,"click",()=>{K4(),this.member=null,this.paint()});for(let J of[x.repBack,x.recBack,x.linkBack])$(J,"click",()=>this.show("describe"));$(x.linkRetry,"click",()=>this.startLinkFlow()),$(x.card,"pointerdown",(J)=>{let X=J.target;if(!this.menu||!(X instanceof Node))return;if([x.accountPop,x.morePop,x.whoBtn,x.more].some((G)=>G.contains(X)))return;this.menu=null,this.paint()}),$(x.back,"click",()=>this.show("describe")),$(x.sentClose,"click",()=>this.close()),$(x.desc,"input",()=>this.paint()),$(x.disclose,"click",()=>{this.includedOpen=!this.includedOpen,this.paint()}),$(x.notifyBox,"change",()=>{this.notify=x.notifyBox.checked}),$(x.where,"click",()=>this.marking?this.endMarking(!0):this.startMarking()),$(x.send,"click",()=>void this.send()),$(x.bindBtn,"click",()=>this.recordingBind?this.stopRecordingBind():this.startRecordingBind()),$(x.unbind,"click",()=>{this.keybind=null,J5(null),this.paint()});for(let[J,X]of x.kindButtons)$(X,"click",()=>{this.kind=this.kind===J?null:J,this.paint()});$(x.card,"keydown",(J)=>{if(J.key!=="Escape"||this.recordingBind||J.defaultPrevented)return;if(J.preventDefault(),this.menu){let X=this.menu==="account"?x.whoBtn:x.more;this.menu=null,this.paint(),X.focus()}else if(this.view!=="describe"&&this.view!=="sent")this.show("describe");else this.close()});for(let[J,X]of x.toolButtons)$(X,"click",(G)=>{if(this.tool=J,this.renderKbDraft(),this.paint(),this.placeSeg(),G.detail===0)x.mark.focus()});if($(x.mark,"keydown",(J)=>this.markKey(J)),$(x.cancel,"click",()=>this.cancelMarking()),$(x.discard,"click",()=>{this.markers=l1(this.markers.filter((J)=>this.passKeys.has(J.key))),this.renderMarks(),this.endMarking(!0)}),$(x.keep,"click",()=>{this.confirming=!1,this.paint(),x.cancel.focus()}),$(x.mark,"pointerdown",(J)=>this.pointerDown(J)),$(x.mark,"pointermove",(J)=>this.pointerMove(J)),$(x.mark,"pointerup",(J)=>this.pointerUp(J)),$(x.mark,"pointercancel",()=>this.cancelDraft()),this.offs.push(R(x.mark,"wheel",(J)=>J.preventDefault())),this.offs.push(R(x.mark,"touchmove",(J)=>J.preventDefault())),this.offs.push(R(window,"keydown",(J)=>{if(this.recordingBind)return;if(this.marking&&J.key==="Escape"){if(J.preventDefault(),this.confirming)x.keep.click();else if(this.kbDraft)this.cancelDraft();else this.endMarking(!0);return}if(this.marking&&(J.metaKey||J.ctrlKey)&&!J.shiftKey&&!J.altKey&&J.key.toLowerCase()==="z"&&!G$()){J.preventDefault(),this.markers=l1(this.markers.slice(0,-1)),this.renderMarks(),this.paint();return}if(this.keybind&&d6(J,this.keybind))if(J.preventDefault(),this.isOpen)this.close();else this.open()},{capture:!0})),this.offs.push(R(document,"click",(J)=>{if(!M5(J,this.openSelector))return;J.preventDefault(),this.open()})),this.offs.push(R(window,"resize",()=>{if(this.parked)this.placeCard(!0);if(this.marking)this.placeSeg()})),this.offs.push(o6((J)=>{this.keybind=J,this.paint()})),this.offs.push(u6(()=>this.whoChanged())),this.engine)this.offs.push(this.engine.onChange(()=>this.paint()));let Z=0,V=new MutationObserver((J)=>{for(let X of J){if(X.type!=="attributes"||X.attributeName!=="open"||!(X.target instanceof HTMLDialogElement))continue;let G=X.target;if(!G.open)this.dialogOrder=this.dialogOrder.filter((Y)=>Y!==G);else if(X.oldValue===null)this.dialogOrder=[...this.dialogOrder.filter((Y)=>Y!==G),G]}if(Z)return;Z=requestAnimationFrame(()=>{Z=0,this.followDialog()})});V.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeOldValue:!0,attributeFilter:["open","data-state"]}),this.offs.push(()=>{if(V.disconnect(),Z)cancelAnimationFrame(Z)})}show(x){if(this.stopRecordingBind(),x!=="link"&&this.linkFlow)this.linkFlow.abort.abort(),this.linkFlow=null;this.view=x,this.paint();let $={describe:this.e.desc,settings:this.e.bindBtn,sent:null,reports:this.e.repBack,recents:this.e.recBack,link:this.e.linkBack}[x];if($)requestAnimationFrame(()=>$.focus())}target(){return{url:this.opts.base,key:this.opts.key}}toggleMenu(x){if(this.menu=this.menu===x?null:x,this.menu==="account")this.refreshWho(),this.refreshMember();this.paint(),(this.menu==="account"?this.e.accountPop:this.menu==="more"?this.e.morePop:null)?.querySelector("button:not([hidden]), a:not([hidden])")?.focus()}async refreshWho(){let x=this.who();if(!x||!("token"in x))return this.session=null,this.sessionToken="",null;if(this.sessionToken===x.token&&s6(this.session))return this.session;this.sessionToken=x.token;let $=null;try{$=await t6(this.target(),x.token)}catch(z){console.warn("vitrinka: the reporter session could not be opened — My reports shows this browser’s reports only",z)}if(this.sessionToken!==x.token)return null;return this.session=$,this.paint(),this.session}whoChanged(){if(this.whoToken()!==this.sessionToken){if(this.session=null,this.sessionToken="",this.mine={rows:[],state:"ok"},this.isOpen)this.view==="reports"?this.loadReports():this.refreshWho()}this.paint()}async refreshMember(){let x=l0(this.opts.base)?h0():null;if(!x){if(this.member)this.member=null,this.paint();return}try{let $=await n("GET","/api/v1/recorder/me",void 0,{target:{url:this.opts.base,key:x.token}});this.member={email:$.user?.email??"",name:$.user?.name??"",workspace:$.workspace?.slug??x.workspace},E3($.displayMode)}catch($){console.warn("vitrinka: the linked vitrinka account could not be read",$),this.member={email:"",name:"",workspace:x.workspace}}this.paint()}async openReports(){this.show("reports"),await this.loadReports()}async loadReports(){let x=this.whoToken(),$=await this.refreshWho();if(this.whoToken()!==x)return;if(!$){this.mine={rows:[],state:"ok"},this.paint();return}this.mine={rows:[],state:"loading"},this.paint();let z;try{z={rows:await this.listMineRenewing($),state:"ok"}}catch(Q){console.warn("vitrinka: My reports could not be loaded",Q),z={rows:[],state:"failed"}}if(this.whoToken()!==x)return;this.mine=z,this.paint()}async listMineRenewing(x){try{return(await X5(this.target(),x.session)).reports}catch($){if(!($ instanceof g)||$.status!==401)throw $;this.session=null,this.sessionToken="";let z=await this.refreshWho();if(!z)throw $;return(await X5(this.target(),z.session)).reports}}startLinkFlow(){this.linkFlow?.abort.abort();let x={start:null,state:"starting",abort:new AbortController};this.linkFlow=x,this.show("link");let $=this.opts.base,z=X1($);(async()=>{try{x.start=await Z4($,{label:H4(),workspace:z}),x.state="waiting",this.paint();let Q=await J4($,x.start.device_code,{interval:x.start.interval,expiresIn:x.start.expires_in,workspace:z,signal:x.abort.signal});M4({...Q,base:$}),this.linkFlow=null,this.show("describe"),await this.refreshMember()}catch(Q){if(x.abort.signal.aborted)return;if(x.state=Q instanceof w0?"expired":"failed",x.state==="failed")console.warn("vitrinka: linking the vitrinka account failed",Q);this.paint()}})()}ago(x){let $=new Intl.RelativeTimeFormat(this.locale,{numeric:"auto"}),z=Math.round((x-Date.now())/1000),Q=[[60,"second"],[60,"minute"],[24,"hour"],[30,"day"],[12,"month"],[1/0,"year"]],Z=z;for(let[V,J]of Q){if(Math.abs(Z)<V)return $.format(Z,J);Z=Math.round(Z/V)}return $.format(Z,"year")}row(x,$,z,Q){let Z=[j("span",{class:"row-t"},x),j("span",{class:"step"},$),j("span",{class:"age"},this.ago(z))],V=Q?j("a",{class:"row",href:Q,target:"_blank",rel:"noopener noreferrer"},...Z):j("div",{class:"row"},...Z);return j("li",{},V)}who(){return this.identity!==void 0?this.identity:m6()}whoToken(){let x=this.who();return x&&"token"in x?x.token:""}stopBindListener=null;startRecordingBind(){this.recordingBind=!0,this.bindRefused=!1,this.stopBindListener=R(window,"keydown",(x)=>{x.preventDefault(),x.stopPropagation();let $=c6(x);if($.kind==="wait")return;if($.kind==="bare"){this.bindRefused=!0,this.paint();return}if($.kind==="bind")this.keybind=$.bind,J5($.bind);this.stopRecordingBind()},{capture:!0}),this.paint()}stopRecordingBind(){if(!this.recordingBind)return;this.recordingBind=!1,this.bindRefused=!1,this.stopBindListener?.(),this.stopBindListener=null,this.paint()}canAttach(){return this.isOpen&&this.view==="describe"&&!this.sending&&!this.job?.id}caps(){return this.config?.attachments??Q0}addFiles(x){if(!x.length)return;let{files:$,refusal:z}=t3(this.files,x,this.caps());this.files=[...this.files,...$],this.fileRefusal=z,this.renderFiles(),this.paint()}removeFile(x){this.files=this.files.filter(($)=>$!==x),this.fileRefusal=null,this.renderFiles(),this.paint(),this.e.attach.focus()}renderFiles(){let x=new Set(this.files);for(let[$,z]of this.chips){if(x.has($))continue;z.el.remove(),this.chips.delete($)}for(let $ of this.files){if(this.chips.has($))continue;let z=j("span",{class:"file-size"}),Q=j("button",{class:"ln-x",type:"button"},_(L.close)),Z=j("li",{class:"file"},j("span",{class:"file-name"},$.name),z,Q);Q.addEventListener("click",()=>this.removeFile($)),this.e.files.append(Z),this.chips.set($,{el:Z,size:z,rm:Q})}}refusalText(x){let $=this.s;if(!x)return"";if(x.kind==="size")return $.fileTooBig(x.name,a0(x.cap,this.locale));if(x.kind==="count")return $.tooManyFiles(x.cap);return $.fileType(x.name,s3(this.caps().types,$.typeNames,this.locale))}fabDown(x){if(this.swallowClick=!1,x.button!==0||!x.isPrimary)return;let $=this.e.fab.getBoundingClientRect();this.fabDrag={pointer:x.pointerId,start:{x:x.clientX,y:x.clientY},grab:{x:x.clientX-$.left,y:x.clientY-$.top},moved:!1};try{this.e.fab.setPointerCapture(x.pointerId)}catch{}}fabMove(x){let $=this.fabDrag;if(!$||x.pointerId!==$.pointer)return;if(!$.moved&&Math.hypot(x.clientX-$.start.x,x.clientY-$.start.y)<Z6)return;$.moved=!0;let z=this.e.fab;z.classList.add("dragging");let Q=z.getBoundingClientRect(),Z=globalThis.innerWidth||800,V=globalThis.innerHeight||600,J=z.style;J.left=`${Math.min(Math.max(0,x.clientX-$.grab.x),Z-Q.width)}px`,J.top=`${Math.min(Math.max(0,x.clientY-$.grab.y),V-Q.height)}px`,J.right="auto",J.bottom="auto"}fabUp(x,$){let z=this.fabDrag;if(!z||x.pointerId!==z.pointer)return;if(this.fabDrag=null,!z.moved)return;let Q=this.e.fab,Z=Q.getBoundingClientRect();Q.classList.remove("dragging");for(let X of["left","top","right","bottom"])Q.style.removeProperty(X);this.swallowClick=!0,setTimeout(()=>{this.swallowClick=!1},0);let V=globalThis.innerWidth||800,J=globalThis.innerHeight||600;this.moveDock($?X6({x:Z.left+Z.width/2,y:Z.top+Z.height/2},V,J):this.dock,Z)}moveDock(x,$){let z=this.e.fab,Q=$??z.getBoundingClientRect();if(this.dock=x,V6(x),this.paint(),z.hidden||W8())return;let Z=z.getBoundingClientRect(),V=Q.left-Z.left,J=Q.top-Z.top;if(!V&&!J)return;this.glide?.abort();let X=new AbortController;this.glide=X,z.classList.remove("gliding"),z.style.setProperty("translate",`${V}px ${J}px`),z.offsetWidth,z.classList.add("gliding"),z.style.setProperty("translate","0px 0px");let G=(Y)=>{if(Y.propertyName!=="translate")return;X.abort(),z.classList.remove("gliding"),z.style.removeProperty("translate")};z.addEventListener("transitionend",G,{signal:X.signal}),z.addEventListener("transitioncancel",G,{signal:X.signal})}startMarking(){if(this.job?.id)return;this.marking=!0,this.confirming=!1,this.passKeys=new Set(this.markers.map((z)=>z.key));let x=this.parked??this.dock;this.parkInsets=this.insetsAt(x,this.e.card.getBoundingClientRect()),this.parked=x,this.renderMarks(),this.paint(),this.placeCard(),this.placeSeg(!0);let $=globalThis.innerWidth||800;this.placeCoach({x:$/2-150,y:i1+12},!1),this.e.mark.focus()}endMarking(x){if(this.cancelDraft(),this.marking=!1,this.confirming=!1,this.paint(),x&&this.isOpen)requestAnimationFrame(()=>this.e.desc.focus())}cancelMarking(){if(this.markers.filter(($)=>!this.passKeys.has($.key)).length===0){this.endMarking(!0);return}this.confirming=!0,this.paint(),this.e.discard.focus()}insetsAt(x,$){let z=globalThis.innerWidth||800,Q=globalThis.innerHeight||600,Z=i1*T1[this.size],V=x==="br"||x==="bl";return{edge:Math.max(0,Math.min($.left,z-$.right)),top:V?Z:Math.max(Z,$.top),bottom:V?Math.max(0,Q-$.bottom):F5}}frame(){let x=globalThis.innerWidth||800,$=globalThis.innerHeight||600,z=T1[this.size],Q=this.parkInsets??{top:i1*z,bottom:F5,edge:F5},Z=this.e.card.getBoundingClientRect();return{vw:x,vh:$,w:Z.width||Math.min(G8.w*z,x-32),h:Z.height||Math.min(G8.h*z,$-Q.top-Q.bottom),...Q}}placeCard(x=!1){if(!this.parked)return;let $=this.frame(),z=this.parked;this.parked=a6(this.parked,this.markers.map((J)=>J.rect),$);let Q=V5(this.parked,$),Z=this.e.card,V=x&&this.parked===z;if(V)Z.style.transition="none";if(Z.classList.add("parked"),Z.style.left=`${Q.x}px`,Z.style.top=`${Q.y}px`,!V)return;Z.offsetWidth,Z.style.removeProperty("transition")}unpark(){this.parked=null,this.parkInsets=null,this.e.card.classList.remove("parked"),this.e.card.style.removeProperty("left"),this.e.card.style.removeProperty("top")}placeSeg(x=!1){U8(this.e.seg,this.e.segInd,this.e.toolButtons.get(this.tool),x)}onChrome(x){return x instanceof Node&&(this.e.toolbar.contains(x)||this.e.pins.contains(x))}pointerDown(x){if(this.onChrome(x.target)||x.button!==0||!x.isPrimary)return;x.preventDefault();let $=this.e.root.getRootNode();if($ instanceof ShadowRoot&&$.activeElement instanceof HTMLElement)$.activeElement.blur();this.drawing={start:{x:x.clientX,y:x.clientY},shape:this.tool,pointer:x.pointerId};try{this.e.mark.setPointerCapture(x.pointerId)}catch{}this.e.coach.classList.add("pressing")}pointerMove(x){if(!this.markers.length)this.placeCoach({x:x.clientX,y:x.clientY},!0);let $=this.drawing;if(!$||x.pointerId!==$.pointer)return;this.e.draft.replaceChildren(...this.shapeNodes({shape:$.shape,rect:s2($.start,{x:x.clientX,y:x.clientY}),head:e2($.start,{x:x.clientX,y:x.clientY})}))}pointerUp(x){let $=this.drawing;if(!$||x.pointerId!==$.pointer)return;let z={x:x.clientX,y:x.clientY};if(this.cancelDraft(),!_6($.shape,$.start,z))return;this.addMarker($.shape,s2($.start,z),$.shape==="arrow"?e2($.start,z):void 0)}addMarker(x,$,z){let Q=this.nextKey++;if(x==="hide"){let Z=this.engine?.hiddenIdsAt($);if(Z)this.hideIds.set(Q,Z)}this.markers=l1([...this.markers,{key:Q,n:this.markers.length+1,shape:x,rect:$,note:"",...z?{head:z}:{}}]),this.renderMarks(),this.paint(),this.lines.get(Q)?.note.focus()}cancelDraft(){this.drawing=null,this.kbDraft=null,this.e.draft.replaceChildren(),this.e.coach.classList.remove("pressing")}kbDraft=null;markKey(x){if(x.target!==this.e.mark)return;let $=globalThis.innerWidth||800,z=globalThis.innerHeight||600;if(x.key==="Enter"||x.key===" "){if(x.preventDefault(),!this.kbDraft){this.kbDraft={x:Math.round($/2-W5.w/2),y:Math.round(z/2-W5.h/2),...W5},this.renderKbDraft();return}let X=this.kbDraft;this.cancelDraft(),this.addMarker(this.tool,X,this.tool==="arrow"?"se":void 0);return}let Q=J$[x.key];if(!Q||!this.kbDraft)return;x.preventDefault();let Z=this.kbDraft,[V,J]=Q;this.kbDraft=x.shiftKey?{...Z,w:Math.min($-Z.x,Math.max(X8,Z.w+V)),h:Math.min(z-Z.y,Math.max(X8,Z.h+J))}:{...Z,x:Math.min($-Z.w,Math.max(0,Z.x+V)),y:Math.min(z-Z.h,Math.max(0,Z.y+J))},this.renderKbDraft()}renderKbDraft(){let x=this.kbDraft;if(!x)return;this.e.draft.replaceChildren(...this.shapeNodes({shape:this.tool,rect:x,head:"se"}))}placeCoach(x,$){let z=globalThis.innerWidth||800,Q=globalThis.innerHeight||600,Z=this.e.coach.offsetWidth||300,V=this.e.coach.offsetHeight||140,J=$?x.x+20:x.x,X=$?x.y+20:x.y;if(J+Z>z-8)J=$?x.x-Z-20:z-Z-8;if(X+V>Q-90)X=$?x.y-V-20:Q-V-90;this.e.coach.style.left=`${Math.max(8,J)}px`,this.e.coach.style.top=`${Math.max(8,X)}px`}shapeNodes(x){let{x:$,y:z,w:Q,h:Z}=x.rect;if(x.shape==="circle")return[p("ellipse",{class:"stroke",cx:$+Q/2,cy:z+Z/2,rx:Math.max(1,Q/2),ry:Math.max(1,Z/2)})];if(x.shape==="box")return[p("rect",{class:"stroke",x:$,y:z,width:Q,height:Z,rx:6})];if(x.shape==="arrow"){let{tail:X,tip:G}=x5(x.rect,x.head??"se");return[p("line",{class:"stroke",x1:X.x,y1:X.y,x2:G.x,y2:G.y,"marker-end":"url(#vr-head)"})]}let V=p("rect",{class:"veil",x:$,y:z,width:Q,height:Z,rx:4}),J=p("text",{class:"veil-label",x:$+Q/2,y:z+Z/2+4,"text-anchor":"middle"});return J.textContent=Q>60&&Z>20?this.s.hidden:"",[V,J]}renderMarks(){this.e.shapes.replaceChildren(...this.markers.flatMap((z)=>this.shapeNodes(z)));let x=new Set(this.markers.map((z)=>z.key));for(let[z,Q]of this.pins){if(x.has(z))continue;Q.el.remove(),this.pins.delete(z)}for(let[z,Q]of this.lines){if(x.has(z))continue;Q.el.remove(),this.lines.delete(z)}let $=(z)=>{this.markers=l1(this.markers.filter((Q)=>Q.key!==z)),this.renderMarks(),this.paint()};for(let z of this.markers){if(this.pins.has(z.key))continue;let Q=j("button",{class:"num",type:"button"}),Z=j("button",{class:"rm",type:"button"},_(L.close)),V=j("div",{class:"pin"},Q,Z);Q.addEventListener("click",()=>this.lines.get(z.key)?.note.focus()),Z.addEventListener("click",()=>$(z.key)),this.e.pins.append(V),this.pins.set(z.key,{el:V,num:Q,rm:Z});let J=j("span",{class:"ln-n","aria-hidden":"true"}),X=j("input",{class:"ln-t",type:"text",maxlength:"500"}),G=j("button",{class:"ln-x",type:"button"},_(L.close)),Y=j("li",{class:"ln"},J,X,G);X.addEventListener("input",()=>{this.markers=this.markers.map((F)=>F.key===z.key?{...F,note:X.value}:F),this.paint()}),X.addEventListener("keydown",(F)=>{if(F.key!=="Enter"||!this.marking)return;F.preventDefault(),this.e.mark.focus()}),G.addEventListener("click",()=>$(z.key)),this.e.lines.append(Y),this.lines.set(z.key,{el:Y,num:J,note:X,rm:G})}for(let z of this.markers){let Q=this.lines.get(z.key);if(Q)this.e.lines.append(Q.el)}if(this.renderPins(),this.parked)this.placeCard()}renderPins(){let x=globalThis.innerWidth||800;for(let $ of this.markers){let z=this.pins.get($.key),Q=this.lines.get($.key);if(!z||!Q)continue;let Z=$.shape==="arrow"?x5($.rect,$.head??"se").tail:{x:$.rect.x,y:$.rect.y};z.el.style.left=`${Math.min(Math.max(4,Z.x-12),x-60)}px`,z.el.style.top=`${Math.max(i1-12,Z.y-12)}px`,z.num.textContent=String($.n),z.num.setAttribute("aria-label",this.s.mark($.n)),z.rm.setAttribute("aria-label",this.s.removeMark($.n)),Q.num.textContent=String($.n),Q.el.classList.toggle("hide",$.shape==="hide"),Q.note.placeholder=this.s.notePlaceholder,Q.note.setAttribute("aria-label",`${this.s.mark($.n)} — ${this.s.notePlaceholder}`),Q.rm.setAttribute("aria-label",this.s.removeMark($.n))}}envelope(x,$){let z=this.who(),Q=globalThis.location;return{title:Y8(x),description:x,env:{url:J0(Q?`${Q.origin}${Q.pathname}`:""),ua:globalThis.navigator?.userAgent??"",viewport:{w:globalThis.innerWidth||0,h:globalThis.innerHeight||0,dpr:globalThis.devicePixelRatio||1},appVersion:this.opts.appVersion??"",locale:globalThis.navigator?.language??""},console:$.console,network:$.network,...z?{identity:z,notify:this.notify}:{},markers:I6(this.markers),locale:this.locale,...this.kind?{type:this.kind}:{}}}words(){return this.e.desc.value.trim()||(this.markers.find((x)=>x.note.trim())?.note.trim()??"")}hasDraft(){return this.e.desc.value.trim()!==""||this.markers.length>0||this.kind!==null||this.files.length>0}recordWaits(){return this.sending||this.job!==null||this.hasDraft()}async send(){let x=this.words();if(this.sending||!x)return;if(this.marking)this.endMarking(!1);if(this.sending=!0,this.error="",this.paint(),this.job&&!this.job.id)this.job=null;try{if(!this.job){let $=new Set;for(let V of this.markers)for(let J of this.hideIds.get(V.key)??[])$.add(J);let z=this.engine,Q=this.frozen??{clip:null,stored:Promise.resolve(new Map)},Z=z?await J8(()=>z.build(Q,this.markers,$)):Y5;this.job=new U5(Z,globalThis.location?.host??"",{url:this.opts.base,key:this.opts.key},this.files)}this.result=await this.job.run(this.envelope(x,this.job.capture)),$8(this.opts.base,globalThis.location?.host??"",{title:Y8(x),at:Date.now(),status:this.result.status,...this.result.reportUrl?{url:this.result.reportUrl}:{}}),this.sentNotify=this.notify&&this.who()!==null,this.view="sent",this.job=null,this.frozen=null,this.e.desc.value="",this.markers=[],this.hideIds.clear(),this.kind=null,this.notify=!1,this.e.notifyBox.checked=!1,this.includedOpen=!1,this.files=[],this.fileRefusal=null,this.renderMarks(),this.renderFiles(),this.engine?.clear()}catch($){console.warn("vitrinka: the report did not go through — Retry resumes it",$),this.error=!this.job?.id?"create":this.job.filesPending?"files":"capture"}finally{this.sending=!1,this.paint()}if(this.view==="sent")requestAnimationFrame(()=>((this.result?.reportUrl)?this.e.see:this.e.sentClose).focus())}includedItems(){let x=this.s,$=[],z=this.config?.lanes;if(z?.replay)$.push(`${x.incReplay} — ${x.incReplayMasked[this.config?.masking??"strict"].toLowerCase()}`);if(z?.errors)$.push(x.incErrors);if(z?.console)$.push(x.incConsole);if(z?.network)$.push(x.incNetwork);else if(z?.errors)$.push(x.incFailedRequests);if($.push(x.incEnv),this.who())$.push(x.incIdentity);if(this.markers.length)$.push(x.incMarks);if(this.files.length)$.push(x.incFiles);return $}paintAccount(){let{e:x,s:$}=this,z=this.who(),Q=!z?null:("email"in z)?{name:z.name??"",email:z.email}:this.session?{name:this.session.reporter.name??"",email:this.session.reporter.email}:null,Z=Q?.name||Q?.email||"";x.whoAv.textContent=z?X$(Z):"?",x.whoName.textContent=Z.split(/[\s@]/)[0]??"",x.whoName.hidden=!Z,x.whoBtn.setAttribute("aria-label",`${$.account}: ${Z||(z?"":$.anonymous)}`.replace(/: $/,"")),x.whoBtn.setAttribute("aria-expanded",String(this.menu==="account")),x.more.setAttribute("aria-label",$.menu),x.more.setAttribute("aria-expanded",String(this.menu==="more")),x.accountPop.hidden=this.menu!=="account",x.morePop.hidden=this.menu!=="more",x.accountPop.setAttribute("aria-label",$.account),x.morePop.setAttribute("aria-label",$.menu),x.accName.textContent=z?Q?.name||Q?.email||"":$.anonymous,x.accMail.textContent=Q?.name?Q.email:"",x.accMail.hidden=!x.accMail.textContent,x.accVia.textContent=z&&"token"in z?$.signedInByApp:$.anonymousHint;let V=this.member;x.accLinked.hidden=!V,x.accUnlink.hidden=!V,x.accLinked.textContent=V?$.linkedAs(V.email||V.name||V.workspace):"",x.accUnlink.textContent=$.unlink,x.accLink.hidden=Boolean(V),h(x.accLink,$.linkVitrinka);let J=this.session?.portalUrl;if(x.accPortal.hidden=!J,J)x.accPortal.setAttribute("href",J);h(x.accPortal,$.openPortal),h(x.mReports,$.myReports),h(x.mRecents,$.recentRecordings),h(x.mRecord,$.record),h(x.mSettings,$.settings),x.mRecents.hidden=!this.recordSwitch,x.mRecord.hidden=!this.recordSwitch;let X=this.recordWaits();if(X)x.mRecord.setAttribute("aria-disabled","true");else x.mRecord.removeAttribute("aria-disabled");if(x.mRecordWhy.hidden=!X,x.mRecordWhy.textContent=$.recordHasDraft,X)x.mRecord.setAttribute("aria-describedby",x.mRecordWhy.id);else x.mRecord.removeAttribute("aria-describedby");let G=V?this.opts.base:J;if(x.mOpen.hidden=!G,G)x.mOpen.setAttribute("href",G);h(x.mOpen,V?$.openVitrinka:$.openPortal)}paintReports(){let{e:x,s:$}=this;h(x.repBack,$.myReports);let z=!this.session,Q=z?G5(this.opts.base,globalThis.location?.host??"").map((J)=>this.row(J.title,J.status==="quarantined"?$.waiting:$.steps.received??"",J.at,J.url)):this.mine.rows.map((J)=>this.row(J.title,$.steps[J.step]??J.step,Date.parse(J.updatedAt),J.url));x.repRows.replaceChildren(...Q);let Z=z?"ok":this.mine.state;x.repStatus.hidden=Z==="ok"&&Q.length>0,x.repStatus.textContent=Z==="loading"?$.loading:Z==="failed"?$.listFailed:$.noReports,x.repLocal.hidden=!z||Q.length===0,x.repLocal.textContent=$.fromThisBrowser;let V=this.session?.portalUrl;if(x.repPortal.hidden=!V,V)x.repPortal.setAttribute("href",V);x.repPortal.textContent=$.openPortal}paintRecents(){let{e:x,s:$}=this;h(x.recBack,$.recentRecordings);let z=p3().map((Q)=>this.row(Q.title,"",Q.startedAt,Q.boardUrl));x.recRows.replaceChildren(...z),x.recStatus.hidden=z.length>0,x.recStatus.textContent=$.noRecordings}paintLink(){let{e:x,s:$}=this,z=this.linkFlow;h(x.linkBack,$.linkVitrinka),x.linkLabel.textContent=$.linkCode,x.linkCode.textContent=z?.start?.user_code??"…",x.linkOpenText.textContent=$.openVitrinka;let Q=z?.start;if(x.linkOpen.hidden=!Q,Q)x.linkOpen.setAttribute("href",Q.verifyUrl);let Z=globalThis.matchMedia?.("(pointer: fine)").matches??!0;if(x.linkQr.hidden=!Q||!Z,Q&&Z&&x.linkQr.getAttribute("src")!==Q.qrUrl)x.linkQr.setAttribute("src",Q.qrUrl);x.linkHint.textContent=$.linkHint;let V=z?.state??"failed";x.linkWait.textContent=V==="expired"?$.linkExpired:V==="failed"?$.linkFailed:V==="waiting"?$.linkWaiting:$.loading,x.linkRetry.hidden=V!=="expired"&&V!=="failed",x.linkRetry.textContent=$.retry}paintFiles(){let{e:x,s:$}=this,z=this.sending||Boolean(this.job?.id);x.attach.setAttribute("aria-label",$.attach),x.attach.disabled=z,x.attach.hidden=this.caps().maxCount===0,x.fileInput.setAttribute("accept",this.caps().types.join(",")),x.tray.hidden=this.view!=="describe"||this.files.length===0&&!this.fileRefusal,x.files.hidden=this.files.length===0,x.files.setAttribute("aria-label",$.incFiles),x.fileNote.hidden=!this.fileRefusal,x.fileNote.textContent=this.refusalText(this.fileRefusal);for(let[Q,Z]of this.chips)Z.size.textContent=a0(Q.size,this.locale),Z.rm.setAttribute("aria-label",$.removeFile(Q.name)),Z.rm.disabled=z}paintSettings(){let{e:x,s:$}=this;x.sizeLabel.textContent=$.size;for(let[z,Q]of x.sizeButtons)Q.textContent=$.sizes[z],Q.setAttribute("aria-checked",String(this.size===z));if(x.techText.textContent=$.techDetails,x.techBtn.setAttribute("aria-expanded",String(this.techOpen)),x.tech.hidden=!this.techOpen,this.techOpen&&this.view==="settings"){let z=z6({version:C3,base:this.opts.base,config:this.config,engine:this.engine!==null,locale:this.locale},$);x.tech.replaceChildren(...z.flatMap(([Q,Z])=>[j("dt",{},Q),j("dd",{},Z)]))}if(this.view==="settings")U8(x.sizeSeg,x.sizeInd,x.sizeButtons.get(this.size))}paint(){let{e:x,s:$}=this,z=this.who();if(x.root.setAttribute("lang",this.locale),x.root.classList.toggle("nobutton",!this.button),x.root.dataset.dock=this.dock,x.root.style.setProperty("--vr-scale",String(T1[this.size])),x.fab.hidden=!this.button||this.marking,x.fabLabel.textContent=$.button,x.fab.setAttribute("aria-expanded",String(this.isOpen)),x.fab.setAttribute("aria-description",$.moveHint),x.fab.setAttribute("aria-keyshortcuts","Alt+ArrowUp Alt+ArrowDown Alt+ArrowLeft Alt+ArrowRight"),x.fabKbd.hidden=!this.keybind,x.fabKbd.textContent=this.keybind?d1(this.keybind):"",x.card.hidden=!this.isOpen,x.card.classList.toggle("busy",this.sending),x.title.textContent=$.title,x.closeBtn.setAttribute("aria-label",$.close),this.paintAccount(),x.describe.hidden=this.view!=="describe",x.settings.hidden=this.view!=="settings",x.sent.hidden=this.view!=="sent",x.reports.hidden=this.view!=="reports",x.recents.hidden=this.view!=="recents",x.linking.hidden=this.view!=="link",this.view==="reports")this.paintReports();if(this.view==="recents")this.paintRecents();if(this.view==="link")this.paintLink();x.foot.hidden=this.view!=="describe",this.paintFiles(),x.kindsLabel.textContent=$.kindsLabel;for(let[Z,V]of x.kindButtons)V.textContent=$.kinds[Z],V.setAttribute("aria-checked",String(this.kind===Z)),V.disabled=this.sending||Boolean(this.job?.id);x.prompt.textContent=$.prompt,x.desc.placeholder=$.placeholder,x.attachedText.textContent=$.attached(this.config?.profile.windowSec??60),x.attached.hidden=this.engine===null||this.config?.capturing===!1,x.discloseText.textContent=$.included,x.disclose.setAttribute("aria-expanded",String(this.includedOpen)),x.included.hidden=!this.includedOpen,x.included.replaceChildren(...this.includedItems().map((Z)=>j("li",{},Z))),x.desc.disabled=this.sending,x.lines.hidden=this.markers.length===0,x.linesEmpty.hidden=!this.marking||this.markers.length>0,x.linesEmpty.textContent=$.linesEmpty;for(let Z of this.lines.values())Z.note.disabled=this.sending,Z.rm.disabled=this.sending;x.notify.hidden=z===null,x.notifyText.textContent=$.notify,x.error.hidden=this.error==="",x.error.textContent={"":"",create:$.errorCreate,files:$.errorFiles,capture:$.errorCapture}[this.error],x.whereText.textContent=$.showWhere,x.where.setAttribute("aria-pressed",String(this.marking)),x.where.disabled=this.sending||Boolean(this.job?.id),x.send.textContent=this.sending?$.sending:this.error?$.retry:$.send,x.send.disabled=this.sending||this.words()==="",x.bindLabel.textContent=$.shortcut,x.bindBtn.setAttribute("aria-pressed",String(this.recordingBind)),x.bindBtn.setAttribute("aria-label",`${$.shortcut}: ${this.keybind?d1(this.keybind):$.notSet} — ${$.recordShortcut}`),x.bindBtn.textContent=this.recordingBind?$.pressKeys:this.keybind?d1(this.keybind):$.notSet,x.unbind.textContent=$.removeShortcut,x.unbind.hidden=!this.keybind||this.recordingBind,x.bindHint.textContent=$.shortcutHint,x.bindReason.hidden=!this.bindRefused,x.bindReason.textContent=this.bindRefused?$.needModifier:"",x.back.textContent=$.back,this.paintSettings(),x.sentTitle.textContent=$.sentTitle,x.sentBody.textContent=this.result?.status==="quarantined"?$.sentQueued:this.sentNotify?$.sentNotify:$.sentBody,x.seeText.textContent=$.seeReport;let Q=this.result?.reportUrl;if(x.see.hidden=!Q,Q)x.see.setAttribute("href",Q);else x.see.removeAttribute("href");x.sentClose.textContent=$.close,x.mark.hidden=!this.marking,x.toolbar.setAttribute("aria-label",$.toolbar),x.seg.setAttribute("aria-label",$.toolbar),x.barLead.textContent=$.barLead;for(let[Z,V]of x.toolButtons){let J=x.toolLabels.get(Z);if(J)J.textContent=$.tools[Z];V.setAttribute("aria-checked",String(this.tool===Z))}if(x.cancel.textContent=$.cancelMarking,x.cancel.hidden=this.confirming,x.ask.hidden=!this.confirming,x.askText.textContent=$.discardMarks(this.markers.filter((Z)=>!this.passKeys.has(Z.key)).length),x.discard.textContent=$.discard,x.keep.textContent=$.keep,x.coach.hidden=!this.marking||this.markers.length>0,x.coachText.textContent=$.coach,x.coachMore.textContent=$.coachMore,x.coachKeys.textContent=$.keyboardHint,x.mark.setAttribute("aria-label",$.marking),this.marking){for(let Z of x.shapes.querySelectorAll(".veil-label"))if(Z.textContent)Z.textContent=$.hidden}this.renderPins()}}function l1(x){return A6(x).map(($,z)=>({...$,key:x[z].key}))}var o1="vitrinka-report",Y$=["key","base","open-selector","locale","button"];function F8(x){return x.trim().replace(/\/+$/,"")}function D5(x){if(typeof customElements>"u"||customElements.get(o1))return;class $ extends HTMLElement{static get observedAttributes(){return Y$}options={};at=null;shown=null;widget=null;pill=null;gen=0;recordOffered=!1;offPillOpener=null;warnedRecording=!1;offLink=null;pendingIdentity=void 0;get face(){return this.shown??"report"}connectedCallback(){this.hidden=!0,this.mount()}disconnectedCallback(){this.unmount()}attributeChangedCallback(z,Q,Z){if(Q===Z)return;if(!this.at){if(this.isConnected&&(z==="key"||z==="base"))this.mount();return}if(z==="key"||z==="base"){this.unmount(),this.mount();return}if(!this.widget)return;if(z==="locale")this.widget.setLocale(Z);else if(z==="button")this.widget.setButton(Z!=="false");else if(z==="open-selector")this.widget.setOpenSelector(Z)}open(){if(this.shown==="recorder")this.openFromPill();else this.widget?.open()}close(){this.widget?.close()}identify(z){this.pendingIdentity=z,this.widget?.identify(z)}setLocale(z){this.setAttribute("locale",String(z))}mount(){if(this.at)return;let z=(this.getAttribute("key")??"").trim(),Q=F8(this.getAttribute("base")??x.defaultBase());if(!z||!Q){console.warn(`vitrinka: <${o1}> needs a key${Q?"":" and a base"} — nothing mounted`);return}if(this.at={key:z,base:Q},x.recorderFace)this.offLink=k3(()=>this.offerRecord());this.show(x.recorderFace?f3(Q):"report")}unmount(){this.offLink?.(),this.offLink=null,this.takeDown(),this.at=null,this.shown=null}takeDown(){this.gen++,this.widget?.unmount(),this.widget=null,this.recordOffered=!1,this.offPillOpener?.(),this.offPillOpener=null,this.pill?.(),this.pill=null}show(z){let Q=this.at;if(!Q)return;this.takeDown();let Z=x.recorderFace;if(z==="recorder"&&Z){this.shown="recorder",this.offPillOpener=R(document,"click",(J)=>{if(!M5(J,this.getAttribute("open-selector")))return;J.preventDefault(),this.open()});let V=this.gen;Z().then((J)=>{if(V!==this.gen)return;this.pill=J({base:Q.base,appVersion:this.options.appVersion,sanitizeUrl:this.options.sanitizeUrl,onReportFace:()=>this.switchTo("report")})}).catch((J)=>{if(console.warn("vitrinka: the recorder face did not load — showing Report a problem",J),V===this.gen)this.show("report")});return}this.shown="report",this.widget=new K5({base:Q.base,key:Q.key,locale:o0(this.getAttribute("locale")),button:this.getAttribute("button")!=="false",openSelector:this.getAttribute("open-selector"),identity:this.pendingIdentity,appVersion:this.options.appVersion,capture:this.options.capture,sanitizeUrl:this.options.sanitizeUrl,loadRecord:x.loadRecord}),this.offerRecord()}offerRecord(){if(!this.widget||!this.at)return;let z=x.recorderFace!==null&&l0(this.at.base);if(z===this.recordOffered)return;this.recordOffered=z,this.widget.setRecordSwitch(z?()=>this.switchTo("recorder"):null)}openFromPill(){if(this.keepsPill())return;let z=this.at;setTimeout(()=>{if(!z||this.at!==z)return;if(this.shown==="recorder"){if(this.keepsPill())return;w2("report"),this.show("report")}this.widget?.open()},0)}keepsPill(){if(!w3())return!1;if(!this.warnedRecording)console.warn("vitrinka: Report a problem stays closed while the recorder pill records — leaving would strand the session; stop the recording first");return this.warnedRecording=!0,!0}switchTo(z){w2(z);let Q=this.gen;setTimeout(()=>{if(Q===this.gen&&this.shown!==z)this.show(z)},0)}}customElements.define(o1,$)}function q8(x,$){if(x.face==="recorder")return U$(x,$);D5($);let z=document.createElement(o1);if(z.setAttribute("key",x.key),x.base)z.setAttribute("base",x.base);if(x.locale)z.setAttribute("locale",String(x.locale));if(x.button===!1)z.setAttribute("button","false");if(x.openSelector)z.setAttribute("open-selector",x.openSelector);if(z.options={appVersion:x.appVersion,capture:x.capture,sanitizeUrl:x.sanitizeUrl},x.identity!==void 0)z.identify(x.identity);return(x.parent??document.body).append(z),{get face(){return z.face},open:()=>z.open(),close:()=>z.close(),identify:(Q)=>z.identify(Q),setLocale:(Q)=>z.setLocale(Q),unmount:()=>z.remove()}}function U$(x,$){let z=F8(x.base??$.defaultBase()),Q=null,Z=!1;if(!$.recorderFace)console.warn("vitrinka: the recorder face needs the npm package (@vitrinka/web/report) — nothing mounted");else $.recorderFace().then((J)=>{if(!Z)Q=J({base:z,key:x.key,appVersion:x.appVersion,sanitizeUrl:x.sanitizeUrl})}).catch((J)=>console.warn("vitrinka: the recorder face did not load",J));let V=()=>{return};return{face:"recorder",open:V,close:V,identify:V,setLocale:V,unmount:()=>{Z=!0,Q?.()}}}var W$=(()=>{try{return new URL(import.meta.url).origin}catch{return""}})();async function F$(x){let z=await import(`${x}/vendor/rrweb-record-1.min.js`)??{},Q=typeof z.default==="object"&&z.default!==null?z.default.record:void 0,Z=typeof z.default==="function"?z.default:Q??z.record;return typeof Z==="function"?Z:null}var M8={loadRecord:F$,recorderFace:null,defaultBase:()=>W$};D5(M8);function sQ(x){return q8(x,M8)}export{sQ as mountReport,r7 as identify};
|
|
416
|
+
`;var M8={ms:30000,bytesPerMs:32};class K8 extends Error{constructor(x,$){super(`vitrinka: ${x} got no answer in ${Math.round($/1000)} s — Try again resumes it`);this.name="LegTimeout"}}async function j5(x,$,z){let Q=new AbortController,Z,J=new Promise((V,X)=>{Z=setTimeout(()=>{let G=new K8(x,$);Q.abort(G),X(G)},$)});try{return await Promise.race([z(Q.signal),J])}finally{clearTimeout(Z)}}var Y5={chunks:[],truncated:!1,console:[],network:[]};function D8(x,$=M8.ms){return j5("preparing the capture",$,x).catch((z)=>{return console.warn("vitrinka: the capture could not be prepared — the report goes without it",z),Y5})}class W5{capture;tabHost;target;files;limits;id="";custody="";sent="";blobKeys=new Map;rowsPosted=0;skipCapture=!1;filesDone=new Set;constructor(x,$,z,Q=[],Z=M8){this.capture=x;this.tabHost=$;this.target=z;this.files=Q;this.limits=Z}call(x,$,z){return j5(`${x} ${$}`,this.limits.ms,(Q)=>n(x,$,z,{target:this.target,signal:Q}))}upload(x,$,z){let Q=typeof z==="string"?new TextEncoder().encode(z).byteLength:z.size,Z=this.limits.ms+Math.ceil(Q/this.limits.bytesPerMs);return j5(`POST ${x}`,Z,(J)=>V2(x,$,z,this.target,J))}get filesPending(){return this.filesDone.size<this.files.length}async run(x){let $={title:x.title,description:x.description,markers:x.markers,notify:x.notify??!1},z=JSON.stringify($);if(!this.id){let Z=await this.call("POST","/api/v1/reports",x).catch((J)=>{if(x.type===void 0||!(J instanceof L)||J.status!==400||!/\btype\b/.test(J.message))throw J;console.warn("vitrinka: this server takes no report type yet — sending the report without it");let{type:V,...X}=x;return this.call("POST","/api/v1/reports",X)});if(typeof Z.id!=="string"||!Z.id)throw Error("vitrinka: the server filed the report without an id");this.id=Z.id,this.custody=Z.custody==="direct"?"direct":"quarantined",this.sent=z}else if(this.sent!==z)await this.call("PATCH",`/api/v1/reports/${encodeURIComponent(this.id)}`,$),this.sent=z;if(await this.sendFiles(),!this.skipCapture)try{await this.sendCapture()}catch(Z){if(!(Z instanceof L)||!m(Z.status))throw Z;console.warn("vitrinka: the server refused the recording — the report goes without it",Z),this.skipCapture=!0}let Q=await this.call("POST",`/api/v1/reports/${encodeURIComponent(this.id)}/submit`,{});return{status:Q.status==="filed"?"filed":"quarantined",...typeof Q.reportUrl==="string"&&Q.reportUrl?{reportUrl:Q.reportUrl}:{}}}async sendFiles(){let x=encodeURIComponent(this.id);for(let[$,z]of this.files.entries()){if(this.filesDone.has($))continue;try{await this.upload(`/api/v1/reports/${x}/attachment?name=${encodeURIComponent(z.name)}`,z.type||"application/octet-stream",z)}catch(Q){if(!(Q instanceof L)||!m(Q.status))throw Q;console.warn(`vitrinka: the server refused ${z.name} — the report goes without it`,Q)}this.filesDone.add($)}}async sendCapture(){let x=encodeURIComponent(this.id),{chunks:$,truncated:z}=this.capture;for(let Z of $){if(this.blobKeys.has(Z.seq))continue;let J=await this.upload(`/api/v1/reports/${x}/chunk?seq=${Z.seq}`,"application/json",Z.body);if(!J.blobKey)throw Error(`vitrinka: chunk ${Z.seq} came back without a blob key`);this.blobKeys.set(Z.seq,J.blobKey)}let Q=$.map((Z)=>({seq:Z.seq,ts:Z.ts,tabHost:this.tabHost,kind:"rrweb",payload:{count:Z.count,source:"replay",truncated:z},blobKey:this.blobKeys.get(Z.seq)??""}));while(this.rowsPosted<Q.length){let Z=Q.slice(this.rowsPosted,this.rowsPosted+R1);await this.call("POST",`/api/v1/reports/${x}/events`,{events:Z}),this.rowsPosted+=Z.length}}}var P$="http://www.w3.org/2000/svg",P8=100,_8=["box","circle","arrow","hide"],U5={w:160,h:80},H8=16,N8={w:380,h:460},F5=72,q5={w:300,h:160,gap:10},M5=16,H$={ArrowLeft:[-10,0],ArrowRight:[10,0],ArrowUp:[0,-10],ArrowDown:[0,10]},O={close:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 4l8 8M12 4l-8 8" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>',gear:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M6.9 1.5h2.2l.35 1.75a5 5 0 011.3.75l1.7-.57 1.1 1.9-1.35 1.18a5 5 0 010 1.5l1.35 1.18-1.1 1.9-1.7-.57a5 5 0 01-1.3.75L9.1 14.5H6.9l-.35-1.75a5 5 0 01-1.3-.75l-1.7.57-1.1-1.9 1.35-1.18a5 5 0 010-1.5L2.45 6.81l1.1-1.9 1.7.57a5 5 0 011.3-.75z" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round"/><circle cx="8" cy="8" r="2" fill="none" stroke="currentColor" stroke-width="1.3"/></svg>',circle:'<svg viewBox="0 0 16 16" aria-hidden="true"><ellipse cx="8" cy="8" rx="6" ry="4.6" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>',box:'<svg viewBox="0 0 16 16" aria-hidden="true"><rect x="2.2" y="3.4" width="11.6" height="9.2" rx="1.8" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>',arrow:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3 13L12.5 3.5M7 3.5h5.5V9" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>',hide:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M2 8s2.3-4 6-4 6 4 6 4-2.3 4-6 4-6-4-6-4z" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linejoin="round"/><path d="M3 13L13 3" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg>',dots:'<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="3.5" cy="8" r="1.3" fill="currentColor"/><circle cx="8" cy="8" r="1.3" fill="currentColor"/><circle cx="12.5" cy="8" r="1.3" fill="currentColor"/></svg>',left:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M10 3.5L5.5 8l4.5 4.5" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>',ext:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M9 3h4v4M13 3L7.5 8.5M11 9.5V13H3V5h3.5" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/></svg>',list:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M5.5 4h8M5.5 8h8M5.5 12h8M2.5 4h.01M2.5 8h.01M2.5 12h.01" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>',clock:'<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="6" fill="none" stroke="currentColor" stroke-width="1.4"/><path d="M8 4.8V8l2.2 1.6" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg>',rec:'<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="6" fill="none" stroke="currentColor" stroke-width="1.4"/><circle cx="8" cy="8" r="2.8" fill="currentColor"/></svg>',link:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M7 9a3 3 0 004.2 0l2-2a3 3 0 00-4.2-4.2l-.8.8M9 7a3 3 0 00-4.2 0l-2 2a3 3 0 004.2 4.2l.8-.8" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg>',clip:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M10.5 4.5l-5 5a1.6 1.6 0 002.3 2.3l5.4-5.4a3 3 0 00-4.2-4.2L3.6 7.6a4.4 4.4 0 006.2 6.2l4-4" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"/></svg>',chevron:'<svg viewBox="0 0 12 12" aria-hidden="true"><path d="M3 4.5l3 3 3-3" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>',pen:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M10.8 2.7l2.5 2.5-7.6 7.6-3.1 0.6 0.6-3.1z" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linejoin="round"/></svg>',check:'<svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="10" fill="none" stroke="currentColor" stroke-width="1.8"/><path d="M7.5 12.3l3 3 6-6.3" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>'},I8="0;0.18;0.72;1",X1="2.8s",B8="M 134 14 C 200 14, 214 50, 134 50 C 54 50, 68 14, 134 14",N$='<path d="M0 0 L0 15 L4 11 L7 18 L10 16.6 L7 10 L12.5 10 Z" fill="#fff" stroke="#151417" stroke-width="1"/>';function B$(x,$,z){return`<animate attributeName="${x}" values="${$};${$};${z};${z}" keyTimes="${I8}" calcMode="linear" dur="${X1}" repeatCount="indefinite"/>`}function g$(x,$){let z=(U,q)=>$?q:U,Q=(U,q,W)=>$?"":B$(U,q,W),Z=$?"":`<animate attributeName="opacity" values="1;1;0" keyTimes="0;0.9;1" dur="${X1}" repeatCount="indefinite"/>`,J=$?"":`<animate attributeName="opacity" values="0;0;.9;.9;0;0" keyTimes="0;0.08;0.14;0.72;0.8;1" dur="${X1}" repeatCount="indefinite"/>`,V,X,G;if(x==="circle")X=B8,G={x:134,y:14},V=`<rect class="bar" x="84" y="27" width="100" height="10" rx="5"/><path class="loop" d="${B8}" pathLength="200" stroke-dasharray="200" stroke-dashoffset="${z(200,0)}">${Q("stroke-dashoffset",200,0)}${Z}</path>`;else if(x==="arrow"){X="M 74 54 L 128 33",G={x:128,y:33};let U=$?"":`<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.18;0.19;0.9;1" dur="${X1}" repeatCount="indefinite"/>`;V=`<defs><marker id="vr-coach-head" viewBox="0 0 10 10" refX="7" refY="5" markerWidth="5" markerHeight="5" orient="auto-start-reverse"><path d="M0 0L10 5L0 10z" fill="#e6455f"/></marker></defs><rect class="bar" x="136" y="27" width="70" height="10" rx="5"/><line class="loop" x1="74" y1="54" x2="${z(74,128)}" y2="${z(54,33)}" marker-end="url(#vr-coach-head)"${$?"":' opacity="0"'}>${Q("x2",74,128)}${Q("y2",54,33)}${U}</line>`}else{let U=x==="hide";X=U?"M 90 10 L 178 54":"M 96 12 L 172 52",G=U?{x:178,y:54}:{x:172,y:52};let q=U?90:96,W=U?10:12,F=G.x-q,M=G.y-W;V=(U?'<rect class="bar" x="102" y="20" width="64" height="8" rx="4"/><rect class="bar" x="102" y="35" width="44" height="8" rx="4"/>':'<rect class="bar" x="110" y="27" width="48" height="10" rx="5"/>')+`<rect class="${U?"veil":"loop"}" x="${q}" y="${W}" width="${z(0,F)}" height="${z(0,M)}" rx="${U?4:6}">${Q("width",0,F)}${Q("height",0,M)}${Z}</rect>`}let Y=$?"":`<animateMotion dur="${X1}" repeatCount="indefinite" keyPoints="0;0;1;1" keyTimes="${I8}" calcMode="linear" path="${X}"/>`;return`<svg viewBox="0 0 268 64" aria-hidden="true" data-shape="${x}">${V}<g class="pointer"${$?` transform="translate(${G.x} ${G.y})"`:""}><circle class="hold" r="9"${$?' opacity=".9"':' opacity="0"'}>${J}</circle>${N$}${Y}</g></svg>`}function j(x,$={},...z){let Q=document.createElement(x);for(let[Z,J]of Object.entries($))Q.setAttribute(Z,J);return Q.append(...z),Q}function _(x){let $=document.createElement("template");$.innerHTML=x;let z=$.content.firstElementChild;if(!z)throw Error("vitrinka: icon markup is empty");return z}function p(x,$){let z=document.createElementNS(P$,x);for(let[Q,Z]of Object.entries($))z.setAttribute(Q,String(Z));return z}function g8(x){let $=x.split(`
|
|
417
|
+
`)[0]?.trim()??"";return $.length>P8?`${$.slice(0,P8-1)}…`:$}function O8(){return globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1}function K5(){let x=document.activeElement;while(x?.shadowRoot?.activeElement)x=x.shadowRoot.activeElement;if(x===document.body)return null;return x instanceof HTMLElement||x instanceof SVGElement?x:null}function O$(x){return(x.split("@")[0]?.split(/[\s._-]+/).filter(Boolean)??[]).slice(0,2).map((z)=>z[0]?.toUpperCase()??"").join("")||"?"}function h(x,$){let z=x.querySelector("span");if(z)z.textContent=$}function L8(x,$,z,Q=!1){if(!z||!z.offsetWidth)return;let Z=Q||!x.classList.contains("measured");if(Z)$.style.transition="none";if($.style.width=`${z.offsetWidth}px`,$.style.transform=`translateX(${z.offsetLeft}px)`,x.classList.add("measured"),!Z)return;$.offsetWidth,$.style.removeProperty("transition")}function L$(){let x=K5();return x instanceof HTMLInputElement||x instanceof HTMLTextAreaElement||x instanceof HTMLElement&&x.isContentEditable}function D5(x,$){let z=x.target;if(!$||!(z instanceof Element))return!1;try{return z.closest($)!==null}catch{return!1}}function _$(x){let $=j("span"),z=j("kbd",{"aria-hidden":"true"}),Q=j("button",{class:"fab",type:"button",part:"button","aria-haspopup":"dialog"},$,z),Z=j("h2",{id:"vr-title"}),J=j("span",{class:"av","aria-hidden":"true"}),V=j("span",{class:"who-name"}),X=j("button",{class:"who",type:"button","aria-haspopup":"dialog","aria-expanded":"false"},J,V),G=j("button",{class:"icon",type:"button","aria-haspopup":"menu","aria-expanded":"false"},_(O.dots)),Y=j("button",{class:"icon",type:"button"},_(O.close)),U=j("header",{class:"head"},Z,X,G,Y),q=j("strong"),W=j("span",{class:"acc-mail"}),F=j("p",{class:"acc-via"}),M=j("p",{class:"acc-linked"}),P=j("button",{class:"link",type:"button"}),D=j("button",{class:"pop-item",type:"button"},_(O.link),j("span")),H=j("a",{class:"pop-item",target:"_blank",rel:"noopener noreferrer"},_(O.ext),j("span")),B=j("div",{class:"pop acc",role:"dialog"},j("div",{class:"acc-who"},q,W,F),j("div",{class:"acc-member"},M,P),D,H),K=(b)=>j("button",{class:"pop-item",type:"button",role:"menuitem"},_(b),j("span")),R=K(O.list),b0=K(O.clock),E0=K(O.rec),G1=j("small",{class:"pop-why",id:"vr-record-why","aria-hidden":"true"});E0.append(G1);let w0=K(O.gear),N5=j("a",{class:"pop-item",role:"menuitem",target:"_blank",rel:"noopener noreferrer"},_(O.ext),j("span")),B5=j("div",{class:"pop more",role:"menu"},R,b0,E0,w0,N5),g5=j("span",{class:"sr",id:"vr-kinds"}),n1=new Map;for(let b of c3)n1.set(b,j("button",{type:"button",role:"radio","aria-checked":"false","data-kind":b}));let O5=j("div",{class:"kinds",role:"radiogroup","aria-labelledby":"vr-kinds"},g5,...n1.values()),L5=j("label",{class:"prompt",for:"vr-desc"}),_5=j("textarea",{class:"desc",id:"vr-desc",rows:"3"}),I5=j("ol",{class:"lines"}),A5=j("p",{class:"ln-empty"}),R5=j("span"),C5=j("span"),S5=j("button",{class:"link",type:"button","aria-expanded":"false","aria-controls":"vr-included"},C5,_(O.chevron)),T5=j("div",{class:"attached"},_(O.clip),R5,j("span",{"aria-hidden":"true"},"·"),S5),b5=j("ul",{class:"included",id:"vr-included"}),E5=j("input",{type:"checkbox"}),w5=j("span"),f5=j("label",{class:"notify"},E5,w5),k5=j("p",{class:"error",role:"alert"}),y5=j("span"),p5=j("button",{class:"where",type:"button","aria-pressed":"false"},_(O.pen),y5),v5=j("button",{class:"send",type:"button"}),h5=j("div",{class:"pane describe"},O5,L5,_5,j("div",{class:"lines-wrap"},I5,A5),T5,b5,f5,k5),m5=j("button",{class:"icon",type:"button"},_(O.clip)),u5=j("input",{type:"file",multiple:"",tabindex:"-1","aria-hidden":"true",hidden:""}),d5=j("p",{class:"file-note",role:"status"}),c5=j("ul",{class:"files"}),i5=j("div",{class:"tray"},d5,c5),l5=j("div",{class:"foot"},m5,u5,p5,v5),o5=j("span",{class:"label",id:"vr-bind-label"}),n5=j("button",{class:"bind",type:"button","aria-pressed":"false","aria-describedby":"vr-bind-label"}),a5=j("button",{class:"link",type:"button"}),r5=j("p",{class:"hint"}),t5=j("p",{class:"reason",role:"status"}),s5=j("button",{class:"link",type:"button"}),e5=j("span",{class:"label",id:"vr-size-label"}),a1=new Map;for(let b of p2)a1.set(b,j("button",{type:"button",role:"radio","aria-checked":"false","data-size":b}));let xx=j("span",{class:"seg-ind","aria-hidden":"true"}),$x=j("div",{class:"seg",role:"radiogroup","aria-labelledby":"vr-size-label"},xx,...a1.values()),zx=j("span",{class:"label",id:"vr-coach-label"}),Qx=j("button",{class:"switch",type:"button",role:"switch","aria-checked":"true","aria-labelledby":"vr-coach-label"},j("span",{class:"knob","aria-hidden":"true"})),Zx=j("span"),Jx=j("button",{class:"link",type:"button","aria-expanded":"false","aria-controls":"vr-tech"},Zx,_(O.chevron)),Vx=j("dl",{class:"tech",id:"vr-tech"}),Xx=j("div",{class:"pane settings"},j("div",{class:"row"},o5,n5),t5,r5,j("div",{class:"row size-row"},e5,$x),j("div",{class:"row tips-row"},zx,Qx),j("div",{class:"tech-wrap"},Jx,Vx),j("div",{class:"settings-foot"},s5,a5)),Gx=j("h3"),jx=j("p",{class:"sent-body"}),Yx=j("span"),Wx=j("a",{class:"see",target:"_blank",rel:"noopener noreferrer"},Yx),Ux=j("button",{class:"link",type:"button"}),Fx=j("div",{class:"pane sent",role:"status"},j("div",{class:"sent-head"},_(O.check),Gx),jx,j("div",{class:"sent-actions"},Wx,Ux)),r1=()=>j("button",{class:"back",type:"button"},_(O.left),j("span")),qx=r1(),Mx=j("p",{class:"list-status"}),Kx=j("ul",{class:"rows"}),Dx=j("p",{class:"list-note"}),Px=j("a",{class:"link",target:"_blank",rel:"noopener noreferrer"}),Hx=j("div",{class:"pane list"},qx,Mx,Kx,Dx,Px),Nx=r1(),Bx=j("p",{class:"list-status"}),gx=j("ul",{class:"rows"}),Ox=j("div",{class:"pane list"},Nx,Bx,gx),Lx=r1(),_x=j("p",{class:"list-note"}),Ix=j("div",{class:"code"}),Ax=j("span"),Rx=j("a",{class:"see",target:"_blank",rel:"noopener noreferrer"},Ax),Cx=j("img",{class:"qr",alt:""}),Sx=j("p",{class:"hint"}),Tx=j("p",{class:"list-status",role:"status"}),bx=j("button",{class:"link",type:"button"}),Ex=j("div",{class:"pane linking"},Lx,_x,Ix,j("div",{class:"link-go"},Rx,Cx),Sx,Tx,bx),wx=j("div",{class:"coach-art"}),fx=j("p"),kx=j("p"),yx=j("button",{class:"coach-ok",type:"button"}),px=j("div",{class:"coach",role:"status"},wx,fx,kx,yx),vx=j("p",{class:"sr-only",id:"vr-keys"}),hx=j("div",{class:"body"},h5,Xx,Fx,Hx,Ox,Ex),mx=j("section",{class:"card",role:"dialog","aria-modal":"false","aria-labelledby":"vr-title"},U,B,B5,hx,i5,l5,px),t1=p("svg",{class:"ink","aria-hidden":"true"}),ux=p("defs",{}),dx=p("marker",{id:"vr-head",viewBox:"0 0 10 10",refX:7,refY:5,markerWidth:5,markerHeight:5,orient:"auto-start-reverse"});dx.append(p("path",{d:"M0 0L10 5L0 10z",fill:"#dc2f4c"})),ux.append(dx);let cx=p("g",{}),ix=p("g",{class:"draft"});t1.append(ux,cx,ix);let lx=j("div",{class:"pins"}),s1=new Map,ox=new Map;for(let b of _8){let Z4=j("span");ox.set(b,Z4),s1.set(b,j("button",{type:"button",role:"radio","aria-checked":"false","data-tool":b},_(O[b]),Z4))}let nx=j("span",{class:"seg-ind","aria-hidden":"true"}),ax=j("div",{class:"seg",role:"radiogroup"},nx,...s1.values()),rx=j("span",{class:"tb-lead"}),tx=j("button",{type:"button",class:"tb-quiet"}),sx=j("span",{class:"tb-ask"}),ex=j("button",{type:"button",class:"tb-discard"}),x4=j("button",{type:"button",class:"tb-quiet"}),$4=j("span",{class:"tb-confirm",role:"group"},sx,ex,x4),z4=j("div",{class:"tb",role:"toolbar"},rx,ax,j("span",{class:"tb-sep","aria-hidden":"true"}),tx,$4),e1=j("div",{class:"mark",tabindex:"0",role:"application","aria-describedby":"vr-keys"},lx,vx,z4);e1.prepend(t1);let x2=j("div",{class:"vr"},Q,e1,mx),Q4=j("style");return Q4.textContent=q8,x2.prepend(Q4),x.append(x2),{root:x2,fab:Q,fabLabel:$,fabKbd:z,card:mx,head:U,title:Z,whoBtn:X,whoAv:J,whoName:V,more:G,closeBtn:Y,body:hx,foot:l5,accountPop:B,accName:q,accMail:W,accVia:F,accLinked:M,accUnlink:P,accLink:D,accPortal:H,morePop:B5,mReports:R,mRecents:b0,mRecord:E0,mRecordWhy:G1,mSettings:w0,mOpen:N5,reports:Hx,repBack:qx,repStatus:Mx,repRows:Kx,repLocal:Dx,repPortal:Px,recents:Ox,recBack:Nx,recStatus:Bx,recRows:gx,linking:Ex,linkBack:Lx,linkLabel:_x,linkCode:Ix,linkOpen:Rx,linkOpenText:Ax,linkQr:Cx,linkHint:Sx,linkWait:Tx,linkRetry:bx,describe:h5,kinds:O5,kindsLabel:g5,kindButtons:n1,prompt:L5,desc:_5,lines:I5,linesEmpty:A5,attached:T5,attachedText:R5,disclose:S5,discloseText:C5,included:b5,notify:f5,notifyBox:E5,notifyText:w5,error:k5,where:p5,whereText:y5,send:v5,attach:m5,fileInput:u5,fileNote:d5,files:c5,tray:i5,settings:Xx,bindLabel:o5,bindBtn:n5,unbind:a5,bindHint:r5,bindReason:t5,back:s5,sizeLabel:e5,sizeButtons:a1,sizeInd:xx,sizeSeg:$x,coachLabel:zx,coachSwitch:Qx,techText:Zx,techBtn:Jx,tech:Vx,sent:Fx,sentTitle:Gx,sentBody:jx,see:Wx,seeText:Yx,sentClose:Ux,mark:e1,ink:t1,shapes:cx,draft:ix,pins:lx,coach:px,coachArtSlot:wx,coachText:fx,coachMore:kx,coachDismiss:yx,coachKeys:vx,toolbar:z4,barLead:rx,seg:ax,segInd:nx,toolButtons:s1,toolLabels:ox,cancel:tx,ask:$4,askText:sx,discard:ex,keep:x4}}class P5{opts;hud;engine;config=null;locale;s;button;openSelector;identity;keybind;isOpen=!1;opener=null;view="describe";marking=!1;markers=[];nextKey=1;tool=_8[0];coachOn=j6();coachShape=null;frozen=null;job=null;sending=!1;error="";result=null;notify=!1;sentNotify=!1;includedOpen=!1;recordingBind=!1;bindRefused=!1;kind=null;passKeys=new Set;confirming=!1;parked=null;parkInsets=null;dock=F6();size=G6();techOpen=!1;fabDrag=null;swallowClick=!1;glide=null;files=[];fileRefusal=null;pastes=0;chips=new Map;recordSwitch=null;menu=null;session=null;sessionToken="";member=null;mine={rows:[],state:"ok"};linkFlow=null;drawing=null;offs=[];pins=new Map;lines=new Map;hideIds=new Map;dialogOrder=[...document.querySelectorAll("dialog[open]")].filter((x)=>x instanceof HTMLDialogElement);activeDialog(){this.dialogOrder=this.dialogOrder.filter((z)=>z.isConnected&&z.open);let x=(z)=>{try{return z.matches(":modal")}catch{return!1}};return[...this.dialogOrder].reverse().find(x)??this.dialogOrder.at(-1)??x6()}sheet=null;e;constructor(x){this.opts=x;this.locale=x.locale??k2(),this.s=f2(this.locale),this.button=x.button,this.openSelector=x.openSelector??null,this.identity=x.identity===void 0?void 0:c1(x.identity),this.keybind=Q8(),this.hud=s3(),this.e=_$(this.hud.mount),this.engine=l6({base:x.base,key:x.key,appVersion:x.appVersion,capture:x.capture,sanitizeUrl:x.sanitizeUrl,loadRecord:x.loadRecord}),this.engine?.ready.then(($)=>{this.config=$,this.paint()}),this.bind(),this.paint(),this.followDialog()}followDialog(){let x=this.activeDialog();if((this.sheet?.target??null)===x)return;let $=this.e.root.getRootNode(),z=$ instanceof ShadowRoot&&$.activeElement instanceof HTMLElement?$.activeElement:null,Q=this.sheet;if(x){let Z=$6(x);Z.mount.append(this.e.root),this.sheet={target:x,host:Z}}else this.hud.mount.append(this.e.root),this.sheet=null;Q?.host.destroy(),z?.focus()}open(){if(this.isOpen)return;if(this.isOpen=!0,this.opener=z6(document.activeElement)?null:K5(),this.view!=="describe")this.view="describe";if(this.result=null,!this.job)this.frozen=this.engine?.freeze()??null;this.paint(),requestAnimationFrame(()=>this.e.desc.focus()),this.refreshWho(),this.refreshMember()}close(){if(!this.isOpen)return;if(this.marking)this.endMarking(!1);this.stopRecordingBind(),this.isOpen=!1,this.view="describe",this.unpark(),this.paint();let x=this.opener;if(this.opener=null,x?.focus(),x&&K5()===x)return;if(this.button)this.e.fab.focus()}setLocale(x){let $=o0(x)??k2();if($===this.locale)return;this.locale=$,this.s=f2($),this.paint()}setButton(x){this.button=x,this.paint()}setOpenSelector(x){this.openSelector=x||null}setRecordSwitch(x){this.recordSwitch=x,this.paint()}identify(x){this.identity=x===void 0?void 0:c1(x),this.whoChanged()}unmount(){this.stopRecordingBind(),this.linkFlow?.abort.abort();for(let x of this.offs.splice(0).reverse())x();o6(this.engine),this.sheet?.host.destroy(),this.sheet=null,this.hud.destroy()}bind(){let x=this.e,$=(X,G,Y)=>{X.addEventListener(G,Y)};$(x.fab,"click",()=>{if(this.swallowClick){this.swallowClick=!1;return}if(this.isOpen)this.close();else this.open()}),$(x.fab,"pointerdown",(X)=>this.fabDown(X)),$(x.fab,"pointermove",(X)=>this.fabMove(X)),$(x.fab,"pointerup",(X)=>this.fabUp(X,!0)),$(x.fab,"pointercancel",(X)=>this.fabUp(X,!1)),$(x.fab,"keydown",(X)=>{if(!X.altKey||X.ctrlKey||X.metaKey||X.shiftKey)return;let G=K6(this.dock,X.key);if(!G)return;if(X.preventDefault(),G!==this.dock)this.moveDock(G)}),$(x.attach,"click",()=>x.fileInput.click()),$(x.fileInput,"change",()=>{this.addFiles([...x.fileInput.files??[]]),x.fileInput.value=""}),$(x.card,"paste",(X)=>{let G=[...X.clipboardData?.files??[]];if(!G.length||!this.canAttach())return;let Y=X.clipboardData?.getData("text/plain").trim()??"";if(Y&&!G.some((U)=>U.name&&Y.includes(U.name)))return;X.preventDefault(),this.addFiles(G.map((U)=>{let q=V6(U.name,++this.pastes);return q===U.name?U:new File([U],q,{type:U.type,lastModified:U.lastModified})}))}),$(x.card,"dragover",(X)=>{if(!X.dataTransfer?.types.includes("Files")||!this.canAttach())return;X.preventDefault(),X.dataTransfer.dropEffect="copy",x.card.classList.add("dropping")}),$(x.card,"dragleave",(X)=>{if(X.relatedTarget instanceof Node&&x.card.contains(X.relatedTarget))return;x.card.classList.remove("dropping")}),$(x.card,"drop",(X)=>{x.card.classList.remove("dropping");let G=[...X.dataTransfer?.files??[]];if(!G.length||!this.canAttach())return;X.preventDefault(),this.addFiles(G)});for(let[X,G]of x.sizeButtons)$(G,"click",()=>{if(this.size=X,t0(v2,X),this.paint(),this.parked)this.placeCard(!0)});let z=(X)=>{this.coachOn=X,t0(h2,X?"on":"off"),this.paint()};$(x.coachDismiss,"click",()=>{if(z(!1),this.marking)x.mark.focus()}),$(x.coachSwitch,"click",()=>z(!this.coachOn)),$(x.techBtn,"click",()=>{this.techOpen=!this.techOpen,this.paint()}),$(x.closeBtn,"click",()=>this.close()),$(x.whoBtn,"click",()=>this.toggleMenu("account")),$(x.more,"click",()=>this.toggleMenu("more"));let Q=(X)=>()=>{this.menu=null,X(),this.paint()};$(x.morePop,"keydown",(X)=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(X.key))return;let G=[...x.morePop.querySelectorAll('[role="menuitem"]')].filter((M)=>!M.hidden&&!(M instanceof HTMLButtonElement&&M.disabled));if(!G.length)return;X.preventDefault();let Y=x.morePop.getRootNode(),U=G.indexOf(Y.activeElement),q=G.length-1,W=X.key==="ArrowDown",F=X.key==="Home"?0:X.key==="End"?q:U<0?W?0:q:(U+(W?1:-1)+G.length)%G.length;G[F]?.focus()}),$(x.mReports,"click",Q(()=>void this.openReports())),$(x.mRecents,"click",Q(()=>this.show("recents")));let Z=Q(()=>this.recordSwitch?.());$(x.mRecord,"click",()=>{if(!this.recordWaits())Z()}),$(x.mSettings,"click",Q(()=>this.show("settings"))),$(x.mOpen,"click",Q(()=>{return})),$(x.accPortal,"click",Q(()=>{return})),$(x.accLink,"click",Q(()=>this.startLinkFlow())),$(x.accUnlink,"click",()=>{O4(),this.member=null,this.paint()});for(let X of[x.repBack,x.recBack,x.linkBack])$(X,"click",()=>this.show("describe"));$(x.linkRetry,"click",()=>this.startLinkFlow()),$(x.card,"pointerdown",(X)=>{let G=X.target;if(!this.menu||!(G instanceof Node))return;if([x.accountPop,x.morePop,x.whoBtn,x.more].some((Y)=>Y.contains(G)))return;this.menu=null,this.paint()}),$(x.back,"click",()=>this.show("describe")),$(x.sentClose,"click",()=>this.close()),$(x.desc,"input",()=>this.paint()),$(x.disclose,"click",()=>{this.includedOpen=!this.includedOpen,this.paint()}),$(x.notifyBox,"change",()=>{this.notify=x.notifyBox.checked}),$(x.where,"click",()=>this.marking?this.endMarking(!0):this.startMarking()),$(x.send,"click",()=>void this.send()),$(x.bindBtn,"click",()=>this.recordingBind?this.stopRecordingBind():this.startRecordingBind()),$(x.unbind,"click",()=>{this.keybind=null,J5(null),this.paint()});for(let[X,G]of x.kindButtons)$(G,"click",()=>{this.kind=this.kind===X?null:X,this.paint()});$(x.card,"keydown",(X)=>{if(X.key!=="Escape"||this.recordingBind||X.defaultPrevented)return;if(X.preventDefault(),this.menu){let G=this.menu==="account"?x.whoBtn:x.more;this.menu=null,this.paint(),G.focus()}else if(this.view!=="describe"&&this.view!=="sent")this.show("describe");else this.close()});for(let[X,G]of x.toolButtons)$(G,"click",(Y)=>{if(this.tool=X,this.renderKbDraft(),this.paint(),this.placeSeg(),Y.detail===0)x.mark.focus()});if($(x.mark,"keydown",(X)=>this.markKey(X)),$(x.cancel,"click",()=>this.cancelMarking()),$(x.discard,"click",()=>{this.markers=l1(this.markers.filter((X)=>this.passKeys.has(X.key))),this.renderMarks(),this.endMarking(!0)}),$(x.keep,"click",()=>{this.confirming=!1,this.paint(),x.cancel.focus()}),$(x.mark,"pointerdown",(X)=>this.pointerDown(X)),$(x.mark,"pointermove",(X)=>this.pointerMove(X)),$(x.mark,"pointerup",(X)=>this.pointerUp(X)),$(x.mark,"pointercancel",()=>this.cancelDraft()),this.offs.push(C(x.mark,"wheel",(X)=>X.preventDefault())),this.offs.push(C(x.mark,"touchmove",(X)=>X.preventDefault())),this.offs.push(C(window,"keydown",(X)=>{if(this.recordingBind)return;if(this.marking&&X.key==="Escape"){if(X.preventDefault(),this.confirming)x.keep.click();else if(this.kbDraft)this.cancelDraft();else this.endMarking(!0);return}if(this.marking&&(X.metaKey||X.ctrlKey)&&!X.shiftKey&&!X.altKey&&X.key.toLowerCase()==="z"&&!L$()){X.preventDefault(),this.markers=l1(this.markers.slice(0,-1)),this.renderMarks(),this.paint();return}if(this.keybind&&s6(X,this.keybind))if(X.preventDefault(),this.isOpen)this.close();else this.open()},{capture:!0})),this.offs.push(C(document,"click",(X)=>{if(!D5(X,this.openSelector))return;X.preventDefault(),this.open()})),this.offs.push(C(window,"resize",()=>{if(this.parked)this.placeCard(!0);if(this.marking)this.placeSeg()})),this.offs.push(Z8((X)=>{this.keybind=X,this.paint()})),this.offs.push(r6(()=>this.whoChanged())),this.engine)this.offs.push(this.engine.onChange(()=>this.paint()));let J=0,V=new MutationObserver((X)=>{for(let G of X){if(G.type!=="attributes"||G.attributeName!=="open"||!(G.target instanceof HTMLDialogElement))continue;let Y=G.target;if(!Y.open)this.dialogOrder=this.dialogOrder.filter((U)=>U!==Y);else if(G.oldValue===null)this.dialogOrder=[...this.dialogOrder.filter((U)=>U!==Y),Y]}if(J)return;J=requestAnimationFrame(()=>{J=0,this.followDialog()})});V.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeOldValue:!0,attributeFilter:["open","data-state"]}),this.offs.push(()=>{if(V.disconnect(),J)cancelAnimationFrame(J)})}show(x){if(this.stopRecordingBind(),x!=="link"&&this.linkFlow)this.linkFlow.abort.abort(),this.linkFlow=null;this.view=x,this.paint();let $={describe:this.e.desc,settings:this.e.bindBtn,sent:null,reports:this.e.repBack,recents:this.e.recBack,link:this.e.linkBack}[x];if($)requestAnimationFrame(()=>$.focus())}target(){return{url:this.opts.base,key:this.opts.key}}toggleMenu(x){if(this.menu=this.menu===x?null:x,this.menu==="account")this.refreshWho(),this.refreshMember();this.paint(),(this.menu==="account"?this.e.accountPop:this.menu==="more"?this.e.morePop:null)?.querySelector("button:not([hidden]), a:not([hidden])")?.focus()}async refreshWho(){let x=this.who();if(!x||!("token"in x))return this.session=null,this.sessionToken="",null;if(this.sessionToken===x.token&&Y8(this.session))return this.session;this.sessionToken=x.token;let $=null;try{$=await j8(this.target(),x.token)}catch(z){console.warn("vitrinka: the reporter session could not be opened — My reports shows this browser’s reports only",z)}if(this.sessionToken!==x.token)return null;return this.session=$,this.paint(),this.session}whoChanged(){if(this.whoToken()!==this.sessionToken){if(this.session=null,this.sessionToken="",this.mine={rows:[],state:"ok"},this.isOpen)this.view==="reports"?this.loadReports():this.refreshWho()}this.paint()}async refreshMember(){let x=l0(this.opts.base)?h0():null;if(!x){if(this.member)this.member=null,this.paint();return}try{let $=await n("GET","/api/v1/recorder/me",void 0,{target:{url:this.opts.base,key:x.token}});this.member={email:$.user?.email??"",name:$.user?.name??"",workspace:$.workspace?.slug??x.workspace},h3($.displayMode)}catch($){console.warn("vitrinka: the linked vitrinka account could not be read",$),this.member={email:"",name:"",workspace:x.workspace}}this.paint()}async openReports(){this.show("reports"),await this.loadReports()}async loadReports(){let x=this.whoToken(),$=await this.refreshWho();if(this.whoToken()!==x)return;if(!$){this.mine={rows:[],state:"ok"},this.paint();return}this.mine={rows:[],state:"loading"},this.paint();let z;try{z={rows:await this.listMineRenewing($),state:"ok"}}catch(Q){console.warn("vitrinka: My reports could not be loaded",Q),z={rows:[],state:"failed"}}if(this.whoToken()!==x)return;this.mine=z,this.paint()}async listMineRenewing(x){try{return(await X5(this.target(),x.session)).reports}catch($){if(!($ instanceof L)||$.status!==401)throw $;this.session=null,this.sessionToken="";let z=await this.refreshWho();if(!z)throw $;return(await X5(this.target(),z.session)).reports}}startLinkFlow(){this.linkFlow?.abort.abort();let x={start:null,state:"starting",abort:new AbortController};this.linkFlow=x,this.show("link");let $=this.opts.base,z=Y1($);(async()=>{try{x.start=await W4($,{label:_4(),workspace:z}),x.state="waiting",this.paint();let Q=await U4($,x.start.device_code,{interval:x.start.interval,expiresIn:x.start.expires_in,workspace:z,signal:x.abort.signal});g4({...Q,base:$}),this.linkFlow=null,this.show("describe"),await this.refreshMember()}catch(Q){if(x.abort.signal.aborted)return;if(x.state=Q instanceof f0?"expired":"failed",x.state==="failed")console.warn("vitrinka: linking the vitrinka account failed",Q);this.paint()}})()}ago(x){let $=new Intl.RelativeTimeFormat(this.locale,{numeric:"auto"}),z=Math.round((x-Date.now())/1000),Q=[[60,"second"],[60,"minute"],[24,"hour"],[30,"day"],[12,"month"],[1/0,"year"]],Z=z;for(let[J,V]of Q){if(Math.abs(Z)<J)return $.format(Z,V);Z=Math.round(Z/J)}return $.format(Z,"year")}row(x,$,z,Q){let Z=[j("span",{class:"row-t"},x),j("span",{class:"step"},$),j("span",{class:"age"},this.ago(z))],J=Q?j("a",{class:"row",href:Q,target:"_blank",rel:"noopener noreferrer"},...Z):j("div",{class:"row"},...Z);return j("li",{},J)}who(){return this.identity!==void 0?this.identity:a6()}whoToken(){let x=this.who();return x&&"token"in x?x.token:""}stopBindListener=null;startRecordingBind(){this.recordingBind=!0,this.bindRefused=!1,this.stopBindListener=C(window,"keydown",(x)=>{x.preventDefault(),x.stopPropagation();let $=t6(x);if($.kind==="wait")return;if($.kind==="bare"){this.bindRefused=!0,this.paint();return}if($.kind==="bind")this.keybind=$.bind,J5($.bind);this.stopRecordingBind()},{capture:!0}),this.paint()}stopRecordingBind(){if(!this.recordingBind)return;this.recordingBind=!1,this.bindRefused=!1,this.stopBindListener?.(),this.stopBindListener=null,this.paint()}canAttach(){return this.isOpen&&this.view==="describe"&&!this.sending&&!this.job?.id}caps(){return this.config?.attachments??Q0}addFiles(x){if(!x.length)return;let{files:$,refusal:z}=Z6(this.files,x,this.caps());this.files=[...this.files,...$],this.fileRefusal=z,this.renderFiles(),this.paint()}removeFile(x){this.files=this.files.filter(($)=>$!==x),this.fileRefusal=null,this.renderFiles(),this.paint(),this.e.attach.focus()}renderFiles(){let x=new Set(this.files);for(let[$,z]of this.chips){if(x.has($))continue;z.el.remove(),this.chips.delete($)}for(let $ of this.files){if(this.chips.has($))continue;let z=j("span",{class:"file-size"}),Q=j("button",{class:"ln-x",type:"button"},_(O.close)),Z=j("li",{class:"file"},j("span",{class:"file-name"},$.name),z,Q);Q.addEventListener("click",()=>this.removeFile($)),this.e.files.append(Z),this.chips.set($,{el:Z,size:z,rm:Q})}}refusalText(x){let $=this.s;if(!x)return"";if(x.kind==="size")return $.fileTooBig(x.name,a0(x.cap,this.locale));if(x.kind==="count")return $.tooManyFiles(x.cap);return $.fileType(x.name,J6(this.caps().types,$.typeNames,this.locale))}fabDown(x){if(this.swallowClick=!1,x.button!==0||!x.isPrimary)return;let $=this.e.fab.getBoundingClientRect();this.fabDrag={pointer:x.pointerId,start:{x:x.clientX,y:x.clientY},grab:{x:x.clientX-$.left,y:x.clientY-$.top},moved:!1};try{this.e.fab.setPointerCapture(x.pointerId)}catch{}}fabMove(x){let $=this.fabDrag;if(!$||x.pointerId!==$.pointer)return;if(!$.moved&&Math.hypot(x.clientX-$.start.x,x.clientY-$.start.y)<U6)return;$.moved=!0;let z=this.e.fab;z.classList.add("dragging");let Q=z.getBoundingClientRect(),Z=globalThis.innerWidth||800,J=globalThis.innerHeight||600,V=z.style;V.left=`${Math.min(Math.max(0,x.clientX-$.grab.x),Z-Q.width)}px`,V.top=`${Math.min(Math.max(0,x.clientY-$.grab.y),J-Q.height)}px`,V.right="auto",V.bottom="auto"}fabUp(x,$){let z=this.fabDrag;if(!z||x.pointerId!==z.pointer)return;if(this.fabDrag=null,!z.moved)return;let Q=this.e.fab,Z=Q.getBoundingClientRect();Q.classList.remove("dragging");for(let X of["left","top","right","bottom"])Q.style.removeProperty(X);this.swallowClick=!0,setTimeout(()=>{this.swallowClick=!1},0);let J=globalThis.innerWidth||800,V=globalThis.innerHeight||600;this.moveDock($?M6({x:Z.left+Z.width/2,y:Z.top+Z.height/2},J,V):this.dock,Z)}moveDock(x,$){let z=this.e.fab,Q=$??z.getBoundingClientRect();if(this.dock=x,q6(x),this.paint(),z.hidden||O8())return;let Z=z.getBoundingClientRect(),J=Q.left-Z.left,V=Q.top-Z.top;if(!J&&!V)return;this.glide?.abort();let X=new AbortController;this.glide=X,z.classList.remove("gliding"),z.style.setProperty("translate",`${J}px ${V}px`),z.offsetWidth,z.classList.add("gliding"),z.style.setProperty("translate","0px 0px");let G=(Y)=>{if(Y.propertyName!=="translate")return;X.abort(),z.classList.remove("gliding"),z.style.removeProperty("translate")};z.addEventListener("transitionend",G,{signal:X.signal}),z.addEventListener("transitioncancel",G,{signal:X.signal})}startMarking(){if(this.job?.id)return;this.marking=!0,this.confirming=!1,this.passKeys=new Set(this.markers.map(($)=>$.key));let x=this.parked??this.dock;this.parkInsets=this.insetsAt(x,this.e.card.getBoundingClientRect()),this.parked=x,this.renderMarks(),this.paint(),this.placeCard(),this.placeSeg(!0),this.e.mark.focus()}endMarking(x){if(this.cancelDraft(),this.marking=!1,this.confirming=!1,this.paint(),x&&this.isOpen)requestAnimationFrame(()=>this.e.desc.focus())}cancelMarking(){if(this.markers.filter(($)=>!this.passKeys.has($.key)).length===0){this.endMarking(!0);return}this.confirming=!0,this.paint(),this.e.discard.focus()}insetsAt(x,$){let z=globalThis.innerWidth||800,Q=globalThis.innerHeight||600,Z=F5*r0[this.size],J=x==="br"||x==="bl";return{edge:Math.max(0,Math.min($.left,z-$.right)),top:J?Z:Math.max(Z,$.top),bottom:J?Math.max(0,Q-$.bottom):M5}}frame(){let x=globalThis.innerWidth||800,$=globalThis.innerHeight||600,z=r0[this.size],Q=this.parkInsets??{top:F5*z,bottom:M5,edge:M5},Z=this.e.card.getBoundingClientRect();return{vw:x,vh:$,w:Z.width||Math.min(N8.w*z,x-32),h:Z.height||Math.min(N8.h*z,$-Q.top-Q.bottom),...Q}}placeCard(x=!1){if(!this.parked)return;let $=this.frame(),z=this.parked;this.parked=V8(this.parked,this.markers.map((V)=>V.rect),$);let Q=V5(this.parked,$),Z=this.e.card,J=x&&this.parked===z;if(J)Z.style.transition="none";if(Z.classList.add("parked"),Z.style.left=`${Q.x}px`,Z.style.top=`${Q.y}px`,this.placeCoachSide(),!J)return;Z.offsetWidth,Z.style.removeProperty("transition")}placeCoachSide(){let x=r0[this.size],$=this.e.coach;$.dataset.side="above";let z=$.offsetHeight||q5.h;$.dataset.side=X8(this.parked??this.dock,this.frame(),{w:q5.w*x,h:z*x},q5.gap*x)}unpark(){this.parked=null,this.parkInsets=null,this.e.card.classList.remove("parked"),this.e.card.style.removeProperty("left"),this.e.card.style.removeProperty("top")}placeSeg(x=!1){L8(this.e.seg,this.e.segInd,this.e.toolButtons.get(this.tool),x)}onChrome(x){return x instanceof Node&&(this.e.toolbar.contains(x)||this.e.pins.contains(x))}pointerDown(x){if(this.onChrome(x.target)||x.button!==0||!x.isPrimary)return;x.preventDefault();let $=this.e.root.getRootNode();if($ instanceof ShadowRoot&&$.activeElement instanceof HTMLElement)$.activeElement.blur();this.drawing={start:{x:x.clientX,y:x.clientY},shape:this.tool,pointer:x.pointerId};try{this.e.mark.setPointerCapture(x.pointerId)}catch{}this.e.coach.classList.add("pressing")}pointerMove(x){let $=this.drawing;if(!$||x.pointerId!==$.pointer)return;this.e.draft.replaceChildren(...this.shapeNodes({shape:$.shape,rect:t2($.start,{x:x.clientX,y:x.clientY}),head:s2($.start,{x:x.clientX,y:x.clientY})}))}pointerUp(x){let $=this.drawing;if(!$||x.pointerId!==$.pointer)return;let z={x:x.clientX,y:x.clientY};if(this.cancelDraft(),!E6($.shape,$.start,z))return;this.addMarker($.shape,t2($.start,z),$.shape==="arrow"?s2($.start,z):void 0)}addMarker(x,$,z){let Q=this.nextKey++;if(x==="hide"){let Z=this.engine?.hiddenIdsAt($);if(Z)this.hideIds.set(Q,Z)}this.markers=l1([...this.markers,{key:Q,n:this.markers.length+1,shape:x,rect:$,note:"",...z?{head:z}:{}}]),this.renderMarks(),this.paint(),this.lines.get(Q)?.note.focus()}cancelDraft(){this.drawing=null,this.kbDraft=null,this.e.draft.replaceChildren(),this.e.coach.classList.remove("pressing")}kbDraft=null;markKey(x){if(x.target!==this.e.mark)return;let $=globalThis.innerWidth||800,z=globalThis.innerHeight||600;if(x.key==="Enter"||x.key===" "){if(x.preventDefault(),!this.kbDraft){this.kbDraft={x:Math.round($/2-U5.w/2),y:Math.round(z/2-U5.h/2),...U5},this.renderKbDraft();return}let X=this.kbDraft;this.cancelDraft(),this.addMarker(this.tool,X,this.tool==="arrow"?"se":void 0);return}let Q=H$[x.key];if(!Q||!this.kbDraft)return;x.preventDefault();let Z=this.kbDraft,[J,V]=Q;this.kbDraft=x.shiftKey?{...Z,w:Math.min($-Z.x,Math.max(H8,Z.w+J)),h:Math.min(z-Z.y,Math.max(H8,Z.h+V))}:{...Z,x:Math.min($-Z.w,Math.max(0,Z.x+J)),y:Math.min(z-Z.h,Math.max(0,Z.y+V))},this.renderKbDraft()}renderKbDraft(){let x=this.kbDraft;if(!x)return;this.e.draft.replaceChildren(...this.shapeNodes({shape:this.tool,rect:x,head:"se"}))}shapeNodes(x){let{x:$,y:z,w:Q,h:Z}=x.rect;if(x.shape==="circle")return[p("ellipse",{class:"stroke",cx:$+Q/2,cy:z+Z/2,rx:Math.max(1,Q/2),ry:Math.max(1,Z/2)})];if(x.shape==="box")return[p("rect",{class:"stroke",x:$,y:z,width:Q,height:Z,rx:6})];if(x.shape==="arrow"){let{tail:X,tip:G}=e2(x.rect,x.head??"se");return[p("line",{class:"stroke",x1:X.x,y1:X.y,x2:G.x,y2:G.y,"marker-end":"url(#vr-head)"})]}let J=p("rect",{class:"veil",x:$,y:z,width:Q,height:Z,rx:4}),V=p("text",{class:"veil-label",x:$+Q/2,y:z+Z/2+4,"text-anchor":"middle"});return V.textContent=Q>150&&Z>20?this.s.hidden:"",[J,V]}renderMarks(){this.e.shapes.replaceChildren(...this.markers.flatMap((z)=>this.shapeNodes(z)));let x=new Set(this.markers.map((z)=>z.key));for(let[z,Q]of this.pins){if(x.has(z))continue;Q.el.remove(),this.pins.delete(z)}for(let[z,Q]of this.lines){if(x.has(z))continue;Q.el.remove(),this.lines.delete(z)}let $=(z)=>{this.markers=l1(this.markers.filter((Q)=>Q.key!==z)),this.renderMarks(),this.paint()};for(let z of this.markers){if(this.pins.has(z.key))continue;let Q=j("button",{class:"num",type:"button"}),Z=j("button",{class:"rm",type:"button"},_(O.close)),J=j("div",{class:"pin"},Q,Z);Q.addEventListener("click",()=>this.lines.get(z.key)?.note.focus()),Z.addEventListener("click",()=>$(z.key)),this.e.pins.append(J),this.pins.set(z.key,{el:J,num:Q,rm:Z});let V=j("span",{class:"ln-n","aria-hidden":"true"}),X=j("input",{class:"ln-t",type:"text",maxlength:"500"}),G=j("button",{class:"ln-x",type:"button"},_(O.close)),Y=j("li",{class:"ln"},V,X,G);X.addEventListener("input",()=>{this.markers=this.markers.map((U)=>U.key===z.key?{...U,note:X.value}:U),this.paint()}),X.addEventListener("keydown",(U)=>{if(U.key!=="Enter"||!this.marking)return;U.preventDefault(),this.e.mark.focus()}),G.addEventListener("click",()=>$(z.key)),this.e.lines.append(Y),this.lines.set(z.key,{el:Y,num:V,note:X,rm:G})}for(let z of this.markers){let Q=this.lines.get(z.key);if(Q)this.e.lines.append(Q.el)}if(this.renderPins(),this.parked)this.placeCard()}renderPins(){let x=globalThis.innerWidth||800;for(let $ of this.markers){let z=this.pins.get($.key),Q=this.lines.get($.key);if(!z||!Q)continue;let Z=$.shape==="arrow"?e2($.rect,$.head??"se").tail:{x:$.rect.x,y:$.rect.y};z.el.style.left=`${Math.min(Math.max(4,Z.x-12),x-60)}px`,z.el.style.top=`${Math.max(F5-12,Z.y-12)}px`,z.num.textContent=String($.n),z.num.setAttribute("aria-label",this.s.mark($.n)),z.rm.setAttribute("aria-label",this.s.removeMark($.n)),Q.num.textContent=String($.n),Q.el.classList.toggle("hide",$.shape==="hide"),Q.note.placeholder=this.s.notePlaceholder,Q.note.setAttribute("aria-label",`${this.s.mark($.n)} — ${this.s.notePlaceholder}`),Q.rm.setAttribute("aria-label",this.s.removeMark($.n))}}envelope(x,$){let z=this.who(),Q=globalThis.location;return{title:g8(x),description:x,env:{url:J0(Q?`${Q.origin}${Q.pathname}`:""),ua:globalThis.navigator?.userAgent??"",viewport:{w:globalThis.innerWidth||0,h:globalThis.innerHeight||0,dpr:globalThis.devicePixelRatio||1},appVersion:this.opts.appVersion??"",locale:globalThis.navigator?.language??""},console:$.console,network:$.network,...z?{identity:z,notify:this.notify}:{},markers:f6(this.markers),locale:this.locale,...this.kind?{type:this.kind}:{}}}words(){return this.e.desc.value.trim()||(this.markers.find((x)=>x.note.trim())?.note.trim()??"")}hasDraft(){return this.e.desc.value.trim()!==""||this.markers.length>0||this.kind!==null||this.files.length>0}recordWaits(){return this.sending||this.job!==null||this.hasDraft()}async send(){let x=this.words();if(this.sending||!x)return;if(this.marking)this.endMarking(!1);if(this.sending=!0,this.error="",this.paint(),this.job&&!this.job.id)this.job=null;try{if(!this.job){let $=new Set;for(let J of this.markers)for(let V of this.hideIds.get(J.key)??[])$.add(V);let z=this.engine,Q=this.frozen??{clip:null,stored:Promise.resolve(new Map)},Z=z?await D8(()=>z.build(Q,this.markers,$)):Y5;this.job=new W5(Z,globalThis.location?.host??"",{url:this.opts.base,key:this.opts.key},this.files)}this.result=await this.job.run(this.envelope(x,this.job.capture)),F8(this.opts.base,globalThis.location?.host??"",{title:g8(x),at:Date.now(),status:this.result.status,...this.result.reportUrl?{url:this.result.reportUrl}:{}}),this.sentNotify=this.notify&&this.who()!==null,this.view="sent",this.job=null,this.frozen=null,this.e.desc.value="",this.markers=[],this.hideIds.clear(),this.kind=null,this.notify=!1,this.e.notifyBox.checked=!1,this.includedOpen=!1,this.files=[],this.fileRefusal=null,this.renderMarks(),this.renderFiles(),this.engine?.clear()}catch($){console.warn("vitrinka: the report did not go through — Retry resumes it",$),this.error=!this.job?.id?"create":this.job.filesPending?"files":"capture"}finally{this.sending=!1,this.paint()}if(this.view==="sent")requestAnimationFrame(()=>((this.result?.reportUrl)?this.e.see:this.e.sentClose).focus())}includedItems(){let x=this.s,$=[],z=this.config?.lanes;if(z?.replay)$.push(`${x.incReplay} — ${x.incReplayMasked[this.config?.masking??"strict"].toLowerCase()}`);if(z?.errors)$.push(x.incErrors);if(z?.console)$.push(x.incConsole);if(z?.network)$.push(x.incNetwork);else if(z?.errors)$.push(x.incFailedRequests);if($.push(x.incEnv),this.who())$.push(x.incIdentity);if(this.markers.length)$.push(x.incMarks);if(this.files.length)$.push(x.incFiles);return $}paintAccount(){let{e:x,s:$}=this,z=this.who(),Q=!z?null:("email"in z)?{name:z.name??"",email:z.email}:this.session?{name:this.session.reporter.name??"",email:this.session.reporter.email}:null,Z=Q?.name||Q?.email||"";x.whoAv.textContent=z?O$(Z):"?",x.whoName.textContent=Z.split(/[\s@]/)[0]??"",x.whoName.hidden=!Z,x.whoBtn.setAttribute("aria-label",`${$.account}: ${Z||(z?"":$.anonymous)}`.replace(/: $/,"")),x.whoBtn.setAttribute("aria-expanded",String(this.menu==="account")),x.more.setAttribute("aria-label",$.menu),x.more.setAttribute("aria-expanded",String(this.menu==="more")),x.accountPop.hidden=this.menu!=="account",x.morePop.hidden=this.menu!=="more",x.accountPop.setAttribute("aria-label",$.account),x.morePop.setAttribute("aria-label",$.menu),x.accName.textContent=z?Q?.name||Q?.email||"":$.anonymous,x.accMail.textContent=Q?.name?Q.email:"",x.accMail.hidden=!x.accMail.textContent,x.accVia.textContent=z&&"token"in z?$.signedInByApp:$.anonymousHint;let J=this.member;x.accLinked.hidden=!J,x.accUnlink.hidden=!J,x.accLinked.textContent=J?$.linkedAs(J.email||J.name||J.workspace):"",x.accUnlink.textContent=$.unlink,x.accLink.hidden=Boolean(J),h(x.accLink,$.linkVitrinka);let V=this.session?.portalUrl;if(x.accPortal.hidden=!V,V)x.accPortal.setAttribute("href",V);h(x.accPortal,$.openPortal),h(x.mReports,$.myReports),h(x.mRecents,$.recentRecordings),h(x.mRecord,$.record),h(x.mSettings,$.settings),x.mRecents.hidden=!this.recordSwitch,x.mRecord.hidden=!this.recordSwitch;let X=this.recordWaits();if(X)x.mRecord.setAttribute("aria-disabled","true");else x.mRecord.removeAttribute("aria-disabled");if(x.mRecordWhy.hidden=!X,x.mRecordWhy.textContent=$.recordHasDraft,X)x.mRecord.setAttribute("aria-describedby",x.mRecordWhy.id);else x.mRecord.removeAttribute("aria-describedby");let G=J?this.opts.base:V;if(x.mOpen.hidden=!G,G)x.mOpen.setAttribute("href",G);h(x.mOpen,J?$.openVitrinka:$.openPortal)}paintReports(){let{e:x,s:$}=this;h(x.repBack,$.myReports);let z=!this.session,Q=z?G5(this.opts.base,globalThis.location?.host??"").map((V)=>this.row(V.title,V.status==="quarantined"?$.waiting:$.steps.received??"",V.at,V.url)):this.mine.rows.map((V)=>this.row(V.title,$.steps[V.step]??V.step,Date.parse(V.updatedAt),V.url));x.repRows.replaceChildren(...Q);let Z=z?"ok":this.mine.state;x.repStatus.hidden=Z==="ok"&&Q.length>0,x.repStatus.textContent=Z==="loading"?$.loading:Z==="failed"?$.listFailed:$.noReports,x.repLocal.hidden=!z||Q.length===0,x.repLocal.textContent=$.fromThisBrowser;let J=this.session?.portalUrl;if(x.repPortal.hidden=!J,J)x.repPortal.setAttribute("href",J);x.repPortal.textContent=$.openPortal}paintRecents(){let{e:x,s:$}=this;h(x.recBack,$.recentRecordings);let z=i3().map((Q)=>this.row(Q.title,"",Q.startedAt,Q.boardUrl));x.recRows.replaceChildren(...z),x.recStatus.hidden=z.length>0,x.recStatus.textContent=$.noRecordings}paintLink(){let{e:x,s:$}=this,z=this.linkFlow;h(x.linkBack,$.linkVitrinka),x.linkLabel.textContent=$.linkCode,x.linkCode.textContent=z?.start?.user_code??"…",x.linkOpenText.textContent=$.openVitrinka;let Q=z?.start;if(x.linkOpen.hidden=!Q,Q)x.linkOpen.setAttribute("href",Q.verifyUrl);let Z=globalThis.matchMedia?.("(pointer: fine)").matches??!0;if(x.linkQr.hidden=!Q||!Z,Q&&Z&&x.linkQr.getAttribute("src")!==Q.qrUrl)x.linkQr.setAttribute("src",Q.qrUrl);x.linkHint.textContent=$.linkHint;let J=z?.state??"failed";x.linkWait.textContent=J==="expired"?$.linkExpired:J==="failed"?$.linkFailed:J==="waiting"?$.linkWaiting:$.loading,x.linkRetry.hidden=J!=="expired"&&J!=="failed",x.linkRetry.textContent=$.retry}paintFiles(){let{e:x,s:$}=this,z=this.sending||Boolean(this.job?.id);x.attach.setAttribute("aria-label",$.attach),x.attach.disabled=z,x.attach.hidden=this.caps().maxCount===0,x.fileInput.setAttribute("accept",this.caps().types.join(",")),x.tray.hidden=this.view!=="describe"||this.files.length===0&&!this.fileRefusal,x.files.hidden=this.files.length===0,x.files.setAttribute("aria-label",$.incFiles),x.fileNote.hidden=!this.fileRefusal,x.fileNote.textContent=this.refusalText(this.fileRefusal);for(let[Q,Z]of this.chips)Z.size.textContent=a0(Q.size,this.locale),Z.rm.setAttribute("aria-label",$.removeFile(Q.name)),Z.rm.disabled=z}paintSettings(){let{e:x,s:$}=this;x.sizeLabel.textContent=$.size,x.coachLabel.textContent=$.coachSetting,x.coachSwitch.setAttribute("aria-checked",String(this.coachOn));for(let[z,Q]of x.sizeButtons)Q.textContent=$.sizes[z],Q.setAttribute("aria-checked",String(this.size===z));if(x.techText.textContent=$.techDetails,x.techBtn.setAttribute("aria-expanded",String(this.techOpen)),x.tech.hidden=!this.techOpen,this.techOpen&&this.view==="settings"){let z=Y6({version:f3,base:this.opts.base,config:this.config,engine:this.engine!==null,locale:this.locale},$);x.tech.replaceChildren(...z.flatMap(([Q,Z])=>[j("dt",{},Q),j("dd",{},Z)]))}if(this.view==="settings")L8(x.sizeSeg,x.sizeInd,x.sizeButtons.get(this.size))}paint(){let{e:x,s:$}=this,z=this.who();if(x.root.setAttribute("lang",this.locale),x.root.classList.toggle("nobutton",!this.button),x.root.dataset.dock=this.dock,x.root.style.setProperty("--vr-scale",String(r0[this.size])),x.fab.hidden=!this.button||this.marking,x.fabLabel.textContent=$.button,x.fab.setAttribute("aria-expanded",String(this.isOpen)),x.fab.setAttribute("aria-description",$.moveHint),x.fab.setAttribute("aria-keyshortcuts",`${this.keybind?`${x8(this.keybind)} `:""}Alt+ArrowUp Alt+ArrowDown Alt+ArrowLeft Alt+ArrowRight`),x.fabKbd.hidden=!this.keybind,x.fabKbd.textContent=this.keybind?i1(this.keybind):"",x.card.hidden=!this.isOpen,x.card.classList.toggle("busy",this.sending),x.title.textContent=$.title,x.closeBtn.setAttribute("aria-label",$.close),this.paintAccount(),x.describe.hidden=this.view!=="describe",x.settings.hidden=this.view!=="settings",x.sent.hidden=this.view!=="sent",x.reports.hidden=this.view!=="reports",x.recents.hidden=this.view!=="recents",x.linking.hidden=this.view!=="link",this.view==="reports")this.paintReports();if(this.view==="recents")this.paintRecents();if(this.view==="link")this.paintLink();x.foot.hidden=this.view!=="describe",this.paintFiles(),x.kindsLabel.textContent=$.kindsLabel;for(let[Z,J]of x.kindButtons)J.textContent=$.kinds[Z],J.setAttribute("aria-checked",String(this.kind===Z)),J.disabled=this.sending||Boolean(this.job?.id);x.prompt.textContent=$.prompt,x.desc.placeholder=$.placeholder,x.attachedText.textContent=$.attached(this.config?.profile.windowSec??60),x.attached.hidden=this.engine===null||this.config?.capturing===!1,x.discloseText.textContent=$.included,x.disclose.setAttribute("aria-expanded",String(this.includedOpen)),x.included.hidden=!this.includedOpen,x.included.replaceChildren(...this.includedItems().map((Z)=>j("li",{},Z))),x.desc.disabled=this.sending,x.lines.hidden=this.markers.length===0,x.linesEmpty.hidden=!this.marking||this.markers.length>0,x.linesEmpty.textContent=$.linesEmpty;for(let Z of this.lines.values())Z.note.disabled=this.sending,Z.rm.disabled=this.sending;x.notify.hidden=z===null,x.notifyText.textContent=$.notify,x.error.hidden=this.error==="",x.error.textContent={"":"",create:$.errorCreate,files:$.errorFiles,capture:$.errorCapture}[this.error],x.whereText.textContent=$.showWhere,x.where.setAttribute("aria-pressed",String(this.marking)),x.where.disabled=this.sending||Boolean(this.job?.id),x.send.textContent=this.sending?$.sending:this.error?$.retry:$.send,x.send.disabled=this.sending||this.words()==="",x.bindLabel.textContent=$.shortcut,x.bindBtn.setAttribute("aria-pressed",String(this.recordingBind)),x.bindBtn.setAttribute("aria-label",`${$.shortcut}: ${this.keybind?i1(this.keybind):$.notSet} — ${$.recordShortcut}`),x.bindBtn.textContent=this.recordingBind?$.pressKeys:this.keybind?i1(this.keybind):$.notSet,x.unbind.textContent=$.removeShortcut,x.unbind.hidden=!this.keybind||this.recordingBind,x.bindHint.textContent=$.shortcutHint,x.bindReason.hidden=!this.bindRefused,x.bindReason.textContent=this.bindRefused?$.needModifier:"",x.back.textContent=$.back,this.paintSettings(),x.sentTitle.textContent=$.sentTitle,x.sentBody.textContent=this.result?.status==="quarantined"?$.sentQueued:this.sentNotify?$.sentNotify:$.sentBody,x.seeText.textContent=$.seeReport;let Q=this.result?.reportUrl;if(x.see.hidden=!Q,Q)x.see.setAttribute("href",Q);else x.see.removeAttribute("href");x.sentClose.textContent=$.close,x.mark.hidden=!this.marking,x.toolbar.setAttribute("aria-label",$.toolbar),x.seg.setAttribute("aria-label",$.toolbar),x.barLead.textContent=this.tool==="hide"?$.barLeadHide:$.barLead;for(let[Z,J]of x.toolButtons){let V=x.toolLabels.get(Z);if(V)V.textContent=$.tools[Z];J.setAttribute("aria-checked",String(this.tool===Z))}if(x.cancel.textContent=$.cancelMarking,x.cancel.hidden=this.confirming,x.ask.hidden=!this.confirming,x.askText.textContent=$.discardMarks(this.markers.filter((Z)=>!this.passKeys.has(Z.key)).length),x.discard.textContent=$.discard,x.keep.textContent=$.keep,x.coach.hidden=!this.marking||!this.coachOn,x.coach.hidden)this.coachShape=null;else if(this.coachShape!==this.tool)this.coachShape=this.tool,x.coachArtSlot.replaceChildren(_(g$(this.tool,O8()))),this.placeCoachSide();if(x.coachText.textContent=$.coach[this.tool],x.coachMore.textContent=$.coachMore,x.coachDismiss.textContent=$.coachDismiss,x.coachKeys.textContent=$.keyboardHint,x.mark.setAttribute("aria-label",$.marking),this.marking){for(let Z of x.shapes.querySelectorAll(".veil-label"))if(Z.textContent)Z.textContent=$.hidden}this.renderPins()}}function l1(x){return w6(x).map(($,z)=>({...$,key:x[z].key}))}var o1="vitrinka-report",I$=["key","base","open-selector","locale","button"];function A8(x){return x.trim().replace(/\/+$/,"")}function H5(x){if(typeof customElements>"u"||customElements.get(o1))return;class $ extends HTMLElement{static get observedAttributes(){return I$}options={};at=null;shown=null;widget=null;pill=null;gen=0;recordOffered=!1;offPillOpener=null;warnedRecording=!1;offLink=null;pendingIdentity=void 0;get face(){return this.shown??"report"}connectedCallback(){this.hidden=!0,this.mount()}disconnectedCallback(){this.unmount()}attributeChangedCallback(z,Q,Z){if(Q===Z)return;if(!this.at){if(this.isConnected&&(z==="key"||z==="base"))this.mount();return}if(z==="key"||z==="base"){this.unmount(),this.mount();return}if(!this.widget)return;if(z==="locale")this.widget.setLocale(Z);else if(z==="button")this.widget.setButton(Z!=="false");else if(z==="open-selector")this.widget.setOpenSelector(Z)}open(){if(this.shown==="recorder")this.openFromPill();else this.widget?.open()}close(){this.widget?.close()}identify(z){this.pendingIdentity=z,this.widget?.identify(z)}setLocale(z){this.setAttribute("locale",String(z))}mount(){if(this.at)return;let z=(this.getAttribute("key")??"").trim(),Q=A8(this.getAttribute("base")??x.defaultBase());if(!z||!Q){console.warn(`vitrinka: <${o1}> needs a key${Q?"":" and a base"} — nothing mounted`);return}if(this.at={key:z,base:Q},x.recorderFace)this.offLink=d3(()=>this.offerRecord());this.show(x.recorderFace?m3(Q):"report")}unmount(){this.offLink?.(),this.offLink=null,this.takeDown(),this.at=null,this.shown=null}takeDown(){this.gen++,this.widget?.unmount(),this.widget=null,this.recordOffered=!1,this.offPillOpener?.(),this.offPillOpener=null,this.pill?.(),this.pill=null}show(z){let Q=this.at;if(!Q)return;this.takeDown();let Z=x.recorderFace;if(z==="recorder"&&Z){this.shown="recorder",this.offPillOpener=C(document,"click",(V)=>{if(!D5(V,this.getAttribute("open-selector")))return;V.preventDefault(),this.open()});let J=this.gen;Z().then((V)=>{if(J!==this.gen)return;this.pill=V({base:Q.base,appVersion:this.options.appVersion,sanitizeUrl:this.options.sanitizeUrl,onReportFace:()=>this.switchTo("report")})}).catch((V)=>{if(console.warn("vitrinka: the recorder face did not load — showing Report a problem",V),J===this.gen)this.show("report")});return}this.shown="report",this.widget=new P5({base:Q.base,key:Q.key,locale:o0(this.getAttribute("locale")),button:this.getAttribute("button")!=="false",openSelector:this.getAttribute("open-selector"),identity:this.pendingIdentity,appVersion:this.options.appVersion,capture:this.options.capture,sanitizeUrl:this.options.sanitizeUrl,loadRecord:x.loadRecord}),this.offerRecord()}offerRecord(){if(!this.widget||!this.at)return;let z=x.recorderFace!==null&&l0(this.at.base);if(z===this.recordOffered)return;this.recordOffered=z,this.widget.setRecordSwitch(z?()=>this.switchTo("recorder"):null)}openFromPill(){if(this.keepsPill())return;let z=this.at;setTimeout(()=>{if(!z||this.at!==z)return;if(this.shown==="recorder"){if(this.keepsPill())return;w2("report"),this.show("report")}this.widget?.open()},0)}keepsPill(){if(!u3())return!1;if(!this.warnedRecording)console.warn("vitrinka: Report a problem stays closed while the recorder pill records — leaving would strand the session; stop the recording first");return this.warnedRecording=!0,!0}switchTo(z){w2(z);let Q=this.gen;setTimeout(()=>{if(Q===this.gen&&this.shown!==z)this.show(z)},0)}}customElements.define(o1,$)}function R8(x,$){if(x.face==="recorder")return A$(x,$);H5($);let z=document.createElement(o1);if(z.setAttribute("key",x.key),x.base)z.setAttribute("base",x.base);if(x.locale)z.setAttribute("locale",String(x.locale));if(x.button===!1)z.setAttribute("button","false");if(x.openSelector)z.setAttribute("open-selector",x.openSelector);if(z.options={appVersion:x.appVersion,capture:x.capture,sanitizeUrl:x.sanitizeUrl},x.identity!==void 0)z.identify(x.identity);return(x.parent??document.body).append(z),{get face(){return z.face},open:()=>z.open(),close:()=>z.close(),identify:(Q)=>z.identify(Q),setLocale:(Q)=>z.setLocale(Q),unmount:()=>z.remove()}}function A$(x,$){let z=A8(x.base??$.defaultBase()),Q=null,Z=!1;if(!$.recorderFace)console.warn("vitrinka: the recorder face needs the npm package (@vitrinka/web/report) — nothing mounted");else $.recorderFace().then((V)=>{if(!Z)Q=V({base:z,key:x.key,appVersion:x.appVersion,sanitizeUrl:x.sanitizeUrl})}).catch((V)=>console.warn("vitrinka: the recorder face did not load",V));let J=()=>{return};return{face:"recorder",open:J,close:J,identify:J,setLocale:J,unmount:()=>{Z=!0,Q?.()}}}var R$=(()=>{try{return new URL(import.meta.url).origin}catch{return""}})();async function C$(x){let z=await import(`${x}/vendor/rrweb-record-1.min.js`)??{},Q=typeof z.default==="object"&&z.default!==null?z.default.record:void 0,Z=typeof z.default==="function"?z.default:Q??z.record;return typeof Z==="function"?Z:null}var C8={loadRecord:C$,recorderFace:null,defaultBase:()=>R$};H5(C8);function qZ(x){return R8(x,C8)}export{qZ as mountReport,Y$ as identify};
|