import{o as e}from"./rolldown-runtime.DAXXjFlN.js";import{r as t}from"./emotion-is-prop-valid.esm.CygBv61C.js";import{c as n,l as r,t as i}from"./emotion-styled.browser.esm.DmHEQgFq.js";import{f as a}from"./getColors.DvVOOCnR.js";import{t as o}from"./useEmotionTheme.tyjAwN1A.js";import{t as s}from"./ErrorElement.BlvlqstC.js";import{r as c,t as l}from"./useFloatingOverlay.DKo8T0mQ.js";import{Gt as u,gn as d,x as f}from"./index.D3kRk1xg.js";import{t as p}from"./dist.D-2Cuhbv.js";import{t as m}from"./reactJsonViewCompat.w22CqI5a.js";var h=e(t(),1),g=e(p(),1),_=i(`div`,{target:`epagahn0`})(({theme:e})=>({overflowY:`auto`,position:`relative`,".react-json-view .copy-icon svg":{fontSize:`1em !important`,marginRight:`${e.spacing.threeXS} !important`,verticalAlign:`middle !important`}})),v=i(`div`,{target:`epagahn1`})(({theme:e})=>({display:`flex`,alignItems:`center`,gap:e.spacing.sm,padding:e.spacing.sm,paddingLeft:e.spacing.md,fontFamily:e.genericFonts.codeFont,fontSize:e.fontSizes.twoSm,color:e.colors.bodyText,maxWidth:`90vw`,wordBreak:`break-all`})),y=i(`button`,{target:`epagahn2`})(({theme:e})=>({display:`flex`,alignItems:`center`,justifyContent:`center`,padding:e.spacing.threeXS,backgroundColor:`transparent`,border:`none`,borderRadius:e.radii.sm,cursor:`pointer`,color:e.colors.fadedText60,transition:`color 0.15s ease, background-color 0.15s ease`,"&:hover":{backgroundColor:e.colors.darkenedBgMix15,color:e.colors.bodyText},"&:active":{backgroundColor:e.colors.darkenedBgMix25},"&:focus":{outline:`none`},"&:focus-visible":{boxShadow:e.shadows.focusRing}})),b=i(`div`,{target:`epagahn3`})(({theme:e})=>({backgroundColor:a(e)?e.colors.bgColor:e.colors.secondaryBg,borderRadius:e.radii.default,boxShadow:e.shadows.tooltip,overflow:`hidden`,zIndex:e.zIndices.popup}));function x({top:e,left:t,path:i,clearTooltip:a}){let{isCopied:o,copyToClipboard:s,label:f}=u(),{refs:p,floatingStyles:m}=l({open:!0,placement:`top`,offsetPx:15}),g=(0,h.useRef)(0);(0,h.useEffect)(()=>{g.current=Date.now()},[]);let _=(0,h.useRef)(a);(0,h.useEffect)(()=>{_.current=a},[a]);let x=(0,h.useRef)(null);(0,h.useEffect)(()=>{p.setReference({getBoundingClientRect:()=>({x:t,y:e,top:e,left:t,bottom:e,right:t,width:0,height:0})})},[p,e,t]);let S=(0,h.useCallback)(e=>{p.setFloating(e),x.current=e},[p]);(0,h.useEffect)(()=>{let e=e=>{Date.now()-g.current<50||x.current?.contains(e.target)||_.current()},t=e=>{e.key===`Escape`&&(e.stopPropagation(),_.current())};return document.addEventListener(`click`,e),document.addEventListener(`keydown`,t,!0),()=>{document.removeEventListener(`click`,e),document.removeEventListener(`keydown`,t,!0)}},[]);let C=(0,h.useCallback)(()=>{s(i)},[s,i]);return n(c,{children:n(b,{ref:S,"data-testid":`stJsonPathTooltipBody`,style:m,role:`dialog`,"aria-label":`JSON path`,children:r(v,{"data-testid":`stJsonPathTooltip`,children:[n(`code`,{children:i}),n(y,{onClick:C,title:f,"aria-label":f,autoFocus:!0,children:n(d,{size:`sm`,iconValue:o?`:material/check:`:`:material/content_copy:`})})]})})})}var S=(0,h.memo)(x);function C(e){return e.length===0?`$`:e.reduce((e,t,n)=>t===null?e:/^\d+$/.test(t)?`${e}[${t}]`:t===``||/[^a-zA-Z0-9_$]/.test(t)||/^\d/.test(t)?`${e}["${t.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"]`:n===0||e===``?t:`${e}.${t}`,``)}function w(){let[e,t]=(0,h.useState)(null),n=(0,h.useRef)({x:0,y:0});return(0,h.useEffect)(()=>{let e=e=>{n.current={x:e.clientX,y:e.clientY}};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),{tooltip:e,handleSelect:(0,h.useCallback)(e=>{let{x:r,y:i}=n.current;t({path:C([...e.namespace,e.name]),x:r,y:i})},[]),clearTooltip:(0,h.useCallback)(()=>{t(null)},[])}}function T({element:e}){let t=o(),{tooltip:i,handleSelect:c,clearTooltip:l}=w(),{copyToClipboard:d}=u(),p=(0,h.useCallback)(e=>{d(JSON.stringify(e.src))},[d]),v;try{v=JSON.parse(e.body)}catch(t){let r=f(t);try{v=g.default.parse(e.body)}catch{let t=parseInt(r.message.replace(/[^0-9]/g,``),10);return r.message+=`\n${e.body.substring(0,t+1)} ← here`,n(s,{name:`Json Parse Error`,message:r.message})}}let y=a(t)?`rjv-default`:`monokai`;return r(_,{className:`stJson`,"data-testid":`stJson`,children:[n(m,{src:v,collapsed:e.maxExpandDepth??!e.expanded,displayDataTypes:!1,displayObjectSize:!1,name:!1,theme:y,enableClipboard:p,onSelect:c,showComma:!1,style:{fontFamily:t.genericFonts.codeFont,fontSize:t.fontSizes.codeFontSize,fontWeight:t.fontWeights.code,backgroundColor:t.colors.bgColor,whiteSpace:`pre-wrap`}}),i&&n(S,{top:i.y,left:i.x,path:i.path,clearTooltip:l})]})}var E=(0,h.memo)(T);export{E as default};