interface LangDetails {
  langCode: string;
  langName: string;
}

export default interface LangFormat {
  details: LangDetails;
  appName: string;
  navigation: {
    home: {
      profile: {
        tabName: string;
        overview: string;
        settings: string;
        updateUsername: string;
        updatePassword: string;
        help: string;
        about: string;
      };
      calendar: {
        tabName: string;
        overview: string;
      };
      map: {
        tabName: string;
        overview: string;
      };
      chats: {
        tabName: string;
        overview: string;
      };
    };
  };
  info: string;
  error: string;
  success: string;
  registration: {
    buttonLogin: string;
    buttonSignUp: string;
    buttonNext: string;
    dividerText: string;
    thirdAuthButton: {
      google: string;
      apple: string;
    };
    previewLogin: {
      title: string;
      dontHaveAccount: string;
    };
    previewSignup: {
      title: string;
      agreeToTerms: string;
      agreeToTermsAnd: string;
      alreadyHaveAccount: string;
      terms: string;
      privacyPolicy: string;
      cookieUse: string;
    };
    login: {
      title: string;
      inputPhoneNumberOrAccountName: string;
      inputPassword: string;
    };
    signUpStepUsername: {
      title: string;
      description: string;
      inputUsername: string;
    };
    signUpStepPhoneNumber: {
      title: string;
      inputPhoneNumber: string;
    };
    signUpStepVerifyPhoneNumber: {
      title: string;
      description: string;
      clickableTextResendCode: string;
    };
    signUpStepPassword: {
      title: string;
      description: string;
      inputPassword: string;
    };
    signUpStepAccountName: {
      title: string;
      description: string;
      inputAccountName: string;
      buttonGetStarted: string;
    };
  };
  profile: {
    overview: {
      statistics: {
        followers: string;
        following: string;
        visited: string;
      };
    };
    settings: {
      overview: {
        accountData: {
          title: string;
          accountName: string;
          username: string;
          phoneNumber: string;
        };
        changePassword: {
          title: string;
          password: string;
          tapToChange: string;
        };
        moreInfo: {
          title: string;
          help: string;
          about: string;
          logout: string;
        };
      };
      changeUsername: {
        username: string;
        info: string;
        info2: string;
      };
      changePassword: {
        currentPassword: string;
        newPassword: string;
        repeatNewPassword: string;
        info: string;
        info2: string;
      };
      help: {
        reportAProblem: string;
        helpCenter: string;
      };
      about: {
        aboutYourAccount: string;
        privacyPolicy: string;
        termsOfService: string;
        openSourceLibraries: string;
      };
    };
  };
}

interface LangPlaceholderKeys {
  version?: number;
  appName?: string;
}

export function placeholder(text: string, data: LangPlaceholderKeys): string {
  let out = text;

  for (const key in data) {
    const rawValue = data[key as keyof LangPlaceholderKeys];

    let _value: any =
      typeof rawValue === 'number' ? rawValue.toString() : rawValue;

    if (typeof rawValue === 'undefined') _value = 'undefined';
    let value: string = _value;

    out = out.replaceAll('${' + key + '}', value);
  }

  return out;
}
