@lightworkai.official/debug-capture 0.10.1 → 0.11.0

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/config.d.ts CHANGED
@@ -119,6 +119,40 @@ export interface DebugCaptureConfig {
119
119
  screenshotFallback?: () => Promise<ToPng | null>;
120
120
  /** UI language. Only affects the built-in reporter's own strings. */
121
121
  locale?: "th" | "en";
122
+ /**
123
+ * Where this library's own notifications go.
124
+ *
125
+ * Three things get announced outside the reporter dialog: a report was filed,
126
+ * a report failed to file, and a crash was caught (that one carries a button
127
+ * that opens the reporter). They land on top of the host's application, so in
128
+ * an app with its own toaster they are the one message in a different corner,
129
+ * with a different animation — which reads as coming from somewhere other than
130
+ * the app the person is using.
131
+ *
132
+ * Set this and every one of them is yours instead:
133
+ *
134
+ * toast: (n) => n.action
135
+ * ? toast[n.tone](n.message, { action: { label: n.action.label, onClick: n.action.onClick } })
136
+ * : toast[n.tone](n.message)
137
+ *
138
+ * Left unset, the built-in toast is used — a package that assumed sonner, or
139
+ * react-toastify, or any other, would impose it on everybody.
140
+ *
141
+ * The `lw-report-submitted` event remains the finer-grained hook for the
142
+ * success case alone: it carries the filed ticket, and cancelling it
143
+ * suppresses that one message. This covers all three at once.
144
+ */
145
+ toast?: (notice: ToastNotice) => void;
146
+ }
147
+ /** One notification from the library, for a host that renders its own. */
148
+ export interface ToastNotice {
149
+ message: string;
150
+ tone: "success" | "error";
151
+ /** Present on the crash invitation: the button that opens the reporter. */
152
+ action?: {
153
+ label: string;
154
+ onClick: () => void;
155
+ };
122
156
  }
