// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.server.core.ui.browser;

import com.hypixel.hytale.server.core.ui.LocalizableString;
import java.nio.file.Path;
import java.util.function.Predicate;
import java.util.Set;
import java.util.List;
import javax.annotation.Nullable;
import javax.annotation.Nonnull;

record FileBrowserConfig(@Nonnull String listElementId, @Nullable String rootSelectorId, @Nullable String searchInputId, @Nullable String currentPathId, @Nonnull List<RootEntry> roots, @Nonnull Set<String> allowedExtensions, boolean enableRootSelector, boolean enableSearch, boolean enableDirectoryNav, boolean enableMultiSelect, int maxResults, @Nullable FileListProvider customProvider, boolean assetPackMode, @Nullable String assetPackSubPath, @Nullable Predicate<Path> terminalDirectoryPredicate) {
    public static Builder builder() {
        return new Builder();
    }
    
    @Nonnull
    public String listElementId() {
        return this.listElementId;
    }
    
    @Nullable
    public String rootSelectorId() {
        return this.rootSelectorId;
    }
    
    @Nullable
    public String searchInputId() {
        return this.searchInputId;
    }
    
    @Nullable
    public String currentPathId() {
        return this.currentPathId;
    }
    
    @Nonnull
    public List<RootEntry> roots() {
        return this.roots;
    }
    
    @Nonnull
    public Set<String> allowedExtensions() {
        return this.allowedExtensions;
    }
    
    @Nullable
    public FileListProvider customProvider() {
        return this.customProvider;
    }
    
    @Nullable
    public String assetPackSubPath() {
        return this.assetPackSubPath;
    }
    
    @Nullable
    public Predicate<Path> terminalDirectoryPredicate() {
        return this.terminalDirectoryPredicate;
    }
    
    record RootEntry(@Nonnull LocalizableString displayName, @Nonnull Path path) {
        public RootEntry(@Nonnull final String displayName, @Nonnull final Path path) {
            this(LocalizableString.fromString(displayName), path);
        }
        
        @Nonnull
        public LocalizableString displayName() {
            return this.displayName;
        }
        
        @Nonnull
        public Path path() {
            return this.path;
        }
    }
    
    public static class Builder
    {
        private String listElementId;
        private String rootSelectorId;
        private String searchInputId;
        private String currentPathId;
        private List<RootEntry> roots;
        private Set<String> allowedExtensions;
        private boolean enableRootSelector;
        private boolean enableSearch;
        private boolean enableDirectoryNav;
        private boolean enableMultiSelect;
        private int maxResults;
        private FileListProvider customProvider;
        private boolean assetPackMode;
        private String assetPackSubPath;
        private Predicate<Path> terminalDirectoryPredicate;
        
        public Builder() {
            this.listElementId = "#FileList";
            this.rootSelectorId = "#RootSelector";
            this.searchInputId = "#SearchInput";
            this.currentPathId = null;
            this.roots = List.of();
            this.allowedExtensions = Set.of();
            this.enableRootSelector = true;
            this.enableSearch = true;
            this.enableDirectoryNav = true;
            this.enableMultiSelect = false;
            this.maxResults = 50;
            this.customProvider = null;
            this.assetPackMode = false;
            this.assetPackSubPath = null;
            this.terminalDirectoryPredicate = null;
        }
        
        public Builder listElementId(@Nonnull final String listElementId) {
            this.listElementId = listElementId;
            return this;
        }
        
        public Builder rootSelectorId(@Nullable final String rootSelectorId) {
            this.rootSelectorId = rootSelectorId;
            return this;
        }
        
        public Builder searchInputId(@Nullable final String searchInputId) {
            this.searchInputId = searchInputId;
            return this;
        }
        
        public Builder currentPathId(@Nullable final String currentPathId) {
            this.currentPathId = currentPathId;
            return this;
        }
        
        public Builder roots(@Nonnull final List<RootEntry> roots) {
            this.roots = roots;
            return this;
        }
        
        public Builder allowedExtensions(@Nonnull final String... extensions) {
            this.allowedExtensions = Set.of(extensions);
            return this;
        }
        
        public Builder allowedExtensions(@Nonnull final Set<String> extensions) {
            this.allowedExtensions = extensions;
            return this;
        }
        
        public Builder enableRootSelector(final boolean enable) {
            this.enableRootSelector = enable;
            return this;
        }
        
        public Builder enableSearch(final boolean enable) {
            this.enableSearch = enable;
            return this;
        }
        
        public Builder enableDirectoryNav(final boolean enable) {
            this.enableDirectoryNav = enable;
            return this;
        }
        
        public Builder enableMultiSelect(final boolean enable) {
            this.enableMultiSelect = enable;
            return this;
        }
        
        public Builder maxResults(final int maxResults) {
            this.maxResults = maxResults;
            return this;
        }
        
        public Builder customProvider(@Nullable final FileListProvider provider) {
            this.customProvider = provider;
            return this;
        }
        
        public Builder assetPackMode(final boolean enable, @Nullable final String subPath) {
            if (enable && subPath == null) {
                throw new IllegalArgumentException("assetPackSubPath cannot be null when assetPackMode is enabled");
            }
            this.assetPackMode = enable;
            this.assetPackSubPath = subPath;
            return this;
        }
        
        public Builder terminalDirectoryPredicate(@Nullable final Predicate<Path> predicate) {
            this.terminalDirectoryPredicate = predicate;
            return this;
        }
        
        public FileBrowserConfig build() {
            return new FileBrowserConfig(this.listElementId, this.rootSelectorId, this.searchInputId, this.currentPathId, this.roots, this.allowedExtensions, this.enableRootSelector, this.enableSearch, this.enableDirectoryNav, this.enableMultiSelect, this.maxResults, this.customProvider, this.assetPackMode, this.assetPackSubPath, this.terminalDirectoryPredicate);
        }
    }
}
