import{u as c}from"./useQuery-DB4moXtm.js";import{i as u,x as r,p as g,q as y}from"./index-CXwCk-SR.js";function k(n,e){const t=c({queryKey:["layer-traces",n,e.source,e.service,e.instanceId,e.endpointId,e.traceId,e.traceState,e.queryOrder,e.minDuration,e.maxDuration,e.pageNum,e.pageSize,e.tags,e.windowMinutes,e.customStart,e.customEnd],queryFn:()=>r.trace.list(n.value,{source:e.source.value,...e.service.value?{service:e.service.value}:{},...e.instanceId.value?{instanceId:e.instanceId.value}:{},...e.endpointId.value?{endpointId:e.endpointId.value}:{},...e.traceId.value?{traceId:e.traceId.value}:{},traceState:e.traceState.value,queryOrder:e.queryOrder.value,...e.minDuration.value!==null?{minTraceDuration:e.minDuration.value}:{},...e.maxDuration.value!==null?{maxTraceDuration:e.maxDuration.value}:{},pageNum:e.pageNum.value,pageSize:e.pageSize.value,...e.tags.value.length>0?{tags:e.tags.value}:{},...e.customStart.value&&e.customEnd.value?{start:e.customStart.value,end:e.customEnd.value}:{windowMinutes:e.windowMinutes.value}}),enabled:u(()=>n.value.length>0&&(e.enabled?e.enabled.value:!0)),staleTime:15e3});return{data:u(()=>t.data.value??null),native:u(()=>{var i;return((i=t.data.value)==null?void 0:i.native)??null}),zipkin:u(()=>{var i;return((i=t.data.value)==null?void 0:i.zipkin)??null}),isLoading:t.isLoading,isFetching:t.isFetching,error:t.error,refetch:t.refetch}}function h(n,e){const t=c({queryKey:["trace-detail",n,e],queryFn:()=>r.trace.detail(n.value,e.value),enabled:u(()=>!!n.value),staleTime:6e4});return{data:u(()=>t.data.value??null),nativeDetail:u(()=>{var i;return((i=t.data.value)==null?void 0:i.native)??null}),zipkinDetail:u(()=>{var i;return((i=t.data.value)==null?void 0:i.zipkin)??null}),isLoading:t.isLoading,isFetching:t.isFetching,error:t.error}}function D(n){const e=u(()=>n.enabled?n.enabled.value:!0),t=c({queryKey:["zipkin-traces",n.serviceName,n.remoteServiceName??u(()=>null),n.spanName??u(()=>null),n.minDuration??u(()=>null),n.maxDuration??u(()=>null),n.endTs??u(()=>null),n.lookback,n.limit,n.annotationQuery??u(()=>null)],queryFn:()=>{var o,l,a,v,d,s;const i={...n.serviceName.value?{serviceName:n.serviceName.value}:{},...(o=n.remoteServiceName)!=null&&o.value?{remoteServiceName:n.remoteServiceName.value}:{},...(l=n.spanName)!=null&&l.value?{spanName:n.spanName.value}:{},...(a=n.minDuration)!=null&&a.value?{minDuration:n.minDuration.value}:{},...(v=n.maxDuration)!=null&&v.value?{maxDuration:n.maxDuration.value}:{},...(d=n.endTs)!=null&&d.value?{endTs:n.endTs.value}:{},...(s=n.annotationQuery)!=null&&s.value?{annotationQuery:n.annotationQuery.value}:{},lookback:n.lookback.value,limit:n.limit.value};return r.zipkin.traces(i)},enabled:e,staleTime:15e3});return{data:u(()=>t.data.value??null),traces:u(()=>{var i;return((i=t.data.value)==null?void 0:i.traces)??[]}),isLoading:t.isLoading,isFetching:t.isFetching,error:t.error,refetch:t.refetch}}function f(n){const e=c({queryKey:["zipkin-trace",n],queryFn:()=>r.zipkin.trace(n.value),enabled:u(()=>!!n.value),staleTime:6e4});return{data:u(()=>e.data.value??null),spans:u(()=>{var t;return((t=e.data.value)==null?void 0:t.spans)??[]}),isLoading:e.isLoading,isFetching:e.isFetching,error:e.error}}function N(){const n=g(),e=y(),t=u(()=>{const l=n.query.openZipkinTraceId;return typeof l=="string"&&l.length>0?l:null});function i(l){if(!l)return;const a={...n.query,openZipkinTraceId:l};e.replace({path:n.path,query:a})}function o(){if(!t.value)return;const l={...n.query};delete l.openZipkinTraceId,e.replace({path:n.path,query:l})}return{openTraceId:t,openTrace:i,closeTrace:o}}export{h as a,D as b,N as c,f as d,k as u};
