mirage-engine 0.3.16 → 0.3.17

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.
@@ -78,18 +78,19 @@ const Ae = {
78
78
  }
79
79
  }, ue = 0, re = 1, he = 2, Pe = 4, fe = 8, we = 16;
80
80
  function He(s) {
81
- const e = s.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
81
+ const e = s.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);
82
82
  return e ? {
83
83
  r: parseInt(e[1]) / 255,
84
84
  g: parseInt(e[2]) / 255,
85
- b: parseInt(e[3]) / 255
86
- } : { r: 1, g: 1, b: 1 };
85
+ b: parseInt(e[3]) / 255,
86
+ a: e[4] !== void 0 ? parseFloat(e[4]) : 1
87
+ } : { r: 1, g: 1, b: 1, a: 1 };
87
88
  }
88
89
  function Ge(s) {
89
90
  const e = {};
90
- if (s.opacity && (e.opacity = parseFloat(s.opacity)), s.backgroundColor && s.backgroundColor !== "rgba(0, 0, 0, 0)") {
91
+ if (s.opacity && (e.opacity = parseFloat(s.opacity)), s.backgroundColor) {
91
92
  const t = He(s.backgroundColor);
92
- e.backgroundColor = [t.r, t.g, t.b];
93
+ e.backgroundColor = [t.r, t.g, t.b, t.a];
93
94
  }
94
95
  if (s.backgroundImage ? e.backgroundImage = s.backgroundImage : s.background && (e.backgroundImage = s.background), s.boxShadow && (e.boxShadow = s.boxShadow), s.borderRadius && (e.borderRadius = parseFloat(s.borderRadius)), s.width && (e.width = parseFloat(s.width)), s.height && (e.height = parseFloat(s.height)), s.transform && s.transform !== "none") {
95
96
  const t = new DOMMatrix(s.transform);
@@ -642,7 +643,7 @@ function ye(s, e) {
642
643
  }
643
644
  if (e.borderWidth !== void 0 && (s.uniforms.uBorderWidth.value = e.borderWidth), e.backgroundColor !== void 0)
644
645
  if (Array.isArray(e.backgroundColor)) {
645
- const n = s.uniforms.uBgColor.value.w;
646
+ const n = e.backgroundColor[3] !== void 0 ? e.backgroundColor[3] : s.uniforms.uBgColor.value.w;
646
647
  s.uniforms.uBgColor.value.set(
647
648
  e.backgroundColor[0],
648
649
  e.backgroundColor[1],
@@ -1,4 +1,4 @@
1
- (function(I,D){typeof exports=="object"&&typeof module!="undefined"?D(exports,require("three")):typeof define=="function"&&define.amd?define(["exports","three"],D):(I=typeof globalThis!="undefined"?globalThis:I||self,D(I.MirageEngine={},I.THREE))})(this,function(I,D){"use strict";var ht=Object.defineProperty,dt=Object.defineProperties;var ut=Object.getOwnPropertyDescriptors;var Fe=Object.getOwnPropertySymbols;var ft=Object.prototype.hasOwnProperty,gt=Object.prototype.propertyIsEnumerable;var Ce=(I,D,B)=>D in I?ht(I,D,{enumerable:!0,configurable:!0,writable:!0,value:B}):I[D]=B,ne=(I,D)=>{for(var B in D||(D={}))ft.call(D,B)&&Ce(I,B,D[B]);if(Fe)for(var B of Fe(D))gt.call(D,B)&&Ce(I,B,D[B]);return I},_e=(I,D)=>dt(I,ut(D));var u=(I,D,B)=>(Ce(I,typeof D!="symbol"?D+"":D,B),B);var ze=(I,D,B)=>new Promise((v,ue)=>{var Z=F=>{try{_(B.next(F))}catch(Y){ue(Y)}},pe=F=>{try{_(B.throw(F))}catch(Y){ue(Y)}},_=F=>F.done?v(F.value):Promise.resolve(F.value).then(Z,pe);_((B=B.apply(I,D)).next())});function B(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const v=B(D),ue={INCLUDE_TREE:"include-tree",EXCLUDE_TREE:"exclude-tree",INCLUDE_SELF:"include-self",EXCLUDE_SELF:"exclude-self",END:"end"},Z={NAME:"data-mirage-dom",KEY:"mirageDom",VALUES:{HIDE:"hide",SHOW:"show"}},pe={TRAVELER:"traveler",NATIVE:"native",CAPTURE_1:"1",CAPTURE_2:"2",CAPTURE_3:"3",CAPTURE_4:"4",CAPTURE_5:"5",CAPTURE_6:"6",CAPTURE_7:"7",CAPTURE_8:"8",CAPTURE_9:"9",CAPTURE_10:"10"},_={NAME:"data-mirage-travel",KEY:"mirageTravel",VALUES:pe,MAX_LAYERS:Object.keys(pe).length-1},F={NAME:"data-mirage-filter",KEY:"mirageFilter",VALUES:ue},Y={NAME:"data-mirage-select",KEY:"mirageSelect",VALUES:ue},Ne={NAME:"data-mirage-shader",KEY:"mirageShader"},Te={NAME:"data-mirage-sandwich",KEY:"mirageSandwich",VALUES:{FRONT:"front"}},me=0,se=1,fe=2,Xe=4,ve=8,ye=16;function Ve(n){const e=n.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);return e?{r:parseInt(e[1])/255,g:parseInt(e[2])/255,b:parseInt(e[3])/255}:{r:1,g:1,b:1}}function Ye(n){const e={};if(n.opacity&&(e.opacity=parseFloat(n.opacity)),n.backgroundColor&&n.backgroundColor!=="rgba(0, 0, 0, 0)"){const t=Ve(n.backgroundColor);e.backgroundColor=[t.r,t.g,t.b]}if(n.backgroundImage?e.backgroundImage=n.backgroundImage:n.background&&(e.backgroundImage=n.background),n.boxShadow&&(e.boxShadow=n.boxShadow),n.borderRadius&&(e.borderRadius=parseFloat(n.borderRadius)),n.width&&(e.width=parseFloat(n.width)),n.height&&(e.height=parseFloat(n.height)),n.transform&&n.transform!=="none"){const t=new DOMMatrix(n.transform);e.x=t.m41,e.y=t.m42,e.z=t.m43}return e}class Re{constructor(e,t){u(this,"target");u(this,"observer");u(this,"pendingDeletions",new Set);u(this,"pendingStyles",new Map);u(this,"isDomDirty",!1);u(this,"isRunning",!1);u(this,"pendingMask",me);u(this,"mutationTimer",null);u(this,"cssTimer",null);u(this,"resizeConfig");u(this,"resizeTimer",null);u(this,"isResizing",!1);u(this,"lastScrollX",0);u(this,"lastScrollY",0);u(this,"scrollTimer",null);u(this,"onBeforeRender",new Set);u(this,"onLayoutChange",new Set);u(this,"onStyleChange",new Set);u(this,"onScrollChange",new Set);u(this,"onRender",new Set);u(this,"onTransitionFinished",e=>{this.target.contains(e.target)&&this.mutationTimer===null&&(this.cssTimer&&clearTimeout(this.cssTimer),this.pendingStyles.size==0&&(this.pendingMask|=se|fe,this.cssTimer=window.setTimeout(()=>{this.isDomDirty=!0,this.cssTimer=null},50)))});u(this,"onWindowResize",()=>{if(!this.resizeConfig.enabled){this.isDomDirty=!0;return}this.isResizing||(this.isResizing=!0,this.resizeConfig.onStart&&this.resizeConfig.onStart()),this.resizeTimer&&clearTimeout(this.resizeTimer),this.resizeTimer=window.setTimeout(()=>{this.isDomDirty=!0,this.resizeConfig.onEnd&&this.resizeConfig.onEnd(),this.isResizing=!1,this.resizeTimer=null},this.resizeConfig.delay)});u(this,"renderLoop",()=>{if(!this.isRunning)return;this.onBeforeRender.forEach(r=>r()),this.isDomDirty&&(this.isDomDirty=!1,this.onLayoutChange.forEach(r=>r(this.pendingMask,this.pendingDeletions)),this.pendingDeletions.clear(),this.pendingMask=me);const e=window.scrollX,t=window.scrollY;(e!==this.lastScrollX||t!==this.lastScrollY)&&(this.onScrollChange.forEach(r=>r(e,t)),this.lastScrollX=e,this.lastScrollY=t,this.scrollTimer&&clearTimeout(this.scrollTimer),this.scrollTimer=window.setTimeout(()=>{this.pendingMask|=se,this.isDomDirty=!0,this.scrollTimer=null},150)),this.pendingStyles.size>0&&(this.onStyleChange.forEach(r=>r(this.pendingStyles)),this.pendingStyles.clear()),this.onRender.forEach(r=>r()),requestAnimationFrame(this.renderLoop)});var i,c;this.target=e;const r=(i=t.resizeDebounce)!=null?i:!0;r===!1?this.resizeConfig={enabled:!1,delay:0}:r===!0?this.resizeConfig={enabled:!0,delay:150}:this.resizeConfig={enabled:!0,delay:(c=r.delay)!=null?c:150,onStart:r.onStart,onEnd:r.onEnd},this.observer=new MutationObserver(s=>{let o=me;for(const a of s)if(a.type==="childList")o|=ve,a.removedNodes.length>0&&a.removedNodes.forEach(l=>{l instanceof HTMLElement&&this.pendingDeletions.add(l)});else if(a.type==="attributes")if(a.attributeName==="style"){o|=se|fe;const l=a.target,d=Ye(l.style);this.pendingStyles.set(l,d)}else a.attributeName==="class"?o|=se|fe:a.attributeName&&a.attributeName.startsWith("data-")&&(o|=se|fe,a.attributeName.startsWith("data-mirage")&&(o|=ve));else a.type==="characterData"&&(o|=ye|se);if(o!==me){if(this.pendingMask|=o,o&ve){this.clearTimers(),this.isDomDirty=!0;return}this.mutationTimer&&clearTimeout(this.mutationTimer),this.mutationTimer=window.setTimeout(()=>{this.mutationTimer=null,this.isDomDirty=!0},200)}})}start(){this.isRunning||(this.isRunning=!0,this.observer.observe(this.target,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),this.target.addEventListener("transitionend",this.onTransitionFinished),this.target.addEventListener("animationend",this.onTransitionFinished),window.addEventListener("resize",this.onWindowResize),this.isDomDirty=!0,this.lastScrollX=window.scrollX,this.lastScrollY=window.scrollY,this.renderLoop())}stop(){this.isRunning=!1,this.observer.disconnect(),this.clearTimers(),this.target.removeEventListener("transitionend",this.onTransitionFinished),this.target.removeEventListener("animationend",this.onTransitionFinished),window.removeEventListener("resize",this.onWindowResize)}clearTimers(){this.mutationTimer&&(clearTimeout(this.mutationTimer),this.mutationTimer=null),this.cssTimer&&(clearTimeout(this.cssTimer),this.cssTimer=null),this.scrollTimer&&(clearTimeout(this.scrollTimer),this.scrollTimer=null)}}const j=1,oe=2,N={BASE:0,SELECTED:1,getCaptureLayer:n=>31-n,HIDDEN:31},Le=Object.values(F.VALUES);class Me{static getBaseline(e){if(this.cache.has(e))return this.cache.get(e);const t=this.calculateBaselineFromDOM(e);return this.cache.set(e,t),t}static calculateBaselineFromDOM(e){if(typeof document=="undefined")return 0;const t=document.createElement("div"),r=document.createElement("span"),i=document.createElement("img");t.style.visibility="hidden",t.style.position="absolute",t.style.top="0px",t.style.left="0px",t.style.font=e,t.style.margin="0",t.style.padding="0",t.style.border="none",r.style.margin="0",r.style.padding="0",r.style.border="none",r.style.lineHeight="normal",i.width=1,i.height=1,i.style.verticalAlign="baseline",r.appendChild(document.createTextNode("Hidden Text")),t.appendChild(r),t.appendChild(i),document.body.appendChild(t);const c=i.offsetTop-r.offsetTop;return document.body.removeChild(t),c}}u(Me,"cache",new Map);class Pe extends v.MeshBasicMaterial{constructor(t,r,i,c,s=2){super({transparent:!0,side:v.FrontSide,color:16777215});u(this,"canvas");u(this,"ctx");u(this,"qualityFactor");if(this.canvas=document.createElement("canvas"),this.ctx=this.canvas.getContext("2d"),!this.ctx)throw new Error("[Mirage] Failed to create canvas context");this.qualityFactor=s,this.map=new v.CanvasTexture(this.canvas),this.map.colorSpace=v.LinearSRGBColorSpace,this.map.minFilter=v.LinearFilter,this.map.magFilter=v.LinearFilter,this.updateText(t,r,i,c)}wrapText(t,r){const i=t.split(`
1
+ (function(I,D){typeof exports=="object"&&typeof module!="undefined"?D(exports,require("three")):typeof define=="function"&&define.amd?define(["exports","three"],D):(I=typeof globalThis!="undefined"?globalThis:I||self,D(I.MirageEngine={},I.THREE))})(this,function(I,D){"use strict";var ht=Object.defineProperty,dt=Object.defineProperties;var ut=Object.getOwnPropertyDescriptors;var Fe=Object.getOwnPropertySymbols;var ft=Object.prototype.hasOwnProperty,gt=Object.prototype.propertyIsEnumerable;var Ce=(I,D,B)=>D in I?ht(I,D,{enumerable:!0,configurable:!0,writable:!0,value:B}):I[D]=B,ne=(I,D)=>{for(var B in D||(D={}))ft.call(D,B)&&Ce(I,B,D[B]);if(Fe)for(var B of Fe(D))gt.call(D,B)&&Ce(I,B,D[B]);return I},_e=(I,D)=>dt(I,ut(D));var u=(I,D,B)=>(Ce(I,typeof D!="symbol"?D+"":D,B),B);var ze=(I,D,B)=>new Promise((v,ue)=>{var Z=F=>{try{_(B.next(F))}catch(Y){ue(Y)}},pe=F=>{try{_(B.throw(F))}catch(Y){ue(Y)}},_=F=>F.done?v(F.value):Promise.resolve(F.value).then(Z,pe);_((B=B.apply(I,D)).next())});function B(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const v=B(D),ue={INCLUDE_TREE:"include-tree",EXCLUDE_TREE:"exclude-tree",INCLUDE_SELF:"include-self",EXCLUDE_SELF:"exclude-self",END:"end"},Z={NAME:"data-mirage-dom",KEY:"mirageDom",VALUES:{HIDE:"hide",SHOW:"show"}},pe={TRAVELER:"traveler",NATIVE:"native",CAPTURE_1:"1",CAPTURE_2:"2",CAPTURE_3:"3",CAPTURE_4:"4",CAPTURE_5:"5",CAPTURE_6:"6",CAPTURE_7:"7",CAPTURE_8:"8",CAPTURE_9:"9",CAPTURE_10:"10"},_={NAME:"data-mirage-travel",KEY:"mirageTravel",VALUES:pe,MAX_LAYERS:Object.keys(pe).length-1},F={NAME:"data-mirage-filter",KEY:"mirageFilter",VALUES:ue},Y={NAME:"data-mirage-select",KEY:"mirageSelect",VALUES:ue},Ne={NAME:"data-mirage-shader",KEY:"mirageShader"},Te={NAME:"data-mirage-sandwich",KEY:"mirageSandwich",VALUES:{FRONT:"front"}},me=0,se=1,fe=2,Xe=4,ve=8,ye=16;function Ve(n){const e=n.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);return e?{r:parseInt(e[1])/255,g:parseInt(e[2])/255,b:parseInt(e[3])/255,a:e[4]!==void 0?parseFloat(e[4]):1}:{r:1,g:1,b:1,a:1}}function Ye(n){const e={};if(n.opacity&&(e.opacity=parseFloat(n.opacity)),n.backgroundColor){const t=Ve(n.backgroundColor);e.backgroundColor=[t.r,t.g,t.b,t.a]}if(n.backgroundImage?e.backgroundImage=n.backgroundImage:n.background&&(e.backgroundImage=n.background),n.boxShadow&&(e.boxShadow=n.boxShadow),n.borderRadius&&(e.borderRadius=parseFloat(n.borderRadius)),n.width&&(e.width=parseFloat(n.width)),n.height&&(e.height=parseFloat(n.height)),n.transform&&n.transform!=="none"){const t=new DOMMatrix(n.transform);e.x=t.m41,e.y=t.m42,e.z=t.m43}return e}class Re{constructor(e,t){u(this,"target");u(this,"observer");u(this,"pendingDeletions",new Set);u(this,"pendingStyles",new Map);u(this,"isDomDirty",!1);u(this,"isRunning",!1);u(this,"pendingMask",me);u(this,"mutationTimer",null);u(this,"cssTimer",null);u(this,"resizeConfig");u(this,"resizeTimer",null);u(this,"isResizing",!1);u(this,"lastScrollX",0);u(this,"lastScrollY",0);u(this,"scrollTimer",null);u(this,"onBeforeRender",new Set);u(this,"onLayoutChange",new Set);u(this,"onStyleChange",new Set);u(this,"onScrollChange",new Set);u(this,"onRender",new Set);u(this,"onTransitionFinished",e=>{this.target.contains(e.target)&&this.mutationTimer===null&&(this.cssTimer&&clearTimeout(this.cssTimer),this.pendingStyles.size==0&&(this.pendingMask|=se|fe,this.cssTimer=window.setTimeout(()=>{this.isDomDirty=!0,this.cssTimer=null},50)))});u(this,"onWindowResize",()=>{if(!this.resizeConfig.enabled){this.isDomDirty=!0;return}this.isResizing||(this.isResizing=!0,this.resizeConfig.onStart&&this.resizeConfig.onStart()),this.resizeTimer&&clearTimeout(this.resizeTimer),this.resizeTimer=window.setTimeout(()=>{this.isDomDirty=!0,this.resizeConfig.onEnd&&this.resizeConfig.onEnd(),this.isResizing=!1,this.resizeTimer=null},this.resizeConfig.delay)});u(this,"renderLoop",()=>{if(!this.isRunning)return;this.onBeforeRender.forEach(r=>r()),this.isDomDirty&&(this.isDomDirty=!1,this.onLayoutChange.forEach(r=>r(this.pendingMask,this.pendingDeletions)),this.pendingDeletions.clear(),this.pendingMask=me);const e=window.scrollX,t=window.scrollY;(e!==this.lastScrollX||t!==this.lastScrollY)&&(this.onScrollChange.forEach(r=>r(e,t)),this.lastScrollX=e,this.lastScrollY=t,this.scrollTimer&&clearTimeout(this.scrollTimer),this.scrollTimer=window.setTimeout(()=>{this.pendingMask|=se,this.isDomDirty=!0,this.scrollTimer=null},150)),this.pendingStyles.size>0&&(this.onStyleChange.forEach(r=>r(this.pendingStyles)),this.pendingStyles.clear()),this.onRender.forEach(r=>r()),requestAnimationFrame(this.renderLoop)});var i,c;this.target=e;const r=(i=t.resizeDebounce)!=null?i:!0;r===!1?this.resizeConfig={enabled:!1,delay:0}:r===!0?this.resizeConfig={enabled:!0,delay:150}:this.resizeConfig={enabled:!0,delay:(c=r.delay)!=null?c:150,onStart:r.onStart,onEnd:r.onEnd},this.observer=new MutationObserver(s=>{let o=me;for(const a of s)if(a.type==="childList")o|=ve,a.removedNodes.length>0&&a.removedNodes.forEach(l=>{l instanceof HTMLElement&&this.pendingDeletions.add(l)});else if(a.type==="attributes")if(a.attributeName==="style"){o|=se|fe;const l=a.target,d=Ye(l.style);this.pendingStyles.set(l,d)}else a.attributeName==="class"?o|=se|fe:a.attributeName&&a.attributeName.startsWith("data-")&&(o|=se|fe,a.attributeName.startsWith("data-mirage")&&(o|=ve));else a.type==="characterData"&&(o|=ye|se);if(o!==me){if(this.pendingMask|=o,o&ve){this.clearTimers(),this.isDomDirty=!0;return}this.mutationTimer&&clearTimeout(this.mutationTimer),this.mutationTimer=window.setTimeout(()=>{this.mutationTimer=null,this.isDomDirty=!0},200)}})}start(){this.isRunning||(this.isRunning=!0,this.observer.observe(this.target,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),this.target.addEventListener("transitionend",this.onTransitionFinished),this.target.addEventListener("animationend",this.onTransitionFinished),window.addEventListener("resize",this.onWindowResize),this.isDomDirty=!0,this.lastScrollX=window.scrollX,this.lastScrollY=window.scrollY,this.renderLoop())}stop(){this.isRunning=!1,this.observer.disconnect(),this.clearTimers(),this.target.removeEventListener("transitionend",this.onTransitionFinished),this.target.removeEventListener("animationend",this.onTransitionFinished),window.removeEventListener("resize",this.onWindowResize)}clearTimers(){this.mutationTimer&&(clearTimeout(this.mutationTimer),this.mutationTimer=null),this.cssTimer&&(clearTimeout(this.cssTimer),this.cssTimer=null),this.scrollTimer&&(clearTimeout(this.scrollTimer),this.scrollTimer=null)}}const j=1,oe=2,N={BASE:0,SELECTED:1,getCaptureLayer:n=>31-n,HIDDEN:31},Le=Object.values(F.VALUES);class Me{static getBaseline(e){if(this.cache.has(e))return this.cache.get(e);const t=this.calculateBaselineFromDOM(e);return this.cache.set(e,t),t}static calculateBaselineFromDOM(e){if(typeof document=="undefined")return 0;const t=document.createElement("div"),r=document.createElement("span"),i=document.createElement("img");t.style.visibility="hidden",t.style.position="absolute",t.style.top="0px",t.style.left="0px",t.style.font=e,t.style.margin="0",t.style.padding="0",t.style.border="none",r.style.margin="0",r.style.padding="0",r.style.border="none",r.style.lineHeight="normal",i.width=1,i.height=1,i.style.verticalAlign="baseline",r.appendChild(document.createTextNode("Hidden Text")),t.appendChild(r),t.appendChild(i),document.body.appendChild(t);const c=i.offsetTop-r.offsetTop;return document.body.removeChild(t),c}}u(Me,"cache",new Map);class Pe extends v.MeshBasicMaterial{constructor(t,r,i,c,s=2){super({transparent:!0,side:v.FrontSide,color:16777215});u(this,"canvas");u(this,"ctx");u(this,"qualityFactor");if(this.canvas=document.createElement("canvas"),this.ctx=this.canvas.getContext("2d"),!this.ctx)throw new Error("[Mirage] Failed to create canvas context");this.qualityFactor=s,this.map=new v.CanvasTexture(this.canvas),this.map.colorSpace=v.LinearSRGBColorSpace,this.map.minFilter=v.LinearFilter,this.map.magFilter=v.LinearFilter,this.updateText(t,r,i,c)}wrapText(t,r){const i=t.split(`
2
2
  `),c=[];return i.forEach(s=>{const o=s.match(/[^\s\-]+\-?|\-|\s+/g)||[];if(o.length===0){c.push("");return}let a=o[0];for(let l=1;l<o.length;l++){const d=o[l];this.ctx.measureText(a+d).width<=r+2?a+=d:(a&&c.push(a),a=d.trimStart())}a&&c.push(a)}),c}updateText(t,r,i,c,s){s!==void 0&&(this.qualityFactor=s);const a=(window.devicePixelRatio||1)*this.qualityFactor,l=i*a,d=c*a;this.canvas.width!==l||this.canvas.height!==d?(this.canvas.width=l,this.canvas.height=d):this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.setTransform(a,0,0,a,0,0),this.ctx.font=r.font,this.ctx.fillStyle=r.color,this.ctx.textBaseline="alphabetic",this.ctx.globalAlpha=1;const h=this.wrapText(t,i),f=r.lineHeight,g=Me.getBaseline(r.font);h.forEach((p,w)=>{const y=w*f+g;let C=0;r.textAlign==="center"?C=i/2:r.textAlign==="right"&&(C=i),this.ctx.textAlign=r.textAlign,this.ctx.fillText(p,C,y)}),this.map&&(this.map.needsUpdate=!0)}dispose(){this.map&&this.map.dispose(),super.dispose()}}function ae(n,e=0){if(typeof n=="number")return n;const t=parseFloat(n)||0;return typeof n=="string"&&n.includes("%")?t/100*e:t}function ce(n){if(!n||n==="transparent")return{color:new v.Color(16777215),alpha:0};const e=n.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);if(e){const t=parseInt(e[1],10),r=parseInt(e[2],10),i=parseInt(e[3],10),c=e[4]!==void 0?parseFloat(e[4]):1;return{color:new v.Color(`rgb(${t}, ${r}, ${i})`),alpha:c}}return{color:new v.Color(n),alpha:1}}function De(n){const e=[];let t="",r=0;for(let i=0;i<n.length;i++){const c=n[i];if(c==="(")r++;else if(c===")")r--;else if(c===","&&r===0){e.push(t.trim()),t="";continue}t+=c}return t&&e.push(t.trim()),e}function We(n){if(!n||typeof n!="string"||!n.includes("linear-gradient"))return null;const e=n.match(/linear-gradient\((.*)\)/);if(!e)return null;const t=e[1],r=De(t);let i=Math.PI,c=0;const s=r[0].trim();if(s.startsWith("to "))s==="to top"?i=0:s==="to right"?i=Math.PI/2:s==="to bottom"?i=Math.PI:s==="to left"?i=Math.PI*1.5:s==="to top right"||s==="to right top"?i=Math.PI/4:s==="to bottom right"||s==="to right bottom"?i=Math.PI*.75:s==="to bottom left"||s==="to left bottom"?i=Math.PI*1.25:(s==="to top left"||s==="to left top")&&(i=Math.PI*1.75),c=1;else if(s.endsWith("deg")||s.endsWith("rad")||s.endsWith("turn")){const a=parseFloat(s);s.endsWith("deg")?i=a*(Math.PI/180):s.endsWith("rad")?i=a:s.endsWith("turn")&&(i=a*Math.PI*2),c=1}const o=[];for(let a=c;a<r.length&&!(o.length>=8);a++){const l=r[a].trim(),d=l.lastIndexOf(" ");let h=l,f=null;if(d!==-1&&!l.endsWith(")")){const p=l.substring(d+1);(p.endsWith("%")||p.endsWith("px")||!isNaN(parseFloat(p)))&&(h=l.substring(0,d).trim(),f=p)}const g=ce(h);o.push({color:g.color,alpha:g.alpha,rawStop:f,stop:0})}if(o.length>0){for(let l=0;l<o.length;l++)o[l].rawStop!==null&&(o[l].stop=parseFloat(o[l].rawStop)/100);o[0].rawStop===null&&(o[0].stop=0),o.length>1&&o[o.length-1].rawStop===null&&(o[o.length-1].stop=1);let a=0;for(let l=1;l<o.length;l++)if(o[l].rawStop!==null||l===o.length-1){const d=l-a;if(d>1){const h=o[a].stop,g=(o[l].stop-h)/d;for(let p=1;p<d;p++)o[a+p].stop=h+g*p}a=l}}return{angle:i,stops:o}}function He(n){if(!n||n==="none")return null;const e=De(n);if(e.length===0)return null;const t=e[0].trim(),r=/(rgba?\([^)]+\)|#[0-9a-fA-F]+|[a-zA-Z]+)/,i=t.match(r);let c="transparent",s=t;if(i&&i[1]!=="inset"){const g=i[1];(g.startsWith("rgb")||g.startsWith("#")||g==="black"||g==="white"||g==="transparent")&&(c=g,s=t.replace(g,"").trim())}s=s.replace("inset","").trim();const o=s.split(/\s+/).map(g=>parseFloat(g)||0),a=o[0]||0,l=o[1]||0,d=o[2]||0,h=o[3]||0,f=ce(c);return{offsetX:a,offsetY:l,blurRadius:d,spreadRadius:h,color:f.color,alpha:f.alpha}}const Ge=`varying vec2 vUv;
3
3
  varying vec4 vScreenPos;
4
4
  void main() {
@@ -181,7 +181,7 @@ baseColor = blendSrcOver(baseColor, texColor);`,Ae={vertexShader:Ge,fragmentShad
181
181
  `,h=n.isTraveler?`vec2 resultUv = screenUv;
182
182
  `:`vec2 localUv = (p / uSize) + 0.5;
183
183
  vec2 resultUv = localUv * uTextureRepeat + uTextureOffset;
184
- `,f=c||a?d+h+((i==null?void 0:i.uvModifier)||""):"",g=c||a?ke.baseColorChunk:"",p=(i==null?void 0:i.colorModifier)||"",w=Ae.fragmentShader.replace("#INJECT_DECLARATIONS",l).replace("#INJECT_UV_MODIFIER",f).replace("#INJECT_BASE_COLOR",g).replace("#INJECT_COLOR_MODIFIER",p),y=ce(n.backgroundColor),C=ce(n.borderColor),O={uSize:{value:new v.Vector2(e,t)},uMeshSize:{value:new v.Vector2(e,t)},uShadowColor:{value:new v.Vector4(0,0,0,0)},uShadowOffset:{value:new v.Vector2(0,0)},uShadowBlur:{value:0},uShadowSpread:{value:0},uBgColor:{value:new v.Vector4(y.color.r,y.color.g,y.color.b,y.alpha)},uBorderColor:{value:new v.Vector4(C.color.r,C.color.g,C.color.b,C.alpha)},uBorderRadius:{value:new v.Vector4(0,0,0,0)},uBorderWidth:{value:ae(n.borderWidth)},uOpacity:{value:(S=n.opacity)!=null?S:1},uTexture:{value:null},uTextureRepeat:{value:new v.Vector2(1,1)},uTextureOffset:{value:new v.Vector2(0,0)},uGradientCount:{value:0},uGradientAngle:{value:0},uGradientColors:{value:Array.from({length:8},()=>new v.Vector4(0,0,0,0))},uGradientStops:{value:new Float32Array(8)}};Ie(O.uBorderRadius.value,n.borderRadius,Math.min(e,t)),c&&(O.uTexture.value=r);const A=new v.ShaderMaterial({uniforms:ne(ne({},O),o),vertexShader:Ae.vertexShader,fragmentShader:w,transparent:!0,side:v.FrontSide});return n.backgroundImage&&be(A,{backgroundImage:n.backgroundImage}),A}function Ze(n,e,t,r,i){const c=ae(e.borderWidth);be(n,{width:t,height:r,borderRadius:e.borderRadius,borderWidth:c,backgroundColor:e.backgroundColor,borderColor:e.borderColor,opacity:e.opacity,texture:i,backgroundImage:e.backgroundImage,boxShadow:e.boxShadow})}function be(n,e){var r,i,c;if(e.boxShadow!==void 0){const s=He(e.boxShadow);s?(n.uniforms.uShadowColor.value.set(s.color.r,s.color.g,s.color.b,s.alpha),n.uniforms.uShadowOffset.value.set(s.offsetX,s.offsetY),n.uniforms.uShadowBlur.value=s.blurRadius,n.uniforms.uShadowSpread.value=s.spreadRadius,n.userData.shadowPadding=s.blurRadius+s.spreadRadius+Math.max(Math.abs(s.offsetX),Math.abs(s.offsetY))):(n.uniforms.uShadowColor.value.w=0,n.userData.shadowPadding=0)}if(e.width!==void 0&&e.height!==void 0&&n.uniforms.uSize.value.set(e.width,e.height),n.uniforms.uMeshSize){const s=n.userData.shadowPadding||0,o=e.width!==void 0?e.width:n.uniforms.uSize.value.x,a=e.height!==void 0?e.height:n.uniforms.uSize.value.y;n.uniforms.uMeshSize.value.set(o+s*2,a+s*2)}if(e.borderRadius!==void 0){const s=e.width!==void 0&&e.height!==void 0?Math.min(e.width,e.height):Math.min(n.uniforms.uSize.value.x,n.uniforms.uSize.value.y);Ie(n.uniforms.uBorderRadius.value,e.borderRadius,s)}if(e.borderWidth!==void 0&&(n.uniforms.uBorderWidth.value=e.borderWidth),e.backgroundColor!==void 0)if(Array.isArray(e.backgroundColor)){const s=n.uniforms.uBgColor.value.w;n.uniforms.uBgColor.value.set(e.backgroundColor[0],e.backgroundColor[1],e.backgroundColor[2],s)}else if(typeof e.backgroundColor=="string"){const s=ce(e.backgroundColor);n.uniforms.uBgColor.value.set(s.color.r,s.color.g,s.color.b,s.alpha)}else{const s=n.uniforms.uBgColor.value.w;n.uniforms.uBgColor.value.set(e.backgroundColor.r,e.backgroundColor.g,e.backgroundColor.b,s)}if(e.borderColor!==void 0)if(Array.isArray(e.borderColor)){const s=n.uniforms.uBorderColor.value.w;n.uniforms.uBorderColor.value.set(e.borderColor[0],e.borderColor[1],e.borderColor[2],s)}else if(typeof e.borderColor=="string"){const s=ce(e.borderColor);n.uniforms.uBorderColor.value.set(s.color.r,s.color.g,s.color.b,s.alpha)}else{const s=n.uniforms.uBorderColor.value.w;n.uniforms.uBorderColor.value.set(e.borderColor.r,e.borderColor.g,e.borderColor.b,s)}e.opacity!==void 0&&(n.uniforms.uOpacity.value=e.opacity),e.bgOpacity!==void 0&&(n.uniforms.uBgColor.value.w=e.bgOpacity),e.borderOpacity!==void 0&&(n.uniforms.uBorderColor.value.w=e.borderOpacity),n.uniforms.uTexture&&e.texture!==void 0&&(n.uniforms.uTexture.value=e.texture);const t=e.texture!==void 0?e.texture:(r=n.uniforms.uTexture)==null?void 0:r.value;if(t&&(t.image instanceof ImageBitmap||t.image instanceof HTMLImageElement||t.image instanceof HTMLCanvasElement)){const s=t.image.naturalWidth||t.image.videoWidth||t.image.width,o=t.image.naturalHeight||t.image.videoHeight||t.image.height,a=(i=e.width)!=null?i:n.uniforms.uSize.value.x,l=(c=e.height)!=null?c:n.uniforms.uSize.value.y;if(s&&o&&a&&l){const d=s/o,h=a/l;if(d>h){const f=h/d;n.uniforms.uTextureRepeat.value.set(f,1),n.uniforms.uTextureOffset.value.set((1-f)/2,0)}else{const f=d/h;n.uniforms.uTextureRepeat.value.set(1,f),n.uniforms.uTextureOffset.value.set(0,(1-f)/2)}}}else n.uniforms.uTextureRepeat&&(n.uniforms.uTextureRepeat.value.set(1,1),n.uniforms.uTextureOffset.value.set(0,0));if(e.backgroundImage!==void 0){const s=We(e.backgroundImage);if(s){n.uniforms.uGradientCount.value=s.stops.length,n.uniforms.uGradientAngle.value=s.angle;for(let o=0;o<8;o++)if(o<s.stops.length){const a=s.stops[o];n.uniforms.uGradientColors.value[o].set(a.color.r,a.color.g,a.color.b,a.alpha),n.uniforms.uGradientStops.value[o]=a.stop}else n.uniforms.uGradientColors.value[o].set(0,0,0,0),n.uniforms.uGradientStops.value[o]=1}else n.uniforms.uGradientCount.value=0}for(const s of Object.keys(e))s!=="width"&&s!=="height"&&s!=="borderRadius"&&s!=="borderWidth"&&s!=="backgroundColor"&&s!=="borderColor"&&s!=="opacity"&&s!=="bgOpacity"&&s!=="borderOpacity"&&s!=="texture"&&s!=="backgroundImage"&&s!=="boxShadow"&&n.uniforms[s]!==void 0&&(n.uniforms[s].value!==void 0&&n.uniforms[s].value!==null&&typeof n.uniforms[s].value.set=="function"?Array.isArray(e[s])?n.uniforms[s].value.set(...e[s]):e[s]!==void 0&&(e[s].copy?n.uniforms[s].value.copy(e[s]):n.uniforms[s].value=e[s]):n.uniforms[s].value=e[s])}function Ie(n,e,t=0){var a,l,d,h;if(e==null){n.set(0,0,0,0);return}if(typeof e=="number"){n.set(e,e,e,e);return}if(Array.isArray(e)){n.set(e[0],e[1],e[2],e[3]);return}const r=e.split("/")[0].trim().split(/\s+/),i=ae(r[0],t),c=ae((a=r[1])!=null?a:r[0],t),s=ae((l=r[2])!=null?l:r[0],t),o=ae((h=(d=r[3])!=null?d:r[1])!=null?h:r[0],t);n.set(i,c,s,o)}const G={create(n,e,t,r,i,c=2,s=null,o){return n==="BOX"?Je(e,r,i,s,o):n==="TEXT"?new Pe(t||"",e,r,i,c):new v.MeshBasicMaterial({visible:!1})},update(n,e,t,r,i,c,s=2,o){e==="BOX"?Ze(n,t,i,c,o):e==="TEXT"&&n.updateText(r||"",t,i,c,s)},forceUpdateUniforms(n,e){be(n,e)}};class Qe{constructor(e,t=!0){u(this,"observer");u(this,"textures",new WeakMap);u(this,"loadStatus",new WeakMap);u(this,"elementUrls",new WeakMap);u(this,"onUpdate");this.onUpdate=e,t&&(this.observer=new IntersectionObserver(r=>{for(const i of r){const c=i.target;i.isIntersecting?this.loadTexture(c):this.disposeTexture(c)}},{rootMargin:"300px"}))}register(e,t){if(e.nodeType!==Node.ELEMENT_NODE)return;this.elementUrls.get(e)!==t&&(this.elementUrls.set(e,t),this.observer?(this.observer.unobserve(e),this.observer.observe(e)):this.loadTexture(e))}unregister(e){e.nodeType===Node.ELEMENT_NODE&&this.observer&&this.observer.unobserve(e),this.disposeTexture(e),this.elementUrls.delete(e),this.loadStatus.delete(e)}loadTexture(e){return ze(this,null,function*(){if(this.loadStatus.get(e)||this.textures.has(e))return;const t=this.elementUrls.get(e);if(t){this.loadStatus.set(e,!0);try{let r;if(t.startsWith("data:image/svg+xml"))r=yield new Promise((c,s)=>{const o=new Image;o.onload=()=>c(o),o.onerror=s,o.src=t});else{const s=yield(yield fetch(t)).blob();r=yield createImageBitmap(s,{imageOrientation:"flipY"})}if(this.elementUrls.get(e)!==t){"close"in r&&r.close();return}const i=new v.Texture(r);r instanceof HTMLImageElement||(i.flipY=!1),i.colorSpace=v.LinearSRGBColorSpace,i.needsUpdate=!0,this.textures.set(e,i),this.onUpdate(e,i)}catch(r){console.warn("[MirageEngine] Failed to load texture:",t,r)}finally{this.elementUrls.has(e)&&this.loadStatus.set(e,!1)}}})}disposeTexture(e){const t=this.textures.get(e);t&&(t.dispose(),this.textures.delete(e),this.onUpdate(e,null)),this.loadStatus.set(e,!1)}get(e){return this.textures.get(e)}disposeAll(){this.observer&&this.observer.disconnect()}}class et{constructor(e,t,r,i){u(this,"canvas");u(this,"scene");u(this,"camera");u(this,"renderer");u(this,"renderTargets",[]);u(this,"renderOrder",0);u(this,"qualityFactor",2);u(this,"mode","overlay");u(this,"canvasSize","viewport");u(this,"clipArea",1);u(this,"targetLayer","base");u(this,"overscan",200);u(this,"target");u(this,"mountContainer");u(this,"registry");u(this,"targetRect");u(this,"travelersByLayer",Array.from({length:_.MAX_LAYERS},()=>new Set));u(this,"textureManager");u(this,"fixedMeshes",new Set);var o,a,l,d,h;this.target=e,this.mountContainer=r,this.registry=i,this.mode=(o=t.mode)!=null?o:"overlay",this.canvasSize=(a=t.canvasSize)!=null?a:"viewport",this.clipArea=(l=t.travelerClipArea)!=null?l:1,this.targetLayer=(d=t.layer)!=null?d:"base",this.textureManager=new Qe((f,g)=>{const p=this.registry.get(f);p&&p.material instanceof v.ShaderMaterial&&G.forceUpdateUniforms(p.material,{texture:g})},this.isViewport),this.canvas=document.createElement("canvas"),this.scene=new v.Scene,this.targetRect=this.target.getBoundingClientRect();const c=this.isViewport?window.innerWidth+this.overscan*2:this.targetRect.width,s=this.isViewport?window.innerHeight+this.overscan*2:this.targetRect.height;this.camera=new v.OrthographicCamera(c/-2,c/2,s/2,s/-2,1,1e3),this.camera.position.z=100,this.camera.layers.set(this.getSceneLayer()),this.renderer=new v.WebGLRenderer({canvas:this.canvas,alpha:!0,antialias:!0}),v.ColorManagement.enabled=!1,this.renderer.outputColorSpace=v.LinearSRGBColorSpace,this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(c,s),this.applyTextQuality((h=t.quality)!=null?h:"medium")}get isViewport(){return this.mode==="overlay"&&this.canvasSize==="viewport"}getSceneLayer(){return typeof this.targetLayer=="number"?this.targetLayer:this.targetLayer==="selected"?N.SELECTED:N.BASE}createRenderTarget(){for(let e=0;e<_.MAX_LAYERS;e++){const t=this.isViewport?window.innerWidth+this.overscan*2:this.targetRect.width,r=this.isViewport?window.innerHeight+this.overscan*2:this.targetRect.height;this.renderTargets.push(new v.WebGLRenderTarget(t*this.qualityFactor,r*this.qualityFactor,{minFilter:v.LinearFilter,magFilter:v.LinearFilter,format:v.RGBAFormat,stencilBuffer:!1,depthBuffer:!0}))}}applyTextQuality(e){if(typeof e=="number"){this.qualityFactor=Math.max(.1,e);return}switch(e){case"low":this.qualityFactor=1;break;case"high":this.qualityFactor=4;break;case"medium":this.qualityFactor=2;break;default:this.qualityFactor=2;break}}mount(){this.mountContainer.prepend(this.canvas),this.canvas.style.pointerEvents=this.mode==="overlay"?"none":"auto",this.updateCanvasLayout()}updateCanvasLayout(){const e=this.isViewport?window.innerWidth+this.overscan*2:this.targetRect.width,t=this.isViewport?window.innerHeight+this.overscan*2:this.targetRect.height;this.canvas.style.width=`${e}px`,this.canvas.style.height=`${t}px`,this.mode==="duplicate"?(this.canvas.style.position="",this.canvas.style.top="",this.canvas.style.left="",this.canvas.style.display="block"):(this.canvas.style.position=this.isViewport?"fixed":"absolute",this.canvas.style.top=this.isViewport?`-${this.overscan}px`:`${this.target.offsetTop}px`,this.canvas.style.left=this.isViewport?`-${this.overscan}px`:`${this.target.offsetLeft}px`,this.canvas.style.display="block")}updateUniforms(e,t){const r=this.registry.get(e);r&&(r.traverse(i=>{i.isMesh&&i.material&&G.forceUpdateUniforms(i.material,t)}),r.userData.nativeMesh&&r.userData.nativeMesh.traverse(i=>{i.isMesh&&i.material&&G.forceUpdateUniforms(i.material,t)}))}dispose(){this.renderer.dispose(),this.canvas.remove(),this.textureManager.disposeAll()}setSize(e,t){this.renderer.setSize(e,t);for(const r of this.renderTargets)r.setSize(e*this.qualityFactor,t*this.qualityFactor);this.camera.left=e/-2,this.camera.right=e/2,this.camera.top=t/2,this.camera.bottom=t/-2,this.camera.updateProjectionMatrix()}syncScene(e,t){const r=this.target.getBoundingClientRect(),i=this.isViewport?window.innerWidth+this.overscan*2:r.width,c=this.isViewport?window.innerHeight+this.overscan*2:r.height,s=this.isViewport?this.canvas.clientWidth:this.targetRect.width,o=this.isViewport?this.canvas.clientHeight:this.targetRect.height,a=Math.abs(i-s)>.1||Math.abs(c-o)>.1,l=this.mode==="overlay"&&(Math.abs(r.top-this.targetRect.top)>.1||Math.abs(r.left-this.targetRect.left)>.1);a?(this.targetRect=r,this.setSize(i,c),this.updateCanvasLayout()):l?(this.targetRect=r,this.updateCanvasLayout()):this.targetRect=r,this.renderOrder=0,this.reconcileNode(e),t.size>0&&t.forEach(d=>{const h=this.registry.get(d);if(h){this.scene.remove(h);for(const f of this.travelersByLayer)f.delete(h);this.fixedMeshes.delete(h),h.geometry.dispose(),h.userData.nativeMesh&&(this.scene.remove(h.userData.nativeMesh),Array.isArray(h.userData.nativeMesh.material)?h.userData.nativeMesh.material.forEach(f=>f.dispose()):h.userData.nativeMesh.material.dispose(),h.userData.nativeMesh.geometry.dispose()),h.traverse(f=>{f instanceof v.Mesh&&(f.geometry&&f.geometry.dispose(),f.material&&(Array.isArray(f.material)?f.material.forEach(g=>g.dispose()):f.material.dispose()))}),this.registry.remove(d),this.textureManager.unregister(d)}})}reconcileNode(e){var i,c;let t=this.registry.get(e.element);const r=JSON.stringify(e.shaderHooks||null);if(t&&t.userData.shaderHash!==r&&(this.scene.remove(t),t.geometry.dispose(),t.material instanceof v.Material&&t.material.dispose(),this.registry.remove(e.element),t=void 0),!t){const s=new v.PlaneGeometry(1,1),o=e.isTraveler?(i=this.renderTargets[e.captureLayer-2])==null?void 0:i.texture:this.textureManager.get(e.element),a=G.create("BOX",e.styles,"",e.rect.width,e.rect.height,this.qualityFactor,o,e.shaderHooks);t=new v.Mesh(s,a),e.type==="TEXT"&&(t.name="BG_MESH"),this.scene.add(t),this.registry.register(e.element,t),t.userData.baseMaterial=a,t.userData.domElement=e.element,t.userData.shaderHash=r}if((c=e.nativeStyles)!=null&&c.transform?t.userData.nativeTransform=e.nativeStyles.transform:t.userData.nativeTransform=void 0,this.updateMeshProperties(t,e),this.updateMeshLayers(t,e),e.isTraveler)for(let s=0;s<_.MAX_LAYERS;s++)s===e.captureLayer-2?this.travelersByLayer[s].add(t):this.travelersByLayer[s].delete(t);else for(const s of this.travelersByLayer)s.delete(t);if(e.isFixed?this.fixedMeshes.add(t):this.fixedMeshes.delete(t),e.styles.imageSrc?this.textureManager.register(e.element,e.styles.imageSrc):this.textureManager.unregister(e.element),e.type==="BOX")for(const s of e.children)this.reconcileNode(s);else e.type==="TEXT"&&(this.reconcileTextChild(t,e,!1),t.userData.nativeMesh&&e.nativeStyles&&this.reconcileTextChild(t.userData.nativeMesh,e,!0))}reconcileTextChild(e,t,r){var l;const i=t.textLines||[{text:t.textContent||"",rect:t.rect}],c=r?t.nativeStyles:t.textStyles,s=JSON.stringify(c)+t.textContent+i.map(d=>d.text).join("|"),o=(l=e.userData)==null?void 0:l.textChildStyleHash;if(t.dirtyMask&ye||s!==o){e.children.filter(p=>p.name.startsWith("TEXT_CHILD")).forEach(p=>{var y;const w=p;(y=w.material.map)==null||y.dispose(),w.geometry.dispose(),e.remove(w)});const h=t.rect,f=h.x+h.width/2,g=h.y+h.height/2;i.forEach((p,w)=>{const y=G.create("TEXT",c,p.text,p.rect.width,p.rect.height,this.qualityFactor),C=new v.PlaneGeometry(1,1),O=new v.Mesh(C,y);O.name=`TEXT_CHILD_${w}`;const A=t.rect.width===0?1:p.rect.width/t.rect.width,S=t.rect.height===0?1:p.rect.height/t.rect.height;O.scale.set(A,S,1);const R=p.rect.x+p.rect.width/2,E=p.rect.y+p.rect.height/2,$=R-f,W=-(E-g);O.position.set(t.rect.width===0?0:$/t.rect.width,t.rect.height===0?0:W/t.rect.height,.005),e.add(O)}),e.userData.textChildStyleHash=s}e.children.forEach(d=>{if(!d.name.startsWith("TEXT_CHILD"))return;const h=d;if(r&&t.nativeLayer!==void 0)h.layers.set(N.HIDDEN),t.visibility&j&&h.layers.enable(N.getCaptureLayer(t.nativeLayer));else{const f=t.visibility&j?N.BASE:N.HIDDEN;if(h.layers.set(f),t.visibility&oe&&h.layers.enable(N.SELECTED),t.visibility&j)if(!r&&t.nativeLayer!==void 0&&t.nativeStyles!==void 0)for(let g=t.captureLayer;g<=_.MAX_LAYERS+1;g++)g!==t.nativeLayer&&h.layers.enable(N.getCaptureLayer(g));else for(let g=t.captureLayer;g<=_.MAX_LAYERS+1;g++)h.layers.enable(N.getCaptureLayer(g))}})}updateMeshProperties(e,t){var S,R,E,$,W;const{rect:r,styles:i}=t,c=this.renderer.getPixelRatio(),s=this.renderer.domElement.width/c,o=this.renderer.domElement.height/c;e.material=e.userData.baseMaterial;let a=((S=e.material.userData)==null?void 0:S.shadowPadding)||0;e.scale.set(r.width+a*2,r.height+a*2,1),e.userData.domRect={x:r.x,y:r.y,width:r.width,height:r.height};const l=.001;this.renderOrder++;const d=this.targetRect.left+window.scrollX,h=this.targetRect.top+window.scrollY;let f,g;if(this.isViewport)f=r.x-window.innerWidth/2+r.width/2,g=-r.y+window.innerHeight/2-r.height/2;else{const L=r.x-d,K=r.y-h;f=L-s/2+r.width/2,g=-K+o/2-r.height/2}e.position.set(f,g,i.zIndex+this.renderOrder*l);const p=r.x,w=r.y;e.userData.basePosition={x:f,y:g},e.userData.originalBasePosition={x:f,y:g},e.userData.baseSize={width:r.width,height:r.height},e.userData.baseDOM={x:p,y:w},e.userData.isFixed=t.isFixed,e.userData.initialScroll={x:window.scrollX,y:window.scrollY};const y=t.element.nodeType===Node.TEXT_NODE?t.element.parentElement:t.element,C=window.getComputedStyle(y);let O=0,A=0;if(C.transform&&C.transform!=="none"){const L=new DOMMatrix(C.transform);O=L.m41,A=L.m42}if(e.userData.baseTransform={x:O,y:A},delete e.userData.originRatioX,delete e.userData.originRatioY,G.update(e.userData.baseMaterial,"BOX",i,"",r.width,r.height,this.qualityFactor,t.isTraveler?(R=this.renderTargets[t.captureLayer-2])==null?void 0:R.texture:this.textureManager.get(t.element)),t.nativeStyles&&t.nativeRect){if(!e.userData.nativeMesh){const H=G.create("BOX",t.nativeStyles,"",t.nativeRect.width,t.nativeRect.height,this.qualityFactor,t.isTraveler?(E=this.renderTargets[t.captureLayer-2])==null?void 0:E.texture:this.textureManager.get(t.element),t.shaderHooks),q=new v.Mesh(e.geometry,H);t.type==="TEXT"&&(q.name="BG_MESH"),this.scene.add(q),e.userData.nativeMesh=q}const L=e.userData.nativeMesh;let K,te;if(this.isViewport)K=t.nativeRect.x-window.innerWidth/2+t.nativeRect.width/2,te=-t.nativeRect.y+window.innerHeight/2-t.nativeRect.height/2;else{const H=t.nativeRect.x-d,q=t.nativeRect.y-h;K=H-s/2+t.nativeRect.width/2,te=-q+o/2-t.nativeRect.height/2}let re=t.nativeRect.width,M=t.nativeRect.height,X=K,Q=te;if(t.nativeStyles.transform){const H=t.nativeStyles.transform,q=H.match(/scale\(([\d.]+%?)\)/);if(q){let b=parseFloat(q[1]);q[1].includes("%")&&(b/=100),re*=b,M*=b}const le=H.match(/scaleX\(([\d.]+%?)\)/);if(le){let b=parseFloat(le[1]);le[1].includes("%")&&(b/=100),re*=b}const he=H.match(/scaleY\(([\d.]+%?)\)/);if(he){let b=parseFloat(he[1]);he[1].includes("%")&&(b/=100),M*=b}const m=H.match(/translate\(([^,]+),\s*([^)]+)\)/);if(m){const b=m[1].trim(),x=m[2].trim();let P=parseFloat(b);b.includes("%")&&(P=P/100*t.nativeRect.width);let V=parseFloat(x);x.includes("%")&&(V=V/100*t.nativeRect.height),X+=P,Q-=V}const k=H.match(/translateX\(([^)]+)\)/);if(k){const b=k[1].trim();let x=parseFloat(b);b.includes("%")&&(x=x/100*t.nativeRect.width),X+=x}const z=H.match(/translateY\(([^)]+)\)/);if(z){const b=z[1].trim();let x=parseFloat(b);b.includes("%")&&(x=x/100*t.nativeRect.height),Q-=x}}let ee=(($=L.material.userData)==null?void 0:$.shadowPadding)||0;L.scale.set(re+ee*2,M+ee*2,1),L.position.set(X,Q,t.nativeStyles.zIndex+this.renderOrder*l),G.update(L.material,"BOX",t.nativeStyles,"",t.nativeRect.width,t.nativeRect.height,this.qualityFactor,t.isTraveler?(W=this.renderTargets[t.captureLayer-2])==null?void 0:W.texture:this.textureManager.get(t.element))}else e.userData.nativeMesh&&(this.scene.remove(e.userData.nativeMesh),e.userData.nativeMesh.material instanceof v.Material&&e.userData.nativeMesh.material.dispose(),delete e.userData.nativeMesh)}updateMeshLayers(e,t){const r=t.visibility&j?N.BASE:N.HIDDEN;if(e.layers.set(r),t.visibility&oe&&e.layers.enable(N.SELECTED),e.userData.nativeMesh&&t.nativeLayer!==void 0){const i=e.userData.nativeMesh;if(i.layers.set(N.HIDDEN),t.visibility&j){i.layers.enable(N.getCaptureLayer(t.nativeLayer));for(let c=t.captureLayer;c<=_.MAX_LAYERS+1;c++)c!==t.nativeLayer&&e.layers.enable(N.getCaptureLayer(c))}}else if(t.visibility&j)for(let i=t.captureLayer;i<=_.MAX_LAYERS+1;i++)e.layers.enable(N.getCaptureLayer(i))}captureRenderTarget(e,t,r){if(e.size===0||!r)return;const i=new v.Color,c=this.renderer.getClearAlpha();this.renderer.getClearColor(i),this.renderer.setClearColor(0,0),this.renderer.setRenderTarget(r),this.renderer.clear(),this.renderer.autoClear=!1,this.renderer.setScissorTest(!0),this.camera.layers.set(t);const s=new v.Vector3,o=this.isViewport?window.innerWidth+this.overscan*2:this.targetRect.width,a=this.isViewport?window.innerHeight+this.overscan*2:this.targetRect.height,l=this.renderer.getPixelRatio();for(const d of e){s.setFromMatrixPosition(d.matrixWorld),s.project(this.camera);const h=(s.x+1)/2*o,f=(s.y+1)/2*a;let g=0,p=1;typeof this.clipArea=="number"?p=this.clipArea:this.clipArea.endsWith("%")?p=parseFloat(this.clipArea)/100:this.clipArea.endsWith("px")&&(g=parseFloat(this.clipArea));const w=d.scale.x*p+.5,y=d.scale.y*p+.5,C=h-w/2,O=f-y/2,A=(C*this.qualityFactor-g)/l,S=(O*this.qualityFactor-g)/l,R=(w*this.qualityFactor+g*2)/l,E=(y*this.qualityFactor+g*2)/l;this.renderer.setScissor(A,S,R,E),this.renderer.render(this.scene,this.camera)}this.renderer.setScissorTest(!1),this.renderer.autoClear=!0,this.renderer.setRenderTarget(null),this.camera.layers.set(this.getSceneLayer()),this.renderer.setClearColor(i,c)}render(){for(let e=0;e<_.MAX_LAYERS;e++){const t=e+1;this.captureRenderTarget(this.travelersByLayer[e],N.getCaptureLayer(t),this.renderTargets[e])}this.renderer.render(this.scene,this.camera)}syncMeshesByDOM(){const e=this.targetRect.left+window.scrollX,t=this.targetRect.top+window.scrollY,r=this.renderer.getPixelRatio(),i=this.renderer.domElement.width/r,c=this.renderer.domElement.height/r;this.scene.children.forEach(s=>{var h,f;const o=s;if(!o.userData||!o.userData.domElement)return;const a=o.userData.domElement;if(!a.isConnected)return;let l;if(a.nodeType===Node.TEXT_NODE){const g=document.createRange();g.selectNode(a),l=g.getBoundingClientRect()}else l=a.getBoundingClientRect();const d=o.userData.domRect;if(!d||Math.abs(l.x-d.x)>.5||Math.abs(l.y-d.y)>.5||Math.abs(l.width-d.width)>.5||Math.abs(l.height-d.height)>.5){o.userData.domRect={x:l.x,y:l.y,width:l.width,height:l.height};let g,p;if(this.isViewport)g=l.x-window.innerWidth/2+l.width/2,p=-l.y+window.innerHeight/2-l.height/2;else{const y=l.x-e,C=l.y-t;g=y-i/2+l.width/2,p=-C+c/2-l.height/2}o.position.setX(g),o.position.setY(p);let w=((h=o.material.userData)==null?void 0:h.shadowPadding)||0;if(o.scale.set(l.width+w*2,l.height+w*2,1),o.updateMatrixWorld(),o.material instanceof v.ShaderMaterial&&G.forceUpdateUniforms(o.material,{width:l.width,height:l.height}),o.userData.nativeMesh){const y=o.userData.nativeMesh;let C=l.width,O=l.height,A=g,S=p;if(o.userData.nativeTransform){const E=o.userData.nativeTransform,$=E.match(/scale\(([\d.]+%?)\)/);if($){let M=parseFloat($[1]);$[1].includes("%")&&(M/=100),C*=M,O*=M}const W=E.match(/scaleX\(([\d.]+%?)\)/);if(W){let M=parseFloat(W[1]);W[1].includes("%")&&(M/=100),C*=M}const L=E.match(/scaleY\(([\d.]+%?)\)/);if(L){let M=parseFloat(L[1]);L[1].includes("%")&&(M/=100),O*=M}const K=E.match(/translate\(([^,]+),\s*([^)]+)\)/);if(K){const M=K[1].trim(),X=K[2].trim();let Q=parseFloat(M);M.includes("%")&&(Q=Q/100*l.width);let ee=parseFloat(X);X.includes("%")&&(ee=ee/100*l.height),A+=Q,S-=ee}const te=E.match(/translateX\(([^)]+)\)/);if(te){const M=te[1].trim();let X=parseFloat(M);M.includes("%")&&(X=X/100*l.width),A+=X}const re=E.match(/translateY\(([^)]+)\)/);if(re){const M=re[1].trim();let X=parseFloat(M);M.includes("%")&&(X=X/100*l.height),S-=X}}let R=((f=y.material.userData)==null?void 0:f.shadowPadding)||0;y.position.setX(A),y.position.setY(S),y.scale.set(C+R*2,O+R*2,1),y.updateMatrixWorld(),y.material instanceof v.ShaderMaterial&&G.forceUpdateUniforms(y.material,{width:C,height:O})}}})}}function tt(n){const e=n.textContent||"",t=[];let r="",i=null,c=-1;const s=(l,d)=>{for(let h=0;h<l.length;h++){const f=l[h],g=document.createRange();g.setStart(n,d+h),g.setEnd(n,d+h+1);const p=g.getBoundingClientRect();if(p.width===0&&p.height===0){r+=f;continue}c===-1||Math.abs(p.top-c)>p.height/2?(r&&i&&t.push({text:r,rect:{left:i.left,top:i.top,width:i.right-i.left,height:i.bottom-i.top}}),r=f,i={left:p.left,top:p.top,right:p.right,bottom:p.bottom},c=p.top):(r+=f,i&&(i.left=Math.min(i.left,p.left),i.top=Math.min(i.top,p.top),i.right=Math.max(i.right,p.right),i.bottom=Math.max(i.bottom,p.bottom)))}},o=e.match(/[^\s\-]+\-?|\-|\s+/g)||[];let a=0;for(const l of o){const d=document.createRange();d.setStart(n,a),d.setEnd(n,a+l.length);const h=d.getClientRects();if(h.length>1)s(l,a);else{const f=h.length===1?h[0]:d.getBoundingClientRect();if(f.width===0&&f.height===0){r+=l,a+=l.length;continue}c===-1||Math.abs(f.top-c)>f.height/2?(r&&i&&t.push({text:r,rect:{left:i.left,top:i.top,width:i.right-i.left,height:i.bottom-i.top}}),r=l,i={left:f.left,top:f.top,right:f.right,bottom:f.bottom},c=f.top):(r+=l,i&&(i.left=Math.min(i.left,f.left),i.top=Math.min(i.top,f.top),i.right=Math.max(i.right,f.right),i.bottom=Math.max(i.bottom,f.bottom)))}a+=l.length}return r&&i&&t.push({text:r,rect:{left:i.left,top:i.top,width:i.right-i.left,height:i.bottom-i.top}}),t.filter(l=>l.text.trim().length>0&&l.rect.width>0&&l.rect.height>0)}function Oe(n){const e=parseFloat(n.fontSize);let t=parseFloat(n.lineHeight);isNaN(t)&&(t=e*1.2);let r=parseFloat(n.letterSpacing);return isNaN(r)&&(r=0),{font:`${n.fontStyle} ${n.fontWeight} ${n.fontSize} ${n.fontFamily}`,fontSize:n.fontSize,color:n.color,textAlign:n.textAlign||"start",textBaseline:"alphabetic",direction:n.direction||"inherit",lineHeight:t,letterSpacing:r}}function Ue(n,e=se|fe|Xe|ye|ve,t,r=1,i=0,c=2,s,o){var X,Q,ee,H,q,le,he;if(n.nodeType===Node.TEXT_NODE){const m=n;if(!m.textContent||!m.textContent.trim())return null;const k=m.textContent.replace(/\s+/g," ");if(k.length===0)return null;const z=tt(m);if(z.length===0)return null;const b=m.parentElement,x=b?window.getComputedStyle(b):null;if(!x)return null;const P=Math.min(...z.map(T=>T.rect.left)),V=Math.min(...z.map(T=>T.rect.top)),ie=Math.max(...z.map(T=>T.rect.left+T.rect.width)),U=Math.max(...z.map(T=>T.rect.top+T.rect.height));return{id:Math.random().toString(36).substring(2,9),type:"TEXT",element:m,rect:{x:P+window.scrollX,y:V+window.scrollY,width:ie-P,height:U-V},styles:{backgroundColor:"transparent",backgroundImage:"",opacity:b&&b.dataset[Z.KEY]===Z.VALUES.HIDE?1:parseFloat(x.opacity),zIndex:(isNaN(parseInt(x.zIndex))?0:parseInt(x.zIndex))+i,borderRadius:"0px",borderColor:"transparent",borderWidth:"0px",isTraveler:!1},textContent:k,textLines:z.map(T=>({text:T.text.trim(),rect:{x:T.rect.left+window.scrollX,y:T.rect.top+window.scrollY,width:T.rect.width,height:T.rect.height}})),textStyles:Oe(x),dirtyMask:e,visibility:t,isTraveler:!1,captureLayer:r,isFixed:x.position==="fixed",nativeLayer:s,nativeStyles:o?ne(ne({backgroundColor:"transparent",backgroundImage:"",opacity:b&&b.dataset[Z.KEY]===Z.VALUES.HIDE?1:parseFloat(x.opacity),zIndex:(isNaN(parseInt(x.zIndex))?0:parseInt(x.zIndex))+i,borderRadius:"0px",borderColor:"transparent",borderWidth:"0px",isTraveler:!1},Oe(x)),o):void 0,nativeRect:o?{x:P+window.scrollX,y:V+window.scrollY,width:ie-P,height:U-V}:void 0,children:[]}}if(n.nodeType!==Node.ELEMENT_NODE)return null;const a=n,l=a.dataset[F.KEY];let d=t,h=t;if(l){const m=new Set(l.split(/\s+/));for(const k of m)if(!Le.includes(k))throw new Error(`[MirageEngine] Invalid filter token: '${k}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`);if(m.has(F.VALUES.END))return null;if(m.has(F.VALUES.INCLUDE_TREE)&&m.has(F.VALUES.EXCLUDE_TREE))throw new Error("[MirageEngine] Conflicting filters: 'include-tree' and 'exclude-tree' cannot be used together on the same element.");if(m.has(F.VALUES.INCLUDE_SELF)&&m.has(F.VALUES.EXCLUDE_SELF))throw new Error("[MirageEngine] Conflicting filters: 'include-self' and 'exclude-self' cannot be used together on the same element.");m.has(F.VALUES.INCLUDE_TREE)?d=d|j:m.has(F.VALUES.EXCLUDE_TREE)&&(d=d&~j),h=d,m.has(F.VALUES.INCLUDE_SELF)?h=h|j:m.has(F.VALUES.EXCLUDE_SELF)&&(h=h&~j)}const f=a.dataset[Y.KEY];if(f){const m=new Set(f.split(/\s+/));for(const k of m)if(!Le.includes(k))throw new Error(`[MirageEngine] Invalid select token: '${k}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`);if(m.has(Y.VALUES.END))return null;if(m.has(Y.VALUES.INCLUDE_TREE)&&m.has(Y.VALUES.EXCLUDE_TREE))throw new Error("[MirageEngine] Conflicting selects: 'include-tree' and 'exclude-tree' cannot be used together on the same element.");if(m.has(Y.VALUES.INCLUDE_SELF)&&m.has(Y.VALUES.EXCLUDE_SELF))throw new Error("[MirageEngine] Conflicting selects: 'include-self' and 'exclude-self' cannot be used together on the same element.");m.has(Y.VALUES.INCLUDE_TREE)?d=d|oe:m.has(Y.VALUES.EXCLUDE_TREE)&&(d=d&~oe),h=d,m.has(Y.VALUES.INCLUDE_SELF)?h=h|oe:m.has(Y.VALUES.EXCLUDE_SELF)&&(h=h&~oe)}const g=a.dataset[_.KEY];let p=!1,w=o?ne({},o):{},y=s;if(g){let m=1;const k=g.indexOf("{"),z=g.lastIndexOf("}");let b=g;if(k!==-1&&z!==-1&&z>k){b=g.substring(0,k).trim();const U=g.substring(k,z+1);try{w=new Function("return "+U)()}catch(T){console.warn(`[MirageEngine] Failed to parse travel styles JSON: ${U}`)}}const x=b.split(/\s+/);let P=!1;const V=x.indexOf(_.VALUES.TRAVELER);if(V!==-1){p=!0,P=!0;const U=x[V+1];if(U&&!isNaN(parseInt(U,10)))m=parseInt(U,10);else{const T=x.find(de=>!isNaN(parseInt(de,10)));T&&(m=parseInt(T,10))}}const ie=x.indexOf(_.VALUES.NATIVE);if(ie!==-1){const U=x[ie+1];if(U&&!isNaN(parseInt(U,10)))y=parseInt(U,10);else if(!p){const T=x.find(de=>!isNaN(parseInt(de,10)));T&&(y=parseInt(T,10))}}if(P){const U=m+1;if(U<r)throw new Error(`[MirageEngine] Traveler layer (${m}) cannot be smaller than inherited capture layer (${r-1}).`);r=Math.min(U,_.MAX_LAYERS+1)}}const C=a.dataset[Ne.KEY];let O;C&&(O=JSON.parse(C));const A=a.getBoundingClientRect(),S=window.getComputedStyle(a);if(A.width===0||A.height===0||S.display==="none")return null;let R=a.getAttribute("data-mid");R||(R=Math.random().toString(36).substring(2,11),a.setAttribute("data-mid",R));const E=parseInt(S.zIndex),$=(isNaN(E)?0:E)+i;let W;if(a.tagName==="IMG")W=a.src;else if(a.tagName.toLowerCase()==="svg"){const m=a.cloneNode(!0),k=w==null?void 0:w.color,z=w==null?void 0:w.fill,b=w==null?void 0:w.stroke,x=w==null?void 0:w.opacity,P=(T,de)=>{const J=window.getComputedStyle(T),ge=de,ct=J.fill===J.color,lt=J.stroke===J.color,xe=z||(ct?k:void 0)||J.fill;xe&&xe!=="none"&&(ge.style.fill=xe);const Se=b||(lt?k:void 0)||J.stroke;Se&&Se!=="none"&&(ge.style.stroke=Se),J.strokeWidth&&J.strokeWidth!=="0px"&&(ge.style.strokeWidth=J.strokeWidth);const Be=k||J.color;Be&&(ge.style.color=Be);const Ee=x||J.opacity;Ee&&Ee!=="1"&&(ge.style.opacity=Ee);for(let we=0;we<T.children.length;we++)P(T.children[we],de.children[we])};P(a,m);const V=a.getBoundingClientRect(),ie=window.devicePixelRatio*c;m.hasAttribute("viewBox")||m.setAttribute("viewBox",`0 0 ${V.width} ${V.height}`),m.setAttribute("width",(V.width*ie).toString()),m.setAttribute("height",(V.height*ie).toString());let U=new XMLSerializer().serializeToString(m);U.includes("xmlns=")||(U=U.replace("<svg",'<svg xmlns="http://www.w3.org/2000/svg"')),W=`data:image/svg+xml;utf8,${encodeURIComponent(U)}`}else if(S.backgroundImage&&S.backgroundImage!=="none"){const m=S.backgroundImage.match(/url\(['"]?(.*?)['"]?\)/);m&&(W=m[1])}const L={backgroundColor:S.backgroundColor,backgroundImage:S.backgroundImage,opacity:a.dataset[Z.KEY]===Z.VALUES.HIDE?1:parseFloat(S.opacity),zIndex:$,borderRadius:S.borderRadius,borderColor:S.borderColor,borderWidth:S.borderWidth,boxShadow:S.boxShadow,imageSrc:W,isTraveler:p},K=L;let te,re;const M=[];return a.tagName.toLowerCase()!=="svg"&&Array.from(a.childNodes).forEach(m=>{const k=m.nodeType===Node.TEXT_NODE?h:d,z=Ue(m,e,k,r,$,c,m.nodeType===Node.TEXT_NODE?y:void 0,m.nodeType===Node.TEXT_NODE&&Object.keys(w).length>0?w:void 0);z&&M.push(z)}),{id:R,type:"BOX",element:a,rect:{x:A.left+window.scrollX,y:A.top+window.scrollY,width:A.width,height:A.height},styles:K,textContent:te,textStyles:re,dirtyMask:e,visibility:h,isTraveler:p,captureLayer:r,nativeLayer:y,nativeStyles:y!==void 0?_e(ne({},L),{backgroundColor:(X=w.backgroundColor)!=null?X:L.backgroundColor,backgroundImage:(Q=w.backgroundImage)!=null?Q:L.backgroundImage,opacity:(ee=w.opacity)!=null?ee:L.opacity,zIndex:w.zIndex!==void 0?w.zIndex+$:L.zIndex,borderRadius:(H=w.borderRadius)!=null?H:L.borderRadius,borderColor:(q=w.borderColor)!=null?q:L.borderColor,borderWidth:(le=w.borderWidth)!=null?le:L.borderWidth,boxShadow:(he=w.boxShadow)!=null?he:L.boxShadow,isTraveler:L.isTraveler,transform:w.transform}):void 0,nativeRect:y!==void 0?{x:w.x!==void 0?parseFloat(w.x):A.left+window.scrollX,y:w.y!==void 0?parseFloat(w.y):A.top+window.scrollY,width:w.width!==void 0?parseFloat(w.width):A.width,height:w.height!==void 0?parseFloat(w.height):A.height}:void 0,isFixed:S.position==="fixed",children:M,shaderHooks:O}}function rt(n,e){e.size!==0&&e.forEach((t,r)=>{var c,s,o,a;const i=n.get(r);!i||!i.userData.basePosition||(G.forceUpdateUniforms(i.material,{backgroundColor:t.backgroundColor,backgroundImage:t.backgroundImage,boxShadow:t.boxShadow,opacity:t.opacity,borderRadius:(s=t.borderRadius)!=null?s:(c=i.userData.baseStyles)==null?void 0:c.borderRadius}),i.userData.nativeMesh&&G.forceUpdateUniforms(i.userData.nativeMesh.material,{backgroundColor:t.backgroundColor,backgroundImage:t.backgroundImage,boxShadow:t.boxShadow,opacity:t.opacity,borderRadius:(a=t.borderRadius)!=null?a:(o=i.userData.baseStyles)==null?void 0:o.borderRadius}))})}class it{constructor(e,t,r,i){u(this,"target");u(this,"renderer");u(this,"registry");u(this,"isTravelEnabled",!1);u(this,"tracker");this.target=e,this.renderer=t,this.registry=r,this.tracker=new Re(e,{resizeDebounce:i.resizeDebounce}),this.tracker.onLayoutChange.add((c,s)=>{document.querySelector(`[${_.NAME}~='${_.VALUES.TRAVELER}']`)!==null&&!this.isTravelEnabled&&(this.isTravelEnabled=!0,this.renderer.createRenderTarget());const a=Ue(this.target,c,j,1,0,this.renderer.qualityFactor);a&&this.renderer.syncScene(a,s)}),this.tracker.onStyleChange.add(c=>{rt(this.registry,c)}),this.tracker.onRender.add(()=>{this.renderer.syncMeshesByDOM(),this.renderer.render()})}start(){this.tracker.start()}stop(){this.tracker.stop()}}class st{constructor(){u(this,"store");this.store=new WeakMap}register(e,t){this.store.set(e,t)}get(e){return this.store.get(e)}has(e){return this.store.has(e)}remove(e){this.store.delete(e)}}class nt{constructor(e,t){u(this,"renderer");u(this,"syncer");u(this,"target");u(this,"registry");var i,c,s;if(this.target=e,this.registry=new st,!document.getElementById("mirage-engine-styles")){const o=document.createElement("style");o.id="mirage-engine-styles",o.textContent=`
184
+ `,f=c||a?d+h+((i==null?void 0:i.uvModifier)||""):"",g=c||a?ke.baseColorChunk:"",p=(i==null?void 0:i.colorModifier)||"",w=Ae.fragmentShader.replace("#INJECT_DECLARATIONS",l).replace("#INJECT_UV_MODIFIER",f).replace("#INJECT_BASE_COLOR",g).replace("#INJECT_COLOR_MODIFIER",p),y=ce(n.backgroundColor),C=ce(n.borderColor),O={uSize:{value:new v.Vector2(e,t)},uMeshSize:{value:new v.Vector2(e,t)},uShadowColor:{value:new v.Vector4(0,0,0,0)},uShadowOffset:{value:new v.Vector2(0,0)},uShadowBlur:{value:0},uShadowSpread:{value:0},uBgColor:{value:new v.Vector4(y.color.r,y.color.g,y.color.b,y.alpha)},uBorderColor:{value:new v.Vector4(C.color.r,C.color.g,C.color.b,C.alpha)},uBorderRadius:{value:new v.Vector4(0,0,0,0)},uBorderWidth:{value:ae(n.borderWidth)},uOpacity:{value:(S=n.opacity)!=null?S:1},uTexture:{value:null},uTextureRepeat:{value:new v.Vector2(1,1)},uTextureOffset:{value:new v.Vector2(0,0)},uGradientCount:{value:0},uGradientAngle:{value:0},uGradientColors:{value:Array.from({length:8},()=>new v.Vector4(0,0,0,0))},uGradientStops:{value:new Float32Array(8)}};Ie(O.uBorderRadius.value,n.borderRadius,Math.min(e,t)),c&&(O.uTexture.value=r);const A=new v.ShaderMaterial({uniforms:ne(ne({},O),o),vertexShader:Ae.vertexShader,fragmentShader:w,transparent:!0,side:v.FrontSide});return n.backgroundImage&&be(A,{backgroundImage:n.backgroundImage}),A}function Ze(n,e,t,r,i){const c=ae(e.borderWidth);be(n,{width:t,height:r,borderRadius:e.borderRadius,borderWidth:c,backgroundColor:e.backgroundColor,borderColor:e.borderColor,opacity:e.opacity,texture:i,backgroundImage:e.backgroundImage,boxShadow:e.boxShadow})}function be(n,e){var r,i,c;if(e.boxShadow!==void 0){const s=He(e.boxShadow);s?(n.uniforms.uShadowColor.value.set(s.color.r,s.color.g,s.color.b,s.alpha),n.uniforms.uShadowOffset.value.set(s.offsetX,s.offsetY),n.uniforms.uShadowBlur.value=s.blurRadius,n.uniforms.uShadowSpread.value=s.spreadRadius,n.userData.shadowPadding=s.blurRadius+s.spreadRadius+Math.max(Math.abs(s.offsetX),Math.abs(s.offsetY))):(n.uniforms.uShadowColor.value.w=0,n.userData.shadowPadding=0)}if(e.width!==void 0&&e.height!==void 0&&n.uniforms.uSize.value.set(e.width,e.height),n.uniforms.uMeshSize){const s=n.userData.shadowPadding||0,o=e.width!==void 0?e.width:n.uniforms.uSize.value.x,a=e.height!==void 0?e.height:n.uniforms.uSize.value.y;n.uniforms.uMeshSize.value.set(o+s*2,a+s*2)}if(e.borderRadius!==void 0){const s=e.width!==void 0&&e.height!==void 0?Math.min(e.width,e.height):Math.min(n.uniforms.uSize.value.x,n.uniforms.uSize.value.y);Ie(n.uniforms.uBorderRadius.value,e.borderRadius,s)}if(e.borderWidth!==void 0&&(n.uniforms.uBorderWidth.value=e.borderWidth),e.backgroundColor!==void 0)if(Array.isArray(e.backgroundColor)){const s=e.backgroundColor[3]!==void 0?e.backgroundColor[3]:n.uniforms.uBgColor.value.w;n.uniforms.uBgColor.value.set(e.backgroundColor[0],e.backgroundColor[1],e.backgroundColor[2],s)}else if(typeof e.backgroundColor=="string"){const s=ce(e.backgroundColor);n.uniforms.uBgColor.value.set(s.color.r,s.color.g,s.color.b,s.alpha)}else{const s=n.uniforms.uBgColor.value.w;n.uniforms.uBgColor.value.set(e.backgroundColor.r,e.backgroundColor.g,e.backgroundColor.b,s)}if(e.borderColor!==void 0)if(Array.isArray(e.borderColor)){const s=n.uniforms.uBorderColor.value.w;n.uniforms.uBorderColor.value.set(e.borderColor[0],e.borderColor[1],e.borderColor[2],s)}else if(typeof e.borderColor=="string"){const s=ce(e.borderColor);n.uniforms.uBorderColor.value.set(s.color.r,s.color.g,s.color.b,s.alpha)}else{const s=n.uniforms.uBorderColor.value.w;n.uniforms.uBorderColor.value.set(e.borderColor.r,e.borderColor.g,e.borderColor.b,s)}e.opacity!==void 0&&(n.uniforms.uOpacity.value=e.opacity),e.bgOpacity!==void 0&&(n.uniforms.uBgColor.value.w=e.bgOpacity),e.borderOpacity!==void 0&&(n.uniforms.uBorderColor.value.w=e.borderOpacity),n.uniforms.uTexture&&e.texture!==void 0&&(n.uniforms.uTexture.value=e.texture);const t=e.texture!==void 0?e.texture:(r=n.uniforms.uTexture)==null?void 0:r.value;if(t&&(t.image instanceof ImageBitmap||t.image instanceof HTMLImageElement||t.image instanceof HTMLCanvasElement)){const s=t.image.naturalWidth||t.image.videoWidth||t.image.width,o=t.image.naturalHeight||t.image.videoHeight||t.image.height,a=(i=e.width)!=null?i:n.uniforms.uSize.value.x,l=(c=e.height)!=null?c:n.uniforms.uSize.value.y;if(s&&o&&a&&l){const d=s/o,h=a/l;if(d>h){const f=h/d;n.uniforms.uTextureRepeat.value.set(f,1),n.uniforms.uTextureOffset.value.set((1-f)/2,0)}else{const f=d/h;n.uniforms.uTextureRepeat.value.set(1,f),n.uniforms.uTextureOffset.value.set(0,(1-f)/2)}}}else n.uniforms.uTextureRepeat&&(n.uniforms.uTextureRepeat.value.set(1,1),n.uniforms.uTextureOffset.value.set(0,0));if(e.backgroundImage!==void 0){const s=We(e.backgroundImage);if(s){n.uniforms.uGradientCount.value=s.stops.length,n.uniforms.uGradientAngle.value=s.angle;for(let o=0;o<8;o++)if(o<s.stops.length){const a=s.stops[o];n.uniforms.uGradientColors.value[o].set(a.color.r,a.color.g,a.color.b,a.alpha),n.uniforms.uGradientStops.value[o]=a.stop}else n.uniforms.uGradientColors.value[o].set(0,0,0,0),n.uniforms.uGradientStops.value[o]=1}else n.uniforms.uGradientCount.value=0}for(const s of Object.keys(e))s!=="width"&&s!=="height"&&s!=="borderRadius"&&s!=="borderWidth"&&s!=="backgroundColor"&&s!=="borderColor"&&s!=="opacity"&&s!=="bgOpacity"&&s!=="borderOpacity"&&s!=="texture"&&s!=="backgroundImage"&&s!=="boxShadow"&&n.uniforms[s]!==void 0&&(n.uniforms[s].value!==void 0&&n.uniforms[s].value!==null&&typeof n.uniforms[s].value.set=="function"?Array.isArray(e[s])?n.uniforms[s].value.set(...e[s]):e[s]!==void 0&&(e[s].copy?n.uniforms[s].value.copy(e[s]):n.uniforms[s].value=e[s]):n.uniforms[s].value=e[s])}function Ie(n,e,t=0){var a,l,d,h;if(e==null){n.set(0,0,0,0);return}if(typeof e=="number"){n.set(e,e,e,e);return}if(Array.isArray(e)){n.set(e[0],e[1],e[2],e[3]);return}const r=e.split("/")[0].trim().split(/\s+/),i=ae(r[0],t),c=ae((a=r[1])!=null?a:r[0],t),s=ae((l=r[2])!=null?l:r[0],t),o=ae((h=(d=r[3])!=null?d:r[1])!=null?h:r[0],t);n.set(i,c,s,o)}const G={create(n,e,t,r,i,c=2,s=null,o){return n==="BOX"?Je(e,r,i,s,o):n==="TEXT"?new Pe(t||"",e,r,i,c):new v.MeshBasicMaterial({visible:!1})},update(n,e,t,r,i,c,s=2,o){e==="BOX"?Ze(n,t,i,c,o):e==="TEXT"&&n.updateText(r||"",t,i,c,s)},forceUpdateUniforms(n,e){be(n,e)}};class Qe{constructor(e,t=!0){u(this,"observer");u(this,"textures",new WeakMap);u(this,"loadStatus",new WeakMap);u(this,"elementUrls",new WeakMap);u(this,"onUpdate");this.onUpdate=e,t&&(this.observer=new IntersectionObserver(r=>{for(const i of r){const c=i.target;i.isIntersecting?this.loadTexture(c):this.disposeTexture(c)}},{rootMargin:"300px"}))}register(e,t){if(e.nodeType!==Node.ELEMENT_NODE)return;this.elementUrls.get(e)!==t&&(this.elementUrls.set(e,t),this.observer?(this.observer.unobserve(e),this.observer.observe(e)):this.loadTexture(e))}unregister(e){e.nodeType===Node.ELEMENT_NODE&&this.observer&&this.observer.unobserve(e),this.disposeTexture(e),this.elementUrls.delete(e),this.loadStatus.delete(e)}loadTexture(e){return ze(this,null,function*(){if(this.loadStatus.get(e)||this.textures.has(e))return;const t=this.elementUrls.get(e);if(t){this.loadStatus.set(e,!0);try{let r;if(t.startsWith("data:image/svg+xml"))r=yield new Promise((c,s)=>{const o=new Image;o.onload=()=>c(o),o.onerror=s,o.src=t});else{const s=yield(yield fetch(t)).blob();r=yield createImageBitmap(s,{imageOrientation:"flipY"})}if(this.elementUrls.get(e)!==t){"close"in r&&r.close();return}const i=new v.Texture(r);r instanceof HTMLImageElement||(i.flipY=!1),i.colorSpace=v.LinearSRGBColorSpace,i.needsUpdate=!0,this.textures.set(e,i),this.onUpdate(e,i)}catch(r){console.warn("[MirageEngine] Failed to load texture:",t,r)}finally{this.elementUrls.has(e)&&this.loadStatus.set(e,!1)}}})}disposeTexture(e){const t=this.textures.get(e);t&&(t.dispose(),this.textures.delete(e),this.onUpdate(e,null)),this.loadStatus.set(e,!1)}get(e){return this.textures.get(e)}disposeAll(){this.observer&&this.observer.disconnect()}}class et{constructor(e,t,r,i){u(this,"canvas");u(this,"scene");u(this,"camera");u(this,"renderer");u(this,"renderTargets",[]);u(this,"renderOrder",0);u(this,"qualityFactor",2);u(this,"mode","overlay");u(this,"canvasSize","viewport");u(this,"clipArea",1);u(this,"targetLayer","base");u(this,"overscan",200);u(this,"target");u(this,"mountContainer");u(this,"registry");u(this,"targetRect");u(this,"travelersByLayer",Array.from({length:_.MAX_LAYERS},()=>new Set));u(this,"textureManager");u(this,"fixedMeshes",new Set);var o,a,l,d,h;this.target=e,this.mountContainer=r,this.registry=i,this.mode=(o=t.mode)!=null?o:"overlay",this.canvasSize=(a=t.canvasSize)!=null?a:"viewport",this.clipArea=(l=t.travelerClipArea)!=null?l:1,this.targetLayer=(d=t.layer)!=null?d:"base",this.textureManager=new Qe((f,g)=>{const p=this.registry.get(f);p&&p.material instanceof v.ShaderMaterial&&G.forceUpdateUniforms(p.material,{texture:g})},this.isViewport),this.canvas=document.createElement("canvas"),this.scene=new v.Scene,this.targetRect=this.target.getBoundingClientRect();const c=this.isViewport?window.innerWidth+this.overscan*2:this.targetRect.width,s=this.isViewport?window.innerHeight+this.overscan*2:this.targetRect.height;this.camera=new v.OrthographicCamera(c/-2,c/2,s/2,s/-2,1,1e3),this.camera.position.z=100,this.camera.layers.set(this.getSceneLayer()),this.renderer=new v.WebGLRenderer({canvas:this.canvas,alpha:!0,antialias:!0}),v.ColorManagement.enabled=!1,this.renderer.outputColorSpace=v.LinearSRGBColorSpace,this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(c,s),this.applyTextQuality((h=t.quality)!=null?h:"medium")}get isViewport(){return this.mode==="overlay"&&this.canvasSize==="viewport"}getSceneLayer(){return typeof this.targetLayer=="number"?this.targetLayer:this.targetLayer==="selected"?N.SELECTED:N.BASE}createRenderTarget(){for(let e=0;e<_.MAX_LAYERS;e++){const t=this.isViewport?window.innerWidth+this.overscan*2:this.targetRect.width,r=this.isViewport?window.innerHeight+this.overscan*2:this.targetRect.height;this.renderTargets.push(new v.WebGLRenderTarget(t*this.qualityFactor,r*this.qualityFactor,{minFilter:v.LinearFilter,magFilter:v.LinearFilter,format:v.RGBAFormat,stencilBuffer:!1,depthBuffer:!0}))}}applyTextQuality(e){if(typeof e=="number"){this.qualityFactor=Math.max(.1,e);return}switch(e){case"low":this.qualityFactor=1;break;case"high":this.qualityFactor=4;break;case"medium":this.qualityFactor=2;break;default:this.qualityFactor=2;break}}mount(){this.mountContainer.prepend(this.canvas),this.canvas.style.pointerEvents=this.mode==="overlay"?"none":"auto",this.updateCanvasLayout()}updateCanvasLayout(){const e=this.isViewport?window.innerWidth+this.overscan*2:this.targetRect.width,t=this.isViewport?window.innerHeight+this.overscan*2:this.targetRect.height;this.canvas.style.width=`${e}px`,this.canvas.style.height=`${t}px`,this.mode==="duplicate"?(this.canvas.style.position="",this.canvas.style.top="",this.canvas.style.left="",this.canvas.style.display="block"):(this.canvas.style.position=this.isViewport?"fixed":"absolute",this.canvas.style.top=this.isViewport?`-${this.overscan}px`:`${this.target.offsetTop}px`,this.canvas.style.left=this.isViewport?`-${this.overscan}px`:`${this.target.offsetLeft}px`,this.canvas.style.display="block")}updateUniforms(e,t){const r=this.registry.get(e);r&&(r.traverse(i=>{i.isMesh&&i.material&&G.forceUpdateUniforms(i.material,t)}),r.userData.nativeMesh&&r.userData.nativeMesh.traverse(i=>{i.isMesh&&i.material&&G.forceUpdateUniforms(i.material,t)}))}dispose(){this.renderer.dispose(),this.canvas.remove(),this.textureManager.disposeAll()}setSize(e,t){this.renderer.setSize(e,t);for(const r of this.renderTargets)r.setSize(e*this.qualityFactor,t*this.qualityFactor);this.camera.left=e/-2,this.camera.right=e/2,this.camera.top=t/2,this.camera.bottom=t/-2,this.camera.updateProjectionMatrix()}syncScene(e,t){const r=this.target.getBoundingClientRect(),i=this.isViewport?window.innerWidth+this.overscan*2:r.width,c=this.isViewport?window.innerHeight+this.overscan*2:r.height,s=this.isViewport?this.canvas.clientWidth:this.targetRect.width,o=this.isViewport?this.canvas.clientHeight:this.targetRect.height,a=Math.abs(i-s)>.1||Math.abs(c-o)>.1,l=this.mode==="overlay"&&(Math.abs(r.top-this.targetRect.top)>.1||Math.abs(r.left-this.targetRect.left)>.1);a?(this.targetRect=r,this.setSize(i,c),this.updateCanvasLayout()):l?(this.targetRect=r,this.updateCanvasLayout()):this.targetRect=r,this.renderOrder=0,this.reconcileNode(e),t.size>0&&t.forEach(d=>{const h=this.registry.get(d);if(h){this.scene.remove(h);for(const f of this.travelersByLayer)f.delete(h);this.fixedMeshes.delete(h),h.geometry.dispose(),h.userData.nativeMesh&&(this.scene.remove(h.userData.nativeMesh),Array.isArray(h.userData.nativeMesh.material)?h.userData.nativeMesh.material.forEach(f=>f.dispose()):h.userData.nativeMesh.material.dispose(),h.userData.nativeMesh.geometry.dispose()),h.traverse(f=>{f instanceof v.Mesh&&(f.geometry&&f.geometry.dispose(),f.material&&(Array.isArray(f.material)?f.material.forEach(g=>g.dispose()):f.material.dispose()))}),this.registry.remove(d),this.textureManager.unregister(d)}})}reconcileNode(e){var i,c;let t=this.registry.get(e.element);const r=JSON.stringify(e.shaderHooks||null);if(t&&t.userData.shaderHash!==r&&(this.scene.remove(t),t.geometry.dispose(),t.material instanceof v.Material&&t.material.dispose(),this.registry.remove(e.element),t=void 0),!t){const s=new v.PlaneGeometry(1,1),o=e.isTraveler?(i=this.renderTargets[e.captureLayer-2])==null?void 0:i.texture:this.textureManager.get(e.element),a=G.create("BOX",e.styles,"",e.rect.width,e.rect.height,this.qualityFactor,o,e.shaderHooks);t=new v.Mesh(s,a),e.type==="TEXT"&&(t.name="BG_MESH"),this.scene.add(t),this.registry.register(e.element,t),t.userData.baseMaterial=a,t.userData.domElement=e.element,t.userData.shaderHash=r}if((c=e.nativeStyles)!=null&&c.transform?t.userData.nativeTransform=e.nativeStyles.transform:t.userData.nativeTransform=void 0,this.updateMeshProperties(t,e),this.updateMeshLayers(t,e),e.isTraveler)for(let s=0;s<_.MAX_LAYERS;s++)s===e.captureLayer-2?this.travelersByLayer[s].add(t):this.travelersByLayer[s].delete(t);else for(const s of this.travelersByLayer)s.delete(t);if(e.isFixed?this.fixedMeshes.add(t):this.fixedMeshes.delete(t),e.styles.imageSrc?this.textureManager.register(e.element,e.styles.imageSrc):this.textureManager.unregister(e.element),e.type==="BOX")for(const s of e.children)this.reconcileNode(s);else e.type==="TEXT"&&(this.reconcileTextChild(t,e,!1),t.userData.nativeMesh&&e.nativeStyles&&this.reconcileTextChild(t.userData.nativeMesh,e,!0))}reconcileTextChild(e,t,r){var l;const i=t.textLines||[{text:t.textContent||"",rect:t.rect}],c=r?t.nativeStyles:t.textStyles,s=JSON.stringify(c)+t.textContent+i.map(d=>d.text).join("|"),o=(l=e.userData)==null?void 0:l.textChildStyleHash;if(t.dirtyMask&ye||s!==o){e.children.filter(p=>p.name.startsWith("TEXT_CHILD")).forEach(p=>{var y;const w=p;(y=w.material.map)==null||y.dispose(),w.geometry.dispose(),e.remove(w)});const h=t.rect,f=h.x+h.width/2,g=h.y+h.height/2;i.forEach((p,w)=>{const y=G.create("TEXT",c,p.text,p.rect.width,p.rect.height,this.qualityFactor),C=new v.PlaneGeometry(1,1),O=new v.Mesh(C,y);O.name=`TEXT_CHILD_${w}`;const A=t.rect.width===0?1:p.rect.width/t.rect.width,S=t.rect.height===0?1:p.rect.height/t.rect.height;O.scale.set(A,S,1);const R=p.rect.x+p.rect.width/2,E=p.rect.y+p.rect.height/2,$=R-f,W=-(E-g);O.position.set(t.rect.width===0?0:$/t.rect.width,t.rect.height===0?0:W/t.rect.height,.005),e.add(O)}),e.userData.textChildStyleHash=s}e.children.forEach(d=>{if(!d.name.startsWith("TEXT_CHILD"))return;const h=d;if(r&&t.nativeLayer!==void 0)h.layers.set(N.HIDDEN),t.visibility&j&&h.layers.enable(N.getCaptureLayer(t.nativeLayer));else{const f=t.visibility&j?N.BASE:N.HIDDEN;if(h.layers.set(f),t.visibility&oe&&h.layers.enable(N.SELECTED),t.visibility&j)if(!r&&t.nativeLayer!==void 0&&t.nativeStyles!==void 0)for(let g=t.captureLayer;g<=_.MAX_LAYERS+1;g++)g!==t.nativeLayer&&h.layers.enable(N.getCaptureLayer(g));else for(let g=t.captureLayer;g<=_.MAX_LAYERS+1;g++)h.layers.enable(N.getCaptureLayer(g))}})}updateMeshProperties(e,t){var S,R,E,$,W;const{rect:r,styles:i}=t,c=this.renderer.getPixelRatio(),s=this.renderer.domElement.width/c,o=this.renderer.domElement.height/c;e.material=e.userData.baseMaterial;let a=((S=e.material.userData)==null?void 0:S.shadowPadding)||0;e.scale.set(r.width+a*2,r.height+a*2,1),e.userData.domRect={x:r.x,y:r.y,width:r.width,height:r.height};const l=.001;this.renderOrder++;const d=this.targetRect.left+window.scrollX,h=this.targetRect.top+window.scrollY;let f,g;if(this.isViewport)f=r.x-window.innerWidth/2+r.width/2,g=-r.y+window.innerHeight/2-r.height/2;else{const L=r.x-d,K=r.y-h;f=L-s/2+r.width/2,g=-K+o/2-r.height/2}e.position.set(f,g,i.zIndex+this.renderOrder*l);const p=r.x,w=r.y;e.userData.basePosition={x:f,y:g},e.userData.originalBasePosition={x:f,y:g},e.userData.baseSize={width:r.width,height:r.height},e.userData.baseDOM={x:p,y:w},e.userData.isFixed=t.isFixed,e.userData.initialScroll={x:window.scrollX,y:window.scrollY};const y=t.element.nodeType===Node.TEXT_NODE?t.element.parentElement:t.element,C=window.getComputedStyle(y);let O=0,A=0;if(C.transform&&C.transform!=="none"){const L=new DOMMatrix(C.transform);O=L.m41,A=L.m42}if(e.userData.baseTransform={x:O,y:A},delete e.userData.originRatioX,delete e.userData.originRatioY,G.update(e.userData.baseMaterial,"BOX",i,"",r.width,r.height,this.qualityFactor,t.isTraveler?(R=this.renderTargets[t.captureLayer-2])==null?void 0:R.texture:this.textureManager.get(t.element)),t.nativeStyles&&t.nativeRect){if(!e.userData.nativeMesh){const H=G.create("BOX",t.nativeStyles,"",t.nativeRect.width,t.nativeRect.height,this.qualityFactor,t.isTraveler?(E=this.renderTargets[t.captureLayer-2])==null?void 0:E.texture:this.textureManager.get(t.element),t.shaderHooks),q=new v.Mesh(e.geometry,H);t.type==="TEXT"&&(q.name="BG_MESH"),this.scene.add(q),e.userData.nativeMesh=q}const L=e.userData.nativeMesh;let K,te;if(this.isViewport)K=t.nativeRect.x-window.innerWidth/2+t.nativeRect.width/2,te=-t.nativeRect.y+window.innerHeight/2-t.nativeRect.height/2;else{const H=t.nativeRect.x-d,q=t.nativeRect.y-h;K=H-s/2+t.nativeRect.width/2,te=-q+o/2-t.nativeRect.height/2}let re=t.nativeRect.width,M=t.nativeRect.height,X=K,Q=te;if(t.nativeStyles.transform){const H=t.nativeStyles.transform,q=H.match(/scale\(([\d.]+%?)\)/);if(q){let b=parseFloat(q[1]);q[1].includes("%")&&(b/=100),re*=b,M*=b}const le=H.match(/scaleX\(([\d.]+%?)\)/);if(le){let b=parseFloat(le[1]);le[1].includes("%")&&(b/=100),re*=b}const he=H.match(/scaleY\(([\d.]+%?)\)/);if(he){let b=parseFloat(he[1]);he[1].includes("%")&&(b/=100),M*=b}const m=H.match(/translate\(([^,]+),\s*([^)]+)\)/);if(m){const b=m[1].trim(),x=m[2].trim();let P=parseFloat(b);b.includes("%")&&(P=P/100*t.nativeRect.width);let V=parseFloat(x);x.includes("%")&&(V=V/100*t.nativeRect.height),X+=P,Q-=V}const k=H.match(/translateX\(([^)]+)\)/);if(k){const b=k[1].trim();let x=parseFloat(b);b.includes("%")&&(x=x/100*t.nativeRect.width),X+=x}const z=H.match(/translateY\(([^)]+)\)/);if(z){const b=z[1].trim();let x=parseFloat(b);b.includes("%")&&(x=x/100*t.nativeRect.height),Q-=x}}let ee=(($=L.material.userData)==null?void 0:$.shadowPadding)||0;L.scale.set(re+ee*2,M+ee*2,1),L.position.set(X,Q,t.nativeStyles.zIndex+this.renderOrder*l),G.update(L.material,"BOX",t.nativeStyles,"",t.nativeRect.width,t.nativeRect.height,this.qualityFactor,t.isTraveler?(W=this.renderTargets[t.captureLayer-2])==null?void 0:W.texture:this.textureManager.get(t.element))}else e.userData.nativeMesh&&(this.scene.remove(e.userData.nativeMesh),e.userData.nativeMesh.material instanceof v.Material&&e.userData.nativeMesh.material.dispose(),delete e.userData.nativeMesh)}updateMeshLayers(e,t){const r=t.visibility&j?N.BASE:N.HIDDEN;if(e.layers.set(r),t.visibility&oe&&e.layers.enable(N.SELECTED),e.userData.nativeMesh&&t.nativeLayer!==void 0){const i=e.userData.nativeMesh;if(i.layers.set(N.HIDDEN),t.visibility&j){i.layers.enable(N.getCaptureLayer(t.nativeLayer));for(let c=t.captureLayer;c<=_.MAX_LAYERS+1;c++)c!==t.nativeLayer&&e.layers.enable(N.getCaptureLayer(c))}}else if(t.visibility&j)for(let i=t.captureLayer;i<=_.MAX_LAYERS+1;i++)e.layers.enable(N.getCaptureLayer(i))}captureRenderTarget(e,t,r){if(e.size===0||!r)return;const i=new v.Color,c=this.renderer.getClearAlpha();this.renderer.getClearColor(i),this.renderer.setClearColor(0,0),this.renderer.setRenderTarget(r),this.renderer.clear(),this.renderer.autoClear=!1,this.renderer.setScissorTest(!0),this.camera.layers.set(t);const s=new v.Vector3,o=this.isViewport?window.innerWidth+this.overscan*2:this.targetRect.width,a=this.isViewport?window.innerHeight+this.overscan*2:this.targetRect.height,l=this.renderer.getPixelRatio();for(const d of e){s.setFromMatrixPosition(d.matrixWorld),s.project(this.camera);const h=(s.x+1)/2*o,f=(s.y+1)/2*a;let g=0,p=1;typeof this.clipArea=="number"?p=this.clipArea:this.clipArea.endsWith("%")?p=parseFloat(this.clipArea)/100:this.clipArea.endsWith("px")&&(g=parseFloat(this.clipArea));const w=d.scale.x*p+.5,y=d.scale.y*p+.5,C=h-w/2,O=f-y/2,A=(C*this.qualityFactor-g)/l,S=(O*this.qualityFactor-g)/l,R=(w*this.qualityFactor+g*2)/l,E=(y*this.qualityFactor+g*2)/l;this.renderer.setScissor(A,S,R,E),this.renderer.render(this.scene,this.camera)}this.renderer.setScissorTest(!1),this.renderer.autoClear=!0,this.renderer.setRenderTarget(null),this.camera.layers.set(this.getSceneLayer()),this.renderer.setClearColor(i,c)}render(){for(let e=0;e<_.MAX_LAYERS;e++){const t=e+1;this.captureRenderTarget(this.travelersByLayer[e],N.getCaptureLayer(t),this.renderTargets[e])}this.renderer.render(this.scene,this.camera)}syncMeshesByDOM(){const e=this.targetRect.left+window.scrollX,t=this.targetRect.top+window.scrollY,r=this.renderer.getPixelRatio(),i=this.renderer.domElement.width/r,c=this.renderer.domElement.height/r;this.scene.children.forEach(s=>{var h,f;const o=s;if(!o.userData||!o.userData.domElement)return;const a=o.userData.domElement;if(!a.isConnected)return;let l;if(a.nodeType===Node.TEXT_NODE){const g=document.createRange();g.selectNode(a),l=g.getBoundingClientRect()}else l=a.getBoundingClientRect();const d=o.userData.domRect;if(!d||Math.abs(l.x-d.x)>.5||Math.abs(l.y-d.y)>.5||Math.abs(l.width-d.width)>.5||Math.abs(l.height-d.height)>.5){o.userData.domRect={x:l.x,y:l.y,width:l.width,height:l.height};let g,p;if(this.isViewport)g=l.x-window.innerWidth/2+l.width/2,p=-l.y+window.innerHeight/2-l.height/2;else{const y=l.x-e,C=l.y-t;g=y-i/2+l.width/2,p=-C+c/2-l.height/2}o.position.setX(g),o.position.setY(p);let w=((h=o.material.userData)==null?void 0:h.shadowPadding)||0;if(o.scale.set(l.width+w*2,l.height+w*2,1),o.updateMatrixWorld(),o.material instanceof v.ShaderMaterial&&G.forceUpdateUniforms(o.material,{width:l.width,height:l.height}),o.userData.nativeMesh){const y=o.userData.nativeMesh;let C=l.width,O=l.height,A=g,S=p;if(o.userData.nativeTransform){const E=o.userData.nativeTransform,$=E.match(/scale\(([\d.]+%?)\)/);if($){let M=parseFloat($[1]);$[1].includes("%")&&(M/=100),C*=M,O*=M}const W=E.match(/scaleX\(([\d.]+%?)\)/);if(W){let M=parseFloat(W[1]);W[1].includes("%")&&(M/=100),C*=M}const L=E.match(/scaleY\(([\d.]+%?)\)/);if(L){let M=parseFloat(L[1]);L[1].includes("%")&&(M/=100),O*=M}const K=E.match(/translate\(([^,]+),\s*([^)]+)\)/);if(K){const M=K[1].trim(),X=K[2].trim();let Q=parseFloat(M);M.includes("%")&&(Q=Q/100*l.width);let ee=parseFloat(X);X.includes("%")&&(ee=ee/100*l.height),A+=Q,S-=ee}const te=E.match(/translateX\(([^)]+)\)/);if(te){const M=te[1].trim();let X=parseFloat(M);M.includes("%")&&(X=X/100*l.width),A+=X}const re=E.match(/translateY\(([^)]+)\)/);if(re){const M=re[1].trim();let X=parseFloat(M);M.includes("%")&&(X=X/100*l.height),S-=X}}let R=((f=y.material.userData)==null?void 0:f.shadowPadding)||0;y.position.setX(A),y.position.setY(S),y.scale.set(C+R*2,O+R*2,1),y.updateMatrixWorld(),y.material instanceof v.ShaderMaterial&&G.forceUpdateUniforms(y.material,{width:C,height:O})}}})}}function tt(n){const e=n.textContent||"",t=[];let r="",i=null,c=-1;const s=(l,d)=>{for(let h=0;h<l.length;h++){const f=l[h],g=document.createRange();g.setStart(n,d+h),g.setEnd(n,d+h+1);const p=g.getBoundingClientRect();if(p.width===0&&p.height===0){r+=f;continue}c===-1||Math.abs(p.top-c)>p.height/2?(r&&i&&t.push({text:r,rect:{left:i.left,top:i.top,width:i.right-i.left,height:i.bottom-i.top}}),r=f,i={left:p.left,top:p.top,right:p.right,bottom:p.bottom},c=p.top):(r+=f,i&&(i.left=Math.min(i.left,p.left),i.top=Math.min(i.top,p.top),i.right=Math.max(i.right,p.right),i.bottom=Math.max(i.bottom,p.bottom)))}},o=e.match(/[^\s\-]+\-?|\-|\s+/g)||[];let a=0;for(const l of o){const d=document.createRange();d.setStart(n,a),d.setEnd(n,a+l.length);const h=d.getClientRects();if(h.length>1)s(l,a);else{const f=h.length===1?h[0]:d.getBoundingClientRect();if(f.width===0&&f.height===0){r+=l,a+=l.length;continue}c===-1||Math.abs(f.top-c)>f.height/2?(r&&i&&t.push({text:r,rect:{left:i.left,top:i.top,width:i.right-i.left,height:i.bottom-i.top}}),r=l,i={left:f.left,top:f.top,right:f.right,bottom:f.bottom},c=f.top):(r+=l,i&&(i.left=Math.min(i.left,f.left),i.top=Math.min(i.top,f.top),i.right=Math.max(i.right,f.right),i.bottom=Math.max(i.bottom,f.bottom)))}a+=l.length}return r&&i&&t.push({text:r,rect:{left:i.left,top:i.top,width:i.right-i.left,height:i.bottom-i.top}}),t.filter(l=>l.text.trim().length>0&&l.rect.width>0&&l.rect.height>0)}function Oe(n){const e=parseFloat(n.fontSize);let t=parseFloat(n.lineHeight);isNaN(t)&&(t=e*1.2);let r=parseFloat(n.letterSpacing);return isNaN(r)&&(r=0),{font:`${n.fontStyle} ${n.fontWeight} ${n.fontSize} ${n.fontFamily}`,fontSize:n.fontSize,color:n.color,textAlign:n.textAlign||"start",textBaseline:"alphabetic",direction:n.direction||"inherit",lineHeight:t,letterSpacing:r}}function Ue(n,e=se|fe|Xe|ye|ve,t,r=1,i=0,c=2,s,o){var X,Q,ee,H,q,le,he;if(n.nodeType===Node.TEXT_NODE){const m=n;if(!m.textContent||!m.textContent.trim())return null;const k=m.textContent.replace(/\s+/g," ");if(k.length===0)return null;const z=tt(m);if(z.length===0)return null;const b=m.parentElement,x=b?window.getComputedStyle(b):null;if(!x)return null;const P=Math.min(...z.map(T=>T.rect.left)),V=Math.min(...z.map(T=>T.rect.top)),ie=Math.max(...z.map(T=>T.rect.left+T.rect.width)),U=Math.max(...z.map(T=>T.rect.top+T.rect.height));return{id:Math.random().toString(36).substring(2,9),type:"TEXT",element:m,rect:{x:P+window.scrollX,y:V+window.scrollY,width:ie-P,height:U-V},styles:{backgroundColor:"transparent",backgroundImage:"",opacity:b&&b.dataset[Z.KEY]===Z.VALUES.HIDE?1:parseFloat(x.opacity),zIndex:(isNaN(parseInt(x.zIndex))?0:parseInt(x.zIndex))+i,borderRadius:"0px",borderColor:"transparent",borderWidth:"0px",isTraveler:!1},textContent:k,textLines:z.map(T=>({text:T.text.trim(),rect:{x:T.rect.left+window.scrollX,y:T.rect.top+window.scrollY,width:T.rect.width,height:T.rect.height}})),textStyles:Oe(x),dirtyMask:e,visibility:t,isTraveler:!1,captureLayer:r,isFixed:x.position==="fixed",nativeLayer:s,nativeStyles:o?ne(ne({backgroundColor:"transparent",backgroundImage:"",opacity:b&&b.dataset[Z.KEY]===Z.VALUES.HIDE?1:parseFloat(x.opacity),zIndex:(isNaN(parseInt(x.zIndex))?0:parseInt(x.zIndex))+i,borderRadius:"0px",borderColor:"transparent",borderWidth:"0px",isTraveler:!1},Oe(x)),o):void 0,nativeRect:o?{x:P+window.scrollX,y:V+window.scrollY,width:ie-P,height:U-V}:void 0,children:[]}}if(n.nodeType!==Node.ELEMENT_NODE)return null;const a=n,l=a.dataset[F.KEY];let d=t,h=t;if(l){const m=new Set(l.split(/\s+/));for(const k of m)if(!Le.includes(k))throw new Error(`[MirageEngine] Invalid filter token: '${k}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`);if(m.has(F.VALUES.END))return null;if(m.has(F.VALUES.INCLUDE_TREE)&&m.has(F.VALUES.EXCLUDE_TREE))throw new Error("[MirageEngine] Conflicting filters: 'include-tree' and 'exclude-tree' cannot be used together on the same element.");if(m.has(F.VALUES.INCLUDE_SELF)&&m.has(F.VALUES.EXCLUDE_SELF))throw new Error("[MirageEngine] Conflicting filters: 'include-self' and 'exclude-self' cannot be used together on the same element.");m.has(F.VALUES.INCLUDE_TREE)?d=d|j:m.has(F.VALUES.EXCLUDE_TREE)&&(d=d&~j),h=d,m.has(F.VALUES.INCLUDE_SELF)?h=h|j:m.has(F.VALUES.EXCLUDE_SELF)&&(h=h&~j)}const f=a.dataset[Y.KEY];if(f){const m=new Set(f.split(/\s+/));for(const k of m)if(!Le.includes(k))throw new Error(`[MirageEngine] Invalid select token: '${k}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`);if(m.has(Y.VALUES.END))return null;if(m.has(Y.VALUES.INCLUDE_TREE)&&m.has(Y.VALUES.EXCLUDE_TREE))throw new Error("[MirageEngine] Conflicting selects: 'include-tree' and 'exclude-tree' cannot be used together on the same element.");if(m.has(Y.VALUES.INCLUDE_SELF)&&m.has(Y.VALUES.EXCLUDE_SELF))throw new Error("[MirageEngine] Conflicting selects: 'include-self' and 'exclude-self' cannot be used together on the same element.");m.has(Y.VALUES.INCLUDE_TREE)?d=d|oe:m.has(Y.VALUES.EXCLUDE_TREE)&&(d=d&~oe),h=d,m.has(Y.VALUES.INCLUDE_SELF)?h=h|oe:m.has(Y.VALUES.EXCLUDE_SELF)&&(h=h&~oe)}const g=a.dataset[_.KEY];let p=!1,w=o?ne({},o):{},y=s;if(g){let m=1;const k=g.indexOf("{"),z=g.lastIndexOf("}");let b=g;if(k!==-1&&z!==-1&&z>k){b=g.substring(0,k).trim();const U=g.substring(k,z+1);try{w=new Function("return "+U)()}catch(T){console.warn(`[MirageEngine] Failed to parse travel styles JSON: ${U}`)}}const x=b.split(/\s+/);let P=!1;const V=x.indexOf(_.VALUES.TRAVELER);if(V!==-1){p=!0,P=!0;const U=x[V+1];if(U&&!isNaN(parseInt(U,10)))m=parseInt(U,10);else{const T=x.find(de=>!isNaN(parseInt(de,10)));T&&(m=parseInt(T,10))}}const ie=x.indexOf(_.VALUES.NATIVE);if(ie!==-1){const U=x[ie+1];if(U&&!isNaN(parseInt(U,10)))y=parseInt(U,10);else if(!p){const T=x.find(de=>!isNaN(parseInt(de,10)));T&&(y=parseInt(T,10))}}if(P){const U=m+1;if(U<r)throw new Error(`[MirageEngine] Traveler layer (${m}) cannot be smaller than inherited capture layer (${r-1}).`);r=Math.min(U,_.MAX_LAYERS+1)}}const C=a.dataset[Ne.KEY];let O;C&&(O=JSON.parse(C));const A=a.getBoundingClientRect(),S=window.getComputedStyle(a);if(A.width===0||A.height===0||S.display==="none")return null;let R=a.getAttribute("data-mid");R||(R=Math.random().toString(36).substring(2,11),a.setAttribute("data-mid",R));const E=parseInt(S.zIndex),$=(isNaN(E)?0:E)+i;let W;if(a.tagName==="IMG")W=a.src;else if(a.tagName.toLowerCase()==="svg"){const m=a.cloneNode(!0),k=w==null?void 0:w.color,z=w==null?void 0:w.fill,b=w==null?void 0:w.stroke,x=w==null?void 0:w.opacity,P=(T,de)=>{const J=window.getComputedStyle(T),ge=de,ct=J.fill===J.color,lt=J.stroke===J.color,xe=z||(ct?k:void 0)||J.fill;xe&&xe!=="none"&&(ge.style.fill=xe);const Se=b||(lt?k:void 0)||J.stroke;Se&&Se!=="none"&&(ge.style.stroke=Se),J.strokeWidth&&J.strokeWidth!=="0px"&&(ge.style.strokeWidth=J.strokeWidth);const Be=k||J.color;Be&&(ge.style.color=Be);const Ee=x||J.opacity;Ee&&Ee!=="1"&&(ge.style.opacity=Ee);for(let we=0;we<T.children.length;we++)P(T.children[we],de.children[we])};P(a,m);const V=a.getBoundingClientRect(),ie=window.devicePixelRatio*c;m.hasAttribute("viewBox")||m.setAttribute("viewBox",`0 0 ${V.width} ${V.height}`),m.setAttribute("width",(V.width*ie).toString()),m.setAttribute("height",(V.height*ie).toString());let U=new XMLSerializer().serializeToString(m);U.includes("xmlns=")||(U=U.replace("<svg",'<svg xmlns="http://www.w3.org/2000/svg"')),W=`data:image/svg+xml;utf8,${encodeURIComponent(U)}`}else if(S.backgroundImage&&S.backgroundImage!=="none"){const m=S.backgroundImage.match(/url\(['"]?(.*?)['"]?\)/);m&&(W=m[1])}const L={backgroundColor:S.backgroundColor,backgroundImage:S.backgroundImage,opacity:a.dataset[Z.KEY]===Z.VALUES.HIDE?1:parseFloat(S.opacity),zIndex:$,borderRadius:S.borderRadius,borderColor:S.borderColor,borderWidth:S.borderWidth,boxShadow:S.boxShadow,imageSrc:W,isTraveler:p},K=L;let te,re;const M=[];return a.tagName.toLowerCase()!=="svg"&&Array.from(a.childNodes).forEach(m=>{const k=m.nodeType===Node.TEXT_NODE?h:d,z=Ue(m,e,k,r,$,c,m.nodeType===Node.TEXT_NODE?y:void 0,m.nodeType===Node.TEXT_NODE&&Object.keys(w).length>0?w:void 0);z&&M.push(z)}),{id:R,type:"BOX",element:a,rect:{x:A.left+window.scrollX,y:A.top+window.scrollY,width:A.width,height:A.height},styles:K,textContent:te,textStyles:re,dirtyMask:e,visibility:h,isTraveler:p,captureLayer:r,nativeLayer:y,nativeStyles:y!==void 0?_e(ne({},L),{backgroundColor:(X=w.backgroundColor)!=null?X:L.backgroundColor,backgroundImage:(Q=w.backgroundImage)!=null?Q:L.backgroundImage,opacity:(ee=w.opacity)!=null?ee:L.opacity,zIndex:w.zIndex!==void 0?w.zIndex+$:L.zIndex,borderRadius:(H=w.borderRadius)!=null?H:L.borderRadius,borderColor:(q=w.borderColor)!=null?q:L.borderColor,borderWidth:(le=w.borderWidth)!=null?le:L.borderWidth,boxShadow:(he=w.boxShadow)!=null?he:L.boxShadow,isTraveler:L.isTraveler,transform:w.transform}):void 0,nativeRect:y!==void 0?{x:w.x!==void 0?parseFloat(w.x):A.left+window.scrollX,y:w.y!==void 0?parseFloat(w.y):A.top+window.scrollY,width:w.width!==void 0?parseFloat(w.width):A.width,height:w.height!==void 0?parseFloat(w.height):A.height}:void 0,isFixed:S.position==="fixed",children:M,shaderHooks:O}}function rt(n,e){e.size!==0&&e.forEach((t,r)=>{var c,s,o,a;const i=n.get(r);!i||!i.userData.basePosition||(G.forceUpdateUniforms(i.material,{backgroundColor:t.backgroundColor,backgroundImage:t.backgroundImage,boxShadow:t.boxShadow,opacity:t.opacity,borderRadius:(s=t.borderRadius)!=null?s:(c=i.userData.baseStyles)==null?void 0:c.borderRadius}),i.userData.nativeMesh&&G.forceUpdateUniforms(i.userData.nativeMesh.material,{backgroundColor:t.backgroundColor,backgroundImage:t.backgroundImage,boxShadow:t.boxShadow,opacity:t.opacity,borderRadius:(a=t.borderRadius)!=null?a:(o=i.userData.baseStyles)==null?void 0:o.borderRadius}))})}class it{constructor(e,t,r,i){u(this,"target");u(this,"renderer");u(this,"registry");u(this,"isTravelEnabled",!1);u(this,"tracker");this.target=e,this.renderer=t,this.registry=r,this.tracker=new Re(e,{resizeDebounce:i.resizeDebounce}),this.tracker.onLayoutChange.add((c,s)=>{document.querySelector(`[${_.NAME}~='${_.VALUES.TRAVELER}']`)!==null&&!this.isTravelEnabled&&(this.isTravelEnabled=!0,this.renderer.createRenderTarget());const a=Ue(this.target,c,j,1,0,this.renderer.qualityFactor);a&&this.renderer.syncScene(a,s)}),this.tracker.onStyleChange.add(c=>{rt(this.registry,c)}),this.tracker.onRender.add(()=>{this.renderer.syncMeshesByDOM(),this.renderer.render()})}start(){this.tracker.start()}stop(){this.tracker.stop()}}class st{constructor(){u(this,"store");this.store=new WeakMap}register(e,t){this.store.set(e,t)}get(e){return this.store.get(e)}has(e){return this.store.has(e)}remove(e){this.store.delete(e)}}class nt{constructor(e,t){u(this,"renderer");u(this,"syncer");u(this,"target");u(this,"registry");var i,c,s;if(this.target=e,this.registry=new st,!document.getElementById("mirage-engine-styles")){const o=document.createElement("style");o.id="mirage-engine-styles",o.textContent=`
185
185
  [${Z.NAME}="${Z.VALUES.HIDE}"] {
186
186
  opacity: 0 !important;
187
187
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mirage-engine",
3
- "version": "0.3.16",
3
+ "version": "0.3.17",
4
4
  "description": "An engine that mirrors HTML DOM elements to a WebGL scene in real-time.",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
@@ -21,9 +21,9 @@
21
21
  "dist"
22
22
  ],
23
23
  "dependencies": {
24
- "@mirage-engine/core": "0.3.16",
25
- "@mirage-engine/painter": "1.0.6",
26
- "@mirage-engine/sandwich": "0.2.8"
24
+ "@mirage-engine/sandwich": "0.2.8",
25
+ "@mirage-engine/core": "0.3.17",
26
+ "@mirage-engine/painter": "1.0.7"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "three": "^0.160.0"