1import{M as y,c as S,a as M,s as k,N as h,b as A,d as E}from"./connectToChild-CYVGlWxw.js";import{E as L,e as v}from"./connectToChild-CYVGlWxw.js";const N=(n,s,l,t)=>{const{destroy:g,onDestroy:r}=l;return e=>{if(!(n instanceof RegExp?n.test(e.origin):n==="*"||n===e.origin)){t(`Child: Handshake - Received SYN-ACK from origin ${e.origin} which did not match expected origin ${n}`);return}t("Child: Handshake - Received SYN-ACK, responding with ACK");const c=e.origin==="null"?"*":e.origin,m={penpal:y.Ack,methodNames:Object.keys(s)};window.parent.postMessage(m,c);const d={localName:"Child",local:window,remote:window.parent,originForSending:c,originForReceiving:e.origin},w=S(d,s,t);r(w);const i={},a=M(i,d,e.data.methodNames,g,t);return r(a),i}},R=()=>{try{clearTimeout()}catch{return!1}return!0},b=(n={})=>{const{parentOrigin:s="*",methods:l={},timeout:t,debug:g=!1}=n,r=A(g),e=E("Child",r),{destroy:p,onDestroy:c}=e,m=N(s,l,e,r),d=()=>{r("Child: Handshake - Sending SYN");const i={penpal:y.Syn},a=s instanceof RegExp?"*":s;window.parent.postMessage(i,a)};return{promise:new Promise((i,a)=>{const C=k(t,p),u=o=>{if(R()&&!(o.source!==parent||!o.data)&&o.data.penpal===y.SynAck){const f=m(o);f&&(window.removeEventListener(h.Message,u),C(),i(f))}};window.addEventListener(h.Message,u),d(),c(o=>{window.removeEventListener(h.Message,u),o&&a(o)})}),destroy(){p()}}};export{L as ErrorCode,v as connectToChild,b as connectToParent};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.