var a=new Set(["__proto__","constructor","prototype"]);function i(r){if(a.has(r))throw new Error(`Invalid state key: "${r}"`)}var h=class{constructor(t={}){this._state=Object.create(null),Object.assign(this._state,{messages:[],errors:[],artifacts:{},metadata:{},...t}),this._history=[]}get(t){return this._state[t]}set(t,s){i(t),this._history.push({...this._state}),this._state[t]=s}update(t){let s=Object.getOwnPropertyNames(t);for(let e of s)i(e);this._history.push({...this._state});for(let e of s)this._state[e]=t[e]}append(t,s){i(t),this._history.push({...this._state}),Array.isArray(this._state[t])||(this._state[t]=[]),this._state[t].push(s)}getAll(){return{...this._state}}rollback(){this._history.length>0&&(this._state=this._history.pop())}};export{h as WorkflowState};
