From ada8aef58624dff4181e789f8039b2c94e1c54da Mon Sep 17 00:00:00 2001 From: Yuan Chuan Date: Thu, 19 May 2022 08:43:52 +0800 Subject: [PATCH] 0.27.4 (#90) * 0.27.3 * Put the `seed` argument at the end * 0.27.4 --- CHANGELOG.md | 14 ++++++++++++++ css-doodle.js | 28 +++++++++++++++++++++++----- css-doodle.min.js | 2 +- package.json | 2 +- src/function.js | 4 ++-- 5 files changed, 41 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a0032d..4106684 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +## 0.27.4 + +* Put the `seed` argument at the end. + + +## 0.27.3 + +* Add shorthand for frequently used svg filter (#88) +* Skip empty group argument (#87) + +

+ + + ## 0.27.2 * Add `t` variable to represent `u_time` in pattern (#85) diff --git a/css-doodle.js b/css-doodle.js index fd7e0ea..9b9dfe0 100644 --- a/css-doodle.js +++ b/css-doodle.js @@ -1,4 +1,4 @@ -/*! css-doodle@0.27.2 */ +/*! css-doodle@0.27.4 */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : @@ -812,10 +812,9 @@ if (arg.length) { if (!group.length) { group.push(Tokens.text(get_text_value(arg))); - } else { + } else if (/\S/.test(arg)) { group.push(Tokens.text(arg)); } - if (arg.startsWith('±') && !doodle) { let raw = arg.substr(1); let cloned = clone(group); @@ -838,7 +837,6 @@ } arg += c; } - if (composition && (it.curr(1) == ')' || !/[0-9a-zA-Z_\-.]/.test(it.curr())) && !stack.length) { if (group.length) { args.push(normalize_argument(group)); @@ -3133,8 +3131,28 @@ }), filter: lazy((...args) => { - let value = args.map(input => get_value(input())).join(','); + let values = args.map(input => get_value(input())); + let value = values.join(','); let id = unique_id('filter-'); + // shorthand + if (values.every(n => /^[\d.]/.test(n))) { + let [fq = 1, scale = 1, octave, seed] = values; + let [bx, by = bx] = parse$4(fq); + octave = octave ? `numOctaves: ${octave};` : ''; + seed = seed ? `seed: ${seed};` : ''; + value = ` + feTurbulence { + type: fractalNoise; + baseFrequency: ${bx} ${by}; + ${octave} ${seed} + } + feDisplacementMap { + in: SourceGraphic; + scale: ${scale}; + } + `; + } + // new svg syntax if (!value.startsWith('<')) { let parsed = parse$2(value, { type: 'block', diff --git a/css-doodle.min.js b/css-doodle.min.js index b2f91e9..3a6aaaa 100644 --- a/css-doodle.min.js +++ b/css-doodle.min.js @@ -1 +1 @@ -/*! css-doodle@0.27.2 */!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).CSSDoodle={})}(this,(function(e){"use strict";const t=[":",";",",","(",")","[","]","{","}","\u03c0","\xb1","+","-","*","/","%",'"',"'","`","@"],n={escape:e=>"\\"==e,space:e=>/[\r\n\t\s]/.test(e),digit:e=>/^[0-9]$/.test(e),sign:e=>/^[+-]$/.test(e),dot:e=>"."==e,quote:e=>/^["'`]$/.test(e),symbol:e=>t.includes(e),hexNum:e=>/^[0-9a-f]$/i.test(e),hex:(e,t,r)=>"0"==e&&n.letter(t,"x")&&n.hexNum(r),expWithSign:(e,t,r)=>n.letter(e,"e")&&n.sign(t)&&n.digit(r),exp:(e,t)=>n.letter(e,"e")&&n.digit(t),dots:(e,t)=>n.dot(e)&&n.dot(t),letter:(e,t)=>String(e).toLowerCase()==String(t).toLowerCase(),comment:(e,t)=>"/"==e&&"*"==t,inlineComment:(e,t)=>"/"==e&&"/"===t,selfClosedTag:(e,t)=>"/"==e&&">"==t,closedTag:(e,t)=>"<"==e&&"/"==t};class r{constructor({type:e,value:t,pos:n,status:r}){this.type=e,this.value=t,this.pos=n,r&&(this.status=r)}isSymbol(...e){let t="Symbol"==this.type;return e.length?e.some((e=>e===this.value)):t}isSpace(){return"Space"==this.type}isNumber(){return"Number"==this.type}isWord(){return"Word"==this.type}}function i(e){let t=-1,n=e.length,r=-1,i=0;return{curr:(n=0)=>e[t+n],next(n=1){let s=e[t+=n];return"\n"===s?(i++,r=0):r+=n,s},end:()=>t>=n,get:()=>({prev:e[t-1],curr:e[t+0],next:e[t+1],next2:e[t+2],next3:e[t+3],pos:[r,i]})}}function s(e){for(;e.next();){let{curr:t,prev:r}=e.get();if(n.comment(t,r))break}}function o(e){for(;e.next()&&"\n"!==e.curr(););}function l(e){return[":",";",",","{","}","(",")","[","]"].includes(e)}function a(e){let t="";for(;!e.end();){let{curr:r,next:i}=e.get();t+=r;let s=n.symbol(i)||n.space(i)||n.digit(i);if(t.length&&s&&!n.closedTag(r,i))break;e.next()}return t.trim()}function u(e){let t="";for(;!e.end();){let{curr:r,next:i}=e.get();if(t+=r,!n.space(i))break;e.next()}return t}function c(e){let t="",r=!1;for(;!e.end();){let{curr:i,next:s,next2:o,next3:l}=e.get();if(t+=i,r&&n.dot(s))break;if(n.dot(i)&&(r=!0),n.dots(s,o))break;if(n.expWithSign(s,o,l))t+=e.next()+e.next();else if(n.exp(s,o))t+=e.next();else if(!n.digit(s)&&!n.dot(s))break;e.next()}return t}function h(e){let t="0x";for(e.next(2);!e.end();){let{curr:r,next:i}=e.get();if(t+=r,!n.hexNum(i))break;e.next()}return t}function p(e){return e[e.length-1]}function f(e,t={}){let f=i(String(e).trim()),m=[],d=[];for(;f.next();){let{prev:e,curr:i,next:g,next2:v,pos:y}=f.get();if(n.comment(i,g))s(f);else if(t.ignoreInlineComment&&n.inlineComment(i,g))o(f);else if(n.hex(i,g,v)){let e=h(f);m.push(new r({type:"Number",value:e,pos:y}))}else if(n.digit(i)||n.digit(g)&&n.dot(i)&&!n.dots(e,i)){let e=c(f);m.push(new r({type:"Number",value:e,pos:y}))}else if(n.symbol(i)&&!n.selfClosedTag(i,g)){let e=p(m),t=n.digit(g)||n.dot(g)&&n.digit(v);if("-"===i&&t&&(!e||!e.isNumber())){let e=c(f);m.push(new r({type:"Number",value:e,pos:y}));continue}let s={type:"Symbol",value:i,pos:y};if(d.length&&n.escape(e.value)){m.pop();let e=a(f);e.length&&m.push(new r({type:"Word",value:e,pos:y}))}else{if(n.quote(i)){p(d)==i?(d.pop(),s.status="close"):(d.push(i),s.status="open")}m.push(new r(s))}}else if(n.space(i)){let e=u(f),n=p(m),{next:s}=f.get();if(!d.length&&n){let r=n.value,o=l(r)&&")"!==r,a=l(s)&&"("!==s;if(o||a)continue;e=t.preserveLineBreak?i:" "}m.length&&s&&s.trim()&&m.push(new r({type:"Space",value:e,pos:y}))}else{let e=a(f);e.length&&m.push(new r({type:"Word",value:e,pos:y}))}}let g=p(m);return g&&g.isSpace()&&(m.length=m.length-1),m}function m(e){let t=[];for(;e.next();){let{curr:n,next:r}=e.get();if("var"===n.value){if(r&&r.isSymbol("(")){e.next();let n=d(e);v(n.name)&&t.push(n)}}else if(t.length&&!n.isSymbol(","))break}return t}function d(e){let t={},n=[];for(;e.next();){let{curr:r,next:i}=e.get();if(r.isSymbol(")",";")&&!t.name){t.name=g(n);break}r.isSymbol(",")?(void 0===t.name&&(t.name=g(n),n=[]),t.name&&(t.fallback=m(e))):n.push(r)}return t}function g(e){return e.map((e=>e.value)).join("")}function v(e){return void 0!==e&&(!(e.length<=2)&&(!e.substr(2).startsWith("-")&&!!e.startsWith("--")))}function y(e,t,n){return e=Number(e)||0,Math.max(t,Math.min(n,e))}function x(e,t,n){let r=0,i=e,s=e=>e>0&&e<1?.1:1,o=arguments.length;1==o&&([e,t]=[s(e),e]),o<3&&(n=s(e));let l=[];for(;(n>=0&&e<=t||n<0&&e>t)&&(l.push(e),e+=n,!(r++>=1e3)););return l.length||l.push(i),l}function b(e,t){for(let[n,r]of Object.entries(t))e[n]=e[r];return e}function _(e){return/^[a-zA-Z]$/.test(e)}function w(e){return null==e}function k(e){return w(e)||Number.isNaN(e)}function $(e){return w(e)||""===e}function S(e){let t=()=>e;return t.lazy=!0,t}function j(e,t,n){return"c-"+e+"-"+t+"-"+n}function E(e){let t=e;for(;t&&!w(t.value);)t=t.value;return w(t)?"":t}function T(e,t,n=0){let r=new Image;r.crossOrigin="anonymous",r.src=e,r.onload=function(){setTimeout(t,n)}}function A(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function R(e){let t=document.createElement("textarea");return t.innerHTML=e,t.value}function z(e,t=0){let n=3735928559^t,r=1103547991^t;for(let t,i=0;i>>16,2246822507)^Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}function P(e){return(t,...n)=>{let r=t.reduce(((e,t,r)=>{return e+t+(w(i=n[r])?"":i);var i}),"");return e(r)}}function C(){let e=0;return(t="")=>`${t}-${++e}`}function N(e,t,n){return t+e*(n-t)}function M(e=""){return e+Math.random().toString(32).substr(2)}function L(e){return Array.isArray(e)?e:[e]}function I(e,t="\n"){return(e||[]).join(t)}function O(e,t=1){return w(e)?"":e[e.length-t]}function W(e){return e[0]}function U(e,t){return Array.prototype.flatMap?e.flatMap(t):e.reduce(((e,n)=>e.concat(t(n))),[])}const D={func:(e="")=>({type:"func",name:e,arguments:[]}),argument:()=>({type:"argument",value:[]}),text:(e="")=>({type:"text",value:e}),pseudo:(e="")=>({type:"pseudo",selector:e,styles:[]}),cond:(e="")=>({type:"cond",name:e,styles:[],arguments:[]}),rule:(e="")=>({type:"rule",property:e,value:[]}),keyframes:(e="")=>({type:"keyframes",name:e,steps:[]}),step:(e="")=>({type:"step",name:e,styles:[]})},B={white_space:e=>/[\s\n\t]/.test(e),line_break:e=>/\n/.test(e),number:e=>!isNaN(e),pair:e=>['"',"(",")","'"].includes(e),pair_of:(e,t)=>({'"':'"',"'":"'","(":")"}[e]==t)},F={\u03c0:Math.PI,"\u220f":Math.PI};function X(e){return["@canvas","@shaders","@doodle"].includes(e)}function H(e,{col:t,line:n}){console.warn(`(at line ${n}, column ${t}) ${e}`)}function q(e){return function(t,n){let r=t.index(),i="";for(;!t.end();){let n=t.next();if(e(n))break;i+=n}return n&&t.index(r),i}}function Y(e,t){return q((e=>/[^\w@]/.test(e)))(e,t)}function V(e){return q((e=>/[\s\{]/.test(e)))(e)}function Z(e,t){return q((e=>B.line_break(e)||"{"==e))(e,t)}function G(e,t){let n,r=D.step();for(;!e.end()&&"}"!=(n=e.curr());)if(B.white_space(n))e.next();else{if(r.name.length){if(r.styles.push(ue(e,t)),"}"==e.curr())break}else r.name=oe(e);e.next()}return r}function K(e,t){const n=[];let r;for(;!e.end()&&"}"!=(r=e.curr());)B.white_space(r)||n.push(G(e,t)),e.next();return n}function J(e,t){let n,r=D.keyframes();for(;!e.end()&&"}"!=(n=e.curr());)if(r.name.length){if("{"==n||"{"==e.curr(-1)){e.next(),r.steps=K(e,t);break}e.next()}else if(Y(e),r.name=V(e),!r.name.length){H("missing keyframes name",e.info());break}return r}function Q(e,t={}){for(e.next();!e.end();){let n=e.curr();if(t.inline){if("\n"==n)break}else if("*"==(n=e.curr())&&"/"==e.curr(1))break;e.next()}t.inline||(e.next(),e.next())}function ee(e){for(e.next();!e.end();){if(">"==e.curr())break;e.next()}}function te(e){let t,n="";for(;!e.end()&&":"!=(t=e.curr());)B.white_space(t)||(n+=t),e.next();return n}function ne(e,t,n){let r,i=[],s=[],o=[],l="";for(;!e.end();){if(r=e.curr(),/[\('"`]/.test(r)&&"\\"!==e.curr(-1))o.length&&"("!=r&&r===O(o)?o.pop():o.push(r),l+=r;else if("@"!=r||n)if(n&&/[)]/.test(r)||!n&&/[,)]/.test(r))if(o.length)")"==r&&o.pop(),l+=r;else{if(l.length&&(s.length?s.push(D.text(l)):s.push(D.text((u=l).trim().length?B.number(+u)?+u:u.trim():u)),l.startsWith("\xb1")&&!n)){let e=l.substr(1),t=(a=s,JSON.parse(JSON.stringify(a)));O(t).value="-"+e,i.push(re(t)),O(s).value=e}if(i.push(re(s)),[s,l]=[[],""],")"==r)break}else F[r]&&!/[0-9]/.test(e.curr(-1))&&(r=F[r]),l+=r;else s.length||(l=l.trimLeft()),l.length&&(s.push(D.text(l)),l=""),s.push(ie(e));if(!(!t||")"!=e.curr(1)&&/[0-9a-zA-Z_\-.]/.test(e.curr())||o.length)){s.length&&i.push(re(s));break}e.next()}var a,u;return function(e){let t=O(e[0]);t&&"text"===t.type&&!String(t.value).trim().length&&(e[0]=e[0].slice(0,-1));return e}(i)}function re(e){let t=e.map((e=>{if("text"==e.type&&"string"==typeof e.value){let t=String(e.value);t.includes("`")&&(e.value=t=t.replace(/`/g,'"')),e.value=t}return e})),n=W(t)||{},r=O(t)||{};if("text"==n.type&&"text"==r.type){let e=W(n.value),i=O(r.value);"string"==typeof n.value&&"string"==typeof r.value&&B.pair_of(e,i)&&(n.value=n.value.slice(1),r.value=r.value.slice(0,r.value.length-1),t.cluster=!0)}return t}function ie(e){let t,n=D.func(),r="@",i=!1;for(e.next();!e.end();){t=e.curr();let s="."==t&&"@"==e.curr(1),o=e.curr(1);if("("==t||s){i=!0,e.next(),n.arguments=ne(e,s,X(r));break}if(!i&&"("!==o&&!/[0-9a-zA-Z_\-.]/.test(o)){r+=t;break}r+=t,e.next()}let{fname:s,extra:o}=function(e){let t="",n="";if(/\D$/.test(e)&&!/\d+x\d+/.test(e)||Math[e.substr(1)])return{fname:e,extra:n};for(let r=e.length-1;r>=0;r--){let i=e[r],s=e[r-1],o=e[r+1];if(!(/[\d.]/.test(i)||"x"==i&&/\d/.test(s)&&/\d/.test(o))){t=e.substring(0,r+1);break}n=i+n}return{fname:t,extra:n}}(r);return n.name=s,o.length&&n.arguments.unshift([{type:"text",value:o}]),n.position=e.info().index,n}function se(e){let t,n=D.text(),r=0,i=!0;const s=[],o=[];for(s[r]=[];!e.end();)if(t=e.curr(),i&&B.white_space(t))e.next();else{if(i=!1,"\n"!=t||B.white_space(e.curr(-1)))if(","!=t||o.length){if(/[;}<]/.test(t)){n.value.length&&(s[r].push(n),n=D.text());break}"@"==t?(n.value.length&&(s[r].push(n),n=D.text()),s[r].push(ie(e))):B.white_space(t)&&B.white_space(e.curr(-1))||("("==t&&o.push(t),")"==t&&o.pop(),F[t]&&!/[0-9]/.test(e.curr(-1))&&(t=F[t]),n.value+=t)}else n.value.length&&(s[r].push(n),n=D.text()),s[++r]=[],i=!0;else n.value+=" ";e.next()}return n.value.length&&s[r].push(n),s}function oe(e){let t,n="";for(;!e.end()&&"{"!=(t=e.curr());)B.white_space(t)||(n+=t),e.next();return n}function le(e){let t,n={name:"",arguments:[]};for(;!e.end();){if("("==(t=e.curr()))e.next(),n.arguments=ne(e);else{if(/[){]/.test(t))break;B.white_space(t)||(n.name+=t)}e.next()}return n}function ae(e,t){let n,r=D.pseudo();for(;!e.end();){if(n=e.curr(),"/"==n&&"*"==e.curr(1))Q(e);else{if("}"==n)break;if(B.white_space(n)){e.next();continue}if(r.selector){let n=ue(e,t);if("@use"==n.property?r.styles=r.styles.concat(n.value):r.styles.push(n),"}"==e.curr())break}else r.selector=oe(e)}e.next()}return r}function ue(e,t){let n,r=D.rule();for(;!e.end();){if(n=e.curr(),"/"==n&&"*"==e.curr(1))Q(e);else{if(";"==n)break;if(r.property.length){r.value=se(e);break}if(r.property=te(e),"@use"==r.property){r.value=fe(e,t);break}}e.next()}return r}function ce(e,t){let n,r=D.cond();for(;!e.end();){if(n=e.curr(),"/"==n&&"*"==e.curr(1))Q(e);else{if("}"==n)break;if(r.name.length)if(":"==n){let t=ae(e);t.selector&&r.styles.push(t)}else if("@"!=n||Z(e,!0).includes(":")){if(!B.white_space(n)){let n=ue(e,t);if(n.property&&r.styles.push(n),"}"==e.curr())break}}else r.styles.push(ce(e));else Object.assign(r,le(e))}e.next()}return r}function he(e,t){let n="";return e&&e.get_variable&&(n=e.get_variable(t)),n}function pe(e,t){e.forEach&&e.forEach((e=>{if("text"==e.type&&e.value){let n=m(i(f(e.value)));e.value=n.reduce(((e,n)=>{let r,i="",s="";i=he(t,n.name),!i&&n.fallback&&n.fallback.every((e=>{if(s=he(t,e.name),s)return i=s,!1}));try{r=me(i,t)}catch(e){}return r&&e.push.apply(e,r),e}),[])}"func"==e.type&&e.arguments&&e.arguments.forEach((e=>{pe(e,t)}))}))}function fe(e,t){return e.next(),(se(e)||[]).reduce(((e,n)=>{pe(n,t);let[r]=n;return r.value&&r.value.length&&e.push(...r.value),e}),[])}function me(e,t){const n=function(e=""){let t=0,n=1,r=1;return{curr:(n=0)=>e[t+n],end:()=>e.length<=t,info:()=>({index:t,col:n,line:r}),index:e=>void 0===e?t:t=e,next(){let i=e[t++];return"\n"==i?(r++,n=0):n++,i}}}(e),r=[];for(;!n.end();){let e=n.curr();if(B.white_space(e))n.next();else{if("/"==e&&"*"==n.curr(1))Q(n);else if(":"==e){let e=ae(n,t);e.selector&&r.push(e)}else if("@"==e&&"@keyframes"===Y(n,!0)){let e=J(n,t);r.push(e)}else if("@"!=e||Z(n,!0).includes(":")){if("<"==e)ee(n);else if(!B.white_space(e)){let e=ue(n,t);e.property&&r.push(e)}}else{let e=ce(n,t);e.name.length&&r.push(e)}n.next()}}return r}const[de,ge,ve]=[1,256,65536];function ye(e){let[t,n,r]=(e+"").replace(/\s+/g,"").replace(/[,\uff0cxX]+/g,"x").split("x").map((e=>parseInt(e)));const i=1==t||1==n?ve:ge,s=1==t&&1==n?ve:de,o={x:y(t||de,1,i),y:y(n||t||de,1,i),z:y(r||de,1,s)};return Object.assign({},o,{count:o.x*o.y*o.z,ratio:o.x/o.y})}function xe(e){return/^texture\w*$|^(fragment|vertex)$/.test(e)}function be(){return new r({type:"LineBreak",value:"\n"})}function _e(e){let t=e[0],n=e[e.length-1];for(;t&&t.isSymbol("(")&&n&&n.isSymbol(")");)t=(e=e.slice(1,e.length-1))[0],n=e[e.length-1];return e}function we(e){return _e(e).map((e=>e.value)).join("")}function ke(e,t){return`url("data:image/svg+xml;utf8,${encodeURIComponent(e)+(t?`#${t}`:"")}")`}function $e(e){const t='xmlns="http://www.w3.org/2000/svg"',n='xmlns:xlink="http://www.w3.org/1999/xlink"';return e.includes("${e}`),e.includes("xmlns")||(e=e.replace(/])/,`e.attrs.id===t&&e.name===n))}append(e){this.isTextNode()||this.body.push(e)}merge(e){for(let[t,n]of Object.entries(e.attrs))this.attrs[t]=n;Array.isArray(e.body)&&this.body.push(...e.body)}attr(e,t){if(!this.isTextNode())return void 0===t?this.attrs[e]:this.attrs[e]=t}toString(){if(this.isTextNode())return this.body;let e=[""],t=[];for(let[t,n]of Object.entries(this.attrs))e.push(`${t}="${n}"`);for(let e of this.body)t.push(e.toString());return`<${this.name}${e.join(" ")}>${t.join("")}`}}function Ee(e,t){return`${e}:${t};`}function Te(e){const t=e.value.map((e=>"block"===e.type?Te(e):Ee(e.name,e.value))).join("");return`${e.name}{${t}}`}function Ae(e,t,n,r){let i;if(t||(t=new je("root")),"block"===e.type)if("style"===e.name){if(Array.isArray(e.value)){let n=new je("style"),r=[];for(let t of e.value)"block"===t.type&&r.push(Te(t));n.append(r.join("")),t.append(n)}}else{let n=new je(e.name);r||(r=n).attr("xmlns","http://www.w3.org/2000/svg");for(let t of e.value){let s=Ae(t,n,e,r);s&&(i=s)}if(e.inline){let t=e.value.find((e=>"statement"===e.type&&"id"===e.name));t?i=t.value:(i=Se(e.name),n.attr("id",i))}let s=r.find(n);s?s.merge(n):t.append(n)}if("statement"===e.type){if(n&&/^(text|tspan|textPath)$/i.test(n.name)&&"content"===e.name){let n=new je("text-node",e.value);t.append(n)}else if(e.name.startsWith("style ")){let n=(e.name.split("style ")[1]||"").trim();if(n.length){let r=t.attr("style")||"";t.attr("style",r+Ee(n,e.value))}}else{let n=e.value;if(n&&"block"===n.type){let t=Ae(e.value,r,e,r);n=`url(#${t})`,"xlink:href"!==e.name&&"href"!==e.name||(n=`#${t}`)}t.attr(e.name,n),e.name.includes("xlink:")&&r.attr("xmlns:xlink","http://www.w3.org/1999/xlink")}}return n?i:r.toString()}function Re(e){return Ae(e)}function ze(e){let t=i(f(e)),n={},r=!1;for(;t.next();){let{prev:e,curr:i,next:s}=t.get(),o=r&&(i.isWord()||i.isSymbol())&&e&&e.isNumber()&&!s;if(i.isNumber())n.value=Number(i.value),r=!0;else{if(!o)break;n.unit=i.value}}return n}function Pe(e){return(...t)=>{let n=[],r=[];for(let e of t){let{unit:t,value:i}=ze(e);void 0!==t&&n.push(t),void 0!==i&&r.push(i)}let i=e(...r),s=n.find((e=>void 0!==e));return void 0===s?i:Array.isArray(i)?i.map((e=>e+s)):i+s}}function Ce(e){return(...t)=>{let n=t.map((e=>String(e).charCodeAt(0))),r=e(...n);return Array.isArray(r)?r.map((e=>String.fromCharCode(e))):String.fromCharCode(r)}}const Ne={\u03c0:Math.PI,gcd:(e,t)=>{for(;t;)[e,t]=[t,e%t];return e}},Me={"^":7,"*":6,"/":6,"\xf7":6,"%":6,"&":5,"|":5,"+":4,"-":4,"<":3,"<<":3,">":3,">>":3,"=":3,"==":3,"\u2264":3,"<=":3,"\u2265":3,">=":3,"\u2260":3,"!=":3,"\u2227":2,"&&":2,"\u2228":2,"||":2,"(":1,")":1};function Le(e,t,n=[]){let r=[];for(;e.length;){let{name:s,value:o,type:l}=e.shift();if("variable"===l){let e=t[o];k(e)&&(e=Math[o]),k(e)&&(e=We(o,t)),k(e)&&/^\-\D/.test(o)&&(e=We("-1"+o.substr(1),t)),void 0===e&&(e=0),"number"!=typeof e&&(n.push(e),(i=n)[0]==i[2]&&i[1]==i[3]?(e=0,n=[]):e=Le(Ie(e),t,n)),r.push(e)}else if("function"===l){let e=!1;/^\-/.test(s)&&(e=!0,s=s.substr(1));let n,i=o.map((e=>Le(e,t))),l=s.split(".");for(;n=l.pop();){if(!n)continue;let e=t[n]||Math[n];i="function"==typeof e?Array.isArray(i)?e(...i):e(i):0}e&&(i*=-1),r.push(i)}else if(/\d+/.test(o))r.push(o);else{let e=r.pop(),t=r.pop();r.push(Oe(o,Number(t),Number(e)))}}var i;return Number(r[0])||0}function Ie(e){let t=function(e){let t=String(e),n=[],r="";for(let e=0;e=]$/.test(s.value))s.value+=i;else if(/^[|&<>]$/.test(i)&&s&&s.value==i)s.value+=i;else if("-"==i&&"e"==t[e-1])r+=i;else if(n.length||r.length||!/[+-]/.test(i)){let{type:e,value:t}=s||{};"operator"==e&&!r.length&&/[^()]/.test(i)&&/[^()]/.test(t)?r+=i:(r.length&&(n.push({type:"number",value:r}),r=""),n.push({type:"operator",value:i}))}else r+=i}else/\S/.test(i)&&(","==i?(n.push({type:"number",value:r}),r="",n.push({type:"comma",value:i})):"!"==i?(n.push({type:"number",value:r}),n.push({type:"operator",value:i}),r=""):r+=i)}return r.length&&n.push({type:"number",value:r}),n}(e);const n=[],r=[];for(let e=0;e=Me[s];){let e=n.pop();/[()]/.test(e)||r.push({type:"operator",value:e})}n.push(s)}}for(;n.length;)r.push({type:"operator",value:n.pop()});return r}function Oe(e,t,n){switch(e){case"+":return t+n;case"-":return t-n;case"*":return t*n;case"%":return t%n;case"|":return t|n;case"&":return t&n;case"<":return t":return t>n;case"^":return Math.pow(t,n);case"\xf7":case"/":return t/n;case"=":case"==":return t==n;case"\u2264":case"<=":return t<=n;case"\u2265":case">=":return t>=n;case"\u2260":case"!=":return t!=n;case"\u2227":case"&&":return t&&n;case"\u2228":case"||":return t||n;case"<<":return t<>":return t>>n}}function We(e,t){let[n,r,i]=e.match(/([\d.\-]+)(.*)/)||[],s=t[i];return void 0===s?s:"number"==typeof s?Number(r)*s:r*Le(Ie(s),t)}function Ue(e,t){return Le(Ie(e),Object.assign({},Ne,t))}var De=new class{constructor(){this.cache={}}clear(){this.cache={}}set(e,t){if(w(e))return"";let n=this.getKey(e);return this.cache[n]=t}get(e){let t=this.getKey(e);return this.cache[t]}getKey(e){return z("string"==typeof e?e:JSON.stringify(e))}};function Be(e,t){return(...n)=>{let r=e+n.join("-");return De.get(r)||De.set(r,t(...n))}}function Fe(e,t){return{type:e,value:t}}const Xe=Be("build_range",(e=>{let t=function(e){let t=String(e),n=[],r=[];if(!t.startsWith("[")||!t.endsWith("]"))return n;for(let e=1;e{if("char"==e)return t;let[n,r]=t,i=!1;n>r&&([n,r]=[r,n],i=!0);let s=Ce(x)(n,r);return i&&s.reverse(),s}))}));function He(e){return(...t)=>e(...U(t,(e=>String(e).startsWith("[")?Xe(e):e)))}class qe{constructor(e){this.prev=this.next=null,this.data=e}}class Ye{constructor(e=20){this._limit=e,this._size=0}push(e){this._size>=this._limit&&(this.root=this.root.next,this.root.prev=null);let t=new qe(e);this.root?(t.prev=this.tail,this.tail.next=t,this.tail=t):this.root=this.tail=t,this._size++}last(e=1){let t=this.tail;for(;--e&&t.prev;)t=t.prev;return t.data}}class Ve{constructor(e){var t;this.p=(t=e([151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180]),[].concat(t,t))}grad(e,t,n,r){let i=15&e,s=i<8?t:n,o=i<4?n:12==i||14==i?t:r;return(0==(1&i)?s:-s)+(0==(2&i)?o:-o)}noise(e,t,n){let{p:r,grad:i}=this,[s,o,l]=[e,t,n].map((e=>255&Math.floor(e)));[e,t,n]=[e,t,n].map((e=>e-Math.floor(e)));let[a,u,c]=[e,t,n].map((e=>e*e*e*(e*(6*e-15)+10))),h=r[s]+o,p=r[h]+l,f=r[h+1]+l,m=r[s+1]+o,d=r[m]+l,g=r[m+1]+l;return N(c,N(u,N(a,i(r[p],e,t,n),i(r[d],e-1,t,n)),N(a,i(r[f],e,t-1,n),i(r[g],e-1,t-1,n))),N(u,N(a,i(r[p+1],e,t,n-1),i(r[d+1],e-1,t,n-1)),N(a,i(r[f+1],e,t-1,n-1),i(r[g+1],e-1,t-1,n-1))))}}function Ze(e){let t,n=i(f(e)),r={},s=[],o=!1;for(;n.next();){let{prev:e,curr:i,next:l}=n.get();if(i.isSymbol(":")&&!t)t=Ke(s),s=[];else if(i.isSymbol(";")&&t)r[t]=Ge(t,Ke(s),o),s=[],t=null,o=!1;else if(!i.isSymbol(";")){let n=e&&e.isSymbol("-"),r=l&&l.isSymbol("-"),a=i.isSymbol("-");t||s.length||!a||n||r||l&&l.isSymbol(":")?s.push(i):o=!0}}return s.length&&t&&(r[t]=Ge(t,Ke(s),o)),r}function Ge(e,t,n){return["fill-rule","fill"].includes(e)?t:n?`-1 * (${t})`:t}function Ke(e){return e.map((e=>e.value)).join("")}function Je(e,t){let n=[],r=[],s=[],o=[];if($(e))return n;let l=i(f(e));for(;l.next();){let{prev:e,curr:i,next:u}=l.get();i.isSymbol("(")&&s.push(i.value),i.isSymbol(")")&&s.pop(),"open"===i.status&&o.push(i.value),"close"===i.status&&o.pop(),a=i,!(t?a.isSymbol(","):a.isSymbol(",")||a.isSpace())||s.length||o.length?r.push(i):(n.push(Qe(r)),r=[])}var a;return r.length&&n.push(Qe(r)),n}function Qe(e){return e.map((e=>e.value)).join("")}const et=["auto","reverse"],tt=["deg","rad","grad","turn"];function nt(e){let t=i(f(e)),n=!1,r="",s={direction:"",angle:""};for(;t.next();){let{prev:e,curr:i,next:o}=t.get();if(i.isWord()&&et.includes(i.value))s.direction=i.value,n=!0;else if(i.isNumber())s.angle=Number(i.value),n=!0;else if(i.isWord()&&e&&e.isNumber()&&tt.includes(i.value))r=i.value;else if(i.isSpace()&&""!==s.direction&&""!==s.angle)break}return n||(s.direction="auto"),function(e,t){let{angle:n}=e;""===n&&(n=0);"rad"===t&&(n/=Math.PI/180);"grad"===t&&(n*=.9);"turn"===t&&(n*=360);return Object.assign({},e,{angle:n})}(s,r)}const{cos:rt,sin:it,abs:st,atan2:ot,PI:lt}=Math,at=P((e=>ft(Ze(e),{min:3,max:3600}))),ut={circle:()=>at`split:180;scale:.99`,triangle:()=>at`rotate:30;scale:1.1;move:0 .2`,pentagon:()=>at`split:5;rotate:54`,hexagon:()=>at`split:6;rotate:30;scale:.98`,octagon:()=>at`split:8;rotat:22.5;scale:.99`,star:()=>at`split:10;r:cos(5t);rotate:-18;scale:.99`,infinity:()=>at`split:180;scale:.99;x:cos(t)*.99 / (sin(t)^2 + 1);y:x * sin(t)`,heart:()=>at`split:180;rotate:180;a:cos(t)*13/18 - cos(2t)*5/18;b:cos(3t)/18 + cos(4t)/18;x:(.75 * sin(t)^3) * 1.2;y:(a - b + .2) * -1.1`,bean:()=>at`split:180;r:sin(t)^3 + cos(t)^3;move:-.35 .35;`,bicorn:()=>at`split:180;x:cos(t);y:sin(t)^2 / (2 + sin(t)) - .5`,drop:()=>at`split:180;rotate:90;scale:.95;x:sin(t);y:(1 + sin(t)) * cos(t) / 1.6`,fish:()=>at`split:240;x:cos(t) - sin(t)^2 / sqrt(2) - .04;y:sin(2t)/2`,whale:()=>at`split:240;rotate:180;R:3.4 * (sin(t)^2 - .5) * cos(t);x:cos(t) * R + .75;y:sin(t) * R * 1.2`,windmill:()=>at`split:18;R:seq(.618, 1, 0);T:seq(t-.55, t, t);x:R * cos(T);y:R * sin(T)`,vase:()=>at`split:240;scale:.3;x:sin(4t) + sin(t) * 1.4;y:cos(t) + cos(t) * 4.8 + .3`,clover:(e=3)=>(4==(e=y(e,3,5))&&(e=2),at`split:240;r:cos(${e}t);scale:.98`),hypocycloid:(e=3)=>(e=y(e,3,5),at`split:240;scale:${[0,0,0,.34,.25,.19][e]};k:${e};x:(k-1)*cos(t) + cos((k-1)*t);y:(k-1)*sin(t) - sin((k-1)*t)`),bud:(e=3)=>(e=y(e,3,10),at`split:240;scale:.8;r:1 + .2 * cos(${e}t)`)};class ct{constructor(e,t,n){this.x=e,this.y=t,this.extra=n}valueOf(){return this.x+" "+this.y}toString(){return this.valueOf()}}function ht(e,t,n,r,i){let s=180*ot(t+r,e-n)/lt;return"reverse"===i.direction&&(s-=180),i.direction||(s=90),i.angle&&(s+=i.angle),s}function pt(e,t,n){let[r,i=r]=Je(n).map(Number);return[e*r,t*i]}function ft(e,{min:t,max:n}){let r=y(parseInt(e.vertices||e.points||e.split)||0,t,n),i=$(e.x)?"cos(t)":e.x,s=$(e.y)?"sin(t)":e.y,o=$(e.r)?"":e.r,{unit:l,value:a}=ze(o);return l&&!e[l]&&"t"!==l&&($(e.unit)&&(e.unit=l),o=e.r=a),e.degree&&(e.rotate=e.degree),e.origin&&(e.move=e.origin),function(e,t){"function"==typeof arguments[0]&&(t=e,e={}),t||(t=e=>[rt(e),it(e)]);let n,r,i=e.split||180,s=e.turn||1,o=e.frame,l=e.fill||e["fill-rule"],a=nt(e.direction||e.dir||""),u=e.unit,c=2*lt*s/i,h=[],p=void 0===e.scale?1:e.scale,f=([e,t,n=0,r=0])=>{if("evenodd"==e||"nonzero"==e)return h.push(new ct(e,"",""));let[i,s]=pt(e,-t,p),[o,l]=pt(n,-r,p),c=ht(i,s,o,l,a);void 0!==u&&"%"!==u?"none"!==u&&(i+=u,s+=u):(i=50*(i+1)+"%",s=50*(s+1)+"%"),h.push(new ct(i,s,c))};"nonzero"!=l&&"evenodd"!=l||f([l,"",""]);for(let e=0;e1&&(e*=2),0==e&&(e=.002);for(let n=0;n{let l=Object.assign({},e,{t,\u03b8:t,i:n+1,seq:(...e)=>e.length?e[n%e.length]:"",range:(e,t=0)=>((e=Number(e)||0)>(t=Number(t)||0)&&([e,t]=[t,e]),e+st(t-e)/(r-1)*n)}),a=Ue(i,l),u=Ue(s,l),c=0,h=0;if(o){let e=Ue(o,l);0==e&&(e=1e-5),a=e*rt(t),u=e*it(t)}return e.rotate&&([a,u]=function(e,t,n){let r=-lt/180*n;return[e*rt(r)-t*it(r),t*rt(r)+e*it(r)]}(a,u,Number(e.rotate)||0)),e.move&&([a,u,c,h]=function(e,t,n){let[r,i=r]=Je(n).map(Number);return[e+(r||0),t-(i||0),r,i]}(a,u,e.move)),[a,u,c,h]}))}function mt(e,t){let n,r=[],i=[];for(;e.next();){let{curr:t,next:s}=e.get(),o=!i.length&&(!s||t.isSymbol(";")||s.isSymbol("}"));if(t.isSymbol("'",'"')&&("open"===t.status?i.push(t):i.pop(),s.isSymbol("}")&&!i.length&&(o=!0)),!i.length&&t.isSymbol("{")){let t=xt(r,(e=>e.isSpace()));if(!t.length)continue;let i=t.pop(),s=bt(...t,i);for(n=yt(dt(e,{type:"block",name:i,inline:!0,value:[]}),s);i=t.pop();)n=yt({type:"block",name:i,value:[n]},s);break}if("open"==t.status&&1==i.length||"close"==t.status&&!i.length||r.push(t),o)break}return r.length&&!n?t.value=vt(r):n&&(t.value=n),t}function dt(e,t){let n=[],r=[],i=t&&t.type||"",s=[];for(;e.next();){let{prev:o,curr:l,next:a}=e.get(),u=!a||l.isSymbol("}");if(l.isSymbol("(")&&s.push(l.value),l.isSymbol(")")&&s.pop(),_t(i)&&u){if(!a&&n.length&&!l.isSymbol("}")){"string"==typeof n[n.length-1].value&&(n[n.length-1].value+=";"+l.value)}t.value=n;break}if(l.isSymbol("{")){let i=xt(r,(e=>e.isSpace()));if(!i.length)continue;bt(t.name)&&(i=[vt(r)]);let s=i.pop(),o=bt(...i,t.name,s),l=yt(dt(e,{type:"block",name:s,value:[]}),o);for(;s=i.pop();)l=yt({type:"block",name:s,value:[l]},o);n.push(l),r=[]}else if(l.isSymbol(":")&&!s.length&&!gt(o,a)&&r.length){let s=xt(r,(e=>e.isSymbol(","))),o=mt(e,{type:"statement",name:"unkown",value:""}),l=Je(o.value),a=s.length>1&&l.length===s.length;s.forEach(((e,t)=>{let r=Object.assign({},o,{name:e});a&&(r.value=l[t]),n.push(r)})),_t(i)&&(t.value=n),r=[]}else l.isSymbol(";")?n.length&&r.length&&(n[n.length-1].value+=";"+vt(r),r=[]):r.push(l)}return n.length&&_t(i)&&(t.value=n),i?t:n}function gt(e,t){let n=e&&e.value,r=t&&t.value;return["xlink:actuate","xlink:arcrole","xlink:href","xlink:role","xlink:show","xlink:title","xlink:type","xml:base","xml:lang","xml:space"].includes(n+":"+r)}function vt(e){return e.filter(((t,n)=>!t.isSymbol(";","}")||n!==e.length-1)).map((e=>e.value)).join("")}function yt(e,t){let n=e.name||"",[r,...i]=n.split(/#/),s=i[i.length-1];return r&&s&&!t&&(e.name=r,e.value.push({type:"statement",name:"id",value:s})),e}function xt(e,t){let n=[],r=[];return e.forEach((e=>{t(e)?(n.push(vt(r)),r=[]):r.push(e)})),r.length&&n.push(vt(r)),n}function bt(...e){return e.some((e=>"style"===e))}function _t(e){return"block"===e}function wt(e){let t=e&&e.value&&e.value[0];return t&&"svg"===t.name&&_t(t.type)?wt(t):e}function kt(e,t){return wt(dt(i(f(e)),t||{type:"block",name:"svg",value:[]}))}function $t(e){let t=i(f(e)),n={},r={commands:[],valid:!0};for(;t.next();){let{curr:e}=t.get();if(!e.isSpace()&&!e.isSymbol(","))if(e.isWord())n.name&&(r.commands.push(n),n={}),n.name=e.value,n.value=[],"MmLlHhVvCcSsQqTtAaZz".includes(e.value)?"mlhvcsqtaz".includes(e.value)?n.type="relative":n.type="absolute":(n.type="unknown",r.valid=!1);else if(n.value){let t=e.value;e.isNumber()&&(t=Number(e.value)),n.value.push(t)}else n.name||(r.valid=!1)}return n.name&&r.commands.push(n),r}const St={name:"cssd-uniform-time","animation-name":"cssd-uniform-time-animation","animation-duration":31536e6,"animation-iteration-count":"infinite","animation-delay":"0s","animation-direction":"normal","animation-fill-mode":"none","animation-play-state":"running","animation-timing-function":"linear"};St.animation=`\n ${St["animation-duration"]}ms\n ${St["animation-timing-function"]} ${St["animation-delay"]} ${St["animation-iteration-count"]} ${St["animation-name"]}`;const jt={name:"cssd-uniform-mousex"},Et={name:"cssd-uniform-mousey"},Tt={name:"cssd-uniform-width"},At={name:"cssd-uniform-height"};var Rt=Object.freeze({__proto__:null,uniform_time:St,uniform_mousex:jt,uniform_mousey:Et,uniform_width:Tt,uniform_height:At});function zt(e){return S(((t,...n)=>{if(!n||!t)return"";let r=E(t()),i=r;/\D/.test(r)&&(i=Ue(r),0===i&&(i=r));let s=Math.random();return function(e,t){let[n,r=1]=String(e).split("x");n=y(Math.ceil(n)||1,1,65536),r=y(Math.ceil(r)||1,1,65536);let i=n*r,s=[],o=1;for(let e=1;e<=r;++e)for(let l=1;l<=n;++l)s.push(t(o++,l,e,i,n,r));return s}(i,((...e)=>n.map((t=>E(t(...e,s)))).join(","))).join(e)}))}function Pt(e,t,n){return e[t]||(e[t]=new Ye),e[t].push(n),n}function Ct(e){return-1*e}const Nt=b({i:({count:e})=>t=>e,y:({y:e})=>t=>e,x:({x:e})=>t=>e,z:({z:e})=>t=>e,I:({grid:e})=>t=>e.count,Y:({grid:e})=>t=>e.y,X:({grid:e})=>t=>e.x,Z:({grid:e})=>t=>e.z,id:({x:e,y:t,z:n})=>r=>j(e,t,n),n({extra:e}){let t=O(e);return e=>t?t[0]+(Number(e)||0):"@n"},nx({extra:e}){let t=O(e);return e=>t?t[1]+(Number(e)||0):"@nx"},ny({extra:e}){let t=O(e);return e=>t?t[2]+(Number(e)||0):"@ny"},N({extra:e}){let t=O(e);return e=>t?t[3]+(Number(e)||0):"@N"},m:zt(","),M:zt(" "),\u00b5:zt(""),p:({context:e,pick:t})=>He(((...n)=>{n.length||(n=e.last_pick_args||[]);let r=t(n);return e.last_pick_args=n,Pt(e,"last_pick",r)})),P({context:e,pick:t,position:n}){let r="P-counter"+n;return He(((...n)=>{let i=!0;n.length||(n=e.last_pick_args||[],i=!1);let s=e.last_pick,o=s?s.last(1):"";if(i&&(e[r]||(e[r]={}),o=e[r].last_pick),n.length>1){let e=n.findIndex((e=>e===o));-1!==e&&n.splice(e,1)}let l=t(n);return e.last_pick_args=n,i&&(e[r].last_pick=l),Pt(e,"last_pick",l)}))},pn({context:e,extra:t,position:n}){let r=O(t),i="pn-counter"+n+(r?O(r):"");return He(((...t)=>{e[i]||(e[i]=0),e[i]+=1;let n=t.length,[s=e[i]]=r||[],o=t[(s-1)%n];return Pt(e,"last_pick",o)}))},pd({context:e,extra:t,position:n,shuffle:r}){let i=O(t),s=i?O(i):"",o="pd-counter"+n+s,l="pd-values"+n+s;return He(((...t)=>{e[o]||(e[o]=0),e[o]+=1,e[l]||(e[l]=r(t||[]));let n=t.length,[s=e[o]]=i||[],a=(s-1)%n,u=e[l][a];return Pt(e,"last_pick",u)}))},lp:({context:e})=>(t=1)=>{let n=e.last_pick;return n?n.last(t):""},r:({context:e,rand:t})=>(...n)=>{let r=(n.every(_)?Ce:Pe)(t)(...n);return Pt(e,"last_rand",r)},rn({x:e,y:t,context:n,position:r,grid:i,extra:s,shuffle:o}){let l="noise-2d"+r,[a,u,c,h,p,f]=O(s)||[],m=a&&h;return(...r)=>{let[s,a=s,h=1,d=1]=r;1==r.length&&([s,a]=[0,s]),n[l]||(n[l]=new Ve(o)),h=y(h,0,1/0),d=y(d,0,1/0);let g=[s,a].every(_)?Ce:Pe,v=m?n[l].noise((u-1)/p*h,(c-1)/f*h,0):n[l].noise((e-1)/i.x*h,(t-1)/i.y*h,0),x=g(((e,t)=>function(e,t,n,r=1){let i=Math.sqrt(.5)*r,[s,o]=[-i,i];return N((e-s)/(o-s),t*r,n*r)}(v*d,e,t,d))),b=x(s,a);return Pt(n,"last_rand",b)}},lr:({context:e})=>(t=1)=>{let n=e.last_rand;return n?n.last(t):""},noise({context:e,grid:t,position:n,shuffle:r,...i}){let s={i:i.count,I:t.count,x:i.x,X:t.x,y:i.y,Y:t.y,z:i.z,Z:t.z};return(t,i,o=0)=>{let l="raw-noise-2d"+n;return e[l]||(e[l]=new Ve(r)),e[l].noise(Ue(t,s),Ue(i,s),Ue(o,s))}},stripe:()=>(...e)=>{let t,n=e.map(E),r=n.length,i=0,s=[];if(!r)return"";n.forEach((e=>{let[t,n]=Je(e);void 0!==n?s.push(n):i+=1}));let o=s.length?`(100% - ${s.join(" - ")}) / ${i}`:`100% / ${r}`;return n.map(((e,n)=>{if(s.length){let[n,r]=Je(e);return t=(t?t+" + ":"")+(void 0!==r?r:o),`${n} 0 calc(${t})`}return`${e} 0 ${100/r*(n+1)}%`})).join(",")},calc:()=>e=>Ue(E(e)),hex:()=>e=>parseInt(E(e)).toString(16),svg:S(((...e)=>{let t=e.map((e=>E(e()))).join(",");if(!t.startsWith("<")){t=Re(kt(t))}return ke($e(t))})),filter:S(((...e)=>{let t=e.map((e=>E(e()))).join(","),n=M("filter-");if(!t.startsWith("<")){t=Re(kt(t,{type:"block",name:"filter"}))}return ke($e(t).replace(/])/,`e=>`var(${E(e)})`,ut:()=>e=>`var(--${St.name})`,uw:()=>e=>`var(--${Tt.name})`,uh:()=>e=>`var(--${At.name})`,ux:()=>e=>`var(--${jt.name})`,uy:()=>e=>`var(--${Et.name})`,plot({count:e,context:t,extra:n,position:r,grid:i}){let s="offset-points"+r,o=O(n);return n=>{let[r=e,l,a,u=i.count]=o||[];if(!t[s]){let e=Ze(n);delete e.fill,delete e["fill-rule"],delete e.frame,e.points=u,t[s]=ft(e,{min:1,max:65536})}return t[s][r-1]}},shape:()=>Be("shape-function",((e="",...t)=>{let n=[];if((e=String(e).trim()).length)if("function"==typeof ut[e])n=ut[e](t);else{let r=e,i=t.join(",");i.length&&(r=e+","+i),n=ft(Ze(r),{min:3,max:3600})}return`polygon(${n.join(",")})`})),doodle:()=>e=>e,shaders:()=>e=>e,canvas:()=>e=>e,pattern:()=>e=>e,invert:()=>e=>{let t=$t(e);return t.valid?t.commands.map((({name:e,value:t})=>{switch(e){case"v":return"h"+t.join(" ");case"V":return"H"+t.join(" ");case"h":return"v"+t.join(" ");case"H":return"V"+t.join(" ");default:return e+t.join(" ")}})).join(" "):e},flipH:()=>e=>{let t=$t(e);return t.valid?t.commands.map((({name:e,value:t})=>{switch(e){case"h":case"H":return e+t.map(Ct).join(" ");default:return e+t.join(" ")}})).join(" "):e},flipV:()=>e=>{let t=$t(e);return t.valid?t.commands.map((({name:e,value:t})=>{switch(e){case"v":case"V":return e+t.map(Ct).join(" ");default:return e+t.join(" ")}})).join(" "):e},flip(...e){let t=Nt.flipH(...e),n=Nt.flipV(...e);return e=>n(t(e))},reverse:(...e)=>e=>{let t=$t(e);return t.valid?t.commands.reverse().map((({name:e,value:t})=>e+t.join(" "))).join(" "):e}},{index:"i",col:"x",row:"y",depth:"z",rand:"r",pick:"p",stripes:"stripe",strip:"stripe",patern:"pattern",flipv:"flipV",fliph:"flipH",t:"ut","svg-filter":"filter","last-rand":"lr","last-pick":"lp",multiple:"m",multi:"m",rep:"\xb5",repeat:"\xb5",ms:"M",s:"I",size:"I",sx:"X","size-x":"X","size-col":"X","max-col":"X",sy:"Y","size-y":"Y","size-row":"Y","max-row":"Y",sz:"Z","size-z":"Z","size-depth":"Z","pick-by-turn":"pn","pick-n":"pn","pick-d":"pd",offset:"plot",Offset:"Plot",point:"plot",Point:"Plot",paint:"canvas"}),Mt={"4a0":[1682,2378],"2a0":[1189,1682],a0:[841,1189],a1:[594,841],a2:[420,594],a3:[297,420],a4:[210,297],a5:[148,210],a6:[105,148],a7:[74,105],a8:[52,74],a9:[37,52],a10:[26,37],b0:[1e3,1414],b1:[707,1e3],b2:[500,707],b3:[353,500],b4:[250,353],b5:[176,250],b6:[125,176],b7:[88,125],b8:[62,88],b9:[44,62],b10:[31,44],b11:[22,32],b12:[16,22],c0:[917,1297],c1:[648,917],c2:[458,648],c3:[324,458],c4:[229,324],c5:[162,229],c6:[114,162],c7:[81,114],c8:[57,81],c9:[40,57],c10:[28,40],c11:[22,32],c12:[16,22],d0:[764,1064],d1:[532,760],d2:[380,528],d3:[264,376],d4:[188,260],d5:[130,184],d6:[92,126],letter:[216,279],postcard:[100,148],poster:[390,540]},Lt={portrait:"p",pt:"p",p:"p",landscape:"l",ls:"l",l:"l"};let It=[];function Ot(e){if(!It.length){let e=new Set;if("undefined"!=typeof document)for(let t in document.head.style)t.startsWith("-")||e.add(t.replace(/[A-Z]/g,"-$&").toLowerCase());e.has("grid-gap")||e.add("grid-gap"),It=Array.from(e)}return e instanceof RegExp?It.filter((t=>e.test(t))):It}function Wt(e){let t=new RegExp(`\\-?${e}\\-?`);return Ot(t).map((e=>e.replace(t,""))).reduce(((e,t)=>(e[t]=t,e)),{})}const Ut=Wt("webkit"),Dt=Wt("moz");function Bt(e,t){return Ut[e]?`-webkit-${t} ${t}`:Dt[e]?`-moz-${t} ${t}`:t}const Ft={center:"50%",left:"0%",right:"100%",top:"50%",bottom:"50%"},Xt={center:"50%",top:"0%",bottom:"100%",left:"50%",right:"50%"};var Ht=b({size(e,{is_special_selector:t,grid:n}){let[r,i=r]=Je(e);Mt[r]&&([r,i]=function(e,t){e=String(e).toLowerCase();let[n,r]=Mt[e]||[];return"p"==Lt[t]&&([r,n]=[n,r]),[r,n].map((e=>e+"mm"))}(r,i));let s=`\n width:${r};height:${i};`;return t?"auto"!==r&&"auto"!==i||(s+=`aspect-ratio:${n.ratio};`):s+=`\n --internal-cell-width:${r};--internal-cell-height:${i};`,s},position(e,{extra:t}){let[n,r="50%"]=Je(e);n=Ft[n]||n,r=Xt[r]||r;const i="var(--internal-cell-width, 25%)",s="var(--internal-cell-height, 25%)";return`\n position:absolute;left:${n};top:${r};width:${i};height:${s};margin-left:calc(${i} / -2);margin-top:calc(${s} / -2);grid-area:unset;--plot-angle:${t||0};transform:rotate(${t||0}deg);`},grid(e,t){let[n,...r]=e.split("/").map((e=>e.trim()));return r=r.join(" / "),{grid:ye(n),size:r?this.size(r,t):""}},shape:Be("shape-property",(e=>{let[t,...n]=Je(e);if("function"!=typeof ut[t])return"";let r="clip-path";return Bt(r,`${r}:polygon(${ut[t](...n).join(",")});`)+"overflow:hidden;"})),use(e){if(e.length>2)return e}},{"place-cell":"position",offset:"position"});const qt={even:e=>!(e%2),odd:e=>!!(e%2)};function Yt(e,t,n){for(let r=0;r<=n;++r)if(Ue(e,{n:r})==t)return!0}var Vt={at:({x:e,y:t})=>(n,r)=>e==n&&t==r,nth:({count:e,grid:t})=>(...n)=>n.some((n=>qt[n]?qt[n](e):Yt(n,e,t.count))),row:({y:e,grid:t})=>(...n)=>n.some((n=>qt[n]?qt[n](e):Yt(n,e,t.y))),col:({x:e,grid:t})=>(...n)=>n.some((n=>qt[n]?qt[n](e):Yt(n,e,t.x))),even:({count:e,grid:t,x:n,y:r})=>e=>qt.odd(n+r),odd:({count:e,grid:t,x:n,y:r})=>e=>qt.even(n+r),random:({random:e,count:t,x:n,y:r,grid:i})=>(s=.5)=>/\D/.test(s)?e()s=>!!Ue("("+s+")",{x:n,X:t.x,y:r,Y:t.y,i:e,I:t.count,random:i})};function Zt(e){return/^\:(host|doodle)/.test(e)}function Gt(e){return/^\:(container|parent)/.test(e)}function Kt(e){return Zt(e)||Gt(e)}const Jt={};for(let e of Object.getOwnPropertyNames(Math))Jt[e]=()=>(...t)=>"number"==typeof Math[e]?Math[e]:(t=t.map((e=>Ue(E(e)))),Math[e](...t));class Qt{constructor(e){this.tokens=e,this.rules={},this.props={},this.keyframes={},this.grid=null,this.is_grid_defined=!1,this.coords=[],this.doodles={},this.canvas={},this.pattern={},this.shaders={},this.reset(),this.custom_properties={},this.uniforms={}}reset(){this.styles={host:"",container:"",cells:"",keyframes:""},this.coords=[],this.doodles={},this.canvas={},this.pattern={},this.shaders={};for(let e in this.rules)e.startsWith("#c")&&delete this.rules[e]}add_rule(e,t){let n=this.rules[e];n||(n=this.rules[e]=[]),n.push.apply(n,L(t))}pick_func(e){return Nt[e]||Jt[e]}apply_func(e,t,n){let r=e(...L(t)),i=[];return n.forEach((e=>{let t=typeof e.value,n="number"===t||"string"===t;if(!e.cluster&&n)i.push(...Je(e.value,!0));else if("function"==typeof e)i.push(e);else if(!w(e.value)){let t=E(e.value);i.push(t)}})),i=i.filter((e=>!w(e)&&String(e).trim().length)),r(...L(i))}compose_aname(...e){return e.join("-")}compose_selector({x:e,y:t,z:n},r=""){return`#${j(e,t,n)}${r}`}is_composable(e){return["doodle","shaders","canvas","pattern"].includes(e)}read_var(e,t){let n=t.count,r=this.custom_properties[n]||{};if(void 0!==r[e]){let t=String(r[e]).trim();if("("==t[0]){")"===t[t.length-1]&&(t=t.substring(1,t.length-1))}return t.replace(/;+$/g,"")}return e}compose_argument(e,t,n=[],r){t.extra||(t.extra=[]),t.extra.push(n);let i=e.map((e=>{if("text"===e.type)return/^\-\-\w/.test(e.value)?r&&"@var"===r.name?e.value:this.read_var(e.value,t):e.value;if("func"===e.type){let r=e.name.substr(1),i=this.pick_func(r);if("function"==typeof i){if(this.check_uniforms(r),this.is_composable(r)){let n=E((e.arguments[0]||[])[0]);if(!w(n))switch(r){case"doodle":return this.compose_doodle(this.inject_variables(n,t.count));case"shaders":return this.compose_shaders(n,t);case"canvas":return this.compose_canvas(n,e.arguments.slice(1));case"pattern":return this.compose_pattern(n,t)}}t.position=e.position;let s=e.arguments.map((r=>i.lazy?(...n)=>this.compose_argument(r,t,n,e):this.compose_argument(r,t,n,e)));return this.apply_func(i,t,s)}return e.name}}));return t.extra.pop(),{cluster:e.cluster,value:i.length>=2?{value:i.join("")}:i[0]}}compose_doodle(e){let t=M("doodle");return this.doodles[t]=e,"${"+t+"}"}compose_shaders(e,{x:t,y:n,z:r}){let i=M("shader");return this.shaders[i]={id:"--"+i,shader:e,cell:j(t,n,r)},"${"+i+"}"}compose_pattern(e,{x:t,y:n,z:r}){let i=M("pattern");return this.pattern[i]={id:"--"+i,code:e,cell:j(t,n,r)},"${"+i+"}"}compose_canvas(e,t=[]){let n=e,r=t.map((e=>E(e[0]))).join(",");r.length&&(n=e+","+r);let i=M("canvas");return this.canvas[i]={code:n},"${"+i+"}"}check_uniforms(e){switch(e){case"ut":case"t":this.uniforms.time=!0;break;case"ux":this.uniforms.mousex=!0;break;case"uy":this.uniforms.mousey=!0;break;case"uw":this.uniforms.width=!0;break;case"uh":this.uniforms.height=!0}}inject_variables(e,t){let n=this.custom_properties[t];if(w(n))return e;let r=[];for(let[e,t]of Object.entries(n))r.push(`${e}:${t};`);return r.join("")+e}compose_value(e,t){if(!Array.isArray(e))return{value:"",extra:""};let n="";return{value:e.reduce(((e,r)=>{switch(r.type){case"text":e+=r.value;break;case"func":{let i=r.name.substr(1),s=this.pick_func(i);if("function"==typeof s)if(this.check_uniforms(i),this.is_composable(i)){let n=E((r.arguments[0]||[])[0]);if(!w(n))switch(i){case"doodle":e+=this.compose_doodle(this.inject_variables(n,t.count));break;case"shaders":e+=this.compose_shaders(n,t);break;case"pattern":e+=this.compose_pattern(n,t);break;case"canvas":e+=this.compose_canvas(n,r.arguments.slice(1))}}else{t.position=r.position;let i=r.arguments.map((e=>s.lazy?(...n)=>this.compose_argument(e,t,n,r):this.compose_argument(e,t,[],r))),o=this.apply_func(s,t,i);w(o)||(e+=o,o.extra&&(n=o.extra))}else e+=r.name}}return e}),""),extra:n}}compose_rule(e,t,n){let r,i=Object.assign({},t),s=e.property,o=e.value.reduce(((e,t)=>{let n=this.compose_value(t,i);return n&&(n.value&&e.push(n.value),n.extra&&(r=n.extra)),e}),[]),l=o.join(", ");if(/^animation(\-name)?$/.test(s)){if(this.props.has_animation=!0,Zt(n)){let e=St[s];e&&l&&(l=e+","+l)}if(i.count>1){let{count:e}=i;switch(s){case"animation-name":l=o.map((t=>this.compose_aname(t,e))).join(", ");break;case"animation":l=o.map((t=>{let n=(t||"").split(/\s+/);return n[0]=this.compose_aname(n[0],e),n.join(" ")})).join(", ")}}}"content"===s&&(/["']|^none$|^(var|counter|counters|attr|url)\(/.test(l)||(l=`'${l}'`)),"transition"===s&&(this.props.has_transition=!0);let a=`${s}:${l};`;if(a=Bt(s,a),"clip-path"===s&&(a+=";overflow:hidden;"),"width"!==s&&"height"!==s||Kt(n)||(a+=`--internal-cell-${s}:${l};`),"background"===s&&(l.includes("shader")||l.includes("canvas")||l.includes("pattern"))&&(a+="background-size:100% 100%;"),/^\-\-/.test(s)&&(this.custom_properties[t.count]||(this.custom_properties[t.count]={}),this.custom_properties[t.count][s]=l),/^@/.test(s)&&Ht[s.substr(1)]){let t=s.substr(1),o=Ht[t](l,{is_special_selector:Kt(n),grid:i.grid,extra:r});switch(t){case"grid":Zt(n)?a=o.size||"":(a="",this.is_grid_defined||(o=Ht[t](l,{is_special_selector:!0,grid:i.grid}),this.add_rule(":host",o.size||""))),this.grid=i.grid,this.is_grid_defined=!0;break;case"place-cell":case"position":case"offset":Zt(n)||(a=o);break;case"use":e.value.length&&this.compose(i,e.value),a="";break;default:a=o}}return a}pre_compose_rule(e,t){let n=Object.assign({},t),r=e.property;switch(r){case"@grid":{let t=e.value.reduce(((e,t)=>{let r=this.compose_value(t,n);return r&&r.value&&e.push(r.value),e}),[]).join(", "),i=r.substr(1),s=Ht[i](t,{});this.grid=s.grid;break}case"@use":e.value.length&&this.pre_compose(n,e.value)}}pre_compose(e,t){(t||this.tokens).forEach((t=>{switch(t.type){case"rule":this.pre_compose_rule(t,e);break;case"pseudo":Zt(t.selector)&&(t.styles||[]).forEach((t=>{this.pre_compose_rule(t,e)}))}}))}compose(e,t,n){this.coords.push(e),(t||this.tokens).forEach(((t,r)=>{if(t.skip)return!1;if(n&&this.grid)return!1;switch(t.type){case"rule":this.add_rule(this.compose_selector(e),this.compose_rule(t,e));break;case"pseudo":{t.selector.startsWith(":doodle")&&(t.selector=t.selector.replace(/^\:+doodle/,":host"));let n=Kt(t.selector);n&&(t.skip=!0),t.selector.split(",").forEach((r=>{let i=t.styles.map((t=>this.compose_rule(t,e,r))),s=n?r:this.compose_selector(e,r);this.add_rule(s,i)}));break}case"cond":{let n=Vt[t.name.substr(1)];if(n){let r=t.arguments.map((t=>this.compose_argument(t,e)));this.apply_func(n,e,r)&&this.compose(e,t.styles)}break}case"keyframes":this.keyframes[t.name]||(this.keyframes[t.name]=e=>`\n ${I(t.steps.map((t=>`\n ${t.name}{${I(t.styles.map((t=>this.compose_rule(t,e))))}}`)))}`)}}))}output(){for(let[e,t]of Object.entries(this.rules))if(Gt(e))this.styles.container+=`\n .container{${I(t)}}`;else{let n=Zt(e)?"host":"cells",r=I(t).trim(),i="host"===n?`${e}, .host`:e;this.styles[n]+=`${i}{${r}}`}return this.uniforms.time&&(this.styles.container+=`\n:host, .host{animation:${St.animation};}`,this.styles.keyframes+=`\n @keyframes ${St["animation-name"]}{from{--${St.name}:0} to{--${St.name}:${St["animation-duration"]/10}}}`),this.coords.forEach(((e,t)=>{for(let[i,s]of Object.entries(this.keyframes)){let o=this.compose_aname(i,e.count);this.styles.keyframes+=`\n ${n=0===t,r=`@keyframes ${i}{${s(e)}}`,n?"function"==typeof r?r():r:""} @keyframes ${o}{${s(e)}}`}var n,r})),{props:this.props,styles:this.styles,grid:this.grid,doodles:this.doodles,shaders:this.shaders,canvas:this.canvas,pattern:this.pattern,uniforms:this.uniforms}}}function en(e,t,n){let r=new Qt(e),i={};function s(e=0,t){return 1==arguments.length&&([e,t]=[0,e]),N(n(),e,t)}function o(...e){let t=e.reduce(((e,t)=>e.concat(t)),[]);return t[~~(n()*t.length)]}function l(e){let t=[...e],r=e.length;for(;r;){let e=~~(n()*r--),i=t[r];t[r]=t[e],t[e]=i}return t}r.pre_compose({x:1,y:1,z:1,count:1,context:{},grid:{x:1,y:1,z:1,count:1},random:n,rand:s,pick:o,shuffle:l});let{grid:a}=r.output();if(a&&(t=a),r.reset(),1==t.z)for(let e=1,a=0;e<=t.y;++e)for(let u=1;u<=t.x;++u)r.compose({x:u,y:e,z:1,count:++a,grid:t,context:i,random:n,rand:s,pick:o,shuffle:l});else for(let e=1,a=0;e<=t.z;++e)r.compose({x:1,y:1,z:e,count:++a,grid:t,context:i,random:n,rand:s,pick:o,shuffle:l});return r.output()}function tn(e,t,n){let r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}function nn(e,t){return e.includes(t)?e:t+"\n"+e}function rn(e,t,n,r){let i=De.get(e);if(i)return Promise.resolve(i);let s=document.createElement("canvas"),o=window.devicePixelRatio||1;t*=o,n*=o,s.width=t,s.height=n;let l=s.getContext("webgl2",{preserveDrawingBuffer:!0});if(!l)return Promise.resolve("");let a=nn(e.fragment||"","uniform vec2 u_resolution;");a=nn(a,"uniform float u_time;"),a=nn(a,"uniform float u_timeDelta;"),a=nn(a,"uniform int u_frameIndex;"),a=nn(a,"uniform vec2 u_seed;"),e.textures.forEach((e=>{let t=`uniform sampler2D ${e.name};`;a=nn(a,t)}));/(^|[^\w\_])void\s+mainImage\(\s*out\s+vec4\s+fragColor,\s*in\s+vec2\s+fragCoord\s*\)/gm.test(a)&&(a=`// https://www.shadertoy.com/howto\n\n#define iResolution vec3(u_resolution, 0)\n#define iTime u_time\n#define iTimeDelta u_timeDelta\n#define iFrame u_frameIndex\n\n${e.textures.map(((e,t)=>`#define iChannel${t} ${e.name}`)).join("\n")}\n${a}\nvoid main(){mainImage(FragColor, gl_FragCoord.xy);}`);let u=function(e,t,n){let r=tn(e,e.VERTEX_SHADER,t),i=tn(e,e.FRAGMENT_SHADER,n),s=e.createProgram();return e.attachShader(s,r),e.attachShader(s,i),e.linkProgram(s),e.getProgramParameter(s,e.LINK_STATUS)||(console.warn("Link failed:"+e.getProgramInfoLog(s)),console.warn("vs info-log:"+e.getShaderInfoLog(r)),console.warn("fs info-log:"+e.getShaderInfoLog(i))),s}(l,e.vertex||"#version 300 es\n in vec4 position;void main(){gl_Position = position;}","#version 300 es\n precision highp float;out vec4 FragColor;"+a),c=l.getAttribLocation(u,"position"),h=l.createBuffer();l.bindBuffer(l.ARRAY_BUFFER,h);l.bufferData(l.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,-1,1,1,-1,1,1,-1]),l.STATIC_DRAW),l.enableVertexAttribArray(c),l.vertexAttribPointer(c,2,l.FLOAT,!1,0,0),l.viewport(0,0,l.drawingBufferWidth,l.drawingBufferHeight),l.clearColor(0,0,0,0),l.clear(l.COLOR_BUFFER_BIT),l.useProgram(u);const p=l.getUniformLocation(u,"u_resolution");l.uniform2fv(p,[t,n]),e.textures.forEach(((e,t)=>{!function(e,t,n){const r=e.createTexture();e.activeTexture(e["TEXTURE"+n]),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!0),e.bindTexture(e.TEXTURE_2D,r),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR)}(l,e.value,t),l.uniform1i(l.getUniformLocation(u,e.name),t)}));const f=l.getUniformLocation(u,"u_seed");f&&l.uniform2f(f,z(r)/1e16,Math.random());const m=l.getUniformLocation(u,"u_time"),d=l.getUniformLocation(u,"u_frameIndex"),g=l.getUniformLocation(u,"u_timeDelta");if(m||g||d){let t=0,n=0;return Promise.resolve(De.set(e,(e=>(l.clear(l.COLOR_BUFFER_BIT),m&&l.uniform1f(m,e/1e3),d&&l.uniform1i(d,t++),g&&(l.uniform1f(g,(n-e)/1e3),n=e),l.drawArrays(l.TRIANGLES,0,6),s.toDataURL()))))}return l.drawArrays(l.TRIANGLES,0,6),Promise.resolve(De.set(e,s.toDataURL()))}function sn(e,t){let n=[];for(;e.next();){let{curr:t,next:r}=e.get(),i=!r||t.isSymbol(";")||r.isSymbol("}");if(n.push(t),i)break}return n.length&&(t.value=ln(n)),t}function on(e,t){let n=[],r=[],i=t&&t.type||"",s=[];for(;e.next();){let{prev:o,curr:l,next:a}=e.get(),u=!a||l.isSymbol("}");if("block"===i&&u){a||!n.length||l.isSymbol("}")||(n[n.length-1].value+=";"+l.value),t.value=n;break}if(l.isSymbol("{")&&r.length&&!s.length){let t=an(r);if(!t.length)continue;let i=on(e,{type:"block",name:"unkown",value:[]});t.forEach((e=>{let t=Object.assign({},i,{name:e.name,args:e.args});n.push(t)})),r=[]}else if(l.isSymbol(":")&&r.length&&!s.length){let s=ln(r);n.push(sn(e,{type:"statement",name:s,value:""})),"block"==i&&(t.value=n),r=[]}else l.isSymbol(";")?n.length&&r.length&&(n[n.length-1].value+=";"+ln(r),r=[]):(l.isSymbol("(")&&s.push(l),l.isSymbol(")")&&s.pop(),r.push(l))}return n.length&&"block"==i&&(t.value=n),i?t:n}function ln(e){return e.filter(((t,n)=>!t.isSymbol(";")||n!==e.length-1)).map((e=>e.value)).join("")}function an(e){let t=i(e),n=[],r="",s=[],o=[],l=[];for(;t.next();){let{curr:e,next:i}=t.get();!r.length&&e.isWord()?r=e.value:e.isSymbol("(")?(l.length&&o.push(e.value),l.push(e)):e.isSymbol(")")?(l.pop(),l.length?o.push(e.value):o.length&&(s.push(o.join("")),o=[])):e.isSymbol(",")?l.length?(s.push(o.join("")),o=[]):(o.length&&(s.push(o.join("")),o=[]),r&&(n.push({name:r,args:s}),r="",s=[],o=[])):o.push(e.value)}return r&&n.push({name:r,args:s}),n.filter(((e,t,n)=>n.findIndex((t=>t.name===e.name&&e.args.join("")==t.args.join("")))===t))}function un(e){return on(i(f(e)))}function cn(e,t){if("fill"===e.name){let{r:n,g:r,b:i,a:s}=t.get_rgba_color(e.value);return{type:"statement",value:`\ncolor = vec4(${hn(n/255)}, ${hn(r/255)}, ${hn(i/255)}, ${hn(s)});`}}return"grid"==e.name?{type:"grid",value:e.value}:{type:"statement",value:""}}function hn(e){return String(e).includes(".")?e:e+".0"}function pn(e,t){let n=un(e),r=[],i={x:1,y:1};return n.forEach((e=>{if("statement"===e.type){let n=cn(e,t);"statement"==n.type&&r.push(n.value),"grid"===n.type&&(i=function(e){let[t,n=t]=String(e+"").replace(/\s+/g,"").replace(/[,\uff0cxX]+/g,"x").split("x").map((e=>parseInt(e)));return(!t||t<1)&&(t=1),(!n||n<1)&&(n=1),{x:t,y:n}}(n.value))}else"block"===e.type&&r.push(function(e,t){if("match"===e.name){let n=e.args[0],r=[];return e.value.forEach((e=>{let n=cn(e,t);"statement"==n.type&&r.push(n.value)})),`\n if (${n}){${r.join("")}}`}return""}(e,t))})),function(e,t){return`\n vec3 mapping(vec2 uv, vec2 grid){vec2 _grid = 1.0/grid;float x = ceil(uv.x/_grid.x);float y = ceil(grid.y - uv.y/_grid.y);float i = x + (y - 1.0) * y;return vec3(x, y, i);} vec4 getColor(float x, float y, float i, float I, float X, float Y, float t){vec4 color = vec4(0, 0, 0, 0);${e} return color;} void main(){vec2 uv = gl_FragCoord.xy/u_resolution.xy;vec2 grid = vec2(${t.x}, ${t.y});vec3 p = mapping(uv, grid);FragColor = getColor(p.x, p.y, p.z, grid.x * grid.y, grid.x, grid.y, u_time);}`}(r.join(""),i)}const fn=C();function mn(e){let t=De.get(e);if(t)return Promise.resolve(t);let n=fn("css-doodle-paint"),r=function(e,t){(t=R(t)).includes("paint(")||(t=`\n paint(ctx,{width, height}, props){${t}}`);return`\n registerPaint('${e}', class{${t}})\n`}(n,e),i=new Blob([r],{type:"text/javascript"});try{CSS.paintWorklet&&CSS.paintWorklet.addModule(URL.createObjectURL(i))}catch(e){}return Promise.resolve(De.set(e,`paint(${n})`))}var dn=globalThis,gn=Math,vn=[],yn=256,xn=gn.pow(yn,6),bn=gn.pow(2,52),_n=2*bn,wn=255;function kn(e,t,n){var r=[],i=En(jn((t=1==t?{entropy:!0}:t||{}).entropy?[e,Tn(vn)]:null==e?function(){try{var e;return e=new Uint8Array(yn),(dn.crypto||dn.msCrypto).getRandomValues(e),Tn(e)}catch(e){var t=dn.navigator,n=t&&t.plugins;return[+new Date,dn,n,dn.screen,Tn(vn)]}}():e,3),r),s=new $n(r),o=function(){for(var e=s.g(6),t=xn,n=0;e=_n;)e/=2,t/=2,n>>>=1;return(e+n)/t};return o.int32=function(){return 0|s.g(4)},o.quick=function(){return s.g(4)/4294967296},o.double=o,En(Tn(s.S),vn),(t.pass||n||function(e,t,n,r){return r&&(r.S&&Sn(r,s),e.state=function(){return Sn(s,{})}),n?(gn.random=e,t):e})(o,i,"global"in t?t.global:this==gn,t.state)}function $n(e){var t,n=e.length,r=this,i=0,s=r.i=r.j=0,o=r.S=[];for(n||(e=[n++]);ifunction(e,t){return"undefined"==typeof getComputedStyle?"":getComputedStyle(e).getPropertyValue(t).trim().replace(/^\(|\)$/g,"")}(this,e),get_rgba_color:e=>function(e,t){let n=e.querySelector("#defs");return n?(n.style.color=t,function(e){let[t,n,r,i=1]=e.replace(/rgba?\((.+)\)/,((e,t)=>t)).split(/,\s*/);return{r:t,g:n,b:r,a:i}}(getComputedStyle(n).color)):{r:0,g:0,b:0,a:1}}(this.shadowRoot,e)}}connectedCallback(e){this.innerHTML?this.load(e):setTimeout((()=>this.load(e)))}disconnectedCallback(){this.cleanup()}cleanup(){De.clear();for(let e of this.animations)e.cancel();this.animations=[]}update(e){this.cleanup();let t=this.get_use();e||(e=R(this.innerHTML)),this.innerHTML=e,this.grid_size||(this.grid_size=this.get_grid());let{x:n,y:r,z:i}=this.grid_size;const s=this.generate(me(t+e,this.extra));if(!this.shadowRoot.innerHTML)return Object.assign(this.grid_size,s.grid),this.build_grid(s,s.grid);if(s.grid){let{x:e,y:t,z:o}=s.grid;if(n!==e||r!==t||i!==o)return Object.assign(this.grid_size,s.grid),this.build_grid(s,s.grid);Object.assign(this.grid_size,s.grid)}else{let s=this.get_grid(),{x:o,y:l,z:a}=s;if(n!==o||r!==l||i!==a)return Object.assign(this.grid_size,s),this.build_grid(this.generate(me(t+e,this.extra)),s)}let o=this.replace(s);this.set_content(".style-keyframes",o(s.styles.keyframes)),s.props.has_animation&&(this.set_content(".style-cells",""),this.set_content(".style-container","")),setTimeout((()=>{this.set_content(".style-container",o(Pn(this.grid_size)+s.styles.host+s.styles.container)),this.set_content(".style-cells",o(s.styles.cells))}))}get grid(){return Object.assign({},this.grid_size)}set grid(e){this.attr("grid",e),this.connectedCallback(!0)}get seed(){return this._seed_value}set seed(e){this.attr("seed",e),this.connectedCallback(!0)}get use(){return this.attr("use")}set use(e){this.attr("use",e),this.connectedCallback(!0)}get_grid(){return ye(this.attr("grid"))}get_use(){let e=this.attr("use")||"";return e&&(e=`@use:${e};`),e}attr(e,t){return 1===arguments.length?this.getAttribute(e):2===arguments.length?(this.setAttribute(e,t),t):void 0}generate(e){let t=this.get_grid(),n=this.attr("seed")||this.attr("data-seed");w(n)&&(n=Date.now()),n=String(n),this._seed_value=n;let r=this.random=kn(n);return this.compiled=en(e,t,r)}doodle_to_image(e,t,n){"function"==typeof t&&(n=t,t=null);let r=me(e=":doodle{width:100%;height:100%}"+e,this.extra),i=ye({}),s=en(r,i,this.random),o=s.grid?s.grid:i;const{keyframes:l,host:a,container:u,cells:c}=s.styles;let h=this.replace(s),p=Nn(o);h(`\n
${p}
`).then((e=>{let t=`data:image/svg+xml;base64,${window.btoa(unescape(encodeURIComponent(e)))}`;A()&&T(t),n(t)}))}pattern_to_image({code:e,cell:t,id:n},r){let i=pn(e,this.extra);this.shader_to_image({shader:i,cell:t,id:n},r)}canvas_to_image({code:e},t){mn(e).then(t)}pause(){this.setAttribute("cssd-paused-animation",!0);for(let e of this.animations)e.pause()}resume(){this.removeAttribute("cssd-paused-animation");for(let e of this.animations)e.resume()}shader_to_image({shader:e,cell:t,id:n},r){let s="string"==typeof e?function(e){let t,n,r=i(_e(f(e,{preserveLineBreak:!0,ignoreInlineComment:!0}))),s=[],o=[],l={textures:[]};for(;r.next();){let{curr:e,next:i}=r.get();if(e.isSymbol("{")){if(s.length)o.push(e);else{let n=we(o);xe(n)?(t=n,o=[]):o.push(e)}s.push("{")}else if(e.isSymbol("}"))if(s.pop(),!s.length&&t){let e=we(o);t&&e.length&&(t.startsWith("texture")?l.textures.push({name:t,value:e}):l[t]=e,o=[]),t=null}else o.push(e);else $(n)||n==e.pos[1]||(o.push(be()),n=null),e.isWord()&&e.value.startsWith("#")&&(o.push(be()),n=i.pos[1]),o.push(e)}return $(l.fragment)&&(l.fragment=we(o),l.textures=l.textures||[]),l}(e):e,o=this.doodle.getElementById(t);const l=this.seed,a=e=>{o.style.setProperty(n,`url(${e})`)},u=e=>{if("function"==typeof e){let t=function(e){let t,n=0,r=0,i=0,s=!1;function o(s){n||(n=s),e(n);let l=s-r;l1e3&&(l=i||1e3),r&&(n+=l),i=l,r=s,t=requestAnimationFrame(o)}return t=requestAnimationFrame(o),{resume(){t&&s&&(s=!1,t=requestAnimationFrame(o))},pause(){t&&(cancelAnimationFrame(t),s=!0)},cancel(){t&&(s=!1,cancelAnimationFrame(t),t=null)}}}((t=>{a(e(t))}));return this.animations.push(t),""}a(e)};let{width:c,height:h}=o&&o.getBoundingClientRect()||{width:0,height:0},p=window.devicePixelRatio||1;if(!s.textures.length||s.ticker)rn(s,c,h,l).then(u).then(r);else{let e=s.textures.map((e=>new Promise((t=>{this.doodle_to_image(e.value,{width:c,height:h},(n=>{let r=new Image;r.width=c*p,r.height=h*p,r.onload=()=>t({name:e.name,value:r}),r.src=n}))}))));Promise.all(e).then((e=>{s.textures=e,rn(s,c,h,l).then(u).then(r)}))}}load(e){this.cleanup();let t=me(this.get_use()+R(this.innerHTML),this.extra),n=this.generate(t);e||this.hasAttribute("click-to-update")&&this.addEventListener("click",(e=>this.update())),this.grid_size=n.grid?n.grid:this.get_grid(),this.build_grid(n,this.grid_size)}replace({doodles:e,shaders:t,canvas:n,pattern:r}){let i=Object.keys(e),s=Object.keys(t),o=Object.keys(n),l=Object.keys(r),a=i.length+o.length+s.length+l.length;return u=>{if(!a)return Promise.resolve(u);let c=[].concat(i.map((t=>u.includes(t)?new Promise((n=>{this.doodle_to_image(e[t],(e=>n({id:t,value:e})))})):Promise.resolve(""))),s.map((e=>u.includes(e)?new Promise((n=>{this.shader_to_image(t[e],(t=>n({id:e,value:t})))})):Promise.resolve(""))),o.map((e=>u.includes(e)?new Promise((t=>{this.canvas_to_image(n[e],(n=>t({id:e,value:n})))})):Promise.resolve(""))),l.map((e=>u.includes(e)?new Promise((t=>{this.pattern_to_image(r[e],(n=>t({id:e,value:n})))})):Promise.resolve(""))));return Promise.all(c).then((e=>{for(let{id:t,value:n}of e){let e=`url(${n})`;/^canvas/.test(t)&&(e=n),/^shader|^pattern/.test(t)&&(e=`var(--${t})`),u=u.replaceAll("${"+t+"}",e)}return u}))}}build_grid(e,t){const{has_transition:n,has_animation:r}=e.props;let i=n||r;const{keyframes:s,host:o,container:l,cells:a}=e.styles;let u=Pn(t)+o+l,c=i?"":a;const{uniforms:h}=e;let p=this.replace(e);this.doodle.innerHTML=`\n${Nn(t)}`,this.set_content(".style-container",p(u)),i?setTimeout((()=>{this.set_content(".style-cells",p(a))}),50):this.set_content(".style-cells",p(a)),h.time&&this.register_uniform_time(),h.mousex||h.mousey?this.register_uniform_mouse(h):this.remove_uniform_mouse(),h.width||h.height?this.register_uniform_resolution(h):this.remove_uniform_resolution()}register_uniform_mouse(e){if(!this.uniform_mouse_callback){let{uniform_mousex:t,uniform_mousey:n}=Rt;this.uniform_mouse_callback=r=>{let i=r.detail||r;e.mousex&&this.style.setProperty("--"+t.name,i.offsetX),e.mousey&&this.style.setProperty("--"+n.name,i.offsetY)},this.addEventListener("pointermove",this.uniform_mouse_callback);let r=new CustomEvent("pointermove",{detail:{offsetX:0,offsetY:0}});this.dispatchEvent(r)}}remove_uniform_mouse(){if(this.uniform_mouse_callback){let{uniform_mousex:e,uniform_mousey:t}=Rt;this.style.removeProperty("--"+e.name),this.style.removeProperty("--"+t.name),this.removeEventListener("pointermove",this.uniform_mouse_callback),this.uniform_mouse_callback=null}}register_uniform_resolution(e){if(!this.uniform_resolution_observer){let{uniform_width:t,uniform_height:n}=Rt;const r=()=>{let r=this.getBoundingClientRect();e.width&&this.style.setProperty("--"+t.name,r.width),e.height&&this.style.setProperty("--"+n.name,r.height)};r(),this.uniform_resolution_observer=new ResizeObserver((e=>{for(let t of e){(t.contentBoxSize||t.contentRect)&&r()}})),this.uniform_resolution_observer.observe(this)}}remove_uniform_resolution(){if(this.uniform_resolution_observer){let{uniform_width:e,uniform_height:t}=Rt;this.style.removeProperty("--"+e.name),this.style.removeProperty("--"+t.name),this.uniform_resolution_observer.unobserve(this),this.uniform_resolution_observer=null}}register_uniform_time(){if(!window.CSS||!window.CSS.registerProperty)return!1;if(!this.is_uniform_time_registered){let{uniform_time:e}=Rt;try{CSS.registerProperty({name:"--"+e.name,syntax:"",initialValue:0,inherits:!0})}catch(e){}this.is_uniform_time_registered=!0}}export({scale:e,name:t,download:n,detail:r}={}){return new Promise(((i,s)=>{let o=An(this),l=this.doodle.innerHTML,{width:a,height:u}=this.getBoundingClientRect(),c=a*(e=parseInt(e)||1),h=u*e,p=`\n${l}`;var f;n||r?function(e,t,n,r){return new Promise(((i,s)=>{let o=`data:image/svg+xml;utf8,${encodeURIComponent(e)}`;function l(){let e=new Image;e.crossOrigin="anonymous",e.src=o,e.onload=()=>{let l=document.createElement("canvas"),a=l.getContext("2d"),u=window.devicePixelRatio||1;1!=r&&(u=1),l.width=t*u,l.height=n*u,a.drawImage(e,0,0,l.width,l.height);try{l.toBlob((e=>{i({blob:e,source:o,url:URL.createObjectURL(e)})}))}catch(e){s(e)}}}A()?T(o,l,200):l()}))}(p,c,h,e).then((({source:e,url:r,blob:s})=>{if(i({width:c,height:h,svg:p,blob:s,source:e}),n){let e=document.createElement("a");e.download=function(e){return(w(e)?Date.now():String(e).replace(/\/.png$/g,""))+".png"}(t),e.href=r,e.click()}})).catch((e=>{s(e)})):i({width:c,height:h,svg:p})}))}set_content(e,t){if(t instanceof Promise)t.then((t=>{this.set_content(e,t)}));else{const n=this.shadowRoot.querySelector(e);n&&(n.styleSheet?n.styleSheet.cssText=t:n.innerHTML=t)}}}customElements.get("css-doodle")||customElements.define("css-doodle",e)}function zn(){let{uniform_time:e}=Rt;const t=Ot(/grid/).map((e=>`${e}:inherit;`)).join("");return`\n *, *::after, *::before{box-sizing:border-box;animation-play-state:var(--cssd-animation-play-state) !important;}:host, .host{display:block;visibility:visible;width:auto;height:auto;--${e.name}:0\n}:host([hidden]), .host[hidden]{display:none\n} .container{position:relative;width:100%;height:100%;display:grid;${t}} cell:empty{position:relative;line-height:1;display:grid;place-items:center\n} svg{position:absolute;width:100%;height:100%;}:host([cssd-paused-animation]){--cssd-animation-play-state:paused;animation-play-state:paused !important;}`}function Pn(e){let{x:t,y:n}=e||{};return`\n:host, .host{grid-template-rows:repeat(${n}, 1fr);grid-template-columns:repeat(${t}, 1fr);}`}function Cn(e,t,n){let r=document.createElement("cell");return r.id=j(e,t,n),r}function Nn(e){let{x:t,y:n,z:r}=e||{},i=document.createElement("grid"),s=document.createDocumentFragment();if(1==r)for(let e=1;e<=n;++e)for(let n=1;n<=t;++n)s.appendChild(Cn(n,e,1));else{let e=null;for(let t=1;t<=r;++t){let n=Cn(1,1,t);(e||s).appendChild(n),e=n}e=null}return i.className="container",i.appendChild(s),i.outerHTML}const Mn=P((e=>{let t=document.createElement("css-doodle");return t.update&&t.update(e),t}));e.CSSDoodle=Mn,Object.defineProperty(e,"__esModule",{value:!0})})); \ No newline at end of file +/*! css-doodle@0.27.4 */!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).CSSDoodle={})}(this,(function(e){"use strict";const t=[":",";",",","(",")","[","]","{","}","\u03c0","\xb1","+","-","*","/","%",'"',"'","`","@"],n={escape:e=>"\\"==e,space:e=>/[\r\n\t\s]/.test(e),digit:e=>/^[0-9]$/.test(e),sign:e=>/^[+-]$/.test(e),dot:e=>"."==e,quote:e=>/^["'`]$/.test(e),symbol:e=>t.includes(e),hexNum:e=>/^[0-9a-f]$/i.test(e),hex:(e,t,r)=>"0"==e&&n.letter(t,"x")&&n.hexNum(r),expWithSign:(e,t,r)=>n.letter(e,"e")&&n.sign(t)&&n.digit(r),exp:(e,t)=>n.letter(e,"e")&&n.digit(t),dots:(e,t)=>n.dot(e)&&n.dot(t),letter:(e,t)=>String(e).toLowerCase()==String(t).toLowerCase(),comment:(e,t)=>"/"==e&&"*"==t,inlineComment:(e,t)=>"/"==e&&"/"===t,selfClosedTag:(e,t)=>"/"==e&&">"==t,closedTag:(e,t)=>"<"==e&&"/"==t};class r{constructor({type:e,value:t,pos:n,status:r}){this.type=e,this.value=t,this.pos=n,r&&(this.status=r)}isSymbol(...e){let t="Symbol"==this.type;return e.length?e.some((e=>e===this.value)):t}isSpace(){return"Space"==this.type}isNumber(){return"Number"==this.type}isWord(){return"Word"==this.type}}function i(e){let t=-1,n=e.length,r=-1,i=0;return{curr:(n=0)=>e[t+n],next(n=1){let s=e[t+=n];return"\n"===s?(i++,r=0):r+=n,s},end:()=>t>=n,get:()=>({prev:e[t-1],curr:e[t+0],next:e[t+1],next2:e[t+2],next3:e[t+3],pos:[r,i]})}}function s(e){for(;e.next();){let{curr:t,prev:r}=e.get();if(n.comment(t,r))break}}function o(e){for(;e.next()&&"\n"!==e.curr(););}function l(e){return[":",";",",","{","}","(",")","[","]"].includes(e)}function a(e){let t="";for(;!e.end();){let{curr:r,next:i}=e.get();t+=r;let s=n.symbol(i)||n.space(i)||n.digit(i);if(t.length&&s&&!n.closedTag(r,i))break;e.next()}return t.trim()}function u(e){let t="";for(;!e.end();){let{curr:r,next:i}=e.get();if(t+=r,!n.space(i))break;e.next()}return t}function c(e){let t="",r=!1;for(;!e.end();){let{curr:i,next:s,next2:o,next3:l}=e.get();if(t+=i,r&&n.dot(s))break;if(n.dot(i)&&(r=!0),n.dots(s,o))break;if(n.expWithSign(s,o,l))t+=e.next()+e.next();else if(n.exp(s,o))t+=e.next();else if(!n.digit(s)&&!n.dot(s))break;e.next()}return t}function h(e){let t="0x";for(e.next(2);!e.end();){let{curr:r,next:i}=e.get();if(t+=r,!n.hexNum(i))break;e.next()}return t}function p(e){return e[e.length-1]}function f(e,t={}){let f=i(String(e).trim()),m=[],d=[];for(;f.next();){let{prev:e,curr:i,next:g,next2:v,pos:y}=f.get();if(n.comment(i,g))s(f);else if(t.ignoreInlineComment&&n.inlineComment(i,g))o(f);else if(n.hex(i,g,v)){let e=h(f);m.push(new r({type:"Number",value:e,pos:y}))}else if(n.digit(i)||n.digit(g)&&n.dot(i)&&!n.dots(e,i)){let e=c(f);m.push(new r({type:"Number",value:e,pos:y}))}else if(n.symbol(i)&&!n.selfClosedTag(i,g)){let e=p(m),t=n.digit(g)||n.dot(g)&&n.digit(v);if("-"===i&&t&&(!e||!e.isNumber())){let e=c(f);m.push(new r({type:"Number",value:e,pos:y}));continue}let s={type:"Symbol",value:i,pos:y};if(d.length&&n.escape(e.value)){m.pop();let e=a(f);e.length&&m.push(new r({type:"Word",value:e,pos:y}))}else{if(n.quote(i)){p(d)==i?(d.pop(),s.status="close"):(d.push(i),s.status="open")}m.push(new r(s))}}else if(n.space(i)){let e=u(f),n=p(m),{next:s}=f.get();if(!d.length&&n){let r=n.value,o=l(r)&&")"!==r,a=l(s)&&"("!==s;if(o||a)continue;e=t.preserveLineBreak?i:" "}m.length&&s&&s.trim()&&m.push(new r({type:"Space",value:e,pos:y}))}else{let e=a(f);e.length&&m.push(new r({type:"Word",value:e,pos:y}))}}let g=p(m);return g&&g.isSpace()&&(m.length=m.length-1),m}function m(e){let t=[];for(;e.next();){let{curr:n,next:r}=e.get();if("var"===n.value){if(r&&r.isSymbol("(")){e.next();let n=d(e);v(n.name)&&t.push(n)}}else if(t.length&&!n.isSymbol(","))break}return t}function d(e){let t={},n=[];for(;e.next();){let{curr:r,next:i}=e.get();if(r.isSymbol(")",";")&&!t.name){t.name=g(n);break}r.isSymbol(",")?(void 0===t.name&&(t.name=g(n),n=[]),t.name&&(t.fallback=m(e))):n.push(r)}return t}function g(e){return e.map((e=>e.value)).join("")}function v(e){return void 0!==e&&(!(e.length<=2)&&(!e.substr(2).startsWith("-")&&!!e.startsWith("--")))}function y(e,t,n){return e=Number(e)||0,Math.max(t,Math.min(n,e))}function x(e,t,n){let r=0,i=e,s=e=>e>0&&e<1?.1:1,o=arguments.length;1==o&&([e,t]=[s(e),e]),o<3&&(n=s(e));let l=[];for(;(n>=0&&e<=t||n<0&&e>t)&&(l.push(e),e+=n,!(r++>=1e3)););return l.length||l.push(i),l}function b(e,t){for(let[n,r]of Object.entries(t))e[n]=e[r];return e}function _(e){return/^[a-zA-Z]$/.test(e)}function w(e){return null==e}function k(e){return w(e)||Number.isNaN(e)}function $(e){return w(e)||""===e}function S(e){let t=()=>e;return t.lazy=!0,t}function j(e,t,n){return"c-"+e+"-"+t+"-"+n}function E(e){let t=e;for(;t&&!w(t.value);)t=t.value;return w(t)?"":t}function T(e,t,n=0){let r=new Image;r.crossOrigin="anonymous",r.src=e,r.onload=function(){setTimeout(t,n)}}function A(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function R(e){let t=document.createElement("textarea");return t.innerHTML=e,t.value}function z(e,t=0){let n=3735928559^t,r=1103547991^t;for(let t,i=0;i>>16,2246822507)^Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}function P(e){return(t,...n)=>{let r=t.reduce(((e,t,r)=>{return e+t+(w(i=n[r])?"":i);var i}),"");return e(r)}}function C(){let e=0;return(t="")=>`${t}-${++e}`}function N(e,t,n){return t+e*(n-t)}function M(e=""){return e+Math.random().toString(32).substr(2)}function L(e){return Array.isArray(e)?e:[e]}function I(e,t="\n"){return(e||[]).join(t)}function O(e,t=1){return w(e)?"":e[e.length-t]}function W(e){return e[0]}function U(e,t){return Array.prototype.flatMap?e.flatMap(t):e.reduce(((e,n)=>e.concat(t(n))),[])}const D={func:(e="")=>({type:"func",name:e,arguments:[]}),argument:()=>({type:"argument",value:[]}),text:(e="")=>({type:"text",value:e}),pseudo:(e="")=>({type:"pseudo",selector:e,styles:[]}),cond:(e="")=>({type:"cond",name:e,styles:[],arguments:[]}),rule:(e="")=>({type:"rule",property:e,value:[]}),keyframes:(e="")=>({type:"keyframes",name:e,steps:[]}),step:(e="")=>({type:"step",name:e,styles:[]})},F={white_space:e=>/[\s\n\t]/.test(e),line_break:e=>/\n/.test(e),number:e=>!isNaN(e),pair:e=>['"',"(",")","'"].includes(e),pair_of:(e,t)=>({'"':'"',"'":"'","(":")"}[e]==t)},B={\u03c0:Math.PI,"\u220f":Math.PI};function X(e){return["@canvas","@shaders","@doodle"].includes(e)}function H(e,{col:t,line:n}){console.warn(`(at line ${n}, column ${t}) ${e}`)}function q(e){return function(t,n){let r=t.index(),i="";for(;!t.end();){let n=t.next();if(e(n))break;i+=n}return n&&t.index(r),i}}function Y(e,t){return q((e=>/[^\w@]/.test(e)))(e,t)}function V(e){return q((e=>/[\s\{]/.test(e)))(e)}function Z(e,t){return q((e=>F.line_break(e)||"{"==e))(e,t)}function G(e,t){let n,r=D.step();for(;!e.end()&&"}"!=(n=e.curr());)if(F.white_space(n))e.next();else{if(r.name.length){if(r.styles.push(ue(e,t)),"}"==e.curr())break}else r.name=oe(e);e.next()}return r}function K(e,t){const n=[];let r;for(;!e.end()&&"}"!=(r=e.curr());)F.white_space(r)||n.push(G(e,t)),e.next();return n}function J(e,t){let n,r=D.keyframes();for(;!e.end()&&"}"!=(n=e.curr());)if(r.name.length){if("{"==n||"{"==e.curr(-1)){e.next(),r.steps=K(e,t);break}e.next()}else if(Y(e),r.name=V(e),!r.name.length){H("missing keyframes name",e.info());break}return r}function Q(e,t={}){for(e.next();!e.end();){let n=e.curr();if(t.inline){if("\n"==n)break}else if("*"==(n=e.curr())&&"/"==e.curr(1))break;e.next()}t.inline||(e.next(),e.next())}function ee(e){for(e.next();!e.end();){if(">"==e.curr())break;e.next()}}function te(e){let t,n="";for(;!e.end()&&":"!=(t=e.curr());)F.white_space(t)||(n+=t),e.next();return n}function ne(e,t,n){let r,i=[],s=[],o=[],l="";for(;!e.end();){if(r=e.curr(),/[\('"`]/.test(r)&&"\\"!==e.curr(-1))o.length&&"("!=r&&r===O(o)?o.pop():o.push(r),l+=r;else if("@"!=r||n)if(n&&/[)]/.test(r)||!n&&/[,)]/.test(r))if(o.length)")"==r&&o.pop(),l+=r;else{if(l.length&&(s.length?/\S/.test(l)&&s.push(D.text(l)):s.push(D.text((u=l).trim().length?F.number(+u)?+u:u.trim():u)),l.startsWith("\xb1")&&!n)){let e=l.substr(1),t=(a=s,JSON.parse(JSON.stringify(a)));O(t).value="-"+e,i.push(re(t)),O(s).value=e}if(i.push(re(s)),[s,l]=[[],""],")"==r)break}else B[r]&&!/[0-9]/.test(e.curr(-1))&&(r=B[r]),l+=r;else s.length||(l=l.trimLeft()),l.length&&(s.push(D.text(l)),l=""),s.push(ie(e));if(!(!t||")"!=e.curr(1)&&/[0-9a-zA-Z_\-.]/.test(e.curr())||o.length)){s.length&&i.push(re(s));break}e.next()}var a,u;return function(e){let t=O(e[0]);t&&"text"===t.type&&!String(t.value).trim().length&&(e[0]=e[0].slice(0,-1));return e}(i)}function re(e){let t=e.map((e=>{if("text"==e.type&&"string"==typeof e.value){let t=String(e.value);t.includes("`")&&(e.value=t=t.replace(/`/g,'"')),e.value=t}return e})),n=W(t)||{},r=O(t)||{};if("text"==n.type&&"text"==r.type){let e=W(n.value),i=O(r.value);"string"==typeof n.value&&"string"==typeof r.value&&F.pair_of(e,i)&&(n.value=n.value.slice(1),r.value=r.value.slice(0,r.value.length-1),t.cluster=!0)}return t}function ie(e){let t,n=D.func(),r="@",i=!1;for(e.next();!e.end();){t=e.curr();let s="."==t&&"@"==e.curr(1),o=e.curr(1);if("("==t||s){i=!0,e.next(),n.arguments=ne(e,s,X(r));break}if(!i&&"("!==o&&!/[0-9a-zA-Z_\-.]/.test(o)){r+=t;break}r+=t,e.next()}let{fname:s,extra:o}=function(e){let t="",n="";if(/\D$/.test(e)&&!/\d+x\d+/.test(e)||Math[e.substr(1)])return{fname:e,extra:n};for(let r=e.length-1;r>=0;r--){let i=e[r],s=e[r-1],o=e[r+1];if(!(/[\d.]/.test(i)||"x"==i&&/\d/.test(s)&&/\d/.test(o))){t=e.substring(0,r+1);break}n=i+n}return{fname:t,extra:n}}(r);return n.name=s,o.length&&n.arguments.unshift([{type:"text",value:o}]),n.position=e.info().index,n}function se(e){let t,n=D.text(),r=0,i=!0;const s=[],o=[];for(s[r]=[];!e.end();)if(t=e.curr(),i&&F.white_space(t))e.next();else{if(i=!1,"\n"!=t||F.white_space(e.curr(-1)))if(","!=t||o.length){if(/[;}<]/.test(t)){n.value.length&&(s[r].push(n),n=D.text());break}"@"==t?(n.value.length&&(s[r].push(n),n=D.text()),s[r].push(ie(e))):F.white_space(t)&&F.white_space(e.curr(-1))||("("==t&&o.push(t),")"==t&&o.pop(),B[t]&&!/[0-9]/.test(e.curr(-1))&&(t=B[t]),n.value+=t)}else n.value.length&&(s[r].push(n),n=D.text()),s[++r]=[],i=!0;else n.value+=" ";e.next()}return n.value.length&&s[r].push(n),s}function oe(e){let t,n="";for(;!e.end()&&"{"!=(t=e.curr());)F.white_space(t)||(n+=t),e.next();return n}function le(e){let t,n={name:"",arguments:[]};for(;!e.end();){if("("==(t=e.curr()))e.next(),n.arguments=ne(e);else{if(/[){]/.test(t))break;F.white_space(t)||(n.name+=t)}e.next()}return n}function ae(e,t){let n,r=D.pseudo();for(;!e.end();){if(n=e.curr(),"/"==n&&"*"==e.curr(1))Q(e);else{if("}"==n)break;if(F.white_space(n)){e.next();continue}if(r.selector){let n=ue(e,t);if("@use"==n.property?r.styles=r.styles.concat(n.value):r.styles.push(n),"}"==e.curr())break}else r.selector=oe(e)}e.next()}return r}function ue(e,t){let n,r=D.rule();for(;!e.end();){if(n=e.curr(),"/"==n&&"*"==e.curr(1))Q(e);else{if(";"==n)break;if(r.property.length){r.value=se(e);break}if(r.property=te(e),"@use"==r.property){r.value=fe(e,t);break}}e.next()}return r}function ce(e,t){let n,r=D.cond();for(;!e.end();){if(n=e.curr(),"/"==n&&"*"==e.curr(1))Q(e);else{if("}"==n)break;if(r.name.length)if(":"==n){let t=ae(e);t.selector&&r.styles.push(t)}else if("@"!=n||Z(e,!0).includes(":")){if(!F.white_space(n)){let n=ue(e,t);if(n.property&&r.styles.push(n),"}"==e.curr())break}}else r.styles.push(ce(e));else Object.assign(r,le(e))}e.next()}return r}function he(e,t){let n="";return e&&e.get_variable&&(n=e.get_variable(t)),n}function pe(e,t){e.forEach&&e.forEach((e=>{if("text"==e.type&&e.value){let n=m(i(f(e.value)));e.value=n.reduce(((e,n)=>{let r,i="",s="";i=he(t,n.name),!i&&n.fallback&&n.fallback.every((e=>{if(s=he(t,e.name),s)return i=s,!1}));try{r=me(i,t)}catch(e){}return r&&e.push.apply(e,r),e}),[])}"func"==e.type&&e.arguments&&e.arguments.forEach((e=>{pe(e,t)}))}))}function fe(e,t){return e.next(),(se(e)||[]).reduce(((e,n)=>{pe(n,t);let[r]=n;return r.value&&r.value.length&&e.push(...r.value),e}),[])}function me(e,t){const n=function(e=""){let t=0,n=1,r=1;return{curr:(n=0)=>e[t+n],end:()=>e.length<=t,info:()=>({index:t,col:n,line:r}),index:e=>void 0===e?t:t=e,next(){let i=e[t++];return"\n"==i?(r++,n=0):n++,i}}}(e),r=[];for(;!n.end();){let e=n.curr();if(F.white_space(e))n.next();else{if("/"==e&&"*"==n.curr(1))Q(n);else if(":"==e){let e=ae(n,t);e.selector&&r.push(e)}else if("@"==e&&"@keyframes"===Y(n,!0)){let e=J(n,t);r.push(e)}else if("@"!=e||Z(n,!0).includes(":")){if("<"==e)ee(n);else if(!F.white_space(e)){let e=ue(n,t);e.property&&r.push(e)}}else{let e=ce(n,t);e.name.length&&r.push(e)}n.next()}}return r}const[de,ge,ve]=[1,256,65536];function ye(e){let[t,n,r]=(e+"").replace(/\s+/g,"").replace(/[,\uff0cxX]+/g,"x").split("x").map((e=>parseInt(e)));const i=1==t||1==n?ve:ge,s=1==t&&1==n?ve:de,o={x:y(t||de,1,i),y:y(n||t||de,1,i),z:y(r||de,1,s)};return Object.assign({},o,{count:o.x*o.y*o.z,ratio:o.x/o.y})}function xe(e){return/^texture\w*$|^(fragment|vertex)$/.test(e)}function be(){return new r({type:"LineBreak",value:"\n"})}function _e(e){let t=e[0],n=e[e.length-1];for(;t&&t.isSymbol("(")&&n&&n.isSymbol(")");)t=(e=e.slice(1,e.length-1))[0],n=e[e.length-1];return e}function we(e){return _e(e).map((e=>e.value)).join("")}function ke(e,t){return`url("data:image/svg+xml;utf8,${encodeURIComponent(e)+(t?`#${t}`:"")}")`}function $e(e){const t='xmlns="http://www.w3.org/2000/svg"',n='xmlns:xlink="http://www.w3.org/1999/xlink"';return e.includes("${e}`),e.includes("xmlns")||(e=e.replace(/])/,`e.attrs.id===t&&e.name===n))}append(e){this.isTextNode()||this.body.push(e)}merge(e){for(let[t,n]of Object.entries(e.attrs))this.attrs[t]=n;Array.isArray(e.body)&&this.body.push(...e.body)}attr(e,t){if(!this.isTextNode())return void 0===t?this.attrs[e]:this.attrs[e]=t}toString(){if(this.isTextNode())return this.body;let e=[""],t=[];for(let[t,n]of Object.entries(this.attrs))e.push(`${t}="${n}"`);for(let e of this.body)t.push(e.toString());return`<${this.name}${e.join(" ")}>${t.join("")}`}}function Ee(e,t){return`${e}:${t};`}function Te(e){const t=e.value.map((e=>"block"===e.type?Te(e):Ee(e.name,e.value))).join("");return`${e.name}{${t}}`}function Ae(e,t,n,r){let i;if(t||(t=new je("root")),"block"===e.type)if("style"===e.name){if(Array.isArray(e.value)){let n=new je("style"),r=[];for(let t of e.value)"block"===t.type&&r.push(Te(t));n.append(r.join("")),t.append(n)}}else{let n=new je(e.name);r||(r=n).attr("xmlns","http://www.w3.org/2000/svg");for(let t of e.value){let s=Ae(t,n,e,r);s&&(i=s)}if(e.inline){let t=e.value.find((e=>"statement"===e.type&&"id"===e.name));t?i=t.value:(i=Se(e.name),n.attr("id",i))}let s=r.find(n);s?s.merge(n):t.append(n)}if("statement"===e.type){if(n&&/^(text|tspan|textPath)$/i.test(n.name)&&"content"===e.name){let n=new je("text-node",e.value);t.append(n)}else if(e.name.startsWith("style ")){let n=(e.name.split("style ")[1]||"").trim();if(n.length){let r=t.attr("style")||"";t.attr("style",r+Ee(n,e.value))}}else{let n=e.value;if(n&&"block"===n.type){let t=Ae(e.value,r,e,r);n=`url(#${t})`,"xlink:href"!==e.name&&"href"!==e.name||(n=`#${t}`)}t.attr(e.name,n),e.name.includes("xlink:")&&r.attr("xmlns:xlink","http://www.w3.org/1999/xlink")}}return n?i:r.toString()}function Re(e){return Ae(e)}function ze(e){let t=i(f(e)),n={},r=!1;for(;t.next();){let{prev:e,curr:i,next:s}=t.get(),o=r&&(i.isWord()||i.isSymbol())&&e&&e.isNumber()&&!s;if(i.isNumber())n.value=Number(i.value),r=!0;else{if(!o)break;n.unit=i.value}}return n}function Pe(e){return(...t)=>{let n=[],r=[];for(let e of t){let{unit:t,value:i}=ze(e);void 0!==t&&n.push(t),void 0!==i&&r.push(i)}let i=e(...r),s=n.find((e=>void 0!==e));return void 0===s?i:Array.isArray(i)?i.map((e=>e+s)):i+s}}function Ce(e){return(...t)=>{let n=t.map((e=>String(e).charCodeAt(0))),r=e(...n);return Array.isArray(r)?r.map((e=>String.fromCharCode(e))):String.fromCharCode(r)}}const Ne={\u03c0:Math.PI,gcd:(e,t)=>{for(;t;)[e,t]=[t,e%t];return e}},Me={"^":7,"*":6,"/":6,"\xf7":6,"%":6,"&":5,"|":5,"+":4,"-":4,"<":3,"<<":3,">":3,">>":3,"=":3,"==":3,"\u2264":3,"<=":3,"\u2265":3,">=":3,"\u2260":3,"!=":3,"\u2227":2,"&&":2,"\u2228":2,"||":2,"(":1,")":1};function Le(e,t,n=[]){let r=[];for(;e.length;){let{name:s,value:o,type:l}=e.shift();if("variable"===l){let e=t[o];k(e)&&(e=Math[o]),k(e)&&(e=We(o,t)),k(e)&&/^\-\D/.test(o)&&(e=We("-1"+o.substr(1),t)),void 0===e&&(e=0),"number"!=typeof e&&(n.push(e),(i=n)[0]==i[2]&&i[1]==i[3]?(e=0,n=[]):e=Le(Ie(e),t,n)),r.push(e)}else if("function"===l){let e=!1;/^\-/.test(s)&&(e=!0,s=s.substr(1));let n,i=o.map((e=>Le(e,t))),l=s.split(".");for(;n=l.pop();){if(!n)continue;let e=t[n]||Math[n];i="function"==typeof e?Array.isArray(i)?e(...i):e(i):0}e&&(i*=-1),r.push(i)}else if(/\d+/.test(o))r.push(o);else{let e=r.pop(),t=r.pop();r.push(Oe(o,Number(t),Number(e)))}}var i;return Number(r[0])||0}function Ie(e){let t=function(e){let t=String(e),n=[],r="";for(let e=0;e=]$/.test(s.value))s.value+=i;else if(/^[|&<>]$/.test(i)&&s&&s.value==i)s.value+=i;else if("-"==i&&"e"==t[e-1])r+=i;else if(n.length||r.length||!/[+-]/.test(i)){let{type:e,value:t}=s||{};"operator"==e&&!r.length&&/[^()]/.test(i)&&/[^()]/.test(t)?r+=i:(r.length&&(n.push({type:"number",value:r}),r=""),n.push({type:"operator",value:i}))}else r+=i}else/\S/.test(i)&&(","==i?(n.push({type:"number",value:r}),r="",n.push({type:"comma",value:i})):"!"==i?(n.push({type:"number",value:r}),n.push({type:"operator",value:i}),r=""):r+=i)}return r.length&&n.push({type:"number",value:r}),n}(e);const n=[],r=[];for(let e=0;e=Me[s];){let e=n.pop();/[()]/.test(e)||r.push({type:"operator",value:e})}n.push(s)}}for(;n.length;)r.push({type:"operator",value:n.pop()});return r}function Oe(e,t,n){switch(e){case"+":return t+n;case"-":return t-n;case"*":return t*n;case"%":return t%n;case"|":return t|n;case"&":return t&n;case"<":return t":return t>n;case"^":return Math.pow(t,n);case"\xf7":case"/":return t/n;case"=":case"==":return t==n;case"\u2264":case"<=":return t<=n;case"\u2265":case">=":return t>=n;case"\u2260":case"!=":return t!=n;case"\u2227":case"&&":return t&&n;case"\u2228":case"||":return t||n;case"<<":return t<>":return t>>n}}function We(e,t){let[n,r,i]=e.match(/([\d.\-]+)(.*)/)||[],s=t[i];return void 0===s?s:"number"==typeof s?Number(r)*s:r*Le(Ie(s),t)}function Ue(e,t){return Le(Ie(e),Object.assign({},Ne,t))}var De=new class{constructor(){this.cache={}}clear(){this.cache={}}set(e,t){if(w(e))return"";let n=this.getKey(e);return this.cache[n]=t}get(e){let t=this.getKey(e);return this.cache[t]}getKey(e){return z("string"==typeof e?e:JSON.stringify(e))}};function Fe(e,t){return(...n)=>{let r=e+n.join("-");return De.get(r)||De.set(r,t(...n))}}function Be(e,t){return{type:e,value:t}}const Xe=Fe("build_range",(e=>{let t=function(e){let t=String(e),n=[],r=[];if(!t.startsWith("[")||!t.endsWith("]"))return n;for(let e=1;e{if("char"==e)return t;let[n,r]=t,i=!1;n>r&&([n,r]=[r,n],i=!0);let s=Ce(x)(n,r);return i&&s.reverse(),s}))}));function He(e){return(...t)=>e(...U(t,(e=>String(e).startsWith("[")?Xe(e):e)))}class qe{constructor(e){this.prev=this.next=null,this.data=e}}class Ye{constructor(e=20){this._limit=e,this._size=0}push(e){this._size>=this._limit&&(this.root=this.root.next,this.root.prev=null);let t=new qe(e);this.root?(t.prev=this.tail,this.tail.next=t,this.tail=t):this.root=this.tail=t,this._size++}last(e=1){let t=this.tail;for(;--e&&t.prev;)t=t.prev;return t.data}}class Ve{constructor(e){var t;this.p=(t=e([151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180]),[].concat(t,t))}grad(e,t,n,r){let i=15&e,s=i<8?t:n,o=i<4?n:12==i||14==i?t:r;return(0==(1&i)?s:-s)+(0==(2&i)?o:-o)}noise(e,t,n){let{p:r,grad:i}=this,[s,o,l]=[e,t,n].map((e=>255&Math.floor(e)));[e,t,n]=[e,t,n].map((e=>e-Math.floor(e)));let[a,u,c]=[e,t,n].map((e=>e*e*e*(e*(6*e-15)+10))),h=r[s]+o,p=r[h]+l,f=r[h+1]+l,m=r[s+1]+o,d=r[m]+l,g=r[m+1]+l;return N(c,N(u,N(a,i(r[p],e,t,n),i(r[d],e-1,t,n)),N(a,i(r[f],e,t-1,n),i(r[g],e-1,t-1,n))),N(u,N(a,i(r[p+1],e,t,n-1),i(r[d+1],e-1,t,n-1)),N(a,i(r[f+1],e,t-1,n-1),i(r[g+1],e-1,t-1,n-1))))}}function Ze(e){let t,n=i(f(e)),r={},s=[],o=!1;for(;n.next();){let{prev:e,curr:i,next:l}=n.get();if(i.isSymbol(":")&&!t)t=Ke(s),s=[];else if(i.isSymbol(";")&&t)r[t]=Ge(t,Ke(s),o),s=[],t=null,o=!1;else if(!i.isSymbol(";")){let n=e&&e.isSymbol("-"),r=l&&l.isSymbol("-"),a=i.isSymbol("-");t||s.length||!a||n||r||l&&l.isSymbol(":")?s.push(i):o=!0}}return s.length&&t&&(r[t]=Ge(t,Ke(s),o)),r}function Ge(e,t,n){return["fill-rule","fill"].includes(e)?t:n?`-1 * (${t})`:t}function Ke(e){return e.map((e=>e.value)).join("")}function Je(e,t){let n=[],r=[],s=[],o=[];if($(e))return n;let l=i(f(e));for(;l.next();){let{prev:e,curr:i,next:u}=l.get();i.isSymbol("(")&&s.push(i.value),i.isSymbol(")")&&s.pop(),"open"===i.status&&o.push(i.value),"close"===i.status&&o.pop(),a=i,!(t?a.isSymbol(","):a.isSymbol(",")||a.isSpace())||s.length||o.length?r.push(i):(n.push(Qe(r)),r=[])}var a;return r.length&&n.push(Qe(r)),n}function Qe(e){return e.map((e=>e.value)).join("")}const et=["auto","reverse"],tt=["deg","rad","grad","turn"];function nt(e){let t=i(f(e)),n=!1,r="",s={direction:"",angle:""};for(;t.next();){let{prev:e,curr:i,next:o}=t.get();if(i.isWord()&&et.includes(i.value))s.direction=i.value,n=!0;else if(i.isNumber())s.angle=Number(i.value),n=!0;else if(i.isWord()&&e&&e.isNumber()&&tt.includes(i.value))r=i.value;else if(i.isSpace()&&""!==s.direction&&""!==s.angle)break}return n||(s.direction="auto"),function(e,t){let{angle:n}=e;""===n&&(n=0);"rad"===t&&(n/=Math.PI/180);"grad"===t&&(n*=.9);"turn"===t&&(n*=360);return Object.assign({},e,{angle:n})}(s,r)}const{cos:rt,sin:it,abs:st,atan2:ot,PI:lt}=Math,at=P((e=>ft(Ze(e),{min:3,max:3600}))),ut={circle:()=>at`split:180;scale:.99`,triangle:()=>at`rotate:30;scale:1.1;move:0 .2`,pentagon:()=>at`split:5;rotate:54`,hexagon:()=>at`split:6;rotate:30;scale:.98`,octagon:()=>at`split:8;rotat:22.5;scale:.99`,star:()=>at`split:10;r:cos(5t);rotate:-18;scale:.99`,infinity:()=>at`split:180;scale:.99;x:cos(t)*.99 / (sin(t)^2 + 1);y:x * sin(t)`,heart:()=>at`split:180;rotate:180;a:cos(t)*13/18 - cos(2t)*5/18;b:cos(3t)/18 + cos(4t)/18;x:(.75 * sin(t)^3) * 1.2;y:(a - b + .2) * -1.1`,bean:()=>at`split:180;r:sin(t)^3 + cos(t)^3;move:-.35 .35;`,bicorn:()=>at`split:180;x:cos(t);y:sin(t)^2 / (2 + sin(t)) - .5`,drop:()=>at`split:180;rotate:90;scale:.95;x:sin(t);y:(1 + sin(t)) * cos(t) / 1.6`,fish:()=>at`split:240;x:cos(t) - sin(t)^2 / sqrt(2) - .04;y:sin(2t)/2`,whale:()=>at`split:240;rotate:180;R:3.4 * (sin(t)^2 - .5) * cos(t);x:cos(t) * R + .75;y:sin(t) * R * 1.2`,windmill:()=>at`split:18;R:seq(.618, 1, 0);T:seq(t-.55, t, t);x:R * cos(T);y:R * sin(T)`,vase:()=>at`split:240;scale:.3;x:sin(4t) + sin(t) * 1.4;y:cos(t) + cos(t) * 4.8 + .3`,clover:(e=3)=>(4==(e=y(e,3,5))&&(e=2),at`split:240;r:cos(${e}t);scale:.98`),hypocycloid:(e=3)=>(e=y(e,3,5),at`split:240;scale:${[0,0,0,.34,.25,.19][e]};k:${e};x:(k-1)*cos(t) + cos((k-1)*t);y:(k-1)*sin(t) - sin((k-1)*t)`),bud:(e=3)=>(e=y(e,3,10),at`split:240;scale:.8;r:1 + .2 * cos(${e}t)`)};class ct{constructor(e,t,n){this.x=e,this.y=t,this.extra=n}valueOf(){return this.x+" "+this.y}toString(){return this.valueOf()}}function ht(e,t,n,r,i){let s=180*ot(t+r,e-n)/lt;return"reverse"===i.direction&&(s-=180),i.direction||(s=90),i.angle&&(s+=i.angle),s}function pt(e,t,n){let[r,i=r]=Je(n).map(Number);return[e*r,t*i]}function ft(e,{min:t,max:n}){let r=y(parseInt(e.vertices||e.points||e.split)||0,t,n),i=$(e.x)?"cos(t)":e.x,s=$(e.y)?"sin(t)":e.y,o=$(e.r)?"":e.r,{unit:l,value:a}=ze(o);return l&&!e[l]&&"t"!==l&&($(e.unit)&&(e.unit=l),o=e.r=a),e.degree&&(e.rotate=e.degree),e.origin&&(e.move=e.origin),function(e,t){"function"==typeof arguments[0]&&(t=e,e={}),t||(t=e=>[rt(e),it(e)]);let n,r,i=e.split||180,s=e.turn||1,o=e.frame,l=e.fill||e["fill-rule"],a=nt(e.direction||e.dir||""),u=e.unit,c=2*lt*s/i,h=[],p=void 0===e.scale?1:e.scale,f=([e,t,n=0,r=0])=>{if("evenodd"==e||"nonzero"==e)return h.push(new ct(e,"",""));let[i,s]=pt(e,-t,p),[o,l]=pt(n,-r,p),c=ht(i,s,o,l,a);void 0!==u&&"%"!==u?"none"!==u&&(i+=u,s+=u):(i=50*(i+1)+"%",s=50*(s+1)+"%"),h.push(new ct(i,s,c))};"nonzero"!=l&&"evenodd"!=l||f([l,"",""]);for(let e=0;e1&&(e*=2),0==e&&(e=.002);for(let n=0;n{let l=Object.assign({},e,{t,\u03b8:t,i:n+1,seq:(...e)=>e.length?e[n%e.length]:"",range:(e,t=0)=>((e=Number(e)||0)>(t=Number(t)||0)&&([e,t]=[t,e]),e+st(t-e)/(r-1)*n)}),a=Ue(i,l),u=Ue(s,l),c=0,h=0;if(o){let e=Ue(o,l);0==e&&(e=1e-5),a=e*rt(t),u=e*it(t)}return e.rotate&&([a,u]=function(e,t,n){let r=-lt/180*n;return[e*rt(r)-t*it(r),t*rt(r)+e*it(r)]}(a,u,Number(e.rotate)||0)),e.move&&([a,u,c,h]=function(e,t,n){let[r,i=r]=Je(n).map(Number);return[e+(r||0),t-(i||0),r,i]}(a,u,e.move)),[a,u,c,h]}))}function mt(e,t){let n,r=[],i=[];for(;e.next();){let{curr:t,next:s}=e.get(),o=!i.length&&(!s||t.isSymbol(";")||s.isSymbol("}"));if(t.isSymbol("'",'"')&&("open"===t.status?i.push(t):i.pop(),s.isSymbol("}")&&!i.length&&(o=!0)),!i.length&&t.isSymbol("{")){let t=xt(r,(e=>e.isSpace()));if(!t.length)continue;let i=t.pop(),s=bt(...t,i);for(n=yt(dt(e,{type:"block",name:i,inline:!0,value:[]}),s);i=t.pop();)n=yt({type:"block",name:i,value:[n]},s);break}if("open"==t.status&&1==i.length||"close"==t.status&&!i.length||r.push(t),o)break}return r.length&&!n?t.value=vt(r):n&&(t.value=n),t}function dt(e,t){let n=[],r=[],i=t&&t.type||"",s=[];for(;e.next();){let{prev:o,curr:l,next:a}=e.get(),u=!a||l.isSymbol("}");if(l.isSymbol("(")&&s.push(l.value),l.isSymbol(")")&&s.pop(),_t(i)&&u){if(!a&&n.length&&!l.isSymbol("}")){"string"==typeof n[n.length-1].value&&(n[n.length-1].value+=";"+l.value)}t.value=n;break}if(l.isSymbol("{")){let i=xt(r,(e=>e.isSpace()));if(!i.length)continue;bt(t.name)&&(i=[vt(r)]);let s=i.pop(),o=bt(...i,t.name,s),l=yt(dt(e,{type:"block",name:s,value:[]}),o);for(;s=i.pop();)l=yt({type:"block",name:s,value:[l]},o);n.push(l),r=[]}else if(l.isSymbol(":")&&!s.length&&!gt(o,a)&&r.length){let s=xt(r,(e=>e.isSymbol(","))),o=mt(e,{type:"statement",name:"unkown",value:""}),l=Je(o.value),a=s.length>1&&l.length===s.length;s.forEach(((e,t)=>{let r=Object.assign({},o,{name:e});a&&(r.value=l[t]),n.push(r)})),_t(i)&&(t.value=n),r=[]}else l.isSymbol(";")?n.length&&r.length&&(n[n.length-1].value+=";"+vt(r),r=[]):r.push(l)}return n.length&&_t(i)&&(t.value=n),i?t:n}function gt(e,t){let n=e&&e.value,r=t&&t.value;return["xlink:actuate","xlink:arcrole","xlink:href","xlink:role","xlink:show","xlink:title","xlink:type","xml:base","xml:lang","xml:space"].includes(n+":"+r)}function vt(e){return e.filter(((t,n)=>!t.isSymbol(";","}")||n!==e.length-1)).map((e=>e.value)).join("")}function yt(e,t){let n=e.name||"",[r,...i]=n.split(/#/),s=i[i.length-1];return r&&s&&!t&&(e.name=r,e.value.push({type:"statement",name:"id",value:s})),e}function xt(e,t){let n=[],r=[];return e.forEach((e=>{t(e)?(n.push(vt(r)),r=[]):r.push(e)})),r.length&&n.push(vt(r)),n}function bt(...e){return e.some((e=>"style"===e))}function _t(e){return"block"===e}function wt(e){let t=e&&e.value&&e.value[0];return t&&"svg"===t.name&&_t(t.type)?wt(t):e}function kt(e,t){return wt(dt(i(f(e)),t||{type:"block",name:"svg",value:[]}))}function $t(e){let t=i(f(e)),n={},r={commands:[],valid:!0};for(;t.next();){let{curr:e}=t.get();if(!e.isSpace()&&!e.isSymbol(","))if(e.isWord())n.name&&(r.commands.push(n),n={}),n.name=e.value,n.value=[],"MmLlHhVvCcSsQqTtAaZz".includes(e.value)?"mlhvcsqtaz".includes(e.value)?n.type="relative":n.type="absolute":(n.type="unknown",r.valid=!1);else if(n.value){let t=e.value;e.isNumber()&&(t=Number(e.value)),n.value.push(t)}else n.name||(r.valid=!1)}return n.name&&r.commands.push(n),r}const St={name:"cssd-uniform-time","animation-name":"cssd-uniform-time-animation","animation-duration":31536e6,"animation-iteration-count":"infinite","animation-delay":"0s","animation-direction":"normal","animation-fill-mode":"none","animation-play-state":"running","animation-timing-function":"linear"};St.animation=`\n ${St["animation-duration"]}ms\n ${St["animation-timing-function"]} ${St["animation-delay"]} ${St["animation-iteration-count"]} ${St["animation-name"]}`;const jt={name:"cssd-uniform-mousex"},Et={name:"cssd-uniform-mousey"},Tt={name:"cssd-uniform-width"},At={name:"cssd-uniform-height"};var Rt=Object.freeze({__proto__:null,uniform_time:St,uniform_mousex:jt,uniform_mousey:Et,uniform_width:Tt,uniform_height:At});function zt(e){return S(((t,...n)=>{if(!n||!t)return"";let r=E(t()),i=r;/\D/.test(r)&&(i=Ue(r),0===i&&(i=r));let s=Math.random();return function(e,t){let[n,r=1]=String(e).split("x");n=y(Math.ceil(n)||1,1,65536),r=y(Math.ceil(r)||1,1,65536);let i=n*r,s=[],o=1;for(let e=1;e<=r;++e)for(let l=1;l<=n;++l)s.push(t(o++,l,e,i,n,r));return s}(i,((...e)=>n.map((t=>E(t(...e,s)))).join(","))).join(e)}))}function Pt(e,t,n){return e[t]||(e[t]=new Ye),e[t].push(n),n}function Ct(e){return-1*e}const Nt=b({i:({count:e})=>t=>e,y:({y:e})=>t=>e,x:({x:e})=>t=>e,z:({z:e})=>t=>e,I:({grid:e})=>t=>e.count,Y:({grid:e})=>t=>e.y,X:({grid:e})=>t=>e.x,Z:({grid:e})=>t=>e.z,id:({x:e,y:t,z:n})=>r=>j(e,t,n),n({extra:e}){let t=O(e);return e=>t?t[0]+(Number(e)||0):"@n"},nx({extra:e}){let t=O(e);return e=>t?t[1]+(Number(e)||0):"@nx"},ny({extra:e}){let t=O(e);return e=>t?t[2]+(Number(e)||0):"@ny"},N({extra:e}){let t=O(e);return e=>t?t[3]+(Number(e)||0):"@N"},m:zt(","),M:zt(" "),\u00b5:zt(""),p:({context:e,pick:t})=>He(((...n)=>{n.length||(n=e.last_pick_args||[]);let r=t(n);return e.last_pick_args=n,Pt(e,"last_pick",r)})),P({context:e,pick:t,position:n}){let r="P-counter"+n;return He(((...n)=>{let i=!0;n.length||(n=e.last_pick_args||[],i=!1);let s=e.last_pick,o=s?s.last(1):"";if(i&&(e[r]||(e[r]={}),o=e[r].last_pick),n.length>1){let e=n.findIndex((e=>e===o));-1!==e&&n.splice(e,1)}let l=t(n);return e.last_pick_args=n,i&&(e[r].last_pick=l),Pt(e,"last_pick",l)}))},pn({context:e,extra:t,position:n}){let r=O(t),i="pn-counter"+n+(r?O(r):"");return He(((...t)=>{e[i]||(e[i]=0),e[i]+=1;let n=t.length,[s=e[i]]=r||[],o=t[(s-1)%n];return Pt(e,"last_pick",o)}))},pd({context:e,extra:t,position:n,shuffle:r}){let i=O(t),s=i?O(i):"",o="pd-counter"+n+s,l="pd-values"+n+s;return He(((...t)=>{e[o]||(e[o]=0),e[o]+=1,e[l]||(e[l]=r(t||[]));let n=t.length,[s=e[o]]=i||[],a=(s-1)%n,u=e[l][a];return Pt(e,"last_pick",u)}))},lp:({context:e})=>(t=1)=>{let n=e.last_pick;return n?n.last(t):""},r:({context:e,rand:t})=>(...n)=>{let r=(n.every(_)?Ce:Pe)(t)(...n);return Pt(e,"last_rand",r)},rn({x:e,y:t,context:n,position:r,grid:i,extra:s,shuffle:o}){let l="noise-2d"+r,[a,u,c,h,p,f]=O(s)||[],m=a&&h;return(...r)=>{let[s,a=s,h=1,d=1]=r;1==r.length&&([s,a]=[0,s]),n[l]||(n[l]=new Ve(o)),h=y(h,0,1/0),d=y(d,0,1/0);let g=[s,a].every(_)?Ce:Pe,v=m?n[l].noise((u-1)/p*h,(c-1)/f*h,0):n[l].noise((e-1)/i.x*h,(t-1)/i.y*h,0),x=g(((e,t)=>function(e,t,n,r=1){let i=Math.sqrt(.5)*r,[s,o]=[-i,i];return N((e-s)/(o-s),t*r,n*r)}(v*d,e,t,d))),b=x(s,a);return Pt(n,"last_rand",b)}},lr:({context:e})=>(t=1)=>{let n=e.last_rand;return n?n.last(t):""},noise({context:e,grid:t,position:n,shuffle:r,...i}){let s={i:i.count,I:t.count,x:i.x,X:t.x,y:i.y,Y:t.y,z:i.z,Z:t.z};return(t,i,o=0)=>{let l="raw-noise-2d"+n;return e[l]||(e[l]=new Ve(r)),e[l].noise(Ue(t,s),Ue(i,s),Ue(o,s))}},stripe:()=>(...e)=>{let t,n=e.map(E),r=n.length,i=0,s=[];if(!r)return"";n.forEach((e=>{let[t,n]=Je(e);void 0!==n?s.push(n):i+=1}));let o=s.length?`(100% - ${s.join(" - ")}) / ${i}`:`100% / ${r}`;return n.map(((e,n)=>{if(s.length){let[n,r]=Je(e);return t=(t?t+" + ":"")+(void 0!==r?r:o),`${n} 0 calc(${t})`}return`${e} 0 ${100/r*(n+1)}%`})).join(",")},calc:()=>e=>Ue(E(e)),hex:()=>e=>parseInt(E(e)).toString(16),svg:S(((...e)=>{let t=e.map((e=>E(e()))).join(",");if(!t.startsWith("<")){t=Re(kt(t))}return ke($e(t))})),filter:S(((...e)=>{let t=e.map((e=>E(e()))),n=t.join(","),r=M("filter-");if(t.every((e=>/^[\d.]/.test(e)))){let[e=1,r=1,i,s]=t,[o,l=o]=Je(e);i=i?`numOctaves:${i};`:"",s=s?`seed:${s};`:"",n=`\n feTurbulence{type:fractalNoise;baseFrequency:${o} ${l};${i} ${s}} feDisplacementMap{in:SourceGraphic;scale:${r};}`}if(!n.startsWith("<")){n=Re(kt(n,{type:"block",name:"filter"}))}return ke($e(n).replace(/])/,`e=>`var(${E(e)})`,ut:()=>e=>`var(--${St.name})`,uw:()=>e=>`var(--${Tt.name})`,uh:()=>e=>`var(--${At.name})`,ux:()=>e=>`var(--${jt.name})`,uy:()=>e=>`var(--${Et.name})`,plot({count:e,context:t,extra:n,position:r,grid:i}){let s="offset-points"+r,o=O(n);return n=>{let[r=e,l,a,u=i.count]=o||[];if(!t[s]){let e=Ze(n);delete e.fill,delete e["fill-rule"],delete e.frame,e.points=u,t[s]=ft(e,{min:1,max:65536})}return t[s][r-1]}},shape:()=>Fe("shape-function",((e="",...t)=>{let n=[];if((e=String(e).trim()).length)if("function"==typeof ut[e])n=ut[e](t);else{let r=e,i=t.join(",");i.length&&(r=e+","+i),n=ft(Ze(r),{min:3,max:3600})}return`polygon(${n.join(",")})`})),doodle:()=>e=>e,shaders:()=>e=>e,canvas:()=>e=>e,pattern:()=>e=>e,invert:()=>e=>{let t=$t(e);return t.valid?t.commands.map((({name:e,value:t})=>{switch(e){case"v":return"h"+t.join(" ");case"V":return"H"+t.join(" ");case"h":return"v"+t.join(" ");case"H":return"V"+t.join(" ");default:return e+t.join(" ")}})).join(" "):e},flipH:()=>e=>{let t=$t(e);return t.valid?t.commands.map((({name:e,value:t})=>{switch(e){case"h":case"H":return e+t.map(Ct).join(" ");default:return e+t.join(" ")}})).join(" "):e},flipV:()=>e=>{let t=$t(e);return t.valid?t.commands.map((({name:e,value:t})=>{switch(e){case"v":case"V":return e+t.map(Ct).join(" ");default:return e+t.join(" ")}})).join(" "):e},flip(...e){let t=Nt.flipH(...e),n=Nt.flipV(...e);return e=>n(t(e))},reverse:(...e)=>e=>{let t=$t(e);return t.valid?t.commands.reverse().map((({name:e,value:t})=>e+t.join(" "))).join(" "):e}},{index:"i",col:"x",row:"y",depth:"z",rand:"r",pick:"p",stripes:"stripe",strip:"stripe",patern:"pattern",flipv:"flipV",fliph:"flipH",t:"ut","svg-filter":"filter","last-rand":"lr","last-pick":"lp",multiple:"m",multi:"m",rep:"\xb5",repeat:"\xb5",ms:"M",s:"I",size:"I",sx:"X","size-x":"X","size-col":"X","max-col":"X",sy:"Y","size-y":"Y","size-row":"Y","max-row":"Y",sz:"Z","size-z":"Z","size-depth":"Z","pick-by-turn":"pn","pick-n":"pn","pick-d":"pd",offset:"plot",Offset:"Plot",point:"plot",Point:"Plot",paint:"canvas"}),Mt={"4a0":[1682,2378],"2a0":[1189,1682],a0:[841,1189],a1:[594,841],a2:[420,594],a3:[297,420],a4:[210,297],a5:[148,210],a6:[105,148],a7:[74,105],a8:[52,74],a9:[37,52],a10:[26,37],b0:[1e3,1414],b1:[707,1e3],b2:[500,707],b3:[353,500],b4:[250,353],b5:[176,250],b6:[125,176],b7:[88,125],b8:[62,88],b9:[44,62],b10:[31,44],b11:[22,32],b12:[16,22],c0:[917,1297],c1:[648,917],c2:[458,648],c3:[324,458],c4:[229,324],c5:[162,229],c6:[114,162],c7:[81,114],c8:[57,81],c9:[40,57],c10:[28,40],c11:[22,32],c12:[16,22],d0:[764,1064],d1:[532,760],d2:[380,528],d3:[264,376],d4:[188,260],d5:[130,184],d6:[92,126],letter:[216,279],postcard:[100,148],poster:[390,540]},Lt={portrait:"p",pt:"p",p:"p",landscape:"l",ls:"l",l:"l"};let It=[];function Ot(e){if(!It.length){let e=new Set;if("undefined"!=typeof document)for(let t in document.head.style)t.startsWith("-")||e.add(t.replace(/[A-Z]/g,"-$&").toLowerCase());e.has("grid-gap")||e.add("grid-gap"),It=Array.from(e)}return e instanceof RegExp?It.filter((t=>e.test(t))):It}function Wt(e){let t=new RegExp(`\\-?${e}\\-?`);return Ot(t).map((e=>e.replace(t,""))).reduce(((e,t)=>(e[t]=t,e)),{})}const Ut=Wt("webkit"),Dt=Wt("moz");function Ft(e,t){return Ut[e]?`-webkit-${t} ${t}`:Dt[e]?`-moz-${t} ${t}`:t}const Bt={center:"50%",left:"0%",right:"100%",top:"50%",bottom:"50%"},Xt={center:"50%",top:"0%",bottom:"100%",left:"50%",right:"50%"};var Ht=b({size(e,{is_special_selector:t,grid:n}){let[r,i=r]=Je(e);Mt[r]&&([r,i]=function(e,t){e=String(e).toLowerCase();let[n,r]=Mt[e]||[];return"p"==Lt[t]&&([r,n]=[n,r]),[r,n].map((e=>e+"mm"))}(r,i));let s=`\n width:${r};height:${i};`;return t?"auto"!==r&&"auto"!==i||(s+=`aspect-ratio:${n.ratio};`):s+=`\n --internal-cell-width:${r};--internal-cell-height:${i};`,s},position(e,{extra:t}){let[n,r="50%"]=Je(e);n=Bt[n]||n,r=Xt[r]||r;const i="var(--internal-cell-width, 25%)",s="var(--internal-cell-height, 25%)";return`\n position:absolute;left:${n};top:${r};width:${i};height:${s};margin-left:calc(${i} / -2);margin-top:calc(${s} / -2);grid-area:unset;--plot-angle:${t||0};transform:rotate(${t||0}deg);`},grid(e,t){let[n,...r]=e.split("/").map((e=>e.trim()));return r=r.join(" / "),{grid:ye(n),size:r?this.size(r,t):""}},shape:Fe("shape-property",(e=>{let[t,...n]=Je(e);if("function"!=typeof ut[t])return"";let r="clip-path";return Ft(r,`${r}:polygon(${ut[t](...n).join(",")});`)+"overflow:hidden;"})),use(e){if(e.length>2)return e}},{"place-cell":"position",offset:"position"});const qt={even:e=>!(e%2),odd:e=>!!(e%2)};function Yt(e,t,n){for(let r=0;r<=n;++r)if(Ue(e,{n:r})==t)return!0}var Vt={at:({x:e,y:t})=>(n,r)=>e==n&&t==r,nth:({count:e,grid:t})=>(...n)=>n.some((n=>qt[n]?qt[n](e):Yt(n,e,t.count))),row:({y:e,grid:t})=>(...n)=>n.some((n=>qt[n]?qt[n](e):Yt(n,e,t.y))),col:({x:e,grid:t})=>(...n)=>n.some((n=>qt[n]?qt[n](e):Yt(n,e,t.x))),even:({count:e,grid:t,x:n,y:r})=>e=>qt.odd(n+r),odd:({count:e,grid:t,x:n,y:r})=>e=>qt.even(n+r),random:({random:e,count:t,x:n,y:r,grid:i})=>(s=.5)=>/\D/.test(s)?e()s=>!!Ue("("+s+")",{x:n,X:t.x,y:r,Y:t.y,i:e,I:t.count,random:i})};function Zt(e){return/^\:(host|doodle)/.test(e)}function Gt(e){return/^\:(container|parent)/.test(e)}function Kt(e){return Zt(e)||Gt(e)}const Jt={};for(let e of Object.getOwnPropertyNames(Math))Jt[e]=()=>(...t)=>"number"==typeof Math[e]?Math[e]:(t=t.map((e=>Ue(E(e)))),Math[e](...t));class Qt{constructor(e){this.tokens=e,this.rules={},this.props={},this.keyframes={},this.grid=null,this.is_grid_defined=!1,this.coords=[],this.doodles={},this.canvas={},this.pattern={},this.shaders={},this.reset(),this.custom_properties={},this.uniforms={}}reset(){this.styles={host:"",container:"",cells:"",keyframes:""},this.coords=[],this.doodles={},this.canvas={},this.pattern={},this.shaders={};for(let e in this.rules)e.startsWith("#c")&&delete this.rules[e]}add_rule(e,t){let n=this.rules[e];n||(n=this.rules[e]=[]),n.push.apply(n,L(t))}pick_func(e){return Nt[e]||Jt[e]}apply_func(e,t,n){let r=e(...L(t)),i=[];return n.forEach((e=>{let t=typeof e.value,n="number"===t||"string"===t;if(!e.cluster&&n)i.push(...Je(e.value,!0));else if("function"==typeof e)i.push(e);else if(!w(e.value)){let t=E(e.value);i.push(t)}})),i=i.filter((e=>!w(e)&&String(e).trim().length)),r(...L(i))}compose_aname(...e){return e.join("-")}compose_selector({x:e,y:t,z:n},r=""){return`#${j(e,t,n)}${r}`}is_composable(e){return["doodle","shaders","canvas","pattern"].includes(e)}read_var(e,t){let n=t.count,r=this.custom_properties[n]||{};if(void 0!==r[e]){let t=String(r[e]).trim();if("("==t[0]){")"===t[t.length-1]&&(t=t.substring(1,t.length-1))}return t.replace(/;+$/g,"")}return e}compose_argument(e,t,n=[],r){t.extra||(t.extra=[]),t.extra.push(n);let i=e.map((e=>{if("text"===e.type)return/^\-\-\w/.test(e.value)?r&&"@var"===r.name?e.value:this.read_var(e.value,t):e.value;if("func"===e.type){let r=e.name.substr(1),i=this.pick_func(r);if("function"==typeof i){if(this.check_uniforms(r),this.is_composable(r)){let n=E((e.arguments[0]||[])[0]);if(!w(n))switch(r){case"doodle":return this.compose_doodle(this.inject_variables(n,t.count));case"shaders":return this.compose_shaders(n,t);case"canvas":return this.compose_canvas(n,e.arguments.slice(1));case"pattern":return this.compose_pattern(n,t)}}t.position=e.position;let s=e.arguments.map((r=>i.lazy?(...n)=>this.compose_argument(r,t,n,e):this.compose_argument(r,t,n,e)));return this.apply_func(i,t,s)}return e.name}}));return t.extra.pop(),{cluster:e.cluster,value:i.length>=2?{value:i.join("")}:i[0]}}compose_doodle(e){let t=M("doodle");return this.doodles[t]=e,"${"+t+"}"}compose_shaders(e,{x:t,y:n,z:r}){let i=M("shader");return this.shaders[i]={id:"--"+i,shader:e,cell:j(t,n,r)},"${"+i+"}"}compose_pattern(e,{x:t,y:n,z:r}){let i=M("pattern");return this.pattern[i]={id:"--"+i,code:e,cell:j(t,n,r)},"${"+i+"}"}compose_canvas(e,t=[]){let n=e,r=t.map((e=>E(e[0]))).join(",");r.length&&(n=e+","+r);let i=M("canvas");return this.canvas[i]={code:n},"${"+i+"}"}check_uniforms(e){switch(e){case"ut":case"t":this.uniforms.time=!0;break;case"ux":this.uniforms.mousex=!0;break;case"uy":this.uniforms.mousey=!0;break;case"uw":this.uniforms.width=!0;break;case"uh":this.uniforms.height=!0}}inject_variables(e,t){let n=this.custom_properties[t];if(w(n))return e;let r=[];for(let[e,t]of Object.entries(n))r.push(`${e}:${t};`);return r.join("")+e}compose_value(e,t){if(!Array.isArray(e))return{value:"",extra:""};let n="";return{value:e.reduce(((e,r)=>{switch(r.type){case"text":e+=r.value;break;case"func":{let i=r.name.substr(1),s=this.pick_func(i);if("function"==typeof s)if(this.check_uniforms(i),this.is_composable(i)){let n=E((r.arguments[0]||[])[0]);if(!w(n))switch(i){case"doodle":e+=this.compose_doodle(this.inject_variables(n,t.count));break;case"shaders":e+=this.compose_shaders(n,t);break;case"pattern":e+=this.compose_pattern(n,t);break;case"canvas":e+=this.compose_canvas(n,r.arguments.slice(1))}}else{t.position=r.position;let i=r.arguments.map((e=>s.lazy?(...n)=>this.compose_argument(e,t,n,r):this.compose_argument(e,t,[],r))),o=this.apply_func(s,t,i);w(o)||(e+=o,o.extra&&(n=o.extra))}else e+=r.name}}return e}),""),extra:n}}compose_rule(e,t,n){let r,i=Object.assign({},t),s=e.property,o=e.value.reduce(((e,t)=>{let n=this.compose_value(t,i);return n&&(n.value&&e.push(n.value),n.extra&&(r=n.extra)),e}),[]),l=o.join(", ");if(/^animation(\-name)?$/.test(s)){if(this.props.has_animation=!0,Zt(n)){let e=St[s];e&&l&&(l=e+","+l)}if(i.count>1){let{count:e}=i;switch(s){case"animation-name":l=o.map((t=>this.compose_aname(t,e))).join(", ");break;case"animation":l=o.map((t=>{let n=(t||"").split(/\s+/);return n[0]=this.compose_aname(n[0],e),n.join(" ")})).join(", ")}}}"content"===s&&(/["']|^none$|^(var|counter|counters|attr|url)\(/.test(l)||(l=`'${l}'`)),"transition"===s&&(this.props.has_transition=!0);let a=`${s}:${l};`;if(a=Ft(s,a),"clip-path"===s&&(a+=";overflow:hidden;"),"width"!==s&&"height"!==s||Kt(n)||(a+=`--internal-cell-${s}:${l};`),"background"===s&&(l.includes("shader")||l.includes("canvas")||l.includes("pattern"))&&(a+="background-size:100% 100%;"),/^\-\-/.test(s)&&(this.custom_properties[t.count]||(this.custom_properties[t.count]={}),this.custom_properties[t.count][s]=l),/^@/.test(s)&&Ht[s.substr(1)]){let t=s.substr(1),o=Ht[t](l,{is_special_selector:Kt(n),grid:i.grid,extra:r});switch(t){case"grid":Zt(n)?a=o.size||"":(a="",this.is_grid_defined||(o=Ht[t](l,{is_special_selector:!0,grid:i.grid}),this.add_rule(":host",o.size||""))),this.grid=i.grid,this.is_grid_defined=!0;break;case"place-cell":case"position":case"offset":Zt(n)||(a=o);break;case"use":e.value.length&&this.compose(i,e.value),a="";break;default:a=o}}return a}pre_compose_rule(e,t){let n=Object.assign({},t),r=e.property;switch(r){case"@grid":{let t=e.value.reduce(((e,t)=>{let r=this.compose_value(t,n);return r&&r.value&&e.push(r.value),e}),[]).join(", "),i=r.substr(1),s=Ht[i](t,{});this.grid=s.grid;break}case"@use":e.value.length&&this.pre_compose(n,e.value)}}pre_compose(e,t){(t||this.tokens).forEach((t=>{switch(t.type){case"rule":this.pre_compose_rule(t,e);break;case"pseudo":Zt(t.selector)&&(t.styles||[]).forEach((t=>{this.pre_compose_rule(t,e)}))}}))}compose(e,t,n){this.coords.push(e),(t||this.tokens).forEach(((t,r)=>{if(t.skip)return!1;if(n&&this.grid)return!1;switch(t.type){case"rule":this.add_rule(this.compose_selector(e),this.compose_rule(t,e));break;case"pseudo":{t.selector.startsWith(":doodle")&&(t.selector=t.selector.replace(/^\:+doodle/,":host"));let n=Kt(t.selector);n&&(t.skip=!0),t.selector.split(",").forEach((r=>{let i=t.styles.map((t=>this.compose_rule(t,e,r))),s=n?r:this.compose_selector(e,r);this.add_rule(s,i)}));break}case"cond":{let n=Vt[t.name.substr(1)];if(n){let r=t.arguments.map((t=>this.compose_argument(t,e)));this.apply_func(n,e,r)&&this.compose(e,t.styles)}break}case"keyframes":this.keyframes[t.name]||(this.keyframes[t.name]=e=>`\n ${I(t.steps.map((t=>`\n ${t.name}{${I(t.styles.map((t=>this.compose_rule(t,e))))}}`)))}`)}}))}output(){for(let[e,t]of Object.entries(this.rules))if(Gt(e))this.styles.container+=`\n .container{${I(t)}}`;else{let n=Zt(e)?"host":"cells",r=I(t).trim(),i="host"===n?`${e}, .host`:e;this.styles[n]+=`${i}{${r}}`}return this.uniforms.time&&(this.styles.container+=`\n:host, .host{animation:${St.animation};}`,this.styles.keyframes+=`\n @keyframes ${St["animation-name"]}{from{--${St.name}:0} to{--${St.name}:${St["animation-duration"]/10}}}`),this.coords.forEach(((e,t)=>{for(let[i,s]of Object.entries(this.keyframes)){let o=this.compose_aname(i,e.count);this.styles.keyframes+=`\n ${n=0===t,r=`@keyframes ${i}{${s(e)}}`,n?"function"==typeof r?r():r:""} @keyframes ${o}{${s(e)}}`}var n,r})),{props:this.props,styles:this.styles,grid:this.grid,doodles:this.doodles,shaders:this.shaders,canvas:this.canvas,pattern:this.pattern,uniforms:this.uniforms}}}function en(e,t,n){let r=new Qt(e),i={};function s(e=0,t){return 1==arguments.length&&([e,t]=[0,e]),N(n(),e,t)}function o(...e){let t=e.reduce(((e,t)=>e.concat(t)),[]);return t[~~(n()*t.length)]}function l(e){let t=[...e],r=e.length;for(;r;){let e=~~(n()*r--),i=t[r];t[r]=t[e],t[e]=i}return t}r.pre_compose({x:1,y:1,z:1,count:1,context:{},grid:{x:1,y:1,z:1,count:1},random:n,rand:s,pick:o,shuffle:l});let{grid:a}=r.output();if(a&&(t=a),r.reset(),1==t.z)for(let e=1,a=0;e<=t.y;++e)for(let u=1;u<=t.x;++u)r.compose({x:u,y:e,z:1,count:++a,grid:t,context:i,random:n,rand:s,pick:o,shuffle:l});else for(let e=1,a=0;e<=t.z;++e)r.compose({x:1,y:1,z:e,count:++a,grid:t,context:i,random:n,rand:s,pick:o,shuffle:l});return r.output()}function tn(e,t,n){let r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}function nn(e,t){return e.includes(t)?e:t+"\n"+e}function rn(e,t,n,r){let i=De.get(e);if(i)return Promise.resolve(i);let s=document.createElement("canvas"),o=window.devicePixelRatio||1;t*=o,n*=o,s.width=t,s.height=n;let l=s.getContext("webgl2",{preserveDrawingBuffer:!0});if(!l)return Promise.resolve("");let a=nn(e.fragment||"","uniform vec2 u_resolution;");a=nn(a,"uniform float u_time;"),a=nn(a,"uniform float u_timeDelta;"),a=nn(a,"uniform int u_frameIndex;"),a=nn(a,"uniform vec2 u_seed;"),e.textures.forEach((e=>{let t=`uniform sampler2D ${e.name};`;a=nn(a,t)}));/(^|[^\w\_])void\s+mainImage\(\s*out\s+vec4\s+fragColor,\s*in\s+vec2\s+fragCoord\s*\)/gm.test(a)&&(a=`// https://www.shadertoy.com/howto\n\n#define iResolution vec3(u_resolution, 0)\n#define iTime u_time\n#define iTimeDelta u_timeDelta\n#define iFrame u_frameIndex\n\n${e.textures.map(((e,t)=>`#define iChannel${t} ${e.name}`)).join("\n")}\n${a}\nvoid main(){mainImage(FragColor, gl_FragCoord.xy);}`);let u=function(e,t,n){let r=tn(e,e.VERTEX_SHADER,t),i=tn(e,e.FRAGMENT_SHADER,n),s=e.createProgram();return e.attachShader(s,r),e.attachShader(s,i),e.linkProgram(s),e.getProgramParameter(s,e.LINK_STATUS)||(console.warn("Link failed:"+e.getProgramInfoLog(s)),console.warn("vs info-log:"+e.getShaderInfoLog(r)),console.warn("fs info-log:"+e.getShaderInfoLog(i))),s}(l,e.vertex||"#version 300 es\n in vec4 position;void main(){gl_Position = position;}","#version 300 es\n precision highp float;out vec4 FragColor;"+a),c=l.getAttribLocation(u,"position"),h=l.createBuffer();l.bindBuffer(l.ARRAY_BUFFER,h);l.bufferData(l.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,-1,1,1,-1,1,1,-1]),l.STATIC_DRAW),l.enableVertexAttribArray(c),l.vertexAttribPointer(c,2,l.FLOAT,!1,0,0),l.viewport(0,0,l.drawingBufferWidth,l.drawingBufferHeight),l.clearColor(0,0,0,0),l.clear(l.COLOR_BUFFER_BIT),l.useProgram(u);const p=l.getUniformLocation(u,"u_resolution");l.uniform2fv(p,[t,n]),e.textures.forEach(((e,t)=>{!function(e,t,n){const r=e.createTexture();e.activeTexture(e["TEXTURE"+n]),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!0),e.bindTexture(e.TEXTURE_2D,r),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR)}(l,e.value,t),l.uniform1i(l.getUniformLocation(u,e.name),t)}));const f=l.getUniformLocation(u,"u_seed");f&&l.uniform2f(f,z(r)/1e16,Math.random());const m=l.getUniformLocation(u,"u_time"),d=l.getUniformLocation(u,"u_frameIndex"),g=l.getUniformLocation(u,"u_timeDelta");if(m||g||d){let t=0,n=0;return Promise.resolve(De.set(e,(e=>(l.clear(l.COLOR_BUFFER_BIT),m&&l.uniform1f(m,e/1e3),d&&l.uniform1i(d,t++),g&&(l.uniform1f(g,(n-e)/1e3),n=e),l.drawArrays(l.TRIANGLES,0,6),s.toDataURL()))))}return l.drawArrays(l.TRIANGLES,0,6),Promise.resolve(De.set(e,s.toDataURL()))}function sn(e,t){let n=[];for(;e.next();){let{curr:t,next:r}=e.get(),i=!r||t.isSymbol(";")||r.isSymbol("}");if(n.push(t),i)break}return n.length&&(t.value=ln(n)),t}function on(e,t){let n=[],r=[],i=t&&t.type||"",s=[];for(;e.next();){let{prev:o,curr:l,next:a}=e.get(),u=!a||l.isSymbol("}");if("block"===i&&u){a||!n.length||l.isSymbol("}")||(n[n.length-1].value+=";"+l.value),t.value=n;break}if(l.isSymbol("{")&&r.length&&!s.length){let t=an(r);if(!t.length)continue;let i=on(e,{type:"block",name:"unkown",value:[]});t.forEach((e=>{let t=Object.assign({},i,{name:e.name,args:e.args});n.push(t)})),r=[]}else if(l.isSymbol(":")&&r.length&&!s.length){let s=ln(r);n.push(sn(e,{type:"statement",name:s,value:""})),"block"==i&&(t.value=n),r=[]}else l.isSymbol(";")?n.length&&r.length&&(n[n.length-1].value+=";"+ln(r),r=[]):(l.isSymbol("(")&&s.push(l),l.isSymbol(")")&&s.pop(),r.push(l))}return n.length&&"block"==i&&(t.value=n),i?t:n}function ln(e){return e.filter(((t,n)=>!t.isSymbol(";")||n!==e.length-1)).map((e=>e.value)).join("")}function an(e){let t=i(e),n=[],r="",s=[],o=[],l=[];for(;t.next();){let{curr:e,next:i}=t.get();!r.length&&e.isWord()?r=e.value:e.isSymbol("(")?(l.length&&o.push(e.value),l.push(e)):e.isSymbol(")")?(l.pop(),l.length?o.push(e.value):o.length&&(s.push(o.join("")),o=[])):e.isSymbol(",")?l.length?(s.push(o.join("")),o=[]):(o.length&&(s.push(o.join("")),o=[]),r&&(n.push({name:r,args:s}),r="",s=[],o=[])):o.push(e.value)}return r&&n.push({name:r,args:s}),n.filter(((e,t,n)=>n.findIndex((t=>t.name===e.name&&e.args.join("")==t.args.join("")))===t))}function un(e){return on(i(f(e)))}function cn(e,t){if("fill"===e.name){let{r:n,g:r,b:i,a:s}=t.get_rgba_color(e.value);return{type:"statement",value:`\ncolor = vec4(${hn(n/255)}, ${hn(r/255)}, ${hn(i/255)}, ${hn(s)});`}}return"grid"==e.name?{type:"grid",value:e.value}:{type:"statement",value:""}}function hn(e){return String(e).includes(".")?e:e+".0"}function pn(e,t){let n=un(e),r=[],i={x:1,y:1};return n.forEach((e=>{if("statement"===e.type){let n=cn(e,t);"statement"==n.type&&r.push(n.value),"grid"===n.type&&(i=function(e){let[t,n=t]=String(e+"").replace(/\s+/g,"").replace(/[,\uff0cxX]+/g,"x").split("x").map((e=>parseInt(e)));return(!t||t<1)&&(t=1),(!n||n<1)&&(n=1),{x:t,y:n}}(n.value))}else"block"===e.type&&r.push(function(e,t){if("match"===e.name){let n=e.args[0],r=[];return e.value.forEach((e=>{let n=cn(e,t);"statement"==n.type&&r.push(n.value)})),`\n if (${n}){${r.join("")}}`}return""}(e,t))})),function(e,t){return`\n vec3 mapping(vec2 uv, vec2 grid){vec2 _grid = 1.0/grid;float x = ceil(uv.x/_grid.x);float y = ceil(grid.y - uv.y/_grid.y);float i = x + (y - 1.0) * y;return vec3(x, y, i);} vec4 getColor(float x, float y, float i, float I, float X, float Y, float t){vec4 color = vec4(0, 0, 0, 0);${e} return color;} void main(){vec2 uv = gl_FragCoord.xy/u_resolution.xy;vec2 grid = vec2(${t.x}, ${t.y});vec3 p = mapping(uv, grid);FragColor = getColor(p.x, p.y, p.z, grid.x * grid.y, grid.x, grid.y, u_time);}`}(r.join(""),i)}const fn=C();function mn(e){let t=De.get(e);if(t)return Promise.resolve(t);let n=fn("css-doodle-paint"),r=function(e,t){(t=R(t)).includes("paint(")||(t=`\n paint(ctx,{width, height}, props){${t}}`);return`\n registerPaint('${e}', class{${t}})\n`}(n,e),i=new Blob([r],{type:"text/javascript"});try{CSS.paintWorklet&&CSS.paintWorklet.addModule(URL.createObjectURL(i))}catch(e){}return Promise.resolve(De.set(e,`paint(${n})`))}var dn=globalThis,gn=Math,vn=[],yn=256,xn=gn.pow(yn,6),bn=gn.pow(2,52),_n=2*bn,wn=255;function kn(e,t,n){var r=[],i=En(jn((t=1==t?{entropy:!0}:t||{}).entropy?[e,Tn(vn)]:null==e?function(){try{var e;return e=new Uint8Array(yn),(dn.crypto||dn.msCrypto).getRandomValues(e),Tn(e)}catch(e){var t=dn.navigator,n=t&&t.plugins;return[+new Date,dn,n,dn.screen,Tn(vn)]}}():e,3),r),s=new $n(r),o=function(){for(var e=s.g(6),t=xn,n=0;e=_n;)e/=2,t/=2,n>>>=1;return(e+n)/t};return o.int32=function(){return 0|s.g(4)},o.quick=function(){return s.g(4)/4294967296},o.double=o,En(Tn(s.S),vn),(t.pass||n||function(e,t,n,r){return r&&(r.S&&Sn(r,s),e.state=function(){return Sn(s,{})}),n?(gn.random=e,t):e})(o,i,"global"in t?t.global:this==gn,t.state)}function $n(e){var t,n=e.length,r=this,i=0,s=r.i=r.j=0,o=r.S=[];for(n||(e=[n++]);ifunction(e,t){return"undefined"==typeof getComputedStyle?"":getComputedStyle(e).getPropertyValue(t).trim().replace(/^\(|\)$/g,"")}(this,e),get_rgba_color:e=>function(e,t){let n=e.querySelector("#defs");return n?(n.style.color=t,function(e){let[t,n,r,i=1]=e.replace(/rgba?\((.+)\)/,((e,t)=>t)).split(/,\s*/);return{r:t,g:n,b:r,a:i}}(getComputedStyle(n).color)):{r:0,g:0,b:0,a:1}}(this.shadowRoot,e)}}connectedCallback(e){this.innerHTML?this.load(e):setTimeout((()=>this.load(e)))}disconnectedCallback(){this.cleanup()}cleanup(){De.clear();for(let e of this.animations)e.cancel();this.animations=[]}update(e){this.cleanup();let t=this.get_use();e||(e=R(this.innerHTML)),this.innerHTML=e,this.grid_size||(this.grid_size=this.get_grid());let{x:n,y:r,z:i}=this.grid_size;const s=this.generate(me(t+e,this.extra));if(!this.shadowRoot.innerHTML)return Object.assign(this.grid_size,s.grid),this.build_grid(s,s.grid);if(s.grid){let{x:e,y:t,z:o}=s.grid;if(n!==e||r!==t||i!==o)return Object.assign(this.grid_size,s.grid),this.build_grid(s,s.grid);Object.assign(this.grid_size,s.grid)}else{let s=this.get_grid(),{x:o,y:l,z:a}=s;if(n!==o||r!==l||i!==a)return Object.assign(this.grid_size,s),this.build_grid(this.generate(me(t+e,this.extra)),s)}let o=this.replace(s);this.set_content(".style-keyframes",o(s.styles.keyframes)),s.props.has_animation&&(this.set_content(".style-cells",""),this.set_content(".style-container","")),setTimeout((()=>{this.set_content(".style-container",o(Pn(this.grid_size)+s.styles.host+s.styles.container)),this.set_content(".style-cells",o(s.styles.cells))}))}get grid(){return Object.assign({},this.grid_size)}set grid(e){this.attr("grid",e),this.connectedCallback(!0)}get seed(){return this._seed_value}set seed(e){this.attr("seed",e),this.connectedCallback(!0)}get use(){return this.attr("use")}set use(e){this.attr("use",e),this.connectedCallback(!0)}get_grid(){return ye(this.attr("grid"))}get_use(){let e=this.attr("use")||"";return e&&(e=`@use:${e};`),e}attr(e,t){return 1===arguments.length?this.getAttribute(e):2===arguments.length?(this.setAttribute(e,t),t):void 0}generate(e){let t=this.get_grid(),n=this.attr("seed")||this.attr("data-seed");w(n)&&(n=Date.now()),n=String(n),this._seed_value=n;let r=this.random=kn(n);return this.compiled=en(e,t,r)}doodle_to_image(e,t,n){"function"==typeof t&&(n=t,t=null);let r=me(e=":doodle{width:100%;height:100%}"+e,this.extra),i=ye({}),s=en(r,i,this.random),o=s.grid?s.grid:i;const{keyframes:l,host:a,container:u,cells:c}=s.styles;let h=this.replace(s),p=Nn(o);h(`\n
${p}
`).then((e=>{let t=`data:image/svg+xml;base64,${window.btoa(unescape(encodeURIComponent(e)))}`;A()&&T(t),n(t)}))}pattern_to_image({code:e,cell:t,id:n},r){let i=pn(e,this.extra);this.shader_to_image({shader:i,cell:t,id:n},r)}canvas_to_image({code:e},t){mn(e).then(t)}pause(){this.setAttribute("cssd-paused-animation",!0);for(let e of this.animations)e.pause()}resume(){this.removeAttribute("cssd-paused-animation");for(let e of this.animations)e.resume()}shader_to_image({shader:e,cell:t,id:n},r){let s="string"==typeof e?function(e){let t,n,r=i(_e(f(e,{preserveLineBreak:!0,ignoreInlineComment:!0}))),s=[],o=[],l={textures:[]};for(;r.next();){let{curr:e,next:i}=r.get();if(e.isSymbol("{")){if(s.length)o.push(e);else{let n=we(o);xe(n)?(t=n,o=[]):o.push(e)}s.push("{")}else if(e.isSymbol("}"))if(s.pop(),!s.length&&t){let e=we(o);t&&e.length&&(t.startsWith("texture")?l.textures.push({name:t,value:e}):l[t]=e,o=[]),t=null}else o.push(e);else $(n)||n==e.pos[1]||(o.push(be()),n=null),e.isWord()&&e.value.startsWith("#")&&(o.push(be()),n=i.pos[1]),o.push(e)}return $(l.fragment)&&(l.fragment=we(o),l.textures=l.textures||[]),l}(e):e,o=this.doodle.getElementById(t);const l=this.seed,a=e=>{o.style.setProperty(n,`url(${e})`)},u=e=>{if("function"==typeof e){let t=function(e){let t,n=0,r=0,i=0,s=!1;function o(s){n||(n=s),e(n);let l=s-r;l1e3&&(l=i||1e3),r&&(n+=l),i=l,r=s,t=requestAnimationFrame(o)}return t=requestAnimationFrame(o),{resume(){t&&s&&(s=!1,t=requestAnimationFrame(o))},pause(){t&&(cancelAnimationFrame(t),s=!0)},cancel(){t&&(s=!1,cancelAnimationFrame(t),t=null)}}}((t=>{a(e(t))}));return this.animations.push(t),""}a(e)};let{width:c,height:h}=o&&o.getBoundingClientRect()||{width:0,height:0},p=window.devicePixelRatio||1;if(!s.textures.length||s.ticker)rn(s,c,h,l).then(u).then(r);else{let e=s.textures.map((e=>new Promise((t=>{this.doodle_to_image(e.value,{width:c,height:h},(n=>{let r=new Image;r.width=c*p,r.height=h*p,r.onload=()=>t({name:e.name,value:r}),r.src=n}))}))));Promise.all(e).then((e=>{s.textures=e,rn(s,c,h,l).then(u).then(r)}))}}load(e){this.cleanup();let t=me(this.get_use()+R(this.innerHTML),this.extra),n=this.generate(t);e||this.hasAttribute("click-to-update")&&this.addEventListener("click",(e=>this.update())),this.grid_size=n.grid?n.grid:this.get_grid(),this.build_grid(n,this.grid_size)}replace({doodles:e,shaders:t,canvas:n,pattern:r}){let i=Object.keys(e),s=Object.keys(t),o=Object.keys(n),l=Object.keys(r),a=i.length+o.length+s.length+l.length;return u=>{if(!a)return Promise.resolve(u);let c=[].concat(i.map((t=>u.includes(t)?new Promise((n=>{this.doodle_to_image(e[t],(e=>n({id:t,value:e})))})):Promise.resolve(""))),s.map((e=>u.includes(e)?new Promise((n=>{this.shader_to_image(t[e],(t=>n({id:e,value:t})))})):Promise.resolve(""))),o.map((e=>u.includes(e)?new Promise((t=>{this.canvas_to_image(n[e],(n=>t({id:e,value:n})))})):Promise.resolve(""))),l.map((e=>u.includes(e)?new Promise((t=>{this.pattern_to_image(r[e],(n=>t({id:e,value:n})))})):Promise.resolve(""))));return Promise.all(c).then((e=>{for(let{id:t,value:n}of e){let e=`url(${n})`;/^canvas/.test(t)&&(e=n),/^shader|^pattern/.test(t)&&(e=`var(--${t})`),u=u.replaceAll("${"+t+"}",e)}return u}))}}build_grid(e,t){const{has_transition:n,has_animation:r}=e.props;let i=n||r;const{keyframes:s,host:o,container:l,cells:a}=e.styles;let u=Pn(t)+o+l,c=i?"":a;const{uniforms:h}=e;let p=this.replace(e);this.doodle.innerHTML=`\n${Nn(t)}`,this.set_content(".style-container",p(u)),i?setTimeout((()=>{this.set_content(".style-cells",p(a))}),50):this.set_content(".style-cells",p(a)),h.time&&this.register_uniform_time(),h.mousex||h.mousey?this.register_uniform_mouse(h):this.remove_uniform_mouse(),h.width||h.height?this.register_uniform_resolution(h):this.remove_uniform_resolution()}register_uniform_mouse(e){if(!this.uniform_mouse_callback){let{uniform_mousex:t,uniform_mousey:n}=Rt;this.uniform_mouse_callback=r=>{let i=r.detail||r;e.mousex&&this.style.setProperty("--"+t.name,i.offsetX),e.mousey&&this.style.setProperty("--"+n.name,i.offsetY)},this.addEventListener("pointermove",this.uniform_mouse_callback);let r=new CustomEvent("pointermove",{detail:{offsetX:0,offsetY:0}});this.dispatchEvent(r)}}remove_uniform_mouse(){if(this.uniform_mouse_callback){let{uniform_mousex:e,uniform_mousey:t}=Rt;this.style.removeProperty("--"+e.name),this.style.removeProperty("--"+t.name),this.removeEventListener("pointermove",this.uniform_mouse_callback),this.uniform_mouse_callback=null}}register_uniform_resolution(e){if(!this.uniform_resolution_observer){let{uniform_width:t,uniform_height:n}=Rt;const r=()=>{let r=this.getBoundingClientRect();e.width&&this.style.setProperty("--"+t.name,r.width),e.height&&this.style.setProperty("--"+n.name,r.height)};r(),this.uniform_resolution_observer=new ResizeObserver((e=>{for(let t of e){(t.contentBoxSize||t.contentRect)&&r()}})),this.uniform_resolution_observer.observe(this)}}remove_uniform_resolution(){if(this.uniform_resolution_observer){let{uniform_width:e,uniform_height:t}=Rt;this.style.removeProperty("--"+e.name),this.style.removeProperty("--"+t.name),this.uniform_resolution_observer.unobserve(this),this.uniform_resolution_observer=null}}register_uniform_time(){if(!window.CSS||!window.CSS.registerProperty)return!1;if(!this.is_uniform_time_registered){let{uniform_time:e}=Rt;try{CSS.registerProperty({name:"--"+e.name,syntax:"",initialValue:0,inherits:!0})}catch(e){}this.is_uniform_time_registered=!0}}export({scale:e,name:t,download:n,detail:r}={}){return new Promise(((i,s)=>{let o=An(this),l=this.doodle.innerHTML,{width:a,height:u}=this.getBoundingClientRect(),c=a*(e=parseInt(e)||1),h=u*e,p=`\n${l}`;var f;n||r?function(e,t,n,r){return new Promise(((i,s)=>{let o=`data:image/svg+xml;utf8,${encodeURIComponent(e)}`;function l(){let e=new Image;e.crossOrigin="anonymous",e.src=o,e.onload=()=>{let l=document.createElement("canvas"),a=l.getContext("2d"),u=window.devicePixelRatio||1;1!=r&&(u=1),l.width=t*u,l.height=n*u,a.drawImage(e,0,0,l.width,l.height);try{l.toBlob((e=>{i({blob:e,source:o,url:URL.createObjectURL(e)})}))}catch(e){s(e)}}}A()?T(o,l,200):l()}))}(p,c,h,e).then((({source:e,url:r,blob:s})=>{if(i({width:c,height:h,svg:p,blob:s,source:e}),n){let e=document.createElement("a");e.download=function(e){return(w(e)?Date.now():String(e).replace(/\/.png$/g,""))+".png"}(t),e.href=r,e.click()}})).catch((e=>{s(e)})):i({width:c,height:h,svg:p})}))}set_content(e,t){if(t instanceof Promise)t.then((t=>{this.set_content(e,t)}));else{const n=this.shadowRoot.querySelector(e);n&&(n.styleSheet?n.styleSheet.cssText=t:n.innerHTML=t)}}}customElements.get("css-doodle")||customElements.define("css-doodle",e)}function zn(){let{uniform_time:e}=Rt;const t=Ot(/grid/).map((e=>`${e}:inherit;`)).join("");return`\n *, *::after, *::before{box-sizing:border-box;animation-play-state:var(--cssd-animation-play-state) !important;}:host, .host{display:block;visibility:visible;width:auto;height:auto;--${e.name}:0\n}:host([hidden]), .host[hidden]{display:none\n} .container{position:relative;width:100%;height:100%;display:grid;${t}} cell:empty{position:relative;line-height:1;display:grid;place-items:center\n} svg{position:absolute;width:100%;height:100%;}:host([cssd-paused-animation]){--cssd-animation-play-state:paused;animation-play-state:paused !important;}`}function Pn(e){let{x:t,y:n}=e||{};return`\n:host, .host{grid-template-rows:repeat(${n}, 1fr);grid-template-columns:repeat(${t}, 1fr);}`}function Cn(e,t,n){let r=document.createElement("cell");return r.id=j(e,t,n),r}function Nn(e){let{x:t,y:n,z:r}=e||{},i=document.createElement("grid"),s=document.createDocumentFragment();if(1==r)for(let e=1;e<=n;++e)for(let n=1;n<=t;++n)s.appendChild(Cn(n,e,1));else{let e=null;for(let t=1;t<=r;++t){let n=Cn(1,1,t);(e||s).appendChild(n),e=n}e=null}return i.className="container",i.appendChild(s),i.outerHTML}const Mn=P((e=>{let t=document.createElement("css-doodle");return t.update&&t.update(e),t}));e.CSSDoodle=Mn,Object.defineProperty(e,"__esModule",{value:!0})})); \ No newline at end of file diff --git a/package.json b/package.json index ca39a89..04a46f4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "css-doodle", - "version": "0.27.2", + "version": "0.27.4", "description": "A web component for drawing patterns with CSS", "main": "css-doodle.js", "scripts": { diff --git a/src/function.js b/src/function.js index e107cbc..a7b9c15 100644 --- a/src/function.js +++ b/src/function.js @@ -323,7 +323,7 @@ const Expose = add_alias({ let id = unique_id('filter-'); // shorthand if (values.every(n => /^[\d.]/.test(n))) { - let [fq = 1, scale = 1, seed, octave] = values; + let [fq = 1, scale = 1, octave, seed] = values; let [bx, by = bx] = parse_value_group(fq); octave = octave ? `numOctaves: ${octave};` : ''; seed = seed ? `seed: ${seed};` : ''; @@ -331,7 +331,7 @@ const Expose = add_alias({ feTurbulence { type: fractalNoise; baseFrequency: ${bx} ${by}; - ${seed} ${octave} + ${octave} ${seed} } feDisplacementMap { in: SourceGraphic;