{"version":3,"file":"connect-card-kXLdSNTL.mjs","names":[],"sources":["../src/penpal/connect-card.ts"],"sourcesContent":["import type { CardSetupIntent, PublicCardCheckoutResponse } from \"@pkg/sdk/models\";\nimport type { Connection } from \"penpal\";\nimport { connectToWindow } from \".\";\n\ntype CardIFrameMethods = {\n  onSubmit: (cardSetupIntentId: string) => Promise<CardSetupIntent | { error: CardErrorCode }>;\n  onValidate: () => Promise<CardErrorCode | undefined>;\n};\n\ntype CardParentMethods = {\n  onLoaded: () => void;\n  onFocusChange: (isFocused: boolean) => void;\n};\n\nexport type CardInputType = \"card_pan\" | \"card_exp\" | \"card_cvc\";\n\nexport type CardErrorCode =\n  | \"invalid\"\n  | \"required\"\n  | \"unknown_error\"\n  | \"penpal_not_connected\"\n  | \"missing_checkout_token\";\n\nexport type IFrameConnection = Connection<CardIFrameMethods>;\n\nexport type ParentConnection = Connection<CardParentMethods>;\n\nexport type CheckoutResponse = PublicCardCheckoutResponse;\n\nexport const connectToCardIframe = (iframe: HTMLIFrameElement, methods: CardParentMethods) => {\n  return connectToWindow<CardIFrameMethods>({ window: iframe.contentWindow as Window, methods });\n};\n\nexport const connectToCardParent = (methods: CardIFrameMethods) => {\n  return connectToWindow<CardParentMethods>({ window: window.parent, methods });\n};\n"],"mappings":";;;AA6BA,MAAa,uBAAuB,QAA2B,YAA+B;AAC5F,QAAO,gBAAmC;EAAE,QAAQ,OAAO;EAAyB;EAAS,CAAC;;AAGhG,MAAa,uBAAuB,YAA+B;AACjE,QAAO,gBAAmC;EAAE,QAAQ,OAAO;EAAQ;EAAS,CAAC"}