ccdeck 3.51.0 → 3.52.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/web/assets/BrowserWatchModal-CRqdEVdh.js +1 -0
- package/dist/web/assets/IntegrationModal-BDzEIGSM.js +7 -0
- package/dist/web/assets/RadioPanel-BJlsCpnN.js +1 -0
- package/dist/web/assets/TrafficRadar-BGxw-hlO.js +8 -0
- package/dist/web/assets/UsageHistoryModal-C_WBpNIp.js +1 -0
- package/dist/web/assets/app-B53fC4gE.js +358 -0
- package/dist/web/assets/app-Co1HNGP8.css +1 -0
- package/dist/web/assets/{index-CWUj8Kqh.js → index-D9nJhUJR.js} +1 -1
- package/dist/web/index.html +3 -3
- package/package.json +2 -1
- package/release-notes.json +14 -0
- package/dist/web/assets/BrowserWatchModal-CDpunrq9.js +0 -1
- package/dist/web/assets/IntegrationModal-BctMcNU8.js +0 -7
- package/dist/web/assets/RadioPanel-DQNFtYOx.js +0 -1
- package/dist/web/assets/TrafficRadar-DRt3Al7E.js +0 -8
- package/dist/web/assets/UsageHistoryModal-DlgPufgs.js +0 -1
- package/dist/web/assets/app-4x4wTE-L.js +0 -321
- package/dist/web/assets/app-o4kL0FgZ.css +0 -1
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{j as e,b as c,a4 as Kn,a5 as pn,r as _s,a6 as Is,w as Ps,a7 as Vn,o as Ls,v as Ms,l as Ks}from"./app-4x4wTE-L.js";const Vs={radar:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M20 12a8 8 0 1 1-8-8v8l5-5"}),e.jsx("path",{d:"M12 8a4 4 0 1 0 4 4"}),e.jsx("circle",{cx:"12",cy:"12",r:"1"})]}),connection:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M8 8h8v8H8zM12 3v5M12 16v5M3 12h5M16 12h5"}),e.jsx("circle",{cx:"12",cy:"3",r:"1"}),e.jsx("circle",{cx:"21",cy:"12",r:"1"})]}),logs:e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"5",y:"3",width:"14",height:"18",rx:"2"}),e.jsx("path",{d:"M9 8h6M9 12h6M9 16h3"})]}),metrics:e.jsx(e.Fragment,{children:e.jsx("path",{d:"M4 20h16M7 16v-5M12 16V4M17 16V8"})}),traces:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M7 5h10M7 12h10M7 19h10M12 5v14"}),e.jsx("circle",{cx:"7",cy:"5",r:"2"}),e.jsx("circle",{cx:"17",cy:"12",r:"2"}),e.jsx("circle",{cx:"7",cy:"19",r:"2"})]}),info:e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"9"}),e.jsx("path",{d:"M12 11v5M12 7h.01"})]})};function Rt({kind:t,...n}){return e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n,children:Vs[t]})}function ln({className:t="",children:n,...s}){return e.jsxs("span",{className:"tr-select-wrap",children:[e.jsx("select",{...s,className:`tr-select${t?` ${t}`:""}`,children:n}),e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"m6 9 6 6 6-6"})})]})}function cn(t,n=!1){return n||t.active===null?"Visibility unavailable":t.connecting?t.active?"Connecting · no reply yet":"Attempted · no reply seen":t.active?"Active connection":"Previously observed"}function Fn(t){return[...new Set(t.filter(n=>n.key.endsWith("ENDPOINT")).map(n=>n.value).filter(n=>/^https?:\/\//.test(n)))]}function Fs(t){return(t==null?void 0:t.status)!=="observing"?[]:[...new Set(t.connections.filter(n=>n.active===!0&&!n.connecting).map(n=>n.destination))]}function $s(t){try{const n=new URL(t);return/^\d+\.\d+\.\d+\.\d+$/.test(n.hostname)?`${n.hostname}:${n.port||(n.protocol==="https:"?"443":"80")}`:null}catch{return null}}function Bs(t){const n=t.filter(o=>o.key==="CLAUDE_CODE_ENABLE_TELEMETRY"),s=n.map(o=>o.value);if(!s.length)return"Unknown";if(new Set(s).size>1)return"Conflicting settings";const r=n.every(o=>o.launch)?"in launch environment":"in settings";return s[0]==="Enabled"?`Enabled ${r}`:s[0]==="Disabled"?`Disabled ${r}`:"Unknown"}function Ws(t){const n=t.replace(/^\uFEFF/,"").trim();if(!n)return[];let s;try{JSON.parse(n),s=[n]}catch{s=t.replace(/^\uFEFF/,"").split(/\r?\n/)}if(s.length>1e4)throw new Error("This file has more than 10,000 lines. Choose a smaller export.");return s.flatMap((r,o)=>{var i;if(!r.trim())return[];try{const h=JSON.parse(r),d=h&&typeof h=="object"?h:{},m=new Set,a=[h];for(;a.length;){const l=a.pop();if(!l||typeof l!="object")continue;if(Array.isArray(l)){for(const p of l)a.push(p);continue}const g=l;for(const p of["session.id","session_id","sessionId"])typeof g[p]=="string"&&m.add(g[p]);if(["session.id","session_id"].includes(String(g.key))){const p=g.value;typeof(p==null?void 0:p.stringValue)=="string"&&m.add(p.stringValue)}for(const p of Object.values(g))a.push(p)}return[{line:o+1,raw:r,sessionIds:[...m],label:String(d.eventName??((i=d.event)==null?void 0:i.name)??d.type??d.model??"JSON record").slice(0,160),sessionId:typeof(d.session_id??d.sessionId??d["session.id"])=="string"?d.session_id??d.sessionId??d["session.id"]:null,timestamp:typeof d.timestamp=="string"?d.timestamp:null,valid:!0}]}catch{return[{line:o+1,raw:r,label:"Invalid JSON",sessionId:null,timestamp:null,sessionIds:[],valid:!1}]}})}function Hs(){const[t,n]=c.useState(null),[s,r]=c.useState(!1),o=c.useRef(0);return c.useEffect(()=>{let h=!0,d,m=null;const a=()=>document.visibilityState!=="hidden",l=()=>{clearTimeout(d),m==null||m.abort(),m=null},g=async()=>{if(!h||!a()||m)return;const y=new AbortController,w=o.current;m=y;try{const b=await fetch("/api/system/traffic-radar",{signal:y.signal});if(!b.ok)throw new Error("radar_unavailable");const v=await b.json();if(!v.ok)throw new Error("radar_unavailable");h&&!y.signal.aborted&&w===o.current&&(n(v),r(!1))}catch{h&&!y.signal.aborted&&w===o.current&&r(!0)}finally{m===y&&(m=null),h&&!y.signal.aborted&&a()&&(d=setTimeout(g,5e3))}},p=()=>{l(),document.visibilityState!=="hidden"&&g()};return g(),document.addEventListener("visibilitychange",p),()=>{h=!1,l(),document.removeEventListener("visibilitychange",p)}},[]),{snapshot:t,failed:s,updateConfig:h=>{o.current++,n(d=>d&&{...d,config:h})}}}function zs(){const[t,n]=c.useState(null),[s,r]=c.useState(!1),[o,i]=c.useState(!1),[h,d]=c.useState(""),[m,a]=c.useState(null),[l,g]=c.useState(null),p=c.useRef(null),y=c.useRef(null),w=c.useRef(0);return c.useEffect(()=>{let v=!0,D,O=null;const L=()=>document.visibilityState!=="hidden",C=()=>{clearTimeout(D),O==null||O.abort(),O=null},f=async()=>{if(!v||!L()||O)return;if(p.current){D=setTimeout(f,1e3);return}const N=w.current,x=new AbortController;O=x;try{const T=await fetch("/api/system/traffic-radar/capture",{signal:x.signal});if(!T.ok)throw new Error;const z=await T.json();v&&!x.signal.aborted&&N===w.current&&(n(z),r(!1))}catch{v&&!x.signal.aborted&&N===w.current&&r(!0)}finally{O===x&&(O=null),v&&!x.signal.aborted&&L()&&(D=setTimeout(f,1e3))}},E=()=>{C(),document.visibilityState!=="hidden"&&f()};return f(),document.addEventListener("visibilitychange",E),()=>{var N;v=!1,C(),(N=y.current)==null||N.abort(),document.removeEventListener("visibilitychange",E)}},[]),{capture:t,failed:s,busy:o,pendingAction:l,error:h,permission:m,action:async v=>{if(!Kn(p.current))return;w.current++,p.current=v,g(v),i(!0),d(""),v==="permission"&&a(null);const D=new AbortController;y.current=D;const O=setTimeout(()=>D.abort(),v==="permission"?3e5:2e4);try{const L=await fetch(`/api/system/traffic-radar/capture/${v}`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}",signal:D.signal}),C=await L.json();if(!L.ok)throw new Error(C.error||"Capture action failed. Please retry.");v==="permission"&&a(C);const f=await fetch("/api/system/traffic-radar/capture",{signal:D.signal});f.ok&&(n(await f.json()),r(!1))}catch(L){d(L instanceof Error?L.message:"Capture action failed. Please retry.")}finally{clearTimeout(O),y.current=null,p.current=null,g(null),i(!1)}}}}function Us({workspace:t,width:n,onCommit:s}){const r=c.useRef(null),o=a=>Math.max(28,Math.min(65,a)),i=a=>{var l;return(l=t.current)==null?void 0:l.style.setProperty("--tr-feed-width",`${a}%`)},h=a=>{const l=o(a);i(l),s(l)},d=a=>{if(r.current===null||!t.current)return;const l=t.current.getBoundingClientRect();r.current=o((a.clientX-l.left)/l.width*100),i(r.current),a.currentTarget.setAttribute("aria-valuenow",String(Math.round(r.current)))},m=()=>{var l;if(r.current===null)return;const a=r.current;r.current=null,(l=t.current)==null||l.removeAttribute("data-resizing"),h(a)};return e.jsx("div",{className:"tr-splitter",role:"separator","aria-label":"Activity list width","aria-orientation":"vertical","aria-valuemin":28,"aria-valuemax":65,"aria-valuenow":Math.round(n),tabIndex:0,title:"Drag to resize · double-click to reset · arrow keys to adjust",onPointerDown:a=>{var l;a.button===0&&(a.preventDefault(),r.current=n,a.currentTarget.setPointerCapture(a.pointerId),(l=t.current)==null||l.setAttribute("data-resizing",""))},onPointerMove:d,onPointerUp:m,onPointerCancel:m,onLostPointerCapture:m,onDoubleClick:()=>h(34),onKeyDown:a=>{const l=a.key==="ArrowLeft"?n-(a.shiftKey?10:2):a.key==="ArrowRight"?n+(a.shiftKey?10:2):a.key==="Home"?28:a.key==="End"?65:a.key==="Enter"?34:null;l!==null&&(a.preventDefault(),h(l))}})}const Qt=["prompt_text","user_prompt","prompt","gen_ai.prompt","gen_ai.input.messages"],mn=["response","assistant_response","completion","gen_ai.completion","gen_ai.output.messages"],$n=["project.name","project_name","project","workspace.name","workspace","repository.name","repo.name"],Bn=["cwd","working_directory","working.directory","process.cwd","process.working_directory","workspace.path","project.path","project_path"],Nt=t=>t&&typeof t=="object"&&!Array.isArray(t)?t:{},Bt=t=>Array.isArray(t)?t:[];function Mt(t){const n=Nt(t);for(const s of["stringValue","intValue","doubleValue","boolValue","bytesValue"])if(n[s]!==void 0)return n[s];return n.arrayValue?Bt(Nt(n.arrayValue).values).map(Mt):n.kvlistValue?Et(Nt(n.kvlistValue).values):null}function Et(t){return Object.fromEntries(Bt(t).map(n=>{const s=Nt(n);return[String(s.key),Mt(s.value)]}))}const dn=t=>typeof t=="string"&&/^(?:\[redacted\]|<redacted>|\(redacted\)|redacted)$/i.test(t.trim());function it(t,n){const s=n.filter(o=>t[o]!==void 0&&t[o]!==null&&t[o]!==""),r=s.find(o=>!dn(t[o]))??s[0];return r?{state:dn(t[r])?"redacted":"included",key:r,value:t[r]}:{state:"absent",key:null,value:null}}function Js(t){let n=!1;const s=Nt(t);for(const[r,o,i]of[["resourceLogs","scopeLogs","logRecords"],["resourceSpans","scopeSpans","spans"],["resourceMetrics","scopeMetrics","metrics"]])for(const h of Bt(s[r]))for(const d of Bt(Nt(h)[o]))for(const m of Bt(Nt(d)[i])){const a=it(Et(Nt(m).attributes),Qt);if(a.state==="redacted"&&(n=!0),a.state==="included"){const l=(typeof a.value=="string"?a.value:JSON.stringify(a.value)).replace(/\s+/g," ").trim();if(l)return l.length>180?`${l.slice(0,180)}…`:l}}return n?"Prompt redacted":null}function Ys(t){const n=Et(t.attributes);if(/error|fatal/i.test(String(t.severityText??""))||typeof t.severityNumber=="number"&&t.severityNumber>=17||it(n,["error.message","exception.message","error","error_type"]).state!=="absent"||n.success===!1)return 0;if(it(n,Qt).state!=="absent")return 1;if(it(n,mn).state!=="absent")return 2;if(it(n,["tool_name","tool.name","gen_ai.tool.name","model","gen_ai.request.model","cost_usd","input_tokens"]).state!=="absent")return 3;const s=String(t.eventName??t.name??n["event.name"]??"");return/^(?:claude_code[._])?(?:plugin[._]loaded|managed[._]settings[._]resolved)$/i.test(s)?4:t.body!==void 0&&Mt(t.body)!==null&&Mt(t.body)!==""?3:4}function qs(t,n){const s=it(t,$n),r=it(t,Bn);if(s.state!=="absent"||r.state!=="absent")return{source:"export",project:s,directory:r};const o=it(t,["session.id","session_id","gen_ai.conversation.id"]),i=n.filter(d=>d.id===o.value&&d.workspace);return new Set(i.map(d=>d.workspace)).size===1?{source:"local",project:{state:"included",value:i[0].project??i[0].label,key:null},directory:{state:"included",value:i[0].workspace,key:null}}:{source:"absent",project:s,directory:r}}function Gs({event:t}){const n=c.useRef(null),[s,r]=c.useState(null);return c.useEffect(()=>{const o=new AbortController;let i=!1;const h=()=>{i||(i=!0,fetch(`/api/system/traffic-radar/capture/event?id=${t.id}`,{signal:o.signal}).then(async m=>{if(!m.ok)return;const a=await m.json();o.signal.aborted||r(Js(a.payload))}).catch(()=>{}))},d=typeof IntersectionObserver>"u"?null:new IntersectionObserver(m=>{m.some(a=>a.isIntersecting)&&(h(),d==null||d.disconnect())},{rootMargin:"100px"});return n.current&&d?d.observe(n.current):h(),()=>{o.abort(),d==null||d.disconnect()}},[t.id,t.observedAt]),e.jsx("span",{ref:n,className:"tr-prompt-preview",children:s??"Prompt-related fields · open to inspect"})}const St=()=>{},fn=t=>Array.isArray(t)?t:[t],Xe=t=>t!==null&&typeof t=="object",un=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),Wn=t=>t!=null&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function",Hn=t=>t&&typeof t=="object"&&"type"in t&&"target"in t&&"preventDefault"in t&&typeof t.preventDefault=="function",kn=(t,n)=>{if(typeof t!="string")return null;const s=n.filter(r=>r instanceof Object&&r.enum&&r.values.includes(t)&&r.matchPriority);return s.sort((r,o)=>(o.matchPriority??0)-(r.matchPriority??0)),s[0]??null},zn=t=>{if(t!==Un){if(t&&typeof t=="object")for(const n in t){const s=t[n],r=zn(s);r!==s&&(t[n]=r)}return t}},Un="__undefined__",Jn=t=>t.split(/(\.|\[\d+\])/).filter(n=>n!=="."&&n!=="").map(n=>{const s=/\[(\d+)\]/.exec(n);return s?Number(s[1]):n}),Yn=t=>typeof t=="string"?t:typeof t=="number"?String(t):t.reduce((n,s)=>typeof s=="number"?`${n}[${s}]`:n===""?s:`${n}.${s}`,""),Qe=t=>t.length===1&&t[0]===""?"\0":t.map(n=>encodeURIComponent(String(n))).join("/"),lt=(t,n)=>t.length===n.length&&t.every((s,r)=>s===n[r]),gn=(t,n)=>t.length>=n.length&&n.every((s,r)=>s===t[r]),At=(t,n,s,r,o)=>{if(!r)throw new Error(o??`Invalid property path: ${n}
|
|
2
|
-
Couldn't access "${s}" in ${JSON.stringify(t)}`)},Yt=t=>Array.isArray(t),qn=(t,n)=>t.filter((s,r)=>r!==n),Xs=(t,n,s,r={})=>{const{remove:o=!1,createNew:i=!0,noError:h=!1}=r,d=t,m=Yn(n),a={...r,remove:o,createNew:i,noError:h,fullData:d,fullPath:m},l=Array.isArray(n)?n:Jn(n);return Yt(t)&&o&&l.length===1?qn(t,l[0]):$t(t,l,s,a)},$t=(t,n,s,r)=>{const o=un(t)?{...t}:null,i=Yt(t)?[...t]:null;if(n.length===0)return t;if(!o&&!i)throw new Error("Can't assign property -- invalid input object");const{createNew:h,remove:d,noError:m,fullData:a,fullPath:l}=r,g=n[0];if(i&&typeof g=="string")return i.map(b=>$t(b,n,s,r));if(n.length===1)return o&&typeof g=="string"?Zs(o,g,s,r)??o:i&&typeof g=="number"?(Qs(i,g,s,r),i):(At(a,l,g,m),t);const p=o||i||[];if(d&&n.length===2&&typeof n[1]=="number"){const b=p[g],v=n[1];return Yt(b)?p[g]=qn(b,v):At(a,l,g,m,"Trying to remove an indexed item from an object that is not an array"),p}const y=n.slice(1);if(g in t){if(w=p[g],!Yt(w)&&!un(w)){if(!h)return At(a,l,g,m),p;p[g]={}}return p[g]=$t(p[g],y,s,r),p}var w;if(h){const b=typeof y[0]=="number"?[]:{};if(o)return p[g]=b,p[g]=$t(p[g],y,s,r),p;if(i&&Array.isArray(p)){p.push(b);const v=p.length-1;return p[v]=$t(p[v],y,s,r),p}}return At(a,l,g,m),p},Zs=(t,n,s,r)=>{const{remove:o,createNew:i,noError:h,insertAfter:d,insertBefore:m,fullData:a,fullPath:l}=r;if(m!==void 0||d!==void 0){const p=Object.entries(t);let y;return y=typeof m=="number"?m:typeof d=="number"?d:p.findIndex(([w])=>w===(m??d)),d!==void 0&&y++,p.splice(y,0,[n,s]),Object.fromEntries(p)}const g=n in t;o?g?delete t[n]:At(a,l,n,h):i||g?t[n]=s:At(a,l,n,h)},Qs=(t,n,s,r)=>{const{noError:o,fullData:i,fullPath:h,createNew:d,insert:m}=r;m&&t.splice(n,0,s),n in t?t[n]=s:d?t.push(s):At(i,h,n,o)},Ze=(t,n,s)=>{const r=Array.isArray(n)?n:Jn(n);if(r.length===0)return t;const o=r[0];if(Array.isArray(t)&&typeof o!="number"&&t.length>0)return t.map(h=>Ze(h,r,s));if(typeof t!="object"||t===null||!(o in t))return er(t,o,s);const i=t[o];return r.length===1?i:Ze(i,r.slice(1),s)},er=(t,n,s)=>{if(s===void 0)throw new Error(`Unable to extract object property
|
|
3
|
-
Looking for property: ${n}
|
|
4
|
-
In object: ${JSON.stringify(t)}`);return s},xt=(t,n,s="",r)=>{if(n.length===0)return{key:s,path:[],level:0,index:0,value:t,size:Xe(t)?Object.keys(t).length:1,parentData:null,fullData:t};const o=n[n.length-1],i=Ze(t,n),h=Ze(t,n.slice(0,-1))??null;let d=0;if(Array.isArray(h))d=typeof o=="number"?o:Number(o);else if(h&&typeof h=="object"){const m=Object.entries(h);r==null||r(m,a=>a),d=m.findIndex(([a])=>a===o)}return{key:o,path:n,level:n.length,index:d,value:i,size:Xe(i)?Object.keys(i).length:null,parentData:h,fullData:t}},Gn=typeof window<"u"?c.useLayoutEffect:c.useEffect,Xn=({className:t,name:n,value:s,setValue:r,onKeyDown:o,styles:i,textAreaRef:h})=>{const d=c.useRef(null);if(Gn(()=>{const a=d.current;d.current=null;const l=h==null?void 0:h.current;if(!a||!l)return;const g=a.start+s.length-a.sourceLength,p=Math.max(0,Math.min(g,s.length));l.selectionStart!==p&&l.setSelectionRange(p,p)},[s,h]),typeof s!="string")return null;const m=s.slice(-1)===`
|
|
5
|
-
`?s+".":s;return e.jsxs("div",{style:{display:"grid"},children:[e.jsx("textarea",{id:`${n}_textarea`,ref:h,style:{height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap",...i},rows:1,className:t,name:`${n}_textarea`,value:s,onChange:a=>{const{value:l,selectionStart:g}=a.target;d.current=g!==null&&g<l.length?{start:g,sourceLength:l.length}:null,r(l)},autoFocus:!0,onFocus:a=>{s.length<40&&a.target.select()},onKeyDown:o}),e.jsx("span",{className:t,style:{visibility:"hidden",height:"auto",gridArea:"1 / 1 / 2 / 2",color:"red",opacity:.9,whiteSpace:"pre-wrap",overflowY:"auto",border:"1px solid transparent",...i},children:m})]})},yn=t=>t.shiftKey?"Shift":t.metaKey?"Meta":t.ctrlKey?"Control":t.altKey?"Alt":void 0,tr=(t,n,s)=>{if(!n)return!1;const r=t.key,o=yn(t);if(Array.isArray(n))return!!o&&n.includes(o);const{key:i,modifier:h}=n;return(s!=="stringLineBreak"||r!=="Enter"||o!=="Shift"||i!=="Enter"||!(h!=null&&h.includes("Shift")))&&r===i&&(h===o||Array.isArray(h)&&h.includes(o))},Tt={key:"Enter"},Dn={confirm:Tt,cancel:{key:"Escape"},objectConfirm:{...Tt,modifier:["Meta","Shift","Control"]},objectLineBreak:Tt,stringConfirm:Tt,stringLineBreak:{...Tt,modifier:["Shift"]},numberConfirm:Tt,numberUp:{key:"ArrowUp"},numberDown:{key:"ArrowDown"},tabForward:{key:"Tab"},tabBack:{key:"Tab",modifier:"Shift"},booleanConfirm:Tt,booleanToggle:{key:" "},clipboardModifier:["Meta","Control"],collapseModifier:["Alt"]},nr=["stringConfirm","numberConfirm","booleanConfirm"],Zn=(t,n)=>{const s=t.current,r=s.selectionStart??1/0,o=s.selectionEnd??1/0,i=s.value.slice(0,r)+n+s.value.slice(o);return s.value=i,s.setSelectionRange(r+1,r+1),i},qt=(t,n,s="next",r,o)=>{const i=n.slice(0,n.length-1),h=n.slice(-1)[0];if(h===void 0)return null;const d=Ze(t,i),m=sr(d);Array.isArray(d)||r(m,({key:p,value:y})=>[p,y]);const a=m.findIndex(p=>p.key===h),l=m[a+(s==="next"?1:-1)];if(!l)return i.length===0?null:qt(t,i,s,r,o);let g;if(Xe(l.value)){if(Object.keys(l.value).length===0)return qt(t,[...i,l.key],s,r,o);g=Qn(t,[...i,l.key],s,r)}else g=[...i,l.key];return g?o(xt(t,g,"",r))?g:qt(t,g,s,r,o):null},Qn=(t,n,s="next",r)=>{const o=Ze(t,n);if(!Xe(o))return n;const i=Array.isArray(o)?o.map((d,m)=>m):Object.keys(o);r(i,d=>[d,o]);const h=s==="next"?i[0]:i[i.length-1];return Qn(t,[...n,h],s,r)},sr=t=>Array.isArray(t)?t.map((n,s)=>({value:n,key:s})):Object.entries(t).map(([n,s])=>({key:n,value:s})),Tn={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2},en={displayName:"Default",icons:{add:{content:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z"}),e.jsx("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"})]})},edit:{content:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M7 17.013l4.413-.015 9.632-9.54c.378-.378.586-.88.586-1.414s-.208-1.036-.586-1.414l-1.586-1.586c-.756-.756-2.075-.752-2.825-.003L7 12.583v4.43zM18.045 4.458l1.589 1.583-1.597 1.582-1.586-1.585 1.594-1.58zM9 13.417l6.03-5.973 1.586 1.586-6.029 5.971L9 15.006v-1.589z"}),e.jsx("path",{d:"M5 21h14c1.103 0 2-.897 2-2v-8.668l-2 2V19H8.158c-.026 0-.053.01-.079.01-.033 0-.066-.009-.1-.01H5V5h6.847l2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2z"})]}),svgProps:{transform:"translate(0, 0.5)"}},delete:{content:e.jsx("path",{d:"M6 19a2 2 0 002 2h8a2 2 0 002-2V7H6v12m2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12M15.5 4l-1-1h-5l-1 1H5v2h14V4h-3.5z"}),scale:1.04},copy:{content:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M9 2 H15 A1 1 0 0 1 16 3 V5 A1 1 0 0 1 15 6 H9 A1 1 0 0 1 8 5 V3 A1 1 0 0 1 9 2 z"}),e.jsx("path",{d:"M8 4H6a2 2 0 00-2 2v14a2 2 0 002 2h12a2 2 0 002-2v-2M16 4h2a2 2 0 012 2v4M21 14H11"}),e.jsx("path",{d:"M15 10l-4 4 4 4"})]}),svgProps:Tn,scale:.86},ok:{content:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 11-5.93-9.14"}),e.jsx("path",{d:"M22 4L12 14.01l-3-3"})]}),svgProps:Tn,scale:.9},cancel:{content:e.jsx("path",{d:"M12 4c-4.411 0-8 3.589-8 8s3.589 8 8 8 8-3.589 8-8-3.589-8-8-8zm-5 8c0-.832.224-1.604.584-2.295l6.711 6.711A4.943 4.943 0 0112 17c-2.757 0-5-2.243-5-5zm9.416 2.295L9.705 7.584A4.943 4.943 0 0112 7c2.757 0 5 2.243 5 5 0 .832-.224 1.604-.584 2.295z"}),svgProps:{baseProfile:"tiny"},scale:1.3},collection:{content:e.jsx("path",{d:"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"}),viewBox:"0 0 512 512",scale:.7}},styles:{container:{backgroundColor:"#f6f6f6",fontFamily:"monospace"},property:"#292929",bracket:{color:"#002b36",fontWeight:"bold"},itemCount:{color:"#0000004d",fontStyle:"italic"},string:"#cb4b16",number:"#268bd2",boolean:"green",null:{color:"#dc322f",fontVariant:"small-caps",fontWeight:"bold"},input:["#292929"],inputHighlight:"#b3d8ff",error:{fontSize:"0.8em",color:"red",fontWeight:"bold"},iconCollection:"#002b36",iconEdit:"#2aa198",iconDelete:"#cb4b16",iconAdd:"#2aa198",iconCopy:"#268bd2",iconOk:"green",iconCancel:"#cb4b16"}},rr={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",headerRow:"backgroundColor",valueRow:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},es=t=>[en,...fn(t)].map(n=>"styles"in n?n:{styles:n}),ts=t=>{const n={};for(const{icons:s}of es(t))s&&Object.assign(n,s);return n},ns=c.createContext({getStyles:()=>({}),icons:ts(en),cssVars:{}}),or=({theme:t=en,children:n})=>{const s=c.useMemo(()=>(d=>{var m;const a=es(d),l={},g={};for(const{fragments:y,styles:w}of a)for(const b in w){const v=b;for(const D of[].concat(w[v]))if(typeof D=="function")(g[v]??(g[v]=[])).push(D);else{const O=typeof D=="string"?(y==null?void 0:y[D])??D:D;l[v]={...l[v],...typeof O=="string"?{[rr[v]??"color"]:O}:O}}}for(const y in g)l[m=y]??(l[m]={});const p={};for(const y in l){const w=y,b=l[w],v=g[w];p[w]=v?D=>v.reduce((O,L)=>({...O,...L(D)??{}}),b):b}return p})(t),[t]),r=c.useMemo(()=>ts(t),[t]),o=c.useMemo(()=>(d=>{const{inputHighlight:m,iconCopy:a}=d,l={};return typeof m!="function"&&(m!=null&&m.backgroundColor)&&(l["--jer-highlight-color"]=m.backgroundColor),typeof a!="function"&&(a!=null&&a.color)&&(l["--jer-icon-copy-color"]=a.color),l})(s),[s]),i=c.useCallback((d,m)=>((a,l,g)=>{const p=a[l];return typeof p=="function"?p(g):p??{}})(s,d,m),[s]),h=c.useMemo(()=>({getStyles:i,icons:r,cssVars:o}),[i,r,o]);return e.jsx(ns.Provider,{value:h,children:n})},ct=()=>c.useContext(ns),ar={edit:{start:"startEdit",submit:"submitEdit",cancel:"cancelEdit",commit:"commitEdit"},add:{start:"startAdd",submit:"submitAdd",cancel:"cancelAdd",commit:"commitAdd"},rename:{start:"startRename",submit:"submitRename",cancel:"cancelRename",commit:"commitRename"},delete:{commit:"delete"},move:{commit:"move"}},Ot=(t,n)=>ar[t][n]??null,Lt=(t,n)=>t!==null&&n!==null&&t.op===n.op&<(t.path,n.path),ir={active:null,settling:{}},ss=c.createContext(null),lr=({children:t,onEditEvent:n,buildNodeDataFromPathRef:s,commitRef:r})=>{const o=c.useRef(n);o.current=n;const i=c.useRef(null);return i.current===null&&(i.current=((h,d,m)=>{let a=ir;const l=new Set;let g=null,p=null,y=!1,w=0;const b=C=>{a=C,l.forEach(f=>f())},v=(C,f,E)=>{var N;(N=h.current)==null||N.call(h,{...C,...E,event:f})},D=(C,f,E)=>{var x;if(!h.current)return;let N;try{N=(x=d.current)==null?void 0:x.call(d,C)}catch{return b({...a,active:null}),g=null,void(p=null)}N&&v(N,f,E)},O=(C,f)=>{var x;var E;g=(f==null?void 0:f.cancelOp)??null,p=(f==null?void 0:f.commitOp)??null,E=C,Lt(a.active,E)&&((x=a.active)==null?void 0:x.phase)===(E==null?void 0:E.phase)||b({...a,active:E});const N=Ot(C.op,"start");N&&D(C.path,N)},L=(C,f,E,N,x,T,z,U,j)=>{var k;const V=Qe(C);if(!z()){if(N.status==="cancel"||N.status==="error"){a.active&<(a.active.path,C)&&(a.active.phase==="held"||a.active.phase==="editing")&&(b({...a,active:null}),g=null,p=null);const R=Ot(f,"cancel");return R&&v(U,R),N.status==="error"&&v(U,"updateError",{operation:f,error:N.error}),N}x()}if(a.settling[V]===E){switch((R=>{if(!(R in a.settling))return;const A={...a.settling};delete A[R],b({...a,settling:A})})(V),N.status){case"cancel":T();break;case"error":T(),v(U,"updateError",{operation:f,error:N.error});break;case"override":(k=m.current)==null||k.applyValue(N.path,N.value),v(U,"updateSuccess",{operation:f,...j});break;case"commit":v(U,"updateSuccess",{operation:f,...j})}return N}};return{subscribe:C=>(l.add(C),()=>l.delete(C)),getSnapshot:()=>a,getServerSnapshot:()=>a,open:(C,f)=>{var z;if(((z=a.active)==null?void 0:z.phase)==="held")return;const E={path:C,op:(f==null?void 0:f.op)??"edit",phase:"editing",force:f==null?void 0:f.force},N=a.active,x=N!==null&&!Lt(N,E);if(x&&p)return void p(()=>O(E,f));const T=g;if(g=null,p=null,T&&T(),x&&Lt(a.active,N)){const U=Ot(N.op,"cancel");U&&D(N.path,U)}O(E,f)},cancel:()=>{var f;if(y||((f=a.active)==null?void 0:f.phase)==="held")return;const C=a.active;y=!0;try{const E=g;if(g=null,p=null,E&&E(),C!==null){a.active!==null&&b({...a,active:null});const N=Ot(C.op,"cancel");N&&D(C.path,N)}}finally{y=!1}},submit:C=>{const{op:f,path:E,instant:N,onCommit:x}=C,T=m.current;let z;try{z=(T==null?void 0:T.buildCommit(C))??null}catch{return Lt(a.active,{path:E,op:f})&&b({...a,active:null}),g=null,p=null,x==null||x(),Promise.resolve(void 0)}const U=z==null?void 0:z.extra,j=Qe(E),V=++w;if(!N){const ae=Ot(f,"submit");ae&&D(E,ae)}if(!z||z.isNoOp){Lt(a.active,{path:E,op:f})&&b({...a,active:null}),g=null,p=null;const ae=Ot(f,"commit");return ae&&(z?v(z.nodeData,ae,U):D(E,ae,U)),x==null||x(),Promise.resolve(void 0)}const{input:k,nodeData:R,apply:A,revert:q}=z,J=!!(T!=null&&T.runUpdate);let se=!1,fe=!1;const oe=()=>{if(se)return;se=!0,A(),g=null,p=null,Lt(a.active,{path:E,op:f})&&b({...a,active:null}),J&&((H,re)=>{b({...a,settling:{...a.settling,[H]:re}})})(j,V);const ae=Ot(f,"commit");ae&&v(R,ae,U),x==null||x()},ce={hold:()=>{var ae;return fe=!0,b({...a,active:{path:E,op:f,phase:"held",force:(ae=a.active)==null?void 0:ae.force}}),()=>oe()}};if(!J)return oe(),Promise.resolve(void 0);const W=T.runUpdate(k,ce),we=Wn(W);if(!fe&&!N&&!we)return Promise.resolve(L(E,f,V,W,oe,q,()=>se,R,U));const ye=we?W:Promise.resolve(W);let Ie;return fe||(N?Ie=setTimeout(oe,100):oe()),ye.then(ae=>(clearTimeout(Ie),L(E,f,V,ae,oe,q,()=>se,R,U)))},areChildrenBeingEdited:C=>a.active!==null&&gn(a.active.path,C)}})(o,s,r)),e.jsx(ss.Provider,{value:i.current,children:t})},kt=()=>{const t=c.useContext(ss);if(!t)throw new Error("Missing Editing Context Provider");return t},Wt=t=>{const n=kt();return c.useSyncExternalStore(n.subscribe,()=>t(n.getSnapshot()),()=>t(n.getServerSnapshot()))},rs=c.createContext(null),cr=({children:t,onCollapse:n,buildNodeDataFromPathRef:s})=>{const[r,o]=c.useState({commands:null,version:0}),i=c.useRef(n);i.current=n;const h=c.useCallback(m=>{if(m===null)return void o(p=>p.commands===null?p:{commands:null,version:p.version});const a=fn(m),l=a.map(p=>({...p,path:[...p.path]}));o(p=>({commands:l,version:p.version+1}));const g=i.current;g&&a.forEach(p=>{var w;const y=(w=s.current)==null?void 0:w.call(s,p.path);y&&g({...y,collapsed:p.collapsed,includeChildren:p.includeChildren})})},[s]),d=c.useMemo(()=>({commands:r.commands,version:r.version,setCollapseState:h}),[r.commands,r.version,h]);return e.jsx(rs.Provider,{value:d,children:t})},Xt=()=>{const t=c.useContext(rs);if(!t)throw new Error("Missing Collapse Context Provider");return t},dr=(t,n)=>{if(!n.includeChildren)return n.path.length===t.length&&n.path.every((s,r)=>t[r]===s);for(const[s,r]of n.path.entries())if(r!==t[s])return!1;return!0},os=c.createContext(null),ur=({children:t})=>{const[n,s]=c.useState({path:null,canDelete:!1}),r=c.useRef(!1),o=c.useMemo(()=>({dragSource:n,setDragSource:s,armed:r}),[n]);return e.jsx(os.Provider,{value:o,children:t})},hr=({children:t,onEditEvent:n,onCollapse:s,buildNodeDataFromPathRef:r,commitRef:o})=>e.jsx(lr,{onEditEvent:n,buildNodeDataFromPathRef:r,commitRef:o,children:e.jsx(cr,{onCollapse:s,buildNodeDataFromPathRef:r,children:e.jsx(ur,{children:t})})}),as=c.createContext(void 0),pr=({value:t,children:n})=>e.jsx(as.Provider,{value:t,children:n}),jn=()=>{const t=c.useContext(as);if(t===void 0)throw new Error("Missing FilterStateProvider");return t},is=t=>{const n=jn();return n===null||n.visiblePaths.has(Qe(t))},mr=t=>{const n=jn();return n===null?null:n.visibleChildCounts.get(Qe(t))??null},hn="**INVALID_FUNCTION**",fr=({nodeData:t,showStringQuotes:n=!0,stringTruncateLength:s=200,pathString:r,canEdit:o,setIsEditing:i,styles:h,translate:d,showIconTooltips:m=!1,value:a,TextWrapper:l=({children:g})=>g})=>{const g=a??t.value,[p,y]=c.useState(!1),w=n?'"':"",b=g.length>s,v=()=>{o?i(!0):y(!p)},D=d("SHOW_MORE",t);return e.jsxs("div",{id:`${r}_display`,onDoubleClick:v,onClick:O=>{(O.getModifierState("Control")||O.getModifierState("Meta"))&&v()},className:"jer-value-string",style:h,children:[w,b?e.jsxs(e.Fragment,p?{children:[e.jsx(l,{children:e.jsxs("span",{children:[g,w]})})," ",e.jsx("button",{type:"button",tabIndex:-1,className:"jer-string-expansion jer-show-less",onClick:()=>y(!1),children:d("SHOW_LESS",t)})]}:{children:[e.jsxs(l,{children:[e.jsx("span",{children:g.slice(0,s-2).trimEnd()})," "]}),e.jsx("button",{type:"button",tabIndex:-1,className:"jer-string-expansion jer-ellipsis",onClick:()=>y(!0),"aria-label":D,title:m?D:"",children:"..."}),w]}):e.jsx(l,{children:`${g}${w}`})]})},gr=({styles:t,pathString:n,value:s,setValue:r,handleEdit:o,handleKeyboard:i,keyboardCommon:h})=>{const d=c.useRef(null);return e.jsx(Xn,{className:"jer-input-text",textAreaRef:d,name:n,value:s,setValue:r,onKeyDown:m=>{i(m,{stringConfirm:o,stringLineBreak:()=>{const a=Zn(d,`
|
|
6
|
-
`);r(a)},...h})},styles:t})},yr=({isEditing:t,path:n,enumType:s,...r})=>{const{getStyles:o}=ct(),i=Qe(n),{value:h,setValue:d,nodeData:m,handleEdit:a,handleKeyboard:l,keyboardCommon:g,Select:p}=r;return t&&s?e.jsx(p,{name:`${i}-value-select`,value:h,onChange:d,options:s.values,autoFocus:!0,onKeyDown:y=>l(y,{stringConfirm:a,...g})}):t?e.jsx(gr,{styles:o("input",m),pathString:i,...r,setValue:r.setValue}):e.jsx(fr,{pathString:i,styles:o("string",m),...r})},jr=({value:t,setValue:n,isEditing:s,path:r,setIsEditing:o,handleEdit:i,nodeData:h,handleKeyboard:d,keyboardCommon:m})=>{const{getStyles:a}=ct();return s?e.jsx("input",{className:"jer-input-number",type:"text",name:Qe(r),value:t,onChange:l=>n(l.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:l=>setTimeout(()=>l.target.select(),10),onKeyDown:l=>d(l,{numberConfirm:i,numberUp:()=>n(Number(t)+1),numberDown:()=>n(Number(t)-1),...m}),style:{width:String(t).length/1.5+2+"em",...a("input",h)}}):e.jsx("span",{onDoubleClick:()=>o(!0),className:"jer-value-number",style:a("number",h),children:t})},xr=({value:t,setValue:n,isEditing:s,path:r,setIsEditing:o,handleEdit:i,nodeData:h,handleKeyboard:d,keyboardCommon:m})=>{const{getStyles:a}=ct();return typeof t!="boolean"?null:s?e.jsx("input",{className:"jer-input-boolean",type:"checkbox",name:Qe(r),checked:t,onChange:()=>n(!t),onKeyDown:l=>{l.key===" "&&l.preventDefault(),d(l,{booleanConfirm:i,booleanToggle:()=>n(!t),...m})},autoFocus:!0}):e.jsx("span",{onDoubleClick:()=>o(!0),className:"jer-value-boolean",style:a("boolean",h),children:String(t)})},vr=(t,n)=>{const s=c.useRef(void 0),r=c.useRef(n);c.useEffect(()=>{r.current=n},[n]);const o=i=>{r.current(i)};c.useEffect(()=>{if(window.clearTimeout(s.current),t)return s.current=window.setTimeout(()=>{window.addEventListener("keydown",o)},100),()=>{window.clearTimeout(s.current),window.removeEventListener("keydown",o)}},[t])},br=({value:t,isEditing:n,setIsEditing:s,handleEdit:r,nodeData:o,handleKeyboard:i,keyboardCommon:h})=>{const{getStyles:d}=ct();return vr(n,m=>i(m,{confirm:r,...h})),e.jsx("div",{onDoubleClick:()=>s(!0),className:"jer-value-null",style:d("null",o),children:String(t)})},wr=({value:t})=>{let n="Error!";switch(typeof t){case"string":t===hn&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return e.jsx("span",{className:"jer-value-invalid",children:n})},Cr=({scale:t=1,viewBox:n="0 0 24 24",fill:s="currentColor",children:r,...o})=>{const i=1.4*t+"em";return e.jsx("svg",{viewBox:n,fill:s,width:i,height:i,...o,children:r})},_t=({name:t,nodeData:n})=>{const{getStyles:s,icons:r}=ct(),o=r[t],i=`icon${t[0].toUpperCase()}${t.slice(1)}`;return e.jsx(Cr,{viewBox:o.viewBox,...o.svgProps,scale:o.scale,className:t==="collection"?void 0:"jer-icon",style:s(i,n),children:o.content})},ls=({startEdit:t,handleDelete:n,handleAdd:s,showClipboardButton:r,onCopy:o,type:i,customButtons:h,handleEdit:d,canEdit:m,nodeData:a,translate:l,keyboardControls:g,handleKeyboard:p,editConfirmRef:y,getNewKeyOptions:w,jsonStringify:b,showIconTooltips:v,Select:D})=>{const{getStyles:O}=ct(),{open:L,cancel:C}=kt(),[f,E]=c.useState(""),[N,x]=c.useState(!1),{path:T,value:z}=a,U=Wt(k=>{const R=k.active;return R!==null&&R.op==="add"&<(R.path,T)}),j=Array.isArray(N);Gn(()=>{var A;if(!U)return x(!1),void E("");const k=Object.keys(Ze(a.fullData,T)),R=w?(A=w(a))==null?void 0:A.filter(q=>!k.includes(q)):null;x(R??!0)},[U]);const V=()=>{s&&f&&s(i==="array"?"":f)};return e.jsxs("div",{className:"jer-edit-buttons",style:{opacity:U?1:void 0},onClick:k=>k.stopPropagation(),children:[r&&e.jsx("button",{type:"button",tabIndex:-1,onClick:k=>{var fe;k.stopPropagation();let R,A,q="value",J="",se=null;if(r){const oe=yn(k);if(oe&&g.clipboardModifier.includes(oe)?(R=Yn(T),J=R,q="path"):(R=z,J=typeof R=="object"?b(z):String(R)),!navigator.clipboard)return void(o==null?void 0:o({...a,success:!1,stringValue:J,type:q,error:{code:"CLIPBOARD_ERROR",message:"Can't access clipboard API"}}));(fe=navigator.clipboard)==null||fe.writeText(J).then(()=>A=!0).catch(ce=>{A=!1,se=ce.message}).finally(()=>{o==null||o({...a,success:A,stringValue:J,type:q,error:A?void 0:{code:"CLIPBOARD_ERROR",message:se??"Copy failed"}})})}},className:"jer-copy-pulse","aria-label":l("TOOLTIP_COPY",a),title:v?l("TOOLTIP_COPY",a):"",children:e.jsx(_t,{name:"copy",nodeData:a})}),t&&e.jsx("button",{type:"button",tabIndex:-1,onClick:t,"aria-label":l("TOOLTIP_EDIT",a),title:v?l("TOOLTIP_EDIT",a):"",children:e.jsx(_t,{name:"edit",nodeData:a})}),n&&e.jsx("button",{type:"button",tabIndex:-1,onClick:n,"aria-label":l("TOOLTIP_DELETE",a),title:v?l("TOOLTIP_DELETE",a):"",children:e.jsx(_t,{name:"delete",nodeData:a})}),s&&e.jsx("button",{type:"button",tabIndex:-1,onClick:()=>{i==="object"?L(T,{op:"add"}):s("")},"aria-label":l("TOOLTIP_ADD",a),title:v?l("TOOLTIP_ADD",a):"",children:e.jsx(_t,{name:"add",nodeData:a})}),h==null?void 0:h.map(({Element:k,onClick:R,label:A},q)=>{const J=se=>R==null?void 0:R(a,se,{handleEdit:d,canEdit:m});return A?e.jsx("button",{type:"button",className:"jer-custom-button",tabIndex:-1,onClick:J,"aria-label":A,title:v?A:"",children:e.jsx(k,{nodeData:a,canEdit:m,handleEdit:d})},q):e.jsx("div",{className:"jer-custom-button",onClick:J,children:e.jsx(k,{nodeData:a,canEdit:m,handleEdit:d})},q)}),U&&s&&i==="object"&&e.jsxs(e.Fragment,{children:[j?e.jsx(D,{name:"new-key-select",onChange:s,defaultValue:"",autoFocus:!0,onKeyDown:k=>p(k,{cancel:()=>C()}),placeholder:N.length>0?l("KEY_SELECT",a):l("NO_KEY_OPTIONS",a),options:N}):e.jsx("input",{className:"jer-input-text jer-input-new-key",type:"text",name:"new-object-key",value:f,placeholder:l("KEY_NEW",a),onChange:k=>E(k.target.value),autoFocus:!0,onKeyDown:k=>{p(k,{stringConfirm:()=>V(),cancel:()=>C()})},style:O("input",a)}),e.jsx(xn,{onOk:()=>V(),onCancel:()=>C(),nodeData:a,translate:l,showIconTooltips:v,editConfirmRef:y,hideOk:j})]})]})},xn=({onOk:t,onCancel:n,nodeData:s,translate:r,showIconTooltips:o,editConfirmRef:i,hideOk:h=!1})=>e.jsxs("div",{className:"jer-confirm-buttons",children:[!h&&e.jsx("button",{type:"button",tabIndex:-1,onClick:t,"aria-label":r("TOOLTIP_OK",s),title:o?r("TOOLTIP_OK",s):"",ref:i,children:e.jsx(_t,{name:"ok",nodeData:s})}),e.jsx("button",{type:"button",tabIndex:-1,onClick:n,"aria-label":r("TOOLTIP_CANCEL",s),title:o?r("TOOLTIP_CANCEL",s):"",children:e.jsx(_t,{name:"cancel",nodeData:s})})]}),cs=["string","number","boolean","null"],Nr=["object","array"],Er=[...cs,...Nr],ds=t=>{const{component:n,wrapperComponent:s,keyComponent:r,showKey:o=!0,showEditTools:i=!0,showOnEdit:h=!1,showOnView:d=!0,showCollectionWrapper:m=!0,...a}=t;return{CustomComponent:n,CustomWrapperComponent:s,CustomKeyComponent:r,showKey:o,showEditTools:i,showOnEdit:h,showOnView:d,showCollectionWrapper:m,...a}},us=(t=[],n)=>{const s=t.find(({condition:r})=>r(n));return s?ds(s):{}},hs=({props:t,collapsed:n})=>{const{nodeData:s,parentData:r,onError:o,getLatestData:i,showErrorMessages:h,allowEditFilter:d,allowDeleteFilter:m,allowAddFilter:a,allowDragFilter:l,canAddHere:g,translate:p,errorDisplayTime:y,sort:w,arrayIndexStart:b,handleKeyboard:v,customNodeData:D}=t,{submit:O}=kt(),[L,C]=c.useState(null),f={...s,collapsed:n,visibleSize:mr(s.path)},{path:E,key:N,size:x}=f,T=Qe(E),z=Wt(H=>{const re=H.active;return re!==null&&re.op==="edit"&<(re.path,E)}),U=Wt(H=>{const re=H.active;return re!==null&&re.op==="rename"&<(re.path,E)}),j=Wt(H=>T in H.settling),V=d(f),k=m(f),R=a(f),A=l(f),q=H=>{h&&(C(H),setTimeout(()=>C(null),y)),console.warn("Error",H)},J=c.useRef(f);J.current=f;const se=c.useCallback((H,re)=>{q(H.message),o&&o({...J.current,fullData:i(),error:H,errorValue:re})},[o,h,i,y]),fe=jn(),oe=c.useCallback(H=>(fe===null||fe.visiblePaths.has(Qe(H.path)))&&d(H),[fe,d]),ce=H=>qt(i(),E,H,w,oe),W=(H,re)=>{r&&(N!==H&&Object.keys(r).includes(H)?se({code:"KEY_EXISTS",message:p("ERROR_KEY_EXISTS",f)},H):O({op:"rename",path:E,newKey:H,onCommit:re}).then(le=>{(le==null?void 0:le.status)==="error"&&se(le.error,H)}))},we=typeof E.slice(-1)[0]=="number",ye=r!==null&&!we&&k&&g,Ie={isEditing:z,isEditingKey:U,isPending:j,isArray:we,canEditKey:ye},ae=N===""&&E.length>0?p("EMPTY_STRING",f):null;return{pathString:T,nodeData:f,path:E,name:N,size:x,canEdit:V,canDelete:k,canAdd:R,canDrag:A,error:L,showError:q,onError:se,setError:C,handleEditKey:W,derivedValues:Ie,emptyStringKey:ae,getNextOrPreviousAtPath:ce,buildKeyDisplayProps:({handleCancel:H,getStyles:re,keyValueArray:le,handleClick:je})=>({canEditKey:ye,isEditingKey:U,pathString:T,path:E,name:N,arrayIndexStart:b,handleKeyboard:v,handleEditKey:W,handleCancel:H,styles:re("property",f),getNextOrPrevious:ce,emptyStringKey:ae,nodeData:f,customNodeData:D,getStyles:re,...le!==void 0?{keyValueArray:le}:{},...je!==void 0?{handleClick:je}:{}})}},ps=({canDrag:t,canDelete:n,canDragOnto:s,canAddHere:r,path:o,nodeData:i,onError:h,translate:d})=>{const{getStyles:m}=ct(),{dragSource:a,setDragSource:l,armed:g}=(()=>{const C=c.useContext(os);if(!C)throw new Error("Missing DragSource Context Provider");return C})(),p=kt(),[y,w]=c.useState(!1),b=()=>a.path!==null&&!gn(o,a.path)&&(lt(a.path.slice(0,-1),o.slice(0,-1))?s:a.canDelete&&r),v=c.useMemo(()=>t?{onMouseDown:C=>{C.button===0&&p.getSnapshot().active===null&&(g.current=!0)},onMouseUp:()=>{g.current=!1},onDragStart:C=>{if(!g.current||p.getSnapshot().active!==null)return C.preventDefault(),void C.stopPropagation();g.current=!1,C.stopPropagation(),l({path:o,canDelete:n})},onDragEnd:C=>{g.current=!1,C.stopPropagation(),l({path:null,canDelete:!1})}}:{},[t,n,o]),D=c.useMemo(()=>C=>s||r?{onDragOver:f=>{f.stopPropagation(),b()&&f.preventDefault()},onDrop:f=>{f.stopPropagation(),L(C),l({path:null,canDelete:!1}),w(!1)},onDragEnter:f=>{f.stopPropagation(),b()&&w(C)},onDragExit:f=>{f.stopPropagation(),w(!1)}}:{},[a,s,r,o]),O=c.useMemo(()=>a.path!==null&&b()?e.jsx("div",{className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:o.length},...D("below")}):null,[a,s,r,o.length]),L=C=>{if(a.path===null||!b())return;const f=a.path.slice(-1)[0],E=a.path.slice(0,-1),N=o.slice(0,-1),{parentData:x}=i;typeof f=="string"&&x&&!Array.isArray(x)&&Object.keys(x).includes(f)&&f in x&&!lt(E,N)?h({code:"KEY_EXISTS",message:d("ERROR_KEY_EXISTS",i)},f):p.submit({op:"move",path:a.path,to:{path:o,position:C},instant:!0})};return{dragSourceProps:v,getDropTargetProps:D,BottomDropTarget:O,DropTargetPadding:({position:C,nodeData:f})=>y===C?e.jsx("div",{className:"jer-drag-n-drop-padding",style:m("dropZone",f)}):null,handleDrop:L}},Zt=({isEditingKey:t,canEditKey:n,pathString:s,path:r,name:o,arrayIndexStart:i,handleKeyboard:h,handleEditKey:d,handleCancel:m,handleClick:a,keyValueArray:l,styles:g,getNextOrPrevious:p,emptyStringKey:y,nodeData:w,customNodeData:b,getStyles:v})=>{const{open:D,cancel:O}=kt(),L=pn.useRef(null),C=E=>{var N;return d(((N=L.current)==null?void 0:N.value)??String(o),E)},f=typeof o=="number"?String(o+i):o;if(!t){const E={...g,minWidth:`${Math.min(f.length+1,5)}ch`,flexShrink:f.length>10?1:0};if(b!=null&&b.CustomKeyComponent&&w&&v){const{CustomKeyComponent:N,componentProps:x}=b;return e.jsx(N,{nodeData:w,name:y??f,path:r,canEditKey:n,handleEditKey:T=>{n&&d(T)},startEditingKey:()=>{n&&D(r,{op:"rename",commitOp:C})},handleClick:a,styles:E,componentProps:x,getStyles:v})}return e.jsxs("span",{className:"jer-key-text",style:E,onDoubleClick:()=>n&&D(r,{op:"rename",commitOp:C}),onClick:a,children:[y?e.jsx("span",{className:"jer-empty-string",children:y}):f,f!==""||y?e.jsx("span",{className:"jer-key-colon",children:":"}):null]})}return e.jsx("input",{ref:L,className:"jer-input-text jer-key-edit",type:"text",name:s,defaultValue:f,autoFocus:!0,onFocus:E=>E.target.select(),onKeyDown:E=>h(E,{stringConfirm:()=>d(E.target.value),cancel:m,tabForward:()=>{const N=E.target.value;d(N,()=>{if(l){const x=l==null?void 0:l[0][0],T=x?[...r,x]:p("next");T?D(T):O()}else D(r)})},tabBack:()=>{const N=E.target.value;d(N,()=>{const x=p("prev");x?D(x):O()})}}),style:{width:f.length/1.5+.5+"em"}})},Sr=new Set(["nodeData","customNodeData"]),ms=(t,n)=>{if(s=t.nodeData,r=n.nodeData,s.key!==r.key||s.index!==r.index||s.level!==r.level||s.size!==r.size||!lt(s.path,r.path))return!1;var s,r;const o=Object.keys(n);if(o.length!==Object.keys(t).length)return!1;for(const i of o)if(!Sr.has(i)&&!Object.is(t[i],n[i]))return!1;return!0},kr=t=>{const{data:n,parentData:s,onChange:r,showClipboardButton:o,onCopy:i,canDragOnto:h,canAddHere:d,allowTypeSelection:m,showLabel:a,stringTruncateLength:l,showStringQuotes:g,indent:p,translate:y,customNodeDefinitions:w,customNodeData:b,Select:v,handleKeyboard:D,keyboardControls:O,editConfirmRef:L,jsonStringify:C,showIconTooltips:f,getLatestData:E}=t,{getStyles:N}=ct(),{open:x,cancel:T,submit:z,getSnapshot:U}=kt(),{setCollapseState:j}=Xt(),[V,k]=c.useState(typeof n=="function"?hn:n),{nodeData:R,path:A,name:q,canEdit:J,canDelete:se,canDrag:fe,error:oe,onError:ce,setError:W,derivedValues:we,getNextOrPreviousAtPath:ye,buildKeyDisplayProps:Ie}=hs({props:t}),{dragSourceProps:ae,getDropTargetProps:H,BottomDropTarget:re,DropTargetPadding:le}=ps({canDrag:fe,canDelete:se,canDragOnto:h,canAddHere:d,path:A,nodeData:R,onError:ce,translate:y}),[je,ge]=c.useState(Gt(n,b)),Pe=c.useRef(V);Pe.current=V;const M=c.useRef(R);M.current=R;const K=c.useCallback(I=>{if(!r)return void k(I);const G=r({...M.current,value:Pe.current,fullData:E(),newValue:I});k(G)},[r,E]),Le=()=>{k(typeof n=="function"?hn:n),ge(Gt(n,b)),Me(kn(n,Te))};c.useEffect(()=>{we.isEditing||Le()},[n]);const Te=c.useMemo(()=>{const I=[...Er,...w.filter(({showInTypeSelector:u=!1,name:_})=>u&&!!_).map(({name:u})=>u)];if(typeof m=="boolean")return m?I:[];if(Array.isArray(m))return m;const G=m(R);return typeof G=="boolean"?G?I:[]:G},[R,m,w]),[Ne,Me]=c.useState(kn(V,Te)),{isEditing:xe,isPending:et}=we,Ee=is(A),We=c.useRef(St);if(!Ee)return null;const Se=xe&&je!==Gt(n,b),ve=Se?w.find(I=>I.name===je&&On(I)):void 0,be=ve?ds(ve):b,{CustomComponent:Fe,componentProps:bt,showKey:dt=!0,showEditTools:ut=!0,showOnEdit:Oe,showOnView:de,passOriginalNode:Re}=be,wt=Fe&&(ve!==void 0||!Se&&(xe&&Oe||!xe&&de)),ht=I=>{j(null);const G=Se&&!ve?void 0:be,u=G!=null&&G.toStandardType?G.toStandardType(V):V,_=w.find(ie=>ie.name===I);if(_){const ie=typeof _.defaultValue=="function"?_.defaultValue(R):_.defaultValue;if(On(_)){let Je=ie;if(_.fromStandardType)try{Je=_.fromStandardType(u,R,_.componentProps)}catch{}return k(Je),ge(I),void Me(null)}return z({op:"edit",path:A,value:ie}).then(tt(ie)),void j({path:A,collapsed:!1,includeChildren:!1})}const Q=Te.find(ie=>ie instanceof Object&&ie.enum===I);if(Q)return typeof V=="string"&&Q.values.includes(V)||k(Q.values[0]),Me(Q),void ge(I);const ee=Dr(u,I,y("DEFAULT_NEW_KEY",R));if(I==="object"||I==="array"||I==="null")return z({op:"edit",path:A,value:ee}).then(tt(ee)),void(I!=="null"&&j({path:A,collapsed:!1,includeChildren:!1}));k(ee),ge(I),Me(null)},tt=I=>G=>{if((G==null?void 0:G.status)==="error"&&ce(G.error,I),(G==null?void 0:G.status)==="error"||(G==null?void 0:G.status)==="cancel"){const u=U().active;(u==null?void 0:u.phase)==="editing"&<(u.path,A)||Le()}},De=(I,G)=>{const u=I!==void 0&&!Hn(I);let _;if(u)_=I;else if(wt&&be.fromStandardType)try{_=be.fromStandardType(V,R,be.componentProps)}catch(ee){return void ce({code:"UPDATE_ERROR",message:ee instanceof Error?ee.message:String(ee)},V)}else _=je==="number"?gs(V):V;W(null),ve&&j({path:A,collapsed:!1,includeChildren:!1});const Q=u&&Xe(_)&&!Xe(n);z({op:"edit",path:A,value:_,onCommit:()=>{Q&&j({path:A,collapsed:!1,includeChildren:!1}),G==null||G()}}).then(tt(_))};We.current=De;const $e=()=>{W(null),Le(),T()},{isEditingKey:Ae}=we,nt=!!oe,pt=xe&&Te.length>1,mt=(je!=="invalid"||Fe)&&!oe&&ut,st=a&&dt,ze=()=>x(A,{cancelOp:Le,commitOp:I=>We.current(void 0,I)}),rt=J?ze:St,ft=I=>()=>{const G=ye(I);G&&De(void 0,()=>x(G))},Ue={value:V,parentData:s,setValue:K,isEditing:xe,canEdit:J,setIsEditing:rt,handleEdit:De,handleCancel:$e,path:A,stringTruncateLength:l,showStringQuotes:g,showIconTooltips:f,nodeData:R,enumType:Ne,translate:y,handleKeyboard:D,keyboardCommon:{cancel:$e,tabForward:ft("next"),tabBack:ft("prev")},Select:v},ot={...Ie({handleCancel:$e,getStyles:N}),customNodeData:be},gt=wt?e.jsx(Fe,{...t,value:V,componentProps:bt,setValue:K,handleEdit:De,handleCancel:$e,onKeyDown:I=>D(I,{stringConfirm:De,cancel:$e}),isEditing:xe,isPending:et,setIsEditing:rt,getStyles:N,originalNode:Re?Rn(n,je,Ue):void 0,originalNodeKey:Re?e.jsx(Zt,{...ot,customNodeData:void 0}):void 0,canEdit:J,keyboardCommon:Ue.keyboardCommon}):Rn(n,je,Ue);return e.jsxs("div",{className:"jer-component jer-value-component",style:{marginLeft:s!==null?p/2+"em":0,position:"relative"},draggable:fe&&!xe&&!Ae,...ae,...H("above"),children:[re,e.jsx(le,{position:"above",nodeData:R}),e.jsxs("div",{className:"jer-value-main-row",style:{...N("valueRow",R),flexWrap:q.length>10?"wrap":"nowrap"},children:[st&&e.jsx(Zt,{...ot}),e.jsxs("div",{className:"jer-value-and-buttons",children:[e.jsx("div",{className:"jer-input-component",children:gt}),xe?e.jsx(xn,{onOk:De,onCancel:$e,nodeData:R,translate:y,showIconTooltips:f,editConfirmRef:L}):mt&&e.jsx(ls,{startEdit:J?ze:void 0,handleDelete:se?()=>{z({op:"delete",path:A,instant:!0}).then(I=>{(I==null?void 0:I.status)==="error"&&ce(I.error,V)})}:void 0,showClipboardButton:o,onCopy:i,translate:y,customButtons:t.customButtons,handleEdit:I=>De(I),canEdit:J,nodeData:R,handleKeyboard:D,keyboardControls:O,editConfirmRef:L,jsonStringify:C,showIconTooltips:f,Select:v}),pt&&e.jsx(v,{name:`${q}-type-select`,value:Ne?Ne.enum:je,onChange:I=>ht(I),options:Te.map(I=>I instanceof Object&&"enum"in I?I.enum:I)}),nt&&e.jsx("span",{className:"jer-error-slug",style:N("error",R),children:oe})]})]}),e.jsx(le,{position:"below",nodeData:R})]})},fs=pn.memo(kr,ms),On=t=>!!t.editOnTypeSwitch&&!!t.component&&!!t.showOnEdit,Gt=(t,n)=>n!=null&&n.CustomComponent&&(n!=null&&n.name)&&n.showInTypeSelector?n.name:typeof t=="string"?"string":typeof t=="number"?"number":typeof t=="boolean"?"boolean":t===null?"null":"invalid",Rn=(t,n,s)=>{const r=cs.includes(n)?n:typeof t=="function"?"invalid":Gt(s.value),{value:o}=s;switch(r){case"string":return e.jsx(yr,{...s,value:o});case"number":return e.jsx(jr,{...s,value:o});case"boolean":return e.jsx(xr,{...s,value:o});case"null":return e.jsx(br,{...s});default:return e.jsx(wr,{...s})}},gs=t=>{if(typeof t=="symbol")return 0;const n=Number(t);return isNaN(n)?0:n},Dr=(t,n,s)=>{switch(n){case"string":return t==null?"":String(t);case"number":return gs(t);case"boolean":return!!t;case"null":return null;case"object":return{[s]:t};case"array":return[t];default:return String(t)}},Tr=t=>{const{getStyles:n}=ct(),{open:s,cancel:r,submit:o,areChildrenBeingEdited:i,getSnapshot:h}=kt(),{setCollapseState:d}=Xt(),{mainContainerRef:m,data:a,nodeData:l,parentData:g,showCollectionCount:p,canDragOnto:y,canAddHere:w,collapseFilter:b,collapseAnimationTime:v,showClipboardButton:D,onCopy:O,showIconTooltips:L,indent:C,sort:f,showArrayIndexes:E,defaultValue:N,newKeyOptions:x,translate:T,customNodeDefinitions:z,customNodeData:U,jsonParse:j,jsonStringify:V,TextEditor:k,Select:R,keyboardControls:A,handleKeyboard:q,insertAtTop:J,onCollapse:se,editConfirmRef:fe,collapseClickZones:oe,getLatestData:ce}=t,[W,we]=c.useState(null),{showCollectionWrapper:ye=!0}=U,Ie=ye&&b(l),{contentRef:ae,isAnimating:H,maxHeight:re,collapsed:le,animateCollapse:je,cssTransitionValue:ge}=((S,Y,ke,ue,pe)=>{const[Ve,jt]=c.useState(ke?0:void 0),[Dt,Es]=c.useState(ke),tn=c.useRef(!1),nn=c.useRef(null),bn=c.useRef(0),wn=c.useRef(0),Ss=Y/1e3+"s",ks=c.useCallback(sn=>{var Cn;if(Dt!==sn){switch(window.clearTimeout(wn.current),tn.current=!0,sn){case!0:{const Ut=((Cn=nn.current)==null?void 0:Cn.offsetHeight)??0;bn.current=Ut,jt(Ut),setTimeout(()=>{jt(0)},5);break}case!1:jt(bn.current||((Ut,Nn,Ds,Ts)=>{var Sn;if(!Nn.current)return 0;const En=parseInt(getComputedStyle(Ds.current).getPropertyValue("line-height"))||16,Os=(((Sn=Nn.current)==null?void 0:Sn.offsetWidth)??0)/(.5*En),Rs=Ts(Ut).replace(/\\n/g,`
|
|
7
|
-
`).split(`
|
|
8
|
-
`).map(rn=>Math.ceil(rn.length/Os)).reduce((rn,As)=>rn+As,0)*En;return Math.min(Rs+30,window.innerHeight-50)})(S,nn,ue,pe))}Es(!Dt),wn.current=window.setTimeout(()=>{tn.current=!1,sn||jt(void 0)},Y)}},[Y,Dt,S,ue,pe]);return{contentRef:nn,isAnimating:tn.current,animateCollapse:ks,maxHeight:Ve,collapsed:Dt,cssTransitionValue:Ss}})(a,v,Ie,m,V),{pathString:Pe,nodeData:M,path:K,name:Le,size:Te,canEdit:Ne,canDelete:Me,canAdd:xe,canDrag:et,error:Ee,setError:We,onError:Se,derivedValues:ve,buildKeyDisplayProps:be}=hs({props:t,collapsed:le}),{dragSourceProps:Fe,getDropTargetProps:bt,BottomDropTarget:dt,DropTargetPadding:ut}=ps({canDrag:et,canDelete:Me,canDragOnto:y,canAddHere:w,path:K,nodeData:M,onError:Se,translate:T}),Oe=c.useRef(!Ie),{isEditing:de,isEditingKey:Re,isPending:wt,isArray:ht}=ve,tt=(S=>{const Y=c.useRef(S),ke=!Object.is(Y.current,S);return c.useEffect(()=>{Y.current=S}),ke})(b);c.useEffect(()=>{const S=ye&&b(M)&&!de;Oe.current=!S,je(S),tt&&d(null)},[b]),((S,Y,ke)=>{const{commands:ue,version:pe}=Xt(),Ve=c.useRef(0);c.useEffect(()=>{if(pe===Ve.current||(Ve.current=pe,!ue))return;let jt;for(const Dt of ue)dr(S,Dt)&&(jt=Dt);jt&&(jt.collapsed||(Y.current=!0),ke(jt.collapsed))},[pe,ue])})(K,Oe,ye?je:St);const De=c.useRef(null),$e=c.useCallback(S=>we(Y=>typeof S=="function"?S(Y??V(a)):S),[a,V]),Ae=c.useCallback(()=>we(null),[]),nt=c.useMemo(()=>de?W??V(a):null,[de,W,a,V]),pt=c.useCallback((S,Y)=>{if(typeof N!="function")return N;const ke=N(S,Y);return ke!==void 0?ke:null},[N]),mt=c.useCallback(S=>x?typeof x!="function"?x:x(S):null,[x]),{CustomComponent:st,componentProps:ze,CustomWrapperComponent:rt,wrapperProps:ft={},showKey:Ue=!0,showEditTools:ot=!0,showOnEdit:gt,showOnView:I,passOriginalNode:G}=U,u=Wt(S=>S.active!==null&&gn(S.active.path,K));!u&&ye||!le||je(!1);const _=is(K)||M.level===0,Q=c.useRef(St);if(!_&&!u)return null;const{visibleSize:ee}=M,ie=Array.isArray(a)?"array":"object",Je=ie==="array"?{open:"[",close:"]"}:{open:"{",close:"}"},Kt=S=>{if(S.key==="Tab"&&!S.getModifierState("Shift")&&S.target===De.current){S.preventDefault();const Y=Zn(De," ");return void we(Y)}q(S,{objectConfirm:yt,cancel:P})},It=S=>{if(S.stopPropagation(),!ye)return;const Y=yn(S);if(Y&&A.collapseModifier.includes(Y))return Oe.current=!0,void d({collapsed:!le,path:K,includeChildren:!0});i(K)||(Oe.current=!0,se&&se({...M,fullData:ce(),collapsed:!le,includeChildren:!1}),je(!le))},yt=(S,Y)=>{const ke=S!==void 0&&!Hn(S);let ue=a;if(ke)ue=S;else if(W!==null)try{ue=j(W)}catch{return void Se({code:"INVALID_JSON",message:T("ERROR_INVALID_JSON",M)},W)}We(null),o({op:"edit",path:K,value:ue,onCommit:()=>{Ae(),Y==null||Y()}}).then(pe=>{if((pe==null?void 0:pe.status)==="error"&&Se(pe.error,ue),(pe==null?void 0:pe.status)==="error"||(pe==null?void 0:pe.status)==="cancel"){const Ve=h().active;(Ve==null?void 0:Ve.phase)==="editing"&<(Ve.path,K)||Ae()}})};Q.current=yt;const Pt=S=>yt(S),$=K.length>0?()=>{o({op:"delete",path:K,instant:!0}).then(S=>{(S==null?void 0:S.status)==="error"&&Se(S.error,a)})}:void 0,P=()=>{r(),We(null),Ae()},X=p==="when-collapsed"?le:p==="when-collapsed-or-filtered"?le||ee!=null:p,he=!de&&ot,Z=(E||!ht)&&Ue&&Le!==void 0,Ce=st&&(de&>||!de&&I),te=Object.entries(a).map(([S,Y])=>[ie==="array"?Number(S):S,Y]);ie==="object"&&f(te,S=>S);const F=!de||!!st&>,B=()=>e.jsxs("div",{className:"jer-collection-text-edit"+(k?"-custom":""),children:[k?e.jsx(k,{value:nt??"",onChange:we,onKeyDown:S=>q(S,{objectConfirm:yt,cancel:P})}):e.jsx(Xn,{textAreaRef:De,className:"jer-collection-text-area",name:Pe,value:nt??"",setValue:$e,onKeyDown:Kt,styles:n("input",M)}),e.jsx("div",{className:"jer-collection-input-button-row",children:e.jsx(xn,{onOk:yt,onCancel:P,nodeData:M,translate:T,showIconTooltips:L,editConfirmRef:fe})})]}),ne=Oe.current?F?te.map(([S,Y],ke)=>{const ue={key:S,value:Y,path:[...K,S],level:K.length+1,index:ke,size:Xe(Y)?Object.keys(Y).length:null,parentData:a,fullData:M.fullData},pe=us(z,ue);return e.jsx("div",{className:"jer-collection-element",style:n("collectionElement",ue),children:Xe(Y)&&!(pe!=null&&pe.renderCollectionAsValue)?e.jsx(ys,{...t,data:Y,parentData:a,nodeData:ue,canDragOnto:Ne,canAddHere:xe,customNodeData:pe},S):e.jsx(fs,{...t,data:Y,parentData:a,nodeData:ue,canDragOnto:Ne,canAddHere:xe,showLabel:ie==="object"||E,customNodeData:pe},S)},S)}):e.jsx(e.Fragment,{children:B()}):null,me=!!ye&&le&&!u;me||(Oe.current=!0);const Be=T(le?"TOOLTIP_EXPAND":"TOOLTIP_COLLAPSE",M),Ye=()=>({...t,data:a,value:a,parentData:g,nodeData:M,setValue:Pt,handleEdit:yt,handleCancel:P,onKeyDown:Kt,isEditing:de,isPending:wt,setIsEditing:Ne?()=>s(K,{cancelOp:Ae,commitOp:S=>Q.current(void 0,S)}):St,getStyles:n,canDragOnto:Ne,canAddHere:xe,canEdit:Ne,keyboardCommon:{}}),_e=Ce?e.jsx(st,{componentProps:ze,...Ye(),originalNode:G&&de?B():void 0,children:ne}):ne,qe=he&&e.jsx(ls,{startEdit:Ne?()=>{Oe.current=!0,s(K,{cancelOp:Ae,commitOp:S=>Q.current(void 0,S)})}:void 0,handleAdd:xe?S=>{d(null),je(!1);const Y=pt(M,S);if(ie==="array"){const ue=J.array?0:a.length,pe=J.array?{insert:!0}:{};return void o({op:"add",path:K,key:ue,value:Y,options:pe,instant:!0}).then(Ve=>{(Ve==null?void 0:Ve.status)==="error"&&Se(Ve.error,Y)})}if(S in a)return Se({code:"KEY_EXISTS",message:T("ERROR_KEY_EXISTS",M)},S),void r();const ke=J.object?{insertBefore:0}:{};o({op:"add",path:K,key:S,value:Y,options:ke}).then(ue=>{(ue==null?void 0:ue.status)==="error"&&Se(ue.error,Y)})}:void 0,handleDelete:Me?$:void 0,showClipboardButton:D,onCopy:O,type:ie,nodeData:M,translate:T,customButtons:t.customButtons,handleEdit:Pt,canEdit:Ne,keyboardControls:A,handleKeyboard:q,getNewKeyOptions:mt,editConfirmRef:fe,jsonStringify:V,showIconTooltips:L,Select:R}),Ke=be({handleCancel:P,getStyles:n,keyValueArray:te,handleClick:oe.includes("property")?It:S=>S.stopPropagation()}),at=e.jsxs("div",{className:"jer-component jer-collection-component",style:{marginLeft:(K.length===0?0:C/2)+"em",...n("collection",M),position:"relative"},draggable:et&&!de&&!Re&&!u,...Fe,...bt("above"),children:[ye&&e.jsx("div",{className:"jer-clickzone",style:{width:C/2+1+"em",zIndex:10+2*M.level},onClick:oe.includes("left")?It:void 0}),!de&&dt,e.jsx(ut,{position:"above",nodeData:M}),ye?e.jsxs("div",{className:"jer-collection-header-row",style:{...n("headerRow",M),position:"relative"},onClick:oe.includes("header")?It:void 0,children:[e.jsxs("div",{className:"jer-collection-name",children:[e.jsx("button",{type:"button",className:"jer-collapse-icon jer-accordion-icon"+(le?" jer-rotate-90":""),style:{zIndex:11+2*M.level,transition:ge},onClick:It,tabIndex:-1,"aria-expanded":!le,"aria-label":Be,title:L?Be:"",children:e.jsx(_t,{name:"collection",nodeData:M})}),Z&&e.jsx(Zt,{...Ke}),!de&&e.jsx("span",{className:"jer-brackets jer-bracket-open",style:n("bracket",M),children:Je.open})]}),p!==!1&&!de&&e.jsx("div",{className:"jer-collection-item-count"+(X?" jer-visible":" jer-hidden"),style:{...n("itemCount",M),transition:ge,transitionBehavior:"allow-discrete"},children:ee!=null&&ee!==Te?T("ITEMS_FILTERED",M,{visible:ee,total:Te}):Te===1?T("ITEM_SINGLE",{...M,size:1},1):T("ITEMS_MULTIPLE",M,Te)}),e.jsx("div",{className:"jer-brackets"+(me?" jer-visible":" jer-hidden"),style:{...n("bracket",M),transition:ge},children:Je.close}),qe]}):Ue?e.jsxs("div",{className:"jer-collection-header-row",style:{...n("headerRow",M),position:"relative"},children:[e.jsx(Zt,{...Ke}),qe]}):e.jsx(e.Fragment,{}),e.jsxs("div",{className:"jer-collection-inner",style:{overflowY:me||H?"clip":"visible",maxHeight:u?void 0:re,...n("collectionInner",M),transition:`max-height ${ge}`},ref:ae,children:[_e,e.jsx("div",{className:de?"jer-collection-error-row-edit":"jer-collection-error-row",children:Ee&&e.jsx("span",{className:"jer-error-slug",style:n("error",M),children:Ee})}),!de&&ye&&e.jsx("div",{className:"jer-brackets jer-bracket-outside",style:n("bracket",M),children:Je.close})]}),e.jsx(ut,{position:"below",nodeData:M})]});return rt?e.jsx(rt,{wrapperProps:ft,...Ye(),children:at}):at},ys=pn.memo(Tr,ms),Or=({options:t,value:n,defaultValue:s,onChange:r,placeholder:o,className:i,...h})=>e.jsxs("div",{className:"jer-select",children:[e.jsxs("select",{className:i??"jer-select-inner",onChange:d=>r(d.target.value),...h,...n!==void 0?{value:n}:{defaultValue:s??""},children:[o!==void 0&&e.jsx("option",{value:"",disabled:!0,children:o}),t.map(d=>e.jsx("option",{value:d,children:d},d))]}),e.jsx("span",{className:"focus"})]}),zt=(t,n="")=>{const{value:s}=t;if(s===null&&"null".includes(n.toLowerCase()))return!0;switch(typeof s){case"string":return s.toLowerCase().includes(n.toLowerCase());case"number":return!!String(s).includes(n);case"boolean":return s?"true".includes(n.toLowerCase())||n==="1":"false".includes(n.toLowerCase())||n==="0";default:return!1}},An=({key:t,path:n},s="")=>!!zt({value:t},s)||!!n.some(r=>zt({value:r},s)),Rr={ITEM_SINGLE:"{{count}} item",ITEMS_MULTIPLE:"{{count}} items",ITEMS_FILTERED:"{{visible}} of {{total}} items",KEY_NEW:"Enter new key",KEY_SELECT:"Select key",NO_KEY_OPTIONS:"No key options",ERROR_KEY_EXISTS:"Key already exists",ERROR_INVALID_JSON:"Invalid JSON",ERROR_UPDATE:"Update unsuccessful",ERROR_DELETE:"Delete unsuccessful",ERROR_ADD:"Adding node unsuccessful",ERROR_RENAME:"Rename unsuccessful",ERROR_MOVE:"Move unsuccessful",DEFAULT_NEW_KEY:"key",SHOW_LESS:"(Show less)",SHOW_MORE:"Show more",EMPTY_STRING:"<empty string>",TOOLTIP_COPY:"Copy to clipboard",TOOLTIP_EDIT:"Edit",TOOLTIP_DELETE:"Delete",TOOLTIP_ADD:"Add",TOOLTIP_OK:"OK",TOOLTIP_CANCEL:"Cancel",TOOLTIP_COLLAPSE:"Collapse",TOOLTIP_EXPAND:"Expand"};var on=':root,:host{--jer-select-border: #b6b6b6;--jer-select-focus: #777;--jer-select-arrow: #777;--jer-form-border: 1px solid #ededf0;--jer-form-border-focus: 1px solid #e2e2e2;--jer-highlight-color: #b3d8ff;--jer-icon-copy-color: #268bd2}.jer-visible{opacity:1}.jer-hidden{opacity:0}.jer-select select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;padding:0 1em 0 0;margin:0;font-family:inherit;font-size:.8em;color:#000;cursor:inherit;line-height:inherit;z-index:1;outline:none}select::-ms-expand{display:none}.jer-select{display:grid;grid-template-areas:"select";align-items:center;position:relative;min-width:12ch;max-width:15ch;border:1px solid var(--jer-select-border);border-radius:.25em;padding:.25em .5em;cursor:pointer;line-height:1.1;background-color:#fff;background-image:linear-gradient(to top,#f9f9f9,#fff 33%)}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{content:"";justify-self:end;width:.8em;height:.5em;background-color:var(--jer-select-arrow);clip-path:polygon(100% 0%,0 0%,50% 100%)}select:focus+.focus{position:absolute;inset:-1px;border:1px solid var(--jer-select-focus);border-radius:inherit}.jer-select-inner{width:100%;text-overflow:ellipsis}.jer-editor-container{position:relative;font-size:16px;line-height:1;padding:1em 1em 1em 2em;border-radius:.5em;text-align:left}.jer-editor-container textarea{color:var(--jer-input-color);border:var(--jer-form-border);border-radius:.3em;outline:none}.jer-editor-container textarea:focus{border:var(--jer-form-border-focus)}.jer-editor-container input{border:var(--jer-form-border);border-radius:.3em;outline:none;font-family:inherit}.jer-editor-container input:focus{border:var(--jer-form-border-focus)}.jer-editor-container ::selection{background-color:var(--jer-highlight-color)}.jer-collection-header-row,.jer-value-main-row{display:flex;min-height:1.7em;gap:.3em;align-items:center}.jer-collection-header-row{flex-wrap:wrap}.jer-value-main-row{gap:0}.jer-bracket-outside{padding-left:0}.jer-collection-item-count{display:none}.jer-collection-item-count.jer-visible{display:block}@starting-style{.jer-collection-item-count.jer-visible{opacity:0}}.jer-collapse-icon{position:absolute;left:-1.2em;top:50%;transform:translateY(-50%)}.jer-collapse-icon.jer-rotate-90{transform:translateY(-50%) rotate(-90deg)}.jer-collection-inner{position:relative}.jer-collection-text-edit,.jer-collection-text-edit-custom{display:flex;flex-direction:column;gap:.3em;align-items:flex-start;line-height:1.1em}.jer-collection-text-edit{width:fit-content}.jer-collection-text-area{box-sizing:content-box;resize:both;padding:.2em .5em 0;overflow:hidden;max-height:40em;line-height:1.25em;font-family:inherit;font-size:.85em}.jer-collection-input-button-row{display:flex;justify-content:flex-end;width:100%;font-size:150%;margin-top:.4em}.jer-collection-error-row-edit{position:absolute;bottom:.5em}.jer-error-slug{margin-left:1em}.jer-value-component{position:relative}.jer-value-and-buttons{display:flex;justify-content:flex-start;align-items:center;padding-left:.5em}.jer-value-error-row{position:absolute}.jer-value-string{line-height:1.3em;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word}.jer-string-expansion{cursor:pointer;opacity:.6;filter:saturate(50%)}.jer-string-expansion.jer-show-less{font-size:80%}.jer-hyperlink{text-decoration:underline}.jer-input-text{box-sizing:content-box;resize:none;margin:0;height:1.2em;padding:.25em .5em .2em;min-width:6em;overflow:hidden;line-height:1.2em;font-family:inherit;font-size:.9em}.jer-input-boolean{transform:scale(1.5);margin-left:.3em;margin-right:.3em}.jer-key-text{word-break:break-word;line-height:1.1em;white-space:pre-wrap}.jer-value-invalid{opacity:.5;font-style:italic}.jer-input-number{min-width:3em;font-size:90%}.jer-edit-buttons,.jer-confirm-buttons{display:flex;align-items:center;cursor:pointer;height:1em;margin-right:.2em}.jer-edit-buttons>button,.jer-confirm-buttons>button,button.jer-collapse-icon,button.jer-string-expansion{appearance:none;background:none;border:none;margin:0;padding:0;font:inherit;color:inherit;vertical-align:baseline}.jer-input-buttons{gap:.4em}.jer-edit-buttons{gap:.4em;margin-left:.5em;opacity:0}.jer-custom-button:empty{display:none}.jer-confirm-buttons{gap:.2em;margin-left:.4em}.jer-edit-buttons:hover{opacity:1;position:relative}.jer-collection-header-row:hover>.jer-edit-buttons{opacity:1}.jer-value-main-row:hover>.jer-edit-buttons{opacity:1}.jer-value-and-buttons:hover>.jer-edit-buttons{opacity:1}.jer-copy-pulse{position:relative;transition:.3s}.jer-copy-pulse:hover{opacity:.85;transition:.3s;transform:scale(1.2)}.jer-copy-pulse:after{content:"";display:block;position:absolute;border-radius:50%;left:0;top:0;width:100%;height:100%;opacity:0;transition:all .5s;box-shadow:0 0 15px 5px var(--jer-icon-copy-color)}.jer-copy-pulse:active:after{box-shadow:0 0 0 0 var(--jer-icon-copy-color);position:absolute;border-radius:4em;left:0;top:0;opacity:1;transition:0s}.jer-copy-pulse:active{top:.07em}.jer-icon:hover{opacity:.85;transition:.3s;transform:scale(1.2)}.jer-empty-string{font-style:italic;font-size:90%}.jer-drag-n-drop-padding{height:.5em;border:1px dashed #b4b4b4;border-radius:.3em}.jer-clickzone{position:absolute;left:-1em;top:1.2em;height:calc(100% - .8em)}';const _n="data-jer-styles",Ar=(t,n)=>JSON.stringify(t,n,2),_r={edit:"ERROR_UPDATE",add:"ERROR_ADD",delete:"ERROR_DELETE",rename:"ERROR_RENAME",move:"ERROR_MOVE"},Ir={edit:"UPDATE_ERROR",add:"ADD_ERROR",delete:"DELETE_ERROR",rename:"RENAME_ERROR",move:"MOVE_ERROR"},Vt=t=>{const n=c.useRef(t);t&&(n.current=t);const s=c.useRef((...r)=>n.current(...r));return t?s.current:void 0},Pr=[],Lr=["header","left"],Mr={},Kr={},Vr={},Fr=[],$r=({data:t,setData:n,buildNodeDataFromPathRef:s,commitRef:r,rootName:o="root",onUpdate:i=St,onChange:h,onError:d,onEditEvent:m,showErrorMessages:a=!0,showClipboardButton:l=!0,onCopy:g,indent:p=2,collapse:y=3,collapseAnimationTime:w=300,showCollectionCount:b="when-collapsed-or-filtered",allowEdit:v=!0,allowDelete:D=!0,allowAdd:O=!0,allowTypeSelection:L=!0,allowDrag:C=!1,searchFilter:f,searchText:E,searchDebounceTime:N=350,sortKeys:x=!1,showArrayIndexes:T=!0,arrayIndexStart:z=0,showStringQuotes:U=!0,showIconTooltips:j=!1,defaultValue:V=null,newKeyOptions:k,minWidth:R=250,maxWidth:A="min(600px, 90vw)",baseFontSize:q,stringTruncateLength:J=250,translations:se=Mr,className:fe,id:oe,customText:ce=Kr,customNodeDefinitions:W=Pr,customButtons:we=Fr,jsonParse:ye=JSON.parse,jsonStringify:Ie=Ar,TextEditor:ae,Select:H=Or,errorDisplayTime:re=2500,keyboardControls:le=Vr,editorRef:je,insertAtTop:ge=!1,onCollapse:Pe,collapseClickZones:M=Lr})=>{const{getStyles:K,cssVars:Le}=ct(),{open:Te,cancel:Ne,getSnapshot:Me}=kt(),xe=c.useMemo(()=>Ft(y),[y]),et=c.useMemo(()=>(($,P)=>(X,he,Z)=>((Ce,te,F,B,ne)=>{if(te[B]){const Be=te[B](F);if(Be!==null)return Be}let me=B in Ce?Ce[B]:Rr[B];if(ne!==void 0){const Be=un(ne)?ne:{count:ne};for(const[Ye,_e]of Object.entries(Be))me=me==null?void 0:me.replace(`{{${Ye}}}`,String(_e))}return me})($,P,he,X,Z))(se,ce),[se,ce]),[Ee,We]=c.useState(E),Se=c.useRef(null);c.useEffect(()=>{Ne();const $=setTimeout(()=>We(E),N);return()=>clearTimeout($)},[E,N]);const ve=xt(t,[],o),be=c.useRef(t);be.current=t;const Fe=c.useRef(n);Fe.current=n;const bt=c.useRef(et);bt.current=et;const dt=c.useRef(ve);dt.current=ve;const ut=c.useRef(i);ut.current=i;const Oe=c.useRef(o);Oe.current=o;const de=c.useRef(void 0),Re=c.useCallback(()=>be.current,[]),wt=Vt(h),ht=Vt(d),tt=Vt(Pe),De=Vt(m),$e=Vt(g),Ae=c.useCallback($=>{be.current=$,Fe.current($)},[]),nt=c.useCallback(($,P)=>{Ae(Ge(be.current,$,P,"update").newData)},[Ae]),pt=c.useCallback($=>{const P=be.current,X=Oe.current,he=de.current,Z=Ae,{op:Ce,path:te}=$;switch(Ce){case"edit":{const{newData:F,currentValue:B,newValue:ne}=Ge(P,te,$.value,"update"),me=xt(P,te,X,he);return{input:{...me,newData:F,event:"edit",newValue:ne},nodeData:me,isNoOp:B===ne,apply:()=>Z(F),revert:()=>Z(Ge(be.current,te,B,"update").newData)}}case"delete":{const{newData:F,currentValue:B}=Ge(P,te,"","delete"),ne=xt(P,te,X,he);return{input:{...ne,newData:F,event:"delete"},nodeData:ne,isNoOp:!1,apply:()=>Z(F),revert:()=>Z(Ge(be.current,te,B,"add",{insert:!0,insertBefore:ne.index}).newData)}}case"add":{const F=[...te,$.key],{newData:B,newValue:ne}=Ge(P,F,$.value,"add",$.options),me=xt(B,F,X,he);return{input:{...me,value:void 0,size:null,parentData:Ze(P,te)??null,fullData:P,newData:B,event:"add",newValue:ne},nodeData:me,isNoOp:!1,apply:()=>Z(B),revert:()=>Z(Ge(be.current,F,"","delete").newData)}}case"rename":{const F=te.slice(0,-1),B=te[te.length-1],{newKey:ne}=$,me=Ze(P,F),Be=Object.fromEntries(Object.entries(me).map(([qe,Ke])=>qe===B?[ne,Ke]:[qe,Ke])),{newData:Ye}=Ge(P,F,Be,"update"),_e=xt(P,te,X,he);return{input:{..._e,newData:Ye,event:"rename",newKey:ne},nodeData:_e,isNoOp:B===ne,apply:()=>Z(Ye),revert:()=>Z(Ge(be.current,F,me,"update").newData),extra:{oldKey:B,newKey:ne}}}case"move":{const F=te,{path:B,position:ne}=$.to,me=P,{newData:Be,currentValue:Ye}=Ge(P,F,"","delete"),_e=F.slice(-1)[0],qe=B.slice(0,-1),Ke=B.slice(-1)[0];let at=typeof Ke=="number"?ne==="above"?Ke:Ke+1:typeof _e=="number"?`arr_${_e}`:_e;F.slice(0,-1).join(".")===B.slice(0,-1).join(".")&&typeof _e=="number"&&typeof at=="number"&&_e<at&&(at-=1);const S=typeof at=="number"?{insert:!0}:ne==="above"?{insertBefore:Ke}:{insertAfter:Ke},Y=[...qe,at],{newData:ke}=Ge(Be,Y,Ye,"add",S),ue=xt(P,F,X,he);return{input:{...ue,newData:ke,event:"move",newPath:Y},nodeData:ue,isNoOp:!1,apply:()=>Z(ke),revert:()=>Z(me)}}}},[Ae]),mt=c.useCallback(($,P)=>{const X=Ir[$.event],he=()=>bt.current(_r[$.event],dt.current),Z=F=>{const B=F instanceof Error&&F.message?F.message:typeof F=="string"&&F?F:he();return{status:"error",error:{code:X,message:B}}},Ce=F=>{if(F===!1)return{status:"error",error:{code:X,message:he()}};if(F===null)return{status:"cancel"};if(F&&typeof F=="object"){if(F.error!==void 0)return typeof F.error=="string"?{status:"error",error:{code:X,message:F.error}}:{status:"error",error:F.error};const B=F.data!==void 0,ne=F.value!==void 0;if(B&&ne&&console.warn("json-edit-react: onUpdate returned both { value } and { data }; { data } (whole-document) takes precedence and { value } is ignored."),B)return{status:"override",value:F.data,path:[]};if(ne&&($.event==="edit"||$.event==="add"))return{status:"override",value:F.value,path:$.path}}return{status:"commit"}};let te;try{te=ut.current($,P)}catch(F){return Z(F)}return Wn(te)?te.then(Ce,Z):Ce(te)},[]),st=c.useMemo(()=>({runUpdate:i===St?void 0:mt,buildCommit:pt,applyValue:nt}),[mt,pt,nt,i]);r.current=st;const ze=c.useMemo(()=>Ft(v),[v]),rt=c.useMemo(()=>Ft(D),[D]),ft=c.useMemo(()=>Ft(O),[O]),Ue=c.useMemo(()=>Ft(C),[C]),ot=c.useMemo(()=>Wr(f),[f]),gt=c.useMemo(()=>(($,P,X)=>{if(!P&&!X)return null;const he=new Set,Z=new Map,Ce=P??zt,te=X??"",F=B=>{let ne=Ce(B,te);if(Xe(B.value)){let me=0;const Be=Array.isArray(B.value),Ye=Object.entries(B.value);for(const[_e,qe]of Ye){const Ke=Be?Number(_e):_e,at={key:Ke,path:[...B.path,Ke],level:B.level+1,index:me,value:qe,size:Xe(qe)?Object.keys(qe).length:null,parentData:B.value,fullData:B.fullData};F(at)&&(ne=!0,me++)}Z.set(Qe(B.path),me)}return ne&&he.add(Qe(B.path)),ne};return F($),{visiblePaths:he,visibleChildCounts:Z}})(ve,ot,Ee),[t,Ee,ot,o]),I=c.useMemo(()=>($=>{const P={...Dn};for(const X of Object.keys(Dn)){const he=X,Z=$[he];if(Z===void 0)continue;const Ce=X==="clipboardModifier"||X==="collapseModifier";if(Z===null){P[he]=Ce?[]:null;continue}const te=Ce?fn(Z):typeof Z=="string"?{key:Z}:Z;P[he]=te}return nr.forEach(X=>{$[X]===void 0&&$.confirm!==void 0&&(P[X]=P.confirm)}),P})(le),[le]),G=c.useCallback(($,P)=>((X,he,Z)=>{for(const[Ce,te]of Object.entries(he))if(tr(Z,X[Ce],Ce)){Z.preventDefault(),te();break}})(I,P,$),[I]),u=c.useMemo(()=>{const $=In(W,"stringifyReplacer");return P=>Ie(P,$)},[W,Ie]),_=c.useMemo(()=>{const $=In(W,"parseReviver");return P=>{const X=ye(P,$);return zn(X)}},[W,ye]),Q=c.useRef(null),{setCollapseState:ee}=Xt(),ie=c.useCallback(($,P)=>{x!==!1&&(typeof x!="function"?$.sort((X,he)=>{const Z=P(X)[0],Ce=P(he)[0];return Z<Ce?-1:Z>Ce?1:0}):$.sort((X,he)=>x(P(X),P(he))))},[x]);de.current=ie;const Je=c.useCallback($=>xt(Re(),$,Oe.current,de.current),[Re]);s.current=Je,c.useImperativeHandle(je,()=>{const $=Symbol("path-missing");return{collapse:P=>ee(P),startEdit:({path:P,overrideRestrictions:X=!1})=>Ze(Re(),P,$)===$?"PATH_NOT_FOUND":X||ze(xt(Re(),P,o,ie))?(Te(P,{force:!0}),!0):"RESTRICTED",confirm:()=>{var P;Q.current&&(Q.current.click(),((P=Me().active)==null?void 0:P.phase)!=="editing"&&Ne())},cancel:()=>Ne()}},[ee,Te,Ne,Me,ze,Re,o,ie]);const Kt=us(W,ve),It=c.useMemo(()=>({object:ge===!0||ge==="object",array:ge===!0||ge==="array"}),[ge]),yt={mainContainerRef:Se,name:o,nodeData:ve,getLatestData:Re,onChange:wt,onError:ht,onEditEvent:De,showErrorMessages:a,showCollectionCount:b,collapseFilter:xe,collapseAnimationTime:w,allowEditFilter:ze,allowDeleteFilter:rt,allowAddFilter:ft,allowTypeSelection:L,allowDragFilter:Ue,canDragOnto:!1,canAddHere:!1,showClipboardButton:l,onCopy:$e,sortKeys:x,sort:ie,showArrayIndexes:T,arrayIndexStart:z,showStringQuotes:U,showIconTooltips:j,indent:p,defaultValue:V,newKeyOptions:k,stringTruncateLength:J,translate:et,customNodeDefinitions:W,customNodeData:Kt,customButtons:we,parentData:null,jsonParse:_,jsonStringify:u,TextEditor:ae,Select:H,errorDisplayTime:re,handleKeyboard:G,keyboardControls:I,insertAtTop:It,onCollapse:tt,editConfirmRef:Q,collapseClickZones:M},Pt={...K("container",ve),...Le,minWidth:R,maxWidth:A};return Pt.fontSize=q??Pt.fontSize,e.jsx("div",{id:oe,ref:Se,className:`jer-editor-container ${fe??""}`,style:Pt,children:e.jsx(pr,{value:gt,children:Xe(t)&&!Kt.renderCollectionAsValue?e.jsx(ys,{data:t,...yt}):e.jsx(fs,{data:t,showLabel:!0,...yt})})})};function Br(t){c.useInsertionEffect(()=>{(()=>{if(typeof document>"u")return;const o=document.head.querySelector(`style[${_n}]`);if(o)return void(o.textContent!==on&&(o.textContent=on));const i=document.createElement("style");i.setAttribute(_n,""),i.textContent=on,document.head.appendChild(i)})()},[]);const n=c.useRef(void 0),s=c.useRef(void 0),r=t;return e.jsx(or,{theme:r.theme??en,children:e.jsx(hr,{onEditEvent:r.onEditEvent,onCollapse:r.onCollapse,buildNodeDataFromPathRef:n,commitRef:s,children:e.jsx($r,{...r,buildNodeDataFromPathRef:n,commitRef:s})})})}const Ge=(t,n,s,r,o={})=>{if(n.length===0)return{currentData:t,newData:s,currentValue:t,newValue:s};const i={remove:r==="delete",...o},h=r!=="add"?Ze(t,n):void 0;return{currentData:t,newData:Xs(t,n,s,i),currentValue:h,newValue:r!=="delete"?s:void 0}},Ft=t=>typeof t=="boolean"?()=>t:typeof t=="number"?({level:n})=>n>=t:t,Wr=t=>{if(t!==void 0)return t==="value"?zt:t==="key"?An:t==="all"?(n,s)=>zt(n,s)||An(n,s):t},In=(t,n)=>{const s=n==="stringifyReplacer"?[r=>r===void 0?Un:r]:[];if(s.push(...t.map(r=>r[n]).filter(r=>!!r)),s.length!==0)return(r,o)=>{let i=o;for(const h of s)i=h(i);return i}};function Hr(t){const{editorRef:n,...s}=t,r=c.useRef(null);return c.useImperativeHandle(n,()=>({collapse:o=>{var i;return(i=r.current)==null?void 0:i.collapse(o)}}),[]),e.jsx(Br,{...s,editorRef:r,setData:St,allowEdit:!1,allowAdd:!1,allowDelete:!1,allowDrag:!1})}const Ht=50,zr=2e5,js=c.createContext(""),xs=c.createContext(null),Ur={container:{backgroundColor:"transparent",color:"var(--text)",fontFamily:"var(--font-mono)",padding:"8px 0 8px 20px"},property:"var(--text)",string:"var(--ok)",number:"var(--accent)",boolean:"var(--accent)",null:"var(--text-secondary)",bracket:"var(--text-secondary)",itemCount:"var(--text-secondary)",iconCollection:"var(--text-secondary)",iconCopy:"var(--text-secondary)",collectionInner:{borderLeft:"1px solid var(--line)"},inputHighlight:"var(--ctl-fill)"},Jr=new Set(["resourceLogs","resourceMetrics","resourceSpans","scopeLogs","scopeMetrics","scopeSpans","logRecords","metrics","spans"]),Yr=({path:t,level:n,size:s})=>s!==null&&s>Ht?n>0:n===0?!1:!t.every(r=>typeof r=="number"||Jr.has(r)),qr=[{condition:({size:t})=>t!==null&&t>Ht,renderCollectionAsValue:!0,component:({value:t})=>e.jsx(ws,{value:t,root:!0})}];function vs({name:t}){return e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"tr-json-key",children:typeof t=="string"?JSON.stringify(t):t}),": "]})}function bs({value:t,name:n,root:s=!1}){if(t!==null&&typeof t=="object")return e.jsx(ws,{value:t,name:n,root:s});const r=t===null?"null":typeof t;return e.jsxs("div",{children:[n!==void 0&&e.jsx(vs,{name:n}),e.jsx("span",{className:`tr-json-${r}`,children:JSON.stringify(t)})]})}function ws({value:t,name:n,root:s}){const[r,o]=c.useState(s),[i,h]=c.useState(Ht),d=c.useContext(xs);c.useEffect(()=>{d&&o(!d.collapsed&&s)},[d,s]);const m=c.useContext(js).trim().toLowerCase(),a=Array.isArray(t),l=c.useMemo(()=>Array.isArray(t)?null:Object.keys(t),[t]),g=c.useMemo(()=>m?(l??Array.from({length:t.length},(w,b)=>b)).filter(w=>String(w).toLowerCase().includes(m)||JSON.stringify(Array.isArray(t)?t[Number(w)]:t[w]).toLowerCase().includes(m)):null,[t,l,m]),p=g?g.length:a?t.length:l.length,y=Math.min(i,p);return e.jsxs("details",{open:r,onToggle:w=>{w.target===w.currentTarget&&o(w.currentTarget.open)},children:[e.jsxs("summary",{children:[n!==void 0&&e.jsx(vs,{name:n}),e.jsxs("span",{children:[a?"[":"{",p===0?a?"]":"}":"…"]}),p>0&&e.jsxs("span",{className:"tr-count",children:[p," ",a?p===1?"item":"items":p===1?"key":"keys"]})]}),r&&p>0&&e.jsxs("div",{children:[Array.from({length:y},(w,b)=>{const v=g?g[b]:l?l[b]:b,D=Array.isArray(t)?t[Number(v)]:t[v];return e.jsx(bs,{name:v,value:D},v)}),y<p&&e.jsxs("button",{type:"button",className:"btn",onClick:()=>h(w=>w+Ht),children:["Show ",Math.min(Ht,p-y)," more (",p-y," remaining)"]}),e.jsx("div",{children:a?"]":"}"})]})]})}function Gr({value:t}){const n=c.useMemo(()=>{const s=JSON.stringify(t,null,2);if(s.length>zr)return s;const r=[],o=/"(?:\\.|[^"\\])*"(\s*:)?|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|\b(?:true|false|null)\b/g;let i=0;for(const h of s.matchAll(o)){const d=h.index;d>i&&r.push(s.slice(i,d));const m=h[0],a=h[1]||"",l=a?"key":m[0]==='"'?"string":m==="null"?"null":m==="true"||m==="false"?"boolean":"number";r.push(e.jsx("span",{className:`tr-json-${l}`,children:a?m.slice(0,-a.length):m},d)),a&&r.push(a),i=d+m.length}return i<s.length&&r.push(s.slice(i)),r},[t]);return e.jsx("pre",{className:"tr-value",children:n})}function Cs({value:t,initialMode:n="tree"}){const[s,r]=c.useState(n),[o,i]=c.useState(""),[h,d]=c.useState(!1),m=c.useRef(null),a=c.useRef(null),[l,g]=c.useState(null);return c.useEffect(()=>{const p=a.current;if(!p)return;const y=()=>p.querySelectorAll(".jer-editor-container button[tabindex='-1']").forEach(b=>{b.tabIndex=0});y();const w=new MutationObserver(y);return w.observe(p,{childList:!0,subtree:!0}),()=>w.disconnect()},[s,t]),e.jsxs("div",{children:[e.jsxs("div",{className:"tr-detail-tabs",role:"group","aria-label":"JSON view",children:[e.jsx("button",{type:"button",className:"btn","aria-pressed":s==="tree",onClick:()=>r("tree"),children:"Tree"}),e.jsx("button",{type:"button",className:"btn","aria-pressed":s==="raw",onClick:()=>r("raw"),children:"Raw JSON"})]}),s==="raw"?e.jsx(Gr,{value:t}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"tr-json-tools",children:[e.jsxs("label",{className:"tr-json-search",children:["Search JSON",e.jsx("input",{type:"search",className:"tr-input",value:o,placeholder:"Find a key or value…",onChange:p=>i(p.target.value)})]}),e.jsx("button",{type:"button",className:"btn",onClick:()=>{var p;g(y=>({revision:((y==null?void 0:y.revision)??0)+1,collapsed:!0})),(p=m.current)==null||p.collapse({path:[],collapsed:!0,includeChildren:!0})},children:"Collapse all"}),e.jsx("button",{type:"button",className:"btn",onClick:()=>{var p;g(y=>({revision:((y==null?void 0:y.revision)??0)+1,collapsed:!1})),(p=m.current)==null||p.collapse([{path:[],collapsed:!0,includeChildren:!0},{path:[],collapsed:!1,includeChildren:!1}])},children:"Open root"})]}),e.jsx("p",{className:"tr-note",children:"Copy a value with its copy button; hold ⌘ / Ctrl to copy its path."}),h&&e.jsx("p",{role:"alert",className:"tr-capture-error",children:"Clipboard unavailable. Select the value and copy it manually."}),e.jsx(js.Provider,{value:o,children:e.jsx(xs.Provider,{value:l,children:e.jsx("div",{ref:a,className:"tr-value tr-json-tree",children:t===null||typeof t!="object"?e.jsx(bs,{value:t}):e.jsx(Hr,{data:t,editorRef:m,theme:Ur,rootName:"",collapse:o?!1:Yr,collapseAnimationTime:0,searchText:o||void 0,searchFilter:o?"all":void 0,searchDebounceTime:200,customNodeDefinitions:qr,minWidth:0,maxWidth:"100%",baseFontSize:"inherit",indent:2,stringTruncateLength:300,showIconTooltips:!0,onCopy:({success:p})=>d(!p)},o?"search":"browse")})})})]})]})}function Xr(t,n=!1){var g,p,y,w,b;const s=!!t&&(t.featureEnabled??t.enabled??["awaiting","receiving","capturing"].includes(t.state)),r=((g=t==null?void 0:t.sources)==null?void 0:g.filter(v=>v.active).length)??0,o=/permission/i.test((t==null?void 0:t.setupError)??"")||!!((p=t==null?void 0:t.sources)!=null&&p.some(v=>/permission/i.test(v.error??""))),i=/^Install /.test((t==null?void 0:t.setupError)??""),h=(t==null?void 0:t.events.length)??0,d=((y=t==null?void 0:t.observations)==null?void 0:y.length)??0,m=!!(t!=null&&t.bytes)||d>0||h>0;let a="Monitoring stopped",l="neutral";return n?(a="Monitor connection lost",l="error"):t?s&&o?(a="Capture permission needed",l="attention"):s&&i?(a="Capture setup needed",l="attention"):t.automatic&&s&&!((w=t.sources)!=null&&w.length)&&t.state!=="error"?a="Waiting for a collector…":t.state==="error"?(a="Capture error",l="error"):s&&r>0&&r<(((b=t.sources)==null?void 0:b.length)??0)?(a="Listening to some destinations",l="attention"):s&&o?(a="Capture permission needed",l="attention"):s&&t.state==="interrupted"?(a="Reconnecting capture…",l="attention"):s&&(r||!t.managed&&["receiving","capturing"].includes(t.state))?(a="Listening for telemetry",l="ok"):s&&(a=t.managed?"Starting monitoring…":"Activation needed"):a="Reading monitor…",{enabled:s,active:r,permission:o,install:i,decoded:h,observed:d,traffic:m,title:a,tone:l}}const He=t=>t&&typeof t=="object"&&!Array.isArray(t)?t:{},Ct=t=>Array.isArray(t)?t:[],Jt=t=>new Date(t).toLocaleTimeString(),Pn="agent-dag.radar-feed-width",Zr=t=>({unconfirmed:"Transfer observed · receipt unconfirmed",accepted:"Collector accepted",partial:"Collector reported partial success",rejected:"Collector rejected",unknown:"Response incomplete",reset:"Stream reset"})[t.outcome],an={encrypted:"Encrypted traffic observed; contents cannot be read.",joined_midstream:"Capture joined an existing connection. Waiting for a new HTTP/2 connection to decode it reliably.",capture_gap:"Incomplete packets or a gap were observed. Affected contents are not shown as decoded.",decode_failed:"Some payloads could not be decoded. They are not shown as verified events.",payload_limit:"A payload exceeded the inspection limit and was omitted.",stream_limit:"A stream exceeded the inspection limit.",connection_limit:"The connection inspection limit was reached.",unsupported_compression:"A compression format other than gzip was observed.",unsupported_link:"This network capture format is not supported.",unsupported_network:"Some packets used a network protocol this decoder does not support.",fragmented:"Fragmented IP packets cannot be decoded in this version.",unknown_export:"A request could not be identified as an OTLP export.",connection_closed:"An HTTP/2 connection closed.",idle_connection:"An idle connection was removed from the decoder."};function Qr(t){return/prompt/i.test(t)?"Prompt-related field included in this export.":/response|completion/i.test(t)?"Response-related field included in this export.":/tool/i.test(t)?"Tool-related field included in this export.":/session/i.test(t)?"Session identifier or session metadata.":/user|email|account/i.test(t)?"User or account metadata.":/token|cost|duration|latency/i.test(t)?"Usage or timing measurement.":"Attribute included in this export."}function vt({value:t}){return e.jsx("pre",{className:"tr-value",children:typeof t=="string"?t:JSON.stringify(t,null,2)})}function eo({value:t}){return e.jsx("dl",{className:"tr-attributes",children:Ct(t).map((n,s)=>{const r=He(n);return e.jsxs("div",{children:[e.jsxs("dt",{children:[e.jsx("code",{children:String(r.key??"Unnamed attribute")}),e.jsx("span",{children:Qr(String(r.key))})]}),e.jsx("dd",{children:e.jsx(vt,{value:Mt(r.value)})})]},s)})})}const to=[["Error",["error.message","exception.message","error","error_type"]],["Prompt",Qt],["Response",mn],["Project",$n],["Working directory",Bn],["Repository",["repository.url","repo_url","vcs.repository.url.full"]],["Branch",["git.branch","branch","vcs.ref.head.name"]],["Tool",["tool_name","tool.name","gen_ai.tool.name"]],["Tool input",["tool_parameters","tool_input","tool.input"]],["Tool result",["tool_result","tool_response","tool.output"]],["Model",["model","gen_ai.request.model","gen_ai.response.model"]],["Input tokens",["input_tokens","gen_ai.usage.input_tokens"]],["Output tokens",["output_tokens","gen_ai.usage.output_tokens"]],["Cache read tokens",["cache_read_tokens"]],["Cache creation tokens",["cache_creation_tokens"]],["Cost (USD)",["cost_usd"]],["Duration (ms)",["duration_ms","interaction.duration_ms"]],["Time to first token (ms)",["ttft_ms"]],["Success",["success"]],["Stop reason",["stop_reason","gen_ai.response.finish_reasons"]],["Token type",["type"]]];function Ns({value:t}){const n=Et(t);return e.jsx("dl",{className:"tr-highlights",children:to.flatMap(([s,r])=>{const o=it(n,r).key;if(!o)return[];const i=n[o];if(i===null||i==="")return[];if((s==="Prompt"||s==="Response")&&dn(i))return[e.jsxs("div",{"data-field":s,children:[e.jsx("dt",{children:s}),e.jsxs("dd",{children:[e.jsx("span",{className:"tr-evidence-status",children:"Redacted in export"}),e.jsx("p",{className:"tr-note",children:"The export contains a redaction marker, not the original text."})]})]},s)];const h=typeof i=="string"?i:JSON.stringify(i,null,2);return[e.jsxs("div",{"data-field":s,children:[e.jsx("dt",{children:s}),e.jsx("dd",{children:h.length>800?e.jsxs(e.Fragment,{children:[e.jsx(vt,{value:h.slice(0,800)+"…"}),e.jsxs("details",{className:"tr-details",children:[e.jsxs("summary",{children:["Show full ",s.toLowerCase()]}),e.jsx(vt,{value:i})]})]}):e.jsx(vt,{value:i})})]},s)]})})}function vn({label:t,value:n}){const[s,r]=c.useState(!1);return e.jsxs("details",{className:"tr-details",onToggle:o=>{o.target===o.currentTarget&&r(o.currentTarget.open)},children:[e.jsx("summary",{children:t}),s&&e.jsx(Cs,{value:n})]})}function no({record:t}){const n=["gauge","sum","histogram","exponentialHistogram","summary"].find(s=>t[s]);return n?e.jsxs("div",{children:[t.description&&e.jsx("p",{className:"tr-note",children:String(t.description)}),Ct(He(t[n]).dataPoints).map((s,r)=>{const o=He(s);return e.jsxs("section",{children:[e.jsxs("dl",{className:"tr-facts",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Measurement"}),e.jsx("dd",{children:n})]}),o.asInt!==void 0||o.asDouble!==void 0?e.jsxs("div",{children:[e.jsx("dt",{children:"Value"}),e.jsx("dd",{children:e.jsxs("code",{children:[String(o.asInt??o.asDouble)," ",String(t.unit??"")]})})]}):null,o.count!==void 0&&e.jsxs("div",{children:[e.jsx("dt",{children:"Count"}),e.jsx("dd",{children:e.jsx("code",{children:String(o.count)})})]}),o.sum!==void 0&&e.jsxs("div",{children:[e.jsx("dt",{children:"Sum"}),e.jsx("dd",{children:e.jsxs("code",{children:[String(o.sum)," ",String(t.unit??"")]})})]})]}),e.jsx(Ns,{value:o.attributes}),e.jsx(vn,{label:"All measurement fields",value:o})]},r)})]}):null}function so({record:t}){let n=null;try{n=`${Number(BigInt(String(t.endTimeUnixNano))-BigInt(String(t.startTimeUnixNano)))/1e6} ms`}catch{n=null}return e.jsxs("dl",{className:"tr-facts",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Duration"}),e.jsx("dd",{children:n??"Not included"})]}),t.kind&&e.jsxs("div",{children:[e.jsx("dt",{children:"Span kind"}),e.jsx("dd",{children:String(t.kind)})]}),t.status&&e.jsxs("div",{children:[e.jsx("dt",{children:"Span status"}),e.jsx("dd",{children:e.jsx(vt,{value:t.status})})]})]})}const ro=[["Prompt",Qt],["Response",mn]];function oo({fields:t}){return e.jsx("dl",{className:"tr-content-evidence",children:ro.map(([n,s])=>{const r=t.map(h=>it(h,s)),o=r.some(h=>h.state==="included"),i=r.some(h=>h.state==="redacted");return e.jsxs("div",{children:[e.jsx("dt",{children:n}),e.jsx("dd",{"data-evidence":o?"included":i?"redacted":"absent",children:o?i?"Included · some records redacted":"Included in export":i?"Redacted in export":"Not included in this export"})]},String(n))})})}function ao({fields:t,sessions:n}){const r=t.map(i=>qs(i,n)).filter(i=>i.source!=="absent"),o=r.filter((i,h)=>r.findIndex(d=>d.source===i.source&&d.project.value===i.project.value&&d.directory.value===i.directory.value)===h);return e.jsxs("section",{className:"tr-project-context","aria-label":"Project context",children:[e.jsx("h4",{children:"Project / working directory"}),o.length?o.map((i,h)=>e.jsxs("div",{children:[i.project.value!==null&&(i.project.state==="redacted"?e.jsx("p",{className:"tr-note",children:"Project redacted in export"}):e.jsx(vt,{value:i.project.value})),i.directory.value!==null&&i.directory.value!==i.project.value&&(i.directory.state==="redacted"?e.jsx("p",{className:"tr-note",children:"Working directory redacted in export"}):e.jsx(vt,{value:i.directory.value})),e.jsx("p",{className:"tr-note",children:i.source==="export"?"Included in export":"Local ccdeck context · exact session match. Project path is not present in the export."})]},h)):e.jsx("p",{className:"tr-note",children:"Not included in this export. No matching local working directory is available."})]})}function Ln({record:t,signal:n}){const s=Et(t.attributes),r=t.eventName??t.name??s["event.name"]??(n==="logs"?"Log record":"Record"),o=Mt(t.body),i=typeof o=="string"&&(o===r||o===`claude_code.${r}`);return e.jsxs("article",{className:"tr-record",children:[e.jsx("h4",{children:String(r)}),t.body&&!i&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"tr-note",children:"Event body"}),e.jsx(vt,{value:o})]}),n==="metrics"&&e.jsx(no,{record:t}),n==="traces"&&e.jsx(so,{record:t}),t.attributes&&e.jsx(Ns,{value:t.attributes}),t.severityText&&e.jsxs("p",{className:"tr-note",children:["Severity: ",String(t.severityText)]}),e.jsx(vn,{label:"All record fields",value:t})]})}function io({scope:t,signal:n,item:s}){const r=Ct(t[s]).map(He),o=n==="logs"?r.map((l,g)=>({record:l,index:g,priority:Ys(l)})).sort((l,g)=>l.priority-g.priority||l.index-g.index):[],i=o.some(l=>l.priority<4),h=i?o.filter(l=>l.priority<4).map(({record:l})=>l):r,d=i?o.filter(l=>l.priority===4).map(({record:l})=>l):[],[m,a]=c.useState(!1);return e.jsxs("div",{children:[h.map((l,g)=>e.jsx(Ln,{record:l,signal:n},g)),!!d.length&&e.jsxs("details",{className:"tr-details",onToggle:l=>{l.target===l.currentTarget&&a(l.currentTarget.open)},children:[e.jsxs("summary",{children:["Other events (",d.length,")"]}),m&&d.map((l,g)=>e.jsx(Ln,{record:l,signal:n},g))]}),t.scope&&e.jsx(vn,{label:"Instrumentation details",value:t.scope})]})}function lo({payload:t,signal:n,sessions:s=[]}){const r=n==="traces"?"Spans":n==="logs"?"Logs":"Metrics",o=n==="traces"?"spans":n==="logs"?"logRecords":"metrics",i=Ct(t["resource"+r]).map(He),h=i.flatMap(d=>{const m=Et(He(d.resource).attributes),a=Ct(d["scope"+r]).flatMap(l=>Ct(He(l)[o]).map(He));return a.length?a.flatMap(l=>{const g={...m,...Et(l.attributes)},p=["gauge","sum","histogram","exponentialHistogram","summary"].find(w=>l[w]),y=p?Ct(He(l[p]).dataPoints):[];return y.length?y.map(w=>({...g,...Et(He(w).attributes)})):[g]}):[m]});return e.jsxs("div",{className:"tr-decoded",children:[e.jsx(ao,{fields:h,sessions:s}),e.jsx(oo,{fields:h}),e.jsxs("details",{className:"tr-details tr-export-scope",children:[e.jsx("summary",{children:"About captured content"}),e.jsx("p",{className:"tr-note",children:"These are telemetry fields sent to the collector. This view does not capture the full request sent to the AI model. Missing text is not reconstructed from local conversations."})]}),i.map((d,m)=>e.jsxs("section",{children:[Ct(d["scope"+r]).map((a,l)=>e.jsx(io,{scope:He(a),signal:n,item:o},l)),e.jsxs("details",{className:"tr-details",children:[e.jsx("summary",{children:"Resource metadata"}),e.jsx(eo,{value:He(d.resource).attributes})]})]},m))]})}function co({platform:t,install:n,asking:s,permission:r,onAllow:o,onCopy:i,copied:h}){const d=t==="win32",m=t==="darwin",a=r&&(r.outcome==="unavailable"||r.outcome==="failed");return e.jsxs("section",{className:"tr-activation","aria-labelledby":"tr-setup-title",children:[e.jsx("strong",{id:"tr-setup-title",children:"Allow packet capture once"}),e.jsxs("p",{className:"tr-note",children:["Radar reads Claude Code's telemetry from network traffic, which ",d?"on Windows needs Wireshark with Npcap.":`${m?"macOS":"Linux"} lets only an administrator read.`]}),d?e.jsxs("p",{className:"tr-note",children:[n?"Install Wireshark once and keep Npcap ticked in its installer.":"Npcap is limited to administrators. Run its installer again with that restriction unticked."," Radar starts by itself afterwards."]}):e.jsxs("p",{className:"tr-note",children:[m?"Allow capture asks for your password once and adds a small ccdeck helper that gives your user that access, now and after every restart.":`Allow capture asks for your password once${n?", installs tcpdump":""} and lets tcpdump capture for your user only.`," Radar then starts by itself, and what it reads stays on this ",m?"Mac":"computer","."]}),d?e.jsx("a",{className:"btn primary",href:"https://www.wireshark.org/download.html",target:"_blank",rel:"noreferrer",children:"Get Wireshark"}):e.jsx("button",{type:"button",className:"btn primary","aria-busy":s,onClick:()=>{s||o()},children:s?"Waiting for your password…":"Allow capture…"}),e.jsxs("div",{role:"status",children:[(r==null?void 0:r.outcome)==="cancelled"&&e.jsx("p",{className:"tr-note",children:"Nothing changed. Allow capture when you are ready."}),(r==null?void 0:r.outcome)==="granted"&&e.jsx("p",{className:"tr-note",children:"Capture allowed. Starting monitoring…"}),a&&e.jsxs("p",{className:"tr-note",children:[r.message,r.command&&" Run this once in a terminal instead:"]})]}),a&&r.command&&e.jsxs("div",{className:"tr-command-entry",children:[e.jsx("div",{children:e.jsx("button",{type:"button",className:"btn",onClick:()=>i(r.command),children:h?"Copied":"Copy command"})}),e.jsx("pre",{className:"tr-command",children:r.command})]})]})}function uo({capture:t,radar:n,failed:s,busy:r,pendingAction:o=null,error:i,permission:h=null,action:d,sessionFilter:m="all",sessions:a=[]}){var tt,De,$e,Ae,nt,pt,mt,st,ze,rt,ft,Ue,ot,gt,I,G;const l=Fn([...((tt=n==null?void 0:n.config)==null?void 0:tt.variables)??[],...(n==null?void 0:n.environment)??[]]),g=[...new Set(l.map($s).filter(u=>!!u))],[p,y]=c.useState(null),[w,b]=c.useState(null),[v,D]=c.useState("all"),[O,L]=c.useState("all"),C=c.useRef(null),[f,E]=c.useState(()=>{const u=Number(_s(Pn));return u>=28&&u<=65?u:34}),N=u=>{E(u),Ps(Pn,String(u))},[x,T]=c.useState(!1),[z,U]=c.useState(100),[j,V]=c.useState(null),[k,R]=c.useState(null),[A,q]=c.useState(null),[J,se]=c.useState(!1),fe=c.useRef(0),[oe,ce]=c.useState("summary"),[W,we]=c.useState(null),[ye,Ie]=c.useState(0),ae=c.useRef(null),H=(t==null?void 0:t.events)??[],re=!!(H.length||(De=t==null?void 0:t.observations)!=null&&De.length),le=new Map(H.map(u=>[u.id,u])),je=k?k.map(u=>le.get(u.id)).filter(u=>!!u):H,ge=je.filter(u=>{var _,Q;return(!x||u.content.includes("Prompt"))&&(O==="all"||u.signal===O)&&(v==="all"||v===u.destination)&&(m==="all"||(m==="unidentified"?!((_=u.sessionIds)!=null&&_.length):(Q=u.sessionIds)==null?void 0:Q.includes(m)))}),Pe=((t==null?void 0:t.observations)??[]).filter(u=>!x&&(j===null||j.includes(u.id))&&O==="all"&&(m==="all"||m==="unidentified")&&(v==="all"||v===u.destination)),M=Pe.find(u=>u.id===p),K=p!==null?void 0:w===null?ge[0]:ge.find(u=>u.id===w),Le=[...ge.map(u=>({kind:"export",event:u})),...Pe.map(u=>({kind:"observation",event:u}))].sort((u,_)=>_.event.at-u.event.at||_.event.id-u.event.id),Te=new Set(k==null?void 0:k.map(u=>u.id)),Ne=new Set(j),Me=k===null?0:H.filter(u=>!Te.has(u.id)).length+((t==null?void 0:t.observations)??[]).filter(u=>!Ne.has(u.id)).length,xe=K==null?void 0:K.id;c.useEffect(()=>{b(null),y(null),U(100)},[m,O,v,x]),c.useEffect(()=>{w!==null||p!==null||(ge.length?b(ge[0].id):Pe.length&&y(Pe[0].id))},[($e=ge[0])==null?void 0:$e.id,(Ae=Pe[0])==null?void 0:Ae.id,w,p]),c.useEffect(()=>{if(we(null),q(null),xe===void 0)return;const u=new AbortController;let _=!0;const Q=setTimeout(()=>u.abort(),5e3);return fetch(`/api/system/traffic-radar/capture/event?id=${xe}`,{signal:u.signal}).then(async ee=>{if(!ee.ok)throw new Error("This message has expired. Select a newer message.");const ie=await ee.json();_&&!u.signal.aborted&&we({id:xe,payload:ie.payload})}).catch(ee=>{_&&we({id:xe,error:u.signal.aborted?"Loading timed out. Try again.":ee instanceof Error?ee.message:"Could not read this message."})}).finally(()=>clearTimeout(Q)),()=>{_=!1,clearTimeout(Q),u.abort()}},[xe,p,ye]),c.useEffect(()=>{if(!A||A==="failed")return;const u=setTimeout(()=>q(null),2e3);return()=>clearTimeout(u)},[A]),c.useEffect(()=>{if(!J)return;const u=setTimeout(()=>se(!1),5e3);return()=>clearTimeout(u)},[J]);const et=(t==null?void 0:t.platform)??(n==null?void 0:n.platform),Ee=Xr(t,s),We=Ee.enabled,Se=!!(t!=null&&t.managed),ve=Se&&(Ee.permission||Ee.install),be=Ee.active,Fe=((nt=t==null?void 0:t.sources)==null?void 0:nt.length)??1,bt=Ee.title,dt=u=>{const _=Vn(o??(r?"capture":null),u);return{disabled:_.disabled,"aria-busy":_.busy}},ut=u=>{var _,Q,ee;y(null),b(u.id),typeof window<"u"&&((_=window.matchMedia)!=null&&_.call(window,"(max-width: 640px)").matches)&&((Q=ae.current)==null||Q.focus({preventScroll:!0}),(ee=ae.current)==null||ee.scrollIntoView({block:"start",behavior:"auto"}))},Oe=()=>{const u=Date.now(),_=Is({armedFor:J?"history":null,target:"history",armedAt:fe.current,now:u,gapMs:350});if(_==="arm"){fe.current=u,se(!0);return}_!=="ignore"&&(se(!1),b(null),y(null),R(null),V(null),d("clear"))},de=async(u,_)=>{try{await navigator.clipboard.writeText(u),q(_)}catch{q("failed")}},Re=(u=[])=>u.length?u.map(_=>{var Q;return`${((Q=a.find(ee=>ee.id===_))==null?void 0:Q.label)??"Session"} · ${_.slice(0,8)}`}).join(", "):"Unidentified session",wt=new Set([...((pt=t==null?void 0:t.sources)==null?void 0:pt.map(u=>u.destination))??[],...g]),ht=(n==null?void 0:n.status)==="observing"?n.connections.filter(u=>u.active&&wt.has(u.destination)):[];return e.jsxs("div",{className:"tr-telemetry",children:[e.jsx("div",{className:"tr-capture-bar",children:e.jsxs("div",{children:[e.jsxs("h3",{role:"status","aria-live":"polite",children:[e.jsx("span",{className:`tr-live-dot tr-dot-${Ee.tone}`}),bt]}),e.jsx("p",{className:"tr-note",children:s?"Showing the last successful read. Reconnecting automatically.":ve?(mt=t==null?void 0:t.sources)!=null&&mt.length?"Radar found the collector and listens as soon as capture is allowed.":"Radar listens as soon as capture is allowed.":We?!((st=t==null?void 0:t.sources)!=null&&st.length)&&!(t!=null&&t.destination)?"Looking for the collector in Claude Code's settings and connections.":be?`${be} of ${Fe} destination${Fe===1?"":"s"} listening · ${Ee.traffic?"Traffic observed":"No traffic observed yet"}`:"Monitoring is enabled; the listener is not ready yet.":"Claude may still be sending telemetry."}),We&&(((ze=t==null?void 0:t.sources)==null?void 0:ze.length)||(t==null?void 0:t.destination))&&e.jsxs("div",{className:"tr-active-destinations",role:"group","aria-label":"Monitored destinations",children:[e.jsxs("span",{children:["Destination",Fe>1?"s":""]}),(rt=t==null?void 0:t.sources)!=null&&rt.length?t.sources.map(u=>e.jsxs("span",{className:"tr-destination-entry",children:[e.jsx("code",{children:u.destination}),(Fe>1||!u.active)&&e.jsx("span",{className:u.active?"tr-source-ready":"tr-source-pending",children:u.active?"Listening":"Not listening"}),!u.active&&u.error&&!ve&&e.jsx("span",{className:"tr-source-error",children:u.error})]},u.destination)):(t==null?void 0:t.destination)&&e.jsx("code",{children:t.destination})]})]})}),(n==null?void 0:n.status)==="unsupported"&&e.jsx("p",{className:"tr-capture-error",role:"status",children:"Live capture is available on macOS, Linux and Windows. You can still inspect a local file."}),(t==null?void 0:t.setupError)&&!ve&&e.jsx("p",{className:"tr-capture-error",role:"status",children:t.setupError}),i&&e.jsx("p",{className:"tr-capture-error",role:"alert",children:i}),ve&&e.jsx(co,{platform:et,install:Ee.install,asking:o==="permission",permission:h,onAllow:()=>void d("permission"),onCopy:u=>void de(u,"setup"),copied:A==="setup"}),A==="failed"&&e.jsx("p",{className:"tr-capture-error",role:"alert",children:"Clipboard unavailable. Select the text and copy it manually."}),e.jsxs("div",{className:"tr-workspace","data-empty":!re,ref:C,style:{"--tr-feed-width":`${f}%`},children:[e.jsxs("section",{className:"tr-feed","aria-label":"Collector activity",children:[re&&e.jsxs("div",{className:"tr-feed-head",children:[e.jsxs("h3",{children:["Activity ",e.jsx("span",{className:"tr-count",children:Le.length})]}),e.jsxs("label",{className:"tr-prompt-filter",title:"Show only exports with prompt-related fields, including redacted prompts",children:[e.jsx("span",{children:"With prompt"}),e.jsx("button",{type:"button",className:"switch",role:"switch","aria-label":"With prompt","aria-checked":x,onClick:()=>T(u=>!u),children:e.jsx("span",{className:"switch-knob"})})]})]}),(re||k!==null||O!=="all"||v!=="all")&&e.jsxs("details",{className:"tr-details tr-feed-options",children:[e.jsxs("summary",{children:["Filters and history",O!=="all"||v!=="all"?" · Filtered":""]}),e.jsxs("div",{className:"tr-filter",children:[e.jsx("label",{children:e.jsxs(ln,{"aria-label":"Message type",value:O,onChange:u=>{b(null),L(u.target.value)},children:[e.jsx("option",{value:"all",children:"All types"}),e.jsx("option",{value:"logs",children:"Events"}),e.jsx("option",{value:"metrics",children:"Metrics"}),e.jsx("option",{value:"traces",children:"Traces"})]})}),e.jsx("label",{children:e.jsxs(ln,{"aria-label":"Message destination",value:v,onChange:u=>{b(null),D(u.target.value)},children:[e.jsx("option",{value:"all",children:"All destinations"}),[...new Set([...g,...((ft=t==null?void 0:t.sources)==null?void 0:ft.map(u=>u.destination))??[],...H.map(u=>u.destination),...((t==null?void 0:t.observations)??[]).map(u=>u.destination)])].map(u=>e.jsx("option",{value:u,children:u},u))]})})]}),e.jsxs("div",{className:"tr-history-toolbar",children:[e.jsxs("p",{className:"tr-history",title:"Matching activity retained over the last 24 hours",children:["24h · ",ge.length," decoded · ",Pe.length," observed"]}),e.jsxs("div",{className:"tr-capture-actions",children:[e.jsxs("button",{className:"btn","aria-pressed":k!==null,title:k?"Show new entries received while the list was paused":"Freeze the list while monitoring continues",disabled:!je.length&&!Pe.length&&k===null,onClick:()=>{R(k?null:[...je]),V(k?null:((t==null?void 0:t.observations)??[]).map(u=>u.id))},children:[e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:k?e.jsx("path",{d:"m9 5 11 7-11 7z"}):e.jsx("path",{d:"M8 5v14M16 5v14"})}),e.jsx("span",{className:"tr-action-label",children:k?"Resume list":"Pause list"})]}),e.jsxs("button",{className:J?"btn danger armed":"btn",...dt("clear"),disabled:dt("clear").disabled||!(t!=null&&t.events.length)&&!((Ue=t==null?void 0:t.observations)!=null&&Ue.length),title:J?"Remove decoded messages and observations. Monitoring continues.":"Clear retained messages and connection observations",onBlur:()=>se(!1),onClick:Oe,children:[e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M3 6h18M9 6V3h6v3M5 6l1 15h12l1-15M10 10v7M14 10v7"})}),e.jsx("span",{className:J?"":"tr-action-label",children:J?"Confirm clear history":"Clear history"})]})]})]})]}),k&&e.jsxs("p",{className:"tr-list-notice",role:"status",children:["List paused · Monitoring continues",Me>0?` · ${Me} new ${Me===1?"entry":"entries"}`:""]}),(ot=t==null?void 0:t.retention)!=null&&ot.evictedExports?e.jsxs("p",{className:"tr-note",children:[t.retention.evictedExports.toLocaleString()," older messages removed by history limits."]}):null,Le.length?e.jsx("ul",{className:"tr-connections",onKeyDown:u=>{var Je;if(!["ArrowDown","ArrowUp","Home","End"].includes(u.key))return;const _=Array.from(u.currentTarget.querySelectorAll(".tr-message")),Q=_.indexOf(document.activeElement);if(Q<0)return;u.preventDefault();const ee=u.key==="Home"?0:u.key==="End"?_.length-1:Math.max(0,Math.min(_.length-1,Q+(u.key==="ArrowDown"?1:-1))),ie=Le[ee];ie&&(b(ie.kind==="export"?ie.event.id:null),y(ie.kind==="observation"?ie.event.id:null)),(Je=_[ee])==null||Je.focus()},children:Le.slice(0,z).map(u=>u.kind==="export"?e.jsx("li",{children:e.jsxs("button",{className:"tr-message","aria-pressed":(K==null?void 0:K.id)===u.event.id,onClick:()=>ut(u.event),children:[e.jsx(Rt,{kind:u.event.signal,className:"tr-row-icon"}),e.jsxs("span",{className:"tr-event-top",children:[e.jsx("strong",{className:"tr-event-name",title:u.event.name,children:u.event.name}),e.jsx("time",{dateTime:new Date(u.event.at).toISOString(),children:Jt(u.event.at)})]}),u.event.content.includes("Prompt")&&e.jsx(Gs,{event:u.event}),e.jsx("span",{className:"tr-event-context",title:Re(u.event.sessionIds),children:Re(u.event.sessionIds)}),e.jsxs("span",{className:"tr-event-bottom",children:[e.jsx("span",{className:`tr-receipt ${u.event.outcome==="accepted"?"tr-tone-ok":u.event.outcome==="rejected"?"tr-tone-error":u.event.outcome==="partial"?"tr-tone-enabled":""}`,children:u.event.outcome==="accepted"?"Accepted":u.event.outcome==="unconfirmed"?"Receipt unconfirmed":u.event.outcome==="partial"?"Partially accepted":u.event.outcome==="rejected"?"Rejected":"Receipt unknown"}),e.jsxs("span",{children:[u.event.count," ",u.event.count===1?"record":"records"]})]})]})},`event-${u.event.id}`):e.jsx("li",{children:e.jsxs("button",{className:"tr-message","aria-pressed":p===u.event.id,onClick:()=>{var _,Q,ee;b(null),y(u.event.id),(_=window.matchMedia)!=null&&_.call(window,"(max-width: 640px)").matches&&((Q=ae.current)==null||Q.focus({preventScroll:!0}),(ee=ae.current)==null||ee.scrollIntoView({block:"start",behavior:"auto"}))},children:[e.jsx(Rt,{kind:"connection",className:"tr-row-icon"}),e.jsxs("span",{className:"tr-event-top",children:[e.jsx("strong",{className:"tr-event-name",children:"Connection observed"}),e.jsx("time",{dateTime:new Date(u.event.at).toISOString(),children:Jt(u.event.at)})]}),e.jsxs("span",{className:"tr-event-context",title:u.event.destination,children:[u.event.destination," · ",u.event.reason==="encrypted"?"Encrypted contents":"Contents not decoded"]})]})},`observation-${u.event.id}`))}):e.jsxs("div",{className:"tr-empty-capture",children:[!re&&e.jsx(Rt,{kind:"radar"}),e.jsx("h4",{children:H.length||(gt=t==null?void 0:t.observations)!=null&>.length?"No matching activity":ve?"Not listening yet":"Waiting for traffic"}),e.jsx("p",{className:"tr-note",children:H.length||(I=t==null?void 0:t.observations)!=null&&I.length?x?"No exports with prompt fields match your filters. Turn off With prompt to see all activity. Redacted prompts are included.":"Try another session, type or destination.":ve?"Messages appear here once packet capture is allowed.":"Radar monitors automatically when a collector is available. Keep using Claude while Radar listens."})]}),Le.length>z&&e.jsx("button",{className:"btn",onClick:()=>U(u=>u+100),children:"Show older messages"}),ht.length>0&&e.jsxs("details",{className:"tr-details",children:[e.jsxs("summary",{children:["Connections to these collectors (",ht.length,")"]}),e.jsx("ul",{className:"tr-live-connections",children:ht.map(u=>e.jsxs("li",{children:[e.jsx("code",{children:u.destination}),e.jsxs("span",{children:["Claude · ",u.connecting&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"tr-attempt",children:cn(u)})," · "]}),"PID ",u.pid," · ",u.workspace??"Workspace unknown"]})]},`${u.pid}:${u.destination}`))}),e.jsx("p",{className:"tr-note",children:"A connection alone does not prove a telemetry message was sent. These connections are not filtered by session."})]})]}),re&&e.jsx(Us,{workspace:C,width:f,onCommit:N}),e.jsx("section",{className:"tr-inspector",hidden:!re,"aria-label":"Activity inspector",ref:ae,tabIndex:-1,children:M?e.jsxs("div",{children:[e.jsx("div",{className:"tr-inspector-head",children:e.jsxs("h3",{children:[e.jsx(Rt,{kind:"connection"}),"Connection details"]})}),e.jsxs("dl",{className:"tr-facts",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Destination"}),e.jsxs("dd",{className:"tr-fact-copy",children:[e.jsx("code",{children:M.destination}),e.jsx("button",{className:"tr-inline-copy","aria-label":"Copy destination",onClick:()=>void de(M.destination,"destination"),title:A==="destination"?"Copied destination":"Copy destination",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:A==="destination"?e.jsx("path",{d:"m5 12 4 4L19 6"}):e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"8",y:"8",width:"12",height:"12",rx:"2"}),e.jsx("path",{d:"M16 8V4H4v12h4"})]})})})]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Observed"}),e.jsx("dd",{children:e.jsx("time",{dateTime:new Date(M.at).toISOString(),children:new Date(M.at).toLocaleString()})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Source"}),e.jsx("dd",{children:e.jsx("code",{children:M.source||"Not identified"})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Contents"}),e.jsx("dd",{children:M.reason==="encrypted"?"Encrypted":"Not decoded"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Session"}),e.jsx("dd",{children:"Not identified"})]})]}),e.jsxs("div",{className:"tr-inspection-limit",children:[e.jsx(Rt,{kind:"info"}),e.jsxs("div",{children:[e.jsx("h4",{children:M.reason==="encrypted"?"Encrypted connection":"Message contents unavailable"}),e.jsx("p",{children:M.reason==="joined_midstream"?"Radar joined an existing connection. Keep listening: new connections may allow decoding.":M.reason==="encrypted"?"Radar cannot decrypt HTTPS. Inspect the collector’s own records for the contents.":an[M.reason]??"This connection could not be decoded."}),e.jsxs("details",{className:"tr-details",children:[e.jsx("summary",{children:"Technical details"}),e.jsx("p",{className:"tr-note",children:an[M.reason]??"The decoder could not read this connection."}),e.jsxs("p",{className:"tr-note",children:["There is no decoded JSON or confirmed session ID for this observation. ",M.reason==="joined_midstream"&&"Already captured traffic cannot be reconstructed."]})]})]})]})]}):K?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"tr-inspector-head",children:[e.jsxs("h3",{children:[e.jsx(Rt,{kind:K.signal}),K.name]}),e.jsxs("p",{className:"tr-note",children:["Decoded ",K.signal==="logs"?"event":K.signal==="metrics"?"metrics":"trace"," · ",Re(K.sessionIds)," · ",Jt(K.at)]})]}),e.jsxs("div",{className:"tr-detail-tabs",role:"group","aria-label":"Message format",children:[e.jsx("button",{className:"btn","aria-pressed":oe==="summary",onClick:()=>ce("summary"),children:"Overview"}),e.jsx("button",{className:"btn","aria-pressed":oe==="json",onClick:()=>ce("json"),children:"JSON"}),e.jsx("button",{className:"btn tr-copy-json",disabled:!(W!=null&&W.payload)||W.id!==K.id,onClick:()=>void de(JSON.stringify(W==null?void 0:W.payload,null,2),"json"),children:A==="json"?"Copied":"Copy JSON"})]}),(W==null?void 0:W.id)===K.id?W.payload?oe==="json"?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"tr-note",children:"Decoded OTLP fields. Unknown protobuf fields and transport headers are excluded."}),e.jsx(Cs,{value:W.payload},K.id)]}):e.jsxs(e.Fragment,{children:[e.jsx(lo,{payload:W.payload,signal:K.signal,sessions:a},K.id),e.jsxs("details",{className:"tr-details",children:[e.jsx("summary",{children:"Transfer details"}),e.jsxs("dl",{className:"tr-facts",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Destination"}),e.jsxs("dd",{className:"tr-fact-copy",children:[e.jsx("code",{children:K.destination}),e.jsx("button",{className:"tr-inline-copy","aria-label":"Copy destination",onClick:()=>void de(K.destination,"destination"),title:A==="destination"?"Copied destination":"Copy destination",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:A==="destination"?e.jsx("path",{d:"m5 12 4 4L19 6"}):e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"8",y:"8",width:"12",height:"12",rx:"2"}),e.jsx("path",{d:"M16 8V4H4v12h4"})]})})})]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Time"}),e.jsx("dd",{children:Jt(K.at)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Receipt"}),e.jsx("dd",{children:Zr(K)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Size"}),e.jsxs("dd",{children:[K.bytes.toLocaleString()," bytes · ",K.count," ",K.count===1?"record":"records"]})]}),((G=K.response)==null?void 0:G.message)&&e.jsxs("div",{children:[e.jsx("dt",{children:"Response"}),e.jsx("dd",{children:e.jsx(vt,{value:K.response.message})})]})]})]})]}):e.jsxs("div",{role:"alert",children:[e.jsx("p",{children:W.error}),e.jsx("button",{className:"btn",onClick:()=>Ie(ye+1),children:"Retry"})]}):e.jsx("p",{className:"tr-note",role:"status",children:"Loading message contents…"})]}):e.jsxs("div",{className:"tr-inspector-empty",children:[e.jsx("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.25","aria-hidden":"true",children:e.jsx("path",{d:"M8 4H5a1 1 0 0 0-1 1v14a1 1 0 0 0 1 1h3M16 4h3a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1h-3M10 8l-3 4 3 4M14 8l3 4-3 4"})}),e.jsx("h3",{children:w!==null||p!==null?"Activity no longer available":"Inspect collector activity"}),e.jsx("p",{className:"tr-note",children:w!==null||p!==null?"The selected entry is no longer retained or does not match your filter. Select another entry.":Ee.traffic&&!Ee.decoded?"Traffic has been observed, but no messages have been decoded. Select a connection observation to see what is known.":"Select an entry to inspect its metadata and any decoded contents."})]})})]}),e.jsxs("footer",{className:"tr-monitor-footer",children:[(We||re||s)&&e.jsxs("span",{children:[s?"Connection interrupted":We?Se?"Continuous local monitoring":"Local capture":"Not monitoring"," · History in local memory"]}),e.jsxs("details",{children:[e.jsx("summary",{children:"Monitoring limits"}),e.jsxs("div",{children:[e.jsx("p",{children:"Plaintext IPv4 OTLP/gRPC only. HTTPS contents cannot be decoded. Traffic to the chosen addresses can come from any process, not only Claude."}),e.jsx("p",{children:"History covers the last 24 hours, up to 2,000 exports and a 32 MiB payload budget. When a limit is reached, the oldest messages are removed."}),e.jsx("p",{children:"History stays in local memory. Restarting ccdeck or clearing messages removes it. Closing this modal does not stop capture or clear history. No capture file is written."}),t!=null&&t.bytes?e.jsxs("p",{children:["Captured transport bytes: ",t.bytes.toLocaleString(),". This is not a decoded-message count."]}):null,Se&&e.jsx("p",{children:"Monitoring is always on: it starts with ccdeck and continues in the background, looking for Claude's collector about once a minute while Radar is closed. The in-memory history is cleared after a restart."}),Object.entries((t==null?void 0:t.issues)??{}).map(([u,_])=>e.jsxs("p",{children:[an[u]??"An inspection limitation was observed."," (",_,")"]},u))]})]})]})]})}function ho({sessionFilter:t="all",onSessions:n}){const[s,r]=c.useState([]),[o,i]=c.useState(""),[h,d]=c.useState(""),[m,a]=c.useState(!1),[l,g]=c.useState(null),[p,y]=c.useState(""),[w,b]=c.useState(!1),v=c.useRef(0),D=async f=>{if(!f)return;const E=++v.current;d(""),a(!0),b(!1);try{if(f.size>10*1024*1024)throw new Error("Choose a file smaller than 10 MB.");const N=await f.text(),x=Ws(N);if(E!==v.current)return;n==null||n([...new Set(x.flatMap(T=>T.sessionIds))]),r(x),i(f.name),g(null),y(""),x.length||d("This file is empty. Choose a JSON or JSONL telemetry file.")}catch(N){E===v.current&&d(N instanceof Error?N.message:"Could not read this file.")}finally{E===v.current&&a(!1)}},O=s.filter(f=>(t==="all"||(t==="unidentified"?!f.sessionIds.length:f.sessionIds.includes(t)))&&(!p||f.raw.toLowerCase().includes(p.toLowerCase()))),L=O.slice(0,200),C=l===null?L[0]:O.find(f=>f.line===l);return e.jsxs("div",{className:"tr-file",children:[e.jsxs("div",{className:"tr-file-toolbar",children:[e.jsxs("div",{children:[e.jsx("h3",{children:"Inspect a telemetry file"}),e.jsx("p",{className:"tr-note",children:"Open a local JSON or JSONL file. It stays in your browser and is not uploaded."})]}),e.jsxs("label",{className:"btn tr-file-picker",children:[m?"Reading…":o?"Choose another file":"Open file",e.jsx("input",{type:"file",accept:".json,.jsonl,.ndjson,application/json","aria-label":"Open telemetry file",onChange:f=>{var E;D((E=f.target.files)==null?void 0:E[0]),f.target.value=""}})]})]}),h&&e.jsx("p",{className:"tr-capture-error",role:"alert",children:h}),e.jsxs("div",{className:"tr-workspace","data-empty":s.length===0,children:[e.jsxs("section",{className:"tr-feed","aria-label":"File records",children:[s.length>0&&e.jsxs("h3",{children:[o||"File records"," ",e.jsx("span",{className:"tr-count",children:O.length})]}),s.length>0&&e.jsx("input",{type:"search",className:"tr-input tr-search","aria-label":"Search file contents",placeholder:"Search contents…",value:p,onChange:f=>{y(f.target.value),g(null)}}),L.length?e.jsx("ul",{className:"tr-connections",children:L.map(f=>e.jsx("li",{children:e.jsxs("button",{className:"tr-message","aria-pressed":(C==null?void 0:C.line)===f.line,onClick:()=>{g(f.line),b(!1)},children:[e.jsxs("span",{className:"tr-event-top",children:[e.jsxs("span",{children:["Line ",f.line]}),e.jsx("span",{className:f.valid?"":"tr-tone-enabled",children:f.valid?"JSON":"Invalid JSON"})]}),e.jsx("strong",{children:f.label}),f.timestamp&&e.jsx("span",{children:f.timestamp}),e.jsx("span",{children:f.sessionIds.join(", ")||"Unidentified session"})]})},f.line))}):e.jsxs("div",{className:"tr-empty-capture",children:[e.jsx("h4",{children:s.length?"No matching records":"Open a telemetry file"}),e.jsx("p",{className:"tr-note",children:s.length?"Try another session or search.":"Choose Open file above to browse a JSON or JSONL file. Its records and original contents will appear here."})]}),O.length>L.length&&e.jsx("p",{className:"tr-note",children:"Showing the first 200 matching rows. Search to narrow the list."})]}),e.jsx("section",{className:"tr-inspector",hidden:!s.length,"aria-label":"File record contents",children:C?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"tr-feed-head",children:[e.jsxs("h3",{children:["Line ",C.line]}),e.jsx("button",{className:"btn",onClick:()=>{navigator.clipboard.writeText(C.raw).then(()=>b(!0),()=>d("Clipboard unavailable. Select the JSON and copy it manually."))},children:w?"Copied":"Copy JSON"})]}),e.jsx("p",{className:"tr-note",children:"Original file contents. This does not prove the record was sent or received."}),e.jsx("pre",{className:"tr-value",children:C.raw})]}):e.jsxs("div",{className:"tr-inspector-empty",children:[e.jsx("h3",{children:"Inspect a record"}),e.jsx("p",{className:"tr-note",children:"Select a row to read its original contents."})]})})]})]})}function go({onClose:t,sessions:n=[]}){const s=Ls(t),r=Ms(t),{snapshot:o,failed:i,updateConfig:h}=Hs(),d=zs();return e.jsx("div",{className:"modal-backdrop",...r,role:"presentation",children:e.jsx("div",{className:"modal tr-modal",ref:s,role:"dialog","aria-modal":"true","aria-labelledby":"tr-title","aria-describedby":"tr-purpose",onClick:m=>m.stopPropagation(),children:e.jsx(po,{snapshot:o,failed:i,captureState:d,sessions:n,onConfigChange:h,onClose:t})})})}function po({snapshot:t,failed:n=!1,captureState:s,sessions:r=[],onConfigChange:o,onClose:i}){var C,f,E,N;const[h,d]=c.useState("monitor"),[m,a]=c.useState([]),[l,g]=c.useState("all"),p=["monitor","configuration","file"],y=x=>{var U;const T=Ks(x,p.indexOf(h),p.length);if(T.kind!=="select")return;x.preventDefault();const z=p[T.index];d(z),(U=document.getElementById(`tr-tab-${z}`))==null||U.focus()},w=[...((C=t==null?void 0:t.config)==null?void 0:C.variables)??[],...(t==null?void 0:t.environment)??[]],b=Fn(w),v=Bs(w),D=(f=t==null?void 0:t.config)==null?void 0:f.sources.some(x=>x.status==="unavailable"),O=n?[]:Fs(t),L=new Map(r.map(x=>[x.id,x.label]));for(const x of((E=s==null?void 0:s.capture)==null?void 0:E.events)??[])for(const T of x.sessionIds??[])L.has(T)||L.set(T,"Session");for(const x of m)L.has(x)||L.set(x,"Session");return e.jsxs("div",{className:"tr-body",children:[e.jsxs("header",{className:"modal-head tr-header",children:[e.jsxs("div",{className:"tr-identity",children:[e.jsxs("div",{className:"modal-title",children:[e.jsx("span",{className:"modal-tool-name",id:"tr-title",children:"Telemetry Radar"}),e.jsx("span",{className:"tr-beta",title:"Beta feature — still being tested and improved.",children:"Beta"})]}),e.jsx("p",{id:"tr-purpose",children:"Inspect Claude Code’s collector traffic."})]}),e.jsxs("div",{className:"tr-navigation",children:[e.jsxs("div",{className:"tr-tabs",role:"tablist","aria-label":"Radar views",onKeyDown:y,children:[e.jsx("button",{id:"tr-tab-monitor",className:"tr-tab",role:"tab","aria-selected":h==="monitor","aria-controls":"tr-panel-monitor",tabIndex:h==="monitor"?0:-1,onClick:()=>d("monitor"),children:"Monitor"}),e.jsx("button",{id:"tr-tab-configuration",className:"tr-tab",role:"tab","aria-selected":h==="configuration","aria-controls":"tr-panel-configuration",tabIndex:h==="configuration"?0:-1,onClick:()=>d("configuration"),children:"Configuration"}),e.jsx("button",{id:"tr-tab-file",className:"tr-tab",role:"tab","aria-selected":h==="file","aria-controls":"tr-panel-file",tabIndex:h==="file"?0:-1,onClick:()=>d("file"),children:"File"})]}),e.jsxs("label",{className:"tr-session-filter",hidden:!L.size&&l==="all"&&!((N=s==null?void 0:s.capture)!=null&&N.events.length),children:["Session",e.jsxs(ln,{value:l,onChange:x=>g(x.target.value),"aria-label":"Session",children:[e.jsx("option",{value:"all",children:"All sessions"}),[...L].map(([x,T])=>e.jsxs("option",{value:x,children:[T," · ",x.slice(0,8)]},x)),e.jsx("option",{value:"unidentified",children:"Unidentified session"})]})]}),e.jsxs("details",{className:"tr-help",children:[e.jsxs("summary",{children:[e.jsx(Rt,{kind:"info"}),e.jsx("span",{className:"tr-help-label",children:"About Radar"})]}),e.jsxs("div",{children:[e.jsx("h3",{children:"What does Radar show?"}),e.jsx("p",{children:"See what Claude Code sends to your telemetry collectors. Destinations can be configured by you or your organization."}),e.jsx("p",{children:"Radar inspects configured OpenTelemetry exports, including prompts or responses when enabled and captured. It does not show everything Claude knows about you, ordinary AI requests, or Anthropic’s separate service telemetry."}),e.jsx("p",{children:"An address does not identify who owns a collector or who can access its data. Encrypted connections can be observed, but their contents cannot be decoded here."}),e.jsx("a",{href:"https://code.claude.com/docs/en/monitoring-usage",target:"_blank",rel:"noreferrer",children:"Claude Code telemetry documentation"})]})]})]}),i&&e.jsx("button",{className:"glyph-btn tr-header-close",onClick:i,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),e.jsx("div",{className:"tr-page",id:"tr-panel-monitor",role:"tabpanel","aria-labelledby":"tr-tab-monitor",hidden:h!=="monitor",children:s?e.jsx(uo,{...s,radar:n&&t?{...t,status:"unavailable"}:t,sessionFilter:l,sessions:r}):e.jsx("p",{className:"tr-empty",children:"Reading monitor status…"})}),e.jsxs("div",{className:"tr-page tr-configuration-page",id:"tr-panel-configuration",role:"tabpanel","aria-labelledby":"tr-tab-configuration",hidden:h!=="configuration",children:[e.jsxs("div",{className:"tr-summary",children:[e.jsxs("div",{className:"tr-summary-state",children:[e.jsx("span",{className:`tr-state ${n||!t||D?"tr-tone-unknown":v.startsWith("Enabled")?"tr-tone-enabled":"tr-tone-unknown"}`,children:n?"Configuration unavailable":t?D?"Configuration incomplete":v==="Unknown"?"Configuration unknown":v:"Reading settings…"}),e.jsx("span",{className:"tr-note",children:b.length?`${b.length} configured destination${b.length===1?"":"s"}`:"No destination found in the settings files read. Telemetry may still be running."})]}),b.length>0&&e.jsx("div",{className:"tr-endpoints",children:b.map(x=>e.jsx("code",{children:x},x))}),!b.length&&O.length>0&&e.jsxs("div",{className:"tr-observed-summary",children:[e.jsx("span",{className:"tr-state",children:"Claude connections observed"}),e.jsx("div",{className:"tr-endpoints",children:O.map(x=>e.jsx("code",{children:x},x))}),e.jsx("p",{className:"tr-note",children:"These are active connections, not confirmed telemetry messages. Radar watches them while no settings file names a destination, and Monitor shows what they send."})]})]}),t?e.jsx(mo,{snapshot:t,stale:n,onConfigChange:o,sessionLabel:l==="all"?void 0:L.get(l)??l}):e.jsx("p",{className:"tr-empty",children:n?"Could not read settings. Sampling will retry.":"Reading local settings…"})]}),e.jsx("div",{className:"tr-page",id:"tr-panel-file",role:"tabpanel","aria-labelledby":"tr-tab-file",hidden:h!=="file",children:e.jsx(ho,{onSessions:a,sessionFilter:l})})]})}const Mn="Set in the environment this Claude process started with. Change it where the session is launched.";function mo({snapshot:t,sessionLabel:n,stale:s=!1,onConfigChange:r}){var N,x,T,z,U;const[o,i]=c.useState(null),[h,d]=c.useState(null),m=c.useRef(null),[a,l]=c.useState(""),[g,p]=c.useState(""),y=(N=o??t.config)==null?void 0:N.sources.some(j=>j.status==="unavailable");c.useEffect(()=>{i(null)},[t.config]);const w=[...((x=o??t.config)==null?void 0:x.variables)??[],...t.environment??[]],b=t.uninspected??0,v=async(j,V)=>{if(!Kn(m.current)||s)return;m.current=j,d(j),p(""),l("");const k=new AbortController,R=setTimeout(()=>k.abort(),2e4);try{const A=await fetch("/api/system/traffic-radar/configuration",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:j,enabled:V}),signal:k.signal}),q=await A.json();if(!A.ok||!q.ok)throw new Error(q.error??"Could not save this setting.");i(q.config),r==null||r(q.config),l("Saved to user settings. Start a new Claude session to apply the change.")}catch(A){p(k.signal.aborted?"Saving timed out. Check the current setting and try again.":A instanceof Error?A.message:"Could not save this setting. Try again.")}finally{clearTimeout(R),m.current=null,d(null)}},D=w.filter(j=>j.key.endsWith("ENDPOINT")),O={CLAUDE_CODE_ENABLE_TELEMETRY:"Telemetry",OTEL_LOG_USER_PROMPTS:"Your prompts",OTEL_LOG_ASSISTANT_RESPONSES:"Claude responses",OTEL_LOG_TOOL_DETAILS:"Tool details",OTEL_LOG_TOOL_CONTENT:"Tool contents",OTEL_LOG_RAW_API_BODIES:"Full API bodies",OTEL_LOG_MANAGED_SETTINGS:"Managed settings",CLAUDE_CODE_ENHANCED_TELEMETRY_BETA:"Enhanced telemetry",ENABLE_ENHANCED_TELEMETRY_BETA:"Enhanced telemetry"},L=Object.keys(O),C=j=>L.includes(j)?L.indexOf(j):L.length,f=(((T=o??t.config)==null?void 0:T.unsetFlags)??[]).map(j=>({key:j,value:"Not set",source:"User settings",unset:!0,editable:!0})),E=[...w.filter(j=>j.key.startsWith("OTEL_LOG_")||j.key.includes("ENABLE")||j.key.includes("TELEMETRY_BETA")),...f].sort((j,V)=>C(j.key)-C(V.key));return e.jsxs("section",{className:"tr-config","aria-label":"Telemetry configuration",children:[e.jsx("h3",{children:"What Claude is configured to send"}),s&&e.jsx("p",{className:"tr-warning",role:"status",children:"Last successfully read settings. Current configuration could not be verified."}),y&&e.jsx("p",{className:"tr-warning",role:"status",children:"Some settings sources could not be read. Editing is unavailable until they can be verified."}),e.jsx("p",{className:"tr-note",children:(z=t.environment)!=null&&z.length?"Read from local Claude settings and the launch environment of running Claude processes. A running session’s effective values can still differ.":"Read from local Claude settings. The effective environment of a running session is not verified."}),b>0&&e.jsx("p",{className:"tr-note",children:`${b} Claude ${b===1?"process":"processes"} could not be inspected, such as one run by another user. ${b===1?"Its":"Their"} connections and launch environment are not shown.`}),n&&e.jsxs("p",{className:"tr-note",children:["Selected session: ",n,". These shared settings are evidence; this session’s runtime values are unverified."]}),e.jsx("h4",{children:"Destinations"}),D.length?e.jsx("ul",{className:"tr-destinations",children:D.map(j=>e.jsxs("li",{children:[e.jsx("code",{children:j.value}),e.jsxs("span",{children:[j.source," · ",j.key]})]},`${j.source}:${j.key}`))}):e.jsx("p",{className:"tr-note",children:"No destination found in the sources read. This does not mean telemetry is off."}),e.jsx("h4",{children:"Telemetry and content"}),e.jsx("p",{className:"tr-note",children:"Controls save shared user settings for new Claude sessions. Organization and managed flags require an administrator."}),a&&e.jsx("p",{className:"tr-note",role:"status",children:a}),g&&e.jsx("p",{className:"tr-warning",role:"alert",children:g}),E.length?e.jsx("dl",{className:"tr-variables tr-flags",children:E.map(j=>{const V=j.value.startsWith("Enabled"),k=V||j.value==="Disabled"||j.unset,R=Vn(h,j.key),A=j.unset?"Not in any settings file":j.source,q=`${O[j.key]??j.key} (${j.unset?"not set":j.source})`,J=j.launch===!0,se=!J&&(s||y||j.editable!==!0&&!j.blockedReason),fe=!J&&j.editable!==!0&&!se,oe=(ce,W=j.blockedReason)=>e.jsx("button",{type:"button",className:"switch",role:"switch","data-tone":"warn","aria-checked":V,"aria-label":q,...ce?{disabled:!0,title:W}:{"aria-busy":R.busy,disabled:R.disabled,title:`Turn ${V?"off":"on"} for new Claude sessions`,onClick:()=>void v(j.key,!V)},children:e.jsx("span",{className:"switch-knob"})});return e.jsxs("div",{children:[e.jsxs("dt",{children:[e.jsx("strong",{children:O[j.key]??j.key}),e.jsx("code",{children:j.key}),e.jsx("span",{children:A}),j.blockedReason&&!y&&e.jsx("span",{children:j.blockedReason})]}),e.jsxs("dd",{className:"tr-flag-control",children:[e.jsxs("span",{className:"tr-flag-value",children:[e.jsx("span",{className:`tr-state ${V?"tr-tone-enabled":"tr-tone-unknown"}`,children:j.value}),j.rawValue!==void 0&&e.jsx("code",{className:"tr-raw-flag",children:j.rawValue})]}),e.jsxs("span",{className:"tr-flag-action",children:[J?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"tr-control-note",title:Mn,children:"Read-only"}),k&&oe(!0,Mn)]}):se?e.jsx("span",{className:"tr-control-note",title:j.blockedReason,children:"Unavailable"}):fe?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"tr-control-note",title:j.blockedReason,children:"Managed"}),k&&oe(!0)]}):k?oe(!1):e.jsx("span",{className:"tr-unknown-actions",children:[!0,!1].map(ce=>e.jsx("button",{type:"button",className:"btn","aria-label":`${ce?"Enable":"Disable"} ${q}`,"aria-busy":R.busy,disabled:R.disabled,onClick:()=>void v(j.key,ce),children:ce?"Enable":"Disable"},String(ce)))}),h===j.key&&e.jsx("span",{className:"tr-control-note",role:"status",children:"Saving…"})]})]})]},`${j.source}:${j.key}`)})}):e.jsx("p",{className:"tr-note",children:"No telemetry flags found in the settings read."}),!D.length&&t.connections.length>0&&e.jsxs("details",{className:"tr-details",children:[e.jsxs("summary",{children:["Observed Claude connections (",t.connections.length,")"]}),e.jsx("ul",{className:"tr-live-connections",children:t.connections.map(j=>e.jsxs("li",{children:[e.jsx("code",{children:j.destination}),e.jsxs("span",{children:[j.connecting&&!s&&j.active!==null?e.jsx("span",{className:"tr-attempt",children:cn(j)}):cn(j,s)," · PID ",j.pid," · ",j.workspace??"Workspace unknown"]})]},`${j.pid}:${j.destination}`))}),e.jsx("p",{className:"tr-note",children:"A running process can keep previously loaded settings after a settings file disappears. Connections alone do not identify telemetry or prove a message was sent."})]}),e.jsxs("details",{className:"tr-details",children:[e.jsx("summary",{children:"All variables and sources"}),e.jsx("dl",{className:"tr-variables",children:w.map(j=>e.jsxs("div",{children:[e.jsxs("dt",{children:[e.jsx("code",{children:j.key}),e.jsx("span",{children:j.source})]}),e.jsx("dd",{children:j.value})]},`${j.source}:${j.key}`))}),e.jsx("ul",{className:"tr-sources",children:(U=t.config)==null?void 0:U.sources.map(j=>e.jsxs("li",{children:[e.jsx("span",{children:j.name}),e.jsx("span",{children:j.status==="read"?"Read":j.status==="absent"?"Not found":"Unavailable"})]},j.name))}),e.jsx("p",{className:"tr-note",children:"Endpoint credentials and headers are hidden. Settings can differ from an already running process."})]})]})}export{mo as Configuration,po as TrafficRadarView,go as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{J as z,K as V,b as c,s as re,L as le,M as L,j as e,N as b,O as _,P as x,Q as q,o as ie,v as ce,S as de,U as ue,R as he,e as G,V as me,W as ge}from"./app-4x4wTE-L.js";function pe(t){return!t.answer||t.answer.range!==t.want?{phase:"busy",stale:!1}:t.answer.ok?{phase:t.answer.days>0?"chart":"empty",stale:t.loading}:{phase:"error",stale:t.loading}}function J(t){const s=new Map;for(const n of t)for(const o of n.agents??[]){if(!o||typeof o.agent!="string"||o.agent==="")continue;const l=s.get(o.agent)??{id:o.agent,cost:0,tokens:0};l.cost+=Number.isFinite(o.totalCost)?o.totalCost:0,l.tokens+=Number.isFinite(o.totalTokens)?o.totalTokens:0,s.set(o.agent,l)}return[...s.values()].sort((n,o)=>o.cost-n.cost||n.id.localeCompare(o.id))}function xe(t){const s=J([{agents:t}]);return s.length<2?null:s.map(n=>`${z(n.id)} ${V(n.cost)}`).join(" · ")}function H(t){switch(t.toLowerCase()){case"claude":return"var(--model-opus)";case"codex":return"var(--model-codex)";case"gemini":return"var(--model-gemini)";case"copilot":return"var(--model-haiku)";default:return"var(--model-other)"}}function fe(t,s){if(!(s>0)||!(t>0))return"0%";const n=t/s*100;return n<.1?"<0.1%":`${n.toFixed(1)}%`}const h=t=>typeof t=="number"&&Number.isFinite(t)?t:0,$=t=>typeof t=="string"?t:"",W=t=>Array.isArray(t)?t.filter(s=>typeof s=="string"):[];function je(t){const s=t??{};return{modelName:$(s.modelName),cost:h(s.cost),...typeof s.missingPricing=="boolean"?{missingPricing:s.missingPricing}:{},...typeof s.storedCost=="number"&&Number.isFinite(s.storedCost)&&s.storedCost>=0?{storedCost:Math.min(s.storedCost,Math.max(0,h(s.cost)))}:{},inputTokens:h(s.inputTokens),outputTokens:h(s.outputTokens),cacheCreationTokens:h(s.cacheCreationTokens),cacheReadTokens:h(s.cacheReadTokens)}}function Ne(t){const s=t??{},n=Array.isArray(s.agents)?s.agents.map(o=>{const l=o??{};return{agent:$(l.agent),totalCost:h(l.totalCost),totalTokens:h(l.totalTokens)}}):void 0;return{period:$(s.period),totalCost:h(s.totalCost),totalTokens:h(s.totalTokens),inputTokens:h(s.inputTokens),outputTokens:h(s.outputTokens),cacheCreationTokens:h(s.cacheCreationTokens),cacheReadTokens:h(s.cacheReadTokens),modelsUsed:W(s.modelsUsed),modelBreakdowns:Array.isArray(s.modelBreakdowns)?s.modelBreakdowns.map(je):[],...n?{agents:n}:{},...s.metadata&&typeof s.metadata=="object"?{metadata:{agents:W(s.metadata.agents)}}:{}}}function ke(t){const s=t??{};return{...s,ok:s.ok===!0,days:Array.isArray(s.days)?s.days.map(Ne):void 0}}function R(t){const s=t.toLowerCase();return s.includes("opus")?"var(--model-opus)":s.includes("sonnet")?"var(--model-sonnet)":s.includes("haiku")?"var(--model-haiku)":s.includes("gpt-5")||s.includes("gpt5")?"var(--model-gpt5)":s.includes("gpt")?"var(--model-gpt)":s.includes("gemini")?"var(--model-gemini)":s.includes("codex")?"var(--model-codex)":s.includes("fable")||s.includes("mythos")?"var(--model-fable)":"var(--model-other)"}function ye(t){let s=0,n=0,o=0,l=0;const r=new Map,i=new Set;let p=null;for(const m of t){s+=m.totalCost,n+=m.totalTokens,o+=m.inputTokens+m.outputTokens,l+=m.cacheReadTokens;for(const d of m.modelBreakdowns)r.set(d.modelName,(r.get(d.modelName)??0)+d.cost),d.missingPricing&&i.add(d.modelName),d.storedCost!==void 0&&(p=(p??0)+d.storedCost)}return{totalCost:s,totalTok:n,inOut:o,cacheRead:l,modelCosts:r,missingModels:i,storedCost:p}}function be(t){return Array.from(t.entries()).sort((s,n)=>n[1]-s[1])}function K(t){return t.slice().sort((s,n)=>n.cost-s.cost)}function T(t,s){return s>0?t/s*100:0}function ve(t){var n,o;return xe(t.agents)??((o=(n=t.metadata)==null?void 0:n.agents)!=null&&o.length?t.metadata.agents.join(" · "):null)}function Ce(t){return t<=14?1:t<=31?2:7}function we(){let t=0;return{begin(){const s=++t;return()=>s===t},cancel(){t++}}}function Te(t){const[s,n]=c.useState(null),[o,l]=c.useState(!1),r=c.useState(we)[0],i=c.useRef(!1),p=(m=!1)=>{if(m&&!re(i.current))return;const d=r.begin();i.current=m;const j=t;l(!0);const u=`/api/ccusage?since=${le(j)}${m?"&refresh=1":""}`;fetch(u).then(N=>N.json()).then(N=>{d()&&n({range:j,resp:ke(N)})}).catch(()=>{d()&&n({range:j,resp:{ok:!1,reason:"unreachable"}})}).finally(()=>{d()&&(i.current=!1,l(!1))})};return c.useEffect(()=>(p(!1),()=>r.cancel()),[t]),{landed:s,loading:o,reload:()=>p(!0)}}function Re({selectedDay:t}){const s=ve(t),n=t.modelBreakdowns.some(r=>r.missingPricing),o=t.modelBreakdowns.filter(r=>r.storedCost!==void 0),l=L(o.length?o.reduce((r,i)=>r+i.storedCost,0):null,t.totalCost);return e.jsxs("div",{className:"uh-detail",children:[e.jsxs("div",{className:"uh-detail-head",children:[e.jsx("span",{className:"uh-detail-date",children:t.period}),e.jsx("span",{className:"uh-detail-cost",children:b(t.totalCost,n)}),s&&e.jsx("span",{className:"uh-detail-agents",title:s,children:s})]}),n&&e.jsx("p",{className:"uh-cost-note",children:_}),l&&e.jsx("p",{className:"uh-cost-note",children:l}),e.jsxs("div",{className:"uh-detail-mini",children:[e.jsx(C,{label:"input",val:x(t.inputTokens)}),e.jsx(C,{label:"output",val:x(t.outputTokens)}),e.jsx(C,{label:"cache write",val:x(t.cacheCreationTokens)}),e.jsx(C,{label:"cache read",val:x(t.cacheReadTokens)})]}),e.jsx("div",{className:"uh-detail-models",children:K(t.modelBreakdowns).map(r=>{const i=T(r.cost,t.totalCost);return e.jsxs("div",{className:"uh-model-row",title:r.modelName,children:[e.jsxs("span",{className:"uh-model-name",children:[e.jsx("span",{className:"uh-legend-dot",style:{background:R(r.modelName)}}),e.jsx("span",{className:"uh-model-label",children:q(r.modelName)})]}),e.jsx("span",{className:"uh-model-bar",children:e.jsx("span",{className:"uh-model-bar-fill",style:{width:`${i}%`,background:R(r.modelName)}})}),e.jsx("span",{className:"uh-model-cost",children:b(r.cost,r.missingPricing)})]},r.modelName)})})]})}function C({label:t,val:s}){return e.jsxs("div",{className:"uh-ministat",children:[e.jsx("span",{className:"uh-ministat-val",children:s}),e.jsx("span",{className:"uh-ministat-label",children:t})]})}const Me=[7,14,30,90];function Le({onClose:t,providers:s}){var U;const[n,o]=c.useState(30),[l,r]=c.useState(null),{landed:i,loading:p,reload:m}=Te(n),d=c.useRef(null),j=ie(t,{focusRef:d}),P=ce(t),u=pe({loading:p,want:n,answer:i&&{range:i.range,ok:i.resp.ok===!0,days:((U=i.resp.days)==null?void 0:U.length)??0}}),[N,Q]=c.useState(()=>typeof document<"u"&&document.hidden);c.useEffect(()=>{if(u.phase!=="busy")return;const a=()=>Q(document.hidden);return a(),document.addEventListener("visibilitychange",a),()=>document.removeEventListener("visibilitychange",a)},[u.phase]);const g=u.phase==="chart"?i.resp.days??[]:[],A=c.useRef(null),X=de(u.phase!=="error",A),Y=c.useMemo(()=>g.reduce((a,f)=>Math.max(a,f.totalCost),0),[g]),B=c.useRef(null);c.useLayoutEffect(()=>{const a=B.current;a&&(a.scrollLeft=a.scrollWidth)},[g]);const{totalCost:k,totalTok:Z,inOut:D,cacheRead:ee,modelCosts:E,missingModels:M,storedCost:F}=c.useMemo(()=>ye(g),[g]),se=c.useMemo(()=>be(E),[E]),v=c.useMemo(()=>J(g),[g]),te=v.length>1,O=l?g.find(a=>a.period===l)??null:null,ae=Ce(g.length);return e.jsx("div",{className:"modal-backdrop",...P,role:"presentation",children:e.jsxs("div",{ref:j,className:"modal uh-modal",onClick:a=>a.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Usage history",children:[e.jsxs("header",{className:"modal-head uh-head",children:[e.jsxs("div",{className:"uh-titlewrap",children:[e.jsx("div",{className:"modal-tool-name",children:"Usage history"}),e.jsx("div",{className:"uh-sub",children:u.stale?"running ccusage…":ue(s,v.map(a=>a.id))})]}),e.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:Me.map(a=>e.jsxs("button",{type:"button","aria-pressed":n===a,className:"uh-range-btn",onClick:()=>{o(a),r(null)},children:[a,"d"]},a))}),e.jsx("button",{ref:A,className:"glyph-btn uh-reload",onClick:m,...G(p),title:"Re-run ccusage","aria-label":"Reload",children:p?"…":e.jsx(he,{})}),e.jsx("button",{ref:d,className:"glyph-btn uh-close",onClick:t,"aria-label":"Close",children:"×"})]}),u.phase==="busy"?e.jsxs("div",{className:"uh-status uh-status-wait",role:"status","aria-label":"Reading usage history","aria-busy":"true","data-paused":N||void 0,children:[e.jsxs("span",{className:"uh-wait-word",children:[e.jsxs("svg",{className:"uh-reading-art",viewBox:"0 0 240 96",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M25 24v-7a4 4 0 0 1 4-4h28a4 4 0 0 1 4 4v43"}),e.jsx("rect",{x:"17",y:"24",width:"36",height:"51",rx:"4"}),e.jsx("path",{d:"M25 36h19M25 44h19M25 52h13M25 64h7"}),e.jsx("path",{className:"uh-reading-link",d:"M69 49h59"}),e.jsxs("g",{className:"uh-reading-packets",children:[e.jsx("rect",{x:"76",y:"46",width:"6",height:"6",rx:"1.5"}),e.jsx("rect",{x:"76",y:"46",width:"6",height:"6",rx:"1.5"}),e.jsx("rect",{x:"76",y:"46",width:"6",height:"6",rx:"1.5"})]}),e.jsx("rect",{x:"145",y:"18",width:"76",height:"57",rx:"5"}),e.jsx("path",{d:"M154 28h21M154 64h57M154 38v26M163 39h47M163 49h47"}),e.jsx("circle",{cx:"209",cy:"28",r:"2"})]}),e.jsx("strong",{className:"uh-reading-title",children:"Reading usage history"}),e.jsx("span",{className:"uh-reading-note",children:"Gathering costs and tokens from local logs…"}),!i&&e.jsx("span",{className:"uh-reading-hint",children:"The first run may download ccusage."})]}),e.jsx("span",{className:"uh-wait-axis","aria-hidden":!0})]}):u.phase==="error"?e.jsxs("div",{className:"uh-status uh-err",title:ge(i.resp)||void 0,children:[me(i.resp,"ccusage did not report usage"),e.jsx("div",{children:e.jsx("button",{className:"btn uh-retry",onClick:()=>{X(),m()},...G(p),children:p?"trying…":"Try again"})})]}):u.phase==="empty"?e.jsx("div",{className:`uh-status${u.stale?" uh-stale":""}`,"aria-busy":u.stale||void 0,children:"no usage in this range"}):e.jsxs("div",{className:u.stale?"uh-stale":void 0,"aria-busy":u.stale||void 0,children:[e.jsxs("div",{className:"uh-totals",children:[e.jsx(w,{label:"total cost",val:b(k,M.size>0),accent:!0}),e.jsx(w,{label:"tokens",val:x(Z)}),e.jsx(w,{label:"input+output",val:x(D)}),e.jsx(w,{label:"cache reads",val:x(ee)})]}),M.size>0&&e.jsx("p",{className:"uh-cost-note",children:_}),L(F,k)&&e.jsx("p",{className:"uh-cost-note",children:L(F,k)}),te&&e.jsxs("div",{className:"uh-agents",role:"group","aria-label":"Cost by CLI",children:[e.jsx("div",{className:"uh-agent-bar","aria-hidden":"true",children:v.map(a=>e.jsx("span",{className:"uh-agent-seg",style:{width:`${T(a.cost,k)}%`,background:H(a.id)}},a.id))}),e.jsx("div",{className:"uh-agent-keys",children:v.map(a=>e.jsxs("span",{className:"uh-agent-key",title:`${a.id} · ${x(a.tokens)} tokens`,children:[e.jsx("span",{className:"uh-legend-dot",style:{background:H(a.id)}}),z(a.id),e.jsx("span",{className:"uh-agent-cost",children:V(a.cost)}),e.jsx("span",{className:"uh-agent-share",children:fe(a.cost,k)})]},a.id))})]}),e.jsx("div",{ref:B,className:"uh-chart",role:"group","aria-label":"Daily cost by model",children:g.map((a,f)=>{const ne=T(a.totalCost,Y),S=a.period===l,I=`${a.period}, ${b(a.totalCost,a.modelBreakdowns.some(y=>y.missingPricing))}`;return e.jsxs("button",{className:`uh-bar-col${S?" sel":""}`,onClick:()=>r(S?null:a.period),"aria-pressed":S,"aria-label":I,title:I,style:{flexBasis:`${100/g.length}%`,"--uh-i":f,"--uh-step":`${Math.min(10,200/Math.max(g.length,1))}ms`},children:[e.jsx("div",{className:"uh-bar",style:{height:`${Math.max(ne,a.totalCost>0?2:0)}%`},children:K(a.modelBreakdowns).map(y=>{const oe=T(y.cost,a.totalCost);return e.jsx("div",{className:"uh-bar-seg",style:{height:`${oe}%`,background:R(y.modelName)}},y.modelName)})}),(g.length-1-f)%ae===0&&e.jsx("span",{className:"uh-bar-label",children:a.period.slice(5)})]},a.period)})}),e.jsx("div",{className:"uh-legend",children:se.map(([a,f])=>e.jsxs("span",{className:"uh-legend-item",title:a,children:[e.jsx("span",{className:"uh-legend-dot",style:{background:R(a)}}),q(a)," ",e.jsx("span",{className:"uh-legend-cost",children:b(f,M.has(a))})]},a))}),O&&e.jsx(Re,{selectedDay:O})]})]})})}function w({label:t,val:s,accent:n}){return e.jsxs("div",{className:"uh-stat",children:[e.jsx("span",{className:`uh-stat-val${n?" accent":""}`,children:s}),e.jsx("span",{className:"uh-stat-label",children:t})]})}export{Le as default};
|