{"version":3,"file":"reactive-state.cjs","sources":["../../src/state/reactive-state.ts"],"sourcesContent":["import { ReactiveController, ReactiveControllerHost } from 'lit';\nimport { BehaviorSubject, Observable, Subscription } from 'rxjs';\n\nexport class ReactiveState<T> implements ReactiveController {\n  sub: Subscription | null = null;\n  value$: BehaviorSubject<T | undefined> = new BehaviorSubject<T | undefined>(undefined);\n\n  constructor(private host: ReactiveControllerHost, private source: Observable<T>, public value?: T) {\n    this.host.addController(this);\n  }\n\n  hostConnected() {\n    this.sub = this.source.subscribe(value => {\n      this.value = value;\n      this.value$.next(value);\n      this.host.requestUpdate();\n    });\n  }\n\n  hostDisconnected() {\n    this.sub?.unsubscribe();\n  }\n}\n"],"names":["BehaviorSubject"],"mappings":";;;;MAGa,aAAa,CAAA;AAIxB,IAAA,WAAA,CAAoB,IAA4B,EAAU,MAAqB,EAAS,KAAS,EAAA;QAA7E,IAAI,CAAA,IAAA,GAAJ,IAAI;QAAkC,IAAM,CAAA,MAAA,GAAN,MAAM;QAAwB,IAAK,CAAA,KAAA,GAAL,KAAK;QAH7F,IAAG,CAAA,GAAA,GAAwB,IAAI;AAC/B,QAAA,IAAA,CAAA,MAAM,GAAmC,IAAIA,oBAAe,CAAgB,SAAS,CAAC;AAGpF,QAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;;IAG/B,aAAa,GAAA;QACX,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,IAAG;AACvC,YAAA,IAAI,CAAC,KAAK,GAAG,KAAK;AAClB,YAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;AACvB,YAAA,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;AAC3B,SAAC,CAAC;;IAGJ,gBAAgB,GAAA;AACd,QAAA,IAAI,CAAC,GAAG,EAAE,WAAW,EAAE;;AAE1B;;;;"}