var g=Object.defineProperty;var l=(s,t,e)=>t in s?g(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var a=(s,t,e)=>(l(s,typeof t!="symbol"?t+"":t,e),e);import{eM as h,F as b,eN as d}from"./outputWidgets.dd3997b1.js";import{P as o}from"./pubsub.7e2ca77e.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]="5caf33bb-c3f7-4c2b-9ce9-0b8ab00815c9",s._sentryDebugIdIdentifier="sentry-dbid-5caf33bb-c3f7-4c2b-9ce9-0b8ab00815c9")}catch{}})();class n{constructor(t){a(this,"initialState");a(this,"pubsub");a(this,"_changes");this.initialState=t,this.pubsub=new o,this._changes=b({})}static from(t){return h(new n(t))}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}}hasChanges(t){return t?t in this.changes:Object.keys(this.changes).length>0}hasChangesDeep(t){return t in this.changes&&!d.exports.isEqual(this.initialState[t],this.changes[t])}get state(){return{...this.initialState,...this.changes}}resetChanges(){const t={...this.changes};this._changes.value={},this.pubsub.publish("update",t)}}class c extends n{constructor(e,i){super(i);a(this,"api");this.api=e}static create(e,i){return h(new c(e,i))}getInitialState(e){return this.initialState[e]}updateInitialState(e,i){this.initialState[e]=i,delete this._changes.value[e]}async save(e){if(Object.keys(this.changes).length===0||e&&!(e in this.changes))return;if(e){const r={[e]:this.changes[e]},u=await this.api.update(this.initialState.id,r);this.initialState={...this.initialState,...u},delete this._changes.value[e];return}this.initialState=await this.api.update(this.initialState.id,this.changes);const i={...this.changes};this._changes.value={},this.pubsub.publish("update",i)}}export{c as A,n as E};
//# sourceMappingURL=record.27251633.js.map
