package com.ss.android.ugc.aweme.im.sdk.chat.data.model;

import X.2HN;
import X.9EH;
import X.Cl7;
import X.DwO;
import X.M12;
import android.content.Context;
import android.os.Bundle;
import com.bytedance.covode.number.Covode;
import com.google.gson.a.c;
import com.ss.android.ugc.aweme.base.model.UrlModel;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import com.ss.android.ugc.aweme.feed.model.Video;
import com.ss.android.ugc.aweme.feed.model.story.Story;
import com.ss.android.ugc.aweme.im.sdk.share.data.model.PureDataSharePackage;
import com.ss.android.ugc.aweme.profile.model.User;
import com.ss.android.ugc.aweme.sharer.ui.SharePackage;
import java.io.Serializable;
import kotlin.h.b.n;

public final class ShareStoryContent extends ShareAwemeContent {
    public static final Companion Companion = new Companion((2HN) null);
    @c(LIZ = "expired_at")
    public Long expireAt = 0L;
    @c(LIZ = "source_type")
    public Integer sourceType = 0;
    public String storyCollectionId = "";

    static {
        Covode.recordClassIndex(84136);
    }

    public static final ShareStoryContent fromAweme(Aweme aweme) {
        return Companion.fromAweme(aweme);
    }

    public static final ShareStoryContent fromSharePackage(SharePackage sharePackage) {
        return Companion.fromSharePackage(sharePackage);
    }

    public static final boolean isStory(BaseContent baseContent) {
        return Companion.isStory(baseContent);
    }

    public static final boolean isStoryExpired(ShareStoryContent shareStoryContent) {
        return Companion.isStoryExpired(shareStoryContent);
    }

    public final boolean showQuoteHint() {
        return true;
    }

    public static final class Companion {
        static {
            Covode.recordClassIndex(84137);
        }

        public Companion() {
        }

        public /* synthetic */ Companion(2HN r1) {
            this();
        }

        public final boolean isStory(BaseContent baseContent) {
            M12.LIZ(baseContent);
            return baseContent instanceof ShareStoryContent;
        }

        private final int getAweType(Integer num) {
            if (num != null && num.intValue() == 1) {
                return 0;
            }
            return 1;
        }

        public final boolean isStoryExpired(ShareStoryContent shareStoryContent) {
            M12.LIZ(shareStoryContent);
            Long expireAt = shareStoryContent.getExpireAt();
            if (expireAt == null || expireAt.longValue() >= System.currentTimeMillis()) {
                return false;
            }
            return true;
        }

        public final ShareStoryContent fromAweme(Aweme aweme) {
            UrlModel urlModel;
            UrlModel urlModel2;
            String str;
            float f;
            long j;
            M12.LIZ(aweme);
            ShareStoryContent shareStoryContent = new ShareStoryContent();
            shareStoryContent.user = aweme.getAuthorUid();
            shareStoryContent.secUid = aweme.getSecAuthorUid();
            shareStoryContent.itemId = aweme.getAid();
            shareStoryContent.setStoryCollectionId(Cl7.LIZIZ(aweme));
            Video video = aweme.getVideo();
            if (video == null || (urlModel = video.getCover()) == null) {
                urlModel = new UrlModel();
            }
            shareStoryContent.coverUrl = urlModel;
            User author = aweme.getAuthor();
            if (author == null || (urlModel2 = author.getAvatarThumb()) == null) {
                urlModel2 = new UrlModel();
            }
            shareStoryContent.contentThumb = urlModel2;
            User author2 = aweme.getAuthor();
            if (author2 == null || (str = author2.getNickname()) == null) {
                str = "";
            }
            shareStoryContent.contentName = str;
            Video video2 = aweme.getVideo();
            float f2 = 0.0f;
            if (video2 != null) {
                f = (float) video2.getWidth();
            } else {
                f = 0.0f;
            }
            shareStoryContent.width = f;
            Video video3 = aweme.getVideo();
            if (video3 != null) {
                f2 = (float) video3.getHeight();
            }
            shareStoryContent.height = f2;
            shareStoryContent.title = aweme.getDesc();
            Story story = aweme.getStory();
            if (story != null) {
                j = story.getExpiredAt();
            } else {
                j = 0;
            }
            shareStoryContent.setExpireAt(Long.valueOf(j));
            shareStoryContent.setSourceType(1);
            shareStoryContent.awemeType = 40;
            shareStoryContent.type = ShareStoryContent.Companion.getAweType(shareStoryContent.getSourceType());
            return shareStoryContent;
        }

