package Ġjp . co . sor am its u . feature _ c rowd loan _ impl . presentation . contribute . custom . ref erral Ċ Ċ import Ġjp . co . sor am its u . common . resources . ResourceManager Ċ import Ġjp . co . sor am its u . common . utils . format As Percentage Ċ import Ġjp . co . sor am its u . common . utils . fraction To Percentage Ċ import Ġjp . co . sor am its u . feature _ c rowd loan _ impl . R Ċ import Ġjp . co . sor am its u . feature _ c rowd loan _ impl . presentation . contribute . custom . Apply Action State Ċ import Ġjp . co . sor am its u . feature _ c rowd loan _ impl . presentation . contribute . custom . Bonus Payload Ċ import Ġjp . co . sor am its u . feature _ c rowd loan _ impl . presentation . contribute . custom . Custom Contribut e ViewState Ċ import Ġjp . co . sor am its u . feature _ c rowd loan _ impl . presentation . contribute . custom . model . Custom Contribut e Payload Ċ import Ġjp . co . sor am its u . feature _ c rowd loan _ impl . presentation . contribute . select . model . Learn More Model Ċ import Ġjp . co . sor am its u . feature _ wallet _ api . presentation . format ters . format Token Amount Ċ import Ġkotlinx . coroutines . flow . Flow Ċ import Ġkotlinx . coroutines . flow . Mutable Shared Flow Ċ import Ġkotlinx . coroutines . flow . Mutable State Flow Ċ import Ġkotlinx . coroutines . flow . combine Ċ import Ġkotlinx . coroutines . flow . first Ċ import Ġkotlinx . coroutines . flow . map Ċ import Ġjava . math . BigDecimal Ċ Ċ abstract Ġclass ĠRef erral Contribut e ViewState ( ĊĠĠĠ Ġprotected Ġval Ġcustom Contribut e Payload : ĠCustom Contribut e Payload , ĊĠĠĠ Ġprotected Ġval Ġresource Manager : ĠResourceManager , ĊĠĠĠ Ġprivate Ġval Ġfear less Ref erral Code : ĠString , ĊĠĠĠ Ġprivate Ġval Ġbonus Percentage : ĠBigDecimal , ĊĠĠĠ Ġprivate Ġval Ġterms Url : ĠString Ġ= Ġcustom Contribut e Payload . par ach ain Metadata . website , ĊĠĠĠ Ġprivate Ġval Ġlearn More Url : ĠString Ġ= Ġcustom Contribut e Payload . par ach ain Metadata . website , Ċ ) Ġ: ĠCustom Contribut e ViewState Ġ{ ĊĊĠĠĠ Ġabstract Ġfun Ġcreate Bonus Payload ( ref erral Code : ĠString ): ĠRef erral Code Payload ĊĊĠĠĠ Ġabstract Ġsuspend Ġfun Ġvalidate Payload ( payload : ĠRef erral Code Payload ) ĊĊĠĠĠ Ġprivate Ġval Ġ_ open Browser Flow Ġ= ĠMutable Shared Flow < String >( replay Ġ= Ġ 0 , Ġextra Buffer Capacity Ġ= Ġ 1 ) ĊĠĠĠ Ġval Ġopen Browser Flow : ĠFlow < String > Ġ= Ġ_ open Browser Flow ĊĊĠĠĠ Ġval Ġentered Ref erral Code Flow Ġ= ĠMutable State Flow ("") ĊĊĠĠĠ Ġval Ġprivacy Accepted Flow Ġ= ĠMutable State Flow ( false ) ĊĊĠĠĠ Ġval Ġapply F ear less Title Ġ= Ġcreate F ear less Bonus Title () ĊĊĠĠĠ Ġval Ġapply F ear less Code Enabled Flow Ġ= Ġentered Ref erral Code Flow . map Ġ{ ĊĠĠĠĠĠĠĠ Ġit Ġ!= Ġfear less Ref erral Code ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġlearn Bon uses Title Ġ= ĠLearn More Model ( ĊĠĠĠĠĠĠĠ Ġicon Link Ġ= Ġcustom Contribut e Payload . par ach ain Metadata . icon Link , ĊĠĠĠĠĠĠĠ Ġtext Ġ= Ġresource Manager . getString ( R . string . c rowd loan _ learn , Ġcustom Contribut e Payload . par ach ain Metadata . name ) ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġprivate Ġval Ġbonus Payload Flow Ġ= Ġentered Ref erral Code Flow . map Ġ{ ĊĠĠĠĠĠĠĠ Ġcreate Bonus Payload ( it ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġbonus Flow Ġ= Ġbonus Payload Flow . map Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtoken Name Ġ= Ġcustom Contribut e Payload . par ach ain Metadata . token ĊĊĠĠĠĠĠĠĠ Ġit . calculate Bonus ( custom Contribut e Payload . amount )?. format Token Amount ( token Name ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠĠĠ Ġprevious Payload ()?. let Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġentered Ref erral Code Flow . value Ġ= Ġit . ref erral Code ĊĠĠĠĠĠĠĠĠĠĠĠ Ġprivacy Accepted Flow . value Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġapply F ear less Code () Ġ{ ĊĠĠĠĠĠĠĠ Ġentered Ref erral Code Flow . value Ġ= Ġfear less Ref erral Code ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġterms Clicked () Ġ{ ĊĠĠĠĠĠĠĠ Ġ_ open Browser Flow . try Emit ( terms Url ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġlearn More Clicked () Ġ{ ĊĠĠĠĠĠĠĠ Ġ_ open Browser Flow . try Emit ( learn More Url ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġval Ġapply Action State Ġ= Ġentered Ref erral Code Flow . combine ( privacy Accepted Flow ) Ġ{ Ġref erral , Ġprivacy Accepted Ġ-> ĊĠĠĠĠĠĠĠ Ġwhen Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġref erral . isEmpty () Ġ-> ĠApply Action State . Unavailable ( reason Ġ= Ġresource Manager . getString ( R . string . c rowd loan _ enter _ ref erral )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġprivacy Accepted . not () Ġ-> ĠApply Action State . Unavailable ( reason Ġ= Ġresource Manager . getString ( R . string . c rowd loan _ empty _ bonus _ title )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġ-> ĠApply Action State . Available ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġgenerate Payload (): ĠResult < Bonus Payload > Ġ= Ġrun Catch ing Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġpayload Ġ= Ġbonus Payload Flow . first () ĊĊĠĠĠĠĠĠĠ Ġvalidate Payload ( payload ) ĊĊĠĠĠĠĠĠĠ Ġpayload ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcreate F ear less Bonus Title (): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġpercentage Ġ= Ġbonus Percentage . fraction To Percentage (). format As Percentage () ĊĊĠĠĠĠĠĠĠ Ġreturn Ġresource Manager . getString ( R . string . c rowd loan _ app _ bonus _ format , Ġpercentage ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprotected Ġfun Ġprevious Payload () Ġ= Ġcustom Contribut e Payload . previous Bonus Payload Ġas ? ĠRef erral Code Payload Ċ } Ċ