// withHooks

import { applyStyle } from 'esoftplay';
import { EventAlert } from 'esoftplay/cache/event/alert/import';
import { EventButton } from 'esoftplay/cache/event/button/import';
import { EventConfigProperty } from 'esoftplay/cache/event/config/import';
import { EventHeader } from 'esoftplay/cache/event/header/import';
import { EventIndexProperty } from 'esoftplay/cache/event/index/import';
import { EventOrder_itemProperty } from 'esoftplay/cache/event/order_item/import';
import { EventQueue } from 'esoftplay/cache/event/queue/import';
import { EventShare } from 'esoftplay/cache/event/share/import';
import { LibCarrousel } from 'esoftplay/cache/lib/carrousel/import';
import { LibCurl } from 'esoftplay/cache/lib/curl/import';
import { LibIcon } from 'esoftplay/cache/lib/icon/import';
import { LibLoading } from 'esoftplay/cache/lib/loading/import';
import { LibNavigation } from 'esoftplay/cache/lib/navigation/import';
import { LibObject } from 'esoftplay/cache/lib/object/import';
import { LibPicture } from 'esoftplay/cache/lib/picture/import';
import { LibScroll } from 'esoftplay/cache/lib/scroll/import';
import { LibSlidingup } from 'esoftplay/cache/lib/slidingup/import';
import { LibStyle } from 'esoftplay/cache/lib/style/import';
import { LibToastProperty } from 'esoftplay/cache/lib/toast/import';
import { LibUtils } from 'esoftplay/cache/lib/utils/import';
import { LibVideoProperty } from 'esoftplay/cache/lib/video/import';
import { LibWebview } from 'esoftplay/cache/lib/webview/import';
import { UseTasks } from 'esoftplay/cache/use/tasks/import';
import esp from 'esoftplay/esp';
import useLazyState from 'esoftplay/lazy';
import moment from 'esoftplay/moment';
import useSafeState from 'esoftplay/state';
import React, { useEffect } from 'react';
import { ActivityIndicator, Pressable, ScrollView, Text, TouchableOpacity, View } from 'react-native';


export interface EventArtist_detail_multiProps {

}

export type PriceList = Array<{
  "price_id": string,
  "type": string,
  "price_date": string,
  "currency": string,
  "use_seat": string,
  "use_code": string,
  "global_quota": string,
  "info": string,
  "term": [],
  "image_map": string,
  "price": string,
  "qty_min": string,
  "qty_max": string,
  "tax": string,
  "date_start": string,
  "date_end": string,
  "status": number,
  "config": {
    "seat_autopick": number,
    "seat_autopick_start": string,
  },
  "list": Array<{
    "event_artist_id": string,
    "ondate": string,
    "image": string,
    "date_id": number,
    "price": string,
    "quota": string,
    "quota_used": string,
    "status": number,
  }>,
  "quota_used": string,
}>


const taskSeat = UseTasks()
const taskAdditional = UseTasks()