        public final ShareStoryContent fromSharePackage(SharePackage sharePackage) {
            M12.LIZ(sharePackage);
            ShareStoryContent shareStoryContent = new ShareStoryContent();
            Bundle bundle = sharePackage.LJIILJJIL;
            shareStoryContent.user = bundle.getString("uid_for_share");
            shareStoryContent.secUid = bundle.getString("sec_user_id");
            shareStoryContent.itemId = bundle.getString("item_id_string");
            Serializable serializable = bundle.getSerializable("video_cover");
            UrlModel urlModel = null;
            if (!(serializable instanceof UrlModel)) {
                serializable = null;
            }
            shareStoryContent.coverUrl = (UrlModel) serializable;
            UrlModel serializable2 = bundle.getSerializable("thumb_for_share");
            if (serializable2 instanceof UrlModel) {
                urlModel = serializable2;
            }
            shareStoryContent.contentThumb = urlModel;
            shareStoryContent.contentName = bundle.getString("author_name");
            shareStoryContent.width = (float) bundle.getInt("aweme_width");
            shareStoryContent.height = (float) bundle.getInt("aweme_height");
            shareStoryContent.title = bundle.getString("desc");
            shareStoryContent.setExpireAt(Long.valueOf(bundle.getLong("expired_at", 0)));
            shareStoryContent.setSourceType(Integer.valueOf(bundle.getInt("source_type", 0)));
            shareStoryContent.awemeType = 40;
            shareStoryContent.type = ShareStoryContent.Companion.getAweType(shareStoryContent.getSourceType());
            return shareStoryContent;
        }
    }

    public final Long getExpireAt() {
        return this.expireAt;
    }

    public final Integer getSourceType() {
        return this.sourceType;
    }

    public final String getStoryCollectionId() {
        return this.storyCollectionId;
    }

    public ShareStoryContent() {
        this.awemeType = 40;
    }

    public final SharePackage generateSharePackage() {
        long j;
        SharePackage LIZ = PureDataSharePackage.LIZ.LIZ("story_video");
        Bundle bundle = LIZ.LJIILJJIL;
        bundle.putInt("aweme_type", getAwemeType());
        bundle.putString("item_id_string", this.itemId);
        bundle.putString("author_id", this.user);
        bundle.putString("author_name", this.contentName);
        bundle.putSerializable("video_cover", getCoverUrl());
        bundle.putSerializable("thumb_for_share", this.contentThumb);
        bundle.putString("desc", this.title);
        Long l = this.expireAt;
        if (l != null) {
            j = l.longValue();
        } else {
            j = 0;
        }
        bundle.putLong("expired_at", j);
        bundle.putInt("source_type", 3);
        bundle.putInt("aweme_height", (int) this.height);
        bundle.putInt("aweme_width", (int) this.width);
        bundle.putInt("aweme_type", this.type);
        return LIZ;
    }

    public final void setExpireAt(Long l) {
        this.expireAt = l;
    }

    public final void setSourceType(Integer num) {
        this.sourceType = num;
    }

    public final void setStoryCollectionId(String str) {
        M12.LIZ(str);
        this.storyCollectionId = str;
    }

    public final String getQuoteHint(Context context) {
        M12.LIZ(context);
        String string = context.getResources().getString(2131825942);
        n.LIZIZ(string, "");
        return string;
    }

    public final String wrapMsgHint(boolean z, boolean z2, String str) {
        String str2;
        if (!DwO.LIZ.LIZ()) {
            return super.wrapMsgHint(z, z2, str);
        }
        Context LIZ = 9EH.LJJIFFI.LIZ();
        if (z || z2) {
            str2 = LIZ.getString(2131835049);
        } else {
            str2 = LIZ.getString(2131835048);
        }
        ShareAwemeContent.awemeMsgHint = str2;
        return str2;
    }
}
