text: (window.webpackJsonp=window.webpackJsonp||[]).push([[0],{"../../src/index.js":function(e,t,i){"use strict";const s=Object.prototype,r=s.toString,d=(s.hasOwnProperty,()=>{});function o(e){return function(t){return r.call(t)==="[object "+e+"]"}}o("Error");const a=o("Function");o("Array"),o("Date");const n="VI_SYNC",l="CHILD_",c="PARENT_",h="ADD_IN_BROADCAST_LIST",p="DEL_IN_BROADCAST_LIST",u="INIT_STATE";class f{constructor({id:e,el:t}){this.id=e,this.el=t}update(e,t){this.el&&this.el.contentWindow.postMessage({type:e,payload:t},location.origin)}}class m{constructor({id:e,parent:t,store:i,created:s,destroyed:r}){this.id=e,this.store=i,this.parent=t||window.parent,this.createdCallback=a(s)?s:d,this.destroyedCallback=a(r)?r:d,this.init()}init(){const e=this,{id:t,store:i}=this,{_mutations:s}=i,{parentPrefix:r,childPrefix:d}=m;Object.entries(s).forEach(([e,t])=>{s[r+e]=t}),s[r+u]=[e=>{Object.assign(i.state,e)}],i.subscribe(({type:i,payload:s},o)=>{i.indexOf(r)>=0||e.send(d+i,{id:t,payload:s})}),window.addEventListener("load",this.load.bind(this)),window.addEventListener("message",this.update.bind(this)),window.addEventListener("beforeunload",this.unLoad.bind(this))}update({data:{type:e,payload:t}}){const{store:i}=this;if(!(e&&Reflect.has(i._mutations,e)||e===u))return;const{parentPrefix:s}=m;i.commit(s+e,t)}send(e,t){this.parent&&this.parent.postMessage({type:e,payload:t},location.origin)}load(){this.send(`${m.moduleName}/${h}`,this.id),this.created()}unLoad(){this.send(`${m.moduleName}/${p}`,this.id),this.destroyed()}created(){this.createdCallback(this.id,this.store,this.send.bind(this))}destroyed(){this.destroyedCallback(this.id,this.store,this.send.bind(this))}}m.moduleName="",m.parentPrefix="",m.childPrefix="";class y{constructor({ids:e,store:t}){this.allFrameIds=e.split(","),this.observerList=[],this.store=t,this.init()}addObserver(e){if(this.allFrameIds.indexOf(e)<0)return;const t=document.getElementById(e);if(t&&"IFRAME"===t.tagName){let i=new f({id:e,el:t});this.observerList.push(i),this.notifyObserver(i,{type:u,payload:function(e,t=[]){let i={};for(let s in e)t.indexOf(s)<0&&(i[s]=e[s]);return i}(this.store.state,[y.moduleName])})}}deleteObserver(e){const t=this.observerList.map(e=>e.id).indexOf(e);t>=0&&this.observerList.splice(t,1)}notifyObserver(e,{type:t,payload:i}){e.update(t,i)}notifyObservers({id:e,type:t,payload:i}){for(let s of this.observerList.filter(t=>t.id!==e))s.update(t,i)}init(){const e=this,{_mutations:t}=e.store,{moduleName:i,childPrefix:s}=y;e.store.registerModule(i,{namespaced:!0,mutations:{[h](t,i){e.addObserver(i)},[p](t,i){e.deleteObserver(i)}}}),Object.entries(t).forEach(([i,r])=>{t[s+i]=r.map(t=>({id:s,payload:r})=>{t(r),e.notifyObservers({id:s,type:i,payload:r})})});const r=new RegExp(`^(${s}|${i})`);e.store.subscribe(({type:t,payload:i},s)=>{r.test(t)||e.notifyObservers({type:t,payload:i})}),window.addEventListener("message",this.update.bind(this))}update({data:{type:e,payload:t}}){const{store:i}=this;e&&Reflect.has(i._mutations,e)&&i.commit(e,t)}}y.moduleName="",y.parentPrefix="",y.childPrefix="",i.d(t,"a",function(){return b}),i.d(t,"b",function(){return w});const b=(e,t={})=>i=>{let{moduleName:s,parentPrefix:r,childPrefix:d}=t;return y.moduleName=s||n,y.parentPrefix=r||c,y.childPrefix=d||l,new y({ids:e,store:i})},w=(e={})=>t=>{let{moduleName:i,parentPrefix:s,childPrefix:r,created:d,destroyed:o}=e;return m.moduleName=i||n,m.parentPrefix=s||c,m.childPrefix=r||l,new m({id:window.frameElement.id,store:t,created:d,destroyed:o})}}}]);