export default function m(props: EventArtist_detail_multiProps): any {
  moment().locale('id')
  let showSchedule = React.useRef<LibSlidingup>(null)
  const { url, data, subscribed } = LibNavigation.getArgsAll(props)
  const [result, setResult, getResult] = useLazyState<any>(data)
  const [startBooking, setStartBooking] = useLazyState(moment(getResult()?.start_booking).serverFormat('YYYY-MM-DD HH:mm:ss'))
  const date = moment().localeFormat('YYYY-MM-DD HH:mm:ss')

  const [priceList, setPriceList, getPriceList] = useSafeState<PriceList>()
  const [, setDataPostBooking, getDataPostBooking] = useLazyState<any>([])
  const [dataAddition, setDataAddition] = useSafeState<any>([])
  const [showAll, setShowAll] = useSafeState<any>({});
  const [loading, setLoading] = useSafeState<boolean>(false)


  useEffect(() => {
    EventConfigProperty.curlConfig('v2/config_order_type')
    loadResult()
  }, [])

  function loadResult() {
    if (!url) {
      loadDataPrice(getResult()?.price_list_url)
    } else {
      new LibCurl(url, null, (res, msg) => {
        loadDataPrice(res?.price_list_url)
        setStartBooking(moment(res?.start_booking).serverFormat('YYYY-MM-DD HH:mm:ss'))
        setResult(res)()
      }, (err) => {
        LibToastProperty.show(err?.message)
        LibNavigation.back()
      })
    }
  }


  let dataEvent: any = {
    event_id: getResult()?.event_id,
    event_title: getResult()?.event_title,
    charge_payment: getResult()?.charge_payment,
    charge_payment_type: getResult()?.charge_payment_type,
    images: [{ image: getResult()?.image }],
  }

  const [ticketSeat, resetTicketSeat] = taskSeat((item: any) => new Promise((next) => {
    if (item.use_seat == 1) {
      if (item.seat_autopick == 0) {
        LibNavigation.navigateForResult('event/seat_map', {
          url: 'event_seat',
          dataTicket: {
            ...dataEvent,
            qty: item.qty,
            selected_ticket: {
              price_id: item.price_id,
              type: item.type,
              list: {
                ondate: item.ondate
              }
            }
          },
        }, item.list_id)
          .then((value: any) => {
            const merged = { ...item, ...value }
            let a = LibObject.replaceItem(getDataPostBooking(), (it) => it.list_id == item.list_id, merged)()
            setDataPostBooking(a)
            next()
          })
      } else {
        let a = LibObject.replaceItem(getDataPostBooking(), (it) => it.list_id == item.list_id, item)()
        setDataPostBooking(a)
        next()
      }
    } else {
      let a = LibObject.replaceItem(getDataPostBooking(), (it) => it.list_id == item.list_id, item)()
      setDataPostBooking(a)
      next()
    }
  }), () => {

    const transformedData: any[] = [];
    priceList?.filter((y: any) => y.selected == 1)?.map((item: any) => {
      item?.list?.filter((x: any) => x.selected == 1)?.map((listItem: any) => {
        transformedData.push({
          ...item,
          list_id: item.price_id + " " + listItem?.ondate,
          qty: listItem.qty,
          ondate: listItem.ondate,
          list: [listItem],
        });
      });
    })


    resetTicketAdditional()
    ticketAdditional(transformedData)
    setDataAddition([])

  })

  const [ticketAdditional, resetTicketAdditional] = taskAdditional((item: any) => new Promise((next) => {
    if (getResult()?.has_addition == 1 || item.has_addition && item.has_addition == 1) {
      LibNavigation.navigateForResult('event/additional', {
        event_id: dataEvent?.event_id,
        qty: item.qty,
        ondate: item.ondate,
        data: dataEvent,
        price_id: item.price_id,
        type_ticket: item.type
      }, item.list_id).then((value) => {
        if (value != "") {
          setDataAddition(dataAddition.push(JSON.parse(value)))
        }
        next()
      })
    } else {
      next()
    }
  }), () => {
    if (dataAddition?.length > 0) {
      dataEvent.addition = dataAddition
    }
    let args: any = {
      order_type: EventConfigProperty?.state()?.get()?.order_type?.ticket,
      fee_platform: {
        fee_platform_amount: getResult()?.fee_platform_amount,
        fee_platform_type: getResult()?.fee_platform_type,
      },
      subscribed: subscribed,
      dataEvent: dataEvent,
      dataTicket: getDataPostBooking(),
    }

    const selectedPriceIds = getDataPostBooking().filter((x: any) => x.selected == 1).map((x: any) => x.price_id)
    curlPriceConfig(selectedPriceIds, (filteredFee) => {
      const editedDataTicket = getDataPostBooking().map((item: any) => {
        const priceId = item.price_id;
        if (filteredFee?.[priceId]) {
          return {
            ...item,
            ...filteredFee?.[priceId]
          };
        }
        return item;
      })
      args["fee_platform"] = undefined
      args["dataTicket"] = editedDataTicket
      LibNavigation.navigate('payment/ticket_multi', args)
    })
  })

  function curlPriceConfig(price_ids: string[], onDone: (data: any) => void) {
    setLoading(true)
    if (getResult()?.url_price_config) {
      new LibCurl(getResult()?.url_price_config, null, (res, msg) => {
        setLoading(false)
        let filteredFee: any = {}
        if (res) {
          filteredFee = Object.fromEntries(
            price_ids.flatMap(k => res[k] ? [[k, res[k]]] : [])
          )
        }
        onDone(filteredFee)
      }, (err) => {
        setLoading(false)
        LibToastProperty.show(err?.message)
      })
    } else {
      setLoading(false)
      onDone({})
    }
  }

  function loadDataPrice(price_list_url: string) {
    new LibCurl(price_list_url, null, (res, msg) => {

      setPriceList(res)
    }, (err) => {
      LibToastProperty.show(err?.message)
      LibNavigation.back()
    }, 1)
  }

  function proceedToPayment() {
    let newResult: any[] = [];
    getPriceList().map((priceType: any) => {
      let filteredList = priceType.list/* .filter((item: any) => item.selected == 1); */
      filteredList = filteredList?.map((item: any) => ({
        ...item,
        type: priceType?.type,
        tax: priceType?.tax,
        term: priceType?.term,
        list_id: priceType?.price_id + "-" + item.ondate,
        price_id: priceType?.price_id
      }))

      newResult = newResult.concat(filteredList);
    });

    setDataPostBooking(newResult)
    resetTicketSeat()
    ticketSeat(newResult.filter((x: any) => x.selected == 1))

  }

  let share = [
    {
      icon: 'icons/ic_facebook.png',
      title: 'Facebook',
      onPress: () => { EventShare.facebook(getResult()?.url) }
    },
    {
      icon: 'icons/ic_whatsapp.png',
      title: 'Whatsapp',
      onPress: () => { EventShare.whatsapp(getResult()?.url) }
    },
    {
      icon: 'icons/ic_twitter.png',
      title: 'Twitter',
      onPress: () => { EventShare.twitter(getResult()?.url) }
    },
    {
      icon: 'icons/ic_copy.png',
      title: esp.lang("event/artist_detail", "copy"),
      onPress: () => {
        LibUtils.copyToClipboard(getResult()?.url).then((v) => {
          LibToastProperty.show(esp.lang("event/artist_detail", "alert"))
        })
      }
    },
  ]

  function renderShare(item: any, i: number) {
    return (
      <View key={i} style={applyStyle({ marginRight: 10 })}>
        <TouchableOpacity onPress={item.onPress} >
          <LibPicture style={applyStyle({ resizeMode: 'contain', height: 25, width: 25, borderRadius: 12.5, backgroundColor: 'white' })} source={esp.assets(item.icon)} />
        </TouchableOpacity>
      </View>
    )
  }

  function renderItem(itemC: any, iC: number, item: any, i: number) {
    let ticketWithDate = item.price_date == 1 && item.use_code == 0
    let ticketSpecial = item.price_date == 0 && item.use_code == 0

    let _selectedTicket = itemC?.selected == 1

    let colorDefault = _selectedTicket ? "#FFE9AD" : '#fff'
    let colorBackground = item?.status != 1 ? LibStyle.colorLightGrey : itemC?.status != 1 ? LibStyle.colorLightGrey : colorDefault
    let textOpacity = itemC?.status == 1 ? 1 : 0.3

    return (
      <TouchableOpacity
        onPress={() => {
          let msg = itemC?.status == 0 ? esp.lang("event/artist_detail", "sold_out") : esp.lang("event/artist_detail", "coming_soon")

          // kondisi untuk tipe tiket yang ada tanggalnya
          if (item?.status == 1 && itemC?.status == 1) {
            const data = new LibObject(priceList)
              .update((itemList) => {
                itemList.selected = itemList.selected == 1 ? 0 : 1
                itemList.qty = itemList.selected == 1 ? item.qty_min : 0
                itemList.seat_autopick = item.config?.seat_autopick
                itemList.use_seat = item.use_seat
                return itemList
              })(i, 'list', iC)
              .update((priceTypeItem) => {
                return ({
                  ...priceTypeItem,
                  selected: priceTypeItem.list.some((item: any) => item.selected == 1) ? 1 : 0
                })
              })(i)
              .value()

            setPriceList(data)
          } else if (itemC?.status == 0) {
            LibToastProperty.show(msg)
          } else if (itemC?.status == 2) {
            LibToastProperty.show(msg)
          }
        }} activeOpacity={itemC?.status == 1 ? 0 : 1} key={iC} style={{ borderBottomWidth: item.list.length == 1 ? 0 : 5, borderBottomColor: "#fff", flex: 1, flexDirection: 'row', backgroundColor: colorBackground, justifyContent: 'space-between', padding: 10, alignItems: 'center' }}>
        {
          itemC.ondate == "0000-00-00" ?
            <LibPicture source={esp.assets('icons/ic_special2.png')} style={{ height: 42, width: 42 }} />
            :
            <>
              <View style={applyStyle({ marginLeft: 10, marginHorizontal: 20, width: 42, height: 42, borderRadius: 5, backgroundColor: "#fff", borderStyle: "solid", borderWidth: 1, borderColor: _selectedTicket ? "#3ea4dc" : '#999', alignContent: 'center', alignItems: 'center', justifyContent: 'center' })}>
                <Text allowFontScaling={false} style={applyStyle({ opacity: textOpacity, fontFamily: "Arial", fontSize: 20, fontWeight: "bold", fontStyle: "normal", letterSpacing: 0.23, textAlign: "center", color: _selectedTicket ? "#3ea4dc" : '#999' })}>{LibUtils.moment(itemC.ondate).localeFormat('DD')}</Text>
              </View>
              <View style={applyStyle({ flexDirection: 'column', flex: 1 })}>
                {
                  item?.status == 1 && itemC?.status != 1 &&
                  <View style={applyStyle({ flexDirection: 'row', marginBottom: 5 })}>
                    <View style={applyStyle({ alignContent: 'center', alignItems: 'center', justifyContent: 'center', marginTop: 5, borderWidth: 1, backgroundColor: itemC?.status == 0 ? LibStyle.colorRed : "#4cd964", borderColor: itemC?.status == 0 ? LibStyle.colorRed : "#4cd964", borderRadius: 5, padding: 3, opacity: 0.8 })}>
                      <Text allowFontScaling={false} style={applyStyle({ fontSize: 10, fontStyle: "normal", letterSpacing: 0, color:/*  itemC?.status == 2 ? "#000" :  */"#fff", fontWeight: 'bold' })}>{itemC?.status == 0 ? esp.lang("event/artist_detail", "sold_out") : esp.lang("event/artist_detail", "coming_soon")}</Text>
                    </View>
                  </View>
                }
                <Text allowFontScaling={false} style={applyStyle({ opacity: textOpacity, fontFamily: "Arial", fontSize: 14, fontWeight: "bold", fontStyle: "normal", letterSpacing: 0, color: _selectedTicket ? "#3ea4dc" : '#999' })}>{LibUtils.moment(itemC.ondate).localeFormat('dddd')}</Text>
                <View style={applyStyle({ flexDirection: 'row' })}>
                  <Text allowFontScaling={false} style={applyStyle({ opacity: textOpacity, fontFamily: "Arial", fontSize: 12, fontWeight: "bold", fontStyle: "normal", letterSpacing: 0, color: _selectedTicket ? "#3ea4dc" : '#999' })}>{LibUtils.moment(itemC.ondate).localeFormat('MMMM')}</Text>
                  <Text allowFontScaling={false} style={applyStyle({ opacity: textOpacity, marginLeft: 7, fontFamily: "Arial", fontSize: 12, fontWeight: "bold", fontStyle: "normal", letterSpacing: 0, color: _selectedTicket ? "#3ea4dc" : '#999' })}>{LibUtils.moment(itemC.ondate).localeFormat('YYYY')}</Text>
                </View>
              </View>
            </>
        }

        <View style={applyStyle({ marginRight: 5, marginLeft: 5, flexDirection: 'column' })} >
          {
            (itemC?.status == 1 || itemC?.status == 0) &&
            <Text allowFontScaling={false} style={applyStyle({ opacity: ticketWithDate ? textOpacity : 1, fontFamily: "Arial", fontSize: 12, fontWeight: "bold", fontStyle: "normal", letterSpacing: 0, textAlign: "right", color: _selectedTicket ? "#3ea4dc" : (itemC.price == 0 ? LibStyle.colorGreen : '#999') })} >{itemC.price == 0 ? esp.lang("event/ticket_list", "free") : LibUtils.money(itemC.price, item.currency)}</Text>
          }
          {
            item?.status == 1 && (ticketWithDate || ticketSpecial) && itemC.selected == 1 &&
            <View style={applyStyle({ marginTop: 4, flexDirection: 'row', marginLeft: 8, alignContent: 'center', alignItems: 'center' })}>
              <TouchableOpacity onPress={() => {
                let qty = 1
                if (Number(itemC.qty) - 1 <= 0) {
                  // set 0 & unselect tiket
                  qty = 0

                  const data = new LibObject(priceList)
                    .update((itemList) => {
                      itemList.selected = 0
                      itemList.qty = 0
                      itemList.seat_autopick = item.config?.seat_autopick
                      itemList.use_seat = item.use_seat
                      return itemList
                    })(i, 'list', iC)
                    .update((priceTypeItem) => {
                      return ({
                        ...priceTypeItem,
                        selected: priceTypeItem.list.some((item: any) => item.selected == 1) ? 1 : 0
                      })
                    })(i)
                    .value()

                  setPriceList(data)

                } else {
                  // patuhi qty_min
                  if (itemC.qty <= item.qty_min) {
                    qty = Number(item.qty_min)
                  } else {
                    qty = Number(itemC.qty) - 1
                  }

                  // set qty baru
                  setPriceList(LibObject.set(getPriceList(), qty)(i, 'list', iC, 'qty'))
                }

              }}>
                <View style={applyStyle({ width: 28, height: 28, borderRadius: 6, backgroundColor: "#ecf0f1", justifyContent: 'center', alignContent: 'center', alignItems: 'center' })}>
                  <LibIcon name="minus" color="#e74c3c" />
                </View>
              </TouchableOpacity>
              <Text style={applyStyle({ fontFamily: "Arial", fontSize: 20, fontWeight: "bold", fontStyle: "normal", letterSpacing: 0, color: "#9b9b9b", marginLeft: 13, marginRight: 13 })}>{itemC?.qty}</Text>
              <TouchableOpacity onPress={() => {
                // add()
                let qty = 1
                if (itemC.qty != item.qty_max) {
                  if (qty != (Number(itemC.quota) - Number(itemC.quota_used))) {
                    qty = Number(itemC?.qty) + 1
                  }
                } else {
                  qty = Number(item.qty_max)
                }
                setPriceList(LibObject.set(getPriceList(), qty)(i, 'list', iC, 'qty'))

              }}>
                <View style={applyStyle({ width: 28, height: 28, borderRadius: 6, backgroundColor: "#ecf0f1", justifyContent: 'center', alignContent: 'center', alignItems: 'center' })}>
                  <LibIcon name="plus" color="#16a085" />
                </View>
              </TouchableOpacity>
            </View>
          }
        </View>
      </TouchableOpacity>
    )
  }

  if (!priceList) {
    return <LibLoading />
  }

  const bgHeight = LibStyle.width * 9 / 16

  function renderImages(item: any, i: number) {
    const styleId_Z1ecB7O: any = { height: bgHeight, width: LibStyle.width, resizeMode: 'cover' }
    return (
      <TouchableOpacity key={i} onPress={() => LibNavigation.navigate('lib/gallery', { images: getResult()?.images_artist, index: i })}>
        <LibPicture source={{ uri: item.image }} style={styleId_Z1ecB7O} />
      </TouchableOpacity>
    )
  }

  const maxDisplay = 3;
  const handleShowAll = (price_id: any) => {
    setShowAll((prevShowAll: any) => ({
      ...prevShowAll,
      [price_id]: !prevShowAll[price_id],
    }));
  };

  return (
    <EventQueue event_id={result?.event_id}>
      <View style={{ flex: 1 }} >
        <EventHeader title={esp.lang("event/artist_detail", "title")} subtitle={result?.title} />
        <LibScroll onRefresh={loadResult}>
          {
            getResult()?.images_artist && getResult()?.images_artist?.length > 0 ?
              <LibCarrousel
                delay={3000}
                style={{ height: bgHeight, width: LibStyle.width }}
                autoplay
                bullets
                bulletStyle={{ width: 7, height: 7, backgroundColor: "#fff", borderRadius: 3.5, borderWidth: 0, marginHorizontal: 2 }}
                chosenBulletStyle={{ width: 7, height: 7, backgroundColor: "#f4e31b", borderRadius: 3.5, borderWidth: 0, marginHorizontal: 2 }}
                bulletsContainerStyle={{ marginBottom: -10 }}>
                {
                  getResult()?.images_artist && getResult()?.images_artist?.map(renderImages)
                }
              </LibCarrousel>
              :
              <Pressable onPress={() => LibNavigation.navigate('lib/gallery', { image: result?.image_artist })} >
                <LibPicture
                  style={applyStyle({ height: LibStyle.width * 9 / 16, width: LibStyle.width, backgroundColor: '#f2f3f4' })}
                  source={{ uri: result?.image_artist }} />
              </Pressable>
          }

          <View style={applyStyle({ marginTop: 10, marginLeft: 17, flexDirection: 'row' })}>
            {
              share.map(renderShare)
            }
          </View>
          <Text allowFontScaling={false} style={applyStyle({ marginBottom: 12, marginLeft: 17, fontFamily: "Arial", marginTop: 20, fontSize: 26, fontWeight: "bold", fontStyle: "normal", lineHeight: 30, letterSpacing: 0, color: "#000" })}>{result?.title}</Text>
          {/* {
          data && priceList?.map?.(renderPrieList)
        } */}
          {
            result?.description != "" &&
            <ScrollView>
              <LibWebview onFinishLoad={() => { }} source={{ html: result?.description }} />
            </ScrollView>
          }
          {
            result && result?.youtube != "" &&
            <>
              <Text allowFontScaling={false} style={applyStyle({ marginHorizontal: 20, marginTop: 10, fontFamily: "Arial", fontSize: 13, fontWeight: "bold", fontStyle: "normal", lineHeight: 22, letterSpacing: 0, color: "#4a4a4a" })} >{esp.lang("event/artist_detail", "video")}</Text>
              <TouchableOpacity onPress={() => LibNavigation.navigate('lib/video', { code: getResult()?.youtube })} >
                <LibPicture source={{ uri: LibVideoProperty.getUrlThumbnail(getResult()?.youtube) }} style={applyStyle({ height: LibStyle.width * 9 / 16, width: LibStyle.width - 40, marginHorizontal: 20, resizeMode: 'cover' })} />
              </TouchableOpacity>
            </>
          }
        </LibScroll>
        <View style={applyStyle({ flexDirection: 'row', padding: 10, backgroundColor: 'white' })} >

          {
            result?.book_available == 1 ?
              <EventButton label={esp.lang("event/artist_detail", "buy_ticket")} onPress={() => {
                EventIndexProperty.isLogin(() => {
                  showSchedule.current?.show()
                })
              }} style={applyStyle({ backgroundColor: LibStyle.colorGreen })} />
              :
              <View style={applyStyle({ flex: 1, height: 35, borderRadius: 17, backgroundColor: LibStyle.colorLightGrey, justifyContent: 'center', alignItems: 'center', paddingHorizontal: 9 })} >
                <Text allowFontScaling={false} style={applyStyle({ fontFamily: "ArialBold", fontSize: 12, textAlign: "center", textAlignVertical: 'center', color: 'black', marginRight: 10, marginLeft: 10 })} >{esp.lang("event/artist_detail", "book_available", moment(startBooking).serverFormat("DD MMMM YYYY HH:mm:ss"))}</Text>
              </View>
          }
        </View>

        <LibSlidingup ref={showSchedule}>
          <View style={applyStyle({ backgroundColor: 'white', borderTopRightRadius: 30, borderTopLeftRadius: 30, paddingTop: 15, maxHeight: LibStyle.height - (LibStyle.height / 3) })}>
            <Text allowFontScaling={false} style={applyStyle({ marginBottom: 15, fontFamily: "Arial", fontSize: 16, fontWeight: "bold", fontStyle: "normal", lineHeight: 22, letterSpacing: 0, textAlign: "center", color: "#34495e" })}>{esp.lang("event/artist_detail", "select_date")}</Text>
            <ScrollView showsVerticalScrollIndicator={false} >
              <EventAlert
                color={LibStyle.colorPrimary}
                msg={esp.lang("event/ticket_list2", "u_can_choose_multiple")}
                style={{ marginHorizontal: 15, marginBottom: 0 }}
                useIcon
              />
              {
                priceList?.length > 0 && priceList?.map((item: any, i: number) => {
                  let filterFullData = priceList?.filter((it: any) => it.status != 0)
                  const displayedData = showAll[item.price_id] ? item?.list : item?.list.slice(0, maxDisplay);

                  let textOpacity = item?.status == 1 ? 1 : 0.3
                  return (
                    <View key={i} style={{ overflow: 'hidden', margin: 15, marginBottom: 5, backgroundColor: '#fff', borderRadius: 10, ...LibStyle.elevation(2), borderWidth: 1, borderColor: /* selTic ? LibStyle.colorBlue : */ LibStyle.colorBgGrey }}>
                      <View style={{ padding: 10, backgroundColor: '#f1f2f3', borderTopLeftRadius: 10, borderTopRightRadius: 10 }}>
                        {
                          item?.hasOwnProperty('label') && (item?.label != "" && item?.label != null) &&
                          <View style={applyStyle({ flexDirection: 'row' })}>
                            <View style={applyStyle({ alignContent: 'center', alignItems: 'center', justifyContent: 'center', borderWidth: 1, backgroundColor: item?.label_color, borderColor: item?.label_color, borderRadius: 3, padding: 2, paddingHorizontal: 5, opacity: 1 })}>
                              <Text allowFontScaling={false} style={{ fontSize: 10, fontStyle: "normal", letterSpacing: 0.5, color: EventOrder_itemProperty.textColor(item?.label_color), fontWeight: 'bold' }}>{item?.label}</Text>
                            </View>
                          </View>
                        }
                        <View style={{ alignContent: 'center', alignItems: 'center', flexDirection: 'row', justifyContent: 'space-between', }}>
                          <Text allowFontScaling={false} style={{ opacity: textOpacity, fontWeight: 'bold' }}>{item.type}</Text>
                          {
                            item.qty_min > 1 &&
                            <Text style={{ color: LibStyle.colorRed, fontSize: 10, fontWeight: 'normal' }}> {"(" + esp.lang("event/ticket_list", "min_order") + LibUtils.number(item.qty_min) + ")"}</Text>
                          }
                          {
                            item?.status != 1 &&
                            <View style={applyStyle({ flexDirection: 'row' })}>
                              <View style={applyStyle({ alignContent: 'center', alignItems: 'center', justifyContent: 'center', borderWidth: 1, backgroundColor: item?.status == 0 ? LibStyle.colorRed : "#4cd964", borderColor: item?.status == 0 ? LibStyle.colorRed : "#4cd964", borderRadius: 5, padding: 3, opacity: 0.8 })}>
                                <Text allowFontScaling={false} style={applyStyle({ fontSize: 10, fontStyle: "normal", letterSpacing: 0, color: /* item?.status == 2 ? "#000" : */ "#fff", fontWeight: 'bold' })}>{item?.status == 0 ? esp.lang("event/artist_detail", "sold_out") : esp.lang("event/artist_detail", "coming_soon")}</Text>
                              </View>
                            </View>
                          }
                        </View>
                        {
                          item.info != "" &&
                          <View style={{ marginTop: 3, alignContent: 'center', alignItems: 'center', flexDirection: 'row', marginRight: 5 }}>
                            <Text allowFontScaling={false} style={{ fontSize: 12, color: LibStyle.colorBlue }}>{item.info}</Text>
                          </View>
                        }
                      </View>
                      {
                        displayedData?.map((itemC: any, iC: number) => renderItem(itemC, iC, item, i))
                      }

                      {
                        filterFullData[i].list?.length > 3 &&
                        <TouchableOpacity onPress={() => {
                          handleShowAll(item.price_id)
                        }} style={{ borderTopColor: LibStyle.colorGrey, borderTopWidth: 0.8, flex: 1, padding: 8, flexDirection: 'row', alignContent: 'center', alignItems: 'center', justifyContent: 'center' }}>
                          <Text allowFontScaling={false} style={{ marginRight: 5, fontFamily: "Arial", fontSize: 12, fontWeight: "bold", fontStyle: "normal", letterSpacing: 0, color: LibStyle.colorBlue }}>{showAll[item.price_id] ? esp.lang("event/ticket_list", "see_less") : esp.lang("event/ticket_list", "see_more")}</Text>
                          <LibIcon name={showAll[item.price_id] ? 'chevron-up-circle-outline' : 'chevron-down-circle-outline'} color={LibStyle.colorBlue} size={18} />
                        </TouchableOpacity>
                      }

                    </View>
                  )
                })
              }
            </ScrollView>
            <View style={applyStyle({ flexDirection: 'row', paddingVertical: 10 })} >
              {
                result?.book_available == 1 ?
                  <>
                    {
                      result?.book_available == 0 && result.end_booking <= date && result.end_booking != '0000-00-00 00:00:00' ?
                        <View style={applyStyle({ flex: 1, height: 35, borderRadius: 17, backgroundColor: LibStyle.colorLightGrey, justifyContent: 'center', alignItems: 'center', paddingHorizontal: 9 })} >
                          <Text allowFontScaling={false} style={applyStyle({ fontFamily: "ArialBold", fontSize: 12, textAlign: "center", textAlignVertical: 'center', color: 'black', marginHorizontal: 10 })} >{esp.lang("event/artist_detail", "booking_end")}</Text>
                        </View>
                        :
                        <>
                          {
                            loading ?
                              <View style={{ minWidth: '100%', alignSelf: 'center' }}  >
                                <View style={{ borderWidth: 1, borderColor: 'rgba(0, 0, 0, 0)', height: 40, borderRadius: 16, backgroundColor: "#e6e6e6", alignItems: 'center', justifyContent: 'center', paddingHorizontal: 9 }} >
                                  <ActivityIndicator size={"small"} color={LibStyle.colorPrimary} />
                                </View>
                              </View> :
                              <EventButton label={esp.lang("event/artist_detail", "buy_ticket")} onPress={() => {
                                EventIndexProperty.isLogin(() => {
                                  proceedToPayment()
                                })
                              }} style={{ backgroundColor: LibStyle.colorGreen, marginTop: 2, marginHorizontal: 15 }} />
                          }
                        </>
                    }
                  </>
                  :
                  <View style={applyStyle({ flex: 1, height: 35, borderRadius: 17, backgroundColor: LibStyle.colorLightGrey, justifyContent: 'center', alignItems: 'center', paddingHorizontal: 9 })} >
                    <Text allowFontScaling={false} style={applyStyle({ fontFamily: "ArialBold", fontSize: 12, textAlign: "center", textAlignVertical: 'center', color: 'black', marginHorizontal: 10 })} >{esp.lang("event/artist_detail", "booking_on", moment(result?.start_booking).serverFormat('DD MMMM YYYY HH:mm '))}</Text>
                  </View>
              }
            </View>
          </View>
        </LibSlidingup>

      </View>
    </EventQueue>
  )
}