@lostgradient/weft 0.6.0 → 0.7.0
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.
- package/README.md +4 -4
- package/dist/cli/generated/operation-client.generated.d.ts +1 -0
- package/dist/cli-main.js +63 -63
- package/dist/client/event-stream-options.d.ts +58 -0
- package/dist/client/event-stream-options.js +0 -0
- package/dist/client/event-stream.d.ts +27 -44
- package/dist/client/event-stream.js +21 -56
- package/dist/client/event-tail-lifecycle.d.ts +21 -0
- package/dist/client/event-tail-lifecycle.js +71 -0
- package/dist/client/event-tail.d.ts +3 -1
- package/dist/client/http-client.d.ts +4 -5
- package/dist/client/http-client.js +4 -1
- package/dist/client/http-handle.d.ts +4 -5
- package/dist/client/http-request.d.ts +7 -0
- package/dist/client/index.d.ts +2 -1
- package/dist/client/interface.d.ts +23 -7
- package/dist/client/local-handles.d.ts +2 -0
- package/dist/client/local-handles.js +10 -1
- package/dist/client/local.d.ts +3 -3
- package/dist/client/open-event-subscription.d.ts +3 -2
- package/dist/client/open-event-subscription.js +28 -1
- package/dist/client/sse-event-stream.d.ts +27 -0
- package/dist/client/sse-event-stream.js +276 -0
- package/dist/client/start-body.d.ts +2 -2
- package/dist/client/start-body.js +1 -0
- package/dist/core/engine/construction.js +3 -1
- package/dist/core/engine/engine-internal-types.d.ts +2 -0
- package/dist/core/engine/errors.d.ts +6 -6
- package/dist/core/engine/errors.js +1 -1
- package/dist/core/engine/handles.js +1 -1
- package/dist/core/engine/index.d.ts +6 -5
- package/dist/core/engine/index.js +1 -0
- package/dist/core/engine/lifecycle/recovered-services.js +8 -1
- package/dist/core/engine/lifecycle/start-or-signal-create.d.ts +2 -2
- package/dist/core/engine/lifecycle/start-or-signal-create.js +17 -15
- package/dist/core/engine/lifecycle/start-or-signal-resolution.d.ts +1 -1
- package/dist/core/engine/lifecycle/start-or-signal-resolution.js +23 -5
- package/dist/core/engine/lifecycle/start-or-signal.d.ts +6 -4
- package/dist/core/engine/lifecycle/start-or-signal.js +21 -4
- package/dist/core/engine/schedule-run.js +12 -3
- package/dist/core/engine/storage-io.js +1 -1
- package/dist/core/engine/termination/complete.js +3 -3
- package/dist/core/scheduler/scheduler-class.js +2 -1
- package/dist/core/start-workflow-validation.d.ts +3 -4
- package/dist/core/start-workflow-validation.js +1 -1
- package/dist/core/timeouts.d.ts +13 -1
- package/dist/core/timeouts.js +4 -1
- package/dist/core/types/constants.d.ts +16 -0
- package/dist/core/types/options.d.ts +60 -12
- package/dist/core/types/services-resolution.d.ts +49 -3
- package/dist/core/weft-error.d.ts +1 -1
- package/dist/core/weft-error.js +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -0
- package/dist/json-schema.js +1 -1
- package/dist/mcp/cli.js +17 -17
- package/dist/server/asyncapi-channels.js +82 -16
- package/dist/server/handler/auth-context-principal.d.ts +19 -0
- package/dist/server/handler/auth-context-principal.js +25 -0
- package/dist/server/handler/index.d.ts +2 -1
- package/dist/server/handler/index.js +35 -18
- package/dist/server/handler/route-dispatch.d.ts +12 -22
- package/dist/server/handler/route-dispatch.js +30 -36
- package/dist/server/handler/sse-route-dispatch.d.ts +25 -0
- package/dist/server/handler/sse-route-dispatch.js +45 -0
- package/dist/server/handler.js +21 -21
- package/dist/server/index.d.ts +8 -7
- package/dist/server/index.js +15 -15
- package/dist/server/operations/fleet-events-sse.d.ts +11 -0
- package/dist/server/operations/fleet-events-sse.js +164 -0
- package/dist/server/operations/sse-stream.d.ts +43 -0
- package/dist/server/operations/sse-stream.js +152 -7
- package/dist/server/operations/start-or-signal-workflow.d.ts +2 -0
- package/dist/server/operations/start-or-signal-workflow.js +25 -14
- package/dist/server/operations/start-workflow-options.d.ts +9 -6
- package/dist/server/operations/start-workflow-options.js +13 -0
- package/dist/server/operations/workflow-events-sse.d.ts +17 -0
- package/dist/server/operations/workflow-events-sse.js +200 -0
- package/dist/server/rest-bindings.js +12 -0
- package/dist/server/runtime/authentication-bridge.js +4 -0
- package/dist/server/runtime/cors.d.ts +1 -1
- package/dist/server/runtime/cors.js +6 -1
- package/dist/server/runtime/websocket-stream.d.ts +4 -0
- package/dist/server/runtime/websocket-stream.js +20 -3
- package/dist/server/workflow-event-feed.d.ts +1 -0
- package/dist/server/workflow-event-feed.js +17 -6
- package/dist/service-worker/index.js +28 -28
- package/dist/storage/typed-storage.js +1 -1
- package/dist/testing/index.js +17 -17
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var r0=Object.defineProperty;var s0=($)=>$;function a0($,Z){this[$]=s0.bind(null,Z)}var Y1=($,Z)=>{for(var Q in Z)r0($,Q,{get:Z[Q],enumerable:!0,configurable:!0,set:a0.bind(Z,Q)})};var H=($,Z)=>()=>($&&(Z=$($=0)),Z);var V1=($,Z,Q)=>{if(Z!=null){if(typeof Z!=="object"&&typeof Z!=="function")throw TypeError('Object expected to be assigned to "using" declaration');let J;if(Q)J=Z[Symbol.asyncDispose];if(J===void 0)J=Z[Symbol.dispose];if(typeof J!=="function")throw TypeError("Object not disposable");$.push([Q,J,Z])}else if(Q)$.push([Q]);return Z},P1=($,Z,Q)=>{let J=(q)=>Z=Q?new SuppressedError(q,Z,"An error was suppressed during disposal"):(Q=!0,q),W=(q)=>{while(q=$.pop())try{var F=q[1]&&q[1].call(q[2]);if(q[0])return Promise.resolve(F).then(W,(K)=>(J(K),W()))}catch(K){J(K)}if(Q)throw Z};return W()};function v($,Z,Q){if(!$.capabilities()[Z])throw Error(`Feature "${Q}" requires storage capability "${Z}", but this storage backend does not provide it.`)}function o0($){let Z=$.capabilities(),Q=[];if(Z.persistence!=="local"&&Z.persistence!=="remote")Q.push(`persistence must be "local" or "remote" (got "${Z.persistence}")`);if(Z.readAfterWrite!=="linearizable")Q.push(`readAfterWrite must be "linearizable" (got "${Z.readAfterWrite}")`);if(Z.scanConsistency!=="snapshot")Q.push(`scanConsistency must be "snapshot" (got "${Z.scanConsistency}")`);if(!Z.atomicBatch)Q.push("atomicBatch must be true");if(!Z.conditionalBatch)Q.push("conditionalBatch must be true");if(Q.length>0)throw Error(`Storage is not durable enough for recovery: ${Q.join("; ")}.`)}var p="default";async function Q0($,Z){return await $.get(Z)!==null}async function*A($,Z,Q){for await(let[J]of $.scan(Z,Q))yield J}async function J0($,Z){let Q=0;for await(let J of A($,Z))Q++;return Q}async function W0($,Z){let Q=[];for await(let J of A($,Z))Q.push({type:"delete",key:J});if(Q.length===0)return 0;return await $.batch(Q),Q.length}async function G0($,Z,Q){let J=[];for await(let W of A($,Z,Q))J.push({type:"delete",key:W});if(J.length===0)return 0;return await $.batch(J),J.length}var t0;var q0=H(()=>{t0=["actrec:","archive:","async-act:","attr:","audit:bulk:","blob:","budget:","budget-charged:","ev:","fleet-event-by-workflow:","fleet-event:","fleet-event-tail","idx:","lease:","liveness:","offload:","op:","review:","schedule:","schedule-due:","schedule-run:","sig:","sigres:","sigseq:","start-idem:","state:","tag:","tool-effect:","upd:","upk:","upr:","wf:","wf-cleanup:","wf-cleanup-needed:","wf-concurrency:","wf-concurrency-holder:","wf-deadline:","wf-delayed:","wf-finalizer-state:","wf-has-services:","wf-headers:","wf-idx-","wf-teardown:","wf-teardown-deadletter:","wf-teardown-needed:","wf-terminal:"]});function z($,Z){if(Z>c)throw new K0($,Z)}function A1($){return $.length>0?$.slice(0,-1)+String.fromCharCode($.charCodeAt($.length-1)+1):"\xFF"}function z1($,Z={}){if(Z.gt!==void 0&&$<=Z.gt)return!1;if(Z.gte!==void 0&&$<Z.gte)return!1;if(Z.lt!==void 0&&$>=Z.lt)return!1;if(Z.lte!==void 0&&$>Z.lte)return!1;return!0}function T1($,Z){if($===null||Z===null)return $===Z;if($.byteLength!==Z.byteLength)return!1;for(let Q=0;Q<$.byteLength;Q++)if($[Q]!==Z[Q])return!1;return!0}async function H0($,Z){if($.has)return $.has(Z);return Q0($,Z)}function X0($,Z,Q){if($.keys)return $.keys(Z,Q);return A($,Z,Q)}async function Y0($,Z){if($.count)return $.count(Z);return J0($,Z)}async function V0($,Z){if($.deletePrefix)return $.deletePrefix(Z);return W0($,Z)}async function D1($,Z){z("batch operations",Z.length),await $.batch(Z)}async function P0($,Z,Q){if(z("conditionalBatch conditions",Z.length),z("conditionalBatch operations",Q.length),v($,"conditionalBatch","storageConditionalBatch"),!$.conditionalBatch)throw Error("This storage backend reports conditionalBatch capability but does not implement the conditionalBatch() method.");return $.conditionalBatch(Z,Q)}function G($){return encodeURIComponent($)}function L1($){return decodeURIComponent($)}function x1($){try{return decodeURIComponent($)}catch{return null}}var c=1e4,B1=1e4,K0,P=($)=>String($).padStart(16,"0"),e0="0",$$="1",F0=($,Z,Q,J)=>`sig:${G($)}:${G(Z)}:${J}:${G(Q)}`,I1;var N0=H(()=>{q0();K0=class K0 extends Error{code="StorageBatchOperationLimitExceededError";cap=c;count;target;constructor($,Z){super(`${$} count ${Z} exceeds MAX_BATCH_OPERATIONS (${c}).`);this.name="StorageBatchOperationLimitExceededError",this.target=$,this.count=Z}};I1={workflow:($)=>`wf:${G($)}`,checkpoint:($)=>`wf:${G($)}:ckpt`,checkpointHistory:($,Z)=>`wf:${G($)}:ckpt:${String(Z).padStart(10,"0")}`,timelinePrefix:($)=>`wf:${G($)}:timeline:`,timeline:($,Z)=>`wf:${G($)}:timeline:${String(Z).padStart(10,"0")}`,schedule:($)=>`schedule:${G($)}`,scheduleTick:($,Z)=>`schedule-due:${String($).padStart(16,"0")}:${G(Z)}`,scheduleRun:($)=>`schedule-run:${G($)}`,operation:($,Z,Q)=>`op:${$}:${P(Z)}:${Q}`,operationInflight:($)=>`op:inflight:${$}`,operationQueued:($)=>`op:queued:${$}`,operationResolved:($)=>`op:resolved:${$}`,operationDeadLetterPrefix:()=>"op:dead-letter:",operationDeadLetter:($)=>`op:dead-letter:${$}`,bulkOperationAuditPrefix:()=>"audit:bulk:",bulkOperationAudit:($,Z,Q)=>`audit:bulk:${P($)}:${G(Z)}:${G(Q)}`,operationResolvedByTimePrefix:()=>"op:resolved-by-time:",operationResolvedByTime:($,Z)=>`op:resolved-by-time:${P($)}:${G(Z)}`,asyncActivity:($,Z)=>`async-act:v1:${G($)}:${G(Z)}`,activityReconciliationPrefix:($)=>`actrec:v1:${G($)}:`,activityReconciliation:($,Z,Q)=>`actrec:v1:${G($)}:${G(Z)}:${Q}`,eventPrefix:($)=>`ev:${G($)}:`,event:($,Z)=>`ev:${G($)}:${String(Z).padStart(10,"0")}`,eventHead:($)=>`ev:${G($)}:head`,eventWatermark:($)=>`ev:${G($)}:watermark`,fleetEventPrefix:()=>"fleet-event:",fleetEvent:($)=>`fleet-event:${String($).padStart(10,"0")}`,fleetEventTail:()=>"fleet-event-tail",fleetEventByWorkflowPrefix:($)=>`fleet-event-by-workflow:${G($)}:`,fleetEventByWorkflow:($,Z)=>`fleet-event-by-workflow:${G($)}:${String(Z).padStart(10,"0")}`,signal:($,Z,Q)=>F0($,Z,Q,$$),startSignal:($,Z,Q)=>F0($,Z,Q,e0),signalSequence:($)=>`sigseq:v1:${G($)}`,signalAcceptedResponsePrefix:($)=>`sigres:v1:${G($)}:`,signalAcceptedResponse:($,Z,Q)=>`sigres:v1:${G($)}:${G(Z)}:${G(Q)}`,deadline:($,Z)=>`wf-deadline:${P($)}:${G(Z)}`,terminalCleanup:($,Z)=>`wf-cleanup:${P($)}:${G(Z)}`,teardownTimer:($,Z)=>`wf-teardown:${P($)}:${G(Z)}`,delayedStart:($,Z)=>`wf-delayed:${P($)}:${G(Z)}`,terminalWorkflowPrefix:()=>"wf-terminal:",terminalWorkflow:($,Z)=>`wf-terminal:${P($)}:${G(Z)}`,attribute:($)=>`attr:${G($)}`,attributeIndex:($,Z,Q)=>`idx:${$}:${Z}:${G(Q)}`,tagIndex:($,Z)=>`tag:${G($)}:${G(Z)}`,updatePrefix:($)=>`upd:${G($)}:`,update:($,Z)=>`upd:${G($)}:${Z}`,updateResponse:($)=>`upr:${$}`,updateIdempotency:($,Z)=>`upk:${G($)}:${Z}`,startIdempotency:($)=>`start-idem:${G($)}`,startIdempotencySignalId:($)=>`start-idem:${$}`,livenessPrefix:()=>"liveness:",liveness:($)=>`liveness:${G($)}`,leasePrefix:()=>"lease:",leaseEpoch:()=>"lease:epoch",leaseHolder:()=>"lease:holder",budget:($,Z,Q)=>`budget:${$}:${Z}:${Q}`,review:($,Z)=>`review:${G($)}:${Z}`,workflowHeaders:($)=>`wf-headers:${G($)}`,childCancellationPrefix:($)=>`child-cancel:${G($)}:`,childCancellation:($,Z)=>`child-cancel:${G($)}:${G(Z)}`,terminalCleanupNeeded:($)=>`wf-cleanup-needed:${G($)}`,workflowConcurrency:($,Z)=>`wf-concurrency:${G($)}:${G(Z)}`,workflowConcurrencyHolder:($)=>`wf-concurrency-holder:${G($)}`,workflowHasServices:($)=>`wf-has-services:${G($)}`,finalizerState:($)=>`wf-finalizer-state:${G($)}`,teardownOwed:($)=>`wf-teardown-needed:${G($)}`,teardownDeadLetter:($)=>`wf-teardown-deadletter:${G($)}`,offload:($,Z)=>`offload:${G($)}:${Z}`,archive:($,Z)=>`archive:${G($)}:${Z}`,stateExecution:($,Z)=>`state:execution:${G($)}:${G(Z)}`,stateWorkflow:($,Z)=>`state:workflow-scope:${p}:${G($)}:${G(Z)}`,streamChunkPrefix:($,Z)=>`blob:${G($)}:${Z}:chunk:`,streamChunk:($,Z,Q)=>`blob:${G($)}:${Z}:chunk:${String(Q).padStart(10,"0")}`,streamTail:($,Z)=>`blob:${G($)}:${Z}:tail`,streamMetadata:($,Z)=>`blob:${G($)}:${Z}:meta`,budgetCharged:($)=>`budget-charged:${$}`,toolEffect:($,Z,Q)=>`tool-effect:${G($)}:${Z}:${Q}`,workflowVisibilityStatus:($,Z)=>`wf-idx-status:${G($)}:${G(Z)}`,workflowVisibilityType:($,Z)=>`wf-idx-type:${G($)}:${G(Z)}`,workflowVisibilityCreated:($,Z)=>`wf-idx-created:${P($)}:${G(Z)}`,workflowVisibilityUpdated:($,Z)=>`wf-idx-updated:${P($)}:${G(Z)}`,workflowVisibilityDeadline:($,Z)=>`wf-idx-deadline:${P($)}:${G(Z)}`,workflowVisibilityManifest:($)=>`wf-idx-manifest:${G($)}`,workflowVisibilityMetaVersion:()=>"wf-idx-meta:version",workflowVisibilityMetaBuiltAt:()=>"wf-idx-meta:built-at",workflowVisibilityMetaCursor:()=>"wf-idx-meta:cursor"}});function M0($){let Z=$.length,Q=0,J=0;while(J<Z){let W=$.charCodeAt(J++);if((W&4294967168)===0){Q++;continue}else if((W&4294965248)===0)Q+=2;else{if(W>=55296&&W<=56319){if(J<Z){let q=$.charCodeAt(J);if((q&64512)===56320)++J,W=((W&1023)<<10)+(q&1023)+65536}}if((W&4294901760)===0)Q+=3;else Q+=4}}return Q}function Z$($,Z,Q){let J=$.length,W=Q,q=0;while(q<J){let F=$.charCodeAt(q++);if((F&4294967168)===0){Z[W++]=F;continue}else if((F&4294965248)===0)Z[W++]=F>>6&31|192;else{if(F>=55296&&F<=56319){if(q<J){let K=$.charCodeAt(q);if((K&64512)===56320)++q,F=((F&1023)<<10)+(K&1023)+65536}}if((F&4294901760)===0)Z[W++]=F>>12&15|224,Z[W++]=F>>6&63|128;else Z[W++]=F>>18&7|240,Z[W++]=F>>12&63|128,Z[W++]=F>>6&63|128}Z[W++]=F&63|128}}function W$($,Z,Q){Q$.encodeInto($,Z.subarray(Q))}function R0($,Z,Q){if($.length>J$)W$($,Z,Q);else Z$($,Z,Q)}function l($,Z,Q){let J=Z,W=J+Q,q=[],F="";while(J<W){let K=$[J++];if((K&128)===0)q.push(K);else if((K&224)===192){let B=$[J++]&63;q.push((K&31)<<6|B)}else if((K&240)===224){let B=$[J++]&63,f=$[J++]&63;q.push((K&31)<<12|B<<6|f)}else if((K&248)===240){let B=$[J++]&63,f=$[J++]&63,i0=$[J++]&63,U=(K&7)<<18|B<<12|f<<6|i0;if(U>65535)U-=65536,q.push(U>>>10&1023|55296),U=56320|U&1023;q.push(U)}else q.push(K);if(q.length>=G$)F+=String.fromCharCode(...q),q.length=0}if(q.length>0)F+=String.fromCharCode(...q);return F}function K$($,Z,Q){let J=$.subarray(Z,Z+Q);return q$.decode(J)}function U0($,Z,Q){if(Q>F$)return K$($,Z,Q);else return l($,Z,Q)}var Q$,J$=50,G$=4096,q$,F$=200;var I=H(()=>{Q$=new TextEncoder;q$=new TextDecoder});class S{type;data;constructor($,Z){this.type=$,this.data=Z}}var Y;var u=H(()=>{Y=class Y extends Error{constructor($){super($);let Z=Object.create(Y.prototype);Object.setPrototypeOf(this,Z),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:Y.name})}}});function S0($,Z,Q){let J=Q/4294967296,W=Q;$.setUint32(Z,J),$.setUint32(Z+4,W)}function k($,Z,Q){let J=Math.floor(Q/4294967296),W=Q;$.setUint32(Z,J),$.setUint32(Z+4,W)}function m($,Z){let Q=$.getInt32(Z),J=$.getUint32(Z+4);return Q*4294967296+J}function _0($,Z){let Q=$.getUint32(Z),J=$.getUint32(Z+4);return Q*4294967296+J}var _=4294967295;function V$({sec:$,nsec:Z}){if($>=0&&Z>=0&&$<=Y$)if(Z===0&&$<=X$){let Q=new Uint8Array(4);return new DataView(Q.buffer).setUint32(0,$),Q}else{let Q=$/4294967296,J=$&4294967295,W=new Uint8Array(8),q=new DataView(W.buffer);return q.setUint32(0,Z<<2|Q&3),q.setUint32(4,J),W}else{let Q=new Uint8Array(12),J=new DataView(Q.buffer);return J.setUint32(0,Z),k(J,4,$),Q}}function P$($){let Z=$.getTime(),Q=Math.floor(Z/1000),J=(Z-Q*1000)*1e6,W=Math.floor(J/1e9);return{sec:Q+W,nsec:J-W*1e9}}function N$($){if($ instanceof Date){let Z=P$($);return V$(Z)}else return null}function M$($){let Z=new DataView($.buffer,$.byteOffset,$.byteLength);switch($.byteLength){case 4:{let Q=Z.getUint32(0),J=0;return{sec:Q,nsec:0}}case 8:{let Q=Z.getUint32(0),J=Z.getUint32(4),W=(Q&3)*4294967296+J,q=Q>>>2;return{sec:W,nsec:q}}case 12:{let Q=m(Z,4),J=Z.getUint32(0);return{sec:Q,nsec:J}}default:throw new Y(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${$.length}`)}}function R$($){let Z=M$($);return new Date(Z.sec*1000+Z.nsec/1e6)}var H$=-1,X$=4294967295,Y$=17179869183,C0;var O0=H(()=>{u();C0={type:H$,encode:N$,decode:R$}});var R;var E=H(()=>{O0();R=class R{static defaultCodec=new R;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(C0)}register({type:$,encode:Z,decode:Q}){if($>=0)this.encoders[$]=Z,this.decoders[$]=Q;else{let J=-1-$;this.builtInEncoders[J]=Z,this.builtInDecoders[J]=Q}}tryToEncode($,Z){for(let Q=0;Q<this.builtInEncoders.length;Q++){let J=this.builtInEncoders[Q];if(J!=null){let W=J($,Z);if(W!=null){let q=-1-Q;return new S(q,W)}}}for(let Q=0;Q<this.encoders.length;Q++){let J=this.encoders[Q];if(J!=null){let W=J($,Z);if(W!=null)return new S(Q,W)}}if($ instanceof S)return $;return null}decode($,Z,Q){let J=Z<0?this.builtInDecoders[-1-Z]:this.decoders[Z];if(J)return J($,Z,Q);else return new S(Z,$)}}});function U$($){return $ instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&$ instanceof SharedArrayBuffer}function T($){if($ instanceof Uint8Array)return $;else if(ArrayBuffer.isView($))return new Uint8Array($.buffer,$.byteOffset,$.byteLength);else if(U$($))return new Uint8Array($);else return Uint8Array.from($)}class w{extensionCodec;context;useBigInt64;maxDepth;initialBufferSize;sortKeys;forceFloat32;ignoreUndefined;forceIntegerToFloat;pos;view;bytes;entered=!1;constructor($){this.extensionCodec=$?.extensionCodec??R.defaultCodec,this.context=$?.context,this.useBigInt64=$?.useBigInt64??!1,this.maxDepth=$?.maxDepth??S$,this.initialBufferSize=$?.initialBufferSize??_$,this.sortKeys=$?.sortKeys??!1,this.forceFloat32=$?.forceFloat32??!1,this.ignoreUndefined=$?.ignoreUndefined??!1,this.forceIntegerToFloat=$?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new w({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef($){if(this.entered)return this.clone().encodeSharedRef($);try{return this.entered=!0,this.reinitializeState(),this.doEncode($,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode($){if(this.entered)return this.clone().encode($);try{return this.entered=!0,this.reinitializeState(),this.doEncode($,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode($,Z){if(Z>this.maxDepth)throw Error(`Too deep objects in depth ${Z}`);if($==null)this.encodeNil();else if(typeof $==="boolean")this.encodeBoolean($);else if(typeof $==="number")if(!this.forceIntegerToFloat)this.encodeNumber($);else this.encodeNumberAsFloat($);else if(typeof $==="string")this.encodeString($);else if(this.useBigInt64&&typeof $==="bigint")this.encodeBigInt64($);else this.encodeObject($,Z)}ensureBufferSizeToWrite($){let Z=this.pos+$;if(this.view.byteLength<Z)this.resizeBuffer(Z*2)}resizeBuffer($){let Z=new ArrayBuffer($),Q=new Uint8Array(Z),J=new DataView(Z);Q.set(this.bytes),this.view=J,this.bytes=Q}encodeNil(){this.writeU8(192)}encodeBoolean($){if($===!1)this.writeU8(194);else this.writeU8(195)}encodeNumber($){if(!this.forceIntegerToFloat&&Number.isSafeInteger($))if($>=0)if($<128)this.writeU8($);else if($<256)this.writeU8(204),this.writeU8($);else if($<65536)this.writeU8(205),this.writeU16($);else if($<4294967296)this.writeU8(206),this.writeU32($);else if(!this.useBigInt64)this.writeU8(207),this.writeU64($);else this.encodeNumberAsFloat($);else if($>=-32)this.writeU8(224|$+32);else if($>=-128)this.writeU8(208),this.writeI8($);else if($>=-32768)this.writeU8(209),this.writeI16($);else if($>=-2147483648)this.writeU8(210),this.writeI32($);else if(!this.useBigInt64)this.writeU8(211),this.writeI64($);else this.encodeNumberAsFloat($);else this.encodeNumberAsFloat($)}encodeNumberAsFloat($){if(this.forceFloat32)this.writeU8(202),this.writeF32($);else this.writeU8(203),this.writeF64($)}encodeBigInt64($){if($>=BigInt(0))this.writeU8(207),this.writeBigUint64($);else this.writeU8(211),this.writeBigInt64($)}writeStringHeader($){if($<32)this.writeU8(160+$);else if($<256)this.writeU8(217),this.writeU8($);else if($<65536)this.writeU8(218),this.writeU16($);else if($<4294967296)this.writeU8(219),this.writeU32($);else throw Error(`Too long string: ${$} bytes in UTF-8`)}encodeString($){let Q=M0($);this.ensureBufferSizeToWrite(5+Q),this.writeStringHeader(Q),R0($,this.bytes,this.pos),this.pos+=Q}encodeObject($,Z){let Q=this.extensionCodec.tryToEncode($,this.context);if(Q!=null)this.encodeExtension(Q);else if(Array.isArray($))this.encodeArray($,Z);else if(ArrayBuffer.isView($))this.encodeBinary($);else if(typeof $==="object")this.encodeMap($,Z);else throw Error(`Unrecognized object: ${Object.prototype.toString.apply($)}`)}encodeBinary($){let Z=$.byteLength;if(Z<256)this.writeU8(196),this.writeU8(Z);else if(Z<65536)this.writeU8(197),this.writeU16(Z);else if(Z<4294967296)this.writeU8(198),this.writeU32(Z);else throw Error(`Too large binary: ${Z}`);let Q=T($);this.writeU8a(Q)}encodeArray($,Z){let Q=$.length;if(Q<16)this.writeU8(144+Q);else if(Q<65536)this.writeU8(220),this.writeU16(Q);else if(Q<4294967296)this.writeU8(221),this.writeU32(Q);else throw Error(`Too large array: ${Q}`);for(let J of $)this.doEncode(J,Z+1)}countWithoutUndefined($,Z){let Q=0;for(let J of Z)if($[J]!==void 0)Q++;return Q}encodeMap($,Z){let Q=Object.keys($);if(this.sortKeys)Q.sort();let J=this.ignoreUndefined?this.countWithoutUndefined($,Q):Q.length;if(J<16)this.writeU8(128+J);else if(J<65536)this.writeU8(222),this.writeU16(J);else if(J<4294967296)this.writeU8(223),this.writeU32(J);else throw Error(`Too large map object: ${J}`);for(let W of Q){let q=$[W];if(!(this.ignoreUndefined&&q===void 0))this.encodeString(W),this.doEncode(q,Z+1)}}encodeExtension($){if(typeof $.data==="function"){let Q=$.data(this.pos+6),J=Q.length;if(J>=4294967296)throw Error(`Too large extension object: ${J}`);this.writeU8(201),this.writeU32(J),this.writeI8($.type),this.writeU8a(Q);return}let Z=$.data.length;if(Z===1)this.writeU8(212);else if(Z===2)this.writeU8(213);else if(Z===4)this.writeU8(214);else if(Z===8)this.writeU8(215);else if(Z===16)this.writeU8(216);else if(Z<256)this.writeU8(199),this.writeU8(Z);else if(Z<65536)this.writeU8(200),this.writeU16(Z);else if(Z<4294967296)this.writeU8(201),this.writeU32(Z);else throw Error(`Too large extension object: ${Z}`);this.writeI8($.type),this.writeU8a($.data)}writeU8($){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,$),this.pos++}writeU8a($){let Z=$.length;this.ensureBufferSizeToWrite(Z),this.bytes.set($,this.pos),this.pos+=Z}writeI8($){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,$),this.pos++}writeU16($){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,$),this.pos+=2}writeI16($){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,$),this.pos+=2}writeU32($){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,$),this.pos+=4}writeI32($){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,$),this.pos+=4}writeF32($){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,$),this.pos+=4}writeF64($){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,$),this.pos+=8}writeU64($){this.ensureBufferSizeToWrite(8),S0(this.view,this.pos,$),this.pos+=8}writeI64($){this.ensureBufferSizeToWrite(8),k(this.view,this.pos,$),this.pos+=8}writeBigUint64($){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,$),this.pos+=8}writeBigInt64($){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,$),this.pos+=8}}var S$=100,_$=2048;var B0=H(()=>{I();E()});function N($,Z){return new w(Z).encodeSharedRef($)}var A0=H(()=>{B0()});function j($){return`${$<0?"-":""}0x${Math.abs($).toString(16).padStart(2,"0")}`}class n{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor($=C$,Z=O$){this.maxKeyLength=$,this.maxLengthPerKey=Z,this.caches=[];for(let Q=0;Q<this.maxKeyLength;Q++)this.caches.push([])}canBeCached($){return $>0&&$<=this.maxKeyLength}find($,Z,Q){let J=this.caches[Q-1];$:for(let W of J){let q=W.bytes;for(let F=0;F<Q;F++)if(q[F]!==$[Z+F])continue $;return W.str}return null}store($,Z){let Q=this.caches[$.length-1],J={bytes:$,str:Z};if(Q.length>=this.maxLengthPerKey)Q[Math.random()*Q.length|0]=J;else Q.push(J)}decode($,Z,Q){let J=this.find($,Z,Q);if(J!=null)return this.hit++,J;this.miss++;let W=l($,Z,Q),q=Uint8Array.prototype.slice.call($,Z,Z+Q);return this.store(q,W),W}}var C$=16,O$=16;var z0=H(()=>{I()});class L0{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState($){let Z=this.getUninitializedStateFromPool();Z.type=d,Z.position=0,Z.size=$,Z.array=Array($)}pushMapState($){let Z=this.getUninitializedStateFromPool();Z.type=L,Z.readCount=0,Z.size=$,Z.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){let $={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push($)}return this.stack[this.stackHeadPosition]}release($){if(this.stack[this.stackHeadPosition]!==$)throw Error("Invalid stack state. Released state is not on top of the stack.");if($.type===d){let Q=$;Q.size=0,Q.array=void 0,Q.position=0,Q.type=void 0}if($.type===L||$.type===D0){let Q=$;Q.size=0,Q.map=void 0,Q.readCount=0,Q.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}}class h{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=i;bytes=A$;headByte=D;stack=new L0;entered=!1;constructor($){this.extensionCodec=$?.extensionCodec??R.defaultCodec,this.context=$?.context,this.useBigInt64=$?.useBigInt64??!1,this.rawStrings=$?.rawStrings??!1,this.maxStrLength=$?.maxStrLength??_,this.maxBinLength=$?.maxBinLength??_,this.maxArrayLength=$?.maxArrayLength??_,this.maxMapLength=$?.maxMapLength??_,this.maxExtLength=$?.maxExtLength??_,this.keyDecoder=$?.keyDecoder!==void 0?$.keyDecoder:z$,this.mapKeyConverter=$?.mapKeyConverter??B$}clone(){return new h({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=D,this.stack.reset()}setBuffer($){let Z=T($);this.bytes=Z,this.view=new DataView(Z.buffer,Z.byteOffset,Z.byteLength),this.pos=0}appendBuffer($){if(this.headByte===D&&!this.hasRemaining(1))this.setBuffer($);else{let Z=this.bytes.subarray(this.pos),Q=T($),J=new Uint8Array(Z.length+Q.length);J.set(Z),J.set(Q,Z.length),this.setBuffer(J)}}hasRemaining($){return this.view.byteLength-this.pos>=$}createExtraByteError($){let{view:Z,pos:Q}=this;return RangeError(`Extra ${Z.byteLength-Q} of ${Z.byteLength} byte(s) found at buffer[${$}]`)}decode($){if(this.entered)return this.clone().decode($);try{this.entered=!0,this.reinitializeState(),this.setBuffer($);let Z=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return Z}finally{this.entered=!1}}*decodeMulti($){if(this.entered){yield*this.clone().decodeMulti($);return}try{this.entered=!0,this.reinitializeState(),this.setBuffer($);while(this.hasRemaining(1))yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync($){if(this.entered)return this.clone().decodeAsync($);try{this.entered=!0;let Z=!1,Q;for await(let F of $){if(Z)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(F);try{Q=this.doDecodeSync(),Z=!0}catch(K){if(!(K instanceof RangeError))throw K}this.totalPos+=this.pos}if(Z){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return Q}let{headByte:J,pos:W,totalPos:q}=this;throw RangeError(`Insufficient data in parsing ${j(J)} at ${q} (${W} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream($){return this.decodeMultiAsync($,!0)}decodeStream($){return this.decodeMultiAsync($,!1)}async*decodeMultiAsync($,Z){if(this.entered){yield*this.clone().decodeMultiAsync($,Z);return}try{this.entered=!0;let Q=Z,J=-1;for await(let W of $){if(Z&&J===0)throw this.createExtraByteError(this.totalPos);if(this.appendBuffer(W),Q)J=this.readArraySize(),Q=!1,this.complete();try{while(!0)if(yield this.doDecodeSync(),--J===0)break}catch(q){if(!(q instanceof RangeError))throw q}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){$:while(!0){let $=this.readHeadByte(),Z;if($>=224)Z=$-256;else if($<192)if($<128)Z=$;else if($<144){let J=$-128;if(J!==0){this.pushMapState(J),this.complete();continue $}else Z={}}else if($<160){let J=$-144;if(J!==0){this.pushArrayState(J),this.complete();continue $}else Z=[]}else{let J=$-160;Z=this.decodeString(J,0)}else if($===192)Z=null;else if($===194)Z=!1;else if($===195)Z=!0;else if($===202)Z=this.readF32();else if($===203)Z=this.readF64();else if($===204)Z=this.readU8();else if($===205)Z=this.readU16();else if($===206)Z=this.readU32();else if($===207)if(this.useBigInt64)Z=this.readU64AsBigInt();else Z=this.readU64();else if($===208)Z=this.readI8();else if($===209)Z=this.readI16();else if($===210)Z=this.readI32();else if($===211)if(this.useBigInt64)Z=this.readI64AsBigInt();else Z=this.readI64();else if($===217){let J=this.lookU8();Z=this.decodeString(J,1)}else if($===218){let J=this.lookU16();Z=this.decodeString(J,2)}else if($===219){let J=this.lookU32();Z=this.decodeString(J,4)}else if($===220){let J=this.readU16();if(J!==0){this.pushArrayState(J),this.complete();continue $}else Z=[]}else if($===221){let J=this.readU32();if(J!==0){this.pushArrayState(J),this.complete();continue $}else Z=[]}else if($===222){let J=this.readU16();if(J!==0){this.pushMapState(J),this.complete();continue $}else Z={}}else if($===223){let J=this.readU32();if(J!==0){this.pushMapState(J),this.complete();continue $}else Z={}}else if($===196){let J=this.lookU8();Z=this.decodeBinary(J,1)}else if($===197){let J=this.lookU16();Z=this.decodeBinary(J,2)}else if($===198){let J=this.lookU32();Z=this.decodeBinary(J,4)}else if($===212)Z=this.decodeExtension(1,0);else if($===213)Z=this.decodeExtension(2,0);else if($===214)Z=this.decodeExtension(4,0);else if($===215)Z=this.decodeExtension(8,0);else if($===216)Z=this.decodeExtension(16,0);else if($===199){let J=this.lookU8();Z=this.decodeExtension(J,1)}else if($===200){let J=this.lookU16();Z=this.decodeExtension(J,2)}else if($===201){let J=this.lookU32();Z=this.decodeExtension(J,4)}else throw new Y(`Unrecognized type byte: ${j($)}`);this.complete();let Q=this.stack;while(Q.length>0){let J=Q.top();if(J.type===d)if(J.array[J.position]=Z,J.position++,J.position===J.size)Z=J.array,Q.release(J);else continue $;else if(J.type===L){if(Z==="__proto__")throw new Y("The key __proto__ is not allowed");J.key=this.mapKeyConverter(Z),J.type=D0;continue $}else if(J.map[J.key]=Z,J.readCount++,J.readCount===J.size)Z=J.map,Q.release(J);else{J.key=null,J.type=L;continue $}}return Z}}readHeadByte(){if(this.headByte===D)this.headByte=this.readU8();return this.headByte}complete(){this.headByte=D}readArraySize(){let $=this.readHeadByte();switch($){case 220:return this.readU16();case 221:return this.readU32();default:if($<160)return $-144;else throw new Y(`Unrecognized array type byte: ${j($)}`)}}pushMapState($){if($>this.maxMapLength)throw new Y(`Max length exceeded: map length (${$}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState($)}pushArrayState($){if($>this.maxArrayLength)throw new Y(`Max length exceeded: array length (${$}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState($)}decodeString($,Z){if(!this.rawStrings||this.stateIsMapKey())return this.decodeUtf8String($,Z);return this.decodeBinary($,Z)}decodeUtf8String($,Z){if($>this.maxStrLength)throw new Y(`Max length exceeded: UTF-8 byte length (${$}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+Z+$)throw T0;let Q=this.pos+Z,J;if(this.stateIsMapKey()&&this.keyDecoder?.canBeCached($))J=this.keyDecoder.decode(this.bytes,Q,$);else J=U0(this.bytes,Q,$);return this.pos+=Z+$,J}stateIsMapKey(){if(this.stack.length>0)return this.stack.top().type===L;return!1}decodeBinary($,Z){if($>this.maxBinLength)throw new Y(`Max length exceeded: bin length (${$}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining($+Z))throw T0;let Q=this.pos+Z,J=this.bytes.subarray(Q,Q+$);return this.pos+=Z+$,J}decodeExtension($,Z){if($>this.maxExtLength)throw new Y(`Max length exceeded: ext length (${$}) > maxExtLength (${this.maxExtLength})`);let Q=this.view.getInt8(this.pos+Z),J=this.decodeBinary($,Z+1);return this.extensionCodec.decode(J,Q,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let $=this.view.getUint8(this.pos);return this.pos++,$}readI8(){let $=this.view.getInt8(this.pos);return this.pos++,$}readU16(){let $=this.view.getUint16(this.pos);return this.pos+=2,$}readI16(){let $=this.view.getInt16(this.pos);return this.pos+=2,$}readU32(){let $=this.view.getUint32(this.pos);return this.pos+=4,$}readI32(){let $=this.view.getInt32(this.pos);return this.pos+=4,$}readU64(){let $=_0(this.view,this.pos);return this.pos+=8,$}readI64(){let $=m(this.view,this.pos);return this.pos+=8,$}readU64AsBigInt(){let $=this.view.getBigUint64(this.pos);return this.pos+=8,$}readI64AsBigInt(){let $=this.view.getBigInt64(this.pos);return this.pos+=8,$}readF32(){let $=this.view.getFloat32(this.pos);return this.pos+=4,$}readF64(){let $=this.view.getFloat64(this.pos);return this.pos+=8,$}}var d="array",L="map_key",D0="map_value",B$=($)=>{if(typeof $==="string"||typeof $==="number")return $;throw new Y("The type of key must be string or number but "+typeof $)},D=-1,i,A$,T0,z$;var x0=H(()=>{E();I();z0();u();i=new DataView(new ArrayBuffer(0)),A$=new Uint8Array(i.buffer);try{i.getInt8(0)}catch($){if(!($ instanceof RangeError))throw Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}T0=RangeError("Insufficient data"),z$=new n});function M($,Z){return new h(Z).decode($)}var I0=H(()=>{x0()});var g=H(()=>{A0();I0();E()});function r($){if(typeof $==="object"&&$!==null&&!Array.isArray($))return $;return{}}function b($){return Array.isArray($)?$:[]}function k0($){if(!($ instanceof Date))return null;let Z=new ArrayBuffer(8);return new DataView(Z).setFloat64(0,$.getTime()),new Uint8Array(Z)}function m0($){let Z=new DataView($.buffer,$.byteOffset,$.byteLength).getFloat64(0);return new Date(Z)}function g6($){return typeof $==="string"&&D$.has($)}var s,T$,D$;var E0=H(()=>{s=class s extends Error{code;constructor($,Z,Q){super(Z,Q);this.code=$,this.name=$}};T$={WorkflowAlreadyExistsError:!0,BulkDeleteRequiresTerminalWorkflowsError:!0,BulkOperationConfirmationError:!0,WorkflowTypeNotRegisteredForRecoveryError:!0,EngineCreateNameMismatchError:!0,EngineDisposedError:!0,WorkflowNotFoundError:!0,WorkflowNotRegisteredError:!0,WorkflowConcurrencyLimitExceededError:!0,WorkflowSuspendNotSupportedError:!0,ActivityResolutionError:!0,BranchTopologyChangedError:!0,PersistedDataIncompatibleError:!0,WorkflowTimeoutError:!0,HttpClientError:!0,WorkerProtocolIncompatibleError:!0,UpdateTimeoutError:!0,UpdateValidationError:!0,WorkflowTerminalError:!0,WorkflowBuilderError:!0,VersionMismatchError:!0,EffectReplayConflictError:!0,ReviewTimeoutError:!0,AtomicStateConflictError:!0,StandardSchemaValidationError:!0,ActivityReconciliationCapabilityError:!0,ActivityReconciliationConflictError:!0,ActivityReconciliationIndeterminateError:!0,AsyncActivityTokenNotFoundError:!0,ActivityScheduleToCloseTimeoutError:!0,ActivityPerAttemptTimeoutError:!0,PayloadSizeExceededError:!0,StartOrSignalConflictError:!0,IdempotencyKeyPurgedError:!0},D$=new Set(Object.keys(T$))});function a($){return w0.has($.constructor)}function j0($,Z){$.register({type:L$,encode(Q){if(typeof Q!=="object"||Q===null)return null;let J=w0.get(Q.constructor);if(J===void 0)return null;let W=Z(J.handlers.toJSON(Q),new Set);return N({tag:J.tag,data:W},{extensionCodec:$})},decode(Q){let J=M(Q,{extensionCodec:$});if(typeof J!=="object"||J===null||!("tag"in J))throw Error("Corrupt custom-serializer payload: missing tag.");let{tag:W,data:q}=J;if(typeof W!=="string")throw Error("Corrupt custom-serializer payload: tag is not a string.");let F=x$.get(W);if(F===void 0)throw Error(`No serializer registered for tag "${W}". Register it (with the same tag) before decoding a checkpoint that used it.`);return F.handlers.fromJSON(q)}})}var L$=100,w0,x$;var h0=H(()=>{g();w0=new Map,x$=new Map});function h$($,Z){if(Z<=200)return JSON.stringify($);return`${Z}-byte string starting ${JSON.stringify($.slice(0,120))}`}function g$($,Z){let Q=j$.encode($).byteLength;if(Q>g0)throw new t({source:$,flags:Z,sourceByteLength:Q,reason:`because source exceeds the ${g0}-byte limit.`});try{return new RegExp($,Z)}catch(J){let W=J instanceof Error?J.message:String(J);throw new t({source:$,flags:Z,sourceByteLength:Q,reason:`because ${W}`,cause:J})}}function y$($){return typeof $==="object"&&$!==null&&"__tag"in $&&$.__tag===b0}function e($,Z){if(!O($,Z))return $;return C($,new Set)}function C($,Z){if($===void 0)return b$;if($===null||typeof $!=="object")return $;if(Z.has($))return $;Z.add($);try{return f$($,Z)}finally{Z.delete($)}}function f$($,Z){if(Array.isArray($))return v$($,Z);if($ instanceof Map)return p$($,Z);if($ instanceof Set)return c$($,Z);if(y0($))return $;return l$($,Z)}function v$($,Z){let Q=Array.from({length:$.length});for(let J=0;J<$.length;J++)Q[J]=C($[J],Z);return Q}function p$($,Z){let Q=new Map;for(let[J,W]of $)Q.set(C(J,Z),C(W,Z));return Q}function c$($,Z){let Q=new Set;for(let J of $)Q.add(C(J,Z));return Q}function y0($){return $ instanceof Date||$ instanceof RegExp||$ instanceof Error||$ instanceof Uint8Array||$ instanceof ArrayBuffer||a($)}function l$($,Z){let Q=$,J={};for(let W of Object.keys(Q))J[W]=C(Q[W],Z);return J}function O($,Z){if($===void 0)return!0;if($===null||typeof $!=="object")return!1;if(Z.has($))return!1;if(y0($))return!1;Z.add($);try{if(Array.isArray($))return u$($,Z);if($ instanceof Map)return n$($,Z);if($ instanceof Set)return d$($,Z);return i$($,Z)}finally{Z.delete($)}}function u$($,Z){for(let Q=0;Q<$.length;Q++)if(O($[Q],Z))return!0;return!1}function n$($,Z){for(let[Q,J]of $)if(O(Q,Z)||O(J,Z))return!0;return!1}function d$($,Z){for(let Q of $)if(O(Q,Z))return!0;return!1}function i$($,Z){let Q=$;for(let J of Object.keys(Q))if(O(Q[J],Z))return!0;return!1}var I$=1,o=2,k$=3,m$=4,E$=5,w$=6,g0=65535,j$,t,V,b0,b$;var f0=H(()=>{g();E0();h0();j$=new TextEncoder;t=class t extends s{extensionType;source;flags;sourceByteLength;constructor($){super("RegExpExtensionDecodeError",`RegExp extension type ${o} could not be decoded: source=${h$($.source,$.sourceByteLength)} flags=${JSON.stringify($.flags)} ${$.reason}`,$.cause===void 0?void 0:{cause:$.cause});this.extensionType=o,this.source=$.source,this.flags=$.flags,this.sourceByteLength=$.sourceByteLength}};V=new R;j0(V,e);V.register({type:I$,encode:k0,decode:m0});V.register({type:o,encode($){if($ instanceof RegExp)return N({source:$.source,flags:$.flags});return null},decode($){let Z=r(M($)),Q=typeof Z.source==="string"?Z.source:"",J=typeof Z.flags==="string"?Z.flags:"";return g$(Q,J)}});V.register({type:k$,encode($){if($ instanceof Map){let Z=[...$.entries()];return N(Z,{extensionCodec:V})}return null},decode($){let Q=b(M($,{extensionCodec:V})).map((J)=>{let W=b(J);return[W[0],W[1]]});return new Map(Q)}});V.register({type:m$,encode($){if($ instanceof Set){let Z=[...$.values()];return N(Z,{extensionCodec:V})}return null},decode($){let Z=b(M($,{extensionCodec:V}));return new Set(Z)}});b0=Symbol("UndefinedSentinel"),b$=Object.freeze({__tag:b0});V.register({type:E$,encode($){if(y$($))return new Uint8Array(0);return null},decode(){return}});V.register({type:w$,encode($){if($ instanceof Error&&!a($))return N({name:$.name,message:$.message,stack:$.stack});return null},decode($){let Z=r(M($)),Q=typeof Z.name==="string"?Z.name:"Error",J=typeof Z.message==="string"?Z.message:"",W=typeof Z.stack==="string"?Z.stack:void 0,q=Error(J);if(q.name=Q,W!==void 0)q.stack=W;return q}})});function $0($){let Z=e($,new Set);return N(Z,{extensionCodec:V})}function Z0($){return M($,{extensionCodec:V})}var v0=H(()=>{g();f0()});function y($,Z=""){let Q=[];return x($,Z,Q,new Set),{valid:Q.length===0,errors:Q}}function r$($){let Z=Object.getPrototypeOf($);return s$(Z)&&!a$($)&&o$(Z)}function s$($){return $!==Object.prototype&&$!==null}function a$($){return Array.isArray($)||$ instanceof Date||$ instanceof RegExp||$ instanceof Map||$ instanceof Set||$ instanceof Error||$ instanceof Uint8Array||$ instanceof ArrayBuffer}function o$($){if(typeof $!=="object"||$===null)return!1;return Object.getOwnPropertyNames($).some((Q)=>{if(Q==="constructor")return!1;let J=Object.getOwnPropertyDescriptor($,Q);return J!==void 0&&typeof J.value==="function"})}function p0($,Z,Q,J){$.push({path:Z,value:Q,reason:J.reason,suggestion:J.suggestion})}function t$($){if(typeof $==="function")return{reason:"Functions cannot be serialized.",suggestion:"Move this into ctx.run() or reconstruct it on resume."};if(typeof $==="symbol")return{reason:"Symbols cannot be serialized.",suggestion:"Use a string identifier instead of a Symbol."};return null}function e$($,Z){if($ instanceof WeakRef)return{reason:"WeakRef cannot be serialized.",suggestion:"Store the referenced value directly instead of using a WeakRef."};if($ instanceof WeakMap)return{reason:"WeakMap cannot be serialized.",suggestion:"Use a Map instead of a WeakMap."};if($ instanceof WeakSet)return{reason:"WeakSet cannot be serialized.",suggestion:"Use a Set instead of a WeakSet."};if(Z.has($))return{reason:"Circular reference detected.",suggestion:"Remove the circular reference or restructure the data."};if(r$($))return{reason:"Class instances with methods cannot be serialized.",suggestion:"Store only the data and reconstruct the instance."};return null}function $1($){return $ instanceof Date||$ instanceof RegExp||$ instanceof Error||$ instanceof Uint8Array||$ instanceof ArrayBuffer}function Z1($,Z,Q,J){for(let[W,q]of $){let F=String(W);x(q,Z?`${Z}.${F}`:F,Q,J)}}function Q1($,Z,Q,J){let W=0;for(let q of $){let F=Z?`${Z}[${W}]`:`[${W}]`;x(q,F,Q,J),W++}}function J1($,Z,Q,J){for(let W=0;W<$.length;W++){let q=Z?`${Z}[${W}]`:`[${W}]`;x($[W],q,Q,J)}}function W1($,Z,Q,J){for(let W of Object.keys($)){let q=Z?`${Z}.${W}`:W;x($[W],q,Q,J)}}function x($,Z,Q,J){if($===null||$===void 0)return;let W=t$($);if(W){p0(Q,Z,$,W);return}if(typeof $!=="object")return;let q=e$($,J);if(q){p0(Q,Z,$,q);return}J.add($);try{if($1($))return;if($ instanceof Map){Z1($,Z,Q,J);return}if($ instanceof Set){Q1($,Z,Q,J);return}if(Array.isArray($)){J1($,Z,Q,J);return}W1($,Z,Q,J)}finally{J.delete($)}}var c0=H(()=>{v0()});var l0=H(()=>{c0()});function G1($){if($===void 0)return;if(typeof $!=="number"||!Number.isInteger($)||$<0)throw Error("deleteRange limit must be a finite non-negative integer");return $===0?0:$}function q1($){let Z={},Q=!1;for(let W of["gt","gte","lt","lte"]){let q=$[W];if(q===void 0)continue;if(typeof q!=="string")throw Error("deleteRange bounds must be strings");Z[W]=q,Q=!0}if(!Q)throw Error("deleteRange requires at least one of gt/gte/lt/lte; use deletePrefix to delete a whole prefix");let J=G1($.limit);if(J!==void 0)Z.limit=J;return Z}async function u0($,Z,Q){let J=q1(Q);if($.deleteRange)return $.deleteRange(Z,J);return G0($,Z,J)}var n0=()=>{};l0();n0();N0();class d0{#$;#Z;#Q;constructor($,Z,Q={}){this.#$=$,this.#Z=Z,this.#Q=Q.disposeUnderlyingStorage??!0}async get($){let Z=await this.#$.get($);return Z===null?null:this.#Z.decode(Z)}async put($,Z){await this.#$.put($,this.#Z.encode(Z))}async delete($){await this.#$.delete($)}async*scan($,Z){for await(let[Q,J]of this.#$.scan($,Z))yield[Q,this.#Z.decode(J)]}async batch($){z("batch operations",$.length),await this.#$.batch(this.#J($))}#J($){return $.map((Q)=>{if(Q.type==="put")return{type:"put",key:Q.key,value:this.#Z.encode(Q.value)};return Q})}#W($){return $.map((Z)=>({key:Z.key,expectedValue:Z.expectedValue===null?null:this.#Z.encode(Z.expectedValue)}))}async conditionalBatch($,Z){return P0(this.#$,this.#W($),this.#J(Z))}async has($){return H0(this.#$,$)}async deletePrefix($){return V0(this.#$,$)}async deleteRange($,Z){return u0(this.#$,$,Z)}keys($,Z){return X0(this.#$,$,Z)}async count($){return Y0(this.#$,$)}[Symbol.dispose](){if(!this.#Q)return;this.#$[Symbol.dispose]()}}function q8($,Z,Q={}){return new d0($,Z,Q)}function F1($){try{let Z=JSON.stringify($);if(Z===void 0)throw TypeError("jsonCodec only supports JSON-serializable values.");return new TextEncoder().encode(Z)}catch(Z){throw TypeError("jsonCodec only supports JSON-serializable values.",{cause:Z})}}function K1($){let Z=y($);if(!Z.valid)throw TypeError(`msgpackCodec only supports structuredClone-compatible values. ${Z.errors[0]?.reason??""}`.trim());return $0($)}function H1($){return JSON.parse(new TextDecoder().decode($))}function X1($){let Z=Z0($),Q=y(Z);if(!Q.valid)throw TypeError(`msgpackCodec decoded a non-cloneable value. ${Q.errors[0]?.reason??""}`.trim());return Z}function F8($){return{encode(Z){return F1(Z)},decode(Z){let Q=H1(Z);return $?$(Q):Q}}}function K8($){return{encode(Z){return K1(Z)},decode(Z){let Q=X1(Z);return $?$(Q):Q}}}export{q8 as withCodec,K8 as msgpackCodec,F8 as jsonCodec};
|
|
2
|
+
var r0=Object.defineProperty;var s0=($)=>$;function a0($,Z){this[$]=s0.bind(null,Z)}var Y1=($,Z)=>{for(var Q in Z)r0($,Q,{get:Z[Q],enumerable:!0,configurable:!0,set:a0.bind(Z,Q)})};var H=($,Z)=>()=>($&&(Z=$($=0)),Z);var V1=($,Z,Q)=>{if(Z!=null){if(typeof Z!=="object"&&typeof Z!=="function")throw TypeError('Object expected to be assigned to "using" declaration');let J;if(Q)J=Z[Symbol.asyncDispose];if(J===void 0)J=Z[Symbol.dispose];if(typeof J!=="function")throw TypeError("Object not disposable");$.push([Q,J,Z])}else if(Q)$.push([Q]);return Z},P1=($,Z,Q)=>{let J=(q)=>Z=Q?new SuppressedError(q,Z,"An error was suppressed during disposal"):(Q=!0,q),W=(q)=>{while(q=$.pop())try{var F=q[1]&&q[1].call(q[2]);if(q[0])return Promise.resolve(F).then(W,(K)=>(J(K),W()))}catch(K){J(K)}if(Q)throw Z};return W()};function v($,Z,Q){if(!$.capabilities()[Z])throw Error(`Feature "${Q}" requires storage capability "${Z}", but this storage backend does not provide it.`)}function o0($){let Z=$.capabilities(),Q=[];if(Z.persistence!=="local"&&Z.persistence!=="remote")Q.push(`persistence must be "local" or "remote" (got "${Z.persistence}")`);if(Z.readAfterWrite!=="linearizable")Q.push(`readAfterWrite must be "linearizable" (got "${Z.readAfterWrite}")`);if(Z.scanConsistency!=="snapshot")Q.push(`scanConsistency must be "snapshot" (got "${Z.scanConsistency}")`);if(!Z.atomicBatch)Q.push("atomicBatch must be true");if(!Z.conditionalBatch)Q.push("conditionalBatch must be true");if(Q.length>0)throw Error(`Storage is not durable enough for recovery: ${Q.join("; ")}.`)}var p="default";async function Q0($,Z){return await $.get(Z)!==null}async function*A($,Z,Q){for await(let[J]of $.scan(Z,Q))yield J}async function J0($,Z){let Q=0;for await(let J of A($,Z))Q++;return Q}async function W0($,Z){let Q=[];for await(let J of A($,Z))Q.push({type:"delete",key:J});if(Q.length===0)return 0;return await $.batch(Q),Q.length}async function G0($,Z,Q){let J=[];for await(let W of A($,Z,Q))J.push({type:"delete",key:W});if(J.length===0)return 0;return await $.batch(J),J.length}var t0;var q0=H(()=>{t0=["actrec:","archive:","async-act:","attr:","audit:bulk:","blob:","budget:","budget-charged:","ev:","fleet-event-by-workflow:","fleet-event:","fleet-event-tail","idx:","lease:","liveness:","offload:","op:","review:","schedule:","schedule-due:","schedule-run:","sig:","sigres:","sigseq:","start-idem:","state:","tag:","tool-effect:","upd:","upk:","upr:","wf:","wf-cleanup:","wf-cleanup-needed:","wf-concurrency:","wf-concurrency-holder:","wf-deadline:","wf-delayed:","wf-finalizer-state:","wf-has-services:","wf-headers:","wf-idx-","wf-teardown:","wf-teardown-deadletter:","wf-teardown-needed:","wf-terminal:"]});function z($,Z){if(Z>c)throw new K0($,Z)}function A1($){return $.length>0?$.slice(0,-1)+String.fromCharCode($.charCodeAt($.length-1)+1):"\xFF"}function z1($,Z={}){if(Z.gt!==void 0&&$<=Z.gt)return!1;if(Z.gte!==void 0&&$<Z.gte)return!1;if(Z.lt!==void 0&&$>=Z.lt)return!1;if(Z.lte!==void 0&&$>Z.lte)return!1;return!0}function T1($,Z){if($===null||Z===null)return $===Z;if($.byteLength!==Z.byteLength)return!1;for(let Q=0;Q<$.byteLength;Q++)if($[Q]!==Z[Q])return!1;return!0}async function H0($,Z){if($.has)return $.has(Z);return Q0($,Z)}function X0($,Z,Q){if($.keys)return $.keys(Z,Q);return A($,Z,Q)}async function Y0($,Z){if($.count)return $.count(Z);return J0($,Z)}async function V0($,Z){if($.deletePrefix)return $.deletePrefix(Z);return W0($,Z)}async function D1($,Z){z("batch operations",Z.length),await $.batch(Z)}async function P0($,Z,Q){if(z("conditionalBatch conditions",Z.length),z("conditionalBatch operations",Q.length),v($,"conditionalBatch","storageConditionalBatch"),!$.conditionalBatch)throw Error("This storage backend reports conditionalBatch capability but does not implement the conditionalBatch() method.");return $.conditionalBatch(Z,Q)}function G($){return encodeURIComponent($)}function L1($){return decodeURIComponent($)}function x1($){try{return decodeURIComponent($)}catch{return null}}var c=1e4,B1=1e4,K0,P=($)=>String($).padStart(16,"0"),e0="0",$$="1",F0=($,Z,Q,J)=>`sig:${G($)}:${G(Z)}:${J}:${G(Q)}`,I1;var N0=H(()=>{q0();K0=class K0 extends Error{code="StorageBatchOperationLimitExceededError";cap=c;count;target;constructor($,Z){super(`${$} count ${Z} exceeds MAX_BATCH_OPERATIONS (${c}).`);this.name="StorageBatchOperationLimitExceededError",this.target=$,this.count=Z}};I1={workflow:($)=>`wf:${G($)}`,checkpoint:($)=>`wf:${G($)}:ckpt`,checkpointHistory:($,Z)=>`wf:${G($)}:ckpt:${String(Z).padStart(10,"0")}`,timelinePrefix:($)=>`wf:${G($)}:timeline:`,timeline:($,Z)=>`wf:${G($)}:timeline:${String(Z).padStart(10,"0")}`,schedule:($)=>`schedule:${G($)}`,scheduleTick:($,Z)=>`schedule-due:${String($).padStart(16,"0")}:${G(Z)}`,scheduleRun:($)=>`schedule-run:${G($)}`,operation:($,Z,Q)=>`op:${$}:${P(Z)}:${Q}`,operationInflight:($)=>`op:inflight:${$}`,operationQueued:($)=>`op:queued:${$}`,operationResolved:($)=>`op:resolved:${$}`,operationDeadLetterPrefix:()=>"op:dead-letter:",operationDeadLetter:($)=>`op:dead-letter:${$}`,bulkOperationAuditPrefix:()=>"audit:bulk:",bulkOperationAudit:($,Z,Q)=>`audit:bulk:${P($)}:${G(Z)}:${G(Q)}`,operationResolvedByTimePrefix:()=>"op:resolved-by-time:",operationResolvedByTime:($,Z)=>`op:resolved-by-time:${P($)}:${G(Z)}`,asyncActivity:($,Z)=>`async-act:v1:${G($)}:${G(Z)}`,activityReconciliationPrefix:($)=>`actrec:v1:${G($)}:`,activityReconciliation:($,Z,Q)=>`actrec:v1:${G($)}:${G(Z)}:${Q}`,eventPrefix:($)=>`ev:${G($)}:`,event:($,Z)=>`ev:${G($)}:${String(Z).padStart(10,"0")}`,eventHead:($)=>`ev:${G($)}:head`,eventWatermark:($)=>`ev:${G($)}:watermark`,fleetEventPrefix:()=>"fleet-event:",fleetEvent:($)=>`fleet-event:${String($).padStart(10,"0")}`,fleetEventTail:()=>"fleet-event-tail",fleetEventByWorkflowPrefix:($)=>`fleet-event-by-workflow:${G($)}:`,fleetEventByWorkflow:($,Z)=>`fleet-event-by-workflow:${G($)}:${String(Z).padStart(10,"0")}`,signal:($,Z,Q)=>F0($,Z,Q,$$),startSignal:($,Z,Q)=>F0($,Z,Q,e0),signalSequence:($)=>`sigseq:v1:${G($)}`,signalAcceptedResponsePrefix:($)=>`sigres:v1:${G($)}:`,signalAcceptedResponse:($,Z,Q)=>`sigres:v1:${G($)}:${G(Z)}:${G(Q)}`,deadline:($,Z)=>`wf-deadline:${P($)}:${G(Z)}`,terminalCleanup:($,Z)=>`wf-cleanup:${P($)}:${G(Z)}`,teardownTimer:($,Z)=>`wf-teardown:${P($)}:${G(Z)}`,delayedStart:($,Z)=>`wf-delayed:${P($)}:${G(Z)}`,terminalWorkflowPrefix:()=>"wf-terminal:",terminalWorkflow:($,Z)=>`wf-terminal:${P($)}:${G(Z)}`,attribute:($)=>`attr:${G($)}`,attributeIndex:($,Z,Q)=>`idx:${$}:${Z}:${G(Q)}`,tagIndex:($,Z)=>`tag:${G($)}:${G(Z)}`,updatePrefix:($)=>`upd:${G($)}:`,update:($,Z)=>`upd:${G($)}:${Z}`,updateResponse:($)=>`upr:${$}`,updateIdempotency:($,Z)=>`upk:${G($)}:${Z}`,startIdempotency:($)=>`start-idem:${G($)}`,startIdempotencySignalId:($)=>`start-idem:${$}`,livenessPrefix:()=>"liveness:",liveness:($)=>`liveness:${G($)}`,leasePrefix:()=>"lease:",leaseEpoch:()=>"lease:epoch",leaseHolder:()=>"lease:holder",budget:($,Z,Q)=>`budget:${$}:${Z}:${Q}`,review:($,Z)=>`review:${G($)}:${Z}`,workflowHeaders:($)=>`wf-headers:${G($)}`,childCancellationPrefix:($)=>`child-cancel:${G($)}:`,childCancellation:($,Z)=>`child-cancel:${G($)}:${G(Z)}`,terminalCleanupNeeded:($)=>`wf-cleanup-needed:${G($)}`,workflowConcurrency:($,Z)=>`wf-concurrency:${G($)}:${G(Z)}`,workflowConcurrencyHolder:($)=>`wf-concurrency-holder:${G($)}`,workflowHasServices:($)=>`wf-has-services:${G($)}`,finalizerState:($)=>`wf-finalizer-state:${G($)}`,teardownOwed:($)=>`wf-teardown-needed:${G($)}`,teardownDeadLetter:($)=>`wf-teardown-deadletter:${G($)}`,offload:($,Z)=>`offload:${G($)}:${Z}`,archive:($,Z)=>`archive:${G($)}:${Z}`,stateExecution:($,Z)=>`state:execution:${G($)}:${G(Z)}`,stateWorkflow:($,Z)=>`state:workflow-scope:${p}:${G($)}:${G(Z)}`,streamChunkPrefix:($,Z)=>`blob:${G($)}:${Z}:chunk:`,streamChunk:($,Z,Q)=>`blob:${G($)}:${Z}:chunk:${String(Q).padStart(10,"0")}`,streamTail:($,Z)=>`blob:${G($)}:${Z}:tail`,streamMetadata:($,Z)=>`blob:${G($)}:${Z}:meta`,budgetCharged:($)=>`budget-charged:${$}`,toolEffect:($,Z,Q)=>`tool-effect:${G($)}:${Z}:${Q}`,workflowVisibilityStatus:($,Z)=>`wf-idx-status:${G($)}:${G(Z)}`,workflowVisibilityType:($,Z)=>`wf-idx-type:${G($)}:${G(Z)}`,workflowVisibilityCreated:($,Z)=>`wf-idx-created:${P($)}:${G(Z)}`,workflowVisibilityUpdated:($,Z)=>`wf-idx-updated:${P($)}:${G(Z)}`,workflowVisibilityDeadline:($,Z)=>`wf-idx-deadline:${P($)}:${G(Z)}`,workflowVisibilityManifest:($)=>`wf-idx-manifest:${G($)}`,workflowVisibilityMetaVersion:()=>"wf-idx-meta:version",workflowVisibilityMetaBuiltAt:()=>"wf-idx-meta:built-at",workflowVisibilityMetaCursor:()=>"wf-idx-meta:cursor"}});function M0($){let Z=$.length,Q=0,J=0;while(J<Z){let W=$.charCodeAt(J++);if((W&4294967168)===0){Q++;continue}else if((W&4294965248)===0)Q+=2;else{if(W>=55296&&W<=56319){if(J<Z){let q=$.charCodeAt(J);if((q&64512)===56320)++J,W=((W&1023)<<10)+(q&1023)+65536}}if((W&4294901760)===0)Q+=3;else Q+=4}}return Q}function Z$($,Z,Q){let J=$.length,W=Q,q=0;while(q<J){let F=$.charCodeAt(q++);if((F&4294967168)===0){Z[W++]=F;continue}else if((F&4294965248)===0)Z[W++]=F>>6&31|192;else{if(F>=55296&&F<=56319){if(q<J){let K=$.charCodeAt(q);if((K&64512)===56320)++q,F=((F&1023)<<10)+(K&1023)+65536}}if((F&4294901760)===0)Z[W++]=F>>12&15|224,Z[W++]=F>>6&63|128;else Z[W++]=F>>18&7|240,Z[W++]=F>>12&63|128,Z[W++]=F>>6&63|128}Z[W++]=F&63|128}}function W$($,Z,Q){Q$.encodeInto($,Z.subarray(Q))}function R0($,Z,Q){if($.length>J$)W$($,Z,Q);else Z$($,Z,Q)}function l($,Z,Q){let J=Z,W=J+Q,q=[],F="";while(J<W){let K=$[J++];if((K&128)===0)q.push(K);else if((K&224)===192){let B=$[J++]&63;q.push((K&31)<<6|B)}else if((K&240)===224){let B=$[J++]&63,f=$[J++]&63;q.push((K&31)<<12|B<<6|f)}else if((K&248)===240){let B=$[J++]&63,f=$[J++]&63,i0=$[J++]&63,U=(K&7)<<18|B<<12|f<<6|i0;if(U>65535)U-=65536,q.push(U>>>10&1023|55296),U=56320|U&1023;q.push(U)}else q.push(K);if(q.length>=G$)F+=String.fromCharCode(...q),q.length=0}if(q.length>0)F+=String.fromCharCode(...q);return F}function K$($,Z,Q){let J=$.subarray(Z,Z+Q);return q$.decode(J)}function U0($,Z,Q){if(Q>F$)return K$($,Z,Q);else return l($,Z,Q)}var Q$,J$=50,G$=4096,q$,F$=200;var I=H(()=>{Q$=new TextEncoder;q$=new TextDecoder});class S{type;data;constructor($,Z){this.type=$,this.data=Z}}var Y;var u=H(()=>{Y=class Y extends Error{constructor($){super($);let Z=Object.create(Y.prototype);Object.setPrototypeOf(this,Z),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:Y.name})}}});function S0($,Z,Q){let J=Q/4294967296,W=Q;$.setUint32(Z,J),$.setUint32(Z+4,W)}function k($,Z,Q){let J=Math.floor(Q/4294967296),W=Q;$.setUint32(Z,J),$.setUint32(Z+4,W)}function m($,Z){let Q=$.getInt32(Z),J=$.getUint32(Z+4);return Q*4294967296+J}function _0($,Z){let Q=$.getUint32(Z),J=$.getUint32(Z+4);return Q*4294967296+J}var _=4294967295;function V$({sec:$,nsec:Z}){if($>=0&&Z>=0&&$<=Y$)if(Z===0&&$<=X$){let Q=new Uint8Array(4);return new DataView(Q.buffer).setUint32(0,$),Q}else{let Q=$/4294967296,J=$&4294967295,W=new Uint8Array(8),q=new DataView(W.buffer);return q.setUint32(0,Z<<2|Q&3),q.setUint32(4,J),W}else{let Q=new Uint8Array(12),J=new DataView(Q.buffer);return J.setUint32(0,Z),k(J,4,$),Q}}function P$($){let Z=$.getTime(),Q=Math.floor(Z/1000),J=(Z-Q*1000)*1e6,W=Math.floor(J/1e9);return{sec:Q+W,nsec:J-W*1e9}}function N$($){if($ instanceof Date){let Z=P$($);return V$(Z)}else return null}function M$($){let Z=new DataView($.buffer,$.byteOffset,$.byteLength);switch($.byteLength){case 4:{let Q=Z.getUint32(0),J=0;return{sec:Q,nsec:0}}case 8:{let Q=Z.getUint32(0),J=Z.getUint32(4),W=(Q&3)*4294967296+J,q=Q>>>2;return{sec:W,nsec:q}}case 12:{let Q=m(Z,4),J=Z.getUint32(0);return{sec:Q,nsec:J}}default:throw new Y(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${$.length}`)}}function R$($){let Z=M$($);return new Date(Z.sec*1000+Z.nsec/1e6)}var H$=-1,X$=4294967295,Y$=17179869183,C0;var O0=H(()=>{u();C0={type:H$,encode:N$,decode:R$}});var R;var E=H(()=>{O0();R=class R{static defaultCodec=new R;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(C0)}register({type:$,encode:Z,decode:Q}){if($>=0)this.encoders[$]=Z,this.decoders[$]=Q;else{let J=-1-$;this.builtInEncoders[J]=Z,this.builtInDecoders[J]=Q}}tryToEncode($,Z){for(let Q=0;Q<this.builtInEncoders.length;Q++){let J=this.builtInEncoders[Q];if(J!=null){let W=J($,Z);if(W!=null){let q=-1-Q;return new S(q,W)}}}for(let Q=0;Q<this.encoders.length;Q++){let J=this.encoders[Q];if(J!=null){let W=J($,Z);if(W!=null)return new S(Q,W)}}if($ instanceof S)return $;return null}decode($,Z,Q){let J=Z<0?this.builtInDecoders[-1-Z]:this.decoders[Z];if(J)return J($,Z,Q);else return new S(Z,$)}}});function U$($){return $ instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&$ instanceof SharedArrayBuffer}function T($){if($ instanceof Uint8Array)return $;else if(ArrayBuffer.isView($))return new Uint8Array($.buffer,$.byteOffset,$.byteLength);else if(U$($))return new Uint8Array($);else return Uint8Array.from($)}class w{extensionCodec;context;useBigInt64;maxDepth;initialBufferSize;sortKeys;forceFloat32;ignoreUndefined;forceIntegerToFloat;pos;view;bytes;entered=!1;constructor($){this.extensionCodec=$?.extensionCodec??R.defaultCodec,this.context=$?.context,this.useBigInt64=$?.useBigInt64??!1,this.maxDepth=$?.maxDepth??S$,this.initialBufferSize=$?.initialBufferSize??_$,this.sortKeys=$?.sortKeys??!1,this.forceFloat32=$?.forceFloat32??!1,this.ignoreUndefined=$?.ignoreUndefined??!1,this.forceIntegerToFloat=$?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new w({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef($){if(this.entered)return this.clone().encodeSharedRef($);try{return this.entered=!0,this.reinitializeState(),this.doEncode($,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode($){if(this.entered)return this.clone().encode($);try{return this.entered=!0,this.reinitializeState(),this.doEncode($,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode($,Z){if(Z>this.maxDepth)throw Error(`Too deep objects in depth ${Z}`);if($==null)this.encodeNil();else if(typeof $==="boolean")this.encodeBoolean($);else if(typeof $==="number")if(!this.forceIntegerToFloat)this.encodeNumber($);else this.encodeNumberAsFloat($);else if(typeof $==="string")this.encodeString($);else if(this.useBigInt64&&typeof $==="bigint")this.encodeBigInt64($);else this.encodeObject($,Z)}ensureBufferSizeToWrite($){let Z=this.pos+$;if(this.view.byteLength<Z)this.resizeBuffer(Z*2)}resizeBuffer($){let Z=new ArrayBuffer($),Q=new Uint8Array(Z),J=new DataView(Z);Q.set(this.bytes),this.view=J,this.bytes=Q}encodeNil(){this.writeU8(192)}encodeBoolean($){if($===!1)this.writeU8(194);else this.writeU8(195)}encodeNumber($){if(!this.forceIntegerToFloat&&Number.isSafeInteger($))if($>=0)if($<128)this.writeU8($);else if($<256)this.writeU8(204),this.writeU8($);else if($<65536)this.writeU8(205),this.writeU16($);else if($<4294967296)this.writeU8(206),this.writeU32($);else if(!this.useBigInt64)this.writeU8(207),this.writeU64($);else this.encodeNumberAsFloat($);else if($>=-32)this.writeU8(224|$+32);else if($>=-128)this.writeU8(208),this.writeI8($);else if($>=-32768)this.writeU8(209),this.writeI16($);else if($>=-2147483648)this.writeU8(210),this.writeI32($);else if(!this.useBigInt64)this.writeU8(211),this.writeI64($);else this.encodeNumberAsFloat($);else this.encodeNumberAsFloat($)}encodeNumberAsFloat($){if(this.forceFloat32)this.writeU8(202),this.writeF32($);else this.writeU8(203),this.writeF64($)}encodeBigInt64($){if($>=BigInt(0))this.writeU8(207),this.writeBigUint64($);else this.writeU8(211),this.writeBigInt64($)}writeStringHeader($){if($<32)this.writeU8(160+$);else if($<256)this.writeU8(217),this.writeU8($);else if($<65536)this.writeU8(218),this.writeU16($);else if($<4294967296)this.writeU8(219),this.writeU32($);else throw Error(`Too long string: ${$} bytes in UTF-8`)}encodeString($){let Q=M0($);this.ensureBufferSizeToWrite(5+Q),this.writeStringHeader(Q),R0($,this.bytes,this.pos),this.pos+=Q}encodeObject($,Z){let Q=this.extensionCodec.tryToEncode($,this.context);if(Q!=null)this.encodeExtension(Q);else if(Array.isArray($))this.encodeArray($,Z);else if(ArrayBuffer.isView($))this.encodeBinary($);else if(typeof $==="object")this.encodeMap($,Z);else throw Error(`Unrecognized object: ${Object.prototype.toString.apply($)}`)}encodeBinary($){let Z=$.byteLength;if(Z<256)this.writeU8(196),this.writeU8(Z);else if(Z<65536)this.writeU8(197),this.writeU16(Z);else if(Z<4294967296)this.writeU8(198),this.writeU32(Z);else throw Error(`Too large binary: ${Z}`);let Q=T($);this.writeU8a(Q)}encodeArray($,Z){let Q=$.length;if(Q<16)this.writeU8(144+Q);else if(Q<65536)this.writeU8(220),this.writeU16(Q);else if(Q<4294967296)this.writeU8(221),this.writeU32(Q);else throw Error(`Too large array: ${Q}`);for(let J of $)this.doEncode(J,Z+1)}countWithoutUndefined($,Z){let Q=0;for(let J of Z)if($[J]!==void 0)Q++;return Q}encodeMap($,Z){let Q=Object.keys($);if(this.sortKeys)Q.sort();let J=this.ignoreUndefined?this.countWithoutUndefined($,Q):Q.length;if(J<16)this.writeU8(128+J);else if(J<65536)this.writeU8(222),this.writeU16(J);else if(J<4294967296)this.writeU8(223),this.writeU32(J);else throw Error(`Too large map object: ${J}`);for(let W of Q){let q=$[W];if(!(this.ignoreUndefined&&q===void 0))this.encodeString(W),this.doEncode(q,Z+1)}}encodeExtension($){if(typeof $.data==="function"){let Q=$.data(this.pos+6),J=Q.length;if(J>=4294967296)throw Error(`Too large extension object: ${J}`);this.writeU8(201),this.writeU32(J),this.writeI8($.type),this.writeU8a(Q);return}let Z=$.data.length;if(Z===1)this.writeU8(212);else if(Z===2)this.writeU8(213);else if(Z===4)this.writeU8(214);else if(Z===8)this.writeU8(215);else if(Z===16)this.writeU8(216);else if(Z<256)this.writeU8(199),this.writeU8(Z);else if(Z<65536)this.writeU8(200),this.writeU16(Z);else if(Z<4294967296)this.writeU8(201),this.writeU32(Z);else throw Error(`Too large extension object: ${Z}`);this.writeI8($.type),this.writeU8a($.data)}writeU8($){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,$),this.pos++}writeU8a($){let Z=$.length;this.ensureBufferSizeToWrite(Z),this.bytes.set($,this.pos),this.pos+=Z}writeI8($){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,$),this.pos++}writeU16($){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,$),this.pos+=2}writeI16($){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,$),this.pos+=2}writeU32($){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,$),this.pos+=4}writeI32($){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,$),this.pos+=4}writeF32($){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,$),this.pos+=4}writeF64($){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,$),this.pos+=8}writeU64($){this.ensureBufferSizeToWrite(8),S0(this.view,this.pos,$),this.pos+=8}writeI64($){this.ensureBufferSizeToWrite(8),k(this.view,this.pos,$),this.pos+=8}writeBigUint64($){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,$),this.pos+=8}writeBigInt64($){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,$),this.pos+=8}}var S$=100,_$=2048;var B0=H(()=>{I();E()});function N($,Z){return new w(Z).encodeSharedRef($)}var A0=H(()=>{B0()});function j($){return`${$<0?"-":""}0x${Math.abs($).toString(16).padStart(2,"0")}`}class n{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor($=C$,Z=O$){this.maxKeyLength=$,this.maxLengthPerKey=Z,this.caches=[];for(let Q=0;Q<this.maxKeyLength;Q++)this.caches.push([])}canBeCached($){return $>0&&$<=this.maxKeyLength}find($,Z,Q){let J=this.caches[Q-1];$:for(let W of J){let q=W.bytes;for(let F=0;F<Q;F++)if(q[F]!==$[Z+F])continue $;return W.str}return null}store($,Z){let Q=this.caches[$.length-1],J={bytes:$,str:Z};if(Q.length>=this.maxLengthPerKey)Q[Math.random()*Q.length|0]=J;else Q.push(J)}decode($,Z,Q){let J=this.find($,Z,Q);if(J!=null)return this.hit++,J;this.miss++;let W=l($,Z,Q),q=Uint8Array.prototype.slice.call($,Z,Z+Q);return this.store(q,W),W}}var C$=16,O$=16;var z0=H(()=>{I()});class L0{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState($){let Z=this.getUninitializedStateFromPool();Z.type=d,Z.position=0,Z.size=$,Z.array=Array($)}pushMapState($){let Z=this.getUninitializedStateFromPool();Z.type=L,Z.readCount=0,Z.size=$,Z.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){let $={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push($)}return this.stack[this.stackHeadPosition]}release($){if(this.stack[this.stackHeadPosition]!==$)throw Error("Invalid stack state. Released state is not on top of the stack.");if($.type===d){let Q=$;Q.size=0,Q.array=void 0,Q.position=0,Q.type=void 0}if($.type===L||$.type===D0){let Q=$;Q.size=0,Q.map=void 0,Q.readCount=0,Q.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}}class h{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=i;bytes=A$;headByte=D;stack=new L0;entered=!1;constructor($){this.extensionCodec=$?.extensionCodec??R.defaultCodec,this.context=$?.context,this.useBigInt64=$?.useBigInt64??!1,this.rawStrings=$?.rawStrings??!1,this.maxStrLength=$?.maxStrLength??_,this.maxBinLength=$?.maxBinLength??_,this.maxArrayLength=$?.maxArrayLength??_,this.maxMapLength=$?.maxMapLength??_,this.maxExtLength=$?.maxExtLength??_,this.keyDecoder=$?.keyDecoder!==void 0?$.keyDecoder:z$,this.mapKeyConverter=$?.mapKeyConverter??B$}clone(){return new h({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=D,this.stack.reset()}setBuffer($){let Z=T($);this.bytes=Z,this.view=new DataView(Z.buffer,Z.byteOffset,Z.byteLength),this.pos=0}appendBuffer($){if(this.headByte===D&&!this.hasRemaining(1))this.setBuffer($);else{let Z=this.bytes.subarray(this.pos),Q=T($),J=new Uint8Array(Z.length+Q.length);J.set(Z),J.set(Q,Z.length),this.setBuffer(J)}}hasRemaining($){return this.view.byteLength-this.pos>=$}createExtraByteError($){let{view:Z,pos:Q}=this;return RangeError(`Extra ${Z.byteLength-Q} of ${Z.byteLength} byte(s) found at buffer[${$}]`)}decode($){if(this.entered)return this.clone().decode($);try{this.entered=!0,this.reinitializeState(),this.setBuffer($);let Z=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return Z}finally{this.entered=!1}}*decodeMulti($){if(this.entered){yield*this.clone().decodeMulti($);return}try{this.entered=!0,this.reinitializeState(),this.setBuffer($);while(this.hasRemaining(1))yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync($){if(this.entered)return this.clone().decodeAsync($);try{this.entered=!0;let Z=!1,Q;for await(let F of $){if(Z)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(F);try{Q=this.doDecodeSync(),Z=!0}catch(K){if(!(K instanceof RangeError))throw K}this.totalPos+=this.pos}if(Z){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return Q}let{headByte:J,pos:W,totalPos:q}=this;throw RangeError(`Insufficient data in parsing ${j(J)} at ${q} (${W} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream($){return this.decodeMultiAsync($,!0)}decodeStream($){return this.decodeMultiAsync($,!1)}async*decodeMultiAsync($,Z){if(this.entered){yield*this.clone().decodeMultiAsync($,Z);return}try{this.entered=!0;let Q=Z,J=-1;for await(let W of $){if(Z&&J===0)throw this.createExtraByteError(this.totalPos);if(this.appendBuffer(W),Q)J=this.readArraySize(),Q=!1,this.complete();try{while(!0)if(yield this.doDecodeSync(),--J===0)break}catch(q){if(!(q instanceof RangeError))throw q}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){$:while(!0){let $=this.readHeadByte(),Z;if($>=224)Z=$-256;else if($<192)if($<128)Z=$;else if($<144){let J=$-128;if(J!==0){this.pushMapState(J),this.complete();continue $}else Z={}}else if($<160){let J=$-144;if(J!==0){this.pushArrayState(J),this.complete();continue $}else Z=[]}else{let J=$-160;Z=this.decodeString(J,0)}else if($===192)Z=null;else if($===194)Z=!1;else if($===195)Z=!0;else if($===202)Z=this.readF32();else if($===203)Z=this.readF64();else if($===204)Z=this.readU8();else if($===205)Z=this.readU16();else if($===206)Z=this.readU32();else if($===207)if(this.useBigInt64)Z=this.readU64AsBigInt();else Z=this.readU64();else if($===208)Z=this.readI8();else if($===209)Z=this.readI16();else if($===210)Z=this.readI32();else if($===211)if(this.useBigInt64)Z=this.readI64AsBigInt();else Z=this.readI64();else if($===217){let J=this.lookU8();Z=this.decodeString(J,1)}else if($===218){let J=this.lookU16();Z=this.decodeString(J,2)}else if($===219){let J=this.lookU32();Z=this.decodeString(J,4)}else if($===220){let J=this.readU16();if(J!==0){this.pushArrayState(J),this.complete();continue $}else Z=[]}else if($===221){let J=this.readU32();if(J!==0){this.pushArrayState(J),this.complete();continue $}else Z=[]}else if($===222){let J=this.readU16();if(J!==0){this.pushMapState(J),this.complete();continue $}else Z={}}else if($===223){let J=this.readU32();if(J!==0){this.pushMapState(J),this.complete();continue $}else Z={}}else if($===196){let J=this.lookU8();Z=this.decodeBinary(J,1)}else if($===197){let J=this.lookU16();Z=this.decodeBinary(J,2)}else if($===198){let J=this.lookU32();Z=this.decodeBinary(J,4)}else if($===212)Z=this.decodeExtension(1,0);else if($===213)Z=this.decodeExtension(2,0);else if($===214)Z=this.decodeExtension(4,0);else if($===215)Z=this.decodeExtension(8,0);else if($===216)Z=this.decodeExtension(16,0);else if($===199){let J=this.lookU8();Z=this.decodeExtension(J,1)}else if($===200){let J=this.lookU16();Z=this.decodeExtension(J,2)}else if($===201){let J=this.lookU32();Z=this.decodeExtension(J,4)}else throw new Y(`Unrecognized type byte: ${j($)}`);this.complete();let Q=this.stack;while(Q.length>0){let J=Q.top();if(J.type===d)if(J.array[J.position]=Z,J.position++,J.position===J.size)Z=J.array,Q.release(J);else continue $;else if(J.type===L){if(Z==="__proto__")throw new Y("The key __proto__ is not allowed");J.key=this.mapKeyConverter(Z),J.type=D0;continue $}else if(J.map[J.key]=Z,J.readCount++,J.readCount===J.size)Z=J.map,Q.release(J);else{J.key=null,J.type=L;continue $}}return Z}}readHeadByte(){if(this.headByte===D)this.headByte=this.readU8();return this.headByte}complete(){this.headByte=D}readArraySize(){let $=this.readHeadByte();switch($){case 220:return this.readU16();case 221:return this.readU32();default:if($<160)return $-144;else throw new Y(`Unrecognized array type byte: ${j($)}`)}}pushMapState($){if($>this.maxMapLength)throw new Y(`Max length exceeded: map length (${$}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState($)}pushArrayState($){if($>this.maxArrayLength)throw new Y(`Max length exceeded: array length (${$}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState($)}decodeString($,Z){if(!this.rawStrings||this.stateIsMapKey())return this.decodeUtf8String($,Z);return this.decodeBinary($,Z)}decodeUtf8String($,Z){if($>this.maxStrLength)throw new Y(`Max length exceeded: UTF-8 byte length (${$}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+Z+$)throw T0;let Q=this.pos+Z,J;if(this.stateIsMapKey()&&this.keyDecoder?.canBeCached($))J=this.keyDecoder.decode(this.bytes,Q,$);else J=U0(this.bytes,Q,$);return this.pos+=Z+$,J}stateIsMapKey(){if(this.stack.length>0)return this.stack.top().type===L;return!1}decodeBinary($,Z){if($>this.maxBinLength)throw new Y(`Max length exceeded: bin length (${$}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining($+Z))throw T0;let Q=this.pos+Z,J=this.bytes.subarray(Q,Q+$);return this.pos+=Z+$,J}decodeExtension($,Z){if($>this.maxExtLength)throw new Y(`Max length exceeded: ext length (${$}) > maxExtLength (${this.maxExtLength})`);let Q=this.view.getInt8(this.pos+Z),J=this.decodeBinary($,Z+1);return this.extensionCodec.decode(J,Q,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let $=this.view.getUint8(this.pos);return this.pos++,$}readI8(){let $=this.view.getInt8(this.pos);return this.pos++,$}readU16(){let $=this.view.getUint16(this.pos);return this.pos+=2,$}readI16(){let $=this.view.getInt16(this.pos);return this.pos+=2,$}readU32(){let $=this.view.getUint32(this.pos);return this.pos+=4,$}readI32(){let $=this.view.getInt32(this.pos);return this.pos+=4,$}readU64(){let $=_0(this.view,this.pos);return this.pos+=8,$}readI64(){let $=m(this.view,this.pos);return this.pos+=8,$}readU64AsBigInt(){let $=this.view.getBigUint64(this.pos);return this.pos+=8,$}readI64AsBigInt(){let $=this.view.getBigInt64(this.pos);return this.pos+=8,$}readF32(){let $=this.view.getFloat32(this.pos);return this.pos+=4,$}readF64(){let $=this.view.getFloat64(this.pos);return this.pos+=8,$}}var d="array",L="map_key",D0="map_value",B$=($)=>{if(typeof $==="string"||typeof $==="number")return $;throw new Y("The type of key must be string or number but "+typeof $)},D=-1,i,A$,T0,z$;var x0=H(()=>{E();I();z0();u();i=new DataView(new ArrayBuffer(0)),A$=new Uint8Array(i.buffer);try{i.getInt8(0)}catch($){if(!($ instanceof RangeError))throw Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}T0=RangeError("Insufficient data"),z$=new n});function M($,Z){return new h(Z).decode($)}var I0=H(()=>{x0()});var g=H(()=>{A0();I0();E()});function r($){if(typeof $==="object"&&$!==null&&!Array.isArray($))return $;return{}}function b($){return Array.isArray($)?$:[]}function k0($){if(!($ instanceof Date))return null;let Z=new ArrayBuffer(8);return new DataView(Z).setFloat64(0,$.getTime()),new Uint8Array(Z)}function m0($){let Z=new DataView($.buffer,$.byteOffset,$.byteLength).getFloat64(0);return new Date(Z)}function g6($){return typeof $==="string"&&D$.has($)}var s,T$,D$;var E0=H(()=>{s=class s extends Error{code;constructor($,Z,Q){super(Z,Q);this.code=$,this.name=$}};T$={WorkflowAlreadyExistsError:!0,BulkDeleteRequiresTerminalWorkflowsError:!0,BulkOperationConfirmationError:!0,WorkflowTypeNotRegisteredForRecoveryError:!0,EngineCreateNameMismatchError:!0,EngineDisposedError:!0,WorkflowNotFoundError:!0,WorkflowNotRegisteredError:!0,WorkflowConcurrencyLimitExceededError:!0,WorkflowSuspendNotSupportedError:!0,ActivityResolutionError:!0,BranchTopologyChangedError:!0,PersistedDataIncompatibleError:!0,WorkflowTimeoutError:!0,HttpClientError:!0,WorkerProtocolIncompatibleError:!0,UpdateTimeoutError:!0,UpdateValidationError:!0,WorkflowTerminalError:!0,WorkflowBuilderError:!0,VersionMismatchError:!0,EffectReplayConflictError:!0,ReviewTimeoutError:!0,AtomicStateConflictError:!0,StandardSchemaValidationError:!0,ActivityReconciliationCapabilityError:!0,ActivityReconciliationConflictError:!0,ActivityReconciliationIndeterminateError:!0,AsyncActivityTokenNotFoundError:!0,ActivityScheduleToCloseTimeoutError:!0,ActivityPerAttemptTimeoutError:!0,PayloadSizeExceededError:!0,StartOrSignalConflictError:!0,WorkflowTeardownPendingError:!0,IdempotencyKeyPurgedError:!0},D$=new Set(Object.keys(T$))});function a($){return w0.has($.constructor)}function j0($,Z){$.register({type:L$,encode(Q){if(typeof Q!=="object"||Q===null)return null;let J=w0.get(Q.constructor);if(J===void 0)return null;let W=Z(J.handlers.toJSON(Q),new Set);return N({tag:J.tag,data:W},{extensionCodec:$})},decode(Q){let J=M(Q,{extensionCodec:$});if(typeof J!=="object"||J===null||!("tag"in J))throw Error("Corrupt custom-serializer payload: missing tag.");let{tag:W,data:q}=J;if(typeof W!=="string")throw Error("Corrupt custom-serializer payload: tag is not a string.");let F=x$.get(W);if(F===void 0)throw Error(`No serializer registered for tag "${W}". Register it (with the same tag) before decoding a checkpoint that used it.`);return F.handlers.fromJSON(q)}})}var L$=100,w0,x$;var h0=H(()=>{g();w0=new Map,x$=new Map});function h$($,Z){if(Z<=200)return JSON.stringify($);return`${Z}-byte string starting ${JSON.stringify($.slice(0,120))}`}function g$($,Z){let Q=j$.encode($).byteLength;if(Q>g0)throw new t({source:$,flags:Z,sourceByteLength:Q,reason:`because source exceeds the ${g0}-byte limit.`});try{return new RegExp($,Z)}catch(J){let W=J instanceof Error?J.message:String(J);throw new t({source:$,flags:Z,sourceByteLength:Q,reason:`because ${W}`,cause:J})}}function y$($){return typeof $==="object"&&$!==null&&"__tag"in $&&$.__tag===b0}function e($,Z){if(!O($,Z))return $;return C($,new Set)}function C($,Z){if($===void 0)return b$;if($===null||typeof $!=="object")return $;if(Z.has($))return $;Z.add($);try{return f$($,Z)}finally{Z.delete($)}}function f$($,Z){if(Array.isArray($))return v$($,Z);if($ instanceof Map)return p$($,Z);if($ instanceof Set)return c$($,Z);if(y0($))return $;return l$($,Z)}function v$($,Z){let Q=Array.from({length:$.length});for(let J=0;J<$.length;J++)Q[J]=C($[J],Z);return Q}function p$($,Z){let Q=new Map;for(let[J,W]of $)Q.set(C(J,Z),C(W,Z));return Q}function c$($,Z){let Q=new Set;for(let J of $)Q.add(C(J,Z));return Q}function y0($){return $ instanceof Date||$ instanceof RegExp||$ instanceof Error||$ instanceof Uint8Array||$ instanceof ArrayBuffer||a($)}function l$($,Z){let Q=$,J={};for(let W of Object.keys(Q))J[W]=C(Q[W],Z);return J}function O($,Z){if($===void 0)return!0;if($===null||typeof $!=="object")return!1;if(Z.has($))return!1;if(y0($))return!1;Z.add($);try{if(Array.isArray($))return u$($,Z);if($ instanceof Map)return n$($,Z);if($ instanceof Set)return d$($,Z);return i$($,Z)}finally{Z.delete($)}}function u$($,Z){for(let Q=0;Q<$.length;Q++)if(O($[Q],Z))return!0;return!1}function n$($,Z){for(let[Q,J]of $)if(O(Q,Z)||O(J,Z))return!0;return!1}function d$($,Z){for(let Q of $)if(O(Q,Z))return!0;return!1}function i$($,Z){let Q=$;for(let J of Object.keys(Q))if(O(Q[J],Z))return!0;return!1}var I$=1,o=2,k$=3,m$=4,E$=5,w$=6,g0=65535,j$,t,V,b0,b$;var f0=H(()=>{g();E0();h0();j$=new TextEncoder;t=class t extends s{extensionType;source;flags;sourceByteLength;constructor($){super("RegExpExtensionDecodeError",`RegExp extension type ${o} could not be decoded: source=${h$($.source,$.sourceByteLength)} flags=${JSON.stringify($.flags)} ${$.reason}`,$.cause===void 0?void 0:{cause:$.cause});this.extensionType=o,this.source=$.source,this.flags=$.flags,this.sourceByteLength=$.sourceByteLength}};V=new R;j0(V,e);V.register({type:I$,encode:k0,decode:m0});V.register({type:o,encode($){if($ instanceof RegExp)return N({source:$.source,flags:$.flags});return null},decode($){let Z=r(M($)),Q=typeof Z.source==="string"?Z.source:"",J=typeof Z.flags==="string"?Z.flags:"";return g$(Q,J)}});V.register({type:k$,encode($){if($ instanceof Map){let Z=[...$.entries()];return N(Z,{extensionCodec:V})}return null},decode($){let Q=b(M($,{extensionCodec:V})).map((J)=>{let W=b(J);return[W[0],W[1]]});return new Map(Q)}});V.register({type:m$,encode($){if($ instanceof Set){let Z=[...$.values()];return N(Z,{extensionCodec:V})}return null},decode($){let Z=b(M($,{extensionCodec:V}));return new Set(Z)}});b0=Symbol("UndefinedSentinel"),b$=Object.freeze({__tag:b0});V.register({type:E$,encode($){if(y$($))return new Uint8Array(0);return null},decode(){return}});V.register({type:w$,encode($){if($ instanceof Error&&!a($))return N({name:$.name,message:$.message,stack:$.stack});return null},decode($){let Z=r(M($)),Q=typeof Z.name==="string"?Z.name:"Error",J=typeof Z.message==="string"?Z.message:"",W=typeof Z.stack==="string"?Z.stack:void 0,q=Error(J);if(q.name=Q,W!==void 0)q.stack=W;return q}})});function $0($){let Z=e($,new Set);return N(Z,{extensionCodec:V})}function Z0($){return M($,{extensionCodec:V})}var v0=H(()=>{g();f0()});function y($,Z=""){let Q=[];return x($,Z,Q,new Set),{valid:Q.length===0,errors:Q}}function r$($){let Z=Object.getPrototypeOf($);return s$(Z)&&!a$($)&&o$(Z)}function s$($){return $!==Object.prototype&&$!==null}function a$($){return Array.isArray($)||$ instanceof Date||$ instanceof RegExp||$ instanceof Map||$ instanceof Set||$ instanceof Error||$ instanceof Uint8Array||$ instanceof ArrayBuffer}function o$($){if(typeof $!=="object"||$===null)return!1;return Object.getOwnPropertyNames($).some((Q)=>{if(Q==="constructor")return!1;let J=Object.getOwnPropertyDescriptor($,Q);return J!==void 0&&typeof J.value==="function"})}function p0($,Z,Q,J){$.push({path:Z,value:Q,reason:J.reason,suggestion:J.suggestion})}function t$($){if(typeof $==="function")return{reason:"Functions cannot be serialized.",suggestion:"Move this into ctx.run() or reconstruct it on resume."};if(typeof $==="symbol")return{reason:"Symbols cannot be serialized.",suggestion:"Use a string identifier instead of a Symbol."};return null}function e$($,Z){if($ instanceof WeakRef)return{reason:"WeakRef cannot be serialized.",suggestion:"Store the referenced value directly instead of using a WeakRef."};if($ instanceof WeakMap)return{reason:"WeakMap cannot be serialized.",suggestion:"Use a Map instead of a WeakMap."};if($ instanceof WeakSet)return{reason:"WeakSet cannot be serialized.",suggestion:"Use a Set instead of a WeakSet."};if(Z.has($))return{reason:"Circular reference detected.",suggestion:"Remove the circular reference or restructure the data."};if(r$($))return{reason:"Class instances with methods cannot be serialized.",suggestion:"Store only the data and reconstruct the instance."};return null}function $1($){return $ instanceof Date||$ instanceof RegExp||$ instanceof Error||$ instanceof Uint8Array||$ instanceof ArrayBuffer}function Z1($,Z,Q,J){for(let[W,q]of $){let F=String(W);x(q,Z?`${Z}.${F}`:F,Q,J)}}function Q1($,Z,Q,J){let W=0;for(let q of $){let F=Z?`${Z}[${W}]`:`[${W}]`;x(q,F,Q,J),W++}}function J1($,Z,Q,J){for(let W=0;W<$.length;W++){let q=Z?`${Z}[${W}]`:`[${W}]`;x($[W],q,Q,J)}}function W1($,Z,Q,J){for(let W of Object.keys($)){let q=Z?`${Z}.${W}`:W;x($[W],q,Q,J)}}function x($,Z,Q,J){if($===null||$===void 0)return;let W=t$($);if(W){p0(Q,Z,$,W);return}if(typeof $!=="object")return;let q=e$($,J);if(q){p0(Q,Z,$,q);return}J.add($);try{if($1($))return;if($ instanceof Map){Z1($,Z,Q,J);return}if($ instanceof Set){Q1($,Z,Q,J);return}if(Array.isArray($)){J1($,Z,Q,J);return}W1($,Z,Q,J)}finally{J.delete($)}}var c0=H(()=>{v0()});var l0=H(()=>{c0()});function G1($){if($===void 0)return;if(typeof $!=="number"||!Number.isInteger($)||$<0)throw Error("deleteRange limit must be a finite non-negative integer");return $===0?0:$}function q1($){let Z={},Q=!1;for(let W of["gt","gte","lt","lte"]){let q=$[W];if(q===void 0)continue;if(typeof q!=="string")throw Error("deleteRange bounds must be strings");Z[W]=q,Q=!0}if(!Q)throw Error("deleteRange requires at least one of gt/gte/lt/lte; use deletePrefix to delete a whole prefix");let J=G1($.limit);if(J!==void 0)Z.limit=J;return Z}async function u0($,Z,Q){let J=q1(Q);if($.deleteRange)return $.deleteRange(Z,J);return G0($,Z,J)}var n0=()=>{};l0();n0();N0();class d0{#$;#Z;#Q;constructor($,Z,Q={}){this.#$=$,this.#Z=Z,this.#Q=Q.disposeUnderlyingStorage??!0}async get($){let Z=await this.#$.get($);return Z===null?null:this.#Z.decode(Z)}async put($,Z){await this.#$.put($,this.#Z.encode(Z))}async delete($){await this.#$.delete($)}async*scan($,Z){for await(let[Q,J]of this.#$.scan($,Z))yield[Q,this.#Z.decode(J)]}async batch($){z("batch operations",$.length),await this.#$.batch(this.#J($))}#J($){return $.map((Q)=>{if(Q.type==="put")return{type:"put",key:Q.key,value:this.#Z.encode(Q.value)};return Q})}#W($){return $.map((Z)=>({key:Z.key,expectedValue:Z.expectedValue===null?null:this.#Z.encode(Z.expectedValue)}))}async conditionalBatch($,Z){return P0(this.#$,this.#W($),this.#J(Z))}async has($){return H0(this.#$,$)}async deletePrefix($){return V0(this.#$,$)}async deleteRange($,Z){return u0(this.#$,$,Z)}keys($,Z){return X0(this.#$,$,Z)}async count($){return Y0(this.#$,$)}[Symbol.dispose](){if(!this.#Q)return;this.#$[Symbol.dispose]()}}function q8($,Z,Q={}){return new d0($,Z,Q)}function F1($){try{let Z=JSON.stringify($);if(Z===void 0)throw TypeError("jsonCodec only supports JSON-serializable values.");return new TextEncoder().encode(Z)}catch(Z){throw TypeError("jsonCodec only supports JSON-serializable values.",{cause:Z})}}function K1($){let Z=y($);if(!Z.valid)throw TypeError(`msgpackCodec only supports structuredClone-compatible values. ${Z.errors[0]?.reason??""}`.trim());return $0($)}function H1($){return JSON.parse(new TextDecoder().decode($))}function X1($){let Z=Z0($),Q=y(Z);if(!Q.valid)throw TypeError(`msgpackCodec decoded a non-cloneable value. ${Q.errors[0]?.reason??""}`.trim());return Z}function F8($){return{encode(Z){return F1(Z)},decode(Z){let Q=H1(Z);return $?$(Q):Q}}}function K8($){return{encode(Z){return K1(Z)},decode(Z){let Q=X1(Z);return $?$(Q):Q}}}export{q8 as withCodec,K8 as msgpackCodec,F8 as jsonCodec};
|