@lightworkai.official/debug-capture 0.12.6 → 0.12.7

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.
@@ -1,4 +1,4 @@
1
- (()=>{var U2=(($)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy($,{get:(J,Q)=>(typeof require<"u"?require:J)[Q]}):$)(function($){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+$+'" is not supported')});var P2={maxRequests:60,maxConsoleEntries:120,maxActions:80,maxBodyChars:20000},S=null;function b0($){let J=[];if(!$.host?.trim())J.push("host");if(!$.realmKey?.trim())J.push("realmKey");if(!$.app?.name?.trim())J.push("app.name");if(typeof $.module!=="function")J.push("module");if(J.length)throw Error(`[debug-capture] configureDebugCapture is missing: ${J.join(", ")}. `+"See the README — `module` maps a pathname to the part of your app it belongs to.");S=$}function D(){if(!S)throw Error("[debug-capture] configureDebugCapture() has not been called");return S}function j0(){return S!==null}function g(){let $=D().app;return{name:$.name,version:$.version??"0.0.0",environment:$.environment??I2()}}function I2(){if(typeof window>"u")return"unknown";let $=window.location.hostname;if($==="localhost"||$==="127.0.0.1"||$.endsWith(".local"))return"development";return"production"}function x($){let J=S?.capture?.[$];return typeof J==="number"?J:P2[$]}function p0($){let J=S?.module;if(!J)return null;try{return J($)??null}catch{return null}}function z0(){let $=S?.redact;return{headers:$?.headers??[],queryKeys:($?.queryKeys??[]).map((J)=>J.toLowerCase()),bodyKeys:($?.bodyKeys??[]).map((J)=>J.toLowerCase())}}function v0(){return S?.capture?.overlaySelectors??[]}var M2='[contenteditable]:not([contenteditable="false"]), [data-lw-mask]',q2="[data-lw-mask]",y0={fps:1,quality:0.5};function d(){let $=S?.replay;if(!$)return null;let J=$===!0?{}:$,Q=(K,W)=>typeof K==="number"&&K>0?K:W,j=J.maskInputs!==!1,z=J.recordCanvas?{fps:Q(typeof J.recordCanvas==="object"?J.recordCanvas.fps:void 0,y0.fps),quality:Q(typeof J.recordCanvas==="object"?J.recordCanvas.quality:void 0,y0.quality)}:null;return{seconds:Q(J.seconds,60),maskInputs:j,maskTextSelector:J.maskTextSelector?.trim()||(j?M2:q2),maskText:J.maskText===!0,blockSelector:J.blockSelector?.trim()||"[data-lw-private]",maxBytes:Q(J.maxBytes,4000000),canvas:z}}function u0($){if(typeof window>"u")return!1;let J;try{J=new URL($,window.location.href)}catch{return!1}if(B2(J))return!1;if(J.origin===window.location.origin)return!0;return(S?.capture?.bodyOrigins??[]).some((Q)=>{try{return new URL(Q).origin===J.origin}catch{return!1}})}function B2($){if(!S?.host)return!1;try{if(new URL(S.host).origin!==$.origin)return!1}catch{return!1}return $.pathname.startsWith("/ingest/")}function d0($){let J=Object.entries($).map(([Q,j])=>[Q.replace(/\/+$/,"")||"/",j]).sort((Q,j)=>j[0].length-Q[0].length);return(Q)=>{let j=(Q||"/").replace(/\/+$/,"")||"/";for(let[z,K]of J)if(j===z||j.startsWith(`${z}/`))return{key:z,label:K};return null}}var i="‹redacted›",C2=/^(authorization|proxy-authorization|cookie|set-cookie|x-[a-z-]*token|x-csrf[a-z-]*|x-xsrf[a-z-]*)$/i,D2=new Set(["access_token","token","id_token","refresh_token","code","secret","client_secret","password","apikey","api_key","signature","x-amz-signature","x-amz-credential"]),N2=/(password|passwd|token|secret|authorization|refresh|client_secret|otp|pin)/i,w2=/[\w.+-]+@[\w-]+\.[\w.-]+/g,O2=/\d(?:[\d\s-]{7,})\d/g;function c($){return $.replace(w2,i).replace(O2,i)}function S2($){if(C2.test($))return!0;return z0().headers.some((Q)=>Q.toLowerCase()===$.toLowerCase())}function o($){let J={};for(let[Q,j]of Object.entries($))J[Q]=S2(Q)?i:j;return J}function E($){try{let J=/^https?:\/\//i.test($),Q=new URL($,J?void 0:"http://local.invalid"),j=!1;if(Q.searchParams.forEach((z,K)=>{if(D2.has(K.toLowerCase())||z0().queryKeys.includes(K.toLowerCase()))Q.searchParams.set(K,i),j=!0}),!j)return $;return J?Q.toString():`${Q.pathname}${Q.search}`}catch{return $}}function I0($,J){if(J>6||$===null||typeof $!=="object")return $;if(Array.isArray($))return $.map((j)=>I0(j,J+1));let Q={};for(let[j,z]of Object.entries($)){let K=N2.test(j)||z0().bodyKeys.some((W)=>j.toLowerCase().includes(W));Q[j]=K?i:I0(z,J+1)}return Q}function l($,J){if($==null)return null;let Q=$,j=$.trim();if(j.startsWith("{")||j.startsWith("["))try{let z=JSON.parse(j);Q=JSON.stringify(I0(z,0))}catch{}if(Q.length>J)return`${Q.slice(0,J)}… [truncated ${Q.length-J} chars]`;return Q}var M0=120,q0=40,p=($,J)=>$.length>J?`${$.slice(0,J)}…`:$,B0=($)=>{try{return decodeURIComponent($)}catch{return $}},b=[],i0=0,c0=!1;function s($,J,Q,j){let z=p(J,M0),K=b[b.length-1];if($==="navigate"&&K?.kind==="click"){let X=z.replace(/^ไปที่\s*/,"");if(K.detail.includes(`→ ${X}`))return K.at=new Date().toISOString(),K;let H=X.split(/[?#]/)[0]??X,P=K.source?B0(K.source.replace(/^→\s*/,"")).split(/[?#]/)[0]:null;if(P&&(H===P||H.startsWith(P)))return K.detail=p(`${K.detail} → ${X}`,M0),K.source=void 0,K.at=new Date().toISOString(),K}if(K&&K.kind===$&&K.detail===z){if(K.at=new Date().toISOString(),$!=="navigate")K.count=(K.count??1)+1;return K}i0+=1;let W={id:`act_${i0}`,at:new Date().toISOString(),kind:$,detail:z,count:1,source:Q,html:K0(j)};b.push(W);while(b.length>x("maxActions"))R2(b.shift());return W}var k2=200000,r=0;function K0($){if(!$)return;if(r+$.length>k2)return;return r+=$.length,$}function R2($){if(!$)return;if(r-=($.html?.length??0)+($.afterHtml?.length??0),r<0)r=0}function Z0($){return $ instanceof Element&&Boolean($.closest("[data-debug-reporter]"))}var _2='button, a[href], [role="button"], [role="tab"], [role="menuitem"], [role="option"], [role="switch"], [role="checkbox"], [role="radio"], [role="link"], summary, input, select, textarea',T2={button:"ปุ่ม",a:"ลิงก์",input:"ช่อง",textarea:"ช่อง",select:"ตัวเลือก",summary:"ส่วนขยาย"},o0={button:"ปุ่ม",tab:"แท็บ",menuitem:"เมนู",option:"ตัวเลือก",switch:"สวิตช์",checkbox:"ช่องเลือก",radio:"ตัวเลือก",link:"ลิงก์"};function L2($){let J=$.getAttribute("role");if(J&&o0[J])return o0[J];return T2[$.tagName.toLowerCase()]??"ปุ่ม"}function f2($,J){try{let Q=$,j=0;while(Q&&j<=J){let z=t0(Q);if(z&&typeof z.memoizedProps?.onClick==="function")return Q;Q=Q.parentElement,j+=1}}catch{}return null}function A2($){let J=$.getAttribute("aria-label")?.trim();if(J)return J;let Q=$.getAttribute("title")?.trim();if(Q)return Q;if($ instanceof HTMLInputElement||$ instanceof HTMLTextAreaElement||$ instanceof HTMLSelectElement)return($.getAttribute("placeholder")||$.getAttribute("name")||"").trim();if($ instanceof HTMLImageElement)return($.getAttribute("alt")||"").trim();let j=($.textContent??"").replace(/\s+/g," ").trim();if(j)return j;if($ instanceof HTMLAnchorElement){let z=$.getAttribute("href");if(z?.startsWith("/"))return B0(z)}return""}function x2($){if(!($ instanceof Element))return null;let J=$.closest(_2)??f2($,4);if(!J)return null;let Q=J.tagName.toLowerCase();if(Q==="html"||Q==="body")return null;return J}function E2($){let J=c(A2($));if(!J)return null;return`${L2($)} “${p(J,q0)}”`}var a0=6000,h2=4000,m2=/(?:^|\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 g2($){$.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 W of Array.from(z.attributes)){let X=W.name.toLowerCase();if(X.startsWith("on")||X==="srcdoc"||X==="value"||X.startsWith("data-"))z.removeAttribute(W.name)}if(z instanceof HTMLAnchorElement)z.setAttribute("href","#");if(z instanceof HTMLImageElement)z.removeAttribute("src");let K=z.getAttribute("class");if(K){let W=K.replace(m2," ").replace(/\s+/g," ").trim();if(W)z.setAttribute("class",W);else z.removeAttribute("class")}}let Q=document.createTreeWalker($,NodeFilter.SHOW_TEXT),j=Q.nextNode();while(j){if(j.nodeValue)j.nodeValue=c(j.nodeValue);j=Q.nextNode()}}function C0($,J,Q){try{let j=$.outerHTML;if(!j||j.length>J)return;let z=$.cloneNode(!0);g2(z);let K=z.outerHTML;return K&&K.length<=Q?K:void 0}catch{return}}var y2=($)=>C0($,a0,h2),b2=150000,p2=40000,l0=($)=>C0($,b2,p2);function v2($){if(!($ instanceof HTMLInputElement)&&!($ instanceof HTMLTextAreaElement)&&!($ instanceof HTMLSelectElement))return null;let J=$.name||$.id||$.getAttribute("aria-label")||$.getAttribute("placeholder")||$.tagName.toLowerCase();return`ช่อง “${c(J)}”`}var s0=80;function t0($){let J=Object.keys($).find((Q)=>Q.startsWith("__reactFiber$")||Q.startsWith("__reactInternalInstance$"));return J?$[J]:null}function u2($){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 r0($){if(!$)return;return`→ ${$.length>s0?`${$.slice(0,s0)}…`:$}`}function d2($){try{let J=$.closest("a[href]")?.getAttribute("href");if(J&&J.startsWith("/"))return r0(J);let Q=t0($),j=0;while(Q&&j<30){if(typeof Q.memoizedProps?.onClick==="function")return r0(u2(Q.memoizedProps.onClick));Q=Q.return,j+=1}return}catch{return}}var i2='[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], [role="status"], [role="alert"]';function c2(){let $=v0();return $.length?$.join(", "):i2}function o2($){let J=$.getAttribute("role");if(J==="status"||J==="alert")return"ข้อความแจ้งเตือน";if(J==="menu")return"เมนู";if(J==="listbox")return"รายการตัวเลือก";if(J==="alertdialog")return"กล่องยืนยัน";return"กล่องโต้ตอบ"}function l2($){let J=$.getAttribute("aria-label")?.trim();if(J)return J;let Q=$.getAttribute("aria-labelledby");if(Q){let K=Q.split(/\s+/).map((W)=>document.getElementById(W)?.textContent?.trim()??"").filter(Boolean).join(" ");if(K)return K}let z=$.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 e0($){let J=c(l2($)),Q=o2($);return J?`เปิด ${Q} “${p(J,q0)}”`:`เปิด ${Q}`}var s2='[aria-busy="true"], [role="progressbar"], [data-loading="true"], .animate-pulse, .animate-spin',r2=/กำลังโหลด|กำลังค้นหา|กำลังดำเนินการ|\bloading\b/i;function n2($){if($.querySelector(s2))return!0;return r2.test($.textContent??"")}var a2=400,t2=250,e2=8000;function $4($,J){if(typeof MutationObserver>"u"){J.html=K0(l0($));return}let Q=Date.now(),j=!1,z=()=>{j=!0,W.disconnect(),window.clearInterval(X),window.clearTimeout(H)},K=()=>{if(j)return;if(z(),!$.isConnected)return;J.detail=p(e0($),M0),J.html=K0(l0($))},W=new MutationObserver(()=>{Q=Date.now()});W.observe($,{childList:!0,subtree:!0,attributes:!0,characterData:!0});let X=window.setInterval(()=>{if(j)return;if(!$.isConnected){z();return}if(Date.now()-Q>=a2&&!n2($))K()},t2),H=window.setTimeout(K,e2)}function J4($){if(Z0($))return;let J=s("ui",e0($));if(J)$4($,J)}function Q4(){if(typeof MutationObserver>"u")return;let $=new WeakSet;new MutationObserver((Q)=>{for(let j of Q)for(let z of Array.from(j.addedNodes)){if(!(z instanceof Element))continue;let K=c2(),W=z.matches(K)?[z]:Array.from(z.querySelectorAll(K));for(let X of W){if($.has(X))continue;$.add(X),J4(X)}}}).observe(document.body,{childList:!0,subtree:!0})}var j4=1600,z4=2500;function n0($){return{disabled:$.hasAttribute("disabled")||$.getAttribute("aria-disabled")==="true",busy:$.getAttribute("aria-busy")==="true",text:p(($.textContent??"").replace(/\s+/g," ").trim(),q0)}}function Z4($,J){if(!$.disabled&&J.disabled)return"ปุ่มถูกปิดใช้งานหลังคลิก";if(!$.busy&&J.busy)return"ปุ่มเข้าสู่สถานะกำลังโหลด";if($.text!==J.text&&J.text)return`ข้อความเปลี่ยนเป็น “${J.text}”`;return null}function K4($,J){if(typeof MutationObserver>"u")return;let Q=n0($),j=!1,z=(X,H)=>{if(j)return;if(j=!0,K.disconnect(),window.clearTimeout(W),J.afterNote=X,H)J.afterHtml=K0(C0($,a0,z4))},K=new MutationObserver(()=>{if(!$.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}let X=Z4(Q,n0($));if(X)z(X,!0)});K.observe($,{attributes:!0,attributeFilter:["disabled","aria-disabled","aria-busy","class"],childList:!0,subtree:!0,characterData:!0});let W=window.setTimeout(()=>{if(!j&&!$.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}j=!0,K.disconnect()},j4)}function $1(){if(c0||typeof window>"u")return;c0=!0,document.addEventListener("click",(j)=>{if(Z0(j.target))return;let z=x2(j.target);if(!z)return;let K=E2(z);if(!K)return;let W=s("click",`คลิก ${K}`,d2(z),y2(z));if(W)K4(z,W)},{capture:!0,passive:!0}),document.addEventListener("change",(j)=>{if(Z0(j.target))return;let z=v2(j.target);if(z)s("input",`แก้ไข ${z}`)},{capture:!0,passive:!0}),document.addEventListener("submit",(j)=>{if(Z0(j.target))return;s("submit","ส่งฟอร์ม")},{capture:!0,passive:!0});let $=()=>s("navigate",`ไปที่ ${B0(E(location.pathname+location.search))}`),J=history.pushState.bind(history),Q=history.replaceState.bind(history);history.pushState=(...j)=>{let z=J(...j);return $(),z},history.replaceState=(...j)=>{let z=Q(...j);return $(),z},window.addEventListener("popstate",$),Q4()}function J1(){return b.map(($)=>({...$}))}var Q1=2000,W0=[],j1=0,z1=!1;function D0($,J){j1+=1,W0.push({id:`log_${j1}`,at:new Date().toISOString(),level:$,message:J.length>Q1?`${J.slice(0,Q1)}…`:J});while(W0.length>x("maxConsoleEntries"))W0.shift()}function W4(){let $=new WeakSet;return(J,Q)=>{if(typeof Q==="object"&&Q!==null){if($.has(Q))return"[Circular]";$.add(Q)}if(typeof Q==="bigint")return Q.toString();return Q}}function Z1($){if(typeof $==="string")return $;if($ instanceof Error)return`${$.name}: ${$.message}`;try{let J=JSON.stringify($,W4());if(J!==void 0)return J}catch{}try{return String($)}catch{}try{return Object.prototype.toString.call($)}catch{return`[${typeof $}]`}}function K1(){if(z1||typeof window>"u")return;z1=!0;let $=["log","info","warn","error","debug"];for(let J of $){let Q=console[J].bind(console);console[J]=(...j)=>{D0(J,j.map(Z1).join(" ")),Q(...j)}}window.addEventListener("error",(J)=>{let Q=J.filename?` (${J.filename}:${J.lineno}:${J.colno})`:"";D0("exception",`${J.message}${Q}`)}),window.addEventListener("unhandledrejection",(J)=>{let Q=J.reason instanceof Error?`${J.reason.name}: ${J.reason.message}`:Z1(J.reason);D0("unhandledrejection",Q)})}function W1(){return W0.map(($)=>({...$}))}var G1=new Set,Y1=new Set;function V1($,J){return $.add(J),()=>$.delete(J)}function X1($,J){for(let Q of[...$])Q(J)}function F1($){return V1(G1,$)}function G0($={type:"manual"}){X1(G1,$)}function H1($){return V1(Y1,$)}function U1($){X1(Y1,$)}var G4=15000,Y4=["ResizeObserver loop","Script error.","Non-Error promise rejection captured"],P1=!1,I1=0;function V4($){return Y4.some((J)=>$.includes(J))}function M1($){let J=$.message??"";if(!J||V4(J))return;let Q=Date.now();if(Q-I1<G4)return;I1=Q,U1({...$,message:J})}function q1(){if(P1||typeof window>"u")return;P1=!0,window.addEventListener("error",($)=>{if(!$.message&&!$.error)return;let J=$.error instanceof Error?$.error:null;M1({type:"runtime-error",message:$.message||(J?J.message:"Unknown error"),stack:J?.stack})}),window.addEventListener("unhandledrejection",($)=>{let J=$.reason;M1({type:"unhandledrejection",message:J instanceof Error?J.message:String(J),stack:J instanceof Error?J.stack:void 0})})}var N1=4000,X4=1e6,F4=1e7,Y0=[],B1=0,C1=!1;function w1($){Y0.push($);while(Y0.length>x("maxRequests"))Y0.shift()}function O1(){return B1+=1,`req_${B1}`}function D1($){let J={};if(!$)return J;if($ instanceof Headers)$.forEach((Q,j)=>{J[j]=Q});else if(Array.isArray($))for(let[Q,j]of $)J[Q]=j;else Object.assign(J,$);return J}function H4($){let J={};return $.forEach((Q,j)=>{J[j]=Q}),J}function U4($){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 P4($,J){let Q="",j="GET",z={},K=null;if(typeof $==="string")Q=$;else if($ instanceof URL)Q=$.toString();else Q=$.url,j=$.method||j,z=D1($.headers);if(J){if(J.method)j=J.method;if(J.headers)z={...z,...D1(J.headers)};if(J.body!==void 0)K=U4(J.body)}return{method:j.toUpperCase(),url:Q,headers:z,body:K}}function S1($){return!u0($)}function I4($,J){if(S1(J.url)){J.responseSnippet="[body not captured for this origin]";return}let Q=$.headers.get("content-type")??"",j=Number($.headers.get("content-length")??"0"),z=j?`, ~${j} bytes`:"";if(!/json|text|xml|html|javascript|urlencoded/i.test(Q)){J.responseSnippet=`[binary ${Q||"unknown"}${z}]`;return}if(j>X4){J.responseSnippet=`[response ${Q||"text"}${z} — omitted]`;return}try{$.clone().text().then((K)=>{J.responseSnippet=l(K,x("maxBodyChars"))}).catch(()=>{})}catch{}}function k1($,J){if(/[?&]_rsc=/.test($))return!0;for(let Q of Object.keys(J)){let j=Q.toLowerCase();if(j==="rsc"||j==="next-router-prefetch"||j==="next-router-state-tree")return!0}return!1}function M4(){if(typeof window>"u"||typeof window.fetch!=="function")return;let $=window.fetch.bind(window);window.fetch=Object.assign(async(J,Q)=>{let j=P4(J,Q);if(k1(j.url,j.headers))return $(J,Q);let z={id:O1(),startedAt:new Date().toISOString(),method:j.method,url:E(j.url),requestHeaders:o(j.headers),requestBody:l(j.body,N1),status:null,statusText:null,durationMs:null,via:"fetch"};w1(z);let K=performance.now();try{let W=await $(J,Q);return z.status=W.status,z.statusText=W.statusText,z.durationMs=Math.round(performance.now()-K),z.responseHeaders=o(H4(W.headers)),I4(W,z),W}catch(W){throw z.durationMs=Math.round(performance.now()-K),z.error=W instanceof Error?`${W.name}: ${W.message}`:String(W),W}},$)}function q4(){if(typeof window>"u"||typeof window.XMLHttpRequest!=="function")return;let $=XMLHttpRequest.prototype,J=$.open,Q=$.send,j=function(K,W){let X=typeof W==="string"?W:W.toString();return this.__lwEntry=k1(X,{})?void 0:{id:O1(),startedAt:"",method:(K||"GET").toUpperCase(),url:E(X),requestHeaders:{},requestBody:null,status:null,statusText:null,durationMs:null,via:"xhr"},J.apply(this,arguments)},z=function(K){let W=this.__lwEntry;if(W){W.startedAt=new Date().toISOString(),W.requestBody=typeof K==="string"?l(K,N1):K==null?null:"[non-string body]";let X=performance.now();w1(W),this.addEventListener("loadend",()=>{if(W.status=this.status||null,W.statusText=this.statusText||null,W.durationMs=Math.round(performance.now()-X),S1(W.url))W.responseSnippet="[body not captured for this origin]";else if(this.responseType===""||this.responseType==="text")try{W.responseSnippet=l(this.responseText||"",x("maxBodyChars"))}catch{}else{let H=this.getResponseHeader("content-type")??this.responseType;W.responseSnippet=`[binary ${H}]`}})}return Q.apply(this,arguments)};$.open=j,$.send=z}function R1(){if(C1)return;C1=!0,M4(),q4()}function _1(){let $=Y0.map((Q)=>({...Q})),J=0;for(let Q=$.length-1;Q>=0;Q-=1){let j=$[Q],z=j?.responseSnippet;if(!j||typeof z!=="string"||z.length===0)continue;if(J+z.length>F4)j.responseSnippet=`[response omitted — report size budget reached (${z.length.toLocaleString()} chars)]`;else J+=z.length}return $}var B4=4,T1=3,C4=4000,D4="[data-debug-reporter]",L1=()=>import("@rrweb/record");function f1($){L1=$}var _=[],N0=null,V0=!1;function A1(){if(typeof window>"u"||N0||V0)return;let $=d();if(!$)return;V0=!0;let J=()=>void N4($);if("requestIdleCallback"in window)window.requestIdleCallback(J,{timeout:3000});else setTimeout(J,1000)}async function N4($){let J;try{J=(await L1()).record}catch(Q){V0=!1,console.warn("[debug-capture] session replay could not start:",Q);return}if(N0)return;try{N0=J({emit:(Q)=>w4(Q),checkoutEveryNms:Math.max(1000,$.seconds*1000/2),checkoutEveryNth:C4,maskAllInputs:$.maskInputs,maskTextSelector:$.maskText?"*":$.maskTextSelector,blockSelector:`${$.blockSelector}, ${D4}`,slimDOMOptions:"all",inlineStylesheet:!0,sampling:{mousemove:50,scroll:150,media:800,input:"last",...$.canvas?{canvas:$.canvas.fps}:{}},recordCanvas:$.canvas!==null,...$.canvas?{dataURLOptions:{type:"image/webp",quality:$.canvas.quality}}:{},errorHandler:()=>!0})??null}catch(Q){console.warn("[debug-capture] session replay could not start:",Q)}finally{V0=!1}}function w4($){if($.type===B4||_.length===0){if(_.push([]),_.length>T1)_=_.slice(-T1)}_[_.length-1].push($)}function x1($=Date.now()){let J=d();if(!J||!_.length)return null;let Q=$-J.seconds*1000,j=_.length-1;while(j>0&&(_[j][0]?.timestamp??$)>Q)j-=1;let z=_.slice(j).flat(),K=z[0]?.timestamp,W=z[z.length-1]?.timestamp;if(K===void 0||W===void 0)return null;return{events:z,startedAt:new Date(K).toISOString(),endedAt:new Date(W).toISOString(),durationMs:Math.max(0,W-K)}}var O4={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:"ส่งรายงานไม่สำเร็จ",failedOffline:"ส่งไม่สำเร็จ — เชื่อมต่อเซิร์ฟเวอร์ไม่ได้ ข้อความที่พิมพ์ไว้ยังอยู่ ตรวจสอบอินเทอร์เน็ตแล้วลองใหม่",failedUnavailable:"ส่งไม่สำเร็จ — ระบบกำลังปรับปรุงชั่วคราว ข้อความที่พิมพ์ไว้ยังอยู่ ลองใหม่ในอีกสักครู่",failedTooMany:"แจ้งปัญหาถี่เกินไป — ลองใหม่ในอีก {seconds} วินาที",captured:"เก็บข้อมูลแล้ว",reporter:"ผู้แจ้ง",page:"หน้า",replay:"บันทึกการใช้งาน",handoffTitle:"กำลังพาไปที่ระบบแจ้งปัญหา",handoffBody:"ระบบจะลงชื่อเข้าใช้ให้อัตโนมัติ เพื่อดูเรื่องที่คุณแจ้งไว้",handoffGo:"ไปเลย",handoffPreparing:"กำลังเตรียม…",handoffFailed:"เปิดรายการที่แจ้งไว้ไม่สำเร็จ",handoffBlocked:"เบราว์เซอร์บล็อกการเปิดแท็บใหม่",handoffOpen:"เปิดในแท็บใหม่"},S4={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",failedOffline:"Could not send — the server could not be reached. What you wrote is still here; check your connection and try again.",failedUnavailable:"Could not send — the system is being updated. What you wrote is still here; try again in a moment.",failedTooMany:"Too many reports — try again in {seconds} seconds.",captured:"Captured",reporter:"Reporter",page:"Page",replay:"activity log",handoffTitle:"Opening the support portal",handoffBody:"You will be signed in automatically to see what you reported",handoffGo:"Go now",handoffPreparing:"Preparing…",handoffFailed:"Could not open your reports",handoffBlocked:"Your browser blocked the new tab",handoffOpen:"Open in a new tab"};function X0($){return $==="en"?S4:O4}var k4="lw-debug-toasts",R4=6000,_4=`
1
+ (()=>{var U2=(($)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy($,{get:(J,Q)=>(typeof require<"u"?require:J)[Q]}):$)(function($){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+$+'" is not supported')});var M2={maxRequests:60,maxConsoleEntries:120,maxActions:80,maxBodyChars:20000},S=null;function b0($){let J=[];if(!$.host?.trim())J.push("host");if(!$.realmKey?.trim())J.push("realmKey");if(!$.app?.name?.trim())J.push("app.name");if(typeof $.module!=="function")J.push("module");if(J.length)throw Error(`[debug-capture] configureDebugCapture is missing: ${J.join(", ")}. `+"See the README — `module` maps a pathname to the part of your app it belongs to.");S=$}function C(){if(!S)throw Error("[debug-capture] configureDebugCapture() has not been called");return S}function j0(){return S!==null}function g(){let $=C().app;return{name:$.name,version:$.version??"0.0.0",environment:$.environment??I2()}}function I2(){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=S?.capture?.[$];return typeof J==="number"?J:M2[$]}function p0($){let J=S?.module;if(!J)return null;try{return J($)??null}catch{return null}}function z0(){let $=S?.redact;return{headers:$?.headers??[],queryKeys:($?.queryKeys??[]).map((J)=>J.toLowerCase()),bodyKeys:($?.bodyKeys??[]).map((J)=>J.toLowerCase())}}function v0(){return S?.capture?.overlaySelectors??[]}var q2='[contenteditable]:not([contenteditable="false"]), [data-lw-mask]',w2="[data-lw-mask]",y0={fps:1,quality:0.5};function d(){let $=S?.replay;if(!$)return null;let J=$===!0?{}:$,Q=(K,W)=>typeof K==="number"&&K>0?K:W,j=J.maskInputs!==!1,z=J.recordCanvas?{fps:Q(typeof J.recordCanvas==="object"?J.recordCanvas.fps:void 0,y0.fps),quality:Q(typeof J.recordCanvas==="object"?J.recordCanvas.quality:void 0,y0.quality)}:null;return{seconds:Q(J.seconds,60),maskInputs:j,maskTextSelector:J.maskTextSelector?.trim()||(j?q2:w2),maskText:J.maskText===!0,blockSelector:J.blockSelector?.trim()||"[data-lw-private]",maxBytes:Q(J.maxBytes,4000000),canvas:z}}function u0($){if(typeof window>"u")return!1;let J;try{J=new URL($,window.location.href)}catch{return!1}if(B2(J))return!1;if(J.origin===window.location.origin)return!0;return(S?.capture?.bodyOrigins??[]).some((Q)=>{try{return new URL(Q).origin===J.origin}catch{return!1}})}function B2($){if(!S?.host)return!1;try{if(new URL(S.host).origin!==$.origin)return!1}catch{return!1}return $.pathname.startsWith("/ingest/")}function d0($){let J=Object.entries($).map(([Q,j])=>[Q.replace(/\/+$/,"")||"/",j]).sort((Q,j)=>j[0].length-Q[0].length);return(Q)=>{let j=(Q||"/").replace(/\/+$/,"")||"/";for(let[z,K]of J)if(j===z||j.startsWith(`${z}/`))return{key:z,label:K};return null}}var i="‹redacted›",C2=/^(authorization|proxy-authorization|cookie|set-cookie|x-[a-z-]*token|x-csrf[a-z-]*|x-xsrf[a-z-]*)$/i,D2=new Set(["access_token","token","id_token","refresh_token","code","secret","client_secret","password","apikey","api_key","signature","x-amz-signature","x-amz-credential"]),N2=/(password|passwd|token|secret|authorization|refresh|client_secret|otp|pin)/i,k2=/[\w.+-]+@[\w-]+\.[\w.-]+/g,S2=/\d(?:[\d\s-]{7,})\d/g;function c($){return $.replace(k2,i).replace(S2,i)}function O2($){if(C2.test($))return!0;return z0().headers.some((Q)=>Q.toLowerCase()===$.toLowerCase())}function o($){let J={};for(let[Q,j]of Object.entries($))J[Q]=O2(Q)?i:j;return J}function x($){try{let J=/^https?:\/\//i.test($),Q=new URL($,J?void 0:"http://local.invalid"),j=!1;if(Q.searchParams.forEach((z,K)=>{if(D2.has(K.toLowerCase())||z0().queryKeys.includes(K.toLowerCase()))Q.searchParams.set(K,i),j=!0}),!j)return $;return J?Q.toString():`${Q.pathname}${Q.search}`}catch{return $}}function M0($,J){if(J>6||$===null||typeof $!=="object")return $;if(Array.isArray($))return $.map((j)=>M0(j,J+1));let Q={};for(let[j,z]of Object.entries($)){let K=N2.test(j)||z0().bodyKeys.some((W)=>j.toLowerCase().includes(W));Q[j]=K?i:M0(z,J+1)}return Q}function l($,J){if($==null)return null;let Q=$,j=$.trim();if(j.startsWith("{")||j.startsWith("["))try{let z=JSON.parse(j);Q=JSON.stringify(M0(z,0))}catch{}if(Q.length>J)return`${Q.slice(0,J)}… [truncated ${Q.length-J} chars]`;return Q}var I0=120,q0=40,p=($,J)=>$.length>J?`${$.slice(0,J)}…`:$,w0=($)=>{try{return decodeURIComponent($)}catch{return $}},b=[],i0=0,c0=!1;function s($,J,Q,j){let z=p(J,I0),K=b[b.length-1];if($==="navigate"&&K?.kind==="click"){let X=z.replace(/^ไปที่\s*/,"");if(K.detail.includes(`→ ${X}`))return K.at=new Date().toISOString(),K;let H=X.split(/[?#]/)[0]??X,U=K.source?w0(K.source.replace(/^→\s*/,"")).split(/[?#]/)[0]:null;if(U&&(H===U||H.startsWith(U)))return K.detail=p(`${K.detail} → ${X}`,I0),K.source=void 0,K.at=new Date().toISOString(),K}if(K&&K.kind===$&&K.detail===z){if(K.at=new Date().toISOString(),$!=="navigate")K.count=(K.count??1)+1;return K}i0+=1;let W={id:`act_${i0}`,at:new Date().toISOString(),kind:$,detail:z,count:1,source:Q,html:K0(j)};b.push(W);while(b.length>h("maxActions"))_2(b.shift());return W}var R2=200000,r=0;function K0($){if(!$)return;if(r+$.length>R2)return;return r+=$.length,$}function _2($){if(!$)return;if(r-=($.html?.length??0)+($.afterHtml?.length??0),r<0)r=0}function Z0($){return $ instanceof Element&&Boolean($.closest("[data-debug-reporter]"))}var T2='button, a[href], [role="button"], [role="tab"], [role="menuitem"], [role="option"], [role="switch"], [role="checkbox"], [role="radio"], [role="link"], summary, input, select, textarea',L2={button:"ปุ่ม",a:"ลิงก์",input:"ช่อง",textarea:"ช่อง",select:"ตัวเลือก",summary:"ส่วนขยาย"},o0={button:"ปุ่ม",tab:"แท็บ",menuitem:"เมนู",option:"ตัวเลือก",switch:"สวิตช์",checkbox:"ช่องเลือก",radio:"ตัวเลือก",link:"ลิงก์"};function f2($){let J=$.getAttribute("role");if(J&&o0[J])return o0[J];return L2[$.tagName.toLowerCase()]??"ปุ่ม"}function A2($,J){try{let Q=$,j=0;while(Q&&j<=J){let z=t0(Q);if(z&&typeof z.memoizedProps?.onClick==="function")return Q;Q=Q.parentElement,j+=1}}catch{}return null}function h2($){let J=$.getAttribute("aria-label")?.trim();if(J)return J;let Q=$.getAttribute("title")?.trim();if(Q)return Q;if($ instanceof HTMLInputElement||$ instanceof HTMLTextAreaElement||$ instanceof HTMLSelectElement)return($.getAttribute("placeholder")||$.getAttribute("name")||"").trim();if($ instanceof HTMLImageElement)return($.getAttribute("alt")||"").trim();let j=($.textContent??"").replace(/\s+/g," ").trim();if(j)return j;if($ instanceof HTMLAnchorElement){let z=$.getAttribute("href");if(z?.startsWith("/"))return w0(z)}return""}function x2($){if(!($ instanceof Element))return null;let J=$.closest(T2)??A2($,4);if(!J)return null;let Q=J.tagName.toLowerCase();if(Q==="html"||Q==="body")return null;return J}function E2($){let J=c(h2($));if(!J)return null;return`${f2($)} “${p(J,q0)}”`}var a0=6000,m2=4000,g2=/(?:^|\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 y2($){$.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 W of Array.from(z.attributes)){let X=W.name.toLowerCase();if(X.startsWith("on")||X==="srcdoc"||X==="value"||X.startsWith("data-"))z.removeAttribute(W.name)}if(z instanceof HTMLAnchorElement)z.setAttribute("href","#");if(z instanceof HTMLImageElement)z.removeAttribute("src");let K=z.getAttribute("class");if(K){let W=K.replace(g2," ").replace(/\s+/g," ").trim();if(W)z.setAttribute("class",W);else z.removeAttribute("class")}}let Q=document.createTreeWalker($,NodeFilter.SHOW_TEXT),j=Q.nextNode();while(j){if(j.nodeValue)j.nodeValue=c(j.nodeValue);j=Q.nextNode()}}function B0($,J,Q){try{let j=$.outerHTML;if(!j||j.length>J)return;let z=$.cloneNode(!0);y2(z);let K=z.outerHTML;return K&&K.length<=Q?K:void 0}catch{return}}var b2=($)=>B0($,a0,m2),p2=150000,v2=40000,l0=($)=>B0($,p2,v2);function u2($){if(!($ instanceof HTMLInputElement)&&!($ instanceof HTMLTextAreaElement)&&!($ instanceof HTMLSelectElement))return null;let J=$.name||$.id||$.getAttribute("aria-label")||$.getAttribute("placeholder")||$.tagName.toLowerCase();return`ช่อง “${c(J)}”`}var s0=80;function t0($){let J=Object.keys($).find((Q)=>Q.startsWith("__reactFiber$")||Q.startsWith("__reactInternalInstance$"));return J?$[J]:null}function d2($){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 r0($){if(!$)return;return`→ ${$.length>s0?`${$.slice(0,s0)}…`:$}`}function i2($){try{let J=$.closest("a[href]")?.getAttribute("href");if(J&&J.startsWith("/"))return r0(J);let Q=t0($),j=0;while(Q&&j<30){if(typeof Q.memoizedProps?.onClick==="function")return r0(d2(Q.memoizedProps.onClick));Q=Q.return,j+=1}return}catch{return}}var c2='[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], [role="status"], [role="alert"]';function o2(){let $=v0();return $.length?$.join(", "):c2}function l2($){let J=$.getAttribute("role");if(J==="status"||J==="alert")return"ข้อความแจ้งเตือน";if(J==="menu")return"เมนู";if(J==="listbox")return"รายการตัวเลือก";if(J==="alertdialog")return"กล่องยืนยัน";return"กล่องโต้ตอบ"}function s2($){let J=$.getAttribute("aria-label")?.trim();if(J)return J;let Q=$.getAttribute("aria-labelledby");if(Q){let K=Q.split(/\s+/).map((W)=>document.getElementById(W)?.textContent?.trim()??"").filter(Boolean).join(" ");if(K)return K}let z=$.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 e0($){let J=c(s2($)),Q=l2($);return J?`เปิด ${Q} “${p(J,q0)}”`:`เปิด ${Q}`}var r2='[aria-busy="true"], [role="progressbar"], [data-loading="true"], .animate-pulse, .animate-spin',n2=/กำลังโหลด|กำลังค้นหา|กำลังดำเนินการ|\bloading\b/i;function a2($){if($.querySelector(r2))return!0;return n2.test($.textContent??"")}var t2=400,e2=250,$4=8000;function J4($,J){if(typeof MutationObserver>"u"){J.html=K0(l0($));return}let Q=Date.now(),j=!1,z=()=>{j=!0,W.disconnect(),window.clearInterval(X),window.clearTimeout(H)},K=()=>{if(j)return;if(z(),!$.isConnected)return;J.detail=p(e0($),I0),J.html=K0(l0($))},W=new MutationObserver(()=>{Q=Date.now()});W.observe($,{childList:!0,subtree:!0,attributes:!0,characterData:!0});let X=window.setInterval(()=>{if(j)return;if(!$.isConnected){z();return}if(Date.now()-Q>=t2&&!a2($))K()},e2),H=window.setTimeout(K,$4)}function Q4($){if(Z0($))return;let J=s("ui",e0($));if(J)J4($,J)}function j4(){if(typeof MutationObserver>"u")return;let $=new WeakSet;new MutationObserver((Q)=>{for(let j of Q)for(let z of Array.from(j.addedNodes)){if(!(z instanceof Element))continue;let K=o2(),W=z.matches(K)?[z]:Array.from(z.querySelectorAll(K));for(let X of W){if($.has(X))continue;$.add(X),Q4(X)}}}).observe(document.body,{childList:!0,subtree:!0})}var z4=1600,Z4=2500;function n0($){return{disabled:$.hasAttribute("disabled")||$.getAttribute("aria-disabled")==="true",busy:$.getAttribute("aria-busy")==="true",text:p(($.textContent??"").replace(/\s+/g," ").trim(),q0)}}function K4($,J){if(!$.disabled&&J.disabled)return"ปุ่มถูกปิดใช้งานหลังคลิก";if(!$.busy&&J.busy)return"ปุ่มเข้าสู่สถานะกำลังโหลด";if($.text!==J.text&&J.text)return`ข้อความเปลี่ยนเป็น “${J.text}”`;return null}function W4($,J){if(typeof MutationObserver>"u")return;let Q=n0($),j=!1,z=(X,H)=>{if(j)return;if(j=!0,K.disconnect(),window.clearTimeout(W),J.afterNote=X,H)J.afterHtml=K0(B0($,a0,Z4))},K=new MutationObserver(()=>{if(!$.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}let X=K4(Q,n0($));if(X)z(X,!0)});K.observe($,{attributes:!0,attributeFilter:["disabled","aria-disabled","aria-busy","class"],childList:!0,subtree:!0,characterData:!0});let W=window.setTimeout(()=>{if(!j&&!$.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}j=!0,K.disconnect()},z4)}function $1(){if(c0||typeof window>"u")return;c0=!0,document.addEventListener("click",(j)=>{if(Z0(j.target))return;let z=x2(j.target);if(!z)return;let K=E2(z);if(!K)return;let W=s("click",`คลิก ${K}`,i2(z),b2(z));if(W)W4(z,W)},{capture:!0,passive:!0}),document.addEventListener("change",(j)=>{if(Z0(j.target))return;let z=u2(j.target);if(z)s("input",`แก้ไข ${z}`)},{capture:!0,passive:!0}),document.addEventListener("submit",(j)=>{if(Z0(j.target))return;s("submit","ส่งฟอร์ม")},{capture:!0,passive:!0});let $=()=>s("navigate",`ไปที่ ${w0(x(location.pathname+location.search))}`),J=history.pushState.bind(history),Q=history.replaceState.bind(history);history.pushState=(...j)=>{let z=J(...j);return $(),z},history.replaceState=(...j)=>{let z=Q(...j);return $(),z},window.addEventListener("popstate",$),j4()}function J1(){return b.map(($)=>({...$}))}var Q1=2000,W0=[],j1=0,z1=!1;function C0($,J){j1+=1,W0.push({id:`log_${j1}`,at:new Date().toISOString(),level:$,message:J.length>Q1?`${J.slice(0,Q1)}…`:J});while(W0.length>h("maxConsoleEntries"))W0.shift()}function Y4(){let $=new WeakSet;return(J,Q)=>{if(typeof Q==="object"&&Q!==null){if($.has(Q))return"[Circular]";$.add(Q)}if(typeof Q==="bigint")return Q.toString();return Q}}function Z1($){if(typeof $==="string")return $;if($ instanceof Error)return`${$.name}: ${$.message}`;try{let J=JSON.stringify($,Y4());if(J!==void 0)return J}catch{}try{return String($)}catch{}try{return Object.prototype.toString.call($)}catch{return`[${typeof $}]`}}function K1(){if(z1||typeof window>"u")return;z1=!0;let $=["log","info","warn","error","debug"];for(let J of $){let Q=console[J].bind(console);console[J]=(...j)=>{C0(J,j.map(Z1).join(" ")),Q(...j)}}window.addEventListener("error",(J)=>{let Q=J.filename?` (${J.filename}:${J.lineno}:${J.colno})`:"";C0("exception",`${J.message}${Q}`)}),window.addEventListener("unhandledrejection",(J)=>{let Q=J.reason instanceof Error?`${J.reason.name}: ${J.reason.message}`:Z1(J.reason);C0("unhandledrejection",Q)})}function W1(){return W0.map(($)=>({...$}))}var Y1=new Set,G1=new Set;function V1($,J){return $.add(J),()=>$.delete(J)}function X1($,J){for(let Q of[...$])Q(J)}function F1($){return V1(Y1,$)}function Y0($={type:"manual"}){X1(Y1,$)}function H1($){return V1(G1,$)}function P1($){X1(G1,$)}var G4=15000,V4=["ResizeObserver loop","Script error.","Non-Error promise rejection captured"],U1=!1,M1=0;function X4($){return V4.some((J)=>$.includes(J))}function I1($){let J=$.message??"";if(!J||X4(J))return;let Q=Date.now();if(Q-M1<G4)return;M1=Q,P1({...$,message:J})}function q1(){if(U1||typeof window>"u")return;U1=!0,window.addEventListener("error",($)=>{if(!$.message&&!$.error)return;let J=$.error instanceof Error?$.error:null;I1({type:"runtime-error",message:$.message||(J?J.message:"Unknown error"),stack:J?.stack})}),window.addEventListener("unhandledrejection",($)=>{let J=$.reason;I1({type:"unhandledrejection",message:J instanceof Error?J.message:String(J),stack:J instanceof Error?J.stack:void 0})})}var D1=4000,F4=1e6,H4=1e7,G0=[],w1=0,B1=!1;function N1($){G0.push($);while(G0.length>h("maxRequests"))G0.shift()}function k1(){return w1+=1,`req_${w1}`}function C1($){let J={};if(!$)return J;if($ instanceof Headers)$.forEach((Q,j)=>{J[j]=Q});else if(Array.isArray($))for(let[Q,j]of $)J[Q]=j;else Object.assign(J,$);return J}function P4($){let J={};return $.forEach((Q,j)=>{J[j]=Q}),J}function U4($){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 M4($,J){let Q="",j="GET",z={},K=null;if(typeof $==="string")Q=$;else if($ instanceof URL)Q=$.toString();else Q=$.url,j=$.method||j,z=C1($.headers);if(J){if(J.method)j=J.method;if(J.headers)z={...z,...C1(J.headers)};if(J.body!==void 0)K=U4(J.body)}return{method:j.toUpperCase(),url:Q,headers:z,body:K}}function S1($){return!u0($)}function I4($,J){if(S1(J.url)){J.responseSnippet="[body not captured for this origin]";return}let Q=$.headers.get("content-type")??"",j=Number($.headers.get("content-length")??"0"),z=j?`, ~${j} bytes`:"";if(!/json|text|xml|html|javascript|urlencoded/i.test(Q)){J.responseSnippet=`[binary ${Q||"unknown"}${z}]`;return}if(j>F4){J.responseSnippet=`[response ${Q||"text"}${z} — omitted]`;return}try{$.clone().text().then((K)=>{J.responseSnippet=l(K,h("maxBodyChars"))}).catch(()=>{})}catch{}}function O1($,J){if(/[?&]_rsc=/.test($))return!0;for(let Q of Object.keys(J)){let j=Q.toLowerCase();if(j==="rsc"||j==="next-router-prefetch"||j==="next-router-state-tree")return!0}return!1}function q4(){if(typeof window>"u"||typeof window.fetch!=="function")return;let $=window.fetch.bind(window);window.fetch=Object.assign(async(J,Q)=>{let j=M4(J,Q);if(O1(j.url,j.headers))return $(J,Q);let z={id:k1(),startedAt:new Date().toISOString(),method:j.method,url:x(j.url),requestHeaders:o(j.headers),requestBody:l(j.body,D1),status:null,statusText:null,durationMs:null,via:"fetch"};N1(z);let K=performance.now();try{let W=await $(J,Q);return z.status=W.status,z.statusText=W.statusText,z.durationMs=Math.round(performance.now()-K),z.responseHeaders=o(P4(W.headers)),I4(W,z),W}catch(W){throw z.durationMs=Math.round(performance.now()-K),z.error=W instanceof Error?`${W.name}: ${W.message}`:String(W),W}},$)}function w4(){if(typeof window>"u"||typeof window.XMLHttpRequest!=="function")return;let $=XMLHttpRequest.prototype,J=$.open,Q=$.send,j=function(K,W){let X=typeof W==="string"?W:W.toString();return this.__lwEntry=O1(X,{})?void 0:{id:k1(),startedAt:"",method:(K||"GET").toUpperCase(),url:x(X),requestHeaders:{},requestBody:null,status:null,statusText:null,durationMs:null,via:"xhr"},J.apply(this,arguments)},z=function(K){let W=this.__lwEntry;if(W){W.startedAt=new Date().toISOString(),W.requestBody=typeof K==="string"?l(K,D1):K==null?null:"[non-string body]";let X=performance.now();N1(W),this.addEventListener("loadend",()=>{if(W.status=this.status||null,W.statusText=this.statusText||null,W.durationMs=Math.round(performance.now()-X),S1(W.url))W.responseSnippet="[body not captured for this origin]";else if(this.responseType===""||this.responseType==="text")try{W.responseSnippet=l(this.responseText||"",h("maxBodyChars"))}catch{}else{let H=this.getResponseHeader("content-type")??this.responseType;W.responseSnippet=`[binary ${H}]`}})}return Q.apply(this,arguments)};$.open=j,$.send=z}function R1(){if(B1)return;B1=!0,q4(),w4()}function _1(){let $=G0.map((Q)=>({...Q})),J=0;for(let Q=$.length-1;Q>=0;Q-=1){let j=$[Q],z=j?.responseSnippet;if(!j||typeof z!=="string"||z.length===0)continue;if(J+z.length>H4)j.responseSnippet=`[response omitted — report size budget reached (${z.length.toLocaleString()} chars)]`;else J+=z.length}return $}var B4=4,T1=3,C4=4000,D4="[data-debug-reporter]",L1=()=>import("@rrweb/record");function f1($){L1=$}var _=[],D0=null,V0=!1;function A1(){if(typeof window>"u"||D0||V0)return;let $=d();if(!$)return;V0=!0;let J=()=>void N4($);if("requestIdleCallback"in window)window.requestIdleCallback(J,{timeout:3000});else setTimeout(J,1000)}async function N4($){let J;try{J=(await L1()).record}catch(Q){V0=!1,console.warn("[debug-capture] session replay could not start:",Q);return}if(D0)return;try{D0=J({emit:(Q)=>k4(Q),checkoutEveryNms:Math.max(1000,$.seconds*1000/2),checkoutEveryNth:C4,maskAllInputs:$.maskInputs,maskTextSelector:$.maskText?"*":$.maskTextSelector,blockSelector:`${$.blockSelector}, ${D4}`,slimDOMOptions:"all",inlineStylesheet:!0,sampling:{mousemove:50,scroll:150,media:800,input:"last",...$.canvas?{canvas:$.canvas.fps}:{}},recordCanvas:$.canvas!==null,...$.canvas?{dataURLOptions:{type:"image/webp",quality:$.canvas.quality}}:{},errorHandler:()=>!0})??null}catch(Q){console.warn("[debug-capture] session replay could not start:",Q)}finally{V0=!1}}function k4($){if($.type===B4||_.length===0){if(_.push([]),_.length>T1)_=_.slice(-T1)}_[_.length-1].push($)}function h1($=Date.now()){let J=d();if(!J||!_.length)return null;let Q=$-J.seconds*1000,j=_.length-1;while(j>0&&(_[j][0]?.timestamp??$)>Q)j-=1;let z=_.slice(j).flat(),K=z[0]?.timestamp,W=z[z.length-1]?.timestamp;if(K===void 0||W===void 0)return null;return{events:z,startedAt:new Date(K).toISOString(),endedAt:new Date(W).toISOString(),durationMs:Math.max(0,W-K)}}var S4={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:"ส่งรายงานไม่สำเร็จ",failedOffline:"ส่งไม่สำเร็จ — เชื่อมต่อเซิร์ฟเวอร์ไม่ได้ ข้อความที่พิมพ์ไว้ยังอยู่ ตรวจสอบอินเทอร์เน็ตแล้วลองใหม่",failedUnavailable:"ส่งไม่สำเร็จ — ระบบกำลังปรับปรุงชั่วคราว ข้อความที่พิมพ์ไว้ยังอยู่ ลองใหม่ในอีกสักครู่",failedTooMany:"แจ้งปัญหาถี่เกินไป — ลองใหม่ในอีก {seconds} วินาที",captured:"เก็บข้อมูลแล้ว",reporter:"ผู้แจ้ง",page:"หน้า",replay:"บันทึกการใช้งาน",handoffTitle:"กำลังพาไปที่ระบบแจ้งปัญหา",handoffBody:"ระบบจะลงชื่อเข้าใช้ให้อัตโนมัติ เพื่อดูเรื่องที่คุณแจ้งไว้",handoffGo:"ไปเลย",handoffPreparing:"กำลังเตรียม…",handoffFailed:"เปิดรายการที่แจ้งไว้ไม่สำเร็จ",handoffBlocked:"เบราว์เซอร์บล็อกการเปิดแท็บใหม่",handoffOpen:"เปิดในแท็บใหม่"},O4={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",failedOffline:"Could not send — the server could not be reached. What you wrote is still here; check your connection and try again.",failedUnavailable:"Could not send — the system is being updated. What you wrote is still here; try again in a moment.",failedTooMany:"Too many reports — try again in {seconds} seconds.",captured:"Captured",reporter:"Reporter",page:"Page",replay:"activity log",handoffTitle:"Opening the support portal",handoffBody:"You will be signed in automatically to see what you reported",handoffGo:"Go now",handoffPreparing:"Preparing…",handoffFailed:"Could not open your reports",handoffBlocked:"Your browser blocked the new tab",handoffOpen:"Open in a new tab"};function X0($){return $==="en"?O4:S4}var R4="lw-debug-toasts",_4=6000,T4=`
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
- `,w0=null;function T4(){if(typeof document>"u")return null;if(w0?.isConnected)return w0;let $=document.createElement(k4);$.dataset.debugReporter="true";let J=$.attachShadow({mode:"open"}),Q=document.createElement("style");Q.textContent=_4;let j=document.createElement("div");return j.className="stack",j.setAttribute("role","status"),j.setAttribute("aria-live","polite"),J.append(Q,j),document.body.append($),w0=j,j}function n($,J="success",Q){let j=j0()?D().toast:void 0;if(j){j({message:$,tone:J,...Q?{action:Q}:{}});return}let z=T4();if(!z)return;let K=document.createElement("div");K.className="toast",K.dataset.tone=J;let W=document.createElement("span");W.className="dot";let X=document.createElement("span");X.textContent=$;let H=document.createElement("button");H.type="button",H.className="close",H.textContent="✕",H.setAttribute("aria-label","ปิด");let P=()=>{window.clearTimeout(w),K.remove()};H.addEventListener("click",P);let w=J==="error"||Q?0:window.setTimeout(P,R4);if(K.append(W,X),Q){let I=document.createElement("button");I.type="button",I.className="action",I.textContent=Q.label,I.addEventListener("click",()=>{P(),Q.onClick()}),K.append(I)}K.append(H),z.append(K)}function E1($,J,Q){let j=$.filter((K)=>Boolean(K.error)||K.status!=null&&K.status>=400).slice(-20).map((K)=>({method:K.method,url:K.url,status:K.status,error:K.error,at:K.startedAt})),z=J.filter((K)=>K.level==="error"||K.level==="exception"||K.level==="unhandledrejection").slice(-20).map((K)=>K.message);return{failedRequests:j,errors:z,erroredQueries:Q.slice(0,20)}}function L4(){let $={memoryUsedMb:null,memoryLimitMb:null,domContentLoadedMs:null,loadEventMs:null};if(typeof performance>"u")return $;let J=performance.memory;if(J)$.memoryUsedMb=Math.round(J.usedJSHeapSize/1024/1024),$.memoryLimitMb=Math.round(J.jsHeapSizeLimit/1024/1024);let[Q]=performance.getEntriesByType("navigation");if(Q)$.domContentLoadedMs=Math.round(Q.domContentLoadedEventEnd),$.loadEventMs=Math.round(Q.loadEventEnd);return $}function O0($,J){if(!$)return J;try{return $()}catch{return J}}function h1(){let $=D(),{pathname:J,search:Q,href:j}=window.location;return{capturedAt:new Date().toISOString(),route:{href:j,pathname:J,search:Q},module:p0(J),user:O0($.user,{}),apiHeaders:o(O0($.headers,{})),app:{name:g().name,version:g().version,environment:g().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:L4(),extra:O0($.extra,{})}}var f4=2;function m1($){let J=_1(),Q=W1();return{context:h1(),reason:$.reason,note:$.note,cause:E1(J,Q,$.erroredQueries),actionTrail:J1(),network:J,console:Q,screenshotDataUrl:$.screenshotDataUrl,screenshotMethod:$.screenshotMethod,replay:x1()??void 0,meta:{generatedBy:"lightwork-debug-capture",schemaVersion:f4}}}async function g1(){if(typeof navigator<"u"&&Boolean(navigator.mediaDevices?.getDisplayMedia)){let Q=await A4();if(Q.status==="ok")return{dataUrl:Q.dataUrl,method:"display-media"};if(Q.status==="cancelled")return{dataUrl:null,method:"cancelled"}}let J=await h4();if(J)return{dataUrl:J,method:"html-to-image"};return{dataUrl:null,method:"none"}}async function A4(){let $=null;try{let J={video:{frameRate:30},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude"};$=await navigator.mediaDevices.getDisplayMedia(J);let Q=await x4($);return Q?{status:"ok",dataUrl:Q}:{status:"error"}}catch(J){if(J instanceof DOMException&&(J.name==="NotAllowedError"||J.name==="AbortError"))return{status:"cancelled"};return{status:"error"}}finally{$?.getTracks().forEach((J)=>J.stop())}}async function x4($){let J=document.createElement("video");J.srcObject=$,J.muted=!0,J.playsInline=!0,await new Promise((W)=>{let X=!1,H=()=>{if(X)return;X=!0,W()};J.onloadedmetadata=()=>{J.play().then(H).catch(H)},window.setTimeout(H,1500)}),await E4(J);let{videoWidth:Q,videoHeight:j}=J;if(!Q||!j)return null;let z=document.createElement("canvas");z.width=Q,z.height=j;let K=z.getContext("2d");if(!K)return null;K.drawImage(J,0,0,Q,j),J.pause(),J.srcObject=null;try{return z.toDataURL("image/png")}catch{return null}}function E4($){return new Promise((J)=>{let Q=!1,j=()=>{if(Q)return;Q=!0,J()},z=$;if(typeof z.requestVideoFrameCallback==="function")z.requestVideoFrameCallback(()=>j()),window.setTimeout(j,1000);else window.setTimeout(j,250)})}async function h4(){let $=D().screenshotFallback;if(!$)return null;let J=await $().catch(()=>null);if(!J)return null;try{return await J(document.body,{cacheBust:!0,pixelRatio:Math.min(window.devicePixelRatio||1,2),filter:(Q)=>!(Q instanceof HTMLElement&&Q.dataset?.debugReporter==="true")})}catch{return null}}var m4=2000,g4=0.82,y4=3000000;function b4($){return new Promise((J,Q)=>{let j=new Image;j.onload=()=>J(j),j.onerror=()=>Q(Error("could not read the screenshot")),j.src=$})}async function y1($){try{let J=await b4($),Q=Math.max(J.naturalWidth,J.naturalHeight),j=Math.min(1,m4/Q),z=document.createElement("canvas");z.width=Math.max(1,Math.round(J.naturalWidth*j)),z.height=Math.max(1,Math.round(J.naturalHeight*j));let K=z.getContext("2d");if(!K)return $;K.fillStyle="#fff",K.fillRect(0,0,z.width,z.height),K.drawImage(J,0,0,z.width,z.height);let W=g4,X=z.toDataURL("image/jpeg",W);while(X.length>y4&&W>0.4)W-=0.15,X=z.toDataURL("image/jpeg",W);return X}catch{return $}}var p4=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,v4=/^\d+$/,u4=/^[0-9a-f]{16,}$/i;function b1($){if($.reason.type==="manual")return null;let J=$.cause?.failedRequests?.[0];if(!J?.url)return null;let Q;try{Q=new URL(J.url,"http://x").pathname}catch{Q=J.url}let j=Q.split("/").map((K)=>p4.test(K)||v4.test(K)||u4.test(K)?":id":K).join("/"),z=J.status??(J.error?"ERR":"?");return`${J.method??"REQ"} ${j} ${z}`}var p1=2000000;function F0($){let{screenshotDataUrl:J,replay:Q,...j}=$;return JSON.stringify(j).length}function v1($,J=2000000){if(F0($)<=J)return $;let Q=$.network.map((z)=>({...z})),j={...$,network:Q};for(let z of Q){if(F0(j)<=J)return j;if(typeof z.responseSnippet==="string"&&z.responseSnippet.length>35)z.responseSnippet="[body dropped — report size budget]";if(typeof z.requestBody==="string"&&z.requestBody.length>35)z.requestBody="[body dropped — report size budget]"}while(j.network.length>1&&F0(j)>J)j.network=j.network.slice(1);while(j.console.length>1&&F0(j)>J)j.console=j.console.slice(1);return j}function a($){let J="";for(let Q=0;Q<$.length;Q+=32768)J+=String.fromCharCode(...$.subarray(Q,Q+32768));return btoa(J)}var d4=4,i4=2,c4=3,o4=0,l4=new Set(["href","src","action","formaction","xlink:href","data","poster","srcset"]),s4=/^\s*javascript:/i;function r4($,J){let Q=$.toLowerCase();if(Q.startsWith("on")||Q==="srcdoc")return!0;return typeof J==="string"&&s4.test(J)}function u1($,J=!1){if(!$)return;for(let Q of Object.keys($)){let j=$[Q];if(r4(Q,j)){if(J)$[Q]=null;else delete $[Q];continue}if(typeof j!=="string"||!l4.has(Q)||!j.includes("?"))continue;$[Q]=E(j)}}function S0($){if(!$)return;u1($.attributes);for(let J of $.childNodes??[])S0(J)}function d1($){let J=JSON.parse(JSON.stringify($));for(let Q of J){let j=Q.data;if(!j||typeof j!=="object")continue;if(Q.type===d4&&typeof j.href==="string")j.href=E(j.href);else if(Q.type===i4)S0(j.node);else if(Q.type===c4&&j.source===o4){for(let z of j.adds??[])S0(z.node);for(let z of j.attributes??[])u1(z.attributes,!0)}}return J}var n4="session-replay.json.gz",a4="session-replay.json";function t4($){return Boolean($&&$.events.length>0)}async function e4($){if(typeof CompressionStream>"u")return null;try{let J=new Blob([$]).stream().pipeThrough(new CompressionStream("gzip"));return new Uint8Array(await new Response(J).arrayBuffer())}catch{return null}}async function c1($,J){if(!t4($))return{summary:{omitted:"empty"}};let j={seconds:Math.round($.durationMs/1000),events:$.events.length,startedAt:$.startedAt,endedAt:$.endedAt},z=d1($.events),K=await i1(z),W=!1;if(K.bytes.byteLength>J&&Q6(z))z=j6(z),K=await i1(z),W=!0;let{bytes:X,compressed:H}=K;if(X.byteLength>J)return{summary:{...j,bytes:X.byteLength,omitted:"too-large"}};return{dataUri:`data:${H?"application/gzip":"application/json"};base64,${a(X)}`,filename:H?n4:a4,summary:{...j,events:z.length,bytes:X.byteLength,compressed:H,...W?{canvasDropped:W}:{}}}}async function i1($){let J=new TextEncoder().encode(JSON.stringify({events:$})),Q=await e4(J);return Q?{bytes:Q,compressed:!0}:{bytes:J,compressed:!1}}var $6=3,o1=2,J6=9;function l1($){return $.type===$6&&$.data?.source===J6}function Q6($){return $.some(l1)||$.some((J)=>J.type===o1&&s1(J.data.node))}function s1($){if(!$)return!1;if($.attributes&&"rr_dataURL"in $.attributes)return!0;return($.childNodes??[]).some(s1)}function r1($){if(!$)return;if($.attributes&&"rr_dataURL"in $.attributes)delete $.attributes.rr_dataURL;for(let J of $.childNodes??[])r1(J)}function j6($){let J=[];for(let Q of $){if(l1(Q))continue;if(Q.type===o1)r1(Q.data.node);J.push(Q)}return J}var z6=new Set([502,503,504]);class y extends Error{kind;retryAfter;status;constructor($,J,Q,j){super($);this.kind=J;this.retryAfter=Q;this.status=j;this.name="ReportError"}}function Z6($){let{screenshotDataUrl:J,replay:Q,...j}=$;return{dataUri:`data:application/json;base64,${a(new TextEncoder().encode(JSON.stringify(j)))}`,filename:"debug-bundle.json"}}async function K6(){let $=D().identity;if(!$)return{};try{let J=await $();return J?{authorization:`Bearer ${J}`}:{}}catch{return{}}}async function n1($,J){let Q=D(),j=v1(J,p1),{context:z,note:K}=j,W=[];if(j.screenshotDataUrl){let M=await y1(j.screenshotDataUrl);W.push({dataUri:M,filename:"screenshot.jpg"})}W.push(Z6(j));let X,H=d();if(H){let M=await c1(j.replay,H.maxBytes);if(X=M.summary,"dataUri"in M)W.push({dataUri:M.dataUri,filename:M.filename})}let P=b1(j),w={title:$,description:K.trim()||void 0,appName:g().name,category:z.module?.label,routeUrl:z.route.href,priority:"MEDIUM",requesterEmail:z.user.email??void 0,requesterName:z.user.fullName??void 0,customFields:{unit:z.user.unit??"",appVersion:z.app.version,environment:z.app.environment,reasonType:j.reason.type,appName:g().name,module:z.module?.label??""},context:{...P?{signature:P}:{},capturedAt:z.capturedAt,reason:j.reason,cause:j.cause,actionTrail:j.actionTrail,client:z.client,performance:z.performance,apiHeaders:z.apiHeaders,extra:z.extra,counts:{network:j.network.length,console:j.console.length,actions:j.actionTrail.length},screenshotMethod:j.screenshotMethod,...X?{replay:X}:{}},attachments:W},I=await fetch(`${Q.host.replace(/\/$/,"")}/ingest/tickets`,{method:"POST",headers:{"content-type":"application/json","x-realm-key":Q.realmKey,...await K6()},body:JSON.stringify(w)}).catch(()=>{throw new y("report never left the browser","offline")});if(!I.ok){let M=I.headers.get("retry-after"),O=await I.json().then((B)=>B.error).catch(()=>null);if(I.status===429)throw new y("rate limited","rateLimited",M??void 0);if(z6.has(I.status))throw new y("desk unavailable","unavailable");throw new y(O??`Report failed (${I.status})`,"rejected",void 0,I.status)}return await I.json()}var t=Math.PI/6;function a1($,J,Q){let j=J.x-$.x,z=J.y-$.y,K=Math.hypot(j,z),W=Math.atan2(z,j),X=[{x:J.x,y:J.y},{x:J.x-Q*Math.cos(W-t),y:J.y-Q*Math.sin(W-t)},{x:J.x-Q*Math.cos(W+t),y:J.y-Q*Math.sin(W+t)}],H=Q*Math.cos(t)*0.92;if(K<=H)return{shaft:null,head:X};return{shaft:{from:$,to:{x:J.x-H*Math.cos(W),y:J.y-H*Math.sin(W)}},head:X}}var k0="#f44336",W6="rgba(250, 204, 21, 0.4)",R0=22,t1="#2563eb",e1=9,$2=11,J2=18,Q2=4,H0=8,G6=[{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 j2($,J,Q){let j=[],z=null,K=-1,W=null,X=null,H=$.getContext("2d");function P(){let Z=$.getBoundingClientRect().width;return Z>0?$.width/Z:1}function w(Z){let G=$.getBoundingClientRect();return{x:(Z.clientX-G.left)/G.width*$.width,y:(Z.clientY-G.top)/G.height*$.height}}function I(Z){let G=Z.size??R0;if(!H)return(Z.text?.length??0)*G*0.6;H.save(),H.font=`600 ${G}px system-ui, sans-serif`;let V=H.measureText(Z.text??"").width;return H.restore(),V}function M(Z){if(Z.tool==="text"){let G=Z.size??R0;return{left:Z.x1,top:Z.y1,right:Z.x1+I(Z),bottom:Z.y1+G*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 G=M(Z);if(Z.tool==="text")return[{id:"size",x:G.right,y:G.bottom,cursor:"nwse-resize"}];return G6.map((V)=>({id:V.id,x:G.left+(G.right-G.left)*V.fx,y:G.top+(G.bottom-G.top)*V.fy,cursor:V.cursor}))}function B(Z){let G=M(Z);return{x:G.right+J2*P(),y:G.top-J2*P()}}function k(Z,G,V){let{shaft:Y,head:F}=a1({x:G.x1,y:G.y1},{x:G.x2,y:G.y2},Math.max(10,16*V));if(Y)Z.lineCap="butt",Z.beginPath(),Z.moveTo(Y.from.x,Y.from.y),Z.lineTo(Y.to.x,Y.to.y),Z.stroke();Z.beginPath(),Z.moveTo(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 L(Z,G,V){Z.save(),Z.lineWidth=Math.max(2,3*V),Z.strokeStyle=k0,Z.fillStyle=k0;let Y=M(G);if(G.tool==="rect")Z.strokeRect(Y.left,Y.top,Y.right-Y.left,Y.bottom-Y.top);else if(G.tool==="arrow")k(Z,G,V);else if(G.tool==="highlight")Z.fillStyle=W6,Z.fillRect(Y.left,Y.top,Y.right-Y.left,Y.bottom-Y.top);else if(G.tool==="text"&&G.text){let F=G.size??R0;Z.font=`600 ${F}px system-ui, sans-serif`,Z.textBaseline="top";let U=F*0.22;Z.fillStyle="rgba(255,255,255,0.92)",Z.fillRect(Y.left-U,Y.top-U,Y.right-Y.left+U*2,Y.bottom-Y.top+U*2),Z.fillStyle=k0,Z.fillText(G.text,Y.left,Y.top)}Z.restore()}function $0(Z,G,V){let Y=M(G);Z.save(),Z.strokeStyle=t1,Z.lineWidth=Math.max(1,1.5*V),Z.setLineDash([6*V,4*V]),Z.strokeRect(Y.left,Y.top,Y.right-Y.left,Y.bottom-Y.top),Z.setLineDash([]);let F=e1*V;for(let R of O(G))Z.fillStyle="#fff",Z.strokeStyle=t1,Z.lineWidth=Math.max(1,1.5*V),Z.beginPath(),Z.rect(R.x-F/2,R.y-F/2,F,F),Z.fill(),Z.stroke();let U=B(G),q=$2*V;Z.beginPath(),Z.arc(U.x,U.y,q,0,Math.PI*2),Z.fillStyle="#dc2626",Z.fill(),Z.strokeStyle="#fff",Z.lineWidth=Math.max(1.5,2*V),Z.beginPath(),Z.moveTo(U.x-q*0.4,U.y-q*0.4),Z.lineTo(U.x+q*0.4,U.y+q*0.4),Z.moveTo(U.x+q*0.4,U.y-q*0.4),Z.lineTo(U.x-q*0.4,U.y+q*0.4),Z.stroke(),Z.restore()}function C(){if(!H)return;let Z=P();if(H.clearRect(0,0,$.width,$.height),H.drawImage(J,0,0,$.width,$.height),j.forEach((V,Y)=>{if(Y!==J0)L(H,V,Z)}),W)L(H,W,Z);let G=j[K];if(G&&!W)$0(H,G,Z)}function T0(Z,G,V,Y,F){return Math.abs(Z-V)<=F&&Math.abs(G-Y)<=F}function L0(Z,G){let V=j[K];if(!V)return null;let Y=e1*P()/2+3*P();for(let F of O(V))if(T0(Z,G,F.x,F.y,Y))return F.id;return null}function f0(Z,G){let V=j[K];if(!V)return!1;let Y=B(V);return T0(Z,G,Y.x,Y.y,$2*P())}function U0(Z,G){let V=6*P();for(let Y=j.length-1;Y>=0;Y-=1){let F=j[Y];if(F.tool==="arrow"){let q=F.x2-F.x1,R=F.y2-F.y1,h=Math.hypot(q,R)||1,m=Math.max(0,Math.min(1,((Z-F.x1)*q+(G-F.y1)*R)/(h*h)));if(Math.hypot(Z-(F.x1+m*q),G-(F.y1+m*R))<=V+4*P())return Y;continue}let U=M(F);if(Z>=U.left-V&&Z<=U.right+V&&G>=U.top-V&&G<=U.bottom+V)return Y}return-1}function Y2(Z,G,V,Y,F){if(G==="tail"){Z.x1=V.x1+Y,Z.y1=V.y1+F;return}if(G==="head"){Z.x2=V.x2+Y,Z.y2=V.y2+F;return}if(G==="size"){let H2=(V.size??24)+F;Z.size=Math.max(10,H2);return}let U=M(V),{left:q,top:R,right:h,bottom:m}=U;if(G.includes("w"))q=Math.min(h-H0,q+Y);if(G.includes("e"))h=Math.max(q+H0,h+Y);if(G.includes("n"))R=Math.min(m-H0,R+F);if(G.includes("s"))m=Math.max(R+H0,m+F);Z.x1=q,Z.y1=R,Z.x2=h,Z.y2=m}function V2(Z,G,V,Y){Z.x1=G.x1+V,Z.y1=G.y1+Y,Z.x2=G.x2+V,Z.y2=G.y2+Y}let f=null,J0=-1,A={x:0,y:0,size:24};function X2(){let Z=$.getBoundingClientRect().width;return Z>0?Z/$.width:1}function F2(Z,G){if(!H)return Z.length*G*0.6;H.save(),H.font=`600 ${G}px system-ui, sans-serif`;let V=H.measureText(Z||" ").width;return H.restore(),V}function A0(){if(!f)return;let Z=$.parentElement;if(!Z)return;let G=$.getBoundingClientRect(),V=Z.getBoundingClientRect(),Y=X2(),F=A.size*Y;f.style.left=`${G.left-V.left+A.x*Y}px`,f.style.top=`${G.top-V.top+A.y*Y}px`,f.style.fontSize=`${F}px`,f.style.width=`${Math.max(40,F2(f.value,F)+F)}px`}function u(Z){let G=f;if(!G)return;f=null;let V=G.value.trim(),Y=J0;if(J0=-1,G.remove(),Z&&V){if(Y>=0&&j[Y])j[Y].text=V,K=Y;else j.push({tool:"text",x1:A.x,y1:A.y,x2:A.x,y2:A.y,text:V,size:A.size}),K=j.length-1;Q()}else if(Y>=0)K=Y;$.focus(),C()}function x0(Z,G,V=-1){u(!0);let Y=$.parentElement;if(!Y)return;if(getComputedStyle(Y).position==="static")Y.style.position="relative";let F=V>=0?j[V]:void 0;J0=V,A={x:F?.x1??Z,y:F?.y1??G,size:F?.size??Math.round(24*P())};let U=document.createElement("input");U.type="text",U.className="text-edit",U.value=F?.text??"",U.setAttribute("aria-label","ข้อความบนภาพ"),U.placeholder="ข้อความ",f=U,Y.append(U),A0(),U.addEventListener("input",A0),U.addEventListener("keydown",(q)=>{if(q.stopPropagation(),q.key==="Enter")u(!0);else if(q.key==="Escape")u(!1)}),requestAnimationFrame(()=>{if(f!==U)return;U.focus(),U.select(),U.addEventListener("blur",()=>u(!0))}),C()}function E0(Z){let{x:G,y:V}=w(Z);if($.setPointerCapture(Z.pointerId),f0(G,V)){P0();return}let Y=L0(G,V);if(Y&&j[K]){X={grip:Y,x:G,y:V,start:{...j[K]}};return}if(z==="text"){if(Z.preventDefault(),$.hasPointerCapture(Z.pointerId))$.releasePointerCapture(Z.pointerId);z=null,Q(),x0(G,V);return}if(z){W={tool:z,x1:G,y1:V,x2:G,y2:V},K=-1;return}let F=U0(G,V);K=F,X=F>=0?{grip:"body",x:G,y:V,start:{...j[F]}}:null,C()}function h0(Z){let{x:G,y:V}=w(Z);if(W){W.x2=G,W.y2=V,C();return}if(X){let F=j[K];if(!F)return;let U=G-X.x,q=V-X.y;if(X.grip==="body")V2(F,X.start,U,q);else Y2(F,X.grip,X.start,U,q);C();return}if(z){$.style.cursor="crosshair";return}if(f0(G,V)){$.style.cursor="pointer";return}let Y=L0(G,V);if(Y){let F=j[K]?O(j[K]).find((U)=>U.id===Y):null;$.style.cursor=F?.cursor??"pointer";return}$.style.cursor=U0(G,V)>=0?"move":"default"}function Q0(){if(W){if(!(Math.abs(W.x2-W.x1)<Q2&&Math.abs(W.y2-W.y1)<Q2))j.push(W),K=j.length-1,z=null,Q();W=null}if(X)X=null,Q();C()}function m0(Z){let G=$.getBoundingClientRect(),V=(Z.clientX-G.left)/G.width*$.width,Y=(Z.clientY-G.top)/G.height*$.height,F=U0(V,Y),U=j[F];if(!U||U.tool!=="text")return;Z.preventDefault(),x0(U.x1,U.y1,F)}function g0(Z){if(K<0)return;if(Z.key==="Delete"||Z.key==="Backspace")Z.preventDefault(),P0();else if(Z.key==="Escape")K=-1,C()}function P0(){if(K<0)return;j.splice(K,1),K=-1,Q(),C()}return $.addEventListener("pointerdown",E0),$.addEventListener("pointermove",h0),$.addEventListener("pointerup",Q0),$.addEventListener("pointercancel",Q0),$.addEventListener("dblclick",m0),$.tabIndex=0,$.addEventListener("keydown",g0),C(),{setTool(Z){z=Z,K=-1,$.style.cursor=Z?"crosshair":"default",C()},deleteSelected:P0,clear(){j.length=0,K=-1,Q(),C()},hasShapes:()=>j.length>0,hasSelection:()=>K>=0,toDataUrl(){let Z=document.createElement("canvas");Z.width=J.naturalWidth,Z.height=J.naturalHeight;let G=Z.getContext("2d");if(!G)return $.toDataURL("image/png");G.drawImage(J,0,0);let V=P();for(let Y of j)L(G,Y,V);return Z.toDataURL("image/png")},destroy(){u(!1),$.removeEventListener("pointerdown",E0),$.removeEventListener("pointermove",h0),$.removeEventListener("pointerup",Q0),$.removeEventListener("pointercancel",Q0),$.removeEventListener("dblclick",m0),$.removeEventListener("keydown",g0)}}}var z2=`
33
+ `,N0=null;function L4(){if(typeof document>"u")return null;if(N0?.isConnected)return N0;let $=document.createElement(R4);$.dataset.debugReporter="true";let J=$.attachShadow({mode:"open"}),Q=document.createElement("style");Q.textContent=T4;let j=document.createElement("div");return j.className="stack",j.setAttribute("role","status"),j.setAttribute("aria-live","polite"),J.append(Q,j),document.body.append($),N0=j,j}function n($,J="success",Q){let j=j0()?C().toast:void 0;if(j){j({message:$,tone:J,...Q?{action:Q}:{}});return}let z=L4();if(!z)return;let K=document.createElement("div");K.className="toast",K.dataset.tone=J;let W=document.createElement("span");W.className="dot";let X=document.createElement("span");X.textContent=$;let H=document.createElement("button");H.type="button",H.className="close",H.textContent="✕",H.setAttribute("aria-label","ปิด");let U=()=>{window.clearTimeout(N),K.remove()};H.addEventListener("click",U);let N=J==="error"||Q?0:window.setTimeout(U,_4);if(K.append(W,X),Q){let M=document.createElement("button");M.type="button",M.className="action",M.textContent=Q.label,M.addEventListener("click",()=>{U(),Q.onClick()}),K.append(M)}K.append(H),z.append(K)}function x1($,J,Q){let j=$.filter((K)=>Boolean(K.error)||K.status!=null&&K.status>=400).slice(-20).map((K)=>({method:K.method,url:K.url,status:K.status,error:K.error,at:K.startedAt})),z=J.filter((K)=>K.level==="error"||K.level==="exception"||K.level==="unhandledrejection").slice(-20).map((K)=>K.message);return{failedRequests:j,errors:z,erroredQueries:Q.slice(0,20)}}function 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[Q]=performance.getEntriesByType("navigation");if(Q)$.domContentLoadedMs=Math.round(Q.domContentLoadedEventEnd),$.loadEventMs=Math.round(Q.loadEventEnd);return $}function k0($,J){if(!$)return J;try{return $()}catch{return J}}function E1(){let $=C(),{pathname:J,search:Q,href:j}=window.location;return{capturedAt:new Date().toISOString(),route:{href:j,pathname:J,search:Q},module:p0(J),user:k0($.user,{}),apiHeaders:o(k0($.headers,{})),app:{name:g().name,version:g().version,environment:g().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:k0($.extra,{})}}var A4=2;function m1($){let J=_1(),Q=W1();return{context:E1(),reason:$.reason,note:$.note,cause:x1(J,Q,$.erroredQueries),actionTrail:J1(),network:J,console:Q,screenshotDataUrl:$.screenshotDataUrl,screenshotMethod:$.screenshotMethod,replay:h1()??void 0,meta:{generatedBy:"lightwork-debug-capture",schemaVersion:A4}}}async function g1(){if(typeof navigator<"u"&&Boolean(navigator.mediaDevices?.getDisplayMedia)){let Q=await h4();if(Q.status==="ok")return{dataUrl:Q.dataUrl,method:"display-media"};if(Q.status==="cancelled")return{dataUrl:null,method:"cancelled"}}let J=await m4();if(J)return{dataUrl:J,method:"html-to-image"};return{dataUrl:null,method:"none"}}async function h4(){let $=null;try{let J={video:{frameRate:30},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude"};$=await navigator.mediaDevices.getDisplayMedia(J);let Q=await x4($);return Q?{status:"ok",dataUrl:Q}:{status:"error"}}catch(J){if(J instanceof DOMException&&(J.name==="NotAllowedError"||J.name==="AbortError"))return{status:"cancelled"};return{status:"error"}}finally{$?.getTracks().forEach((J)=>J.stop())}}async function x4($){let J=document.createElement("video");J.srcObject=$,J.muted=!0,J.playsInline=!0,await new Promise((W)=>{let X=!1,H=()=>{if(X)return;X=!0,W()};J.onloadedmetadata=()=>{J.play().then(H).catch(H)},window.setTimeout(H,1500)}),await E4(J);let{videoWidth:Q,videoHeight:j}=J;if(!Q||!j)return null;let z=document.createElement("canvas");z.width=Q,z.height=j;let K=z.getContext("2d");if(!K)return null;K.drawImage(J,0,0,Q,j),J.pause(),J.srcObject=null;try{return z.toDataURL("image/png")}catch{return null}}function E4($){return new Promise((J)=>{let Q=!1,j=()=>{if(Q)return;Q=!0,J()},z=$;if(typeof z.requestVideoFrameCallback==="function")z.requestVideoFrameCallback(()=>j()),window.setTimeout(j,1000);else window.setTimeout(j,250)})}async function m4(){let $=C().screenshotFallback;if(!$)return null;let J=await $().catch(()=>null);if(!J)return null;try{return await J(document.body,{cacheBust:!0,pixelRatio:Math.min(window.devicePixelRatio||1,2),filter:(Q)=>!(Q instanceof HTMLElement&&Q.dataset?.debugReporter==="true")})}catch{return null}}var g4=2000,y4=0.82,b4=3000000;function p4($){return new Promise((J,Q)=>{let j=new Image;j.onload=()=>J(j),j.onerror=()=>Q(Error("could not read the screenshot")),j.src=$})}async function y1($){try{let J=await p4($),Q=Math.max(J.naturalWidth,J.naturalHeight),j=Math.min(1,g4/Q),z=document.createElement("canvas");z.width=Math.max(1,Math.round(J.naturalWidth*j)),z.height=Math.max(1,Math.round(J.naturalHeight*j));let K=z.getContext("2d");if(!K)return $;K.fillStyle="#fff",K.fillRect(0,0,z.width,z.height),K.drawImage(J,0,0,z.width,z.height);let W=y4,X=z.toDataURL("image/jpeg",W);while(X.length>b4&&W>0.4)W-=0.15,X=z.toDataURL("image/jpeg",W);return X}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,u4=/^\d+$/,d4=/^[0-9a-f]{16,}$/i;function b1($){if($.reason.type==="manual")return null;let J=$.cause?.failedRequests?.[0];if(!J?.url)return null;let Q;try{Q=new URL(J.url,"http://x").pathname}catch{Q=J.url}let j=Q.split("/").map((K)=>v4.test(K)||u4.test(K)||d4.test(K)?":id":K).join("/"),z=J.status??(J.error?"ERR":"?");return`${J.method??"REQ"} ${j} ${z}`}var p1=2000000;function F0($){let{screenshotDataUrl:J,replay:Q,...j}=$;return JSON.stringify(j).length}function v1($,J=2000000){if(F0($)<=J)return $;let Q=$.network.map((z)=>({...z})),j={...$,network:Q};for(let z of Q){if(F0(j)<=J)return j;if(typeof z.responseSnippet==="string"&&z.responseSnippet.length>35)z.responseSnippet="[body dropped — report size budget]";if(typeof z.requestBody==="string"&&z.requestBody.length>35)z.requestBody="[body dropped — report size budget]"}while(j.network.length>1&&F0(j)>J)j.network=j.network.slice(1);while(j.console.length>1&&F0(j)>J)j.console=j.console.slice(1);return j}function a($){let J="";for(let Q=0;Q<$.length;Q+=32768)J+=String.fromCharCode(...$.subarray(Q,Q+32768));return btoa(J)}var i4=4,c4=2,o4=3,l4=0,s4=new Set(["href","src","action","formaction","xlink:href","data","poster","srcset"]),r4=/^\s*javascript:/i;function n4($,J){let Q=$.toLowerCase();if(Q.startsWith("on")||Q==="srcdoc")return!0;return typeof J==="string"&&r4.test(J)}function u1($,J=!1){if(!$)return;for(let Q of Object.keys($)){let j=$[Q];if(n4(Q,j)){if(J)$[Q]=null;else delete $[Q];continue}if(typeof j!=="string"||!s4.has(Q)||!j.includes("?"))continue;$[Q]=x(j)}}function S0($){if(!$)return;u1($.attributes);for(let J of $.childNodes??[])S0(J)}function d1($){let J=JSON.parse(JSON.stringify($));for(let Q of J){let j=Q.data;if(!j||typeof j!=="object")continue;if(Q.type===i4&&typeof j.href==="string")j.href=x(j.href);else if(Q.type===c4)S0(j.node);else if(Q.type===o4&&j.source===l4){for(let z of j.adds??[])S0(z.node);for(let z of j.attributes??[])u1(z.attributes,!0)}}return J}var a4="session-replay.json.gz",t4="session-replay.json";function e4($){return Boolean($&&$.events.length>0)}async function $6($){if(typeof CompressionStream>"u")return null;try{let J=new Blob([$]).stream().pipeThrough(new CompressionStream("gzip"));return new Uint8Array(await new Response(J).arrayBuffer())}catch{return null}}async function c1($,J){if(!e4($))return{summary:{omitted:"empty"}};let j={seconds:Math.round($.durationMs/1000),events:$.events.length,startedAt:$.startedAt,endedAt:$.endedAt},z=d1($.events),K=await i1(z),W=!1;if(K.bytes.byteLength>J&&j6(z))z=z6(z),K=await i1(z),W=!0;let{bytes:X,compressed:H}=K;if(X.byteLength>J)return{summary:{...j,bytes:X.byteLength,omitted:"too-large"}};return{dataUri:`data:${H?"application/gzip":"application/json"};base64,${a(X)}`,filename:H?a4:t4,summary:{...j,events:z.length,bytes:X.byteLength,compressed:H,...W?{canvasDropped:W}:{}}}}async function i1($){let J=new TextEncoder().encode(JSON.stringify({events:$})),Q=await $6(J);return Q?{bytes:Q,compressed:!0}:{bytes:J,compressed:!1}}var J6=3,o1=2,Q6=9;function l1($){return $.type===J6&&$.data?.source===Q6}function j6($){return $.some(l1)||$.some((J)=>J.type===o1&&s1(J.data.node))}function s1($){if(!$)return!1;if($.attributes&&"rr_dataURL"in $.attributes)return!0;return($.childNodes??[]).some(s1)}function r1($){if(!$)return;if($.attributes&&"rr_dataURL"in $.attributes)delete $.attributes.rr_dataURL;for(let J of $.childNodes??[])r1(J)}function z6($){let J=[];for(let Q of $){if(l1(Q))continue;if(Q.type===o1)r1(Q.data.node);J.push(Q)}return J}var Z6=new Set([502,503,504]);class y extends Error{kind;retryAfter;status;constructor($,J,Q,j){super($);this.kind=J;this.retryAfter=Q;this.status=j;this.name="ReportError"}}function K6($){let{screenshotDataUrl:J,replay:Q,...j}=$;return{dataUri:`data:application/json;base64,${a(new TextEncoder().encode(JSON.stringify(j)))}`,filename:"debug-bundle.json"}}async function W6(){let $=C().identity;if(!$)return{};try{let J=await $();return J?{authorization:`Bearer ${J}`}:{}}catch{return{}}}async function n1($,J){let Q=C(),j=v1(J,p1),{context:z,note:K}=j,W=[];if(j.screenshotDataUrl){let I=await y1(j.screenshotDataUrl);W.push({dataUri:I,filename:"screenshot.jpg"})}W.push(K6(j));let X,H=d();if(H){let I=await c1(j.replay,H.maxBytes);if(X=I.summary,"dataUri"in I)W.push({dataUri:I.dataUri,filename:I.filename})}let U=b1(j),N={title:$,description:K.trim()||void 0,appName:g().name,category:z.module?.label,routeUrl:z.route.href,priority:"MEDIUM",requesterEmail:z.user.email??void 0,requesterName:z.user.fullName??void 0,customFields:{unit:z.user.unit??"",appVersion:z.app.version,environment:z.app.environment,reasonType:j.reason.type,appName:g().name,module:z.module?.label??""},context:{...U?{signature:U}:{},capturedAt:z.capturedAt,reason:j.reason,cause:j.cause,actionTrail:j.actionTrail,client:z.client,performance:z.performance,apiHeaders:z.apiHeaders,extra:z.extra,counts:{network:j.network.length,console:j.console.length,actions:j.actionTrail.length},screenshotMethod:j.screenshotMethod,...X?{replay:X}:{}},attachments:W},M=await fetch(`${Q.host.replace(/\/$/,"")}/ingest/tickets`,{method:"POST",headers:{"content-type":"application/json","x-realm-key":Q.realmKey,...await W6()},body:JSON.stringify(N)}).catch(()=>{throw new y("report never left the browser","offline")});if(!M.ok){let I=M.headers.get("retry-after"),k=await M.json().then((w)=>w.error).catch(()=>null);if(M.status===429)throw new y("rate limited","rateLimited",I??void 0);if(Z6.has(M.status))throw new y("desk unavailable","unavailable");throw new y(k??`Report failed (${M.status})`,"rejected",void 0,M.status)}return await M.json()}var t=Math.PI/6;function a1($,J,Q){let j=J.x-$.x,z=J.y-$.y,K=Math.hypot(j,z),W=Math.atan2(z,j),X=[{x:J.x,y:J.y},{x:J.x-Q*Math.cos(W-t),y:J.y-Q*Math.sin(W-t)},{x:J.x-Q*Math.cos(W+t),y:J.y-Q*Math.sin(W+t)}],H=Q*Math.cos(t)*0.92;if(K<=H)return{shaft:null,head:X};return{shaft:{from:$,to:{x:J.x-H*Math.cos(W),y:J.y-H*Math.sin(W)}},head:X}}var O0="#f44336",Y6="rgba(250, 204, 21, 0.4)",R0=22,t1="#2563eb",e1=9,$2=11,J2=18,Q2=4,H0=8,G6=[{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 j2($,J,Q){let j=[],z=null,K=-1,W=null,X=null,H=$.getContext("2d");function U(){let Z=$.getBoundingClientRect().width;return Z>0?$.width/Z:1}function N(Z){let Y=$.getBoundingClientRect();return{x:(Z.clientX-Y.left)/Y.width*$.width,y:(Z.clientY-Y.top)/Y.height*$.height}}function M(Z){let Y=Z.size??R0;if(!H)return(Z.text?.length??0)*Y*0.6;H.save(),H.font=`600 ${Y}px system-ui, sans-serif`;let V=H.measureText(Z.text??"").width;return H.restore(),V}function I(Z){if(Z.tool==="text"){let Y=Z.size??R0;return{left:Z.x1,top:Z.y1,right:Z.x1+M(Z),bottom:Z.y1+Y*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 k(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 Y=I(Z);if(Z.tool==="text")return[{id:"size",x:Y.right,y:Y.bottom,cursor:"nwse-resize"}];return G6.map((V)=>({id:V.id,x:Y.left+(Y.right-Y.left)*V.fx,y:Y.top+(Y.bottom-Y.top)*V.fy,cursor:V.cursor}))}function w(Z){let Y=I(Z);return{x:Y.right+J2*U(),y:Y.top-J2*U()}}function O(Z,Y,V){let{shaft:G,head:F}=a1({x:Y.x1,y:Y.y1},{x:Y.x2,y:Y.y2},Math.max(10,16*V));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 L(Z,Y,V){Z.save(),Z.lineWidth=Math.max(2,3*V),Z.strokeStyle=O0,Z.fillStyle=O0;let G=I(Y);if(Y.tool==="rect")Z.strokeRect(G.left,G.top,G.right-G.left,G.bottom-G.top);else if(Y.tool==="arrow")O(Z,Y,V);else if(Y.tool==="highlight")Z.fillStyle=Y6,Z.fillRect(G.left,G.top,G.right-G.left,G.bottom-G.top);else if(Y.tool==="text"&&Y.text){let F=Y.size??R0;Z.font=`600 ${F}px system-ui, sans-serif`,Z.textBaseline="top";let P=F*0.22;Z.fillStyle="rgba(255,255,255,0.92)",Z.fillRect(G.left-P,G.top-P,G.right-G.left+P*2,G.bottom-G.top+P*2),Z.fillStyle=O0,Z.fillText(Y.text,G.left,G.top)}Z.restore()}function $0(Z,Y,V){let G=I(Y);Z.save(),Z.strokeStyle=t1,Z.lineWidth=Math.max(1,1.5*V),Z.setLineDash([6*V,4*V]),Z.strokeRect(G.left,G.top,G.right-G.left,G.bottom-G.top),Z.setLineDash([]);let F=e1*V;for(let R of k(Y))Z.fillStyle="#fff",Z.strokeStyle=t1,Z.lineWidth=Math.max(1,1.5*V),Z.beginPath(),Z.rect(R.x-F/2,R.y-F/2,F,F),Z.fill(),Z.stroke();let P=w(Y),q=$2*V;Z.beginPath(),Z.arc(P.x,P.y,q,0,Math.PI*2),Z.fillStyle="#dc2626",Z.fill(),Z.strokeStyle="#fff",Z.lineWidth=Math.max(1.5,2*V),Z.beginPath(),Z.moveTo(P.x-q*0.4,P.y-q*0.4),Z.lineTo(P.x+q*0.4,P.y+q*0.4),Z.moveTo(P.x+q*0.4,P.y-q*0.4),Z.lineTo(P.x-q*0.4,P.y+q*0.4),Z.stroke(),Z.restore()}function B(){if(!H)return;let Z=U();if(H.clearRect(0,0,$.width,$.height),H.drawImage(J,0,0,$.width,$.height),j.forEach((V,G)=>{if(G!==J0)L(H,V,Z)}),W)L(H,W,Z);let Y=j[K];if(Y&&!W)$0(H,Y,Z)}function T0(Z,Y,V,G,F){return Math.abs(Z-V)<=F&&Math.abs(Y-G)<=F}function L0(Z,Y){let V=j[K];if(!V)return null;let G=e1*U()/2+3*U();for(let F of k(V))if(T0(Z,Y,F.x,F.y,G))return F.id;return null}function f0(Z,Y){let V=j[K];if(!V)return!1;let G=w(V);return T0(Z,Y,G.x,G.y,$2*U())}function P0(Z,Y){let V=6*U();for(let G=j.length-1;G>=0;G-=1){let F=j[G];if(F.tool==="arrow"){let q=F.x2-F.x1,R=F.y2-F.y1,E=Math.hypot(q,R)||1,m=Math.max(0,Math.min(1,((Z-F.x1)*q+(Y-F.y1)*R)/(E*E)));if(Math.hypot(Z-(F.x1+m*q),Y-(F.y1+m*R))<=V+4*U())return G;continue}let P=I(F);if(Z>=P.left-V&&Z<=P.right+V&&Y>=P.top-V&&Y<=P.bottom+V)return G}return-1}function V2(Z,Y,V,G,F){if(Y==="tail"){Z.x1=V.x1+G,Z.y1=V.y1+F;return}if(Y==="head"){Z.x2=V.x2+G,Z.y2=V.y2+F;return}if(Y==="size"){let P2=(V.size??24)+F;Z.size=Math.max(10,P2);return}let P=I(V),{left:q,top:R,right:E,bottom:m}=P;if(Y.includes("w"))q=Math.min(E-H0,q+G);if(Y.includes("e"))E=Math.max(q+H0,E+G);if(Y.includes("n"))R=Math.min(m-H0,R+F);if(Y.includes("s"))m=Math.max(R+H0,m+F);Z.x1=q,Z.y1=R,Z.x2=E,Z.y2=m}function X2(Z,Y,V,G){Z.x1=Y.x1+V,Z.y1=Y.y1+G,Z.x2=Y.x2+V,Z.y2=Y.y2+G}let f=null,J0=-1,A={x:0,y:0,size:24};function F2(){let Z=$.getBoundingClientRect().width;return Z>0?Z/$.width:1}function H2(Z,Y){if(!H)return Z.length*Y*0.6;H.save(),H.font=`600 ${Y}px system-ui, sans-serif`;let V=H.measureText(Z||" ").width;return H.restore(),V}function A0(){if(!f)return;let Z=$.parentElement;if(!Z)return;let Y=$.getBoundingClientRect(),V=Z.getBoundingClientRect(),G=F2(),F=A.size*G;f.style.left=`${Y.left-V.left+A.x*G}px`,f.style.top=`${Y.top-V.top+A.y*G}px`,f.style.fontSize=`${F}px`,f.style.width=`${Math.max(40,H2(f.value,F)+F)}px`}function u(Z){let Y=f;if(!Y)return;f=null;let V=Y.value.trim(),G=J0;if(J0=-1,Y.remove(),Z&&V){if(G>=0&&j[G])j[G].text=V,K=G;else j.push({tool:"text",x1:A.x,y1:A.y,x2:A.x,y2:A.y,text:V,size:A.size}),K=j.length-1;Q()}else if(G>=0)K=G;$.focus(),B()}function h0(Z,Y,V=-1){u(!0);let G=$.parentElement;if(!G)return;if(getComputedStyle(G).position==="static")G.style.position="relative";let F=V>=0?j[V]:void 0;J0=V,A={x:F?.x1??Z,y:F?.y1??Y,size:F?.size??Math.round(24*U())};let P=document.createElement("input");P.type="text",P.className="text-edit",P.value=F?.text??"",P.setAttribute("aria-label","ข้อความบนภาพ"),P.placeholder="ข้อความ",f=P,G.append(P),A0(),P.addEventListener("input",A0),P.addEventListener("keydown",(q)=>{if(q.stopPropagation(),q.key==="Enter")u(!0);else if(q.key==="Escape")u(!1)}),requestAnimationFrame(()=>{if(f!==P)return;P.focus(),P.select(),P.addEventListener("blur",()=>u(!0))}),B()}function x0(Z){let{x:Y,y:V}=N(Z);if($.setPointerCapture(Z.pointerId),f0(Y,V)){U0();return}let G=L0(Y,V);if(G&&j[K]){X={grip:G,x:Y,y:V,start:{...j[K]}};return}if(z==="text"){if(Z.preventDefault(),$.hasPointerCapture(Z.pointerId))$.releasePointerCapture(Z.pointerId);z=null,Q(),h0(Y,V);return}if(z){W={tool:z,x1:Y,y1:V,x2:Y,y2:V},K=-1;return}let F=P0(Y,V);K=F,X=F>=0?{grip:"body",x:Y,y:V,start:{...j[F]}}:null,B()}function E0(Z){let{x:Y,y:V}=N(Z);if(W){W.x2=Y,W.y2=V,B();return}if(X){let F=j[K];if(!F)return;let P=Y-X.x,q=V-X.y;if(X.grip==="body")X2(F,X.start,P,q);else V2(F,X.grip,X.start,P,q);B();return}if(z){$.style.cursor="crosshair";return}if(f0(Y,V)){$.style.cursor="pointer";return}let G=L0(Y,V);if(G){let F=j[K]?k(j[K]).find((P)=>P.id===G):null;$.style.cursor=F?.cursor??"pointer";return}$.style.cursor=P0(Y,V)>=0?"move":"default"}function Q0(){if(W){if(!(Math.abs(W.x2-W.x1)<Q2&&Math.abs(W.y2-W.y1)<Q2))j.push(W),K=j.length-1,z=null,Q();W=null}if(X)X=null,Q();B()}function m0(Z){let Y=$.getBoundingClientRect(),V=(Z.clientX-Y.left)/Y.width*$.width,G=(Z.clientY-Y.top)/Y.height*$.height,F=P0(V,G),P=j[F];if(!P||P.tool!=="text")return;Z.preventDefault(),h0(P.x1,P.y1,F)}function g0(Z){if(K<0)return;if(Z.key==="Delete"||Z.key==="Backspace")Z.preventDefault(),U0();else if(Z.key==="Escape")K=-1,B()}function U0(){if(K<0)return;j.splice(K,1),K=-1,Q(),B()}return $.addEventListener("pointerdown",x0),$.addEventListener("pointermove",E0),$.addEventListener("pointerup",Q0),$.addEventListener("pointercancel",Q0),$.addEventListener("dblclick",m0),$.tabIndex=0,$.addEventListener("keydown",g0),B(),{setTool(Z){z=Z,K=-1,$.style.cursor=Z?"crosshair":"default",B()},deleteSelected:U0,clear(){j.length=0,K=-1,Q(),B()},hasShapes:()=>j.length>0,hasSelection:()=>K>=0,toDataUrl(){let Z=document.createElement("canvas");Z.width=J.naturalWidth,Z.height=J.naturalHeight;let Y=Z.getContext("2d");if(!Y)return $.toDataURL("image/png");Y.drawImage(J,0,0);let V=U();for(let G of j)L(Y,G,V);return Z.toDataURL("image/png")},destroy(){u(!1),$.removeEventListener("pointerdown",x0),$.removeEventListener("pointermove",E0),$.removeEventListener("pointerup",Q0),$.removeEventListener("pointercancel",Q0),$.removeEventListener("dblclick",m0),$.removeEventListener("keydown",g0)}}}var V6=["keydown","keyup","keypress"];function z2($){for(let J of V6)$.addEventListener(J,(Q)=>Q.stopPropagation())}var Z2=`
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 e="lw-debug-reporter";function Y6($,J){if($ instanceof y){if($.kind==="offline")return J.failedOffline;if($.kind==="unavailable")return J.failedUnavailable;if($.kind==="rateLimited")return J.failedTooMany.replace("{seconds}",$.retryAfter??"60");return $.message||J.failed}return J.failed}var V6=()=>[];var X6=[{tool:"rect",key:"toolRect"},{tool:"arrow",key:"toolArrow"},{tool:"highlight",key:"toolHighlight"},{tool:"text",key:"toolText"}];function F6(){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=F1((J)=>void this.open(J))}disconnectedCallback(){this.stop?.(),this.stop=null,this.close()}async open(J){if(this.busy)return;this.busy=!0;let Q=X0(D().locale),j=await g1();if(j.method==="cancelled"){this.close();return}this.bundle=m1({reason:J,note:"",screenshotDataUrl:j.dataUrl,screenshotMethod:j.method,erroredQueries:H6()}),this.renderForm(Q)}close(){this.annotator?.destroy(),this.annotator=null,this.bundle=null,this.busy=!1,this.root.replaceChildren()}shell(J){let Q=document.createElement("style");Q.textContent=z2;let j=document.createElement("div");j.className="backdrop";let z=document.createElement("div");return z.className="panel",z.setAttribute("role","dialog"),z.setAttribute("aria-modal","true"),z.setAttribute("aria-label",J.title),j.append(z),this.root.replaceChildren(Q,j),z}renderShell(J,Q){let j=this.shell(J),z=N("div","head");z.append(N("h2","",J.title)),j.append(z,N("p","status",Q))}renderForm(J){let Q=this.bundle;if(!Q)return;let j=this.shell(J),z=N("div","head"),K=v("✕","icon");K.setAttribute("aria-label",J.close),K.addEventListener("click",()=>this.close()),z.append(N("h2","",J.title),K);let W=document.createElement("input");W.type="text",W.placeholder=J.summaryPlaceholder;let X=_0(J.summaryLabel,J.summaryRequired,!0),H=document.createElement("textarea");H.placeholder=J.detailPlaceholder;let P=N("div","meta");P.innerHTML="";let{context:w}=Q;for(let[k,L]of[[J.reporter,`${w.user.fullName??"—"} (${w.user.email??"—"})`],[J.page,w.route.href],[J.captured,`${Q.network.length} network · ${Q.console.length} console · ${Q.actionTrail.length} actions${Q.replay?` · ${J.replay} ${Math.round(Q.replay.durationMs/1000)}s`:""}`]]){let $0=document.createElement("div"),C=document.createElement("b");C.textContent=`${k}: `,$0.append(C,document.createTextNode(L)),P.append($0)}let I=N("p","status",""),M=v(J.submit,"primary");if(M.disabled=!0,W.addEventListener("input",()=>{M.disabled=W.value.trim().length===0}),j.append(z,X,W,_0(J.detailLabel),H,P),Q.screenshotDataUrl)j.append(...this.screenshotSection(J,Q.screenshotDataUrl));else j.append(N("p","status",J.noScreenshot));let O=N("div","foot"),B=v(J.close);B.addEventListener("click",()=>this.close()),O.append(B,I,N("span","grow"),M),j.append(O),M.addEventListener("click",async()=>{M.disabled=!0,I.dataset.tone="",I.textContent=J.submitting;try{let k=await n1(W.value.trim(),{...Q,note:H.value,screenshotDataUrl:this.annotator?.hasShapes()?this.annotator.toDataUrl():Q.screenshotDataUrl}),L=this.dispatchEvent(new CustomEvent("lw-report-submitted",{detail:k,bubbles:!0,composed:!0,cancelable:!0}));if(this.close(),L)n(`${J.submitted} — #${k.number}`,"success")}catch(k){let L=Y6(k,J);I.dataset.tone="error",I.textContent=L,n(L,"error"),M.disabled=!1}}),W.focus()}screenshotSection(J,Q){let j=_0(J.annotateHint),z=N("div","tools"),K=document.createElement("canvas"),W=N("div","shot");W.append(K);let X=[],H=(M)=>{for(let O of X)O.setAttribute("aria-pressed",String(O===M))};for(let{tool:M,key:O}of X6){let B=v(J[O]);B.setAttribute("aria-pressed","false"),B.addEventListener("click",()=>{let k=B.getAttribute("aria-pressed")==="true";H(k?null:B),this.annotator?.setTool(k?null:M)}),X.push(B),z.append(B)}z.append(N("span","sep"));let P=v(J.deleteSelected);P.addEventListener("click",()=>this.annotator?.deleteSelected());let w=v(J.clearAll);w.addEventListener("click",()=>{this.annotator?.clear(),H(null)}),z.append(P,w);let I=new Image;return I.onload=()=>{K.width=I.naturalWidth,K.height=I.naturalHeight,this.annotator=j2(K,I,()=>{H(null),P.disabled=!this.annotator?.hasSelection()})},I.src=Q,[j,z,N("p","status",J.annotateHelp),W]}}}function H6(){try{return V6()}catch{return[]}}function N($,J="",Q=""){let j=document.createElement($);if(J)j.className=J;if(Q)j.textContent=Q;return j}function v($,J=""){let Q=document.createElement("button");if(Q.type="button",Q.textContent=$,J)Q.className=J;return Q}function _0($,J="",Q=!1){let j=document.createElement("label");if(j.append(document.createTextNode($)),Q){let z=document.createElement("span");z.className="req",z.textContent=" *",j.append(z)}if(J){let z=document.createElement("span");z.className="hint",z.textContent=` ${J}`,j.append(z)}return j}function Z2(){if(typeof window>"u"||customElements.get(e))return;customElements.define(e,F6())}var K2=!1;function W2($={}){if(K2||typeof window>"u")return;if(!j0()){console.error("[debug-capture] configureDebugCapture() must be called before install");return}if(K2=!0,R1(),K1(),$1(),q1(),A1(),$.ui===!1)return;let J=X0(D().locale);if(H1((Q)=>{n(Q.message??J.crashed,"error",{label:J.crashAction,onClick:()=>G0(Q)})}),Z2(),!document.querySelector(e))document.body.append(document.createElement(e))}var G2=document.currentScript,T=G2?.dataset??{},U6="rrweb-record.mjs";f1(()=>import(new URL(U6,G2?.src??location.href).href));function P6($){if(!$)return{};try{let J=JSON.parse($);if(!J||typeof J!=="object"||Array.isArray(J))return{};return Object.fromEntries(Object.entries(J).filter(([,Q])=>typeof Q==="string"&&Q.trim()))}catch{return{}}}if(T.host&&T.realmKey)b0({host:T.host,realmKey:T.realmKey,app:{name:T.appName??document.title??"app",version:T.appVersion??"0.0.0",environment:T.environment??"production"},module:d0(P6(T.modules)),locale:T.locale==="en"?"en":"th",...T.replay!==void 0?{replay:{seconds:Number(T.replay)||void 0}}:{}}),W2();window.lwReportProblem=G0;})();
116
+ `;var e="lw-debug-reporter";function X6($,J){if($ instanceof y){if($.kind==="offline")return J.failedOffline;if($.kind==="unavailable")return J.failedUnavailable;if($.kind==="rateLimited")return J.failedTooMany.replace("{seconds}",$.retryAfter??"60");return $.message||J.failed}return J.failed}var F6=()=>[];var H6=[{tool:"rect",key:"toolRect"},{tool:"arrow",key:"toolArrow"},{tool:"highlight",key:"toolHighlight"},{tool:"text",key:"toolText"}];function P6(){return class extends HTMLElement{root;stop=null;annotator=null;bundle=null;busy=!1;constructor(){super();this.root=this.attachShadow({mode:"open"}),z2(this.root)}connectedCallback(){this.dataset.debugReporter="true",this.stop=F1((J)=>void this.open(J))}disconnectedCallback(){this.stop?.(),this.stop=null,this.close()}async open(J){if(this.busy)return;this.busy=!0;let Q=X0(C().locale),j=await g1();if(j.method==="cancelled"){this.close();return}this.bundle=m1({reason:J,note:"",screenshotDataUrl:j.dataUrl,screenshotMethod:j.method,erroredQueries:U6()}),this.renderForm(Q)}close(){this.annotator?.destroy(),this.annotator=null,this.bundle=null,this.busy=!1,this.root.replaceChildren()}shell(J){let Q=document.createElement("style");Q.textContent=Z2;let j=document.createElement("div");j.className="backdrop";let z=document.createElement("div");return z.className="panel",z.setAttribute("role","dialog"),z.setAttribute("aria-modal","true"),z.setAttribute("aria-label",J.title),j.append(z),this.root.replaceChildren(Q,j),z}renderShell(J,Q){let j=this.shell(J),z=D("div","head");z.append(D("h2","",J.title)),j.append(z,D("p","status",Q))}renderForm(J){let Q=this.bundle;if(!Q)return;let j=this.shell(J),z=D("div","head"),K=v("✕","icon");K.setAttribute("aria-label",J.close),K.addEventListener("click",()=>this.close()),z.append(D("h2","",J.title),K);let W=document.createElement("input");W.type="text",W.placeholder=J.summaryPlaceholder;let X=_0(J.summaryLabel,J.summaryRequired,!0),H=document.createElement("textarea");H.placeholder=J.detailPlaceholder;let U=D("div","meta");U.innerHTML="";let{context:N}=Q;for(let[O,L]of[[J.reporter,`${N.user.fullName??"—"} (${N.user.email??"—"})`],[J.page,N.route.href],[J.captured,`${Q.network.length} network · ${Q.console.length} console · ${Q.actionTrail.length} actions${Q.replay?` · ${J.replay} ${Math.round(Q.replay.durationMs/1000)}s`:""}`]]){let $0=document.createElement("div"),B=document.createElement("b");B.textContent=`${O}: `,$0.append(B,document.createTextNode(L)),U.append($0)}let M=D("p","status",""),I=v(J.submit,"primary");if(I.disabled=!0,W.addEventListener("input",()=>{I.disabled=W.value.trim().length===0}),j.append(z,X,W,_0(J.detailLabel),H,U),Q.screenshotDataUrl)j.append(...this.screenshotSection(J,Q.screenshotDataUrl));else j.append(D("p","status",J.noScreenshot));let k=D("div","foot"),w=v(J.close);w.addEventListener("click",()=>this.close()),k.append(w,M,D("span","grow"),I),j.append(k),I.addEventListener("click",async()=>{I.disabled=!0,M.dataset.tone="",M.textContent=J.submitting;try{let O=await n1(W.value.trim(),{...Q,note:H.value,screenshotDataUrl:this.annotator?.hasShapes()?this.annotator.toDataUrl():Q.screenshotDataUrl}),L=this.dispatchEvent(new CustomEvent("lw-report-submitted",{detail:O,bubbles:!0,composed:!0,cancelable:!0}));if(this.close(),L)n(`${J.submitted} — #${O.number}`,"success")}catch(O){let L=X6(O,J);M.dataset.tone="error",M.textContent=L,n(L,"error"),I.disabled=!1}}),W.focus()}screenshotSection(J,Q){let j=_0(J.annotateHint),z=D("div","tools"),K=document.createElement("canvas"),W=D("div","shot");W.append(K);let X=[],H=(I)=>{for(let k of X)k.setAttribute("aria-pressed",String(k===I))};for(let{tool:I,key:k}of H6){let w=v(J[k]);w.setAttribute("aria-pressed","false"),w.addEventListener("click",()=>{let O=w.getAttribute("aria-pressed")==="true";H(O?null:w),this.annotator?.setTool(O?null:I)}),X.push(w),z.append(w)}z.append(D("span","sep"));let U=v(J.deleteSelected);U.addEventListener("click",()=>this.annotator?.deleteSelected());let N=v(J.clearAll);N.addEventListener("click",()=>{this.annotator?.clear(),H(null)}),z.append(U,N);let M=new Image;return M.onload=()=>{K.width=M.naturalWidth,K.height=M.naturalHeight,this.annotator=j2(K,M,()=>{H(null),U.disabled=!this.annotator?.hasSelection()})},M.src=Q,[j,z,D("p","status",J.annotateHelp),W]}}}function U6(){try{return F6()}catch{return[]}}function D($,J="",Q=""){let j=document.createElement($);if(J)j.className=J;if(Q)j.textContent=Q;return j}function v($,J=""){let Q=document.createElement("button");if(Q.type="button",Q.textContent=$,J)Q.className=J;return Q}function _0($,J="",Q=!1){let j=document.createElement("label");if(j.append(document.createTextNode($)),Q){let z=document.createElement("span");z.className="req",z.textContent=" *",j.append(z)}if(J){let z=document.createElement("span");z.className="hint",z.textContent=` ${J}`,j.append(z)}return j}function K2(){if(typeof window>"u"||customElements.get(e))return;customElements.define(e,P6())}var W2=!1;function Y2($={}){if(W2||typeof window>"u")return;if(!j0()){console.error("[debug-capture] configureDebugCapture() must be called before install");return}if(W2=!0,R1(),K1(),$1(),q1(),A1(),$.ui===!1)return;let J=X0(C().locale);if(H1((Q)=>{n(Q.message??J.crashed,"error",{label:J.crashAction,onClick:()=>Y0(Q)})}),K2(),!document.querySelector(e))document.body.append(document.createElement(e))}var G2=document.currentScript,T=G2?.dataset??{},M6="rrweb-record.mjs";f1(()=>import(new URL(M6,G2?.src??location.href).href));function I6($){if(!$)return{};try{let J=JSON.parse($);if(!J||typeof J!=="object"||Array.isArray(J))return{};return Object.fromEntries(Object.entries(J).filter(([,Q])=>typeof Q==="string"&&Q.trim()))}catch{return{}}}if(T.host&&T.realmKey)b0({host:T.host,realmKey:T.realmKey,app:{name:T.appName??document.title??"app",version:T.appVersion??"0.0.0",environment:T.environment??"production"},module:d0(I6(T.modules)),locale:T.locale==="en"?"en":"th",...T.replay!==void 0?{replay:{seconds:Number(T.replay)||void 0}}:{}}),Y2();window.lwReportProblem=Y0;})();
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- var B2=((J)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(J,{get:($,Q)=>(typeof require<"u"?require:$)[Q]}):J)(function(J){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+J+'" is not supported')});var N2={maxRequests:60,maxConsoleEntries:120,maxActions:80,maxBodyChars:20000},T=null;function S2(J){let $=[];if(!J.host?.trim())$.push("host");if(!J.realmKey?.trim())$.push("realmKey");if(!J.app?.name?.trim())$.push("app.name");if(typeof J.module!=="function")$.push("module");if($.length)throw Error(`[debug-capture] configureDebugCapture is missing: ${$.join(", ")}. `+"See the README — `module` maps a pathname to the part of your app it belongs to.");T=J}function S(){if(!T)throw Error("[debug-capture] configureDebugCapture() has not been called");return T}function z0(){return T!==null}function m(){let J=S().app;return{name:J.name,version:J.version??"0.0.0",environment:J.environment??w2()}}function w2(){if(typeof window>"u")return"unknown";let J=window.location.hostname;if(J==="localhost"||J==="127.0.0.1"||J.endsWith(".local"))return"development";return"production"}function g(J){let $=T?.capture?.[J];return typeof $==="number"?$:N2[J]}function K1(J){let $=T?.module;if(!$)return null;try{return $(J)??null}catch{return null}}function X0(){let J=T?.redact;return{headers:J?.headers??[],queryKeys:(J?.queryKeys??[]).map(($)=>$.toLowerCase()),bodyKeys:(J?.bodyKeys??[]).map(($)=>$.toLowerCase())}}function W1(){return T?.capture?.overlaySelectors??[]}var O2='[contenteditable]:not([contenteditable="false"]), [data-lw-mask]',R2="[data-lw-mask]",Z1={fps:1,quality:0.5};function Z0(){let J=T?.replay;if(!J)return null;let $=J===!0?{}:J,Q=(K,W)=>typeof K==="number"&&K>0?K:W,j=$.maskInputs!==!1,z=$.recordCanvas?{fps:Q(typeof $.recordCanvas==="object"?$.recordCanvas.fps:void 0,Z1.fps),quality:Q(typeof $.recordCanvas==="object"?$.recordCanvas.quality:void 0,Z1.quality)}:null;return{seconds:Q($.seconds,60),maskInputs:j,maskTextSelector:$.maskTextSelector?.trim()||(j?O2:R2),maskText:$.maskText===!0,blockSelector:$.blockSelector?.trim()||"[data-lw-private]",maxBytes:Q($.maxBytes,4000000),canvas:z}}function Y1(J){if(typeof window>"u")return!1;let $;try{$=new URL(J,window.location.href)}catch{return!1}if(_2($))return!1;if($.origin===window.location.origin)return!0;return(T?.capture?.bodyOrigins??[]).some((Q)=>{try{return new URL(Q).origin===$.origin}catch{return!1}})}function _2(J){if(!T?.host)return!1;try{if(new URL(T.host).origin!==J.origin)return!1}catch{return!1}return J.pathname.startsWith("/ingest/")}function L2(J){let $=Object.entries(J).map(([Q,j])=>[Q.replace(/\/+$/,"")||"/",j]).sort((Q,j)=>j[0].length-Q[0].length);return(Q)=>{let j=(Q||"/").replace(/\/+$/,"")||"/";for(let[z,K]of $)if(j===z||j.startsWith(`${z}/`))return{key:z,label:K};return null}}var l="‹redacted›",k2=/^(authorization|proxy-authorization|cookie|set-cookie|x-[a-z-]*token|x-csrf[a-z-]*|x-xsrf[a-z-]*)$/i,T2=new Set(["access_token","token","id_token","refresh_token","code","secret","client_secret","password","apikey","api_key","signature","x-amz-signature","x-amz-credential"]),A2=/(password|passwd|token|secret|authorization|refresh|client_secret|otp|pin)/i,x2=/[\w.+-]+@[\w-]+\.[\w.-]+/g,f2=/\d(?:[\d\s-]{7,})\d/g;function o(J){return J.replace(x2,l).replace(f2,l)}function E2(J){if(k2.test(J))return!0;return X0().headers.some((Q)=>Q.toLowerCase()===J.toLowerCase())}function r(J){let $={};for(let[Q,j]of Object.entries(J))$[Q]=E2(Q)?l:j;return $}function E(J){try{let $=/^https?:\/\//i.test(J),Q=new URL(J,$?void 0:"http://local.invalid"),j=!1;if(Q.searchParams.forEach((z,K)=>{if(T2.has(K.toLowerCase())||X0().queryKeys.includes(K.toLowerCase()))Q.searchParams.set(K,l),j=!0}),!j)return J;return $?Q.toString():`${Q.pathname}${Q.search}`}catch{return J}}function N0(J,$){if($>6||J===null||typeof J!=="object")return J;if(Array.isArray(J))return J.map((j)=>N0(j,$+1));let Q={};for(let[j,z]of Object.entries(J)){let K=A2.test(j)||X0().bodyKeys.some((W)=>j.toLowerCase().includes(W));Q[j]=K?l:N0(z,$+1)}return Q}function s(J,$){if(J==null)return null;let Q=J,j=J.trim();if(j.startsWith("{")||j.startsWith("["))try{let z=JSON.parse(j);Q=JSON.stringify(N0(z,0))}catch{}if(Q.length>$)return`${Q.slice(0,$)}… [truncated ${Q.length-$} chars]`;return Q}var S0=120,w0=40,a=(J,$)=>J.length>$?`${J.slice(0,$)}…`:J,O0=(J)=>{try{return decodeURIComponent(J)}catch{return J}},n=[],G1=0,V1=!1;function K0(J,$,Q,j){let z=a($,S0),K=n[n.length-1];if(J==="navigate"&&K?.kind==="click"){let G=z.replace(/^ไปที่\s*/,"");if(K.detail.includes(`→ ${G}`))return K.at=new Date().toISOString(),K;let F=G.split(/[?#]/)[0]??G,P=K.source?O0(K.source.replace(/^→\s*/,"")).split(/[?#]/)[0]:null;if(P&&(F===P||F.startsWith(P)))return K.detail=a(`${K.detail} → ${G}`,S0),K.source=void 0,K.at=new Date().toISOString(),K}if(K&&K.kind===J&&K.detail===z){if(K.at=new Date().toISOString(),J!=="navigate")K.count=(K.count??1)+1;return K}G1+=1;let W={id:`act_${G1}`,at:new Date().toISOString(),kind:J,detail:z,count:1,source:Q,html:H0(j)};n.push(W);while(n.length>g("maxActions"))m2(n.shift());return W}var h2=200000,W0=0;function H0(J){if(!J)return;if(W0+J.length>h2)return;return W0+=J.length,J}function m2(J){if(!J)return;if(W0-=(J.html?.length??0)+(J.afterHtml?.length??0),W0<0)W0=0}function R0(J){return J&&J>1?` (×${J})`:""}function F0(J){return J instanceof Element&&Boolean(J.closest("[data-debug-reporter]"))}var g2='button, a[href], [role="button"], [role="tab"], [role="menuitem"], [role="option"], [role="switch"], [role="checkbox"], [role="radio"], [role="link"], summary, input, select, textarea',y2={button:"ปุ่ม",a:"ลิงก์",input:"ช่อง",textarea:"ช่อง",select:"ตัวเลือก",summary:"ส่วนขยาย"},X1={button:"ปุ่ม",tab:"แท็บ",menuitem:"เมนู",option:"ตัวเลือก",switch:"สวิตช์",checkbox:"ช่องเลือก",radio:"ตัวเลือก",link:"ลิงก์"};function b2(J){let $=J.getAttribute("role");if($&&X1[$])return X1[$];return y2[J.tagName.toLowerCase()]??"ปุ่ม"}function v2(J,$){try{let Q=J,j=0;while(Q&&j<=$){let z=C1(Q);if(z&&typeof z.memoizedProps?.onClick==="function")return Q;Q=Q.parentElement,j+=1}}catch{}return null}function p2(J){let $=J.getAttribute("aria-label")?.trim();if($)return $;let Q=J.getAttribute("title")?.trim();if(Q)return Q;if(J instanceof HTMLInputElement||J instanceof HTMLTextAreaElement||J instanceof HTMLSelectElement)return(J.getAttribute("placeholder")||J.getAttribute("name")||"").trim();if(J instanceof HTMLImageElement)return(J.getAttribute("alt")||"").trim();let j=(J.textContent??"").replace(/\s+/g," ").trim();if(j)return j;if(J instanceof HTMLAnchorElement){let z=J.getAttribute("href");if(z?.startsWith("/"))return O0(z)}return""}function u2(J){if(!(J instanceof Element))return null;let $=J.closest(g2)??v2(J,4);if(!$)return null;let Q=$.tagName.toLowerCase();if(Q==="html"||Q==="body")return null;return $}function d2(J){let $=o(p2(J));if(!$)return null;return`${b2(J)} “${a($,w0)}”`}var M1=6000,c2=4000,i2=/(?:^|\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 l2(J){J.querySelectorAll("script, style, link, iframe, object, embed, noscript, canvas, video, audio").forEach((z)=>z.remove());let $=[J,...Array.from(J.querySelectorAll("*"))];for(let z of $){for(let W of Array.from(z.attributes)){let G=W.name.toLowerCase();if(G.startsWith("on")||G==="srcdoc"||G==="value"||G.startsWith("data-"))z.removeAttribute(W.name)}if(z instanceof HTMLAnchorElement)z.setAttribute("href","#");if(z instanceof HTMLImageElement)z.removeAttribute("src");let K=z.getAttribute("class");if(K){let W=K.replace(i2," ").replace(/\s+/g," ").trim();if(W)z.setAttribute("class",W);else z.removeAttribute("class")}}let Q=document.createTreeWalker(J,NodeFilter.SHOW_TEXT),j=Q.nextNode();while(j){if(j.nodeValue)j.nodeValue=o(j.nodeValue);j=Q.nextNode()}}function _0(J,$,Q){try{let j=J.outerHTML;if(!j||j.length>$)return;let z=J.cloneNode(!0);l2(z);let K=z.outerHTML;return K&&K.length<=Q?K:void 0}catch{return}}var o2=(J)=>_0(J,M1,c2),r2=150000,s2=40000,F1=(J)=>_0(J,r2,s2);function n2(J){if(!(J instanceof HTMLInputElement)&&!(J instanceof HTMLTextAreaElement)&&!(J instanceof HTMLSelectElement))return null;let $=J.name||J.id||J.getAttribute("aria-label")||J.getAttribute("placeholder")||J.tagName.toLowerCase();return`ช่อง “${o($)}”`}var H1=80;function C1(J){let $=Object.keys(J).find((Q)=>Q.startsWith("__reactFiber$")||Q.startsWith("__reactInternalInstance$"));return $?J[$]:null}function a2(J){if(typeof J!=="function")return null;try{let $=Function.prototype.toString.call(J);return($.match(/\.(?:push|replace)\(\s*['"`]([^'"`]+)['"`]/)??$.match(/redirect\(\s*['"`]([^'"`]+)['"`]/))?.[1]??null}catch{return null}}function U1(J){if(!J)return;return`→ ${J.length>H1?`${J.slice(0,H1)}…`:J}`}function t2(J){try{let $=J.closest("a[href]")?.getAttribute("href");if($&&$.startsWith("/"))return U1($);let Q=C1(J),j=0;while(Q&&j<30){if(typeof Q.memoizedProps?.onClick==="function")return U1(a2(Q.memoizedProps.onClick));Q=Q.return,j+=1}return}catch{return}}var e2='[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], [role="status"], [role="alert"]';function J4(){let J=W1();return J.length?J.join(", "):e2}function $4(J){let $=J.getAttribute("role");if($==="status"||$==="alert")return"ข้อความแจ้งเตือน";if($==="menu")return"เมนู";if($==="listbox")return"รายการตัวเลือก";if($==="alertdialog")return"กล่องยืนยัน";return"กล่องโต้ตอบ"}function Q4(J){let $=J.getAttribute("aria-label")?.trim();if($)return $;let Q=J.getAttribute("aria-labelledby");if(Q){let K=Q.split(/\s+/).map((W)=>document.getElementById(W)?.textContent?.trim()??"").filter(Boolean).join(" ");if(K)return K}let z=J.querySelector('[data-slot="dialog-title"], h1, h2, h3, [role="heading"]')?.textContent?.replace(/\s+/g," ").trim();if(z)return z;return(J.textContent??"").replace(/\s+/g," ").trim()}function I1(J){let $=o(Q4(J)),Q=$4(J);return $?`เปิด ${Q} “${a($,w0)}”`:`เปิด ${Q}`}var j4='[aria-busy="true"], [role="progressbar"], [data-loading="true"], .animate-pulse, .animate-spin',z4=/กำลังโหลด|กำลังค้นหา|กำลังดำเนินการ|\bloading\b/i;function Z4(J){if(J.querySelector(j4))return!0;return z4.test(J.textContent??"")}var K4=400,W4=250,Y4=8000;function G4(J,$){if(typeof MutationObserver>"u"){$.html=H0(F1(J));return}let Q=Date.now(),j=!1,z=()=>{j=!0,W.disconnect(),window.clearInterval(G),window.clearTimeout(F)},K=()=>{if(j)return;if(z(),!J.isConnected)return;$.detail=a(I1(J),S0),$.html=H0(F1(J))},W=new MutationObserver(()=>{Q=Date.now()});W.observe(J,{childList:!0,subtree:!0,attributes:!0,characterData:!0});let G=window.setInterval(()=>{if(j)return;if(!J.isConnected){z();return}if(Date.now()-Q>=K4&&!Z4(J))K()},W4),F=window.setTimeout(K,Y4)}function V4(J){if(F0(J))return;let $=K0("ui",I1(J));if($)G4(J,$)}function X4(){if(typeof MutationObserver>"u")return;let J=new WeakSet;new MutationObserver((Q)=>{for(let j of Q)for(let z of Array.from(j.addedNodes)){if(!(z instanceof Element))continue;let K=J4(),W=z.matches(K)?[z]:Array.from(z.querySelectorAll(K));for(let G of W){if(J.has(G))continue;J.add(G),V4(G)}}}).observe(document.body,{childList:!0,subtree:!0})}var F4=1600,H4=2500;function P1(J){return{disabled:J.hasAttribute("disabled")||J.getAttribute("aria-disabled")==="true",busy:J.getAttribute("aria-busy")==="true",text:a((J.textContent??"").replace(/\s+/g," ").trim(),w0)}}function U4(J,$){if(!J.disabled&&$.disabled)return"ปุ่มถูกปิดใช้งานหลังคลิก";if(!J.busy&&$.busy)return"ปุ่มเข้าสู่สถานะกำลังโหลด";if(J.text!==$.text&&$.text)return`ข้อความเปลี่ยนเป็น “${$.text}”`;return null}function P4(J,$){if(typeof MutationObserver>"u")return;let Q=P1(J),j=!1,z=(G,F)=>{if(j)return;if(j=!0,K.disconnect(),window.clearTimeout(W),$.afterNote=G,F)$.afterHtml=H0(_0(J,M1,H4))},K=new MutationObserver(()=>{if(!J.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}let G=U4(Q,P1(J));if(G)z(G,!0)});K.observe(J,{attributes:!0,attributeFilter:["disabled","aria-disabled","aria-busy","class"],childList:!0,subtree:!0,characterData:!0});let W=window.setTimeout(()=>{if(!j&&!J.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}j=!0,K.disconnect()},F4)}function D1(){if(V1||typeof window>"u")return;V1=!0,document.addEventListener("click",(j)=>{if(F0(j.target))return;let z=u2(j.target);if(!z)return;let K=d2(z);if(!K)return;let W=K0("click",`คลิก ${K}`,t2(z),o2(z));if(W)P4(z,W)},{capture:!0,passive:!0}),document.addEventListener("change",(j)=>{if(F0(j.target))return;let z=n2(j.target);if(z)K0("input",`แก้ไข ${z}`)},{capture:!0,passive:!0}),document.addEventListener("submit",(j)=>{if(F0(j.target))return;K0("submit","ส่งฟอร์ม")},{capture:!0,passive:!0});let J=()=>K0("navigate",`ไปที่ ${O0(E(location.pathname+location.search))}`),$=history.pushState.bind(history),Q=history.replaceState.bind(history);history.pushState=(...j)=>{let z=$(...j);return J(),z},history.replaceState=(...j)=>{let z=Q(...j);return J(),z},window.addEventListener("popstate",J),X4()}function L0(){return n.map((J)=>({...J}))}var q1=2000,U0=[],B1=0,N1=!1;function k0(J,$){B1+=1,U0.push({id:`log_${B1}`,at:new Date().toISOString(),level:J,message:$.length>q1?`${$.slice(0,q1)}…`:$});while(U0.length>g("maxConsoleEntries"))U0.shift()}function M4(){let J=new WeakSet;return($,Q)=>{if(typeof Q==="object"&&Q!==null){if(J.has(Q))return"[Circular]";J.add(Q)}if(typeof Q==="bigint")return Q.toString();return Q}}function S1(J){if(typeof J==="string")return J;if(J instanceof Error)return`${J.name}: ${J.message}`;try{let $=JSON.stringify(J,M4());if($!==void 0)return $}catch{}try{return String(J)}catch{}try{return Object.prototype.toString.call(J)}catch{return`[${typeof J}]`}}function w1(){if(N1||typeof window>"u")return;N1=!0;let J=["log","info","warn","error","debug"];for(let $ of J){let Q=console[$].bind(console);console[$]=(...j)=>{k0($,j.map(S1).join(" ")),Q(...j)}}window.addEventListener("error",($)=>{let Q=$.filename?` (${$.filename}:${$.lineno}:${$.colno})`:"";k0("exception",`${$.message}${Q}`)}),window.addEventListener("unhandledrejection",($)=>{let Q=$.reason instanceof Error?`${$.reason.name}: ${$.reason.message}`:S1($.reason);k0("unhandledrejection",Q)})}function T0(){return U0.map((J)=>({...J}))}var O1=new Set,R1=new Set;function _1(J,$){return J.add($),()=>J.delete($)}function L1(J,$){for(let Q of[...J])Q($)}function A0(J){return _1(O1,J)}function x0(J={type:"manual"}){L1(O1,J)}function f0(J){return _1(R1,J)}function E0(J){L1(R1,J)}var C4=15000,I4=["ResizeObserver loop","Script error.","Non-Error promise rejection captured"],k1=!1,T1=0;function D4(J){return I4.some(($)=>J.includes($))}function A1(J){let $=J.message??"";if(!$||D4($))return;let Q=Date.now();if(Q-T1<C4)return;T1=Q,E0({...J,message:$})}function x1(){if(k1||typeof window>"u")return;k1=!0,window.addEventListener("error",(J)=>{if(!J.message&&!J.error)return;let $=J.error instanceof Error?J.error:null;A1({type:"runtime-error",message:J.message||($?$.message:"Unknown error"),stack:$?.stack})}),window.addEventListener("unhandledrejection",(J)=>{let $=J.reason;A1({type:"unhandledrejection",message:$ instanceof Error?$.message:String($),stack:$ instanceof Error?$.stack:void 0})})}var m1=4000,q4=1e6,B4=1e7,P0=[],f1=0,E1=!1;function g1(J){P0.push(J);while(P0.length>g("maxRequests"))P0.shift()}function y1(){return f1+=1,`req_${f1}`}function h1(J){let $={};if(!J)return $;if(J instanceof Headers)J.forEach((Q,j)=>{$[j]=Q});else if(Array.isArray(J))for(let[Q,j]of J)$[Q]=j;else Object.assign($,J);return $}function N4(J){let $={};return J.forEach((Q,j)=>{$[j]=Q}),$}function S4(J){if(J==null)return null;if(typeof J==="string")return J;if(J instanceof URLSearchParams)return J.toString();if(typeof FormData<"u"&&J instanceof FormData)return`[FormData: ${Array.from(J.keys()).join(", ")}]`;if(typeof Blob<"u"&&J instanceof Blob)return`[Blob ${J.size} bytes]`;if(J instanceof ArrayBuffer)return`[ArrayBuffer ${J.byteLength} bytes]`;return"[binary]"}function w4(J,$){let Q="",j="GET",z={},K=null;if(typeof J==="string")Q=J;else if(J instanceof URL)Q=J.toString();else Q=J.url,j=J.method||j,z=h1(J.headers);if($){if($.method)j=$.method;if($.headers)z={...z,...h1($.headers)};if($.body!==void 0)K=S4($.body)}return{method:j.toUpperCase(),url:Q,headers:z,body:K}}function b1(J){return!Y1(J)}function O4(J,$){if(b1($.url)){$.responseSnippet="[body not captured for this origin]";return}let Q=J.headers.get("content-type")??"",j=Number(J.headers.get("content-length")??"0"),z=j?`, ~${j} bytes`:"";if(!/json|text|xml|html|javascript|urlencoded/i.test(Q)){$.responseSnippet=`[binary ${Q||"unknown"}${z}]`;return}if(j>q4){$.responseSnippet=`[response ${Q||"text"}${z} — omitted]`;return}try{J.clone().text().then((K)=>{$.responseSnippet=s(K,g("maxBodyChars"))}).catch(()=>{})}catch{}}function v1(J,$){if(/[?&]_rsc=/.test(J))return!0;for(let Q of Object.keys($)){let j=Q.toLowerCase();if(j==="rsc"||j==="next-router-prefetch"||j==="next-router-state-tree")return!0}return!1}function R4(){if(typeof window>"u"||typeof window.fetch!=="function")return;let J=window.fetch.bind(window);window.fetch=Object.assign(async($,Q)=>{let j=w4($,Q);if(v1(j.url,j.headers))return J($,Q);let z={id:y1(),startedAt:new Date().toISOString(),method:j.method,url:E(j.url),requestHeaders:r(j.headers),requestBody:s(j.body,m1),status:null,statusText:null,durationMs:null,via:"fetch"};g1(z);let K=performance.now();try{let W=await J($,Q);return z.status=W.status,z.statusText=W.statusText,z.durationMs=Math.round(performance.now()-K),z.responseHeaders=r(N4(W.headers)),O4(W,z),W}catch(W){throw z.durationMs=Math.round(performance.now()-K),z.error=W instanceof Error?`${W.name}: ${W.message}`:String(W),W}},J)}function _4(){if(typeof window>"u"||typeof window.XMLHttpRequest!=="function")return;let J=XMLHttpRequest.prototype,$=J.open,Q=J.send,j=function(K,W){let G=typeof W==="string"?W:W.toString();return this.__lwEntry=v1(G,{})?void 0:{id:y1(),startedAt:"",method:(K||"GET").toUpperCase(),url:E(G),requestHeaders:{},requestBody:null,status:null,statusText:null,durationMs:null,via:"xhr"},$.apply(this,arguments)},z=function(K){let W=this.__lwEntry;if(W){W.startedAt=new Date().toISOString(),W.requestBody=typeof K==="string"?s(K,m1):K==null?null:"[non-string body]";let G=performance.now();g1(W),this.addEventListener("loadend",()=>{if(W.status=this.status||null,W.statusText=this.statusText||null,W.durationMs=Math.round(performance.now()-G),b1(W.url))W.responseSnippet="[body not captured for this origin]";else if(this.responseType===""||this.responseType==="text")try{W.responseSnippet=s(this.responseText||"",g("maxBodyChars"))}catch{}else{let F=this.getResponseHeader("content-type")??this.responseType;W.responseSnippet=`[binary ${F}]`}})}return Q.apply(this,arguments)};J.open=j,J.send=z}function p1(){if(E1)return;E1=!0,R4(),_4()}function h0(){let J=P0.map((Q)=>({...Q})),$=0;for(let Q=J.length-1;Q>=0;Q-=1){let j=J[Q],z=j?.responseSnippet;if(!j||typeof z!=="string"||z.length===0)continue;if($+z.length>B4)j.responseSnippet=`[response omitted — report size budget reached (${z.length.toLocaleString()} chars)]`;else $+=z.length}return J}var L4=4,u1=3,k4=4000,T4="[data-debug-reporter]",A4=()=>import("@rrweb/record");var A=[],t=null,M0=!1;function d1(){if(typeof window>"u"||t||M0)return;let J=Z0();if(!J)return;M0=!0;let $=()=>void x4(J);if("requestIdleCallback"in window)window.requestIdleCallback($,{timeout:3000});else setTimeout($,1000)}async function x4(J){let $;try{$=(await A4()).record}catch(Q){M0=!1,console.warn("[debug-capture] session replay could not start:",Q);return}if(t)return;try{t=$({emit:(Q)=>f4(Q),checkoutEveryNms:Math.max(1000,J.seconds*1000/2),checkoutEveryNth:k4,maskAllInputs:J.maskInputs,maskTextSelector:J.maskText?"*":J.maskTextSelector,blockSelector:`${J.blockSelector}, ${T4}`,slimDOMOptions:"all",inlineStylesheet:!0,sampling:{mousemove:50,scroll:150,media:800,input:"last",...J.canvas?{canvas:J.canvas.fps}:{}},recordCanvas:J.canvas!==null,...J.canvas?{dataURLOptions:{type:"image/webp",quality:J.canvas.quality}}:{},errorHandler:()=>!0})??null}catch(Q){console.warn("[debug-capture] session replay could not start:",Q)}finally{M0=!1}}function f4(J){if(J.type===L4||A.length===0){if(A.push([]),A.length>u1)A=A.slice(-u1)}A[A.length-1].push(J)}function m0(J=Date.now()){let $=Z0();if(!$||!A.length)return null;let Q=J-$.seconds*1000,j=A.length-1;while(j>0&&(A[j][0]?.timestamp??J)>Q)j-=1;let z=A.slice(j).flat(),K=z[0]?.timestamp,W=z[z.length-1]?.timestamp;if(K===void 0||W===void 0)return null;return{events:z,startedAt:new Date(K).toISOString(),endedAt:new Date(W).toISOString(),durationMs:Math.max(0,W-K)}}function E4(){return t!==null}function h4(){t?.(),t=null,A=[]}var m4={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:"ส่งรายงานไม่สำเร็จ",failedOffline:"ส่งไม่สำเร็จ — เชื่อมต่อเซิร์ฟเวอร์ไม่ได้ ข้อความที่พิมพ์ไว้ยังอยู่ ตรวจสอบอินเทอร์เน็ตแล้วลองใหม่",failedUnavailable:"ส่งไม่สำเร็จ — ระบบกำลังปรับปรุงชั่วคราว ข้อความที่พิมพ์ไว้ยังอยู่ ลองใหม่ในอีกสักครู่",failedTooMany:"แจ้งปัญหาถี่เกินไป — ลองใหม่ในอีก {seconds} วินาที",captured:"เก็บข้อมูลแล้ว",reporter:"ผู้แจ้ง",page:"หน้า",replay:"บันทึกการใช้งาน",handoffTitle:"กำลังพาไปที่ระบบแจ้งปัญหา",handoffBody:"ระบบจะลงชื่อเข้าใช้ให้อัตโนมัติ เพื่อดูเรื่องที่คุณแจ้งไว้",handoffGo:"ไปเลย",handoffPreparing:"กำลังเตรียม…",handoffFailed:"เปิดรายการที่แจ้งไว้ไม่สำเร็จ",handoffBlocked:"เบราว์เซอร์บล็อกการเปิดแท็บใหม่",handoffOpen:"เปิดในแท็บใหม่"},g4={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",failedOffline:"Could not send — the server could not be reached. What you wrote is still here; check your connection and try again.",failedUnavailable:"Could not send — the system is being updated. What you wrote is still here; try again in a moment.",failedTooMany:"Too many reports — try again in {seconds} seconds.",captured:"Captured",reporter:"Reporter",page:"Page",replay:"activity log",handoffTitle:"Opening the support portal",handoffBody:"You will be signed in automatically to see what you reported",handoffGo:"Go now",handoffPreparing:"Preparing…",handoffFailed:"Could not open your reports",handoffBlocked:"Your browser blocked the new tab",handoffOpen:"Open in a new tab"};function d(J){return J==="en"?g4:m4}var y4="lw-debug-toasts",b4=6000,v4=`
1
+ var N2=((J)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(J,{get:($,Q)=>(typeof require<"u"?require:$)[Q]}):J)(function(J){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+J+'" is not supported')});var w2={maxRequests:60,maxConsoleEntries:120,maxActions:80,maxBodyChars:20000},T=null;function S2(J){let $=[];if(!J.host?.trim())$.push("host");if(!J.realmKey?.trim())$.push("realmKey");if(!J.app?.name?.trim())$.push("app.name");if(typeof J.module!=="function")$.push("module");if($.length)throw Error(`[debug-capture] configureDebugCapture is missing: ${$.join(", ")}. `+"See the README — `module` maps a pathname to the part of your app it belongs to.");T=J}function w(){if(!T)throw Error("[debug-capture] configureDebugCapture() has not been called");return T}function z0(){return T!==null}function m(){let J=w().app;return{name:J.name,version:J.version??"0.0.0",environment:J.environment??O2()}}function O2(){if(typeof window>"u")return"unknown";let J=window.location.hostname;if(J==="localhost"||J==="127.0.0.1"||J.endsWith(".local"))return"development";return"production"}function g(J){let $=T?.capture?.[J];return typeof $==="number"?$:w2[J]}function W1(J){let $=T?.module;if(!$)return null;try{return $(J)??null}catch{return null}}function X0(){let J=T?.redact;return{headers:J?.headers??[],queryKeys:(J?.queryKeys??[]).map(($)=>$.toLowerCase()),bodyKeys:(J?.bodyKeys??[]).map(($)=>$.toLowerCase())}}function Y1(){return T?.capture?.overlaySelectors??[]}var R2='[contenteditable]:not([contenteditable="false"]), [data-lw-mask]',_2="[data-lw-mask]",K1={fps:1,quality:0.5};function Z0(){let J=T?.replay;if(!J)return null;let $=J===!0?{}:J,Q=(K,W)=>typeof K==="number"&&K>0?K:W,j=$.maskInputs!==!1,z=$.recordCanvas?{fps:Q(typeof $.recordCanvas==="object"?$.recordCanvas.fps:void 0,K1.fps),quality:Q(typeof $.recordCanvas==="object"?$.recordCanvas.quality:void 0,K1.quality)}:null;return{seconds:Q($.seconds,60),maskInputs:j,maskTextSelector:$.maskTextSelector?.trim()||(j?R2:_2),maskText:$.maskText===!0,blockSelector:$.blockSelector?.trim()||"[data-lw-private]",maxBytes:Q($.maxBytes,4000000),canvas:z}}function G1(J){if(typeof window>"u")return!1;let $;try{$=new URL(J,window.location.href)}catch{return!1}if(L2($))return!1;if($.origin===window.location.origin)return!0;return(T?.capture?.bodyOrigins??[]).some((Q)=>{try{return new URL(Q).origin===$.origin}catch{return!1}})}function L2(J){if(!T?.host)return!1;try{if(new URL(T.host).origin!==J.origin)return!1}catch{return!1}return J.pathname.startsWith("/ingest/")}function k2(J){let $=Object.entries(J).map(([Q,j])=>[Q.replace(/\/+$/,"")||"/",j]).sort((Q,j)=>j[0].length-Q[0].length);return(Q)=>{let j=(Q||"/").replace(/\/+$/,"")||"/";for(let[z,K]of $)if(j===z||j.startsWith(`${z}/`))return{key:z,label:K};return null}}var l="‹redacted›",T2=/^(authorization|proxy-authorization|cookie|set-cookie|x-[a-z-]*token|x-csrf[a-z-]*|x-xsrf[a-z-]*)$/i,A2=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,f2=/[\w.+-]+@[\w-]+\.[\w.-]+/g,E2=/\d(?:[\d\s-]{7,})\d/g;function o(J){return J.replace(f2,l).replace(E2,l)}function h2(J){if(T2.test(J))return!0;return X0().headers.some((Q)=>Q.toLowerCase()===J.toLowerCase())}function r(J){let $={};for(let[Q,j]of Object.entries(J))$[Q]=h2(Q)?l:j;return $}function E(J){try{let $=/^https?:\/\//i.test(J),Q=new URL(J,$?void 0:"http://local.invalid"),j=!1;if(Q.searchParams.forEach((z,K)=>{if(A2.has(K.toLowerCase())||X0().queryKeys.includes(K.toLowerCase()))Q.searchParams.set(K,l),j=!0}),!j)return J;return $?Q.toString():`${Q.pathname}${Q.search}`}catch{return J}}function w0(J,$){if($>6||J===null||typeof J!=="object")return J;if(Array.isArray(J))return J.map((j)=>w0(j,$+1));let Q={};for(let[j,z]of Object.entries(J)){let K=x2.test(j)||X0().bodyKeys.some((W)=>j.toLowerCase().includes(W));Q[j]=K?l:w0(z,$+1)}return Q}function s(J,$){if(J==null)return null;let Q=J,j=J.trim();if(j.startsWith("{")||j.startsWith("["))try{let z=JSON.parse(j);Q=JSON.stringify(w0(z,0))}catch{}if(Q.length>$)return`${Q.slice(0,$)}… [truncated ${Q.length-$} chars]`;return Q}var S0=120,O0=40,a=(J,$)=>J.length>$?`${J.slice(0,$)}…`:J,R0=(J)=>{try{return decodeURIComponent(J)}catch{return J}},n=[],V1=0,X1=!1;function K0(J,$,Q,j){let z=a($,S0),K=n[n.length-1];if(J==="navigate"&&K?.kind==="click"){let G=z.replace(/^ไปที่\s*/,"");if(K.detail.includes(`→ ${G}`))return K.at=new Date().toISOString(),K;let F=G.split(/[?#]/)[0]??G,P=K.source?R0(K.source.replace(/^→\s*/,"")).split(/[?#]/)[0]:null;if(P&&(F===P||F.startsWith(P)))return K.detail=a(`${K.detail} → ${G}`,S0),K.source=void 0,K.at=new Date().toISOString(),K}if(K&&K.kind===J&&K.detail===z){if(K.at=new Date().toISOString(),J!=="navigate")K.count=(K.count??1)+1;return K}V1+=1;let W={id:`act_${V1}`,at:new Date().toISOString(),kind:J,detail:z,count:1,source:Q,html:H0(j)};n.push(W);while(n.length>g("maxActions"))g2(n.shift());return W}var m2=200000,W0=0;function H0(J){if(!J)return;if(W0+J.length>m2)return;return W0+=J.length,J}function g2(J){if(!J)return;if(W0-=(J.html?.length??0)+(J.afterHtml?.length??0),W0<0)W0=0}function _0(J){return J&&J>1?` (×${J})`:""}function F0(J){return J instanceof Element&&Boolean(J.closest("[data-debug-reporter]"))}var y2='button, a[href], [role="button"], [role="tab"], [role="menuitem"], [role="option"], [role="switch"], [role="checkbox"], [role="radio"], [role="link"], summary, input, select, textarea',b2={button:"ปุ่ม",a:"ลิงก์",input:"ช่อง",textarea:"ช่อง",select:"ตัวเลือก",summary:"ส่วนขยาย"},F1={button:"ปุ่ม",tab:"แท็บ",menuitem:"เมนู",option:"ตัวเลือก",switch:"สวิตช์",checkbox:"ช่องเลือก",radio:"ตัวเลือก",link:"ลิงก์"};function v2(J){let $=J.getAttribute("role");if($&&F1[$])return F1[$];return b2[J.tagName.toLowerCase()]??"ปุ่ม"}function p2(J,$){try{let Q=J,j=0;while(Q&&j<=$){let z=I1(Q);if(z&&typeof z.memoizedProps?.onClick==="function")return Q;Q=Q.parentElement,j+=1}}catch{}return null}function u2(J){let $=J.getAttribute("aria-label")?.trim();if($)return $;let Q=J.getAttribute("title")?.trim();if(Q)return Q;if(J instanceof HTMLInputElement||J instanceof HTMLTextAreaElement||J instanceof HTMLSelectElement)return(J.getAttribute("placeholder")||J.getAttribute("name")||"").trim();if(J instanceof HTMLImageElement)return(J.getAttribute("alt")||"").trim();let j=(J.textContent??"").replace(/\s+/g," ").trim();if(j)return j;if(J instanceof HTMLAnchorElement){let z=J.getAttribute("href");if(z?.startsWith("/"))return R0(z)}return""}function d2(J){if(!(J instanceof Element))return null;let $=J.closest(y2)??p2(J,4);if(!$)return null;let Q=$.tagName.toLowerCase();if(Q==="html"||Q==="body")return null;return $}function c2(J){let $=o(u2(J));if(!$)return null;return`${v2(J)} “${a($,O0)}”`}var C1=6000,i2=4000,l2=/(?:^|\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 o2(J){J.querySelectorAll("script, style, link, iframe, object, embed, noscript, canvas, video, audio").forEach((z)=>z.remove());let $=[J,...Array.from(J.querySelectorAll("*"))];for(let z of $){for(let W of Array.from(z.attributes)){let G=W.name.toLowerCase();if(G.startsWith("on")||G==="srcdoc"||G==="value"||G.startsWith("data-"))z.removeAttribute(W.name)}if(z instanceof HTMLAnchorElement)z.setAttribute("href","#");if(z instanceof HTMLImageElement)z.removeAttribute("src");let K=z.getAttribute("class");if(K){let W=K.replace(l2," ").replace(/\s+/g," ").trim();if(W)z.setAttribute("class",W);else z.removeAttribute("class")}}let Q=document.createTreeWalker(J,NodeFilter.SHOW_TEXT),j=Q.nextNode();while(j){if(j.nodeValue)j.nodeValue=o(j.nodeValue);j=Q.nextNode()}}function L0(J,$,Q){try{let j=J.outerHTML;if(!j||j.length>$)return;let z=J.cloneNode(!0);o2(z);let K=z.outerHTML;return K&&K.length<=Q?K:void 0}catch{return}}var r2=(J)=>L0(J,C1,i2),s2=150000,n2=40000,H1=(J)=>L0(J,s2,n2);function a2(J){if(!(J instanceof HTMLInputElement)&&!(J instanceof HTMLTextAreaElement)&&!(J instanceof HTMLSelectElement))return null;let $=J.name||J.id||J.getAttribute("aria-label")||J.getAttribute("placeholder")||J.tagName.toLowerCase();return`ช่อง “${o($)}”`}var U1=80;function I1(J){let $=Object.keys(J).find((Q)=>Q.startsWith("__reactFiber$")||Q.startsWith("__reactInternalInstance$"));return $?J[$]:null}function t2(J){if(typeof J!=="function")return null;try{let $=Function.prototype.toString.call(J);return($.match(/\.(?:push|replace)\(\s*['"`]([^'"`]+)['"`]/)??$.match(/redirect\(\s*['"`]([^'"`]+)['"`]/))?.[1]??null}catch{return null}}function P1(J){if(!J)return;return`→ ${J.length>U1?`${J.slice(0,U1)}…`:J}`}function e2(J){try{let $=J.closest("a[href]")?.getAttribute("href");if($&&$.startsWith("/"))return P1($);let Q=I1(J),j=0;while(Q&&j<30){if(typeof Q.memoizedProps?.onClick==="function")return P1(t2(Q.memoizedProps.onClick));Q=Q.return,j+=1}return}catch{return}}var J4='[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], [role="status"], [role="alert"]';function $4(){let J=Y1();return J.length?J.join(", "):J4}function Q4(J){let $=J.getAttribute("role");if($==="status"||$==="alert")return"ข้อความแจ้งเตือน";if($==="menu")return"เมนู";if($==="listbox")return"รายการตัวเลือก";if($==="alertdialog")return"กล่องยืนยัน";return"กล่องโต้ตอบ"}function j4(J){let $=J.getAttribute("aria-label")?.trim();if($)return $;let Q=J.getAttribute("aria-labelledby");if(Q){let K=Q.split(/\s+/).map((W)=>document.getElementById(W)?.textContent?.trim()??"").filter(Boolean).join(" ");if(K)return K}let z=J.querySelector('[data-slot="dialog-title"], h1, h2, h3, [role="heading"]')?.textContent?.replace(/\s+/g," ").trim();if(z)return z;return(J.textContent??"").replace(/\s+/g," ").trim()}function D1(J){let $=o(j4(J)),Q=Q4(J);return $?`เปิด ${Q} “${a($,O0)}”`:`เปิด ${Q}`}var z4='[aria-busy="true"], [role="progressbar"], [data-loading="true"], .animate-pulse, .animate-spin',Z4=/กำลังโหลด|กำลังค้นหา|กำลังดำเนินการ|\bloading\b/i;function K4(J){if(J.querySelector(z4))return!0;return Z4.test(J.textContent??"")}var W4=400,Y4=250,G4=8000;function V4(J,$){if(typeof MutationObserver>"u"){$.html=H0(H1(J));return}let Q=Date.now(),j=!1,z=()=>{j=!0,W.disconnect(),window.clearInterval(G),window.clearTimeout(F)},K=()=>{if(j)return;if(z(),!J.isConnected)return;$.detail=a(D1(J),S0),$.html=H0(H1(J))},W=new MutationObserver(()=>{Q=Date.now()});W.observe(J,{childList:!0,subtree:!0,attributes:!0,characterData:!0});let G=window.setInterval(()=>{if(j)return;if(!J.isConnected){z();return}if(Date.now()-Q>=W4&&!K4(J))K()},Y4),F=window.setTimeout(K,G4)}function X4(J){if(F0(J))return;let $=K0("ui",D1(J));if($)V4(J,$)}function F4(){if(typeof MutationObserver>"u")return;let J=new WeakSet;new MutationObserver((Q)=>{for(let j of Q)for(let z of Array.from(j.addedNodes)){if(!(z instanceof Element))continue;let K=$4(),W=z.matches(K)?[z]:Array.from(z.querySelectorAll(K));for(let G of W){if(J.has(G))continue;J.add(G),X4(G)}}}).observe(document.body,{childList:!0,subtree:!0})}var H4=1600,U4=2500;function M1(J){return{disabled:J.hasAttribute("disabled")||J.getAttribute("aria-disabled")==="true",busy:J.getAttribute("aria-busy")==="true",text:a((J.textContent??"").replace(/\s+/g," ").trim(),O0)}}function P4(J,$){if(!J.disabled&&$.disabled)return"ปุ่มถูกปิดใช้งานหลังคลิก";if(!J.busy&&$.busy)return"ปุ่มเข้าสู่สถานะกำลังโหลด";if(J.text!==$.text&&$.text)return`ข้อความเปลี่ยนเป็น “${$.text}”`;return null}function M4(J,$){if(typeof MutationObserver>"u")return;let Q=M1(J),j=!1,z=(G,F)=>{if(j)return;if(j=!0,K.disconnect(),window.clearTimeout(W),$.afterNote=G,F)$.afterHtml=H0(L0(J,C1,U4))},K=new MutationObserver(()=>{if(!J.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}let G=P4(Q,M1(J));if(G)z(G,!0)});K.observe(J,{attributes:!0,attributeFilter:["disabled","aria-disabled","aria-busy","class"],childList:!0,subtree:!0,characterData:!0});let W=window.setTimeout(()=>{if(!j&&!J.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}j=!0,K.disconnect()},H4)}function q1(){if(X1||typeof window>"u")return;X1=!0,document.addEventListener("click",(j)=>{if(F0(j.target))return;let z=d2(j.target);if(!z)return;let K=c2(z);if(!K)return;let W=K0("click",`คลิก ${K}`,e2(z),r2(z));if(W)M4(z,W)},{capture:!0,passive:!0}),document.addEventListener("change",(j)=>{if(F0(j.target))return;let z=a2(j.target);if(z)K0("input",`แก้ไข ${z}`)},{capture:!0,passive:!0}),document.addEventListener("submit",(j)=>{if(F0(j.target))return;K0("submit","ส่งฟอร์ม")},{capture:!0,passive:!0});let J=()=>K0("navigate",`ไปที่ ${R0(E(location.pathname+location.search))}`),$=history.pushState.bind(history),Q=history.replaceState.bind(history);history.pushState=(...j)=>{let z=$(...j);return J(),z},history.replaceState=(...j)=>{let z=Q(...j);return J(),z},window.addEventListener("popstate",J),F4()}function k0(){return n.map((J)=>({...J}))}var B1=2000,U0=[],N1=0,w1=!1;function T0(J,$){N1+=1,U0.push({id:`log_${N1}`,at:new Date().toISOString(),level:J,message:$.length>B1?`${$.slice(0,B1)}…`:$});while(U0.length>g("maxConsoleEntries"))U0.shift()}function C4(){let J=new WeakSet;return($,Q)=>{if(typeof Q==="object"&&Q!==null){if(J.has(Q))return"[Circular]";J.add(Q)}if(typeof Q==="bigint")return Q.toString();return Q}}function S1(J){if(typeof J==="string")return J;if(J instanceof Error)return`${J.name}: ${J.message}`;try{let $=JSON.stringify(J,C4());if($!==void 0)return $}catch{}try{return String(J)}catch{}try{return Object.prototype.toString.call(J)}catch{return`[${typeof J}]`}}function O1(){if(w1||typeof window>"u")return;w1=!0;let J=["log","info","warn","error","debug"];for(let $ of J){let Q=console[$].bind(console);console[$]=(...j)=>{T0($,j.map(S1).join(" ")),Q(...j)}}window.addEventListener("error",($)=>{let Q=$.filename?` (${$.filename}:${$.lineno}:${$.colno})`:"";T0("exception",`${$.message}${Q}`)}),window.addEventListener("unhandledrejection",($)=>{let Q=$.reason instanceof Error?`${$.reason.name}: ${$.reason.message}`:S1($.reason);T0("unhandledrejection",Q)})}function A0(){return U0.map((J)=>({...J}))}var R1=new Set,_1=new Set;function L1(J,$){return J.add($),()=>J.delete($)}function k1(J,$){for(let Q of[...J])Q($)}function x0(J){return L1(R1,J)}function f0(J={type:"manual"}){k1(R1,J)}function E0(J){return L1(_1,J)}function h0(J){k1(_1,J)}var I4=15000,D4=["ResizeObserver loop","Script error.","Non-Error promise rejection captured"],T1=!1,A1=0;function q4(J){return D4.some(($)=>J.includes($))}function x1(J){let $=J.message??"";if(!$||q4($))return;let Q=Date.now();if(Q-A1<I4)return;A1=Q,h0({...J,message:$})}function f1(){if(T1||typeof window>"u")return;T1=!0,window.addEventListener("error",(J)=>{if(!J.message&&!J.error)return;let $=J.error instanceof Error?J.error:null;x1({type:"runtime-error",message:J.message||($?$.message:"Unknown error"),stack:$?.stack})}),window.addEventListener("unhandledrejection",(J)=>{let $=J.reason;x1({type:"unhandledrejection",message:$ instanceof Error?$.message:String($),stack:$ instanceof Error?$.stack:void 0})})}var g1=4000,B4=1e6,N4=1e7,P0=[],E1=0,h1=!1;function y1(J){P0.push(J);while(P0.length>g("maxRequests"))P0.shift()}function b1(){return E1+=1,`req_${E1}`}function m1(J){let $={};if(!J)return $;if(J instanceof Headers)J.forEach((Q,j)=>{$[j]=Q});else if(Array.isArray(J))for(let[Q,j]of J)$[Q]=j;else Object.assign($,J);return $}function w4(J){let $={};return J.forEach((Q,j)=>{$[j]=Q}),$}function S4(J){if(J==null)return null;if(typeof J==="string")return J;if(J instanceof URLSearchParams)return J.toString();if(typeof FormData<"u"&&J instanceof FormData)return`[FormData: ${Array.from(J.keys()).join(", ")}]`;if(typeof Blob<"u"&&J instanceof Blob)return`[Blob ${J.size} bytes]`;if(J instanceof ArrayBuffer)return`[ArrayBuffer ${J.byteLength} bytes]`;return"[binary]"}function O4(J,$){let Q="",j="GET",z={},K=null;if(typeof J==="string")Q=J;else if(J instanceof URL)Q=J.toString();else Q=J.url,j=J.method||j,z=m1(J.headers);if($){if($.method)j=$.method;if($.headers)z={...z,...m1($.headers)};if($.body!==void 0)K=S4($.body)}return{method:j.toUpperCase(),url:Q,headers:z,body:K}}function v1(J){return!G1(J)}function R4(J,$){if(v1($.url)){$.responseSnippet="[body not captured for this origin]";return}let Q=J.headers.get("content-type")??"",j=Number(J.headers.get("content-length")??"0"),z=j?`, ~${j} bytes`:"";if(!/json|text|xml|html|javascript|urlencoded/i.test(Q)){$.responseSnippet=`[binary ${Q||"unknown"}${z}]`;return}if(j>B4){$.responseSnippet=`[response ${Q||"text"}${z} — omitted]`;return}try{J.clone().text().then((K)=>{$.responseSnippet=s(K,g("maxBodyChars"))}).catch(()=>{})}catch{}}function p1(J,$){if(/[?&]_rsc=/.test(J))return!0;for(let Q of Object.keys($)){let j=Q.toLowerCase();if(j==="rsc"||j==="next-router-prefetch"||j==="next-router-state-tree")return!0}return!1}function _4(){if(typeof window>"u"||typeof window.fetch!=="function")return;let J=window.fetch.bind(window);window.fetch=Object.assign(async($,Q)=>{let j=O4($,Q);if(p1(j.url,j.headers))return J($,Q);let z={id:b1(),startedAt:new Date().toISOString(),method:j.method,url:E(j.url),requestHeaders:r(j.headers),requestBody:s(j.body,g1),status:null,statusText:null,durationMs:null,via:"fetch"};y1(z);let K=performance.now();try{let W=await J($,Q);return z.status=W.status,z.statusText=W.statusText,z.durationMs=Math.round(performance.now()-K),z.responseHeaders=r(w4(W.headers)),R4(W,z),W}catch(W){throw z.durationMs=Math.round(performance.now()-K),z.error=W instanceof Error?`${W.name}: ${W.message}`:String(W),W}},J)}function L4(){if(typeof window>"u"||typeof window.XMLHttpRequest!=="function")return;let J=XMLHttpRequest.prototype,$=J.open,Q=J.send,j=function(K,W){let G=typeof W==="string"?W:W.toString();return this.__lwEntry=p1(G,{})?void 0:{id:b1(),startedAt:"",method:(K||"GET").toUpperCase(),url:E(G),requestHeaders:{},requestBody:null,status:null,statusText:null,durationMs:null,via:"xhr"},$.apply(this,arguments)},z=function(K){let W=this.__lwEntry;if(W){W.startedAt=new Date().toISOString(),W.requestBody=typeof K==="string"?s(K,g1):K==null?null:"[non-string body]";let G=performance.now();y1(W),this.addEventListener("loadend",()=>{if(W.status=this.status||null,W.statusText=this.statusText||null,W.durationMs=Math.round(performance.now()-G),v1(W.url))W.responseSnippet="[body not captured for this origin]";else if(this.responseType===""||this.responseType==="text")try{W.responseSnippet=s(this.responseText||"",g("maxBodyChars"))}catch{}else{let F=this.getResponseHeader("content-type")??this.responseType;W.responseSnippet=`[binary ${F}]`}})}return Q.apply(this,arguments)};J.open=j,J.send=z}function u1(){if(h1)return;h1=!0,_4(),L4()}function m0(){let J=P0.map((Q)=>({...Q})),$=0;for(let Q=J.length-1;Q>=0;Q-=1){let j=J[Q],z=j?.responseSnippet;if(!j||typeof z!=="string"||z.length===0)continue;if($+z.length>N4)j.responseSnippet=`[response omitted — report size budget reached (${z.length.toLocaleString()} chars)]`;else $+=z.length}return J}var k4=4,d1=3,T4=4000,A4="[data-debug-reporter]",x4=()=>import("@rrweb/record");var A=[],t=null,M0=!1;function c1(){if(typeof window>"u"||t||M0)return;let J=Z0();if(!J)return;M0=!0;let $=()=>void f4(J);if("requestIdleCallback"in window)window.requestIdleCallback($,{timeout:3000});else setTimeout($,1000)}async function f4(J){let $;try{$=(await x4()).record}catch(Q){M0=!1,console.warn("[debug-capture] session replay could not start:",Q);return}if(t)return;try{t=$({emit:(Q)=>E4(Q),checkoutEveryNms:Math.max(1000,J.seconds*1000/2),checkoutEveryNth:T4,maskAllInputs:J.maskInputs,maskTextSelector:J.maskText?"*":J.maskTextSelector,blockSelector:`${J.blockSelector}, ${A4}`,slimDOMOptions:"all",inlineStylesheet:!0,sampling:{mousemove:50,scroll:150,media:800,input:"last",...J.canvas?{canvas:J.canvas.fps}:{}},recordCanvas:J.canvas!==null,...J.canvas?{dataURLOptions:{type:"image/webp",quality:J.canvas.quality}}:{},errorHandler:()=>!0})??null}catch(Q){console.warn("[debug-capture] session replay could not start:",Q)}finally{M0=!1}}function E4(J){if(J.type===k4||A.length===0){if(A.push([]),A.length>d1)A=A.slice(-d1)}A[A.length-1].push(J)}function g0(J=Date.now()){let $=Z0();if(!$||!A.length)return null;let Q=J-$.seconds*1000,j=A.length-1;while(j>0&&(A[j][0]?.timestamp??J)>Q)j-=1;let z=A.slice(j).flat(),K=z[0]?.timestamp,W=z[z.length-1]?.timestamp;if(K===void 0||W===void 0)return null;return{events:z,startedAt:new Date(K).toISOString(),endedAt:new Date(W).toISOString(),durationMs:Math.max(0,W-K)}}function h4(){return t!==null}function m4(){t?.(),t=null,A=[]}var g4={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:"ส่งรายงานไม่สำเร็จ",failedOffline:"ส่งไม่สำเร็จ — เชื่อมต่อเซิร์ฟเวอร์ไม่ได้ ข้อความที่พิมพ์ไว้ยังอยู่ ตรวจสอบอินเทอร์เน็ตแล้วลองใหม่",failedUnavailable:"ส่งไม่สำเร็จ — ระบบกำลังปรับปรุงชั่วคราว ข้อความที่พิมพ์ไว้ยังอยู่ ลองใหม่ในอีกสักครู่",failedTooMany:"แจ้งปัญหาถี่เกินไป — ลองใหม่ในอีก {seconds} วินาที",captured:"เก็บข้อมูลแล้ว",reporter:"ผู้แจ้ง",page:"หน้า",replay:"บันทึกการใช้งาน",handoffTitle:"กำลังพาไปที่ระบบแจ้งปัญหา",handoffBody:"ระบบจะลงชื่อเข้าใช้ให้อัตโนมัติ เพื่อดูเรื่องที่คุณแจ้งไว้",handoffGo:"ไปเลย",handoffPreparing:"กำลังเตรียม…",handoffFailed:"เปิดรายการที่แจ้งไว้ไม่สำเร็จ",handoffBlocked:"เบราว์เซอร์บล็อกการเปิดแท็บใหม่",handoffOpen:"เปิดในแท็บใหม่"},y4={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",failedOffline:"Could not send — the server could not be reached. What you wrote is still here; check your connection and try again.",failedUnavailable:"Could not send — the system is being updated. What you wrote is still here; try again in a moment.",failedTooMany:"Too many reports — try again in {seconds} seconds.",captured:"Captured",reporter:"Reporter",page:"Page",replay:"activity log",handoffTitle:"Opening the support portal",handoffBody:"You will be signed in automatically to see what you reported",handoffGo:"Go now",handoffPreparing:"Preparing…",handoffFailed:"Could not open your reports",handoffBlocked:"Your browser blocked the new tab",handoffOpen:"Open in a new tab"};function d(J){return J==="en"?y4:g4}var b4="lw-debug-toasts",v4=6000,p4=`
2
2
  :host { all: initial; }
3
3
  .stack {
4
4
  position: fixed; top: 16px; right: 16px; z-index: 2147483001;
@@ -30,15 +30,15 @@ var B2=((J)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(J,{get:($,Q)=
30
30
  }
31
31
  @keyframes in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
32
32
  @media (prefers-reduced-motion: reduce) { .toast { animation: none; } }
33
- `,g0=null;function p4(){if(typeof document>"u")return null;if(g0?.isConnected)return g0;let J=document.createElement(y4);J.dataset.debugReporter="true";let $=J.attachShadow({mode:"open"}),Q=document.createElement("style");Q.textContent=v4;let j=document.createElement("div");return j.className="stack",j.setAttribute("role","status"),j.setAttribute("aria-live","polite"),$.append(Q,j),document.body.append(J),g0=j,j}function e(J,$="success",Q){let j=z0()?S().toast:void 0;if(j){j({message:J,tone:$,...Q?{action:Q}:{}});return}let z=p4();if(!z)return;let K=document.createElement("div");K.className="toast",K.dataset.tone=$;let W=document.createElement("span");W.className="dot";let G=document.createElement("span");G.textContent=J;let F=document.createElement("button");F.type="button",F.className="close",F.textContent="✕",F.setAttribute("aria-label","ปิด");let P=()=>{window.clearTimeout(B),K.remove()};F.addEventListener("click",P);let B=$==="error"||Q?0:window.setTimeout(P,b4);if(K.append(W,G),Q){let M=document.createElement("button");M.type="button",M.className="action",M.textContent=Q.label,M.addEventListener("click",()=>{P(),Q.onClick()}),K.append(M)}K.append(F),z.append(K)}function c1(J,$,Q){let j=J.filter((K)=>Boolean(K.error)||K.status!=null&&K.status>=400).slice(-20).map((K)=>({method:K.method,url:K.url,status:K.status,error:K.error,at:K.startedAt})),z=$.filter((K)=>K.level==="error"||K.level==="exception"||K.level==="unhandledrejection").slice(-20).map((K)=>K.message);return{failedRequests:j,errors:z,erroredQueries:Q.slice(0,20)}}function i1(J){return J.failedRequests.length+J.errors.length+J.erroredQueries.length}function u4(){let J={memoryUsedMb:null,memoryLimitMb:null,domContentLoadedMs:null,loadEventMs:null};if(typeof performance>"u")return J;let $=performance.memory;if($)J.memoryUsedMb=Math.round($.usedJSHeapSize/1024/1024),J.memoryLimitMb=Math.round($.jsHeapSizeLimit/1024/1024);let[Q]=performance.getEntriesByType("navigation");if(Q)J.domContentLoadedMs=Math.round(Q.domContentLoadedEventEnd),J.loadEventMs=Math.round(Q.loadEventEnd);return J}function y0(J,$){if(!J)return $;try{return J()}catch{return $}}function l1(){let J=S(),{pathname:$,search:Q,href:j}=window.location;return{capturedAt:new Date().toISOString(),route:{href:j,pathname:$,search:Q},module:K1($),user:y0(J.user,{}),apiHeaders:r(y0(J.headers,{})),app:{name:m().name,version:m().version,environment:m().environment},client:{userAgent:navigator.userAgent,language:navigator.language,platform:navigator.platform,online:navigator.onLine,viewport:{width:window.innerWidth,height:window.innerHeight,dpr:window.devicePixelRatio},screen:{width:window.screen.width,height:window.screen.height}},performance:u4(),extra:y0(J.extra,{})}}var d4=2,c4={manual:"ผู้ใช้แจ้งเอง","runtime-error":"ข้อผิดพลาด runtime (auto)",unhandledrejection:"Promise rejection (auto)","framework-error":"หน้าจอค้าง/พัง (auto)"};function b0(J){let $=h0(),Q=T0();return{context:l1(),reason:J.reason,note:J.note,cause:c1($,Q,J.erroredQueries),actionTrail:L0(),network:$,console:Q,screenshotDataUrl:J.screenshotDataUrl,screenshotMethod:J.screenshotMethod,replay:m0()??void 0,meta:{generatedBy:"lightwork-debug-capture",schemaVersion:d4}}}function o1(J){return J.replace(/'/g,"'\\''")}function r1(J){let $=[`curl -X ${J.method} '${J.url}'`];for(let[Q,j]of Object.entries(J.requestHeaders))$.push(` -H '${Q}: ${o1(j)}'`);if(J.requestBody)$.push(` --data '${o1(J.requestBody)}'`);return $.join(" \\\n")}function i4(J){if(J.error)return`ERR ${J.error}`;return`${J.status??"—"} ${J.statusText??""}`.trim()}function l4(J){if(J.length===0)return"No network activity captured.";return J.map(($)=>{let Q=$.durationMs!=null?`${$.durationMs}ms`:"—",j=`# [${i4($)}] ${$.method} ${$.url} (${Q}, ${$.startedAt})`,z=$.responseSnippet?`
33
+ `,y0=null;function u4(){if(typeof document>"u")return null;if(y0?.isConnected)return y0;let J=document.createElement(b4);J.dataset.debugReporter="true";let $=J.attachShadow({mode:"open"}),Q=document.createElement("style");Q.textContent=p4;let j=document.createElement("div");return j.className="stack",j.setAttribute("role","status"),j.setAttribute("aria-live","polite"),$.append(Q,j),document.body.append(J),y0=j,j}function e(J,$="success",Q){let j=z0()?w().toast:void 0;if(j){j({message:J,tone:$,...Q?{action:Q}:{}});return}let z=u4();if(!z)return;let K=document.createElement("div");K.className="toast",K.dataset.tone=$;let W=document.createElement("span");W.className="dot";let G=document.createElement("span");G.textContent=J;let F=document.createElement("button");F.type="button",F.className="close",F.textContent="✕",F.setAttribute("aria-label","ปิด");let P=()=>{window.clearTimeout(B),K.remove()};F.addEventListener("click",P);let B=$==="error"||Q?0:window.setTimeout(P,v4);if(K.append(W,G),Q){let M=document.createElement("button");M.type="button",M.className="action",M.textContent=Q.label,M.addEventListener("click",()=>{P(),Q.onClick()}),K.append(M)}K.append(F),z.append(K)}function i1(J,$,Q){let j=J.filter((K)=>Boolean(K.error)||K.status!=null&&K.status>=400).slice(-20).map((K)=>({method:K.method,url:K.url,status:K.status,error:K.error,at:K.startedAt})),z=$.filter((K)=>K.level==="error"||K.level==="exception"||K.level==="unhandledrejection").slice(-20).map((K)=>K.message);return{failedRequests:j,errors:z,erroredQueries:Q.slice(0,20)}}function l1(J){return J.failedRequests.length+J.errors.length+J.erroredQueries.length}function d4(){let J={memoryUsedMb:null,memoryLimitMb:null,domContentLoadedMs:null,loadEventMs:null};if(typeof performance>"u")return J;let $=performance.memory;if($)J.memoryUsedMb=Math.round($.usedJSHeapSize/1024/1024),J.memoryLimitMb=Math.round($.jsHeapSizeLimit/1024/1024);let[Q]=performance.getEntriesByType("navigation");if(Q)J.domContentLoadedMs=Math.round(Q.domContentLoadedEventEnd),J.loadEventMs=Math.round(Q.loadEventEnd);return J}function b0(J,$){if(!J)return $;try{return J()}catch{return $}}function o1(){let J=w(),{pathname:$,search:Q,href:j}=window.location;return{capturedAt:new Date().toISOString(),route:{href:j,pathname:$,search:Q},module:W1($),user:b0(J.user,{}),apiHeaders:r(b0(J.headers,{})),app:{name:m().name,version:m().version,environment:m().environment},client:{userAgent:navigator.userAgent,language:navigator.language,platform:navigator.platform,online:navigator.onLine,viewport:{width:window.innerWidth,height:window.innerHeight,dpr:window.devicePixelRatio},screen:{width:window.screen.width,height:window.screen.height}},performance:d4(),extra:b0(J.extra,{})}}var c4=2,i4={manual:"ผู้ใช้แจ้งเอง","runtime-error":"ข้อผิดพลาด runtime (auto)",unhandledrejection:"Promise rejection (auto)","framework-error":"หน้าจอค้าง/พัง (auto)"};function v0(J){let $=m0(),Q=A0();return{context:o1(),reason:J.reason,note:J.note,cause:i1($,Q,J.erroredQueries),actionTrail:k0(),network:$,console:Q,screenshotDataUrl:J.screenshotDataUrl,screenshotMethod:J.screenshotMethod,replay:g0()??void 0,meta:{generatedBy:"lightwork-debug-capture",schemaVersion:c4}}}function r1(J){return J.replace(/'/g,"'\\''")}function s1(J){let $=[`curl -X ${J.method} '${J.url}'`];for(let[Q,j]of Object.entries(J.requestHeaders))$.push(` -H '${Q}: ${r1(j)}'`);if(J.requestBody)$.push(` --data '${r1(J.requestBody)}'`);return $.join(" \\\n")}function l4(J){if(J.error)return`ERR ${J.error}`;return`${J.status??"—"} ${J.statusText??""}`.trim()}function o4(J){if(J.length===0)return"No network activity captured.";return J.map(($)=>{let Q=$.durationMs!=null?`${$.durationMs}ms`:"—",j=`# [${l4($)}] ${$.method} ${$.url} (${Q}, ${$.startedAt})`,z=$.responseSnippet?`
34
34
  # response: ${$.responseSnippet}`:"";return`${j}
35
- ${r1($)}${z}`}).join(`
35
+ ${s1($)}${z}`}).join(`
36
36
 
37
- `)}function o4(J){if(J.length===0)return"No console output captured.";return J.map(($)=>`[${$.at}] ${$.level.toUpperCase()}: ${$.message}`).join(`
38
- `)}function r4(J){if(J.length===0)return"No user actions captured.";let $=0;return J.map((Q)=>{let j=Q.source?` (${Q.source})`:"",z=`${Q.detail}${R0(Q.count)}${j}`;if(Q.kind==="ui")return` ↳ [${Q.at}] ${z}`;$+=1;let K=`${$}. [${Q.at}] ${z}`;return Q.afterNote?`${K}
37
+ `)}function r4(J){if(J.length===0)return"No console output captured.";return J.map(($)=>`[${$.at}] ${$.level.toUpperCase()}: ${$.message}`).join(`
38
+ `)}function s4(J){if(J.length===0)return"No user actions captured.";let $=0;return J.map((Q)=>{let j=Q.source?` (${Q.source})`:"",z=`${Q.detail}${_0(Q.count)}${j}`;if(Q.kind==="ui")return` ↳ [${Q.at}] ${z}`;$+=1;let K=`${$}. [${Q.at}] ${z}`;return Q.afterNote?`${K}
39
39
  ↳ ${Q.afterNote}`:K}).join(`
40
- `)}function s4(J){let $=[];for(let Q of J.failedRequests)$.push(`✗ ${Q.status??Q.error??"ERR"} ${Q.method} ${Q.url}`);for(let Q of J.errors)$.push(`⚠ ${Q}`);for(let Q of J.erroredQueries)$.push(`⚠ React Query error: ${Q.key} — ${Q.error}`);return $}function n4(J){let{context:$}=J;return[`User : ${$.user.fullName??"—"} (${$.user.email??"—"})`,`Unit : ${$.user.unit??"—"}`,`Roles : ${$.user.roles?.join(", ")||"—"}`,`Route : ${$.route.href}`,`Module : ${$.module?`${$.module.label} (${$.module.key})`:"—"}`,`App : ${$.app.name} v${$.app.version} · ${$.app.environment}`,`Memory : ${$.performance.memoryUsedMb??"—"}/${$.performance.memoryLimitMb??"—"} MB`,`Client : ${$.client.userAgent}`,`Viewport : ${$.client.viewport.width}×${$.client.viewport.height} @${$.client.viewport.dpr}x`,`Reason : ${c4[J.reason.type]}${J.reason.message?` — ${J.reason.message}`:""}`,`Captured : ${J.network.length} requests · ${J.console.length} console · ${J.actionTrail.length} actions · screenshot=${J.screenshotMethod}${J.replay?` · replay=${Math.round(J.replay.durationMs/1000)}s`:""}`]}function a4(J){let $=s4(J.cause),Q=[`## \uD83D\uDC1E ${J.context.app.name} — Debug Report`,`**Generated:** ${J.context.capturedAt}`,"",...n4(J).map((j)=>`- ${j.replace(/\s{2,}:/,":")}`),"",`**หมายเหตุจากผู้แจ้ง:** ${J.note.trim()||"(ไม่มี)"}`];if($.length>0)Q.push("","### ⚠ สาเหตุที่น่าจะเป็น","```",...$,"```");return Q.push("",`<details><summary>ขั้นตอน (${J.actionTrail.length})</summary>`,"","```",r4(J.actionTrail),"```","</details>","",`<details><summary>Network (${J.network.length})</summary>`,"","```",l4(J.network),"```","</details>","",`<details><summary>Console (${J.console.length})</summary>`,"","```",o4(J.console),"```","</details>","","_ข้อมูลลับ (token, cookie) ถูกปกปิดอัตโนมัติ · ภาพหน้าจออยู่ในไฟล์ .zip_"),Q.join(`
41
- `)}function t4(J){return J.replace(/[:.]/g,"-").replace("T","_").slice(0,19)}function e4(J,$){return`debug-report_${t4(J.context.capturedAt)}.${$}`}function J6(J){return i1(J.cause)>0}async function v0(){if(typeof navigator<"u"&&Boolean(navigator.mediaDevices?.getDisplayMedia)){let Q=await $6();if(Q.status==="ok")return{dataUrl:Q.dataUrl,method:"display-media"};if(Q.status==="cancelled")return{dataUrl:null,method:"cancelled"}}let $=await z6();if($)return{dataUrl:$,method:"html-to-image"};return{dataUrl:null,method:"none"}}async function $6(){let J=null;try{let $={video:{frameRate:30},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude"};J=await navigator.mediaDevices.getDisplayMedia($);let Q=await Q6(J);return Q?{status:"ok",dataUrl:Q}:{status:"error"}}catch($){if($ instanceof DOMException&&($.name==="NotAllowedError"||$.name==="AbortError"))return{status:"cancelled"};return{status:"error"}}finally{J?.getTracks().forEach(($)=>$.stop())}}async function Q6(J){let $=document.createElement("video");$.srcObject=J,$.muted=!0,$.playsInline=!0,await new Promise((W)=>{let G=!1,F=()=>{if(G)return;G=!0,W()};$.onloadedmetadata=()=>{$.play().then(F).catch(F)},window.setTimeout(F,1500)}),await j6($);let{videoWidth:Q,videoHeight:j}=$;if(!Q||!j)return null;let z=document.createElement("canvas");z.width=Q,z.height=j;let K=z.getContext("2d");if(!K)return null;K.drawImage($,0,0,Q,j),$.pause(),$.srcObject=null;try{return z.toDataURL("image/png")}catch{return null}}function j6(J){return new Promise(($)=>{let Q=!1,j=()=>{if(Q)return;Q=!0,$()},z=J;if(typeof z.requestVideoFrameCallback==="function")z.requestVideoFrameCallback(()=>j()),window.setTimeout(j,1000);else window.setTimeout(j,250)})}async function z6(){let J=S().screenshotFallback;if(!J)return null;let $=await J().catch(()=>null);if(!$)return null;try{return await $(document.body,{cacheBust:!0,pixelRatio:Math.min(window.devicePixelRatio||1,2),filter:(Q)=>!(Q instanceof HTMLElement&&Q.dataset?.debugReporter==="true")})}catch{return null}}var Z6=2000,K6=0.82,W6=3000000;function Y6(J){return new Promise(($,Q)=>{let j=new Image;j.onload=()=>$(j),j.onerror=()=>Q(Error("could not read the screenshot")),j.src=J})}async function s1(J){try{let $=await Y6(J),Q=Math.max($.naturalWidth,$.naturalHeight),j=Math.min(1,Z6/Q),z=document.createElement("canvas");z.width=Math.max(1,Math.round($.naturalWidth*j)),z.height=Math.max(1,Math.round($.naturalHeight*j));let K=z.getContext("2d");if(!K)return J;K.fillStyle="#fff",K.fillRect(0,0,z.width,z.height),K.drawImage($,0,0,z.width,z.height);let W=K6,G=z.toDataURL("image/jpeg",W);while(G.length>W6&&W>0.4)W-=0.15,G=z.toDataURL("image/jpeg",W);return G}catch{return J}}var G6=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,V6=/^\d+$/,X6=/^[0-9a-f]{16,}$/i;function p0(J){if(J.reason.type==="manual")return null;let $=J.cause?.failedRequests?.[0];if(!$?.url)return null;let Q;try{Q=new URL($.url,"http://x").pathname}catch{Q=$.url}let j=Q.split("/").map((K)=>G6.test(K)||V6.test(K)||X6.test(K)?":id":K).join("/"),z=$.status??($.error?"ERR":"?");return`${$.method??"REQ"} ${j} ${z}`}var u0=2000000;function C0(J){let{screenshotDataUrl:$,replay:Q,...j}=J;return JSON.stringify(j).length}function d0(J,$=2000000){if(C0(J)<=$)return J;let Q=J.network.map((z)=>({...z})),j={...J,network:Q};for(let z of Q){if(C0(j)<=$)return j;if(typeof z.responseSnippet==="string"&&z.responseSnippet.length>35)z.responseSnippet="[body dropped — report size budget]";if(typeof z.requestBody==="string"&&z.requestBody.length>35)z.requestBody="[body dropped — report size budget]"}while(j.network.length>1&&C0(j)>$)j.network=j.network.slice(1);while(j.console.length>1&&C0(j)>$)j.console=j.console.slice(1);return j}function Y0(J){let $="";for(let Q=0;Q<J.length;Q+=32768)$+=String.fromCharCode(...J.subarray(Q,Q+32768));return btoa($)}var F6=4,H6=2,U6=3,P6=0,M6=new Set(["href","src","action","formaction","xlink:href","data","poster","srcset"]),C6=/^\s*javascript:/i;function I6(J,$){let Q=J.toLowerCase();if(Q.startsWith("on")||Q==="srcdoc")return!0;return typeof $==="string"&&C6.test($)}function n1(J,$=!1){if(!J)return;for(let Q of Object.keys(J)){let j=J[Q];if(I6(Q,j)){if($)J[Q]=null;else delete J[Q];continue}if(typeof j!=="string"||!M6.has(Q)||!j.includes("?"))continue;J[Q]=E(j)}}function c0(J){if(!J)return;n1(J.attributes);for(let $ of J.childNodes??[])c0($)}function a1(J){let $=JSON.parse(JSON.stringify(J));for(let Q of $){let j=Q.data;if(!j||typeof j!=="object")continue;if(Q.type===F6&&typeof j.href==="string")j.href=E(j.href);else if(Q.type===H6)c0(j.node);else if(Q.type===U6&&j.source===P6){for(let z of j.adds??[])c0(z.node);for(let z of j.attributes??[])n1(z.attributes,!0)}}return $}var e1="session-replay.json.gz",D6="session-replay.json";function q6(J){return Boolean(J&&J.events.length>0)}async function B6(J){if(typeof CompressionStream>"u")return null;try{let $=new Blob([J]).stream().pipeThrough(new CompressionStream("gzip"));return new Uint8Array(await new Response($).arrayBuffer())}catch{return null}}async function i0(J,$){if(!q6(J))return{summary:{omitted:"empty"}};let j={seconds:Math.round(J.durationMs/1000),events:J.events.length,startedAt:J.startedAt,endedAt:J.endedAt},z=a1(J.events),K=await t1(z),W=!1;if(K.bytes.byteLength>$&&w6(z))z=O6(z),K=await t1(z),W=!0;let{bytes:G,compressed:F}=K;if(G.byteLength>$)return{summary:{...j,bytes:G.byteLength,omitted:"too-large"}};return{dataUri:`data:${F?"application/gzip":"application/json"};base64,${Y0(G)}`,filename:F?e1:D6,summary:{...j,events:z.length,bytes:G.byteLength,compressed:F,...W?{canvasDropped:W}:{}}}}async function t1(J){let $=new TextEncoder().encode(JSON.stringify({events:J})),Q=await B6($);return Q?{bytes:Q,compressed:!0}:{bytes:$,compressed:!1}}var N6=3,J2=2,S6=9;function $2(J){return J.type===N6&&J.data?.source===S6}function w6(J){return J.some($2)||J.some(($)=>$.type===J2&&Q2($.data.node))}function Q2(J){if(!J)return!1;if(J.attributes&&"rr_dataURL"in J.attributes)return!0;return(J.childNodes??[]).some(Q2)}function j2(J){if(!J)return;if(J.attributes&&"rr_dataURL"in J.attributes)delete J.attributes.rr_dataURL;for(let $ of J.childNodes??[])j2($)}function O6(J){let $=[];for(let Q of J){if($2(Q))continue;if(Q.type===J2)j2(Q.data.node);$.push(Q)}return $}var R6=new Set([502,503,504]);class c extends Error{kind;retryAfter;status;constructor(J,$,Q,j){super(J);this.kind=$;this.retryAfter=Q;this.status=j;this.name="ReportError"}}function _6(J){let{screenshotDataUrl:$,replay:Q,...j}=J;return{dataUri:`data:application/json;base64,${Y0(new TextEncoder().encode(JSON.stringify(j)))}`,filename:"debug-bundle.json"}}async function L6(){let J=S().identity;if(!J)return{};try{let $=await J();return $?{authorization:`Bearer ${$}`}:{}}catch{return{}}}async function l0(J,$){let Q=S(),j=d0($,u0),{context:z,note:K}=j,W=[];if(j.screenshotDataUrl){let C=await s1(j.screenshotDataUrl);W.push({dataUri:C,filename:"screenshot.jpg"})}W.push(_6(j));let G,F=Z0();if(F){let C=await i0(j.replay,F.maxBytes);if(G=C.summary,"dataUri"in C)W.push({dataUri:C.dataUri,filename:C.filename})}let P=p0(j),B={title:J,description:K.trim()||void 0,appName:m().name,category:z.module?.label,routeUrl:z.route.href,priority:"MEDIUM",requesterEmail:z.user.email??void 0,requesterName:z.user.fullName??void 0,customFields:{unit:z.user.unit??"",appVersion:z.app.version,environment:z.app.environment,reasonType:j.reason.type,appName:m().name,module:z.module?.label??""},context:{...P?{signature:P}:{},capturedAt:z.capturedAt,reason:j.reason,cause:j.cause,actionTrail:j.actionTrail,client:z.client,performance:z.performance,apiHeaders:z.apiHeaders,extra:z.extra,counts:{network:j.network.length,console:j.console.length,actions:j.actionTrail.length},screenshotMethod:j.screenshotMethod,...G?{replay:G}:{}},attachments:W},M=await fetch(`${Q.host.replace(/\/$/,"")}/ingest/tickets`,{method:"POST",headers:{"content-type":"application/json","x-realm-key":Q.realmKey,...await L6()},body:JSON.stringify(B)}).catch(()=>{throw new c("report never left the browser","offline")});if(!M.ok){let C=M.headers.get("retry-after"),w=await M.json().then((D)=>D.error).catch(()=>null);if(M.status===429)throw new c("rate limited","rateLimited",C??void 0);if(R6.has(M.status))throw new c("desk unavailable","unavailable");throw new c(w??`Report failed (${M.status})`,"rejected",void 0,M.status)}return await M.json()}var G0=Math.PI/6;function z2(J,$,Q){let j=$.x-J.x,z=$.y-J.y,K=Math.hypot(j,z),W=Math.atan2(z,j),G=[{x:$.x,y:$.y},{x:$.x-Q*Math.cos(W-G0),y:$.y-Q*Math.sin(W-G0)},{x:$.x-Q*Math.cos(W+G0),y:$.y-Q*Math.sin(W+G0)}],F=Q*Math.cos(G0)*0.92;if(K<=F)return{shaft:null,head:G};return{shaft:{from:J,to:{x:$.x-F*Math.cos(W),y:$.y-F*Math.sin(W)}},head:G}}var o0="#f44336",k6="rgba(250, 204, 21, 0.4)",r0=22,Z2="#2563eb",K2=9,W2=11,Y2=18,G2=4,I0=8,T6=[{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 s0(J,$,Q){let j=[],z=null,K=-1,W=null,G=null,F=J.getContext("2d");function P(){let Z=J.getBoundingClientRect().width;return Z>0?J.width/Z:1}function B(Z){let Y=J.getBoundingClientRect();return{x:(Z.clientX-Y.left)/Y.width*J.width,y:(Z.clientY-Y.top)/Y.height*J.height}}function M(Z){let Y=Z.size??r0;if(!F)return(Z.text?.length??0)*Y*0.6;F.save(),F.font=`600 ${Y}px system-ui, sans-serif`;let X=F.measureText(Z.text??"").width;return F.restore(),X}function C(Z){if(Z.tool==="text"){let Y=Z.size??r0;return{left:Z.x1,top:Z.y1,right:Z.x1+M(Z),bottom:Z.y1+Y*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 w(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 Y=C(Z);if(Z.tool==="text")return[{id:"size",x:Y.right,y:Y.bottom,cursor:"nwse-resize"}];return T6.map((X)=>({id:X.id,x:Y.left+(Y.right-Y.left)*X.fx,y:Y.top+(Y.bottom-Y.top)*X.fy,cursor:X.cursor}))}function D(Z){let Y=C(Z);return{x:Y.right+Y2*P(),y:Y.top-Y2*P()}}function R(Z,Y,X){let{shaft:V,head:H}=z2({x:Y.x1,y:Y.y1},{x:Y.x2,y:Y.y2},Math.max(10,16*X));if(V)Z.lineCap="butt",Z.beginPath(),Z.moveTo(V.from.x,V.from.y),Z.lineTo(V.to.x,V.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,Y,X){Z.save(),Z.lineWidth=Math.max(2,3*X),Z.strokeStyle=o0,Z.fillStyle=o0;let V=C(Y);if(Y.tool==="rect")Z.strokeRect(V.left,V.top,V.right-V.left,V.bottom-V.top);else if(Y.tool==="arrow")R(Z,Y,X);else if(Y.tool==="highlight")Z.fillStyle=k6,Z.fillRect(V.left,V.top,V.right-V.left,V.bottom-V.top);else if(Y.tool==="text"&&Y.text){let H=Y.size??r0;Z.font=`600 ${H}px system-ui, sans-serif`,Z.textBaseline="top";let U=H*0.22;Z.fillStyle="rgba(255,255,255,0.92)",Z.fillRect(V.left-U,V.top-U,V.right-V.left+U*2,V.bottom-V.top+U*2),Z.fillStyle=o0,Z.fillText(Y.text,V.left,V.top)}Z.restore()}function q(Z,Y,X){let V=C(Y);Z.save(),Z.strokeStyle=Z2,Z.lineWidth=Math.max(1,1.5*X),Z.setLineDash([6*X,4*X]),Z.strokeRect(V.left,V.top,V.right-V.left,V.bottom-V.top),Z.setLineDash([]);let H=K2*X;for(let x of w(Y))Z.fillStyle="#fff",Z.strokeStyle=Z2,Z.lineWidth=Math.max(1,1.5*X),Z.beginPath(),Z.rect(x.x-H/2,x.y-H/2,H,H),Z.fill(),Z.stroke();let U=D(Y),I=W2*X;Z.beginPath(),Z.arc(U.x,U.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(U.x-I*0.4,U.y-I*0.4),Z.lineTo(U.x+I*0.4,U.y+I*0.4),Z.moveTo(U.x+I*0.4,U.y-I*0.4),Z.lineTo(U.x-I*0.4,U.y+I*0.4),Z.stroke(),Z.restore()}function O(){if(!F)return;let Z=P();if(F.clearRect(0,0,J.width,J.height),F.drawImage($,0,0,J.width,J.height),j.forEach((X,V)=>{if(V!==v)_(F,X,Z)}),W)_(F,W,Z);let Y=j[K];if(Y&&!W)q(F,Y,Z)}function y(Z,Y,X,V,H){return Math.abs(Z-X)<=H&&Math.abs(Y-V)<=H}function Q0(Z,Y){let X=j[K];if(!X)return null;let V=K2*P()/2+3*P();for(let H of w(X))if(y(Z,Y,H.x,H.y,V))return H.id;return null}function i(Z,Y){let X=j[K];if(!X)return!1;let V=D(X);return y(Z,Y,V.x,V.y,W2*P())}function h(Z,Y){let X=6*P();for(let V=j.length-1;V>=0;V-=1){let H=j[V];if(H.tool==="arrow"){let I=H.x2-H.x1,x=H.y2-H.y1,p=Math.hypot(I,x)||1,u=Math.max(0,Math.min(1,((Z-H.x1)*I+(Y-H.y1)*x)/(p*p)));if(Math.hypot(Z-(H.x1+u*I),Y-(H.y1+u*x))<=X+4*P())return V;continue}let U=C(H);if(Z>=U.left-X&&Z<=U.right+X&&Y>=U.top-X&&Y<=U.bottom+X)return V}return-1}function b(Z,Y,X,V,H){if(Y==="tail"){Z.x1=X.x1+V,Z.y1=X.y1+H;return}if(Y==="head"){Z.x2=X.x2+V,Z.y2=X.y2+H;return}if(Y==="size"){let q2=(X.size??24)+H;Z.size=Math.max(10,q2);return}let U=C(X),{left:I,top:x,right:p,bottom:u}=U;if(Y.includes("w"))I=Math.min(p-I0,I+V);if(Y.includes("e"))p=Math.max(I+I0,p+V);if(Y.includes("n"))x=Math.min(u-I0,x+H);if(Y.includes("s"))u=Math.max(x+I0,u+H);Z.x1=I,Z.y1=x,Z.x2=p,Z.y2=u}function q0(Z,Y,X,V){Z.x1=Y.x1+X,Z.y1=Y.y1+V,Z.x2=Y.x2+X,Z.y2=Y.y2+V}let L=null,v=-1,N={x:0,y:0,size:24};function f(){let Z=J.getBoundingClientRect().width;return Z>0?Z/J.width:1}function D2(Z,Y){if(!F)return Z.length*Y*0.6;F.save(),F.font=`600 ${Y}px system-ui, sans-serif`;let X=F.measureText(Z||" ").width;return F.restore(),X}function e0(){if(!L)return;let Z=J.parentElement;if(!Z)return;let Y=J.getBoundingClientRect(),X=Z.getBoundingClientRect(),V=f(),H=N.size*V;L.style.left=`${Y.left-X.left+N.x*V}px`,L.style.top=`${Y.top-X.top+N.y*V}px`,L.style.fontSize=`${H}px`,L.style.width=`${Math.max(40,D2(L.value,H)+H)}px`}function j0(Z){let Y=L;if(!Y)return;L=null;let X=Y.value.trim(),V=v;if(v=-1,Y.remove(),Z&&X){if(V>=0&&j[V])j[V].text=X,K=V;else j.push({tool:"text",x1:N.x,y1:N.y,x2:N.x,y2:N.y,text:X,size:N.size}),K=j.length-1;Q()}else if(V>=0)K=V;J.focus(),O()}function J1(Z,Y,X=-1){j0(!0);let V=J.parentElement;if(!V)return;if(getComputedStyle(V).position==="static")V.style.position="relative";let H=X>=0?j[X]:void 0;v=X,N={x:H?.x1??Z,y:H?.y1??Y,size:H?.size??Math.round(24*P())};let U=document.createElement("input");U.type="text",U.className="text-edit",U.value=H?.text??"",U.setAttribute("aria-label","ข้อความบนภาพ"),U.placeholder="ข้อความ",L=U,V.append(U),e0(),U.addEventListener("input",e0),U.addEventListener("keydown",(I)=>{if(I.stopPropagation(),I.key==="Enter")j0(!0);else if(I.key==="Escape")j0(!1)}),requestAnimationFrame(()=>{if(L!==U)return;U.focus(),U.select(),U.addEventListener("blur",()=>j0(!0))}),O()}function $1(Z){let{x:Y,y:X}=B(Z);if(J.setPointerCapture(Z.pointerId),i(Y,X)){B0();return}let V=Q0(Y,X);if(V&&j[K]){G={grip:V,x:Y,y:X,start:{...j[K]}};return}if(z==="text"){if(Z.preventDefault(),J.hasPointerCapture(Z.pointerId))J.releasePointerCapture(Z.pointerId);z=null,Q(),J1(Y,X);return}if(z){W={tool:z,x1:Y,y1:X,x2:Y,y2:X},K=-1;return}let H=h(Y,X);K=H,G=H>=0?{grip:"body",x:Y,y:X,start:{...j[H]}}:null,O()}function Q1(Z){let{x:Y,y:X}=B(Z);if(W){W.x2=Y,W.y2=X,O();return}if(G){let H=j[K];if(!H)return;let U=Y-G.x,I=X-G.y;if(G.grip==="body")q0(H,G.start,U,I);else b(H,G.grip,G.start,U,I);O();return}if(z){J.style.cursor="crosshair";return}if(i(Y,X)){J.style.cursor="pointer";return}let V=Q0(Y,X);if(V){let H=j[K]?w(j[K]).find((U)=>U.id===V):null;J.style.cursor=H?.cursor??"pointer";return}J.style.cursor=h(Y,X)>=0?"move":"default"}function V0(){if(W){if(!(Math.abs(W.x2-W.x1)<G2&&Math.abs(W.y2-W.y1)<G2))j.push(W),K=j.length-1,z=null,Q();W=null}if(G)G=null,Q();O()}function j1(Z){let Y=J.getBoundingClientRect(),X=(Z.clientX-Y.left)/Y.width*J.width,V=(Z.clientY-Y.top)/Y.height*J.height,H=h(X,V),U=j[H];if(!U||U.tool!=="text")return;Z.preventDefault(),J1(U.x1,U.y1,H)}function z1(Z){if(K<0)return;if(Z.key==="Delete"||Z.key==="Backspace")Z.preventDefault(),B0();else if(Z.key==="Escape")K=-1,O()}function B0(){if(K<0)return;j.splice(K,1),K=-1,Q(),O()}return J.addEventListener("pointerdown",$1),J.addEventListener("pointermove",Q1),J.addEventListener("pointerup",V0),J.addEventListener("pointercancel",V0),J.addEventListener("dblclick",j1),J.tabIndex=0,J.addEventListener("keydown",z1),O(),{setTool(Z){z=Z,K=-1,J.style.cursor=Z?"crosshair":"default",O()},deleteSelected:B0,clear(){j.length=0,K=-1,Q(),O()},hasShapes:()=>j.length>0,hasSelection:()=>K>=0,toDataUrl(){let Z=document.createElement("canvas");Z.width=$.naturalWidth,Z.height=$.naturalHeight;let Y=Z.getContext("2d");if(!Y)return J.toDataURL("image/png");Y.drawImage($,0,0);let X=P();for(let V of j)_(Y,V,X);return Z.toDataURL("image/png")},destroy(){j0(!1),J.removeEventListener("pointerdown",$1),J.removeEventListener("pointermove",Q1),J.removeEventListener("pointerup",V0),J.removeEventListener("pointercancel",V0),J.removeEventListener("dblclick",j1),J.removeEventListener("keydown",z1)}}}var V2=`
40
+ `)}function n4(J){let $=[];for(let Q of J.failedRequests)$.push(`✗ ${Q.status??Q.error??"ERR"} ${Q.method} ${Q.url}`);for(let Q of J.errors)$.push(`⚠ ${Q}`);for(let Q of J.erroredQueries)$.push(`⚠ React Query error: ${Q.key} — ${Q.error}`);return $}function a4(J){let{context:$}=J;return[`User : ${$.user.fullName??"—"} (${$.user.email??"—"})`,`Unit : ${$.user.unit??"—"}`,`Roles : ${$.user.roles?.join(", ")||"—"}`,`Route : ${$.route.href}`,`Module : ${$.module?`${$.module.label} (${$.module.key})`:"—"}`,`App : ${$.app.name} v${$.app.version} · ${$.app.environment}`,`Memory : ${$.performance.memoryUsedMb??"—"}/${$.performance.memoryLimitMb??"—"} MB`,`Client : ${$.client.userAgent}`,`Viewport : ${$.client.viewport.width}×${$.client.viewport.height} @${$.client.viewport.dpr}x`,`Reason : ${i4[J.reason.type]}${J.reason.message?` — ${J.reason.message}`:""}`,`Captured : ${J.network.length} requests · ${J.console.length} console · ${J.actionTrail.length} actions · screenshot=${J.screenshotMethod}${J.replay?` · replay=${Math.round(J.replay.durationMs/1000)}s`:""}`]}function t4(J){let $=n4(J.cause),Q=[`## \uD83D\uDC1E ${J.context.app.name} — Debug Report`,`**Generated:** ${J.context.capturedAt}`,"",...a4(J).map((j)=>`- ${j.replace(/\s{2,}:/,":")}`),"",`**หมายเหตุจากผู้แจ้ง:** ${J.note.trim()||"(ไม่มี)"}`];if($.length>0)Q.push("","### ⚠ สาเหตุที่น่าจะเป็น","```",...$,"```");return Q.push("",`<details><summary>ขั้นตอน (${J.actionTrail.length})</summary>`,"","```",s4(J.actionTrail),"```","</details>","",`<details><summary>Network (${J.network.length})</summary>`,"","```",o4(J.network),"```","</details>","",`<details><summary>Console (${J.console.length})</summary>`,"","```",r4(J.console),"```","</details>","","_ข้อมูลลับ (token, cookie) ถูกปกปิดอัตโนมัติ · ภาพหน้าจออยู่ในไฟล์ .zip_"),Q.join(`
41
+ `)}function e4(J){return J.replace(/[:.]/g,"-").replace("T","_").slice(0,19)}function J6(J,$){return`debug-report_${e4(J.context.capturedAt)}.${$}`}function $6(J){return l1(J.cause)>0}async function p0(){if(typeof navigator<"u"&&Boolean(navigator.mediaDevices?.getDisplayMedia)){let Q=await Q6();if(Q.status==="ok")return{dataUrl:Q.dataUrl,method:"display-media"};if(Q.status==="cancelled")return{dataUrl:null,method:"cancelled"}}let $=await Z6();if($)return{dataUrl:$,method:"html-to-image"};return{dataUrl:null,method:"none"}}async function Q6(){let J=null;try{let $={video:{frameRate:30},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude"};J=await navigator.mediaDevices.getDisplayMedia($);let Q=await j6(J);return Q?{status:"ok",dataUrl:Q}:{status:"error"}}catch($){if($ instanceof DOMException&&($.name==="NotAllowedError"||$.name==="AbortError"))return{status:"cancelled"};return{status:"error"}}finally{J?.getTracks().forEach(($)=>$.stop())}}async function j6(J){let $=document.createElement("video");$.srcObject=J,$.muted=!0,$.playsInline=!0,await new Promise((W)=>{let G=!1,F=()=>{if(G)return;G=!0,W()};$.onloadedmetadata=()=>{$.play().then(F).catch(F)},window.setTimeout(F,1500)}),await z6($);let{videoWidth:Q,videoHeight:j}=$;if(!Q||!j)return null;let z=document.createElement("canvas");z.width=Q,z.height=j;let K=z.getContext("2d");if(!K)return null;K.drawImage($,0,0,Q,j),$.pause(),$.srcObject=null;try{return z.toDataURL("image/png")}catch{return null}}function z6(J){return new Promise(($)=>{let Q=!1,j=()=>{if(Q)return;Q=!0,$()},z=J;if(typeof z.requestVideoFrameCallback==="function")z.requestVideoFrameCallback(()=>j()),window.setTimeout(j,1000);else window.setTimeout(j,250)})}async function Z6(){let J=w().screenshotFallback;if(!J)return null;let $=await J().catch(()=>null);if(!$)return null;try{return await $(document.body,{cacheBust:!0,pixelRatio:Math.min(window.devicePixelRatio||1,2),filter:(Q)=>!(Q instanceof HTMLElement&&Q.dataset?.debugReporter==="true")})}catch{return null}}var K6=2000,W6=0.82,Y6=3000000;function G6(J){return new Promise(($,Q)=>{let j=new Image;j.onload=()=>$(j),j.onerror=()=>Q(Error("could not read the screenshot")),j.src=J})}async function n1(J){try{let $=await G6(J),Q=Math.max($.naturalWidth,$.naturalHeight),j=Math.min(1,K6/Q),z=document.createElement("canvas");z.width=Math.max(1,Math.round($.naturalWidth*j)),z.height=Math.max(1,Math.round($.naturalHeight*j));let K=z.getContext("2d");if(!K)return J;K.fillStyle="#fff",K.fillRect(0,0,z.width,z.height),K.drawImage($,0,0,z.width,z.height);let W=W6,G=z.toDataURL("image/jpeg",W);while(G.length>Y6&&W>0.4)W-=0.15,G=z.toDataURL("image/jpeg",W);return G}catch{return J}}var V6=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,X6=/^\d+$/,F6=/^[0-9a-f]{16,}$/i;function u0(J){if(J.reason.type==="manual")return null;let $=J.cause?.failedRequests?.[0];if(!$?.url)return null;let Q;try{Q=new URL($.url,"http://x").pathname}catch{Q=$.url}let j=Q.split("/").map((K)=>V6.test(K)||X6.test(K)||F6.test(K)?":id":K).join("/"),z=$.status??($.error?"ERR":"?");return`${$.method??"REQ"} ${j} ${z}`}var d0=2000000;function C0(J){let{screenshotDataUrl:$,replay:Q,...j}=J;return JSON.stringify(j).length}function c0(J,$=2000000){if(C0(J)<=$)return J;let Q=J.network.map((z)=>({...z})),j={...J,network:Q};for(let z of Q){if(C0(j)<=$)return j;if(typeof z.responseSnippet==="string"&&z.responseSnippet.length>35)z.responseSnippet="[body dropped — report size budget]";if(typeof z.requestBody==="string"&&z.requestBody.length>35)z.requestBody="[body dropped — report size budget]"}while(j.network.length>1&&C0(j)>$)j.network=j.network.slice(1);while(j.console.length>1&&C0(j)>$)j.console=j.console.slice(1);return j}function Y0(J){let $="";for(let Q=0;Q<J.length;Q+=32768)$+=String.fromCharCode(...J.subarray(Q,Q+32768));return btoa($)}var H6=4,U6=2,P6=3,M6=0,C6=new Set(["href","src","action","formaction","xlink:href","data","poster","srcset"]),I6=/^\s*javascript:/i;function D6(J,$){let Q=J.toLowerCase();if(Q.startsWith("on")||Q==="srcdoc")return!0;return typeof $==="string"&&I6.test($)}function a1(J,$=!1){if(!J)return;for(let Q of Object.keys(J)){let j=J[Q];if(D6(Q,j)){if($)J[Q]=null;else delete J[Q];continue}if(typeof j!=="string"||!C6.has(Q)||!j.includes("?"))continue;J[Q]=E(j)}}function i0(J){if(!J)return;a1(J.attributes);for(let $ of J.childNodes??[])i0($)}function t1(J){let $=JSON.parse(JSON.stringify(J));for(let Q of $){let j=Q.data;if(!j||typeof j!=="object")continue;if(Q.type===H6&&typeof j.href==="string")j.href=E(j.href);else if(Q.type===U6)i0(j.node);else if(Q.type===P6&&j.source===M6){for(let z of j.adds??[])i0(z.node);for(let z of j.attributes??[])a1(z.attributes,!0)}}return $}var J2="session-replay.json.gz",q6="session-replay.json";function B6(J){return Boolean(J&&J.events.length>0)}async function N6(J){if(typeof CompressionStream>"u")return null;try{let $=new Blob([J]).stream().pipeThrough(new CompressionStream("gzip"));return new Uint8Array(await new Response($).arrayBuffer())}catch{return null}}async function l0(J,$){if(!B6(J))return{summary:{omitted:"empty"}};let j={seconds:Math.round(J.durationMs/1000),events:J.events.length,startedAt:J.startedAt,endedAt:J.endedAt},z=t1(J.events),K=await e1(z),W=!1;if(K.bytes.byteLength>$&&O6(z))z=R6(z),K=await e1(z),W=!0;let{bytes:G,compressed:F}=K;if(G.byteLength>$)return{summary:{...j,bytes:G.byteLength,omitted:"too-large"}};return{dataUri:`data:${F?"application/gzip":"application/json"};base64,${Y0(G)}`,filename:F?J2:q6,summary:{...j,events:z.length,bytes:G.byteLength,compressed:F,...W?{canvasDropped:W}:{}}}}async function e1(J){let $=new TextEncoder().encode(JSON.stringify({events:J})),Q=await N6($);return Q?{bytes:Q,compressed:!0}:{bytes:$,compressed:!1}}var w6=3,$2=2,S6=9;function Q2(J){return J.type===w6&&J.data?.source===S6}function O6(J){return J.some(Q2)||J.some(($)=>$.type===$2&&j2($.data.node))}function j2(J){if(!J)return!1;if(J.attributes&&"rr_dataURL"in J.attributes)return!0;return(J.childNodes??[]).some(j2)}function z2(J){if(!J)return;if(J.attributes&&"rr_dataURL"in J.attributes)delete J.attributes.rr_dataURL;for(let $ of J.childNodes??[])z2($)}function R6(J){let $=[];for(let Q of J){if(Q2(Q))continue;if(Q.type===$2)z2(Q.data.node);$.push(Q)}return $}var _6=new Set([502,503,504]);class c extends Error{kind;retryAfter;status;constructor(J,$,Q,j){super(J);this.kind=$;this.retryAfter=Q;this.status=j;this.name="ReportError"}}function L6(J){let{screenshotDataUrl:$,replay:Q,...j}=J;return{dataUri:`data:application/json;base64,${Y0(new TextEncoder().encode(JSON.stringify(j)))}`,filename:"debug-bundle.json"}}async function k6(){let J=w().identity;if(!J)return{};try{let $=await J();return $?{authorization:`Bearer ${$}`}:{}}catch{return{}}}async function o0(J,$){let Q=w(),j=c0($,d0),{context:z,note:K}=j,W=[];if(j.screenshotDataUrl){let C=await n1(j.screenshotDataUrl);W.push({dataUri:C,filename:"screenshot.jpg"})}W.push(L6(j));let G,F=Z0();if(F){let C=await l0(j.replay,F.maxBytes);if(G=C.summary,"dataUri"in C)W.push({dataUri:C.dataUri,filename:C.filename})}let P=u0(j),B={title:J,description:K.trim()||void 0,appName:m().name,category:z.module?.label,routeUrl:z.route.href,priority:"MEDIUM",requesterEmail:z.user.email??void 0,requesterName:z.user.fullName??void 0,customFields:{unit:z.user.unit??"",appVersion:z.app.version,environment:z.app.environment,reasonType:j.reason.type,appName:m().name,module:z.module?.label??""},context:{...P?{signature:P}:{},capturedAt:z.capturedAt,reason:j.reason,cause:j.cause,actionTrail:j.actionTrail,client:z.client,performance:z.performance,apiHeaders:z.apiHeaders,extra:z.extra,counts:{network:j.network.length,console:j.console.length,actions:j.actionTrail.length},screenshotMethod:j.screenshotMethod,...G?{replay:G}:{}},attachments:W},M=await fetch(`${Q.host.replace(/\/$/,"")}/ingest/tickets`,{method:"POST",headers:{"content-type":"application/json","x-realm-key":Q.realmKey,...await k6()},body:JSON.stringify(B)}).catch(()=>{throw new c("report never left the browser","offline")});if(!M.ok){let C=M.headers.get("retry-after"),S=await M.json().then((D)=>D.error).catch(()=>null);if(M.status===429)throw new c("rate limited","rateLimited",C??void 0);if(_6.has(M.status))throw new c("desk unavailable","unavailable");throw new c(S??`Report failed (${M.status})`,"rejected",void 0,M.status)}return await M.json()}var G0=Math.PI/6;function Z2(J,$,Q){let j=$.x-J.x,z=$.y-J.y,K=Math.hypot(j,z),W=Math.atan2(z,j),G=[{x:$.x,y:$.y},{x:$.x-Q*Math.cos(W-G0),y:$.y-Q*Math.sin(W-G0)},{x:$.x-Q*Math.cos(W+G0),y:$.y-Q*Math.sin(W+G0)}],F=Q*Math.cos(G0)*0.92;if(K<=F)return{shaft:null,head:G};return{shaft:{from:J,to:{x:$.x-F*Math.cos(W),y:$.y-F*Math.sin(W)}},head:G}}var r0="#f44336",T6="rgba(250, 204, 21, 0.4)",s0=22,K2="#2563eb",W2=9,Y2=11,G2=18,V2=4,I0=8,A6=[{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 n0(J,$,Q){let j=[],z=null,K=-1,W=null,G=null,F=J.getContext("2d");function P(){let Z=J.getBoundingClientRect().width;return Z>0?J.width/Z:1}function B(Z){let Y=J.getBoundingClientRect();return{x:(Z.clientX-Y.left)/Y.width*J.width,y:(Z.clientY-Y.top)/Y.height*J.height}}function M(Z){let Y=Z.size??s0;if(!F)return(Z.text?.length??0)*Y*0.6;F.save(),F.font=`600 ${Y}px system-ui, sans-serif`;let X=F.measureText(Z.text??"").width;return F.restore(),X}function C(Z){if(Z.tool==="text"){let Y=Z.size??s0;return{left:Z.x1,top:Z.y1,right:Z.x1+M(Z),bottom:Z.y1+Y*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 Y=C(Z);if(Z.tool==="text")return[{id:"size",x:Y.right,y:Y.bottom,cursor:"nwse-resize"}];return A6.map((X)=>({id:X.id,x:Y.left+(Y.right-Y.left)*X.fx,y:Y.top+(Y.bottom-Y.top)*X.fy,cursor:X.cursor}))}function D(Z){let Y=C(Z);return{x:Y.right+G2*P(),y:Y.top-G2*P()}}function R(Z,Y,X){let{shaft:V,head:H}=Z2({x:Y.x1,y:Y.y1},{x:Y.x2,y:Y.y2},Math.max(10,16*X));if(V)Z.lineCap="butt",Z.beginPath(),Z.moveTo(V.from.x,V.from.y),Z.lineTo(V.to.x,V.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,Y,X){Z.save(),Z.lineWidth=Math.max(2,3*X),Z.strokeStyle=r0,Z.fillStyle=r0;let V=C(Y);if(Y.tool==="rect")Z.strokeRect(V.left,V.top,V.right-V.left,V.bottom-V.top);else if(Y.tool==="arrow")R(Z,Y,X);else if(Y.tool==="highlight")Z.fillStyle=T6,Z.fillRect(V.left,V.top,V.right-V.left,V.bottom-V.top);else if(Y.tool==="text"&&Y.text){let H=Y.size??s0;Z.font=`600 ${H}px system-ui, sans-serif`,Z.textBaseline="top";let U=H*0.22;Z.fillStyle="rgba(255,255,255,0.92)",Z.fillRect(V.left-U,V.top-U,V.right-V.left+U*2,V.bottom-V.top+U*2),Z.fillStyle=r0,Z.fillText(Y.text,V.left,V.top)}Z.restore()}function q(Z,Y,X){let V=C(Y);Z.save(),Z.strokeStyle=K2,Z.lineWidth=Math.max(1,1.5*X),Z.setLineDash([6*X,4*X]),Z.strokeRect(V.left,V.top,V.right-V.left,V.bottom-V.top),Z.setLineDash([]);let H=W2*X;for(let x of S(Y))Z.fillStyle="#fff",Z.strokeStyle=K2,Z.lineWidth=Math.max(1,1.5*X),Z.beginPath(),Z.rect(x.x-H/2,x.y-H/2,H,H),Z.fill(),Z.stroke();let U=D(Y),I=Y2*X;Z.beginPath(),Z.arc(U.x,U.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(U.x-I*0.4,U.y-I*0.4),Z.lineTo(U.x+I*0.4,U.y+I*0.4),Z.moveTo(U.x+I*0.4,U.y-I*0.4),Z.lineTo(U.x-I*0.4,U.y+I*0.4),Z.stroke(),Z.restore()}function O(){if(!F)return;let Z=P();if(F.clearRect(0,0,J.width,J.height),F.drawImage($,0,0,J.width,J.height),j.forEach((X,V)=>{if(V!==v)_(F,X,Z)}),W)_(F,W,Z);let Y=j[K];if(Y&&!W)q(F,Y,Z)}function y(Z,Y,X,V,H){return Math.abs(Z-X)<=H&&Math.abs(Y-V)<=H}function Q0(Z,Y){let X=j[K];if(!X)return null;let V=W2*P()/2+3*P();for(let H of S(X))if(y(Z,Y,H.x,H.y,V))return H.id;return null}function i(Z,Y){let X=j[K];if(!X)return!1;let V=D(X);return y(Z,Y,V.x,V.y,Y2*P())}function h(Z,Y){let X=6*P();for(let V=j.length-1;V>=0;V-=1){let H=j[V];if(H.tool==="arrow"){let I=H.x2-H.x1,x=H.y2-H.y1,p=Math.hypot(I,x)||1,u=Math.max(0,Math.min(1,((Z-H.x1)*I+(Y-H.y1)*x)/(p*p)));if(Math.hypot(Z-(H.x1+u*I),Y-(H.y1+u*x))<=X+4*P())return V;continue}let U=C(H);if(Z>=U.left-X&&Z<=U.right+X&&Y>=U.top-X&&Y<=U.bottom+X)return V}return-1}function b(Z,Y,X,V,H){if(Y==="tail"){Z.x1=X.x1+V,Z.y1=X.y1+H;return}if(Y==="head"){Z.x2=X.x2+V,Z.y2=X.y2+H;return}if(Y==="size"){let B2=(X.size??24)+H;Z.size=Math.max(10,B2);return}let U=C(X),{left:I,top:x,right:p,bottom:u}=U;if(Y.includes("w"))I=Math.min(p-I0,I+V);if(Y.includes("e"))p=Math.max(I+I0,p+V);if(Y.includes("n"))x=Math.min(u-I0,x+H);if(Y.includes("s"))u=Math.max(x+I0,u+H);Z.x1=I,Z.y1=x,Z.x2=p,Z.y2=u}function B0(Z,Y,X,V){Z.x1=Y.x1+X,Z.y1=Y.y1+V,Z.x2=Y.x2+X,Z.y2=Y.y2+V}let L=null,v=-1,N={x:0,y:0,size:24};function f(){let Z=J.getBoundingClientRect().width;return Z>0?Z/J.width:1}function q2(Z,Y){if(!F)return Z.length*Y*0.6;F.save(),F.font=`600 ${Y}px system-ui, sans-serif`;let X=F.measureText(Z||" ").width;return F.restore(),X}function J1(){if(!L)return;let Z=J.parentElement;if(!Z)return;let Y=J.getBoundingClientRect(),X=Z.getBoundingClientRect(),V=f(),H=N.size*V;L.style.left=`${Y.left-X.left+N.x*V}px`,L.style.top=`${Y.top-X.top+N.y*V}px`,L.style.fontSize=`${H}px`,L.style.width=`${Math.max(40,q2(L.value,H)+H)}px`}function j0(Z){let Y=L;if(!Y)return;L=null;let X=Y.value.trim(),V=v;if(v=-1,Y.remove(),Z&&X){if(V>=0&&j[V])j[V].text=X,K=V;else j.push({tool:"text",x1:N.x,y1:N.y,x2:N.x,y2:N.y,text:X,size:N.size}),K=j.length-1;Q()}else if(V>=0)K=V;J.focus(),O()}function $1(Z,Y,X=-1){j0(!0);let V=J.parentElement;if(!V)return;if(getComputedStyle(V).position==="static")V.style.position="relative";let H=X>=0?j[X]:void 0;v=X,N={x:H?.x1??Z,y:H?.y1??Y,size:H?.size??Math.round(24*P())};let U=document.createElement("input");U.type="text",U.className="text-edit",U.value=H?.text??"",U.setAttribute("aria-label","ข้อความบนภาพ"),U.placeholder="ข้อความ",L=U,V.append(U),J1(),U.addEventListener("input",J1),U.addEventListener("keydown",(I)=>{if(I.stopPropagation(),I.key==="Enter")j0(!0);else if(I.key==="Escape")j0(!1)}),requestAnimationFrame(()=>{if(L!==U)return;U.focus(),U.select(),U.addEventListener("blur",()=>j0(!0))}),O()}function Q1(Z){let{x:Y,y:X}=B(Z);if(J.setPointerCapture(Z.pointerId),i(Y,X)){N0();return}let V=Q0(Y,X);if(V&&j[K]){G={grip:V,x:Y,y:X,start:{...j[K]}};return}if(z==="text"){if(Z.preventDefault(),J.hasPointerCapture(Z.pointerId))J.releasePointerCapture(Z.pointerId);z=null,Q(),$1(Y,X);return}if(z){W={tool:z,x1:Y,y1:X,x2:Y,y2:X},K=-1;return}let H=h(Y,X);K=H,G=H>=0?{grip:"body",x:Y,y:X,start:{...j[H]}}:null,O()}function j1(Z){let{x:Y,y:X}=B(Z);if(W){W.x2=Y,W.y2=X,O();return}if(G){let H=j[K];if(!H)return;let U=Y-G.x,I=X-G.y;if(G.grip==="body")B0(H,G.start,U,I);else b(H,G.grip,G.start,U,I);O();return}if(z){J.style.cursor="crosshair";return}if(i(Y,X)){J.style.cursor="pointer";return}let V=Q0(Y,X);if(V){let H=j[K]?S(j[K]).find((U)=>U.id===V):null;J.style.cursor=H?.cursor??"pointer";return}J.style.cursor=h(Y,X)>=0?"move":"default"}function V0(){if(W){if(!(Math.abs(W.x2-W.x1)<V2&&Math.abs(W.y2-W.y1)<V2))j.push(W),K=j.length-1,z=null,Q();W=null}if(G)G=null,Q();O()}function z1(Z){let Y=J.getBoundingClientRect(),X=(Z.clientX-Y.left)/Y.width*J.width,V=(Z.clientY-Y.top)/Y.height*J.height,H=h(X,V),U=j[H];if(!U||U.tool!=="text")return;Z.preventDefault(),$1(U.x1,U.y1,H)}function Z1(Z){if(K<0)return;if(Z.key==="Delete"||Z.key==="Backspace")Z.preventDefault(),N0();else if(Z.key==="Escape")K=-1,O()}function N0(){if(K<0)return;j.splice(K,1),K=-1,Q(),O()}return J.addEventListener("pointerdown",Q1),J.addEventListener("pointermove",j1),J.addEventListener("pointerup",V0),J.addEventListener("pointercancel",V0),J.addEventListener("dblclick",z1),J.tabIndex=0,J.addEventListener("keydown",Z1),O(),{setTool(Z){z=Z,K=-1,J.style.cursor=Z?"crosshair":"default",O()},deleteSelected:N0,clear(){j.length=0,K=-1,Q(),O()},hasShapes:()=>j.length>0,hasSelection:()=>K>=0,toDataUrl(){let Z=document.createElement("canvas");Z.width=$.naturalWidth,Z.height=$.naturalHeight;let Y=Z.getContext("2d");if(!Y)return J.toDataURL("image/png");Y.drawImage($,0,0);let X=P();for(let V of j)_(Y,V,X);return Z.toDataURL("image/png")},destroy(){j0(!1),J.removeEventListener("pointerdown",Q1),J.removeEventListener("pointermove",j1),J.removeEventListener("pointerup",V0),J.removeEventListener("pointercancel",V0),J.removeEventListener("dblclick",z1),J.removeEventListener("keydown",Z1)}}}var x6=["keydown","keyup","keypress"];function D0(J){for(let $ of x6)J.addEventListener($,(Q)=>Q.stopPropagation())}var X2=`
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 $0="lw-debug-reporter";function A6(J,$){if(J instanceof c){if(J.kind==="offline")return $.failedOffline;if(J.kind==="unavailable")return $.failedUnavailable;if(J.kind==="rateLimited")return $.failedTooMany.replace("{seconds}",J.retryAfter??"60");return J.message||$.failed}return $.failed}var X2=()=>[];function x6(J){X2=J}var f6=[{tool:"rect",key:"toolRect"},{tool:"arrow",key:"toolArrow"},{tool:"highlight",key:"toolHighlight"},{tool:"text",key:"toolText"}];function E6(){return class extends HTMLElement{root;stop=null;annotator=null;bundle=null;busy=!1;constructor(){super();this.root=this.attachShadow({mode:"open"})}connectedCallback(){this.dataset.debugReporter="true",this.stop=A0(($)=>void this.open($))}disconnectedCallback(){this.stop?.(),this.stop=null,this.close()}async open($){if(this.busy)return;this.busy=!0;let Q=d(S().locale),j=await v0();if(j.method==="cancelled"){this.close();return}this.bundle=b0({reason:$,note:"",screenshotDataUrl:j.dataUrl,screenshotMethod:j.method,erroredQueries:h6()}),this.renderForm(Q)}close(){this.annotator?.destroy(),this.annotator=null,this.bundle=null,this.busy=!1,this.root.replaceChildren()}shell($){let Q=document.createElement("style");Q.textContent=V2;let j=document.createElement("div");j.className="backdrop";let z=document.createElement("div");return z.className="panel",z.setAttribute("role","dialog"),z.setAttribute("aria-modal","true"),z.setAttribute("aria-label",$.title),j.append(z),this.root.replaceChildren(Q,j),z}renderShell($,Q){let j=this.shell($),z=k("div","head");z.append(k("h2","",$.title)),j.append(z,k("p","status",Q))}renderForm($){let Q=this.bundle;if(!Q)return;let j=this.shell($),z=k("div","head"),K=J0("✕","icon");K.setAttribute("aria-label",$.close),K.addEventListener("click",()=>this.close()),z.append(k("h2","",$.title),K);let W=document.createElement("input");W.type="text",W.placeholder=$.summaryPlaceholder;let G=n0($.summaryLabel,$.summaryRequired,!0),F=document.createElement("textarea");F.placeholder=$.detailPlaceholder;let P=k("div","meta");P.innerHTML="";let{context:B}=Q;for(let[R,_]of[[$.reporter,`${B.user.fullName??"—"} (${B.user.email??"—"})`],[$.page,B.route.href],[$.captured,`${Q.network.length} network · ${Q.console.length} console · ${Q.actionTrail.length} actions${Q.replay?` · ${$.replay} ${Math.round(Q.replay.durationMs/1000)}s`:""}`]]){let q=document.createElement("div"),O=document.createElement("b");O.textContent=`${R}: `,q.append(O,document.createTextNode(_)),P.append(q)}let M=k("p","status",""),C=J0($.submit,"primary");if(C.disabled=!0,W.addEventListener("input",()=>{C.disabled=W.value.trim().length===0}),j.append(z,G,W,n0($.detailLabel),F,P),Q.screenshotDataUrl)j.append(...this.screenshotSection($,Q.screenshotDataUrl));else j.append(k("p","status",$.noScreenshot));let w=k("div","foot"),D=J0($.close);D.addEventListener("click",()=>this.close()),w.append(D,M,k("span","grow"),C),j.append(w),C.addEventListener("click",async()=>{C.disabled=!0,M.dataset.tone="",M.textContent=$.submitting;try{let R=await l0(W.value.trim(),{...Q,note:F.value,screenshotDataUrl:this.annotator?.hasShapes()?this.annotator.toDataUrl():Q.screenshotDataUrl}),_=this.dispatchEvent(new CustomEvent("lw-report-submitted",{detail:R,bubbles:!0,composed:!0,cancelable:!0}));if(this.close(),_)e(`${$.submitted} — #${R.number}`,"success")}catch(R){let _=A6(R,$);M.dataset.tone="error",M.textContent=_,e(_,"error"),C.disabled=!1}}),W.focus()}screenshotSection($,Q){let j=n0($.annotateHint),z=k("div","tools"),K=document.createElement("canvas"),W=k("div","shot");W.append(K);let G=[],F=(C)=>{for(let w of G)w.setAttribute("aria-pressed",String(w===C))};for(let{tool:C,key:w}of f6){let D=J0($[w]);D.setAttribute("aria-pressed","false"),D.addEventListener("click",()=>{let R=D.getAttribute("aria-pressed")==="true";F(R?null:D),this.annotator?.setTool(R?null:C)}),G.push(D),z.append(D)}z.append(k("span","sep"));let P=J0($.deleteSelected);P.addEventListener("click",()=>this.annotator?.deleteSelected());let B=J0($.clearAll);B.addEventListener("click",()=>{this.annotator?.clear(),F(null)}),z.append(P,B);let M=new Image;return M.onload=()=>{K.width=M.naturalWidth,K.height=M.naturalHeight,this.annotator=s0(K,M,()=>{F(null),P.disabled=!this.annotator?.hasSelection()})},M.src=Q,[j,z,k("p","status",$.annotateHelp),W]}}}function h6(){try{return X2()}catch{return[]}}function k(J,$="",Q=""){let j=document.createElement(J);if($)j.className=$;if(Q)j.textContent=Q;return j}function J0(J,$=""){let Q=document.createElement("button");if(Q.type="button",Q.textContent=J,$)Q.className=$;return Q}function n0(J,$="",Q=!1){let j=document.createElement("label");if(j.append(document.createTextNode(J)),Q){let z=document.createElement("span");z.className="req",z.textContent=" *",j.append(z)}if($){let z=document.createElement("span");z.className="hint",z.textContent=` ${$}`,j.append(z)}return j}function a0(){if(typeof window>"u"||customElements.get($0))return;customElements.define($0,E6())}var F2=!1;function m6(J={}){if(F2||typeof window>"u")return;if(!z0()){console.error("[debug-capture] configureDebugCapture() must be called before install");return}if(F2=!0,p1(),w1(),D1(),x1(),d1(),J.ui===!1)return;let $=d(S().locale);if(f0((Q)=>{e(Q.message??$.crashed,"error",{label:$.crashAction,onClick:()=>x0(Q)})}),a0(),!document.querySelector($0))document.body.append(document.createElement($0))}var g6=new Set(["error","exception","unhandledrejection"]);function H2(J){if(J.error)return!0;return J.status!==null&&J.status>=400}function t0(J){if(!J)return null;let $=Date.parse(J);return Number.isNaN($)?null:$}function y6(J){try{let{pathname:$}=new URL(J,"http://x");try{return decodeURIComponent($)}catch{return $}}catch{return J.split(/[?#]/)[0]??J}}function b6(J,$,Q){let j=(W)=>({elapsedMs:W,requests:[],failedRequests:[],consoleErrors:[],slowestMs:null});if(J.length===0)return[];let z=J.map((W)=>t0(W.at)),K=(W)=>{for(let G=W+1;G<z.length;G+=1){let F=z[G];if(F!=null)return F}return Number.POSITIVE_INFINITY};return J.map((W,G)=>{let F=z[G]??null,P=(G>0?z[G-1]:null)??null,B=F!==null&&P!==null?Math.max(0,F-P):null;if(F===null)return j(B);let M=F,C=Math.max(M,K(G)),w=(q)=>q!==null&&q>=M&&(q<C||C===Number.POSITIVE_INFINITY),D=$.filter((q)=>w(t0(q.startedAt))),R=Q.filter((q)=>g6.has(q.level)&&w(t0(q.at))),_=D.map((q)=>q.durationMs).filter((q)=>typeof q==="number");return{elapsedMs:B,requests:D,failedRequests:D.filter(H2),consoleErrors:R,slowestMs:_.length>0?Math.max(..._):null}})}function v6(J,$){return J.requests.length===0&&J.consoleErrors.length===0&&(J.elapsedMs===null||J.elapsedMs<$)}function p6(J){if(J<1000)return`${Math.round(J)} มิลลิวินาที`;let $=J/1000;if($<10)return`${$.toFixed(1)} วิ`;if($<60)return`${Math.round($)} วิ`;let Q=Math.floor($/60),j=Math.round($%60);return j===0?`${Q} นาที`:`${Q} นาที ${j} วิ`}var u6="lw-portal-handoff",U2=138.23,d6=`
124
+ `;var $0="lw-debug-reporter";function f6(J,$){if(J instanceof c){if(J.kind==="offline")return $.failedOffline;if(J.kind==="unavailable")return $.failedUnavailable;if(J.kind==="rateLimited")return $.failedTooMany.replace("{seconds}",J.retryAfter??"60");return J.message||$.failed}return $.failed}var F2=()=>[];function E6(J){F2=J}var h6=[{tool:"rect",key:"toolRect"},{tool:"arrow",key:"toolArrow"},{tool:"highlight",key:"toolHighlight"},{tool:"text",key:"toolText"}];function m6(){return class extends HTMLElement{root;stop=null;annotator=null;bundle=null;busy=!1;constructor(){super();this.root=this.attachShadow({mode:"open"}),D0(this.root)}connectedCallback(){this.dataset.debugReporter="true",this.stop=x0(($)=>void this.open($))}disconnectedCallback(){this.stop?.(),this.stop=null,this.close()}async open($){if(this.busy)return;this.busy=!0;let Q=d(w().locale),j=await p0();if(j.method==="cancelled"){this.close();return}this.bundle=v0({reason:$,note:"",screenshotDataUrl:j.dataUrl,screenshotMethod:j.method,erroredQueries:g6()}),this.renderForm(Q)}close(){this.annotator?.destroy(),this.annotator=null,this.bundle=null,this.busy=!1,this.root.replaceChildren()}shell($){let Q=document.createElement("style");Q.textContent=X2;let j=document.createElement("div");j.className="backdrop";let z=document.createElement("div");return z.className="panel",z.setAttribute("role","dialog"),z.setAttribute("aria-modal","true"),z.setAttribute("aria-label",$.title),j.append(z),this.root.replaceChildren(Q,j),z}renderShell($,Q){let j=this.shell($),z=k("div","head");z.append(k("h2","",$.title)),j.append(z,k("p","status",Q))}renderForm($){let Q=this.bundle;if(!Q)return;let j=this.shell($),z=k("div","head"),K=J0("✕","icon");K.setAttribute("aria-label",$.close),K.addEventListener("click",()=>this.close()),z.append(k("h2","",$.title),K);let W=document.createElement("input");W.type="text",W.placeholder=$.summaryPlaceholder;let G=a0($.summaryLabel,$.summaryRequired,!0),F=document.createElement("textarea");F.placeholder=$.detailPlaceholder;let P=k("div","meta");P.innerHTML="";let{context:B}=Q;for(let[R,_]of[[$.reporter,`${B.user.fullName??"—"} (${B.user.email??"—"})`],[$.page,B.route.href],[$.captured,`${Q.network.length} network · ${Q.console.length} console · ${Q.actionTrail.length} actions${Q.replay?` · ${$.replay} ${Math.round(Q.replay.durationMs/1000)}s`:""}`]]){let q=document.createElement("div"),O=document.createElement("b");O.textContent=`${R}: `,q.append(O,document.createTextNode(_)),P.append(q)}let M=k("p","status",""),C=J0($.submit,"primary");if(C.disabled=!0,W.addEventListener("input",()=>{C.disabled=W.value.trim().length===0}),j.append(z,G,W,a0($.detailLabel),F,P),Q.screenshotDataUrl)j.append(...this.screenshotSection($,Q.screenshotDataUrl));else j.append(k("p","status",$.noScreenshot));let S=k("div","foot"),D=J0($.close);D.addEventListener("click",()=>this.close()),S.append(D,M,k("span","grow"),C),j.append(S),C.addEventListener("click",async()=>{C.disabled=!0,M.dataset.tone="",M.textContent=$.submitting;try{let R=await o0(W.value.trim(),{...Q,note:F.value,screenshotDataUrl:this.annotator?.hasShapes()?this.annotator.toDataUrl():Q.screenshotDataUrl}),_=this.dispatchEvent(new CustomEvent("lw-report-submitted",{detail:R,bubbles:!0,composed:!0,cancelable:!0}));if(this.close(),_)e(`${$.submitted} — #${R.number}`,"success")}catch(R){let _=f6(R,$);M.dataset.tone="error",M.textContent=_,e(_,"error"),C.disabled=!1}}),W.focus()}screenshotSection($,Q){let j=a0($.annotateHint),z=k("div","tools"),K=document.createElement("canvas"),W=k("div","shot");W.append(K);let G=[],F=(C)=>{for(let S of G)S.setAttribute("aria-pressed",String(S===C))};for(let{tool:C,key:S}of h6){let D=J0($[S]);D.setAttribute("aria-pressed","false"),D.addEventListener("click",()=>{let R=D.getAttribute("aria-pressed")==="true";F(R?null:D),this.annotator?.setTool(R?null:C)}),G.push(D),z.append(D)}z.append(k("span","sep"));let P=J0($.deleteSelected);P.addEventListener("click",()=>this.annotator?.deleteSelected());let B=J0($.clearAll);B.addEventListener("click",()=>{this.annotator?.clear(),F(null)}),z.append(P,B);let M=new Image;return M.onload=()=>{K.width=M.naturalWidth,K.height=M.naturalHeight,this.annotator=n0(K,M,()=>{F(null),P.disabled=!this.annotator?.hasSelection()})},M.src=Q,[j,z,k("p","status",$.annotateHelp),W]}}}function g6(){try{return F2()}catch{return[]}}function k(J,$="",Q=""){let j=document.createElement(J);if($)j.className=$;if(Q)j.textContent=Q;return j}function J0(J,$=""){let Q=document.createElement("button");if(Q.type="button",Q.textContent=J,$)Q.className=$;return Q}function a0(J,$="",Q=!1){let j=document.createElement("label");if(j.append(document.createTextNode(J)),Q){let z=document.createElement("span");z.className="req",z.textContent=" *",j.append(z)}if($){let z=document.createElement("span");z.className="hint",z.textContent=` ${$}`,j.append(z)}return j}function t0(){if(typeof window>"u"||customElements.get($0))return;customElements.define($0,m6())}var H2=!1;function y6(J={}){if(H2||typeof window>"u")return;if(!z0()){console.error("[debug-capture] configureDebugCapture() must be called before install");return}if(H2=!0,u1(),O1(),q1(),f1(),c1(),J.ui===!1)return;let $=d(w().locale);if(E0((Q)=>{e(Q.message??$.crashed,"error",{label:$.crashAction,onClick:()=>f0(Q)})}),t0(),!document.querySelector($0))document.body.append(document.createElement($0))}var b6=new Set(["error","exception","unhandledrejection"]);function U2(J){if(J.error)return!0;return J.status!==null&&J.status>=400}function e0(J){if(!J)return null;let $=Date.parse(J);return Number.isNaN($)?null:$}function v6(J){try{let{pathname:$}=new URL(J,"http://x");try{return decodeURIComponent($)}catch{return $}}catch{return J.split(/[?#]/)[0]??J}}function p6(J,$,Q){let j=(W)=>({elapsedMs:W,requests:[],failedRequests:[],consoleErrors:[],slowestMs:null});if(J.length===0)return[];let z=J.map((W)=>e0(W.at)),K=(W)=>{for(let G=W+1;G<z.length;G+=1){let F=z[G];if(F!=null)return F}return Number.POSITIVE_INFINITY};return J.map((W,G)=>{let F=z[G]??null,P=(G>0?z[G-1]:null)??null,B=F!==null&&P!==null?Math.max(0,F-P):null;if(F===null)return j(B);let M=F,C=Math.max(M,K(G)),S=(q)=>q!==null&&q>=M&&(q<C||C===Number.POSITIVE_INFINITY),D=$.filter((q)=>S(e0(q.startedAt))),R=Q.filter((q)=>b6.has(q.level)&&S(e0(q.at))),_=D.map((q)=>q.durationMs).filter((q)=>typeof q==="number");return{elapsedMs:B,requests:D,failedRequests:D.filter(U2),consoleErrors:R,slowestMs:_.length>0?Math.max(..._):null}})}function u6(J,$){return J.requests.length===0&&J.consoleErrors.length===0&&(J.elapsedMs===null||J.elapsedMs<$)}function d6(J){if(J<1000)return`${Math.round(J)} มิลลิวินาที`;let $=J/1000;if($<10)return`${$.toFixed(1)} วิ`;if($<60)return`${Math.round($)} วิ`;let Q=Math.floor($/60),j=Math.round($%60);return j===0?`${Q} นาที`:`${Q} นาที ${j} วิ`}var c6="lw-portal-handoff",P2=138.23,i6=`
125
125
  :host { all: initial; }
126
126
  .backdrop {
127
127
  position: fixed; inset: 0; z-index: 2147483002;
@@ -151,10 +151,10 @@ canvas { width: 100%; height: auto; display: block; border: 1px solid #e2e8f0; b
151
151
  .ring .track { stroke: #e2e8f0; }
152
152
  .ring .bar {
153
153
  stroke: #0ea5e9; transform: rotate(-90deg); transform-origin: 50% 50%;
154
- stroke-dasharray: ${U2}; stroke-dashoffset: 0;
154
+ stroke-dasharray: ${P2}; stroke-dashoffset: 0;
155
155
  animation: deplete var(--secs, 3s) linear forwards;
156
156
  }
157
- @keyframes deplete { to { stroke-dashoffset: ${U2}; } }
157
+ @keyframes deplete { to { stroke-dashoffset: ${P2}; } }
158
158
  .count {
159
159
  position: absolute; inset: 0; display: grid; place-items: center;
160
160
  font-size: 18px; font-weight: 600; color: #0f172a;
@@ -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 P2(J){if(typeof document>"u")return J.prepare().then((q)=>void J.go(q),()=>{return});let $=d(S().locale),Q=Math.max(1,Math.floor(J.seconds??3)),j=document.createElement(u6),z=j.attachShadow({mode:"open"}),K=document.createElement("style");K.textContent=d6,z.append(K);let W=document.createElement("div");W.className="backdrop",W.innerHTML=`
201
+ `;function M2(J){if(typeof document>"u")return J.prepare().then((q)=>void J.go(q),()=>{return});let $=d(w().locale),Q=Math.max(1,Math.floor(J.seconds??3)),j=document.createElement(c6),z=j.attachShadow({mode:"open"});D0(z);let K=document.createElement("style");K.textContent=i6,z.append(K);let W=document.createElement("div");W.className="backdrop",W.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(W);let G=(q)=>W.querySelector(q),F=G(".card"),P=G(".bar"),B=G(".count"),M=G("h2"),C=G(".body"),w=G(".host"),D=G(".go"),R=G(".cancel");M.textContent=$.handoffTitle,C.textContent=$.handoffBody;try{w.textContent=new URL(S().host).host}catch{w.textContent=""}D.textContent=$.handoffGo,R.textContent=$.cancel,F.style.setProperty("--secs",`${Q}s`),B.textContent=String(Q),document.body.append(j),requestAnimationFrame(()=>W.setAttribute("data-open","1"));let _=document.activeElement;return D.focus({preventScroll:!0}),new Promise((q)=>{let O=!1,y=null,Q0=!1,i=Date.now()+Q*1000,h=window.setInterval(()=>{let N=Math.ceil((i-Date.now())/1000);if(B.textContent=String(Math.max(0,N)),Date.now()>=i)L()},100);function b(N){if(O)return;if(O=!0,window.clearInterval(h),document.removeEventListener("keydown",v,!0),W.removeAttribute("data-open"),window.setTimeout(()=>j.remove(),200),!N)_?.focus?.({preventScroll:!0});q()}function q0(N){window.clearInterval(h),P.classList.remove("spinner"),P.style.animation="none",B.textContent="",M.textContent=$.handoffBlocked,C.textContent=$.handoffBody;let f=document.createElement("a");f.className="go",f.href=N,f.target="_blank",f.rel="noopener noreferrer",f.textContent=$.handoffOpen,f.addEventListener("click",()=>b(!0)),D.replaceWith(f),f.focus({preventScroll:!0})}function L(){if(O||Q0)return;if(y)return J.go(y)?b(!0):q0(y);window.clearInterval(h),B.textContent="",P.classList.add("spinner"),M.textContent=$.handoffPreparing}function v(N){if(N.key==="Escape")N.stopPropagation(),b(!1)}document.addEventListener("keydown",v,!0),D.addEventListener("click",L),R.addEventListener("click",()=>b(!1)),W.addEventListener("click",(N)=>{if(N.target===W)b(!1)}),J.prepare().then((N)=>{if(y=N,!O&&Date.now()>=i)L()},()=>{Q0=!0,window.clearInterval(h),F.classList.add("error"),P.classList.remove("spinner"),P.style.animation="none",B.textContent="",M.textContent=$.handoffFailed,C.textContent=$.handoffBody,D.remove(),R.textContent=$.close})})}var c6="/sso";function I2(J,$,Q,j){let z=new URL(c6,J.endsWith("/")?J:`${J}/`);if(z.searchParams.set("realm",$),z.searchParams.set("token",Q),j)z.searchParams.set("return",j);return z.toString()}class D0 extends Error{constructor(J="No identity provider is configured, or nobody is signed in"){super(J);this.name="NoIdentityError"}}async function M2(J){let $=S();if(!$.identity)throw new D0;let Q=await $.identity();if(!Q)throw new D0;return I2($.host,$.realmKey,Q,J)}function C2(J,$){if($==="_self")return window.location.assign(J),!0;let Q=window.open(J,"_blank");if(!Q)return!1;try{Q.opener=null}catch{}return!0}async function i6(J={}){if(J.announce===!1){C2(await M2(J.returnTo),J.target);return}await P2({seconds:J.seconds,prepare:()=>M2(J.returnTo),go:($)=>C2($,J.target)})}export{d0 as trimToBudget,r1 as toCurl,m0 as takeReplay,I2 as supportPortalUrl,l0 as submitBundle,h4 as stopReplay,e as showToast,x6 as setErroredQueriesSource,y6 as requestPath,d as reporterStrings,E as redactUrl,o as redactLabel,r as redactHeaders,s as redactBody,i0 as packReplay,i6 as openSupportPortal,A0 as onLaunch,f0 as onCrash,L2 as moduleResolver,x0 as launch,E4 as isReplayRecording,v6 as isQuietStep,H2 as isFailedRequest,z0 as isConfigured,m6 as installDebugCapture,J6 as hasCause,h0 as getNetworkLog,T0 as getConsoleLog,S as getConfig,L0 as getActionTrail,p6 as formatDuration,p0 as errorSignature,E0 as emitCrash,a0 as defineReporterElement,s0 as createAnnotator,b6 as correlateActionTrail,S2 as configureDebugCapture,v0 as captureScreen,a4 as bundleToMarkdown,e4 as bundleFileName,b0 as buildBundle,m as appInfo,R0 as actionCountSuffix,$0 as REPORTER_TAG,e1 as REPLAY_FILENAME,l as REDACTED,D0 as NoIdentityError,u0 as BUNDLE_BUDGET_BYTES};
217
+ </div>`,z.append(W);let G=(q)=>W.querySelector(q),F=G(".card"),P=G(".bar"),B=G(".count"),M=G("h2"),C=G(".body"),S=G(".host"),D=G(".go"),R=G(".cancel");M.textContent=$.handoffTitle,C.textContent=$.handoffBody;try{S.textContent=new URL(w().host).host}catch{S.textContent=""}D.textContent=$.handoffGo,R.textContent=$.cancel,F.style.setProperty("--secs",`${Q}s`),B.textContent=String(Q),document.body.append(j),requestAnimationFrame(()=>W.setAttribute("data-open","1"));let _=document.activeElement;return D.focus({preventScroll:!0}),new Promise((q)=>{let O=!1,y=null,Q0=!1,i=Date.now()+Q*1000,h=window.setInterval(()=>{let N=Math.ceil((i-Date.now())/1000);if(B.textContent=String(Math.max(0,N)),Date.now()>=i)L()},100);function b(N){if(O)return;if(O=!0,window.clearInterval(h),document.removeEventListener("keydown",v,!0),W.removeAttribute("data-open"),window.setTimeout(()=>j.remove(),200),!N)_?.focus?.({preventScroll:!0});q()}function B0(N){window.clearInterval(h),P.classList.remove("spinner"),P.style.animation="none",B.textContent="",M.textContent=$.handoffBlocked,C.textContent=$.handoffBody;let f=document.createElement("a");f.className="go",f.href=N,f.target="_blank",f.rel="noopener noreferrer",f.textContent=$.handoffOpen,f.addEventListener("click",()=>b(!0)),D.replaceWith(f),f.focus({preventScroll:!0})}function L(){if(O||Q0)return;if(y)return J.go(y)?b(!0):B0(y);window.clearInterval(h),B.textContent="",P.classList.add("spinner"),M.textContent=$.handoffPreparing}function v(N){if(N.key==="Escape")N.stopPropagation(),b(!1)}document.addEventListener("keydown",v,!0),D.addEventListener("click",L),R.addEventListener("click",()=>b(!1)),W.addEventListener("click",(N)=>{if(N.target===W)b(!1)}),J.prepare().then((N)=>{if(y=N,!O&&Date.now()>=i)L()},()=>{Q0=!0,window.clearInterval(h),F.classList.add("error"),P.classList.remove("spinner"),P.style.animation="none",B.textContent="",M.textContent=$.handoffFailed,C.textContent=$.handoffBody,D.remove(),R.textContent=$.close})})}var l6="/sso";function D2(J,$,Q,j){let z=new URL(l6,J.endsWith("/")?J:`${J}/`);if(z.searchParams.set("realm",$),z.searchParams.set("token",Q),j)z.searchParams.set("return",j);return z.toString()}class q0 extends Error{constructor(J="No identity provider is configured, or nobody is signed in"){super(J);this.name="NoIdentityError"}}async function C2(J){let $=w();if(!$.identity)throw new q0;let Q=await $.identity();if(!Q)throw new q0;return D2($.host,$.realmKey,Q,J)}function I2(J,$){if($==="_self")return window.location.assign(J),!0;let Q=window.open(J,"_blank");if(!Q)return!1;try{Q.opener=null}catch{}return!0}async function o6(J={}){if(J.announce===!1){I2(await C2(J.returnTo),J.target);return}await M2({seconds:J.seconds,prepare:()=>C2(J.returnTo),go:($)=>I2($,J.target)})}export{c0 as trimToBudget,s1 as toCurl,g0 as takeReplay,D2 as supportPortalUrl,o0 as submitBundle,m4 as stopReplay,e as showToast,E6 as setErroredQueriesSource,v6 as requestPath,d as reporterStrings,E as redactUrl,o as redactLabel,r as redactHeaders,s as redactBody,l0 as packReplay,o6 as openSupportPortal,x0 as onLaunch,E0 as onCrash,k2 as moduleResolver,f0 as launch,h4 as isReplayRecording,u6 as isQuietStep,U2 as isFailedRequest,z0 as isConfigured,y6 as installDebugCapture,$6 as hasCause,m0 as getNetworkLog,A0 as getConsoleLog,w as getConfig,k0 as getActionTrail,d6 as formatDuration,u0 as errorSignature,h0 as emitCrash,t0 as defineReporterElement,n0 as createAnnotator,p6 as correlateActionTrail,S2 as configureDebugCapture,p0 as captureScreen,t4 as bundleToMarkdown,J6 as bundleFileName,v0 as buildBundle,m as appInfo,_0 as actionCountSuffix,$0 as REPORTER_TAG,J2 as REPLAY_FILENAME,l as REDACTED,q0 as NoIdentityError,d0 as BUNDLE_BUDGET_BYTES};
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Keys pressed inside one of our dialogs stay inside it.
3
+ *
4
+ * Our dialogs live in a shadow root on a host page we know nothing about. A
5
+ * key typed into the reporter's title field bubbles out of the shadow root
6
+ * retargeted to the host element — so the page's own listeners see a
7
+ * keypress on some custom element, not on an input, and any "never while
8
+ * typing" guard they wrote lets it through. On the desk that meant an `M`
9
+ * typed into the title toggled a filter behind the dialog and a `2` changed
10
+ * the page under it. Every host with single-key shortcuts has the same hole.
11
+ *
12
+ * So the dialog stops keyboard events at its own boundary, after everything
13
+ * inside it has heard them: listeners on the elements within run first
14
+ * (bubbling reaches them before the root), capture-phase listeners on the
15
+ * document ran already, and only the host page's bubbling listeners are
16
+ * shielded. The browser's own actions — reload, find, tab — are untouched:
17
+ * this is `stopPropagation`, never `preventDefault`.
18
+ */
19
+ export declare const KEY_EVENTS: readonly ["keydown", "keyup", "keypress"];
20
+ export declare function containKeys(root: ShadowRoot): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightworkai.official/debug-capture",
3
- "version": "0.12.6",
3
+ "version": "0.12.7",
4
4
  "description": "Report-a-problem widget: rolling network/console/action capture, optional rrweb session replay, annotated screenshot, and submission to a Lightwork Support host",
5
5
  "type": "module",
6
6
  "module": "./dist/index.mjs",
package/src/ui/element.ts CHANGED
@@ -16,6 +16,7 @@ import { captureScreen } from "../screenshot";
16
16
  import { ReportError, submitBundle } from "../submit";
17
17
  import type { DebugBundle, DebugReason, ErroredQuery } from "../types";
18
18
  import { createAnnotator, type Annotator, type AnnotatorTool } from "./annotator";
19
+ import { containKeys } from "./keys";
19
20
  import { strings, type Strings } from "./strings";
20
21
  import { showToast } from "./toast";
21
22
  import { CSS } from "./styles";
@@ -89,6 +90,10 @@ function createReporterClass(): CustomElementConstructor {
89
90
  // "NotSupportedError: The result must not have attributes". Marking the
90
91
  // element in the constructor cost every consumer a crash at mount.
91
92
  this.root = this.attachShadow({ mode: "open" });
93
+ // What is typed into the dialog is the dialog's: the host page's own
94
+ // shortcuts must not hear it (ui/keys). Once, on the root — it outlives
95
+ // every open and close.
96
+ containKeys(this.root);
92
97
  }
93
98
 
94
99
  connectedCallback(): void {
package/src/ui/handoff.ts CHANGED
@@ -17,6 +17,7 @@
17
17
  * CSS should reach the other.
18
18
  */
19
19
  import { getConfig } from "../config";
20
+ import { containKeys } from "./keys";
20
21
  import { strings } from "./strings";
21
22
 
22
23
  const HOST_TAG = "lw-portal-handoff";
@@ -135,6 +136,9 @@ export function showHandoff(options: HandoffOptions): Promise<void> {
135
136
 
136
137
  const host = document.createElement(HOST_TAG);
137
138
  const root = host.attachShadow({ mode: "open" });
139
+ // A modal, so the host page's shortcuts hear nothing while it is up (ui/keys).
140
+ // Escape is caught on the document in the capture phase below, which runs first.
141
+ containKeys(root);
138
142
  const style = document.createElement("style");
139
143
  style.textContent = CSS;
140
144
  root.append(style);
package/src/ui/keys.ts ADDED
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Keys pressed inside one of our dialogs stay inside it.
3
+ *
4
+ * Our dialogs live in a shadow root on a host page we know nothing about. A
5
+ * key typed into the reporter's title field bubbles out of the shadow root
6
+ * retargeted to the host element — so the page's own listeners see a
7
+ * keypress on some custom element, not on an input, and any "never while
8
+ * typing" guard they wrote lets it through. On the desk that meant an `M`
9
+ * typed into the title toggled a filter behind the dialog and a `2` changed
10
+ * the page under it. Every host with single-key shortcuts has the same hole.
11
+ *
12
+ * So the dialog stops keyboard events at its own boundary, after everything
13
+ * inside it has heard them: listeners on the elements within run first
14
+ * (bubbling reaches them before the root), capture-phase listeners on the
15
+ * document ran already, and only the host page's bubbling listeners are
16
+ * shielded. The browser's own actions — reload, find, tab — are untouched:
17
+ * this is `stopPropagation`, never `preventDefault`.
18
+ */
19
+ export const KEY_EVENTS = ["keydown", "keyup", "keypress"] as const;
20
+
21
+ export function containKeys(root: ShadowRoot): void {
22
+ for (const type of KEY_EVENTS) root.addEventListener(type, (event) => event.stopPropagation());
23
+ }