//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// UserRTX.NET satellite library | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.Text;

#if !WASM
namespace user_rtx { using u = user_rtx;
#else
namespace user_rtx.wasm { using u = user_rtx.wasm;
#endif

static partial class str {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

public static string TXT_I( string multilineStr ) =>
   AppendText_I( new StringBuilder(), multilineStr ).ToString();

public static string? AsTextOrNull_I( string multilineStr ) =>
   multilineStr!=null ? TXT_I( multilineStr ) : null;
public static string AsTextOrEmpty_I( string multilineStr ) =>
   multilineStr!=null ? TXT_I( multilineStr ) : "";

//--------------------------------------------------------------------------------------------------

[u.returns_source]
public static StringBuilder AppendText_I( StringBuilder sb, string multilineStr ) =>
   AppendText_I( sb, true, multilineStr );
[u.returns_source]
public static StringBuilder AppendText_I( StringBuilder sb,
                                          [u.def_true] bool insertLineIfNotEmpty,
                                          string multilineStr )
{
   if ( insertLineIfNotEmpty )
      u.text_i.AppendLine( sb );
   foreach ( char ch in multilineStr )
      if ( ch != '\r' )
         sb.Append( ch );
   return sb;
}

//==================================================================================================

public static string FMT_I( string messageFmt, params object?[] args ) =>
   TXT_I( string.Format( messageFmt, args ) );

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // str

} // user_rtx (.wasm)
