diff --git a/app/Http/Controllers/Campaign/WebhookController.php b/app/Http/Controllers/Campaign/WebhookController.php index cf37f6504a..45d6a93a52 100644 --- a/app/Http/Controllers/Campaign/WebhookController.php +++ b/app/Http/Controllers/Campaign/WebhookController.php @@ -13,10 +13,6 @@ class WebhookController extends Controller { protected string $view = 'webhooks'; - /** - * Create a new controller instance. - * @return void - */ public function __construct() { $this->middleware('auth'); @@ -33,15 +29,13 @@ public function index(Campaign $campaign) $this->authorize('webhooks', $campaign); - $webhooks = $campaign->webhooks() + $rows = $campaign->webhooks() ->sort(request()->only(['o', 'k'])) //->with(['users', 'permissions', 'campaign']) ->orderBy('updated_at', 'DESC') //->orderBy('name') ->paginate(); - $rows = $webhooks; - // Ajax Datagrid if (request()->ajax()) { $html = view('layouts.datagrid._table')->with('rows', $rows)->with('campaign', $campaign)->render(); @@ -53,7 +47,7 @@ public function index(Campaign $campaign) ]); } - return view('campaigns.webhooks', compact('campaign', 'rows', 'webhooks')); + return view('campaigns.webhooks', compact('campaign', 'rows')); } /** @@ -75,8 +69,9 @@ public function store(StoreWebhook $request, Campaign $campaign) return response()->json(); } - $data = $request->all() + ['campaign_id' => $campaign->id]; - Webhook::create($data); + $new = new Webhook($request->all()); + $new->campaign_id = $campaign->id; + $new->save(); return redirect()->route('webhooks.index', $campaign) ->with('success', __('campaigns/webhooks.create.success')); @@ -106,21 +101,10 @@ public function destroy(Campaign $campaign, Webhook $webhook) $this->authorize('webhooks', $campaign); $webhook->delete(); - return redirect()->route('webhooks.index', $campaign) ->with('success', __('campaigns/webhooks.destroy.success')); } - public function status(Campaign $campaign, Webhook $webhook) - { - $this->authorize('webhooks', $campaign); - - return view('campaigns.webhooks.status', [ - 'campaign' => $campaign, - 'webhook' => $webhook, - ]); - } - /** * @return \Illuminate\Http\RedirectResponse * @throws \Illuminate\Auth\Access\AuthorizationException @@ -161,14 +145,10 @@ public function bulk(Campaign $campaign) if ($action === 'delete') { $webhook->delete(); $count++; - } - - if ($action === 'disable' && $webhook->status) { + } elseif ($action === 'disable' && $webhook->status) { $webhook->update(['status' => 0]); $count++; - } - - if ($action === 'enable' && !$webhook->status) { + } elseif ($action === 'enable' && !$webhook->status) { $webhook->update(['status' => 1]); $count++; } diff --git a/app/Jobs/EntityWebhookJob.php b/app/Jobs/EntityWebhookJob.php index ee06504d0d..1a9c206dc5 100644 --- a/app/Jobs/EntityWebhookJob.php +++ b/app/Jobs/EntityWebhookJob.php @@ -58,7 +58,7 @@ public function handle() return; } - $webhooks = Webhook::Active($this->campaign->id, $this->action)->with('tags')->get(); + $webhooks = Webhook::active($this->campaign->id, $this->action)->with('tags')->get(); $entityTags = $this->entity->tags()->pluck('tags.id')->all(); foreach ($webhooks as $webhook) { if ($this->isInvalid($webhook, $entityTags)) { diff --git a/app/Jobs/TestWebhookJob.php b/app/Jobs/TestWebhookJob.php index c936785dc9..4e4de4be4e 100644 --- a/app/Jobs/TestWebhookJob.php +++ b/app/Jobs/TestWebhookJob.php @@ -21,25 +21,13 @@ class TestWebhookJob implements ShouldQueue use Queueable; use SerializesModels; - /** - * @var int - */ - public $campaignId; + public int $campaignId; - /** - * @var int - */ - public $action; + public int $action; - /** - * @var string - */ - public $username; + public string $username; - /** - * @var Webhook - */ - public $webhook; + public Webhook $webhook; /** * The number of times the job may be attempted. @@ -70,10 +58,13 @@ public function __construct(Campaign $campaign, User $user, Webhook $webhook, in */ public function handle() { + /** @var Campaign|null $campaign */ + $campaign = Campaign::find($this->campaignId); + if ($this->webhook->type == 1) { $data = Str::replace( ['{name}', '{who}', '{url}'], - ['Thaelia', $this->username, route('locations.index', [$this->campaignId])], + ['Thaelia', $this->username, route('locations.index', [$campaign])], $this->webhook->message ); @@ -119,7 +110,7 @@ public function handle() 'title' => 'Thaelia', 'description' => strval($data), 'color' => config('discord.color'), - 'url' => route('locations.index', [$this->campaignId]), + 'url' => route('locations.index', [$campaign]), 'author' => [ 'name' => 'Kanka Webhooks', ], diff --git a/app/Models/Webhook.php b/app/Models/Webhook.php index f484c9b6ad..258a9bbb20 100644 --- a/app/Models/Webhook.php +++ b/app/Models/Webhook.php @@ -9,13 +9,16 @@ use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Relations\BelongsTo; use App\Facades\CampaignLocalization; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; /** * @property int $id * @property int $feature_id + * @property int $campaign_id + * @property int $status * @property string $path * @property Feature $feature - * @property \App\Enums\Webhook $status_id + * @property WebhookAction $action */ class Webhook extends Model { @@ -23,14 +26,11 @@ class Webhook extends Model use SortableTrait; public $fillable = [ - 'campaign_id', 'action', 'url', 'type', 'message', 'status', - 'created_by', - 'updated_by', ]; protected array $sortable = [ @@ -39,10 +39,7 @@ class Webhook extends Model 'action', ]; - /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany - */ - public function tags() + public function tags(): BelongsToMany { return $this->belongsToMany( 'App\Models\Tag', @@ -91,10 +88,11 @@ public function shortUrl(): string return $this->url; } - /** - */ public function scopeActive(Builder $query, int $campaignId, int $action): Builder { - return $query->where('campaign_id', $campaignId)->where('action', $action)->where('status', 1); + return $query + ->where('campaign_id', $campaignId) + ->where('action', $action) + ->where('status', 1); } } diff --git a/app/Renderers/Layouts/Campaign/Webhook.php b/app/Renderers/Layouts/Campaign/Webhook.php index 8200349675..4d00ab22c9 100644 --- a/app/Renderers/Layouts/Campaign/Webhook.php +++ b/app/Renderers/Layouts/Campaign/Webhook.php @@ -3,6 +3,7 @@ namespace App\Renderers\Layouts\Campaign; use App\Renderers\Layouts\Layout; +use Illuminate\Support\Str; class Webhook extends Layout { @@ -32,13 +33,17 @@ public function columns(): array 'label' => 'campaigns/webhooks.fields.message', 'render' => function ($model) { /** @var \App\Models\Webhook $model */ - return $model->message; + return '
' + . Str::limit(strip_tags($model->message ?? ''), 30) + . '
'; }, ], 'url' => [ 'label' => 'campaigns/webhooks.fields.url', 'render' => function ($model) { - return '
' . $model->shortUrl() . '
'; + return '
' + . $model->shortUrl() + . '
'; }, ], diff --git a/lang/en/campaigns/webhooks.php b/lang/en/campaigns/webhooks.php index a8c0dcba94..2cb1074750 100644 --- a/lang/en/campaigns/webhooks.php +++ b/lang/en/campaigns/webhooks.php @@ -3,9 +3,9 @@ return [ 'title' => 'Webhooks', 'destroy' => [ - 'success' => 'Webhook deleted succesfully', + 'success' => 'Webhook deleted successfully', ], - 'pitch' => 'Create custom webhooks to recieve custom updates whenever an entity from the campaign is updated.', + 'pitch' => 'Create custom webhooks to receive custom updates whenever an entity from the campaign is updated.', 'actions' => [ 'add' => 'Create webhook', 'update' => 'Update webhook', @@ -21,11 +21,11 @@ ], 'create' => [ 'title' => 'Add new webhook', - 'success' => 'Webhook created succesfully', + 'success' => 'Webhook created successfully', ], 'edit' => [ 'title' => 'Update webhook', - 'success' => 'Webhook updated succesfully', + 'success' => 'Webhook updated successfully', ], 'test' => [ 'success' => 'Test request sent', @@ -53,6 +53,6 @@ ], 'placeholders' => [ 'url' => 'Target webhook\'s url', - 'message' => 'Message to append to the webhook', + 'message' => '{who} made changes to {name}, check it out at {url}', ], ]; diff --git a/public/build/assets/app-5da4beae.js b/public/build/assets/app-5da4beae.js new file mode 100644 index 0000000000..1295c8a17f --- /dev/null +++ b/public/build/assets/app-5da4beae.js @@ -0,0 +1 @@ +import{t as U,C as W}from"./tippy.esm-24ef6cb2.js";import{d as tt}from"./mention-2d258b1d.js";import{S as De}from"./sortable.esm-0d19b1d3.js";import"./dialog-66bef5f6.js";import{_ as S,c as l,a,t as u,o as r,n as E,w as X,b as h,F as v,r as w,d as b,e as g,f as T,g as L,h as ee,i as nt,v as it,j as z,k as qe,l as st}from"./_plugin-vue_export-helper-0796b9c6.js";import{m as at}from"./mitt-f7ef348c.js";import{v as Ee}from"./v-click-outside.umd-1708c20a.js";import"./_commonjsHelpers-725317a4.js";$(document).ready(function(){window.initTags=function(){$.each($(".form-tags"),function(){$(this).hasClass("select2-hidden-accessible")||$(this).select2({tags:$(this).data("allow-new"),allowClear:$(this).data("allow-clear"),dropdownParent:$(this).data("dropdown-parent")||"",minimumInputLength:0,ajax:{quietMillis:500,delay:500,url:$(this).data("url"),dataType:"json",data:function(e){return{q:$.trim(e.term)}},processResults:function(e){return{results:e}},cache:!0},createTag:function(e){var t=$.trim(e.term);return t===""?null:{id:t,text:t,newTag:!0}},templateResult:function(e){var t=$(""+e.text+"");return e.colour&&(t=$(""+e.text+"")),t},templateSelection:function(e,t){if(e.newTag)return $(''+e.text+' ');let n=$(e.element);return e.colour?$(t).addClass(e.colour):n.data("colour")&&$(t).addClass(n.data("colour")),$(t).addClass("text-left"),e.text}})})},window.initTags()});/*! Select2 4.0.13 | https://github.com/select2/select2/blob/master/LICENSE.md */(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;e.define("select2/i18n/ca",[],function(){return{errorLoading:function(){return"La càrrega ha fallat"},inputTooLong:function(t){var n=t.input.length-t.maximum,s="Si us plau, elimina "+n+" car";return s+=n==1?"àcter":"àcters"},inputTooShort:function(t){var n=t.minimum-t.input.length,s="Si us plau, introdueix "+n+" car";return s+=n==1?"àcter":"àcters"},loadingMore:function(){return"Carregant més resultats…"},maximumSelected:function(t){var n="Només es pot seleccionar "+t.maximum+" element";return t.maximum!=1&&(n+="s"),n},noResults:function(){return"No s'han trobat resultats"},searching:function(){return"Cercant…"},removeAllItems:function(){return"Treu tots els elements"}}}),e.define,e.require})();/*! Select2 4.0.13 | https://github.com/select2/select2/blob/master/LICENSE.md */(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;e.define("select2/i18n/de",[],function(){return{errorLoading:function(){return"Die Ergebnisse konnten nicht geladen werden."},inputTooLong:function(t){return"Bitte "+(t.input.length-t.maximum)+" Zeichen weniger eingeben"},inputTooShort:function(t){return"Bitte "+(t.minimum-t.input.length)+" Zeichen mehr eingeben"},loadingMore:function(){return"Lade mehr Ergebnisse…"},maximumSelected:function(t){var n="Sie können nur "+t.maximum+" Element";return t.maximum!=1&&(n+="e"),n+=" auswählen"},noResults:function(){return"Keine Übereinstimmungen gefunden"},searching:function(){return"Suche…"},removeAllItems:function(){return"Entferne alle Elemente"}}}),e.define,e.require})();/*! Select2 4.0.13 | https://github.com/select2/select2/blob/master/LICENSE.md */(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;e.define("select2/i18n/en",[],function(){return{errorLoading:function(){return"The results could not be loaded."},inputTooLong:function(t){var n=t.input.length-t.maximum,s="Please delete "+n+" character";return n!=1&&(s+="s"),s},inputTooShort:function(t){return"Please enter "+(t.minimum-t.input.length)+" or more characters"},loadingMore:function(){return"Loading more results…"},maximumSelected:function(t){var n="You can only select "+t.maximum+" item";return t.maximum!=1&&(n+="s"),n},noResults:function(){return"No results found"},searching:function(){return"Searching…"},removeAllItems:function(){return"Remove all items"}}}),e.define,e.require})();/*! Select2 4.0.13 | https://github.com/select2/select2/blob/master/LICENSE.md */(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;e.define("select2/i18n/es",[],function(){return{errorLoading:function(){return"No se pudieron cargar los resultados"},inputTooLong:function(t){var n=t.input.length-t.maximum,s="Por favor, elimine "+n+" car";return s+=n==1?"ácter":"acteres"},inputTooShort:function(t){var n=t.minimum-t.input.length,s="Por favor, introduzca "+n+" car";return s+=n==1?"ácter":"acteres"},loadingMore:function(){return"Cargando más resultados…"},maximumSelected:function(t){var n="Sólo puede seleccionar "+t.maximum+" elemento";return t.maximum!=1&&(n+="s"),n},noResults:function(){return"No se encontraron resultados"},searching:function(){return"Buscando…"},removeAllItems:function(){return"Eliminar todos los elementos"}}}),e.define,e.require})();/*! Select2 4.0.13 | https://github.com/select2/select2/blob/master/LICENSE.md */(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;e.define("select2/i18n/fr",[],function(){return{errorLoading:function(){return"Les résultats ne peuvent pas être chargés."},inputTooLong:function(t){var n=t.input.length-t.maximum;return"Supprimez "+n+" caractère"+(n>1?"s":"")},inputTooShort:function(t){var n=t.minimum-t.input.length;return"Saisissez au moins "+n+" caractère"+(n>1?"s":"")},loadingMore:function(){return"Chargement de résultats supplémentaires…"},maximumSelected:function(t){return"Vous pouvez seulement sélectionner "+t.maximum+" élément"+(t.maximum>1?"s":"")},noResults:function(){return"Aucun résultat trouvé"},searching:function(){return"Recherche en cours…"},removeAllItems:function(){return"Supprimer tous les éléments"}}}),e.define,e.require})();/*! Select2 4.0.13 | https://github.com/select2/select2/blob/master/LICENSE.md */(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;e.define("select2/i18n/hu",[],function(){return{errorLoading:function(){return"Az eredmények betöltése nem sikerült."},inputTooLong:function(t){return"Túl hosszú. "+(t.input.length-t.maximum)+" karakterrel több, mint kellene."},inputTooShort:function(t){return"Túl rövid. Még "+(t.minimum-t.input.length)+" karakter hiányzik."},loadingMore:function(){return"Töltés…"},maximumSelected:function(t){return"Csak "+t.maximum+" elemet lehet kiválasztani."},noResults:function(){return"Nincs találat."},searching:function(){return"Keresés…"},removeAllItems:function(){return"Távolítson el minden elemet"}}}),e.define,e.require})();/*! Select2 4.0.13 | https://github.com/select2/select2/blob/master/LICENSE.md */(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;e.define("select2/i18n/it",[],function(){return{errorLoading:function(){return"I risultati non possono essere caricati."},inputTooLong:function(t){var n=t.input.length-t.maximum,s="Per favore cancella "+n+" caratter";return s+=n!==1?"i":"e"},inputTooShort:function(t){return"Per favore inserisci "+(t.minimum-t.input.length)+" o più caratteri"},loadingMore:function(){return"Caricando più risultati…"},maximumSelected:function(t){var n="Puoi selezionare solo "+t.maximum+" element";return t.maximum!==1?n+="i":n+="o",n},noResults:function(){return"Nessun risultato trovato"},searching:function(){return"Sto cercando…"},removeAllItems:function(){return"Rimuovi tutti gli oggetti"}}}),e.define,e.require})();/*! Select2 4.0.13 | https://github.com/select2/select2/blob/master/LICENSE.md */(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;e.define("select2/i18n/nl",[],function(){return{errorLoading:function(){return"De resultaten konden niet worden geladen."},inputTooLong:function(t){return"Gelieve "+(t.input.length-t.maximum)+" karakters te verwijderen"},inputTooShort:function(t){return"Gelieve "+(t.minimum-t.input.length)+" of meer karakters in te voeren"},loadingMore:function(){return"Meer resultaten laden…"},maximumSelected:function(t){var n=t.maximum==1?"kan":"kunnen",s="Er "+n+" maar "+t.maximum+" item";return t.maximum!=1&&(s+="s"),s+=" worden geselecteerd"},noResults:function(){return"Geen resultaten gevonden…"},searching:function(){return"Zoeken…"},removeAllItems:function(){return"Verwijder alle items"}}}),e.define,e.require})();/*! Select2 4.0.13 | https://github.com/select2/select2/blob/master/LICENSE.md */(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;e.define("select2/i18n/pl",[],function(){var t=["znak","znaki","znaków"],n=["element","elementy","elementów"],s=function(i,o){return i===1?o[0]:i>1&&i<=4?o[1]:i>=5?o[2]:void 0};return{errorLoading:function(){return"Nie można załadować wyników."},inputTooLong:function(i){var o=i.input.length-i.maximum;return"Usuń "+o+" "+s(o,t)},inputTooShort:function(i){var o=i.minimum-i.input.length;return"Podaj przynajmniej "+o+" "+s(o,t)},loadingMore:function(){return"Trwa ładowanie…"},maximumSelected:function(i){return"Możesz zaznaczyć tylko "+i.maximum+" "+s(i.maximum,n)},noResults:function(){return"Brak wyników"},searching:function(){return"Trwa wyszukiwanie…"},removeAllItems:function(){return"Usuń wszystkie przedmioty"}}}),e.define,e.require})();/*! Select2 4.0.13 | https://github.com/select2/select2/blob/master/LICENSE.md */(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;e.define("select2/i18n/pt-BR",[],function(){return{errorLoading:function(){return"Os resultados não puderam ser carregados."},inputTooLong:function(t){var n=t.input.length-t.maximum,s="Apague "+n+" caracter";return n!=1&&(s+="es"),s},inputTooShort:function(t){return"Digite "+(t.minimum-t.input.length)+" ou mais caracteres"},loadingMore:function(){return"Carregando mais resultados…"},maximumSelected:function(t){var n="Você só pode selecionar "+t.maximum+" ite";return t.maximum==1?n+="m":n+="ns",n},noResults:function(){return"Nenhum resultado encontrado"},searching:function(){return"Buscando…"},removeAllItems:function(){return"Remover todos os itens"}}}),e.define,e.require})();/*! Select2 4.0.13 | https://github.com/select2/select2/blob/master/LICENSE.md */(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;e.define("select2/i18n/ru",[],function(){function t(n,s,i,o){return n%10<5&&n%10>0&&n%100<5||n%100>20?n%10>1?i:s:o}return{errorLoading:function(){return"Невозможно загрузить результаты"},inputTooLong:function(n){var s=n.input.length-n.maximum,i="Пожалуйста, введите на "+s+" символ";return i+=t(s,"","a","ов"),i+=" меньше"},inputTooShort:function(n){var s=n.minimum-n.input.length,i="Пожалуйста, введите ещё хотя бы "+s+" символ";return i+=t(s,"","a","ов")},loadingMore:function(){return"Загрузка данных…"},maximumSelected:function(n){var s="Вы можете выбрать не более "+n.maximum+" элемент";return s+=t(n.maximum,"","a","ов")},noResults:function(){return"Совпадений не найдено"},searching:function(){return"Поиск…"},removeAllItems:function(){return"Удалить все элементы"}}}),e.define,e.require})();/*! Select2 4.0.13 | https://github.com/select2/select2/blob/master/LICENSE.md */(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;e.define("select2/i18n/sk",[],function(){var t={2:function(n){return n?"dva":"dve"},3:function(){return"tri"},4:function(){return"štyri"}};return{errorLoading:function(){return"Výsledky sa nepodarilo načítať."},inputTooLong:function(n){var s=n.input.length-n.maximum;return s==1?"Prosím, zadajte o jeden znak menej":s>=2&&s<=4?"Prosím, zadajte o "+t[s](!0)+" znaky menej":"Prosím, zadajte o "+s+" znakov menej"},inputTooShort:function(n){var s=n.minimum-n.input.length;return s==1?"Prosím, zadajte ešte jeden znak":s<=4?"Prosím, zadajte ešte ďalšie "+t[s](!0)+" znaky":"Prosím, zadajte ešte ďalších "+s+" znakov"},loadingMore:function(){return"Načítanie ďalších výsledkov…"},maximumSelected:function(n){return n.maximum==1?"Môžete zvoliť len jednu položku":n.maximum>=2&&n.maximum<=4?"Môžete zvoliť najviac "+t[n.maximum](!1)+" položky":"Môžete zvoliť najviac "+n.maximum+" položiek"},noResults:function(){return"Nenašli sa žiadne položky"},searching:function(){return"Vyhľadávanie…"},removeAllItems:function(){return"Odstráňte všetky položky"}}}),e.define,e.require})();$(document).ready(function(){window.initForeignSelect=function(){$("select.select2").length!==0&&($.each($("select.select2"),function(e){if($(this).hasClass("select2-hidden-accessible"))return;if($(this).hasClass("campaign-genres")){$(this).select2({tags:!1,allowClear:!0,dropdownParent:"",width:"100%",maximumSelectionLength:3});return}let t=$(this).data("allow-clear"),n=$(this).data("dropdown-parent");$(this).select2({tags:!1,placeholder:$(this).data("placeholder"),allowClear:t||!0,language:$(this).data("language"),minimumInputLength:0,dropdownParent:n||"",width:"100%",ajax:{delay:500,quietMillis:500,url:$(this).data("url"),dataType:"json",data:function(s){return{q:$.trim(s.term)}},processResults:function(s){return{results:s}},error:function(s){return console.log("error",s),s.status===503&&window.showToast(s.responseJSON.message,"error"),{results:[]}},cache:!0},templateResult:function(s){var i="";return s.image?i=$(""+s.text+""):i=$(""+s.text+""),i},createTag:function(s){return null}})}),$("select.select2-local").select2({placeholder:$(this).data("placeholder"),language:$(this).data("language"),allowClear:!0}),$("select.select2-colour").select2({allowClear:!1,templateResult:pe,templateSelection:pe}))}});function pe(e){return e.id==="none"?e.text:$('
'+e.text+"
")}$(document).ready(function(){$.each($("form"),function(){$(this).data("shortcut")&&rt(this)}),ot(),ge(),$(document).on("shown.bs.modal",()=>{ge()})});function ot(){$(document).bind("keydown",function(e){let t=$(e.target),n=$("#entity-modal"),s=$(".quick-creator-button"),i=$('[data-keyboard="edit"]');if(e.key==="]"){if(H(t))return;$(".sidebar-toggle").click().blur()}else{if(e.key==="k")return H(t)?void 0:($("#entity-lookup").focus(),!1);if(e.key==="n"&&!(e.ctrlKey||e.metaKey)&&!e.altKey&&s.length>0){if(H(t)||(n.data("bs.modal")||{}).isShown)return;s[0].click()}else if(e.key==="e"&&!(e.ctrlKey||e.metaKey)&&i.length===1){if(H(t)||(n.data("bs.modal")||{}).isShown)return;i[0].click()}else e.key==="Escape"&&n.has(".qq-modal-selection").length===1&&n.modal("hide")}})}function H(e){return e.length===0?!1:e.is("input")||e.is("select")||e.is("textarea")||e.attr("contentEditable")==="true"||e.hasClass("CodeMirror")}function rt(e){$(document).bind("keydown",function(t){if((t.ctrlKey||t.metaKey)&&t.key.toLowerCase()==="s")return window.entityFormHasUnsavedChanges=!1,t.shiftKey?J("submit-update"):t.altKey&&J("submit-new"),$(e).submit(),!1;if((t.ctrlKey||t.metaKey)&&t.altKey&&t.key==="c")return window.entityFormHasUnsavedChanges=!1,J("submit-copy"),$(e).submit(),!1})}function J(e){let t=$("#form-submit-main");t&&(t.attr("name",e),$("#submit-mode").attr("name",e))}const ge=()=>{$('input[data-paste="fontawesome"]').on("paste",function(e){e.preventDefault();let t;if(e.clipboardData||e.originalEvent.clipboardData?t=(e.originalEvent||e).clipboardData.getData("text/plain"):window.clipboardData&&(t=window.clipboardData.getData("Text")),t.startsWith('i.json()).then(i=>{s.innerHTML="",i.forEach(o=>{let c=document.createElement("a");c.href=o.url,c.text=o.name,s.append(c)}),i.length>0&&t.show()})})}function Me(){if(P=$(".form-submit-actions"),P.length===0)return;let e=$("#form-submit-main"),t=$("#submit-mode");if(t===void 0)throw new Error("No submit mode hidden input found");$.each(P,function(){$(this).data("loaded")!==1&&($(this).data("loaded",1),$(this).unbind("click").on("click",function(){return t.attr("name",$(this).data("action")),e.trigger("click"),!1}))})}function dt(){$.each($("form"),function(){$(this).on("submit",function(){window.entityFormHasUnsavedChanges=!1;var e=$(this).find(".btn-primary");return e.length>0&&($.each(e,function(){$(this).parent().hasClass("dropdown")||$(this).hasClass("quick-creator-subform")?$(this).prop("disabled",!0):$(this).prop("disabled",!0).addClass("loading")}),$(this).append('')),!0})})}function ut(){q=$("#entity-calendar-form-add"),y=$('select[name="calendar_id"]'),G=$('input[name="calendar_id"]'),$(".entity-calendar-modal-form"),j=$(".entity-calendar-subform"),A=$("#entity-calendar-form-cancel"),te=$(".entity-calendar-form"),k=$('input[name="calendar_year"]'),C=$('select[name="calendar_month"]'),x=$('select[name="calendar_day"]'),N=$(".entity-calendar-loading"),q.length===1&&(q.on("click",function(e){e.preventDefault(),q.hide(),te.show();let t=$(this).data("default-calendar");return t&&(G.val(t),A.show(),j.show(),B(t)),!1}),A.on("click",function(e){e.preventDefault(),y.val(null),G.val(null),A.hide(),ne()})),y.length===1&&y.on("change",function(){if(j.hide(),!$(this).val())return ne(),!1;k=$('input[name="calendar_year"]'),C=$('select[name="calendar_month"]'),x=$('select[name="calendar_day"]'),k.length===0&&$('input[name="year"]').length===1&&(k=$('input[name="year"]'),C=$('select[name="month"]'),x=$('input[name="day"]')),B(y.val())}),_t()}function Ae(){$("#entity-calendar-modal-add").length!==0&&(q=$("input[name=calendar-data-url]"),y=$('select[name="calendar_id"]'),k=$('input[name="year"]'),C=$('select[name="month"]'),x=$('input[name="day"]'),N=$(".entity-calendar-loading"),j=$(".entity-calendar-subform"),y.on("change",function(){if(j.hide(),!y.val()){ne();return}B(y.val())}),y.val()&&(A.show(),j.show(),B(y.val())),$('.entity-calendar-subform input[name="length"]').focusout(function(){if(!$(this).val())return;let e=$(this).data("url").replace("/0/","/"+y.val()+"/"),t={day:x.val(),month:C.val(),year:k.val(),length:$(this).val()};$.ajax(e,{data:t}).done(function(n){n.overflow==!0?$(".length-warning").show():$(".length-warning").hide()})}))}const B=e=>{N.show(),e=parseInt(e);var t=$('input[name="calendar-data-url"]').data("url").replace("/0/","/"+e+"/");fetch(t).then(n=>n.json()).then(n=>{let s=x.val();k.html(""),C.html(""),x.html("");let i=1,o=1;s||(s=n.current.day);let c=parseInt(n.current.month);$.each(n.months,function(d){let m=n.months[d],f=i===c?' selected="selected"':"";C.append('"),i===c&&(o=m.length),i++});for(let d=1;d"+d+"")}N.hide(),j.show(),k.val(n.current.year),$("select.reminder-periodicity option").remove(),$.each(n.recurring,function(d,m){$("select.reminder-periodicity").append('")}),$('input[name="length"]').val(1),n.length===1&&C.val(n[0].id)})};function ne(){te.hide(),q.show(),$('input[name="calendar_day"]').val(null),$('input[name="calendar_month"]').val(null),$('input[name="calendar_year"]').val(null),$('select[name="calendar_id"]').val(null)}function ft(){if(P=$('form[data-unload="1"]'),P.length===0)return;let e=$("#form-submit-main");$(document).on("change",":input",function(){$(this).data("skip-unsaved")||(window.entityFormHasUnsavedChanges=!0)}),e.length===1&&$(window).bind("beforeunload",function(t){if(window.entityFormHasUnsavedChanges)return"Unsaved data warning"})}function Ie(){$('form[data-maintenance="1"]').each(function(){$(this).data("with-maintenance")!==!0&&($(this).data("with-maintenance",!0),$(this).submit(function(e){if($(this).data("checked-maintenance")===!0)return!0;e.preventDefault();let t={url:$(this).attr("action"),method:$(this).attr("method"),data:$(this).serialize(),context:this};if($(this).find('input[type="file"]').not(".note-image-input").length>0){let n=new FormData(this);t={url:$(this).attr("action"),method:$(this).attr("method"),data:n,cache:!1,contentType:!1,processData:!1,context:this}}$.ajax(t).done(function(){$(this).data("checked-maintenance",!0).submit()}).fail(function(n){window.formErrorHandler(n,this)})}))})}function ht(){$(".permission-toggle").change(function(){let t="input[data-action="+$(this).data("action")+"]";$(this).prop("checked")?$(t).prop("checked",!0):$(t).prop("checked",!1)})}function Pe(){$(".btn-post-collapse").unbind("click").click(function(){return document.querySelectorAll(".element-toggle").forEach(t=>{t.classList.add("animate-collapsed"),document.querySelector(t.dataset.target).classList.add("hidden")}),!1}),$(".btn-post-expand").unbind("click").click(function(){return document.querySelectorAll(".element-toggle").forEach(t=>{t.classList.remove("animate-collapsed"),document.querySelector(t.dataset.target).classList.remove("hidden")}),!1})}function Qe(){$(".story-load-more").click(function(e){e.preventDefault();let t=$(this);return $(this).addClass("loading"),mt($(this).data("url")).then(n=>{t.parent().remove(),$(".entity-posts").append(n),Qe(),Pe(),$(document).trigger("shown.bs.modal")}).catch(()=>{t.removeClass("loading")}),!1})}async function mt(e){return await(await fetch(e)).text()}function pt(){$(".domain-trust").click(function(){let e="kanka_trusted_domains",t=document.cookie.match("(^|;) ?"+e+"=([^;]*)(;|$)");t=t?t[2]:"";let n=$(this).data("domain");t.includes(n)||(t&&(t+="|"),t+=n);let s=new Date;s.setTime(s.getTime()+30*24*60*60*1e3),document.cookie=e+"="+t+";expires="+s.toUTCString()+";sameSite=Strict"})}function gt(){$(".dynamic-row-add").on("click",function(e){e.preventDefault();let t=$(this).data("target"),n=$(this).data("template");return $("."+t).append('
'+$("#"+n).html()+"
"),ve(),$(document).trigger("shown.bs.modal"),!1}),ve()}function ve(){$.each($(".dynamic-row-delete"),function(){$(this).data("init")!==1&&$(this).data("init",1).on("click",function(e){e.preventDefault(),$(this).closest(".parent-delete-row").remove()}).on("keydown",function(e){e.key==="Enter"&&$(this).click()})})}function vt(){$('input[data-toggle="entity-privacy"]').change(function(){let e=$("#entity-is-private");$(this).prop("checked")?e.show():e.hide()})}function _t(){$('select[name="calendar_month"]').change(function(){let e=$(this).find(":selected").data("length");yt(e)})}function yt(e){let t=x.val();t>e&&(t=e),x.html("");for(let n=1;n<=e;n++){let s=n==t?' selected="selected"':"";x.append('")}}var ie;$(document).ready(function(){_e(),$(document).on("shown.bs.modal shown.bs.popover",function(){_e()}),ie=$(".post-perm-add"),ie.length!==0&&(wt(),He())});function wt(){ie.on("click",function(e){e.preventDefault();let t=$(this).data("type"),n=$('select[name="'+t+'"]');if(!n||!n.val())return!1;let s=n.find(":selected")[0],i=$("#post-perm-"+t+"-template").clone().removeClass("hidden").removeAttr("id"),o=i.html().replace(/\$SELECTEDID\$/g,n.val()).replace(/\$SELECTEDNAME\$/g,s.text);return i.html(o).insertBefore($("#post-perm-target")),document.getElementById("post-new-"+t).close(),He(),n.val("").trigger("change"),!1})}function He(){$.each($(".post-delete-perm"),function(){$(this).unbind("click"),$(this).on("click",function(){$(this).closest(".grid").remove()})})}const _e=()=>{$("form.post-visibility").on("submit",function(e){return e.preventDefault(),$.post({url:$(this).attr("action"),data:{visibility_id:$(this).find('[name="visibility_id"]').val()}}).done(function(t){document.getElementById("primary-dialog").close(),$("#visibility-icon-"+t.post_id).html(t.icon),window.showToast(t.toast)}),!1})};var ye;$(document).ready(function(){ye=$("#calendar-year-switcher"),ye.length===1&&($("#calendar-year-switcher-field"),$("#add-calendar-event"),bt()),$(document).on("shown.bs.modal",function(){we()}),$('select[name="recurring_periodicity"]').length===1&&we(),xt()});function bt(){$(".calendar-event-block").each(function(){$(this).data("toggle")!=="dialog"&&$(this).data("url")&&$(this).click(function(){window.location=$(this).data("url")})})}function we(){$('select[name="recurring_periodicity"]').change(function(){this.value?$(".field-recurring-until").show():$(".field-recurring-until").hide()}),$("#calendar-action-existing").click(function(e){e.preventDefault(),$("#calendar-event-first").hide(),$(".calendar-new-event-field").hide(),$("#calendar-event-subform").fadeToggle(),$("#calendar-event-submit").toggle()}),$("#calendar-action-new").click(function(e){e.preventDefault(),$("#calendar-event-first").hide(),$(".calendar-existing-event-field").hide(),$("#calendar-event-subform").fadeToggle(),$("#calendar-event-submit").toggle()}),$("#calendar-event-switch").click(function(e){e.preventDefault(),$("#calendar-event-subform").hide(),$("#calendar-event-first").fadeToggle(),$(".calendar-existing-event-field").show(),$(".calendar-new-event-field").show(),$("#calendar-event-submit").toggle()})}function xt(){$('[data-shortcut="previous"]').length!==0&&$(document).bind("keydown",function(e){(e.ctrlKey||e.metaKey)&&e.which===37?$('[data-shortcut="previous"]').addClass("loading")[0].click():(e.ctrlKey||e.metaKey)&&e.which===39&&$('[data-shortcut="next"]').addClass("loading")[0].click()})}const ze=document.querySelector("dialog#edit-warning"),se=300*1e3;let Fe,ae=!0;$(document).ready(function(){if(!ze)return;let e=document.querySelector('input[name="edit-warning"]');window.openDialog("edit-warning",e.dataset.url),$(document).on("shown.bs.modal",function(){kt()}),$t()});function kt(){ae=!1,$("#entity-edit-warning-ignore").click(function(e){e.preventDefault(),ae=!0,$.ajax({url:$(this).data("url"),type:"POST",context:this}).done(function(){ze.close()})})}function $t(){let e=$("#editing-keep-alive");e.length!==0&&(Fe=e.data("url"),setTimeout(oe,se))}function oe(){if(!ae){setTimeout(oe,se);return}$.ajax({url:Fe,type:"POST"}).done(function(){setTimeout(oe,se)})}var M;let re,be,O;$(document).ready(function(){$(document).on("shown.bs.modal shown.bs.popover",function(){V()}),$(".quick-creator-subform").click(function(){$(document).on("shown.bs.modal",function(){fe()}),window.openDialog("primary-dialog",$(this).data("url"))})});function V(){re=$("#qq-modal-loading"),be=$("#qq-modal-selection"),O=$("#qq-modal-form"),$('[data-toggle="entity-creator"]').unbind("click").click(function(e){return e.preventDefault(),$(this).data("type")==="inline"?($(".quick-creator-body").hide(),$(".quick-creator-footer").hide(),$(".quick-creator-loading").show()):Re(),$.ajax({url:$(this).data("url"),context:this}).done(function(n){re.hide(),be.hide(),O.show().html(n),fe(),he(),$(document).trigger("shown.bs.modal")}),!1})}function Ne(){$("#qq-name-field").unbind("focusout").focusout(function(){$(this).val()&&($(this).parent().parent().find(".duplicate-entity-warning").hide(),$.ajax({url:$(this).data("live")+"?q="+$(this).val()+"&type="+$(this).data("type"),context:this}).done(function(e){if(e.length>0){let t=Object.keys(e).map(function(n){return''+e[n].name+""}).join(", ");$(this).parent().parent().find(".duplicate-entities").html(t),$(this).parent().parent().find(".duplicate-entity-warning").show()}else $(this).parent().parent().find(".duplicate-entity-warning").hide()}))})}function Re(){$("#qq-modal-form").hide(),$("#qq-modal-selection").hide(),$("#qq-modal-loading").show()}function fe(){M=$(".quick-creator-submit"),M.length!==0&&(Ne(),Be(),he(),M.on("click",function(e){let t=$(this).data("action");return t&&$('#entity-creator-form [name="action"]').val(t),!0}),$("#entity-creator-form").submit(function(e){e.preventDefault(),M.prop("disabled",!0).find("span").hide().parent().find("i.fa-spin").show(),$("div.text-error").remove(),$.post({url:$(this).attr("action"),data:$(this).serialize(),context:this}).done(function(t){if(typeof t=="object"){if(t.redirect){window.location.replace(t.redirect);return}let s=new Option(t._name,t._id),i=$("#"+t._target);if(t._multi){let c=i.val();c.push(t._id),i.append(s).val(c)}else i.children().remove().end().append(s).val(t._id);i.trigger("change"),$("#qq-modal-form").html("").show(),$("#qq-modal-loading").hide(),$("#qq-modal-selection").show(),document.getElementById("primary-dialog").close(),le();return}let n=document.getElementById("qq-modal-form");n.innerHTML=t,V(),le()}).fail(function(t){if(t.responseJSON.errors){let n=t.responseJSON.errors;Object.keys(n).forEach(function(c){let d=$('#entity-creator-form [name="'+c+'"]');d.length>0&&d.addClass("input-error").parent().append('
'+n[c][0]+"
")});let i=Object.keys(n)[0],o=$('#entity-creator-form input[name="'+i+'"]');if(o[0]){o[0].scrollIntoView({behavior:"smooth"}),$(".tab-content .active").removeClass("active"),$(".nav-tabs li.active").removeClass("active");let c=$('[name="'+i+'"').closest(".tab-pane");c.addClass("active"),$('a[href="#'+c.attr("id")+'"]').closest("li").addClass("active")}}M.prop("disabled",!1).find("i.fa-spin").hide().parent().find("span").show(),$('#entity-creator-form [name="action"]').val("")})}))}function Be(){$("#entity-creator-back").click(function(e){e.preventDefault(),Re(),$.ajax({url:$(this).data("url"),context:this}).done(function(t){$(this).data("target"),O.html(t).show(),re.hide(),V()})})}function he(){$(".qq-mode-toggle").unbind("click").on("click",function(e){e.preventDefault(),!$(this).hasClass("active")&&($(".qq-mode-toggle").removeClass("active"),$(this).addClass("active"),$(".quick-creator-body").hide(),$(".quick-creator-footer").hide(),$(".quick-creator-loading").show(),$.ajax({url:$(this).data("url")}).done(function(t){O.html(t).show(),le(),$(document).trigger("shown.bs.modal")}))}),$(".qq-action-more").unbind("click").on("click",function(e){e.preventDefault(),$(this).hide(),$(".qq-more-fields").show()}),V()}function le(){he(),Ne(),Be(),fe()}var D,I,Ct=new IntersectionObserver(function(e){e[0].isIntersecting===!0&&de($(".datagrid-onload"))},{threshold:[0]});$(document).ready(function(){Oe(),ce(),K(),Tt(),$(document).on("shown.bs.modal",function(){ce(),me()})});function ce(){$("[data-bulk-action]").unbind("click").on("click",function(){St($(this).data("bulk-action"))}),$(".bulk-print").unbind("click").on("click",function(e){e.preventDefault();let t=$(this).closest("form");t.find(),t.submit()})}function Oe(){var e=$("#datagrid-select-all");e.length>0&&e.unbind("click").click(function(){$(this).prop("checked")?$.each($("input[name='model[]']"),function(){$(this).prop("checked",!0)}):$.each($("input[name='model[]']"),function(){$(this).prop("checked",!1)}),K()}),$.each($("input[name='model[]']"),function(){$(this).change(function(t){K(),t.preventDefault()})})}function St(e){var t=[];$.each($("input[name='model[]']"),function(){$(this).prop("checked")&&t.push($(this).val())}),e==="ajax"?$(document).on("shown.bs.modal",function(){$("#primary-dialog").find('input[name="models"]').val(t.toString())}):$("#datagrid-bulk-"+e+"-models").val(t.toString())}function K(){var e=!0;$.each($("input[name='model[]']"),function(){$(this).prop("checked")&&(e=!1)}),e?$(".datagrid-bulk-actions .btn2").prop("disabled",!0).addClass("btn-disabled"):$(".datagrid-bulk-actions .btn2").prop("disabled",!1).removeClass("btn-disabled").removeClass("disabled")}function Tt(){me(),Ke(),Lt(),K()}function me(){$(".datagrid-bulk").unbind("click").click(function(e){e.preventDefault(),D=$(this).closest("form");let t=[];$.each($("input[name='model[]']"),function(){$(this).prop("checked")&&t.push($(this).val())}),$.ajax({url:D.attr("action")+"?action=edit",method:"POST",data:{model:t}}).done(function(n){let s=document.getElementById("primary-dialog");s.innerHTML=n,window.openDialog("primary-dialog"),$(document).trigger("shown.bs.modal")})}),$(".datagrid-submit").click(function(e){if(e.preventDefault(),D=$(this).closest("form"),D.find('input[name="action"]').val($(this).data("action")),$(this).data("action")==="delete")return window.openDialog("datagrid-bulk-delete"),!1;$(".datagrid-bulk-actions").hide(),$(".datagrid-spinner").show(),D.submit()}),$("#datagrid-action-confirm").click(function(){window.closeDialog("datagrid-bulk-delete"),D.submit()})}function Ke(){$.each($('table[data-render="datagrid2"]'),function(){I=$(this),$(this).find("thead a").click(function(e){e.preventDefault(),de($(this))}),$(this).closest("#datagrid-parent").find('nav[role="navigation"] a').click(function(e){e.preventDefault(),de($(this))})}),Oe(),ce(),me()}function Lt(){$(".datagrid-onload").length!=0&&Ct.observe(document.querySelector(".datagrid-onload"))}function de(e){I.find("thead").hide(),I.find("tbody").hide(),I.find("tfoot").show();let t=e.attr("href"),n=e.data("url");t==="#"&&n&&(t=n);let s=e.data("target")??"#datagrid-parent";$.ajax(t).done(function(i){i.html&&$(s).html(i.html),i.deletes&&$("#datagrid-delete-forms").html(i.deletes),i.url&&window.history.pushState({},"",i.url),Ke(),$(document).trigger("shown.bs.modal")}).fail(function(i){console.error("datagrid2",i),I.find("tfoot").addClass("bg-danger")})}const Ue=()=>{document.querySelectorAll('[data-animate="collapse"]').forEach(n=>{n.addEventListener("click",jt)}),document.querySelectorAll('[data-animate="reveal"]').forEach(n=>{n.addEventListener("change",Dt)})};function jt(e){let t=this.dataset.target;t||(t=this.hash),document.querySelectorAll(t).forEach(s=>{s.classList.toggle("hidden")}),this.classList.toggle("animate-collapsed")}function Dt(e){let t=document.querySelector(this.dataset.target);this.value?t.classList.remove("hidden"):t.classList.add("hidden")}$(document).on("shown.bs.modal",function(){Ue()});Ue();$(document).ready(function(){qt(),Et()});function qt(){let e=$("#bookmark-selector");if(e.length===0)return!1;e.change(function(t){t.preventDefault();let n=$(this).find(":selected");$(".bookmark-subform").addClass("hidden");let s=n.data("target");$(s).removeClass("hidden")})}function Et(){let e=$("#entity-selector");if(e.length===0)return!1;e.val()!=""&&$("#filter-subform").show(),e.change(function(){e.val()==""?($("#filter-subform").hide(),console.log(e.val())):$("#filter-subform").show()})}$(document).ready(function(){Mt()});function Mt(){let e=$("#webhook-selector");if(e.length===0)return!1;e.change(function(t){t.preventDefault();let n=$(this).find(":selected");$(".webhook-subform").addClass("hidden");let s=n.data("target");$(s).removeClass("hidden")})}$(document).ready(function(){At()});function At(){let e=$("#post-layout-selector");e.length!==0&&e.change(function(t){t.preventDefault(),$(this).find(":selected").val()===""?($(".field-entry").show(),$(".field-location").show(),$(".field-display").show(),$("#post-layout-subform").hide()):($(".field-entry").hide(),$(".field-location").hide(),$(".field-display").hide(),$("#post-layout-subform").show())})}$(document).ready(function(){$(document).on("shown.bs.modal shown.bs.popover",function(){xe()}),$(".form-members").count!==0&&xe()});function xe(){$.each($(".form-members"),function(){let e=$(this);if(e.data("loaded")===1)return;e.data("loaded",1);let t=e.data("allow-clear");e.select2({tags:!0,allowClear:t||!0,minimumInputLength:0,ajax:{quietMillis:500,delay:500,url:e.data("url"),dataType:"json",data:function(n){return{q:$.trim(n.term)}},processResults:function(n){return{results:n}},cache:!0},createTag:function(){}})})}$(document).ready(function(){It(),Pt(),zt(),Ft(),Qt(),Nt(),Rt()});function It(){$("#campaign-modules").length!==0&&$('input[name="enabled"]').change(function(e){e.preventDefault();let t=$(this).closest(".box-module").find("h3");t.hasClass("loading")||(t.addClass("loading"),axios.post($(this).data("url")).then(n=>{let s=$(this);s.closest(".box-module").find("h3").removeClass("loading"),n.data.success&&(n.data.status?s.closest(".box-module").addClass("module-enabled"):s.closest(".box-module").removeClass("module-enabled"),window.showToast(n.data.toast))}))})}function Pt(){$(".btn-user-roles").popover({html:!0,sanitize:!1,trigger:"focus"})}function Qt(){document.querySelectorAll(".public-permission").forEach(t=>{t.addEventListener("click",Ht)})}function Ht(e){e.preventDefault(),this.classList.add("loading"),axios.post(this.dataset.url).then(t=>{this.classList.remove("loading"),t.data.success&&(t.data.status?$(this).addClass("enabled"):$(this).removeClass("enabled"),window.showToast(t.data.toast))})}function zt(){$.each($(".codemirror"),function(){let e=$(this).attr("id");CodeMirror.fromTextArea(document.getElementById(e),{extraKeys:{"Ctrl-Space":"autocomplete"},lineNumbers:!0,lineWrapping:!0,theme:"dracula"})})}function Ft(){let e=[].slice.call(document.querySelectorAll(".nested-sortable"));for(let t=0;t0;return!(i.classList.contains("fixed-position")&&c)}})}function Nt(){let e=$("form#campaign-style");e.length!==0&&e.on("submit",function(t){let n=$($(this).data("error"));return $('textarea[name="content"]').val().length<$(this).data("max-content")?(n.hide(),!0):(n.show(),$("form .submit-group .btn").prop("disabled",!1),!1)})}function Rt(){$('input[name="vanity"]').focusout(function(e){let t=$(this).val(),n=$("#vanity-error"),s=$("#vanity-success"),i=$("#vanity-loading");if(n.html("").hide(),s.hide(),!t)return;i.show();let o={};o.vanity=t,$.post({url:$(this).data("url"),method:"POST",context:this,data:o}).done(function(c){$(this).val(c.vanity),s.find("code").html(c.vanity),s.show(),n.hide(),i.hide()}).fail(function(c){let d="";c.responseJSON.errors.vanity.forEach(m=>d+=m+" "),n.html(d).show(),s.hide(),i.hide()})})}const Ve=()=>{document.querySelectorAll("[data-clipboard]").forEach(t=>{t.addEventListener("click",Bt,!1)})};function Bt(e){e.preventDefault(),Ot(this.dataset.clipboard,this);let t=this.dataset.toast;return t&&window.showToast(t),!1}async function Ot(e,t){if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(e);else{const n=document.createElement("textarea");n.value=e,n.style.position="absolute",n.style.left="-999999px",t.append(n),n.select();try{document.execCommand("copy")}catch(s){console.error(s)}finally{n.remove()}}}Ve();$(document).on("shown.bs.modal",function(e){Ve()});$(document).ready(function(){We()});function We(){$('.toast-container [data-toggle="dismiss"]').unbind("click").on("click",function(e){e.preventDefault();let t=$(this).closest(".toast-message");t.removeClass("opacity-100").addClass("opacity-0"),setTimeout(function(){t.remove()},150)})}window.showToast=function(e,t){t=t||"bg-success text-success-content",t==="error"&&(t="bg-error text-error-content");let n=$('
');n.html('
'+e+'this.options.collapseScreenSize?e("body").removeClass(i.collapsed).trigger(e.Event(o.expanded)):e("body").addClass(i.open).trigger(e.Event(o.expanded))},c.prototype.close=function(){var f=e(window).width();f>this.options.collapseScreenSize?e("body").addClass(i.collapsed).trigger(e.Event(o.collapsed)):e("body").removeClass(i.open+" "+i.collapsed).trigger(e.Event(o.collapsed))},c.prototype.expandOnHover=function(){e(s.mainSidebar).hover((function(){e("body").is(s.mini+s.collapsed)&&e(window).width()>this.options.collapseScreenSize&&this.expand()}).bind(this),(function(){e("body").is(s.expanded)&&this.collapse()}).bind(this))},c.prototype.expand=function(){setTimeout(function(){e("body").removeClass(i.collapsed).addClass(i.expanded)},this.options.expandTransitionDelay)},c.prototype.collapse=function(){setTimeout(function(){e("body").removeClass(i.expanded).addClass(i.collapsed)},this.options.expandTransitionDelay)};function d(f){return this.each(function(){var _=e(this),p=_.data(t);if(!p){var et=e.extend({},n,_.data(),typeof f=="object"&&f);_.data(t,p=new c(et))}f==="toggle"&&p.toggle()})}var m=window.$.fn.pushMenu;window.$.fn.pushMenu=d,window.$.fn.pushMenu.Constructor=c,window.$.fn.pushMenu.noConflict=function(){return window.$.fn.pushMenu=m,this},window.$(document).on("click",s.button,function(f){f.preventDefault(),d.call(window.$(this),"toggle")}),window.$(window).on("load",function(){d.call(window.$(s.button))})}(jQuery);const Kt=()=>{document.querySelectorAll(".banner-notification-dismiss").forEach(e=>{e.addEventListener("click",Ut,!1)}),document.querySelectorAll('[data-dismiss="tutorial"]').forEach(e=>{e.addEventListener("click",Vt,!1)})};function Ut(e){e.preventDefault();let t=this.dataset.dismiss;axios.post(this.dataset.url).then(()=>{if(!t)return;let n=document.querySelector(t);n&&n.classList.add("hidden")})}function Vt(e){e.preventDefault();let t=this.dataset.target;axios.post(this.dataset.url).then(()=>{if(!t)return;let n=document.querySelector(t);n&&n.classList.add("hidden")})}Kt();let Je;$(document).ready(function(){Wt()});function Wt(){let e=$("#element-era-id");e.length!==0&&(Je=e.val(),e.length===1&&e.on("change",function(){Jt(e.val())}))}function Jt(e){e=parseInt(e);let t=$('input[name="era-data-url"]').data("url").replace("/0/","/"+e+"/"),n=$('input[name="oldPosition"]').data("url");$.ajax(t).done(function(s){let i=$('select[name="position"]');i.html("");let o=1;$.each(s.positions,function(c){let d=s.positions[c],m=' selected="selected"';n&&!c&&Je==e&&i.append('"),c&&i.append('"),o++})})}window.initSortable=function(){let e=document.querySelectorAll(".sortable-elements");e.length!==0&&e.forEach(t=>{let n={},s=t.dataset.handle;s&&(n.handle=s),De.create(t,n)})};window.initSortable();window.formErrorHandler=function(e,t){if($(".input-error").removeClass("input-error"),$(".text-error").remove(),$(t).find(".btn-primary").prop("disabled",!1).removeClass("loading"),e.status===503){window.showToast(e.responseJSON.message,"error");return}if(e.status===403){$("#entity-form-403-error").show();return}let n=e.responseJSON.errors,s=[],i=Object.keys(n),o=!0;if(i.forEach(function(f){let _=$('[name="'+f+'"]');_.length>0?_.addClass("input-error").parent().append('
'+n[f][0]+"
"):(o=!1,s.push(n[f][0])),window.showToast(n[f][0],"error")}),!o){let f=$("#entity-form-generic-error .error-logs");f.html(""),s.forEach(function(_){let p=_+"
";f.append(p)}),$("#entity-form-generic-error").show()}if($(t).find(".tab-content").length===0)return;let c=Object.keys(n)[0],d=document.getElementsByName(c);if(!d[0])return;$(".tab-content .active").removeClass("active"),$(".nav-tabs li.active").removeClass("active");let m=$('[name="'+c+'"').closest(".tab-pane");m.addClass("active"),$('a[href="#'+m.attr("id")+'"]').closest("li").addClass("active"),d[0].scrollIntoView({behavior:"smooth"})};const Gt={props:{text:String,title:String}},Yt={class:"mx-5"},Zt=["data-title"],Xt=a("i",{class:"fa-solid fa-chevrons-left","aria-hidden":"true","data-sidebar":"collapse"},null,-1),en=a("i",{class:"fa-solid fa-chevrons-right","aria-hidden":"true","data-sidebar":"expand"},null,-1),tn={class:"sr-only"};function nn(e,t,n,s,i,o){return r(),l("div",Yt,[a("span",{role:"button",class:"sidebar-toggle text-center cursor-pointer","data-toggle":"tooltip","data-title":n.title,"data-placement":"right","data-html":"true",tabindex:"3"},[Xt,en,a("span",tn,u(n.text),1)],8,Zt)])}const sn=S(Gt,[["render",nn]]),an={props:["entity"],methods:{backgroundImage:function(e){return"url('"+e.image+"')"},preview:function(e){this.emitter.emit("preview",e)}}},on=["data-id"],rn={class:"flex-none"},ln=["href","title"],cn={class:"flex-grow truncate pl-1"},dn=["title","innerHTML"],un=["innerHTML"];function fn(e,t,n,s,i,o){return r(),l("div",{class:"flex justify-center gap-1 cursor-pointer hover:bg-base-200 rounded w-full","data-id":n.entity.id,onClick:t[1]||(t[1]=c=>o.preview(n.entity))},[a("div",rn,[a("a",{href:n.entity.link,style:E({backgroundImage:o.backgroundImage(n.entity)}),onClick:t[0]||(t[0]=X(()=>{},["stop"])),title:n.entity.name,class:"rounded cover-background block h-16 w-16"},null,12,ln)]),a("div",cn,[a("div",{class:"font-extrabold entity-name truncate",title:n.entity.name,innerHTML:n.entity.name},null,8,dn),a("div",{class:"entity-type text-xs",innerHTML:n.entity.type},null,8,un)])],8,on)}const Ge=S(an,[["render",fn]]),hn={props:["entity"],components:{LookupEntity:Ge},data(){return{focus_profile:!0,focus_pins:!1,focus_access:!1}},methods:{hasTitle(){return this.entity.title},tagClass(e){let t="inline-block rounded-xl px-3 py-1 bg-base-100 text-base-content text-xs";return e.colour&&(t+=" bg-"+e.colour,e.colour==="black"&&(t+=" text-white")),t},backgroundImage:function(){return"url('"+this.entity.image+"')"},tabClass:function(e){let t="p-1 px-1 mx-1 pt-2 select-none text-center truncate border-b-2 border-solid border-r-0 border-t-0 border-l-0";return e==="profile"&&this.focus_profile||e==="links"&&this.focus_pins||e==="access"&&this.focus_access?t+=" font-black border-slate-600":t+=" cursor-pointer border-base-100",t},switchTab:function(e){this.focus_profile=!1,this.focus_pins=!1,this.focus_access=!1,e==="profile"?this.focus_profile=!0:e==="links"?this.focus_pins=!0:e==="access"&&(this.focus_access=!0)},profileClass:function(e){return"entity-profile-"+e.slug}}},mn={class:"entity-header p-3 bg-entity-focus"},pn={class:"w-full flex items-center"},gn=["href","title","innerHTML"],vn={key:0,class:"fa-solid fa-skull mx-2","aria-hidden":"true"},_n=["href"],yn=a("i",{class:"fa-solid fa-external-link","aria-hidden":"true","aria-label":"Open in a new window"},null,-1),wn=[yn],bn=["innerHTML"],xn={key:1,class:"my-1 w-full flex flex-wrap gap-1"},kn=["href","data-tag-id","data-tag-slug","innerHTML"],$n=["href","data-tag"],Cn=a("i",{class:"fa-duotone circle-location-arrow","aria-hidden":"true","aria-label":"Location"},null,-1),Sn=["href","title"],Tn={class:"entity-sections"},Ln={class:"tabs flex my-2 justify-center items-center border-solid border-slate-600 border-b-2 border-r-0 border-t-0 border-l-0"},jn={key:0,class:"tab-profile p-5 flex flex-col gap-5"},Dn={key:0,class:"entity-pinned-attributes flex flex-col gap-3"},qn=["data-attribute","data-target"],En={class:"inline-block uppercase font-extrabold mr-1"},Mn=["innerHTML"],An={key:1},In={class:"flex flex-col gap-3"},Pn={class:"uppercase font-extrabold truncate"},Qn={key:1,class:"tab-links p-3"},Hn={key:0,class:"text-center italic"};function zn(e,t,n,s,i,o){const c=L("LookupEntity");return r(),l(v,null,[a("div",mn,[a("div",pn,[a("a",{class:"text-2xl font-extrabold entity-name",href:n.entity.link,title:n.entity.name,innerHTML:n.entity.name},null,8,gn),n.entity.is_dead?(r(),l("i",vn)):h("",!0),a("a",{class:"ml-2 text-xs",target:"_blank",href:n.entity.link},wn,8,_n)]),o.hasTitle()?(r(),l("div",{key:0,class:"block w-full",innerHTML:n.entity.title},null,8,bn)):h("",!0),n.entity.tags.length>0?(r(),l("div",xn,[(r(!0),l(v,null,w(n.entity.tags,d=>(r(),l("a",{class:g(o.tagClass(d)),href:d.link,"data-tag-id":d.id,"data-tag-slug":d.slug,innerHTML:d.name},null,10,kn))),256))])):h("",!0),n.entity.location?(r(),l("a",{key:2,class:"block w-full cursor-pointer my-2",href:n.entity.location.link,"data-tag":n.entity.id},[Cn,b(" "+u(n.entity.location.name),1)],8,$n)):h("",!0),n.entity.image?(r(),l("a",{key:3,href:n.entity.link,style:E({backgroundImage:o.backgroundImage()}),title:n.entity.name,class:"rounded cover-background block w-full aspect-square"},null,12,Sn)):h("",!0)]),a("div",Tn,[a("div",Ln,[a("div",{class:g(o.tabClass("profile")),onClick:t[0]||(t[0]=d=>o.switchTab("profile"))},u(n.entity.texts.profile),3),a("div",{class:g(o.tabClass("links")),onClick:t[1]||(t[1]=d=>o.switchTab("links"))},u(n.entity.texts.connections),3),a("div",{class:g(o.tabClass("access")),onClick:t[2]||(t[2]=d=>o.switchTab("access"))},null,2)]),i.focus_profile?(r(),l("div",jn,[n.entity.attributes.length>0?(r(),l("div",Dn,[(r(!0),l(v,null,w(n.entity.attributes,d=>(r(),l("div",{class:"","data-attribute":d.name,"data-target":d.id},[a("span",En,u(d.name),1),a("span",{innerHTML:d.value},null,8,Mn)],8,qn))),256))])):h("",!0),n.entity.attributes.length>0?(r(),l("hr",An)):h("",!0),a("div",In,[(r(!0),l(v,null,w(n.entity.profile,d=>(r(),l("div",{class:g(["",o.profileClass(d)])},[a("div",Pn,u(d.field),1),a("div",null,u(d.value),1)],2))),256))])])):h("",!0),i.focus_pins?(r(),l("div",Qn,[(r(!0),l(v,null,w(n.entity.connections,d=>(r(),T(c,{entity:d},null,8,["entity"]))),256)),n.entity.connections.length===0?(r(),l("p",Hn,u(n.entity.texts["no-connections"]),1)):h("",!0)])):h("",!0)])],64)}const Fn=S(hn,[["render",zn]]),Nn={directives:{clickOutside:Ee.directive},props:{api_lookup:String,api_recent:String,placeholder:String,keyboard_tooltip:String},components:{LookupEntity:Ge,EntityPreview:Fn},data(){return{has_drawer:!1,term:null,show_loading:!1,show_recent:!1,show_preview:!1,show_results:!1,show_bookmarks:!1,recent:[],bookmarks:[],indexes:[],results:[],cached:{},has_recent:!1,texts:{},timeout_id:null,preview_entity:null}},watch:{term(e,t){this.termChanged()}},methods:{termChanged(){this.term.trim().length<3||(this.timeout_id!==void 0&&clearTimeout(this.timeout_id),this.show_loading=!0,this.timeout_id=setTimeout(()=>this.lookup(),500))},lookup(){let e=this.term.trim(),t=e.toLowerCase().replace(/ /g,"-").replace(/ [^\w-]+/g,"");if(this.cached[t])return this.displayCached(t);fetch(this.api_lookup+"?"+new URLSearchParams({q:e,v2:!0})).then(n=>n.json()).then(n=>this.parseLookupResponse(n,t))},focus(){this.api_recent&&(this.show_preview=!1,this.has_drawer=!0,this.fetch())},escape(){this.timeout_id!==void 0&&clearTimeout(this.timeout_id),this.close()},fetch(){if(this.has_recent){this.show_recent=!0;return}this.show_loading=!0,fetch(this.api_recent).then(e=>e.json()).then(e=>{this.recent=e.recent,this.bookmarks=e.bookmarks,this.indexes=e.indexes,this.texts.recents=e.texts.recents,this.texts.results=e.texts.results,this.texts.hint=e.texts.hint,this.texts.bookmarks=e.texts.bookmarks,this.texts.index=e.texts.index,this.texts.keyboard=e.texts.keyboard,this.texts.empty_results=e.texts.empty_results,this.texts.fulltext=e.texts.fulltext,this.texts.fulltext_route=e.fulltext_route,this.show_loading=!1,this.show_recent=!0,this.has_recent=!0,this.bookmarks.length>0?this.show_bookmarks=!0:this.show_bookmarks=!1}).catch(e=>{this.show_loading=!1,this.show_recent=!0,this.has_recent=!1})},parseLookupResponse(e,t){this.results=e.entities,this.cached[t]=e.entities,this.showResults()},displayCached(e){this.results=this.cached[e],this.showResults()},showResults(){this.timeout_id=null,this.show_preview=!1,this.show_loading=!1,this.show_results=!0},loadPreview(e){this.show_loading=!0,fetch(e.preview).then(t=>t.json()).then(t=>this.parsePreviewResponse(t))},parsePreviewResponse(e){this.preview_entity=e,this.show_loading=!1,this.show_preview=!0,this.show_recent=!1},onClickOutside(e){this.close()},close(){this.show_recent=!1,this.show_loading=!1,this.show_preview=!1,this.$refs.searchField.blur()},showBookmarks(){this.show_bookmarks=!0},searchFullTextUrl(){return`${this.texts.fulltext_route}?term=${this.term}`},showIndexes(){this.show_bookmarks=!1},modeClass(e){return e&&this.show_bookmarks||!e&&!this.show_bookmarks?" underline":""}},mounted(){this.emitter.on("preview",e=>{this.loadPreview(e)})}},Rn={class:"flex grow mr-2"},Bn={class:"relative grow field flex items-center"},On=["placeholder"],Kn={class:"absolute right-1 hidden md:inline"},Un=["data-title"],Vn={key:0,class:"search-drawer absolute top-0 left-0 mt-12 h-sidebar w-sidebar bg-navbar bg-base-100 shadow-r overflow-y-auto"},Wn={key:0,class:"text-center"},Jn=a("i",{class:"fa-solid fa-spinner fa-spin","aria-hidden":"true","aria-label":"Loading"},null,-1),Gn=[Jn],Yn={key:1,class:"search-recent bg-lookup p-2 min-h-full shadow-r flex flex-col items-stretch"},Zn={key:0,class:"flex-none"},Xn={class:"italic text-xs text-center"},ei={class:"grow flex flex-col gap-5 p-2"},ti={key:0,class:"search-results flex flex-col gap-2"},ni={class:"text-sm uppercase"},ii={key:0,class:"text-neutral-content text-sm"},si=["href"],ai={key:1,class:"recent-searches flex flex-col gap-2"},oi={class:"text-sm uppercase"},ri={key:2,class:"flex gap-5 justify-center"},li={key:3,class:"flex flex-col gap-4"},ci=["href","title"],di=["innerHTML"],ui={key:4,class:"flex flex-col gap-4"},fi=["href","title"],hi=["innerHTML"],mi={key:1,class:"flex-none text-xs text-center"},pi=a("hr",null,null,-1),gi=["innerHTML"],vi={key:2,class:"search-preview bg-lookup min-h-full shadow-r"};function _i(e,t,n,s,i,o){const c=L("LookupEntity"),d=L("EntityPreview"),m=qe("click-outside");return ee((r(),l("div",Rn,[a("div",Bn,[ee(a("input",{type:"text",class:"leading-4 w-20 md:w-full",maxlength:"25",ref:"searchField",id:"entity-lookup","onUpdate:modelValue":t[0]||(t[0]=f=>i.term=f),onClick:t[1]||(t[1]=f=>o.focus()),onFocus:t[2]||(t[2]=f=>o.focus()),onKeydown:t[3]||(t[3]=nt(f=>o.escape(),["esc"])),placeholder:n.placeholder},null,40,On),[[it,i.term]]),a("span",Kn,[a("span",{class:"flex-none keyboard-shortcut py-1",id:"lookup-kb-shortcut","data-toggle":"tooltip","data-title":n.keyboard_tooltip,"data-html":"true","data-placement":"bottom"}," K ",8,Un)])]),i.show_recent||i.show_loading||i.show_preview?(r(),l("aside",Vn,[i.show_loading?(r(),l("div",Wn,Gn)):h("",!0),i.show_recent?(r(),l("div",Yn,[i.show_results?h("",!0):(r(),l("div",Zn,[a("p",Xn,u(i.texts.hint),1)])),a("div",ei,[i.show_results?(r(),l("div",ti,[a("div",ni,u(i.texts.results),1),i.results.length===0?(r(),l("div",ii,u(i.texts.empty_results),1)):(r(!0),l(v,{key:1},w(i.results,f=>(r(),T(c,{entity:f},null,8,["entity"]))),256)),a("a",{class:"grow text-sm uppercase hover:underline",href:o.searchFullTextUrl()},u(i.texts.fulltext),9,si)])):h("",!0),i.recent.length>0?(r(),l("div",ai,[a("div",oi,u(i.texts.recents),1),(r(!0),l(v,null,w(i.recent,f=>(r(),T(c,{entity:f},null,8,["entity"]))),256))])):h("",!0),i.bookmarks.length>0?(r(),l("div",ri,[i.bookmarks.length>0?(r(),l("button",{key:0,class:g(["grow text-sm uppercase hover:underline",this.modeClass(!0)]),onClick:t[4]||(t[4]=f=>o.showBookmarks())},u(i.texts.bookmarks),3)):h("",!0),a("button",{class:g(["grow text-sm uppercase hover:underline",this.modeClass(!1)]),onClick:t[5]||(t[5]=f=>o.showIndexes())},u(i.texts.index),3)])):h("",!0),i.show_bookmarks?(r(),l("div",li,[(r(!0),l(v,null,w(i.bookmarks,f=>(r(),l("a",{href:f.url,onClick:t[6]||(t[6]=X(()=>{},["stop"])),title:f.text,class:"flex gap-2 items-center"},[a("i",{class:g(["w-4",f.icon]),"aria-hidden":"true"},null,2),a("span",{innerHTML:f.text},null,8,di)],8,ci))),256))])):(r(),l("div",ui,[(r(!0),l(v,null,w(i.indexes,f=>(r(),l("a",{href:f.url,onClick:t[7]||(t[7]=X(()=>{},["stop"])),title:f.name,class:"flex gap-2 items-center"},[a("i",{class:g(["w-4 text-center",f.icon]),"aria-hidden":"true"},null,2),a("span",{innerHTML:f.name},null,8,hi)],8,fi))),256))]))]),i.show_loading?h("",!0):(r(),l("div",mi,[pi,a("p",{class:"italic text-xs text-center",innerHTML:i.texts.keyboard},null,8,gi)]))])):h("",!0),i.show_preview?(r(),l("div",vi,[z(d,{entity:i.preview_entity},null,8,["entity"])])):h("",!0)])):h("",!0)])),[[m,o.onClickOutside]])}const yi=S(Nn,[["render",_i]]),wi={props:["campaign"],methods:{backgroundImage:function(e){return e.image?"url("+e.image+")":""},campaignClass:function(e){return"campaign flex items-end border border-solid rounded-lg cover-background relative h-24 overflow-hidden text-break shadow-xs hover:shadow-md border-0"+(e.is_boosted?" boosted":"")}}},bi=["href","title"],xi=["innerHTML"];function ki(e,t,n,s,i,o){return r(),l("a",{class:g(o.campaignClass(n.campaign)),href:n.campaign.url,style:E({backgroundImage:o.backgroundImage(n.campaign)}),title:n.campaign.name},[a("div",{class:"flex items-end justify-center name w-full text-xs p-2 pt-6 text-center",innerHTML:n.campaign.name},null,8,xi)],14,bi)}const $i=S(wi,[["render",ki]]),Ci={props:["notification"],data(){return{is_dismissed:!1,is_loading:!1}},methods:{backgroundClass:function(e){let t="notification bg-base-200 flex justify-center items-center p-2 rounded-md";return e.is_read?t:t+" unread"},iconClass:function(e){return"fa-solid fa-"+e.icon},dismiss:function(e){this.is_loading=!0,axios.post(e.dismiss).then(()=>{this.is_dismissed=!0,this.emitter.emit("read_notification",e)})}}},Si=["data-id"],Ti={class:"flex-none p-2"},Li=["innerHTML","href"],ji=["title"],Di=a("i",{class:"fa-solid fa-times","aria-hidden":"true"},null,-1),qi=[Di],Ei={key:1,class:"flex-none p-2"},Mi=a("i",{class:"fa-solid fa-spinner fa-spin","aria-hidden":"true"},null,-1),Ai=[Mi],Ii=["data-id"],Pi={class:"flex-none p-2"},Qi=["innerHTML"],Hi=["title"],zi=a("i",{class:"fa-solid fa-times","aria-hidden":"true"},null,-1),Fi=[zi],Ni={key:1,class:"flex-none p-2"},Ri=a("i",{class:"fa-solid fa-spinner fa-spin","aria-hidden":"true"},null,-1),Bi=[Ri];function Oi(e,t,n,s,i,o){return n.notification.url&&!i.is_dismissed?(r(),l("div",{key:0,class:g(o.backgroundClass(n.notification)),"data-id":n.notification.id},[a("div",Ti,[a("i",{class:g(o.iconClass(n.notification)),"aria-hidden":"true"},null,2)]),a("a",{class:"flex-grow p-2 break-all",innerHTML:n.notification.text,href:n.notification.url},null,8,Li),this.is_loading?(r(),l("div",Ei,Ai)):(r(),l("div",{key:0,class:"flex-none p-2 cursor-pointer dismissable",onClick:t[0]||(t[0]=c=>o.dismiss(n.notification)),title:n.notification.dismiss_text},qi,8,ji))],10,Si)):i.is_dismissed?h("",!0):(r(),l("div",{key:1,class:g(o.backgroundClass(n.notification)),"data-id":n.notification.id},[a("div",Pi,[a("i",{class:g(o.iconClass(n.notification)),"aria-hidden":"true"},null,2)]),a("div",{class:"flex-grow p-2",innerHTML:n.notification.text},null,8,Qi),this.is_loading?(r(),l("div",Ni,Bi)):(r(),l("div",{key:0,class:"flex-none p-2 cursor-pointer dismissable",onClick:t[1]||(t[1]=c=>o.dismiss(n.notification)),title:n.notification.dismiss_text},Fi,8,Hi))],10,Ii))}const Ki=S(Ci,[["render",Oi]]),Ui={props:["release"],data(){return{is_dismissed:!1,is_loading:!1}},methods:{backgroundClass:function(e){return"release bg-base-200 flex justify-center items-center p-2 rounded-md"},dismiss:function(e){this.is_loading=!0,axios.post(e.dismiss).then(()=>{this.is_dismissed=!0,this.emitter.emit("read_release",e)})}}},Vi=["data-id"],Wi={class:"flex-grow p-2"},Ji=["innerHTML","href"],Gi=["innerHTML"],Yi=["title"],Zi=a("i",{class:"fa-solid fa-times","aria-hidden":"true"},null,-1),Xi=[Zi],es={key:1,class:"flex-none p-2"},ts=a("i",{class:"fa-solid fa-spinner fa-spin","aria-hidden":"true"},null,-1),ns=[ts];function is(e,t,n,s,i,o){return i.is_dismissed?h("",!0):(r(),l("div",{key:0,class:g(o.backgroundClass(n.release)),"data-id":n.release.id},[a("div",Wi,[a("a",{innerHTML:n.release.title,class:"font-bold cursor-pointer block w-full",href:n.release.url,target:"_blank"},null,8,Ji),a("p",{innerHTML:n.release.text},null,8,Gi)]),this.is_loading?(r(),l("div",es,ns)):(r(),l("div",{key:0,class:"flex-none p-2 cursor-pointer dismissable",onClick:t[0]||(t[0]=c=>o.dismiss(n.release)),title:n.release.dismiss_text},Xi,8,Yi))],10,Vi))}const ss=S(Ui,[["render",is]]),as=a("g",{stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[a("g",{transform:"translate(-219.000000, -200.000000)",fill:"currentcolor"},[a("g",{id:"icons",transform:"translate(56.000000, 160.000000)"},[a("path",{d:"M181.9,54 L179.8,54 C178.63975,54 177.7,54.895 177.7,56 L177.7,58 C177.7,59.105 178.63975,60 179.8,60 L181.9,60 C183.06025,60 184,59.105 184,58 L184,56 C184,54.895 183.06025,54 181.9,54 M174.55,54 L172.45,54 C171.28975,54 170.35,54.895 170.35,56 L170.35,58 C170.35,59.105 171.28975,60 172.45,60 L174.55,60 C175.71025,60 176.65,59.105 176.65,58 L176.65,56 C176.65,54.895 175.71025,54 174.55,54 M167.2,54 L165.1,54 C163.93975,54 163,54.895 163,56 L163,58 C163,59.105 163.93975,60 165.1,60 L167.2,60 C168.36025,60 169.3,59.105 169.3,58 L169.3,56 C169.3,54.895 168.36025,54 167.2,54 M181.9,47 L179.8,47 C178.63975,47 177.7,47.895 177.7,49 L177.7,51 C177.7,52.105 178.63975,53 179.8,53 L181.9,53 C183.06025,53 184,52.105 184,51 L184,49 C184,47.895 183.06025,47 181.9,47 M174.55,47 L172.45,47 C171.28975,47 170.35,47.895 170.35,49 L170.35,51 C170.35,52.105 171.28975,53 172.45,53 L174.55,53 C175.71025,53 176.65,52.105 176.65,51 L176.65,49 C176.65,47.895 175.71025,47 174.55,47 M167.2,47 L165.1,47 C163.93975,47 163,47.895 163,49 L163,51 C163,52.105 163.93975,53 165.1,53 L167.2,53 C168.36025,53 169.3,52.105 169.3,51 L169.3,49 C169.3,47.895 168.36025,47 167.2,47 M181.9,40 L179.8,40 C178.63975,40 177.7,40.895 177.7,42 L177.7,44 C177.7,45.105 178.63975,46 179.8,46 L181.9,46 C183.06025,46 184,45.105 184,44 L184,42 C184,40.895 183.06025,40 181.9,40 M174.55,40 L172.45,40 C171.28975,40 170.35,40.895 170.35,42 L170.35,44 C170.35,45.105 171.28975,46 172.45,46 L174.55,46 C175.71025,46 176.65,45.105 176.65,44 L176.65,42 C176.65,40.895 175.71025,40 174.55,40 M169.3,42 L169.3,44 C169.3,45.105 168.36025,46 167.2,46 L165.1,46 C163.93975,46 163,45.105 163,44 L163,42 C163,40.895 163.93975,40 165.1,40 L167.2,40 C168.36025,40 169.3,40.895 169.3,42"})])])],-1),os=[as],rs={__name:"GridSvg",props:{size:Number},setup(e){const t=e;function n(){return"w-"+t.size+" h-"+t.size}return(s,i)=>(r(),l("svg",{class:g(n()),viewBox:"0 -0.5 21 21",version:"1.1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true"},os,2))}},ls={directives:{clickOutside:Ee.directive},props:{user_id:{type:String},api:{type:String},fetch:{type:String},initials:{type:String},avatar:{type:String},campaign_id:void 0,has_alerts:{type:Boolean}},components:{GridSvg:rs,Campaign:$i,Notification:Ki,Release:ss},data(){return{alert_delta:60*1e3,is_loading:!1,is_expanded:!1,has_data:!1,view_campaigns:!1,view_profile:!1,profile:{},campaigns:{},notifications:{},marketplace:{},releases:{},show_alerts:!1,is_loaded:!1}},methods:{openCampaigns:function(){this.view_campaigns=!0,this.view_profile=!1,this.loadData()},openProfile:function(){this.view_profile=!0,this.view_campaigns=!1,this.loadData()},loadData:function(){this.is_expanded=!0,!this.has_data&&(this.is_loading=!0,fetch(this.api).then(e=>e.json()).then(e=>{this.profile=e.profile,this.campaigns=e.campaigns,this.notifications=e.notifications,this.marketplace=e.marketplace,this.releases=e.releases,this.show_alerts=e.has_unread,this.has_data=!0,this.is_loading=!1,this.is_loaded=!0}))},blockClass:function(e){return e?"block p-4 flex-grow items-center focus:box-shadow":"block p-4 items-center bg-base-200 cursor-pointer flex-none focus:box-shadow"},logout:function(){document.getElementById("logout-form").submit()},onClickOutside(e){this.is_expanded=!1},readRelease:function(e){let t=this.releases.releases.findIndex(n=>n.id===e.id);this.releases.releases.slice(t,1),this.updateUnread()},readNotification:function(e){let t=this.notifications.messages.findIndex(n=>n.id==e.id);this.notifications.messages.slice(t,1),this.updateUnread()},updateUnread:function(){this.notifications.messages.length===0&&this.releases.releases.length===0&&(this.show_alerts=!1)},updateAlerts:function(){let e=localStorage.getItem("last_notification-"+this.user_id),n=new Date().getTime()-60*5e3;if(!e||et.json()).then(t=>{localStorage.setItem("notification-has-alerts-"+this.user_id,t.has_alerts),this.updateAlerts()})},queueFetch:function(){let e=this;setTimeout((function(){e.updateAlerts()}).bind(this),this.alert_delta)},showInitials:function(){return this.avatar.startsWith("/images/")},profilePictureUrl:function(){return"url("+this.avatar+")"}},mounted(){this.emitter.on("read_release",e=>{this.readRelease(e)}),this.emitter.on("read_notification",e=>{this.readNotification(e)}),this.show_alerts=this.has_alerts,this.queueFetch()}},cs={class:"nav-switcher flex items-center justify-center h-12"},ds=a("span",{class:"sr-only"},"Campaigns",-1),us={class:"indicator relative inline-flex w-max"},fs={key:0,class:"notification-badge left-auto top-auto w-fit inline-flex absolute content-center items-center z-10"},hs={key:1,class:"profile-box rounded-lg p-2 text-center font-bold"},ms={key:0,class:"navigation-drawer bg-base-100 h-full overflow-y-auto fixed top-0 right-0 rounded-l-2xl shadow-lg"},ps={key:0,class:"temporary p-8 text-center"},gs=a("i",{class:"fa-solid fa-spinner fa-spin","aria-hidden":"true"},null,-1),vs=[gs],_s={key:1,class:""},ys={class:"header flex"},ws={key:0,class:"full flex items-center gap-4"},bs={class:"flex-none"},xs={class:"flex-grow"},ks={class:"font-bold"},$s=["title"],Cs={key:0,class:"full flex items-center gap-4"},Ss={key:0,class:"flex-none profile-box rounded-lg p-2 text-center uppercase font-bold"},Ts={class:"flex-grow"},Ls={class:"font-bold"},js=["title"],Ds={key:0,class:"flex-none profile-box rounded-lg p-2 text-center uppercase font-bold"},qs={key:0,class:"profile p-5 flex flex-col gap-5"},Es={key:0,class:"notifications"},Ms={class:"flex w-full py-2"},As={class:"flex-grow uppercase font-bold"},Is={class:"flex-grow text-right"},Ps=["href"],Qs={class:"flex flex-col gap-2"},Hs={key:0,class:"no-notifications help-block text-neutral-content italic"},zs={key:1,class:"releases"},Fs={class:"flex w-full py-2"},Ns={class:"flex-grow uppercase font-bold"},Rs={class:"flex flex-col gap-2"},Bs={key:2,class:"marketplace"},Os={class:"flex w-full py-2"},Ks={class:"flex-grow uppercase font-bold"},Us={class:"flex-grow text-right"},Vs=["href"],Ws={class:"grid grid-cols-3 gap-2"},Js=["href"],Gs=a("div",{class:"icon bg-base-200 rounded-full w-14 h-14 text-3xl aspect-square flex justify-center items-center"},[a("i",{class:"fa-solid fa-palette","aria-hidden":"true"})],-1),Ys={class:"text-muted text-xs"},Zs=["href"],Xs=a("div",{class:"icon bg-base-200 rounded-full w-14 h-14 text-3xl aspect-square flex justify-center items-center"},[a("i",{class:"fa-solid fa-columns","aria-hidden":"true"})],-1),ea={class:"text-muted text-xs"},ta=["href"],na=a("div",{class:"icon bg-base-200 rounded-full w-14 h-14 text-3xl aspect-square flex justify-center items-center"},[a("i",{class:"fa-solid fa-dice-d20","aria-hidden":"true"})],-1),ia={class:"text-muted text-xs"},sa={key:3,class:"subscription"},aa={class:"uppercase font-bold py-2"},oa=["href"],ra={class:"flex-none p-2"},la=["src","alt"],ca={class:"flex-grow p-2"},da={class:"font-bold text-lg"},ua={key:0,class:"more"},fa=a("br",null,null,-1),ha={key:1,class:"more"},ma={class:"link flex gap-1 items-center"},pa=a("i",{class:"fa-duotone fa-credit-card","aria-hidden":"true"},null,-1),ga=a("i",{class:"fa-brands fa-paypal","aria-hidden":"true"},null,-1),va={key:4,class:"m-0 p-0 list-none flex flex-col gap-2"},_a=["href"],ya=a("i",{class:"fa-solid fa-cog mr-3","aria-hidden":"true"},null,-1),wa=["href"],ba=a("i",{class:"fa-solid fa-user mr-3","aria-hidden":"true"},null,-1),xa=["href"],ka=a("i",{class:"fa-solid fa-question-circle mr-3","aria-hidden":"true"},null,-1),$a=a("i",{class:"fa-solid fa-sign-out mr-3","aria-hidden":"true"},null,-1),Ca={key:5,class:"m-0 p-0 list-none flex flex-col gap-2"},Sa=["href"],Ta=a("i",{class:"fa-solid fa-sign-out-alt mr-3","aria-hidden":"true"},null,-1),La={key:1,class:"campaigns p-5"},ja={key:0,class:"campaigns flex flex-col gap-5"},Da={class:"flex flex-col gap-2"},qa={class:"flex w-full"},Ea={class:"flex-grow uppercase font-bold"},Ma={key:0,class:"flex-grow text-right"},Aa=["href"],Ia={class:"grid grid-cols-2 md:grid-cols-3 gap-5"},Pa=["href"],Qa={class:"text-xs text-break uppercase"},Ha=a("i",{class:"fa-solid fa-plus","aria-hidden":"true",style:{display:"none"}},null,-1),za={key:0},Fa={class:"flex flex-col gap-2"},Na={key:0,class:"uppercase"},Ra={key:1,class:"grid grid-cols-2 md:grid-cols-3 gap-5 following"},Ba=["href"],Oa={class:"text-xs uppercase text-break"};function Ka(e,t,n,s,i,o){const c=L("GridSvg"),d=L("Notification"),m=L("Release"),f=L("Campaign"),_=qe("click-outside");return r(),l(v,null,[a("div",cs,[a("div",{class:"campaigns inline cursor-pointer text-center px-3 text-2xl",onClick:t[0]||(t[0]=p=>o.openCampaigns()),"aria-label":"Switch campaigns",tabindex:"0",role:"button"},[z(c,{size:7}),ds]),a("div",{class:"profile inline cursor-pointer text-center uppercase pt-1",onClick:t[1]||(t[1]=p=>o.openProfile()),"aria-label":"Profile settings",tabindex:"0",role:"button"},[a("div",us,[i.show_alerts?(r(),l("span",fs)):h("",!0),o.showInitials()?(r(),l("div",hs,u(n.initials),1)):(r(),l("div",{key:2,class:"w-9 h-9 rounded-lg cover-background",style:E({backgroundImage:o.profilePictureUrl()})},null,4))])])]),i.is_expanded?ee((r(),l("div",ms,[i.is_loading?(r(),l("div",ps,vs)):(r(),l("div",_s,[a("div",ys,[a("div",{class:g(o.blockClass(i.view_campaigns)),onClick:t[2]||(t[2]=p=>o.openCampaigns()),tabindex:"0",role:"button","aria-label":"Campaign list"},[i.view_campaigns?(r(),l("div",ws,[a("div",bs,[z(c,{size:6})]),a("div",xs,[a("div",ks,u(i.campaigns.texts.campaigns),1),a("div",null,u(i.campaigns.texts.count),1)])])):(r(),l("div",{key:1,class:"flex items-center justify-center h-full",title:i.campaigns.texts.campaigns},[z(c,{size:6})],8,$s))],2),a("div",{class:g(o.blockClass(i.view_profile)),onClick:t[3]||(t[3]=p=>o.openProfile()),tabindex:"0",role:"button","aria-label":"Profile pane"},[i.view_profile?(r(),l("div",Cs,[o.showInitials()?(r(),l("div",Ss,u(n.initials),1)):(r(),l("div",{key:1,class:"flex-none w-9 h-9 rounded-lg cover-background",style:E({backgroundImage:o.profilePictureUrl()})},null,4)),a("div",Ts,[a("div",Ls,u(i.profile.name),1),a("div",null,u(i.profile.created),1)])])):(r(),l("div",{key:1,class:"",title:i.profile.your_profile},[o.showInitials()?(r(),l("div",Ds,u(n.initials),1)):(r(),l("div",{key:1,class:"flex-none w-9 h-9 rounded-lg cover-background",style:E({backgroundImage:o.profilePictureUrl()})},null,4))],8,js))],2)]),i.view_profile?(r(),l("div",qs,[i.notifications.title?(r(),l("div",Es,[a("div",Ms,[a("div",As,u(i.notifications.title),1),a("div",Is,[a("a",{href:i.notifications.all.url},u(i.notifications.all.text),9,Ps)])]),a("div",Qs,[(r(!0),l(v,null,w(i.notifications.messages,p=>(r(),T(d,{notification:p},null,8,["notification"]))),256))]),i.notifications.messages.length===0?(r(),l("div",Hs,u(i.notifications.none),1)):h("",!0)])):h("",!0),i.releases.title&&i.releases.releases.length>0?(r(),l("div",zs,[a("div",Fs,[a("div",Ns,u(i.releases.title),1)]),a("div",Rs,[(r(!0),l(v,null,w(i.releases.releases,p=>(r(),T(m,{release:p},null,8,["release"]))),256))])])):h("",!0),!i.profile.is_impersonating&&i.marketplace.title?(r(),l("div",Bs,[a("div",Os,[a("div",Ks,u(i.marketplace.title),1),a("div",Us,[a("a",{href:i.marketplace.explore.url,target:"_blank"},u(i.marketplace.explore.text),9,Vs)])]),a("div",Ws,[a("a",{href:i.marketplace.themes.url,class:"border py-2 items-center justify-center rounded-md hover:shadow-md flex flex-col gap-1",target:"_blank"},[Gs,a("div",null,u(i.marketplace.themes.title),1),a("div",Ys,u(i.marketplace.themes.number),1)],8,Js),a("a",{href:i.marketplace.sheets.url,class:"border py-2 items-center justify-center rounded-md hover:shadow-md flex flex-col gap-1",target:"_blank"},[Xs,a("div",null,u(i.marketplace.sheets.title),1),a("div",ea,u(i.marketplace.sheets.number),1)],8,Zs),a("a",{href:i.marketplace.content.url,class:"border py-2 items-center justify-center rounded-md hover:shadow-md flex flex-col gap-1",target:"_blank"},[na,a("div",null,u(i.marketplace.content.title),1),a("div",ia,u(i.marketplace.content.number),1)],8,ta)])])):h("",!0),!i.profile.is_impersonating&&i.profile.subscription?(r(),l("div",sa,[a("div",aa,u(i.profile.subscription.title),1),a("a",{class:"border rounded-lg flex justify-center items-center hover:shadow-md",href:i.profile.urls.subscription},[a("div",ra,[a("img",{class:"w-16 h-16",src:i.profile.subscription.image,alt:i.profile.subscription.tier},null,8,la)]),a("div",ca,[a("div",da,u(i.profile.subscription.tier),1),i.profile.subscription.tier!=="Kobold"?(r(),l("div",ua,[b(u(i.profile.subscription.created),1),fa,b(" "+u(i.profile.subscription.boosters),1)])):(r(),l("div",ha,[b(u(i.profile.subscription.call_to_action)+" ",1),a("div",ma,[b(u(i.profile.subscription.call_to_action_2)+" ",1),pa,ga])]))])],8,oa)])):h("",!0),i.profile.is_impersonating?(r(),l("ul",Ca,[a("li",null,[a("a",{href:i.profile.return.url,class:""},[Ta,b(" "+u(i.profile.return.name),1)],8,Sa)])])):(r(),l("ul",va,[a("li",null,[a("a",{href:i.profile.urls.settings.url,class:"p-2 block"},[ya,b(" "+u(i.profile.urls.settings.name),1)],8,_a)]),a("li",null,[a("a",{href:i.profile.urls.profile.url,class:"p-2 block"},[ba,b(" "+u(i.profile.urls.profile.name),1)],8,wa)]),a("li",null,[a("a",{href:i.profile.urls.help.url,class:"p-2 block",target:"_blank"},[ka,b(" "+u(i.profile.urls.help.name),1)],8,xa)]),a("li",null,[a("a",{href:"#",onClick:t[4]||(t[4]=p=>o.logout()),class:"p-2 block"},[$a,b(" "+u(i.profile.urls.logout.name),1)])])]))])):(r(),l("div",La,[i.profile.is_impersonating?h("",!0):(r(),l("div",ja,[a("div",Da,[a("div",qa,[a("div",Ea,u(i.campaigns.texts.campaigns),1),i.campaigns.member.length>0?(r(),l("div",Ma,[a("a",{href:i.campaigns.urls.reorder},u(i.campaigns.texts.reorder),9,Aa)])):h("",!0)]),a("div",Ia,[(r(!0),l(v,null,w(i.campaigns.member,p=>(r(),T(f,{campaign:p},null,8,["campaign"]))),256)),a("a",{href:i.campaigns.urls.new,class:"new-campaign flex items-center text-center border-dashed border rounded-lg h-24 p-2 overflow-hidden"},[a("span",Qa,[Ha,b(" "+u(i.campaigns.texts.new),1)])],8,Pa)])]),i.profile.is_impersonating?h("",!0):(r(),l("hr",za)),a("div",Fa,[i.profile.is_impersonating?h("",!0):(r(),l("p",Na,u(i.campaigns.texts.followed),1)),i.profile.is_impersonating?h("",!0):(r(),l("div",Ra,[(r(!0),l(v,null,w(i.campaigns.following,p=>(r(),T(f,{campaign:p},null,8,["campaign"]))),256)),a("a",{href:i.campaigns.urls.follow,class:"new-campaign flex items-center text-center border-dashed border rounded-lg h-24 p-2 overflow-hidden"},[a("span",Oa,u(i.campaigns.texts.follow),1)],8,Ba)]))])]))]))]))])),[[_,o.onClickOutside]]):h("",!0)],64)}const Ua=S(ls,[["render",Ka]]),Va=at(),Q=st({});Q.config.globalProperties.emitter=Va;Q.component("nav-toggler",sn);Q.component("nav-search",yi);Q.component("nav-switcher",Ua);Q.mount("#header");const Y=Array(),Ye=()=>{document.querySelectorAll('[data-toggle="tooltip-ajax"]').forEach(t=>{t.dataset.loaded!=="1"&&(t.dataset.loaded="1",U(t,{theme:"kanka",placement:t.dataset.direction??"bottom",allowHTML:!0,interactive:!0,delay:500,appendTo:t.dataset.append??document.body,content:'