nodality
Version:
A lightweight library for declarative UI elements.
2 lines • 22.7 kB
JavaScript
/*! For license information please see free.esm.js.LICENSE.txt */
function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,s,i,a=[],l=!0,c=!1;try{if(s=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=s.call(r)).done)&&(a.push(n.value),a.length!==e);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(c)throw o}}return a}}(t,e)||n(t,e)||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 r(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=n(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var o=0,s=function(){};return{s,n:function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function(t){throw t},f:s}}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,a=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(l)throw i}}}}function n(t,e){if(t){if("string"==typeof t)return o(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function s(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,i(n.key),n)}}function i(e){var r=function(e){if("object"!=t(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=t(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==t(r)?r:r+""}var a=function(){return t=function t(){var e,r,n,o=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e=this,n=function(t){if(console.log("LOBJO IS"),console.log(t),t.transform||t.op&&t.op.transform){var e=t.transform;t.transform||(e=t.op.transform),e.duration||(e.duration="3s-ease-in-out"),o.setDefault=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0px";return 0===t.length?e+" ":t};var r=function(){var r="",n="",s="",i="",a="",l="",c="",u="",f="";if(0!==e.values.length){e.values.forEach((function(t){t.startsWith("tx:")&&(r=t.replace("tx:","")),t.startsWith("ty:")&&(n=t.replace("ty:","")),t.startsWith("tz:")?s=t.replace("tz:",""):t.startsWith("scale(")?i=t:t.startsWith("skew(")?a=t:t.startsWith("rotate(")?l=function(t){var e=t.match(/rotate\(([^)]+)\)/);if(!e)return t;var r=e[1].split(",").map((function(t){return t.trim()}));return 1===r.length?"rotate(".concat(r[0],")"):2===r.length?"rotateX(".concat(r[0],") rotateY(").concat(r[1],")"):3===r.length?"rotateX(".concat(r[0],") rotateY(").concat(r[1],") rotate(").concat(r[2],")"):t}(t):t.startsWith("perspective(")?c=t:t.startsWith("matrix(")?u=t:t.startsWith("opacity:")&&(f=t.replace("opacity:",""))})),r=o.setDefault(r),n=o.setDefault(n),s=o.setDefault(s);var p="";if("0px"!=n&&"0px"!=r&&"0px"!=s?p+="translate3d(".concat(r,", ").concat(n,", ").concat(s,")"):"0px"==n&&"0px"==r||(p+="translate(".concat(r,", ").concat(n,")")),i&&(p+=" ".concat(i)),l&&(p+=" ".concat(l)),a&&(p+=" ".concat(a)),c&&(p+=" ".concat(c)),u&&(p+=" ".concat(u)),p){if(t.op.transform.duration){var y=t.op.transform.duration.replace(/^(\d+)(s)-/,(function(t,e,r){return e/2+r+" "})),h="transform ".concat(y,", opacity ").concat(y);o.res.style.transition=h}else o.res.style.transition="transform 3s ease-in-out, opacity 3s ease-in-out";t.op.transform.static&&(o.res.style.transition=""),(o.blastTarget||o.res).style.transform=p,o.res.style.opacity=f}else alert("OPE")}};e.on?o.res.addEventListener(e.on,(function(){e.delay?setTimeout((function(){r()}),e.delay):r()})):window.addEventListener("load",(function(){e.delay?setTimeout((function(){r()}),e.delay):r()}));var n=function(){var t="";e.values.forEach((function(e){e.startsWith("tx:")?t+="translateX(0) ":e.startsWith("ty:")?t+="translateY(0) ":e.startsWith("tz:")?t+="translateZ(0) ":e.startsWith("scale(")?t+="scale(1) ":e.startsWith("skew(")?t+="skew(0, 0) ":e.startsWith("rotate(")?t+="rotate(0) ":e.startsWith("perspective(")?t+="perspective(0) ":e.startsWith("matrix(")&&(t+="matrix(1, 0, 0, 1, 0, 0) "),o.res.style.opacity="1"})),t&&(o.res.style.transform=t.trim())};if(e.on)o.res.addEventListener("mouseout",(function(){e.keep||n()}));else{var s=1e3*parseFloat(e.duration),i=e.closeAfter?e.closeAfter:0;setTimeout((function(){e.keep||n()}),s/2+i)}e.hardCSS&&(o.res.style.transform=e.hardCSS)}else alert("THIS FIRE WITH GRADIENT (invalid block"),console.log("INVALID BLOCKA"),console.log(t)},(r=i(r="reactOnTransform"))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,this.state={isExpanded:!1,isMovedUp:!1,isMovedDown:!1}},n=[{key:"keySet",value:function(t){return this.temporaryVal=1,this.res.style[t.key]=t.value,this}},{key:"onScroll",value:function(t){var e=this;"opacity"===t.value?this.res.style.opacity=t.valMin:"scale"===t.value&&(this.res.style.transform="scale(".concat(t.valMax,")")),window.addEventListener("scroll",(function(){var r=e.smartRange(window.scrollY,{min:t.from,max:t.to},{min:t.valMin,max:t.valMax});"opacity"===t.value?e.res.style.opacity=r:"scale"===t.value&&(e.res.style.transform="scale(".concat(r,")"))}))}},{key:"setAny",value:function(t){this[Object.keys(t)[0]]=[Object.values(t)[0]]}},{key:"setID",value:function(t){this.id=t}},{key:"setPrevText",value:function(t){this.prevText=t}},{key:"getCSS",value:function(){return this.css}},{key:"getPX",value:function(t){return{xs:"0px",sm:"576px",md:"768px",lg:"992px",xl:"1200px",xxl:"1400px",mxxl:"1800px"}[t]||"Invalid breakpoint"}},{key:"respad",value:function(t){var e=this,r=function(){e.pad(t[0].values);for(var r=0;r<t.length;r++){var n=t[r].breakpoint;window.matchMedia("(min-width: ".concat(e.getPX(n))).matches&&e.pad(t[r].values)}};window.addEventListener("resize",r),r()}},{key:"resmar",value:function(t){var e=this,r=function(){e.mar(t[0].values);for(var r=0;r<t.length;r++){var n=t[r].breakpoint;window.matchMedia("(max-width: ".concat(e.getPX(n))).matches&&e.mar(t[r].values)}};window.addEventListener("resize",r),r()}},{key:"resprop",value:function(t){var e=this;console.log("RES STYLE"),console.log(t),this.prevStyles={};for(var r=0;r<this.res.style.length;r++){var n=this.res.style[r];this.prevStyles[n]=this.res.style[n],console.log("kio")}var o=function(){for(var r in e.prevStyles)e.res.style[r]=e.prevStyles[r];console.log("mkio");for(var n=0;n<t.length;n++){var o=t[n].breakpoint,s="(max-width: ".concat(o,")");if(console.log("testing media query:",s,window.matchMedia(s).matches),window.matchMedia(s).matches)for(var i in t[n])"breakpoint"!==i&&(console.log("ukio"),e.res.style[i]=t[n][i])}};window.addEventListener("resize",o),o()}},{key:"isNumber",value:function(t){return"number"==typeof t&&!isNaN(t)}},{key:"pad",value:function(t){for(var e=0;e<t.length;e++)for(var r=Object.keys(t[e]),n=0;n<r.length;n++)for(var o=r[n],s=t[e][o],i=0;i<o.length;i++)switch(o[i]){case"a":this.res.style.padding=this.isNumber(s)?"".concat(s,"px"):s;break;case"t":this.res.style.paddingTop=this.isNumber(s)?"".concat(s,"px"):s;break;case"l":this.res.style.paddingLeft=this.isNumber(s)?"".concat(s,"px"):s;break;case"r":this.res.style.paddingRight=this.isNumber(s)?"".concat(s,"px"):s;break;case"b":this.res.style.paddingBottom=this.isNumber(s)?"".concat(s,"px"):s}return this}},{key:"as",value:function(t){return this.res.style.alignSelf=t,this}},{key:"mar",value:function(t){for(var e=0;e<t.length;e++)for(var r=Object.keys(t[e]),n=0;n<r.length;n++)for(var o=r[n],s=t[e][o],i=0;i<o.length;i++){switch(o[i]){case"a":this.res.style.margin=this.isNumber(s)?"".concat(s,"px"):s;break;case"t":this.res.style.marginTop=this.isNumber(s)?"".concat(s,"px"):s;break;case"l":this.res.style.marginLeft=this.isNumber(s)?"".concat(s,"px"):s;break;case"r":this.res.style.marginRight=this.isNumber(s)?"".concat(s,"px"):s;break;case"b":this.res.style.marginBottom=this.isNumber(s)?"".concat(s,"px"):s}"auto"===o[i]&&(this.res.style.marginLeft="auto",this.res.style.marginRight="auto")}return this}},{key:"smartRange",value:function(t,e,r){t<e.min&&(t=e.min),t>e.max&&(t=e.max);var n=(t-e.min)/(e.max-e.min);e.min>e.max&&(n=(t-e.max)/(e.min-e.max));var o=(r.min-r.max)*n-r.min;if(o=Math.abs(o),r.min<r.max){var s=(r.max+Math.abs(r.min))*n;o=r.min+s}return o}},{key:"gpos",value:function(t){return this.res.style.gridColumn=t.col,this.res.style.gridRow=t.row,this}},{key:"fluidCopy",value:function(t){if(t instanceof Object){this.prevStylex=this.res.style,this.res=document.createElement("h1"),this.res.style.cssText=this.prevStylex.cssText;var e=document.createTextNode(this.text);return this.res.appendChild(e),this.res.style.fontSize=t.exact,this}if("S1"===t){this.prevStylex=this.res.style,this.res=document.createElement("h1"),this.res.style.cssText=this.prevStylex.cssText;var r=document.createTextNode(this.text);this.res.appendChild(r),this.res.style.fontSize="calc(1.625rem + 5.075vw)"}if("S2"===t){this.prevStylex=this.res.style,this.res=document.createElement("h2"),this.res.style.cssText=this.prevStylex.cssText;var n=document.createTextNode(this.text);this.res.appendChild(n),this.res.style.fontSize="calc(1.500rem + 4.3vw)"}if("S3"===t){this.prevStylex=this.res.style,this.res=document.createElement("h3"),this.res.style.cssText=this.prevStylex.cssText;var o=document.createTextNode(this.text);this.res.appendChild(o),this.res.style.fontSize="calc(1.375rem + 3.525vw)"}if("S4"===t){this.prevStylex=this.res.style,this.res=document.createElement("h4"),this.res.style.cssText=this.prevStylex.cssText;var s=document.createTextNode(this.text);this.res.appendChild(s),this.res.style.fontSize="calc(1.250rem + 2.75vw)"}if("S5"===t){this.prevStylex=this.res.style,this.res=document.createElement("h5"),this.res.style.cssText=this.prevStylex.cssText;var i=document.createTextNode(this.text);this.res.appendChild(i),this.res.style.fontSize="calc(1.125rem + 1.975vw)"}return"S6"===t&&(this.res.style.fontSize="calc(1rem + 0.5vw)"),this}},{key:"setIndex",value:function(t){this.index=t}},{key:"borderObj",value:function(t){var e,r=null!==(e=t.type)&&void 0!==e?e:"solid";return this.res.style.border="".concat(t.width," ").concat(r," ").concat(t.color),this.res.style.borderRadius=t.radius,this}},{key:"setPref",value:function(t){this.preffersId=t}},{key:"setClass",value:function(t){this.class=t}},{key:"setTags",value:function(t){this.openTag=t.open,this.closeTag=t.close,console.log("TAGS SET"),console.log(t)}},{key:"chainReact",value:function(t,n,o){var s=this;console.log("0P"),this.ap=!1,this.cta=0,this.once=!1;var i,a=r(t);try{for(a.s();!(i=a.n()).done;){var l=i.value;l.range||(l.range=["0px","999999px"])}}catch(t){a.e(t)}finally{a.f()}t.sort((function(t,e){return parseInt(t.range[0])-parseInt(e.range[0])}));var c=function(i){var a=window.visualViewport.width,l=[],c=[];s.resCopy=s.res,s.storedQueries=t.map((function(t){return t.target})).filter((function(t){return null!=t}));var u,f=r(t);try{for(f.s();!(u=f.n()).done;){var p=u.value;s.counterIndex++;var y=e(p.range,2),h=y[0],d=y[1],m=parseInt(h),v=parseInt(d),g=!0;if(p.target){g=!1;for(var b=0;b<p.target.length;b++)p.target[b]===n&&(g=!0)}a>=m&&a<=v&&g&&(l.push(p.log),c.push(p),p.op&&p.op.margin&&(s.useMargin=p.op.margin))}}catch(t){f.e(t)}finally{f.f()}if(o&&!o.includes("background")&&(s.res.style.background="",s.res.style.backgroundColor=""),s.res.style.textShadow="",o&&!o.includes("border")&&(s.res.style.border=""),o&&!o.includes("margin")&&(s.res.style.margin=""),s.res.style["-webkit-text-fill-color"]="",s.res.style["-webkit-text-stroke-color"]="",s.res.style["-webkit-text-stroke-width"]="",s.res.style.filter="",s.options.background&&(console.log(s.options.background),s.res.style.background=s.options.background),l.includes("gradient"),(l.includes("gradient")||l.includes("shadow"))&&(s.res.style.position="relative"),l.includes("blast")){var x,w=c.filter((function(t){return"blast"===t.log}))[0].op.color,k=null!==(x=c.filter((function(t){return"blast"===t.log}))[0].op.width)&&void 0!==x?x:"1px";"FlexRowLayoutElement"===s.getType()||"LayoutWrapperElement"===s.getType()?(s.res.style.border="".concat("number"==typeof k?k+"px":k," solid orange"),s.res.style.display="inline-block","FlexRowLayoutElement"===s.getType()&&(s.res.style.display="flex"),s.res.style.boxSizing="border-box",s.res.style.transformOrigin="center",s.blastTarget=s.res):(s.text&&(s.res.textContent=s.text),s.res.style["-webkit-text-fill-color"]="transparent",s.res.style["-webkit-text-stroke-color"]=w,s.res.style["-webkit-text-stroke-width"]="".concat(k))}if(l.includes("filter")){var S=c.filter((function(t){return"filter"===t.log}))[0].op.filter;s.res.style.filter=S}if(l.includes("background")&&(s.res.style.backgroundColor="green"),l.includes("gradient")&&("LayoutWrapperElement"!==s.getType()&&"FlexRowLayoutElement"!==s.getType()&&(s.res.style["-webkit-text-fill-color"]="transparent"),s.res.style.background=s.globalGradient,"LayoutWrapperElement"!==s.getType()&&"FlexRowLayoutElement"!==s.getType()&&(s.res.style["background-clip"]="text")),l.includes("shadow")){var T,E="",O=0;for(b=0;b<s.options.shadow.op.steps;b++){var C;E+="drop-shadow(".concat(O+=3,"px ").concat(O,"px ").concat(O,"px ").concat(null!==(C=s.options.shadow.color)&&void 0!==C?C:"gray",") ")}"FlexRowLayoutElement"===s.getType()||"LayoutWrapperElement"===s.getType()?s.res.style.boxShadow="".concat(O,"px ").concat(O,"px ").concat(O,"px ").concat(null!==(T=s.options.shadow.color)&&void 0!==T?T:"gray"):s.res.style.filter=E}if(l.includes("margin"))for(b=0;b<t.length;b++)if(t[b].op){var A=t[b].op.offsets;A&&void 0!==s.index&&(s.res.style.margin=A[Number(s.index)]+"px")}if(l.includes("spana")||l.includes("span")){if(s.res=s.resCopy,s.options.span){var j;for(j=Array.isArray(s.options.span)?s.options.span.filter((function(t){return"span"===t.op.name}))[0]:s.options.span,s.res.textContent="",b=0;b<j.op.parts.length;b++){var L=j.op.parts[b].style,I=new s.constructor(j.op.parts[b].text).setup({type:"span"}).set(L).render();s.res.appendChild(I)}}}else{var R=new s.constructor(s.prevText).set({}).render();s.prevText&&s.prevText.length>0&&i&&s.res.appendChild(R)}if(l.includes("animation")){if(s.options.animation&&!s.hasAnimated&&!s.options.animation.op.fireAt){console.warn(s.openTag),s.hasAnimated=!0;var P=s.options.animation.op;window.addEventListener("sidebar:open",(function(){s.res.animate(P.keyframesOpen,P.openOptions)})),window.addEventListener("sidebar:closed",(function(){s.res.animate(P.keyframesClose,P.closeOptions)})),s.res.animate(P.keyframesClose,{duration:0,fill:"forwards"}),s.openTag&&s.closeTag&&(window.addEventListener(s.openTag,(function(){s.res.animate(P.keyframesOpen,P.openOptions)})),window.addEventListener(s.closeTag,(function(){s.res.animate(P.keyframesClose,P.closeOptions)})))}if(s.options.animation&&s.options.animation.op.fireAt&&s.options.animation.op.fireAt.endsWith("px")){var W=s.options.animation.op;s.res.animate(W.keyframesClose,{duration:0,fill:"forwards"});var M=function(){window.scrollY>parseFloat(W.fireAt)&&(s.res.animate(W.keyframesOpen,W.openOptions),window.removeEventListener("scroll",M))};window.addEventListener("scroll",M)}if(s.options.animation&&s.options.animation.op.fireAt&&"inview"===s.options.animation.op.fireAt){var N=s.options.animation.op;s.res.animate(N.keyframesClose,{duration:0,fill:"forwards"}),new IntersectionObserver((function(t,e){t.forEach((function(t){t.isIntersecting&&(s.res.animate(N.keyframesOpen,N.openOptions),e.disconnect())}))})).observe(s.res)}}};this.options.animation||window.addEventListener("resize",(function(){return c()})),c()}},{key:"maxWidth",value:function(t){return this.res.style.maxWidth=t,this}},{key:"removeQuotesFromFirstWord",value:function(t){return t.replace(/"([^"]+)":/g,"$1:")}},{key:"arrayMargin",value:function(t,e){return t.includes("left")&&(this.res.style.marginLeft=e),t.includes("right")&&(this.res.style.marginRight=e),t.includes("top")&&(this.res.style.marginTop=e),t.includes("bottom")&&(this.res.style.marginBottom=e),t.includes("all")&&(this.res.style.margin=e),e||(this.res.style.marginBottom=t),this}}],n&&s(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n}();function l(t){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},l(t)}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function u(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,f(n.key),n)}}function f(t){var e=function(t){if("object"!=l(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=l(r))return r;throw new TypeError("@ must return a primitive value.")}return String(t)}(t);return"symbol"==l(e)?e:e+""}function p(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(p=function(){return!!t})()}function y(t){return y=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},y(t)}function h(t,e){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},h(t,e)}var d=function(){function t(){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),(e=function(t,e,r){return e=y(e),function(t,e){if(e&&("object"==l(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,p()?Reflect.construct(e,r||[],y(t).constructor):e.apply(t,r))}(this,t)).res=document.createElement("div"),e.res.style.display="grid",e.attributes={},e}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&h(t,e)}(t,a),e=t,r=[{key:"set",value:function(t){return this.options=t,this.attributes=t,this.templateCols=t.templateCols,t.templateCols&&(this.res.style.gridTemplateColumns="repeat(".concat(t.templateCols.cols,", 1fr)"),this.res.style.gridTemplateRows="repeat(".concat(t.templateCols.cols,", 1fr)")),this.res.style.height=t.height?t.height:"600px",t.positions&&(this.storedPositions=t.positions),this}},{key:"generateGridPositions",value:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:30,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:50,o=document.createElement("div");o.classList.add("container"),o.style.display="grid",o.style.gridTemplateColumns="repeat(".concat(n,", 1fr)"),o.style.gridTemplateRows="repeat(".concat(r,", 1fr)"),o.style.width="100%",o.style.height="100vh";var s=t.map((function(t,e){return{row:Math.floor(r/2)+e,col:Math.floor(n/2)+e}}));return t.forEach((function(o,i){var a=s[i],l=a.row,c=a.col,u=function(e){var r=0,n=0;return t.forEach((function(t,o){var i=t.weight,a=t.direction,l=s[e],c=s[o],u=l.col-c.col,f=l.row-c.row,p=i*(1/(Math.sqrt(u*u+f*f)+1));switch(a){case"L":r-=p;break;case"R":r+=p;break;case"U":n-=p;break;case"B":n+=p}})),{forceX:r,forceY:n}}(i),f=u.forceX,p=u.forceY;c=Math.max(1,Math.min(n,c+Math.round(f))),l=Math.max(1,Math.min(r,l+Math.round(p))),console.log(e.items.map((function(t){return t.id}))),console.log(o.attract.slice(1));var y=e.items.filter((function(t){return t.id===o.attract.slice(1)}))[0].render();console.log(y),y.style.gridRowStart=l,y.style.gridColumnStart=c,y.style.display="flex",y.style.alignItems="center",y.style.justifyContent="center",y.style.fontWeight="bold",e.res.appendChild(y)})),console.log("ARAO"),console.log(this.res.children.length),this}},{key:"add",value:function(t){this.items=t;var e,r=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return c(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 s,i=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return i=t.done,t},e:function(t){a=!0,s=t},f:function(){try{i||null==r.return||r.return()}finally{if(a)throw s}}}}(t);try{for(r.s();!(e=r.n()).done;){var n=e.value;this.res.appendChild(n.render())}}catch(t){r.e(t)}finally{r.f()}return this.storedPositions&&this.generateGridPositions(this.storedPositions),console.log("MORAA"),console.log(this.res.children.length),this}},{key:"toCode",value:function(){if(this.excludeFromCodeTrue)return[""];var t=JSON.stringify(this.options,null,4).replace(/"([^"]+)":/g,"$1:"),e="";return e+=".add([\n",e+=this.items.map((function(t){return t.toCode().join("").trim()})).join(",\n"),e+="\n])",["new Free().set(".concat(t,")").concat(e)]}},{key:"render",value:function(t){if(console.log("CHILDREN IN RENDER"),console.log(this.res.children.length),!t)return this.res;document.querySelector(t).appendChild(this.res)}}],r&&u(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r}();export{d as Free};