aptechka 0.66.5 → 0.67.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/en3/index.cjs CHANGED
@@ -1,8 +1,8 @@
1
- "use strict";var de=Object.defineProperty,ue=Object.defineProperties;var me=Object.getOwnPropertyDescriptors;var Z=Object.getOwnPropertySymbols;var fe=Object.prototype.hasOwnProperty,ge=Object.prototype.propertyIsEnumerable;var Q=s=>{throw TypeError(s)};var J=(s,e,i)=>e in s?de(s,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):s[e]=i,k=(s,e)=>{for(var i in e||(e={}))fe.call(e,i)&&J(s,i,e[i]);if(Z)for(var i of Z(e))ge.call(e,i)&&J(s,i,e[i]);return s},ee=(s,e)=>ue(s,me(e));var te=(s,e,i)=>e.has(s)||Q("Cannot "+i);var t=(s,e,i)=>(te(s,e,"read from private field"),i?i.call(s):e.get(s)),r=(s,e,i)=>e.has(s)?Q("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,i),n=(s,e,i,a)=>(te(s,e,"write to private field"),a?a.call(s,i):e.set(s,i),i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("three"),ie=require("../order/index.cjs"),se=require("../window-resizer/index.cjs"),re=require("../ticker/index.cjs"),ae=require("../dom-JBOkFLTh.cjs");require("construct-style-sheets-polyfill");require("../index-DekP7OZe.cjs");const ne=require("../layout-box/index.cjs");function he(s){const e=i=>{i.dispose();for(const a of Object.keys(i)){const h=i[a];h&&typeof h=="object"&&"minFilter"in h&&h.dispose()}};s.traverse(i=>{if(i instanceof u.Mesh){if(i.geometry.dispose(),!Array.isArray(i.material)&&i.material.isMaterial)e(i.material);else if(Array.isArray(i.material))for(const a of i.material)e(a)}})}var P,o,C,p,w,O,D,R;class X{constructor(e,i){r(this,P);r(this,o);r(this,C);r(this,p);r(this,w);r(this,O);r(this,D);r(this,R);n(this,P,e),n(this,o,(i==null?void 0:i.cameraType)==="orthographic"?new u.OrthographicCamera:new u.PerspectiveCamera),n(this,C,new u.Scene),n(this,p,[]),n(this,w,(i==null?void 0:i.cameraDistance)||1e3),t(this,o).near=(i==null?void 0:i.cameraNear)||1,t(this,o).far=(i==null?void 0:i.cameraFar)||11e3,n(this,O,(i==null?void 0:i.cameraFov)||"auto"),t(this,o).position.z=t(this,w),t(this,o).name=`Cameras.${t(this,P)}`,n(this,D,ae.getElement(i==null?void 0:i.sizeElement)||document.documentElement),this.beforeRenderCallback=i==null?void 0:i.beforeRender,n(this,R,new ne.LayoutBox(t(this,D))),t(this,R).onResize(()=>{this.resize()})}get name(){return t(this,P)}get camera(){return t(this,o)}get scene(){return t(this,C)}get box(){return t(this,R)}get cameraDistance(){return t(this,w)}set cameraDistance(e){n(this,w,e),this.resize()}get sizeElement(){return t(this,D)}get isClipped(){return t(this,D)!==d.containerElement}resize(){const{width:e,height:i}=t(this,R);t(this,o).userData.controlled||(t(this,o).position.z=t(this,w)),t(this,o)instanceof u.PerspectiveCamera?(t(this,o).aspect=e/i,t(this,o).fov=t(this,O)==="auto"?2*Math.atan(i/2/t(this,w))*(180/Math.PI):t(this,o).userData.controlled?t(this,o).fov:t(this,O)):t(this,o)instanceof u.OrthographicCamera&&(t(this,o).left=e/-2,t(this,o).right=e/2,t(this,o).top=i/2,t(this,o).bottom=i/-2),t(this,o).updateProjectionMatrix()}destroy(){t(this,p).forEach(e=>{e.userData.box.destroy()}),t(this,C).clear(),he(t(this,C)),d.destroyView(this.name),t(this,R).destroy()}attachToHTMLElement(e,i,a){const h=new ne.LayoutBox(e,ee(k({},a),{containerElement:t(this,D),cartesian:!0,scrollStep:!this.isClipped}));return h.bindObject(i),i.userData.box=h,t(this,p).push(i),i}detachFromHTMLElement(e){n(this,p,t(this,p).filter(i=>i===e?(e.userData.box.destroy(),!1):!0))}add(...e){const i=e[0],a=e[1],h=e[2];return a&&this.attachToHTMLElement(a,i,h),this.scene.add(i),i}remove(e,i){this.scene.remove(e),i&&this.detachFromHTMLElement(e)}}P=new WeakMap,o=new WeakMap,C=new WeakMap,p=new WeakMap,w=new WeakMap,O=new WeakMap,D=new WeakMap,R=new WeakMap;var A,q,F,z,I;class Ee{constructor(e){r(this,A);r(this,q);r(this,F);r(this,z);r(this,I);n(this,A,e.targetName||void 0),n(this,q,e.eventDispatcher||e.object3D),n(this,F,e.propagation||!1),n(this,z,e.object3D),n(this,I,t(this,A)?()=>t(this,z).getObjectByName(t(this,A))||t(this,z):()=>t(this,z))}get object3D(){return t(this,z)}get eventDispatcher(){return t(this,q)}get propagation(){return t(this,F)}get target(){return t(this,I).call(this)}dispatch(e,i){this.eventDispatcher.dispatchEvent(k({originalEvent:i,type:e},this.intersection))}}A=new WeakMap,q=new WeakMap,F=new WeakMap,z=new WeakMap,I=new WeakMap;var b,m,H,N,_,B,$;class xe{constructor(){r(this,b,[]);r(this,m,[]);r(this,H,new u.Vector2);r(this,N,new u.Raycaster);r(this,_,e=>{for(let i=0;i<t(this,m).length;i++)t(this,m)[i].dispatch("pointerDown",e)});r(this,B,e=>{for(let i=0;i<t(this,m).length;i++)t(this,m)[i].dispatch("pointerUp",e)});r(this,$,e=>{if(!t(this,b).length)return;t(this,H).x=e.clientX/d.width*2-1,t(this,H).y=-(e.clientY/d.height)*2+1,d.camera&&t(this,N).setFromCamera(t(this,H),d.camera);const i=[];for(const c of t(this,b)){const g=t(this,N).intersectObject(c.target);g.length&&(c.intersection=g[0],i.push(c))}let a=!1;const h=t(this,m).filter(c=>!i.find(g=>g.object3D.uuid===c.object3D.uuid)),y=i.sort((c,g)=>g.object3D.position.z-c.object3D.position.z).filter((c,g)=>a?(h.push(c),!1):(a=!c.propagation,!0)),v=y.filter(c=>!t(this,m).find(g=>g.object3D.uuid===c.object3D.uuid));for(let c=0;c<h.length;c++)h[c].dispatch("pointerLeave",e);for(let c=0;c<v.length;c++)v[c].dispatch("pointerEnter",e);n(this,m,y);for(let c=0;c<t(this,m).length;c++)t(this,m)[c].dispatch("pointerMove",e)});d.containerElement.addEventListener("pointerdown",t(this,_)),d.containerElement.addEventListener("pointerup",t(this,B)),d.containerElement.addEventListener("pointermove",t(this,$))}destroy(){d.containerElement.removeEventListener("pointerdown",t(this,_)),d.containerElement.removeEventListener("pointerup",t(this,B)),d.containerElement.removeEventListener("pointermove",t(this,$)),n(this,b,[]),n(this,m,[])}add(e,i){if(t(this,b).find(h=>h.object3D.uuid===e.uuid))return;const a=new Ee(k({object3D:e},i));t(this,b).push(a)}remove(e){n(this,b,t(this,b).filter(i=>i.object3D.uuid!==e.uuid)),n(this,m,t(this,m).filter(i=>i.object3D.uuid!==e.uuid))}}b=new WeakMap,m=new WeakMap,H=new WeakMap,N=new WeakMap,_=new WeakMap,B=new WeakMap,$=new WeakMap;var U,E,l,j,f,M,T,L,W,S,x,Y,G;class ye{constructor(){r(this,U,`https://unpkg.com/three@0.${u.REVISION}.x`);r(this,E,null);r(this,l,null);r(this,j,null);r(this,f,new Map);r(this,M,0);r(this,T,0);r(this,L,0);r(this,W,2);r(this,S,!1);r(this,x,null);r(this,Y,e=>{e instanceof CustomEvent||(n(this,M,t(this,E).clientWidth),n(this,T,t(this,E).clientHeight),n(this,L,Math.min(t(this,W),devicePixelRatio||1)),t(this,l).setPixelRatio(t(this,L)),t(this,l).setSize(t(this,M),t(this,T)),t(this,x)&&(t(this,x).setPixelRatio(t(this,L)),t(this,x).setSize(t(this,M),t(this,T))))});r(this,G,()=>{t(this,l).setRenderTarget(null),t(this,f).forEach(e=>{this.render(e)})})}get CDNVersion(){return t(this,U)}get containerElement(){return t(this,E)}get webglRenderer(){return t(this,l)}get raycaster(){return t(this,j)}get views(){return t(this,f)}get view(){return this.getView("default")}get camera(){return this.getView("default").camera}get scene(){return this.getView("default").scene}get width(){return t(this,M)}get height(){return t(this,T)}get pixelRatio(){return t(this,L)}get composer(){return t(this,x)}setup(e){if(t(this,S)){console.warn("[en3.setup]: You are trying to setup en3 again.");return}n(this,E,ae.getElement(e==null?void 0:e.containerElement)||document.body),n(this,W,(e==null?void 0:e.maxPixelRatio)||2),n(this,l,new u.WebGLRenderer(e==null?void 0:e.webGLRendererParameters)),t(this,l).domElement.style.cssText=`
1
+ "use strict";var de=Object.defineProperty,ue=Object.defineProperties;var me=Object.getOwnPropertyDescriptors;var Z=Object.getOwnPropertySymbols;var fe=Object.prototype.hasOwnProperty,ge=Object.prototype.propertyIsEnumerable;var Q=s=>{throw TypeError(s)};var J=(s,e,i)=>e in s?de(s,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):s[e]=i,k=(s,e)=>{for(var i in e||(e={}))fe.call(e,i)&&J(s,i,e[i]);if(Z)for(var i of Z(e))ge.call(e,i)&&J(s,i,e[i]);return s},ee=(s,e)=>ue(s,me(e));var te=(s,e,i)=>e.has(s)||Q("Cannot "+i);var t=(s,e,i)=>(te(s,e,"read from private field"),i?i.call(s):e.get(s)),r=(s,e,i)=>e.has(s)?Q("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,i),h=(s,e,i,a)=>(te(s,e,"write to private field"),a?a.call(s,i):e.set(s,i),i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("three"),ie=require("../order/index.cjs"),se=require("../window-resizer/index.cjs"),re=require("../ticker/index.cjs"),ae=require("../dom-JBOkFLTh.cjs");require("construct-style-sheets-polyfill");require("../index-DekP7OZe.cjs");const he=require("../layout-box/index.cjs");function ne(s){const e=i=>{i.dispose();for(const a of Object.keys(i)){const n=i[a];n&&typeof n=="object"&&"minFilter"in n&&n.dispose()}};s.traverse(i=>{if(i instanceof u.Mesh){if(i.geometry.dispose(),!Array.isArray(i.material)&&i.material.isMaterial)e(i.material);else if(Array.isArray(i.material))for(const a of i.material)e(a)}})}var P,o,C,D,y,O,R,p;class Y{constructor(e,i){r(this,P);r(this,o);r(this,C);r(this,D);r(this,y);r(this,O);r(this,R);r(this,p);h(this,P,e),h(this,o,(i==null?void 0:i.cameraType)==="orthographic"?new u.OrthographicCamera:new u.PerspectiveCamera),h(this,C,new u.Scene),h(this,D,[]),h(this,y,(i==null?void 0:i.cameraDistance)||1e3),t(this,o).near=(i==null?void 0:i.cameraNear)||1,t(this,o).far=(i==null?void 0:i.cameraFar)||11e3,h(this,O,(i==null?void 0:i.cameraFov)||"auto"),t(this,o).position.z=t(this,y),t(this,o).name=`Cameras.${t(this,P)}`,h(this,R,ae.getElement(i==null?void 0:i.sizeElement)||document.documentElement),this.beforeRenderCallback=i==null?void 0:i.beforeRender,h(this,p,new he.LayoutBox(t(this,R))),t(this,p).onResize(()=>{this.resize()})}get name(){return t(this,P)}get camera(){return t(this,o)}get scene(){return t(this,C)}get box(){return t(this,p)}get cameraDistance(){return t(this,y)}set cameraDistance(e){h(this,y,e),this.resize()}get sizeElement(){return t(this,R)}get isClipped(){return t(this,R)!==d.containerElement}resize(){const{width:e,height:i}=t(this,p);t(this,o).userData.controlled||(t(this,o).position.z=t(this,y)),t(this,o)instanceof u.PerspectiveCamera?(t(this,o).aspect=e/i,t(this,o).fov=t(this,O)==="auto"?2*Math.atan(i/2/t(this,y))*(180/Math.PI):t(this,o).userData.controlled?t(this,o).fov:t(this,O)):t(this,o)instanceof u.OrthographicCamera&&(t(this,o).left=e/-2,t(this,o).right=e/2,t(this,o).top=i/2,t(this,o).bottom=i/-2),t(this,o).updateProjectionMatrix()}destroy(){t(this,D).forEach(e=>{e.userData.box.destroy()}),t(this,C).clear(),ne(t(this,C)),d.destroyView(this.name),t(this,p).destroy()}attachToHTMLElement(e,i,a){const n=new he.LayoutBox(e,ee(k({},a),{containerElement:t(this,R),cartesian:!0,scrollStep:!this.isClipped}));return n.bindObject(i),i.userData.box=n,t(this,D).push(i),i}detachFromHTMLElement(e){h(this,D,t(this,D).filter(i=>i===e?(e.userData.box.destroy(),!1):!0))}add(...e){const i=e[0],a=e[1],n=e[2];return a&&this.attachToHTMLElement(a,i,n),this.scene.add(i),i}remove(e,i){this.scene.remove(e),i&&this.detachFromHTMLElement(e)}}P=new WeakMap,o=new WeakMap,C=new WeakMap,D=new WeakMap,y=new WeakMap,O=new WeakMap,R=new WeakMap,p=new WeakMap;var A,q,F,z,I;class Ee{constructor(e){r(this,A);r(this,q);r(this,F);r(this,z);r(this,I);h(this,A,e.targetName||void 0),h(this,q,e.eventDispatcher||e.object3D),h(this,F,e.propagation||!1),h(this,z,e.object3D),h(this,I,t(this,A)?()=>t(this,z).getObjectByName(t(this,A))||t(this,z):()=>t(this,z))}get object3D(){return t(this,z)}get eventDispatcher(){return t(this,q)}get propagation(){return t(this,F)}get target(){return t(this,I).call(this)}dispatch(e,i){this.eventDispatcher.dispatchEvent(k({originalEvent:i,type:e},this.intersection))}}A=new WeakMap,q=new WeakMap,F=new WeakMap,z=new WeakMap,I=new WeakMap;var w,m,H,N,_,B,$;class xe{constructor(){r(this,w,[]);r(this,m,[]);r(this,H,new u.Vector2);r(this,N,new u.Raycaster);r(this,_,e=>{for(let i=0;i<t(this,m).length;i++)t(this,m)[i].dispatch("pointerDown",e)});r(this,B,e=>{for(let i=0;i<t(this,m).length;i++)t(this,m)[i].dispatch("pointerUp",e)});r(this,$,e=>{if(!t(this,w).length)return;t(this,H).x=e.clientX/d.width*2-1,t(this,H).y=-(e.clientY/d.height)*2+1,d.camera&&t(this,N).setFromCamera(t(this,H),d.camera);const i=[];for(const c of t(this,w)){const g=t(this,N).intersectObject(c.target);g.length&&(c.intersection=g[0],i.push(c))}let a=!1;const n=t(this,m).filter(c=>!i.find(g=>g.object3D.uuid===c.object3D.uuid)),b=i.sort((c,g)=>g.object3D.position.z-c.object3D.position.z).filter((c,g)=>a?(n.push(c),!1):(a=!c.propagation,!0)),v=b.filter(c=>!t(this,m).find(g=>g.object3D.uuid===c.object3D.uuid));for(let c=0;c<n.length;c++)n[c].dispatch("pointerLeave",e);for(let c=0;c<v.length;c++)v[c].dispatch("pointerEnter",e);h(this,m,b);for(let c=0;c<t(this,m).length;c++)t(this,m)[c].dispatch("pointerMove",e)});d.containerElement.addEventListener("pointerdown",t(this,_)),d.containerElement.addEventListener("pointerup",t(this,B)),d.containerElement.addEventListener("pointermove",t(this,$))}destroy(){d.containerElement.removeEventListener("pointerdown",t(this,_)),d.containerElement.removeEventListener("pointerup",t(this,B)),d.containerElement.removeEventListener("pointermove",t(this,$)),h(this,w,[]),h(this,m,[])}add(e,i){if(t(this,w).find(n=>n.object3D.uuid===e.uuid))return;const a=new Ee(k({object3D:e},i));t(this,w).push(a)}remove(e){h(this,w,t(this,w).filter(i=>i.object3D.uuid!==e.uuid)),h(this,m,t(this,m).filter(i=>i.object3D.uuid!==e.uuid))}}w=new WeakMap,m=new WeakMap,H=new WeakMap,N=new WeakMap,_=new WeakMap,B=new WeakMap,$=new WeakMap;var K,E,l,j,f,M,T,L,W,S,x,G,U;class be{constructor(){r(this,K,`https://unpkg.com/three@0.${u.REVISION}.x`);r(this,E,null);r(this,l,null);r(this,j,null);r(this,f,new Map);r(this,M,0);r(this,T,0);r(this,L,0);r(this,W,2);r(this,S,!1);r(this,x,null);r(this,G,e=>{e instanceof CustomEvent||(h(this,M,t(this,E).clientWidth),h(this,T,t(this,E).clientHeight),h(this,L,Math.min(t(this,W),devicePixelRatio||1)),t(this,l).setPixelRatio(t(this,L)),t(this,l).setSize(t(this,M),t(this,T)),t(this,x)&&(t(this,x).setPixelRatio(t(this,L)),t(this,x).setSize(t(this,M),t(this,T))))});r(this,U,()=>{t(this,l).setRenderTarget(null),t(this,f).forEach(e=>{this.render(e)})})}get CDNVersion(){return t(this,K)}get containerElement(){return t(this,E)}get webglRenderer(){return t(this,l)}get raycaster(){return t(this,j)}get views(){return t(this,f)}get view(){return this.getView("default")}get camera(){return this.getView("default").camera}get scene(){return this.getView("default").scene}get width(){return t(this,M)}get height(){return t(this,T)}get pixelRatio(){return t(this,L)}get composer(){return t(this,x)}setup(e){if(t(this,S))return;h(this,E,ae.getElement(e==null?void 0:e.containerElement)||document.body),h(this,W,(e==null?void 0:e.maxPixelRatio)||2),h(this,l,new u.WebGLRenderer(e==null?void 0:e.webGLRendererParameters)),t(this,l).domElement.style.cssText=`
2
2
  position: ${(e==null?void 0:e.position)||"fixed"};
3
3
  left: 0;
4
4
  top: 0;
5
5
  width: 100%;
6
6
  height: 100%;
7
7
  z-index: ${(e==null?void 0:e.zIndex)||0};
8
- `,(t(this,E).shadowRoot||t(this,E)).append(t(this,l).domElement),t(this,f).set("default",new X("default",k({sizeElement:t(this,E)},e==null?void 0:e.view))),n(this,j,new xe),e!=null&&e.composer&&(n(this,x,new e.composer(t(this,l))),this.render=()=>{t(this,x).render()}),n(this,S,!0),se.windowResizer.subscribe(t(this,Y),ie.RESIZE_ORDER.CANVAS),re.ticker.subscribe(t(this,G),{order:ie.TICK_ORDER.CANVAS,culling:t(this,E)})}destroy(){var e;if(!t(this,S)){console.warn("[en3.setup]: You are trying to destory en3 but it has not been initialized.");return}se.windowResizer.unsubscribe(t(this,Y)),re.ticker.unsubscribe(t(this,G)),t(this,j).destroy(),t(this,f).forEach(i=>{i.destroy()}),t(this,f).clear(),t(this,l).dispose(),t(this,l).domElement.remove(),n(this,l,null),(e=t(this,x))==null||e.dispose(),n(this,x,null),n(this,S,!1)}createView(e,i){const a=t(this,f).size,h=new X(e,i);return t(this,f).set(e,h),a===1&&t(this,l).setScissorTest(!0),h}getView(e){return t(this,f).get(e)}destroyView(e){const i=t(this,f).get(e);i&&(t(this,f).delete(e),i.destroy(),t(this,f).size<=1&&t(this,l).setScissorTest(!1))}render(e){var i;if(t(this,f).size>1||this.view.isClipped){const a=e.box.left+e.box.CSSTranslation.x+e.box.scrollValue.x,h=d.height-e.box.height-e.box.top+e.box.CSSTranslation.y+e.box.scrollValue.y*-1;t(this,l).setScissor(a,h,e.box.width,e.box.height),t(this,l).setViewport(a,h,e.box.width,e.box.height)}(i=e.beforeRenderCallback)==null||i.call(e),t(this,l).render(e.scene,e.camera)}}U=new WeakMap,E=new WeakMap,l=new WeakMap,j=new WeakMap,f=new WeakMap,M=new WeakMap,T=new WeakMap,L=new WeakMap,W=new WeakMap,S=new WeakMap,x=new WeakMap,Y=new WeakMap,G=new WeakMap;const d=new ye;function be(s,e,i){const a=e.x,h=e.y,V=i||s.image.width/s.image.height;let y=0,v=0,c=s.offset.x,g=s.offset.y,ce=s.rotation,oe=s.center.x,le=s.center.y;a/h>V?(y=1,v=h/a*V):(v=1,y=a/h/V),s.matrix.setUvTransform(c,g,y,v,ce,oe,le)}const K=new u.Vector3,we=new u.Vector3;function ve(s,e="default"){const i=d.getView(e),{width:a,height:h}=d,V=a/h;s instanceof u.Vector3?K.copy(s):K.set(...s);const y=i.camera.getWorldPosition(we).distanceTo(K);if(i.camera instanceof u.OrthographicCamera)return{width:a/i.camera.zoom,height:h/i.camera.zoom,factor:1,distance:y,aspect:V};{const v=i.camera.fov*Math.PI/180,c=2*Math.tan(v/2)*y,g=c*(a/h);return{width:g,height:c,factor:a/g,distance:y,aspect:V}}}function pe(s,e){s.traverse(i=>{i instanceof u.Mesh&&i.material&&(Array.isArray(i.material)?i.material:[i.material]).forEach(e)})}function De(s,e){s.traverse(i=>{i instanceof u.Mesh&&e(i)})}exports.En3View=X;exports.coverTexture=be;exports.dispose=he;exports.en3=d;exports.getCurrentViewport=ve;exports.traverseMaterials=pe;exports.traverseMeshes=De;
8
+ `,(t(this,E).shadowRoot||t(this,E)).append(t(this,l).domElement),t(this,f).set("default",new Y("default",k({sizeElement:t(this,E)},e==null?void 0:e.view))),h(this,j,new xe),e!=null&&e.composer&&(h(this,x,new e.composer(t(this,l))),this.render=()=>{t(this,x).render()}),h(this,S,!0),se.windowResizer.subscribe(t(this,G),ie.RESIZE_ORDER.CANVAS),re.ticker.subscribe(t(this,U),{order:ie.TICK_ORDER.CANVAS,culling:t(this,E)})}destroy(){var e;t(this,S)&&(se.windowResizer.unsubscribe(t(this,G)),re.ticker.unsubscribe(t(this,U)),t(this,j).destroy(),t(this,f).forEach(i=>{i.destroy()}),t(this,f).clear(),t(this,l).dispose(),t(this,l).domElement.remove(),h(this,l,null),(e=t(this,x))==null||e.dispose(),h(this,x,null),h(this,S,!1))}createView(e,i){const a=t(this,f).size,n=new Y(e,i);return t(this,f).set(e,n),a===1&&t(this,l).setScissorTest(!0),n}getView(e){return t(this,f).get(e)}destroyView(e){const i=t(this,f).get(e);i&&(t(this,f).delete(e),i.destroy(),t(this,f).size<=1&&t(this,l).setScissorTest(!1))}render(e){var i;if(t(this,f).size>1||this.view.isClipped){const a=e.box.left+e.box.CSSTranslation.x+e.box.scrollValue.x,n=d.height-e.box.height-e.box.top+e.box.CSSTranslation.y+e.box.scrollValue.y*-1;t(this,l).setScissor(a,n,e.box.width,e.box.height),t(this,l).setViewport(a,n,e.box.width,e.box.height)}(i=e.beforeRenderCallback)==null||i.call(e),t(this,l).render(e.scene,e.camera)}}K=new WeakMap,E=new WeakMap,l=new WeakMap,j=new WeakMap,f=new WeakMap,M=new WeakMap,T=new WeakMap,L=new WeakMap,W=new WeakMap,S=new WeakMap,x=new WeakMap,G=new WeakMap,U=new WeakMap;const d=new be;function we(s,e,i){const a=e.x,n=e.y,V=i||s.image.width/s.image.height;let b=0,v=0,c=s.offset.x,g=s.offset.y,ce=s.rotation,oe=s.center.x,le=s.center.y;a/n>V?(b=1,v=n/a*V):(v=1,b=a/n/V),s.matrix.setUvTransform(c,g,b,v,ce,oe,le)}const X=new u.Vector3,ye=new u.Vector3;function ve(s,e="default"){const i=d.getView(e),{width:a,height:n}=d,V=a/n;s instanceof u.Vector3?X.copy(s):X.set(...s);const b=i.camera.getWorldPosition(ye).distanceTo(X);if(i.camera instanceof u.OrthographicCamera)return{width:a/i.camera.zoom,height:n/i.camera.zoom,factor:1,distance:b,aspect:V};{const v=i.camera.fov*Math.PI/180,c=2*Math.tan(v/2)*b,g=c*(a/n);return{width:g,height:c,factor:a/g,distance:b,aspect:V}}}function De(s,e){s.traverse(i=>{i instanceof u.Mesh&&i.material&&(Array.isArray(i.material)?i.material:[i.material]).forEach(e)})}function Re(s,e){s.traverse(i=>{i instanceof u.Mesh&&e(i)})}exports.En3View=Y;exports.coverTexture=we;exports.dispose=ne;exports.en3=d;exports.getCurrentViewport=ve;exports.traverseMaterials=De;exports.traverseMeshes=Re;
package/lib/en3/index.js CHANGED
@@ -1,21 +1,21 @@
1
- var ue = Object.defineProperty, me = Object.defineProperties;
1
+ var me = Object.defineProperty, ue = Object.defineProperties;
2
2
  var fe = Object.getOwnPropertyDescriptors;
