import{o as e}from"./chunk.DuxOD-Sk.js";import{r as t}from"./emotion-is-prop-valid.esm.DV_OErv-.js";import{c as n,l as r,t as i}from"./emotion-styled.browser.esm.BPUx6WuE.js";import{f as a}from"./getColors.DUygtxH4.js";import{n as o,t as s}from"./useEmotionTheme.61kSPILX.js";import{t as c}from"./ErrorElement.BPchO-rz.js";import{t as l}from"./DynamicIcon.BDXbm0Of.js";import{c as u,n as d,s as f,t as p}from"./useCopyToClipboard.CEiWWO_K.js";import{t as m}from"./dist.B1bOMQPF.js";import{t as h}from"./reactJsonViewCompat.D5MCl5lB.js";var g=e(t(),1),_=e(m()),v=i(`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=i(`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=i(`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=i(`div`,{target:`e1dt4n1i3`})(({top:e,left:t})=>({position:`fixed`,top:e,left:t}));function S({top:e,left:t,path:i,clearTooltip:o}){let[c,m]=(0,g.useState)(!0),h=s(),{colors:_,radii:v}=h,{isCopied:S,copyToClipboard:C,label:w}=p(),T=(0,g.useCallback)(()=>{m(!1),o()},[o]),E=(0,g.useCallback)(()=>{C(i)},[C,i]);return n(d,{content:r(y,{"data-testid":`stJsonPathTooltip`,children:[n(`code`,{children:i}),n(b,{onClick:E,title:w,"aria-label":w,autoFocus:!0,children:n(l,{size:`sm`,iconValue:S?`:material/check:`:`:material/content_copy:`})})]}),placement:u.top,accessibilityType:f.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:a(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:c,children:n(x,{"data-testid":`stJsonPathTooltipTarget`,top:e,left:t})})}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:e}){let t=s(),{tooltip:i,handleSelect:l,clearTooltip:u}=T(),{copyToClipboard:d}=p(),f=(0,g.useCallback)(e=>{d(JSON.stringify(e.src))},[d]),m;try{m=JSON.parse(e.body)}catch(t){let r=o(t);try{m=_.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(c,{name:`Json Parse Error`,message:r.message})}}let y=a(t)?`rjv-default`:`monokai`;return r(v,{className:`stJson`,"data-testid":`stJson`,children:[n(h,{src:m,collapsed:e.maxExpandDepth??!e.expanded,displayDataTypes:!1,displayObjectSize:!1,name:!1,theme:y,enableClipboard:f,onSelect:l,showComma:!1,style:{fontFamily:t.genericFonts.codeFont,fontSize:t.fontSizes.codeFontSize,fontWeight:t.fontWeights.code,backgroundColor:t.colors.bgColor,whiteSpace:`pre-wrap`}}),i&&n(C,{top:i.y,left:i.x,path:i.path,clearTooltip:u})]})}var D=(0,g.memo)(E);export{D as default};