"use strict";var l=/^00-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/,c=/^[0-9a-f]{32}$/,i=/^[0-9a-f]{16}$/;function f(t){if(!t||!t.traceId||!t.spanId)return null;let{traceId:e,spanId:r}=t;if(!c.test(e)||!i.test(r)||/^0+$/.test(e)||/^0+$/.test(r))return null;let n=t.traceFlags,a=("number"==typeof n&&Number.isInteger(n)&&n>=0&&n<=255?n:1).toString(16).padStart(2,"0");return`00-${e}-${r}-${a}`}function u(t){if(!t||"string"!=typeof t)return null;let e=t.match(l);if(!e)return null;let[,r,n,a]=e;return/^0+$/.test(r)||/^0+$/.test(n)?null:{traceId:r,spanId:n,traceFlags:parseInt(a,16),isRemote:!0}}module.exports={serializeContext:f,deserializeContext:u};