import{c as t,M as s,V as e}from"./p-dcc98162.js";import{O as i}from"./p-331a62d5.js";import{C as o}from"./p-816f6fc6.js";import{f as c}from"./p-2ade684f.js";import{d as a}from"./p-243c99c3.js";import{j as n,k as l}from"./p-72158667.js";var h=function(t,s,e,i){var o,c=arguments.length,a=c<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,s,e,i);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(c<3?o(a):c>3?o(s,e,a):o(s,e))||a);return c>3&&a&&Object.defineProperty(s,e,a),a};class r extends e{constructor(t){super(),this.isAcceptableObserverPayload=t=>"object"==typeof t&&!!t&&t.host===this.parent,this.observerEntry=t}connectedCallback(){if(this.parent=this.getParent(),!this.parent)return;const{subStates:t}=this.observerEntry;this.subStateObserver=new i(this.isAcceptableObserverPayload,(s=>{const e=t.find((t=>t.parentStateName===s.stateName));e&&this.updateState(e,s.value)})),o.register(a.getSubject(this.parent,n),this.subStateObserver),this.observerEntry.pullStatesWhenReattached&&this.host.classList.contains("hydrated")&&(this.parent=this.getParent(),this.pullStates())}disconnectedCallback(){this.parent&&o.unregister(a.getSubject(this.parent,n),this.subStateObserver)}componentWillLoad(){this.pullStates()}getParent(){return"string"==typeof this.observerEntry.parent?c(this.host,this.observerEntry.parent):this.observerEntry.parent()}updateState(t,s){t.callback?t.callback(s):this[t.subStateName]=s}pullStates(){if(!this.parent)return;const{subStates:t}=this.observerEntry;t.forEach((t=>{o.notify(a.getSubject(this.parent,l),{host:this.parent,stateName:t.parentStateName,callback:s=>{this.updateState(t,s)}})}))}}h([t()],r.prototype,"host",void 0),h([s("connectedCallback")],r.prototype,"connectedCallback",null),h([s("disconnectedCallback")],r.prototype,"disconnectedCallback",null),h([s("componentWillLoad")],r.prototype,"componentWillLoad",null);export{r as S}