@lightworkai.official/debug-capture 0.11.2 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- var Q2={maxRequests:60,maxConsoleEntries:120,maxActions:80,maxBodyChars:20000},k=null;function z2(J){let $=[];if(!J.host?.trim())$.push("host");if(!J.realmKey?.trim())$.push("realmKey");if(!J.app?.name?.trim())$.push("app.name");if(typeof J.module!=="function")$.push("module");if($.length)throw Error(`[debug-capture] configureDebugCapture is missing: ${$.join(", ")}. `+"See the README — `module` maps a pathname to the part of your app it belongs to.");k=J}function w(){if(!k)throw Error("[debug-capture] configureDebugCapture() has not been called");return k}function $0(){return k!==null}function f(){let J=w().app;return{name:J.name,version:J.version??"0.0.0",environment:J.environment??j2()}}function j2(){if(typeof window>"u")return"unknown";let J=window.location.hostname;if(J==="localhost"||J==="127.0.0.1"||J.endsWith(".local"))return"development";return"production"}function h(J){let $=k?.capture?.[J];return typeof $==="number"?$:Q2[J]}function n0(J){let $=k?.module;if(!$)return null;try{return $(J)??null}catch{return null}}function W0(){let J=k?.redact;return{headers:J?.headers??[],queryKeys:(J?.queryKeys??[]).map(($)=>$.toLowerCase()),bodyKeys:(J?.bodyKeys??[]).map(($)=>$.toLowerCase())}}function a0(){return k?.capture?.overlaySelectors??[]}function t0(J){if(typeof window>"u")return!1;let $;try{$=new URL(J,window.location.href)}catch{return!1}if(Z2($))return!1;if($.origin===window.location.origin)return!0;return(k?.capture?.bodyOrigins??[]).some((Q)=>{try{return new URL(Q).origin===$.origin}catch{return!1}})}function Z2(J){if(!k?.host)return!1;try{if(new URL(k.host).origin!==J.origin)return!1}catch{return!1}return J.pathname.startsWith("/ingest/")}function W2(J){let $=Object.entries(J).map(([Q,z])=>[Q.replace(/\/+$/,"")||"/",z]).sort((Q,z)=>z[0].length-Q[0].length);return(Q)=>{let z=(Q||"/").replace(/\/+$/,"")||"/";for(let[j,W]of $)if(z===j||z.startsWith(`${j}/`))return{key:j,label:W};return null}}var d="‹redacted›",K2=/^(authorization|proxy-authorization|cookie|set-cookie|x-[a-z-]*token|x-csrf[a-z-]*|x-xsrf[a-z-]*)$/i,V2=new Set(["access_token","token","id_token","refresh_token","code","secret","client_secret","password","apikey","api_key","signature","x-amz-signature","x-amz-credential"]),Y2=/(password|passwd|token|secret|authorization|refresh|client_secret|otp|pin)/i,X2=/[\w.+-]+@[\w-]+\.[\w.-]+/g,F2=/\d(?:[\d\s-]{7,})\d/g;function c(J){return J.replace(X2,d).replace(F2,d)}function G2(J){if(K2.test(J))return!0;return W0().headers.some((Q)=>Q.toLowerCase()===J.toLowerCase())}function i(J){let $={};for(let[Q,z]of Object.entries(J))$[Q]=G2(Q)?d:z;return $}function l(J){try{let $=/^https?:\/\//i.test(J),Q=new URL(J,$?void 0:"http://local.invalid"),z=!1;if(Q.searchParams.forEach((j,W)=>{if(V2.has(W.toLowerCase())||W0().queryKeys.includes(W.toLowerCase()))Q.searchParams.set(W,d),z=!0}),!z)return J;return $?Q.toString():`${Q.pathname}${Q.search}`}catch{return J}}function P0(J,$){if($>6||J===null||typeof J!=="object")return J;if(Array.isArray(J))return J.map((z)=>P0(z,$+1));let Q={};for(let[z,j]of Object.entries(J)){let W=Y2.test(z)||W0().bodyKeys.some((K)=>z.toLowerCase().includes(K));Q[z]=W?d:P0(j,$+1)}return Q}function o(J,$){if(J==null)return null;let Q=J,z=J.trim();if(z.startsWith("{")||z.startsWith("["))try{let j=JSON.parse(z);Q=JSON.stringify(P0(j,0))}catch{}if(Q.length>$)return`${Q.slice(0,$)}… [truncated ${Q.length-$} chars]`;return Q}var I0=120,D0=40,s=(J,$)=>J.length>$?`${J.slice(0,$)}…`:J,N0=(J)=>{try{return decodeURIComponent(J)}catch{return J}},r=[],e0=0,J1=!1;function Q0(J,$,Q,z){let j=s($,I0),W=r[r.length-1];if(J==="navigate"&&W?.kind==="click"){let F=j.replace(/^ไปที่\s*/,"");if(W.detail.includes(`→ ${F}`))return W.at=new Date().toISOString(),W;let G=F.split(/[?#]/)[0]??F,M=W.source?N0(W.source.replace(/^→\s*/,"")).split(/[?#]/)[0]:null;if(M&&(G===M||G.startsWith(M)))return W.detail=s(`${W.detail} → ${F}`,I0),W.source=void 0,W.at=new Date().toISOString(),W}if(W&&W.kind===J&&W.detail===j){if(W.at=new Date().toISOString(),J!=="navigate")W.count=(W.count??1)+1;return W}e0+=1;let K={id:`act_${e0}`,at:new Date().toISOString(),kind:J,detail:j,count:1,source:Q,html:V0(z)};r.push(K);while(r.length>h("maxActions"))U2(r.shift());return K}var H2=200000,z0=0;function V0(J){if(!J)return;if(z0+J.length>H2)return;return z0+=J.length,J}function U2(J){if(!J)return;if(z0-=(J.html?.length??0)+(J.afterHtml?.length??0),z0<0)z0=0}function C0(J){return J&&J>1?` (×${J})`:""}function K0(J){return J instanceof Element&&Boolean(J.closest("[data-debug-reporter]"))}var M2='button, a[href], [role="button"], [role="tab"], [role="menuitem"], [role="option"], [role="switch"], [role="checkbox"], [role="radio"], [role="link"], summary, input, select, textarea',P2={button:"ปุ่ม",a:"ลิงก์",input:"ช่อง",textarea:"ช่อง",select:"ตัวเลือก",summary:"ส่วนขยาย"},$1={button:"ปุ่ม",tab:"แท็บ",menuitem:"เมนู",option:"ตัวเลือก",switch:"สวิตช์",checkbox:"ช่องเลือก",radio:"ตัวเลือก",link:"ลิงก์"};function I2(J){let $=J.getAttribute("role");if($&&$1[$])return $1[$];return P2[J.tagName.toLowerCase()]??"ปุ่ม"}function D2(J,$){try{let Q=J,z=0;while(Q&&z<=$){let j=K1(Q);if(j&&typeof j.memoizedProps?.onClick==="function")return Q;Q=Q.parentElement,z+=1}}catch{}return null}function N2(J){let $=J.getAttribute("aria-label")?.trim();if($)return $;let Q=J.getAttribute("title")?.trim();if(Q)return Q;if(J instanceof HTMLInputElement||J instanceof HTMLTextAreaElement||J instanceof HTMLSelectElement)return(J.getAttribute("placeholder")||J.getAttribute("name")||"").trim();if(J instanceof HTMLImageElement)return(J.getAttribute("alt")||"").trim();let z=(J.textContent??"").replace(/\s+/g," ").trim();if(z)return z;if(J instanceof HTMLAnchorElement){let j=J.getAttribute("href");if(j?.startsWith("/"))return N0(j)}return""}function C2(J){if(!(J instanceof Element))return null;let $=J.closest(M2)??D2(J,4);if(!$)return null;let Q=$.tagName.toLowerCase();if(Q==="html"||Q==="body")return null;return $}function B2(J){let $=c(N2(J));if(!$)return null;return`${I2(J)} “${s($,D0)}”`}var W1=6000,q2=4000,w2=/(?:^|\s)!?(?:fixed|absolute|sticky|inset-\S+|z-\S+|top-\S+|bottom-\S+|left-\S+|right-\S+|w-screen|h-screen|min-h-screen|max-h-screen|translate-\S+|scale-\S+)(?=\s|$)/g;function R2(J){J.querySelectorAll("script, style, link, iframe, object, embed, noscript, canvas, video, audio").forEach((j)=>j.remove());let $=[J,...Array.from(J.querySelectorAll("*"))];for(let j of $){for(let K of Array.from(j.attributes)){let F=K.name.toLowerCase();if(F.startsWith("on")||F==="srcdoc"||F==="value"||F.startsWith("data-"))j.removeAttribute(K.name)}if(j instanceof HTMLAnchorElement)j.setAttribute("href","#");if(j instanceof HTMLImageElement)j.removeAttribute("src");let W=j.getAttribute("class");if(W){let K=W.replace(w2," ").replace(/\s+/g," ").trim();if(K)j.setAttribute("class",K);else j.removeAttribute("class")}}let Q=document.createTreeWalker(J,NodeFilter.SHOW_TEXT),z=Q.nextNode();while(z){if(z.nodeValue)z.nodeValue=c(z.nodeValue);z=Q.nextNode()}}function B0(J,$,Q){try{let z=J.outerHTML;if(!z||z.length>$)return;let j=J.cloneNode(!0);R2(j);let W=j.outerHTML;return W&&W.length<=Q?W:void 0}catch{return}}var S2=(J)=>B0(J,W1,q2),O2=150000,_2=40000,Q1=(J)=>B0(J,O2,_2);function L2(J){if(!(J instanceof HTMLInputElement)&&!(J instanceof HTMLTextAreaElement)&&!(J instanceof HTMLSelectElement))return null;let $=J.name||J.id||J.getAttribute("aria-label")||J.getAttribute("placeholder")||J.tagName.toLowerCase();return`ช่อง “${c($)}”`}var z1=80;function K1(J){let $=Object.keys(J).find((Q)=>Q.startsWith("__reactFiber$")||Q.startsWith("__reactInternalInstance$"));return $?J[$]:null}function A2(J){if(typeof J!=="function")return null;try{let $=Function.prototype.toString.call(J);return($.match(/\.(?:push|replace)\(\s*['"`]([^'"`]+)['"`]/)??$.match(/redirect\(\s*['"`]([^'"`]+)['"`]/))?.[1]??null}catch{return null}}function j1(J){if(!J)return;return`→ ${J.length>z1?`${J.slice(0,z1)}…`:J}`}function T2(J){try{let $=J.closest("a[href]")?.getAttribute("href");if($&&$.startsWith("/"))return j1($);let Q=K1(J),z=0;while(Q&&z<30){if(typeof Q.memoizedProps?.onClick==="function")return j1(A2(Q.memoizedProps.onClick));Q=Q.return,z+=1}return}catch{return}}var k2='[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], [role="status"], [role="alert"]';function E2(){let J=a0();return J.length?J.join(", "):k2}function x2(J){let $=J.getAttribute("role");if($==="status"||$==="alert")return"ข้อความแจ้งเตือน";if($==="menu")return"เมนู";if($==="listbox")return"รายการตัวเลือก";if($==="alertdialog")return"กล่องยืนยัน";return"กล่องโต้ตอบ"}function f2(J){let $=J.getAttribute("aria-label")?.trim();if($)return $;let Q=J.getAttribute("aria-labelledby");if(Q){let W=Q.split(/\s+/).map((K)=>document.getElementById(K)?.textContent?.trim()??"").filter(Boolean).join(" ");if(W)return W}let j=J.querySelector('[data-slot="dialog-title"], h1, h2, h3, [role="heading"]')?.textContent?.replace(/\s+/g," ").trim();if(j)return j;return(J.textContent??"").replace(/\s+/g," ").trim()}function V1(J){let $=c(f2(J)),Q=x2(J);return $?`เปิด ${Q} “${s($,D0)}”`:`เปิด ${Q}`}var h2='[aria-busy="true"], [role="progressbar"], [data-loading="true"], .animate-pulse, .animate-spin',m2=/กำลังโหลด|กำลังค้นหา|กำลังดำเนินการ|\bloading\b/i;function p2(J){if(J.querySelector(h2))return!0;return m2.test(J.textContent??"")}var y2=400,v2=250,g2=8000;function b2(J,$){if(typeof MutationObserver>"u"){$.html=V0(Q1(J));return}let Q=Date.now(),z=!1,j=()=>{z=!0,K.disconnect(),window.clearInterval(F),window.clearTimeout(G)},W=()=>{if(z)return;if(j(),!J.isConnected)return;$.detail=s(V1(J),I0),$.html=V0(Q1(J))},K=new MutationObserver(()=>{Q=Date.now()});K.observe(J,{childList:!0,subtree:!0,attributes:!0,characterData:!0});let F=window.setInterval(()=>{if(z)return;if(!J.isConnected){j();return}if(Date.now()-Q>=y2&&!p2(J))W()},v2),G=window.setTimeout(W,g2)}function u2(J){if(K0(J))return;let $=Q0("ui",V1(J));if($)b2(J,$)}function d2(){if(typeof MutationObserver>"u")return;let J=new WeakSet;new MutationObserver((Q)=>{for(let z of Q)for(let j of Array.from(z.addedNodes)){if(!(j instanceof Element))continue;let W=E2(),K=j.matches(W)?[j]:Array.from(j.querySelectorAll(W));for(let F of K){if(J.has(F))continue;J.add(F),u2(F)}}}).observe(document.body,{childList:!0,subtree:!0})}var c2=1600,i2=2500;function Z1(J){return{disabled:J.hasAttribute("disabled")||J.getAttribute("aria-disabled")==="true",busy:J.getAttribute("aria-busy")==="true",text:s((J.textContent??"").replace(/\s+/g," ").trim(),D0)}}function l2(J,$){if(!J.disabled&&$.disabled)return"ปุ่มถูกปิดใช้งานหลังคลิก";if(!J.busy&&$.busy)return"ปุ่มเข้าสู่สถานะกำลังโหลด";if(J.text!==$.text&&$.text)return`ข้อความเปลี่ยนเป็น “${$.text}”`;return null}function o2(J,$){if(typeof MutationObserver>"u")return;let Q=Z1(J),z=!1,j=(F,G)=>{if(z)return;if(z=!0,W.disconnect(),window.clearTimeout(K),$.afterNote=F,G)$.afterHtml=V0(B0(J,W1,i2))},W=new MutationObserver(()=>{if(!J.isConnected){j("องค์ประกอบหายไปจากหน้าจอ",!1);return}let F=l2(Q,Z1(J));if(F)j(F,!0)});W.observe(J,{attributes:!0,attributeFilter:["disabled","aria-disabled","aria-busy","class"],childList:!0,subtree:!0,characterData:!0});let K=window.setTimeout(()=>{if(!z&&!J.isConnected){j("องค์ประกอบหายไปจากหน้าจอ",!1);return}z=!0,W.disconnect()},c2)}function Y1(){if(J1||typeof window>"u")return;J1=!0,document.addEventListener("click",(z)=>{if(K0(z.target))return;let j=C2(z.target);if(!j)return;let W=B2(j);if(!W)return;let K=Q0("click",`คลิก ${W}`,T2(j),S2(j));if(K)o2(j,K)},{capture:!0,passive:!0}),document.addEventListener("change",(z)=>{if(K0(z.target))return;let j=L2(z.target);if(j)Q0("input",`แก้ไข ${j}`)},{capture:!0,passive:!0}),document.addEventListener("submit",(z)=>{if(K0(z.target))return;Q0("submit","ส่งฟอร์ม")},{capture:!0,passive:!0});let J=()=>Q0("navigate",`ไปที่ ${N0(l(location.pathname+location.search))}`),$=history.pushState.bind(history),Q=history.replaceState.bind(history);history.pushState=(...z)=>{let j=$(...z);return J(),j},history.replaceState=(...z)=>{let j=Q(...z);return J(),j},window.addEventListener("popstate",J),d2()}function q0(){return r.map((J)=>({...J}))}var X1=2000,Y0=[],F1=0,G1=!1;function w0(J,$){F1+=1,Y0.push({id:`log_${F1}`,at:new Date().toISOString(),level:J,message:$.length>X1?`${$.slice(0,X1)}…`:$});while(Y0.length>h("maxConsoleEntries"))Y0.shift()}function r2(){let J=new WeakSet;return($,Q)=>{if(typeof Q==="object"&&Q!==null){if(J.has(Q))return"[Circular]";J.add(Q)}if(typeof Q==="bigint")return Q.toString();return Q}}function H1(J){if(typeof J==="string")return J;if(J instanceof Error)return`${J.name}: ${J.message}`;try{let $=JSON.stringify(J,r2());if($!==void 0)return $}catch{}try{return String(J)}catch{}try{return Object.prototype.toString.call(J)}catch{return`[${typeof J}]`}}function U1(){if(G1||typeof window>"u")return;G1=!0;let J=["log","info","warn","error","debug"];for(let $ of J){let Q=console[$].bind(console);console[$]=(...z)=>{w0($,z.map(H1).join(" ")),Q(...z)}}window.addEventListener("error",($)=>{let Q=$.filename?` (${$.filename}:${$.lineno}:${$.colno})`:"";w0("exception",`${$.message}${Q}`)}),window.addEventListener("unhandledrejection",($)=>{let Q=$.reason instanceof Error?`${$.reason.name}: ${$.reason.message}`:H1($.reason);w0("unhandledrejection",Q)})}function R0(){return Y0.map((J)=>({...J}))}var M1=new Set,P1=new Set;function I1(J,$){return J.add($),()=>J.delete($)}function D1(J,$){for(let Q of[...J])Q($)}function S0(J){return I1(M1,J)}function O0(J={type:"manual"}){D1(M1,J)}function _0(J){return I1(P1,J)}function L0(J){D1(P1,J)}var s2=15000,n2=["ResizeObserver loop","Script error.","Non-Error promise rejection captured"],N1=!1,C1=0;function a2(J){return n2.some(($)=>J.includes($))}function B1(J){let $=J.message??"";if(!$||a2($))return;let Q=Date.now();if(Q-C1<s2)return;C1=Q,L0({...J,message:$})}function q1(){if(N1||typeof window>"u")return;N1=!0,window.addEventListener("error",(J)=>{if(!J.message&&!J.error)return;let $=J.error instanceof Error?J.error:null;B1({type:"runtime-error",message:J.message||($?$.message:"Unknown error"),stack:$?.stack})}),window.addEventListener("unhandledrejection",(J)=>{let $=J.reason;B1({type:"unhandledrejection",message:$ instanceof Error?$.message:String($),stack:$ instanceof Error?$.stack:void 0})})}var O1=4000,t2=1e6,e2=1e7,X0=[],w1=0,R1=!1;function _1(J){X0.push(J);while(X0.length>h("maxRequests"))X0.shift()}function L1(){return w1+=1,`req_${w1}`}function S1(J){let $={};if(!J)return $;if(J instanceof Headers)J.forEach((Q,z)=>{$[z]=Q});else if(Array.isArray(J))for(let[Q,z]of J)$[Q]=z;else Object.assign($,J);return $}function J4(J){let $={};return J.forEach((Q,z)=>{$[z]=Q}),$}function $4(J){if(J==null)return null;if(typeof J==="string")return J;if(J instanceof URLSearchParams)return J.toString();if(typeof FormData<"u"&&J instanceof FormData)return`[FormData: ${Array.from(J.keys()).join(", ")}]`;if(typeof Blob<"u"&&J instanceof Blob)return`[Blob ${J.size} bytes]`;if(J instanceof ArrayBuffer)return`[ArrayBuffer ${J.byteLength} bytes]`;return"[binary]"}function Q4(J,$){let Q="",z="GET",j={},W=null;if(typeof J==="string")Q=J;else if(J instanceof URL)Q=J.toString();else Q=J.url,z=J.method||z,j=S1(J.headers);if($){if($.method)z=$.method;if($.headers)j={...j,...S1($.headers)};if($.body!==void 0)W=$4($.body)}return{method:z.toUpperCase(),url:Q,headers:j,body:W}}function A1(J){return!t0(J)}function z4(J,$){if(A1($.url)){$.responseSnippet="[body not captured for this origin]";return}let Q=J.headers.get("content-type")??"",z=Number(J.headers.get("content-length")??"0"),j=z?`, ~${z} bytes`:"";if(!/json|text|xml|html|javascript|urlencoded/i.test(Q)){$.responseSnippet=`[binary ${Q||"unknown"}${j}]`;return}if(z>t2){$.responseSnippet=`[response ${Q||"text"}${j} — omitted]`;return}try{J.clone().text().then((W)=>{$.responseSnippet=o(W,h("maxBodyChars"))}).catch(()=>{})}catch{}}function T1(J,$){if(/[?&]_rsc=/.test(J))return!0;for(let Q of Object.keys($)){let z=Q.toLowerCase();if(z==="rsc"||z==="next-router-prefetch"||z==="next-router-state-tree")return!0}return!1}function j4(){if(typeof window>"u"||typeof window.fetch!=="function")return;let J=window.fetch.bind(window);window.fetch=Object.assign(async($,Q)=>{let z=Q4($,Q);if(T1(z.url,z.headers))return J($,Q);let j={id:L1(),startedAt:new Date().toISOString(),method:z.method,url:l(z.url),requestHeaders:i(z.headers),requestBody:o(z.body,O1),status:null,statusText:null,durationMs:null,via:"fetch"};_1(j);let W=performance.now();try{let K=await J($,Q);return j.status=K.status,j.statusText=K.statusText,j.durationMs=Math.round(performance.now()-W),j.responseHeaders=i(J4(K.headers)),z4(K,j),K}catch(K){throw j.durationMs=Math.round(performance.now()-W),j.error=K instanceof Error?`${K.name}: ${K.message}`:String(K),K}},J)}function Z4(){if(typeof window>"u"||typeof window.XMLHttpRequest!=="function")return;let J=XMLHttpRequest.prototype,$=J.open,Q=J.send,z=function(W,K){let F=typeof K==="string"?K:K.toString();return this.__cibEntry=T1(F,{})?void 0:{id:L1(),startedAt:"",method:(W||"GET").toUpperCase(),url:l(F),requestHeaders:{},requestBody:null,status:null,statusText:null,durationMs:null,via:"xhr"},$.apply(this,arguments)},j=function(W){let K=this.__cibEntry;if(K){K.startedAt=new Date().toISOString(),K.requestBody=typeof W==="string"?o(W,O1):W==null?null:"[non-string body]";let F=performance.now();_1(K),this.addEventListener("loadend",()=>{if(K.status=this.status||null,K.statusText=this.statusText||null,K.durationMs=Math.round(performance.now()-F),A1(K.url))K.responseSnippet="[body not captured for this origin]";else if(this.responseType===""||this.responseType==="text")try{K.responseSnippet=o(this.responseText||"",h("maxBodyChars"))}catch{}else{let G=this.getResponseHeader("content-type")??this.responseType;K.responseSnippet=`[binary ${G}]`}})}return Q.apply(this,arguments)};J.open=z,J.send=j}function k1(){if(R1)return;R1=!0,j4(),Z4()}function A0(){let J=X0.map((Q)=>({...Q})),$=0;for(let Q=J.length-1;Q>=0;Q-=1){let z=J[Q],j=z?.responseSnippet;if(!z||typeof j!=="string"||j.length===0)continue;if($+j.length>e2)z.responseSnippet=`[response omitted — report size budget reached (${j.length.toLocaleString()} chars)]`;else $+=j.length}return J}var W4={title:"รายงานปัญหา",summaryLabel:"หัวข้อปัญหา",summaryRequired:"(ต้องกรอกก่อนแจ้งปัญหา)",summaryPlaceholder:"สรุปปัญหาสั้น ๆ เช่น กดบันทึกร่างแล้ว error",detailLabel:"อธิบายปัญหา (ไม่บังคับ)",detailPlaceholder:"เกิดอะไรขึ้น? กำลังทำอะไรอยู่ตอนที่พบปัญหา?",annotateTitle:"วาดบนรูป",annotateHint:"ทำเครื่องหมายจุดที่มีปัญหาก่อนแนบ — วงกรอบ ชี้ลูกศร ไฮไลต์ หรือพิมพ์ข้อความ",annotateApply:"ใช้รูปนี้",cancel:"ยกเลิก",toolRect:"กรอบ",toolArrow:"ลูกศร",toolHighlight:"ไฮไลต์",toolText:"ข้อความ",deleteSelected:"ลบที่เลือก",clearAll:"ล้างทั้งหมด",annotateHelp:"เลือกเครื่องมือแล้วลากบนรูป · ไม่ได้เลือกเครื่องมือ = ย้าย/ปรับขนาดสิ่งที่วาดไว้ · กดกากบาทมุมขวาบนของรูปทรงเพื่อลบ",capturing:"กำลังเก็บภาพหน้าจอ…",noScreenshot:"ไม่มีภาพหน้าจอ — ยังส่งรายงานได้",cancelled:"ยกเลิกการเก็บภาพหน้าจอแล้ว",close:"ปิด",submit:"แจ้งปัญหา",submitting:"กำลังส่ง…",submitted:"แจ้งปัญหาสำเร็จ",crashed:"เกิดข้อผิดพลาดในระบบ",crashAction:"แจ้งปัญหา",failed:"ส่งรายงานไม่สำเร็จ",captured:"เก็บข้อมูลแล้ว",reporter:"ผู้แจ้ง",page:"หน้า",handoffTitle:"กำลังพาไปที่ระบบแจ้งปัญหา",handoffBody:"ระบบจะลงชื่อเข้าใช้ให้อัตโนมัติ เพื่อดูเรื่องที่คุณแจ้งไว้",handoffGo:"ไปเลย",handoffPreparing:"กำลังเตรียม…",handoffFailed:"เปิดรายการที่แจ้งไว้ไม่สำเร็จ",handoffBlocked:"เบราว์เซอร์บล็อกการเปิดแท็บใหม่",handoffOpen:"เปิดในแท็บใหม่"},K4={title:"Report a problem",summaryLabel:"Summary",summaryRequired:"(required)",summaryPlaceholder:"One line, e.g. saving a draft returns an error",detailLabel:"Details (optional)",detailPlaceholder:"What happened? What were you doing at the time?",annotateTitle:"Draw on the image",annotateHint:"Mark what went wrong before attaching — box it, point at it, highlight it, or type on it",annotateApply:"Use this image",cancel:"Cancel",toolRect:"Box",toolArrow:"Arrow",toolHighlight:"Highlight",toolText:"Text",deleteSelected:"Delete selected",clearAll:"Clear all",annotateHelp:"Pick a tool and drag on the image · no tool selected = move/resize what you drew · press the ✕ on a shape to delete it",capturing:"Capturing the screen…",noScreenshot:"No screenshot — you can still send the report",cancelled:"Screen capture cancelled",close:"Close",submit:"Send report",submitting:"Sending…",submitted:"Report sent",crashed:"Something went wrong",crashAction:"Report it",failed:"Could not send the report",captured:"Captured",reporter:"Reporter",page:"Page",handoffTitle:"Opening the support portal",handoffBody:"You will be signed in automatically to see what you reported",handoffGo:"Go now",handoffPreparing:"Preparing…",handoffFailed:"Could not open your reports",handoffBlocked:"Your browser blocked the new tab",handoffOpen:"Open in a new tab"};function b(J){return J==="en"?K4:W4}var V4="lw-debug-toasts",Y4=6000,X4=`
1
+ var M2=((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 C2={maxRequests:60,maxConsoleEntries:120,maxActions:80,maxBodyChars:20000},k=null;function I2(J){let $=[];if(!J.host?.trim())$.push("host");if(!J.realmKey?.trim())$.push("realmKey");if(!J.app?.name?.trim())$.push("app.name");if(typeof J.module!=="function")$.push("module");if($.length)throw Error(`[debug-capture] configureDebugCapture is missing: ${$.join(", ")}. `+"See the README — `module` maps a pathname to the part of your app it belongs to.");k=J}function S(){if(!k)throw Error("[debug-capture] configureDebugCapture() has not been called");return k}function j0(){return k!==null}function m(){let J=S().app;return{name:J.name,version:J.version??"0.0.0",environment:J.environment??P2()}}function P2(){if(typeof window>"u")return"unknown";let J=window.location.hostname;if(J==="localhost"||J==="127.0.0.1"||J.endsWith(".local"))return"development";return"production"}function g(J){let $=k?.capture?.[J];return typeof $==="number"?$:C2[J]}function Z1(J){let $=k?.module;if(!$)return null;try{return $(J)??null}catch{return null}}function G0(){let J=k?.redact;return{headers:J?.headers??[],queryKeys:(J?.queryKeys??[]).map(($)=>$.toLowerCase()),bodyKeys:(J?.bodyKeys??[]).map(($)=>$.toLowerCase())}}function K1(){return k?.capture?.overlaySelectors??[]}var q0={seconds:60,blockSelector:"[data-lw-private]",maskText:!1,maxBytes:4000000};function z0(){let J=k?.replay;if(!J)return null;let $=J===!0?{}:J,Q=typeof $.seconds==="number"&&$.seconds>0?$.seconds:q0.seconds,j=typeof $.maxBytes==="number"&&$.maxBytes>0?$.maxBytes:q0.maxBytes;return{seconds:Q,blockSelector:$.blockSelector?.trim()||q0.blockSelector,maskText:$.maskText===!0,maxBytes:j}}function W1(J){if(typeof window>"u")return!1;let $;try{$=new URL(J,window.location.href)}catch{return!1}if(D2($))return!1;if($.origin===window.location.origin)return!0;return(k?.capture?.bodyOrigins??[]).some((Q)=>{try{return new URL(Q).origin===$.origin}catch{return!1}})}function D2(J){if(!k?.host)return!1;try{if(new URL(k.host).origin!==J.origin)return!1}catch{return!1}return J.pathname.startsWith("/ingest/")}function N2(J){let $=Object.entries(J).map(([Q,j])=>[Q.replace(/\/+$/,"")||"/",j]).sort((Q,j)=>j[0].length-Q[0].length);return(Q)=>{let j=(Q||"/").replace(/\/+$/,"")||"/";for(let[z,K]of $)if(j===z||j.startsWith(`${z}/`))return{key:z,label:K};return null}}var i="‹redacted›",q2=/^(authorization|proxy-authorization|cookie|set-cookie|x-[a-z-]*token|x-csrf[a-z-]*|x-xsrf[a-z-]*)$/i,B2=new Set(["access_token","token","id_token","refresh_token","code","secret","client_secret","password","apikey","api_key","signature","x-amz-signature","x-amz-credential"]),S2=/(password|passwd|token|secret|authorization|refresh|client_secret|otp|pin)/i,O2=/[\w.+-]+@[\w-]+\.[\w.-]+/g,w2=/\d(?:[\d\s-]{7,})\d/g;function l(J){return J.replace(O2,i).replace(w2,i)}function R2(J){if(q2.test(J))return!0;return G0().headers.some((Q)=>Q.toLowerCase()===J.toLowerCase())}function o(J){let $={};for(let[Q,j]of Object.entries(J))$[Q]=R2(Q)?i:j;return $}function f(J){try{let $=/^https?:\/\//i.test(J),Q=new URL(J,$?void 0:"http://local.invalid"),j=!1;if(Q.searchParams.forEach((z,K)=>{if(B2.has(K.toLowerCase())||G0().queryKeys.includes(K.toLowerCase()))Q.searchParams.set(K,i),j=!0}),!j)return J;return $?Q.toString():`${Q.pathname}${Q.search}`}catch{return J}}function B0(J,$){if($>6||J===null||typeof J!=="object")return J;if(Array.isArray(J))return J.map((j)=>B0(j,$+1));let Q={};for(let[j,z]of Object.entries(J)){let K=S2.test(j)||G0().bodyKeys.some((W)=>j.toLowerCase().includes(W));Q[j]=K?i:B0(z,$+1)}return Q}function r(J,$){if(J==null)return null;let Q=J,j=J.trim();if(j.startsWith("{")||j.startsWith("["))try{let z=JSON.parse(j);Q=JSON.stringify(B0(z,0))}catch{}if(Q.length>$)return`${Q.slice(0,$)}… [truncated ${Q.length-$} chars]`;return Q}var S0=120,O0=40,n=(J,$)=>J.length>$?`${J.slice(0,$)}…`:J,w0=(J)=>{try{return decodeURIComponent(J)}catch{return J}},s=[],V1=0,X1=!1;function Z0(J,$,Q,j){let z=n($,S0),K=s[s.length-1];if(J==="navigate"&&K?.kind==="click"){let G=z.replace(/^ไปที่\s*/,"");if(K.detail.includes(`→ ${G}`))return K.at=new Date().toISOString(),K;let F=G.split(/[?#]/)[0]??G,M=K.source?w0(K.source.replace(/^→\s*/,"")).split(/[?#]/)[0]:null;if(M&&(F===M||F.startsWith(M)))return K.detail=n(`${K.detail} → ${G}`,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:F0(j)};s.push(W);while(s.length>g("maxActions"))L2(s.shift());return W}var _2=200000,K0=0;function F0(J){if(!J)return;if(K0+J.length>_2)return;return K0+=J.length,J}function L2(J){if(!J)return;if(K0-=(J.html?.length??0)+(J.afterHtml?.length??0),K0<0)K0=0}function R0(J){return J&&J>1?` (×${J})`:""}function Y0(J){return J instanceof Element&&Boolean(J.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',k2={button:"ปุ่ม",a:"ลิงก์",input:"ช่อง",textarea:"ช่อง",select:"ตัวเลือก",summary:"ส่วนขยาย"},G1={button:"ปุ่ม",tab:"แท็บ",menuitem:"เมนู",option:"ตัวเลือก",switch:"สวิตช์",checkbox:"ช่องเลือก",radio:"ตัวเลือก",link:"ลิงก์"};function A2(J){let $=J.getAttribute("role");if($&&G1[$])return G1[$];return k2[J.tagName.toLowerCase()]??"ปุ่ม"}function x2(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 E2(J){let $=J.getAttribute("aria-label")?.trim();if($)return $;let Q=J.getAttribute("title")?.trim();if(Q)return Q;if(J instanceof HTMLInputElement||J instanceof HTMLTextAreaElement||J instanceof HTMLSelectElement)return(J.getAttribute("placeholder")||J.getAttribute("name")||"").trim();if(J instanceof HTMLImageElement)return(J.getAttribute("alt")||"").trim();let j=(J.textContent??"").replace(/\s+/g," ").trim();if(j)return j;if(J instanceof HTMLAnchorElement){let z=J.getAttribute("href");if(z?.startsWith("/"))return w0(z)}return""}function f2(J){if(!(J instanceof Element))return null;let $=J.closest(T2)??x2(J,4);if(!$)return null;let Q=$.tagName.toLowerCase();if(Q==="html"||Q==="body")return null;return $}function h2(J){let $=l(E2(J));if(!$)return null;return`${A2(J)} “${n($,O0)}”`}var M1=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 v2(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(g2," ").replace(/\s+/g," ").trim();if(W)z.setAttribute("class",W);else z.removeAttribute("class")}}let Q=document.createTreeWalker(J,NodeFilter.SHOW_TEXT),j=Q.nextNode();while(j){if(j.nodeValue)j.nodeValue=l(j.nodeValue);j=Q.nextNode()}}function _0(J,$,Q){try{let j=J.outerHTML;if(!j||j.length>$)return;let z=J.cloneNode(!0);v2(z);let K=z.outerHTML;return K&&K.length<=Q?K:void 0}catch{return}}var y2=(J)=>_0(J,M1,m2),b2=150000,p2=40000,Y1=(J)=>_0(J,b2,p2);function u2(J){if(!(J instanceof HTMLInputElement)&&!(J instanceof HTMLTextAreaElement)&&!(J instanceof HTMLSelectElement))return null;let $=J.name||J.id||J.getAttribute("aria-label")||J.getAttribute("placeholder")||J.tagName.toLowerCase();return`ช่อง “${l($)}”`}var F1=80;function C1(J){let $=Object.keys(J).find((Q)=>Q.startsWith("__reactFiber$")||Q.startsWith("__reactInternalInstance$"));return $?J[$]:null}function d2(J){if(typeof J!=="function")return null;try{let $=Function.prototype.toString.call(J);return($.match(/\.(?:push|replace)\(\s*['"`]([^'"`]+)['"`]/)??$.match(/redirect\(\s*['"`]([^'"`]+)['"`]/))?.[1]??null}catch{return null}}function H1(J){if(!J)return;return`→ ${J.length>F1?`${J.slice(0,F1)}…`:J}`}function c2(J){try{let $=J.closest("a[href]")?.getAttribute("href");if($&&$.startsWith("/"))return H1($);let Q=C1(J),j=0;while(Q&&j<30){if(typeof Q.memoizedProps?.onClick==="function")return H1(d2(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 l2(){let J=K1();return J.length?J.join(", "):i2}function o2(J){let $=J.getAttribute("role");if($==="status"||$==="alert")return"ข้อความแจ้งเตือน";if($==="menu")return"เมนู";if($==="listbox")return"รายการตัวเลือก";if($==="alertdialog")return"กล่องยืนยัน";return"กล่องโต้ตอบ"}function r2(J){let $=J.getAttribute("aria-label")?.trim();if($)return $;let Q=J.getAttribute("aria-labelledby");if(Q){let K=Q.split(/\s+/).map((W)=>document.getElementById(W)?.textContent?.trim()??"").filter(Boolean).join(" ");if(K)return K}let z=J.querySelector('[data-slot="dialog-title"], h1, h2, h3, [role="heading"]')?.textContent?.replace(/\s+/g," ").trim();if(z)return z;return(J.textContent??"").replace(/\s+/g," ").trim()}function I1(J){let $=l(r2(J)),Q=o2(J);return $?`เปิด ${Q} “${n($,O0)}”`:`เปิด ${Q}`}var s2='[aria-busy="true"], [role="progressbar"], [data-loading="true"], .animate-pulse, .animate-spin',n2=/กำลังโหลด|กำลังค้นหา|กำลังดำเนินการ|\bloading\b/i;function a2(J){if(J.querySelector(s2))return!0;return n2.test(J.textContent??"")}var t2=400,e2=250,J4=8000;function $4(J,$){if(typeof MutationObserver>"u"){$.html=F0(Y1(J));return}let Q=Date.now(),j=!1,z=()=>{j=!0,W.disconnect(),window.clearInterval(G),window.clearTimeout(F)},K=()=>{if(j)return;if(z(),!J.isConnected)return;$.detail=n(I1(J),S0),$.html=F0(Y1(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>=t2&&!a2(J))K()},e2),F=window.setTimeout(K,J4)}function Q4(J){if(Y0(J))return;let $=Z0("ui",I1(J));if($)$4(J,$)}function j4(){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=l2(),W=z.matches(K)?[z]:Array.from(z.querySelectorAll(K));for(let G of W){if(J.has(G))continue;J.add(G),Q4(G)}}}).observe(document.body,{childList:!0,subtree:!0})}var z4=1600,Z4=2500;function U1(J){return{disabled:J.hasAttribute("disabled")||J.getAttribute("aria-disabled")==="true",busy:J.getAttribute("aria-busy")==="true",text:n((J.textContent??"").replace(/\s+/g," ").trim(),O0)}}function K4(J,$){if(!J.disabled&&$.disabled)return"ปุ่มถูกปิดใช้งานหลังคลิก";if(!J.busy&&$.busy)return"ปุ่มเข้าสู่สถานะกำลังโหลด";if(J.text!==$.text&&$.text)return`ข้อความเปลี่ยนเป็น “${$.text}”`;return null}function W4(J,$){if(typeof MutationObserver>"u")return;let Q=U1(J),j=!1,z=(G,F)=>{if(j)return;if(j=!0,K.disconnect(),window.clearTimeout(W),$.afterNote=G,F)$.afterHtml=F0(_0(J,M1,Z4))},K=new MutationObserver(()=>{if(!J.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}let G=K4(Q,U1(J));if(G)z(G,!0)});K.observe(J,{attributes:!0,attributeFilter:["disabled","aria-disabled","aria-busy","class"],childList:!0,subtree:!0,characterData:!0});let W=window.setTimeout(()=>{if(!j&&!J.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}j=!0,K.disconnect()},z4)}function P1(){if(X1||typeof window>"u")return;X1=!0,document.addEventListener("click",(j)=>{if(Y0(j.target))return;let z=f2(j.target);if(!z)return;let K=h2(z);if(!K)return;let W=Z0("click",`คลิก ${K}`,c2(z),y2(z));if(W)W4(z,W)},{capture:!0,passive:!0}),document.addEventListener("change",(j)=>{if(Y0(j.target))return;let z=u2(j.target);if(z)Z0("input",`แก้ไข ${z}`)},{capture:!0,passive:!0}),document.addEventListener("submit",(j)=>{if(Y0(j.target))return;Z0("submit","ส่งฟอร์ม")},{capture:!0,passive:!0});let J=()=>Z0("navigate",`ไปที่ ${w0(f(location.pathname+location.search))}`),$=history.pushState.bind(history),Q=history.replaceState.bind(history);history.pushState=(...j)=>{let z=$(...j);return J(),z},history.replaceState=(...j)=>{let z=Q(...j);return J(),z},window.addEventListener("popstate",J),j4()}function L0(){return s.map((J)=>({...J}))}var D1=2000,H0=[],N1=0,q1=!1;function T0(J,$){N1+=1,H0.push({id:`log_${N1}`,at:new Date().toISOString(),level:J,message:$.length>D1?`${$.slice(0,D1)}…`:$});while(H0.length>g("maxConsoleEntries"))H0.shift()}function V4(){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 B1(J){if(typeof J==="string")return J;if(J instanceof Error)return`${J.name}: ${J.message}`;try{let $=JSON.stringify(J,V4());if($!==void 0)return $}catch{}try{return String(J)}catch{}try{return Object.prototype.toString.call(J)}catch{return`[${typeof J}]`}}function S1(){if(q1||typeof window>"u")return;q1=!0;let J=["log","info","warn","error","debug"];for(let $ of J){let Q=console[$].bind(console);console[$]=(...j)=>{T0($,j.map(B1).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}`:B1($.reason);T0("unhandledrejection",Q)})}function k0(){return H0.map((J)=>({...J}))}var O1=new Set,w1=new Set;function R1(J,$){return J.add($),()=>J.delete($)}function _1(J,$){for(let Q of[...J])Q($)}function A0(J){return R1(O1,J)}function x0(J={type:"manual"}){_1(O1,J)}function E0(J){return R1(w1,J)}function f0(J){_1(w1,J)}var X4=15000,G4=["ResizeObserver loop","Script error.","Non-Error promise rejection captured"],L1=!1,T1=0;function Y4(J){return G4.some(($)=>J.includes($))}function k1(J){let $=J.message??"";if(!$||Y4($))return;let Q=Date.now();if(Q-T1<X4)return;T1=Q,f0({...J,message:$})}function A1(){if(L1||typeof window>"u")return;L1=!0,window.addEventListener("error",(J)=>{if(!J.message&&!J.error)return;let $=J.error instanceof Error?J.error:null;k1({type:"runtime-error",message:J.message||($?$.message:"Unknown error"),stack:$?.stack})}),window.addEventListener("unhandledrejection",(J)=>{let $=J.reason;k1({type:"unhandledrejection",message:$ instanceof Error?$.message:String($),stack:$ instanceof Error?$.stack:void 0})})}var h1=4000,F4=1e6,H4=1e7,U0=[],x1=0,E1=!1;function m1(J){U0.push(J);while(U0.length>g("maxRequests"))U0.shift()}function g1(){return x1+=1,`req_${x1}`}function f1(J){let $={};if(!J)return $;if(J instanceof Headers)J.forEach((Q,j)=>{$[j]=Q});else if(Array.isArray(J))for(let[Q,j]of J)$[Q]=j;else Object.assign($,J);return $}function U4(J){let $={};return J.forEach((Q,j)=>{$[j]=Q}),$}function M4(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 C4(J,$){let Q="",j="GET",z={},K=null;if(typeof J==="string")Q=J;else if(J instanceof URL)Q=J.toString();else Q=J.url,j=J.method||j,z=f1(J.headers);if($){if($.method)j=$.method;if($.headers)z={...z,...f1($.headers)};if($.body!==void 0)K=M4($.body)}return{method:j.toUpperCase(),url:Q,headers:z,body:K}}function v1(J){return!W1(J)}function I4(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>F4){$.responseSnippet=`[response ${Q||"text"}${z} — omitted]`;return}try{J.clone().text().then((K)=>{$.responseSnippet=r(K,g("maxBodyChars"))}).catch(()=>{})}catch{}}function y1(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 P4(){if(typeof window>"u"||typeof window.fetch!=="function")return;let J=window.fetch.bind(window);window.fetch=Object.assign(async($,Q)=>{let j=C4($,Q);if(y1(j.url,j.headers))return J($,Q);let z={id:g1(),startedAt:new Date().toISOString(),method:j.method,url:f(j.url),requestHeaders:o(j.headers),requestBody:r(j.body,h1),status:null,statusText:null,durationMs:null,via:"fetch"};m1(z);let K=performance.now();try{let W=await J($,Q);return z.status=W.status,z.statusText=W.statusText,z.durationMs=Math.round(performance.now()-K),z.responseHeaders=o(U4(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}},J)}function D4(){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=y1(G,{})?void 0:{id:g1(),startedAt:"",method:(K||"GET").toUpperCase(),url:f(G),requestHeaders:{},requestBody:null,status:null,statusText:null,durationMs:null,via:"xhr"},$.apply(this,arguments)},z=function(K){let W=this.__lwEntry;if(W){W.startedAt=new Date().toISOString(),W.requestBody=typeof K==="string"?r(K,h1):K==null?null:"[non-string body]";let G=performance.now();m1(W),this.addEventListener("loadend",()=>{if(W.status=this.status||null,W.statusText=this.statusText||null,W.durationMs=Math.round(performance.now()-G),v1(W.url))W.responseSnippet="[body not captured for this origin]";else if(this.responseType===""||this.responseType==="text")try{W.responseSnippet=r(this.responseText||"",g("maxBodyChars"))}catch{}else{let F=this.getResponseHeader("content-type")??this.responseType;W.responseSnippet=`[binary ${F}]`}})}return Q.apply(this,arguments)};J.open=j,J.send=z}function b1(){if(E1)return;E1=!0,P4(),D4()}function h0(){let J=U0.map((Q)=>({...Q})),$=0;for(let Q=J.length-1;Q>=0;Q-=1){let j=J[Q],z=j?.responseSnippet;if(!j||typeof z!=="string"||z.length===0)continue;if($+z.length>H4)j.responseSnippet=`[response omitted — report size budget reached (${z.length.toLocaleString()} chars)]`;else $+=z.length}return J}var N4=4,p1=3,q4=4000,B4="[data-debug-reporter]",S4=()=>import("@rrweb/record");var A=[],a=null,M0=!1;function u1(){if(typeof window>"u"||a||M0)return;let J=z0();if(!J)return;M0=!0;let $=()=>void O4(J);if("requestIdleCallback"in window)window.requestIdleCallback($,{timeout:3000});else setTimeout($,1000)}async function O4(J){let $;try{$=(await S4()).record}catch(Q){M0=!1,console.warn("[debug-capture] session replay could not start:",Q);return}if(a)return;try{a=$({emit:(Q)=>w4(Q),checkoutEveryNms:Math.max(1000,J.seconds*1000/2),checkoutEveryNth:q4,maskAllInputs:!0,...J.maskText?{maskTextSelector:"*"}:{},blockSelector:`${J.blockSelector}, ${B4}`,slimDOMOptions:"all",inlineStylesheet:!0,sampling:{mousemove:50,scroll:150,media:800,input:"last"},recordCanvas:!1,errorHandler:()=>!0})??null}catch(Q){console.warn("[debug-capture] session replay could not start:",Q)}finally{M0=!1}}function w4(J){if(J.type===N4||A.length===0){if(A.push([]),A.length>p1)A=A.slice(-p1)}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 R4(){return a!==null}function _4(){a?.(),a=null,A=[]}var L4={title:"รายงานปัญหา",summaryLabel:"หัวข้อปัญหา",summaryRequired:"(ต้องกรอกก่อนแจ้งปัญหา)",summaryPlaceholder:"สรุปปัญหาสั้น ๆ เช่น กดบันทึกร่างแล้ว error",detailLabel:"อธิบายปัญหา (ไม่บังคับ)",detailPlaceholder:"เกิดอะไรขึ้น? กำลังทำอะไรอยู่ตอนที่พบปัญหา?",annotateTitle:"วาดบนรูป",annotateHint:"ทำเครื่องหมายจุดที่มีปัญหาก่อนแนบ — วงกรอบ ชี้ลูกศร ไฮไลต์ หรือพิมพ์ข้อความ",annotateApply:"ใช้รูปนี้",cancel:"ยกเลิก",toolRect:"กรอบ",toolArrow:"ลูกศร",toolHighlight:"ไฮไลต์",toolText:"ข้อความ",deleteSelected:"ลบที่เลือก",clearAll:"ล้างทั้งหมด",annotateHelp:"เลือกเครื่องมือแล้วลากบนรูป · ไม่ได้เลือกเครื่องมือ = ย้าย/ปรับขนาดสิ่งที่วาดไว้ · กดกากบาทมุมขวาบนของรูปทรงเพื่อลบ",capturing:"กำลังเก็บภาพหน้าจอ…",noScreenshot:"ไม่มีภาพหน้าจอ — ยังส่งรายงานได้",cancelled:"ยกเลิกการเก็บภาพหน้าจอแล้ว",close:"ปิด",submit:"แจ้งปัญหา",submitting:"กำลังส่ง…",submitted:"แจ้งปัญหาสำเร็จ",crashed:"เกิดข้อผิดพลาดในระบบ",crashAction:"แจ้งปัญหา",failed:"ส่งรายงานไม่สำเร็จ",captured:"เก็บข้อมูลแล้ว",reporter:"ผู้แจ้ง",page:"หน้า",replay:"บันทึกหน้าจอ",handoffTitle:"กำลังพาไปที่ระบบแจ้งปัญหา",handoffBody:"ระบบจะลงชื่อเข้าใช้ให้อัตโนมัติ เพื่อดูเรื่องที่คุณแจ้งไว้",handoffGo:"ไปเลย",handoffPreparing:"กำลังเตรียม…",handoffFailed:"เปิดรายการที่แจ้งไว้ไม่สำเร็จ",handoffBlocked:"เบราว์เซอร์บล็อกการเปิดแท็บใหม่",handoffOpen:"เปิดในแท็บใหม่"},T4={title:"Report a problem",summaryLabel:"Summary",summaryRequired:"(required)",summaryPlaceholder:"One line, e.g. saving a draft returns an error",detailLabel:"Details (optional)",detailPlaceholder:"What happened? What were you doing at the time?",annotateTitle:"Draw on the image",annotateHint:"Mark what went wrong before attaching — box it, point at it, highlight it, or type on it",annotateApply:"Use this image",cancel:"Cancel",toolRect:"Box",toolArrow:"Arrow",toolHighlight:"Highlight",toolText:"Text",deleteSelected:"Delete selected",clearAll:"Clear all",annotateHelp:"Pick a tool and drag on the image · no tool selected = move/resize what you drew · press the ✕ on a shape to delete it",capturing:"Capturing the screen…",noScreenshot:"No screenshot — you can still send the report",cancelled:"Screen capture cancelled",close:"Close",submit:"Send report",submitting:"Sending…",submitted:"Report sent",crashed:"Something went wrong",crashAction:"Report it",failed:"Could not send the report",captured:"Captured",reporter:"Reporter",page:"Page",replay:"replay",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"?T4:L4}var k4="lw-debug-toasts",A4=6000,x4=`
2
2
  :host { all: initial; }
3
3
  .stack {
4
4
  position: fixed; top: 16px; right: 16px; z-index: 2147483001;
@@ -30,15 +30,15 @@ var Q2={maxRequests:60,maxConsoleEntries:120,maxActions:80,maxBodyChars:20000},k
30
30
  }
31
31
  @keyframes in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
32
32
  @media (prefers-reduced-motion: reduce) { .toast { animation: none; } }
33
- `,T0=null;function F4(){if(typeof document>"u")return null;if(T0?.isConnected)return T0;let J=document.createElement(V4);J.dataset.debugReporter="true";let $=J.attachShadow({mode:"open"}),Q=document.createElement("style");Q.textContent=X4;let z=document.createElement("div");return z.className="stack",z.setAttribute("role","status"),z.setAttribute("aria-live","polite"),$.append(Q,z),document.body.append(J),T0=z,z}function n(J,$="success",Q){let z=$0()?w().toast:void 0;if(z){z({message:J,tone:$,...Q?{action:Q}:{}});return}let j=F4();if(!j)return;let W=document.createElement("div");W.className="toast",W.dataset.tone=$;let K=document.createElement("span");K.className="dot";let F=document.createElement("span");F.textContent=J;let G=document.createElement("button");G.type="button",G.className="close",G.textContent="✕",G.setAttribute("aria-label","ปิด");let M=()=>{window.clearTimeout(N),W.remove()};G.addEventListener("click",M);let N=$==="error"||Q?0:window.setTimeout(M,Y4);if(W.append(K,F),Q){let P=document.createElement("button");P.type="button",P.className="action",P.textContent=Q.label,P.addEventListener("click",()=>{M(),Q.onClick()}),W.append(P)}W.append(G),j.append(W)}function E1(J,$,Q){let z=J.filter((W)=>Boolean(W.error)||W.status!=null&&W.status>=400).slice(-20).map((W)=>({method:W.method,url:W.url,status:W.status,error:W.error,at:W.startedAt})),j=$.filter((W)=>W.level==="error"||W.level==="exception"||W.level==="unhandledrejection").slice(-20).map((W)=>W.message);return{failedRequests:z,errors:j,erroredQueries:Q.slice(0,20)}}function x1(J){return J.failedRequests.length+J.errors.length+J.erroredQueries.length}function G4(){let J={memoryUsedMb:null,memoryLimitMb:null,domContentLoadedMs:null,loadEventMs:null};if(typeof performance>"u")return J;let $=performance.memory;if($)J.memoryUsedMb=Math.round($.usedJSHeapSize/1024/1024),J.memoryLimitMb=Math.round($.jsHeapSizeLimit/1024/1024);let[Q]=performance.getEntriesByType("navigation");if(Q)J.domContentLoadedMs=Math.round(Q.domContentLoadedEventEnd),J.loadEventMs=Math.round(Q.loadEventEnd);return J}function k0(J,$){if(!J)return $;try{return J()}catch{return $}}function f1(){let J=w(),{pathname:$,search:Q,href:z}=window.location;return{capturedAt:new Date().toISOString(),route:{href:z,pathname:$,search:Q},module:n0($),user:k0(J.user,{}),apiHeaders:i(k0(J.headers,{})),app:{name:f().name,version:f().version,environment:f().environment},client:{userAgent:navigator.userAgent,language:navigator.language,platform:navigator.platform,online:navigator.onLine,viewport:{width:window.innerWidth,height:window.innerHeight,dpr:window.devicePixelRatio},screen:{width:window.screen.width,height:window.screen.height}},performance:G4(),extra:k0(J.extra,{})}}var H4=2,U4={manual:"ผู้ใช้แจ้งเอง","runtime-error":"ข้อผิดพลาด runtime (auto)",unhandledrejection:"Promise rejection (auto)","framework-error":"หน้าจอค้าง/พัง (auto)"};function E0(J){let $=A0(),Q=R0();return{context:f1(),reason:J.reason,note:J.note,cause:E1($,Q,J.erroredQueries),actionTrail:q0(),network:$,console:Q,screenshotDataUrl:J.screenshotDataUrl,screenshotMethod:J.screenshotMethod,meta:{generatedBy:"lightwork-debug-capture",schemaVersion:H4}}}function h1(J){return J.replace(/'/g,"'\\''")}function m1(J){let $=[`curl -X ${J.method} '${J.url}'`];for(let[Q,z]of Object.entries(J.requestHeaders))$.push(` -H '${Q}: ${h1(z)}'`);if(J.requestBody)$.push(` --data '${h1(J.requestBody)}'`);return $.join(" \\\n")}function M4(J){if(J.error)return`ERR ${J.error}`;return`${J.status??"—"} ${J.statusText??""}`.trim()}function P4(J){if(J.length===0)return"No network activity captured.";return J.map(($)=>{let Q=$.durationMs!=null?`${$.durationMs}ms`:"—",z=`# [${M4($)}] ${$.method} ${$.url} (${Q}, ${$.startedAt})`,j=$.responseSnippet?`
34
- # response: ${$.responseSnippet}`:"";return`${z}
35
- ${m1($)}${j}`}).join(`
33
+ `,g0=null;function E4(){if(typeof document>"u")return null;if(g0?.isConnected)return g0;let J=document.createElement(k4);J.dataset.debugReporter="true";let $=J.attachShadow({mode:"open"}),Q=document.createElement("style");Q.textContent=x4;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 t(J,$="success",Q){let j=j0()?S().toast:void 0;if(j){j({message:J,tone:$,...Q?{action:Q}:{}});return}let z=E4();if(!z)return;let K=document.createElement("div");K.className="toast",K.dataset.tone=$;let W=document.createElement("span");W.className="dot";let G=document.createElement("span");G.textContent=J;let F=document.createElement("button");F.type="button",F.className="close",F.textContent="✕",F.setAttribute("aria-label","ปิด");let M=()=>{window.clearTimeout(q),K.remove()};F.addEventListener("click",M);let q=$==="error"||Q?0:window.setTimeout(M,A4);if(K.append(W,G),Q){let C=document.createElement("button");C.type="button",C.className="action",C.textContent=Q.label,C.addEventListener("click",()=>{M(),Q.onClick()}),K.append(C)}K.append(F),z.append(K)}function d1(J,$,Q){let j=J.filter((K)=>Boolean(K.error)||K.status!=null&&K.status>=400).slice(-20).map((K)=>({method:K.method,url:K.url,status:K.status,error:K.error,at:K.startedAt})),z=$.filter((K)=>K.level==="error"||K.level==="exception"||K.level==="unhandledrejection").slice(-20).map((K)=>K.message);return{failedRequests:j,errors:z,erroredQueries:Q.slice(0,20)}}function c1(J){return J.failedRequests.length+J.errors.length+J.erroredQueries.length}function f4(){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 v0(J,$){if(!J)return $;try{return J()}catch{return $}}function i1(){let J=S(),{pathname:$,search:Q,href:j}=window.location;return{capturedAt:new Date().toISOString(),route:{href:j,pathname:$,search:Q},module:Z1($),user:v0(J.user,{}),apiHeaders:o(v0(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:f4(),extra:v0(J.extra,{})}}var h4=2,m4={manual:"ผู้ใช้แจ้งเอง","runtime-error":"ข้อผิดพลาด runtime (auto)",unhandledrejection:"Promise rejection (auto)","framework-error":"หน้าจอค้าง/พัง (auto)"};function y0(J){let $=h0(),Q=k0();return{context:i1(),reason:J.reason,note:J.note,cause:d1($,Q,J.erroredQueries),actionTrail:L0(),network:$,console:Q,screenshotDataUrl:J.screenshotDataUrl,screenshotMethod:J.screenshotMethod,replay:m0()??void 0,meta:{generatedBy:"lightwork-debug-capture",schemaVersion:h4}}}function l1(J){return J.replace(/'/g,"'\\''")}function o1(J){let $=[`curl -X ${J.method} '${J.url}'`];for(let[Q,j]of Object.entries(J.requestHeaders))$.push(` -H '${Q}: ${l1(j)}'`);if(J.requestBody)$.push(` --data '${l1(J.requestBody)}'`);return $.join(" \\\n")}function g4(J){if(J.error)return`ERR ${J.error}`;return`${J.status??"—"} ${J.statusText??""}`.trim()}function v4(J){if(J.length===0)return"No network activity captured.";return J.map(($)=>{let Q=$.durationMs!=null?`${$.durationMs}ms`:"—",j=`# [${g4($)}] ${$.method} ${$.url} (${Q}, ${$.startedAt})`,z=$.responseSnippet?`
34
+ # response: ${$.responseSnippet}`:"";return`${j}
35
+ ${o1($)}${z}`}).join(`
36
36
 
37
- `)}function I4(J){if(J.length===0)return"No console output captured.";return J.map(($)=>`[${$.at}] ${$.level.toUpperCase()}: ${$.message}`).join(`
38
- `)}function D4(J){if(J.length===0)return"No user actions captured.";let $=0;return J.map((Q)=>{let z=Q.source?` (${Q.source})`:"",j=`${Q.detail}${C0(Q.count)}${z}`;if(Q.kind==="ui")return` ↳ [${Q.at}] ${j}`;$+=1;let W=`${$}. [${Q.at}] ${j}`;return Q.afterNote?`${W}
39
- ↳ ${Q.afterNote}`:W}).join(`
40
- `)}function N4(J){let $=[];for(let Q of J.failedRequests)$.push(`✗ ${Q.status??Q.error??"ERR"} ${Q.method} ${Q.url}`);for(let Q of J.errors)$.push(`⚠ ${Q}`);for(let Q of J.erroredQueries)$.push(`⚠ React Query error: ${Q.key} — ${Q.error}`);return $}function C4(J){let{context:$}=J;return[`User : ${$.user.fullName??"—"} (${$.user.email??"—"})`,`Unit : ${$.user.unit??"—"}`,`Roles : ${$.user.roles?.join(", ")||"—"}`,`Route : ${$.route.href}`,`Module : ${$.module?`${$.module.label} (${$.module.key})`:"—"}`,`App : ${$.app.name} v${$.app.version} · ${$.app.environment}`,`Memory : ${$.performance.memoryUsedMb??"—"}/${$.performance.memoryLimitMb??"—"} MB`,`Client : ${$.client.userAgent}`,`Viewport : ${$.client.viewport.width}×${$.client.viewport.height} @${$.client.viewport.dpr}x`,`Reason : ${U4[J.reason.type]}${J.reason.message?` — ${J.reason.message}`:""}`,`Captured : ${J.network.length} requests · ${J.console.length} console · ${J.actionTrail.length} actions · screenshot=${J.screenshotMethod}`]}function B4(J){let $=N4(J.cause),Q=[`## \uD83D\uDC1E ${J.context.app.name} — Debug Report`,`**Generated:** ${J.context.capturedAt}`,"",...C4(J).map((z)=>`- ${z.replace(/\s{2,}:/,":")}`),"",`**หมายเหตุจากผู้แจ้ง:** ${J.note.trim()||"(ไม่มี)"}`];if($.length>0)Q.push("","### ⚠ สาเหตุที่น่าจะเป็น","```",...$,"```");return Q.push("",`<details><summary>ขั้นตอน (${J.actionTrail.length})</summary>`,"","```",D4(J.actionTrail),"```","</details>","",`<details><summary>Network (${J.network.length})</summary>`,"","```",P4(J.network),"```","</details>","",`<details><summary>Console (${J.console.length})</summary>`,"","```",I4(J.console),"```","</details>","","_ข้อมูลลับ (token, cookie) ถูกปกปิดอัตโนมัติ · ภาพหน้าจออยู่ในไฟล์ .zip_"),Q.join(`
41
- `)}function q4(J){return J.replace(/[:.]/g,"-").replace("T","_").slice(0,19)}function w4(J,$){return`debug-report_${q4(J.context.capturedAt)}.${$}`}function R4(J){return x1(J.cause)>0}async function x0(){if(typeof navigator<"u"&&Boolean(navigator.mediaDevices?.getDisplayMedia)){let Q=await S4();if(Q.status==="ok")return{dataUrl:Q.dataUrl,method:"display-media"};if(Q.status==="cancelled")return{dataUrl:null,method:"cancelled"}}let $=await L4();if($)return{dataUrl:$,method:"html-to-image"};return{dataUrl:null,method:"none"}}async function S4(){let J=null;try{let $={video:{frameRate:30},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude"};J=await navigator.mediaDevices.getDisplayMedia($);let Q=await O4(J);return Q?{status:"ok",dataUrl:Q}:{status:"error"}}catch($){if($ instanceof DOMException&&($.name==="NotAllowedError"||$.name==="AbortError"))return{status:"cancelled"};return{status:"error"}}finally{J?.getTracks().forEach(($)=>$.stop())}}async function O4(J){let $=document.createElement("video");$.srcObject=J,$.muted=!0,$.playsInline=!0,await new Promise((K)=>{let F=!1,G=()=>{if(F)return;F=!0,K()};$.onloadedmetadata=()=>{$.play().then(G).catch(G)},window.setTimeout(G,1500)}),await _4($);let{videoWidth:Q,videoHeight:z}=$;if(!Q||!z)return null;let j=document.createElement("canvas");j.width=Q,j.height=z;let W=j.getContext("2d");if(!W)return null;W.drawImage($,0,0,Q,z),$.pause(),$.srcObject=null;try{return j.toDataURL("image/png")}catch{return null}}function _4(J){return new Promise(($)=>{let Q=!1,z=()=>{if(Q)return;Q=!0,$()},j=J;if(typeof j.requestVideoFrameCallback==="function")j.requestVideoFrameCallback(()=>z()),window.setTimeout(z,1000);else window.setTimeout(z,250)})}async function L4(){let J=w().screenshotFallback;if(!J)return null;let $=await J().catch(()=>null);if(!$)return null;try{return await $(document.body,{cacheBust:!0,pixelRatio:Math.min(window.devicePixelRatio||1,2),filter:(Q)=>!(Q instanceof HTMLElement&&Q.dataset?.debugReporter==="true")})}catch{return null}}var A4=2000,T4=0.82,k4=3000000;function E4(J){return new Promise(($,Q)=>{let z=new Image;z.onload=()=>$(z),z.onerror=()=>Q(Error("could not read the screenshot")),z.src=J})}async function p1(J){try{let $=await E4(J),Q=Math.max($.naturalWidth,$.naturalHeight),z=Math.min(1,A4/Q),j=document.createElement("canvas");j.width=Math.max(1,Math.round($.naturalWidth*z)),j.height=Math.max(1,Math.round($.naturalHeight*z));let W=j.getContext("2d");if(!W)return J;W.fillStyle="#fff",W.fillRect(0,0,j.width,j.height),W.drawImage($,0,0,j.width,j.height);let K=T4,F=j.toDataURL("image/jpeg",K);while(F.length>k4&&K>0.4)K-=0.15,F=j.toDataURL("image/jpeg",K);return F}catch{return J}}var x4=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,f4=/^\d+$/,h4=/^[0-9a-f]{16,}$/i;function f0(J){if(J.reason.type==="manual")return null;let $=J.cause?.failedRequests?.[0];if(!$?.url)return null;let Q;try{Q=new URL($.url,"http://x").pathname}catch{Q=$.url}let z=Q.split("/").map((W)=>x4.test(W)||f4.test(W)||h4.test(W)?":id":W).join("/"),j=$.status??($.error?"ERR":"?");return`${$.method??"REQ"} ${z} ${j}`}var h0=2000000;function F0(J){let{screenshotDataUrl:$,...Q}=J;return JSON.stringify(Q).length}function m0(J,$=2000000){if(F0(J)<=$)return J;let Q=J.network.map((j)=>({...j})),z={...J,network:Q};for(let j of Q){if(F0(z)<=$)return z;if(typeof j.responseSnippet==="string"&&j.responseSnippet.length>35)j.responseSnippet="[body dropped — report size budget]";if(typeof j.requestBody==="string"&&j.requestBody.length>35)j.requestBody="[body dropped — report size budget]"}while(z.network.length>1&&F0(z)>$)z.network=z.network.slice(1);while(z.console.length>1&&F0(z)>$)z.console=z.console.slice(1);return z}var y1=32768;function m4(J){let $="";for(let Q=0;Q<J.length;Q+=y1)$+=String.fromCharCode(...J.subarray(Q,Q+y1));return btoa($)}function p4(J){let{screenshotDataUrl:$,...Q}=J;return{dataUri:`data:application/json;base64,${m4(new TextEncoder().encode(JSON.stringify(Q)))}`,filename:"debug-bundle.json"}}async function y4(){let J=w().identity;if(!J)return{};try{let $=await J();return $?{authorization:`Bearer ${$}`}:{}}catch{return{}}}async function p0(J,$){let Q=w(),z=m0($,h0),{context:j,note:W}=z,K=[];if(z.screenshotDataUrl){let N=await p1(z.screenshotDataUrl);K.push({dataUri:N,filename:"screenshot.jpg"})}K.push(p4(z));let F=f0(z),G={title:J,description:W.trim()||void 0,appName:f().name,category:j.module?.label,routeUrl:j.route.href,priority:"MEDIUM",requesterEmail:j.user.email??void 0,requesterName:j.user.fullName??void 0,customFields:{unit:j.user.unit??"",appVersion:j.app.version,environment:j.app.environment,reasonType:z.reason.type,appName:f().name,module:j.module?.label??""},context:{...F?{signature:F}:{},capturedAt:j.capturedAt,reason:z.reason,cause:z.cause,actionTrail:z.actionTrail,client:j.client,performance:j.performance,apiHeaders:j.apiHeaders,extra:j.extra,counts:{network:z.network.length,console:z.console.length,actions:z.actionTrail.length},screenshotMethod:z.screenshotMethod},attachments:K},M=await fetch(`${Q.host.replace(/\/$/,"")}/ingest/tickets`,{method:"POST",headers:{"content-type":"application/json","x-realm-key":Q.realmKey,...await y4()},body:JSON.stringify(G)});if(!M.ok){let N=M.headers.get("retry-after"),P=await M.json().then((I)=>I.error).catch(()=>null);throw Error(M.status===429?`Too many reports — try again in ${N??"a moment"}s`:P??`Report failed (${M.status})`)}return await M.json()}var j0=Math.PI/6;function v1(J,$,Q){let z=$.x-J.x,j=$.y-J.y,W=Math.hypot(z,j),K=Math.atan2(j,z),F=[{x:$.x,y:$.y},{x:$.x-Q*Math.cos(K-j0),y:$.y-Q*Math.sin(K-j0)},{x:$.x-Q*Math.cos(K+j0),y:$.y-Q*Math.sin(K+j0)}],G=Q*Math.cos(j0)*0.92;if(W<=G)return{shaft:null,head:F};return{shaft:{from:J,to:{x:$.x-G*Math.cos(K),y:$.y-G*Math.sin(K)}},head:F}}var y0="#f44336",v4="rgba(250, 204, 21, 0.4)",v0=22,g1="#2563eb",b1=9,u1=11,d1=18,c1=4,G0=8,g4=[{id:"nw",fx:0,fy:0,cursor:"nwse-resize"},{id:"n",fx:0.5,fy:0,cursor:"ns-resize"},{id:"ne",fx:1,fy:0,cursor:"nesw-resize"},{id:"e",fx:1,fy:0.5,cursor:"ew-resize"},{id:"se",fx:1,fy:1,cursor:"nwse-resize"},{id:"s",fx:0.5,fy:1,cursor:"ns-resize"},{id:"sw",fx:0,fy:1,cursor:"nesw-resize"},{id:"w",fx:0,fy:0.5,cursor:"ew-resize"}];function g0(J,$,Q){let z=[],j=null,W=-1,K=null,F=null,G=J.getContext("2d");function M(){let Z=J.getBoundingClientRect().width;return Z>0?J.width/Z:1}function N(Z){let V=J.getBoundingClientRect();return{x:(Z.clientX-V.left)/V.width*J.width,y:(Z.clientY-V.top)/V.height*J.height}}function P(Z){let V=Z.size??v0;if(!G)return(Z.text?.length??0)*V*0.6;G.save(),G.font=`600 ${V}px system-ui, sans-serif`;let X=G.measureText(Z.text??"").width;return G.restore(),X}function I(Z){if(Z.tool==="text"){let V=Z.size??v0;return{left:Z.x1,top:Z.y1,right:Z.x1+P(Z),bottom:Z.y1+V*1.25}}return{left:Math.min(Z.x1,Z.x2),top:Math.min(Z.y1,Z.y2),right:Math.max(Z.x1,Z.x2),bottom:Math.max(Z.y1,Z.y2)}}function O(Z){if(Z.tool==="arrow")return[{id:"tail",x:Z.x1,y:Z.y1,cursor:"move"},{id:"head",x:Z.x2,y:Z.y2,cursor:"move"}];let V=I(Z);if(Z.tool==="text")return[{id:"size",x:V.right,y:V.bottom,cursor:"nwse-resize"}];return g4.map((X)=>({id:X.id,x:V.left+(V.right-V.left)*X.fx,y:V.top+(V.bottom-V.top)*X.fy,cursor:X.cursor}))}function B(Z){let V=I(Z);return{x:V.right+d1*M(),y:V.top-d1*M()}}function S(Z,V,X){let{shaft:Y,head:H}=v1({x:V.x1,y:V.y1},{x:V.x2,y:V.y2},Math.max(10,16*X));if(Y)Z.lineCap="butt",Z.beginPath(),Z.moveTo(Y.from.x,Y.from.y),Z.lineTo(Y.to.x,Y.to.y),Z.stroke();Z.beginPath(),Z.moveTo(H[0].x,H[0].y),Z.lineTo(H[1].x,H[1].y),Z.lineTo(H[2].x,H[2].y),Z.closePath(),Z.fill()}function _(Z,V,X){Z.save(),Z.lineWidth=Math.max(2,3*X),Z.strokeStyle=y0,Z.fillStyle=y0;let Y=I(V);if(V.tool==="rect")Z.strokeRect(Y.left,Y.top,Y.right-Y.left,Y.bottom-Y.top);else if(V.tool==="arrow")S(Z,V,X);else if(V.tool==="highlight")Z.fillStyle=v4,Z.fillRect(Y.left,Y.top,Y.right-Y.left,Y.bottom-Y.top);else if(V.tool==="text"&&V.text){let H=V.size??v0;Z.font=`600 ${H}px system-ui, sans-serif`,Z.textBaseline="top";let U=H*0.22;Z.fillStyle="rgba(255,255,255,0.92)",Z.fillRect(Y.left-U,Y.top-U,Y.right-Y.left+U*2,Y.bottom-Y.top+U*2),Z.fillStyle=y0,Z.fillText(V.text,Y.left,Y.top)}Z.restore()}function C(Z,V,X){let Y=I(V);Z.save(),Z.strokeStyle=g1,Z.lineWidth=Math.max(1,1.5*X),Z.setLineDash([6*X,4*X]),Z.strokeRect(Y.left,Y.top,Y.right-Y.left,Y.bottom-Y.top),Z.setLineDash([]);let H=b1*X;for(let T of O(V))Z.fillStyle="#fff",Z.strokeStyle=g1,Z.lineWidth=Math.max(1,1.5*X),Z.beginPath(),Z.rect(T.x-H/2,T.y-H/2,H,H),Z.fill(),Z.stroke();let U=B(V),D=u1*X;Z.beginPath(),Z.arc(U.x,U.y,D,0,Math.PI*2),Z.fillStyle="#dc2626",Z.fill(),Z.strokeStyle="#fff",Z.lineWidth=Math.max(1.5,2*X),Z.beginPath(),Z.moveTo(U.x-D*0.4,U.y-D*0.4),Z.lineTo(U.x+D*0.4,U.y+D*0.4),Z.moveTo(U.x+D*0.4,U.y-D*0.4),Z.lineTo(U.x-D*0.4,U.y+D*0.4),Z.stroke(),Z.restore()}function R(){if(!G)return;let Z=M();if(G.clearRect(0,0,J.width,J.height),G.drawImage($,0,0,J.width,J.height),z.forEach((X,Y)=>{if(Y!==y)_(G,X,Z)}),K)_(G,K,Z);let V=z[W];if(V&&!K)C(G,V,Z)}function m(Z,V,X,Y,H){return Math.abs(Z-X)<=H&&Math.abs(V-Y)<=H}function e(Z,V){let X=z[W];if(!X)return null;let Y=b1*M()/2+3*M();for(let H of O(X))if(m(Z,V,H.x,H.y,Y))return H.id;return null}function u(Z,V){let X=z[W];if(!X)return!1;let Y=B(X);return m(Z,V,Y.x,Y.y,u1*M())}function x(Z,V){let X=6*M();for(let Y=z.length-1;Y>=0;Y-=1){let H=z[Y];if(H.tool==="arrow"){let D=H.x2-H.x1,T=H.y2-H.y1,v=Math.hypot(D,T)||1,g=Math.max(0,Math.min(1,((Z-H.x1)*D+(V-H.y1)*T)/(v*v)));if(Math.hypot(Z-(H.x1+g*D),V-(H.y1+g*T))<=X+4*M())return Y;continue}let U=I(H);if(Z>=U.left-X&&Z<=U.right+X&&V>=U.top-X&&V<=U.bottom+X)return Y}return-1}function p(Z,V,X,Y,H){if(V==="tail"){Z.x1=X.x1+Y,Z.y1=X.y1+H;return}if(V==="head"){Z.x2=X.x2+Y,Z.y2=X.y2+H;return}if(V==="size"){let $2=(X.size??24)+H;Z.size=Math.max(10,$2);return}let U=I(X),{left:D,top:T,right:v,bottom:g}=U;if(V.includes("w"))D=Math.min(v-G0,D+Y);if(V.includes("e"))v=Math.max(D+G0,v+Y);if(V.includes("n"))T=Math.min(g-G0,T+H);if(V.includes("s"))g=Math.max(T+G0,g+H);Z.x1=D,Z.y1=T,Z.x2=v,Z.y2=g}function U0(Z,V,X,Y){Z.x1=V.x1+X,Z.y1=V.y1+Y,Z.x2=V.x2+X,Z.y2=V.y2+Y}let L=null,y=-1,q={x:0,y:0,size:24};function E(){let Z=J.getBoundingClientRect().width;return Z>0?Z/J.width:1}function J2(Z,V){if(!G)return Z.length*V*0.6;G.save(),G.font=`600 ${V}px system-ui, sans-serif`;let X=G.measureText(Z||" ").width;return G.restore(),X}function c0(){if(!L)return;let Z=J.parentElement;if(!Z)return;let V=J.getBoundingClientRect(),X=Z.getBoundingClientRect(),Y=E(),H=q.size*Y;L.style.left=`${V.left-X.left+q.x*Y}px`,L.style.top=`${V.top-X.top+q.y*Y}px`,L.style.fontSize=`${H}px`,L.style.width=`${Math.max(40,J2(L.value,H)+H)}px`}function J0(Z){let V=L;if(!V)return;L=null;let X=V.value.trim(),Y=y;if(y=-1,V.remove(),Z&&X){if(Y>=0&&z[Y])z[Y].text=X,W=Y;else z.push({tool:"text",x1:q.x,y1:q.y,x2:q.x,y2:q.y,text:X,size:q.size}),W=z.length-1;Q()}else if(Y>=0)W=Y;J.focus(),R()}function i0(Z,V,X=-1){J0(!0);let Y=J.parentElement;if(!Y)return;if(getComputedStyle(Y).position==="static")Y.style.position="relative";let H=X>=0?z[X]:void 0;y=X,q={x:H?.x1??Z,y:H?.y1??V,size:H?.size??Math.round(24*M())};let U=document.createElement("input");U.type="text",U.className="text-edit",U.value=H?.text??"",U.setAttribute("aria-label","ข้อความบนภาพ"),U.placeholder="ข้อความ",L=U,Y.append(U),c0(),U.addEventListener("input",c0),U.addEventListener("keydown",(D)=>{if(D.stopPropagation(),D.key==="Enter")J0(!0);else if(D.key==="Escape")J0(!1)}),requestAnimationFrame(()=>{if(L!==U)return;U.focus(),U.select(),U.addEventListener("blur",()=>J0(!0))}),R()}function l0(Z){let{x:V,y:X}=N(Z);if(J.setPointerCapture(Z.pointerId),u(V,X)){M0();return}let Y=e(V,X);if(Y&&z[W]){F={grip:Y,x:V,y:X,start:{...z[W]}};return}if(j==="text"){if(Z.preventDefault(),J.hasPointerCapture(Z.pointerId))J.releasePointerCapture(Z.pointerId);j=null,Q(),i0(V,X);return}if(j){K={tool:j,x1:V,y1:X,x2:V,y2:X},W=-1;return}let H=x(V,X);W=H,F=H>=0?{grip:"body",x:V,y:X,start:{...z[H]}}:null,R()}function o0(Z){let{x:V,y:X}=N(Z);if(K){K.x2=V,K.y2=X,R();return}if(F){let H=z[W];if(!H)return;let U=V-F.x,D=X-F.y;if(F.grip==="body")U0(H,F.start,U,D);else p(H,F.grip,F.start,U,D);R();return}if(j){J.style.cursor="crosshair";return}if(u(V,X)){J.style.cursor="pointer";return}let Y=e(V,X);if(Y){let H=z[W]?O(z[W]).find((U)=>U.id===Y):null;J.style.cursor=H?.cursor??"pointer";return}J.style.cursor=x(V,X)>=0?"move":"default"}function Z0(){if(K){if(!(Math.abs(K.x2-K.x1)<c1&&Math.abs(K.y2-K.y1)<c1))z.push(K),W=z.length-1,j=null,Q();K=null}if(F)F=null,Q();R()}function r0(Z){let V=J.getBoundingClientRect(),X=(Z.clientX-V.left)/V.width*J.width,Y=(Z.clientY-V.top)/V.height*J.height,H=x(X,Y),U=z[H];if(!U||U.tool!=="text")return;Z.preventDefault(),i0(U.x1,U.y1,H)}function s0(Z){if(W<0)return;if(Z.key==="Delete"||Z.key==="Backspace")Z.preventDefault(),M0();else if(Z.key==="Escape")W=-1,R()}function M0(){if(W<0)return;z.splice(W,1),W=-1,Q(),R()}return J.addEventListener("pointerdown",l0),J.addEventListener("pointermove",o0),J.addEventListener("pointerup",Z0),J.addEventListener("pointercancel",Z0),J.addEventListener("dblclick",r0),J.tabIndex=0,J.addEventListener("keydown",s0),R(),{setTool(Z){j=Z,W=-1,J.style.cursor=Z?"crosshair":"default",R()},deleteSelected:M0,clear(){z.length=0,W=-1,Q(),R()},hasShapes:()=>z.length>0,hasSelection:()=>W>=0,toDataUrl(){let Z=document.createElement("canvas");Z.width=$.naturalWidth,Z.height=$.naturalHeight;let V=Z.getContext("2d");if(!V)return J.toDataURL("image/png");V.drawImage($,0,0);let X=M();for(let Y of z)_(V,Y,X);return Z.toDataURL("image/png")},destroy(){J0(!1),J.removeEventListener("pointerdown",l0),J.removeEventListener("pointermove",o0),J.removeEventListener("pointerup",Z0),J.removeEventListener("pointercancel",Z0),J.removeEventListener("dblclick",r0),J.removeEventListener("keydown",s0)}}}var i1=`
37
+ `)}function y4(J){if(J.length===0)return"No console output captured.";return J.map(($)=>`[${$.at}] ${$.level.toUpperCase()}: ${$.message}`).join(`
38
+ `)}function b4(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}
39
+ ↳ ${Q.afterNote}`:K}).join(`
40
+ `)}function p4(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 u4(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 : ${m4[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 d4(J){let $=p4(J.cause),Q=[`## \uD83D\uDC1E ${J.context.app.name} — Debug Report`,`**Generated:** ${J.context.capturedAt}`,"",...u4(J).map((j)=>`- ${j.replace(/\s{2,}:/,":")}`),"",`**หมายเหตุจากผู้แจ้ง:** ${J.note.trim()||"(ไม่มี)"}`];if($.length>0)Q.push("","### ⚠ สาเหตุที่น่าจะเป็น","```",...$,"```");return Q.push("",`<details><summary>ขั้นตอน (${J.actionTrail.length})</summary>`,"","```",b4(J.actionTrail),"```","</details>","",`<details><summary>Network (${J.network.length})</summary>`,"","```",v4(J.network),"```","</details>","",`<details><summary>Console (${J.console.length})</summary>`,"","```",y4(J.console),"```","</details>","","_ข้อมูลลับ (token, cookie) ถูกปกปิดอัตโนมัติ · ภาพหน้าจออยู่ในไฟล์ .zip_"),Q.join(`
41
+ `)}function c4(J){return J.replace(/[:.]/g,"-").replace("T","_").slice(0,19)}function i4(J,$){return`debug-report_${c4(J.context.capturedAt)}.${$}`}function l4(J){return c1(J.cause)>0}async function b0(){if(typeof navigator<"u"&&Boolean(navigator.mediaDevices?.getDisplayMedia)){let Q=await o4();if(Q.status==="ok")return{dataUrl:Q.dataUrl,method:"display-media"};if(Q.status==="cancelled")return{dataUrl:null,method:"cancelled"}}let $=await n4();if($)return{dataUrl:$,method:"html-to-image"};return{dataUrl:null,method:"none"}}async function o4(){let J=null;try{let $={video:{frameRate:30},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude"};J=await navigator.mediaDevices.getDisplayMedia($);let Q=await r4(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 r4(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 s4($);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 s4(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 n4(){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 a4=2000,t4=0.82,e4=3000000;function J6(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 r1(J){try{let $=await J6(J),Q=Math.max($.naturalWidth,$.naturalHeight),j=Math.min(1,a4/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=t4,G=z.toDataURL("image/jpeg",W);while(G.length>e4&&W>0.4)W-=0.15,G=z.toDataURL("image/jpeg",W);return G}catch{return J}}var $6=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Q6=/^\d+$/,j6=/^[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)=>$6.test(K)||Q6.test(K)||j6.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 W0(J){let $="";for(let Q=0;Q<J.length;Q+=32768)$+=String.fromCharCode(...J.subarray(Q,Q+32768));return btoa($)}var z6=4,Z6=2,K6=3,W6=0,V6=new Set(["href","src","action","formaction","xlink:href","data","poster","srcset"]);function s1(J){if(!J)return;for(let $ of Object.keys(J)){let Q=J[$];if(typeof Q!=="string"||!V6.has($)||!Q.includes("?"))continue;J[$]=f(Q)}}function c0(J){if(!J)return;s1(J.attributes);for(let $ of J.childNodes??[])c0($)}function n1(J){let $=JSON.parse(JSON.stringify(J));for(let Q of $){let j=Q.data;if(!j||typeof j!=="object")continue;if(Q.type===z6&&typeof j.href==="string")j.href=f(j.href);else if(Q.type===Z6)c0(j.node);else if(Q.type===K6&&j.source===W6){for(let z of j.adds??[])c0(z.node);for(let z of j.attributes??[])s1(z.attributes)}}return $}var a1="session-replay.json.gz",X6="session-replay.json";function G6(J){return Boolean(J&&J.events.length>0)}async function Y6(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(!G6(J))return{summary:{omitted:"empty"}};let j={seconds:Math.round(J.durationMs/1000),events:J.events.length,startedAt:J.startedAt,endedAt:J.endedAt},z=new TextEncoder().encode(JSON.stringify({events:n1(J.events)})),K=await Y6(z),W=K??z;if(W.byteLength>$)return{summary:{...j,bytes:W.byteLength,omitted:"too-large"}};let G=K!==null;return{dataUri:`data:${G?"application/gzip":"application/json"};base64,${W0(W)}`,filename:G?a1:X6,summary:{...j,bytes:W.byteLength,compressed:G}}}function F6(J){let{screenshotDataUrl:$,replay:Q,...j}=J;return{dataUri:`data:application/json;base64,${W0(new TextEncoder().encode(JSON.stringify(j)))}`,filename:"debug-bundle.json"}}async function H6(){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 I=await r1(j.screenshotDataUrl);W.push({dataUri:I,filename:"screenshot.jpg"})}W.push(F6(j));let G,F=z0();if(F){let I=await i0(j.replay,F.maxBytes);if(G=I.summary,"dataUri"in I)W.push({dataUri:I.dataUri,filename:I.filename})}let M=p0(j),q={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:{...M?{signature:M}:{},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},C=await fetch(`${Q.host.replace(/\/$/,"")}/ingest/tickets`,{method:"POST",headers:{"content-type":"application/json","x-realm-key":Q.realmKey,...await H6()},body:JSON.stringify(q)});if(!C.ok){let I=C.headers.get("retry-after"),O=await C.json().then((D)=>D.error).catch(()=>null);throw Error(C.status===429?`Too many reports — try again in ${I??"a moment"}s`:O??`Report failed (${C.status})`)}return await C.json()}var V0=Math.PI/6;function t1(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-V0),y:$.y-Q*Math.sin(W-V0)},{x:$.x-Q*Math.cos(W+V0),y:$.y-Q*Math.sin(W+V0)}],F=Q*Math.cos(V0)*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",U6="rgba(250, 204, 21, 0.4)",r0=22,e1="#2563eb",J2=9,$2=11,Q2=18,j2=4,I0=8,M6=[{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 M(){let Z=J.getBoundingClientRect().width;return Z>0?J.width/Z:1}function q(Z){let V=J.getBoundingClientRect();return{x:(Z.clientX-V.left)/V.width*J.width,y:(Z.clientY-V.top)/V.height*J.height}}function C(Z){let V=Z.size??r0;if(!F)return(Z.text?.length??0)*V*0.6;F.save(),F.font=`600 ${V}px system-ui, sans-serif`;let Y=F.measureText(Z.text??"").width;return F.restore(),Y}function I(Z){if(Z.tool==="text"){let V=Z.size??r0;return{left:Z.x1,top:Z.y1,right:Z.x1+C(Z),bottom:Z.y1+V*1.25}}return{left:Math.min(Z.x1,Z.x2),top:Math.min(Z.y1,Z.y2),right:Math.max(Z.x1,Z.x2),bottom:Math.max(Z.y1,Z.y2)}}function O(Z){if(Z.tool==="arrow")return[{id:"tail",x:Z.x1,y:Z.y1,cursor:"move"},{id:"head",x:Z.x2,y:Z.y2,cursor:"move"}];let V=I(Z);if(Z.tool==="text")return[{id:"size",x:V.right,y:V.bottom,cursor:"nwse-resize"}];return M6.map((Y)=>({id:Y.id,x:V.left+(V.right-V.left)*Y.fx,y:V.top+(V.bottom-V.top)*Y.fy,cursor:Y.cursor}))}function D(Z){let V=I(Z);return{x:V.right+Q2*M(),y:V.top-Q2*M()}}function R(Z,V,Y){let{shaft:X,head:H}=t1({x:V.x1,y:V.y1},{x:V.x2,y:V.y2},Math.max(10,16*Y));if(X)Z.lineCap="butt",Z.beginPath(),Z.moveTo(X.from.x,X.from.y),Z.lineTo(X.to.x,X.to.y),Z.stroke();Z.beginPath(),Z.moveTo(H[0].x,H[0].y),Z.lineTo(H[1].x,H[1].y),Z.lineTo(H[2].x,H[2].y),Z.closePath(),Z.fill()}function _(Z,V,Y){Z.save(),Z.lineWidth=Math.max(2,3*Y),Z.strokeStyle=o0,Z.fillStyle=o0;let X=I(V);if(V.tool==="rect")Z.strokeRect(X.left,X.top,X.right-X.left,X.bottom-X.top);else if(V.tool==="arrow")R(Z,V,Y);else if(V.tool==="highlight")Z.fillStyle=U6,Z.fillRect(X.left,X.top,X.right-X.left,X.bottom-X.top);else if(V.tool==="text"&&V.text){let H=V.size??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(X.left-U,X.top-U,X.right-X.left+U*2,X.bottom-X.top+U*2),Z.fillStyle=o0,Z.fillText(V.text,X.left,X.top)}Z.restore()}function N(Z,V,Y){let X=I(V);Z.save(),Z.strokeStyle=e1,Z.lineWidth=Math.max(1,1.5*Y),Z.setLineDash([6*Y,4*Y]),Z.strokeRect(X.left,X.top,X.right-X.left,X.bottom-X.top),Z.setLineDash([]);let H=J2*Y;for(let x of O(V))Z.fillStyle="#fff",Z.strokeStyle=e1,Z.lineWidth=Math.max(1,1.5*Y),Z.beginPath(),Z.rect(x.x-H/2,x.y-H/2,H,H),Z.fill(),Z.stroke();let U=D(V),P=$2*Y;Z.beginPath(),Z.arc(U.x,U.y,P,0,Math.PI*2),Z.fillStyle="#dc2626",Z.fill(),Z.strokeStyle="#fff",Z.lineWidth=Math.max(1.5,2*Y),Z.beginPath(),Z.moveTo(U.x-P*0.4,U.y-P*0.4),Z.lineTo(U.x+P*0.4,U.y+P*0.4),Z.moveTo(U.x+P*0.4,U.y-P*0.4),Z.lineTo(U.x-P*0.4,U.y+P*0.4),Z.stroke(),Z.restore()}function w(){if(!F)return;let Z=M();if(F.clearRect(0,0,J.width,J.height),F.drawImage($,0,0,J.width,J.height),j.forEach((Y,X)=>{if(X!==b)_(F,Y,Z)}),W)_(F,W,Z);let V=j[K];if(V&&!W)N(F,V,Z)}function v(Z,V,Y,X,H){return Math.abs(Z-Y)<=H&&Math.abs(V-X)<=H}function $0(Z,V){let Y=j[K];if(!Y)return null;let X=J2*M()/2+3*M();for(let H of O(Y))if(v(Z,V,H.x,H.y,X))return H.id;return null}function c(Z,V){let Y=j[K];if(!Y)return!1;let X=D(Y);return v(Z,V,X.x,X.y,$2*M())}function h(Z,V){let Y=6*M();for(let X=j.length-1;X>=0;X-=1){let H=j[X];if(H.tool==="arrow"){let P=H.x2-H.x1,x=H.y2-H.y1,p=Math.hypot(P,x)||1,u=Math.max(0,Math.min(1,((Z-H.x1)*P+(V-H.y1)*x)/(p*p)));if(Math.hypot(Z-(H.x1+u*P),V-(H.y1+u*x))<=Y+4*M())return X;continue}let U=I(H);if(Z>=U.left-Y&&Z<=U.right+Y&&V>=U.top-Y&&V<=U.bottom+Y)return X}return-1}function y(Z,V,Y,X,H){if(V==="tail"){Z.x1=Y.x1+X,Z.y1=Y.y1+H;return}if(V==="head"){Z.x2=Y.x2+X,Z.y2=Y.y2+H;return}if(V==="size"){let U2=(Y.size??24)+H;Z.size=Math.max(10,U2);return}let U=I(Y),{left:P,top:x,right:p,bottom:u}=U;if(V.includes("w"))P=Math.min(p-I0,P+X);if(V.includes("e"))p=Math.max(P+I0,p+X);if(V.includes("n"))x=Math.min(u-I0,x+H);if(V.includes("s"))u=Math.max(x+I0,u+H);Z.x1=P,Z.y1=x,Z.x2=p,Z.y2=u}function D0(Z,V,Y,X){Z.x1=V.x1+Y,Z.y1=V.y1+X,Z.x2=V.x2+Y,Z.y2=V.y2+X}let L=null,b=-1,B={x:0,y:0,size:24};function E(){let Z=J.getBoundingClientRect().width;return Z>0?Z/J.width:1}function H2(Z,V){if(!F)return Z.length*V*0.6;F.save(),F.font=`600 ${V}px system-ui, sans-serif`;let Y=F.measureText(Z||" ").width;return F.restore(),Y}function e0(){if(!L)return;let Z=J.parentElement;if(!Z)return;let V=J.getBoundingClientRect(),Y=Z.getBoundingClientRect(),X=E(),H=B.size*X;L.style.left=`${V.left-Y.left+B.x*X}px`,L.style.top=`${V.top-Y.top+B.y*X}px`,L.style.fontSize=`${H}px`,L.style.width=`${Math.max(40,H2(L.value,H)+H)}px`}function Q0(Z){let V=L;if(!V)return;L=null;let Y=V.value.trim(),X=b;if(b=-1,V.remove(),Z&&Y){if(X>=0&&j[X])j[X].text=Y,K=X;else j.push({tool:"text",x1:B.x,y1:B.y,x2:B.x,y2:B.y,text:Y,size:B.size}),K=j.length-1;Q()}else if(X>=0)K=X;J.focus(),w()}function J1(Z,V,Y=-1){Q0(!0);let X=J.parentElement;if(!X)return;if(getComputedStyle(X).position==="static")X.style.position="relative";let H=Y>=0?j[Y]:void 0;b=Y,B={x:H?.x1??Z,y:H?.y1??V,size:H?.size??Math.round(24*M())};let U=document.createElement("input");U.type="text",U.className="text-edit",U.value=H?.text??"",U.setAttribute("aria-label","ข้อความบนภาพ"),U.placeholder="ข้อความ",L=U,X.append(U),e0(),U.addEventListener("input",e0),U.addEventListener("keydown",(P)=>{if(P.stopPropagation(),P.key==="Enter")Q0(!0);else if(P.key==="Escape")Q0(!1)}),requestAnimationFrame(()=>{if(L!==U)return;U.focus(),U.select(),U.addEventListener("blur",()=>Q0(!0))}),w()}function $1(Z){let{x:V,y:Y}=q(Z);if(J.setPointerCapture(Z.pointerId),c(V,Y)){N0();return}let X=$0(V,Y);if(X&&j[K]){G={grip:X,x:V,y:Y,start:{...j[K]}};return}if(z==="text"){if(Z.preventDefault(),J.hasPointerCapture(Z.pointerId))J.releasePointerCapture(Z.pointerId);z=null,Q(),J1(V,Y);return}if(z){W={tool:z,x1:V,y1:Y,x2:V,y2:Y},K=-1;return}let H=h(V,Y);K=H,G=H>=0?{grip:"body",x:V,y:Y,start:{...j[H]}}:null,w()}function Q1(Z){let{x:V,y:Y}=q(Z);if(W){W.x2=V,W.y2=Y,w();return}if(G){let H=j[K];if(!H)return;let U=V-G.x,P=Y-G.y;if(G.grip==="body")D0(H,G.start,U,P);else y(H,G.grip,G.start,U,P);w();return}if(z){J.style.cursor="crosshair";return}if(c(V,Y)){J.style.cursor="pointer";return}let X=$0(V,Y);if(X){let H=j[K]?O(j[K]).find((U)=>U.id===X):null;J.style.cursor=H?.cursor??"pointer";return}J.style.cursor=h(V,Y)>=0?"move":"default"}function X0(){if(W){if(!(Math.abs(W.x2-W.x1)<j2&&Math.abs(W.y2-W.y1)<j2))j.push(W),K=j.length-1,z=null,Q();W=null}if(G)G=null,Q();w()}function j1(Z){let V=J.getBoundingClientRect(),Y=(Z.clientX-V.left)/V.width*J.width,X=(Z.clientY-V.top)/V.height*J.height,H=h(Y,X),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(),N0();else if(Z.key==="Escape")K=-1,w()}function N0(){if(K<0)return;j.splice(K,1),K=-1,Q(),w()}return J.addEventListener("pointerdown",$1),J.addEventListener("pointermove",Q1),J.addEventListener("pointerup",X0),J.addEventListener("pointercancel",X0),J.addEventListener("dblclick",j1),J.tabIndex=0,J.addEventListener("keydown",z1),w(),{setTool(Z){z=Z,K=-1,J.style.cursor=Z?"crosshair":"default",w()},deleteSelected:N0,clear(){j.length=0,K=-1,Q(),w()},hasShapes:()=>j.length>0,hasSelection:()=>K>=0,toDataUrl(){let Z=document.createElement("canvas");Z.width=$.naturalWidth,Z.height=$.naturalHeight;let V=Z.getContext("2d");if(!V)return J.toDataURL("image/png");V.drawImage($,0,0);let Y=M();for(let X of j)_(V,X,Y);return Z.toDataURL("image/png")},destroy(){Q0(!1),J.removeEventListener("pointerdown",$1),J.removeEventListener("pointermove",Q1),J.removeEventListener("pointerup",X0),J.removeEventListener("pointercancel",X0),J.removeEventListener("dblclick",j1),J.removeEventListener("keydown",z1)}}}var z2=`
42
42
  :host { all: initial; }
43
43
  * { box-sizing: border-box; }
44
44
 
@@ -121,7 +121,7 @@ canvas { width: 100%; height: auto; display: block; border: 1px solid #e2e8f0; b
121
121
  border-radius: 0 0 16px 16px;
122
122
  }
123
123
  .foot .grow { flex: 1; }
124
- `;var t="lw-debug-reporter",l1=()=>[];function b4(J){l1=J}var u4=[{tool:"rect",key:"toolRect"},{tool:"arrow",key:"toolArrow"},{tool:"highlight",key:"toolHighlight"},{tool:"text",key:"toolText"}];function d4(){return class extends HTMLElement{root;stop=null;annotator=null;bundle=null;busy=!1;constructor(){super();this.root=this.attachShadow({mode:"open"})}connectedCallback(){this.dataset.debugReporter="true",this.stop=S0(($)=>void this.open($))}disconnectedCallback(){this.stop?.(),this.stop=null,this.close()}async open($){if(this.busy)return;this.busy=!0;let Q=b(w().locale),z=await x0();if(z.method==="cancelled"){this.close();return}this.bundle=E0({reason:$,note:"",screenshotDataUrl:z.dataUrl,screenshotMethod:z.method,erroredQueries:c4()}),this.renderForm(Q)}close(){this.annotator?.destroy(),this.annotator=null,this.bundle=null,this.busy=!1,this.root.replaceChildren()}shell($){let Q=document.createElement("style");Q.textContent=i1;let z=document.createElement("div");z.className="backdrop";let j=document.createElement("div");return j.className="panel",j.setAttribute("role","dialog"),j.setAttribute("aria-modal","true"),j.setAttribute("aria-label",$.title),z.append(j),this.root.replaceChildren(Q,z),j}renderShell($,Q){let z=this.shell($),j=A("div","head");j.append(A("h2","",$.title)),z.append(j,A("p","status",Q))}renderForm($){let Q=this.bundle;if(!Q)return;let z=this.shell($),j=A("div","head"),W=a("✕","icon");W.setAttribute("aria-label",$.close),W.addEventListener("click",()=>this.close()),j.append(A("h2","",$.title),W);let K=document.createElement("input");K.type="text",K.placeholder=$.summaryPlaceholder;let F=b0($.summaryLabel,$.summaryRequired,!0),G=document.createElement("textarea");G.placeholder=$.detailPlaceholder;let M=A("div","meta");M.innerHTML="";let{context:N}=Q;for(let[S,_]of[[$.reporter,`${N.user.fullName??"—"} (${N.user.email??"—"})`],[$.page,N.route.href],[$.captured,`${Q.network.length} network · ${Q.console.length} console · ${Q.actionTrail.length} actions`]]){let C=document.createElement("div"),R=document.createElement("b");R.textContent=`${S}: `,C.append(R,document.createTextNode(_)),M.append(C)}let P=A("p","status",""),I=a($.submit,"primary");if(I.disabled=!0,K.addEventListener("input",()=>{I.disabled=K.value.trim().length===0}),z.append(j,F,K,b0($.detailLabel),G,M),Q.screenshotDataUrl)z.append(...this.screenshotSection($,Q.screenshotDataUrl));else z.append(A("p","status",$.noScreenshot));let O=A("div","foot"),B=a($.close);B.addEventListener("click",()=>this.close()),O.append(B,P,A("span","grow"),I),z.append(O),I.addEventListener("click",async()=>{I.disabled=!0,P.dataset.tone="",P.textContent=$.submitting;try{let S=await p0(K.value.trim(),{...Q,note:G.value,screenshotDataUrl:this.annotator?.hasShapes()?this.annotator.toDataUrl():Q.screenshotDataUrl}),_=this.dispatchEvent(new CustomEvent("lw-report-submitted",{detail:S,bubbles:!0,composed:!0,cancelable:!0}));if(this.close(),_)n(`${$.submitted} — #${S.number}`,"success")}catch(S){let _=S instanceof Error?S.message:$.failed;P.dataset.tone="error",P.textContent=_,n(`${$.failed} — ${_}`,"error"),I.disabled=!1}}),K.focus()}screenshotSection($,Q){let z=b0($.annotateHint),j=A("div","tools"),W=document.createElement("canvas"),K=A("div","shot");K.append(W);let F=[],G=(I)=>{for(let O of F)O.setAttribute("aria-pressed",String(O===I))};for(let{tool:I,key:O}of u4){let B=a($[O]);B.setAttribute("aria-pressed","false"),B.addEventListener("click",()=>{let S=B.getAttribute("aria-pressed")==="true";G(S?null:B),this.annotator?.setTool(S?null:I)}),F.push(B),j.append(B)}j.append(A("span","sep"));let M=a($.deleteSelected);M.addEventListener("click",()=>this.annotator?.deleteSelected());let N=a($.clearAll);N.addEventListener("click",()=>{this.annotator?.clear(),G(null)}),j.append(M,N);let P=new Image;return P.onload=()=>{W.width=P.naturalWidth,W.height=P.naturalHeight,this.annotator=g0(W,P,()=>{G(null),M.disabled=!this.annotator?.hasSelection()})},P.src=Q,[z,j,A("p","status",$.annotateHelp),K]}}}function c4(){try{return l1()}catch{return[]}}function A(J,$="",Q=""){let z=document.createElement(J);if($)z.className=$;if(Q)z.textContent=Q;return z}function a(J,$=""){let Q=document.createElement("button");if(Q.type="button",Q.textContent=J,$)Q.className=$;return Q}function b0(J,$="",Q=!1){let z=document.createElement("label");if(z.append(document.createTextNode(J)),Q){let j=document.createElement("span");j.className="req",j.textContent=" *",z.append(j)}if($){let j=document.createElement("span");j.className="hint",j.textContent=` ${$}`,z.append(j)}return z}function u0(){if(typeof window>"u"||customElements.get(t))return;customElements.define(t,d4())}var o1=!1;function i4(J={}){if(o1||typeof window>"u")return;if(!$0()){console.error("[debug-capture] configureDebugCapture() must be called before install");return}if(o1=!0,k1(),U1(),Y1(),q1(),J.ui===!1)return;let $=b(w().locale);if(_0((Q)=>{n(Q.message??$.crashed,"error",{label:$.crashAction,onClick:()=>O0(Q)})}),u0(),!document.querySelector(t))document.body.append(document.createElement(t))}var l4=new Set(["error","exception","unhandledrejection"]);function r1(J){if(J.error)return!0;return J.status!==null&&J.status>=400}function d0(J){if(!J)return null;let $=Date.parse(J);return Number.isNaN($)?null:$}function o4(J){try{let{pathname:$}=new URL(J,"http://x");try{return decodeURIComponent($)}catch{return $}}catch{return J.split(/[?#]/)[0]??J}}function r4(J,$,Q){let z=(K)=>({elapsedMs:K,requests:[],failedRequests:[],consoleErrors:[],slowestMs:null});if(J.length===0)return[];let j=J.map((K)=>d0(K.at)),W=(K)=>{for(let F=K+1;F<j.length;F+=1){let G=j[F];if(G!=null)return G}return Number.POSITIVE_INFINITY};return J.map((K,F)=>{let G=j[F]??null,M=(F>0?j[F-1]:null)??null,N=G!==null&&M!==null?Math.max(0,G-M):null;if(G===null)return z(N);let P=G,I=Math.max(P,W(F)),O=(C)=>C!==null&&C>=P&&(C<I||I===Number.POSITIVE_INFINITY),B=$.filter((C)=>O(d0(C.startedAt))),S=Q.filter((C)=>l4.has(C.level)&&O(d0(C.at))),_=B.map((C)=>C.durationMs).filter((C)=>typeof C==="number");return{elapsedMs:N,requests:B,failedRequests:B.filter(r1),consoleErrors:S,slowestMs:_.length>0?Math.max(..._):null}})}function s4(J,$){return J.requests.length===0&&J.consoleErrors.length===0&&(J.elapsedMs===null||J.elapsedMs<$)}function n4(J){if(J<1000)return`${Math.round(J)} มิลลิวินาที`;let $=J/1000;if($<10)return`${$.toFixed(1)} วิ`;if($<60)return`${Math.round($)} วิ`;let Q=Math.floor($/60),z=Math.round($%60);return z===0?`${Q} นาที`:`${Q} นาที ${z} วิ`}var a4="lw-portal-handoff",s1=138.23,t4=`
124
+ `;var J0="lw-debug-reporter",Z2=()=>[];function C6(J){Z2=J}var I6=[{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"})}connectedCallback(){this.dataset.debugReporter="true",this.stop=A0(($)=>void this.open($))}disconnectedCallback(){this.stop?.(),this.stop=null,this.close()}async open($){if(this.busy)return;this.busy=!0;let Q=d(S().locale),j=await b0();if(j.method==="cancelled"){this.close();return}this.bundle=y0({reason:$,note:"",screenshotDataUrl:j.dataUrl,screenshotMethod:j.method,erroredQueries:D6()}),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=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",$.title),j.append(z),this.root.replaceChildren(Q,j),z}renderShell($,Q){let j=this.shell($),z=T("div","head");z.append(T("h2","",$.title)),j.append(z,T("p","status",Q))}renderForm($){let Q=this.bundle;if(!Q)return;let j=this.shell($),z=T("div","head"),K=e("✕","icon");K.setAttribute("aria-label",$.close),K.addEventListener("click",()=>this.close()),z.append(T("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 M=T("div","meta");M.innerHTML="";let{context:q}=Q;for(let[R,_]of[[$.reporter,`${q.user.fullName??"—"} (${q.user.email??"—"})`],[$.page,q.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 N=document.createElement("div"),w=document.createElement("b");w.textContent=`${R}: `,N.append(w,document.createTextNode(_)),M.append(N)}let C=T("p","status",""),I=e($.submit,"primary");if(I.disabled=!0,W.addEventListener("input",()=>{I.disabled=W.value.trim().length===0}),j.append(z,G,W,n0($.detailLabel),F,M),Q.screenshotDataUrl)j.append(...this.screenshotSection($,Q.screenshotDataUrl));else j.append(T("p","status",$.noScreenshot));let O=T("div","foot"),D=e($.close);D.addEventListener("click",()=>this.close()),O.append(D,C,T("span","grow"),I),j.append(O),I.addEventListener("click",async()=>{I.disabled=!0,C.dataset.tone="",C.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(),_)t(`${$.submitted} — #${R.number}`,"success")}catch(R){let _=R instanceof Error?R.message:$.failed;C.dataset.tone="error",C.textContent=_,t(`${$.failed} — ${_}`,"error"),I.disabled=!1}}),W.focus()}screenshotSection($,Q){let j=n0($.annotateHint),z=T("div","tools"),K=document.createElement("canvas"),W=T("div","shot");W.append(K);let G=[],F=(I)=>{for(let O of G)O.setAttribute("aria-pressed",String(O===I))};for(let{tool:I,key:O}of I6){let D=e($[O]);D.setAttribute("aria-pressed","false"),D.addEventListener("click",()=>{let R=D.getAttribute("aria-pressed")==="true";F(R?null:D),this.annotator?.setTool(R?null:I)}),G.push(D),z.append(D)}z.append(T("span","sep"));let M=e($.deleteSelected);M.addEventListener("click",()=>this.annotator?.deleteSelected());let q=e($.clearAll);q.addEventListener("click",()=>{this.annotator?.clear(),F(null)}),z.append(M,q);let C=new Image;return C.onload=()=>{K.width=C.naturalWidth,K.height=C.naturalHeight,this.annotator=s0(K,C,()=>{F(null),M.disabled=!this.annotator?.hasSelection()})},C.src=Q,[j,z,T("p","status",$.annotateHelp),W]}}}function D6(){try{return Z2()}catch{return[]}}function T(J,$="",Q=""){let j=document.createElement(J);if($)j.className=$;if(Q)j.textContent=Q;return j}function e(J,$=""){let Q=document.createElement("button");if(Q.type="button",Q.textContent=J,$)Q.className=$;return Q}function 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(J0))return;customElements.define(J0,P6())}var K2=!1;function N6(J={}){if(K2||typeof window>"u")return;if(!j0()){console.error("[debug-capture] configureDebugCapture() must be called before install");return}if(K2=!0,b1(),S1(),P1(),A1(),u1(),J.ui===!1)return;let $=d(S().locale);if(E0((Q)=>{t(Q.message??$.crashed,"error",{label:$.crashAction,onClick:()=>x0(Q)})}),a0(),!document.querySelector(J0))document.body.append(document.createElement(J0))}var q6=new Set(["error","exception","unhandledrejection"]);function W2(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 B6(J){try{let{pathname:$}=new URL(J,"http://x");try{return decodeURIComponent($)}catch{return $}}catch{return J.split(/[?#]/)[0]??J}}function S6(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,M=(G>0?z[G-1]:null)??null,q=F!==null&&M!==null?Math.max(0,F-M):null;if(F===null)return j(q);let C=F,I=Math.max(C,K(G)),O=(N)=>N!==null&&N>=C&&(N<I||I===Number.POSITIVE_INFINITY),D=$.filter((N)=>O(t0(N.startedAt))),R=Q.filter((N)=>q6.has(N.level)&&O(t0(N.at))),_=D.map((N)=>N.durationMs).filter((N)=>typeof N==="number");return{elapsedMs:q,requests:D,failedRequests:D.filter(W2),consoleErrors:R,slowestMs:_.length>0?Math.max(..._):null}})}function O6(J,$){return J.requests.length===0&&J.consoleErrors.length===0&&(J.elapsedMs===null||J.elapsedMs<$)}function w6(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 R6="lw-portal-handoff",V2=138.23,_6=`
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: ${s1}; stroke-dashoffset: 0;
154
+ stroke-dasharray: ${V2}; stroke-dashoffset: 0;
155
155
  animation: deplete var(--secs, 3s) linear forwards;
156
156
  }
157
- @keyframes deplete { to { stroke-dashoffset: ${s1}; } }
157
+ @keyframes deplete { to { stroke-dashoffset: ${V2}; } }
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 n1(J){if(typeof document>"u")return J.prepare().then((C)=>void J.go(C),()=>{return});let $=b(w().locale),Q=Math.max(1,Math.floor(J.seconds??3)),z=document.createElement(a4),j=z.attachShadow({mode:"open"}),W=document.createElement("style");W.textContent=t4,j.append(W);let K=document.createElement("div");K.className="backdrop",K.innerHTML=`
201
+ `;function X2(J){if(typeof document>"u")return J.prepare().then((N)=>void J.go(N),()=>{return});let $=d(S().locale),Q=Math.max(1,Math.floor(J.seconds??3)),j=document.createElement(R6),z=j.attachShadow({mode:"open"}),K=document.createElement("style");K.textContent=_6,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>`,j.append(K);let F=(C)=>K.querySelector(C),G=F(".card"),M=F(".bar"),N=F(".count"),P=F("h2"),I=F(".body"),O=F(".host"),B=F(".go"),S=F(".cancel");P.textContent=$.handoffTitle,I.textContent=$.handoffBody;try{O.textContent=new URL(w().host).host}catch{O.textContent=""}B.textContent=$.handoffGo,S.textContent=$.cancel,G.style.setProperty("--secs",`${Q}s`),N.textContent=String(Q),document.body.append(z),requestAnimationFrame(()=>K.setAttribute("data-open","1"));let _=document.activeElement;return B.focus({preventScroll:!0}),new Promise((C)=>{let R=!1,m=null,e=!1,u=Date.now()+Q*1000,x=window.setInterval(()=>{let q=Math.ceil((u-Date.now())/1000);if(N.textContent=String(Math.max(0,q)),Date.now()>=u)L()},100);function p(q){if(R)return;if(R=!0,window.clearInterval(x),document.removeEventListener("keydown",y,!0),K.removeAttribute("data-open"),window.setTimeout(()=>z.remove(),200),!q)_?.focus?.({preventScroll:!0});C()}function U0(q){window.clearInterval(x),M.classList.remove("spinner"),M.style.animation="none",N.textContent="",P.textContent=$.handoffBlocked,I.textContent=$.handoffBody;let E=document.createElement("a");E.className="go",E.href=q,E.target="_blank",E.rel="noopener noreferrer",E.textContent=$.handoffOpen,E.addEventListener("click",()=>p(!0)),B.replaceWith(E),E.focus({preventScroll:!0})}function L(){if(R||e)return;if(m)return J.go(m)?p(!0):U0(m);window.clearInterval(x),N.textContent="",M.classList.add("spinner"),P.textContent=$.handoffPreparing}function y(q){if(q.key==="Escape")q.stopPropagation(),p(!1)}document.addEventListener("keydown",y,!0),B.addEventListener("click",L),S.addEventListener("click",()=>p(!1)),K.addEventListener("click",(q)=>{if(q.target===K)p(!1)}),J.prepare().then((q)=>{if(m=q,!R&&Date.now()>=u)L()},()=>{e=!0,window.clearInterval(x),G.classList.add("error"),M.classList.remove("spinner"),M.style.animation="none",N.textContent="",P.textContent=$.handoffFailed,I.textContent=$.handoffBody,B.remove(),S.textContent=$.close})})}var e4="/sso";function e1(J,$,Q){let z=new URL(e4,J.endsWith("/")?J:`${J}/`);return z.searchParams.set("realm",$),z.searchParams.set("token",Q),z.toString()}class H0 extends Error{constructor(J="No identity provider is configured, or nobody is signed in"){super(J);this.name="NoIdentityError"}}async function a1(){let J=w();if(!J.identity)throw new H0;let $=await J.identity();if(!$)throw new H0;return e1(J.host,J.realmKey,$)}function t1(J,$){if($==="_self")return window.location.assign(J),!0;let Q=window.open(J,"_blank");if(!Q)return!1;try{Q.opener=null}catch{}return!0}async function J5(J={}){if(J.announce===!1){t1(await a1(),J.target);return}await n1({seconds:J.seconds,prepare:a1,go:($)=>t1($,J.target)})}export{m0 as trimToBudget,m1 as toCurl,e1 as supportPortalUrl,p0 as submitBundle,n as showToast,b4 as setErroredQueriesSource,o4 as requestPath,b as reporterStrings,l as redactUrl,c as redactLabel,i as redactHeaders,o as redactBody,J5 as openSupportPortal,S0 as onLaunch,_0 as onCrash,W2 as moduleResolver,O0 as launch,s4 as isQuietStep,r1 as isFailedRequest,$0 as isConfigured,i4 as installDebugCapture,R4 as hasCause,A0 as getNetworkLog,R0 as getConsoleLog,w as getConfig,q0 as getActionTrail,n4 as formatDuration,f0 as errorSignature,L0 as emitCrash,u0 as defineReporterElement,g0 as createAnnotator,r4 as correlateActionTrail,z2 as configureDebugCapture,x0 as captureScreen,B4 as bundleToMarkdown,w4 as bundleFileName,E0 as buildBundle,f as appInfo,C0 as actionCountSuffix,t as REPORTER_TAG,d as REDACTED,H0 as NoIdentityError,h0 as BUNDLE_BUDGET_BYTES};
217
+ </div>`,z.append(W);let G=(N)=>W.querySelector(N),F=G(".card"),M=G(".bar"),q=G(".count"),C=G("h2"),I=G(".body"),O=G(".host"),D=G(".go"),R=G(".cancel");C.textContent=$.handoffTitle,I.textContent=$.handoffBody;try{O.textContent=new URL(S().host).host}catch{O.textContent=""}D.textContent=$.handoffGo,R.textContent=$.cancel,F.style.setProperty("--secs",`${Q}s`),q.textContent=String(Q),document.body.append(j),requestAnimationFrame(()=>W.setAttribute("data-open","1"));let _=document.activeElement;return D.focus({preventScroll:!0}),new Promise((N)=>{let w=!1,v=null,$0=!1,c=Date.now()+Q*1000,h=window.setInterval(()=>{let B=Math.ceil((c-Date.now())/1000);if(q.textContent=String(Math.max(0,B)),Date.now()>=c)L()},100);function y(B){if(w)return;if(w=!0,window.clearInterval(h),document.removeEventListener("keydown",b,!0),W.removeAttribute("data-open"),window.setTimeout(()=>j.remove(),200),!B)_?.focus?.({preventScroll:!0});N()}function D0(B){window.clearInterval(h),M.classList.remove("spinner"),M.style.animation="none",q.textContent="",C.textContent=$.handoffBlocked,I.textContent=$.handoffBody;let E=document.createElement("a");E.className="go",E.href=B,E.target="_blank",E.rel="noopener noreferrer",E.textContent=$.handoffOpen,E.addEventListener("click",()=>y(!0)),D.replaceWith(E),E.focus({preventScroll:!0})}function L(){if(w||$0)return;if(v)return J.go(v)?y(!0):D0(v);window.clearInterval(h),q.textContent="",M.classList.add("spinner"),C.textContent=$.handoffPreparing}function b(B){if(B.key==="Escape")B.stopPropagation(),y(!1)}document.addEventListener("keydown",b,!0),D.addEventListener("click",L),R.addEventListener("click",()=>y(!1)),W.addEventListener("click",(B)=>{if(B.target===W)y(!1)}),J.prepare().then((B)=>{if(v=B,!w&&Date.now()>=c)L()},()=>{$0=!0,window.clearInterval(h),F.classList.add("error"),M.classList.remove("spinner"),M.style.animation="none",q.textContent="",C.textContent=$.handoffFailed,I.textContent=$.handoffBody,D.remove(),R.textContent=$.close})})}var L6="/sso";function F2(J,$,Q){let j=new URL(L6,J.endsWith("/")?J:`${J}/`);return j.searchParams.set("realm",$),j.searchParams.set("token",Q),j.toString()}class P0 extends Error{constructor(J="No identity provider is configured, or nobody is signed in"){super(J);this.name="NoIdentityError"}}async function G2(){let J=S();if(!J.identity)throw new P0;let $=await J.identity();if(!$)throw new P0;return F2(J.host,J.realmKey,$)}function Y2(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 T6(J={}){if(J.announce===!1){Y2(await G2(),J.target);return}await X2({seconds:J.seconds,prepare:G2,go:($)=>Y2($,J.target)})}export{d0 as trimToBudget,o1 as toCurl,m0 as takeReplay,F2 as supportPortalUrl,l0 as submitBundle,_4 as stopReplay,t as showToast,C6 as setErroredQueriesSource,B6 as requestPath,d as reporterStrings,f as redactUrl,l as redactLabel,o as redactHeaders,r as redactBody,i0 as packReplay,T6 as openSupportPortal,A0 as onLaunch,E0 as onCrash,N2 as moduleResolver,x0 as launch,R4 as isReplayRecording,O6 as isQuietStep,W2 as isFailedRequest,j0 as isConfigured,N6 as installDebugCapture,l4 as hasCause,h0 as getNetworkLog,k0 as getConsoleLog,S as getConfig,L0 as getActionTrail,w6 as formatDuration,p0 as errorSignature,f0 as emitCrash,a0 as defineReporterElement,s0 as createAnnotator,S6 as correlateActionTrail,I2 as configureDebugCapture,b0 as captureScreen,d4 as bundleToMarkdown,i4 as bundleFileName,y0 as buildBundle,m as appInfo,R0 as actionCountSuffix,J0 as REPORTER_TAG,a1 as REPLAY_FILENAME,i as REDACTED,P0 as NoIdentityError,u0 as BUNDLE_BUDGET_BYTES};
@@ -0,0 +1,20 @@
1
+ import type { ReplayCapture, ReplaySummary } from "./types";
2
+ /** The name the desk looks for. Changing it here changes it nowhere else. */
3
+ export declare const REPLAY_FILENAME = "session-replay.json.gz";
4
+ export interface PackedReplay {
5
+ dataUri: string;
6
+ filename: string;
7
+ summary: ReplaySummary;
8
+ }
9
+ /** Is there something to attach, before the work of packing it. */
10
+ export declare function hasReplayEvents(replay: ReplayCapture | null | undefined): replay is ReplayCapture;
11
+ /**
12
+ * Pack, or say why not. Never throws: the report goes on without it.
13
+ *
14
+ * The cap is applied to what is SENT — compressed bytes when compression is
15
+ * available — because that is the number the server's per-file limit is
16
+ * measured against.
17
+ */
18
+ export declare function packReplay(replay: ReplayCapture | null | undefined, maxBytes: number): Promise<PackedReplay | {
19
+ summary: ReplaySummary;
20
+ }>;