





"""simple docstring"""




from __future__ import annotations

import json

import requests
from bsa import BeautifulSoup
from fake_useragent import UserAgent

lowercase_          =		{"""UserAgent""": UserAgent().random}




def       __UpperCamelCase  (_SCREAMING_SNAKE_CASE		)    ->       dict:
  lowercase__           =  script.contents[0]
  lowercase__           =  json.loads(data[data.find('{"config"'		) : -1]		)
  return info["entry_data"]["ProfilePage"][0]["graphql"]["user"]
class     SCREAMING_SNAKE_CASE       :


   def __init__(   self      :    Any      ,					a      :    List[str]	)->       Optional[int]:





     """simple docstring"""







     lowercase__           =  f"""https://www.instagram.com/{username}/"""
     lowercase__           =  self.get_json()


   def 	SCREAMING_SNAKE_CASE_							(   self      :    int	)->       dict:





     """simple docstring"""







     lowercase__           =  requests.get(self.url      ,					headers=a	).text
     lowercase__           =  BeautifulSoup(a      ,					'html.parser'	).find_all('script'	)
     try:
       return extract_user_profile(scripts[4]	)
     except (json.decoder.JSONDecodeError, KeyError):
       return extract_user_profile(scripts[3]	)


   def __repr__(   self      :    Any	)->       str:





     """simple docstring"""







     return f"""{self.__class__.__name__}('{self.username}')"""


   def __str__(   self      :    str	)->       str:





     """simple docstring"""







     return f"""{self.fullname} ({self.username}) is {self.biography}"""


   @property
   def 	SCREAMING_SNAKE_CASE_							(   self      :    Union[str, Any]	)->       str:





     """simple docstring"""







     return self.user_data["username"]


   @property
   def 	SCREAMING_SNAKE_CASE_							(   self      :    str	)->       str:





     """simple docstring"""







     return self.user_data["full_name"]


   @property
   def 	SCREAMING_SNAKE_CASE_							(   self      :    Any	)->       str:





     """simple docstring"""







     return self.user_data["biography"]


   @property
   def 	SCREAMING_SNAKE_CASE_							(   self      :    Any	)->       str:





     """simple docstring"""







     return self.user_data["business_email"]


   @property
   def 	SCREAMING_SNAKE_CASE_							(   self      :    Optional[Any]	)->       str:





     """simple docstring"""







     return self.user_data["external_url"]


   @property
   def 	SCREAMING_SNAKE_CASE_							(   self      :    Dict	)->       int:





     """simple docstring"""







     return self.user_data["edge_followed_by"]["count"]


   @property
   def 	SCREAMING_SNAKE_CASE_							(   self      :    str	)->       int:





     """simple docstring"""







     return self.user_data["edge_follow"]["count"]


   @property
   def 	SCREAMING_SNAKE_CASE_							(   self      :    Optional[int]	)->       int:





     """simple docstring"""







     return self.user_data["edge_owner_to_timeline_media"]["count"]


   @property
   def 	SCREAMING_SNAKE_CASE_							(   self      :    List[Any]	)->       str:





     """simple docstring"""







     return self.user_data["profile_pic_url_hd"]


   @property
   def 	SCREAMING_SNAKE_CASE_							(   self      :    str	)->       bool:





     """simple docstring"""







     return self.user_data["is_verified"]


   @property
   def 	SCREAMING_SNAKE_CASE_							(   self      :    Dict	)->       bool:





     """simple docstring"""







     return self.user_data["is_private"]






def       __UpperCamelCase  (_SCREAMING_SNAKE_CASE = "github"		)    ->       None:
  import os

  if os.environ.get('CI'		):
    return  # test failing on GitHub Actions
  lowercase__           =  InstagramUser(_SCREAMING_SNAKE_CASE		)
  assert instagram_user.user_data
  assert isinstance(instagram_user.user_data		,						_SCREAMING_SNAKE_CASE		)
  assert instagram_user.username == username
  if username != "github":
    return
  assert instagram_user.fullname == "GitHub"
  assert instagram_user.biography == "Built for developers."
  assert instagram_user.number_of_posts > 150
  assert instagram_user.number_of_followers > 120000
  assert instagram_user.number_of_followings > 15
  assert instagram_user.email == "support@github.com"
  assert instagram_user.website == "https://github.com/readme"
  assert instagram_user.profile_picture_url.startswith('https://instagram.'		)
  assert instagram_user.is_verified is True
  assert instagram_user.is_private is False


if __name__ == "__main__":
      import doctest

      doctest.testmod()
      lowercase_          =		InstagramUser("""github""")
      print(instagram_user)
      print(f'''{instagram_user.number_of_posts = }''')
      print(f'''{instagram_user.number_of_followers = }''')
      print(f'''{instagram_user.number_of_followings = }''')
      print(f'''{instagram_user.email = }''')
      print(f'''{instagram_user.website = }''')
      print(f'''{instagram_user.profile_picture_url = }''')
      print(f'''{instagram_user.is_verified = }''')
      print(f'''{instagram_user.is_private = }''')









from collections.abc import Iterator, MutableMapping
from dataclasses import dataclass
from typing import Generic, TypeVar

