@lightworkai.official/debug-capture 0.11.0 → 0.11.2
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/dist/debug-capture.js +3 -3
- package/dist/index.mjs +12 -12
- package/package.json +1 -1
- package/src/capture/consoleBuffer.ts +36 -1
package/dist/debug-capture.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(()=>{var l1={maxRequests:60,maxConsoleEntries:120,maxActions:80,maxBodyChars:20000},O=null;function A0($){let j=[];if(!$.host?.trim())j.push("host");if(!$.realmKey?.trim())j.push("realmKey");if(!$.app?.name?.trim())j.push("app.name");if(typeof $.module!=="function")j.push("module");if(j.length)throw Error(`[debug-capture] configureDebugCapture is missing: ${j.join(", ")}. `+"See the README — `module` maps a pathname to the part of your app it belongs to.");O=$}function q(){if(!O)throw Error("[debug-capture] configureDebugCapture() has not been called");return O}function e(){return O!==null}function h(){let $=q().app;return{name:$.name,version:$.version??"0.0.0",environment:$.environment??r1()}}function r1(){if(typeof window>"u")return"unknown";let $=window.location.hostname;if($==="localhost"||$==="127.0.0.1"||$.endsWith(".local"))return"development";return"production"}function L($){let j=O?.capture?.[$];return typeof j==="number"?j:l1[$]}function L0($){let j=O?.module;if(!j)return null;try{return j($)??null}catch{return null}}function $0(){let $=O?.redact;return{headers:$?.headers??[],queryKeys:($?.queryKeys??[]).map((j)=>j.toLowerCase()),bodyKeys:($?.bodyKeys??[]).map((j)=>j.toLowerCase())}}function E0(){return O?.capture?.overlaySelectors??[]}function x0($){if(typeof window>"u")return!1;let j;try{j=new URL($,window.location.href)}catch{return!1}if(n1(j))return!1;if(j.origin===window.location.origin)return!0;return(O?.capture?.bodyOrigins??[]).some((J)=>{try{return new URL(J).origin===j.origin}catch{return!1}})}function n1($){if(!O?.host)return!1;try{if(new URL(O.host).origin!==$.origin)return!1}catch{return!1}return $.pathname.startsWith("/ingest/")}function h0($){let j=Object.entries($).map(([J,Q])=>[J.replace(/\/+$/,"")||"/",Q]).sort((J,Q)=>Q[0].length-J[0].length);return(J)=>{let Q=(J||"/").replace(/\/+$/,"")||"/";for(let[z,W]of j)if(Q===z||Q.startsWith(`${z}/`))return{key:z,label:W};return null}}var v="‹redacted›",s1=/^(authorization|proxy-authorization|cookie|set-cookie|x-[a-z-]*token|x-csrf[a-z-]*|x-xsrf[a-z-]*)$/i,a1=new Set(["access_token","token","id_token","refresh_token","code","secret","client_secret","password","apikey","api_key","signature","x-amz-signature","x-amz-credential"]),t1=/(password|passwd|token|secret|authorization|refresh|client_secret|otp|pin)/i,e1=/[\w.+-]+@[\w-]+\.[\w.-]+/g,$2=/\d(?:[\d\s-]{7,})\d/g;function b($){return $.replace(e1,v).replace($2,v)}function j2($){if(s1.test($))return!0;return $0().headers.some((J)=>J.toLowerCase()===$.toLowerCase())}function u($){let j={};for(let[J,Q]of Object.entries($))j[J]=j2(J)?v:Q;return j}function d($){try{let j=/^https?:\/\//i.test($),J=new URL($,j?void 0:"http://local.invalid"),Q=!1;if(J.searchParams.forEach((z,W)=>{if(a1.has(W.toLowerCase())||$0().queryKeys.includes(W.toLowerCase()))J.searchParams.set(W,v),Q=!0}),!Q)return $;return j?J.toString():`${J.pathname}${J.search}`}catch{return $}}function Y0($,j){if(j>6||$===null||typeof $!=="object")return $;if(Array.isArray($))return $.map((Q)=>Y0(Q,j+1));let J={};for(let[Q,z]of Object.entries($)){let W=t1.test(Q)||$0().bodyKeys.some((V)=>Q.toLowerCase().includes(V));J[Q]=W?v:Y0(z,j+1)}return J}function i($,j){if($==null)return null;let J=$,Q=$.trim();if(Q.startsWith("{")||Q.startsWith("["))try{let z=JSON.parse(Q);J=JSON.stringify(Y0(z,0))}catch{}if(J.length>j)return`${J.slice(0,j)}… [truncated ${J.length-j} chars]`;return J}var F0=120,w0=40,m=($,j)=>$.length>j?`${$.slice(0,j)}…`:$,M0=($)=>{try{return decodeURIComponent($)}catch{return $}},p=[],p0=0,m0=!1;function o($,j,J,Q){let z=m(j,F0),W=p[p.length-1];if($==="navigate"&&W?.kind==="click"){let F=z.replace(/^ไปที่\s*/,"");if(W.detail.includes(`→ ${F}`))return W.at=new Date().toISOString(),W;let w=F.split(/[?#]/)[0]??F,H=W.source?M0(W.source.replace(/^→\s*/,"")).split(/[?#]/)[0]:null;if(H&&(w===H||w.startsWith(H)))return W.detail=m(`${W.detail} → ${F}`,F0),W.source=void 0,W.at=new Date().toISOString(),W}if(W&&W.kind===$&&W.detail===z){if(W.at=new Date().toISOString(),$!=="navigate")W.count=(W.count??1)+1;return W}p0+=1;let V={id:`act_${p0}`,at:new Date().toISOString(),kind:$,detail:z,count:1,source:J,html:J0(Q)};p.push(V);while(p.length>L("maxActions"))Q2(p.shift());return V}var J2=200000,c=0;function J0($){if(!$)return;if(c+$.length>J2)return;return c+=$.length,$}function Q2($){if(!$)return;if(c-=($.html?.length??0)+($.afterHtml?.length??0),c<0)c=0}function j0($){return $ instanceof Element&&Boolean($.closest("[data-debug-reporter]"))}var z2='button, a[href], [role="button"], [role="tab"], [role="menuitem"], [role="option"], [role="switch"], [role="checkbox"], [role="radio"], [role="link"], summary, input, select, textarea',Z2={button:"ปุ่ม",a:"ลิงก์",input:"ช่อง",textarea:"ช่อง",select:"ตัวเลือก",summary:"ส่วนขยาย"},g0={button:"ปุ่ม",tab:"แท็บ",menuitem:"เมนู",option:"ตัวเลือก",switch:"สวิตช์",checkbox:"ช่องเลือก",radio:"ตัวเลือก",link:"ลิงก์"};function W2($){let j=$.getAttribute("role");if(j&&g0[j])return g0[j];return Z2[$.tagName.toLowerCase()]??"ปุ่ม"}function K2($,j){try{let J=$,Q=0;while(J&&Q<=j){let z=i0(J);if(z&&typeof z.memoizedProps?.onClick==="function")return J;J=J.parentElement,Q+=1}}catch{}return null}function V2($){let j=$.getAttribute("aria-label")?.trim();if(j)return j;let J=$.getAttribute("title")?.trim();if(J)return J;if($ instanceof HTMLInputElement||$ instanceof HTMLTextAreaElement||$ instanceof HTMLSelectElement)return($.getAttribute("placeholder")||$.getAttribute("name")||"").trim();if($ instanceof HTMLImageElement)return($.getAttribute("alt")||"").trim();let Q=($.textContent??"").replace(/\s+/g," ").trim();if(Q)return Q;if($ instanceof HTMLAnchorElement){let z=$.getAttribute("href");if(z?.startsWith("/"))return M0(z)}return""}function G2($){if(!($ instanceof Element))return null;let j=$.closest(z2)??K2($,4);if(!j)return null;let J=j.tagName.toLowerCase();if(J==="html"||J==="body")return null;return j}function X2($){let j=b(V2($));if(!j)return null;return`${W2($)} “${m(j,w0)}”`}var d0=6000,Y2=4000,F2=/(?:^|\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 w2($){$.querySelectorAll("script, style, link, iframe, object, embed, noscript, canvas, video, audio").forEach((z)=>z.remove());let j=[$,...Array.from($.querySelectorAll("*"))];for(let z of j){for(let V of Array.from(z.attributes)){let F=V.name.toLowerCase();if(F.startsWith("on")||F==="srcdoc"||F==="value"||F.startsWith("data-"))z.removeAttribute(V.name)}if(z instanceof HTMLAnchorElement)z.setAttribute("href","#");if(z instanceof HTMLImageElement)z.removeAttribute("src");let W=z.getAttribute("class");if(W){let V=W.replace(F2," ").replace(/\s+/g," ").trim();if(V)z.setAttribute("class",V);else z.removeAttribute("class")}}let J=document.createTreeWalker($,NodeFilter.SHOW_TEXT),Q=J.nextNode();while(Q){if(Q.nodeValue)Q.nodeValue=b(Q.nodeValue);Q=J.nextNode()}}function H0($,j,J){try{let Q=$.outerHTML;if(!Q||Q.length>j)return;let z=$.cloneNode(!0);w2(z);let W=z.outerHTML;return W&&W.length<=J?W:void 0}catch{return}}var M2=($)=>H0($,d0,Y2),H2=150000,I2=40000,y0=($)=>H0($,H2,I2);function U2($){if(!($ instanceof HTMLInputElement)&&!($ instanceof HTMLTextAreaElement)&&!($ instanceof HTMLSelectElement))return null;let j=$.name||$.id||$.getAttribute("aria-label")||$.getAttribute("placeholder")||$.tagName.toLowerCase();return`ช่อง “${b(j)}”`}var v0=80;function i0($){let j=Object.keys($).find((J)=>J.startsWith("__reactFiber$")||J.startsWith("__reactInternalInstance$"));return j?$[j]:null}function P2($){if(typeof $!=="function")return null;try{let j=Function.prototype.toString.call($);return(j.match(/\.(?:push|replace)\(\s*['"`]([^'"`]+)['"`]/)??j.match(/redirect\(\s*['"`]([^'"`]+)['"`]/))?.[1]??null}catch{return null}}function b0($){if(!$)return;return`→ ${$.length>v0?`${$.slice(0,v0)}…`:$}`}function C2($){try{let j=$.closest("a[href]")?.getAttribute("href");if(j&&j.startsWith("/"))return b0(j);let J=i0($),Q=0;while(J&&Q<30){if(typeof J.memoizedProps?.onClick==="function")return b0(P2(J.memoizedProps.onClick));J=J.return,Q+=1}return}catch{return}}var N2='[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], [role="status"], [role="alert"]';function q2(){let $=E0();return $.length?$.join(", "):N2}function B2($){let j=$.getAttribute("role");if(j==="status"||j==="alert")return"ข้อความแจ้งเตือน";if(j==="menu")return"เมนู";if(j==="listbox")return"รายการตัวเลือก";if(j==="alertdialog")return"กล่องยืนยัน";return"กล่องโต้ตอบ"}function D2($){let j=$.getAttribute("aria-label")?.trim();if(j)return j;let J=$.getAttribute("aria-labelledby");if(J){let W=J.split(/\s+/).map((V)=>document.getElementById(V)?.textContent?.trim()??"").filter(Boolean).join(" ");if(W)return W}let z=$.querySelector('[data-slot="dialog-title"], h1, h2, h3, [role="heading"]')?.textContent?.replace(/\s+/g," ").trim();if(z)return z;return($.textContent??"").replace(/\s+/g," ").trim()}function o0($){let j=b(D2($)),J=B2($);return j?`เปิด ${J} “${m(j,w0)}”`:`เปิด ${J}`}var k2='[aria-busy="true"], [role="progressbar"], [data-loading="true"], .animate-pulse, .animate-spin',R2=/กำลังโหลด|กำลังค้นหา|กำลังดำเนินการ|\bloading\b/i;function S2($){if($.querySelector(k2))return!0;return R2.test($.textContent??"")}var O2=400,f2=250,_2=8000;function T2($,j){if(typeof MutationObserver>"u"){j.html=J0(y0($));return}let J=Date.now(),Q=!1,z=()=>{Q=!0,V.disconnect(),window.clearInterval(F),window.clearTimeout(w)},W=()=>{if(Q)return;if(z(),!$.isConnected)return;j.detail=m(o0($),F0),j.html=J0(y0($))},V=new MutationObserver(()=>{J=Date.now()});V.observe($,{childList:!0,subtree:!0,attributes:!0,characterData:!0});let F=window.setInterval(()=>{if(Q)return;if(!$.isConnected){z();return}if(Date.now()-J>=O2&&!S2($))W()},f2),w=window.setTimeout(W,_2)}function A2($){if(j0($))return;let j=o("ui",o0($));if(j)T2($,j)}function L2(){if(typeof MutationObserver>"u")return;let $=new WeakSet;new MutationObserver((J)=>{for(let Q of J)for(let z of Array.from(Q.addedNodes)){if(!(z instanceof Element))continue;let W=q2(),V=z.matches(W)?[z]:Array.from(z.querySelectorAll(W));for(let F of V){if($.has(F))continue;$.add(F),A2(F)}}}).observe(document.body,{childList:!0,subtree:!0})}var E2=1600,x2=2500;function u0($){return{disabled:$.hasAttribute("disabled")||$.getAttribute("aria-disabled")==="true",busy:$.getAttribute("aria-busy")==="true",text:m(($.textContent??"").replace(/\s+/g," ").trim(),w0)}}function h2($,j){if(!$.disabled&&j.disabled)return"ปุ่มถูกปิดใช้งานหลังคลิก";if(!$.busy&&j.busy)return"ปุ่มเข้าสู่สถานะกำลังโหลด";if($.text!==j.text&&j.text)return`ข้อความเปลี่ยนเป็น “${j.text}”`;return null}function p2($,j){if(typeof MutationObserver>"u")return;let J=u0($),Q=!1,z=(F,w)=>{if(Q)return;if(Q=!0,W.disconnect(),window.clearTimeout(V),j.afterNote=F,w)j.afterHtml=J0(H0($,d0,x2))},W=new MutationObserver(()=>{if(!$.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}let F=h2(J,u0($));if(F)z(F,!0)});W.observe($,{attributes:!0,attributeFilter:["disabled","aria-disabled","aria-busy","class"],childList:!0,subtree:!0,characterData:!0});let V=window.setTimeout(()=>{if(!Q&&!$.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}Q=!0,W.disconnect()},E2)}function c0(){if(m0||typeof window>"u")return;m0=!0,document.addEventListener("click",(Q)=>{if(j0(Q.target))return;let z=G2(Q.target);if(!z)return;let W=X2(z);if(!W)return;let V=o("click",`คลิก ${W}`,C2(z),M2(z));if(V)p2(z,V)},{capture:!0,passive:!0}),document.addEventListener("change",(Q)=>{if(j0(Q.target))return;let z=U2(Q.target);if(z)o("input",`แก้ไข ${z}`)},{capture:!0,passive:!0}),document.addEventListener("submit",(Q)=>{if(j0(Q.target))return;o("submit","ส่งฟอร์ม")},{capture:!0,passive:!0});let $=()=>o("navigate",`ไปที่ ${M0(d(location.pathname+location.search))}`),j=history.pushState.bind(history),J=history.replaceState.bind(history);history.pushState=(...Q)=>{let z=j(...Q);return $(),z},history.replaceState=(...Q)=>{let z=J(...Q);return $(),z},window.addEventListener("popstate",$),L2()}function l0(){return p.map(($)=>({...$}))}var r0=2000,Q0=[],n0=0,s0=!1;function I0($,j){n0+=1,Q0.push({id:`log_${n0}`,at:new Date().toISOString(),level:$,message:j.length>r0?`${j.slice(0,r0)}…`:j});while(Q0.length>L("maxConsoleEntries"))Q0.shift()}function m2(){let $=new WeakSet;return(j,J)=>{if(typeof J==="object"&&J!==null){if($.has(J))return"[Circular]";$.add(J)}if(typeof J==="bigint")return J.toString();return J}}function a0($){if(typeof $==="string")return $;if($ instanceof Error)return`${$.name}: ${$.message}`;try{return JSON.stringify($,m2())??String($)}catch{return String($)}}function t0(){if(s0||typeof window>"u")return;s0=!0;let $=["log","info","warn","error","debug"];for(let j of $){let J=console[j].bind(console);console[j]=(...Q)=>{I0(j,Q.map(a0).join(" ")),J(...Q)}}window.addEventListener("error",(j)=>{let J=j.filename?` (${j.filename}:${j.lineno}:${j.colno})`:"";I0("exception",`${j.message}${J}`)}),window.addEventListener("unhandledrejection",(j)=>{let J=j.reason instanceof Error?`${j.reason.name}: ${j.reason.message}`:a0(j.reason);I0("unhandledrejection",J)})}function e0(){return Q0.map(($)=>({...$}))}var $1=new Set,j1=new Set;function J1($,j){return $.add(j),()=>$.delete(j)}function Q1($,j){for(let J of[...$])J(j)}function z1($){return J1($1,$)}function z0($={type:"manual"}){Q1($1,$)}function Z1($){return J1(j1,$)}function W1($){Q1(j1,$)}var g2=15000,y2=["ResizeObserver loop","Script error.","Non-Error promise rejection captured"],K1=!1,V1=0;function v2($){return y2.some((j)=>$.includes(j))}function G1($){let j=$.message??"";if(!j||v2(j))return;let J=Date.now();if(J-V1<g2)return;V1=J,W1({...$,message:j})}function X1(){if(K1||typeof window>"u")return;K1=!0,window.addEventListener("error",($)=>{if(!$.message&&!$.error)return;let j=$.error instanceof Error?$.error:null;G1({type:"runtime-error",message:$.message||(j?j.message:"Unknown error"),stack:j?.stack})}),window.addEventListener("unhandledrejection",($)=>{let j=$.reason;G1({type:"unhandledrejection",message:j instanceof Error?j.message:String(j),stack:j instanceof Error?j.stack:void 0})})}var M1=4000,b2=1e6,u2=1e7,Z0=[],Y1=0,F1=!1;function H1($){Z0.push($);while(Z0.length>L("maxRequests"))Z0.shift()}function I1(){return Y1+=1,`req_${Y1}`}function w1($){let j={};if(!$)return j;if($ instanceof Headers)$.forEach((J,Q)=>{j[Q]=J});else if(Array.isArray($))for(let[J,Q]of $)j[J]=Q;else Object.assign(j,$);return j}function d2($){let j={};return $.forEach((J,Q)=>{j[Q]=J}),j}function i2($){if($==null)return null;if(typeof $==="string")return $;if($ instanceof URLSearchParams)return $.toString();if(typeof FormData<"u"&&$ instanceof FormData)return`[FormData: ${Array.from($.keys()).join(", ")}]`;if(typeof Blob<"u"&&$ instanceof Blob)return`[Blob ${$.size} bytes]`;if($ instanceof ArrayBuffer)return`[ArrayBuffer ${$.byteLength} bytes]`;return"[binary]"}function o2($,j){let J="",Q="GET",z={},W=null;if(typeof $==="string")J=$;else if($ instanceof URL)J=$.toString();else J=$.url,Q=$.method||Q,z=w1($.headers);if(j){if(j.method)Q=j.method;if(j.headers)z={...z,...w1(j.headers)};if(j.body!==void 0)W=i2(j.body)}return{method:Q.toUpperCase(),url:J,headers:z,body:W}}function U1($){return!x0($)}function c2($,j){if(U1(j.url)){j.responseSnippet="[body not captured for this origin]";return}let J=$.headers.get("content-type")??"",Q=Number($.headers.get("content-length")??"0"),z=Q?`, ~${Q} bytes`:"";if(!/json|text|xml|html|javascript|urlencoded/i.test(J)){j.responseSnippet=`[binary ${J||"unknown"}${z}]`;return}if(Q>b2){j.responseSnippet=`[response ${J||"text"}${z} — omitted]`;return}try{$.clone().text().then((W)=>{j.responseSnippet=i(W,L("maxBodyChars"))}).catch(()=>{})}catch{}}function P1($,j){if(/[?&]_rsc=/.test($))return!0;for(let J of Object.keys(j)){let Q=J.toLowerCase();if(Q==="rsc"||Q==="next-router-prefetch"||Q==="next-router-state-tree")return!0}return!1}function l2(){if(typeof window>"u"||typeof window.fetch!=="function")return;let $=window.fetch.bind(window);window.fetch=Object.assign(async(j,J)=>{let Q=o2(j,J);if(P1(Q.url,Q.headers))return $(j,J);let z={id:I1(),startedAt:new Date().toISOString(),method:Q.method,url:d(Q.url),requestHeaders:u(Q.headers),requestBody:i(Q.body,M1),status:null,statusText:null,durationMs:null,via:"fetch"};H1(z);let W=performance.now();try{let V=await $(j,J);return z.status=V.status,z.statusText=V.statusText,z.durationMs=Math.round(performance.now()-W),z.responseHeaders=u(d2(V.headers)),c2(V,z),V}catch(V){throw z.durationMs=Math.round(performance.now()-W),z.error=V instanceof Error?`${V.name}: ${V.message}`:String(V),V}},$)}function r2(){if(typeof window>"u"||typeof window.XMLHttpRequest!=="function")return;let $=XMLHttpRequest.prototype,j=$.open,J=$.send,Q=function(W,V){let F=typeof V==="string"?V:V.toString();return this.__cibEntry=P1(F,{})?void 0:{id:I1(),startedAt:"",method:(W||"GET").toUpperCase(),url:d(F),requestHeaders:{},requestBody:null,status:null,statusText:null,durationMs:null,via:"xhr"},j.apply(this,arguments)},z=function(W){let V=this.__cibEntry;if(V){V.startedAt=new Date().toISOString(),V.requestBody=typeof W==="string"?i(W,M1):W==null?null:"[non-string body]";let F=performance.now();H1(V),this.addEventListener("loadend",()=>{if(V.status=this.status||null,V.statusText=this.statusText||null,V.durationMs=Math.round(performance.now()-F),U1(V.url))V.responseSnippet="[body not captured for this origin]";else if(this.responseType===""||this.responseType==="text")try{V.responseSnippet=i(this.responseText||"",L("maxBodyChars"))}catch{}else{let w=this.getResponseHeader("content-type")??this.responseType;V.responseSnippet=`[binary ${w}]`}})}return J.apply(this,arguments)};$.open=Q,$.send=z}function C1(){if(F1)return;F1=!0,l2(),r2()}function N1(){let $=Z0.map((J)=>({...J})),j=0;for(let J=$.length-1;J>=0;J-=1){let Q=$[J],z=Q?.responseSnippet;if(!Q||typeof z!=="string"||z.length===0)continue;if(j+z.length>u2)Q.responseSnippet=`[response omitted — report size budget reached (${z.length.toLocaleString()} chars)]`;else j+=z.length}return $}var n2={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:"หน้า",handoffTitle:"กำลังพาไปที่ระบบแจ้งปัญหา",handoffBody:"ระบบจะลงชื่อเข้าใช้ให้อัตโนมัติ เพื่อดูเรื่องที่คุณแจ้งไว้",handoffGo:"ไปเลย",handoffPreparing:"กำลังเตรียม…",handoffFailed:"เปิดรายการที่แจ้งไว้ไม่สำเร็จ",handoffBlocked:"เบราว์เซอร์บล็อกการเปิดแท็บใหม่",handoffOpen:"เปิดในแท็บใหม่"},s2={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",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 W0($){return $==="en"?s2:n2}var a2="lw-debug-toasts",t2=6000,e2=`
|
|
1
|
+
(()=>{var l1={maxRequests:60,maxConsoleEntries:120,maxActions:80,maxBodyChars:20000},S=null;function L0($){let J=[];if(!$.host?.trim())J.push("host");if(!$.realmKey?.trim())J.push("realmKey");if(!$.app?.name?.trim())J.push("app.name");if(typeof $.module!=="function")J.push("module");if(J.length)throw Error(`[debug-capture] configureDebugCapture is missing: ${J.join(", ")}. `+"See the README — `module` maps a pathname to the part of your app it belongs to.");S=$}function N(){if(!S)throw Error("[debug-capture] configureDebugCapture() has not been called");return S}function e(){return S!==null}function h(){let $=N().app;return{name:$.name,version:$.version??"0.0.0",environment:$.environment??r1()}}function r1(){if(typeof window>"u")return"unknown";let $=window.location.hostname;if($==="localhost"||$==="127.0.0.1"||$.endsWith(".local"))return"development";return"production"}function f($){let J=S?.capture?.[$];return typeof J==="number"?J:l1[$]}function f0($){let J=S?.module;if(!J)return null;try{return J($)??null}catch{return null}}function $0(){let $=S?.redact;return{headers:$?.headers??[],queryKeys:($?.queryKeys??[]).map((J)=>J.toLowerCase()),bodyKeys:($?.bodyKeys??[]).map((J)=>J.toLowerCase())}}function E0(){return S?.capture?.overlaySelectors??[]}function x0($){if(typeof window>"u")return!1;let J;try{J=new URL($,window.location.href)}catch{return!1}if(s1(J))return!1;if(J.origin===window.location.origin)return!0;return(S?.capture?.bodyOrigins??[]).some((Q)=>{try{return new URL(Q).origin===J.origin}catch{return!1}})}function s1($){if(!S?.host)return!1;try{if(new URL(S.host).origin!==$.origin)return!1}catch{return!1}return $.pathname.startsWith("/ingest/")}function h0($){let J=Object.entries($).map(([Q,j])=>[Q.replace(/\/+$/,"")||"/",j]).sort((Q,j)=>j[0].length-Q[0].length);return(Q)=>{let j=(Q||"/").replace(/\/+$/,"")||"/";for(let[z,W]of J)if(j===z||j.startsWith(`${z}/`))return{key:z,label:W};return null}}var v="‹redacted›",n1=/^(authorization|proxy-authorization|cookie|set-cookie|x-[a-z-]*token|x-csrf[a-z-]*|x-xsrf[a-z-]*)$/i,a1=new Set(["access_token","token","id_token","refresh_token","code","secret","client_secret","password","apikey","api_key","signature","x-amz-signature","x-amz-credential"]),t1=/(password|passwd|token|secret|authorization|refresh|client_secret|otp|pin)/i,e1=/[\w.+-]+@[\w-]+\.[\w.-]+/g,$2=/\d(?:[\d\s-]{7,})\d/g;function b($){return $.replace(e1,v).replace($2,v)}function J2($){if(n1.test($))return!0;return $0().headers.some((Q)=>Q.toLowerCase()===$.toLowerCase())}function u($){let J={};for(let[Q,j]of Object.entries($))J[Q]=J2(Q)?v:j;return J}function d($){try{let J=/^https?:\/\//i.test($),Q=new URL($,J?void 0:"http://local.invalid"),j=!1;if(Q.searchParams.forEach((z,W)=>{if(a1.has(W.toLowerCase())||$0().queryKeys.includes(W.toLowerCase()))Q.searchParams.set(W,v),j=!0}),!j)return $;return J?Q.toString():`${Q.pathname}${Q.search}`}catch{return $}}function G0($,J){if(J>6||$===null||typeof $!=="object")return $;if(Array.isArray($))return $.map((j)=>G0(j,J+1));let Q={};for(let[j,z]of Object.entries($)){let W=t1.test(j)||$0().bodyKeys.some((V)=>j.toLowerCase().includes(V));Q[j]=W?v:G0(z,J+1)}return Q}function i($,J){if($==null)return null;let Q=$,j=$.trim();if(j.startsWith("{")||j.startsWith("["))try{let z=JSON.parse(j);Q=JSON.stringify(G0(z,0))}catch{}if(Q.length>J)return`${Q.slice(0,J)}… [truncated ${Q.length-J} chars]`;return Q}var X0=120,H0=40,m=($,J)=>$.length>J?`${$.slice(0,J)}…`:$,I0=($)=>{try{return decodeURIComponent($)}catch{return $}},p=[],p0=0,m0=!1;function c($,J,Q,j){let z=m(J,X0),W=p[p.length-1];if($==="navigate"&&W?.kind==="click"){let X=z.replace(/^ไปที่\s*/,"");if(W.detail.includes(`→ ${X}`))return W.at=new Date().toISOString(),W;let H=X.split(/[?#]/)[0]??X,U=W.source?I0(W.source.replace(/^→\s*/,"")).split(/[?#]/)[0]:null;if(U&&(H===U||H.startsWith(U)))return W.detail=m(`${W.detail} → ${X}`,X0),W.source=void 0,W.at=new Date().toISOString(),W}if(W&&W.kind===$&&W.detail===z){if(W.at=new Date().toISOString(),$!=="navigate")W.count=(W.count??1)+1;return W}p0+=1;let V={id:`act_${p0}`,at:new Date().toISOString(),kind:$,detail:z,count:1,source:Q,html:Q0(j)};p.push(V);while(p.length>f("maxActions"))j2(p.shift());return V}var Q2=200000,o=0;function Q0($){if(!$)return;if(o+$.length>Q2)return;return o+=$.length,$}function j2($){if(!$)return;if(o-=($.html?.length??0)+($.afterHtml?.length??0),o<0)o=0}function J0($){return $ instanceof Element&&Boolean($.closest("[data-debug-reporter]"))}var z2='button, a[href], [role="button"], [role="tab"], [role="menuitem"], [role="option"], [role="switch"], [role="checkbox"], [role="radio"], [role="link"], summary, input, select, textarea',Z2={button:"ปุ่ม",a:"ลิงก์",input:"ช่อง",textarea:"ช่อง",select:"ตัวเลือก",summary:"ส่วนขยาย"},y0={button:"ปุ่ม",tab:"แท็บ",menuitem:"เมนู",option:"ตัวเลือก",switch:"สวิตช์",checkbox:"ช่องเลือก",radio:"ตัวเลือก",link:"ลิงก์"};function W2($){let J=$.getAttribute("role");if(J&&y0[J])return y0[J];return Z2[$.tagName.toLowerCase()]??"ปุ่ม"}function K2($,J){try{let Q=$,j=0;while(Q&&j<=J){let z=i0(Q);if(z&&typeof z.memoizedProps?.onClick==="function")return Q;Q=Q.parentElement,j+=1}}catch{}return null}function V2($){let J=$.getAttribute("aria-label")?.trim();if(J)return J;let Q=$.getAttribute("title")?.trim();if(Q)return Q;if($ instanceof HTMLInputElement||$ instanceof HTMLTextAreaElement||$ instanceof HTMLSelectElement)return($.getAttribute("placeholder")||$.getAttribute("name")||"").trim();if($ instanceof HTMLImageElement)return($.getAttribute("alt")||"").trim();let j=($.textContent??"").replace(/\s+/g," ").trim();if(j)return j;if($ instanceof HTMLAnchorElement){let z=$.getAttribute("href");if(z?.startsWith("/"))return I0(z)}return""}function Y2($){if(!($ instanceof Element))return null;let J=$.closest(z2)??K2($,4);if(!J)return null;let Q=J.tagName.toLowerCase();if(Q==="html"||Q==="body")return null;return J}function F2($){let J=b(V2($));if(!J)return null;return`${W2($)} “${m(J,H0)}”`}var d0=6000,G2=4000,X2=/(?:^|\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 H2($){$.querySelectorAll("script, style, link, iframe, object, embed, noscript, canvas, video, audio").forEach((z)=>z.remove());let J=[$,...Array.from($.querySelectorAll("*"))];for(let z of J){for(let V of Array.from(z.attributes)){let X=V.name.toLowerCase();if(X.startsWith("on")||X==="srcdoc"||X==="value"||X.startsWith("data-"))z.removeAttribute(V.name)}if(z instanceof HTMLAnchorElement)z.setAttribute("href","#");if(z instanceof HTMLImageElement)z.removeAttribute("src");let W=z.getAttribute("class");if(W){let V=W.replace(X2," ").replace(/\s+/g," ").trim();if(V)z.setAttribute("class",V);else z.removeAttribute("class")}}let Q=document.createTreeWalker($,NodeFilter.SHOW_TEXT),j=Q.nextNode();while(j){if(j.nodeValue)j.nodeValue=b(j.nodeValue);j=Q.nextNode()}}function U0($,J,Q){try{let j=$.outerHTML;if(!j||j.length>J)return;let z=$.cloneNode(!0);H2(z);let W=z.outerHTML;return W&&W.length<=Q?W:void 0}catch{return}}var I2=($)=>U0($,d0,G2),U2=150000,M2=40000,g0=($)=>U0($,U2,M2);function P2($){if(!($ instanceof HTMLInputElement)&&!($ instanceof HTMLTextAreaElement)&&!($ instanceof HTMLSelectElement))return null;let J=$.name||$.id||$.getAttribute("aria-label")||$.getAttribute("placeholder")||$.tagName.toLowerCase();return`ช่อง “${b(J)}”`}var v0=80;function i0($){let J=Object.keys($).find((Q)=>Q.startsWith("__reactFiber$")||Q.startsWith("__reactInternalInstance$"));return J?$[J]:null}function w2($){if(typeof $!=="function")return null;try{let J=Function.prototype.toString.call($);return(J.match(/\.(?:push|replace)\(\s*['"`]([^'"`]+)['"`]/)??J.match(/redirect\(\s*['"`]([^'"`]+)['"`]/))?.[1]??null}catch{return null}}function b0($){if(!$)return;return`→ ${$.length>v0?`${$.slice(0,v0)}…`:$}`}function q2($){try{let J=$.closest("a[href]")?.getAttribute("href");if(J&&J.startsWith("/"))return b0(J);let Q=i0($),j=0;while(Q&&j<30){if(typeof Q.memoizedProps?.onClick==="function")return b0(w2(Q.memoizedProps.onClick));Q=Q.return,j+=1}return}catch{return}}var B2='[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], [role="status"], [role="alert"]';function N2(){let $=E0();return $.length?$.join(", "):B2}function D2($){let J=$.getAttribute("role");if(J==="status"||J==="alert")return"ข้อความแจ้งเตือน";if(J==="menu")return"เมนู";if(J==="listbox")return"รายการตัวเลือก";if(J==="alertdialog")return"กล่องยืนยัน";return"กล่องโต้ตอบ"}function C2($){let J=$.getAttribute("aria-label")?.trim();if(J)return J;let Q=$.getAttribute("aria-labelledby");if(Q){let W=Q.split(/\s+/).map((V)=>document.getElementById(V)?.textContent?.trim()??"").filter(Boolean).join(" ");if(W)return W}let z=$.querySelector('[data-slot="dialog-title"], h1, h2, h3, [role="heading"]')?.textContent?.replace(/\s+/g," ").trim();if(z)return z;return($.textContent??"").replace(/\s+/g," ").trim()}function c0($){let J=b(C2($)),Q=D2($);return J?`เปิด ${Q} “${m(J,H0)}”`:`เปิด ${Q}`}var k2='[aria-busy="true"], [role="progressbar"], [data-loading="true"], .animate-pulse, .animate-spin',R2=/กำลังโหลด|กำลังค้นหา|กำลังดำเนินการ|\bloading\b/i;function O2($){if($.querySelector(k2))return!0;return R2.test($.textContent??"")}var S2=400,_2=250,T2=8000;function A2($,J){if(typeof MutationObserver>"u"){J.html=Q0(g0($));return}let Q=Date.now(),j=!1,z=()=>{j=!0,V.disconnect(),window.clearInterval(X),window.clearTimeout(H)},W=()=>{if(j)return;if(z(),!$.isConnected)return;J.detail=m(c0($),X0),J.html=Q0(g0($))},V=new MutationObserver(()=>{Q=Date.now()});V.observe($,{childList:!0,subtree:!0,attributes:!0,characterData:!0});let X=window.setInterval(()=>{if(j)return;if(!$.isConnected){z();return}if(Date.now()-Q>=S2&&!O2($))W()},_2),H=window.setTimeout(W,T2)}function L2($){if(J0($))return;let J=c("ui",c0($));if(J)A2($,J)}function f2(){if(typeof MutationObserver>"u")return;let $=new WeakSet;new MutationObserver((Q)=>{for(let j of Q)for(let z of Array.from(j.addedNodes)){if(!(z instanceof Element))continue;let W=N2(),V=z.matches(W)?[z]:Array.from(z.querySelectorAll(W));for(let X of V){if($.has(X))continue;$.add(X),L2(X)}}}).observe(document.body,{childList:!0,subtree:!0})}var E2=1600,x2=2500;function u0($){return{disabled:$.hasAttribute("disabled")||$.getAttribute("aria-disabled")==="true",busy:$.getAttribute("aria-busy")==="true",text:m(($.textContent??"").replace(/\s+/g," ").trim(),H0)}}function h2($,J){if(!$.disabled&&J.disabled)return"ปุ่มถูกปิดใช้งานหลังคลิก";if(!$.busy&&J.busy)return"ปุ่มเข้าสู่สถานะกำลังโหลด";if($.text!==J.text&&J.text)return`ข้อความเปลี่ยนเป็น “${J.text}”`;return null}function p2($,J){if(typeof MutationObserver>"u")return;let Q=u0($),j=!1,z=(X,H)=>{if(j)return;if(j=!0,W.disconnect(),window.clearTimeout(V),J.afterNote=X,H)J.afterHtml=Q0(U0($,d0,x2))},W=new MutationObserver(()=>{if(!$.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}let X=h2(Q,u0($));if(X)z(X,!0)});W.observe($,{attributes:!0,attributeFilter:["disabled","aria-disabled","aria-busy","class"],childList:!0,subtree:!0,characterData:!0});let V=window.setTimeout(()=>{if(!j&&!$.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}j=!0,W.disconnect()},E2)}function o0(){if(m0||typeof window>"u")return;m0=!0,document.addEventListener("click",(j)=>{if(J0(j.target))return;let z=Y2(j.target);if(!z)return;let W=F2(z);if(!W)return;let V=c("click",`คลิก ${W}`,q2(z),I2(z));if(V)p2(z,V)},{capture:!0,passive:!0}),document.addEventListener("change",(j)=>{if(J0(j.target))return;let z=P2(j.target);if(z)c("input",`แก้ไข ${z}`)},{capture:!0,passive:!0}),document.addEventListener("submit",(j)=>{if(J0(j.target))return;c("submit","ส่งฟอร์ม")},{capture:!0,passive:!0});let $=()=>c("navigate",`ไปที่ ${I0(d(location.pathname+location.search))}`),J=history.pushState.bind(history),Q=history.replaceState.bind(history);history.pushState=(...j)=>{let z=J(...j);return $(),z},history.replaceState=(...j)=>{let z=Q(...j);return $(),z},window.addEventListener("popstate",$),f2()}function l0(){return p.map(($)=>({...$}))}var r0=2000,j0=[],s0=0,n0=!1;function M0($,J){s0+=1,j0.push({id:`log_${s0}`,at:new Date().toISOString(),level:$,message:J.length>r0?`${J.slice(0,r0)}…`:J});while(j0.length>f("maxConsoleEntries"))j0.shift()}function m2(){let $=new WeakSet;return(J,Q)=>{if(typeof Q==="object"&&Q!==null){if($.has(Q))return"[Circular]";$.add(Q)}if(typeof Q==="bigint")return Q.toString();return Q}}function a0($){if(typeof $==="string")return $;if($ instanceof Error)return`${$.name}: ${$.message}`;try{let J=JSON.stringify($,m2());if(J!==void 0)return J}catch{}try{return String($)}catch{}try{return Object.prototype.toString.call($)}catch{return`[${typeof $}]`}}function t0(){if(n0||typeof window>"u")return;n0=!0;let $=["log","info","warn","error","debug"];for(let J of $){let Q=console[J].bind(console);console[J]=(...j)=>{M0(J,j.map(a0).join(" ")),Q(...j)}}window.addEventListener("error",(J)=>{let Q=J.filename?` (${J.filename}:${J.lineno}:${J.colno})`:"";M0("exception",`${J.message}${Q}`)}),window.addEventListener("unhandledrejection",(J)=>{let Q=J.reason instanceof Error?`${J.reason.name}: ${J.reason.message}`:a0(J.reason);M0("unhandledrejection",Q)})}function e0(){return j0.map(($)=>({...$}))}var $1=new Set,J1=new Set;function Q1($,J){return $.add(J),()=>$.delete(J)}function j1($,J){for(let Q of[...$])Q(J)}function z1($){return Q1($1,$)}function z0($={type:"manual"}){j1($1,$)}function Z1($){return Q1(J1,$)}function W1($){j1(J1,$)}var y2=15000,g2=["ResizeObserver loop","Script error.","Non-Error promise rejection captured"],K1=!1,V1=0;function v2($){return g2.some((J)=>$.includes(J))}function Y1($){let J=$.message??"";if(!J||v2(J))return;let Q=Date.now();if(Q-V1<y2)return;V1=Q,W1({...$,message:J})}function F1(){if(K1||typeof window>"u")return;K1=!0,window.addEventListener("error",($)=>{if(!$.message&&!$.error)return;let J=$.error instanceof Error?$.error:null;Y1({type:"runtime-error",message:$.message||(J?J.message:"Unknown error"),stack:J?.stack})}),window.addEventListener("unhandledrejection",($)=>{let J=$.reason;Y1({type:"unhandledrejection",message:J instanceof Error?J.message:String(J),stack:J instanceof Error?J.stack:void 0})})}var I1=4000,b2=1e6,u2=1e7,Z0=[],G1=0,X1=!1;function U1($){Z0.push($);while(Z0.length>f("maxRequests"))Z0.shift()}function M1(){return G1+=1,`req_${G1}`}function H1($){let J={};if(!$)return J;if($ instanceof Headers)$.forEach((Q,j)=>{J[j]=Q});else if(Array.isArray($))for(let[Q,j]of $)J[Q]=j;else Object.assign(J,$);return J}function d2($){let J={};return $.forEach((Q,j)=>{J[j]=Q}),J}function i2($){if($==null)return null;if(typeof $==="string")return $;if($ instanceof URLSearchParams)return $.toString();if(typeof FormData<"u"&&$ instanceof FormData)return`[FormData: ${Array.from($.keys()).join(", ")}]`;if(typeof Blob<"u"&&$ instanceof Blob)return`[Blob ${$.size} bytes]`;if($ instanceof ArrayBuffer)return`[ArrayBuffer ${$.byteLength} bytes]`;return"[binary]"}function c2($,J){let Q="",j="GET",z={},W=null;if(typeof $==="string")Q=$;else if($ instanceof URL)Q=$.toString();else Q=$.url,j=$.method||j,z=H1($.headers);if(J){if(J.method)j=J.method;if(J.headers)z={...z,...H1(J.headers)};if(J.body!==void 0)W=i2(J.body)}return{method:j.toUpperCase(),url:Q,headers:z,body:W}}function P1($){return!x0($)}function o2($,J){if(P1(J.url)){J.responseSnippet="[body not captured for this origin]";return}let Q=$.headers.get("content-type")??"",j=Number($.headers.get("content-length")??"0"),z=j?`, ~${j} bytes`:"";if(!/json|text|xml|html|javascript|urlencoded/i.test(Q)){J.responseSnippet=`[binary ${Q||"unknown"}${z}]`;return}if(j>b2){J.responseSnippet=`[response ${Q||"text"}${z} — omitted]`;return}try{$.clone().text().then((W)=>{J.responseSnippet=i(W,f("maxBodyChars"))}).catch(()=>{})}catch{}}function w1($,J){if(/[?&]_rsc=/.test($))return!0;for(let Q of Object.keys(J)){let j=Q.toLowerCase();if(j==="rsc"||j==="next-router-prefetch"||j==="next-router-state-tree")return!0}return!1}function l2(){if(typeof window>"u"||typeof window.fetch!=="function")return;let $=window.fetch.bind(window);window.fetch=Object.assign(async(J,Q)=>{let j=c2(J,Q);if(w1(j.url,j.headers))return $(J,Q);let z={id:M1(),startedAt:new Date().toISOString(),method:j.method,url:d(j.url),requestHeaders:u(j.headers),requestBody:i(j.body,I1),status:null,statusText:null,durationMs:null,via:"fetch"};U1(z);let W=performance.now();try{let V=await $(J,Q);return z.status=V.status,z.statusText=V.statusText,z.durationMs=Math.round(performance.now()-W),z.responseHeaders=u(d2(V.headers)),o2(V,z),V}catch(V){throw z.durationMs=Math.round(performance.now()-W),z.error=V instanceof Error?`${V.name}: ${V.message}`:String(V),V}},$)}function r2(){if(typeof window>"u"||typeof window.XMLHttpRequest!=="function")return;let $=XMLHttpRequest.prototype,J=$.open,Q=$.send,j=function(W,V){let X=typeof V==="string"?V:V.toString();return this.__cibEntry=w1(X,{})?void 0:{id:M1(),startedAt:"",method:(W||"GET").toUpperCase(),url:d(X),requestHeaders:{},requestBody:null,status:null,statusText:null,durationMs:null,via:"xhr"},J.apply(this,arguments)},z=function(W){let V=this.__cibEntry;if(V){V.startedAt=new Date().toISOString(),V.requestBody=typeof W==="string"?i(W,I1):W==null?null:"[non-string body]";let X=performance.now();U1(V),this.addEventListener("loadend",()=>{if(V.status=this.status||null,V.statusText=this.statusText||null,V.durationMs=Math.round(performance.now()-X),P1(V.url))V.responseSnippet="[body not captured for this origin]";else if(this.responseType===""||this.responseType==="text")try{V.responseSnippet=i(this.responseText||"",f("maxBodyChars"))}catch{}else{let H=this.getResponseHeader("content-type")??this.responseType;V.responseSnippet=`[binary ${H}]`}})}return Q.apply(this,arguments)};$.open=j,$.send=z}function q1(){if(X1)return;X1=!0,l2(),r2()}function B1(){let $=Z0.map((Q)=>({...Q})),J=0;for(let Q=$.length-1;Q>=0;Q-=1){let j=$[Q],z=j?.responseSnippet;if(!j||typeof z!=="string"||z.length===0)continue;if(J+z.length>u2)j.responseSnippet=`[response omitted — report size budget reached (${z.length.toLocaleString()} chars)]`;else J+=z.length}return $}var s2={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:"หน้า",handoffTitle:"กำลังพาไปที่ระบบแจ้งปัญหา",handoffBody:"ระบบจะลงชื่อเข้าใช้ให้อัตโนมัติ เพื่อดูเรื่องที่คุณแจ้งไว้",handoffGo:"ไปเลย",handoffPreparing:"กำลังเตรียม…",handoffFailed:"เปิดรายการที่แจ้งไว้ไม่สำเร็จ",handoffBlocked:"เบราว์เซอร์บล็อกการเปิดแท็บใหม่",handoffOpen:"เปิดในแท็บใหม่"},n2={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",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 W0($){return $==="en"?n2:s2}var a2="lw-debug-toasts",t2=6000,e2=`
|
|
2
2
|
:host { all: initial; }
|
|
3
3
|
.stack {
|
|
4
4
|
position: fixed; top: 16px; right: 16px; z-index: 2147483001;
|
|
@@ -30,7 +30,7 @@
|
|
|
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
|
-
`,U0=null;function $4(){if(typeof document>"u")return null;if(U0?.isConnected)return U0;let $=document.createElement(a2);$.dataset.debugReporter="true";let j=$.attachShadow({mode:"open"}),J=document.createElement("style");J.textContent=e2;let Q=document.createElement("div");return Q.className="stack",Q.setAttribute("role","status"),Q.setAttribute("aria-live","polite"),j.append(J,Q),document.body.append($),U0=Q,Q}function l($,j="success",J){let Q=e()?q().toast:void 0;if(Q){Q({message:$,tone:j,...J?{action:J}:{}});return}let z=$4();if(!z)return;let W=document.createElement("div");W.className="toast",W.dataset.tone=j;let V=document.createElement("span");V.className="dot";let F=document.createElement("span");F.textContent=$;let w=document.createElement("button");w.type="button",w.className="close",w.textContent="✕",w.setAttribute("aria-label","ปิด");let H=()=>{window.clearTimeout(C),W.remove()};w.addEventListener("click",H);let C=j==="error"||J?0:window.setTimeout(H,t2);if(W.append(V,F),J){let U=document.createElement("button");U.type="button",U.className="action",U.textContent=J.label,U.addEventListener("click",()=>{H(),J.onClick()}),W.append(U)}W.append(w),z.append(W)}function q1($,j,J){let Q=$.filter((W)=>Boolean(W.error)||W.status!=null&&W.status>=400).slice(-20).map((W)=>({method:W.method,url:W.url,status:W.status,error:W.error,at:W.startedAt})),z=j.filter((W)=>W.level==="error"||W.level==="exception"||W.level==="unhandledrejection").slice(-20).map((W)=>W.message);return{failedRequests:Q,errors:z,erroredQueries:J.slice(0,20)}}function j4(){let $={memoryUsedMb:null,memoryLimitMb:null,domContentLoadedMs:null,loadEventMs:null};if(typeof performance>"u")return $;let j=performance.memory;if(j)$.memoryUsedMb=Math.round(j.usedJSHeapSize/1024/1024),$.memoryLimitMb=Math.round(j.jsHeapSizeLimit/1024/1024);let[J]=performance.getEntriesByType("navigation");if(J)$.domContentLoadedMs=Math.round(J.domContentLoadedEventEnd),$.loadEventMs=Math.round(J.loadEventEnd);return $}function P0($,j){if(!$)return j;try{return $()}catch{return j}}function B1(){let $=q(),{pathname:j,search:J,href:Q}=window.location;return{capturedAt:new Date().toISOString(),route:{href:Q,pathname:j,search:J},module:L0(j),user:P0($.user,{}),apiHeaders:u(P0($.headers,{})),app:{name:h().name,version:h().version,environment:h().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:j4(),extra:P0($.extra,{})}}var J4=2;function D1($){let j=N1(),J=e0();return{context:B1(),reason:$.reason,note:$.note,cause:q1(j,J,$.erroredQueries),actionTrail:l0(),network:j,console:J,screenshotDataUrl:$.screenshotDataUrl,screenshotMethod:$.screenshotMethod,meta:{generatedBy:"lightwork-debug-capture",schemaVersion:J4}}}async function k1(){if(typeof navigator<"u"&&Boolean(navigator.mediaDevices?.getDisplayMedia)){let J=await Q4();if(J.status==="ok")return{dataUrl:J.dataUrl,method:"display-media"};if(J.status==="cancelled")return{dataUrl:null,method:"cancelled"}}let j=await W4();if(j)return{dataUrl:j,method:"html-to-image"};return{dataUrl:null,method:"none"}}async function Q4(){let $=null;try{let j={video:{frameRate:30},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude"};$=await navigator.mediaDevices.getDisplayMedia(j);let J=await z4($);return J?{status:"ok",dataUrl:J}:{status:"error"}}catch(j){if(j instanceof DOMException&&(j.name==="NotAllowedError"||j.name==="AbortError"))return{status:"cancelled"};return{status:"error"}}finally{$?.getTracks().forEach((j)=>j.stop())}}async function z4($){let j=document.createElement("video");j.srcObject=$,j.muted=!0,j.playsInline=!0,await new Promise((V)=>{let F=!1,w=()=>{if(F)return;F=!0,V()};j.onloadedmetadata=()=>{j.play().then(w).catch(w)},window.setTimeout(w,1500)}),await Z4(j);let{videoWidth:J,videoHeight:Q}=j;if(!J||!Q)return null;let z=document.createElement("canvas");z.width=J,z.height=Q;let W=z.getContext("2d");if(!W)return null;W.drawImage(j,0,0,J,Q),j.pause(),j.srcObject=null;try{return z.toDataURL("image/png")}catch{return null}}function Z4($){return new Promise((j)=>{let J=!1,Q=()=>{if(J)return;J=!0,j()},z=$;if(typeof z.requestVideoFrameCallback==="function")z.requestVideoFrameCallback(()=>Q()),window.setTimeout(Q,1000);else window.setTimeout(Q,250)})}async function W4(){let $=q().screenshotFallback;if(!$)return null;let j=await $().catch(()=>null);if(!j)return null;try{return await j(document.body,{cacheBust:!0,pixelRatio:Math.min(window.devicePixelRatio||1,2),filter:(J)=>!(J instanceof HTMLElement&&J.dataset?.debugReporter==="true")})}catch{return null}}var K4=2000,V4=0.82,G4=3000000;function X4($){return new Promise((j,J)=>{let Q=new Image;Q.onload=()=>j(Q),Q.onerror=()=>J(Error("could not read the screenshot")),Q.src=$})}async function R1($){try{let j=await X4($),J=Math.max(j.naturalWidth,j.naturalHeight),Q=Math.min(1,K4/J),z=document.createElement("canvas");z.width=Math.max(1,Math.round(j.naturalWidth*Q)),z.height=Math.max(1,Math.round(j.naturalHeight*Q));let W=z.getContext("2d");if(!W)return $;W.fillStyle="#fff",W.fillRect(0,0,z.width,z.height),W.drawImage(j,0,0,z.width,z.height);let V=V4,F=z.toDataURL("image/jpeg",V);while(F.length>G4&&V>0.4)V-=0.15,F=z.toDataURL("image/jpeg",V);return F}catch{return $}}var Y4=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,F4=/^\d+$/,w4=/^[0-9a-f]{16,}$/i;function S1($){if($.reason.type==="manual")return null;let j=$.cause?.failedRequests?.[0];if(!j?.url)return null;let J;try{J=new URL(j.url,"http://x").pathname}catch{J=j.url}let Q=J.split("/").map((W)=>Y4.test(W)||F4.test(W)||w4.test(W)?":id":W).join("/"),z=j.status??(j.error?"ERR":"?");return`${j.method??"REQ"} ${Q} ${z}`}var O1=2000000;function K0($){let{screenshotDataUrl:j,...J}=$;return JSON.stringify(J).length}function f1($,j=2000000){if(K0($)<=j)return $;let J=$.network.map((z)=>({...z})),Q={...$,network:J};for(let z of J){if(K0(Q)<=j)return Q;if(typeof z.responseSnippet==="string"&&z.responseSnippet.length>35)z.responseSnippet="[body dropped — report size budget]";if(typeof z.requestBody==="string"&&z.requestBody.length>35)z.requestBody="[body dropped — report size budget]"}while(Q.network.length>1&&K0(Q)>j)Q.network=Q.network.slice(1);while(Q.console.length>1&&K0(Q)>j)Q.console=Q.console.slice(1);return Q}var _1=32768;function M4($){let j="";for(let J=0;J<$.length;J+=_1)j+=String.fromCharCode(...$.subarray(J,J+_1));return btoa(j)}function H4($){let{screenshotDataUrl:j,...J}=$;return{dataUri:`data:application/json;base64,${M4(new TextEncoder().encode(JSON.stringify(J)))}`,filename:"debug-bundle.json"}}async function I4(){let $=q().identity;if(!$)return{};try{let j=await $();return j?{authorization:`Bearer ${j}`}:{}}catch{return{}}}async function T1($,j){let J=q(),Q=f1(j,O1),{context:z,note:W}=Q,V=[];if(Q.screenshotDataUrl){let C=await R1(Q.screenshotDataUrl);V.push({dataUri:C,filename:"screenshot.jpg"})}V.push(H4(Q));let F=S1(Q),w={title:$,description:W.trim()||void 0,appName:h().name,category:z.module?.label,routeUrl:z.route.href,priority:"MEDIUM",requesterEmail:z.user.email??void 0,requesterName:z.user.fullName??void 0,customFields:{unit:z.user.unit??"",appVersion:z.app.version,environment:z.app.environment,reasonType:Q.reason.type,appName:h().name,module:z.module?.label??""},context:{...F?{signature:F}:{},capturedAt:z.capturedAt,reason:Q.reason,cause:Q.cause,actionTrail:Q.actionTrail,client:z.client,performance:z.performance,apiHeaders:z.apiHeaders,extra:z.extra,counts:{network:Q.network.length,console:Q.console.length,actions:Q.actionTrail.length},screenshotMethod:Q.screenshotMethod},attachments:V},H=await fetch(`${J.host.replace(/\/$/,"")}/ingest/tickets`,{method:"POST",headers:{"content-type":"application/json","x-realm-key":J.realmKey,...await I4()},body:JSON.stringify(w)});if(!H.ok){let C=H.headers.get("retry-after"),U=await H.json().then((P)=>P.error).catch(()=>null);throw Error(H.status===429?`Too many reports — try again in ${C??"a moment"}s`:U??`Report failed (${H.status})`)}return await H.json()}var r=Math.PI/6;function A1($,j,J){let Q=j.x-$.x,z=j.y-$.y,W=Math.hypot(Q,z),V=Math.atan2(z,Q),F=[{x:j.x,y:j.y},{x:j.x-J*Math.cos(V-r),y:j.y-J*Math.sin(V-r)},{x:j.x-J*Math.cos(V+r),y:j.y-J*Math.sin(V+r)}],w=J*Math.cos(r)*0.92;if(W<=w)return{shaft:null,head:F};return{shaft:{from:$,to:{x:j.x-w*Math.cos(V),y:j.y-w*Math.sin(V)}},head:F}}var C0="#f44336",U4="rgba(250, 204, 21, 0.4)",N0=22,L1="#2563eb",E1=9,x1=11,h1=18,p1=4,V0=8,P4=[{id:"nw",fx:0,fy:0,cursor:"nwse-resize"},{id:"n",fx:0.5,fy:0,cursor:"ns-resize"},{id:"ne",fx:1,fy:0,cursor:"nesw-resize"},{id:"e",fx:1,fy:0.5,cursor:"ew-resize"},{id:"se",fx:1,fy:1,cursor:"nwse-resize"},{id:"s",fx:0.5,fy:1,cursor:"ns-resize"},{id:"sw",fx:0,fy:1,cursor:"nesw-resize"},{id:"w",fx:0,fy:0.5,cursor:"ew-resize"}];function m1($,j,J){let Q=[],z=null,W=-1,V=null,F=null,w=$.getContext("2d");function H(){let Z=$.getBoundingClientRect().width;return Z>0?$.width/Z:1}function C(Z){let K=$.getBoundingClientRect();return{x:(Z.clientX-K.left)/K.width*$.width,y:(Z.clientY-K.top)/K.height*$.height}}function U(Z){let K=Z.size??N0;if(!w)return(Z.text?.length??0)*K*0.6;w.save(),w.font=`600 ${K}px system-ui, sans-serif`;let X=w.measureText(Z.text??"").width;return w.restore(),X}function P(Z){if(Z.tool==="text"){let K=Z.size??N0;return{left:Z.x1,top:Z.y1,right:Z.x1+U(Z),bottom:Z.y1+K*1.25}}return{left:Math.min(Z.x1,Z.x2),top:Math.min(Z.y1,Z.y2),right:Math.max(Z.x1,Z.x2),bottom:Math.max(Z.y1,Z.y2)}}function R(Z){if(Z.tool==="arrow")return[{id:"tail",x:Z.x1,y:Z.y1,cursor:"move"},{id:"head",x:Z.x2,y:Z.y2,cursor:"move"}];let K=P(Z);if(Z.tool==="text")return[{id:"size",x:K.right,y:K.bottom,cursor:"nwse-resize"}];return P4.map((X)=>({id:X.id,x:K.left+(K.right-K.left)*X.fx,y:K.top+(K.bottom-K.top)*X.fy,cursor:X.cursor}))}function D(Z){let K=P(Z);return{x:K.right+h1*H(),y:K.top-h1*H()}}function k(Z,K,X){let{shaft:G,head:Y}=A1({x:K.x1,y:K.y1},{x:K.x2,y:K.y2},Math.max(10,16*X));if(G)Z.lineCap="butt",Z.beginPath(),Z.moveTo(G.from.x,G.from.y),Z.lineTo(G.to.x,G.to.y),Z.stroke();Z.beginPath(),Z.moveTo(Y[0].x,Y[0].y),Z.lineTo(Y[1].x,Y[1].y),Z.lineTo(Y[2].x,Y[2].y),Z.closePath(),Z.fill()}function f(Z,K,X){Z.save(),Z.lineWidth=Math.max(2,3*X),Z.strokeStyle=C0,Z.fillStyle=C0;let G=P(K);if(K.tool==="rect")Z.strokeRect(G.left,G.top,G.right-G.left,G.bottom-G.top);else if(K.tool==="arrow")k(Z,K,X);else if(K.tool==="highlight")Z.fillStyle=U4,Z.fillRect(G.left,G.top,G.right-G.left,G.bottom-G.top);else if(K.tool==="text"&&K.text){let Y=K.size??N0;Z.font=`600 ${Y}px system-ui, sans-serif`,Z.textBaseline="top";let M=Y*0.22;Z.fillStyle="rgba(255,255,255,0.92)",Z.fillRect(G.left-M,G.top-M,G.right-G.left+M*2,G.bottom-G.top+M*2),Z.fillStyle=C0,Z.fillText(K.text,G.left,G.top)}Z.restore()}function s(Z,K,X){let G=P(K);Z.save(),Z.strokeStyle=L1,Z.lineWidth=Math.max(1,1.5*X),Z.setLineDash([6*X,4*X]),Z.strokeRect(G.left,G.top,G.right-G.left,G.bottom-G.top),Z.setLineDash([]);let Y=E1*X;for(let S of R(K))Z.fillStyle="#fff",Z.strokeStyle=L1,Z.lineWidth=Math.max(1,1.5*X),Z.beginPath(),Z.rect(S.x-Y/2,S.y-Y/2,Y,Y),Z.fill(),Z.stroke();let M=D(K),I=x1*X;Z.beginPath(),Z.arc(M.x,M.y,I,0,Math.PI*2),Z.fillStyle="#dc2626",Z.fill(),Z.strokeStyle="#fff",Z.lineWidth=Math.max(1.5,2*X),Z.beginPath(),Z.moveTo(M.x-I*0.4,M.y-I*0.4),Z.lineTo(M.x+I*0.4,M.y+I*0.4),Z.moveTo(M.x+I*0.4,M.y-I*0.4),Z.lineTo(M.x-I*0.4,M.y+I*0.4),Z.stroke(),Z.restore()}function N(){if(!w)return;let Z=H();if(w.clearRect(0,0,$.width,$.height),w.drawImage(j,0,0,$.width,$.height),Q.forEach((X,G)=>{if(G!==a)f(w,X,Z)}),V)f(w,V,Z);let K=Q[W];if(K&&!V)s(w,K,Z)}function B0(Z,K,X,G,Y){return Math.abs(Z-X)<=Y&&Math.abs(K-G)<=Y}function D0(Z,K){let X=Q[W];if(!X)return null;let G=E1*H()/2+3*H();for(let Y of R(X))if(B0(Z,K,Y.x,Y.y,G))return Y.id;return null}function k0(Z,K){let X=Q[W];if(!X)return!1;let G=D(X);return B0(Z,K,G.x,G.y,x1*H())}function G0(Z,K){let X=6*H();for(let G=Q.length-1;G>=0;G-=1){let Y=Q[G];if(Y.tool==="arrow"){let I=Y.x2-Y.x1,S=Y.y2-Y.y1,E=Math.hypot(I,S)||1,x=Math.max(0,Math.min(1,((Z-Y.x1)*I+(K-Y.y1)*S)/(E*E)));if(Math.hypot(Z-(Y.x1+x*I),K-(Y.y1+x*S))<=X+4*H())return G;continue}let M=P(Y);if(Z>=M.left-X&&Z<=M.right+X&&K>=M.top-X&&K<=M.bottom+X)return G}return-1}function u1(Z,K,X,G,Y){if(K==="tail"){Z.x1=X.x1+G,Z.y1=X.y1+Y;return}if(K==="head"){Z.x2=X.x2+G,Z.y2=X.y2+Y;return}if(K==="size"){let c1=(X.size??24)+Y;Z.size=Math.max(10,c1);return}let M=P(X),{left:I,top:S,right:E,bottom:x}=M;if(K.includes("w"))I=Math.min(E-V0,I+G);if(K.includes("e"))E=Math.max(I+V0,E+G);if(K.includes("n"))S=Math.min(x-V0,S+Y);if(K.includes("s"))x=Math.max(S+V0,x+Y);Z.x1=I,Z.y1=S,Z.x2=E,Z.y2=x}function d1(Z,K,X,G){Z.x1=K.x1+X,Z.y1=K.y1+G,Z.x2=K.x2+X,Z.y2=K.y2+G}let _=null,a=-1,T={x:0,y:0,size:24};function i1(){let Z=$.getBoundingClientRect().width;return Z>0?Z/$.width:1}function o1(Z,K){if(!w)return Z.length*K*0.6;w.save(),w.font=`600 ${K}px system-ui, sans-serif`;let X=w.measureText(Z||" ").width;return w.restore(),X}function R0(){if(!_)return;let Z=$.parentElement;if(!Z)return;let K=$.getBoundingClientRect(),X=Z.getBoundingClientRect(),G=i1(),Y=T.size*G;_.style.left=`${K.left-X.left+T.x*G}px`,_.style.top=`${K.top-X.top+T.y*G}px`,_.style.fontSize=`${Y}px`,_.style.width=`${Math.max(40,o1(_.value,Y)+Y)}px`}function y(Z){let K=_;if(!K)return;_=null;let X=K.value.trim(),G=a;if(a=-1,K.remove(),Z&&X){if(G>=0&&Q[G])Q[G].text=X,W=G;else Q.push({tool:"text",x1:T.x,y1:T.y,x2:T.x,y2:T.y,text:X,size:T.size}),W=Q.length-1;J()}else if(G>=0)W=G;$.focus(),N()}function S0(Z,K,X=-1){y(!0);let G=$.parentElement;if(!G)return;if(getComputedStyle(G).position==="static")G.style.position="relative";let Y=X>=0?Q[X]:void 0;a=X,T={x:Y?.x1??Z,y:Y?.y1??K,size:Y?.size??Math.round(24*H())};let M=document.createElement("input");M.type="text",M.className="text-edit",M.value=Y?.text??"",M.setAttribute("aria-label","ข้อความบนภาพ"),M.placeholder="ข้อความ",_=M,G.append(M),R0(),M.addEventListener("input",R0),M.addEventListener("keydown",(I)=>{if(I.stopPropagation(),I.key==="Enter")y(!0);else if(I.key==="Escape")y(!1)}),requestAnimationFrame(()=>{if(_!==M)return;M.focus(),M.select(),M.addEventListener("blur",()=>y(!0))}),N()}function O0(Z){let{x:K,y:X}=C(Z);if($.setPointerCapture(Z.pointerId),k0(K,X)){X0();return}let G=D0(K,X);if(G&&Q[W]){F={grip:G,x:K,y:X,start:{...Q[W]}};return}if(z==="text"){if(Z.preventDefault(),$.hasPointerCapture(Z.pointerId))$.releasePointerCapture(Z.pointerId);z=null,J(),S0(K,X);return}if(z){V={tool:z,x1:K,y1:X,x2:K,y2:X},W=-1;return}let Y=G0(K,X);W=Y,F=Y>=0?{grip:"body",x:K,y:X,start:{...Q[Y]}}:null,N()}function f0(Z){let{x:K,y:X}=C(Z);if(V){V.x2=K,V.y2=X,N();return}if(F){let Y=Q[W];if(!Y)return;let M=K-F.x,I=X-F.y;if(F.grip==="body")d1(Y,F.start,M,I);else u1(Y,F.grip,F.start,M,I);N();return}if(z){$.style.cursor="crosshair";return}if(k0(K,X)){$.style.cursor="pointer";return}let G=D0(K,X);if(G){let Y=Q[W]?R(Q[W]).find((M)=>M.id===G):null;$.style.cursor=Y?.cursor??"pointer";return}$.style.cursor=G0(K,X)>=0?"move":"default"}function t(){if(V){if(!(Math.abs(V.x2-V.x1)<p1&&Math.abs(V.y2-V.y1)<p1))Q.push(V),W=Q.length-1,z=null,J();V=null}if(F)F=null,J();N()}function _0(Z){let K=$.getBoundingClientRect(),X=(Z.clientX-K.left)/K.width*$.width,G=(Z.clientY-K.top)/K.height*$.height,Y=G0(X,G),M=Q[Y];if(!M||M.tool!=="text")return;Z.preventDefault(),S0(M.x1,M.y1,Y)}function T0(Z){if(W<0)return;if(Z.key==="Delete"||Z.key==="Backspace")Z.preventDefault(),X0();else if(Z.key==="Escape")W=-1,N()}function X0(){if(W<0)return;Q.splice(W,1),W=-1,J(),N()}return $.addEventListener("pointerdown",O0),$.addEventListener("pointermove",f0),$.addEventListener("pointerup",t),$.addEventListener("pointercancel",t),$.addEventListener("dblclick",_0),$.tabIndex=0,$.addEventListener("keydown",T0),N(),{setTool(Z){z=Z,W=-1,$.style.cursor=Z?"crosshair":"default",N()},deleteSelected:X0,clear(){Q.length=0,W=-1,J(),N()},hasShapes:()=>Q.length>0,hasSelection:()=>W>=0,toDataUrl(){let Z=document.createElement("canvas");Z.width=j.naturalWidth,Z.height=j.naturalHeight;let K=Z.getContext("2d");if(!K)return $.toDataURL("image/png");K.drawImage(j,0,0);let X=H();for(let G of Q)f(K,G,X);return Z.toDataURL("image/png")},destroy(){y(!1),$.removeEventListener("pointerdown",O0),$.removeEventListener("pointermove",f0),$.removeEventListener("pointerup",t),$.removeEventListener("pointercancel",t),$.removeEventListener("dblclick",_0),$.removeEventListener("keydown",T0)}}}var g1=`
|
|
33
|
+
`,P0=null;function $4(){if(typeof document>"u")return null;if(P0?.isConnected)return P0;let $=document.createElement(a2);$.dataset.debugReporter="true";let J=$.attachShadow({mode:"open"}),Q=document.createElement("style");Q.textContent=e2;let j=document.createElement("div");return j.className="stack",j.setAttribute("role","status"),j.setAttribute("aria-live","polite"),J.append(Q,j),document.body.append($),P0=j,j}function l($,J="success",Q){let j=e()?N().toast:void 0;if(j){j({message:$,tone:J,...Q?{action:Q}:{}});return}let z=$4();if(!z)return;let W=document.createElement("div");W.className="toast",W.dataset.tone=J;let V=document.createElement("span");V.className="dot";let X=document.createElement("span");X.textContent=$;let H=document.createElement("button");H.type="button",H.className="close",H.textContent="✕",H.setAttribute("aria-label","ปิด");let U=()=>{window.clearTimeout(q),W.remove()};H.addEventListener("click",U);let q=J==="error"||Q?0:window.setTimeout(U,t2);if(W.append(V,X),Q){let P=document.createElement("button");P.type="button",P.className="action",P.textContent=Q.label,P.addEventListener("click",()=>{U(),Q.onClick()}),W.append(P)}W.append(H),z.append(W)}function N1($,J,Q){let j=$.filter((W)=>Boolean(W.error)||W.status!=null&&W.status>=400).slice(-20).map((W)=>({method:W.method,url:W.url,status:W.status,error:W.error,at:W.startedAt})),z=J.filter((W)=>W.level==="error"||W.level==="exception"||W.level==="unhandledrejection").slice(-20).map((W)=>W.message);return{failedRequests:j,errors:z,erroredQueries:Q.slice(0,20)}}function J4(){let $={memoryUsedMb:null,memoryLimitMb:null,domContentLoadedMs:null,loadEventMs:null};if(typeof performance>"u")return $;let J=performance.memory;if(J)$.memoryUsedMb=Math.round(J.usedJSHeapSize/1024/1024),$.memoryLimitMb=Math.round(J.jsHeapSizeLimit/1024/1024);let[Q]=performance.getEntriesByType("navigation");if(Q)$.domContentLoadedMs=Math.round(Q.domContentLoadedEventEnd),$.loadEventMs=Math.round(Q.loadEventEnd);return $}function w0($,J){if(!$)return J;try{return $()}catch{return J}}function D1(){let $=N(),{pathname:J,search:Q,href:j}=window.location;return{capturedAt:new Date().toISOString(),route:{href:j,pathname:J,search:Q},module:f0(J),user:w0($.user,{}),apiHeaders:u(w0($.headers,{})),app:{name:h().name,version:h().version,environment:h().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:J4(),extra:w0($.extra,{})}}var Q4=2;function C1($){let J=B1(),Q=e0();return{context:D1(),reason:$.reason,note:$.note,cause:N1(J,Q,$.erroredQueries),actionTrail:l0(),network:J,console:Q,screenshotDataUrl:$.screenshotDataUrl,screenshotMethod:$.screenshotMethod,meta:{generatedBy:"lightwork-debug-capture",schemaVersion:Q4}}}async function k1(){if(typeof navigator<"u"&&Boolean(navigator.mediaDevices?.getDisplayMedia)){let Q=await j4();if(Q.status==="ok")return{dataUrl:Q.dataUrl,method:"display-media"};if(Q.status==="cancelled")return{dataUrl:null,method:"cancelled"}}let J=await W4();if(J)return{dataUrl:J,method:"html-to-image"};return{dataUrl:null,method:"none"}}async function j4(){let $=null;try{let J={video:{frameRate:30},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude"};$=await navigator.mediaDevices.getDisplayMedia(J);let Q=await z4($);return Q?{status:"ok",dataUrl:Q}:{status:"error"}}catch(J){if(J instanceof DOMException&&(J.name==="NotAllowedError"||J.name==="AbortError"))return{status:"cancelled"};return{status:"error"}}finally{$?.getTracks().forEach((J)=>J.stop())}}async function z4($){let J=document.createElement("video");J.srcObject=$,J.muted=!0,J.playsInline=!0,await new Promise((V)=>{let X=!1,H=()=>{if(X)return;X=!0,V()};J.onloadedmetadata=()=>{J.play().then(H).catch(H)},window.setTimeout(H,1500)}),await Z4(J);let{videoWidth:Q,videoHeight:j}=J;if(!Q||!j)return null;let z=document.createElement("canvas");z.width=Q,z.height=j;let W=z.getContext("2d");if(!W)return null;W.drawImage(J,0,0,Q,j),J.pause(),J.srcObject=null;try{return z.toDataURL("image/png")}catch{return null}}function Z4($){return new Promise((J)=>{let Q=!1,j=()=>{if(Q)return;Q=!0,J()},z=$;if(typeof z.requestVideoFrameCallback==="function")z.requestVideoFrameCallback(()=>j()),window.setTimeout(j,1000);else window.setTimeout(j,250)})}async function W4(){let $=N().screenshotFallback;if(!$)return null;let J=await $().catch(()=>null);if(!J)return null;try{return await J(document.body,{cacheBust:!0,pixelRatio:Math.min(window.devicePixelRatio||1,2),filter:(Q)=>!(Q instanceof HTMLElement&&Q.dataset?.debugReporter==="true")})}catch{return null}}var K4=2000,V4=0.82,Y4=3000000;function F4($){return new Promise((J,Q)=>{let j=new Image;j.onload=()=>J(j),j.onerror=()=>Q(Error("could not read the screenshot")),j.src=$})}async function R1($){try{let J=await F4($),Q=Math.max(J.naturalWidth,J.naturalHeight),j=Math.min(1,K4/Q),z=document.createElement("canvas");z.width=Math.max(1,Math.round(J.naturalWidth*j)),z.height=Math.max(1,Math.round(J.naturalHeight*j));let W=z.getContext("2d");if(!W)return $;W.fillStyle="#fff",W.fillRect(0,0,z.width,z.height),W.drawImage(J,0,0,z.width,z.height);let V=V4,X=z.toDataURL("image/jpeg",V);while(X.length>Y4&&V>0.4)V-=0.15,X=z.toDataURL("image/jpeg",V);return X}catch{return $}}var G4=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,X4=/^\d+$/,H4=/^[0-9a-f]{16,}$/i;function O1($){if($.reason.type==="manual")return null;let J=$.cause?.failedRequests?.[0];if(!J?.url)return null;let Q;try{Q=new URL(J.url,"http://x").pathname}catch{Q=J.url}let j=Q.split("/").map((W)=>G4.test(W)||X4.test(W)||H4.test(W)?":id":W).join("/"),z=J.status??(J.error?"ERR":"?");return`${J.method??"REQ"} ${j} ${z}`}var S1=2000000;function K0($){let{screenshotDataUrl:J,...Q}=$;return JSON.stringify(Q).length}function _1($,J=2000000){if(K0($)<=J)return $;let Q=$.network.map((z)=>({...z})),j={...$,network:Q};for(let z of Q){if(K0(j)<=J)return j;if(typeof z.responseSnippet==="string"&&z.responseSnippet.length>35)z.responseSnippet="[body dropped — report size budget]";if(typeof z.requestBody==="string"&&z.requestBody.length>35)z.requestBody="[body dropped — report size budget]"}while(j.network.length>1&&K0(j)>J)j.network=j.network.slice(1);while(j.console.length>1&&K0(j)>J)j.console=j.console.slice(1);return j}var T1=32768;function I4($){let J="";for(let Q=0;Q<$.length;Q+=T1)J+=String.fromCharCode(...$.subarray(Q,Q+T1));return btoa(J)}function U4($){let{screenshotDataUrl:J,...Q}=$;return{dataUri:`data:application/json;base64,${I4(new TextEncoder().encode(JSON.stringify(Q)))}`,filename:"debug-bundle.json"}}async function M4(){let $=N().identity;if(!$)return{};try{let J=await $();return J?{authorization:`Bearer ${J}`}:{}}catch{return{}}}async function A1($,J){let Q=N(),j=_1(J,S1),{context:z,note:W}=j,V=[];if(j.screenshotDataUrl){let q=await R1(j.screenshotDataUrl);V.push({dataUri:q,filename:"screenshot.jpg"})}V.push(U4(j));let X=O1(j),H={title:$,description:W.trim()||void 0,appName:h().name,category:z.module?.label,routeUrl:z.route.href,priority:"MEDIUM",requesterEmail:z.user.email??void 0,requesterName:z.user.fullName??void 0,customFields:{unit:z.user.unit??"",appVersion:z.app.version,environment:z.app.environment,reasonType:j.reason.type,appName:h().name,module:z.module?.label??""},context:{...X?{signature:X}:{},capturedAt:z.capturedAt,reason:j.reason,cause:j.cause,actionTrail:j.actionTrail,client:z.client,performance:z.performance,apiHeaders:z.apiHeaders,extra:z.extra,counts:{network:j.network.length,console:j.console.length,actions:j.actionTrail.length},screenshotMethod:j.screenshotMethod},attachments:V},U=await fetch(`${Q.host.replace(/\/$/,"")}/ingest/tickets`,{method:"POST",headers:{"content-type":"application/json","x-realm-key":Q.realmKey,...await M4()},body:JSON.stringify(H)});if(!U.ok){let q=U.headers.get("retry-after"),P=await U.json().then((w)=>w.error).catch(()=>null);throw Error(U.status===429?`Too many reports — try again in ${q??"a moment"}s`:P??`Report failed (${U.status})`)}return await U.json()}var r=Math.PI/6;function L1($,J,Q){let j=J.x-$.x,z=J.y-$.y,W=Math.hypot(j,z),V=Math.atan2(z,j),X=[{x:J.x,y:J.y},{x:J.x-Q*Math.cos(V-r),y:J.y-Q*Math.sin(V-r)},{x:J.x-Q*Math.cos(V+r),y:J.y-Q*Math.sin(V+r)}],H=Q*Math.cos(r)*0.92;if(W<=H)return{shaft:null,head:X};return{shaft:{from:$,to:{x:J.x-H*Math.cos(V),y:J.y-H*Math.sin(V)}},head:X}}var q0="#f44336",P4="rgba(250, 204, 21, 0.4)",B0=22,f1="#2563eb",E1=9,x1=11,h1=18,p1=4,V0=8,w4=[{id:"nw",fx:0,fy:0,cursor:"nwse-resize"},{id:"n",fx:0.5,fy:0,cursor:"ns-resize"},{id:"ne",fx:1,fy:0,cursor:"nesw-resize"},{id:"e",fx:1,fy:0.5,cursor:"ew-resize"},{id:"se",fx:1,fy:1,cursor:"nwse-resize"},{id:"s",fx:0.5,fy:1,cursor:"ns-resize"},{id:"sw",fx:0,fy:1,cursor:"nesw-resize"},{id:"w",fx:0,fy:0.5,cursor:"ew-resize"}];function m1($,J,Q){let j=[],z=null,W=-1,V=null,X=null,H=$.getContext("2d");function U(){let Z=$.getBoundingClientRect().width;return Z>0?$.width/Z:1}function q(Z){let K=$.getBoundingClientRect();return{x:(Z.clientX-K.left)/K.width*$.width,y:(Z.clientY-K.top)/K.height*$.height}}function P(Z){let K=Z.size??B0;if(!H)return(Z.text?.length??0)*K*0.6;H.save(),H.font=`600 ${K}px system-ui, sans-serif`;let F=H.measureText(Z.text??"").width;return H.restore(),F}function w(Z){if(Z.tool==="text"){let K=Z.size??B0;return{left:Z.x1,top:Z.y1,right:Z.x1+P(Z),bottom:Z.y1+K*1.25}}return{left:Math.min(Z.x1,Z.x2),top:Math.min(Z.y1,Z.y2),right:Math.max(Z.x1,Z.x2),bottom:Math.max(Z.y1,Z.y2)}}function R(Z){if(Z.tool==="arrow")return[{id:"tail",x:Z.x1,y:Z.y1,cursor:"move"},{id:"head",x:Z.x2,y:Z.y2,cursor:"move"}];let K=w(Z);if(Z.tool==="text")return[{id:"size",x:K.right,y:K.bottom,cursor:"nwse-resize"}];return w4.map((F)=>({id:F.id,x:K.left+(K.right-K.left)*F.fx,y:K.top+(K.bottom-K.top)*F.fy,cursor:F.cursor}))}function C(Z){let K=w(Z);return{x:K.right+h1*U(),y:K.top-h1*U()}}function k(Z,K,F){let{shaft:Y,head:G}=L1({x:K.x1,y:K.y1},{x:K.x2,y:K.y2},Math.max(10,16*F));if(Y)Z.lineCap="butt",Z.beginPath(),Z.moveTo(Y.from.x,Y.from.y),Z.lineTo(Y.to.x,Y.to.y),Z.stroke();Z.beginPath(),Z.moveTo(G[0].x,G[0].y),Z.lineTo(G[1].x,G[1].y),Z.lineTo(G[2].x,G[2].y),Z.closePath(),Z.fill()}function _(Z,K,F){Z.save(),Z.lineWidth=Math.max(2,3*F),Z.strokeStyle=q0,Z.fillStyle=q0;let Y=w(K);if(K.tool==="rect")Z.strokeRect(Y.left,Y.top,Y.right-Y.left,Y.bottom-Y.top);else if(K.tool==="arrow")k(Z,K,F);else if(K.tool==="highlight")Z.fillStyle=P4,Z.fillRect(Y.left,Y.top,Y.right-Y.left,Y.bottom-Y.top);else if(K.tool==="text"&&K.text){let G=K.size??B0;Z.font=`600 ${G}px system-ui, sans-serif`,Z.textBaseline="top";let I=G*0.22;Z.fillStyle="rgba(255,255,255,0.92)",Z.fillRect(Y.left-I,Y.top-I,Y.right-Y.left+I*2,Y.bottom-Y.top+I*2),Z.fillStyle=q0,Z.fillText(K.text,Y.left,Y.top)}Z.restore()}function n(Z,K,F){let Y=w(K);Z.save(),Z.strokeStyle=f1,Z.lineWidth=Math.max(1,1.5*F),Z.setLineDash([6*F,4*F]),Z.strokeRect(Y.left,Y.top,Y.right-Y.left,Y.bottom-Y.top),Z.setLineDash([]);let G=E1*F;for(let O of R(K))Z.fillStyle="#fff",Z.strokeStyle=f1,Z.lineWidth=Math.max(1,1.5*F),Z.beginPath(),Z.rect(O.x-G/2,O.y-G/2,G,G),Z.fill(),Z.stroke();let I=C(K),M=x1*F;Z.beginPath(),Z.arc(I.x,I.y,M,0,Math.PI*2),Z.fillStyle="#dc2626",Z.fill(),Z.strokeStyle="#fff",Z.lineWidth=Math.max(1.5,2*F),Z.beginPath(),Z.moveTo(I.x-M*0.4,I.y-M*0.4),Z.lineTo(I.x+M*0.4,I.y+M*0.4),Z.moveTo(I.x+M*0.4,I.y-M*0.4),Z.lineTo(I.x-M*0.4,I.y+M*0.4),Z.stroke(),Z.restore()}function B(){if(!H)return;let Z=U();if(H.clearRect(0,0,$.width,$.height),H.drawImage(J,0,0,$.width,$.height),j.forEach((F,Y)=>{if(Y!==a)_(H,F,Z)}),V)_(H,V,Z);let K=j[W];if(K&&!V)n(H,K,Z)}function D0(Z,K,F,Y,G){return Math.abs(Z-F)<=G&&Math.abs(K-Y)<=G}function C0(Z,K){let F=j[W];if(!F)return null;let Y=E1*U()/2+3*U();for(let G of R(F))if(D0(Z,K,G.x,G.y,Y))return G.id;return null}function k0(Z,K){let F=j[W];if(!F)return!1;let Y=C(F);return D0(Z,K,Y.x,Y.y,x1*U())}function Y0(Z,K){let F=6*U();for(let Y=j.length-1;Y>=0;Y-=1){let G=j[Y];if(G.tool==="arrow"){let M=G.x2-G.x1,O=G.y2-G.y1,E=Math.hypot(M,O)||1,x=Math.max(0,Math.min(1,((Z-G.x1)*M+(K-G.y1)*O)/(E*E)));if(Math.hypot(Z-(G.x1+x*M),K-(G.y1+x*O))<=F+4*U())return Y;continue}let I=w(G);if(Z>=I.left-F&&Z<=I.right+F&&K>=I.top-F&&K<=I.bottom+F)return Y}return-1}function u1(Z,K,F,Y,G){if(K==="tail"){Z.x1=F.x1+Y,Z.y1=F.y1+G;return}if(K==="head"){Z.x2=F.x2+Y,Z.y2=F.y2+G;return}if(K==="size"){let o1=(F.size??24)+G;Z.size=Math.max(10,o1);return}let I=w(F),{left:M,top:O,right:E,bottom:x}=I;if(K.includes("w"))M=Math.min(E-V0,M+Y);if(K.includes("e"))E=Math.max(M+V0,E+Y);if(K.includes("n"))O=Math.min(x-V0,O+G);if(K.includes("s"))x=Math.max(O+V0,x+G);Z.x1=M,Z.y1=O,Z.x2=E,Z.y2=x}function d1(Z,K,F,Y){Z.x1=K.x1+F,Z.y1=K.y1+Y,Z.x2=K.x2+F,Z.y2=K.y2+Y}let T=null,a=-1,A={x:0,y:0,size:24};function i1(){let Z=$.getBoundingClientRect().width;return Z>0?Z/$.width:1}function c1(Z,K){if(!H)return Z.length*K*0.6;H.save(),H.font=`600 ${K}px system-ui, sans-serif`;let F=H.measureText(Z||" ").width;return H.restore(),F}function R0(){if(!T)return;let Z=$.parentElement;if(!Z)return;let K=$.getBoundingClientRect(),F=Z.getBoundingClientRect(),Y=i1(),G=A.size*Y;T.style.left=`${K.left-F.left+A.x*Y}px`,T.style.top=`${K.top-F.top+A.y*Y}px`,T.style.fontSize=`${G}px`,T.style.width=`${Math.max(40,c1(T.value,G)+G)}px`}function g(Z){let K=T;if(!K)return;T=null;let F=K.value.trim(),Y=a;if(a=-1,K.remove(),Z&&F){if(Y>=0&&j[Y])j[Y].text=F,W=Y;else j.push({tool:"text",x1:A.x,y1:A.y,x2:A.x,y2:A.y,text:F,size:A.size}),W=j.length-1;Q()}else if(Y>=0)W=Y;$.focus(),B()}function O0(Z,K,F=-1){g(!0);let Y=$.parentElement;if(!Y)return;if(getComputedStyle(Y).position==="static")Y.style.position="relative";let G=F>=0?j[F]:void 0;a=F,A={x:G?.x1??Z,y:G?.y1??K,size:G?.size??Math.round(24*U())};let I=document.createElement("input");I.type="text",I.className="text-edit",I.value=G?.text??"",I.setAttribute("aria-label","ข้อความบนภาพ"),I.placeholder="ข้อความ",T=I,Y.append(I),R0(),I.addEventListener("input",R0),I.addEventListener("keydown",(M)=>{if(M.stopPropagation(),M.key==="Enter")g(!0);else if(M.key==="Escape")g(!1)}),requestAnimationFrame(()=>{if(T!==I)return;I.focus(),I.select(),I.addEventListener("blur",()=>g(!0))}),B()}function S0(Z){let{x:K,y:F}=q(Z);if($.setPointerCapture(Z.pointerId),k0(K,F)){F0();return}let Y=C0(K,F);if(Y&&j[W]){X={grip:Y,x:K,y:F,start:{...j[W]}};return}if(z==="text"){if(Z.preventDefault(),$.hasPointerCapture(Z.pointerId))$.releasePointerCapture(Z.pointerId);z=null,Q(),O0(K,F);return}if(z){V={tool:z,x1:K,y1:F,x2:K,y2:F},W=-1;return}let G=Y0(K,F);W=G,X=G>=0?{grip:"body",x:K,y:F,start:{...j[G]}}:null,B()}function _0(Z){let{x:K,y:F}=q(Z);if(V){V.x2=K,V.y2=F,B();return}if(X){let G=j[W];if(!G)return;let I=K-X.x,M=F-X.y;if(X.grip==="body")d1(G,X.start,I,M);else u1(G,X.grip,X.start,I,M);B();return}if(z){$.style.cursor="crosshair";return}if(k0(K,F)){$.style.cursor="pointer";return}let Y=C0(K,F);if(Y){let G=j[W]?R(j[W]).find((I)=>I.id===Y):null;$.style.cursor=G?.cursor??"pointer";return}$.style.cursor=Y0(K,F)>=0?"move":"default"}function t(){if(V){if(!(Math.abs(V.x2-V.x1)<p1&&Math.abs(V.y2-V.y1)<p1))j.push(V),W=j.length-1,z=null,Q();V=null}if(X)X=null,Q();B()}function T0(Z){let K=$.getBoundingClientRect(),F=(Z.clientX-K.left)/K.width*$.width,Y=(Z.clientY-K.top)/K.height*$.height,G=Y0(F,Y),I=j[G];if(!I||I.tool!=="text")return;Z.preventDefault(),O0(I.x1,I.y1,G)}function A0(Z){if(W<0)return;if(Z.key==="Delete"||Z.key==="Backspace")Z.preventDefault(),F0();else if(Z.key==="Escape")W=-1,B()}function F0(){if(W<0)return;j.splice(W,1),W=-1,Q(),B()}return $.addEventListener("pointerdown",S0),$.addEventListener("pointermove",_0),$.addEventListener("pointerup",t),$.addEventListener("pointercancel",t),$.addEventListener("dblclick",T0),$.tabIndex=0,$.addEventListener("keydown",A0),B(),{setTool(Z){z=Z,W=-1,$.style.cursor=Z?"crosshair":"default",B()},deleteSelected:F0,clear(){j.length=0,W=-1,Q(),B()},hasShapes:()=>j.length>0,hasSelection:()=>W>=0,toDataUrl(){let Z=document.createElement("canvas");Z.width=J.naturalWidth,Z.height=J.naturalHeight;let K=Z.getContext("2d");if(!K)return $.toDataURL("image/png");K.drawImage(J,0,0);let F=U();for(let Y of j)_(K,Y,F);return Z.toDataURL("image/png")},destroy(){g(!1),$.removeEventListener("pointerdown",S0),$.removeEventListener("pointermove",_0),$.removeEventListener("pointerup",t),$.removeEventListener("pointercancel",t),$.removeEventListener("dblclick",T0),$.removeEventListener("keydown",A0)}}}var y1=`
|
|
34
34
|
:host { all: initial; }
|
|
35
35
|
* { box-sizing: border-box; }
|
|
36
36
|
|
|
@@ -113,4 +113,4 @@ canvas { width: 100%; height: auto; display: block; border: 1px solid #e2e8f0; b
|
|
|
113
113
|
border-radius: 0 0 16px 16px;
|
|
114
114
|
}
|
|
115
115
|
.foot .grow { flex: 1; }
|
|
116
|
-
`;var
|
|
116
|
+
`;var s="lw-debug-reporter",q4=()=>[];var B4=[{tool:"rect",key:"toolRect"},{tool:"arrow",key:"toolArrow"},{tool:"highlight",key:"toolHighlight"},{tool:"text",key:"toolText"}];function N4(){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=z1((J)=>void this.open(J))}disconnectedCallback(){this.stop?.(),this.stop=null,this.close()}async open(J){if(this.busy)return;this.busy=!0;let Q=W0(N().locale),j=await k1();if(j.method==="cancelled"){this.close();return}this.bundle=C1({reason:J,note:"",screenshotDataUrl:j.dataUrl,screenshotMethod:j.method,erroredQueries:D4()}),this.renderForm(Q)}close(){this.annotator?.destroy(),this.annotator=null,this.bundle=null,this.busy=!1,this.root.replaceChildren()}shell(J){let Q=document.createElement("style");Q.textContent=y1;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",J.title),j.append(z),this.root.replaceChildren(Q,j),z}renderShell(J,Q){let j=this.shell(J),z=D("div","head");z.append(D("h2","",J.title)),j.append(z,D("p","status",Q))}renderForm(J){let Q=this.bundle;if(!Q)return;let j=this.shell(J),z=D("div","head"),W=y("✕","icon");W.setAttribute("aria-label",J.close),W.addEventListener("click",()=>this.close()),z.append(D("h2","",J.title),W);let V=document.createElement("input");V.type="text",V.placeholder=J.summaryPlaceholder;let X=N0(J.summaryLabel,J.summaryRequired,!0),H=document.createElement("textarea");H.placeholder=J.detailPlaceholder;let U=D("div","meta");U.innerHTML="";let{context:q}=Q;for(let[k,_]of[[J.reporter,`${q.user.fullName??"—"} (${q.user.email??"—"})`],[J.page,q.route.href],[J.captured,`${Q.network.length} network · ${Q.console.length} console · ${Q.actionTrail.length} actions`]]){let n=document.createElement("div"),B=document.createElement("b");B.textContent=`${k}: `,n.append(B,document.createTextNode(_)),U.append(n)}let P=D("p","status",""),w=y(J.submit,"primary");if(w.disabled=!0,V.addEventListener("input",()=>{w.disabled=V.value.trim().length===0}),j.append(z,X,V,N0(J.detailLabel),H,U),Q.screenshotDataUrl)j.append(...this.screenshotSection(J,Q.screenshotDataUrl));else j.append(D("p","status",J.noScreenshot));let R=D("div","foot"),C=y(J.close);C.addEventListener("click",()=>this.close()),R.append(C,P,D("span","grow"),w),j.append(R),w.addEventListener("click",async()=>{w.disabled=!0,P.dataset.tone="",P.textContent=J.submitting;try{let k=await A1(V.value.trim(),{...Q,note:H.value,screenshotDataUrl:this.annotator?.hasShapes()?this.annotator.toDataUrl():Q.screenshotDataUrl}),_=this.dispatchEvent(new CustomEvent("lw-report-submitted",{detail:k,bubbles:!0,composed:!0,cancelable:!0}));if(this.close(),_)l(`${J.submitted} — #${k.number}`,"success")}catch(k){let _=k instanceof Error?k.message:J.failed;P.dataset.tone="error",P.textContent=_,l(`${J.failed} — ${_}`,"error"),w.disabled=!1}}),V.focus()}screenshotSection(J,Q){let j=N0(J.annotateHint),z=D("div","tools"),W=document.createElement("canvas"),V=D("div","shot");V.append(W);let X=[],H=(w)=>{for(let R of X)R.setAttribute("aria-pressed",String(R===w))};for(let{tool:w,key:R}of B4){let C=y(J[R]);C.setAttribute("aria-pressed","false"),C.addEventListener("click",()=>{let k=C.getAttribute("aria-pressed")==="true";H(k?null:C),this.annotator?.setTool(k?null:w)}),X.push(C),z.append(C)}z.append(D("span","sep"));let U=y(J.deleteSelected);U.addEventListener("click",()=>this.annotator?.deleteSelected());let q=y(J.clearAll);q.addEventListener("click",()=>{this.annotator?.clear(),H(null)}),z.append(U,q);let P=new Image;return P.onload=()=>{W.width=P.naturalWidth,W.height=P.naturalHeight,this.annotator=m1(W,P,()=>{H(null),U.disabled=!this.annotator?.hasSelection()})},P.src=Q,[j,z,D("p","status",J.annotateHelp),V]}}}function D4(){try{return q4()}catch{return[]}}function D($,J="",Q=""){let j=document.createElement($);if(J)j.className=J;if(Q)j.textContent=Q;return j}function y($,J=""){let Q=document.createElement("button");if(Q.type="button",Q.textContent=$,J)Q.className=J;return Q}function N0($,J="",Q=!1){let j=document.createElement("label");if(j.append(document.createTextNode($)),Q){let z=document.createElement("span");z.className="req",z.textContent=" *",j.append(z)}if(J){let z=document.createElement("span");z.className="hint",z.textContent=` ${J}`,j.append(z)}return j}function g1(){if(typeof window>"u"||customElements.get(s))return;customElements.define(s,N4())}var v1=!1;function b1($={}){if(v1||typeof window>"u")return;if(!e()){console.error("[debug-capture] configureDebugCapture() must be called before install");return}if(v1=!0,q1(),t0(),o0(),F1(),$.ui===!1)return;let J=W0(N().locale);if(Z1((Q)=>{l(Q.message??J.crashed,"error",{label:J.crashAction,onClick:()=>z0(Q)})}),g1(),!document.querySelector(s))document.body.append(document.createElement(s))}var C4=document.currentScript,L=C4?.dataset??{};function k4($){if(!$)return{};try{let J=JSON.parse($);if(!J||typeof J!=="object"||Array.isArray(J))return{};return Object.fromEntries(Object.entries(J).filter(([,Q])=>typeof Q==="string"&&Q.trim()))}catch{return{}}}if(L.host&&L.realmKey)L0({host:L.host,realmKey:L.realmKey,app:{name:L.appName??document.title??"app",version:L.appVersion??"0.0.0",environment:L.environment??"production"},module:h0(k4(L.modules)),locale:L.locale==="en"?"en":"th"}),b1();window.lwReportProblem=z0;})();
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var J2={maxRequests:60,maxConsoleEntries:120,maxActions:80,maxBodyChars:20000},T=null;function Q2($){let j=[];if(!$.host?.trim())j.push("host");if(!$.realmKey?.trim())j.push("realmKey");if(!$.app?.name?.trim())j.push("app.name");if(typeof $.module!=="function")j.push("module");if(j.length)throw Error(`[debug-capture] configureDebugCapture is missing: ${j.join(", ")}. `+"See the README — `module` maps a pathname to the part of your app it belongs to.");T=$}function q(){if(!T)throw Error("[debug-capture] configureDebugCapture() has not been called");return T}function j0(){return T!==null}function x(){let $=q().app;return{name:$.name,version:$.version??"0.0.0",environment:$.environment??z2()}}function z2(){if(typeof window>"u")return"unknown";let $=window.location.hostname;if($==="localhost"||$==="127.0.0.1"||$.endsWith(".local"))return"development";return"production"}function h($){let j=T?.capture?.[$];return typeof j==="number"?j:J2[$]}function n0($){let j=T?.module;if(!j)return null;try{return j($)??null}catch{return null}}function W0(){let $=T?.redact;return{headers:$?.headers??[],queryKeys:($?.queryKeys??[]).map((j)=>j.toLowerCase()),bodyKeys:($?.bodyKeys??[]).map((j)=>j.toLowerCase())}}function a0(){return T?.capture?.overlaySelectors??[]}function t0($){if(typeof window>"u")return!1;let j;try{j=new URL($,window.location.href)}catch{return!1}if(Z2(j))return!1;if(j.origin===window.location.origin)return!0;return(T?.capture?.bodyOrigins??[]).some((J)=>{try{return new URL(J).origin===j.origin}catch{return!1}})}function Z2($){if(!T?.host)return!1;try{if(new URL(T.host).origin!==$.origin)return!1}catch{return!1}return $.pathname.startsWith("/ingest/")}function W2($){let j=Object.entries($).map(([J,Q])=>[J.replace(/\/+$/,"")||"/",Q]).sort((J,Q)=>Q[0].length-J[0].length);return(J)=>{let Q=(J||"/").replace(/\/+$/,"")||"/";for(let[z,W]of j)if(Q===z||Q.startsWith(`${z}/`))return{key:z,label:W};return null}}var d="‹redacted›",K2=/^(authorization|proxy-authorization|cookie|set-cookie|x-[a-z-]*token|x-csrf[a-z-]*|x-xsrf[a-z-]*)$/i,V2=new Set(["access_token","token","id_token","refresh_token","code","secret","client_secret","password","apikey","api_key","signature","x-amz-signature","x-amz-credential"]),X2=/(password|passwd|token|secret|authorization|refresh|client_secret|otp|pin)/i,Y2=/[\w.+-]+@[\w-]+\.[\w.-]+/g,G2=/\d(?:[\d\s-]{7,})\d/g;function c($){return $.replace(Y2,d).replace(G2,d)}function F2($){if(K2.test($))return!0;return W0().headers.some((J)=>J.toLowerCase()===$.toLowerCase())}function i($){let j={};for(let[J,Q]of Object.entries($))j[J]=F2(J)?d:Q;return j}function o($){try{let j=/^https?:\/\//i.test($),J=new URL($,j?void 0:"http://local.invalid"),Q=!1;if(J.searchParams.forEach((z,W)=>{if(V2.has(W.toLowerCase())||W0().queryKeys.includes(W.toLowerCase()))J.searchParams.set(W,d),Q=!0}),!Q)return $;return j?J.toString():`${J.pathname}${J.search}`}catch{return $}}function P0($,j){if(j>6||$===null||typeof $!=="object")return $;if(Array.isArray($))return $.map((Q)=>P0(Q,j+1));let J={};for(let[Q,z]of Object.entries($)){let W=X2.test(Q)||W0().bodyKeys.some((K)=>Q.toLowerCase().includes(K));J[Q]=W?d:P0(z,j+1)}return J}function l($,j){if($==null)return null;let J=$,Q=$.trim();if(Q.startsWith("{")||Q.startsWith("["))try{let z=JSON.parse(Q);J=JSON.stringify(P0(z,0))}catch{}if(J.length>j)return`${J.slice(0,j)}… [truncated ${J.length-j} chars]`;return J}var C0=120,I0=40,s=($,j)=>$.length>j?`${$.slice(0,j)}…`:$,w0=($)=>{try{return decodeURIComponent($)}catch{return $}},r=[],e0=0,$1=!1;function J0($,j,J,Q){let z=s(j,C0),W=r[r.length-1];if($==="navigate"&&W?.kind==="click"){let G=z.replace(/^ไปที่\s*/,"");if(W.detail.includes(`→ ${G}`))return W.at=new Date().toISOString(),W;let F=G.split(/[?#]/)[0]??G,U=W.source?w0(W.source.replace(/^→\s*/,"")).split(/[?#]/)[0]:null;if(U&&(F===U||F.startsWith(U)))return W.detail=s(`${W.detail} → ${G}`,C0),W.source=void 0,W.at=new Date().toISOString(),W}if(W&&W.kind===$&&W.detail===z){if(W.at=new Date().toISOString(),$!=="navigate")W.count=(W.count??1)+1;return W}e0+=1;let K={id:`act_${e0}`,at:new Date().toISOString(),kind:$,detail:z,count:1,source:J,html:V0(Q)};r.push(K);while(r.length>h("maxActions"))M2(r.shift());return K}var H2=200000,Q0=0;function V0($){if(!$)return;if(Q0+$.length>H2)return;return Q0+=$.length,$}function M2($){if(!$)return;if(Q0-=($.html?.length??0)+($.afterHtml?.length??0),Q0<0)Q0=0}function D0($){return $&&$>1?` (×${$})`:""}function K0($){return $ instanceof Element&&Boolean($.closest("[data-debug-reporter]"))}var U2='button, a[href], [role="button"], [role="tab"], [role="menuitem"], [role="option"], [role="switch"], [role="checkbox"], [role="radio"], [role="link"], summary, input, select, textarea',P2={button:"ปุ่ม",a:"ลิงก์",input:"ช่อง",textarea:"ช่อง",select:"ตัวเลือก",summary:"ส่วนขยาย"},j1={button:"ปุ่ม",tab:"แท็บ",menuitem:"เมนู",option:"ตัวเลือก",switch:"สวิตช์",checkbox:"ช่องเลือก",radio:"ตัวเลือก",link:"ลิงก์"};function C2($){let j=$.getAttribute("role");if(j&&j1[j])return j1[j];return P2[$.tagName.toLowerCase()]??"ปุ่ม"}function I2($,j){try{let J=$,Q=0;while(J&&Q<=j){let z=K1(J);if(z&&typeof z.memoizedProps?.onClick==="function")return J;J=J.parentElement,Q+=1}}catch{}return null}function w2($){let j=$.getAttribute("aria-label")?.trim();if(j)return j;let J=$.getAttribute("title")?.trim();if(J)return J;if($ instanceof HTMLInputElement||$ instanceof HTMLTextAreaElement||$ instanceof HTMLSelectElement)return($.getAttribute("placeholder")||$.getAttribute("name")||"").trim();if($ instanceof HTMLImageElement)return($.getAttribute("alt")||"").trim();let Q=($.textContent??"").replace(/\s+/g," ").trim();if(Q)return Q;if($ instanceof HTMLAnchorElement){let z=$.getAttribute("href");if(z?.startsWith("/"))return w0(z)}return""}function D2($){if(!($ instanceof Element))return null;let j=$.closest(U2)??I2($,4);if(!j)return null;let J=j.tagName.toLowerCase();if(J==="html"||J==="body")return null;return j}function N2($){let j=c(w2($));if(!j)return null;return`${C2($)} “${s(j,I0)}”`}var W1=6000,B2=4000,q2=/(?:^|\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 S2($){$.querySelectorAll("script, style, link, iframe, object, embed, noscript, canvas, video, audio").forEach((z)=>z.remove());let j=[$,...Array.from($.querySelectorAll("*"))];for(let z of j){for(let K of Array.from(z.attributes)){let G=K.name.toLowerCase();if(G.startsWith("on")||G==="srcdoc"||G==="value"||G.startsWith("data-"))z.removeAttribute(K.name)}if(z instanceof HTMLAnchorElement)z.setAttribute("href","#");if(z instanceof HTMLImageElement)z.removeAttribute("src");let W=z.getAttribute("class");if(W){let K=W.replace(q2," ").replace(/\s+/g," ").trim();if(K)z.setAttribute("class",K);else z.removeAttribute("class")}}let J=document.createTreeWalker($,NodeFilter.SHOW_TEXT),Q=J.nextNode();while(Q){if(Q.nodeValue)Q.nodeValue=c(Q.nodeValue);Q=J.nextNode()}}function N0($,j,J){try{let Q=$.outerHTML;if(!Q||Q.length>j)return;let z=$.cloneNode(!0);S2(z);let W=z.outerHTML;return W&&W.length<=J?W:void 0}catch{return}}var R2=($)=>N0($,W1,B2),O2=150000,_2=40000,J1=($)=>N0($,O2,_2);function L2($){if(!($ instanceof HTMLInputElement)&&!($ instanceof HTMLTextAreaElement)&&!($ instanceof HTMLSelectElement))return null;let j=$.name||$.id||$.getAttribute("aria-label")||$.getAttribute("placeholder")||$.tagName.toLowerCase();return`ช่อง “${c(j)}”`}var Q1=80;function K1($){let j=Object.keys($).find((J)=>J.startsWith("__reactFiber$")||J.startsWith("__reactInternalInstance$"));return j?$[j]:null}function A2($){if(typeof $!=="function")return null;try{let j=Function.prototype.toString.call($);return(j.match(/\.(?:push|replace)\(\s*['"`]([^'"`]+)['"`]/)??j.match(/redirect\(\s*['"`]([^'"`]+)['"`]/))?.[1]??null}catch{return null}}function z1($){if(!$)return;return`→ ${$.length>Q1?`${$.slice(0,Q1)}…`:$}`}function k2($){try{let j=$.closest("a[href]")?.getAttribute("href");if(j&&j.startsWith("/"))return z1(j);let J=K1($),Q=0;while(J&&Q<30){if(typeof J.memoizedProps?.onClick==="function")return z1(A2(J.memoizedProps.onClick));J=J.return,Q+=1}return}catch{return}}var T2='[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], [role="status"], [role="alert"]';function f2(){let $=a0();return $.length?$.join(", "):T2}function E2($){let j=$.getAttribute("role");if(j==="status"||j==="alert")return"ข้อความแจ้งเตือน";if(j==="menu")return"เมนู";if(j==="listbox")return"รายการตัวเลือก";if(j==="alertdialog")return"กล่องยืนยัน";return"กล่องโต้ตอบ"}function x2($){let j=$.getAttribute("aria-label")?.trim();if(j)return j;let J=$.getAttribute("aria-labelledby");if(J){let W=J.split(/\s+/).map((K)=>document.getElementById(K)?.textContent?.trim()??"").filter(Boolean).join(" ");if(W)return W}let z=$.querySelector('[data-slot="dialog-title"], h1, h2, h3, [role="heading"]')?.textContent?.replace(/\s+/g," ").trim();if(z)return z;return($.textContent??"").replace(/\s+/g," ").trim()}function V1($){let j=c(x2($)),J=E2($);return j?`เปิด ${J} “${s(j,I0)}”`:`เปิด ${J}`}var h2='[aria-busy="true"], [role="progressbar"], [data-loading="true"], .animate-pulse, .animate-spin',p2=/กำลังโหลด|กำลังค้นหา|กำลังดำเนินการ|\bloading\b/i;function m2($){if($.querySelector(h2))return!0;return p2.test($.textContent??"")}var g2=400,v2=250,y2=8000;function b2($,j){if(typeof MutationObserver>"u"){j.html=V0(J1($));return}let J=Date.now(),Q=!1,z=()=>{Q=!0,K.disconnect(),window.clearInterval(G),window.clearTimeout(F)},W=()=>{if(Q)return;if(z(),!$.isConnected)return;j.detail=s(V1($),C0),j.html=V0(J1($))},K=new MutationObserver(()=>{J=Date.now()});K.observe($,{childList:!0,subtree:!0,attributes:!0,characterData:!0});let G=window.setInterval(()=>{if(Q)return;if(!$.isConnected){z();return}if(Date.now()-J>=g2&&!m2($))W()},v2),F=window.setTimeout(W,y2)}function u2($){if(K0($))return;let j=J0("ui",V1($));if(j)b2($,j)}function d2(){if(typeof MutationObserver>"u")return;let $=new WeakSet;new MutationObserver((J)=>{for(let Q of J)for(let z of Array.from(Q.addedNodes)){if(!(z instanceof Element))continue;let W=f2(),K=z.matches(W)?[z]:Array.from(z.querySelectorAll(W));for(let G of K){if($.has(G))continue;$.add(G),u2(G)}}}).observe(document.body,{childList:!0,subtree:!0})}var c2=1600,i2=2500;function Z1($){return{disabled:$.hasAttribute("disabled")||$.getAttribute("aria-disabled")==="true",busy:$.getAttribute("aria-busy")==="true",text:s(($.textContent??"").replace(/\s+/g," ").trim(),I0)}}function o2($,j){if(!$.disabled&&j.disabled)return"ปุ่มถูกปิดใช้งานหลังคลิก";if(!$.busy&&j.busy)return"ปุ่มเข้าสู่สถานะกำลังโหลด";if($.text!==j.text&&j.text)return`ข้อความเปลี่ยนเป็น “${j.text}”`;return null}function l2($,j){if(typeof MutationObserver>"u")return;let J=Z1($),Q=!1,z=(G,F)=>{if(Q)return;if(Q=!0,W.disconnect(),window.clearTimeout(K),j.afterNote=G,F)j.afterHtml=V0(N0($,W1,i2))},W=new MutationObserver(()=>{if(!$.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}let G=o2(J,Z1($));if(G)z(G,!0)});W.observe($,{attributes:!0,attributeFilter:["disabled","aria-disabled","aria-busy","class"],childList:!0,subtree:!0,characterData:!0});let K=window.setTimeout(()=>{if(!Q&&!$.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}Q=!0,W.disconnect()},c2)}function X1(){if($1||typeof window>"u")return;$1=!0,document.addEventListener("click",(Q)=>{if(K0(Q.target))return;let z=D2(Q.target);if(!z)return;let W=N2(z);if(!W)return;let K=J0("click",`คลิก ${W}`,k2(z),R2(z));if(K)l2(z,K)},{capture:!0,passive:!0}),document.addEventListener("change",(Q)=>{if(K0(Q.target))return;let z=L2(Q.target);if(z)J0("input",`แก้ไข ${z}`)},{capture:!0,passive:!0}),document.addEventListener("submit",(Q)=>{if(K0(Q.target))return;J0("submit","ส่งฟอร์ม")},{capture:!0,passive:!0});let $=()=>J0("navigate",`ไปที่ ${w0(o(location.pathname+location.search))}`),j=history.pushState.bind(history),J=history.replaceState.bind(history);history.pushState=(...Q)=>{let z=j(...Q);return $(),z},history.replaceState=(...Q)=>{let z=J(...Q);return $(),z},window.addEventListener("popstate",$),d2()}function B0(){return r.map(($)=>({...$}))}var Y1=2000,X0=[],G1=0,F1=!1;function q0($,j){G1+=1,X0.push({id:`log_${G1}`,at:new Date().toISOString(),level:$,message:j.length>Y1?`${j.slice(0,Y1)}…`:j});while(X0.length>h("maxConsoleEntries"))X0.shift()}function r2(){let $=new WeakSet;return(j,J)=>{if(typeof J==="object"&&J!==null){if($.has(J))return"[Circular]";$.add(J)}if(typeof J==="bigint")return J.toString();return J}}function H1($){if(typeof $==="string")return $;if($ instanceof Error)return`${$.name}: ${$.message}`;try{return JSON.stringify($,r2())??String($)}catch{return String($)}}function M1(){if(F1||typeof window>"u")return;F1=!0;let $=["log","info","warn","error","debug"];for(let j of $){let J=console[j].bind(console);console[j]=(...Q)=>{q0(j,Q.map(H1).join(" ")),J(...Q)}}window.addEventListener("error",(j)=>{let J=j.filename?` (${j.filename}:${j.lineno}:${j.colno})`:"";q0("exception",`${j.message}${J}`)}),window.addEventListener("unhandledrejection",(j)=>{let J=j.reason instanceof Error?`${j.reason.name}: ${j.reason.message}`:H1(j.reason);q0("unhandledrejection",J)})}function S0(){return X0.map(($)=>({...$}))}var U1=new Set,P1=new Set;function C1($,j){return $.add(j),()=>$.delete(j)}function I1($,j){for(let J of[...$])J(j)}function R0($){return C1(U1,$)}function O0($={type:"manual"}){I1(U1,$)}function _0($){return C1(P1,$)}function L0($){I1(P1,$)}var s2=15000,n2=["ResizeObserver loop","Script error.","Non-Error promise rejection captured"],w1=!1,D1=0;function a2($){return n2.some((j)=>$.includes(j))}function N1($){let j=$.message??"";if(!j||a2(j))return;let J=Date.now();if(J-D1<s2)return;D1=J,L0({...$,message:j})}function B1(){if(w1||typeof window>"u")return;w1=!0,window.addEventListener("error",($)=>{if(!$.message&&!$.error)return;let j=$.error instanceof Error?$.error:null;N1({type:"runtime-error",message:$.message||(j?j.message:"Unknown error"),stack:j?.stack})}),window.addEventListener("unhandledrejection",($)=>{let j=$.reason;N1({type:"unhandledrejection",message:j instanceof Error?j.message:String(j),stack:j instanceof Error?j.stack:void 0})})}var O1=4000,t2=1e6,e2=1e7,Y0=[],q1=0,S1=!1;function _1($){Y0.push($);while(Y0.length>h("maxRequests"))Y0.shift()}function L1(){return q1+=1,`req_${q1}`}function R1($){let j={};if(!$)return j;if($ instanceof Headers)$.forEach((J,Q)=>{j[Q]=J});else if(Array.isArray($))for(let[J,Q]of $)j[J]=Q;else Object.assign(j,$);return j}function $4($){let j={};return $.forEach((J,Q)=>{j[Q]=J}),j}function j4($){if($==null)return null;if(typeof $==="string")return $;if($ instanceof URLSearchParams)return $.toString();if(typeof FormData<"u"&&$ instanceof FormData)return`[FormData: ${Array.from($.keys()).join(", ")}]`;if(typeof Blob<"u"&&$ instanceof Blob)return`[Blob ${$.size} bytes]`;if($ instanceof ArrayBuffer)return`[ArrayBuffer ${$.byteLength} bytes]`;return"[binary]"}function J4($,j){let J="",Q="GET",z={},W=null;if(typeof $==="string")J=$;else if($ instanceof URL)J=$.toString();else J=$.url,Q=$.method||Q,z=R1($.headers);if(j){if(j.method)Q=j.method;if(j.headers)z={...z,...R1(j.headers)};if(j.body!==void 0)W=j4(j.body)}return{method:Q.toUpperCase(),url:J,headers:z,body:W}}function A1($){return!t0($)}function Q4($,j){if(A1(j.url)){j.responseSnippet="[body not captured for this origin]";return}let J=$.headers.get("content-type")??"",Q=Number($.headers.get("content-length")??"0"),z=Q?`, ~${Q} bytes`:"";if(!/json|text|xml|html|javascript|urlencoded/i.test(J)){j.responseSnippet=`[binary ${J||"unknown"}${z}]`;return}if(Q>t2){j.responseSnippet=`[response ${J||"text"}${z} — omitted]`;return}try{$.clone().text().then((W)=>{j.responseSnippet=l(W,h("maxBodyChars"))}).catch(()=>{})}catch{}}function k1($,j){if(/[?&]_rsc=/.test($))return!0;for(let J of Object.keys(j)){let Q=J.toLowerCase();if(Q==="rsc"||Q==="next-router-prefetch"||Q==="next-router-state-tree")return!0}return!1}function z4(){if(typeof window>"u"||typeof window.fetch!=="function")return;let $=window.fetch.bind(window);window.fetch=Object.assign(async(j,J)=>{let Q=J4(j,J);if(k1(Q.url,Q.headers))return $(j,J);let z={id:L1(),startedAt:new Date().toISOString(),method:Q.method,url:o(Q.url),requestHeaders:i(Q.headers),requestBody:l(Q.body,O1),status:null,statusText:null,durationMs:null,via:"fetch"};_1(z);let W=performance.now();try{let K=await $(j,J);return z.status=K.status,z.statusText=K.statusText,z.durationMs=Math.round(performance.now()-W),z.responseHeaders=i($4(K.headers)),Q4(K,z),K}catch(K){throw z.durationMs=Math.round(performance.now()-W),z.error=K instanceof Error?`${K.name}: ${K.message}`:String(K),K}},$)}function Z4(){if(typeof window>"u"||typeof window.XMLHttpRequest!=="function")return;let $=XMLHttpRequest.prototype,j=$.open,J=$.send,Q=function(W,K){let G=typeof K==="string"?K:K.toString();return this.__cibEntry=k1(G,{})?void 0:{id:L1(),startedAt:"",method:(W||"GET").toUpperCase(),url:o(G),requestHeaders:{},requestBody:null,status:null,statusText:null,durationMs:null,via:"xhr"},j.apply(this,arguments)},z=function(W){let K=this.__cibEntry;if(K){K.startedAt=new Date().toISOString(),K.requestBody=typeof W==="string"?l(W,O1):W==null?null:"[non-string body]";let G=performance.now();_1(K),this.addEventListener("loadend",()=>{if(K.status=this.status||null,K.statusText=this.statusText||null,K.durationMs=Math.round(performance.now()-G),A1(K.url))K.responseSnippet="[body not captured for this origin]";else if(this.responseType===""||this.responseType==="text")try{K.responseSnippet=l(this.responseText||"",h("maxBodyChars"))}catch{}else{let F=this.getResponseHeader("content-type")??this.responseType;K.responseSnippet=`[binary ${F}]`}})}return J.apply(this,arguments)};$.open=Q,$.send=z}function T1(){if(S1)return;S1=!0,z4(),Z4()}function A0(){let $=Y0.map((J)=>({...J})),j=0;for(let J=$.length-1;J>=0;J-=1){let Q=$[J],z=Q?.responseSnippet;if(!Q||typeof z!=="string"||z.length===0)continue;if(j+z.length>e2)Q.responseSnippet=`[response omitted — report size budget reached (${z.length.toLocaleString()} chars)]`;else j+=z.length}return $}var W4={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:"หน้า",handoffTitle:"กำลังพาไปที่ระบบแจ้งปัญหา",handoffBody:"ระบบจะลงชื่อเข้าใช้ให้อัตโนมัติ เพื่อดูเรื่องที่คุณแจ้งไว้",handoffGo:"ไปเลย",handoffPreparing:"กำลังเตรียม…",handoffFailed:"เปิดรายการที่แจ้งไว้ไม่สำเร็จ",handoffBlocked:"เบราว์เซอร์บล็อกการเปิดแท็บใหม่",handoffOpen:"เปิดในแท็บใหม่"},K4={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",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 b($){return $==="en"?K4:W4}var V4="lw-debug-toasts",X4=6000,Y4=`
|
|
1
|
+
var Q2={maxRequests:60,maxConsoleEntries:120,maxActions:80,maxBodyChars:20000},k=null;function z2(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 w(){if(!k)throw Error("[debug-capture] configureDebugCapture() has not been called");return k}function $0(){return k!==null}function f(){let J=w().app;return{name:J.name,version:J.version??"0.0.0",environment:J.environment??j2()}}function j2(){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 h(J){let $=k?.capture?.[J];return typeof $==="number"?$:Q2[J]}function n0(J){let $=k?.module;if(!$)return null;try{return $(J)??null}catch{return null}}function W0(){let J=k?.redact;return{headers:J?.headers??[],queryKeys:(J?.queryKeys??[]).map(($)=>$.toLowerCase()),bodyKeys:(J?.bodyKeys??[]).map(($)=>$.toLowerCase())}}function a0(){return k?.capture?.overlaySelectors??[]}function t0(J){if(typeof window>"u")return!1;let $;try{$=new URL(J,window.location.href)}catch{return!1}if(Z2($))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 Z2(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 W2(J){let $=Object.entries(J).map(([Q,z])=>[Q.replace(/\/+$/,"")||"/",z]).sort((Q,z)=>z[0].length-Q[0].length);return(Q)=>{let z=(Q||"/").replace(/\/+$/,"")||"/";for(let[j,W]of $)if(z===j||z.startsWith(`${j}/`))return{key:j,label:W};return null}}var d="‹redacted›",K2=/^(authorization|proxy-authorization|cookie|set-cookie|x-[a-z-]*token|x-csrf[a-z-]*|x-xsrf[a-z-]*)$/i,V2=new Set(["access_token","token","id_token","refresh_token","code","secret","client_secret","password","apikey","api_key","signature","x-amz-signature","x-amz-credential"]),Y2=/(password|passwd|token|secret|authorization|refresh|client_secret|otp|pin)/i,X2=/[\w.+-]+@[\w-]+\.[\w.-]+/g,F2=/\d(?:[\d\s-]{7,})\d/g;function c(J){return J.replace(X2,d).replace(F2,d)}function G2(J){if(K2.test(J))return!0;return W0().headers.some((Q)=>Q.toLowerCase()===J.toLowerCase())}function i(J){let $={};for(let[Q,z]of Object.entries(J))$[Q]=G2(Q)?d:z;return $}function l(J){try{let $=/^https?:\/\//i.test(J),Q=new URL(J,$?void 0:"http://local.invalid"),z=!1;if(Q.searchParams.forEach((j,W)=>{if(V2.has(W.toLowerCase())||W0().queryKeys.includes(W.toLowerCase()))Q.searchParams.set(W,d),z=!0}),!z)return J;return $?Q.toString():`${Q.pathname}${Q.search}`}catch{return J}}function P0(J,$){if($>6||J===null||typeof J!=="object")return J;if(Array.isArray(J))return J.map((z)=>P0(z,$+1));let Q={};for(let[z,j]of Object.entries(J)){let W=Y2.test(z)||W0().bodyKeys.some((K)=>z.toLowerCase().includes(K));Q[z]=W?d:P0(j,$+1)}return Q}function o(J,$){if(J==null)return null;let Q=J,z=J.trim();if(z.startsWith("{")||z.startsWith("["))try{let j=JSON.parse(z);Q=JSON.stringify(P0(j,0))}catch{}if(Q.length>$)return`${Q.slice(0,$)}… [truncated ${Q.length-$} chars]`;return Q}var I0=120,D0=40,s=(J,$)=>J.length>$?`${J.slice(0,$)}…`:J,N0=(J)=>{try{return decodeURIComponent(J)}catch{return J}},r=[],e0=0,J1=!1;function Q0(J,$,Q,z){let j=s($,I0),W=r[r.length-1];if(J==="navigate"&&W?.kind==="click"){let F=j.replace(/^ไปที่\s*/,"");if(W.detail.includes(`→ ${F}`))return W.at=new Date().toISOString(),W;let G=F.split(/[?#]/)[0]??F,M=W.source?N0(W.source.replace(/^→\s*/,"")).split(/[?#]/)[0]:null;if(M&&(G===M||G.startsWith(M)))return W.detail=s(`${W.detail} → ${F}`,I0),W.source=void 0,W.at=new Date().toISOString(),W}if(W&&W.kind===J&&W.detail===j){if(W.at=new Date().toISOString(),J!=="navigate")W.count=(W.count??1)+1;return W}e0+=1;let K={id:`act_${e0}`,at:new Date().toISOString(),kind:J,detail:j,count:1,source:Q,html:V0(z)};r.push(K);while(r.length>h("maxActions"))U2(r.shift());return K}var H2=200000,z0=0;function V0(J){if(!J)return;if(z0+J.length>H2)return;return z0+=J.length,J}function U2(J){if(!J)return;if(z0-=(J.html?.length??0)+(J.afterHtml?.length??0),z0<0)z0=0}function C0(J){return J&&J>1?` (×${J})`:""}function K0(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',P2={button:"ปุ่ม",a:"ลิงก์",input:"ช่อง",textarea:"ช่อง",select:"ตัวเลือก",summary:"ส่วนขยาย"},$1={button:"ปุ่ม",tab:"แท็บ",menuitem:"เมนู",option:"ตัวเลือก",switch:"สวิตช์",checkbox:"ช่องเลือก",radio:"ตัวเลือก",link:"ลิงก์"};function I2(J){let $=J.getAttribute("role");if($&&$1[$])return $1[$];return P2[J.tagName.toLowerCase()]??"ปุ่ม"}function D2(J,$){try{let Q=J,z=0;while(Q&&z<=$){let j=K1(Q);if(j&&typeof j.memoizedProps?.onClick==="function")return Q;Q=Q.parentElement,z+=1}}catch{}return null}function N2(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 z=(J.textContent??"").replace(/\s+/g," ").trim();if(z)return z;if(J instanceof HTMLAnchorElement){let j=J.getAttribute("href");if(j?.startsWith("/"))return N0(j)}return""}function C2(J){if(!(J instanceof Element))return null;let $=J.closest(M2)??D2(J,4);if(!$)return null;let Q=$.tagName.toLowerCase();if(Q==="html"||Q==="body")return null;return $}function B2(J){let $=c(N2(J));if(!$)return null;return`${I2(J)} “${s($,D0)}”`}var W1=6000,q2=4000,w2=/(?:^|\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 R2(J){J.querySelectorAll("script, style, link, iframe, object, embed, noscript, canvas, video, audio").forEach((j)=>j.remove());let $=[J,...Array.from(J.querySelectorAll("*"))];for(let j of $){for(let K of Array.from(j.attributes)){let F=K.name.toLowerCase();if(F.startsWith("on")||F==="srcdoc"||F==="value"||F.startsWith("data-"))j.removeAttribute(K.name)}if(j instanceof HTMLAnchorElement)j.setAttribute("href","#");if(j instanceof HTMLImageElement)j.removeAttribute("src");let W=j.getAttribute("class");if(W){let K=W.replace(w2," ").replace(/\s+/g," ").trim();if(K)j.setAttribute("class",K);else j.removeAttribute("class")}}let Q=document.createTreeWalker(J,NodeFilter.SHOW_TEXT),z=Q.nextNode();while(z){if(z.nodeValue)z.nodeValue=c(z.nodeValue);z=Q.nextNode()}}function B0(J,$,Q){try{let z=J.outerHTML;if(!z||z.length>$)return;let j=J.cloneNode(!0);R2(j);let W=j.outerHTML;return W&&W.length<=Q?W:void 0}catch{return}}var S2=(J)=>B0(J,W1,q2),O2=150000,_2=40000,Q1=(J)=>B0(J,O2,_2);function L2(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`ช่อง “${c($)}”`}var z1=80;function K1(J){let $=Object.keys(J).find((Q)=>Q.startsWith("__reactFiber$")||Q.startsWith("__reactInternalInstance$"));return $?J[$]:null}function A2(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 j1(J){if(!J)return;return`→ ${J.length>z1?`${J.slice(0,z1)}…`:J}`}function T2(J){try{let $=J.closest("a[href]")?.getAttribute("href");if($&&$.startsWith("/"))return j1($);let Q=K1(J),z=0;while(Q&&z<30){if(typeof Q.memoizedProps?.onClick==="function")return j1(A2(Q.memoizedProps.onClick));Q=Q.return,z+=1}return}catch{return}}var k2='[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], [role="status"], [role="alert"]';function E2(){let J=a0();return J.length?J.join(", "):k2}function x2(J){let $=J.getAttribute("role");if($==="status"||$==="alert")return"ข้อความแจ้งเตือน";if($==="menu")return"เมนู";if($==="listbox")return"รายการตัวเลือก";if($==="alertdialog")return"กล่องยืนยัน";return"กล่องโต้ตอบ"}function f2(J){let $=J.getAttribute("aria-label")?.trim();if($)return $;let Q=J.getAttribute("aria-labelledby");if(Q){let W=Q.split(/\s+/).map((K)=>document.getElementById(K)?.textContent?.trim()??"").filter(Boolean).join(" ");if(W)return W}let j=J.querySelector('[data-slot="dialog-title"], h1, h2, h3, [role="heading"]')?.textContent?.replace(/\s+/g," ").trim();if(j)return j;return(J.textContent??"").replace(/\s+/g," ").trim()}function V1(J){let $=c(f2(J)),Q=x2(J);return $?`เปิด ${Q} “${s($,D0)}”`:`เปิด ${Q}`}var h2='[aria-busy="true"], [role="progressbar"], [data-loading="true"], .animate-pulse, .animate-spin',m2=/กำลังโหลด|กำลังค้นหา|กำลังดำเนินการ|\bloading\b/i;function p2(J){if(J.querySelector(h2))return!0;return m2.test(J.textContent??"")}var y2=400,v2=250,g2=8000;function b2(J,$){if(typeof MutationObserver>"u"){$.html=V0(Q1(J));return}let Q=Date.now(),z=!1,j=()=>{z=!0,K.disconnect(),window.clearInterval(F),window.clearTimeout(G)},W=()=>{if(z)return;if(j(),!J.isConnected)return;$.detail=s(V1(J),I0),$.html=V0(Q1(J))},K=new MutationObserver(()=>{Q=Date.now()});K.observe(J,{childList:!0,subtree:!0,attributes:!0,characterData:!0});let F=window.setInterval(()=>{if(z)return;if(!J.isConnected){j();return}if(Date.now()-Q>=y2&&!p2(J))W()},v2),G=window.setTimeout(W,g2)}function u2(J){if(K0(J))return;let $=Q0("ui",V1(J));if($)b2(J,$)}function d2(){if(typeof MutationObserver>"u")return;let J=new WeakSet;new MutationObserver((Q)=>{for(let z of Q)for(let j of Array.from(z.addedNodes)){if(!(j instanceof Element))continue;let W=E2(),K=j.matches(W)?[j]:Array.from(j.querySelectorAll(W));for(let F of K){if(J.has(F))continue;J.add(F),u2(F)}}}).observe(document.body,{childList:!0,subtree:!0})}var c2=1600,i2=2500;function Z1(J){return{disabled:J.hasAttribute("disabled")||J.getAttribute("aria-disabled")==="true",busy:J.getAttribute("aria-busy")==="true",text:s((J.textContent??"").replace(/\s+/g," ").trim(),D0)}}function l2(J,$){if(!J.disabled&&$.disabled)return"ปุ่มถูกปิดใช้งานหลังคลิก";if(!J.busy&&$.busy)return"ปุ่มเข้าสู่สถานะกำลังโหลด";if(J.text!==$.text&&$.text)return`ข้อความเปลี่ยนเป็น “${$.text}”`;return null}function o2(J,$){if(typeof MutationObserver>"u")return;let Q=Z1(J),z=!1,j=(F,G)=>{if(z)return;if(z=!0,W.disconnect(),window.clearTimeout(K),$.afterNote=F,G)$.afterHtml=V0(B0(J,W1,i2))},W=new MutationObserver(()=>{if(!J.isConnected){j("องค์ประกอบหายไปจากหน้าจอ",!1);return}let F=l2(Q,Z1(J));if(F)j(F,!0)});W.observe(J,{attributes:!0,attributeFilter:["disabled","aria-disabled","aria-busy","class"],childList:!0,subtree:!0,characterData:!0});let K=window.setTimeout(()=>{if(!z&&!J.isConnected){j("องค์ประกอบหายไปจากหน้าจอ",!1);return}z=!0,W.disconnect()},c2)}function Y1(){if(J1||typeof window>"u")return;J1=!0,document.addEventListener("click",(z)=>{if(K0(z.target))return;let j=C2(z.target);if(!j)return;let W=B2(j);if(!W)return;let K=Q0("click",`คลิก ${W}`,T2(j),S2(j));if(K)o2(j,K)},{capture:!0,passive:!0}),document.addEventListener("change",(z)=>{if(K0(z.target))return;let j=L2(z.target);if(j)Q0("input",`แก้ไข ${j}`)},{capture:!0,passive:!0}),document.addEventListener("submit",(z)=>{if(K0(z.target))return;Q0("submit","ส่งฟอร์ม")},{capture:!0,passive:!0});let J=()=>Q0("navigate",`ไปที่ ${N0(l(location.pathname+location.search))}`),$=history.pushState.bind(history),Q=history.replaceState.bind(history);history.pushState=(...z)=>{let j=$(...z);return J(),j},history.replaceState=(...z)=>{let j=Q(...z);return J(),j},window.addEventListener("popstate",J),d2()}function q0(){return r.map((J)=>({...J}))}var X1=2000,Y0=[],F1=0,G1=!1;function w0(J,$){F1+=1,Y0.push({id:`log_${F1}`,at:new Date().toISOString(),level:J,message:$.length>X1?`${$.slice(0,X1)}…`:$});while(Y0.length>h("maxConsoleEntries"))Y0.shift()}function r2(){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 H1(J){if(typeof J==="string")return J;if(J instanceof Error)return`${J.name}: ${J.message}`;try{let $=JSON.stringify(J,r2());if($!==void 0)return $}catch{}try{return String(J)}catch{}try{return Object.prototype.toString.call(J)}catch{return`[${typeof J}]`}}function U1(){if(G1||typeof window>"u")return;G1=!0;let J=["log","info","warn","error","debug"];for(let $ of J){let Q=console[$].bind(console);console[$]=(...z)=>{w0($,z.map(H1).join(" ")),Q(...z)}}window.addEventListener("error",($)=>{let Q=$.filename?` (${$.filename}:${$.lineno}:${$.colno})`:"";w0("exception",`${$.message}${Q}`)}),window.addEventListener("unhandledrejection",($)=>{let Q=$.reason instanceof Error?`${$.reason.name}: ${$.reason.message}`:H1($.reason);w0("unhandledrejection",Q)})}function R0(){return Y0.map((J)=>({...J}))}var M1=new Set,P1=new Set;function I1(J,$){return J.add($),()=>J.delete($)}function D1(J,$){for(let Q of[...J])Q($)}function S0(J){return I1(M1,J)}function O0(J={type:"manual"}){D1(M1,J)}function _0(J){return I1(P1,J)}function L0(J){D1(P1,J)}var s2=15000,n2=["ResizeObserver loop","Script error.","Non-Error promise rejection captured"],N1=!1,C1=0;function a2(J){return n2.some(($)=>J.includes($))}function B1(J){let $=J.message??"";if(!$||a2($))return;let Q=Date.now();if(Q-C1<s2)return;C1=Q,L0({...J,message:$})}function q1(){if(N1||typeof window>"u")return;N1=!0,window.addEventListener("error",(J)=>{if(!J.message&&!J.error)return;let $=J.error instanceof Error?J.error:null;B1({type:"runtime-error",message:J.message||($?$.message:"Unknown error"),stack:$?.stack})}),window.addEventListener("unhandledrejection",(J)=>{let $=J.reason;B1({type:"unhandledrejection",message:$ instanceof Error?$.message:String($),stack:$ instanceof Error?$.stack:void 0})})}var O1=4000,t2=1e6,e2=1e7,X0=[],w1=0,R1=!1;function _1(J){X0.push(J);while(X0.length>h("maxRequests"))X0.shift()}function L1(){return w1+=1,`req_${w1}`}function S1(J){let $={};if(!J)return $;if(J instanceof Headers)J.forEach((Q,z)=>{$[z]=Q});else if(Array.isArray(J))for(let[Q,z]of J)$[Q]=z;else Object.assign($,J);return $}function J4(J){let $={};return J.forEach((Q,z)=>{$[z]=Q}),$}function $4(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 Q4(J,$){let Q="",z="GET",j={},W=null;if(typeof J==="string")Q=J;else if(J instanceof URL)Q=J.toString();else Q=J.url,z=J.method||z,j=S1(J.headers);if($){if($.method)z=$.method;if($.headers)j={...j,...S1($.headers)};if($.body!==void 0)W=$4($.body)}return{method:z.toUpperCase(),url:Q,headers:j,body:W}}function A1(J){return!t0(J)}function z4(J,$){if(A1($.url)){$.responseSnippet="[body not captured for this origin]";return}let Q=J.headers.get("content-type")??"",z=Number(J.headers.get("content-length")??"0"),j=z?`, ~${z} bytes`:"";if(!/json|text|xml|html|javascript|urlencoded/i.test(Q)){$.responseSnippet=`[binary ${Q||"unknown"}${j}]`;return}if(z>t2){$.responseSnippet=`[response ${Q||"text"}${j} — omitted]`;return}try{J.clone().text().then((W)=>{$.responseSnippet=o(W,h("maxBodyChars"))}).catch(()=>{})}catch{}}function T1(J,$){if(/[?&]_rsc=/.test(J))return!0;for(let Q of Object.keys($)){let z=Q.toLowerCase();if(z==="rsc"||z==="next-router-prefetch"||z==="next-router-state-tree")return!0}return!1}function j4(){if(typeof window>"u"||typeof window.fetch!=="function")return;let J=window.fetch.bind(window);window.fetch=Object.assign(async($,Q)=>{let z=Q4($,Q);if(T1(z.url,z.headers))return J($,Q);let j={id:L1(),startedAt:new Date().toISOString(),method:z.method,url:l(z.url),requestHeaders:i(z.headers),requestBody:o(z.body,O1),status:null,statusText:null,durationMs:null,via:"fetch"};_1(j);let W=performance.now();try{let K=await J($,Q);return j.status=K.status,j.statusText=K.statusText,j.durationMs=Math.round(performance.now()-W),j.responseHeaders=i(J4(K.headers)),z4(K,j),K}catch(K){throw j.durationMs=Math.round(performance.now()-W),j.error=K instanceof Error?`${K.name}: ${K.message}`:String(K),K}},J)}function Z4(){if(typeof window>"u"||typeof window.XMLHttpRequest!=="function")return;let J=XMLHttpRequest.prototype,$=J.open,Q=J.send,z=function(W,K){let F=typeof K==="string"?K:K.toString();return this.__cibEntry=T1(F,{})?void 0:{id:L1(),startedAt:"",method:(W||"GET").toUpperCase(),url:l(F),requestHeaders:{},requestBody:null,status:null,statusText:null,durationMs:null,via:"xhr"},$.apply(this,arguments)},j=function(W){let K=this.__cibEntry;if(K){K.startedAt=new Date().toISOString(),K.requestBody=typeof W==="string"?o(W,O1):W==null?null:"[non-string body]";let F=performance.now();_1(K),this.addEventListener("loadend",()=>{if(K.status=this.status||null,K.statusText=this.statusText||null,K.durationMs=Math.round(performance.now()-F),A1(K.url))K.responseSnippet="[body not captured for this origin]";else if(this.responseType===""||this.responseType==="text")try{K.responseSnippet=o(this.responseText||"",h("maxBodyChars"))}catch{}else{let G=this.getResponseHeader("content-type")??this.responseType;K.responseSnippet=`[binary ${G}]`}})}return Q.apply(this,arguments)};J.open=z,J.send=j}function k1(){if(R1)return;R1=!0,j4(),Z4()}function A0(){let J=X0.map((Q)=>({...Q})),$=0;for(let Q=J.length-1;Q>=0;Q-=1){let z=J[Q],j=z?.responseSnippet;if(!z||typeof j!=="string"||j.length===0)continue;if($+j.length>e2)z.responseSnippet=`[response omitted — report size budget reached (${j.length.toLocaleString()} chars)]`;else $+=j.length}return J}var W4={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:"หน้า",handoffTitle:"กำลังพาไปที่ระบบแจ้งปัญหา",handoffBody:"ระบบจะลงชื่อเข้าใช้ให้อัตโนมัติ เพื่อดูเรื่องที่คุณแจ้งไว้",handoffGo:"ไปเลย",handoffPreparing:"กำลังเตรียม…",handoffFailed:"เปิดรายการที่แจ้งไว้ไม่สำเร็จ",handoffBlocked:"เบราว์เซอร์บล็อกการเปิดแท็บใหม่",handoffOpen:"เปิดในแท็บใหม่"},K4={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",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 b(J){return J==="en"?K4:W4}var V4="lw-debug-toasts",Y4=6000,X4=`
|
|
2
2
|
:host { all: initial; }
|
|
3
3
|
.stack {
|
|
4
4
|
position: fixed; top: 16px; right: 16px; z-index: 2147483001;
|
|
@@ -30,15 +30,15 @@ var J2={maxRequests:60,maxConsoleEntries:120,maxActions:80,maxBodyChars:20000},T
|
|
|
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
|
-
`,
|
|
34
|
-
# response: ${
|
|
35
|
-
${
|
|
33
|
+
`,T0=null;function F4(){if(typeof document>"u")return null;if(T0?.isConnected)return T0;let J=document.createElement(V4);J.dataset.debugReporter="true";let $=J.attachShadow({mode:"open"}),Q=document.createElement("style");Q.textContent=X4;let z=document.createElement("div");return z.className="stack",z.setAttribute("role","status"),z.setAttribute("aria-live","polite"),$.append(Q,z),document.body.append(J),T0=z,z}function n(J,$="success",Q){let z=$0()?w().toast:void 0;if(z){z({message:J,tone:$,...Q?{action:Q}:{}});return}let j=F4();if(!j)return;let W=document.createElement("div");W.className="toast",W.dataset.tone=$;let K=document.createElement("span");K.className="dot";let F=document.createElement("span");F.textContent=J;let G=document.createElement("button");G.type="button",G.className="close",G.textContent="✕",G.setAttribute("aria-label","ปิด");let M=()=>{window.clearTimeout(N),W.remove()};G.addEventListener("click",M);let N=$==="error"||Q?0:window.setTimeout(M,Y4);if(W.append(K,F),Q){let P=document.createElement("button");P.type="button",P.className="action",P.textContent=Q.label,P.addEventListener("click",()=>{M(),Q.onClick()}),W.append(P)}W.append(G),j.append(W)}function E1(J,$,Q){let z=J.filter((W)=>Boolean(W.error)||W.status!=null&&W.status>=400).slice(-20).map((W)=>({method:W.method,url:W.url,status:W.status,error:W.error,at:W.startedAt})),j=$.filter((W)=>W.level==="error"||W.level==="exception"||W.level==="unhandledrejection").slice(-20).map((W)=>W.message);return{failedRequests:z,errors:j,erroredQueries:Q.slice(0,20)}}function x1(J){return J.failedRequests.length+J.errors.length+J.erroredQueries.length}function G4(){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 k0(J,$){if(!J)return $;try{return J()}catch{return $}}function f1(){let J=w(),{pathname:$,search:Q,href:z}=window.location;return{capturedAt:new Date().toISOString(),route:{href:z,pathname:$,search:Q},module:n0($),user:k0(J.user,{}),apiHeaders:i(k0(J.headers,{})),app:{name:f().name,version:f().version,environment:f().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:G4(),extra:k0(J.extra,{})}}var H4=2,U4={manual:"ผู้ใช้แจ้งเอง","runtime-error":"ข้อผิดพลาด runtime (auto)",unhandledrejection:"Promise rejection (auto)","framework-error":"หน้าจอค้าง/พัง (auto)"};function E0(J){let $=A0(),Q=R0();return{context:f1(),reason:J.reason,note:J.note,cause:E1($,Q,J.erroredQueries),actionTrail:q0(),network:$,console:Q,screenshotDataUrl:J.screenshotDataUrl,screenshotMethod:J.screenshotMethod,meta:{generatedBy:"lightwork-debug-capture",schemaVersion:H4}}}function h1(J){return J.replace(/'/g,"'\\''")}function m1(J){let $=[`curl -X ${J.method} '${J.url}'`];for(let[Q,z]of Object.entries(J.requestHeaders))$.push(` -H '${Q}: ${h1(z)}'`);if(J.requestBody)$.push(` --data '${h1(J.requestBody)}'`);return $.join(" \\\n")}function M4(J){if(J.error)return`ERR ${J.error}`;return`${J.status??"—"} ${J.statusText??""}`.trim()}function P4(J){if(J.length===0)return"No network activity captured.";return J.map(($)=>{let Q=$.durationMs!=null?`${$.durationMs}ms`:"—",z=`# [${M4($)}] ${$.method} ${$.url} (${Q}, ${$.startedAt})`,j=$.responseSnippet?`
|
|
34
|
+
# response: ${$.responseSnippet}`:"";return`${z}
|
|
35
|
+
${m1($)}${j}`}).join(`
|
|
36
36
|
|
|
37
|
-
`)}function
|
|
38
|
-
`)}function
|
|
39
|
-
↳ ${
|
|
40
|
-
`)}function
|
|
41
|
-
`)}function B4($){return $.replace(/[:.]/g,"-").replace("T","_").slice(0,19)}function q4($,j){return`debug-report_${B4($.context.capturedAt)}.${j}`}function S4($){return E1($.cause)>0}async function E0(){if(typeof navigator<"u"&&Boolean(navigator.mediaDevices?.getDisplayMedia)){let J=await R4();if(J.status==="ok")return{dataUrl:J.dataUrl,method:"display-media"};if(J.status==="cancelled")return{dataUrl:null,method:"cancelled"}}let j=await L4();if(j)return{dataUrl:j,method:"html-to-image"};return{dataUrl:null,method:"none"}}async function R4(){let $=null;try{let j={video:{frameRate:30},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude"};$=await navigator.mediaDevices.getDisplayMedia(j);let J=await O4($);return J?{status:"ok",dataUrl:J}:{status:"error"}}catch(j){if(j instanceof DOMException&&(j.name==="NotAllowedError"||j.name==="AbortError"))return{status:"cancelled"};return{status:"error"}}finally{$?.getTracks().forEach((j)=>j.stop())}}async function O4($){let j=document.createElement("video");j.srcObject=$,j.muted=!0,j.playsInline=!0,await new Promise((K)=>{let G=!1,F=()=>{if(G)return;G=!0,K()};j.onloadedmetadata=()=>{j.play().then(F).catch(F)},window.setTimeout(F,1500)}),await _4(j);let{videoWidth:J,videoHeight:Q}=j;if(!J||!Q)return null;let z=document.createElement("canvas");z.width=J,z.height=Q;let W=z.getContext("2d");if(!W)return null;W.drawImage(j,0,0,J,Q),j.pause(),j.srcObject=null;try{return z.toDataURL("image/png")}catch{return null}}function _4($){return new Promise((j)=>{let J=!1,Q=()=>{if(J)return;J=!0,j()},z=$;if(typeof z.requestVideoFrameCallback==="function")z.requestVideoFrameCallback(()=>Q()),window.setTimeout(Q,1000);else window.setTimeout(Q,250)})}async function L4(){let $=q().screenshotFallback;if(!$)return null;let j=await $().catch(()=>null);if(!j)return null;try{return await j(document.body,{cacheBust:!0,pixelRatio:Math.min(window.devicePixelRatio||1,2),filter:(J)=>!(J instanceof HTMLElement&&J.dataset?.debugReporter==="true")})}catch{return null}}var A4=2000,k4=0.82,T4=3000000;function f4($){return new Promise((j,J)=>{let Q=new Image;Q.onload=()=>j(Q),Q.onerror=()=>J(Error("could not read the screenshot")),Q.src=$})}async function m1($){try{let j=await f4($),J=Math.max(j.naturalWidth,j.naturalHeight),Q=Math.min(1,A4/J),z=document.createElement("canvas");z.width=Math.max(1,Math.round(j.naturalWidth*Q)),z.height=Math.max(1,Math.round(j.naturalHeight*Q));let W=z.getContext("2d");if(!W)return $;W.fillStyle="#fff",W.fillRect(0,0,z.width,z.height),W.drawImage(j,0,0,z.width,z.height);let K=k4,G=z.toDataURL("image/jpeg",K);while(G.length>T4&&K>0.4)K-=0.15,G=z.toDataURL("image/jpeg",K);return G}catch{return $}}var E4=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,x4=/^\d+$/,h4=/^[0-9a-f]{16,}$/i;function x0($){if($.reason.type==="manual")return null;let j=$.cause?.failedRequests?.[0];if(!j?.url)return null;let J;try{J=new URL(j.url,"http://x").pathname}catch{J=j.url}let Q=J.split("/").map((W)=>E4.test(W)||x4.test(W)||h4.test(W)?":id":W).join("/"),z=j.status??(j.error?"ERR":"?");return`${j.method??"REQ"} ${Q} ${z}`}var h0=2000000;function G0($){let{screenshotDataUrl:j,...J}=$;return JSON.stringify(J).length}function p0($,j=2000000){if(G0($)<=j)return $;let J=$.network.map((z)=>({...z})),Q={...$,network:J};for(let z of J){if(G0(Q)<=j)return Q;if(typeof z.responseSnippet==="string"&&z.responseSnippet.length>35)z.responseSnippet="[body dropped — report size budget]";if(typeof z.requestBody==="string"&&z.requestBody.length>35)z.requestBody="[body dropped — report size budget]"}while(Q.network.length>1&&G0(Q)>j)Q.network=Q.network.slice(1);while(Q.console.length>1&&G0(Q)>j)Q.console=Q.console.slice(1);return Q}var g1=32768;function p4($){let j="";for(let J=0;J<$.length;J+=g1)j+=String.fromCharCode(...$.subarray(J,J+g1));return btoa(j)}function m4($){let{screenshotDataUrl:j,...J}=$;return{dataUri:`data:application/json;base64,${p4(new TextEncoder().encode(JSON.stringify(J)))}`,filename:"debug-bundle.json"}}async function g4(){let $=q().identity;if(!$)return{};try{let j=await $();return j?{authorization:`Bearer ${j}`}:{}}catch{return{}}}async function m0($,j){let J=q(),Q=p0(j,h0),{context:z,note:W}=Q,K=[];if(Q.screenshotDataUrl){let w=await m1(Q.screenshotDataUrl);K.push({dataUri:w,filename:"screenshot.jpg"})}K.push(m4(Q));let G=x0(Q),F={title:$,description:W.trim()||void 0,appName:x().name,category:z.module?.label,routeUrl:z.route.href,priority:"MEDIUM",requesterEmail:z.user.email??void 0,requesterName:z.user.fullName??void 0,customFields:{unit:z.user.unit??"",appVersion:z.app.version,environment:z.app.environment,reasonType:Q.reason.type,appName:x().name,module:z.module?.label??""},context:{...G?{signature:G}:{},capturedAt:z.capturedAt,reason:Q.reason,cause:Q.cause,actionTrail:Q.actionTrail,client:z.client,performance:z.performance,apiHeaders:z.apiHeaders,extra:z.extra,counts:{network:Q.network.length,console:Q.console.length,actions:Q.actionTrail.length},screenshotMethod:Q.screenshotMethod},attachments:K},U=await fetch(`${J.host.replace(/\/$/,"")}/ingest/tickets`,{method:"POST",headers:{"content-type":"application/json","x-realm-key":J.realmKey,...await g4()},body:JSON.stringify(F)});if(!U.ok){let w=U.headers.get("retry-after"),P=await U.json().then((C)=>C.error).catch(()=>null);throw Error(U.status===429?`Too many reports — try again in ${w??"a moment"}s`:P??`Report failed (${U.status})`)}return await U.json()}var z0=Math.PI/6;function v1($,j,J){let Q=j.x-$.x,z=j.y-$.y,W=Math.hypot(Q,z),K=Math.atan2(z,Q),G=[{x:j.x,y:j.y},{x:j.x-J*Math.cos(K-z0),y:j.y-J*Math.sin(K-z0)},{x:j.x-J*Math.cos(K+z0),y:j.y-J*Math.sin(K+z0)}],F=J*Math.cos(z0)*0.92;if(W<=F)return{shaft:null,head:G};return{shaft:{from:$,to:{x:j.x-F*Math.cos(K),y:j.y-F*Math.sin(K)}},head:G}}var g0="#f44336",v4="rgba(250, 204, 21, 0.4)",v0=22,y1="#2563eb",b1=9,u1=11,d1=18,c1=4,F0=8,y4=[{id:"nw",fx:0,fy:0,cursor:"nwse-resize"},{id:"n",fx:0.5,fy:0,cursor:"ns-resize"},{id:"ne",fx:1,fy:0,cursor:"nesw-resize"},{id:"e",fx:1,fy:0.5,cursor:"ew-resize"},{id:"se",fx:1,fy:1,cursor:"nwse-resize"},{id:"s",fx:0.5,fy:1,cursor:"ns-resize"},{id:"sw",fx:0,fy:1,cursor:"nesw-resize"},{id:"w",fx:0,fy:0.5,cursor:"ew-resize"}];function y0($,j,J){let Q=[],z=null,W=-1,K=null,G=null,F=$.getContext("2d");function U(){let Z=$.getBoundingClientRect().width;return Z>0?$.width/Z:1}function w(Z){let V=$.getBoundingClientRect();return{x:(Z.clientX-V.left)/V.width*$.width,y:(Z.clientY-V.top)/V.height*$.height}}function P(Z){let V=Z.size??v0;if(!F)return(Z.text?.length??0)*V*0.6;F.save(),F.font=`600 ${V}px system-ui, sans-serif`;let Y=F.measureText(Z.text??"").width;return F.restore(),Y}function C(Z){if(Z.tool==="text"){let V=Z.size??v0;return{left:Z.x1,top:Z.y1,right:Z.x1+P(Z),bottom:Z.y1+V*1.25}}return{left:Math.min(Z.x1,Z.x2),top:Math.min(Z.y1,Z.y2),right:Math.max(Z.x1,Z.x2),bottom:Math.max(Z.y1,Z.y2)}}function O(Z){if(Z.tool==="arrow")return[{id:"tail",x:Z.x1,y:Z.y1,cursor:"move"},{id:"head",x:Z.x2,y:Z.y2,cursor:"move"}];let V=C(Z);if(Z.tool==="text")return[{id:"size",x:V.right,y:V.bottom,cursor:"nwse-resize"}];return y4.map((Y)=>({id:Y.id,x:V.left+(V.right-V.left)*Y.fx,y:V.top+(V.bottom-V.top)*Y.fy,cursor:Y.cursor}))}function N(Z){let V=C(Z);return{x:V.right+d1*U(),y:V.top-d1*U()}}function R(Z,V,Y){let{shaft:X,head:H}=v1({x:V.x1,y:V.y1},{x:V.x2,y:V.y2},Math.max(10,16*Y));if(X)Z.lineCap="butt",Z.beginPath(),Z.moveTo(X.from.x,X.from.y),Z.lineTo(X.to.x,X.to.y),Z.stroke();Z.beginPath(),Z.moveTo(H[0].x,H[0].y),Z.lineTo(H[1].x,H[1].y),Z.lineTo(H[2].x,H[2].y),Z.closePath(),Z.fill()}function _(Z,V,Y){Z.save(),Z.lineWidth=Math.max(2,3*Y),Z.strokeStyle=g0,Z.fillStyle=g0;let X=C(V);if(V.tool==="rect")Z.strokeRect(X.left,X.top,X.right-X.left,X.bottom-X.top);else if(V.tool==="arrow")R(Z,V,Y);else if(V.tool==="highlight")Z.fillStyle=v4,Z.fillRect(X.left,X.top,X.right-X.left,X.bottom-X.top);else if(V.tool==="text"&&V.text){let H=V.size??v0;Z.font=`600 ${H}px system-ui, sans-serif`,Z.textBaseline="top";let M=H*0.22;Z.fillStyle="rgba(255,255,255,0.92)",Z.fillRect(X.left-M,X.top-M,X.right-X.left+M*2,X.bottom-X.top+M*2),Z.fillStyle=g0,Z.fillText(V.text,X.left,X.top)}Z.restore()}function D(Z,V,Y){let X=C(V);Z.save(),Z.strokeStyle=y1,Z.lineWidth=Math.max(1,1.5*Y),Z.setLineDash([6*Y,4*Y]),Z.strokeRect(X.left,X.top,X.right-X.left,X.bottom-X.top),Z.setLineDash([]);let H=b1*Y;for(let k of O(V))Z.fillStyle="#fff",Z.strokeStyle=y1,Z.lineWidth=Math.max(1,1.5*Y),Z.beginPath(),Z.rect(k.x-H/2,k.y-H/2,H,H),Z.fill(),Z.stroke();let M=N(V),I=u1*Y;Z.beginPath(),Z.arc(M.x,M.y,I,0,Math.PI*2),Z.fillStyle="#dc2626",Z.fill(),Z.strokeStyle="#fff",Z.lineWidth=Math.max(1.5,2*Y),Z.beginPath(),Z.moveTo(M.x-I*0.4,M.y-I*0.4),Z.lineTo(M.x+I*0.4,M.y+I*0.4),Z.moveTo(M.x+I*0.4,M.y-I*0.4),Z.lineTo(M.x-I*0.4,M.y+I*0.4),Z.stroke(),Z.restore()}function S(){if(!F)return;let Z=U();if(F.clearRect(0,0,$.width,$.height),F.drawImage(j,0,0,$.width,$.height),Q.forEach((Y,X)=>{if(X!==g)_(F,Y,Z)}),K)_(F,K,Z);let V=Q[W];if(V&&!K)D(F,V,Z)}function p(Z,V,Y,X,H){return Math.abs(Z-Y)<=H&&Math.abs(V-X)<=H}function e(Z,V){let Y=Q[W];if(!Y)return null;let X=b1*U()/2+3*U();for(let H of O(Y))if(p(Z,V,H.x,H.y,X))return H.id;return null}function u(Z,V){let Y=Q[W];if(!Y)return!1;let X=N(Y);return p(Z,V,X.x,X.y,u1*U())}function E(Z,V){let Y=6*U();for(let X=Q.length-1;X>=0;X-=1){let H=Q[X];if(H.tool==="arrow"){let I=H.x2-H.x1,k=H.y2-H.y1,v=Math.hypot(I,k)||1,y=Math.max(0,Math.min(1,((Z-H.x1)*I+(V-H.y1)*k)/(v*v)));if(Math.hypot(Z-(H.x1+y*I),V-(H.y1+y*k))<=Y+4*U())return X;continue}let M=C(H);if(Z>=M.left-Y&&Z<=M.right+Y&&V>=M.top-Y&&V<=M.bottom+Y)return X}return-1}function m(Z,V,Y,X,H){if(V==="tail"){Z.x1=Y.x1+X,Z.y1=Y.y1+H;return}if(V==="head"){Z.x2=Y.x2+X,Z.y2=Y.y2+H;return}if(V==="size"){let j2=(Y.size??24)+H;Z.size=Math.max(10,j2);return}let M=C(Y),{left:I,top:k,right:v,bottom:y}=M;if(V.includes("w"))I=Math.min(v-F0,I+X);if(V.includes("e"))v=Math.max(I+F0,v+X);if(V.includes("n"))k=Math.min(y-F0,k+H);if(V.includes("s"))y=Math.max(k+F0,y+H);Z.x1=I,Z.y1=k,Z.x2=v,Z.y2=y}function M0(Z,V,Y,X){Z.x1=V.x1+Y,Z.y1=V.y1+X,Z.x2=V.x2+Y,Z.y2=V.y2+X}let L=null,g=-1,B={x:0,y:0,size:24};function f(){let Z=$.getBoundingClientRect().width;return Z>0?Z/$.width:1}function $2(Z,V){if(!F)return Z.length*V*0.6;F.save(),F.font=`600 ${V}px system-ui, sans-serif`;let Y=F.measureText(Z||" ").width;return F.restore(),Y}function c0(){if(!L)return;let Z=$.parentElement;if(!Z)return;let V=$.getBoundingClientRect(),Y=Z.getBoundingClientRect(),X=f(),H=B.size*X;L.style.left=`${V.left-Y.left+B.x*X}px`,L.style.top=`${V.top-Y.top+B.y*X}px`,L.style.fontSize=`${H}px`,L.style.width=`${Math.max(40,$2(L.value,H)+H)}px`}function $0(Z){let V=L;if(!V)return;L=null;let Y=V.value.trim(),X=g;if(g=-1,V.remove(),Z&&Y){if(X>=0&&Q[X])Q[X].text=Y,W=X;else Q.push({tool:"text",x1:B.x,y1:B.y,x2:B.x,y2:B.y,text:Y,size:B.size}),W=Q.length-1;J()}else if(X>=0)W=X;$.focus(),S()}function i0(Z,V,Y=-1){$0(!0);let X=$.parentElement;if(!X)return;if(getComputedStyle(X).position==="static")X.style.position="relative";let H=Y>=0?Q[Y]:void 0;g=Y,B={x:H?.x1??Z,y:H?.y1??V,size:H?.size??Math.round(24*U())};let M=document.createElement("input");M.type="text",M.className="text-edit",M.value=H?.text??"",M.setAttribute("aria-label","ข้อความบนภาพ"),M.placeholder="ข้อความ",L=M,X.append(M),c0(),M.addEventListener("input",c0),M.addEventListener("keydown",(I)=>{if(I.stopPropagation(),I.key==="Enter")$0(!0);else if(I.key==="Escape")$0(!1)}),requestAnimationFrame(()=>{if(L!==M)return;M.focus(),M.select(),M.addEventListener("blur",()=>$0(!0))}),S()}function o0(Z){let{x:V,y:Y}=w(Z);if($.setPointerCapture(Z.pointerId),u(V,Y)){U0();return}let X=e(V,Y);if(X&&Q[W]){G={grip:X,x:V,y:Y,start:{...Q[W]}};return}if(z==="text"){if(Z.preventDefault(),$.hasPointerCapture(Z.pointerId))$.releasePointerCapture(Z.pointerId);z=null,J(),i0(V,Y);return}if(z){K={tool:z,x1:V,y1:Y,x2:V,y2:Y},W=-1;return}let H=E(V,Y);W=H,G=H>=0?{grip:"body",x:V,y:Y,start:{...Q[H]}}:null,S()}function l0(Z){let{x:V,y:Y}=w(Z);if(K){K.x2=V,K.y2=Y,S();return}if(G){let H=Q[W];if(!H)return;let M=V-G.x,I=Y-G.y;if(G.grip==="body")M0(H,G.start,M,I);else m(H,G.grip,G.start,M,I);S();return}if(z){$.style.cursor="crosshair";return}if(u(V,Y)){$.style.cursor="pointer";return}let X=e(V,Y);if(X){let H=Q[W]?O(Q[W]).find((M)=>M.id===X):null;$.style.cursor=H?.cursor??"pointer";return}$.style.cursor=E(V,Y)>=0?"move":"default"}function Z0(){if(K){if(!(Math.abs(K.x2-K.x1)<c1&&Math.abs(K.y2-K.y1)<c1))Q.push(K),W=Q.length-1,z=null,J();K=null}if(G)G=null,J();S()}function r0(Z){let V=$.getBoundingClientRect(),Y=(Z.clientX-V.left)/V.width*$.width,X=(Z.clientY-V.top)/V.height*$.height,H=E(Y,X),M=Q[H];if(!M||M.tool!=="text")return;Z.preventDefault(),i0(M.x1,M.y1,H)}function s0(Z){if(W<0)return;if(Z.key==="Delete"||Z.key==="Backspace")Z.preventDefault(),U0();else if(Z.key==="Escape")W=-1,S()}function U0(){if(W<0)return;Q.splice(W,1),W=-1,J(),S()}return $.addEventListener("pointerdown",o0),$.addEventListener("pointermove",l0),$.addEventListener("pointerup",Z0),$.addEventListener("pointercancel",Z0),$.addEventListener("dblclick",r0),$.tabIndex=0,$.addEventListener("keydown",s0),S(),{setTool(Z){z=Z,W=-1,$.style.cursor=Z?"crosshair":"default",S()},deleteSelected:U0,clear(){Q.length=0,W=-1,J(),S()},hasShapes:()=>Q.length>0,hasSelection:()=>W>=0,toDataUrl(){let Z=document.createElement("canvas");Z.width=j.naturalWidth,Z.height=j.naturalHeight;let V=Z.getContext("2d");if(!V)return $.toDataURL("image/png");V.drawImage(j,0,0);let Y=U();for(let X of Q)_(V,X,Y);return Z.toDataURL("image/png")},destroy(){$0(!1),$.removeEventListener("pointerdown",o0),$.removeEventListener("pointermove",l0),$.removeEventListener("pointerup",Z0),$.removeEventListener("pointercancel",Z0),$.removeEventListener("dblclick",r0),$.removeEventListener("keydown",s0)}}}var i1=`
|
|
37
|
+
`)}function I4(J){if(J.length===0)return"No console output captured.";return J.map(($)=>`[${$.at}] ${$.level.toUpperCase()}: ${$.message}`).join(`
|
|
38
|
+
`)}function D4(J){if(J.length===0)return"No user actions captured.";let $=0;return J.map((Q)=>{let z=Q.source?` (${Q.source})`:"",j=`${Q.detail}${C0(Q.count)}${z}`;if(Q.kind==="ui")return` ↳ [${Q.at}] ${j}`;$+=1;let W=`${$}. [${Q.at}] ${j}`;return Q.afterNote?`${W}
|
|
39
|
+
↳ ${Q.afterNote}`:W}).join(`
|
|
40
|
+
`)}function N4(J){let $=[];for(let Q of J.failedRequests)$.push(`✗ ${Q.status??Q.error??"ERR"} ${Q.method} ${Q.url}`);for(let Q of J.errors)$.push(`⚠ ${Q}`);for(let Q of J.erroredQueries)$.push(`⚠ React Query error: ${Q.key} — ${Q.error}`);return $}function C4(J){let{context:$}=J;return[`User : ${$.user.fullName??"—"} (${$.user.email??"—"})`,`Unit : ${$.user.unit??"—"}`,`Roles : ${$.user.roles?.join(", ")||"—"}`,`Route : ${$.route.href}`,`Module : ${$.module?`${$.module.label} (${$.module.key})`:"—"}`,`App : ${$.app.name} v${$.app.version} · ${$.app.environment}`,`Memory : ${$.performance.memoryUsedMb??"—"}/${$.performance.memoryLimitMb??"—"} MB`,`Client : ${$.client.userAgent}`,`Viewport : ${$.client.viewport.width}×${$.client.viewport.height} @${$.client.viewport.dpr}x`,`Reason : ${U4[J.reason.type]}${J.reason.message?` — ${J.reason.message}`:""}`,`Captured : ${J.network.length} requests · ${J.console.length} console · ${J.actionTrail.length} actions · screenshot=${J.screenshotMethod}`]}function B4(J){let $=N4(J.cause),Q=[`## \uD83D\uDC1E ${J.context.app.name} — Debug Report`,`**Generated:** ${J.context.capturedAt}`,"",...C4(J).map((z)=>`- ${z.replace(/\s{2,}:/,":")}`),"",`**หมายเหตุจากผู้แจ้ง:** ${J.note.trim()||"(ไม่มี)"}`];if($.length>0)Q.push("","### ⚠ สาเหตุที่น่าจะเป็น","```",...$,"```");return Q.push("",`<details><summary>ขั้นตอน (${J.actionTrail.length})</summary>`,"","```",D4(J.actionTrail),"```","</details>","",`<details><summary>Network (${J.network.length})</summary>`,"","```",P4(J.network),"```","</details>","",`<details><summary>Console (${J.console.length})</summary>`,"","```",I4(J.console),"```","</details>","","_ข้อมูลลับ (token, cookie) ถูกปกปิดอัตโนมัติ · ภาพหน้าจออยู่ในไฟล์ .zip_"),Q.join(`
|
|
41
|
+
`)}function q4(J){return J.replace(/[:.]/g,"-").replace("T","_").slice(0,19)}function w4(J,$){return`debug-report_${q4(J.context.capturedAt)}.${$}`}function R4(J){return x1(J.cause)>0}async function x0(){if(typeof navigator<"u"&&Boolean(navigator.mediaDevices?.getDisplayMedia)){let Q=await S4();if(Q.status==="ok")return{dataUrl:Q.dataUrl,method:"display-media"};if(Q.status==="cancelled")return{dataUrl:null,method:"cancelled"}}let $=await L4();if($)return{dataUrl:$,method:"html-to-image"};return{dataUrl:null,method:"none"}}async function S4(){let J=null;try{let $={video:{frameRate:30},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude"};J=await navigator.mediaDevices.getDisplayMedia($);let Q=await O4(J);return Q?{status:"ok",dataUrl:Q}:{status:"error"}}catch($){if($ instanceof DOMException&&($.name==="NotAllowedError"||$.name==="AbortError"))return{status:"cancelled"};return{status:"error"}}finally{J?.getTracks().forEach(($)=>$.stop())}}async function O4(J){let $=document.createElement("video");$.srcObject=J,$.muted=!0,$.playsInline=!0,await new Promise((K)=>{let F=!1,G=()=>{if(F)return;F=!0,K()};$.onloadedmetadata=()=>{$.play().then(G).catch(G)},window.setTimeout(G,1500)}),await _4($);let{videoWidth:Q,videoHeight:z}=$;if(!Q||!z)return null;let j=document.createElement("canvas");j.width=Q,j.height=z;let W=j.getContext("2d");if(!W)return null;W.drawImage($,0,0,Q,z),$.pause(),$.srcObject=null;try{return j.toDataURL("image/png")}catch{return null}}function _4(J){return new Promise(($)=>{let Q=!1,z=()=>{if(Q)return;Q=!0,$()},j=J;if(typeof j.requestVideoFrameCallback==="function")j.requestVideoFrameCallback(()=>z()),window.setTimeout(z,1000);else window.setTimeout(z,250)})}async function L4(){let J=w().screenshotFallback;if(!J)return null;let $=await J().catch(()=>null);if(!$)return null;try{return await $(document.body,{cacheBust:!0,pixelRatio:Math.min(window.devicePixelRatio||1,2),filter:(Q)=>!(Q instanceof HTMLElement&&Q.dataset?.debugReporter==="true")})}catch{return null}}var A4=2000,T4=0.82,k4=3000000;function E4(J){return new Promise(($,Q)=>{let z=new Image;z.onload=()=>$(z),z.onerror=()=>Q(Error("could not read the screenshot")),z.src=J})}async function p1(J){try{let $=await E4(J),Q=Math.max($.naturalWidth,$.naturalHeight),z=Math.min(1,A4/Q),j=document.createElement("canvas");j.width=Math.max(1,Math.round($.naturalWidth*z)),j.height=Math.max(1,Math.round($.naturalHeight*z));let W=j.getContext("2d");if(!W)return J;W.fillStyle="#fff",W.fillRect(0,0,j.width,j.height),W.drawImage($,0,0,j.width,j.height);let K=T4,F=j.toDataURL("image/jpeg",K);while(F.length>k4&&K>0.4)K-=0.15,F=j.toDataURL("image/jpeg",K);return F}catch{return J}}var x4=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,f4=/^\d+$/,h4=/^[0-9a-f]{16,}$/i;function f0(J){if(J.reason.type==="manual")return null;let $=J.cause?.failedRequests?.[0];if(!$?.url)return null;let Q;try{Q=new URL($.url,"http://x").pathname}catch{Q=$.url}let z=Q.split("/").map((W)=>x4.test(W)||f4.test(W)||h4.test(W)?":id":W).join("/"),j=$.status??($.error?"ERR":"?");return`${$.method??"REQ"} ${z} ${j}`}var h0=2000000;function F0(J){let{screenshotDataUrl:$,...Q}=J;return JSON.stringify(Q).length}function m0(J,$=2000000){if(F0(J)<=$)return J;let Q=J.network.map((j)=>({...j})),z={...J,network:Q};for(let j of Q){if(F0(z)<=$)return z;if(typeof j.responseSnippet==="string"&&j.responseSnippet.length>35)j.responseSnippet="[body dropped — report size budget]";if(typeof j.requestBody==="string"&&j.requestBody.length>35)j.requestBody="[body dropped — report size budget]"}while(z.network.length>1&&F0(z)>$)z.network=z.network.slice(1);while(z.console.length>1&&F0(z)>$)z.console=z.console.slice(1);return z}var y1=32768;function m4(J){let $="";for(let Q=0;Q<J.length;Q+=y1)$+=String.fromCharCode(...J.subarray(Q,Q+y1));return btoa($)}function p4(J){let{screenshotDataUrl:$,...Q}=J;return{dataUri:`data:application/json;base64,${m4(new TextEncoder().encode(JSON.stringify(Q)))}`,filename:"debug-bundle.json"}}async function y4(){let J=w().identity;if(!J)return{};try{let $=await J();return $?{authorization:`Bearer ${$}`}:{}}catch{return{}}}async function p0(J,$){let Q=w(),z=m0($,h0),{context:j,note:W}=z,K=[];if(z.screenshotDataUrl){let N=await p1(z.screenshotDataUrl);K.push({dataUri:N,filename:"screenshot.jpg"})}K.push(p4(z));let F=f0(z),G={title:J,description:W.trim()||void 0,appName:f().name,category:j.module?.label,routeUrl:j.route.href,priority:"MEDIUM",requesterEmail:j.user.email??void 0,requesterName:j.user.fullName??void 0,customFields:{unit:j.user.unit??"",appVersion:j.app.version,environment:j.app.environment,reasonType:z.reason.type,appName:f().name,module:j.module?.label??""},context:{...F?{signature:F}:{},capturedAt:j.capturedAt,reason:z.reason,cause:z.cause,actionTrail:z.actionTrail,client:j.client,performance:j.performance,apiHeaders:j.apiHeaders,extra:j.extra,counts:{network:z.network.length,console:z.console.length,actions:z.actionTrail.length},screenshotMethod:z.screenshotMethod},attachments:K},M=await fetch(`${Q.host.replace(/\/$/,"")}/ingest/tickets`,{method:"POST",headers:{"content-type":"application/json","x-realm-key":Q.realmKey,...await y4()},body:JSON.stringify(G)});if(!M.ok){let N=M.headers.get("retry-after"),P=await M.json().then((I)=>I.error).catch(()=>null);throw Error(M.status===429?`Too many reports — try again in ${N??"a moment"}s`:P??`Report failed (${M.status})`)}return await M.json()}var j0=Math.PI/6;function v1(J,$,Q){let z=$.x-J.x,j=$.y-J.y,W=Math.hypot(z,j),K=Math.atan2(j,z),F=[{x:$.x,y:$.y},{x:$.x-Q*Math.cos(K-j0),y:$.y-Q*Math.sin(K-j0)},{x:$.x-Q*Math.cos(K+j0),y:$.y-Q*Math.sin(K+j0)}],G=Q*Math.cos(j0)*0.92;if(W<=G)return{shaft:null,head:F};return{shaft:{from:J,to:{x:$.x-G*Math.cos(K),y:$.y-G*Math.sin(K)}},head:F}}var y0="#f44336",v4="rgba(250, 204, 21, 0.4)",v0=22,g1="#2563eb",b1=9,u1=11,d1=18,c1=4,G0=8,g4=[{id:"nw",fx:0,fy:0,cursor:"nwse-resize"},{id:"n",fx:0.5,fy:0,cursor:"ns-resize"},{id:"ne",fx:1,fy:0,cursor:"nesw-resize"},{id:"e",fx:1,fy:0.5,cursor:"ew-resize"},{id:"se",fx:1,fy:1,cursor:"nwse-resize"},{id:"s",fx:0.5,fy:1,cursor:"ns-resize"},{id:"sw",fx:0,fy:1,cursor:"nesw-resize"},{id:"w",fx:0,fy:0.5,cursor:"ew-resize"}];function g0(J,$,Q){let z=[],j=null,W=-1,K=null,F=null,G=J.getContext("2d");function M(){let Z=J.getBoundingClientRect().width;return Z>0?J.width/Z:1}function N(Z){let V=J.getBoundingClientRect();return{x:(Z.clientX-V.left)/V.width*J.width,y:(Z.clientY-V.top)/V.height*J.height}}function P(Z){let V=Z.size??v0;if(!G)return(Z.text?.length??0)*V*0.6;G.save(),G.font=`600 ${V}px system-ui, sans-serif`;let X=G.measureText(Z.text??"").width;return G.restore(),X}function I(Z){if(Z.tool==="text"){let V=Z.size??v0;return{left:Z.x1,top:Z.y1,right:Z.x1+P(Z),bottom:Z.y1+V*1.25}}return{left:Math.min(Z.x1,Z.x2),top:Math.min(Z.y1,Z.y2),right:Math.max(Z.x1,Z.x2),bottom:Math.max(Z.y1,Z.y2)}}function O(Z){if(Z.tool==="arrow")return[{id:"tail",x:Z.x1,y:Z.y1,cursor:"move"},{id:"head",x:Z.x2,y:Z.y2,cursor:"move"}];let V=I(Z);if(Z.tool==="text")return[{id:"size",x:V.right,y:V.bottom,cursor:"nwse-resize"}];return g4.map((X)=>({id:X.id,x:V.left+(V.right-V.left)*X.fx,y:V.top+(V.bottom-V.top)*X.fy,cursor:X.cursor}))}function B(Z){let V=I(Z);return{x:V.right+d1*M(),y:V.top-d1*M()}}function S(Z,V,X){let{shaft:Y,head:H}=v1({x:V.x1,y:V.y1},{x:V.x2,y:V.y2},Math.max(10,16*X));if(Y)Z.lineCap="butt",Z.beginPath(),Z.moveTo(Y.from.x,Y.from.y),Z.lineTo(Y.to.x,Y.to.y),Z.stroke();Z.beginPath(),Z.moveTo(H[0].x,H[0].y),Z.lineTo(H[1].x,H[1].y),Z.lineTo(H[2].x,H[2].y),Z.closePath(),Z.fill()}function _(Z,V,X){Z.save(),Z.lineWidth=Math.max(2,3*X),Z.strokeStyle=y0,Z.fillStyle=y0;let Y=I(V);if(V.tool==="rect")Z.strokeRect(Y.left,Y.top,Y.right-Y.left,Y.bottom-Y.top);else if(V.tool==="arrow")S(Z,V,X);else if(V.tool==="highlight")Z.fillStyle=v4,Z.fillRect(Y.left,Y.top,Y.right-Y.left,Y.bottom-Y.top);else if(V.tool==="text"&&V.text){let H=V.size??v0;Z.font=`600 ${H}px system-ui, sans-serif`,Z.textBaseline="top";let U=H*0.22;Z.fillStyle="rgba(255,255,255,0.92)",Z.fillRect(Y.left-U,Y.top-U,Y.right-Y.left+U*2,Y.bottom-Y.top+U*2),Z.fillStyle=y0,Z.fillText(V.text,Y.left,Y.top)}Z.restore()}function C(Z,V,X){let Y=I(V);Z.save(),Z.strokeStyle=g1,Z.lineWidth=Math.max(1,1.5*X),Z.setLineDash([6*X,4*X]),Z.strokeRect(Y.left,Y.top,Y.right-Y.left,Y.bottom-Y.top),Z.setLineDash([]);let H=b1*X;for(let T of O(V))Z.fillStyle="#fff",Z.strokeStyle=g1,Z.lineWidth=Math.max(1,1.5*X),Z.beginPath(),Z.rect(T.x-H/2,T.y-H/2,H,H),Z.fill(),Z.stroke();let U=B(V),D=u1*X;Z.beginPath(),Z.arc(U.x,U.y,D,0,Math.PI*2),Z.fillStyle="#dc2626",Z.fill(),Z.strokeStyle="#fff",Z.lineWidth=Math.max(1.5,2*X),Z.beginPath(),Z.moveTo(U.x-D*0.4,U.y-D*0.4),Z.lineTo(U.x+D*0.4,U.y+D*0.4),Z.moveTo(U.x+D*0.4,U.y-D*0.4),Z.lineTo(U.x-D*0.4,U.y+D*0.4),Z.stroke(),Z.restore()}function R(){if(!G)return;let Z=M();if(G.clearRect(0,0,J.width,J.height),G.drawImage($,0,0,J.width,J.height),z.forEach((X,Y)=>{if(Y!==y)_(G,X,Z)}),K)_(G,K,Z);let V=z[W];if(V&&!K)C(G,V,Z)}function m(Z,V,X,Y,H){return Math.abs(Z-X)<=H&&Math.abs(V-Y)<=H}function e(Z,V){let X=z[W];if(!X)return null;let Y=b1*M()/2+3*M();for(let H of O(X))if(m(Z,V,H.x,H.y,Y))return H.id;return null}function u(Z,V){let X=z[W];if(!X)return!1;let Y=B(X);return m(Z,V,Y.x,Y.y,u1*M())}function x(Z,V){let X=6*M();for(let Y=z.length-1;Y>=0;Y-=1){let H=z[Y];if(H.tool==="arrow"){let D=H.x2-H.x1,T=H.y2-H.y1,v=Math.hypot(D,T)||1,g=Math.max(0,Math.min(1,((Z-H.x1)*D+(V-H.y1)*T)/(v*v)));if(Math.hypot(Z-(H.x1+g*D),V-(H.y1+g*T))<=X+4*M())return Y;continue}let U=I(H);if(Z>=U.left-X&&Z<=U.right+X&&V>=U.top-X&&V<=U.bottom+X)return Y}return-1}function p(Z,V,X,Y,H){if(V==="tail"){Z.x1=X.x1+Y,Z.y1=X.y1+H;return}if(V==="head"){Z.x2=X.x2+Y,Z.y2=X.y2+H;return}if(V==="size"){let $2=(X.size??24)+H;Z.size=Math.max(10,$2);return}let U=I(X),{left:D,top:T,right:v,bottom:g}=U;if(V.includes("w"))D=Math.min(v-G0,D+Y);if(V.includes("e"))v=Math.max(D+G0,v+Y);if(V.includes("n"))T=Math.min(g-G0,T+H);if(V.includes("s"))g=Math.max(T+G0,g+H);Z.x1=D,Z.y1=T,Z.x2=v,Z.y2=g}function U0(Z,V,X,Y){Z.x1=V.x1+X,Z.y1=V.y1+Y,Z.x2=V.x2+X,Z.y2=V.y2+Y}let L=null,y=-1,q={x:0,y:0,size:24};function E(){let Z=J.getBoundingClientRect().width;return Z>0?Z/J.width:1}function J2(Z,V){if(!G)return Z.length*V*0.6;G.save(),G.font=`600 ${V}px system-ui, sans-serif`;let X=G.measureText(Z||" ").width;return G.restore(),X}function c0(){if(!L)return;let Z=J.parentElement;if(!Z)return;let V=J.getBoundingClientRect(),X=Z.getBoundingClientRect(),Y=E(),H=q.size*Y;L.style.left=`${V.left-X.left+q.x*Y}px`,L.style.top=`${V.top-X.top+q.y*Y}px`,L.style.fontSize=`${H}px`,L.style.width=`${Math.max(40,J2(L.value,H)+H)}px`}function J0(Z){let V=L;if(!V)return;L=null;let X=V.value.trim(),Y=y;if(y=-1,V.remove(),Z&&X){if(Y>=0&&z[Y])z[Y].text=X,W=Y;else z.push({tool:"text",x1:q.x,y1:q.y,x2:q.x,y2:q.y,text:X,size:q.size}),W=z.length-1;Q()}else if(Y>=0)W=Y;J.focus(),R()}function i0(Z,V,X=-1){J0(!0);let Y=J.parentElement;if(!Y)return;if(getComputedStyle(Y).position==="static")Y.style.position="relative";let H=X>=0?z[X]:void 0;y=X,q={x:H?.x1??Z,y:H?.y1??V,size:H?.size??Math.round(24*M())};let U=document.createElement("input");U.type="text",U.className="text-edit",U.value=H?.text??"",U.setAttribute("aria-label","ข้อความบนภาพ"),U.placeholder="ข้อความ",L=U,Y.append(U),c0(),U.addEventListener("input",c0),U.addEventListener("keydown",(D)=>{if(D.stopPropagation(),D.key==="Enter")J0(!0);else if(D.key==="Escape")J0(!1)}),requestAnimationFrame(()=>{if(L!==U)return;U.focus(),U.select(),U.addEventListener("blur",()=>J0(!0))}),R()}function l0(Z){let{x:V,y:X}=N(Z);if(J.setPointerCapture(Z.pointerId),u(V,X)){M0();return}let Y=e(V,X);if(Y&&z[W]){F={grip:Y,x:V,y:X,start:{...z[W]}};return}if(j==="text"){if(Z.preventDefault(),J.hasPointerCapture(Z.pointerId))J.releasePointerCapture(Z.pointerId);j=null,Q(),i0(V,X);return}if(j){K={tool:j,x1:V,y1:X,x2:V,y2:X},W=-1;return}let H=x(V,X);W=H,F=H>=0?{grip:"body",x:V,y:X,start:{...z[H]}}:null,R()}function o0(Z){let{x:V,y:X}=N(Z);if(K){K.x2=V,K.y2=X,R();return}if(F){let H=z[W];if(!H)return;let U=V-F.x,D=X-F.y;if(F.grip==="body")U0(H,F.start,U,D);else p(H,F.grip,F.start,U,D);R();return}if(j){J.style.cursor="crosshair";return}if(u(V,X)){J.style.cursor="pointer";return}let Y=e(V,X);if(Y){let H=z[W]?O(z[W]).find((U)=>U.id===Y):null;J.style.cursor=H?.cursor??"pointer";return}J.style.cursor=x(V,X)>=0?"move":"default"}function Z0(){if(K){if(!(Math.abs(K.x2-K.x1)<c1&&Math.abs(K.y2-K.y1)<c1))z.push(K),W=z.length-1,j=null,Q();K=null}if(F)F=null,Q();R()}function r0(Z){let V=J.getBoundingClientRect(),X=(Z.clientX-V.left)/V.width*J.width,Y=(Z.clientY-V.top)/V.height*J.height,H=x(X,Y),U=z[H];if(!U||U.tool!=="text")return;Z.preventDefault(),i0(U.x1,U.y1,H)}function s0(Z){if(W<0)return;if(Z.key==="Delete"||Z.key==="Backspace")Z.preventDefault(),M0();else if(Z.key==="Escape")W=-1,R()}function M0(){if(W<0)return;z.splice(W,1),W=-1,Q(),R()}return J.addEventListener("pointerdown",l0),J.addEventListener("pointermove",o0),J.addEventListener("pointerup",Z0),J.addEventListener("pointercancel",Z0),J.addEventListener("dblclick",r0),J.tabIndex=0,J.addEventListener("keydown",s0),R(),{setTool(Z){j=Z,W=-1,J.style.cursor=Z?"crosshair":"default",R()},deleteSelected:M0,clear(){z.length=0,W=-1,Q(),R()},hasShapes:()=>z.length>0,hasSelection:()=>W>=0,toDataUrl(){let Z=document.createElement("canvas");Z.width=$.naturalWidth,Z.height=$.naturalHeight;let V=Z.getContext("2d");if(!V)return J.toDataURL("image/png");V.drawImage($,0,0);let X=M();for(let Y of z)_(V,Y,X);return Z.toDataURL("image/png")},destroy(){J0(!1),J.removeEventListener("pointerdown",l0),J.removeEventListener("pointermove",o0),J.removeEventListener("pointerup",Z0),J.removeEventListener("pointercancel",Z0),J.removeEventListener("dblclick",r0),J.removeEventListener("keydown",s0)}}}var i1=`
|
|
42
42
|
:host { all: initial; }
|
|
43
43
|
* { box-sizing: border-box; }
|
|
44
44
|
|
|
@@ -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 t="lw-debug-reporter",
|
|
124
|
+
`;var t="lw-debug-reporter",l1=()=>[];function b4(J){l1=J}var u4=[{tool:"rect",key:"toolRect"},{tool:"arrow",key:"toolArrow"},{tool:"highlight",key:"toolHighlight"},{tool:"text",key:"toolText"}];function d4(){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=S0(($)=>void this.open($))}disconnectedCallback(){this.stop?.(),this.stop=null,this.close()}async open($){if(this.busy)return;this.busy=!0;let Q=b(w().locale),z=await x0();if(z.method==="cancelled"){this.close();return}this.bundle=E0({reason:$,note:"",screenshotDataUrl:z.dataUrl,screenshotMethod:z.method,erroredQueries:c4()}),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=i1;let z=document.createElement("div");z.className="backdrop";let j=document.createElement("div");return j.className="panel",j.setAttribute("role","dialog"),j.setAttribute("aria-modal","true"),j.setAttribute("aria-label",$.title),z.append(j),this.root.replaceChildren(Q,z),j}renderShell($,Q){let z=this.shell($),j=A("div","head");j.append(A("h2","",$.title)),z.append(j,A("p","status",Q))}renderForm($){let Q=this.bundle;if(!Q)return;let z=this.shell($),j=A("div","head"),W=a("✕","icon");W.setAttribute("aria-label",$.close),W.addEventListener("click",()=>this.close()),j.append(A("h2","",$.title),W);let K=document.createElement("input");K.type="text",K.placeholder=$.summaryPlaceholder;let F=b0($.summaryLabel,$.summaryRequired,!0),G=document.createElement("textarea");G.placeholder=$.detailPlaceholder;let M=A("div","meta");M.innerHTML="";let{context:N}=Q;for(let[S,_]of[[$.reporter,`${N.user.fullName??"—"} (${N.user.email??"—"})`],[$.page,N.route.href],[$.captured,`${Q.network.length} network · ${Q.console.length} console · ${Q.actionTrail.length} actions`]]){let C=document.createElement("div"),R=document.createElement("b");R.textContent=`${S}: `,C.append(R,document.createTextNode(_)),M.append(C)}let P=A("p","status",""),I=a($.submit,"primary");if(I.disabled=!0,K.addEventListener("input",()=>{I.disabled=K.value.trim().length===0}),z.append(j,F,K,b0($.detailLabel),G,M),Q.screenshotDataUrl)z.append(...this.screenshotSection($,Q.screenshotDataUrl));else z.append(A("p","status",$.noScreenshot));let O=A("div","foot"),B=a($.close);B.addEventListener("click",()=>this.close()),O.append(B,P,A("span","grow"),I),z.append(O),I.addEventListener("click",async()=>{I.disabled=!0,P.dataset.tone="",P.textContent=$.submitting;try{let S=await p0(K.value.trim(),{...Q,note:G.value,screenshotDataUrl:this.annotator?.hasShapes()?this.annotator.toDataUrl():Q.screenshotDataUrl}),_=this.dispatchEvent(new CustomEvent("lw-report-submitted",{detail:S,bubbles:!0,composed:!0,cancelable:!0}));if(this.close(),_)n(`${$.submitted} — #${S.number}`,"success")}catch(S){let _=S instanceof Error?S.message:$.failed;P.dataset.tone="error",P.textContent=_,n(`${$.failed} — ${_}`,"error"),I.disabled=!1}}),K.focus()}screenshotSection($,Q){let z=b0($.annotateHint),j=A("div","tools"),W=document.createElement("canvas"),K=A("div","shot");K.append(W);let F=[],G=(I)=>{for(let O of F)O.setAttribute("aria-pressed",String(O===I))};for(let{tool:I,key:O}of u4){let B=a($[O]);B.setAttribute("aria-pressed","false"),B.addEventListener("click",()=>{let S=B.getAttribute("aria-pressed")==="true";G(S?null:B),this.annotator?.setTool(S?null:I)}),F.push(B),j.append(B)}j.append(A("span","sep"));let M=a($.deleteSelected);M.addEventListener("click",()=>this.annotator?.deleteSelected());let N=a($.clearAll);N.addEventListener("click",()=>{this.annotator?.clear(),G(null)}),j.append(M,N);let P=new Image;return P.onload=()=>{W.width=P.naturalWidth,W.height=P.naturalHeight,this.annotator=g0(W,P,()=>{G(null),M.disabled=!this.annotator?.hasSelection()})},P.src=Q,[z,j,A("p","status",$.annotateHelp),K]}}}function c4(){try{return l1()}catch{return[]}}function A(J,$="",Q=""){let z=document.createElement(J);if($)z.className=$;if(Q)z.textContent=Q;return z}function a(J,$=""){let Q=document.createElement("button");if(Q.type="button",Q.textContent=J,$)Q.className=$;return Q}function b0(J,$="",Q=!1){let z=document.createElement("label");if(z.append(document.createTextNode(J)),Q){let j=document.createElement("span");j.className="req",j.textContent=" *",z.append(j)}if($){let j=document.createElement("span");j.className="hint",j.textContent=` ${$}`,z.append(j)}return z}function u0(){if(typeof window>"u"||customElements.get(t))return;customElements.define(t,d4())}var o1=!1;function i4(J={}){if(o1||typeof window>"u")return;if(!$0()){console.error("[debug-capture] configureDebugCapture() must be called before install");return}if(o1=!0,k1(),U1(),Y1(),q1(),J.ui===!1)return;let $=b(w().locale);if(_0((Q)=>{n(Q.message??$.crashed,"error",{label:$.crashAction,onClick:()=>O0(Q)})}),u0(),!document.querySelector(t))document.body.append(document.createElement(t))}var l4=new Set(["error","exception","unhandledrejection"]);function r1(J){if(J.error)return!0;return J.status!==null&&J.status>=400}function d0(J){if(!J)return null;let $=Date.parse(J);return Number.isNaN($)?null:$}function o4(J){try{let{pathname:$}=new URL(J,"http://x");try{return decodeURIComponent($)}catch{return $}}catch{return J.split(/[?#]/)[0]??J}}function r4(J,$,Q){let z=(K)=>({elapsedMs:K,requests:[],failedRequests:[],consoleErrors:[],slowestMs:null});if(J.length===0)return[];let j=J.map((K)=>d0(K.at)),W=(K)=>{for(let F=K+1;F<j.length;F+=1){let G=j[F];if(G!=null)return G}return Number.POSITIVE_INFINITY};return J.map((K,F)=>{let G=j[F]??null,M=(F>0?j[F-1]:null)??null,N=G!==null&&M!==null?Math.max(0,G-M):null;if(G===null)return z(N);let P=G,I=Math.max(P,W(F)),O=(C)=>C!==null&&C>=P&&(C<I||I===Number.POSITIVE_INFINITY),B=$.filter((C)=>O(d0(C.startedAt))),S=Q.filter((C)=>l4.has(C.level)&&O(d0(C.at))),_=B.map((C)=>C.durationMs).filter((C)=>typeof C==="number");return{elapsedMs:N,requests:B,failedRequests:B.filter(r1),consoleErrors:S,slowestMs:_.length>0?Math.max(..._):null}})}function s4(J,$){return J.requests.length===0&&J.consoleErrors.length===0&&(J.elapsedMs===null||J.elapsedMs<$)}function n4(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),z=Math.round($%60);return z===0?`${Q} นาที`:`${Q} นาที ${z} วิ`}var a4="lw-portal-handoff",s1=138.23,t4=`
|
|
125
125
|
:host { all: initial; }
|
|
126
126
|
.backdrop {
|
|
127
127
|
position: fixed; inset: 0; z-index: 2147483002;
|
|
@@ -198,7 +198,7 @@ p { margin: 0; font-size: 13px; line-height: 1.6; color: #475569; }
|
|
|
198
198
|
.ring .bar { animation: none; stroke-dashoffset: 0; }
|
|
199
199
|
.spinner { animation-duration: 2s; }
|
|
200
200
|
}
|
|
201
|
-
`;function n1(
|
|
201
|
+
`;function n1(J){if(typeof document>"u")return J.prepare().then((C)=>void J.go(C),()=>{return});let $=b(w().locale),Q=Math.max(1,Math.floor(J.seconds??3)),z=document.createElement(a4),j=z.attachShadow({mode:"open"}),W=document.createElement("style");W.textContent=t4,j.append(W);let K=document.createElement("div");K.className="backdrop",K.innerHTML=`
|
|
202
202
|
<div class="card" role="dialog" aria-modal="true" aria-labelledby="lw-ho-title">
|
|
203
203
|
<div class="dial">
|
|
204
204
|
<svg class="ring" viewBox="0 0 52 52" aria-hidden="true">
|
|
@@ -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>`,
|
|
217
|
+
</div>`,j.append(K);let F=(C)=>K.querySelector(C),G=F(".card"),M=F(".bar"),N=F(".count"),P=F("h2"),I=F(".body"),O=F(".host"),B=F(".go"),S=F(".cancel");P.textContent=$.handoffTitle,I.textContent=$.handoffBody;try{O.textContent=new URL(w().host).host}catch{O.textContent=""}B.textContent=$.handoffGo,S.textContent=$.cancel,G.style.setProperty("--secs",`${Q}s`),N.textContent=String(Q),document.body.append(z),requestAnimationFrame(()=>K.setAttribute("data-open","1"));let _=document.activeElement;return B.focus({preventScroll:!0}),new Promise((C)=>{let R=!1,m=null,e=!1,u=Date.now()+Q*1000,x=window.setInterval(()=>{let q=Math.ceil((u-Date.now())/1000);if(N.textContent=String(Math.max(0,q)),Date.now()>=u)L()},100);function p(q){if(R)return;if(R=!0,window.clearInterval(x),document.removeEventListener("keydown",y,!0),K.removeAttribute("data-open"),window.setTimeout(()=>z.remove(),200),!q)_?.focus?.({preventScroll:!0});C()}function U0(q){window.clearInterval(x),M.classList.remove("spinner"),M.style.animation="none",N.textContent="",P.textContent=$.handoffBlocked,I.textContent=$.handoffBody;let E=document.createElement("a");E.className="go",E.href=q,E.target="_blank",E.rel="noopener noreferrer",E.textContent=$.handoffOpen,E.addEventListener("click",()=>p(!0)),B.replaceWith(E),E.focus({preventScroll:!0})}function L(){if(R||e)return;if(m)return J.go(m)?p(!0):U0(m);window.clearInterval(x),N.textContent="",M.classList.add("spinner"),P.textContent=$.handoffPreparing}function y(q){if(q.key==="Escape")q.stopPropagation(),p(!1)}document.addEventListener("keydown",y,!0),B.addEventListener("click",L),S.addEventListener("click",()=>p(!1)),K.addEventListener("click",(q)=>{if(q.target===K)p(!1)}),J.prepare().then((q)=>{if(m=q,!R&&Date.now()>=u)L()},()=>{e=!0,window.clearInterval(x),G.classList.add("error"),M.classList.remove("spinner"),M.style.animation="none",N.textContent="",P.textContent=$.handoffFailed,I.textContent=$.handoffBody,B.remove(),S.textContent=$.close})})}var e4="/sso";function e1(J,$,Q){let z=new URL(e4,J.endsWith("/")?J:`${J}/`);return z.searchParams.set("realm",$),z.searchParams.set("token",Q),z.toString()}class H0 extends Error{constructor(J="No identity provider is configured, or nobody is signed in"){super(J);this.name="NoIdentityError"}}async function a1(){let J=w();if(!J.identity)throw new H0;let $=await J.identity();if(!$)throw new H0;return e1(J.host,J.realmKey,$)}function t1(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 J5(J={}){if(J.announce===!1){t1(await a1(),J.target);return}await n1({seconds:J.seconds,prepare:a1,go:($)=>t1($,J.target)})}export{m0 as trimToBudget,m1 as toCurl,e1 as supportPortalUrl,p0 as submitBundle,n as showToast,b4 as setErroredQueriesSource,o4 as requestPath,b as reporterStrings,l as redactUrl,c as redactLabel,i as redactHeaders,o as redactBody,J5 as openSupportPortal,S0 as onLaunch,_0 as onCrash,W2 as moduleResolver,O0 as launch,s4 as isQuietStep,r1 as isFailedRequest,$0 as isConfigured,i4 as installDebugCapture,R4 as hasCause,A0 as getNetworkLog,R0 as getConsoleLog,w as getConfig,q0 as getActionTrail,n4 as formatDuration,f0 as errorSignature,L0 as emitCrash,u0 as defineReporterElement,g0 as createAnnotator,r4 as correlateActionTrail,z2 as configureDebugCapture,x0 as captureScreen,B4 as bundleToMarkdown,w4 as bundleFileName,E0 as buildBundle,f as appInfo,C0 as actionCountSuffix,t as REPORTER_TAG,d as REDACTED,H0 as NoIdentityError,h0 as BUNDLE_BUDGET_BYTES};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightworkai.official/debug-capture",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.2",
|
|
4
4
|
"description": "Report-a-problem widget: rolling network/console/action capture, annotated screenshot, and submission to a Lightwork Support host",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -34,13 +34,48 @@ function safeReplacer(): (key: string, value: unknown) => unknown {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Describe one console argument, and never throw doing it.
|
|
39
|
+
*
|
|
40
|
+
* `String(x)` is not safe on an arbitrary object, which is easy to miss because
|
|
41
|
+
* it is safe on almost all of them. An object with a null prototype, or one
|
|
42
|
+
* whose `Symbol.toPrimitive`/`toString` is absent or throws, raises
|
|
43
|
+
* "Cannot convert object to primitive value" — and it was reachable here TWICE:
|
|
44
|
+
* as the `??` fallback when JSON.stringify returns undefined, and inside the
|
|
45
|
+
* catch that exists precisely because stringify already failed.
|
|
46
|
+
*
|
|
47
|
+
* That mattered more than a logging edge case. This runs inside a patched
|
|
48
|
+
* `console.warn`, so throwing here turns somebody ELSE's warning into an
|
|
49
|
+
* exception raised from the logging call — which the crash watcher then reports
|
|
50
|
+
* as an error in the host application. A Vue dev warning naming a component
|
|
51
|
+
* (reka-ui's Popover passes one) was enough: the app showed a red
|
|
52
|
+
* "Cannot convert object to primitive value" toast, sourced to nothing the host
|
|
53
|
+
* had done, on a page where nothing was wrong.
|
|
54
|
+
*
|
|
55
|
+
* Every step after the first is therefore guarded, INCLUDING the last-resort
|
|
56
|
+
* one: `Object.prototype.toString.call` looks up `Symbol.toStringTag`, so a
|
|
57
|
+
* Proxy with a throwing `get` trap defeats that too — measured, not assumed.
|
|
58
|
+
* `typeof` is the only description of a value that cannot execute any of its
|
|
59
|
+
* code, which is what makes it the floor.
|
|
60
|
+
*/
|
|
37
61
|
function stringifyArg(arg: unknown): string {
|
|
38
62
|
if (typeof arg === 'string') return arg;
|
|
39
63
|
if (arg instanceof Error) return `${arg.name}: ${arg.message}`;
|
|
40
64
|
try {
|
|
41
|
-
|
|
65
|
+
const json = JSON.stringify(arg, safeReplacer());
|
|
66
|
+
if (json !== undefined) return json;
|
|
42
67
|
} catch {
|
|
68
|
+
/* not serialisable — fall through to a description of it */
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
43
71
|
return String(arg);
|
|
72
|
+
} catch {
|
|
73
|
+
/* no primitive conversion — fall through */
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
return Object.prototype.toString.call(arg);
|
|
77
|
+
} catch {
|
|
78
|
+
return `[${typeof arg}]`;
|
|
44
79
|
}
|
|
45
80
|
}
|
|
46
81
|
|