package com.lloydm.geosword.common;

import java.io.FileDescriptor;
import java.io.IOException;

import com.lloydm.geosword.activities.AuthenticateDialog;
import com.lloydm.geosword.common.HelpDialog;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.AssetFileDescriptor;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Gravity;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.TextView;
import android.widget.Toast;

public class StandardGameMenuActivity extends Activity implements MyActivityLoader, SurfaceHolder.Callback
{

     // 22-Apr-2015
     // menu music is worked out in here too.....

     public final static String TAG = "com.lloydm.geosword.common.StandardGameMenuActivity";
     public MyHandler handler = null;
     public MyRunnable runnable = null;
     private MyRunnable toastrunnable = null;

     private boolean mPause = false;

     private SharedPreferences prefs = null;
     private SharedPreferences.Editor prefsedit = null;

     public volatile boolean isrunnablerunning = false;
     private volatile boolean istoastrunnablerunning = false;
     private boolean instantkill = true;

     public AssetManager assetmgr = null;
     public Typeface font = null;

     public String txt = "";

     public View mainview = null;
     public boolean mvisflag = false;

     public Button btnback = null;

     public SurfaceView bvideo = null;
     private SurfaceHolder bholder = null;
     private MediaPlayer bplayer = null;
     public TextView txtwait = null;

     public boolean bvideodone = false;
     public boolean bvideolooped = false;
     public boolean bhidevidonfinish = false;
     public boolean bbeginfade = false;
     private boolean bvidcanplay = false;
     public float bvidalpha = 1f;
     private Runnable bfadevid = null;

     public int bvidresid = 0;

     private AuthenticateDialog authdialog = null;

     private HelpDialog helpdialog = null;

     // default screen resolution metric - not necessarily actual dimensions but
     // rather what we are basing our positioning calculations on....
     // aspect ratio 16:9;
     private int screenwidth = 1280;
     private int screenheight = 720;

     public long uid = 0;

     public boolean worldcampaign = false;

