@lightworkai.official/debug-capture 0.12.4 → 0.12.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -1
- package/dist/index.mjs +4 -4
- package/dist/portal.d.ts +11 -1
- package/package.json +1 -1
- package/src/portal.ts +18 -5
package/README.md
CHANGED
|
@@ -276,8 +276,16 @@ await openSupportPortal(); // announces, then a new tab
|
|
|
276
276
|
await openSupportPortal({ seconds: 5 }); // a longer countdown
|
|
277
277
|
await openSupportPortal({ announce: false }); // go on the spot, no dialog
|
|
278
278
|
await openSupportPortal({ target: "_self" }); // take over this tab instead
|
|
279
|
+
await openSupportPortal({ returnTo: "/me/tickets/<id>" }); // land on one ticket
|
|
279
280
|
```
|
|
280
281
|
|
|
282
|
+
**`returnTo` is for links that name a ticket.** Your own notification about a
|
|
283
|
+
reply ("ACME-5158 · ทีมงานตอบกลับแล้ว") points at that ticket, and a person who
|
|
284
|
+
follows it should arrive there, not on a list they then have to search. It is a
|
|
285
|
+
hint: the portal accepts only a path under its reporter pages (`/me…`) and lands
|
|
286
|
+
on the list for anything else, so a host cannot send someone off-site through
|
|
287
|
+
it.
|
|
288
|
+
|
|
281
289
|
**A new tab by default.** Checking on a report is an interruption to something
|
|
282
290
|
else; replacing the page costs someone their place to answer a question that
|
|
283
291
|
takes ten seconds. A tab opened after a countdown can be refused — the click's
|
|
@@ -301,7 +309,7 @@ cannot reach it. With it, a failure is reported *in* it and the call resolves;
|
|
|
301
309
|
with `announce: false` there is nowhere to put the message, so the error is
|
|
302
310
|
thrown for you to handle.
|
|
303
311
|
|
|
304
|
-
`supportPortalUrl(host, realmKey, token)` is pure and safe to call on a server.
|
|
312
|
+
`supportPortalUrl(host, realmKey, token, returnTo?)` is pure and safe to call on a server.
|
|
305
313
|
|
|
306
314
|
|
|
307
315
|
## Installing
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var q2=((J)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(J,{get:($,Q)=>(typeof require<"u"?require:$)[Q]}):J)(function(J){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+J+'" is not supported')});var B2={maxRequests:60,maxConsoleEntries:120,maxActions:80,maxBodyChars:20000},k=null;function N2(J){let $=[];if(!J.host?.trim())$.push("host");if(!J.realmKey?.trim())$.push("realmKey");if(!J.app?.name?.trim())$.push("app.name");if(typeof J.module!=="function")$.push("module");if($.length)throw Error(`[debug-capture] configureDebugCapture is missing: ${$.join(", ")}. `+"See the README — `module` maps a pathname to the part of your app it belongs to.");k=J}function S(){if(!k)throw Error("[debug-capture] configureDebugCapture() has not been called");return k}function j0(){return k!==null}function m(){let J=S().app;return{name:J.name,version:J.version??"0.0.0",environment:J.environment??S2()}}function S2(){if(typeof window>"u")return"unknown";let J=window.location.hostname;if(J==="localhost"||J==="127.0.0.1"||J.endsWith(".local"))return"development";return"production"}function g(J){let $=k?.capture?.[J];return typeof $==="number"?$:B2[J]}function Z1(J){let $=k?.module;if(!$)return null;try{return $(J)??null}catch{return null}}function V0(){let J=k?.redact;return{headers:J?.headers??[],queryKeys:(J?.queryKeys??[]).map(($)=>$.toLowerCase()),bodyKeys:(J?.bodyKeys??[]).map(($)=>$.toLowerCase())}}function K1(){return k?.capture?.overlaySelectors??[]}var w2='[contenteditable]:not([contenteditable="false"]), [data-lw-mask]',O2="[data-lw-mask]",z1={fps:1,quality:0.5};function z0(){let J=k?.replay;if(!J)return null;let $=J===!0?{}:J,Q=(K,W)=>typeof K==="number"&&K>0?K:W,j=$.maskInputs!==!1,z=$.recordCanvas?{fps:Q(typeof $.recordCanvas==="object"?$.recordCanvas.fps:void 0,z1.fps),quality:Q(typeof $.recordCanvas==="object"?$.recordCanvas.quality:void 0,z1.quality)}:null;return{seconds:Q($.seconds,60),maskInputs:j,maskTextSelector:$.maskTextSelector?.trim()||(j?w2:O2),maskText:$.maskText===!0,blockSelector:$.blockSelector?.trim()||"[data-lw-private]",maxBytes:Q($.maxBytes,4000000),canvas:z}}function W1(J){if(typeof window>"u")return!1;let $;try{$=new URL(J,window.location.href)}catch{return!1}if(R2($))return!1;if($.origin===window.location.origin)return!0;return(k?.capture?.bodyOrigins??[]).some((Q)=>{try{return new URL(Q).origin===$.origin}catch{return!1}})}function R2(J){if(!k?.host)return!1;try{if(new URL(k.host).origin!==J.origin)return!1}catch{return!1}return J.pathname.startsWith("/ingest/")}function _2(J){let $=Object.entries(J).map(([Q,j])=>[Q.replace(/\/+$/,"")||"/",j]).sort((Q,j)=>j[0].length-Q[0].length);return(Q)=>{let j=(Q||"/").replace(/\/+$/,"")||"/";for(let[z,K]of $)if(j===z||j.startsWith(`${z}/`))return{key:z,label:K};return null}}var i="‹redacted›",L2=/^(authorization|proxy-authorization|cookie|set-cookie|x-[a-z-]*token|x-csrf[a-z-]*|x-xsrf[a-z-]*)$/i,T2=new Set(["access_token","token","id_token","refresh_token","code","secret","client_secret","password","apikey","api_key","signature","x-amz-signature","x-amz-credential"]),k2=/(password|passwd|token|secret|authorization|refresh|client_secret|otp|pin)/i,A2=/[\w.+-]+@[\w-]+\.[\w.-]+/g,x2=/\d(?:[\d\s-]{7,})\d/g;function l(J){return J.replace(A2,i).replace(x2,i)}function E2(J){if(L2.test(J))return!0;return V0().headers.some((Q)=>Q.toLowerCase()===J.toLowerCase())}function o(J){let $={};for(let[Q,j]of Object.entries(J))$[Q]=E2(Q)?i:j;return $}function f(J){try{let $=/^https?:\/\//i.test(J),Q=new URL(J,$?void 0:"http://local.invalid"),j=!1;if(Q.searchParams.forEach((z,K)=>{if(T2.has(K.toLowerCase())||V0().queryKeys.includes(K.toLowerCase()))Q.searchParams.set(K,i),j=!0}),!j)return J;return $?Q.toString():`${Q.pathname}${Q.search}`}catch{return J}}function B0(J,$){if($>6||J===null||typeof J!=="object")return J;if(Array.isArray(J))return J.map((j)=>B0(j,$+1));let Q={};for(let[j,z]of Object.entries(J)){let K=k2.test(j)||V0().bodyKeys.some((W)=>j.toLowerCase().includes(W));Q[j]=K?i:B0(z,$+1)}return Q}function r(J,$){if(J==null)return null;let Q=J,j=J.trim();if(j.startsWith("{")||j.startsWith("["))try{let z=JSON.parse(j);Q=JSON.stringify(B0(z,0))}catch{}if(Q.length>$)return`${Q.slice(0,$)}… [truncated ${Q.length-$} chars]`;return Q}var N0=120,S0=40,n=(J,$)=>J.length>$?`${J.slice(0,$)}…`:J,w0=(J)=>{try{return decodeURIComponent(J)}catch{return J}},s=[],Y1=0,G1=!1;function Z0(J,$,Q,j){let z=n($,N0),K=s[s.length-1];if(J==="navigate"&&K?.kind==="click"){let G=z.replace(/^ไปที่\s*/,"");if(K.detail.includes(`→ ${G}`))return K.at=new Date().toISOString(),K;let F=G.split(/[?#]/)[0]??G,M=K.source?w0(K.source.replace(/^→\s*/,"")).split(/[?#]/)[0]:null;if(M&&(F===M||F.startsWith(M)))return K.detail=n(`${K.detail} → ${G}`,N0),K.source=void 0,K.at=new Date().toISOString(),K}if(K&&K.kind===J&&K.detail===z){if(K.at=new Date().toISOString(),J!=="navigate")K.count=(K.count??1)+1;return K}Y1+=1;let W={id:`act_${Y1}`,at:new Date().toISOString(),kind:J,detail:z,count:1,source:Q,html:F0(j)};s.push(W);while(s.length>g("maxActions"))h2(s.shift());return W}var f2=200000,K0=0;function F0(J){if(!J)return;if(K0+J.length>f2)return;return K0+=J.length,J}function h2(J){if(!J)return;if(K0-=(J.html?.length??0)+(J.afterHtml?.length??0),K0<0)K0=0}function O0(J){return J&&J>1?` (×${J})`:""}function X0(J){return J instanceof Element&&Boolean(J.closest("[data-debug-reporter]"))}var m2='button, a[href], [role="button"], [role="tab"], [role="menuitem"], [role="option"], [role="switch"], [role="checkbox"], [role="radio"], [role="link"], summary, input, select, textarea',g2={button:"ปุ่ม",a:"ลิงก์",input:"ช่อง",textarea:"ช่อง",select:"ตัวเลือก",summary:"ส่วนขยาย"},V1={button:"ปุ่ม",tab:"แท็บ",menuitem:"เมนู",option:"ตัวเลือก",switch:"สวิตช์",checkbox:"ช่องเลือก",radio:"ตัวเลือก",link:"ลิงก์"};function y2(J){let $=J.getAttribute("role");if($&&V1[$])return V1[$];return g2[J.tagName.toLowerCase()]??"ปุ่ม"}function b2(J,$){try{let Q=J,j=0;while(Q&&j<=$){let z=P1(Q);if(z&&typeof z.memoizedProps?.onClick==="function")return Q;Q=Q.parentElement,j+=1}}catch{}return null}function v2(J){let $=J.getAttribute("aria-label")?.trim();if($)return $;let Q=J.getAttribute("title")?.trim();if(Q)return Q;if(J instanceof HTMLInputElement||J instanceof HTMLTextAreaElement||J instanceof HTMLSelectElement)return(J.getAttribute("placeholder")||J.getAttribute("name")||"").trim();if(J instanceof HTMLImageElement)return(J.getAttribute("alt")||"").trim();let j=(J.textContent??"").replace(/\s+/g," ").trim();if(j)return j;if(J instanceof HTMLAnchorElement){let z=J.getAttribute("href");if(z?.startsWith("/"))return w0(z)}return""}function p2(J){if(!(J instanceof Element))return null;let $=J.closest(m2)??b2(J,4);if(!$)return null;let Q=$.tagName.toLowerCase();if(Q==="html"||Q==="body")return null;return $}function u2(J){let $=l(v2(J));if(!$)return null;return`${y2(J)} “${n($,S0)}”`}var M1=6000,d2=4000,c2=/(?:^|\s)!?(?:fixed|absolute|sticky|inset-\S+|z-\S+|top-\S+|bottom-\S+|left-\S+|right-\S+|w-screen|h-screen|min-h-screen|max-h-screen|translate-\S+|scale-\S+)(?=\s|$)/g;function i2(J){J.querySelectorAll("script, style, link, iframe, object, embed, noscript, canvas, video, audio").forEach((z)=>z.remove());let $=[J,...Array.from(J.querySelectorAll("*"))];for(let z of $){for(let W of Array.from(z.attributes)){let G=W.name.toLowerCase();if(G.startsWith("on")||G==="srcdoc"||G==="value"||G.startsWith("data-"))z.removeAttribute(W.name)}if(z instanceof HTMLAnchorElement)z.setAttribute("href","#");if(z instanceof HTMLImageElement)z.removeAttribute("src");let K=z.getAttribute("class");if(K){let W=K.replace(c2," ").replace(/\s+/g," ").trim();if(W)z.setAttribute("class",W);else z.removeAttribute("class")}}let Q=document.createTreeWalker(J,NodeFilter.SHOW_TEXT),j=Q.nextNode();while(j){if(j.nodeValue)j.nodeValue=l(j.nodeValue);j=Q.nextNode()}}function R0(J,$,Q){try{let j=J.outerHTML;if(!j||j.length>$)return;let z=J.cloneNode(!0);i2(z);let K=z.outerHTML;return K&&K.length<=Q?K:void 0}catch{return}}var l2=(J)=>R0(J,M1,d2),o2=150000,r2=40000,X1=(J)=>R0(J,o2,r2);function s2(J){if(!(J instanceof HTMLInputElement)&&!(J instanceof HTMLTextAreaElement)&&!(J instanceof HTMLSelectElement))return null;let $=J.name||J.id||J.getAttribute("aria-label")||J.getAttribute("placeholder")||J.tagName.toLowerCase();return`ช่อง “${l($)}”`}var F1=80;function P1(J){let $=Object.keys(J).find((Q)=>Q.startsWith("__reactFiber$")||Q.startsWith("__reactInternalInstance$"));return $?J[$]:null}function n2(J){if(typeof J!=="function")return null;try{let $=Function.prototype.toString.call(J);return($.match(/\.(?:push|replace)\(\s*['"`]([^'"`]+)['"`]/)??$.match(/redirect\(\s*['"`]([^'"`]+)['"`]/))?.[1]??null}catch{return null}}function H1(J){if(!J)return;return`→ ${J.length>F1?`${J.slice(0,F1)}…`:J}`}function a2(J){try{let $=J.closest("a[href]")?.getAttribute("href");if($&&$.startsWith("/"))return H1($);let Q=P1(J),j=0;while(Q&&j<30){if(typeof Q.memoizedProps?.onClick==="function")return H1(n2(Q.memoizedProps.onClick));Q=Q.return,j+=1}return}catch{return}}var t2='[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], [role="status"], [role="alert"]';function e2(){let J=K1();return J.length?J.join(", "):t2}function J4(J){let $=J.getAttribute("role");if($==="status"||$==="alert")return"ข้อความแจ้งเตือน";if($==="menu")return"เมนู";if($==="listbox")return"รายการตัวเลือก";if($==="alertdialog")return"กล่องยืนยัน";return"กล่องโต้ตอบ"}function $4(J){let $=J.getAttribute("aria-label")?.trim();if($)return $;let Q=J.getAttribute("aria-labelledby");if(Q){let K=Q.split(/\s+/).map((W)=>document.getElementById(W)?.textContent?.trim()??"").filter(Boolean).join(" ");if(K)return K}let z=J.querySelector('[data-slot="dialog-title"], h1, h2, h3, [role="heading"]')?.textContent?.replace(/\s+/g," ").trim();if(z)return z;return(J.textContent??"").replace(/\s+/g," ").trim()}function I1(J){let $=l($4(J)),Q=J4(J);return $?`เปิด ${Q} “${n($,S0)}”`:`เปิด ${Q}`}var Q4='[aria-busy="true"], [role="progressbar"], [data-loading="true"], .animate-pulse, .animate-spin',j4=/กำลังโหลด|กำลังค้นหา|กำลังดำเนินการ|\bloading\b/i;function z4(J){if(J.querySelector(Q4))return!0;return j4.test(J.textContent??"")}var Z4=400,K4=250,W4=8000;function Y4(J,$){if(typeof MutationObserver>"u"){$.html=F0(X1(J));return}let Q=Date.now(),j=!1,z=()=>{j=!0,W.disconnect(),window.clearInterval(G),window.clearTimeout(F)},K=()=>{if(j)return;if(z(),!J.isConnected)return;$.detail=n(I1(J),N0),$.html=F0(X1(J))},W=new MutationObserver(()=>{Q=Date.now()});W.observe(J,{childList:!0,subtree:!0,attributes:!0,characterData:!0});let G=window.setInterval(()=>{if(j)return;if(!J.isConnected){z();return}if(Date.now()-Q>=Z4&&!z4(J))K()},K4),F=window.setTimeout(K,W4)}function G4(J){if(X0(J))return;let $=Z0("ui",I1(J));if($)Y4(J,$)}function V4(){if(typeof MutationObserver>"u")return;let J=new WeakSet;new MutationObserver((Q)=>{for(let j of Q)for(let z of Array.from(j.addedNodes)){if(!(z instanceof Element))continue;let K=e2(),W=z.matches(K)?[z]:Array.from(z.querySelectorAll(K));for(let G of W){if(J.has(G))continue;J.add(G),G4(G)}}}).observe(document.body,{childList:!0,subtree:!0})}var X4=1600,F4=2500;function U1(J){return{disabled:J.hasAttribute("disabled")||J.getAttribute("aria-disabled")==="true",busy:J.getAttribute("aria-busy")==="true",text:n((J.textContent??"").replace(/\s+/g," ").trim(),S0)}}function H4(J,$){if(!J.disabled&&$.disabled)return"ปุ่มถูกปิดใช้งานหลังคลิก";if(!J.busy&&$.busy)return"ปุ่มเข้าสู่สถานะกำลังโหลด";if(J.text!==$.text&&$.text)return`ข้อความเปลี่ยนเป็น “${$.text}”`;return null}function U4(J,$){if(typeof MutationObserver>"u")return;let Q=U1(J),j=!1,z=(G,F)=>{if(j)return;if(j=!0,K.disconnect(),window.clearTimeout(W),$.afterNote=G,F)$.afterHtml=F0(R0(J,M1,F4))},K=new MutationObserver(()=>{if(!J.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}let G=H4(Q,U1(J));if(G)z(G,!0)});K.observe(J,{attributes:!0,attributeFilter:["disabled","aria-disabled","aria-busy","class"],childList:!0,subtree:!0,characterData:!0});let W=window.setTimeout(()=>{if(!j&&!J.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}j=!0,K.disconnect()},X4)}function C1(){if(G1||typeof window>"u")return;G1=!0,document.addEventListener("click",(j)=>{if(X0(j.target))return;let z=p2(j.target);if(!z)return;let K=u2(z);if(!K)return;let W=Z0("click",`คลิก ${K}`,a2(z),l2(z));if(W)U4(z,W)},{capture:!0,passive:!0}),document.addEventListener("change",(j)=>{if(X0(j.target))return;let z=s2(j.target);if(z)Z0("input",`แก้ไข ${z}`)},{capture:!0,passive:!0}),document.addEventListener("submit",(j)=>{if(X0(j.target))return;Z0("submit","ส่งฟอร์ม")},{capture:!0,passive:!0});let J=()=>Z0("navigate",`ไปที่ ${w0(f(location.pathname+location.search))}`),$=history.pushState.bind(history),Q=history.replaceState.bind(history);history.pushState=(...j)=>{let z=$(...j);return J(),z},history.replaceState=(...j)=>{let z=Q(...j);return J(),z},window.addEventListener("popstate",J),V4()}function _0(){return s.map((J)=>({...J}))}var D1=2000,H0=[],q1=0,B1=!1;function L0(J,$){q1+=1,H0.push({id:`log_${q1}`,at:new Date().toISOString(),level:J,message:$.length>D1?`${$.slice(0,D1)}…`:$});while(H0.length>g("maxConsoleEntries"))H0.shift()}function M4(){let J=new WeakSet;return($,Q)=>{if(typeof Q==="object"&&Q!==null){if(J.has(Q))return"[Circular]";J.add(Q)}if(typeof Q==="bigint")return Q.toString();return Q}}function N1(J){if(typeof J==="string")return J;if(J instanceof Error)return`${J.name}: ${J.message}`;try{let $=JSON.stringify(J,M4());if($!==void 0)return $}catch{}try{return String(J)}catch{}try{return Object.prototype.toString.call(J)}catch{return`[${typeof J}]`}}function S1(){if(B1||typeof window>"u")return;B1=!0;let J=["log","info","warn","error","debug"];for(let $ of J){let Q=console[$].bind(console);console[$]=(...j)=>{L0($,j.map(N1).join(" ")),Q(...j)}}window.addEventListener("error",($)=>{let Q=$.filename?` (${$.filename}:${$.lineno}:${$.colno})`:"";L0("exception",`${$.message}${Q}`)}),window.addEventListener("unhandledrejection",($)=>{let Q=$.reason instanceof Error?`${$.reason.name}: ${$.reason.message}`:N1($.reason);L0("unhandledrejection",Q)})}function T0(){return H0.map((J)=>({...J}))}var w1=new Set,O1=new Set;function R1(J,$){return J.add($),()=>J.delete($)}function _1(J,$){for(let Q of[...J])Q($)}function k0(J){return R1(w1,J)}function A0(J={type:"manual"}){_1(w1,J)}function x0(J){return R1(O1,J)}function E0(J){_1(O1,J)}var P4=15000,I4=["ResizeObserver loop","Script error.","Non-Error promise rejection captured"],L1=!1,T1=0;function C4(J){return I4.some(($)=>J.includes($))}function k1(J){let $=J.message??"";if(!$||C4($))return;let Q=Date.now();if(Q-T1<P4)return;T1=Q,E0({...J,message:$})}function A1(){if(L1||typeof window>"u")return;L1=!0,window.addEventListener("error",(J)=>{if(!J.message&&!J.error)return;let $=J.error instanceof Error?J.error:null;k1({type:"runtime-error",message:J.message||($?$.message:"Unknown error"),stack:$?.stack})}),window.addEventListener("unhandledrejection",(J)=>{let $=J.reason;k1({type:"unhandledrejection",message:$ instanceof Error?$.message:String($),stack:$ instanceof Error?$.stack:void 0})})}var h1=4000,D4=1e6,q4=1e7,U0=[],x1=0,E1=!1;function m1(J){U0.push(J);while(U0.length>g("maxRequests"))U0.shift()}function g1(){return x1+=1,`req_${x1}`}function f1(J){let $={};if(!J)return $;if(J instanceof Headers)J.forEach((Q,j)=>{$[j]=Q});else if(Array.isArray(J))for(let[Q,j]of J)$[Q]=j;else Object.assign($,J);return $}function B4(J){let $={};return J.forEach((Q,j)=>{$[j]=Q}),$}function N4(J){if(J==null)return null;if(typeof J==="string")return J;if(J instanceof URLSearchParams)return J.toString();if(typeof FormData<"u"&&J instanceof FormData)return`[FormData: ${Array.from(J.keys()).join(", ")}]`;if(typeof Blob<"u"&&J instanceof Blob)return`[Blob ${J.size} bytes]`;if(J instanceof ArrayBuffer)return`[ArrayBuffer ${J.byteLength} bytes]`;return"[binary]"}function S4(J,$){let Q="",j="GET",z={},K=null;if(typeof J==="string")Q=J;else if(J instanceof URL)Q=J.toString();else Q=J.url,j=J.method||j,z=f1(J.headers);if($){if($.method)j=$.method;if($.headers)z={...z,...f1($.headers)};if($.body!==void 0)K=N4($.body)}return{method:j.toUpperCase(),url:Q,headers:z,body:K}}function y1(J){return!W1(J)}function w4(J,$){if(y1($.url)){$.responseSnippet="[body not captured for this origin]";return}let Q=J.headers.get("content-type")??"",j=Number(J.headers.get("content-length")??"0"),z=j?`, ~${j} bytes`:"";if(!/json|text|xml|html|javascript|urlencoded/i.test(Q)){$.responseSnippet=`[binary ${Q||"unknown"}${z}]`;return}if(j>D4){$.responseSnippet=`[response ${Q||"text"}${z} — omitted]`;return}try{J.clone().text().then((K)=>{$.responseSnippet=r(K,g("maxBodyChars"))}).catch(()=>{})}catch{}}function b1(J,$){if(/[?&]_rsc=/.test(J))return!0;for(let Q of Object.keys($)){let j=Q.toLowerCase();if(j==="rsc"||j==="next-router-prefetch"||j==="next-router-state-tree")return!0}return!1}function O4(){if(typeof window>"u"||typeof window.fetch!=="function")return;let J=window.fetch.bind(window);window.fetch=Object.assign(async($,Q)=>{let j=S4($,Q);if(b1(j.url,j.headers))return J($,Q);let z={id:g1(),startedAt:new Date().toISOString(),method:j.method,url:f(j.url),requestHeaders:o(j.headers),requestBody:r(j.body,h1),status:null,statusText:null,durationMs:null,via:"fetch"};m1(z);let K=performance.now();try{let W=await J($,Q);return z.status=W.status,z.statusText=W.statusText,z.durationMs=Math.round(performance.now()-K),z.responseHeaders=o(B4(W.headers)),w4(W,z),W}catch(W){throw z.durationMs=Math.round(performance.now()-K),z.error=W instanceof Error?`${W.name}: ${W.message}`:String(W),W}},J)}function R4(){if(typeof window>"u"||typeof window.XMLHttpRequest!=="function")return;let J=XMLHttpRequest.prototype,$=J.open,Q=J.send,j=function(K,W){let G=typeof W==="string"?W:W.toString();return this.__lwEntry=b1(G,{})?void 0:{id:g1(),startedAt:"",method:(K||"GET").toUpperCase(),url:f(G),requestHeaders:{},requestBody:null,status:null,statusText:null,durationMs:null,via:"xhr"},$.apply(this,arguments)},z=function(K){let W=this.__lwEntry;if(W){W.startedAt=new Date().toISOString(),W.requestBody=typeof K==="string"?r(K,h1):K==null?null:"[non-string body]";let G=performance.now();m1(W),this.addEventListener("loadend",()=>{if(W.status=this.status||null,W.statusText=this.statusText||null,W.durationMs=Math.round(performance.now()-G),y1(W.url))W.responseSnippet="[body not captured for this origin]";else if(this.responseType===""||this.responseType==="text")try{W.responseSnippet=r(this.responseText||"",g("maxBodyChars"))}catch{}else{let F=this.getResponseHeader("content-type")??this.responseType;W.responseSnippet=`[binary ${F}]`}})}return Q.apply(this,arguments)};J.open=j,J.send=z}function v1(){if(E1)return;E1=!0,O4(),R4()}function f0(){let J=U0.map((Q)=>({...Q})),$=0;for(let Q=J.length-1;Q>=0;Q-=1){let j=J[Q],z=j?.responseSnippet;if(!j||typeof z!=="string"||z.length===0)continue;if($+z.length>q4)j.responseSnippet=`[response omitted — report size budget reached (${z.length.toLocaleString()} chars)]`;else $+=z.length}return J}var _4=4,p1=3,L4=4000,T4="[data-debug-reporter]",k4=()=>import("@rrweb/record");var A=[],a=null,M0=!1;function u1(){if(typeof window>"u"||a||M0)return;let J=z0();if(!J)return;M0=!0;let $=()=>void A4(J);if("requestIdleCallback"in window)window.requestIdleCallback($,{timeout:3000});else setTimeout($,1000)}async function A4(J){let $;try{$=(await k4()).record}catch(Q){M0=!1,console.warn("[debug-capture] session replay could not start:",Q);return}if(a)return;try{a=$({emit:(Q)=>x4(Q),checkoutEveryNms:Math.max(1000,J.seconds*1000/2),checkoutEveryNth:L4,maskAllInputs:J.maskInputs,maskTextSelector:J.maskText?"*":J.maskTextSelector,blockSelector:`${J.blockSelector}, ${T4}`,slimDOMOptions:"all",inlineStylesheet:!0,sampling:{mousemove:50,scroll:150,media:800,input:"last",...J.canvas?{canvas:J.canvas.fps}:{}},recordCanvas:J.canvas!==null,...J.canvas?{dataURLOptions:{type:"image/webp",quality:J.canvas.quality}}:{},errorHandler:()=>!0})??null}catch(Q){console.warn("[debug-capture] session replay could not start:",Q)}finally{M0=!1}}function x4(J){if(J.type===_4||A.length===0){if(A.push([]),A.length>p1)A=A.slice(-p1)}A[A.length-1].push(J)}function h0(J=Date.now()){let $=z0();if(!$||!A.length)return null;let Q=J-$.seconds*1000,j=A.length-1;while(j>0&&(A[j][0]?.timestamp??J)>Q)j-=1;let z=A.slice(j).flat(),K=z[0]?.timestamp,W=z[z.length-1]?.timestamp;if(K===void 0||W===void 0)return null;return{events:z,startedAt:new Date(K).toISOString(),endedAt:new Date(W).toISOString(),durationMs:Math.max(0,W-K)}}function E4(){return a!==null}function f4(){a?.(),a=null,A=[]}var h4={title:"รายงานปัญหา",summaryLabel:"หัวข้อปัญหา",summaryRequired:"(ต้องกรอกก่อนแจ้งปัญหา)",summaryPlaceholder:"สรุปปัญหาสั้น ๆ เช่น กดบันทึกร่างแล้ว error",detailLabel:"อธิบายปัญหา (ไม่บังคับ)",detailPlaceholder:"เกิดอะไรขึ้น? กำลังทำอะไรอยู่ตอนที่พบปัญหา?",annotateTitle:"วาดบนรูป",annotateHint:"ทำเครื่องหมายจุดที่มีปัญหาก่อนแนบ — วงกรอบ ชี้ลูกศร ไฮไลต์ หรือพิมพ์ข้อความ",annotateApply:"ใช้รูปนี้",cancel:"ยกเลิก",toolRect:"กรอบ",toolArrow:"ลูกศร",toolHighlight:"ไฮไลต์",toolText:"ข้อความ",deleteSelected:"ลบที่เลือก",clearAll:"ล้างทั้งหมด",annotateHelp:"เลือกเครื่องมือแล้วลากบนรูป · ไม่ได้เลือกเครื่องมือ = ย้าย/ปรับขนาดสิ่งที่วาดไว้ · กดกากบาทมุมขวาบนของรูปทรงเพื่อลบ",capturing:"กำลังเก็บภาพหน้าจอ…",noScreenshot:"ไม่มีภาพหน้าจอ — ยังส่งรายงานได้",cancelled:"ยกเลิกการเก็บภาพหน้าจอแล้ว",close:"ปิด",submit:"แจ้งปัญหา",submitting:"กำลังส่ง…",submitted:"แจ้งปัญหาสำเร็จ",crashed:"เกิดข้อผิดพลาดในระบบ",crashAction:"แจ้งปัญหา",failed:"ส่งรายงานไม่สำเร็จ",captured:"เก็บข้อมูลแล้ว",reporter:"ผู้แจ้ง",page:"หน้า",replay:"บันทึกการใช้งาน",handoffTitle:"กำลังพาไปที่ระบบแจ้งปัญหา",handoffBody:"ระบบจะลงชื่อเข้าใช้ให้อัตโนมัติ เพื่อดูเรื่องที่คุณแจ้งไว้",handoffGo:"ไปเลย",handoffPreparing:"กำลังเตรียม…",handoffFailed:"เปิดรายการที่แจ้งไว้ไม่สำเร็จ",handoffBlocked:"เบราว์เซอร์บล็อกการเปิดแท็บใหม่",handoffOpen:"เปิดในแท็บใหม่"},m4={title:"Report a problem",summaryLabel:"Summary",summaryRequired:"(required)",summaryPlaceholder:"One line, e.g. saving a draft returns an error",detailLabel:"Details (optional)",detailPlaceholder:"What happened? What were you doing at the time?",annotateTitle:"Draw on the image",annotateHint:"Mark what went wrong before attaching — box it, point at it, highlight it, or type on it",annotateApply:"Use this image",cancel:"Cancel",toolRect:"Box",toolArrow:"Arrow",toolHighlight:"Highlight",toolText:"Text",deleteSelected:"Delete selected",clearAll:"Clear all",annotateHelp:"Pick a tool and drag on the image · no tool selected = move/resize what you drew · press the ✕ on a shape to delete it",capturing:"Capturing the screen…",noScreenshot:"No screenshot — you can still send the report",cancelled:"Screen capture cancelled",close:"Close",submit:"Send report",submitting:"Sending…",submitted:"Report sent",crashed:"Something went wrong",crashAction:"Report it",failed:"Could not send the report",captured:"Captured",reporter:"Reporter",page:"Page",replay:"activity log",handoffTitle:"Opening the support portal",handoffBody:"You will be signed in automatically to see what you reported",handoffGo:"Go now",handoffPreparing:"Preparing…",handoffFailed:"Could not open your reports",handoffBlocked:"Your browser blocked the new tab",handoffOpen:"Open in a new tab"};function d(J){return J==="en"?m4:h4}var g4="lw-debug-toasts",y4=6000,b4=`
|
|
1
|
+
var q2=((J)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(J,{get:($,Q)=>(typeof require<"u"?require:$)[Q]}):J)(function(J){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+J+'" is not supported')});var B2={maxRequests:60,maxConsoleEntries:120,maxActions:80,maxBodyChars:20000},A=null;function N2(J){let $=[];if(!J.host?.trim())$.push("host");if(!J.realmKey?.trim())$.push("realmKey");if(!J.app?.name?.trim())$.push("app.name");if(typeof J.module!=="function")$.push("module");if($.length)throw Error(`[debug-capture] configureDebugCapture is missing: ${$.join(", ")}. `+"See the README — `module` maps a pathname to the part of your app it belongs to.");A=J}function S(){if(!A)throw Error("[debug-capture] configureDebugCapture() has not been called");return A}function j0(){return A!==null}function m(){let J=S().app;return{name:J.name,version:J.version??"0.0.0",environment:J.environment??S2()}}function S2(){if(typeof window>"u")return"unknown";let J=window.location.hostname;if(J==="localhost"||J==="127.0.0.1"||J.endsWith(".local"))return"development";return"production"}function g(J){let $=A?.capture?.[J];return typeof $==="number"?$:B2[J]}function Z1(J){let $=A?.module;if(!$)return null;try{return $(J)??null}catch{return null}}function V0(){let J=A?.redact;return{headers:J?.headers??[],queryKeys:(J?.queryKeys??[]).map(($)=>$.toLowerCase()),bodyKeys:(J?.bodyKeys??[]).map(($)=>$.toLowerCase())}}function K1(){return A?.capture?.overlaySelectors??[]}var w2='[contenteditable]:not([contenteditable="false"]), [data-lw-mask]',O2="[data-lw-mask]",z1={fps:1,quality:0.5};function z0(){let J=A?.replay;if(!J)return null;let $=J===!0?{}:J,Q=(K,W)=>typeof K==="number"&&K>0?K:W,j=$.maskInputs!==!1,z=$.recordCanvas?{fps:Q(typeof $.recordCanvas==="object"?$.recordCanvas.fps:void 0,z1.fps),quality:Q(typeof $.recordCanvas==="object"?$.recordCanvas.quality:void 0,z1.quality)}:null;return{seconds:Q($.seconds,60),maskInputs:j,maskTextSelector:$.maskTextSelector?.trim()||(j?w2:O2),maskText:$.maskText===!0,blockSelector:$.blockSelector?.trim()||"[data-lw-private]",maxBytes:Q($.maxBytes,4000000),canvas:z}}function W1(J){if(typeof window>"u")return!1;let $;try{$=new URL(J,window.location.href)}catch{return!1}if(R2($))return!1;if($.origin===window.location.origin)return!0;return(A?.capture?.bodyOrigins??[]).some((Q)=>{try{return new URL(Q).origin===$.origin}catch{return!1}})}function R2(J){if(!A?.host)return!1;try{if(new URL(A.host).origin!==J.origin)return!1}catch{return!1}return J.pathname.startsWith("/ingest/")}function _2(J){let $=Object.entries(J).map(([Q,j])=>[Q.replace(/\/+$/,"")||"/",j]).sort((Q,j)=>j[0].length-Q[0].length);return(Q)=>{let j=(Q||"/").replace(/\/+$/,"")||"/";for(let[z,K]of $)if(j===z||j.startsWith(`${z}/`))return{key:z,label:K};return null}}var i="‹redacted›",L2=/^(authorization|proxy-authorization|cookie|set-cookie|x-[a-z-]*token|x-csrf[a-z-]*|x-xsrf[a-z-]*)$/i,k2=new Set(["access_token","token","id_token","refresh_token","code","secret","client_secret","password","apikey","api_key","signature","x-amz-signature","x-amz-credential"]),A2=/(password|passwd|token|secret|authorization|refresh|client_secret|otp|pin)/i,T2=/[\w.+-]+@[\w-]+\.[\w.-]+/g,x2=/\d(?:[\d\s-]{7,})\d/g;function l(J){return J.replace(T2,i).replace(x2,i)}function E2(J){if(L2.test(J))return!0;return V0().headers.some((Q)=>Q.toLowerCase()===J.toLowerCase())}function o(J){let $={};for(let[Q,j]of Object.entries(J))$[Q]=E2(Q)?i:j;return $}function f(J){try{let $=/^https?:\/\//i.test(J),Q=new URL(J,$?void 0:"http://local.invalid"),j=!1;if(Q.searchParams.forEach((z,K)=>{if(k2.has(K.toLowerCase())||V0().queryKeys.includes(K.toLowerCase()))Q.searchParams.set(K,i),j=!0}),!j)return J;return $?Q.toString():`${Q.pathname}${Q.search}`}catch{return J}}function B0(J,$){if($>6||J===null||typeof J!=="object")return J;if(Array.isArray(J))return J.map((j)=>B0(j,$+1));let Q={};for(let[j,z]of Object.entries(J)){let K=A2.test(j)||V0().bodyKeys.some((W)=>j.toLowerCase().includes(W));Q[j]=K?i:B0(z,$+1)}return Q}function r(J,$){if(J==null)return null;let Q=J,j=J.trim();if(j.startsWith("{")||j.startsWith("["))try{let z=JSON.parse(j);Q=JSON.stringify(B0(z,0))}catch{}if(Q.length>$)return`${Q.slice(0,$)}… [truncated ${Q.length-$} chars]`;return Q}var N0=120,S0=40,n=(J,$)=>J.length>$?`${J.slice(0,$)}…`:J,w0=(J)=>{try{return decodeURIComponent(J)}catch{return J}},s=[],Y1=0,G1=!1;function Z0(J,$,Q,j){let z=n($,N0),K=s[s.length-1];if(J==="navigate"&&K?.kind==="click"){let G=z.replace(/^ไปที่\s*/,"");if(K.detail.includes(`→ ${G}`))return K.at=new Date().toISOString(),K;let F=G.split(/[?#]/)[0]??G,M=K.source?w0(K.source.replace(/^→\s*/,"")).split(/[?#]/)[0]:null;if(M&&(F===M||F.startsWith(M)))return K.detail=n(`${K.detail} → ${G}`,N0),K.source=void 0,K.at=new Date().toISOString(),K}if(K&&K.kind===J&&K.detail===z){if(K.at=new Date().toISOString(),J!=="navigate")K.count=(K.count??1)+1;return K}Y1+=1;let W={id:`act_${Y1}`,at:new Date().toISOString(),kind:J,detail:z,count:1,source:Q,html:F0(j)};s.push(W);while(s.length>g("maxActions"))h2(s.shift());return W}var f2=200000,K0=0;function F0(J){if(!J)return;if(K0+J.length>f2)return;return K0+=J.length,J}function h2(J){if(!J)return;if(K0-=(J.html?.length??0)+(J.afterHtml?.length??0),K0<0)K0=0}function O0(J){return J&&J>1?` (×${J})`:""}function X0(J){return J instanceof Element&&Boolean(J.closest("[data-debug-reporter]"))}var m2='button, a[href], [role="button"], [role="tab"], [role="menuitem"], [role="option"], [role="switch"], [role="checkbox"], [role="radio"], [role="link"], summary, input, select, textarea',g2={button:"ปุ่ม",a:"ลิงก์",input:"ช่อง",textarea:"ช่อง",select:"ตัวเลือก",summary:"ส่วนขยาย"},V1={button:"ปุ่ม",tab:"แท็บ",menuitem:"เมนู",option:"ตัวเลือก",switch:"สวิตช์",checkbox:"ช่องเลือก",radio:"ตัวเลือก",link:"ลิงก์"};function y2(J){let $=J.getAttribute("role");if($&&V1[$])return V1[$];return g2[J.tagName.toLowerCase()]??"ปุ่ม"}function b2(J,$){try{let Q=J,j=0;while(Q&&j<=$){let z=P1(Q);if(z&&typeof z.memoizedProps?.onClick==="function")return Q;Q=Q.parentElement,j+=1}}catch{}return null}function v2(J){let $=J.getAttribute("aria-label")?.trim();if($)return $;let Q=J.getAttribute("title")?.trim();if(Q)return Q;if(J instanceof HTMLInputElement||J instanceof HTMLTextAreaElement||J instanceof HTMLSelectElement)return(J.getAttribute("placeholder")||J.getAttribute("name")||"").trim();if(J instanceof HTMLImageElement)return(J.getAttribute("alt")||"").trim();let j=(J.textContent??"").replace(/\s+/g," ").trim();if(j)return j;if(J instanceof HTMLAnchorElement){let z=J.getAttribute("href");if(z?.startsWith("/"))return w0(z)}return""}function p2(J){if(!(J instanceof Element))return null;let $=J.closest(m2)??b2(J,4);if(!$)return null;let Q=$.tagName.toLowerCase();if(Q==="html"||Q==="body")return null;return $}function u2(J){let $=l(v2(J));if(!$)return null;return`${y2(J)} “${n($,S0)}”`}var M1=6000,d2=4000,c2=/(?:^|\s)!?(?:fixed|absolute|sticky|inset-\S+|z-\S+|top-\S+|bottom-\S+|left-\S+|right-\S+|w-screen|h-screen|min-h-screen|max-h-screen|translate-\S+|scale-\S+)(?=\s|$)/g;function i2(J){J.querySelectorAll("script, style, link, iframe, object, embed, noscript, canvas, video, audio").forEach((z)=>z.remove());let $=[J,...Array.from(J.querySelectorAll("*"))];for(let z of $){for(let W of Array.from(z.attributes)){let G=W.name.toLowerCase();if(G.startsWith("on")||G==="srcdoc"||G==="value"||G.startsWith("data-"))z.removeAttribute(W.name)}if(z instanceof HTMLAnchorElement)z.setAttribute("href","#");if(z instanceof HTMLImageElement)z.removeAttribute("src");let K=z.getAttribute("class");if(K){let W=K.replace(c2," ").replace(/\s+/g," ").trim();if(W)z.setAttribute("class",W);else z.removeAttribute("class")}}let Q=document.createTreeWalker(J,NodeFilter.SHOW_TEXT),j=Q.nextNode();while(j){if(j.nodeValue)j.nodeValue=l(j.nodeValue);j=Q.nextNode()}}function R0(J,$,Q){try{let j=J.outerHTML;if(!j||j.length>$)return;let z=J.cloneNode(!0);i2(z);let K=z.outerHTML;return K&&K.length<=Q?K:void 0}catch{return}}var l2=(J)=>R0(J,M1,d2),o2=150000,r2=40000,X1=(J)=>R0(J,o2,r2);function s2(J){if(!(J instanceof HTMLInputElement)&&!(J instanceof HTMLTextAreaElement)&&!(J instanceof HTMLSelectElement))return null;let $=J.name||J.id||J.getAttribute("aria-label")||J.getAttribute("placeholder")||J.tagName.toLowerCase();return`ช่อง “${l($)}”`}var F1=80;function P1(J){let $=Object.keys(J).find((Q)=>Q.startsWith("__reactFiber$")||Q.startsWith("__reactInternalInstance$"));return $?J[$]:null}function n2(J){if(typeof J!=="function")return null;try{let $=Function.prototype.toString.call(J);return($.match(/\.(?:push|replace)\(\s*['"`]([^'"`]+)['"`]/)??$.match(/redirect\(\s*['"`]([^'"`]+)['"`]/))?.[1]??null}catch{return null}}function H1(J){if(!J)return;return`→ ${J.length>F1?`${J.slice(0,F1)}…`:J}`}function a2(J){try{let $=J.closest("a[href]")?.getAttribute("href");if($&&$.startsWith("/"))return H1($);let Q=P1(J),j=0;while(Q&&j<30){if(typeof Q.memoizedProps?.onClick==="function")return H1(n2(Q.memoizedProps.onClick));Q=Q.return,j+=1}return}catch{return}}var t2='[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], [role="status"], [role="alert"]';function e2(){let J=K1();return J.length?J.join(", "):t2}function J4(J){let $=J.getAttribute("role");if($==="status"||$==="alert")return"ข้อความแจ้งเตือน";if($==="menu")return"เมนู";if($==="listbox")return"รายการตัวเลือก";if($==="alertdialog")return"กล่องยืนยัน";return"กล่องโต้ตอบ"}function $4(J){let $=J.getAttribute("aria-label")?.trim();if($)return $;let Q=J.getAttribute("aria-labelledby");if(Q){let K=Q.split(/\s+/).map((W)=>document.getElementById(W)?.textContent?.trim()??"").filter(Boolean).join(" ");if(K)return K}let z=J.querySelector('[data-slot="dialog-title"], h1, h2, h3, [role="heading"]')?.textContent?.replace(/\s+/g," ").trim();if(z)return z;return(J.textContent??"").replace(/\s+/g," ").trim()}function I1(J){let $=l($4(J)),Q=J4(J);return $?`เปิด ${Q} “${n($,S0)}”`:`เปิด ${Q}`}var Q4='[aria-busy="true"], [role="progressbar"], [data-loading="true"], .animate-pulse, .animate-spin',j4=/กำลังโหลด|กำลังค้นหา|กำลังดำเนินการ|\bloading\b/i;function z4(J){if(J.querySelector(Q4))return!0;return j4.test(J.textContent??"")}var Z4=400,K4=250,W4=8000;function Y4(J,$){if(typeof MutationObserver>"u"){$.html=F0(X1(J));return}let Q=Date.now(),j=!1,z=()=>{j=!0,W.disconnect(),window.clearInterval(G),window.clearTimeout(F)},K=()=>{if(j)return;if(z(),!J.isConnected)return;$.detail=n(I1(J),N0),$.html=F0(X1(J))},W=new MutationObserver(()=>{Q=Date.now()});W.observe(J,{childList:!0,subtree:!0,attributes:!0,characterData:!0});let G=window.setInterval(()=>{if(j)return;if(!J.isConnected){z();return}if(Date.now()-Q>=Z4&&!z4(J))K()},K4),F=window.setTimeout(K,W4)}function G4(J){if(X0(J))return;let $=Z0("ui",I1(J));if($)Y4(J,$)}function V4(){if(typeof MutationObserver>"u")return;let J=new WeakSet;new MutationObserver((Q)=>{for(let j of Q)for(let z of Array.from(j.addedNodes)){if(!(z instanceof Element))continue;let K=e2(),W=z.matches(K)?[z]:Array.from(z.querySelectorAll(K));for(let G of W){if(J.has(G))continue;J.add(G),G4(G)}}}).observe(document.body,{childList:!0,subtree:!0})}var X4=1600,F4=2500;function U1(J){return{disabled:J.hasAttribute("disabled")||J.getAttribute("aria-disabled")==="true",busy:J.getAttribute("aria-busy")==="true",text:n((J.textContent??"").replace(/\s+/g," ").trim(),S0)}}function H4(J,$){if(!J.disabled&&$.disabled)return"ปุ่มถูกปิดใช้งานหลังคลิก";if(!J.busy&&$.busy)return"ปุ่มเข้าสู่สถานะกำลังโหลด";if(J.text!==$.text&&$.text)return`ข้อความเปลี่ยนเป็น “${$.text}”`;return null}function U4(J,$){if(typeof MutationObserver>"u")return;let Q=U1(J),j=!1,z=(G,F)=>{if(j)return;if(j=!0,K.disconnect(),window.clearTimeout(W),$.afterNote=G,F)$.afterHtml=F0(R0(J,M1,F4))},K=new MutationObserver(()=>{if(!J.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}let G=H4(Q,U1(J));if(G)z(G,!0)});K.observe(J,{attributes:!0,attributeFilter:["disabled","aria-disabled","aria-busy","class"],childList:!0,subtree:!0,characterData:!0});let W=window.setTimeout(()=>{if(!j&&!J.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}j=!0,K.disconnect()},X4)}function C1(){if(G1||typeof window>"u")return;G1=!0,document.addEventListener("click",(j)=>{if(X0(j.target))return;let z=p2(j.target);if(!z)return;let K=u2(z);if(!K)return;let W=Z0("click",`คลิก ${K}`,a2(z),l2(z));if(W)U4(z,W)},{capture:!0,passive:!0}),document.addEventListener("change",(j)=>{if(X0(j.target))return;let z=s2(j.target);if(z)Z0("input",`แก้ไข ${z}`)},{capture:!0,passive:!0}),document.addEventListener("submit",(j)=>{if(X0(j.target))return;Z0("submit","ส่งฟอร์ม")},{capture:!0,passive:!0});let J=()=>Z0("navigate",`ไปที่ ${w0(f(location.pathname+location.search))}`),$=history.pushState.bind(history),Q=history.replaceState.bind(history);history.pushState=(...j)=>{let z=$(...j);return J(),z},history.replaceState=(...j)=>{let z=Q(...j);return J(),z},window.addEventListener("popstate",J),V4()}function _0(){return s.map((J)=>({...J}))}var D1=2000,H0=[],q1=0,B1=!1;function L0(J,$){q1+=1,H0.push({id:`log_${q1}`,at:new Date().toISOString(),level:J,message:$.length>D1?`${$.slice(0,D1)}…`:$});while(H0.length>g("maxConsoleEntries"))H0.shift()}function M4(){let J=new WeakSet;return($,Q)=>{if(typeof Q==="object"&&Q!==null){if(J.has(Q))return"[Circular]";J.add(Q)}if(typeof Q==="bigint")return Q.toString();return Q}}function N1(J){if(typeof J==="string")return J;if(J instanceof Error)return`${J.name}: ${J.message}`;try{let $=JSON.stringify(J,M4());if($!==void 0)return $}catch{}try{return String(J)}catch{}try{return Object.prototype.toString.call(J)}catch{return`[${typeof J}]`}}function S1(){if(B1||typeof window>"u")return;B1=!0;let J=["log","info","warn","error","debug"];for(let $ of J){let Q=console[$].bind(console);console[$]=(...j)=>{L0($,j.map(N1).join(" ")),Q(...j)}}window.addEventListener("error",($)=>{let Q=$.filename?` (${$.filename}:${$.lineno}:${$.colno})`:"";L0("exception",`${$.message}${Q}`)}),window.addEventListener("unhandledrejection",($)=>{let Q=$.reason instanceof Error?`${$.reason.name}: ${$.reason.message}`:N1($.reason);L0("unhandledrejection",Q)})}function k0(){return H0.map((J)=>({...J}))}var w1=new Set,O1=new Set;function R1(J,$){return J.add($),()=>J.delete($)}function _1(J,$){for(let Q of[...J])Q($)}function A0(J){return R1(w1,J)}function T0(J={type:"manual"}){_1(w1,J)}function x0(J){return R1(O1,J)}function E0(J){_1(O1,J)}var P4=15000,I4=["ResizeObserver loop","Script error.","Non-Error promise rejection captured"],L1=!1,k1=0;function C4(J){return I4.some(($)=>J.includes($))}function A1(J){let $=J.message??"";if(!$||C4($))return;let Q=Date.now();if(Q-k1<P4)return;k1=Q,E0({...J,message:$})}function T1(){if(L1||typeof window>"u")return;L1=!0,window.addEventListener("error",(J)=>{if(!J.message&&!J.error)return;let $=J.error instanceof Error?J.error:null;A1({type:"runtime-error",message:J.message||($?$.message:"Unknown error"),stack:$?.stack})}),window.addEventListener("unhandledrejection",(J)=>{let $=J.reason;A1({type:"unhandledrejection",message:$ instanceof Error?$.message:String($),stack:$ instanceof Error?$.stack:void 0})})}var h1=4000,D4=1e6,q4=1e7,U0=[],x1=0,E1=!1;function m1(J){U0.push(J);while(U0.length>g("maxRequests"))U0.shift()}function g1(){return x1+=1,`req_${x1}`}function f1(J){let $={};if(!J)return $;if(J instanceof Headers)J.forEach((Q,j)=>{$[j]=Q});else if(Array.isArray(J))for(let[Q,j]of J)$[Q]=j;else Object.assign($,J);return $}function B4(J){let $={};return J.forEach((Q,j)=>{$[j]=Q}),$}function N4(J){if(J==null)return null;if(typeof J==="string")return J;if(J instanceof URLSearchParams)return J.toString();if(typeof FormData<"u"&&J instanceof FormData)return`[FormData: ${Array.from(J.keys()).join(", ")}]`;if(typeof Blob<"u"&&J instanceof Blob)return`[Blob ${J.size} bytes]`;if(J instanceof ArrayBuffer)return`[ArrayBuffer ${J.byteLength} bytes]`;return"[binary]"}function S4(J,$){let Q="",j="GET",z={},K=null;if(typeof J==="string")Q=J;else if(J instanceof URL)Q=J.toString();else Q=J.url,j=J.method||j,z=f1(J.headers);if($){if($.method)j=$.method;if($.headers)z={...z,...f1($.headers)};if($.body!==void 0)K=N4($.body)}return{method:j.toUpperCase(),url:Q,headers:z,body:K}}function y1(J){return!W1(J)}function w4(J,$){if(y1($.url)){$.responseSnippet="[body not captured for this origin]";return}let Q=J.headers.get("content-type")??"",j=Number(J.headers.get("content-length")??"0"),z=j?`, ~${j} bytes`:"";if(!/json|text|xml|html|javascript|urlencoded/i.test(Q)){$.responseSnippet=`[binary ${Q||"unknown"}${z}]`;return}if(j>D4){$.responseSnippet=`[response ${Q||"text"}${z} — omitted]`;return}try{J.clone().text().then((K)=>{$.responseSnippet=r(K,g("maxBodyChars"))}).catch(()=>{})}catch{}}function b1(J,$){if(/[?&]_rsc=/.test(J))return!0;for(let Q of Object.keys($)){let j=Q.toLowerCase();if(j==="rsc"||j==="next-router-prefetch"||j==="next-router-state-tree")return!0}return!1}function O4(){if(typeof window>"u"||typeof window.fetch!=="function")return;let J=window.fetch.bind(window);window.fetch=Object.assign(async($,Q)=>{let j=S4($,Q);if(b1(j.url,j.headers))return J($,Q);let z={id:g1(),startedAt:new Date().toISOString(),method:j.method,url:f(j.url),requestHeaders:o(j.headers),requestBody:r(j.body,h1),status:null,statusText:null,durationMs:null,via:"fetch"};m1(z);let K=performance.now();try{let W=await J($,Q);return z.status=W.status,z.statusText=W.statusText,z.durationMs=Math.round(performance.now()-K),z.responseHeaders=o(B4(W.headers)),w4(W,z),W}catch(W){throw z.durationMs=Math.round(performance.now()-K),z.error=W instanceof Error?`${W.name}: ${W.message}`:String(W),W}},J)}function R4(){if(typeof window>"u"||typeof window.XMLHttpRequest!=="function")return;let J=XMLHttpRequest.prototype,$=J.open,Q=J.send,j=function(K,W){let G=typeof W==="string"?W:W.toString();return this.__lwEntry=b1(G,{})?void 0:{id:g1(),startedAt:"",method:(K||"GET").toUpperCase(),url:f(G),requestHeaders:{},requestBody:null,status:null,statusText:null,durationMs:null,via:"xhr"},$.apply(this,arguments)},z=function(K){let W=this.__lwEntry;if(W){W.startedAt=new Date().toISOString(),W.requestBody=typeof K==="string"?r(K,h1):K==null?null:"[non-string body]";let G=performance.now();m1(W),this.addEventListener("loadend",()=>{if(W.status=this.status||null,W.statusText=this.statusText||null,W.durationMs=Math.round(performance.now()-G),y1(W.url))W.responseSnippet="[body not captured for this origin]";else if(this.responseType===""||this.responseType==="text")try{W.responseSnippet=r(this.responseText||"",g("maxBodyChars"))}catch{}else{let F=this.getResponseHeader("content-type")??this.responseType;W.responseSnippet=`[binary ${F}]`}})}return Q.apply(this,arguments)};J.open=j,J.send=z}function v1(){if(E1)return;E1=!0,O4(),R4()}function f0(){let J=U0.map((Q)=>({...Q})),$=0;for(let Q=J.length-1;Q>=0;Q-=1){let j=J[Q],z=j?.responseSnippet;if(!j||typeof z!=="string"||z.length===0)continue;if($+z.length>q4)j.responseSnippet=`[response omitted — report size budget reached (${z.length.toLocaleString()} chars)]`;else $+=z.length}return J}var _4=4,p1=3,L4=4000,k4="[data-debug-reporter]",A4=()=>import("@rrweb/record");var T=[],a=null,M0=!1;function u1(){if(typeof window>"u"||a||M0)return;let J=z0();if(!J)return;M0=!0;let $=()=>void T4(J);if("requestIdleCallback"in window)window.requestIdleCallback($,{timeout:3000});else setTimeout($,1000)}async function T4(J){let $;try{$=(await A4()).record}catch(Q){M0=!1,console.warn("[debug-capture] session replay could not start:",Q);return}if(a)return;try{a=$({emit:(Q)=>x4(Q),checkoutEveryNms:Math.max(1000,J.seconds*1000/2),checkoutEveryNth:L4,maskAllInputs:J.maskInputs,maskTextSelector:J.maskText?"*":J.maskTextSelector,blockSelector:`${J.blockSelector}, ${k4}`,slimDOMOptions:"all",inlineStylesheet:!0,sampling:{mousemove:50,scroll:150,media:800,input:"last",...J.canvas?{canvas:J.canvas.fps}:{}},recordCanvas:J.canvas!==null,...J.canvas?{dataURLOptions:{type:"image/webp",quality:J.canvas.quality}}:{},errorHandler:()=>!0})??null}catch(Q){console.warn("[debug-capture] session replay could not start:",Q)}finally{M0=!1}}function x4(J){if(J.type===_4||T.length===0){if(T.push([]),T.length>p1)T=T.slice(-p1)}T[T.length-1].push(J)}function h0(J=Date.now()){let $=z0();if(!$||!T.length)return null;let Q=J-$.seconds*1000,j=T.length-1;while(j>0&&(T[j][0]?.timestamp??J)>Q)j-=1;let z=T.slice(j).flat(),K=z[0]?.timestamp,W=z[z.length-1]?.timestamp;if(K===void 0||W===void 0)return null;return{events:z,startedAt:new Date(K).toISOString(),endedAt:new Date(W).toISOString(),durationMs:Math.max(0,W-K)}}function E4(){return a!==null}function f4(){a?.(),a=null,T=[]}var h4={title:"รายงานปัญหา",summaryLabel:"หัวข้อปัญหา",summaryRequired:"(ต้องกรอกก่อนแจ้งปัญหา)",summaryPlaceholder:"สรุปปัญหาสั้น ๆ เช่น กดบันทึกร่างแล้ว error",detailLabel:"อธิบายปัญหา (ไม่บังคับ)",detailPlaceholder:"เกิดอะไรขึ้น? กำลังทำอะไรอยู่ตอนที่พบปัญหา?",annotateTitle:"วาดบนรูป",annotateHint:"ทำเครื่องหมายจุดที่มีปัญหาก่อนแนบ — วงกรอบ ชี้ลูกศร ไฮไลต์ หรือพิมพ์ข้อความ",annotateApply:"ใช้รูปนี้",cancel:"ยกเลิก",toolRect:"กรอบ",toolArrow:"ลูกศร",toolHighlight:"ไฮไลต์",toolText:"ข้อความ",deleteSelected:"ลบที่เลือก",clearAll:"ล้างทั้งหมด",annotateHelp:"เลือกเครื่องมือแล้วลากบนรูป · ไม่ได้เลือกเครื่องมือ = ย้าย/ปรับขนาดสิ่งที่วาดไว้ · กดกากบาทมุมขวาบนของรูปทรงเพื่อลบ",capturing:"กำลังเก็บภาพหน้าจอ…",noScreenshot:"ไม่มีภาพหน้าจอ — ยังส่งรายงานได้",cancelled:"ยกเลิกการเก็บภาพหน้าจอแล้ว",close:"ปิด",submit:"แจ้งปัญหา",submitting:"กำลังส่ง…",submitted:"แจ้งปัญหาสำเร็จ",crashed:"เกิดข้อผิดพลาดในระบบ",crashAction:"แจ้งปัญหา",failed:"ส่งรายงานไม่สำเร็จ",captured:"เก็บข้อมูลแล้ว",reporter:"ผู้แจ้ง",page:"หน้า",replay:"บันทึกการใช้งาน",handoffTitle:"กำลังพาไปที่ระบบแจ้งปัญหา",handoffBody:"ระบบจะลงชื่อเข้าใช้ให้อัตโนมัติ เพื่อดูเรื่องที่คุณแจ้งไว้",handoffGo:"ไปเลย",handoffPreparing:"กำลังเตรียม…",handoffFailed:"เปิดรายการที่แจ้งไว้ไม่สำเร็จ",handoffBlocked:"เบราว์เซอร์บล็อกการเปิดแท็บใหม่",handoffOpen:"เปิดในแท็บใหม่"},m4={title:"Report a problem",summaryLabel:"Summary",summaryRequired:"(required)",summaryPlaceholder:"One line, e.g. saving a draft returns an error",detailLabel:"Details (optional)",detailPlaceholder:"What happened? What were you doing at the time?",annotateTitle:"Draw on the image",annotateHint:"Mark what went wrong before attaching — box it, point at it, highlight it, or type on it",annotateApply:"Use this image",cancel:"Cancel",toolRect:"Box",toolArrow:"Arrow",toolHighlight:"Highlight",toolText:"Text",deleteSelected:"Delete selected",clearAll:"Clear all",annotateHelp:"Pick a tool and drag on the image · no tool selected = move/resize what you drew · press the ✕ on a shape to delete it",capturing:"Capturing the screen…",noScreenshot:"No screenshot — you can still send the report",cancelled:"Screen capture cancelled",close:"Close",submit:"Send report",submitting:"Sending…",submitted:"Report sent",crashed:"Something went wrong",crashAction:"Report it",failed:"Could not send the report",captured:"Captured",reporter:"Reporter",page:"Page",replay:"activity log",handoffTitle:"Opening the support portal",handoffBody:"You will be signed in automatically to see what you reported",handoffGo:"Go now",handoffPreparing:"Preparing…",handoffFailed:"Could not open your reports",handoffBlocked:"Your browser blocked the new tab",handoffOpen:"Open in a new tab"};function d(J){return J==="en"?m4:h4}var g4="lw-debug-toasts",y4=6000,b4=`
|
|
2
2
|
:host { all: initial; }
|
|
3
3
|
.stack {
|
|
4
4
|
position: fixed; top: 16px; right: 16px; z-index: 2147483001;
|
|
@@ -30,7 +30,7 @@ var q2=((J)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(J,{get:($,Q)=
|
|
|
30
30
|
}
|
|
31
31
|
@keyframes in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
|
|
32
32
|
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }
|
|
33
|
-
`,m0=null;function v4(){if(typeof document>"u")return null;if(m0?.isConnected)return m0;let J=document.createElement(g4);J.dataset.debugReporter="true";let $=J.attachShadow({mode:"open"}),Q=document.createElement("style");Q.textContent=b4;let j=document.createElement("div");return j.className="stack",j.setAttribute("role","status"),j.setAttribute("aria-live","polite"),$.append(Q,j),document.body.append(J),m0=j,j}function t(J,$="success",Q){let j=j0()?S().toast:void 0;if(j){j({message:J,tone:$,...Q?{action:Q}:{}});return}let z=v4();if(!z)return;let K=document.createElement("div");K.className="toast",K.dataset.tone=$;let W=document.createElement("span");W.className="dot";let G=document.createElement("span");G.textContent=J;let F=document.createElement("button");F.type="button",F.className="close",F.textContent="✕",F.setAttribute("aria-label","ปิด");let M=()=>{window.clearTimeout(B),K.remove()};F.addEventListener("click",M);let B=$==="error"||Q?0:window.setTimeout(M,y4);if(K.append(W,G),Q){let P=document.createElement("button");P.type="button",P.className="action",P.textContent=Q.label,P.addEventListener("click",()=>{M(),Q.onClick()}),K.append(P)}K.append(F),z.append(K)}function d1(J,$,Q){let j=J.filter((K)=>Boolean(K.error)||K.status!=null&&K.status>=400).slice(-20).map((K)=>({method:K.method,url:K.url,status:K.status,error:K.error,at:K.startedAt})),z=$.filter((K)=>K.level==="error"||K.level==="exception"||K.level==="unhandledrejection").slice(-20).map((K)=>K.message);return{failedRequests:j,errors:z,erroredQueries:Q.slice(0,20)}}function c1(J){return J.failedRequests.length+J.errors.length+J.erroredQueries.length}function p4(){let J={memoryUsedMb:null,memoryLimitMb:null,domContentLoadedMs:null,loadEventMs:null};if(typeof performance>"u")return J;let $=performance.memory;if($)J.memoryUsedMb=Math.round($.usedJSHeapSize/1024/1024),J.memoryLimitMb=Math.round($.jsHeapSizeLimit/1024/1024);let[Q]=performance.getEntriesByType("navigation");if(Q)J.domContentLoadedMs=Math.round(Q.domContentLoadedEventEnd),J.loadEventMs=Math.round(Q.loadEventEnd);return J}function g0(J,$){if(!J)return $;try{return J()}catch{return $}}function i1(){let J=S(),{pathname:$,search:Q,href:j}=window.location;return{capturedAt:new Date().toISOString(),route:{href:j,pathname:$,search:Q},module:Z1($),user:g0(J.user,{}),apiHeaders:o(g0(J.headers,{})),app:{name:m().name,version:m().version,environment:m().environment},client:{userAgent:navigator.userAgent,language:navigator.language,platform:navigator.platform,online:navigator.onLine,viewport:{width:window.innerWidth,height:window.innerHeight,dpr:window.devicePixelRatio},screen:{width:window.screen.width,height:window.screen.height}},performance:p4(),extra:g0(J.extra,{})}}var u4=2,d4={manual:"ผู้ใช้แจ้งเอง","runtime-error":"ข้อผิดพลาด runtime (auto)",unhandledrejection:"Promise rejection (auto)","framework-error":"หน้าจอค้าง/พัง (auto)"};function y0(J){let $=f0(),Q=
|
|
33
|
+
`,m0=null;function v4(){if(typeof document>"u")return null;if(m0?.isConnected)return m0;let J=document.createElement(g4);J.dataset.debugReporter="true";let $=J.attachShadow({mode:"open"}),Q=document.createElement("style");Q.textContent=b4;let j=document.createElement("div");return j.className="stack",j.setAttribute("role","status"),j.setAttribute("aria-live","polite"),$.append(Q,j),document.body.append(J),m0=j,j}function t(J,$="success",Q){let j=j0()?S().toast:void 0;if(j){j({message:J,tone:$,...Q?{action:Q}:{}});return}let z=v4();if(!z)return;let K=document.createElement("div");K.className="toast",K.dataset.tone=$;let W=document.createElement("span");W.className="dot";let G=document.createElement("span");G.textContent=J;let F=document.createElement("button");F.type="button",F.className="close",F.textContent="✕",F.setAttribute("aria-label","ปิด");let M=()=>{window.clearTimeout(B),K.remove()};F.addEventListener("click",M);let B=$==="error"||Q?0:window.setTimeout(M,y4);if(K.append(W,G),Q){let P=document.createElement("button");P.type="button",P.className="action",P.textContent=Q.label,P.addEventListener("click",()=>{M(),Q.onClick()}),K.append(P)}K.append(F),z.append(K)}function d1(J,$,Q){let j=J.filter((K)=>Boolean(K.error)||K.status!=null&&K.status>=400).slice(-20).map((K)=>({method:K.method,url:K.url,status:K.status,error:K.error,at:K.startedAt})),z=$.filter((K)=>K.level==="error"||K.level==="exception"||K.level==="unhandledrejection").slice(-20).map((K)=>K.message);return{failedRequests:j,errors:z,erroredQueries:Q.slice(0,20)}}function c1(J){return J.failedRequests.length+J.errors.length+J.erroredQueries.length}function p4(){let J={memoryUsedMb:null,memoryLimitMb:null,domContentLoadedMs:null,loadEventMs:null};if(typeof performance>"u")return J;let $=performance.memory;if($)J.memoryUsedMb=Math.round($.usedJSHeapSize/1024/1024),J.memoryLimitMb=Math.round($.jsHeapSizeLimit/1024/1024);let[Q]=performance.getEntriesByType("navigation");if(Q)J.domContentLoadedMs=Math.round(Q.domContentLoadedEventEnd),J.loadEventMs=Math.round(Q.loadEventEnd);return J}function g0(J,$){if(!J)return $;try{return J()}catch{return $}}function i1(){let J=S(),{pathname:$,search:Q,href:j}=window.location;return{capturedAt:new Date().toISOString(),route:{href:j,pathname:$,search:Q},module:Z1($),user:g0(J.user,{}),apiHeaders:o(g0(J.headers,{})),app:{name:m().name,version:m().version,environment:m().environment},client:{userAgent:navigator.userAgent,language:navigator.language,platform:navigator.platform,online:navigator.onLine,viewport:{width:window.innerWidth,height:window.innerHeight,dpr:window.devicePixelRatio},screen:{width:window.screen.width,height:window.screen.height}},performance:p4(),extra:g0(J.extra,{})}}var u4=2,d4={manual:"ผู้ใช้แจ้งเอง","runtime-error":"ข้อผิดพลาด runtime (auto)",unhandledrejection:"Promise rejection (auto)","framework-error":"หน้าจอค้าง/พัง (auto)"};function y0(J){let $=f0(),Q=k0();return{context:i1(),reason:J.reason,note:J.note,cause:d1($,Q,J.erroredQueries),actionTrail:_0(),network:$,console:Q,screenshotDataUrl:J.screenshotDataUrl,screenshotMethod:J.screenshotMethod,replay:h0()??void 0,meta:{generatedBy:"lightwork-debug-capture",schemaVersion:u4}}}function l1(J){return J.replace(/'/g,"'\\''")}function o1(J){let $=[`curl -X ${J.method} '${J.url}'`];for(let[Q,j]of Object.entries(J.requestHeaders))$.push(` -H '${Q}: ${l1(j)}'`);if(J.requestBody)$.push(` --data '${l1(J.requestBody)}'`);return $.join(" \\\n")}function c4(J){if(J.error)return`ERR ${J.error}`;return`${J.status??"—"} ${J.statusText??""}`.trim()}function i4(J){if(J.length===0)return"No network activity captured.";return J.map(($)=>{let Q=$.durationMs!=null?`${$.durationMs}ms`:"—",j=`# [${c4($)}] ${$.method} ${$.url} (${Q}, ${$.startedAt})`,z=$.responseSnippet?`
|
|
34
34
|
# response: ${$.responseSnippet}`:"";return`${j}
|
|
35
35
|
${o1($)}${z}`}).join(`
|
|
36
36
|
|
|
@@ -121,7 +121,7 @@ canvas { width: 100%; height: auto; display: block; border: 1px solid #e2e8f0; b
|
|
|
121
121
|
border-radius: 0 0 16px 16px;
|
|
122
122
|
}
|
|
123
123
|
.foot .grow { flex: 1; }
|
|
124
|
-
`;var J0="lw-debug-reporter",V2=()=>[];function
|
|
124
|
+
`;var J0="lw-debug-reporter",V2=()=>[];function k6(J){V2=J}var A6=[{tool:"rect",key:"toolRect"},{tool:"arrow",key:"toolArrow"},{tool:"highlight",key:"toolHighlight"},{tool:"text",key:"toolText"}];function T6(){return class extends HTMLElement{root;stop=null;annotator=null;bundle=null;busy=!1;constructor(){super();this.root=this.attachShadow({mode:"open"})}connectedCallback(){this.dataset.debugReporter="true",this.stop=A0(($)=>void this.open($))}disconnectedCallback(){this.stop?.(),this.stop=null,this.close()}async open($){if(this.busy)return;this.busy=!0;let Q=d(S().locale),j=await b0();if(j.method==="cancelled"){this.close();return}this.bundle=y0({reason:$,note:"",screenshotDataUrl:j.dataUrl,screenshotMethod:j.method,erroredQueries:x6()}),this.renderForm(Q)}close(){this.annotator?.destroy(),this.annotator=null,this.bundle=null,this.busy=!1,this.root.replaceChildren()}shell($){let Q=document.createElement("style");Q.textContent=G2;let j=document.createElement("div");j.className="backdrop";let z=document.createElement("div");return z.className="panel",z.setAttribute("role","dialog"),z.setAttribute("aria-modal","true"),z.setAttribute("aria-label",$.title),j.append(z),this.root.replaceChildren(Q,j),z}renderShell($,Q){let j=this.shell($),z=k("div","head");z.append(k("h2","",$.title)),j.append(z,k("p","status",Q))}renderForm($){let Q=this.bundle;if(!Q)return;let j=this.shell($),z=k("div","head"),K=e("✕","icon");K.setAttribute("aria-label",$.close),K.addEventListener("click",()=>this.close()),z.append(k("h2","",$.title),K);let W=document.createElement("input");W.type="text",W.placeholder=$.summaryPlaceholder;let G=s0($.summaryLabel,$.summaryRequired,!0),F=document.createElement("textarea");F.placeholder=$.detailPlaceholder;let M=k("div","meta");M.innerHTML="";let{context:B}=Q;for(let[R,_]of[[$.reporter,`${B.user.fullName??"—"} (${B.user.email??"—"})`],[$.page,B.route.href],[$.captured,`${Q.network.length} network · ${Q.console.length} console · ${Q.actionTrail.length} actions${Q.replay?` · ${$.replay} ${Math.round(Q.replay.durationMs/1000)}s`:""}`]]){let q=document.createElement("div"),O=document.createElement("b");O.textContent=`${R}: `,q.append(O,document.createTextNode(_)),M.append(q)}let P=k("p","status",""),I=e($.submit,"primary");if(I.disabled=!0,W.addEventListener("input",()=>{I.disabled=W.value.trim().length===0}),j.append(z,G,W,s0($.detailLabel),F,M),Q.screenshotDataUrl)j.append(...this.screenshotSection($,Q.screenshotDataUrl));else j.append(k("p","status",$.noScreenshot));let w=k("div","foot"),D=e($.close);D.addEventListener("click",()=>this.close()),w.append(D,P,k("span","grow"),I),j.append(w),I.addEventListener("click",async()=>{I.disabled=!0,P.dataset.tone="",P.textContent=$.submitting;try{let R=await i0(W.value.trim(),{...Q,note:F.value,screenshotDataUrl:this.annotator?.hasShapes()?this.annotator.toDataUrl():Q.screenshotDataUrl}),_=this.dispatchEvent(new CustomEvent("lw-report-submitted",{detail:R,bubbles:!0,composed:!0,cancelable:!0}));if(this.close(),_)t(`${$.submitted} — #${R.number}`,"success")}catch(R){let _=R instanceof Error?R.message:$.failed;P.dataset.tone="error",P.textContent=_,t(`${$.failed} — ${_}`,"error"),I.disabled=!1}}),W.focus()}screenshotSection($,Q){let j=s0($.annotateHint),z=k("div","tools"),K=document.createElement("canvas"),W=k("div","shot");W.append(K);let G=[],F=(I)=>{for(let w of G)w.setAttribute("aria-pressed",String(w===I))};for(let{tool:I,key:w}of A6){let D=e($[w]);D.setAttribute("aria-pressed","false"),D.addEventListener("click",()=>{let R=D.getAttribute("aria-pressed")==="true";F(R?null:D),this.annotator?.setTool(R?null:I)}),G.push(D),z.append(D)}z.append(k("span","sep"));let M=e($.deleteSelected);M.addEventListener("click",()=>this.annotator?.deleteSelected());let B=e($.clearAll);B.addEventListener("click",()=>{this.annotator?.clear(),F(null)}),z.append(M,B);let P=new Image;return P.onload=()=>{K.width=P.naturalWidth,K.height=P.naturalHeight,this.annotator=r0(K,P,()=>{F(null),M.disabled=!this.annotator?.hasSelection()})},P.src=Q,[j,z,k("p","status",$.annotateHelp),W]}}}function x6(){try{return V2()}catch{return[]}}function k(J,$="",Q=""){let j=document.createElement(J);if($)j.className=$;if(Q)j.textContent=Q;return j}function e(J,$=""){let Q=document.createElement("button");if(Q.type="button",Q.textContent=J,$)Q.className=$;return Q}function s0(J,$="",Q=!1){let j=document.createElement("label");if(j.append(document.createTextNode(J)),Q){let z=document.createElement("span");z.className="req",z.textContent=" *",j.append(z)}if($){let z=document.createElement("span");z.className="hint",z.textContent=` ${$}`,j.append(z)}return j}function n0(){if(typeof window>"u"||customElements.get(J0))return;customElements.define(J0,T6())}var X2=!1;function E6(J={}){if(X2||typeof window>"u")return;if(!j0()){console.error("[debug-capture] configureDebugCapture() must be called before install");return}if(X2=!0,v1(),S1(),C1(),T1(),u1(),J.ui===!1)return;let $=d(S().locale);if(x0((Q)=>{t(Q.message??$.crashed,"error",{label:$.crashAction,onClick:()=>T0(Q)})}),n0(),!document.querySelector(J0))document.body.append(document.createElement(J0))}var f6=new Set(["error","exception","unhandledrejection"]);function F2(J){if(J.error)return!0;return J.status!==null&&J.status>=400}function a0(J){if(!J)return null;let $=Date.parse(J);return Number.isNaN($)?null:$}function h6(J){try{let{pathname:$}=new URL(J,"http://x");try{return decodeURIComponent($)}catch{return $}}catch{return J.split(/[?#]/)[0]??J}}function m6(J,$,Q){let j=(W)=>({elapsedMs:W,requests:[],failedRequests:[],consoleErrors:[],slowestMs:null});if(J.length===0)return[];let z=J.map((W)=>a0(W.at)),K=(W)=>{for(let G=W+1;G<z.length;G+=1){let F=z[G];if(F!=null)return F}return Number.POSITIVE_INFINITY};return J.map((W,G)=>{let F=z[G]??null,M=(G>0?z[G-1]:null)??null,B=F!==null&&M!==null?Math.max(0,F-M):null;if(F===null)return j(B);let P=F,I=Math.max(P,K(G)),w=(q)=>q!==null&&q>=P&&(q<I||I===Number.POSITIVE_INFINITY),D=$.filter((q)=>w(a0(q.startedAt))),R=Q.filter((q)=>f6.has(q.level)&&w(a0(q.at))),_=D.map((q)=>q.durationMs).filter((q)=>typeof q==="number");return{elapsedMs:B,requests:D,failedRequests:D.filter(F2),consoleErrors:R,slowestMs:_.length>0?Math.max(..._):null}})}function g6(J,$){return J.requests.length===0&&J.consoleErrors.length===0&&(J.elapsedMs===null||J.elapsedMs<$)}function y6(J){if(J<1000)return`${Math.round(J)} มิลลิวินาที`;let $=J/1000;if($<10)return`${$.toFixed(1)} วิ`;if($<60)return`${Math.round($)} วิ`;let Q=Math.floor($/60),j=Math.round($%60);return j===0?`${Q} นาที`:`${Q} นาที ${j} วิ`}var b6="lw-portal-handoff",H2=138.23,v6=`
|
|
125
125
|
:host { all: initial; }
|
|
126
126
|
.backdrop {
|
|
127
127
|
position: fixed; inset: 0; z-index: 2147483002;
|
|
@@ -214,4 +214,4 @@ p { margin: 0; font-size: 13px; line-height: 1.6; color: #475569; }
|
|
|
214
214
|
<button type="button" class="cancel"></button>
|
|
215
215
|
<button type="button" class="go"></button>
|
|
216
216
|
</div>
|
|
217
|
-
</div>`,z.append(W);let G=(q)=>W.querySelector(q),F=G(".card"),M=G(".bar"),B=G(".count"),P=G("h2"),I=G(".body"),w=G(".host"),D=G(".go"),R=G(".cancel");P.textContent=$.handoffTitle,I.textContent=$.handoffBody;try{w.textContent=new URL(S().host).host}catch{w.textContent=""}D.textContent=$.handoffGo,R.textContent=$.cancel,F.style.setProperty("--secs",`${Q}s`),B.textContent=String(Q),document.body.append(j),requestAnimationFrame(()=>W.setAttribute("data-open","1"));let _=document.activeElement;return D.focus({preventScroll:!0}),new Promise((q)=>{let O=!1,y=null,$0=!1,c=Date.now()+Q*1000,h=window.setInterval(()=>{let N=Math.ceil((c-Date.now())/1000);if(B.textContent=String(Math.max(0,N)),Date.now()>=c)L()},100);function b(N){if(O)return;if(O=!0,window.clearInterval(h),document.removeEventListener("keydown",v,!0),W.removeAttribute("data-open"),window.setTimeout(()=>j.remove(),200),!N)_?.focus?.({preventScroll:!0});q()}function D0(N){window.clearInterval(h),M.classList.remove("spinner"),M.style.animation="none",B.textContent="",P.textContent=$.handoffBlocked,I.textContent=$.handoffBody;let E=document.createElement("a");E.className="go",E.href=N,E.target="_blank",E.rel="noopener noreferrer",E.textContent=$.handoffOpen,E.addEventListener("click",()=>b(!0)),D.replaceWith(E),E.focus({preventScroll:!0})}function L(){if(O||$0)return;if(y)return J.go(y)?b(!0):D0(y);window.clearInterval(h),B.textContent="",M.classList.add("spinner"),P.textContent=$.handoffPreparing}function v(N){if(N.key==="Escape")N.stopPropagation(),b(!1)}document.addEventListener("keydown",v,!0),D.addEventListener("click",L),R.addEventListener("click",()=>b(!1)),W.addEventListener("click",(N)=>{if(N.target===W)b(!1)}),J.prepare().then((N)=>{if(y=N,!O&&Date.now()>=c)L()},()=>{$0=!0,window.clearInterval(h),F.classList.add("error"),M.classList.remove("spinner"),M.style.animation="none",B.textContent="",P.textContent=$.handoffFailed,I.textContent=$.handoffBody,D.remove(),R.textContent=$.close})})}var p6="/sso";function I2(J,$,Q){let
|
|
217
|
+
</div>`,z.append(W);let G=(q)=>W.querySelector(q),F=G(".card"),M=G(".bar"),B=G(".count"),P=G("h2"),I=G(".body"),w=G(".host"),D=G(".go"),R=G(".cancel");P.textContent=$.handoffTitle,I.textContent=$.handoffBody;try{w.textContent=new URL(S().host).host}catch{w.textContent=""}D.textContent=$.handoffGo,R.textContent=$.cancel,F.style.setProperty("--secs",`${Q}s`),B.textContent=String(Q),document.body.append(j),requestAnimationFrame(()=>W.setAttribute("data-open","1"));let _=document.activeElement;return D.focus({preventScroll:!0}),new Promise((q)=>{let O=!1,y=null,$0=!1,c=Date.now()+Q*1000,h=window.setInterval(()=>{let N=Math.ceil((c-Date.now())/1000);if(B.textContent=String(Math.max(0,N)),Date.now()>=c)L()},100);function b(N){if(O)return;if(O=!0,window.clearInterval(h),document.removeEventListener("keydown",v,!0),W.removeAttribute("data-open"),window.setTimeout(()=>j.remove(),200),!N)_?.focus?.({preventScroll:!0});q()}function D0(N){window.clearInterval(h),M.classList.remove("spinner"),M.style.animation="none",B.textContent="",P.textContent=$.handoffBlocked,I.textContent=$.handoffBody;let E=document.createElement("a");E.className="go",E.href=N,E.target="_blank",E.rel="noopener noreferrer",E.textContent=$.handoffOpen,E.addEventListener("click",()=>b(!0)),D.replaceWith(E),E.focus({preventScroll:!0})}function L(){if(O||$0)return;if(y)return J.go(y)?b(!0):D0(y);window.clearInterval(h),B.textContent="",M.classList.add("spinner"),P.textContent=$.handoffPreparing}function v(N){if(N.key==="Escape")N.stopPropagation(),b(!1)}document.addEventListener("keydown",v,!0),D.addEventListener("click",L),R.addEventListener("click",()=>b(!1)),W.addEventListener("click",(N)=>{if(N.target===W)b(!1)}),J.prepare().then((N)=>{if(y=N,!O&&Date.now()>=c)L()},()=>{$0=!0,window.clearInterval(h),F.classList.add("error"),M.classList.remove("spinner"),M.style.animation="none",B.textContent="",P.textContent=$.handoffFailed,I.textContent=$.handoffBody,D.remove(),R.textContent=$.close})})}var p6="/sso";function I2(J,$,Q,j){let z=new URL(p6,J.endsWith("/")?J:`${J}/`);if(z.searchParams.set("realm",$),z.searchParams.set("token",Q),j)z.searchParams.set("return",j);return z.toString()}class C0 extends Error{constructor(J="No identity provider is configured, or nobody is signed in"){super(J);this.name="NoIdentityError"}}async function M2(J){let $=S();if(!$.identity)throw new C0;let Q=await $.identity();if(!Q)throw new C0;return I2($.host,$.realmKey,Q,J)}function P2(J,$){if($==="_self")return window.location.assign(J),!0;let Q=window.open(J,"_blank");if(!Q)return!1;try{Q.opener=null}catch{}return!0}async function u6(J={}){if(J.announce===!1){P2(await M2(J.returnTo),J.target);return}await U2({seconds:J.seconds,prepare:()=>M2(J.returnTo),go:($)=>P2($,J.target)})}export{u0 as trimToBudget,o1 as toCurl,h0 as takeReplay,I2 as supportPortalUrl,i0 as submitBundle,f4 as stopReplay,t as showToast,k6 as setErroredQueriesSource,h6 as requestPath,d as reporterStrings,f as redactUrl,l as redactLabel,o as redactHeaders,r as redactBody,c0 as packReplay,u6 as openSupportPortal,A0 as onLaunch,x0 as onCrash,_2 as moduleResolver,T0 as launch,E4 as isReplayRecording,g6 as isQuietStep,F2 as isFailedRequest,j0 as isConfigured,E6 as installDebugCapture,e4 as hasCause,f0 as getNetworkLog,k0 as getConsoleLog,S as getConfig,_0 as getActionTrail,y6 as formatDuration,v0 as errorSignature,E0 as emitCrash,n0 as defineReporterElement,r0 as createAnnotator,m6 as correlateActionTrail,N2 as configureDebugCapture,b0 as captureScreen,n4 as bundleToMarkdown,t4 as bundleFileName,y0 as buildBundle,m as appInfo,O0 as actionCountSuffix,J0 as REPORTER_TAG,t1 as REPLAY_FILENAME,i as REDACTED,C0 as NoIdentityError,p0 as BUNDLE_BUDGET_BYTES};
|
package/dist/portal.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* tested without a browser, and so a host that wants its own link element
|
|
4
4
|
* rather than our button has something to point it at.
|
|
5
5
|
*/
|
|
6
|
-
export declare function supportPortalUrl(host: string, realmKey: string, token: string): string;
|
|
6
|
+
export declare function supportPortalUrl(host: string, realmKey: string, token: string, returnTo?: string): string;
|
|
7
7
|
export declare class NoIdentityError extends Error {
|
|
8
8
|
constructor(message?: string);
|
|
9
9
|
}
|
|
@@ -19,6 +19,16 @@ export interface OpenPortalOptions {
|
|
|
19
19
|
announce?: boolean;
|
|
20
20
|
/** How long the dialog counts down. Default 3. */
|
|
21
21
|
seconds?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Where on the portal to land, as a path — `/me/tickets/<id>` behind a
|
|
24
|
+
* notification about that ticket, say. Without it the person arrives at
|
|
25
|
+
* their ticket list, which is right for a button and wrong for a link that
|
|
26
|
+
* named one ticket: they would then have to find it again.
|
|
27
|
+
*
|
|
28
|
+
* A hint, not a redirect. The portal accepts only a path on itself, under
|
|
29
|
+
* the reporter's own pages, and falls back to the list for anything else.
|
|
30
|
+
*/
|
|
31
|
+
returnTo?: string;
|
|
22
32
|
}
|
|
23
33
|
/**
|
|
24
34
|
* Open the portal, signed in as the current user.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightworkai.official/debug-capture",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.5",
|
|
4
4
|
"description": "Report-a-problem widget: rolling network/console/action capture, optional rrweb session replay, annotated screenshot, and submission to a Lightwork Support host",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/index.mjs",
|
package/src/portal.ts
CHANGED
|
@@ -25,10 +25,13 @@ const PORTAL_PATH = "/sso";
|
|
|
25
25
|
* tested without a browser, and so a host that wants its own link element
|
|
26
26
|
* rather than our button has something to point it at.
|
|
27
27
|
*/
|
|
28
|
-
export function supportPortalUrl(host: string, realmKey: string, token: string): string {
|
|
28
|
+
export function supportPortalUrl(host: string, realmKey: string, token: string, returnTo?: string): string {
|
|
29
29
|
const url = new URL(PORTAL_PATH, host.endsWith("/") ? host : `${host}/`);
|
|
30
30
|
url.searchParams.set("realm", realmKey);
|
|
31
31
|
url.searchParams.set("token", token);
|
|
32
|
+
// Same parameter, same rule, as the OIDC link documented beside this one:
|
|
33
|
+
// a path on the portal, checked there — a host cannot send someone off-site.
|
|
34
|
+
if (returnTo) url.searchParams.set("return", returnTo);
|
|
32
35
|
return url.toString();
|
|
33
36
|
}
|
|
34
37
|
|
|
@@ -51,10 +54,20 @@ export interface OpenPortalOptions {
|
|
|
51
54
|
announce?: boolean;
|
|
52
55
|
/** How long the dialog counts down. Default 3. */
|
|
53
56
|
seconds?: number;
|
|
57
|
+
/**
|
|
58
|
+
* Where on the portal to land, as a path — `/me/tickets/<id>` behind a
|
|
59
|
+
* notification about that ticket, say. Without it the person arrives at
|
|
60
|
+
* their ticket list, which is right for a button and wrong for a link that
|
|
61
|
+
* named one ticket: they would then have to find it again.
|
|
62
|
+
*
|
|
63
|
+
* A hint, not a redirect. The portal accepts only a path on itself, under
|
|
64
|
+
* the reporter's own pages, and falls back to the list for anything else.
|
|
65
|
+
*/
|
|
66
|
+
returnTo?: string;
|
|
54
67
|
}
|
|
55
68
|
|
|
56
69
|
/** Build the destination. Separated so it can run UNDER the countdown. */
|
|
57
|
-
async function prepareUrl(): Promise<string> {
|
|
70
|
+
async function prepareUrl(returnTo?: string): Promise<string> {
|
|
58
71
|
const config = getConfig();
|
|
59
72
|
if (!config.identity) throw new NoIdentityError();
|
|
60
73
|
|
|
@@ -63,7 +76,7 @@ async function prepareUrl(): Promise<string> {
|
|
|
63
76
|
// login screen and we do not know where it is.
|
|
64
77
|
if (!token) throw new NoIdentityError();
|
|
65
78
|
|
|
66
|
-
return supportPortalUrl(config.host, config.realmKey, token);
|
|
79
|
+
return supportPortalUrl(config.host, config.realmKey, token, returnTo);
|
|
67
80
|
}
|
|
68
81
|
|
|
69
82
|
/** False when the browser refused — a popup blocker, almost always. */
|
|
@@ -124,12 +137,12 @@ function navigate(url: string, target: OpenPortalOptions["target"]): boolean {
|
|
|
124
137
|
*/
|
|
125
138
|
export async function openSupportPortal(options: OpenPortalOptions = {}): Promise<void> {
|
|
126
139
|
if (options.announce === false) {
|
|
127
|
-
navigate(await prepareUrl(), options.target);
|
|
140
|
+
navigate(await prepareUrl(options.returnTo), options.target);
|
|
128
141
|
return;
|
|
129
142
|
}
|
|
130
143
|
await showHandoff({
|
|
131
144
|
seconds: options.seconds,
|
|
132
|
-
prepare: prepareUrl,
|
|
145
|
+
prepare: () => prepareUrl(options.returnTo),
|
|
133
146
|
go: (url) => navigate(url, options.target),
|
|
134
147
|
});
|
|
135
148
|
}
|