@lightworkai.official/debug-capture 0.12.7 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- var N2=((J)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(J,{get:($,Q)=>(typeof require<"u"?require:$)[Q]}):J)(function(J){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+J+'" is not supported')});var w2={maxRequests:60,maxConsoleEntries:120,maxActions:80,maxBodyChars:20000},T=null;function S2(J){let $=[];if(!J.host?.trim())$.push("host");if(!J.realmKey?.trim())$.push("realmKey");if(!J.app?.name?.trim())$.push("app.name");if(typeof J.module!=="function")$.push("module");if($.length)throw Error(`[debug-capture] configureDebugCapture is missing: ${$.join(", ")}. `+"See the README — `module` maps a pathname to the part of your app it belongs to.");T=J}function w(){if(!T)throw Error("[debug-capture] configureDebugCapture() has not been called");return T}function z0(){return T!==null}function m(){let J=w().app;return{name:J.name,version:J.version??"0.0.0",environment:J.environment??O2()}}function O2(){if(typeof window>"u")return"unknown";let J=window.location.hostname;if(J==="localhost"||J==="127.0.0.1"||J.endsWith(".local"))return"development";return"production"}function g(J){let $=T?.capture?.[J];return typeof $==="number"?$:w2[J]}function W1(J){let $=T?.module;if(!$)return null;try{return $(J)??null}catch{return null}}function X0(){let J=T?.redact;return{headers:J?.headers??[],queryKeys:(J?.queryKeys??[]).map(($)=>$.toLowerCase()),bodyKeys:(J?.bodyKeys??[]).map(($)=>$.toLowerCase())}}function Y1(){return T?.capture?.overlaySelectors??[]}var R2='[contenteditable]:not([contenteditable="false"]), [data-lw-mask]',_2="[data-lw-mask]",K1={fps:1,quality:0.5};function Z0(){let J=T?.replay;if(!J)return null;let $=J===!0?{}:J,Q=(K,W)=>typeof K==="number"&&K>0?K:W,j=$.maskInputs!==!1,z=$.recordCanvas?{fps:Q(typeof $.recordCanvas==="object"?$.recordCanvas.fps:void 0,K1.fps),quality:Q(typeof $.recordCanvas==="object"?$.recordCanvas.quality:void 0,K1.quality)}:null;return{seconds:Q($.seconds,60),maskInputs:j,maskTextSelector:$.maskTextSelector?.trim()||(j?R2:_2),maskText:$.maskText===!0,blockSelector:$.blockSelector?.trim()||"[data-lw-private]",maxBytes:Q($.maxBytes,4000000),canvas:z}}function G1(J){if(typeof window>"u")return!1;let $;try{$=new URL(J,window.location.href)}catch{return!1}if(L2($))return!1;if($.origin===window.location.origin)return!0;return(T?.capture?.bodyOrigins??[]).some((Q)=>{try{return new URL(Q).origin===$.origin}catch{return!1}})}function L2(J){if(!T?.host)return!1;try{if(new URL(T.host).origin!==J.origin)return!1}catch{return!1}return J.pathname.startsWith("/ingest/")}function k2(J){let $=Object.entries(J).map(([Q,j])=>[Q.replace(/\/+$/,"")||"/",j]).sort((Q,j)=>j[0].length-Q[0].length);return(Q)=>{let j=(Q||"/").replace(/\/+$/,"")||"/";for(let[z,K]of $)if(j===z||j.startsWith(`${z}/`))return{key:z,label:K};return null}}var l="‹redacted›",T2=/^(authorization|proxy-authorization|cookie|set-cookie|x-[a-z-]*token|x-csrf[a-z-]*|x-xsrf[a-z-]*)$/i,A2=new Set(["access_token","token","id_token","refresh_token","code","secret","client_secret","password","apikey","api_key","signature","x-amz-signature","x-amz-credential"]),x2=/(password|passwd|token|secret|authorization|refresh|client_secret|otp|pin)/i,f2=/[\w.+-]+@[\w-]+\.[\w.-]+/g,E2=/\d(?:[\d\s-]{7,})\d/g;function o(J){return J.replace(f2,l).replace(E2,l)}function h2(J){if(T2.test(J))return!0;return X0().headers.some((Q)=>Q.toLowerCase()===J.toLowerCase())}function r(J){let $={};for(let[Q,j]of Object.entries(J))$[Q]=h2(Q)?l:j;return $}function E(J){try{let $=/^https?:\/\//i.test(J),Q=new URL(J,$?void 0:"http://local.invalid"),j=!1;if(Q.searchParams.forEach((z,K)=>{if(A2.has(K.toLowerCase())||X0().queryKeys.includes(K.toLowerCase()))Q.searchParams.set(K,l),j=!0}),!j)return J;return $?Q.toString():`${Q.pathname}${Q.search}`}catch{return J}}function w0(J,$){if($>6||J===null||typeof J!=="object")return J;if(Array.isArray(J))return J.map((j)=>w0(j,$+1));let Q={};for(let[j,z]of Object.entries(J)){let K=x2.test(j)||X0().bodyKeys.some((W)=>j.toLowerCase().includes(W));Q[j]=K?l:w0(z,$+1)}return Q}function s(J,$){if(J==null)return null;let Q=J,j=J.trim();if(j.startsWith("{")||j.startsWith("["))try{let z=JSON.parse(j);Q=JSON.stringify(w0(z,0))}catch{}if(Q.length>$)return`${Q.slice(0,$)}… [truncated ${Q.length-$} chars]`;return Q}var S0=120,O0=40,a=(J,$)=>J.length>$?`${J.slice(0,$)}…`:J,R0=(J)=>{try{return decodeURIComponent(J)}catch{return J}},n=[],V1=0,X1=!1;function K0(J,$,Q,j){let z=a($,S0),K=n[n.length-1];if(J==="navigate"&&K?.kind==="click"){let G=z.replace(/^ไปที่\s*/,"");if(K.detail.includes(`→ ${G}`))return K.at=new Date().toISOString(),K;let F=G.split(/[?#]/)[0]??G,P=K.source?R0(K.source.replace(/^→\s*/,"")).split(/[?#]/)[0]:null;if(P&&(F===P||F.startsWith(P)))return K.detail=a(`${K.detail} → ${G}`,S0),K.source=void 0,K.at=new Date().toISOString(),K}if(K&&K.kind===J&&K.detail===z){if(K.at=new Date().toISOString(),J!=="navigate")K.count=(K.count??1)+1;return K}V1+=1;let W={id:`act_${V1}`,at:new Date().toISOString(),kind:J,detail:z,count:1,source:Q,html:H0(j)};n.push(W);while(n.length>g("maxActions"))g2(n.shift());return W}var m2=200000,W0=0;function H0(J){if(!J)return;if(W0+J.length>m2)return;return W0+=J.length,J}function g2(J){if(!J)return;if(W0-=(J.html?.length??0)+(J.afterHtml?.length??0),W0<0)W0=0}function _0(J){return J&&J>1?` (×${J})`:""}function F0(J){return J instanceof Element&&Boolean(J.closest("[data-debug-reporter]"))}var y2='button, a[href], [role="button"], [role="tab"], [role="menuitem"], [role="option"], [role="switch"], [role="checkbox"], [role="radio"], [role="link"], summary, input, select, textarea',b2={button:"ปุ่ม",a:"ลิงก์",input:"ช่อง",textarea:"ช่อง",select:"ตัวเลือก",summary:"ส่วนขยาย"},F1={button:"ปุ่ม",tab:"แท็บ",menuitem:"เมนู",option:"ตัวเลือก",switch:"สวิตช์",checkbox:"ช่องเลือก",radio:"ตัวเลือก",link:"ลิงก์"};function v2(J){let $=J.getAttribute("role");if($&&F1[$])return F1[$];return b2[J.tagName.toLowerCase()]??"ปุ่ม"}function p2(J,$){try{let Q=J,j=0;while(Q&&j<=$){let z=I1(Q);if(z&&typeof z.memoizedProps?.onClick==="function")return Q;Q=Q.parentElement,j+=1}}catch{}return null}function u2(J){let $=J.getAttribute("aria-label")?.trim();if($)return $;let Q=J.getAttribute("title")?.trim();if(Q)return Q;if(J instanceof HTMLInputElement||J instanceof HTMLTextAreaElement||J instanceof HTMLSelectElement)return(J.getAttribute("placeholder")||J.getAttribute("name")||"").trim();if(J instanceof HTMLImageElement)return(J.getAttribute("alt")||"").trim();let j=(J.textContent??"").replace(/\s+/g," ").trim();if(j)return j;if(J instanceof HTMLAnchorElement){let z=J.getAttribute("href");if(z?.startsWith("/"))return R0(z)}return""}function d2(J){if(!(J instanceof Element))return null;let $=J.closest(y2)??p2(J,4);if(!$)return null;let Q=$.tagName.toLowerCase();if(Q==="html"||Q==="body")return null;return $}function c2(J){let $=o(u2(J));if(!$)return null;return`${v2(J)} “${a($,O0)}”`}var C1=6000,i2=4000,l2=/(?:^|\s)!?(?:fixed|absolute|sticky|inset-\S+|z-\S+|top-\S+|bottom-\S+|left-\S+|right-\S+|w-screen|h-screen|min-h-screen|max-h-screen|translate-\S+|scale-\S+)(?=\s|$)/g;function o2(J){J.querySelectorAll("script, style, link, iframe, object, embed, noscript, canvas, video, audio").forEach((z)=>z.remove());let $=[J,...Array.from(J.querySelectorAll("*"))];for(let z of $){for(let W of Array.from(z.attributes)){let G=W.name.toLowerCase();if(G.startsWith("on")||G==="srcdoc"||G==="value"||G.startsWith("data-"))z.removeAttribute(W.name)}if(z instanceof HTMLAnchorElement)z.setAttribute("href","#");if(z instanceof HTMLImageElement)z.removeAttribute("src");let K=z.getAttribute("class");if(K){let W=K.replace(l2," ").replace(/\s+/g," ").trim();if(W)z.setAttribute("class",W);else z.removeAttribute("class")}}let Q=document.createTreeWalker(J,NodeFilter.SHOW_TEXT),j=Q.nextNode();while(j){if(j.nodeValue)j.nodeValue=o(j.nodeValue);j=Q.nextNode()}}function L0(J,$,Q){try{let j=J.outerHTML;if(!j||j.length>$)return;let z=J.cloneNode(!0);o2(z);let K=z.outerHTML;return K&&K.length<=Q?K:void 0}catch{return}}var r2=(J)=>L0(J,C1,i2),s2=150000,n2=40000,H1=(J)=>L0(J,s2,n2);function a2(J){if(!(J instanceof HTMLInputElement)&&!(J instanceof HTMLTextAreaElement)&&!(J instanceof HTMLSelectElement))return null;let $=J.name||J.id||J.getAttribute("aria-label")||J.getAttribute("placeholder")||J.tagName.toLowerCase();return`ช่อง “${o($)}”`}var U1=80;function I1(J){let $=Object.keys(J).find((Q)=>Q.startsWith("__reactFiber$")||Q.startsWith("__reactInternalInstance$"));return $?J[$]:null}function t2(J){if(typeof J!=="function")return null;try{let $=Function.prototype.toString.call(J);return($.match(/\.(?:push|replace)\(\s*['"`]([^'"`]+)['"`]/)??$.match(/redirect\(\s*['"`]([^'"`]+)['"`]/))?.[1]??null}catch{return null}}function P1(J){if(!J)return;return`→ ${J.length>U1?`${J.slice(0,U1)}…`:J}`}function e2(J){try{let $=J.closest("a[href]")?.getAttribute("href");if($&&$.startsWith("/"))return P1($);let Q=I1(J),j=0;while(Q&&j<30){if(typeof Q.memoizedProps?.onClick==="function")return P1(t2(Q.memoizedProps.onClick));Q=Q.return,j+=1}return}catch{return}}var J4='[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], [role="status"], [role="alert"]';function $4(){let J=Y1();return J.length?J.join(", "):J4}function Q4(J){let $=J.getAttribute("role");if($==="status"||$==="alert")return"ข้อความแจ้งเตือน";if($==="menu")return"เมนู";if($==="listbox")return"รายการตัวเลือก";if($==="alertdialog")return"กล่องยืนยัน";return"กล่องโต้ตอบ"}function j4(J){let $=J.getAttribute("aria-label")?.trim();if($)return $;let Q=J.getAttribute("aria-labelledby");if(Q){let K=Q.split(/\s+/).map((W)=>document.getElementById(W)?.textContent?.trim()??"").filter(Boolean).join(" ");if(K)return K}let z=J.querySelector('[data-slot="dialog-title"], h1, h2, h3, [role="heading"]')?.textContent?.replace(/\s+/g," ").trim();if(z)return z;return(J.textContent??"").replace(/\s+/g," ").trim()}function D1(J){let $=o(j4(J)),Q=Q4(J);return $?`เปิด ${Q} “${a($,O0)}”`:`เปิด ${Q}`}var z4='[aria-busy="true"], [role="progressbar"], [data-loading="true"], .animate-pulse, .animate-spin',Z4=/กำลังโหลด|กำลังค้นหา|กำลังดำเนินการ|\bloading\b/i;function K4(J){if(J.querySelector(z4))return!0;return Z4.test(J.textContent??"")}var W4=400,Y4=250,G4=8000;function V4(J,$){if(typeof MutationObserver>"u"){$.html=H0(H1(J));return}let Q=Date.now(),j=!1,z=()=>{j=!0,W.disconnect(),window.clearInterval(G),window.clearTimeout(F)},K=()=>{if(j)return;if(z(),!J.isConnected)return;$.detail=a(D1(J),S0),$.html=H0(H1(J))},W=new MutationObserver(()=>{Q=Date.now()});W.observe(J,{childList:!0,subtree:!0,attributes:!0,characterData:!0});let G=window.setInterval(()=>{if(j)return;if(!J.isConnected){z();return}if(Date.now()-Q>=W4&&!K4(J))K()},Y4),F=window.setTimeout(K,G4)}function X4(J){if(F0(J))return;let $=K0("ui",D1(J));if($)V4(J,$)}function F4(){if(typeof MutationObserver>"u")return;let J=new WeakSet;new MutationObserver((Q)=>{for(let j of Q)for(let z of Array.from(j.addedNodes)){if(!(z instanceof Element))continue;let K=$4(),W=z.matches(K)?[z]:Array.from(z.querySelectorAll(K));for(let G of W){if(J.has(G))continue;J.add(G),X4(G)}}}).observe(document.body,{childList:!0,subtree:!0})}var H4=1600,U4=2500;function M1(J){return{disabled:J.hasAttribute("disabled")||J.getAttribute("aria-disabled")==="true",busy:J.getAttribute("aria-busy")==="true",text:a((J.textContent??"").replace(/\s+/g," ").trim(),O0)}}function P4(J,$){if(!J.disabled&&$.disabled)return"ปุ่มถูกปิดใช้งานหลังคลิก";if(!J.busy&&$.busy)return"ปุ่มเข้าสู่สถานะกำลังโหลด";if(J.text!==$.text&&$.text)return`ข้อความเปลี่ยนเป็น “${$.text}”`;return null}function M4(J,$){if(typeof MutationObserver>"u")return;let Q=M1(J),j=!1,z=(G,F)=>{if(j)return;if(j=!0,K.disconnect(),window.clearTimeout(W),$.afterNote=G,F)$.afterHtml=H0(L0(J,C1,U4))},K=new MutationObserver(()=>{if(!J.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}let G=P4(Q,M1(J));if(G)z(G,!0)});K.observe(J,{attributes:!0,attributeFilter:["disabled","aria-disabled","aria-busy","class"],childList:!0,subtree:!0,characterData:!0});let W=window.setTimeout(()=>{if(!j&&!J.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}j=!0,K.disconnect()},H4)}function q1(){if(X1||typeof window>"u")return;X1=!0,document.addEventListener("click",(j)=>{if(F0(j.target))return;let z=d2(j.target);if(!z)return;let K=c2(z);if(!K)return;let W=K0("click",`คลิก ${K}`,e2(z),r2(z));if(W)M4(z,W)},{capture:!0,passive:!0}),document.addEventListener("change",(j)=>{if(F0(j.target))return;let z=a2(j.target);if(z)K0("input",`แก้ไข ${z}`)},{capture:!0,passive:!0}),document.addEventListener("submit",(j)=>{if(F0(j.target))return;K0("submit","ส่งฟอร์ม")},{capture:!0,passive:!0});let J=()=>K0("navigate",`ไปที่ ${R0(E(location.pathname+location.search))}`),$=history.pushState.bind(history),Q=history.replaceState.bind(history);history.pushState=(...j)=>{let z=$(...j);return J(),z},history.replaceState=(...j)=>{let z=Q(...j);return J(),z},window.addEventListener("popstate",J),F4()}function k0(){return n.map((J)=>({...J}))}var B1=2000,U0=[],N1=0,w1=!1;function T0(J,$){N1+=1,U0.push({id:`log_${N1}`,at:new Date().toISOString(),level:J,message:$.length>B1?`${$.slice(0,B1)}…`:$});while(U0.length>g("maxConsoleEntries"))U0.shift()}function C4(){let J=new WeakSet;return($,Q)=>{if(typeof Q==="object"&&Q!==null){if(J.has(Q))return"[Circular]";J.add(Q)}if(typeof Q==="bigint")return Q.toString();return Q}}function S1(J){if(typeof J==="string")return J;if(J instanceof Error)return`${J.name}: ${J.message}`;try{let $=JSON.stringify(J,C4());if($!==void 0)return $}catch{}try{return String(J)}catch{}try{return Object.prototype.toString.call(J)}catch{return`[${typeof J}]`}}function O1(){if(w1||typeof window>"u")return;w1=!0;let J=["log","info","warn","error","debug"];for(let $ of J){let Q=console[$].bind(console);console[$]=(...j)=>{T0($,j.map(S1).join(" ")),Q(...j)}}window.addEventListener("error",($)=>{let Q=$.filename?` (${$.filename}:${$.lineno}:${$.colno})`:"";T0("exception",`${$.message}${Q}`)}),window.addEventListener("unhandledrejection",($)=>{let Q=$.reason instanceof Error?`${$.reason.name}: ${$.reason.message}`:S1($.reason);T0("unhandledrejection",Q)})}function A0(){return U0.map((J)=>({...J}))}var R1=new Set,_1=new Set;function L1(J,$){return J.add($),()=>J.delete($)}function k1(J,$){for(let Q of[...J])Q($)}function x0(J){return L1(R1,J)}function f0(J={type:"manual"}){k1(R1,J)}function E0(J){return L1(_1,J)}function h0(J){k1(_1,J)}var I4=15000,D4=["ResizeObserver loop","Script error.","Non-Error promise rejection captured"],T1=!1,A1=0;function q4(J){return D4.some(($)=>J.includes($))}function x1(J){let $=J.message??"";if(!$||q4($))return;let Q=Date.now();if(Q-A1<I4)return;A1=Q,h0({...J,message:$})}function f1(){if(T1||typeof window>"u")return;T1=!0,window.addEventListener("error",(J)=>{if(!J.message&&!J.error)return;let $=J.error instanceof Error?J.error:null;x1({type:"runtime-error",message:J.message||($?$.message:"Unknown error"),stack:$?.stack})}),window.addEventListener("unhandledrejection",(J)=>{let $=J.reason;x1({type:"unhandledrejection",message:$ instanceof Error?$.message:String($),stack:$ instanceof Error?$.stack:void 0})})}var g1=4000,B4=1e6,N4=1e7,P0=[],E1=0,h1=!1;function y1(J){P0.push(J);while(P0.length>g("maxRequests"))P0.shift()}function b1(){return E1+=1,`req_${E1}`}function m1(J){let $={};if(!J)return $;if(J instanceof Headers)J.forEach((Q,j)=>{$[j]=Q});else if(Array.isArray(J))for(let[Q,j]of J)$[Q]=j;else Object.assign($,J);return $}function w4(J){let $={};return J.forEach((Q,j)=>{$[j]=Q}),$}function S4(J){if(J==null)return null;if(typeof J==="string")return J;if(J instanceof URLSearchParams)return J.toString();if(typeof FormData<"u"&&J instanceof FormData)return`[FormData: ${Array.from(J.keys()).join(", ")}]`;if(typeof Blob<"u"&&J instanceof Blob)return`[Blob ${J.size} bytes]`;if(J instanceof ArrayBuffer)return`[ArrayBuffer ${J.byteLength} bytes]`;return"[binary]"}function O4(J,$){let Q="",j="GET",z={},K=null;if(typeof J==="string")Q=J;else if(J instanceof URL)Q=J.toString();else Q=J.url,j=J.method||j,z=m1(J.headers);if($){if($.method)j=$.method;if($.headers)z={...z,...m1($.headers)};if($.body!==void 0)K=S4($.body)}return{method:j.toUpperCase(),url:Q,headers:z,body:K}}function v1(J){return!G1(J)}function R4(J,$){if(v1($.url)){$.responseSnippet="[body not captured for this origin]";return}let Q=J.headers.get("content-type")??"",j=Number(J.headers.get("content-length")??"0"),z=j?`, ~${j} bytes`:"";if(!/json|text|xml|html|javascript|urlencoded/i.test(Q)){$.responseSnippet=`[binary ${Q||"unknown"}${z}]`;return}if(j>B4){$.responseSnippet=`[response ${Q||"text"}${z} — omitted]`;return}try{J.clone().text().then((K)=>{$.responseSnippet=s(K,g("maxBodyChars"))}).catch(()=>{})}catch{}}function p1(J,$){if(/[?&]_rsc=/.test(J))return!0;for(let Q of Object.keys($)){let j=Q.toLowerCase();if(j==="rsc"||j==="next-router-prefetch"||j==="next-router-state-tree")return!0}return!1}function _4(){if(typeof window>"u"||typeof window.fetch!=="function")return;let J=window.fetch.bind(window);window.fetch=Object.assign(async($,Q)=>{let j=O4($,Q);if(p1(j.url,j.headers))return J($,Q);let z={id:b1(),startedAt:new Date().toISOString(),method:j.method,url:E(j.url),requestHeaders:r(j.headers),requestBody:s(j.body,g1),status:null,statusText:null,durationMs:null,via:"fetch"};y1(z);let K=performance.now();try{let W=await J($,Q);return z.status=W.status,z.statusText=W.statusText,z.durationMs=Math.round(performance.now()-K),z.responseHeaders=r(w4(W.headers)),R4(W,z),W}catch(W){throw z.durationMs=Math.round(performance.now()-K),z.error=W instanceof Error?`${W.name}: ${W.message}`:String(W),W}},J)}function L4(){if(typeof window>"u"||typeof window.XMLHttpRequest!=="function")return;let J=XMLHttpRequest.prototype,$=J.open,Q=J.send,j=function(K,W){let G=typeof W==="string"?W:W.toString();return this.__lwEntry=p1(G,{})?void 0:{id:b1(),startedAt:"",method:(K||"GET").toUpperCase(),url:E(G),requestHeaders:{},requestBody:null,status:null,statusText:null,durationMs:null,via:"xhr"},$.apply(this,arguments)},z=function(K){let W=this.__lwEntry;if(W){W.startedAt=new Date().toISOString(),W.requestBody=typeof K==="string"?s(K,g1):K==null?null:"[non-string body]";let G=performance.now();y1(W),this.addEventListener("loadend",()=>{if(W.status=this.status||null,W.statusText=this.statusText||null,W.durationMs=Math.round(performance.now()-G),v1(W.url))W.responseSnippet="[body not captured for this origin]";else if(this.responseType===""||this.responseType==="text")try{W.responseSnippet=s(this.responseText||"",g("maxBodyChars"))}catch{}else{let F=this.getResponseHeader("content-type")??this.responseType;W.responseSnippet=`[binary ${F}]`}})}return Q.apply(this,arguments)};J.open=j,J.send=z}function u1(){if(h1)return;h1=!0,_4(),L4()}function m0(){let J=P0.map((Q)=>({...Q})),$=0;for(let Q=J.length-1;Q>=0;Q-=1){let j=J[Q],z=j?.responseSnippet;if(!j||typeof z!=="string"||z.length===0)continue;if($+z.length>N4)j.responseSnippet=`[response omitted — report size budget reached (${z.length.toLocaleString()} chars)]`;else $+=z.length}return J}var k4=4,d1=3,T4=4000,A4="[data-debug-reporter]",x4=()=>import("@rrweb/record");var A=[],t=null,M0=!1;function c1(){if(typeof window>"u"||t||M0)return;let J=Z0();if(!J)return;M0=!0;let $=()=>void f4(J);if("requestIdleCallback"in window)window.requestIdleCallback($,{timeout:3000});else setTimeout($,1000)}async function f4(J){let $;try{$=(await x4()).record}catch(Q){M0=!1,console.warn("[debug-capture] session replay could not start:",Q);return}if(t)return;try{t=$({emit:(Q)=>E4(Q),checkoutEveryNms:Math.max(1000,J.seconds*1000/2),checkoutEveryNth:T4,maskAllInputs:J.maskInputs,maskTextSelector:J.maskText?"*":J.maskTextSelector,blockSelector:`${J.blockSelector}, ${A4}`,slimDOMOptions:"all",inlineStylesheet:!0,sampling:{mousemove:50,scroll:150,media:800,input:"last",...J.canvas?{canvas:J.canvas.fps}:{}},recordCanvas:J.canvas!==null,...J.canvas?{dataURLOptions:{type:"image/webp",quality:J.canvas.quality}}:{},errorHandler:()=>!0})??null}catch(Q){console.warn("[debug-capture] session replay could not start:",Q)}finally{M0=!1}}function E4(J){if(J.type===k4||A.length===0){if(A.push([]),A.length>d1)A=A.slice(-d1)}A[A.length-1].push(J)}function g0(J=Date.now()){let $=Z0();if(!$||!A.length)return null;let Q=J-$.seconds*1000,j=A.length-1;while(j>0&&(A[j][0]?.timestamp??J)>Q)j-=1;let z=A.slice(j).flat(),K=z[0]?.timestamp,W=z[z.length-1]?.timestamp;if(K===void 0||W===void 0)return null;return{events:z,startedAt:new Date(K).toISOString(),endedAt:new Date(W).toISOString(),durationMs:Math.max(0,W-K)}}function h4(){return t!==null}function m4(){t?.(),t=null,A=[]}var g4={title:"รายงานปัญหา",summaryLabel:"หัวข้อปัญหา",summaryRequired:"(ต้องกรอกก่อนแจ้งปัญหา)",summaryPlaceholder:"สรุปปัญหาสั้น ๆ เช่น กดบันทึกร่างแล้ว error",detailLabel:"อธิบายปัญหา (ไม่บังคับ)",detailPlaceholder:"เกิดอะไรขึ้น? กำลังทำอะไรอยู่ตอนที่พบปัญหา?",annotateTitle:"วาดบนรูป",annotateHint:"ทำเครื่องหมายจุดที่มีปัญหาก่อนแนบ — วงกรอบ ชี้ลูกศร ไฮไลต์ หรือพิมพ์ข้อความ",annotateApply:"ใช้รูปนี้",cancel:"ยกเลิก",toolRect:"กรอบ",toolArrow:"ลูกศร",toolHighlight:"ไฮไลต์",toolText:"ข้อความ",deleteSelected:"ลบที่เลือก",clearAll:"ล้างทั้งหมด",annotateHelp:"เลือกเครื่องมือแล้วลากบนรูป · ไม่ได้เลือกเครื่องมือ = ย้าย/ปรับขนาดสิ่งที่วาดไว้ · กดกากบาทมุมขวาบนของรูปทรงเพื่อลบ",capturing:"กำลังเก็บภาพหน้าจอ…",noScreenshot:"ไม่มีภาพหน้าจอ — ยังส่งรายงานได้",cancelled:"ยกเลิกการเก็บภาพหน้าจอแล้ว",close:"ปิด",submit:"แจ้งปัญหา",submitting:"กำลังส่ง…",submitted:"แจ้งปัญหาสำเร็จ",crashed:"เกิดข้อผิดพลาดในระบบ",crashAction:"แจ้งปัญหา",failed:"ส่งรายงานไม่สำเร็จ",failedOffline:"ส่งไม่สำเร็จ — เชื่อมต่อเซิร์ฟเวอร์ไม่ได้ ข้อความที่พิมพ์ไว้ยังอยู่ ตรวจสอบอินเทอร์เน็ตแล้วลองใหม่",failedUnavailable:"ส่งไม่สำเร็จ — ระบบกำลังปรับปรุงชั่วคราว ข้อความที่พิมพ์ไว้ยังอยู่ ลองใหม่ในอีกสักครู่",failedTooMany:"แจ้งปัญหาถี่เกินไป — ลองใหม่ในอีก {seconds} วินาที",captured:"เก็บข้อมูลแล้ว",reporter:"ผู้แจ้ง",page:"หน้า",replay:"บันทึกการใช้งาน",handoffTitle:"กำลังพาไปที่ระบบแจ้งปัญหา",handoffBody:"ระบบจะลงชื่อเข้าใช้ให้อัตโนมัติ เพื่อดูเรื่องที่คุณแจ้งไว้",handoffGo:"ไปเลย",handoffPreparing:"กำลังเตรียม…",handoffFailed:"เปิดรายการที่แจ้งไว้ไม่สำเร็จ",handoffBlocked:"เบราว์เซอร์บล็อกการเปิดแท็บใหม่",handoffOpen:"เปิดในแท็บใหม่"},y4={title:"Report a problem",summaryLabel:"Summary",summaryRequired:"(required)",summaryPlaceholder:"One line, e.g. saving a draft returns an error",detailLabel:"Details (optional)",detailPlaceholder:"What happened? What were you doing at the time?",annotateTitle:"Draw on the image",annotateHint:"Mark what went wrong before attaching — box it, point at it, highlight it, or type on it",annotateApply:"Use this image",cancel:"Cancel",toolRect:"Box",toolArrow:"Arrow",toolHighlight:"Highlight",toolText:"Text",deleteSelected:"Delete selected",clearAll:"Clear all",annotateHelp:"Pick a tool and drag on the image · no tool selected = move/resize what you drew · press the ✕ on a shape to delete it",capturing:"Capturing the screen…",noScreenshot:"No screenshot — you can still send the report",cancelled:"Screen capture cancelled",close:"Close",submit:"Send report",submitting:"Sending…",submitted:"Report sent",crashed:"Something went wrong",crashAction:"Report it",failed:"Could not send the report",failedOffline:"Could not send — the server could not be reached. What you wrote is still here; check your connection and try again.",failedUnavailable:"Could not send — the system is being updated. What you wrote is still here; try again in a moment.",failedTooMany:"Too many reports — try again in {seconds} seconds.",captured:"Captured",reporter:"Reporter",page:"Page",replay:"activity log",handoffTitle:"Opening the support portal",handoffBody:"You will be signed in automatically to see what you reported",handoffGo:"Go now",handoffPreparing:"Preparing…",handoffFailed:"Could not open your reports",handoffBlocked:"Your browser blocked the new tab",handoffOpen:"Open in a new tab"};function d(J){return J==="en"?y4:g4}var b4="lw-debug-toasts",v4=6000,p4=`
1
+ var k2=((J)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(J,{get:($,z)=>(typeof require<"u"?require:$)[z]}):J)(function(J){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+J+'" is not supported')});var f2={maxRequests:60,maxConsoleEntries:120,maxActions:80,maxBodyChars:20000},x=null;function E2(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.");x=J}function w(){if(!x)throw Error("[debug-capture] configureDebugCapture() has not been called");return x}function K0(){return x!==null}function m(){let J=w().app;return{name:J.name,version:J.version??"0.0.0",environment:J.environment??h2()}}function h2(){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 v(J){let $=x?.capture?.[J];return typeof $==="number"?$:f2[J]}function U0(J){let $=x?.module;if(!$)return null;try{return $(J)??null}catch{return null}}function P0(){let J=x?.redact;return{headers:J?.headers??[],queryKeys:(J?.queryKeys??[]).map(($)=>$.toLowerCase()),bodyKeys:(J?.bodyKeys??[]).map(($)=>$.toLowerCase())}}function P1(){return x?.capture?.overlaySelectors??[]}var m2='[contenteditable]:not([contenteditable="false"]), [data-lw-mask]',g2="[data-lw-mask]",U1={fps:1,quality:0.5};function W0(){let J=x?.replay;if(!J)return null;let $=J===!0?{}:J,z=(Z,W)=>typeof Z==="number"&&Z>0?Z:W,Q=$.maskInputs!==!1,j=$.recordCanvas?{fps:z(typeof $.recordCanvas==="object"?$.recordCanvas.fps:void 0,U1.fps),quality:z(typeof $.recordCanvas==="object"?$.recordCanvas.quality:void 0,U1.quality)}:null;return{seconds:z($.seconds,60),maskInputs:Q,maskTextSelector:$.maskTextSelector?.trim()||(Q?m2:g2),maskText:$.maskText===!0,blockSelector:$.blockSelector?.trim()||"[data-lw-private]",maxBytes:z($.maxBytes,4000000),canvas:j}}function M1(J){if(typeof window>"u")return!1;let $;try{$=new URL(J,window.location.href)}catch{return!1}if(b2($))return!1;if($.origin===window.location.origin)return!0;return(x?.capture?.bodyOrigins??[]).some((z)=>{try{return new URL(z).origin===$.origin}catch{return!1}})}function b2(J){if(!x?.host)return!1;try{if(new URL(x.host).origin!==J.origin)return!1}catch{return!1}return J.pathname.startsWith("/ingest/")}function y2(J){let $=Object.entries(J).map(([z,Q])=>[z.replace(/\/+$/,"")||"/",Q]).sort((z,Q)=>Q[0].length-z[0].length);return(z)=>{let Q=(z||"/").replace(/\/+$/,"")||"/";for(let[j,Z]of $)if(Q===j||Q.startsWith(`${j}/`))return{key:j,label:Z};return null}}var r="‹redacted›",v2=/^(authorization|proxy-authorization|cookie|set-cookie|x-[a-z-]*token|x-csrf[a-z-]*|x-xsrf[a-z-]*)$/i,p2=new Set(["access_token","token","id_token","refresh_token","code","secret","client_secret","password","apikey","api_key","signature","x-amz-signature","x-amz-credential"]),u2=/(password|passwd|token|secret|authorization|refresh|client_secret|otp|pin)/i,d2=/[\w.+-]+@[\w-]+\.[\w.-]+/g,c2=/\d(?:[\d\s-]{7,})\d/g;function n(J){return J.replace(d2,r).replace(c2,r)}function i2(J){if(v2.test(J))return!0;return P0().headers.some((z)=>z.toLowerCase()===J.toLowerCase())}function s(J){let $={};for(let[z,Q]of Object.entries(J))$[z]=i2(z)?r:Q;return $}function g(J){try{let $=/^https?:\/\//i.test(J),z=new URL(J,$?void 0:"http://local.invalid"),Q=!1;if(z.searchParams.forEach((j,Z)=>{if(p2.has(Z.toLowerCase())||P0().queryKeys.includes(Z.toLowerCase()))z.searchParams.set(Z,r),Q=!0}),!Q)return J;return $?z.toString():`${z.pathname}${z.search}`}catch{return J}}function L0(J,$){if($>6||J===null||typeof J!=="object")return J;if(Array.isArray(J))return J.map((Q)=>L0(Q,$+1));let z={};for(let[Q,j]of Object.entries(J)){let Z=u2.test(Q)||P0().bodyKeys.some((W)=>Q.toLowerCase().includes(W));z[Q]=Z?r:L0(j,$+1)}return z}function a(J,$){if(J==null)return null;let z=J,Q=J.trim();if(Q.startsWith("{")||Q.startsWith("["))try{let j=JSON.parse(Q);z=JSON.stringify(L0(j,0))}catch{}if(z.length>$)return`${z.slice(0,$)}… [truncated ${z.length-$} chars]`;return z}var A0=120,x0=40,e=(J,$)=>J.length>$?`${J.slice(0,$)}…`:J,T0=(J)=>{try{return decodeURIComponent(J)}catch{return J}},t=[],D1=0,I1=!1;function Y0(J,$,z,Q){let j=e($,A0),Z=t[t.length-1];if(J==="navigate"&&Z?.kind==="click"){let G=j.replace(/^ไปที่\s*/,"");if(Z.detail.includes(`→ ${G}`))return Z.at=new Date().toISOString(),Z;let F=G.split(/[?#]/)[0]??G,P=Z.source?T0(Z.source.replace(/^→\s*/,"")).split(/[?#]/)[0]:null;if(P&&(F===P||F.startsWith(P)))return Z.detail=e(`${Z.detail} → ${G}`,A0),Z.source=void 0,Z.at=new Date().toISOString(),Z}if(Z&&Z.kind===J&&Z.detail===j){if(Z.at=new Date().toISOString(),J!=="navigate")Z.count=(Z.count??1)+1;return Z}D1+=1;let W={id:`act_${D1}`,at:new Date().toISOString(),kind:J,detail:j,count:1,source:z,html:D0(Q)};t.push(W);while(t.length>v("maxActions"))o2(t.shift());return W}var l2=200000,G0=0;function D0(J){if(!J)return;if(G0+J.length>l2)return;return G0+=J.length,J}function o2(J){if(!J)return;if(G0-=(J.html?.length??0)+(J.afterHtml?.length??0),G0<0)G0=0}function k0(J){return J&&J>1?` (×${J})`:""}function M0(J){return J instanceof Element&&Boolean(J.closest("[data-debug-reporter]"))}var r2='button, a[href], [role="button"], [role="tab"], [role="menuitem"], [role="option"], [role="switch"], [role="checkbox"], [role="radio"], [role="link"], summary, input, select, textarea',n2={button:"ปุ่ม",a:"ลิงก์",input:"ช่อง",textarea:"ช่อง",select:"ตัวเลือก",summary:"ส่วนขยาย"},C1={button:"ปุ่ม",tab:"แท็บ",menuitem:"เมนู",option:"ตัวเลือก",switch:"สวิตช์",checkbox:"ช่องเลือก",radio:"ตัวเลือก",link:"ลิงก์"};function s2(J){let $=J.getAttribute("role");if($&&C1[$])return C1[$];return n2[J.tagName.toLowerCase()]??"ปุ่ม"}function a2(J,$){try{let z=J,Q=0;while(z&&Q<=$){let j=O1(z);if(j&&typeof j.memoizedProps?.onClick==="function")return z;z=z.parentElement,Q+=1}}catch{}return null}function t2(J){let $=J.getAttribute("aria-label")?.trim();if($)return $;let z=J.getAttribute("title")?.trim();if(z)return z;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 Q=(J.textContent??"").replace(/\s+/g," ").trim();if(Q)return Q;if(J instanceof HTMLAnchorElement){let j=J.getAttribute("href");if(j?.startsWith("/"))return T0(j)}return""}function e2(J){if(!(J instanceof Element))return null;let $=J.closest(r2)??a2(J,4);if(!$)return null;let z=$.tagName.toLowerCase();if(z==="html"||z==="body")return null;return $}function J4(J){let $=n(t2(J));if(!$)return null;return`${s2(J)} “${e($,x0)}”`}var S1=6000,$4=4000,z4=/(?:^|\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 Q4(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 W of Array.from(j.attributes)){let G=W.name.toLowerCase();if(G.startsWith("on")||G==="srcdoc"||G==="value"||G.startsWith("data-"))j.removeAttribute(W.name)}if(j instanceof HTMLAnchorElement)j.setAttribute("href","#");if(j instanceof HTMLImageElement)j.removeAttribute("src");let Z=j.getAttribute("class");if(Z){let W=Z.replace(z4," ").replace(/\s+/g," ").trim();if(W)j.setAttribute("class",W);else j.removeAttribute("class")}}let z=document.createTreeWalker(J,NodeFilter.SHOW_TEXT),Q=z.nextNode();while(Q){if(Q.nodeValue)Q.nodeValue=n(Q.nodeValue);Q=z.nextNode()}}function f0(J,$,z){try{let Q=J.outerHTML;if(!Q||Q.length>$)return;let j=J.cloneNode(!0);Q4(j);let Z=j.outerHTML;return Z&&Z.length<=z?Z:void 0}catch{return}}var j4=(J)=>f0(J,S1,$4),Z4=150000,K4=40000,N1=(J)=>f0(J,Z4,K4);function W4(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`ช่อง “${n($)}”`}var q1=80;function O1(J){let $=Object.keys(J).find((z)=>z.startsWith("__reactFiber$")||z.startsWith("__reactInternalInstance$"));return $?J[$]:null}function Y4(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 B1(J){if(!J)return;return`→ ${J.length>q1?`${J.slice(0,q1)}…`:J}`}function G4(J){try{let $=J.closest("a[href]")?.getAttribute("href");if($&&$.startsWith("/"))return B1($);let z=O1(J),Q=0;while(z&&Q<30){if(typeof z.memoizedProps?.onClick==="function")return B1(Y4(z.memoizedProps.onClick));z=z.return,Q+=1}return}catch{return}}var V4='[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], [role="status"], [role="alert"]';function X4(){let J=P1();return J.length?J.join(", "):V4}function F4(J){let $=J.getAttribute("role");if($==="status"||$==="alert")return"ข้อความแจ้งเตือน";if($==="menu")return"เมนู";if($==="listbox")return"รายการตัวเลือก";if($==="alertdialog")return"กล่องยืนยัน";return"กล่องโต้ตอบ"}function H4(J){let $=J.getAttribute("aria-label")?.trim();if($)return $;let z=J.getAttribute("aria-labelledby");if(z){let Z=z.split(/\s+/).map((W)=>document.getElementById(W)?.textContent?.trim()??"").filter(Boolean).join(" ");if(Z)return Z}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 _1(J){let $=n(H4(J)),z=F4(J);return $?`เปิด ${z} “${e($,x0)}”`:`เปิด ${z}`}var U4='[aria-busy="true"], [role="progressbar"], [data-loading="true"], .animate-pulse, .animate-spin',P4=/กำลังโหลด|กำลังค้นหา|กำลังดำเนินการ|\bloading\b/i;function M4(J){if(J.querySelector(U4))return!0;return P4.test(J.textContent??"")}var D4=400,I4=250,C4=8000;function N4(J,$){if(typeof MutationObserver>"u"){$.html=D0(N1(J));return}let z=Date.now(),Q=!1,j=()=>{Q=!0,W.disconnect(),window.clearInterval(G),window.clearTimeout(F)},Z=()=>{if(Q)return;if(j(),!J.isConnected)return;$.detail=e(_1(J),A0),$.html=D0(N1(J))},W=new MutationObserver(()=>{z=Date.now()});W.observe(J,{childList:!0,subtree:!0,attributes:!0,characterData:!0});let G=window.setInterval(()=>{if(Q)return;if(!J.isConnected){j();return}if(Date.now()-z>=D4&&!M4(J))Z()},I4),F=window.setTimeout(Z,C4)}function q4(J){if(M0(J))return;let $=Y0("ui",_1(J));if($)N4(J,$)}function B4(){if(typeof MutationObserver>"u")return;let J=new WeakSet;new MutationObserver((z)=>{for(let Q of z)for(let j of Array.from(Q.addedNodes)){if(!(j instanceof Element))continue;let Z=X4(),W=j.matches(Z)?[j]:Array.from(j.querySelectorAll(Z));for(let G of W){if(J.has(G))continue;J.add(G),q4(G)}}}).observe(document.body,{childList:!0,subtree:!0})}var w4=1600,S4=2500;function w1(J){return{disabled:J.hasAttribute("disabled")||J.getAttribute("aria-disabled")==="true",busy:J.getAttribute("aria-busy")==="true",text:e((J.textContent??"").replace(/\s+/g," ").trim(),x0)}}function O4(J,$){if(!J.disabled&&$.disabled)return"ปุ่มถูกปิดใช้งานหลังคลิก";if(!J.busy&&$.busy)return"ปุ่มเข้าสู่สถานะกำลังโหลด";if(J.text!==$.text&&$.text)return`ข้อความเปลี่ยนเป็น “${$.text}”`;return null}function _4(J,$){if(typeof MutationObserver>"u")return;let z=w1(J),Q=!1,j=(G,F)=>{if(Q)return;if(Q=!0,Z.disconnect(),window.clearTimeout(W),$.afterNote=G,F)$.afterHtml=D0(f0(J,S1,S4))},Z=new MutationObserver(()=>{if(!J.isConnected){j("องค์ประกอบหายไปจากหน้าจอ",!1);return}let G=O4(z,w1(J));if(G)j(G,!0)});Z.observe(J,{attributes:!0,attributeFilter:["disabled","aria-disabled","aria-busy","class"],childList:!0,subtree:!0,characterData:!0});let W=window.setTimeout(()=>{if(!Q&&!J.isConnected){j("องค์ประกอบหายไปจากหน้าจอ",!1);return}Q=!0,Z.disconnect()},w4)}function R1(){if(I1||typeof window>"u")return;I1=!0,document.addEventListener("click",(Q)=>{if(M0(Q.target))return;let j=e2(Q.target);if(!j)return;let Z=J4(j);if(!Z)return;let W=Y0("click",`คลิก ${Z}`,G4(j),j4(j));if(W)_4(j,W)},{capture:!0,passive:!0}),document.addEventListener("change",(Q)=>{if(M0(Q.target))return;let j=W4(Q.target);if(j)Y0("input",`แก้ไข ${j}`)},{capture:!0,passive:!0}),document.addEventListener("submit",(Q)=>{if(M0(Q.target))return;Y0("submit","ส่งฟอร์ม")},{capture:!0,passive:!0});let J=()=>Y0("navigate",`ไปที่ ${T0(g(location.pathname+location.search))}`),$=history.pushState.bind(history),z=history.replaceState.bind(history);history.pushState=(...Q)=>{let j=$(...Q);return J(),j},history.replaceState=(...Q)=>{let j=z(...Q);return J(),j},window.addEventListener("popstate",J),B4()}function E0(){return t.map((J)=>({...J}))}var L1=2000,I0=[],A1=0,x1=!1;function h0(J,$){A1+=1,I0.push({id:`log_${A1}`,at:new Date().toISOString(),level:J,message:$.length>L1?`${$.slice(0,L1)}…`:$});while(I0.length>v("maxConsoleEntries"))I0.shift()}function R4(){let J=new WeakSet;return($,z)=>{if(typeof z==="object"&&z!==null){if(J.has(z))return"[Circular]";J.add(z)}if(typeof z==="bigint")return z.toString();return z}}function T1(J){if(typeof J==="string")return J;if(J instanceof Error)return`${J.name}: ${J.message}`;try{let $=JSON.stringify(J,R4());if($!==void 0)return $}catch{}try{return String(J)}catch{}try{return Object.prototype.toString.call(J)}catch{return`[${typeof J}]`}}function k1(){if(x1||typeof window>"u")return;x1=!0;let J=["log","info","warn","error","debug"];for(let $ of J){let z=console[$].bind(console);console[$]=(...Q)=>{h0($,Q.map(T1).join(" ")),z(...Q)}}window.addEventListener("error",($)=>{let z=$.filename?` (${$.filename}:${$.lineno}:${$.colno})`:"";h0("exception",`${$.message}${z}`)}),window.addEventListener("unhandledrejection",($)=>{let z=$.reason instanceof Error?`${$.reason.name}: ${$.reason.message}`:T1($.reason);h0("unhandledrejection",z)})}function m0(){return I0.map((J)=>({...J}))}var f1=new Set,E1=new Set;function h1(J,$){return J.add($),()=>J.delete($)}function m1(J,$){for(let z of[...J])z($)}function g0(J){return h1(f1,J)}function b0(J={type:"manual"}){m1(f1,J)}function y0(J){return h1(E1,J)}function v0(J){m1(E1,J)}var L4=15000,A4=["ResizeObserver loop","Script error.","Non-Error promise rejection captured"],g1=!1,b1=0;function x4(J){return A4.some(($)=>J.includes($))}function y1(J){let $=J.message??"";if(!$||x4($))return;let z=Date.now();if(z-b1<L4)return;b1=z,v0({...J,message:$})}function v1(){if(g1||typeof window>"u")return;g1=!0,window.addEventListener("error",(J)=>{if(!J.message&&!J.error)return;let $=J.error instanceof Error?J.error:null;y1({type:"runtime-error",message:J.message||($?$.message:"Unknown error"),stack:$?.stack})}),window.addEventListener("unhandledrejection",(J)=>{let $=J.reason;y1({type:"unhandledrejection",message:$ instanceof Error?$.message:String($),stack:$ instanceof Error?$.stack:void 0})})}var c1=4000,T4=1e6,k4=1e7,C0=[],p1=0,u1=!1;function i1(J){C0.push(J);while(C0.length>v("maxRequests"))C0.shift()}function l1(){return p1+=1,`req_${p1}`}function d1(J){let $={};if(!J)return $;if(J instanceof Headers)J.forEach((z,Q)=>{$[Q]=z});else if(Array.isArray(J))for(let[z,Q]of J)$[z]=Q;else Object.assign($,J);return $}function f4(J){let $={};return J.forEach((z,Q)=>{$[Q]=z}),$}function E4(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 h4(J,$){let z="",Q="GET",j={},Z=null;if(typeof J==="string")z=J;else if(J instanceof URL)z=J.toString();else z=J.url,Q=J.method||Q,j=d1(J.headers);if($){if($.method)Q=$.method;if($.headers)j={...j,...d1($.headers)};if($.body!==void 0)Z=E4($.body)}return{method:Q.toUpperCase(),url:z,headers:j,body:Z}}function o1(J){return!M1(J)}function m4(J,$){if(o1($.url)){$.responseSnippet="[body not captured for this origin]";return}let z=J.headers.get("content-type")??"",Q=Number(J.headers.get("content-length")??"0"),j=Q?`, ~${Q} bytes`:"";if(!/json|text|xml|html|javascript|urlencoded/i.test(z)){$.responseSnippet=`[binary ${z||"unknown"}${j}]`;return}if(Q>T4){$.responseSnippet=`[response ${z||"text"}${j} — omitted]`;return}try{J.clone().text().then((Z)=>{$.responseSnippet=a(Z,v("maxBodyChars"))}).catch(()=>{})}catch{}}function r1(J,$){if(/[?&]_rsc=/.test(J))return!0;for(let z of Object.keys($)){let Q=z.toLowerCase();if(Q==="rsc"||Q==="next-router-prefetch"||Q==="next-router-state-tree")return!0}return!1}function g4(){if(typeof window>"u"||typeof window.fetch!=="function")return;let J=window.fetch.bind(window);window.fetch=Object.assign(async($,z)=>{let Q=h4($,z);if(r1(Q.url,Q.headers))return J($,z);let j={id:l1(),startedAt:new Date().toISOString(),method:Q.method,url:g(Q.url),requestHeaders:s(Q.headers),requestBody:a(Q.body,c1),status:null,statusText:null,durationMs:null,via:"fetch"};i1(j);let Z=performance.now();try{let W=await J($,z);return j.status=W.status,j.statusText=W.statusText,j.durationMs=Math.round(performance.now()-Z),j.responseHeaders=s(f4(W.headers)),m4(W,j),W}catch(W){throw j.durationMs=Math.round(performance.now()-Z),j.error=W instanceof Error?`${W.name}: ${W.message}`:String(W),W}},J)}function b4(){if(typeof window>"u"||typeof window.XMLHttpRequest!=="function")return;let J=XMLHttpRequest.prototype,$=J.open,z=J.send,Q=function(Z,W){let G=typeof W==="string"?W:W.toString();return this.__lwEntry=r1(G,{})?void 0:{id:l1(),startedAt:"",method:(Z||"GET").toUpperCase(),url:g(G),requestHeaders:{},requestBody:null,status:null,statusText:null,durationMs:null,via:"xhr"},$.apply(this,arguments)},j=function(Z){let W=this.__lwEntry;if(W){W.startedAt=new Date().toISOString(),W.requestBody=typeof Z==="string"?a(Z,c1):Z==null?null:"[non-string body]";let G=performance.now();i1(W),this.addEventListener("loadend",()=>{if(W.status=this.status||null,W.statusText=this.statusText||null,W.durationMs=Math.round(performance.now()-G),o1(W.url))W.responseSnippet="[body not captured for this origin]";else if(this.responseType===""||this.responseType==="text")try{W.responseSnippet=a(this.responseText||"",v("maxBodyChars"))}catch{}else{let F=this.getResponseHeader("content-type")??this.responseType;W.responseSnippet=`[binary ${F}]`}})}return z.apply(this,arguments)};J.open=Q,J.send=j}function n1(){if(u1)return;u1=!0,g4(),b4()}function p0(){let J=C0.map((z)=>({...z})),$=0;for(let z=J.length-1;z>=0;z-=1){let Q=J[z],j=Q?.responseSnippet;if(!Q||typeof j!=="string"||j.length===0)continue;if($+j.length>k4)Q.responseSnippet=`[response omitted — report size budget reached (${j.length.toLocaleString()} chars)]`;else $+=j.length}return J}var y4=4,s1=3,v4=4000,p4="[data-debug-reporter]",u4=()=>import("@rrweb/record");var T=[],J0=null,N0=!1;function a1(){if(typeof window>"u"||J0||N0)return;let J=W0();if(!J)return;N0=!0;let $=()=>void d4(J);if("requestIdleCallback"in window)window.requestIdleCallback($,{timeout:3000});else setTimeout($,1000)}async function d4(J){let $;try{$=(await u4()).record}catch(z){N0=!1,console.warn("[debug-capture] session replay could not start:",z);return}if(J0)return;try{J0=$({emit:(z)=>c4(z),checkoutEveryNms:Math.max(1000,J.seconds*1000/2),checkoutEveryNth:v4,maskAllInputs:J.maskInputs,maskTextSelector:J.maskText?"*":J.maskTextSelector,blockSelector:`${J.blockSelector}, ${p4}`,slimDOMOptions:"all",inlineStylesheet:!0,sampling:{mousemove:50,scroll:150,media:800,input:"last",...J.canvas?{canvas:J.canvas.fps}:{}},recordCanvas:J.canvas!==null,...J.canvas?{dataURLOptions:{type:"image/webp",quality:J.canvas.quality}}:{},errorHandler:()=>!0})??null}catch(z){console.warn("[debug-capture] session replay could not start:",z)}finally{N0=!1}}function c4(J){if(J.type===y4||T.length===0){if(T.push([]),T.length>s1)T=T.slice(-s1)}T[T.length-1].push(J)}function u0(J=Date.now()){let $=W0();if(!$||!T.length)return null;let z=J-$.seconds*1000,Q=T.length-1;while(Q>0&&(T[Q][0]?.timestamp??J)>z)Q-=1;let j=T.slice(Q).flat(),Z=j[0]?.timestamp,W=j[j.length-1]?.timestamp;if(Z===void 0||W===void 0)return null;return{events:j,startedAt:new Date(Z).toISOString(),endedAt:new Date(W).toISOString(),durationMs:Math.max(0,W-Z)}}function i4(){return J0!==null}function l4(){J0?.(),J0=null,T=[]}var o4={title:"รายงานปัญหา",summaryLabel:"หัวข้อปัญหา",summaryRequired:"(ต้องกรอกก่อนแจ้งปัญหา)",summaryPlaceholder:"สรุปปัญหาสั้น ๆ เช่น กดบันทึกร่างแล้ว error",detailLabel:"อธิบายปัญหา (ไม่บังคับ)",detailPlaceholder:"เกิดอะไรขึ้น? กำลังทำอะไรอยู่ตอนที่พบปัญหา?",annotateTitle:"วาดบนรูป",annotateHint:"ทำเครื่องหมายจุดที่มีปัญหาก่อนแนบ — วงกรอบ ชี้ลูกศร ไฮไลต์ หรือพิมพ์ข้อความ",annotateApply:"ใช้รูปนี้",cancel:"ยกเลิก",toolRect:"กรอบ",toolArrow:"ลูกศร",toolHighlight:"ไฮไลต์",toolText:"ข้อความ",deleteSelected:"ลบที่เลือก",clearAll:"ล้างทั้งหมด",annotateHelp:"เลือกเครื่องมือแล้วลากบนรูป · ไม่ได้เลือกเครื่องมือ = ย้าย/ปรับขนาดสิ่งที่วาดไว้ · กดกากบาทมุมขวาบนของรูปทรงเพื่อลบ",capturing:"กำลังเก็บภาพหน้าจอ…",noScreenshot:"ไม่มีภาพหน้าจอ — ยังส่งรายงานได้",cancelled:"ยกเลิกการเก็บภาพหน้าจอแล้ว",close:"ปิด",submit:"แจ้งปัญหา",submitting:"กำลังส่ง…",submitted:"แจ้งปัญหาสำเร็จ",crashed:"เกิดข้อผิดพลาดในระบบ",crashAction:"แจ้งปัญหา",failed:"ส่งรายงานไม่สำเร็จ",failedOffline:"ส่งไม่สำเร็จ — เชื่อมต่อเซิร์ฟเวอร์ไม่ได้ ข้อความที่พิมพ์ไว้ยังอยู่ ตรวจสอบอินเทอร์เน็ตแล้วลองใหม่",failedUnavailable:"ส่งไม่สำเร็จ — ระบบกำลังปรับปรุงชั่วคราว ข้อความที่พิมพ์ไว้ยังอยู่ ลองใหม่ในอีกสักครู่",failedTooMany:"แจ้งปัญหาถี่เกินไป — ลองใหม่ในอีก {seconds} วินาที",captured:"เก็บข้อมูลแล้ว",reporter:"ผู้แจ้ง",page:"หน้า",replay:"บันทึกการใช้งาน",handoffTitle:"กำลังพาไปที่ระบบแจ้งปัญหา",handoffBody:"ระบบจะลงชื่อเข้าใช้ให้อัตโนมัติ เพื่อดูเรื่องที่คุณแจ้งไว้",handoffGo:"ไปเลย",handoffPreparing:"กำลังเตรียม…",handoffFailed:"เปิดรายการที่แจ้งไว้ไม่สำเร็จ",handoffBlocked:"เบราว์เซอร์บล็อกการเปิดแท็บใหม่",handoffOpen:"เปิดในแท็บใหม่",chooseTitle:"ต้องการให้ทีมช่วยเรื่องอะไร",chooseProblem:"แจ้งปัญหา",chooseProblemHint:"มีอะไรเสียหรือใช้งานไม่ได้ — แนบภาพหน้าจอ",chooseRequest:"ขอให้ทีมดำเนินการ",chooseRequestHint:"ขอสิทธิ์ ขอแก้ข้อมูล หรือขอให้ทีมทำบางอย่าง",requestTitle:"ขอให้ทีมดำเนินการ",requestTypeLabel:"เรื่องที่ขอ",requestTarget:"ทีมตั้งใจให้เสร็จภายใน {time}",requestSummaryLabel:"หัวข้อ",requestSummaryPlaceholder:"ขออะไร — สั้น ๆ",requestDetailLabel:"รายละเอียด (ไม่บังคับ)",requestDetailPlaceholder:"สิ่งที่ทีมต้องรู้เพื่อดำเนินการ",requestSubmit:"ส่งคำขอ",requestSubmitted:"ส่งคำขอแล้ว",back:"ย้อนกลับ",days:"{n} วัน",hours:"{n} ชั่วโมง"},r4={title:"Report a problem",summaryLabel:"Summary",summaryRequired:"(required)",summaryPlaceholder:"One line, e.g. saving a draft returns an error",detailLabel:"Details (optional)",detailPlaceholder:"What happened? What were you doing at the time?",annotateTitle:"Draw on the image",annotateHint:"Mark what went wrong before attaching — box it, point at it, highlight it, or type on it",annotateApply:"Use this image",cancel:"Cancel",toolRect:"Box",toolArrow:"Arrow",toolHighlight:"Highlight",toolText:"Text",deleteSelected:"Delete selected",clearAll:"Clear all",annotateHelp:"Pick a tool and drag on the image · no tool selected = move/resize what you drew · press the ✕ on a shape to delete it",capturing:"Capturing the screen…",noScreenshot:"No screenshot — you can still send the report",cancelled:"Screen capture cancelled",close:"Close",submit:"Send report",submitting:"Sending…",submitted:"Report sent",crashed:"Something went wrong",crashAction:"Report it",failed:"Could not send the report",failedOffline:"Could not send — the server could not be reached. What you wrote is still here; check your connection and try again.",failedUnavailable:"Could not send — the system is being updated. What you wrote is still here; try again in a moment.",failedTooMany:"Too many reports — try again in {seconds} seconds.",captured:"Captured",reporter:"Reporter",page:"Page",replay:"activity log",handoffTitle:"Opening the support portal",handoffBody:"You will be signed in automatically to see what you reported",handoffGo:"Go now",handoffPreparing:"Preparing…",handoffFailed:"Could not open your reports",handoffBlocked:"Your browser blocked the new tab",handoffOpen:"Open in a new tab",chooseTitle:"How can the team help?",chooseProblem:"Report a problem",chooseProblemHint:"Something is broken or not working — with a screenshot",chooseRequest:"Ask the team",chooseRequestHint:"Access, a data change, or something done for you",requestTitle:"Ask the team",requestTypeLabel:"What you need",requestTarget:"The team aims to finish within {time}",requestSummaryLabel:"Subject",requestSummaryPlaceholder:"What do you need — briefly",requestDetailLabel:"Details (optional)",requestDetailPlaceholder:"What the team needs to know to do it",requestSubmit:"Send request",requestSubmitted:"Request sent",back:"Back",days:"{n} days",hours:"{n} hours"};function l(J){return J==="en"?r4:o4}var n4="lw-debug-toasts",s4=6000,a4=`
2
2
  :host { all: initial; }
3
3
  .stack {
4
4
  position: fixed; top: 16px; right: 16px; z-index: 2147483001;
@@ -30,15 +30,15 @@ var N2=((J)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(J,{get:($,Q)=
30
30
  }
31
31
  @keyframes in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
32
32
  @media (prefers-reduced-motion: reduce) { .toast { animation: none; } }
33
- `,y0=null;function u4(){if(typeof document>"u")return null;if(y0?.isConnected)return y0;let J=document.createElement(b4);J.dataset.debugReporter="true";let $=J.attachShadow({mode:"open"}),Q=document.createElement("style");Q.textContent=p4;let j=document.createElement("div");return j.className="stack",j.setAttribute("role","status"),j.setAttribute("aria-live","polite"),$.append(Q,j),document.body.append(J),y0=j,j}function e(J,$="success",Q){let j=z0()?w().toast:void 0;if(j){j({message:J,tone:$,...Q?{action:Q}:{}});return}let z=u4();if(!z)return;let K=document.createElement("div");K.className="toast",K.dataset.tone=$;let W=document.createElement("span");W.className="dot";let G=document.createElement("span");G.textContent=J;let F=document.createElement("button");F.type="button",F.className="close",F.textContent="✕",F.setAttribute("aria-label","ปิด");let P=()=>{window.clearTimeout(B),K.remove()};F.addEventListener("click",P);let B=$==="error"||Q?0:window.setTimeout(P,v4);if(K.append(W,G),Q){let M=document.createElement("button");M.type="button",M.className="action",M.textContent=Q.label,M.addEventListener("click",()=>{P(),Q.onClick()}),K.append(M)}K.append(F),z.append(K)}function i1(J,$,Q){let j=J.filter((K)=>Boolean(K.error)||K.status!=null&&K.status>=400).slice(-20).map((K)=>({method:K.method,url:K.url,status:K.status,error:K.error,at:K.startedAt})),z=$.filter((K)=>K.level==="error"||K.level==="exception"||K.level==="unhandledrejection").slice(-20).map((K)=>K.message);return{failedRequests:j,errors:z,erroredQueries:Q.slice(0,20)}}function l1(J){return J.failedRequests.length+J.errors.length+J.erroredQueries.length}function d4(){let J={memoryUsedMb:null,memoryLimitMb:null,domContentLoadedMs:null,loadEventMs:null};if(typeof performance>"u")return J;let $=performance.memory;if($)J.memoryUsedMb=Math.round($.usedJSHeapSize/1024/1024),J.memoryLimitMb=Math.round($.jsHeapSizeLimit/1024/1024);let[Q]=performance.getEntriesByType("navigation");if(Q)J.domContentLoadedMs=Math.round(Q.domContentLoadedEventEnd),J.loadEventMs=Math.round(Q.loadEventEnd);return J}function b0(J,$){if(!J)return $;try{return J()}catch{return $}}function o1(){let J=w(),{pathname:$,search:Q,href:j}=window.location;return{capturedAt:new Date().toISOString(),route:{href:j,pathname:$,search:Q},module:W1($),user:b0(J.user,{}),apiHeaders:r(b0(J.headers,{})),app:{name:m().name,version:m().version,environment:m().environment},client:{userAgent:navigator.userAgent,language:navigator.language,platform:navigator.platform,online:navigator.onLine,viewport:{width:window.innerWidth,height:window.innerHeight,dpr:window.devicePixelRatio},screen:{width:window.screen.width,height:window.screen.height}},performance:d4(),extra:b0(J.extra,{})}}var c4=2,i4={manual:"ผู้ใช้แจ้งเอง","runtime-error":"ข้อผิดพลาด runtime (auto)",unhandledrejection:"Promise rejection (auto)","framework-error":"หน้าจอค้าง/พัง (auto)"};function v0(J){let $=m0(),Q=A0();return{context:o1(),reason:J.reason,note:J.note,cause:i1($,Q,J.erroredQueries),actionTrail:k0(),network:$,console:Q,screenshotDataUrl:J.screenshotDataUrl,screenshotMethod:J.screenshotMethod,replay:g0()??void 0,meta:{generatedBy:"lightwork-debug-capture",schemaVersion:c4}}}function r1(J){return J.replace(/'/g,"'\\''")}function s1(J){let $=[`curl -X ${J.method} '${J.url}'`];for(let[Q,j]of Object.entries(J.requestHeaders))$.push(` -H '${Q}: ${r1(j)}'`);if(J.requestBody)$.push(` --data '${r1(J.requestBody)}'`);return $.join(" \\\n")}function l4(J){if(J.error)return`ERR ${J.error}`;return`${J.status??"—"} ${J.statusText??""}`.trim()}function o4(J){if(J.length===0)return"No network activity captured.";return J.map(($)=>{let Q=$.durationMs!=null?`${$.durationMs}ms`:"—",j=`# [${l4($)}] ${$.method} ${$.url} (${Q}, ${$.startedAt})`,z=$.responseSnippet?`
34
- # response: ${$.responseSnippet}`:"";return`${j}
35
- ${s1($)}${z}`}).join(`
33
+ `,d0=null;function t4(){if(typeof document>"u")return null;if(d0?.isConnected)return d0;let J=document.createElement(n4);J.dataset.debugReporter="true";let $=J.attachShadow({mode:"open"}),z=document.createElement("style");z.textContent=a4;let Q=document.createElement("div");return Q.className="stack",Q.setAttribute("role","status"),Q.setAttribute("aria-live","polite"),$.append(z,Q),document.body.append(J),d0=Q,Q}function p(J,$="success",z){let Q=K0()?w().toast:void 0;if(Q){Q({message:J,tone:$,...z?{action:z}:{}});return}let j=t4();if(!j)return;let Z=document.createElement("div");Z.className="toast",Z.dataset.tone=$;let W=document.createElement("span");W.className="dot";let G=document.createElement("span");G.textContent=J;let F=document.createElement("button");F.type="button",F.className="close",F.textContent="✕",F.setAttribute("aria-label","ปิด");let P=()=>{window.clearTimeout(q),Z.remove()};F.addEventListener("click",P);let q=$==="error"||z?0:window.setTimeout(P,s4);if(Z.append(W,G),z){let M=document.createElement("button");M.type="button",M.className="action",M.textContent=z.label,M.addEventListener("click",()=>{P(),z.onClick()}),Z.append(M)}Z.append(F),j.append(Z)}function t1(J,$,z){let Q=J.filter((Z)=>Boolean(Z.error)||Z.status!=null&&Z.status>=400).slice(-20).map((Z)=>({method:Z.method,url:Z.url,status:Z.status,error:Z.error,at:Z.startedAt})),j=$.filter((Z)=>Z.level==="error"||Z.level==="exception"||Z.level==="unhandledrejection").slice(-20).map((Z)=>Z.message);return{failedRequests:Q,errors:j,erroredQueries:z.slice(0,20)}}function e1(J){return J.failedRequests.length+J.errors.length+J.erroredQueries.length}function e4(){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[z]=performance.getEntriesByType("navigation");if(z)J.domContentLoadedMs=Math.round(z.domContentLoadedEventEnd),J.loadEventMs=Math.round(z.loadEventEnd);return J}function c0(J,$){if(!J)return $;try{return J()}catch{return $}}function J2(){let J=w(),{pathname:$,search:z,href:Q}=window.location;return{capturedAt:new Date().toISOString(),route:{href:Q,pathname:$,search:z},module:U0($),user:c0(J.user,{}),apiHeaders:s(c0(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:e4(),extra:c0(J.extra,{})}}var J6=2,$6={manual:"ผู้ใช้แจ้งเอง","runtime-error":"ข้อผิดพลาด runtime (auto)",unhandledrejection:"Promise rejection (auto)","framework-error":"หน้าจอค้าง/พัง (auto)"};function i0(J){let $=p0(),z=m0();return{context:J2(),reason:J.reason,note:J.note,cause:t1($,z,J.erroredQueries),actionTrail:E0(),network:$,console:z,screenshotDataUrl:J.screenshotDataUrl,screenshotMethod:J.screenshotMethod,replay:u0()??void 0,meta:{generatedBy:"lightwork-debug-capture",schemaVersion:J6}}}function $2(J){return J.replace(/'/g,"'\\''")}function z2(J){let $=[`curl -X ${J.method} '${J.url}'`];for(let[z,Q]of Object.entries(J.requestHeaders))$.push(` -H '${z}: ${$2(Q)}'`);if(J.requestBody)$.push(` --data '${$2(J.requestBody)}'`);return $.join(" \\\n")}function z6(J){if(J.error)return`ERR ${J.error}`;return`${J.status??"—"} ${J.statusText??""}`.trim()}function Q6(J){if(J.length===0)return"No network activity captured.";return J.map(($)=>{let z=$.durationMs!=null?`${$.durationMs}ms`:"—",Q=`# [${z6($)}] ${$.method} ${$.url} (${z}, ${$.startedAt})`,j=$.responseSnippet?`
34
+ # response: ${$.responseSnippet}`:"";return`${Q}
35
+ ${z2($)}${j}`}).join(`
36
36
 
37
- `)}function r4(J){if(J.length===0)return"No console output captured.";return J.map(($)=>`[${$.at}] ${$.level.toUpperCase()}: ${$.message}`).join(`
38
- `)}function s4(J){if(J.length===0)return"No user actions captured.";let $=0;return J.map((Q)=>{let j=Q.source?` (${Q.source})`:"",z=`${Q.detail}${_0(Q.count)}${j}`;if(Q.kind==="ui")return` ↳ [${Q.at}] ${z}`;$+=1;let K=`${$}. [${Q.at}] ${z}`;return Q.afterNote?`${K}
39
- ↳ ${Q.afterNote}`:K}).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 a4(J){let{context:$}=J;return[`User : ${$.user.fullName??"—"} (${$.user.email??"—"})`,`Unit : ${$.user.unit??"—"}`,`Roles : ${$.user.roles?.join(", ")||"—"}`,`Route : ${$.route.href}`,`Module : ${$.module?`${$.module.label} (${$.module.key})`:"—"}`,`App : ${$.app.name} v${$.app.version} · ${$.app.environment}`,`Memory : ${$.performance.memoryUsedMb??"—"}/${$.performance.memoryLimitMb??"—"} MB`,`Client : ${$.client.userAgent}`,`Viewport : ${$.client.viewport.width}×${$.client.viewport.height} @${$.client.viewport.dpr}x`,`Reason : ${i4[J.reason.type]}${J.reason.message?` — ${J.reason.message}`:""}`,`Captured : ${J.network.length} requests · ${J.console.length} console · ${J.actionTrail.length} actions · screenshot=${J.screenshotMethod}${J.replay?` · replay=${Math.round(J.replay.durationMs/1000)}s`:""}`]}function t4(J){let $=n4(J.cause),Q=[`## \uD83D\uDC1E ${J.context.app.name} — Debug Report`,`**Generated:** ${J.context.capturedAt}`,"",...a4(J).map((j)=>`- ${j.replace(/\s{2,}:/,":")}`),"",`**หมายเหตุจากผู้แจ้ง:** ${J.note.trim()||"(ไม่มี)"}`];if($.length>0)Q.push("","### ⚠ สาเหตุที่น่าจะเป็น","```",...$,"```");return Q.push("",`<details><summary>ขั้นตอน (${J.actionTrail.length})</summary>`,"","```",s4(J.actionTrail),"```","</details>","",`<details><summary>Network (${J.network.length})</summary>`,"","```",o4(J.network),"```","</details>","",`<details><summary>Console (${J.console.length})</summary>`,"","```",r4(J.console),"```","</details>","","_ข้อมูลลับ (token, cookie) ถูกปกปิดอัตโนมัติ · ภาพหน้าจออยู่ในไฟล์ .zip_"),Q.join(`
41
- `)}function e4(J){return J.replace(/[:.]/g,"-").replace("T","_").slice(0,19)}function J6(J,$){return`debug-report_${e4(J.context.capturedAt)}.${$}`}function $6(J){return l1(J.cause)>0}async function p0(){if(typeof navigator<"u"&&Boolean(navigator.mediaDevices?.getDisplayMedia)){let Q=await Q6();if(Q.status==="ok")return{dataUrl:Q.dataUrl,method:"display-media"};if(Q.status==="cancelled")return{dataUrl:null,method:"cancelled"}}let $=await Z6();if($)return{dataUrl:$,method:"html-to-image"};return{dataUrl:null,method:"none"}}async function Q6(){let J=null;try{let $={video:{frameRate:30},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude"};J=await navigator.mediaDevices.getDisplayMedia($);let Q=await j6(J);return Q?{status:"ok",dataUrl:Q}:{status:"error"}}catch($){if($ instanceof DOMException&&($.name==="NotAllowedError"||$.name==="AbortError"))return{status:"cancelled"};return{status:"error"}}finally{J?.getTracks().forEach(($)=>$.stop())}}async function j6(J){let $=document.createElement("video");$.srcObject=J,$.muted=!0,$.playsInline=!0,await new Promise((W)=>{let G=!1,F=()=>{if(G)return;G=!0,W()};$.onloadedmetadata=()=>{$.play().then(F).catch(F)},window.setTimeout(F,1500)}),await z6($);let{videoWidth:Q,videoHeight:j}=$;if(!Q||!j)return null;let z=document.createElement("canvas");z.width=Q,z.height=j;let K=z.getContext("2d");if(!K)return null;K.drawImage($,0,0,Q,j),$.pause(),$.srcObject=null;try{return z.toDataURL("image/png")}catch{return null}}function z6(J){return new Promise(($)=>{let Q=!1,j=()=>{if(Q)return;Q=!0,$()},z=J;if(typeof z.requestVideoFrameCallback==="function")z.requestVideoFrameCallback(()=>j()),window.setTimeout(j,1000);else window.setTimeout(j,250)})}async function Z6(){let J=w().screenshotFallback;if(!J)return null;let $=await J().catch(()=>null);if(!$)return null;try{return await $(document.body,{cacheBust:!0,pixelRatio:Math.min(window.devicePixelRatio||1,2),filter:(Q)=>!(Q instanceof HTMLElement&&Q.dataset?.debugReporter==="true")})}catch{return null}}var K6=2000,W6=0.82,Y6=3000000;function G6(J){return new Promise(($,Q)=>{let j=new Image;j.onload=()=>$(j),j.onerror=()=>Q(Error("could not read the screenshot")),j.src=J})}async function n1(J){try{let $=await G6(J),Q=Math.max($.naturalWidth,$.naturalHeight),j=Math.min(1,K6/Q),z=document.createElement("canvas");z.width=Math.max(1,Math.round($.naturalWidth*j)),z.height=Math.max(1,Math.round($.naturalHeight*j));let K=z.getContext("2d");if(!K)return J;K.fillStyle="#fff",K.fillRect(0,0,z.width,z.height),K.drawImage($,0,0,z.width,z.height);let W=W6,G=z.toDataURL("image/jpeg",W);while(G.length>Y6&&W>0.4)W-=0.15,G=z.toDataURL("image/jpeg",W);return G}catch{return J}}var V6=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,X6=/^\d+$/,F6=/^[0-9a-f]{16,}$/i;function u0(J){if(J.reason.type==="manual")return null;let $=J.cause?.failedRequests?.[0];if(!$?.url)return null;let Q;try{Q=new URL($.url,"http://x").pathname}catch{Q=$.url}let j=Q.split("/").map((K)=>V6.test(K)||X6.test(K)||F6.test(K)?":id":K).join("/"),z=$.status??($.error?"ERR":"?");return`${$.method??"REQ"} ${j} ${z}`}var d0=2000000;function C0(J){let{screenshotDataUrl:$,replay:Q,...j}=J;return JSON.stringify(j).length}function c0(J,$=2000000){if(C0(J)<=$)return J;let Q=J.network.map((z)=>({...z})),j={...J,network:Q};for(let z of Q){if(C0(j)<=$)return j;if(typeof z.responseSnippet==="string"&&z.responseSnippet.length>35)z.responseSnippet="[body dropped — report size budget]";if(typeof z.requestBody==="string"&&z.requestBody.length>35)z.requestBody="[body dropped — report size budget]"}while(j.network.length>1&&C0(j)>$)j.network=j.network.slice(1);while(j.console.length>1&&C0(j)>$)j.console=j.console.slice(1);return j}function Y0(J){let $="";for(let Q=0;Q<J.length;Q+=32768)$+=String.fromCharCode(...J.subarray(Q,Q+32768));return btoa($)}var H6=4,U6=2,P6=3,M6=0,C6=new Set(["href","src","action","formaction","xlink:href","data","poster","srcset"]),I6=/^\s*javascript:/i;function D6(J,$){let Q=J.toLowerCase();if(Q.startsWith("on")||Q==="srcdoc")return!0;return typeof $==="string"&&I6.test($)}function a1(J,$=!1){if(!J)return;for(let Q of Object.keys(J)){let j=J[Q];if(D6(Q,j)){if($)J[Q]=null;else delete J[Q];continue}if(typeof j!=="string"||!C6.has(Q)||!j.includes("?"))continue;J[Q]=E(j)}}function i0(J){if(!J)return;a1(J.attributes);for(let $ of J.childNodes??[])i0($)}function t1(J){let $=JSON.parse(JSON.stringify(J));for(let Q of $){let j=Q.data;if(!j||typeof j!=="object")continue;if(Q.type===H6&&typeof j.href==="string")j.href=E(j.href);else if(Q.type===U6)i0(j.node);else if(Q.type===P6&&j.source===M6){for(let z of j.adds??[])i0(z.node);for(let z of j.attributes??[])a1(z.attributes,!0)}}return $}var J2="session-replay.json.gz",q6="session-replay.json";function B6(J){return Boolean(J&&J.events.length>0)}async function N6(J){if(typeof CompressionStream>"u")return null;try{let $=new Blob([J]).stream().pipeThrough(new CompressionStream("gzip"));return new Uint8Array(await new Response($).arrayBuffer())}catch{return null}}async function l0(J,$){if(!B6(J))return{summary:{omitted:"empty"}};let j={seconds:Math.round(J.durationMs/1000),events:J.events.length,startedAt:J.startedAt,endedAt:J.endedAt},z=t1(J.events),K=await e1(z),W=!1;if(K.bytes.byteLength>$&&O6(z))z=R6(z),K=await e1(z),W=!0;let{bytes:G,compressed:F}=K;if(G.byteLength>$)return{summary:{...j,bytes:G.byteLength,omitted:"too-large"}};return{dataUri:`data:${F?"application/gzip":"application/json"};base64,${Y0(G)}`,filename:F?J2:q6,summary:{...j,events:z.length,bytes:G.byteLength,compressed:F,...W?{canvasDropped:W}:{}}}}async function e1(J){let $=new TextEncoder().encode(JSON.stringify({events:J})),Q=await N6($);return Q?{bytes:Q,compressed:!0}:{bytes:$,compressed:!1}}var w6=3,$2=2,S6=9;function Q2(J){return J.type===w6&&J.data?.source===S6}function O6(J){return J.some(Q2)||J.some(($)=>$.type===$2&&j2($.data.node))}function j2(J){if(!J)return!1;if(J.attributes&&"rr_dataURL"in J.attributes)return!0;return(J.childNodes??[]).some(j2)}function z2(J){if(!J)return;if(J.attributes&&"rr_dataURL"in J.attributes)delete J.attributes.rr_dataURL;for(let $ of J.childNodes??[])z2($)}function R6(J){let $=[];for(let Q of J){if(Q2(Q))continue;if(Q.type===$2)z2(Q.data.node);$.push(Q)}return $}var _6=new Set([502,503,504]);class c extends Error{kind;retryAfter;status;constructor(J,$,Q,j){super(J);this.kind=$;this.retryAfter=Q;this.status=j;this.name="ReportError"}}function L6(J){let{screenshotDataUrl:$,replay:Q,...j}=J;return{dataUri:`data:application/json;base64,${Y0(new TextEncoder().encode(JSON.stringify(j)))}`,filename:"debug-bundle.json"}}async function k6(){let J=w().identity;if(!J)return{};try{let $=await J();return $?{authorization:`Bearer ${$}`}:{}}catch{return{}}}async function o0(J,$){let Q=w(),j=c0($,d0),{context:z,note:K}=j,W=[];if(j.screenshotDataUrl){let C=await n1(j.screenshotDataUrl);W.push({dataUri:C,filename:"screenshot.jpg"})}W.push(L6(j));let G,F=Z0();if(F){let C=await l0(j.replay,F.maxBytes);if(G=C.summary,"dataUri"in C)W.push({dataUri:C.dataUri,filename:C.filename})}let P=u0(j),B={title:J,description:K.trim()||void 0,appName:m().name,category:z.module?.label,routeUrl:z.route.href,priority:"MEDIUM",requesterEmail:z.user.email??void 0,requesterName:z.user.fullName??void 0,customFields:{unit:z.user.unit??"",appVersion:z.app.version,environment:z.app.environment,reasonType:j.reason.type,appName:m().name,module:z.module?.label??""},context:{...P?{signature:P}:{},capturedAt:z.capturedAt,reason:j.reason,cause:j.cause,actionTrail:j.actionTrail,client:z.client,performance:z.performance,apiHeaders:z.apiHeaders,extra:z.extra,counts:{network:j.network.length,console:j.console.length,actions:j.actionTrail.length},screenshotMethod:j.screenshotMethod,...G?{replay:G}:{}},attachments:W},M=await fetch(`${Q.host.replace(/\/$/,"")}/ingest/tickets`,{method:"POST",headers:{"content-type":"application/json","x-realm-key":Q.realmKey,...await k6()},body:JSON.stringify(B)}).catch(()=>{throw new c("report never left the browser","offline")});if(!M.ok){let C=M.headers.get("retry-after"),S=await M.json().then((D)=>D.error).catch(()=>null);if(M.status===429)throw new c("rate limited","rateLimited",C??void 0);if(_6.has(M.status))throw new c("desk unavailable","unavailable");throw new c(S??`Report failed (${M.status})`,"rejected",void 0,M.status)}return await M.json()}var G0=Math.PI/6;function Z2(J,$,Q){let j=$.x-J.x,z=$.y-J.y,K=Math.hypot(j,z),W=Math.atan2(z,j),G=[{x:$.x,y:$.y},{x:$.x-Q*Math.cos(W-G0),y:$.y-Q*Math.sin(W-G0)},{x:$.x-Q*Math.cos(W+G0),y:$.y-Q*Math.sin(W+G0)}],F=Q*Math.cos(G0)*0.92;if(K<=F)return{shaft:null,head:G};return{shaft:{from:J,to:{x:$.x-F*Math.cos(W),y:$.y-F*Math.sin(W)}},head:G}}var r0="#f44336",T6="rgba(250, 204, 21, 0.4)",s0=22,K2="#2563eb",W2=9,Y2=11,G2=18,V2=4,I0=8,A6=[{id:"nw",fx:0,fy:0,cursor:"nwse-resize"},{id:"n",fx:0.5,fy:0,cursor:"ns-resize"},{id:"ne",fx:1,fy:0,cursor:"nesw-resize"},{id:"e",fx:1,fy:0.5,cursor:"ew-resize"},{id:"se",fx:1,fy:1,cursor:"nwse-resize"},{id:"s",fx:0.5,fy:1,cursor:"ns-resize"},{id:"sw",fx:0,fy:1,cursor:"nesw-resize"},{id:"w",fx:0,fy:0.5,cursor:"ew-resize"}];function n0(J,$,Q){let j=[],z=null,K=-1,W=null,G=null,F=J.getContext("2d");function P(){let Z=J.getBoundingClientRect().width;return Z>0?J.width/Z:1}function B(Z){let Y=J.getBoundingClientRect();return{x:(Z.clientX-Y.left)/Y.width*J.width,y:(Z.clientY-Y.top)/Y.height*J.height}}function M(Z){let Y=Z.size??s0;if(!F)return(Z.text?.length??0)*Y*0.6;F.save(),F.font=`600 ${Y}px system-ui, sans-serif`;let X=F.measureText(Z.text??"").width;return F.restore(),X}function C(Z){if(Z.tool==="text"){let Y=Z.size??s0;return{left:Z.x1,top:Z.y1,right:Z.x1+M(Z),bottom:Z.y1+Y*1.25}}return{left:Math.min(Z.x1,Z.x2),top:Math.min(Z.y1,Z.y2),right:Math.max(Z.x1,Z.x2),bottom:Math.max(Z.y1,Z.y2)}}function S(Z){if(Z.tool==="arrow")return[{id:"tail",x:Z.x1,y:Z.y1,cursor:"move"},{id:"head",x:Z.x2,y:Z.y2,cursor:"move"}];let Y=C(Z);if(Z.tool==="text")return[{id:"size",x:Y.right,y:Y.bottom,cursor:"nwse-resize"}];return A6.map((X)=>({id:X.id,x:Y.left+(Y.right-Y.left)*X.fx,y:Y.top+(Y.bottom-Y.top)*X.fy,cursor:X.cursor}))}function D(Z){let Y=C(Z);return{x:Y.right+G2*P(),y:Y.top-G2*P()}}function R(Z,Y,X){let{shaft:V,head:H}=Z2({x:Y.x1,y:Y.y1},{x:Y.x2,y:Y.y2},Math.max(10,16*X));if(V)Z.lineCap="butt",Z.beginPath(),Z.moveTo(V.from.x,V.from.y),Z.lineTo(V.to.x,V.to.y),Z.stroke();Z.beginPath(),Z.moveTo(H[0].x,H[0].y),Z.lineTo(H[1].x,H[1].y),Z.lineTo(H[2].x,H[2].y),Z.closePath(),Z.fill()}function _(Z,Y,X){Z.save(),Z.lineWidth=Math.max(2,3*X),Z.strokeStyle=r0,Z.fillStyle=r0;let V=C(Y);if(Y.tool==="rect")Z.strokeRect(V.left,V.top,V.right-V.left,V.bottom-V.top);else if(Y.tool==="arrow")R(Z,Y,X);else if(Y.tool==="highlight")Z.fillStyle=T6,Z.fillRect(V.left,V.top,V.right-V.left,V.bottom-V.top);else if(Y.tool==="text"&&Y.text){let H=Y.size??s0;Z.font=`600 ${H}px system-ui, sans-serif`,Z.textBaseline="top";let U=H*0.22;Z.fillStyle="rgba(255,255,255,0.92)",Z.fillRect(V.left-U,V.top-U,V.right-V.left+U*2,V.bottom-V.top+U*2),Z.fillStyle=r0,Z.fillText(Y.text,V.left,V.top)}Z.restore()}function q(Z,Y,X){let V=C(Y);Z.save(),Z.strokeStyle=K2,Z.lineWidth=Math.max(1,1.5*X),Z.setLineDash([6*X,4*X]),Z.strokeRect(V.left,V.top,V.right-V.left,V.bottom-V.top),Z.setLineDash([]);let H=W2*X;for(let x of S(Y))Z.fillStyle="#fff",Z.strokeStyle=K2,Z.lineWidth=Math.max(1,1.5*X),Z.beginPath(),Z.rect(x.x-H/2,x.y-H/2,H,H),Z.fill(),Z.stroke();let U=D(Y),I=Y2*X;Z.beginPath(),Z.arc(U.x,U.y,I,0,Math.PI*2),Z.fillStyle="#dc2626",Z.fill(),Z.strokeStyle="#fff",Z.lineWidth=Math.max(1.5,2*X),Z.beginPath(),Z.moveTo(U.x-I*0.4,U.y-I*0.4),Z.lineTo(U.x+I*0.4,U.y+I*0.4),Z.moveTo(U.x+I*0.4,U.y-I*0.4),Z.lineTo(U.x-I*0.4,U.y+I*0.4),Z.stroke(),Z.restore()}function O(){if(!F)return;let Z=P();if(F.clearRect(0,0,J.width,J.height),F.drawImage($,0,0,J.width,J.height),j.forEach((X,V)=>{if(V!==v)_(F,X,Z)}),W)_(F,W,Z);let Y=j[K];if(Y&&!W)q(F,Y,Z)}function y(Z,Y,X,V,H){return Math.abs(Z-X)<=H&&Math.abs(Y-V)<=H}function Q0(Z,Y){let X=j[K];if(!X)return null;let V=W2*P()/2+3*P();for(let H of S(X))if(y(Z,Y,H.x,H.y,V))return H.id;return null}function i(Z,Y){let X=j[K];if(!X)return!1;let V=D(X);return y(Z,Y,V.x,V.y,Y2*P())}function h(Z,Y){let X=6*P();for(let V=j.length-1;V>=0;V-=1){let H=j[V];if(H.tool==="arrow"){let I=H.x2-H.x1,x=H.y2-H.y1,p=Math.hypot(I,x)||1,u=Math.max(0,Math.min(1,((Z-H.x1)*I+(Y-H.y1)*x)/(p*p)));if(Math.hypot(Z-(H.x1+u*I),Y-(H.y1+u*x))<=X+4*P())return V;continue}let U=C(H);if(Z>=U.left-X&&Z<=U.right+X&&Y>=U.top-X&&Y<=U.bottom+X)return V}return-1}function b(Z,Y,X,V,H){if(Y==="tail"){Z.x1=X.x1+V,Z.y1=X.y1+H;return}if(Y==="head"){Z.x2=X.x2+V,Z.y2=X.y2+H;return}if(Y==="size"){let B2=(X.size??24)+H;Z.size=Math.max(10,B2);return}let U=C(X),{left:I,top:x,right:p,bottom:u}=U;if(Y.includes("w"))I=Math.min(p-I0,I+V);if(Y.includes("e"))p=Math.max(I+I0,p+V);if(Y.includes("n"))x=Math.min(u-I0,x+H);if(Y.includes("s"))u=Math.max(x+I0,u+H);Z.x1=I,Z.y1=x,Z.x2=p,Z.y2=u}function B0(Z,Y,X,V){Z.x1=Y.x1+X,Z.y1=Y.y1+V,Z.x2=Y.x2+X,Z.y2=Y.y2+V}let L=null,v=-1,N={x:0,y:0,size:24};function f(){let Z=J.getBoundingClientRect().width;return Z>0?Z/J.width:1}function q2(Z,Y){if(!F)return Z.length*Y*0.6;F.save(),F.font=`600 ${Y}px system-ui, sans-serif`;let X=F.measureText(Z||" ").width;return F.restore(),X}function J1(){if(!L)return;let Z=J.parentElement;if(!Z)return;let Y=J.getBoundingClientRect(),X=Z.getBoundingClientRect(),V=f(),H=N.size*V;L.style.left=`${Y.left-X.left+N.x*V}px`,L.style.top=`${Y.top-X.top+N.y*V}px`,L.style.fontSize=`${H}px`,L.style.width=`${Math.max(40,q2(L.value,H)+H)}px`}function j0(Z){let Y=L;if(!Y)return;L=null;let X=Y.value.trim(),V=v;if(v=-1,Y.remove(),Z&&X){if(V>=0&&j[V])j[V].text=X,K=V;else j.push({tool:"text",x1:N.x,y1:N.y,x2:N.x,y2:N.y,text:X,size:N.size}),K=j.length-1;Q()}else if(V>=0)K=V;J.focus(),O()}function $1(Z,Y,X=-1){j0(!0);let V=J.parentElement;if(!V)return;if(getComputedStyle(V).position==="static")V.style.position="relative";let H=X>=0?j[X]:void 0;v=X,N={x:H?.x1??Z,y:H?.y1??Y,size:H?.size??Math.round(24*P())};let U=document.createElement("input");U.type="text",U.className="text-edit",U.value=H?.text??"",U.setAttribute("aria-label","ข้อความบนภาพ"),U.placeholder="ข้อความ",L=U,V.append(U),J1(),U.addEventListener("input",J1),U.addEventListener("keydown",(I)=>{if(I.stopPropagation(),I.key==="Enter")j0(!0);else if(I.key==="Escape")j0(!1)}),requestAnimationFrame(()=>{if(L!==U)return;U.focus(),U.select(),U.addEventListener("blur",()=>j0(!0))}),O()}function Q1(Z){let{x:Y,y:X}=B(Z);if(J.setPointerCapture(Z.pointerId),i(Y,X)){N0();return}let V=Q0(Y,X);if(V&&j[K]){G={grip:V,x:Y,y:X,start:{...j[K]}};return}if(z==="text"){if(Z.preventDefault(),J.hasPointerCapture(Z.pointerId))J.releasePointerCapture(Z.pointerId);z=null,Q(),$1(Y,X);return}if(z){W={tool:z,x1:Y,y1:X,x2:Y,y2:X},K=-1;return}let H=h(Y,X);K=H,G=H>=0?{grip:"body",x:Y,y:X,start:{...j[H]}}:null,O()}function j1(Z){let{x:Y,y:X}=B(Z);if(W){W.x2=Y,W.y2=X,O();return}if(G){let H=j[K];if(!H)return;let U=Y-G.x,I=X-G.y;if(G.grip==="body")B0(H,G.start,U,I);else b(H,G.grip,G.start,U,I);O();return}if(z){J.style.cursor="crosshair";return}if(i(Y,X)){J.style.cursor="pointer";return}let V=Q0(Y,X);if(V){let H=j[K]?S(j[K]).find((U)=>U.id===V):null;J.style.cursor=H?.cursor??"pointer";return}J.style.cursor=h(Y,X)>=0?"move":"default"}function V0(){if(W){if(!(Math.abs(W.x2-W.x1)<V2&&Math.abs(W.y2-W.y1)<V2))j.push(W),K=j.length-1,z=null,Q();W=null}if(G)G=null,Q();O()}function z1(Z){let Y=J.getBoundingClientRect(),X=(Z.clientX-Y.left)/Y.width*J.width,V=(Z.clientY-Y.top)/Y.height*J.height,H=h(X,V),U=j[H];if(!U||U.tool!=="text")return;Z.preventDefault(),$1(U.x1,U.y1,H)}function Z1(Z){if(K<0)return;if(Z.key==="Delete"||Z.key==="Backspace")Z.preventDefault(),N0();else if(Z.key==="Escape")K=-1,O()}function N0(){if(K<0)return;j.splice(K,1),K=-1,Q(),O()}return J.addEventListener("pointerdown",Q1),J.addEventListener("pointermove",j1),J.addEventListener("pointerup",V0),J.addEventListener("pointercancel",V0),J.addEventListener("dblclick",z1),J.tabIndex=0,J.addEventListener("keydown",Z1),O(),{setTool(Z){z=Z,K=-1,J.style.cursor=Z?"crosshair":"default",O()},deleteSelected:N0,clear(){j.length=0,K=-1,Q(),O()},hasShapes:()=>j.length>0,hasSelection:()=>K>=0,toDataUrl(){let Z=document.createElement("canvas");Z.width=$.naturalWidth,Z.height=$.naturalHeight;let Y=Z.getContext("2d");if(!Y)return J.toDataURL("image/png");Y.drawImage($,0,0);let X=P();for(let V of j)_(Y,V,X);return Z.toDataURL("image/png")},destroy(){j0(!1),J.removeEventListener("pointerdown",Q1),J.removeEventListener("pointermove",j1),J.removeEventListener("pointerup",V0),J.removeEventListener("pointercancel",V0),J.removeEventListener("dblclick",z1),J.removeEventListener("keydown",Z1)}}}var x6=["keydown","keyup","keypress"];function D0(J){for(let $ of x6)J.addEventListener($,(Q)=>Q.stopPropagation())}var X2=`
37
+ `)}function j6(J){if(J.length===0)return"No console output captured.";return J.map(($)=>`[${$.at}] ${$.level.toUpperCase()}: ${$.message}`).join(`
38
+ `)}function Z6(J){if(J.length===0)return"No user actions captured.";let $=0;return J.map((z)=>{let Q=z.source?` (${z.source})`:"",j=`${z.detail}${k0(z.count)}${Q}`;if(z.kind==="ui")return` ↳ [${z.at}] ${j}`;$+=1;let Z=`${$}. [${z.at}] ${j}`;return z.afterNote?`${Z}
39
+ ↳ ${z.afterNote}`:Z}).join(`
40
+ `)}function K6(J){let $=[];for(let z of J.failedRequests)$.push(`✗ ${z.status??z.error??"ERR"} ${z.method} ${z.url}`);for(let z of J.errors)$.push(`⚠ ${z}`);for(let z of J.erroredQueries)$.push(`⚠ React Query error: ${z.key} — ${z.error}`);return $}function W6(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 : ${$6[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 Y6(J){let $=K6(J.cause),z=[`## \uD83D\uDC1E ${J.context.app.name} — Debug Report`,`**Generated:** ${J.context.capturedAt}`,"",...W6(J).map((Q)=>`- ${Q.replace(/\s{2,}:/,":")}`),"",`**หมายเหตุจากผู้แจ้ง:** ${J.note.trim()||"(ไม่มี)"}`];if($.length>0)z.push("","### ⚠ สาเหตุที่น่าจะเป็น","```",...$,"```");return z.push("",`<details><summary>ขั้นตอน (${J.actionTrail.length})</summary>`,"","```",Z6(J.actionTrail),"```","</details>","",`<details><summary>Network (${J.network.length})</summary>`,"","```",Q6(J.network),"```","</details>","",`<details><summary>Console (${J.console.length})</summary>`,"","```",j6(J.console),"```","</details>","","_ข้อมูลลับ (token, cookie) ถูกปกปิดอัตโนมัติ · ภาพหน้าจออยู่ในไฟล์ .zip_"),z.join(`
41
+ `)}function G6(J){return J.replace(/[:.]/g,"-").replace("T","_").slice(0,19)}function V6(J,$){return`debug-report_${G6(J.context.capturedAt)}.${$}`}function X6(J){return e1(J.cause)>0}async function l0(){if(typeof navigator<"u"&&Boolean(navigator.mediaDevices?.getDisplayMedia)){let z=await F6();if(z.status==="ok")return{dataUrl:z.dataUrl,method:"display-media"};if(z.status==="cancelled")return{dataUrl:null,method:"cancelled"}}let $=await P6();if($)return{dataUrl:$,method:"html-to-image"};return{dataUrl:null,method:"none"}}async function F6(){let J=null;try{let $={video:{frameRate:30},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude"};J=await navigator.mediaDevices.getDisplayMedia($);let z=await H6(J);return z?{status:"ok",dataUrl:z}:{status:"error"}}catch($){if($ instanceof DOMException&&($.name==="NotAllowedError"||$.name==="AbortError"))return{status:"cancelled"};return{status:"error"}}finally{J?.getTracks().forEach(($)=>$.stop())}}async function H6(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 U6($);let{videoWidth:z,videoHeight:Q}=$;if(!z||!Q)return null;let j=document.createElement("canvas");j.width=z,j.height=Q;let Z=j.getContext("2d");if(!Z)return null;Z.drawImage($,0,0,z,Q),$.pause(),$.srcObject=null;try{return j.toDataURL("image/png")}catch{return null}}function U6(J){return new Promise(($)=>{let z=!1,Q=()=>{if(z)return;z=!0,$()},j=J;if(typeof j.requestVideoFrameCallback==="function")j.requestVideoFrameCallback(()=>Q()),window.setTimeout(Q,1000);else window.setTimeout(Q,250)})}async function P6(){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:(z)=>!(z instanceof HTMLElement&&z.dataset?.debugReporter==="true")})}catch{return null}}var M6=2000,D6=0.82,I6=3000000;function C6(J){return new Promise(($,z)=>{let Q=new Image;Q.onload=()=>$(Q),Q.onerror=()=>z(Error("could not read the screenshot")),Q.src=J})}async function Q2(J){try{let $=await C6(J),z=Math.max($.naturalWidth,$.naturalHeight),Q=Math.min(1,M6/z),j=document.createElement("canvas");j.width=Math.max(1,Math.round($.naturalWidth*Q)),j.height=Math.max(1,Math.round($.naturalHeight*Q));let Z=j.getContext("2d");if(!Z)return J;Z.fillStyle="#fff",Z.fillRect(0,0,j.width,j.height),Z.drawImage($,0,0,j.width,j.height);let W=D6,G=j.toDataURL("image/jpeg",W);while(G.length>I6&&W>0.4)W-=0.15,G=j.toDataURL("image/jpeg",W);return G}catch{return J}}var N6=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,q6=/^\d+$/,B6=/^[0-9a-f]{16,}$/i;function o0(J){if(J.reason.type==="manual")return null;let $=J.cause?.failedRequests?.[0];if(!$?.url)return null;let z;try{z=new URL($.url,"http://x").pathname}catch{z=$.url}let Q=z.split("/").map((Z)=>N6.test(Z)||q6.test(Z)||B6.test(Z)?":id":Z).join("/"),j=$.status??($.error?"ERR":"?");return`${$.method??"REQ"} ${Q} ${j}`}var r0=2000000;function q0(J){let{screenshotDataUrl:$,replay:z,...Q}=J;return JSON.stringify(Q).length}function n0(J,$=2000000){if(q0(J)<=$)return J;let z=J.network.map((j)=>({...j})),Q={...J,network:z};for(let j of z){if(q0(Q)<=$)return Q;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(Q.network.length>1&&q0(Q)>$)Q.network=Q.network.slice(1);while(Q.console.length>1&&q0(Q)>$)Q.console=Q.console.slice(1);return Q}function V0(J){let $="";for(let z=0;z<J.length;z+=32768)$+=String.fromCharCode(...J.subarray(z,z+32768));return btoa($)}var w6=4,S6=2,O6=3,_6=0,R6=new Set(["href","src","action","formaction","xlink:href","data","poster","srcset"]),L6=/^\s*javascript:/i;function A6(J,$){let z=J.toLowerCase();if(z.startsWith("on")||z==="srcdoc")return!0;return typeof $==="string"&&L6.test($)}function j2(J,$=!1){if(!J)return;for(let z of Object.keys(J)){let Q=J[z];if(A6(z,Q)){if($)J[z]=null;else delete J[z];continue}if(typeof Q!=="string"||!R6.has(z)||!Q.includes("?"))continue;J[z]=g(Q)}}function s0(J){if(!J)return;j2(J.attributes);for(let $ of J.childNodes??[])s0($)}function Z2(J){let $=JSON.parse(JSON.stringify(J));for(let z of $){let Q=z.data;if(!Q||typeof Q!=="object")continue;if(z.type===w6&&typeof Q.href==="string")Q.href=g(Q.href);else if(z.type===S6)s0(Q.node);else if(z.type===O6&&Q.source===_6){for(let j of Q.adds??[])s0(j.node);for(let j of Q.attributes??[])j2(j.attributes,!0)}}return $}var W2="session-replay.json.gz",x6="session-replay.json";function T6(J){return Boolean(J&&J.events.length>0)}async function k6(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 a0(J,$){if(!T6(J))return{summary:{omitted:"empty"}};let Q={seconds:Math.round(J.durationMs/1000),events:J.events.length,startedAt:J.startedAt,endedAt:J.endedAt},j=Z2(J.events),Z=await K2(j),W=!1;if(Z.bytes.byteLength>$&&h6(j))j=m6(j),Z=await K2(j),W=!0;let{bytes:G,compressed:F}=Z;if(G.byteLength>$)return{summary:{...Q,bytes:G.byteLength,omitted:"too-large"}};return{dataUri:`data:${F?"application/gzip":"application/json"};base64,${V0(G)}`,filename:F?W2:x6,summary:{...Q,events:j.length,bytes:G.byteLength,compressed:F,...W?{canvasDropped:W}:{}}}}async function K2(J){let $=new TextEncoder().encode(JSON.stringify({events:J})),z=await k6($);return z?{bytes:z,compressed:!0}:{bytes:$,compressed:!1}}var f6=3,Y2=2,E6=9;function G2(J){return J.type===f6&&J.data?.source===E6}function h6(J){return J.some(G2)||J.some(($)=>$.type===Y2&&V2($.data.node))}function V2(J){if(!J)return!1;if(J.attributes&&"rr_dataURL"in J.attributes)return!0;return(J.childNodes??[]).some(V2)}function X2(J){if(!J)return;if(J.attributes&&"rr_dataURL"in J.attributes)delete J.attributes.rr_dataURL;for(let $ of J.childNodes??[])X2($)}function m6(J){let $=[];for(let z of J){if(G2(z))continue;if(z.type===Y2)X2(z.data.node);$.push(z)}return $}var g6=new Set([502,503,504]);class b extends Error{kind;retryAfter;status;constructor(J,$,z,Q){super(J);this.kind=$;this.retryAfter=z;this.status=Q;this.name="ReportError"}}function b6(J){let{screenshotDataUrl:$,replay:z,...Q}=J;return{dataUri:`data:application/json;base64,${V0(new TextEncoder().encode(JSON.stringify(Q)))}`,filename:"debug-bundle.json"}}async function t0(){let J=w().identity;if(!J)return{};try{let $=await J();return $?{authorization:`Bearer ${$}`}:{}}catch{return{}}}async function e0(J,$){let z=w(),Q=n0($,r0),{context:j,note:Z}=Q,W=[];if(Q.screenshotDataUrl){let I=await Q2(Q.screenshotDataUrl);W.push({dataUri:I,filename:"screenshot.jpg"})}W.push(b6(Q));let G,F=W0();if(F){let I=await a0(Q.replay,F.maxBytes);if(G=I.summary,"dataUri"in I)W.push({dataUri:I.dataUri,filename:I.filename})}let P=o0(Q),q={title:J,description:Z.trim()||void 0,appName:m().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:Q.reason.type,appName:m().name,module:j.module?.label??""},context:{...P?{signature:P}:{},capturedAt:j.capturedAt,reason:Q.reason,cause:Q.cause,actionTrail:Q.actionTrail,client:j.client,performance:j.performance,apiHeaders:j.apiHeaders,extra:j.extra,counts:{network:Q.network.length,console:Q.console.length,actions:Q.actionTrail.length},screenshotMethod:Q.screenshotMethod,...G?{replay:G}:{}},attachments:W},M=await fetch(`${z.host.replace(/\/$/,"")}/ingest/tickets`,{method:"POST",headers:{"content-type":"application/json","x-realm-key":z.realmKey,...await t0()},body:JSON.stringify(q)}).catch(()=>{throw new b("report never left the browser","offline")});if(!M.ok)throw await J1(M);return await M.json()}async function J1(J){let $=J.headers.get("retry-after"),z=await J.json().then((Q)=>Q.error).catch(()=>null);if(J.status===429)return new b("rate limited","rateLimited",$??void 0);if(g6.has(J.status))return new b("desk unavailable","unavailable");return new b(z??`Report failed (${J.status})`,"rejected",void 0,J.status)}var B0=null,X0=null,F2=()=>w().host.replace(/\/$/,"");function $1(){return B0}function $0(){if(X0)return X0;return X0=(async()=>{try{let J=await fetch(`${F2()}/ingest/request-types`,{headers:{"x-realm-key":w().realmKey}}),$=J.ok?await J.json():null;B0=Array.isArray($?.types)?$.types.filter(y6):[]}catch{B0=[],X0=null}return B0??[]})(),X0}function y6(J){let $=J;return!!$&&typeof $.id==="string"&&typeof $.name==="string"}async function z1(J){let $=w(),z={};try{z=$.user?.()??{}}catch{z={}}let Q=typeof window>"u"?null:window.location,j={title:J.title,description:J.description.trim()||void 0,ticketTypeId:J.ticketTypeId,appName:m().name,category:Q?U0(Q.pathname)?.label:void 0,routeUrl:Q?.href,priority:"MEDIUM",requesterEmail:z.email??void 0,requesterName:z.fullName??void 0},Z=await fetch(`${F2()}/ingest/tickets`,{method:"POST",headers:{"content-type":"application/json","x-realm-key":$.realmKey,...await t0()},body:JSON.stringify(j)}).catch(()=>{throw new b("request never left the browser","offline")});if(!Z.ok)throw await J1(Z);return await Z.json()}var F0=Math.PI/6;function H2(J,$,z){let Q=$.x-J.x,j=$.y-J.y,Z=Math.hypot(Q,j),W=Math.atan2(j,Q),G=[{x:$.x,y:$.y},{x:$.x-z*Math.cos(W-F0),y:$.y-z*Math.sin(W-F0)},{x:$.x-z*Math.cos(W+F0),y:$.y-z*Math.sin(W+F0)}],F=z*Math.cos(F0)*0.92;if(Z<=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 Q1="#f44336",v6="rgba(250, 204, 21, 0.4)",j1=22,U2="#2563eb",P2=9,M2=11,D2=18,I2=4,w0=8,p6=[{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 Z1(J,$,z){let Q=[],j=null,Z=-1,W=null,G=null,F=J.getContext("2d");function P(){let K=J.getBoundingClientRect().width;return K>0?J.width/K:1}function q(K){let Y=J.getBoundingClientRect();return{x:(K.clientX-Y.left)/Y.width*J.width,y:(K.clientY-Y.top)/Y.height*J.height}}function M(K){let Y=K.size??j1;if(!F)return(K.text?.length??0)*Y*0.6;F.save(),F.font=`600 ${Y}px system-ui, sans-serif`;let X=F.measureText(K.text??"").width;return F.restore(),X}function I(K){if(K.tool==="text"){let Y=K.size??j1;return{left:K.x1,top:K.y1,right:K.x1+M(K),bottom:K.y1+Y*1.25}}return{left:Math.min(K.x1,K.x2),top:Math.min(K.y1,K.y2),right:Math.max(K.x1,K.x2),bottom:Math.max(K.y1,K.y2)}}function O(K){if(K.tool==="arrow")return[{id:"tail",x:K.x1,y:K.y1,cursor:"move"},{id:"head",x:K.x2,y:K.y2,cursor:"move"}];let Y=I(K);if(K.tool==="text")return[{id:"size",x:Y.right,y:Y.bottom,cursor:"nwse-resize"}];return p6.map((X)=>({id:X.id,x:Y.left+(Y.right-Y.left)*X.fx,y:Y.top+(Y.bottom-Y.top)*X.fy,cursor:X.cursor}))}function C(K){let Y=I(K);return{x:Y.right+D2*P(),y:Y.top-D2*P()}}function R(K,Y,X){let{shaft:V,head:H}=H2({x:Y.x1,y:Y.y1},{x:Y.x2,y:Y.y2},Math.max(10,16*X));if(V)K.lineCap="butt",K.beginPath(),K.moveTo(V.from.x,V.from.y),K.lineTo(V.to.x,V.to.y),K.stroke();K.beginPath(),K.moveTo(H[0].x,H[0].y),K.lineTo(H[1].x,H[1].y),K.lineTo(H[2].x,H[2].y),K.closePath(),K.fill()}function L(K,Y,X){K.save(),K.lineWidth=Math.max(2,3*X),K.strokeStyle=Q1,K.fillStyle=Q1;let V=I(Y);if(Y.tool==="rect")K.strokeRect(V.left,V.top,V.right-V.left,V.bottom-V.top);else if(Y.tool==="arrow")R(K,Y,X);else if(Y.tool==="highlight")K.fillStyle=v6,K.fillRect(V.left,V.top,V.right-V.left,V.bottom-V.top);else if(Y.tool==="text"&&Y.text){let H=Y.size??j1;K.font=`600 ${H}px system-ui, sans-serif`,K.textBaseline="top";let U=H*0.22;K.fillStyle="rgba(255,255,255,0.92)",K.fillRect(V.left-U,V.top-U,V.right-V.left+U*2,V.bottom-V.top+U*2),K.fillStyle=Q1,K.fillText(Y.text,V.left,V.top)}K.restore()}function D(K,Y,X){let V=I(Y);K.save(),K.strokeStyle=U2,K.lineWidth=Math.max(1,1.5*X),K.setLineDash([6*X,4*X]),K.strokeRect(V.left,V.top,V.right-V.left,V.bottom-V.top),K.setLineDash([]);let H=P2*X;for(let f of O(Y))K.fillStyle="#fff",K.strokeStyle=U2,K.lineWidth=Math.max(1,1.5*X),K.beginPath(),K.rect(f.x-H/2,f.y-H/2,H,H),K.fill(),K.stroke();let U=C(Y),B=M2*X;K.beginPath(),K.arc(U.x,U.y,B,0,Math.PI*2),K.fillStyle="#dc2626",K.fill(),K.strokeStyle="#fff",K.lineWidth=Math.max(1.5,2*X),K.beginPath(),K.moveTo(U.x-B*0.4,U.y-B*0.4),K.lineTo(U.x+B*0.4,U.y+B*0.4),K.moveTo(U.x+B*0.4,U.y-B*0.4),K.lineTo(U.x-B*0.4,U.y+B*0.4),K.stroke(),K.restore()}function N(){if(!F)return;let K=P();if(F.clearRect(0,0,J.width,J.height),F.drawImage($,0,0,J.width,J.height),Q.forEach((X,V)=>{if(V!==d)L(F,X,K)}),W)L(F,W,K);let Y=Q[Z];if(Y&&!W)D(F,Y,K)}function k(K,Y,X,V,H){return Math.abs(K-X)<=H&&Math.abs(Y-V)<=H}function j0(K,Y){let X=Q[Z];if(!X)return null;let V=P2*P()/2+3*P();for(let H of O(X))if(k(K,Y,H.x,H.y,V))return H.id;return null}function o(K,Y){let X=Q[Z];if(!X)return!1;let V=C(X);return k(K,Y,V.x,V.y,M2*P())}function y(K,Y){let X=6*P();for(let V=Q.length-1;V>=0;V-=1){let H=Q[V];if(H.tool==="arrow"){let B=H.x2-H.x1,f=H.y2-H.y1,c=Math.hypot(B,f)||1,i=Math.max(0,Math.min(1,((K-H.x1)*B+(Y-H.y1)*f)/(c*c)));if(Math.hypot(K-(H.x1+i*B),Y-(H.y1+i*f))<=X+4*P())return V;continue}let U=I(H);if(K>=U.left-X&&K<=U.right+X&&Y>=U.top-X&&Y<=U.bottom+X)return V}return-1}function u(K,Y,X,V,H){if(Y==="tail"){K.x1=X.x1+V,K.y1=X.y1+H;return}if(Y==="head"){K.x2=X.x2+V,K.y2=X.y2+H;return}if(Y==="size"){let T2=(X.size??24)+H;K.size=Math.max(10,T2);return}let U=I(X),{left:B,top:f,right:c,bottom:i}=U;if(Y.includes("w"))B=Math.min(c-w0,B+V);if(Y.includes("e"))c=Math.max(B+w0,c+V);if(Y.includes("n"))f=Math.min(i-w0,f+H);if(Y.includes("s"))i=Math.max(f+w0,i+H);K.x1=B,K.y1=f,K.x2=c,K.y2=i}function _0(K,Y,X,V){K.x1=Y.x1+X,K.y1=Y.y1+V,K.x2=Y.x2+X,K.y2=Y.y2+V}let A=null,d=-1,_={x:0,y:0,size:24};function h(){let K=J.getBoundingClientRect().width;return K>0?K/J.width:1}function x2(K,Y){if(!F)return K.length*Y*0.6;F.save(),F.font=`600 ${Y}px system-ui, sans-serif`;let X=F.measureText(K||" ").width;return F.restore(),X}function Y1(){if(!A)return;let K=J.parentElement;if(!K)return;let Y=J.getBoundingClientRect(),X=K.getBoundingClientRect(),V=h(),H=_.size*V;A.style.left=`${Y.left-X.left+_.x*V}px`,A.style.top=`${Y.top-X.top+_.y*V}px`,A.style.fontSize=`${H}px`,A.style.width=`${Math.max(40,x2(A.value,H)+H)}px`}function Z0(K){let Y=A;if(!Y)return;A=null;let X=Y.value.trim(),V=d;if(d=-1,Y.remove(),K&&X){if(V>=0&&Q[V])Q[V].text=X,Z=V;else Q.push({tool:"text",x1:_.x,y1:_.y,x2:_.x,y2:_.y,text:X,size:_.size}),Z=Q.length-1;z()}else if(V>=0)Z=V;J.focus(),N()}function G1(K,Y,X=-1){Z0(!0);let V=J.parentElement;if(!V)return;if(getComputedStyle(V).position==="static")V.style.position="relative";let H=X>=0?Q[X]:void 0;d=X,_={x:H?.x1??K,y:H?.y1??Y,size:H?.size??Math.round(24*P())};let U=document.createElement("input");U.type="text",U.className="text-edit",U.value=H?.text??"",U.setAttribute("aria-label","ข้อความบนภาพ"),U.placeholder="ข้อความ",A=U,V.append(U),Y1(),U.addEventListener("input",Y1),U.addEventListener("keydown",(B)=>{if(B.stopPropagation(),B.key==="Enter")Z0(!0);else if(B.key==="Escape")Z0(!1)}),requestAnimationFrame(()=>{if(A!==U)return;U.focus(),U.select(),U.addEventListener("blur",()=>Z0(!0))}),N()}function V1(K){let{x:Y,y:X}=q(K);if(J.setPointerCapture(K.pointerId),o(Y,X)){R0();return}let V=j0(Y,X);if(V&&Q[Z]){G={grip:V,x:Y,y:X,start:{...Q[Z]}};return}if(j==="text"){if(K.preventDefault(),J.hasPointerCapture(K.pointerId))J.releasePointerCapture(K.pointerId);j=null,z(),G1(Y,X);return}if(j){W={tool:j,x1:Y,y1:X,x2:Y,y2:X},Z=-1;return}let H=y(Y,X);Z=H,G=H>=0?{grip:"body",x:Y,y:X,start:{...Q[H]}}:null,N()}function X1(K){let{x:Y,y:X}=q(K);if(W){W.x2=Y,W.y2=X,N();return}if(G){let H=Q[Z];if(!H)return;let U=Y-G.x,B=X-G.y;if(G.grip==="body")_0(H,G.start,U,B);else u(H,G.grip,G.start,U,B);N();return}if(j){J.style.cursor="crosshair";return}if(o(Y,X)){J.style.cursor="pointer";return}let V=j0(Y,X);if(V){let H=Q[Z]?O(Q[Z]).find((U)=>U.id===V):null;J.style.cursor=H?.cursor??"pointer";return}J.style.cursor=y(Y,X)>=0?"move":"default"}function H0(){if(W){if(!(Math.abs(W.x2-W.x1)<I2&&Math.abs(W.y2-W.y1)<I2))Q.push(W),Z=Q.length-1,j=null,z();W=null}if(G)G=null,z();N()}function F1(K){let Y=J.getBoundingClientRect(),X=(K.clientX-Y.left)/Y.width*J.width,V=(K.clientY-Y.top)/Y.height*J.height,H=y(X,V),U=Q[H];if(!U||U.tool!=="text")return;K.preventDefault(),G1(U.x1,U.y1,H)}function H1(K){if(Z<0)return;if(K.key==="Delete"||K.key==="Backspace")K.preventDefault(),R0();else if(K.key==="Escape")Z=-1,N()}function R0(){if(Z<0)return;Q.splice(Z,1),Z=-1,z(),N()}return J.addEventListener("pointerdown",V1),J.addEventListener("pointermove",X1),J.addEventListener("pointerup",H0),J.addEventListener("pointercancel",H0),J.addEventListener("dblclick",F1),J.tabIndex=0,J.addEventListener("keydown",H1),N(),{setTool(K){j=K,Z=-1,J.style.cursor=K?"crosshair":"default",N()},deleteSelected:R0,clear(){Q.length=0,Z=-1,z(),N()},hasShapes:()=>Q.length>0,hasSelection:()=>Z>=0,toDataUrl(){let K=document.createElement("canvas");K.width=$.naturalWidth,K.height=$.naturalHeight;let Y=K.getContext("2d");if(!Y)return J.toDataURL("image/png");Y.drawImage($,0,0);let X=P();for(let V of Q)L(Y,V,X);return K.toDataURL("image/png")},destroy(){Z0(!1),J.removeEventListener("pointerdown",V1),J.removeEventListener("pointermove",X1),J.removeEventListener("pointerup",H0),J.removeEventListener("pointercancel",H0),J.removeEventListener("dblclick",F1),J.removeEventListener("keydown",H1)}}}var u6=["keydown","keyup","keypress"];function S0(J){for(let $ of u6)J.addEventListener($,(z)=>z.stopPropagation())}var C2=`
42
42
  :host { all: initial; }
43
43
  * { box-sizing: border-box; }
44
44
 
@@ -62,11 +62,11 @@ h2 { margin: 0; font-size: 20px; font-weight: 700; flex: 1; }
62
62
  label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
63
63
  .req { color: #dc2626; }
64
64
  .hint { font-weight: 400; color: #64748b; }
65
- input[type="text"], textarea {
65
+ input[type="text"], textarea, select {
66
66
  width: 100%; padding: 10px 12px; font: inherit; font-size: 14px;
67
67
  border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; color: inherit;
68
68
  }
69
- input[type="text"]:focus, textarea:focus {
69
+ input[type="text"]:focus, textarea:focus, select:focus {
70
70
  outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
71
71
  }
72
72
  textarea { min-height: 88px; resize: vertical; }
@@ -121,7 +121,20 @@ canvas { width: 100%; height: auto; display: block; border: 1px solid #e2e8f0; b
121
121
  border-radius: 0 0 16px 16px;
122
122
  }
123
123
  .foot .grow { flex: 1; }
124
- `;var $0="lw-debug-reporter";function f6(J,$){if(J instanceof c){if(J.kind==="offline")return $.failedOffline;if(J.kind==="unavailable")return $.failedUnavailable;if(J.kind==="rateLimited")return $.failedTooMany.replace("{seconds}",J.retryAfter??"60");return J.message||$.failed}return $.failed}var F2=()=>[];function E6(J){F2=J}var h6=[{tool:"rect",key:"toolRect"},{tool:"arrow",key:"toolArrow"},{tool:"highlight",key:"toolHighlight"},{tool:"text",key:"toolText"}];function m6(){return class extends HTMLElement{root;stop=null;annotator=null;bundle=null;busy=!1;constructor(){super();this.root=this.attachShadow({mode:"open"}),D0(this.root)}connectedCallback(){this.dataset.debugReporter="true",this.stop=x0(($)=>void this.open($))}disconnectedCallback(){this.stop?.(),this.stop=null,this.close()}async open($){if(this.busy)return;this.busy=!0;let Q=d(w().locale),j=await p0();if(j.method==="cancelled"){this.close();return}this.bundle=v0({reason:$,note:"",screenshotDataUrl:j.dataUrl,screenshotMethod:j.method,erroredQueries:g6()}),this.renderForm(Q)}close(){this.annotator?.destroy(),this.annotator=null,this.bundle=null,this.busy=!1,this.root.replaceChildren()}shell($){let Q=document.createElement("style");Q.textContent=X2;let j=document.createElement("div");j.className="backdrop";let z=document.createElement("div");return z.className="panel",z.setAttribute("role","dialog"),z.setAttribute("aria-modal","true"),z.setAttribute("aria-label",$.title),j.append(z),this.root.replaceChildren(Q,j),z}renderShell($,Q){let j=this.shell($),z=k("div","head");z.append(k("h2","",$.title)),j.append(z,k("p","status",Q))}renderForm($){let Q=this.bundle;if(!Q)return;let j=this.shell($),z=k("div","head"),K=J0("✕","icon");K.setAttribute("aria-label",$.close),K.addEventListener("click",()=>this.close()),z.append(k("h2","",$.title),K);let W=document.createElement("input");W.type="text",W.placeholder=$.summaryPlaceholder;let G=a0($.summaryLabel,$.summaryRequired,!0),F=document.createElement("textarea");F.placeholder=$.detailPlaceholder;let P=k("div","meta");P.innerHTML="";let{context:B}=Q;for(let[R,_]of[[$.reporter,`${B.user.fullName??"—"} (${B.user.email??"—"})`],[$.page,B.route.href],[$.captured,`${Q.network.length} network · ${Q.console.length} console · ${Q.actionTrail.length} actions${Q.replay?` · ${$.replay} ${Math.round(Q.replay.durationMs/1000)}s`:""}`]]){let q=document.createElement("div"),O=document.createElement("b");O.textContent=`${R}: `,q.append(O,document.createTextNode(_)),P.append(q)}let M=k("p","status",""),C=J0($.submit,"primary");if(C.disabled=!0,W.addEventListener("input",()=>{C.disabled=W.value.trim().length===0}),j.append(z,G,W,a0($.detailLabel),F,P),Q.screenshotDataUrl)j.append(...this.screenshotSection($,Q.screenshotDataUrl));else j.append(k("p","status",$.noScreenshot));let S=k("div","foot"),D=J0($.close);D.addEventListener("click",()=>this.close()),S.append(D,M,k("span","grow"),C),j.append(S),C.addEventListener("click",async()=>{C.disabled=!0,M.dataset.tone="",M.textContent=$.submitting;try{let R=await o0(W.value.trim(),{...Q,note:F.value,screenshotDataUrl:this.annotator?.hasShapes()?this.annotator.toDataUrl():Q.screenshotDataUrl}),_=this.dispatchEvent(new CustomEvent("lw-report-submitted",{detail:R,bubbles:!0,composed:!0,cancelable:!0}));if(this.close(),_)e(`${$.submitted} — #${R.number}`,"success")}catch(R){let _=f6(R,$);M.dataset.tone="error",M.textContent=_,e(_,"error"),C.disabled=!1}}),W.focus()}screenshotSection($,Q){let j=a0($.annotateHint),z=k("div","tools"),K=document.createElement("canvas"),W=k("div","shot");W.append(K);let G=[],F=(C)=>{for(let S of G)S.setAttribute("aria-pressed",String(S===C))};for(let{tool:C,key:S}of h6){let D=J0($[S]);D.setAttribute("aria-pressed","false"),D.addEventListener("click",()=>{let R=D.getAttribute("aria-pressed")==="true";F(R?null:D),this.annotator?.setTool(R?null:C)}),G.push(D),z.append(D)}z.append(k("span","sep"));let P=J0($.deleteSelected);P.addEventListener("click",()=>this.annotator?.deleteSelected());let B=J0($.clearAll);B.addEventListener("click",()=>{this.annotator?.clear(),F(null)}),z.append(P,B);let M=new Image;return M.onload=()=>{K.width=M.naturalWidth,K.height=M.naturalHeight,this.annotator=n0(K,M,()=>{F(null),P.disabled=!this.annotator?.hasSelection()})},M.src=Q,[j,z,k("p","status",$.annotateHelp),W]}}}function g6(){try{return F2()}catch{return[]}}function k(J,$="",Q=""){let j=document.createElement(J);if($)j.className=$;if(Q)j.textContent=Q;return j}function J0(J,$=""){let Q=document.createElement("button");if(Q.type="button",Q.textContent=J,$)Q.className=$;return Q}function a0(J,$="",Q=!1){let j=document.createElement("label");if(j.append(document.createTextNode(J)),Q){let z=document.createElement("span");z.className="req",z.textContent=" *",j.append(z)}if($){let z=document.createElement("span");z.className="hint",z.textContent=` ${$}`,j.append(z)}return j}function t0(){if(typeof window>"u"||customElements.get($0))return;customElements.define($0,m6())}var H2=!1;function y6(J={}){if(H2||typeof window>"u")return;if(!z0()){console.error("[debug-capture] configureDebugCapture() must be called before install");return}if(H2=!0,u1(),O1(),q1(),f1(),c1(),J.ui===!1)return;let $=d(w().locale);if(E0((Q)=>{e(Q.message??$.crashed,"error",{label:$.crashAction,onClick:()=>f0(Q)})}),t0(),!document.querySelector($0))document.body.append(document.createElement($0))}var b6=new Set(["error","exception","unhandledrejection"]);function U2(J){if(J.error)return!0;return J.status!==null&&J.status>=400}function e0(J){if(!J)return null;let $=Date.parse(J);return Number.isNaN($)?null:$}function v6(J){try{let{pathname:$}=new URL(J,"http://x");try{return decodeURIComponent($)}catch{return $}}catch{return J.split(/[?#]/)[0]??J}}function p6(J,$,Q){let j=(W)=>({elapsedMs:W,requests:[],failedRequests:[],consoleErrors:[],slowestMs:null});if(J.length===0)return[];let z=J.map((W)=>e0(W.at)),K=(W)=>{for(let G=W+1;G<z.length;G+=1){let F=z[G];if(F!=null)return F}return Number.POSITIVE_INFINITY};return J.map((W,G)=>{let F=z[G]??null,P=(G>0?z[G-1]:null)??null,B=F!==null&&P!==null?Math.max(0,F-P):null;if(F===null)return j(B);let M=F,C=Math.max(M,K(G)),S=(q)=>q!==null&&q>=M&&(q<C||C===Number.POSITIVE_INFINITY),D=$.filter((q)=>S(e0(q.startedAt))),R=Q.filter((q)=>b6.has(q.level)&&S(e0(q.at))),_=D.map((q)=>q.durationMs).filter((q)=>typeof q==="number");return{elapsedMs:B,requests:D,failedRequests:D.filter(U2),consoleErrors:R,slowestMs:_.length>0?Math.max(..._):null}})}function u6(J,$){return J.requests.length===0&&J.consoleErrors.length===0&&(J.elapsedMs===null||J.elapsedMs<$)}function d6(J){if(J<1000)return`${Math.round(J)} มิลลิวินาที`;let $=J/1000;if($<10)return`${$.toFixed(1)} วิ`;if($<60)return`${Math.round($)} วิ`;let Q=Math.floor($/60),j=Math.round($%60);return j===0?`${Q} นาที`:`${Q} นาที ${j} วิ`}var c6="lw-portal-handoff",P2=138.23,i6=`
124
+
125
+ /* ขอให้ทีมดำเนินการ: the chooser and the request form — a smaller dialog, no image in it. */
126
+ .panel.narrow { width: min(560px, 100%); }
127
+ .choices { display: grid; gap: 10px; padding-bottom: 24px; }
128
+ button.choice {
129
+ display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
130
+ width: 100%; padding: 14px 16px; text-align: left; border-radius: 12px;
131
+ }
132
+ button.choice b { font-size: 15px; font-weight: 600; }
133
+ button.choice span { font-size: 13px; font-weight: 400; color: #64748b; }
134
+ button.choice:focus-visible { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18); }
135
+ .panel.narrow p { margin: 0; }
136
+ .ask-type { font-size: 14px; font-weight: 600; margin-top: -8px; }
137
+ `;var Q0="lw-debug-reporter";function N2(J,$){if(J instanceof b){if(J.kind==="offline")return $.failedOffline;if(J.kind==="unavailable")return $.failedUnavailable;if(J.kind==="rateLimited")return $.failedTooMany.replace("{seconds}",J.retryAfter??"60");return J.message||$.failed}return $.failed}var B2=()=>[];function d6(J){B2=J}var c6=[{tool:"rect",key:"toolRect"},{tool:"arrow",key:"toolArrow"},{tool:"highlight",key:"toolHighlight"},{tool:"text",key:"toolText"}];function i6(){return class extends HTMLElement{root;stop=null;annotator=null;bundle=null;busy=!1;constructor(){super();this.root=this.attachShadow({mode:"open"}),S0(this.root)}connectedCallback(){this.dataset.debugReporter="true",this.stop=g0(($)=>void this.open($))}disconnectedCallback(){this.stop?.(),this.stop=null,this.close()}async open($){if(this.busy)return;this.busy=!0;let z=l(w().locale);if($.type==="manual"){let Q=$1();if(Q?.length){this.renderChooser(z,$,Q);return}if(Q===null)$0()}await this.report($,z)}async report($,z){let Q=await l0();if(Q.method==="cancelled"){this.close();return}this.bundle=i0({reason:$,note:"",screenshotDataUrl:Q.dataUrl,screenshotMethod:Q.method,erroredQueries:l6()}),this.renderForm(z)}renderChooser($,z,Q){let j=this.shell($);j.classList.add("narrow"),j.setAttribute("aria-label",$.chooseTitle);let Z=S("div","head"),W=E("✕","icon");W.setAttribute("aria-label",$.close),W.addEventListener("click",()=>this.close()),Z.append(S("h2","",$.chooseTitle),W);let G=q2($.chooseProblem,$.chooseProblemHint);G.dataset.choose="problem",G.addEventListener("click",()=>{this.root.replaceChildren(),this.report(z,$)});let F=q2($.chooseRequest,$.chooseRequestHint);F.dataset.choose="request",F.addEventListener("click",()=>this.renderRequestForm($,z,Q));let P=S("div","choices");P.append(G,F),j.append(Z,P),G.focus()}renderRequestForm($,z,Q){let j=this.shell($);j.classList.add("narrow"),j.setAttribute("aria-label",$.requestTitle);let Z=S("div","head"),W=E("✕","icon");W.setAttribute("aria-label",$.close),W.addEventListener("click",()=>this.close()),Z.append(S("h2","",$.requestTitle),W);let G=Q[0],F=S("p","status",""),P=()=>{let D=[G.description,G.targetHours?$.requestTarget.replace("{time}",o6($,G.targetHours)):""].filter(Boolean);F.textContent=D.join(" · ")},q=[z0($.requestTypeLabel,"",!0)];if(Q.length>1){let D=document.createElement("select");D.dataset.requestType="";for(let N of Q){let k=document.createElement("option");k.value=N.id,k.textContent=N.name,D.append(k)}D.addEventListener("change",()=>{G=Q.find((N)=>N.id===D.value)??G,P()}),q.push(D)}else q.push(S("p","ask-type",G.name));P();let M=document.createElement("input");M.type="text",M.placeholder=$.requestSummaryPlaceholder,M.maxLength=300;let I=document.createElement("textarea");I.placeholder=$.requestDetailPlaceholder;let O=S("p","status",""),C=E($.requestSubmit,"primary");C.disabled=!0,M.addEventListener("input",()=>{C.disabled=M.value.trim().length===0});let R=E($.back);R.addEventListener("click",()=>this.renderChooser($,z,Q));let L=S("div","foot");L.append(R,O,S("span","grow"),C),j.append(Z,...q,F,z0($.requestSummaryLabel,"",!0),M,z0($.requestDetailLabel),I,L),C.addEventListener("click",async()=>{C.disabled=!0,O.dataset.tone="",O.textContent=$.submitting;try{let D=await z1({ticketTypeId:G.id,title:M.value.trim(),description:I.value}),N=this.dispatchEvent(new CustomEvent("lw-request-submitted",{detail:D,bubbles:!0,composed:!0,cancelable:!0}));if(this.close(),N)p(`${$.requestSubmitted} — #${D.number}`,"success")}catch(D){let N=N2(D,$);O.dataset.tone="error",O.textContent=N,p(N,"error"),C.disabled=!1}}),M.focus()}close(){this.annotator?.destroy(),this.annotator=null,this.bundle=null,this.busy=!1,this.root.replaceChildren()}shell($){let z=document.createElement("style");z.textContent=C2;let Q=document.createElement("div");Q.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),Q.append(j),this.root.replaceChildren(z,Q),j}renderShell($,z){let Q=this.shell($),j=S("div","head");j.append(S("h2","",$.title)),Q.append(j,S("p","status",z))}renderForm($){let z=this.bundle;if(!z)return;let Q=this.shell($),j=S("div","head"),Z=E("✕","icon");Z.setAttribute("aria-label",$.close),Z.addEventListener("click",()=>this.close()),j.append(S("h2","",$.title),Z);let W=document.createElement("input");W.type="text",W.placeholder=$.summaryPlaceholder;let G=z0($.summaryLabel,$.summaryRequired,!0),F=document.createElement("textarea");F.placeholder=$.detailPlaceholder;let P=S("div","meta");P.innerHTML="";let{context:q}=z;for(let[R,L]of[[$.reporter,`${q.user.fullName??"—"} (${q.user.email??"—"})`],[$.page,q.route.href],[$.captured,`${z.network.length} network · ${z.console.length} console · ${z.actionTrail.length} actions${z.replay?` · ${$.replay} ${Math.round(z.replay.durationMs/1000)}s`:""}`]]){let D=document.createElement("div"),N=document.createElement("b");N.textContent=`${R}: `,D.append(N,document.createTextNode(L)),P.append(D)}let M=S("p","status",""),I=E($.submit,"primary");if(I.disabled=!0,W.addEventListener("input",()=>{I.disabled=W.value.trim().length===0}),Q.append(j,G,W,z0($.detailLabel),F,P),z.screenshotDataUrl)Q.append(...this.screenshotSection($,z.screenshotDataUrl));else Q.append(S("p","status",$.noScreenshot));let O=S("div","foot"),C=E($.close);C.addEventListener("click",()=>this.close()),O.append(C,M,S("span","grow"),I),Q.append(O),I.addEventListener("click",async()=>{I.disabled=!0,M.dataset.tone="",M.textContent=$.submitting;try{let R=await e0(W.value.trim(),{...z,note:F.value,screenshotDataUrl:this.annotator?.hasShapes()?this.annotator.toDataUrl():z.screenshotDataUrl}),L=this.dispatchEvent(new CustomEvent("lw-report-submitted",{detail:R,bubbles:!0,composed:!0,cancelable:!0}));if(this.close(),L)p(`${$.submitted} — #${R.number}`,"success")}catch(R){let L=N2(R,$);M.dataset.tone="error",M.textContent=L,p(L,"error"),I.disabled=!1}}),W.focus()}screenshotSection($,z){let Q=z0($.annotateHint),j=S("div","tools"),Z=document.createElement("canvas"),W=S("div","shot");W.append(Z);let G=[],F=(I)=>{for(let O of G)O.setAttribute("aria-pressed",String(O===I))};for(let{tool:I,key:O}of c6){let C=E($[O]);C.setAttribute("aria-pressed","false"),C.addEventListener("click",()=>{let R=C.getAttribute("aria-pressed")==="true";F(R?null:C),this.annotator?.setTool(R?null:I)}),G.push(C),j.append(C)}j.append(S("span","sep"));let P=E($.deleteSelected);P.addEventListener("click",()=>this.annotator?.deleteSelected());let q=E($.clearAll);q.addEventListener("click",()=>{this.annotator?.clear(),F(null)}),j.append(P,q);let M=new Image;return M.onload=()=>{Z.width=M.naturalWidth,Z.height=M.naturalHeight,this.annotator=Z1(Z,M,()=>{F(null),P.disabled=!this.annotator?.hasSelection()})},M.src=z,[Q,j,S("p","status",$.annotateHelp),W]}}}function l6(){try{return B2()}catch{return[]}}function S(J,$="",z=""){let Q=document.createElement(J);if($)Q.className=$;if(z)Q.textContent=z;return Q}function o6(J,$){return $>=24&&$%24===0?J.days.replace("{n}",String($/24)):J.hours.replace("{n}",String($))}function q2(J,$){let z=E("","choice"),Q=document.createElement("b");Q.textContent=J;let j=document.createElement("span");return j.textContent=$,z.append(Q,j),z}function E(J,$=""){let z=document.createElement("button");if(z.type="button",z.textContent=J,$)z.className=$;return z}function z0(J,$="",z=!1){let Q=document.createElement("label");if(Q.append(document.createTextNode(J)),z){let j=document.createElement("span");j.className="req",j.textContent=" *",Q.append(j)}if($){let j=document.createElement("span");j.className="hint",j.textContent=` ${$}`,Q.append(j)}return Q}function K1(){if(typeof window>"u"||customElements.get(Q0))return;customElements.define(Q0,i6())}var w2=!1;function r6(J={}){if(w2||typeof window>"u")return;if(!K0()){console.error("[debug-capture] configureDebugCapture() must be called before install");return}if(w2=!0,n1(),k1(),R1(),v1(),a1(),J.ui===!1)return;let $=l(w().locale);if(y0((Q)=>{p(Q.message??$.crashed,"error",{label:$.crashAction,onClick:()=>b0(Q)})}),K1(),!document.querySelector(Q0))document.body.append(document.createElement(Q0));let z=window.requestIdleCallback;if(z)z(()=>void $0(),{timeout:5000});else setTimeout(()=>void $0(),2000)}var n6=new Set(["error","exception","unhandledrejection"]);function S2(J){if(J.error)return!0;return J.status!==null&&J.status>=400}function W1(J){if(!J)return null;let $=Date.parse(J);return Number.isNaN($)?null:$}function s6(J){try{let{pathname:$}=new URL(J,"http://x");try{return decodeURIComponent($)}catch{return $}}catch{return J.split(/[?#]/)[0]??J}}function a6(J,$,z){let Q=(W)=>({elapsedMs:W,requests:[],failedRequests:[],consoleErrors:[],slowestMs:null});if(J.length===0)return[];let j=J.map((W)=>W1(W.at)),Z=(W)=>{for(let G=W+1;G<j.length;G+=1){let F=j[G];if(F!=null)return F}return Number.POSITIVE_INFINITY};return J.map((W,G)=>{let F=j[G]??null,P=(G>0?j[G-1]:null)??null,q=F!==null&&P!==null?Math.max(0,F-P):null;if(F===null)return Q(q);let M=F,I=Math.max(M,Z(G)),O=(D)=>D!==null&&D>=M&&(D<I||I===Number.POSITIVE_INFINITY),C=$.filter((D)=>O(W1(D.startedAt))),R=z.filter((D)=>n6.has(D.level)&&O(W1(D.at))),L=C.map((D)=>D.durationMs).filter((D)=>typeof D==="number");return{elapsedMs:q,requests:C,failedRequests:C.filter(S2),consoleErrors:R,slowestMs:L.length>0?Math.max(...L):null}})}function t6(J,$){return J.requests.length===0&&J.consoleErrors.length===0&&(J.elapsedMs===null||J.elapsedMs<$)}function e6(J){if(J<1000)return`${Math.round(J)} มิลลิวินาที`;let $=J/1000;if($<10)return`${$.toFixed(1)} วิ`;if($<60)return`${Math.round($)} วิ`;let z=Math.floor($/60),Q=Math.round($%60);return Q===0?`${z} นาที`:`${z} นาที ${Q} วิ`}var J8="lw-portal-handoff",O2=138.23,$8=`
125
138
  :host { all: initial; }
126
139
  .backdrop {
127
140
  position: fixed; inset: 0; z-index: 2147483002;
@@ -151,10 +164,10 @@ canvas { width: 100%; height: auto; display: block; border: 1px solid #e2e8f0; b
151
164
  .ring .track { stroke: #e2e8f0; }
152
165
  .ring .bar {
153
166
  stroke: #0ea5e9; transform: rotate(-90deg); transform-origin: 50% 50%;
154
- stroke-dasharray: ${P2}; stroke-dashoffset: 0;
167
+ stroke-dasharray: ${O2}; stroke-dashoffset: 0;
155
168
  animation: deplete var(--secs, 3s) linear forwards;
156
169
  }
157
- @keyframes deplete { to { stroke-dashoffset: ${P2}; } }
170
+ @keyframes deplete { to { stroke-dashoffset: ${O2}; } }
158
171
  .count {
159
172
  position: absolute; inset: 0; display: grid; place-items: center;
160
173
  font-size: 18px; font-weight: 600; color: #0f172a;
@@ -198,7 +211,7 @@ p { margin: 0; font-size: 13px; line-height: 1.6; color: #475569; }
198
211
  .ring .bar { animation: none; stroke-dashoffset: 0; }
199
212
  .spinner { animation-duration: 2s; }
200
213
  }
201
- `;function M2(J){if(typeof document>"u")return J.prepare().then((q)=>void J.go(q),()=>{return});let $=d(w().locale),Q=Math.max(1,Math.floor(J.seconds??3)),j=document.createElement(c6),z=j.attachShadow({mode:"open"});D0(z);let K=document.createElement("style");K.textContent=i6,z.append(K);let W=document.createElement("div");W.className="backdrop",W.innerHTML=`
214
+ `;function _2(J){if(typeof document>"u")return J.prepare().then((D)=>void J.go(D),()=>{return});let $=l(w().locale),z=Math.max(1,Math.floor(J.seconds??3)),Q=document.createElement(J8),j=Q.attachShadow({mode:"open"});S0(j);let Z=document.createElement("style");Z.textContent=$8,j.append(Z);let W=document.createElement("div");W.className="backdrop",W.innerHTML=`
202
215
  <div class="card" role="dialog" aria-modal="true" aria-labelledby="lw-ho-title">
203
216
  <div class="dial">
204
217
  <svg class="ring" viewBox="0 0 52 52" aria-hidden="true">
@@ -214,4 +227,4 @@ p { margin: 0; font-size: 13px; line-height: 1.6; color: #475569; }
214
227
  <button type="button" class="cancel"></button>
215
228
  <button type="button" class="go"></button>
216
229
  </div>
217
- </div>`,z.append(W);let G=(q)=>W.querySelector(q),F=G(".card"),P=G(".bar"),B=G(".count"),M=G("h2"),C=G(".body"),S=G(".host"),D=G(".go"),R=G(".cancel");M.textContent=$.handoffTitle,C.textContent=$.handoffBody;try{S.textContent=new URL(w().host).host}catch{S.textContent=""}D.textContent=$.handoffGo,R.textContent=$.cancel,F.style.setProperty("--secs",`${Q}s`),B.textContent=String(Q),document.body.append(j),requestAnimationFrame(()=>W.setAttribute("data-open","1"));let _=document.activeElement;return D.focus({preventScroll:!0}),new Promise((q)=>{let O=!1,y=null,Q0=!1,i=Date.now()+Q*1000,h=window.setInterval(()=>{let N=Math.ceil((i-Date.now())/1000);if(B.textContent=String(Math.max(0,N)),Date.now()>=i)L()},100);function b(N){if(O)return;if(O=!0,window.clearInterval(h),document.removeEventListener("keydown",v,!0),W.removeAttribute("data-open"),window.setTimeout(()=>j.remove(),200),!N)_?.focus?.({preventScroll:!0});q()}function B0(N){window.clearInterval(h),P.classList.remove("spinner"),P.style.animation="none",B.textContent="",M.textContent=$.handoffBlocked,C.textContent=$.handoffBody;let f=document.createElement("a");f.className="go",f.href=N,f.target="_blank",f.rel="noopener noreferrer",f.textContent=$.handoffOpen,f.addEventListener("click",()=>b(!0)),D.replaceWith(f),f.focus({preventScroll:!0})}function L(){if(O||Q0)return;if(y)return J.go(y)?b(!0):B0(y);window.clearInterval(h),B.textContent="",P.classList.add("spinner"),M.textContent=$.handoffPreparing}function v(N){if(N.key==="Escape")N.stopPropagation(),b(!1)}document.addEventListener("keydown",v,!0),D.addEventListener("click",L),R.addEventListener("click",()=>b(!1)),W.addEventListener("click",(N)=>{if(N.target===W)b(!1)}),J.prepare().then((N)=>{if(y=N,!O&&Date.now()>=i)L()},()=>{Q0=!0,window.clearInterval(h),F.classList.add("error"),P.classList.remove("spinner"),P.style.animation="none",B.textContent="",M.textContent=$.handoffFailed,C.textContent=$.handoffBody,D.remove(),R.textContent=$.close})})}var l6="/sso";function D2(J,$,Q,j){let z=new URL(l6,J.endsWith("/")?J:`${J}/`);if(z.searchParams.set("realm",$),z.searchParams.set("token",Q),j)z.searchParams.set("return",j);return z.toString()}class q0 extends Error{constructor(J="No identity provider is configured, or nobody is signed in"){super(J);this.name="NoIdentityError"}}async function C2(J){let $=w();if(!$.identity)throw new q0;let Q=await $.identity();if(!Q)throw new q0;return D2($.host,$.realmKey,Q,J)}function I2(J,$){if($==="_self")return window.location.assign(J),!0;let Q=window.open(J,"_blank");if(!Q)return!1;try{Q.opener=null}catch{}return!0}async function o6(J={}){if(J.announce===!1){I2(await C2(J.returnTo),J.target);return}await M2({seconds:J.seconds,prepare:()=>C2(J.returnTo),go:($)=>I2($,J.target)})}export{c0 as trimToBudget,s1 as toCurl,g0 as takeReplay,D2 as supportPortalUrl,o0 as submitBundle,m4 as stopReplay,e as showToast,E6 as setErroredQueriesSource,v6 as requestPath,d as reporterStrings,E as redactUrl,o as redactLabel,r as redactHeaders,s as redactBody,l0 as packReplay,o6 as openSupportPortal,x0 as onLaunch,E0 as onCrash,k2 as moduleResolver,f0 as launch,h4 as isReplayRecording,u6 as isQuietStep,U2 as isFailedRequest,z0 as isConfigured,y6 as installDebugCapture,$6 as hasCause,m0 as getNetworkLog,A0 as getConsoleLog,w as getConfig,k0 as getActionTrail,d6 as formatDuration,u0 as errorSignature,h0 as emitCrash,t0 as defineReporterElement,n0 as createAnnotator,p6 as correlateActionTrail,S2 as configureDebugCapture,p0 as captureScreen,t4 as bundleToMarkdown,J6 as bundleFileName,v0 as buildBundle,m as appInfo,_0 as actionCountSuffix,$0 as REPORTER_TAG,J2 as REPLAY_FILENAME,l as REDACTED,q0 as NoIdentityError,d0 as BUNDLE_BUDGET_BYTES};
230
+ </div>`,j.append(W);let G=(D)=>W.querySelector(D),F=G(".card"),P=G(".bar"),q=G(".count"),M=G("h2"),I=G(".body"),O=G(".host"),C=G(".go"),R=G(".cancel");M.textContent=$.handoffTitle,I.textContent=$.handoffBody;try{O.textContent=new URL(w().host).host}catch{O.textContent=""}C.textContent=$.handoffGo,R.textContent=$.cancel,F.style.setProperty("--secs",`${z}s`),q.textContent=String(z),document.body.append(Q),requestAnimationFrame(()=>W.setAttribute("data-open","1"));let L=document.activeElement;return C.focus({preventScroll:!0}),new Promise((D)=>{let N=!1,k=null,j0=!1,o=Date.now()+z*1000,y=window.setInterval(()=>{let _=Math.ceil((o-Date.now())/1000);if(q.textContent=String(Math.max(0,_)),Date.now()>=o)A()},100);function u(_){if(N)return;if(N=!0,window.clearInterval(y),document.removeEventListener("keydown",d,!0),W.removeAttribute("data-open"),window.setTimeout(()=>Q.remove(),200),!_)L?.focus?.({preventScroll:!0});D()}function _0(_){window.clearInterval(y),P.classList.remove("spinner"),P.style.animation="none",q.textContent="",M.textContent=$.handoffBlocked,I.textContent=$.handoffBody;let h=document.createElement("a");h.className="go",h.href=_,h.target="_blank",h.rel="noopener noreferrer",h.textContent=$.handoffOpen,h.addEventListener("click",()=>u(!0)),C.replaceWith(h),h.focus({preventScroll:!0})}function A(){if(N||j0)return;if(k)return J.go(k)?u(!0):_0(k);window.clearInterval(y),q.textContent="",P.classList.add("spinner"),M.textContent=$.handoffPreparing}function d(_){if(_.key==="Escape")_.stopPropagation(),u(!1)}document.addEventListener("keydown",d,!0),C.addEventListener("click",A),R.addEventListener("click",()=>u(!1)),W.addEventListener("click",(_)=>{if(_.target===W)u(!1)}),J.prepare().then((_)=>{if(k=_,!N&&Date.now()>=o)A()},()=>{j0=!0,window.clearInterval(y),F.classList.add("error"),P.classList.remove("spinner"),P.style.animation="none",q.textContent="",M.textContent=$.handoffFailed,I.textContent=$.handoffBody,C.remove(),R.textContent=$.close})})}var z8="/sso";function A2(J,$,z,Q){let j=new URL(z8,J.endsWith("/")?J:`${J}/`);if(j.searchParams.set("realm",$),j.searchParams.set("token",z),Q)j.searchParams.set("return",Q);return j.toString()}class O0 extends Error{constructor(J="No identity provider is configured, or nobody is signed in"){super(J);this.name="NoIdentityError"}}async function R2(J){let $=w();if(!$.identity)throw new O0;let z=await $.identity();if(!z)throw new O0;return A2($.host,$.realmKey,z,J)}function L2(J,$){if($==="_self")return window.location.assign(J),!0;let z=window.open(J,"_blank");if(!z)return!1;try{z.opener=null}catch{}return!0}async function Q8(J={}){if(J.announce===!1){L2(await R2(J.returnTo),J.target);return}await _2({seconds:J.seconds,prepare:()=>R2(J.returnTo),go:($)=>L2($,J.target)})}export{n0 as trimToBudget,z2 as toCurl,u0 as takeReplay,A2 as supportPortalUrl,z1 as submitRequest,e0 as submitBundle,l4 as stopReplay,p as showToast,d6 as setErroredQueriesSource,$1 as requestTypesNow,s6 as requestPath,l as reporterStrings,g as redactUrl,n as redactLabel,s as redactHeaders,a as redactBody,a0 as packReplay,Q8 as openSupportPortal,g0 as onLaunch,y0 as onCrash,y2 as moduleResolver,$0 as loadRequestTypes,b0 as launch,i4 as isReplayRecording,t6 as isQuietStep,S2 as isFailedRequest,K0 as isConfigured,r6 as installDebugCapture,X6 as hasCause,p0 as getNetworkLog,m0 as getConsoleLog,w as getConfig,E0 as getActionTrail,e6 as formatDuration,o0 as errorSignature,v0 as emitCrash,K1 as defineReporterElement,Z1 as createAnnotator,a6 as correlateActionTrail,E2 as configureDebugCapture,l0 as captureScreen,Y6 as bundleToMarkdown,V6 as bundleFileName,i0 as buildBundle,m as appInfo,k0 as actionCountSuffix,Q0 as REPORTER_TAG,W2 as REPLAY_FILENAME,r as REDACTED,O0 as NoIdentityError,r0 as BUNDLE_BUDGET_BYTES};
@@ -0,0 +1,29 @@
1
+ import { type FiledTicket } from "./submit";
2
+ export interface RequestTypeOption {
3
+ id: string;
4
+ name: string;
5
+ description: string;
6
+ /** How long the team means to take, in hours — null when it has not said. */
7
+ targetHours: number | null;
8
+ }
9
+ /** What the desk opens to its reporters, as far as is known right now — null before the first read lands. */
10
+ export declare function requestTypesNow(): RequestTypeOption[] | null;
11
+ /**
12
+ * Ask the desk once. Never throws: a desk that answers nothing useful — an
13
+ * older one without the endpoint (404), a network blip — offers nothing, and
14
+ * the widget stays a report button.
15
+ */
16
+ export declare function loadRequestTypes(): Promise<RequestTypeOption[]>;
17
+ /** Forget what was read — for tests, and for a host that changes realm. */
18
+ export declare function resetRequestTypes(): void;
19
+ /**
20
+ * Send a request. The same door as a report (POST /ingest/tickets), with the
21
+ * type it asks for — the desk starts its steps and never folds two people's
22
+ * same request into one. Who is asking comes from the identity token when the
23
+ * host has one, as for a report.
24
+ */
25
+ export declare function submitRequest(input: {
26
+ ticketTypeId: string;
27
+ title: string;
28
+ description: string;
29
+ }): Promise<FiledTicket>;
package/dist/server.d.ts CHANGED
@@ -1,10 +1,36 @@
1
+ /**
2
+ * One fact about a person's WORK, as the host knows it — their unit, their
3
+ * position — with the host's own label for it. The support desk shows these
4
+ * beside the person's name and records them with what the person does (an
5
+ * event registration takes them as its own), so nobody types their unit into
6
+ * a form the host could have filled.
7
+ *
8
+ * `key` is stable across people (it names a column in an export); `label` is
9
+ * what a person reads, in the host's language. Order matters: the first is
10
+ * the one drawn under a name.
11
+ */
12
+ export interface SupportProfileFact {
13
+ key: string;
14
+ label: string;
15
+ value: string;
16
+ }
1
17
  /** Whoever the host has authenticated. Email is the account key. */
2
18
  export interface SupportUser {
3
19
  /** The host's own id for this person, recorded so a changed email still matches. */
4
20
  id?: string | null;
5
21
  email: string;
6
22
  name?: string | null;
23
+ /** What the host knows about their work — most important first. Optional; bounded on the way in. */
24
+ profile?: SupportProfileFact[] | null;
7
25
  }
26
+ /** How much of a profile rides in a token. It travels in a URL, so it is small on purpose. */
27
+ export declare const PROFILE_MAX_FACTS = 10;
28
+ /**
29
+ * A profile made safe to sign: known shape, stable keys, trimmed, bounded.
30
+ * A fact with no value is left out (an empty unit is not a unit). Null when
31
+ * there is nothing to say — the support side then keeps what it had.
32
+ */
33
+ export declare function cleanProfile(profile: SupportProfileFact[] | null | undefined): SupportProfileFact[] | null;
8
34
  /**
9
35
  * Two minutes.
10
36
  *
@@ -31,6 +57,28 @@ export declare function createSupportToken(options: {
31
57
  token: string;
32
58
  expiresIn: number;
33
59
  };
60
+ /**
61
+ * The address that signs a person into the support desk and lands them on a
62
+ * page of it — for a host that sends people there by LINK rather than from
63
+ * its own button (a notice on a portal, a "sign in" door the desk bounces a
64
+ * signed-out reader to). The token is minted here, on the server, at the
65
+ * moment of the redirect; it lives two minutes and is spent on arrival.
66
+ *
67
+ * redirect(supportSignInUrl({ host, realmKey, secret, user, returnPath: "/e/อบรม-a4f2" }))
68
+ *
69
+ * `returnPath` must be a path on the support desk; the desk decides again
70
+ * where it may land (its own reporter pages, or an event).
71
+ */
72
+ export declare function supportSignInUrl(options: {
73
+ /** The support desk's origin, e.g. https://support.example.com */
74
+ host: string;
75
+ /** The realm's public key. */
76
+ realmKey: string;
77
+ secret: string;
78
+ user: SupportUser;
79
+ returnPath?: string | null;
80
+ ttlSeconds?: number;
81
+ }): string;
34
82
  /**
35
83
  * A ready-made route handler, for the common case.
36
84
  *
package/dist/server.mjs CHANGED
@@ -1,5 +1,25 @@
1
1
  // src/server.ts
2
2
  import { createHmac, randomUUID } from "node:crypto";
3
+ var PROFILE_MAX_FACTS = 10;
4
+ var PROFILE_KEY = /^[a-z][a-z0-9_]{0,31}$/;
5
+ function cleanProfile(profile) {
6
+ if (!Array.isArray(profile))
7
+ return null;
8
+ const out = [];
9
+ const seen = new Set;
10
+ for (const f of profile) {
11
+ const key = typeof f?.key === "string" ? f.key.trim() : "";
12
+ const value = typeof f?.value === "string" ? f.value.trim() : "";
13
+ if (!PROFILE_KEY.test(key) || !value || seen.has(key))
14
+ continue;
15
+ seen.add(key);
16
+ const label = typeof f.label === "string" && f.label.trim() ? f.label.trim().slice(0, 40) : key;
17
+ out.push({ key, label, value: value.slice(0, 120) });
18
+ if (out.length >= PROFILE_MAX_FACTS)
19
+ break;
20
+ }
21
+ return out.length ? out : null;
22
+ }
3
23
  var DEFAULT_TTL_SECONDS = 120;
4
24
  var b64 = (value) => Buffer.from(JSON.stringify(value), "utf8").toString("base64url");
5
25
  function createSupportToken(options) {
@@ -15,12 +35,23 @@ function createSupportToken(options) {
15
35
  sub: options.user.id?.trim() || email,
16
36
  email,
17
37
  name: options.user.name?.trim() || null,
38
+ ...cleanProfile(options.user.profile) ? { profile: cleanProfile(options.user.profile) } : {},
18
39
  jti: randomUUID(),
19
40
  iat: now,
20
41
  exp: now + expiresIn
21
42
  })}`;
22
43
  return { token: `${body}.${createHmac("sha256", options.secret).update(body).digest("base64url")}`, expiresIn };
23
44
  }
45
+ function supportSignInUrl(options) {
46
+ const { token } = createSupportToken({ secret: options.secret, user: options.user, ttlSeconds: options.ttlSeconds });
47
+ const url = new URL("/sso", options.host.replace(/\/+$/, ""));
48
+ url.searchParams.set("realm", options.realmKey);
49
+ url.searchParams.set("token", token);
50
+ const back = options.returnPath?.trim();
51
+ if (back && back.startsWith("/") && !back.startsWith("//"))
52
+ url.searchParams.set("return", back);
53
+ return url.toString();
54
+ }
24
55
  function supportTokenHandler(options) {
25
56
  return async () => {
26
57
  const secret = options.secret ?? process.env.SUPPORT_REPORTER_SECRET;
@@ -49,6 +80,9 @@ function json(body, status) {
49
80
  }
50
81
  export {
51
82
  supportTokenHandler,
83
+ supportSignInUrl,
52
84
  createSupportToken,
85
+ cleanProfile,
86
+ PROFILE_MAX_FACTS,
53
87
  DEFAULT_TTL_SECONDS
54
88
  };
package/dist/submit.d.ts CHANGED
@@ -38,4 +38,15 @@ export declare function bundleAttachment(bundle: DebugBundle): {
38
38
  dataUri: string;
39
39
  filename: string;
40
40
  };
41
+ /**
42
+ * The host's proof of who is filing, when it has any.
43
+ *
44
+ * Never throws. Filing a report has to keep working for an app that has not
45
+ * wired identity up, for one where nobody is signed in, and for one whose token
46
+ * endpoint is having a bad day — a bug report is the last thing that should
47
+ * fail because of a side quest.
48
+ */
49
+ export declare function identityHeader(): Promise<Record<string, string>>;
41
50
  export declare function submitBundle(title: string, bundle: DebugBundle): Promise<FiledTicket>;
51
+ /** The send that did not go through, as one of the four failures — shared with a request's send (requests.ts). */
52
+ export declare function failureOf(res: Response): Promise<ReportError>;