     @SuppressLint("NewApi")
     @Override
     protected void onCreate(Bundle savedInstanceState)
     {
                     super.onCreate(savedInstanceState);
                     getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
                     getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

                     Log.i(TAG, "onCreate");
                     if (Build.VERSION.SDK_INT >= 18)
                     {
                                     try
                                     {
                                                     setImmersive(true);
                                     }
                                     catch (Exception e)
                                     {
                                                     Log.w(TAG, "Failed to set Immersive Mode");
                                     }
                     }
                     uid = Config.getUniqueID(uid);
                     prefs = getSharedPreferences("com.lloydm.geosword.common.stdgameprefs", MODE_PRIVATE);

                     // start the menu music service.....or try to....
                     String audiostatus = getprefs("com.lloydm.geosword.toggleaudio", "1");
                     if (audiostatus.equals("1"))
                     {
                                     MenuMusicService.audiomuted = false;
                     }
                     else
                     {
                                     MenuMusicService.audiomuted = true;
                     }

                     Log.i(TAG, "onCreate - music would normally be created here");
                     assetmgr = getAssets();
                     font = Typeface.createFromAsset(assetmgr, "font/spaceranger.ttf");

                     toastrunnable = new MyRunnable()
                     {
                                     @Override
                                     public void run()
                                     {
                                                     if (istoastrunnablerunning)
                                                     {
                                                                     return;
                                                     }
                                                     istoastrunnablerunning = true;
                                                     Toast.makeText(getApplicationContext(), txt, Toast.LENGTH_SHORT).show();
                                                     istoastrunnablerunning = false;
                                     }
                     };

                     authdialog = new AuthenticateDialog(this);

                     bfadevid = new Runnable()
                     {
                                     // must run on ui thread
                                     @Override
                                     public void run()
                                     {
                                                     if (bvideo != null)
                                                     {
                                                                     if (!mPause)
                                                                     {
                                                                                     runOnUiThread(new Runnable()
                                                                                     {

                                                                                                     @Override
                                                                                                     public void
run()
                                                                                                     {
                                                                                                                     // TODO Auto-generated method stub
                                                                                                                     if (bbeginfade)
                                                                                                                     {
                                                                                                                                     bvidalpha -= 0.125f;
                                                                                                                                     if (bvidalpha < 0)
                                                                                                                                     {
                                                                                                                                                     bvidalpha = 0f;
                                                                                                                                     }
                                                                                                                                     bvideo.setAlpha(bvidalpha);
                                                                                                                                     if (bvidalpha > 0)
                                                                                                                                     {
                                                                                                                                                     // call this again shortly....
                                                                                                                                                     Handler h = bvideo.getHandler();
                                                                                                                                                     h.removeCallbacks(bfadevid);
                                                                                                                                                     bvideo.postDelayed(bfadevid, 200);
                                                                                                                                     }
                                                                                                                                     if (txtwait != null)
                                                                                                                                     {
                                                                                                                                                     try
                                                                                                                                                     {
                                                                                                                                                                     txtwait.setVisibility(View.INVISIBLE);
                                                                                                                                                     }
                                                                                                                                                     catch (Exception efg)
                                                                                                                                                     {
                                                                                                                                                                     Log.w(TAG, "error hiding txtview");
                                                                                                                                                     }
                                                                                                                                     }
                                                                                                                     }
                                                                                                                     else
                                                                                                                     {
                                                                                                                                     // check again in a few seconds...
                                                                                                                                     Handler h = bvideo.getHandler();
                                                                                                                                     h.removeCallbacks(bfadevid);
                                                                                                                                     bvideo.postDelayed(bfadevid, 2000);
                                                                                                                     }
                                                                                                     }
                                                                                     });
                                                                     }
                                                     }

                                     }

                     };
                     setup();
                     if (btnback != null)
                     {
                                     btnback.setTypeface(font);
                     }
                     if (mainview != null)
                     {
                                     Log.d(TAG, "mainview not null setting layout nav stuff");
                                     mainview.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
                     }
     }

     public void saveprefs(String name, String value)
     {
                     prefsedit = prefs.edit();
                     prefsedit.putString(name, value);
                     prefsedit.commit();
     }

     public String getprefs(String name, String defvalue)
     {
                     return prefs.getString(name, defvalue);
     }

     public void newtoast()
     {
                     if (toastrunnable == null)
                     {
                                     return;
                     }
                     if (!txt.equals(""))
                     {
                                     runOnUiThread(toastrunnable);
                     }
     }

     public void newtoast(String txt)
     {
                     this.txt = txt;
                     newtoast();
     }

     public void setup()
     {

     }

     public void login()
     {
                     if (authdialog != null)
                     {
                                     authdialog.show();
                     }
     }

     public boolean isloggedin()
     {
                     if (authdialog != null)
                     {
                                     return authdialog.isauthenticated();
                     }
                     return false;
     }

     public boolean loginstatuschanged()
     {
                     if (authdialog != null)
                     {
                                     return authdialog.authstatuschanged();
                     }
                     return false;
     }

     @SuppressLint({ "InlinedApi", "RtlHardcoded" })
     public void setelementposition(View v, int x, int y, int w, int h)
     {
                     try
                     {
                                     final DisplayMetrics metrics = new DisplayMetrics();
                                     getWindowManager().getDefaultDisplay().getMetrics(metrics);
                                     final int actualX
=
(int)
(metrics.widthPixels * 1.0f / screenwidth * x);
                                     final int actualY
= (int) (metrics.heightPixels * 1.0f / screenheight * y);
                                     final int actualWidth = (int) (metrics.widthPixels * 1.0f / screenwidth * w);
                                     final int actualHeight = (int) (metrics.heightPixels * 1.0f / screenheight * h);
                                     FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
                                     if (Build.VERSION.SDK_INT >= 14)
                                     {
                                                     params.gravity = Gravity.START | Gravity.TOP;
                                     }
                                     else
                                     {
                                                     params.gravity = Gravity.LEFT | Gravity.TOP;
                                     }
                                     params.leftMargin = actualX;
                                     params.topMargin = actualY;
                                     params.width = actualWidth;
                                     params.height = actualHeight;
                                     v.setLayoutParams(params);
                                     v.getLayoutParams().width = actualWidth;
                                     v.getLayoutParams().height = actualHeight;
                                     v.invalidate();
                     }
                     catch (Exception e)
                     {
                                     Log.e(TAG, "Error setting element position");
                     }
     }

