var h=Object.defineProperty;var u=(s,t,e)=>t in s?h(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var a=(s,t,e)=>(u(s,typeof t!="symbol"?t+"":t,e),e);import{P as r}from"./pubsub.1dc45978.js";import{D as g,eD as c}from"./registerWidgets.6f5be576.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[t]="aa6174ed-7066-446a-a15f-730b0b4b8d17",s._sentryDebugIdIdentifier="sentry-dbid-aa6174ed-7066-446a-a15f-730b0b4b8d17")}catch{}})();class n{constructor(t,e,i){a(this,"initialState");a(this,"_changes");a(this,"api");a(this,"idKey");a(this,"pubsub");this.initialState=e,this._changes=g({}),this.api=t,this.idKey=i,this.pubsub=new r}static create(t,e,i=null){return c(new n(t,e,i))}get changes(){return this._changes.value}get(t){var e;return(e=this.changes[t])!=null?e:this.initialState[t]}set(t,e){this._changes.value={...this.changes,[t]:e}}async save(){if(Object.keys(this.changes).length===0)return;this.initialState=await this.api.update(this.idKey?this.initialState[this.idKey]:null,this.changes);const t={...this.changes};this._changes.value={},this.pubsub.publish("update",t)}hasChanges(){return Object.keys(this.changes).length>0}get state(){return{...this.initialState,...this.changes}}resetChanges(){const t={...this.changes};this._changes.value={},this.pubsub.publish("update",t)}}export{n as A};
//# sourceMappingURL=activeRecord.eb203c6f.js.map
