From 871cfeba26cbb7f774c3cc42c099cd3772e20d19 Mon Sep 17 00:00:00 2001 From: Ben Thomson Date: Wed, 10 Apr 2024 11:46:02 +0800 Subject: [PATCH] Initial development of Composer support within Manage Updates area --- composer.json | 7 +- config/marketplace.php | 32 +++++ .../fileupload/assets/css/fileupload.css | 2 +- .../assets/css/permissioneditor.css | 4 +- modules/system/ServiceProvider.php | 20 +++ modules/system/aliases.php | 1 + modules/system/assets/css/updates/updates.css | 117 +----------------- modules/system/assets/js/build/manifest.js | 2 +- .../system/assets/js/build/system.debug.js | 2 +- modules/system/assets/js/build/system.js | 2 +- .../snowboard/build/snowboard.base.debug.js | 2 +- .../js/snowboard/build/snowboard.base.js | 2 +- .../js/snowboard/build/snowboard.data-attr.js | 2 +- .../js/snowboard/build/snowboard.extras.js | 2 +- .../js/snowboard/build/snowboard.request.js | 2 +- .../js/snowboard/build/snowboard.vendor.js | 4 +- .../system/assets/less/updates/updates.less | 12 +- modules/system/assets/ui/storm.css | 2 +- modules/system/classes/DetailedPackage.php | 10 ++ .../classes/DetailedVersionedPackage.php | 10 ++ modules/system/classes/PackageStorage.php | 97 +++++++++++++++ modules/system/classes/WinterPackage.php | 52 ++++++++ modules/system/controllers/Updates.php | 16 ++- .../controllers/updates/config_list.yaml | 4 +- modules/system/facades/Composer.php | 22 ++++ modules/system/models/PluginList.php | 94 ++++++++++++++ modules/system/models/pluginlist/columns.yaml | 21 ++++ modules/system/winter.mix.js | 3 + 28 files changed, 410 insertions(+), 136 deletions(-) create mode 100644 config/marketplace.php create mode 100644 modules/system/classes/DetailedPackage.php create mode 100644 modules/system/classes/DetailedVersionedPackage.php create mode 100644 modules/system/classes/PackageStorage.php create mode 100644 modules/system/classes/WinterPackage.php create mode 100644 modules/system/facades/Composer.php create mode 100644 modules/system/models/PluginList.php create mode 100644 modules/system/models/pluginlist/columns.yaml diff --git a/composer.json b/composer.json index de944efaa8..01b113e438 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,9 @@ "winter/wn-backend-module": "dev-develop", "winter/wn-cms-module": "dev-develop", "laravel/framework": "^9.1", - "wikimedia/composer-merge-plugin": "~2.1.0" + "winter/packager": "dev-main", + "wikimedia/composer-merge-plugin": "~2.1.0", + "nyholm/psr7": "^1.8" }, "require-dev": { "phpunit/phpunit": "^9.5.8", @@ -79,7 +81,8 @@ "config": { "allow-plugins": { "composer/installers": true, - "wikimedia/composer-merge-plugin": true + "wikimedia/composer-merge-plugin": true, + "php-http/discovery": false } } } diff --git a/config/marketplace.php b/config/marketplace.php new file mode 100644 index 0000000000..6de3c75648 --- /dev/null +++ b/config/marketplace.php @@ -0,0 +1,32 @@ + true, + + /* + |-------------------------------------------------------------------------- + | Marketplace package cache store + |-------------------------------------------------------------------------- + | + | If caching is enabled, the following value sets the store that should be + | used to store the cache. If this is `null`, the default store will be + | used. + | + */ + + 'store' => null, + +]; diff --git a/modules/backend/formwidgets/fileupload/assets/css/fileupload.css b/modules/backend/formwidgets/fileupload/assets/css/fileupload.css index 91f828c02d..6a9f2d3220 100644 --- a/modules/backend/formwidgets/fileupload/assets/css/fileupload.css +++ b/modules/backend/formwidgets/fileupload/assets/css/fileupload.css @@ -154,4 +154,4 @@ .field-fileupload.style-file-single .upload-object .meta{position:absolute;top:50%;margin-top:-44px;height:88px;right:0;width:15%} .field-fileupload.style-file-single .upload-object .meta .upload-remove-button{position:absolute;top:50%;right:0;height:20px;margin-top:-10px;margin-right:10px;z-index:100} .field-fileupload.style-file-single .upload-object .icon-container:after{width:20px;height:20px;margin-top:-10px;margin-left:-10px;background-size:20px 20px} -.field-fileupload.style-file-single .upload-object.is-error .icon-container:after{font-size:20px} +.field-fileupload.style-file-single .upload-object.is-error .icon-container:after{font-size:20px} \ No newline at end of file diff --git a/modules/backend/formwidgets/permissioneditor/assets/css/permissioneditor.css b/modules/backend/formwidgets/permissioneditor/assets/css/permissioneditor.css index a55d29893a..4815d62508 100644 --- a/modules/backend/formwidgets/permissioneditor/assets/css/permissioneditor.css +++ b/modules/backend/formwidgets/permissioneditor/assets/css/permissioneditor.css @@ -4,7 +4,7 @@ .permissioneditor table{width:100%} .permissioneditor table th{padding:30px 4px 8px 4px;color:#2a3e51;font-weight:normal;border-bottom:1px solid #dbe1e3} .permissioneditor table th.tab{font-size:13px} -.permissioneditor table th.permission-type{text-transform:uppercase;font-size:11px;text-align:center;cursor:pointer} +.permissioneditor table th.permission-type{text-transform:uppercase;font-size:11px;text-align:center} .permissioneditor table td{padding:10px 4px;vertical-align:top;border-bottom:1px solid #ecf0f1;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none} .permissioneditor table td.permission-value{text-align:center} .permissioneditor table td.permission-name{font-size:13px;cursor:pointer;color:#777} @@ -37,4 +37,4 @@ .permissioneditor table tr:last-child td{border-bottom:none} .permissioneditor table tr:first-child th{padding-top:0} .permissioneditor table tr.disabled td.permission-name{color:#AAA} -.permissioneditor table tr.last-section-row td{border-bottom:none} +.permissioneditor table tr.last-section-row td{border-bottom:none} \ No newline at end of file diff --git a/modules/system/ServiceProvider.php b/modules/system/ServiceProvider.php index 3dfd76c7aa..aab801dbed 100644 --- a/modules/system/ServiceProvider.php +++ b/modules/system/ServiceProvider.php @@ -12,6 +12,8 @@ use Markdown; use Request; use System\Classes\CombineAssets; +use System\Classes\DetailedPackage; +use System\Classes\DetailedVersionedPackage; use System\Classes\ErrorHandler; use System\Classes\MailManager; use System\Classes\MarkupManager; @@ -83,6 +85,7 @@ public function register() $this->registerBackendNavigation(); $this->registerBackendReportWidgets(); $this->registerBackendSettings(); + $this->registerComposer(); } } @@ -580,6 +583,7 @@ protected function registerAssetBundles() $combiner->registerBundle('~/modules/system/assets/js/framework.combined.js'); $combiner->registerBundle('~/modules/system/assets/less/framework.extras.less'); $combiner->registerBundle('~/modules/system/assets/less/snowboard.extras.less'); + $combiner->registerBundle('~/modules/system/assets/less/updates/updates.less'); }); } @@ -629,4 +633,20 @@ protected function registerGlobalViewVars() { View::share('appName', Config::get('app.name')); } + + protected function registerComposer() + { + $this->app->bind('system.composer', function () { + \Winter\Packager\Composer::setPackageClass('detailedPackage', DetailedPackage::class); + \Winter\Packager\Composer::setPackageClass('detailedVersionedPackage', DetailedVersionedPackage::class); + + $composer = new \Winter\Packager\Composer; + $composer + ->setHomeDir(storage_path('temp/packager'), true) + ->setWorkDir(base_path()) + ->setStorage(new \System\Classes\PackageStorage); + + return $composer; + }); + } } diff --git a/modules/system/aliases.php b/modules/system/aliases.php index 3a644a3339..3999faf659 100644 --- a/modules/system/aliases.php +++ b/modules/system/aliases.php @@ -56,6 +56,7 @@ 'BackendMenu' => Backend\Facades\BackendMenu::class, 'Block' => Winter\Storm\Support\Facades\Block::class, 'Cms' => Cms\Facades\Cms::class, + 'Composer' => System\Facades\Composer::class, 'Config' => Winter\Storm\Support\Facades\Config::class, 'DbDongle' => Winter\Storm\Support\Facades\DbDongle::class, 'File' => Winter\Storm\Support\Facades\File::class, diff --git a/modules/system/assets/css/updates/updates.css b/modules/system/assets/css/updates/updates.css index 3de4192d72..35e2a71159 100644 --- a/modules/system/assets/css/updates/updates.css +++ b/modules/system/assets/css/updates/updates.css @@ -1,116 +1 @@ -.important-update-label { - margin: 7px 0; -} -.control-updatelist { - border: 1px solid #ccc; - margin-bottom: 20px; -} -.control-updatelist .update-item { - border-bottom: 1px solid #ccc; -} -.control-updatelist .update-item .item-header { - background-color: #f5f5f5; - border-bottom: 1px solid #ccc; - padding: 0 10px; -} -.control-updatelist .update-item .item-header h5 { - margin: 0; - padding: 15px 0; - text-transform: uppercase; - font-size: 13px; -} -.control-updatelist .update-item .item-header h5 i { - margin-right: 7px; - color: #405261; -} -.control-updatelist .update-item .item-header h5 small { - text-transform: none; - float: right; - line-height: 13px; - margin-right: 5px; -} -.control-updatelist .update-item .item-header .important-update { - padding: 7px 0 0 0; - float: right; - width: 200px; -} -.control-updatelist .update-item dl { - padding: 10px; - margin-bottom: 0; -} -.control-updatelist .update-item dl:before, -.control-updatelist .update-item dl:after { - content: " "; - display: table; -} -.control-updatelist .update-item dl:after { - clear: both; -} -.control-updatelist .update-item dl dt, -.control-updatelist .update-item dl dd { - float: left; - padding: 5px 0; - line-height: 20px; -} -.control-updatelist .update-item dl dt.text-muted, -.control-updatelist .update-item dl dd.text-muted { - color: #999 !important; -} -.control-updatelist .update-item dl dt { - width: 15%; - clear: left; - font-size: 14px; - font-weight: 400; - color: #2b3e50; -} -.control-updatelist .update-item dl dd { - width: 85%; - font-size: 12px; - color: #455152; -} -.control-updatelist .update-item dl .important-update-label { - position: relative; - top: -1px; - background-color: #ab2a1c; - color: #fff; - display: inline-block; - padding: .2em .6em .3em; - font-size: 75%; - line-height: 1; - text-align: center; - white-space: nowrap; - vertical-align: baseline; - -webkit-border-radius: 0.25em; - -moz-border-radius: 0.25em; - border-radius: 0.25em; -} -.control-updatelist .update-item:last-child { - border-bottom: none; -} -.control-updatelist .update-item.item-danger .item-header { - background-color: #f2dede; -} -.control-updatelist .update-item.item-danger .item-header h5, -.control-updatelist .update-item.item-danger .item-header i, -.control-updatelist .update-item.item-danger .item-header { - color: #a94442; -} -.control-updatelist .update-item.item-success .item-header { - background-color: #dff0d8; -} -.control-updatelist .update-item.item-success .item-header h5, -.control-updatelist .update-item.item-success .item-header i, -.control-updatelist .update-item.item-success .item-header { - color: #3c763d; -} -.control-updatelist .update-item.item-muted { - border-bottom: none; -} -.control-updatelist .update-item.item-muted .item-header h5, -.control-updatelist .update-item.item-muted .item-header i, -.control-updatelist .update-item.item-muted .item-header { - color: rgba(0, 0, 0, 0.35); -} -.control-updatelist .update-item.item-muted dl { - display: none; -} +.important-update-label{margin:7px 0}.control-updatelist{border:1px solid #ccc;margin-bottom:20px}.control-updatelist .update-item{border-bottom:1px solid #ccc}.control-updatelist .update-item .item-header{background-color:#f5f5f5;border-bottom:1px solid #ccc;padding:0 10px}.control-updatelist .update-item .item-header h5{font-size:13px;margin:0;padding:15px 0;text-transform:uppercase}.control-updatelist .update-item .item-header h5 i{color:#405261;margin-right:7px}.control-updatelist .update-item .item-header h5 small{float:right;line-height:13px;margin-right:5px;text-transform:none}.control-updatelist .update-item .item-header .important-update{float:right;padding:7px 0 0;width:200px}.control-updatelist .update-item dl{margin-bottom:0;padding:10px}.control-updatelist .update-item dl:after,.control-updatelist .update-item dl:before{content:" ";display:table}.control-updatelist .update-item dl:after{clear:both}.control-updatelist .update-item dl dd,.control-updatelist .update-item dl dt{float:left;line-height:20px;padding:5px 0}.control-updatelist .update-item dl dd.text-muted,.control-updatelist .update-item dl dt.text-muted{color:#999!important}.control-updatelist .update-item dl dt{clear:left;color:#2b3e50;font-size:14px;font-weight:400;width:15%}.control-updatelist .update-item dl dd{color:#455152;font-size:12px;width:85%}.control-updatelist .update-item dl .important-update-label{background-color:#ab2a1c;border-radius:.25em;color:#fff;display:inline-block;font-size:75%;line-height:1;padding:.2em .6em .3em;position:relative;text-align:center;top:-1px;vertical-align:baseline;white-space:nowrap}.control-updatelist .update-item:last-child{border-bottom:none}.control-updatelist .update-item.item-danger .item-header{background-color:#f2dede}.control-updatelist .update-item.item-danger .item-header,.control-updatelist .update-item.item-danger .item-header h5,.control-updatelist .update-item.item-danger .item-header i{color:#a94442}.control-updatelist .update-item.item-success .item-header{background-color:#dff0d8}.control-updatelist .update-item.item-success .item-header,.control-updatelist .update-item.item-success .item-header h5,.control-updatelist .update-item.item-success .item-header i{color:#3c763d}.control-updatelist .update-item.item-muted{border-bottom:none}.control-updatelist .update-item.item-muted .item-header,.control-updatelist .update-item.item-muted .item-header h5,.control-updatelist .update-item.item-muted .item-header i{color:rgba(0,0,0,.35)}.control-updatelist .update-item.item-muted dl{display:none}.label-update{background-color:#5bc0de;border-radius:3px;color:#fff;display:inline-block;font-size:12px;font-weight:700;padding:1px 5px} diff --git a/modules/system/assets/js/build/manifest.js b/modules/system/assets/js/build/manifest.js index 6bb0026d28..7b8aa3fed4 100644 --- a/modules/system/assets/js/build/manifest.js +++ b/modules/system/assets/js/build/manifest.js @@ -1 +1 @@ -!function(){"use strict";var r,n={},e={};function t(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return n[r](i,i.exports,t),i.exports}t.m=n,r=[],t.O=function(n,e,o,i){if(!e){var u=1/0;for(a=0;a=i)&&Object.keys(t.O).every((function(r){return t.O[r](e[c])}))?e.splice(c--,1):(f=!1,i0&&r[a-1][2]>i;a--)r[a]=r[a-1];r[a]=[e,o,i]},t.d=function(r,n){for(var e in n)t.o(n,e)&&!t.o(r,e)&&Object.defineProperty(r,e,{enumerable:!0,get:n[e]})},t.o=function(r,n){return Object.prototype.hasOwnProperty.call(r,n)},function(){var r={911:0};t.O.j=function(n){return 0===r[n]};var n=function(n,e){var o,i,u=e[0],f=e[1],c=e[2],s=0;if(u.some((function(n){return 0!==r[n]}))){for(o in f)t.o(f,o)&&(t.m[o]=f[o]);if(c)var a=c(t)}for(n&&n(e);s=i)&&Object.keys(t.O).every((function(r){return t.O[r](e[c])}))?e.splice(c--,1):(f=!1,i0&&r[a-1][2]>i;a--)r[a]=r[a-1];r[a]=[e,o,i]},t.d=function(r,n){for(var e in n)t.o(n,e)&&!t.o(r,e)&&Object.defineProperty(r,e,{enumerable:!0,get:n[e]})},t.o=function(r,n){return Object.prototype.hasOwnProperty.call(r,n)},function(){var r={21:0,804:0};t.O.j=function(n){return 0===r[n]};var n=function(n,e){var o,i,u=e[0],f=e[1],c=e[2],s=0;if(u.some((function(n){return 0!==r[n]}))){for(o in f)t.o(f,o)&&(t.m[o]=f[o]);if(c)var a=c(t)}for(n&&n(e);s0)for(const t of e.js)try{await this.loadScript(t)}catch(e){return Promise.reject(e)}if(e.css&&e.css.length>0)for(const t of e.css)try{await this.loadStyle(t)}catch(e){return Promise.reject(e)}if(e.img&&e.img.length>0)for(const t of e.img)try{await this.loadImage(t)}catch(e){return Promise.reject(e)}return Promise.resolve()}loadScript(e){return new Promise(((t,s)=>{e=this.snowboard.url().asset(e);if(document.querySelector(`script[src="${e}"]`))return void t();const n=document.createElement("script");n.setAttribute("type","text/javascript"),n.setAttribute("src",e),n.addEventListener("load",(()=>{this.snowboard.globalEvent("assetLoader.loaded","script",e,n),t()})),n.addEventListener("error",(()=>{this.snowboard.globalEvent("assetLoader.error","script",e,n),s(new Error(`Unable to load script file: "${e}"`))})),document.body.append(n)}))}loadStyle(e){return new Promise(((t,s)=>{e=this.snowboard.url().asset(e);if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void t();const n=document.createElement("link");n.setAttribute("rel","stylesheet"),n.setAttribute("href",e),n.addEventListener("load",(()=>{this.snowboard.globalEvent("assetLoader.loaded","style",e,n),t()})),n.addEventListener("error",(()=>{this.snowboard.globalEvent("assetLoader.error","style",e,n),s(new Error(`Unable to load stylesheet file: "${e}"`))})),document.head.append(n)}))}loadImage(e){return new Promise(((t,s)=>{e=this.snowboard.url().asset(e);const n=new Image;n.addEventListener("load",(()=>{this.snowboard.globalEvent("assetLoader.loaded","image",e,n),t()})),n.addEventListener("error",(()=>{this.snowboard.globalEvent("assetLoader.error","image",e,n),s(new Error(`Unable to load image file: "${e}"`))})),n.src=e}))}}},553:function(e,t,s){s.d(t,{Z:function(){return i}});var n=s(281);class i extends n.Z{dependencies(){return["request"]}listens(){return{ajaxStart:"ajaxStart",ajaxDone:"ajaxDone"}}ajaxStart(e,t){if(t.element)if("FORM"===t.element.tagName){const e=t.element.querySelectorAll("[data-attach-loading]");e.length>0&&e.forEach((e=>{e.classList.add(this.getLoadingClass(e))}))}else void 0!==t.element.dataset.attachLoading&&t.element.classList.add(this.getLoadingClass(t.element))}ajaxDone(e,t){if(t.element)if("FORM"===t.element.tagName){const e=t.element.querySelectorAll("[data-attach-loading]");e.length>0&&e.forEach((e=>{e.classList.remove(this.getLoadingClass(e))}))}else void 0!==t.element.dataset.attachLoading&&t.element.classList.remove(this.getLoadingClass(t.element))}getLoadingClass(e){return void 0!==e.dataset.attachLoading&&""!==e.dataset.attachLoading?e.dataset.attachLoading:"wn-loading"}}},763:function(e,t,s){s.d(t,{Z:function(){return i}});var n=s(579);class i extends n.Z{construct(e,t,s){if(e instanceof n.Z==!1)throw new Error("You must provide a Snowboard plugin to enable data configuration");if(t instanceof HTMLElement==!1)throw new Error("Data configuration can only be extracted from HTML elements");this.instance=e,this.element=t,this.localConfig=s||{},this.instanceConfig={},this.acceptedConfigs={},this.refresh()}get(e){return void 0===e?this.instanceConfig:void 0!==this.instanceConfig[e]?this.instanceConfig[e]:void 0}set(e,t,s){if(void 0===e)throw new Error("You must provide a configuration key to set");this.instanceConfig[e]=t,!0===s&&(this.element.dataset[e]=t,this.localConfig[e]=t)}refresh(){this.acceptedConfigs=this.getAcceptedConfigs(),this.instanceConfig=this.processConfig()}getAcceptedConfigs(){return void 0!==this.instance.acceptAllDataConfigs&&!0===this.instance.acceptAllDataConfigs||void 0!==this.instance.defaults&&"function"==typeof this.instance.defaults&&"object"==typeof this.instance.defaults()&&Object.keys(this.instance.defaults())}getDefaults(){return void 0!==this.instance.defaults&&"function"==typeof this.instance.defaults&&"object"==typeof this.instance.defaults()?this.instance.defaults():{}}processConfig(){const e=this.getDefaults();if(!1===this.acceptedConfigs)return e;for(const t in this.element.dataset)(!0===this.acceptedConfigs||this.acceptedConfigs.includes(t))&&(e[t]=this.coerceValue(this.element.dataset[t]));for(const t in this.localConfig)(!0===this.acceptedConfigs||this.acceptedConfigs.includes(t))&&(e[t]=this.localConfig[t]);return e}coerceValue(e){const t=String(e);if("null"===t)return null;if("undefined"!==t){if(t.startsWith("base64:")){const e=t.replace(/^base64:/,""),s=atob(e);return this.coerceValue(s)}if(["true","yes"].includes(t.toLowerCase()))return!0;if(["false","no"].includes(t.toLowerCase()))return!1;if(/^[-+]?[0-9]+(\.[0-9]+)?$/.test(t))return Number(t);try{return this.snowboard.jsonParser().parse(t)}catch(e){return""===t||t}}}}},270:function(e,t,s){s.d(t,{Z:function(){return i}});var n=s(579);class i extends n.Z{construct(e,t,s){if(this.message=e,this.type=t||"default",this.duration=Number(s||7),this.duration<0)throw new Error("Flash duration must be a positive number, or zero");this.clear(),this.timer=null,this.flashTimer=null,this.create()}dependencies(){return["transition"]}destruct(){null!==this.timer&&window.clearTimeout(this.timer),this.flashTimer&&this.flashTimer.remove(),this.flash&&(this.flash.remove(),this.flash=null,this.flashTimer=null),super.destruct()}create(){this.snowboard.globalEvent("flash.create",this),this.flash=document.createElement("DIV"),this.flash.innerHTML=this.message,this.flash.classList.add("flash-message",this.type),this.flash.removeAttribute("data-control"),this.flash.addEventListener("click",(()=>this.remove())),this.flash.addEventListener("mouseover",(()=>this.stopTimer())),this.flash.addEventListener("mouseout",(()=>this.startTimer())),this.duration>0?(this.flashTimer=document.createElement("DIV"),this.flashTimer.classList.add("flash-timer"),this.flash.appendChild(this.flashTimer)):this.flash.classList.add("no-timer"),document.body.appendChild(this.flash),this.snowboard.transition(this.flash,"show",(()=>{this.startTimer()}))}remove(){this.snowboard.globalEvent("flash.remove",this),this.stopTimer(),this.snowboard.transition(this.flash,"hide",(()=>{this.flash.remove(),this.flash=null,this.destruct()}))}clear(){document.querySelectorAll("body > div.flash-message").forEach((e=>e.remove()))}startTimer(){0!==this.duration&&(this.timerTrans=this.snowboard.transition(this.flashTimer,"timeout",null,`${this.duration}.0s`,!0),this.timer=window.setTimeout((()=>this.remove()),1e3*this.duration))}stopTimer(){this.timerTrans&&this.timerTrans.cancel(),this.timer&&window.clearTimeout(this.timer)}}},277:function(e,t,s){s.d(t,{Z:function(){return i}});var n=s(281);class i extends n.Z{dependencies(){return["request"]}listens(){return{ready:"ready",ajaxStart:"ajaxStart"}}ready(){this.counter=0,this.createStripe()}ajaxStart(e,t){!1!==t.options.stripe&&(this.show(),e.then((()=>{this.hide()})).catch((()=>{this.hide()})))}createStripe(){this.indicator=document.createElement("DIV"),this.stripe=document.createElement("DIV"),this.stripeLoaded=document.createElement("DIV"),this.indicator.classList.add("stripe-loading-indicator","loaded"),this.stripe.classList.add("stripe"),this.stripeLoaded.classList.add("stripe-loaded"),this.indicator.appendChild(this.stripe),this.indicator.appendChild(this.stripeLoaded),document.body.appendChild(this.indicator)}show(){this.counter+=1;const e=this.stripe.cloneNode(!0);this.indicator.appendChild(e),this.stripe.remove(),this.stripe=e,this.counter>1||(this.indicator.classList.remove("loaded"),document.body.classList.add("wn-loading"))}hide(e){this.counter-=1,!0===e&&(this.counter=0),this.counter<=0&&(this.indicator.classList.add("loaded"),document.body.classList.remove("wn-loading"))}}},32:function(e,t,s){s.d(t,{Z:function(){return i}});var n=s(281);class i extends n.Z{listens(){return{ready:"ready"}}ready(){let e=!1;if(document.querySelectorAll('link[rel="stylesheet"]').forEach((t=>{t.href.endsWith("/modules/system/assets/css/snowboard.extras.css")&&(e=!0)})),!e){const e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("href",this.snowboard.url().asset("/modules/system/assets/css/snowboard.extras.css")),document.head.appendChild(e)}}}},269:function(e,t,s){s.d(t,{Z:function(){return i}});var n=s(579);class i extends n.Z{construct(e,t,s,n,i){if(e instanceof HTMLElement==!1)throw new Error("A HTMLElement must be provided for transitioning");if(this.element=e,"string"!=typeof t)throw new Error("Transition name must be specified as a string");if(this.transition=t,s&&"function"!=typeof s)throw new Error("Callback must be a valid function");this.callback=s,this.duration=n?this.parseDuration(n):null,this.trailTo=!0===i,this.doTransition()}eventClasses(){for(var e=arguments.length,t=new Array(e),s=0;s{const[s,n]=e;-1!==t.indexOf(s)&&i.push(n)})),i}doTransition(){null!==this.duration&&(this.element.style.transitionDuration=this.duration),this.resetClasses(),this.eventClasses("in","active").forEach((e=>{this.element.classList.add(e)})),window.requestAnimationFrame((()=>{"0s"!==window.getComputedStyle(this.element)["transition-duration"]?(this.element.addEventListener("transitionend",(()=>this.onTransitionEnd()),{once:!0}),window.requestAnimationFrame((()=>{this.element.classList.remove(this.eventClasses("in")[0]),this.element.classList.add(this.eventClasses("out")[0])}))):(this.resetClasses(),this.callback&&this.callback.apply(this.element),this.destruct())}))}onTransitionEnd(){this.eventClasses("active",this.trailTo?"":"out").forEach((e=>{this.element.classList.remove(e)})),this.callback&&this.callback.apply(this.element),null!==this.duration&&(this.element.style.transitionDuration=null),this.destruct()}cancel(){this.element.removeEventListener("transitionend",(()=>this.onTransitionEnd),{once:!0}),this.resetClasses(),null!==this.duration&&(this.element.style.transitionDuration=null),this.destruct()}resetClasses(){this.eventClasses().forEach((e=>{this.element.classList.remove(e)}))}parseDuration(e){const t=/^([0-9]+(\.[0-9]+)?)(m?s)?$/.exec(e),s=Number(t[1]);return"sec"===("s"===t[3]?"sec":"msec")?1e3*s+"ms":`${Math.floor(s)}ms`}}},662:function(e,t){t.Z={get(e,t,s){if("string"==typeof t){const s=t.toLowerCase();if(e.hasPlugin(s))return function(){return Reflect.get(e,"plugins")[s].getInstance(...arguments)}}return Reflect.get(e,t,s)},has(e,t){if("string"==typeof t){const s=t.toLowerCase();if(e.hasPlugin(s))return!0}return Reflect.has(e,t)}}},286:function(e,t,s){s.d(t,{Z:function(){return g}});var n=s(579),i=s(281),r={get(e,t,s){if("string"==typeof t){const s=t.toLowerCase();if(["attachAbstracts","loadUtilities","initialise","initialiseSingletons"].includes(t))throw new Error(`You cannot use the "${t}" Snowboard method within a plugin.`);if(e.hasPlugin(s))return function(){return Reflect.get(e,"plugins")[s].getInstance(...arguments)}}return Reflect.get(e,t,s)},has(e,t){if("string"==typeof t){const s=t.toLowerCase();if(["attachAbstracts","loadUtilities","initialise","initialiseSingletons"].includes(t))return!1;if(e.hasPlugin(s))return!0}return Reflect.has(e,t)}};class o{constructor(e,t,s){this.name=e,this.snowboard=new Proxy(t,r),this.instance=s,Object.freeze(this.instance),this.instances=[],this.singleton={initialised:!1},Object.seal(this.singleton),this.mocks={},this.originalFunctions={},Object.freeze(o.prototype),Object.freeze(this)}hasMethod(e){return!this.isFunction()&&"function"==typeof this.instance.prototype[e]}callMethod(){if(this.isFunction())return null;for(var e=arguments.length,t=new Array(e),s=0;s!this.snowboard.getPluginNames().includes(e)));throw new Error(`The "${this.name}" plugin requires the following plugins: ${e.join(", ")}`)}if(this.isSingleton())return 0===this.instances.length&&this.initialiseSingleton(...s),Object.keys(this.mocks).length>0&&(Object.entries(this.originalFunctions).forEach((e=>{const[t,s]=e;this.instances[0][t]=s})),Object.entries(this.mocks).forEach((t=>{const[s,n]=t;this.instances[0][s]=function(){for(var t=arguments.length,s=new Array(t),i=0;i0&&(Object.entries(this.originalFunctions).forEach((e=>{const[t,s]=e;this.instance.prototype[t]=s})),Object.entries(this.mocks).forEach((t=>{const[s,n]=t;this.instance.prototype[s]=function(){for(var t=arguments.length,s=new Array(t),i=0;ithis.instances.splice(this.instances.indexOf(i),1),i.construct(...s),this.instances.push(i),i}getInstances(){return this.isFunction()?[]:this.instances}isFunction(){return"function"==typeof this.instance&&this.instance.prototype instanceof n.Z==!1}isSingleton(){return this.instance.prototype instanceof i.Z==!0}isInitialised(){return!this.isSingleton()||this.singleton.initialised}initialiseSingleton(){if(!this.isSingleton())return;for(var e=arguments.length,t=new Array(e),s=0;sthis.instances.splice(this.instances.indexOf(n),1),n.construct(...t),this.instances.push(n),this.singleton.initialised=!0}getDependencies(){return this.isFunction()||"function"!=typeof this.instance.prototype.dependencies?[]:this.instance.prototype.dependencies().map((e=>e.toLowerCase()))}dependenciesFulfilled(){const e=this.getDependencies();let t=!0;return e.forEach((e=>{this.snowboard.hasPlugin(e)||(t=!1)})),t}mock(e,t){var s=this;if(!this.isFunction()){if(!this.instance.prototype[e])throw new Error(`Function "${e}" does not exist and cannot be mocked`);this.mocks[e]=t,this.originalFunctions[e]=this.instance.prototype[e],this.isSingleton()&&0===this.instances.length&&(this.initialiseSingleton(),this.instances[0][e]=function(){for(var e=arguments.length,n=new Array(e),i=0;i{const[t,s]=e;void 0!==this.defaults[t]&&(this.defaults[t]=s)}))}getDefaults(){const e={};return Object.entries(this.defaults).forEach((t=>{const[s,n]=t;null!==this.defaults[s]&&(e[s]=n)})),e}get(e){if(void 0===e){const e=a.Z.get();return Object.entries(e).forEach((t=>{const[s,n]=t;this.snowboard.globalEvent("cookie.get",s,n,(t=>{e[s]=t}))})),e}let t=a.Z.get(e);return this.snowboard.globalEvent("cookie.get",e,t,(e=>{t=e})),t}set(e,t,s){let n=t;return this.snowboard.globalEvent("cookie.set",e,t,(e=>{n=e})),a.Z.set(e,n,h(h({},this.getDefaults()),s))}remove(e,t){a.Z.remove(e,h(h({},this.getDefaults()),t))}}class u extends i.Z{construct(){window.wnJSON=e=>this.parse(e),window.ocJSON=window.wnJSON}parse(e){const t=this.parseString(e);return JSON.parse(t)}parseString(e){let t=e.trim();if(!t.length)throw new Error("Broken JSON object.");let s="",n=null,i=null,r="";for(;t&&","===t[0];)t=t.substr(1);if('"'===t[0]||"'"===t[0]){if(t[t.length-1]!==t[0])throw new Error("Invalid string JSON object.");r='"';for(let e=1;e="0"&&e[t]<="9"){s="";for(let n=t;n="0"&&e[n]<="9"))return{originLength:s.length,body:s};s+=e[n]}throw new Error(`Broken JSON number body near ${s}`)}if("{"===e[t]||"["===e[t]){const n=[e[t]];s=e[t];for(let i=t+1;i=0?t-5:0,50)}`)}parseKey(e,t,s){let n="";for(let i=t;i="a"&&e[0]<="z"||e[0]>="A"&&e[0]<="Z"||"_"===e[0]||(e[0]>="0"&&e[0]<="9"||("$"===e[0]||e.charCodeAt(0)>255)))}isBlankChar(e){return" "===e||"\n"===e||"\t"===e}}class f extends i.Z{construct(){window.wnSanitize=e=>this.sanitize(e),window.ocSanitize=window.wnSanitize}sanitize(e,t){const s=(new DOMParser).parseFromString(e,"text/html"),n=void 0===t||"boolean"!=typeof t||t;return this.sanitizeNode(s.getRootNode()),n?s.body.innerHTML:s.innerHTML}sanitizeNode(e){if("SCRIPT"===e.tagName)return void e.remove();this.trimAttributes(e);Array.from(e.children).forEach((e=>{this.sanitizeNode(e)}))}trimAttributes(e){if(e.attributes)for(let t=0;t{this.autoInitSingletons&&this.initialiseSingletons(),this.globalEvent("ready"),this.readiness.dom=!0}))}initialiseSingletons(){Object.values(this.plugins).forEach((e=>{e.isSingleton()&&e.dependenciesFulfilled()&&e.initialiseSingleton()}))}addPlugin(e,t){const s=e.toLowerCase();if(this.hasPlugin(s))throw new Error(`A plugin called "${e}" is already registered.`);if("function"!=typeof t&&t instanceof n.Z==!1)throw new Error("The provided plugin must extend the PluginBase class, or must be a callback function.");if(void 0!==this[e]||void 0!==this[s])throw new Error("The given name is already in use for a property or method of the Snowboard class.");this.plugins[s]=new o(s,this,t),this.debug(`Plugin "${e}" registered`),Object.values(this.getPlugins()).forEach((e=>{if(e.isSingleton()&&!e.isInitialised()&&e.dependenciesFulfilled()&&e.hasMethod("listens")&&Object.keys(e.callMethod("listens")).includes("ready")&&this.readiness.dom){const t=e.callMethod("listens").ready;e.callMethod(t)}}))}removePlugin(e){const t=e.toLowerCase();this.hasPlugin(t)?(this.plugins[t].getInstances().forEach((e=>{e.destruct()})),delete this.plugins[t],delete this[t],delete this[e],this.debug(`Plugin "${e}" removed`)):this.debug(`Plugin "${e}" already removed`)}hasPlugin(e){const t=e.toLowerCase();return void 0!==this.plugins[t]}getPlugins(){return this.plugins}getPluginNames(){return Object.keys(this.plugins)}getPlugin(e){const t=e.toLowerCase();if(!this.hasPlugin(t))throw new Error(`No plugin called "${t}" has been registered.`);return this.plugins[t]}listensToEvent(e){const t=[];return Object.entries(this.plugins).forEach((s=>{const[n,i]=s;if(i.isFunction())return;if(!i.dependenciesFulfilled())return;if(!i.hasMethod("listens"))return;const r=i.callMethod("listens");"string"!=typeof r[e]&&"function"!=typeof r[e]||t.push(n)})),t}ready(e){this.readiness.dom&&e(),this.on("ready",e)}on(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].includes(t)||this.listeners[e].push(t)}off(e,t){if(!this.listeners[e])return;const s=this.listeners[e].indexOf(t);-1!==s&&this.listeners[e].splice(s,1)}globalEvent(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),n=1;n{const n=this.getPlugin(t);if(n.isFunction())return;n.isSingleton()&&0===n.getInstances().length&&n.initialiseSingleton();const i=n.callMethod("listens")[e];n.getInstances().forEach((n=>{if(!r)if("function"==typeof i)try{!1===i.apply(n,s)&&(r=!0)}catch(s){this.error(`Error thrown in "${e}" event by "${t}" plugin.`,s)}else if("string"==typeof i){if(!n[i])throw new Error(`Missing "${i}" method in "${t}" plugin`);try{!1===n[i](...s)&&(r=!0,this.debug(`Global event "${e}" cancelled by "${t}" plugin`))}catch(s){this.error(`Error thrown in "${e}" event by "${t}" plugin.`,s)}}else this.error(`Listen method for "${e}" event in "${t}" plugin is not a function or string.`)}))})),!r&&this.listeners[e]&&this.listeners[e].length>0&&(this.debug(`Found ${this.listeners[e].length} ad-hoc listener(s) for global event "${e}"`),this.listeners[e].forEach((t=>{if(!r)try{!1===t(...s)&&(r=!0,this.debug(`Global event "${e} cancelled by an ad-hoc listener.`))}catch(t){this.error(`Error thrown in "${e}" event by an ad-hoc listener.`,t)}}))),!r}globalPromiseEvent(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),n=1;n{const n=this.getPlugin(t);if(n.isFunction())return;n.isSingleton()&&0===n.getInstances().length&&n.initialiseSingleton();const i=n.callMethod("listens")[e];n.getInstances().forEach((n=>{if("function"==typeof i)try{const e=i.apply(n,s);if(e instanceof Promise==!1)return;r.push(e)}catch(s){this.error(`Error thrown in "${e}" event by "${t}" plugin.`,s)}else if("string"==typeof i){if(!n[i])throw new Error(`Missing "${i}" method in "${t}" plugin`);try{const e=n[i](...s);if(e instanceof Promise==!1)return;r.push(e)}catch(s){this.error(`Error thrown in "${e}" promise event by "${t}" plugin.`,s)}}else this.error(`Listen method for "${e}" event in "${t}" plugin is not a function or string.`)}))})),this.listeners[e]&&this.listeners[e].length>0&&(this.debug(`Found ${this.listeners[e].length} ad-hoc listener(s) for global promise event "${e}"`),this.listeners[e].forEach((t=>{try{const e=t(...s);if(e instanceof Promise==!1)return;r.push(e)}catch(t){this.error(`Error thrown in "${e}" promise event by an ad-hoc listener.`,t)}}))),0===r.length?Promise.resolve():Promise.all(r)}logMessage(e,t,s){console.groupCollapsed("%c[Snowboard]",`color: ${e}; font-weight: ${t?"bold":"normal"};`,s);for(var n=arguments.length,i=new Array(n>3?n-3:0),r=3;r{e+=1,console.log(`%c${e}:`,"color: rgb(88, 88, 88); font-weight: normal;",t)})),console.groupEnd(),console.groupCollapsed("%cTrace","color: rgb(45, 167, 199); font-weight: bold;"),console.trace(),console.groupEnd()}else console.trace();console.groupEnd()}log(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),n=1;n1?t-1:0),n=1;n1?t-1:0),n=1;n{const t=new Proxy(new n.Z(!0,!0),i.Z);e.snowboard=t,e.Snowboard=t,e.SnowBoard=t})(window)},640:function(e,t,s){var n=s(579);function i(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,n)}return s}function r(e){for(var t=1;t{e&&this.doAjax().then((e=>{if(e.cancelled)return this.cancelled=!0,void this.complete();this.responseData=e,this.processUpdate(e).then((()=>{!1===e.X_WINTER_SUCCESS?this.processError(e):this.processResponse(e)}))}),(e=>{this.responseError=e,this.processError(e)}))})):this.doAjax().then((e=>{if(e.cancelled)return this.cancelled=!0,void this.complete();this.responseData=e,this.processUpdate(e).then((()=>{!1===e.X_WINTER_SUCCESS?this.processError(e):this.processResponse(e)}))}),(e=>{this.responseError=e,this.processError(e)})):this.cancelled=!0}else this.cancelled=!0}dependencies(){return["cookie","jsonParser"]}checkRequest(){if(this.element&&this.element instanceof Element==!1)throw new Error("The element provided must be an Element instance");if(void 0===this.handler)throw new Error("The AJAX handler name is not specified.");if(!this.isHandlerName(this.handler))throw new Error('Invalid AJAX handler name. The correct handler name format is: "onEvent".')}getFetch(){return this.fetchOptions=void 0!==this.options.fetchOptions&&"object"==typeof this.options.fetchOptions?this.options.fetchOptions:{method:"POST",headers:this.headers,body:this.data,redirect:"follow",mode:"same-origin"},this.snowboard.globalEvent("ajaxFetchOptions",this.fetchOptions,this),fetch(this.url,this.fetchOptions)}doClientValidation(){return!0!==this.options.browserValidate||!this.form||!1!==this.form.checkValidity()||(this.form.reportValidity(),!1)}doAjax(){if(!1===this.snowboard.globalEvent("ajaxBeforeSend",this))return Promise.resolve({cancelled:!0});const e=new Promise(((e,t)=>{this.getFetch().then((s=>{s.ok||406===s.status?s.headers.has("Content-Type")&&s.headers.get("Content-Type").includes("/json")?s.json().then((t=>{e(r(r({},t),{},{X_WINTER_SUCCESS:406!==s.status,X_WINTER_RESPONSE_CODE:s.status}))}),(e=>{t(this.renderError(`Unable to parse JSON response: ${e}`))})):s.text().then((t=>{e(t)}),(e=>{t(this.renderError(`Unable to process response: ${e}`))})):s.headers.has("Content-Type")&&s.headers.get("Content-Type").includes("/json")?s.json().then((e=>{e.message&&e.exception?t(this.renderError(e.message,e.exception,e.file,e.line,e.trace)):t(e)}),(e=>{t(this.renderError(`Unable to parse JSON response: ${e}`))})):s.text().then((e=>{t(this.renderError(e))}),(e=>{t(this.renderError(`Unable to process response: ${e}`))}))}),(e=>{t(this.renderError(`Unable to retrieve a response from the server: ${e}`))}))}));if(this.snowboard.globalEvent("ajaxStart",e,this),this.element){const t=new Event("ajaxPromise");t.promise=e,this.element.dispatchEvent(t)}return e}processUpdate(e){return new Promise(((t,s)=>{if("function"==typeof this.options.beforeUpdate&&!1===this.options.beforeUpdate.apply(this,[e]))return void t();const n={};if(Object.entries(e).forEach((e=>{const[t,s]=e;"X_WINTER"!==t.substr(0,8)&&(n[t]=s)})),0===Object.keys(n).length)return void(e.X_WINTER_ASSETS?this.processAssets(e.X_WINTER_ASSETS).then((()=>{t()}),(()=>{s()})):t());this.snowboard.globalPromiseEvent("ajaxBeforeUpdate",e,this).then((async()=>{e.X_WINTER_ASSETS&&await this.processAssets(e.X_WINTER_ASSETS),this.doUpdate(n).then((()=>{window.requestAnimationFrame((()=>t()))}),(()=>{s()}))}),(()=>{t()}))}))}doUpdate(e){return new Promise((t=>{const s=[];Object.entries(e).forEach((e=>{const[t,n]=e;let i=this.options.update&&this.options.update[t]?this.options.update[t]:t,r="replace";"@"===i.substr(0,1)?(r="append",i=i.substr(1)):"^"===i.substr(0,1)?(r="prepend",i=i.substr(1)):"#"!==i.substr(0,1)&&"."!==i.substr(0,1)&&(r="noop");const o=document.querySelectorAll(i);o.length>0&&o.forEach((e=>{switch(r){case"append":e.innerHTML+=n;break;case"prepend":e.innerHTML=n+e.innerHTML;break;case"noop":break;default:e.innerHTML=n}s.push(e),this.snowboard.globalEvent("ajaxUpdate",e,n,this);const t=new Event("ajaxUpdate");t.content=n,e.dispatchEvent(t)}))})),this.snowboard.globalEvent("ajaxUpdateComplete",s,this),t()}))}processResponse(e){if((!this.options.success||"function"!=typeof this.options.success||!1!==this.options.success(this.responseData,this))&&!1!==this.snowboard.globalEvent("ajaxSuccess",this.responseData,this)){if(this.element){const e=new Event("ajaxDone",{cancelable:!0});if(e.responseData=this.responseData,e.request=this,this.element.dispatchEvent(e),e.defaultPrevented)return}this.flash&&e.X_WINTER_FLASH_MESSAGES&&this.processFlashMessages(e.X_WINTER_FLASH_MESSAGES),this.redirect||e.X_WINTER_REDIRECT?this.processRedirect(this.redirect||e.X_WINTER_REDIRECT):this.complete()}}processError(e){if((!this.options.error||"function"!=typeof this.options.error||!1!==this.options.error(this.responseError,this))&&!1!==this.snowboard.globalEvent("ajaxError",this.responseError,this)){if(this.element){const e=new Event("ajaxFail",{cancelable:!0});if(e.responseError=this.responseError,e.request=this,this.element.dispatchEvent(e),e.defaultPrevented)return}if(e instanceof Error)this.processErrorMessage(e.message);else{let t=!1;e.X_WINTER_ERROR_FIELDS&&(t=this.processValidationErrors(e.X_WINTER_ERROR_FIELDS)),e.X_WINTER_ERROR_MESSAGE&&!t&&this.processErrorMessage(e.X_WINTER_ERROR_MESSAGE)}this.complete()}}processRedirect(e){"function"==typeof this.options.handleRedirectResponse&&!1===this.options.handleRedirectResponse.apply(this,[e])||!1!==this.snowboard.globalEvent("ajaxRedirect",e,this)&&(window.addEventListener("popstate",(()=>{if(this.element){const e=document.createEvent("CustomEvent");e.eventName="ajaxRedirected",this.element.dispatchEvent(e)}}),{once:!0}),window.location.assign(e))}processErrorMessage(e){"function"==typeof this.options.handleErrorMessage&&!1===this.options.handleErrorMessage.apply(this,[e])||!1!==this.snowboard.globalEvent("ajaxErrorMessage",e,this)&&window.alert(e)}processFlashMessages(e){"function"==typeof this.options.handleFlashMessages&&!1===this.options.handleFlashMessages.apply(this,[e])||this.snowboard.globalEvent("ajaxFlashMessages",e,this)}processValidationErrors(e){return"function"==typeof this.options.handleValidationErrors&&!1===this.options.handleValidationErrors.apply(this,[this.form,e])||!1===this.snowboard.globalEvent("ajaxValidationErrors",this.form,e,this)}processAssets(e){return this.snowboard.globalPromiseEvent("ajaxLoadAssets",e)}async doConfirm(){if("function"==typeof this.options.handleConfirmMessage)return!1!==this.options.handleConfirmMessage.apply(this,[this.confirm]);if(0===this.snowboard.listensToEvent("ajaxConfirmMessage").length)return window.confirm(this.confirm);const e=this.snowboard.globalPromiseEvent("ajaxConfirmMessage",this.confirm,this);try{if(await e)return!0}catch(e){return!1}return!1}complete(){if(this.options.complete&&"function"==typeof this.options.complete&&this.options.complete(this.responseData,this),this.snowboard.globalEvent("ajaxDone",this.responseData,this),this.element){const e=new Event("ajaxAlways");e.request=this,e.responseData=this.responseData,e.responseError=this.responseError,this.element.dispatchEvent(e)}this.destruct()}get form(){return this.options.form?"string"==typeof this.options.form?document.querySelector(this.options.form):this.options.form:this.element?"FORM"===this.element.tagName?this.element:this.element.closest("form"):null}get context(){return{handler:this.handler,options:this.options}}get headers(){const e={"X-Requested-With":"XMLHttpRequest","X-WINTER-REQUEST-HANDLER":this.handler,"X-WINTER-REQUEST-PARTIALS":this.extractPartials(this.options.update||[])};return this.flash&&(e["X-WINTER-REQUEST-FLASH"]=1),this.xsrfToken&&(e["X-XSRF-TOKEN"]=this.xsrfToken),e}get loading(){return this.options.loading||!1}get url(){return this.options.url||window.location.href}get redirect(){return this.options.redirect&&this.options.redirect.length?this.options.redirect:null}get flash(){return this.options.flash||!1}get files(){return!0===this.options.files&&(void 0!==FormData||(this.snowboard.debug("This browser does not support file uploads"),!1))}get xsrfToken(){return this.snowboard.cookie().get("XSRF-TOKEN")}get data(){const e="object"==typeof this.options.data?this.options.data:{},t=new FormData(this.form||void 0);return Object.keys(e).length>0&&Object.entries(e).forEach((e=>{const[s,n]=e;t.append(s,n)})),t}get confirm(){return this.options.confirm||!1}extractPartials(e){return Object.keys(e).join("&")}renderError(e,t,s,n,i){const r=new Error(e);return r.exception=t||null,r.file=s||null,r.line=n||null,r.trace=i||[],r}isHandlerName(e){return/^(?:\w+:{2})?on[A-Z0-9]/.test(e)}}if(void 0===window.Snowboard)throw new Error("Snowboard must be loaded in order to use the Javascript AJAX request feature.");window.Snowboard.addPlugin("request",a)}},function(e){var t=function(t){return e(e.s=t)};e.O(0,[109],(function(){return t(165),t(640),t(136)}));e.O()}]); \ No newline at end of file +"use strict";(self.webpackChunk_wintercms_wn_system_module=self.webpackChunk_wintercms_wn_system_module||[]).push([[639,38,813],{660:function(e,t,s){s.d(t,{A:function(){return n}});class n{constructor(e){this.snowboard=e}construct(){}dependencies(){return[]}listens(){return{}}destruct(){this.detach(),delete this.snowboard}destructor(){this.destruct()}}},373:function(e,t,s){s.d(t,{A:function(){return i}});var n=s(660);class i extends n.A{}},477:function(e,t,s){s.d(t,{A:function(){return i}});var n=s(373);class i extends n.A{listens(){return{ajaxLoadAssets:"load"}}dependencies(){return["url"]}async load(e){if(e.js&&e.js.length>0)for(const t of e.js)try{await this.loadScript(t)}catch(e){return Promise.reject(e)}if(e.css&&e.css.length>0)for(const t of e.css)try{await this.loadStyle(t)}catch(e){return Promise.reject(e)}if(e.img&&e.img.length>0)for(const t of e.img)try{await this.loadImage(t)}catch(e){return Promise.reject(e)}return Promise.resolve()}loadScript(e){return new Promise(((t,s)=>{e=this.snowboard.url().asset(e);if(document.querySelector(`script[src="${e}"]`))return void t();const n=document.createElement("script");n.setAttribute("type","text/javascript"),n.setAttribute("src",e),n.addEventListener("load",(()=>{this.snowboard.globalEvent("assetLoader.loaded","script",e,n),t()})),n.addEventListener("error",(()=>{this.snowboard.globalEvent("assetLoader.error","script",e,n),s(new Error(`Unable to load script file: "${e}"`))})),document.body.append(n)}))}loadStyle(e){return new Promise(((t,s)=>{e=this.snowboard.url().asset(e);if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void t();const n=document.createElement("link");n.setAttribute("rel","stylesheet"),n.setAttribute("href",e),n.addEventListener("load",(()=>{this.snowboard.globalEvent("assetLoader.loaded","style",e,n),t()})),n.addEventListener("error",(()=>{this.snowboard.globalEvent("assetLoader.error","style",e,n),s(new Error(`Unable to load stylesheet file: "${e}"`))})),document.head.append(n)}))}loadImage(e){return new Promise(((t,s)=>{e=this.snowboard.url().asset(e);const n=new Image;n.addEventListener("load",(()=>{this.snowboard.globalEvent("assetLoader.loaded","image",e,n),t()})),n.addEventListener("error",(()=>{this.snowboard.globalEvent("assetLoader.error","image",e,n),s(new Error(`Unable to load image file: "${e}"`))})),n.src=e}))}}},293:function(e,t,s){s.d(t,{A:function(){return i}});var n=s(373);class i extends n.A{dependencies(){return["request"]}listens(){return{ajaxStart:"ajaxStart",ajaxDone:"ajaxDone"}}ajaxStart(e,t){if(t.element)if("FORM"===t.element.tagName){const e=t.element.querySelectorAll("[data-attach-loading]");e.length>0&&e.forEach((e=>{e.classList.add(this.getLoadingClass(e))}))}else void 0!==t.element.dataset.attachLoading&&t.element.classList.add(this.getLoadingClass(t.element))}ajaxDone(e,t){if(t.element)if("FORM"===t.element.tagName){const e=t.element.querySelectorAll("[data-attach-loading]");e.length>0&&e.forEach((e=>{e.classList.remove(this.getLoadingClass(e))}))}else void 0!==t.element.dataset.attachLoading&&t.element.classList.remove(this.getLoadingClass(t.element))}getLoadingClass(e){return void 0!==e.dataset.attachLoading&&""!==e.dataset.attachLoading?e.dataset.attachLoading:"wn-loading"}}},490:function(e,t,s){s.d(t,{A:function(){return i}});var n=s(660);class i extends n.A{construct(e,t,s){if(e instanceof n.A==!1)throw new Error("You must provide a Snowboard plugin to enable data configuration");if(t instanceof HTMLElement==!1)throw new Error("Data configuration can only be extracted from HTML elements");this.instance=e,this.element=t,this.localConfig=s||{},this.instanceConfig={},this.acceptedConfigs={},this.refresh()}get(e){return void 0===e?this.instanceConfig:void 0!==this.instanceConfig[e]?this.instanceConfig[e]:void 0}set(e,t,s){if(void 0===e)throw new Error("You must provide a configuration key to set");this.instanceConfig[e]=t,!0===s&&(this.element.dataset[e]=t,this.localConfig[e]=t)}refresh(){this.acceptedConfigs=this.getAcceptedConfigs(),this.instanceConfig=this.processConfig()}getAcceptedConfigs(){return void 0!==this.instance.acceptAllDataConfigs&&!0===this.instance.acceptAllDataConfigs||void 0!==this.instance.defaults&&"function"==typeof this.instance.defaults&&"object"==typeof this.instance.defaults()&&Object.keys(this.instance.defaults())}getDefaults(){return void 0!==this.instance.defaults&&"function"==typeof this.instance.defaults&&"object"==typeof this.instance.defaults()?this.instance.defaults():{}}processConfig(){const e=this.getDefaults();if(!1===this.acceptedConfigs)return e;for(const t in this.element.dataset)(!0===this.acceptedConfigs||this.acceptedConfigs.includes(t))&&(e[t]=this.coerceValue(this.element.dataset[t]));for(const t in this.localConfig)(!0===this.acceptedConfigs||this.acceptedConfigs.includes(t))&&(e[t]=this.localConfig[t]);return e}coerceValue(e){const t=String(e);if("null"===t)return null;if("undefined"!==t){if(t.startsWith("base64:")){const e=t.replace(/^base64:/,""),s=atob(e);return this.coerceValue(s)}if(["true","yes"].includes(t.toLowerCase()))return!0;if(["false","no"].includes(t.toLowerCase()))return!1;if(/^[-+]?[0-9]+(\.[0-9]+)?$/.test(t))return Number(t);try{return this.snowboard.jsonParser().parse(t)}catch(e){return""===t||t}}}}},336:function(e,t,s){s.d(t,{A:function(){return i}});var n=s(660);class i extends n.A{construct(e,t,s){if(this.message=e,this.type=t||"default",this.duration=Number(s||7),this.duration<0)throw new Error("Flash duration must be a positive number, or zero");this.clear(),this.timer=null,this.flashTimer=null,this.create()}dependencies(){return["transition"]}destruct(){null!==this.timer&&window.clearTimeout(this.timer),this.flashTimer&&this.flashTimer.remove(),this.flash&&(this.flash.remove(),this.flash=null,this.flashTimer=null),super.destruct()}create(){this.snowboard.globalEvent("flash.create",this),this.flash=document.createElement("DIV"),this.flash.innerHTML=this.message,this.flash.classList.add("flash-message",this.type),this.flash.removeAttribute("data-control"),this.flash.addEventListener("click",(()=>this.remove())),this.flash.addEventListener("mouseover",(()=>this.stopTimer())),this.flash.addEventListener("mouseout",(()=>this.startTimer())),this.duration>0?(this.flashTimer=document.createElement("DIV"),this.flashTimer.classList.add("flash-timer"),this.flash.appendChild(this.flashTimer)):this.flash.classList.add("no-timer"),document.body.appendChild(this.flash),this.snowboard.transition(this.flash,"show",(()=>{this.startTimer()}))}remove(){this.snowboard.globalEvent("flash.remove",this),this.stopTimer(),this.snowboard.transition(this.flash,"hide",(()=>{this.flash.remove(),this.flash=null,this.destruct()}))}clear(){document.querySelectorAll("body > div.flash-message").forEach((e=>e.remove()))}startTimer(){0!==this.duration&&(this.timerTrans=this.snowboard.transition(this.flashTimer,"timeout",null,`${this.duration}.0s`,!0),this.timer=window.setTimeout((()=>this.remove()),1e3*this.duration))}stopTimer(){this.timerTrans&&this.timerTrans.cancel(),this.timer&&window.clearTimeout(this.timer)}}},758:function(e,t,s){s.d(t,{A:function(){return i}});var n=s(373);class i extends n.A{dependencies(){return["request"]}listens(){return{ready:"ready",ajaxStart:"ajaxStart"}}ready(){this.counter=0,this.createStripe()}ajaxStart(e,t){!1!==t.options.stripe&&(this.show(),e.then((()=>{this.hide()})).catch((()=>{this.hide()})))}createStripe(){this.indicator=document.createElement("DIV"),this.stripe=document.createElement("DIV"),this.stripeLoaded=document.createElement("DIV"),this.indicator.classList.add("stripe-loading-indicator","loaded"),this.stripe.classList.add("stripe"),this.stripeLoaded.classList.add("stripe-loaded"),this.indicator.appendChild(this.stripe),this.indicator.appendChild(this.stripeLoaded),document.body.appendChild(this.indicator)}show(){this.counter+=1;const e=this.stripe.cloneNode(!0);this.indicator.appendChild(e),this.stripe.remove(),this.stripe=e,this.counter>1||(this.indicator.classList.remove("loaded"),document.body.classList.add("wn-loading"))}hide(e){this.counter-=1,!0===e&&(this.counter=0),this.counter<=0&&(this.indicator.classList.add("loaded"),document.body.classList.remove("wn-loading"))}}},75:function(e,t,s){s.d(t,{A:function(){return i}});var n=s(373);class i extends n.A{listens(){return{ready:"ready"}}ready(){let e=!1;if(document.querySelectorAll('link[rel="stylesheet"]').forEach((t=>{t.href.endsWith("/modules/system/assets/css/snowboard.extras.css")&&(e=!0)})),!e){const e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("href",this.snowboard.url().asset("/modules/system/assets/css/snowboard.extras.css")),document.head.appendChild(e)}}}},843:function(e,t,s){s.d(t,{A:function(){return i}});var n=s(660);class i extends n.A{construct(e,t,s,n,i){if(e instanceof HTMLElement==!1)throw new Error("A HTMLElement must be provided for transitioning");if(this.element=e,"string"!=typeof t)throw new Error("Transition name must be specified as a string");if(this.transition=t,s&&"function"!=typeof s)throw new Error("Callback must be a valid function");this.callback=s,this.duration=n?this.parseDuration(n):null,this.trailTo=!0===i,this.doTransition()}eventClasses(){for(var e=arguments.length,t=new Array(e),s=0;s{const[s,n]=e;-1!==t.indexOf(s)&&i.push(n)})),i}doTransition(){null!==this.duration&&(this.element.style.transitionDuration=this.duration),this.resetClasses(),this.eventClasses("in","active").forEach((e=>{this.element.classList.add(e)})),window.requestAnimationFrame((()=>{"0s"!==window.getComputedStyle(this.element)["transition-duration"]?(this.element.addEventListener("transitionend",(()=>this.onTransitionEnd()),{once:!0}),window.requestAnimationFrame((()=>{this.element.classList.remove(this.eventClasses("in")[0]),this.element.classList.add(this.eventClasses("out")[0])}))):(this.resetClasses(),this.callback&&this.callback.apply(this.element),this.destruct())}))}onTransitionEnd(){this.eventClasses("active",this.trailTo?"":"out").forEach((e=>{this.element.classList.remove(e)})),this.callback&&this.callback.apply(this.element),null!==this.duration&&(this.element.style.transitionDuration=null),this.destruct()}cancel(){this.element.removeEventListener("transitionend",(()=>this.onTransitionEnd),{once:!0}),this.resetClasses(),null!==this.duration&&(this.element.style.transitionDuration=null),this.destruct()}resetClasses(){this.eventClasses().forEach((e=>{this.element.classList.remove(e)}))}parseDuration(e){const t=/^([0-9]+(\.[0-9]+)?)(m?s)?$/.exec(e),s=Number(t[1]);return"sec"===("s"===t[3]?"sec":"msec")?1e3*s+"ms":`${Math.floor(s)}ms`}}},54:function(e,t){t.A={get(e,t,s){if("string"==typeof t){const s=t.toLowerCase();if(e.hasPlugin(s))return function(){return Reflect.get(e,"plugins")[s].getInstance(...arguments)}}return Reflect.get(e,t,s)},has(e,t){if("string"==typeof t){const s=t.toLowerCase();if(e.hasPlugin(s))return!0}return Reflect.has(e,t)}}},160:function(e,t,s){s.d(t,{A:function(){return g}});var n=s(660),i=s(373),r={get(e,t,s){if("string"==typeof t){const s=t.toLowerCase();if(["attachAbstracts","loadUtilities","initialise","initialiseSingletons"].includes(t))throw new Error(`You cannot use the "${t}" Snowboard method within a plugin.`);if(e.hasPlugin(s))return function(){return Reflect.get(e,"plugins")[s].getInstance(...arguments)}}return Reflect.get(e,t,s)},has(e,t){if("string"==typeof t){const s=t.toLowerCase();if(["attachAbstracts","loadUtilities","initialise","initialiseSingletons"].includes(t))return!1;if(e.hasPlugin(s))return!0}return Reflect.has(e,t)}};class o{constructor(e,t,s){this.name=e,this.snowboard=new Proxy(t,r),this.instance=s,Object.freeze(this.instance),this.instances=[],this.singleton={initialised:!1},Object.seal(this.singleton),this.mocks={},this.originalFunctions={},Object.freeze(o.prototype),Object.freeze(this)}hasMethod(e){return!this.isFunction()&&"function"==typeof this.instance.prototype[e]}callMethod(){if(this.isFunction())return null;for(var e=arguments.length,t=new Array(e),s=0;s!this.snowboard.getPluginNames().includes(e)));throw new Error(`The "${this.name}" plugin requires the following plugins: ${e.join(", ")}`)}if(this.isSingleton())return 0===this.instances.length&&this.initialiseSingleton(...s),Object.keys(this.mocks).length>0&&(Object.entries(this.originalFunctions).forEach((e=>{const[t,s]=e;this.instances[0][t]=s})),Object.entries(this.mocks).forEach((t=>{const[s,n]=t;this.instances[0][s]=function(){for(var t=arguments.length,s=new Array(t),i=0;i0&&(Object.entries(this.originalFunctions).forEach((e=>{const[t,s]=e;this.instance.prototype[t]=s})),Object.entries(this.mocks).forEach((t=>{const[s,n]=t;this.instance.prototype[s]=function(){for(var t=arguments.length,s=new Array(t),i=0;ithis.instances.splice(this.instances.indexOf(i),1),i.construct(...s),this.instances.push(i),i}getInstances(){return this.isFunction()?[]:this.instances}isFunction(){return"function"==typeof this.instance&&this.instance.prototype instanceof n.A==!1}isSingleton(){return this.instance.prototype instanceof i.A==!0}isInitialised(){return!this.isSingleton()||this.singleton.initialised}initialiseSingleton(){if(!this.isSingleton())return;for(var e=arguments.length,t=new Array(e),s=0;sthis.instances.splice(this.instances.indexOf(n),1),n.construct(...t),this.instances.push(n),this.singleton.initialised=!0}getDependencies(){return this.isFunction()||"function"!=typeof this.instance.prototype.dependencies?[]:this.instance.prototype.dependencies().map((e=>e.toLowerCase()))}dependenciesFulfilled(){const e=this.getDependencies();let t=!0;return e.forEach((e=>{this.snowboard.hasPlugin(e)||(t=!1)})),t}mock(e,t){var s=this;if(!this.isFunction()){if(!this.instance.prototype[e])throw new Error(`Function "${e}" does not exist and cannot be mocked`);this.mocks[e]=t,this.originalFunctions[e]=this.instance.prototype[e],this.isSingleton()&&0===this.instances.length&&(this.initialiseSingleton(),this.instances[0][e]=function(){for(var e=arguments.length,n=new Array(e),i=0;i{const[t,s]=e;void 0!==this.defaults[t]&&(this.defaults[t]=s)}))}getDefaults(){const e={};return Object.entries(this.defaults).forEach((t=>{const[s,n]=t;null!==this.defaults[s]&&(e[s]=n)})),e}get(e){if(void 0===e){const e=a.A.get();return Object.entries(e).forEach((t=>{const[s,n]=t;this.snowboard.globalEvent("cookie.get",s,n,(t=>{e[s]=t}))})),e}let t=a.A.get(e);return this.snowboard.globalEvent("cookie.get",e,t,(e=>{t=e})),t}set(e,t,s){let n=t;return this.snowboard.globalEvent("cookie.set",e,t,(e=>{n=e})),a.A.set(e,n,h(h({},this.getDefaults()),s))}remove(e,t){a.A.remove(e,h(h({},this.getDefaults()),t))}}class u extends i.A{construct(){window.wnJSON=e=>this.parse(e),window.ocJSON=window.wnJSON}parse(e){const t=this.parseString(e);return JSON.parse(t)}parseString(e){let t=e.trim();if(!t.length)throw new Error("Broken JSON object.");let s="",n=null,i=null,r="";for(;t&&","===t[0];)t=t.substr(1);if('"'===t[0]||"'"===t[0]){if(t[t.length-1]!==t[0])throw new Error("Invalid string JSON object.");r='"';for(let e=1;e="0"&&e[t]<="9"){s="";for(let n=t;n="0"&&e[n]<="9"))return{originLength:s.length,body:s};s+=e[n]}throw new Error(`Broken JSON number body near ${s}`)}if("{"===e[t]||"["===e[t]){const n=[e[t]];s=e[t];for(let i=t+1;i=0?t-5:0,50)}`)}parseKey(e,t,s){let n="";for(let i=t;i="a"&&e[0]<="z"||e[0]>="A"&&e[0]<="Z"||"_"===e[0]||(e[0]>="0"&&e[0]<="9"||("$"===e[0]||e.charCodeAt(0)>255)))}isBlankChar(e){return" "===e||"\n"===e||"\t"===e}}class f extends i.A{construct(){window.wnSanitize=e=>this.sanitize(e),window.ocSanitize=window.wnSanitize}sanitize(e,t){const s=(new DOMParser).parseFromString(e,"text/html"),n=void 0===t||"boolean"!=typeof t||t;return this.sanitizeNode(s.getRootNode()),n?s.body.innerHTML:s.innerHTML}sanitizeNode(e){if("SCRIPT"===e.tagName)return void e.remove();this.trimAttributes(e);Array.from(e.children).forEach((e=>{this.sanitizeNode(e)}))}trimAttributes(e){if(e.attributes)for(let t=0;t{this.autoInitSingletons&&this.initialiseSingletons(),this.globalEvent("ready"),this.readiness.dom=!0}))}initialiseSingletons(){Object.values(this.plugins).forEach((e=>{e.isSingleton()&&e.dependenciesFulfilled()&&e.initialiseSingleton()}))}addPlugin(e,t){const s=e.toLowerCase();if(this.hasPlugin(s))throw new Error(`A plugin called "${e}" is already registered.`);if("function"!=typeof t&&t instanceof n.A==!1)throw new Error("The provided plugin must extend the PluginBase class, or must be a callback function.");if(void 0!==this[e]||void 0!==this[s])throw new Error("The given name is already in use for a property or method of the Snowboard class.");this.plugins[s]=new o(s,this,t),this.debug(`Plugin "${e}" registered`),Object.values(this.getPlugins()).forEach((e=>{if(e.isSingleton()&&!e.isInitialised()&&e.dependenciesFulfilled()&&e.hasMethod("listens")&&Object.keys(e.callMethod("listens")).includes("ready")&&this.readiness.dom){const t=e.callMethod("listens").ready;e.callMethod(t)}}))}removePlugin(e){const t=e.toLowerCase();this.hasPlugin(t)?(this.plugins[t].getInstances().forEach((e=>{e.destruct()})),delete this.plugins[t],delete this[t],delete this[e],this.debug(`Plugin "${e}" removed`)):this.debug(`Plugin "${e}" already removed`)}hasPlugin(e){const t=e.toLowerCase();return void 0!==this.plugins[t]}getPlugins(){return this.plugins}getPluginNames(){return Object.keys(this.plugins)}getPlugin(e){const t=e.toLowerCase();if(!this.hasPlugin(t))throw new Error(`No plugin called "${t}" has been registered.`);return this.plugins[t]}listensToEvent(e){const t=[];return Object.entries(this.plugins).forEach((s=>{const[n,i]=s;if(i.isFunction())return;if(!i.dependenciesFulfilled())return;if(!i.hasMethod("listens"))return;const r=i.callMethod("listens");"string"!=typeof r[e]&&"function"!=typeof r[e]||t.push(n)})),t}ready(e){this.readiness.dom&&e(),this.on("ready",e)}on(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].includes(t)||this.listeners[e].push(t)}off(e,t){if(!this.listeners[e])return;const s=this.listeners[e].indexOf(t);-1!==s&&this.listeners[e].splice(s,1)}globalEvent(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),n=1;n{const n=this.getPlugin(t);if(n.isFunction())return;n.isSingleton()&&0===n.getInstances().length&&n.initialiseSingleton();const i=n.callMethod("listens")[e];n.getInstances().forEach((n=>{if(!r)if("function"==typeof i)try{!1===i.apply(n,s)&&(r=!0)}catch(s){this.error(`Error thrown in "${e}" event by "${t}" plugin.`,s)}else if("string"==typeof i){if(!n[i])throw new Error(`Missing "${i}" method in "${t}" plugin`);try{!1===n[i](...s)&&(r=!0,this.debug(`Global event "${e}" cancelled by "${t}" plugin`))}catch(s){this.error(`Error thrown in "${e}" event by "${t}" plugin.`,s)}}else this.error(`Listen method for "${e}" event in "${t}" plugin is not a function or string.`)}))})),!r&&this.listeners[e]&&this.listeners[e].length>0&&(this.debug(`Found ${this.listeners[e].length} ad-hoc listener(s) for global event "${e}"`),this.listeners[e].forEach((t=>{if(!r)try{!1===t(...s)&&(r=!0,this.debug(`Global event "${e} cancelled by an ad-hoc listener.`))}catch(t){this.error(`Error thrown in "${e}" event by an ad-hoc listener.`,t)}}))),!r}globalPromiseEvent(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),n=1;n{const n=this.getPlugin(t);if(n.isFunction())return;n.isSingleton()&&0===n.getInstances().length&&n.initialiseSingleton();const i=n.callMethod("listens")[e];n.getInstances().forEach((n=>{if("function"==typeof i)try{const e=i.apply(n,s);if(e instanceof Promise==!1)return;r.push(e)}catch(s){this.error(`Error thrown in "${e}" event by "${t}" plugin.`,s)}else if("string"==typeof i){if(!n[i])throw new Error(`Missing "${i}" method in "${t}" plugin`);try{const e=n[i](...s);if(e instanceof Promise==!1)return;r.push(e)}catch(s){this.error(`Error thrown in "${e}" promise event by "${t}" plugin.`,s)}}else this.error(`Listen method for "${e}" event in "${t}" plugin is not a function or string.`)}))})),this.listeners[e]&&this.listeners[e].length>0&&(this.debug(`Found ${this.listeners[e].length} ad-hoc listener(s) for global promise event "${e}"`),this.listeners[e].forEach((t=>{try{const e=t(...s);if(e instanceof Promise==!1)return;r.push(e)}catch(t){this.error(`Error thrown in "${e}" promise event by an ad-hoc listener.`,t)}}))),0===r.length?Promise.resolve():Promise.all(r)}logMessage(e,t,s){console.groupCollapsed("%c[Snowboard]",`color: ${e}; font-weight: ${t?"bold":"normal"};`,s);for(var n=arguments.length,i=new Array(n>3?n-3:0),r=3;r{e+=1,console.log(`%c${e}:`,"color: rgb(88, 88, 88); font-weight: normal;",t)})),console.groupEnd(),console.groupCollapsed("%cTrace","color: rgb(45, 167, 199); font-weight: bold;"),console.trace(),console.groupEnd()}else console.trace();console.groupEnd()}log(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),n=1;n1?t-1:0),n=1;n1?t-1:0),n=1;n{const t=new Proxy(new n.A(!0,!0),i.A);e.snowboard=t,e.Snowboard=t,e.SnowBoard=t})(window)},59:function(e,t,s){var n=s(660);function i(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,n)}return s}function r(e){for(var t=1;t{e&&this.doAjax().then((e=>{if(e.cancelled)return this.cancelled=!0,void this.complete();this.responseData=e,this.processUpdate(e).then((()=>{!1===e.X_WINTER_SUCCESS?this.processError(e):this.processResponse(e)}))}),(e=>{this.responseError=e,this.processError(e)}))})):this.doAjax().then((e=>{if(e.cancelled)return this.cancelled=!0,void this.complete();this.responseData=e,this.processUpdate(e).then((()=>{!1===e.X_WINTER_SUCCESS?this.processError(e):this.processResponse(e)}))}),(e=>{this.responseError=e,this.processError(e)})):this.cancelled=!0}else this.cancelled=!0}dependencies(){return["cookie","jsonParser"]}checkRequest(){if(this.element&&this.element instanceof Element==!1)throw new Error("The element provided must be an Element instance");if(void 0===this.handler)throw new Error("The AJAX handler name is not specified.");if(!this.isHandlerName(this.handler))throw new Error('Invalid AJAX handler name. The correct handler name format is: "onEvent".')}getFetch(){return this.fetchOptions=void 0!==this.options.fetchOptions&&"object"==typeof this.options.fetchOptions?this.options.fetchOptions:{method:"POST",headers:this.headers,body:this.data,redirect:"follow",mode:"same-origin"},this.snowboard.globalEvent("ajaxFetchOptions",this.fetchOptions,this),fetch(this.url,this.fetchOptions)}doClientValidation(){return!0!==this.options.browserValidate||!this.form||!1!==this.form.checkValidity()||(this.form.reportValidity(),!1)}doAjax(){if(!1===this.snowboard.globalEvent("ajaxBeforeSend",this))return Promise.resolve({cancelled:!0});const e=new Promise(((e,t)=>{this.getFetch().then((s=>{s.ok||406===s.status?s.headers.has("Content-Type")&&s.headers.get("Content-Type").includes("/json")?s.json().then((t=>{e(r(r({},t),{},{X_WINTER_SUCCESS:406!==s.status,X_WINTER_RESPONSE_CODE:s.status}))}),(e=>{t(this.renderError(`Unable to parse JSON response: ${e}`))})):s.text().then((t=>{e(t)}),(e=>{t(this.renderError(`Unable to process response: ${e}`))})):s.headers.has("Content-Type")&&s.headers.get("Content-Type").includes("/json")?s.json().then((e=>{e.message&&e.exception?t(this.renderError(e.message,e.exception,e.file,e.line,e.trace)):t(e)}),(e=>{t(this.renderError(`Unable to parse JSON response: ${e}`))})):s.text().then((e=>{t(this.renderError(e))}),(e=>{t(this.renderError(`Unable to process response: ${e}`))}))}),(e=>{t(this.renderError(`Unable to retrieve a response from the server: ${e}`))}))}));if(this.snowboard.globalEvent("ajaxStart",e,this),this.element){const t=new Event("ajaxPromise");t.promise=e,this.element.dispatchEvent(t)}return e}processUpdate(e){return new Promise(((t,s)=>{if("function"==typeof this.options.beforeUpdate&&!1===this.options.beforeUpdate.apply(this,[e]))return void t();const n={};if(Object.entries(e).forEach((e=>{const[t,s]=e;"X_WINTER"!==t.substr(0,8)&&(n[t]=s)})),0===Object.keys(n).length)return void(e.X_WINTER_ASSETS?this.processAssets(e.X_WINTER_ASSETS).then((()=>{t()}),(()=>{s()})):t());this.snowboard.globalPromiseEvent("ajaxBeforeUpdate",e,this).then((async()=>{e.X_WINTER_ASSETS&&await this.processAssets(e.X_WINTER_ASSETS),this.doUpdate(n).then((()=>{window.requestAnimationFrame((()=>t()))}),(()=>{s()}))}),(()=>{t()}))}))}doUpdate(e){return new Promise((t=>{const s=[];Object.entries(e).forEach((e=>{const[t,n]=e;let i=this.options.update&&this.options.update[t]?this.options.update[t]:t,r="replace";"@"===i.substr(0,1)?(r="append",i=i.substr(1)):"^"===i.substr(0,1)?(r="prepend",i=i.substr(1)):"#"!==i.substr(0,1)&&"."!==i.substr(0,1)&&(r="noop");const o=document.querySelectorAll(i);o.length>0&&o.forEach((e=>{switch(r){case"append":e.innerHTML+=n;break;case"prepend":e.innerHTML=n+e.innerHTML;break;case"noop":break;default:e.innerHTML=n}s.push(e),this.snowboard.globalEvent("ajaxUpdate",e,n,this);const t=new Event("ajaxUpdate");t.content=n,e.dispatchEvent(t)}))})),this.snowboard.globalEvent("ajaxUpdateComplete",s,this),t()}))}processResponse(e){if((!this.options.success||"function"!=typeof this.options.success||!1!==this.options.success(this.responseData,this))&&!1!==this.snowboard.globalEvent("ajaxSuccess",this.responseData,this)){if(this.element){const e=new Event("ajaxDone",{cancelable:!0});if(e.responseData=this.responseData,e.request=this,this.element.dispatchEvent(e),e.defaultPrevented)return}this.flash&&e.X_WINTER_FLASH_MESSAGES&&this.processFlashMessages(e.X_WINTER_FLASH_MESSAGES),this.redirect||e.X_WINTER_REDIRECT?this.processRedirect(this.redirect||e.X_WINTER_REDIRECT):this.complete()}}processError(e){if((!this.options.error||"function"!=typeof this.options.error||!1!==this.options.error(this.responseError,this))&&!1!==this.snowboard.globalEvent("ajaxError",this.responseError,this)){if(this.element){const e=new Event("ajaxFail",{cancelable:!0});if(e.responseError=this.responseError,e.request=this,this.element.dispatchEvent(e),e.defaultPrevented)return}if(e instanceof Error)this.processErrorMessage(e.message);else{let t=!1;e.X_WINTER_ERROR_FIELDS&&(t=this.processValidationErrors(e.X_WINTER_ERROR_FIELDS)),e.X_WINTER_ERROR_MESSAGE&&!t&&this.processErrorMessage(e.X_WINTER_ERROR_MESSAGE)}this.complete()}}processRedirect(e){"function"==typeof this.options.handleRedirectResponse&&!1===this.options.handleRedirectResponse.apply(this,[e])||!1!==this.snowboard.globalEvent("ajaxRedirect",e,this)&&(window.addEventListener("popstate",(()=>{if(this.element){const e=document.createEvent("CustomEvent");e.eventName="ajaxRedirected",this.element.dispatchEvent(e)}}),{once:!0}),window.location.assign(e))}processErrorMessage(e){"function"==typeof this.options.handleErrorMessage&&!1===this.options.handleErrorMessage.apply(this,[e])||!1!==this.snowboard.globalEvent("ajaxErrorMessage",e,this)&&window.alert(e)}processFlashMessages(e){"function"==typeof this.options.handleFlashMessages&&!1===this.options.handleFlashMessages.apply(this,[e])||this.snowboard.globalEvent("ajaxFlashMessages",e,this)}processValidationErrors(e){return"function"==typeof this.options.handleValidationErrors&&!1===this.options.handleValidationErrors.apply(this,[this.form,e])||!1===this.snowboard.globalEvent("ajaxValidationErrors",this.form,e,this)}processAssets(e){return this.snowboard.globalPromiseEvent("ajaxLoadAssets",e)}async doConfirm(){if("function"==typeof this.options.handleConfirmMessage)return!1!==this.options.handleConfirmMessage.apply(this,[this.confirm]);if(0===this.snowboard.listensToEvent("ajaxConfirmMessage").length)return window.confirm(this.confirm);const e=this.snowboard.globalPromiseEvent("ajaxConfirmMessage",this.confirm,this);try{if(await e)return!0}catch(e){return!1}return!1}complete(){if(this.options.complete&&"function"==typeof this.options.complete&&this.options.complete(this.responseData,this),this.snowboard.globalEvent("ajaxDone",this.responseData,this),this.element){const e=new Event("ajaxAlways");e.request=this,e.responseData=this.responseData,e.responseError=this.responseError,this.element.dispatchEvent(e)}this.destruct()}get form(){return this.options.form?"string"==typeof this.options.form?document.querySelector(this.options.form):this.options.form:this.element?"FORM"===this.element.tagName?this.element:this.element.closest("form"):null}get context(){return{handler:this.handler,options:this.options}}get headers(){const e={"X-Requested-With":"XMLHttpRequest","X-WINTER-REQUEST-HANDLER":this.handler,"X-WINTER-REQUEST-PARTIALS":this.extractPartials(this.options.update||[])};return this.flash&&(e["X-WINTER-REQUEST-FLASH"]=1),this.xsrfToken&&(e["X-XSRF-TOKEN"]=this.xsrfToken),e}get loading(){return this.options.loading||!1}get url(){return this.options.url||window.location.href}get redirect(){return this.options.redirect&&this.options.redirect.length?this.options.redirect:null}get flash(){return this.options.flash||!1}get files(){return!0===this.options.files&&(void 0!==FormData||(this.snowboard.debug("This browser does not support file uploads"),!1))}get xsrfToken(){return this.snowboard.cookie().get("XSRF-TOKEN")}get data(){const e="object"==typeof this.options.data?this.options.data:{},t=new FormData(this.form||void 0);return Object.keys(e).length>0&&Object.entries(e).forEach((e=>{const[s,n]=e;t.append(s,n)})),t}get confirm(){return this.options.confirm||!1}extractPartials(e){return Object.keys(e).join("&")}renderError(e,t,s,n,i){const r=new Error(e);return r.exception=t||null,r.file=s||null,r.line=n||null,r.trace=i||[],r}isHandlerName(e){return/^(?:\w+:{2})?on[A-Z0-9]/.test(e)}}if(void 0===window.Snowboard)throw new Error("Snowboard must be loaded in order to use the Javascript AJAX request feature.");window.Snowboard.addPlugin("request",a)}},function(e){var t=function(t){return e(e.s=t)};e.O(0,[969],(function(){return t(799),t(59),t(590)}));e.O()}]); \ No newline at end of file diff --git a/modules/system/assets/js/build/system.js b/modules/system/assets/js/build/system.js index a60492e24d..eca1d7f532 100644 --- a/modules/system/assets/js/build/system.js +++ b/modules/system/assets/js/build/system.js @@ -1 +1 @@ -"use strict";(self.webpackChunk_wintercms_wn_system_module=self.webpackChunk_wintercms_wn_system_module||[]).push([[290,243,988],{579:function(e,t,s){s.d(t,{Z:function(){return n}});class n{constructor(e){this.snowboard=e}construct(){}dependencies(){return[]}listens(){return{}}destruct(){this.detach(),delete this.snowboard}destructor(){this.destruct()}}},281:function(e,t,s){s.d(t,{Z:function(){return i}});var n=s(579);class i extends n.Z{}},809:function(e,t,s){s.d(t,{Z:function(){return i}});var n=s(281);class i extends n.Z{listens(){return{ajaxLoadAssets:"load"}}dependencies(){return["url"]}async load(e){if(e.js&&e.js.length>0)for(const t of e.js)try{await this.loadScript(t)}catch(e){return Promise.reject(e)}if(e.css&&e.css.length>0)for(const t of e.css)try{await this.loadStyle(t)}catch(e){return Promise.reject(e)}if(e.img&&e.img.length>0)for(const t of e.img)try{await this.loadImage(t)}catch(e){return Promise.reject(e)}return Promise.resolve()}loadScript(e){return new Promise(((t,s)=>{e=this.snowboard.url().asset(e);if(document.querySelector(`script[src="${e}"]`))return void t();const n=document.createElement("script");n.setAttribute("type","text/javascript"),n.setAttribute("src",e),n.addEventListener("load",(()=>{this.snowboard.globalEvent("assetLoader.loaded","script",e,n),t()})),n.addEventListener("error",(()=>{this.snowboard.globalEvent("assetLoader.error","script",e,n),s(new Error(`Unable to load script file: "${e}"`))})),document.body.append(n)}))}loadStyle(e){return new Promise(((t,s)=>{e=this.snowboard.url().asset(e);if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void t();const n=document.createElement("link");n.setAttribute("rel","stylesheet"),n.setAttribute("href",e),n.addEventListener("load",(()=>{this.snowboard.globalEvent("assetLoader.loaded","style",e,n),t()})),n.addEventListener("error",(()=>{this.snowboard.globalEvent("assetLoader.error","style",e,n),s(new Error(`Unable to load stylesheet file: "${e}"`))})),document.head.append(n)}))}loadImage(e){return new Promise(((t,s)=>{e=this.snowboard.url().asset(e);const n=new Image;n.addEventListener("load",(()=>{this.snowboard.globalEvent("assetLoader.loaded","image",e,n),t()})),n.addEventListener("error",(()=>{this.snowboard.globalEvent("assetLoader.error","image",e,n),s(new Error(`Unable to load image file: "${e}"`))})),n.src=e}))}}},553:function(e,t,s){s.d(t,{Z:function(){return i}});var n=s(281);class i extends n.Z{dependencies(){return["request"]}listens(){return{ajaxStart:"ajaxStart",ajaxDone:"ajaxDone"}}ajaxStart(e,t){if(t.element)if("FORM"===t.element.tagName){const e=t.element.querySelectorAll("[data-attach-loading]");e.length>0&&e.forEach((e=>{e.classList.add(this.getLoadingClass(e))}))}else void 0!==t.element.dataset.attachLoading&&t.element.classList.add(this.getLoadingClass(t.element))}ajaxDone(e,t){if(t.element)if("FORM"===t.element.tagName){const e=t.element.querySelectorAll("[data-attach-loading]");e.length>0&&e.forEach((e=>{e.classList.remove(this.getLoadingClass(e))}))}else void 0!==t.element.dataset.attachLoading&&t.element.classList.remove(this.getLoadingClass(t.element))}getLoadingClass(e){return void 0!==e.dataset.attachLoading&&""!==e.dataset.attachLoading?e.dataset.attachLoading:"wn-loading"}}},763:function(e,t,s){s.d(t,{Z:function(){return i}});var n=s(579);class i extends n.Z{construct(e,t,s){if(e instanceof n.Z==!1)throw new Error("You must provide a Snowboard plugin to enable data configuration");if(t instanceof HTMLElement==!1)throw new Error("Data configuration can only be extracted from HTML elements");this.instance=e,this.element=t,this.localConfig=s||{},this.instanceConfig={},this.acceptedConfigs={},this.refresh()}get(e){return void 0===e?this.instanceConfig:void 0!==this.instanceConfig[e]?this.instanceConfig[e]:void 0}set(e,t,s){if(void 0===e)throw new Error("You must provide a configuration key to set");this.instanceConfig[e]=t,!0===s&&(this.element.dataset[e]=t,this.localConfig[e]=t)}refresh(){this.acceptedConfigs=this.getAcceptedConfigs(),this.instanceConfig=this.processConfig()}getAcceptedConfigs(){return void 0!==this.instance.acceptAllDataConfigs&&!0===this.instance.acceptAllDataConfigs||void 0!==this.instance.defaults&&"function"==typeof this.instance.defaults&&"object"==typeof this.instance.defaults()&&Object.keys(this.instance.defaults())}getDefaults(){return void 0!==this.instance.defaults&&"function"==typeof this.instance.defaults&&"object"==typeof this.instance.defaults()?this.instance.defaults():{}}processConfig(){const e=this.getDefaults();if(!1===this.acceptedConfigs)return e;for(const t in this.element.dataset)(!0===this.acceptedConfigs||this.acceptedConfigs.includes(t))&&(e[t]=this.coerceValue(this.element.dataset[t]));for(const t in this.localConfig)(!0===this.acceptedConfigs||this.acceptedConfigs.includes(t))&&(e[t]=this.localConfig[t]);return e}coerceValue(e){const t=String(e);if("null"===t)return null;if("undefined"!==t){if(t.startsWith("base64:")){const e=t.replace(/^base64:/,""),s=atob(e);return this.coerceValue(s)}if(["true","yes"].includes(t.toLowerCase()))return!0;if(["false","no"].includes(t.toLowerCase()))return!1;if(/^[-+]?[0-9]+(\.[0-9]+)?$/.test(t))return Number(t);try{return this.snowboard.jsonParser().parse(t)}catch(e){return""===t||t}}}}},270:function(e,t,s){s.d(t,{Z:function(){return i}});var n=s(579);class i extends n.Z{construct(e,t,s){if(this.message=e,this.type=t||"default",this.duration=Number(s||7),this.duration<0)throw new Error("Flash duration must be a positive number, or zero");this.clear(),this.timer=null,this.flashTimer=null,this.create()}dependencies(){return["transition"]}destruct(){null!==this.timer&&window.clearTimeout(this.timer),this.flashTimer&&this.flashTimer.remove(),this.flash&&(this.flash.remove(),this.flash=null,this.flashTimer=null),super.destruct()}create(){this.snowboard.globalEvent("flash.create",this),this.flash=document.createElement("DIV"),this.flash.innerHTML=this.message,this.flash.classList.add("flash-message",this.type),this.flash.removeAttribute("data-control"),this.flash.addEventListener("click",(()=>this.remove())),this.flash.addEventListener("mouseover",(()=>this.stopTimer())),this.flash.addEventListener("mouseout",(()=>this.startTimer())),this.duration>0?(this.flashTimer=document.createElement("DIV"),this.flashTimer.classList.add("flash-timer"),this.flash.appendChild(this.flashTimer)):this.flash.classList.add("no-timer"),document.body.appendChild(this.flash),this.snowboard.transition(this.flash,"show",(()=>{this.startTimer()}))}remove(){this.snowboard.globalEvent("flash.remove",this),this.stopTimer(),this.snowboard.transition(this.flash,"hide",(()=>{this.flash.remove(),this.flash=null,this.destruct()}))}clear(){document.querySelectorAll("body > div.flash-message").forEach((e=>e.remove()))}startTimer(){0!==this.duration&&(this.timerTrans=this.snowboard.transition(this.flashTimer,"timeout",null,`${this.duration}.0s`,!0),this.timer=window.setTimeout((()=>this.remove()),1e3*this.duration))}stopTimer(){this.timerTrans&&this.timerTrans.cancel(),this.timer&&window.clearTimeout(this.timer)}}},277:function(e,t,s){s.d(t,{Z:function(){return i}});var n=s(281);class i extends n.Z{dependencies(){return["request"]}listens(){return{ready:"ready",ajaxStart:"ajaxStart"}}ready(){this.counter=0,this.createStripe()}ajaxStart(e,t){!1!==t.options.stripe&&(this.show(),e.then((()=>{this.hide()})).catch((()=>{this.hide()})))}createStripe(){this.indicator=document.createElement("DIV"),this.stripe=document.createElement("DIV"),this.stripeLoaded=document.createElement("DIV"),this.indicator.classList.add("stripe-loading-indicator","loaded"),this.stripe.classList.add("stripe"),this.stripeLoaded.classList.add("stripe-loaded"),this.indicator.appendChild(this.stripe),this.indicator.appendChild(this.stripeLoaded),document.body.appendChild(this.indicator)}show(){this.counter+=1;const e=this.stripe.cloneNode(!0);this.indicator.appendChild(e),this.stripe.remove(),this.stripe=e,this.counter>1||(this.indicator.classList.remove("loaded"),document.body.classList.add("wn-loading"))}hide(e){this.counter-=1,!0===e&&(this.counter=0),this.counter<=0&&(this.indicator.classList.add("loaded"),document.body.classList.remove("wn-loading"))}}},32:function(e,t,s){s.d(t,{Z:function(){return i}});var n=s(281);class i extends n.Z{listens(){return{ready:"ready"}}ready(){let e=!1;if(document.querySelectorAll('link[rel="stylesheet"]').forEach((t=>{t.href.endsWith("/modules/system/assets/css/snowboard.extras.css")&&(e=!0)})),!e){const e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("href",this.snowboard.url().asset("/modules/system/assets/css/snowboard.extras.css")),document.head.appendChild(e)}}}},269:function(e,t,s){s.d(t,{Z:function(){return i}});var n=s(579);class i extends n.Z{construct(e,t,s,n,i){if(e instanceof HTMLElement==!1)throw new Error("A HTMLElement must be provided for transitioning");if(this.element=e,"string"!=typeof t)throw new Error("Transition name must be specified as a string");if(this.transition=t,s&&"function"!=typeof s)throw new Error("Callback must be a valid function");this.callback=s,this.duration=n?this.parseDuration(n):null,this.trailTo=!0===i,this.doTransition()}eventClasses(){for(var e=arguments.length,t=new Array(e),s=0;s{const[s,n]=e;-1!==t.indexOf(s)&&i.push(n)})),i}doTransition(){null!==this.duration&&(this.element.style.transitionDuration=this.duration),this.resetClasses(),this.eventClasses("in","active").forEach((e=>{this.element.classList.add(e)})),window.requestAnimationFrame((()=>{"0s"!==window.getComputedStyle(this.element)["transition-duration"]?(this.element.addEventListener("transitionend",(()=>this.onTransitionEnd()),{once:!0}),window.requestAnimationFrame((()=>{this.element.classList.remove(this.eventClasses("in")[0]),this.element.classList.add(this.eventClasses("out")[0])}))):(this.resetClasses(),this.callback&&this.callback.apply(this.element),this.destruct())}))}onTransitionEnd(){this.eventClasses("active",this.trailTo?"":"out").forEach((e=>{this.element.classList.remove(e)})),this.callback&&this.callback.apply(this.element),null!==this.duration&&(this.element.style.transitionDuration=null),this.destruct()}cancel(){this.element.removeEventListener("transitionend",(()=>this.onTransitionEnd),{once:!0}),this.resetClasses(),null!==this.duration&&(this.element.style.transitionDuration=null),this.destruct()}resetClasses(){this.eventClasses().forEach((e=>{this.element.classList.remove(e)}))}parseDuration(e){const t=/^([0-9]+(\.[0-9]+)?)(m?s)?$/.exec(e),s=Number(t[1]);return"sec"===("s"===t[3]?"sec":"msec")?1e3*s+"ms":`${Math.floor(s)}ms`}}},662:function(e,t){t.Z={get(e,t,s){if("string"==typeof t){const s=t.toLowerCase();if(e.hasPlugin(s))return function(){return Reflect.get(e,"plugins")[s].getInstance(...arguments)}}return Reflect.get(e,t,s)},has(e,t){if("string"==typeof t){const s=t.toLowerCase();if(e.hasPlugin(s))return!0}return Reflect.has(e,t)}}},286:function(e,t,s){s.d(t,{Z:function(){return g}});var n=s(579),i=s(281),r={get(e,t,s){if("string"==typeof t){const s=t.toLowerCase();if(["attachAbstracts","loadUtilities","initialise","initialiseSingletons"].includes(t))throw new Error(`You cannot use the "${t}" Snowboard method within a plugin.`);if(e.hasPlugin(s))return function(){return Reflect.get(e,"plugins")[s].getInstance(...arguments)}}return Reflect.get(e,t,s)},has(e,t){if("string"==typeof t){const s=t.toLowerCase();if(["attachAbstracts","loadUtilities","initialise","initialiseSingletons"].includes(t))return!1;if(e.hasPlugin(s))return!0}return Reflect.has(e,t)}};class o{constructor(e,t,s){this.name=e,this.snowboard=new Proxy(t,r),this.instance=s,Object.freeze(this.instance),this.instances=[],this.singleton={initialised:!1},Object.seal(this.singleton),this.mocks={},this.originalFunctions={},Object.freeze(o.prototype),Object.freeze(this)}hasMethod(e){return!this.isFunction()&&"function"==typeof this.instance.prototype[e]}callMethod(){if(this.isFunction())return null;for(var e=arguments.length,t=new Array(e),s=0;s!this.snowboard.getPluginNames().includes(e)));throw new Error(`The "${this.name}" plugin requires the following plugins: ${e.join(", ")}`)}if(this.isSingleton())return 0===this.instances.length&&this.initialiseSingleton(...s),Object.keys(this.mocks).length>0&&(Object.entries(this.originalFunctions).forEach((e=>{const[t,s]=e;this.instances[0][t]=s})),Object.entries(this.mocks).forEach((t=>{const[s,n]=t;this.instances[0][s]=function(){for(var t=arguments.length,s=new Array(t),i=0;i0&&(Object.entries(this.originalFunctions).forEach((e=>{const[t,s]=e;this.instance.prototype[t]=s})),Object.entries(this.mocks).forEach((t=>{const[s,n]=t;this.instance.prototype[s]=function(){for(var t=arguments.length,s=new Array(t),i=0;ithis.instances.splice(this.instances.indexOf(i),1),i.construct(...s),this.instances.push(i),i}getInstances(){return this.isFunction()?[]:this.instances}isFunction(){return"function"==typeof this.instance&&this.instance.prototype instanceof n.Z==!1}isSingleton(){return this.instance.prototype instanceof i.Z==!0}isInitialised(){return!this.isSingleton()||this.singleton.initialised}initialiseSingleton(){if(!this.isSingleton())return;for(var e=arguments.length,t=new Array(e),s=0;sthis.instances.splice(this.instances.indexOf(n),1),n.construct(...t),this.instances.push(n),this.singleton.initialised=!0}getDependencies(){return this.isFunction()||"function"!=typeof this.instance.prototype.dependencies?[]:this.instance.prototype.dependencies().map((e=>e.toLowerCase()))}dependenciesFulfilled(){const e=this.getDependencies();let t=!0;return e.forEach((e=>{this.snowboard.hasPlugin(e)||(t=!1)})),t}mock(e,t){var s=this;if(!this.isFunction()){if(!this.instance.prototype[e])throw new Error(`Function "${e}" does not exist and cannot be mocked`);this.mocks[e]=t,this.originalFunctions[e]=this.instance.prototype[e],this.isSingleton()&&0===this.instances.length&&(this.initialiseSingleton(),this.instances[0][e]=function(){for(var e=arguments.length,n=new Array(e),i=0;i{const[t,s]=e;void 0!==this.defaults[t]&&(this.defaults[t]=s)}))}getDefaults(){const e={};return Object.entries(this.defaults).forEach((t=>{const[s,n]=t;null!==this.defaults[s]&&(e[s]=n)})),e}get(e){if(void 0===e){const e=a.Z.get();return Object.entries(e).forEach((t=>{const[s,n]=t;this.snowboard.globalEvent("cookie.get",s,n,(t=>{e[s]=t}))})),e}let t=a.Z.get(e);return this.snowboard.globalEvent("cookie.get",e,t,(e=>{t=e})),t}set(e,t,s){let n=t;return this.snowboard.globalEvent("cookie.set",e,t,(e=>{n=e})),a.Z.set(e,n,h(h({},this.getDefaults()),s))}remove(e,t){a.Z.remove(e,h(h({},this.getDefaults()),t))}}class u extends i.Z{construct(){window.wnJSON=e=>this.parse(e),window.ocJSON=window.wnJSON}parse(e){const t=this.parseString(e);return JSON.parse(t)}parseString(e){let t=e.trim();if(!t.length)throw new Error("Broken JSON object.");let s="",n=null,i=null,r="";for(;t&&","===t[0];)t=t.substr(1);if('"'===t[0]||"'"===t[0]){if(t[t.length-1]!==t[0])throw new Error("Invalid string JSON object.");r='"';for(let e=1;e="0"&&e[t]<="9"){s="";for(let n=t;n="0"&&e[n]<="9"))return{originLength:s.length,body:s};s+=e[n]}throw new Error(`Broken JSON number body near ${s}`)}if("{"===e[t]||"["===e[t]){const n=[e[t]];s=e[t];for(let i=t+1;i=0?t-5:0,50)}`)}parseKey(e,t,s){let n="";for(let i=t;i="a"&&e[0]<="z"||e[0]>="A"&&e[0]<="Z"||"_"===e[0]||(e[0]>="0"&&e[0]<="9"||("$"===e[0]||e.charCodeAt(0)>255)))}isBlankChar(e){return" "===e||"\n"===e||"\t"===e}}class f extends i.Z{construct(){window.wnSanitize=e=>this.sanitize(e),window.ocSanitize=window.wnSanitize}sanitize(e,t){const s=(new DOMParser).parseFromString(e,"text/html"),n=void 0===t||"boolean"!=typeof t||t;return this.sanitizeNode(s.getRootNode()),n?s.body.innerHTML:s.innerHTML}sanitizeNode(e){if("SCRIPT"===e.tagName)return void e.remove();this.trimAttributes(e);Array.from(e.children).forEach((e=>{this.sanitizeNode(e)}))}trimAttributes(e){if(e.attributes)for(let t=0;t{this.autoInitSingletons&&this.initialiseSingletons(),this.globalEvent("ready"),this.readiness.dom=!0}))}initialiseSingletons(){Object.values(this.plugins).forEach((e=>{e.isSingleton()&&e.dependenciesFulfilled()&&e.initialiseSingleton()}))}addPlugin(e,t){const s=e.toLowerCase();if(this.hasPlugin(s))throw new Error(`A plugin called "${e}" is already registered.`);if("function"!=typeof t&&t instanceof n.Z==!1)throw new Error("The provided plugin must extend the PluginBase class, or must be a callback function.");if(void 0!==this[e]||void 0!==this[s])throw new Error("The given name is already in use for a property or method of the Snowboard class.");this.plugins[s]=new o(s,this,t),this.debug(`Plugin "${e}" registered`),Object.values(this.getPlugins()).forEach((e=>{if(e.isSingleton()&&!e.isInitialised()&&e.dependenciesFulfilled()&&e.hasMethod("listens")&&Object.keys(e.callMethod("listens")).includes("ready")&&this.readiness.dom){const t=e.callMethod("listens").ready;e.callMethod(t)}}))}removePlugin(e){const t=e.toLowerCase();this.hasPlugin(t)?(this.plugins[t].getInstances().forEach((e=>{e.destruct()})),delete this.plugins[t],delete this[t],delete this[e],this.debug(`Plugin "${e}" removed`)):this.debug(`Plugin "${e}" already removed`)}hasPlugin(e){const t=e.toLowerCase();return void 0!==this.plugins[t]}getPlugins(){return this.plugins}getPluginNames(){return Object.keys(this.plugins)}getPlugin(e){const t=e.toLowerCase();if(!this.hasPlugin(t))throw new Error(`No plugin called "${t}" has been registered.`);return this.plugins[t]}listensToEvent(e){const t=[];return Object.entries(this.plugins).forEach((s=>{const[n,i]=s;if(i.isFunction())return;if(!i.dependenciesFulfilled())return;if(!i.hasMethod("listens"))return;const r=i.callMethod("listens");"string"!=typeof r[e]&&"function"!=typeof r[e]||t.push(n)})),t}ready(e){this.readiness.dom&&e(),this.on("ready",e)}on(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].includes(t)||this.listeners[e].push(t)}off(e,t){if(!this.listeners[e])return;const s=this.listeners[e].indexOf(t);-1!==s&&this.listeners[e].splice(s,1)}globalEvent(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),n=1;n{const n=this.getPlugin(t);if(n.isFunction())return;n.isSingleton()&&0===n.getInstances().length&&n.initialiseSingleton();const i=n.callMethod("listens")[e];n.getInstances().forEach((n=>{if(!r)if("function"==typeof i)try{!1===i.apply(n,s)&&(r=!0)}catch(s){this.error(`Error thrown in "${e}" event by "${t}" plugin.`,s)}else if("string"==typeof i){if(!n[i])throw new Error(`Missing "${i}" method in "${t}" plugin`);try{!1===n[i](...s)&&(r=!0,this.debug(`Global event "${e}" cancelled by "${t}" plugin`))}catch(s){this.error(`Error thrown in "${e}" event by "${t}" plugin.`,s)}}else this.error(`Listen method for "${e}" event in "${t}" plugin is not a function or string.`)}))})),!r&&this.listeners[e]&&this.listeners[e].length>0&&(this.debug(`Found ${this.listeners[e].length} ad-hoc listener(s) for global event "${e}"`),this.listeners[e].forEach((t=>{if(!r)try{!1===t(...s)&&(r=!0,this.debug(`Global event "${e} cancelled by an ad-hoc listener.`))}catch(t){this.error(`Error thrown in "${e}" event by an ad-hoc listener.`,t)}}))),!r}globalPromiseEvent(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),n=1;n{const n=this.getPlugin(t);if(n.isFunction())return;n.isSingleton()&&0===n.getInstances().length&&n.initialiseSingleton();const i=n.callMethod("listens")[e];n.getInstances().forEach((n=>{if("function"==typeof i)try{const e=i.apply(n,s);if(e instanceof Promise==!1)return;r.push(e)}catch(s){this.error(`Error thrown in "${e}" event by "${t}" plugin.`,s)}else if("string"==typeof i){if(!n[i])throw new Error(`Missing "${i}" method in "${t}" plugin`);try{const e=n[i](...s);if(e instanceof Promise==!1)return;r.push(e)}catch(s){this.error(`Error thrown in "${e}" promise event by "${t}" plugin.`,s)}}else this.error(`Listen method for "${e}" event in "${t}" plugin is not a function or string.`)}))})),this.listeners[e]&&this.listeners[e].length>0&&(this.debug(`Found ${this.listeners[e].length} ad-hoc listener(s) for global promise event "${e}"`),this.listeners[e].forEach((t=>{try{const e=t(...s);if(e instanceof Promise==!1)return;r.push(e)}catch(t){this.error(`Error thrown in "${e}" promise event by an ad-hoc listener.`,t)}}))),0===r.length?Promise.resolve():Promise.all(r)}logMessage(e,t,s){console.groupCollapsed("%c[Snowboard]",`color: ${e}; font-weight: ${t?"bold":"normal"};`,s);for(var n=arguments.length,i=new Array(n>3?n-3:0),r=3;r{e+=1,console.log(`%c${e}:`,"color: rgb(88, 88, 88); font-weight: normal;",t)})),console.groupEnd(),console.groupCollapsed("%cTrace","color: rgb(45, 167, 199); font-weight: bold;"),console.trace(),console.groupEnd()}else console.trace();console.groupEnd()}log(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),n=1;n1?t-1:0),n=1;n1?t-1:0),n=1;n{const t=new Proxy(new n.Z,i.Z);e.snowboard=t,e.Snowboard=t,e.SnowBoard=t})(window)},640:function(e,t,s){var n=s(579);function i(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,n)}return s}function r(e){for(var t=1;t{e&&this.doAjax().then((e=>{if(e.cancelled)return this.cancelled=!0,void this.complete();this.responseData=e,this.processUpdate(e).then((()=>{!1===e.X_WINTER_SUCCESS?this.processError(e):this.processResponse(e)}))}),(e=>{this.responseError=e,this.processError(e)}))})):this.doAjax().then((e=>{if(e.cancelled)return this.cancelled=!0,void this.complete();this.responseData=e,this.processUpdate(e).then((()=>{!1===e.X_WINTER_SUCCESS?this.processError(e):this.processResponse(e)}))}),(e=>{this.responseError=e,this.processError(e)})):this.cancelled=!0}else this.cancelled=!0}dependencies(){return["cookie","jsonParser"]}checkRequest(){if(this.element&&this.element instanceof Element==!1)throw new Error("The element provided must be an Element instance");if(void 0===this.handler)throw new Error("The AJAX handler name is not specified.");if(!this.isHandlerName(this.handler))throw new Error('Invalid AJAX handler name. The correct handler name format is: "onEvent".')}getFetch(){return this.fetchOptions=void 0!==this.options.fetchOptions&&"object"==typeof this.options.fetchOptions?this.options.fetchOptions:{method:"POST",headers:this.headers,body:this.data,redirect:"follow",mode:"same-origin"},this.snowboard.globalEvent("ajaxFetchOptions",this.fetchOptions,this),fetch(this.url,this.fetchOptions)}doClientValidation(){return!0!==this.options.browserValidate||!this.form||!1!==this.form.checkValidity()||(this.form.reportValidity(),!1)}doAjax(){if(!1===this.snowboard.globalEvent("ajaxBeforeSend",this))return Promise.resolve({cancelled:!0});const e=new Promise(((e,t)=>{this.getFetch().then((s=>{s.ok||406===s.status?s.headers.has("Content-Type")&&s.headers.get("Content-Type").includes("/json")?s.json().then((t=>{e(r(r({},t),{},{X_WINTER_SUCCESS:406!==s.status,X_WINTER_RESPONSE_CODE:s.status}))}),(e=>{t(this.renderError(`Unable to parse JSON response: ${e}`))})):s.text().then((t=>{e(t)}),(e=>{t(this.renderError(`Unable to process response: ${e}`))})):s.headers.has("Content-Type")&&s.headers.get("Content-Type").includes("/json")?s.json().then((e=>{e.message&&e.exception?t(this.renderError(e.message,e.exception,e.file,e.line,e.trace)):t(e)}),(e=>{t(this.renderError(`Unable to parse JSON response: ${e}`))})):s.text().then((e=>{t(this.renderError(e))}),(e=>{t(this.renderError(`Unable to process response: ${e}`))}))}),(e=>{t(this.renderError(`Unable to retrieve a response from the server: ${e}`))}))}));if(this.snowboard.globalEvent("ajaxStart",e,this),this.element){const t=new Event("ajaxPromise");t.promise=e,this.element.dispatchEvent(t)}return e}processUpdate(e){return new Promise(((t,s)=>{if("function"==typeof this.options.beforeUpdate&&!1===this.options.beforeUpdate.apply(this,[e]))return void t();const n={};if(Object.entries(e).forEach((e=>{const[t,s]=e;"X_WINTER"!==t.substr(0,8)&&(n[t]=s)})),0===Object.keys(n).length)return void(e.X_WINTER_ASSETS?this.processAssets(e.X_WINTER_ASSETS).then((()=>{t()}),(()=>{s()})):t());this.snowboard.globalPromiseEvent("ajaxBeforeUpdate",e,this).then((async()=>{e.X_WINTER_ASSETS&&await this.processAssets(e.X_WINTER_ASSETS),this.doUpdate(n).then((()=>{window.requestAnimationFrame((()=>t()))}),(()=>{s()}))}),(()=>{t()}))}))}doUpdate(e){return new Promise((t=>{const s=[];Object.entries(e).forEach((e=>{const[t,n]=e;let i=this.options.update&&this.options.update[t]?this.options.update[t]:t,r="replace";"@"===i.substr(0,1)?(r="append",i=i.substr(1)):"^"===i.substr(0,1)?(r="prepend",i=i.substr(1)):"#"!==i.substr(0,1)&&"."!==i.substr(0,1)&&(r="noop");const o=document.querySelectorAll(i);o.length>0&&o.forEach((e=>{switch(r){case"append":e.innerHTML+=n;break;case"prepend":e.innerHTML=n+e.innerHTML;break;case"noop":break;default:e.innerHTML=n}s.push(e),this.snowboard.globalEvent("ajaxUpdate",e,n,this);const t=new Event("ajaxUpdate");t.content=n,e.dispatchEvent(t)}))})),this.snowboard.globalEvent("ajaxUpdateComplete",s,this),t()}))}processResponse(e){if((!this.options.success||"function"!=typeof this.options.success||!1!==this.options.success(this.responseData,this))&&!1!==this.snowboard.globalEvent("ajaxSuccess",this.responseData,this)){if(this.element){const e=new Event("ajaxDone",{cancelable:!0});if(e.responseData=this.responseData,e.request=this,this.element.dispatchEvent(e),e.defaultPrevented)return}this.flash&&e.X_WINTER_FLASH_MESSAGES&&this.processFlashMessages(e.X_WINTER_FLASH_MESSAGES),this.redirect||e.X_WINTER_REDIRECT?this.processRedirect(this.redirect||e.X_WINTER_REDIRECT):this.complete()}}processError(e){if((!this.options.error||"function"!=typeof this.options.error||!1!==this.options.error(this.responseError,this))&&!1!==this.snowboard.globalEvent("ajaxError",this.responseError,this)){if(this.element){const e=new Event("ajaxFail",{cancelable:!0});if(e.responseError=this.responseError,e.request=this,this.element.dispatchEvent(e),e.defaultPrevented)return}if(e instanceof Error)this.processErrorMessage(e.message);else{let t=!1;e.X_WINTER_ERROR_FIELDS&&(t=this.processValidationErrors(e.X_WINTER_ERROR_FIELDS)),e.X_WINTER_ERROR_MESSAGE&&!t&&this.processErrorMessage(e.X_WINTER_ERROR_MESSAGE)}this.complete()}}processRedirect(e){"function"==typeof this.options.handleRedirectResponse&&!1===this.options.handleRedirectResponse.apply(this,[e])||!1!==this.snowboard.globalEvent("ajaxRedirect",e,this)&&(window.addEventListener("popstate",(()=>{if(this.element){const e=document.createEvent("CustomEvent");e.eventName="ajaxRedirected",this.element.dispatchEvent(e)}}),{once:!0}),window.location.assign(e))}processErrorMessage(e){"function"==typeof this.options.handleErrorMessage&&!1===this.options.handleErrorMessage.apply(this,[e])||!1!==this.snowboard.globalEvent("ajaxErrorMessage",e,this)&&window.alert(e)}processFlashMessages(e){"function"==typeof this.options.handleFlashMessages&&!1===this.options.handleFlashMessages.apply(this,[e])||this.snowboard.globalEvent("ajaxFlashMessages",e,this)}processValidationErrors(e){return"function"==typeof this.options.handleValidationErrors&&!1===this.options.handleValidationErrors.apply(this,[this.form,e])||!1===this.snowboard.globalEvent("ajaxValidationErrors",this.form,e,this)}processAssets(e){return this.snowboard.globalPromiseEvent("ajaxLoadAssets",e)}async doConfirm(){if("function"==typeof this.options.handleConfirmMessage)return!1!==this.options.handleConfirmMessage.apply(this,[this.confirm]);if(0===this.snowboard.listensToEvent("ajaxConfirmMessage").length)return window.confirm(this.confirm);const e=this.snowboard.globalPromiseEvent("ajaxConfirmMessage",this.confirm,this);try{if(await e)return!0}catch(e){return!1}return!1}complete(){if(this.options.complete&&"function"==typeof this.options.complete&&this.options.complete(this.responseData,this),this.snowboard.globalEvent("ajaxDone",this.responseData,this),this.element){const e=new Event("ajaxAlways");e.request=this,e.responseData=this.responseData,e.responseError=this.responseError,this.element.dispatchEvent(e)}this.destruct()}get form(){return this.options.form?"string"==typeof this.options.form?document.querySelector(this.options.form):this.options.form:this.element?"FORM"===this.element.tagName?this.element:this.element.closest("form"):null}get context(){return{handler:this.handler,options:this.options}}get headers(){const e={"X-Requested-With":"XMLHttpRequest","X-WINTER-REQUEST-HANDLER":this.handler,"X-WINTER-REQUEST-PARTIALS":this.extractPartials(this.options.update||[])};return this.flash&&(e["X-WINTER-REQUEST-FLASH"]=1),this.xsrfToken&&(e["X-XSRF-TOKEN"]=this.xsrfToken),e}get loading(){return this.options.loading||!1}get url(){return this.options.url||window.location.href}get redirect(){return this.options.redirect&&this.options.redirect.length?this.options.redirect:null}get flash(){return this.options.flash||!1}get files(){return!0===this.options.files&&(void 0!==FormData||(this.snowboard.debug("This browser does not support file uploads"),!1))}get xsrfToken(){return this.snowboard.cookie().get("XSRF-TOKEN")}get data(){const e="object"==typeof this.options.data?this.options.data:{},t=new FormData(this.form||void 0);return Object.keys(e).length>0&&Object.entries(e).forEach((e=>{const[s,n]=e;t.append(s,n)})),t}get confirm(){return this.options.confirm||!1}extractPartials(e){return Object.keys(e).join("&")}renderError(e,t,s,n,i){const r=new Error(e);return r.exception=t||null,r.file=s||null,r.line=n||null,r.trace=i||[],r}isHandlerName(e){return/^(?:\w+:{2})?on[A-Z0-9]/.test(e)}}if(void 0===window.Snowboard)throw new Error("Snowboard must be loaded in order to use the Javascript AJAX request feature.");window.Snowboard.addPlugin("request",a)}},function(e){var t=function(t){return e(e.s=t)};e.O(0,[109],(function(){return t(236),t(640),t(136)}));e.O()}]); \ No newline at end of file +"use strict";(self.webpackChunk_wintercms_wn_system_module=self.webpackChunk_wintercms_wn_system_module||[]).push([[336,861,813],{660:function(e,t,s){s.d(t,{A:function(){return n}});class n{constructor(e){this.snowboard=e}construct(){}dependencies(){return[]}listens(){return{}}destruct(){this.detach(),delete this.snowboard}destructor(){this.destruct()}}},373:function(e,t,s){s.d(t,{A:function(){return i}});var n=s(660);class i extends n.A{}},477:function(e,t,s){s.d(t,{A:function(){return i}});var n=s(373);class i extends n.A{listens(){return{ajaxLoadAssets:"load"}}dependencies(){return["url"]}async load(e){if(e.js&&e.js.length>0)for(const t of e.js)try{await this.loadScript(t)}catch(e){return Promise.reject(e)}if(e.css&&e.css.length>0)for(const t of e.css)try{await this.loadStyle(t)}catch(e){return Promise.reject(e)}if(e.img&&e.img.length>0)for(const t of e.img)try{await this.loadImage(t)}catch(e){return Promise.reject(e)}return Promise.resolve()}loadScript(e){return new Promise(((t,s)=>{e=this.snowboard.url().asset(e);if(document.querySelector(`script[src="${e}"]`))return void t();const n=document.createElement("script");n.setAttribute("type","text/javascript"),n.setAttribute("src",e),n.addEventListener("load",(()=>{this.snowboard.globalEvent("assetLoader.loaded","script",e,n),t()})),n.addEventListener("error",(()=>{this.snowboard.globalEvent("assetLoader.error","script",e,n),s(new Error(`Unable to load script file: "${e}"`))})),document.body.append(n)}))}loadStyle(e){return new Promise(((t,s)=>{e=this.snowboard.url().asset(e);if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void t();const n=document.createElement("link");n.setAttribute("rel","stylesheet"),n.setAttribute("href",e),n.addEventListener("load",(()=>{this.snowboard.globalEvent("assetLoader.loaded","style",e,n),t()})),n.addEventListener("error",(()=>{this.snowboard.globalEvent("assetLoader.error","style",e,n),s(new Error(`Unable to load stylesheet file: "${e}"`))})),document.head.append(n)}))}loadImage(e){return new Promise(((t,s)=>{e=this.snowboard.url().asset(e);const n=new Image;n.addEventListener("load",(()=>{this.snowboard.globalEvent("assetLoader.loaded","image",e,n),t()})),n.addEventListener("error",(()=>{this.snowboard.globalEvent("assetLoader.error","image",e,n),s(new Error(`Unable to load image file: "${e}"`))})),n.src=e}))}}},293:function(e,t,s){s.d(t,{A:function(){return i}});var n=s(373);class i extends n.A{dependencies(){return["request"]}listens(){return{ajaxStart:"ajaxStart",ajaxDone:"ajaxDone"}}ajaxStart(e,t){if(t.element)if("FORM"===t.element.tagName){const e=t.element.querySelectorAll("[data-attach-loading]");e.length>0&&e.forEach((e=>{e.classList.add(this.getLoadingClass(e))}))}else void 0!==t.element.dataset.attachLoading&&t.element.classList.add(this.getLoadingClass(t.element))}ajaxDone(e,t){if(t.element)if("FORM"===t.element.tagName){const e=t.element.querySelectorAll("[data-attach-loading]");e.length>0&&e.forEach((e=>{e.classList.remove(this.getLoadingClass(e))}))}else void 0!==t.element.dataset.attachLoading&&t.element.classList.remove(this.getLoadingClass(t.element))}getLoadingClass(e){return void 0!==e.dataset.attachLoading&&""!==e.dataset.attachLoading?e.dataset.attachLoading:"wn-loading"}}},490:function(e,t,s){s.d(t,{A:function(){return i}});var n=s(660);class i extends n.A{construct(e,t,s){if(e instanceof n.A==!1)throw new Error("You must provide a Snowboard plugin to enable data configuration");if(t instanceof HTMLElement==!1)throw new Error("Data configuration can only be extracted from HTML elements");this.instance=e,this.element=t,this.localConfig=s||{},this.instanceConfig={},this.acceptedConfigs={},this.refresh()}get(e){return void 0===e?this.instanceConfig:void 0!==this.instanceConfig[e]?this.instanceConfig[e]:void 0}set(e,t,s){if(void 0===e)throw new Error("You must provide a configuration key to set");this.instanceConfig[e]=t,!0===s&&(this.element.dataset[e]=t,this.localConfig[e]=t)}refresh(){this.acceptedConfigs=this.getAcceptedConfigs(),this.instanceConfig=this.processConfig()}getAcceptedConfigs(){return void 0!==this.instance.acceptAllDataConfigs&&!0===this.instance.acceptAllDataConfigs||void 0!==this.instance.defaults&&"function"==typeof this.instance.defaults&&"object"==typeof this.instance.defaults()&&Object.keys(this.instance.defaults())}getDefaults(){return void 0!==this.instance.defaults&&"function"==typeof this.instance.defaults&&"object"==typeof this.instance.defaults()?this.instance.defaults():{}}processConfig(){const e=this.getDefaults();if(!1===this.acceptedConfigs)return e;for(const t in this.element.dataset)(!0===this.acceptedConfigs||this.acceptedConfigs.includes(t))&&(e[t]=this.coerceValue(this.element.dataset[t]));for(const t in this.localConfig)(!0===this.acceptedConfigs||this.acceptedConfigs.includes(t))&&(e[t]=this.localConfig[t]);return e}coerceValue(e){const t=String(e);if("null"===t)return null;if("undefined"!==t){if(t.startsWith("base64:")){const e=t.replace(/^base64:/,""),s=atob(e);return this.coerceValue(s)}if(["true","yes"].includes(t.toLowerCase()))return!0;if(["false","no"].includes(t.toLowerCase()))return!1;if(/^[-+]?[0-9]+(\.[0-9]+)?$/.test(t))return Number(t);try{return this.snowboard.jsonParser().parse(t)}catch(e){return""===t||t}}}}},336:function(e,t,s){s.d(t,{A:function(){return i}});var n=s(660);class i extends n.A{construct(e,t,s){if(this.message=e,this.type=t||"default",this.duration=Number(s||7),this.duration<0)throw new Error("Flash duration must be a positive number, or zero");this.clear(),this.timer=null,this.flashTimer=null,this.create()}dependencies(){return["transition"]}destruct(){null!==this.timer&&window.clearTimeout(this.timer),this.flashTimer&&this.flashTimer.remove(),this.flash&&(this.flash.remove(),this.flash=null,this.flashTimer=null),super.destruct()}create(){this.snowboard.globalEvent("flash.create",this),this.flash=document.createElement("DIV"),this.flash.innerHTML=this.message,this.flash.classList.add("flash-message",this.type),this.flash.removeAttribute("data-control"),this.flash.addEventListener("click",(()=>this.remove())),this.flash.addEventListener("mouseover",(()=>this.stopTimer())),this.flash.addEventListener("mouseout",(()=>this.startTimer())),this.duration>0?(this.flashTimer=document.createElement("DIV"),this.flashTimer.classList.add("flash-timer"),this.flash.appendChild(this.flashTimer)):this.flash.classList.add("no-timer"),document.body.appendChild(this.flash),this.snowboard.transition(this.flash,"show",(()=>{this.startTimer()}))}remove(){this.snowboard.globalEvent("flash.remove",this),this.stopTimer(),this.snowboard.transition(this.flash,"hide",(()=>{this.flash.remove(),this.flash=null,this.destruct()}))}clear(){document.querySelectorAll("body > div.flash-message").forEach((e=>e.remove()))}startTimer(){0!==this.duration&&(this.timerTrans=this.snowboard.transition(this.flashTimer,"timeout",null,`${this.duration}.0s`,!0),this.timer=window.setTimeout((()=>this.remove()),1e3*this.duration))}stopTimer(){this.timerTrans&&this.timerTrans.cancel(),this.timer&&window.clearTimeout(this.timer)}}},758:function(e,t,s){s.d(t,{A:function(){return i}});var n=s(373);class i extends n.A{dependencies(){return["request"]}listens(){return{ready:"ready",ajaxStart:"ajaxStart"}}ready(){this.counter=0,this.createStripe()}ajaxStart(e,t){!1!==t.options.stripe&&(this.show(),e.then((()=>{this.hide()})).catch((()=>{this.hide()})))}createStripe(){this.indicator=document.createElement("DIV"),this.stripe=document.createElement("DIV"),this.stripeLoaded=document.createElement("DIV"),this.indicator.classList.add("stripe-loading-indicator","loaded"),this.stripe.classList.add("stripe"),this.stripeLoaded.classList.add("stripe-loaded"),this.indicator.appendChild(this.stripe),this.indicator.appendChild(this.stripeLoaded),document.body.appendChild(this.indicator)}show(){this.counter+=1;const e=this.stripe.cloneNode(!0);this.indicator.appendChild(e),this.stripe.remove(),this.stripe=e,this.counter>1||(this.indicator.classList.remove("loaded"),document.body.classList.add("wn-loading"))}hide(e){this.counter-=1,!0===e&&(this.counter=0),this.counter<=0&&(this.indicator.classList.add("loaded"),document.body.classList.remove("wn-loading"))}}},75:function(e,t,s){s.d(t,{A:function(){return i}});var n=s(373);class i extends n.A{listens(){return{ready:"ready"}}ready(){let e=!1;if(document.querySelectorAll('link[rel="stylesheet"]').forEach((t=>{t.href.endsWith("/modules/system/assets/css/snowboard.extras.css")&&(e=!0)})),!e){const e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("href",this.snowboard.url().asset("/modules/system/assets/css/snowboard.extras.css")),document.head.appendChild(e)}}}},843:function(e,t,s){s.d(t,{A:function(){return i}});var n=s(660);class i extends n.A{construct(e,t,s,n,i){if(e instanceof HTMLElement==!1)throw new Error("A HTMLElement must be provided for transitioning");if(this.element=e,"string"!=typeof t)throw new Error("Transition name must be specified as a string");if(this.transition=t,s&&"function"!=typeof s)throw new Error("Callback must be a valid function");this.callback=s,this.duration=n?this.parseDuration(n):null,this.trailTo=!0===i,this.doTransition()}eventClasses(){for(var e=arguments.length,t=new Array(e),s=0;s{const[s,n]=e;-1!==t.indexOf(s)&&i.push(n)})),i}doTransition(){null!==this.duration&&(this.element.style.transitionDuration=this.duration),this.resetClasses(),this.eventClasses("in","active").forEach((e=>{this.element.classList.add(e)})),window.requestAnimationFrame((()=>{"0s"!==window.getComputedStyle(this.element)["transition-duration"]?(this.element.addEventListener("transitionend",(()=>this.onTransitionEnd()),{once:!0}),window.requestAnimationFrame((()=>{this.element.classList.remove(this.eventClasses("in")[0]),this.element.classList.add(this.eventClasses("out")[0])}))):(this.resetClasses(),this.callback&&this.callback.apply(this.element),this.destruct())}))}onTransitionEnd(){this.eventClasses("active",this.trailTo?"":"out").forEach((e=>{this.element.classList.remove(e)})),this.callback&&this.callback.apply(this.element),null!==this.duration&&(this.element.style.transitionDuration=null),this.destruct()}cancel(){this.element.removeEventListener("transitionend",(()=>this.onTransitionEnd),{once:!0}),this.resetClasses(),null!==this.duration&&(this.element.style.transitionDuration=null),this.destruct()}resetClasses(){this.eventClasses().forEach((e=>{this.element.classList.remove(e)}))}parseDuration(e){const t=/^([0-9]+(\.[0-9]+)?)(m?s)?$/.exec(e),s=Number(t[1]);return"sec"===("s"===t[3]?"sec":"msec")?1e3*s+"ms":`${Math.floor(s)}ms`}}},54:function(e,t){t.A={get(e,t,s){if("string"==typeof t){const s=t.toLowerCase();if(e.hasPlugin(s))return function(){return Reflect.get(e,"plugins")[s].getInstance(...arguments)}}return Reflect.get(e,t,s)},has(e,t){if("string"==typeof t){const s=t.toLowerCase();if(e.hasPlugin(s))return!0}return Reflect.has(e,t)}}},160:function(e,t,s){s.d(t,{A:function(){return g}});var n=s(660),i=s(373),r={get(e,t,s){if("string"==typeof t){const s=t.toLowerCase();if(["attachAbstracts","loadUtilities","initialise","initialiseSingletons"].includes(t))throw new Error(`You cannot use the "${t}" Snowboard method within a plugin.`);if(e.hasPlugin(s))return function(){return Reflect.get(e,"plugins")[s].getInstance(...arguments)}}return Reflect.get(e,t,s)},has(e,t){if("string"==typeof t){const s=t.toLowerCase();if(["attachAbstracts","loadUtilities","initialise","initialiseSingletons"].includes(t))return!1;if(e.hasPlugin(s))return!0}return Reflect.has(e,t)}};class o{constructor(e,t,s){this.name=e,this.snowboard=new Proxy(t,r),this.instance=s,Object.freeze(this.instance),this.instances=[],this.singleton={initialised:!1},Object.seal(this.singleton),this.mocks={},this.originalFunctions={},Object.freeze(o.prototype),Object.freeze(this)}hasMethod(e){return!this.isFunction()&&"function"==typeof this.instance.prototype[e]}callMethod(){if(this.isFunction())return null;for(var e=arguments.length,t=new Array(e),s=0;s!this.snowboard.getPluginNames().includes(e)));throw new Error(`The "${this.name}" plugin requires the following plugins: ${e.join(", ")}`)}if(this.isSingleton())return 0===this.instances.length&&this.initialiseSingleton(...s),Object.keys(this.mocks).length>0&&(Object.entries(this.originalFunctions).forEach((e=>{const[t,s]=e;this.instances[0][t]=s})),Object.entries(this.mocks).forEach((t=>{const[s,n]=t;this.instances[0][s]=function(){for(var t=arguments.length,s=new Array(t),i=0;i0&&(Object.entries(this.originalFunctions).forEach((e=>{const[t,s]=e;this.instance.prototype[t]=s})),Object.entries(this.mocks).forEach((t=>{const[s,n]=t;this.instance.prototype[s]=function(){for(var t=arguments.length,s=new Array(t),i=0;ithis.instances.splice(this.instances.indexOf(i),1),i.construct(...s),this.instances.push(i),i}getInstances(){return this.isFunction()?[]:this.instances}isFunction(){return"function"==typeof this.instance&&this.instance.prototype instanceof n.A==!1}isSingleton(){return this.instance.prototype instanceof i.A==!0}isInitialised(){return!this.isSingleton()||this.singleton.initialised}initialiseSingleton(){if(!this.isSingleton())return;for(var e=arguments.length,t=new Array(e),s=0;sthis.instances.splice(this.instances.indexOf(n),1),n.construct(...t),this.instances.push(n),this.singleton.initialised=!0}getDependencies(){return this.isFunction()||"function"!=typeof this.instance.prototype.dependencies?[]:this.instance.prototype.dependencies().map((e=>e.toLowerCase()))}dependenciesFulfilled(){const e=this.getDependencies();let t=!0;return e.forEach((e=>{this.snowboard.hasPlugin(e)||(t=!1)})),t}mock(e,t){var s=this;if(!this.isFunction()){if(!this.instance.prototype[e])throw new Error(`Function "${e}" does not exist and cannot be mocked`);this.mocks[e]=t,this.originalFunctions[e]=this.instance.prototype[e],this.isSingleton()&&0===this.instances.length&&(this.initialiseSingleton(),this.instances[0][e]=function(){for(var e=arguments.length,n=new Array(e),i=0;i{const[t,s]=e;void 0!==this.defaults[t]&&(this.defaults[t]=s)}))}getDefaults(){const e={};return Object.entries(this.defaults).forEach((t=>{const[s,n]=t;null!==this.defaults[s]&&(e[s]=n)})),e}get(e){if(void 0===e){const e=a.A.get();return Object.entries(e).forEach((t=>{const[s,n]=t;this.snowboard.globalEvent("cookie.get",s,n,(t=>{e[s]=t}))})),e}let t=a.A.get(e);return this.snowboard.globalEvent("cookie.get",e,t,(e=>{t=e})),t}set(e,t,s){let n=t;return this.snowboard.globalEvent("cookie.set",e,t,(e=>{n=e})),a.A.set(e,n,h(h({},this.getDefaults()),s))}remove(e,t){a.A.remove(e,h(h({},this.getDefaults()),t))}}class u extends i.A{construct(){window.wnJSON=e=>this.parse(e),window.ocJSON=window.wnJSON}parse(e){const t=this.parseString(e);return JSON.parse(t)}parseString(e){let t=e.trim();if(!t.length)throw new Error("Broken JSON object.");let s="",n=null,i=null,r="";for(;t&&","===t[0];)t=t.substr(1);if('"'===t[0]||"'"===t[0]){if(t[t.length-1]!==t[0])throw new Error("Invalid string JSON object.");r='"';for(let e=1;e="0"&&e[t]<="9"){s="";for(let n=t;n="0"&&e[n]<="9"))return{originLength:s.length,body:s};s+=e[n]}throw new Error(`Broken JSON number body near ${s}`)}if("{"===e[t]||"["===e[t]){const n=[e[t]];s=e[t];for(let i=t+1;i=0?t-5:0,50)}`)}parseKey(e,t,s){let n="";for(let i=t;i="a"&&e[0]<="z"||e[0]>="A"&&e[0]<="Z"||"_"===e[0]||(e[0]>="0"&&e[0]<="9"||("$"===e[0]||e.charCodeAt(0)>255)))}isBlankChar(e){return" "===e||"\n"===e||"\t"===e}}class f extends i.A{construct(){window.wnSanitize=e=>this.sanitize(e),window.ocSanitize=window.wnSanitize}sanitize(e,t){const s=(new DOMParser).parseFromString(e,"text/html"),n=void 0===t||"boolean"!=typeof t||t;return this.sanitizeNode(s.getRootNode()),n?s.body.innerHTML:s.innerHTML}sanitizeNode(e){if("SCRIPT"===e.tagName)return void e.remove();this.trimAttributes(e);Array.from(e.children).forEach((e=>{this.sanitizeNode(e)}))}trimAttributes(e){if(e.attributes)for(let t=0;t{this.autoInitSingletons&&this.initialiseSingletons(),this.globalEvent("ready"),this.readiness.dom=!0}))}initialiseSingletons(){Object.values(this.plugins).forEach((e=>{e.isSingleton()&&e.dependenciesFulfilled()&&e.initialiseSingleton()}))}addPlugin(e,t){const s=e.toLowerCase();if(this.hasPlugin(s))throw new Error(`A plugin called "${e}" is already registered.`);if("function"!=typeof t&&t instanceof n.A==!1)throw new Error("The provided plugin must extend the PluginBase class, or must be a callback function.");if(void 0!==this[e]||void 0!==this[s])throw new Error("The given name is already in use for a property or method of the Snowboard class.");this.plugins[s]=new o(s,this,t),this.debug(`Plugin "${e}" registered`),Object.values(this.getPlugins()).forEach((e=>{if(e.isSingleton()&&!e.isInitialised()&&e.dependenciesFulfilled()&&e.hasMethod("listens")&&Object.keys(e.callMethod("listens")).includes("ready")&&this.readiness.dom){const t=e.callMethod("listens").ready;e.callMethod(t)}}))}removePlugin(e){const t=e.toLowerCase();this.hasPlugin(t)?(this.plugins[t].getInstances().forEach((e=>{e.destruct()})),delete this.plugins[t],delete this[t],delete this[e],this.debug(`Plugin "${e}" removed`)):this.debug(`Plugin "${e}" already removed`)}hasPlugin(e){const t=e.toLowerCase();return void 0!==this.plugins[t]}getPlugins(){return this.plugins}getPluginNames(){return Object.keys(this.plugins)}getPlugin(e){const t=e.toLowerCase();if(!this.hasPlugin(t))throw new Error(`No plugin called "${t}" has been registered.`);return this.plugins[t]}listensToEvent(e){const t=[];return Object.entries(this.plugins).forEach((s=>{const[n,i]=s;if(i.isFunction())return;if(!i.dependenciesFulfilled())return;if(!i.hasMethod("listens"))return;const r=i.callMethod("listens");"string"!=typeof r[e]&&"function"!=typeof r[e]||t.push(n)})),t}ready(e){this.readiness.dom&&e(),this.on("ready",e)}on(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].includes(t)||this.listeners[e].push(t)}off(e,t){if(!this.listeners[e])return;const s=this.listeners[e].indexOf(t);-1!==s&&this.listeners[e].splice(s,1)}globalEvent(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),n=1;n{const n=this.getPlugin(t);if(n.isFunction())return;n.isSingleton()&&0===n.getInstances().length&&n.initialiseSingleton();const i=n.callMethod("listens")[e];n.getInstances().forEach((n=>{if(!r)if("function"==typeof i)try{!1===i.apply(n,s)&&(r=!0)}catch(s){this.error(`Error thrown in "${e}" event by "${t}" plugin.`,s)}else if("string"==typeof i){if(!n[i])throw new Error(`Missing "${i}" method in "${t}" plugin`);try{!1===n[i](...s)&&(r=!0,this.debug(`Global event "${e}" cancelled by "${t}" plugin`))}catch(s){this.error(`Error thrown in "${e}" event by "${t}" plugin.`,s)}}else this.error(`Listen method for "${e}" event in "${t}" plugin is not a function or string.`)}))})),!r&&this.listeners[e]&&this.listeners[e].length>0&&(this.debug(`Found ${this.listeners[e].length} ad-hoc listener(s) for global event "${e}"`),this.listeners[e].forEach((t=>{if(!r)try{!1===t(...s)&&(r=!0,this.debug(`Global event "${e} cancelled by an ad-hoc listener.`))}catch(t){this.error(`Error thrown in "${e}" event by an ad-hoc listener.`,t)}}))),!r}globalPromiseEvent(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),n=1;n{const n=this.getPlugin(t);if(n.isFunction())return;n.isSingleton()&&0===n.getInstances().length&&n.initialiseSingleton();const i=n.callMethod("listens")[e];n.getInstances().forEach((n=>{if("function"==typeof i)try{const e=i.apply(n,s);if(e instanceof Promise==!1)return;r.push(e)}catch(s){this.error(`Error thrown in "${e}" event by "${t}" plugin.`,s)}else if("string"==typeof i){if(!n[i])throw new Error(`Missing "${i}" method in "${t}" plugin`);try{const e=n[i](...s);if(e instanceof Promise==!1)return;r.push(e)}catch(s){this.error(`Error thrown in "${e}" promise event by "${t}" plugin.`,s)}}else this.error(`Listen method for "${e}" event in "${t}" plugin is not a function or string.`)}))})),this.listeners[e]&&this.listeners[e].length>0&&(this.debug(`Found ${this.listeners[e].length} ad-hoc listener(s) for global promise event "${e}"`),this.listeners[e].forEach((t=>{try{const e=t(...s);if(e instanceof Promise==!1)return;r.push(e)}catch(t){this.error(`Error thrown in "${e}" promise event by an ad-hoc listener.`,t)}}))),0===r.length?Promise.resolve():Promise.all(r)}logMessage(e,t,s){console.groupCollapsed("%c[Snowboard]",`color: ${e}; font-weight: ${t?"bold":"normal"};`,s);for(var n=arguments.length,i=new Array(n>3?n-3:0),r=3;r{e+=1,console.log(`%c${e}:`,"color: rgb(88, 88, 88); font-weight: normal;",t)})),console.groupEnd(),console.groupCollapsed("%cTrace","color: rgb(45, 167, 199); font-weight: bold;"),console.trace(),console.groupEnd()}else console.trace();console.groupEnd()}log(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),n=1;n1?t-1:0),n=1;n1?t-1:0),n=1;n{const t=new Proxy(new n.A,i.A);e.snowboard=t,e.Snowboard=t,e.SnowBoard=t})(window)},59:function(e,t,s){var n=s(660);function i(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,n)}return s}function r(e){for(var t=1;t{e&&this.doAjax().then((e=>{if(e.cancelled)return this.cancelled=!0,void this.complete();this.responseData=e,this.processUpdate(e).then((()=>{!1===e.X_WINTER_SUCCESS?this.processError(e):this.processResponse(e)}))}),(e=>{this.responseError=e,this.processError(e)}))})):this.doAjax().then((e=>{if(e.cancelled)return this.cancelled=!0,void this.complete();this.responseData=e,this.processUpdate(e).then((()=>{!1===e.X_WINTER_SUCCESS?this.processError(e):this.processResponse(e)}))}),(e=>{this.responseError=e,this.processError(e)})):this.cancelled=!0}else this.cancelled=!0}dependencies(){return["cookie","jsonParser"]}checkRequest(){if(this.element&&this.element instanceof Element==!1)throw new Error("The element provided must be an Element instance");if(void 0===this.handler)throw new Error("The AJAX handler name is not specified.");if(!this.isHandlerName(this.handler))throw new Error('Invalid AJAX handler name. The correct handler name format is: "onEvent".')}getFetch(){return this.fetchOptions=void 0!==this.options.fetchOptions&&"object"==typeof this.options.fetchOptions?this.options.fetchOptions:{method:"POST",headers:this.headers,body:this.data,redirect:"follow",mode:"same-origin"},this.snowboard.globalEvent("ajaxFetchOptions",this.fetchOptions,this),fetch(this.url,this.fetchOptions)}doClientValidation(){return!0!==this.options.browserValidate||!this.form||!1!==this.form.checkValidity()||(this.form.reportValidity(),!1)}doAjax(){if(!1===this.snowboard.globalEvent("ajaxBeforeSend",this))return Promise.resolve({cancelled:!0});const e=new Promise(((e,t)=>{this.getFetch().then((s=>{s.ok||406===s.status?s.headers.has("Content-Type")&&s.headers.get("Content-Type").includes("/json")?s.json().then((t=>{e(r(r({},t),{},{X_WINTER_SUCCESS:406!==s.status,X_WINTER_RESPONSE_CODE:s.status}))}),(e=>{t(this.renderError(`Unable to parse JSON response: ${e}`))})):s.text().then((t=>{e(t)}),(e=>{t(this.renderError(`Unable to process response: ${e}`))})):s.headers.has("Content-Type")&&s.headers.get("Content-Type").includes("/json")?s.json().then((e=>{e.message&&e.exception?t(this.renderError(e.message,e.exception,e.file,e.line,e.trace)):t(e)}),(e=>{t(this.renderError(`Unable to parse JSON response: ${e}`))})):s.text().then((e=>{t(this.renderError(e))}),(e=>{t(this.renderError(`Unable to process response: ${e}`))}))}),(e=>{t(this.renderError(`Unable to retrieve a response from the server: ${e}`))}))}));if(this.snowboard.globalEvent("ajaxStart",e,this),this.element){const t=new Event("ajaxPromise");t.promise=e,this.element.dispatchEvent(t)}return e}processUpdate(e){return new Promise(((t,s)=>{if("function"==typeof this.options.beforeUpdate&&!1===this.options.beforeUpdate.apply(this,[e]))return void t();const n={};if(Object.entries(e).forEach((e=>{const[t,s]=e;"X_WINTER"!==t.substr(0,8)&&(n[t]=s)})),0===Object.keys(n).length)return void(e.X_WINTER_ASSETS?this.processAssets(e.X_WINTER_ASSETS).then((()=>{t()}),(()=>{s()})):t());this.snowboard.globalPromiseEvent("ajaxBeforeUpdate",e,this).then((async()=>{e.X_WINTER_ASSETS&&await this.processAssets(e.X_WINTER_ASSETS),this.doUpdate(n).then((()=>{window.requestAnimationFrame((()=>t()))}),(()=>{s()}))}),(()=>{t()}))}))}doUpdate(e){return new Promise((t=>{const s=[];Object.entries(e).forEach((e=>{const[t,n]=e;let i=this.options.update&&this.options.update[t]?this.options.update[t]:t,r="replace";"@"===i.substr(0,1)?(r="append",i=i.substr(1)):"^"===i.substr(0,1)?(r="prepend",i=i.substr(1)):"#"!==i.substr(0,1)&&"."!==i.substr(0,1)&&(r="noop");const o=document.querySelectorAll(i);o.length>0&&o.forEach((e=>{switch(r){case"append":e.innerHTML+=n;break;case"prepend":e.innerHTML=n+e.innerHTML;break;case"noop":break;default:e.innerHTML=n}s.push(e),this.snowboard.globalEvent("ajaxUpdate",e,n,this);const t=new Event("ajaxUpdate");t.content=n,e.dispatchEvent(t)}))})),this.snowboard.globalEvent("ajaxUpdateComplete",s,this),t()}))}processResponse(e){if((!this.options.success||"function"!=typeof this.options.success||!1!==this.options.success(this.responseData,this))&&!1!==this.snowboard.globalEvent("ajaxSuccess",this.responseData,this)){if(this.element){const e=new Event("ajaxDone",{cancelable:!0});if(e.responseData=this.responseData,e.request=this,this.element.dispatchEvent(e),e.defaultPrevented)return}this.flash&&e.X_WINTER_FLASH_MESSAGES&&this.processFlashMessages(e.X_WINTER_FLASH_MESSAGES),this.redirect||e.X_WINTER_REDIRECT?this.processRedirect(this.redirect||e.X_WINTER_REDIRECT):this.complete()}}processError(e){if((!this.options.error||"function"!=typeof this.options.error||!1!==this.options.error(this.responseError,this))&&!1!==this.snowboard.globalEvent("ajaxError",this.responseError,this)){if(this.element){const e=new Event("ajaxFail",{cancelable:!0});if(e.responseError=this.responseError,e.request=this,this.element.dispatchEvent(e),e.defaultPrevented)return}if(e instanceof Error)this.processErrorMessage(e.message);else{let t=!1;e.X_WINTER_ERROR_FIELDS&&(t=this.processValidationErrors(e.X_WINTER_ERROR_FIELDS)),e.X_WINTER_ERROR_MESSAGE&&!t&&this.processErrorMessage(e.X_WINTER_ERROR_MESSAGE)}this.complete()}}processRedirect(e){"function"==typeof this.options.handleRedirectResponse&&!1===this.options.handleRedirectResponse.apply(this,[e])||!1!==this.snowboard.globalEvent("ajaxRedirect",e,this)&&(window.addEventListener("popstate",(()=>{if(this.element){const e=document.createEvent("CustomEvent");e.eventName="ajaxRedirected",this.element.dispatchEvent(e)}}),{once:!0}),window.location.assign(e))}processErrorMessage(e){"function"==typeof this.options.handleErrorMessage&&!1===this.options.handleErrorMessage.apply(this,[e])||!1!==this.snowboard.globalEvent("ajaxErrorMessage",e,this)&&window.alert(e)}processFlashMessages(e){"function"==typeof this.options.handleFlashMessages&&!1===this.options.handleFlashMessages.apply(this,[e])||this.snowboard.globalEvent("ajaxFlashMessages",e,this)}processValidationErrors(e){return"function"==typeof this.options.handleValidationErrors&&!1===this.options.handleValidationErrors.apply(this,[this.form,e])||!1===this.snowboard.globalEvent("ajaxValidationErrors",this.form,e,this)}processAssets(e){return this.snowboard.globalPromiseEvent("ajaxLoadAssets",e)}async doConfirm(){if("function"==typeof this.options.handleConfirmMessage)return!1!==this.options.handleConfirmMessage.apply(this,[this.confirm]);if(0===this.snowboard.listensToEvent("ajaxConfirmMessage").length)return window.confirm(this.confirm);const e=this.snowboard.globalPromiseEvent("ajaxConfirmMessage",this.confirm,this);try{if(await e)return!0}catch(e){return!1}return!1}complete(){if(this.options.complete&&"function"==typeof this.options.complete&&this.options.complete(this.responseData,this),this.snowboard.globalEvent("ajaxDone",this.responseData,this),this.element){const e=new Event("ajaxAlways");e.request=this,e.responseData=this.responseData,e.responseError=this.responseError,this.element.dispatchEvent(e)}this.destruct()}get form(){return this.options.form?"string"==typeof this.options.form?document.querySelector(this.options.form):this.options.form:this.element?"FORM"===this.element.tagName?this.element:this.element.closest("form"):null}get context(){return{handler:this.handler,options:this.options}}get headers(){const e={"X-Requested-With":"XMLHttpRequest","X-WINTER-REQUEST-HANDLER":this.handler,"X-WINTER-REQUEST-PARTIALS":this.extractPartials(this.options.update||[])};return this.flash&&(e["X-WINTER-REQUEST-FLASH"]=1),this.xsrfToken&&(e["X-XSRF-TOKEN"]=this.xsrfToken),e}get loading(){return this.options.loading||!1}get url(){return this.options.url||window.location.href}get redirect(){return this.options.redirect&&this.options.redirect.length?this.options.redirect:null}get flash(){return this.options.flash||!1}get files(){return!0===this.options.files&&(void 0!==FormData||(this.snowboard.debug("This browser does not support file uploads"),!1))}get xsrfToken(){return this.snowboard.cookie().get("XSRF-TOKEN")}get data(){const e="object"==typeof this.options.data?this.options.data:{},t=new FormData(this.form||void 0);return Object.keys(e).length>0&&Object.entries(e).forEach((e=>{const[s,n]=e;t.append(s,n)})),t}get confirm(){return this.options.confirm||!1}extractPartials(e){return Object.keys(e).join("&")}renderError(e,t,s,n,i){const r=new Error(e);return r.exception=t||null,r.file=s||null,r.line=n||null,r.trace=i||[],r}isHandlerName(e){return/^(?:\w+:{2})?on[A-Z0-9]/.test(e)}}if(void 0===window.Snowboard)throw new Error("Snowboard must be loaded in order to use the Javascript AJAX request feature.");window.Snowboard.addPlugin("request",a)},47:function(){}},function(e){var t=function(t){return e(e.s=t)};e.O(0,[969,804],(function(){return t(2),t(59),t(590),t(47)}));e.O()}]); \ No newline at end of file diff --git a/modules/system/assets/js/snowboard/build/snowboard.base.debug.js b/modules/system/assets/js/snowboard/build/snowboard.base.debug.js index 513538bfdf..e490f641ee 100644 --- a/modules/system/assets/js/snowboard/build/snowboard.base.debug.js +++ b/modules/system/assets/js/snowboard/build/snowboard.base.debug.js @@ -1 +1 @@ -"use strict";(self.webpackChunk_wintercms_wn_system_module=self.webpackChunk_wintercms_wn_system_module||[]).push([[450],{579:function(e,t,n){n.d(t,{Z:function(){return i}});class i{constructor(e){this.snowboard=e}construct(){}dependencies(){return[]}listens(){return{}}destruct(){this.detach(),delete this.snowboard}destructor(){this.destruct()}}},281:function(e,t,n){n.d(t,{Z:function(){return s}});var i=n(579);class s extends i.Z{}},662:function(e,t){t.Z={get(e,t,n){if("string"==typeof t){const n=t.toLowerCase();if(e.hasPlugin(n))return function(){return Reflect.get(e,"plugins")[n].getInstance(...arguments)}}return Reflect.get(e,t,n)},has(e,t){if("string"==typeof t){const n=t.toLowerCase();if(e.hasPlugin(n))return!0}return Reflect.has(e,t)}}},286:function(e,t,n){n.d(t,{Z:function(){return b}});var i=n(579),s=n(281),r={get(e,t,n){if("string"==typeof t){const n=t.toLowerCase();if(["attachAbstracts","loadUtilities","initialise","initialiseSingletons"].includes(t))throw new Error(`You cannot use the "${t}" Snowboard method within a plugin.`);if(e.hasPlugin(n))return function(){return Reflect.get(e,"plugins")[n].getInstance(...arguments)}}return Reflect.get(e,t,n)},has(e,t){if("string"==typeof t){const n=t.toLowerCase();if(["attachAbstracts","loadUtilities","initialise","initialiseSingletons"].includes(t))return!1;if(e.hasPlugin(n))return!0}return Reflect.has(e,t)}};class o{constructor(e,t,n){this.name=e,this.snowboard=new Proxy(t,r),this.instance=n,Object.freeze(this.instance),this.instances=[],this.singleton={initialised:!1},Object.seal(this.singleton),this.mocks={},this.originalFunctions={},Object.freeze(o.prototype),Object.freeze(this)}hasMethod(e){return!this.isFunction()&&"function"==typeof this.instance.prototype[e]}callMethod(){if(this.isFunction())return null;for(var e=arguments.length,t=new Array(e),n=0;n!this.snowboard.getPluginNames().includes(e)));throw new Error(`The "${this.name}" plugin requires the following plugins: ${e.join(", ")}`)}if(this.isSingleton())return 0===this.instances.length&&this.initialiseSingleton(...n),Object.keys(this.mocks).length>0&&(Object.entries(this.originalFunctions).forEach((e=>{const[t,n]=e;this.instances[0][t]=n})),Object.entries(this.mocks).forEach((t=>{const[n,i]=t;this.instances[0][n]=function(){for(var t=arguments.length,n=new Array(t),s=0;s0&&(Object.entries(this.originalFunctions).forEach((e=>{const[t,n]=e;this.instance.prototype[t]=n})),Object.entries(this.mocks).forEach((t=>{const[n,i]=t;this.instance.prototype[n]=function(){for(var t=arguments.length,n=new Array(t),s=0;sthis.instances.splice(this.instances.indexOf(s),1),s.construct(...n),this.instances.push(s),s}getInstances(){return this.isFunction()?[]:this.instances}isFunction(){return"function"==typeof this.instance&&this.instance.prototype instanceof i.Z==!1}isSingleton(){return this.instance.prototype instanceof s.Z==!0}isInitialised(){return!this.isSingleton()||this.singleton.initialised}initialiseSingleton(){if(!this.isSingleton())return;for(var e=arguments.length,t=new Array(e),n=0;nthis.instances.splice(this.instances.indexOf(i),1),i.construct(...t),this.instances.push(i),this.singleton.initialised=!0}getDependencies(){return this.isFunction()||"function"!=typeof this.instance.prototype.dependencies?[]:this.instance.prototype.dependencies().map((e=>e.toLowerCase()))}dependenciesFulfilled(){const e=this.getDependencies();let t=!0;return e.forEach((e=>{this.snowboard.hasPlugin(e)||(t=!1)})),t}mock(e,t){var n=this;if(!this.isFunction()){if(!this.instance.prototype[e])throw new Error(`Function "${e}" does not exist and cannot be mocked`);this.mocks[e]=t,this.originalFunctions[e]=this.instance.prototype[e],this.isSingleton()&&0===this.instances.length&&(this.initialiseSingleton(),this.instances[0][e]=function(){for(var e=arguments.length,i=new Array(e),s=0;s{const[t,n]=e;void 0!==this.defaults[t]&&(this.defaults[t]=n)}))}getDefaults(){const e={};return Object.entries(this.defaults).forEach((t=>{const[n,i]=t;null!==this.defaults[n]&&(e[n]=i)})),e}get(e){if(void 0===e){const e=l.Z.get();return Object.entries(e).forEach((t=>{const[n,i]=t;this.snowboard.globalEvent("cookie.get",n,i,(t=>{e[n]=t}))})),e}let t=l.Z.get(e);return this.snowboard.globalEvent("cookie.get",e,t,(e=>{t=e})),t}set(e,t,n){let i=t;return this.snowboard.globalEvent("cookie.set",e,t,(e=>{i=e})),l.Z.set(e,i,h(h({},this.getDefaults()),n))}remove(e,t){l.Z.remove(e,h(h({},this.getDefaults()),t))}}class f extends s.Z{construct(){window.wnJSON=e=>this.parse(e),window.ocJSON=window.wnJSON}parse(e){const t=this.parseString(e);return JSON.parse(t)}parseString(e){let t=e.trim();if(!t.length)throw new Error("Broken JSON object.");let n="",i=null,s=null,r="";for(;t&&","===t[0];)t=t.substr(1);if('"'===t[0]||"'"===t[0]){if(t[t.length-1]!==t[0])throw new Error("Invalid string JSON object.");r='"';for(let e=1;e="0"&&e[t]<="9"){n="";for(let i=t;i="0"&&e[i]<="9"))return{originLength:n.length,body:n};n+=e[i]}throw new Error(`Broken JSON number body near ${n}`)}if("{"===e[t]||"["===e[t]){const i=[e[t]];n=e[t];for(let s=t+1;s=0?t-5:0,50)}`)}parseKey(e,t,n){let i="";for(let s=t;s="a"&&e[0]<="z"||e[0]>="A"&&e[0]<="Z"||"_"===e[0]||(e[0]>="0"&&e[0]<="9"||("$"===e[0]||e.charCodeAt(0)>255)))}isBlankChar(e){return" "===e||"\n"===e||"\t"===e}}class d extends s.Z{construct(){window.wnSanitize=e=>this.sanitize(e),window.ocSanitize=window.wnSanitize}sanitize(e,t){const n=(new DOMParser).parseFromString(e,"text/html"),i=void 0===t||"boolean"!=typeof t||t;return this.sanitizeNode(n.getRootNode()),i?n.body.innerHTML:n.innerHTML}sanitizeNode(e){if("SCRIPT"===e.tagName)return void e.remove();this.trimAttributes(e);Array.from(e.children).forEach((e=>{this.sanitizeNode(e)}))}trimAttributes(e){if(e.attributes)for(let t=0;t{this.autoInitSingletons&&this.initialiseSingletons(),this.globalEvent("ready"),this.readiness.dom=!0}))}initialiseSingletons(){Object.values(this.plugins).forEach((e=>{e.isSingleton()&&e.dependenciesFulfilled()&&e.initialiseSingleton()}))}addPlugin(e,t){const n=e.toLowerCase();if(this.hasPlugin(n))throw new Error(`A plugin called "${e}" is already registered.`);if("function"!=typeof t&&t instanceof i.Z==!1)throw new Error("The provided plugin must extend the PluginBase class, or must be a callback function.");if(void 0!==this[e]||void 0!==this[n])throw new Error("The given name is already in use for a property or method of the Snowboard class.");this.plugins[n]=new o(n,this,t),this.debug(`Plugin "${e}" registered`),Object.values(this.getPlugins()).forEach((e=>{if(e.isSingleton()&&!e.isInitialised()&&e.dependenciesFulfilled()&&e.hasMethod("listens")&&Object.keys(e.callMethod("listens")).includes("ready")&&this.readiness.dom){const t=e.callMethod("listens").ready;e.callMethod(t)}}))}removePlugin(e){const t=e.toLowerCase();this.hasPlugin(t)?(this.plugins[t].getInstances().forEach((e=>{e.destruct()})),delete this.plugins[t],delete this[t],delete this[e],this.debug(`Plugin "${e}" removed`)):this.debug(`Plugin "${e}" already removed`)}hasPlugin(e){const t=e.toLowerCase();return void 0!==this.plugins[t]}getPlugins(){return this.plugins}getPluginNames(){return Object.keys(this.plugins)}getPlugin(e){const t=e.toLowerCase();if(!this.hasPlugin(t))throw new Error(`No plugin called "${t}" has been registered.`);return this.plugins[t]}listensToEvent(e){const t=[];return Object.entries(this.plugins).forEach((n=>{const[i,s]=n;if(s.isFunction())return;if(!s.dependenciesFulfilled())return;if(!s.hasMethod("listens"))return;const r=s.callMethod("listens");"string"!=typeof r[e]&&"function"!=typeof r[e]||t.push(i)})),t}ready(e){this.readiness.dom&&e(),this.on("ready",e)}on(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].includes(t)||this.listeners[e].push(t)}off(e,t){if(!this.listeners[e])return;const n=this.listeners[e].indexOf(t);-1!==n&&this.listeners[e].splice(n,1)}globalEvent(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i{const i=this.getPlugin(t);if(i.isFunction())return;i.isSingleton()&&0===i.getInstances().length&&i.initialiseSingleton();const s=i.callMethod("listens")[e];i.getInstances().forEach((i=>{if(!r)if("function"==typeof s)try{!1===s.apply(i,n)&&(r=!0)}catch(n){this.error(`Error thrown in "${e}" event by "${t}" plugin.`,n)}else if("string"==typeof s){if(!i[s])throw new Error(`Missing "${s}" method in "${t}" plugin`);try{!1===i[s](...n)&&(r=!0,this.debug(`Global event "${e}" cancelled by "${t}" plugin`))}catch(n){this.error(`Error thrown in "${e}" event by "${t}" plugin.`,n)}}else this.error(`Listen method for "${e}" event in "${t}" plugin is not a function or string.`)}))})),!r&&this.listeners[e]&&this.listeners[e].length>0&&(this.debug(`Found ${this.listeners[e].length} ad-hoc listener(s) for global event "${e}"`),this.listeners[e].forEach((t=>{if(!r)try{!1===t(...n)&&(r=!0,this.debug(`Global event "${e} cancelled by an ad-hoc listener.`))}catch(t){this.error(`Error thrown in "${e}" event by an ad-hoc listener.`,t)}}))),!r}globalPromiseEvent(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i{const i=this.getPlugin(t);if(i.isFunction())return;i.isSingleton()&&0===i.getInstances().length&&i.initialiseSingleton();const s=i.callMethod("listens")[e];i.getInstances().forEach((i=>{if("function"==typeof s)try{const e=s.apply(i,n);if(e instanceof Promise==!1)return;r.push(e)}catch(n){this.error(`Error thrown in "${e}" event by "${t}" plugin.`,n)}else if("string"==typeof s){if(!i[s])throw new Error(`Missing "${s}" method in "${t}" plugin`);try{const e=i[s](...n);if(e instanceof Promise==!1)return;r.push(e)}catch(n){this.error(`Error thrown in "${e}" promise event by "${t}" plugin.`,n)}}else this.error(`Listen method for "${e}" event in "${t}" plugin is not a function or string.`)}))})),this.listeners[e]&&this.listeners[e].length>0&&(this.debug(`Found ${this.listeners[e].length} ad-hoc listener(s) for global promise event "${e}"`),this.listeners[e].forEach((t=>{try{const e=t(...n);if(e instanceof Promise==!1)return;r.push(e)}catch(t){this.error(`Error thrown in "${e}" promise event by an ad-hoc listener.`,t)}}))),0===r.length?Promise.resolve():Promise.all(r)}logMessage(e,t,n){console.groupCollapsed("%c[Snowboard]",`color: ${e}; font-weight: ${t?"bold":"normal"};`,n);for(var i=arguments.length,s=new Array(i>3?i-3:0),r=3;r{e+=1,console.log(`%c${e}:`,"color: rgb(88, 88, 88); font-weight: normal;",t)})),console.groupEnd(),console.groupCollapsed("%cTrace","color: rgb(45, 167, 199); font-weight: bold;"),console.trace(),console.groupEnd()}else console.trace();console.groupEnd()}log(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i1?t-1:0),i=1;i1?t-1:0),i=1;i{const t=new Proxy(new i.Z(!0,!0),s.Z);e.snowboard=t,e.Snowboard=t,e.SnowBoard=t})(window)}},function(e){e.O(0,[109],(function(){return t=165,e(e.s=t);var t}));e.O()}]); \ No newline at end of file +"use strict";(self.webpackChunk_wintercms_wn_system_module=self.webpackChunk_wintercms_wn_system_module||[]).push([[38],{660:function(e,t,n){n.d(t,{A:function(){return i}});class i{constructor(e){this.snowboard=e}construct(){}dependencies(){return[]}listens(){return{}}destruct(){this.detach(),delete this.snowboard}destructor(){this.destruct()}}},373:function(e,t,n){n.d(t,{A:function(){return s}});var i=n(660);class s extends i.A{}},54:function(e,t){t.A={get(e,t,n){if("string"==typeof t){const n=t.toLowerCase();if(e.hasPlugin(n))return function(){return Reflect.get(e,"plugins")[n].getInstance(...arguments)}}return Reflect.get(e,t,n)},has(e,t){if("string"==typeof t){const n=t.toLowerCase();if(e.hasPlugin(n))return!0}return Reflect.has(e,t)}}},160:function(e,t,n){n.d(t,{A:function(){return b}});var i=n(660),s=n(373),r={get(e,t,n){if("string"==typeof t){const n=t.toLowerCase();if(["attachAbstracts","loadUtilities","initialise","initialiseSingletons"].includes(t))throw new Error(`You cannot use the "${t}" Snowboard method within a plugin.`);if(e.hasPlugin(n))return function(){return Reflect.get(e,"plugins")[n].getInstance(...arguments)}}return Reflect.get(e,t,n)},has(e,t){if("string"==typeof t){const n=t.toLowerCase();if(["attachAbstracts","loadUtilities","initialise","initialiseSingletons"].includes(t))return!1;if(e.hasPlugin(n))return!0}return Reflect.has(e,t)}};class o{constructor(e,t,n){this.name=e,this.snowboard=new Proxy(t,r),this.instance=n,Object.freeze(this.instance),this.instances=[],this.singleton={initialised:!1},Object.seal(this.singleton),this.mocks={},this.originalFunctions={},Object.freeze(o.prototype),Object.freeze(this)}hasMethod(e){return!this.isFunction()&&"function"==typeof this.instance.prototype[e]}callMethod(){if(this.isFunction())return null;for(var e=arguments.length,t=new Array(e),n=0;n!this.snowboard.getPluginNames().includes(e)));throw new Error(`The "${this.name}" plugin requires the following plugins: ${e.join(", ")}`)}if(this.isSingleton())return 0===this.instances.length&&this.initialiseSingleton(...n),Object.keys(this.mocks).length>0&&(Object.entries(this.originalFunctions).forEach((e=>{const[t,n]=e;this.instances[0][t]=n})),Object.entries(this.mocks).forEach((t=>{const[n,i]=t;this.instances[0][n]=function(){for(var t=arguments.length,n=new Array(t),s=0;s0&&(Object.entries(this.originalFunctions).forEach((e=>{const[t,n]=e;this.instance.prototype[t]=n})),Object.entries(this.mocks).forEach((t=>{const[n,i]=t;this.instance.prototype[n]=function(){for(var t=arguments.length,n=new Array(t),s=0;sthis.instances.splice(this.instances.indexOf(s),1),s.construct(...n),this.instances.push(s),s}getInstances(){return this.isFunction()?[]:this.instances}isFunction(){return"function"==typeof this.instance&&this.instance.prototype instanceof i.A==!1}isSingleton(){return this.instance.prototype instanceof s.A==!0}isInitialised(){return!this.isSingleton()||this.singleton.initialised}initialiseSingleton(){if(!this.isSingleton())return;for(var e=arguments.length,t=new Array(e),n=0;nthis.instances.splice(this.instances.indexOf(i),1),i.construct(...t),this.instances.push(i),this.singleton.initialised=!0}getDependencies(){return this.isFunction()||"function"!=typeof this.instance.prototype.dependencies?[]:this.instance.prototype.dependencies().map((e=>e.toLowerCase()))}dependenciesFulfilled(){const e=this.getDependencies();let t=!0;return e.forEach((e=>{this.snowboard.hasPlugin(e)||(t=!1)})),t}mock(e,t){var n=this;if(!this.isFunction()){if(!this.instance.prototype[e])throw new Error(`Function "${e}" does not exist and cannot be mocked`);this.mocks[e]=t,this.originalFunctions[e]=this.instance.prototype[e],this.isSingleton()&&0===this.instances.length&&(this.initialiseSingleton(),this.instances[0][e]=function(){for(var e=arguments.length,i=new Array(e),s=0;s{const[t,n]=e;void 0!==this.defaults[t]&&(this.defaults[t]=n)}))}getDefaults(){const e={};return Object.entries(this.defaults).forEach((t=>{const[n,i]=t;null!==this.defaults[n]&&(e[n]=i)})),e}get(e){if(void 0===e){const e=l.A.get();return Object.entries(e).forEach((t=>{const[n,i]=t;this.snowboard.globalEvent("cookie.get",n,i,(t=>{e[n]=t}))})),e}let t=l.A.get(e);return this.snowboard.globalEvent("cookie.get",e,t,(e=>{t=e})),t}set(e,t,n){let i=t;return this.snowboard.globalEvent("cookie.set",e,t,(e=>{i=e})),l.A.set(e,i,h(h({},this.getDefaults()),n))}remove(e,t){l.A.remove(e,h(h({},this.getDefaults()),t))}}class f extends s.A{construct(){window.wnJSON=e=>this.parse(e),window.ocJSON=window.wnJSON}parse(e){const t=this.parseString(e);return JSON.parse(t)}parseString(e){let t=e.trim();if(!t.length)throw new Error("Broken JSON object.");let n="",i=null,s=null,r="";for(;t&&","===t[0];)t=t.substr(1);if('"'===t[0]||"'"===t[0]){if(t[t.length-1]!==t[0])throw new Error("Invalid string JSON object.");r='"';for(let e=1;e="0"&&e[t]<="9"){n="";for(let i=t;i="0"&&e[i]<="9"))return{originLength:n.length,body:n};n+=e[i]}throw new Error(`Broken JSON number body near ${n}`)}if("{"===e[t]||"["===e[t]){const i=[e[t]];n=e[t];for(let s=t+1;s=0?t-5:0,50)}`)}parseKey(e,t,n){let i="";for(let s=t;s="a"&&e[0]<="z"||e[0]>="A"&&e[0]<="Z"||"_"===e[0]||(e[0]>="0"&&e[0]<="9"||("$"===e[0]||e.charCodeAt(0)>255)))}isBlankChar(e){return" "===e||"\n"===e||"\t"===e}}class d extends s.A{construct(){window.wnSanitize=e=>this.sanitize(e),window.ocSanitize=window.wnSanitize}sanitize(e,t){const n=(new DOMParser).parseFromString(e,"text/html"),i=void 0===t||"boolean"!=typeof t||t;return this.sanitizeNode(n.getRootNode()),i?n.body.innerHTML:n.innerHTML}sanitizeNode(e){if("SCRIPT"===e.tagName)return void e.remove();this.trimAttributes(e);Array.from(e.children).forEach((e=>{this.sanitizeNode(e)}))}trimAttributes(e){if(e.attributes)for(let t=0;t{this.autoInitSingletons&&this.initialiseSingletons(),this.globalEvent("ready"),this.readiness.dom=!0}))}initialiseSingletons(){Object.values(this.plugins).forEach((e=>{e.isSingleton()&&e.dependenciesFulfilled()&&e.initialiseSingleton()}))}addPlugin(e,t){const n=e.toLowerCase();if(this.hasPlugin(n))throw new Error(`A plugin called "${e}" is already registered.`);if("function"!=typeof t&&t instanceof i.A==!1)throw new Error("The provided plugin must extend the PluginBase class, or must be a callback function.");if(void 0!==this[e]||void 0!==this[n])throw new Error("The given name is already in use for a property or method of the Snowboard class.");this.plugins[n]=new o(n,this,t),this.debug(`Plugin "${e}" registered`),Object.values(this.getPlugins()).forEach((e=>{if(e.isSingleton()&&!e.isInitialised()&&e.dependenciesFulfilled()&&e.hasMethod("listens")&&Object.keys(e.callMethod("listens")).includes("ready")&&this.readiness.dom){const t=e.callMethod("listens").ready;e.callMethod(t)}}))}removePlugin(e){const t=e.toLowerCase();this.hasPlugin(t)?(this.plugins[t].getInstances().forEach((e=>{e.destruct()})),delete this.plugins[t],delete this[t],delete this[e],this.debug(`Plugin "${e}" removed`)):this.debug(`Plugin "${e}" already removed`)}hasPlugin(e){const t=e.toLowerCase();return void 0!==this.plugins[t]}getPlugins(){return this.plugins}getPluginNames(){return Object.keys(this.plugins)}getPlugin(e){const t=e.toLowerCase();if(!this.hasPlugin(t))throw new Error(`No plugin called "${t}" has been registered.`);return this.plugins[t]}listensToEvent(e){const t=[];return Object.entries(this.plugins).forEach((n=>{const[i,s]=n;if(s.isFunction())return;if(!s.dependenciesFulfilled())return;if(!s.hasMethod("listens"))return;const r=s.callMethod("listens");"string"!=typeof r[e]&&"function"!=typeof r[e]||t.push(i)})),t}ready(e){this.readiness.dom&&e(),this.on("ready",e)}on(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].includes(t)||this.listeners[e].push(t)}off(e,t){if(!this.listeners[e])return;const n=this.listeners[e].indexOf(t);-1!==n&&this.listeners[e].splice(n,1)}globalEvent(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i{const i=this.getPlugin(t);if(i.isFunction())return;i.isSingleton()&&0===i.getInstances().length&&i.initialiseSingleton();const s=i.callMethod("listens")[e];i.getInstances().forEach((i=>{if(!r)if("function"==typeof s)try{!1===s.apply(i,n)&&(r=!0)}catch(n){this.error(`Error thrown in "${e}" event by "${t}" plugin.`,n)}else if("string"==typeof s){if(!i[s])throw new Error(`Missing "${s}" method in "${t}" plugin`);try{!1===i[s](...n)&&(r=!0,this.debug(`Global event "${e}" cancelled by "${t}" plugin`))}catch(n){this.error(`Error thrown in "${e}" event by "${t}" plugin.`,n)}}else this.error(`Listen method for "${e}" event in "${t}" plugin is not a function or string.`)}))})),!r&&this.listeners[e]&&this.listeners[e].length>0&&(this.debug(`Found ${this.listeners[e].length} ad-hoc listener(s) for global event "${e}"`),this.listeners[e].forEach((t=>{if(!r)try{!1===t(...n)&&(r=!0,this.debug(`Global event "${e} cancelled by an ad-hoc listener.`))}catch(t){this.error(`Error thrown in "${e}" event by an ad-hoc listener.`,t)}}))),!r}globalPromiseEvent(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i{const i=this.getPlugin(t);if(i.isFunction())return;i.isSingleton()&&0===i.getInstances().length&&i.initialiseSingleton();const s=i.callMethod("listens")[e];i.getInstances().forEach((i=>{if("function"==typeof s)try{const e=s.apply(i,n);if(e instanceof Promise==!1)return;r.push(e)}catch(n){this.error(`Error thrown in "${e}" event by "${t}" plugin.`,n)}else if("string"==typeof s){if(!i[s])throw new Error(`Missing "${s}" method in "${t}" plugin`);try{const e=i[s](...n);if(e instanceof Promise==!1)return;r.push(e)}catch(n){this.error(`Error thrown in "${e}" promise event by "${t}" plugin.`,n)}}else this.error(`Listen method for "${e}" event in "${t}" plugin is not a function or string.`)}))})),this.listeners[e]&&this.listeners[e].length>0&&(this.debug(`Found ${this.listeners[e].length} ad-hoc listener(s) for global promise event "${e}"`),this.listeners[e].forEach((t=>{try{const e=t(...n);if(e instanceof Promise==!1)return;r.push(e)}catch(t){this.error(`Error thrown in "${e}" promise event by an ad-hoc listener.`,t)}}))),0===r.length?Promise.resolve():Promise.all(r)}logMessage(e,t,n){console.groupCollapsed("%c[Snowboard]",`color: ${e}; font-weight: ${t?"bold":"normal"};`,n);for(var i=arguments.length,s=new Array(i>3?i-3:0),r=3;r{e+=1,console.log(`%c${e}:`,"color: rgb(88, 88, 88); font-weight: normal;",t)})),console.groupEnd(),console.groupCollapsed("%cTrace","color: rgb(45, 167, 199); font-weight: bold;"),console.trace(),console.groupEnd()}else console.trace();console.groupEnd()}log(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i1?t-1:0),i=1;i1?t-1:0),i=1;i{const t=new Proxy(new i.A(!0,!0),s.A);e.snowboard=t,e.Snowboard=t,e.SnowBoard=t})(window)}},function(e){e.O(0,[969],(function(){return t=799,e(e.s=t);var t}));e.O()}]); \ No newline at end of file diff --git a/modules/system/assets/js/snowboard/build/snowboard.base.js b/modules/system/assets/js/snowboard/build/snowboard.base.js index e92fb327a1..f02f177fd4 100644 --- a/modules/system/assets/js/snowboard/build/snowboard.base.js +++ b/modules/system/assets/js/snowboard/build/snowboard.base.js @@ -1 +1 @@ -"use strict";(self.webpackChunk_wintercms_wn_system_module=self.webpackChunk_wintercms_wn_system_module||[]).push([[243],{579:function(e,t,n){n.d(t,{Z:function(){return i}});class i{constructor(e){this.snowboard=e}construct(){}dependencies(){return[]}listens(){return{}}destruct(){this.detach(),delete this.snowboard}destructor(){this.destruct()}}},281:function(e,t,n){n.d(t,{Z:function(){return s}});var i=n(579);class s extends i.Z{}},662:function(e,t){t.Z={get(e,t,n){if("string"==typeof t){const n=t.toLowerCase();if(e.hasPlugin(n))return function(){return Reflect.get(e,"plugins")[n].getInstance(...arguments)}}return Reflect.get(e,t,n)},has(e,t){if("string"==typeof t){const n=t.toLowerCase();if(e.hasPlugin(n))return!0}return Reflect.has(e,t)}}},286:function(e,t,n){n.d(t,{Z:function(){return b}});var i=n(579),s=n(281),r={get(e,t,n){if("string"==typeof t){const n=t.toLowerCase();if(["attachAbstracts","loadUtilities","initialise","initialiseSingletons"].includes(t))throw new Error(`You cannot use the "${t}" Snowboard method within a plugin.`);if(e.hasPlugin(n))return function(){return Reflect.get(e,"plugins")[n].getInstance(...arguments)}}return Reflect.get(e,t,n)},has(e,t){if("string"==typeof t){const n=t.toLowerCase();if(["attachAbstracts","loadUtilities","initialise","initialiseSingletons"].includes(t))return!1;if(e.hasPlugin(n))return!0}return Reflect.has(e,t)}};class o{constructor(e,t,n){this.name=e,this.snowboard=new Proxy(t,r),this.instance=n,Object.freeze(this.instance),this.instances=[],this.singleton={initialised:!1},Object.seal(this.singleton),this.mocks={},this.originalFunctions={},Object.freeze(o.prototype),Object.freeze(this)}hasMethod(e){return!this.isFunction()&&"function"==typeof this.instance.prototype[e]}callMethod(){if(this.isFunction())return null;for(var e=arguments.length,t=new Array(e),n=0;n!this.snowboard.getPluginNames().includes(e)));throw new Error(`The "${this.name}" plugin requires the following plugins: ${e.join(", ")}`)}if(this.isSingleton())return 0===this.instances.length&&this.initialiseSingleton(...n),Object.keys(this.mocks).length>0&&(Object.entries(this.originalFunctions).forEach((e=>{const[t,n]=e;this.instances[0][t]=n})),Object.entries(this.mocks).forEach((t=>{const[n,i]=t;this.instances[0][n]=function(){for(var t=arguments.length,n=new Array(t),s=0;s0&&(Object.entries(this.originalFunctions).forEach((e=>{const[t,n]=e;this.instance.prototype[t]=n})),Object.entries(this.mocks).forEach((t=>{const[n,i]=t;this.instance.prototype[n]=function(){for(var t=arguments.length,n=new Array(t),s=0;sthis.instances.splice(this.instances.indexOf(s),1),s.construct(...n),this.instances.push(s),s}getInstances(){return this.isFunction()?[]:this.instances}isFunction(){return"function"==typeof this.instance&&this.instance.prototype instanceof i.Z==!1}isSingleton(){return this.instance.prototype instanceof s.Z==!0}isInitialised(){return!this.isSingleton()||this.singleton.initialised}initialiseSingleton(){if(!this.isSingleton())return;for(var e=arguments.length,t=new Array(e),n=0;nthis.instances.splice(this.instances.indexOf(i),1),i.construct(...t),this.instances.push(i),this.singleton.initialised=!0}getDependencies(){return this.isFunction()||"function"!=typeof this.instance.prototype.dependencies?[]:this.instance.prototype.dependencies().map((e=>e.toLowerCase()))}dependenciesFulfilled(){const e=this.getDependencies();let t=!0;return e.forEach((e=>{this.snowboard.hasPlugin(e)||(t=!1)})),t}mock(e,t){var n=this;if(!this.isFunction()){if(!this.instance.prototype[e])throw new Error(`Function "${e}" does not exist and cannot be mocked`);this.mocks[e]=t,this.originalFunctions[e]=this.instance.prototype[e],this.isSingleton()&&0===this.instances.length&&(this.initialiseSingleton(),this.instances[0][e]=function(){for(var e=arguments.length,i=new Array(e),s=0;s{const[t,n]=e;void 0!==this.defaults[t]&&(this.defaults[t]=n)}))}getDefaults(){const e={};return Object.entries(this.defaults).forEach((t=>{const[n,i]=t;null!==this.defaults[n]&&(e[n]=i)})),e}get(e){if(void 0===e){const e=l.Z.get();return Object.entries(e).forEach((t=>{const[n,i]=t;this.snowboard.globalEvent("cookie.get",n,i,(t=>{e[n]=t}))})),e}let t=l.Z.get(e);return this.snowboard.globalEvent("cookie.get",e,t,(e=>{t=e})),t}set(e,t,n){let i=t;return this.snowboard.globalEvent("cookie.set",e,t,(e=>{i=e})),l.Z.set(e,i,h(h({},this.getDefaults()),n))}remove(e,t){l.Z.remove(e,h(h({},this.getDefaults()),t))}}class f extends s.Z{construct(){window.wnJSON=e=>this.parse(e),window.ocJSON=window.wnJSON}parse(e){const t=this.parseString(e);return JSON.parse(t)}parseString(e){let t=e.trim();if(!t.length)throw new Error("Broken JSON object.");let n="",i=null,s=null,r="";for(;t&&","===t[0];)t=t.substr(1);if('"'===t[0]||"'"===t[0]){if(t[t.length-1]!==t[0])throw new Error("Invalid string JSON object.");r='"';for(let e=1;e="0"&&e[t]<="9"){n="";for(let i=t;i="0"&&e[i]<="9"))return{originLength:n.length,body:n};n+=e[i]}throw new Error(`Broken JSON number body near ${n}`)}if("{"===e[t]||"["===e[t]){const i=[e[t]];n=e[t];for(let s=t+1;s=0?t-5:0,50)}`)}parseKey(e,t,n){let i="";for(let s=t;s="a"&&e[0]<="z"||e[0]>="A"&&e[0]<="Z"||"_"===e[0]||(e[0]>="0"&&e[0]<="9"||("$"===e[0]||e.charCodeAt(0)>255)))}isBlankChar(e){return" "===e||"\n"===e||"\t"===e}}class d extends s.Z{construct(){window.wnSanitize=e=>this.sanitize(e),window.ocSanitize=window.wnSanitize}sanitize(e,t){const n=(new DOMParser).parseFromString(e,"text/html"),i=void 0===t||"boolean"!=typeof t||t;return this.sanitizeNode(n.getRootNode()),i?n.body.innerHTML:n.innerHTML}sanitizeNode(e){if("SCRIPT"===e.tagName)return void e.remove();this.trimAttributes(e);Array.from(e.children).forEach((e=>{this.sanitizeNode(e)}))}trimAttributes(e){if(e.attributes)for(let t=0;t{this.autoInitSingletons&&this.initialiseSingletons(),this.globalEvent("ready"),this.readiness.dom=!0}))}initialiseSingletons(){Object.values(this.plugins).forEach((e=>{e.isSingleton()&&e.dependenciesFulfilled()&&e.initialiseSingleton()}))}addPlugin(e,t){const n=e.toLowerCase();if(this.hasPlugin(n))throw new Error(`A plugin called "${e}" is already registered.`);if("function"!=typeof t&&t instanceof i.Z==!1)throw new Error("The provided plugin must extend the PluginBase class, or must be a callback function.");if(void 0!==this[e]||void 0!==this[n])throw new Error("The given name is already in use for a property or method of the Snowboard class.");this.plugins[n]=new o(n,this,t),this.debug(`Plugin "${e}" registered`),Object.values(this.getPlugins()).forEach((e=>{if(e.isSingleton()&&!e.isInitialised()&&e.dependenciesFulfilled()&&e.hasMethod("listens")&&Object.keys(e.callMethod("listens")).includes("ready")&&this.readiness.dom){const t=e.callMethod("listens").ready;e.callMethod(t)}}))}removePlugin(e){const t=e.toLowerCase();this.hasPlugin(t)?(this.plugins[t].getInstances().forEach((e=>{e.destruct()})),delete this.plugins[t],delete this[t],delete this[e],this.debug(`Plugin "${e}" removed`)):this.debug(`Plugin "${e}" already removed`)}hasPlugin(e){const t=e.toLowerCase();return void 0!==this.plugins[t]}getPlugins(){return this.plugins}getPluginNames(){return Object.keys(this.plugins)}getPlugin(e){const t=e.toLowerCase();if(!this.hasPlugin(t))throw new Error(`No plugin called "${t}" has been registered.`);return this.plugins[t]}listensToEvent(e){const t=[];return Object.entries(this.plugins).forEach((n=>{const[i,s]=n;if(s.isFunction())return;if(!s.dependenciesFulfilled())return;if(!s.hasMethod("listens"))return;const r=s.callMethod("listens");"string"!=typeof r[e]&&"function"!=typeof r[e]||t.push(i)})),t}ready(e){this.readiness.dom&&e(),this.on("ready",e)}on(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].includes(t)||this.listeners[e].push(t)}off(e,t){if(!this.listeners[e])return;const n=this.listeners[e].indexOf(t);-1!==n&&this.listeners[e].splice(n,1)}globalEvent(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i{const i=this.getPlugin(t);if(i.isFunction())return;i.isSingleton()&&0===i.getInstances().length&&i.initialiseSingleton();const s=i.callMethod("listens")[e];i.getInstances().forEach((i=>{if(!r)if("function"==typeof s)try{!1===s.apply(i,n)&&(r=!0)}catch(n){this.error(`Error thrown in "${e}" event by "${t}" plugin.`,n)}else if("string"==typeof s){if(!i[s])throw new Error(`Missing "${s}" method in "${t}" plugin`);try{!1===i[s](...n)&&(r=!0,this.debug(`Global event "${e}" cancelled by "${t}" plugin`))}catch(n){this.error(`Error thrown in "${e}" event by "${t}" plugin.`,n)}}else this.error(`Listen method for "${e}" event in "${t}" plugin is not a function or string.`)}))})),!r&&this.listeners[e]&&this.listeners[e].length>0&&(this.debug(`Found ${this.listeners[e].length} ad-hoc listener(s) for global event "${e}"`),this.listeners[e].forEach((t=>{if(!r)try{!1===t(...n)&&(r=!0,this.debug(`Global event "${e} cancelled by an ad-hoc listener.`))}catch(t){this.error(`Error thrown in "${e}" event by an ad-hoc listener.`,t)}}))),!r}globalPromiseEvent(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i{const i=this.getPlugin(t);if(i.isFunction())return;i.isSingleton()&&0===i.getInstances().length&&i.initialiseSingleton();const s=i.callMethod("listens")[e];i.getInstances().forEach((i=>{if("function"==typeof s)try{const e=s.apply(i,n);if(e instanceof Promise==!1)return;r.push(e)}catch(n){this.error(`Error thrown in "${e}" event by "${t}" plugin.`,n)}else if("string"==typeof s){if(!i[s])throw new Error(`Missing "${s}" method in "${t}" plugin`);try{const e=i[s](...n);if(e instanceof Promise==!1)return;r.push(e)}catch(n){this.error(`Error thrown in "${e}" promise event by "${t}" plugin.`,n)}}else this.error(`Listen method for "${e}" event in "${t}" plugin is not a function or string.`)}))})),this.listeners[e]&&this.listeners[e].length>0&&(this.debug(`Found ${this.listeners[e].length} ad-hoc listener(s) for global promise event "${e}"`),this.listeners[e].forEach((t=>{try{const e=t(...n);if(e instanceof Promise==!1)return;r.push(e)}catch(t){this.error(`Error thrown in "${e}" promise event by an ad-hoc listener.`,t)}}))),0===r.length?Promise.resolve():Promise.all(r)}logMessage(e,t,n){console.groupCollapsed("%c[Snowboard]",`color: ${e}; font-weight: ${t?"bold":"normal"};`,n);for(var i=arguments.length,s=new Array(i>3?i-3:0),r=3;r{e+=1,console.log(`%c${e}:`,"color: rgb(88, 88, 88); font-weight: normal;",t)})),console.groupEnd(),console.groupCollapsed("%cTrace","color: rgb(45, 167, 199); font-weight: bold;"),console.trace(),console.groupEnd()}else console.trace();console.groupEnd()}log(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i1?t-1:0),i=1;i1?t-1:0),i=1;i{const t=new Proxy(new i.Z,s.Z);e.snowboard=t,e.Snowboard=t,e.SnowBoard=t})(window)}},function(e){e.O(0,[109],(function(){return t=236,e(e.s=t);var t}));e.O()}]); \ No newline at end of file +"use strict";(self.webpackChunk_wintercms_wn_system_module=self.webpackChunk_wintercms_wn_system_module||[]).push([[861],{660:function(e,t,n){n.d(t,{A:function(){return i}});class i{constructor(e){this.snowboard=e}construct(){}dependencies(){return[]}listens(){return{}}destruct(){this.detach(),delete this.snowboard}destructor(){this.destruct()}}},373:function(e,t,n){n.d(t,{A:function(){return s}});var i=n(660);class s extends i.A{}},54:function(e,t){t.A={get(e,t,n){if("string"==typeof t){const n=t.toLowerCase();if(e.hasPlugin(n))return function(){return Reflect.get(e,"plugins")[n].getInstance(...arguments)}}return Reflect.get(e,t,n)},has(e,t){if("string"==typeof t){const n=t.toLowerCase();if(e.hasPlugin(n))return!0}return Reflect.has(e,t)}}},160:function(e,t,n){n.d(t,{A:function(){return b}});var i=n(660),s=n(373),r={get(e,t,n){if("string"==typeof t){const n=t.toLowerCase();if(["attachAbstracts","loadUtilities","initialise","initialiseSingletons"].includes(t))throw new Error(`You cannot use the "${t}" Snowboard method within a plugin.`);if(e.hasPlugin(n))return function(){return Reflect.get(e,"plugins")[n].getInstance(...arguments)}}return Reflect.get(e,t,n)},has(e,t){if("string"==typeof t){const n=t.toLowerCase();if(["attachAbstracts","loadUtilities","initialise","initialiseSingletons"].includes(t))return!1;if(e.hasPlugin(n))return!0}return Reflect.has(e,t)}};class o{constructor(e,t,n){this.name=e,this.snowboard=new Proxy(t,r),this.instance=n,Object.freeze(this.instance),this.instances=[],this.singleton={initialised:!1},Object.seal(this.singleton),this.mocks={},this.originalFunctions={},Object.freeze(o.prototype),Object.freeze(this)}hasMethod(e){return!this.isFunction()&&"function"==typeof this.instance.prototype[e]}callMethod(){if(this.isFunction())return null;for(var e=arguments.length,t=new Array(e),n=0;n!this.snowboard.getPluginNames().includes(e)));throw new Error(`The "${this.name}" plugin requires the following plugins: ${e.join(", ")}`)}if(this.isSingleton())return 0===this.instances.length&&this.initialiseSingleton(...n),Object.keys(this.mocks).length>0&&(Object.entries(this.originalFunctions).forEach((e=>{const[t,n]=e;this.instances[0][t]=n})),Object.entries(this.mocks).forEach((t=>{const[n,i]=t;this.instances[0][n]=function(){for(var t=arguments.length,n=new Array(t),s=0;s0&&(Object.entries(this.originalFunctions).forEach((e=>{const[t,n]=e;this.instance.prototype[t]=n})),Object.entries(this.mocks).forEach((t=>{const[n,i]=t;this.instance.prototype[n]=function(){for(var t=arguments.length,n=new Array(t),s=0;sthis.instances.splice(this.instances.indexOf(s),1),s.construct(...n),this.instances.push(s),s}getInstances(){return this.isFunction()?[]:this.instances}isFunction(){return"function"==typeof this.instance&&this.instance.prototype instanceof i.A==!1}isSingleton(){return this.instance.prototype instanceof s.A==!0}isInitialised(){return!this.isSingleton()||this.singleton.initialised}initialiseSingleton(){if(!this.isSingleton())return;for(var e=arguments.length,t=new Array(e),n=0;nthis.instances.splice(this.instances.indexOf(i),1),i.construct(...t),this.instances.push(i),this.singleton.initialised=!0}getDependencies(){return this.isFunction()||"function"!=typeof this.instance.prototype.dependencies?[]:this.instance.prototype.dependencies().map((e=>e.toLowerCase()))}dependenciesFulfilled(){const e=this.getDependencies();let t=!0;return e.forEach((e=>{this.snowboard.hasPlugin(e)||(t=!1)})),t}mock(e,t){var n=this;if(!this.isFunction()){if(!this.instance.prototype[e])throw new Error(`Function "${e}" does not exist and cannot be mocked`);this.mocks[e]=t,this.originalFunctions[e]=this.instance.prototype[e],this.isSingleton()&&0===this.instances.length&&(this.initialiseSingleton(),this.instances[0][e]=function(){for(var e=arguments.length,i=new Array(e),s=0;s{const[t,n]=e;void 0!==this.defaults[t]&&(this.defaults[t]=n)}))}getDefaults(){const e={};return Object.entries(this.defaults).forEach((t=>{const[n,i]=t;null!==this.defaults[n]&&(e[n]=i)})),e}get(e){if(void 0===e){const e=l.A.get();return Object.entries(e).forEach((t=>{const[n,i]=t;this.snowboard.globalEvent("cookie.get",n,i,(t=>{e[n]=t}))})),e}let t=l.A.get(e);return this.snowboard.globalEvent("cookie.get",e,t,(e=>{t=e})),t}set(e,t,n){let i=t;return this.snowboard.globalEvent("cookie.set",e,t,(e=>{i=e})),l.A.set(e,i,h(h({},this.getDefaults()),n))}remove(e,t){l.A.remove(e,h(h({},this.getDefaults()),t))}}class f extends s.A{construct(){window.wnJSON=e=>this.parse(e),window.ocJSON=window.wnJSON}parse(e){const t=this.parseString(e);return JSON.parse(t)}parseString(e){let t=e.trim();if(!t.length)throw new Error("Broken JSON object.");let n="",i=null,s=null,r="";for(;t&&","===t[0];)t=t.substr(1);if('"'===t[0]||"'"===t[0]){if(t[t.length-1]!==t[0])throw new Error("Invalid string JSON object.");r='"';for(let e=1;e="0"&&e[t]<="9"){n="";for(let i=t;i="0"&&e[i]<="9"))return{originLength:n.length,body:n};n+=e[i]}throw new Error(`Broken JSON number body near ${n}`)}if("{"===e[t]||"["===e[t]){const i=[e[t]];n=e[t];for(let s=t+1;s=0?t-5:0,50)}`)}parseKey(e,t,n){let i="";for(let s=t;s="a"&&e[0]<="z"||e[0]>="A"&&e[0]<="Z"||"_"===e[0]||(e[0]>="0"&&e[0]<="9"||("$"===e[0]||e.charCodeAt(0)>255)))}isBlankChar(e){return" "===e||"\n"===e||"\t"===e}}class d extends s.A{construct(){window.wnSanitize=e=>this.sanitize(e),window.ocSanitize=window.wnSanitize}sanitize(e,t){const n=(new DOMParser).parseFromString(e,"text/html"),i=void 0===t||"boolean"!=typeof t||t;return this.sanitizeNode(n.getRootNode()),i?n.body.innerHTML:n.innerHTML}sanitizeNode(e){if("SCRIPT"===e.tagName)return void e.remove();this.trimAttributes(e);Array.from(e.children).forEach((e=>{this.sanitizeNode(e)}))}trimAttributes(e){if(e.attributes)for(let t=0;t{this.autoInitSingletons&&this.initialiseSingletons(),this.globalEvent("ready"),this.readiness.dom=!0}))}initialiseSingletons(){Object.values(this.plugins).forEach((e=>{e.isSingleton()&&e.dependenciesFulfilled()&&e.initialiseSingleton()}))}addPlugin(e,t){const n=e.toLowerCase();if(this.hasPlugin(n))throw new Error(`A plugin called "${e}" is already registered.`);if("function"!=typeof t&&t instanceof i.A==!1)throw new Error("The provided plugin must extend the PluginBase class, or must be a callback function.");if(void 0!==this[e]||void 0!==this[n])throw new Error("The given name is already in use for a property or method of the Snowboard class.");this.plugins[n]=new o(n,this,t),this.debug(`Plugin "${e}" registered`),Object.values(this.getPlugins()).forEach((e=>{if(e.isSingleton()&&!e.isInitialised()&&e.dependenciesFulfilled()&&e.hasMethod("listens")&&Object.keys(e.callMethod("listens")).includes("ready")&&this.readiness.dom){const t=e.callMethod("listens").ready;e.callMethod(t)}}))}removePlugin(e){const t=e.toLowerCase();this.hasPlugin(t)?(this.plugins[t].getInstances().forEach((e=>{e.destruct()})),delete this.plugins[t],delete this[t],delete this[e],this.debug(`Plugin "${e}" removed`)):this.debug(`Plugin "${e}" already removed`)}hasPlugin(e){const t=e.toLowerCase();return void 0!==this.plugins[t]}getPlugins(){return this.plugins}getPluginNames(){return Object.keys(this.plugins)}getPlugin(e){const t=e.toLowerCase();if(!this.hasPlugin(t))throw new Error(`No plugin called "${t}" has been registered.`);return this.plugins[t]}listensToEvent(e){const t=[];return Object.entries(this.plugins).forEach((n=>{const[i,s]=n;if(s.isFunction())return;if(!s.dependenciesFulfilled())return;if(!s.hasMethod("listens"))return;const r=s.callMethod("listens");"string"!=typeof r[e]&&"function"!=typeof r[e]||t.push(i)})),t}ready(e){this.readiness.dom&&e(),this.on("ready",e)}on(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].includes(t)||this.listeners[e].push(t)}off(e,t){if(!this.listeners[e])return;const n=this.listeners[e].indexOf(t);-1!==n&&this.listeners[e].splice(n,1)}globalEvent(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i{const i=this.getPlugin(t);if(i.isFunction())return;i.isSingleton()&&0===i.getInstances().length&&i.initialiseSingleton();const s=i.callMethod("listens")[e];i.getInstances().forEach((i=>{if(!r)if("function"==typeof s)try{!1===s.apply(i,n)&&(r=!0)}catch(n){this.error(`Error thrown in "${e}" event by "${t}" plugin.`,n)}else if("string"==typeof s){if(!i[s])throw new Error(`Missing "${s}" method in "${t}" plugin`);try{!1===i[s](...n)&&(r=!0,this.debug(`Global event "${e}" cancelled by "${t}" plugin`))}catch(n){this.error(`Error thrown in "${e}" event by "${t}" plugin.`,n)}}else this.error(`Listen method for "${e}" event in "${t}" plugin is not a function or string.`)}))})),!r&&this.listeners[e]&&this.listeners[e].length>0&&(this.debug(`Found ${this.listeners[e].length} ad-hoc listener(s) for global event "${e}"`),this.listeners[e].forEach((t=>{if(!r)try{!1===t(...n)&&(r=!0,this.debug(`Global event "${e} cancelled by an ad-hoc listener.`))}catch(t){this.error(`Error thrown in "${e}" event by an ad-hoc listener.`,t)}}))),!r}globalPromiseEvent(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i{const i=this.getPlugin(t);if(i.isFunction())return;i.isSingleton()&&0===i.getInstances().length&&i.initialiseSingleton();const s=i.callMethod("listens")[e];i.getInstances().forEach((i=>{if("function"==typeof s)try{const e=s.apply(i,n);if(e instanceof Promise==!1)return;r.push(e)}catch(n){this.error(`Error thrown in "${e}" event by "${t}" plugin.`,n)}else if("string"==typeof s){if(!i[s])throw new Error(`Missing "${s}" method in "${t}" plugin`);try{const e=i[s](...n);if(e instanceof Promise==!1)return;r.push(e)}catch(n){this.error(`Error thrown in "${e}" promise event by "${t}" plugin.`,n)}}else this.error(`Listen method for "${e}" event in "${t}" plugin is not a function or string.`)}))})),this.listeners[e]&&this.listeners[e].length>0&&(this.debug(`Found ${this.listeners[e].length} ad-hoc listener(s) for global promise event "${e}"`),this.listeners[e].forEach((t=>{try{const e=t(...n);if(e instanceof Promise==!1)return;r.push(e)}catch(t){this.error(`Error thrown in "${e}" promise event by an ad-hoc listener.`,t)}}))),0===r.length?Promise.resolve():Promise.all(r)}logMessage(e,t,n){console.groupCollapsed("%c[Snowboard]",`color: ${e}; font-weight: ${t?"bold":"normal"};`,n);for(var i=arguments.length,s=new Array(i>3?i-3:0),r=3;r{e+=1,console.log(`%c${e}:`,"color: rgb(88, 88, 88); font-weight: normal;",t)})),console.groupEnd(),console.groupCollapsed("%cTrace","color: rgb(45, 167, 199); font-weight: bold;"),console.trace(),console.groupEnd()}else console.trace();console.groupEnd()}log(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i1?t-1:0),i=1;i1?t-1:0),i=1;i{const t=new Proxy(new i.A,s.A);e.snowboard=t,e.Snowboard=t,e.SnowBoard=t})(window)}},function(e){e.O(0,[969],(function(){return t=2,e(e.s=t);var t}));e.O()}]); \ No newline at end of file diff --git a/modules/system/assets/js/snowboard/build/snowboard.data-attr.js b/modules/system/assets/js/snowboard/build/snowboard.data-attr.js index 39059da802..c23062e69b 100644 --- a/modules/system/assets/js/snowboard/build/snowboard.data-attr.js +++ b/modules/system/assets/js/snowboard/build/snowboard.data-attr.js @@ -1 +1 @@ -"use strict";(self.webpackChunk_wintercms_wn_system_module=self.webpackChunk_wintercms_wn_system_module||[]).push([[806],{579:function(e,t,r){r.d(t,{Z:function(){return n}});class n{constructor(e){this.snowboard=e}construct(){}dependencies(){return[]}listens(){return{}}destruct(){this.detach(),delete this.snowboard}destructor(){this.destruct()}}},281:function(e,t,r){r.d(t,{Z:function(){return a}});var n=r(579);class a extends n.Z{}},974:function(e,t,r){var n=r(281);function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function s(e){for(var t=1;tthis.changeHandler(e))),window.addEventListener("click",(e=>this.clickHandler(e))),window.addEventListener("keydown",(e=>this.keyDownHandler(e))),window.addEventListener("submit",(e=>this.submitHandler(e)))}disableDefaultFormValidation(){document.querySelectorAll("form[data-request]:not([data-browser-validate])").forEach((e=>{e.setAttribute("novalidate",!0)}))}detachHandlers(){window.removeEventListener("change",(e=>this.changeHandler(e))),window.removeEventListener("click",(e=>this.clickHandler(e))),window.removeEventListener("keydown",(e=>this.keyDownHandler(e))),window.removeEventListener("submit",(e=>this.submitHandler(e)))}changeHandler(e){e.target.matches("select[data-request], input[type=radio][data-request], input[type=checkbox][data-request], input[type=file][data-request]")&&this.processRequestOnElement(e.target)}clickHandler(e){let t=e.target;for(;t&&"HTML"!==t.tagName;){if(t.matches("a[data-request], button[data-request], input[type=button][data-request], input[type=submit][data-request]")){e.preventDefault(),this.processRequestOnElement(t);break}t=t.parentElement}}keyDownHandler(e){if(!e.target.matches("input"))return;-1!==["checkbox","color","date","datetime","datetime-local","email","image","month","number","password","radio","range","search","tel","text","time","url","week"].indexOf(e.target.getAttribute("type"))&&("Enter"===e.key&&e.target.matches("*[data-request]")?(this.processRequestOnElement(e.target),e.preventDefault(),e.stopImmediatePropagation()):e.target.matches("*[data-track-input]")&&this.trackInput(e.target))}submitHandler(e){e.target.matches("form[data-request]")&&(e.preventDefault(),this.processRequestOnElement(e.target))}processRequestOnElement(e){const t=e.dataset,r=String(t.request),n={confirm:"requestConfirm"in t?String(t.requestConfirm):null,redirect:"requestRedirect"in t?String(t.requestRedirect):null,loading:"requestLoading"in t?String(t.requestLoading):null,flash:"requestFlash"in t,files:"requestFiles"in t,browserValidate:"requestBrowserValidate"in t,form:"requestForm"in t?String(t.requestForm):null,url:"requestUrl"in t?String(t.requestUrl):null,update:"requestUpdate"in t?this.parseData(String(t.requestUpdate)):[],data:"requestData"in t?this.parseData(String(t.requestData)):[]};this.snowboard.request(e,r,n)}onAjaxSetup(e){if(!e.element)return;const t=e.element.getAttribute("name"),r=s(s({},this.getParentRequestData(e.element)),e.options.data);e.element&&e.element.matches("input, textarea, select, button")&&!e.form&&t&&!e.options.data[t]&&(r[t]=e.element.value),e.options.data=r}getParentRequestData(e){const t=[];let r={},n=e;for(;n.parentElement&&"HTML"!==n.parentElement.tagName;)t.push(n.parentElement),n=n.parentElement;return t.reverse(),t.forEach((e=>{const t=e.dataset;"requestData"in t&&(r=s(s({},r),this.parseData(t.requestData)))})),r}parseData(e){let t;if(void 0===e&&(t=""),"object"==typeof t)return t;try{return this.snowboard.jsonparser().parse(`{${e}}`)}catch(e){throw new Error(`Error parsing the data attribute on element: ${e.message}`)}}trackInput(e){const{lastValue:t}=e.dataset,r=e.dataset.trackInput||300;void 0!==t&&t===e.value||(this.resetTrackInputTimer(e),e.dataset.inputTimer=window.setTimeout((()=>{if(e.dataset.request)return void this.processRequestOnElement(e);let t=e;for(;t.parentElement&&"HTML"!==t.parentElement.tagName;)if(t=t.parentElement,"FORM"===t.tagName&&t.dataset.request){this.processRequestOnElement(t);break}}),r))}resetTrackInputTimer(e){e.dataset.inputTimer&&(window.clearTimeout(e.dataset.inputTimer),e.dataset.inputTimer=null)}}if(void 0===window.Snowboard)throw new Error("Snowboard must be loaded in order to use the HTML data attribute AJAX request feature.");window.Snowboard.addPlugin("attributeRequest",o)}},function(e){var t;t=974,e(e.s=t)}]); \ No newline at end of file +"use strict";(self.webpackChunk_wintercms_wn_system_module=self.webpackChunk_wintercms_wn_system_module||[]).push([[14],{660:function(e,t,r){r.d(t,{A:function(){return n}});class n{constructor(e){this.snowboard=e}construct(){}dependencies(){return[]}listens(){return{}}destruct(){this.detach(),delete this.snowboard}destructor(){this.destruct()}}},373:function(e,t,r){r.d(t,{A:function(){return a}});var n=r(660);class a extends n.A{}},364:function(e,t,r){var n=r(373);function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function s(e){for(var t=1;tthis.changeHandler(e))),window.addEventListener("click",(e=>this.clickHandler(e))),window.addEventListener("keydown",(e=>this.keyDownHandler(e))),window.addEventListener("submit",(e=>this.submitHandler(e)))}disableDefaultFormValidation(){document.querySelectorAll("form[data-request]:not([data-browser-validate])").forEach((e=>{e.setAttribute("novalidate",!0)}))}detachHandlers(){window.removeEventListener("change",(e=>this.changeHandler(e))),window.removeEventListener("click",(e=>this.clickHandler(e))),window.removeEventListener("keydown",(e=>this.keyDownHandler(e))),window.removeEventListener("submit",(e=>this.submitHandler(e)))}changeHandler(e){e.target.matches("select[data-request], input[type=radio][data-request], input[type=checkbox][data-request], input[type=file][data-request]")&&this.processRequestOnElement(e.target)}clickHandler(e){let t=e.target;for(;t&&"HTML"!==t.tagName;){if(t.matches("a[data-request], button[data-request], input[type=button][data-request], input[type=submit][data-request]")){e.preventDefault(),this.processRequestOnElement(t);break}t=t.parentElement}}keyDownHandler(e){if(!e.target.matches("input"))return;-1!==["checkbox","color","date","datetime","datetime-local","email","image","month","number","password","radio","range","search","tel","text","time","url","week"].indexOf(e.target.getAttribute("type"))&&("Enter"===e.key&&e.target.matches("*[data-request]")?(this.processRequestOnElement(e.target),e.preventDefault(),e.stopImmediatePropagation()):e.target.matches("*[data-track-input]")&&this.trackInput(e.target))}submitHandler(e){e.target.matches("form[data-request]")&&(e.preventDefault(),this.processRequestOnElement(e.target))}processRequestOnElement(e){const t=e.dataset,r=String(t.request),n={confirm:"requestConfirm"in t?String(t.requestConfirm):null,redirect:"requestRedirect"in t?String(t.requestRedirect):null,loading:"requestLoading"in t?String(t.requestLoading):null,flash:"requestFlash"in t,files:"requestFiles"in t,browserValidate:"requestBrowserValidate"in t,form:"requestForm"in t?String(t.requestForm):null,url:"requestUrl"in t?String(t.requestUrl):null,update:"requestUpdate"in t?this.parseData(String(t.requestUpdate)):[],data:"requestData"in t?this.parseData(String(t.requestData)):[]};this.snowboard.request(e,r,n)}onAjaxSetup(e){if(!e.element)return;const t=e.element.getAttribute("name"),r=s(s({},this.getParentRequestData(e.element)),e.options.data);e.element&&e.element.matches("input, textarea, select, button")&&!e.form&&t&&!e.options.data[t]&&(r[t]=e.element.value),e.options.data=r}getParentRequestData(e){const t=[];let r={},n=e;for(;n.parentElement&&"HTML"!==n.parentElement.tagName;)t.push(n.parentElement),n=n.parentElement;return t.reverse(),t.forEach((e=>{const t=e.dataset;"requestData"in t&&(r=s(s({},r),this.parseData(t.requestData)))})),r}parseData(e){let t;if(void 0===e&&(t=""),"object"==typeof t)return t;try{return this.snowboard.jsonparser().parse(`{${e}}`)}catch(e){throw new Error(`Error parsing the data attribute on element: ${e.message}`)}}trackInput(e){const{lastValue:t}=e.dataset,r=e.dataset.trackInput||300;void 0!==t&&t===e.value||(this.resetTrackInputTimer(e),e.dataset.inputTimer=window.setTimeout((()=>{if(e.dataset.request)return void this.processRequestOnElement(e);let t=e;for(;t.parentElement&&"HTML"!==t.parentElement.tagName;)if(t=t.parentElement,"FORM"===t.tagName&&t.dataset.request){this.processRequestOnElement(t);break}}),r))}resetTrackInputTimer(e){e.dataset.inputTimer&&(window.clearTimeout(e.dataset.inputTimer),e.dataset.inputTimer=null)}}if(void 0===window.Snowboard)throw new Error("Snowboard must be loaded in order to use the HTML data attribute AJAX request feature.");window.Snowboard.addPlugin("attributeRequest",o)}},function(e){var t;t=364,e(e.s=t)}]); \ No newline at end of file diff --git a/modules/system/assets/js/snowboard/build/snowboard.extras.js b/modules/system/assets/js/snowboard/build/snowboard.extras.js index 5a447a9111..a4c6f6aaa4 100644 --- a/modules/system/assets/js/snowboard/build/snowboard.extras.js +++ b/modules/system/assets/js/snowboard/build/snowboard.extras.js @@ -1 +1 @@ -"use strict";(self.webpackChunk_wintercms_wn_system_module=self.webpackChunk_wintercms_wn_system_module||[]).push([[459],{579:function(e,t,s){s.d(t,{Z:function(){return a}});class a{constructor(e){this.snowboard=e}construct(){}dependencies(){return[]}listens(){return{}}destruct(){this.detach(),delete this.snowboard}destructor(){this.destruct()}}},281:function(e,t,s){s.d(t,{Z:function(){return i}});var a=s(579);class i extends a.Z{}},809:function(e,t,s){s.d(t,{Z:function(){return i}});var a=s(281);class i extends a.Z{listens(){return{ajaxLoadAssets:"load"}}dependencies(){return["url"]}async load(e){if(e.js&&e.js.length>0)for(const t of e.js)try{await this.loadScript(t)}catch(e){return Promise.reject(e)}if(e.css&&e.css.length>0)for(const t of e.css)try{await this.loadStyle(t)}catch(e){return Promise.reject(e)}if(e.img&&e.img.length>0)for(const t of e.img)try{await this.loadImage(t)}catch(e){return Promise.reject(e)}return Promise.resolve()}loadScript(e){return new Promise(((t,s)=>{e=this.snowboard.url().asset(e);if(document.querySelector(`script[src="${e}"]`))return void t();const a=document.createElement("script");a.setAttribute("type","text/javascript"),a.setAttribute("src",e),a.addEventListener("load",(()=>{this.snowboard.globalEvent("assetLoader.loaded","script",e,a),t()})),a.addEventListener("error",(()=>{this.snowboard.globalEvent("assetLoader.error","script",e,a),s(new Error(`Unable to load script file: "${e}"`))})),document.body.append(a)}))}loadStyle(e){return new Promise(((t,s)=>{e=this.snowboard.url().asset(e);if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void t();const a=document.createElement("link");a.setAttribute("rel","stylesheet"),a.setAttribute("href",e),a.addEventListener("load",(()=>{this.snowboard.globalEvent("assetLoader.loaded","style",e,a),t()})),a.addEventListener("error",(()=>{this.snowboard.globalEvent("assetLoader.error","style",e,a),s(new Error(`Unable to load stylesheet file: "${e}"`))})),document.head.append(a)}))}loadImage(e){return new Promise(((t,s)=>{e=this.snowboard.url().asset(e);const a=new Image;a.addEventListener("load",(()=>{this.snowboard.globalEvent("assetLoader.loaded","image",e,a),t()})),a.addEventListener("error",(()=>{this.snowboard.globalEvent("assetLoader.error","image",e,a),s(new Error(`Unable to load image file: "${e}"`))})),a.src=e}))}}},553:function(e,t,s){s.d(t,{Z:function(){return i}});var a=s(281);class i extends a.Z{dependencies(){return["request"]}listens(){return{ajaxStart:"ajaxStart",ajaxDone:"ajaxDone"}}ajaxStart(e,t){if(t.element)if("FORM"===t.element.tagName){const e=t.element.querySelectorAll("[data-attach-loading]");e.length>0&&e.forEach((e=>{e.classList.add(this.getLoadingClass(e))}))}else void 0!==t.element.dataset.attachLoading&&t.element.classList.add(this.getLoadingClass(t.element))}ajaxDone(e,t){if(t.element)if("FORM"===t.element.tagName){const e=t.element.querySelectorAll("[data-attach-loading]");e.length>0&&e.forEach((e=>{e.classList.remove(this.getLoadingClass(e))}))}else void 0!==t.element.dataset.attachLoading&&t.element.classList.remove(this.getLoadingClass(t.element))}getLoadingClass(e){return void 0!==e.dataset.attachLoading&&""!==e.dataset.attachLoading?e.dataset.attachLoading:"wn-loading"}}},763:function(e,t,s){s.d(t,{Z:function(){return i}});var a=s(579);class i extends a.Z{construct(e,t,s){if(e instanceof a.Z==!1)throw new Error("You must provide a Snowboard plugin to enable data configuration");if(t instanceof HTMLElement==!1)throw new Error("Data configuration can only be extracted from HTML elements");this.instance=e,this.element=t,this.localConfig=s||{},this.instanceConfig={},this.acceptedConfigs={},this.refresh()}get(e){return void 0===e?this.instanceConfig:void 0!==this.instanceConfig[e]?this.instanceConfig[e]:void 0}set(e,t,s){if(void 0===e)throw new Error("You must provide a configuration key to set");this.instanceConfig[e]=t,!0===s&&(this.element.dataset[e]=t,this.localConfig[e]=t)}refresh(){this.acceptedConfigs=this.getAcceptedConfigs(),this.instanceConfig=this.processConfig()}getAcceptedConfigs(){return void 0!==this.instance.acceptAllDataConfigs&&!0===this.instance.acceptAllDataConfigs||void 0!==this.instance.defaults&&"function"==typeof this.instance.defaults&&"object"==typeof this.instance.defaults()&&Object.keys(this.instance.defaults())}getDefaults(){return void 0!==this.instance.defaults&&"function"==typeof this.instance.defaults&&"object"==typeof this.instance.defaults()?this.instance.defaults():{}}processConfig(){const e=this.getDefaults();if(!1===this.acceptedConfigs)return e;for(const t in this.element.dataset)(!0===this.acceptedConfigs||this.acceptedConfigs.includes(t))&&(e[t]=this.coerceValue(this.element.dataset[t]));for(const t in this.localConfig)(!0===this.acceptedConfigs||this.acceptedConfigs.includes(t))&&(e[t]=this.localConfig[t]);return e}coerceValue(e){const t=String(e);if("null"===t)return null;if("undefined"!==t){if(t.startsWith("base64:")){const e=t.replace(/^base64:/,""),s=atob(e);return this.coerceValue(s)}if(["true","yes"].includes(t.toLowerCase()))return!0;if(["false","no"].includes(t.toLowerCase()))return!1;if(/^[-+]?[0-9]+(\.[0-9]+)?$/.test(t))return Number(t);try{return this.snowboard.jsonParser().parse(t)}catch(e){return""===t||t}}}}},270:function(e,t,s){s.d(t,{Z:function(){return i}});var a=s(579);class i extends a.Z{construct(e,t,s){if(this.message=e,this.type=t||"default",this.duration=Number(s||7),this.duration<0)throw new Error("Flash duration must be a positive number, or zero");this.clear(),this.timer=null,this.flashTimer=null,this.create()}dependencies(){return["transition"]}destruct(){null!==this.timer&&window.clearTimeout(this.timer),this.flashTimer&&this.flashTimer.remove(),this.flash&&(this.flash.remove(),this.flash=null,this.flashTimer=null),super.destruct()}create(){this.snowboard.globalEvent("flash.create",this),this.flash=document.createElement("DIV"),this.flash.innerHTML=this.message,this.flash.classList.add("flash-message",this.type),this.flash.removeAttribute("data-control"),this.flash.addEventListener("click",(()=>this.remove())),this.flash.addEventListener("mouseover",(()=>this.stopTimer())),this.flash.addEventListener("mouseout",(()=>this.startTimer())),this.duration>0?(this.flashTimer=document.createElement("DIV"),this.flashTimer.classList.add("flash-timer"),this.flash.appendChild(this.flashTimer)):this.flash.classList.add("no-timer"),document.body.appendChild(this.flash),this.snowboard.transition(this.flash,"show",(()=>{this.startTimer()}))}remove(){this.snowboard.globalEvent("flash.remove",this),this.stopTimer(),this.snowboard.transition(this.flash,"hide",(()=>{this.flash.remove(),this.flash=null,this.destruct()}))}clear(){document.querySelectorAll("body > div.flash-message").forEach((e=>e.remove()))}startTimer(){0!==this.duration&&(this.timerTrans=this.snowboard.transition(this.flashTimer,"timeout",null,`${this.duration}.0s`,!0),this.timer=window.setTimeout((()=>this.remove()),1e3*this.duration))}stopTimer(){this.timerTrans&&this.timerTrans.cancel(),this.timer&&window.clearTimeout(this.timer)}}},277:function(e,t,s){s.d(t,{Z:function(){return i}});var a=s(281);class i extends a.Z{dependencies(){return["request"]}listens(){return{ready:"ready",ajaxStart:"ajaxStart"}}ready(){this.counter=0,this.createStripe()}ajaxStart(e,t){!1!==t.options.stripe&&(this.show(),e.then((()=>{this.hide()})).catch((()=>{this.hide()})))}createStripe(){this.indicator=document.createElement("DIV"),this.stripe=document.createElement("DIV"),this.stripeLoaded=document.createElement("DIV"),this.indicator.classList.add("stripe-loading-indicator","loaded"),this.stripe.classList.add("stripe"),this.stripeLoaded.classList.add("stripe-loaded"),this.indicator.appendChild(this.stripe),this.indicator.appendChild(this.stripeLoaded),document.body.appendChild(this.indicator)}show(){this.counter+=1;const e=this.stripe.cloneNode(!0);this.indicator.appendChild(e),this.stripe.remove(),this.stripe=e,this.counter>1||(this.indicator.classList.remove("loaded"),document.body.classList.add("wn-loading"))}hide(e){this.counter-=1,!0===e&&(this.counter=0),this.counter<=0&&(this.indicator.classList.add("loaded"),document.body.classList.remove("wn-loading"))}}},32:function(e,t,s){s.d(t,{Z:function(){return i}});var a=s(281);class i extends a.Z{listens(){return{ready:"ready"}}ready(){let e=!1;if(document.querySelectorAll('link[rel="stylesheet"]').forEach((t=>{t.href.endsWith("/modules/system/assets/css/snowboard.extras.css")&&(e=!0)})),!e){const e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("href",this.snowboard.url().asset("/modules/system/assets/css/snowboard.extras.css")),document.head.appendChild(e)}}}},269:function(e,t,s){s.d(t,{Z:function(){return i}});var a=s(579);class i extends a.Z{construct(e,t,s,a,i){if(e instanceof HTMLElement==!1)throw new Error("A HTMLElement must be provided for transitioning");if(this.element=e,"string"!=typeof t)throw new Error("Transition name must be specified as a string");if(this.transition=t,s&&"function"!=typeof s)throw new Error("Callback must be a valid function");this.callback=s,this.duration=a?this.parseDuration(a):null,this.trailTo=!0===i,this.doTransition()}eventClasses(){for(var e=arguments.length,t=new Array(e),s=0;s{const[s,a]=e;-1!==t.indexOf(s)&&i.push(a)})),i}doTransition(){null!==this.duration&&(this.element.style.transitionDuration=this.duration),this.resetClasses(),this.eventClasses("in","active").forEach((e=>{this.element.classList.add(e)})),window.requestAnimationFrame((()=>{"0s"!==window.getComputedStyle(this.element)["transition-duration"]?(this.element.addEventListener("transitionend",(()=>this.onTransitionEnd()),{once:!0}),window.requestAnimationFrame((()=>{this.element.classList.remove(this.eventClasses("in")[0]),this.element.classList.add(this.eventClasses("out")[0])}))):(this.resetClasses(),this.callback&&this.callback.apply(this.element),this.destruct())}))}onTransitionEnd(){this.eventClasses("active",this.trailTo?"":"out").forEach((e=>{this.element.classList.remove(e)})),this.callback&&this.callback.apply(this.element),null!==this.duration&&(this.element.style.transitionDuration=null),this.destruct()}cancel(){this.element.removeEventListener("transitionend",(()=>this.onTransitionEnd),{once:!0}),this.resetClasses(),null!==this.duration&&(this.element.style.transitionDuration=null),this.destruct()}resetClasses(){this.eventClasses().forEach((e=>{this.element.classList.remove(e)}))}parseDuration(e){const t=/^([0-9]+(\.[0-9]+)?)(m?s)?$/.exec(e),s=Number(t[1]);return"sec"===("s"===t[3]?"sec":"msec")?1e3*s+"ms":`${Math.floor(s)}ms`}}},820:function(e,t,s){var a=s(270),i=s(281);class r extends i.Z{dependencies(){return["flash"]}listens(){return{ready:"ready",ajaxErrorMessage:"ajaxErrorMessage",ajaxFlashMessages:"ajaxFlashMessages"}}ready(){document.querySelectorAll('[data-control="flash-message"]').forEach((e=>{this.snowboard.flash(e.innerHTML,e.dataset.flashType,e.dataset.flashDuration),e.remove()}))}ajaxErrorMessage(e){return this.snowboard.flash(e,"error"),!1}ajaxFlashMessages(e){return Object.entries(e).forEach((e=>{const[t,s]=e;this.snowboard.flash(s,t)})),!1}}class n extends i.Z{construct(){this.errorBags=[]}listens(){return{ready:"ready",ajaxStart:"clearValidation",ajaxValidationErrors:"doValidation"}}ready(){this.collectErrorBags(document)}doValidation(e,t,s){if(s.element&&void 0===s.element.dataset.requestValidate)return null;if(!e)return null;return this.errorBags.filter((t=>t.form===e)).forEach((e=>{this.showErrorBag(e,t)})),!1}clearValidation(e,t){if(t.element&&void 0===t.element.dataset.requestValidate)return;if(!t.form)return;this.errorBags.filter((e=>e.form===t.form)).forEach((e=>{this.hideErrorBag(e)}))}collectErrorBags(e){e.querySelectorAll("[data-validate-error], [data-validate-for]").forEach((e=>{const t=e.closest("form[data-request-validate]");if(!t)return void e.parentNode.removeChild(e);let s=null;e.matches("[data-validate-error]")&&(s=e.querySelector("[data-message]"));const a=document.createComment(""),i={element:e,form:t,validateFor:e.dataset.validateFor?e.dataset.validateFor.split(/\s*,\s*/):"*",placeholder:a,messageListElement:s?s.cloneNode(!0):null,messageListAnchor:null,customMessage:!!e.dataset.validateFor&&(""!==e.textContent||e.childNodes.length>0)};if(s){const e=document.createComment("");s.parentNode.replaceChild(e,s),i.messageListAnchor=e}e.parentNode.replaceChild(a,e),this.errorBags.push(i)}))}hideErrorBag(e){e.element.isConnected&&e.element.parentNode.replaceChild(e.placeholder,e.element)}showErrorBag(e,t){if(this.errorBagValidatesField(e,t))if(e.element.isConnected||e.placeholder.parentNode.replaceChild(e.element,e.placeholder),"*"!==e.validateFor){if(!e.customMessage){const s=Object.keys(t).filter((t=>e.validateFor.includes(t))).shift();[e.element.innerHTML]=t[s]}}else e.messageListElement?(e.element.querySelectorAll("[data-validation-message]").forEach((e=>{e.parentNode.removeChild(e)})),Object.entries(t).forEach((t=>{const[,s]=t;s.forEach((t=>{const s=e.messageListElement.cloneNode(!0);s.dataset.validationMessage="",s.innerHTML=t,e.messageListAnchor.after(s)}))}))):[e.element.innerHTML]=t[Object.keys(t).shift()]}errorBagValidatesField(e,t){return"*"===e.validateFor||Object.keys(t).filter((t=>e.validateFor.includes(t))).length>0}}var o,l=s(269),d=s(553),c=s(277),h=s(32),u=s(809),m=s(763);if(void 0===window.Snowboard)throw new Error("Snowboard must be loaded in order to use the extra plugins.");(o=window.Snowboard).addPlugin("assetLoader",u.Z),o.addPlugin("dataConfig",m.Z),o.addPlugin("extrasStyles",h.Z),o.addPlugin("transition",l.Z),o.addPlugin("flash",a.Z),o.addPlugin("flashListener",r),o.addPlugin("formValidation",n),o.addPlugin("attachLoading",d.Z),o.addPlugin("stripeLoader",c.Z)}},function(e){var t;t=820,e(e.s=t)}]); \ No newline at end of file +"use strict";(self.webpackChunk_wintercms_wn_system_module=self.webpackChunk_wintercms_wn_system_module||[]).push([[683],{660:function(e,t,s){s.d(t,{A:function(){return a}});class a{constructor(e){this.snowboard=e}construct(){}dependencies(){return[]}listens(){return{}}destruct(){this.detach(),delete this.snowboard}destructor(){this.destruct()}}},373:function(e,t,s){s.d(t,{A:function(){return i}});var a=s(660);class i extends a.A{}},477:function(e,t,s){s.d(t,{A:function(){return i}});var a=s(373);class i extends a.A{listens(){return{ajaxLoadAssets:"load"}}dependencies(){return["url"]}async load(e){if(e.js&&e.js.length>0)for(const t of e.js)try{await this.loadScript(t)}catch(e){return Promise.reject(e)}if(e.css&&e.css.length>0)for(const t of e.css)try{await this.loadStyle(t)}catch(e){return Promise.reject(e)}if(e.img&&e.img.length>0)for(const t of e.img)try{await this.loadImage(t)}catch(e){return Promise.reject(e)}return Promise.resolve()}loadScript(e){return new Promise(((t,s)=>{e=this.snowboard.url().asset(e);if(document.querySelector(`script[src="${e}"]`))return void t();const a=document.createElement("script");a.setAttribute("type","text/javascript"),a.setAttribute("src",e),a.addEventListener("load",(()=>{this.snowboard.globalEvent("assetLoader.loaded","script",e,a),t()})),a.addEventListener("error",(()=>{this.snowboard.globalEvent("assetLoader.error","script",e,a),s(new Error(`Unable to load script file: "${e}"`))})),document.body.append(a)}))}loadStyle(e){return new Promise(((t,s)=>{e=this.snowboard.url().asset(e);if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void t();const a=document.createElement("link");a.setAttribute("rel","stylesheet"),a.setAttribute("href",e),a.addEventListener("load",(()=>{this.snowboard.globalEvent("assetLoader.loaded","style",e,a),t()})),a.addEventListener("error",(()=>{this.snowboard.globalEvent("assetLoader.error","style",e,a),s(new Error(`Unable to load stylesheet file: "${e}"`))})),document.head.append(a)}))}loadImage(e){return new Promise(((t,s)=>{e=this.snowboard.url().asset(e);const a=new Image;a.addEventListener("load",(()=>{this.snowboard.globalEvent("assetLoader.loaded","image",e,a),t()})),a.addEventListener("error",(()=>{this.snowboard.globalEvent("assetLoader.error","image",e,a),s(new Error(`Unable to load image file: "${e}"`))})),a.src=e}))}}},293:function(e,t,s){s.d(t,{A:function(){return i}});var a=s(373);class i extends a.A{dependencies(){return["request"]}listens(){return{ajaxStart:"ajaxStart",ajaxDone:"ajaxDone"}}ajaxStart(e,t){if(t.element)if("FORM"===t.element.tagName){const e=t.element.querySelectorAll("[data-attach-loading]");e.length>0&&e.forEach((e=>{e.classList.add(this.getLoadingClass(e))}))}else void 0!==t.element.dataset.attachLoading&&t.element.classList.add(this.getLoadingClass(t.element))}ajaxDone(e,t){if(t.element)if("FORM"===t.element.tagName){const e=t.element.querySelectorAll("[data-attach-loading]");e.length>0&&e.forEach((e=>{e.classList.remove(this.getLoadingClass(e))}))}else void 0!==t.element.dataset.attachLoading&&t.element.classList.remove(this.getLoadingClass(t.element))}getLoadingClass(e){return void 0!==e.dataset.attachLoading&&""!==e.dataset.attachLoading?e.dataset.attachLoading:"wn-loading"}}},490:function(e,t,s){s.d(t,{A:function(){return i}});var a=s(660);class i extends a.A{construct(e,t,s){if(e instanceof a.A==!1)throw new Error("You must provide a Snowboard plugin to enable data configuration");if(t instanceof HTMLElement==!1)throw new Error("Data configuration can only be extracted from HTML elements");this.instance=e,this.element=t,this.localConfig=s||{},this.instanceConfig={},this.acceptedConfigs={},this.refresh()}get(e){return void 0===e?this.instanceConfig:void 0!==this.instanceConfig[e]?this.instanceConfig[e]:void 0}set(e,t,s){if(void 0===e)throw new Error("You must provide a configuration key to set");this.instanceConfig[e]=t,!0===s&&(this.element.dataset[e]=t,this.localConfig[e]=t)}refresh(){this.acceptedConfigs=this.getAcceptedConfigs(),this.instanceConfig=this.processConfig()}getAcceptedConfigs(){return void 0!==this.instance.acceptAllDataConfigs&&!0===this.instance.acceptAllDataConfigs||void 0!==this.instance.defaults&&"function"==typeof this.instance.defaults&&"object"==typeof this.instance.defaults()&&Object.keys(this.instance.defaults())}getDefaults(){return void 0!==this.instance.defaults&&"function"==typeof this.instance.defaults&&"object"==typeof this.instance.defaults()?this.instance.defaults():{}}processConfig(){const e=this.getDefaults();if(!1===this.acceptedConfigs)return e;for(const t in this.element.dataset)(!0===this.acceptedConfigs||this.acceptedConfigs.includes(t))&&(e[t]=this.coerceValue(this.element.dataset[t]));for(const t in this.localConfig)(!0===this.acceptedConfigs||this.acceptedConfigs.includes(t))&&(e[t]=this.localConfig[t]);return e}coerceValue(e){const t=String(e);if("null"===t)return null;if("undefined"!==t){if(t.startsWith("base64:")){const e=t.replace(/^base64:/,""),s=atob(e);return this.coerceValue(s)}if(["true","yes"].includes(t.toLowerCase()))return!0;if(["false","no"].includes(t.toLowerCase()))return!1;if(/^[-+]?[0-9]+(\.[0-9]+)?$/.test(t))return Number(t);try{return this.snowboard.jsonParser().parse(t)}catch(e){return""===t||t}}}}},336:function(e,t,s){s.d(t,{A:function(){return i}});var a=s(660);class i extends a.A{construct(e,t,s){if(this.message=e,this.type=t||"default",this.duration=Number(s||7),this.duration<0)throw new Error("Flash duration must be a positive number, or zero");this.clear(),this.timer=null,this.flashTimer=null,this.create()}dependencies(){return["transition"]}destruct(){null!==this.timer&&window.clearTimeout(this.timer),this.flashTimer&&this.flashTimer.remove(),this.flash&&(this.flash.remove(),this.flash=null,this.flashTimer=null),super.destruct()}create(){this.snowboard.globalEvent("flash.create",this),this.flash=document.createElement("DIV"),this.flash.innerHTML=this.message,this.flash.classList.add("flash-message",this.type),this.flash.removeAttribute("data-control"),this.flash.addEventListener("click",(()=>this.remove())),this.flash.addEventListener("mouseover",(()=>this.stopTimer())),this.flash.addEventListener("mouseout",(()=>this.startTimer())),this.duration>0?(this.flashTimer=document.createElement("DIV"),this.flashTimer.classList.add("flash-timer"),this.flash.appendChild(this.flashTimer)):this.flash.classList.add("no-timer"),document.body.appendChild(this.flash),this.snowboard.transition(this.flash,"show",(()=>{this.startTimer()}))}remove(){this.snowboard.globalEvent("flash.remove",this),this.stopTimer(),this.snowboard.transition(this.flash,"hide",(()=>{this.flash.remove(),this.flash=null,this.destruct()}))}clear(){document.querySelectorAll("body > div.flash-message").forEach((e=>e.remove()))}startTimer(){0!==this.duration&&(this.timerTrans=this.snowboard.transition(this.flashTimer,"timeout",null,`${this.duration}.0s`,!0),this.timer=window.setTimeout((()=>this.remove()),1e3*this.duration))}stopTimer(){this.timerTrans&&this.timerTrans.cancel(),this.timer&&window.clearTimeout(this.timer)}}},758:function(e,t,s){s.d(t,{A:function(){return i}});var a=s(373);class i extends a.A{dependencies(){return["request"]}listens(){return{ready:"ready",ajaxStart:"ajaxStart"}}ready(){this.counter=0,this.createStripe()}ajaxStart(e,t){!1!==t.options.stripe&&(this.show(),e.then((()=>{this.hide()})).catch((()=>{this.hide()})))}createStripe(){this.indicator=document.createElement("DIV"),this.stripe=document.createElement("DIV"),this.stripeLoaded=document.createElement("DIV"),this.indicator.classList.add("stripe-loading-indicator","loaded"),this.stripe.classList.add("stripe"),this.stripeLoaded.classList.add("stripe-loaded"),this.indicator.appendChild(this.stripe),this.indicator.appendChild(this.stripeLoaded),document.body.appendChild(this.indicator)}show(){this.counter+=1;const e=this.stripe.cloneNode(!0);this.indicator.appendChild(e),this.stripe.remove(),this.stripe=e,this.counter>1||(this.indicator.classList.remove("loaded"),document.body.classList.add("wn-loading"))}hide(e){this.counter-=1,!0===e&&(this.counter=0),this.counter<=0&&(this.indicator.classList.add("loaded"),document.body.classList.remove("wn-loading"))}}},75:function(e,t,s){s.d(t,{A:function(){return i}});var a=s(373);class i extends a.A{listens(){return{ready:"ready"}}ready(){let e=!1;if(document.querySelectorAll('link[rel="stylesheet"]').forEach((t=>{t.href.endsWith("/modules/system/assets/css/snowboard.extras.css")&&(e=!0)})),!e){const e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("href",this.snowboard.url().asset("/modules/system/assets/css/snowboard.extras.css")),document.head.appendChild(e)}}}},843:function(e,t,s){s.d(t,{A:function(){return i}});var a=s(660);class i extends a.A{construct(e,t,s,a,i){if(e instanceof HTMLElement==!1)throw new Error("A HTMLElement must be provided for transitioning");if(this.element=e,"string"!=typeof t)throw new Error("Transition name must be specified as a string");if(this.transition=t,s&&"function"!=typeof s)throw new Error("Callback must be a valid function");this.callback=s,this.duration=a?this.parseDuration(a):null,this.trailTo=!0===i,this.doTransition()}eventClasses(){for(var e=arguments.length,t=new Array(e),s=0;s{const[s,a]=e;-1!==t.indexOf(s)&&i.push(a)})),i}doTransition(){null!==this.duration&&(this.element.style.transitionDuration=this.duration),this.resetClasses(),this.eventClasses("in","active").forEach((e=>{this.element.classList.add(e)})),window.requestAnimationFrame((()=>{"0s"!==window.getComputedStyle(this.element)["transition-duration"]?(this.element.addEventListener("transitionend",(()=>this.onTransitionEnd()),{once:!0}),window.requestAnimationFrame((()=>{this.element.classList.remove(this.eventClasses("in")[0]),this.element.classList.add(this.eventClasses("out")[0])}))):(this.resetClasses(),this.callback&&this.callback.apply(this.element),this.destruct())}))}onTransitionEnd(){this.eventClasses("active",this.trailTo?"":"out").forEach((e=>{this.element.classList.remove(e)})),this.callback&&this.callback.apply(this.element),null!==this.duration&&(this.element.style.transitionDuration=null),this.destruct()}cancel(){this.element.removeEventListener("transitionend",(()=>this.onTransitionEnd),{once:!0}),this.resetClasses(),null!==this.duration&&(this.element.style.transitionDuration=null),this.destruct()}resetClasses(){this.eventClasses().forEach((e=>{this.element.classList.remove(e)}))}parseDuration(e){const t=/^([0-9]+(\.[0-9]+)?)(m?s)?$/.exec(e),s=Number(t[1]);return"sec"===("s"===t[3]?"sec":"msec")?1e3*s+"ms":`${Math.floor(s)}ms`}}},183:function(e,t,s){var a=s(336),i=s(373);class r extends i.A{dependencies(){return["flash"]}listens(){return{ready:"ready",ajaxErrorMessage:"ajaxErrorMessage",ajaxFlashMessages:"ajaxFlashMessages"}}ready(){document.querySelectorAll('[data-control="flash-message"]').forEach((e=>{this.snowboard.flash(e.innerHTML,e.dataset.flashType,e.dataset.flashDuration),e.remove()}))}ajaxErrorMessage(e){return this.snowboard.flash(e,"error"),!1}ajaxFlashMessages(e){return Object.entries(e).forEach((e=>{const[t,s]=e;this.snowboard.flash(s,t)})),!1}}class n extends i.A{construct(){this.errorBags=[]}listens(){return{ready:"ready",ajaxStart:"clearValidation",ajaxValidationErrors:"doValidation"}}ready(){this.collectErrorBags(document)}doValidation(e,t,s){if(s.element&&void 0===s.element.dataset.requestValidate)return null;if(!e)return null;return this.errorBags.filter((t=>t.form===e)).forEach((e=>{this.showErrorBag(e,t)})),!1}clearValidation(e,t){if(t.element&&void 0===t.element.dataset.requestValidate)return;if(!t.form)return;this.errorBags.filter((e=>e.form===t.form)).forEach((e=>{this.hideErrorBag(e)}))}collectErrorBags(e){e.querySelectorAll("[data-validate-error], [data-validate-for]").forEach((e=>{const t=e.closest("form[data-request-validate]");if(!t)return void e.parentNode.removeChild(e);let s=null;e.matches("[data-validate-error]")&&(s=e.querySelector("[data-message]"));const a=document.createComment(""),i={element:e,form:t,validateFor:e.dataset.validateFor?e.dataset.validateFor.split(/\s*,\s*/):"*",placeholder:a,messageListElement:s?s.cloneNode(!0):null,messageListAnchor:null,customMessage:!!e.dataset.validateFor&&(""!==e.textContent||e.childNodes.length>0)};if(s){const e=document.createComment("");s.parentNode.replaceChild(e,s),i.messageListAnchor=e}e.parentNode.replaceChild(a,e),this.errorBags.push(i)}))}hideErrorBag(e){e.element.isConnected&&e.element.parentNode.replaceChild(e.placeholder,e.element)}showErrorBag(e,t){if(this.errorBagValidatesField(e,t))if(e.element.isConnected||e.placeholder.parentNode.replaceChild(e.element,e.placeholder),"*"!==e.validateFor){if(!e.customMessage){const s=Object.keys(t).filter((t=>e.validateFor.includes(t))).shift();[e.element.innerHTML]=t[s]}}else e.messageListElement?(e.element.querySelectorAll("[data-validation-message]").forEach((e=>{e.parentNode.removeChild(e)})),Object.entries(t).forEach((t=>{const[,s]=t;s.forEach((t=>{const s=e.messageListElement.cloneNode(!0);s.dataset.validationMessage="",s.innerHTML=t,e.messageListAnchor.after(s)}))}))):[e.element.innerHTML]=t[Object.keys(t).shift()]}errorBagValidatesField(e,t){return"*"===e.validateFor||Object.keys(t).filter((t=>e.validateFor.includes(t))).length>0}}var o,l=s(843),d=s(293),c=s(758),h=s(75),u=s(477),m=s(490);if(void 0===window.Snowboard)throw new Error("Snowboard must be loaded in order to use the extra plugins.");(o=window.Snowboard).addPlugin("assetLoader",u.A),o.addPlugin("dataConfig",m.A),o.addPlugin("extrasStyles",h.A),o.addPlugin("transition",l.A),o.addPlugin("flash",a.A),o.addPlugin("flashListener",r),o.addPlugin("formValidation",n),o.addPlugin("attachLoading",d.A),o.addPlugin("stripeLoader",c.A)}},function(e){var t;t=183,e(e.s=t)}]); \ No newline at end of file diff --git a/modules/system/assets/js/snowboard/build/snowboard.request.js b/modules/system/assets/js/snowboard/build/snowboard.request.js index 8522d2a05d..f9b4a53f76 100644 --- a/modules/system/assets/js/snowboard/build/snowboard.request.js +++ b/modules/system/assets/js/snowboard/build/snowboard.request.js @@ -1 +1 @@ -"use strict";(self.webpackChunk_wintercms_wn_system_module=self.webpackChunk_wintercms_wn_system_module||[]).push([[988],{579:function(e,t,s){s.d(t,{Z:function(){return r}});class r{constructor(e){this.snowboard=e}construct(){}dependencies(){return[]}listens(){return{}}destruct(){this.detach(),delete this.snowboard}destructor(){this.destruct()}}},640:function(e,t,s){var r=s(579);function o(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,r)}return s}function n(e){for(var t=1;t{e&&this.doAjax().then((e=>{if(e.cancelled)return this.cancelled=!0,void this.complete();this.responseData=e,this.processUpdate(e).then((()=>{!1===e.X_WINTER_SUCCESS?this.processError(e):this.processResponse(e)}))}),(e=>{this.responseError=e,this.processError(e)}))})):this.doAjax().then((e=>{if(e.cancelled)return this.cancelled=!0,void this.complete();this.responseData=e,this.processUpdate(e).then((()=>{!1===e.X_WINTER_SUCCESS?this.processError(e):this.processResponse(e)}))}),(e=>{this.responseError=e,this.processError(e)})):this.cancelled=!0}else this.cancelled=!0}dependencies(){return["cookie","jsonParser"]}checkRequest(){if(this.element&&this.element instanceof Element==!1)throw new Error("The element provided must be an Element instance");if(void 0===this.handler)throw new Error("The AJAX handler name is not specified.");if(!this.isHandlerName(this.handler))throw new Error('Invalid AJAX handler name. The correct handler name format is: "onEvent".')}getFetch(){return this.fetchOptions=void 0!==this.options.fetchOptions&&"object"==typeof this.options.fetchOptions?this.options.fetchOptions:{method:"POST",headers:this.headers,body:this.data,redirect:"follow",mode:"same-origin"},this.snowboard.globalEvent("ajaxFetchOptions",this.fetchOptions,this),fetch(this.url,this.fetchOptions)}doClientValidation(){return!0!==this.options.browserValidate||!this.form||!1!==this.form.checkValidity()||(this.form.reportValidity(),!1)}doAjax(){if(!1===this.snowboard.globalEvent("ajaxBeforeSend",this))return Promise.resolve({cancelled:!0});const e=new Promise(((e,t)=>{this.getFetch().then((s=>{s.ok||406===s.status?s.headers.has("Content-Type")&&s.headers.get("Content-Type").includes("/json")?s.json().then((t=>{e(n(n({},t),{},{X_WINTER_SUCCESS:406!==s.status,X_WINTER_RESPONSE_CODE:s.status}))}),(e=>{t(this.renderError(`Unable to parse JSON response: ${e}`))})):s.text().then((t=>{e(t)}),(e=>{t(this.renderError(`Unable to process response: ${e}`))})):s.headers.has("Content-Type")&&s.headers.get("Content-Type").includes("/json")?s.json().then((e=>{e.message&&e.exception?t(this.renderError(e.message,e.exception,e.file,e.line,e.trace)):t(e)}),(e=>{t(this.renderError(`Unable to parse JSON response: ${e}`))})):s.text().then((e=>{t(this.renderError(e))}),(e=>{t(this.renderError(`Unable to process response: ${e}`))}))}),(e=>{t(this.renderError(`Unable to retrieve a response from the server: ${e}`))}))}));if(this.snowboard.globalEvent("ajaxStart",e,this),this.element){const t=new Event("ajaxPromise");t.promise=e,this.element.dispatchEvent(t)}return e}processUpdate(e){return new Promise(((t,s)=>{if("function"==typeof this.options.beforeUpdate&&!1===this.options.beforeUpdate.apply(this,[e]))return void t();const r={};if(Object.entries(e).forEach((e=>{const[t,s]=e;"X_WINTER"!==t.substr(0,8)&&(r[t]=s)})),0===Object.keys(r).length)return void(e.X_WINTER_ASSETS?this.processAssets(e.X_WINTER_ASSETS).then((()=>{t()}),(()=>{s()})):t());this.snowboard.globalPromiseEvent("ajaxBeforeUpdate",e,this).then((async()=>{e.X_WINTER_ASSETS&&await this.processAssets(e.X_WINTER_ASSETS),this.doUpdate(r).then((()=>{window.requestAnimationFrame((()=>t()))}),(()=>{s()}))}),(()=>{t()}))}))}doUpdate(e){return new Promise((t=>{const s=[];Object.entries(e).forEach((e=>{const[t,r]=e;let o=this.options.update&&this.options.update[t]?this.options.update[t]:t,n="replace";"@"===o.substr(0,1)?(n="append",o=o.substr(1)):"^"===o.substr(0,1)?(n="prepend",o=o.substr(1)):"#"!==o.substr(0,1)&&"."!==o.substr(0,1)&&(n="noop");const i=document.querySelectorAll(o);i.length>0&&i.forEach((e=>{switch(n){case"append":e.innerHTML+=r;break;case"prepend":e.innerHTML=r+e.innerHTML;break;case"noop":break;default:e.innerHTML=r}s.push(e),this.snowboard.globalEvent("ajaxUpdate",e,r,this);const t=new Event("ajaxUpdate");t.content=r,e.dispatchEvent(t)}))})),this.snowboard.globalEvent("ajaxUpdateComplete",s,this),t()}))}processResponse(e){if((!this.options.success||"function"!=typeof this.options.success||!1!==this.options.success(this.responseData,this))&&!1!==this.snowboard.globalEvent("ajaxSuccess",this.responseData,this)){if(this.element){const e=new Event("ajaxDone",{cancelable:!0});if(e.responseData=this.responseData,e.request=this,this.element.dispatchEvent(e),e.defaultPrevented)return}this.flash&&e.X_WINTER_FLASH_MESSAGES&&this.processFlashMessages(e.X_WINTER_FLASH_MESSAGES),this.redirect||e.X_WINTER_REDIRECT?this.processRedirect(this.redirect||e.X_WINTER_REDIRECT):this.complete()}}processError(e){if((!this.options.error||"function"!=typeof this.options.error||!1!==this.options.error(this.responseError,this))&&!1!==this.snowboard.globalEvent("ajaxError",this.responseError,this)){if(this.element){const e=new Event("ajaxFail",{cancelable:!0});if(e.responseError=this.responseError,e.request=this,this.element.dispatchEvent(e),e.defaultPrevented)return}if(e instanceof Error)this.processErrorMessage(e.message);else{let t=!1;e.X_WINTER_ERROR_FIELDS&&(t=this.processValidationErrors(e.X_WINTER_ERROR_FIELDS)),e.X_WINTER_ERROR_MESSAGE&&!t&&this.processErrorMessage(e.X_WINTER_ERROR_MESSAGE)}this.complete()}}processRedirect(e){"function"==typeof this.options.handleRedirectResponse&&!1===this.options.handleRedirectResponse.apply(this,[e])||!1!==this.snowboard.globalEvent("ajaxRedirect",e,this)&&(window.addEventListener("popstate",(()=>{if(this.element){const e=document.createEvent("CustomEvent");e.eventName="ajaxRedirected",this.element.dispatchEvent(e)}}),{once:!0}),window.location.assign(e))}processErrorMessage(e){"function"==typeof this.options.handleErrorMessage&&!1===this.options.handleErrorMessage.apply(this,[e])||!1!==this.snowboard.globalEvent("ajaxErrorMessage",e,this)&&window.alert(e)}processFlashMessages(e){"function"==typeof this.options.handleFlashMessages&&!1===this.options.handleFlashMessages.apply(this,[e])||this.snowboard.globalEvent("ajaxFlashMessages",e,this)}processValidationErrors(e){return"function"==typeof this.options.handleValidationErrors&&!1===this.options.handleValidationErrors.apply(this,[this.form,e])||!1===this.snowboard.globalEvent("ajaxValidationErrors",this.form,e,this)}processAssets(e){return this.snowboard.globalPromiseEvent("ajaxLoadAssets",e)}async doConfirm(){if("function"==typeof this.options.handleConfirmMessage)return!1!==this.options.handleConfirmMessage.apply(this,[this.confirm]);if(0===this.snowboard.listensToEvent("ajaxConfirmMessage").length)return window.confirm(this.confirm);const e=this.snowboard.globalPromiseEvent("ajaxConfirmMessage",this.confirm,this);try{if(await e)return!0}catch(e){return!1}return!1}complete(){if(this.options.complete&&"function"==typeof this.options.complete&&this.options.complete(this.responseData,this),this.snowboard.globalEvent("ajaxDone",this.responseData,this),this.element){const e=new Event("ajaxAlways");e.request=this,e.responseData=this.responseData,e.responseError=this.responseError,this.element.dispatchEvent(e)}this.destruct()}get form(){return this.options.form?"string"==typeof this.options.form?document.querySelector(this.options.form):this.options.form:this.element?"FORM"===this.element.tagName?this.element:this.element.closest("form"):null}get context(){return{handler:this.handler,options:this.options}}get headers(){const e={"X-Requested-With":"XMLHttpRequest","X-WINTER-REQUEST-HANDLER":this.handler,"X-WINTER-REQUEST-PARTIALS":this.extractPartials(this.options.update||[])};return this.flash&&(e["X-WINTER-REQUEST-FLASH"]=1),this.xsrfToken&&(e["X-XSRF-TOKEN"]=this.xsrfToken),e}get loading(){return this.options.loading||!1}get url(){return this.options.url||window.location.href}get redirect(){return this.options.redirect&&this.options.redirect.length?this.options.redirect:null}get flash(){return this.options.flash||!1}get files(){return!0===this.options.files&&(void 0!==FormData||(this.snowboard.debug("This browser does not support file uploads"),!1))}get xsrfToken(){return this.snowboard.cookie().get("XSRF-TOKEN")}get data(){const e="object"==typeof this.options.data?this.options.data:{},t=new FormData(this.form||void 0);return Object.keys(e).length>0&&Object.entries(e).forEach((e=>{const[s,r]=e;t.append(s,r)})),t}get confirm(){return this.options.confirm||!1}extractPartials(e){return Object.keys(e).join("&")}renderError(e,t,s,r,o){const n=new Error(e);return n.exception=t||null,n.file=s||null,n.line=r||null,n.trace=o||[],n}isHandlerName(e){return/^(?:\w+:{2})?on[A-Z0-9]/.test(e)}}if(void 0===window.Snowboard)throw new Error("Snowboard must be loaded in order to use the Javascript AJAX request feature.");window.Snowboard.addPlugin("request",a)}},function(e){var t;t=640,e(e.s=t)}]); \ No newline at end of file +"use strict";(self.webpackChunk_wintercms_wn_system_module=self.webpackChunk_wintercms_wn_system_module||[]).push([[813],{660:function(e,t,s){s.d(t,{A:function(){return r}});class r{constructor(e){this.snowboard=e}construct(){}dependencies(){return[]}listens(){return{}}destruct(){this.detach(),delete this.snowboard}destructor(){this.destruct()}}},59:function(e,t,s){var r=s(660);function o(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,r)}return s}function n(e){for(var t=1;t{e&&this.doAjax().then((e=>{if(e.cancelled)return this.cancelled=!0,void this.complete();this.responseData=e,this.processUpdate(e).then((()=>{!1===e.X_WINTER_SUCCESS?this.processError(e):this.processResponse(e)}))}),(e=>{this.responseError=e,this.processError(e)}))})):this.doAjax().then((e=>{if(e.cancelled)return this.cancelled=!0,void this.complete();this.responseData=e,this.processUpdate(e).then((()=>{!1===e.X_WINTER_SUCCESS?this.processError(e):this.processResponse(e)}))}),(e=>{this.responseError=e,this.processError(e)})):this.cancelled=!0}else this.cancelled=!0}dependencies(){return["cookie","jsonParser"]}checkRequest(){if(this.element&&this.element instanceof Element==!1)throw new Error("The element provided must be an Element instance");if(void 0===this.handler)throw new Error("The AJAX handler name is not specified.");if(!this.isHandlerName(this.handler))throw new Error('Invalid AJAX handler name. The correct handler name format is: "onEvent".')}getFetch(){return this.fetchOptions=void 0!==this.options.fetchOptions&&"object"==typeof this.options.fetchOptions?this.options.fetchOptions:{method:"POST",headers:this.headers,body:this.data,redirect:"follow",mode:"same-origin"},this.snowboard.globalEvent("ajaxFetchOptions",this.fetchOptions,this),fetch(this.url,this.fetchOptions)}doClientValidation(){return!0!==this.options.browserValidate||!this.form||!1!==this.form.checkValidity()||(this.form.reportValidity(),!1)}doAjax(){if(!1===this.snowboard.globalEvent("ajaxBeforeSend",this))return Promise.resolve({cancelled:!0});const e=new Promise(((e,t)=>{this.getFetch().then((s=>{s.ok||406===s.status?s.headers.has("Content-Type")&&s.headers.get("Content-Type").includes("/json")?s.json().then((t=>{e(n(n({},t),{},{X_WINTER_SUCCESS:406!==s.status,X_WINTER_RESPONSE_CODE:s.status}))}),(e=>{t(this.renderError(`Unable to parse JSON response: ${e}`))})):s.text().then((t=>{e(t)}),(e=>{t(this.renderError(`Unable to process response: ${e}`))})):s.headers.has("Content-Type")&&s.headers.get("Content-Type").includes("/json")?s.json().then((e=>{e.message&&e.exception?t(this.renderError(e.message,e.exception,e.file,e.line,e.trace)):t(e)}),(e=>{t(this.renderError(`Unable to parse JSON response: ${e}`))})):s.text().then((e=>{t(this.renderError(e))}),(e=>{t(this.renderError(`Unable to process response: ${e}`))}))}),(e=>{t(this.renderError(`Unable to retrieve a response from the server: ${e}`))}))}));if(this.snowboard.globalEvent("ajaxStart",e,this),this.element){const t=new Event("ajaxPromise");t.promise=e,this.element.dispatchEvent(t)}return e}processUpdate(e){return new Promise(((t,s)=>{if("function"==typeof this.options.beforeUpdate&&!1===this.options.beforeUpdate.apply(this,[e]))return void t();const r={};if(Object.entries(e).forEach((e=>{const[t,s]=e;"X_WINTER"!==t.substr(0,8)&&(r[t]=s)})),0===Object.keys(r).length)return void(e.X_WINTER_ASSETS?this.processAssets(e.X_WINTER_ASSETS).then((()=>{t()}),(()=>{s()})):t());this.snowboard.globalPromiseEvent("ajaxBeforeUpdate",e,this).then((async()=>{e.X_WINTER_ASSETS&&await this.processAssets(e.X_WINTER_ASSETS),this.doUpdate(r).then((()=>{window.requestAnimationFrame((()=>t()))}),(()=>{s()}))}),(()=>{t()}))}))}doUpdate(e){return new Promise((t=>{const s=[];Object.entries(e).forEach((e=>{const[t,r]=e;let o=this.options.update&&this.options.update[t]?this.options.update[t]:t,n="replace";"@"===o.substr(0,1)?(n="append",o=o.substr(1)):"^"===o.substr(0,1)?(n="prepend",o=o.substr(1)):"#"!==o.substr(0,1)&&"."!==o.substr(0,1)&&(n="noop");const i=document.querySelectorAll(o);i.length>0&&i.forEach((e=>{switch(n){case"append":e.innerHTML+=r;break;case"prepend":e.innerHTML=r+e.innerHTML;break;case"noop":break;default:e.innerHTML=r}s.push(e),this.snowboard.globalEvent("ajaxUpdate",e,r,this);const t=new Event("ajaxUpdate");t.content=r,e.dispatchEvent(t)}))})),this.snowboard.globalEvent("ajaxUpdateComplete",s,this),t()}))}processResponse(e){if((!this.options.success||"function"!=typeof this.options.success||!1!==this.options.success(this.responseData,this))&&!1!==this.snowboard.globalEvent("ajaxSuccess",this.responseData,this)){if(this.element){const e=new Event("ajaxDone",{cancelable:!0});if(e.responseData=this.responseData,e.request=this,this.element.dispatchEvent(e),e.defaultPrevented)return}this.flash&&e.X_WINTER_FLASH_MESSAGES&&this.processFlashMessages(e.X_WINTER_FLASH_MESSAGES),this.redirect||e.X_WINTER_REDIRECT?this.processRedirect(this.redirect||e.X_WINTER_REDIRECT):this.complete()}}processError(e){if((!this.options.error||"function"!=typeof this.options.error||!1!==this.options.error(this.responseError,this))&&!1!==this.snowboard.globalEvent("ajaxError",this.responseError,this)){if(this.element){const e=new Event("ajaxFail",{cancelable:!0});if(e.responseError=this.responseError,e.request=this,this.element.dispatchEvent(e),e.defaultPrevented)return}if(e instanceof Error)this.processErrorMessage(e.message);else{let t=!1;e.X_WINTER_ERROR_FIELDS&&(t=this.processValidationErrors(e.X_WINTER_ERROR_FIELDS)),e.X_WINTER_ERROR_MESSAGE&&!t&&this.processErrorMessage(e.X_WINTER_ERROR_MESSAGE)}this.complete()}}processRedirect(e){"function"==typeof this.options.handleRedirectResponse&&!1===this.options.handleRedirectResponse.apply(this,[e])||!1!==this.snowboard.globalEvent("ajaxRedirect",e,this)&&(window.addEventListener("popstate",(()=>{if(this.element){const e=document.createEvent("CustomEvent");e.eventName="ajaxRedirected",this.element.dispatchEvent(e)}}),{once:!0}),window.location.assign(e))}processErrorMessage(e){"function"==typeof this.options.handleErrorMessage&&!1===this.options.handleErrorMessage.apply(this,[e])||!1!==this.snowboard.globalEvent("ajaxErrorMessage",e,this)&&window.alert(e)}processFlashMessages(e){"function"==typeof this.options.handleFlashMessages&&!1===this.options.handleFlashMessages.apply(this,[e])||this.snowboard.globalEvent("ajaxFlashMessages",e,this)}processValidationErrors(e){return"function"==typeof this.options.handleValidationErrors&&!1===this.options.handleValidationErrors.apply(this,[this.form,e])||!1===this.snowboard.globalEvent("ajaxValidationErrors",this.form,e,this)}processAssets(e){return this.snowboard.globalPromiseEvent("ajaxLoadAssets",e)}async doConfirm(){if("function"==typeof this.options.handleConfirmMessage)return!1!==this.options.handleConfirmMessage.apply(this,[this.confirm]);if(0===this.snowboard.listensToEvent("ajaxConfirmMessage").length)return window.confirm(this.confirm);const e=this.snowboard.globalPromiseEvent("ajaxConfirmMessage",this.confirm,this);try{if(await e)return!0}catch(e){return!1}return!1}complete(){if(this.options.complete&&"function"==typeof this.options.complete&&this.options.complete(this.responseData,this),this.snowboard.globalEvent("ajaxDone",this.responseData,this),this.element){const e=new Event("ajaxAlways");e.request=this,e.responseData=this.responseData,e.responseError=this.responseError,this.element.dispatchEvent(e)}this.destruct()}get form(){return this.options.form?"string"==typeof this.options.form?document.querySelector(this.options.form):this.options.form:this.element?"FORM"===this.element.tagName?this.element:this.element.closest("form"):null}get context(){return{handler:this.handler,options:this.options}}get headers(){const e={"X-Requested-With":"XMLHttpRequest","X-WINTER-REQUEST-HANDLER":this.handler,"X-WINTER-REQUEST-PARTIALS":this.extractPartials(this.options.update||[])};return this.flash&&(e["X-WINTER-REQUEST-FLASH"]=1),this.xsrfToken&&(e["X-XSRF-TOKEN"]=this.xsrfToken),e}get loading(){return this.options.loading||!1}get url(){return this.options.url||window.location.href}get redirect(){return this.options.redirect&&this.options.redirect.length?this.options.redirect:null}get flash(){return this.options.flash||!1}get files(){return!0===this.options.files&&(void 0!==FormData||(this.snowboard.debug("This browser does not support file uploads"),!1))}get xsrfToken(){return this.snowboard.cookie().get("XSRF-TOKEN")}get data(){const e="object"==typeof this.options.data?this.options.data:{},t=new FormData(this.form||void 0);return Object.keys(e).length>0&&Object.entries(e).forEach((e=>{const[s,r]=e;t.append(s,r)})),t}get confirm(){return this.options.confirm||!1}extractPartials(e){return Object.keys(e).join("&")}renderError(e,t,s,r,o){const n=new Error(e);return n.exception=t||null,n.file=s||null,n.line=r||null,n.trace=o||[],n}isHandlerName(e){return/^(?:\w+:{2})?on[A-Z0-9]/.test(e)}}if(void 0===window.Snowboard)throw new Error("Snowboard must be loaded in order to use the Javascript AJAX request feature.");window.Snowboard.addPlugin("request",a)}},function(e){var t;t=59,e(e.s=t)}]); \ No newline at end of file diff --git a/modules/system/assets/js/snowboard/build/snowboard.vendor.js b/modules/system/assets/js/snowboard/build/snowboard.vendor.js index 7038746c39..dbff54961f 100644 --- a/modules/system/assets/js/snowboard/build/snowboard.vendor.js +++ b/modules/system/assets/js/snowboard/build/snowboard.vendor.js @@ -1,3 +1,3 @@ -"use strict";(self.webpackChunk_wintercms_wn_system_module=self.webpackChunk_wintercms_wn_system_module||[]).push([[109],{805:function(e,t,n){ +"use strict";(self.webpackChunk_wintercms_wn_system_module=self.webpackChunk_wintercms_wn_system_module||[]).push([[969],{478:function(e,t,n){ /*! js-cookie v3.0.5 | MIT */ -function r(e){for(var t=1;tgetCache()->get($this->getCacheKey($namespace, $name)); + + if (!is_null($version)) { + $version = $this->normalizeVersion($version); + + if (!isset($data['versions'][$version])) { + return null; + } + + return $data['versions'][$version]; + } + + return $data; + } + + public function has(string $namespace, string $name, ?string $version = null): bool + { + if (Config::get('marketplace.cache') === false) { + return null; + } + + if (is_null($version)) { + $this->getCache()->get($this->getCacheKey($namespace, $name)); + } + + return $this->get($namespace, $name, $version) !== null; + } + + public function set(string $namespace, string $name, string $version, array $packageData): void + { + if (Config::get('marketplace.cache') === false) { + return; + } + + $data = $this->getCache()->get($this->getCacheKey($namespace, $name)); + if (!isset($data['versions'])) { + $data['versions'] = []; + } + + $version = $this->normalizeVersion($version); + $data['versions'][$version] = $packageData; + + $this->getCache()->put($this->getCacheKey($namespace, $name), $data); + } + + public function forget(string $namespace, string $name, ?string $version = null): void + { + if (Config::get('marketplace.cache') === false) { + return; + } + + $this->getCache()->forget($this->getCacheKey($namespace, $name)); + } + + public function clear(): void + { + if (Config::get('marketplace.cache') === false) { + return; + } + + $this->getCache()->clear(); + } + + protected function getCache(): Repository + { + return Cache::store(Config::get('marketplace.store')); + } + + protected function getCacheKey(string $namespace, string $name): string + { + return 'marketplace.' . $namespace . '.' . $name; + } + + protected function normalizeVersion(string $version): string + { + $parser = new VersionParser; + return $parser->normalize($version); + } +} diff --git a/modules/system/classes/WinterPackage.php b/modules/system/classes/WinterPackage.php new file mode 100644 index 0000000000..58895d7e92 --- /dev/null +++ b/modules/system/classes/WinterPackage.php @@ -0,0 +1,52 @@ +getType() === 'winter-plugin') { + return false; + } + + $extras = $this->getExtras(); + + if (!isset($extras['winter']['name'])) { + return false; + } + + return true; + } + + public function getPluginName() + { + return $this->getExtras()['winter']['name']; + } + + public function getDisplayVersion() + { + $version = $this->getVersionNormalized(); + + if (preg_match('/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/', $version)) { + $parts = explode('.', $version); + array_pop($parts); + return implode('.', $parts); + } + + return $version; + } + + public function getAuthorList() + { + $authors = $this->getAuthors(); + + $list = []; + + foreach ($authors as $author) { + $list[] = $author['name']; + } + + return implode(', ', $list); + } +} diff --git a/modules/system/controllers/Updates.php b/modules/system/controllers/Updates.php index f27e1e4f5d..10fe78e941 100644 --- a/modules/system/controllers/Updates.php +++ b/modules/system/controllers/Updates.php @@ -16,8 +16,10 @@ use System\Classes\PluginManager; use System\Classes\SettingsManager; use System\Classes\UpdateManager; +use System\Facades\Composer; use System\Models\Parameter; use System\Models\PluginVersion; +use Winter\Packager\Enums\ShowMode; /** * Updates controller @@ -73,7 +75,7 @@ public function __construct() */ public function index() { - $this->vars['coreBuild'] = Parameter::get('system::core.build'); + $this->vars['coreBuild'] = $this->getCurrentBuild(); $this->vars['coreBuildModified'] = Parameter::get('system::core.modified', false); $this->vars['projectId'] = Parameter::get('system::project.id'); $this->vars['projectName'] = Parameter::get('system::project.name'); @@ -1040,4 +1042,16 @@ protected function appendRequiredPlugins(array $plugins, array $result) return $plugins; } + + /** + * Get current build from Composer. + * + * @return string + */ + protected function getCurrentBuild(): string + { + $package = Composer::show(ShowMode::SELF); + + return $package->getVersion(); + } } diff --git a/modules/system/controllers/updates/config_list.yaml b/modules/system/controllers/updates/config_list.yaml index 49cebd452e..c2d9483d85 100644 --- a/modules/system/controllers/updates/config_list.yaml +++ b/modules/system/controllers/updates/config_list.yaml @@ -3,8 +3,8 @@ # =================================== title: system::lang.updates.title -list: ~/modules/system/models/pluginversion/columns.yaml -modelClass: System\Models\PluginVersion +list: ~/modules/system/models/pluginlist/columns.yaml +modelClass: System\Models\PluginList noRecordsMessage: backend::lang.list.no_records recordUrl: system/updates/details/:slug diff --git a/modules/system/facades/Composer.php b/modules/system/facades/Composer.php new file mode 100644 index 0000000000..e4390fd396 --- /dev/null +++ b/modules/system/facades/Composer.php @@ -0,0 +1,22 @@ +code)] = [ + 'name' => $plugin->name, + 'composer' => false, + 'code' => strtolower($plugin->code), + 'description' => $plugin->description, + 'version' => $plugin->version, + 'author' => $plugin->author, + 'icon' => $plugin->icon, + 'iconSvg' => $plugin->iconSvg, + 'homepage' => $plugin->homepage, + 'orphaned' => $plugin->orphaned, + 'disabled' => $plugin->disabledBySystem || $plugin->disabledByConfig, + ]; + } + + $composerPackages = Composer::show()->type('winter-plugin')->toDetailed(); + + /** @var \System\Classes\DetailedPackage */ + foreach ($composerPackages as $package) { + $records[$this->toPluginCode($package->getNamespace(), $package->getName())] = [ + 'name' => $package->isWinterPlugin() + ? $package->getPluginName() + : $package->getPackageName(), + 'composer' => true, + 'code' => $this->toPluginCode($package->getNamespace(), $package->getName()), + 'description' => $package->getDescription(), + 'version' => ($package instanceof DetailedVersionedPackage) ? $package->getDisplayVersion() : null, + 'author' => $package->getAuthorList(), + 'icon' => null, + 'iconSvg' => null, + 'homepage' => $package->getHomepage(), + 'orphaned' => false, + 'disabled' => false, + ]; + } + + return array_values($records); + } + + protected function toPluginCode(string $namespace, string $name): string + { + $namespace = strtolower($namespace); + + $name = preg_replace('/^(wn|oc)\-/', '', strtolower($name)); + $name = preg_replace('/-plugin$/', '', $name); + + return $namespace . '.' . $name; + } + + /** + * Provides the slug attribute. + */ + public function getSlugAttribute(): string + { + return self::makeSlug($this->code); + } + + /** + * Generates a slug for the plugin. + */ + public static function makeSlug(string $code): string + { + return strtolower(str_replace('.', '-', $code)); + } +} diff --git a/modules/system/models/pluginlist/columns.yaml b/modules/system/models/pluginlist/columns.yaml new file mode 100644 index 0000000000..3f81e3b173 --- /dev/null +++ b/modules/system/models/pluginlist/columns.yaml @@ -0,0 +1,21 @@ +# =================================== +# Column Definitions +# =================================== + +columns: + + name: + label: system::lang.updates.plugin_name + sortable: false + + description: + label: system::lang.updates.plugin_description + sortable: false + + version: + label: system::lang.updates.plugin_version + sortable: false + + author: + label: system::lang.updates.plugin_author + sortable: false diff --git a/modules/system/winter.mix.js b/modules/system/winter.mix.js index afd0ec4c40..b070753c35 100644 --- a/modules/system/winter.mix.js +++ b/modules/system/winter.mix.js @@ -19,6 +19,9 @@ mix to: './assets/js/snowboard/build/snowboard.vendor.js', }) + // Compile updates assets + .less('./assets/less/updates/updates.less', './assets/css/updates/updates.css') + // Compile Snowboard for the Backend / System .js( [