3
3
  var J = Object.getOwnPropertySymbols;
4
4
  var ge = Object.prototype.hasOwnProperty, Ee = Object.prototype.propertyIsEnumerable;
5
5
  var ee = (s) => {
6
6
  throw TypeError(s);
7
7
  };
8
- var Q = (s, e, i) => e in s ? ue(s, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : s[e] = i, j = (s, e) => {
8
+ var Q = (s, e, i) => e in s ? me(s, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : s[e] = i, j = (s, e) => {
9
9
  for (var i in e || (e = {}))
10
10
  ge.call(e, i) && Q(s, i, e[i]);
11
11
  if (J)
12
12
  for (var i of J(e))
13
13
  Ee.call(e, i) && Q(s, i, e[i]);
14
14
  return s;
15
- }, te = (s, e) => me(s, fe(e));
15
+ }, te = (s, e) => ue(s, fe(e));
16
16
  var ie = (s, e, i) => e.has(s) || ee("Cannot " + i);
17
17
  var t = (s, e, i) => (ie(s, e, "read from private field"), i ? i.call(s) : e.get(s)), r = (s, e, i) => e.has(s) ? ee("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(s) : e.set(s, i), h = (s, e, i, a) => (ie(s, e, "write to private field"), a ? a.call(s, i) : e.set(s, i), i);
18
- import { Mesh as Z, OrthographicCamera as X, PerspectiveCamera as se, Scene as be, Vector2 as ye, Raycaster as xe, REVISION as we, WebGLRenderer as pe, Vector3 as q } from "three";
18
+ import { Mesh as Z, OrthographicCamera as Y, PerspectiveCamera as se, Scene as be, Vector2 as xe, Raycaster as ye, REVISION as we, WebGLRenderer as pe, Vector3 as q } from "three";
19
19
  import { RESIZE_ORDER as De, TICK_ORDER as ve } from "../order/index.js";
20
20
  import { windowResizer as re } from "../window-resizer/index.js";
21
21
  import { ticker as he } from "../ticker/index.js";
@@ -40,18 +40,18 @@ function Re(s) {
40
40
  }
41
41
  });
42
42
  }
