import{onChange as onChangeCheckout}from"../checkout";import{onChange as onChangeProcessor,state as selectedProcessor}from"../selected-processor";import{availableManualPaymentMethods,availableMethodTypes,availableProcessors}from"./getters";import{onChange}from"./store";const maybeUpdateProcessor=()=>{const e=[...availableProcessors().map((({processor_type:e})=>e)),...availableManualPaymentMethods().map((({id:e})=>e))];e.includes(selectedProcessor.id)||(selectedProcessor.id=(null==e?void 0:e.length)?null==e?void 0:e[0]:null)},maybeUpdateMethod=()=>{const e=(availableMethodTypes()||[]).map((({id:e})=>e));"mollie"===(null==selectedProcessor?void 0:selectedProcessor.id)?e.includes(selectedProcessor.method)||(selectedProcessor.method=(null==e?void 0:e.length)?null==e?void 0:e[0]:null):selectedProcessor.method=null};onChangeCheckout("checkout",(()=>{maybeUpdateProcessor(),maybeUpdateMethod()})),onChangeProcessor("id",(()=>maybeUpdateProcessor())),onChange("processors",(()=>maybeUpdateProcessor())),onChange("methods",(()=>maybeUpdateMethod()));