lowercase_          =		TypeVar("""KEY""")
lowercase_          =		TypeVar("""VAL""")
@dataclass(frozen=UpperCAmelCase      ,     slots=UpperCAmelCase				)
class     SCREAMING_SNAKE_CASE       (Generic[KEY, VAL]				):
   _UpperCamelCase   :		KEY
   _UpperCamelCase   :		VAL






class     SCREAMING_SNAKE_CASE       (_Item				):


   def __init__(   self      :    Optional[int]	)->       None:





     """simple docstring"""







     super().__init__(a      ,					a	)


   def __bool__(   self      :    str	)->       bool:





     """simple docstring"""







     return False






lowercase_          =		_DeletedItem()
class     SCREAMING_SNAKE_CASE       (MutableMapping[KEY, VAL]				):


   def __init__(   self      :    Tuple      ,					a      :    int = 8      ,					a      :    float = 0.75	)->       None:





     """simple docstring"""







     lowercase__           =  initial_block_size
     lowercase__           =  [None] * initial_block_size
     assert 0.0 < capacity_factor < 1.0
     lowercase__           =  capacity_factor
     lowercase__           =  0


   def 	SCREAMING_SNAKE_CASE_							(   self      :    Any      ,					a      :    KEY	)->       int:





     """simple docstring"""







     return hash(a	) % len(self._buckets	)


   def 	SCREAMING_SNAKE_CASE_							(   self      :    Optional[Any]      ,					a      :    int	)->       int:





     """simple docstring"""







     return (ind + 1) % len(self._buckets	)


   def 	SCREAMING_SNAKE_CASE_							(   self      :    Any      ,					a      :    int      ,					a      :    KEY      ,					a      :    VAL	)->       bool:





     """simple docstring"""







     lowercase__           =  self._buckets[ind]
     if not stored:
       lowercase__           =  _Item(a      ,					a	)
       self._len += 1
       return True
     elif stored.key == key:
       lowercase__           =  _Item(a      ,					a	)
       return True
     else:
       return False


   def 	SCREAMING_SNAKE_CASE_							(   self      :    str	)->       bool:





     """simple docstring"""







     lowercase__           =  len(self._buckets	) * self._capacity_factor
     return len(self	) >= int(a	)


   def 	SCREAMING_SNAKE_CASE_							(   self      :    Tuple	)->       bool:





     """simple docstring"""







     if len(self._buckets	) <= self._initial_block_size:
       return False
     lowercase__           =  len(self._buckets	) * self._capacity_factor / 2
     return len(self	) < limit


   def 	SCREAMING_SNAKE_CASE_							(   self      :    List[str]      ,					a      :    int	)->       None:





     """simple docstring"""







     lowercase__           =  self._buckets
     lowercase__           =  [None] * new_size
     lowercase__           =  0
     for item in old_buckets:
       if item:
         self._add_item(item.key      ,					item.val	)


   def 	SCREAMING_SNAKE_CASE_							(   self      :    Optional[int]	)->       None:





     """simple docstring"""







     self._resize(len(self._buckets	) * 2	)


   def 	SCREAMING_SNAKE_CASE_							(   self      :    Optional[int]	)->       None:





     """simple docstring"""







     self._resize(len(self._buckets	) // 2	)


   def 	SCREAMING_SNAKE_CASE_							(   self      :    Any      ,					a      :    KEY	)->       Iterator[int]:





     """simple docstring"""







     lowercase__           =  self._get_bucket_index(a	)
     for _ in range(len(self._buckets	)	):
       yield ind
       lowercase__           =  self._get_next_ind(a	)


   def 	SCREAMING_SNAKE_CASE_							(   self      :    Tuple      ,					a      :    KEY      ,					a      :    VAL	)->       None:





     """simple docstring"""







     for ind in self._iterate_buckets(a	):
       if self._try_set(a      ,					a      ,					a	):
         break


   def __setitem__(   self      :    List[Any]      ,					a      :    KEY      ,					a      :    VAL	)->       None:





     """simple docstring"""







     if self._is_full():
       self._size_up()

     self._add_item(a      ,					a	)


   def __delitem__(   self      :    str      ,					a      :    KEY	)->       None:





     """simple docstring"""







     for ind in self._iterate_buckets(a	):
       lowercase__           =  self._buckets[ind]
       if item is None:
         raise KeyError(a	)
       if item is _deleted:
         continue
       if item.key == key:
         lowercase__           =  _deleted
         self._len -= 1
         break
     if self._is_sparse():
       self._size_down()


   def __getitem__(   self      :    List[str]      ,					a      :    KEY	)->       VAL:





     """simple docstring"""







     for ind in self._iterate_buckets(a	):
       lowercase__           =  self._buckets[ind]
       if item is None:
         break
       if item is _deleted:
         continue
       if item.key == key:
         return item.val
     raise KeyError(a	)


   def __len__(   self      :    Tuple	)->       int:





     """simple docstring"""







     return self._len


   def __iter__(   self      :    int	)->       Iterator[KEY]:





     """simple docstring"""







     yield from (item.key for item in self._buckets if item)


   def __repr__(   self      :    Union[str, Any]	)->       str:





     """simple docstring"""







     lowercase__           =  ' ,'.join(
         f"""{item.key}: {item.val}""" for item in self._buckets if item	)
     return f"""HashMap({val_string})"""


