import{d as Z}from"../chunks/environment.9aa685ef.js";import{S as V,i as F,s as j,e as G,b as I,g as w,v as x,d as O,f as ee,h as v,H as te,k,l as g,m as b,n as E,N as le,D as m,F as N,O as oe,I as ae,J as se,K as ne,P as re,a as B,q as $,c as y,r as M,Q as A,R as ie,E as P,G as ue,T as fe,y as L,z as W,A as X,u as U,U as ce,B as Y,V as de}from"../chunks/index.463cc238.js";const _e=Z,he=!0,Ie=Object.freeze(Object.defineProperty({__proto__:null,csr:_e,prerender:he},Symbol.toStringTag,{value:"Module"}));function J(s){let t,o,e,l,r;const c=s[2].default,a=te(c,s,s[1],null);return{c(){t=k("div"),o=k("div"),a&&a.c(),this.h()},l(n){t=g(n,"DIV",{class:!0});var u=b(t);o=g(u,"DIV",{class:!0});var f=b(o);a&&a.l(f),f.forEach(v),u.forEach(v),this.h()},h(){E(o,"class","modal"),E(t,"class","backdrop"),le(t,"interesting",pe)},m(n,u){I(n,t,u),m(t,o),a&&a.m(o,null),e=!0,l||(r=N(t,"click",oe(s[3])),l=!0)},p(n,u){a&&a.p&&(!e||u&2)&&ae(a,c,n,n[1],e?ne(c,n[1],u,null):se(n[1]),null)},i(n){e||(w(a,n),e=!0)},o(n){O(a,n),e=!1},d(n){n&&v(t),a&&a.d(n),l=!1,r()}}}function me(s){let t,o,e=s[0]&&J(s);return{c(){e&&e.c(),t=G()},l(l){e&&e.l(l),t=G()},m(l,r){e&&e.m(l,r),I(l,t,r),o=!0},p(l,[r]){l[0]?e?(e.p(l,r),r&1&&w(e,1)):(e=J(l),e.c(),w(e,1),e.m(t.parentNode,t)):e&&(x(),O(e,1,1,()=>{e=null}),ee())},i(l){o||(w(e),o=!0)},o(l){O(e),o=!1},d(l){e&&e.d(l),l&&v(t)}}}let pe=!1;function ve(s,t,o){let{$$slots:e={},$$scope:l}=t,{showModal:r=!1}=t;function c(a){re.call(this,s,a)}return s.$$set=a=>{"showModal"in a&&o(0,r=a.showModal),"$$scope"in a&&o(1,l=a.$$scope)},[r,l,e,c]}class ke extends V{constructor(t){super(),F(this,t,ve,me,j,{showModal:0})}}function ge(s){let t,o,e,l,r,c,a,n,u;return{c(){t=k("form"),o=k("input"),e=B(),l=k("input"),r=B(),c=k("button"),a=$("Add Book"),this.h()},l(f){t=g(f,"FORM",{});var d=b(t);o=g(d,"INPUT",{type:!0,placeholder:!0}),e=y(d),l=g(d,"INPUT",{type:!0,placeholder:!0}),r=y(d),c=g(d,"BUTTON",{});var h=b(c);a=M(h,"Add Book"),h.forEach(v),d.forEach(v),this.h()},h(){E(o,"type","text"),E(o,"placeholder","title"),E(l,"type","text"),E(l,"placeholder","author")},m(f,d){I(f,t,d),m(t,o),A(o,s[0]),m(t,e),m(t,l),A(l,s[1]),m(t,r),m(t,c),m(c,a),n||(u=[N(o,"input",s[3]),N(l,"input",s[4]),N(t,"submit",ie(s[2]))],n=!0)},p(f,[d]){d&1&&o.value!==f[0]&&A(o,f[0]),d&2&&l.value!==f[1]&&A(l,f[1])},i:P,o:P,d(f){f&&v(t),n=!1,ue(u)}}}function be(s,t,o){let e=fe(),l,r;const c=()=>{const u={id:Math.random(),title:l,author:r};e("addBookEvent",u)};function a(){l=this.value,o(0,l)}function n(){r=this.value,o(1,r)}return[l,r,c,a,n]}class $e extends V{constructor(t){super(),F(this,t,be,ge,j,{})}}function K(s,t,o){const e=s.slice();return e[5]=t[o],e}function Me(s){let t,o;return t=new $e({}),t.$on("addBookEvent",s[4]),{c(){L(t.$$.fragment)},l(e){W(t.$$.fragment,e)},m(e,l){X(t,e,l),o=!0},p:P,i(e){o||(w(t.$$.fragment,e),o=!0)},o(e){O(t.$$.fragment,e),o=!1},d(e){Y(t,e)}}}function Q(s,t){let o,e,l=t[5].title+"",r,c,a=t[5].author+"",n,u;return{key:s,first:null,c(){o=k("div"),e=k("h4"),r=$(l),c=$(" - "),n=$(a),u=B(),this.h()},l(f){o=g(f,"DIV",{});var d=b(o);e=g(d,"H4",{});var h=b(e);r=M(h,l),c=M(h," - "),n=M(h,a),h.forEach(v),u=y(d),d.forEach(v),this.h()},h(){this.first=o},m(f,d){I(f,o,d),m(o,e),m(e,r),m(e,c),m(e,n),m(o,u)},p(f,d){t=f,d&4&&l!==(l=t[5].title+"")&&U(r,l),d&4&&a!==(a=t[5].author+"")&&U(n,a)},d(f){f&&v(o)}}}function Ee(s){let t,o,e,l,r,c,a,n,u,f,d,h=[],q=new Map,T,D,z;t=new ke({props:{showModal:s[1],$$slots:{default:[Me]},$$scope:{ctx:s}}}),t.$on("click",s[3]);let S=s[2];const R=i=>i[5].id;for(let i=0;i<S.length;i+=1){let _=K(s,S,i),p=R(_);q.set(p,h[i]=Q(p,_))}return{c(){L(t.$$.fragment),o=B(),e=k("main"),l=k("h1"),r=$("Hello "),c=$(s[0]),a=$("!"),n=B(),u=k("button"),f=$("Show Modal"),d=B();for(let i=0;i<h.length;i+=1)h[i].c()},l(i){W(t.$$.fragment,i),o=y(i),e=g(i,"MAIN",{});var _=b(e);l=g(_,"H1",{});var p=b(l);r=M(p,"Hello "),c=M(p,s[0]),a=M(p,"!"),p.forEach(v),n=y(_),u=g(_,"BUTTON",{});var C=b(u);f=M(C,"Show Modal"),C.forEach(v),d=y(_);for(let H=0;H<h.length;H+=1)h[H].l(_);_.forEach(v)},m(i,_){X(t,i,_),I(i,o,_),I(i,e,_),m(e,l),m(l,r),m(l,c),m(l,a),m(e,n),m(e,u),m(u,f),m(e,d);for(let p=0;p<h.length;p+=1)h[p]&&h[p].m(e,null);T=!0,D||(z=N(u,"click",s[3]),D=!0)},p(i,[_]){const p={};_&2&&(p.showModal=i[1]),_&256&&(p.$$scope={dirty:_,ctx:i}),t.$set(p),(!T||_&1)&&U(c,i[0]),_&4&&(S=i[2],h=ce(h,_,R,1,i,S,q,e,de,Q,null,K))},i(i){T||(w(t.$$.fragment,i),T=!0)},o(i){O(t.$$.fragment,i),T=!1},d(i){Y(t,i),i&&v(o),i&&v(e);for(let _=0;_<h.length;_+=1)h[_].d();D=!1,z()}}}function we(s,t,o){let{name:e}=t,l=!1,r=[];const c=()=>{o(1,l=!l)},a=n=>{const u=n.detail;o(2,r=[u,...r]),o(1,l=!1)};return s.$$set=n=>{"name"in n&&o(0,e=n.name)},[e,l,r,c,a]}class Te extends V{constructor(t){super(),F(this,t,we,Ee,j,{name:0})}}export{Te as component,Ie as universal};
