package Ġme . alex . pet . apps . zh ish i . data . sections Ċ Ċ import Ġcom . squareup . mos hi . M oshi Ċ import Ġkotlinx . coroutines . Dispatch ers Ċ import Ġkotlinx . coroutines . with Context Ċ import Ġme . alex . pet . apps . zh ish i . Rule Queries Ċ import Ġme . alex . pet . apps . zh ish i . Section Queries Ċ import Ġme . alex . pet . apps . zh ish i . data . common . Markup Dto Ċ import Ġme . alex . pet . apps . zh ish i . data . common . styled Text Of Ċ import Ġme . alex . pet . apps . zh ish i . domain . sections . Rule Ċ import Ġme . alex . pet . apps . zh ish i . domain . sections . Section Ċ import Ġme . alex . pet . apps . zh ish i . domain . sections . Sections Repository Ċ import Ġjavax . inject . Inject Ċ import Ġjavax . inject . Singleton Ċ Ċ @ Singleton Ċ class ĠSe ctions DataStore Ġ@ Inject Ġconstructor ( ĊĠĠĠ Ġprivate Ġval Ġsection Queries : ĠSection Queries , ĊĠĠĠ Ġprivate Ġval Ġrule Queries : ĠRule Queries , ĊĠĠĠ Ġm oshi : ĠM oshi Ċ ) Ġ: ĠSe ctions Repository Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġmarkup Adapter Ġ= Ġm oshi . adapter ( Markup Dto :: class . java ) ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġget Section ( section Id : ĠLong ): ĠSection ? Ġ= Ġwith Context ( Dispatch ers . IO ) Ġ{ ĊĠĠĠĠĠĠĠ Ġsection Queries . transaction With Result Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsection Queries . findById ( section Id ) Ġ{ Ġid , Ġ_, Ġname , Ġmarkup Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġmarkup Dto Ġ= Ġmarkup Adapter . fromJson ( markup ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ?: Ġthrow ĠIllegalStateException (" Unable Ġto Ġparse Ġmarkup ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠSection ( id , Ġstyled Text Of ( name , Ġmarkup Dto ), Ġfind Rules By Section Id ( id )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}. execute As One OrNull () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġfind Rules By Section Id ( section Id : ĠLong ): ĠList < Rule > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġrule Queries . find Id And Annotation By Section Id ( section Id ) Ġ{ Ġid , Ġannotation , Ġannotation Markup Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġannotation Markup Dto Ġ= Ġmarkup Adapter . fromJson ( annotation Markup ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ?: Ġthrow ĠIllegalStateException (" Unable Ġto Ġparse Ġmarkup ") ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRule ( id , Ġstyled Text Of ( annotation , Ġannotation Markup Dto )) ĊĠĠĠĠĠĠĠ Ġ}. execute As List () ĊĠĠĠ Ġ} Ċ }