     @Override
     public void onChangeActivity(int id)
     {
                     instantkill = false;
     }

     public long
getmemoryusage()
     {
                     try
                     {
                                     long totalmemory = Runtime.getRuntime().totalMemory();
                                     long freememory = Runtime.getRuntime().freeMemory();
                                     return totalmemory - freememory;
                     }
                     catch (Exception e)
                     {
                                     Log.e(TAG, "Error getting memory usage");
                                     return 0;
                     }
     }

     public void logmemoryusage()
     {
                     try
                     {
                                     long totalmemory = Runtime.getRuntime().totalMemory();
                                     long freememory = Runtime.getRuntime().freeMemory();
                                     Log.d(TAG, "Memory usage:" + (totalmemory - freememory));
                     }
                     catch (Exception e)
                     {
                                     Log.e(TAG, "Error getting memory usage");
                     }
     }

     public void logmemoryusage(String txt)
     {
                     try
                     {
                                     long totalmemory = Runtime.getRuntime().totalMemory();
                                     long freememory = Runtime.getRuntime().freeMemory();
                                     Log.d(TAG, txt + ".Memory usage:" + (totalmemory - freememory));
                     }
                     catch (Exception e)
                     {
                                     Log.e(TAG, "Error getting memory usage");
                     }
     }

     @Override
     protected void onStop()
     {
                     super.onStop();
                     if (!isFinishing())
                     {
                                     finish();
                     }
     }

     @SuppressLint("InlinedApi")
     @SuppressWarnings("deprecation")
     @Override
     protected void onResume()
     {

                     super.onResume();
                     Log.i(TAG, "onResume");
                     mPause = false;
                     // try and start the music again if we can....
                     Log.i(TAG, "onResume starting music");
                     Intent serviceintent = new Intent(this, MenuMusicService.class);
                     if (Build.VERSION.SDK_INT >= 12)
                     {
                                     serviceintent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
                     }

                     serviceintent.setAction("com.lloydm.geosword.common.MenuMusicService.start");

                     startService(serviceintent);

                     if (bvideo != null)
                     {
                                     Log.i(TAG, "bvideo is not null in resume");
                                     if (bholder == null)
                                     {
                                                     bholder = bvideo.getHolder();
                                                     bholder.addCallback(this);
                                                     bholder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
                                                     Log.i(TAG, "bholder created again");
                                     }
                                     else
                                     {
                                                     Log.i(TAG, "bholder already exists");
                                     }
                                     if (bplayer == null)
                                     {
                                                     bplayer = new MediaPlayer();
                                                     bplayer.reset();
                                                     bplayer.setOnErrorListener(new MediaPlayer.OnErrorListener()
                                                     {

                                                                     @Override
                                                                     public boolean
onError(MediaPlayer mp, int what, int extra)
                                                                     {
                                                                                     Log.e(TAG, "bplayer error:" + what + ", " + extra);

                                                                                     return true;
                                                                     }
                                                     });
                                                     Log.i(TAG, "created bplayer in resume");
                                     }
                                     else
                                     {
                                                     Log.i(TAG, "bplayer is not null");
                                     }
                     }
                     else
                     {
                                     Log.i(TAG, "bvideo is null in resume");
                     }

     }

