{%- import "util/forms.html" as forms -%}
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	{% include "analytics.html" %}
	<meta name="description" content="{{config('DESCRIPTION')}}">
		<script src="{{ 'js/bootstrap.js' | asset }}"></script>
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<meta name="author" content="">
		<link rel="icon" type="image/png" href="{{ ('images/'~SITE_ID~'/icon.webp') | asset }}">
		{% block title %}
		<title>Create a post - {{SITE_TITLE}}</title>
		{% endblock %}

		
		{% block stylesheets %}
		{% if v %}
			<style>:root{--primary:#{{v.themecolor}}}</style>
			<link rel="stylesheet" href="{{ 'css/main.css' | asset }}">
			<link rel="stylesheet" href="{{ ('css/'~v.theme~'.css') | asset }}">
			{% if v.css %}
				<style>{{v.css | safe}}</style>
			{% endif %}
		{% else %}
			<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
			<link rel="stylesheet" href="{{ 'css/main.css' | asset }}">
			<link rel="stylesheet" href="{{ ('css/'~config('DEFAULT_THEME')~'.css') | asset }}">
		{% endif %}
		{% endblock %}

<body id="submit">
{% include "header.html" %}
{% block form %}
		<div class="submit-grid-view">
			<form id="submitform" action="/submit" method="post" enctype="multipart/form-data" style="grid-column: 2">
				<div class="container">
						<div class="row justify-content-center mb-5">
								<div class="col p-3 py-md-0">
										<h2 class="mt-3">Create a post</h2>
										<div class="body">
												{{forms.formkey(v)}}
												<label class='mt-4' for="title">Post Title</label>

												<input autocomplete="off" class="form-control" id="post-title" aria-describedby="titleHelpRegister" type="text" name="title" placeholder="Required" value="{{title}}" minlength="1" maxlength="{{SUBMISSION_TITLE_LENGTH_MAXIMUM}}" required oninput="checkForRequired();savetext()">

												<div id="urlblock">
														<label for="URL" class="mt-3">URL</label>
														<input autocomplete="off" class="form-control" id="post-url" aria-describedby="URLHelp" name="url" type="url" placeholder="Optional if you have text." value="{{request.values.get('url','')}}" maxlength="2048" required oninput="checkForRequired();hide_image();savetext();checkRepost(this);autoSuggestTitle()">
														<small id="system" class="form-text text-muted">To post an image, use a direct image link such as i.imgur.com</small>
												</div>
												<div id="image-upload-block">
													<div><label class="mt-3">Attachment Upload</label></div>

													<img loading="lazy" id="image-preview" style="max-width:50%">
													<label class="btn btn-secondary m-0" for="file-upload">
														<div id="filename-show">Select File</div>
														<input autocomplete="off" id="file-upload" type="file" name="file" {% if request.headers.get('cf-ipcountry')=="T1" %}disabled{% endif %} accept="image/*" hidden>
													</label>
													<small class="form-text text-muted">Optional if you have text.</small>
													<small class="form-text text-muted">You can upload images or videos up to 60 seconds.</small>
												</div>
												</div>

												<label for="body" class="mt-3">Text<i class="fas fa-info-circle text-gray-400 ml-1" data-bs-toggle="tooltip" data-bs-placement="top" title="Uses markdown. Limited to {{SUBMISSION_BODY_LENGTH_MAXIMUM}} characters."></i></label>

												<div>
													<textarea form="submitform" id="post-text" class="form-control rounded" aria-label="With textarea" placeholder="Optional if you have a link or an image." rows="7" name="body" oninput="markdown('post-text','preview');charLimit('post-text','character-count-submit-text-form');checkForRequired();savetext()" maxlength="{{SUBMISSION_BODY_LENGTH_MAXIMUM}}" required></textarea>

													<div class="btn btn-secondary fl-r mt-3" onclick="document.getElementById('preview').classList.toggle('d-none');">
														Toggle preview
													</div>

													<div class="text-small font-weight-bold mt-1" id="character-count-submit-text-form" style="right: 1rem; bottom: 0.5rem; z-index: 3;"></div>

												</div>

												<p></p>
												<small class="btn btn-secondary format d-inline-block m-0" onclick="makeBold('post-text')" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Bold">
												<i class="fas fa-bold" aria-hidden="true"></i>
												</small>
												<small class="btn btn-secondary format d-inline-block m-0" onclick="makeItalics('post-text')" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Italicize">
												<i class="fas fa-italic" aria-hidden="true"></i>
												</small>
												<small class="btn btn-secondary format d-inline-block m-0" onclick="makeQuote('post-text')" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Quote">
												<i class="fas fa-quote-right" aria-hidden="true"></i>
												</small>
												<small class="btn btn-secondary format d-inline-block m-0" onclick="makeLink('post-text')" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Link">
													<i class="fas fa-link" aria-hidden="true"></i>
												</small>
												<label class="format btn btn-secondary m-0 {% if v %}d-inline-block{% else %}d-none{% endif %}" for="file-upload-submit">
													<div id="filename-show-submit"><i class="far fa-image"></i></div>
													<input autocomplete="off" id="file-upload-submit" multiple="multiple" type="file" name="file2" accept="image/*" {% if request.headers.get('cf-ipcountry')=="T1" %}disabled{% endif %} onchange="changename('filename-show-submit','file-upload-submit');checkForRequired()" hidden>
												</label>	

												<div id="preview" class="preview my-3"></div>

												<pre></pre>
												<div class="form-text text-small"><a href="/formatting" {% if v and v.newtab and not g.webview %}target="_blank"{% endif %}>Formatting help</a></div>
												<pre></pre>

												<div class="custom-control custom-checkbox">
														<input checked autocomplete="off" type="checkbox" class="custom-control-input" id="followers" name="followers">
														<label class="custom-control-label" for="followers">Notify followers</label>
												</div>

												<div class="custom-control custom-checkbox">
														<input autocomplete="off" type="checkbox" class="custom-control-input" id="nsfw" name="over_18">
														<label class="custom-control-label" for="nsfw">18+</label>
												</div>
												<div class="custom-control custom-checkbox">
														<input onchange='draft(this);' autocomplete="off" type="checkbox" class="custom-control-input" id="private" name="private">
														<label class="custom-control-label" for="private">Draft</label>
												</div>

												<pre>






												</pre>
										</div>
								</div>
						</div>
				<div class="container">
						<div class="row fixed-bottom bg-white border-top p-3" id="" style="z-index: 100; bottom: 0px; transition: bottom 220ms cubic-bezier(0, 0, 0.2, 1) 0s;">
								<div class="col">
										<a href="/" class="btn btn-secondary">Cancel</a>
								</div>
								<div class="col text-right">
										{% if error %}<span class="text-danger text-large mr-2">{{error}}</span>{% endif %}
										<button class="btn btn-primary" id="create_button" type="submit" disabled>Post</button>
								</div>
						</div>
				</div>
			</form>
		</div>
		{% endblock %}

		<script src="{{ 'js/vendor/purify.min.js' | asset }}"></script>
		<script src="{{ 'js/vendor/marked.min.js' | asset }}"></script>
		<script src="{{ 'js/marked.custom.js' | asset }}"></script>
		<script src="{{ 'js/formatting.js' | asset }}"></script>
		<script src="{{ 'js/submit.js' | asset }}"></script>
</body>
</html>
