function _ts_decorate(decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function _ts_metadata(k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
}
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from "typeorm";
import { id } from "../id.js";
import { User } from "./user.js";
import { DriveFolder } from "./drive-folder.js";
import { DB_MAX_IMAGE_COMMENT_LENGTH } from "../../misc/hard-limits.js";
export let DriveFile = class DriveFile {
    id;
    createdAt;
    userId;
    user;
    userHost;
    md5;
    name;
    type;
    size;
    comment;
    blurhash;
    properties;
    storedInternal;
    url;
    thumbnailUrl;
    webpublicUrl;
    webpublicType;
    accessKey;
    thumbnailAccessKey;
    webpublicAccessKey;
    uri;
    src;
    folderId;
    folder;
    isSensitive;
    allowDownload;
    isDatabase;
    /**
	 * 外部の(信頼されていない)URLへの直リンクか否か
	 */ isLink;
    requestHeaders;
    requestIp;
};
_ts_decorate([
    PrimaryColumn(id()),
    _ts_metadata("design:type", String)
], DriveFile.prototype, "id", void 0);
_ts_decorate([
    Index(),
    Column("timestamp with time zone", {
        comment: "The created date of the DriveFile."
    }),
    _ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
], DriveFile.prototype, "createdAt", void 0);
_ts_decorate([
    Index(),
    Column({
        ...id(),
        nullable: true,
        comment: "The owner ID."
    }),
    _ts_metadata("design:type", Object)
], DriveFile.prototype, "userId", void 0);
_ts_decorate([
    ManyToOne((type)=>User, {
        onDelete: "SET NULL"
    }),
    JoinColumn(),
    _ts_metadata("design:type", Object)
], DriveFile.prototype, "user", void 0);
_ts_decorate([
    Index(),
    Column("varchar", {
        length: 512,
        nullable: true,
        comment: "The host of owner. It will be null if the user in local."
    }),
    _ts_metadata("design:type", Object)
], DriveFile.prototype, "userHost", void 0);
_ts_decorate([
    Index(),
    Column("varchar", {
        length: 32,
        comment: "The MD5 hash of the DriveFile."
    }),
    _ts_metadata("design:type", String)
], DriveFile.prototype, "md5", void 0);
_ts_decorate([
    Column("varchar", {
        length: 256,
        comment: "The file name of the DriveFile."
    }),
    _ts_metadata("design:type", String)
], DriveFile.prototype, "name", void 0);
_ts_decorate([
    Index(),
    Column("varchar", {
        length: 128,
        comment: "The content type (MIME) of the DriveFile."
    }),
    _ts_metadata("design:type", String)
], DriveFile.prototype, "type", void 0);
_ts_decorate([
    Column("integer", {
        comment: "The file size (bytes) of the DriveFile."
    }),
    _ts_metadata("design:type", Number)
], DriveFile.prototype, "size", void 0);
_ts_decorate([
    Column("varchar", {
        length: DB_MAX_IMAGE_COMMENT_LENGTH,
        nullable: true,
        comment: "The comment of the DriveFile."
    }),
    _ts_metadata("design:type", Object)
], DriveFile.prototype, "comment", void 0);
_ts_decorate([
    Column("varchar", {
        length: 128,
        nullable: true,
        comment: "The BlurHash string."
    }),
    _ts_metadata("design:type", Object)
], DriveFile.prototype, "blurhash", void 0);
_ts_decorate([
    Column("jsonb", {
        default: {},
        comment: "The any properties of the DriveFile. For example, it includes image width/height."
    }),
    _ts_metadata("design:type", Object)
], DriveFile.prototype, "properties", void 0);
_ts_decorate([
    Column("boolean"),
    _ts_metadata("design:type", Boolean)
], DriveFile.prototype, "storedInternal", void 0);
_ts_decorate([
    Column("varchar", {
        length: 512,
        comment: "The URL of the DriveFile."
    }),
    _ts_metadata("design:type", String)
], DriveFile.prototype, "url", void 0);
_ts_decorate([
    Column("varchar", {
        length: 512,
        nullable: true,
        comment: "The URL of the thumbnail of the DriveFile."
    }),
    _ts_metadata("design:type", Object)
], DriveFile.prototype, "thumbnailUrl", void 0);
_ts_decorate([
    Column("varchar", {
        length: 512,
        nullable: true,
        comment: "The URL of the webpublic of the DriveFile."
    }),
    _ts_metadata("design:type", Object)
], DriveFile.prototype, "webpublicUrl", void 0);
_ts_decorate([
    Column("varchar", {
        length: 128,
        nullable: true
    }),
    _ts_metadata("design:type", Object)
], DriveFile.prototype, "webpublicType", void 0);
_ts_decorate([
    Index({
        unique: true
    }),
    Column("varchar", {
        length: 256,
        nullable: true
    }),
    _ts_metadata("design:type", Object)
], DriveFile.prototype, "accessKey", void 0);
_ts_decorate([
    Index({
        unique: true
    }),
    Column("varchar", {
        length: 256,
        nullable: true
    }),
    _ts_metadata("design:type", Object)
], DriveFile.prototype, "thumbnailAccessKey", void 0);
_ts_decorate([
    Index({
        unique: true
    }),
    Column("varchar", {
        length: 256,
        nullable: true
    }),
    _ts_metadata("design:type", Object)
], DriveFile.prototype, "webpublicAccessKey", void 0);
_ts_decorate([
    Index(),
    Column("varchar", {
        length: 512,
        nullable: true,
        comment: "The URI of the DriveFile. it will be null when the DriveFile is local."
    }),
    _ts_metadata("design:type", Object)
], DriveFile.prototype, "uri", void 0);
_ts_decorate([
    Column("varchar", {
        length: 512,
        nullable: true
    }),
    _ts_metadata("design:type", Object)
], DriveFile.prototype, "src", void 0);
_ts_decorate([
    Index(),
    Column({
        ...id(),
        nullable: true,
        comment: "The parent folder ID. If null, it means the DriveFile is located in root."
    }),
    _ts_metadata("design:type", Object)
], DriveFile.prototype, "folderId", void 0);
_ts_decorate([
    ManyToOne((type)=>DriveFolder, {
        onDelete: "SET NULL"
    }),
    JoinColumn(),
    _ts_metadata("design:type", Object)
], DriveFile.prototype, "folder", void 0);
_ts_decorate([
    Index(),
    Column("boolean", {
        default: false,
        comment: "Whether the DriveFile is NSFW."
    }),
    _ts_metadata("design:type", Boolean)
], DriveFile.prototype, "isSensitive", void 0);
_ts_decorate([
    Index(),
    Column("boolean", {
        default: true,
        comment: "Whether the DriveFile can be downloaded by users other than its owner."
    }),
    _ts_metadata("design:type", Boolean)
], DriveFile.prototype, "allowDownload", void 0);
_ts_decorate([
    Index(),
    Column("boolean", {
        default: false,
        comment: "Whether the DriveFile is a Lua4Frozen database file."
    }),
    _ts_metadata("design:type", Boolean)
], DriveFile.prototype, "isDatabase", void 0);
_ts_decorate([
    Index(),
    Column("boolean", {
        default: false,
        comment: "Whether the DriveFile is direct link to remote server."
    }),
    _ts_metadata("design:type", Boolean)
], DriveFile.prototype, "isLink", void 0);
_ts_decorate([
    Column("jsonb", {
        default: {},
        nullable: true
    }),
    _ts_metadata("design:type", Object)
], DriveFile.prototype, "requestHeaders", void 0);
_ts_decorate([
    Column("varchar", {
        length: 128,
        nullable: true
    }),
    _ts_metadata("design:type", Object)
], DriveFile.prototype, "requestIp", void 0);
DriveFile = _ts_decorate([
    Entity(),
    Index([
        "userId",
        "folderId",
        "id"
    ])
], DriveFile);
