UNPKG

csdsolutions-csdjs

Version:

Libreria per i progetti di CSD Solutions

1 lines 151 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("$CSD",[],t):"object"==typeof exports?exports.$CSD=t():e.$CSD=t()}(this,(()=>(()=>{var e={831:(e,t,n)=>{var o;function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function i(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function s(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o,a,i,r,s=[],c=!0,l=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(o=i.call(n)).done)&&(s.push(o.value),s.length!==t);c=!0);}catch(e){l=!0,a=e}finally{try{if(!c&&null!=n.return&&(r=n.return(),Object(r)!==r))return}finally{if(l)throw a}}return s}}(e,t)||l(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e){return function(e){if(Array.isArray(e))return d(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||l(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e,t){if(e){if("string"==typeof e)return d(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d(e,t):void 0}}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,h(o.key),o)}}function p(e,t,n){return t&&f(e.prototype,t),n&&f(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function h(e){var t=function(e,t){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=r(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==r(t)?t:t+""}var v,m=function(){function e(t){if(u(this,e),"string"==typeof t)try{if(t.trim().startsWith("<")&&t.trim().endsWith(">")){var n=document.createElement("div");n.innerHTML=t.trim(),this.elements=[n.firstElementChild]}else this.elements=Array.from(document.querySelectorAll(t))}catch(e){if(!(e instanceof DOMException&&"SyntaxError"===e.name))throw e;var o=document.createElement("div");o.innerHTML=t.trim(),this.elements=[o.firstElementChild]}else t instanceof Node?this.elements=[t]:t instanceof NodeList||Array.isArray(t)?this.elements=Array.from(t):this.elements=t instanceof e?t.elements:[];return new Proxy(this,{get:function(e,t){return"length"===t?e.elements.length:isNaN(t)?e[t]:e.elements[t]}})}return p(e,[{key:"_updateElements",value:function(){return this.elements=this.elements.map((function(t){return new e(t).elements[0]||null})).filter((function(e){return null!==e})),this}},{key:"addClass",value:function(e){return this.each((function(t){t.classList.add(e)}))._updateElements()}},{key:"removeClass",value:function(e){return this.each((function(t){t.classList.remove(e)}))._updateElements()}},{key:"toggleClass",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return this.each((function(n){void 0===t?n.classList.toggle(e):n.classList.toggle(e,t)}))._updateElements()}},{key:"attr",value:function(e,t){var n;return void 0===t?null===(n=this.elements[0])||void 0===n?void 0:n.getAttribute(e):this.each((function(n){n.setAttribute(e,t)}))._updateElements()}},{key:"removeAttr",value:function(e){return this.each((function(t){t.removeAttribute(e)}))._updateElements()}},{key:"prop",value:function(e,t){if(void 0===t){var n=this.elements[0];if(!n)return;return n[e],n[e]}return this.each((function(n){"checked"!==e&&"selected"!==e&&"disabled"!==e&&"readonly"!==e||(!0===t||"true"===t?n.setAttribute(e,""):n.removeAttribute(e)),n[e]=t,"readOnly"===e&&(!0===t||"true"===t?n.setAttribute("readonly",""):n.removeAttribute("readonly"))}))._updateElements()}},{key:"removeProp",value:function(e){return this.each((function(t){delete t[e]}))._updateElements()}},{key:"hasClass",value:function(e){var t;return(null===(t=this.elements[0])||void 0===t?void 0:t.classList.contains(e))||!1}},{key:"each",value:function(e){return this.elements.forEach((function(t,n){e.call(t,t,n)})),this}},{key:"add",value:function(e){var t=document.querySelectorAll(e);return this.elements=[].concat(c(this.elements),c(t)),this}},{key:"eq",value:function(t){return new e(this.elements[t])}},{key:"first",value:function(){return this.eq(0)}},{key:"last",value:function(){return this.eq(this.elements.length-1)}},{key:"get",value:function(e){return this.elements[e]}},{key:"index",value:function(){var e=this.elements[0];return e?Array.from(e.parentNode.children).indexOf(e):-1}},{key:"filter",value:function(t){return new e(this.elements.filter((function(e){if("function"==typeof t)return t.call(e,e);if(":visible"===t){if("undefined"!=typeof window){var n=window.getComputedStyle(e);return"none"!==n.display&&"hidden"!==n.visibility&&"0"!==n.opacity&&e.offsetWidth>0&&e.offsetHeight>0}return e.offsetWidth>0&&e.offsetHeight>0}if(":hidden"===t){if("undefined"!=typeof window){var o=window.getComputedStyle(e);return"none"===o.display||"hidden"===o.visibility||"0"===o.opacity||0===e.offsetWidth||0===e.offsetHeight}return 0===e.offsetWidth||0===e.offsetHeight}return t.includes("[")?t.match(/\[(.*?)\]/g).every((function(t){var n=s(t.slice(1,-1).split("="),2),o=n[0],a=n[1];if(a){var i=a.replace(/['"]/g,"");return e.getAttribute(o)===i}return e.hasAttribute(o)})):e.matches(t)})))}},{key:"map",value:function(e){return this.elements.map(e)}},{key:"slice",value:function(t,n){return new e(this.elements.slice(t,n))}},{key:"css",value:function(e,t){if("object"===r(e))return this.each((function(t){Object.assign(t.style,e)}));if(void 0===t){var n=this.elements[0];return n?"undefined"!=typeof window?window.getComputedStyle(n)[e]||"":n.style[e]||"":""}return this.each((function(n){n.style[e]=t}))}},{key:"data",value:function(e,t){var n=e.startsWith("data-")?e:"data-".concat(e);if(void 0!==t)return this.each((function(e){if(null===t)e.removeAttribute(n);else{var o="object"===r(t)?JSON.stringify(t):t;e.setAttribute(n,o)}}));var o=this.elements[0];if(o){var a=o.getAttribute(n);if(a)try{return"true"===a.toLowerCase()||"false"!==a.toLowerCase()&&(isNaN(a)?JSON.parse(a):Number(a))}catch(e){return a}}}},{key:"outerWidth",value:function(){var e;return(null===(e=this.elements[0])||void 0===e?void 0:e.offsetWidth)||0}},{key:"outerHeight",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.elements[0];if(!t)return 0;var n=t.offsetHeight;if(e){var o=window.getComputedStyle(t);n+=parseFloat(o.marginTop)+parseFloat(o.marginBottom)}return n}},{key:"height",value:function(){var e;return null===(e=this.elements[0])||void 0===e?void 0:e.offsetHeight}},{key:"width",value:function(){var e;return null===(e=this.elements[0])||void 0===e?void 0:e.offsetWidth}},{key:"innerHeight",value:function(){var e;return null===(e=this.elements[0])||void 0===e?void 0:e.clientHeight}},{key:"innerWidth",value:function(){var e;return null===(e=this.elements[0])||void 0===e?void 0:e.clientWidth}},{key:"show",value:function(){return this.each((function(e){e.style.display=""}))._updateElements()}},{key:"hide",value:function(){return this.each((function(e){e.style.display="none"}))._updateElements()}},{key:"toggle",value:function(e){return this.each((function(t){var n="none"===window.getComputedStyle(t).display;t.style.display=void 0===e?n?"":"none":e?"":"none"}))._updateElements()}},{key:"on",value:function(e,t,n){if("string"==typeof t){var o=t;return this.each((function(t){var a=function(e){for(var a=t.querySelectorAll(o),i=!1,r=e.target;r&&r!==t;){if(Array.from(a).includes(r)){i=!0;break}r=r.parentElement}i&&n.call(r,e)};t._eventHandlers||(t._eventHandlers={}),t._eventHandlers[e]||(t._eventHandlers[e]=[]),t._eventHandlers[e].push({selector:o,handler:a,callback:n}),t.addEventListener(e,a)}))._updateElements()}var a=t;return this.each((function(t){t._eventHandlers||(t._eventHandlers={}),t._eventHandlers[e]||(t._eventHandlers[e]=[]),t._eventHandlers[e].push({handler:a,callback:a}),t.addEventListener(e,a)}))._updateElements()}},{key:"off",value:function(e,t){return this.each((function(n){n._eventHandlers&&n._eventHandlers[e]&&(n._eventHandlers[e].forEach((function(o){t&&o.callback!==t||n.removeEventListener(e,o.handler||o.callback)})),t?n._eventHandlers[e]=n._eventHandlers[e].filter((function(e){return e.callback!==t})):delete n._eventHandlers[e])}))._updateElements()}},{key:"one",value:function(e,t){return this.each((function(n){var o=function(a){t(a),n.removeEventListener(e,o)};n.addEventListener(e,o)}))._updateElements()}},{key:"trigger",value:function(e){if("string"==typeof e){var t=new Event(e);return this.each((function(e){e.dispatchEvent(t)}))._updateElements()}var n=new CustomEvent(e.type,{detail:e,bubbles:!0,cancelable:!0});return this.each((function(e){e.dispatchEvent(n)}))._updateElements()}},{key:"click",value:function(e){return e?this.on("click",(function(t){e.call(this,t)}))._updateElements():this.each((function(e){e.click()}))._updateElements()}},{key:"hover",value:function(e,t){return this.on("mouseenter",(function(t){e&&e.call(this,t)})).on("mouseleave",(function(e){t&&t.call(this,e)}))._updateElements()}},{key:"ready",value:function(e){return"loading"!==document.readyState?e():document.addEventListener("DOMContentLoaded",e),this}},{key:"focus",value:function(e){return void 0===e?(this.elements[0]&&this.elements[0].focus(),this):this.on("focus",e)}},{key:"blur",value:function(e){return void 0===e?(this.elements[0]&&this.elements[0].blur(),this):this.on("blur",e)}},{key:"val",value:function(e){if(void 0===e){var t=this.elements[0];if(!t)return;if("select-multiple"===t.type){var n=Array.from(t.selectedOptions).map((function(e){return e.value})).filter((function(e){return""!==e}));return n}return t.value}return this.each((function(t){"select-multiple"===t.type&&Array.isArray(e)?Array.from(t.options).forEach((function(t){t.selected=e.includes(t.value)})):t.value=e}))._updateElements()}},{key:"serialize",value:function(){if(!this.elements[0]||"FORM"!==this.elements[0].nodeName)return"";var e=new FormData(this.elements[0]);return new URLSearchParams(e).toString()}},{key:"html",value:function(e){var t;return void 0===e?null===(t=this.elements[0])||void 0===t?void 0:t.innerHTML:this.each((function(t){t.innerHTML=e}))._updateElements()}},{key:"text",value:function(e){var t;return void 0===e?null===(t=this.elements[0])||void 0===t?void 0:t.textContent:this.each((function(t){t.textContent=e}))._updateElements()}},{key:"append",value:function(t){if(!t)return this;var n=function(e,t){if("string"==typeof t)return e.insertAdjacentHTML("beforeend",t),e.lastElementChild;if(t instanceof Node){var n=t.cloneNode(!0);return e.appendChild(n),n}return null},o=[];return this.each((function(a){if(t instanceof e)t.each((function(e){var t=n(a,e);t&&o.push(t)}));else{var i=n(a,t);i&&o.push(i)}})),t instanceof e&&(t.elements=o),this._updateElements()}},{key:"prepend",value:function(t){if(!t)return this;var n=[];return this.each((function(o){if("string"==typeof t)o.insertAdjacentHTML("afterbegin",t),n.push(o.firstElementChild);else if(t instanceof e)t.each((function(e){var t=e.cloneNode(!0);o.prepend(t),n.push(t)}));else if(t instanceof Node){var a=t.cloneNode(!0);o.prepend(a),n.push(a)}})),t instanceof e&&(t.elements=n),this._updateElements()}},{key:"before",value:function(t){if(!t)return this;var n=[];return this.each((function(o){if("string"==typeof t)o.insertAdjacentHTML("beforebegin",t),n.push(o.previousElementSibling);else if(t instanceof e)t.each((function(e){var t=e.cloneNode(!0);o.before(t),n.push(t)}));else if(t instanceof Node){var a=t.cloneNode(!0);o.before(a),n.push(a)}})),t instanceof e&&(t.elements=n),this._updateElements()}},{key:"after",value:function(t){if(!t)return this;var n=[];return this.each((function(o){if("string"==typeof t)o.insertAdjacentHTML("afterend",t),n.push(o.nextElementSibling);else if(t instanceof e)t.each((function(e){var t=e.cloneNode(!0);o.after(t),n.push(t)}));else if(t instanceof Node){var a=t.cloneNode(!0);o.after(a),n.push(a)}})),t instanceof e&&(t.elements=n),this._updateElements()}},{key:"empty",value:function(){return this.each((function(e){e.innerHTML=""}))._updateElements()}},{key:"remove",value:function(){return this.each((function(e){e.remove()})),this._updateElements()}},{key:"clone",value:function(){return new e(this.elements.map((function(e){return e.cloneNode(!0)})))}},{key:"wrap",value:function(t){return this.each((function(n){var o,a=document.createElement("div");t instanceof e?a.innerHTML=(null===(o=t.elements[0])||void 0===o?void 0:o.outerHTML)||"":a.innerHTML=t;var i=a.firstElementChild;i&&(n.parentNode.insertBefore(i,n),i.appendChild(n))}))._updateElements()}},{key:"unwrap",value:function(){return this.each((function(e){var t=e.parentNode;t&&"BODY"!==t.nodeName&&t.replaceWith.apply(t,c(t.childNodes))}))._updateElements()}},{key:"wrapInner",value:function(e){return this.each((function(t){var n=document.createElement("div");for(n.innerHTML=e;t.firstChild;)n.firstElementChild.appendChild(t.firstChild);t.appendChild(n.firstElementChild)}))._updateElements()}},{key:"wrapAll",value:function(e){if(0===this.elements.length)return this;var t=document.createElement("div");t.innerHTML=e;var n=t.firstElementChild;return this.elements[0].parentNode.insertBefore(n,this.elements[0]),this.each((function(e){n.appendChild(e)})),this._updateElements()}},{key:"scrollTop",value:function(e){return this.elements[0]===window?void 0===e?window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0:(window.scrollTo({top:e,behavior:"smooth"}),this):void 0===e?(null===(t=this.elements[0])||void 0===t?void 0:t.scrollTop)||0:this.each((function(t){t.scrollTop=e}))._updateElements();var t}},{key:"offset",value:function(){if(this.elements[0]){var e=this.elements[0].getBoundingClientRect();return"undefined"!=typeof window?{top:e.top+window.scrollY,left:e.left+window.scrollX}:{top:e.top,left:e.left}}}},{key:"position",value:function(){if(this.elements[0])return{top:this.elements[0].offsetTop,left:this.elements[0].offsetLeft}}},{key:"offsetParent",value:function(){var t;return new e(null===(t=this.elements[0])||void 0===t?void 0:t.offsetParent)}},{key:"children",value:function(){var t;return new e(null===(t=this.elements[0])||void 0===t?void 0:t.children)}},{key:"parent",value:function(){var t;return new e(null===(t=this.elements[0])||void 0===t?void 0:t.parentNode)}},{key:"parents",value:function(){for(var t,n=[],o=null===(t=this.elements[0])||void 0===t?void 0:t.parentNode;o&&"HTML"!==o.nodeName;)n.push(o),o=o.parentNode;return new e(n)}},{key:"parentsUntil",value:function(t){for(var n,o=[],a=null===(n=this.elements[0])||void 0===n?void 0:n.parentNode;a&&!a.matches(t);)o.push(a),a=a.parentNode;return new e(o)}},{key:"closest",value:function(t){var n=this.elements[0];if(!n)return new e([]);var o=n.closest(t);return new e(o?[o]:[])}},{key:"contents",value:function(){var t;return new e(null===(t=this.elements[0])||void 0===t?void 0:t.childNodes)}},{key:"find",value:function(t){var n;if(":visible"===t){var o,a=null===(o=this.elements[0])||void 0===o?void 0:o.querySelectorAll("*");return new e(a?Array.from(a).filter((function(e){if("undefined"!=typeof window){var t=window.getComputedStyle(e);return"none"!==t.display&&"hidden"!==t.visibility&&"0"!==t.opacity&&e.offsetWidth>0&&e.offsetHeight>0}return e.offsetWidth>0&&e.offsetHeight>0})):[])}if(":hidden"===t){var i,r=null===(i=this.elements[0])||void 0===i?void 0:i.querySelectorAll("*");return new e(r?Array.from(r).filter((function(e){if("undefined"!=typeof window){var t=window.getComputedStyle(e);return"none"===t.display||"hidden"===t.visibility||"0"===t.opacity||0===e.offsetWidth||0===e.offsetHeight}return 0===e.offsetWidth||0===e.offsetHeight})):[])}if(":selected"===t)return new e(this.elements.reduce((function(e,t){var n=t.querySelectorAll("option").length>0?Array.from(t.querySelectorAll("option")).filter((function(e){return e.selected})):[];return[].concat(c(e),c(n))}),[]));if(t.includes(":visible")||t.includes(":hidden")||t.includes(":selected")||t.includes(":checked")){var s,l=t.replace(/:visible|:hidden|:selected/g,""),d=t.includes(":visible"),u=t.includes(":hidden"),f=t.includes(":selected"),p=null===(s=this.elements[0])||void 0===s?void 0:s.querySelectorAll(l);return new e(p?Array.from(p).filter((function(e){if(f&&"option"===e.tagName.toLowerCase())return e.selected;var t=window.getComputedStyle(e),n="none"!==t.display&&"hidden"!==t.visibility&&"0"!==t.opacity&&e.offsetWidth>0&&e.offsetHeight>0;return d?n:!u||!n})):[])}return new e(null===(n=this.elements[0])||void 0===n?void 0:n.querySelectorAll(t))}},{key:"siblings",value:function(){var t,n=this,o=Array.from((null===(t=this.elements[0])||void 0===t||null===(t=t.parentNode)||void 0===t?void 0:t.children)||[]).filter((function(e){return e!==n.elements[0]}));return new e(o)}},{key:"next",value:function(){var t;return new e(null===(t=this.elements[0])||void 0===t?void 0:t.nextElementSibling)}},{key:"prev",value:function(){var t;return new e(null===(t=this.elements[0])||void 0===t?void 0:t.previousElementSibling)}},{key:"nextAll",value:function(){for(var t,n=[],o=null===(t=this.elements[0])||void 0===t?void 0:t.nextElementSibling;o;)n.push(o),o=o.nextElementSibling;return new e(n)}},{key:"prevAll",value:function(){for(var t,n=[],o=null===(t=this.elements[0])||void 0===t?void 0:t.previousElementSibling;o;)n.push(o),o=o.previousElementSibling;return new e(n)}},{key:"nextUntil",value:function(t){for(var n,o=[],a=null===(n=this.elements[0])||void 0===n?void 0:n.nextElementSibling;a&&!a.matches(t);)o.push(a),a=a.nextElementSibling;return new e(o)}},{key:"prevUntil",value:function(t){for(var n,o=[],a=null===(n=this.elements[0])||void 0===n?void 0:n.previousElementSibling;a&&!a.matches(t);)o.push(a),a=a.previousElementSibling;return new e(o)}},{key:"is",value:function(t){if(!this.elements[0]||!t)return!1;if("function"==typeof t)return this.elements.some((function(e,n){return t.call(e,n,e)}));if(t instanceof e)return this.elements.some((function(e){return t.elements.includes(e)}));if(t.nodeType)return this.elements.includes(t);if(":visible"===t||":hidden"===t){return this.elements.some((function(e){if(!e)return!1;if("undefined"!=typeof window){var n=window.getComputedStyle(e),o="none"!==n.display&&"hidden"!==n.visibility&&"0"!==n.opacity&&e.offsetWidth>0&&e.offsetHeight>0;return":visible"===t?o:!o}var a=e.offsetWidth>0&&e.offsetHeight>0;return":visible"===t?a:!a}))}try{if("string"==typeof t){var n=Array.from(document.querySelectorAll(t));return this.elements.some((function(e){return n.includes(e)}))}}catch(e){}return!1}},{key:"not",value:function(t){if(t instanceof e){var n=t.elements;return new e(this.elements.filter((function(e){return!n.includes(e)})))}if(t instanceof Node)return new e(this.elements.filter((function(e){return e!==t})));if("string"==typeof t)try{return new e(this.elements.filter((function(e){return!(e instanceof Element)||!e.matches(t)})))}catch(e){return this}return this}},{key:"has",value:function(t){return new e(this.elements.some((function(e){return e.querySelector(t)}))?this.elements:[])}},{key:"replaceWith",value:function(t){var n;return this.each((function(o){var a;if(t instanceof e)a=t.elements[0],o.replaceWith(a);else if(t instanceof Node)a=t.cloneNode(!0),o.replaceWith(a);else if("string"==typeof t){var i=document.createElement("div");i.innerHTML=t.trim(),a=i.firstElementChild,o.replaceWith(a)}n=a})),new e(n)._updateElements()}}],[{key:"extend",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return Object.assign.apply(Object,[e].concat(n))}},{key:"each",value:function(e,t){if(e)return e instanceof NodeList||Array.isArray(e)||e instanceof Array||e instanceof NamedNodeMap?Array.from(e).forEach((function(e,n){t.call(e,n)})):t.call(e,0),this}}])}(),g=function(){return p((function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};u(this,e),this.element=t,this.options=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({handle:".handle",draggable:".csd-reorder",ghostClass:"csd-reorder-ghost",dragClass:"csd-reorder-drag",onStart:null,onEnd:null},n),this.dragItem=null,this.startY=0,this.currentY=0,this.initialY=0,this.touchStartTime=0,this.init()}),[{key:"init",value:function(){var e=this;this.element.querySelectorAll(this.options.draggable).forEach((function(t){t.draggable=!0;var n=t.querySelector(e.options.handle);n&&(n.addEventListener("mousedown",(function(){t.draggable=!0})),n.addEventListener("mouseup",(function(){t.draggable=!1})),n.addEventListener("touchstart",(function(n){return e.handleTouchStart(n,t)})),n.addEventListener("touchmove",(function(t){return e.handleTouchMove(t)})),n.addEventListener("touchend",(function(t){return e.handleTouchEnd(t)}))),t.addEventListener("dragstart",(function(n){return e.handleDragStart(n,t)})),t.addEventListener("dragend",(function(n){return e.handleDragEnd(n,t)}))})),this.element.addEventListener("dragover",(function(t){return e.handleDragOver(t)})),this.element.addEventListener("dragenter",(function(e){return e.preventDefault()}))}},{key:"handleTouchStart",value:function(e,t){e.preventDefault(),this.touchStartTime=Date.now(),this.dragItem=t;var n=e.touches[0];this.startY=n.clientY,this.initialY=this.dragItem.offsetTop}},{key:"handleTouchMove",value:function(e){if(this.dragItem){e.preventDefault();var t=e.touches[0];this.currentY=t.clientY;var n=this.currentY-this.startY;if(Date.now()-this.touchStartTime>150){this.dragItem.classList.add(this.options.dragClass),this.element.classList.add("is-dragging"),this.dragItem.style.transform="translateY(".concat(n,"px)");var o=c(this.element.querySelectorAll("".concat(this.options.draggable,":not(.").concat(this.options.dragClass,")"))).find((function(e){var n=e.getBoundingClientRect(),o=n.top+n.height/2;return t.clientY<=o}));o?this.element.insertBefore(this.dragItem,o):this.element.appendChild(this.dragItem)}}}},{key:"handleTouchEnd",value:function(e){if(this.dragItem){if(e.preventDefault(),this.dragItem.classList.remove(this.options.dragClass),this.element.classList.remove("is-dragging"),this.dragItem.style.transform="",this.options.onEnd){var t=Array.from(this.element.children).indexOf(this.dragItem);this.options.onEnd({item:this.dragItem,from:this.startIndex,to:t})}this.dragItem=null,this.startY=0,this.currentY=0,this.initialY=0,this.touchStartTime=0}}},{key:"handleDragStart",value:function(e,t){var n=this;e.dataTransfer.effectAllowed="move",this.startIndex=Array.from(this.element.children).indexOf(t),setTimeout((function(){t.classList.add(n.options.dragClass),n.element.classList.add("is-dragging")}),0),this.options.onStart&&this.options.onStart({item:t,index:this.startIndex})}},{key:"handleDragOver",value:function(e){e.preventDefault(),e.dataTransfer.dropEffect="move";var t=this.element.querySelector("."+this.options.dragClass);if(t){var n=c(this.element.querySelectorAll("".concat(this.options.draggable,":not(.").concat(this.options.dragClass,")"))).find((function(t){var n=t.getBoundingClientRect(),o=n.top+n.height/2;return e.clientY<=o}));n?this.element.insertBefore(t,n):this.element.appendChild(t)}}},{key:"handleDragEnd",value:function(e,t){t.classList.remove(this.options.dragClass),this.element.classList.remove("is-dragging");var n=Array.from(this.element.children).indexOf(t);this.options.onEnd&&this.options.onEnd({item:t,from:this.startIndex,to:n}),t.draggable=!1}},{key:"destroy",value:function(){var e=this;this.element.querySelectorAll(this.options.draggable).forEach((function(t){t.draggable=!1,t.removeEventListener("dragstart",e.handleDragStart),t.removeEventListener("dragend",e.handleDragEnd);var n=t.querySelector(e.options.handle);n&&(n.removeEventListener("mousedown",null),n.removeEventListener("mouseup",null),n.removeEventListener("touchstart",null),n.removeEventListener("touchmove",null),n.removeEventListener("touchend",null))})),this.element.removeEventListener("dragover",this.handleDragOver),this.element.removeEventListener("dragenter",null)}}])}(),b=((v=function(e){return"undefined"==typeof window||"undefined"==typeof document?{elements:[],length:0,each:function(){return this},find:function(){return this},addClass:function(){return this},removeClass:function(){return this},toggleClass:function(){return this},hasClass:function(){return!1},attr:function(){return this},removeAttr:function(){return this},data:function(){return this},css:function(){return this},html:function(){return""},text:function(){return""},append:function(){return this},prepend:function(){return this},on:function(){return this},off:function(){return this},closest:function(){return this},is:function(){return!1}}:new m(e)}).ready=function(e){"undefined"!=typeof document&&("loading"!==document.readyState?e():document.addEventListener("DOMContentLoaded",e))},v);"undefined"!=typeof window&&(window.$CSD=b,window._CSD_UTILS=m,window.Sortable=g),b.extend=m.extend,b.each=m.each,e.exports?e.exports={$CSD:b,_CSD_UTILS:m,Sortable:g}:void 0===(o=function(){return{$CSD:b,_CSD_UTILS:m,Sortable:g}}.call(t,n,t,e))||(e.exports=o)},981:(e,t,n)=>{"use strict";n.d(t,{default:()=>Ne});var o={};n.r(o),n.d(o,{destroyBtn:()=>K,destroyFab:()=>x,getCheckboxValues:()=>l,getRadioValue:()=>u,initializeAccordion:()=>Ce,initializeBtn:()=>G,initializeCheckbox:()=>c,initializeConfirmDialog:()=>ue,initializeCustomSelect:()=>I,initializeDatepickers:()=>J,initializeDropdown:()=>O,initializeEditor:()=>m,initializeFab:()=>E,initializeList:()=>pe,initializeMask:()=>U,initializeMenu:()=>Se,initializeModal:()=>de,initializeNavigation:()=>le,initializeNumber:()=>z,initializeOTP:()=>Y,initializePassword:()=>te,initializePopover:()=>ve,initializeRadio:()=>f,initializeRange:()=>re,initializeReorder:()=>M,initializeSearchbar:()=>Q,initializeSegment:()=>we,initializeSidebar:()=>De,initializeSplitButton:()=>se,initializeSplitter:()=>he,initializeStepper:()=>me,initializeSubmenu:()=>$e,initializeTab:()=>ge,initializeTextArea:()=>ce,initializeToast:()=>fe,initializeToggle:()=>ee,initializeToggleButton:()=>Z,initializeToolbar:()=>ke,showAccordion:()=>ye});var a=function(){var e=function(){return{elements:[],length:0,each:function(){return this},find:function(){return this},addClass:function(){return this},removeClass:function(){return this},toggleClass:function(){return this},hasClass:function(){return!1},attr:function(){return this},removeAttr:function(){return this},data:function(){return this},css:function(){return this},html:function(){return""},text:function(){return""},append:function(){return this},prepend:function(){return this},on:function(){return this},off:function(){return this},closest:function(){return this},is:function(){return!1}}};return e.ready=function(e){},e.extend=function(){return{}},e.each=function(){return null},e},i="undefined"==typeof window?a():void 0!==i?i:a();var r=n(831);function s(e){var t,n=e.closest(".csd-field").find(".csd-checkbox-input"),o=n.find(".csd-checkbox-input:checked"),a={type:"csd_change",action:"change",item:e,targetValue:e.attr("value"),totalItems:n.length,checkedItems:o.length,allChecked:n.length===o.length,allUnchecked:0===o.length,checkedValues:(t=[],o.each((function(){t.push($CSD(this).attr("value"))})),t)};e.trigger(a)}function c(e){var t=$CSD(e),n=t.attr("label")||"",o=t.attr("id")||"checkbox-"+Math.random().toString(36).substr(2,9),a=$CSD('<div class="csd-checkbox-wrapper"></div>'),i=$CSD('<div class="csd-checkbox"></div>'),r=$CSD('<input type="checkbox" class="csd-checkbox-input">').attr("id",o),c=$CSD('<div class="csd-checkbox-box"><ion-icon name="checkmark-sharp"></ion-icon></div>');t.elements[0].checked&&(r.elements[0].checked=!0),t.elements[0].disabled&&(r.elements[0].disabled=!0),t.attr("name")&&r.attr("name",t.attr("name")),t.attr("value")&&r.attr("value",t.attr("value"));var l=t.attr("class");if(l){var d=l.split(" ").filter((function(e){return"csd-checkbox"!==e})).join(" ");d&&r.addClass(d)}for(var u=t.elements[0],f=0;f<u.attributes.length;f++){var p=u.attributes[f];["type","class","id"].includes(p.name)||r.attr(p.name,p.value)}if(i.append(r),i.append(c),a.append(i),n){var h=$CSD('<label class="csd-checkbox-label"></label>').text(n).attr("for",o);a.append(h)}t.replaceWith(a),a.find(".csd-checkbox-label").on("click",(function(e){if(e.preventDefault(),e.stopPropagation(),!a.find(".csd-checkbox-input").prop("disabled")){var t=a.find(".csd-checkbox-input").prop("checked");a.find(".csd-checkbox-input").prop("checked",!t),s(a.find(".csd-checkbox-input"))}})),a.find(".csd-checkbox-box").on("click",(function(e){if(e.preventDefault(),!a.find(".csd-checkbox-input").prop("disabled")){var t=a.find(".csd-checkbox-input").prop("checked");a.find(".csd-checkbox-input").prop("checked",!t),s(a.find(".csd-checkbox-input"))}}))}function l(e){var t=[];return $CSD('.csd-checkbox-wrapper input[name="'.concat(e,'"]')).each((function(){var e=$CSD(this);t.push({value:e.val()||"on",checked:e.elements[0].checked,disabled:e.elements[0].disabled,label:e.closest(".csd-checkbox-wrapper").find(".csd-checkbox-label").text()})})),t}function d(e){var t=e.closest(".csd-field").find(".csd-radio-input"),n=t.find(".csd-radio-input:checked"),o={type:"csd_change",action:"change",item:e,targetValue:e.attr("value"),totalItems:t.length,selectedValue:n.length?n.attr("value"):null,selectedLabel:n.length?n.closest(".csd-radio-wrapper").find(".csd-radio-label").text():null,hasSelection:n.length>0};e.trigger(o)}function u(e){var t=[];return $CSD('.csd-radio-wrapper input[name="'.concat(e,'"]')).each((function(){var e=$CSD(this);t.push({value:e.val()||"on",checked:e.elements[0].checked,disabled:e.elements[0].disabled,label:e.closest(".csd-radio-wrapper").find(".csd-radio-label").text()})})),t}function f(e){var t=$CSD(e),n=t.attr("label")||"",o=t.attr("id")||"radio-"+Math.random().toString(36).substr(2,9),a=$CSD('<div class="csd-radio-wrapper"></div>'),i=$CSD('<div class="csd-radio"></div>'),r=$CSD('<input type="radio" class="csd-radio-input">').attr("id",o),s=$CSD('<div class="csd-radio-box"><div class="csd-radio-dot"></div></div>');t.elements[0].checked&&(r.elements[0].checked=!0),t.elements[0].disabled&&(r.elements[0].disabled=!0),t.attr("name")&&r.attr("name",t.attr("name")),t.attr("value")&&r.attr("value",t.attr("value"));var c=t.attr("class");if(c){var l=c.split(" ").filter((function(e){return"csd-radio"!==e})).join(" ");l&&r.addClass(l)}for(var u=t.elements[0],f=0;f<u.attributes.length;f++){var p=u.attributes[f];["type","class","id"].includes(p.name)||r.attr(p.name,p.value)}if(i.append(r),i.append(s),a.append(i),n){var h=$CSD('<label class="csd-radio-label"></label>').text(n).attr("for",o);a.append(h)}t.replaceWith(a),a.find(".csd-radio-label").on("click",(function(e){e.preventDefault(),e.stopPropagation(),a.find(".csd-radio-input").prop("disabled")||(a.find(".csd-radio-input").prop("checked",!0),d(a.find(".csd-radio-input")))})),a.find(".csd-radio-box").on("click",(function(e){e.preventDefault(),a.find(".csd-radio-input").prop("disabled")||(a.find(".csd-radio-input").prop("checked",!0),d(a.find(".csd-radio-input")))}))}function p(e){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p(e)}function h(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return v(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?v(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0,a=function(){};return{s:a,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,r=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return r=e.done,e},e:function(e){s=!0,i=e},f:function(){try{r||null==n.return||n.return()}finally{if(s)throw i}}}}function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function m(e){if(e&&!e.initialized){var t=$CSD(e),n=$CSD('<div class="csd-editor-container"></div>');t.wrap(n);var o=function(){var e=$CSD('<div class="csd-editor-menubar"></div>');return Object.keys(S).forEach((function(t){var n=$CSD('<div class="csd-editor-menu-item">\n <span>'.concat(t.charAt(0).toUpperCase()+t.slice(1),'</span>\n <div class="csd-editor-menu-dropdown">\n ').concat(S[t].map((function(e){return'\n <button type="button" data-action="'.concat(e.action,'">\n <i class="').concat(e.icon,'"></i>\n ').concat(e.label,"\n </button>\n ")})).join(""),"\n </div>\n </div>"));e.append(n)})),e}(),a=function(){var e=$CSD('<div class="csd-editor-toolbar"></div>');D.forEach((function(t){var n=$CSD('<div class="csd-editor-toolbar-group"></div>');t.forEach((function(e){var t=function(e){var t={undo:{icon:"fa-solid fa-rotate-left",title:"Undo (Ctrl+Z)",shortcut:"Ctrl+Z"},redo:{icon:"fa-solid fa-rotate-right",title:"Redo (Ctrl+Y)",shortcut:"Ctrl+Y"},cut:{icon:"fa-regular fa-scissors",title:"Cut (Ctrl+X)",shortcut:"Ctrl+X"},copy:{icon:"fa-regular fa-copy",title:"Copy (Ctrl+C)",shortcut:"Ctrl+C"},paste:{icon:"fa-regular fa-clipboard",title:"Paste (Ctrl+V)",shortcut:"Ctrl+V"},heading:{icon:"fa-solid fa-heading",title:"Heading",dropdown:!0},bold:{icon:"fa-solid fa-bold",title:"Bold (Ctrl+B)",shortcut:"Ctrl+B"},italic:{icon:"fa-solid fa-italic",title:"Italic (Ctrl+I)",shortcut:"Ctrl+I"},underline:{icon:"fa-solid fa-underline",title:"Underline (Ctrl+U)",shortcut:"Ctrl+U"},strikethrough:{icon:"fa-solid fa-strikethrough",title:"Strikethrough"},font:{icon:"fa-solid fa-font",title:"Font Family",dropdown:!0},fontSize:{icon:"fa-solid fa-text-height",title:"Font Size",dropdown:!0},textColor:{icon:"fa-solid fa-palette",title:"Text Color",dropdown:!0},backgroundColor:{icon:"fa-solid fa-fill",title:"Background Color",dropdown:!0},alignment:{icon:"fa-solid fa-align-justify",title:"Text Alignment",dropdown:!0},numberedList:{icon:"fa-solid fa-list-ol",title:"Numbered List (Ctrl+Shift+7)"},bulletedList:{icon:"fa-solid fa-list-ul",title:"Bulleted List (Ctrl+Shift+8)"},indent:{icon:"fa-solid fa-indent",title:"Increase Indent (Tab)"},outdent:{icon:"fa-solid fa-outdent",title:"Decrease Indent (Shift+Tab)"},link:{icon:"fa-solid fa-link",title:"Insert Link (Ctrl+K)",shortcut:"Ctrl+K"},image:{icon:"fa-regular fa-image",title:"Insert Image"},table:{icon:"fa-solid fa-table",title:"Insert Table"},specialCharacters:{icon:"fa-solid fa-s",title:"Special Characters"},pageBreak:{icon:"fa-solid fa-grip-lines",title:"Insert Page Break"},sourceEditing:{icon:"fa-solid fa-code",title:"Source Editing"}}[e];if(!t)return"";var n=t.title,o=$CSD('\n <button type="button" class="csd-editor-tool" data-command="'.concat(e,'">\n <i class="').concat(t.icon,'"></i>\n ').concat(t.dropdown?'<i class="fa-solid fa-chevron-down"></i>':"",'\n <span class="csd-editor-tooltip">').concat(n,"</span>\n </button>\n "));return o}(e);n.append(t)})),e.append(n)}));var t=function(){var e=$CSD('<div class="csd-editor-toolbar-mobile"></div>'),t=$CSD('<div class="csd-editor-toolbar-mobile-top"></div>'),n=$CSD('<div class="csd-editor-toolbar-group"></div>');n.append('\n <button class="csd-editor-tool" data-command="undo">\n <i class="fa-solid fa-rotate-left"></i>\n </button>\n <button class="csd-editor-tool" data-command="redo">\n <i class="fa-solid fa-rotate-right"></i>\n </button>\n <button class="csd-editor-tool" data-command="copy">\n <i class="fa-solid fa-copy"></i>\n </button>\n <button class="csd-editor-tool" data-command="paste">\n <i class="fa-solid fa-paste"></i>\n </button>\n ');var o=$CSD('\n <div class="csd-editor-toolbar-dropdown">\n <button class="csd-editor-tool">\n <i class="fa-solid fa-plus"></i>\n </button>\n <div class="csd-editor-toolbar-dropdown-menu">\n <button data-command="image"><i class="fa-regular fa-image"></i> Image</button>\n <button data-command="link"><i class="fa-solid fa-link"></i> Link</button>\n </div>\n </div>\n ');t.append(n),t.append(o);var a=$CSD('<div class="csd-editor-toolbar-mobile-bottom"></div>'),i=$CSD('<div class="csd-editor-toolbar-group"></div>');i.append('\n <button class="csd-editor-tool" data-command="bold" style="width: 100%; height: 100%;">\n <i class="fa-solid fa-bold" style="pointer-events: none;"></i>\n </button>\n <button class="csd-editor-tool" data-command="italic" style="width: 100%; height: 100%;">\n <i class="fa-solid fa-italic" style="pointer-events: none;"></i>\n </button>\n <button class="csd-editor-tool" data-command="underline" style="width: 100%; height: 100%;">\n <i class="fa-solid fa-underline" style="pointer-events: none;"></i>\n </button>\n <button class="csd-editor-tool" data-command="textColor" style="width: 100%; height: 100%;">\n <i class="fa-solid fa-palette" style="pointer-events: none;"></i>\n </button>\n ');var r=$CSD('\n <div class="csd-editor-toolbar-dropdown">\n <button class="csd-editor-tool" style="width: 100%; height: 100%;">\n <i class="fa-solid fa-align-left" style="pointer-events: none;"></i>\n </button>\n <div class="csd-editor-toolbar-dropdown-menu">\n <button data-command="justifyLeft" style="width: 100%;"><i class="fa-solid fa-align-left" style="pointer-events: none;"></i></button>\n <button data-command="justifyCenter" style="width: 100%;"><i class="fa-solid fa-align-center" style="pointer-events: none;"></i></button>\n <button data-command="justifyRight" style="width: 100%;"><i class="fa-solid fa-align-right" style="pointer-events: none;"></i></button>\n </div>\n </div>\n '),s=$CSD('\n <div class="csd-editor-toolbar-dropdown">\n <button class="csd-editor-tool" style="width: 100%; height: 100%;">\n <i class="fa-solid fa-text-height" style="pointer-events: none;"></i>\n </button>\n <div class="csd-editor-toolbar-dropdown-menu">\n <button data-command="fontSize" data-value="1" style="width: 100%;">Small</button>\n <button data-command="fontSize" data-value="3" style="width: 100%;">Normal</button>\n <button data-command="fontSize" data-value="5" style="width: 100%;">Large</button>\n <button data-command="fontSize" data-value="7" style="width: 100%;">Huge</button>\n </div>\n </div>\n '),c=$CSD('\n <div class="csd-editor-toolbar-dropdown">\n <button class="csd-editor-tool" style="width: 100%; height: 100%;">\n <i class="fa-solid fa-ellipsis" style="pointer-events: none;"></i>\n </button>\n <div class="csd-editor-toolbar-dropdown-menu">\n <button data-command="strikethrough" style="width: 100%;"><i class="fa-solid fa-strikethrough" style="pointer-events: none;"></i> Strikethrough</button>\n <button data-command="subscript" style="width: 100%;"><i class="fa-solid fa-subscript" style="pointer-events: none;"></i> Subscript</button>\n <button data-command="superscript" style="width: 100%;"><i class="fa-solid fa-superscript" style="pointer-events: none;"></i> Superscript</button>\n <button data-command="indent" style="width: 100%;"><i class="fa-solid fa-indent" style="pointer-events: none;"></i> Indent</button>\n <button data-command="outdent" style="width: 100%;"><i class="fa-solid fa-outdent" style="pointer-events: none;"></i> Outdent</button>\n </div>\n </div>\n ');return a.append(i),a.append(r),a.append(s),a.append(c),e.append(t),e.append(a),e}();return $CSD('<div class="csd-editor-toolbars"></div>').append(e).append(t)}(),i=$CSD('<div class="csd-editor-content" contenteditable="true"></div>');i.attr("placeholder",t.attr("placeholder")||"");var r=$CSD('\n <div class="csd-editor-statusbar">\n <div class="csd-editor-wordcount">Words: 0</div>\n <div class="csd-editor-charcount">Characters: 0</div>\n </div>\n ');t.before(o),t.before(a),t.before(i),t.after(r),t.hide(),i.html(t.val()),function(e){var t,n=e.closest(".csd-editor-container"),o=n.find(".csd-editor-toolbar-mobile").find(".csd-editor-toolbar-mobile-bottom"),a=n.find(".csd-editor-toolbar-mobile-top"),i=!1;function r(){if("undefined"!=typeof window){var e=window.visualViewport;if(!e)return;var t=Math.max(0,window.innerHeight-e.height),r=window.visualViewport.offsetTop||0;if(document.documentElement.style.setProperty("--keyboard-height","".concat(t,"px")),t>0){n.addClass("keyboard-open"),o.addClass("keyboard-open");var s=n.find(".csd-editor-toolbar-mobile-top");o.css({position:"fixed",bottom:"".concat(t,"px"),transform:"translateY(".concat(r,"px)"),zIndex:1050}),s.css({position:"fixed",top:0,left:0,right:0,transform:"translateY(".concat(r,"px)"),zIndex:1050})}else i||(n.removeClass("keyboard-open"),o.removeClass("keyboard-open"),o.css({position:"fixed",bottom:0,transform:"none",zIndex:1050}),a.css({position:"fixed",top:0,left:0,right:0,transform:"none",zIndex:1050}))}}"undefined"!=typeof window&&window.visualViewport&&(window.visualViewport.addEventListener("resize",r),window.visualViewport.addEventListener("scroll",(function(){a.css("opacity","0"),a.css("pointer-events","none"),o.css("opacity","0"),o.css("pointer-events","none"),t&&clearTimeout(t),t=setTimeout((function(){a.css("opacity","1"),a.css("pointer-events","auto"),o.css("opacity","1"),o.css("pointer-events","auto"),r()}),150)}))),o.on("mousedown touchstart",".csd-editor-tool",(function(e){i=!0,e.preventDefault()})),o.on("mouseup touchend",".csd-editor-tool",(function(){setTimeout((function(){i=!1,e.focus()}),100)})),e.on("focus",(function(){r();var t=e[0].getBoundingClientRect();if("undefined"!=typeof window){var n=window.visualViewport?window.visualViewport.height:window.innerHeight;t.bottom>n&&window.scrollTo({top:window.pageYOffset+(t.bottom-n)+100,behavior:"smooth"})}})),e.on("blur",(function(e){i||$CSD(e.target).closest(".csd-color-picker").length?e.preventDefault():(document.documentElement.style.setProperty("--keyboard-height","0px"),n.removeClass("keyboard-open"),o.removeClass("keyboard-open"),o.css({position:"fixed",bottom:0,transform:"none",opacity:"1",pointerEvents:"auto"}))})),r()}(i),function(e,t){var n=e.closest(".csd-editor-container");e.on("input",(function(){t.val(e.html()),t.trigger("change"),y(n)})),n.on("click",".csd-editor-tool",(function(t){t.preventDefault();$CSD(this).data("tool");g(this,e)})),n.on("click",".csd-editor-menu-item button",(function(t){t.preventDefault(),function(e,t){switch(e){case"new":confirm("Create new document? All changes will be lost.")&&t.html("");break;case"open":var n=document.createElement("input");n.type="file",n.accept=".txt,.html,.md",n.onchange=function(e){var n=e.target.files[0];if(n){var o=new FileReader;o.onload=function(e){t.html(e.target.result)},o.readAsText(n)}},n.click();break;case"save":var o=t.html();if("undefined"!=typeof window){var a=new Blob([o],{type:"text/html"}),i=window.URL.createObjectURL(a),r=document.createElement("a");r.href=i,r.download="document.html",r.click(),window.URL.revokeObjectURL(i)}break;case"export-pdf":alert("PDF export functionality requires a PDF generation library. Please implement based on your needs.");break;case"export-word":var s=t.html();if("undefined"!=typeof window){var c=new Blob([s],{type:"application/msword"}),l=window.URL.createObjectURL(c),d=document.createElement("a");d.href=l,d.download="document.doc",d.click(),window.URL.revokeObjectURL(l)}}}($CSD(this).data("action"),e)})),y(n),e.on("paste",(function(e){e.preventDefault();var t=e.originalEvent.clipboardData||("undefined"!=typeof window?window.clipboardData:null),n=t?t.getData("text/html")||t.getData("text"):"",o=document.createElement("div");o.innerHTML=n;var a,i=h(o.getElementsByTagName("*"));try{for(i.s();!(a=i.n()).done;){for(var r=a.value,s=["font-weight","font-style","text-decoration","text-align"],c=r.style,l=c.length-1;l>=0;l--){var d=c[l];s.includes(d)||c.removeProperty(d)}r.removeAttribute("class"),r.removeAttribute("id")}}catch(e){i.e(e)}finally{i.f()}document.execCommand("insertHTML",!1,o.innerHTML)}))}(i,t),a.find(".csd-editor-toolbar-dropdown > button").on("touchend",(function(e){e.preventDefault(),e.stopPropagation();var t=$CSD(this).closest(".csd-editor-toolbar-dropdown");t.toggleClass("active"),a.find(".csd-editor-toolbar-dropdown.active").not(t).removeClass("active")})),$CSD(document).on("touchend",(function(e){$CSD(e.target).closest(".csd-editor-toolbar-dropdown").length||a.find(".csd-editor-toolbar-dropdown.active").removeClass("active")})),a.find(".csd-editor-toolbar-dropdown-menu button").on("touchend",(function(e){e.preventDefault(),e.stopPropagation();var t=$CSD(this).data("command"),n=$CSD(this).data("value");t&&(g({command:t,value:n},i),$CSD(this).closest(".csd-editor-toolbar-dropdown").removeClass("active"),t.startsWith("justify")&&$CSD(this).closest(".csd-editor-toolbar-dropdown").find("button i").attr("class",$CSD(this).find("i").attr("class")))})),a.find(".csd-editor-tool").on("touchend",(function(e){var n,o;e.preventDefault(),e.stopPropagation(),n=e.target,o=$CSD(n).data("command"),$CSD(n).data("value"),o&&(t[0].focus({preventScroll:!0}),g(n,i),["bold","italic","underline"].includes(o)&&$CSD(n).toggleClass("active"))})),i.on("selectionchange",(function(){!function(e){["bold","italic","underline"].forEach((function(t){var n=document.queryCommandState(t);e.find('[data-command="'.concat(t,'"]')).toggleClass("active",n)}))}(a)})),function(e){function t(){var t=e.html();if(t){var n=t.split(/\n|<br\/?>/).map((function(e){return(e=e.trim()).match(/^#\s/)?"<h1>".concat(e.replace(/^#\s/,""),"</h1>"):e.match(/^##\s/)?"<h2>".concat(e.replace(/^##\s/,""),"</h2>"):e.match(/^###\s/)?"<h3>".concat(e.replace(/^###\s/,""),"</h3>"):e.match(/^[\*\-]\s/)?"<ul><li>".concat(e.replace(/^[\*\-]\s/,""),"</li></ul>"):e.match(/^1\.\s/)?"<ol><li>".concat(e.replace(/^1\.\s/,""),"</li></ol>"):e.match(/^>\s/)?"<blockquote>".concat(e.replace(/^>\s/,""),"</blockquote>"):e.match(/^```/)?"<pre><code>":(e=(e=(e=(e=e.replace(/\*\*([^\*]+)\*\*/g,"<strong>$1</strong>")).replace(/\*([^\*]+)\*/g,"<em>$1</em>")).replace(/`([^`]+)`/g,"<code>$1</code>")).replace(/\[([^\]]+)\]\(([^\)]+)\)/g,'<a href="$2">$1</a>'))?"<p>".concat(e,"</p>"):"<p><br></p>"}));e.html(n.join(""))}}t(),e.on("keydown",(function(e){if("Enter"===e.key){if("undefined"==typeof window)return;if("undefined"==typeof window)return;var t=window.getSelection();if(!t||!t.rangeCount)return;var n=t.anchorNode.textContent;if(n&&n.match(/^#\s/))e.preventDefault(),document.execCommand("formatBlock",!1,"h1"),document.execCommand("delete",!1),document.execCommand("delete",!1);else if(n.match(/^##\s/))e.preventDefault(),document.execCommand("formatBlock",!1,"h2"),document.execCommand("delete",!1),document.execCommand("delete",!1),document.execCommand("delete",!1);else if(n.match(/^###\s/))e.preventDefault(),document.execCommand("formatBlock",!1,"h3"),document.execCommand("delete",!1),document.execCommand("delete",!1),document.execCommand("delete",!1),document.execCommand("delete",!1);else if(n.match(/^[\*\-]\s/))e.preventDefault(),document.execCommand("insertUnorderedList",!1),document.execCommand("delete",!1),document.execCommand("delete",!1);els