     public void resumevideo(final String eTAG)
     {
                     // always called after onResume in "invite" .... this is the only code that calls this method....ever.....currently...
                     Log.i(TAG, "resumevideo called");
                     if (!eTAG.equals("com.lloydm.geosword.activities.InviteActivity"))
                     {
                                     return;
                     }
                     if (bvideo != null)
                     {
                                     if (bholder != null)
                                     {
                                                     if (bplayer != null)
                                                     {
                                                                     try
                                                                     {
                                                                                     if (bvidcanplay)
                                                                                     {
                                                                                                     // if(!bplayer.isPlaying())
                                                                                                     Log.i(TAG, "resumevideo attempting to play again");
                                                                                                     startvideo();
                                                                                                     // {
                                                                                                     // assuming the video is ready....maybe it is not?

                                                                                                     // bplayer.start();
                                                                                                     // }
                                                                                     }
                                                                     }
                                                                     catch (Exception e)
                                                                     {
                                                                                     Log.e(TAG, "Error resuming video playback most likely in invite screen");
                                                                     }
                                                     }
                                     }
                     }
     }

     @Override
     protected void onPause()
     {
                     super.onPause();
                     Log.i(TAG, "onPause");
                     mPause = true;

                     if (bplayer != null)
                     {
                                     Log.i(TAG, "on pause - bplayer");
                                     try
                                     {
                                                     if (bplayer.isPlaying())
                                                     {
                                                                     bplayer.stop();
                                                     }
                                     }
                                     catch (Exception e)
                                     {
                                                     Log.e(TAG, "Error closing video 1");
                                     }
                                     try
                                     {
                                                     bplayer.release();
                                                     bplayer = null;
                                     }
                                     catch (Exception e)
                                     {
                                                     Log.e(TAG, "Error closing video 2");
                                     }
                     }
                     // we want to signal a 'finish command' to the music which is delayed.....
                     // it waits approximately 2750ms before actually finishing.....
                     // if there is a resume then it will cancel the finish command.....
                     Intent serviceintent = new Intent(this, MenuMusicService.class);
                     if (Build.VERSION.SDK_INT >= 12)
                     {
                                     serviceintent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
                     }
                     if (instantkill)
                     {
                                     serviceintent.setAction("com.lloydm.geosword.common.MenuMusicService.instantkill");

                     }
                     else
                     {
                                     serviceintent.setAction("com.lloydm.geosword.common.MenuMusicService.finish");
                     }
                     startService(serviceintent);

     }

     @Override
     public void surfaceCreated(SurfaceHolder holder)
     {
                     Log.i(TAG, "surf created");
                     if (bplayer != null)
                     {
                                     try
                                     {
                                                     bplayer.setDisplay(holder);
                                                     Log.i(TAG, "bplayer has had holder set in surface created");
                                                     startvideo();
                                     }
                                     catch (Exception e)
                                     {
                                                     Log.e(TAG, "Error on surf created");
                                     }
                     }
                     else
                     {
                                     Log.i(TAG, "bplayer is null in surfacecreated");
                     }

     }

     @Override
     public void surfaceChanged(SurfaceHolder holder, int format, int width, int height)
     {
                     Log.i(TAG, "surf changed");

                     if (bplayer != null)
                     {
                                     Log.i(TAG, "bplayer not null in surf chagned");
                                     try
                                     {
                                                     Log.i(TAG, "setting display holder in surf changed");
                                                     bplayer.setDisplay(holder);
                                                     startvideo();
                                     }
                                     catch (Exception e)
                                     {
                                                     Log.e(TAG, "Error on surf changed");

                                     }
                     }
                     else
                     {
                                     Log.i(TAG, "bplayer is null in surf changed");
                     }
     }

     @Override
     public void surfaceDestroyed(SurfaceHolder holder)
     {
                     Log.i(TAG, "surf destroyed");
                     if (bplayer != null)
                     {
                                     try
                                     {

                                                     if (bplayer.isPlaying())
                                                     {
                                                                     bplayer.stop();
                                                     }
                                     }
                                     catch (Exception e)
                                     {
                                                     Log.e(TAG, "Video player exception on stop");
                                     }
                                     bplayer.release();
                                     bplayer = null;
                     }
                     else
                     {
                                     Log.i(TAG, "bplayer already null surf dest");
                     }

     }

