@lostgradient/weft 0.9.0 → 0.11.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 +12 -4
- package/dist/alerting/alert-manager.d.ts +3 -1
- package/dist/alerting/alert-manager.js +5 -2
- package/dist/cli-main.js +63 -63
- package/dist/core/checkpoint/serialization.js +2 -2
- package/dist/core/context/index.d.ts +2 -1
- package/dist/core/context/index.js +8 -0
- package/dist/core/context/operation-request.d.ts +2 -0
- package/dist/core/context/parallel-cache-entry.d.ts +1 -1
- package/dist/core/context/parallel-cache-entry.js +12 -8
- package/dist/core/context/parallel-operations.d.ts +1 -1
- package/dist/core/context/parallel-operations.js +50 -8
- package/dist/core/engine/async-activity-completion.d.ts +24 -54
- package/dist/core/engine/async-activity-completion.js +25 -90
- package/dist/core/engine/async-activity-records.d.ts +106 -0
- package/dist/core/engine/async-activity-records.js +124 -0
- package/dist/core/engine/bulk-operations-purge.js +2 -1
- package/dist/core/engine/callback-creators-core.js +1 -0
- package/dist/core/engine/construction.d.ts +1 -3
- package/dist/core/engine/construction.js +2 -5
- package/dist/core/engine/deferred-consume-envelope.d.ts +10 -1
- package/dist/core/engine/deferred-consume-envelope.js +9 -1
- package/dist/core/engine/disposal.js +4 -0
- package/dist/core/engine/engine-internal-types.d.ts +1 -0
- package/dist/core/engine/engine-leak-warnings.d.ts +2 -0
- package/dist/core/engine/engine-leak-warnings.js +7 -1
- package/dist/core/engine/engine-runtime-helpers.d.ts +8 -0
- package/dist/core/engine/engine-runtime-helpers.js +9 -0
- package/dist/core/engine/errors.js +1 -1
- package/dist/core/engine/index.d.ts +18 -5
- package/dist/core/engine/index.js +41 -10
- package/dist/core/engine/inline-parking.js +14 -1
- package/dist/core/engine/internals.d.ts +23 -2
- package/dist/core/engine/lifecycle/recovered-services.d.ts +4 -2
- package/dist/core/engine/lifecycle/recovered-services.js +37 -7
- package/dist/core/engine/lifecycle/resume.d.ts +2 -2
- package/dist/core/engine/lifecycle/resume.js +39 -7
- package/dist/core/engine/lifecycle/shared.d.ts +34 -0
- package/dist/core/engine/lifecycle/transition.d.ts +1 -1
- package/dist/core/engine/lifecycle/transition.js +3 -3
- package/dist/core/engine/lifecycle.d.ts +1 -1
- package/dist/core/engine/memo-durable-activity.js +7 -9
- package/dist/core/engine/operations-activity.js +1 -1
- package/dist/core/engine/operations-coordination.d.ts +15 -1
- package/dist/core/engine/operations-coordination.js +43 -10
- package/dist/core/engine/operations-time.js +8 -28
- package/dist/core/engine/ownership-options.d.ts +1 -0
- package/dist/core/engine/ownership-options.js +14 -0
- package/dist/core/engine/retention.js +4 -0
- package/dist/core/engine/schedule-run-metadata.d.ts +3 -0
- package/dist/core/engine/schedule-run-metadata.js +29 -0
- package/dist/core/engine/schedule-run.js +19 -4
- package/dist/core/engine/schedules.js +4 -3
- package/dist/core/engine/sleep-timer-acknowledgements.d.ts +15 -0
- package/dist/core/engine/sleep-timer-acknowledgements.js +144 -0
- package/dist/core/engine/sub-operation.js +6 -13
- package/dist/core/engine/termination/cleanup.js +6 -1
- package/dist/core/types/options.d.ts +12 -0
- package/dist/core/types/services-resolution.d.ts +8 -3
- package/dist/core/types/workflow-builder.d.ts +2 -2
- package/dist/core/types/workflow-context.d.ts +27 -0
- package/dist/index.d.ts +2 -2
- package/dist/mcp/cli.js +17 -17
- package/dist/server/authorization.d.ts +3 -3
- package/dist/server/fault-to-json-rpc.d.ts +2 -1
- package/dist/server/handler.js +22 -22
- package/dist/server/index.js +17 -17
- package/dist/server/json-rpc-dispatch.d.ts +2 -2
- package/dist/server/json-rpc-parse.d.ts +1 -1
- package/dist/server/json-rpc-protocol.d.ts +2 -2
- package/dist/server/json-rpc-websocket.d.ts +1 -1
- package/dist/server/operation-fault.d.ts +3 -1
- package/dist/server/operations/async-activity.js +2 -2
- package/dist/server/principal.d.ts +2 -2
- package/dist/server/stdio-session.d.ts +4 -4
- package/dist/service-worker/index.js +13 -13
- package/dist/service-worker/scheduler.js +1 -0
- package/dist/storage/compressed-storage.js +1 -1
- package/dist/storage/http.js +2 -2
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/indexeddb.js +1 -1
- package/dist/storage/interface.d.ts +1 -0
- package/dist/storage/interface.js +1 -1
- package/dist/storage/lazy-postgres-pool.d.ts +38 -0
- package/dist/storage/lazy-postgres-pool.js +38 -0
- package/dist/storage/lmdb.js +1 -1
- package/dist/storage/memory.js +1 -1
- package/dist/storage/neon-batch.d.ts +8 -8
- package/dist/storage/neon.d.ts +26 -79
- package/dist/storage/neon.js +3 -3
- package/dist/storage/postgres-key-value-queries.d.ts +1 -1
- package/dist/storage/postgres-key-value-queries.js +1 -1
- package/dist/storage/postgres-key-value-storage.d.ts +110 -0
- package/dist/storage/postgres-key-value-storage.js +204 -0
- package/dist/storage/postgres.d.ts +59 -0
- package/dist/storage/postgres.js +15 -0
- package/dist/storage/resolve.js +1 -1
- package/dist/storage/scoped-storage.js +1 -1
- package/dist/storage/testing.js +1 -1
- package/dist/storage/turso.js +1 -1
- package/dist/storage/typed-storage.js +1 -1
- package/dist/storage/web-extension.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 +17 -4
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var a0=Object.defineProperty;var o0=($)=>$;function t0($,Z){this[$]=o0.bind(null,Z)}var _6=($,Z)=>{for(var Q in Z)a0($,Q,{get:Z[Q],enumerable:!0,configurable:!0,set:t0.bind(Z,Q)})};var J=($,Z)=>()=>($&&(Z=$($=0)),Z);var C6=import.meta.require,S6=($,Z,Q)=>{if(Z!=null){if(typeof Z!=="object"&&typeof Z!=="function")throw TypeError('Object expected to be assigned to "using" declaration');let W;if(Q)W=Z[Symbol.asyncDispose];if(W===void 0)W=Z[Symbol.dispose];if(typeof W!=="function")throw TypeError("Object not disposable");$.push([Q,W,Z])}else if(Q)$.push([Q]);return Z},B6=($,Z,Q)=>{let W=(F)=>Z=Q?new SuppressedError(F,Z,"An error was suppressed during disposal"):(Q=!0,F),G=(F)=>{while(F=$.pop())try{var K=F[1]&&F[1].call(F[2]);if(F[0])return Promise.resolve(K).then(G,(H)=>(W(H),G()))}catch(H){W(H)}if(Q)throw Z};return G()};function p($,Z,Q){if(!$.capabilities()[Z])throw Error(`Feature "${Q}" requires storage capability "${Z}", but this storage backend does not provide it.`)}function e0($){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 c="default";async function G0($,Z){return await $.get(Z)!==null}async function*O($,Z,Q){for await(let[W]of $.scan(Z,Q))yield W}async function q0($,Z){let Q=0;for await(let W of O($,Z))Q++;return Q}async function F0($,Z){let Q=[];for await(let W of O($,Z))Q.push({type:"delete",key:W});if(Q.length===0)return 0;return await $.batch(Q),Q.length}async function K0($,Z,Q){let W=[];for await(let G of O($,Z,Q))W.push({type:"delete",key:G});if(W.length===0)return 0;return await $.batch(W),W.length}var $$;var H0=J(()=>{$$=["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>l)throw new X0($,Z)}function k6($){return $.length>0?$.slice(0,-1)+String.fromCharCode($.charCodeAt($.length-1)+1):"\xFF"}function m6($,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 w6($,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 Y0($,Z){if($.has)return $.has(Z);return G0($,Z)}function V0($,Z,Q){if($.keys)return $.keys(Z,Q);return O($,Z,Q)}async function P0($,Z){if($.count)return $.count(Z);return q0($,Z)}async function M0($,Z){if($.deletePrefix)return $.deletePrefix(Z);return F0($,Z)}async function j6($,Z){z("batch operations",Z.length),await $.batch(Z)}async function N0($,Z,Q){if(z("conditionalBatch conditions",Z.length),z("conditionalBatch operations",Q.length),p($,"conditionalBatch","storageConditionalBatch"),!$.conditionalBatch)throw Error("This storage backend reports conditionalBatch capability but does not implement the conditionalBatch() method.");return $.conditionalBatch(Z,Q)}function q($){return encodeURIComponent($)}function h6($){return decodeURIComponent($)}function g6($){try{return decodeURIComponent($)}catch{return null}}var l=1e4,E6=1e4,X0,P=($)=>String($).padStart(16,"0"),Z$="0",Q$="1",J0=($,Z,Q,W)=>`sig:${q($)}:${q(Z)}:${W}:${q(Q)}`,b6;var R0=J(()=>{H0();X0=class X0 extends Error{code="StorageBatchOperationLimitExceededError";cap=l;count;target;constructor($,Z){super(`${$} count ${Z} exceeds MAX_BATCH_OPERATIONS (${l}).`);this.name="StorageBatchOperationLimitExceededError",this.target=$,this.count=Z}};b6={workflow:($)=>`wf:${q($)}`,checkpoint:($)=>`wf:${q($)}:ckpt`,checkpointHistory:($,Z)=>`wf:${q($)}:ckpt:${String(Z).padStart(10,"0")}`,timelinePrefix:($)=>`wf:${q($)}:timeline:`,timeline:($,Z)=>`wf:${q($)}:timeline:${String(Z).padStart(10,"0")}`,schedule:($)=>`schedule:${q($)}`,scheduleTick:($,Z)=>`schedule-due:${String($).padStart(16,"0")}:${q(Z)}`,scheduleRun:($)=>`schedule-run:${q($)}`,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($)}:${q(Z)}:${q(Q)}`,operationResolvedByTimePrefix:()=>"op:resolved-by-time:",operationResolvedByTime:($,Z)=>`op:resolved-by-time:${P($)}:${q(Z)}`,asyncActivity:($,Z)=>`async-act:v1:${q($)}:${q(Z)}`,activityReconciliationPrefix:($)=>`actrec:v1:${q($)}:`,activityReconciliation:($,Z,Q)=>`actrec:v1:${q($)}:${q(Z)}:${Q}`,eventPrefix:($)=>`ev:${q($)}:`,event:($,Z)=>`ev:${q($)}:${String(Z).padStart(10,"0")}`,eventHead:($)=>`ev:${q($)}:head`,eventWatermark:($)=>`ev:${q($)}:watermark`,fleetEventPrefix:()=>"fleet-event:",fleetEvent:($)=>`fleet-event:${String($).padStart(10,"0")}`,fleetEventTail:()=>"fleet-event-tail",fleetEventByWorkflowPrefix:($)=>`fleet-event-by-workflow:${q($)}:`,fleetEventByWorkflow:($,Z)=>`fleet-event-by-workflow:${q($)}:${String(Z).padStart(10,"0")}`,signal:($,Z,Q)=>J0($,Z,Q,Q$),startSignal:($,Z,Q)=>J0($,Z,Q,Z$),signalSequence:($)=>`sigseq:v1:${q($)}`,signalAcceptedResponsePrefix:($)=>`sigres:v1:${q($)}:`,signalAcceptedResponse:($,Z,Q)=>`sigres:v1:${q($)}:${q(Z)}:${q(Q)}`,deadline:($,Z)=>`wf-deadline:${P($)}:${q(Z)}`,terminalCleanup:($,Z)=>`wf-cleanup:${P($)}:${q(Z)}`,teardownTimer:($,Z)=>`wf-teardown:${P($)}:${q(Z)}`,delayedStart:($,Z)=>`wf-delayed:${P($)}:${q(Z)}`,terminalWorkflowPrefix:()=>"wf-terminal:",terminalWorkflow:($,Z)=>`wf-terminal:${P($)}:${q(Z)}`,attribute:($)=>`attr:${q($)}`,attributeIndex:($,Z,Q)=>`idx:${$}:${Z}:${q(Q)}`,tagIndex:($,Z)=>`tag:${q($)}:${q(Z)}`,updatePrefix:($)=>`upd:${q($)}:`,update:($,Z)=>`upd:${q($)}:${Z}`,updateResponse:($)=>`upr:${$}`,updateIdempotency:($,Z)=>`upk:${q($)}:${Z}`,startIdempotency:($)=>`start-idem:${q($)}`,startIdempotencySignalId:($)=>`start-idem:${$}`,livenessPrefix:()=>"liveness:",liveness:($)=>`liveness:${q($)}`,leasePrefix:()=>"lease:",leaseEpoch:()=>"lease:epoch",leaseHolder:()=>"lease:holder",budget:($,Z,Q)=>`budget:${$}:${Z}:${Q}`,review:($,Z)=>`review:${q($)}:${Z}`,workflowHeaders:($)=>`wf-headers:${q($)}`,childCancellationPrefix:($)=>`child-cancel:${q($)}:`,childCancellation:($,Z)=>`child-cancel:${q($)}:${q(Z)}`,terminalCleanupNeeded:($)=>`wf-cleanup-needed:${q($)}`,workflowConcurrency:($,Z)=>`wf-concurrency:${q($)}:${q(Z)}`,workflowConcurrencyHolder:($)=>`wf-concurrency-holder:${q($)}`,workflowHasServices:($)=>`wf-has-services:${q($)}`,finalizerState:($)=>`wf-finalizer-state:${q($)}`,teardownOwed:($)=>`wf-teardown-needed:${q($)}`,teardownDeadLetter:($)=>`wf-teardown-deadletter:${q($)}`,offload:($,Z)=>`offload:${q($)}:${Z}`,archive:($,Z)=>`archive:${q($)}:${Z}`,stateExecution:($,Z)=>`state:execution:${q($)}:${q(Z)}`,stateWorkflow:($,Z)=>`state:workflow-scope:${c}:${q($)}:${q(Z)}`,streamChunkPrefix:($,Z)=>`blob:${q($)}:${Z}:chunk:`,streamChunk:($,Z,Q)=>`blob:${q($)}:${Z}:chunk:${String(Q).padStart(10,"0")}`,streamTail:($,Z)=>`blob:${q($)}:${Z}:tail`,streamMetadata:($,Z)=>`blob:${q($)}:${Z}:meta`,budgetCharged:($)=>`budget-charged:${$}`,toolEffect:($,Z,Q)=>`tool-effect:${q($)}:${Z}:${Q}`,workflowVisibilityStatus:($,Z)=>`wf-idx-status:${q($)}:${q(Z)}`,workflowVisibilityType:($,Z)=>`wf-idx-type:${q($)}:${q(Z)}`,workflowVisibilityCreated:($,Z)=>`wf-idx-created:${P($)}:${q(Z)}`,workflowVisibilityUpdated:($,Z)=>`wf-idx-updated:${P($)}:${q(Z)}`,workflowVisibilityDeadline:($,Z)=>`wf-idx-deadline:${P($)}:${q(Z)}`,workflowVisibilityManifest:($)=>`wf-idx-manifest:${q($)}`,workflowVisibilityMetaVersion:()=>"wf-idx-meta:version",workflowVisibilityMetaBuiltAt:()=>"wf-idx-meta:built-at",workflowVisibilityMetaCursor:()=>"wf-idx-meta:cursor"}});function U0($){let Z=$.length,Q=0,W=0;while(W<Z){let G=$.charCodeAt(W++);if((G&4294967168)===0){Q++;continue}else if((G&4294965248)===0)Q+=2;else{if(G>=55296&&G<=56319){if(W<Z){let F=$.charCodeAt(W);if((F&64512)===56320)++W,G=((G&1023)<<10)+(F&1023)+65536}}if((G&4294901760)===0)Q+=3;else Q+=4}}return Q}function W$($,Z,Q){let W=$.length,G=Q,F=0;while(F<W){let K=$.charCodeAt(F++);if((K&4294967168)===0){Z[G++]=K;continue}else if((K&4294965248)===0)Z[G++]=K>>6&31|192;else{if(K>=55296&&K<=56319){if(F<W){let H=$.charCodeAt(F);if((H&64512)===56320)++F,K=((K&1023)<<10)+(H&1023)+65536}}if((K&4294901760)===0)Z[G++]=K>>12&15|224,Z[G++]=K>>6&63|128;else Z[G++]=K>>18&7|240,Z[G++]=K>>12&63|128,Z[G++]=K>>6&63|128}Z[G++]=K&63|128}}function F$($,Z,Q){G$.encodeInto($,Z.subarray(Q))}function _0($,Z,Q){if($.length>q$)F$($,Z,Q);else W$($,Z,Q)}function n($,Z,Q){let W=Z,G=W+Q,F=[],K="";while(W<G){let H=$[W++];if((H&128)===0)F.push(H);else if((H&224)===192){let A=$[W++]&63;F.push((H&31)<<6|A)}else if((H&240)===224){let A=$[W++]&63,v=$[W++]&63;F.push((H&31)<<12|A<<6|v)}else if((H&248)===240){let A=$[W++]&63,v=$[W++]&63,s0=$[W++]&63,U=(H&7)<<18|A<<12|v<<6|s0;if(U>65535)U-=65536,F.push(U>>>10&1023|55296),U=56320|U&1023;F.push(U)}else F.push(H);if(F.length>=K$)K+=String.fromCharCode(...F),F.length=0}if(F.length>0)K+=String.fromCharCode(...F);return K}function X$($,Z,Q){let W=$.subarray(Z,Z+Q);return H$.decode(W)}function C0($,Z,Q){if(Q>J$)return X$($,Z,Q);else return n($,Z,Q)}var G$,q$=50,K$=4096,H$,J$=200;var I=J(()=>{G$=new TextEncoder;H$=new TextDecoder});class _{type;data;constructor($,Z){this.type=$,this.data=Z}}var Y;var d=J(()=>{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 W=Q/4294967296,G=Q;$.setUint32(Z,W),$.setUint32(Z+4,G)}function E($,Z,Q){let W=Math.floor(Q/4294967296),G=Q;$.setUint32(Z,W),$.setUint32(Z+4,G)}function k($,Z){let Q=$.getInt32(Z),W=$.getUint32(Z+4);return Q*4294967296+W}function B0($,Z){let Q=$.getUint32(Z),W=$.getUint32(Z+4);return Q*4294967296+W}var C=4294967295;function M$({sec:$,nsec:Z}){if($>=0&&Z>=0&&$<=P$)if(Z===0&&$<=V$){let Q=new Uint8Array(4);return new DataView(Q.buffer).setUint32(0,$),Q}else{let Q=$/4294967296,W=$&4294967295,G=new Uint8Array(8),F=new DataView(G.buffer);return F.setUint32(0,Z<<2|Q&3),F.setUint32(4,W),G}else{let Q=new Uint8Array(12),W=new DataView(Q.buffer);return W.setUint32(0,Z),E(W,4,$),Q}}function N$($){let Z=$.getTime(),Q=Math.floor(Z/1000),W=(Z-Q*1000)*1e6,G=Math.floor(W/1e9);return{sec:Q+G,nsec:W-G*1e9}}function R$($){if($ instanceof Date){let Z=N$($);return M$(Z)}else return null}function U$($){let Z=new DataView($.buffer,$.byteOffset,$.byteLength);switch($.byteLength){case 4:{let Q=Z.getUint32(0),W=0;return{sec:Q,nsec:0}}case 8:{let Q=Z.getUint32(0),W=Z.getUint32(4),G=(Q&3)*4294967296+W,F=Q>>>2;return{sec:G,nsec:F}}case 12:{let Q=k(Z,4),W=Z.getUint32(0);return{sec:Q,nsec:W}}default:throw new Y(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${$.length}`)}}function _$($){let Z=U$($);return new Date(Z.sec*1000+Z.nsec/1e6)}var Y$=-1,V$=4294967295,P$=17179869183,A0;var O0=J(()=>{d();A0={type:Y$,encode:R$,decode:_$}});var R;var m=J(()=>{O0();R=class R{static defaultCodec=new R;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(A0)}register({type:$,encode:Z,decode:Q}){if($>=0)this.encoders[$]=Z,this.decoders[$]=Q;else{let W=-1-$;this.builtInEncoders[W]=Z,this.builtInDecoders[W]=Q}}tryToEncode($,Z){for(let Q=0;Q<this.builtInEncoders.length;Q++){let W=this.builtInEncoders[Q];if(W!=null){let G=W($,Z);if(G!=null){let F=-1-Q;return new _(F,G)}}}for(let Q=0;Q<this.encoders.length;Q++){let W=this.encoders[Q];if(W!=null){let G=W($,Z);if(G!=null)return new _(Q,G)}}if($ instanceof _)return $;return null}decode($,Z,Q){let W=Z<0?this.builtInDecoders[-1-Z]:this.decoders[Z];if(W)return W($,Z,Q);else return new _(Z,$)}}});function C$($){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(C$($))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??B$,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),W=new DataView(Z);Q.set(this.bytes),this.view=W,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=U0($);this.ensureBufferSizeToWrite(5+Q),this.writeStringHeader(Q),_0($,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 W of $)this.doEncode(W,Z+1)}countWithoutUndefined($,Z){let Q=0;for(let W of Z)if($[W]!==void 0)Q++;return Q}encodeMap($,Z){let Q=Object.keys($);if(this.sortKeys)Q.sort();let W=this.ignoreUndefined?this.countWithoutUndefined($,Q):Q.length;if(W<16)this.writeU8(128+W);else if(W<65536)this.writeU8(222),this.writeU16(W);else if(W<4294967296)this.writeU8(223),this.writeU32(W);else throw Error(`Too large map object: ${W}`);for(let G of Q){let F=$[G];if(!(this.ignoreUndefined&&F===void 0))this.encodeString(G),this.doEncode(F,Z+1)}}encodeExtension($){if(typeof $.data==="function"){let Q=$.data(this.pos+6),W=Q.length;if(W>=4294967296)throw Error(`Too large extension object: ${W}`);this.writeU8(201),this.writeU32(W),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),E(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,B$=2048;var z0=J(()=>{I();m()});function M($,Z){return new w(Z).encodeSharedRef($)}var T0=J(()=>{z0()});function j($){return`${$<0?"-":""}0x${Math.abs($).toString(16).padStart(2,"0")}`}class u{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor($=A$,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 W=this.caches[Q-1];$:for(let G of W){let F=G.bytes;for(let K=0;K<Q;K++)if(F[K]!==$[Z+K])continue $;return G.str}return null}store($,Z){let Q=this.caches[$.length-1],W={bytes:$,str:Z};if(Q.length>=this.maxLengthPerKey)Q[Math.random()*Q.length|0]=W;else Q.push(W)}decode($,Z,Q){let W=this.find($,Z,Q);if(W!=null)return this.hit++,W;this.miss++;let G=n($,Z,Q),F=Uint8Array.prototype.slice.call($,Z,Z+Q);return this.store(F,G),G}}var A$=16,O$=16;var D0=J(()=>{I()});class I0{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState($){let Z=this.getUninitializedStateFromPool();Z.type=i,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===i){let Q=$;Q.size=0,Q.array=void 0,Q.position=0,Q.type=void 0}if($.type===L||$.type===x0){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=r;bytes=T$;headByte=D;stack=new I0;entered=!1;constructor($){this.extensionCodec=$?.extensionCodec??R.defaultCodec,this.context=$?.context,this.useBigInt64=$?.useBigInt64??!1,this.rawStrings=$?.rawStrings??!1,this.maxStrLength=$?.maxStrLength??C,this.maxBinLength=$?.maxBinLength??C,this.maxArrayLength=$?.maxArrayLength??C,this.maxMapLength=$?.maxMapLength??C,this.maxExtLength=$?.maxExtLength??C,this.keyDecoder=$?.keyDecoder!==void 0?$.keyDecoder:D$,this.mapKeyConverter=$?.mapKeyConverter??z$}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($),W=new Uint8Array(Z.length+Q.length);W.set(Z),W.set(Q,Z.length),this.setBuffer(W)}}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 K of $){if(Z)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(K);try{Q=this.doDecodeSync(),Z=!0}catch(H){if(!(H instanceof RangeError))throw H}this.totalPos+=this.pos}if(Z){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return Q}let{headByte:W,pos:G,totalPos:F}=this;throw RangeError(`Insufficient data in parsing ${j(W)} at ${F} (${G} 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,W=-1;for await(let G of $){if(Z&&W===0)throw this.createExtraByteError(this.totalPos);if(this.appendBuffer(G),Q)W=this.readArraySize(),Q=!1,this.complete();try{while(!0)if(yield this.doDecodeSync(),--W===0)break}catch(F){if(!(F instanceof RangeError))throw F}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 W=$-128;if(W!==0){this.pushMapState(W),this.complete();continue $}else Z={}}else if($<160){let W=$-144;if(W!==0){this.pushArrayState(W),this.complete();continue $}else Z=[]}else{let W=$-160;Z=this.decodeString(W,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 W=this.lookU8();Z=this.decodeString(W,1)}else if($===218){let W=this.lookU16();Z=this.decodeString(W,2)}else if($===219){let W=this.lookU32();Z=this.decodeString(W,4)}else if($===220){let W=this.readU16();if(W!==0){this.pushArrayState(W),this.complete();continue $}else Z=[]}else if($===221){let W=this.readU32();if(W!==0){this.pushArrayState(W),this.complete();continue $}else Z=[]}else if($===222){let W=this.readU16();if(W!==0){this.pushMapState(W),this.complete();continue $}else Z={}}else if($===223){let W=this.readU32();if(W!==0){this.pushMapState(W),this.complete();continue $}else Z={}}else if($===196){let W=this.lookU8();Z=this.decodeBinary(W,1)}else if($===197){let W=this.lookU16();Z=this.decodeBinary(W,2)}else if($===198){let W=this.lookU32();Z=this.decodeBinary(W,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 W=this.lookU8();Z=this.decodeExtension(W,1)}else if($===200){let W=this.lookU16();Z=this.decodeExtension(W,2)}else if($===201){let W=this.lookU32();Z=this.decodeExtension(W,4)}else throw new Y(`Unrecognized type byte: ${j($)}`);this.complete();let Q=this.stack;while(Q.length>0){let W=Q.top();if(W.type===i)if(W.array[W.position]=Z,W.position++,W.position===W.size)Z=W.array,Q.release(W);else continue $;else if(W.type===L){if(Z==="__proto__")throw new Y("The key __proto__ is not allowed");W.key=this.mapKeyConverter(Z),W.type=x0;continue $}else if(W.map[W.key]=Z,W.readCount++,W.readCount===W.size)Z=W.map,Q.release(W);else{W.key=null,W.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 L0;let Q=this.pos+Z,W;if(this.stateIsMapKey()&&this.keyDecoder?.canBeCached($))W=this.keyDecoder.decode(this.bytes,Q,$);else W=C0(this.bytes,Q,$);return this.pos+=Z+$,W}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 L0;let Q=this.pos+Z,W=this.bytes.subarray(Q,Q+$);return this.pos+=Z+$,W}decodeExtension($,Z){if($>this.maxExtLength)throw new Y(`Max length exceeded: ext length (${$}) > maxExtLength (${this.maxExtLength})`);let Q=this.view.getInt8(this.pos+Z),W=this.decodeBinary($,Z+1);return this.extensionCodec.decode(W,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 $=B0(this.view,this.pos);return this.pos+=8,$}readI64(){let $=k(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 i="array",L="map_key",x0="map_value",z$=($)=>{if(typeof $==="string"||typeof $==="number")return $;throw new Y("The type of key must be string or number but "+typeof $)},D=-1,r,T$,L0,D$;var E0=J(()=>{m();I();D0();d();r=new DataView(new ArrayBuffer(0)),T$=new Uint8Array(r.buffer);try{r.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")}L0=RangeError("Insufficient data"),D$=new u});function N($,Z){return new h(Z).decode($)}var k0=J(()=>{E0()});var g=J(()=>{T0();k0();m()});function s($){if(typeof $==="object"&&$!==null&&!Array.isArray($))return $;return{}}function b($){return Array.isArray($)?$:[]}function m0($){if(!($ instanceof Date))return null;let Z=new ArrayBuffer(8);return new DataView(Z).setFloat64(0,$.getTime()),new Uint8Array(Z)}function w0($){let Z=new DataView($.buffer,$.byteOffset,$.byteLength).getFloat64(0);return new Date(Z)}function n8($){return typeof $==="string"&&x$.has($)}var a,L$,x$;var j0=J(()=>{a=class a extends Error{code;constructor($,Z,Q){super(Z,Q);this.code=$,this.name=$}};L$={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,DurableActivityScopeError:!0,DurableActivityUnsupportedError:!0,AsyncActivityTokenNotFoundError:!0,ActivityScheduleToCloseTimeoutError:!0,ActivityPerAttemptTimeoutError:!0,PayloadSizeExceededError:!0,StartOrSignalConflictError:!0,WorkflowTeardownPendingError:!0,IdempotencyKeyPurgedError:!0},x$=new Set(Object.keys(L$))});function o($){return h0.has($.constructor)}function g0($,Z){$.register({type:I$,encode(Q){if(typeof Q!=="object"||Q===null)return null;let W=h0.get(Q.constructor);if(W===void 0)return null;let G=Z(W.handlers.toJSON(Q),new Set);return M({tag:W.tag,data:G},{extensionCodec:$})},decode(Q){let W=N(Q,{extensionCodec:$});if(typeof W!=="object"||W===null||!("tag"in W))throw Error("Corrupt custom-serializer payload: missing tag.");let{tag:G,data:F}=W;if(typeof G!=="string")throw Error("Corrupt custom-serializer payload: tag is not a string.");let K=E$.get(G);if(K===void 0)throw Error(`No serializer registered for tag "${G}". Register it (with the same tag) before decoding a checkpoint that used it.`);return K.handlers.fromJSON(F)}})}var I$=100,h0,E$;var b0=J(()=>{g();h0=new Map,E$=new Map});function b$($,Z){if(Z<=200)return JSON.stringify($);return`${Z}-byte string starting ${JSON.stringify($.slice(0,120))}`}function y$($,Z){let Q=g$.encode($).byteLength;if(Q>y0)throw new e({source:$,flags:Z,sourceByteLength:Q,reason:`because source exceeds the ${y0}-byte limit.`});try{return new RegExp($,Z)}catch(W){let G=W instanceof Error?W.message:String(W);throw new e({source:$,flags:Z,sourceByteLength:Q,reason:`because ${G}`,cause:W})}}function v$($){return typeof $==="object"&&$!==null&&"__tag"in $&&$.__tag===f0}function $0($,Z){if(!B($,Z))return $;return S($,new Set)}function S($,Z){if($===void 0)return f$;if($===null||typeof $!=="object")return $;if(Z.has($))return $;Z.add($);try{return p$($,Z)}finally{Z.delete($)}}function p$($,Z){if(Array.isArray($))return c$($,Z);if($ instanceof Map)return l$($,Z);if($ instanceof Set)return n$($,Z);if(v0($))return $;return d$($,Z)}function c$($,Z){let Q=Array.from({length:$.length});for(let W=0;W<$.length;W++)Q[W]=S($[W],Z);return Q}function l$($,Z){let Q=new Map;for(let[W,G]of $)Q.set(S(W,Z),S(G,Z));return Q}function n$($,Z){let Q=new Set;for(let W of $)Q.add(S(W,Z));return Q}function v0($){return $ instanceof Date||$ instanceof RegExp||$ instanceof Error||$ instanceof Uint8Array||$ instanceof ArrayBuffer||o($)}function d$($,Z){let Q=$,W={};for(let G of Object.keys(Q))W[G]=S(Q[G],Z);return W}function B($,Z){if($===void 0)return!0;if($===null||typeof $!=="object")return!1;if(Z.has($))return!1;if(v0($))return!1;Z.add($);try{if(Array.isArray($))return u$($,Z);if($ instanceof Map)return i$($,Z);if($ instanceof Set)return r$($,Z);return s$($,Z)}finally{Z.delete($)}}function u$($,Z){for(let Q=0;Q<$.length;Q++)if(B($[Q],Z))return!0;return!1}function i$($,Z){for(let[Q,W]of $)if(B(Q,Z)||B(W,Z))return!0;return!1}function r$($,Z){for(let Q of $)if(B(Q,Z))return!0;return!1}function s$($,Z){let Q=$;for(let W of Object.keys(Q))if(B(Q[W],Z))return!0;return!1}var k$=1,t=2,m$=3,w$=4,j$=5,h$=6,y0=65535,g$,e,V,f0,f$;var p0=J(()=>{g();j0();b0();g$=new TextEncoder;e=class e extends a{extensionType;source;flags;sourceByteLength;constructor($){super("RegExpExtensionDecodeError",`RegExp extension type ${t} could not be decoded: source=${b$($.source,$.sourceByteLength)} flags=${JSON.stringify($.flags)} ${$.reason}`,$.cause===void 0?void 0:{cause:$.cause});this.extensionType=t,this.source=$.source,this.flags=$.flags,this.sourceByteLength=$.sourceByteLength}};V=new R;g0(V,$0);V.register({type:k$,encode:m0,decode:w0});V.register({type:t,encode($){if($ instanceof RegExp)return M({source:$.source,flags:$.flags});return null},decode($){let Z=s(N($)),Q=typeof Z.source==="string"?Z.source:"",W=typeof Z.flags==="string"?Z.flags:"";return y$(Q,W)}});V.register({type:m$,encode($){if($ instanceof Map){let Z=[...$.entries()];return M(Z,{extensionCodec:V})}return null},decode($){let Q=b(N($,{extensionCodec:V})).map((W)=>{let G=b(W);return[G[0],G[1]]});return new Map(Q)}});V.register({type:w$,encode($){if($ instanceof Set){let Z=[...$.values()];return M(Z,{extensionCodec:V})}return null},decode($){let Z=b(N($,{extensionCodec:V}));return new Set(Z)}});f0=Symbol("UndefinedSentinel"),f$=Object.freeze({__tag:f0});V.register({type:j$,encode($){if(v$($))return new Uint8Array(0);return null},decode(){return}});V.register({type:h$,encode($){if($ instanceof Error&&!o($))return M({name:$.name,message:$.message,stack:$.stack});return null},decode($){let Z=s(N($)),Q=typeof Z.name==="string"?Z.name:"Error",W=typeof Z.message==="string"?Z.message:"",G=typeof Z.stack==="string"?Z.stack:void 0,F=Error(W);if(F.name=Q,G!==void 0)F.stack=G;return F}})});function Z0($){let Z=$0($,new Set);return M(Z,{extensionCodec:V})}function Q0($){return N($,{extensionCodec:V})}var c0=J(()=>{g();p0()});function y($,Z=""){let Q=[];return x($,Z,Q,new Set),{valid:Q.length===0,errors:Q}}function a$($){let Z=Object.getPrototypeOf($);return o$(Z)&&!t$($)&&e$(Z)}function o$($){return $!==Object.prototype&&$!==null}function t$($){return Array.isArray($)||$ instanceof Date||$ instanceof RegExp||$ instanceof Map||$ instanceof Set||$ instanceof Error||$ instanceof Uint8Array||$ instanceof ArrayBuffer}function e$($){if(typeof $!=="object"||$===null)return!1;return Object.getOwnPropertyNames($).some((Q)=>{if(Q==="constructor")return!1;let W=Object.getOwnPropertyDescriptor($,Q);return W!==void 0&&typeof W.value==="function"})}function l0($,Z,Q,W){$.push({path:Z,value:Q,reason:W.reason,suggestion:W.suggestion})}function $6($){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 Z6($,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(a$($))return{reason:"Class instances with methods cannot be serialized.",suggestion:"Store only the data and reconstruct the instance."};return null}function Q6($){return $ instanceof Date||$ instanceof RegExp||$ instanceof Error||$ instanceof Uint8Array||$ instanceof ArrayBuffer}function W6($,Z,Q,W){for(let[G,F]of $){let K=String(G);x(F,Z?`${Z}.${K}`:K,Q,W)}}function G6($,Z,Q,W){let G=0;for(let F of $){let K=Z?`${Z}[${G}]`:`[${G}]`;x(F,K,Q,W),G++}}function q6($,Z,Q,W){for(let G=0;G<$.length;G++){let F=Z?`${Z}[${G}]`:`[${G}]`;x($[G],F,Q,W)}}function F6($,Z,Q,W){for(let G of Object.keys($)){let F=Z?`${Z}.${G}`:G;x($[G],F,Q,W)}}function x($,Z,Q,W){if($===null||$===void 0)return;let G=$6($);if(G){l0(Q,Z,$,G);return}if(typeof $!=="object")return;let F=Z6($,W);if(F){l0(Q,Z,$,F);return}W.add($);try{if(Q6($))return;if($ instanceof Map){W6($,Z,Q,W);return}if($ instanceof Set){G6($,Z,Q,W);return}if(Array.isArray($)){q6($,Z,Q,W);return}F6($,Z,Q,W)}finally{W.delete($)}}var n0=J(()=>{c0()});var d0=J(()=>{n0()});function f($){let Z=new WeakSet,Q=(W)=>{if(K6(W))return!0;if(H6(W))return!1;if(Array.isArray(W))return J6(W,Z,Q);if(typeof W==="object")return X6(W,Z,Q);return!1};return Q($)}function JZ($){if($===void 0)return null;if($ instanceof Error)return{name:$.name,message:$.message};if(f($))return $;try{let Z=JSON.stringify($);if(Z===void 0)return W0($);let Q=JSON.parse(Z);return f(Q)?Q:W0($)}catch{return W0($)}}function K6($){if($===null)return!0;if(typeof $==="number")return Number.isFinite($)&&!Object.is($,-0);return typeof $==="string"||typeof $==="boolean"}function H6($){let Z=typeof $;return Z==="undefined"||Z==="bigint"||Z==="function"||Z==="symbol"}function J6($,Z,Q){if(Z.has($))return!1;Z.add($);for(let W of $)if(!Q(W))return!1;return Z.delete($),!0}function X6($,Z,Q){if(!Y6($))return!1;if(Z.has($))return!1;Z.add($);for(let W of Object.values($))if(!Q(W))return!1;return Z.delete($),!0}function W0($){if(typeof $==="bigint")return $.toString();if(typeof $==="symbol")return $.description??null;return null}function Y6($){if(!$||typeof $!=="object")return!1;let Z=Reflect.getPrototypeOf($);return Z===Object.prototype||Z===null}function V6($){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 P6($){let Z={},Q=!1;for(let G of["gt","gte","lt","lte"]){let F=$[G];if(F===void 0)continue;if(typeof F!=="string")throw Error("deleteRange bounds must be strings");Z[G]=F,Q=!0}if(!Q)throw Error("deleteRange requires at least one of gt/gte/lt/lte; use deletePrefix to delete a whole prefix");let W=V6($.limit);if(W!==void 0)Z.limit=W;return Z}async function u0($,Z,Q){let W=P6(Q);if($.deleteRange)return $.deleteRange(Z,W);return K0($,Z,W)}var i0=()=>{};d0();i0();R0();class r0{#$;#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,W]of this.#$.scan($,Z))yield[Q,this.#Z.decode(W)]}async batch($){z("batch operations",$.length),await this.#$.batch(this.#W($))}#W($){return $.map((Q)=>{if(Q.type==="put")return{type:"put",key:Q.key,value:this.#Z.encode(Q.value)};return Q})}#G($){return $.map((Z)=>({key:Z.key,expectedValue:Z.expectedValue===null?null:this.#Z.encode(Z.expectedValue)}))}async conditionalBatch($,Z){return N0(this.#$,this.#G($),this.#W(Z))}async has($){return Y0(this.#$,$)}async deletePrefix($){return M0(this.#$,$)}async deleteRange($,Z){return u0(this.#$,$,Z)}keys($,Z){return V0(this.#$,$,Z)}async count($){return P0(this.#$,$)}[Symbol.dispose](){if(!this.#Q)return;this.#$[Symbol.dispose]()}}function UZ($,Z,Q={}){return new r0($,Z,Q)}function M6($){try{if(!f($))throw TypeError("jsonCodec only supports JSON-serializable values.");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 N6($){let Z=y($);if(!Z.valid)throw TypeError(`msgpackCodec only supports structuredClone-compatible values. ${Z.errors[0]?.reason??""}`.trim());return Z0($)}function R6($){return JSON.parse(new TextDecoder().decode($))}function U6($){let Z=Q0($),Q=y(Z);if(!Q.valid)throw TypeError(`msgpackCodec decoded a non-cloneable value. ${Q.errors[0]?.reason??""}`.trim());return Z}function _Z($){return{encode(Z){return M6(Z)},decode(Z){let Q=R6(Z);return $?$(Q):Q}}}function CZ($){return{encode(Z){return N6(Z)},decode(Z){let Q=U6(Z);return $?$(Q):Q}}}export{UZ as withCodec,CZ as msgpackCodec,_Z as jsonCodec};
|
|
2
|
+
var a0=Object.defineProperty;var o0=($)=>$;function t0($,Z){this[$]=o0.bind(null,Z)}var _6=($,Z)=>{for(var Q in Z)a0($,Q,{get:Z[Q],enumerable:!0,configurable:!0,set:t0.bind(Z,Q)})};var J=($,Z)=>()=>($&&(Z=$($=0)),Z);var C6=import.meta.require,S6=($,Z,Q)=>{if(Z!=null){if(typeof Z!=="object"&&typeof Z!=="function")throw TypeError('Object expected to be assigned to "using" declaration');let W;if(Q)W=Z[Symbol.asyncDispose];if(W===void 0)W=Z[Symbol.dispose];if(typeof W!=="function")throw TypeError("Object not disposable");$.push([Q,W,Z])}else if(Q)$.push([Q]);return Z},B6=($,Z,Q)=>{let W=(F)=>Z=Q?new SuppressedError(F,Z,"An error was suppressed during disposal"):(Q=!0,F),G=(F)=>{while(F=$.pop())try{var K=F[1]&&F[1].call(F[2]);if(F[0])return Promise.resolve(K).then(G,(H)=>(W(H),G()))}catch(H){W(H)}if(Q)throw Z};return G()};function p($,Z,Q){if(!$.capabilities()[Z])throw Error(`Feature "${Q}" requires storage capability "${Z}", but this storage backend does not provide it.`)}function e0($){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 c="default";async function G0($,Z){return await $.get(Z)!==null}async function*O($,Z,Q){for await(let[W]of $.scan(Z,Q))yield W}async function q0($,Z){let Q=0;for await(let W of O($,Z))Q++;return Q}async function F0($,Z){let Q=[];for await(let W of O($,Z))Q.push({type:"delete",key:W});if(Q.length===0)return 0;return await $.batch(Q),Q.length}async function K0($,Z,Q){let W=[];for await(let G of O($,Z,Q))W.push({type:"delete",key:G});if(W.length===0)return 0;return await $.batch(W),W.length}var $$;var H0=J(()=>{$$=["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>l)throw new X0($,Z)}function k6($){return $.length>0?$.slice(0,-1)+String.fromCharCode($.charCodeAt($.length-1)+1):"\xFF"}function m6($,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 w6($,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 Y0($,Z){if($.has)return $.has(Z);return G0($,Z)}function V0($,Z,Q){if($.keys)return $.keys(Z,Q);return O($,Z,Q)}async function P0($,Z){if($.count)return $.count(Z);return q0($,Z)}async function M0($,Z){if($.deletePrefix)return $.deletePrefix(Z);return F0($,Z)}async function j6($,Z){z("batch operations",Z.length),await $.batch(Z)}async function N0($,Z,Q){if(z("conditionalBatch conditions",Z.length),z("conditionalBatch operations",Q.length),p($,"conditionalBatch","storageConditionalBatch"),!$.conditionalBatch)throw Error("This storage backend reports conditionalBatch capability but does not implement the conditionalBatch() method.");return $.conditionalBatch(Z,Q)}function q($){return encodeURIComponent($)}function h6($){return decodeURIComponent($)}function g6($){try{return decodeURIComponent($)}catch{return null}}var l=1e4,E6=1e4,X0,P=($)=>String($).padStart(16,"0"),Z$="0",Q$="1",J0=($,Z,Q,W)=>`sig:${q($)}:${q(Z)}:${W}:${q(Q)}`,b6;var R0=J(()=>{H0();X0=class X0 extends Error{code="StorageBatchOperationLimitExceededError";cap=l;count;target;constructor($,Z){super(`${$} count ${Z} exceeds MAX_BATCH_OPERATIONS (${l}).`);this.name="StorageBatchOperationLimitExceededError",this.target=$,this.count=Z}};b6={workflow:($)=>`wf:${q($)}`,checkpoint:($)=>`wf:${q($)}:ckpt`,checkpointHistory:($,Z)=>`wf:${q($)}:ckpt:${String(Z).padStart(10,"0")}`,timelinePrefix:($)=>`wf:${q($)}:timeline:`,timeline:($,Z)=>`wf:${q($)}:timeline:${String(Z).padStart(10,"0")}`,schedule:($)=>`schedule:${q($)}`,scheduleTick:($,Z)=>`schedule-due:${String($).padStart(16,"0")}:${q(Z)}`,scheduleRun:($)=>`schedule-run:${q($)}`,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($)}:${q(Z)}:${q(Q)}`,operationResolvedByTimePrefix:()=>"op:resolved-by-time:",operationResolvedByTime:($,Z)=>`op:resolved-by-time:${P($)}:${q(Z)}`,asyncActivity:($,Z)=>`async-act:v1:${q($)}:${q(Z)}`,asyncActivityResolution:($,Z)=>`async-act:v1:${q($)}:${q(Z)}:resolution`,activityReconciliationPrefix:($)=>`actrec:v1:${q($)}:`,activityReconciliation:($,Z,Q)=>`actrec:v1:${q($)}:${q(Z)}:${Q}`,eventPrefix:($)=>`ev:${q($)}:`,event:($,Z)=>`ev:${q($)}:${String(Z).padStart(10,"0")}`,eventHead:($)=>`ev:${q($)}:head`,eventWatermark:($)=>`ev:${q($)}:watermark`,fleetEventPrefix:()=>"fleet-event:",fleetEvent:($)=>`fleet-event:${String($).padStart(10,"0")}`,fleetEventTail:()=>"fleet-event-tail",fleetEventByWorkflowPrefix:($)=>`fleet-event-by-workflow:${q($)}:`,fleetEventByWorkflow:($,Z)=>`fleet-event-by-workflow:${q($)}:${String(Z).padStart(10,"0")}`,signal:($,Z,Q)=>J0($,Z,Q,Q$),startSignal:($,Z,Q)=>J0($,Z,Q,Z$),signalSequence:($)=>`sigseq:v1:${q($)}`,signalAcceptedResponsePrefix:($)=>`sigres:v1:${q($)}:`,signalAcceptedResponse:($,Z,Q)=>`sigres:v1:${q($)}:${q(Z)}:${q(Q)}`,deadline:($,Z)=>`wf-deadline:${P($)}:${q(Z)}`,terminalCleanup:($,Z)=>`wf-cleanup:${P($)}:${q(Z)}`,teardownTimer:($,Z)=>`wf-teardown:${P($)}:${q(Z)}`,delayedStart:($,Z)=>`wf-delayed:${P($)}:${q(Z)}`,terminalWorkflowPrefix:()=>"wf-terminal:",terminalWorkflow:($,Z)=>`wf-terminal:${P($)}:${q(Z)}`,attribute:($)=>`attr:${q($)}`,attributeIndex:($,Z,Q)=>`idx:${$}:${Z}:${q(Q)}`,tagIndex:($,Z)=>`tag:${q($)}:${q(Z)}`,updatePrefix:($)=>`upd:${q($)}:`,update:($,Z)=>`upd:${q($)}:${Z}`,updateResponse:($)=>`upr:${$}`,updateIdempotency:($,Z)=>`upk:${q($)}:${Z}`,startIdempotency:($)=>`start-idem:${q($)}`,startIdempotencySignalId:($)=>`start-idem:${$}`,livenessPrefix:()=>"liveness:",liveness:($)=>`liveness:${q($)}`,leasePrefix:()=>"lease:",leaseEpoch:()=>"lease:epoch",leaseHolder:()=>"lease:holder",budget:($,Z,Q)=>`budget:${$}:${Z}:${Q}`,review:($,Z)=>`review:${q($)}:${Z}`,workflowHeaders:($)=>`wf-headers:${q($)}`,childCancellationPrefix:($)=>`child-cancel:${q($)}:`,childCancellation:($,Z)=>`child-cancel:${q($)}:${q(Z)}`,terminalCleanupNeeded:($)=>`wf-cleanup-needed:${q($)}`,workflowConcurrency:($,Z)=>`wf-concurrency:${q($)}:${q(Z)}`,workflowConcurrencyHolder:($)=>`wf-concurrency-holder:${q($)}`,workflowHasServices:($)=>`wf-has-services:${q($)}`,finalizerState:($)=>`wf-finalizer-state:${q($)}`,teardownOwed:($)=>`wf-teardown-needed:${q($)}`,teardownDeadLetter:($)=>`wf-teardown-deadletter:${q($)}`,offload:($,Z)=>`offload:${q($)}:${Z}`,archive:($,Z)=>`archive:${q($)}:${Z}`,stateExecution:($,Z)=>`state:execution:${q($)}:${q(Z)}`,stateWorkflow:($,Z)=>`state:workflow-scope:${c}:${q($)}:${q(Z)}`,streamChunkPrefix:($,Z)=>`blob:${q($)}:${Z}:chunk:`,streamChunk:($,Z,Q)=>`blob:${q($)}:${Z}:chunk:${String(Q).padStart(10,"0")}`,streamTail:($,Z)=>`blob:${q($)}:${Z}:tail`,streamMetadata:($,Z)=>`blob:${q($)}:${Z}:meta`,budgetCharged:($)=>`budget-charged:${$}`,toolEffect:($,Z,Q)=>`tool-effect:${q($)}:${Z}:${Q}`,workflowVisibilityStatus:($,Z)=>`wf-idx-status:${q($)}:${q(Z)}`,workflowVisibilityType:($,Z)=>`wf-idx-type:${q($)}:${q(Z)}`,workflowVisibilityCreated:($,Z)=>`wf-idx-created:${P($)}:${q(Z)}`,workflowVisibilityUpdated:($,Z)=>`wf-idx-updated:${P($)}:${q(Z)}`,workflowVisibilityDeadline:($,Z)=>`wf-idx-deadline:${P($)}:${q(Z)}`,workflowVisibilityManifest:($)=>`wf-idx-manifest:${q($)}`,workflowVisibilityMetaVersion:()=>"wf-idx-meta:version",workflowVisibilityMetaBuiltAt:()=>"wf-idx-meta:built-at",workflowVisibilityMetaCursor:()=>"wf-idx-meta:cursor"}});function U0($){let Z=$.length,Q=0,W=0;while(W<Z){let G=$.charCodeAt(W++);if((G&4294967168)===0){Q++;continue}else if((G&4294965248)===0)Q+=2;else{if(G>=55296&&G<=56319){if(W<Z){let F=$.charCodeAt(W);if((F&64512)===56320)++W,G=((G&1023)<<10)+(F&1023)+65536}}if((G&4294901760)===0)Q+=3;else Q+=4}}return Q}function W$($,Z,Q){let W=$.length,G=Q,F=0;while(F<W){let K=$.charCodeAt(F++);if((K&4294967168)===0){Z[G++]=K;continue}else if((K&4294965248)===0)Z[G++]=K>>6&31|192;else{if(K>=55296&&K<=56319){if(F<W){let H=$.charCodeAt(F);if((H&64512)===56320)++F,K=((K&1023)<<10)+(H&1023)+65536}}if((K&4294901760)===0)Z[G++]=K>>12&15|224,Z[G++]=K>>6&63|128;else Z[G++]=K>>18&7|240,Z[G++]=K>>12&63|128,Z[G++]=K>>6&63|128}Z[G++]=K&63|128}}function F$($,Z,Q){G$.encodeInto($,Z.subarray(Q))}function _0($,Z,Q){if($.length>q$)F$($,Z,Q);else W$($,Z,Q)}function n($,Z,Q){let W=Z,G=W+Q,F=[],K="";while(W<G){let H=$[W++];if((H&128)===0)F.push(H);else if((H&224)===192){let A=$[W++]&63;F.push((H&31)<<6|A)}else if((H&240)===224){let A=$[W++]&63,v=$[W++]&63;F.push((H&31)<<12|A<<6|v)}else if((H&248)===240){let A=$[W++]&63,v=$[W++]&63,s0=$[W++]&63,U=(H&7)<<18|A<<12|v<<6|s0;if(U>65535)U-=65536,F.push(U>>>10&1023|55296),U=56320|U&1023;F.push(U)}else F.push(H);if(F.length>=K$)K+=String.fromCharCode(...F),F.length=0}if(F.length>0)K+=String.fromCharCode(...F);return K}function X$($,Z,Q){let W=$.subarray(Z,Z+Q);return H$.decode(W)}function C0($,Z,Q){if(Q>J$)return X$($,Z,Q);else return n($,Z,Q)}var G$,q$=50,K$=4096,H$,J$=200;var I=J(()=>{G$=new TextEncoder;H$=new TextDecoder});class _{type;data;constructor($,Z){this.type=$,this.data=Z}}var Y;var d=J(()=>{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 W=Q/4294967296,G=Q;$.setUint32(Z,W),$.setUint32(Z+4,G)}function E($,Z,Q){let W=Math.floor(Q/4294967296),G=Q;$.setUint32(Z,W),$.setUint32(Z+4,G)}function k($,Z){let Q=$.getInt32(Z),W=$.getUint32(Z+4);return Q*4294967296+W}function B0($,Z){let Q=$.getUint32(Z),W=$.getUint32(Z+4);return Q*4294967296+W}var C=4294967295;function M$({sec:$,nsec:Z}){if($>=0&&Z>=0&&$<=P$)if(Z===0&&$<=V$){let Q=new Uint8Array(4);return new DataView(Q.buffer).setUint32(0,$),Q}else{let Q=$/4294967296,W=$&4294967295,G=new Uint8Array(8),F=new DataView(G.buffer);return F.setUint32(0,Z<<2|Q&3),F.setUint32(4,W),G}else{let Q=new Uint8Array(12),W=new DataView(Q.buffer);return W.setUint32(0,Z),E(W,4,$),Q}}function N$($){let Z=$.getTime(),Q=Math.floor(Z/1000),W=(Z-Q*1000)*1e6,G=Math.floor(W/1e9);return{sec:Q+G,nsec:W-G*1e9}}function R$($){if($ instanceof Date){let Z=N$($);return M$(Z)}else return null}function U$($){let Z=new DataView($.buffer,$.byteOffset,$.byteLength);switch($.byteLength){case 4:{let Q=Z.getUint32(0),W=0;return{sec:Q,nsec:0}}case 8:{let Q=Z.getUint32(0),W=Z.getUint32(4),G=(Q&3)*4294967296+W,F=Q>>>2;return{sec:G,nsec:F}}case 12:{let Q=k(Z,4),W=Z.getUint32(0);return{sec:Q,nsec:W}}default:throw new Y(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${$.length}`)}}function _$($){let Z=U$($);return new Date(Z.sec*1000+Z.nsec/1e6)}var Y$=-1,V$=4294967295,P$=17179869183,A0;var O0=J(()=>{d();A0={type:Y$,encode:R$,decode:_$}});var R;var m=J(()=>{O0();R=class R{static defaultCodec=new R;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(A0)}register({type:$,encode:Z,decode:Q}){if($>=0)this.encoders[$]=Z,this.decoders[$]=Q;else{let W=-1-$;this.builtInEncoders[W]=Z,this.builtInDecoders[W]=Q}}tryToEncode($,Z){for(let Q=0;Q<this.builtInEncoders.length;Q++){let W=this.builtInEncoders[Q];if(W!=null){let G=W($,Z);if(G!=null){let F=-1-Q;return new _(F,G)}}}for(let Q=0;Q<this.encoders.length;Q++){let W=this.encoders[Q];if(W!=null){let G=W($,Z);if(G!=null)return new _(Q,G)}}if($ instanceof _)return $;return null}decode($,Z,Q){let W=Z<0?this.builtInDecoders[-1-Z]:this.decoders[Z];if(W)return W($,Z,Q);else return new _(Z,$)}}});function C$($){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(C$($))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??B$,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),W=new DataView(Z);Q.set(this.bytes),this.view=W,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=U0($);this.ensureBufferSizeToWrite(5+Q),this.writeStringHeader(Q),_0($,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 W of $)this.doEncode(W,Z+1)}countWithoutUndefined($,Z){let Q=0;for(let W of Z)if($[W]!==void 0)Q++;return Q}encodeMap($,Z){let Q=Object.keys($);if(this.sortKeys)Q.sort();let W=this.ignoreUndefined?this.countWithoutUndefined($,Q):Q.length;if(W<16)this.writeU8(128+W);else if(W<65536)this.writeU8(222),this.writeU16(W);else if(W<4294967296)this.writeU8(223),this.writeU32(W);else throw Error(`Too large map object: ${W}`);for(let G of Q){let F=$[G];if(!(this.ignoreUndefined&&F===void 0))this.encodeString(G),this.doEncode(F,Z+1)}}encodeExtension($){if(typeof $.data==="function"){let Q=$.data(this.pos+6),W=Q.length;if(W>=4294967296)throw Error(`Too large extension object: ${W}`);this.writeU8(201),this.writeU32(W),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),E(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,B$=2048;var z0=J(()=>{I();m()});function M($,Z){return new w(Z).encodeSharedRef($)}var T0=J(()=>{z0()});function j($){return`${$<0?"-":""}0x${Math.abs($).toString(16).padStart(2,"0")}`}class u{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor($=A$,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 W=this.caches[Q-1];$:for(let G of W){let F=G.bytes;for(let K=0;K<Q;K++)if(F[K]!==$[Z+K])continue $;return G.str}return null}store($,Z){let Q=this.caches[$.length-1],W={bytes:$,str:Z};if(Q.length>=this.maxLengthPerKey)Q[Math.random()*Q.length|0]=W;else Q.push(W)}decode($,Z,Q){let W=this.find($,Z,Q);if(W!=null)return this.hit++,W;this.miss++;let G=n($,Z,Q),F=Uint8Array.prototype.slice.call($,Z,Z+Q);return this.store(F,G),G}}var A$=16,O$=16;var D0=J(()=>{I()});class I0{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState($){let Z=this.getUninitializedStateFromPool();Z.type=i,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===i){let Q=$;Q.size=0,Q.array=void 0,Q.position=0,Q.type=void 0}if($.type===L||$.type===x0){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=r;bytes=T$;headByte=D;stack=new I0;entered=!1;constructor($){this.extensionCodec=$?.extensionCodec??R.defaultCodec,this.context=$?.context,this.useBigInt64=$?.useBigInt64??!1,this.rawStrings=$?.rawStrings??!1,this.maxStrLength=$?.maxStrLength??C,this.maxBinLength=$?.maxBinLength??C,this.maxArrayLength=$?.maxArrayLength??C,this.maxMapLength=$?.maxMapLength??C,this.maxExtLength=$?.maxExtLength??C,this.keyDecoder=$?.keyDecoder!==void 0?$.keyDecoder:D$,this.mapKeyConverter=$?.mapKeyConverter??z$}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($),W=new Uint8Array(Z.length+Q.length);W.set(Z),W.set(Q,Z.length),this.setBuffer(W)}}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 K of $){if(Z)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(K);try{Q=this.doDecodeSync(),Z=!0}catch(H){if(!(H instanceof RangeError))throw H}this.totalPos+=this.pos}if(Z){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return Q}let{headByte:W,pos:G,totalPos:F}=this;throw RangeError(`Insufficient data in parsing ${j(W)} at ${F} (${G} 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,W=-1;for await(let G of $){if(Z&&W===0)throw this.createExtraByteError(this.totalPos);if(this.appendBuffer(G),Q)W=this.readArraySize(),Q=!1,this.complete();try{while(!0)if(yield this.doDecodeSync(),--W===0)break}catch(F){if(!(F instanceof RangeError))throw F}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 W=$-128;if(W!==0){this.pushMapState(W),this.complete();continue $}else Z={}}else if($<160){let W=$-144;if(W!==0){this.pushArrayState(W),this.complete();continue $}else Z=[]}else{let W=$-160;Z=this.decodeString(W,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 W=this.lookU8();Z=this.decodeString(W,1)}else if($===218){let W=this.lookU16();Z=this.decodeString(W,2)}else if($===219){let W=this.lookU32();Z=this.decodeString(W,4)}else if($===220){let W=this.readU16();if(W!==0){this.pushArrayState(W),this.complete();continue $}else Z=[]}else if($===221){let W=this.readU32();if(W!==0){this.pushArrayState(W),this.complete();continue $}else Z=[]}else if($===222){let W=this.readU16();if(W!==0){this.pushMapState(W),this.complete();continue $}else Z={}}else if($===223){let W=this.readU32();if(W!==0){this.pushMapState(W),this.complete();continue $}else Z={}}else if($===196){let W=this.lookU8();Z=this.decodeBinary(W,1)}else if($===197){let W=this.lookU16();Z=this.decodeBinary(W,2)}else if($===198){let W=this.lookU32();Z=this.decodeBinary(W,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 W=this.lookU8();Z=this.decodeExtension(W,1)}else if($===200){let W=this.lookU16();Z=this.decodeExtension(W,2)}else if($===201){let W=this.lookU32();Z=this.decodeExtension(W,4)}else throw new Y(`Unrecognized type byte: ${j($)}`);this.complete();let Q=this.stack;while(Q.length>0){let W=Q.top();if(W.type===i)if(W.array[W.position]=Z,W.position++,W.position===W.size)Z=W.array,Q.release(W);else continue $;else if(W.type===L){if(Z==="__proto__")throw new Y("The key __proto__ is not allowed");W.key=this.mapKeyConverter(Z),W.type=x0;continue $}else if(W.map[W.key]=Z,W.readCount++,W.readCount===W.size)Z=W.map,Q.release(W);else{W.key=null,W.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 L0;let Q=this.pos+Z,W;if(this.stateIsMapKey()&&this.keyDecoder?.canBeCached($))W=this.keyDecoder.decode(this.bytes,Q,$);else W=C0(this.bytes,Q,$);return this.pos+=Z+$,W}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 L0;let Q=this.pos+Z,W=this.bytes.subarray(Q,Q+$);return this.pos+=Z+$,W}decodeExtension($,Z){if($>this.maxExtLength)throw new Y(`Max length exceeded: ext length (${$}) > maxExtLength (${this.maxExtLength})`);let Q=this.view.getInt8(this.pos+Z),W=this.decodeBinary($,Z+1);return this.extensionCodec.decode(W,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 $=B0(this.view,this.pos);return this.pos+=8,$}readI64(){let $=k(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 i="array",L="map_key",x0="map_value",z$=($)=>{if(typeof $==="string"||typeof $==="number")return $;throw new Y("The type of key must be string or number but "+typeof $)},D=-1,r,T$,L0,D$;var E0=J(()=>{m();I();D0();d();r=new DataView(new ArrayBuffer(0)),T$=new Uint8Array(r.buffer);try{r.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")}L0=RangeError("Insufficient data"),D$=new u});function N($,Z){return new h(Z).decode($)}var k0=J(()=>{E0()});var g=J(()=>{T0();k0();m()});function s($){if(typeof $==="object"&&$!==null&&!Array.isArray($))return $;return{}}function b($){return Array.isArray($)?$:[]}function m0($){if(!($ instanceof Date))return null;let Z=new ArrayBuffer(8);return new DataView(Z).setFloat64(0,$.getTime()),new Uint8Array(Z)}function w0($){let Z=new DataView($.buffer,$.byteOffset,$.byteLength).getFloat64(0);return new Date(Z)}function n8($){return typeof $==="string"&&x$.has($)}var a,L$,x$;var j0=J(()=>{a=class a extends Error{code;constructor($,Z,Q){super(Z,Q);this.code=$,this.name=$}};L$={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,DurableActivityScopeError:!0,DurableActivityUnsupportedError:!0,AsyncActivityTokenNotFoundError:!0,ActivityScheduleToCloseTimeoutError:!0,ActivityPerAttemptTimeoutError:!0,PayloadSizeExceededError:!0,StartOrSignalConflictError:!0,WorkflowTeardownPendingError:!0,IdempotencyKeyPurgedError:!0},x$=new Set(Object.keys(L$))});function o($){return h0.has($.constructor)}function g0($,Z){$.register({type:I$,encode(Q){if(typeof Q!=="object"||Q===null)return null;let W=h0.get(Q.constructor);if(W===void 0)return null;let G=Z(W.handlers.toJSON(Q),new Set);return M({tag:W.tag,data:G},{extensionCodec:$})},decode(Q){let W=N(Q,{extensionCodec:$});if(typeof W!=="object"||W===null||!("tag"in W))throw Error("Corrupt custom-serializer payload: missing tag.");let{tag:G,data:F}=W;if(typeof G!=="string")throw Error("Corrupt custom-serializer payload: tag is not a string.");let K=E$.get(G);if(K===void 0)throw Error(`No serializer registered for tag "${G}". Register it (with the same tag) before decoding a checkpoint that used it.`);return K.handlers.fromJSON(F)}})}var I$=100,h0,E$;var b0=J(()=>{g();h0=new Map,E$=new Map});function b$($,Z){if(Z<=200)return JSON.stringify($);return`${Z}-byte string starting ${JSON.stringify($.slice(0,120))}`}function y$($,Z){let Q=g$.encode($).byteLength;if(Q>y0)throw new e({source:$,flags:Z,sourceByteLength:Q,reason:`because source exceeds the ${y0}-byte limit.`});try{return new RegExp($,Z)}catch(W){let G=W instanceof Error?W.message:String(W);throw new e({source:$,flags:Z,sourceByteLength:Q,reason:`because ${G}`,cause:W})}}function v$($){return typeof $==="object"&&$!==null&&"__tag"in $&&$.__tag===f0}function $0($,Z){if(!B($,Z))return $;return S($,new Set)}function S($,Z){if($===void 0)return f$;if($===null||typeof $!=="object")return $;if(Z.has($))return $;Z.add($);try{return p$($,Z)}finally{Z.delete($)}}function p$($,Z){if(Array.isArray($))return c$($,Z);if($ instanceof Map)return l$($,Z);if($ instanceof Set)return n$($,Z);if(v0($))return $;return d$($,Z)}function c$($,Z){let Q=Array.from({length:$.length});for(let W=0;W<$.length;W++)Q[W]=S($[W],Z);return Q}function l$($,Z){let Q=new Map;for(let[W,G]of $)Q.set(S(W,Z),S(G,Z));return Q}function n$($,Z){let Q=new Set;for(let W of $)Q.add(S(W,Z));return Q}function v0($){return $ instanceof Date||$ instanceof RegExp||$ instanceof Error||$ instanceof Uint8Array||$ instanceof ArrayBuffer||o($)}function d$($,Z){let Q=$,W={};for(let G of Object.keys(Q))W[G]=S(Q[G],Z);return W}function B($,Z){if($===void 0)return!0;if($===null||typeof $!=="object")return!1;if(Z.has($))return!1;if(v0($))return!1;Z.add($);try{if(Array.isArray($))return u$($,Z);if($ instanceof Map)return i$($,Z);if($ instanceof Set)return r$($,Z);return s$($,Z)}finally{Z.delete($)}}function u$($,Z){for(let Q=0;Q<$.length;Q++)if(B($[Q],Z))return!0;return!1}function i$($,Z){for(let[Q,W]of $)if(B(Q,Z)||B(W,Z))return!0;return!1}function r$($,Z){for(let Q of $)if(B(Q,Z))return!0;return!1}function s$($,Z){let Q=$;for(let W of Object.keys(Q))if(B(Q[W],Z))return!0;return!1}var k$=1,t=2,m$=3,w$=4,j$=5,h$=6,y0=65535,g$,e,V,f0,f$;var p0=J(()=>{g();j0();b0();g$=new TextEncoder;e=class e extends a{extensionType;source;flags;sourceByteLength;constructor($){super("RegExpExtensionDecodeError",`RegExp extension type ${t} could not be decoded: source=${b$($.source,$.sourceByteLength)} flags=${JSON.stringify($.flags)} ${$.reason}`,$.cause===void 0?void 0:{cause:$.cause});this.extensionType=t,this.source=$.source,this.flags=$.flags,this.sourceByteLength=$.sourceByteLength}};V=new R;g0(V,$0);V.register({type:k$,encode:m0,decode:w0});V.register({type:t,encode($){if($ instanceof RegExp)return M({source:$.source,flags:$.flags});return null},decode($){let Z=s(N($)),Q=typeof Z.source==="string"?Z.source:"",W=typeof Z.flags==="string"?Z.flags:"";return y$(Q,W)}});V.register({type:m$,encode($){if($ instanceof Map){let Z=[...$.entries()];return M(Z,{extensionCodec:V})}return null},decode($){let Q=b(N($,{extensionCodec:V})).map((W)=>{let G=b(W);return[G[0],G[1]]});return new Map(Q)}});V.register({type:w$,encode($){if($ instanceof Set){let Z=[...$.values()];return M(Z,{extensionCodec:V})}return null},decode($){let Z=b(N($,{extensionCodec:V}));return new Set(Z)}});f0=Symbol("UndefinedSentinel"),f$=Object.freeze({__tag:f0});V.register({type:j$,encode($){if(v$($))return new Uint8Array(0);return null},decode(){return}});V.register({type:h$,encode($){if($ instanceof Error&&!o($))return M({name:$.name,message:$.message,stack:$.stack});return null},decode($){let Z=s(N($)),Q=typeof Z.name==="string"?Z.name:"Error",W=typeof Z.message==="string"?Z.message:"",G=typeof Z.stack==="string"?Z.stack:void 0,F=Error(W);if(F.name=Q,G!==void 0)F.stack=G;return F}})});function Z0($){let Z=$0($,new Set);return M(Z,{extensionCodec:V})}function Q0($){return N($,{extensionCodec:V})}var c0=J(()=>{g();p0()});function y($,Z=""){let Q=[];return x($,Z,Q,new Set),{valid:Q.length===0,errors:Q}}function a$($){let Z=Object.getPrototypeOf($);return o$(Z)&&!t$($)&&e$(Z)}function o$($){return $!==Object.prototype&&$!==null}function t$($){return Array.isArray($)||$ instanceof Date||$ instanceof RegExp||$ instanceof Map||$ instanceof Set||$ instanceof Error||$ instanceof Uint8Array||$ instanceof ArrayBuffer}function e$($){if(typeof $!=="object"||$===null)return!1;return Object.getOwnPropertyNames($).some((Q)=>{if(Q==="constructor")return!1;let W=Object.getOwnPropertyDescriptor($,Q);return W!==void 0&&typeof W.value==="function"})}function l0($,Z,Q,W){$.push({path:Z,value:Q,reason:W.reason,suggestion:W.suggestion})}function $6($){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 Z6($,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(a$($))return{reason:"Class instances with methods cannot be serialized.",suggestion:"Store only the data and reconstruct the instance."};return null}function Q6($){return $ instanceof Date||$ instanceof RegExp||$ instanceof Error||$ instanceof Uint8Array||$ instanceof ArrayBuffer}function W6($,Z,Q,W){for(let[G,F]of $){let K=String(G);x(F,Z?`${Z}.${K}`:K,Q,W)}}function G6($,Z,Q,W){let G=0;for(let F of $){let K=Z?`${Z}[${G}]`:`[${G}]`;x(F,K,Q,W),G++}}function q6($,Z,Q,W){for(let G=0;G<$.length;G++){let F=Z?`${Z}[${G}]`:`[${G}]`;x($[G],F,Q,W)}}function F6($,Z,Q,W){for(let G of Object.keys($)){let F=Z?`${Z}.${G}`:G;x($[G],F,Q,W)}}function x($,Z,Q,W){if($===null||$===void 0)return;let G=$6($);if(G){l0(Q,Z,$,G);return}if(typeof $!=="object")return;let F=Z6($,W);if(F){l0(Q,Z,$,F);return}W.add($);try{if(Q6($))return;if($ instanceof Map){W6($,Z,Q,W);return}if($ instanceof Set){G6($,Z,Q,W);return}if(Array.isArray($)){q6($,Z,Q,W);return}F6($,Z,Q,W)}finally{W.delete($)}}var n0=J(()=>{c0()});var d0=J(()=>{n0()});function f($){let Z=new WeakSet,Q=(W)=>{if(K6(W))return!0;if(H6(W))return!1;if(Array.isArray(W))return J6(W,Z,Q);if(typeof W==="object")return X6(W,Z,Q);return!1};return Q($)}function JZ($){if($===void 0)return null;if($ instanceof Error)return{name:$.name,message:$.message};if(f($))return $;try{let Z=JSON.stringify($);if(Z===void 0)return W0($);let Q=JSON.parse(Z);return f(Q)?Q:W0($)}catch{return W0($)}}function K6($){if($===null)return!0;if(typeof $==="number")return Number.isFinite($)&&!Object.is($,-0);return typeof $==="string"||typeof $==="boolean"}function H6($){let Z=typeof $;return Z==="undefined"||Z==="bigint"||Z==="function"||Z==="symbol"}function J6($,Z,Q){if(Z.has($))return!1;Z.add($);for(let W of $)if(!Q(W))return!1;return Z.delete($),!0}function X6($,Z,Q){if(!Y6($))return!1;if(Z.has($))return!1;Z.add($);for(let W of Object.values($))if(!Q(W))return!1;return Z.delete($),!0}function W0($){if(typeof $==="bigint")return $.toString();if(typeof $==="symbol")return $.description??null;return null}function Y6($){if(!$||typeof $!=="object")return!1;let Z=Reflect.getPrototypeOf($);return Z===Object.prototype||Z===null}function V6($){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 P6($){let Z={},Q=!1;for(let G of["gt","gte","lt","lte"]){let F=$[G];if(F===void 0)continue;if(typeof F!=="string")throw Error("deleteRange bounds must be strings");Z[G]=F,Q=!0}if(!Q)throw Error("deleteRange requires at least one of gt/gte/lt/lte; use deletePrefix to delete a whole prefix");let W=V6($.limit);if(W!==void 0)Z.limit=W;return Z}async function u0($,Z,Q){let W=P6(Q);if($.deleteRange)return $.deleteRange(Z,W);return K0($,Z,W)}var i0=()=>{};d0();i0();R0();class r0{#$;#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,W]of this.#$.scan($,Z))yield[Q,this.#Z.decode(W)]}async batch($){z("batch operations",$.length),await this.#$.batch(this.#W($))}#W($){return $.map((Q)=>{if(Q.type==="put")return{type:"put",key:Q.key,value:this.#Z.encode(Q.value)};return Q})}#G($){return $.map((Z)=>({key:Z.key,expectedValue:Z.expectedValue===null?null:this.#Z.encode(Z.expectedValue)}))}async conditionalBatch($,Z){return N0(this.#$,this.#G($),this.#W(Z))}async has($){return Y0(this.#$,$)}async deletePrefix($){return M0(this.#$,$)}async deleteRange($,Z){return u0(this.#$,$,Z)}keys($,Z){return V0(this.#$,$,Z)}async count($){return P0(this.#$,$)}[Symbol.dispose](){if(!this.#Q)return;this.#$[Symbol.dispose]()}}function UZ($,Z,Q={}){return new r0($,Z,Q)}function M6($){try{if(!f($))throw TypeError("jsonCodec only supports JSON-serializable values.");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 N6($){let Z=y($);if(!Z.valid)throw TypeError(`msgpackCodec only supports structuredClone-compatible values. ${Z.errors[0]?.reason??""}`.trim());return Z0($)}function R6($){return JSON.parse(new TextDecoder().decode($))}function U6($){let Z=Q0($),Q=y(Z);if(!Q.valid)throw TypeError(`msgpackCodec decoded a non-cloneable value. ${Q.errors[0]?.reason??""}`.trim());return Z}function _Z($){return{encode(Z){return M6(Z)},decode(Z){let Q=R6(Z);return $?$(Q):Q}}}function CZ($){return{encode(Z){return N6(Z)},decode(Z){let Q=U6(Z);return $?$(Q):Q}}}export{UZ as withCodec,CZ as msgpackCodec,_Z as jsonCodec};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var r=Object.defineProperty;var i=(F)=>F;function t(F,J){this[F]=i.bind(null,J)}var qF=(F,J)=>{for(var X in J)r(F,X,{get:J[X],enumerable:!0,configurable:!0,set:t.bind(J,X)})};function b(F){let J=[];for(let X=0;X<F.length;X+=512)J.push(String.fromCharCode(...F.subarray(X,X+512)));return btoa(J.join(""))}function x(F){let J=atob(F),X=new Uint8Array(J.length);for(let $=0;$<J.length;$+=1)X[$]=J.charCodeAt($);return X}function Y(F){return typeof F==="object"&&F!==null&&!Array.isArray(F)}async function j(F,J){return await F.get(J)!==null}async function*G(F,J,X){for await(let[$]of F.scan(J,X))yield $}async function C(F,J){let X=0;for await(let $ of G(F,J))X++;return X}async function T(F,J){let X=[];for await(let $ of G(F,J))X.push({type:"delete",key:$});if(X.length===0)return 0;return await F.batch(X),X.length}async function W(F,J,X){let $=[];for await(let H of G(F,J,X))$.push({type:"delete",key:H});if($.length===0)return 0;return await F.batch($),$.length}function B(F,J,X){if(!F.capabilities()[J])throw Error(`Feature "${X}" requires storage capability "${J}", but this storage backend does not provide it.`)}var v="default";var A=1e4,RF=1e4;class I extends Error{code="StorageBatchOperationLimitExceededError";cap=A;count;target;constructor(F,J){super(`${F} count ${J} exceeds MAX_BATCH_OPERATIONS (${A}).`);this.name="StorageBatchOperationLimitExceededError",this.target=F,this.count=J}}function _(F,J){if(J>A)throw new I(F,J)}function g(F){return F.length>0?F.slice(0,-1)+String.fromCharCode(F.charCodeAt(F.length-1)+1):"ÿ"}function c(F,J={}){if(J.gt!==void 0&&F<=J.gt)return!1;if(J.gte!==void 0&&F<J.gte)return!1;if(J.lt!==void 0&&F>=J.lt)return!1;if(J.lte!==void 0&&F>J.lte)return!1;return!0}function OF(F,J){if(F===null||J===null)return F===J;if(F.byteLength!==J.byteLength)return!1;for(let X=0;X<F.byteLength;X++)if(F[X]!==J[X])return!1;return!0}async function u(F,J){if(F.has)return F.has(J);return j(F,J)}function y(F,J,X){if(F.keys)return F.keys(J,X);return G(F,J,X)}async function w(F,J){if(F.count)return F.count(J);return C(F,J)}async function f(F,J){if(F.deletePrefix)return F.deletePrefix(J);return T(F,J)}async function PF(F,J){_("batch operations",J.length),await F.batch(J)}async function k(F,J,X){if(_("conditionalBatch conditions",J.length),_("conditionalBatch operations",X.length),B(F,"conditionalBatch","storageConditionalBatch"),!F.conditionalBatch)throw Error("This storage backend reports conditionalBatch capability but does not implement the conditionalBatch() method.");return F.conditionalBatch(J,X)}function Z(F){return encodeURIComponent(F)}function SF(F){return decodeURIComponent(F)}function hF(F){try{return decodeURIComponent(F)}catch{return null}}var M=(F)=>String(F).padStart(16,"0"),o="0",e="1",m=(F,J,X,$)=>`sig:${Z(F)}:${Z(J)}:${$}:${Z(X)}`,KF={workflow:(F)=>`wf:${Z(F)}`,checkpoint:(F)=>`wf:${Z(F)}:ckpt`,checkpointHistory:(F,J)=>`wf:${Z(F)}:ckpt:${String(J).padStart(10,"0")}`,timelinePrefix:(F)=>`wf:${Z(F)}:timeline:`,timeline:(F,J)=>`wf:${Z(F)}:timeline:${String(J).padStart(10,"0")}`,schedule:(F)=>`schedule:${Z(F)}`,scheduleTick:(F,J)=>`schedule-due:${String(F).padStart(16,"0")}:${Z(J)}`,scheduleRun:(F)=>`schedule-run:${Z(F)}`,operation:(F,J,X)=>`op:${F}:${M(J)}:${X}`,operationInflight:(F)=>`op:inflight:${F}`,operationQueued:(F)=>`op:queued:${F}`,operationResolved:(F)=>`op:resolved:${F}`,operationDeadLetterPrefix:()=>"op:dead-letter:",operationDeadLetter:(F)=>`op:dead-letter:${F}`,bulkOperationAuditPrefix:()=>"audit:bulk:",bulkOperationAudit:(F,J,X)=>`audit:bulk:${M(F)}:${Z(J)}:${Z(X)}`,operationResolvedByTimePrefix:()=>"op:resolved-by-time:",operationResolvedByTime:(F,J)=>`op:resolved-by-time:${M(F)}:${Z(J)}`,asyncActivity:(F,J)=>`async-act:v1:${Z(F)}:${Z(J)}`,activityReconciliationPrefix:(F)=>`actrec:v1:${Z(F)}:`,activityReconciliation:(F,J,X)=>`actrec:v1:${Z(F)}:${Z(J)}:${X}`,eventPrefix:(F)=>`ev:${Z(F)}:`,event:(F,J)=>`ev:${Z(F)}:${String(J).padStart(10,"0")}`,eventHead:(F)=>`ev:${Z(F)}:head`,eventWatermark:(F)=>`ev:${Z(F)}:watermark`,fleetEventPrefix:()=>"fleet-event:",fleetEvent:(F)=>`fleet-event:${String(F).padStart(10,"0")}`,fleetEventTail:()=>"fleet-event-tail",fleetEventByWorkflowPrefix:(F)=>`fleet-event-by-workflow:${Z(F)}:`,fleetEventByWorkflow:(F,J)=>`fleet-event-by-workflow:${Z(F)}:${String(J).padStart(10,"0")}`,signal:(F,J,X)=>m(F,J,X,e),startSignal:(F,J,X)=>m(F,J,X,o),signalSequence:(F)=>`sigseq:v1:${Z(F)}`,signalAcceptedResponsePrefix:(F)=>`sigres:v1:${Z(F)}:`,signalAcceptedResponse:(F,J,X)=>`sigres:v1:${Z(F)}:${Z(J)}:${Z(X)}`,deadline:(F,J)=>`wf-deadline:${M(F)}:${Z(J)}`,terminalCleanup:(F,J)=>`wf-cleanup:${M(F)}:${Z(J)}`,teardownTimer:(F,J)=>`wf-teardown:${M(F)}:${Z(J)}`,delayedStart:(F,J)=>`wf-delayed:${M(F)}:${Z(J)}`,terminalWorkflowPrefix:()=>"wf-terminal:",terminalWorkflow:(F,J)=>`wf-terminal:${M(F)}:${Z(J)}`,attribute:(F)=>`attr:${Z(F)}`,attributeIndex:(F,J,X)=>`idx:${F}:${J}:${Z(X)}`,tagIndex:(F,J)=>`tag:${Z(F)}:${Z(J)}`,updatePrefix:(F)=>`upd:${Z(F)}:`,update:(F,J)=>`upd:${Z(F)}:${J}`,updateResponse:(F)=>`upr:${F}`,updateIdempotency:(F,J)=>`upk:${Z(F)}:${J}`,startIdempotency:(F)=>`start-idem:${Z(F)}`,startIdempotencySignalId:(F)=>`start-idem:${F}`,livenessPrefix:()=>"liveness:",liveness:(F)=>`liveness:${Z(F)}`,leasePrefix:()=>"lease:",leaseEpoch:()=>"lease:epoch",leaseHolder:()=>"lease:holder",budget:(F,J,X)=>`budget:${F}:${J}:${X}`,review:(F,J)=>`review:${Z(F)}:${J}`,workflowHeaders:(F)=>`wf-headers:${Z(F)}`,childCancellationPrefix:(F)=>`child-cancel:${Z(F)}:`,childCancellation:(F,J)=>`child-cancel:${Z(F)}:${Z(J)}`,terminalCleanupNeeded:(F)=>`wf-cleanup-needed:${Z(F)}`,workflowConcurrency:(F,J)=>`wf-concurrency:${Z(F)}:${Z(J)}`,workflowConcurrencyHolder:(F)=>`wf-concurrency-holder:${Z(F)}`,workflowHasServices:(F)=>`wf-has-services:${Z(F)}`,finalizerState:(F)=>`wf-finalizer-state:${Z(F)}`,teardownOwed:(F)=>`wf-teardown-needed:${Z(F)}`,teardownDeadLetter:(F)=>`wf-teardown-deadletter:${Z(F)}`,offload:(F,J)=>`offload:${Z(F)}:${J}`,archive:(F,J)=>`archive:${Z(F)}:${J}`,stateExecution:(F,J)=>`state:execution:${Z(F)}:${Z(J)}`,stateWorkflow:(F,J)=>`state:workflow-scope:${v}:${Z(F)}:${Z(J)}`,streamChunkPrefix:(F,J)=>`blob:${Z(F)}:${J}:chunk:`,streamChunk:(F,J,X)=>`blob:${Z(F)}:${J}:chunk:${String(X).padStart(10,"0")}`,streamTail:(F,J)=>`blob:${Z(F)}:${J}:tail`,streamMetadata:(F,J)=>`blob:${Z(F)}:${J}:meta`,budgetCharged:(F)=>`budget-charged:${F}`,toolEffect:(F,J,X)=>`tool-effect:${Z(F)}:${J}:${X}`,workflowVisibilityStatus:(F,J)=>`wf-idx-status:${Z(F)}:${Z(J)}`,workflowVisibilityType:(F,J)=>`wf-idx-type:${Z(F)}:${Z(J)}`,workflowVisibilityCreated:(F,J)=>`wf-idx-created:${M(F)}:${Z(J)}`,workflowVisibilityUpdated:(F,J)=>`wf-idx-updated:${M(F)}:${Z(J)}`,workflowVisibilityDeadline:(F,J)=>`wf-idx-deadline:${M(F)}:${Z(J)}`,workflowVisibilityManifest:(F)=>`wf-idx-manifest:${Z(F)}`,workflowVisibilityMetaVersion:()=>"wf-idx-meta:version",workflowVisibilityMetaBuiltAt:()=>"wf-idx-meta:built-at",workflowVisibilityMetaCursor:()=>"wf-idx-meta:cursor"};function FF(F){if(F===void 0)return;if(typeof F!=="number"||!Number.isInteger(F)||F<0)throw Error("deleteRange limit must be a finite non-negative integer");return F===0?0:F}function N(F){let J={},X=!1;for(let H of["gt","gte","lt","lte"]){let U=F[H];if(U===void 0)continue;if(typeof U!=="string")throw Error("deleteRange bounds must be strings");J[H]=U,X=!0}if(!X)throw Error("deleteRange requires at least one of gt/gte/lt/lte; use deletePrefix to delete a whole prefix");let $=FF(F.limit);if($!==void 0)J.limit=$;return J}async function d(F,J,X){let $=N(X);if(F.deleteRange)return F.deleteRange(J,$);return W(F,J,$)}function JF(F,J){let X={key:F,open:!1};if(J.gte!==void 0&&J.gte>X.key)X.key=J.gte,X.open=!1;if(J.gt!==void 0&&J.gt>=X.key)X.key=J.gt,X.open=!0;return X}function XF(F,J){let X={key:g(F),open:!0};if(J.lt!==void 0&&J.lt<=X.key)X.key=J.lt,X.open=!0;if(J.lte!==void 0&&J.lte<X.key)X.key=J.lte,X.open=!1;return X}function IF(F,J){let X=JF(F,J),$=XF(F,J);if(X.key>$.key||X.key===$.key&&(X.open||$.open))return null;return{lower:X,upper:$}}function E(F){return F.replaceAll(/:+$/g,"")}function ZF(F,J){let X=E(F),$=E(J);if(X.length===0)return $;if($.length===0)return X;return`${X}:${$}`}class R{#J;#X;constructor(F,J){this.#J=F,this.#X=E(J)}#F(F){if(this.#X.length===0)return F;return F.length===0?`${this.#X}:`:`${this.#X}:${F}`}#Z(F){if(this.#X.length===0)return F;return F.slice(this.#X.length+1)}#$(F={}){let J={};if(F.limit!==void 0)J.limit=F.limit;if(F.reverse!==void 0)J.reverse=F.reverse;if(F.gt!==void 0)J.gt=this.#F(F.gt);if(F.gte!==void 0)J.gte=this.#F(F.gte);if(F.lt!==void 0)J.lt=this.#F(F.lt);if(F.lte!==void 0)J.lte=this.#F(F.lte);return J}#U(F){let J={};if(F.limit!==void 0)J.limit=F.limit;if(F.gt!==void 0)J.gt=this.#F(F.gt);if(F.gte!==void 0)J.gte=this.#F(F.gte);if(F.lt!==void 0)J.lt=this.#F(F.lt);if(F.lte!==void 0)J.lte=this.#F(F.lte);return J}capabilities(){return this.#J.capabilities()}scoped(F){return new R(this.#J,ZF(this.#X,F))}async get(F){return this.#J.get(this.#F(F))}async put(F,J){await this.#J.put(this.#F(F),J)}async delete(F){await this.#J.delete(this.#F(F))}async*scan(F,J){for await(let[X,$]of this.#J.scan(this.#F(F),this.#$(J)))yield[this.#Z(X),$]}async batch(F){_("batch operations",F.length),await this.#J.batch(F.map((J)=>{if(J.type==="put")return{type:"put",key:this.#F(J.key),value:J.value};return{type:"delete",key:this.#F(J.key)}}))}async conditionalBatch(F,J){return k(this.#J,F.map((X)=>({key:this.#F(X.key),expectedValue:X.expectedValue})),J.map((X)=>{if(X.type==="put")return{type:"put",key:this.#F(X.key),value:X.value};return{type:"delete",key:this.#F(X.key)}}))}async has(F){return u(this.#J,this.#F(F))}async deletePrefix(F){return f(this.#J,this.#F(F))}async deleteRange(F,J){let X=this.#U(N(J));return d(this.#J,this.#F(F),X)}async*keys(F,J){for await(let X of y(this.#J,this.#F(F),this.#$(J)))yield this.#Z(X)}async count(F){return w(this.#J,this.#F(F))}[Symbol.dispose](){this.#J[Symbol.dispose]()}}function l(F,J){return new R(F,J)}var s=1,q="__weftStorageKeyspace",$F=102400,UF=8192;function HF(F){return typeof F==="object"&&F!==null&&"then"in F&&typeof F.then==="function"}function S(F){if(!Y(F))return!1;if(F.__weftStorage!==s)return!1;return typeof F.value==="string"}function MF(F){if(!Y(F))return!1;return Object.values(F).every(S)}function z(F){if(F!==q)return;throw Error(`WebExtensionStorage key "${q}" is reserved for adapter metadata.`)}function VF(F){for(let J of F)z(J.key)}function p(F){return{__weftStorage:s,value:b(F)}}function n(F){if(!S(F))return null;return x(F.value)}function GF(F){return S(F)}function O(F){return new TextEncoder().encode(JSON.stringify(F)).byteLength}function _F(F){if(!Y(F))return!1;if(F.runtime!==void 0&&!Y(F.runtime))return!1;return F.storage===void 0||Y(F.storage)}function YF(F=void 0){if(F!==void 0){if(!_F(F))throw Error("WebExtensionStorage injected namespace must be an object.");return F}let J=globalThis,X=J.browser??J.chrome;if(X?.storage===void 0)throw Error("WebExtensionStorage requires globalThis.browser.storage or globalThis.chrome.storage.");return X}function LF(F,J){let X=F.storage?.[J];if(X===void 0)throw Error(`WebExtensionStorage area "${J}" is not available.`);return X}function NF(F){if(F==="session")return"ephemeral";if(F==="sync"||F==="managed")return"remote";return"local"}function QF(F){let J=F.runtime?.lastError?.message;return J===void 0?null:Error(J)}async function P(F,J,X){return new Promise(($,H)=>{let U=!1,L=(V)=>{if(U)return;let K=QF(F);if(U=!0,K!==null)H(K);else $(V)},h=(V)=>{if(U)return;U=!0,H(V)},a=(V)=>L(V),D;try{D=J(a)}catch{try{D=X()}catch(V){h(V);return}}if(HF(D))D.then(L,h)})}class Q{static#J=new WeakMap;#X;#F;#Z;#$;#U;constructor(F={},J=void 0){this.#Z=F.area??"local",this.#$=NF(this.#Z),this.#X=YF(J),this.#F=LF(this.#X,this.#Z),this.#U=()=>{},this.#X.storage?.onChanged?.addListener?.(this.#U)}capabilities(){return{persistence:this.#$,readAfterWrite:"session",scanConsistency:"best-effort",atomicBatch:!1,conditionalBatch:!1,boundedRangeDelete:!1}}async#_(F){return P(this.#X,(J)=>this.#F.get(F,J),()=>this.#F.get(F))}async#L(F){await P(this.#X,(J)=>this.#F.set(F,J),()=>this.#F.set(F))}async#Y(F){if(this.#F.getBytesInUse===void 0)return null;return P(this.#X,(J)=>this.#F.getBytesInUse?.(F,J),()=>this.#F.getBytesInUse?.(F))}async#H(){let J=(await this.#_(q))[q];if(J===void 0)return{};if(!MF(J))throw Error("WebExtensionStorage keyspace is not a valid storage envelope map.");return{...J}}async#V(F){let J={[q]:F};await this.#q(J),await this.#L(J)}async#G(F){let J=Q.#J.get(this.#F)??Promise.resolve(),X={},$=new Promise((U)=>{X.release=U}),H=J.catch(()=>{return}).then(()=>$);Q.#J.set(this.#F,H),await J.catch(()=>{return});try{return await F()}finally{if(X.release?.(),Q.#J.get(this.#F)===H)Q.#J.delete(this.#F)}}#M(){if(this.#Z==="managed")throw Error('WebExtensionStorage area "managed" is read-only.')}#N(F){let J=this.#F.QUOTA_BYTES_PER_ITEM??UF;for(let[X,$]of Object.entries(F)){let H=O({[X]:$});if(H>J)throw Error(`WebExtensionStorage sync item quota exceeded for "${X}": ${String(H)} > ${String(J)}.`)}}async#Q(F){let J=Object.keys(F),X=await this.#Y(null),$=await this.#Y(J);if(X!==null&&$!==null)return X-$+O(F);let H=await this.#_(null);return O({...H,...F})}async#q(F){if(this.#Z!=="sync")return;this.#N(F);let J=this.#F.QUOTA_BYTES??$F,X=await this.#Q(F);if(X>J)throw Error(`WebExtensionStorage sync total quota exceeded: ${String(X)} > ${String(J)}.`)}async get(F){z(F);let J=await this.#H();return n(J[F])}async put(F,J){this.#M(),z(F),await this.#G(async()=>{let X=await this.#H();X[F]=p(J),await this.#V(X)})}async delete(F){this.#M(),z(F),await this.#G(async()=>{let J=await this.#H();if(!(F in J))return;delete J[F],await this.#V(J)})}async*scan(F,J={}){let X=await this.#H(),$=Object.keys(X).filter((U)=>U.startsWith(F)).filter((U)=>c(U,J)).filter((U)=>GF(X[U])).toSorted();if(J.reverse)$=$.toReversed();let H=0;for(let U of $){if(J.limit!==void 0&&H>=J.limit)break;let L=n(X[U]);if(L===null)continue;yield[U,L],H+=1}}async batch(F){if(_("batch operations",F.length),this.#M(),F.length===0)return;VF(F),await this.#G(async()=>{let J=await this.#H();for(let X of F)if(X.type==="put")J[X.key]=p(X.value);else delete J[X.key];await this.#V(J)})}has(F){return j(this,F)}async*keys(F,J){yield*G(this,F,J)}count(F){return C(this,F)}async deletePrefix(F){return this.#M(),T(this,F)}async deleteRange(F,J){let X=N(J);return this.#M(),W(this,F,X)}scoped(F){return l(this,F)}[Symbol.dispose](){this.#X.storage?.onChanged?.removeListener?.(this.#U)}}export{Q as WebExtensionStorage};
|
|
1
|
+
var r=Object.defineProperty;var i=(F)=>F;function t(F,J){this[F]=i.bind(null,J)}var qF=(F,J)=>{for(var X in J)r(F,X,{get:J[X],enumerable:!0,configurable:!0,set:t.bind(J,X)})};function b(F){let J=[];for(let X=0;X<F.length;X+=512)J.push(String.fromCharCode(...F.subarray(X,X+512)));return btoa(J.join(""))}function x(F){let J=atob(F),X=new Uint8Array(J.length);for(let $=0;$<J.length;$+=1)X[$]=J.charCodeAt($);return X}function Y(F){return typeof F==="object"&&F!==null&&!Array.isArray(F)}async function j(F,J){return await F.get(J)!==null}async function*G(F,J,X){for await(let[$]of F.scan(J,X))yield $}async function C(F,J){let X=0;for await(let $ of G(F,J))X++;return X}async function T(F,J){let X=[];for await(let $ of G(F,J))X.push({type:"delete",key:$});if(X.length===0)return 0;return await F.batch(X),X.length}async function W(F,J,X){let $=[];for await(let H of G(F,J,X))$.push({type:"delete",key:H});if($.length===0)return 0;return await F.batch($),$.length}function B(F,J,X){if(!F.capabilities()[J])throw Error(`Feature "${X}" requires storage capability "${J}", but this storage backend does not provide it.`)}var v="default";var A=1e4,RF=1e4;class I extends Error{code="StorageBatchOperationLimitExceededError";cap=A;count;target;constructor(F,J){super(`${F} count ${J} exceeds MAX_BATCH_OPERATIONS (${A}).`);this.name="StorageBatchOperationLimitExceededError",this.target=F,this.count=J}}function _(F,J){if(J>A)throw new I(F,J)}function g(F){return F.length>0?F.slice(0,-1)+String.fromCharCode(F.charCodeAt(F.length-1)+1):"ÿ"}function c(F,J={}){if(J.gt!==void 0&&F<=J.gt)return!1;if(J.gte!==void 0&&F<J.gte)return!1;if(J.lt!==void 0&&F>=J.lt)return!1;if(J.lte!==void 0&&F>J.lte)return!1;return!0}function OF(F,J){if(F===null||J===null)return F===J;if(F.byteLength!==J.byteLength)return!1;for(let X=0;X<F.byteLength;X++)if(F[X]!==J[X])return!1;return!0}async function u(F,J){if(F.has)return F.has(J);return j(F,J)}function y(F,J,X){if(F.keys)return F.keys(J,X);return G(F,J,X)}async function w(F,J){if(F.count)return F.count(J);return C(F,J)}async function f(F,J){if(F.deletePrefix)return F.deletePrefix(J);return T(F,J)}async function PF(F,J){_("batch operations",J.length),await F.batch(J)}async function k(F,J,X){if(_("conditionalBatch conditions",J.length),_("conditionalBatch operations",X.length),B(F,"conditionalBatch","storageConditionalBatch"),!F.conditionalBatch)throw Error("This storage backend reports conditionalBatch capability but does not implement the conditionalBatch() method.");return F.conditionalBatch(J,X)}function Z(F){return encodeURIComponent(F)}function SF(F){return decodeURIComponent(F)}function hF(F){try{return decodeURIComponent(F)}catch{return null}}var M=(F)=>String(F).padStart(16,"0"),o="0",e="1",m=(F,J,X,$)=>`sig:${Z(F)}:${Z(J)}:${$}:${Z(X)}`,KF={workflow:(F)=>`wf:${Z(F)}`,checkpoint:(F)=>`wf:${Z(F)}:ckpt`,checkpointHistory:(F,J)=>`wf:${Z(F)}:ckpt:${String(J).padStart(10,"0")}`,timelinePrefix:(F)=>`wf:${Z(F)}:timeline:`,timeline:(F,J)=>`wf:${Z(F)}:timeline:${String(J).padStart(10,"0")}`,schedule:(F)=>`schedule:${Z(F)}`,scheduleTick:(F,J)=>`schedule-due:${String(F).padStart(16,"0")}:${Z(J)}`,scheduleRun:(F)=>`schedule-run:${Z(F)}`,operation:(F,J,X)=>`op:${F}:${M(J)}:${X}`,operationInflight:(F)=>`op:inflight:${F}`,operationQueued:(F)=>`op:queued:${F}`,operationResolved:(F)=>`op:resolved:${F}`,operationDeadLetterPrefix:()=>"op:dead-letter:",operationDeadLetter:(F)=>`op:dead-letter:${F}`,bulkOperationAuditPrefix:()=>"audit:bulk:",bulkOperationAudit:(F,J,X)=>`audit:bulk:${M(F)}:${Z(J)}:${Z(X)}`,operationResolvedByTimePrefix:()=>"op:resolved-by-time:",operationResolvedByTime:(F,J)=>`op:resolved-by-time:${M(F)}:${Z(J)}`,asyncActivity:(F,J)=>`async-act:v1:${Z(F)}:${Z(J)}`,asyncActivityResolution:(F,J)=>`async-act:v1:${Z(F)}:${Z(J)}:resolution`,activityReconciliationPrefix:(F)=>`actrec:v1:${Z(F)}:`,activityReconciliation:(F,J,X)=>`actrec:v1:${Z(F)}:${Z(J)}:${X}`,eventPrefix:(F)=>`ev:${Z(F)}:`,event:(F,J)=>`ev:${Z(F)}:${String(J).padStart(10,"0")}`,eventHead:(F)=>`ev:${Z(F)}:head`,eventWatermark:(F)=>`ev:${Z(F)}:watermark`,fleetEventPrefix:()=>"fleet-event:",fleetEvent:(F)=>`fleet-event:${String(F).padStart(10,"0")}`,fleetEventTail:()=>"fleet-event-tail",fleetEventByWorkflowPrefix:(F)=>`fleet-event-by-workflow:${Z(F)}:`,fleetEventByWorkflow:(F,J)=>`fleet-event-by-workflow:${Z(F)}:${String(J).padStart(10,"0")}`,signal:(F,J,X)=>m(F,J,X,e),startSignal:(F,J,X)=>m(F,J,X,o),signalSequence:(F)=>`sigseq:v1:${Z(F)}`,signalAcceptedResponsePrefix:(F)=>`sigres:v1:${Z(F)}:`,signalAcceptedResponse:(F,J,X)=>`sigres:v1:${Z(F)}:${Z(J)}:${Z(X)}`,deadline:(F,J)=>`wf-deadline:${M(F)}:${Z(J)}`,terminalCleanup:(F,J)=>`wf-cleanup:${M(F)}:${Z(J)}`,teardownTimer:(F,J)=>`wf-teardown:${M(F)}:${Z(J)}`,delayedStart:(F,J)=>`wf-delayed:${M(F)}:${Z(J)}`,terminalWorkflowPrefix:()=>"wf-terminal:",terminalWorkflow:(F,J)=>`wf-terminal:${M(F)}:${Z(J)}`,attribute:(F)=>`attr:${Z(F)}`,attributeIndex:(F,J,X)=>`idx:${F}:${J}:${Z(X)}`,tagIndex:(F,J)=>`tag:${Z(F)}:${Z(J)}`,updatePrefix:(F)=>`upd:${Z(F)}:`,update:(F,J)=>`upd:${Z(F)}:${J}`,updateResponse:(F)=>`upr:${F}`,updateIdempotency:(F,J)=>`upk:${Z(F)}:${J}`,startIdempotency:(F)=>`start-idem:${Z(F)}`,startIdempotencySignalId:(F)=>`start-idem:${F}`,livenessPrefix:()=>"liveness:",liveness:(F)=>`liveness:${Z(F)}`,leasePrefix:()=>"lease:",leaseEpoch:()=>"lease:epoch",leaseHolder:()=>"lease:holder",budget:(F,J,X)=>`budget:${F}:${J}:${X}`,review:(F,J)=>`review:${Z(F)}:${J}`,workflowHeaders:(F)=>`wf-headers:${Z(F)}`,childCancellationPrefix:(F)=>`child-cancel:${Z(F)}:`,childCancellation:(F,J)=>`child-cancel:${Z(F)}:${Z(J)}`,terminalCleanupNeeded:(F)=>`wf-cleanup-needed:${Z(F)}`,workflowConcurrency:(F,J)=>`wf-concurrency:${Z(F)}:${Z(J)}`,workflowConcurrencyHolder:(F)=>`wf-concurrency-holder:${Z(F)}`,workflowHasServices:(F)=>`wf-has-services:${Z(F)}`,finalizerState:(F)=>`wf-finalizer-state:${Z(F)}`,teardownOwed:(F)=>`wf-teardown-needed:${Z(F)}`,teardownDeadLetter:(F)=>`wf-teardown-deadletter:${Z(F)}`,offload:(F,J)=>`offload:${Z(F)}:${J}`,archive:(F,J)=>`archive:${Z(F)}:${J}`,stateExecution:(F,J)=>`state:execution:${Z(F)}:${Z(J)}`,stateWorkflow:(F,J)=>`state:workflow-scope:${v}:${Z(F)}:${Z(J)}`,streamChunkPrefix:(F,J)=>`blob:${Z(F)}:${J}:chunk:`,streamChunk:(F,J,X)=>`blob:${Z(F)}:${J}:chunk:${String(X).padStart(10,"0")}`,streamTail:(F,J)=>`blob:${Z(F)}:${J}:tail`,streamMetadata:(F,J)=>`blob:${Z(F)}:${J}:meta`,budgetCharged:(F)=>`budget-charged:${F}`,toolEffect:(F,J,X)=>`tool-effect:${Z(F)}:${J}:${X}`,workflowVisibilityStatus:(F,J)=>`wf-idx-status:${Z(F)}:${Z(J)}`,workflowVisibilityType:(F,J)=>`wf-idx-type:${Z(F)}:${Z(J)}`,workflowVisibilityCreated:(F,J)=>`wf-idx-created:${M(F)}:${Z(J)}`,workflowVisibilityUpdated:(F,J)=>`wf-idx-updated:${M(F)}:${Z(J)}`,workflowVisibilityDeadline:(F,J)=>`wf-idx-deadline:${M(F)}:${Z(J)}`,workflowVisibilityManifest:(F)=>`wf-idx-manifest:${Z(F)}`,workflowVisibilityMetaVersion:()=>"wf-idx-meta:version",workflowVisibilityMetaBuiltAt:()=>"wf-idx-meta:built-at",workflowVisibilityMetaCursor:()=>"wf-idx-meta:cursor"};function FF(F){if(F===void 0)return;if(typeof F!=="number"||!Number.isInteger(F)||F<0)throw Error("deleteRange limit must be a finite non-negative integer");return F===0?0:F}function N(F){let J={},X=!1;for(let H of["gt","gte","lt","lte"]){let U=F[H];if(U===void 0)continue;if(typeof U!=="string")throw Error("deleteRange bounds must be strings");J[H]=U,X=!0}if(!X)throw Error("deleteRange requires at least one of gt/gte/lt/lte; use deletePrefix to delete a whole prefix");let $=FF(F.limit);if($!==void 0)J.limit=$;return J}async function d(F,J,X){let $=N(X);if(F.deleteRange)return F.deleteRange(J,$);return W(F,J,$)}function JF(F,J){let X={key:F,open:!1};if(J.gte!==void 0&&J.gte>X.key)X.key=J.gte,X.open=!1;if(J.gt!==void 0&&J.gt>=X.key)X.key=J.gt,X.open=!0;return X}function XF(F,J){let X={key:g(F),open:!0};if(J.lt!==void 0&&J.lt<=X.key)X.key=J.lt,X.open=!0;if(J.lte!==void 0&&J.lte<X.key)X.key=J.lte,X.open=!1;return X}function IF(F,J){let X=JF(F,J),$=XF(F,J);if(X.key>$.key||X.key===$.key&&(X.open||$.open))return null;return{lower:X,upper:$}}function E(F){return F.replaceAll(/:+$/g,"")}function ZF(F,J){let X=E(F),$=E(J);if(X.length===0)return $;if($.length===0)return X;return`${X}:${$}`}class R{#J;#X;constructor(F,J){this.#J=F,this.#X=E(J)}#F(F){if(this.#X.length===0)return F;return F.length===0?`${this.#X}:`:`${this.#X}:${F}`}#Z(F){if(this.#X.length===0)return F;return F.slice(this.#X.length+1)}#$(F={}){let J={};if(F.limit!==void 0)J.limit=F.limit;if(F.reverse!==void 0)J.reverse=F.reverse;if(F.gt!==void 0)J.gt=this.#F(F.gt);if(F.gte!==void 0)J.gte=this.#F(F.gte);if(F.lt!==void 0)J.lt=this.#F(F.lt);if(F.lte!==void 0)J.lte=this.#F(F.lte);return J}#U(F){let J={};if(F.limit!==void 0)J.limit=F.limit;if(F.gt!==void 0)J.gt=this.#F(F.gt);if(F.gte!==void 0)J.gte=this.#F(F.gte);if(F.lt!==void 0)J.lt=this.#F(F.lt);if(F.lte!==void 0)J.lte=this.#F(F.lte);return J}capabilities(){return this.#J.capabilities()}scoped(F){return new R(this.#J,ZF(this.#X,F))}async get(F){return this.#J.get(this.#F(F))}async put(F,J){await this.#J.put(this.#F(F),J)}async delete(F){await this.#J.delete(this.#F(F))}async*scan(F,J){for await(let[X,$]of this.#J.scan(this.#F(F),this.#$(J)))yield[this.#Z(X),$]}async batch(F){_("batch operations",F.length),await this.#J.batch(F.map((J)=>{if(J.type==="put")return{type:"put",key:this.#F(J.key),value:J.value};return{type:"delete",key:this.#F(J.key)}}))}async conditionalBatch(F,J){return k(this.#J,F.map((X)=>({key:this.#F(X.key),expectedValue:X.expectedValue})),J.map((X)=>{if(X.type==="put")return{type:"put",key:this.#F(X.key),value:X.value};return{type:"delete",key:this.#F(X.key)}}))}async has(F){return u(this.#J,this.#F(F))}async deletePrefix(F){return f(this.#J,this.#F(F))}async deleteRange(F,J){let X=this.#U(N(J));return d(this.#J,this.#F(F),X)}async*keys(F,J){for await(let X of y(this.#J,this.#F(F),this.#$(J)))yield this.#Z(X)}async count(F){return w(this.#J,this.#F(F))}[Symbol.dispose](){this.#J[Symbol.dispose]()}}function l(F,J){return new R(F,J)}var s=1,q="__weftStorageKeyspace",$F=102400,UF=8192;function HF(F){return typeof F==="object"&&F!==null&&"then"in F&&typeof F.then==="function"}function S(F){if(!Y(F))return!1;if(F.__weftStorage!==s)return!1;return typeof F.value==="string"}function MF(F){if(!Y(F))return!1;return Object.values(F).every(S)}function z(F){if(F!==q)return;throw Error(`WebExtensionStorage key "${q}" is reserved for adapter metadata.`)}function VF(F){for(let J of F)z(J.key)}function p(F){return{__weftStorage:s,value:b(F)}}function n(F){if(!S(F))return null;return x(F.value)}function GF(F){return S(F)}function O(F){return new TextEncoder().encode(JSON.stringify(F)).byteLength}function _F(F){if(!Y(F))return!1;if(F.runtime!==void 0&&!Y(F.runtime))return!1;return F.storage===void 0||Y(F.storage)}function YF(F=void 0){if(F!==void 0){if(!_F(F))throw Error("WebExtensionStorage injected namespace must be an object.");return F}let J=globalThis,X=J.browser??J.chrome;if(X?.storage===void 0)throw Error("WebExtensionStorage requires globalThis.browser.storage or globalThis.chrome.storage.");return X}function LF(F,J){let X=F.storage?.[J];if(X===void 0)throw Error(`WebExtensionStorage area "${J}" is not available.`);return X}function NF(F){if(F==="session")return"ephemeral";if(F==="sync"||F==="managed")return"remote";return"local"}function QF(F){let J=F.runtime?.lastError?.message;return J===void 0?null:Error(J)}async function P(F,J,X){return new Promise(($,H)=>{let U=!1,L=(V)=>{if(U)return;let K=QF(F);if(U=!0,K!==null)H(K);else $(V)},h=(V)=>{if(U)return;U=!0,H(V)},a=(V)=>L(V),D;try{D=J(a)}catch{try{D=X()}catch(V){h(V);return}}if(HF(D))D.then(L,h)})}class Q{static#J=new WeakMap;#X;#F;#Z;#$;#U;constructor(F={},J=void 0){this.#Z=F.area??"local",this.#$=NF(this.#Z),this.#X=YF(J),this.#F=LF(this.#X,this.#Z),this.#U=()=>{},this.#X.storage?.onChanged?.addListener?.(this.#U)}capabilities(){return{persistence:this.#$,readAfterWrite:"session",scanConsistency:"best-effort",atomicBatch:!1,conditionalBatch:!1,boundedRangeDelete:!1}}async#_(F){return P(this.#X,(J)=>this.#F.get(F,J),()=>this.#F.get(F))}async#L(F){await P(this.#X,(J)=>this.#F.set(F,J),()=>this.#F.set(F))}async#Y(F){if(this.#F.getBytesInUse===void 0)return null;return P(this.#X,(J)=>this.#F.getBytesInUse?.(F,J),()=>this.#F.getBytesInUse?.(F))}async#H(){let J=(await this.#_(q))[q];if(J===void 0)return{};if(!MF(J))throw Error("WebExtensionStorage keyspace is not a valid storage envelope map.");return{...J}}async#V(F){let J={[q]:F};await this.#q(J),await this.#L(J)}async#G(F){let J=Q.#J.get(this.#F)??Promise.resolve(),X={},$=new Promise((U)=>{X.release=U}),H=J.catch(()=>{return}).then(()=>$);Q.#J.set(this.#F,H),await J.catch(()=>{return});try{return await F()}finally{if(X.release?.(),Q.#J.get(this.#F)===H)Q.#J.delete(this.#F)}}#M(){if(this.#Z==="managed")throw Error('WebExtensionStorage area "managed" is read-only.')}#N(F){let J=this.#F.QUOTA_BYTES_PER_ITEM??UF;for(let[X,$]of Object.entries(F)){let H=O({[X]:$});if(H>J)throw Error(`WebExtensionStorage sync item quota exceeded for "${X}": ${String(H)} > ${String(J)}.`)}}async#Q(F){let J=Object.keys(F),X=await this.#Y(null),$=await this.#Y(J);if(X!==null&&$!==null)return X-$+O(F);let H=await this.#_(null);return O({...H,...F})}async#q(F){if(this.#Z!=="sync")return;this.#N(F);let J=this.#F.QUOTA_BYTES??$F,X=await this.#Q(F);if(X>J)throw Error(`WebExtensionStorage sync total quota exceeded: ${String(X)} > ${String(J)}.`)}async get(F){z(F);let J=await this.#H();return n(J[F])}async put(F,J){this.#M(),z(F),await this.#G(async()=>{let X=await this.#H();X[F]=p(J),await this.#V(X)})}async delete(F){this.#M(),z(F),await this.#G(async()=>{let J=await this.#H();if(!(F in J))return;delete J[F],await this.#V(J)})}async*scan(F,J={}){let X=await this.#H(),$=Object.keys(X).filter((U)=>U.startsWith(F)).filter((U)=>c(U,J)).filter((U)=>GF(X[U])).toSorted();if(J.reverse)$=$.toReversed();let H=0;for(let U of $){if(J.limit!==void 0&&H>=J.limit)break;let L=n(X[U]);if(L===null)continue;yield[U,L],H+=1}}async batch(F){if(_("batch operations",F.length),this.#M(),F.length===0)return;VF(F),await this.#G(async()=>{let J=await this.#H();for(let X of F)if(X.type==="put")J[X.key]=p(X.value);else delete J[X.key];await this.#V(J)})}has(F){return j(this,F)}async*keys(F,J){yield*G(this,F,J)}count(F){return C(this,F)}async deletePrefix(F){return this.#M(),T(this,F)}async deleteRange(F,J){let X=N(J);return this.#M(),W(this,F,X)}scoped(F){return l(this,F)}[Symbol.dispose](){this.#X.storage?.onChanged?.removeListener?.(this.#U)}}export{Q as WebExtensionStorage};
|