123
157
  export interface CaptureOptions {
124
158
  /** Rolling buffer sizes. */
@@ -1,4 +1,4 @@
1
- (()=>{var l1={maxRequests:60,maxConsoleEntries:120,maxActions:80,maxBodyChars:20000},O=null;function T0($){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 k(){if(!O)throw Error("[debug-capture] configureDebugCapture() has not been called");return O}function A0(){return O!==null}function h(){let $=k().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 e(){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 e().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 i($){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())||e().queryKeys.includes(W.toLowerCase()))J.searchParams.set(W,v),Q=!0}),!Q)return $;return j?J.toString():`${J.pathname}${J.search}`}catch{return $}}function X0($,j){if(j>6||$===null||typeof $!=="object")return $;if(Array.isArray($))return $.map((Q)=>X0(Q,j+1));let J={};for(let[Q,z]of Object.entries($)){let W=t1.test(Q)||e().bodyKeys.some((V)=>Q.toLowerCase().includes(V));J[Q]=W?v:X0(z,j+1)}return J}function o($,j){if($==null)return null;let J=$,Q=$.trim();if(Q.startsWith("{")||Q.startsWith("["))try{let z=JSON.parse(Q);J=JSON.stringify(X0(z,0))}catch{}if(J.length>j)return`${J.slice(0,j)}… [truncated ${J.length-j} chars]`;return J}var Y0=120,F0=40,m=($,j)=>$.length>j?`${$.slice(0,j)}…`:$,w0=($)=>{try{return decodeURIComponent($)}catch{return $}},p=[],p0=0,m0=!1;function d($,j,J,Q){let z=m(j,Y0),W=p[p.length-1];if($==="navigate"&&W?.kind==="click"){let Y=z.replace(/^ไปที่\s*/,"");if(W.detail.includes(`→ ${Y}`))return W.at=new Date().toISOString(),W;let w=Y.split(/[?#]/)[0]??Y,H=W.source?w0(W.source.replace(/^→\s*/,"")).split(/[?#]/)[0]:null;if(H&&(w===H||w.startsWith(H)))return W.detail=m(`${W.detail} → ${Y}`,Y0),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 $0($){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=o0(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 w0(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,F0)}”`}var i0=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 Y=V.name.toLowerCase();if(Y.startsWith("on")||Y==="srcdoc"||Y==="value"||Y.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 M0($,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=($)=>M0($,i0,Y2),H2=150000,I2=40000,y0=($)=>M0($,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 o0($){let j=Object.keys($).find((J)=>J.startsWith("__reactFiber$")||J.startsWith("__reactInternalInstance$"));return j?$[j]:null}function C2($){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 P2($){try{let j=$.closest("a[href]")?.getAttribute("href");if(j&&j.startsWith("/"))return b0(j);let J=o0($),Q=0;while(J&&Q<30){if(typeof J.memoizedProps?.onClick==="function")return b0(C2(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 B2(){let $=E0();return $.length?$.join(", "):N2}function q2($){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 d0($){let j=b(D2($)),J=q2($);return j?`เปิด ${J} “${m(j,F0)}”`:`เปิด ${J}`}var k2='[aria-busy="true"], [role="progressbar"], [data-loading="true"], .animate-pulse, .animate-spin',S2=/กำลังโหลด|กำลังค้นหา|กำลังดำเนินการ|\bloading\b/i;function R2($){if($.querySelector(k2))return!0;return S2.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(Y),window.clearTimeout(w)},W=()=>{if(Q)return;if(z(),!$.isConnected)return;j.detail=m(d0($),Y0),j.html=j0(y0($))},V=new MutationObserver(()=>{J=Date.now()});V.observe($,{childList:!0,subtree:!0,attributes:!0,characterData:!0});let Y=window.setInterval(()=>{if(Q)return;if(!$.isConnected){z();return}if(Date.now()-J>=O2&&!R2($))W()},f2),w=window.setTimeout(W,_2)}function A2($){if($0($))return;let j=d("ui",d0($));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=B2(),V=z.matches(W)?[z]:Array.from(z.querySelectorAll(W));for(let Y of V){if($.has(Y))continue;$.add(Y),A2(Y)}}}).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(),F0)}}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=(Y,w)=>{if(Q)return;if(Q=!0,W.disconnect(),window.clearTimeout(V),j.afterNote=Y,w)j.afterHtml=j0(M0($,i0,x2))},W=new MutationObserver(()=>{if(!$.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}let Y=h2(J,u0($));if(Y)z(Y,!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($0(Q.target))return;let z=G2(Q.target);if(!z)return;let W=X2(z);if(!W)return;let V=d("click",`คลิก ${W}`,P2(z),M2(z));if(V)p2(z,V)},{capture:!0,passive:!0}),document.addEventListener("change",(Q)=>{if($0(Q.target))return;let z=U2(Q.target);if(z)d("input",`แก้ไข ${z}`)},{capture:!0,passive:!0}),document.addEventListener("submit",(Q)=>{if($0(Q.target))return;d("submit","ส่งฟอร์ม")},{capture:!0,passive:!0});let $=()=>d("navigate",`ไปที่ ${w0(i(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,J0=[],n0=0,s0=!1;function H0($,j){n0+=1,J0.push({id:`log_${n0}`,at:new Date().toISOString(),level:$,message:j.length>r0?`${j.slice(0,r0)}…`:j});while(J0.length>L("maxConsoleEntries"))J0.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)=>{H0(j,Q.map(a0).join(" ")),J(...Q)}}window.addEventListener("error",(j)=>{let J=j.filename?` (${j.filename}:${j.lineno}:${j.colno})`:"";H0("exception",`${j.message}${J}`)}),window.addEventListener("unhandledrejection",(j)=>{let J=j.reason instanceof Error?`${j.reason.name}: ${j.reason.message}`:a0(j.reason);H0("unhandledrejection",J)})}function e0(){return J0.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 Q0($={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 i2($){let j={};return $.forEach((J,Q)=>{j[Q]=J}),j}function o2($){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 d2($,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=o2(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=o(W,L("maxBodyChars"))}).catch(()=>{})}catch{}}function C1($,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=d2(j,J);if(C1(Q.url,Q.headers))return $(j,J);let z={id:I1(),startedAt:new Date().toISOString(),method:Q.method,url:i(Q.url),requestHeaders:u(Q.headers),requestBody:o(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(i2(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 Y=typeof V==="string"?V:V.toString();return this.__cibEntry=C1(Y,{})?void 0:{id:I1(),startedAt:"",method:(W||"GET").toUpperCase(),url:i(Y),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"?o(W,M1):W==null?null:"[non-string body]";let Y=performance.now();H1(V),this.addEventListener("loadend",()=>{if(V.status=this.status||null,V.statusText=this.statusText||null,V.durationMs=Math.round(performance.now()-Y),U1(V.url))V.responseSnippet="[body not captured for this origin]";else if(this.responseType===""||this.responseType==="text")try{V.responseSnippet=o(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 P1(){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 Z0($){return $==="en"?s2:n2}var I0=null;function a2(){if(typeof document>"u")return null;if(I0?.isConnected)return I0;let $=document.createElement("lw-debug-toasts");$.dataset.debugReporter="true";let j=$.attachShadow({mode:"open"}),J=document.createElement("style");J.textContent=`
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=`
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
- `;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($),I0=Q,Q}function l($,j="success",J){let Q=a2();if(!Q)return;let z=document.createElement("div");z.className="toast",z.dataset.tone=j;let W=document.createElement("span");W.className="dot";let V=document.createElement("span");V.textContent=$;let Y=document.createElement("button");Y.type="button",Y.className="close",Y.textContent="✕",Y.setAttribute("aria-label","ปิด");let w=()=>{window.clearTimeout(H),z.remove()};Y.addEventListener("click",w);let H=j==="error"||J?0:window.setTimeout(w,6000);if(z.append(W,V),J){let U=document.createElement("button");U.type="button",U.className="action",U.textContent=J.label,U.addEventListener("click",()=>{w(),J.onClick()}),z.append(U)}z.append(Y),Q.append(z)}function B1($,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 t2(){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 U0($,j){if(!$)return j;try{return $()}catch{return j}}function q1(){let $=k(),{pathname:j,search:J,href:Q}=window.location;return{capturedAt:new Date().toISOString(),route:{href:Q,pathname:j,search:J},module:L0(j),user:U0($.user,{}),apiHeaders:u(U0($.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:t2(),extra:U0($.extra,{})}}var e2=2;function D1($){let j=N1(),J=e0();return{context:q1(),reason:$.reason,note:$.note,cause:B1(j,J,$.erroredQueries),actionTrail:l0(),network:j,console:J,screenshotDataUrl:$.screenshotDataUrl,screenshotMethod:$.screenshotMethod,meta:{generatedBy:"lightwork-debug-capture",schemaVersion:e2}}}async function k1(){if(typeof navigator<"u"&&Boolean(navigator.mediaDevices?.getDisplayMedia)){let J=await $4();if(J.status==="ok")return{dataUrl:J.dataUrl,method:"display-media"};if(J.status==="cancelled")return{dataUrl:null,method:"cancelled"}}let j=await Q4();if(j)return{dataUrl:j,method:"html-to-image"};return{dataUrl:null,method:"none"}}async function $4(){let $=null;try{let j={video:{frameRate:30},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude"};$=await navigator.mediaDevices.getDisplayMedia(j);let J=await j4($);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 j4($){let j=document.createElement("video");j.srcObject=$,j.muted=!0,j.playsInline=!0,await new Promise((V)=>{let Y=!1,w=()=>{if(Y)return;Y=!0,V()};j.onloadedmetadata=()=>{j.play().then(w).catch(w)},window.setTimeout(w,1500)}),await J4(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 J4($){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 Q4(){let $=k().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 z4=2000,Z4=0.82,W4=3000000;function K4($){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 S1($){try{let j=await K4($),J=Math.max(j.naturalWidth,j.naturalHeight),Q=Math.min(1,z4/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=Z4,Y=z.toDataURL("image/jpeg",V);while(Y.length>W4&&V>0.4)V-=0.15,Y=z.toDataURL("image/jpeg",V);return Y}catch{return $}}var V4=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,G4=/^\d+$/,X4=/^[0-9a-f]{16,}$/i;function R1($){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)=>V4.test(W)||G4.test(W)||X4.test(W)?":id":W).join("/"),z=j.status??(j.error?"ERR":"?");return`${j.method??"REQ"} ${Q} ${z}`}var O1=2000000;function W0($){let{screenshotDataUrl:j,...J}=$;return JSON.stringify(J).length}function f1($,j=2000000){if(W0($)<=j)return $;let J=$.network.map((z)=>({...z})),Q={...$,network:J};for(let z of J){if(W0(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&&W0(Q)>j)Q.network=Q.network.slice(1);while(Q.console.length>1&&W0(Q)>j)Q.console=Q.console.slice(1);return Q}var _1=32768;function Y4($){let j="";for(let J=0;J<$.length;J+=_1)j+=String.fromCharCode(...$.subarray(J,J+_1));return btoa(j)}function F4($){return{dataUri:`data:application/json;base64,${Y4(new TextEncoder().encode(JSON.stringify($)))}`,filename:"debug-bundle.json"}}async function w4(){let $=k().identity;if(!$)return{};try{let j=await $();return j?{authorization:`Bearer ${j}`}:{}}catch{return{}}}async function T1($,j){let J=k(),Q=f1(j,O1),{context:z,note:W}=Q,V=[];if(Q.screenshotDataUrl){let U=await S1(Q.screenshotDataUrl);V.push({dataUri:U,filename:"screenshot.jpg"})}V.push(F4(Q));let Y=R1(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:{...Y?{signature:Y}:{},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 w4()},body:JSON.stringify(w)});if(!H.ok){let U=H.headers.get("retry-after"),P=await H.json().then((C)=>C.error).catch(()=>null);throw Error(H.status===429?`Too many reports — try again in ${U??"a moment"}s`:P??`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),Y=[{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:Y};return{shaft:{from:$,to:{x:j.x-w*Math.cos(V),y:j.y-w*Math.sin(V)}},head:Y}}var C0="#f44336",M4="rgba(250, 204, 21, 0.4)",P0=22,L1="#2563eb",E1=9,x1=11,h1=18,p1=4,K0=8,H4=[{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,Y=null,w=$.getContext("2d");function H(){let Z=$.getBoundingClientRect().width;return Z>0?$.width/Z:1}function U(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??P0;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 C(Z){if(Z.tool==="text"){let K=Z.size??P0;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 S(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=C(Z);if(Z.tool==="text")return[{id:"size",x:K.right,y:K.bottom,cursor:"nwse-resize"}];return H4.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 q(Z){let K=C(Z);return{x:K.right+h1*H(),y:K.top-h1*H()}}function D(Z,K,X){let{shaft:G,head:F}=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(F[0].x,F[0].y),Z.lineTo(F[1].x,F[1].y),Z.lineTo(F[2].x,F[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=C(K);if(K.tool==="rect")Z.strokeRect(G.left,G.top,G.right-G.left,G.bottom-G.top);else if(K.tool==="arrow")D(Z,K,X);else if(K.tool==="highlight")Z.fillStyle=M4,Z.fillRect(G.left,G.top,G.right-G.left,G.bottom-G.top);else if(K.tool==="text"&&K.text){let F=K.size??P0;Z.font=`600 ${F}px system-ui, sans-serif`,Z.textBaseline="top";let M=F*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=C(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 F=E1*X;for(let R of S(K))Z.fillStyle="#fff",Z.strokeStyle=L1,Z.lineWidth=Math.max(1,1.5*X),Z.beginPath(),Z.rect(R.x-F/2,R.y-F/2,F,F),Z.fill(),Z.stroke();let M=q(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,F){return Math.abs(Z-X)<=F&&Math.abs(K-G)<=F}function q0(Z,K){let X=Q[W];if(!X)return null;let G=E1*H()/2+3*H();for(let F of S(X))if(B0(Z,K,F.x,F.y,G))return F.id;return null}function D0(Z,K){let X=Q[W];if(!X)return!1;let G=q(X);return B0(Z,K,G.x,G.y,x1*H())}function V0(Z,K){let X=6*H();for(let G=Q.length-1;G>=0;G-=1){let F=Q[G];if(F.tool==="arrow"){let I=F.x2-F.x1,R=F.y2-F.y1,E=Math.hypot(I,R)||1,x=Math.max(0,Math.min(1,((Z-F.x1)*I+(K-F.y1)*R)/(E*E)));if(Math.hypot(Z-(F.x1+x*I),K-(F.y1+x*R))<=X+4*H())return G;continue}let M=C(F);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,F){if(K==="tail"){Z.x1=X.x1+G,Z.y1=X.y1+F;return}if(K==="head"){Z.x2=X.x2+G,Z.y2=X.y2+F;return}if(K==="size"){let c1=(X.size??24)+F;Z.size=Math.max(10,c1);return}let M=C(X),{left:I,top:R,right:E,bottom:x}=M;if(K.includes("w"))I=Math.min(E-K0,I+G);if(K.includes("e"))E=Math.max(I+K0,E+G);if(K.includes("n"))R=Math.min(x-K0,R+F);if(K.includes("s"))x=Math.max(R+K0,x+F);Z.x1=I,Z.y1=R,Z.x2=E,Z.y2=x}function i1(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 o1(){let Z=$.getBoundingClientRect().width;return Z>0?Z/$.width:1}function d1(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 k0(){if(!_)return;let Z=$.parentElement;if(!Z)return;let K=$.getBoundingClientRect(),X=Z.getBoundingClientRect(),G=o1(),F=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=`${F}px`,_.style.width=`${Math.max(40,d1(_.value,F)+F)}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 F=X>=0?Q[X]:void 0;a=X,T={x:F?.x1??Z,y:F?.y1??K,size:F?.size??Math.round(24*H())};let M=document.createElement("input");M.type="text",M.className="text-edit",M.value=F?.text??"",M.setAttribute("aria-label","ข้อความบนภาพ"),M.placeholder="ข้อความ",_=M,G.append(M),k0(),M.addEventListener("input",k0),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 R0(Z){let{x:K,y:X}=U(Z);if($.setPointerCapture(Z.pointerId),D0(K,X)){G0();return}let G=q0(K,X);if(G&&Q[W]){Y={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 F=V0(K,X);W=F,Y=F>=0?{grip:"body",x:K,y:X,start:{...Q[F]}}:null,N()}function O0(Z){let{x:K,y:X}=U(Z);if(V){V.x2=K,V.y2=X,N();return}if(Y){let F=Q[W];if(!F)return;let M=K-Y.x,I=X-Y.y;if(Y.grip==="body")i1(F,Y.start,M,I);else u1(F,Y.grip,Y.start,M,I);N();return}if(z){$.style.cursor="crosshair";return}if(D0(K,X)){$.style.cursor="pointer";return}let G=q0(K,X);if(G){let F=Q[W]?S(Q[W]).find((M)=>M.id===G):null;$.style.cursor=F?.cursor??"pointer";return}$.style.cursor=V0(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(Y)Y=null,J();N()}function f0(Z){let K=$.getBoundingClientRect(),X=(Z.clientX-K.left)/K.width*$.width,G=(Z.clientY-K.top)/K.height*$.height,F=V0(X,G),M=Q[F];if(!M||M.tool!=="text")return;Z.preventDefault(),S0(M.x1,M.y1,F)}function _0(Z){if(W<0)return;if(Z.key==="Delete"||Z.key==="Backspace")Z.preventDefault(),G0();else if(Z.key==="Escape")W=-1,N()}function G0(){if(W<0)return;Q.splice(W,1),W=-1,J(),N()}return $.addEventListener("pointerdown",R0),$.addEventListener("pointermove",O0),$.addEventListener("pointerup",t),$.addEventListener("pointercancel",t),$.addEventListener("dblclick",f0),$.tabIndex=0,$.addEventListener("keydown",_0),N(),{setTool(Z){z=Z,W=-1,$.style.cursor=Z?"crosshair":"default",N()},deleteSelected:G0,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",R0),$.removeEventListener("pointermove",O0),$.removeEventListener("pointerup",t),$.removeEventListener("pointercancel",t),$.removeEventListener("dblclick",f0),$.removeEventListener("keydown",_0)}}}var g1=`
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=`
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 n="lw-debug-reporter",I4=()=>[];var U4=[{tool:"rect",key:"toolRect"},{tool:"arrow",key:"toolArrow"},{tool:"highlight",key:"toolHighlight"},{tool:"text",key:"toolText"}];function C4(){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 J=Z0(k().locale),Q=await k1();if(Q.method==="cancelled"){this.close();return}this.bundle=D1({reason:j,note:"",screenshotDataUrl:Q.dataUrl,screenshotMethod:Q.method,erroredQueries:P4()}),this.renderForm(J)}close(){this.annotator?.destroy(),this.annotator=null,this.bundle=null,this.busy=!1,this.root.replaceChildren()}shell(j){let J=document.createElement("style");J.textContent=g1;let Q=document.createElement("div");Q.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),Q.append(z),this.root.replaceChildren(J,Q),z}renderShell(j,J){let Q=this.shell(j),z=B("div","head");z.append(B("h2","",j.title)),Q.append(z,B("p","status",J))}renderForm(j){let J=this.bundle;if(!J)return;let Q=this.shell(j),z=B("div","head"),W=g("✕","icon");W.setAttribute("aria-label",j.close),W.addEventListener("click",()=>this.close()),z.append(B("h2","",j.title),W);let V=document.createElement("input");V.type="text",V.placeholder=j.summaryPlaceholder;let Y=N0(j.summaryLabel,j.summaryRequired,!0),w=document.createElement("textarea");w.placeholder=j.detailPlaceholder;let H=B("div","meta");H.innerHTML="";let{context:U}=J;for(let[D,f]of[[j.reporter,`${U.user.fullName??"—"} (${U.user.email??"—"})`],[j.page,U.route.href],[j.captured,`${J.network.length} network · ${J.console.length} console · ${J.actionTrail.length} actions`]]){let s=document.createElement("div"),N=document.createElement("b");N.textContent=`${D}: `,s.append(N,document.createTextNode(f)),H.append(s)}let P=B("p","status",""),C=g(j.submit,"primary");if(C.disabled=!0,V.addEventListener("input",()=>{C.disabled=V.value.trim().length===0}),Q.append(z,Y,V,N0(j.detailLabel),w,H),J.screenshotDataUrl)Q.append(...this.screenshotSection(j,J.screenshotDataUrl));else Q.append(B("p","status",j.noScreenshot));let S=B("div","foot"),q=g(j.close);q.addEventListener("click",()=>this.close()),S.append(q,P,B("span","grow"),C),Q.append(S),C.addEventListener("click",async()=>{C.disabled=!0,P.dataset.tone="",P.textContent=j.submitting;try{let D=await T1(V.value.trim(),{...J,note:w.value,screenshotDataUrl:this.annotator?.hasShapes()?this.annotator.toDataUrl():J.screenshotDataUrl}),f=this.dispatchEvent(new CustomEvent("lw-report-submitted",{detail:D,bubbles:!0,composed:!0,cancelable:!0}));if(this.close(),f)l(`${j.submitted} — #${D.number}`,"success")}catch(D){let f=D instanceof Error?D.message:j.failed;P.dataset.tone="error",P.textContent=f,l(`${j.failed} — ${f}`,"error"),C.disabled=!1}}),V.focus()}screenshotSection(j,J){let Q=N0(j.annotateHint),z=B("div","tools"),W=document.createElement("canvas"),V=B("div","shot");V.append(W);let Y=[],w=(C)=>{for(let S of Y)S.setAttribute("aria-pressed",String(S===C))};for(let{tool:C,key:S}of U4){let q=g(j[S]);q.setAttribute("aria-pressed","false"),q.addEventListener("click",()=>{let D=q.getAttribute("aria-pressed")==="true";w(D?null:q),this.annotator?.setTool(D?null:C)}),Y.push(q),z.append(q)}z.append(B("span","sep"));let H=g(j.deleteSelected);H.addEventListener("click",()=>this.annotator?.deleteSelected());let U=g(j.clearAll);U.addEventListener("click",()=>{this.annotator?.clear(),w(null)}),z.append(H,U);let P=new Image;return P.onload=()=>{W.width=P.naturalWidth,W.height=P.naturalHeight,this.annotator=m1(W,P,()=>{w(null),H.disabled=!this.annotator?.hasSelection()})},P.src=J,[Q,z,B("p","status",j.annotateHelp),V]}}}function P4(){try{return I4()}catch{return[]}}function B($,j="",J=""){let Q=document.createElement($);if(j)Q.className=j;if(J)Q.textContent=J;return Q}function g($,j=""){let J=document.createElement("button");if(J.type="button",J.textContent=$,j)J.className=j;return J}function N0($,j="",J=!1){let Q=document.createElement("label");if(Q.append(document.createTextNode($)),J){let z=document.createElement("span");z.className="req",z.textContent=" *",Q.append(z)}if(j){let z=document.createElement("span");z.className="hint",z.textContent=` ${j}`,Q.append(z)}return Q}function y1(){if(typeof window>"u"||customElements.get(n))return;customElements.define(n,C4())}var v1=!1;function b1($={}){if(v1||typeof window>"u")return;if(!A0()){console.error("[debug-capture] configureDebugCapture() must be called before install");return}if(v1=!0,P1(),t0(),c0(),X1(),$.ui===!1)return;let j=Z0(k().locale);if(Z1((J)=>{l(J.message??j.crashed,"error",{label:j.crashAction,onClick:()=>Q0(J)})}),y1(),!document.querySelector(n))document.body.append(document.createElement(n))}var N4=document.currentScript,A=N4?.dataset??{};function B4($){if(!$)return{};try{let j=JSON.parse($);if(!j||typeof j!=="object"||Array.isArray(j))return{};return Object.fromEntries(Object.entries(j).filter(([,J])=>typeof J==="string"&&J.trim()))}catch{return{}}}if(A.host&&A.realmKey)T0({host:A.host,realmKey:A.realmKey,app:{name:A.appName??document.title??"app",version:A.appVersion??"0.0.0",environment:A.environment??"production"},module:h0(B4(A.modules)),locale:A.locale==="en"?"en":"th"}),b1();window.lwReportProblem=Q0;})();
116
+ `;var n="lw-debug-reporter",C4=()=>[];var N4=[{tool:"rect",key:"toolRect"},{tool:"arrow",key:"toolArrow"},{tool:"highlight",key:"toolHighlight"},{tool:"text",key:"toolText"}];function q4(){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 J=W0(q().locale),Q=await k1();if(Q.method==="cancelled"){this.close();return}this.bundle=D1({reason:j,note:"",screenshotDataUrl:Q.dataUrl,screenshotMethod:Q.method,erroredQueries:B4()}),this.renderForm(J)}close(){this.annotator?.destroy(),this.annotator=null,this.bundle=null,this.busy=!1,this.root.replaceChildren()}shell(j){let J=document.createElement("style");J.textContent=g1;let Q=document.createElement("div");Q.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),Q.append(z),this.root.replaceChildren(J,Q),z}renderShell(j,J){let Q=this.shell(j),z=B("div","head");z.append(B("h2","",j.title)),Q.append(z,B("p","status",J))}renderForm(j){let J=this.bundle;if(!J)return;let Q=this.shell(j),z=B("div","head"),W=g("✕","icon");W.setAttribute("aria-label",j.close),W.addEventListener("click",()=>this.close()),z.append(B("h2","",j.title),W);let V=document.createElement("input");V.type="text",V.placeholder=j.summaryPlaceholder;let F=q0(j.summaryLabel,j.summaryRequired,!0),w=document.createElement("textarea");w.placeholder=j.detailPlaceholder;let H=B("div","meta");H.innerHTML="";let{context:C}=J;for(let[k,f]of[[j.reporter,`${C.user.fullName??"—"} (${C.user.email??"—"})`],[j.page,C.route.href],[j.captured,`${J.network.length} network · ${J.console.length} console · ${J.actionTrail.length} actions`]]){let s=document.createElement("div"),N=document.createElement("b");N.textContent=`${k}: `,s.append(N,document.createTextNode(f)),H.append(s)}let U=B("p","status",""),P=g(j.submit,"primary");if(P.disabled=!0,V.addEventListener("input",()=>{P.disabled=V.value.trim().length===0}),Q.append(z,F,V,q0(j.detailLabel),w,H),J.screenshotDataUrl)Q.append(...this.screenshotSection(j,J.screenshotDataUrl));else Q.append(B("p","status",j.noScreenshot));let R=B("div","foot"),D=g(j.close);D.addEventListener("click",()=>this.close()),R.append(D,U,B("span","grow"),P),Q.append(R),P.addEventListener("click",async()=>{P.disabled=!0,U.dataset.tone="",U.textContent=j.submitting;try{let k=await T1(V.value.trim(),{...J,note:w.value,screenshotDataUrl:this.annotator?.hasShapes()?this.annotator.toDataUrl():J.screenshotDataUrl}),f=this.dispatchEvent(new CustomEvent("lw-report-submitted",{detail:k,bubbles:!0,composed:!0,cancelable:!0}));if(this.close(),f)l(`${j.submitted} — #${k.number}`,"success")}catch(k){let f=k instanceof Error?k.message:j.failed;U.dataset.tone="error",U.textContent=f,l(`${j.failed} — ${f}`,"error"),P.disabled=!1}}),V.focus()}screenshotSection(j,J){let Q=q0(j.annotateHint),z=B("div","tools"),W=document.createElement("canvas"),V=B("div","shot");V.append(W);let F=[],w=(P)=>{for(let R of F)R.setAttribute("aria-pressed",String(R===P))};for(let{tool:P,key:R}of N4){let D=g(j[R]);D.setAttribute("aria-pressed","false"),D.addEventListener("click",()=>{let k=D.getAttribute("aria-pressed")==="true";w(k?null:D),this.annotator?.setTool(k?null:P)}),F.push(D),z.append(D)}z.append(B("span","sep"));let H=g(j.deleteSelected);H.addEventListener("click",()=>this.annotator?.deleteSelected());let C=g(j.clearAll);C.addEventListener("click",()=>{this.annotator?.clear(),w(null)}),z.append(H,C);let U=new Image;return U.onload=()=>{W.width=U.naturalWidth,W.height=U.naturalHeight,this.annotator=m1(W,U,()=>{w(null),H.disabled=!this.annotator?.hasSelection()})},U.src=J,[Q,z,B("p","status",j.annotateHelp),V]}}}function B4(){try{return C4()}catch{return[]}}function B($,j="",J=""){let Q=document.createElement($);if(j)Q.className=j;if(J)Q.textContent=J;return Q}function g($,j=""){let J=document.createElement("button");if(J.type="button",J.textContent=$,j)J.className=j;return J}function q0($,j="",J=!1){let Q=document.createElement("label");if(Q.append(document.createTextNode($)),J){let z=document.createElement("span");z.className="req",z.textContent=" *",Q.append(z)}if(j){let z=document.createElement("span");z.className="hint",z.textContent=` ${j}`,Q.append(z)}return Q}function y1(){if(typeof window>"u"||customElements.get(n))return;customElements.define(n,q4())}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,C1(),t0(),c0(),X1(),$.ui===!1)return;let j=W0(q().locale);if(Z1((J)=>{l(J.message??j.crashed,"error",{label:j.crashAction,onClick:()=>z0(J)})}),y1(),!document.querySelector(n))document.body.append(document.createElement(n))}var D4=document.currentScript,A=D4?.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(([,J])=>typeof J==="string"&&J.trim()))}catch{return{}}}if(A.host&&A.realmKey)A0({host:A.host,realmKey:A.realmKey,app:{name:A.appName??document.title??"app",version:A.appVersion??"0.0.0",environment:A.environment??"production"},module:h0(k4(A.modules)),locale:A.locale==="en"?"en":"th"}),b1();window.lwReportProblem=z0;})();
package/dist/index.d.ts CHANGED
@@ -12,7 +12,7 @@
12
12
  export { configureDebugCapture, isConfigured, getConfig, appInfo } from "./config";
13
13
  export { moduleResolver } from "./modules";
14
14
  export type { ModuleMap } from "./modules";
15
- export type { DebugCaptureConfig, CaptureOptions, RedactOptions } from "./config";
15
+ export type { DebugCaptureConfig, CaptureOptions, RedactOptions, ToastNotice } from "./config";
16
16
  export { installDebugCapture } from "./install";
17
17
  export type { InstallOptions } from "./install";
18
18
  export { launch, onLaunch, onCrash, emitCrash } from "./reporter";
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- var J2={maxRequests:60,maxConsoleEntries:120,maxActions:80,maxBodyChars:20000},k=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.");k=$}function R(){if(!k)throw Error("[debug-capture] configureDebugCapture() has not been called");return k}function U0(){return k!==null}function x(){let $=R().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=k?.capture?.[$];return typeof j==="number"?j:J2[$]}function n0($){let j=k?.module;if(!j)return null;try{return j($)??null}catch{return null}}function Z0(){let $=k?.redact;return{headers:$?.headers??[],queryKeys:($?.queryKeys??[]).map((j)=>j.toLowerCase()),bodyKeys:($?.bodyKeys??[]).map((j)=>j.toLowerCase())}}function a0(){return k?.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(k?.capture?.bodyOrigins??[]).some((J)=>{try{return new URL(J).origin===j.origin}catch{return!1}})}function Z2($){if(!k?.host)return!1;try{if(new URL(k.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,G2=/[\w.+-]+@[\w-]+\.[\w.-]+/g,Y2=/\d(?:[\d\s-]{7,})\d/g;function c($){return $.replace(G2,d).replace(Y2,d)}function F2($){if(K2.test($))return!0;return Z0().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())||Z0().queryKeys.includes(W.toLowerCase()))J.searchParams.set(W,d),Q=!0}),!Q)return $;return j?J.toString():`${J.pathname}${J.search}`}catch{return $}}function C0($,j){if(j>6||$===null||typeof $!=="object")return $;if(Array.isArray($))return $.map((Q)=>C0(Q,j+1));let J={};for(let[Q,z]of Object.entries($)){let W=X2.test(Q)||Z0().bodyKeys.some((K)=>Q.toLowerCase().includes(K));J[Q]=W?d:C0(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(C0(z,0))}catch{}if(J.length>j)return`${J.slice(0,j)}… [truncated ${J.length-j} chars]`;return J}var P0=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,P0),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 H=G.split(/[?#]/)[0]??G,U=W.source?w0(W.source.replace(/^→\s*/,"")).split(/[?#]/)[0]:null;if(U&&(H===U||H.startsWith(U)))return W.detail=s(`${W.detail} → ${G}`,P0),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:K0(Q)};r.push(K);while(r.length>h("maxActions"))M2(r.shift());return K}var H2=200000,J0=0;function K0($){if(!$)return;if(J0+$.length>H2)return;return J0+=$.length,$}function M2($){if(!$)return;if(J0-=($.html?.length??0)+($.afterHtml?.length??0),J0<0)J0=0}function D0($){return $&&$>1?` (×${$})`:""}function W0($){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',C2={button:"ปุ่ม",a:"ลิงก์",input:"ช่อง",textarea:"ช่อง",select:"ตัวเลือก",summary:"ส่วนขยาย"},j1={button:"ปุ่ม",tab:"แท็บ",menuitem:"เมนู",option:"ตัวเลือก",switch:"สวิตช์",checkbox:"ช่องเลือก",radio:"ตัวเลือก",link:"ลิงก์"};function P2($){let j=$.getAttribute("role");if(j&&j1[j])return j1[j];return C2[$.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`${P2($)} “${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 T2($){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 k2='[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], [role="status"], [role="alert"]';function f2(){let $=a0();return $.length?$.join(", "):k2}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',g2=/กำลังโหลด|กำลังค้นหา|กำลังดำเนินการ|\bloading\b/i;function p2($){if($.querySelector(h2))return!0;return g2.test($.textContent??"")}var m2=400,v2=250,y2=8000;function b2($,j){if(typeof MutationObserver>"u"){j.html=K0(J1($));return}let J=Date.now(),Q=!1,z=()=>{Q=!0,K.disconnect(),window.clearInterval(G),window.clearTimeout(H)},W=()=>{if(Q)return;if(z(),!$.isConnected)return;j.detail=s(V1($),P0),j.html=K0(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>=m2&&!p2($))W()},v2),H=window.setTimeout(W,y2)}function u2($){if(W0($))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,H)=>{if(Q)return;if(Q=!0,W.disconnect(),window.clearTimeout(K),j.afterNote=G,H)j.afterHtml=K0(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(W0(Q.target))return;let z=D2(Q.target);if(!z)return;let W=N2(z);if(!W)return;let K=j0("click",`คลิก ${W}`,T2(z),R2(z));if(K)l2(z,K)},{capture:!0,passive:!0}),document.addEventListener("change",(Q)=>{if(W0(Q.target))return;let z=L2(Q.target);if(z)j0("input",`แก้ไข ${z}`)},{capture:!0,passive:!0}),document.addEventListener("submit",(Q)=>{if(W0(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 G1=2000,V0=[],Y1=0,F1=!1;function q0($,j){Y1+=1,V0.push({id:`log_${Y1}`,at:new Date().toISOString(),level:$,message:j.length>G1?`${j.slice(0,G1)}…`:j});while(V0.length>h("maxConsoleEntries"))V0.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 V0.map(($)=>({...$}))}var U1=new Set,C1=new Set;function P1($,j){return $.add(j),()=>$.delete(j)}function I1($,j){for(let J of[...$])J(j)}function R0($){return P1(U1,$)}function O0($={type:"manual"}){I1(U1,$)}function _0($){return P1(C1,$)}function L0($){I1(C1,$)}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,X0=[],q1=0,S1=!1;function _1($){X0.push($);while(X0.length>h("maxRequests"))X0.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 T1($,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(T1(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=T1(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 H=this.getResponseHeader("content-type")??this.responseType;K.responseSnippet=`[binary ${H}]`}})}return J.apply(this,arguments)};$.open=Q,$.send=z}function k1(){if(S1)return;S1=!0,z4(),Z4()}function A0(){let $=X0.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 T0=null;function V4(){if(typeof document>"u")return null;if(T0?.isConnected)return T0;let $=document.createElement("lw-debug-toasts");$.dataset.debugReporter="true";let j=$.attachShadow({mode:"open"}),J=document.createElement("style");J.textContent=`
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=`
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},k
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
- `;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($),T0=Q,Q}function n($,j="success",J){let Q=V4();if(!Q)return;let z=document.createElement("div");z.className="toast",z.dataset.tone=j;let W=document.createElement("span");W.className="dot";let K=document.createElement("span");K.textContent=$;let G=document.createElement("button");G.type="button",G.className="close",G.textContent="✕",G.setAttribute("aria-label","ปิด");let H=()=>{window.clearTimeout(U),z.remove()};G.addEventListener("click",H);let U=j==="error"||J?0:window.setTimeout(H,6000);if(z.append(W,K),J){let C=document.createElement("button");C.type="button",C.className="action",C.textContent=J.label,C.addEventListener("click",()=>{H(),J.onClick()}),z.append(C)}z.append(G),Q.append(z)}function f1($,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 E1($){return $.failedRequests.length+$.errors.length+$.erroredQueries.length}function X4(){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 k0($,j){if(!$)return j;try{return $()}catch{return j}}function x1(){let $=R(),{pathname:j,search:J,href:Q}=window.location;return{capturedAt:new Date().toISOString(),route:{href:Q,pathname:j,search:J},module:n0(j),user:k0($.user,{}),apiHeaders:i(k0($.headers,{})),app:{name:x().name,version:x().version,environment:x().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:X4(),extra:k0($.extra,{})}}var G4=2,Y4={manual:"ผู้ใช้แจ้งเอง","runtime-error":"ข้อผิดพลาด runtime (auto)",unhandledrejection:"Promise rejection (auto)","framework-error":"หน้าจอค้าง/พัง (auto)"};function f0($){let j=A0(),J=S0();return{context:x1(),reason:$.reason,note:$.note,cause:f1(j,J,$.erroredQueries),actionTrail:B0(),network:j,console:J,screenshotDataUrl:$.screenshotDataUrl,screenshotMethod:$.screenshotMethod,meta:{generatedBy:"lightwork-debug-capture",schemaVersion:G4}}}function h1($){return $.replace(/'/g,"'\\''")}function g1($){let j=[`curl -X ${$.method} '${$.url}'`];for(let[J,Q]of Object.entries($.requestHeaders))j.push(` -H '${J}: ${h1(Q)}'`);if($.requestBody)j.push(` --data '${h1($.requestBody)}'`);return j.join(" \\\n")}function F4($){if($.error)return`ERR ${$.error}`;return`${$.status??"—"} ${$.statusText??""}`.trim()}function H4($){if($.length===0)return"No network activity captured.";return $.map((j)=>{let J=j.durationMs!=null?`${j.durationMs}ms`:"—",Q=`# [${F4(j)}] ${j.method} ${j.url} (${J}, ${j.startedAt})`,z=j.responseSnippet?`
33
+ `,k0=null;function G4(){if(typeof document>"u")return null;if(k0?.isConnected)return k0;let $=document.createElement(V4);$.dataset.debugReporter="true";let j=$.attachShadow({mode:"open"}),J=document.createElement("style");J.textContent=Y4;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($),k0=Q,Q}function n($,j="success",J){let Q=j0()?q().toast:void 0;if(Q){Q({message:$,tone:j,...J?{action:J}:{}});return}let z=G4();if(!z)return;let W=document.createElement("div");W.className="toast",W.dataset.tone=j;let K=document.createElement("span");K.className="dot";let G=document.createElement("span");G.textContent=$;let F=document.createElement("button");F.type="button",F.className="close",F.textContent="✕",F.setAttribute("aria-label","ปิด");let U=()=>{window.clearTimeout(w),W.remove()};F.addEventListener("click",U);let w=j==="error"||J?0:window.setTimeout(U,X4);if(W.append(K,G),J){let P=document.createElement("button");P.type="button",P.className="action",P.textContent=J.label,P.addEventListener("click",()=>{U(),J.onClick()}),W.append(P)}W.append(F),z.append(W)}function f1($,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 E1($){return $.failedRequests.length+$.errors.length+$.erroredQueries.length}function F4(){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 T0($,j){if(!$)return j;try{return $()}catch{return j}}function x1(){let $=q(),{pathname:j,search:J,href:Q}=window.location;return{capturedAt:new Date().toISOString(),route:{href:Q,pathname:j,search:J},module:n0(j),user:T0($.user,{}),apiHeaders:i(T0($.headers,{})),app:{name:x().name,version:x().version,environment:x().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:F4(),extra:T0($.extra,{})}}var H4=2,M4={manual:"ผู้ใช้แจ้งเอง","runtime-error":"ข้อผิดพลาด runtime (auto)",unhandledrejection:"Promise rejection (auto)","framework-error":"หน้าจอค้าง/พัง (auto)"};function f0($){let j=A0(),J=S0();return{context:x1(),reason:$.reason,note:$.note,cause:f1(j,J,$.erroredQueries),actionTrail:B0(),network:j,console:J,screenshotDataUrl:$.screenshotDataUrl,screenshotMethod:$.screenshotMethod,meta:{generatedBy:"lightwork-debug-capture",schemaVersion:H4}}}function h1($){return $.replace(/'/g,"'\\''")}function p1($){let j=[`curl -X ${$.method} '${$.url}'`];for(let[J,Q]of Object.entries($.requestHeaders))j.push(` -H '${J}: ${h1(Q)}'`);if($.requestBody)j.push(` --data '${h1($.requestBody)}'`);return j.join(" \\\n")}function U4($){if($.error)return`ERR ${$.error}`;return`${$.status??"—"} ${$.statusText??""}`.trim()}function P4($){if($.length===0)return"No network activity captured.";return $.map((j)=>{let J=j.durationMs!=null?`${j.durationMs}ms`:"—",Q=`# [${U4(j)}] ${j.method} ${j.url} (${J}, ${j.startedAt})`,z=j.responseSnippet?`
34
34
  # response: ${j.responseSnippet}`:"";return`${Q}
35
- ${g1(j)}${z}`}).join(`
35
+ ${p1(j)}${z}`}).join(`
36
36
 
37
- `)}function M4($){if($.length===0)return"No console output captured.";return $.map((j)=>`[${j.at}] ${j.level.toUpperCase()}: ${j.message}`).join(`
38
- `)}function U4($){if($.length===0)return"No user actions captured.";let j=0;return $.map((J)=>{let Q=J.source?` (${J.source})`:"",z=`${J.detail}${D0(J.count)}${Q}`;if(J.kind==="ui")return` ↳ [${J.at}] ${z}`;j+=1;let W=`${j}. [${J.at}] ${z}`;return J.afterNote?`${W}
37
+ `)}function C4($){if($.length===0)return"No console output captured.";return $.map((j)=>`[${j.at}] ${j.level.toUpperCase()}: ${j.message}`).join(`
38
+ `)}function I4($){if($.length===0)return"No user actions captured.";let j=0;return $.map((J)=>{let Q=J.source?` (${J.source})`:"",z=`${J.detail}${D0(J.count)}${Q}`;if(J.kind==="ui")return` ↳ [${J.at}] ${z}`;j+=1;let W=`${j}. [${J.at}] ${z}`;return J.afterNote?`${W}
39
39
  ↳ ${J.afterNote}`:W}).join(`
40
- `)}function C4($){let j=[];for(let J of $.failedRequests)j.push(`✗ ${J.status??J.error??"ERR"} ${J.method} ${J.url}`);for(let J of $.errors)j.push(`⚠ ${J}`);for(let J of $.erroredQueries)j.push(`⚠ React Query error: ${J.key} — ${J.error}`);return j}function P4($){let{context:j}=$;return[`User : ${j.user.fullName??"—"} (${j.user.email??"—"})`,`Unit : ${j.user.unit??"—"}`,`Roles : ${j.user.roles?.join(", ")||"—"}`,`Route : ${j.route.href}`,`Module : ${j.module?`${j.module.label} (${j.module.key})`:"—"}`,`App : ${j.app.name} v${j.app.version} · ${j.app.environment}`,`Memory : ${j.performance.memoryUsedMb??"—"}/${j.performance.memoryLimitMb??"—"} MB`,`Client : ${j.client.userAgent}`,`Viewport : ${j.client.viewport.width}×${j.client.viewport.height} @${j.client.viewport.dpr}x`,`Reason : ${Y4[$.reason.type]}${$.reason.message?` — ${$.reason.message}`:""}`,`Captured : ${$.network.length} requests · ${$.console.length} console · ${$.actionTrail.length} actions · screenshot=${$.screenshotMethod}`]}function I4($){let j=C4($.cause),J=[`## \uD83D\uDC1E ${$.context.app.name} — Debug Report`,`**Generated:** ${$.context.capturedAt}`,"",...P4($).map((Q)=>`- ${Q.replace(/\s{2,}:/,":")}`),"",`**หมายเหตุจากผู้แจ้ง:** ${$.note.trim()||"(ไม่มี)"}`];if(j.length>0)J.push("","### ⚠ สาเหตุที่น่าจะเป็น","```",...j,"```");return J.push("",`<details><summary>ขั้นตอน (${$.actionTrail.length})</summary>`,"","```",U4($.actionTrail),"```","</details>","",`<details><summary>Network (${$.network.length})</summary>`,"","```",H4($.network),"```","</details>","",`<details><summary>Console (${$.console.length})</summary>`,"","```",M4($.console),"```","</details>","","_ข้อมูลลับ (token, cookie) ถูกปกปิดอัตโนมัติ · ภาพหน้าจออยู่ในไฟล์ .zip_"),J.join(`
41
- `)}function w4($){return $.replace(/[:.]/g,"-").replace("T","_").slice(0,19)}function D4($,j){return`debug-report_${w4($.context.capturedAt)}.${j}`}function N4($){return E1($.cause)>0}async function E0(){if(typeof navigator<"u"&&Boolean(navigator.mediaDevices?.getDisplayMedia)){let J=await B4();if(J.status==="ok")return{dataUrl:J.dataUrl,method:"display-media"};if(J.status==="cancelled")return{dataUrl:null,method:"cancelled"}}let j=await R4();if(j)return{dataUrl:j,method:"html-to-image"};return{dataUrl:null,method:"none"}}async function B4(){let $=null;try{let j={video:{frameRate:30},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude"};$=await navigator.mediaDevices.getDisplayMedia(j);let J=await q4($);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 q4($){let j=document.createElement("video");j.srcObject=$,j.muted=!0,j.playsInline=!0,await new Promise((K)=>{let G=!1,H=()=>{if(G)return;G=!0,K()};j.onloadedmetadata=()=>{j.play().then(H).catch(H)},window.setTimeout(H,1500)}),await S4(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 S4($){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 R4(){let $=R().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 O4=2000,_4=0.82,L4=3000000;function A4($){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 p1($){try{let j=await A4($),J=Math.max(j.naturalWidth,j.naturalHeight),Q=Math.min(1,O4/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=_4,G=z.toDataURL("image/jpeg",K);while(G.length>L4&&K>0.4)K-=0.15,G=z.toDataURL("image/jpeg",K);return G}catch{return $}}var T4=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,k4=/^\d+$/,f4=/^[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)=>T4.test(W)||k4.test(W)||f4.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 g0($,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 m1=32768;function E4($){let j="";for(let J=0;J<$.length;J+=m1)j+=String.fromCharCode(...$.subarray(J,J+m1));return btoa(j)}function x4($){return{dataUri:`data:application/json;base64,${E4(new TextEncoder().encode(JSON.stringify($)))}`,filename:"debug-bundle.json"}}async function h4(){let $=R().identity;if(!$)return{};try{let j=await $();return j?{authorization:`Bearer ${j}`}:{}}catch{return{}}}async function p0($,j){let J=R(),Q=g0(j,h0),{context:z,note:W}=Q,K=[];if(Q.screenshotDataUrl){let C=await p1(Q.screenshotDataUrl);K.push({dataUri:C,filename:"screenshot.jpg"})}K.push(x4(Q));let G=x0(Q),H={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 h4()},body:JSON.stringify(H)});if(!U.ok){let C=U.headers.get("retry-after"),w=await U.json().then((P)=>P.error).catch(()=>null);throw Error(U.status===429?`Too many reports — try again in ${C??"a moment"}s`:w??`Report failed (${U.status})`)}return await U.json()}var Q0=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-Q0),y:j.y-J*Math.sin(K-Q0)},{x:j.x-J*Math.cos(K+Q0),y:j.y-J*Math.sin(K+Q0)}],H=J*Math.cos(Q0)*0.92;if(W<=H)return{shaft:null,head:G};return{shaft:{from:$,to:{x:j.x-H*Math.cos(K),y:j.y-H*Math.sin(K)}},head:G}}var m0="#f44336",g4="rgba(250, 204, 21, 0.4)",v0=22,y1="#2563eb",b1=9,u1=11,d1=18,c1=4,Y0=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 y0($,j,J){let Q=[],z=null,W=-1,K=null,G=null,H=$.getContext("2d");function U(){let Z=$.getBoundingClientRect().width;return Z>0?$.width/Z:1}function C(Z){let V=$.getBoundingClientRect();return{x:(Z.clientX-V.left)/V.width*$.width,y:(Z.clientY-V.top)/V.height*$.height}}function w(Z){let V=Z.size??v0;if(!H)return(Z.text?.length??0)*V*0.6;H.save(),H.font=`600 ${V}px system-ui, sans-serif`;let Y=H.measureText(Z.text??"").width;return H.restore(),Y}function P(Z){if(Z.tool==="text"){let V=Z.size??v0;return{left:Z.x1,top:Z.y1,right:Z.x1+w(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=P(Z);if(Z.tool==="text")return[{id:"size",x:V.right,y:V.bottom,cursor:"nwse-resize"}];return p4.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=P(Z);return{x:V.right+d1*U(),y:V.top-d1*U()}}function S(Z,V,Y){let{shaft:X,head:F}=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(F[0].x,F[0].y),Z.lineTo(F[1].x,F[1].y),Z.lineTo(F[2].x,F[2].y),Z.closePath(),Z.fill()}function _(Z,V,Y){Z.save(),Z.lineWidth=Math.max(2,3*Y),Z.strokeStyle=m0,Z.fillStyle=m0;let X=P(V);if(V.tool==="rect")Z.strokeRect(X.left,X.top,X.right-X.left,X.bottom-X.top);else if(V.tool==="arrow")S(Z,V,Y);else if(V.tool==="highlight")Z.fillStyle=g4,Z.fillRect(X.left,X.top,X.right-X.left,X.bottom-X.top);else if(V.tool==="text"&&V.text){let F=V.size??v0;Z.font=`600 ${F}px system-ui, sans-serif`,Z.textBaseline="top";let M=F*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=m0,Z.fillText(V.text,X.left,X.top)}Z.restore()}function D(Z,V,Y){let X=P(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 F=b1*Y;for(let T of O(V))Z.fillStyle="#fff",Z.strokeStyle=y1,Z.lineWidth=Math.max(1,1.5*Y),Z.beginPath(),Z.rect(T.x-F/2,T.y-F/2,F,F),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 q(){if(!H)return;let Z=U();if(H.clearRect(0,0,$.width,$.height),H.drawImage(j,0,0,$.width,$.height),Q.forEach((Y,X)=>{if(X!==m)_(H,Y,Z)}),K)_(H,K,Z);let V=Q[W];if(V&&!K)D(H,V,Z)}function g(Z,V,Y,X,F){return Math.abs(Z-Y)<=F&&Math.abs(V-X)<=F}function e(Z,V){let Y=Q[W];if(!Y)return null;let X=b1*U()/2+3*U();for(let F of O(Y))if(g(Z,V,F.x,F.y,X))return F.id;return null}function u(Z,V){let Y=Q[W];if(!Y)return!1;let X=N(Y);return g(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 F=Q[X];if(F.tool==="arrow"){let I=F.x2-F.x1,T=F.y2-F.y1,v=Math.hypot(I,T)||1,y=Math.max(0,Math.min(1,((Z-F.x1)*I+(V-F.y1)*T)/(v*v)));if(Math.hypot(Z-(F.x1+y*I),V-(F.y1+y*T))<=Y+4*U())return X;continue}let M=P(F);if(Z>=M.left-Y&&Z<=M.right+Y&&V>=M.top-Y&&V<=M.bottom+Y)return X}return-1}function p(Z,V,Y,X,F){if(V==="tail"){Z.x1=Y.x1+X,Z.y1=Y.y1+F;return}if(V==="head"){Z.x2=Y.x2+X,Z.y2=Y.y2+F;return}if(V==="size"){let j2=(Y.size??24)+F;Z.size=Math.max(10,j2);return}let M=P(Y),{left:I,top:T,right:v,bottom:y}=M;if(V.includes("w"))I=Math.min(v-Y0,I+X);if(V.includes("e"))v=Math.max(I+Y0,v+X);if(V.includes("n"))T=Math.min(y-Y0,T+F);if(V.includes("s"))y=Math.max(T+Y0,y+F);Z.x1=I,Z.y1=T,Z.x2=v,Z.y2=y}function H0(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,m=-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(!H)return Z.length*V*0.6;H.save(),H.font=`600 ${V}px system-ui, sans-serif`;let Y=H.measureText(Z||" ").width;return H.restore(),Y}function c0(){if(!L)return;let Z=$.parentElement;if(!Z)return;let V=$.getBoundingClientRect(),Y=Z.getBoundingClientRect(),X=f(),F=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=`${F}px`,L.style.width=`${Math.max(40,$2(L.value,F)+F)}px`}function $0(Z){let V=L;if(!V)return;L=null;let Y=V.value.trim(),X=m;if(m=-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(),q()}function i0(Z,V,Y=-1){$0(!0);let X=$.parentElement;if(!X)return;if(getComputedStyle(X).position==="static")X.style.position="relative";let F=Y>=0?Q[Y]:void 0;m=Y,B={x:F?.x1??Z,y:F?.y1??V,size:F?.size??Math.round(24*U())};let M=document.createElement("input");M.type="text",M.className="text-edit",M.value=F?.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))}),q()}function o0(Z){let{x:V,y:Y}=C(Z);if($.setPointerCapture(Z.pointerId),u(V,Y)){M0();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 F=E(V,Y);W=F,G=F>=0?{grip:"body",x:V,y:Y,start:{...Q[F]}}:null,q()}function l0(Z){let{x:V,y:Y}=C(Z);if(K){K.x2=V,K.y2=Y,q();return}if(G){let F=Q[W];if(!F)return;let M=V-G.x,I=Y-G.y;if(G.grip==="body")H0(F,G.start,M,I);else p(F,G.grip,G.start,M,I);q();return}if(z){$.style.cursor="crosshair";return}if(u(V,Y)){$.style.cursor="pointer";return}let X=e(V,Y);if(X){let F=Q[W]?O(Q[W]).find((M)=>M.id===X):null;$.style.cursor=F?.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();q()}function r0(Z){let V=$.getBoundingClientRect(),Y=(Z.clientX-V.left)/V.width*$.width,X=(Z.clientY-V.top)/V.height*$.height,F=E(Y,X),M=Q[F];if(!M||M.tool!=="text")return;Z.preventDefault(),i0(M.x1,M.y1,F)}function s0(Z){if(W<0)return;if(Z.key==="Delete"||Z.key==="Backspace")Z.preventDefault(),M0();else if(Z.key==="Escape")W=-1,q()}function M0(){if(W<0)return;Q.splice(W,1),W=-1,J(),q()}return $.addEventListener("pointerdown",o0),$.addEventListener("pointermove",l0),$.addEventListener("pointerup",z0),$.addEventListener("pointercancel",z0),$.addEventListener("dblclick",r0),$.tabIndex=0,$.addEventListener("keydown",s0),q(),{setTool(Z){z=Z,W=-1,$.style.cursor=Z?"crosshair":"default",q()},deleteSelected:M0,clear(){Q.length=0,W=-1,J(),q()},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=`
40
+ `)}function w4($){let j=[];for(let J of $.failedRequests)j.push(`✗ ${J.status??J.error??"ERR"} ${J.method} ${J.url}`);for(let J of $.errors)j.push(`⚠ ${J}`);for(let J of $.erroredQueries)j.push(`⚠ React Query error: ${J.key} — ${J.error}`);return j}function D4($){let{context:j}=$;return[`User : ${j.user.fullName??"—"} (${j.user.email??"—"})`,`Unit : ${j.user.unit??"—"}`,`Roles : ${j.user.roles?.join(", ")||"—"}`,`Route : ${j.route.href}`,`Module : ${j.module?`${j.module.label} (${j.module.key})`:"—"}`,`App : ${j.app.name} v${j.app.version} · ${j.app.environment}`,`Memory : ${j.performance.memoryUsedMb??"—"}/${j.performance.memoryLimitMb??"—"} MB`,`Client : ${j.client.userAgent}`,`Viewport : ${j.client.viewport.width}×${j.client.viewport.height} @${j.client.viewport.dpr}x`,`Reason : ${M4[$.reason.type]}${$.reason.message?` — ${$.reason.message}`:""}`,`Captured : ${$.network.length} requests · ${$.console.length} console · ${$.actionTrail.length} actions · screenshot=${$.screenshotMethod}`]}function N4($){let j=w4($.cause),J=[`## \uD83D\uDC1E ${$.context.app.name} — Debug Report`,`**Generated:** ${$.context.capturedAt}`,"",...D4($).map((Q)=>`- ${Q.replace(/\s{2,}:/,":")}`),"",`**หมายเหตุจากผู้แจ้ง:** ${$.note.trim()||"(ไม่มี)"}`];if(j.length>0)J.push("","### ⚠ สาเหตุที่น่าจะเป็น","```",...j,"```");return J.push("",`<details><summary>ขั้นตอน (${$.actionTrail.length})</summary>`,"","```",I4($.actionTrail),"```","</details>","",`<details><summary>Network (${$.network.length})</summary>`,"","```",P4($.network),"```","</details>","",`<details><summary>Console (${$.console.length})</summary>`,"","```",C4($.console),"```","</details>","","_ข้อมูลลับ (token, cookie) ถูกปกปิดอัตโนมัติ · ภาพหน้าจออยู่ในไฟล์ .zip_"),J.join(`
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=`
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",o1=()=>[];function m4($){o1=$}var v4=[{tool:"rect",key:"toolRect"},{tool:"arrow",key:"toolArrow"},{tool:"highlight",key:"toolHighlight"},{tool:"text",key:"toolText"}];function y4(){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=R0((j)=>void this.open(j))}disconnectedCallback(){this.stop?.(),this.stop=null,this.close()}async open(j){if(this.busy)return;this.busy=!0;let J=b(R().locale),Q=await E0();if(Q.method==="cancelled"){this.close();return}this.bundle=f0({reason:j,note:"",screenshotDataUrl:Q.dataUrl,screenshotMethod:Q.method,erroredQueries:b4()}),this.renderForm(J)}close(){this.annotator?.destroy(),this.annotator=null,this.bundle=null,this.busy=!1,this.root.replaceChildren()}shell(j){let J=document.createElement("style");J.textContent=i1;let Q=document.createElement("div");Q.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),Q.append(z),this.root.replaceChildren(J,Q),z}renderShell(j,J){let Q=this.shell(j),z=A("div","head");z.append(A("h2","",j.title)),Q.append(z,A("p","status",J))}renderForm(j){let J=this.bundle;if(!J)return;let Q=this.shell(j),z=A("div","head"),W=a("✕","icon");W.setAttribute("aria-label",j.close),W.addEventListener("click",()=>this.close()),z.append(A("h2","",j.title),W);let K=document.createElement("input");K.type="text",K.placeholder=j.summaryPlaceholder;let G=b0(j.summaryLabel,j.summaryRequired,!0),H=document.createElement("textarea");H.placeholder=j.detailPlaceholder;let U=A("div","meta");U.innerHTML="";let{context:C}=J;for(let[S,_]of[[j.reporter,`${C.user.fullName??"—"} (${C.user.email??"—"})`],[j.page,C.route.href],[j.captured,`${J.network.length} network · ${J.console.length} console · ${J.actionTrail.length} actions`]]){let D=document.createElement("div"),q=document.createElement("b");q.textContent=`${S}: `,D.append(q,document.createTextNode(_)),U.append(D)}let w=A("p","status",""),P=a(j.submit,"primary");if(P.disabled=!0,K.addEventListener("input",()=>{P.disabled=K.value.trim().length===0}),Q.append(z,G,K,b0(j.detailLabel),H,U),J.screenshotDataUrl)Q.append(...this.screenshotSection(j,J.screenshotDataUrl));else Q.append(A("p","status",j.noScreenshot));let O=A("div","foot"),N=a(j.close);N.addEventListener("click",()=>this.close()),O.append(N,w,A("span","grow"),P),Q.append(O),P.addEventListener("click",async()=>{P.disabled=!0,w.dataset.tone="",w.textContent=j.submitting;try{let S=await p0(K.value.trim(),{...J,note:H.value,screenshotDataUrl:this.annotator?.hasShapes()?this.annotator.toDataUrl():J.screenshotDataUrl}),_=this.dispatchEvent(new CustomEvent("lw-report-submitted",{detail:S,bubbles:!0,composed:!0,cancelable:!0}));if(this.close(),_)n(`${j.submitted} — #${S.number}`,"success")}catch(S){let _=S instanceof Error?S.message:j.failed;w.dataset.tone="error",w.textContent=_,n(`${j.failed} — ${_}`,"error"),P.disabled=!1}}),K.focus()}screenshotSection(j,J){let Q=b0(j.annotateHint),z=A("div","tools"),W=document.createElement("canvas"),K=A("div","shot");K.append(W);let G=[],H=(P)=>{for(let O of G)O.setAttribute("aria-pressed",String(O===P))};for(let{tool:P,key:O}of v4){let N=a(j[O]);N.setAttribute("aria-pressed","false"),N.addEventListener("click",()=>{let S=N.getAttribute("aria-pressed")==="true";H(S?null:N),this.annotator?.setTool(S?null:P)}),G.push(N),z.append(N)}z.append(A("span","sep"));let U=a(j.deleteSelected);U.addEventListener("click",()=>this.annotator?.deleteSelected());let C=a(j.clearAll);C.addEventListener("click",()=>{this.annotator?.clear(),H(null)}),z.append(U,C);let w=new Image;return w.onload=()=>{W.width=w.naturalWidth,W.height=w.naturalHeight,this.annotator=y0(W,w,()=>{H(null),U.disabled=!this.annotator?.hasSelection()})},w.src=J,[Q,z,A("p","status",j.annotateHelp),K]}}}function b4(){try{return o1()}catch{return[]}}function A($,j="",J=""){let Q=document.createElement($);if(j)Q.className=j;if(J)Q.textContent=J;return Q}function a($,j=""){let J=document.createElement("button");if(J.type="button",J.textContent=$,j)J.className=j;return J}function b0($,j="",J=!1){let Q=document.createElement("label");if(Q.append(document.createTextNode($)),J){let z=document.createElement("span");z.className="req",z.textContent=" *",Q.append(z)}if(j){let z=document.createElement("span");z.className="hint",z.textContent=` ${j}`,Q.append(z)}return Q}function u0(){if(typeof window>"u"||customElements.get(t))return;customElements.define(t,y4())}var l1=!1;function u4($={}){if(l1||typeof window>"u")return;if(!U0()){console.error("[debug-capture] configureDebugCapture() must be called before install");return}if(l1=!0,k1(),M1(),X1(),B1(),$.ui===!1)return;let j=b(R().locale);if(_0((J)=>{n(J.message??j.crashed,"error",{label:j.crashAction,onClick:()=>O0(J)})}),u0(),!document.querySelector(t))document.body.append(document.createElement(t))}var d4=new Set(["error","exception","unhandledrejection"]);function r1($){if($.error)return!0;return $.status!==null&&$.status>=400}function d0($){if(!$)return null;let j=Date.parse($);return Number.isNaN(j)?null:j}function c4($){try{let{pathname:j}=new URL($,"http://x");try{return decodeURIComponent(j)}catch{return j}}catch{return $.split(/[?#]/)[0]??$}}function i4($,j,J){let Q=(K)=>({elapsedMs:K,requests:[],failedRequests:[],consoleErrors:[],slowestMs:null});if($.length===0)return[];let z=$.map((K)=>d0(K.at)),W=(K)=>{for(let G=K+1;G<z.length;G+=1){let H=z[G];if(H!=null)return H}return Number.POSITIVE_INFINITY};return $.map((K,G)=>{let H=z[G]??null,U=(G>0?z[G-1]:null)??null,C=H!==null&&U!==null?Math.max(0,H-U):null;if(H===null)return Q(C);let w=H,P=Math.max(w,W(G)),O=(D)=>D!==null&&D>=w&&(D<P||P===Number.POSITIVE_INFINITY),N=j.filter((D)=>O(d0(D.startedAt))),S=J.filter((D)=>d4.has(D.level)&&O(d0(D.at))),_=N.map((D)=>D.durationMs).filter((D)=>typeof D==="number");return{elapsedMs:C,requests:N,failedRequests:N.filter(r1),consoleErrors:S,slowestMs:_.length>0?Math.max(..._):null}})}function o4($,j){return $.requests.length===0&&$.consoleErrors.length===0&&($.elapsedMs===null||$.elapsedMs<j)}function l4($){if($<1000)return`${Math.round($)} มิลลิวินาที`;let j=$/1000;if(j<10)return`${j.toFixed(1)} วิ`;if(j<60)return`${Math.round(j)} วิ`;let J=Math.floor(j/60),Q=Math.round(j%60);return Q===0?`${J} นาที`:`${J} นาที ${Q} วิ`}var r4="lw-portal-handoff",s1=138.23,s4=`
124
+ `;var t="lw-debug-reporter",o1=()=>[];function b4($){o1=$}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=R0((j)=>void this.open(j))}disconnectedCallback(){this.stop?.(),this.stop=null,this.close()}async open(j){if(this.busy)return;this.busy=!0;let J=b(q().locale),Q=await E0();if(Q.method==="cancelled"){this.close();return}this.bundle=f0({reason:j,note:"",screenshotDataUrl:Q.dataUrl,screenshotMethod:Q.method,erroredQueries:c4()}),this.renderForm(J)}close(){this.annotator?.destroy(),this.annotator=null,this.bundle=null,this.busy=!1,this.root.replaceChildren()}shell(j){let J=document.createElement("style");J.textContent=i1;let Q=document.createElement("div");Q.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),Q.append(z),this.root.replaceChildren(J,Q),z}renderShell(j,J){let Q=this.shell(j),z=A("div","head");z.append(A("h2","",j.title)),Q.append(z,A("p","status",J))}renderForm(j){let J=this.bundle;if(!J)return;let Q=this.shell(j),z=A("div","head"),W=a("✕","icon");W.setAttribute("aria-label",j.close),W.addEventListener("click",()=>this.close()),z.append(A("h2","",j.title),W);let K=document.createElement("input");K.type="text",K.placeholder=j.summaryPlaceholder;let G=b0(j.summaryLabel,j.summaryRequired,!0),F=document.createElement("textarea");F.placeholder=j.detailPlaceholder;let U=A("div","meta");U.innerHTML="";let{context:w}=J;for(let[R,_]of[[j.reporter,`${w.user.fullName??"—"} (${w.user.email??"—"})`],[j.page,w.route.href],[j.captured,`${J.network.length} network · ${J.console.length} console · ${J.actionTrail.length} actions`]]){let D=document.createElement("div"),S=document.createElement("b");S.textContent=`${R}: `,D.append(S,document.createTextNode(_)),U.append(D)}let P=A("p","status",""),C=a(j.submit,"primary");if(C.disabled=!0,K.addEventListener("input",()=>{C.disabled=K.value.trim().length===0}),Q.append(z,G,K,b0(j.detailLabel),F,U),J.screenshotDataUrl)Q.append(...this.screenshotSection(j,J.screenshotDataUrl));else Q.append(A("p","status",j.noScreenshot));let O=A("div","foot"),N=a(j.close);N.addEventListener("click",()=>this.close()),O.append(N,P,A("span","grow"),C),Q.append(O),C.addEventListener("click",async()=>{C.disabled=!0,P.dataset.tone="",P.textContent=j.submitting;try{let R=await m0(K.value.trim(),{...J,note:F.value,screenshotDataUrl:this.annotator?.hasShapes()?this.annotator.toDataUrl():J.screenshotDataUrl}),_=this.dispatchEvent(new CustomEvent("lw-report-submitted",{detail:R,bubbles:!0,composed:!0,cancelable:!0}));if(this.close(),_)n(`${j.submitted} — #${R.number}`,"success")}catch(R){let _=R instanceof Error?R.message:j.failed;P.dataset.tone="error",P.textContent=_,n(`${j.failed} — ${_}`,"error"),C.disabled=!1}}),K.focus()}screenshotSection(j,J){let Q=b0(j.annotateHint),z=A("div","tools"),W=document.createElement("canvas"),K=A("div","shot");K.append(W);let G=[],F=(C)=>{for(let O of G)O.setAttribute("aria-pressed",String(O===C))};for(let{tool:C,key:O}of u4){let N=a(j[O]);N.setAttribute("aria-pressed","false"),N.addEventListener("click",()=>{let R=N.getAttribute("aria-pressed")==="true";F(R?null:N),this.annotator?.setTool(R?null:C)}),G.push(N),z.append(N)}z.append(A("span","sep"));let U=a(j.deleteSelected);U.addEventListener("click",()=>this.annotator?.deleteSelected());let w=a(j.clearAll);w.addEventListener("click",()=>{this.annotator?.clear(),F(null)}),z.append(U,w);let P=new Image;return P.onload=()=>{W.width=P.naturalWidth,W.height=P.naturalHeight,this.annotator=y0(W,P,()=>{F(null),U.disabled=!this.annotator?.hasSelection()})},P.src=J,[Q,z,A("p","status",j.annotateHelp),K]}}}function c4(){try{return o1()}catch{return[]}}function A($,j="",J=""){let Q=document.createElement($);if(j)Q.className=j;if(J)Q.textContent=J;return Q}function a($,j=""){let J=document.createElement("button");if(J.type="button",J.textContent=$,j)J.className=j;return J}function b0($,j="",J=!1){let Q=document.createElement("label");if(Q.append(document.createTextNode($)),J){let z=document.createElement("span");z.className="req",z.textContent=" *",Q.append(z)}if(j){let z=document.createElement("span");z.className="hint",z.textContent=` ${j}`,Q.append(z)}return Q}function u0(){if(typeof window>"u"||customElements.get(t))return;customElements.define(t,d4())}var l1=!1;function i4($={}){if(l1||typeof window>"u")return;if(!j0()){console.error("[debug-capture] configureDebugCapture() must be called before install");return}if(l1=!0,T1(),M1(),X1(),B1(),$.ui===!1)return;let j=b(q().locale);if(_0((J)=>{n(J.message??j.crashed,"error",{label:j.crashAction,onClick:()=>O0(J)})}),u0(),!document.querySelector(t))document.body.append(document.createElement(t))}var o4=new Set(["error","exception","unhandledrejection"]);function r1($){if($.error)return!0;return $.status!==null&&$.status>=400}function d0($){if(!$)return null;let j=Date.parse($);return Number.isNaN(j)?null:j}function l4($){try{let{pathname:j}=new URL($,"http://x");try{return decodeURIComponent(j)}catch{return j}}catch{return $.split(/[?#]/)[0]??$}}function r4($,j,J){let Q=(K)=>({elapsedMs:K,requests:[],failedRequests:[],consoleErrors:[],slowestMs:null});if($.length===0)return[];let z=$.map((K)=>d0(K.at)),W=(K)=>{for(let G=K+1;G<z.length;G+=1){let F=z[G];if(F!=null)return F}return Number.POSITIVE_INFINITY};return $.map((K,G)=>{let F=z[G]??null,U=(G>0?z[G-1]:null)??null,w=F!==null&&U!==null?Math.max(0,F-U):null;if(F===null)return Q(w);let P=F,C=Math.max(P,W(G)),O=(D)=>D!==null&&D>=P&&(D<C||C===Number.POSITIVE_INFINITY),N=j.filter((D)=>O(d0(D.startedAt))),R=J.filter((D)=>o4.has(D.level)&&O(d0(D.at))),_=N.map((D)=>D.durationMs).filter((D)=>typeof D==="number");return{elapsedMs:w,requests:N,failedRequests:N.filter(r1),consoleErrors:R,slowestMs:_.length>0?Math.max(..._):null}})}function s4($,j){return $.requests.length===0&&$.consoleErrors.length===0&&($.elapsedMs===null||$.elapsedMs<j)}function n4($){if($<1000)return`${Math.round($)} มิลลิวินาที`;let j=$/1000;if(j<10)return`${j.toFixed(1)} วิ`;if(j<60)return`${Math.round(j)} วิ`;let J=Math.floor(j/60),Q=Math.round(j%60);return Q===0?`${J} นาที`:`${J} นาที ${Q} วิ`}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($){if(typeof document>"u")return $.prepare().then((D)=>void $.go(D),()=>{return});let j=b(R().locale),J=Math.max(1,Math.floor($.seconds??3)),Q=document.createElement(r4),z=Q.attachShadow({mode:"open"}),W=document.createElement("style");W.textContent=s4,z.append(W);let K=document.createElement("div");K.className="backdrop",K.innerHTML=`
201
+ `;function n1($){if(typeof document>"u")return $.prepare().then((D)=>void $.go(D),()=>{return});let j=b(q().locale),J=Math.max(1,Math.floor($.seconds??3)),Q=document.createElement(a4),z=Q.attachShadow({mode:"open"}),W=document.createElement("style");W.textContent=t4,z.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>`,z.append(K);let G=(D)=>K.querySelector(D),H=G(".card"),U=G(".bar"),C=G(".count"),w=G("h2"),P=G(".body"),O=G(".host"),N=G(".go"),S=G(".cancel");w.textContent=j.handoffTitle,P.textContent=j.handoffBody;try{O.textContent=new URL(R().host).host}catch{O.textContent=""}N.textContent=j.handoffGo,S.textContent=j.cancel,H.style.setProperty("--secs",`${J}s`),C.textContent=String(J),document.body.append(Q),requestAnimationFrame(()=>K.setAttribute("data-open","1"));let _=document.activeElement;return N.focus({preventScroll:!0}),new Promise((D)=>{let q=!1,g=null,e=!1,u=Date.now()+J*1000,E=window.setInterval(()=>{let B=Math.ceil((u-Date.now())/1000);if(C.textContent=String(Math.max(0,B)),Date.now()>=u)L()},100);function p(B){if(q)return;if(q=!0,window.clearInterval(E),document.removeEventListener("keydown",m,!0),K.removeAttribute("data-open"),window.setTimeout(()=>Q.remove(),200),!B)_?.focus?.({preventScroll:!0});D()}function H0(B){window.clearInterval(E),U.classList.remove("spinner"),U.style.animation="none",C.textContent="",w.textContent=j.handoffBlocked,P.textContent=j.handoffBody;let f=document.createElement("a");f.className="go",f.href=B,f.target="_blank",f.rel="noopener noreferrer",f.textContent=j.handoffOpen,f.addEventListener("click",()=>p(!0)),N.replaceWith(f),f.focus({preventScroll:!0})}function L(){if(q||e)return;if(g)return $.go(g)?p(!0):H0(g);window.clearInterval(E),C.textContent="",U.classList.add("spinner"),w.textContent=j.handoffPreparing}function m(B){if(B.key==="Escape")B.stopPropagation(),p(!1)}document.addEventListener("keydown",m,!0),N.addEventListener("click",L),S.addEventListener("click",()=>p(!1)),K.addEventListener("click",(B)=>{if(B.target===K)p(!1)}),$.prepare().then((B)=>{if(g=B,!q&&Date.now()>=u)L()},()=>{e=!0,window.clearInterval(E),H.classList.add("error"),U.classList.remove("spinner"),U.style.animation="none",C.textContent="",w.textContent=j.handoffFailed,P.textContent=j.handoffBody,N.remove(),S.textContent=j.close})})}var n4="/sso";function e1($,j,J){let Q=new URL(n4,$.endsWith("/")?$:`${$}/`);return Q.searchParams.set("realm",j),Q.searchParams.set("token",J),Q.toString()}class F0 extends Error{constructor($="No identity provider is configured, or nobody is signed in"){super($);this.name="NoIdentityError"}}async function a1(){let $=R();if(!$.identity)throw new F0;let j=await $.identity();if(!j)throw new F0;return e1($.host,$.realmKey,j)}function t1($,j){if(j==="_self")return window.location.assign($),!0;let J=window.open($,"_blank");if(!J)return!1;try{J.opener=null}catch{}return!0}async function a4($={}){if($.announce===!1){t1(await a1(),$.target);return}await n1({seconds:$.seconds,prepare:a1,go:(j)=>t1(j,$.target)})}export{g0 as trimToBudget,g1 as toCurl,e1 as supportPortalUrl,p0 as submitBundle,n as showToast,m4 as setErroredQueriesSource,c4 as requestPath,b as reporterStrings,o as redactUrl,c as redactLabel,i as redactHeaders,l as redactBody,a4 as openSupportPortal,R0 as onLaunch,_0 as onCrash,W2 as moduleResolver,O0 as launch,o4 as isQuietStep,r1 as isFailedRequest,U0 as isConfigured,u4 as installDebugCapture,N4 as hasCause,A0 as getNetworkLog,S0 as getConsoleLog,R as getConfig,B0 as getActionTrail,l4 as formatDuration,x0 as errorSignature,L0 as emitCrash,u0 as defineReporterElement,y0 as createAnnotator,i4 as correlateActionTrail,Q2 as configureDebugCapture,E0 as captureScreen,I4 as bundleToMarkdown,D4 as bundleFileName,f0 as buildBundle,x as appInfo,D0 as actionCountSuffix,t as REPORTER_TAG,d as REDACTED,F0 as NoIdentityError,h0 as BUNDLE_BUDGET_BYTES};
217
+ </div>`,z.append(K);let G=(D)=>K.querySelector(D),F=G(".card"),U=G(".bar"),w=G(".count"),P=G("h2"),C=G(".body"),O=G(".host"),N=G(".go"),R=G(".cancel");P.textContent=j.handoffTitle,C.textContent=j.handoffBody;try{O.textContent=new URL(q().host).host}catch{O.textContent=""}N.textContent=j.handoffGo,R.textContent=j.cancel,F.style.setProperty("--secs",`${J}s`),w.textContent=String(J),document.body.append(Q),requestAnimationFrame(()=>K.setAttribute("data-open","1"));let _=document.activeElement;return N.focus({preventScroll:!0}),new Promise((D)=>{let S=!1,p=null,e=!1,u=Date.now()+J*1000,E=window.setInterval(()=>{let B=Math.ceil((u-Date.now())/1000);if(w.textContent=String(Math.max(0,B)),Date.now()>=u)L()},100);function m(B){if(S)return;if(S=!0,window.clearInterval(E),document.removeEventListener("keydown",g,!0),K.removeAttribute("data-open"),window.setTimeout(()=>Q.remove(),200),!B)_?.focus?.({preventScroll:!0});D()}function M0(B){window.clearInterval(E),U.classList.remove("spinner"),U.style.animation="none",w.textContent="",P.textContent=j.handoffBlocked,C.textContent=j.handoffBody;let f=document.createElement("a");f.className="go",f.href=B,f.target="_blank",f.rel="noopener noreferrer",f.textContent=j.handoffOpen,f.addEventListener("click",()=>m(!0)),N.replaceWith(f),f.focus({preventScroll:!0})}function L(){if(S||e)return;if(p)return $.go(p)?m(!0):M0(p);window.clearInterval(E),w.textContent="",U.classList.add("spinner"),P.textContent=j.handoffPreparing}function g(B){if(B.key==="Escape")B.stopPropagation(),m(!1)}document.addEventListener("keydown",g,!0),N.addEventListener("click",L),R.addEventListener("click",()=>m(!1)),K.addEventListener("click",(B)=>{if(B.target===K)m(!1)}),$.prepare().then((B)=>{if(p=B,!S&&Date.now()>=u)L()},()=>{e=!0,window.clearInterval(E),F.classList.add("error"),U.classList.remove("spinner"),U.style.animation="none",w.textContent="",P.textContent=j.handoffFailed,C.textContent=j.handoffBody,N.remove(),R.textContent=j.close})})}var e4="/sso";function e1($,j,J){let Q=new URL(e4,$.endsWith("/")?$:`${$}/`);return Q.searchParams.set("realm",j),Q.searchParams.set("token",J),Q.toString()}class H0 extends Error{constructor($="No identity provider is configured, or nobody is signed in"){super($);this.name="NoIdentityError"}}async function a1(){let $=q();if(!$.identity)throw new H0;let j=await $.identity();if(!j)throw new H0;return e1($.host,$.realmKey,j)}function t1($,j){if(j==="_self")return window.location.assign($),!0;let J=window.open($,"_blank");if(!J)return!1;try{J.opener=null}catch{}return!0}async function $5($={}){if($.announce===!1){t1(await a1(),$.target);return}await n1({seconds:$.seconds,prepare:a1,go:(j)=>t1(j,$.target)})}export{p0 as trimToBudget,p1 as toCurl,e1 as supportPortalUrl,m0 as submitBundle,n as showToast,b4 as setErroredQueriesSource,l4 as requestPath,b as reporterStrings,o as redactUrl,c as redactLabel,i as redactHeaders,l as redactBody,$5 as openSupportPortal,R0 as onLaunch,_0 as onCrash,W2 as moduleResolver,O0 as launch,s4 as isQuietStep,r1 as isFailedRequest,j0 as isConfigured,i4 as installDebugCapture,S4 as hasCause,A0 as getNetworkLog,S0 as getConsoleLog,q as getConfig,B0 as getActionTrail,n4 as formatDuration,x0 as errorSignature,L0 as emitCrash,u0 as defineReporterElement,y0 as createAnnotator,r4 as correlateActionTrail,Q2 as configureDebugCapture,E0 as captureScreen,N4 as bundleToMarkdown,q4 as bundleFileName,f0 as buildBundle,x as appInfo,D0 as actionCountSuffix,t as REPORTER_TAG,d as REDACTED,H0 as NoIdentityError,h0 as BUNDLE_BUDGET_BYTES};
package/dist/submit.d.ts CHANGED
@@ -5,4 +5,19 @@ export interface FiledTicket {
5
5
  status: string;
6
6
  }
7
7
  export declare function toBase64(bytes: Uint8Array): string;
8
+ /**
9
+ * A data URI for the JSON bundle, so the bulk lands in object storage.
10
+ *
11
+ * The screenshot is dropped first, and that is not an optimisation. It travels
12
+ * as its own compressed attachment; leaving it in here embedded the raw
13
+ * full-resolution data URL a second time and then base64'd the lot again, so a
14
+ * report from a 4K display arrived over the server's 5 MB per-file cap and
15
+ * failed — every time, with nothing the reporter could do about it. The size
16
+ * budget already excludes it from its own measurement for exactly this reason
17
+ * (`budget.ts`), which is what made the duplication invisible.
18
+ */
19
+ export declare function bundleAttachment(bundle: DebugBundle): {
20
+ dataUri: string;
21
+ filename: string;
22
+ };
8
23
  export declare function submitBundle(title: string, bundle: DebugBundle): Promise<FiledTicket>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightworkai.official/debug-capture",
3
- "version": "0.10.1",
3
+ "version": "0.11.0",
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",
package/src/config.ts CHANGED
@@ -127,6 +127,39 @@ export interface DebugCaptureConfig {
127
127
 
128
128
  /** UI language. Only affects the built-in reporter's own strings. */
129
129
  locale?: "th" | "en";
130
+
131
+ /**
132
+ * Where this library's own notifications go.
133
+ *
134
+ * Three things get announced outside the reporter dialog: a report was filed,
135
+ * a report failed to file, and a crash was caught (that one carries a button
136
+ * that opens the reporter). They land on top of the host's application, so in
137
+ * an app with its own toaster they are the one message in a different corner,
138
+ * with a different animation — which reads as coming from somewhere other than
139
+ * the app the person is using.
140
+ *
141
+ * Set this and every one of them is yours instead:
142
+ *
143
+ * toast: (n) => n.action
144
+ * ? toast[n.tone](n.message, { action: { label: n.action.label, onClick: n.action.onClick } })
145
+ * : toast[n.tone](n.message)
146
+ *
147
+ * Left unset, the built-in toast is used — a package that assumed sonner, or
148
+ * react-toastify, or any other, would impose it on everybody.
149
+ *
150
+ * The `lw-report-submitted` event remains the finer-grained hook for the
151
+ * success case alone: it carries the filed ticket, and cancelling it
152
+ * suppresses that one message. This covers all three at once.
153
+ */
154
+ toast?: (notice: ToastNotice) => void;
155
+ }
156
+
157
+ /** One notification from the library, for a host that renders its own. */
158
+ export interface ToastNotice {
159
+ message: string;
160
+ tone: "success" | "error";
161
+ /** Present on the crash invitation: the button that opens the reporter. */
162
+ action?: { label: string; onClick: () => void };
130
163
  }
131
164
 
132
165
  export interface CaptureOptions {
package/src/index.ts CHANGED
@@ -12,7 +12,7 @@
12
12
  export { configureDebugCapture, isConfigured, getConfig, appInfo } from "./config";
13
13
  export { moduleResolver } from "./modules";
14
14
  export type { ModuleMap } from "./modules";
15
- export type { DebugCaptureConfig, CaptureOptions, RedactOptions } from "./config";
15
+ export type { DebugCaptureConfig, CaptureOptions, RedactOptions, ToastNotice } from "./config";
16
16
 
17
17
  export { installDebugCapture } from "./install";
18
18
  export type { InstallOptions } from "./install";
package/src/submit.ts CHANGED
@@ -39,10 +39,21 @@ export function toBase64(bytes: Uint8Array): string {
39
39
  return btoa(binary);
40
40
  }
41
41
 
42
- /** A data URI for the JSON bundle, so the bulk lands in object storage. */
43
- function bundleAttachment(bundle: DebugBundle): { dataUri: string; filename: string } {
42
+ /**
43
+ * A data URI for the JSON bundle, so the bulk lands in object storage.
44
+ *
45
+ * The screenshot is dropped first, and that is not an optimisation. It travels
46
+ * as its own compressed attachment; leaving it in here embedded the raw
47
+ * full-resolution data URL a second time and then base64'd the lot again, so a
48
+ * report from a 4K display arrived over the server's 5 MB per-file cap and
49
+ * failed — every time, with nothing the reporter could do about it. The size
50
+ * budget already excludes it from its own measurement for exactly this reason
51
+ * (`budget.ts`), which is what made the duplication invisible.
52
+ */
53
+ export function bundleAttachment(bundle: DebugBundle): { dataUri: string; filename: string } {
54
+ const { screenshotDataUrl: _sentSeparately, ...rest } = bundle;
44
55
  // btoa is latin1-only and a bundle is full of Thai. Encode to bytes first.
45
- const base64 = toBase64(new TextEncoder().encode(JSON.stringify(bundle)));
56
+ const base64 = toBase64(new TextEncoder().encode(JSON.stringify(rest)));
46
57
  return { dataUri: `data:application/json;base64,${base64}`, filename: "debug-bundle.json" };
47
58
  }
48
59
 
package/src/ui/toast.ts CHANGED
@@ -11,9 +11,12 @@
11
11
  * the dialog — it drops into pages we do not control, and neither side's CSS
12
12
  * should reach the other.
13
13
  *
14
- * A host that already has a toast system suppresses this by calling
15
- * `preventDefault()` on the `lw-report-submitted` event and showing its own.
14
+ * A host that already has a toast system has two ways past this: the
15
+ * `toast` config hook, which routes every one of these to it, or
16
+ * `preventDefault()` on the `lw-report-submitted` event, which suppresses the
17
+ * success message alone and hands over the filed ticket with it.
16
18
  */
19
+ import { getConfig, isConfigured } from "../config";
17
20
  const HOST_TAG = "lw-debug-toasts";
18
21
  const VISIBLE_MS = 6000;
19
22
 
@@ -92,6 +95,22 @@ export function showToast(
92
95
  tone: "success" | "error" = "success",
93
96
  action?: ToastAction,
94
97
  ): void {
98
+ /*
99
+ * The host's toaster wins, and gets everything: this is the single point all
100
+ * three announcements pass through, so routing here covers the crash
101
+ * invitation and the failure message as well as the success one — the two
102
+ * that had no escape hatch at all.
103
+ *
104
+ * `isConfigured` rather than a bare `getConfig`, which throws: a crash can be
105
+ * caught before the app has called `configureDebugCapture`, and losing the
106
+ * message because of that would be a worse bug than the one it announces.
107
+ */
108
+ const hostToast = isConfigured() ? getConfig().toast : undefined;
109
+ if (hostToast) {
110
+ hostToast({ message, tone, ...(action ? { action } : {}) });
111
+ return;
112
+ }
113
+
95
114
  const parent = ensureStack();
96
115
  if (!parent) return;
97
116