package Ġcom . ey gr aber . portal . internal Ċ Ċ import Ġcom . ey gr aber . portal . Portal Entry Ċ import Ġkotlinx . serialization . encode ToString Ċ import Ġkotlinx . serialization . json . Json Ċ import Ġkotlinx . serialization . json . build JsonArray Ċ import Ġkotlinx . serialization . json . build JsonObject Ċ import Ġkotlinx . serialization . json . put Ċ Ċ internal Ġfun Ġ< Key T > Ġserialize Portal Manager State ( ĊĠ Ġkey Serializer : Ġ( Key T ) Ġ-> ĠString , ĊĠ Ġstate : ĠPortal State < Key T > Ċ ) Ġ= ĠJson . encode ToString ( ĊĠ Ġbuild JsonObject Ġ{ ĊĠĠĠ Ġput (" entries ", Ġstate . portal Entries . serialize Entries ( key Serializer )) ĊĠĠĠ Ġput (" back stack ", Ġstate . back stack Entries . serialize Back stack Entries ( key Serializer )) ĊĠ Ġ} Ċ ) Ċ Ċ private Ġfun Ġ< Key T > ĠList < Portal Entry < Key T >> . serialize Entries ( ĊĠ Ġkey Serializer : Ġ( Key T ) Ġ-> ĠString Ċ ) Ġ= Ġbuild JsonArray Ġ{ ĊĠ ĠforEach Ġ{ Ġentry Ġ-> ĊĠĠĠ Ġadd ( ĊĠĠĠĠĠ Ġbuild JsonObject Ġ{ ĊĠĠĠĠĠĠĠ Ġput (" key ", Ġkey Serializer ( entry . key )) ĊĠĠĠĠĠĠĠ Ġput (" was Content Previous ly Visible ", Ġentry . was Content Previous ly Visible ) ĊĠĠĠĠĠĠĠ Ġput (" is Attached ", Ġentry . renderer State . is Added Or Attached ) ĊĠĠĠĠĠĠĠ Ġput (" is Dis appear ing ", Ġentry . is Dis appear ing ) ĊĠĠĠĠĠĠĠ Ġput (" is Back stack Mutation ", Ġentry . is Back stack Mutation ) ĊĠĠĠĠĠĠĠ Ġput (" renderer State ", Ġentry . renderer State . name ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ) ĊĠ Ġ} Ċ } Ċ Ċ private Ġfun Ġ< Key T > ĠList < Portal Back stack Entry < Key T >> . serialize Back stack Entries ( ĊĠ Ġkey Serializer : Ġ( Key T ) Ġ-> ĠString Ċ ) Ġ= Ġbuild JsonArray Ġ{ ĊĠ ĠforEach Ġ{ Ġentry Ġ-> ĊĠĠĠ Ġadd ( ĊĠĠĠĠĠ Ġbuild JsonObject Ġ{ ĊĠĠĠĠĠĠĠ Ġput (" id ", Ġentry . id ) ĊĠĠĠĠĠĠĠ Ġput (" mutations ", Ġentry . mutations . serialize Back stack Mut ations ( key Serializer )) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ) ĊĠ Ġ} Ċ } Ċ Ċ private Ġfun Ġ< Key T > ĠList < Portal Back stack Mutation < Key T >> . serialize Back stack Mut ations ( ĊĠ Ġkey Serializer : Ġ( Key T ) Ġ-> ĠString Ċ ) Ġ= Ġbuild JsonArray Ġ{ ĊĠ ĠforEach Ġ{ Ġmutation Ġ-> ĊĠĠĠ Ġbuild JsonObject Ġ{ ĊĠĠĠĠĠ Ġput (" key ", Ġkey Serializer ( mutation . key )) ĊĊĠĠĠĠĠ Ġwhen ( mutation ) Ġ{ ĊĠĠĠĠĠĠĠ Ġis ĠPortal Back stack Mutation . Remove Ġ-> Ġput (" type ", Ġ" remove ") ĊĊĠĠĠĠĠĠĠ Ġis ĠPortal Back stack Mutation . Attach Ġ-> Ġput (" type ", Ġ" attach ") ĊĊĠĠĠĠĠĠĠ Ġis ĠPortal Back stack Mutation . Detach Ġ-> Ġput (" type ", Ġ" detach ") ĊĊĠĠĠĠĠĠĠ Ġis ĠPortal Back stack Mutation . Dis appear ing Ġ-> Ġput (" type ", Ġ" dis appear ing ") ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