import{Ja as e,Jt as t,Nr as n,Qa as r,Sn as i,Ya as a,bn as o,cr as s,fr as c,g as l,io as u,vr as d,wn as f,xn as p}from"./index.dkY5s53S.js";import{t as m}from"./dist.D8e_gvvD.js";import{t as h}from"./reactJsonViewCompat.DeSSF5mf.js";var g=u(r(),1),_=u(m(),1),v=d(`div`,{target:`e1dt4n1i0`})(({theme:e})=>({overflowY:`auto`,position:`relative`,".react-json-view .copy-icon svg":{fontSize:`1em !important`,marginRight:`${e.spacing.threeXS} !important`,verticalAlign:`middle !important`}})),y=d(`div`,{target:`e1dt4n1i1`})(({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`})),b=d(`button`,{target:`e1dt4n1i2`})(({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}})),x=d(`div`,{target:`e1dt4n1i3`})(({top:e,left:t})=>({position:`fixed`,top:e,left:t}));function S({top:r,left:l,path:u,clearTooltip:d}){let[f,m]=(0,g.useState)(!0),h=s(),{colors:_,radii:v}=h,{isCopied:S,copyToClipboard:C,label:w}=t(),T=(0,g.useCallback)(()=>{m(!1),d()},[d]),E=(0,g.useCallback)(()=>{C(u)},[C,u]);return e(o,{content:a(y,{"data-testid":`stJsonPathTooltip`,children:[e(`code`,{children:u}),e(b,{onClick:E,title:w,"aria-label":w,autoFocus:!0,children:e(c,{size:`sm`,iconValue:S?`:material/check:`:`:material/content_copy:`})})]}),placement:i.top,accessibilityType:p.tooltip,showArrow:!1,popoverMargin:15,onClickOutside:T,onEsc:T,overrides:{Body:{style:{borderTopLeftRadius:v.default,borderTopRightRadius:v.default,borderBottomLeftRadius:v.default,borderBottomRightRadius:v.default,paddingTop:`0 !important`,paddingBottom:`0 !important`,paddingLeft:`0 !important`,paddingRight:`0 !important`,backgroundColor:`transparent`}},Inner:{style:{backgroundColor:n(h)?_.bgColor:_.secondaryBg,color:_.bodyText,borderTopLeftRadius:v.default,borderTopRightRadius:v.default,borderBottomLeftRadius:v.default,borderBottomRightRadius:v.default,paddingTop:`0 !important`,paddingBottom:`0 !important`,paddingLeft:`0 !important`,paddingRight:`0 !important`}}},isOpen:f,children:e(x,{"data-testid":`stJsonPathTooltipTarget`,top:r,left:l})})}var C=(0,g.memo)(S);function w(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 T(){let[e,t]=(0,g.useState)(null),n=(0,g.useRef)({x:0,y:0});return(0,g.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,g.useCallback)(e=>{let{x:r,y:i}=n.current;t({path:w([...e.namespace,e.name]),x:r,y:i})},[]),clearTooltip:(0,g.useCallback)(()=>{t(null)},[])}}function E({element:r}){let i=s(),{tooltip:o,handleSelect:c,clearTooltip:u}=T(),{copyToClipboard:d}=t(),p=(0,g.useCallback)(e=>{d(JSON.stringify(e.src))},[d]),m;try{m=JSON.parse(r.body)}catch(t){let n=l(t);try{m=_.default.parse(r.body)}catch{let t=parseInt(n.message.replace(/[^0-9]/g,``),10);return n.message+=`\n${r.body.substring(0,t+1)} ← here`,e(f,{name:`Json Parse Error`,message:n.message})}}let y=n(i)?`rjv-default`:`monokai`;return a(v,{className:`stJson`,"data-testid":`stJson`,children:[e(h,{src:m,collapsed:r.maxExpandDepth??!r.expanded,displayDataTypes:!1,displayObjectSize:!1,name:!1,theme:y,enableClipboard:p,onSelect:c,showComma:!1,style:{fontFamily:i.genericFonts.codeFont,fontSize:i.fontSizes.codeFontSize,fontWeight:i.fontWeights.code,backgroundColor:i.colors.bgColor,whiteSpace:`pre-wrap`}}),o&&e(C,{top:o.y,left:o.x,path:o.path,clearTooltip:u})]})}var D=(0,g.memo)(E);export{D as default};