@motiadev/plugin-observability 0.8.2-beta.140-428722 → 0.8.3-beta.141-694167

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.
Files changed (3) hide show
  1. package/dist/index.cjs +74 -4
  2. package/dist/index.js +1139 -359
  3. package/package.json +4 -4
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react"),F=require("@motiadev/stream-client-react"),b=require("@motiadev/ui"),j=require("lucide-react"),de=require("zustand"),ue=require("date-fns");var y={exports:{}},E={};/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react"),q=require("@motiadev/stream-client-react"),w=require("@motiadev/ui");var A={exports:{}},P={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var U;function me(){if(U)return E;U=1;var t=Symbol.for("react.transitional.element"),s=Symbol.for("react.fragment");function l(a,o,u){var p=null;if(u!==void 0&&(p=""+u),o.key!==void 0&&(p=""+o.key),"key"in o){u={};for(var d in o)d!=="key"&&(u[d]=o[d])}else u=o;return o=u.ref,{$$typeof:t,type:a,key:p,ref:o!==void 0?o:null,props:u}}return E.Fragment=s,E.jsx=l,E.jsxs=l,E}var w={};/**
9
+ */var K;function we(){if(K)return P;K=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(a,o,c){var l=null;if(c!==void 0&&(l=""+c),o.key!==void 0&&(l=""+o.key),"key"in o){c={};for(var i in o)i!=="key"&&(c[i]=o[i])}else c=o;return o=c.ref,{$$typeof:e,type:a,key:l,ref:o!==void 0?o:null,props:c}}return P.Fragment=t,P.jsx=r,P.jsxs=r,P}var R={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,9 +14,79 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var J;function fe(){return J||(J=1,process.env.NODE_ENV!=="production"&&function(){function t(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===le?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case S:return"Fragment";case K:return"Profiler";case Q:return"StrictMode";case se:return"Suspense";case ae:return"SuspenseList";case oe:return"Activity"}if(typeof r=="object")switch(typeof r.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),r.$$typeof){case H:return"Portal";case te:return(r.displayName||"Context")+".Provider";case ee:return(r._context.displayName||"Context")+".Consumer";case re:var n=r.render;return r=r.displayName,r||(r=n.displayName||n.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case ne:return n=r.displayName||null,n!==null?n:t(r.type)||"Memo";case G:n=r._payload,r=r._init;try{return t(r(n))}catch{}}return null}function s(r){return""+r}function l(r){try{s(r);var n=!1}catch{n=!0}if(n){n=console;var c=n.error,m=typeof Symbol=="function"&&Symbol.toStringTag&&r[Symbol.toStringTag]||r.constructor.name||"Object";return c.call(n,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",m),s(r)}}function a(r){if(r===S)return"<>";if(typeof r=="object"&&r!==null&&r.$$typeof===G)return"<...>";try{var n=t(r);return n?"<"+n+">":"<...>"}catch{return"<...>"}}function o(){var r=O.A;return r===null?null:r.getOwner()}function u(){return Error("react-stack-top-frame")}function p(r){if(L.call(r,"key")){var n=Object.getOwnPropertyDescriptor(r,"key").get;if(n&&n.isReactWarning)return!1}return r.key!==void 0}function d(r,n){function c(){Y||(Y=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",n))}c.isReactWarning=!0,Object.defineProperty(r,"key",{get:c,configurable:!0})}function i(){var r=t(this.type);return q[r]||(q[r]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),r=this.props.ref,r!==void 0?r:null}function k(r,n,c,m,g,v,P,C){return c=v.ref,r={$$typeof:M,type:r,key:n,props:v,_owner:g},(c!==void 0?c:null)!==null?Object.defineProperty(r,"ref",{enumerable:!1,get:i}):Object.defineProperty(r,"ref",{enumerable:!1,value:null}),r._store={},Object.defineProperty(r._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(r,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(r,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:P}),Object.defineProperty(r,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:C}),Object.freeze&&(Object.freeze(r.props),Object.freeze(r)),r}function h(r,n,c,m,g,v,P,C){var f=n.children;if(f!==void 0)if(m)if(ie(f)){for(m=0;m<f.length;m++)$(f[m]);Object.freeze&&Object.freeze(f)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else $(f);if(L.call(n,"key")){f=t(r);var N=Object.keys(n).filter(function(ce){return ce!=="key"});m=0<N.length?"{key: someKey, "+N.join(": ..., ")+": ...}":"{key: someKey}",W[f+m]||(N=0<N.length?"{"+N.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
17
+ */var ee;function Ne(){return ee||(ee=1,process.env.NODE_ENV!=="production"&&function(){function e(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===ve?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case S:return"Fragment";case ue:return"Profiler";case de:return"StrictMode";case xe:return"Suspense";case pe:return"SuspenseList";case ge:return"Activity"}if(typeof s=="object")switch(typeof s.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),s.$$typeof){case N:return"Portal";case fe:return(s.displayName||"Context")+".Provider";case me:return(s._context.displayName||"Context")+".Consumer";case he:var d=s.render;return s=s.displayName,s||(s=d.displayName||d.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case be:return d=s.displayName||null,d!==null?d:e(s.type)||"Memo";case X:d=s._payload,s=s._init;try{return e(s(d))}catch{}}return null}function t(s){return""+s}function r(s){try{t(s);var d=!1}catch{d=!0}if(d){d=console;var f=d.error,g=typeof Symbol=="function"&&Symbol.toStringTag&&s[Symbol.toStringTag]||s.constructor.name||"Object";return f.call(d,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",g),t(s)}}function a(s){if(s===S)return"<>";if(typeof s=="object"&&s!==null&&s.$$typeof===X)return"<...>";try{var d=e(s);return d?"<"+d+">":"<...>"}catch{return"<...>"}}function o(){var s=W.A;return s===null?null:s.getOwner()}function c(){return Error("react-stack-top-frame")}function l(s){if(B.call(s,"key")){var d=Object.getOwnPropertyDescriptor(s,"key").get;if(d&&d.isReactWarning)return!1}return s.key!==void 0}function i(s,d){function f(){J||(J=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",d))}f.isReactWarning=!0,Object.defineProperty(s,"key",{get:f,configurable:!0})}function u(){var s=e(this.type);return U[s]||(U[s]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),s=this.props.ref,s!==void 0?s:null}function m(s,d,f,g,M,T,L,Y){return f=T.ref,s={$$typeof:j,type:s,key:d,props:T,_owner:M},(f!==void 0?f:null)!==null?Object.defineProperty(s,"ref",{enumerable:!1,get:u}):Object.defineProperty(s,"ref",{enumerable:!1,value:null}),s._store={},Object.defineProperty(s._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(s,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(s,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:L}),Object.defineProperty(s,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Y}),Object.freeze&&(Object.freeze(s.props),Object.freeze(s)),s}function p(s,d,f,g,M,T,L,Y){var v=d.children;if(v!==void 0)if(g)if(ye(v)){for(g=0;g<v.length;g++)y(v[g]);Object.freeze&&Object.freeze(v)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else y(v);if(B.call(d,"key")){v=e(s);var E=Object.keys(d).filter(function(je){return je!=="key"});g=0<E.length?"{key: someKey, "+E.join(": ..., ")+": ...}":"{key: someKey}",Z[v+g]||(E=0<E.length?"{"+E.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
18
  let props = %s;
19
19
  <%s {...props} />
20
20
  React keys must be passed directly to JSX without using spread:
21
21
  let props = %s;
22
- <%s key={someKey} {...props} />`,m,f,N,f),W[f+m]=!0)}if(f=null,c!==void 0&&(l(c),f=""+c),p(n)&&(l(n.key),f=""+n.key),"key"in n){c={};for(var I in n)I!=="key"&&(c[I]=n[I])}else c=n;return f&&d(c,typeof r=="function"?r.displayName||r.name||"Unknown":r),k(r,f,v,g,o(),c,P,C)}function $(r){typeof r=="object"&&r!==null&&r.$$typeof===M&&r._store&&(r._store.validated=1)}var _=x,M=Symbol.for("react.transitional.element"),H=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),Q=Symbol.for("react.strict_mode"),K=Symbol.for("react.profiler"),ee=Symbol.for("react.consumer"),te=Symbol.for("react.context"),re=Symbol.for("react.forward_ref"),se=Symbol.for("react.suspense"),ae=Symbol.for("react.suspense_list"),ne=Symbol.for("react.memo"),G=Symbol.for("react.lazy"),oe=Symbol.for("react.activity"),le=Symbol.for("react.client.reference"),O=_.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=Object.prototype.hasOwnProperty,ie=Array.isArray,A=console.createTask?console.createTask:function(){return null};_={react_stack_bottom_frame:function(r){return r()}};var Y,q={},z=_.react_stack_bottom_frame.bind(_,u)(),B=A(a(u)),W={};w.Fragment=S,w.jsx=function(r,n,c,m,g){var v=1e4>O.recentlyCreatedOwnerStacks++;return h(r,n,c,!1,m,g,v?Error("react-stack-top-frame"):z,v?A(a(r)):B)},w.jsxs=function(r,n,c,m,g){var v=1e4>O.recentlyCreatedOwnerStacks++;return h(r,n,c,!0,m,g,v?Error("react-stack-top-frame"):z,v?A(a(r)):B)}}()),w}var V;function xe(){return V||(V=1,process.env.NODE_ENV==="production"?y.exports=me():y.exports=fe()),y.exports}var e=xe();const R=de.create()(t=>({selectedTraceGroupId:void 0,selectedTraceId:void 0,selectTraceGroupId:s=>t({selectedTraceGroupId:s}),selectTraceId:s=>t({selectedTraceId:s})})),pe=t=>{const s=t?.endTime,[l,a]=x.useState(s||Date.now());return x.useEffect(()=>{if(s)a(s);else{const o=setInterval(()=>a(Date.now()),50);return()=>clearInterval(o)}},[s]),l},T=t=>t==null?"N/A":t<1e3?`${t}ms`:t<6e4?`${(t/1e3).toFixed(1)}s`:t<36e5?`${(t/6e4).toFixed(1)}min`:`${(t/36e5).toFixed(1)}h`,he=({trace:t,group:s,groupEndTime:l,onExpand:a})=>e.jsxs("div",{className:"flex hover:bg-muted-foreground/10 relative cursor-pointer",onClick:()=>a(t.id),"data-testid":"trace-timeline-item",children:[e.jsx("div",{className:"flex items-center min-w-[200px] max-w-[200px] h-[32px] max-h-[32px] py-4 px-2 text-sm font-semibold text-foreground truncate sticky left-0 bg-card z-9",children:t.name}),e.jsx("div",{className:"flex w-full flex-row items-center hover:bg-muted/50 rounded-md",children:e.jsx("div",{className:"relative w-full h-[32px] flex items-center",children:e.jsx("div",{className:b.cn("h-[24px] rounded-[4px] hover:opacity-80 transition-all duration-200",{"bg-[repeating-linear-gradient(140deg,#BEFE29,#BEFE29_8px,#ABE625_8px,#ABE625_16px)]":t.status==="running","bg-[repeating-linear-gradient(140deg,#2862FE,#2862FE_8px,#2358E5_8px,#2358E5_16px)]":t.status==="completed","bg-[repeating-linear-gradient(140deg,#EA2069,#EA2069_8px,#D41E60_8px,#D41E60_16px)]":t.status==="failed"}),style:{marginLeft:`${(t.startTime-s.startTime)/(l-s.startTime)*100}%`,width:t.endTime?`${(t.endTime-t.startTime)/(l-s.startTime)*100}%`:`${(Date.now()-t.startTime)/(l-s.startTime)*100}%`}})})})]}),je=({event:t})=>{if(t.type==="log")return e.jsx(j.ScrollText,{className:"w-4 h-4 text-muted-foreground"});if(t.type==="emit")return e.jsx(j.MessageCircle,{className:"w-4 h-4 text-muted-foreground"});if(t.type==="state")return e.jsx(j.Package,{className:"w-4 h-4 text-muted-foreground"});if(t.type==="stream")return e.jsx(j.Radio,{className:"w-4 h-4 text-muted-foreground"})},X=({arg:t})=>{if(typeof t=="string")return e.jsxs("span",{className:"font-mono text-blue-500",children:["'",t,"'"]});if(t===!1)return e.jsx("span",{className:"font-mono text-blue-100 font-bold bg-blue-500/50 px-2 rounded-md",children:"value"});const s=Object.entries(t);return e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-mono text-green-500",children:"{ "}),s.map(([l,a],o)=>e.jsxs("span",{children:[e.jsx("span",{className:"font-mono text-green-500",children:l}),e.jsx("span",{className:"font-mono text-muted-foreground",children:":"})," ",e.jsx(X,{arg:a}),o<s.length-1&&e.jsx(e.Fragment,{children:", "})]},l)),e.jsx("span",{className:"font-mono text-green-500",children:" }"})]})},D=({topLevelClassName:t,objectName:s,functionName:l,args:a,callsQuantity:o})=>{const u=o&&o>1,p=a.filter(d=>d!==void 0);return e.jsxs("div",{children:[t&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-mono text-pink-500",children:t}),"."]}),s&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-mono text-pink-500",children:s}),"."]}),e.jsx("span",{className:"font-mono text-pink-500",children:l}),e.jsx("span",{className:"font-mono text-emerald-500",children:"("}),p.map((d,i)=>e.jsxs("span",{children:[e.jsx(X,{arg:d}),i<p.length-1&&e.jsx(e.Fragment,{children:", "})]},i)),e.jsx("span",{className:"font-mono text-emerald-500",children:")"}),u&&e.jsxs("span",{className:"font-mono text-muted-foreground",children:[" x",o]})]})},be=({event:t})=>e.jsx(D,{functionName:"emit",args:[{topic:t.topic,data:!1}]}),ve=({event:t})=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b.LevelDot,{level:t.level})," ",t.message]}),ge=({event:t})=>e.jsx(D,{objectName:"state",functionName:t.operation,args:[t.data.traceId,t.data.key,t.data.value?!1:void 0]}),Te=({event:t})=>e.jsx(D,{topLevelClassName:"streams",objectName:t.streamName,functionName:t.operation,args:[t.data.groupId,t.data.id,t.data.data?!1:void 0],callsQuantity:t.calls}),Ne=x.memo(({event:t})=>{if(t.type==="log")return e.jsx(ve,{event:t});if(t.type==="emit")return e.jsx(be,{event:t});if(t.type==="state")return e.jsx(ge,{event:t});if(t.type==="stream")return e.jsx(Te,{event:t})}),Ee=x.memo(({trace:t,onClose:s})=>e.jsxs(b.Sidebar,{onClose:s,title:"Trace Details",subtitle:`Viewing details from step ${t.name}`,actions:[{icon:e.jsx(j.X,{}),onClick:s,label:"Close"}],children:[e.jsxs("div",{className:"px-2 w-[800px] overflow-auto",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground mb-4",children:[t.endTime&&e.jsxs("span",{children:["Duration: ",T(t.endTime-t.startTime)]}),e.jsx("div",{className:"bg-blue-500 font-bold text-xs px-[4px] py-[2px] rounded-sm text-blue-100",children:t.entryPoint.type}),t.correlationId&&e.jsxs(b.Badge,{variant:"outline",children:["Correlated: ",t.correlationId]})]}),e.jsx("div",{className:"pl-6 border-l-1 border-gray-500/40 font-mono text-xs flex flex-col gap-3",children:t.events.map((l,a)=>e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute -left-[26px] top-[8px] w-1 h-1 rounded-full bg-emerald-500 outline outline-2 outline-emerald-500/50"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(je,{event:l}),e.jsxs("span",{className:"text-sm font-mono text-muted-foreground",children:["+",T(Math.floor(l.timestamp-t.startTime))]}),e.jsx(Ne,{event:l})]})]},a))})]}),t.error&&e.jsxs("div",{className:"p-4 bg-red-800/10",children:[e.jsx("div",{className:"text-sm text-red-800 dark:text-red-400 font-semibold",children:t.error.message}),e.jsx("div",{className:"text-sm text-red-800 dark:text-red-400 pl-4",children:t.error.stack})]})]})),we=x.memo(({groupId:t})=>{const{data:s}=F.useStreamItem({streamName:"motia-trace-group",groupId:"default",id:t}),{data:l}=F.useStreamGroup({streamName:"motia-trace",groupId:t}),a=pe(s),[o,u]=x.useState(1),p=R(h=>h.selectedTraceId),d=R(h=>h.selectTraceId),i=x.useMemo(()=>l?.find(h=>h.id===p),[l,p]),k=()=>{o>.5&&u(o-.1)};return s?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-col flex-1 overflow-x-auto h-full relative",children:e.jsxs("div",{className:"flex flex-col items-center min-w-full sticky top-0",style:{width:`${o*1e3}px`},children:[e.jsxs("div",{className:"flex flex-1 w-full sticky top-0 bg-background z-10",children:[e.jsxs("div",{className:"w-full min-h-[37px] h-[37px] min-w-[200px] max-w-[200px] flex items-center justify-center gap-2 sticky left-0 top-0 bg-card backdrop-blur-[4px] backdrop-filter",children:[e.jsx(b.Button,{variant:"icon",size:"sm",className:"px-2",onClick:k,children:e.jsx(j.Minus,{className:"w-4 h-4 cursor-pointer"})}),e.jsxs("span",{className:"text-sm font-bold text-muted-foreground",children:[Math.floor(o*100),"%"]}),e.jsx(b.Button,{variant:"icon",size:"sm",className:"px-2",onClick:()=>u(o+.1),children:e.jsx(j.Plus,{className:"w-4 h-4 cursor-pointer"})})]}),e.jsxs("div",{className:"flex justify-between font-mono p-2 w-full text-xs text-muted-foreground bg-card",children:[e.jsx("span",{children:T(0)}),e.jsx("span",{children:T(Math.floor((a-s.startTime)*.25))}),e.jsx("span",{children:T(Math.floor((a-s.startTime)*.5))}),e.jsx("span",{children:T(Math.floor((a-s.startTime)*.75))}),e.jsx("span",{children:T(Math.floor(a-s.startTime))}),e.jsxs("div",{className:"absolute bottom-[-4px] w-full flex justify-between",children:[e.jsx("span",{className:"w-[1px] h-full bg-blue-500"}),e.jsx("span",{className:"w-[1px] h-full bg-blue-500"}),e.jsx("span",{className:"w-[1px] h-full bg-blue-500"}),e.jsx("span",{className:"w-[1px] h-full bg-blue-500"}),e.jsx("span",{className:"w-[1px] h-full bg-blue-500"})]})]})]}),e.jsx("div",{className:"flex flex-col w-full h-full",children:l?.map(h=>e.jsx(he,{trace:h,group:s,groupEndTime:a,onExpand:d},h.id))})]})}),i&&e.jsx(Ee,{trace:i,onClose:()=>d(void 0)})]}):null}),_e=({status:t,duration:s})=>{const l=x.useMemo(()=>t==="running"?"info":t==="completed"?"success":t==="failed"?"error":"default",[t]);return e.jsx(b.Badge,{variant:l,children:s&&t!=="failed"?s:t})},ye=x.memo(({groups:t,selectedGroupId:s,onGroupSelect:l})=>e.jsx("div",{className:"overflow-auto",children:t.length>0&&e.jsx("div",{children:[...t].reverse().map(a=>e.jsx("div",{"data-testid":`trace-${a.id}`,className:b.cn("motia-trace-group cursor-pointer transition-colors",s===a.id?"bg-muted-foreground/10":"hover:bg-muted/70"),onClick:()=>l(a),children:e.jsxs("div",{className:"p-3 flex flex-col gap-1",children:[e.jsxs("div",{className:"flex flex-row justify-between items-center gap-2",children:[e.jsx("span",{className:"font-semibold text-lg",children:a.name}),e.jsx(_e,{status:a.status,duration:a.endTime?T(a.endTime-a.startTime):void 0})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("div",{"data-testid":"trace-id",className:"text-xs text-muted-foreground font-mono tracking-[1px]",children:a.id}),e.jsxs("span",{children:[a.metadata.totalSteps," steps"]})]}),e.jsxs("div",{className:"flex justify-between",children:[ue.formatDistanceToNow(a.startTime)," ago"]}),a.metadata.activeSteps>0&&e.jsxs("div",{className:"text-blue-600",children:[a.metadata.activeSteps," active"]})]})]})},a.id))})})),Re=()=>{const t=R(i=>i.selectedTraceGroupId),s=R(i=>i.selectTraceGroupId),{data:l}=F.useStreamGroup({streamName:"motia-trace-group",groupId:"default"}),a=i=>s(i.id),[o,u]=x.useState(""),p=()=>fetch("/__motia/trace/clear",{method:"POST"}),d=x.useMemo(()=>l?.filter(i=>i.name.toLowerCase().includes(o.toLowerCase())||i.id.toLowerCase().includes(o.toLowerCase())),[l,o]);return x.useEffect(()=>{if(d&&d.length>0){const i=d[d.length-1];i&&i.status==="running"&&i.id!==t&&s(i.id)}else t&&s(void 0)},[d]),e.jsxs("div",{className:"grid grid-rows-[auto_1fr] h-full",children:[e.jsxs("div",{className:"flex p-2 border-b gap-2","data-testid":"logs-search-container",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(b.Input,{variant:"shade",value:o,onChange:i=>u(i.target.value),className:"px-9 font-medium",placeholder:"Search by Trace ID or Step Name"}),e.jsx(j.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground/50"}),e.jsx(j.X,{className:b.cn("cursor-pointer absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground/50 hover:text-muted-foreground",{visible:o!=="",invisible:o===""}),onClick:()=>u("")})]}),e.jsxs(b.Button,{variant:"default",onClick:p,className:"h-[34px]",children:[e.jsx(j.Trash,{})," Clear"]})]}),e.jsxs("div",{className:"grid grid-cols-[300px_1fr] overflow-hidden",children:[e.jsx("div",{className:"w-[300px] border-r border-border overflow-auto h-full","data-testid":"traces-container",children:e.jsx(ye,{groups:d,selectedGroupId:t,onGroupSelect:a})}),e.jsxs("div",{className:"overflow-auto","data-testid":"trace-details",children:[t&&e.jsx(we,{groupId:t}),!t&&e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:"Select a trace or trace group to view the timeline"})]})]})]})},Z=x.memo(()=>e.jsxs(e.Fragment,{children:[e.jsx(j.GanttChart,{"aria-hidden":"true"}),e.jsx("span",{children:"Tracing"})]}));Z.displayName="ObservabilityTabLabel";exports.ObservabilityPage=Re;exports.ObservabilityTabLabel=Z;
22
+ <%s key={someKey} {...props} />`,g,v,E,v),Z[v+g]=!0)}if(v=null,f!==void 0&&(r(f),v=""+f),l(d)&&(r(d.key),v=""+d.key),"key"in d){f={};for(var V in d)V!=="key"&&(f[V]=d[V])}else f=d;return v&&i(f,typeof s=="function"?s.displayName||s.name||"Unknown":s),m(s,v,T,M,o(),f,L,Y)}function y(s){typeof s=="object"&&s!==null&&s.$$typeof===j&&s._store&&(s._store.validated=1)}var x=h,j=Symbol.for("react.transitional.element"),N=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),de=Symbol.for("react.strict_mode"),ue=Symbol.for("react.profiler"),me=Symbol.for("react.consumer"),fe=Symbol.for("react.context"),he=Symbol.for("react.forward_ref"),xe=Symbol.for("react.suspense"),pe=Symbol.for("react.suspense_list"),be=Symbol.for("react.memo"),X=Symbol.for("react.lazy"),ge=Symbol.for("react.activity"),ve=Symbol.for("react.client.reference"),W=x.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B=Object.prototype.hasOwnProperty,ye=Array.isArray,$=console.createTask?console.createTask:function(){return null};x={react_stack_bottom_frame:function(s){return s()}};var J,U={},H=x.react_stack_bottom_frame.bind(x,c)(),Q=$(a(c)),Z={};R.Fragment=S,R.jsx=function(s,d,f,g,M){var T=1e4>W.recentlyCreatedOwnerStacks++;return p(s,d,f,!1,g,M,T?Error("react-stack-top-frame"):H,T?$(a(s)):Q)},R.jsxs=function(s,d,f,g,M){var T=1e4>W.recentlyCreatedOwnerStacks++;return p(s,d,f,!0,g,M,T?Error("react-stack-top-frame"):H,T?$(a(s)):Q)}}()),R}var te;function Te(){return te||(te=1,process.env.NODE_ENV==="production"?A.exports=we():A.exports=Ne()),A.exports}var n=Te();/**
23
+ * @license lucide-react v0.545.0 - ISC
24
+ *
25
+ * This source code is licensed under the ISC license.
26
+ * See the LICENSE file in the root directory of this source tree.
27
+ */const ke=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Me=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,a)=>a?a.toUpperCase():r.toLowerCase()),ne=e=>{const t=Me(e);return t.charAt(0).toUpperCase()+t.slice(1)},oe=(...e)=>e.filter((t,r,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===r).join(" ").trim(),_e=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};/**
28
+ * @license lucide-react v0.545.0 - ISC
29
+ *
30
+ * This source code is licensed under the ISC license.
31
+ * See the LICENSE file in the root directory of this source tree.
32
+ */var Se={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
33
+ * @license lucide-react v0.545.0 - ISC
34
+ *
35
+ * This source code is licensed under the ISC license.
36
+ * See the LICENSE file in the root directory of this source tree.
37
+ */const Ee=h.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:a,className:o="",children:c,iconNode:l,...i},u)=>h.createElement("svg",{ref:u,...Se,width:t,height:t,stroke:e,strokeWidth:a?Number(r)*24/Number(t):r,className:oe("lucide",o),...!c&&!_e(i)&&{"aria-hidden":"true"},...i},[...l.map(([m,p])=>h.createElement(m,p)),...Array.isArray(c)?c:[c]]));/**
38
+ * @license lucide-react v0.545.0 - ISC
39
+ *
40
+ * This source code is licensed under the ISC license.
41
+ * See the LICENSE file in the root directory of this source tree.
42
+ */const k=(e,t)=>{const r=h.forwardRef(({className:a,...o},c)=>h.createElement(Ee,{ref:c,iconNode:t,className:oe(`lucide-${ke(ne(e))}`,`lucide-${e}`,a),...o}));return r.displayName=ne(e),r};/**
43
+ * @license lucide-react v0.545.0 - ISC
44
+ *
45
+ * This source code is licensed under the ISC license.
46
+ * See the LICENSE file in the root directory of this source tree.
47
+ */const Pe=[["path",{d:"M6 5h12",key:"fvfigv"}],["path",{d:"M4 12h10",key:"oujl3d"}],["path",{d:"M12 19h8",key:"baeox8"}]],Re=k("chart-no-axes-gantt",Pe);/**
48
+ * @license lucide-react v0.545.0 - ISC
49
+ *
50
+ * This source code is licensed under the ISC license.
51
+ * See the LICENSE file in the root directory of this source tree.
52
+ */const Ce=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],De=k("message-circle",Ce);/**
53
+ * @license lucide-react v0.545.0 - ISC
54
+ *
55
+ * This source code is licensed under the ISC license.
56
+ * See the LICENSE file in the root directory of this source tree.
57
+ */const Ae=[["path",{d:"M5 12h14",key:"1ays0h"}]],Oe=k("minus",Ae);/**
58
+ * @license lucide-react v0.545.0 - ISC
59
+ *
60
+ * This source code is licensed under the ISC license.
61
+ * See the LICENSE file in the root directory of this source tree.
62
+ */const Ie=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],Fe=k("package",Ie);/**
63
+ * @license lucide-react v0.545.0 - ISC
64
+ *
65
+ * This source code is licensed under the ISC license.
66
+ * See the LICENSE file in the root directory of this source tree.
67
+ */const We=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],$e=k("plus",We);/**
68
+ * @license lucide-react v0.545.0 - ISC
69
+ *
70
+ * This source code is licensed under the ISC license.
71
+ * See the LICENSE file in the root directory of this source tree.
72
+ */const Le=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],Ye=k("radio",Le);/**
73
+ * @license lucide-react v0.545.0 - ISC
74
+ *
75
+ * This source code is licensed under the ISC license.
76
+ * See the LICENSE file in the root directory of this source tree.
77
+ */const Ve=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],ze=k("scroll-text",Ve);/**
78
+ * @license lucide-react v0.545.0 - ISC
79
+ *
80
+ * This source code is licensed under the ISC license.
81
+ * See the LICENSE file in the root directory of this source tree.
82
+ */const qe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Ge=k("search",qe);/**
83
+ * @license lucide-react v0.545.0 - ISC
84
+ *
85
+ * This source code is licensed under the ISC license.
86
+ * See the LICENSE file in the root directory of this source tree.
87
+ */const Xe=[["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Be=k("trash",Xe);/**
88
+ * @license lucide-react v0.545.0 - ISC
89
+ *
90
+ * This source code is licensed under the ISC license.
91
+ * See the LICENSE file in the root directory of this source tree.
92
+ */const Je=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ie=k("x",Je),re=e=>{let t;const r=new Set,a=(m,p)=>{const y=typeof m=="function"?m(t):m;if(!Object.is(y,t)){const x=t;t=p??(typeof y!="object"||y===null)?y:Object.assign({},t,y),r.forEach(j=>j(t,x))}},o=()=>t,i={setState:a,getState:o,getInitialState:()=>u,subscribe:m=>(r.add(m),()=>r.delete(m))},u=t=e(a,o,i);return i},Ue=e=>e?re(e):re,He=e=>e;function Qe(e,t=He){const r=h.useSyncExternalStore(e.subscribe,h.useCallback(()=>t(e.getState()),[e,t]),h.useCallback(()=>t(e.getInitialState()),[e,t]));return h.useDebugValue(r),r}const Ze=e=>{const t=Ue(e),r=a=>Qe(t,a);return Object.assign(r,t),r},Ke=e=>Ze,F=Ke()(e=>({selectedTraceGroupId:void 0,selectedTraceId:void 0,selectTraceGroupId:t=>e({selectedTraceGroupId:t}),selectTraceId:t=>e({selectedTraceId:t})})),et=e=>{const t=e?.endTime,[r,a]=h.useState(t||Date.now());return h.useEffect(()=>{if(t)a(t);else{const o=setInterval(()=>a(Date.now()),50);return()=>clearInterval(o)}},[t]),r},_=e=>e==null?"N/A":e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:e<36e5?`${(e/6e4).toFixed(1)}min`:`${(e/36e5).toFixed(1)}h`,tt=({trace:e,group:t,groupEndTime:r,onExpand:a})=>n.jsxs("div",{className:"flex hover:bg-muted-foreground/10 relative cursor-pointer",onClick:()=>a(e.id),"data-testid":"trace-timeline-item",children:[n.jsx("div",{className:"flex items-center min-w-[200px] max-w-[200px] h-[32px] max-h-[32px] py-4 px-2 text-sm font-semibold text-foreground truncate sticky left-0 bg-card z-9",children:e.name}),n.jsx("div",{className:"flex w-full flex-row items-center hover:bg-muted/50 rounded-md",children:n.jsx("div",{className:"relative w-full h-[32px] flex items-center",children:n.jsx("div",{className:w.cn("h-[24px] rounded-[4px] hover:opacity-80 transition-all duration-200",{"bg-[repeating-linear-gradient(140deg,#BEFE29,#BEFE29_8px,#ABE625_8px,#ABE625_16px)]":e.status==="running","bg-[repeating-linear-gradient(140deg,#2862FE,#2862FE_8px,#2358E5_8px,#2358E5_16px)]":e.status==="completed","bg-[repeating-linear-gradient(140deg,#EA2069,#EA2069_8px,#D41E60_8px,#D41E60_16px)]":e.status==="failed"}),style:{marginLeft:`${(e.startTime-t.startTime)/(r-t.startTime)*100}%`,width:e.endTime?`${(e.endTime-e.startTime)/(r-t.startTime)*100}%`:`${(Date.now()-e.startTime)/(r-t.startTime)*100}%`}})})})]}),nt=({event:e})=>{if(e.type==="log")return n.jsx(ze,{className:"w-4 h-4 text-muted-foreground"});if(e.type==="emit")return n.jsx(De,{className:"w-4 h-4 text-muted-foreground"});if(e.type==="state")return n.jsx(Fe,{className:"w-4 h-4 text-muted-foreground"});if(e.type==="stream")return n.jsx(Ye,{className:"w-4 h-4 text-muted-foreground"})},ce=({arg:e})=>{if(typeof e=="string")return n.jsxs("span",{className:"font-mono text-blue-500",children:["'",e,"'"]});if(e===!1)return n.jsx("span",{className:"font-mono text-blue-100 font-bold bg-blue-500/50 px-2 rounded-md",children:"value"});const t=Object.entries(e);return n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"font-mono text-green-500",children:"{ "}),t.map(([r,a],o)=>n.jsxs("span",{children:[n.jsx("span",{className:"font-mono text-green-500",children:r}),n.jsx("span",{className:"font-mono text-muted-foreground",children:":"})," ",n.jsx(ce,{arg:a}),o<t.length-1&&n.jsx(n.Fragment,{children:", "})]},r)),n.jsx("span",{className:"font-mono text-green-500",children:" }"})]})},G=({topLevelClassName:e,objectName:t,functionName:r,args:a,callsQuantity:o})=>{const c=o&&o>1,l=a.filter(i=>i!==void 0);return n.jsxs("div",{children:[e&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"font-mono text-pink-500",children:e}),"."]}),t&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"font-mono text-pink-500",children:t}),"."]}),n.jsx("span",{className:"font-mono text-pink-500",children:r}),n.jsx("span",{className:"font-mono text-emerald-500",children:"("}),l.map((i,u)=>n.jsxs("span",{children:[n.jsx(ce,{arg:i}),u<l.length-1&&n.jsx(n.Fragment,{children:", "})]},u)),n.jsx("span",{className:"font-mono text-emerald-500",children:")"}),c&&n.jsxs("span",{className:"font-mono text-muted-foreground",children:[" x",o]})]})},rt=({event:e})=>n.jsx(G,{functionName:"emit",args:[{topic:e.topic,data:!1}]}),at=({event:e})=>n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(w.LevelDot,{level:e.level})," ",e.message]}),st=({event:e})=>n.jsx(G,{objectName:"state",functionName:e.operation,args:[e.data.traceId,e.data.key,e.data.value?!1:void 0]}),ot=({event:e})=>n.jsx(G,{topLevelClassName:"streams",objectName:e.streamName,functionName:e.operation,args:[e.data.groupId,e.data.id,e.data.data?!1:void 0],callsQuantity:e.calls}),it=h.memo(({event:e})=>{if(e.type==="log")return n.jsx(at,{event:e});if(e.type==="emit")return n.jsx(rt,{event:e});if(e.type==="state")return n.jsx(st,{event:e});if(e.type==="stream")return n.jsx(ot,{event:e})}),ct=h.memo(({trace:e,onClose:t})=>n.jsxs(w.Sidebar,{onClose:t,title:"Trace Details",subtitle:`Viewing details from step ${e.name}`,actions:[{icon:n.jsx(ie,{}),onClick:t,label:"Close"}],children:[n.jsxs("div",{className:"px-2 w-[800px] overflow-auto",children:[n.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground mb-4",children:[e.endTime&&n.jsxs("span",{children:["Duration: ",_(e.endTime-e.startTime)]}),n.jsx("div",{className:"bg-blue-500 font-bold text-xs px-[4px] py-[2px] rounded-sm text-blue-100",children:e.entryPoint.type}),e.correlationId&&n.jsxs(w.Badge,{variant:"outline",children:["Correlated: ",e.correlationId]})]}),n.jsx("div",{className:"pl-6 border-l-1 border-gray-500/40 font-mono text-xs flex flex-col gap-3",children:e.events.map((r,a)=>n.jsxs("div",{className:"relative",children:[n.jsx("div",{className:"absolute -left-[26px] top-[8px] w-1 h-1 rounded-full bg-emerald-500 outline outline-2 outline-emerald-500/50"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(nt,{event:r}),n.jsxs("span",{className:"text-sm font-mono text-muted-foreground",children:["+",_(Math.floor(r.timestamp-e.startTime))]}),n.jsx(it,{event:r})]})]},a))})]}),e.error&&n.jsxs("div",{className:"p-4 bg-red-800/10",children:[n.jsx("div",{className:"text-sm text-red-800 dark:text-red-400 font-semibold",children:e.error.message}),n.jsx("div",{className:"text-sm text-red-800 dark:text-red-400 pl-4",children:e.error.stack})]})]})),lt=h.memo(({groupId:e})=>{const{data:t}=q.useStreamItem({streamName:"motia-trace-group",groupId:"default",id:e}),{data:r}=q.useStreamGroup({streamName:"motia-trace",groupId:e}),a=et(t),[o,c]=h.useState(1),l=F(p=>p.selectedTraceId),i=F(p=>p.selectTraceId),u=h.useMemo(()=>r?.find(p=>p.id===l),[r,l]),m=()=>{o>.5&&c(o-.1)};return t?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"flex flex-col flex-1 overflow-x-auto h-full relative",children:n.jsxs("div",{className:"flex flex-col items-center min-w-full sticky top-0",style:{width:`${o*1e3}px`},children:[n.jsxs("div",{className:"flex flex-1 w-full sticky top-0 bg-background z-10",children:[n.jsxs("div",{className:"w-full min-h-[37px] h-[37px] min-w-[200px] max-w-[200px] flex items-center justify-center gap-2 sticky left-0 top-0 bg-card backdrop-blur-[4px] backdrop-filter",children:[n.jsx(w.Button,{variant:"icon",size:"sm",className:"px-2",onClick:m,children:n.jsx(Oe,{className:"w-4 h-4 cursor-pointer"})}),n.jsxs("span",{className:"text-sm font-bold text-muted-foreground",children:[Math.floor(o*100),"%"]}),n.jsx(w.Button,{variant:"icon",size:"sm",className:"px-2",onClick:()=>c(o+.1),children:n.jsx($e,{className:"w-4 h-4 cursor-pointer"})})]}),n.jsxs("div",{className:"flex justify-between font-mono p-2 w-full text-xs text-muted-foreground bg-card",children:[n.jsx("span",{children:_(0)}),n.jsx("span",{children:_(Math.floor((a-t.startTime)*.25))}),n.jsx("span",{children:_(Math.floor((a-t.startTime)*.5))}),n.jsx("span",{children:_(Math.floor((a-t.startTime)*.75))}),n.jsx("span",{children:_(Math.floor(a-t.startTime))}),n.jsxs("div",{className:"absolute bottom-[-4px] w-full flex justify-between",children:[n.jsx("span",{className:"w-[1px] h-full bg-blue-500"}),n.jsx("span",{className:"w-[1px] h-full bg-blue-500"}),n.jsx("span",{className:"w-[1px] h-full bg-blue-500"}),n.jsx("span",{className:"w-[1px] h-full bg-blue-500"}),n.jsx("span",{className:"w-[1px] h-full bg-blue-500"})]})]})]}),n.jsx("div",{className:"flex flex-col w-full h-full",children:r?.map(p=>n.jsx(tt,{trace:p,group:t,groupEndTime:a,onExpand:i},p.id))})]})}),u&&n.jsx(ct,{trace:u,onClose:()=>i(void 0)})]}):null});function b(e){const t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function dt(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}const O=43200,ae=1440;let ut={};function mt(){return ut}function se(e){const t=b(e),r=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return r.setUTCFullYear(t.getFullYear()),+e-+r}function I(e,t){const r=b(e),a=b(t),o=r.getTime()-a.getTime();return o<0?-1:o>0?1:o}function ft(e){return dt(e,Date.now())}function ht(e,t){const r=b(e),a=b(t),o=r.getFullYear()-a.getFullYear(),c=r.getMonth()-a.getMonth();return o*12+c}function xt(e){return t=>{const r=Math.trunc,a=r(t);return a===0?0:a}}function pt(e,t){return+b(e)-+b(t)}function bt(e){const t=b(e);return t.setHours(23,59,59,999),t}function gt(e){const t=b(e),r=t.getMonth();return t.setFullYear(t.getFullYear(),r+1,0),t.setHours(23,59,59,999),t}function vt(e){const t=b(e);return+bt(t)==+gt(t)}function yt(e,t){const r=b(e),a=b(t),o=I(r,a),c=Math.abs(ht(r,a));let l;if(c<1)l=0;else{r.getMonth()===1&&r.getDate()>27&&r.setDate(30),r.setMonth(r.getMonth()-o*c);let i=I(r,a)===-o;vt(b(e))&&c===1&&I(e,a)===1&&(i=!1),l=o*(c-Number(i))}return l===0?0:l}function jt(e,t,r){const a=pt(e,t)/1e3;return xt()(a)}const wt={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},Nt=(e,t,r)=>{let a;const o=wt[e];return typeof o=="string"?a=o:t===1?a=o.one:a=o.other.replace("{{count}}",t.toString()),r?.addSuffix?r.comparison&&r.comparison>0?"in "+a:a+" ago":a};function z(e){return(t={})=>{const r=t.width?String(t.width):e.defaultWidth;return e.formats[r]||e.formats[e.defaultWidth]}}const Tt={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},kt={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Mt={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},_t={date:z({formats:Tt,defaultWidth:"full"}),time:z({formats:kt,defaultWidth:"full"}),dateTime:z({formats:Mt,defaultWidth:"full"})},St={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Et=(e,t,r,a)=>St[e];function C(e){return(t,r)=>{const a=r?.context?String(r.context):"standalone";let o;if(a==="formatting"&&e.formattingValues){const l=e.defaultFormattingWidth||e.defaultWidth,i=r?.width?String(r.width):l;o=e.formattingValues[i]||e.formattingValues[l]}else{const l=e.defaultWidth,i=r?.width?String(r.width):e.defaultWidth;o=e.values[i]||e.values[l]}const c=e.argumentCallback?e.argumentCallback(t):t;return o[c]}}const Pt={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Rt={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Ct={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Dt={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},At={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Ot={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},It=(e,t)=>{const r=Number(e),a=r%100;if(a>20||a<10)switch(a%10){case 1:return r+"st";case 2:return r+"nd";case 3:return r+"rd"}return r+"th"},Ft={ordinalNumber:It,era:C({values:Pt,defaultWidth:"wide"}),quarter:C({values:Rt,defaultWidth:"wide",argumentCallback:e=>e-1}),month:C({values:Ct,defaultWidth:"wide"}),day:C({values:Dt,defaultWidth:"wide"}),dayPeriod:C({values:At,defaultWidth:"wide",formattingValues:Ot,defaultFormattingWidth:"wide"})};function D(e){return(t,r={})=>{const a=r.width,o=a&&e.matchPatterns[a]||e.matchPatterns[e.defaultMatchWidth],c=t.match(o);if(!c)return null;const l=c[0],i=a&&e.parsePatterns[a]||e.parsePatterns[e.defaultParseWidth],u=Array.isArray(i)?$t(i,y=>y.test(l)):Wt(i,y=>y.test(l));let m;m=e.valueCallback?e.valueCallback(u):u,m=r.valueCallback?r.valueCallback(m):m;const p=t.slice(l.length);return{value:m,rest:p}}}function Wt(e,t){for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t(e[r]))return r}function $t(e,t){for(let r=0;r<e.length;r++)if(t(e[r]))return r}function Lt(e){return(t,r={})=>{const a=t.match(e.matchPattern);if(!a)return null;const o=a[0],c=t.match(e.parsePattern);if(!c)return null;let l=e.valueCallback?e.valueCallback(c[0]):c[0];l=r.valueCallback?r.valueCallback(l):l;const i=t.slice(o.length);return{value:l,rest:i}}}const Yt=/^(\d+)(th|st|nd|rd)?/i,Vt=/\d+/i,zt={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},qt={any:[/^b/i,/^(a|c)/i]},Gt={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Xt={any:[/1/i,/2/i,/3/i,/4/i]},Bt={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Jt={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},Ut={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Ht={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Qt={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Zt={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Kt={ordinalNumber:Lt({matchPattern:Yt,parsePattern:Vt,valueCallback:e=>parseInt(e,10)}),era:D({matchPatterns:zt,defaultMatchWidth:"wide",parsePatterns:qt,defaultParseWidth:"any"}),quarter:D({matchPatterns:Gt,defaultMatchWidth:"wide",parsePatterns:Xt,defaultParseWidth:"any",valueCallback:e=>e+1}),month:D({matchPatterns:Bt,defaultMatchWidth:"wide",parsePatterns:Jt,defaultParseWidth:"any"}),day:D({matchPatterns:Ut,defaultMatchWidth:"wide",parsePatterns:Ht,defaultParseWidth:"any"}),dayPeriod:D({matchPatterns:Qt,defaultMatchWidth:"any",parsePatterns:Zt,defaultParseWidth:"any"})},en={code:"en-US",formatDistance:Nt,formatLong:_t,formatRelative:Et,localize:Ft,match:Kt,options:{weekStartsOn:0,firstWeekContainsDate:1}};function tn(e,t,r){const a=mt(),o=r?.locale??a.locale??en,c=2520,l=I(e,t);if(isNaN(l))throw new RangeError("Invalid time value");const i=Object.assign({},r,{addSuffix:r?.addSuffix,comparison:l});let u,m;l>0?(u=b(t),m=b(e)):(u=b(e),m=b(t));const p=jt(m,u),y=(se(m)-se(u))/1e3,x=Math.round((p-y)/60);let j;if(x<2)return x===0?o.formatDistance("lessThanXMinutes",1,i):o.formatDistance("xMinutes",x,i);if(x<45)return o.formatDistance("xMinutes",x,i);if(x<90)return o.formatDistance("aboutXHours",1,i);if(x<ae){const N=Math.round(x/60);return o.formatDistance("aboutXHours",N,i)}else{if(x<c)return o.formatDistance("xDays",1,i);if(x<O){const N=Math.round(x/ae);return o.formatDistance("xDays",N,i)}else if(x<O*2)return j=Math.round(x/O),o.formatDistance("aboutXMonths",j,i)}if(j=yt(m,u),j<12){const N=Math.round(x/O);return o.formatDistance("xMonths",N,i)}else{const N=j%12,S=Math.trunc(j/12);return N<3?o.formatDistance("aboutXYears",S,i):N<9?o.formatDistance("overXYears",S,i):o.formatDistance("almostXYears",S+1,i)}}function nn(e,t){return tn(e,ft(e),t)}const rn=({status:e,duration:t})=>{const r=h.useMemo(()=>e==="running"?"info":e==="completed"?"success":e==="failed"?"error":"default",[e]);return n.jsx(w.Badge,{variant:r,children:t&&e!=="failed"?t:e})},an=h.memo(({groups:e,selectedGroupId:t,onGroupSelect:r})=>n.jsx("div",{className:"overflow-auto",children:e.length>0&&n.jsx("div",{children:[...e].reverse().map(a=>n.jsx("div",{"data-testid":`trace-${a.id}`,className:w.cn("motia-trace-group cursor-pointer transition-colors",t===a.id?"bg-muted-foreground/10":"hover:bg-muted/70"),onClick:()=>r(a),children:n.jsxs("div",{className:"p-3 flex flex-col gap-1",children:[n.jsxs("div",{className:"flex flex-row justify-between items-center gap-2",children:[n.jsx("span",{className:"font-semibold text-lg",children:a.name}),n.jsx(rn,{status:a.status,duration:a.endTime?_(a.endTime-a.startTime):void 0})]}),n.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[n.jsxs("div",{className:"flex justify-between",children:[n.jsx("div",{"data-testid":"trace-id",className:"text-xs text-muted-foreground font-mono tracking-[1px]",children:a.id}),n.jsxs("span",{children:[a.metadata.totalSteps," steps"]})]}),n.jsxs("div",{className:"flex justify-between",children:[nn(a.startTime)," ago"]}),a.metadata.activeSteps>0&&n.jsxs("div",{className:"text-blue-600",children:[a.metadata.activeSteps," active"]})]})]})},a.id))})})),sn=()=>{const e=F(u=>u.selectedTraceGroupId),t=F(u=>u.selectTraceGroupId),{data:r}=q.useStreamGroup({streamName:"motia-trace-group",groupId:"default"}),a=u=>t(u.id),[o,c]=h.useState(""),l=()=>fetch("/__motia/trace/clear",{method:"POST"}),i=h.useMemo(()=>r?.filter(u=>u.name.toLowerCase().includes(o.toLowerCase())||u.id.toLowerCase().includes(o.toLowerCase())),[r,o]);return h.useEffect(()=>{if(i&&i.length>0){const u=i[i.length-1];u&&u.status==="running"&&u.id!==e&&t(u.id)}else e&&t(void 0)},[i]),n.jsxs("div",{className:"grid grid-rows-[auto_1fr] h-full",children:[n.jsxs("div",{className:"flex p-2 border-b gap-2","data-testid":"logs-search-container",children:[n.jsxs("div",{className:"flex-1 relative",children:[n.jsx(w.Input,{variant:"shade",value:o,onChange:u=>c(u.target.value),className:"px-9 font-medium",placeholder:"Search by Trace ID or Step Name"}),n.jsx(Ge,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground/50"}),n.jsx(ie,{className:w.cn("cursor-pointer absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground/50 hover:text-muted-foreground",{visible:o!=="",invisible:o===""}),onClick:()=>c("")})]}),n.jsxs(w.Button,{variant:"default",onClick:l,className:"h-[34px]",children:[n.jsx(Be,{})," Clear"]})]}),n.jsxs("div",{className:"grid grid-cols-[300px_1fr] overflow-hidden",children:[n.jsx("div",{className:"w-[300px] border-r border-border overflow-auto h-full","data-testid":"traces-container",children:n.jsx(an,{groups:i,selectedGroupId:e,onGroupSelect:a})}),n.jsxs("div",{className:"overflow-auto","data-testid":"trace-details",children:[e&&n.jsx(lt,{groupId:e}),!e&&n.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:"Select a trace or trace group to view the timeline"})]})]})]})},le=h.memo(()=>n.jsxs(n.Fragment,{children:[n.jsx(Re,{"aria-hidden":"true"}),n.jsx("span",{children:"Tracing"})]}));le.displayName="ObservabilityTabLabel";exports.ObservabilityPage=sn;exports.ObservabilityTabLabel=le;