shaders 3.1.461 → 3.1.462
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +2 -2
- package/dist/core/gpu/index.d.ts.map +1 -1
- package/dist/core/gpu/passManager.d.ts +1 -1
- package/dist/core/gpu/passManager.d.ts.map +1 -1
- package/dist/core/index.js +3 -2
- package/dist/core/presetRenderer.d.ts.map +1 -1
- package/dist/js/bundle.js +2 -2
- package/dist/js/createShader.js +1 -1
- package/dist/react/Shader.js +1 -1
- package/dist/react/bundle.js +3 -3
- package/dist/solid/engine/Shader.js +1 -1
- package/dist/svelte/index.js +1 -1
- package/dist/vue/Shader.vue_vue_type_script_setup_true_lang.js +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
/* shaders@3.1.
|
|
2
|
+
/* shaders@3.1.462 CLI — npx shaders install-mcp. https://shaders.com */
|
|
3
3
|
import { createRequire as __cliCreateRequire } from "module";
|
|
4
4
|
const require = __cliCreateRequire(import.meta.url);
|
|
5
5
|
var Vi=Object.create;var sr=Object.defineProperty;var Yi=Object.getOwnPropertyDescriptor;var Gi=Object.getOwnPropertyNames;var Ki=Object.getPrototypeOf,qi=Object.prototype.hasOwnProperty;var Ji=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,i)=>(typeof require<"u"?require:t)[i]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var $=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var zi=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of Gi(t))!qi.call(e,u)&&u!==i&&sr(e,u,{get:()=>t[u],enumerable:!(r=Yi(t,u))||r.enumerable});return e};var Se=(e,t,i)=>(i=e!=null?Vi(Ki(e)):{},zi(t||!e||!e.__esModule?sr(i,"default",{value:e,enumerable:!0}):i,e));var Dt=$((ka,or)=>{"use strict";var ht={to(e,t){return t?`\x1B[${t+1};${e+1}H`:`\x1B[${e+1}G`},move(e,t){let i="";return e<0?i+=`\x1B[${-e}D`:e>0&&(i+=`\x1B[${e}C`),t<0?i+=`\x1B[${-t}A`:t>0&&(i+=`\x1B[${t}B`),i},up:(e=1)=>`\x1B[${e}A`,down:(e=1)=>`\x1B[${e}B`,forward:(e=1)=>`\x1B[${e}C`,backward:(e=1)=>`\x1B[${e}D`,nextLine:(e=1)=>"\x1B[E".repeat(e),prevLine:(e=1)=>"\x1B[F".repeat(e),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},Qi={up:(e=1)=>"\x1B[S".repeat(e),down:(e=1)=>"\x1B[T".repeat(e)},Zi={screen:"\x1B[2J",up:(e=1)=>"\x1B[1J".repeat(e),down:(e=1)=>"\x1B[J".repeat(e),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(e){let t="";for(let i=0;i<e;i++)t+=this.line+(i<e-1?ht.up():"");return e&&(t+=ht.left),t}};or.exports={cursor:ht,scroll:Qi,erase:Zi,beep:"\x07"}});var cr=$(($a,ft)=>{var Oe=process||{},lr=Oe.argv||[],Be=Oe.env||{},Xi=!(Be.NO_COLOR||lr.includes("--no-color"))&&(!!Be.FORCE_COLOR||lr.includes("--color")||Oe.platform==="win32"||(Oe.stdout||{}).isTTY&&Be.TERM!=="dumb"||!!Be.CI),eu=(e,t,i=e)=>r=>{let u=""+r,s=u.indexOf(t,e.length);return~s?e+tu(u,t,i,s)+t:e+u+t},tu=(e,t,i,r)=>{let u="",s=0;do u+=e.substring(s,r)+i,s=r+t.length,r=e.indexOf(t,s);while(~r);return u+e.substring(s)},ar=(e=Xi)=>{let t=e?eu:()=>String;return{isColorSupported:e,reset:t("\x1B[0m","\x1B[0m"),bold:t("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:t("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:t("\x1B[3m","\x1B[23m"),underline:t("\x1B[4m","\x1B[24m"),inverse:t("\x1B[7m","\x1B[27m"),hidden:t("\x1B[8m","\x1B[28m"),strikethrough:t("\x1B[9m","\x1B[29m"),black:t("\x1B[30m","\x1B[39m"),red:t("\x1B[31m","\x1B[39m"),green:t("\x1B[32m","\x1B[39m"),yellow:t("\x1B[33m","\x1B[39m"),blue:t("\x1B[34m","\x1B[39m"),magenta:t("\x1B[35m","\x1B[39m"),cyan:t("\x1B[36m","\x1B[39m"),white:t("\x1B[37m","\x1B[39m"),gray:t("\x1B[90m","\x1B[39m"),bgBlack:t("\x1B[40m","\x1B[49m"),bgRed:t("\x1B[41m","\x1B[49m"),bgGreen:t("\x1B[42m","\x1B[49m"),bgYellow:t("\x1B[43m","\x1B[49m"),bgBlue:t("\x1B[44m","\x1B[49m"),bgMagenta:t("\x1B[45m","\x1B[49m"),bgCyan:t("\x1B[46m","\x1B[49m"),bgWhite:t("\x1B[47m","\x1B[49m"),blackBright:t("\x1B[90m","\x1B[39m"),redBright:t("\x1B[91m","\x1B[39m"),greenBright:t("\x1B[92m","\x1B[39m"),yellowBright:t("\x1B[93m","\x1B[39m"),blueBright:t("\x1B[94m","\x1B[39m"),magentaBright:t("\x1B[95m","\x1B[39m"),cyanBright:t("\x1B[96m","\x1B[39m"),whiteBright:t("\x1B[97m","\x1B[39m"),bgBlackBright:t("\x1B[100m","\x1B[49m"),bgRedBright:t("\x1B[101m","\x1B[49m"),bgGreenBright:t("\x1B[102m","\x1B[49m"),bgYellowBright:t("\x1B[103m","\x1B[49m"),bgBlueBright:t("\x1B[104m","\x1B[49m"),bgMagentaBright:t("\x1B[105m","\x1B[49m"),bgCyanBright:t("\x1B[106m","\x1B[49m"),bgWhiteBright:t("\x1B[107m","\x1B[49m")}};ft.exports=ar();ft.exports.createColors=ar});var Wn=$((vc,Un)=>{"use strict";var re=class e extends Error{constructor(t,i,r){super("[ParserError] "+t,i,r),this.name="ParserError",this.code="ParserError",Error.captureStackTrace&&Error.captureStackTrace(this,e)}},Ge=class{constructor(t){this.parser=t,this.buf="",this.returned=null,this.result=null,this.resultTable=null,this.resultArr=null}},ve=class{constructor(){this.pos=0,this.col=0,this.line=0,this.obj={},this.ctx=this.obj,this.stack=[],this._buf="",this.char=null,this.ii=0,this.state=new Ge(this.parseStart)}parse(t){if(t.length===0||t.length==null)return;this._buf=String(t),this.ii=-1,this.char=-1;let i;for(;i===!1||this.nextChar();)i=this.runOne();this._buf=null}nextChar(){return this.char===10&&(++this.line,this.col=-1),++this.ii,this.char=this._buf.codePointAt(this.ii),++this.pos,++this.col,this.haveBuffer()}haveBuffer(){return this.ii<this._buf.length}runOne(){return this.state.parser.call(this,this.state.returned)}finish(){this.char=1114112;let t;do t=this.state.parser,this.runOne();while(this.state.parser!==t);return this.ctx=null,this.state=null,this._buf=null,this.obj}next(t){if(typeof t!="function")throw new re("Tried to set state to non-existent state: "+JSON.stringify(t));this.state.parser=t}goto(t){return this.next(t),this.runOne()}call(t,i){i&&this.next(i),this.stack.push(this.state),this.state=new Ge(t)}callNow(t,i){return this.call(t,i),this.runOne()}return(t){if(this.stack.length===0)throw this.error(new re("Stack underflow"));t===void 0&&(t=this.state.buf),this.state=this.stack.pop(),this.state.returned=t}returnNow(t){return this.return(t),this.runOne()}consume(){if(this.char===1114112)throw this.error(new re("Unexpected end-of-buffer"));this.state.buf+=this._buf[this.ii]}error(t){return t.line=this.line,t.col=this.col,t.pos=this.pos,t}parseStart(){throw new re("Must declare a parseStart method")}};ve.END=1114112;ve.Error=re;Un.exports=ve});var Yn=$((wc,Vn)=>{"use strict";Vn.exports=e=>{let t=new Date(e);if(isNaN(t))throw new TypeError("Invalid Datetime");return t}});var Ke=$((_c,Gn)=>{"use strict";Gn.exports=(e,t)=>{for(t=String(t);t.length<e;)t="0"+t;return t}});var qn=$((Tc,Kn)=>{"use strict";var De=Ke(),jt=class extends Date{constructor(t){super(t+"Z"),this.isFloating=!0}toISOString(){let t=`${this.getUTCFullYear()}-${De(2,this.getUTCMonth()+1)}-${De(2,this.getUTCDate())}`,i=`${De(2,this.getUTCHours())}:${De(2,this.getUTCMinutes())}:${De(2,this.getUTCSeconds())}.${De(3,this.getUTCMilliseconds())}`;return`${t}T${i}`}};Kn.exports=e=>{let t=new jt(e);if(isNaN(t))throw new TypeError("Invalid Datetime");return t}});var Qn=$((Sc,zn)=>{"use strict";var Jn=Ke(),cl=global.Date,Ut=class extends cl{constructor(t){super(t),this.isDate=!0}toISOString(){return`${this.getUTCFullYear()}-${Jn(2,this.getUTCMonth()+1)}-${Jn(2,this.getUTCDate())}`}};zn.exports=e=>{let t=new Ut(e);if(isNaN(t))throw new TypeError("Invalid Datetime");return t}});var Xn=$((Bc,Zn)=>{"use strict";var qe=Ke(),Wt=class extends Date{constructor(t){super(`0000-01-01T${t}Z`),this.isTime=!0}toISOString(){return`${qe(2,this.getUTCHours())}:${qe(2,this.getUTCMinutes())}:${qe(2,this.getUTCSeconds())}.${qe(3,this.getUTCMilliseconds())}`}};Zn.exports=e=>{let t=new Wt(e);if(isNaN(t))throw new TypeError("Invalid Datetime");return t}});var Je=$((exports,module)=>{"use strict";module.exports=makeParserClass(Wn());module.exports.makeParserClass=makeParserClass;var TomlError=class e extends Error{constructor(t){super(t),this.name="TomlError",Error.captureStackTrace&&Error.captureStackTrace(this,e),this.fromTOML=!0,this.wrapped=null}};TomlError.wrap=e=>{let t=new TomlError(e.message);return t.code=e.code,t.wrapped=e,t};module.exports.TomlError=TomlError;var createDateTime=Yn(),createDateTimeFloat=qn(),createDate=Qn(),createTime=Xn(),CTRL_I=9,CTRL_J=10,CTRL_M=13,CTRL_CHAR_BOUNDARY=31,CHAR_SP=32,CHAR_QUOT=34,CHAR_NUM=35,CHAR_APOS=39,CHAR_PLUS=43,CHAR_COMMA=44,CHAR_HYPHEN=45,CHAR_PERIOD=46,CHAR_0=48,CHAR_1=49,CHAR_7=55,CHAR_9=57,CHAR_COLON=58,CHAR_EQUALS=61,CHAR_A=65,CHAR_E=69,CHAR_F=70,CHAR_T=84,CHAR_U=85,CHAR_Z=90,CHAR_LOWBAR=95,CHAR_a=97,CHAR_b=98,CHAR_e=101,CHAR_f=102,CHAR_i=105,CHAR_l=108,CHAR_n=110,CHAR_o=111,CHAR_r=114,CHAR_s=115,CHAR_t=116,CHAR_u=117,CHAR_x=120,CHAR_z=122,CHAR_LCUB=123,CHAR_RCUB=125,CHAR_LSQB=91,CHAR_BSOL=92,CHAR_RSQB=93,CHAR_DEL=127,SURROGATE_FIRST=55296,SURROGATE_LAST=57343,escapes={[CHAR_b]:"\b",[CHAR_t]:" ",[CHAR_n]:`
|
|
@@ -106,7 +106,7 @@ Options:
|
|
|
106
106
|
Supported agents:
|
|
107
107
|
${e}
|
|
108
108
|
|
|
109
|
-
Docs: ${Pi}`)}function Ba(e){let t={global:!1,yes:!1,agents:[]},i;for(let r=0;r<e.length;r++){let u=e[r];switch(u){case"-g":case"--global":t.global=!0;break;case"-y":case"--yes":t.yes=!0;break;case"-a":case"--agent":{let s=e[++r];s||ie(`Missing value for ${u}`),t.agents.push(...s.split(",").map(n=>n.trim()).filter(Boolean));break}case"-h":case"--help":Mi(),process.exit(0);break;case"-v":case"--version":console.log("3.1.
|
|
109
|
+
Docs: ${Pi}`)}function Ba(e){let t={global:!1,yes:!1,agents:[]},i;for(let r=0;r<e.length;r++){let u=e[r];switch(u){case"-g":case"--global":t.global=!0;break;case"-y":case"--yes":t.yes=!0;break;case"-a":case"--agent":{let s=e[++r];s||ie(`Missing value for ${u}`),t.agents.push(...s.split(",").map(n=>n.trim()).filter(Boolean));break}case"-h":case"--help":Mi(),process.exit(0);break;case"-v":case"--version":console.log("3.1.462"),process.exit(0);break;default:u.startsWith("-")&&ie(`Unknown option: ${u} (see npx shaders --help)`),i&&ie(`Unexpected argument: ${u}`),i=u}}return{command:i,flags:t}}function ie(e){console.error(`\u2717 ${e}`),process.exit(1)}function ji(e){let t=new Set(Z());for(let i of e)t.has(i)||ie(`Unknown agent "${i}". Supported agents: ${Z().join(", ")}`);return e}async function Oa(e,t){if(e.agents.length>0)return{targets:ji(e.agents),scope:e.global?"global":"project"};let i=e.global?[]:Qt(t),r=e.global||i.length===0?"global":"project",u=r==="project"?i:await Zt();if(!(!e.yes&&process.stdout.isTTY&&process.stdin.isTTY))return u.length===0&&ie(`No coding agents detected. Pass one explicitly, e.g. npx shaders install-mcp -a cursor
|
|
110
110
|
Supported agents: ${Z().join(", ")}`),{targets:u,scope:r};let n=await Et({message:`Install the Shaders MCP server to which agents? (${r} config)`,options:Z().map(o=>({value:o,label:R[o].displayName,hint:r==="project"&&R[o].localConfigPath?R[o].localConfigPath:R[o].configPath.replace(/^\/Users\/[^/]+|^\/home\/[^/]+|^C:\\Users\\[^\\]+/,"~")})),initialValues:u,required:!0});return de(n)&&(console.log("Cancelled \u2014 nothing was changed."),process.exit(0)),{targets:n,scope:r}}async function Ra(e){let t=process.cwd(),{targets:i,scope:r}=await Oa(e,t),u=0;for(let s of i){let n=r==="project"&&!!R[s].localConfigPath,o=$i(s,ir,{type:"http",url:Sa},{local:n,cwd:t});o.success?console.log(`\u2713 ${R[s].displayName} \u2014 ${o.path}`):(u++,console.error(`\u2717 ${R[s].displayName} \u2014 ${o.error}`))}u===i.length&&process.exit(1),console.log(`
|
|
111
111
|
Done! Open your agent and connect to the "${ir}" MCP server \u2014 you'll be
|
|
112
112
|
prompted to sign in to your Shaders account (Pro) the first time it connects.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gpu/index.ts"],"names":[],"mappings":"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
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gpu/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAA;AAIrC,OAAO,EAA2E,KAAK,gBAAgB,EAAC,MAAM,WAAW,CAAA;AACzH,OAAO,EAAuE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAC,MAAM,gBAAgB,CAAA;AAsBrI,OAAO,KAAK,EACR,mBAAmB,EAItB,MAAM,YAAY,CAAA;AAEnB,OAAO,EAOH,KAAK,cAAc,EACtB,MAAM,+BAA+B,CAAA;AAKtC,OAAO,EAAqB,KAAK,gBAAgB,EAAC,MAAM,uBAAuB,CAAA;AAC/E,OAAO,KAAK,EACR,YAAY,EAOZ,eAAe,EAClB,MAAM,UAAU,CAAA;AAGjB,OAAO,EAAC,WAAW,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,uBAAuB,EAAC,MAAM,QAAQ,CAAA;AACrG,YAAY,EAAC,kBAAkB,EAAE,WAAW,EAAC,MAAM,QAAQ,CAAA;AAG3D,OAAO,EAAC,iBAAiB,EAAE,gBAAgB,EAAE,eAAe,EAAE,cAAc,EAAE,mBAAmB,EAAE,qBAAqB,EAAC,MAAM,WAAW,CAAA;AAC1I,YAAY,EAAC,gBAAgB,EAAE,iBAAiB,EAAC,MAAM,WAAW,CAAA;AA0BlE;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC5B,+FAA+F;IAC/F,KAAK,EAAE,OAAO,CAAA;IACd,+EAA+E;IAC/E,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAA;IACvC,wFAAwF;IACxF,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,uEAAuE;IACvE,eAAe,CAAC,EAAE,CAAC,aAAa,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,KAAK,OAAO,CAAA;IACxE,qEAAqE;IACrE,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,2FAA2F;IAC3F,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,uFAAuF;IACvF,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,gFAAgF;IAChF,MAAM,CAAC,EAAE,OAAO,cAAc,EAAE,WAAW,CAAA;CAC9C;AAED,uDAAuD;AACvD,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;AAM5D,MAAM,WAAW,oBAAoB;IACjC,MAAM,EAAE,iBAAiB,CAAA;IACzB,yEAAyE;IACzE,YAAY,CAAC,EAAE,WAAW,CAAA;IAC1B,yBAAyB,CAAC,EAAE,OAAO,CAAA;IACnC,UAAU,CAAC,EAAE,WAAW,GAAG,MAAM,CAAA;IACjC,WAAW,CAAC,EAAE,eAAe,CAAA;IAC7B,0EAA0E;IAC1E,GAAG,CAAC,EAAE;QAAC,MAAM,EAAE,SAAS,CAAC;QAAC,OAAO,CAAC,EAAE,UAAU,CAAA;KAAC,CAAA;IAC/C,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,6FAA6F;IAC7F,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,8FAA8F;IAC9F,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CACpB;AAMD,UAAU,gBAAgB;IACtB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,uFAAuF;AACvF,UAAU,SAAS;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;CAChB;AAED,UAAU,WAAW;IACjB,EAAE,EAAE,MAAM,CAAA;IACV,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,UAAU,EAAE,mBAAmB,CAAA;IAC/B,QAAQ,EAAE,YAAY,CAAA;IACtB,QAAQ,EAAE,cAAc,CAAA;IACxB,SAAS,CAAC,EAAE,iBAAiB,CAAA;IAG7B,WAAW,EAAE,OAAO,CAAA;IACpB,aAAa,EAAE,OAAO,CAAA;IACtB,iBAAiB,EAAE,OAAO,CAAA;IAC1B,gBAAgB,EAAE,OAAO,CAAA;IACzB,2BAA2B,EAAE,OAAO,CAAA;IACpC,WAAW,EAAE,OAAO,CAAA;IACpB,UAAU,EAAE,OAAO,CAAA;IACnB,sBAAsB,CAAC,EAAE,mBAAmB,CAAC,wBAAwB,CAAC,CAAA;IACtE,iBAAiB,EAAE,OAAO,CAAA;IAC1B,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IAG3C,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;IAClD,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IACpC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IAEpC,+FAA+F;IAC/F,YAAY,EAAE,WAAW,GAAG,IAAI,CAAA;CACnC;AAED,UAAU,kBAAkB;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,mBAAmB,CAAA;IAC/B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAA;IAC7B,QAAQ,EAAE,cAAc,CAAA;IACxB,SAAS,CAAC,EAAE,iBAAiB,CAAA;CAChC;AAuGD;;GAEG;AACH,wBAAgB,iBAAiB;0BAkwEM,oBAAoB,KAAG,OAAO,CAAC,IAAI,CAAC;mBA2KnD,IAAI;uBAv2ChB,MAAM,oBACQ,mBAAmB,CAAC,UAAU,CAAC,GAAG,IAAI,YAC9C,MAAM,GAAG,IAAI,YACb,YAAY,GAAG,IAAI,aACnB,cAAc,wBACF,mBAAmB,cAC7B,iBAAiB,KAC9B,IAAI;qBAsXiB,MAAM,KAAG,IAAI;iCA5OD,MAAM,eAAe,MAAM,SAAS,OAAO,KAAG,IAAI;iCAsElD,MAAM,YAAY,OAAO,CAAC,YAAY,CAAC,KAAG,IAAI;;oBAgyC9D,MAAM,UAAU,MAAM,KAAG,IAAI;0BAxmBtB,IAAI;yBAQL,IAAI;8BAlDS;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAC,KAAG,OAAO,CAAC,IAAI,CAAC;yCAiC3B,MAAM,YAAY;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAC,KAAG,OAAO,CAAC,IAAI,CAAC;+BAulB1E,gBAAgB;iCAoCf,MAAM,YAAY,MAAM,KAAG;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAC,GAAG,IAAI;iCAKxD,MAAM,YAAY,MAAM,KAAG,MAAM,GAAG,IAAI;;eAgBnB,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC;;IAElF,yFAAyF;2BACpE,QAAQ,GAAG,OAAO,GAAG,IAAI;IAE9C,iEAAiE;+BACxC;QAAC,MAAM,EAAE,SAAS,CAAC;QAAC,OAAO,CAAC,EAAE,UAAU,CAAC;QAAC,IAAI,EAAE,QAAQ,CAAA;KAAC,GAAG,IAAI;qCAGxD,OAAO,KAAG,OAAO;4CAMV,MAAM,gBAAgB,MAAM,SAAS,MAAM,KAAG,CAAC,MAAM,IAAI,CAAC;gCAsBtE,MAAM,KAAG,IAAI;4BAajB,MAAM,GAAG,IAAI,KAAG,IAAI;2BAGrB,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,KAAG,IAAI;gCAKrB,CAAC,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,IAAI,KAAG,IAAI;IAIpE;;;;;;;;OAQG;iCAC0B,CAAC,CAAC,MAAM,EAAE,gBAAgB,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,IAAI,KAAG,IAAI;IAehG,gEAAgE;4BAC1C,gBAAgB,GAAG,IAAI;;;mCAxiFf,MAAM,KAAG,WAAW,EAAE;QA8iFhD,qFAAqF;8BAC/D,MAAM,KAAG,SAAS,EAAE,GAAG,IAAI;QAIjD,gFAAgF;gCACxD,MAAM,KAAG,IAAI;QAIrC,kFAAkF;sCACpD,MAAM,KAAG,IAAI;QAI3C,sFAAsF;sCACxD,MAAM,KAAG,IAAI;mCAIhB,MAAM,KAAG,MAAM,GAAG,IAAI;8BAO3B,MAAM,QAAQ,MAAM,SAAS,MAAM,GAAG,MAAM,EAAE,KAAG,IAAI;6BAItD,MAAM,QAAQ,MAAM,KAAG,OAAO;;;;;;;;QAOnD,gFAAgF;;;;;;;;;;;;;;qCAnyDtD,MAAM,GAAG,IAAI;;;QAszDvC,sFAAsF;8BAChE;YAAC,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAC,KAAG,IAAI;;EAcvE"}
|
|
@@ -34,7 +34,7 @@ export interface PassManager {
|
|
|
34
34
|
texture: unknown;
|
|
35
35
|
}>): void;
|
|
36
36
|
/** Execute the current composition: compute → RTT passes → final pass to `canvasView`. */
|
|
37
|
-
render(canvasView: unknown, frameParams: unknown): void;
|
|
37
|
+
render(canvasView: unknown, frameParams: unknown, afterCompute?: () => void): void;
|
|
38
38
|
/**
|
|
39
39
|
* Re-execute only the RTT passes (no compute, no final pass). `resize` recreates every RTT
|
|
40
40
|
* texture zero-initialized, and `render` runs compute FIRST — so a compute step that reads a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"passManager.d.ts","sourceRoot":"","sources":["../../src/gpu/passManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAS,KAAK,QAAQ,EAAE,KAAK,aAAa,EAA0B,MAAM,SAAS,CAAA;AAC1F,OAAO,KAAK,EAAC,aAAa,EAAe,MAAM,YAAY,CAAA;AAE3D,OAAO,KAAK,EAAC,cAAc,EAAE,aAAa,EAAyB,MAAM,YAAY,CAAA;AACrF,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,WAAW,CAAA;AA2BhD,MAAM,WAAW,kBAAkB;IAC/B,6CAA6C;IAC7C,cAAc,EAAE,cAAc,CAAA;IAC9B,gDAAgD;IAChD,UAAU,EAAE,iBAAiB,CAAA;IAC7B,2FAA2F;IAC3F,YAAY,CAAC,EAAE,gBAAgB,CAAA;IAC/B,gDAAgD;IAChD,SAAS,CAAC,EAAE,gBAAgB,CAAA;IAC5B;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,iFAAiF;IACjF,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC/B;AAED,MAAM,WAAW,WAAW;IACxB;;;;OAIG;IACH,cAAc,CACV,EAAE,EAAE,aAAa,EACjB,gBAAgB,EAAE,aAAa,GAAG,SAAS,EAC3C,IAAI,EAAE;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,EACrC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG;QAAC,OAAO,EAAE,OAAO,CAAA;KAAC,CAAC,GACpE,IAAI,CAAA;IACP,0FAA0F;IAC1F,MAAM,CAAC,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,GAAG,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"passManager.d.ts","sourceRoot":"","sources":["../../src/gpu/passManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAS,KAAK,QAAQ,EAAE,KAAK,aAAa,EAA0B,MAAM,SAAS,CAAA;AAC1F,OAAO,KAAK,EAAC,aAAa,EAAe,MAAM,YAAY,CAAA;AAE3D,OAAO,KAAK,EAAC,cAAc,EAAE,aAAa,EAAyB,MAAM,YAAY,CAAA;AACrF,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,WAAW,CAAA;AA2BhD,MAAM,WAAW,kBAAkB;IAC/B,6CAA6C;IAC7C,cAAc,EAAE,cAAc,CAAA;IAC9B,gDAAgD;IAChD,UAAU,EAAE,iBAAiB,CAAA;IAC7B,2FAA2F;IAC3F,YAAY,CAAC,EAAE,gBAAgB,CAAA;IAC/B,gDAAgD;IAChD,SAAS,CAAC,EAAE,gBAAgB,CAAA;IAC5B;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,iFAAiF;IACjF,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC/B;AAED,MAAM,WAAW,WAAW;IACxB;;;;OAIG;IACH,cAAc,CACV,EAAE,EAAE,aAAa,EACjB,gBAAgB,EAAE,aAAa,GAAG,SAAS,EAC3C,IAAI,EAAE;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,EACrC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG;QAAC,OAAO,EAAE,OAAO,CAAA;KAAC,CAAC,GACpE,IAAI,CAAA;IACP,0FAA0F;IAC1F,MAAM,CAAC,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI,CAAA;IAClF;;;;;;OAMG;IACH,UAAU,IAAI,IAAI,CAAA;IAClB;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAA;IAC9C,sEAAsE;IACtE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,2EAA2E;IAC3E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,kDAAkD;IAClD,OAAO,IAAI,IAAI,CAAA;CAClB;AAID,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,kBAAkB,GAAG,WAAW,CAgW1F"}
|
package/dist/core/index.js
CHANGED
|
@@ -694,12 +694,13 @@ function createPassManager(root, options) {
|
|
|
694
694
|
}
|
|
695
695
|
p.withColorAttachment({ view }).draw(3);
|
|
696
696
|
}
|
|
697
|
-
function render(canvasView, frameParams) {
|
|
697
|
+
function render(canvasView, frameParams, afterCompute) {
|
|
698
698
|
if (!current) return;
|
|
699
699
|
for (const step of current.computeSteps) {
|
|
700
700
|
const steps = step.getComputeNodes(frameParams);
|
|
701
701
|
if (steps && steps.length) dispatcher.dispatch(steps);
|
|
702
702
|
}
|
|
703
|
+
afterCompute?.();
|
|
703
704
|
repaintRtt();
|
|
704
705
|
execPass(current.finalPass, canvasView);
|
|
705
706
|
}
|
|
@@ -3007,7 +3008,7 @@ function shaderRendererGPU() {
|
|
|
3007
3008
|
render: () => {
|
|
3008
3009
|
if (enablePerformanceTracking) performance.mark("shader-gpu-start");
|
|
3009
3010
|
renderComp = pipelineCache.renderValue ?? built;
|
|
3010
|
-
renderComp?.passManager.render(context, frameParams);
|
|
3011
|
+
renderComp?.passManager.render(context, frameParams, () => boundComposition?.store.flush());
|
|
3011
3012
|
if (enablePerformanceTracking) {
|
|
3012
3013
|
performance.mark("shader-gpu-end");
|
|
3013
3014
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presetRenderer.d.ts","sourceRoot":"","sources":["../src/presetRenderer.ts"],"names":[],"mappings":"AASA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC3B,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAA;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,eAAe,EAAE,CAAA;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,yBAAyB,CAAC,EAAE,OAAO,CAAA;IAEnC,GAAG,CAAC,EAAE;QACJ,MAAM,EAAE,SAAS,CAAA;QACjB,OAAO,EAAE,UAAU,CAAA;KACpB,CAAA;IACD,OAAO,CAAC,EAAE,qBAAqB,GAAG,sBAAsB,CAAA;IAExD,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAA;IACxB,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,OAAO,CAAC,EAAE,UAAU,CAAA;IACpB,OAAO,CAAC,EAAE,qBAAqB,GAAG,sBAAsB,CAAA;IACxD,MAAM,EAAE,iBAAiB,CAAA;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,YAAY,EACpB,OAAO,CAAC,EAAE,qBAAqB;yBAmBG,iBAAiB,KAAG,OAAO,CAAC,IAAI,CAAC;4BA4B9B;QAAE,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,KAAG,OAAO,CAAC,IAAI,CAAC;8BAa5C,YAAY,KAAG,IAAI;yBAgB1B,UAAU;mBAchB,IAAI;IA8FtB;;;;;;OAMG;
|
|
1
|
+
{"version":3,"file":"presetRenderer.d.ts","sourceRoot":"","sources":["../src/presetRenderer.ts"],"names":[],"mappings":"AASA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC3B,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAA;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,eAAe,EAAE,CAAA;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,yBAAyB,CAAC,EAAE,OAAO,CAAA;IAEnC,GAAG,CAAC,EAAE;QACJ,MAAM,EAAE,SAAS,CAAA;QACjB,OAAO,EAAE,UAAU,CAAA;KACpB,CAAA;IACD,OAAO,CAAC,EAAE,qBAAqB,GAAG,sBAAsB,CAAA;IAExD,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAA;IACxB,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,OAAO,CAAC,EAAE,UAAU,CAAA;IACpB,OAAO,CAAC,EAAE,qBAAqB,GAAG,sBAAsB,CAAA;IACxD,MAAM,EAAE,iBAAiB,CAAA;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,YAAY,EACpB,OAAO,CAAC,EAAE,qBAAqB;yBAmBG,iBAAiB,KAAG,OAAO,CAAC,IAAI,CAAC;4BA4B9B;QAAE,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,KAAG,OAAO,CAAC,IAAI,CAAC;8BAa5C,YAAY,KAAG,IAAI;yBAgB1B,UAAU;mBAchB,IAAI;IA8FtB;;;;;;OAMG;8EAM+n0I,CAAC;IAJno0I,+DAA+D;;EAGlE"}
|
package/dist/js/bundle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* shaders@3.1.
|
|
1
|
+
/* shaders@3.1.462/js — ESM bundle for CDN consumption (no bundler required). https://shaders.com */
|
|
2
2
|
var pc=class extends Error{reason;constructor(e,t,s){super(t??`[gpu] WebGPU unavailable (${e})`),this.name="GpuUnavailableError",this.reason=e,s?.cause!==void 0&&(this.cause=s.cause)}};function qh(e){return!!e&&typeof e=="object"&&e.name==="GpuUnavailableError"&&typeof e.reason=="string"}var Vh=null;function Q3(e){Vh=e}function Dm(){if(Vh!==null)return Vh;let e=globalThis.__SHADERS_DEBUG__;if(e!=null)return!!e;try{if(typeof localStorage<"u"&&localStorage.getItem("shaders:debug")==="1")return!0}catch{}return!1}function Wa(...e){Dm()&&console.warn(...e)}function io(...e){Dm()&&console.error(...e)}function Xh(){return typeof navigator<"u"&&!!navigator.gpu}var Rm=null;function Hh(){return Rm||(Rm=(async()=>{if(!Xh())return{supported:!1,reason:"unsupported"};try{return await navigator.gpu.requestAdapter({powerPreference:"high-performance"})?{supported:!0}:{supported:!1,reason:"no-adapter"}}catch(e){return io("[gpu] adapter probe threw:",e),{supported:!1,reason:"no-adapter"}}})(),Rm)}var vO=new Set(["unsupported","no-adapter","no-device","out-of-memory","gpu-error"]),Nh=null;function Z3(e){Nh||!vO.has(e)||(Nh=e)}function J3(){return Nh}var hO=Object.defineProperty,lo=e=>{let t={};for(var s in e)hO(t,s,{get:e[s],enumerable:!0});return t};function Va(e){typeof Symbol[e]>"u"&&Object.defineProperty(Symbol,e,{value:Symbol.for(`Symbol.${e}`),writable:!1,enumerable:!1,configurable:!1})}function e5(e,t){return typeof e?.[t]=="function"}function Tc(e,t,s,o){let r=Fr.deferOperation;return e5(e,s)&&(r=e[s](e,t)),r===Fr.deferOperation&&e5(t,s)&&(r=t[s](e,t)),r===Fr.deferOperation?o(e,t):r}var yO=(e,t)=>e+t;function gO(e,t){return(typeof e=="number"||typeof e=="string")&&(typeof t=="number"||typeof t=="string")?e+t:Tc(e,t,Fr.plus,yO)}var xO=(e,t)=>e-t;function bO(e,t){return typeof e=="number"&&typeof t=="number"?e-t:Tc(e,t,Fr.minus,xO)}var AO=(e,t)=>e*t;function wO(e,t){return typeof e=="number"&&typeof t=="number"?e*t:Tc(e,t,Fr.star,AO)}var TO=(e,t)=>e/t;function SO(e,t){return typeof e=="number"&&typeof t=="number"?e/t:Tc(e,t,Fr.slash,TO)}var CO=(e,t)=>e**t;function PO(e,t){return typeof e=="number"&&typeof t=="number"?e**t:Tc(e,t,Fr.starStar,CO)}var MO=(e,t)=>e%t;function EO(e,t){return typeof e=="number"&&typeof t=="number"?e%t:Tc(e,t,Fr.percent,MO)}var Fr=(Va("deferOperation"),Va("operatorPlus"),Va("operatorMinus"),Va("operatorStar"),Va("operatorSlash"),Va("operatorStarStar"),Va("operatorPercent"),Va("operatorEqEq"),Va("operatorPrePlusPlus"),Va("operatorPreMinusMinus"),Va("operatorPostPlusPlus"),Va("operatorPostMinusMinus"),Va("operatorPreMinus"),globalThis.__tsover_add=gO,globalThis.__tsover_sub=bO,globalThis.__tsover_mul=wO,globalThis.__tsover_div=SO,globalThis.__tsover_pow=PO,globalThis.__tsover_mod=EO,{deferOperation:Symbol.deferOperation,plus:Symbol.operatorPlus,minus:Symbol.operatorMinus,star:Symbol.operatorStar,slash:Symbol.operatorSlash,starStar:Symbol.operatorStarStar,percent:Symbol.operatorPercent,eqEq:Symbol.operatorEqEq,prePlusPlus:Symbol.operatorPrePlusPlus,preMinusMinus:Symbol.operatorPreMinusMinus,postPlusPlus:Symbol.operatorPostPlusPlus,postMinusMinus:Symbol.operatorPostMinusMinus,preMinus:Symbol.operatorPreMinus}),h1=!1,Vy=!1,yr="0.12.3",me=Symbol(`typegpu:${yr}:$internal`),Ve=Symbol(`typegpu:${yr}:$soul`),Ca=Symbol(`typegpu:${yr}:$gpuValueOf`),hr=Symbol(`typegpu:${yr}:$getNameForward`),na=Symbol(`typegpu:${yr}:$providing`),hl=Symbol(`typegpu:${yr}:$ownSnippet`),zs=Symbol(`typegpu:${yr}:$resolve`),Ny=Symbol(`typegpu:${yr}:$cast`),nr=Symbol(`typegpu:${yr}:$gpuCallable`),Sc=Symbol(`typegpu:${yr}:$repr`);`${yr}`;`${yr}`;`${yr}`;`${yr}`;`${yr}`;`${yr}`;`${yr}`;`${yr}`;`${yr}`;function ns(e){return!!e?.[me]}var vo={[me]:{},type:"void",toString(){return"void"}},kO=["bool","f32","f16","i32","u32","u16","vec2f","vec2h","vec2i","vec2u","vec2<bool>","vec3f","vec3h","vec3i","vec3u","vec3<bool>","vec4f","vec4h","vec4i","vec4u","vec4<bool>","mat2x2f","mat3x3f","mat4x4f","struct","array","ptr","atomic","decorated","abstractInt","abstractFloat","void","texture_1d","texture_storage_1d","texture_2d","texture_storage_2d","texture_multisampled_2d","texture_depth_2d","texture_depth_multisampled_2d","texture_2d_array","texture_storage_2d_array","texture_depth_2d_array","texture_cube","texture_depth_cube","texture_cube_array","texture_depth_cube_array","texture_3d","texture_storage_3d","texture_external","sampler","sampler_comparison"];function Wr(e){let t=e;return ns(t)&&typeof t.kind=="string"&&t.kind.startsWith("vec")}function RO(e){return Wr(e)&&e.kind.includes("b")}function DO(e){let t=e;return ns(t)&&typeof t.type=="string"&&t.type.startsWith("vec2")}function zO(e){let t=e;return ns(t)&&typeof t.type=="string"&&t.type.startsWith("vec3")}function BO(e){let t=e;return ns(t)&&typeof t.type=="string"&&t.type.startsWith("vec4")}function Ys(e){return DO(e)||zO(e)||BO(e)}function qy(e){return Ys(e)&&e.type.includes("b")}function Mn(e){let t=e;return ns(t)&&typeof t.kind?.startsWith=="function"&&t.kind.startsWith("mat")}function UA(e){return ns(e)&&e?.type==="mat2x2f"}function OA(e){return ns(e)&&e?.type==="mat3x3f"}function LO(e){return ns(e)&&e?.type==="mat4x4f"}function jn(e){return UA(e)||OA(e)||LO(e)}function GA(e){return ns(e)&&["abstractInt","i32","u32"].includes(e?.type)}function UO(e){return Ys(e)&&GA(e.primitive)}function t5(e){return Wr(e)&&["vec2f","vec3f","vec4f"].includes(e.kind)}function o1(e){return Wr(e)&&/[iu]$/.test(e.kind)}function FA(e){return Wr(e)&&/[u]$/.test(e.kind)}function gd(e){return ns(e)&&kO.includes(e?.type)}function jo(e){return ns(e)&&e?.type==="array"}function so(e){return ns(e)&&e?.type==="struct"}function Vr(e){return ns(e)&&e?.type==="ptr"}function Up(e){return ns(e)&&e?.type==="atomic"}function IA(e){return ns(e)&&e?.type==="@align"}function YA(e){return ns(e)&&e?.type==="@size"}function WA(e){return ns(e)&&e?.type==="@location"}function OO(e){return ns(e)&&e?.type==="@builtin"}function Bi(e){return ns(e)&&e?.type==="decorated"}function y1(e){return ns(e)&&e.type==="void"}function ul(e){return ns(e)&&e.type==="bool"}function oy(e){let t=e?.type;return ns(e)&&(t==="abstractInt"||t==="abstractFloat"||t==="f32"||t==="f16"||t==="i32"||t==="u32")}function Xy(e){let t=e?.type;return ns(e)&&(t==="f16"||t==="vec2h"||t==="vec3h"||t==="vec4h")}var GO=["abstractInt","abstractFloat","f32","f16","i32","u32","bool"];function Pn(e){return!ns(e)||GO.includes(e?.type)}function g1(e){return e.schema}var FO=["deprecated","suspicious","fallback","precision-loss","implicit-conversion","webgpu-feature-missing","webgpu-limits-exceeded","locations-mismatched","log-limit-exceeded","external-omitted","uniform-schema-misaligned"],IO=class{#e;#t;#s=new WeakMap;constructor(e){e?this.#e=["webgpu-feature-missing","webgpu-limits-exceeded","locations-mismatched","log-limit-exceeded","external-omitted"]:this.#e=FO,this.#t=new Set(this.#e)}disable(e){this.#t.delete(e)}reset(){this.#t=new Set(this.#e)}warn(e,...t){this.#t.has(e)&&console.warn(`\u26A0\uFE0F [${e}] `,...t)}warnOnce(e,t,s,...o){if(!this.#t.has(e))return;let r=this.#s.get(t);r||(r=new Set,this.#s.set(t,r));let n=`${e}:${s}`;r.has(n)||(r.add(n),this.warn(e,...o))}},VA=new IO(!(h1||Vy)),Ks=VA,NA=VA;function wa(e){if(Array.isArray(e))return`[${e.map(wa).join(", ")}]`;let t=String(e);if(t!=="[object Object]")return t;try{return JSON.stringify(e)}catch(s){return Ks.warn("suspicious","Error parsing JSON:",s),"<invalid json>"}}function ry(e){return Wr(e)||Mn(e)?e.toString():Array.isArray(e)?`[${e.map(ry).join(", ")}]`:e&&typeof e=="object"?`{ ${Object.entries(e).map(([t,s])=>`${t}: ${ry(s)}`).join(", ")} }`:String(e)}function YO(e){let t={};for(let[s,o]of Object.entries(e))Object.defineProperty(t,s,{get:o,enumerable:!0});return t}function WO(e){if(e.v===1){let t=e.externals;return{...e,externals:typeof t=="function"?t:()=>t}}if(e.v===2){let t=YO(e?.externals);return{...e,externals:()=>t}}throw new Error(`Unrecognized TypeGPU metadata format: ${wa(e)}`)}var qA="0.12.3",Ri=globalThis;Ri.__TYPEGPU_VERSION__!==void 0&&console.warn(`Found duplicate TypeGPU version. First was ${Ri.__TYPEGPU_VERSION__}, this one is ${qA}. This may cause unexpected behavior.`);Ri.__TYPEGPU_VERSION__=qA;Ri.__TYPEGPU_AUTONAME__=(e,t)=>yc(e)&&ns(e)&&!rt(e)?e.$name(t):e;var r1=new WeakMap;function yc(e){return!!e?.$name}function XA(e){return!!e?.[hr]}function HA(e){return e?.[Ve]}function rt(e){return XA(e)?rt(e[hr]):r1.get(e)??HA(e)?.label??Ri.__TYPEGPU_META__?.get(e)?.name}function $t(e,t){if(XA(e)){$t(e[hr],t);return}r1.set(e,t);let s=HA(e);s&&(s.label=t)}var s5=new WeakMap;function Hy(e){let t=Ri.__TYPEGPU_META__?.get(e);if(t){Ri.__TYPEGPU_META__?.delete(e);let s=WO(t);s5.set(e,s),t.name&&r1.get(e)===void 0&&r1.set(e,t.name)}return s5.get(e)}function gc(e){return typeof e=="function"&&!!Hy(e)}var $y=(h1||Vy)&&{get enabled(){return!!Ri.__TYPEGPU_MEASURE_PERF__},record(e,t){let s=Ri.__TYPEGPU_PERF_RECORDS__??=new Map,o=s.get(e);o||(o=[],s.set(e,o)),o.push(t)}}||void 0,$h="Invariant failed";function So(e,t){if(e)return;if(!h1&&!Vy)throw new Error($h);let s=typeof t=="function"?t():t,o=s?`${$h}: ${s}`:$h;throw new Error(o)}var vc=class ay extends Error{cause;trace;constructor(t,s){let o=s.map(r=>`- ${gc(r)?`fn*:${rt(r)}`:r}`);o.length>20&&(o=[...o.slice(0,11),"...",...o.slice(-10)]),super(`Resolution of the following tree failed:
|
|
3
3
|
${o.join(`
|
|
4
4
|
`)}: ${t&&typeof t=="object"&&"message"in t?t.message:t}`),this.cause=t,this.trace=s,Object.setPrototypeOf(this,ay.prototype)}appendToTrace(t){let s=[t,...this.trace];return new ay(this.cause,s)}},o5=class ny extends Error{cause;trace;constructor(t,s){let o=s.map(r=>`- ${r}`);o.length>20&&(o=[...o.slice(0,11),"...",...o.slice(-10)]),super(`Execution of the following tree failed:
|
|
@@ -263,4 +263,4 @@ The element must be a direct child of a <canvas layoutsubtree>.`,T),_=!0)}}}}}),
|
|
|
263
263
|
const uv = array<vec2f, 3>(vec2f(0, 1), vec2f(2, 1), vec2f(0, -1));
|
|
264
264
|
|
|
265
265
|
return Out(vec4f(pos[in.vertexIndex], 0, 1), uv[in.vertexIndex]);
|
|
266
|
-
}`,"fullScreenTriangle");NA.disable("external-omitted");var une=["float32-filterable","timestamp-query"],V3=new WeakMap,Y3=new WeakMap,N3=new WeakSet,tp=null,pne=new WeakSet;async function _ne(e={}){if(e.device&&!N3.has(e.device)){let o=e.device,r=V3.get(o);r||(r=b.initFromDevice({device:o}),V3.set(o,r));let n=sO(r,e.onDeviceLost);return{root:r,device:o,adapter:e.adapter,createdDevice:!1,release:n}}e.device&&Wa("[gpu] injected GPU device was lost \u2014 falling back to the shared default device");let t=await mne(),s=sO(t.root,e.onDeviceLost);return{root:t.root,device:t.device,adapter:t.adapter,createdDevice:!1,release:s}}async function mne(){for(;;){let t=tp;if(!t)break;let s=await t.catch(()=>null);if(s&&!pne.has(t)&&!N3.has(s.device))return s;tp===t&&(tp=null)}let e=fne();tp=e;try{return await e}catch(t){throw tp===e&&(tp=null),t}}async function fne(){if(typeof navigator>"u"||!navigator.gpu)throw new pc("unsupported","[gpu] WebGPU is not available in this environment (navigator.gpu is undefined).");let e;try{e=await b.init({adapter:{powerPreference:"high-performance"},device:{optionalFeatures:une}})}catch(t){let s=await Hh();throw new pc(s.supported?"no-device":s.reason??"init-failed",void 0,{cause:t})}if(!e.device)throw new pc("no-device","[gpu] adapter returned no device.");return V3.set(e.device,e),{root:e,device:e.device,createdDevice:!0}}function vne(e,t,s={}){return e.configureContext({canvas:t,alphaMode:"premultiplied",...s})}function sO(e,t){let s=e.device,o=Y3.get(s);if(o||(o=new Set,Y3.set(s,o),e.device.lost.then(n=>{if(N3.add(s),n.reason!=="destroyed")for(let i of[...Y3.get(s)??[]])i(n)})),!t)return()=>{};let r=o;return r.add(t),()=>r.delete(t)}function hne(){let e={value:0,advance(t,s){e.value+=t*s}};return e}var oO=new WeakMap;function ec(e){let t=oO.get(e);return t||(t=hne(),oO.set(e,t)),t}var yne=(globalThis.__TYPEGPU_AUTONAME__??(e=>e))(je({time:a,viewportSize:p,logicalViewportSize:p,aspect:a,pointer:p,pointerActive:a}),"SystemUniforms");b.fn([p,p],p)((e=>(globalThis.__TYPEGPU_META__??=new WeakMap).set(e.f=((t,s)=>{"use gpu";return Er(t,s)}),{v:2,name:void 0,ast:{params:[{type:"i",name:"uv"},{type:"i",name:"viewportSize"}],body:[0,[[10,[6,"std.mul",["uv","viewportSize"]]]]]},externals:{"std.mul":()=>Er}})&&e.f)({}));b.fn([p],a)((e=>(globalThis.__TYPEGPU_META__??=new WeakMap).set(e.f=(t=>{"use gpu";return __tsover_div(t.x,t.y)}),{v:2,name:void 0,ast:{params:[{type:"i",name:"viewportSize"}],body:[0,[[10,[1,[7,"viewportSize","x"],"/",[7,"viewportSize","y"]]]]]},externals:{}})&&e.f)({}));function gne(e){let t=2166136261,s=e.join("");for(let o=0;o<s.length;o++)t^=s.charCodeAt(o),t=Math.imul(t,16777619);return`${(t>>>0).toString(16).padStart(8,"0")}:${s.length}`}function xne(e={}){let t=e.maxSize??4,s=e.dispose,o=new Map,r=0,n=null,i=null;function l(u){u.lastUsed=++r}function d(){for(;o.size>t;){let u=null;for(let c of o.values())c.hash===n||c.hash===i||(!u||c.lastUsed<u.lastUsed)&&(u=c);if(!u)break;o.delete(u.hash),s?.(u.value,u.hash)}}return{getOrBuild(u,c){let _=o.get(u);if(_)return l(_),u===n?i=null:i=u,_.value;let m=c(),f={hash:u,value:m,lastUsed:++r};return o.set(u,f),n===null?(n=u,i=null):i=u,d(),m},markReady(u){if(u!==i)return;let c=o.get(u);c&&(n=u,i=null,l(c),d())},get renderValue(){let u=n??i;return u?o.get(u)?.value??null:null},get activeHash(){return n},get pendingHash(){return i},release(u){let c=o.get(u);c&&(o.delete(u),s?.(c.value,u),n===u&&(n=null),i===u&&(i=null))},has(u){return o.has(u)},get size(){return o.size},clear(){for(let u of o.values())s?.(u.value,u.hash);o.clear(),n=null,i=null}}}var sp="passManager";function bne(e,t){let{textureManager:s,dispatcher:o}=t,r=t.canvasFormat??Ane(),n=t.rttFormat??"rgba16float",i=e.device?.limits?.maxSampledTexturesPerShaderStage,l=t.maxSampledTextures??(typeof i=="number"&&i>0?i:16),d=t.fullScreenTriangle??cne,u=new Map,c=new Set,_=null;function m(){let y=s.samplers;try{return e.createBindGroup(Zg,{linearClamp:y.linearClamp,nearestClamp:y.nearestClamp,linearRepeat:y.linearRepeat,nearestRepeat:y.nearestRepeat})}catch(R){io(`[${sp}] failed to build sampler bind group:`,R);return}}function f(y,R){let U=new Set;for(let O of y.textures)if(O.kind==="rtt")if(U.add(O.key),u.has(O.key))u.get(O.key).resize(R.width,R.height);else{let I=s.createRenderTexture({width:R.width,height:R.height,format:n,label:`rtt:${O.key}`});u.set(O.key,I),c.add(I)}for(let[O,I]of[...u])U.has(O)||(I.destroy(),c.delete(I),u.delete(O))}function h(y,R){if(!y.textureLayout||y.reads.length===0)return;let U={};for(let O of y.reads){let I=u.get(O),N=R?.[O],G=I??N;if(!G){io(`[${sp}] pass "${y.entry}" reads unknown texture "${O}"`);return}U[O]=G.texture}y.reads.length>l&&Wa(`[${sp}] pass samples ${y.reads.length} textures (> device limit ~${l}); composition may fail on this device.`);try{return e.createBindGroup(y.textureLayout,U)}catch(O){io(`[${sp}] failed to build texture bind group:`,O);return}}function A(y,R){return e.createRenderPipeline({vertex:d,fragment:y.entry,targets:{format:R}})}function w(y,R){if(!y.externalLayout||y.externalReads.length===0)return;let U=y.externalReads;if(U.length===1){let I=R.get(U[0]);if(!I){io(`[${sp}] external read "${U[0]}" has no registered source`);return}return s.createExternalTextureBinding({layout:y.externalLayout,entryKey:U[0],getSource:I})}let O=null;return{update(){let I={};for(let N of U){let G=R.get(N)?.();if(!G)return O=null,null;try{I[N]=e.device.importExternalTexture({source:G})}catch{return O=null,null}}return O=e.createBindGroup(y.externalLayout,I),O},get current(){return O},destroy(){O=null}}}function S(y,R,U,O){let I=R.kind==="canvas"?r:n,N=y.reads.filter(q=>U?.[q]),G=new Map(N.map(q=>[q,U[q].texture]));return{fragment:y,pipeline:A(y,I),textureBindGroup:h(y,U),externalBinding:w(y,O),target:R,mediaReads:N,mediaSnapshot:G}}function T(y,R,U,O){f(y,U);for(let Y of y.computeSteps)Y.bindInputs?.(X=>u.get(X)??O?.[X]);let I=m(),N=new Map;for(let Y of y.externalTextures)N.set(Y.key,Y.getSource);let G=y.rttPasses.map(Y=>S(Y.fragment,{kind:"rtt",key:Y.textureKey},O,N)),q=S(y.finalPass,{kind:"canvas"},O,N);_={ir:y,uniformBindGroup:R,samplerBindGroup:I,computeSteps:y.computeSteps,rttPasses:G,finalPass:q,size:U,mediaResources:O}}function x(y,R){let U=y.pipeline;if(_?.uniformBindGroup&&(U=U.with(_.uniformBindGroup)),y.mediaReads&&y.mediaReads.length>0&&_?.mediaResources){let O=!1;for(let I of y.mediaReads)_.mediaResources[I].texture!==y.mediaSnapshot.get(I)&&(O=!0);if(O){y.textureBindGroup=h(y.fragment,_.mediaResources);for(let I of y.mediaReads)y.mediaSnapshot.set(I,_.mediaResources[I].texture)}}if(y.textureBindGroup&&(U=U.with(y.textureBindGroup)),y.fragment.usesSamplers&&_?.samplerBindGroup&&(U=U.with(_.samplerBindGroup)),y.fragment.externalReads.length>0){let O=y.externalBinding?.update()??null;if(!O){y.externalSkipLogged||(Wa(`[${sp}] external texture not ready \u2014 skipping pass (${y.fragment.externalReads.join(", ")})`),y.externalSkipLogged=!0);return}U=U.with(O)}U.withColorAttachment({view:R}).draw(3)}function D(y,R){if(_){for(let U of _.computeSteps){let O=U.getComputeNodes(R);O&&O.length&&o.dispatch(O)}k(),x(_.finalPass,y)}}function k(){if(_)for(let y of _.rttPasses){let R=u.get(y.target.key);R&&x(y,B(R))}}function B(y){return e.unwrap(y.texture).createView()}function E(y){if(!(!y.fragment.textureLayout||y.fragment.reads.length===0)&&(y.textureBindGroup=h(y.fragment,_?.mediaResources),y.mediaReads&&y.mediaSnapshot&&_?.mediaResources))for(let R of y.mediaReads)y.mediaSnapshot.set(R,_.mediaResources[R].texture)}function z(y,R){let U=!1;for(let O of u.values())O.resize(y,R)&&(U=!0);if(!_)return U;if(_.size={width:y,height:R},!U)return!1;for(let O of _.computeSteps)O.bindInputs?.(I=>u.get(I)??_.mediaResources?.[I]);for(let O of _.rttPasses)E(O);return E(_.finalPass),!0}return{setComposition:T,render:D,repaintRtt:k,resize:z,get textureCount(){return c.size},get passCount(){return _?_.rttPasses.length+1:0},dispose(){for(let y of[...c])y.destroy();c.clear(),u.clear(),_=null}}}function Ane(){return typeof navigator<"u"&&navigator.gpu?navigator.gpu.getPreferredCanvasFormat():"bgra8unorm"}function rO(e){return`${e}-srgb`}function wne(e){let t=new Set;function s(f,...h){return e.createTexture.call(e,f).$usage(...h)}let o,r,n,i,l={get linearClamp(){return o??=e.createSampler({magFilter:"linear",minFilter:"linear",mipmapFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"})},get nearestClamp(){return r??=e.createSampler({magFilter:"nearest",minFilter:"nearest",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"})},get linearRepeat(){return n??=e.createSampler({magFilter:"linear",minFilter:"linear",mipmapFilter:"linear",addressModeU:"repeat",addressModeV:"repeat"})},get nearestRepeat(){return i??=e.createSampler({magFilter:"nearest",minFilter:"nearest",addressModeU:"repeat",addressModeV:"repeat"})}};function d(f,h,A,w,S){let T={texture:f,width:h,height:A,format:w,write(x){f.write(x)},unwrap(){return e.unwrap(f)},createSrgbView(){if(S)return e.unwrap(f).createView({format:rO(w)})},generateMipmaps(){f.generateMipmaps?.()},destroy(){t.has(T)&&(f.destroy(),t.delete(T))}};return t.add(T),T}function u(f){let{width:h,height:A,srgb:w=!1,mipLevelCount:S}=f,T=f.format??"rgba8unorm";return d(s({size:[h,A],format:T,...w?{viewFormats:[rO(T)]}:{},...S?{mipLevelCount:S}:{}},"sampled","render"),h,A,T,w)}function c(f){let{width:h,height:A,format:w,data:S}=f,T=d(s({size:[h,A],format:w},"sampled"),h,A,w,!1);return S&&T.write(S),T}function _(f){let h=f.format??"rgba16float",{mipLevelCount:A}=f,w=f.width,S=f.height;function T(D,k){return d(s({size:[D,k],format:h,...A?{mipLevelCount:A}:{}},"sampled","render"),D,k,h,!1)}let x=T(w,S);return{get texture(){return x.texture},get width(){return w},get height(){return S},format:h,write(D){x.write(D)},unwrap(){return x.unwrap()},createSrgbView(){return x.createSrgbView()},generateMipmaps(){x.generateMipmaps()},resize(D,k){return D===w&&k===S?!1:(x.destroy(),w=D,S=k,x=T(D,k),!0)},destroy(){x.destroy()}}}function m(f){let{layout:h,entryKey:A,getSource:w,staticEntries:S={}}=f,T=null;return{update(){let x=w();if(!x)return T=null,null;let D;try{D=e.device.importExternalTexture({source:x})}catch{return T=null,null}return T=e.createBindGroup(h,{...S,[A]:D}),T},get current(){return T},destroy(){T=null}}}return{samplers:l,createMediaTexture:u,createDataTexture:c,createRenderTexture:_,createExternalTextureBinding:m,get textureCount(){return t.size},destroy(){for(let f of[...t])f.destroy();t.clear()}}}function W3(e,t,s,o,r,n){if(o===0&&r===0)return[s,0];let i=200*Math.pow(.01,o),l=2*Math.sqrt(i)*(1-r*.85),d=t+(i*(s-e)-l*t)*n;return[e+d*n,d]}function Tne(e){return e<1/2.75?7.5625*e*e:e<2/2.75?(e-=1.5/2.75,7.5625*e*e+.75):e<2.5/2.75?(e-=2.25/2.75,7.5625*e*e+.9375):(e-=2.625/2.75,7.5625*e*e+.984375)}function aO(e,t){switch(t){case"linear":return e;case"quad":return e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2;case"expo":return e===0?0:e===1?1:e<.5?Math.pow(2,20*e-10)/2:(2-Math.pow(2,-20*e+10))/2;case"bounce":return Tne(e);default:return(1-Math.cos(Math.PI*e))/2}}function Sne(e,t,s){let o=s.pixelRatio||1,r=Math.max(1,Math.floor(s.maxTextureDim/o)-1),n=Math.min(e,s.viewportWidth,r),i=Math.min(t,s.viewportHeight,r),l=Math.min(n/e,i/t,1);return{width:Math.max(1,Math.round(e*l)),height:Math.max(1,Math.round(t*l))}}function Cne(e,t,s,o){return e!=null?(o-e)/1e3:t+s}function Pne(e,t){let{lastRenderTime:s,isVisible:o,forceFullFrameRate:r}=t,n=s>0?(e-s)/1e3:.016;if(s>0){let i=e-s;if(!o&&!r&&i<1e3)return{render:!1,deltaTime:n};if((o||r)&&i<15.666666666666668)return{render:!1,deltaTime:n}}return{render:!0,deltaTime:Math.min(n,.1)}}async function nO(e){try{let t=e.device?.queue;if(t&&typeof t.onSubmittedWorkDone=="function"){await t.onSubmittedWorkDone();return}}catch{}await new Promise(t=>setTimeout(t,16))}function Mne(e){e.updateDrivers(),e.ensureComposition()&&(e.beforeRender(),e.flush(),e.render(),e.markReady(),e.afterRender())}function Ene(e){let t=null,s=n=>typeof requestAnimationFrame=="function"?requestAnimationFrame(n):setTimeout(()=>n(performance.now()),16),o=n=>{typeof cancelAnimationFrame=="function"?cancelAnimationFrame(n):clearTimeout(n)},r=()=>{e(),t!==null&&(t=s(r))};return{start(){t===null&&(t=s(r))},stop(){t!==null&&(o(t),t=null)},get running(){return t!==null}}}function kne(e,t){let s=I3(e)?.definition?.naturalSizeKey;if(!s)return null;if("fixed"in s)return s.fixed||null;let o=t[s.fromProp];return typeof o=="string"&&o?o:null}function Rne(e,t,s){if(!e||typeof e!="object")return null;let o=(i,l)=>!i||typeof i!="object"||typeof i.value!="number"?null:i.unit==="px"?i.value:i.value*l,r=o(e.width,t),n=o(e.height,s);return r!=null&&n!=null&&r>0&&n>0?{widthPx:r,heightPx:n}:null}function Dne(e,t,s){let{type:o,decl:r,props:n,boundingBox:i}=e;if(!(t>0)||!(s>0)||e.requiresChild)return null;if(r?.computeBounds){let c=r.computeBounds(n,t,s);return c.widthPx>0&&c.heightPx>0?{widthPx:c.widthPx,heightPx:c.heightPx}:null}let l=r?.propBindings;if(l?.width&&l?.height){let c=u_(l.width,n[l.width.prop],t,s),_=u_(l.height,n[l.height.prop],t,s);return c>0&&_>0?{widthPx:c,heightPx:_}:null}let d=Rne(i,t,s);if(d)return d;let u=kne(o,n);if(u){let c=nP(u);if(c)return{widthPx:c.width,heightPx:c.height}}return null}function zne(e,t){return e==null?0:typeof e=="number"?e:e.unit==="px"?e.value:e.value*t}function q3(e,t,s){return!e||e.mode!=="column"&&e.mode!=="row"?null:{mode:e.mode,gapPx:Math.max(0,zne(e.gap,e.mode==="column"?s:t)),align:e.align??"center",anchor:e.anchor??"center",anchorOffsetX:e.anchorOffset?.x??0,anchorOffsetY:e.anchorOffset?.y??0}}var iO=e=>({ox:e.includes("left")?"start":e.includes("right")?"end":"center",oy:e.includes("top")?"start":e.includes("bottom")?"end":"center"}),Ch=(e,t,s,o)=>e==="start"?o:e==="end"?s-t-o:(s-t)/2+o;function Ph(e,t){let s=0,o=0;for(let r of t){let n=e.mode==="column"?r.size.heightPx:r.size.widthPx,i=e.mode==="column"?r.size.widthPx:r.size.heightPx;s+=n,o=Math.max(o,i)}return t.length>1&&(s+=e.gapPx*(t.length-1)),e.mode==="column"?{widthPx:o,heightPx:s}:{widthPx:s,heightPx:o}}function Bne(e,t,s,o){let r=new Map;if(t.length===0)return r;let n=Ph(e,t),{ox:i,oy:l}=iO(e.anchor),d=Ch(i,n.widthPx,s,e.anchorOffsetX),u=Ch(l,n.heightPx,o,e.anchorOffsetY),c=(m,f)=>e.align==="start"?0:e.align==="end"?f-m:(f-m)/2,_=0;for(let m of t)if(e.mode==="column"){let f=d+c(m.size.widthPx,n.widthPx)+m.size.widthPx/2,h=u+_+m.size.heightPx/2;r.set(m.id,{centerXPx:f,centerYPx:h}),_+=m.size.heightPx+e.gapPx}else{let f=d+_+m.size.widthPx/2,h=u+c(m.size.heightPx,n.heightPx)+m.size.heightPx/2;r.set(m.id,{centerXPx:f,centerYPx:h}),_+=m.size.widthPx+e.gapPx}return r}function Lne(e,t,s){let o=q3(e.layout,t,s);if(o){let r=X3(e,t,s);return r.length===0?null:Ph(o,r)}return Dne({type:e.componentName,decl:e.decl,props:e.props,boundingBox:e.boundingBox,requiresChild:e.requiresChild,availableWidthPx:t},t,s)}function X3(e,t,s){let o=[];for(let r of e.children){if(r.visible===!1||r.absolute)continue;let n=Lne(r,t,s);n&&o.push({id:r.id,size:n,view:r})}return o}function Une(e,t,s){if(!e.decl?.computeBounds)return{x:0,y:0};let o=e.decl.computeBounds(e.props,t,s),r=typeof e.props.center?.x=="number"?e.props.center.x:.5,n=typeof e.props.center?.y=="number"?e.props.center.y:.5;return{x:o.centerXPx-r*t,y:o.centerYPx-n*s}}function One(e,t,s,o,r,n,i,l){let d=q3(e.layout,r,n);if(d){lO(e,d,r,n,i,{centerXPx:s,centerYPx:o},l);return}let u=e.decl?.propBindings?.x?.prop??e.decl?.propBindings?.y?.prop;if(u){if(!e.positionDriven){let c=Une(e,r,n);i.push({kind:"position",id:e.id,prop:u,value:{x:(s-c.x)/r,y:(o-c.y)/n}})}return}i.push({kind:"box",id:e.id,xPx:s-t.widthPx/2,yPx:o-t.heightPx/2,widthPx:t.widthPx,heightPx:t.heightPx})}function lO(e,t,s,o,r,n,i,l){let d=l??X3(e,s,o);if(d.length===0)return;let u=t;if(n){let _=Ph(t,d);u={...t,anchor:"top-left",anchorOffsetX:n.centerXPx-_.widthPx/2,anchorOffsetY:n.centerYPx-_.heightPx/2}}if(i){let _=Ph(u,d),{ox:m,oy:f}=iO(u.anchor);i.set(e.id,{leftPx:Ch(m,_.widthPx,s,u.anchorOffsetX),topPx:Ch(f,_.heightPx,o,u.anchorOffsetY),widthPx:_.widthPx,heightPx:_.heightPx})}let c=Bne(u,d,s,o);for(let _ of d){let m=c.get(_.id);m&&One(_.view,_.size,m.centerXPx,m.centerYPx,s,o,r,i)}}function Gne(e,t,s,o){let r=[],n=i=>{let l=q3(i.layout,t,s);if(l){let d=X3(i,t,s);lO(i,l,t,s,r,void 0,o,d);let u=new Set(d.map(c=>c.id));for(let c of i.children)c.visible!==!1&&(u.has(c.id)||n(c));return}for(let d of i.children)d.visible!==!1&&n(d)};for(let i of e)i.visible!==!1&&n(i);return r}var Fne=class{frameTimesMs=[];frameTimesIndex=0;frameTimesCount=0;maxSamples=60;targetFrameTime=16.67;jankFrameCount=0;totalFrameCount=0;memorySnapshots=[];memorySnapshotIndex=0;maxMemorySnapshots=300;nodeCount=0;rttNodeCount=0;lastCpuTime=null;lastGpuTime=null;isRendering=!1;lastFrameTimestamp=0;frameIntervals=[];frameIntervalsIndex=0;frameIntervalsCount=0;pushToCircularBuffer(e,t,s,o,r){return e.length<r?(e.push(t),{index:e.length,count:e.length}):(e[s%r]=t,{index:s+1,count:r})}getBufferValues(e,t){return t<=e.length?e.slice(0,t):e}recordFrame(e){let t=this.pushToCircularBuffer(this.frameTimesMs,e,this.frameTimesIndex,this.frameTimesCount,this.maxSamples);this.frameTimesIndex=t.index,this.frameTimesCount=t.count,this.totalFrameCount++,e>this.targetFrameTime&&this.jankFrameCount++;let s=performance.now();if(this.lastFrameTimestamp>0){let o=s-this.lastFrameTimestamp,r=this.pushToCircularBuffer(this.frameIntervals,o,this.frameIntervalsIndex,this.frameIntervalsCount,this.maxSamples);this.frameIntervalsIndex=r.index,this.frameIntervalsCount=r.count}this.lastFrameTimestamp=s,this.recordMemorySnapshot()}recordCpuTime(e){this.lastCpuTime=e}recordGpuTime(e){this.lastGpuTime=e}updateNodeCounts(e,t){this.nodeCount=e,this.rttNodeCount=t}setRendering(e){this.isRendering=e}recordMemorySnapshot(){if(!performance.memory)return;let e=performance.now(),t=performance.memory.usedJSHeapSize;if(this.memorySnapshots.length<this.maxMemorySnapshots)this.memorySnapshots.push({time:e,bytes:t});else{let s=this.memorySnapshots[this.memorySnapshotIndex];s.time=e,s.bytes=t,this.memorySnapshotIndex=(this.memorySnapshotIndex+1)%this.maxMemorySnapshots}}calculateMemoryGrowthRate(){if(this.memorySnapshots.length<2)return null;let e=this.memorySnapshots.length,t=e<this.maxMemorySnapshots?0:this.memorySnapshotIndex,s=e<this.maxMemorySnapshots?e-1:(this.memorySnapshotIndex-1+e)%e,o=this.memorySnapshots[t],r=this.memorySnapshots[s],n=(r.time-o.time)/1e3;return n<=0?null:(r.bytes-o.bytes)/(1024*1024)/n}calculateStdDev(e){if(e.length===0)return 0;let t=e.reduce((o,r)=>o+r,0)/e.length,s=0;for(let o=0;o<e.length;o++){let r=e[o]-t;s+=r*r}return Math.sqrt(s/e.length)}sortBuffer=[];calculateP99(e){let t=e.length;if(t===0)return 0;for(;this.sortBuffer.length<t;)this.sortBuffer.push(0);for(let o=0;o<t;o++)this.sortBuffer[o]=e[o];for(let o=1;o<t;o++){let r=this.sortBuffer[o],n=o-1;for(;n>=0&&this.sortBuffer[n]>r;)this.sortBuffer[n+1]=this.sortBuffer[n],n--;this.sortBuffer[n+1]=r}let s=Math.floor(t*.99);return this.sortBuffer[Math.min(s,t-1)]}calculateComplexityScore(){return this.nodeCount+this.rttNodeCount*10}calculateIntensityScore(){let e=this.getBufferValues(this.frameTimesMs,this.frameTimesCount),t=e.length;if(t===0)return{score:0,label:"N/A"};let s=e.reduce((c,_)=>c+_,0)/t,o=Math.min(s/16.67*100,100),r=this.calculateComplexityScore(),n=Math.min(r/100*100,100),i=0;this.lastGpuTime!==null&&(i=Math.min(this.lastGpuTime/16.67*100,100));let l=this.lastGpuTime!==null?{frame:.4,gpu:.4,complexity:.2}:{frame:.7,gpu:0,complexity:.3},d=Math.round(o*l.frame+i*l.gpu+n*l.complexity),u;return d<=20?u="Very Light":d<=40?u="Light":d<=60?u="Medium":d<=80?u="Heavy":u="Very Heavy",{score:Math.min(d,100),label:u}}getStats(e){let t=this.getBufferValues(this.frameTimesMs,this.frameTimesCount),s=this.getBufferValues(this.frameIntervals,this.frameIntervalsCount),o=t.length,r=s.length>0?1e3/(s.reduce((x,D)=>x+D,0)/s.length):0,n=o>0?t.reduce((x,D)=>x+D,0)/o:0,i=o>0?Math.min(...t):0,l=o>0?Math.max(...t):0,d=this.calculateP99(t),u=this.calculateStdDev(t),c=this.totalFrameCount>0?this.jankFrameCount/this.totalFrameCount*100:0,_=performance.memory,m=_?_.usedJSHeapSize/(1024*1024):null,f=this.calculateMemoryGrowthRate(),h=n>0?n/this.targetFrameTime*100:0,A=e?.render?.calls??null,w=e?.programs?.length??null,S=e?.memory?.textures??null,T=this.calculateIntensityScore();return{fps:Math.round(r),avgFrameTime:Math.round(n*100)/100,minFrameTime:Math.round(i*100)/100,maxFrameTime:Math.round(l*100)/100,p99FrameTime:Math.round(d*100)/100,stdDevFrameTime:Math.round(u*100)/100,jankCount:this.jankFrameCount,jankPercent:Math.round(c*10)/10,nodeCount:this.nodeCount,rttNodeCount:this.rttNodeCount,complexityScore:this.calculateComplexityScore(),memoryUsedMB:m!==null?Math.round(m*100)/100:null,memoryGrowthRate:f!==null?Math.round(f*1e3)/1e3:null,cpuTime:this.lastCpuTime!==null?Math.round(this.lastCpuTime*100)/100:null,gpuTime:this.lastGpuTime!==null?Math.round(this.lastGpuTime*100)/100:null,budgetUsed:Math.round(h*10)/10,drawCalls:A,shaderPrograms:w,textureCount:S,intensityScore:T.score,intensityLabel:T.label,isRendering:this.isRendering}}reset(){this.frameTimesMs.length=0,this.frameTimesIndex=0,this.frameTimesCount=0,this.frameIntervals.length=0,this.frameIntervalsIndex=0,this.frameIntervalsCount=0,this.lastFrameTimestamp=0,this.jankFrameCount=0,this.totalFrameCount=0,this.memorySnapshots.length=0,this.memorySnapshotIndex=0,this.sortBuffer.length=0,this.lastCpuTime=null,this.lastGpuTime=null}},Ine=32,Yne=5,Wne=(()=>{let e=0,t=new Set,s=(u,c)=>{t.forEach(_=>{try{_[u](c)}catch(m){io("[Shaders] Error in pointer handler:",m)}})},o=u=>s("onMouseMove",u),r=u=>s("onTouchMove",u),n=u=>s("onMouseDown",u),i=u=>s("onTouchStart",u),l=()=>s("onMouseUp"),d=()=>s("onTouchEnd");return{register(u){return t.add(u),e++,e===1&&typeof window<"u"&&(window.addEventListener("mousemove",o),window.addEventListener("touchmove",r),window.addEventListener("mousedown",n,!0),window.addEventListener("touchstart",i,!0),window.addEventListener("mouseup",l,!0),window.addEventListener("touchend",d,!0)),()=>{t.delete(u),e--,e===0&&typeof window<"u"&&(window.removeEventListener("mousemove",o),window.removeEventListener("touchmove",r),window.removeEventListener("mousedown",n,!0),window.removeEventListener("touchstart",i,!0),window.removeEventListener("mouseup",l,!0),window.removeEventListener("touchend",d,!0))}}}})();function Vne(e){if(!e)return!1;let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{return!1}if(!t||typeof t!="object")return!1;for(let s in t){let o=t[s];if(o&&typeof o=="object"&&o.type==="mouse")return!0}return!1}function dO(){let e=null,t=null,s=null,o=null,r=null,n=null,i=!1,l=!1,d=!1,u=null,c=new Map,_=null,m=new Map,f=[],h=[],A=xne({maxSize:4,dispose:Q=>ip(Q)}),w=new Set,S=null,T=null,x=!0,D=0,k=0,B=0,E=0,z=1,y=8192,R=0,U=0,O=!1,I=()=>B||D||1,N=()=>E||k||1,G=!0,q=!1,Y=!1,X=0,H=0,re=null,ee=null,pe=-10,de=-10,se=!1,ie=null,ye=!1,be=null,ge=null,Be=null,Le=null,Ee=null,Te=null,De=!1,Ne="p3-linear",Oe="linear",Ie=!1,He=null,Ze=null,Je=!1,ut=!1,tt=null,it=!1,lt=null,vt=null,wt=!1,mt=null,gt=null,kt=0,Rt=0,Pt=new Fne,pt={deltaTime:0,pointer:{x:-10,y:-10},pointerActive:!1,dimensions:{width:0,height:0}},Ft=Ene(()=>id()),Yt=Q=>Q.replace(/[^a-zA-Z0-9_]/g,"_"),Ut=Q=>{let te=m.get(Q);if(!te)return[];let oe=[];for(let xe of te){let he=c.get(xe);he&&oe.push(he)}return oe},Ht=Q=>{let te=Yt(Q);for(let[oe,xe]of c)if(xe.metadata.id===te)return oe;return null},Ot=(Q,te)=>{if(te==="center")return;let oe=Q.boundingBoxDeclaration;if(!oe)return;let xe={};for(let[he,Pe]of Object.entries(Q.uniforms))xe[he]=Pe._rawDimensional!==void 0?Pe._rawDimensional:Pe.value;return tx(oe,xe,I(),N())},qt=Q=>{let te=Q.boundingBoxDeclaration,oe=Q.extraDimProps,xe=_u(te,oe);if(!xe)return;let he=Q.uniforms.origin?.value??"center",Pe=Ot(Q,he),qe=[...xe.positionProps,...xe.sizeProps.keys()];for(let _t of qe){let St=Q.uniforms[_t];if(!St||St._rawDimensional===void 0)continue;let os=__(te,_t,St._rawDimensional,he,I(),N(),oe,Pe);St.value=os,On(Q,_t,os)}},jt=(Q,te,oe)=>{if(typeof oe=="number")return oe;let xe=Q.uniforms.origin?.value??"center",he=__(Q.boundingBoxDeclaration,te,oe,xe,I(),N(),Q.extraDimProps);return typeof he=="number"?he:oe?.value??0},_s=()=>{let{width:Q,height:te}=Gn();return Q/Math.max(1,te)},ce=Q=>{let te=Q.metadata.transform;return{offsetX:te?.offsetX??0,offsetY:te?.offsetY??0,rotation:te?.rotation??0,scale:te?.scale??1,anchorX:te?.anchorX??.5,anchorY:te?.anchorY??.5,aspectRatio:_s()}},ze=Q=>{let te=Q.metadata.boundingBox;if(!te)return null;let oe=Qg(te,I(),N());return{centerX:oe.centerX,centerY:oe.centerY,halfWidth:oe.halfWidthUV,halfHeight:oe.halfHeightUV,cornerRadius:oe.cornerRadiusUV,rotation:oe.rotation,aspectRatio:_s()}},we=Q=>!!Q.metadata.boundingBox&&!!Q.boundingBoxDeclaration&&!q1(Q.metadata.boundingBox),Se=Q=>{let te=Q.boundingBoxDeclaration;if(!te||!Q.uniforms||!te.computeBounds&&!te.propBindings)return null;let oe={};for(let[St,os]of Object.entries(Q.uniforms))oe[St]=os._rawDimensional!==void 0?os._rawDimensional:os.value;let xe=tx(te,oe,I(),N());if(xe.hwx<=0&&xe.hhy<=0)return null;let he=.5,Pe=.5,qe=te.propBindings?.x?.prop??te.propBindings?.y?.prop,_t=qe?Q.uniforms[qe]?.value:void 0;if(_t&&typeof _t.x=="number"&&typeof _t.y=="number"&&(he=_t.x,Pe=_t.y),qe){let St=Q.metadata.maps?.[qe];if(St?.type==="mouse-position"){let os=Q.mouseDriverState[qe];os&&(he=os.liveX??(typeof St.x=="number"?St.x:os.currentX),Pe=os.liveY??(typeof St.y=="number"?St.y:os.currentY))}}return{centerX:he,centerY:Pe,halfWidth:xe.hwx,halfHeight:xe.hhy}},Me=Q=>{if(!Q.definition.wantsBoundsParams)return null;let te=Ut(Q.id).sort((oe,xe)=>oe.metadata.renderOrder-xe.metadata.renderOrder);for(let oe of te){if(oe.metadata.visible===!1)continue;if(we(oe))return null;let xe=Se(oe);if(xe)return xe}return null},$e=()=>{for(let Q of c.values()){if(!Q.definition.wantsBoundsParams)continue;let te=Me(Q);te&&(ys(Q,"_childBounds_centerX",te.centerX),ys(Q,"_childBounds_centerY",te.centerY),ys(Q,"_childBounds_halfWidth",te.halfWidth),ys(Q,"_childBounds_halfHeight",te.halfHeight))}},ot=!1,ft=()=>{ot=!0,cn()},xt=()=>{for(let Q of c.values()){let te=Q.metadata.flow?.mode;if(te==="column"||te==="row")return!0}return!1},ht=Q=>{let te={};for(let[Pe,qe]of Object.entries(Q.uniforms))te[Pe]=qe._rawDimensional!==void 0?qe._rawDimensional:qe.value;let oe=Q.boundingBoxDeclaration?.propBindings?.x?.prop??Q.boundingBoxDeclaration?.propBindings?.y?.prop,xe=oe?Q.uniforms[oe]?.value:void 0,he=!!(oe&&(xe?.type==="mouse-position"||Q.metadata.maps?.[oe]));return{id:Q.id,componentName:Q.componentName,visible:Q.metadata.visible!==!1,absolute:Q.metadata.absolute===!0,requiresChild:Q.requiresChild,layout:Q.metadata.flow,decl:Q.boundingBoxDeclaration,props:te,boundingBox:Q.metadata.boundingBox,positionDriven:he,children:Ut(Q.id).sort((Pe,qe)=>Pe.metadata.renderOrder-qe.metadata.renderOrder).map(ht)}},Kt=()=>{if(!xt()){ot=!1;return}let Q=I(),te=N();if(Q<=1||te<=1)return;ot=!1;let oe=[];for(let he of c.values())he.parentId===null&&oe.push(ht(he));let xe=Gne(oe,Q,te);for(let he of xe){let Pe=c.get(he.id);if(Pe)if(he.kind==="position"){let qe=Pe.uniforms[he.prop];if(!qe)continue;let _t=qe.value,St=_t&&typeof _t=="object"?{..._t,x:he.value.x,y:he.value.y}:he.value;qe.value=St,On(Pe,he.prop,St)}else{let qe=we(Pe);if(Pe.metadata.boundingBox={x:{value:he.xPx,unit:"px"},y:{value:he.yPx,unit:"px"},width:{value:he.widthPx,unit:"px"},height:{value:he.heightPx,unit:"px"},origin:"top-left",rotation:Pe.metadata.boundingBox?.rotation??0,...Pe.metadata.boundingBox?.cornerRadius?{cornerRadius:Pe.metadata.boundingBox.cornerRadius}:{},...Pe.metadata.boundingBox?.lockAspect!==void 0?{lockAspect:Pe.metadata.boundingBox.lockAspect}:{}},!qe&&we(Pe))Fn();else{let _t=ze(Pe);if(_t)for(let[St,os]of Object.entries(_t))ys(Pe,`_bbox_${St}`,os)}}}},Qt=()=>{ot&&Kt()},Es=null,Os=()=>{xt()&&ft()},Is=()=>{Es||(Es=iP(()=>{xt()&&ft()})),typeof document<"u"&&document.fonts?.addEventListener&&document.fonts.addEventListener("loadingdone",Os)};Is();let is=Q=>Ei(Q.metadata.transform),eo=(Q,te,oe)=>{let xe=Q.mapValues[te]??{inputMin:0,inputMax:1,outputMin:0,outputMax:1,curve:0};if(oe.type==="map"){let he=oe;xe.inputMin=he.inputMin,xe.inputMax=he.inputMax,xe.outputMin=jt(Q,te,he.outputMin),xe.outputMax=jt(Q,te,he.outputMax),xe.curve=he.curve??0}else if(oe.type==="mouse"){let he=oe;xe.outputMin=jt(Q,te,he.outputMin),xe.outputMax=jt(Q,te,he.outputMax),xe.curve=he.curve??0}else if(oe.type==="auto-animate"){let he=oe;xe.outputMin=jt(Q,te,he.outputMin),xe.outputMax=jt(Q,te,he.outputMax)}return Q.mapValues[te]=xe,xe},Mo=(Q,te,oe)=>{let xe=Q.mouseDriverState[te];if(xe)return xe;if(oe.type==="mouse-position"){let he=oe.x===void 0||oe.x==="mouse",Pe=oe.y===void 0||oe.y==="mouse";xe={currentX:he?pe:oe.x,currentY:Pe?de:oe.y,velocityX:0,velocityY:0}}else xe={currentX:Math.max(.001,oe.axis==="x"?pe:de),currentY:0,velocityX:0,velocityY:0};return Q.mouseDriverState[te]=xe,xe},or=Q=>{let te=Q.metadata.maps;if(te)for(let[oe,xe]of Object.entries(te))oe in Q.uniforms&&(xe.type==="map"?eo(Q,oe,xe):xe.type==="mouse-position"?Mo(Q,oe,xe):xe.type==="mouse"?(Mo(Q,oe,xe),eo(Q,oe,xe)):xe.type==="auto-animate"&&(Q.autoAnimateState[oe]||(Q.autoAnimateState[oe]={}),eo(Q,oe,xe)))},rr=Q=>{let te=Q.definition.animatedTime;return(te?Q.uniforms[te.speed]:void 0)??Q},Ya=(Q,te)=>Q.uniforms[te]??Q,Ti=Q=>{let te=[];for(let[he,Pe]of Object.entries(Q.uniforms))te.push({name:he,initial:Pe.value,transform:Pe.transform,cpu:Pe.cpu,schema:Pe.schema});if(te.push({name:"_opacity",schema:a,initial:Q.metadata.opacity??1}),Q.definition.animatedTime&&te.push({name:"_animTime",schema:a,initial:ec(rr(Q)).value}),Q.definition.extraAnimatedTimes)for(let[he,Pe]of Object.entries(Q.definition.extraAnimatedTimes))te.push({name:`_animTime_${he}`,schema:a,initial:ec(Ya(Q,Pe)).value});let oe=Q.definition.extraFields;if(oe)for(let[he,Pe]of Object.entries(oe))te.push({name:he,schema:Pe.schema,initial:Pe.initial});if(is(Q)){let he=ce(Q);for(let[Pe,qe]of Object.entries(he))te.push({name:`_xform_${Pe}`,schema:a,initial:qe})}if(we(Q)){let he=ze(Q);if(he)for(let[Pe,qe]of Object.entries(he))te.push({name:`_bbox_${Pe}`,schema:a,initial:qe})}if(Q.definition.wantsBoundsParams){let he=Me(Q)??{centerX:.5,centerY:.5,halfWidth:.5,halfHeight:.5};for(let[Pe,qe]of Object.entries(he))te.push({name:`_childBounds_${Pe}`,schema:a,initial:qe})}let xe=Q.metadata.maps;if(xe){or(Q);for(let[he,Pe]of Object.entries(xe))if(he in Q.uniforms){if(Pe.type==="map"){let qe=Q.mapValues[he];te.push({name:`_map_${he}_inputMin`,schema:a,initial:qe.inputMin}),te.push({name:`_map_${he}_inputMax`,schema:a,initial:qe.inputMax}),te.push({name:`_map_${he}_outputMin`,schema:a,initial:qe.outputMin}),te.push({name:`_map_${he}_outputMax`,schema:a,initial:qe.outputMax}),te.push({name:`_map_${he}_curve`,schema:a,initial:qe.curve})}else if(Pe.type==="mouse-position"){let qe=Q.mouseDriverState[he];te.push({name:`_smoothed_${he}`,schema:p,initial:[qe.currentX,1-qe.currentY]})}else if(Pe.type==="mouse"){let qe=Q.mapValues[he];te.push({name:`_smoothed_${he}`,schema:a,initial:qe.outputMin})}else if(Pe.type==="auto-animate"){let qe=Q.mapValues[he];te.push({name:`_smoothed_${he}`,schema:a,initial:qe.outputMin})}}}return te},On=(Q,te,oe)=>{let xe=Q._liveHandles?.[te];xe&&(He?.(Ne),Iw(xe,oe))},ys=(Q,te,oe)=>{let xe=Q._liveHandles?.[te];xe instanceof Jn&&(xe.value=oe)},sc=(Q,te,oe)=>{let xe=Q._liveHandles?.[te];xe instanceof Jn&&(xe.value=oe)},op=Q=>{for(let te of Object.values(Q.uniforms))if(te.transform===at){let oe=te.value;if(typeof oe=="string")return at(oe);if(typeof oe=="number")return oe}return 0},rp=Q=>{if(!Q.uniforms.convertedColorsArray)return;let te=null;for(let Pe of Object.values(Q.uniforms))if(Pe.transform===Ol){te=Pe.value??null;break}let oe=K0(te,Z0),xe=Q0(oe.colors,oe.stopCount,op(Q)),he=(Pe,qe)=>{let _t=Q.uniforms[Pe];_t&&(_t.value=qe),On(Q,Pe,qe)};he("colorsArray",oe.colors),he("positionsArray",oe.positions),he("convertedColorsArray",xe),he("stopCount",oe.stopCount)},ap=Q=>{if(ys(Q,"_opacity",Q.metadata.opacity??1),Q.definition.animatedTime&&ys(Q,"_animTime",ec(rr(Q)).value),Q.definition.extraAnimatedTimes)for(let[oe,xe]of Object.entries(Q.definition.extraAnimatedTimes))ys(Q,`_animTime_${oe}`,ec(Ya(Q,xe)).value);if(is(Q))for(let[oe,xe]of Object.entries(ce(Q)))ys(Q,`_xform_${oe}`,xe);if(we(Q)){let oe=ze(Q);if(oe)for(let[xe,he]of Object.entries(oe))ys(Q,`_bbox_${xe}`,he)}let te=Q.metadata.maps;if(te){for(let[oe,xe]of Object.entries(te))if(xe.type==="map"&&Q.mapValues[oe]){let he=Q.mapValues[oe];ys(Q,`_map_${oe}_inputMin`,he.inputMin),ys(Q,`_map_${oe}_inputMax`,he.inputMax),ys(Q,`_map_${oe}_outputMin`,he.outputMin),ys(Q,`_map_${oe}_outputMax`,he.outputMax),ys(Q,`_map_${oe}_curve`,he.curve)}}},il=(Q,te)=>{let oe={};for(let xe of Object.keys(Q.uniforms)){let he=te[xe];he&&(oe[xe]=he)}return oe},oc=Q=>{let te={};for(let[oe,xe]of Object.entries(Q.uniforms))te[oe]={accessorPath:"",cpu:!!xe.cpu,value:xe.value};return te},np=(Q,te)=>({id:Q.id,customId:Q.metadata.id,componentName:Q.componentName,parentId:Q.parentId,definition:Q.definition,metadata:Q.metadata,handles:te,domCanvas:Q.domCanvas}),rc=(Q,te)=>{let oe=new Map,xe=Pe=>np(Pe,Q&&te?il(Pe,te.get(Pe.id)??{}):oc(Pe)),he=Pe=>{let qe=oe.get(Pe);if(qe)return qe;let _t=c.get(Pe);if(!_t)return;let St=xe(_t);return oe.set(Pe,St),St};return{rootId:_,getNode:he,getChildren:Pe=>Ut(Pe).map(qe=>he(qe.id)),resolveCustomId:Pe=>Ht(Pe),store:{gpuAccessor:(Pe,qe)=>Q?Q.gpuAccessor(Pe,qe):"",layout:Q?.layout}}},ac=()=>({toneMapping:Oe,flipY:!1,premultiplyAlpha:!0,canvas:n??void 0,dimensions:Gn(),gpu:t?{device:t.device,root:t}:void 0,writeExtraField:(Q,te,oe)=>{let xe=c.get(Q);xe&&sc(xe,te,oe)},createMediaTexture:Q=>{if(!o)throw new Error("[gpu] createMediaTexture before init");return o.createMediaTexture(Q)},createDataTexture:Q=>{if(!o)throw new Error("[gpu] createDataTexture before init");return o.createDataTexture(Q)},resolveMapWindow:(Q,te)=>{let oe=c.get(Q),xe=oe?.metadata.maps?.[te];if(!oe||!xe||xe.type!=="map")return;let he=eo(oe,te,xe);return{inputMin:he.inputMin,inputMax:he.inputMax,outputMin:he.outputMin,outputMax:he.outputMax,curve:he.curve}},resolveDriverCpuValue:(Q,te)=>{let oe=c.get(Q),xe=oe?.metadata.maps?.[te];if(!(!oe||!xe)){if(xe.type==="mouse-position"){let he=oe.mouseDriverState[te];return!he||he.liveX===void 0||he.liveY===void 0?void 0:{x:he.liveX,y:1-he.liveY}}if(xe.type==="mouse"||xe.type==="auto-animate"){let he=oe._liveHandles?.[`_smoothed_${te}`];return he instanceof Jn?he.value:void 0}}}}),Mh=()=>{let Q=[];for(let[te,oe]of c){let xe=oe.metadata;Q.push(`aopac:${te}:${(xe.opacity??1)<1}`);let he=oe.uniforms.stopCount?.value;typeof he=="number"&&Q.push(`stops:${te}:${he>1?he:0}`);for(let[Pe,qe]of Object.entries(oe.uniforms)){if(!qe.compileTimeWhen)continue;let _t=qe._lastCompiledValue;typeof _t!="number"&&typeof _t!="boolean"||Q.push(`ctw:${te}:${Pe}:${String(_t)}`)}if(xe.maps){let Pe=Object.entries(xe.maps).sort(([qe],[_t])=>qe<_t?-1:qe>_t?1:0).map(([qe,_t])=>{let St=_t;return`${qe}=${St.type}:${St.source??""}:${St.channel??""}:${St.axis??""}`}).join(",");Q.push(`mapfp:${te}:${Pe}`)}}return Q},ym=()=>_?gne([...w7(rc(null,null),ac()),...Mh()]):null,Gn=()=>({width:Math.max(1,Math.round(D*z)),height:Math.max(1,Math.round(k*z))}),gm=Q=>{let te={};for(let oe of Q.textures)oe.kind!=="rtt"&&oe.resource&&(te[oe.key]=oe.resource);return te},xm=Q=>{if(!t||!o||!r)throw new Error("[gpu] buildComposition before init");let te=Fw(t,{systemSchema:yne}),oe=new Map;for(let[qe,_t]of c)oe.set(qe,te.defineNode(qe,Ti(_t)));te.defineSystem(),te.finalize();let xe=A7(rc(te,oe),ac()),he=bne(t,{textureManager:o,dispatcher:r});he.setComposition(xe,te.bindGroup,Gn(),gm(xe));let Pe={hash:Q,store:te,ir:xe,passManager:he,handlesById:oe,fresh:!0};return w.add(Pe),Pe},ip=Q=>{try{for(let te of Q.ir.onCleanup)te()}catch(te){io("[gpu] composition onCleanup error:",te)}try{Q.passManager.dispose()}catch(te){io("[gpu] passManager dispose error:",te)}try{Q.store.destroy()}catch(te){io("[gpu] store destroy error:",te)}w.delete(Q),S===Q&&(S=null)},Eh=Q=>{let te=!1;for(let[oe,xe]of Q.handlesById){let he=c.get(oe);he&&he._liveHandles!==xe&&(he._liveHandles=xe,te=!0)}if(!(Q===S&&!te)){if(!Q.fresh){for(let oe of c.values()){for(let[xe,he]of Object.entries(oe.uniforms))On(oe,xe,he.value);or(oe),ap(oe)}Q.store.writeAll()}Q.fresh=!1,S=Q,!Je&&Q.ir.composedNodeIds.size>0&&(ut=!0)}},Fn=()=>{x=!0,xt()&&(ot=!0),cn()},cn=()=>{lt||Ft.running||ee===null&&typeof requestAnimationFrame=="function"&&(ee=requestAnimationFrame(()=>{ee=null,id()}))},bm=(Q,te,oe,xe,he={},Pe,qe)=>{if(lt)return;if(te===null){let rs=f.findIndex(wr=>wr.id===Q);if(rs!==-1){f.splice(rs,1),h=h.filter(wr=>wr.id!==Q);return}ll(Q);return}if(!Pe){console.error(`[gpu] registerNode("${Q}") requires a componentDefinition`);return}if(!d){let rs=f.findIndex(Tn=>Tn.id===Q),wr={id:Q,definition:Pe,parentId:oe,metadata:xe,uniforms:he,domCanvas:qe};rs!==-1?(f[rs]=wr,h=h.filter(Tn=>Tn.id!==Q)):f.push(wr);return}let _t=0;if(oe!==null){let rs=m.get(oe);if(rs&&rs.size>0){let wr=0;for(let Tn of rs){let xa=c.get(Tn);xa&&xa.metadata.renderOrder>wr&&(wr=xa.metadata.renderOrder)}_t=wr+1}}let St={blendMode:xe?.blendMode||"normal",opacity:xe?.opacity,visible:xe?.visible!==!1,id:xe?.id?Yt(xe.id):xe?.id,mask:xe?.mask,maps:xe?.maps,renderOrder:xe?.renderOrder!==void 0?xe.renderOrder:_t,transform:xe?.transform,boundingBox:xe?.boundingBox,flow:xe?.flow,absolute:xe?.absolute},os=Pe.boundingBoxDeclaration,Uo=Pe.props?ex(Pe.props):void 0,No={id:Q,componentName:Pe.name||"Unknown",parentId:oe,definition:Pe,metadata:St,uniforms:he,domCanvas:qe,requiresRTT:!!Pe.requiresRTT,requiresChild:!!Pe.requiresChild,blendWithChildren:!!Pe.blendWithChildren,acceptsUVContext:!!Pe.acceptsUVContext,providesUVContextViaCompute:!!Pe.providesUVContextViaCompute,usesPointer:!!Pe.usesPointer,hasUvRemap:!!Pe.uvRemap,boundingBoxDeclaration:os,wantsBoundsParams:!!Pe.wantsBoundsParams,extraDimProps:Uo,mouseDriverState:{},autoAnimateState:{},mapValues:{},_liveHandles:null};if(os||Uo){let rs=_u(os,Uo);if(rs){let wr=he.origin?.value??"center",Tn=Ot(No,wr);for(let xa of[...rs.positionProps,...rs.sizeProps.keys()]){let aa=he[xa];aa&&(aa._rawDimensional===void 0&&(aa._rawDimensional=aa.value),aa.value=__(os,xa,aa._rawDimensional,wr,I(),N(),Uo,Tn))}}}for(let rs of Object.values(he))rs.compileTimeWhen&&rs._lastCompiledValue===void 0&&(rs._lastCompiledValue=rs.value);c.set(Q,No),oe===null&&(_=Q);let mo=m.get(oe)||new Set;mo.add(Q),m.set(oe,mo),cc(),Fn(),xt()&&ft()},Am=Q=>{f.some(te=>te.id===Q.id)&&h.push(Q)},wm=(Q,te,oe)=>{let xe=c.get(Q);if(!xe){Am({id:Q,kind:"uniform",name:te,value:oe});return}let he=xe.uniforms[te];if(!he)return;let Pe=xe.boundingBoxDeclaration,qe=xe.extraDimProps;if((Pe||qe)&&sx(Pe,te,qe)){he._rawDimensional=oe;let _t=xe.uniforms.origin?.value??"center",St=Ot(xe,_t);oe=__(Pe,te,oe,_t,I(),N(),qe,St)}if(he.value=oe,On(xe,te,oe),(he.transform===Ol||he.transform===at)&&rp(xe),te==="origin"&&Pe)qt(xe);else if(Pe&&(xe.uniforms.origin?.value??"center")!=="center"){let _t=_u(Pe,qe),St=!!Pe.computeBounds||(_t?.sizeProps.has(te)??!1),os=_t?.positionProps.has(te)??!1;St&&!os&&qt(xe)}if(te==="shape"&&cc(),xt()&&ft(),he.compileTime){Fn();return}if(he.compileTimeWhen){let _t=he._lastCompiledValue;if(he.compileTimeWhen(_t,oe)){he._lastCompiledValue=oe,Fn();return}}cn()},nd=(Q,te)=>{let oe=c.get(Q);if(!oe){Am({id:Q,kind:"metadata",metadata:te});return}let xe=!1;if(te.blendMode!==void 0&&oe.metadata.blendMode!==te.blendMode&&(oe.metadata.blendMode=te.blendMode,xe=!0),te.opacity!==void 0&&oe.metadata.opacity!==te.opacity){let he=oe.metadata.opacity??1,Pe=te.opacity;oe.metadata.opacity=Pe,ys(oe,"_opacity",Pe),he>=1!=Pe>=1&&(xe=!0)}if(te.renderOrder!==void 0&&oe.metadata.renderOrder!==te.renderOrder&&(oe.metadata.renderOrder=te.renderOrder,xe=!0),"visible"in te){let he=te.visible!==!1;oe.metadata.visible!==he&&(oe.metadata.visible=he,xe=!0)}if(te.id!==void 0){let he=Yt(te.id);oe.metadata.id!==he&&(oe.metadata.id=he,xe=!0)}if("mask"in te&&(oe.metadata.mask?.source!==te.mask?.source||oe.metadata.mask?.type!==te.mask?.type)&&(oe.metadata.mask=te.mask,xe=!0),"maps"in te&&JSON.stringify(oe.metadata.maps)!==JSON.stringify(te.maps)){let he=oe.metadata.maps,Pe=te.maps;if(oe.metadata.maps=Pe,cc(),(()=>{if(!he||!Pe)return!0;let qe=Object.keys(he),_t=Object.keys(Pe);if(qe.length!==_t.length||!qe.every(St=>St in Pe))return!0;for(let St of _t){let os=he[St],Uo=Pe[St];if(os.type!==Uo.type)return!0;if(Uo.type==="map"){let No=os,mo=Uo;if(No.source!==mo.source||No.channel!==mo.channel)return!0}else if(Uo.type==="mouse"&&os.axis!==Uo.axis)return!0}return!1})()){if(he&&Pe)for(let qe of Object.keys(he))qe in Pe&&he[qe].type!==Pe[qe].type&&(delete oe.mouseDriverState[qe],delete oe.autoAnimateState[qe],delete oe.mapValues[qe]);xe=!0}else if(Pe)for(let[qe,_t]of Object.entries(Pe)){let St=eo(oe,qe,_t);_t.type==="map"&&(ys(oe,`_map_${qe}_inputMin`,St.inputMin),ys(oe,`_map_${qe}_inputMax`,St.inputMax),ys(oe,`_map_${qe}_outputMin`,St.outputMin),ys(oe,`_map_${qe}_outputMax`,St.outputMax),ys(oe,`_map_${qe}_curve`,St.curve))}}if(te.transform!==void 0){let he=oe.metadata.transform,Pe={offsetX:te.transform.offsetX??he?.offsetX??0,offsetY:te.transform.offsetY??he?.offsetY??0,rotation:te.transform.rotation??he?.rotation??0,scale:te.transform.scale??he?.scale??1,anchorX:te.transform.anchorX??he?.anchorX??.5,anchorY:te.transform.anchorY??he?.anchorY??.5,edges:te.transform.edges??he?.edges??"transparent"},qe=is(oe);oe.metadata.transform=Pe;let _t=Ei(Pe);if(qe!==_t||he&&he.edges!==Pe.edges)xe=!0;else if(_t)for(let[St,os]of Object.entries(ce(oe)))ys(oe,`_xform_${St}`,os)}if(te.boundingBox!==void 0&&te.boundingBox!==null&&oe.boundingBoxDeclaration!==void 0){let he=we(oe);oe.metadata.boundingBox=te.boundingBox;let Pe=we(oe);if(he!==Pe)xe=!0;else if(Pe){let qe=ze(oe);if(qe)for(let[_t,St]of Object.entries(qe))ys(oe,`_bbox_${_t}`,St)}}else te.boundingBox===null&&oe.metadata.boundingBox!==void 0&&(oe.metadata.boundingBox=void 0,xe=!0);if("flow"in te&&JSON.stringify(oe.metadata.flow)!==JSON.stringify(te.flow)){let he=oe.metadata.flow?.mode==="column"||oe.metadata.flow?.mode==="row";oe.metadata.flow=te.flow??void 0;let Pe=oe.metadata.flow?.mode==="column"||oe.metadata.flow?.mode==="row";if(he&&!Pe){let qe=_t=>{for(let St of Ut(_t))qt(St),qe(St.id)};qe(Q)}ft()}"absolute"in te&&oe.metadata.absolute!==te.absolute&&(oe.metadata.absolute=te.absolute,te.absolute&&qt(oe),ft()),xt()&&ft(),xe?Fn():cn()},ll=Q=>{let te=c.get(Q);if(!te)return;for(let xe of Ut(Q))ll(xe.id);_===Q&&(_=null);let oe=m.get(te.parentId);oe&&(oe.delete(Q),oe.size===0&&m.delete(te.parentId)),c.delete(Q),cc(),Fn(),xt()&&ft()},Tm=()=>{let Q=pt.deltaTime;H=Cne(re,H,Q,performance.now());for(let te of c.values()){let oe=te.metadata.maps;if(oe){for(let xe in te.mouseDriverState){let he=te.mouseDriverState[xe],Pe=oe[xe];if(Pe){if(Pe.type==="mouse-position"){let qe=Pe.smoothing??0,_t=Pe.momentum??0,St=Pe.x===void 0||Pe.x==="mouse",os=Pe.y===void 0||Pe.y==="mouse",Uo,No;if(St){let[Sn,uc]=W3(he.currentX,he.velocityX,pe,qe,_t,Q);he.currentX=Sn,he.velocityX=uc,Uo=Sn}else Uo=Pe.x,he.velocityX=0;if(os){let[Sn,uc]=W3(he.currentY,he.velocityY,de,qe,_t,Q);he.currentY=Sn,he.velocityY=uc,No=Sn}else No=Pe.y,he.velocityY=0;let mo=Pe.reach??1,rs=Pe.originX??.5,wr=Pe.originY??.5,Tn=Pe.invertX?-1:1,xa=Pe.invertY?-1:1,aa=rs+Tn*(Uo-rs)*mo,un=wr+xa*(No-wr)*mo,ld=aa,mp=un,km=te.metadata.boundingBox;if(km&&te.boundingBoxDeclaration?.supportsResizeFit&&we(te)){let Sn=Qg(km,I(),N()),uc=g7(aa,un,{centerX:Sn.centerX,centerY:Sn.centerY,halfWidthUV:Sn.halfWidthUV,halfHeightUV:Sn.halfHeightUV,rotationDeg:Sn.rotation,aspectRatio:_s()});ld=uc.x,mp=uc.y}he.liveX=ld,he.liveY=mp;let K3=te._liveHandles?.[`_smoothed_${xe}`];K3 instanceof Jn&&K3.setComponents(ld,1-mp)}else if(Pe.type==="mouse"){let qe=Pe.smoothing??0,_t=Pe.momentum??0,St=Pe.axis==="x"?pe:de,[os,Uo]=W3(he.currentX,he.velocityX,St,qe,_t,Q);he.currentX=os,he.velocityX=Uo;let No=Math.max(.001,os),mo=te.mapValues[xe],rs=mo?mo.outputMin+(mo.outputMax-mo.outputMin)*Math.pow(No,Math.pow(2,-mo.curve*2)):No;he.liveScalar=rs,ys(te,`_smoothed_${xe}`,rs)}}}for(let xe in te.autoAnimateState){let he=oe[xe];if(!he||he.type!=="auto-animate")continue;let Pe=H*(he.speed??1)*.2,qe,_t=he.easing??he.waveform??"sine";if(he.mode==="loop")qe=aO((Pe%1+1)%1,_t);else{let rs=(Pe%1+1)%1;qe=aO(rs<.5?rs*2:(1-rs)*2,_t)}let St=te.mapValues[xe],os=St?St.outputMin:jt(te,xe,he.outputMin),Uo=St?St.outputMax:jt(te,xe,he.outputMax),No=os+qe*(Uo-os),mo=te.uniforms[xe];if(mo?.compileTimeWhen){let rs=mo._lastCompiledValue;mo.compileTimeWhen(rs,No)&&(mo._lastCompiledValue=No,Fn())}ys(te,`_smoothed_${xe}`,No)}}}},Sm=()=>{let Q=pt.deltaTime;for(let te of c.values()){let oe=te.definition.animatedTime;if(oe){let he=te.uniforms[oe.speed],Pe=he&&Number(he.value)||0,qe=ec(rr(te));qe.advance(Q,Pe),ys(te,"_animTime",qe.value)}let xe=te.definition.extraAnimatedTimes;if(xe)for(let[he,Pe]of Object.entries(xe)){let qe=te.uniforms[Pe],_t=qe&&Number(qe.value)||0,St=ec(Ya(te,Pe));St.advance(Q,_t),ys(te,`_animTime_${he}`,St.value)}}},lp=(Q,te)=>Sne(Q,te,{maxTextureDim:y,pixelRatio:z,viewportWidth:typeof window<"u"?window.innerWidth:Q,viewportHeight:typeof window<"u"?window.innerHeight:te}),dp=()=>{let Q=(typeof window<"u"?window.devicePixelRatio:1)||1;return Math.min(Q,L7())},nc=(Q,te,oe,xe)=>{if(O&&Q===D&&te===k&&oe===B&&xe===E){let{width:_t,height:St}=Gn();if(!n||n.width===_t&&n.height===St)return}D=Q,k=te,B=oe,E=xe,J0(oe,xe),O||(O=!0,c.size>0&&Fn());let{width:he,height:Pe}=Gn();n&&(n.width=he,n.height=Pe);let qe=!1;for(let _t of w)_t.passManager.resize(he,Pe)&&(qe=!0);for(let _t of w)for(let St of _t.ir.onResize)try{St({width:he,height:Pe})}catch(os){io("[gpu] composition onResize error:",os)}for(let _t of c.values()){if(is(_t)&&ys(_t,"_xform_aspectRatio",_s()),we(_t)){let St=ze(_t);if(St)for(let[os,Uo]of Object.entries(St))ys(_t,`_bbox_${os}`,Uo)}qt(_t)}if(Kt(),qe)for(let _t of w)pp(_t.store),_t.store.flush(),_t.passManager.repaintRtt();X=0,id()},cp=(Q,te)=>{Q<=0||te<=0||Q===R&&te===U||(R=Q,U=te,Te={width:Q,height:te},!De&&typeof requestAnimationFrame=="function"&&(De=!0,requestAnimationFrame(()=>{if(De=!1,!Te)return;let oe=Te;Te=null;let{width:xe,height:he}=lp(oe.width,oe.height);nc(xe,he,oe.width,oe.height)})))},kh=Q=>{let te=Q[0];if(!te)return;let oe,xe;if(te.contentBoxSize){let he=Array.isArray(te.contentBoxSize)?te.contentBoxSize[0]:te.contentBoxSize;he?(oe=Math.round(he.inlineSize),xe=Math.round(he.blockSize)):(oe=Math.round(te.contentRect.width),xe=Math.round(te.contentRect.height))}else oe=Math.round(te.contentRect.width),xe=Math.round(te.contentRect.height);oe===0||xe===0||cp(oe,xe)},Rh=Q=>{let te=Q[0];te&&(q=te.isIntersecting)},up=()=>i&&!!t&&!!s&&D>0&&k>0,pp=Q=>{let te=Q.systemHandles,{width:oe,height:xe}=Gn(),he=dp(),Pe=(qe,_t)=>{let St=te[qe];St instanceof Jn&&(St.value=_t)};Pe("time",H),Pe("viewportSize",[oe,xe]),Pe("logicalViewportSize",[I()*he,N()*he]),Pe("aspect",oe/Math.max(1,xe)),Pe("pointer",[pe,de]),Pe("pointerActive",se?1:0)},_p=Q=>{for(let te of Q)try{te(pt)}catch(oe){io("[gpu] render callback error:",oe)}},Cm=Q=>{if(lt||!up())return;let te=performance.now(),oe;if(Q!==void 0)oe=Q;else{let qe=Pne(te,{lastRenderTime:X,isVisible:q,forceFullFrameRate:Y});if(!qe.render)return;oe=qe.deltaTime}X=te,Ie&&performance.mark("shader-cpu-start");let xe=pe>-5;pt.deltaTime=oe,pt.pointer.x=xe?pe:.5,pt.pointer.y=xe?de:.5,pt.pointerActive=se,pt.dimensions.width=D,pt.dimensions.height=k;let he=null,Pe=null;try{Mne({updateDrivers:()=>{Tm(),Sm(),$e(),Qt()},ensureComposition:()=>((x||T===null)&&(T=ym(),x=!1),T===null?!1:(he=A.getOrBuild(T,()=>xm(T)),Eh(he),!!S)),beforeRender:()=>_p(S.ir.onBeforeRender),flush:()=>{pp(S.store),S.store.flush()},render:()=>{if(Ie&&performance.mark("shader-gpu-start"),Pe=A.renderValue??he,Pe?.passManager.render(s,pt),Ie){performance.mark("shader-gpu-end");try{performance.measure("shader-gpu-time","shader-gpu-start","shader-gpu-end");let qe=performance.getEntriesByName("shader-gpu-time")[0];qe&&Pt.recordGpuTime(qe.duration),performance.clearMeasures("shader-gpu-time"),performance.clearMarks("shader-gpu-start"),performance.clearMarks("shader-gpu-end")}catch{}}},markReady:()=>{A.markReady(T),ut&&!Je&&(Je=!0,ut=!1,Ze&&queueMicrotask(Ze))},afterRender:()=>_p((Pe??S).ir.onAfterRender)}),Rt=0}catch(qe){Ih(qe);return}if(Ie){performance.mark("shader-cpu-end");try{performance.measure("shader-cpu-time","shader-cpu-start","shader-cpu-end");let qe=performance.getEntriesByName("shader-cpu-time")[0];qe&&Pt.recordCpuTime(qe.duration),performance.clearMarks("shader-cpu-start"),performance.clearMarks("shader-cpu-end"),performance.clearMeasures("shader-cpu-time")}catch{}}Pt.recordFrame(performance.now()-te)},id=()=>Cm(void 0),Dh=async Q=>{if(lt)return;if(!up())throw new Error("Renderer is not ready");let te=Ft.running;te&&lc(),X=0,id(),t&&Q?.waitForGpu!==!1&&await nO(t),te&&ic()},zh=async(Q,te)=>{Cm(Q),t&&te?.waitForGpu!==!1&&await nO(t)},ic=()=>{lt||Ft.running||!G||(Pt.setRendering(!0),Ft.start())},lc=()=>{Ft.running&&(Ft.stop(),Pt.setRendering(!1))},dc=Q=>{if(!n)return;ie=n.getBoundingClientRect();let te,oe;if("touches"in Q){if(Q.touches.length===0)return;te=Q.touches[0].clientX,oe=Q.touches[0].clientY}else te=Q.clientX,oe=Q.clientY;pe=(te-ie.left)/ie.width,de=(oe-ie.top)/ie.height},Bh=Q=>{!i||!n||(dc(Q),se=!0,cn())},Lh=Q=>{!i||!n||(dc(Q),se=!0,cn())},Uh=()=>{i&&(se=!1,cn())},Oh=()=>{i&&(se=!1,cn())},Pm=(Q,te)=>{if(!i||!n)return!1;let oe=n.getBoundingClientRect();return oe.width===0||oe.height===0?!1:Q>=oe.left&&Q<=oe.right&&te>=oe.top&&te<=oe.bottom},Gh=Q=>{Q.button===0&&Pm(Q.clientX,Q.clientY)&&(se=!0,dc(Q),cn())},Fh=Q=>{Q.touches.length!==0&&Pm(Q.touches[0].clientX,Q.touches[0].clientY)&&(se=!0,dc(Q),cn())},cc=()=>{let Q=!1;for(let te of c.values()){if(te.usesPointer){Q=!0;break}if(Vne(te.uniforms?.shape?.value)){Q=!0;break}if(te.metadata.maps){for(let oe of Object.values(te.metadata.maps))if(oe&&typeof oe=="object"&&"type"in oe){let xe=oe.type;if(xe==="mouse"||xe==="mouse-position"){Q=!0;break}}if(Q)break}}Q&&!ye?(ye=!0,!be&&n&&(be=Wne.register({onMouseMove:Bh,onTouchMove:Lh,onMouseDown:Gh,onTouchStart:Fh,onMouseUp:Uh,onTouchEnd:Oh}))):!Q&&ye&&(ye=!1,be&&(be(),be=null))},Mm=()=>{if(f.length===0)return;let Q=[...f];f=[];for(let oe of Q)bm(oe.id,oe.definition.fragment,oe.parentId,oe.metadata,oe.uniforms,oe.definition,oe.domCanvas);let te=h;h=[];for(let oe of te)oe.kind==="uniform"?wm(oe.id,oe.name,oe.value):nd(oe.id,oe.metadata)},In=(Q,te)=>{if(!lt){lt=Q,Z3(Q),io(`[gpu] renderer stopped (${Q}):`,te);try{Wh()}catch(oe){io("[gpu] cleanup during failure threw:",oe)}if(!wt&&vt){wt=!0;let oe=vt;queueMicrotask(()=>{try{oe(Q,te)}catch(xe){io("[gpu] onUnavailable callback threw:",xe)}})}}},Ih=Q=>{if(qh(Q)){In(Q.reason,Q);return}Rt++,Rt===1&&io("[gpu] render error:",Q),Rt>=Yne&&In("render-failed",Q)},Yh=Q=>{!Q||typeof Q.addEventListener!="function"||(Em(),mt=Q,gt=te=>{try{te.preventDefault()}catch{}let oe=te.error;if(io("[gpu] uncaptured device error:",oe),typeof GPUOutOfMemoryError<"u"&&oe instanceof GPUOutOfMemoryError){In("out-of-memory",oe);return}if(typeof GPUInternalError<"u"&&oe instanceof GPUInternalError){In("gpu-error",oe);return}kt++,kt>=Ine&&In("gpu-error",oe)},Q.addEventListener("uncapturederror",gt))},Em=()=>{if(mt&>)try{mt.removeEventListener("uncapturederror",gt)}catch{}mt=null,gt=null},mO=Q=>{if(!it){it=!0;try{lc()}catch{}if(tt){let te=tt;queueMicrotask(()=>{try{te(Q)}catch(oe){io("[gpu] onDeviceLost callback threw:",oe)}});return}In("device-lost",Q)}},fO=async Q=>{if(Q.context!==void 0)throw new Error("[gpu] initialize({ context }) is not supported \u2014 this renderer is WebGPU-only. Remove the WebGL `context` option.");if(lt)return;let te=J3();if(te){In(te);return}if(i||l)return;let{canvas:oe,resizeTarget:xe,enablePerformanceTracking:he=!1,colorSpace:Pe="p3-linear",toneMapping:qe="linear",gpu:_t,forceFullFrameRate:St=!1,observeElement:os=!0,timeOrigin:Uo}=Q;Uo!=null&&(re=Uo),Ie=he,Y=St,Ne=Pe,Oe=qe,Is(),l=!0,u=new AbortController;let No=u;try{if(He=FS,He(Pe),No.signal.aborted||(n=oe,e=await _ne({device:_t?.device,adapter:_t?.adapter,onDeviceLost:un=>mO(un.message||un.reason||"unknown")}),No.signal.aborted))return;t=e.root,Yh(t.device),z=dp();let mo=t.device.limits?.maxTextureDimension2D;typeof mo=="number"&&mo>0&&(y=mo),o=wne(t),r=D7(t),typeof window<"u"&&(Le=()=>Wh(),window.addEventListener("beforeunload",Le),Ee=()=>{if(R>0&&U>0){let un=R,ld=U;R=0,U=0,cp(un,ld)}},window.addEventListener("resize",Ee,{passive:!0}));let rs=oe.getBoundingClientRect();ie=rs,q=!os||rs.width>0&&rs.height>0&&rs.top<window.innerHeight&&rs.bottom>0&&rs.left<window.innerWidth&&rs.right>0,G=!0;let wr=rs.width>0?rs.width:oe.width,Tn=rs.height>0?rs.height:oe.height,xa=Math.round(wr),aa=Math.round(Tn);if(xa>0&&aa>0){R=xa,U=aa;let{width:un,height:ld}=lp(xa,aa);D=un,k=ld,B=xa,E=aa,O=!0,J0(xa,aa);let{width:mp,height:km}=Gn();oe.width=mp,oe.height=km}else O=!1;if(s=vne(t,oe),os&&typeof ResizeObserver<"u"){let un=xe??oe.parentElement;un?(ge=new ResizeObserver(kh),ge.observe(un)):console.warn("[gpu] no element available for resize observation \u2014 use resize() manually"),typeof IntersectionObserver<"u"&&(Be=new IntersectionObserver(Rh,{threshold:0,rootMargin:"128px"}),Be.observe(oe))}if(No.signal.aborted)return;i=!0,d=!0,Mm(),D>0&&k>0&&id(),G&&ic()}catch(mo){let rs=qh(mo)?mo.reason:"init-failed";l=!1,u===No&&(u=null),In(rs,mo);return}finally{l=!1,u===No&&(u=null)}},Wh=()=>{u&&u.abort(),ge&&(ge.disconnect(),ge=null),Be&&(Be.disconnect(),Be=null),be&&(be(),be=null),Le&&typeof window<"u"&&(window.removeEventListener("beforeunload",Le),Le=null),Ee&&typeof window<"u"&&(window.removeEventListener("resize",Ee),Ee=null),ee!==null&&typeof cancelAnimationFrame=="function"&&(cancelAnimationFrame(ee),ee=null),lc(),Em(),Es?.(),Es=null,typeof document<"u"&&document.fonts?.removeEventListener&&document.fonts.removeEventListener("loadingdone",Os);try{e?.release?.()}catch{}A.clear();for(let Q of[...w])ip(Q);S=null;try{o?.destroy()}catch{}try{e?.createdDevice&&t?.destroy()}catch{}c.clear(),_=null,m.clear(),f=[],h=[],d=!1,Te=null,De=!1,n=null,s=null,o=null,r=null,t=null,e=null,i=!1,l=!1,O=!1,u=null,D=0,k=0,B=0,E=0,T=null,x=!0,q=!1,G=!0,pe=-10,de=-10,se=!1,ye=!1,Ze=null,Je=!1,ut=!1,tt=null,it=!1,kt=0,Rt=0};return{initialize:fO,cleanup:Wh,registerNode:bm,removeNode:ll,updateUniformValue:wm,updateNodeMetadata:nd,isInitialized:()=>i,resize:(Q,te)=>{t&&cp(Q,te)},startAnimation:ic,stopAnimation:lc,renderAndWait:Dh,renderSyntheticFrame:zh,getPerformanceStats:()=>{let Q=Math.max(0,c.size-1),te=S?S.ir.rttPasses.length:0;Pt.updateNodeCounts(Q,te);let oe={render:{calls:S?S.passManager.passCount:0},programs:{length:A.size},memory:{textures:o?o.textureCount:0}};return Pt.getStats(oe)},getLiveDriverValue:(Q,te)=>{let oe=c.get(Q)?.mouseDriverState?.[te];return!oe||oe.liveX===void 0||oe.liveY===void 0?null:{x:oe.liveX,y:oe.liveY}},getLiveScalarValue:(Q,te)=>{let oe=c.get(Q);if(!oe)return null;let xe=oe.metadata.maps?.[te];if(xe?.type==="auto-animate"){let he=oe._liveHandles?.[`_smoothed_${te}`],Pe=he instanceof Jn?he.value:void 0;return typeof Pe=="number"?Pe:null}return xe?.type==="mouse"?oe.mouseDriverState[te]?.liveScalar??null:null},getNodeRegistry:()=>({nodes:new Map(c)}),getRendererType:()=>"webgpu",getInternalRenderer:()=>t?{device:t.device,adapter:e?.adapter,root:t}:null,setForceFullFrameRate:Q=>{let te=Y;return Y=Q,te},beginRecordingResolution:(Q,te,oe)=>{if(!t||Q<=0||te<=0)return()=>{};let xe=z,he=D,Pe=k,qe=B,_t=E,St=R,os=U;return z=oe,nc(Q,te,Q,te),()=>{t&&(z=xe,nc(he,Pe,qe,_t),R=St,U=os)}},setResolutionScale:Q=>{if(!t)return;let te=Math.max(.05,Math.min(Q,1)),oe=Math.max(.01,dp()*te);if(Math.abs(z-oe)<.001)return;z=oe;let xe=B||D,he=E||k;if(xe<=0||he<=0)return;let{width:Pe,height:qe}=lp(xe,he);nc(Pe,qe,xe,he)},setTimeOrigin:Q=>{re=Q},setOnReady:Q=>{Ze=Q,Q&&Je&&queueMicrotask(Q)},setOnDeviceLost:Q=>{tt=Q},setOnUnavailable:Q=>{if(vt=Q,Q&<&&!wt){wt=!0;let te=lt;queueMicrotask(()=>{try{Q(te)}catch(oe){io("[gpu] onUnavailable callback threw:",oe)}})}},getFailureReason:()=>lt,__testing:{needsTransformation:Ei,findChildNodes:Ut,buildFieldInits:Q=>{let te=c.get(Q);return te?Ti(te):null},ensureDriverState:Q=>{let te=c.get(Q);te&&or(te)},stepMouseDrivers:Q=>{pt.deltaTime=Q,Tm()},stepAnimatedTime:Q=>{pt.deltaTime=Q,Sm()},getAnimatedTimeValue:Q=>{let te=c.get(Q);return te?.definition.animatedTime?ec(rr(te)).value:null},writeExtraField:(Q,te,oe)=>{let xe=c.get(Q);xe&&sc(xe,te,oe)},readExtraField:(Q,te)=>{let oe=c.get(Q)?._liveHandles?.[te];return oe instanceof Jn?oe.value:void 0},getNodeRegistry:()=>({nodes:c,rootId:_,parentToChildren:m}),getParentToChildren:()=>m,getPendingRegistrations:()=>[...f],getFrameDiagnostics:()=>({deltaTime:pt.deltaTime,pointerX:pe,pointerY:de,pointerActive:se,globalElapsedTime:H,lastRenderTime:X,isVisible:q,forceFullFrameRate:Y,sharedTimeOrigin:re,animating:Ft.running,mouseListenersNeeded:ye}),computeStructuralHash:ym,isStructuralDirty:()=>x,clearStructuralDirty:()=>{x=!1},setTestReady:Q=>{i=!0,d=!0,Q&&(D=Q.width,k=Q.height,B=Q.width,E=Q.height,O=!0),Mm()}}}}var tc={samplingRate:.05,collectionDuration:5e3,warmupDuration:500,sampleInterval:500,apiEndpoint:"https://shaders.com/api/telemetry"};function Nne(e){return e.includes("Edg/")||e.includes("EdgiOS")?"Edge":e.includes("OPR/")||e.includes("Opera/")?"Opera":e.includes("Chrome/")||e.includes("CriOS")?"Chrome":e.includes("Firefox/")||e.includes("FxiOS")?"Firefox":e.includes("Safari/")&&!e.includes("Chrome")?"Safari":"Other"}function qne(e){return/iPad|Tablet|PlayBook/i.test(e)||/Android/i.test(e)&&!/Mobile/i.test(e)?"tablet":/Mobile|Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(e)?"mobile":"desktop"}function Xne(){if(typeof window>"u"||typeof navigator>"u")return{domain:"unknown",browserFamily:"unknown",deviceType:"unknown"};let e=navigator.userAgent;return{domain:window.location.hostname,browserFamily:Nne(e),deviceType:qne(e)}}var Hne=class{renderer;version;sourceType;sessionId;frameSamples=[];sampleInterval=null;stopped=!1;constructor(e,t,s){this.renderer=e,this.version=t,this.sourceType=s,this.sessionId=`tel_${Date.now()}_${Math.random().toString(36).substring(2,9)}`}stop(){this.stopped=!0,this.sampleInterval&&(clearInterval(this.sampleInterval),this.sampleInterval=null)}async start(){try{if(await this.sleep(tc.warmupDuration),this.stopped||(this.sampleInterval=setInterval(()=>{if(!this.stopped)try{let e=this.renderer.getPerformanceStats();this.frameSamples.push(e)}catch(e){io("Telemetry sampling error:",e)}},tc.sampleInterval),await this.sleep(tc.collectionDuration-tc.warmupDuration),this.stopped))return;if(this.sampleInterval&&(clearInterval(this.sampleInterval),this.sampleInterval=null),!this.stopped&&this.frameSamples.length>=5){let e=this.aggregateData();await this.sendTelemetry(e)}}catch(e){io("Telemetry collection error:",e)}}sleep(e){return new Promise(t=>setTimeout(t,e))}aggregateData(){let e=this.aggregatePerformance(),t=this.detectRendererType(),s=this.extractComponents(),o=Xne();return{sessionId:this.sessionId,timestamp:Date.now(),collectionDuration:tc.collectionDuration,version:this.version,sourceType:this.sourceType,performance:e,renderer:t,components:s,environment:o}}aggregatePerformance(){if(this.frameSamples.length===0)return{fps:0,frameTime:{avg:0,min:0,max:0,p99:0},jankPercent:0,budgetUsed:0};let e=this.frameSamples.map(_=>_.avgFrameTime),t=this.frameSamples.map(_=>_.jankPercent),s=this.frameSamples.map(_=>_.budgetUsed),o=this.frameSamples.map(_=>_.fps),r=this.calculateMedian(o),n=this.calculateMean(e),i=Math.min(...e),l=Math.max(...e),d=this.calculatePercentile(e,99),u=this.calculateMean(t),c=this.calculateMean(s);return{fps:Math.round(r*10)/10,frameTime:{avg:Math.round(n*10)/10,min:Math.round(i*10)/10,max:Math.round(l*10)/10,p99:Math.round(d*10)/10},jankPercent:Math.round(u*10)/10,budgetUsed:Math.round(c*10)/10}}detectRendererType(){let e=this.frameSamples[this.frameSamples.length-1];return{type:this.renderer.getRendererType?.()||"webgl",drawCalls:e?.drawCalls??null,textureCount:e?.textureCount??null}}extractComponents(){try{let e=this.renderer.getNodeRegistry(),t=[];for(let[s,o]of e.nodes)o.parentId!==null&&t.push({name:o.componentName,requiresRTT:o.requiresRTT,renderOrder:o.metadata.renderOrder});return t.sort((s,o)=>s.renderOrder-o.renderOrder)}catch(e){return io("Failed to extract components:",e),[]}}async sendTelemetry(e){try{let t=await fetch(tc.apiEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});t.ok||Wa("Telemetry send failed:",t.status,t.statusText)}catch(t){io("Telemetry send error:",t)}}calculateMean(e){return e.length===0?0:e.reduce((t,s)=>t+s,0)/e.length}calculateMedian(e){if(e.length===0)return 0;let t=[...e].sort((o,r)=>o-r),s=Math.floor(t.length/2);return t.length%2===0?(t[s-1]+t[s])/2:t[s]}calculatePercentile(e,t){if(e.length===0)return 0;let s=[...e].sort((r,n)=>r-n),o=Math.ceil(t/100*s.length)-1;return s[Math.max(0,o)]}};function $ne(e=!1,t=!1){return e||typeof navigator<"u"&&navigator.doNotTrack==="1"?!1:t?!0:Math.random()<tc.samplingRate}function cO(e,t,s=!1,o=!1){return $ne(s,o)?new Hne(e,t,o?"preview":"shader"):null}function uO(){if(typeof window>"u"||!window.location)return!1;let e=window.location.hostname;return!e.includes("shaders.com")&&e!=="localhost"&&e!=="127.0.0.1"}function H3(e){if(typeof e!="object"||e===null||!("type"in e))return!1;let t=e;return t.type==="map"||t.type==="mouse"||t.type==="mouse-position"||t.type==="auto-animate"}var pO=new Set(["opacity","blendMode","visible","transform","boundingBox","maskSource","maskType","flow","absolute"]);async function $3(e,t,s){let o=new Map;if(Sh().forEach(y=>{o.set(y.definition.name,y.definition);for(let R of y.definition.deprecatedNames??[])o.set(R,y.definition)}),!e.style.width||!e.style.height){let y=e.getBoundingClientRect(),R=y.width>0?y.width:e.width,U=y.height>0?y.height:e.height;R>0&&!e.style.width&&(e.style.width=`${R}px`),U>0&&!e.style.height&&(e.style.height=`${U}px`)}function r(y){return{...y,props:y.props?{...y.props}:void 0,children:y.children?.map(r)}}let n={...t,components:t.components.map(r)},i=null,l=!1,d=!1,u=3,c=6e4,_=0,m=0,f=null;function h(y){try{s?.onError?.(y)}catch(R){io("[createShader] onError callback threw:",R)}}let A=!1;function w(y){A||(A=!0,f=y,h(y))}function S(y,R,U,O,I){let N=o.get(U.type);if(!N){console.warn(`[createShader] Unknown component type: ${U.type}`);return}let G=U.id||`${U.type}_${Date.now()}_${Math.random().toString(36).slice(2,9)}`,q={};for(let[H,re]of Object.entries(U.props||{}))!pO.has(H)&&Object.prototype.hasOwnProperty.call(N.props,H)&&H3(re)&&(q[H]=re);let Y=ox(N,Object.fromEntries(Object.entries(N.props).map(([H,re])=>{let ee=U.props?.[H]!==void 0?U.props[H]:re.default;return[H,H3(ee)?re.default:ee]})),G),X={blendMode:U.props?.blendMode||"normal",opacity:U.props?.opacity,visible:U.props?.visible,renderOrder:I,id:U.id,maps:Object.keys(q).length>0?{...q}:void 0,mask:U.props?.maskSource?{source:U.props.maskSource,type:U.props.maskType||"alpha"}:void 0,transform:U.props?.transform?{offsetX:0,offsetY:0,rotation:0,scale:1,anchorX:.5,anchorY:.5,edges:"transparent",...U.props.transform}:void 0,boundingBox:N1(U.props?.boundingBox),flow:U.props?.flow,absolute:U.props?.absolute};y.registerNode(G,N.fragment,O,X,Y,N),R.set(G,{componentDef:N,uniforms:Y,nodeId:G,component:U,currentMaps:{...q}}),U.children?.forEach((H,re)=>{S(y,R,H,G,re)})}async function T(){let y=dO(),R=new Map;s?.onReady&&y.setOnReady(s.onReady),y.setOnUnavailable(I=>{l||w(I)}),await y.initialize({canvas:e,resizeTarget:e,enablePerformanceTracking:s?.enablePerformanceTracking||!1,colorSpace:s?.colorSpace,toneMapping:s?.toneMapping,observeElement:s?.observeElement,gpu:s?.gpu});let U={renderer:y,nodeEntryMap:R,telemetryCollector:null,telemetryStartTimeout:null};y.setOnDeviceLost(I=>{if(l||d||f||i!==null&&i!==U)return;d=!0,h(I);let N=Date.now();if(N-m>c&&(_=0),m=N,++_>u){x(U),i=null,d=!1,w("unrecoverable");return}(async()=>{try{if(x(U),i=null,l)return;let G=await T();if(l){x(G);return}i=G}catch(G){io("[createShader] rebuild after device loss failed:",G),w("rebuild_failed")}finally{d=!1}})()});let O="shader-root";if(y.registerNode(O,Pf.fragment,null,null,{},Pf),n.components.forEach((I,N)=>{S(y,R,I,O,N)}),uO()){let N=0,G=()=>{if(l||f||i!==U||++N>40){U.telemetryStartTimeout=null;return}y.getPerformanceStats().fps>0?(U.telemetryCollector=cO(y,"3.1.461",s?.disableTelemetry||!1,!1),U.telemetryCollector&&U.telemetryCollector.start(),U.telemetryStartTimeout=null):U.telemetryStartTimeout=setTimeout(G,500)};U.telemetryStartTimeout=setTimeout(G,500)}return U}function x(y){if(y.telemetryCollector){try{y.telemetryCollector.stop()}catch{}y.telemetryCollector=null}y.telemetryStartTimeout!==null&&(clearTimeout(y.telemetryStartTimeout),y.telemetryStartTimeout=null);try{y.renderer.cleanup()}catch{}}i=await T();function D(y,R){if(!i)return;let{renderer:U,nodeEntryMap:O}=i,I=O.get(y);if(!I){console.warn(`[createShader] Component ID not found: ${y}`);return}I.component.props||(I.component.props={});let N=I.component.props;for(let[G,q]of Object.entries(R))if(pO.has(G))if(G==="maskSource")U.updateNodeMetadata(I.nodeId,{mask:q?{source:q,type:R.maskType||N.maskType||"alpha"}:void 0}),N.maskSource=q,"maskType"in R&&(N.maskType=R.maskType);else{if(G==="maskType")continue;G==="transform"?(U.updateNodeMetadata(I.nodeId,{transform:q}),N.transform=q):G==="boundingBox"?(U.updateNodeMetadata(I.nodeId,{boundingBox:N1(q)}),N.boundingBox=q):(U.updateNodeMetadata(I.nodeId,{[G]:q}),N[G]=q)}else H3(q)?Object.prototype.hasOwnProperty.call(I.componentDef.props,G)?(I.currentMaps[G]=q,U.updateNodeMetadata(I.nodeId,{maps:{...I.currentMaps}}),N[G]=q):console.warn(`[createShader] Ignoring PropDriver for unknown prop "${G}" on ${I.component.type}`):(G in I.currentMaps&&(delete I.currentMaps[G],U.updateNodeMetadata(I.nodeId,{maps:Object.keys(I.currentMaps).length>0?{...I.currentMaps}:void 0})),Object.prototype.hasOwnProperty.call(I.componentDef.props,G)&&(U.updateUniformValue(I.nodeId,G,q),N[G]=q))}function k(y,R){let U=e.getBoundingClientRect(),O=y??(U.width>0?U.width:e.width),I=R??(U.height>0?U.height:e.height);O>0&&I>0&&(e.style.width=`${O}px`,e.style.height=`${I}px`,i&&i.renderer.resize(O,I))}function B(){l=!0,i&&(x(i),i=null)}function E(){i&&i.renderer.stopAnimation()}function z(){i&&i.renderer.startAnimation()}return{update:D,resize:k,pause:E,resume:z,destroy:B,getFailureReason:()=>f}}var jne="shaders-preview-key";function Kne(e,t){let s=new TextEncoder().encode(t),o=new Uint8Array(e.length);for(let r=0;r<e.length;r++)o[r]=e[r]^s[r%s.length];return o}function _O(e){try{let t=atob(e),s=new Uint8Array(t.length);for(let i=0;i<t.length;i++)s[i]=t.charCodeAt(i);let o=Kne(s,jne),r=new TextDecoder().decode(o),n=JSON.parse(r);if(typeof n!="object"||n===null||Array.isArray(n))throw new Error("unexpected shape");return n}catch{throw new Error("Failed to decode preview definition: invalid data")}}var Qne="https://shaders.com",Zne="Unlock your Shaders Pro license",Jne="https://shaders.com/dashboard?pricing=true",eie=new Set(["break","case","catch","class","const","continue","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","new","return","super","switch","this","throw","try","typeof","var","void","while","with","yield"]);function tie(e,t){let s=e.replace(/[^A-Za-z0-9]+/g," ").trim();if(!s)return t;let o=s.split(/\s+/).map((n,i)=>i===0?n.charAt(0).toLowerCase()+n.slice(1):n.charAt(0).toUpperCase()+n.slice(1)).join(""),r=/^[A-Za-z_$]/.test(o)?o:`_${o}`;return eie.has(r)?`_${r}`:r}function sie(e){let t=new Set(["style"]),s=new Map;return e?.length&&e.forEach((o,r)=>{if(!o.targets?.length)return;let n=tie(o.label,`keyProp${r}`),i=n,l=1;for(;t.has(i);)l++,i=`${n}${l}`;t.add(i),s.set(i,o)}),s}function j3(e,t){for(let s of t){if(s.id===e)return s;let o=s.children;if(o?.length){let r=j3(e,o);if(r)return r}}return null}function oie(e,t,s){if(t)for(let[o,r]of Object.entries(t)){let n=s.get(o);if(n)for(let i of n.targets??[]){let l=j3(i.component_id,e);l?.props&&i.prop in l.props&&(l.props[i.prop]=r)}}}async function rie(e,t){if(!t.shader&&!t.presetId||t.shader&&t.presetId)throw new Error("Exactly one of shader (preview token) or presetId must be provided");let s=t.apiBaseUrl||Qne,o=t.presetId&&t.version?`?version=${encodeURIComponent(t.version)}`:"",r=t.shader?`${s}/api/preview/shader/${encodeURIComponent(t.shader)}`:`${s}/api/preview/preset/${encodeURIComponent(t.presetId)}${o}`,n=await fetch(r);if(!n.ok)throw new Error(`Failed to fetch preview: ${n.status} ${n.statusText}`);let i=await n.json(),l=i.preset??i.shader;if(!l?.definition||typeof l.definition!="string")throw new Error("Preview response missing encoded definition");let d=_O(l.definition),u=Array.isArray(l.key_props)?l.key_props:null,c=sie(u),_=new Map;for(let T of c.values())for(let x of T.targets??[]){let D=j3(x.component_id,d.components);D?.props&&x.prop in D.props&&_.set(`${x.component_id}:${x.prop}`,D.props[x.prop])}oie(d.components,t.configuration,c);let m=await $3(e,d,{isPreview:!0,enablePerformanceTracking:!0}),{overlay:f,savedPosition:h,parentEl:A}=aie(e),w=m.destroy.bind(m),S=m;return S.destroy=()=>{A&&h!==void 0&&(A.style.position=h),f.remove(),w()},S.setConfiguration=T=>{if(u?.length)for(let[x,D]of c){let k=Object.prototype.hasOwnProperty.call(T,x)&&T[x]!==void 0;for(let B of D.targets??[]){let E=k?T[x]:_.get(`${B.component_id}:${B.prop}`);E!==void 0&&m.update(B.component_id,{[B.prop]:E})}}},S}function aie(e){let t=e.parentElement,s;t&&getComputedStyle(t).position==="static"&&(s=t.style.position,t.style.position="relative");let o=document.createElement("a");return o.href=Jne,o.target="_blank",o.rel="noopener noreferrer",o.textContent=Zne,Object.assign(o.style,{position:"absolute",bottom:"8px",right:"12px",fontSize:"11px",fontFamily:"system-ui, -apple-system, sans-serif",color:"rgba(255, 255, 255, 0.5)",textDecoration:"none",zIndex:"10",pointerEvents:"auto",transition:"color 0.2s ease"}),o.addEventListener("mouseenter",()=>{o.style.color="rgba(255, 255, 255, 0.8)"}),o.addEventListener("mouseleave",()=>{o.style.color="rgba(255, 255, 255, 0.5)"}),t&&t.appendChild(o),{overlay:o,savedPosition:s,parentEl:t}}async function nie(e){if(typeof navigator>"u"||!navigator.gpu)return null;try{let t=await navigator.gpu.requestAdapter({powerPreference:e?.powerPreference??"high-performance"});return t?{device:await t.requestDevice({requiredFeatures:[...t.features]}),adapter:t}:null}catch(t){return Wa("[shaders] createSharedDevice failed; callers should fall back to per-instance device:",t),null}}export{rie as createPreview,$3 as createShader,nie as createSharedDevice,Hh as getWebGPUSupport,Dm as isShadersDebug,Xh as isWebGPUSupported,Q3 as setShadersDebug};
|
|
266
|
+
}`,"fullScreenTriangle");NA.disable("external-omitted");var une=["float32-filterable","timestamp-query"],V3=new WeakMap,Y3=new WeakMap,N3=new WeakSet,tp=null,pne=new WeakSet;async function _ne(e={}){if(e.device&&!N3.has(e.device)){let o=e.device,r=V3.get(o);r||(r=b.initFromDevice({device:o}),V3.set(o,r));let n=sO(r,e.onDeviceLost);return{root:r,device:o,adapter:e.adapter,createdDevice:!1,release:n}}e.device&&Wa("[gpu] injected GPU device was lost \u2014 falling back to the shared default device");let t=await mne(),s=sO(t.root,e.onDeviceLost);return{root:t.root,device:t.device,adapter:t.adapter,createdDevice:!1,release:s}}async function mne(){for(;;){let t=tp;if(!t)break;let s=await t.catch(()=>null);if(s&&!pne.has(t)&&!N3.has(s.device))return s;tp===t&&(tp=null)}let e=fne();tp=e;try{return await e}catch(t){throw tp===e&&(tp=null),t}}async function fne(){if(typeof navigator>"u"||!navigator.gpu)throw new pc("unsupported","[gpu] WebGPU is not available in this environment (navigator.gpu is undefined).");let e;try{e=await b.init({adapter:{powerPreference:"high-performance"},device:{optionalFeatures:une}})}catch(t){let s=await Hh();throw new pc(s.supported?"no-device":s.reason??"init-failed",void 0,{cause:t})}if(!e.device)throw new pc("no-device","[gpu] adapter returned no device.");return V3.set(e.device,e),{root:e,device:e.device,createdDevice:!0}}function vne(e,t,s={}){return e.configureContext({canvas:t,alphaMode:"premultiplied",...s})}function sO(e,t){let s=e.device,o=Y3.get(s);if(o||(o=new Set,Y3.set(s,o),e.device.lost.then(n=>{if(N3.add(s),n.reason!=="destroyed")for(let i of[...Y3.get(s)??[]])i(n)})),!t)return()=>{};let r=o;return r.add(t),()=>r.delete(t)}function hne(){let e={value:0,advance(t,s){e.value+=t*s}};return e}var oO=new WeakMap;function ec(e){let t=oO.get(e);return t||(t=hne(),oO.set(e,t)),t}var yne=(globalThis.__TYPEGPU_AUTONAME__??(e=>e))(je({time:a,viewportSize:p,logicalViewportSize:p,aspect:a,pointer:p,pointerActive:a}),"SystemUniforms");b.fn([p,p],p)((e=>(globalThis.__TYPEGPU_META__??=new WeakMap).set(e.f=((t,s)=>{"use gpu";return Er(t,s)}),{v:2,name:void 0,ast:{params:[{type:"i",name:"uv"},{type:"i",name:"viewportSize"}],body:[0,[[10,[6,"std.mul",["uv","viewportSize"]]]]]},externals:{"std.mul":()=>Er}})&&e.f)({}));b.fn([p],a)((e=>(globalThis.__TYPEGPU_META__??=new WeakMap).set(e.f=(t=>{"use gpu";return __tsover_div(t.x,t.y)}),{v:2,name:void 0,ast:{params:[{type:"i",name:"viewportSize"}],body:[0,[[10,[1,[7,"viewportSize","x"],"/",[7,"viewportSize","y"]]]]]},externals:{}})&&e.f)({}));function gne(e){let t=2166136261,s=e.join("");for(let o=0;o<s.length;o++)t^=s.charCodeAt(o),t=Math.imul(t,16777619);return`${(t>>>0).toString(16).padStart(8,"0")}:${s.length}`}function xne(e={}){let t=e.maxSize??4,s=e.dispose,o=new Map,r=0,n=null,i=null;function l(u){u.lastUsed=++r}function d(){for(;o.size>t;){let u=null;for(let c of o.values())c.hash===n||c.hash===i||(!u||c.lastUsed<u.lastUsed)&&(u=c);if(!u)break;o.delete(u.hash),s?.(u.value,u.hash)}}return{getOrBuild(u,c){let _=o.get(u);if(_)return l(_),u===n?i=null:i=u,_.value;let m=c(),f={hash:u,value:m,lastUsed:++r};return o.set(u,f),n===null?(n=u,i=null):i=u,d(),m},markReady(u){if(u!==i)return;let c=o.get(u);c&&(n=u,i=null,l(c),d())},get renderValue(){let u=n??i;return u?o.get(u)?.value??null:null},get activeHash(){return n},get pendingHash(){return i},release(u){let c=o.get(u);c&&(o.delete(u),s?.(c.value,u),n===u&&(n=null),i===u&&(i=null))},has(u){return o.has(u)},get size(){return o.size},clear(){for(let u of o.values())s?.(u.value,u.hash);o.clear(),n=null,i=null}}}var sp="passManager";function bne(e,t){let{textureManager:s,dispatcher:o}=t,r=t.canvasFormat??Ane(),n=t.rttFormat??"rgba16float",i=e.device?.limits?.maxSampledTexturesPerShaderStage,l=t.maxSampledTextures??(typeof i=="number"&&i>0?i:16),d=t.fullScreenTriangle??cne,u=new Map,c=new Set,_=null;function m(){let y=s.samplers;try{return e.createBindGroup(Zg,{linearClamp:y.linearClamp,nearestClamp:y.nearestClamp,linearRepeat:y.linearRepeat,nearestRepeat:y.nearestRepeat})}catch(R){io(`[${sp}] failed to build sampler bind group:`,R);return}}function f(y,R){let U=new Set;for(let O of y.textures)if(O.kind==="rtt")if(U.add(O.key),u.has(O.key))u.get(O.key).resize(R.width,R.height);else{let I=s.createRenderTexture({width:R.width,height:R.height,format:n,label:`rtt:${O.key}`});u.set(O.key,I),c.add(I)}for(let[O,I]of[...u])U.has(O)||(I.destroy(),c.delete(I),u.delete(O))}function h(y,R){if(!y.textureLayout||y.reads.length===0)return;let U={};for(let O of y.reads){let I=u.get(O),N=R?.[O],G=I??N;if(!G){io(`[${sp}] pass "${y.entry}" reads unknown texture "${O}"`);return}U[O]=G.texture}y.reads.length>l&&Wa(`[${sp}] pass samples ${y.reads.length} textures (> device limit ~${l}); composition may fail on this device.`);try{return e.createBindGroup(y.textureLayout,U)}catch(O){io(`[${sp}] failed to build texture bind group:`,O);return}}function A(y,R){return e.createRenderPipeline({vertex:d,fragment:y.entry,targets:{format:R}})}function w(y,R){if(!y.externalLayout||y.externalReads.length===0)return;let U=y.externalReads;if(U.length===1){let I=R.get(U[0]);if(!I){io(`[${sp}] external read "${U[0]}" has no registered source`);return}return s.createExternalTextureBinding({layout:y.externalLayout,entryKey:U[0],getSource:I})}let O=null;return{update(){let I={};for(let N of U){let G=R.get(N)?.();if(!G)return O=null,null;try{I[N]=e.device.importExternalTexture({source:G})}catch{return O=null,null}}return O=e.createBindGroup(y.externalLayout,I),O},get current(){return O},destroy(){O=null}}}function S(y,R,U,O){let I=R.kind==="canvas"?r:n,N=y.reads.filter(q=>U?.[q]),G=new Map(N.map(q=>[q,U[q].texture]));return{fragment:y,pipeline:A(y,I),textureBindGroup:h(y,U),externalBinding:w(y,O),target:R,mediaReads:N,mediaSnapshot:G}}function T(y,R,U,O){f(y,U);for(let Y of y.computeSteps)Y.bindInputs?.(X=>u.get(X)??O?.[X]);let I=m(),N=new Map;for(let Y of y.externalTextures)N.set(Y.key,Y.getSource);let G=y.rttPasses.map(Y=>S(Y.fragment,{kind:"rtt",key:Y.textureKey},O,N)),q=S(y.finalPass,{kind:"canvas"},O,N);_={ir:y,uniformBindGroup:R,samplerBindGroup:I,computeSteps:y.computeSteps,rttPasses:G,finalPass:q,size:U,mediaResources:O}}function x(y,R){let U=y.pipeline;if(_?.uniformBindGroup&&(U=U.with(_.uniformBindGroup)),y.mediaReads&&y.mediaReads.length>0&&_?.mediaResources){let O=!1;for(let I of y.mediaReads)_.mediaResources[I].texture!==y.mediaSnapshot.get(I)&&(O=!0);if(O){y.textureBindGroup=h(y.fragment,_.mediaResources);for(let I of y.mediaReads)y.mediaSnapshot.set(I,_.mediaResources[I].texture)}}if(y.textureBindGroup&&(U=U.with(y.textureBindGroup)),y.fragment.usesSamplers&&_?.samplerBindGroup&&(U=U.with(_.samplerBindGroup)),y.fragment.externalReads.length>0){let O=y.externalBinding?.update()??null;if(!O){y.externalSkipLogged||(Wa(`[${sp}] external texture not ready \u2014 skipping pass (${y.fragment.externalReads.join(", ")})`),y.externalSkipLogged=!0);return}U=U.with(O)}U.withColorAttachment({view:R}).draw(3)}function D(y,R,U){if(_){for(let O of _.computeSteps){let I=O.getComputeNodes(R);I&&I.length&&o.dispatch(I)}U?.(),k(),x(_.finalPass,y)}}function k(){if(_)for(let y of _.rttPasses){let R=u.get(y.target.key);R&&x(y,B(R))}}function B(y){return e.unwrap(y.texture).createView()}function E(y){if(!(!y.fragment.textureLayout||y.fragment.reads.length===0)&&(y.textureBindGroup=h(y.fragment,_?.mediaResources),y.mediaReads&&y.mediaSnapshot&&_?.mediaResources))for(let R of y.mediaReads)y.mediaSnapshot.set(R,_.mediaResources[R].texture)}function z(y,R){let U=!1;for(let O of u.values())O.resize(y,R)&&(U=!0);if(!_)return U;if(_.size={width:y,height:R},!U)return!1;for(let O of _.computeSteps)O.bindInputs?.(I=>u.get(I)??_.mediaResources?.[I]);for(let O of _.rttPasses)E(O);return E(_.finalPass),!0}return{setComposition:T,render:D,repaintRtt:k,resize:z,get textureCount(){return c.size},get passCount(){return _?_.rttPasses.length+1:0},dispose(){for(let y of[...c])y.destroy();c.clear(),u.clear(),_=null}}}function Ane(){return typeof navigator<"u"&&navigator.gpu?navigator.gpu.getPreferredCanvasFormat():"bgra8unorm"}function rO(e){return`${e}-srgb`}function wne(e){let t=new Set;function s(f,...h){return e.createTexture.call(e,f).$usage(...h)}let o,r,n,i,l={get linearClamp(){return o??=e.createSampler({magFilter:"linear",minFilter:"linear",mipmapFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"})},get nearestClamp(){return r??=e.createSampler({magFilter:"nearest",minFilter:"nearest",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"})},get linearRepeat(){return n??=e.createSampler({magFilter:"linear",minFilter:"linear",mipmapFilter:"linear",addressModeU:"repeat",addressModeV:"repeat"})},get nearestRepeat(){return i??=e.createSampler({magFilter:"nearest",minFilter:"nearest",addressModeU:"repeat",addressModeV:"repeat"})}};function d(f,h,A,w,S){let T={texture:f,width:h,height:A,format:w,write(x){f.write(x)},unwrap(){return e.unwrap(f)},createSrgbView(){if(S)return e.unwrap(f).createView({format:rO(w)})},generateMipmaps(){f.generateMipmaps?.()},destroy(){t.has(T)&&(f.destroy(),t.delete(T))}};return t.add(T),T}function u(f){let{width:h,height:A,srgb:w=!1,mipLevelCount:S}=f,T=f.format??"rgba8unorm";return d(s({size:[h,A],format:T,...w?{viewFormats:[rO(T)]}:{},...S?{mipLevelCount:S}:{}},"sampled","render"),h,A,T,w)}function c(f){let{width:h,height:A,format:w,data:S}=f,T=d(s({size:[h,A],format:w},"sampled"),h,A,w,!1);return S&&T.write(S),T}function _(f){let h=f.format??"rgba16float",{mipLevelCount:A}=f,w=f.width,S=f.height;function T(D,k){return d(s({size:[D,k],format:h,...A?{mipLevelCount:A}:{}},"sampled","render"),D,k,h,!1)}let x=T(w,S);return{get texture(){return x.texture},get width(){return w},get height(){return S},format:h,write(D){x.write(D)},unwrap(){return x.unwrap()},createSrgbView(){return x.createSrgbView()},generateMipmaps(){x.generateMipmaps()},resize(D,k){return D===w&&k===S?!1:(x.destroy(),w=D,S=k,x=T(D,k),!0)},destroy(){x.destroy()}}}function m(f){let{layout:h,entryKey:A,getSource:w,staticEntries:S={}}=f,T=null;return{update(){let x=w();if(!x)return T=null,null;let D;try{D=e.device.importExternalTexture({source:x})}catch{return T=null,null}return T=e.createBindGroup(h,{...S,[A]:D}),T},get current(){return T},destroy(){T=null}}}return{samplers:l,createMediaTexture:u,createDataTexture:c,createRenderTexture:_,createExternalTextureBinding:m,get textureCount(){return t.size},destroy(){for(let f of[...t])f.destroy();t.clear()}}}function W3(e,t,s,o,r,n){if(o===0&&r===0)return[s,0];let i=200*Math.pow(.01,o),l=2*Math.sqrt(i)*(1-r*.85),d=t+(i*(s-e)-l*t)*n;return[e+d*n,d]}function Tne(e){return e<1/2.75?7.5625*e*e:e<2/2.75?(e-=1.5/2.75,7.5625*e*e+.75):e<2.5/2.75?(e-=2.25/2.75,7.5625*e*e+.9375):(e-=2.625/2.75,7.5625*e*e+.984375)}function aO(e,t){switch(t){case"linear":return e;case"quad":return e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2;case"expo":return e===0?0:e===1?1:e<.5?Math.pow(2,20*e-10)/2:(2-Math.pow(2,-20*e+10))/2;case"bounce":return Tne(e);default:return(1-Math.cos(Math.PI*e))/2}}function Sne(e,t,s){let o=s.pixelRatio||1,r=Math.max(1,Math.floor(s.maxTextureDim/o)-1),n=Math.min(e,s.viewportWidth,r),i=Math.min(t,s.viewportHeight,r),l=Math.min(n/e,i/t,1);return{width:Math.max(1,Math.round(e*l)),height:Math.max(1,Math.round(t*l))}}function Cne(e,t,s,o){return e!=null?(o-e)/1e3:t+s}function Pne(e,t){let{lastRenderTime:s,isVisible:o,forceFullFrameRate:r}=t,n=s>0?(e-s)/1e3:.016;if(s>0){let i=e-s;if(!o&&!r&&i<1e3)return{render:!1,deltaTime:n};if((o||r)&&i<15.666666666666668)return{render:!1,deltaTime:n}}return{render:!0,deltaTime:Math.min(n,.1)}}async function nO(e){try{let t=e.device?.queue;if(t&&typeof t.onSubmittedWorkDone=="function"){await t.onSubmittedWorkDone();return}}catch{}await new Promise(t=>setTimeout(t,16))}function Mne(e){e.updateDrivers(),e.ensureComposition()&&(e.beforeRender(),e.flush(),e.render(),e.markReady(),e.afterRender())}function Ene(e){let t=null,s=n=>typeof requestAnimationFrame=="function"?requestAnimationFrame(n):setTimeout(()=>n(performance.now()),16),o=n=>{typeof cancelAnimationFrame=="function"?cancelAnimationFrame(n):clearTimeout(n)},r=()=>{e(),t!==null&&(t=s(r))};return{start(){t===null&&(t=s(r))},stop(){t!==null&&(o(t),t=null)},get running(){return t!==null}}}function kne(e,t){let s=I3(e)?.definition?.naturalSizeKey;if(!s)return null;if("fixed"in s)return s.fixed||null;let o=t[s.fromProp];return typeof o=="string"&&o?o:null}function Rne(e,t,s){if(!e||typeof e!="object")return null;let o=(i,l)=>!i||typeof i!="object"||typeof i.value!="number"?null:i.unit==="px"?i.value:i.value*l,r=o(e.width,t),n=o(e.height,s);return r!=null&&n!=null&&r>0&&n>0?{widthPx:r,heightPx:n}:null}function Dne(e,t,s){let{type:o,decl:r,props:n,boundingBox:i}=e;if(!(t>0)||!(s>0)||e.requiresChild)return null;if(r?.computeBounds){let c=r.computeBounds(n,t,s);return c.widthPx>0&&c.heightPx>0?{widthPx:c.widthPx,heightPx:c.heightPx}:null}let l=r?.propBindings;if(l?.width&&l?.height){let c=u_(l.width,n[l.width.prop],t,s),_=u_(l.height,n[l.height.prop],t,s);return c>0&&_>0?{widthPx:c,heightPx:_}:null}let d=Rne(i,t,s);if(d)return d;let u=kne(o,n);if(u){let c=nP(u);if(c)return{widthPx:c.width,heightPx:c.height}}return null}function zne(e,t){return e==null?0:typeof e=="number"?e:e.unit==="px"?e.value:e.value*t}function q3(e,t,s){return!e||e.mode!=="column"&&e.mode!=="row"?null:{mode:e.mode,gapPx:Math.max(0,zne(e.gap,e.mode==="column"?s:t)),align:e.align??"center",anchor:e.anchor??"center",anchorOffsetX:e.anchorOffset?.x??0,anchorOffsetY:e.anchorOffset?.y??0}}var iO=e=>({ox:e.includes("left")?"start":e.includes("right")?"end":"center",oy:e.includes("top")?"start":e.includes("bottom")?"end":"center"}),Ch=(e,t,s,o)=>e==="start"?o:e==="end"?s-t-o:(s-t)/2+o;function Ph(e,t){let s=0,o=0;for(let r of t){let n=e.mode==="column"?r.size.heightPx:r.size.widthPx,i=e.mode==="column"?r.size.widthPx:r.size.heightPx;s+=n,o=Math.max(o,i)}return t.length>1&&(s+=e.gapPx*(t.length-1)),e.mode==="column"?{widthPx:o,heightPx:s}:{widthPx:s,heightPx:o}}function Bne(e,t,s,o){let r=new Map;if(t.length===0)return r;let n=Ph(e,t),{ox:i,oy:l}=iO(e.anchor),d=Ch(i,n.widthPx,s,e.anchorOffsetX),u=Ch(l,n.heightPx,o,e.anchorOffsetY),c=(m,f)=>e.align==="start"?0:e.align==="end"?f-m:(f-m)/2,_=0;for(let m of t)if(e.mode==="column"){let f=d+c(m.size.widthPx,n.widthPx)+m.size.widthPx/2,h=u+_+m.size.heightPx/2;r.set(m.id,{centerXPx:f,centerYPx:h}),_+=m.size.heightPx+e.gapPx}else{let f=d+_+m.size.widthPx/2,h=u+c(m.size.heightPx,n.heightPx)+m.size.heightPx/2;r.set(m.id,{centerXPx:f,centerYPx:h}),_+=m.size.widthPx+e.gapPx}return r}function Lne(e,t,s){let o=q3(e.layout,t,s);if(o){let r=X3(e,t,s);return r.length===0?null:Ph(o,r)}return Dne({type:e.componentName,decl:e.decl,props:e.props,boundingBox:e.boundingBox,requiresChild:e.requiresChild,availableWidthPx:t},t,s)}function X3(e,t,s){let o=[];for(let r of e.children){if(r.visible===!1||r.absolute)continue;let n=Lne(r,t,s);n&&o.push({id:r.id,size:n,view:r})}return o}function Une(e,t,s){if(!e.decl?.computeBounds)return{x:0,y:0};let o=e.decl.computeBounds(e.props,t,s),r=typeof e.props.center?.x=="number"?e.props.center.x:.5,n=typeof e.props.center?.y=="number"?e.props.center.y:.5;return{x:o.centerXPx-r*t,y:o.centerYPx-n*s}}function One(e,t,s,o,r,n,i,l){let d=q3(e.layout,r,n);if(d){lO(e,d,r,n,i,{centerXPx:s,centerYPx:o},l);return}let u=e.decl?.propBindings?.x?.prop??e.decl?.propBindings?.y?.prop;if(u){if(!e.positionDriven){let c=Une(e,r,n);i.push({kind:"position",id:e.id,prop:u,value:{x:(s-c.x)/r,y:(o-c.y)/n}})}return}i.push({kind:"box",id:e.id,xPx:s-t.widthPx/2,yPx:o-t.heightPx/2,widthPx:t.widthPx,heightPx:t.heightPx})}function lO(e,t,s,o,r,n,i,l){let d=l??X3(e,s,o);if(d.length===0)return;let u=t;if(n){let _=Ph(t,d);u={...t,anchor:"top-left",anchorOffsetX:n.centerXPx-_.widthPx/2,anchorOffsetY:n.centerYPx-_.heightPx/2}}if(i){let _=Ph(u,d),{ox:m,oy:f}=iO(u.anchor);i.set(e.id,{leftPx:Ch(m,_.widthPx,s,u.anchorOffsetX),topPx:Ch(f,_.heightPx,o,u.anchorOffsetY),widthPx:_.widthPx,heightPx:_.heightPx})}let c=Bne(u,d,s,o);for(let _ of d){let m=c.get(_.id);m&&One(_.view,_.size,m.centerXPx,m.centerYPx,s,o,r,i)}}function Gne(e,t,s,o){let r=[],n=i=>{let l=q3(i.layout,t,s);if(l){let d=X3(i,t,s);lO(i,l,t,s,r,void 0,o,d);let u=new Set(d.map(c=>c.id));for(let c of i.children)c.visible!==!1&&(u.has(c.id)||n(c));return}for(let d of i.children)d.visible!==!1&&n(d)};for(let i of e)i.visible!==!1&&n(i);return r}var Fne=class{frameTimesMs=[];frameTimesIndex=0;frameTimesCount=0;maxSamples=60;targetFrameTime=16.67;jankFrameCount=0;totalFrameCount=0;memorySnapshots=[];memorySnapshotIndex=0;maxMemorySnapshots=300;nodeCount=0;rttNodeCount=0;lastCpuTime=null;lastGpuTime=null;isRendering=!1;lastFrameTimestamp=0;frameIntervals=[];frameIntervalsIndex=0;frameIntervalsCount=0;pushToCircularBuffer(e,t,s,o,r){return e.length<r?(e.push(t),{index:e.length,count:e.length}):(e[s%r]=t,{index:s+1,count:r})}getBufferValues(e,t){return t<=e.length?e.slice(0,t):e}recordFrame(e){let t=this.pushToCircularBuffer(this.frameTimesMs,e,this.frameTimesIndex,this.frameTimesCount,this.maxSamples);this.frameTimesIndex=t.index,this.frameTimesCount=t.count,this.totalFrameCount++,e>this.targetFrameTime&&this.jankFrameCount++;let s=performance.now();if(this.lastFrameTimestamp>0){let o=s-this.lastFrameTimestamp,r=this.pushToCircularBuffer(this.frameIntervals,o,this.frameIntervalsIndex,this.frameIntervalsCount,this.maxSamples);this.frameIntervalsIndex=r.index,this.frameIntervalsCount=r.count}this.lastFrameTimestamp=s,this.recordMemorySnapshot()}recordCpuTime(e){this.lastCpuTime=e}recordGpuTime(e){this.lastGpuTime=e}updateNodeCounts(e,t){this.nodeCount=e,this.rttNodeCount=t}setRendering(e){this.isRendering=e}recordMemorySnapshot(){if(!performance.memory)return;let e=performance.now(),t=performance.memory.usedJSHeapSize;if(this.memorySnapshots.length<this.maxMemorySnapshots)this.memorySnapshots.push({time:e,bytes:t});else{let s=this.memorySnapshots[this.memorySnapshotIndex];s.time=e,s.bytes=t,this.memorySnapshotIndex=(this.memorySnapshotIndex+1)%this.maxMemorySnapshots}}calculateMemoryGrowthRate(){if(this.memorySnapshots.length<2)return null;let e=this.memorySnapshots.length,t=e<this.maxMemorySnapshots?0:this.memorySnapshotIndex,s=e<this.maxMemorySnapshots?e-1:(this.memorySnapshotIndex-1+e)%e,o=this.memorySnapshots[t],r=this.memorySnapshots[s],n=(r.time-o.time)/1e3;return n<=0?null:(r.bytes-o.bytes)/(1024*1024)/n}calculateStdDev(e){if(e.length===0)return 0;let t=e.reduce((o,r)=>o+r,0)/e.length,s=0;for(let o=0;o<e.length;o++){let r=e[o]-t;s+=r*r}return Math.sqrt(s/e.length)}sortBuffer=[];calculateP99(e){let t=e.length;if(t===0)return 0;for(;this.sortBuffer.length<t;)this.sortBuffer.push(0);for(let o=0;o<t;o++)this.sortBuffer[o]=e[o];for(let o=1;o<t;o++){let r=this.sortBuffer[o],n=o-1;for(;n>=0&&this.sortBuffer[n]>r;)this.sortBuffer[n+1]=this.sortBuffer[n],n--;this.sortBuffer[n+1]=r}let s=Math.floor(t*.99);return this.sortBuffer[Math.min(s,t-1)]}calculateComplexityScore(){return this.nodeCount+this.rttNodeCount*10}calculateIntensityScore(){let e=this.getBufferValues(this.frameTimesMs,this.frameTimesCount),t=e.length;if(t===0)return{score:0,label:"N/A"};let s=e.reduce((c,_)=>c+_,0)/t,o=Math.min(s/16.67*100,100),r=this.calculateComplexityScore(),n=Math.min(r/100*100,100),i=0;this.lastGpuTime!==null&&(i=Math.min(this.lastGpuTime/16.67*100,100));let l=this.lastGpuTime!==null?{frame:.4,gpu:.4,complexity:.2}:{frame:.7,gpu:0,complexity:.3},d=Math.round(o*l.frame+i*l.gpu+n*l.complexity),u;return d<=20?u="Very Light":d<=40?u="Light":d<=60?u="Medium":d<=80?u="Heavy":u="Very Heavy",{score:Math.min(d,100),label:u}}getStats(e){let t=this.getBufferValues(this.frameTimesMs,this.frameTimesCount),s=this.getBufferValues(this.frameIntervals,this.frameIntervalsCount),o=t.length,r=s.length>0?1e3/(s.reduce((x,D)=>x+D,0)/s.length):0,n=o>0?t.reduce((x,D)=>x+D,0)/o:0,i=o>0?Math.min(...t):0,l=o>0?Math.max(...t):0,d=this.calculateP99(t),u=this.calculateStdDev(t),c=this.totalFrameCount>0?this.jankFrameCount/this.totalFrameCount*100:0,_=performance.memory,m=_?_.usedJSHeapSize/(1024*1024):null,f=this.calculateMemoryGrowthRate(),h=n>0?n/this.targetFrameTime*100:0,A=e?.render?.calls??null,w=e?.programs?.length??null,S=e?.memory?.textures??null,T=this.calculateIntensityScore();return{fps:Math.round(r),avgFrameTime:Math.round(n*100)/100,minFrameTime:Math.round(i*100)/100,maxFrameTime:Math.round(l*100)/100,p99FrameTime:Math.round(d*100)/100,stdDevFrameTime:Math.round(u*100)/100,jankCount:this.jankFrameCount,jankPercent:Math.round(c*10)/10,nodeCount:this.nodeCount,rttNodeCount:this.rttNodeCount,complexityScore:this.calculateComplexityScore(),memoryUsedMB:m!==null?Math.round(m*100)/100:null,memoryGrowthRate:f!==null?Math.round(f*1e3)/1e3:null,cpuTime:this.lastCpuTime!==null?Math.round(this.lastCpuTime*100)/100:null,gpuTime:this.lastGpuTime!==null?Math.round(this.lastGpuTime*100)/100:null,budgetUsed:Math.round(h*10)/10,drawCalls:A,shaderPrograms:w,textureCount:S,intensityScore:T.score,intensityLabel:T.label,isRendering:this.isRendering}}reset(){this.frameTimesMs.length=0,this.frameTimesIndex=0,this.frameTimesCount=0,this.frameIntervals.length=0,this.frameIntervalsIndex=0,this.frameIntervalsCount=0,this.lastFrameTimestamp=0,this.jankFrameCount=0,this.totalFrameCount=0,this.memorySnapshots.length=0,this.memorySnapshotIndex=0,this.sortBuffer.length=0,this.lastCpuTime=null,this.lastGpuTime=null}},Ine=32,Yne=5,Wne=(()=>{let e=0,t=new Set,s=(u,c)=>{t.forEach(_=>{try{_[u](c)}catch(m){io("[Shaders] Error in pointer handler:",m)}})},o=u=>s("onMouseMove",u),r=u=>s("onTouchMove",u),n=u=>s("onMouseDown",u),i=u=>s("onTouchStart",u),l=()=>s("onMouseUp"),d=()=>s("onTouchEnd");return{register(u){return t.add(u),e++,e===1&&typeof window<"u"&&(window.addEventListener("mousemove",o),window.addEventListener("touchmove",r),window.addEventListener("mousedown",n,!0),window.addEventListener("touchstart",i,!0),window.addEventListener("mouseup",l,!0),window.addEventListener("touchend",d,!0)),()=>{t.delete(u),e--,e===0&&typeof window<"u"&&(window.removeEventListener("mousemove",o),window.removeEventListener("touchmove",r),window.removeEventListener("mousedown",n,!0),window.removeEventListener("touchstart",i,!0),window.removeEventListener("mouseup",l,!0),window.removeEventListener("touchend",d,!0))}}}})();function Vne(e){if(!e)return!1;let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{return!1}if(!t||typeof t!="object")return!1;for(let s in t){let o=t[s];if(o&&typeof o=="object"&&o.type==="mouse")return!0}return!1}function dO(){let e=null,t=null,s=null,o=null,r=null,n=null,i=!1,l=!1,d=!1,u=null,c=new Map,_=null,m=new Map,f=[],h=[],A=xne({maxSize:4,dispose:Q=>ip(Q)}),w=new Set,S=null,T=null,x=!0,D=0,k=0,B=0,E=0,z=1,y=8192,R=0,U=0,O=!1,I=()=>B||D||1,N=()=>E||k||1,G=!0,q=!1,Y=!1,X=0,H=0,re=null,ee=null,pe=-10,de=-10,se=!1,ie=null,ye=!1,be=null,ge=null,Be=null,Le=null,Ee=null,Te=null,De=!1,Ne="p3-linear",Oe="linear",Ie=!1,He=null,Ze=null,Je=!1,ut=!1,tt=null,it=!1,lt=null,vt=null,wt=!1,mt=null,gt=null,kt=0,Rt=0,Pt=new Fne,pt={deltaTime:0,pointer:{x:-10,y:-10},pointerActive:!1,dimensions:{width:0,height:0}},Ft=Ene(()=>id()),Yt=Q=>Q.replace(/[^a-zA-Z0-9_]/g,"_"),Ut=Q=>{let te=m.get(Q);if(!te)return[];let oe=[];for(let xe of te){let he=c.get(xe);he&&oe.push(he)}return oe},Ht=Q=>{let te=Yt(Q);for(let[oe,xe]of c)if(xe.metadata.id===te)return oe;return null},Ot=(Q,te)=>{if(te==="center")return;let oe=Q.boundingBoxDeclaration;if(!oe)return;let xe={};for(let[he,Pe]of Object.entries(Q.uniforms))xe[he]=Pe._rawDimensional!==void 0?Pe._rawDimensional:Pe.value;return tx(oe,xe,I(),N())},qt=Q=>{let te=Q.boundingBoxDeclaration,oe=Q.extraDimProps,xe=_u(te,oe);if(!xe)return;let he=Q.uniforms.origin?.value??"center",Pe=Ot(Q,he),qe=[...xe.positionProps,...xe.sizeProps.keys()];for(let _t of qe){let St=Q.uniforms[_t];if(!St||St._rawDimensional===void 0)continue;let os=__(te,_t,St._rawDimensional,he,I(),N(),oe,Pe);St.value=os,On(Q,_t,os)}},jt=(Q,te,oe)=>{if(typeof oe=="number")return oe;let xe=Q.uniforms.origin?.value??"center",he=__(Q.boundingBoxDeclaration,te,oe,xe,I(),N(),Q.extraDimProps);return typeof he=="number"?he:oe?.value??0},_s=()=>{let{width:Q,height:te}=Gn();return Q/Math.max(1,te)},ce=Q=>{let te=Q.metadata.transform;return{offsetX:te?.offsetX??0,offsetY:te?.offsetY??0,rotation:te?.rotation??0,scale:te?.scale??1,anchorX:te?.anchorX??.5,anchorY:te?.anchorY??.5,aspectRatio:_s()}},ze=Q=>{let te=Q.metadata.boundingBox;if(!te)return null;let oe=Qg(te,I(),N());return{centerX:oe.centerX,centerY:oe.centerY,halfWidth:oe.halfWidthUV,halfHeight:oe.halfHeightUV,cornerRadius:oe.cornerRadiusUV,rotation:oe.rotation,aspectRatio:_s()}},we=Q=>!!Q.metadata.boundingBox&&!!Q.boundingBoxDeclaration&&!q1(Q.metadata.boundingBox),Se=Q=>{let te=Q.boundingBoxDeclaration;if(!te||!Q.uniforms||!te.computeBounds&&!te.propBindings)return null;let oe={};for(let[St,os]of Object.entries(Q.uniforms))oe[St]=os._rawDimensional!==void 0?os._rawDimensional:os.value;let xe=tx(te,oe,I(),N());if(xe.hwx<=0&&xe.hhy<=0)return null;let he=.5,Pe=.5,qe=te.propBindings?.x?.prop??te.propBindings?.y?.prop,_t=qe?Q.uniforms[qe]?.value:void 0;if(_t&&typeof _t.x=="number"&&typeof _t.y=="number"&&(he=_t.x,Pe=_t.y),qe){let St=Q.metadata.maps?.[qe];if(St?.type==="mouse-position"){let os=Q.mouseDriverState[qe];os&&(he=os.liveX??(typeof St.x=="number"?St.x:os.currentX),Pe=os.liveY??(typeof St.y=="number"?St.y:os.currentY))}}return{centerX:he,centerY:Pe,halfWidth:xe.hwx,halfHeight:xe.hhy}},Me=Q=>{if(!Q.definition.wantsBoundsParams)return null;let te=Ut(Q.id).sort((oe,xe)=>oe.metadata.renderOrder-xe.metadata.renderOrder);for(let oe of te){if(oe.metadata.visible===!1)continue;if(we(oe))return null;let xe=Se(oe);if(xe)return xe}return null},$e=()=>{for(let Q of c.values()){if(!Q.definition.wantsBoundsParams)continue;let te=Me(Q);te&&(ys(Q,"_childBounds_centerX",te.centerX),ys(Q,"_childBounds_centerY",te.centerY),ys(Q,"_childBounds_halfWidth",te.halfWidth),ys(Q,"_childBounds_halfHeight",te.halfHeight))}},ot=!1,ft=()=>{ot=!0,cn()},xt=()=>{for(let Q of c.values()){let te=Q.metadata.flow?.mode;if(te==="column"||te==="row")return!0}return!1},ht=Q=>{let te={};for(let[Pe,qe]of Object.entries(Q.uniforms))te[Pe]=qe._rawDimensional!==void 0?qe._rawDimensional:qe.value;let oe=Q.boundingBoxDeclaration?.propBindings?.x?.prop??Q.boundingBoxDeclaration?.propBindings?.y?.prop,xe=oe?Q.uniforms[oe]?.value:void 0,he=!!(oe&&(xe?.type==="mouse-position"||Q.metadata.maps?.[oe]));return{id:Q.id,componentName:Q.componentName,visible:Q.metadata.visible!==!1,absolute:Q.metadata.absolute===!0,requiresChild:Q.requiresChild,layout:Q.metadata.flow,decl:Q.boundingBoxDeclaration,props:te,boundingBox:Q.metadata.boundingBox,positionDriven:he,children:Ut(Q.id).sort((Pe,qe)=>Pe.metadata.renderOrder-qe.metadata.renderOrder).map(ht)}},Kt=()=>{if(!xt()){ot=!1;return}let Q=I(),te=N();if(Q<=1||te<=1)return;ot=!1;let oe=[];for(let he of c.values())he.parentId===null&&oe.push(ht(he));let xe=Gne(oe,Q,te);for(let he of xe){let Pe=c.get(he.id);if(Pe)if(he.kind==="position"){let qe=Pe.uniforms[he.prop];if(!qe)continue;let _t=qe.value,St=_t&&typeof _t=="object"?{..._t,x:he.value.x,y:he.value.y}:he.value;qe.value=St,On(Pe,he.prop,St)}else{let qe=we(Pe);if(Pe.metadata.boundingBox={x:{value:he.xPx,unit:"px"},y:{value:he.yPx,unit:"px"},width:{value:he.widthPx,unit:"px"},height:{value:he.heightPx,unit:"px"},origin:"top-left",rotation:Pe.metadata.boundingBox?.rotation??0,...Pe.metadata.boundingBox?.cornerRadius?{cornerRadius:Pe.metadata.boundingBox.cornerRadius}:{},...Pe.metadata.boundingBox?.lockAspect!==void 0?{lockAspect:Pe.metadata.boundingBox.lockAspect}:{}},!qe&&we(Pe))Fn();else{let _t=ze(Pe);if(_t)for(let[St,os]of Object.entries(_t))ys(Pe,`_bbox_${St}`,os)}}}},Qt=()=>{ot&&Kt()},Es=null,Os=()=>{xt()&&ft()},Is=()=>{Es||(Es=iP(()=>{xt()&&ft()})),typeof document<"u"&&document.fonts?.addEventListener&&document.fonts.addEventListener("loadingdone",Os)};Is();let is=Q=>Ei(Q.metadata.transform),eo=(Q,te,oe)=>{let xe=Q.mapValues[te]??{inputMin:0,inputMax:1,outputMin:0,outputMax:1,curve:0};if(oe.type==="map"){let he=oe;xe.inputMin=he.inputMin,xe.inputMax=he.inputMax,xe.outputMin=jt(Q,te,he.outputMin),xe.outputMax=jt(Q,te,he.outputMax),xe.curve=he.curve??0}else if(oe.type==="mouse"){let he=oe;xe.outputMin=jt(Q,te,he.outputMin),xe.outputMax=jt(Q,te,he.outputMax),xe.curve=he.curve??0}else if(oe.type==="auto-animate"){let he=oe;xe.outputMin=jt(Q,te,he.outputMin),xe.outputMax=jt(Q,te,he.outputMax)}return Q.mapValues[te]=xe,xe},Mo=(Q,te,oe)=>{let xe=Q.mouseDriverState[te];if(xe)return xe;if(oe.type==="mouse-position"){let he=oe.x===void 0||oe.x==="mouse",Pe=oe.y===void 0||oe.y==="mouse";xe={currentX:he?pe:oe.x,currentY:Pe?de:oe.y,velocityX:0,velocityY:0}}else xe={currentX:Math.max(.001,oe.axis==="x"?pe:de),currentY:0,velocityX:0,velocityY:0};return Q.mouseDriverState[te]=xe,xe},or=Q=>{let te=Q.metadata.maps;if(te)for(let[oe,xe]of Object.entries(te))oe in Q.uniforms&&(xe.type==="map"?eo(Q,oe,xe):xe.type==="mouse-position"?Mo(Q,oe,xe):xe.type==="mouse"?(Mo(Q,oe,xe),eo(Q,oe,xe)):xe.type==="auto-animate"&&(Q.autoAnimateState[oe]||(Q.autoAnimateState[oe]={}),eo(Q,oe,xe)))},rr=Q=>{let te=Q.definition.animatedTime;return(te?Q.uniforms[te.speed]:void 0)??Q},Ya=(Q,te)=>Q.uniforms[te]??Q,Ti=Q=>{let te=[];for(let[he,Pe]of Object.entries(Q.uniforms))te.push({name:he,initial:Pe.value,transform:Pe.transform,cpu:Pe.cpu,schema:Pe.schema});if(te.push({name:"_opacity",schema:a,initial:Q.metadata.opacity??1}),Q.definition.animatedTime&&te.push({name:"_animTime",schema:a,initial:ec(rr(Q)).value}),Q.definition.extraAnimatedTimes)for(let[he,Pe]of Object.entries(Q.definition.extraAnimatedTimes))te.push({name:`_animTime_${he}`,schema:a,initial:ec(Ya(Q,Pe)).value});let oe=Q.definition.extraFields;if(oe)for(let[he,Pe]of Object.entries(oe))te.push({name:he,schema:Pe.schema,initial:Pe.initial});if(is(Q)){let he=ce(Q);for(let[Pe,qe]of Object.entries(he))te.push({name:`_xform_${Pe}`,schema:a,initial:qe})}if(we(Q)){let he=ze(Q);if(he)for(let[Pe,qe]of Object.entries(he))te.push({name:`_bbox_${Pe}`,schema:a,initial:qe})}if(Q.definition.wantsBoundsParams){let he=Me(Q)??{centerX:.5,centerY:.5,halfWidth:.5,halfHeight:.5};for(let[Pe,qe]of Object.entries(he))te.push({name:`_childBounds_${Pe}`,schema:a,initial:qe})}let xe=Q.metadata.maps;if(xe){or(Q);for(let[he,Pe]of Object.entries(xe))if(he in Q.uniforms){if(Pe.type==="map"){let qe=Q.mapValues[he];te.push({name:`_map_${he}_inputMin`,schema:a,initial:qe.inputMin}),te.push({name:`_map_${he}_inputMax`,schema:a,initial:qe.inputMax}),te.push({name:`_map_${he}_outputMin`,schema:a,initial:qe.outputMin}),te.push({name:`_map_${he}_outputMax`,schema:a,initial:qe.outputMax}),te.push({name:`_map_${he}_curve`,schema:a,initial:qe.curve})}else if(Pe.type==="mouse-position"){let qe=Q.mouseDriverState[he];te.push({name:`_smoothed_${he}`,schema:p,initial:[qe.currentX,1-qe.currentY]})}else if(Pe.type==="mouse"){let qe=Q.mapValues[he];te.push({name:`_smoothed_${he}`,schema:a,initial:qe.outputMin})}else if(Pe.type==="auto-animate"){let qe=Q.mapValues[he];te.push({name:`_smoothed_${he}`,schema:a,initial:qe.outputMin})}}}return te},On=(Q,te,oe)=>{let xe=Q._liveHandles?.[te];xe&&(He?.(Ne),Iw(xe,oe))},ys=(Q,te,oe)=>{let xe=Q._liveHandles?.[te];xe instanceof Jn&&(xe.value=oe)},sc=(Q,te,oe)=>{let xe=Q._liveHandles?.[te];xe instanceof Jn&&(xe.value=oe)},op=Q=>{for(let te of Object.values(Q.uniforms))if(te.transform===at){let oe=te.value;if(typeof oe=="string")return at(oe);if(typeof oe=="number")return oe}return 0},rp=Q=>{if(!Q.uniforms.convertedColorsArray)return;let te=null;for(let Pe of Object.values(Q.uniforms))if(Pe.transform===Ol){te=Pe.value??null;break}let oe=K0(te,Z0),xe=Q0(oe.colors,oe.stopCount,op(Q)),he=(Pe,qe)=>{let _t=Q.uniforms[Pe];_t&&(_t.value=qe),On(Q,Pe,qe)};he("colorsArray",oe.colors),he("positionsArray",oe.positions),he("convertedColorsArray",xe),he("stopCount",oe.stopCount)},ap=Q=>{if(ys(Q,"_opacity",Q.metadata.opacity??1),Q.definition.animatedTime&&ys(Q,"_animTime",ec(rr(Q)).value),Q.definition.extraAnimatedTimes)for(let[oe,xe]of Object.entries(Q.definition.extraAnimatedTimes))ys(Q,`_animTime_${oe}`,ec(Ya(Q,xe)).value);if(is(Q))for(let[oe,xe]of Object.entries(ce(Q)))ys(Q,`_xform_${oe}`,xe);if(we(Q)){let oe=ze(Q);if(oe)for(let[xe,he]of Object.entries(oe))ys(Q,`_bbox_${xe}`,he)}let te=Q.metadata.maps;if(te){for(let[oe,xe]of Object.entries(te))if(xe.type==="map"&&Q.mapValues[oe]){let he=Q.mapValues[oe];ys(Q,`_map_${oe}_inputMin`,he.inputMin),ys(Q,`_map_${oe}_inputMax`,he.inputMax),ys(Q,`_map_${oe}_outputMin`,he.outputMin),ys(Q,`_map_${oe}_outputMax`,he.outputMax),ys(Q,`_map_${oe}_curve`,he.curve)}}},il=(Q,te)=>{let oe={};for(let xe of Object.keys(Q.uniforms)){let he=te[xe];he&&(oe[xe]=he)}return oe},oc=Q=>{let te={};for(let[oe,xe]of Object.entries(Q.uniforms))te[oe]={accessorPath:"",cpu:!!xe.cpu,value:xe.value};return te},np=(Q,te)=>({id:Q.id,customId:Q.metadata.id,componentName:Q.componentName,parentId:Q.parentId,definition:Q.definition,metadata:Q.metadata,handles:te,domCanvas:Q.domCanvas}),rc=(Q,te)=>{let oe=new Map,xe=Pe=>np(Pe,Q&&te?il(Pe,te.get(Pe.id)??{}):oc(Pe)),he=Pe=>{let qe=oe.get(Pe);if(qe)return qe;let _t=c.get(Pe);if(!_t)return;let St=xe(_t);return oe.set(Pe,St),St};return{rootId:_,getNode:he,getChildren:Pe=>Ut(Pe).map(qe=>he(qe.id)),resolveCustomId:Pe=>Ht(Pe),store:{gpuAccessor:(Pe,qe)=>Q?Q.gpuAccessor(Pe,qe):"",layout:Q?.layout}}},ac=()=>({toneMapping:Oe,flipY:!1,premultiplyAlpha:!0,canvas:n??void 0,dimensions:Gn(),gpu:t?{device:t.device,root:t}:void 0,writeExtraField:(Q,te,oe)=>{let xe=c.get(Q);xe&&sc(xe,te,oe)},createMediaTexture:Q=>{if(!o)throw new Error("[gpu] createMediaTexture before init");return o.createMediaTexture(Q)},createDataTexture:Q=>{if(!o)throw new Error("[gpu] createDataTexture before init");return o.createDataTexture(Q)},resolveMapWindow:(Q,te)=>{let oe=c.get(Q),xe=oe?.metadata.maps?.[te];if(!oe||!xe||xe.type!=="map")return;let he=eo(oe,te,xe);return{inputMin:he.inputMin,inputMax:he.inputMax,outputMin:he.outputMin,outputMax:he.outputMax,curve:he.curve}},resolveDriverCpuValue:(Q,te)=>{let oe=c.get(Q),xe=oe?.metadata.maps?.[te];if(!(!oe||!xe)){if(xe.type==="mouse-position"){let he=oe.mouseDriverState[te];return!he||he.liveX===void 0||he.liveY===void 0?void 0:{x:he.liveX,y:1-he.liveY}}if(xe.type==="mouse"||xe.type==="auto-animate"){let he=oe._liveHandles?.[`_smoothed_${te}`];return he instanceof Jn?he.value:void 0}}}}),Mh=()=>{let Q=[];for(let[te,oe]of c){let xe=oe.metadata;Q.push(`aopac:${te}:${(xe.opacity??1)<1}`);let he=oe.uniforms.stopCount?.value;typeof he=="number"&&Q.push(`stops:${te}:${he>1?he:0}`);for(let[Pe,qe]of Object.entries(oe.uniforms)){if(!qe.compileTimeWhen)continue;let _t=qe._lastCompiledValue;typeof _t!="number"&&typeof _t!="boolean"||Q.push(`ctw:${te}:${Pe}:${String(_t)}`)}if(xe.maps){let Pe=Object.entries(xe.maps).sort(([qe],[_t])=>qe<_t?-1:qe>_t?1:0).map(([qe,_t])=>{let St=_t;return`${qe}=${St.type}:${St.source??""}:${St.channel??""}:${St.axis??""}`}).join(",");Q.push(`mapfp:${te}:${Pe}`)}}return Q},ym=()=>_?gne([...w7(rc(null,null),ac()),...Mh()]):null,Gn=()=>({width:Math.max(1,Math.round(D*z)),height:Math.max(1,Math.round(k*z))}),gm=Q=>{let te={};for(let oe of Q.textures)oe.kind!=="rtt"&&oe.resource&&(te[oe.key]=oe.resource);return te},xm=Q=>{if(!t||!o||!r)throw new Error("[gpu] buildComposition before init");let te=Fw(t,{systemSchema:yne}),oe=new Map;for(let[qe,_t]of c)oe.set(qe,te.defineNode(qe,Ti(_t)));te.defineSystem(),te.finalize();let xe=A7(rc(te,oe),ac()),he=bne(t,{textureManager:o,dispatcher:r});he.setComposition(xe,te.bindGroup,Gn(),gm(xe));let Pe={hash:Q,store:te,ir:xe,passManager:he,handlesById:oe,fresh:!0};return w.add(Pe),Pe},ip=Q=>{try{for(let te of Q.ir.onCleanup)te()}catch(te){io("[gpu] composition onCleanup error:",te)}try{Q.passManager.dispose()}catch(te){io("[gpu] passManager dispose error:",te)}try{Q.store.destroy()}catch(te){io("[gpu] store destroy error:",te)}w.delete(Q),S===Q&&(S=null)},Eh=Q=>{let te=!1;for(let[oe,xe]of Q.handlesById){let he=c.get(oe);he&&he._liveHandles!==xe&&(he._liveHandles=xe,te=!0)}if(!(Q===S&&!te)){if(!Q.fresh){for(let oe of c.values()){for(let[xe,he]of Object.entries(oe.uniforms))On(oe,xe,he.value);or(oe),ap(oe)}Q.store.writeAll()}Q.fresh=!1,S=Q,!Je&&Q.ir.composedNodeIds.size>0&&(ut=!0)}},Fn=()=>{x=!0,xt()&&(ot=!0),cn()},cn=()=>{lt||Ft.running||ee===null&&typeof requestAnimationFrame=="function"&&(ee=requestAnimationFrame(()=>{ee=null,id()}))},bm=(Q,te,oe,xe,he={},Pe,qe)=>{if(lt)return;if(te===null){let rs=f.findIndex(wr=>wr.id===Q);if(rs!==-1){f.splice(rs,1),h=h.filter(wr=>wr.id!==Q);return}ll(Q);return}if(!Pe){console.error(`[gpu] registerNode("${Q}") requires a componentDefinition`);return}if(!d){let rs=f.findIndex(Tn=>Tn.id===Q),wr={id:Q,definition:Pe,parentId:oe,metadata:xe,uniforms:he,domCanvas:qe};rs!==-1?(f[rs]=wr,h=h.filter(Tn=>Tn.id!==Q)):f.push(wr);return}let _t=0;if(oe!==null){let rs=m.get(oe);if(rs&&rs.size>0){let wr=0;for(let Tn of rs){let xa=c.get(Tn);xa&&xa.metadata.renderOrder>wr&&(wr=xa.metadata.renderOrder)}_t=wr+1}}let St={blendMode:xe?.blendMode||"normal",opacity:xe?.opacity,visible:xe?.visible!==!1,id:xe?.id?Yt(xe.id):xe?.id,mask:xe?.mask,maps:xe?.maps,renderOrder:xe?.renderOrder!==void 0?xe.renderOrder:_t,transform:xe?.transform,boundingBox:xe?.boundingBox,flow:xe?.flow,absolute:xe?.absolute},os=Pe.boundingBoxDeclaration,Uo=Pe.props?ex(Pe.props):void 0,No={id:Q,componentName:Pe.name||"Unknown",parentId:oe,definition:Pe,metadata:St,uniforms:he,domCanvas:qe,requiresRTT:!!Pe.requiresRTT,requiresChild:!!Pe.requiresChild,blendWithChildren:!!Pe.blendWithChildren,acceptsUVContext:!!Pe.acceptsUVContext,providesUVContextViaCompute:!!Pe.providesUVContextViaCompute,usesPointer:!!Pe.usesPointer,hasUvRemap:!!Pe.uvRemap,boundingBoxDeclaration:os,wantsBoundsParams:!!Pe.wantsBoundsParams,extraDimProps:Uo,mouseDriverState:{},autoAnimateState:{},mapValues:{},_liveHandles:null};if(os||Uo){let rs=_u(os,Uo);if(rs){let wr=he.origin?.value??"center",Tn=Ot(No,wr);for(let xa of[...rs.positionProps,...rs.sizeProps.keys()]){let aa=he[xa];aa&&(aa._rawDimensional===void 0&&(aa._rawDimensional=aa.value),aa.value=__(os,xa,aa._rawDimensional,wr,I(),N(),Uo,Tn))}}}for(let rs of Object.values(he))rs.compileTimeWhen&&rs._lastCompiledValue===void 0&&(rs._lastCompiledValue=rs.value);c.set(Q,No),oe===null&&(_=Q);let mo=m.get(oe)||new Set;mo.add(Q),m.set(oe,mo),cc(),Fn(),xt()&&ft()},Am=Q=>{f.some(te=>te.id===Q.id)&&h.push(Q)},wm=(Q,te,oe)=>{let xe=c.get(Q);if(!xe){Am({id:Q,kind:"uniform",name:te,value:oe});return}let he=xe.uniforms[te];if(!he)return;let Pe=xe.boundingBoxDeclaration,qe=xe.extraDimProps;if((Pe||qe)&&sx(Pe,te,qe)){he._rawDimensional=oe;let _t=xe.uniforms.origin?.value??"center",St=Ot(xe,_t);oe=__(Pe,te,oe,_t,I(),N(),qe,St)}if(he.value=oe,On(xe,te,oe),(he.transform===Ol||he.transform===at)&&rp(xe),te==="origin"&&Pe)qt(xe);else if(Pe&&(xe.uniforms.origin?.value??"center")!=="center"){let _t=_u(Pe,qe),St=!!Pe.computeBounds||(_t?.sizeProps.has(te)??!1),os=_t?.positionProps.has(te)??!1;St&&!os&&qt(xe)}if(te==="shape"&&cc(),xt()&&ft(),he.compileTime){Fn();return}if(he.compileTimeWhen){let _t=he._lastCompiledValue;if(he.compileTimeWhen(_t,oe)){he._lastCompiledValue=oe,Fn();return}}cn()},nd=(Q,te)=>{let oe=c.get(Q);if(!oe){Am({id:Q,kind:"metadata",metadata:te});return}let xe=!1;if(te.blendMode!==void 0&&oe.metadata.blendMode!==te.blendMode&&(oe.metadata.blendMode=te.blendMode,xe=!0),te.opacity!==void 0&&oe.metadata.opacity!==te.opacity){let he=oe.metadata.opacity??1,Pe=te.opacity;oe.metadata.opacity=Pe,ys(oe,"_opacity",Pe),he>=1!=Pe>=1&&(xe=!0)}if(te.renderOrder!==void 0&&oe.metadata.renderOrder!==te.renderOrder&&(oe.metadata.renderOrder=te.renderOrder,xe=!0),"visible"in te){let he=te.visible!==!1;oe.metadata.visible!==he&&(oe.metadata.visible=he,xe=!0)}if(te.id!==void 0){let he=Yt(te.id);oe.metadata.id!==he&&(oe.metadata.id=he,xe=!0)}if("mask"in te&&(oe.metadata.mask?.source!==te.mask?.source||oe.metadata.mask?.type!==te.mask?.type)&&(oe.metadata.mask=te.mask,xe=!0),"maps"in te&&JSON.stringify(oe.metadata.maps)!==JSON.stringify(te.maps)){let he=oe.metadata.maps,Pe=te.maps;if(oe.metadata.maps=Pe,cc(),(()=>{if(!he||!Pe)return!0;let qe=Object.keys(he),_t=Object.keys(Pe);if(qe.length!==_t.length||!qe.every(St=>St in Pe))return!0;for(let St of _t){let os=he[St],Uo=Pe[St];if(os.type!==Uo.type)return!0;if(Uo.type==="map"){let No=os,mo=Uo;if(No.source!==mo.source||No.channel!==mo.channel)return!0}else if(Uo.type==="mouse"&&os.axis!==Uo.axis)return!0}return!1})()){if(he&&Pe)for(let qe of Object.keys(he))qe in Pe&&he[qe].type!==Pe[qe].type&&(delete oe.mouseDriverState[qe],delete oe.autoAnimateState[qe],delete oe.mapValues[qe]);xe=!0}else if(Pe)for(let[qe,_t]of Object.entries(Pe)){let St=eo(oe,qe,_t);_t.type==="map"&&(ys(oe,`_map_${qe}_inputMin`,St.inputMin),ys(oe,`_map_${qe}_inputMax`,St.inputMax),ys(oe,`_map_${qe}_outputMin`,St.outputMin),ys(oe,`_map_${qe}_outputMax`,St.outputMax),ys(oe,`_map_${qe}_curve`,St.curve))}}if(te.transform!==void 0){let he=oe.metadata.transform,Pe={offsetX:te.transform.offsetX??he?.offsetX??0,offsetY:te.transform.offsetY??he?.offsetY??0,rotation:te.transform.rotation??he?.rotation??0,scale:te.transform.scale??he?.scale??1,anchorX:te.transform.anchorX??he?.anchorX??.5,anchorY:te.transform.anchorY??he?.anchorY??.5,edges:te.transform.edges??he?.edges??"transparent"},qe=is(oe);oe.metadata.transform=Pe;let _t=Ei(Pe);if(qe!==_t||he&&he.edges!==Pe.edges)xe=!0;else if(_t)for(let[St,os]of Object.entries(ce(oe)))ys(oe,`_xform_${St}`,os)}if(te.boundingBox!==void 0&&te.boundingBox!==null&&oe.boundingBoxDeclaration!==void 0){let he=we(oe);oe.metadata.boundingBox=te.boundingBox;let Pe=we(oe);if(he!==Pe)xe=!0;else if(Pe){let qe=ze(oe);if(qe)for(let[_t,St]of Object.entries(qe))ys(oe,`_bbox_${_t}`,St)}}else te.boundingBox===null&&oe.metadata.boundingBox!==void 0&&(oe.metadata.boundingBox=void 0,xe=!0);if("flow"in te&&JSON.stringify(oe.metadata.flow)!==JSON.stringify(te.flow)){let he=oe.metadata.flow?.mode==="column"||oe.metadata.flow?.mode==="row";oe.metadata.flow=te.flow??void 0;let Pe=oe.metadata.flow?.mode==="column"||oe.metadata.flow?.mode==="row";if(he&&!Pe){let qe=_t=>{for(let St of Ut(_t))qt(St),qe(St.id)};qe(Q)}ft()}"absolute"in te&&oe.metadata.absolute!==te.absolute&&(oe.metadata.absolute=te.absolute,te.absolute&&qt(oe),ft()),xt()&&ft(),xe?Fn():cn()},ll=Q=>{let te=c.get(Q);if(!te)return;for(let xe of Ut(Q))ll(xe.id);_===Q&&(_=null);let oe=m.get(te.parentId);oe&&(oe.delete(Q),oe.size===0&&m.delete(te.parentId)),c.delete(Q),cc(),Fn(),xt()&&ft()},Tm=()=>{let Q=pt.deltaTime;H=Cne(re,H,Q,performance.now());for(let te of c.values()){let oe=te.metadata.maps;if(oe){for(let xe in te.mouseDriverState){let he=te.mouseDriverState[xe],Pe=oe[xe];if(Pe){if(Pe.type==="mouse-position"){let qe=Pe.smoothing??0,_t=Pe.momentum??0,St=Pe.x===void 0||Pe.x==="mouse",os=Pe.y===void 0||Pe.y==="mouse",Uo,No;if(St){let[Sn,uc]=W3(he.currentX,he.velocityX,pe,qe,_t,Q);he.currentX=Sn,he.velocityX=uc,Uo=Sn}else Uo=Pe.x,he.velocityX=0;if(os){let[Sn,uc]=W3(he.currentY,he.velocityY,de,qe,_t,Q);he.currentY=Sn,he.velocityY=uc,No=Sn}else No=Pe.y,he.velocityY=0;let mo=Pe.reach??1,rs=Pe.originX??.5,wr=Pe.originY??.5,Tn=Pe.invertX?-1:1,xa=Pe.invertY?-1:1,aa=rs+Tn*(Uo-rs)*mo,un=wr+xa*(No-wr)*mo,ld=aa,mp=un,km=te.metadata.boundingBox;if(km&&te.boundingBoxDeclaration?.supportsResizeFit&&we(te)){let Sn=Qg(km,I(),N()),uc=g7(aa,un,{centerX:Sn.centerX,centerY:Sn.centerY,halfWidthUV:Sn.halfWidthUV,halfHeightUV:Sn.halfHeightUV,rotationDeg:Sn.rotation,aspectRatio:_s()});ld=uc.x,mp=uc.y}he.liveX=ld,he.liveY=mp;let K3=te._liveHandles?.[`_smoothed_${xe}`];K3 instanceof Jn&&K3.setComponents(ld,1-mp)}else if(Pe.type==="mouse"){let qe=Pe.smoothing??0,_t=Pe.momentum??0,St=Pe.axis==="x"?pe:de,[os,Uo]=W3(he.currentX,he.velocityX,St,qe,_t,Q);he.currentX=os,he.velocityX=Uo;let No=Math.max(.001,os),mo=te.mapValues[xe],rs=mo?mo.outputMin+(mo.outputMax-mo.outputMin)*Math.pow(No,Math.pow(2,-mo.curve*2)):No;he.liveScalar=rs,ys(te,`_smoothed_${xe}`,rs)}}}for(let xe in te.autoAnimateState){let he=oe[xe];if(!he||he.type!=="auto-animate")continue;let Pe=H*(he.speed??1)*.2,qe,_t=he.easing??he.waveform??"sine";if(he.mode==="loop")qe=aO((Pe%1+1)%1,_t);else{let rs=(Pe%1+1)%1;qe=aO(rs<.5?rs*2:(1-rs)*2,_t)}let St=te.mapValues[xe],os=St?St.outputMin:jt(te,xe,he.outputMin),Uo=St?St.outputMax:jt(te,xe,he.outputMax),No=os+qe*(Uo-os),mo=te.uniforms[xe];if(mo?.compileTimeWhen){let rs=mo._lastCompiledValue;mo.compileTimeWhen(rs,No)&&(mo._lastCompiledValue=No,Fn())}ys(te,`_smoothed_${xe}`,No)}}}},Sm=()=>{let Q=pt.deltaTime;for(let te of c.values()){let oe=te.definition.animatedTime;if(oe){let he=te.uniforms[oe.speed],Pe=he&&Number(he.value)||0,qe=ec(rr(te));qe.advance(Q,Pe),ys(te,"_animTime",qe.value)}let xe=te.definition.extraAnimatedTimes;if(xe)for(let[he,Pe]of Object.entries(xe)){let qe=te.uniforms[Pe],_t=qe&&Number(qe.value)||0,St=ec(Ya(te,Pe));St.advance(Q,_t),ys(te,`_animTime_${he}`,St.value)}}},lp=(Q,te)=>Sne(Q,te,{maxTextureDim:y,pixelRatio:z,viewportWidth:typeof window<"u"?window.innerWidth:Q,viewportHeight:typeof window<"u"?window.innerHeight:te}),dp=()=>{let Q=(typeof window<"u"?window.devicePixelRatio:1)||1;return Math.min(Q,L7())},nc=(Q,te,oe,xe)=>{if(O&&Q===D&&te===k&&oe===B&&xe===E){let{width:_t,height:St}=Gn();if(!n||n.width===_t&&n.height===St)return}D=Q,k=te,B=oe,E=xe,J0(oe,xe),O||(O=!0,c.size>0&&Fn());let{width:he,height:Pe}=Gn();n&&(n.width=he,n.height=Pe);let qe=!1;for(let _t of w)_t.passManager.resize(he,Pe)&&(qe=!0);for(let _t of w)for(let St of _t.ir.onResize)try{St({width:he,height:Pe})}catch(os){io("[gpu] composition onResize error:",os)}for(let _t of c.values()){if(is(_t)&&ys(_t,"_xform_aspectRatio",_s()),we(_t)){let St=ze(_t);if(St)for(let[os,Uo]of Object.entries(St))ys(_t,`_bbox_${os}`,Uo)}qt(_t)}if(Kt(),qe)for(let _t of w)pp(_t.store),_t.store.flush(),_t.passManager.repaintRtt();X=0,id()},cp=(Q,te)=>{Q<=0||te<=0||Q===R&&te===U||(R=Q,U=te,Te={width:Q,height:te},!De&&typeof requestAnimationFrame=="function"&&(De=!0,requestAnimationFrame(()=>{if(De=!1,!Te)return;let oe=Te;Te=null;let{width:xe,height:he}=lp(oe.width,oe.height);nc(xe,he,oe.width,oe.height)})))},kh=Q=>{let te=Q[0];if(!te)return;let oe,xe;if(te.contentBoxSize){let he=Array.isArray(te.contentBoxSize)?te.contentBoxSize[0]:te.contentBoxSize;he?(oe=Math.round(he.inlineSize),xe=Math.round(he.blockSize)):(oe=Math.round(te.contentRect.width),xe=Math.round(te.contentRect.height))}else oe=Math.round(te.contentRect.width),xe=Math.round(te.contentRect.height);oe===0||xe===0||cp(oe,xe)},Rh=Q=>{let te=Q[0];te&&(q=te.isIntersecting)},up=()=>i&&!!t&&!!s&&D>0&&k>0,pp=Q=>{let te=Q.systemHandles,{width:oe,height:xe}=Gn(),he=dp(),Pe=(qe,_t)=>{let St=te[qe];St instanceof Jn&&(St.value=_t)};Pe("time",H),Pe("viewportSize",[oe,xe]),Pe("logicalViewportSize",[I()*he,N()*he]),Pe("aspect",oe/Math.max(1,xe)),Pe("pointer",[pe,de]),Pe("pointerActive",se?1:0)},_p=Q=>{for(let te of Q)try{te(pt)}catch(oe){io("[gpu] render callback error:",oe)}},Cm=Q=>{if(lt||!up())return;let te=performance.now(),oe;if(Q!==void 0)oe=Q;else{let qe=Pne(te,{lastRenderTime:X,isVisible:q,forceFullFrameRate:Y});if(!qe.render)return;oe=qe.deltaTime}X=te,Ie&&performance.mark("shader-cpu-start");let xe=pe>-5;pt.deltaTime=oe,pt.pointer.x=xe?pe:.5,pt.pointer.y=xe?de:.5,pt.pointerActive=se,pt.dimensions.width=D,pt.dimensions.height=k;let he=null,Pe=null;try{Mne({updateDrivers:()=>{Tm(),Sm(),$e(),Qt()},ensureComposition:()=>((x||T===null)&&(T=ym(),x=!1),T===null?!1:(he=A.getOrBuild(T,()=>xm(T)),Eh(he),!!S)),beforeRender:()=>_p(S.ir.onBeforeRender),flush:()=>{pp(S.store),S.store.flush()},render:()=>{if(Ie&&performance.mark("shader-gpu-start"),Pe=A.renderValue??he,Pe?.passManager.render(s,pt,()=>S?.store.flush()),Ie){performance.mark("shader-gpu-end");try{performance.measure("shader-gpu-time","shader-gpu-start","shader-gpu-end");let qe=performance.getEntriesByName("shader-gpu-time")[0];qe&&Pt.recordGpuTime(qe.duration),performance.clearMeasures("shader-gpu-time"),performance.clearMarks("shader-gpu-start"),performance.clearMarks("shader-gpu-end")}catch{}}},markReady:()=>{A.markReady(T),ut&&!Je&&(Je=!0,ut=!1,Ze&&queueMicrotask(Ze))},afterRender:()=>_p((Pe??S).ir.onAfterRender)}),Rt=0}catch(qe){Ih(qe);return}if(Ie){performance.mark("shader-cpu-end");try{performance.measure("shader-cpu-time","shader-cpu-start","shader-cpu-end");let qe=performance.getEntriesByName("shader-cpu-time")[0];qe&&Pt.recordCpuTime(qe.duration),performance.clearMarks("shader-cpu-start"),performance.clearMarks("shader-cpu-end"),performance.clearMeasures("shader-cpu-time")}catch{}}Pt.recordFrame(performance.now()-te)},id=()=>Cm(void 0),Dh=async Q=>{if(lt)return;if(!up())throw new Error("Renderer is not ready");let te=Ft.running;te&&lc(),X=0,id(),t&&Q?.waitForGpu!==!1&&await nO(t),te&&ic()},zh=async(Q,te)=>{Cm(Q),t&&te?.waitForGpu!==!1&&await nO(t)},ic=()=>{lt||Ft.running||!G||(Pt.setRendering(!0),Ft.start())},lc=()=>{Ft.running&&(Ft.stop(),Pt.setRendering(!1))},dc=Q=>{if(!n)return;ie=n.getBoundingClientRect();let te,oe;if("touches"in Q){if(Q.touches.length===0)return;te=Q.touches[0].clientX,oe=Q.touches[0].clientY}else te=Q.clientX,oe=Q.clientY;pe=(te-ie.left)/ie.width,de=(oe-ie.top)/ie.height},Bh=Q=>{!i||!n||(dc(Q),se=!0,cn())},Lh=Q=>{!i||!n||(dc(Q),se=!0,cn())},Uh=()=>{i&&(se=!1,cn())},Oh=()=>{i&&(se=!1,cn())},Pm=(Q,te)=>{if(!i||!n)return!1;let oe=n.getBoundingClientRect();return oe.width===0||oe.height===0?!1:Q>=oe.left&&Q<=oe.right&&te>=oe.top&&te<=oe.bottom},Gh=Q=>{Q.button===0&&Pm(Q.clientX,Q.clientY)&&(se=!0,dc(Q),cn())},Fh=Q=>{Q.touches.length!==0&&Pm(Q.touches[0].clientX,Q.touches[0].clientY)&&(se=!0,dc(Q),cn())},cc=()=>{let Q=!1;for(let te of c.values()){if(te.usesPointer){Q=!0;break}if(Vne(te.uniforms?.shape?.value)){Q=!0;break}if(te.metadata.maps){for(let oe of Object.values(te.metadata.maps))if(oe&&typeof oe=="object"&&"type"in oe){let xe=oe.type;if(xe==="mouse"||xe==="mouse-position"){Q=!0;break}}if(Q)break}}Q&&!ye?(ye=!0,!be&&n&&(be=Wne.register({onMouseMove:Bh,onTouchMove:Lh,onMouseDown:Gh,onTouchStart:Fh,onMouseUp:Uh,onTouchEnd:Oh}))):!Q&&ye&&(ye=!1,be&&(be(),be=null))},Mm=()=>{if(f.length===0)return;let Q=[...f];f=[];for(let oe of Q)bm(oe.id,oe.definition.fragment,oe.parentId,oe.metadata,oe.uniforms,oe.definition,oe.domCanvas);let te=h;h=[];for(let oe of te)oe.kind==="uniform"?wm(oe.id,oe.name,oe.value):nd(oe.id,oe.metadata)},In=(Q,te)=>{if(!lt){lt=Q,Z3(Q),io(`[gpu] renderer stopped (${Q}):`,te);try{Wh()}catch(oe){io("[gpu] cleanup during failure threw:",oe)}if(!wt&&vt){wt=!0;let oe=vt;queueMicrotask(()=>{try{oe(Q,te)}catch(xe){io("[gpu] onUnavailable callback threw:",xe)}})}}},Ih=Q=>{if(qh(Q)){In(Q.reason,Q);return}Rt++,Rt===1&&io("[gpu] render error:",Q),Rt>=Yne&&In("render-failed",Q)},Yh=Q=>{!Q||typeof Q.addEventListener!="function"||(Em(),mt=Q,gt=te=>{try{te.preventDefault()}catch{}let oe=te.error;if(io("[gpu] uncaptured device error:",oe),typeof GPUOutOfMemoryError<"u"&&oe instanceof GPUOutOfMemoryError){In("out-of-memory",oe);return}if(typeof GPUInternalError<"u"&&oe instanceof GPUInternalError){In("gpu-error",oe);return}kt++,kt>=Ine&&In("gpu-error",oe)},Q.addEventListener("uncapturederror",gt))},Em=()=>{if(mt&>)try{mt.removeEventListener("uncapturederror",gt)}catch{}mt=null,gt=null},mO=Q=>{if(!it){it=!0;try{lc()}catch{}if(tt){let te=tt;queueMicrotask(()=>{try{te(Q)}catch(oe){io("[gpu] onDeviceLost callback threw:",oe)}});return}In("device-lost",Q)}},fO=async Q=>{if(Q.context!==void 0)throw new Error("[gpu] initialize({ context }) is not supported \u2014 this renderer is WebGPU-only. Remove the WebGL `context` option.");if(lt)return;let te=J3();if(te){In(te);return}if(i||l)return;let{canvas:oe,resizeTarget:xe,enablePerformanceTracking:he=!1,colorSpace:Pe="p3-linear",toneMapping:qe="linear",gpu:_t,forceFullFrameRate:St=!1,observeElement:os=!0,timeOrigin:Uo}=Q;Uo!=null&&(re=Uo),Ie=he,Y=St,Ne=Pe,Oe=qe,Is(),l=!0,u=new AbortController;let No=u;try{if(He=FS,He(Pe),No.signal.aborted||(n=oe,e=await _ne({device:_t?.device,adapter:_t?.adapter,onDeviceLost:un=>mO(un.message||un.reason||"unknown")}),No.signal.aborted))return;t=e.root,Yh(t.device),z=dp();let mo=t.device.limits?.maxTextureDimension2D;typeof mo=="number"&&mo>0&&(y=mo),o=wne(t),r=D7(t),typeof window<"u"&&(Le=()=>Wh(),window.addEventListener("beforeunload",Le),Ee=()=>{if(R>0&&U>0){let un=R,ld=U;R=0,U=0,cp(un,ld)}},window.addEventListener("resize",Ee,{passive:!0}));let rs=oe.getBoundingClientRect();ie=rs,q=!os||rs.width>0&&rs.height>0&&rs.top<window.innerHeight&&rs.bottom>0&&rs.left<window.innerWidth&&rs.right>0,G=!0;let wr=rs.width>0?rs.width:oe.width,Tn=rs.height>0?rs.height:oe.height,xa=Math.round(wr),aa=Math.round(Tn);if(xa>0&&aa>0){R=xa,U=aa;let{width:un,height:ld}=lp(xa,aa);D=un,k=ld,B=xa,E=aa,O=!0,J0(xa,aa);let{width:mp,height:km}=Gn();oe.width=mp,oe.height=km}else O=!1;if(s=vne(t,oe),os&&typeof ResizeObserver<"u"){let un=xe??oe.parentElement;un?(ge=new ResizeObserver(kh),ge.observe(un)):console.warn("[gpu] no element available for resize observation \u2014 use resize() manually"),typeof IntersectionObserver<"u"&&(Be=new IntersectionObserver(Rh,{threshold:0,rootMargin:"128px"}),Be.observe(oe))}if(No.signal.aborted)return;i=!0,d=!0,Mm(),D>0&&k>0&&id(),G&&ic()}catch(mo){let rs=qh(mo)?mo.reason:"init-failed";l=!1,u===No&&(u=null),In(rs,mo);return}finally{l=!1,u===No&&(u=null)}},Wh=()=>{u&&u.abort(),ge&&(ge.disconnect(),ge=null),Be&&(Be.disconnect(),Be=null),be&&(be(),be=null),Le&&typeof window<"u"&&(window.removeEventListener("beforeunload",Le),Le=null),Ee&&typeof window<"u"&&(window.removeEventListener("resize",Ee),Ee=null),ee!==null&&typeof cancelAnimationFrame=="function"&&(cancelAnimationFrame(ee),ee=null),lc(),Em(),Es?.(),Es=null,typeof document<"u"&&document.fonts?.removeEventListener&&document.fonts.removeEventListener("loadingdone",Os);try{e?.release?.()}catch{}A.clear();for(let Q of[...w])ip(Q);S=null;try{o?.destroy()}catch{}try{e?.createdDevice&&t?.destroy()}catch{}c.clear(),_=null,m.clear(),f=[],h=[],d=!1,Te=null,De=!1,n=null,s=null,o=null,r=null,t=null,e=null,i=!1,l=!1,O=!1,u=null,D=0,k=0,B=0,E=0,T=null,x=!0,q=!1,G=!0,pe=-10,de=-10,se=!1,ye=!1,Ze=null,Je=!1,ut=!1,tt=null,it=!1,kt=0,Rt=0};return{initialize:fO,cleanup:Wh,registerNode:bm,removeNode:ll,updateUniformValue:wm,updateNodeMetadata:nd,isInitialized:()=>i,resize:(Q,te)=>{t&&cp(Q,te)},startAnimation:ic,stopAnimation:lc,renderAndWait:Dh,renderSyntheticFrame:zh,getPerformanceStats:()=>{let Q=Math.max(0,c.size-1),te=S?S.ir.rttPasses.length:0;Pt.updateNodeCounts(Q,te);let oe={render:{calls:S?S.passManager.passCount:0},programs:{length:A.size},memory:{textures:o?o.textureCount:0}};return Pt.getStats(oe)},getLiveDriverValue:(Q,te)=>{let oe=c.get(Q)?.mouseDriverState?.[te];return!oe||oe.liveX===void 0||oe.liveY===void 0?null:{x:oe.liveX,y:oe.liveY}},getLiveScalarValue:(Q,te)=>{let oe=c.get(Q);if(!oe)return null;let xe=oe.metadata.maps?.[te];if(xe?.type==="auto-animate"){let he=oe._liveHandles?.[`_smoothed_${te}`],Pe=he instanceof Jn?he.value:void 0;return typeof Pe=="number"?Pe:null}return xe?.type==="mouse"?oe.mouseDriverState[te]?.liveScalar??null:null},getNodeRegistry:()=>({nodes:new Map(c)}),getRendererType:()=>"webgpu",getInternalRenderer:()=>t?{device:t.device,adapter:e?.adapter,root:t}:null,setForceFullFrameRate:Q=>{let te=Y;return Y=Q,te},beginRecordingResolution:(Q,te,oe)=>{if(!t||Q<=0||te<=0)return()=>{};let xe=z,he=D,Pe=k,qe=B,_t=E,St=R,os=U;return z=oe,nc(Q,te,Q,te),()=>{t&&(z=xe,nc(he,Pe,qe,_t),R=St,U=os)}},setResolutionScale:Q=>{if(!t)return;let te=Math.max(.05,Math.min(Q,1)),oe=Math.max(.01,dp()*te);if(Math.abs(z-oe)<.001)return;z=oe;let xe=B||D,he=E||k;if(xe<=0||he<=0)return;let{width:Pe,height:qe}=lp(xe,he);nc(Pe,qe,xe,he)},setTimeOrigin:Q=>{re=Q},setOnReady:Q=>{Ze=Q,Q&&Je&&queueMicrotask(Q)},setOnDeviceLost:Q=>{tt=Q},setOnUnavailable:Q=>{if(vt=Q,Q&<&&!wt){wt=!0;let te=lt;queueMicrotask(()=>{try{Q(te)}catch(oe){io("[gpu] onUnavailable callback threw:",oe)}})}},getFailureReason:()=>lt,__testing:{needsTransformation:Ei,findChildNodes:Ut,buildFieldInits:Q=>{let te=c.get(Q);return te?Ti(te):null},ensureDriverState:Q=>{let te=c.get(Q);te&&or(te)},stepMouseDrivers:Q=>{pt.deltaTime=Q,Tm()},stepAnimatedTime:Q=>{pt.deltaTime=Q,Sm()},getAnimatedTimeValue:Q=>{let te=c.get(Q);return te?.definition.animatedTime?ec(rr(te)).value:null},writeExtraField:(Q,te,oe)=>{let xe=c.get(Q);xe&&sc(xe,te,oe)},readExtraField:(Q,te)=>{let oe=c.get(Q)?._liveHandles?.[te];return oe instanceof Jn?oe.value:void 0},getNodeRegistry:()=>({nodes:c,rootId:_,parentToChildren:m}),getParentToChildren:()=>m,getPendingRegistrations:()=>[...f],getFrameDiagnostics:()=>({deltaTime:pt.deltaTime,pointerX:pe,pointerY:de,pointerActive:se,globalElapsedTime:H,lastRenderTime:X,isVisible:q,forceFullFrameRate:Y,sharedTimeOrigin:re,animating:Ft.running,mouseListenersNeeded:ye}),computeStructuralHash:ym,isStructuralDirty:()=>x,clearStructuralDirty:()=>{x=!1},setTestReady:Q=>{i=!0,d=!0,Q&&(D=Q.width,k=Q.height,B=Q.width,E=Q.height,O=!0),Mm()}}}}var tc={samplingRate:.05,collectionDuration:5e3,warmupDuration:500,sampleInterval:500,apiEndpoint:"https://shaders.com/api/telemetry"};function Nne(e){return e.includes("Edg/")||e.includes("EdgiOS")?"Edge":e.includes("OPR/")||e.includes("Opera/")?"Opera":e.includes("Chrome/")||e.includes("CriOS")?"Chrome":e.includes("Firefox/")||e.includes("FxiOS")?"Firefox":e.includes("Safari/")&&!e.includes("Chrome")?"Safari":"Other"}function qne(e){return/iPad|Tablet|PlayBook/i.test(e)||/Android/i.test(e)&&!/Mobile/i.test(e)?"tablet":/Mobile|Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(e)?"mobile":"desktop"}function Xne(){if(typeof window>"u"||typeof navigator>"u")return{domain:"unknown",browserFamily:"unknown",deviceType:"unknown"};let e=navigator.userAgent;return{domain:window.location.hostname,browserFamily:Nne(e),deviceType:qne(e)}}var Hne=class{renderer;version;sourceType;sessionId;frameSamples=[];sampleInterval=null;stopped=!1;constructor(e,t,s){this.renderer=e,this.version=t,this.sourceType=s,this.sessionId=`tel_${Date.now()}_${Math.random().toString(36).substring(2,9)}`}stop(){this.stopped=!0,this.sampleInterval&&(clearInterval(this.sampleInterval),this.sampleInterval=null)}async start(){try{if(await this.sleep(tc.warmupDuration),this.stopped||(this.sampleInterval=setInterval(()=>{if(!this.stopped)try{let e=this.renderer.getPerformanceStats();this.frameSamples.push(e)}catch(e){io("Telemetry sampling error:",e)}},tc.sampleInterval),await this.sleep(tc.collectionDuration-tc.warmupDuration),this.stopped))return;if(this.sampleInterval&&(clearInterval(this.sampleInterval),this.sampleInterval=null),!this.stopped&&this.frameSamples.length>=5){let e=this.aggregateData();await this.sendTelemetry(e)}}catch(e){io("Telemetry collection error:",e)}}sleep(e){return new Promise(t=>setTimeout(t,e))}aggregateData(){let e=this.aggregatePerformance(),t=this.detectRendererType(),s=this.extractComponents(),o=Xne();return{sessionId:this.sessionId,timestamp:Date.now(),collectionDuration:tc.collectionDuration,version:this.version,sourceType:this.sourceType,performance:e,renderer:t,components:s,environment:o}}aggregatePerformance(){if(this.frameSamples.length===0)return{fps:0,frameTime:{avg:0,min:0,max:0,p99:0},jankPercent:0,budgetUsed:0};let e=this.frameSamples.map(_=>_.avgFrameTime),t=this.frameSamples.map(_=>_.jankPercent),s=this.frameSamples.map(_=>_.budgetUsed),o=this.frameSamples.map(_=>_.fps),r=this.calculateMedian(o),n=this.calculateMean(e),i=Math.min(...e),l=Math.max(...e),d=this.calculatePercentile(e,99),u=this.calculateMean(t),c=this.calculateMean(s);return{fps:Math.round(r*10)/10,frameTime:{avg:Math.round(n*10)/10,min:Math.round(i*10)/10,max:Math.round(l*10)/10,p99:Math.round(d*10)/10},jankPercent:Math.round(u*10)/10,budgetUsed:Math.round(c*10)/10}}detectRendererType(){let e=this.frameSamples[this.frameSamples.length-1];return{type:this.renderer.getRendererType?.()||"webgl",drawCalls:e?.drawCalls??null,textureCount:e?.textureCount??null}}extractComponents(){try{let e=this.renderer.getNodeRegistry(),t=[];for(let[s,o]of e.nodes)o.parentId!==null&&t.push({name:o.componentName,requiresRTT:o.requiresRTT,renderOrder:o.metadata.renderOrder});return t.sort((s,o)=>s.renderOrder-o.renderOrder)}catch(e){return io("Failed to extract components:",e),[]}}async sendTelemetry(e){try{let t=await fetch(tc.apiEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});t.ok||Wa("Telemetry send failed:",t.status,t.statusText)}catch(t){io("Telemetry send error:",t)}}calculateMean(e){return e.length===0?0:e.reduce((t,s)=>t+s,0)/e.length}calculateMedian(e){if(e.length===0)return 0;let t=[...e].sort((o,r)=>o-r),s=Math.floor(t.length/2);return t.length%2===0?(t[s-1]+t[s])/2:t[s]}calculatePercentile(e,t){if(e.length===0)return 0;let s=[...e].sort((r,n)=>r-n),o=Math.ceil(t/100*s.length)-1;return s[Math.max(0,o)]}};function $ne(e=!1,t=!1){return e||typeof navigator<"u"&&navigator.doNotTrack==="1"?!1:t?!0:Math.random()<tc.samplingRate}function cO(e,t,s=!1,o=!1){return $ne(s,o)?new Hne(e,t,o?"preview":"shader"):null}function uO(){if(typeof window>"u"||!window.location)return!1;let e=window.location.hostname;return!e.includes("shaders.com")&&e!=="localhost"&&e!=="127.0.0.1"}function H3(e){if(typeof e!="object"||e===null||!("type"in e))return!1;let t=e;return t.type==="map"||t.type==="mouse"||t.type==="mouse-position"||t.type==="auto-animate"}var pO=new Set(["opacity","blendMode","visible","transform","boundingBox","maskSource","maskType","flow","absolute"]);async function $3(e,t,s){let o=new Map;if(Sh().forEach(y=>{o.set(y.definition.name,y.definition);for(let R of y.definition.deprecatedNames??[])o.set(R,y.definition)}),!e.style.width||!e.style.height){let y=e.getBoundingClientRect(),R=y.width>0?y.width:e.width,U=y.height>0?y.height:e.height;R>0&&!e.style.width&&(e.style.width=`${R}px`),U>0&&!e.style.height&&(e.style.height=`${U}px`)}function r(y){return{...y,props:y.props?{...y.props}:void 0,children:y.children?.map(r)}}let n={...t,components:t.components.map(r)},i=null,l=!1,d=!1,u=3,c=6e4,_=0,m=0,f=null;function h(y){try{s?.onError?.(y)}catch(R){io("[createShader] onError callback threw:",R)}}let A=!1;function w(y){A||(A=!0,f=y,h(y))}function S(y,R,U,O,I){let N=o.get(U.type);if(!N){console.warn(`[createShader] Unknown component type: ${U.type}`);return}let G=U.id||`${U.type}_${Date.now()}_${Math.random().toString(36).slice(2,9)}`,q={};for(let[H,re]of Object.entries(U.props||{}))!pO.has(H)&&Object.prototype.hasOwnProperty.call(N.props,H)&&H3(re)&&(q[H]=re);let Y=ox(N,Object.fromEntries(Object.entries(N.props).map(([H,re])=>{let ee=U.props?.[H]!==void 0?U.props[H]:re.default;return[H,H3(ee)?re.default:ee]})),G),X={blendMode:U.props?.blendMode||"normal",opacity:U.props?.opacity,visible:U.props?.visible,renderOrder:I,id:U.id,maps:Object.keys(q).length>0?{...q}:void 0,mask:U.props?.maskSource?{source:U.props.maskSource,type:U.props.maskType||"alpha"}:void 0,transform:U.props?.transform?{offsetX:0,offsetY:0,rotation:0,scale:1,anchorX:.5,anchorY:.5,edges:"transparent",...U.props.transform}:void 0,boundingBox:N1(U.props?.boundingBox),flow:U.props?.flow,absolute:U.props?.absolute};y.registerNode(G,N.fragment,O,X,Y,N),R.set(G,{componentDef:N,uniforms:Y,nodeId:G,component:U,currentMaps:{...q}}),U.children?.forEach((H,re)=>{S(y,R,H,G,re)})}async function T(){let y=dO(),R=new Map;s?.onReady&&y.setOnReady(s.onReady),y.setOnUnavailable(I=>{l||w(I)}),await y.initialize({canvas:e,resizeTarget:e,enablePerformanceTracking:s?.enablePerformanceTracking||!1,colorSpace:s?.colorSpace,toneMapping:s?.toneMapping,observeElement:s?.observeElement,gpu:s?.gpu});let U={renderer:y,nodeEntryMap:R,telemetryCollector:null,telemetryStartTimeout:null};y.setOnDeviceLost(I=>{if(l||d||f||i!==null&&i!==U)return;d=!0,h(I);let N=Date.now();if(N-m>c&&(_=0),m=N,++_>u){x(U),i=null,d=!1,w("unrecoverable");return}(async()=>{try{if(x(U),i=null,l)return;let G=await T();if(l){x(G);return}i=G}catch(G){io("[createShader] rebuild after device loss failed:",G),w("rebuild_failed")}finally{d=!1}})()});let O="shader-root";if(y.registerNode(O,Pf.fragment,null,null,{},Pf),n.components.forEach((I,N)=>{S(y,R,I,O,N)}),uO()){let N=0,G=()=>{if(l||f||i!==U||++N>40){U.telemetryStartTimeout=null;return}y.getPerformanceStats().fps>0?(U.telemetryCollector=cO(y,"3.1.462",s?.disableTelemetry||!1,!1),U.telemetryCollector&&U.telemetryCollector.start(),U.telemetryStartTimeout=null):U.telemetryStartTimeout=setTimeout(G,500)};U.telemetryStartTimeout=setTimeout(G,500)}return U}function x(y){if(y.telemetryCollector){try{y.telemetryCollector.stop()}catch{}y.telemetryCollector=null}y.telemetryStartTimeout!==null&&(clearTimeout(y.telemetryStartTimeout),y.telemetryStartTimeout=null);try{y.renderer.cleanup()}catch{}}i=await T();function D(y,R){if(!i)return;let{renderer:U,nodeEntryMap:O}=i,I=O.get(y);if(!I){console.warn(`[createShader] Component ID not found: ${y}`);return}I.component.props||(I.component.props={});let N=I.component.props;for(let[G,q]of Object.entries(R))if(pO.has(G))if(G==="maskSource")U.updateNodeMetadata(I.nodeId,{mask:q?{source:q,type:R.maskType||N.maskType||"alpha"}:void 0}),N.maskSource=q,"maskType"in R&&(N.maskType=R.maskType);else{if(G==="maskType")continue;G==="transform"?(U.updateNodeMetadata(I.nodeId,{transform:q}),N.transform=q):G==="boundingBox"?(U.updateNodeMetadata(I.nodeId,{boundingBox:N1(q)}),N.boundingBox=q):(U.updateNodeMetadata(I.nodeId,{[G]:q}),N[G]=q)}else H3(q)?Object.prototype.hasOwnProperty.call(I.componentDef.props,G)?(I.currentMaps[G]=q,U.updateNodeMetadata(I.nodeId,{maps:{...I.currentMaps}}),N[G]=q):console.warn(`[createShader] Ignoring PropDriver for unknown prop "${G}" on ${I.component.type}`):(G in I.currentMaps&&(delete I.currentMaps[G],U.updateNodeMetadata(I.nodeId,{maps:Object.keys(I.currentMaps).length>0?{...I.currentMaps}:void 0})),Object.prototype.hasOwnProperty.call(I.componentDef.props,G)&&(U.updateUniformValue(I.nodeId,G,q),N[G]=q))}function k(y,R){let U=e.getBoundingClientRect(),O=y??(U.width>0?U.width:e.width),I=R??(U.height>0?U.height:e.height);O>0&&I>0&&(e.style.width=`${O}px`,e.style.height=`${I}px`,i&&i.renderer.resize(O,I))}function B(){l=!0,i&&(x(i),i=null)}function E(){i&&i.renderer.stopAnimation()}function z(){i&&i.renderer.startAnimation()}return{update:D,resize:k,pause:E,resume:z,destroy:B,getFailureReason:()=>f}}var jne="shaders-preview-key";function Kne(e,t){let s=new TextEncoder().encode(t),o=new Uint8Array(e.length);for(let r=0;r<e.length;r++)o[r]=e[r]^s[r%s.length];return o}function _O(e){try{let t=atob(e),s=new Uint8Array(t.length);for(let i=0;i<t.length;i++)s[i]=t.charCodeAt(i);let o=Kne(s,jne),r=new TextDecoder().decode(o),n=JSON.parse(r);if(typeof n!="object"||n===null||Array.isArray(n))throw new Error("unexpected shape");return n}catch{throw new Error("Failed to decode preview definition: invalid data")}}var Qne="https://shaders.com",Zne="Unlock your Shaders Pro license",Jne="https://shaders.com/dashboard?pricing=true",eie=new Set(["break","case","catch","class","const","continue","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","new","return","super","switch","this","throw","try","typeof","var","void","while","with","yield"]);function tie(e,t){let s=e.replace(/[^A-Za-z0-9]+/g," ").trim();if(!s)return t;let o=s.split(/\s+/).map((n,i)=>i===0?n.charAt(0).toLowerCase()+n.slice(1):n.charAt(0).toUpperCase()+n.slice(1)).join(""),r=/^[A-Za-z_$]/.test(o)?o:`_${o}`;return eie.has(r)?`_${r}`:r}function sie(e){let t=new Set(["style"]),s=new Map;return e?.length&&e.forEach((o,r)=>{if(!o.targets?.length)return;let n=tie(o.label,`keyProp${r}`),i=n,l=1;for(;t.has(i);)l++,i=`${n}${l}`;t.add(i),s.set(i,o)}),s}function j3(e,t){for(let s of t){if(s.id===e)return s;let o=s.children;if(o?.length){let r=j3(e,o);if(r)return r}}return null}function oie(e,t,s){if(t)for(let[o,r]of Object.entries(t)){let n=s.get(o);if(n)for(let i of n.targets??[]){let l=j3(i.component_id,e);l?.props&&i.prop in l.props&&(l.props[i.prop]=r)}}}async function rie(e,t){if(!t.shader&&!t.presetId||t.shader&&t.presetId)throw new Error("Exactly one of shader (preview token) or presetId must be provided");let s=t.apiBaseUrl||Qne,o=t.presetId&&t.version?`?version=${encodeURIComponent(t.version)}`:"",r=t.shader?`${s}/api/preview/shader/${encodeURIComponent(t.shader)}`:`${s}/api/preview/preset/${encodeURIComponent(t.presetId)}${o}`,n=await fetch(r);if(!n.ok)throw new Error(`Failed to fetch preview: ${n.status} ${n.statusText}`);let i=await n.json(),l=i.preset??i.shader;if(!l?.definition||typeof l.definition!="string")throw new Error("Preview response missing encoded definition");let d=_O(l.definition),u=Array.isArray(l.key_props)?l.key_props:null,c=sie(u),_=new Map;for(let T of c.values())for(let x of T.targets??[]){let D=j3(x.component_id,d.components);D?.props&&x.prop in D.props&&_.set(`${x.component_id}:${x.prop}`,D.props[x.prop])}oie(d.components,t.configuration,c);let m=await $3(e,d,{isPreview:!0,enablePerformanceTracking:!0}),{overlay:f,savedPosition:h,parentEl:A}=aie(e),w=m.destroy.bind(m),S=m;return S.destroy=()=>{A&&h!==void 0&&(A.style.position=h),f.remove(),w()},S.setConfiguration=T=>{if(u?.length)for(let[x,D]of c){let k=Object.prototype.hasOwnProperty.call(T,x)&&T[x]!==void 0;for(let B of D.targets??[]){let E=k?T[x]:_.get(`${B.component_id}:${B.prop}`);E!==void 0&&m.update(B.component_id,{[B.prop]:E})}}},S}function aie(e){let t=e.parentElement,s;t&&getComputedStyle(t).position==="static"&&(s=t.style.position,t.style.position="relative");let o=document.createElement("a");return o.href=Jne,o.target="_blank",o.rel="noopener noreferrer",o.textContent=Zne,Object.assign(o.style,{position:"absolute",bottom:"8px",right:"12px",fontSize:"11px",fontFamily:"system-ui, -apple-system, sans-serif",color:"rgba(255, 255, 255, 0.5)",textDecoration:"none",zIndex:"10",pointerEvents:"auto",transition:"color 0.2s ease"}),o.addEventListener("mouseenter",()=>{o.style.color="rgba(255, 255, 255, 0.8)"}),o.addEventListener("mouseleave",()=>{o.style.color="rgba(255, 255, 255, 0.5)"}),t&&t.appendChild(o),{overlay:o,savedPosition:s,parentEl:t}}async function nie(e){if(typeof navigator>"u"||!navigator.gpu)return null;try{let t=await navigator.gpu.requestAdapter({powerPreference:e?.powerPreference??"high-performance"});return t?{device:await t.requestDevice({requiredFeatures:[...t.features]}),adapter:t}:null}catch(t){return Wa("[shaders] createSharedDevice failed; callers should fall back to per-instance device:",t),null}}export{rie as createPreview,$3 as createShader,nie as createSharedDevice,Hh as getWebGPUSupport,Dm as isShadersDebug,Xh as isWebGPUSupported,Q3 as setShadersDebug};
|
package/dist/js/createShader.js
CHANGED
|
@@ -184,7 +184,7 @@ async function createShader(canvas, preset, options) {
|
|
|
184
184
|
return;
|
|
185
185
|
}
|
|
186
186
|
if (renderer.getPerformanceStats().fps > 0) {
|
|
187
|
-
state.telemetryCollector = startTelemetry(renderer, "3.1.
|
|
187
|
+
state.telemetryCollector = startTelemetry(renderer, "3.1.462", options?.disableTelemetry || false, false);
|
|
188
188
|
if (state.telemetryCollector) state.telemetryCollector.start();
|
|
189
189
|
state.telemetryStartTimeout = null;
|
|
190
190
|
} else state.telemetryStartTimeout = setTimeout(checkRendering, 500);
|
package/dist/react/Shader.js
CHANGED
|
@@ -93,7 +93,7 @@ const Shader = ({ children, disableTelemetry = false, colorSpace = "p3-linear",
|
|
|
93
93
|
return;
|
|
94
94
|
}
|
|
95
95
|
if (rendererRef.current.getPerformanceStats().fps > 0) {
|
|
96
|
-
telemetryCollectorRef.current = startTelemetry(rendererRef.current, "3.1.
|
|
96
|
+
telemetryCollectorRef.current = startTelemetry(rendererRef.current, "3.1.462", disableTelemetry, isPreview);
|
|
97
97
|
if (telemetryCollectorRef.current) telemetryCollectorRef.current.start();
|
|
98
98
|
telemetryStartTimeoutRef.current = null;
|
|
99
99
|
} else telemetryStartTimeoutRef.current = window.setTimeout(checkRendering, 500);
|