import urllib3
import json,random
from enum import Enum
from typing import Any, Dict,List
from tempfile import NamedTemporaryFile
from os import system, chmod, remove
from base64 import b64encode
from io import BytesIO


class TagPostVisibility(str, Enum):
    NO_ONE = "NoOne"
    FOLLOWING = "Following"
    EVERYONE = "Everyone"
class InvalidInputError(Exception):
    def __init__(self, message="Invalid input provided"):
        self.message = message
        super().__init__(self.message)
class confing():
    headers= {
        "User-Agent": "okhttp/3.12.1",
        "Connection": "Keep-Alive",
        "Accept-Encoding": "gzip",
        "Content-Type": "application/json; charset=UTF-8"
        }
    server = {
            "rubino": "https://rubino17.iranlms.ir",
            "messenger": "https://messengerg2c137.iranlms.ir"
        }
    android = {
        "app_name": "Main",
        "app_version": "3.7.3",
        "lang_code": "fa",
        "package": "app.rbmain.a",
        "platform": "Android",
        "store": "Myket",
        "temp_code": "34"
    }
    th=b'\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x00\x00\x01\x00\x01\x00\x00\xff\xdb\x00C\x00\x08\x06\x06\x07\x06\x05\x08\x07\x07\x07\t\t\x08\n\x0c\x14\r\x0c\x0b\x0b\x0c\x19\x12\x13\x0f\x14\x1d\x1a\x1f\x1e\x1d\x1a\x1c\x1c $.\' ",#\x1c\x1c(7),01444\x1f\'9=82<.342\xff\xdb\x00C\x01\t\t\t\x0c\x0b\x0c\x18\r\r\x182!\x1c!22222222222222222222222222222222222222222222222222\xff\xc0\x00\x11\x08\x00\x80\x00\x80\x03\x01"\x00\x02\x11\x01\x03\x11\x01\xff\xc4\x00\x1f\x00\x00\x01\x05\x01\x01\x01\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\xff\xc4\x00\xb5\x10\x00\x02\x01\x03\x03\x02\x04\x03\x05\x05\x04\x04\x00\x00\x01}\x01\x02\x03\x00\x04\x11\x05\x12!1A\x06\x13Qa\x07"q\x142\x81\x91\xa1\x08#B\xb1\xc1\x15R\xd1\xf0$3br\x82\t\n\x16\x17\x18\x19\x1a%&\'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz\x83\x84\x85\x86\x87\x88\x89\x8a\x92\x93\x94\x95\x96\x97\x98\x99\x9a\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xff\xc4\x00\x1f\x01\x00\x03\x01\x01\x01\x01\x01\x01\x01\x01\x01\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\xff\xc4\x00\xb5\x11\x00\x02\x01\x02\x04\x04\x03\x04\x07\x05\x04\x04\x00\x01\x02w\x00\x01\x02\x03\x11\x04\x05!1\x06\x12AQ\x07aq\x13"2\x81\x08\x14B\x91\xa1\xb1\xc1\t#3R\xf0\x15br\xd1\n\x16$4\xe1%\xf1\x17\x18\x19\x1a&\'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x92\x93\x94\x95\x96\x97\x98\x99\x9a\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xff\xda\x00\x0c\x03\x01\x00\x02\x11\x03\x11\x00?\x00\xf0\'\x8c\xa6\x18\x1c\xabt5>\x9e\x86k\xe8\x93 |\xc0\x9c\xfbT+)\xd8c<\xafQ\xecj\xc6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xab\x90\xa4\x95\xed\x9aLa\xbbke\t\xc5J$S\x92\x00\xc8\x15^\x9c\xa7\x07$P\x04\xac\xa6M\xbcaI\xc0\x14>\xcd\xbbW#\x1f\xad<8\xfb6\x18\xe0\x97-\x91U\xcbd\xd0\x04\x91\x8d\xf2*g\x82y\xa1\x94\xedfc\x92y\x18\xa9-W\xf7\xae\xdd\x91\x19\xbfJc\x9c\xa0\x01}\xa8\x01\xd0\xb1w\xc6x\n\x7f\x95\\\x95~[h\x97\xe5\xdc\xa1\x98\x8f@*\xad\xaa\x0f=C\x1e\x08\xc1\xc5X\x8d\xc4\x97\n\xf2\x11\x81\xf2(\xf5\x02\x9a\x11$w;"\x96YyF]\x81\x7f\x1e\x95\x92NI54\x8cc2FI85\x05&\xc0S\xda\xb54\xd6\x0b&\xd6m\xa0)\xe4\xfd+1\x00,7\x1c\x0c\xf5\xad("\x02F\x19\xcf@)\xa0dZ\x9e\xc5\x95U3\x9c\x02j\x90ROJ\x9e\xe5\xbc\xc7.F;T\nH9\x1d\xa9=\xc6<#/\xde\x18\xe7\xbd\x05ZWm\xa3\xa9\xe0R\x16b\xd9\xe4\x9atJwu\xc0\xeb\x9a\x00\x89\x94\xa9\xc3\x0c\x11@\x1b\x8e;\x9a\x96\xe0\x0f7r\xe7i\xe8MJ\xb6\xd2C\x07\xda\x9dp\xbf\xc3\x9e\xe7\xfc\xf3E\x80\xff\xd9'

    
try:
    from base64 import b64encode, urlsafe_b64decode
    from Crypto.Util.Padding import pad, unpad
    from Crypto.Cipher import AES
except:os.system('pip install pycryptodome')
class cryption:

    def __init__(self, auth:str):
        self.key = bytearray(self.secret(auth), 'UTF-8')
        self.iv = bytearray.fromhex('0' * 32)

    def replaceCharAt(self, e, t, i):
        return e[0:t] + i + e[t + len(i):]

    def secret(self, e):
        t = e[0:8]
        i = e[8:16]
        n = e[16:24] + t + e[24:32] + i
        s = 0
        while s < len(n):
            e = n[s]
            if e >= '0' and e <= '9':
                t = chr((ord(e[0]) - ord('0') + 5) % 10 + ord('0'))
                n = self.replaceCharAt(n, s, t)
            else:
                t = chr((ord(e[0]) - ord('a') + 9) % 26 + ord('a'))
                n = self.replaceCharAt(n, s, t)
            s += 1
        return n

    def encrypt(self, text):
        return b64encode(
            AES.new(self.key, AES.MODE_CBC, self.iv)
            .encrypt(pad(text.encode('UTF-8'),AES.block_size))
        ).decode('UTF-8')


    def decrypt(self, text):
        return unpad(
            AES.new(self.key, AES.MODE_CBC, self.iv)
            .decrypt(urlsafe_b64decode(text.encode('UTF-8')))
            ,AES.block_size
        ).decode('UTF-8')
    
    
    def changeAuthType(self, auth_enc):
        lowercase = 'abcdefghijklmnopqrstuvwxyz'
        uppercase = 'abcdefghijklmnopqrstuvwxyz'.upper()
        digits = '0123456789'
        n = ''
        for s in auth_enc:
            if s in lowercase:
                n += chr(((32 - (ord(s) - 97)) % 26) + 97)
            elif s in uppercase:
                n += chr(((29- (ord(s) - 65)) % 26) + 65)
            elif s in digits:
                n += chr(((13 - (ord(s)- 48)) % 10) + 48)
            else:
                n += s
        return n
    