43
- var S, o, V, p, x, P, D, v;
43
+ var S, l, V, p, y, P, D, v;
44
44
  class ne {
45
45
  constructor(e, i) {
46
46
  r(this, S);
47
- r(this, o);
47
+ r(this, l);
48
48
  r(this, V);
49
49
  r(this, p);
50
- r(this, x);
50
+ r(this, y);
51
51
  r(this, P);
52
52
  r(this, D);
53
53
  r(this, v);
54
- h(this, S, e), h(this, o, (i == null ? void 0 : i.cameraType) === "orthographic" ? new X() : new se()), h(this, V, new be()), h(this, p, []), h(this, x, (i == null ? void 0 : i.cameraDistance) || 1e3), t(this, o).near = (i == null ? void 0 : i.cameraNear) || 1, t(this, o).far = (i == null ? void 0 : i.cameraFar) || 11e3, h(this, P, (i == null ? void 0 : i.cameraFov) || "auto"), t(this, o).position.z = t(this, x), t(this, o).name = `Cameras.${t(this, S)}`, h(this, D, ce(i == null ? void 0 : i.sizeElement) || document.documentElement), this.beforeRenderCallback = i == null ? void 0 : i.beforeRender, h(this, v, new ae(t(this, D))), t(this, v).onResize(() => {
54
+ h(this, S, e), h(this, l, (i == null ? void 0 : i.cameraType) === "orthographic" ? new Y() : new se()), h(this, V, new be()), h(this, p, []), h(this, y, (i == null ? void 0 : i.cameraDistance) || 1e3), t(this, l).near = (i == null ? void 0 : i.cameraNear) || 1, t(this, l).far = (i == null ? void 0 : i.cameraFar) || 11e3, h(this, P, (i == null ? void 0 : i.cameraFov) || "auto"), t(this, l).position.z = t(this, y), t(this, l).name = `Cameras.${t(this, S)}`, h(this, D, ce(i == null ? void 0 : i.sizeElement) || document.documentElement), this.beforeRenderCallback = i == null ? void 0 : i.beforeRender, h(this, v, new ae(t(this, D))), t(this, v).onResize(() => {
55
55
  this.resize();
56
56
  });
57
57
  }
@@ -59,7 +59,7 @@ class ne {
59
59
  return t(this, S);
60
60
  }
61
61
  get camera() {
62
- return t(this, o);
62
+ return t(this, l);
63
63
  }
64
64
  get scene() {
65
65
  return t(this, V);
@@ -68,25 +68,25 @@ class ne {
68
68
  return t(this, v);
69
69
  }
70
70
  get cameraDistance() {
71
- return t(this, x);
71
+ return t(this, y);
72
72
  }
73
73
  set cameraDistance(e) {
74
- h(this, x, e), this.resize();
74
+ h(this, y, e), this.resize();
75
75
  }
76
76
  get sizeElement() {
77
77
  return t(this, D);
78
78
  }
79
79
  get isClipped() {
80
- return t(this, D) !== m.containerElement;
80
+ return t(this, D) !== u.containerElement;
81
81
  }
82
82
  resize() {
83
83
  const { width: e, height: i } = t(this, v);
84
- t(this, o).userData.controlled || (t(this, o).position.z = t(this, x)), t(this, o) instanceof se ? (t(this, o).aspect = e / i, t(this, o).fov = t(this, P) === "auto" ? 2 * Math.atan(i / 2 / t(this, x)) * (180 / Math.PI) : t(this, o).userData.controlled ? t(this, o).fov : t(this, P)) : t(this, o) instanceof X && (t(this, o).left = e / -2, t(this, o).right = e / 2, t(this, o).top = i / 2, t(this, o).bottom = i / -2), t(this, o).updateProjectionMatrix();
84
+ t(this, l).userData.controlled || (t(this, l).position.z = t(this, y)), t(this, l) instanceof se ? (t(this, l).aspect = e / i, t(this, l).fov = t(this, P) === "auto" ? 2 * Math.atan(i / 2 / t(this, y)) * (180 / Math.PI) : t(this, l).userData.controlled ? t(this, l).fov : t(this, P)) : t(this, l) instanceof Y && (t(this, l).left = e / -2, t(this, l).right = e / 2, t(this, l).top = i / 2, t(this, l).bottom = i / -2), t(this, l).updateProjectionMatrix();
85
85
  }
86
86
  destroy() {
87
87
  t(this, p).forEach((e) => {
88
88
  e.userData.box.destroy();
89
- }), t(this, V).clear(), Re(t(this, V)), m.destroyView(this.name), t(this, v).destroy();
89
+ }), t(this, V).clear(), Re(t(this, V)), u.destroyView(this.name), t(this, v).destroy();
90
90
  }
91
91
  attachToHTMLElement(e, i, a) {
92
92
  const n = new ae(e, te(j({}, a), {
@@ -107,7 +107,7 @@ class ne {
107
107
  this.scene.remove(e), i && this.detachFromHTMLElement(e);
108
108
  }
109
109
  }
110
- S = new WeakMap(), o = new WeakMap(), V = new WeakMap(), p = new WeakMap(), x = new WeakMap(), P = new WeakMap(), D = new WeakMap(), v = new WeakMap();
110
+ S = new WeakMap(), l = new WeakMap(), V = new WeakMap(), p = new WeakMap(), y = new WeakMap(), P = new WeakMap(), D = new WeakMap(), v = new WeakMap();
111
111
  var A, k, F, R, I;
112
112
  class ze {
113
113
  constructor(e) {
@@ -138,13 +138,13 @@ class ze {
138
138
  }
139
139
  }
140
140
  A = new WeakMap(), k = new WeakMap(), F = new WeakMap(), R = new WeakMap(), I = new WeakMap();
141
- var y, d, H, N, $, W, Y;
141
+ var x, d, H, N, $, W, _;
142
142
  class Ve {
143
143
  constructor() {
144
- r(this, y, []);
144
+ r(this, x, []);
145
145
  r(this, d, []);
146
- r(this, H, new ye());
147
- r(this, N, new xe());
146
+ r(this, H, new xe());
147
+ r(this, N, new ye());
148
148
  r(this, $, (e) => {
149
149
  for (let i = 0; i < t(this, d).length; i++)
150
150
  t(this, d)[i].dispatch("pointerDown", e);
@@ -153,12 +153,12 @@ class Ve {
153
153
  for (let i = 0; i < t(this, d).length; i++)
154
154
  t(this, d)[i].dispatch("pointerUp", e);
155
155
  });
156
- r(this, Y, (e) => {
157
- if (!t(this, y).length)
156
+ r(this, _, (e) => {
157
+ if (!t(this, x).length)
158
158
  return;
159
- t(this, H).x = e.clientX / m.width * 2 - 1, t(this, H).y = -(e.clientY / m.height) * 2 + 1, m.camera && t(this, N).setFromCamera(t(this, H), m.camera);
159
+ t(this, H).x = e.clientX / u.width * 2 - 1, t(this, H).y = -(e.clientY / u.height) * 2 + 1, u.camera && t(this, N).setFromCamera(t(this, H), u.camera);
160
160
  const i = [];
161
- for (const c of t(this, y)) {
161
+ for (const c of t(this, x)) {
162
162
  const f = t(this, N).intersectObject(c.target);
163
163
  f.length && (c.intersection = f[0], i.push(c));
164
164
  }
@@ -178,78 +178,78 @@ class Ve {
178
178
  for (let c = 0; c < t(this, d).length; c++)
179
179
  t(this, d)[c].dispatch("pointerMove", e);
180
180
  });
181
- m.containerElement.addEventListener(
181
+ u.containerElement.addEventListener(
182
182
  "pointerdown",
183
183
  t(this, $)
184
- ), m.containerElement.addEventListener("pointerup", t(this, W)), m.containerElement.addEventListener(
184
+ ), u.containerElement.addEventListener("pointerup", t(this, W)), u.containerElement.addEventListener(
185
185
  "pointermove",
186
- t(this, Y)
186
+ t(this, _)
187
187
  );
188
188
  }
189
189
  destroy() {
190
- m.containerElement.removeEventListener(
190
+ u.containerElement.removeEventListener(
191
191
  "pointerdown",
192
192
  t(this, $)
193
- ), m.containerElement.removeEventListener(
193
+ ), u.containerElement.removeEventListener(
194
194
  "pointerup",
195
195
  t(this, W)
196
- ), m.containerElement.removeEventListener(
196
+ ), u.containerElement.removeEventListener(
197
197
  "pointermove",
198
- t(this, Y)
199
- ), h(this, y, []), h(this, d, []);
198
+ t(this, _)
199
+ ), h(this, x, []), h(this, d, []);
200
200
  }
201
201
  add(e, i) {
202
- if (t(this, y).find((n) => n.object3D.uuid === e.uuid))
202
+ if (t(this, x).find((n) => n.object3D.uuid === e.uuid))
203
203
  return;
204
204
  const a = new ze(j({
205
205
  object3D: e
206
206
  }, i));
207
- t(this, y).push(a);
207
+ t(this, x).push(a);
208
208
  }
209
209
  remove(e) {
210
- h(this, y, t(this, y).filter(
210
+ h(this, x, t(this, x).filter(
211
211
  (i) => i.object3D.uuid !== e.uuid
212
212
  )), h(this, d, t(this, d).filter((i) => i.object3D.uuid !== e.uuid));
213
213
  }
214
214
  }
215
- y = new WeakMap(), d = new WeakMap(), H = new WeakMap(), N = new WeakMap(), $ = new WeakMap(), W = new WeakMap(), Y = new WeakMap();
216
- var U, g, l, O, u, C, L, T, _, M, E, B, G;
215
+ x = new WeakMap(), d = new WeakMap(), H = new WeakMap(), N = new WeakMap(), $ = new WeakMap(), W = new WeakMap(), _ = new WeakMap();
216
+ var K, g, o, O, m, C, L, T, B, M, E, G, U;
217
217
  class Ce {
218
218
  constructor() {
219
- r(this, U, `https://unpkg.com/three@0.${we}.x`);
219
+ r(this, K, `https://unpkg.com/three@0.${we}.x`);
220
220
  r(this, g, null);
221
- r(this, l, null);
221
+ r(this, o, null);
222
222
  r(this, O, null);
223
- r(this, u, /* @__PURE__ */ new Map());
223
+ r(this, m, /* @__PURE__ */ new Map());
224
224
  r(this, C, 0);
225
225
  r(this, L, 0);
226
226
  r(this, T, 0);
227
- r(this, _, 2);
227
+ r(this, B, 2);
228
228
  r(this, M, !1);
229
229
  r(this, E, null);
230
- r(this, B, (e) => {
231
- e instanceof CustomEvent || (h(this, C, t(this, g).clientWidth), h(this, L, t(this, g).clientHeight), h(this, T, Math.min(t(this, _), devicePixelRatio || 1)), t(this, l).setPixelRatio(t(this, T)), t(this, l).setSize(t(this, C), t(this, L)), t(this, E) && (t(this, E).setPixelRatio(t(this, T)), t(this, E).setSize(t(this, C), t(this, L))));
230
+ r(this, G, (e) => {
231
+ e instanceof CustomEvent || (h(this, C, t(this, g).clientWidth), h(this, L, t(this, g).clientHeight), h(this, T, Math.min(t(this, B), devicePixelRatio || 1)), t(this, o).setPixelRatio(t(this, T)), t(this, o).setSize(t(this, C), t(this, L)), t(this, E) && (t(this, E).setPixelRatio(t(this, T)), t(this, E).setSize(t(this, C), t(this, L))));
232
232
  });
233
- r(this, G, () => {
234
- t(this, l).setRenderTarget(null), t(this, u).forEach((e) => {
233
+ r(this, U, () => {
234
+ t(this, o).setRenderTarget(null), t(this, m).forEach((e) => {
235
235
  this.render(e);
236
236
  });
237
237
  });
238
238
  }
239
239
  get CDNVersion() {
240
- return t(this, U);
240
+ return t(this, K);
241
241
  }
242
242
  get containerElement() {
243
243
  return t(this, g);
244
244
  }
245
245
  get webglRenderer() {
246
- return t(this, l);
246
+ return t(this, o);
247
247
  }
248
248
  get raycaster() {
249
249
  return t(this, O);
250
250
  }
251
251
  get views() {
252
- return t(this, u);
252
+ return t(this, m);
253
253
  }
254
254
  get view() {
255
255
  return this.getView("default");
@@ -273,79 +273,71 @@ class Ce {
273
273
  return t(this, E);
274
274
  }
275
275
  setup(e) {
276
- if (t(this, M)) {
277
- console.warn("[en3.setup]: You are trying to setup en3 again.");
276
+ if (t(this, M))
278
277
  return;
279
- }
280
- h(this, g, ce(e == null ? void 0 : e.containerElement) || document.body), h(this, _, (e == null ? void 0 : e.maxPixelRatio) || 2), h(this, l, new pe(e == null ? void 0 : e.webGLRendererParameters)), t(this, l).domElement.style.cssText = `
278
+ h(this, g, ce(e == null ? void 0 : e.containerElement) || document.body), h(this, B, (e == null ? void 0 : e.maxPixelRatio) || 2), h(this, o, new pe(e == null ? void 0 : e.webGLRendererParameters)), t(this, o).domElement.style.cssText = `
281
279
  position: ${(e == null ? void 0 : e.position) || "fixed"};
282
280
  left: 0;
283
281
  top: 0;
284
282
  width: 100%;
285
283
  height: 100%;
286
284
  z-index: ${(e == null ? void 0 : e.zIndex) || 0};
287
- `, (t(this, g).shadowRoot || t(this, g)).append(t(this, l).domElement), t(this, u).set(
285
+ `, (t(this, g).shadowRoot || t(this, g)).append(t(this, o).domElement), t(this, m).set(
288
286
  "default",
289
287
  new ne("default", j({
290
288
  sizeElement: t(this, g)
291
289
  }, e == null ? void 0 : e.view))
292
- ), h(this, O, new Ve()), e != null && e.composer && (h(this, E, new e.composer(t(this, l))), this.render = () => {
290
+ ), h(this, O, new Ve()), e != null && e.composer && (h(this, E, new e.composer(t(this, o))), this.render = () => {
293
291
  t(this, E).render();
294
- }), h(this, M, !0), re.subscribe(t(this, B), De.CANVAS), he.subscribe(t(this, G), {
292
+ }), h(this, M, !0), re.subscribe(t(this, G), De.CANVAS), he.subscribe(t(this, U), {
295
293
  order: ve.CANVAS,
296
294
  culling: t(this, g)
297
295
  });
298
296
  }
299
297
  destroy() {
300
298
  var e;
301
- if (!t(this, M)) {
302
- console.warn(
303
- "[en3.setup]: You are trying to destory en3 but it has not been initialized."
304
- );
305
- return;
306
- }
307
- re.unsubscribe(t(this, B)), he.unsubscribe(t(this, G)), t(this, O).destroy(), t(this, u).forEach((i) => {
299
+ t(this, M) && (re.unsubscribe(t(this, G)), he.unsubscribe(t(this, U)), t(this, O).destroy(), t(this, m).forEach((i) => {
308
300
  i.destroy();
309
- }), t(this, u).clear(), t(this, l).dispose(), t(this, l).domElement.remove(), h(this, l, null), (e = t(this, E)) == null || e.dispose(), h(this, E, null), h(this, M, !1);
301
+ }), t(this, m).clear(), t(this, o).dispose(), t(this, o).domElement.remove(), h(this, o, null), (e = t(this, E)) == null || e.dispose(), h(this, E, null), h(this, M, !1));
310
302
  }
311
303
  createView(e, i) {
312
- const a = t(this, u).size, n = new ne(e, i);
313
- return t(this, u).set(e, n), a === 1 && t(this, l).setScissorTest(!0), n;
304
+ const a = t(this, m).size, n = new ne(e, i);
305
+ return t(this, m).set(e, n), a === 1 && t(this, o).setScissorTest(!0), n;
314
306
  }
315
307
  getView(e) {
316
- return t(this, u).get(e);
308
+ return t(this, m).get(e);
317
309
  }
318
310
  destroyView(e) {
319
- const i = t(this, u).get(e);
320
- i && (t(this, u).delete(e), i.destroy(), t(this, u).size <= 1 && t(this, l).setScissorTest(!1));
311
+ const i = t(this, m).get(e);
312
+ i && (t(this, m).delete(e), i.destroy(), t(this, m).size <= 1 && t(this, o).setScissorTest(!1));
321
313
  }
322
314
  render(e) {
323
315
  var i;
324
- if (t(this, u).size > 1 || this.view.isClipped) {
325
- const a = e.box.left + e.box.CSSTranslation.x + e.box.scrollValue.x, n = m.height - e.box.height - e.box.top + e.box.CSSTranslation.y + e.box.scrollValue.y * -1;
326
- t(this, l).setScissor(a, n, e.box.width, e.box.height), t(this, l).setViewport(
316
+ if (t(this, m).size > 1 || this.view.isClipped) {
317
+ const a = e.box.left + e.box.CSSTranslation.x + e.box.scrollValue.x, n = u.height - e.box.height - e.box.top + e.box.CSSTranslation.y + e.box.scrollValue.y * -1;
318
+ t(this, o).setScissor(a, n, e.box.width, e.box.height), t(this, o).setViewport(
327
319
  a,
328
320
  n,
329
321
  e.box.width,
330
322
  e.box.height
331
323
  );
332
324
  }
333
- (i = e.beforeRenderCallback) == null || i.call(e), t(this, l).render(e.scene, e.camera);
325
+ (i = e.beforeRenderCallback) == null || i.call(e), t(this, o).render(e.scene, e.camera);
334
326
  }
335
327
  }
336
- U = new WeakMap(), g = new WeakMap(), l = new WeakMap(), O = new WeakMap(), u = new WeakMap(), C = new WeakMap(), L = new WeakMap(), T = new WeakMap(), _ = new WeakMap(), M = new WeakMap(), E = new WeakMap(), B = new WeakMap(), G = new WeakMap();
337
- const m = new Ce();
328
+ K = new WeakMap(), g = new WeakMap(), o = new WeakMap(), O = new WeakMap(), m = new WeakMap(), C = new WeakMap(), L = new WeakMap(), T = new WeakMap(), B = new WeakMap(), M = new WeakMap(), E = new WeakMap(), G = new WeakMap(), U = new WeakMap();
329
+ const u = new Ce();
338
330
  function Fe(s, e, i) {
339
331
  const a = e.x, n = e.y, z = i || s.image.width / s.image.height;
340
- let b = 0, w = 0, c = s.offset.x, f = s.offset.y, oe = s.rotation, le = s.center.x, de = s.center.y;
341
- a / n > z ? (b = 1, w = n / a * z) : (w = 1, b = a / n / z), s.matrix.setUvTransform(c, f, b, w, oe, le, de);
332
+ let b = 0, w = 0, c = s.offset.x, f = s.offset.y, le = s.rotation, oe = s.center.x, de = s.center.y;
333
+ a / n > z ? (b = 1, w = n / a * z) : (w = 1, b = a / n / z), s.matrix.setUvTransform(c, f, b, w, le, oe, de);
342
334
  }
343
- const K = new q(), Le = new q();
335
+ const X = new q(), Le = new q();
344
336
  function Ie(s, e = "default") {
345
- const i = m.getView(e), { width: a, height: n } = m, z = a / n;
346
- s instanceof q ? K.copy(s) : K.set(...s);
347
- const b = i.camera.getWorldPosition(Le).distanceTo(K);
348
- if (i.camera instanceof X)
337
+ const i = u.getView(e), { width: a, height: n } = u, z = a / n;
338
+ s instanceof q ? X.copy(s) : X.set(...s);
339
+ const b = i.camera.getWorldPosition(Le).distanceTo(X);
340
+ if (i.camera instanceof Y)
349
341
  return {
350
342
  width: a / i.camera.zoom,
351
343
  height: n / i.camera.zoom,
@@ -372,7 +364,7 @@ export {
372
364
  ne as En3View,
373
365
  Fe as coverTexture,
374
366
  Re as dispose,
375
- m as en3,
367
+ u as en3,
376
368
  Ie as getCurrentViewport,
377
369
  Ne as traverseMaterials,
378
370
  $e as traverseMeshes
@@ -10,10 +10,14 @@ export interface MorphRouteSaveState {
10
10
  export type MorpRouteSaveParametersArg = string | object | URLSearchParams;
11
11
  export declare class MorphRoute {
12
12
  #private;
13
- constructor(morph: Morph, pathname: string, initialDocument: Document);
13
+ constructor(morph: Morph, pathname: string, searchParameters?: string);
14
14
  get pathname(): string;
15
+ get searchParameters(): string | undefined;
15
16
  get scrollState(): MorphRouteScrollState;
16
17
  get document(): Document;
18
+ setInitialDocument(document: Document): void;
19
+ abort(): void | undefined;
20
+ fetch(revalidate?: boolean): Promise<void>;
17
21
  cloneDocument(): void;
18
22
  get title(): string;
19
23
  clearScrollState(): void;
@@ -1 +1 @@
1
- "use strict";var Tt=(o,t)=>(t=Symbol[o])?t:Symbol.for("Symbol."+o),Mt=o=>{throw TypeError(o)};var pt=(o,t,s)=>t.has(o)||Mt("Cannot "+s);var e=(o,t,s)=>(pt(o,t,"read from private field"),s?s.call(o):t.get(o)),a=(o,t,s)=>t.has(o)?Mt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(o):t.set(o,s),n=(o,t,s,i)=>(pt(o,t,"write to private field"),i?i.call(o,s):t.set(o,s),s),m=(o,t,s)=>(pt(o,t,"access private method"),s);var z=(o,t,s)=>new Promise((i,h)=>{var w=E=>{try{S(s.next(E))}catch(R){h(R)}},b=E=>{try{S(s.throw(E))}catch(R){h(R)}},S=E=>E.done?i(E.value):Promise.resolve(E.value).then(w,b);S((s=s.apply(o,t)).next())});var Ht=(o,t,s)=>(t=o[Tt("asyncIterator")])?t.call(o):(o=o[Tt("iterator")](),t={},s=(i,h)=>(h=o[i])&&(t[i]=w=>new Promise((b,S,E)=>(w=h.call(o,w),E=w.done,Promise.resolve(w.value).then(R=>b({value:R,done:E}),S)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Dt=require("../index-DekP7OZe.cjs"),I=require("../events-KVanG9sR.cjs"),Wt=require("../polyfills-Df4r-ETT.cjs"),Nt=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const at=require("../url-lnBE_6yf.cjs"),Yt=require("../css-value-parser/index.cjs");class Rt extends HTMLElement{connectedCallback(){const t={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[s,i]of Object.entries(t))this.setAttribute(s,i)}}Dt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Rt);var C,l,M,et,U;class Et{constructor(t,s){a(this,C);a(this,l);a(this,M);a(this,et,t=>{var i;if(t.preventDefault(),e(this,l).hasAttribute("data-back")&&e(this,C).previousPathname)history.back();else{n(this,M,e(this,l).getAttribute("href")||"/");const h=e(this,l).getAttribute("data-history-action")||"push",w=e(this,l).hasAttribute("data-center-scroll"),b=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),S=b?Yt.cssValueParser.parse(b):void 0,E=e(this,l).hasAttribute("data-revalidate"),R=e(this,l).hasAttribute("data-keep-search-parameters"),ut=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(Y=>Y.trim()),f=e(this,l).hasAttribute("data-clear-state");e(this,C).navigate(e(this,M),{historyAction:h,centerScroll:w,offsetScroll:S,revalidate:E,keepSearchParameters:R,submorph:ut,clearState:f})}});a(this,U,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,C).prefetch(e(this,M),t),e(this,l).removeEventListener("pointerenter",e(this,U))});n(this,C,s),n(this,l,t),n(this,M,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,et)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,U))}get element(){return e(this,l)}checkCurrent(t){const s=e(this,C).normalizePath(t),i=e(this,C).normalizePath(e(this,M));e(this,l).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?e(this,l).classList.add("current"):i.pathname===s.pathname?e(this,l).classList.add("current"):e(this,l).classList.remove("current")}destroy(){e(this,l).removeEventListener("click",e(this,et)),e(this,l).removeEventListener("pointerenter",e(this,U)),e(this,l).classList.remove("current")}}C=new WeakMap,l=new WeakMap,M=new WeakMap,et=new WeakMap,U=new WeakMap;var H,$,L,B,O,N,K;class qt{constructor(t,s,i){a(this,H);a(this,$);a(this,L,{x:0,y:0});a(this,B);a(this,O,null);a(this,N,null);a(this,K,null);n(this,H,t),n(this,$,s),n(this,B,i.cloneNode(!0))}get pathname(){return e(this,$)}get scrollState(){return e(this,L)}get document(){return e(this,N)}cloneDocument(){n(this,N,(e(this,O)||e(this,B)).cloneNode(!0))}get title(){let t="";if(e(this,N).title)t=e(this,N).title;else{const s=e(this,N).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,$)}return t}clearScrollState(){e(this,L).x=0,e(this,L).y=0}clearDocumentState(){n(this,O,null)}saveScrollState(){e(this,B).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,L).x=0,e(this,L).y=0):(e(this,L).x=e(this,H).scrollValue.left,e(this,L).y=e(this,H).scrollValue.top)}restoreScrollPosition(){e(this,H).scrollElement.scroll({top:e(this,L).y,left:e(this,L).x,behavior:"instant"})}saveDocumentState(){e(this,B).documentElement.hasAttribute("data-no-page-restoration")?n(this,O,null):n(this,O,document.cloneNode(!0))}renewScrollPosition(){e(this,H).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(t){n(this,K,t)}clearState(){const t=e(this,K);return n(this,K,null),t}}H=new WeakMap,$=new WeakMap,L=new WeakMap,B=new WeakMap,O=new WeakMap,N=new WeakMap,K=new WeakMap;var A,G,p,ct,q,d,st,F,x,P,it,D,W,J,Q,rt,c,lt,Vt,St,zt,vt,wt,yt,Lt,ht,Z;const tt=class tt{constructor(t){a(this,c);a(this,A,null);a(this,G,null);a(this,p,[]);a(this,ct,new DOMParser);a(this,q);a(this,d,null);a(this,st);a(this,F,[]);a(this,x,!1);a(this,P,null);a(this,it,!1);a(this,D,new Map);a(this,W,null);a(this,J,0);a(this,Q,0);a(this,rt,t=>{var s;return((s=t.getAttribute("href"))==null?void 0:s.startsWith("/"))&&!t.hasAttribute("download")&&!t.hasAttribute("data-morph-skip")&&!t.closest("[data-morph-skip]")&&t.getAttribute("target")!=="_blank"});a(this,ht,t=>z(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(t.preventDefault(),n(this,x,!0),yield this.navigate(t.state.path,{historyAction:"none"}),n(this,x,!1))}));a(this,Z,()=>{const{left:t,top:s}=this.scrollValue,i=s-e(this,Q),h=t-e(this,J);n(this,Q,s),n(this,J,t),document.documentElement.classList.toggle("scroll-y",s>0),document.documentElement.classList.toggle("scroll-x",t>0),document.documentElement.classList.toggle("scroll-y-forward",i>0),document.documentElement.classList.toggle("scroll-y-backward",i<0),document.documentElement.classList.toggle("scroll-x-forward",h>0),document.documentElement.classList.toggle("scroll-x-backward",h<0),I.dispatchEvent(document,"morphScroll",{detail:{left:t,top:s}})});if(Dt.isBrowser&&!tt.instance){tt.instance=this,n(this,A,{base:at.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,cachePages:(t==null?void 0:t.cachePages)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:t==null?void 0:t.scrollSelector,morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),n(this,G,m(this,c,St).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);n(this,d,s.pathname),e(this,D).set(e(this,d),new qt(this,e(this,d),document)),document.documentElement.setAttribute("data-current-pathname",e(this,d)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),history.scrollRestoration="manual",addEventListener("popstate",e(this,ht)),at.changeHistory({action:"replace",pathname:e(this,d),searchParameters:s.parameters||location.search,hash:s.hash}),n(this,W,new Rt),m(this,c,yt).call(this,document)}}get currentPathname(){return e(this,d)}get previousPathname(){return e(this,st)}get links(){return e(this,p)}get scrollElement(){return e(this,P)}get isPopstateNavigation(){return e(this,x)}get scrollValue(){let t=0,s=0;return e(this,it)?(t=window.scrollY,s=window.scrollX):(t=e(this,P).scrollTop,s=e(this,P).scrollLeft),{top:t,left:s}}saveState(t){const s=e(this,D).get(e(this,d));s&&s.saveState(t)}getState(){const t=e(this,D).get(e(this,d));return t==null?void 0:t.clearState()}normalizePath(t){return at.splitPath(t,{base:e(this,A).base,trailingSlash:e(this,A).trailingSlash})}prefetch(t,s){return z(this,null,function*(){const i=this.normalizePath(t);m(this,c,lt).call(this,i.pathname,{searchParameters:i.parameters,revalidate:s})})}navigate(R){return z(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:h,revalidate:w,keepSearchParameters:b,submorph:S,clearState:E}={}){var Pt;if(e(this,F).length)return;const ut=this.normalizePath(((Pt=this.pathnameModifier)==null?void 0:Pt.call(this,t))||t);let{pathname:f,hash:Y,parameters:bt,leaf:It}=ut;if(e(this,q)===f||e(this,d)===f){e(this,x)||m(this,c,Lt).call(this,Y||0,{centerScroll:i,offsetScroll:h,behavior:"smooth"});return}n(this,q,f),e(this,p).forEach(X=>{X.checkCurrent(f)});try{let X=!0;if(this.preprocessor)try{yield new Promise((r,k)=>{var y;(y=this.preprocessor)==null||y.call(this,{pathname:f,resolve:r,reject:k,submorph:S})})}catch(r){r?console.error(r):console.log("Route change canceled"),X=!1}if(!X||e(this,q)!==f){e(this,p).forEach(r=>{r.checkCurrent(e(this,d))});return}const dt={pathname:f,submorph:S};I.dispatchEvent(document,"morphNavigation",{detail:dt});const mt=yield m(this,c,lt).call(this,e(this,d)),v=yield m(this,c,lt).call(this,f,{searchParameters:bt,revalidate:w});if(e(this,q)!==f){e(this,p).forEach(r=>{r.checkCurrent(e(this,d))});return}mt.clearState(),mt.saveScrollState(),mt.saveDocumentState(),e(this,x)||(v.clearScrollState(),v.clearDocumentState()),E&&v.clearState(),v.cloneDocument(),e(this,W).textContent=v.title,document.body.appendChild(e(this,W)),I.dispatchEvent(document,"morphStart",{detail:dt});const At=Array.from(document.head.children),kt=Array.from(v.document.head.children),Ct=m(this,c,zt).call(this,At,kt),Bt=m(this,c,vt).call(this,At,Ct),nt=m(this,c,vt).call(this,kt,Ct);nt.forEach((r,k)=>{if(r.tagName==="SCRIPT"&&r.getAttribute("src")){const y=document.createElement("script");y.type="module",y.src=r.getAttribute("src"),nt[k]=y}}),nt.forEach(r=>{document.head.appendChild(r)});const ft=nt.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(m(this,c,wt).call(this,r))return!0});e(this,A).waitForHeadToLoad&&ft.length&&(yield new Promise(r=>z(this,null,function*(){let k=0;try{for(var y=Ht(ft),_,V,j;_=!(V=yield y.next()).done;_=!1){const ot=V.value;ot.onload=()=>{k++,k===ft.length&&r()}}}catch(V){j=[V]}finally{try{_&&(V=y.return)&&(yield V.call(y))}finally{if(j)throw j[0]}}}))),yield Nt.wait(10);const xt=[];Bt.forEach(r=>{r.hasAttribute("data-permanent")||(m(this,c,wt).call(this,r)?xt.push(r):r.remove())});const Ot=m(this,c,St).call(this,v.document.body);e(this,A).morphInsideScrollContainer||m(this,c,yt).call(this,v.document),document.documentElement.setAttribute("data-current-pathname",f),document.documentElement.setAttribute("data-current-leaf",It),at.changeHistory({action:s,pathname:f,searchParameters:bt||(b?location.search:""),hash:Y}),e(this,W).remove(),n(this,st,e(this,d)),n(this,d,f),e(this,G).forEach((r,k)=>{const y=Ot[k],_=getComputedStyle(r).getPropertyValue("--morph-duration");let V=[],j=[];S?S.forEach(u=>{const g=r.querySelector(u),T=y.querySelector(u);g&&T&&(j.push(g),V.push(T))}):(V.push(...y.childNodes),j.push(...r.childNodes)),j.forEach(u=>{u instanceof HTMLElement&&(this.destroyOldLinks(u),u.classList.add("old"))}),V.forEach(u=>{u instanceof HTMLElement&&(this.findNewLinks(u),u.classList.add("new"))}),S?V.forEach((u,g)=>{var T;(T=j[g].parentElement)==null||T.insertBefore(u,j[g])}):r.prepend(...V),Wt.requestIdleCallback(()=>{V.forEach(u=>{var g;u instanceof HTMLElement&&((g=u.parentElement)==null||g.style.setProperty("--new-content-height",u.offsetHeight+"px"),u.classList.add("in"))})});const ot={morphElement:r,pathname:f};I.dispatchEvent(document,"morphNewChildrenAdded",{detail:ot});const Ft=new Promise(u=>{setTimeout(()=>{j.forEach(g=>g.remove()),V.forEach(g=>{var T;g instanceof HTMLElement&&((T=g.parentElement)==null||T.style.removeProperty("--new-content-height"),g.classList.remove("in","new"))}),I.dispatchEvent(document,"morphOldChildrenRemoved",{detail:ot}),u()},(parseFloat(_)||0)*1e3+10)});e(this,F).push(Ft)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-v.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),I.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:v.scrollState}),Y?(v.clearScrollState(),m(this,c,Lt).call(this,Y,{centerScroll:i,offsetScroll:h})):e(this,x)?v.restoreScrollPosition():v.renewScrollPosition(),yield Promise.all(e(this,F)),xt.forEach(r=>r.remove()),n(this,F,[]),e(this,G).forEach(r=>{r.querySelectorAll("script").forEach(y=>{const _=document.createElement("script");_.type="module",_.src=y.getAttribute("src"),y.replaceWith(_)})}),I.dispatchEvent(document,"morphComplete",{detail:dt}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch(X){console.error(X)}n(this,q,void 0)})}addLink(t){e(this,p).push(new Et(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){n(this,p,e(this,p).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){n(this,p,e(this,p).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,rt));e(this,p).push(...s.map(i=>new Et(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,rt));e(this,p).forEach(s=>s.destroy()),n(this,p,t.map(s=>new Et(s,this)))}};A=new WeakMap,G=new WeakMap,p=new WeakMap,ct=new WeakMap,q=new WeakMap,d=new WeakMap,st=new WeakMap,F=new WeakMap,x=new WeakMap,P=new WeakMap,it=new WeakMap,D=new WeakMap,W=new WeakMap,J=new WeakMap,Q=new WeakMap,rt=new WeakMap,c=new WeakSet,lt=function(t,s){return z(this,null,function*(){let i=e(this,D).get(t);return(!i||s!=null&&s.revalidate)&&(i=yield m(this,c,Vt).call(this,t,s==null?void 0:s.searchParameters)),i})},Vt=function(t,s){return z(this,null,function*(){const h=yield(yield fetch(`${t}${s?"?"+s:""}`)).text(),w=e(this,ct).parseFromString(h,"text/html"),b=new qt(this,t,w);return e(this,D).set(t,b),b})},St=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},zt=function(t,s){return t.filter(i=>s.find(h=>h.outerHTML===i.outerHTML))},vt=function(t,s){return t.filter(i=>!s.find(h=>h.outerHTML===i.outerHTML))},wt=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},yt=function(t){var s,i;(s=e(this,P))==null||s.removeEventListener("scroll",e(this,Z)),n(this,Q,0),n(this,J,0),n(this,P,e(this,A).scrollSelector&&t.querySelector(e(this,A).scrollSelector)||window),n(this,it,e(this,P)===window),(i=e(this,P))==null||i.addEventListener("scroll",e(this,Z)),e(this,Z).call(this)},Lt=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Nt.scrollToElement(i,{scrollElement:e(this,P),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},ht=new WeakMap,Z=new WeakMap,tt.instance=null;let gt=tt;exports.Morph=gt;
1
+ "use strict";var Ht=(a,t)=>(t=Symbol[a])?t:Symbol.for("Symbol."+a),Nt=a=>{throw TypeError(a)};var gt=(a,t,s)=>t.has(a)||Nt("Cannot "+s);var e=(a,t,s)=>(gt(a,t,"read from private field"),s?s.call(a):t.get(a)),o=(a,t,s)=>t.has(a)?Nt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(a):t.set(a,s),r=(a,t,s,i)=>(gt(a,t,"write to private field"),i?i.call(a,s):t.set(a,s),s),p=(a,t,s)=>(gt(a,t,"access private method"),s);var z=(a,t,s)=>new Promise((i,c)=>{var w=g=>{try{v(s.next(g))}catch(R){c(R)}},x=g=>{try{v(s.throw(g))}catch(R){c(R)}},v=g=>g.done?i(g.value):Promise.resolve(g.value).then(w,x);v((s=s.apply(a,t)).next())});var qt=(a,t,s)=>(t=a[Ht("asyncIterator")])?t.call(a):(a=a[Ht("iterator")](),t={},s=(i,c)=>(c=a[i])&&(t[i]=w=>new Promise((x,v,g)=>(w=c.call(a,w),g=w.done,Promise.resolve(w.value).then(R=>x({value:R,done:g}),v)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Rt=require("../index-DekP7OZe.cjs"),B=require("../events-KVanG9sR.cjs"),Yt=require("../polyfills-Df4r-ETT.cjs"),Dt=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const ht=require("../url-lnBE_6yf.cjs"),Xt=require("../css-value-parser/index.cjs");class Vt extends HTMLElement{connectedCallback(){const t={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[s,i]of Object.entries(t))this.setAttribute(s,i)}}Rt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Vt);var k,l,H,it,K;class St{constructor(t,s){o(this,k);o(this,l);o(this,H);o(this,it,t=>{var i;if(t.preventDefault(),e(this,l).hasAttribute("data-back")&&e(this,k).previousPathname)history.back();else{r(this,H,e(this,l).getAttribute("href")||"/");const c=e(this,l).getAttribute("data-history-action")||"push",w=e(this,l).hasAttribute("data-center-scroll"),x=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),v=x?Xt.cssValueParser.parse(x):void 0,g=e(this,l).hasAttribute("data-revalidate"),R=e(this,l).hasAttribute("data-keep-search-parameters"),mt=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map($=>$.trim()),m=e(this,l).hasAttribute("data-clear-state");e(this,k).navigate(e(this,H),{historyAction:c,centerScroll:w,offsetScroll:v,revalidate:g,keepSearchParameters:R,submorph:mt,clearState:m})}});o(this,K,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,k).prefetch(e(this,H),t),e(this,l).removeEventListener("pointerenter",e(this,K))});r(this,k,s),r(this,l,t),r(this,H,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,it)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,K))}get element(){return e(this,l)}checkCurrent(t){const s=e(this,k).normalizePath(t),i=e(this,k).normalizePath(e(this,H));e(this,l).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?e(this,l).classList.add("current"):i.pathname===s.pathname?e(this,l).classList.add("current"):e(this,l).classList.remove("current")}destroy(){e(this,l).removeEventListener("click",e(this,it)),e(this,l).removeEventListener("pointerenter",e(this,K)),e(this,l).classList.remove("current")}}k=new WeakMap,l=new WeakMap,H=new WeakMap,it=new WeakMap,K=new WeakMap;const $t=new DOMParser;var N,G,rt,b,q,O,D,J,F,W;class It{constructor(t,s,i){o(this,N);o(this,G);o(this,rt);o(this,b,{x:0,y:0});o(this,q,null);o(this,O,null);o(this,D,null);o(this,J,null);o(this,F,null);o(this,W,null);r(this,N,t),r(this,G,s),r(this,rt,i)}get pathname(){return e(this,G)}get searchParameters(){return e(this,rt)}get scrollState(){return e(this,b)}get document(){return e(this,D)}setInitialDocument(t){r(this,q,t.cloneNode(!0))}abort(){var t;return(t=e(this,F))==null?void 0:t.abort(`[${this.pathname}] page loading cancelled`)}fetch(t){return z(this,null,function*(){if(!(e(this,q)&&!t)){if(e(this,W))return e(this,W);r(this,W,new Promise(s=>z(this,null,function*(){try{r(this,F,new AbortController);const c=yield(yield fetch(`${this.pathname}${this.searchParameters?"?"+this.searchParameters:""}`,{signal:e(this,F).signal})).text(),w=$t.parseFromString(c,"text/html");this.setInitialDocument(w)}catch(i){console.warn(i)}finally{r(this,F,null),r(this,W,null),s()}})))}})}cloneDocument(){r(this,D,(e(this,O)||e(this,q)).cloneNode(!0))}get title(){let t="";if(e(this,D).title)t=e(this,D).title;else{const s=e(this,D).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,G)}return t}clearScrollState(){e(this,b).x=0,e(this,b).y=0}clearDocumentState(){r(this,O,null)}saveScrollState(){e(this,q).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,b).x=0,e(this,b).y=0):(e(this,b).x=e(this,N).scrollValue.left,e(this,b).y=e(this,N).scrollValue.top)}restoreScrollPosition(){e(this,N).scrollElement.scroll({top:e(this,b).y,left:e(this,b).x,behavior:"instant"})}saveDocumentState(){e(this,q).documentElement.hasAttribute("data-no-page-restoration")?r(this,O,null):r(this,O,document.cloneNode(!0))}renewScrollPosition(){e(this,N).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(t){r(this,J,t)}clearState(){const t=e(this,J);return r(this,J,null),t}}N=new WeakMap,G=new WeakMap,rt=new WeakMap,b=new WeakMap,q=new WeakMap,O=new WeakMap,D=new WeakMap,J=new WeakMap,F=new WeakMap,W=new WeakMap;var P,Q,E,I,d,nt,Y,C,L,ot,T,X,Z,_,at,h,ut,wt,zt,yt,bt,Lt,Pt,dt,tt;const st=class st{constructor(t){o(this,h);o(this,P,null);o(this,Q,null);o(this,E,[]);o(this,I);o(this,d,null);o(this,nt);o(this,Y,[]);o(this,C,!1);o(this,L,null);o(this,ot,!1);o(this,T,new Map);o(this,X,null);o(this,Z,0);o(this,_,0);o(this,at,t=>{var s;return((s=t.getAttribute("href"))==null?void 0:s.startsWith("/"))&&!t.hasAttribute("download")&&!t.hasAttribute("data-morph-skip")&&!t.closest("[data-morph-skip]")&&t.getAttribute("target")!=="_blank"});o(this,dt,t=>z(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(t.preventDefault(),r(this,C,!0),yield this.navigate(t.state.path,{historyAction:"none"}),r(this,C,!1))}));o(this,tt,()=>{const{left:t,top:s}=this.scrollValue,i=s-e(this,_),c=t-e(this,Z);r(this,_,s),r(this,Z,t),document.documentElement.classList.toggle("scroll-y",s>0),document.documentElement.classList.toggle("scroll-x",t>0),document.documentElement.classList.toggle("scroll-y-forward",i>0),document.documentElement.classList.toggle("scroll-y-backward",i<0),document.documentElement.classList.toggle("scroll-x-forward",c>0),document.documentElement.classList.toggle("scroll-x-backward",c<0),B.dispatchEvent(document,"morphScroll",{detail:{left:t,top:s}})});if(Rt.isBrowser&&!st.instance){st.instance=this,r(this,P,{base:ht.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,cachePages:(t==null?void 0:t.cachePages)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:t==null?void 0:t.scrollSelector,morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),r(this,Q,p(this,h,wt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);r(this,d,s.pathname);const i=new It(this,e(this,d));i.setInitialDocument(document),e(this,T).set(e(this,d),i),document.documentElement.setAttribute("data-current-pathname",e(this,d)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),history.scrollRestoration="manual",addEventListener("popstate",e(this,dt)),ht.changeHistory({action:"replace",pathname:e(this,d),searchParameters:s.parameters||location.search,hash:s.hash}),r(this,X,new Vt),p(this,h,Lt).call(this,document)}}get currentPathname(){return e(this,d)}get previousPathname(){return e(this,nt)}get links(){return e(this,E)}get scrollElement(){return e(this,L)}get isPopstateNavigation(){return e(this,C)}get scrollValue(){let t=0,s=0;return e(this,ot)?(t=window.scrollY,s=window.scrollX):(t=e(this,L).scrollTop,s=e(this,L).scrollLeft),{top:t,left:s}}saveState(t){const s=e(this,T).get(e(this,d));s&&s.saveState(t)}getState(){const t=e(this,T).get(e(this,d));return t==null?void 0:t.clearState()}normalizePath(t){return ht.splitPath(t,{base:e(this,P).base,trailingSlash:e(this,P).trailingSlash})}prefetch(t,s){return z(this,null,function*(){const i=this.normalizePath(t),c=p(this,h,ut).call(this,i.pathname,i.parameters);c==null||c.fetch(s)})}navigate(R){return z(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:c,revalidate:w,keepSearchParameters:x,submorph:v,clearState:g}={}){var kt;if(e(this,Y).length)return;const mt=this.normalizePath(((kt=this.pathnameModifier)==null?void 0:kt.call(this,t))||t);let{pathname:m,hash:$,parameters:At,leaf:Bt}=mt;if(e(this,I)===m||e(this,d)===m){e(this,C)||p(this,h,Pt).call(this,$||0,{centerScroll:i,offsetScroll:c,behavior:"smooth"});return}r(this,I,m),e(this,E).forEach(j=>{j.checkCurrent(m)});try{let j=!0;if(this.preprocessor)try{yield new Promise((n,A)=>{var y;(y=this.preprocessor)==null||y.call(this,{pathname:m,resolve:n,reject:A,submorph:v})})}catch(n){n?console.error(n):console.log("Route change canceled"),j=!1}if(!j||e(this,I)!==m){e(this,E).forEach(n=>{n.checkCurrent(e(this,d))});return}const ft={pathname:m,submorph:v};B.dispatchEvent(document,"morphNavigation",{detail:ft});const pt=p(this,h,ut).call(this,e(this,d)),f=p(this,h,ut).call(this,m,At);if(e(this,T).forEach(n=>{n.pathname!==m&&n.abort()}),yield f==null?void 0:f.fetch(w),e(this,I)!==m){e(this,E).forEach(n=>{n.checkCurrent(e(this,d))});return}pt.clearState(),pt.saveScrollState(),pt.saveDocumentState(),e(this,C)||(f.clearScrollState(),f.clearDocumentState()),g&&f.clearState(),f.cloneDocument(),e(this,X).textContent=f.title,document.body.appendChild(e(this,X)),B.dispatchEvent(document,"morphStart",{detail:ft});const Ct=Array.from(document.head.children),Tt=Array.from(f.document.head.children),xt=p(this,h,zt).call(this,Ct,Tt),Ot=p(this,h,yt).call(this,Ct,xt),lt=p(this,h,yt).call(this,Tt,xt);lt.forEach((n,A)=>{if(n.tagName==="SCRIPT"&&n.getAttribute("src")){const y=document.createElement("script");y.type="module",y.src=n.getAttribute("src"),lt[A]=y}}),lt.forEach(n=>{document.head.appendChild(n)});const Et=lt.filter(n=>{if(n.hasAttribute("data-no-waiting"))return!1;if(p(this,h,bt).call(this,n))return!0});e(this,P).waitForHeadToLoad&&Et.length&&(yield new Promise(n=>z(this,null,function*(){let A=0;try{for(var y=qt(Et),et,V,U;et=!(V=yield y.next()).done;et=!1){const ct=V.value;ct.onload=()=>{A++,A===Et.length&&n()}}}catch(V){U=[V]}finally{try{et&&(V=y.return)&&(yield V.call(y))}finally{if(U)throw U[0]}}}))),yield Dt.wait(10);const Mt=[];Ot.forEach(n=>{n.hasAttribute("data-permanent")||(p(this,h,bt).call(this,n)?Mt.push(n):n.remove())});const Ft=p(this,h,wt).call(this,f.document.body);e(this,P).morphInsideScrollContainer||p(this,h,Lt).call(this,f.document),document.documentElement.setAttribute("data-current-pathname",m),document.documentElement.setAttribute("data-current-leaf",Bt),ht.changeHistory({action:s,pathname:m,searchParameters:At||(x?location.search:""),hash:$}),e(this,X).remove(),r(this,nt,e(this,d)),r(this,d,m),e(this,Q).forEach((n,A)=>{const y=Ft[A],et=getComputedStyle(n).getPropertyValue("--morph-duration");let V=[],U=[];v?v.forEach(u=>{const S=n.querySelector(u),M=y.querySelector(u);S&&M&&(U.push(S),V.push(M))}):(V.push(...y.childNodes),U.push(...n.childNodes)),U.forEach(u=>{u instanceof HTMLElement&&(this.destroyOldLinks(u),u.classList.add("old"))}),V.forEach(u=>{u instanceof HTMLElement&&(this.findNewLinks(u),u.classList.add("new"))}),v?V.forEach((u,S)=>{var M;(M=U[S].parentElement)==null||M.insertBefore(u,U[S])}):n.prepend(...V),Yt.requestIdleCallback(()=>{V.forEach(u=>{var S;u instanceof HTMLElement&&((S=u.parentElement)==null||S.style.setProperty("--new-content-height",u.offsetHeight+"px"),u.classList.add("in"))})});const ct={morphElement:n,pathname:m};B.dispatchEvent(document,"morphNewChildrenAdded",{detail:ct});const Wt=new Promise(u=>{setTimeout(()=>{U.forEach(S=>S.remove()),V.forEach(S=>{var M;S instanceof HTMLElement&&((M=S.parentElement)==null||M.style.removeProperty("--new-content-height"),S.classList.remove("in","new"))}),B.dispatchEvent(document,"morphOldChildrenRemoved",{detail:ct}),u()},(parseFloat(et)||0)*1e3+10)});e(this,Y).push(Wt)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-f.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),B.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:f.scrollState}),$?(f.clearScrollState(),p(this,h,Pt).call(this,$,{centerScroll:i,offsetScroll:c})):e(this,C)?f.restoreScrollPosition():f.renewScrollPosition(),yield Promise.all(e(this,Y)),Mt.forEach(n=>n.remove()),r(this,Y,[]),e(this,Q).forEach(n=>{n.querySelectorAll("script").forEach(y=>{const et=document.createElement("script");et.type="module",et.src=y.getAttribute("src"),y.replaceWith(et)})}),B.dispatchEvent(document,"morphComplete",{detail:ft}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch(j){console.error(j)}r(this,I,void 0)})}addLink(t){e(this,E).push(new St(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){r(this,E,e(this,E).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){r(this,E,e(this,E).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,at));e(this,E).push(...s.map(i=>new St(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,at));e(this,E).forEach(s=>s.destroy()),r(this,E,t.map(s=>new St(s,this)))}};P=new WeakMap,Q=new WeakMap,E=new WeakMap,I=new WeakMap,d=new WeakMap,nt=new WeakMap,Y=new WeakMap,C=new WeakMap,L=new WeakMap,ot=new WeakMap,T=new WeakMap,X=new WeakMap,Z=new WeakMap,_=new WeakMap,at=new WeakMap,h=new WeakSet,ut=function(t,s){let i=e(this,T).get(t);return i||(i=new It(this,t,s),e(this,T).set(t,i)),i},wt=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},zt=function(t,s){return t.filter(i=>s.find(c=>c.outerHTML===i.outerHTML))},yt=function(t,s){return t.filter(i=>!s.find(c=>c.outerHTML===i.outerHTML))},bt=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},Lt=function(t){var s,i;(s=e(this,L))==null||s.removeEventListener("scroll",e(this,tt)),r(this,_,0),r(this,Z,0),r(this,L,e(this,P).scrollSelector&&t.querySelector(e(this,P).scrollSelector)||window),r(this,ot,e(this,L)===window),(i=e(this,L))==null||i.addEventListener("scroll",e(this,tt)),e(this,tt).call(this)},Pt=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Dt.scrollToElement(i,{scrollElement:e(this,L),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},dt=new WeakMap,tt=new WeakMap,st.instance=null;let vt=st;exports.Morph=vt;