     private void startvideo()
     {
                     Log.i(TAG, "start video ");
                     if (bvideo != null)
                     {
                                     if (bvidresid != 0)
                                     {
                                                     // load the video....
                                                     if (bplayer != null)
                                                     {
                                                                     try
                                                                     {
                                                                                     if (bplayer.isPlaying())
                                                                                     {
                                                                                                     Log.i(TAG, "video already playing.");
                                                                                                     return;
                                                                                     }
                                                                     }
                                                                     catch (Exception ef)
                                                                     {
                                                                                     Log.i(TAG, "expected error");
                                                                     }
                                                                     Resources res = getResources();
                                                                     FileDescriptor fd = null;
                                                                     long fdoff = 0;
                                                                     long fdlen = 0;
                                                                     AssetFileDescriptor afd = res.openRawResourceFd(bvidresid);
                                                                     fd = afd.getFileDescriptor();
                                                                     fdoff = afd.getStartOffset();
                                                                     fdlen = afd.getLength();

                                                                     if (fd != null)
                                                                     {
                                                                                     try
                                                                                     {
                                                                                                     Log.i(TAG, "attempting to read fd");
                                                                                                     bplayer.reset();
                                                                                                     bplayer.setDataSource(fd, fdoff, fdlen);

                                                                                                     // maybe try and remove any onprepared listeners that already exist?

                                                                                                     Log.i(TAG, "data source set");

                                                                                                     bplayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener()
                                                                                                     {

                                                                                                                     @Override
                                                                                                                     public void
onPrepared(MediaPlayer mp)
                                                                                                                     {
                                                                                                                                     Log.i(TAG, "video prepared");
                                                                                                                                     try
                                                                                                                                     {
                                                                                                                                                     if (bplayer != null)
                                                                                                                                                     {
                                                                                                                                                                     if (bplayer != mp)
                                                                                                                                                                     {
                                                                                                                                                                                     return;
                                                                                                                                                                     }
                                                                                                                                                     }
                                                                                                                                                     // also want to show the surface...
                                                                                                                                                     runOnUiThread(new Runnable()
                                                                                                                                                     {

                                                                                                                                                                     @Override
                                                                                                                                                                     public void
run()
                                                                                                                                                                     {
                                                                                                                                                                                     bvideo.setVisibility(View.VISIBLE);
                                                                                                                                                                                     try
                                                                                                                                                                                     {
                                                                                                                                                                                                     if (bhidevidonfinish)
                                                                                                                                                                                                     {
                                                                                                                                                                                                                     Handler h = bvideo.getHandler();
                                                                                                                                                                                                                     h.postDelayed(bfadevid, 1000);
                                                                                                                                                                                                     }
                                                                                                                                                                                     }
                                                                                                                                                                                     catch (Exception f)
                                                                                                                                                                                     {
                                                                                                                                                                                                     Log.e(TAG, "coudl not get handler");
                                                                                                                                                                                     }
                                                                                                                                                                     }
                                                                                                                                                     });

                                                                                                                                                     mp.setOnCompletionListener(new MediaPlayer.OnCompletionListener()
                                                                                                                                                     {

                                                                                                                                                                     @Override
                                                                                                                                                                     public void
onCompletion(MediaPlayer mp)
                                                                                                                                                                     {
                                                                                                                                                                                     if (bplayer != null)
                                                                                                                                                                                     {
                                                                                                                                                                                                     if (bplayer != mp)
                                                                                                                                                                                                     {
                                                                                                                                                                                                                     return;
                                                                                                                                                                                                     }
                                                                                                                                                                                     }

                                                                                                                                                                                     runOnUiThread(new Runnable()
                                                                                                                                                                                     {

                                                                                                                                                                                                     @Override
                                                                                                                                                                                                     public void
run()
                                                                                                                                                                                                     {
                                                                                                                                                                                                                     bvideodone = true;
                                                                                                                                                                                                                     if (bhidevidonfinish)
                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                     bvideo.setVisibility(View.INVISIBLE);
                                                                                                                                                                                                                     }
                                                                                                                                                                                                                     if (txtwait != null)
                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                     try
                                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                                     txtwait.setVisibility(View.INVISIBLE);
                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                     catch (Exception efg)
                                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                                     Log.w(TAG, "error hiding txtview");
                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                     }
                                                                                                                                                                                                     }
                                                                                                                                                                                     });

                                                                                                                                                                                     try
                                                                                                                                                                                     {
                                                                                                                                                                                                     if (bvideolooped)
                                                                                                                                                                                                     {
                                                                                                                                                                                                                     // tablet might need this for some reason......
                                                                                                                                                                                                                     mp.start();
                                                                                                                                                                                                     }
                                                                                                                                                                                     }
                                                                                                                                                                                     catch (Exception ff)
                                                                                                                                                                                     {
                                                                                                                                                                                                     Log.w(TAG, "error restarting video");
                                                                                                                                                                                     }
                                                                                                                                                                     }
                                                                                                                                                     });

                                                                                                                                                     Log.i(TAG, "attempting to loop and start video");
                                                                                                                                                     mp.setLooping(bvideolooped);
                                                                                                                                                     mp.start();
                                                                                                                                                     Log.i(TAG, "video ought to have started");
                                                                                                                                                     bvidcanplay = true;
                                                                                                                                     }
                                                                                                                                     catch (Exception e)
                                                                                                                                     {
                                                                                                                                                     Log.e(TAG, "error after video prepared trying to start");
                                                                                                                                     }
                                                                                                                     }
                                                                                                     });
                                                                                                     bplayer.prepareAsync();
                                                                                     }
                                                                                     catch (IllegalArgumentException e)
                                                                                     {
                                                                                                     // TODO Auto-generated catch block
                                                                                                     Log.e(TAG, "iae fd");
                                                                                                     e.printStackTrace();
                                                                                     }
                                                                                     catch (IllegalStateException e)
                                                                                     {
                                                                                                     // TODO Auto-generated catch block
                                                                                                     Log.e(TAG, "ise fd");
                                                                                                     e.printStackTrace();
                                                                                     }
                                                                                     catch (IOException e)
                                                                                     {
                                                                                                     // TODO Auto-generated catch block
                                                                                                     Log.e(TAG, "io fd");
                                                                                                     e.printStackTrace();
                                                                                     }
                                                                                     finally
                                                                                     {
                                                                                                     try
                                                                                                     {
                                                                                                                     afd.close();
                                                                                                     }
                                                                                                     catch (Exception e)
                                                                                                     {
                                                                                                                     // TODO Auto-generated catch block
                                                                                                                     Log.e(TAG, "Error closing fd");
                                                                                                     }
                                                                                     }
                                                                     }
                                                     }
                                     }
                     }
     }

     public void setkillmusicflag()
     {
                     instantkill = true;
     }

     public void gotostrategyguide()
     {
                     // launch the browser/play app to view the strategy guide
                     try
                     {
                                     Intent intent = new Intent(Intent.ACTION_VIEW);
                                     // won't exist yet......(but we already knew that....)
                                     intent.setData(Uri.parse("http://stardancercinematicspaceopera.blogspot.com.au/"));
                                     startActivity(intent);
                     }
                     catch (Exception f)
                     {
                                     Log.e(TAG, "could not open browser");

                     }
     }

     public void setuphelp(final int helptitleid, final int helptextid, final int helpid)
     {
                     helpdialog = new HelpDialog(this, helptitleid, helptextid, helpid);
                     SharedPreferences sp1 = this.getSharedPreferences("com.lloydm.geosword.common.HelpDialog.helpok", MODE_PRIVATE);

                     final int showit = sp1.getInt(Integer.toString(helpid), 0);
                     if (showit < 2)
                     {
                                     helpdialog.show();
                     }
     }

}