from requests.exceptions import HTTPError , ReadTimeout , ConnectionError
from requests.sessions import Session ; Session = Session()
from json import dumps,loads
from requests.exceptions import HTTPError , ReadTimeout , ConnectionError
from requests.sessions import Session ; Session = Session()
from json import dumps,loads
import requests
from requests import get

import os
import re

import io
import urllib

def get_video_thumbnail_bytes(video_path):
    if os.path.exists(video_path):
        try:
            from moviepy.editor import VideoFileClip
            from PIL import Image
            video = VideoFileClip(video_path)
            frame = video.get_frame(0)
            image = Image.fromarray(frame)
            byte_arr = io.BytesIO()
            image.save(byte_arr, format='JPEG')
            byte_arr.seek(0)
            return byte_arr.getvalue()
        except:
            raise Exception("An error occurred while processing the video file.")
    elif re.match(r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', video_path):  # if it's a download link
        try:
            response = urllib.request.urlopen(video_path)
            video_bytes = response.read()
            video = VideoFileClip(io.BytesIO(video_bytes))
            frame = video.get_frame(0)
            image = Image.fromarray(frame)
            byte_arr = io.BytesIO()
            image.save(byte_arr, format='JPEG')
            byte_arr.seek(0)
            return byte_arr.getvalue()
        except:
            raise Exception("An error occurred while downloading and processing the video file.")
    else:
        raise ValueError("Invalid input. Please provide a valid local file path or a download link.")
    
from PIL import Image
import io

def image_to_bytes(image_path):
    with Image.open(image_path) as img:
        buffer = io.BytesIO()
        img.save(buffer, format="JPEG")
        byte_data = buffer.getvalue()
    return byte_data

class req:

    def __init__(self,auth:str):
        self.auth = auth
        self.enc = cryption(auth)

    def send_request(self,data:dict,method:str,type_method:str="rubino"):

        if type_method == "rubino":

            data_json = {
                "api_version": "0",
                "auth": self.auth,
                "client":confing.android,
                "data": data,
                "method": method
            }
            
        elif type_method == "messenger":

            data_json = {
                "api_version": "5",
                "auth": self.auth,
                "data_enc": self.enc.encrypt(
                    dumps({
                        "method": method,
                        "input": data,
                        "client": confing.android
                    })
                )
            }

        while True:
            try:
                response = Session.post(
                    url=confing.server[type_method],
                    headers=confing.headers,
                    json=data_json
                )
            except HTTPError as err:
                raise HTTPError(f"HTTP Error {err.args[0]}")
            except ReadTimeout:
                raise ReadTimeout('Time out')
            except ConnectionError:
                raise ConnectionError('Check your internet connection')
            except:
                continue
            else:
                
                response_data = response.json()

                if 'data_enc' in response_data:
                    return loads(self.enc.decrypt(response_data['data_enc']))
                if response_data.get('status') != "OK":
                    raise InvalidInputError(f"Error : {response_data.get('status_det', 'Unknown error')}")
                return response_data

        
    def requestUploadFile(self,file_name:str,size:str,file_type:str,profile_id:str=None):
        return self.send_request({
            "file_name": file_name,
            "file_size": str(size), 
            "file_type": file_type,
            "profile_id": profile_id
        },"requestUploadFile")
    

    def upload(self, post_file, post_type: str, profile_id: str = None):
        file_byte_code = post_file if isinstance(post_file, bytes) else open(post_file, "rb").read()
        upload_res = self.requestUploadFile("video.mp4" if post_type == "Video" else "picture.jpg", len(file_byte_code), post_type, profile_id)
        if upload_res is not None and upload_res["status"] == "OK":
            upload_res = upload_res["data"]
            total_part = len(file_byte_code) // 131072
            upload_data = 0
            for part in range(1, total_part + 2):
                byte_part = file_byte_code[131072 * (part - 1): 131072 * part]
                header = {
                    "part-number": str(part),
                    "total-part": str(total_part + 1),
                    "auth": self.auth,
                    "hash-file-request": upload_res["hash_file_request"],
                    "file-id": str(upload_res["file_id"]),
                    "content-type": "application/octet-stream",
                    "content-length": str(len(byte_part)),
                    "Host": upload_res["server_url"].replace("https://", "").replace("/UploadFile.ashx", ""),
                    "Connection": "Keep-Alive",
                    "accept-encoding": "gzip",
                    "user-agent": "okhttp/3.12.1",
                }
                while True:
                    try:
                        response = Session.post(data=byte_part, url=upload_res["server_url"], headers=header)
                        if response.status_code == 200:
                            upload_data += len(byte_part)
                            RED = "\033[31m"
                            GREEN = "\033[32m"
                            YELLOW = "\033[33m"
                            CYAN = "\033[36m"
                            BOLD = "\033[1m"
                            RESET = "\033[0m"
                            progress = upload_data / len(file_byte_code)
                            progress_bar_length = 100
                            filled_length = int(progress_bar_length * progress)
                            progress_bar = f"[{'=' * filled_length}{'.' * (progress_bar_length - filled_length)}]"
                            print(f"\r{RESET}{YELLOW}{BOLD}Post File --{CYAN}{BOLD}| Upload {RESET} {GREEN}{upload_data / (1024 * 1024):.2f} MB {CYAN}{BOLD} total {RESET} {progress_bar} {progress * 100:.2f}%{RESET} in {RESET} {YELLOW}{len(file_byte_code) / (1024 * 1024):.2f} MB {CYAN}{BOLD}", end="\r")
                            break
                    except ConnectionError:raise ConnectionError('Check your internet connection')
            print()
            return [upload_res, response.json()["data"]["hash_file_receive"]]
        return upload_res


class DateInfo:
    def __init__(self, data: Dict[str, Any]):
        self.jalali = data.get('jalali')
        self.miladi = data.get('miladi')
        self.ghamari = data.get('ghamari')
def getVideoData(bytes:bytes):
        try:
            from moviepy.editor import VideoFileClip
            with NamedTemporaryFile(delete=False, dir=".") as temp_video:
                temp_video.write(bytes)
                temp_path = temp_video.name
            chmod(temp_path, 0o777)
            try:
                from PIL import Image
            except ImportError:
                system("pip install pillow")
                from PIL import Image
            with VideoFileClip(temp_path) as clip:
                duration = clip.duration
                resolution = clip.size
                thumbnail = clip.get_frame(0)
                thumbnail_image = Image.fromarray(thumbnail)
                thumbnail_buffer = BytesIO()
                print(thumbnail_buffer)
                thumbnail_image.save(thumbnail_buffer, format="JPEG")
                thumbnail_b64 = thumbnail_buffer.getvalue()
                clip.close()
            remove(temp_path)
            return thumbnail_b64
        except ImportError:
            print("pip install moviepy")
            return confing.th
        except Exception as e:print(e)
class SeasonInfo:
    def __init__(self, data: Dict[str, Any]):
        self.number = data.get('number')
        self.name = data.get('name')

class TimeInfo:
    def __init__(self, data: Dict[str, Any]):
        self.hour = data.get('hour')
        self.minute = data.get('minute')
        self.second = data.get('second')

class DayInfo:
    def __init__(self, data: Dict[str, Any]):
        self.number = data.get('number')
        self.name_week = data.get('name_week')
        self.name_month = data.get('name_month')

class MonthInfo:
    def __init__(self, data: Dict[str, Any]):
        self.number = data.get('number')
        self.name_past = data.get('name_past')
        self.name = data.get('name')

class YearInfo:
    def __init__(self, data: Dict[str, Any]):
        self.number = data.get('number')
        self.name = data.get('name')
        self.name_past = data.get('name_past')
        self.remaining = data.get('remaining')
        self.leap = data.get('leap')

class OccasionInfo:
    def __init__(self, data: Dict[str, Any]):
        self.miladi = data.get('miladi')
        self.jalali = data.get('jalali')
        self.ghamari = data.get('ghamari')

class TimeData:
    def __init__(self, data: Dict[str, Any]):
        self.timestamp = data.get('timestamp')
        self.date = DateInfo(data.get('date', {}))
        self.season = SeasonInfo(data.get('season', {}))
        self.time = TimeInfo(data.get('time', {}))
        self.day = DayInfo(data.get('day', {}))
        self.month = MonthInfo(data.get('month', {}))
        self.year = YearInfo(data.get('year', {}))
        self.occasion = OccasionInfo(data.get('occasion', {}))

    def __repr__(self) -> str:
        return json.dumps(self.__dict__, ensure_ascii=False, indent=4, default=lambda o: o.__dict__)

class IPInfo:
    def __init__(self, data: Dict[str, Any]):
        self.ip = data.get('IP')
        self.country = data.get('Country')
        self.city = data.get('City')
        self.isp = data.get('ISP')
        self.timezone = data.get('timzone')
        self.org = data.get('org')
        self.country_code = data.get('countryCode')

    def __repr__(self) -> str:
        return json.dumps(self.__dict__, ensure_ascii=False, indent=4)

def __request_url():
    import random
    return f"https://rubino{random.randint(1,59)}.iranlms.ir/"
from typing import Union, Optional
from pathlib import Path

_useragent_list = [
    'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0',
    'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36',
    'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36',
    'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36',
    'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36',
    'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.62',
    'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/111.0'
]
def get_useragent():
    import random
    return random.choice(_useragent_list)
class api:
    def download_post_rubika(
            share_url:str,
            #return_choice:None = False
    ):
        body = {'url': share_url}
        request = urllib3.PoolManager()
        response = request.request(
            'POST',
            'https://api-free.ir/api/rubino-dl.php',
            fields=body)
        if response.status == 200:
            response_data = json.loads(response.data.decode('utf-8'))
            if 'result' in response_data:
                    return response_data['result']
            
    def download_story_rubika(
            username:str
    ):
        body = {'id': username}
        request = urllib3.PoolManager()
        response = request.request(
            'POST',
            'https://api-free.ir/api2/story_rubino.php',
            fields=body)
        if response.status == 200:
            response_data = json.loads(response.data.decode('utf-8'))
            if 'result' in response_data:
                    return response_data['result']
    def search_page_rubino(
            text:str
    ):
        body = {'user': text}
        request = urllib3.PoolManager()
        response = request.request(
            'GET',
            'https://api-free.ir/api/rubino-search.php',
            fields=body)
        if response.status == 200:
            response_data = json.loads(response.data.decode('utf-8'))
            if 'result' in response_data:
                    return response_data['result']


class Bot():
    """rubino class Regester m.rubika.ir"""
    def __init__(self,auth,platform="m.rubika.ir",lang_code="fa") -> None:
        """
        regester m.rubika.ir
        """
        self.auth=auth
        self.platform=platform
        self.lang_code=lang_code
        #{"app_name": "Main","app_version": "3.0.2"dd,"lang_code": "fa","package": "app.rbmain.a","platform": "Android"}
    def _request_url(self):
        import random
        return f"https://rubino{random.randint(1,59)}.iranlms.ir/"
    def get_link(self):
        return self._request_url()
    def _requests_post(self,methode:str,data:dict):
        request = urllib3.PoolManager()

        if self.platform == "m.rubika.ir" or self.platform == "web" or self.platform == "PWA":
            body = {
                "auth":self.auth,
                "api_version":"0",
                "client":{
                    "app_name":"Main",
                    "app_version":"2.4.7",
                    "package":"m.rubika.ir",
                    "platform":"PWA"
                },
                "data":data,
                "method":methode
            }
        elif self.platform == "android" or self.platform == "Android" or self.platform == "rubix":
            body = {
                "auth":self.auth,
                "api_version":"0",
                "client":{
                    "app_name": "Main",
                    "app_version": "3.0.2",
                    "lang_code": self.lang_code,
                    "package": "app.rbmain.a",
                    "platform": "Android"
                },
                "data":data,
                "method":methode
            }
        response = request.request(
            'POST',
            self.get_link(),json=body)
        if response.status == 200:
            response_data = json.loads(response.data.decode('utf-8'))
            if 'data' in response_data:
                return response_data['data']
            else:
                raise Exception(f"Error: {response_data.get('status_det', 'Unknown error')}")
        else:
            raise Exception(f"Request Error Server - Status Code: {response.status}")

    def edit_info_page(
        self,
        username_me:str,
        name=str,
        bio=None,
        phone=None,
        email=None,
        website=None
        ):
        """
        - username_me : در این مقدر باید آیدی پیجی که میخاین ادیت شه وارد کنید
        """
        profile_id=requests.post(f"https://api-free.ir/api/rubino-search.php?user={username_me}").json()['result']['data']['profiles'][0]['id']
        data = {
            "profile_id":profile_id,
            "username":username_me,
            "name":name,
            "bio":bio,
            "phone":phone,
            "email":email,
            "website":website
        }
        methode = "updateProfile"
        req_get = self._requests_post(methode=methode,data=data)
        return req_get
    def create_page(
            self,
            username:str,
            name:str = "codern",
            bio:str = None,
            phone=None,
            email=None,
            website=None
            ):
        data = {
            "username":username,
            "name":name,
            "bio":bio,
            "phone":phone,
            "email":email,
            "website":website
        }
        methode = "createPage"

        request = self._requests_post(methode=methode,data=data)
        return request
    def Download_story(self,username):
        return api.download_story_rubika(username)
    def get_comments(self,post_id,post_profile_id,profile_id=None):
        data = {
            "equal": False,
            "limit": 100,
            "sort": "FromMax",
            "post_id": post_id,
            "profile_id": profile_id,
            "post_profile_id": post_profile_id
        }
        methode = "getComments"
        request = self._requests_post(methode=methode,data=data)
        return request
    def get_all_profile(self):
        data = {"equal":False,"limit":10,"sort":"FromMax"}
        methode = 'getProfileList'
        request = self._requests_post(methode=methode,data=data)
        return request
    def get_me_info(self,profile_id):
        """- دریافت اطلاعات پیج"""
        data = {"profile_id":profile_id}
        methode = 'getMyProfileInfo'
        request = self._requests_post(methode=methode,data=data)
        return request
    def Like(self,post_id,target_post_id):
        data ={"action_type":"Like","post_id":post_id,"post_profile_id":target_post_id,"profile_id":[]}
        methode = 'likePostAction'
        request = self._requests_post(methode=methode,data=data)
        return request
    
    #--------------------------------------------

    def comment(self,text,post_id,post_target_id,profile_id=None):
        import random
        data = {
            "content": text,
            "post_id": post_id,
            "post_profile_id": post_target_id,
            "rnd":f"{random.randint(100000,999999999)}" ,
            "profile_id":profile_id
        }
        methode = 'addComment'
        while True:
            try:return self._requests_post(methode=methode,data=data)
            except:return "error"
    
    def get_link_share(self,post_id,post_profile,prof=None):
        data = {
            "post_id":post_id,
            "post_profile_id":post_profile,
            "profile_id":prof
        }
        methode = 'getShareLink'
        return self._requests_post(methode=methode,data=data)
    
    
    def is_Exist_Username(self,username):
        if username.startswith("@"):
            username = username.split("@")[1]
            data = {"username": username}
        else:data = {"username": username}
        methode = "isExistUsername"
        return self._requests_post(methode=methode,data=data)
    
    def add_View_Story(self,target_story_id,ids:list,profile_id=None):
        data = {
            "profile_id":profile_id,
            "story_ids":ids,
            "story_profile_id":target_story_id
        }
        methode = 'addViewStory'
        return self._requests_post(methode=methode,data=data)
               

    def save_post(self,post_id,post_profile_id,prof=None):
        data = {
            "action_type":"Bookmark",
            "post_id":post_id,
            "post_profile_id":post_profile_id,
            "profile_id":prof
        }
        methode ='postBookmarkAction'
        return self._requests_post(methode=methode,data=data)
               

    def un_like(self,post_id,post_profile_id):
        data = {
            "action_type":"Unlike",
            "post_id":post_id,
            "post_profile_id":post_profile_id,
            "profile_id":[]
        }
        methode ='likePostAction'
        return self._requests_post(methode=methode,data=data)
    def get_Suggested(self,profile_id=None):
        data = {
            "profile_id":profile_id,
            "limit": 20,
            "sort": "FromMax"
        }
        methode = 'getSuggested'
        return self._requests_post(methode=methode,data=data)
    def image_to_bytes(self, image_path):
        with Image.open(image_path) as img:
            buffer = io.BytesIO()
            img.save(buffer, format="JPEG")
            byte_data = buffer.getvalue()
        return byte_data

    def check_url_content_type(self, url):
        response = requests.head(url)
        content_type = response.headers.get('Content-Type', '').lower()
        print(f"post type {content_type}")
        if 'image' in content_type:
            return 'image'
        elif 'video' in content_type:
            return 'video'
        return None

    def upload_file(self, file, file_type, profile_id):
        return req(self.auth).upload(file, file_type, profile_id)
        
    def get_video_resolution(self,download_link):
        try:
            from moviepy.editor import VideoFileClip
            clip = VideoFileClip(download_link)
            width = clip.w
            height = clip.h
            clip.close()
            return [width, height]
        except ModuleNotFoundError:
            print("pip install moviepy")
            return [668,789]
        except Exception as e:
            return [668,789]
    def add_Story(self,post_file:str,duration:int=27,size:list=[668,798],thumbnail_file:str=None,profile_id:str=None):
        
        if post_file.split(".")[-1] == "mp4" or post_file.split(".")[-1] == "mov" or post_file.split(".")[-1] == "mkv" or "https://":
            try:
                if "https://" in post_file:
                    tumb_res , post_res = req(self.auth).upload(image_to_bytes(thumbnail_file) if type(thumbnail_file) is str else confing.th,"Picture",profile_id) , req(self.auth).upload(requests.get(post_file).content,"Video",profile_id)
                else :
                    tumb_res , post_res = req(self.auth).upload(image_to_bytes(thumbnail_file) if type(thumbnail_file) is str else confing.th,"Picture",profile_id) , req(self.auth).upload(post_file,"Video",profile_id)
            except ModuleNotFoundError:
                print("pip install moviepy")
                tumb_res , post_res = req(self.auth).upload(confing.th,"Picture",profile_id) , req(self.auth).upload(post_file,"Video",profile_id)
            data = {
                "duration": str(duration),
                "file_id": post_res[0]["file_id"],
                "hash_file_receive": post_res[1],
                "height": 1280 if size[1] > 1280 else size[1],
                "story_type": "Video",
                "rnd": random.randint(100000, 999999999),
                "snapshot_file_id": tumb_res[0]["file_id"],
                "snapshot_hash_file_receive": tumb_res[1],
                "thumbnail_file_id": tumb_res[0]["file_id"],
                "thumbnail_hash_file_receive": tumb_res[1],
                "width": 720 if size[0] > 720 else size[0],
                "profile_id": profile_id
            }
                
        elif post_file.split(".")[-1] == "jpg" or post_file.split(".")[-1] == "png":
            post_res = req(self.auth).upload(post_file,"Picture",profile_id)

            data = {
                "file_id": post_res[0]["file_id"],
                "hash_file_receive": post_res[1],
                "height": 1280 if size[1] > 1280 else size[1],
                "story_type": "Picture",
                "rnd": random.randint(100000, 999999999),
                "thumbnail_file_id": post_res[0]["file_id"],
                "thumbnail_hash_file_receive": post_res[1],
                "width": 720 if size[0] > 720 else size[0],
                "profile_id": profile_id
            }
        else:
            return "file address eror"
        return req(self.auth).send_request(data,"addStory")['data']
    def add_Post(self,post_file: str, caption: str = None, time: int = 1, size: Any = [668, 798], thumbnail_file: str = None, profile_id: str = None):
        from concurrent.futures import ThreadPoolExecutor
        if size == "Auto" or size =="auto":
            try:
                size=self.get_video_resolution(post_file)
                print(size)
            except Exception as e:
                print(f"error data resolution  auto [668,789]")
        http = urllib3.PoolManager(num_pools=10, headers={'Connection': 'keep-alive'})
        def get_file_content(file):
            if file.startswith("https://"):
                content_type = self.check_url_content_type(file)
                if content_type not in ['image', 'video']:
                    return None, None
                response = http.request('GET', file)
                print("GET <<< Data byte.")
                return response.data, "Picture" if content_type == 'image' else "Video"
            else:
                post_extension = file.split(".")[-1].lower()
                if post_extension in ["mp4", "mov", "mkv"]:
                    return open(file, 'rb').read(), "Video"
                elif post_extension in ["jpg", "jpeg", "png"]:
                    return open(file, 'rb').read(), "Picture"
                else:
                    return None, None

        post_file_content, post_type = get_file_content(post_file)
        if post_file_content is None:
            return "Invalid file or URL"

        def get_thumbnail_content(thumbnail, post_file_content):
            if thumbnail and thumbnail.startswith("https://"):
                response = http.request('GET', thumbnail)
                content_type = response.headers.get('content-type', '').lower()
                if 'image' in content_type:
                    return response.data
                else:
                    return confing.th
            elif thumbnail:
                return image_to_bytes(thumbnail)
            else:
                try:
                    print("GET <<< thumbnail Byte.")
                    return getVideoData(post_file_content)
                except ModuleNotFoundError:
                    return confing.th
        thumbnail_content = get_thumbnail_content(thumbnail_file, post_file_content)
        def upload_file_concurrently(file_content, file_type, profile_id):
            return self.upload_file(file_content, file_type, profile_id)

        with ThreadPoolExecutor(max_workers=2) as executor:
            post_res = executor.submit(upload_file_concurrently, post_file_content, post_type, profile_id).result()
            tumb_res = executor.submit(upload_file_concurrently, thumbnail_content, "Picture", profile_id).result()

        data = {
            "caption": caption,
            "file_id": post_res[0]["file_id"],
            "hash_file_receive": post_res[1],
            "height": str(min(size[1], 862)),
            "width": str(min(size[0], 848)),
            "is_multi_file": False,
            "post_type": post_type,
            "rnd": random.randint(100000, 999999999),
            "tagged_profiles": [],
            "thumbnail_file_id": tumb_res[0]["file_id"],
            "thumbnail_hash_file_receive": tumb_res[1],
            "profile_id": profile_id
        }

        if post_type == "Video":
            data.update({
                "duration": str(time),
                "snapshot_file_id": tumb_res[0]["file_id"],
                "snapshot_hash_file_receive": tumb_res[1]
            })

        return req(self.auth).send_request(data, "addPost")

    def get_Post_Likes(self,post_profile_id:str,post_id:str,max_id:str,sort:str="FromMax",limit:int=50,equal:bool=False,profile_id:str=None):
        data = {
            "equal": equal,
            "limit": limit,
            "max_id": max_id,
            "post_id": post_id,
            "post_profile_id": post_profile_id,
            "sort": sort,
            "profile_id": profile_id
        }
        return self._requests_post(methode='getPostLikes',data=data)
    
    def get_Story(self,story_profile_id:str,story_ids:list,profile_id:str=None):
        return self._requests_post(data={
            "profile_id": profile_id,
            "story_ids": story_ids,
            "story_profile_id": story_profile_id
        },methode="getStory")
    
    def get_Story_Viewers(self,story_id:str,limit:int=50,profile_id:str=None):
        return self._requests_post(data={
            "limit": limit,
            "profile_id": profile_id,
            "story_id": story_id
        },methode="getStoryViewers")
    
    def get_My_Archive_Stories(self,sort:str="FromMax",limit:int=10,equal:bool=False,profile_id:str=None):
        return self._requests_post(data={
            "equal": equal,
            "limit": limit,
            "sort": sort,
            "profile_id": profile_id
        },methode="getMyArchiveStories")
    
    def get_Page_Highlights(self,target_profile_id:str,sort:str="FromMax",limit:int=10,equal:bool=False,profile_id:str=None):
        return self._requests_post(data={
            "equal": equal,
            "limit": limit,
            "sort": sort,
            "target_profile_id": target_profile_id,
            "profile_id": profile_id
        },methode="getProfileHighlights")
    
    def create_Highlight(self,highlight_name:str,story_ids:list,highlight_cover_picture:str,profile_id:str=None):
        highlight_cover_res = self.req.upload(highlight_cover_picture,"Picture",profile_id)
        return self._requests_post(data={
            "highlight_cover": {
                "highlight_file_id": highlight_cover_res[0]["file_id"],
                "highlight_hash_file_receive": highlight_cover_res[1],
                "type": "File"
            },
            "highlight_name": highlight_name,
            "story_ids": story_ids,
            "profile_id": profile_id
        },methode="addHighlight")
    
    def highlight_Story(self,highlight_id:str,story_id:str,profile_id:str=None):
        return self._requests_post(data={
            "highlight_id": highlight_id,
            "story_id": story_id,
            "profile_id": profile_id
        },methode="highlightStory")
    
    def remove_Story_From_Highlight(self,highlight_id:str,remove_story_ids:list,profile_id:str=None):
        return self._requests_post(data={
            "highlight_id": highlight_id,
            "remove_story_ids": remove_story_ids,
            "updated_parameters":["remove_story_ids"],
            "profile_id": profile_id
        },methode="editHighlight")
    
    def get_Hash_Tag_Trend(self,sort:str="FromMax",limit:int=50,equal:bool=False,profile_id:str=None):
        return self._requests_post(data={
            "equal": equal,
            "limit": limit,
            "sort": sort,
            "profile_id": profile_id
        },methode="getHashTagTrend")
    
    def get_Explore_Posts(self,sort:str="FromMax",limit:int=51,equal:bool=False,profile_id:str=None):
        return self._requests_post(data={
            "equal": equal,
            "limit": limit,
            "sort": sort,
            "profile_id": profile_id
        },methode="getExplorePosts")
    
    def get_Tagged_Posts(self,target_profile_id:str,sort:str="FromMax",limit:int=50,equal:bool=False,profile_id:str=None):
        return self._requests_post(data={
            "equal": equal,
            "limit": limit,
            "sort": sort,
            "target_profile_id": target_profile_id,
            "profile_id": profile_id
        },methode="getTaggedPosts")
    
    def delete_Comment(self,post_id:str,comment_id:str,text:str,profile_id:str=None):
        return self._requests_post(data={
            "model": "Comment",
            "post_id": post_id,
            "record_id": comment_id,
            "profile_id": profile_id
        },methode="removeRecord")
    
    def like_Comment(self,comment_id:str,post_id:str,profile_id:str=None):
        return self._requests_post(data={
            "action_type": "Like",
            "comment_id": comment_id,
            "post_id": post_id,
            "profile_id": profile_id
        },methode="likeCommentAction")
    
    def un_like_Comment(self,comment_id:str,post_id:str,profile_id:str=None):
        return self._requests_post(data={
            "action_type": "Unlike",
            "comment_id": comment_id,
            "post_id": post_id,
            "profile_id": profile_id
        },methode="likeCommentAction")
    
    def get_Comments(self,post_profile_id:str,post_id:str,sort:str="FromMax",limit:int=50,equal:bool=False,profile_id:str=None):
        return self._requests_post(data={
            "equal": equal,
            "limit": limit,
            "post_id": post_id,
            "post_profile_id": post_profile_id,
            "sort": sort,
            "profile_id": profile_id
        },methode="getComments")
    
    def request_Follow(self,followee_id:str,profile_id:str=None):
        return self._requests_post(data={
            "f_type": "Follow",
            "followee_id": followee_id,
            "profile_id": profile_id
        },methode="requestFollow")
    
    def un_Follow(self,followee_id:str,profile_id:str=None):
        return self._requests_post(data={
            "f_type": "Unfollow",
            "followee_id": followee_id,
            "profile_id": profile_id
        },methode="requestFollow")
    
    def get_Page_Follower(self,target_profile_id:str,sort:str="FromMax",limit:int=50,equal:bool=False,profile_id:str=None):
        return self._requests_post(data={
            "equal": equal,
            "f_type": "Follower",
            "limit": limit,
            "sort": sort,
            "target_profile_id": target_profile_id,
            "profile_id": profile_id
        },methode="getProfileFollowers")
    def search_Follower(self,username,profile_id,target_profile_id,limit=10,search_type="Follower"):
        return self._requests_post(data={
            "limit": limit,
            "profile_id": profile_id,
            "search_type": limit,
            "target_profile_id": target_profile_id,
            "username": username
        },methode="searchFollower")
    def search_Following(self,username,profile_id,target_profile_id,limit=10,search_type="Following"):
        return self._requests_post(data={
            "limit": limit,
            "profile_id": profile_id,
            "search_type": limit,
            "target_profile_id": target_profile_id,
            "username": username
        },methode="searchFollower")
    
    def get_Page_Following(self,target_profile_id:str,sort:str="FromMax",limit:int=50,equal:bool=False,profile_id:str=None):
        return self._requests_post(data={
            "equal": equal,
            "f_type": "Following",
            "limit": limit,
            "sort": sort,
            "target_profile_id": target_profile_id,
            "profile_id": profile_id
        },methode="getProfileFollowers")
    
    def search_Follower(self,target_profile_id:str,username:str,max_id:str,sort:str="FromMax",limit:int=50,equal:bool=False,profile_id:str=None):
        return self._requests_post(data={
            "equal": equal,
            "limit": limit,
            "max_id": max_id,
            "search_type": "Follower",
            "sort": sort,
            "target_profile_id": target_profile_id,
            "username": username,
            "profile_id": profile_id
        },methode="getProfileFollowers")
    
    def search_Following(self,target_profile_id:str,username:str,max_id:str,sort:str="FromMax",limit:int=50,equal:bool=False,profile_id:str=None):
        return self._requests_post(data={
            "equal": equal,
            "limit": limit,
            "max_id": max_id,
            "search_type": "Following",
            "sort": sort,
            "target_profile_id": target_profile_id,
            "username": username,
            "profile_id": profile_id
        },methode="getProfileFollowers")
    def get_Related_Explore_Post(self,post_id:str,track_id,post_profile_id:str,limit:int=50,start_id:bool=False,profile_id:str=None,target_profile_id=None,):
        return self._requests_post(data={
            "limit": limit,
            "post_id": post_id,
            "post_profile_id": post_profile_id,
            "start_id": start_id,
            "target_profile_id": target_profile_id,
            "track_id": track_id,
            "profile_id": profile_id
        },methode="getRelatedExplorePost")
    
    def get_Highlight_StoryIds(self,highlight_id:str,profile_id:str,target_profile_id:str):
        return self._requests_post(data={
            "highlight_id": highlight_id,
            "profile_id": profile_id,
            "target_profile_id": target_profile_id
        },methode="getHighlightStoryIds")
    def get_Highlight_Stories(self,highlight_id:str,profile_id:str,target_profile_id:str,story_ids:list):
        return self._requests_post(data={
            "highlight_id": highlight_id,
            "profile_id": profile_id,
            "target_profile_id": target_profile_id,
            "story_ids":story_ids
        },methode="getHighlightStories")
    def un_save_Post(self,post_profile_id:str,post_id:str,profile_id:str=None):
        return self._requests_post(data={
            "action_type": "Unbookmark",
            "post_id": post_id,
            "post_profile_id": post_profile_id,
            "track_id": "Related",
            "profile_id": profile_id
        },methode="postBookmarkAction")
    def get_saved_posts(
    self,
    max_id: str,
    limit: int = 20,
    profile_id: Optional[str] = None,
    sort: str = "FromMax") -> Dict[str, Any]:
        payload = {
            "limit": limit,
            "max_id": max_id,
            "sort": sort
        }
        if profile_id is not None:
            payload["profile_id"] = profile_id

        return self._requests_post(
            data=payload,
            methode="getBookmarkedPosts"
        )
    
    def search_Page(self,username:str,sort:str="FromMax",limit:int=50,equal:bool=False,profile_id:str=None):
        return self._requests_post(data={
            "equal": equal,
            "limit": limit,
            "sort": sort,
            "username": username,
            "profile_id": profile_id
        },methode="searchProfile")
    
    def block_Page(self,target_profile_id:str,profile_id:str=None):
        return self._requests_post(data={
            "action": "Block",
            "blocked_id": target_profile_id,
            "profile_id": profile_id
        },methode="setBlockProfile")
    
    def un_block_Page(self,target_profile_id:str,profile_id:str=None):
        return self._requests_post(data={
            "action": "Unblock",
            "blocked_id": target_profile_id,
            "profile_id": profile_id
        },methode="setBlockProfile")
    
    def report_Page(self,post_id:str,reason:int=2,profile_id:str=None):
        return self._requests_post(data={
            "model": "Profile",
            "reason": reason,
            "record_id": post_id,
            "profile_id": profile_id
        },methode="setReportRecord")
    def report_Post(self,post_profile_id,post_id:str,reason:int=2,profile_id:str=None):
        return self._requests_post(data={
            "model": "Post",
            "reason": reason,
            "post_profile_id":post_profile_id,
            "record_id": post_id,
            "profile_id": profile_id
        },methode="setReportRecord")

    def delete_Post(self,post_id:str,profile_id:str=None):
        return self._requests_post(data={
            "model": "Post",
            "record_id": post_id,
            "profile_id": profile_id
        },methode="removeRecord")
    
    def delete_Story(self,story_id:list,profile_id:str=None):
        return self._requests_post(data={
            "profile_id": profile_id,
            "story_id": story_id,
        },methode="deleteStory")
    
    def set_Page_Status(self,profile_status:str="Private",profile_id:str=None):
        return self._requests_post(data={
            "profile_status": profile_status,
            "profile_id": profile_id
        },methode="updateProfile")
    def get_New_Events(self,limit:int=20,sort:str="FromMax",profile_id:str=None):
        return self._requests_post(data={
            "limit": limit,
            "profile_id": profile_id,
            "sort":sort
        },methode="updateProfile")

    def allow_Send_MessagePv(self,is_message_allowed:bool=False,profile_id:str=None):
        return self._requests_post(data={
            "is_message_allowed": is_message_allowed,
            "profile_id": profile_id
        },methode="updateProfile")
    
    def edit_Notification(self,is_mute:bool=False,profile_id:str=None):
        return self._requests_post(data={
            "is_mute": is_mute,
            "profile_id": profile_id
        },methode="updateProfile")
    
    def upload_avatar(self,prof_file:str,profile_id:str=None):
        prof_res = req(self.auth).upload(prof_file,"Picture",profile_id)
        return self._requests_post(data={
            "file_id": prof_res[0]["file_id"],
            "hash_file_receive": prof_res[1],
            "thumbnail_file_id": prof_res[0]["file_id"],
            "thumbnail_hash_file_receive": prof_res[1],
            "profile_id": profile_id
        },methode="updateProfilePhoto")
    
    def delete_Page(self,page_profile_id:str):
        return self._requests_post(data={
            "model": "Profile",
            "record_id": page_profile_id,
            "profile_id": None
        },methode="removeRecord")
    
    def add_Post_View_Count(self,post_profile_id:str,post_id:str):
        return self._requests_post(data={
            "post_id": post_id,
            "post_profile_id": post_profile_id
        },methode="addPostViewCount")

    def add_Post_View_Time(self,post_profile_id:str,post_id:str,duration:int,profile_id:str=None):
        return self._requests_post(data={
            "duration": duration,
            "post_id": post_id,
            "post_profile_id": post_profile_id,
            "profile_id": profile_id
        },methode="addPostViewTime")['data']
    def get_Profile_Posts(self,target_profile_id:str,max_id:str,sort:str="FromMax",limit:str=10):
        return self._requests_post(data={
            "limit": limit,
            "max_id": max_id,
            "sort":sort,
            "target_profile_id": target_profile_id,
        },methode="getProfilePosts")['data']
    def get_info_Post(self,url_post:str,profile_id:str=None):
        return self._requests_post(data={
            "share_string": url_post,
            "profile_id": profile_id,
        },methode="getPostByShareLink")['data']
    def search_HashTag(
        self,
        content: str,
        profile_id:str,
        limit: int = 20,
    ) -> Dict[str, Any]:

        payload = {
            "profile_id": profile_id,
            "content": content,
            "limit": limit
        }
        return self._requests_post("reportProfile", data=payload)
    def accept_Follow_Request(
        self,
        request_id: str,
        profile_id: Optional[str] = None
    ) -> Dict[str, Any]:
        """
        Accept a follow request from a user.

        Args:
            request_id (str): The ID of the follow request.
            profile_id (Optional[str]): The profile ID of the current user (if available).

        Returns:
            Dict[str, Any]: The server's response, including action status.
        """
        payload = {
            "action": "Accept",
            "request_id": request_id,
            "profile_id": profile_id
        }
        return self._requests_post("actionOnRequest", data=payload)
    def decline_Follow_Request(
        self,
        request_id: str,
        profile_id: Optional[str] = None
    ) -> Dict[str, Any]:
        """
        Decline a follow request from a user.

        Args:
            request_id (str): The ID of the follow request.
            profile_id (Optional[str]): The profile ID of the current user (if available).

        Returns:
            Dict[str, Any]: The server's response, including action status.
        """
        payload = {
            "action": "Decline",
            "request_id": request_id,
            "profile_id": profile_id
        }
        return self._requests_post("actionOnRequest", data=payload)
    def get_New_Follow_Requests(
        self,
        profile_id: Optional[str] = None ,
        limit: int = 20,
        sort: str = "FromMax"
    ) -> Dict[str, Any]:
        """
        Retrieve new follow requests for a given profile.

        Args:
            profile_id (str): The profile ID of the current user.
            limit (int): The number of requests to fetch. Default is 20.
            sort (str): The sorting order for the requests. Default is "FromMax".

        Returns:
            Dict[str, Any]: The server's response containing new follow requests.
        """
        payload = {
            "profile_id": profile_id,
            "limit": limit,
            "sort": sort
        }
        return self._requests_post("getNewFollowRequests", data=payload)
    def get_myprofile_posts(
        self,
        profile_id: Optional[str] = None ,
        limit: int = 20,
        sort: str = "FromMax"
    ) -> Dict[str, Any]:
        payload = {
            "profile_id": profile_id,
            "limit": limit,
            "sort": sort
        }
        return self._requests_post("getMyProfilePosts", data=payload)
    def get_recent_following_posts(
        self,
        profile_id: Optional[str] = None ,
        limit: int = 20,
        sort: str = "FromMax"
    ) -> Dict[str, Any]:
        payload = {
            "profile_id": profile_id,
            "limit": limit,
            "sort": sort
        }
        return self._requests_post("getRecentFollowingPosts", data=payload)
    def get_explore_post_topics(
        self,
        profile_id: Optional[str] = None ,
    ) -> Dict[str, Any]:
        payload = {
            "profile_id": profile_id,
        }
        return self._requests_post("getExplorePostTopics", data=payload)
    def get_profiles_stories(
        self,
        profile_id: Optional[str] = None ,
    ) -> Dict[str, Any]:
        payload = {
            "profile_id": profile_id,
        }
        return self._requests_post("getProfilesStories", data=payload)
    def get_posts_by_hashtag(
        self,
        hashtag: Optional[str],
        start_id: Optional[str] = None
    ) -> Dict[str, Any]:
        payload = {
            "hashtag": hashtag,
            "start_id":start_id
        }
        return self._requests_post("getPostsByHashTag", data=payload)
    def add_reply_comment(
        self,
        content: str,
        comment_id: str,
        post_id: str,
        profile_id: str,
        track_id: str = "Explore:two_tower"
    ) -> Dict[str, Any]:
        payload = {
            "content": content,
            "comment_id": comment_id,
            "post_id": post_id,
            "profile_id": profile_id,
            "track_id": track_id
        }
        return self._requests_post("addReplyComment", data=payload)
    def set_profile_public(
    self,
    profile_id: str
    ) -> Dict[str, Any]:
        payload = {
            "profile_status": "Public",
            "profile_id": profile_id
        }

        return self._requests_post(
            "updateProfile",
            data=payload
        )
    def set_profile_private(
    self,
    profile_id: str
    ) -> Dict[str, Any]:
        payload = {
            "profile_status": "Private",
            "profile_id": profile_id
        }

        return self._requests_post(
            "updateProfile",
            data=payload
        )
    def enable_private_messages(
    self,
    profile_id: str
    ) -> Dict[str, Any]:
        payload = {
            "is_message_allowed": True,
            "profile_id": profile_id
        }

        return self._requests_post(
            "updateProfile",
            data=payload
        )
    def disable_private_messages(
    self,
    profile_id: str
    ) -> Dict[str, Any]:
        payload = {
            "is_message_allowed": False,
            "profile_id": profile_id
        }

        return self._requests_post(
            "updateProfile",
            data=payload
        )
    def enable_profile_notifications(
    self,
    profile_id: str
    ) -> Dict[str, Any]:
        payload = {
            "is_mute": False,
            "profile_id": profile_id
        }

        return self._requests_post(
            "updateProfile",
            data=payload
        )
    def mute_profile_notifications(
    self,
    profile_id: str
    ) -> Dict[str, Any]:
        payload = {
            "is_mute": True,
            "profile_id": profile_id
        }

        return self._requests_post(
            "updateProfile",
            data=payload
        )
    def set_tagged_posts_visibility(
    self,
    profile_id: str,
    visibility: TagPostVisibility
    ) -> Dict[str, Any]:
        payload = {
            "tag_post": visibility.value,
            "profile_id": profile_id
        }

        return self._requests_post(
            "updateProfile",
            data=payload
        )

    def tagged_posts_no_one(
    self,
    profile_id: str
    ) -> Dict[str, Any]:
        return self.set_tagged_posts_visibility(profile_id, "NoOne")
    def tagged_posts_following(
    self,
    profile_id: str
    ) -> Dict[str, Any]:
        return self.set_tagged_posts_visibility(profile_id, "Following")
    def tagged_posts_everyone(
    self,
    profile_id: str
    ) -> Dict[str, Any]:
        return self.set_tagged_posts_visibility(profile_id, "Everyone")
    def get_liked_comment_profiles(
        self,
        post_id: str,
        comment_id: str,
        profile_id: str,
        limit: int = 20,
        sort: str = "FromMax",
        max_id: Optional[str] = None
    ) -> Dict[str, Any]:
        payload = {
            "post_id": post_id,
            "comment_id": comment_id,
            "limit": limit,
            "sort": sort,
            "max_id": max_id,
            "profile_id": profile_id
        }
        return self._requests_post(
            "getLikedCommentProfiles",
            data=payload
        )
    def get_profile_info(
        self,
        target_profile_id: str,
        track_id: str = "Explore:two_tower"
    ) -> Dict[str, Any]:
        payload = {
            "target_profile_id": target_profile_id,
            "track_id": track_id
        }
        return self._requests_post(
            "getProfileInfo",
            data=payload
        )
    def get_profiles_story_list(
    self,
        profile_id: str,
        story_ids: List[str],
    ) -> Dict[str, Any]:
        payload = {
            "profile_story_ids": [
                {
                    "profile_id": profile_id,
                    "story_ids": story_ids
                }
            ]
        }

        return self._requests_post(
            "getProfilesStoryList",
            data=payload,
        )
    def get_comment_replies(
    self,
        post_id: str,
        comment_id: str,
        profile_id: str,
        limit: int = 10,
        sort: str = "FromMin",
        max_id: Optional[str] = None
    ) -> Dict[str, Any]:

        payload = {
            "post_id": post_id,
            "comment_id": comment_id,
            "profile_id": profile_id,
            "limit": limit,
            "sort": sort,
            "max_id": max_id
        }

        return self._requests_post(
            "getCommentReplies",
            data=payload
        )