import{Aa as V,Ba as w,F as b,T as I,X as S,Z as v,b as g,f as y,ma as R,na as F,pa as l,r as E}from"./chunk-4SVIVQBS.js";var D={schedule(n,t){let e=setTimeout(n,t);return()=>clearTimeout(e)}};function M(n){return n.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function T(n){return!!n&&n.nodeType===Node.ELEMENT_NODE}var h;function C(n,t){if(!h){let e=Element.prototype;h=e.matches||e.matchesSelector||e.mozMatchesSelector||e.msMatchesSelector||e.oMatchesSelector||e.webkitMatchesSelector}return n.nodeType===Node.ELEMENT_NODE?h.call(n,t):!1}function _(n){let t={};return n.forEach(({propName:e,templateName:s,transform:r})=>{t[M(s)]=[e,r]}),t}function x(n,t){return t.get(l).resolveComponentFactory(n).inputs}function O(n,t){let e=n.childNodes,s=t.map(()=>[]),r=-1;t.some((c,u)=>c==="*"?(r=u,!0):!1);for(let c=0,u=e.length;c<u;++c){let i=e[c],o=N(i,t,r);o!==-1&&s[o].push(i)}return s}function N(n,t,e){let s=e;return T(n)&&t.some((r,c)=>r!=="*"&&C(n,r)?(s=c,!0):!1),s}var k=10,p=class{componentFactory;inputMap=new Map;constructor(t,e){this.componentFactory=e.get(l).resolveComponentFactory(t);for(let s of this.componentFactory.inputs)this.inputMap.set(s.propName,s.templateName)}create(t){return new m(this.componentFactory,t,this.inputMap)}},m=class{componentFactory;injector;inputMap;eventEmitters=new y(1);events=this.eventEmitters.pipe(b(t=>E(...t)));componentRef=null;scheduledDestroyFn=null;initialInputValues=new Map;ngZone;elementZone;appRef;cdScheduler;constructor(t,e,s){this.componentFactory=t,this.injector=e,this.inputMap=s,this.ngZone=this.injector.get(S),this.appRef=this.injector.get(w),this.cdScheduler=e.get(v),this.elementZone=typeof Zone>"u"?null:this.ngZone.run(()=>Zone.current)}connect(t){this.runInZone(()=>{if(this.scheduledDestroyFn!==null){this.scheduledDestroyFn(),this.scheduledDestroyFn=null;return}this.componentRef===null&&this.initializeComponent(t)})}disconnect(){this.runInZone(()=>{this.componentRef===null||this.scheduledDestroyFn!==null||(this.scheduledDestroyFn=D.schedule(()=>{this.componentRef!==null&&(this.componentRef.destroy(),this.componentRef=null)},k))})}getInputValue(t){return this.runInZone(()=>this.componentRef===null?this.initialInputValues.get(t):this.componentRef.instance[t])}setInputValue(t,e){if(this.componentRef===null){this.initialInputValues.set(t,e);return}this.runInZone(()=>{this.componentRef.setInput(this.inputMap.get(t)??t,e),R(this.componentRef.hostView)&&(F(this.componentRef.changeDetectorRef),this.cdScheduler.notify(6))})}initializeComponent(t){let e=I.create({providers:[],parent:this.injector}),s=O(t,this.componentFactory.ngContentSelectors);this.componentRef=this.componentFactory.create(e,s,t),this.initializeInputs(),this.initializeOutputs(this.componentRef),this.appRef.attachView(this.componentRef.hostView),this.componentRef.hostView.detectChanges()}initializeInputs(){for(let[t,e]of this.initialInputValues)this.setInputValue(t,e);this.initialInputValues.clear()}initializeOutputs(t){let e=this.componentFactory.outputs.map(({propName:s,templateName:r})=>{let c=t.instance[s];return new g(u=>{let i=c.subscribe(o=>u.next({name:r,value:o}));return()=>i.unsubscribe()})});this.eventEmitters.next(e)}runInZone(t){return this.elementZone&&Zone.current!==this.elementZone?this.ngZone.run(t):t()}},f=class extends HTMLElement{ngElementEventsSubscription=null};function Y(n,t){let e=x(n,t.injector),s=t.strategyFactory||new p(n,t.injector),r=_(e);class c extends f{injector;static observedAttributes=Object.keys(r);get ngElementStrategy(){if(!this._ngElementStrategy){let i=this._ngElementStrategy=s.create(this.injector||t.injector);e.forEach(({propName:o,transform:a})=>{if(!this.hasOwnProperty(o))return;let d=this[o];delete this[o],i.setInputValue(o,d,a)})}return this._ngElementStrategy}_ngElementStrategy;constructor(i){super(),this.injector=i}attributeChangedCallback(i,o,a,d){let[j,Z]=r[i];this.ngElementStrategy.setInputValue(j,a,Z)}connectedCallback(){let i=!1;this.ngElementStrategy.events&&(this.subscribeToEvents(),i=!0),this.ngElementStrategy.connect(this),i||this.subscribeToEvents()}disconnectedCallback(){this._ngElementStrategy&&this._ngElementStrategy.disconnect(),this.ngElementEventsSubscription&&(this.ngElementEventsSubscription.unsubscribe(),this.ngElementEventsSubscription=null)}subscribeToEvents(){this.ngElementEventsSubscription=this.ngElementStrategy.events.subscribe(i=>{let o=new CustomEvent(i.name,{detail:i.value});this.dispatchEvent(o)})}}return e.forEach(({propName:u,transform:i,isSignal:o})=>{Object.defineProperty(c.prototype,u,{get(){let a=this.ngElementStrategy.getInputValue(u);return o&&V(a)?a():a},set(a){this.ngElementStrategy.setInputValue(u,a,i)},configurable:!0,enumerable:!0})}),c}export{Y as a};
