origami-loaders 0.1.0 → 0.1.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased
4
+
5
+ - `frog` folds the way origami.me teaches it. After the front legs, the bottom folds up and the sides fold in. Then the bottom is pushed up and its side flaps squash out to become real back legs. The bottom then folds up and back down in half for the spring. The finished frog sits side-on and pitches nose-up as it hops.
6
+
7
+ ## 0.1.1
8
+
9
+ - The README links to the demo site, [origami-loaders.vercel.app](https://origami-loaders.vercel.app), where every model, look and paper colour folds live.
10
+ - The package's homepage on npm is the demo site.
11
+
3
12
  ## 0.1.0
4
13
 
5
14
  The first release. `<origami-loader>` is a loader that folds a sheet of paper into an origami model, drawn in 3D as live SVG. It is one web component with no dependencies, and works in plain HTML, React, Vue, Svelte or any other framework.
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  **Loaders that fold.** 3D origami animations rendered as lightweight SVG — no canvas, no WebGL, no dependencies.
4
4
 
5
+ **[See them fold →](https://origami-loaders.vercel.app)** Every model, look and paper colour, live, in example apps. Pick one and copy its tag.
6
+
5
7
  A framework-agnostic web component: drop `<origami-loader>` into any page, React, Vue, Svelte or plain HTML.
6
8
 
7
9
  ## Install
@@ -95,7 +97,7 @@ el.restart(); // or set progress again to fold a fresh sheet
95
97
  | `pleat` | An accordion that breathes. Made for "thinking" and other waits with no end in sight. |
96
98
  | `envelope` | Four corners to the centre, so progress maps neatly: a quarter of the work, one corner. |
97
99
  | `boat` | A sailboat in three folds. Rocks on the water, then sails off. |
98
- | `frog` | The traditional jumping frog, from a waterbomb base. Its pleat is a spring: it hops twice, then hops away. |
100
+ | `frog` | The traditional jumping frog, from a waterbomb base. The back legs are a squash fold, and its pleat is a spring: it hops twice, then hops away. |
99
101
  | `swan` | Kite, neck, head. Drifts on the water, then glides off. |
100
102
  | `heart` | The classic heart, folded on the side you see. It beats. |
101
103
  | `whale` | The traditional whale, from a fish base: the rabbit ears become its flippers. Swims, flicks its tail, then dives. |
@@ -136,7 +138,7 @@ A model is written the way origami is taught: one fold at a time, against the pa
136
138
 
137
139
  1. **Folds cut the paper.** Each fold splits the faces it passes through along the fold line, so the crease pattern builds itself (`src/fold.ts`).
138
140
  2. **Joints move the faces.** A hinge rotates faces about a fold line; joints chain, so a flap can fold while it is being lifted. A **reverse fold** mirrors the point across its crease, so it turns inside out and stays joined along the crease, tucked between the layers (inside) or wrapped round them (outside). It gets there the way fingers move it: it swings round and turns over about its own spine, opening like a book.
139
- 3. **Compound folds are solved.** The square base and the petal folds move several creases at once. Those angles are left free, `pin` says which corners must stay together, and a small Gauss–Newton solver works out the angles along the whole motion so the paper never tears. The frog's waterbomb base is worked out exactly instead: as each side triangle turns in by θ, the top comes down by γ = 2·atan(tan(θ/2)/√2).
141
+ 3. **Compound folds are solved.** The square base and the petal folds move several creases at once. Those angles are left free, `pin` says which corners must stay together, and a small Gauss–Newton solver works out the angles along the whole motion so the paper never tears. Some are worked out exactly instead. In the frog's waterbomb base, as each side triangle turns in by θ, the top comes down by γ = 2·atan(tan(θ/2)/√2). In its squash, the bottom rises in front, each side flap's middle triangle turns over just fast enough to keep its two creases 45° apart, and the lower triangle swings out between them. The whale's rabbit ears are tracked numerically so the two halves of each ear meet back to back.
140
142
  4. **Layers are tracked.** After every step the engine works out which face ended up on top wherever two overlap, and gives every face a layer height, so flat stacks have real thickness. Paper that stands up, like a crane's spread wings, keeps its stacking turned with it.
141
143
  5. **Rendering.** Faces are projected with a perspective camera and shaded by how they face a light. Faces lying flat together are drawn as one panel and painted back-to-front with plane tests and a topological sort; where no plane separates two panels, the one nearer the eye where they actually overlap goes on top (`src/scene.ts`).
142
144
  6. **Paper.** Paper Shaders' paper-texture shader renders the grain once per page on a hidden WebGL canvas; the result is baked into an image that each panel maps in sheet space, so the grain folds with the paper (`src/paper-shader.ts`, with a small CPU fallback in `src/texture.ts`).
@@ -194,6 +196,8 @@ From then on, npm trusts this repo's publish workflow directly (trusted publishi
194
196
  git push && git push --tags
195
197
  ```
196
198
 
199
+ Or, once the version bump is on `main`, publish a GitHub Release with a new tag such as `v0.1.1` on `main` (Releases, Draft a new release). Creating the tag starts the same publish.
200
+
197
201
  3. Once that release is out, go to the package's Settings, Publishing access, and choose **Require two-factor authentication and disallow tokens**, so a leaked token can never publish.
198
202
 
199
203
  ## Credits
@@ -1,4 +1,4 @@
1
- "use strict";var OrigamiLoaders=(()=>{var We=Object.defineProperty;var Sr=Object.getOwnPropertyDescriptor;var Er=Object.getOwnPropertyNames;var Br=Object.prototype.hasOwnProperty;var Fr=(e,t,r)=>t in e?We(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Z=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(o){throw r=[o],o}};var io=(e,t)=>{for(var r in t)We(e,r,{get:t[r],enumerable:!0})},kr=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Er(t))!Br.call(e,n)&&n!==r&&We(e,n,{get:()=>t[n],enumerable:!(o=Sr(t,n))||o.enumerable});return e};var Ir=e=>kr(We({},"__esModule",{value:!0}),e);var P=(e,t,r)=>Fr(e,typeof t!="symbol"?t+"":t,r);var ar,sr=Z(()=>{ar=`#version 300 es
1
+ "use strict";var OrigamiLoaders=(()=>{var Je=Object.defineProperty;var Ir=Object.getOwnPropertyDescriptor;var Cr=Object.getOwnPropertyNames;var Rr=Object.prototype.hasOwnProperty;var Dr=(e,t,r)=>t in e?Je(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var $=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(o){throw r=[o],o}};var co=(e,t)=>{for(var r in t)Je(e,r,{get:t[r],enumerable:!0})},Qr=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Cr(t))!Rr.call(e,i)&&i!==r&&Je(e,i,{get:()=>t[i],enumerable:!(o=Ir(t,i))||o.enumerable});return e};var Ur=e=>Qr(Je({},"__esModule",{value:!0}),e);var P=(e,t,r)=>Dr(e,typeof t!="symbol"?t+"":t,r);var ur,hr=$(()=>{ur=`#version 300 es
2
2
  precision mediump float;
3
3
 
4
4
  layout(location = 0) in vec4 a_position;
@@ -148,7 +148,7 @@ void main() {
148
148
 
149
149
  v_imageUV += .5;
150
150
  v_imageUV.y = 1. - v_imageUV.y;
151
- }`});function cr(e,t,r){let o=e.createShader(t);return o?(e.shaderSource(o,r),e.compileShader(o),e.getShaderParameter(o,e.COMPILE_STATUS)?o:(console.error("An error occurred compiling the shaders: "+e.getShaderInfoLog(o)),e.deleteShader(o),null)):null}function yn(e,t,r){let o=e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT),n=o?o.precision:null;n&&n<23&&(t=t.replace(/precision\s+(lowp|mediump)\s+float;/g,"precision highp float;"),r=r.replace(/precision\s+(lowp|mediump)\s+float/g,"precision highp float").replace(/\b(uniform|varying|attribute)\s+(lowp|mediump)\s+(\w+)/g,"$1 highp $3"));let i=cr(e,e.VERTEX_SHADER,t),s=cr(e,e.FRAGMENT_SHADER,r);if(!i||!s)return null;let a=e.createProgram();return a?(e.attachShader(a,i),e.attachShader(a,s),e.linkProgram(a),e.getProgramParameter(a,e.LINK_STATUS)?(e.detachShader(a,i),e.detachShader(a,s),e.deleteShader(i),e.deleteShader(s),a):(console.error("Unable to initialize the shader program: "+e.getProgramInfoLog(a)),e.deleteProgram(a),e.deleteShader(i),e.deleteShader(s),null)):null}function Pn(){let e=navigator.userAgent.toLowerCase();return e.includes("safari")&&!e.includes("chrome")&&!e.includes("android")}function Sn(e){let t=visualViewport?.scale??1,r=visualViewport?.width??window.innerWidth,o=window.innerWidth-e.documentElement.clientWidth,n=t*r+o,i=outerWidth/n,s=Math.round(100*i);return s%5===0?s/100:s===33?1/3:s===67?2/3:s===133?4/3:i}var lr,Ge,Mn,dr=Z(()=>{sr();lr=1920*1080*4,Ge=class{constructor(t,r,o,n,i=0,s=0,a=2,c=lr,d=[]){P(this,"parentElement");P(this,"canvasElement");P(this,"gl");P(this,"program",null);P(this,"uniformLocations",{});P(this,"fragmentShader");P(this,"rafId",null);P(this,"lastRenderTime",0);P(this,"currentFrame",0);P(this,"speed",0);P(this,"currentSpeed",0);P(this,"providedUniforms");P(this,"mipmaps",[]);P(this,"hasBeenDisposed",!1);P(this,"resolutionChanged",!0);P(this,"textures",new Map);P(this,"minPixelRatio");P(this,"maxPixelCount");P(this,"isSafari",Pn());P(this,"uniformCache",{});P(this,"textureUnitMap",new Map);P(this,"ownerDocument");P(this,"initProgram",()=>{let t=yn(this.gl,ar,this.fragmentShader);t&&(this.program=t,this.gl.useProgram(t))});P(this,"setupPositionAttribute",()=>{let t=this.gl.getAttribLocation(this.program,"a_position"),r=this.gl.createBuffer();this.gl.bindBuffer(this.gl.ARRAY_BUFFER,r);let o=[-1,-1,1,-1,-1,1,-1,1,1,-1,1,1];this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(o),this.gl.STATIC_DRAW),this.gl.enableVertexAttribArray(t),this.gl.vertexAttribPointer(t,2,this.gl.FLOAT,!1,0,0)});P(this,"setupUniforms",()=>{let t={u_time:this.gl.getUniformLocation(this.program,"u_time"),u_pixelRatio:this.gl.getUniformLocation(this.program,"u_pixelRatio"),u_resolution:this.gl.getUniformLocation(this.program,"u_resolution")};Object.entries(this.providedUniforms).forEach(([r,o])=>{if(t[r]=this.gl.getUniformLocation(this.program,r),o instanceof HTMLImageElement){let n=`${r}AspectRatio`;t[n]=this.gl.getUniformLocation(this.program,n)}}),this.uniformLocations=t});P(this,"renderScale",1);P(this,"parentWidth",0);P(this,"parentHeight",0);P(this,"parentDevicePixelWidth",0);P(this,"parentDevicePixelHeight",0);P(this,"devicePixelsSupported",!1);P(this,"intersectionObserver",null);P(this,"isInViewport",!0);P(this,"resizeObserver",null);P(this,"setupResizeObserver",()=>{this.resizeObserver=new ResizeObserver(([t])=>{if(t?.borderBoxSize[0]){let r=t.devicePixelContentBoxSize?.[0];r!==void 0&&(this.devicePixelsSupported=!0,this.parentDevicePixelWidth=r.inlineSize,this.parentDevicePixelHeight=r.blockSize),this.parentWidth=t.borderBoxSize[0].inlineSize,this.parentHeight=t.borderBoxSize[0].blockSize}this.handleResize()}),this.resizeObserver.observe(this.parentElement)});P(this,"setupIntersectionObserver",()=>{let t=this.ownerDocument.defaultView;t?.IntersectionObserver&&(this.intersectionObserver=new t.IntersectionObserver(([r])=>{this.isInViewport=r?.isIntersecting??!0,this.updateCurrentSpeed()}),this.intersectionObserver.observe(this.parentElement))});P(this,"handleVisualViewportChange",()=>{this.resizeObserver?.disconnect(),this.setupResizeObserver()});P(this,"handleResize",()=>{let t=0,r=0,o=Math.max(1,window.devicePixelRatio),n=visualViewport?.scale??1;if(this.devicePixelsSupported){let u=Math.max(1,this.minPixelRatio/o);t=this.parentDevicePixelWidth*u*n,r=this.parentDevicePixelHeight*u*n}else{let u=Math.max(o,this.minPixelRatio)*n;if(this.isSafari){let f=Sn(this.ownerDocument);u*=Math.max(1,f)}t=Math.round(this.parentWidth)*u,r=Math.round(this.parentHeight)*u}let i=Math.sqrt(this.maxPixelCount)/Math.sqrt(t*r),s=Math.min(1,i),a=Math.round(t*s),c=Math.round(r*s),d=a/Math.round(this.parentWidth);(this.canvasElement.width!==a||this.canvasElement.height!==c||this.renderScale!==d)&&(this.renderScale=d,this.canvasElement.width=a,this.canvasElement.height=c,this.resolutionChanged=!0,this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height),this.render(performance.now()))});P(this,"render",t=>{if(this.hasBeenDisposed)return;if(this.program===null){console.warn("Tried to render before program or gl was initialized");return}let r=t-this.lastRenderTime;this.lastRenderTime=t,this.currentSpeed!==0&&(this.currentFrame+=r*this.currentSpeed),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.uniform1f(this.uniformLocations.u_time,this.currentFrame*.001),this.resolutionChanged&&(this.gl.uniform2f(this.uniformLocations.u_resolution,this.gl.canvas.width,this.gl.canvas.height),this.gl.uniform1f(this.uniformLocations.u_pixelRatio,this.renderScale),this.resolutionChanged=!1),this.gl.drawArrays(this.gl.TRIANGLES,0,6),this.currentSpeed!==0?this.requestRender():this.rafId=null});P(this,"requestRender",()=>{this.rafId!==null&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(this.render)});P(this,"setTextureUniform",(t,r)=>{if(!r.complete||r.naturalWidth===0)throw new Error(`Paper Shaders: image for uniform ${t} must be fully loaded`);let o=this.textures.get(t);o&&this.gl.deleteTexture(o),this.textureUnitMap.has(t)||this.textureUnitMap.set(t,this.textureUnitMap.size);let n=this.textureUnitMap.get(t);this.gl.activeTexture(this.gl.TEXTURE0+n);let i=this.gl.createTexture();this.gl.bindTexture(this.gl.TEXTURE_2D,i),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,r),this.mipmaps.includes(t)&&(this.gl.generateMipmap(this.gl.TEXTURE_2D),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR_MIPMAP_LINEAR));let s=this.gl.getError();if(s!==this.gl.NO_ERROR||i===null){console.error("Paper Shaders: WebGL error when uploading texture:",s);return}this.textures.set(t,i);let a=this.uniformLocations[t];if(a){this.gl.uniform1i(a,n);let c=`${t}AspectRatio`,d=this.uniformLocations[c];if(d){let u=r.naturalWidth/r.naturalHeight;this.gl.uniform1f(d,u)}}});P(this,"areUniformValuesEqual",(t,r)=>t===r?!0:Array.isArray(t)&&Array.isArray(r)&&t.length===r.length?t.every((o,n)=>this.areUniformValuesEqual(o,r[n])):!1);P(this,"setUniformValues",t=>{Object.entries(t).forEach(([r,o])=>{let n=o;if(o instanceof HTMLImageElement&&(n=`${o.src.slice(0,200)}|${o.naturalWidth}x${o.naturalHeight}`),this.areUniformValuesEqual(this.uniformCache[r],n))return;this.uniformCache[r]=n;let i=this.uniformLocations[r];if(!i){console.warn(`Uniform location for ${r} not found`);return}if(o instanceof HTMLImageElement)this.setTextureUniform(r,o);else if(Array.isArray(o)){let s=null,a=null;if(o[0]!==void 0&&Array.isArray(o[0])){let c=o[0].length;if(o.every(d=>d.length===c))s=o.flat(),a=c;else{console.warn(`All child arrays must be the same length for ${r}`);return}}else s=o,a=s.length;switch(a){case 2:this.gl.uniform2fv(i,s);break;case 3:this.gl.uniform3fv(i,s);break;case 4:this.gl.uniform4fv(i,s);break;case 9:this.gl.uniformMatrix3fv(i,!1,s);break;case 16:this.gl.uniformMatrix4fv(i,!1,s);break;default:console.warn(`Unsupported uniform array length: ${a}`)}}else typeof o=="number"?this.gl.uniform1f(i,o):typeof o=="boolean"?this.gl.uniform1i(i,o?1:0):console.warn(`Unsupported uniform type for ${r}: ${typeof o}`)})});P(this,"getCurrentFrame",()=>this.currentFrame);P(this,"setFrame",t=>{this.currentFrame=t,this.lastRenderTime=performance.now(),this.renderUnlessAnimating()});P(this,"setSpeed",(t=1)=>{this.speed=t,this.updateCurrentSpeed()});P(this,"updateCurrentSpeed",()=>{this.setCurrentSpeed(this.ownerDocument.hidden||!this.isInViewport?0:this.speed)});P(this,"setCurrentSpeed",t=>{this.currentSpeed=t,this.rafId===null&&t!==0&&(this.lastRenderTime=performance.now(),this.rafId=requestAnimationFrame(this.render)),this.rafId!==null&&t===0&&(cancelAnimationFrame(this.rafId),this.rafId=null)});P(this,"setMaxPixelCount",(t=lr)=>{this.maxPixelCount=t,this.handleResize()});P(this,"setMinPixelRatio",(t=2)=>{this.minPixelRatio=t,this.handleResize()});P(this,"setUniforms",t=>{this.setUniformValues(t),this.providedUniforms={...this.providedUniforms,...t},this.renderUnlessAnimating()});P(this,"renderUnlessAnimating",()=>{this.rafId===null&&this.render(performance.now())});P(this,"handleDocumentVisibilityChange",()=>{this.updateCurrentSpeed()});P(this,"dispose",()=>{this.hasBeenDisposed=!0,this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.gl&&this.program&&(this.textures.forEach(t=>{this.gl.deleteTexture(t)}),this.textures.clear(),this.gl.deleteProgram(this.program),this.program=null,this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,null),this.gl.bindRenderbuffer(this.gl.RENDERBUFFER,null),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,null),this.gl.getError()),this.gl.getExtension("WEBGL_lose_context")?.loseContext(),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),visualViewport?.removeEventListener("resize",this.handleVisualViewportChange),this.ownerDocument.removeEventListener("visibilitychange",this.handleDocumentVisibilityChange),this.uniformLocations={},this.canvasElement.remove(),delete this.parentElement.paperShaderMount});if(t?.nodeType===1)this.parentElement=t;else throw new Error("Paper Shaders: parent element must be an HTMLElement");if(this.ownerDocument=t.ownerDocument,!this.ownerDocument.querySelector("style[data-paper-shader]")){let x=this.ownerDocument.createElement("style");x.innerHTML=Mn,x.setAttribute("data-paper-shader",""),this.ownerDocument.head.prepend(x)}let u=this.ownerDocument.createElement("canvas");this.canvasElement=u,this.parentElement.prepend(u),this.fragmentShader=r,this.providedUniforms=o,this.mipmaps=d,this.currentFrame=s,this.minPixelRatio=a,this.maxPixelCount=c;let f=u.getContext("webgl2",{antialias:!1,depth:!1,stencil:!1,...n});if(!f)throw new Error("Paper Shaders: WebGL is not supported in this browser");this.gl=f,this.initProgram(),this.setupPositionAttribute(),this.setupUniforms(),this.setUniformValues(this.providedUniforms),this.setupResizeObserver(),visualViewport?.addEventListener("resize",this.handleVisualViewportChange),this.setupIntersectionObserver(),this.setSpeed(i),this.parentElement.setAttribute("data-paper-shader",""),this.parentElement.paperShaderMount=this,this.ownerDocument.addEventListener("visibilitychange",this.handleDocumentVisibilityChange)}};Mn=`@layer paper-shaders {
151
+ }`});function pr(e,t,r){let o=e.createShader(t);return o?(e.shaderSource(o,r),e.compileShader(o),e.getShaderParameter(o,e.COMPILE_STATUS)?o:(console.error("An error occurred compiling the shaders: "+e.getShaderInfoLog(o)),e.deleteShader(o),null)):null}function Ei(e,t,r){let o=e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT),i=o?o.precision:null;i&&i<23&&(t=t.replace(/precision\s+(lowp|mediump)\s+float;/g,"precision highp float;"),r=r.replace(/precision\s+(lowp|mediump)\s+float/g,"precision highp float").replace(/\b(uniform|varying|attribute)\s+(lowp|mediump)\s+(\w+)/g,"$1 highp $3"));let a=pr(e,e.VERTEX_SHADER,t),s=pr(e,e.FRAGMENT_SHADER,r);if(!a||!s)return null;let n=e.createProgram();return n?(e.attachShader(n,a),e.attachShader(n,s),e.linkProgram(n),e.getProgramParameter(n,e.LINK_STATUS)?(e.detachShader(n,a),e.detachShader(n,s),e.deleteShader(a),e.deleteShader(s),n):(console.error("Unable to initialize the shader program: "+e.getProgramInfoLog(n)),e.deleteProgram(n),e.deleteShader(a),e.deleteShader(s),null)):null}function Bi(){let e=navigator.userAgent.toLowerCase();return e.includes("safari")&&!e.includes("chrome")&&!e.includes("android")}function ki(e){let t=visualViewport?.scale??1,r=visualViewport?.width??window.innerWidth,o=window.innerWidth-e.documentElement.clientWidth,i=t*r+o,a=outerWidth/i,s=Math.round(100*a);return s%5===0?s/100:s===33?1/3:s===67?2/3:s===133?4/3:a}var fr,_e,Fi,mr=$(()=>{hr();fr=1920*1080*4,_e=class{constructor(t,r,o,i,a=0,s=0,n=2,l=fr,d=[]){P(this,"parentElement");P(this,"canvasElement");P(this,"gl");P(this,"program",null);P(this,"uniformLocations",{});P(this,"fragmentShader");P(this,"rafId",null);P(this,"lastRenderTime",0);P(this,"currentFrame",0);P(this,"speed",0);P(this,"currentSpeed",0);P(this,"providedUniforms");P(this,"mipmaps",[]);P(this,"hasBeenDisposed",!1);P(this,"resolutionChanged",!0);P(this,"textures",new Map);P(this,"minPixelRatio");P(this,"maxPixelCount");P(this,"isSafari",Bi());P(this,"uniformCache",{});P(this,"textureUnitMap",new Map);P(this,"ownerDocument");P(this,"initProgram",()=>{let t=Ei(this.gl,ur,this.fragmentShader);t&&(this.program=t,this.gl.useProgram(t))});P(this,"setupPositionAttribute",()=>{let t=this.gl.getAttribLocation(this.program,"a_position"),r=this.gl.createBuffer();this.gl.bindBuffer(this.gl.ARRAY_BUFFER,r);let o=[-1,-1,1,-1,-1,1,-1,1,1,-1,1,1];this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(o),this.gl.STATIC_DRAW),this.gl.enableVertexAttribArray(t),this.gl.vertexAttribPointer(t,2,this.gl.FLOAT,!1,0,0)});P(this,"setupUniforms",()=>{let t={u_time:this.gl.getUniformLocation(this.program,"u_time"),u_pixelRatio:this.gl.getUniformLocation(this.program,"u_pixelRatio"),u_resolution:this.gl.getUniformLocation(this.program,"u_resolution")};Object.entries(this.providedUniforms).forEach(([r,o])=>{if(t[r]=this.gl.getUniformLocation(this.program,r),o instanceof HTMLImageElement){let i=`${r}AspectRatio`;t[i]=this.gl.getUniformLocation(this.program,i)}}),this.uniformLocations=t});P(this,"renderScale",1);P(this,"parentWidth",0);P(this,"parentHeight",0);P(this,"parentDevicePixelWidth",0);P(this,"parentDevicePixelHeight",0);P(this,"devicePixelsSupported",!1);P(this,"intersectionObserver",null);P(this,"isInViewport",!0);P(this,"resizeObserver",null);P(this,"setupResizeObserver",()=>{this.resizeObserver=new ResizeObserver(([t])=>{if(t?.borderBoxSize[0]){let r=t.devicePixelContentBoxSize?.[0];r!==void 0&&(this.devicePixelsSupported=!0,this.parentDevicePixelWidth=r.inlineSize,this.parentDevicePixelHeight=r.blockSize),this.parentWidth=t.borderBoxSize[0].inlineSize,this.parentHeight=t.borderBoxSize[0].blockSize}this.handleResize()}),this.resizeObserver.observe(this.parentElement)});P(this,"setupIntersectionObserver",()=>{let t=this.ownerDocument.defaultView;t?.IntersectionObserver&&(this.intersectionObserver=new t.IntersectionObserver(([r])=>{this.isInViewport=r?.isIntersecting??!0,this.updateCurrentSpeed()}),this.intersectionObserver.observe(this.parentElement))});P(this,"handleVisualViewportChange",()=>{this.resizeObserver?.disconnect(),this.setupResizeObserver()});P(this,"handleResize",()=>{let t=0,r=0,o=Math.max(1,window.devicePixelRatio),i=visualViewport?.scale??1;if(this.devicePixelsSupported){let u=Math.max(1,this.minPixelRatio/o);t=this.parentDevicePixelWidth*u*i,r=this.parentDevicePixelHeight*u*i}else{let u=Math.max(o,this.minPixelRatio)*i;if(this.isSafari){let p=ki(this.ownerDocument);u*=Math.max(1,p)}t=Math.round(this.parentWidth)*u,r=Math.round(this.parentHeight)*u}let a=Math.sqrt(this.maxPixelCount)/Math.sqrt(t*r),s=Math.min(1,a),n=Math.round(t*s),l=Math.round(r*s),d=n/Math.round(this.parentWidth);(this.canvasElement.width!==n||this.canvasElement.height!==l||this.renderScale!==d)&&(this.renderScale=d,this.canvasElement.width=n,this.canvasElement.height=l,this.resolutionChanged=!0,this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height),this.render(performance.now()))});P(this,"render",t=>{if(this.hasBeenDisposed)return;if(this.program===null){console.warn("Tried to render before program or gl was initialized");return}let r=t-this.lastRenderTime;this.lastRenderTime=t,this.currentSpeed!==0&&(this.currentFrame+=r*this.currentSpeed),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.uniform1f(this.uniformLocations.u_time,this.currentFrame*.001),this.resolutionChanged&&(this.gl.uniform2f(this.uniformLocations.u_resolution,this.gl.canvas.width,this.gl.canvas.height),this.gl.uniform1f(this.uniformLocations.u_pixelRatio,this.renderScale),this.resolutionChanged=!1),this.gl.drawArrays(this.gl.TRIANGLES,0,6),this.currentSpeed!==0?this.requestRender():this.rafId=null});P(this,"requestRender",()=>{this.rafId!==null&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(this.render)});P(this,"setTextureUniform",(t,r)=>{if(!r.complete||r.naturalWidth===0)throw new Error(`Paper Shaders: image for uniform ${t} must be fully loaded`);let o=this.textures.get(t);o&&this.gl.deleteTexture(o),this.textureUnitMap.has(t)||this.textureUnitMap.set(t,this.textureUnitMap.size);let i=this.textureUnitMap.get(t);this.gl.activeTexture(this.gl.TEXTURE0+i);let a=this.gl.createTexture();this.gl.bindTexture(this.gl.TEXTURE_2D,a),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,r),this.mipmaps.includes(t)&&(this.gl.generateMipmap(this.gl.TEXTURE_2D),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR_MIPMAP_LINEAR));let s=this.gl.getError();if(s!==this.gl.NO_ERROR||a===null){console.error("Paper Shaders: WebGL error when uploading texture:",s);return}this.textures.set(t,a);let n=this.uniformLocations[t];if(n){this.gl.uniform1i(n,i);let l=`${t}AspectRatio`,d=this.uniformLocations[l];if(d){let u=r.naturalWidth/r.naturalHeight;this.gl.uniform1f(d,u)}}});P(this,"areUniformValuesEqual",(t,r)=>t===r?!0:Array.isArray(t)&&Array.isArray(r)&&t.length===r.length?t.every((o,i)=>this.areUniformValuesEqual(o,r[i])):!1);P(this,"setUniformValues",t=>{Object.entries(t).forEach(([r,o])=>{let i=o;if(o instanceof HTMLImageElement&&(i=`${o.src.slice(0,200)}|${o.naturalWidth}x${o.naturalHeight}`),this.areUniformValuesEqual(this.uniformCache[r],i))return;this.uniformCache[r]=i;let a=this.uniformLocations[r];if(!a){console.warn(`Uniform location for ${r} not found`);return}if(o instanceof HTMLImageElement)this.setTextureUniform(r,o);else if(Array.isArray(o)){let s=null,n=null;if(o[0]!==void 0&&Array.isArray(o[0])){let l=o[0].length;if(o.every(d=>d.length===l))s=o.flat(),n=l;else{console.warn(`All child arrays must be the same length for ${r}`);return}}else s=o,n=s.length;switch(n){case 2:this.gl.uniform2fv(a,s);break;case 3:this.gl.uniform3fv(a,s);break;case 4:this.gl.uniform4fv(a,s);break;case 9:this.gl.uniformMatrix3fv(a,!1,s);break;case 16:this.gl.uniformMatrix4fv(a,!1,s);break;default:console.warn(`Unsupported uniform array length: ${n}`)}}else typeof o=="number"?this.gl.uniform1f(a,o):typeof o=="boolean"?this.gl.uniform1i(a,o?1:0):console.warn(`Unsupported uniform type for ${r}: ${typeof o}`)})});P(this,"getCurrentFrame",()=>this.currentFrame);P(this,"setFrame",t=>{this.currentFrame=t,this.lastRenderTime=performance.now(),this.renderUnlessAnimating()});P(this,"setSpeed",(t=1)=>{this.speed=t,this.updateCurrentSpeed()});P(this,"updateCurrentSpeed",()=>{this.setCurrentSpeed(this.ownerDocument.hidden||!this.isInViewport?0:this.speed)});P(this,"setCurrentSpeed",t=>{this.currentSpeed=t,this.rafId===null&&t!==0&&(this.lastRenderTime=performance.now(),this.rafId=requestAnimationFrame(this.render)),this.rafId!==null&&t===0&&(cancelAnimationFrame(this.rafId),this.rafId=null)});P(this,"setMaxPixelCount",(t=fr)=>{this.maxPixelCount=t,this.handleResize()});P(this,"setMinPixelRatio",(t=2)=>{this.minPixelRatio=t,this.handleResize()});P(this,"setUniforms",t=>{this.setUniformValues(t),this.providedUniforms={...this.providedUniforms,...t},this.renderUnlessAnimating()});P(this,"renderUnlessAnimating",()=>{this.rafId===null&&this.render(performance.now())});P(this,"handleDocumentVisibilityChange",()=>{this.updateCurrentSpeed()});P(this,"dispose",()=>{this.hasBeenDisposed=!0,this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.gl&&this.program&&(this.textures.forEach(t=>{this.gl.deleteTexture(t)}),this.textures.clear(),this.gl.deleteProgram(this.program),this.program=null,this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,null),this.gl.bindRenderbuffer(this.gl.RENDERBUFFER,null),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,null),this.gl.getError()),this.gl.getExtension("WEBGL_lose_context")?.loseContext(),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),visualViewport?.removeEventListener("resize",this.handleVisualViewportChange),this.ownerDocument.removeEventListener("visibilitychange",this.handleDocumentVisibilityChange),this.uniformLocations={},this.canvasElement.remove(),delete this.parentElement.paperShaderMount});if(t?.nodeType===1)this.parentElement=t;else throw new Error("Paper Shaders: parent element must be an HTMLElement");if(this.ownerDocument=t.ownerDocument,!this.ownerDocument.querySelector("style[data-paper-shader]")){let b=this.ownerDocument.createElement("style");b.innerHTML=Fi,b.setAttribute("data-paper-shader",""),this.ownerDocument.head.prepend(b)}let u=this.ownerDocument.createElement("canvas");this.canvasElement=u,this.parentElement.prepend(u),this.fragmentShader=r,this.providedUniforms=o,this.mipmaps=d,this.currentFrame=s,this.minPixelRatio=n,this.maxPixelCount=l;let p=u.getContext("webgl2",{antialias:!1,depth:!1,stencil:!1,...i});if(!p)throw new Error("Paper Shaders: WebGL is not supported in this browser");this.gl=p,this.initProgram(),this.setupPositionAttribute(),this.setupUniforms(),this.setUniformValues(this.providedUniforms),this.setupResizeObserver(),visualViewport?.addEventListener("resize",this.handleVisualViewportChange),this.setupIntersectionObserver(),this.setSpeed(a),this.parentElement.setAttribute("data-paper-shader",""),this.parentElement.paperShaderMount=this,this.ownerDocument.addEventListener("visibilitychange",this.handleDocumentVisibilityChange)}};Fi=`@layer paper-shaders {
152
152
  :where([data-paper-shader]) {
153
153
  isolation: isolate;
154
154
  position: relative;
@@ -165,22 +165,22 @@ void main() {
165
165
  corner-shape: inherit;
166
166
  }
167
167
  }
168
- }`});var eo,to,ur=Z(()=>{eo={fit:"none",scale:1,rotation:0,offsetX:0,offsetY:0,originX:.5,originY:.5,worldWidth:0,worldHeight:0},to={none:0,contain:1,cover:2}});var hr,fr,pr,mr=Z(()=>{hr=`
168
+ }`});var io,no,gr=$(()=>{io={fit:"none",scale:1,rotation:0,offsetX:0,offsetY:0,originX:.5,originY:.5,worldWidth:0,worldHeight:0},no={none:0,contain:1,cover:2}});var br,Ar,xr,vr=$(()=>{br=`
169
169
  #define TWO_PI 6.28318530718
170
170
  #define PI 3.14159265358979323846
171
- `,fr=`
171
+ `,Ar=`
172
172
  float hash21(vec2 p) {
173
173
  p = fract(p * vec2(0.3183099, 0.3678794)) + 0.1;
174
174
  p += dot(p, p + 19.19);
175
175
  return fract(p.x * p.y);
176
176
  }
177
- `,pr=`
177
+ `,xr=`
178
178
  vec2 hash22(vec2 p) {
179
179
  p = fract(p * vec2(0.3183099, 0.3678794)) + 0.1;
180
180
  p += dot(p, p.yx + 19.19);
181
181
  return fract(vec2(p.x * p.y, p.x + p.y));
182
182
  }
183
- `});var Pt,oo,gr=Z(()=>{mr();Pt={maxCrumpleCount:15},oo=`#version 300 es
183
+ `});var Bt,ao,wr=$(()=>{vr();Bt={maxCrumpleCount:15},ao=`#version 300 es
184
184
  precision mediump float;
185
185
 
186
186
  uniform sampler2D u_image;
@@ -229,9 +229,9 @@ float lst(float edge0, float edge1, float x) {
229
229
  return clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);
230
230
  }
231
231
 
232
- ${hr}
233
- ${fr}
234
- ${pr}
232
+ ${br}
233
+ ${Ar}
234
+ ${xr}
235
235
 
236
236
  float getRoughness(vec2 p, vec2 lightDir, vec2 seedShift, float basePixel) {
237
237
  vec2 u = p / vec2(2, 4);
@@ -426,8 +426,8 @@ vec4 getCrumples(vec2 uv) {
426
426
  float near = 60000., nearB = 60000.;
427
427
  float idx = 0., rad = 0.;
428
428
  vec2 nearP = vec2(0.), nearPb = vec2(0.);
429
- vec4 seeds[${Pt.maxCrumpleCount}];
430
- for (int i = 0; i < ${Pt.maxCrumpleCount}; i++) {
429
+ vec4 seeds[${Bt.maxCrumpleCount}];
430
+ for (int i = 0; i < ${Bt.maxCrumpleCount}; i++) {
431
431
  if (float(i) >= crumpleN) break;
432
432
  vec2 rand = hash22(vec2(float(i), float(i) * u_seed));
433
433
  float an = rand.x * TWO_PI;
@@ -460,7 +460,7 @@ vec4 getCrumples(vec2 uv) {
460
460
  float wideSum = 0.;
461
461
  float toEdge = 9., edgeSoft = 0.;
462
462
 
463
- for (int i = 0; i < ${Pt.maxCrumpleCount}; i++) {
463
+ for (int i = 0; i < ${Bt.maxCrumpleCount}; i++) {
464
464
  if (float(i) >= crumpleN) break;
465
465
  if (float(i) == idx) continue;
466
466
  vec4 seed = seeds[i];
@@ -691,7 +691,7 @@ void main() {
691
691
 
692
692
  fragColor = vec4(color, opacity);
693
693
  }
694
- `});function Oe(e){if(Array.isArray(e))return e.length===4?e:e.length===3?[...e,1]:Pe;if(typeof e!="string")return Pe;let t,r,o,n=1;if(e.startsWith("#"))[t,r,o,n]=En(e);else if(e.startsWith("rgb")){let i=Bn(e);if(i===null)return Pe;[t,r,o,n]=i}else if(e.startsWith("hsl")){let i=Fn(e);if(i===null)return Pe;[t,r,o,n]=kn(i)}else return console.error("Unsupported color format",e),Pe;return[St(t,0,1),St(r,0,1),St(o,0,1),St(n,0,1)]}function En(e){if(e=e.replace(/^#/,""),(e.length===3||e.length===4)&&(e=e.split("").map(i=>i+i).join("")),e.length===6&&(e=e+"ff"),!/^[0-9a-f]{8}$/i.test(e))return console.warn("Invalid hex color"),Pe;let t=parseInt(e.slice(0,2),16)/255,r=parseInt(e.slice(2,4),16)/255,o=parseInt(e.slice(4,6),16)/255,n=parseInt(e.slice(6,8),16)/255;return[t,r,o,n]}function Bn(e){let t=e.match(/^rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([0-9.]+))?\s*\)$/i);return t?[parseInt(t[1]??"0")/255,parseInt(t[2]??"0")/255,parseInt(t[3]??"0")/255,t[4]===void 0?1:parseFloat(t[4])]:null}function Fn(e){let t=e.match(/^hsla?\s*\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*([0-9.]+))?\s*\)$/i);return t?[parseInt(t[1]??"0"),parseInt(t[2]??"0"),parseInt(t[3]??"0"),t[4]===void 0?1:parseFloat(t[4])]:null}function kn(e){let[t,r,o,n]=e,i=t/360,s=r/100,a=o/100,c,d,u;if(r===0)c=d=u=a;else{let f=(p,m,l)=>(l<0&&(l+=1),l>1&&(l-=1),l<.16666666666666666?p+(m-p)*6*l:l<.5?m:l<.6666666666666666?p+(m-p)*(.6666666666666666-l)*6:p),x=a<.5?a*(1+s):a+s-a*s,b=2*a-x;c=f(b,x,i+1/3),d=f(b,x,i),u=f(b,x,i-1/3)}return[c,d,u,n]}var St,Pe,br=Z(()=>{St=(e,t,r)=>Math.min(Math.max(e,t),r),Pe=[.5,.5,.5,1]});function ro(){if(typeof window>"u")return;let e=new Image;return e.src=In,e}var In,Ar=Z(()=>{In="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAADAFBMVEUCAQMBAf7/AgMD/wID//7+/wT+A/4FAmYIAqIKnw7+//4EAisEAUgGBIYIewkFVhEJjAoFAuEFA8GW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cSLMjaYxAqHmbAaTZAZcZ5s6JLJGip7sCXaw2LCRnK1YMO4sFRAgVWgfXMfc+zt038JeI6lkCDQU5yCGeZRBOA9aMG3e0AZ7cmQmKjgeCWvmJnn7yAwY8uoEEL1wLBADizps1VFIzm5UYtBHFT5Qy46UAsQTBZCwPgljNPekNGEwdic0FR1JmP5AAhShTl4MCWwq2By1NKlUqzQQGAidkywDoSgYGtQ8JRdefJLqPjw5YsD85GiBWlRsDZ2GzVDkCvRSyUzIq16YUXEBLd2kGn+rLIwAAAK1JREFUf54DD3C0WwmGPi9OSjpCA0A7fFwUZTm0ktDZLl5VXmbFDDQACl7+QSry5QCM2bfNC+WAFj1LAzLsiwEBaQCW/1EGcMN/tG8OViQtylulBUxRADYm5SEBRAcAARkeMC5iRNgZhOoxnz4oHApa6gD3ASdbmF188wxpDZVKUL4RUhTSSRvrQAZLDcgauImabgJzkXIaALePAXot1j6Bdwe3AXoQAnXMFVuCApGWbjuRvTu7AAAAAElFTkSuQmCC"});var xr=Z(()=>{dr();ur();gr();br();Ar()});var vr={};io(vr,{renderPaperShader:()=>Rn});async function Rn(e){if(typeof document>"u"||typeof requestAnimationFrame!="function")return;let t=ro();if(!t)return;await t.decode();let r=document.createElement("div");r.setAttribute("aria-hidden","true"),r.style.cssText=`position:fixed;left:0;top:0;width:${e}px;height:${e}px;opacity:0;pointer-events:none;z-index:-1;contain:strict`,document.body.appendChild(r);let o;try{let n=eo;o=new Ge(r,oo,{u_image:void 0,u_isImage:!1,u_imageAspectRatio:1,u_colorBack:Oe("#808080"),u_colorPaper:Oe("#808080"),u_colorShadow:Oe("#000000"),u_blending:0,u_distortion:0,u_clip:!1,u_angle:135,u_seed:7,u_roughness:.12,u_roughnessSize:.15,u_roughnessRows:0,u_fiber:.95,u_fiberSize:.55,u_folds:0,u_foldSizeX:.5,u_foldSizeY:.5,u_foldOffsetX:0,u_foldOffsetY:0,u_wrinkles:.06,u_wrinkleSize:.6,u_crumples:0,u_crumpleCount:5,u_drops:0,u_noiseTexture:t,u_fit:to[n.fit],u_scale:1,u_rotation:0,u_originX:n.originX,u_originY:n.originY,u_offsetX:0,u_offsetY:0,u_worldWidth:n.worldWidth,u_worldHeight:n.worldHeight},{preserveDrawingBuffer:!0,antialias:!1},0,0,1,e*e);let i=o.canvasElement;for(let m=0;m<10&&(i.width===0||i.height===0);m++)await no();await no(),await no();let s=document.createElement("canvas");s.width=s.height=e;let a=s.getContext("2d");if(!a||!i.width)return;a.drawImage(i,0,0,e,e);let c=a.getImageData(0,0,e,e),d=c.data,u=d.length/4,f=new Float32Array(u),x=0;for(let m=0;m<u;m++)f[m]=(d[m*4]+d[m*4+1]+d[m*4+2])/3,x+=f[m]/u;let b=0;for(let m=0;m<u;m++)b+=Math.abs(f[m]-x)/u;if(b<.5)return;let p=Cn/b;for(let m=0;m<u;m++){let l=(f[m]-x)*p;d[m*4]=d[m*4+1]=d[m*4+2]=l>0?255:0,d[m*4+3]=Math.min(255,Math.abs(l))}return a.putImageData(c,0,0),await new Promise(m=>s.toBlob(l=>m(l?URL.createObjectURL(l):s.toDataURL("image/png")),"image/png"))}catch{return}finally{o?.dispose(),r.remove()}}var Cn,no,wr=Z(()=>{"use strict";xr();Cn=15,no=()=>new Promise(e=>requestAnimationFrame(()=>e()))});var Tn={};io(Tn,{Folder:()=>R,LAYER:()=>qe,OrigamiLoader:()=>Ne,Player:()=>pe,StepBuilder:()=>Ce,SvgScene:()=>Me,buildBoat:()=>at,buildCrane:()=>$e,buildEnvelope:()=>it,buildFox:()=>yt,buildFrog:()=>ht,buildHeart:()=>pt,buildPlane:()=>rt,buildPleat:()=>nt,buildSwan:()=>ft,buildWhale:()=>wt,defaultCamera:()=>Le,defaultPose:()=>le,defineOrigamiLoader:()=>Ft,eases:()=>V,getModel:()=>Mt,listModels:()=>tr,paintOrder:()=>$t,paperTexture:()=>Bt,registerModel:()=>or});var Y=Math.PI/180,Ee=()=>[1,0,0,0,0,1,0,0,0,0,1,0];function D(e,t){let r=new Array(12);for(let o=0;o<12;o+=4){let n=e[o],i=e[o+1],s=e[o+2];r[o]=n*t[0]+i*t[4]+s*t[8],r[o+1]=n*t[1]+i*t[5]+s*t[9],r[o+2]=n*t[2]+i*t[6]+s*t[10],r[o+3]=n*t[3]+i*t[7]+s*t[11]+e[o+3]}return r}function G(e,t,r,o){return[e[0]*t+e[1]*r+e[2]*o+e[3],e[4]*t+e[5]*r+e[6]*o+e[7],e[8]*t+e[9]*r+e[10]*o+e[11]]}function j(e,t,r){let[o,n,i]=t,s=Math.cos(r),a=Math.sin(r),c=1-s,d=[c*o*o+s,c*o*n-a*i,c*o*i+a*n,0,c*o*n+a*i,c*n*n+s,c*n*i-a*o,0,c*o*i-a*n,c*n*i+a*o,c*i*i+s,0];for(let u=0;u<12;u+=4)d[u+3]=e[u/4]-(d[u]*e[0]+d[u+1]*e[1]+d[u+2]*e[2]);return d}var ao=e=>j([0,0,0],[1,0,0],e),so=e=>j([0,0,0],[0,1,0],e),kt=e=>j([0,0,0],[0,0,1],e),ue=(e,t,r)=>[1,0,0,e,0,1,0,t,0,0,1,r],lo=e=>[e,0,0,0,0,e,0,0,0,0,e,0],ie=(e,t=0,r=1)=>e<t?t:e>r?r:e,It=(e,t,r)=>e+(t-e)*r,ae=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],Be=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]];function Fe(e){let t=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/t,e[1]/t,e[2]/t]}var Q=(e,t,r)=>(t[0]-e[0])*(r[1]-e[1])-(t[1]-e[1])*(r[0]-e[0]);function co(e,t,r,o){let n=[t[0]-e[0],t[1]-e[1]],i=[o[0]-r[0],o[1]-r[1]],s=n[0]*i[1]-n[1]*i[0];if(Math.abs(s)<1e-12)return;let a=((r[0]-e[0])*i[1]-(r[1]-e[1])*i[0])/s;return[e[0]+n[0]*a,e[1]+n[1]*a]}function se(e){let t=0;for(let r=0;r<e.length;r++){let o=e[r],n=e[(r+1)%e.length];t+=o[0]*n[1]-n[0]*o[1]}return t/2}function ke(e){let t=0,r=0,o=0;for(let n=0;n<e.length;n++){let i=e[n],s=e[(n+1)%e.length],a=i[0]*s[1]-s[0]*i[1];t+=a,r+=(i[0]+s[0])*a,o+=(i[1]+s[1])*a}if(Math.abs(t)<1e-14){for(let n of e)r+=n[0],o+=n[1];return[r/e.length,o/e.length]}return[r/(3*t),o/(3*t)]}var he=e=>se(e)<0?e.slice().reverse():e;function uo(e,t,r,o=1e-9){let n=Math.hypot(r[0]-t[0],r[1]-t[1]),i=e.map(d=>Q(t,r,d)/n);if(!i.some(d=>d<-o))return{left:e,right:null,chord:null};if(!i.some(d=>d>o))return{left:null,right:e,chord:null};let s=[],a=[],c=[];for(let d=0;d<e.length;d++){let u=(d+1)%e.length,f=e[d],x=e[u],b=i[d],p=i[u];if(b>=-o&&s.push(f),b<=o&&a.push(f),Math.abs(b)<=o&&c.push(f),b>o&&p<-o||b<-o&&p>o){let m=b/(b-p),l=[f[0]+(x[0]-f[0])*m,f[1]+(x[1]-f[1])*m];s.push(l),a.push(l),c.push(l)}}return{left:s,right:a,chord:c.length>=2?[c[0],c[1]]:null}}function He(e,t){let r=e;for(let o=0;o<t.length&&r.length;o++){let n=t[o],i=t[(o+1)%t.length],s=r;r=[];for(let a=0;a<s.length;a++){let c=s[a],d=s[(a+1)%s.length],u=Q(n,i,c),f=Q(n,i,d);if(u>=0&&r.push(c),u>=0!=f>=0){let x=u/(u-f);r.push([c[0]+(d[0]-c[0])*x,c[1]+(d[1]-c[1])*x])}}}return r}function ho(e){let t=e.slice().sort((n,i)=>n[0]-i[0]||n[1]-i[1]);if(t.length<3)return t;let r=[],o=[];for(let n of t){for(;r.length>=2&&Q(r[r.length-2],r[r.length-1],n)<=0;)r.pop();r.push(n)}for(let n=t.length-1;n>=0;n--){let i=t[n];for(;o.length>=2&&Q(o[o.length-2],o[o.length-1],i)<=0;)o.pop();o.push(i)}return r.slice(0,-1).concat(o.slice(0,-1))}function Ye(e,t,r,o){let n=3*e,i=3*(r-e)-n,s=1-n-i,a=3*t,c=3*(o-t)-a,d=1-a-c,u=b=>((s*b+i)*b+n)*b,f=b=>((d*b+c)*b+a)*b,x=b=>(3*s*b+2*i)*b+n;return b=>{if(b<=0)return 0;if(b>=1)return 1;let p=b;for(let m=0;m<8;m++){let l=u(p)-b,g=x(p);if(Math.abs(l)<1e-7||Math.abs(g)<1e-7)break;p-=l/g}if(p<0||p>1||Math.abs(u(p)-b)>1e-5){let m=0,l=1;for(let g=0;g<30;g++)p=(m+l)/2,u(p)<b?m=p:l=p}return f(p)}}var V={linear:e=>e,in:Ye(.55,.055,.675,.19),out:Ye(.23,1,.32,1),inOut:Ye(.645,.045,.355,1),fold:Ye(.77,0,.175,1),drop:e=>1-Math.exp(-7.5*e)*Math.cos(8.5*e)*(1-e),flap:e=>Math.sin(e*Math.PI*4)*(1-e*.6),breathe:e=>(1-Math.cos(2*Math.PI*Math.min(1,Math.max(0,e))))/2},le={rx:0,ry:0,rz:0,spin:0,tx:0,ty:0,tz:0,s:1,o:1},Ct=Object.keys(le);var qe=.0015,fe=41,fo=.9;function Je(e,t,r){return e.rot?j(e.p,e.u,e.free>=0?r:e.script?e.script(t):e.angle*t):ue(e.u[0]*t,e.u[1]*t,e.u[2]*t)}function Cr(e){let t=[e[0],e[4],e[8],0,e[1],e[5],e[9],0,e[2],e[6],e[10],0];return t[3]=-(t[0]*e[3]+t[1]*e[7]+t[2]*e[11]),t[7]=-(t[4]*e[3]+t[5]*e[7]+t[6]*e[11]),t[11]=-(t[8]*e[3]+t[9]*e[7]+t[10]*e[11]),t}var Ie=e=>Math.abs(e[10])>1-1e-6&&Math.abs(e[11])<1e-5;function Rr(e){if(Math.abs(e[10])<1-1e-4||Math.abs(e[11])>.001)return e;let t=e[10]>0?1:-1,r=Math.atan2(e[4],e[0]),o=Math.cos(r),n=Math.sin(r);for(let i of[0,1,-1])Math.abs(o-i)<1e-12&&(o=i),Math.abs(n-i)<1e-12&&(n=i);return[o,-t*n,0,e[3],n,t*o,0,e[7],0,0,t,0]}function Ke(e,t){let r=Math.min(1,Math.max(0,t))*(e.length-1),o=Math.min(e.length-2,Math.floor(r));return e[o]+(e[o+1]-e[o])*(r-o)}function Dr(e,t){let r=t.length,o=e.map((n,i)=>[...n,t[i]]);for(let n=0;n<r;n++){let i=n;for(let a=n+1;a<r;a++)Math.abs(o[a][n])>Math.abs(o[i][n])&&(i=a);[o[n],o[i]]=[o[i],o[n]];let s=o[n][n]||1e-18;for(let a=0;a<r;a++){if(a===n)continue;let c=o[a][n]/s;for(let d=n;d<=r;d++)o[a][d]-=c*o[n][d]}}return o.map((n,i)=>n[r]/(n[i]||1e-18))}function Qr(e,t){let r=e.slice(),o=t(r),n=o.reduce((s,a)=>s+a*a,0),i=r.length;for(let s=0;s<60&&n>1e-24;s++){let a=[];for(let p=0;p<i;p++){let m=r.slice();m[p]+=1e-7,a.push(t(m).map((l,g)=>(l-o[g])/1e-7))}let c=a.map(p=>a.map(m=>p.reduce((l,g,M)=>l+g*m[M],0))),d=a.map(p=>-p.reduce((m,l,g)=>m+l*o[g],0)),u=1e-10+1e-8*Math.max(...c.map((p,m)=>p[m]));c.forEach((p,m)=>p[m]+=u);let f=Dr(c,d),x=1,b=!1;for(let p=0;p<12;p++){let m=r.map((M,w)=>M+x*f[w]),l=t(m),g=l.reduce((M,w)=>M+w*w,0);if(g<n){r=m,o=l,n=g,b=!0;break}x/=2}if(!b)break}return r}var R=class{constructor(t={},r=[[-1,-1],[1,-1],[1,1],[-1,1]]){this.steps=[];this.chords=[];this.nextId=1;this.pose={...le,...t},this.faces=[{id:0,poly:he(r),T:Ee(),level:0,rank:0,hist:[]}]}step(t,r){let o=new Ce(this,t);return r?.(o),o.finish(),this}compile(t={}){let r=[],o=new Map,n=p=>{let m=`${Math.round(p[0]*1e7)},${Math.round(p[1]*1e7)}`,l=o.get(m);return l===void 0&&(l=r.length,r.push(p),o.set(m,l)),l},i=this.faces.map(p=>{let m=he(p.poly).map(n);return m.filter((l,g)=>l!==m[(g+1)%m.length])});i=i.map(p=>{let m=[];for(let l=0;l<p.length;l++){let g=p[l],M=p[(l+1)%p.length];m.push(g);let w=r[g],h=r[M],A=h[0]-w[0],v=h[1]-w[1],y=A*A+v*v,S=[];for(let E=0;E<r.length;E++){if(E===g||E===M)continue;let F=r[E],B=((F[0]-w[0])*A+(F[1]-w[1])*v)/y;B<=1e-9||B>=1-1e-9||Math.abs(Q(w,h,F))/Math.sqrt(y)<1e-7&&S.push([B,E])}S.sort((E,F)=>E[0]-F[0]);for(let[,E]of S)m.push(E)}return m});let s=[],a=new Map,c=i.map((p,m)=>p.map((l,g)=>{let M=p[(g+1)%p.length],w=l<M?`${l}|${M}`:`${M}|${l}`,h=a.get(w);return h===void 0&&(h=s.length,a.set(w,h),s.push({a:l,b:M,faces:[],born:1/0})),s[h].faces.push(m),h})),d=(p,m)=>{let l=m.b[0]-m.a[0],g=m.b[1]-m.a[1],M=l*l+g*g,w=((p[0]-m.a[0])*l+(p[1]-m.a[1])*g)/M;return w>-1e-7&&w<1+1e-7&&Math.abs(Q(m.a,m.b,p))/Math.sqrt(M)<1e-7};for(let p of s)if(!(p.faces.length<2))for(let m of this.chords)m.step<p.born&&d(r[p.a],m)&&d(r[p.b],m)&&(p.born=m.step);let u=[],f=0,x=0,b=0;for(let p of this.steps)u.push(f),p.phase==="intro"&&(x=f+p.duration),p.phase!=="outro"&&(b=f+p.duration),f+=p.duration;return{steps:this.steps,starts:u,duration:f,content:[x,b],pose:this.pose,verts:r,faces:i,tracks:this.faces.map(p=>p.hist),edges:s,faceEdges:c,colourDown:t.colourDown}}},Ce=class{constructor(t,r){this.F=t;this.meta=r;this.joints=[];this.chains=new Map;this.pins=[];this.layers=[];this.nFree=0}get index(){return this.F.steps.length}info(t){let r=ke(t.poly),o=G(t.T,r[0],r[1],0);return{sheet:r,model:[o[0],o[1]],flat:Ie(t.T),up:t.T[10]>0}}select(t){return this.F.faces.filter(r=>!t||t(this.info(r)))}split(t,r,o){let n=new Set(t),i=[],s=[];for(let a of this.F.faces){if(!n.has(a)){s.push(a);continue}if(!Ie(a.T)){s.push(a),i.push(a);continue}let c=Cr(a.T),d=G(c,r[0],r[1],0),u=G(c,o[0],o[1],0),{left:f,right:x,chord:b}=uo(a.poly,[d[0],d[1]],[u[0],u[1]]);if(!f||!x||Math.abs(se(f))<1e-10||Math.abs(se(x))<1e-10){s.push(a),i.push(a);continue}b&&this.F.chords.push({a:b[0],b:b[1],step:this.index});let p=this.chains.get(a);this.chains.delete(a);for(let m of[f,x]){let l={...a,id:this.F.nextId++,poly:m,hist:a.hist.slice()};p&&this.chains.set(l,p),s.push(l),i.push(l)}}return this.F.faces=s,i}rot(t,r,o,n={}){let i=[t[0],t[1],t[2]??0],s=[r[0],r[1],r[2]??0],a=-1;o==="free"&&(a=n.free??this.nFree,this.nFree=Math.max(this.nFree,a+1));let c=typeof o=="function"?d=>o(d)*Y:void 0;return this.joints.push({rot:!0,p:i,u:Fe([s[0]-i[0],s[1]-i[1],s[2]-i[2]]),angle:typeof o=="number"?o*Y:c?c(1):0,free:a,at:n.at??[0,1],ease:c?"linear":n.ease??"fold",script:c}),this.joints.length-1}hinge(t,r,o,n=1,i=180,s={}){return this.rot(t,r,i*n*Math.sign(Q(t,r,o)),s)}swing(t,r,o={}){return this.rot([t[0],t[1],0],[t[0],t[1],1],r,o)}reverse(t,r,o){let[n,i]=r,s=this.split(t.filter(B=>Ie(B.T)),n,i),a=Math.sign(Q(n,i,o.side)),c=s.filter(B=>Math.sign(Q(n,i,this.info(B).model))===a),[d,u]=o.axis,f=co(d,u,n,i);if(!f)throw new Error("reverse: the axis runs parallel to the crease");let x=Math.atan2(u[1]-d[1],u[0]-d[0]),p=2*(Math.atan2(i[1]-n[1],i[0]-n[0])-x);p=Math.atan2(Math.sin(p),Math.cos(p))/Y;let[m,l]=o.at??[0,1],g=B=>m+(l-m)*B,M=B=>o.front(this.info(B)),w=c.filter(M),h=c.filter(B=>!M(B)),A=c.length&&Math.sign(Q(d,u,this.info(c[0]).model))||1,v=o.book?[[w,180*A],[h,-180*A]]:[[c,180]];this.restack=o.roll==="last"?[g(.6),l]:[m,g(.35)];for(let[B,k]of v)if(o.roll==="last"){let _=Math.cos(p*Y),I=Math.sin(p*Y),U=K=>[f[0]+_*(K[0]-f[0])-I*(K[1]-f[1]),f[1]+I*(K[0]-f[0])+_*(K[1]-f[1])],W=this.swing(f,p,{at:[m,g(.8)],ease:o.ease??"inOut"}),L=this.rot(U(d),U(u),k,{at:[g(.6),l],ease:"inOut"});this.attach(B,W,L)}else{let _=this.rot(d,u,k,{at:[m,g(.35)],ease:"inOut"}),I=this.swing(f,p,{at:[g(.2),l],ease:o.ease??"inOut"});this.attach(B,_,I)}let y=new Set(c),S=this.F.faces.filter(B=>!y.has(B)),E=S.filter(M),F=S.filter(B=>!M(B));return o.kind==="inside"?(this.layer(E,[...w,...h]),this.layer(w,h),this.layer([...w,...h],F)):(this.layer(w,S),this.layer(S,h),this.layer(w,h)),c}move(t,r={}){return this.joints.push({rot:!1,p:[0,0,0],u:t,angle:0,free:-1,at:r.at??[0,1],ease:r.ease??"fold"}),this.joints.length-1}fold(t,r,o){let n=this.split(this.select(o.where).filter(a=>Ie(a.T)),t,r),i=Math.sign(Q(t,r,o.side)),s=n.filter(a=>Math.sign(Q(t,r,this.info(a).model))===i);return this.attach(s,this.hinge(t,r,o.side,o.toward??1,o.deg??180,o)),s}attach(t,...r){for(let o of t)this.chains.set(o,[...this.chains.get(o)??[],...r])}pin(t,r,o){this.pins.push({a:t,b:r,pt:o})}layer(t,r){this.layers.push({above:t,below:r})}compose(t,r,o,n=!1){let i=Ee();for(let s of t){let a=this.joints[s],c=n&&this.nFree===0?V[a.ease](r):r;i=D(Je(a,c,o[a.free]??0),i)}return i}place(t,r,o,n=!1){let i=this.chains.get(t);return i?D(this.compose(i,r,o,n),t.T):t.T}solve(){if(!this.nFree)return[];let t=Array.from({length:this.nFree},()=>new Float64Array(fe)),r=new Array(this.nFree).fill(0);for(let o=0;o<fe;o++){let n=o/(fe-1);r=Qr(r,i=>{let s=[];for(let{a,b:c,pt:d}of this.pins){let u=G(this.place(a,n,i),d[0],d[1],0),f=G(this.place(c,n,i),d[0],d[1],0);s.push(u[0]-f[0],u[1]-f[1],u[2]-f[2])}return s}),r.forEach((i,s)=>t[s][o]=i)}for(let o of t){let n=Math.round(o[fe-1]/(Math.PI/2))*(Math.PI/2);Math.abs(o[fe-1]-n)<.001&&(o[fe-1]=n)}return t}finish(){let t=this.F,r=this.solve(),o=h=>r.map(A=>Ke(A,h)),n=o(1),i=o(fo),s=new Map(t.faces.map(h=>[h,Rr(this.place(h,1,n,!0))])),a=[];for(let h of t.faces){let A=s.get(h);if(!Ie(A))continue;let v=he(h.poly.map(F=>{let B=G(A,F[0],F[1],0);return[B[0],B[1]]})),y=[1/0,1/0,-1/0,-1/0];for(let[F,B]of v)y[0]=Math.min(y[0],F),y[1]=Math.min(y[1],B),y[2]=Math.max(y[2],F),y[3]=Math.max(y[3],B);let S=this.chains.get(h),E=D(ue(0,0,h.rank*1e-7),h.T);a.push({f:h,poly:v,box:y,moved:!!S,Tn:S?D(this.compose(S,fo,i,!0),E):E})}let c=new Map;for(let{above:h,below:A}of this.layers)for(let v of h)for(let y of A)c.set(`${v.id}|${y.id}`,1),c.set(`${y.id}|${v.id}`,-1);let d=(h,A)=>{let v=h[10];return Math.abs(v)<.001?h[11]:h[11]-(h[2]*(A[0]-h[3])+h[6]*(A[1]-h[7]))/v},u=a.length,f=a.map(()=>[]),x=a.map(()=>[]),b=new Int32Array(u);for(let h=0;h<u;h++){let A=a[h];for(let v=h+1;v<u;v++){let y=a[v];if(A.box[2]<=y.box[0]+1e-9||y.box[2]<=A.box[0]+1e-9||A.box[3]<=y.box[1]+1e-9||y.box[3]<=A.box[1]+1e-9)continue;let S=He(A.poly,y.poly);if(S.length<3||Math.abs(se(S))<1e-8)continue;let E=c.get(`${A.f.id}|${y.f.id}`);if(E===void 0)if(!A.moved&&!y.moved)E=A.f.rank>y.f.rank||A.f.rank===y.f.rank&&A.f.id>y.f.id?1:-1;else{let k=ke(S);E=d(A.Tn,k)>d(y.Tn,k)?1:-1}let[F,B]=E>0?[v,h]:[h,v];f[F].push(B),x[B].push(F),b[B]++}}let p=[],m=new Uint8Array(u);for(let h=0;h<u;h++){let A=-1;for(let v=0;v<u;v++)m[v]||b[v]>0||(A<0||a[v].f.rank<a[A].f.rank||a[v].f.rank===a[A].f.rank&&a[v].f.id<a[A].f.id)&&(A=v);if(A<0)for(let v=0;v<u;v++)!m[v]&&(A<0||a[v].f.rank<a[A].f.rank)&&(A=v);m[A]=1,p.push(A);for(let v of f[A])b[v]--}let l=new Int32Array(u),g=new Int32Array(u);p.forEach((h,A)=>g[h]=A);for(let h of p)for(let A of x[h])g[A]<g[h]&&(l[h]=Math.max(l[h],l[A]+1));let M=new Map,w=new Map;p.forEach((h,A)=>{M.set(a[h].f,l[h]),w.set(a[h].f,A)});for(let h of t.faces){let A=M.get(h)??h.level;h.hist.push({T:h.T,chain:this.chains.get(h)??[],z0:h.level*qe,z1:A*qe}),h.T=s.get(h),h.level=A,h.rank=w.get(h)??h.rank}t.steps.push({...this.meta,joints:this.joints,table:r,restack:this.restack})}};var Ze=e=>Math.abs(e[10])>1-1e-6,pe=class{constructor(t){this.model=t;let r=t.faces.length;this.anchors=t.steps.map(()=>new Array(r)),this.endsFlat=t.steps.map(()=>new Uint8Array(r));for(let o=0;o<r;o++){let n=t.tracks[o][0].T;t.steps.forEach((i,s)=>{let a=t.tracks[o][s];Ze(a.T)&&(n=a.T),this.anchors[s][o]=n;let d=t.tracks[o][s+1]?.T;if(!d){d=a.T;for(let u of a.chain)d=D(Je(i.joints[u],1,i.table.length?Ke(i.table[i.joints[u].free]??new Float64Array(2),1):0),d)}this.endsFlat[s][o]=Ze(d)?1:0})}this.groupIds=t.steps.map((o,n)=>{let i=new Map;return Int32Array.from(t.tracks.map(s=>{let a=s[n].chain.join(","),c=i.get(a);return c===void 0&&(c=i.size,i.set(a,c)),c}))})}get duration(){return this.model.duration}stepAt(t){let r=this.model.starts,o=0;for(;o<r.length-1&&r[o+1]<=t;)o++;return o}evaluate(t,r){let o=this.model,n=o.faces.length,i=r??{T:new Array(n),z:new Float64Array(n),lift:new Float64Array(3*n),group:new Int32Array(n),pose:{...le},step:0,local:0};t=ie(t,0,o.duration);let s=this.stepAt(t),a=o.steps[s],c=a.duration>0?ie((t-o.starts[s])/a.duration):1,d=V[a.ease??"fold"](c),u=a.table.length>0,f=a.table.map(h=>Ke(h,d)),x=a.joints.map(h=>{let A=u?d:V[h.ease](ie((c-h.at[0])/Math.max(1e-6,h.at[1]-h.at[0])));return Je(h,A,f[h.free]??0)}),b=new Map,[p,m]=a.restack??[0,1],l=V.inOut(ie((c-p)/Math.max(1e-6,m-p)));for(let h=0;h<n;h++){let A=o.tracks[h][s];if(A.chain.length){let v=A.chain.join(","),y=b.get(v);if(!y){y=Ee();for(let S of A.chain)y=D(x[S],y);b.set(v,y)}i.T[h]=D(y,A.T)}else i.T[h]=A.T;i.z[h]=It(A.z0,A.z1,l),this.lift(i,h,s,A.chain.length>0)}i.group.set(this.groupIds[s]);let g=V[a.ease??"inOut"](c),M=Math.sin(Math.PI*c),w=this.poseAt(s);for(let h of Ct){let A=a.pose?.[h];i.pose[h]=(A===void 0?w[h]:It(w[h],A,g))+(a.arc?.[h]??0)*M}if(a.path){let h=a.path(c);for(let A of Ct)i.pose[A]+=h[A]??0}return i.step=s,i.local=c,i}lift(t,r,o,n){let i=this.model.tracks[r][o],s=t.T[r],a=t.lift,c=3*r,d=Ze(i.T)&&this.endsFlat[o][r];if(!n&&Ze(s)||n&&d){a[c]=0,a[c+1]=0,a[c+2]=t.z[r];return}let u=this.anchors[o][r],f=u[8],x=u[9],b=u[10],p=s[0]*f+s[1]*x+s[2]*b,m=s[4]*f+s[5]*x+s[6]*b,l=s[8]*f+s[9]*x+s[10]*b,g=Math.min(1,Math.max(0,(.3-l)/.2)),M=t.z[r];a[c]=g*i.z0*p,a[c+1]=g*i.z0*m,a[c+2]=(1-g)*M+g*i.z0*l}poseAt(t){if(!this.poses){let r={...this.model.pose};this.poses=this.model.steps.map(o=>{let n=r;return r={...r,...o.pose},n})}return this.poses[t]}};var $=Math.SQRT1_2,po=[0,$],C=[0,-$],mo=[$,0],go=[-$,0],Lt=1-$,O=[Math.SQRT2-1,Lt],q=[1-Math.SQRT2,Lt],Mo=e=>[e*Math.sin(Math.PI/16),-$+Math.cos(Math.PI/16)],Vt=Mo(1),Vr=Mo(-1),bo=(()=>{let e=[0,2-$],t=[Vt[0]-C[0],Vt[1]-C[1]],r=[e[0]-O[0],e[1]-O[1]],o=t[0]*r[1]-t[1]*r[0],n=((O[0]-C[0])*r[1]-(O[1]-C[1])*r[0])/o;return C[1]+t[1]*n})(),je=.263,Ao=9*Math.PI/180,xo=.26,Ur=-55*Math.PI/180;function vo(e,[t,r]){let o=[r[0]-t[0],r[1]-t[1]],n=((e[0]-t[0])*o[0]+(e[1]-t[1])*o[1])/(o[0]*o[0]+o[1]*o[1]);return[2*(t[0]+o[0]*n)-e[0],2*(t[1]+o[1]*n)-e[1]]}var Ut=([e,t])=>e>0&&t>0,Tr=([e,t])=>e<0&&t>0,Lr=([e,t])=>e>0&&t<0,Tt=([e,t])=>e<0&&t<0,Xe=([e,t])=>t>Math.abs(e),Re=([e,t])=>e>Math.abs(t),Gt=([e,t])=>t<-Math.abs(e),Ot=([e,t])=>e<-Math.abs(t),wo=e=>e>0?Xe:Ot,yo=e=>e>0?Re:Gt,Rt=e=>e>0?Ut:Tt,Gr=e=>e>0?t=>Xe(t)&&t[0]<0:t=>Ot(t)&&t[1]>0,Or=e=>e>0?t=>Re(t)&&t[1]<0:t=>Gt(t)&&t[0]>0,Dt=e=>e>0?[0,1]:[-1,0],Qt=e=>e>0?[1,0]:[0,-1],X=e=>t=>e(t.sheet),me=(e,t,r)=>(t[0]-e[0])*(r[1]-e[1])-(t[1]-e[1])*(r[0]-e[0])>0;function ge(e,t){let r=e.find(o=>o.poly.some(n=>Math.hypot(n[0]-t[0],n[1]-t[1])<1e-7));if(!r)throw new Error(`crane: no face holds sheet point ${t}`);return r}function $e(){let e=new R({rx:-30,ry:12,ty:.7,tz:.5,o:0}),t=(l,g,M,w,h,A,v={})=>{let y=[];e.step({diagram:l,label:g,duration:.7,...v},S=>{y=S.fold(M,w,{side:h,toward:A,at:[.06,1]})}),e.step({diagram:l,label:"Unfold",duration:.42,ease:"inOut"},S=>{S.attach(y,S.hinge(M,w,h,-A,180,{ease:"inOut"}))})};e.step({diagram:1,label:"Start with a square",duration:1.1,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}}),t(2,"Fold in half diagonally",[-1,1],[1,-1],[1,1],1),t(2,"Fold the other diagonal",[-1,-1],[1,1],[1,-1],1),e.step({diagram:3,label:"Turn the paper over",duration:.8,ease:"inOut",pose:{ry:192},arc:{tz:.35}}),t(3,"Fold in half",[0,-1],[0,1],[-.5,0],-1),t(3,"Fold in half the other way",[-1,0],[1,0],[0,.5],-1),e.step({diagram:4,label:"Collapse into a square base",duration:1.4,ease:"inOut",pose:{s:1.22}},l=>{let g=[0,0],M=l.hinge(g,[0,1],[-.3,.8],-1),w=l.rot(g,[-1,1],"free",{free:0}),h=l.hinge(g,[-1,0],[-.8,-.3],-1),A=l.hinge(g,[0,-1],[.3,-.8],-1),v=l.rot(g,[1,-1],"free",{free:0}),y=l.rot([0,0,0],[0,0,1],-135),S=l.move([0,$,0]),E=k=>l.select(X(k)),F=E(k=>Re(k)&&k[1]>0),B=E(k=>Re(k)&&k[1]<0);l.attach(E(Ut),y,S),l.attach(E(k=>Xe(k)&&k[0]<0),M,y,S),l.attach(E(k=>Ot(k)&&k[1]>0),w,M,y,S),l.attach(E(Tt),h,w,M,y,S),l.attach(E(k=>Gt(k)&&k[0]>0),A,h,w,M,y,S),l.attach(B,v,A,h,w,M,y,S),l.pin(ge(B,[1,0]),ge(F,[1,0]),[1,0])});let r=(l,g)=>{let M=g?.8:1,w=[],h=[],A=[];e.step({diagram:5,label:g?"Repeat: edges to the centre":"Fold the edges to the centre",duration:.95*M},v=>{w=v.fold(C,O,{where:X(wo(l)),side:mo,toward:l,at:[0,.72]}),h=v.fold(C,q,{where:X(yo(l)),side:go,toward:l,at:[.28,1]})}),e.step({diagram:6,label:g?"Fold the top down":"Fold the top triangle down",duration:.65*M},v=>{A=v.fold(q,O,{side:po,toward:l})}),e.step({diagram:6,label:"Unfold the last three folds",duration:.8*M,ease:"inOut"},v=>{v.attach(A,v.hinge(q,O,po,-l,180,{at:[0,.6],ease:"inOut"})),v.attach(w,v.hinge(C,O,mo,-l,180,{at:[.3,1],ease:"inOut"})),v.attach(h,v.hinge(C,q,go,-l,180,{at:[.3,1],ease:"inOut"}))}),e.step({diagram:7,label:g?"Petal fold the back":"Petal fold: lift the bottom point",duration:1.3*M,ease:"inOut",pose:{s:1.2,ty:-.33}},v=>{let y=(T,_e)=>v.select(ne=>T(ne.sheet)&&ne.model[1]<Lt&&_e(ne.model)),S=T=>me(C,O,T)&&!me(C,q,T),E=y(Rt(l),S),F=y(Rt(l),T=>!me(C,O,T)),B=y(Rt(l),T=>me(C,q,T)),k=y(Gr(l),T=>!me(C,O,T)),_=y(Or(l),T=>me(C,q,T)),I=v.hinge(q,O,C,l),U=v.rot(C,O,"free"),W=v.rot(C,q,"free"),L=v.rot(C,O,"free"),K=v.rot(C,q,"free");v.attach(E,I),v.attach(F,U,I),v.attach(B,W,I),v.attach(k,L),v.attach(_,K),v.pin(ge(F,Dt(l)),ge(k,Dt(l)),Dt(l)),v.pin(ge(B,Qt(l)),ge(_,Qt(l)),Qt(l))})};r(-1,!1),e.step({diagram:7,label:"Turn over",duration:.8,ease:"inOut",pose:{ry:372},arc:{tz:.3}}),r(1,!0);let o=(l,g,M)=>e.step({diagram:g,label:M,duration:1,ease:"inOut",pose:{s:1.3,ty:-.36}},w=>{w.fold(C,Vt,{where:X(wo(l)),side:[.35,.1],toward:l,at:[0,.7]}),w.fold(C,Vr,{where:X(yo(l)),side:[-.35,.1],toward:l,at:[.3,1]})});o(1,8,"Narrow the legs"),e.step({diagram:9,label:"Turn over",duration:.8,ease:"inOut",pose:{ry:552},arc:{tz:.3}}),o(-1,9,"Narrow the other side");let n=X(l=>Xe(l)||Re(l)),i=l=>[C,[l*.097,je]],s=l=>[[0,je],[l*Math.cos(Ao),je-Math.sin(Ao)]],a=(l,g,M,w)=>{let h=[];return e.step({diagram:l,label:g,duration:1,ease:"inOut",pose:{s:1.45,ty:-.95}},A=>{h=A.reverse(A.select(v=>M(v.sheet)&&v.flat&&v.model[1]<je),s(w),{side:C,axis:i(w),front:n,kind:"inside"})}),()=>h},c=a(10,"Reverse fold the neck up",Tr,1);a(11,"Reverse fold the tail up",Lr,-1);let d=vo(C,s(1)),u=vo(i(1)[1],s(1)),f=[],x=[],b=[-1,bo],p=[1,bo],m=[0,1.2];return e.step({diagram:12,label:"Fold the wings down",duration:.9,ease:"inOut",pose:{s:1.55,ty:-.8}},l=>{f=l.fold(b,p,{where:X(g=>Ut(g)&&g[0]+g[1]>2-Math.SQRT2),side:m,toward:1,at:[0,.7]}),x=l.fold(b,p,{where:X(g=>Tt(g)&&g[0]+g[1]<Math.SQRT2-2),side:m,toward:-1,at:[.3,1]})}),e.step({diagram:13,label:"Reverse fold the head",duration:.8,ease:"inOut"},l=>{let g=d[0]-u[0],M=d[1]-u[1],w=Math.hypot(g,M),h=Math.atan2(M,g),A=[d[0]-g/w*xo,d[1]-M/w*xo],v=(h+Ur)/2,y=[A,[A[0]+Math.cos(v),A[1]+Math.sin(v)]];l.reverse(c(),y,{side:d,axis:[u,d],front:n,kind:"inside"})}),e.step({diagram:14,label:"Spread the wings",duration:1.5,ease:"inOut",pose:{ry:585,rx:-14,s:1.7,ty:-.9}},l=>{l.attach(f,l.hinge(b,p,m,-1,95,{ease:"inOut"})),l.attach(x,l.hinge(b,p,m,1,95,{ease:"inOut"}))}),e.step({diagram:14,label:"Finished crane",duration:.9,ease:"inOut"}),e.step({diagram:14,label:"Fly",duration:1,phase:"outro",ease:"in",pose:{ty:.7,tx:-.6,tz:.8,s:1.5,o:0}},l=>{l.attach(f,l.hinge(b,p,m,1,28,{ease:"flap"})),l.attach(x,l.hinge(b,p,m,-1,28,{ease:"flap"}))}),e.compile()}var z=Math.SQRT1_2,ee=[0,1],Eo=Math.tan(Math.PI/8),zr=Math.tan(Math.PI/16),Nr=[-z,1-z/Eo],_r=[z,1-z/Eo],et=[-2*zr,-1],tt=.62,Po=.42,So=50*Math.PI/180,ot=[Math.cos(So),Math.sin(So)],te=[-ot[1],ot[0]];function Wr(e){if(e<tt){let r=2*Math.PI*V.inOut(e/tt),o=Math.cos(r),n=Math.sin(r),i=[te[0]*o-te[1]*n,te[0]*n+te[1]*o],s=(1-o)/2;return{tx:Po*(te[0]-i[0]-te[0]*s),ty:Po*(te[1]-i[1]-te[1]*s),spin:r*180/Math.PI,rz:14*Math.sin(r)}}let t=V.in((e-tt)/(1-tt));return{tx:2.6*t*ot[0],ty:2.6*t*ot[1],spin:360,s:-.35*t,o:-t}}function rt(){let e=new R({rx:-30,ry:12,ty:.7,tz:.5,o:0},[[-z,-1],[z,-1],[z,1],[-z,1]]);e.step({diagram:1,label:"Start with a sheet of paper",duration:1,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}});let t=[];e.step({diagram:2,label:"Fold in half lengthwise",duration:.65},n=>{t=n.fold([0,-1],[0,1],{side:[.3,0],toward:1,at:[.06,1]})}),e.step({diagram:2,label:"Unfold",duration:.4,ease:"inOut"},n=>{n.attach(t,n.hinge([0,-1],[0,1],[.3,0],-1,180,{ease:"inOut"}))}),e.step({diagram:3,label:"Fold the top corners to the centre",duration:.95},n=>{n.fold(ee,[-z,1-z],{side:[-z+.05,.98],toward:1,at:[0,.7]}),n.fold(ee,[z,1-z],{side:[z-.05,.98],toward:1,at:[.3,1]})}),e.step({diagram:4,label:"Fold the edges to the centre again",duration:.95,pose:{s:1.05}},n=>{n.fold(ee,Nr,{side:[-.65,.2],toward:1,at:[0,.7]}),n.fold(ee,_r,{side:[.65,.2],toward:1,at:[.3,1]})}),e.step({diagram:5,label:"Fold the plane in half",duration:1,ease:"inOut",pose:{rz:-90,s:1.25,ty:-.3,tx:0}},n=>{n.fold([0,-1],[0,1],{side:[.3,0],toward:-1})});let r=[],o=[];return e.step({diagram:6,label:"Fold the wings down",duration:1,ease:"inOut"},n=>{r=n.fold(ee,et,{where:i=>i.sheet[0]<0,side:[-.6,-.8],toward:1,at:[0,.65]}),o=n.fold(ee,et,{where:i=>i.sheet[0]>0,side:[-.6,-.8],toward:-1,at:[.35,1]})}),e.step({diagram:7,label:"Open the wings",duration:1.3,ease:"inOut",pose:{rx:-30,ry:90,rz:0,spin:-40,s:1.25,ty:0,tx:0}},n=>{n.attach(r,n.hinge(ee,et,[-.6,-.8],-1,82,{ease:"inOut"})),n.attach(o,n.hinge(ee,et,[-.6,-.8],1,82,{ease:"inOut"}))}),e.step({diagram:7,label:"Ready to fly",duration:.6,ease:"inOut"}),e.step({diagram:7,label:"Fly",duration:2.1,phase:"outro",ease:"linear",path:Wr}),e.compile({colourDown:!0})}var De=5,zt=2/De,ce=(De-1)/2,Hr=84,Yr=6,Bo=e=>[[-1+e*zt,-1],[-1+e*zt,1]];function nt(){let e=new R({rx:-42,ry:28,ty:.55,tz:.4,o:0});e.step({diagram:1,label:"Start with a square",duration:.6,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1}}),e.step({diagram:2,label:"Crease the pleats",duration:.01},t=>{for(let r=1;r<De;r++)t.split(t.select(),...Bo(r))});for(let t=0;t<Yr;t++)e.step({diagram:2,label:"Pleat",duration:1.45,ease:"breathe"},r=>{let o=[];for(let i=1;i<De;i++){let[s,a]=Bo(i),c=i>ce?1:-1,d=[s[0]+.1*c,0],u=.16*Math.abs(i-(ce+.5))/ce;o[i]=r.hinge(s,a,d,i%2?1:-1,Hr,{at:[u,.84+u],ease:"breathe"})}let n=i=>r.select(s=>Math.floor((s.sheet[0]+1)/zt)===i);for(let i=0;i<De;i++){if(i===ce)continue;let s=[];if(i>ce)for(let a=i;a>ce;a--)s.push(o[a]);else for(let a=i+1;a<=ce;a++)s.push(o[a]);r.attach(n(i),...s)}});return e.step({diagram:2,label:"Done",duration:.5,phase:"outro",ease:"in",pose:{o:0,s:.92}}),e.compile()}var qr=[{label:"Fold the top corner down",line:[[1,0],[0,1]],corner:[1,1]},{label:"Fold the bottom corner up",line:[[-1,0],[0,-1]],corner:[-1,-1]},{label:"Fold the right corner in",line:[[0,-1],[1,0]],corner:[1,-1]},{label:"Fold the left corner in",line:[[0,1],[-1,0]],corner:[-1,1]}];function it(){let e=new R({rx:-26,ry:8,rz:45,s:.92,ty:.55,tz:.4,o:0});return e.step({diagram:1,label:"Start with a square",duration:.7,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1}}),qr.forEach(({label:t,line:r,corner:o},n)=>{let i=n===3?{s:1.3}:n===1?{s:1.08}:void 0;e.step({diagram:n+2,label:t,duration:.6,pose:i},s=>{s.fold(r[0],r[1],{side:o,toward:1,at:[.05,1]})})}),e.step({diagram:5,label:"Sealed",duration:.7,ease:"inOut",arc:{s:-.05}}),e.step({diagram:5,label:"Into the inbox",duration:.6,phase:"outro",ease:"in",pose:{ty:-.5,s:1,o:0}}),e.compile({colourDown:!0})}var Jr=-.3,be=-.65,Fo=be-Jr,Kr=e=>({rz:3.5*Math.sin(e*Math.PI*4),ty:.025*Math.sin(e*Math.PI*4+1.2)});function at(){let e=new R({rx:-24,ry:190,ty:.6,tz:.4,o:0});return e.step({diagram:1,label:"Start with a square",duration:.8,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}}),e.step({diagram:2,label:"Fold in half diagonally",duration:.8},t=>{t.fold([-1,-1],[1,1],{side:[-1,1],toward:-1,at:[.05,1]})}),e.step({diagram:3,label:"Fold the bottom up for the hull",duration:.8,pose:{s:1.1,ty:.12}},t=>{t.fold([-1,be],[1,be],{side:[0,-.9],toward:-1})}),e.step({diagram:4,label:"Fold the stern corner behind",duration:.7,pose:{s:1.2,ty:.18}},t=>{t.fold([1,be-Fo*.62],[1+Fo*.62,be],{side:[1,be],toward:1})}),e.step({diagram:5,label:"Afloat",duration:2.4,ease:"linear",path:Kr}),e.step({diagram:5,label:"Sail away",duration:1,phase:"outro",ease:"in",pose:{tx:1.5,s:1.05,o:0},arc:{rz:-3}}),e.compile()}var J=.5,N=[0,.5],Wt=[-J,1],Ht=[J,1],st=[J,0],lt=[-J,0],Yt=[-J,.5],qt=[J,.5],ko=[0,0],Nt=35,Io=28,Zr=25,Co=e=>{let t=(270+Zr)/2*Math.PI/180;return[-e*Math.cos(t),Math.sin(t)]};function ct([e,t]){if(t<0)return"body";let r=e-N[0],o=t-N[1];return o>Math.abs(r)?"top":o<-Math.abs(r)?"bottom":r<0?o>0?"upL":"lowL":o>0?"upR":"lowR"}var Ae=(...e)=>t=>e.includes(ct(t.sheet)),ut=e=>180*V.inOut(e),Vo=e=>{let t=ut(e);return t>=180-1e-9?180:2*Math.atan(Math.tan(t/2*Math.PI/180)/Math.SQRT2)*180/Math.PI},oe=e=>[e[0],e[1],0],dt=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],_t=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],jr=(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]],Uo=e=>{let t=Math.hypot(e[0],e[1],e[2]);return[e[0]/t,e[1]/t,e[2]/t]},Ro=(e,t,r,o)=>{let n=Uo(dt(oe(t),oe(e))),i=j(oe(e),n,r*Math.PI/180);return G(i,o[0],o[1],o[2])};function Xr(e,t,r,o){let n=Uo(dt(oe(t),oe(e))),i=c=>{let d=dt(c,oe(e)),u=_t(d,n);return dt(d,[n[0]*u,n[1]*u,n[2]*u])},s=i(r),a=i(o);return Math.atan2(_t(n,jr(s,a)),_t(s,a))*180/Math.PI}var Do=e=>t=>{let r=e<0?Wt:Ht,o=e<0?lt:st,n=e<0?Yt:qt,i=e<0?-1:1,s=Ro(N,[N[0]+1,N[1]],Vo(t),oe(r)),a=Ro(N,o,-i*ut(t),s);return Xr(N,n,oe(r),a)},Qo=e=>{let t=e<.18?Math.sin(e/.18*Math.PI):0,r=e>.18?Math.min(1,(e-.18)/.62):0,o=e>.8?Math.sin((e-.8)/.2*Math.PI):0;return{ty:.5*Math.sin(r*Math.PI)-.03*t,rx:-14*Math.sin(r*Math.PI),s:-.05*(t+o)}},$r=e=>({ty:.45*Math.abs(Math.sin(e*Math.PI*2)),tz:.9*e,o:-Math.max(0,(e-.35)/.65)});function ht(){let e=new R({rx:-28,s:.92,ty:.6,tz:.4,o:0},[[-J,-1],[J,-1],[J,1],[-J,1]]),t=(n,i,s,a,c,d)=>{let u=[];e.step({diagram:n,label:i,duration:.6},f=>{u=f.fold(s,a,{side:c,toward:d,at:[0,1]})}),e.step({diagram:n,label:"Unfold",duration:.38,ease:"inOut"},f=>{f.attach(u,f.hinge(s,a,c,-d,180,{ease:"inOut"}))})};e.step({diagram:1,label:"Start with a 1 : 2 rectangle",duration:.7,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}}),t(2,"Fold the corner to the far edge",Ht,lt,Wt,1),t(2,"And the other corner",Wt,st,Ht,1),t(3,"Fold the top behind",Yt,qt,[0,.9],-1),e.step({diagram:4,label:"Collapse into a waterbomb base",duration:1.3,ease:"inOut",pose:{s:1.15,ty:-.25}},n=>{let i=n.rot(N,lt,f=>-ut(f)),s=n.rot(N,st,f=>ut(f)),a=n.rot(N,[N[0]+1,N[1]],Vo),c=n.rot(N,Yt,Do(-1)),d=n.rot(N,qt,Do(1)),u=f=>n.select(Ae(f));n.attach(u("lowL"),i),n.attach(u("upL"),c,i),n.attach(u("lowR"),s),n.attach(u("upR"),d,s),n.attach(u("top"),a),n.layer(u("top"),[...u("upL"),...u("upR")]),n.layer([...u("upL"),...u("upR")],[...u("lowL"),...u("lowR")]),n.layer([...u("lowL"),...u("lowR")],u("bottom"))});let r=[];e.step({diagram:5,label:"Fold the front legs up",duration:1,pose:{s:1.25}},n=>{r=[...n.fold(ko,Co(-1),{where:Ae("top","upL"),side:lt,toward:1,at:[0,.7]}),...n.fold(ko,Co(1),{where:Ae("top","upR"),side:st,toward:1,at:[.3,1]})]}),e.step({diagram:7,label:"Fold the sides to the centre",duration:.9,pose:{s:1.3,ty:.05}},n=>{let i=n.fold([-.25,-1],[-.25,1],{where:Ae("body","bottom","lowL"),side:[-.5,-.5],toward:1,at:[0,.7]}),s=n.fold([.25,-1],[.25,1],{where:Ae("body","bottom","lowR"),side:[.5,-.5],toward:1,at:[.3,1]}),a=new Set(n.select());n.layer(r.filter(c=>a.has(c)),[...i,...s])}),e.step({diagram:8,label:"Fold the bottom up",duration:.8},n=>{n.fold([-1,-.5],[1,-.5],{where:Ae("body"),side:[0,-1],toward:1})}),e.step({diagram:9,label:"Fold it back down in half",duration:.8},n=>{n.fold([-1,-.25],[1,-.25],{where:i=>ct(i.sheet)==="body"&&i.sheet[1]<-.5,side:[0,0],toward:1})});let o=(n,i,s,a={})=>{let c=n.select(m=>ct(m.sheet)==="body"&&m.sheet[1]<-.5&&m.sheet[1]>-.75),d=n.select(m=>ct(m.sheet)==="body"&&m.sheet[1]<-.75),u=s*Math.PI/180,f=-.5+.25*Math.cos(u),x=.25*Math.sin(u),b=n.rot([-1,-.5,0],[1,-.5,0],i,a),p=n.rot([-1,f,x],[1,f,x],-i,a);n.attach(c,b),n.attach(d,p,b)};return e.step({diagram:10,label:"Turn over",duration:1,ease:"inOut",pose:{ry:200,rx:-62,rz:10,s:1.35,ty:.05},arc:{tz:.3}},n=>{o(n,Nt,0,{ease:"inOut",at:[.4,1]})}),e.step({diagram:10,label:"Hop",duration:1,ease:"linear",path:Qo},n=>o(n,-Io,Nt,{ease:"breathe",at:[0,.36]})),e.step({diagram:10,label:"Hop again",duration:1,ease:"linear",path:Qo},n=>o(n,-Io,Nt,{ease:"breathe",at:[0,.36]})),e.step({diagram:10,label:"Hop away",duration:1.2,phase:"outro",ease:"linear",path:$r}),e.compile({colourDown:!0})}var Qe=[0,-1],xe=(e,t,r=3)=>{let o=e*Math.PI/180;return[t*r*Math.sin(o),-1+r*Math.cos(o)]},To=e=>e*Math.PI/180,Lo=15,en=278,tn=11.25,Go=.29,Oo=.3;function zo(e,[t,r]){let o=[r[0]-t[0],r[1]-t[1]],n=((e[0]-t[0])*o[0]+(e[1]-t[1])*o[1])/(o[0]*o[0]+o[1]*o[1]);return[2*(t[0]+o[0]*n)-e[0],2*(t[1]+o[1]*n)-e[1]]}var No=(e,t)=>[e,[e[0]+Math.cos(To(t)),e[1]+Math.sin(To(t))]];function on(e,t){let r=0;for(let o=0;o<e.length;o++){let n=e[o],i=e[(o+1)%e.length],s=(i[0]-n[0])*(t[1]-n[1])-(i[1]-n[1])*(t[0]-n[0]);if(!(Math.abs(s)<1e-9)){if(r&&Math.sign(s)!==r)return!1;r=Math.sign(s)}}return!0}var rn=e=>({ty:.03*Math.sin(e*Math.PI*2),rz:1.5*Math.sin(e*Math.PI*2+.8)});function ft(){let e=new R({rx:-20,ry:180,ty:.6,tz:.4,o:0},[[0,-1],[1,0],[0,1],[-1,0]]);e.step({diagram:1,label:"Start with a square",duration:.7,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}}),e.step({diagram:2,label:"Fold the edges to the centre",duration:.9},a=>{a.fold(Qe,xe(22.5,-1),{side:[-1,0],toward:-1,at:[0,.7]}),a.fold(Qe,xe(22.5,1),{side:[1,0],toward:-1,at:[.3,1]})}),e.step({diagram:3,label:"Turn over",duration:.7,ease:"inOut",pose:{ry:360},arc:{tz:.3}}),e.step({diagram:4,label:"Fold the edges to the centre again",duration:.9,pose:{s:1.1}},a=>{a.fold(Qe,xe(11.25,-1),{side:xe(17,-1,.75),toward:1,at:[0,.7]}),a.fold(Qe,xe(11.25,1),{side:xe(17,1,.75),toward:1,at:[.3,1]})});let t=[];e.step({diagram:5,label:"Fold the point up to the top",duration:.8,pose:{s:1.25,ty:-.3}},a=>{t=a.fold([-1,0],[1,0],{side:Qe,toward:1}).map(c=>c.poly)});let r=a=>t.some(c=>on(c,nn(a.poly)));e.step({diagram:6,label:"Fold in half",duration:.9,ease:"inOut",pose:{rz:90,rx:-10,s:1.5,tx:.62,ty:.2}},a=>{a.fold([0,-1],[0,1],{side:[.5,.5],toward:-1})});let o=a=>a.sheet[0]<0,n=No([0,Go],(90+Lo)/2),i=[[0,Go],[0,1]],s=[];return e.step({diagram:7,label:"Pull the neck up",duration:1.1,ease:"inOut",pose:{rz:90-tn,s:1.6,tx:.34,ty:-.22}},a=>{s=a.reverse(a.select(c=>c.flat).filter(r),n,{side:[0,1],axis:i,front:o,kind:"outside",roll:"last",book:!0})}),e.step({diagram:8,label:"Reverse fold the head",duration:.8,ease:"inOut"},a=>{let c=zo([0,1],n),d=zo(i[0],n),u=Math.hypot(c[0]-d[0],c[1]-d[1]),f=[c[0]+(d[0]-c[0])/u*Oo,c[1]+(d[1]-c[1])/u*Oo];a.reverse(s,No(f,(Lo+en)/2),{side:c,axis:[d,c],front:o,kind:"inside"})}),e.step({diagram:8,label:"Drift",duration:2.4,ease:"linear",path:rn}),e.step({diagram:8,label:"Glide away",duration:1.1,phase:"outro",ease:"in",pose:{tx:2.4,o:0}}),e.compile()}function nn(e){let t=0,r=0;for(let o of e)t+=o[0],r+=o[1];return[t/e.length,r/e.length]}var Jt=.5,Ve=-.25,Kt=[0,Ve],_o=.12,Wo=e=>{let t=(r,o,n)=>n*Math.exp(-(((e-r)/o)**2));return{s:t(.18,.06,.09)+t(.36,.07,.06)}};function pt(){let e=new R({rx:-16,ry:180,ty:.6,tz:.4,o:0},[[0,-1],[1,0],[0,1],[-1,0]]);return e.step({diagram:1,label:"Start with a square",duration:.7,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}}),e.step({diagram:2,label:"Fold the top corner to the centre",duration:.7},t=>{t.fold([-1,Jt],[1,Jt],{side:[0,1],toward:-1,at:[.05,1]})}),e.step({diagram:3,label:"Fold the bottom corner up",duration:.8},t=>{t.fold([-1,Ve],[1,Ve],{side:[0,-1],toward:-1})}),e.step({diagram:4,label:"Fold the sides up to the centre",duration:1,pose:{s:1.3,ty:-.2}},t=>{t.fold(Kt,[-1,Ve+1],{side:[-.9,-.05],toward:-1,at:[0,.7]}),t.fold(Kt,[1,Ve+1],{side:[.9,-.05],toward:-1,at:[.3,1]})}),e.step({diagram:5,label:"Fold the corners behind",duration:.9,pose:{s:1.55,ty:-.4}},t=>{let r=[];for(let o of[-1,1]){let n=[o*.25,.75],i=[o*.625,.375],s=[0,Jt];r.push({p:n,a:s,b:i,top:!0},{p:i,a:n,b:Kt,top:!1})}r.forEach(({p:o,a:n,b:i,top:s},a)=>{let c=u=>{let f=[u[0]-o[0],u[1]-o[1]],x=Math.hypot(f[0],f[1]);return[o[0]+f[0]/x*_o,o[1]+f[1]/x*_o]},d=Math.sign(o[0]);t.fold(c(n),c(i),{where:s?u=>u.model[0]*d>-.1:void 0,side:o,toward:1,at:[a*.12,.64+a*.12]})})}),e.step({diagram:5,label:"Beat",duration:1.1,ease:"linear",path:Wo}),e.step({diagram:5,label:"Beat again",duration:1.1,ease:"linear",path:Wo}),e.step({diagram:5,label:"Float away",duration:1,phase:"outro",ease:"in",pose:{ty:.4,s:1.35,o:0}}),e.compile()}var re=e=>[e[0],e[1],e[2]??0],an=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]];var sn=e=>{let t=Math.hypot(e[0],e[1],e[2]);return[e[0]/t,e[1]/t,e[2]/t]};function Ue(e,t,r,o){let n=j(re(e),sn(an(re(t),re(e))),r*Math.PI/180);return G(n,o[0],o[1],o[2])}function Ho(e,t,r={}){let o=r.samples??181,n=r.window??30,i=r.step??.25,s=new Float64Array(o);s[0]=t;for(let a=1;a<o;a++){let c=a/(o-1),d=s[a-1],u=d,f=1/0;for(let x=-n;x<n;x+=i){let b=d+x,p=b+i,m=e(c,b),l=e(c,p);if(m===0||m*l<0){let g=b,M=p,w=m;for(let A=0;A<40;A++){let v=(g+M)/2,y=e(c,v);w*y<=0?M=v:(g=v,w=y)}let h=(g+M)/2;if(r.ok&&!r.ok(c,h))continue;Math.abs(h-d)<f&&(f=Math.abs(h-d),u=h)}}s[a]=u}return a=>{let c=Math.min(1,Math.max(0,a))*(o-1),d=Math.min(o-2,Math.floor(c));return s[d]+(s[d+1]-s[d])*(c-d)}}var we=Math.SQRT2-1,At=[0,1],Te=[0,-1],mt=[0,0],H=e=>[e*we,0],ye=e=>[e,0],xt=e=>[e*Math.SQRT1_2,1-Math.SQRT1_2],vt=e=>[e*Math.SQRT1_2,Math.SQRT1_2-1],Yo=.3,qo=(1+we)/2,gt=-.7,ln=350,cn=12;function Zo([e,t]){if(Math.abs(e)/we+Math.abs(t)<1)return"centre";let r=e<0?-1:1,o=t>0,n=H(r),i=o?xt(r):vt(r);return Math.sign(Q(n,i,[e,t]))===Math.sign(Q(n,i,ye(r)))?o?"upEar":"lowEar":o?"upMain":"lowMain"}var ve=(...e)=>t=>e.includes(Zo(t.sheet)),bt=ve("upEar","lowEar"),dn=(e,t,r)=>Ue(e,t,10,re(r))[2]<0?1:-1,Jo=e=>180*V.inOut(e);function un(e,t){let r=t?At:Te,o=t?xt(e):vt(e),n=dn(H(e),r,ye(e)),i=(a,c)=>Ue(H(e),r,n*180*a,Ue(H(e),o,c,re(ye(e)))),s=Ho((a,c)=>i(a,c)[1],0,{ok:(a,c)=>i(a,c)[2]<=1e-9});return{kite:a=>n*Jo(a),ear:a=>s(Jo(a)/180)}}var Ko=e=>({ty:.04*Math.sin(e*Math.PI*2),rz:2.5*Math.sin(e*Math.PI*2-.6)});function wt(){let e=new R({rx:-20,ry:180,ty:.6,tz:.4,o:0},[[0,-1],[1,0],[0,1],[-1,0]]);e.step({diagram:1,label:"Start with a square",duration:.7,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}});let t=(o,n,i)=>{let s=[];e.step({diagram:o,label:n,duration:.8},a=>{s=[-1,1].map(c=>a.fold(i,H(c),{side:ye(c),toward:-1,at:c<0?[0,.7]:[.3,1]}))}),e.step({diagram:o,label:"Unfold",duration:.45,ease:"inOut"},a=>{[-1,1].forEach((c,d)=>a.attach(s[d],a.hinge(i,H(c),ye(c),1,180,{ease:"inOut"})))})};t(2,"Fold the bottom edges to the centre",Te),t(3,"Fold the top edges to the centre",At),e.step({diagram:4,label:"Collapse into a fish base",duration:1.4,ease:"inOut",pose:{s:1.1}},o=>{for(let n of[-1,1]){let i=s=>Zo(o.info(s).sheet)!=="centre"&&n*o.info(s).sheet[0]>0;o.split(o.select().filter(i),[-1,0],[1,0]),o.split(o.select(ve("upMain","upEar")).filter(i),H(n),xt(n)),o.split(o.select(ve("lowMain","lowEar")).filter(i),H(n),vt(n));for(let s of[!0,!1]){let a=s?At:Te,c=s?xt(n):vt(n),d=un(n,s),u=o.rot(H(n),a,d.kite),f=o.rot(H(n),c,d.ear),x=b=>o.select(ve(b)).filter(p=>n*o.info(p).sheet[0]>0);o.attach(x(s?"upMain":"lowMain"),u),o.attach(x(s?"upEar":"lowEar"),f,u)}}}),e.step({diagram:4,label:"Flatten the ears down",duration:.8,ease:"inOut"},o=>{for(let n of[-1,1]){let s=Ue(H(n),mt,90,[0,0,-we])[1]<0?90:-90;o.attach(o.select(bt).filter(a=>n*o.info(a).sheet[0]>0),o.rot(re(H(n)),re(mt),s,{ease:"inOut"}))}o.layer(o.select(ve("lowEar")),o.select(ve("upEar")))}),e.step({diagram:5,label:"Fold the tip back",duration:.7},o=>{o.fold([-1,qo],[1,qo],{side:At,toward:1})}),e.step({diagram:5,label:"Turn over",duration:.8,ease:"inOut",pose:{ry:360},arc:{tz:.3}}),e.step({diagram:6,label:"Fold the corners in",duration:.7,pose:{s:1.15}},o=>{for(let n of[-1,1])o.fold([n*Yo,-1],[n*Yo,1],{side:ye(n),toward:1,at:n<0?[0,.7]:[.3,1]})}),e.step({diagram:7,label:"Fold in half",duration:.9,ease:"inOut",pose:{rz:90,rx:-12,s:1.45,tx:.2,ty:-.05}},o=>{o.fold([0,-1],[0,1],{side:[.3,0],toward:1})}),e.step({diagram:8,label:"Fold the flippers down",duration:.8},o=>{o.fold(mt,[-1,-1],{where:n=>bt(n)&&n.sheet[0]>0,side:[0,-we],toward:1,at:[0,.7]}),o.fold(mt,[-1,-1],{where:n=>bt(n)&&n.sheet[0]<0,side:[0,-we],toward:-1,at:[.3,1]})});let r=[];return e.step({diagram:9,label:"Lift the tail",duration:.9,ease:"inOut",pose:{s:1.5}},o=>{let n=(270+ln)/2*Math.PI/180,i=[[0,gt],[-Math.cos(n),gt-Math.sin(n)]];r=o.reverse(o.select(s=>s.flat&&!bt(s)),i,{side:Te,axis:[[0,gt],Te],front:s=>s.sheet[0]>0,kind:"outside",roll:"last",book:!0})}),e.step({diagram:10,label:"Swim",duration:1.4,ease:"linear",path:Ko},o=>{o.attach(r,o.swing([0,gt],cn,{ease:"breathe"}))}),e.step({diagram:10,label:"Swim on",duration:1.4,ease:"linear",path:Ko}),e.step({diagram:10,label:"Dive",duration:1,phase:"outro",ease:"in",pose:{ty:-.9,rz:112,o:0}}),e.compile()}var jo=[0,0],Xo=[0,-1],hn=-.3,$o=-.9,fn=28,pn=e=>e[0]<-Math.abs(e[1]),mn=e=>e[0]>Math.abs(e[1]),er=e=>[[e*.5,-.5],[0,hn]],gn=e=>({rz:9*Math.sin(e*Math.PI*2)*Math.sin(e*Math.PI)});function yt(){let e=new R({rx:-14,ry:180,ty:.6,tz:.4,o:0},[[0,-1],[1,0],[0,1],[-1,0]]);e.step({diagram:1,label:"Start with a square",duration:.7,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}}),e.step({diagram:2,label:"Fold the top corner down",duration:.7},r=>{r.fold([-1,0],[1,0],{side:[0,1],toward:-1,at:[.05,1]})}),e.step({diagram:3,label:"Fold the corners to the bottom",duration:.9,pose:{s:1.4,ty:.25}},r=>{r.fold(jo,[-.5,-.5],{side:[-1,0],toward:-1,at:[0,.7]}),r.fold(jo,[.5,-.5],{side:[1,0],toward:-1,at:[.3,1]})});let t=[];return e.step({diagram:4,label:"Fold the ears up",duration:1,pose:{s:1.55,ty:.2}},r=>{t=[-1,1].map((o,n)=>r.fold(...er(o),{where:i=>(o<0?pn:mn)(i.sheet),side:Xo,toward:-1,at:n?[.3,1]:[0,.7]}))}),e.step({diagram:5,label:"Tuck the nose behind",duration:.6,pose:{s:1.6,ty:.28}},r=>{r.fold([-1,$o],[1,$o],{side:Xo,toward:1})}),e.step({diagram:6,label:"Tilt the head",duration:1.6,ease:"linear",path:gn}),e.step({diagram:6,label:"Twitch the ears",duration:.9,ease:"linear"},r=>{t.forEach((o,n)=>{let i=n?1:-1,[s,a]=er(i);r.attach(o,r.hinge(s,a,[i*.6,.3],-1,fn,{ease:"breathe",at:n?[.25,1]:[0,.75]}))})}),e.step({diagram:6,label:"Trot off",duration:.9,phase:"outro",ease:"in",pose:{tx:-1.4,o:0},arc:{ty:.08}}),e.compile()}var jt=new Map([["crane",$e],["plane",rt],["pleat",nt],["envelope",it],["boat",at],["frog",ht],["swan",ft],["heart",pt],["whale",wt],["fox",yt]]),Zt=new Map;function tr(){return[...jt.keys()]}function or(e,t){jt.set(e,t),Zt.delete(e)}function Mt(e){let t=Zt.get(e);if(!t){let r=jt.get(e);if(!r)return;t=new pe(r()),Zt.set(e,t)}return t}var Le={distance:5,light:Fe([-.45,.7,.75])};function bn(e){return D(ue(e.tx,e.ty,e.tz),D(kt(e.spin*Y),D(lo(e.s),D(ao(e.rx*Y),D(so(e.ry*Y),kt(e.rz*Y))))))}var rr=1e-6;function nr(e,t,r){let o=e.normal,n=ae(o,Be(r,e.center))>=0?1:-1,i=!1,s=!1;for(let a of t.pts){let c=ae(o,Be(a,e.center))*n;if(c>rr?i=!0:c<-rr&&(s=!0),i&&s)return 0}return i?1:s?-1:0}function An(e,t){for(let r of[e,t])for(let o=0;o<r.length;o++){let n=r[o],i=r[(o+1)%r.length],s=n[1]-i[1],a=i[0]-n[0],c=Math.hypot(s,a);if(c<1e-9)continue;let d=1/0,u=-1/0,f=1/0,x=-1/0;for(let b of e){let p=(b[0]*s+b[1]*a)/c;p<d&&(d=p),p>u&&(u=p)}for(let b of t){let p=(b[0]*s+b[1]*a)/c;p<f&&(f=p),p>x&&(x=p)}if(u<=f+1e-4||x<=d+1e-4)return!1}return!0}function xn(e,t,r){let o=0,n;for(let d of e.polys)for(let u of t.polys){let f=He(d,u);if(f.length<3)continue;let x=Math.abs(se(f));x>o&&(o=x,n=ke(f))}if(!n||o<1e-7)return 0;let i=[n[0],-n[1],-r],s=d=>{let u=ae(d.normal,i);return Math.abs(u)<1e-12?1/0:(d.normal[0]*d.center[0]+d.normal[1]*d.center[1]+d.normal[2]*(d.center[2]-r))/u},a=s(e),c=s(t);return!isFinite(a)||!isFinite(c)||a===c?0:c<a?1:-1}function $t(e,t=Le){let r=[0,0,t.distance],o=e.length,n=e.map(d=>ho(d.scr)),i=e.map(()=>[]),s=new Int32Array(o);for(let d=0;d<o;d++){let u=e[d];for(let f=d+1;f<o;f++){let x=e[f];if(u.box[2]<=x.box[0]||x.box[2]<=u.box[0]||u.box[3]<=x.box[1]||x.box[3]<=u.box[1]||!An(n[d],n[f]))continue;let b=-nr(u,x,r);b||(b=nr(x,u,r)),b||(b=-xn(u,x,t.distance)),b&&(b<0?(i[d].push(f),s[f]++):(i[f].push(d),s[d]++))}}let a=[],c=new Uint8Array(o);for(let d=0;d<o;d++){let u=-1;for(let f=0;f<o;f++)!c[f]&&s[f]===0&&(u<0||e[f].depth>e[u].depth)&&(u=f);if(u<0)for(let f=0;f<o;f++)!c[f]&&(u<0||e[f].depth>e[u].depth)&&(u=f);c[u]=1,a.push(u);for(let f of i[u])s[f]--}return a}function vn(e,t,r=Le){let o=e.faces.length,n=bn(t.pose),i=r.distance,s=[0,0,i],a=new Array(o),c=new Array(o),d=new Array(o),u=new Array(o);for(let l=0;l<o;l++){let g=t.T[l];u[l]=[g[2],g[6],g[10]],a[l]=D(n,D(ue(t.lift[3*l],t.lift[3*l+1],t.lift[3*l+2]),g)),c[l]=e.faces[l].map(M=>G(a[l],e.verts[M][0],e.verts[M][1],0)),d[l]=c[l].map(([M,w,h])=>{let A=i/(i-h);return[M*A,-w*A]})}let f=Int32Array.from({length:o},(l,g)=>g),x=l=>f[l]===l?l:f[l]=x(f[l]),b=new Uint8Array(e.edges.length);e.edges.forEach((l,g)=>{if(l.faces.length!==2)return;let[M,w]=l.faces;if(ae(u[M],u[w])>1-1e-9){b[g]=1;let h=t.lift;Math.abs(h[3*M]-h[3*w])+Math.abs(h[3*M+1]-h[3*w+1])+Math.abs(h[3*M+2]-h[3*w+2])<1e-9&&(f[x(M)]=x(w))}});let p=new Map;for(let l=0;l<o;l++){let g=x(l),M=p.get(g);M?M.push(l):p.set(g,[l])}let m=[];for(let l of p.values()){let g=[],M=[],w=[0,0,0],h=[1/0,1/0,-1/0,-1/0];for(let y of l)for(let S=0;S<c[y].length;S++){g.push(c[y][S]),M.push(d[y][S]);let[E,F]=d[y][S];E<h[0]&&(h[0]=E),E>h[2]&&(h[2]=E),F<h[1]&&(h[1]=F),F>h[3]&&(h[3]=F)}for(let y of g)w[0]+=y[0]/g.length,w[1]+=y[1]/g.length,w[2]+=y[2]/g.length;let A=a[l[0]],v=Be(s,w);m.push({faces:l,pts:g,scr:M,polys:l.map(y=>he(d[y].slice())),normal:Fe([A[2],A[6],A[10]]),center:w,depth:Math.hypot(v[0],v[1],v[2]),box:h})}return{W:a,pts:c,scr:d,flat:b,panels:m,order:$t(m,r)}}var Xt="http://www.w3.org/2000/svg",de=e=>Math.round(e*1e3)/1e3,Me=class{constructor(t,r,o=Le){this.root=t;this.m=r;this.cam=o;this.slots=[];this.uid=Math.random().toString(36).slice(2,8);t.textContent="",this.defs=document.createElementNS(Xt,"defs"),this.image=document.createElementNS(Xt,"image"),this.image.id=`${this.uid}-img`;for(let[n,i]of[["width","2"],["height","2"],["preserveAspectRatio","none"]])this.image.setAttribute(n,i);this.defs.appendChild(this.image),t.appendChild(this.defs)}setTexture(t){this.image.setAttribute("href",t)}slot(t){let r=this.slots[t];if(r)return r;let o=(x,b)=>{let p=document.createElementNS(Xt,x);return b&&p.setAttribute("class",b),p},n=o("pattern");n.id=`${this.uid}-t${t}`,n.setAttribute("patternUnits","userSpaceOnUse"),n.setAttribute("width","2"),n.setAttribute("height","2");let i=o("use");i.setAttribute("href",`#${this.uid}-img`),n.appendChild(i),this.defs.appendChild(n);let s=o("path","f"),a=o("path","t");a.style.fill=`url(#${n.id})`;let c=o("g"),d=c.appendChild(o("path","m")),u=c.appendChild(o("path","a")),f=c.appendChild(o("path","e"));return this.root.append(s,a,c),r={fill:s,tex:a,pattern:n,lines:c,mem:d,act:u,edge:f,cache:["","","","","","","",""]},this.slots[t]=r,r}render(t){let r=this.m,o=this.cam.distance,n=[0,0,o],{W:i,scr:s,flat:a,panels:c,order:d}=vn(r,t,this.cam),u=t.step;for(let f=0;f<d.length;f++){let x=c[d[f]],b=this.slot(f),p="",m="",l="",g="";for(let U of x.faces){let W=s[U];for(let L=0;L<W.length;L++)p+=(L?"L":"M")+de(W[L][0])+" "+de(W[L][1]);p+="Z",r.faceEdges[U].forEach((L,K)=>{let T=W[K],_e=W[(K+1)%W.length],ne=`M${de(T[0])} ${de(T[1])}L${de(_e[0])} ${de(_e[1])}`,Se=r.edges[L];if(Se.faces.length<2||!a[L])g+=ne;else{let Pr=Se.faces[0]===U?Se.faces[1]:Se.faces[0];Se.born<=u&&(m+=ne),t.group[U]!==t.group[Pr]&&(l+=ne)}})}let M=i[x.faces[0]],w=ae(x.normal,Be(n,x.center))>0,h=w?x.normal:[-x.normal[0],-x.normal[1],-x.normal[2]],A=Math.max(0,ae(h,this.cam.light)),v=w!==!!r.colourDown,y=v?"f":"b",S=`color-mix(in oklab,var(--_l${y}) ${Math.round((.15+.85*A)*100)}%,var(--_s${y}))`,E=v?"front":"back",F=r.faces[x.faces[0]],B=0,k=0;for(let U of F)B+=r.verts[U][0]/F.length,k+=r.verts[U][1]/F.length;let _=wn(M,o,B,k),I=b.cache;I[0]!==p&&(b.fill.setAttribute("d",I[0]=p),b.tex.setAttribute("d",p)),I[1]!==m&&b.mem.setAttribute("d",I[1]=m),I[2]!==l&&b.act.setAttribute("d",I[2]=l),I[3]!==g&&b.edge.setAttribute("d",I[3]=g),I[4]!==S&&b.fill.style.setProperty("--f",I[4]=S),I[5]!==E&&b.lines.setAttribute("class",I[5]=E),I[6]!==_&&b.pattern.setAttribute("patternTransform",I[6]=_),I[7]!=="1"&&(I[7]="1",b.fill.style.display=b.tex.style.display=b.lines.style.display="")}for(let f=d.length;f<this.slots.length;f++){let x=this.slots[f];x.cache[7]!=="0"&&(x.cache[7]="0",x.fill.style.display=x.tex.style.display=x.lines.style.display="none")}this.root.style.opacity=String(de(t.pose.o))}};function wn(e,t,r,o){let n=(g,M)=>{let[w,h,A]=G(e,g,M,0),v=t/(t-A);return[w*v,-h*v]},s=n(r,o),a=n(r+.25,o),c=n(r,o+.25),d=(a[0]-s[0])/.25,u=(a[1]-s[1])/.25,f=-(c[0]-s[0])/.25,x=-(c[1]-s[1])/.25,b=r+1,p=1-o,m=s[0]-d*b-f*p,l=s[1]-u*b-x*p;return`matrix(${[d,u,f,x,m,l].map(g=>Math.round(g*1e4)/1e4).join(" ")})`}var ir=`
694
+ `});function We(e){if(Array.isArray(e))return e.length===4?e:e.length===3?[...e,1]:Fe;if(typeof e!="string")return Fe;let t,r,o,i=1;if(e.startsWith("#"))[t,r,o,i]=Ii(e);else if(e.startsWith("rgb")){let a=Ci(e);if(a===null)return Fe;[t,r,o,i]=a}else if(e.startsWith("hsl")){let a=Ri(e);if(a===null)return Fe;[t,r,o,i]=Di(a)}else return console.error("Unsupported color format",e),Fe;return[kt(t,0,1),kt(r,0,1),kt(o,0,1),kt(i,0,1)]}function Ii(e){if(e=e.replace(/^#/,""),(e.length===3||e.length===4)&&(e=e.split("").map(a=>a+a).join("")),e.length===6&&(e=e+"ff"),!/^[0-9a-f]{8}$/i.test(e))return console.warn("Invalid hex color"),Fe;let t=parseInt(e.slice(0,2),16)/255,r=parseInt(e.slice(2,4),16)/255,o=parseInt(e.slice(4,6),16)/255,i=parseInt(e.slice(6,8),16)/255;return[t,r,o,i]}function Ci(e){let t=e.match(/^rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([0-9.]+))?\s*\)$/i);return t?[parseInt(t[1]??"0")/255,parseInt(t[2]??"0")/255,parseInt(t[3]??"0")/255,t[4]===void 0?1:parseFloat(t[4])]:null}function Ri(e){let t=e.match(/^hsla?\s*\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*([0-9.]+))?\s*\)$/i);return t?[parseInt(t[1]??"0"),parseInt(t[2]??"0"),parseInt(t[3]??"0"),t[4]===void 0?1:parseFloat(t[4])]:null}function Di(e){let[t,r,o,i]=e,a=t/360,s=r/100,n=o/100,l,d,u;if(r===0)l=d=u=n;else{let p=(f,g,c)=>(c<0&&(c+=1),c>1&&(c-=1),c<.16666666666666666?f+(g-f)*6*c:c<.5?g:c<.6666666666666666?f+(g-f)*(.6666666666666666-c)*6:f),b=n<.5?n*(1+s):n+s-n*s,m=2*n-b;l=p(m,b,a+1/3),d=p(m,b,a),u=p(m,b,a-1/3)}return[l,d,u,i]}var kt,Fe,yr=$(()=>{kt=(e,t,r)=>Math.min(Math.max(e,t),r),Fe=[.5,.5,.5,1]});function so(){if(typeof window>"u")return;let e=new Image;return e.src=Qi,e}var Qi,Mr=$(()=>{Qi="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAADAFBMVEUCAQMBAf7/AgMD/wID//7+/wT+A/4FAmYIAqIKnw7+//4EAisEAUgGBIYIew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dvYAdQNaQJUDRHlHml5cSLMjaYxAqHmbAaTZAZcZ5s6JLJGip7sCXaw2LCRnK1YMO4sFRAgVWgfXMfc+zt038JeI6lkCDQU5yCGeZRBOA9aMG3e0AZ7cmQmKjgeCWvmJnn7yAwY8uoEEL1wLBADizps1VFIzm5UYtBHFT5Qy46UAsQTBZCwPgljNPekNGEwdic0FR1JmP5AAhShTl4MCWwq2By1NKlUqzQQGAidkywDoSgYGtQ8JRdefJLqPjw5YsD85GiBWlRsDZ2GzVDkCvRSyUzIq16YUXEBLd2kGn+rLIwAAAK1JREFUf54DD3C0WwmGPi9OSjpCA0A7fFwUZTm0ktDZLl5VXmbFDDQACl7+QSry5QCM2bfNC+WAFj1LAzLsiwEBaQCW/1EGcMN/tG8OViQtylulBUxRADYm5SEBRAcAARkeMC5iRNgZhOoxnz4oHApa6gD3ASdbmF188wxpDZVKUL4RUhTSSRvrQAZLDcgauImabgJzkXIaALePAXot1j6Bdwe3AXoQAnXMFVuCApGWbjuRvTu7AAAAAElFTkSuQmCC"});var Pr=$(()=>{mr();gr();wr();yr();Mr()});var Sr={};co(Sr,{renderPaperShader:()=>Vi});async function Vi(e){if(typeof document>"u"||typeof requestAnimationFrame!="function")return;let t=so();if(!t)return;await t.decode();let r=document.createElement("div");r.setAttribute("aria-hidden","true"),r.style.cssText=`position:fixed;left:0;top:0;width:${e}px;height:${e}px;opacity:0;pointer-events:none;z-index:-1;contain:strict`,document.body.appendChild(r);let o;try{let i=io;o=new _e(r,ao,{u_image:void 0,u_isImage:!1,u_imageAspectRatio:1,u_colorBack:We("#808080"),u_colorPaper:We("#808080"),u_colorShadow:We("#000000"),u_blending:0,u_distortion:0,u_clip:!1,u_angle:135,u_seed:7,u_roughness:.12,u_roughnessSize:.15,u_roughnessRows:0,u_fiber:.95,u_fiberSize:.55,u_folds:0,u_foldSizeX:.5,u_foldSizeY:.5,u_foldOffsetX:0,u_foldOffsetY:0,u_wrinkles:.06,u_wrinkleSize:.6,u_crumples:0,u_crumpleCount:5,u_drops:0,u_noiseTexture:t,u_fit:no[i.fit],u_scale:1,u_rotation:0,u_originX:i.originX,u_originY:i.originY,u_offsetX:0,u_offsetY:0,u_worldWidth:i.worldWidth,u_worldHeight:i.worldHeight},{preserveDrawingBuffer:!0,antialias:!1},0,0,1,e*e);let a=o.canvasElement;for(let g=0;g<10&&(a.width===0||a.height===0);g++)await lo();await lo(),await lo();let s=document.createElement("canvas");s.width=s.height=e;let n=s.getContext("2d");if(!n||!a.width)return;n.drawImage(a,0,0,e,e);let l=n.getImageData(0,0,e,e),d=l.data,u=d.length/4,p=new Float32Array(u),b=0;for(let g=0;g<u;g++)p[g]=(d[g*4]+d[g*4+1]+d[g*4+2])/3,b+=p[g]/u;let m=0;for(let g=0;g<u;g++)m+=Math.abs(p[g]-b)/u;if(m<.5)return;let f=Ui/m;for(let g=0;g<u;g++){let c=(p[g]-b)*f;d[g*4]=d[g*4+1]=d[g*4+2]=c>0?255:0,d[g*4+3]=Math.min(255,Math.abs(c))}return n.putImageData(l,0,0),await new Promise(g=>s.toBlob(c=>g(c?URL.createObjectURL(c):s.toDataURL("image/png")),"image/png"))}catch{return}finally{o?.dispose(),r.remove()}}var Ui,lo,Er=$(()=>{"use strict";Pr();Ui=15,lo=()=>new Promise(e=>requestAnimationFrame(()=>e()))});var zi={};co(zi,{Folder:()=>R,LAYER:()=>je,OrigamiLoader:()=>Ye,Player:()=>me,StepBuilder:()=>Qe,SvgScene:()=>Ee,buildBoat:()=>dt,buildCrane:()=>rt,buildEnvelope:()=>ct,buildFox:()=>Et,buildFrog:()=>gt,buildHeart:()=>At,buildPlane:()=>st,buildPleat:()=>lt,buildSwan:()=>bt,buildWhale:()=>St,defaultCamera:()=>Ne,defaultPose:()=>ce,defineOrigamiLoader:()=>Rt,eases:()=>V,getModel:()=>Ft,listModels:()=>ar,paintOrder:()=>ro,paperTexture:()=>Ct,registerModel:()=>sr});var J=Math.PI/180,ke=()=>[1,0,0,0,0,1,0,0,0,0,1,0];function Q(e,t){let r=new Array(12);for(let o=0;o<12;o+=4){let i=e[o],a=e[o+1],s=e[o+2];r[o]=i*t[0]+a*t[4]+s*t[8],r[o+1]=i*t[1]+a*t[5]+s*t[9],r[o+2]=i*t[2]+a*t[6]+s*t[10],r[o+3]=i*t[3]+a*t[7]+s*t[11]+e[o+3]}return r}function H(e,t,r,o){return[e[0]*t+e[1]*r+e[2]*o+e[3],e[4]*t+e[5]*r+e[6]*o+e[7],e[8]*t+e[9]*r+e[10]*o+e[11]]}function ne(e,t,r){let[o,i,a]=t,s=Math.cos(r),n=Math.sin(r),l=1-s,d=[l*o*o+s,l*o*i-n*a,l*o*a+n*i,0,l*o*i+n*a,l*i*i+s,l*i*a-n*o,0,l*o*a-n*i,l*i*a+n*o,l*a*a+s,0];for(let u=0;u<12;u+=4)d[u+3]=e[u/4]-(d[u]*e[0]+d[u+1]*e[1]+d[u+2]*e[2]);return d}var uo=e=>ne([0,0,0],[1,0,0],e),ho=e=>ne([0,0,0],[0,1,0],e),Dt=e=>ne([0,0,0],[0,0,1],e),he=(e,t,r)=>[1,0,0,e,0,1,0,t,0,0,1,r],fo=e=>[e,0,0,0,0,e,0,0,0,0,e,0],ae=(e,t=0,r=1)=>e<t?t:e>r?r:e,Qt=(e,t,r)=>e+(t-e)*r,se=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],Ie=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]];function Ce(e){let t=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/t,e[1]/t,e[2]/t]}var U=(e,t,r)=>(t[0]-e[0])*(r[1]-e[1])-(t[1]-e[1])*(r[0]-e[0]);function po(e,t,r,o){let i=[t[0]-e[0],t[1]-e[1]],a=[o[0]-r[0],o[1]-r[1]],s=i[0]*a[1]-i[1]*a[0];if(Math.abs(s)<1e-12)return;let n=((r[0]-e[0])*a[1]-(r[1]-e[1])*a[0])/s;return[e[0]+i[0]*n,e[1]+i[1]*n]}function le(e){let t=0;for(let r=0;r<e.length;r++){let o=e[r],i=e[(r+1)%e.length];t+=o[0]*i[1]-i[0]*o[1]}return t/2}function Re(e){let t=0,r=0,o=0;for(let i=0;i<e.length;i++){let a=e[i],s=e[(i+1)%e.length],n=a[0]*s[1]-s[0]*a[1];t+=n,r+=(a[0]+s[0])*n,o+=(a[1]+s[1])*n}if(Math.abs(t)<1e-14){for(let i of e)r+=i[0],o+=i[1];return[r/e.length,o/e.length]}return[r/(3*t),o/(3*t)]}var fe=e=>le(e)<0?e.slice().reverse():e;function mo(e,t,r,o=1e-9){let i=Math.hypot(r[0]-t[0],r[1]-t[1]),a=e.map(d=>U(t,r,d)/i);if(!a.some(d=>d<-o))return{left:e,right:null,chord:null};if(!a.some(d=>d>o))return{left:null,right:e,chord:null};let s=[],n=[],l=[];for(let d=0;d<e.length;d++){let u=(d+1)%e.length,p=e[d],b=e[u],m=a[d],f=a[u];if(m>=-o&&s.push(p),m<=o&&n.push(p),Math.abs(m)<=o&&l.push(p),m>o&&f<-o||m<-o&&f>o){let g=m/(m-f),c=[p[0]+(b[0]-p[0])*g,p[1]+(b[1]-p[1])*g];s.push(c),n.push(c),l.push(c)}}return{left:s,right:n,chord:l.length>=2?[l[0],l[1]]:null}}function Ke(e,t){let r=e;for(let o=0;o<t.length&&r.length;o++){let i=t[o],a=t[(o+1)%t.length],s=r;r=[];for(let n=0;n<s.length;n++){let l=s[n],d=s[(n+1)%s.length],u=U(i,a,l),p=U(i,a,d);if(u>=0&&r.push(l),u>=0!=p>=0){let b=u/(u-p);r.push([l[0]+(d[0]-l[0])*b,l[1]+(d[1]-l[1])*b])}}}return r}function go(e){let t=e.slice().sort((i,a)=>i[0]-a[0]||i[1]-a[1]);if(t.length<3)return t;let r=[],o=[];for(let i of t){for(;r.length>=2&&U(r[r.length-2],r[r.length-1],i)<=0;)r.pop();r.push(i)}for(let i=t.length-1;i>=0;i--){let a=t[i];for(;o.length>=2&&U(o[o.length-2],o[o.length-1],a)<=0;)o.pop();o.push(a)}return r.slice(0,-1).concat(o.slice(0,-1))}function Ze(e,t,r,o){let i=3*e,a=3*(r-e)-i,s=1-i-a,n=3*t,l=3*(o-t)-n,d=1-n-l,u=m=>((s*m+a)*m+i)*m,p=m=>((d*m+l)*m+n)*m,b=m=>(3*s*m+2*a)*m+i;return m=>{if(m<=0)return 0;if(m>=1)return 1;let f=m;for(let g=0;g<8;g++){let c=u(f)-m,A=b(f);if(Math.abs(c)<1e-7||Math.abs(A)<1e-7)break;f-=c/A}if(f<0||f>1||Math.abs(u(f)-m)>1e-5){let g=0,c=1;for(let A=0;A<30;A++)f=(g+c)/2,u(f)<m?g=f:c=f}return p(f)}}var V={linear:e=>e,in:Ze(.55,.055,.675,.19),out:Ze(.23,1,.32,1),inOut:Ze(.645,.045,.355,1),fold:Ze(.77,0,.175,1),drop:e=>1-Math.exp(-7.5*e)*Math.cos(8.5*e)*(1-e),flap:e=>Math.sin(e*Math.PI*4)*(1-e*.6),breathe:e=>(1-Math.cos(2*Math.PI*Math.min(1,Math.max(0,e))))/2},ce={rx:0,ry:0,rz:0,spin:0,tx:0,ty:0,tz:0,s:1,o:1},Ut=Object.keys(ce);var je=.0015,pe=41,bo=.9;function Xe(e,t,r){return e.rot?ne(e.p,e.u,e.free>=0?r:e.script?e.script(t):e.angle*t):he(e.u[0]*t,e.u[1]*t,e.u[2]*t)}function Vr(e){let t=[e[0],e[4],e[8],0,e[1],e[5],e[9],0,e[2],e[6],e[10],0];return t[3]=-(t[0]*e[3]+t[1]*e[7]+t[2]*e[11]),t[7]=-(t[4]*e[3]+t[5]*e[7]+t[6]*e[11]),t[11]=-(t[8]*e[3]+t[9]*e[7]+t[10]*e[11]),t}var De=e=>Math.abs(e[10])>1-1e-6&&Math.abs(e[11])<1e-5;function Tr(e){if(Math.abs(e[10])<1-1e-4||Math.abs(e[11])>.001)return e;let t=e[10]>0?1:-1,r=Math.atan2(e[4],e[0]),o=Math.cos(r),i=Math.sin(r);for(let a of[0,1,-1])Math.abs(o-a)<1e-12&&(o=a),Math.abs(i-a)<1e-12&&(i=a);return[o,-t*i,0,e[3],i,t*o,0,e[7],0,0,t,0]}function $e(e,t){let r=Math.min(1,Math.max(0,t))*(e.length-1),o=Math.min(e.length-2,Math.floor(r));return e[o]+(e[o+1]-e[o])*(r-o)}function Lr(e,t){let r=t.length,o=e.map((i,a)=>[...i,t[a]]);for(let i=0;i<r;i++){let a=i;for(let n=i+1;n<r;n++)Math.abs(o[n][i])>Math.abs(o[a][i])&&(a=n);[o[i],o[a]]=[o[a],o[i]];let s=o[i][i]||1e-18;for(let n=0;n<r;n++){if(n===i)continue;let l=o[n][i]/s;for(let d=i;d<=r;d++)o[n][d]-=l*o[i][d]}}return o.map((i,a)=>i[r]/(i[a]||1e-18))}function Or(e,t){let r=e.slice(),o=t(r),i=o.reduce((s,n)=>s+n*n,0),a=r.length;for(let s=0;s<60&&i>1e-24;s++){let n=[];for(let f=0;f<a;f++){let g=r.slice();g[f]+=1e-7,n.push(t(g).map((c,A)=>(c-o[A])/1e-7))}let l=n.map(f=>n.map(g=>f.reduce((c,A,w)=>c+A*g[w],0))),d=n.map(f=>-f.reduce((g,c,A)=>g+c*o[A],0)),u=1e-10+1e-8*Math.max(...l.map((f,g)=>f[g]));l.forEach((f,g)=>f[g]+=u);let p=Lr(l,d),b=1,m=!1;for(let f=0;f<12;f++){let g=r.map((w,y)=>w+b*p[y]),c=t(g),A=c.reduce((w,y)=>w+y*y,0);if(A<i){r=g,o=c,i=A,m=!0;break}b/=2}if(!m)break}return r}var R=class{constructor(t={},r=[[-1,-1],[1,-1],[1,1],[-1,1]]){this.steps=[];this.chords=[];this.nextId=1;this.pose={...ce,...t},this.faces=[{id:0,poly:fe(r),T:ke(),level:0,rank:0,hist:[]}]}step(t,r){let o=new Qe(this,t);return r?.(o),o.finish(),this}compile(t={}){let r=[],o=new Map,i=f=>{let g=`${Math.round(f[0]*1e7)},${Math.round(f[1]*1e7)}`,c=o.get(g);return c===void 0&&(c=r.length,r.push(f),o.set(g,c)),c},a=this.faces.map(f=>{let g=fe(f.poly).map(i);return g.filter((c,A)=>c!==g[(A+1)%g.length])});a=a.map(f=>{let g=[];for(let c=0;c<f.length;c++){let A=f[c],w=f[(c+1)%f.length];g.push(A);let y=r[A],h=r[w],x=h[0]-y[0],v=h[1]-y[1],M=x*x+v*v,S=[];for(let E=0;E<r.length;E++){if(E===A||E===w)continue;let B=r[E],F=((B[0]-y[0])*x+(B[1]-y[1])*v)/M;F<=1e-9||F>=1-1e-9||Math.abs(U(y,h,B))/Math.sqrt(M)<1e-7&&S.push([F,E])}S.sort((E,B)=>E[0]-B[0]);for(let[,E]of S)g.push(E)}return g});let s=[],n=new Map,l=a.map((f,g)=>f.map((c,A)=>{let w=f[(A+1)%f.length],y=c<w?`${c}|${w}`:`${w}|${c}`,h=n.get(y);return h===void 0&&(h=s.length,n.set(y,h),s.push({a:c,b:w,faces:[],born:1/0})),s[h].faces.push(g),h})),d=(f,g)=>{let c=g.b[0]-g.a[0],A=g.b[1]-g.a[1],w=c*c+A*A,y=((f[0]-g.a[0])*c+(f[1]-g.a[1])*A)/w;return y>-1e-7&&y<1+1e-7&&Math.abs(U(g.a,g.b,f))/Math.sqrt(w)<1e-7};for(let f of s)if(!(f.faces.length<2))for(let g of this.chords)g.step<f.born&&d(r[f.a],g)&&d(r[f.b],g)&&(f.born=g.step);let u=[],p=0,b=0,m=0;for(let f of this.steps)u.push(p),f.phase==="intro"&&(b=p+f.duration),f.phase!=="outro"&&(m=p+f.duration),p+=f.duration;return{steps:this.steps,starts:u,duration:p,content:[b,m],pose:this.pose,verts:r,faces:a,tracks:this.faces.map(f=>f.hist),edges:s,faceEdges:l,colourDown:t.colourDown}}},Qe=class{constructor(t,r){this.F=t;this.meta=r;this.joints=[];this.chains=new Map;this.pins=[];this.layers=[];this.nFree=0}get index(){return this.F.steps.length}info(t){let r=Re(t.poly),o=H(t.T,r[0],r[1],0);return{sheet:r,model:[o[0],o[1]],flat:De(t.T),up:t.T[10]>0}}select(t){return this.F.faces.filter(r=>!t||t(this.info(r)))}split(t,r,o){let i=new Set(t),a=[],s=[];for(let n of this.F.faces){if(!i.has(n)){s.push(n);continue}if(!De(n.T)){s.push(n),a.push(n);continue}let l=Vr(n.T),d=H(l,r[0],r[1],0),u=H(l,o[0],o[1],0),{left:p,right:b,chord:m}=mo(n.poly,[d[0],d[1]],[u[0],u[1]]);if(!p||!b||Math.abs(le(p))<1e-10||Math.abs(le(b))<1e-10){s.push(n),a.push(n);continue}m&&this.F.chords.push({a:m[0],b:m[1],step:this.index});let f=this.chains.get(n);this.chains.delete(n);for(let g of[p,b]){let c={...n,id:this.F.nextId++,poly:g,hist:n.hist.slice()};f&&this.chains.set(c,f),s.push(c),a.push(c)}}return this.F.faces=s,a}rot(t,r,o,i={}){let a=[t[0],t[1],t[2]??0],s=[r[0],r[1],r[2]??0],n=-1;o==="free"&&(n=i.free??this.nFree,this.nFree=Math.max(this.nFree,n+1));let l=typeof o=="function"?d=>o(d)*J:void 0;return this.joints.push({rot:!0,p:a,u:Ce([s[0]-a[0],s[1]-a[1],s[2]-a[2]]),angle:typeof o=="number"?o*J:l?l(1):0,free:n,at:i.at??[0,1],ease:l?"linear":i.ease??"fold",script:l}),this.joints.length-1}hinge(t,r,o,i=1,a=180,s={}){return this.rot(t,r,a*i*Math.sign(U(t,r,o)),s)}swing(t,r,o={}){return this.rot([t[0],t[1],0],[t[0],t[1],1],r,o)}reverse(t,r,o){let[i,a]=r,s=this.split(t.filter(F=>De(F.T)),i,a),n=Math.sign(U(i,a,o.side)),l=s.filter(F=>Math.sign(U(i,a,this.info(F).model))===n),[d,u]=o.axis,p=po(d,u,i,a);if(!p)throw new Error("reverse: the axis runs parallel to the crease");let b=Math.atan2(u[1]-d[1],u[0]-d[0]),f=2*(Math.atan2(a[1]-i[1],a[0]-i[0])-b);f=Math.atan2(Math.sin(f),Math.cos(f))/J;let[g,c]=o.at??[0,1],A=F=>g+(c-g)*F,w=F=>o.front(this.info(F)),y=l.filter(w),h=l.filter(F=>!w(F)),x=l.length&&Math.sign(U(d,u,this.info(l[0]).model))||1,v=o.book?[[y,180*x],[h,-180*x]]:[[l,180]];this.restack=o.roll==="last"?[A(.6),c]:[g,A(.35)];for(let[F,k]of v)if(o.roll==="last"){let _=Math.cos(f*J),I=Math.sin(f*J),T=X=>[p[0]+_*(X[0]-p[0])-I*(X[1]-p[1]),p[1]+I*(X[0]-p[0])+_*(X[1]-p[1])],W=this.swing(p,f,{at:[g,A(.8)],ease:o.ease??"inOut"}),O=this.rot(T(d),T(u),k,{at:[A(.6),c],ease:"inOut"});this.attach(F,W,O)}else{let _=this.rot(d,u,k,{at:[g,A(.35)],ease:"inOut"}),I=this.swing(p,f,{at:[A(.2),c],ease:o.ease??"inOut"});this.attach(F,_,I)}let M=new Set(l),S=this.F.faces.filter(F=>!M.has(F)),E=S.filter(w),B=S.filter(F=>!w(F));return o.kind==="inside"?(this.layer(E,[...y,...h]),this.layer(y,h),this.layer([...y,...h],B)):(this.layer(y,S),this.layer(S,h),this.layer(y,h)),l}move(t,r={}){return this.joints.push({rot:!1,p:[0,0,0],u:t,angle:0,free:-1,at:r.at??[0,1],ease:r.ease??"fold"}),this.joints.length-1}fold(t,r,o){let i=this.split(this.select(o.where).filter(n=>De(n.T)),t,r),a=Math.sign(U(t,r,o.side)),s=i.filter(n=>Math.sign(U(t,r,this.info(n).model))===a);return this.attach(s,this.hinge(t,r,o.side,o.toward??1,o.deg??180,o)),s}attach(t,...r){for(let o of t)this.chains.set(o,[...this.chains.get(o)??[],...r])}pin(t,r,o){this.pins.push({a:t,b:r,pt:o})}layer(t,r){this.layers.push({above:t,below:r})}compose(t,r,o,i=!1){let a=ke();for(let s of t){let n=this.joints[s],l=i&&this.nFree===0?V[n.ease](r):r;a=Q(Xe(n,l,o[n.free]??0),a)}return a}place(t,r,o,i=!1){let a=this.chains.get(t);return a?Q(this.compose(a,r,o,i),t.T):t.T}solve(){if(!this.nFree)return[];let t=Array.from({length:this.nFree},()=>new Float64Array(pe)),r=new Array(this.nFree).fill(0);for(let o=0;o<pe;o++){let i=o/(pe-1);r=Or(r,a=>{let s=[];for(let{a:n,b:l,pt:d}of this.pins){let u=H(this.place(n,i,a),d[0],d[1],0),p=H(this.place(l,i,a),d[0],d[1],0);s.push(u[0]-p[0],u[1]-p[1],u[2]-p[2])}return s}),r.forEach((a,s)=>t[s][o]=a)}for(let o of t){let i=Math.round(o[pe-1]/(Math.PI/2))*(Math.PI/2);Math.abs(o[pe-1]-i)<.001&&(o[pe-1]=i)}return t}finish(){let t=this.F,r=this.solve(),o=h=>r.map(x=>$e(x,h)),i=o(1),a=o(bo),s=new Map(t.faces.map(h=>[h,Tr(this.place(h,1,i,!0))])),n=[];for(let h of t.faces){let x=s.get(h);if(!De(x))continue;let v=fe(h.poly.map(B=>{let F=H(x,B[0],B[1],0);return[F[0],F[1]]})),M=[1/0,1/0,-1/0,-1/0];for(let[B,F]of v)M[0]=Math.min(M[0],B),M[1]=Math.min(M[1],F),M[2]=Math.max(M[2],B),M[3]=Math.max(M[3],F);let S=this.chains.get(h),E=Q(he(0,0,h.rank*1e-7),h.T);n.push({f:h,poly:v,box:M,moved:!!S,Tn:S?Q(this.compose(S,bo,a,!0),E):E})}let l=new Map;for(let{above:h,below:x}of this.layers)for(let v of h)for(let M of x)l.set(`${v.id}|${M.id}`,1),l.set(`${M.id}|${v.id}`,-1);let d=(h,x)=>{let v=h[10];return Math.abs(v)<.001?h[11]:h[11]-(h[2]*(x[0]-h[3])+h[6]*(x[1]-h[7]))/v},u=n.length,p=n.map(()=>[]),b=n.map(()=>[]),m=new Int32Array(u);for(let h=0;h<u;h++){let x=n[h];for(let v=h+1;v<u;v++){let M=n[v];if(x.box[2]<=M.box[0]+1e-9||M.box[2]<=x.box[0]+1e-9||x.box[3]<=M.box[1]+1e-9||M.box[3]<=x.box[1]+1e-9)continue;let S=Ke(x.poly,M.poly);if(S.length<3||Math.abs(le(S))<1e-8)continue;let E=l.get(`${x.f.id}|${M.f.id}`);if(E===void 0)if(!x.moved&&!M.moved)E=x.f.rank>M.f.rank||x.f.rank===M.f.rank&&x.f.id>M.f.id?1:-1;else{let k=Re(S);E=d(x.Tn,k)>d(M.Tn,k)?1:-1}let[B,F]=E>0?[v,h]:[h,v];p[B].push(F),b[F].push(B),m[F]++}}let f=[],g=new Uint8Array(u);for(let h=0;h<u;h++){let x=-1;for(let v=0;v<u;v++)g[v]||m[v]>0||(x<0||n[v].f.rank<n[x].f.rank||n[v].f.rank===n[x].f.rank&&n[v].f.id<n[x].f.id)&&(x=v);if(x<0)for(let v=0;v<u;v++)!g[v]&&(x<0||n[v].f.rank<n[x].f.rank)&&(x=v);g[x]=1,f.push(x);for(let v of p[x])m[v]--}let c=new Int32Array(u),A=new Int32Array(u);f.forEach((h,x)=>A[h]=x);for(let h of f)for(let x of b[h])A[x]<A[h]&&(c[h]=Math.max(c[h],c[x]+1));let w=new Map,y=new Map;f.forEach((h,x)=>{w.set(n[h].f,c[h]),y.set(n[h].f,x)});for(let h of t.faces){let x=w.get(h)??h.level;h.hist.push({T:h.T,chain:this.chains.get(h)??[],z0:h.level*je,z1:x*je}),h.T=s.get(h),h.level=x,h.rank=y.get(h)??h.rank}t.steps.push({...this.meta,joints:this.joints,table:r,restack:this.restack})}};var et=e=>Math.abs(e[10])>1-1e-6,me=class{constructor(t){this.model=t;let r=t.faces.length;this.anchors=t.steps.map(()=>new Array(r)),this.endsFlat=t.steps.map(()=>new Uint8Array(r));for(let o=0;o<r;o++){let i=t.tracks[o][0].T;t.steps.forEach((a,s)=>{let n=t.tracks[o][s];et(n.T)&&(i=n.T),this.anchors[s][o]=i;let d=t.tracks[o][s+1]?.T;if(!d){d=n.T;for(let u of n.chain)d=Q(Xe(a.joints[u],1,a.table.length?$e(a.table[a.joints[u].free]??new Float64Array(2),1):0),d)}this.endsFlat[s][o]=et(d)?1:0})}this.groupIds=t.steps.map((o,i)=>{let a=new Map;return Int32Array.from(t.tracks.map(s=>{let n=s[i].chain.join(","),l=a.get(n);return l===void 0&&(l=a.size,a.set(n,l)),l}))})}get duration(){return this.model.duration}stepAt(t){let r=this.model.starts,o=0;for(;o<r.length-1&&r[o+1]<=t;)o++;return o}evaluate(t,r){let o=this.model,i=o.faces.length,a=r??{T:new Array(i),z:new Float64Array(i),lift:new Float64Array(3*i),group:new Int32Array(i),pose:{...ce},step:0,local:0};t=ae(t,0,o.duration);let s=this.stepAt(t),n=o.steps[s],l=n.duration>0?ae((t-o.starts[s])/n.duration):1,d=V[n.ease??"fold"](l),u=n.table.length>0,p=n.table.map(h=>$e(h,d)),b=n.joints.map(h=>{let x=u?d:V[h.ease](ae((l-h.at[0])/Math.max(1e-6,h.at[1]-h.at[0])));return Xe(h,x,p[h.free]??0)}),m=new Map,[f,g]=n.restack??[0,1],c=V.inOut(ae((l-f)/Math.max(1e-6,g-f)));for(let h=0;h<i;h++){let x=o.tracks[h][s];if(x.chain.length){let v=x.chain.join(","),M=m.get(v);if(!M){M=ke();for(let S of x.chain)M=Q(b[S],M);m.set(v,M)}a.T[h]=Q(M,x.T)}else a.T[h]=x.T;a.z[h]=Qt(x.z0,x.z1,c),this.lift(a,h,s,x.chain.length>0)}a.group.set(this.groupIds[s]);let A=V[n.ease??"inOut"](l),w=Math.sin(Math.PI*l),y=this.poseAt(s);for(let h of Ut){let x=n.pose?.[h];a.pose[h]=(x===void 0?y[h]:Qt(y[h],x,A))+(n.arc?.[h]??0)*w}if(n.path){let h=n.path(l);for(let x of Ut)a.pose[x]+=h[x]??0}return a.step=s,a.local=l,a}lift(t,r,o,i){let a=this.model.tracks[r][o],s=t.T[r],n=t.lift,l=3*r,d=et(a.T)&&this.endsFlat[o][r];if(!i&&et(s)||i&&d){n[l]=0,n[l+1]=0,n[l+2]=t.z[r];return}let u=this.anchors[o][r],p=u[8],b=u[9],m=u[10],f=s[0]*p+s[1]*b+s[2]*m,g=s[4]*p+s[5]*b+s[6]*m,c=s[8]*p+s[9]*b+s[10]*m,A=Math.min(1,Math.max(0,(.3-c)/.2)),w=t.z[r];n[l]=A*a.z0*f,n[l+1]=A*a.z0*g,n[l+2]=(1-A)*w+A*a.z0*c}poseAt(t){if(!this.poses){let r={...this.model.pose};this.poses=this.model.steps.map(o=>{let i=r;return r={...r,...o.pose},i})}return this.poses[t]}};var te=Math.SQRT1_2,Ao=[0,te],C=[0,-te],xo=[te,0],vo=[-te,0],Nt=1-te,G=[Math.SQRT2-1,Nt],Z=[1-Math.SQRT2,Nt],Fo=e=>[e*Math.sin(Math.PI/16),-te+Math.cos(Math.PI/16)],Ot=Fo(1),Gr=Fo(-1),wo=(()=>{let e=[0,2-te],t=[Ot[0]-C[0],Ot[1]-C[1]],r=[e[0]-G[0],e[1]-G[1]],o=t[0]*r[1]-t[1]*r[0],i=((G[0]-C[0])*r[1]-(G[1]-C[1])*r[0])/o;return C[1]+t[1]*i})(),tt=.263,yo=9*Math.PI/180,Mo=.26,zr=-55*Math.PI/180;function Po(e,[t,r]){let o=[r[0]-t[0],r[1]-t[1]],i=((e[0]-t[0])*o[0]+(e[1]-t[1])*o[1])/(o[0]*o[0]+o[1]*o[1]);return[2*(t[0]+o[0]*i)-e[0],2*(t[1]+o[1]*i)-e[1]]}var Gt=([e,t])=>e>0&&t>0,Nr=([e,t])=>e<0&&t>0,_r=([e,t])=>e>0&&t<0,zt=([e,t])=>e<0&&t<0,ot=([e,t])=>t>Math.abs(e),Ue=([e,t])=>e>Math.abs(t),_t=([e,t])=>t<-Math.abs(e),Wt=([e,t])=>e<-Math.abs(t),So=e=>e>0?ot:Wt,Eo=e=>e>0?Ue:_t,Vt=e=>e>0?Gt:zt,Wr=e=>e>0?t=>ot(t)&&t[0]<0:t=>Wt(t)&&t[1]>0,Hr=e=>e>0?t=>Ue(t)&&t[1]<0:t=>_t(t)&&t[0]>0,Tt=e=>e>0?[0,1]:[-1,0],Lt=e=>e>0?[1,0]:[0,-1],ee=e=>t=>e(t.sheet),ge=(e,t,r)=>(t[0]-e[0])*(r[1]-e[1])-(t[1]-e[1])*(r[0]-e[0])>0;function be(e,t){let r=e.find(o=>o.poly.some(i=>Math.hypot(i[0]-t[0],i[1]-t[1])<1e-7));if(!r)throw new Error(`crane: no face holds sheet point ${t}`);return r}function rt(){let e=new R({rx:-30,ry:12,ty:.7,tz:.5,o:0}),t=(c,A,w,y,h,x,v={})=>{let M=[];e.step({diagram:c,label:A,duration:.7,...v},S=>{M=S.fold(w,y,{side:h,toward:x,at:[.06,1]})}),e.step({diagram:c,label:"Unfold",duration:.42,ease:"inOut"},S=>{S.attach(M,S.hinge(w,y,h,-x,180,{ease:"inOut"}))})};e.step({diagram:1,label:"Start with a square",duration:1.1,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}}),t(2,"Fold in half diagonally",[-1,1],[1,-1],[1,1],1),t(2,"Fold the other diagonal",[-1,-1],[1,1],[1,-1],1),e.step({diagram:3,label:"Turn the paper over",duration:.8,ease:"inOut",pose:{ry:192},arc:{tz:.35}}),t(3,"Fold in half",[0,-1],[0,1],[-.5,0],-1),t(3,"Fold in half the other way",[-1,0],[1,0],[0,.5],-1),e.step({diagram:4,label:"Collapse into a square base",duration:1.4,ease:"inOut",pose:{s:1.22}},c=>{let A=[0,0],w=c.hinge(A,[0,1],[-.3,.8],-1),y=c.rot(A,[-1,1],"free",{free:0}),h=c.hinge(A,[-1,0],[-.8,-.3],-1),x=c.hinge(A,[0,-1],[.3,-.8],-1),v=c.rot(A,[1,-1],"free",{free:0}),M=c.rot([0,0,0],[0,0,1],-135),S=c.move([0,te,0]),E=k=>c.select(ee(k)),B=E(k=>Ue(k)&&k[1]>0),F=E(k=>Ue(k)&&k[1]<0);c.attach(E(Gt),M,S),c.attach(E(k=>ot(k)&&k[0]<0),w,M,S),c.attach(E(k=>Wt(k)&&k[1]>0),y,w,M,S),c.attach(E(zt),h,y,w,M,S),c.attach(E(k=>_t(k)&&k[0]>0),x,h,y,w,M,S),c.attach(F,v,x,h,y,w,M,S),c.pin(be(F,[1,0]),be(B,[1,0]),[1,0])});let r=(c,A)=>{let w=A?.8:1,y=[],h=[],x=[];e.step({diagram:5,label:A?"Repeat: edges to the centre":"Fold the edges to the centre",duration:.95*w},v=>{y=v.fold(C,G,{where:ee(So(c)),side:xo,toward:c,at:[0,.72]}),h=v.fold(C,Z,{where:ee(Eo(c)),side:vo,toward:c,at:[.28,1]})}),e.step({diagram:6,label:A?"Fold the top down":"Fold the top triangle down",duration:.65*w},v=>{x=v.fold(Z,G,{side:Ao,toward:c})}),e.step({diagram:6,label:"Unfold the last three folds",duration:.8*w,ease:"inOut"},v=>{v.attach(x,v.hinge(Z,G,Ao,-c,180,{at:[0,.6],ease:"inOut"})),v.attach(y,v.hinge(C,G,xo,-c,180,{at:[.3,1],ease:"inOut"})),v.attach(h,v.hinge(C,Z,vo,-c,180,{at:[.3,1],ease:"inOut"}))}),e.step({diagram:7,label:A?"Petal fold the back":"Petal fold: lift the bottom point",duration:1.3*w,ease:"inOut",pose:{s:1.2,ty:-.33}},v=>{let M=(L,qe)=>v.select(ie=>L(ie.sheet)&&ie.model[1]<Nt&&qe(ie.model)),S=L=>ge(C,G,L)&&!ge(C,Z,L),E=M(Vt(c),S),B=M(Vt(c),L=>!ge(C,G,L)),F=M(Vt(c),L=>ge(C,Z,L)),k=M(Wr(c),L=>!ge(C,G,L)),_=M(Hr(c),L=>ge(C,Z,L)),I=v.hinge(Z,G,C,c),T=v.rot(C,G,"free"),W=v.rot(C,Z,"free"),O=v.rot(C,G,"free"),X=v.rot(C,Z,"free");v.attach(E,I),v.attach(B,T,I),v.attach(F,W,I),v.attach(k,O),v.attach(_,X),v.pin(be(B,Tt(c)),be(k,Tt(c)),Tt(c)),v.pin(be(F,Lt(c)),be(_,Lt(c)),Lt(c))})};r(-1,!1),e.step({diagram:7,label:"Turn over",duration:.8,ease:"inOut",pose:{ry:372},arc:{tz:.3}}),r(1,!0);let o=(c,A,w)=>e.step({diagram:A,label:w,duration:1,ease:"inOut",pose:{s:1.3,ty:-.36}},y=>{y.fold(C,Ot,{where:ee(So(c)),side:[.35,.1],toward:c,at:[0,.7]}),y.fold(C,Gr,{where:ee(Eo(c)),side:[-.35,.1],toward:c,at:[.3,1]})});o(1,8,"Narrow the legs"),e.step({diagram:9,label:"Turn over",duration:.8,ease:"inOut",pose:{ry:552},arc:{tz:.3}}),o(-1,9,"Narrow the other side");let i=ee(c=>ot(c)||Ue(c)),a=c=>[C,[c*.097,tt]],s=c=>[[0,tt],[c*Math.cos(yo),tt-Math.sin(yo)]],n=(c,A,w,y)=>{let h=[];return e.step({diagram:c,label:A,duration:1,ease:"inOut",pose:{s:1.45,ty:-.95}},x=>{h=x.reverse(x.select(v=>w(v.sheet)&&v.flat&&v.model[1]<tt),s(y),{side:C,axis:a(y),front:i,kind:"inside"})}),()=>h},l=n(10,"Reverse fold the neck up",Nr,1);n(11,"Reverse fold the tail up",_r,-1);let d=Po(C,s(1)),u=Po(a(1)[1],s(1)),p=[],b=[],m=[-1,wo],f=[1,wo],g=[0,1.2];return e.step({diagram:12,label:"Fold the wings down",duration:.9,ease:"inOut",pose:{s:1.55,ty:-.8}},c=>{p=c.fold(m,f,{where:ee(A=>Gt(A)&&A[0]+A[1]>2-Math.SQRT2),side:g,toward:1,at:[0,.7]}),b=c.fold(m,f,{where:ee(A=>zt(A)&&A[0]+A[1]<Math.SQRT2-2),side:g,toward:-1,at:[.3,1]})}),e.step({diagram:13,label:"Reverse fold the head",duration:.8,ease:"inOut"},c=>{let A=d[0]-u[0],w=d[1]-u[1],y=Math.hypot(A,w),h=Math.atan2(w,A),x=[d[0]-A/y*Mo,d[1]-w/y*Mo],v=(h+zr)/2,M=[x,[x[0]+Math.cos(v),x[1]+Math.sin(v)]];c.reverse(l(),M,{side:d,axis:[u,d],front:i,kind:"inside"})}),e.step({diagram:14,label:"Spread the wings",duration:1.5,ease:"inOut",pose:{ry:585,rx:-14,s:1.7,ty:-.9}},c=>{c.attach(p,c.hinge(m,f,g,-1,95,{ease:"inOut"})),c.attach(b,c.hinge(m,f,g,1,95,{ease:"inOut"}))}),e.step({diagram:14,label:"Finished crane",duration:.9,ease:"inOut"}),e.step({diagram:14,label:"Fly",duration:1,phase:"outro",ease:"in",pose:{ty:.7,tx:-.6,tz:.8,s:1.5,o:0}},c=>{c.attach(p,c.hinge(m,f,g,1,28,{ease:"flap"})),c.attach(b,c.hinge(m,f,g,-1,28,{ease:"flap"}))}),e.compile()}var z=Math.SQRT1_2,oe=[0,1],Io=Math.tan(Math.PI/8),Yr=Math.tan(Math.PI/16),qr=[-z,1-z/Io],Jr=[z,1-z/Io],it=[-2*Yr,-1],nt=.62,Bo=.42,ko=50*Math.PI/180,at=[Math.cos(ko),Math.sin(ko)],re=[-at[1],at[0]];function Kr(e){if(e<nt){let r=2*Math.PI*V.inOut(e/nt),o=Math.cos(r),i=Math.sin(r),a=[re[0]*o-re[1]*i,re[0]*i+re[1]*o],s=(1-o)/2;return{tx:Bo*(re[0]-a[0]-re[0]*s),ty:Bo*(re[1]-a[1]-re[1]*s),spin:r*180/Math.PI,rz:14*Math.sin(r)}}let t=V.in((e-nt)/(1-nt));return{tx:2.6*t*at[0],ty:2.6*t*at[1],spin:360,s:-.35*t,o:-t}}function st(){let e=new R({rx:-30,ry:12,ty:.7,tz:.5,o:0},[[-z,-1],[z,-1],[z,1],[-z,1]]);e.step({diagram:1,label:"Start with a sheet of paper",duration:1,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}});let t=[];e.step({diagram:2,label:"Fold in half lengthwise",duration:.65},i=>{t=i.fold([0,-1],[0,1],{side:[.3,0],toward:1,at:[.06,1]})}),e.step({diagram:2,label:"Unfold",duration:.4,ease:"inOut"},i=>{i.attach(t,i.hinge([0,-1],[0,1],[.3,0],-1,180,{ease:"inOut"}))}),e.step({diagram:3,label:"Fold the top corners to the centre",duration:.95},i=>{i.fold(oe,[-z,1-z],{side:[-z+.05,.98],toward:1,at:[0,.7]}),i.fold(oe,[z,1-z],{side:[z-.05,.98],toward:1,at:[.3,1]})}),e.step({diagram:4,label:"Fold the edges to the centre again",duration:.95,pose:{s:1.05}},i=>{i.fold(oe,qr,{side:[-.65,.2],toward:1,at:[0,.7]}),i.fold(oe,Jr,{side:[.65,.2],toward:1,at:[.3,1]})}),e.step({diagram:5,label:"Fold the plane in half",duration:1,ease:"inOut",pose:{rz:-90,s:1.25,ty:-.3,tx:0}},i=>{i.fold([0,-1],[0,1],{side:[.3,0],toward:-1})});let r=[],o=[];return e.step({diagram:6,label:"Fold the wings down",duration:1,ease:"inOut"},i=>{r=i.fold(oe,it,{where:a=>a.sheet[0]<0,side:[-.6,-.8],toward:1,at:[0,.65]}),o=i.fold(oe,it,{where:a=>a.sheet[0]>0,side:[-.6,-.8],toward:-1,at:[.35,1]})}),e.step({diagram:7,label:"Open the wings",duration:1.3,ease:"inOut",pose:{rx:-30,ry:90,rz:0,spin:-40,s:1.25,ty:0,tx:0}},i=>{i.attach(r,i.hinge(oe,it,[-.6,-.8],-1,82,{ease:"inOut"})),i.attach(o,i.hinge(oe,it,[-.6,-.8],1,82,{ease:"inOut"}))}),e.step({diagram:7,label:"Ready to fly",duration:.6,ease:"inOut"}),e.step({diagram:7,label:"Fly",duration:2.1,phase:"outro",ease:"linear",path:Kr}),e.compile({colourDown:!0})}var Ve=5,Ht=2/Ve,de=(Ve-1)/2,Zr=84,jr=6,Co=e=>[[-1+e*Ht,-1],[-1+e*Ht,1]];function lt(){let e=new R({rx:-42,ry:28,ty:.55,tz:.4,o:0});e.step({diagram:1,label:"Start with a square",duration:.6,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1}}),e.step({diagram:2,label:"Crease the pleats",duration:.01},t=>{for(let r=1;r<Ve;r++)t.split(t.select(),...Co(r))});for(let t=0;t<jr;t++)e.step({diagram:2,label:"Pleat",duration:1.45,ease:"breathe"},r=>{let o=[];for(let a=1;a<Ve;a++){let[s,n]=Co(a),l=a>de?1:-1,d=[s[0]+.1*l,0],u=.16*Math.abs(a-(de+.5))/de;o[a]=r.hinge(s,n,d,a%2?1:-1,Zr,{at:[u,.84+u],ease:"breathe"})}let i=a=>r.select(s=>Math.floor((s.sheet[0]+1)/Ht)===a);for(let a=0;a<Ve;a++){if(a===de)continue;let s=[];if(a>de)for(let n=a;n>de;n--)s.push(o[n]);else for(let n=a+1;n<=de;n++)s.push(o[n]);r.attach(i(a),...s)}});return e.step({diagram:2,label:"Done",duration:.5,phase:"outro",ease:"in",pose:{o:0,s:.92}}),e.compile()}var Xr=[{label:"Fold the top corner down",line:[[1,0],[0,1]],corner:[1,1]},{label:"Fold the bottom corner up",line:[[-1,0],[0,-1]],corner:[-1,-1]},{label:"Fold the right corner in",line:[[0,-1],[1,0]],corner:[1,-1]},{label:"Fold the left corner in",line:[[0,1],[-1,0]],corner:[-1,1]}];function ct(){let e=new R({rx:-26,ry:8,rz:45,s:.92,ty:.55,tz:.4,o:0});return e.step({diagram:1,label:"Start with a square",duration:.7,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1}}),Xr.forEach(({label:t,line:r,corner:o},i)=>{let a=i===3?{s:1.3}:i===1?{s:1.08}:void 0;e.step({diagram:i+2,label:t,duration:.6,pose:a},s=>{s.fold(r[0],r[1],{side:o,toward:1,at:[.05,1]})})}),e.step({diagram:5,label:"Sealed",duration:.7,ease:"inOut",arc:{s:-.05}}),e.step({diagram:5,label:"Into the inbox",duration:.6,phase:"outro",ease:"in",pose:{ty:-.5,s:1,o:0}}),e.compile({colourDown:!0})}var $r=-.3,Ae=-.65,Ro=Ae-$r,ei=e=>({rz:3.5*Math.sin(e*Math.PI*4),ty:.025*Math.sin(e*Math.PI*4+1.2)});function dt(){let e=new R({rx:-24,ry:190,ty:.6,tz:.4,o:0});return e.step({diagram:1,label:"Start with a square",duration:.8,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}}),e.step({diagram:2,label:"Fold in half diagonally",duration:.8},t=>{t.fold([-1,-1],[1,1],{side:[-1,1],toward:-1,at:[.05,1]})}),e.step({diagram:3,label:"Fold the bottom up for the hull",duration:.8,pose:{s:1.1,ty:.12}},t=>{t.fold([-1,Ae],[1,Ae],{side:[0,-.9],toward:-1})}),e.step({diagram:4,label:"Fold the stern corner behind",duration:.7,pose:{s:1.2,ty:.18}},t=>{t.fold([1,Ae-Ro*.62],[1+Ro*.62,Ae],{side:[1,Ae],toward:1})}),e.step({diagram:5,label:"Afloat",duration:2.4,ease:"linear",path:ei}),e.step({diagram:5,label:"Sail away",duration:1,phase:"outro",ease:"in",pose:{tx:1.5,s:1.05,o:0},arc:{rz:-3}}),e.compile()}var D=e=>[e[0],e[1],e[2]??0],xe=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],ve=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],ti=(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]],ut=e=>{let t=Math.hypot(e[0],e[1],e[2]);return[e[0]/t,e[1]/t,e[2]/t]};function Y(e,t,r,o){let i=ne(D(e),ut(xe(D(t),D(e))),r*Math.PI/180);return H(i,o[0],o[1],o[2])}function Yt(e,t,r,o){let i=ut(xe(D(t),D(e))),a=l=>{let d=xe(l,D(e)),u=ve(d,i);return xe(d,[i[0]*u,i[1]*u,i[2]*u])},s=a(r),n=a(o);return Math.atan2(ve(i,ti(s,n)),ve(s,n))*180/Math.PI}function Do(e,t,r={}){let o=r.samples??181,i=r.window??30,a=r.step??.25,s=new Float64Array(o);s[0]=t;for(let n=1;n<o;n++){let l=n/(o-1),d=s[n-1],u=d,p=1/0;for(let b=-i;b<i;b+=a){let m=d+b,f=m+a,g=e(l,m),c=e(l,f);if(g===0||g*c<0){let A=m,w=f,y=g;for(let x=0;x<40;x++){let v=(A+w)/2,M=e(l,v);y*M<=0?w=v:(A=v,y=M)}let h=(A+w)/2;if(r.ok&&!r.ok(l,h))continue;Math.abs(h-d)<p&&(p=Math.abs(h-d),u=h)}}s[n]=u}return n=>{let l=Math.min(1,Math.max(0,n))*(o-1),d=Math.min(o-2,Math.floor(l));return s[d]+(s[d+1]-s[d])*(l-d)}}var j=.5,N=[0,.5],Jt=[-j,1],Kt=[j,1],ft=[j,0],pt=[-j,0],Zt=[-j,.5],jt=[j,.5],K=[0,0],qt=55,Qo=42,oi=25,Uo=e=>{let t=(270+oi)/2*Math.PI/180;return[-e*Math.cos(t),Math.sin(t)]},Vo=e=>[e*Math.sin(Math.PI/8),-Math.cos(Math.PI/8)],ht=.125;function ri([e,t]){if(t<0)return"body";let r=e-N[0],o=t-N[1];return o>Math.abs(r)?"top":o<-Math.abs(r)?"bottom":r<0?o>0?"upL":"lowL":o>0?"upR":"lowR"}var Te=(...e)=>t=>e.includes(ri(t.sheet)),zo=([e,t])=>[e,t>-.5?t:-1-t];function ii(e){let[t,r]=zo(e),o=Math.abs(t);return o<.25?r>-.25?"back":"rise":r>o-.5?"upper":r<-o?"lower":"middle"}var ni=e=>e[0]<0?-1:1,Le=e=>e.sheet[1]<0,we=(e,...t)=>r=>Le(r)&&t.includes(ii(r.sheet))&&(e===0||ni(r.sheet)===e),mt=e=>180*V.inOut(e),No=e=>{let t=mt(e);return t>=180-1e-9?180:2*Math.atan(Math.tan(t/2*Math.PI/180)/Math.SQRT2)*180/Math.PI},To=e=>t=>{let r=e<0?Jt:Kt,o=e<0?pt:ft,i=e<0?Zt:jt,a=e<0?-1:1,s=Y(N,[N[0]+1,N[1]],No(t),D(r)),n=Y(N,o,-a*mt(t),s);return Yt(N,i,D(r),n)},Lo=(e,t,r)=>Y(e,t,10,D(r))[2]>0?1:-1;function Oo(e){let t=[e*.25,-.25],r=[0,-.5],o=[e*.25,-.5],i=[-1,-.25],a=[1,-.25],s=Lo(i,a,r),n=Lo(t,K,r),l=w=>Y(i,a,s*180*w,D(o)),d=w=>Y(t,K,n*w,D(r)),u=w=>ut(xe(w,D(t))),p=u(D(r)),b=u(d(90)),m=w=>{let y=u(l(w)),h=ve(y,p),x=ve(y,b),v=Math.atan2(x,h);return v<-Math.PI/2&&(v+=2*Math.PI),(v+Math.acos(Math.min(1,Math.SQRT1_2/Math.hypot(h,x))))*180/Math.PI},f=181,g=new Float64Array(f);for(let w=1;w<f;w++){let y=w/(f-1),h=Y(i,a,-s*180*y,d(m(y))),x=Yt(t,o,D(r),h);for(;x-g[w-1]>180;)x-=360;for(;x-g[w-1]<-180;)x+=360;g[w]=x}let c=w=>{let y=Math.min(1,Math.max(0,w))*(f-1),h=Math.min(f-2,Math.floor(y));return g[h]+(g[h+1]-g[h])*(y-h)},A=V.inOut;return{rise:w=>s*180*A(w),mid:w=>n*m(A(w)),low:w=>c(A(w)),P:t,hinge:o}}var Go=e=>{let t=e<.18?Math.sin(e/.18*Math.PI):0,r=e>.18?Math.min(1,(e-.18)/.62):0,o=e>.8?Math.sin((e-.8)/.2*Math.PI):0;return{ty:.5*Math.sin(r*Math.PI)-.03*t,spin:-12*Math.sin(r*Math.PI),s:-.05*(t+o)}},ai=e=>({ty:.45*Math.abs(Math.sin(e*Math.PI*2)),tx:-1.3*e,o:-Math.max(0,(e-.35)/.65)});function gt(){let e=new R({rx:-28,s:.92,ty:.6,tz:.4,o:0},[[-j,-1],[j,-1],[j,1],[-j,1]]),t=(n,l,d,u,p,b)=>{let m=[];e.step({diagram:n,label:l,duration:.6},f=>{m=f.fold(d,u,{side:p,toward:b,at:[0,1]})}),e.step({diagram:n,label:"Unfold",duration:.38,ease:"inOut"},f=>{f.attach(m,f.hinge(d,u,p,-b,180,{ease:"inOut"}))})};e.step({diagram:3,label:"Start with a 1 : 2 rectangle",duration:.7,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}}),t(4,"Fold the corner to the far edge",Kt,pt,Jt,1),t(5,"And the other corner",Jt,ft,Kt,1),t(7,"Fold the top behind",Zt,jt,[0,.9],-1),e.step({diagram:9,label:"Collapse into a waterbomb base",duration:1.3,ease:"inOut",pose:{s:1.15,ty:-.25}},n=>{let l=n.rot(N,pt,f=>-mt(f)),d=n.rot(N,ft,f=>mt(f)),u=n.rot(N,[N[0]+1,N[1]],No),p=n.rot(N,Zt,To(-1)),b=n.rot(N,jt,To(1)),m=f=>n.select(Te(f));n.attach(m("lowL"),l),n.attach(m("upL"),p,l),n.attach(m("lowR"),d),n.attach(m("upR"),b,d),n.attach(m("top"),u),n.layer(m("top"),[...m("upL"),...m("upR")]),n.layer([...m("upL"),...m("upR")],[...m("lowL"),...m("lowR")]),n.layer([...m("lowL"),...m("lowR")],m("bottom"))});let r=[];e.step({diagram:10,label:"Fold the front legs up",duration:1,pose:{s:1.25}},n=>{r=[...n.fold(K,Uo(-1),{where:Te("top","upL"),side:pt,toward:1,at:[0,.7]}),...n.fold(K,Uo(1),{where:Te("top","upR"),side:ft,toward:1,at:[.3,1]})]}),e.step({diagram:12,label:"Fold the bottom up",duration:.8},n=>{n.fold([-1,-.5],[1,-.5],{where:Le,side:[0,-1],toward:1})}),e.step({diagram:13,label:"Fold the sides to the centre",duration:.9,pose:{s:1.3,ty:.05}},n=>{let l=n.fold([-.25,-1],[-.25,1],{where:Te("body","bottom","lowL"),side:[-.5,-.5],toward:1,at:[0,.7]}),d=n.fold([.25,-1],[.25,1],{where:Te("body","bottom","lowR"),side:[.5,-.5],toward:1,at:[.3,1]}),u=new Set(n.select());n.layer(r.filter(p=>u.has(p)),[...l,...d])}),e.step({diagram:17,label:"Squash the bottom flaps out",duration:1.5,ease:"inOut",pose:{s:1.4,ty:.15}},n=>{n.split(n.select(we(0,"back","rise")),[-1,-.25],[1,-.25]);for(let b of[-1,1]){let m=we(b,"upper","middle","lower");n.split(n.select(m),[b*.25,-.25],K),n.split(n.select(m),[b*.25,-.25],[0,-.5])}let l=(b,...m)=>n.select(we(b,...m)),[d,u]=[Oo(-1),Oo(1)],p=n.rot([-1,-.25],[1,-.25],d.rise);n.attach(l(0,"rise"),p);for(let[b,m]of[[-1,d],[1,u]])n.attach(l(b,"middle"),n.rot(m.P,K,m.mid)),n.attach(l(b,"lower"),n.rot(m.P,m.hinge,m.low),p);n.layer([...l(0,"rise"),...l(0,"lower")],l(0,"middle")),n.layer(l(0,"middle"),[...l(0,"upper"),...l(0,"back")]),n.layer(l(0,"rise"),[...l(0,"upper"),...l(0,"back")])});let o=n=>l=>{let[d,u]=zo(l.sheet);return-.5-u>-n*d},i=n=>l=>we(n,"middle","lower")(l)||we(0,"rise")(l)&&o(n)(l);e.step({diagram:18,label:"Fold the flaps down",duration:.9},n=>{for(let l of[-1,1])n.split(n.select(we(0,"rise")),[l*.25,-.25],K);n.fold([-.25,-.25],K,{where:i(-1),side:[-.4,-.05],toward:1,at:[0,.7]}),n.fold([.25,-.25],K,{where:i(1),side:[.4,-.05],toward:1,at:[.3,1]})}),e.step({diagram:19,label:"Fold the back legs out",duration:.9},n=>{n.fold(K,Vo(-1),{where:i(-1),side:[-.02,-.45],toward:1,at:[0,.7]}),n.fold(K,Vo(1),{where:i(1),side:[.02,-.45],toward:1,at:[.3,1]})}),e.step({diagram:20,label:"Fold the back legs up",duration:.8,pose:{s:1.7,ty:-.15}},n=>{n.split(n.select(),[-1,0],[1,0]),n.fold([-1,0],[1,0],{where:Le,side:[0,-.2],toward:1})});let a=[];e.step({diagram:21,label:"Fold them back down in half",duration:.8},n=>{a=n.fold([-1,ht],[1,ht],{where:Le,side:[0,.3],toward:1})});let s=(n,l,d,u={})=>{let p=new Set(a),b=n.select(Le),m=d*Math.PI/180,f=ht*Math.cos(m),g=ht*Math.sin(m),c=n.rot([-1,0,0],[1,0,0],l,u),A=n.rot([-1,f,g],[1,f,g],-l,u);n.attach(b.filter(w=>!p.has(w)),c),n.attach(b.filter(w=>p.has(w)),A,c)};return e.step({diagram:22,label:"Turn over",duration:1,ease:"inOut",pose:{ry:180,rx:-70,rz:-35,s:2.1,ty:.25},arc:{tz:.3}},n=>{s(n,qt,0,{ease:"inOut",at:[.4,1]})}),e.step({diagram:22,label:"Hop",duration:1,ease:"linear",path:Go},n=>s(n,-Qo,qt,{ease:"breathe",at:[0,.36]})),e.step({diagram:22,label:"Hop again",duration:1,ease:"linear",path:Go},n=>s(n,-Qo,qt,{ease:"breathe",at:[0,.36]})),e.step({diagram:22,label:"Hop away",duration:1.2,phase:"outro",ease:"linear",path:ai}),e.compile({colourDown:!0})}var Oe=[0,-1],ye=(e,t,r=3)=>{let o=e*Math.PI/180;return[t*r*Math.sin(o),-1+r*Math.cos(o)]},_o=e=>e*Math.PI/180,Wo=15,si=278,li=11.25,Ho=.29,Yo=.3;function qo(e,[t,r]){let o=[r[0]-t[0],r[1]-t[1]],i=((e[0]-t[0])*o[0]+(e[1]-t[1])*o[1])/(o[0]*o[0]+o[1]*o[1]);return[2*(t[0]+o[0]*i)-e[0],2*(t[1]+o[1]*i)-e[1]]}var Jo=(e,t)=>[e,[e[0]+Math.cos(_o(t)),e[1]+Math.sin(_o(t))]];function ci(e,t){let r=0;for(let o=0;o<e.length;o++){let i=e[o],a=e[(o+1)%e.length],s=(a[0]-i[0])*(t[1]-i[1])-(a[1]-i[1])*(t[0]-i[0]);if(!(Math.abs(s)<1e-9)){if(r&&Math.sign(s)!==r)return!1;r=Math.sign(s)}}return!0}var di=e=>({ty:.03*Math.sin(e*Math.PI*2),rz:1.5*Math.sin(e*Math.PI*2+.8)});function bt(){let e=new R({rx:-20,ry:180,ty:.6,tz:.4,o:0},[[0,-1],[1,0],[0,1],[-1,0]]);e.step({diagram:1,label:"Start with a square",duration:.7,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}}),e.step({diagram:2,label:"Fold the edges to the centre",duration:.9},n=>{n.fold(Oe,ye(22.5,-1),{side:[-1,0],toward:-1,at:[0,.7]}),n.fold(Oe,ye(22.5,1),{side:[1,0],toward:-1,at:[.3,1]})}),e.step({diagram:3,label:"Turn over",duration:.7,ease:"inOut",pose:{ry:360},arc:{tz:.3}}),e.step({diagram:4,label:"Fold the edges to the centre again",duration:.9,pose:{s:1.1}},n=>{n.fold(Oe,ye(11.25,-1),{side:ye(17,-1,.75),toward:1,at:[0,.7]}),n.fold(Oe,ye(11.25,1),{side:ye(17,1,.75),toward:1,at:[.3,1]})});let t=[];e.step({diagram:5,label:"Fold the point up to the top",duration:.8,pose:{s:1.25,ty:-.3}},n=>{t=n.fold([-1,0],[1,0],{side:Oe,toward:1}).map(l=>l.poly)});let r=n=>t.some(l=>ci(l,ui(n.poly)));e.step({diagram:6,label:"Fold in half",duration:.9,ease:"inOut",pose:{rz:90,rx:-10,s:1.5,tx:.62,ty:.2}},n=>{n.fold([0,-1],[0,1],{side:[.5,.5],toward:-1})});let o=n=>n.sheet[0]<0,i=Jo([0,Ho],(90+Wo)/2),a=[[0,Ho],[0,1]],s=[];return e.step({diagram:7,label:"Pull the neck up",duration:1.1,ease:"inOut",pose:{rz:90-li,s:1.6,tx:.34,ty:-.22}},n=>{s=n.reverse(n.select(l=>l.flat).filter(r),i,{side:[0,1],axis:a,front:o,kind:"outside",roll:"last",book:!0})}),e.step({diagram:8,label:"Reverse fold the head",duration:.8,ease:"inOut"},n=>{let l=qo([0,1],i),d=qo(a[0],i),u=Math.hypot(l[0]-d[0],l[1]-d[1]),p=[l[0]+(d[0]-l[0])/u*Yo,l[1]+(d[1]-l[1])/u*Yo];n.reverse(s,Jo(p,(Wo+si)/2),{side:l,axis:[d,l],front:o,kind:"inside"})}),e.step({diagram:8,label:"Drift",duration:2.4,ease:"linear",path:di}),e.step({diagram:8,label:"Glide away",duration:1.1,phase:"outro",ease:"in",pose:{tx:2.4,o:0}}),e.compile()}function ui(e){let t=0,r=0;for(let o of e)t+=o[0],r+=o[1];return[t/e.length,r/e.length]}var Xt=.5,Ge=-.25,$t=[0,Ge],Ko=.12,Zo=e=>{let t=(r,o,i)=>i*Math.exp(-(((e-r)/o)**2));return{s:t(.18,.06,.09)+t(.36,.07,.06)}};function At(){let e=new R({rx:-16,ry:180,ty:.6,tz:.4,o:0},[[0,-1],[1,0],[0,1],[-1,0]]);return e.step({diagram:1,label:"Start with a square",duration:.7,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}}),e.step({diagram:2,label:"Fold the top corner to the centre",duration:.7},t=>{t.fold([-1,Xt],[1,Xt],{side:[0,1],toward:-1,at:[.05,1]})}),e.step({diagram:3,label:"Fold the bottom corner up",duration:.8},t=>{t.fold([-1,Ge],[1,Ge],{side:[0,-1],toward:-1})}),e.step({diagram:4,label:"Fold the sides up to the centre",duration:1,pose:{s:1.3,ty:-.2}},t=>{t.fold($t,[-1,Ge+1],{side:[-.9,-.05],toward:-1,at:[0,.7]}),t.fold($t,[1,Ge+1],{side:[.9,-.05],toward:-1,at:[.3,1]})}),e.step({diagram:5,label:"Fold the corners behind",duration:.9,pose:{s:1.55,ty:-.4}},t=>{let r=[];for(let o of[-1,1]){let i=[o*.25,.75],a=[o*.625,.375],s=[0,Xt];r.push({p:i,a:s,b:a,top:!0},{p:a,a:i,b:$t,top:!1})}r.forEach(({p:o,a:i,b:a,top:s},n)=>{let l=u=>{let p=[u[0]-o[0],u[1]-o[1]],b=Math.hypot(p[0],p[1]);return[o[0]+p[0]/b*Ko,o[1]+p[1]/b*Ko]},d=Math.sign(o[0]);t.fold(l(i),l(a),{where:s?u=>u.model[0]*d>-.1:void 0,side:o,toward:1,at:[n*.12,.64+n*.12]})})}),e.step({diagram:5,label:"Beat",duration:1.1,ease:"linear",path:Zo}),e.step({diagram:5,label:"Beat again",duration:1.1,ease:"linear",path:Zo}),e.step({diagram:5,label:"Float away",duration:1,phase:"outro",ease:"in",pose:{ty:.4,s:1.35,o:0}}),e.compile()}var Pe=Math.SQRT2-1,yt=[0,1],ze=[0,-1],xt=[0,0],q=e=>[e*Pe,0],Se=e=>[e,0],Mt=e=>[e*Math.SQRT1_2,1-Math.SQRT1_2],Pt=e=>[e*Math.SQRT1_2,Math.SQRT1_2-1],jo=.3,Xo=(1+Pe)/2,vt=-.7,hi=350,fi=12;function tr([e,t]){if(Math.abs(e)/Pe+Math.abs(t)<1)return"centre";let r=e<0?-1:1,o=t>0,i=q(r),a=o?Mt(r):Pt(r);return Math.sign(U(i,a,[e,t]))===Math.sign(U(i,a,Se(r)))?o?"upEar":"lowEar":o?"upMain":"lowMain"}var Me=(...e)=>t=>e.includes(tr(t.sheet)),wt=Me("upEar","lowEar"),pi=(e,t,r)=>Y(e,t,10,D(r))[2]<0?1:-1,$o=e=>180*V.inOut(e);function mi(e,t){let r=t?yt:ze,o=t?Mt(e):Pt(e),i=pi(q(e),r,Se(e)),a=(n,l)=>Y(q(e),r,i*180*n,Y(q(e),o,l,D(Se(e)))),s=Do((n,l)=>a(n,l)[1],0,{ok:(n,l)=>a(n,l)[2]<=1e-9});return{kite:n=>i*$o(n),ear:n=>s($o(n)/180)}}var er=e=>({ty:.04*Math.sin(e*Math.PI*2),rz:2.5*Math.sin(e*Math.PI*2-.6)});function St(){let e=new R({rx:-20,ry:180,ty:.6,tz:.4,o:0},[[0,-1],[1,0],[0,1],[-1,0]]);e.step({diagram:1,label:"Start with a square",duration:.7,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}});let t=(o,i,a)=>{let s=[];e.step({diagram:o,label:i,duration:.8},n=>{s=[-1,1].map(l=>n.fold(a,q(l),{side:Se(l),toward:-1,at:l<0?[0,.7]:[.3,1]}))}),e.step({diagram:o,label:"Unfold",duration:.45,ease:"inOut"},n=>{[-1,1].forEach((l,d)=>n.attach(s[d],n.hinge(a,q(l),Se(l),1,180,{ease:"inOut"})))})};t(2,"Fold the bottom edges to the centre",ze),t(3,"Fold the top edges to the centre",yt),e.step({diagram:4,label:"Collapse into a fish base",duration:1.4,ease:"inOut",pose:{s:1.1}},o=>{for(let i of[-1,1]){let a=s=>tr(o.info(s).sheet)!=="centre"&&i*o.info(s).sheet[0]>0;o.split(o.select().filter(a),[-1,0],[1,0]),o.split(o.select(Me("upMain","upEar")).filter(a),q(i),Mt(i)),o.split(o.select(Me("lowMain","lowEar")).filter(a),q(i),Pt(i));for(let s of[!0,!1]){let n=s?yt:ze,l=s?Mt(i):Pt(i),d=mi(i,s),u=o.rot(q(i),n,d.kite),p=o.rot(q(i),l,d.ear),b=m=>o.select(Me(m)).filter(f=>i*o.info(f).sheet[0]>0);o.attach(b(s?"upMain":"lowMain"),u),o.attach(b(s?"upEar":"lowEar"),p,u)}}}),e.step({diagram:4,label:"Flatten the ears down",duration:.8,ease:"inOut"},o=>{for(let i of[-1,1]){let s=Y(q(i),xt,90,[0,0,-Pe])[1]<0?90:-90;o.attach(o.select(wt).filter(n=>i*o.info(n).sheet[0]>0),o.rot(D(q(i)),D(xt),s,{ease:"inOut"}))}o.layer(o.select(Me("lowEar")),o.select(Me("upEar")))}),e.step({diagram:5,label:"Fold the tip back",duration:.7},o=>{o.fold([-1,Xo],[1,Xo],{side:yt,toward:1})}),e.step({diagram:5,label:"Turn over",duration:.8,ease:"inOut",pose:{ry:360},arc:{tz:.3}}),e.step({diagram:6,label:"Fold the corners in",duration:.7,pose:{s:1.15}},o=>{for(let i of[-1,1])o.fold([i*jo,-1],[i*jo,1],{side:Se(i),toward:1,at:i<0?[0,.7]:[.3,1]})}),e.step({diagram:7,label:"Fold in half",duration:.9,ease:"inOut",pose:{rz:90,rx:-12,s:1.45,tx:.2,ty:-.05}},o=>{o.fold([0,-1],[0,1],{side:[.3,0],toward:1})}),e.step({diagram:8,label:"Fold the flippers down",duration:.8},o=>{o.fold(xt,[-1,-1],{where:i=>wt(i)&&i.sheet[0]>0,side:[0,-Pe],toward:1,at:[0,.7]}),o.fold(xt,[-1,-1],{where:i=>wt(i)&&i.sheet[0]<0,side:[0,-Pe],toward:-1,at:[.3,1]})});let r=[];return e.step({diagram:9,label:"Lift the tail",duration:.9,ease:"inOut",pose:{s:1.5}},o=>{let i=(270+hi)/2*Math.PI/180,a=[[0,vt],[-Math.cos(i),vt-Math.sin(i)]];r=o.reverse(o.select(s=>s.flat&&!wt(s)),a,{side:ze,axis:[[0,vt],ze],front:s=>s.sheet[0]>0,kind:"outside",roll:"last",book:!0})}),e.step({diagram:10,label:"Swim",duration:1.4,ease:"linear",path:er},o=>{o.attach(r,o.swing([0,vt],fi,{ease:"breathe"}))}),e.step({diagram:10,label:"Swim on",duration:1.4,ease:"linear",path:er}),e.step({diagram:10,label:"Dive",duration:1,phase:"outro",ease:"in",pose:{ty:-.9,rz:112,o:0}}),e.compile()}var or=[0,0],rr=[0,-1],gi=-.3,ir=-.9,bi=28,Ai=e=>e[0]<-Math.abs(e[1]),xi=e=>e[0]>Math.abs(e[1]),nr=e=>[[e*.5,-.5],[0,gi]],vi=e=>({rz:9*Math.sin(e*Math.PI*2)*Math.sin(e*Math.PI)});function Et(){let e=new R({rx:-14,ry:180,ty:.6,tz:.4,o:0},[[0,-1],[1,0],[0,1],[-1,0]]);e.step({diagram:1,label:"Start with a square",duration:.7,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}}),e.step({diagram:2,label:"Fold the top corner down",duration:.7},r=>{r.fold([-1,0],[1,0],{side:[0,1],toward:-1,at:[.05,1]})}),e.step({diagram:3,label:"Fold the corners to the bottom",duration:.9,pose:{s:1.4,ty:.25}},r=>{r.fold(or,[-.5,-.5],{side:[-1,0],toward:-1,at:[0,.7]}),r.fold(or,[.5,-.5],{side:[1,0],toward:-1,at:[.3,1]})});let t=[];return e.step({diagram:4,label:"Fold the ears up",duration:1,pose:{s:1.55,ty:.2}},r=>{t=[-1,1].map((o,i)=>r.fold(...nr(o),{where:a=>(o<0?Ai:xi)(a.sheet),side:rr,toward:-1,at:i?[.3,1]:[0,.7]}))}),e.step({diagram:5,label:"Tuck the nose behind",duration:.6,pose:{s:1.6,ty:.28}},r=>{r.fold([-1,ir],[1,ir],{side:rr,toward:1})}),e.step({diagram:6,label:"Tilt the head",duration:1.6,ease:"linear",path:vi}),e.step({diagram:6,label:"Twitch the ears",duration:.9,ease:"linear"},r=>{t.forEach((o,i)=>{let a=i?1:-1,[s,n]=nr(a);r.attach(o,r.hinge(s,n,[a*.6,.3],-1,bi,{ease:"breathe",at:i?[.25,1]:[0,.75]}))})}),e.step({diagram:6,label:"Trot off",duration:.9,phase:"outro",ease:"in",pose:{tx:-1.4,o:0},arc:{ty:.08}}),e.compile()}var to=new Map([["crane",rt],["plane",st],["pleat",lt],["envelope",ct],["boat",dt],["frog",gt],["swan",bt],["heart",At],["whale",St],["fox",Et]]),eo=new Map;function ar(){return[...to.keys()]}function sr(e,t){to.set(e,t),eo.delete(e)}function Ft(e){let t=eo.get(e);if(!t){let r=to.get(e);if(!r)return;t=new me(r()),eo.set(e,t)}return t}var Ne={distance:5,light:Ce([-.45,.7,.75])};function wi(e){return Q(he(e.tx,e.ty,e.tz),Q(Dt(e.spin*J),Q(fo(e.s),Q(uo(e.rx*J),Q(ho(e.ry*J),Dt(e.rz*J))))))}var lr=1e-6;function cr(e,t,r){let o=e.normal,i=se(o,Ie(r,e.center))>=0?1:-1,a=!1,s=!1;for(let n of t.pts){let l=se(o,Ie(n,e.center))*i;if(l>lr?a=!0:l<-lr&&(s=!0),a&&s)return 0}return a?1:s?-1:0}function yi(e,t){for(let r of[e,t])for(let o=0;o<r.length;o++){let i=r[o],a=r[(o+1)%r.length],s=i[1]-a[1],n=a[0]-i[0],l=Math.hypot(s,n);if(l<1e-9)continue;let d=1/0,u=-1/0,p=1/0,b=-1/0;for(let m of e){let f=(m[0]*s+m[1]*n)/l;f<d&&(d=f),f>u&&(u=f)}for(let m of t){let f=(m[0]*s+m[1]*n)/l;f<p&&(p=f),f>b&&(b=f)}if(u<=p+1e-4||b<=d+1e-4)return!1}return!0}function Mi(e,t,r){let o=0,i;for(let d of e.polys)for(let u of t.polys){let p=Ke(d,u);if(p.length<3)continue;let b=Math.abs(le(p));b>o&&(o=b,i=Re(p))}if(!i||o<1e-7)return 0;let a=[i[0],-i[1],-r],s=d=>{let u=se(d.normal,a);return Math.abs(u)<1e-12?1/0:(d.normal[0]*d.center[0]+d.normal[1]*d.center[1]+d.normal[2]*(d.center[2]-r))/u},n=s(e),l=s(t);return!isFinite(n)||!isFinite(l)||n===l?0:l<n?1:-1}function ro(e,t=Ne){let r=[0,0,t.distance],o=e.length,i=e.map(d=>go(d.scr)),a=e.map(()=>[]),s=new Int32Array(o);for(let d=0;d<o;d++){let u=e[d];for(let p=d+1;p<o;p++){let b=e[p];if(u.box[2]<=b.box[0]||b.box[2]<=u.box[0]||u.box[3]<=b.box[1]||b.box[3]<=u.box[1]||!yi(i[d],i[p]))continue;let m=-cr(u,b,r);m||(m=cr(b,u,r)),m||(m=-Mi(u,b,t.distance)),m&&(m<0?(a[d].push(p),s[p]++):(a[p].push(d),s[d]++))}}let n=[],l=new Uint8Array(o);for(let d=0;d<o;d++){let u=-1;for(let p=0;p<o;p++)!l[p]&&s[p]===0&&(u<0||e[p].depth>e[u].depth)&&(u=p);if(u<0)for(let p=0;p<o;p++)!l[p]&&(u<0||e[p].depth>e[u].depth)&&(u=p);l[u]=1,n.push(u);for(let p of a[u])s[p]--}return n}function Pi(e,t,r=Ne){let o=e.faces.length,i=wi(t.pose),a=r.distance,s=[0,0,a],n=new Array(o),l=new Array(o),d=new Array(o),u=new Array(o);for(let c=0;c<o;c++){let A=t.T[c];u[c]=[A[2],A[6],A[10]],n[c]=Q(i,Q(he(t.lift[3*c],t.lift[3*c+1],t.lift[3*c+2]),A)),l[c]=e.faces[c].map(w=>H(n[c],e.verts[w][0],e.verts[w][1],0)),d[c]=l[c].map(([w,y,h])=>{let x=a/(a-h);return[w*x,-y*x]})}let p=Int32Array.from({length:o},(c,A)=>A),b=c=>p[c]===c?c:p[c]=b(p[c]),m=new Uint8Array(e.edges.length);e.edges.forEach((c,A)=>{if(c.faces.length!==2)return;let[w,y]=c.faces;if(se(u[w],u[y])>1-1e-9){m[A]=1;let h=t.lift;Math.abs(h[3*w]-h[3*y])+Math.abs(h[3*w+1]-h[3*y+1])+Math.abs(h[3*w+2]-h[3*y+2])<1e-9&&(p[b(w)]=b(y))}});let f=new Map;for(let c=0;c<o;c++){let A=b(c),w=f.get(A);w?w.push(c):f.set(A,[c])}let g=[];for(let c of f.values()){let A=[],w=[],y=[0,0,0],h=[1/0,1/0,-1/0,-1/0];for(let M of c)for(let S=0;S<l[M].length;S++){A.push(l[M][S]),w.push(d[M][S]);let[E,B]=d[M][S];E<h[0]&&(h[0]=E),E>h[2]&&(h[2]=E),B<h[1]&&(h[1]=B),B>h[3]&&(h[3]=B)}for(let M of A)y[0]+=M[0]/A.length,y[1]+=M[1]/A.length,y[2]+=M[2]/A.length;let x=n[c[0]],v=Ie(s,y);g.push({faces:c,pts:A,scr:w,polys:c.map(M=>fe(d[M].slice())),normal:Ce([x[2],x[6],x[10]]),center:y,depth:Math.hypot(v[0],v[1],v[2]),box:h})}return{W:n,pts:l,scr:d,flat:m,panels:g,order:ro(g,r)}}var oo="http://www.w3.org/2000/svg",ue=e=>Math.round(e*1e3)/1e3,Ee=class{constructor(t,r,o=Ne){this.root=t;this.m=r;this.cam=o;this.slots=[];this.uid=Math.random().toString(36).slice(2,8);t.textContent="",this.defs=document.createElementNS(oo,"defs"),this.image=document.createElementNS(oo,"image"),this.image.id=`${this.uid}-img`;for(let[i,a]of[["width","2"],["height","2"],["preserveAspectRatio","none"]])this.image.setAttribute(i,a);this.defs.appendChild(this.image),t.appendChild(this.defs)}setTexture(t){this.image.setAttribute("href",t)}slot(t){let r=this.slots[t];if(r)return r;let o=(b,m)=>{let f=document.createElementNS(oo,b);return m&&f.setAttribute("class",m),f},i=o("pattern");i.id=`${this.uid}-t${t}`,i.setAttribute("patternUnits","userSpaceOnUse"),i.setAttribute("width","2"),i.setAttribute("height","2");let a=o("use");a.setAttribute("href",`#${this.uid}-img`),i.appendChild(a),this.defs.appendChild(i);let s=o("path","f"),n=o("path","t");n.style.fill=`url(#${i.id})`;let l=o("g"),d=l.appendChild(o("path","m")),u=l.appendChild(o("path","a")),p=l.appendChild(o("path","e"));return this.root.append(s,n,l),r={fill:s,tex:n,pattern:i,lines:l,mem:d,act:u,edge:p,cache:["","","","","","","",""]},this.slots[t]=r,r}render(t){let r=this.m,o=this.cam.distance,i=[0,0,o],{W:a,scr:s,flat:n,panels:l,order:d}=Pi(r,t,this.cam),u=t.step;for(let p=0;p<d.length;p++){let b=l[d[p]],m=this.slot(p),f="",g="",c="",A="";for(let T of b.faces){let W=s[T];for(let O=0;O<W.length;O++)f+=(O?"L":"M")+ue(W[O][0])+" "+ue(W[O][1]);f+="Z",r.faceEdges[T].forEach((O,X)=>{let L=W[X],qe=W[(X+1)%W.length],ie=`M${ue(L[0])} ${ue(L[1])}L${ue(qe[0])} ${ue(qe[1])}`,Be=r.edges[O];if(Be.faces.length<2||!n[O])A+=ie;else{let kr=Be.faces[0]===T?Be.faces[1]:Be.faces[0];Be.born<=u&&(g+=ie),t.group[T]!==t.group[kr]&&(c+=ie)}})}let w=a[b.faces[0]],y=se(b.normal,Ie(i,b.center))>0,h=y?b.normal:[-b.normal[0],-b.normal[1],-b.normal[2]],x=Math.max(0,se(h,this.cam.light)),v=y!==!!r.colourDown,M=v?"f":"b",S=`color-mix(in oklab,var(--_l${M}) ${Math.round((.15+.85*x)*100)}%,var(--_s${M}))`,E=v?"front":"back",B=r.faces[b.faces[0]],F=0,k=0;for(let T of B)F+=r.verts[T][0]/B.length,k+=r.verts[T][1]/B.length;let _=Si(w,o,F,k),I=m.cache;I[0]!==f&&(m.fill.setAttribute("d",I[0]=f),m.tex.setAttribute("d",f)),I[1]!==g&&m.mem.setAttribute("d",I[1]=g),I[2]!==c&&m.act.setAttribute("d",I[2]=c),I[3]!==A&&m.edge.setAttribute("d",I[3]=A),I[4]!==S&&m.fill.style.setProperty("--f",I[4]=S),I[5]!==E&&m.lines.setAttribute("class",I[5]=E),I[6]!==_&&m.pattern.setAttribute("patternTransform",I[6]=_),I[7]!=="1"&&(I[7]="1",m.fill.style.display=m.tex.style.display=m.lines.style.display="")}for(let p=d.length;p<this.slots.length;p++){let b=this.slots[p];b.cache[7]!=="0"&&(b.cache[7]="0",b.fill.style.display=b.tex.style.display=b.lines.style.display="none")}this.root.style.opacity=String(ue(t.pose.o))}};function Si(e,t,r,o){let i=(A,w)=>{let[y,h,x]=H(e,A,w,0),v=t/(t-x);return[y*v,-h*v]},s=i(r,o),n=i(r+.25,o),l=i(r,o+.25),d=(n[0]-s[0])/.25,u=(n[1]-s[1])/.25,p=-(l[0]-s[0])/.25,b=-(l[1]-s[1])/.25,m=r+1,f=1-o,g=s[0]-d*m-p*f,c=s[1]-u*m-b*f;return`matrix(${[d,u,p,b,g,c].map(A=>Math.round(A*1e4)/1e4).join(" ")})`}var dr=`
695
695
  :host{display:inline-block;width:160px;height:160px;vertical-align:middle;contain:layout paint style;
696
696
  --_ink:var(--ol-ink,#17171a);--_bg:var(--ol-bg,#fff);--_paper:var(--ol-paper,#fffefb);--_sw:var(--ol-stroke,1.5px);
697
697
  --_front:var(--ol-front,#e2553a);--_back:var(--ol-back,#f6f3ec);
@@ -731,4 +731,4 @@ path{vector-effect:non-scaling-stroke;stroke-linejoin:round;stroke-linecap:round
731
731
  [data-look=paper]{--_lf:var(--_front);--_sf:color-mix(in oklab,var(--_front) 68%,#1a0f0c);--_lb:var(--_back);--_sb:color-mix(in oklab,var(--_back) 82%,#6f6a60);--_grain:.7}
732
732
  [data-look=paper] .e{stroke:#000;stroke-opacity:.28;stroke-width:calc(var(--_sw)*.55)}
733
733
  [data-look=paper] .m{stroke:#000;stroke-opacity:.12;stroke-width:calc(var(--_sw)*.5)}
734
- `;var yr=new Map,Mr=e=>e<=220?256:e<=460?512:1024;function Bt(e,t="paper"){let r=`${t}:${e}`,o=yr.get(r);if(!o){let n=()=>new Promise(i=>setTimeout(()=>Qn(e,i),0));o=t==="grain"?n():Promise.resolve().then(()=>(wr(),vr)).then(i=>i.renderPaperShader(e)).catch(()=>{}).then(i=>i??n()),yr.set(r,o)}return o}function Dn(e){return()=>{e|=0,e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function Et(e,t,r){let o=t+1,n=new Float32Array(o*o);for(let a=0;a<n.length;a++)n[a]=r();let i=new Float32Array(e*e),s=t/e;for(let a=0;a<e;a++){let c=a*s,d=c|0,u=c-d,f=u*u*(3-2*u);for(let x=0;x<e;x++){let b=x*s,p=b|0,m=b-p,l=m*m*(3-2*m),g=d*o+p,M=n[g]+(n[g+1]-n[g])*l,w=n[g+o]+(n[g+o+1]-n[g+o])*l;i[a*e+x]=M+(w-M)*f}}return i}function Qn(e,t){if(typeof document>"u")return t("");let r=document.createElement("canvas");r.width=r.height=e;let o=r.getContext("2d");if(!o)return t("");let n=Dn(61469),i=e/512,s=e*e;o.fillStyle="#000",o.fillRect(0,0,e,e),o.lineCap="round";let a=Math.round(420*i*i);for(let w=0;w<a;w++){let h=n()*e,A=n()*e,v=n()*Math.PI,y=(6+n()*n()*70)*i,S=(n()-.5)*y*.9,E=Math.cos(v),F=Math.sin(v);o.strokeStyle=`rgba(255,255,255,${.12+n()*.4})`,o.lineWidth=(.5+n()*1.2)*i,o.beginPath(),o.moveTo(h,A),o.quadraticCurveTo(h+E*y/2-F*S,A+F*y/2+E*S,h+E*y,A+F*y),o.stroke()}let c=o.getImageData(0,0,e,e).data,d=new Float32Array(s);for(let w=0;w<s;w++)d[w]=n();let u=Et(e,Math.round(110*i),n),f=new Float32Array(s);for(let w=0;w<e;w++)for(let h=0;h<e;h++){let A=0;for(let y=-1;y<=1;y++){let S=Math.min(e-1,Math.max(0,w+y))*e;for(let E=-1;E<=1;E++)A+=d[S+Math.min(e-1,Math.max(0,h+E))]}let v=w*e+h;f[v]=A/9*.55+u[v]*.45+c[v*4]/255*.9}let x=Et(e,3,n),b=Et(e,7,n),p=Et(e,16,n),m=o.createImageData(e,e),l=m.data,g=-.62,M=-.78;for(let w=0;w<e;w++){let h=Math.max(0,w-1)*e,A=Math.min(e-1,w+1)*e;for(let v=0;v<e;v++){let y=w*e+v,S=Math.max(0,v-1),E=Math.min(e-1,v+1),F=f[w*e+E]-f[w*e+S],B=f[A+v]-f[h+v],k=-(F*g+B*M)*.55,_=(x[y]*.5+b[y]*.3+p[y]*.2-.5)*.16,I=c[y*4]/255*.05,U=k+_+I,W=Math.min(1,Math.abs(U))*255,L=U>0?255:0;l[y*4]=l[y*4+1]=l[y*4+2]=L,l[y*4+3]=W}}o.putImageData(m,0,0),r.toBlob&&typeof URL<"u"&&URL.createObjectURL?r.toBlob(w=>t(w?URL.createObjectURL(w):r.toDataURL("image/png")),"image/png"):t(r.toDataURL("image/png"))}var Vn=["ink","blueprint","graphite","paper"],ze=typeof matchMedia=="function"?matchMedia("(prefers-reduced-motion: reduce)"):void 0,Un=typeof HTMLElement>"u"?class{}:HTMLElement,Ne=class extends Un{constructor(){super();this.time=0;this.raf=0;this.last=0;this.visible=!0;this.step=-1;this.finishing=!1;this.finished=!1;this.onMotion=()=>this.sync();this.tick=r=>{this.raf=requestAnimationFrame(this.tick);let o=this.last?Math.min(.1,(r-this.last)/1e3):0;this.last=r;let n=this.duration;if(n){if(this.finishing){if(this.time+=o*this.speed,this.time>=n){this.time=n,this.finishing=!1,this.finished=!0,this.stop(),this.draw(),this.dispatchEvent(new CustomEvent("ol-complete"));return}}else this.time=(this.time+o*this.speed)%n;this.draw()}};let r=this.attachShadow({mode:"open"});r.innerHTML=`<style>${ir}</style><svg part="svg" viewBox="-1.6 -1.6 3.2 3.2" aria-hidden="true"><g></g></svg>`,this.svg=r.querySelector("svg")}static get observedAttributes(){return["model","look","speed","progress","paused","texture"]}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","progressbar"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Loading"),this.load(),this.applyLook(),typeof IntersectionObserver=="function"&&(this.io=new IntersectionObserver(r=>{this.visible=r[r.length-1].isIntersecting,this.sync()}),this.io.observe(this)),ze?.addEventListener?.("change",this.onMotion),this.sync()}disconnectedCallback(){this.io?.disconnect(),ze?.removeEventListener?.("change",this.onMotion),this.stop()}attributeChangedCallback(r){this.isConnected&&(r==="model"&&this.load(),r==="look"&&this.applyLook(),r==="texture"&&this.loadTexture(),r==="progress"&&this.hasAttribute("progress")&&(this.finishing=this.finished=!1),this.sync())}complete(){let r=this.player;r&&(this.finished=!1,this.finishing=!0,this.time=r.model.content[1],ze?.matches&&(this.finishing=!1,this.finished=!0),this.hasAttribute("progress")?this.removeAttribute("progress"):this.sync(),this.finished&&this.dispatchEvent(new CustomEvent("ol-complete")))}restart(){this.finishing=this.finished=!1,this.time=this.player?.model.content[0]??0,this.sync(),this.draw()}get duration(){return this.player?.duration??0}get stepCount(){return this.player?Math.max(...this.player.model.steps.map(r=>r.diagram)):0}get currentStep(){let r=this.player;if(!r)return;let o=r.stepAt(this.displayTime()),n=r.model.steps[o];return{index:o,diagram:n.diagram,label:n.label}}seek(r){let o=this.duration;this.time=o?(r%o+o)%o:0,this.draw()}load(){let r=this.getAttribute("model")||"crane";if(this.player=Mt(r),!this.player){console.warn(`<origami-loader>: unknown model "${r}"`);return}this.scene=new Me(this.svg.firstElementChild,this.player.model),this.frame=void 0,this.step=-1,this.finishing=this.finished=!1,this.time=this.player.model.content[0],this.loadTexture(),this.draw()}loadTexture(){let r=this.scene,o=this.getAttribute("texture")==="none";if(this.svg.dataset.tex=o?"off":"loading",!r||o)return;let n=(this.getBoundingClientRect().width||160)*(globalThis.devicePixelRatio||1)*(2/3.2),i=this.getAttribute("texture")==="grain"?"grain":"paper";Bt(Mr(n),i).then(s=>{r!==this.scene||!s||(r.setTexture(s),this.svg.dataset.tex!=="off"&&(this.svg.dataset.tex="on"))})}applyLook(){let r=this.getAttribute("look");this.svg.dataset.look=Vn.includes(r)?r:"ink"}get speed(){let r=parseFloat(this.getAttribute("speed")??"");return Number.isFinite(r)&&r>0?r:1}get progress(){let r=this.getAttribute("progress");if(r===null||r==="")return;let o=parseFloat(r);return Number.isFinite(o)?ie(o):void 0}displayTime(){let r=this.player;if(!r)return 0;let[o,n]=r.model.content;if(this.finished)return r.duration;if(this.finishing)return this.time;let i=this.progress;return i!==void 0?o+i*(n-o):ze?.matches?n-.001:this.time}draw(){let r=this.player;if(!r||!this.scene)return;let o=this.progress;o!==void 0?(this.setAttribute("aria-valuenow",String(Math.round(o*100))),this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax","100")):this.removeAttribute("aria-valuenow"),this.frame=r.evaluate(this.displayTime(),this.frame),this.scene.render(this.frame),this.frame.step!==this.step&&(this.step=this.frame.step,this.dispatchEvent(new CustomEvent("ol-step",{detail:this.currentStep})))}sync(){let r=this.isConnected&&this.visible&&!this.hasAttribute("paused")&&!this.finished&&this.progress===void 0&&(this.finishing||!ze?.matches);r&&!this.raf?(this.last=0,this.raf=requestAnimationFrame(this.tick)):r||(this.stop(),this.draw())}stop(){this.raf&&cancelAnimationFrame(this.raf),this.raf=0}};function Ft(e="origami-loader"){typeof customElements<"u"&&!customElements.get(e)&&customElements.define(e,class extends Ne{})}Ft();return Ir(Tn);})();
734
+ `;var Fr=new Map,Br=e=>e<=220?256:e<=460?512:1024;function Ct(e,t="paper"){let r=`${t}:${e}`,o=Fr.get(r);if(!o){let i=()=>new Promise(a=>setTimeout(()=>Li(e,a),0));o=t==="grain"?i():Promise.resolve().then(()=>(Er(),Sr)).then(a=>a.renderPaperShader(e)).catch(()=>{}).then(a=>a??i()),Fr.set(r,o)}return o}function Ti(e){return()=>{e|=0,e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function It(e,t,r){let o=t+1,i=new Float32Array(o*o);for(let n=0;n<i.length;n++)i[n]=r();let a=new Float32Array(e*e),s=t/e;for(let n=0;n<e;n++){let l=n*s,d=l|0,u=l-d,p=u*u*(3-2*u);for(let b=0;b<e;b++){let m=b*s,f=m|0,g=m-f,c=g*g*(3-2*g),A=d*o+f,w=i[A]+(i[A+1]-i[A])*c,y=i[A+o]+(i[A+o+1]-i[A+o])*c;a[n*e+b]=w+(y-w)*p}}return a}function Li(e,t){if(typeof document>"u")return t("");let r=document.createElement("canvas");r.width=r.height=e;let o=r.getContext("2d");if(!o)return t("");let i=Ti(61469),a=e/512,s=e*e;o.fillStyle="#000",o.fillRect(0,0,e,e),o.lineCap="round";let n=Math.round(420*a*a);for(let y=0;y<n;y++){let h=i()*e,x=i()*e,v=i()*Math.PI,M=(6+i()*i()*70)*a,S=(i()-.5)*M*.9,E=Math.cos(v),B=Math.sin(v);o.strokeStyle=`rgba(255,255,255,${.12+i()*.4})`,o.lineWidth=(.5+i()*1.2)*a,o.beginPath(),o.moveTo(h,x),o.quadraticCurveTo(h+E*M/2-B*S,x+B*M/2+E*S,h+E*M,x+B*M),o.stroke()}let l=o.getImageData(0,0,e,e).data,d=new Float32Array(s);for(let y=0;y<s;y++)d[y]=i();let u=It(e,Math.round(110*a),i),p=new Float32Array(s);for(let y=0;y<e;y++)for(let h=0;h<e;h++){let x=0;for(let M=-1;M<=1;M++){let S=Math.min(e-1,Math.max(0,y+M))*e;for(let E=-1;E<=1;E++)x+=d[S+Math.min(e-1,Math.max(0,h+E))]}let v=y*e+h;p[v]=x/9*.55+u[v]*.45+l[v*4]/255*.9}let b=It(e,3,i),m=It(e,7,i),f=It(e,16,i),g=o.createImageData(e,e),c=g.data,A=-.62,w=-.78;for(let y=0;y<e;y++){let h=Math.max(0,y-1)*e,x=Math.min(e-1,y+1)*e;for(let v=0;v<e;v++){let M=y*e+v,S=Math.max(0,v-1),E=Math.min(e-1,v+1),B=p[y*e+E]-p[y*e+S],F=p[x+v]-p[h+v],k=-(B*A+F*w)*.55,_=(b[M]*.5+m[M]*.3+f[M]*.2-.5)*.16,I=l[M*4]/255*.05,T=k+_+I,W=Math.min(1,Math.abs(T))*255,O=T>0?255:0;c[M*4]=c[M*4+1]=c[M*4+2]=O,c[M*4+3]=W}}o.putImageData(g,0,0),r.toBlob&&typeof URL<"u"&&URL.createObjectURL?r.toBlob(y=>t(y?URL.createObjectURL(y):r.toDataURL("image/png")),"image/png"):t(r.toDataURL("image/png"))}var Oi=["ink","blueprint","graphite","paper"],He=typeof matchMedia=="function"?matchMedia("(prefers-reduced-motion: reduce)"):void 0,Gi=typeof HTMLElement>"u"?class{}:HTMLElement,Ye=class extends Gi{constructor(){super();this.time=0;this.raf=0;this.last=0;this.visible=!0;this.step=-1;this.finishing=!1;this.finished=!1;this.onMotion=()=>this.sync();this.tick=r=>{this.raf=requestAnimationFrame(this.tick);let o=this.last?Math.min(.1,(r-this.last)/1e3):0;this.last=r;let i=this.duration;if(i){if(this.finishing){if(this.time+=o*this.speed,this.time>=i){this.time=i,this.finishing=!1,this.finished=!0,this.stop(),this.draw(),this.dispatchEvent(new CustomEvent("ol-complete"));return}}else this.time=(this.time+o*this.speed)%i;this.draw()}};let r=this.attachShadow({mode:"open"});r.innerHTML=`<style>${dr}</style><svg part="svg" viewBox="-1.6 -1.6 3.2 3.2" aria-hidden="true"><g></g></svg>`,this.svg=r.querySelector("svg")}static get observedAttributes(){return["model","look","speed","progress","paused","texture"]}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","progressbar"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Loading"),this.load(),this.applyLook(),typeof IntersectionObserver=="function"&&(this.io=new IntersectionObserver(r=>{this.visible=r[r.length-1].isIntersecting,this.sync()}),this.io.observe(this)),He?.addEventListener?.("change",this.onMotion),this.sync()}disconnectedCallback(){this.io?.disconnect(),He?.removeEventListener?.("change",this.onMotion),this.stop()}attributeChangedCallback(r){this.isConnected&&(r==="model"&&this.load(),r==="look"&&this.applyLook(),r==="texture"&&this.loadTexture(),r==="progress"&&this.hasAttribute("progress")&&(this.finishing=this.finished=!1),this.sync())}complete(){let r=this.player;r&&(this.finished=!1,this.finishing=!0,this.time=r.model.content[1],He?.matches&&(this.finishing=!1,this.finished=!0),this.hasAttribute("progress")?this.removeAttribute("progress"):this.sync(),this.finished&&this.dispatchEvent(new CustomEvent("ol-complete")))}restart(){this.finishing=this.finished=!1,this.time=this.player?.model.content[0]??0,this.sync(),this.draw()}get duration(){return this.player?.duration??0}get stepCount(){return this.player?Math.max(...this.player.model.steps.map(r=>r.diagram)):0}get currentStep(){let r=this.player;if(!r)return;let o=r.stepAt(this.displayTime()),i=r.model.steps[o];return{index:o,diagram:i.diagram,label:i.label}}seek(r){let o=this.duration;this.time=o?(r%o+o)%o:0,this.draw()}load(){let r=this.getAttribute("model")||"crane";if(this.player=Ft(r),!this.player){console.warn(`<origami-loader>: unknown model "${r}"`);return}this.scene=new Ee(this.svg.firstElementChild,this.player.model),this.frame=void 0,this.step=-1,this.finishing=this.finished=!1,this.time=this.player.model.content[0],this.loadTexture(),this.draw()}loadTexture(){let r=this.scene,o=this.getAttribute("texture")==="none";if(this.svg.dataset.tex=o?"off":"loading",!r||o)return;let i=(this.getBoundingClientRect().width||160)*(globalThis.devicePixelRatio||1)*(2/3.2),a=this.getAttribute("texture")==="grain"?"grain":"paper";Ct(Br(i),a).then(s=>{r!==this.scene||!s||(r.setTexture(s),this.svg.dataset.tex!=="off"&&(this.svg.dataset.tex="on"))})}applyLook(){let r=this.getAttribute("look");this.svg.dataset.look=Oi.includes(r)?r:"ink"}get speed(){let r=parseFloat(this.getAttribute("speed")??"");return Number.isFinite(r)&&r>0?r:1}get progress(){let r=this.getAttribute("progress");if(r===null||r==="")return;let o=parseFloat(r);return Number.isFinite(o)?ae(o):void 0}displayTime(){let r=this.player;if(!r)return 0;let[o,i]=r.model.content;if(this.finished)return r.duration;if(this.finishing)return this.time;let a=this.progress;return a!==void 0?o+a*(i-o):He?.matches?i-.001:this.time}draw(){let r=this.player;if(!r||!this.scene)return;let o=this.progress;o!==void 0?(this.setAttribute("aria-valuenow",String(Math.round(o*100))),this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax","100")):this.removeAttribute("aria-valuenow"),this.frame=r.evaluate(this.displayTime(),this.frame),this.scene.render(this.frame),this.frame.step!==this.step&&(this.step=this.frame.step,this.dispatchEvent(new CustomEvent("ol-step",{detail:this.currentStep})))}sync(){let r=this.isConnected&&this.visible&&!this.hasAttribute("paused")&&!this.finished&&this.progress===void 0&&(this.finishing||!He?.matches);r&&!this.raf?(this.last=0,this.raf=requestAnimationFrame(this.tick)):r||(this.stop(),this.draw())}stop(){this.raf&&cancelAnimationFrame(this.raf),this.raf=0}};function Rt(e="origami-loader"){typeof customElements<"u"&&!customElements.get(e)&&customElements.define(e,class extends Ye{})}Rt();return Ur(zi);})();
@@ -1,4 +1,4 @@
1
- import"./chunks/chunk-IHRIUEAN.js";var H=Math.PI/180,xt=()=>[1,0,0,0,0,1,0,0,0,0,1,0];function O(t,e){let o=new Array(12);for(let n=0;n<12;n+=4){let r=t[n],a=t[n+1],i=t[n+2];o[n]=r*e[0]+a*e[4]+i*e[8],o[n+1]=r*e[1]+a*e[5]+i*e[9],o[n+2]=r*e[2]+a*e[6]+i*e[10],o[n+3]=r*e[3]+a*e[7]+i*e[11]+t[n+3]}return o}function N(t,e,o,n){return[t[0]*e+t[1]*o+t[2]*n+t[3],t[4]*e+t[5]*o+t[6]*n+t[7],t[8]*e+t[9]*o+t[10]*n+t[11]]}function W(t,e,o){let[n,r,a]=e,i=Math.cos(o),s=Math.sin(o),l=1-i,h=[l*n*n+i,l*n*r-s*a,l*n*a+s*r,0,l*n*r+s*a,l*r*r+i,l*r*a-s*n,0,l*n*a-s*r,l*r*a+s*n,l*a*a+i,0];for(let d=0;d<12;d+=4)h[d+3]=t[d/4]-(h[d]*t[0]+h[d+1]*t[1]+h[d+2]*t[2]);return h}var He=t=>W([0,0,0],[1,0,0],t),Qe=t=>W([0,0,0],[0,1,0],t),ie=t=>W([0,0,0],[0,0,1],t),ct=(t,e,o)=>[1,0,0,t,0,1,0,e,0,0,1,o],qe=t=>[t,0,0,0,0,t,0,0,0,0,t,0],ot=(t,e=0,o=1)=>t<e?e:t>o?o:t,ce=(t,e,o)=>t+(e-t)*o,rt=(t,e)=>t[0]*e[0]+t[1]*e[1]+t[2]*e[2],wt=(t,e)=>[t[0]-e[0],t[1]-e[1],t[2]-e[2]];function vt(t){let e=Math.hypot(t[0],t[1],t[2])||1;return[t[0]/e,t[1]/e,t[2]/e]}var L=(t,e,o)=>(e[0]-t[0])*(o[1]-t[1])-(e[1]-t[1])*(o[0]-t[0]);function Ke(t,e,o,n){let r=[e[0]-t[0],e[1]-t[1]],a=[n[0]-o[0],n[1]-o[1]],i=r[0]*a[1]-r[1]*a[0];if(Math.abs(i)<1e-12)return;let s=((o[0]-t[0])*a[1]-(o[1]-t[1])*a[0])/i;return[t[0]+r[0]*s,t[1]+r[1]*s]}function at(t){let e=0;for(let o=0;o<t.length;o++){let n=t[o],r=t[(o+1)%t.length];e+=n[0]*r[1]-r[0]*n[1]}return e/2}function kt(t){let e=0,o=0,n=0;for(let r=0;r<t.length;r++){let a=t[r],i=t[(r+1)%t.length],s=a[0]*i[1]-i[0]*a[1];e+=s,o+=(a[0]+i[0])*s,n+=(a[1]+i[1])*s}if(Math.abs(e)<1e-14){for(let r of t)o+=r[0],n+=r[1];return[o/t.length,n/t.length]}return[o/(3*e),n/(3*e)]}var lt=t=>at(t)<0?t.slice().reverse():t;function We(t,e,o,n=1e-9){let r=Math.hypot(o[0]-e[0],o[1]-e[1]),a=t.map(h=>L(e,o,h)/r);if(!a.some(h=>h<-n))return{left:t,right:null,chord:null};if(!a.some(h=>h>n))return{left:null,right:t,chord:null};let i=[],s=[],l=[];for(let h=0;h<t.length;h++){let d=(h+1)%t.length,p=t[h],x=t[d],y=a[h],f=a[d];if(y>=-n&&i.push(p),y<=n&&s.push(p),Math.abs(y)<=n&&l.push(p),y>n&&f<-n||y<-n&&f>n){let P=y/(y-f),c=[p[0]+(x[0]-p[0])*P,p[1]+(x[1]-p[1])*P];i.push(c),s.push(c),l.push(c)}}return{left:i,right:s,chord:l.length>=2?[l[0],l[1]]:null}}function Ct(t,e){let o=t;for(let n=0;n<e.length&&o.length;n++){let r=e[n],a=e[(n+1)%e.length],i=o;o=[];for(let s=0;s<i.length;s++){let l=i[s],h=i[(s+1)%i.length],d=L(r,a,l),p=L(r,a,h);if(d>=0&&o.push(l),d>=0!=p>=0){let x=d/(d-p);o.push([l[0]+(h[0]-l[0])*x,l[1]+(h[1]-l[1])*x])}}}return o}function Ye(t){let e=t.slice().sort((r,a)=>r[0]-a[0]||r[1]-a[1]);if(e.length<3)return e;let o=[],n=[];for(let r of e){for(;o.length>=2&&L(o[o.length-2],o[o.length-1],r)<=0;)o.pop();o.push(r)}for(let r=e.length-1;r>=0;r--){let a=e[r];for(;n.length>=2&&L(n[n.length-2],n[n.length-1],a)<=0;)n.pop();n.push(a)}return o.slice(0,-1).concat(n.slice(0,-1))}function zt(t,e,o,n){let r=3*t,a=3*(o-t)-r,i=1-r-a,s=3*e,l=3*(n-e)-s,h=1-s-l,d=y=>((i*y+a)*y+r)*y,p=y=>((h*y+l)*y+s)*y,x=y=>(3*i*y+2*a)*y+r;return y=>{if(y<=0)return 0;if(y>=1)return 1;let f=y;for(let P=0;P<8;P++){let c=d(f)-y,m=x(f);if(Math.abs(c)<1e-7||Math.abs(m)<1e-7)break;f-=c/m}if(f<0||f>1||Math.abs(d(f)-y)>1e-5){let P=0,c=1;for(let m=0;m<30;m++)f=(P+c)/2,d(f)<y?P=f:c=f}return p(f)}}var C={linear:t=>t,in:zt(.55,.055,.675,.19),out:zt(.23,1,.32,1),inOut:zt(.645,.045,.355,1),fold:zt(.77,0,.175,1),drop:t=>1-Math.exp(-7.5*t)*Math.cos(8.5*t)*(1-t),flap:t=>Math.sin(t*Math.PI*4)*(1-t*.6),breathe:t=>(1-Math.cos(2*Math.PI*Math.min(1,Math.max(0,t))))/2},ht={rx:0,ry:0,rz:0,spin:0,tx:0,ty:0,tz:0,s:1,o:1},le=Object.keys(ht);var he=.0015,ut=41,Je=.9;function Dt(t,e,o){return t.rot?W(t.p,t.u,t.free>=0?o:t.script?t.script(e):t.angle*e):ct(t.u[0]*e,t.u[1]*e,t.u[2]*e)}function qn(t){let e=[t[0],t[4],t[8],0,t[1],t[5],t[9],0,t[2],t[6],t[10],0];return e[3]=-(e[0]*t[3]+e[1]*t[7]+e[2]*t[11]),e[7]=-(e[4]*t[3]+e[5]*t[7]+e[6]*t[11]),e[11]=-(e[8]*t[3]+e[9]*t[7]+e[10]*t[11]),e}var Ft=t=>Math.abs(t[10])>1-1e-6&&Math.abs(t[11])<1e-5;function Kn(t){if(Math.abs(t[10])<1-1e-4||Math.abs(t[11])>.001)return t;let e=t[10]>0?1:-1,o=Math.atan2(t[4],t[0]),n=Math.cos(o),r=Math.sin(o);for(let a of[0,1,-1])Math.abs(n-a)<1e-12&&(n=a),Math.abs(r-a)<1e-12&&(r=a);return[n,-e*r,0,t[3],r,e*n,0,t[7],0,0,e,0]}function Bt(t,e){let o=Math.min(1,Math.max(0,e))*(t.length-1),n=Math.min(t.length-2,Math.floor(o));return t[n]+(t[n+1]-t[n])*(o-n)}function Wn(t,e){let o=e.length,n=t.map((r,a)=>[...r,e[a]]);for(let r=0;r<o;r++){let a=r;for(let s=r+1;s<o;s++)Math.abs(n[s][r])>Math.abs(n[a][r])&&(a=s);[n[r],n[a]]=[n[a],n[r]];let i=n[r][r]||1e-18;for(let s=0;s<o;s++){if(s===r)continue;let l=n[s][r]/i;for(let h=r;h<=o;h++)n[s][h]-=l*n[r][h]}}return n.map((r,a)=>r[o]/(r[a]||1e-18))}function Yn(t,e){let o=t.slice(),n=e(o),r=n.reduce((i,s)=>i+s*s,0),a=o.length;for(let i=0;i<60&&r>1e-24;i++){let s=[];for(let f=0;f<a;f++){let P=o.slice();P[f]+=1e-7,s.push(e(P).map((c,m)=>(c-n[m])/1e-7))}let l=s.map(f=>s.map(P=>f.reduce((c,m,v)=>c+m*P[v],0))),h=s.map(f=>-f.reduce((P,c,m)=>P+c*n[m],0)),d=1e-10+1e-8*Math.max(...l.map((f,P)=>f[P]));l.forEach((f,P)=>f[P]+=d);let p=Wn(l,h),x=1,y=!1;for(let f=0;f<12;f++){let P=o.map((v,M)=>v+x*p[M]),c=e(P),m=c.reduce((v,M)=>v+M*M,0);if(m<r){o=P,n=c,r=m,y=!0;break}x/=2}if(!y)break}return o}var V=class{constructor(e={},o=[[-1,-1],[1,-1],[1,1],[-1,1]]){this.steps=[];this.chords=[];this.nextId=1;this.pose={...ht,...e},this.faces=[{id:0,poly:lt(o),T:xt(),level:0,rank:0,hist:[]}]}step(e,o){let n=new Nt(this,e);return o?.(n),n.finish(),this}compile(e={}){let o=[],n=new Map,r=f=>{let P=`${Math.round(f[0]*1e7)},${Math.round(f[1]*1e7)}`,c=n.get(P);return c===void 0&&(c=o.length,o.push(f),n.set(P,c)),c},a=this.faces.map(f=>{let P=lt(f.poly).map(r);return P.filter((c,m)=>c!==P[(m+1)%P.length])});a=a.map(f=>{let P=[];for(let c=0;c<f.length;c++){let m=f[c],v=f[(c+1)%f.length];P.push(m);let M=o[m],u=o[v],b=u[0]-M[0],g=u[1]-M[1],w=b*b+g*g,k=[];for(let F=0;F<o.length;F++){if(F===m||F===v)continue;let E=o[F],S=((E[0]-M[0])*b+(E[1]-M[1])*g)/w;S<=1e-9||S>=1-1e-9||Math.abs(L(M,u,E))/Math.sqrt(w)<1e-7&&k.push([S,F])}k.sort((F,E)=>F[0]-E[0]);for(let[,F]of k)P.push(F)}return P});let i=[],s=new Map,l=a.map((f,P)=>f.map((c,m)=>{let v=f[(m+1)%f.length],M=c<v?`${c}|${v}`:`${v}|${c}`,u=s.get(M);return u===void 0&&(u=i.length,s.set(M,u),i.push({a:c,b:v,faces:[],born:1/0})),i[u].faces.push(P),u})),h=(f,P)=>{let c=P.b[0]-P.a[0],m=P.b[1]-P.a[1],v=c*c+m*m,M=((f[0]-P.a[0])*c+(f[1]-P.a[1])*m)/v;return M>-1e-7&&M<1+1e-7&&Math.abs(L(P.a,P.b,f))/Math.sqrt(v)<1e-7};for(let f of i)if(!(f.faces.length<2))for(let P of this.chords)P.step<f.born&&h(o[f.a],P)&&h(o[f.b],P)&&(f.born=P.step);let d=[],p=0,x=0,y=0;for(let f of this.steps)d.push(p),f.phase==="intro"&&(x=p+f.duration),f.phase!=="outro"&&(y=p+f.duration),p+=f.duration;return{steps:this.steps,starts:d,duration:p,content:[x,y],pose:this.pose,verts:o,faces:a,tracks:this.faces.map(f=>f.hist),edges:i,faceEdges:l,colourDown:e.colourDown}}},Nt=class{constructor(e,o){this.F=e;this.meta=o;this.joints=[];this.chains=new Map;this.pins=[];this.layers=[];this.nFree=0}get index(){return this.F.steps.length}info(e){let o=kt(e.poly),n=N(e.T,o[0],o[1],0);return{sheet:o,model:[n[0],n[1]],flat:Ft(e.T),up:e.T[10]>0}}select(e){return this.F.faces.filter(o=>!e||e(this.info(o)))}split(e,o,n){let r=new Set(e),a=[],i=[];for(let s of this.F.faces){if(!r.has(s)){i.push(s);continue}if(!Ft(s.T)){i.push(s),a.push(s);continue}let l=qn(s.T),h=N(l,o[0],o[1],0),d=N(l,n[0],n[1],0),{left:p,right:x,chord:y}=We(s.poly,[h[0],h[1]],[d[0],d[1]]);if(!p||!x||Math.abs(at(p))<1e-10||Math.abs(at(x))<1e-10){i.push(s),a.push(s);continue}y&&this.F.chords.push({a:y[0],b:y[1],step:this.index});let f=this.chains.get(s);this.chains.delete(s);for(let P of[p,x]){let c={...s,id:this.F.nextId++,poly:P,hist:s.hist.slice()};f&&this.chains.set(c,f),i.push(c),a.push(c)}}return this.F.faces=i,a}rot(e,o,n,r={}){let a=[e[0],e[1],e[2]??0],i=[o[0],o[1],o[2]??0],s=-1;n==="free"&&(s=r.free??this.nFree,this.nFree=Math.max(this.nFree,s+1));let l=typeof n=="function"?h=>n(h)*H:void 0;return this.joints.push({rot:!0,p:a,u:vt([i[0]-a[0],i[1]-a[1],i[2]-a[2]]),angle:typeof n=="number"?n*H:l?l(1):0,free:s,at:r.at??[0,1],ease:l?"linear":r.ease??"fold",script:l}),this.joints.length-1}hinge(e,o,n,r=1,a=180,i={}){return this.rot(e,o,a*r*Math.sign(L(e,o,n)),i)}swing(e,o,n={}){return this.rot([e[0],e[1],0],[e[0],e[1],1],o,n)}reverse(e,o,n){let[r,a]=o,i=this.split(e.filter(S=>Ft(S.T)),r,a),s=Math.sign(L(r,a,n.side)),l=i.filter(S=>Math.sign(L(r,a,this.info(S).model))===s),[h,d]=n.axis,p=Ke(h,d,r,a);if(!p)throw new Error("reverse: the axis runs parallel to the crease");let x=Math.atan2(d[1]-h[1],d[0]-h[0]),f=2*(Math.atan2(a[1]-r[1],a[0]-r[0])-x);f=Math.atan2(Math.sin(f),Math.cos(f))/H;let[P,c]=n.at??[0,1],m=S=>P+(c-P)*S,v=S=>n.front(this.info(S)),M=l.filter(v),u=l.filter(S=>!v(S)),b=l.length&&Math.sign(L(h,d,this.info(l[0]).model))||1,g=n.book?[[M,180*b],[u,-180*b]]:[[l,180]];this.restack=n.roll==="last"?[m(.6),c]:[P,m(.35)];for(let[S,A]of g)if(n.roll==="last"){let j=Math.cos(f*H),_=Math.sin(f*H),R=K=>[p[0]+j*(K[0]-p[0])-_*(K[1]-p[1]),p[1]+_*(K[0]-p[0])+j*(K[1]-p[1])],G=this.swing(p,f,{at:[P,m(.8)],ease:n.ease??"inOut"}),z=this.rot(R(h),R(d),A,{at:[m(.6),c],ease:"inOut"});this.attach(S,G,z)}else{let j=this.rot(h,d,A,{at:[P,m(.35)],ease:"inOut"}),_=this.swing(p,f,{at:[m(.2),c],ease:n.ease??"inOut"});this.attach(S,j,_)}let w=new Set(l),k=this.F.faces.filter(S=>!w.has(S)),F=k.filter(v),E=k.filter(S=>!v(S));return n.kind==="inside"?(this.layer(F,[...M,...u]),this.layer(M,u),this.layer([...M,...u],E)):(this.layer(M,k),this.layer(k,u),this.layer(M,u)),l}move(e,o={}){return this.joints.push({rot:!1,p:[0,0,0],u:e,angle:0,free:-1,at:o.at??[0,1],ease:o.ease??"fold"}),this.joints.length-1}fold(e,o,n){let r=this.split(this.select(n.where).filter(s=>Ft(s.T)),e,o),a=Math.sign(L(e,o,n.side)),i=r.filter(s=>Math.sign(L(e,o,this.info(s).model))===a);return this.attach(i,this.hinge(e,o,n.side,n.toward??1,n.deg??180,n)),i}attach(e,...o){for(let n of e)this.chains.set(n,[...this.chains.get(n)??[],...o])}pin(e,o,n){this.pins.push({a:e,b:o,pt:n})}layer(e,o){this.layers.push({above:e,below:o})}compose(e,o,n,r=!1){let a=xt();for(let i of e){let s=this.joints[i],l=r&&this.nFree===0?C[s.ease](o):o;a=O(Dt(s,l,n[s.free]??0),a)}return a}place(e,o,n,r=!1){let a=this.chains.get(e);return a?O(this.compose(a,o,n,r),e.T):e.T}solve(){if(!this.nFree)return[];let e=Array.from({length:this.nFree},()=>new Float64Array(ut)),o=new Array(this.nFree).fill(0);for(let n=0;n<ut;n++){let r=n/(ut-1);o=Yn(o,a=>{let i=[];for(let{a:s,b:l,pt:h}of this.pins){let d=N(this.place(s,r,a),h[0],h[1],0),p=N(this.place(l,r,a),h[0],h[1],0);i.push(d[0]-p[0],d[1]-p[1],d[2]-p[2])}return i}),o.forEach((a,i)=>e[i][n]=a)}for(let n of e){let r=Math.round(n[ut-1]/(Math.PI/2))*(Math.PI/2);Math.abs(n[ut-1]-r)<.001&&(n[ut-1]=r)}return e}finish(){let e=this.F,o=this.solve(),n=u=>o.map(b=>Bt(b,u)),r=n(1),a=n(Je),i=new Map(e.faces.map(u=>[u,Kn(this.place(u,1,r,!0))])),s=[];for(let u of e.faces){let b=i.get(u);if(!Ft(b))continue;let g=lt(u.poly.map(E=>{let S=N(b,E[0],E[1],0);return[S[0],S[1]]})),w=[1/0,1/0,-1/0,-1/0];for(let[E,S]of g)w[0]=Math.min(w[0],E),w[1]=Math.min(w[1],S),w[2]=Math.max(w[2],E),w[3]=Math.max(w[3],S);let k=this.chains.get(u),F=O(ct(0,0,u.rank*1e-7),u.T);s.push({f:u,poly:g,box:w,moved:!!k,Tn:k?O(this.compose(k,Je,a,!0),F):F})}let l=new Map;for(let{above:u,below:b}of this.layers)for(let g of u)for(let w of b)l.set(`${g.id}|${w.id}`,1),l.set(`${w.id}|${g.id}`,-1);let h=(u,b)=>{let g=u[10];return Math.abs(g)<.001?u[11]:u[11]-(u[2]*(b[0]-u[3])+u[6]*(b[1]-u[7]))/g},d=s.length,p=s.map(()=>[]),x=s.map(()=>[]),y=new Int32Array(d);for(let u=0;u<d;u++){let b=s[u];for(let g=u+1;g<d;g++){let w=s[g];if(b.box[2]<=w.box[0]+1e-9||w.box[2]<=b.box[0]+1e-9||b.box[3]<=w.box[1]+1e-9||w.box[3]<=b.box[1]+1e-9)continue;let k=Ct(b.poly,w.poly);if(k.length<3||Math.abs(at(k))<1e-8)continue;let F=l.get(`${b.f.id}|${w.f.id}`);if(F===void 0)if(!b.moved&&!w.moved)F=b.f.rank>w.f.rank||b.f.rank===w.f.rank&&b.f.id>w.f.id?1:-1;else{let A=kt(k);F=h(b.Tn,A)>h(w.Tn,A)?1:-1}let[E,S]=F>0?[g,u]:[u,g];p[E].push(S),x[S].push(E),y[S]++}}let f=[],P=new Uint8Array(d);for(let u=0;u<d;u++){let b=-1;for(let g=0;g<d;g++)P[g]||y[g]>0||(b<0||s[g].f.rank<s[b].f.rank||s[g].f.rank===s[b].f.rank&&s[g].f.id<s[b].f.id)&&(b=g);if(b<0)for(let g=0;g<d;g++)!P[g]&&(b<0||s[g].f.rank<s[b].f.rank)&&(b=g);P[b]=1,f.push(b);for(let g of p[b])y[g]--}let c=new Int32Array(d),m=new Int32Array(d);f.forEach((u,b)=>m[u]=b);for(let u of f)for(let b of x[u])m[b]<m[u]&&(c[u]=Math.max(c[u],c[b]+1));let v=new Map,M=new Map;f.forEach((u,b)=>{v.set(s[u].f,c[u]),M.set(s[u].f,b)});for(let u of e.faces){let b=v.get(u)??u.level;u.hist.push({T:u.T,chain:this.chains.get(u)??[],z0:u.level*he,z1:b*he}),u.T=i.get(u),u.level=b,u.rank=M.get(u)??u.rank}e.steps.push({...this.meta,joints:this.joints,table:o,restack:this.restack})}};var $t=t=>Math.abs(t[10])>1-1e-6,St=class{constructor(e){this.model=e;let o=e.faces.length;this.anchors=e.steps.map(()=>new Array(o)),this.endsFlat=e.steps.map(()=>new Uint8Array(o));for(let n=0;n<o;n++){let r=e.tracks[n][0].T;e.steps.forEach((a,i)=>{let s=e.tracks[n][i];$t(s.T)&&(r=s.T),this.anchors[i][n]=r;let h=e.tracks[n][i+1]?.T;if(!h){h=s.T;for(let d of s.chain)h=O(Dt(a.joints[d],1,a.table.length?Bt(a.table[a.joints[d].free]??new Float64Array(2),1):0),h)}this.endsFlat[i][n]=$t(h)?1:0})}this.groupIds=e.steps.map((n,r)=>{let a=new Map;return Int32Array.from(e.tracks.map(i=>{let s=i[r].chain.join(","),l=a.get(s);return l===void 0&&(l=a.size,a.set(s,l)),l}))})}get duration(){return this.model.duration}stepAt(e){let o=this.model.starts,n=0;for(;n<o.length-1&&o[n+1]<=e;)n++;return n}evaluate(e,o){let n=this.model,r=n.faces.length,a=o??{T:new Array(r),z:new Float64Array(r),lift:new Float64Array(3*r),group:new Int32Array(r),pose:{...ht},step:0,local:0};e=ot(e,0,n.duration);let i=this.stepAt(e),s=n.steps[i],l=s.duration>0?ot((e-n.starts[i])/s.duration):1,h=C[s.ease??"fold"](l),d=s.table.length>0,p=s.table.map(u=>Bt(u,h)),x=s.joints.map(u=>{let b=d?h:C[u.ease](ot((l-u.at[0])/Math.max(1e-6,u.at[1]-u.at[0])));return Dt(u,b,p[u.free]??0)}),y=new Map,[f,P]=s.restack??[0,1],c=C.inOut(ot((l-f)/Math.max(1e-6,P-f)));for(let u=0;u<r;u++){let b=n.tracks[u][i];if(b.chain.length){let g=b.chain.join(","),w=y.get(g);if(!w){w=xt();for(let k of b.chain)w=O(x[k],w);y.set(g,w)}a.T[u]=O(w,b.T)}else a.T[u]=b.T;a.z[u]=ce(b.z0,b.z1,c),this.lift(a,u,i,b.chain.length>0)}a.group.set(this.groupIds[i]);let m=C[s.ease??"inOut"](l),v=Math.sin(Math.PI*l),M=this.poseAt(i);for(let u of le){let b=s.pose?.[u];a.pose[u]=(b===void 0?M[u]:ce(M[u],b,m))+(s.arc?.[u]??0)*v}if(s.path){let u=s.path(l);for(let b of le)a.pose[b]+=u[b]??0}return a.step=i,a.local=l,a}lift(e,o,n,r){let a=this.model.tracks[o][n],i=e.T[o],s=e.lift,l=3*o,h=$t(a.T)&&this.endsFlat[n][o];if(!r&&$t(i)||r&&h){s[l]=0,s[l+1]=0,s[l+2]=e.z[o];return}let d=this.anchors[n][o],p=d[8],x=d[9],y=d[10],f=i[0]*p+i[1]*x+i[2]*y,P=i[4]*p+i[5]*x+i[6]*y,c=i[8]*p+i[9]*x+i[10]*y,m=Math.min(1,Math.max(0,(.3-c)/.2)),v=e.z[o];s[l]=m*a.z0*f,s[l+1]=m*a.z0*P,s[l+2]=(1-m)*v+m*a.z0*c}poseAt(e){if(!this.poses){let o={...this.model.pose};this.poses=this.model.steps.map(n=>{let r=o;return o={...o,...n.pose},r})}return this.poses[e]}};var J=Math.SQRT1_2,Xe=[0,J],I=[0,-J],Ze=[J,0],tn=[-J,0],ge=1-J,D=[Math.SQRT2-1,ge],Q=[1-Math.SQRT2,ge],cn=t=>[t*Math.sin(Math.PI/16),-J+Math.cos(Math.PI/16)],fe=cn(1),Jn=cn(-1),en=(()=>{let t=[0,2-J],e=[fe[0]-I[0],fe[1]-I[1]],o=[t[0]-D[0],t[1]-D[1]],n=e[0]*o[1]-e[1]*o[0],r=((D[0]-I[0])*o[1]-(D[1]-I[1])*o[0])/n;return I[1]+e[1]*r})(),jt=.263,nn=9*Math.PI/180,on=.26,Xn=-55*Math.PI/180;function rn(t,[e,o]){let n=[o[0]-e[0],o[1]-e[1]],r=((t[0]-e[0])*n[0]+(t[1]-e[1])*n[1])/(n[0]*n[0]+n[1]*n[1]);return[2*(e[0]+n[0]*r)-t[0],2*(e[1]+n[1]*r)-t[1]]}var me=([t,e])=>t>0&&e>0,Zn=([t,e])=>t<0&&e>0,to=([t,e])=>t>0&&e<0,be=([t,e])=>t<0&&e<0,Gt=([t,e])=>e>Math.abs(t),Et=([t,e])=>t>Math.abs(e),ye=([t,e])=>e<-Math.abs(t),Pe=([t,e])=>t<-Math.abs(e),an=t=>t>0?Gt:Pe,sn=t=>t>0?Et:ye,ue=t=>t>0?me:be,eo=t=>t>0?e=>Gt(e)&&e[0]<0:e=>Pe(e)&&e[1]>0,no=t=>t>0?e=>Et(e)&&e[1]<0:e=>ye(e)&&e[0]>0,de=t=>t>0?[0,1]:[-1,0],pe=t=>t>0?[1,0]:[0,-1],Y=t=>e=>t(e.sheet),dt=(t,e,o)=>(e[0]-t[0])*(o[1]-t[1])-(e[1]-t[1])*(o[0]-t[0])>0;function pt(t,e){let o=t.find(n=>n.poly.some(r=>Math.hypot(r[0]-e[0],r[1]-e[1])<1e-7));if(!o)throw new Error(`crane: no face holds sheet point ${e}`);return o}function Me(){let t=new V({rx:-30,ry:12,ty:.7,tz:.5,o:0}),e=(c,m,v,M,u,b,g={})=>{let w=[];t.step({diagram:c,label:m,duration:.7,...g},k=>{w=k.fold(v,M,{side:u,toward:b,at:[.06,1]})}),t.step({diagram:c,label:"Unfold",duration:.42,ease:"inOut"},k=>{k.attach(w,k.hinge(v,M,u,-b,180,{ease:"inOut"}))})};t.step({diagram:1,label:"Start with a square",duration:1.1,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}}),e(2,"Fold in half diagonally",[-1,1],[1,-1],[1,1],1),e(2,"Fold the other diagonal",[-1,-1],[1,1],[1,-1],1),t.step({diagram:3,label:"Turn the paper over",duration:.8,ease:"inOut",pose:{ry:192},arc:{tz:.35}}),e(3,"Fold in half",[0,-1],[0,1],[-.5,0],-1),e(3,"Fold in half the other way",[-1,0],[1,0],[0,.5],-1),t.step({diagram:4,label:"Collapse into a square base",duration:1.4,ease:"inOut",pose:{s:1.22}},c=>{let m=[0,0],v=c.hinge(m,[0,1],[-.3,.8],-1),M=c.rot(m,[-1,1],"free",{free:0}),u=c.hinge(m,[-1,0],[-.8,-.3],-1),b=c.hinge(m,[0,-1],[.3,-.8],-1),g=c.rot(m,[1,-1],"free",{free:0}),w=c.rot([0,0,0],[0,0,1],-135),k=c.move([0,J,0]),F=A=>c.select(Y(A)),E=F(A=>Et(A)&&A[1]>0),S=F(A=>Et(A)&&A[1]<0);c.attach(F(me),w,k),c.attach(F(A=>Gt(A)&&A[0]<0),v,w,k),c.attach(F(A=>Pe(A)&&A[1]>0),M,v,w,k),c.attach(F(be),u,M,v,w,k),c.attach(F(A=>ye(A)&&A[0]>0),b,u,M,v,w,k),c.attach(S,g,b,u,M,v,w,k),c.pin(pt(S,[1,0]),pt(E,[1,0]),[1,0])});let o=(c,m)=>{let v=m?.8:1,M=[],u=[],b=[];t.step({diagram:5,label:m?"Repeat: edges to the centre":"Fold the edges to the centre",duration:.95*v},g=>{M=g.fold(I,D,{where:Y(an(c)),side:Ze,toward:c,at:[0,.72]}),u=g.fold(I,Q,{where:Y(sn(c)),side:tn,toward:c,at:[.28,1]})}),t.step({diagram:6,label:m?"Fold the top down":"Fold the top triangle down",duration:.65*v},g=>{b=g.fold(Q,D,{side:Xe,toward:c})}),t.step({diagram:6,label:"Unfold the last three folds",duration:.8*v,ease:"inOut"},g=>{g.attach(b,g.hinge(Q,D,Xe,-c,180,{at:[0,.6],ease:"inOut"})),g.attach(M,g.hinge(I,D,Ze,-c,180,{at:[.3,1],ease:"inOut"})),g.attach(u,g.hinge(I,Q,tn,-c,180,{at:[.3,1],ease:"inOut"}))}),t.step({diagram:7,label:m?"Petal fold the back":"Petal fold: lift the bottom point",duration:1.3*v,ease:"inOut",pose:{s:1.2,ty:-.33}},g=>{let w=(T,Tt)=>g.select(nt=>T(nt.sheet)&&nt.model[1]<ge&&Tt(nt.model)),k=T=>dt(I,D,T)&&!dt(I,Q,T),F=w(ue(c),k),E=w(ue(c),T=>!dt(I,D,T)),S=w(ue(c),T=>dt(I,Q,T)),A=w(eo(c),T=>!dt(I,D,T)),j=w(no(c),T=>dt(I,Q,T)),_=g.hinge(Q,D,I,c),R=g.rot(I,D,"free"),G=g.rot(I,Q,"free"),z=g.rot(I,D,"free"),K=g.rot(I,Q,"free");g.attach(F,_),g.attach(E,R,_),g.attach(S,G,_),g.attach(A,z),g.attach(j,K),g.pin(pt(E,de(c)),pt(A,de(c)),de(c)),g.pin(pt(S,pe(c)),pt(j,pe(c)),pe(c))})};o(-1,!1),t.step({diagram:7,label:"Turn over",duration:.8,ease:"inOut",pose:{ry:372},arc:{tz:.3}}),o(1,!0);let n=(c,m,v)=>t.step({diagram:m,label:v,duration:1,ease:"inOut",pose:{s:1.3,ty:-.36}},M=>{M.fold(I,fe,{where:Y(an(c)),side:[.35,.1],toward:c,at:[0,.7]}),M.fold(I,Jn,{where:Y(sn(c)),side:[-.35,.1],toward:c,at:[.3,1]})});n(1,8,"Narrow the legs"),t.step({diagram:9,label:"Turn over",duration:.8,ease:"inOut",pose:{ry:552},arc:{tz:.3}}),n(-1,9,"Narrow the other side");let r=Y(c=>Gt(c)||Et(c)),a=c=>[I,[c*.097,jt]],i=c=>[[0,jt],[c*Math.cos(nn),jt-Math.sin(nn)]],s=(c,m,v,M)=>{let u=[];return t.step({diagram:c,label:m,duration:1,ease:"inOut",pose:{s:1.45,ty:-.95}},b=>{u=b.reverse(b.select(g=>v(g.sheet)&&g.flat&&g.model[1]<jt),i(M),{side:I,axis:a(M),front:r,kind:"inside"})}),()=>u},l=s(10,"Reverse fold the neck up",Zn,1);s(11,"Reverse fold the tail up",to,-1);let h=rn(I,i(1)),d=rn(a(1)[1],i(1)),p=[],x=[],y=[-1,en],f=[1,en],P=[0,1.2];return t.step({diagram:12,label:"Fold the wings down",duration:.9,ease:"inOut",pose:{s:1.55,ty:-.8}},c=>{p=c.fold(y,f,{where:Y(m=>me(m)&&m[0]+m[1]>2-Math.SQRT2),side:P,toward:1,at:[0,.7]}),x=c.fold(y,f,{where:Y(m=>be(m)&&m[0]+m[1]<Math.SQRT2-2),side:P,toward:-1,at:[.3,1]})}),t.step({diagram:13,label:"Reverse fold the head",duration:.8,ease:"inOut"},c=>{let m=h[0]-d[0],v=h[1]-d[1],M=Math.hypot(m,v),u=Math.atan2(v,m),b=[h[0]-m/M*on,h[1]-v/M*on],g=(u+Xn)/2,w=[b,[b[0]+Math.cos(g),b[1]+Math.sin(g)]];c.reverse(l(),w,{side:h,axis:[d,h],front:r,kind:"inside"})}),t.step({diagram:14,label:"Spread the wings",duration:1.5,ease:"inOut",pose:{ry:585,rx:-14,s:1.7,ty:-.9}},c=>{c.attach(p,c.hinge(y,f,P,-1,95,{ease:"inOut"})),c.attach(x,c.hinge(y,f,P,1,95,{ease:"inOut"}))}),t.step({diagram:14,label:"Finished crane",duration:.9,ease:"inOut"}),t.step({diagram:14,label:"Fly",duration:1,phase:"outro",ease:"in",pose:{ty:.7,tx:-.6,tz:.8,s:1.5,o:0}},c=>{c.attach(p,c.hinge(y,f,P,1,28,{ease:"flap"})),c.attach(x,c.hinge(y,f,P,-1,28,{ease:"flap"}))}),t.compile()}var B=Math.SQRT1_2,X=[0,1],un=Math.tan(Math.PI/8),oo=Math.tan(Math.PI/16),ro=[-B,1-B/un],ao=[B,1-B/un],Ut=[-2*oo,-1],Ht=.62,ln=.42,hn=50*Math.PI/180,Qt=[Math.cos(hn),Math.sin(hn)],Z=[-Qt[1],Qt[0]];function so(t){if(t<Ht){let o=2*Math.PI*C.inOut(t/Ht),n=Math.cos(o),r=Math.sin(o),a=[Z[0]*n-Z[1]*r,Z[0]*r+Z[1]*n],i=(1-n)/2;return{tx:ln*(Z[0]-a[0]-Z[0]*i),ty:ln*(Z[1]-a[1]-Z[1]*i),spin:o*180/Math.PI,rz:14*Math.sin(o)}}let e=C.in((t-Ht)/(1-Ht));return{tx:2.6*e*Qt[0],ty:2.6*e*Qt[1],spin:360,s:-.35*e,o:-e}}function xe(){let t=new V({rx:-30,ry:12,ty:.7,tz:.5,o:0},[[-B,-1],[B,-1],[B,1],[-B,1]]);t.step({diagram:1,label:"Start with a sheet of paper",duration:1,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}});let e=[];t.step({diagram:2,label:"Fold in half lengthwise",duration:.65},r=>{e=r.fold([0,-1],[0,1],{side:[.3,0],toward:1,at:[.06,1]})}),t.step({diagram:2,label:"Unfold",duration:.4,ease:"inOut"},r=>{r.attach(e,r.hinge([0,-1],[0,1],[.3,0],-1,180,{ease:"inOut"}))}),t.step({diagram:3,label:"Fold the top corners to the centre",duration:.95},r=>{r.fold(X,[-B,1-B],{side:[-B+.05,.98],toward:1,at:[0,.7]}),r.fold(X,[B,1-B],{side:[B-.05,.98],toward:1,at:[.3,1]})}),t.step({diagram:4,label:"Fold the edges to the centre again",duration:.95,pose:{s:1.05}},r=>{r.fold(X,ro,{side:[-.65,.2],toward:1,at:[0,.7]}),r.fold(X,ao,{side:[.65,.2],toward:1,at:[.3,1]})}),t.step({diagram:5,label:"Fold the plane in half",duration:1,ease:"inOut",pose:{rz:-90,s:1.25,ty:-.3,tx:0}},r=>{r.fold([0,-1],[0,1],{side:[.3,0],toward:-1})});let o=[],n=[];return t.step({diagram:6,label:"Fold the wings down",duration:1,ease:"inOut"},r=>{o=r.fold(X,Ut,{where:a=>a.sheet[0]<0,side:[-.6,-.8],toward:1,at:[0,.65]}),n=r.fold(X,Ut,{where:a=>a.sheet[0]>0,side:[-.6,-.8],toward:-1,at:[.35,1]})}),t.step({diagram:7,label:"Open the wings",duration:1.3,ease:"inOut",pose:{rx:-30,ry:90,rz:0,spin:-40,s:1.25,ty:0,tx:0}},r=>{r.attach(o,r.hinge(X,Ut,[-.6,-.8],-1,82,{ease:"inOut"})),r.attach(n,r.hinge(X,Ut,[-.6,-.8],1,82,{ease:"inOut"}))}),t.step({diagram:7,label:"Ready to fly",duration:.6,ease:"inOut"}),t.step({diagram:7,label:"Fly",duration:2.1,phase:"outro",ease:"linear",path:so}),t.compile({colourDown:!0})}var At=5,we=2/At,st=(At-1)/2,io=84,co=6,dn=t=>[[-1+t*we,-1],[-1+t*we,1]];function ve(){let t=new V({rx:-42,ry:28,ty:.55,tz:.4,o:0});t.step({diagram:1,label:"Start with a square",duration:.6,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1}}),t.step({diagram:2,label:"Crease the pleats",duration:.01},e=>{for(let o=1;o<At;o++)e.split(e.select(),...dn(o))});for(let e=0;e<co;e++)t.step({diagram:2,label:"Pleat",duration:1.45,ease:"breathe"},o=>{let n=[];for(let a=1;a<At;a++){let[i,s]=dn(a),l=a>st?1:-1,h=[i[0]+.1*l,0],d=.16*Math.abs(a-(st+.5))/st;n[a]=o.hinge(i,s,h,a%2?1:-1,io,{at:[d,.84+d],ease:"breathe"})}let r=a=>o.select(i=>Math.floor((i.sheet[0]+1)/we)===a);for(let a=0;a<At;a++){if(a===st)continue;let i=[];if(a>st)for(let s=a;s>st;s--)i.push(n[s]);else for(let s=a+1;s<=st;s++)i.push(n[s]);o.attach(r(a),...i)}});return t.step({diagram:2,label:"Done",duration:.5,phase:"outro",ease:"in",pose:{o:0,s:.92}}),t.compile()}var lo=[{label:"Fold the top corner down",line:[[1,0],[0,1]],corner:[1,1]},{label:"Fold the bottom corner up",line:[[-1,0],[0,-1]],corner:[-1,-1]},{label:"Fold the right corner in",line:[[0,-1],[1,0]],corner:[1,-1]},{label:"Fold the left corner in",line:[[0,1],[-1,0]],corner:[-1,1]}];function ke(){let t=new V({rx:-26,ry:8,rz:45,s:.92,ty:.55,tz:.4,o:0});return t.step({diagram:1,label:"Start with a square",duration:.7,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1}}),lo.forEach(({label:e,line:o,corner:n},r)=>{let a=r===3?{s:1.3}:r===1?{s:1.08}:void 0;t.step({diagram:r+2,label:e,duration:.6,pose:a},i=>{i.fold(o[0],o[1],{side:n,toward:1,at:[.05,1]})})}),t.step({diagram:5,label:"Sealed",duration:.7,ease:"inOut",arc:{s:-.05}}),t.step({diagram:5,label:"Into the inbox",duration:.6,phase:"outro",ease:"in",pose:{ty:-.5,s:1,o:0}}),t.compile({colourDown:!0})}var ho=-.3,ft=-.65,pn=ft-ho,uo=t=>({rz:3.5*Math.sin(t*Math.PI*4),ty:.025*Math.sin(t*Math.PI*4+1.2)});function Fe(){let t=new V({rx:-24,ry:190,ty:.6,tz:.4,o:0});return t.step({diagram:1,label:"Start with a square",duration:.8,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}}),t.step({diagram:2,label:"Fold in half diagonally",duration:.8},e=>{e.fold([-1,-1],[1,1],{side:[-1,1],toward:-1,at:[.05,1]})}),t.step({diagram:3,label:"Fold the bottom up for the hull",duration:.8,pose:{s:1.1,ty:.12}},e=>{e.fold([-1,ft],[1,ft],{side:[0,-.9],toward:-1})}),t.step({diagram:4,label:"Fold the stern corner behind",duration:.7,pose:{s:1.2,ty:.18}},e=>{e.fold([1,ft-pn*.62],[1+pn*.62,ft],{side:[1,ft],toward:1})}),t.step({diagram:5,label:"Afloat",duration:2.4,ease:"linear",path:uo}),t.step({diagram:5,label:"Sail away",duration:1,phase:"outro",ease:"in",pose:{tx:1.5,s:1.05,o:0},arc:{rz:-3}}),t.compile()}var q=.5,$=[0,.5],Ae=[-q,1],_e=[q,1],qt=[q,0],Kt=[-q,0],Ie=[-q,.5],Ve=[q,.5],fn=[0,0],Se=35,mn=28,po=25,bn=t=>{let e=(270+po)/2*Math.PI/180;return[-t*Math.cos(e),Math.sin(e)]};function Wt([t,e]){if(e<0)return"body";let o=t-$[0],n=e-$[1];return n>Math.abs(o)?"top":n<-Math.abs(o)?"bottom":o<0?n>0?"upL":"lowL":n>0?"upR":"lowR"}var mt=(...t)=>e=>t.includes(Wt(e.sheet)),Jt=t=>180*C.inOut(t),Mn=t=>{let e=Jt(t);return e>=180-1e-9?180:2*Math.atan(Math.tan(e/2*Math.PI/180)/Math.SQRT2)*180/Math.PI},tt=t=>[t[0],t[1],0],Yt=(t,e)=>[t[0]-e[0],t[1]-e[1],t[2]-e[2]],Ee=(t,e)=>t[0]*e[0]+t[1]*e[1]+t[2]*e[2],fo=(t,e)=>[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]],xn=t=>{let e=Math.hypot(t[0],t[1],t[2]);return[t[0]/e,t[1]/e,t[2]/e]},gn=(t,e,o,n)=>{let r=xn(Yt(tt(e),tt(t))),a=W(tt(t),r,o*Math.PI/180);return N(a,n[0],n[1],n[2])};function mo(t,e,o,n){let r=xn(Yt(tt(e),tt(t))),a=l=>{let h=Yt(l,tt(t)),d=Ee(h,r);return Yt(h,[r[0]*d,r[1]*d,r[2]*d])},i=a(o),s=a(n);return Math.atan2(Ee(r,fo(i,s)),Ee(i,s))*180/Math.PI}var yn=t=>e=>{let o=t<0?Ae:_e,n=t<0?Kt:qt,r=t<0?Ie:Ve,a=t<0?-1:1,i=gn($,[$[0]+1,$[1]],Mn(e),tt(o)),s=gn($,n,-a*Jt(e),i);return mo($,r,tt(o),s)},Pn=t=>{let e=t<.18?Math.sin(t/.18*Math.PI):0,o=t>.18?Math.min(1,(t-.18)/.62):0,n=t>.8?Math.sin((t-.8)/.2*Math.PI):0;return{ty:.5*Math.sin(o*Math.PI)-.03*e,rx:-14*Math.sin(o*Math.PI),s:-.05*(e+n)}},bo=t=>({ty:.45*Math.abs(Math.sin(t*Math.PI*2)),tz:.9*t,o:-Math.max(0,(t-.35)/.65)});function Oe(){let t=new V({rx:-28,s:.92,ty:.6,tz:.4,o:0},[[-q,-1],[q,-1],[q,1],[-q,1]]),e=(r,a,i,s,l,h)=>{let d=[];t.step({diagram:r,label:a,duration:.6},p=>{d=p.fold(i,s,{side:l,toward:h,at:[0,1]})}),t.step({diagram:r,label:"Unfold",duration:.38,ease:"inOut"},p=>{p.attach(d,p.hinge(i,s,l,-h,180,{ease:"inOut"}))})};t.step({diagram:1,label:"Start with a 1 : 2 rectangle",duration:.7,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}}),e(2,"Fold the corner to the far edge",_e,Kt,Ae,1),e(2,"And the other corner",Ae,qt,_e,1),e(3,"Fold the top behind",Ie,Ve,[0,.9],-1),t.step({diagram:4,label:"Collapse into a waterbomb base",duration:1.3,ease:"inOut",pose:{s:1.15,ty:-.25}},r=>{let a=r.rot($,Kt,p=>-Jt(p)),i=r.rot($,qt,p=>Jt(p)),s=r.rot($,[$[0]+1,$[1]],Mn),l=r.rot($,Ie,yn(-1)),h=r.rot($,Ve,yn(1)),d=p=>r.select(mt(p));r.attach(d("lowL"),a),r.attach(d("upL"),l,a),r.attach(d("lowR"),i),r.attach(d("upR"),h,i),r.attach(d("top"),s),r.layer(d("top"),[...d("upL"),...d("upR")]),r.layer([...d("upL"),...d("upR")],[...d("lowL"),...d("lowR")]),r.layer([...d("lowL"),...d("lowR")],d("bottom"))});let o=[];t.step({diagram:5,label:"Fold the front legs up",duration:1,pose:{s:1.25}},r=>{o=[...r.fold(fn,bn(-1),{where:mt("top","upL"),side:Kt,toward:1,at:[0,.7]}),...r.fold(fn,bn(1),{where:mt("top","upR"),side:qt,toward:1,at:[.3,1]})]}),t.step({diagram:7,label:"Fold the sides to the centre",duration:.9,pose:{s:1.3,ty:.05}},r=>{let a=r.fold([-.25,-1],[-.25,1],{where:mt("body","bottom","lowL"),side:[-.5,-.5],toward:1,at:[0,.7]}),i=r.fold([.25,-1],[.25,1],{where:mt("body","bottom","lowR"),side:[.5,-.5],toward:1,at:[.3,1]}),s=new Set(r.select());r.layer(o.filter(l=>s.has(l)),[...a,...i])}),t.step({diagram:8,label:"Fold the bottom up",duration:.8},r=>{r.fold([-1,-.5],[1,-.5],{where:mt("body"),side:[0,-1],toward:1})}),t.step({diagram:9,label:"Fold it back down in half",duration:.8},r=>{r.fold([-1,-.25],[1,-.25],{where:a=>Wt(a.sheet)==="body"&&a.sheet[1]<-.5,side:[0,0],toward:1})});let n=(r,a,i,s={})=>{let l=r.select(P=>Wt(P.sheet)==="body"&&P.sheet[1]<-.5&&P.sheet[1]>-.75),h=r.select(P=>Wt(P.sheet)==="body"&&P.sheet[1]<-.75),d=i*Math.PI/180,p=-.5+.25*Math.cos(d),x=.25*Math.sin(d),y=r.rot([-1,-.5,0],[1,-.5,0],a,s),f=r.rot([-1,p,x],[1,p,x],-a,s);r.attach(l,y),r.attach(h,f,y)};return t.step({diagram:10,label:"Turn over",duration:1,ease:"inOut",pose:{ry:200,rx:-62,rz:10,s:1.35,ty:.05},arc:{tz:.3}},r=>{n(r,Se,0,{ease:"inOut",at:[.4,1]})}),t.step({diagram:10,label:"Hop",duration:1,ease:"linear",path:Pn},r=>n(r,-mn,Se,{ease:"breathe",at:[0,.36]})),t.step({diagram:10,label:"Hop again",duration:1,ease:"linear",path:Pn},r=>n(r,-mn,Se,{ease:"breathe",at:[0,.36]})),t.step({diagram:10,label:"Hop away",duration:1.2,phase:"outro",ease:"linear",path:bo}),t.compile({colourDown:!0})}var _t=[0,-1],bt=(t,e,o=3)=>{let n=t*Math.PI/180;return[e*o*Math.sin(n),-1+o*Math.cos(n)]},wn=t=>t*Math.PI/180,vn=15,go=278,yo=11.25,kn=.29,Fn=.3;function Sn(t,[e,o]){let n=[o[0]-e[0],o[1]-e[1]],r=((t[0]-e[0])*n[0]+(t[1]-e[1])*n[1])/(n[0]*n[0]+n[1]*n[1]);return[2*(e[0]+n[0]*r)-t[0],2*(e[1]+n[1]*r)-t[1]]}var En=(t,e)=>[t,[t[0]+Math.cos(wn(e)),t[1]+Math.sin(wn(e))]];function Po(t,e){let o=0;for(let n=0;n<t.length;n++){let r=t[n],a=t[(n+1)%t.length],i=(a[0]-r[0])*(e[1]-r[1])-(a[1]-r[1])*(e[0]-r[0]);if(!(Math.abs(i)<1e-9)){if(o&&Math.sign(i)!==o)return!1;o=Math.sign(i)}}return!0}var Mo=t=>({ty:.03*Math.sin(t*Math.PI*2),rz:1.5*Math.sin(t*Math.PI*2+.8)});function Le(){let t=new V({rx:-20,ry:180,ty:.6,tz:.4,o:0},[[0,-1],[1,0],[0,1],[-1,0]]);t.step({diagram:1,label:"Start with a square",duration:.7,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}}),t.step({diagram:2,label:"Fold the edges to the centre",duration:.9},s=>{s.fold(_t,bt(22.5,-1),{side:[-1,0],toward:-1,at:[0,.7]}),s.fold(_t,bt(22.5,1),{side:[1,0],toward:-1,at:[.3,1]})}),t.step({diagram:3,label:"Turn over",duration:.7,ease:"inOut",pose:{ry:360},arc:{tz:.3}}),t.step({diagram:4,label:"Fold the edges to the centre again",duration:.9,pose:{s:1.1}},s=>{s.fold(_t,bt(11.25,-1),{side:bt(17,-1,.75),toward:1,at:[0,.7]}),s.fold(_t,bt(11.25,1),{side:bt(17,1,.75),toward:1,at:[.3,1]})});let e=[];t.step({diagram:5,label:"Fold the point up to the top",duration:.8,pose:{s:1.25,ty:-.3}},s=>{e=s.fold([-1,0],[1,0],{side:_t,toward:1}).map(l=>l.poly)});let o=s=>e.some(l=>Po(l,xo(s.poly)));t.step({diagram:6,label:"Fold in half",duration:.9,ease:"inOut",pose:{rz:90,rx:-10,s:1.5,tx:.62,ty:.2}},s=>{s.fold([0,-1],[0,1],{side:[.5,.5],toward:-1})});let n=s=>s.sheet[0]<0,r=En([0,kn],(90+vn)/2),a=[[0,kn],[0,1]],i=[];return t.step({diagram:7,label:"Pull the neck up",duration:1.1,ease:"inOut",pose:{rz:90-yo,s:1.6,tx:.34,ty:-.22}},s=>{i=s.reverse(s.select(l=>l.flat).filter(o),r,{side:[0,1],axis:a,front:n,kind:"outside",roll:"last",book:!0})}),t.step({diagram:8,label:"Reverse fold the head",duration:.8,ease:"inOut"},s=>{let l=Sn([0,1],r),h=Sn(a[0],r),d=Math.hypot(l[0]-h[0],l[1]-h[1]),p=[l[0]+(h[0]-l[0])/d*Fn,l[1]+(h[1]-l[1])/d*Fn];s.reverse(i,En(p,(vn+go)/2),{side:l,axis:[h,l],front:n,kind:"inside"})}),t.step({diagram:8,label:"Drift",duration:2.4,ease:"linear",path:Mo}),t.step({diagram:8,label:"Glide away",duration:1.1,phase:"outro",ease:"in",pose:{tx:2.4,o:0}}),t.compile()}function xo(t){let e=0,o=0;for(let n of t)e+=n[0],o+=n[1];return[e/t.length,o/t.length]}var Re=.5,It=-.25,Te=[0,It],An=.12,_n=t=>{let e=(o,n,r)=>r*Math.exp(-(((t-o)/n)**2));return{s:e(.18,.06,.09)+e(.36,.07,.06)}};function Ce(){let t=new V({rx:-16,ry:180,ty:.6,tz:.4,o:0},[[0,-1],[1,0],[0,1],[-1,0]]);return t.step({diagram:1,label:"Start with a square",duration:.7,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}}),t.step({diagram:2,label:"Fold the top corner to the centre",duration:.7},e=>{e.fold([-1,Re],[1,Re],{side:[0,1],toward:-1,at:[.05,1]})}),t.step({diagram:3,label:"Fold the bottom corner up",duration:.8},e=>{e.fold([-1,It],[1,It],{side:[0,-1],toward:-1})}),t.step({diagram:4,label:"Fold the sides up to the centre",duration:1,pose:{s:1.3,ty:-.2}},e=>{e.fold(Te,[-1,It+1],{side:[-.9,-.05],toward:-1,at:[0,.7]}),e.fold(Te,[1,It+1],{side:[.9,-.05],toward:-1,at:[.3,1]})}),t.step({diagram:5,label:"Fold the corners behind",duration:.9,pose:{s:1.55,ty:-.4}},e=>{let o=[];for(let n of[-1,1]){let r=[n*.25,.75],a=[n*.625,.375],i=[0,Re];o.push({p:r,a:i,b:a,top:!0},{p:a,a:r,b:Te,top:!1})}o.forEach(({p:n,a:r,b:a,top:i},s)=>{let l=d=>{let p=[d[0]-n[0],d[1]-n[1]],x=Math.hypot(p[0],p[1]);return[n[0]+p[0]/x*An,n[1]+p[1]/x*An]},h=Math.sign(n[0]);e.fold(l(r),l(a),{where:i?d=>d.model[0]*h>-.1:void 0,side:n,toward:1,at:[s*.12,.64+s*.12]})})}),t.step({diagram:5,label:"Beat",duration:1.1,ease:"linear",path:_n}),t.step({diagram:5,label:"Beat again",duration:1.1,ease:"linear",path:_n}),t.step({diagram:5,label:"Float away",duration:1,phase:"outro",ease:"in",pose:{ty:.4,s:1.35,o:0}}),t.compile()}var et=t=>[t[0],t[1],t[2]??0],wo=(t,e)=>[t[0]-e[0],t[1]-e[1],t[2]-e[2]];var vo=t=>{let e=Math.hypot(t[0],t[1],t[2]);return[t[0]/e,t[1]/e,t[2]/e]};function Vt(t,e,o,n){let r=W(et(t),vo(wo(et(e),et(t))),o*Math.PI/180);return N(r,n[0],n[1],n[2])}function In(t,e,o={}){let n=o.samples??181,r=o.window??30,a=o.step??.25,i=new Float64Array(n);i[0]=e;for(let s=1;s<n;s++){let l=s/(n-1),h=i[s-1],d=h,p=1/0;for(let x=-r;x<r;x+=a){let y=h+x,f=y+a,P=t(l,y),c=t(l,f);if(P===0||P*c<0){let m=y,v=f,M=P;for(let b=0;b<40;b++){let g=(m+v)/2,w=t(l,g);M*w<=0?v=g:(m=g,M=w)}let u=(m+v)/2;if(o.ok&&!o.ok(l,u))continue;Math.abs(u-h)<p&&(p=Math.abs(u-h),d=u)}}i[s]=d}return s=>{let l=Math.min(1,Math.max(0,s))*(n-1),h=Math.min(n-2,Math.floor(l));return i[h]+(i[h+1]-i[h])*(l-h)}}var yt=Math.SQRT2-1,ee=[0,1],Ot=[0,-1],Xt=[0,0],U=t=>[t*yt,0],Pt=t=>[t,0],ne=t=>[t*Math.SQRT1_2,1-Math.SQRT1_2],oe=t=>[t*Math.SQRT1_2,Math.SQRT1_2-1],Vn=.3,On=(1+yt)/2,Zt=-.7,ko=350,Fo=12;function Tn([t,e]){if(Math.abs(t)/yt+Math.abs(e)<1)return"centre";let o=t<0?-1:1,n=e>0,r=U(o),a=n?ne(o):oe(o);return Math.sign(L(r,a,[t,e]))===Math.sign(L(r,a,Pt(o)))?n?"upEar":"lowEar":n?"upMain":"lowMain"}var gt=(...t)=>e=>t.includes(Tn(e.sheet)),te=gt("upEar","lowEar"),So=(t,e,o)=>Vt(t,e,10,et(o))[2]<0?1:-1,Ln=t=>180*C.inOut(t);function Eo(t,e){let o=e?ee:Ot,n=e?ne(t):oe(t),r=So(U(t),o,Pt(t)),a=(s,l)=>Vt(U(t),o,r*180*s,Vt(U(t),n,l,et(Pt(t)))),i=In((s,l)=>a(s,l)[1],0,{ok:(s,l)=>a(s,l)[2]<=1e-9});return{kite:s=>r*Ln(s),ear:s=>i(Ln(s)/180)}}var Rn=t=>({ty:.04*Math.sin(t*Math.PI*2),rz:2.5*Math.sin(t*Math.PI*2-.6)});function ze(){let t=new V({rx:-20,ry:180,ty:.6,tz:.4,o:0},[[0,-1],[1,0],[0,1],[-1,0]]);t.step({diagram:1,label:"Start with a square",duration:.7,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}});let e=(n,r,a)=>{let i=[];t.step({diagram:n,label:r,duration:.8},s=>{i=[-1,1].map(l=>s.fold(a,U(l),{side:Pt(l),toward:-1,at:l<0?[0,.7]:[.3,1]}))}),t.step({diagram:n,label:"Unfold",duration:.45,ease:"inOut"},s=>{[-1,1].forEach((l,h)=>s.attach(i[h],s.hinge(a,U(l),Pt(l),1,180,{ease:"inOut"})))})};e(2,"Fold the bottom edges to the centre",Ot),e(3,"Fold the top edges to the centre",ee),t.step({diagram:4,label:"Collapse into a fish base",duration:1.4,ease:"inOut",pose:{s:1.1}},n=>{for(let r of[-1,1]){let a=i=>Tn(n.info(i).sheet)!=="centre"&&r*n.info(i).sheet[0]>0;n.split(n.select().filter(a),[-1,0],[1,0]),n.split(n.select(gt("upMain","upEar")).filter(a),U(r),ne(r)),n.split(n.select(gt("lowMain","lowEar")).filter(a),U(r),oe(r));for(let i of[!0,!1]){let s=i?ee:Ot,l=i?ne(r):oe(r),h=Eo(r,i),d=n.rot(U(r),s,h.kite),p=n.rot(U(r),l,h.ear),x=y=>n.select(gt(y)).filter(f=>r*n.info(f).sheet[0]>0);n.attach(x(i?"upMain":"lowMain"),d),n.attach(x(i?"upEar":"lowEar"),p,d)}}}),t.step({diagram:4,label:"Flatten the ears down",duration:.8,ease:"inOut"},n=>{for(let r of[-1,1]){let i=Vt(U(r),Xt,90,[0,0,-yt])[1]<0?90:-90;n.attach(n.select(te).filter(s=>r*n.info(s).sheet[0]>0),n.rot(et(U(r)),et(Xt),i,{ease:"inOut"}))}n.layer(n.select(gt("lowEar")),n.select(gt("upEar")))}),t.step({diagram:5,label:"Fold the tip back",duration:.7},n=>{n.fold([-1,On],[1,On],{side:ee,toward:1})}),t.step({diagram:5,label:"Turn over",duration:.8,ease:"inOut",pose:{ry:360},arc:{tz:.3}}),t.step({diagram:6,label:"Fold the corners in",duration:.7,pose:{s:1.15}},n=>{for(let r of[-1,1])n.fold([r*Vn,-1],[r*Vn,1],{side:Pt(r),toward:1,at:r<0?[0,.7]:[.3,1]})}),t.step({diagram:7,label:"Fold in half",duration:.9,ease:"inOut",pose:{rz:90,rx:-12,s:1.45,tx:.2,ty:-.05}},n=>{n.fold([0,-1],[0,1],{side:[.3,0],toward:1})}),t.step({diagram:8,label:"Fold the flippers down",duration:.8},n=>{n.fold(Xt,[-1,-1],{where:r=>te(r)&&r.sheet[0]>0,side:[0,-yt],toward:1,at:[0,.7]}),n.fold(Xt,[-1,-1],{where:r=>te(r)&&r.sheet[0]<0,side:[0,-yt],toward:-1,at:[.3,1]})});let o=[];return t.step({diagram:9,label:"Lift the tail",duration:.9,ease:"inOut",pose:{s:1.5}},n=>{let r=(270+ko)/2*Math.PI/180,a=[[0,Zt],[-Math.cos(r),Zt-Math.sin(r)]];o=n.reverse(n.select(i=>i.flat&&!te(i)),a,{side:Ot,axis:[[0,Zt],Ot],front:i=>i.sheet[0]>0,kind:"outside",roll:"last",book:!0})}),t.step({diagram:10,label:"Swim",duration:1.4,ease:"linear",path:Rn},n=>{n.attach(o,n.swing([0,Zt],Fo,{ease:"breathe"}))}),t.step({diagram:10,label:"Swim on",duration:1.4,ease:"linear",path:Rn}),t.step({diagram:10,label:"Dive",duration:1,phase:"outro",ease:"in",pose:{ty:-.9,rz:112,o:0}}),t.compile()}var Cn=[0,0],zn=[0,-1],Ao=-.3,Nn=-.9,_o=28,Io=t=>t[0]<-Math.abs(t[1]),Vo=t=>t[0]>Math.abs(t[1]),Dn=t=>[[t*.5,-.5],[0,Ao]],Oo=t=>({rz:9*Math.sin(t*Math.PI*2)*Math.sin(t*Math.PI)});function Ne(){let t=new V({rx:-14,ry:180,ty:.6,tz:.4,o:0},[[0,-1],[1,0],[0,1],[-1,0]]);t.step({diagram:1,label:"Start with a square",duration:.7,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}}),t.step({diagram:2,label:"Fold the top corner down",duration:.7},o=>{o.fold([-1,0],[1,0],{side:[0,1],toward:-1,at:[.05,1]})}),t.step({diagram:3,label:"Fold the corners to the bottom",duration:.9,pose:{s:1.4,ty:.25}},o=>{o.fold(Cn,[-.5,-.5],{side:[-1,0],toward:-1,at:[0,.7]}),o.fold(Cn,[.5,-.5],{side:[1,0],toward:-1,at:[.3,1]})});let e=[];return t.step({diagram:4,label:"Fold the ears up",duration:1,pose:{s:1.55,ty:.2}},o=>{e=[-1,1].map((n,r)=>o.fold(...Dn(n),{where:a=>(n<0?Io:Vo)(a.sheet),side:zn,toward:-1,at:r?[.3,1]:[0,.7]}))}),t.step({diagram:5,label:"Tuck the nose behind",duration:.6,pose:{s:1.6,ty:.28}},o=>{o.fold([-1,Nn],[1,Nn],{side:zn,toward:1})}),t.step({diagram:6,label:"Tilt the head",duration:1.6,ease:"linear",path:Oo}),t.step({diagram:6,label:"Twitch the ears",duration:.9,ease:"linear"},o=>{e.forEach((n,r)=>{let a=r?1:-1,[i,s]=Dn(a);o.attach(n,o.hinge(i,s,[a*.6,.3],-1,_o,{ease:"breathe",at:r?[.25,1]:[0,.75]}))})}),t.step({diagram:6,label:"Trot off",duration:.9,phase:"outro",ease:"in",pose:{tx:-1.4,o:0},arc:{ty:.08}}),t.compile()}var Be=new Map([["crane",Me],["plane",xe],["pleat",ve],["envelope",ke],["boat",Fe],["frog",Oe],["swan",Le],["heart",Ce],["whale",ze],["fox",Ne]]),De=new Map;function Lo(){return[...Be.keys()]}function Ro(t,e){Be.set(t,e),De.delete(t)}function $e(t){let e=De.get(t);if(!e){let o=Be.get(t);if(!o)return;e=new St(o()),De.set(t,e)}return e}var re={distance:5,light:vt([-.45,.7,.75])};function To(t){return O(ct(t.tx,t.ty,t.tz),O(ie(t.spin*H),O(qe(t.s),O(He(t.rx*H),O(Qe(t.ry*H),ie(t.rz*H))))))}var Bn=1e-6;function $n(t,e,o){let n=t.normal,r=rt(n,wt(o,t.center))>=0?1:-1,a=!1,i=!1;for(let s of e.pts){let l=rt(n,wt(s,t.center))*r;if(l>Bn?a=!0:l<-Bn&&(i=!0),a&&i)return 0}return a?1:i?-1:0}function Co(t,e){for(let o of[t,e])for(let n=0;n<o.length;n++){let r=o[n],a=o[(n+1)%o.length],i=r[1]-a[1],s=a[0]-r[0],l=Math.hypot(i,s);if(l<1e-9)continue;let h=1/0,d=-1/0,p=1/0,x=-1/0;for(let y of t){let f=(y[0]*i+y[1]*s)/l;f<h&&(h=f),f>d&&(d=f)}for(let y of e){let f=(y[0]*i+y[1]*s)/l;f<p&&(p=f),f>x&&(x=f)}if(d<=p+1e-4||x<=h+1e-4)return!1}return!0}function zo(t,e,o){let n=0,r;for(let h of t.polys)for(let d of e.polys){let p=Ct(h,d);if(p.length<3)continue;let x=Math.abs(at(p));x>n&&(n=x,r=kt(p))}if(!r||n<1e-7)return 0;let a=[r[0],-r[1],-o],i=h=>{let d=rt(h.normal,a);return Math.abs(d)<1e-12?1/0:(h.normal[0]*h.center[0]+h.normal[1]*h.center[1]+h.normal[2]*(h.center[2]-o))/d},s=i(t),l=i(e);return!isFinite(s)||!isFinite(l)||s===l?0:l<s?1:-1}function jn(t,e=re){let o=[0,0,e.distance],n=t.length,r=t.map(h=>Ye(h.scr)),a=t.map(()=>[]),i=new Int32Array(n);for(let h=0;h<n;h++){let d=t[h];for(let p=h+1;p<n;p++){let x=t[p];if(d.box[2]<=x.box[0]||x.box[2]<=d.box[0]||d.box[3]<=x.box[1]||x.box[3]<=d.box[1]||!Co(r[h],r[p]))continue;let y=-$n(d,x,o);y||(y=$n(x,d,o)),y||(y=-zo(d,x,e.distance)),y&&(y<0?(a[h].push(p),i[p]++):(a[p].push(h),i[h]++))}}let s=[],l=new Uint8Array(n);for(let h=0;h<n;h++){let d=-1;for(let p=0;p<n;p++)!l[p]&&i[p]===0&&(d<0||t[p].depth>t[d].depth)&&(d=p);if(d<0)for(let p=0;p<n;p++)!l[p]&&(d<0||t[p].depth>t[d].depth)&&(d=p);l[d]=1,s.push(d);for(let p of a[d])i[p]--}return s}function No(t,e,o=re){let n=t.faces.length,r=To(e.pose),a=o.distance,i=[0,0,a],s=new Array(n),l=new Array(n),h=new Array(n),d=new Array(n);for(let c=0;c<n;c++){let m=e.T[c];d[c]=[m[2],m[6],m[10]],s[c]=O(r,O(ct(e.lift[3*c],e.lift[3*c+1],e.lift[3*c+2]),m)),l[c]=t.faces[c].map(v=>N(s[c],t.verts[v][0],t.verts[v][1],0)),h[c]=l[c].map(([v,M,u])=>{let b=a/(a-u);return[v*b,-M*b]})}let p=Int32Array.from({length:n},(c,m)=>m),x=c=>p[c]===c?c:p[c]=x(p[c]),y=new Uint8Array(t.edges.length);t.edges.forEach((c,m)=>{if(c.faces.length!==2)return;let[v,M]=c.faces;if(rt(d[v],d[M])>1-1e-9){y[m]=1;let u=e.lift;Math.abs(u[3*v]-u[3*M])+Math.abs(u[3*v+1]-u[3*M+1])+Math.abs(u[3*v+2]-u[3*M+2])<1e-9&&(p[x(v)]=x(M))}});let f=new Map;for(let c=0;c<n;c++){let m=x(c),v=f.get(m);v?v.push(c):f.set(m,[c])}let P=[];for(let c of f.values()){let m=[],v=[],M=[0,0,0],u=[1/0,1/0,-1/0,-1/0];for(let w of c)for(let k=0;k<l[w].length;k++){m.push(l[w][k]),v.push(h[w][k]);let[F,E]=h[w][k];F<u[0]&&(u[0]=F),F>u[2]&&(u[2]=F),E<u[1]&&(u[1]=E),E>u[3]&&(u[3]=E)}for(let w of m)M[0]+=w[0]/m.length,M[1]+=w[1]/m.length,M[2]+=w[2]/m.length;let b=s[c[0]],g=wt(i,M);P.push({faces:c,pts:m,scr:v,polys:c.map(w=>lt(h[w].slice())),normal:vt([b[2],b[6],b[10]]),center:M,depth:Math.hypot(g[0],g[1],g[2]),box:u})}return{W:s,pts:l,scr:h,flat:y,panels:P,order:jn(P,o)}}var je="http://www.w3.org/2000/svg",it=t=>Math.round(t*1e3)/1e3,Lt=class{constructor(e,o,n=re){this.root=e;this.m=o;this.cam=n;this.slots=[];this.uid=Math.random().toString(36).slice(2,8);e.textContent="",this.defs=document.createElementNS(je,"defs"),this.image=document.createElementNS(je,"image"),this.image.id=`${this.uid}-img`;for(let[r,a]of[["width","2"],["height","2"],["preserveAspectRatio","none"]])this.image.setAttribute(r,a);this.defs.appendChild(this.image),e.appendChild(this.defs)}setTexture(e){this.image.setAttribute("href",e)}slot(e){let o=this.slots[e];if(o)return o;let n=(x,y)=>{let f=document.createElementNS(je,x);return y&&f.setAttribute("class",y),f},r=n("pattern");r.id=`${this.uid}-t${e}`,r.setAttribute("patternUnits","userSpaceOnUse"),r.setAttribute("width","2"),r.setAttribute("height","2");let a=n("use");a.setAttribute("href",`#${this.uid}-img`),r.appendChild(a),this.defs.appendChild(r);let i=n("path","f"),s=n("path","t");s.style.fill=`url(#${r.id})`;let l=n("g"),h=l.appendChild(n("path","m")),d=l.appendChild(n("path","a")),p=l.appendChild(n("path","e"));return this.root.append(i,s,l),o={fill:i,tex:s,pattern:r,lines:l,mem:h,act:d,edge:p,cache:["","","","","","","",""]},this.slots[e]=o,o}render(e){let o=this.m,n=this.cam.distance,r=[0,0,n],{W:a,scr:i,flat:s,panels:l,order:h}=No(o,e,this.cam),d=e.step;for(let p=0;p<h.length;p++){let x=l[h[p]],y=this.slot(p),f="",P="",c="",m="";for(let R of x.faces){let G=i[R];for(let z=0;z<G.length;z++)f+=(z?"L":"M")+it(G[z][0])+" "+it(G[z][1]);f+="Z",o.faceEdges[R].forEach((z,K)=>{let T=G[K],Tt=G[(K+1)%G.length],nt=`M${it(T[0])} ${it(T[1])}L${it(Tt[0])} ${it(Tt[1])}`,Mt=o.edges[z];if(Mt.faces.length<2||!s[z])m+=nt;else{let Qn=Mt.faces[0]===R?Mt.faces[1]:Mt.faces[0];Mt.born<=d&&(P+=nt),e.group[R]!==e.group[Qn]&&(c+=nt)}})}let v=a[x.faces[0]],M=rt(x.normal,wt(r,x.center))>0,u=M?x.normal:[-x.normal[0],-x.normal[1],-x.normal[2]],b=Math.max(0,rt(u,this.cam.light)),g=M!==!!o.colourDown,w=g?"f":"b",k=`color-mix(in oklab,var(--_l${w}) ${Math.round((.15+.85*b)*100)}%,var(--_s${w}))`,F=g?"front":"back",E=o.faces[x.faces[0]],S=0,A=0;for(let R of E)S+=o.verts[R][0]/E.length,A+=o.verts[R][1]/E.length;let j=Do(v,n,S,A),_=y.cache;_[0]!==f&&(y.fill.setAttribute("d",_[0]=f),y.tex.setAttribute("d",f)),_[1]!==P&&y.mem.setAttribute("d",_[1]=P),_[2]!==c&&y.act.setAttribute("d",_[2]=c),_[3]!==m&&y.edge.setAttribute("d",_[3]=m),_[4]!==k&&y.fill.style.setProperty("--f",_[4]=k),_[5]!==F&&y.lines.setAttribute("class",_[5]=F),_[6]!==j&&y.pattern.setAttribute("patternTransform",_[6]=j),_[7]!=="1"&&(_[7]="1",y.fill.style.display=y.tex.style.display=y.lines.style.display="")}for(let p=h.length;p<this.slots.length;p++){let x=this.slots[p];x.cache[7]!=="0"&&(x.cache[7]="0",x.fill.style.display=x.tex.style.display=x.lines.style.display="none")}this.root.style.opacity=String(it(e.pose.o))}};function Do(t,e,o,n){let r=(m,v)=>{let[M,u,b]=N(t,m,v,0),g=e/(e-b);return[M*g,-u*g]},i=r(o,n),s=r(o+.25,n),l=r(o,n+.25),h=(s[0]-i[0])/.25,d=(s[1]-i[1])/.25,p=-(l[0]-i[0])/.25,x=-(l[1]-i[1])/.25,y=o+1,f=1-n,P=i[0]-h*y-p*f,c=i[1]-d*y-x*f;return`matrix(${[h,d,p,x,P,c].map(m=>Math.round(m*1e4)/1e4).join(" ")})`}var Gn=`
1
+ import"./chunks/chunk-IHRIUEAN.js";var Q=Math.PI/180,kt=()=>[1,0,0,0,0,1,0,0,0,0,1,0];function R(t,e){let o=new Array(12);for(let n=0;n<12;n+=4){let r=t[n],s=t[n+1],i=t[n+2];o[n]=r*e[0]+s*e[4]+i*e[8],o[n+1]=r*e[1]+s*e[5]+i*e[9],o[n+2]=r*e[2]+s*e[6]+i*e[10],o[n+3]=r*e[3]+s*e[7]+i*e[11]+t[n+3]}return o}function q(t,e,o,n){return[t[0]*e+t[1]*o+t[2]*n+t[3],t[4]*e+t[5]*o+t[6]*n+t[7],t[8]*e+t[9]*o+t[10]*n+t[11]]}function ot(t,e,o){let[n,r,s]=e,i=Math.cos(o),a=Math.sin(o),c=1-i,h=[c*n*n+i,c*n*r-a*s,c*n*s+a*r,0,c*n*r+a*s,c*r*r+i,c*r*s-a*n,0,c*n*s-a*r,c*r*s+a*n,c*s*s+i,0];for(let p=0;p<12;p+=4)h[p+3]=t[p/4]-(h[p]*t[0]+h[p+1]*t[1]+h[p+2]*t[2]);return h}var Ye=t=>ot([0,0,0],[1,0,0],t),We=t=>ot([0,0,0],[0,1,0],t),ue=t=>ot([0,0,0],[0,0,1],t),lt=(t,e,o)=>[1,0,0,t,0,1,0,e,0,0,1,o],Je=t=>[t,0,0,0,0,t,0,0,0,0,t,0],rt=(t,e=0,o=1)=>t<e?e:t>o?o:t,de=(t,e,o)=>t+(e-t)*o,at=(t,e)=>t[0]*e[0]+t[1]*e[1]+t[2]*e[2],Ft=(t,e)=>[t[0]-e[0],t[1]-e[1],t[2]-e[2]];function St(t){let e=Math.hypot(t[0],t[1],t[2])||1;return[t[0]/e,t[1]/e,t[2]/e]}var T=(t,e,o)=>(e[0]-t[0])*(o[1]-t[1])-(e[1]-t[1])*(o[0]-t[0]);function Xe(t,e,o,n){let r=[e[0]-t[0],e[1]-t[1]],s=[n[0]-o[0],n[1]-o[1]],i=r[0]*s[1]-r[1]*s[0];if(Math.abs(i)<1e-12)return;let a=((o[0]-t[0])*s[1]-(o[1]-t[1])*s[0])/i;return[t[0]+r[0]*a,t[1]+r[1]*a]}function st(t){let e=0;for(let o=0;o<t.length;o++){let n=t[o],r=t[(o+1)%t.length];e+=n[0]*r[1]-r[0]*n[1]}return e/2}function Et(t){let e=0,o=0,n=0;for(let r=0;r<t.length;r++){let s=t[r],i=t[(r+1)%t.length],a=s[0]*i[1]-i[0]*s[1];e+=a,o+=(s[0]+i[0])*a,n+=(s[1]+i[1])*a}if(Math.abs(e)<1e-14){for(let r of t)o+=r[0],n+=r[1];return[o/t.length,n/t.length]}return[o/(3*e),n/(3*e)]}var ht=t=>st(t)<0?t.slice().reverse():t;function Ze(t,e,o,n=1e-9){let r=Math.hypot(o[0]-e[0],o[1]-e[1]),s=t.map(h=>T(e,o,h)/r);if(!s.some(h=>h<-n))return{left:t,right:null,chord:null};if(!s.some(h=>h>n))return{left:null,right:t,chord:null};let i=[],a=[],c=[];for(let h=0;h<t.length;h++){let p=(h+1)%t.length,f=t[h],P=t[p],m=s[h],d=s[p];if(m>=-n&&i.push(f),m<=n&&a.push(f),Math.abs(m)<=n&&c.push(f),m>n&&d<-n||m<-n&&d>n){let x=m/(m-d),l=[f[0]+(P[0]-f[0])*x,f[1]+(P[1]-f[1])*x];i.push(l),a.push(l),c.push(l)}}return{left:i,right:a,chord:c.length>=2?[c[0],c[1]]:null}}function Bt(t,e){let o=t;for(let n=0;n<e.length&&o.length;n++){let r=e[n],s=e[(n+1)%e.length],i=o;o=[];for(let a=0;a<i.length;a++){let c=i[a],h=i[(a+1)%i.length],p=T(r,s,c),f=T(r,s,h);if(p>=0&&o.push(c),p>=0!=f>=0){let P=p/(p-f);o.push([c[0]+(h[0]-c[0])*P,c[1]+(h[1]-c[1])*P])}}}return o}function tn(t){let e=t.slice().sort((r,s)=>r[0]-s[0]||r[1]-s[1]);if(e.length<3)return e;let o=[],n=[];for(let r of e){for(;o.length>=2&&T(o[o.length-2],o[o.length-1],r)<=0;)o.pop();o.push(r)}for(let r=e.length-1;r>=0;r--){let s=e[r];for(;n.length>=2&&T(n[n.length-2],n[n.length-1],s)<=0;)n.pop();n.push(s)}return o.slice(0,-1).concat(n.slice(0,-1))}function $t(t,e,o,n){let r=3*t,s=3*(o-t)-r,i=1-r-s,a=3*e,c=3*(n-e)-a,h=1-a-c,p=m=>((i*m+s)*m+r)*m,f=m=>((h*m+c)*m+a)*m,P=m=>(3*i*m+2*s)*m+r;return m=>{if(m<=0)return 0;if(m>=1)return 1;let d=m;for(let x=0;x<8;x++){let l=p(d)-m,b=P(d);if(Math.abs(l)<1e-7||Math.abs(b)<1e-7)break;d-=l/b}if(d<0||d>1||Math.abs(p(d)-m)>1e-5){let x=0,l=1;for(let b=0;b<30;b++)d=(x+l)/2,p(d)<m?x=d:l=d}return f(d)}}var V={linear:t=>t,in:$t(.55,.055,.675,.19),out:$t(.23,1,.32,1),inOut:$t(.645,.045,.355,1),fold:$t(.77,0,.175,1),drop:t=>1-Math.exp(-7.5*t)*Math.cos(8.5*t)*(1-t),flap:t=>Math.sin(t*Math.PI*4)*(1-t*.6),breathe:t=>(1-Math.cos(2*Math.PI*Math.min(1,Math.max(0,t))))/2},ut={rx:0,ry:0,rz:0,spin:0,tx:0,ty:0,tz:0,s:1,o:1},pe=Object.keys(ut);var fe=.0015,dt=41,en=.9;function Gt(t,e,o){return t.rot?ot(t.p,t.u,t.free>=0?o:t.script?t.script(e):t.angle*e):lt(t.u[0]*e,t.u[1]*e,t.u[2]*e)}function Xn(t){let e=[t[0],t[4],t[8],0,t[1],t[5],t[9],0,t[2],t[6],t[10],0];return e[3]=-(e[0]*t[3]+e[1]*t[7]+e[2]*t[11]),e[7]=-(e[4]*t[3]+e[5]*t[7]+e[6]*t[11]),e[11]=-(e[8]*t[3]+e[9]*t[7]+e[10]*t[11]),e}var At=t=>Math.abs(t[10])>1-1e-6&&Math.abs(t[11])<1e-5;function Zn(t){if(Math.abs(t[10])<1-1e-4||Math.abs(t[11])>.001)return t;let e=t[10]>0?1:-1,o=Math.atan2(t[4],t[0]),n=Math.cos(o),r=Math.sin(o);for(let s of[0,1,-1])Math.abs(n-s)<1e-12&&(n=s),Math.abs(r-s)<1e-12&&(r=s);return[n,-e*r,0,t[3],r,e*n,0,t[7],0,0,e,0]}function qt(t,e){let o=Math.min(1,Math.max(0,e))*(t.length-1),n=Math.min(t.length-2,Math.floor(o));return t[n]+(t[n+1]-t[n])*(o-n)}function to(t,e){let o=e.length,n=t.map((r,s)=>[...r,e[s]]);for(let r=0;r<o;r++){let s=r;for(let a=r+1;a<o;a++)Math.abs(n[a][r])>Math.abs(n[s][r])&&(s=a);[n[r],n[s]]=[n[s],n[r]];let i=n[r][r]||1e-18;for(let a=0;a<o;a++){if(a===r)continue;let c=n[a][r]/i;for(let h=r;h<=o;h++)n[a][h]-=c*n[r][h]}}return n.map((r,s)=>r[o]/(r[s]||1e-18))}function eo(t,e){let o=t.slice(),n=e(o),r=n.reduce((i,a)=>i+a*a,0),s=o.length;for(let i=0;i<60&&r>1e-24;i++){let a=[];for(let d=0;d<s;d++){let x=o.slice();x[d]+=1e-7,a.push(e(x).map((l,b)=>(l-n[b])/1e-7))}let c=a.map(d=>a.map(x=>d.reduce((l,b,M)=>l+b*x[M],0))),h=a.map(d=>-d.reduce((x,l,b)=>x+l*n[b],0)),p=1e-10+1e-8*Math.max(...c.map((d,x)=>d[x]));c.forEach((d,x)=>d[x]+=p);let f=to(c,h),P=1,m=!1;for(let d=0;d<12;d++){let x=o.map((M,w)=>M+P*f[w]),l=e(x),b=l.reduce((M,w)=>M+w*w,0);if(b<r){o=x,n=l,r=b,m=!0;break}P/=2}if(!m)break}return o}var O=class{constructor(e={},o=[[-1,-1],[1,-1],[1,1],[-1,1]]){this.steps=[];this.chords=[];this.nextId=1;this.pose={...ut,...e},this.faces=[{id:0,poly:ht(o),T:kt(),level:0,rank:0,hist:[]}]}step(e,o){let n=new jt(this,e);return o?.(n),n.finish(),this}compile(e={}){let o=[],n=new Map,r=d=>{let x=`${Math.round(d[0]*1e7)},${Math.round(d[1]*1e7)}`,l=n.get(x);return l===void 0&&(l=o.length,o.push(d),n.set(x,l)),l},s=this.faces.map(d=>{let x=ht(d.poly).map(r);return x.filter((l,b)=>l!==x[(b+1)%x.length])});s=s.map(d=>{let x=[];for(let l=0;l<d.length;l++){let b=d[l],M=d[(l+1)%d.length];x.push(b);let w=o[b],u=o[M],g=u[0]-w[0],y=u[1]-w[1],v=g*g+y*y,k=[];for(let F=0;F<o.length;F++){if(F===b||F===M)continue;let E=o[F],S=((E[0]-w[0])*g+(E[1]-w[1])*y)/v;S<=1e-9||S>=1-1e-9||Math.abs(T(w,u,E))/Math.sqrt(v)<1e-7&&k.push([S,F])}k.sort((F,E)=>F[0]-E[0]);for(let[,F]of k)x.push(F)}return x});let i=[],a=new Map,c=s.map((d,x)=>d.map((l,b)=>{let M=d[(b+1)%d.length],w=l<M?`${l}|${M}`:`${M}|${l}`,u=a.get(w);return u===void 0&&(u=i.length,a.set(w,u),i.push({a:l,b:M,faces:[],born:1/0})),i[u].faces.push(x),u})),h=(d,x)=>{let l=x.b[0]-x.a[0],b=x.b[1]-x.a[1],M=l*l+b*b,w=((d[0]-x.a[0])*l+(d[1]-x.a[1])*b)/M;return w>-1e-7&&w<1+1e-7&&Math.abs(T(x.a,x.b,d))/Math.sqrt(M)<1e-7};for(let d of i)if(!(d.faces.length<2))for(let x of this.chords)x.step<d.born&&h(o[d.a],x)&&h(o[d.b],x)&&(d.born=x.step);let p=[],f=0,P=0,m=0;for(let d of this.steps)p.push(f),d.phase==="intro"&&(P=f+d.duration),d.phase!=="outro"&&(m=f+d.duration),f+=d.duration;return{steps:this.steps,starts:p,duration:f,content:[P,m],pose:this.pose,verts:o,faces:s,tracks:this.faces.map(d=>d.hist),edges:i,faceEdges:c,colourDown:e.colourDown}}},jt=class{constructor(e,o){this.F=e;this.meta=o;this.joints=[];this.chains=new Map;this.pins=[];this.layers=[];this.nFree=0}get index(){return this.F.steps.length}info(e){let o=Et(e.poly),n=q(e.T,o[0],o[1],0);return{sheet:o,model:[n[0],n[1]],flat:At(e.T),up:e.T[10]>0}}select(e){return this.F.faces.filter(o=>!e||e(this.info(o)))}split(e,o,n){let r=new Set(e),s=[],i=[];for(let a of this.F.faces){if(!r.has(a)){i.push(a);continue}if(!At(a.T)){i.push(a),s.push(a);continue}let c=Xn(a.T),h=q(c,o[0],o[1],0),p=q(c,n[0],n[1],0),{left:f,right:P,chord:m}=Ze(a.poly,[h[0],h[1]],[p[0],p[1]]);if(!f||!P||Math.abs(st(f))<1e-10||Math.abs(st(P))<1e-10){i.push(a),s.push(a);continue}m&&this.F.chords.push({a:m[0],b:m[1],step:this.index});let d=this.chains.get(a);this.chains.delete(a);for(let x of[f,P]){let l={...a,id:this.F.nextId++,poly:x,hist:a.hist.slice()};d&&this.chains.set(l,d),i.push(l),s.push(l)}}return this.F.faces=i,s}rot(e,o,n,r={}){let s=[e[0],e[1],e[2]??0],i=[o[0],o[1],o[2]??0],a=-1;n==="free"&&(a=r.free??this.nFree,this.nFree=Math.max(this.nFree,a+1));let c=typeof n=="function"?h=>n(h)*Q:void 0;return this.joints.push({rot:!0,p:s,u:St([i[0]-s[0],i[1]-s[1],i[2]-s[2]]),angle:typeof n=="number"?n*Q:c?c(1):0,free:a,at:r.at??[0,1],ease:c?"linear":r.ease??"fold",script:c}),this.joints.length-1}hinge(e,o,n,r=1,s=180,i={}){return this.rot(e,o,s*r*Math.sign(T(e,o,n)),i)}swing(e,o,n={}){return this.rot([e[0],e[1],0],[e[0],e[1],1],o,n)}reverse(e,o,n){let[r,s]=o,i=this.split(e.filter(S=>At(S.T)),r,s),a=Math.sign(T(r,s,n.side)),c=i.filter(S=>Math.sign(T(r,s,this.info(S).model))===a),[h,p]=n.axis,f=Xe(h,p,r,s);if(!f)throw new Error("reverse: the axis runs parallel to the crease");let P=Math.atan2(p[1]-h[1],p[0]-h[0]),d=2*(Math.atan2(s[1]-r[1],s[0]-r[0])-P);d=Math.atan2(Math.sin(d),Math.cos(d))/Q;let[x,l]=n.at??[0,1],b=S=>x+(l-x)*S,M=S=>n.front(this.info(S)),w=c.filter(M),u=c.filter(S=>!M(S)),g=c.length&&Math.sign(T(h,p,this.info(c[0]).model))||1,y=n.book?[[w,180*g],[u,-180*g]]:[[c,180]];this.restack=n.roll==="last"?[b(.6),l]:[x,b(.35)];for(let[S,A]of y)if(n.roll==="last"){let j=Math.cos(d*Q),_=Math.sin(d*Q),C=J=>[f[0]+j*(J[0]-f[0])-_*(J[1]-f[1]),f[1]+_*(J[0]-f[0])+j*(J[1]-f[1])],G=this.swing(f,d,{at:[x,b(.8)],ease:n.ease??"inOut"}),N=this.rot(C(h),C(p),A,{at:[b(.6),l],ease:"inOut"});this.attach(S,G,N)}else{let j=this.rot(h,p,A,{at:[x,b(.35)],ease:"inOut"}),_=this.swing(f,d,{at:[b(.2),l],ease:n.ease??"inOut"});this.attach(S,j,_)}let v=new Set(c),k=this.F.faces.filter(S=>!v.has(S)),F=k.filter(M),E=k.filter(S=>!M(S));return n.kind==="inside"?(this.layer(F,[...w,...u]),this.layer(w,u),this.layer([...w,...u],E)):(this.layer(w,k),this.layer(k,u),this.layer(w,u)),c}move(e,o={}){return this.joints.push({rot:!1,p:[0,0,0],u:e,angle:0,free:-1,at:o.at??[0,1],ease:o.ease??"fold"}),this.joints.length-1}fold(e,o,n){let r=this.split(this.select(n.where).filter(a=>At(a.T)),e,o),s=Math.sign(T(e,o,n.side)),i=r.filter(a=>Math.sign(T(e,o,this.info(a).model))===s);return this.attach(i,this.hinge(e,o,n.side,n.toward??1,n.deg??180,n)),i}attach(e,...o){for(let n of e)this.chains.set(n,[...this.chains.get(n)??[],...o])}pin(e,o,n){this.pins.push({a:e,b:o,pt:n})}layer(e,o){this.layers.push({above:e,below:o})}compose(e,o,n,r=!1){let s=kt();for(let i of e){let a=this.joints[i],c=r&&this.nFree===0?V[a.ease](o):o;s=R(Gt(a,c,n[a.free]??0),s)}return s}place(e,o,n,r=!1){let s=this.chains.get(e);return s?R(this.compose(s,o,n,r),e.T):e.T}solve(){if(!this.nFree)return[];let e=Array.from({length:this.nFree},()=>new Float64Array(dt)),o=new Array(this.nFree).fill(0);for(let n=0;n<dt;n++){let r=n/(dt-1);o=eo(o,s=>{let i=[];for(let{a,b:c,pt:h}of this.pins){let p=q(this.place(a,r,s),h[0],h[1],0),f=q(this.place(c,r,s),h[0],h[1],0);i.push(p[0]-f[0],p[1]-f[1],p[2]-f[2])}return i}),o.forEach((s,i)=>e[i][n]=s)}for(let n of e){let r=Math.round(n[dt-1]/(Math.PI/2))*(Math.PI/2);Math.abs(n[dt-1]-r)<.001&&(n[dt-1]=r)}return e}finish(){let e=this.F,o=this.solve(),n=u=>o.map(g=>qt(g,u)),r=n(1),s=n(en),i=new Map(e.faces.map(u=>[u,Zn(this.place(u,1,r,!0))])),a=[];for(let u of e.faces){let g=i.get(u);if(!At(g))continue;let y=ht(u.poly.map(E=>{let S=q(g,E[0],E[1],0);return[S[0],S[1]]})),v=[1/0,1/0,-1/0,-1/0];for(let[E,S]of y)v[0]=Math.min(v[0],E),v[1]=Math.min(v[1],S),v[2]=Math.max(v[2],E),v[3]=Math.max(v[3],S);let k=this.chains.get(u),F=R(lt(0,0,u.rank*1e-7),u.T);a.push({f:u,poly:y,box:v,moved:!!k,Tn:k?R(this.compose(k,en,s,!0),F):F})}let c=new Map;for(let{above:u,below:g}of this.layers)for(let y of u)for(let v of g)c.set(`${y.id}|${v.id}`,1),c.set(`${v.id}|${y.id}`,-1);let h=(u,g)=>{let y=u[10];return Math.abs(y)<.001?u[11]:u[11]-(u[2]*(g[0]-u[3])+u[6]*(g[1]-u[7]))/y},p=a.length,f=a.map(()=>[]),P=a.map(()=>[]),m=new Int32Array(p);for(let u=0;u<p;u++){let g=a[u];for(let y=u+1;y<p;y++){let v=a[y];if(g.box[2]<=v.box[0]+1e-9||v.box[2]<=g.box[0]+1e-9||g.box[3]<=v.box[1]+1e-9||v.box[3]<=g.box[1]+1e-9)continue;let k=Bt(g.poly,v.poly);if(k.length<3||Math.abs(st(k))<1e-8)continue;let F=c.get(`${g.f.id}|${v.f.id}`);if(F===void 0)if(!g.moved&&!v.moved)F=g.f.rank>v.f.rank||g.f.rank===v.f.rank&&g.f.id>v.f.id?1:-1;else{let A=Et(k);F=h(g.Tn,A)>h(v.Tn,A)?1:-1}let[E,S]=F>0?[y,u]:[u,y];f[E].push(S),P[S].push(E),m[S]++}}let d=[],x=new Uint8Array(p);for(let u=0;u<p;u++){let g=-1;for(let y=0;y<p;y++)x[y]||m[y]>0||(g<0||a[y].f.rank<a[g].f.rank||a[y].f.rank===a[g].f.rank&&a[y].f.id<a[g].f.id)&&(g=y);if(g<0)for(let y=0;y<p;y++)!x[y]&&(g<0||a[y].f.rank<a[g].f.rank)&&(g=y);x[g]=1,d.push(g);for(let y of f[g])m[y]--}let l=new Int32Array(p),b=new Int32Array(p);d.forEach((u,g)=>b[u]=g);for(let u of d)for(let g of P[u])b[g]<b[u]&&(l[u]=Math.max(l[u],l[g]+1));let M=new Map,w=new Map;d.forEach((u,g)=>{M.set(a[u].f,l[u]),w.set(a[u].f,g)});for(let u of e.faces){let g=M.get(u)??u.level;u.hist.push({T:u.T,chain:this.chains.get(u)??[],z0:u.level*fe,z1:g*fe}),u.T=i.get(u),u.level=g,u.rank=w.get(u)??u.rank}e.steps.push({...this.meta,joints:this.joints,table:o,restack:this.restack})}};var Ut=t=>Math.abs(t[10])>1-1e-6,_t=class{constructor(e){this.model=e;let o=e.faces.length;this.anchors=e.steps.map(()=>new Array(o)),this.endsFlat=e.steps.map(()=>new Uint8Array(o));for(let n=0;n<o;n++){let r=e.tracks[n][0].T;e.steps.forEach((s,i)=>{let a=e.tracks[n][i];Ut(a.T)&&(r=a.T),this.anchors[i][n]=r;let h=e.tracks[n][i+1]?.T;if(!h){h=a.T;for(let p of a.chain)h=R(Gt(s.joints[p],1,s.table.length?qt(s.table[s.joints[p].free]??new Float64Array(2),1):0),h)}this.endsFlat[i][n]=Ut(h)?1:0})}this.groupIds=e.steps.map((n,r)=>{let s=new Map;return Int32Array.from(e.tracks.map(i=>{let a=i[r].chain.join(","),c=s.get(a);return c===void 0&&(c=s.size,s.set(a,c)),c}))})}get duration(){return this.model.duration}stepAt(e){let o=this.model.starts,n=0;for(;n<o.length-1&&o[n+1]<=e;)n++;return n}evaluate(e,o){let n=this.model,r=n.faces.length,s=o??{T:new Array(r),z:new Float64Array(r),lift:new Float64Array(3*r),group:new Int32Array(r),pose:{...ut},step:0,local:0};e=rt(e,0,n.duration);let i=this.stepAt(e),a=n.steps[i],c=a.duration>0?rt((e-n.starts[i])/a.duration):1,h=V[a.ease??"fold"](c),p=a.table.length>0,f=a.table.map(u=>qt(u,h)),P=a.joints.map(u=>{let g=p?h:V[u.ease](rt((c-u.at[0])/Math.max(1e-6,u.at[1]-u.at[0])));return Gt(u,g,f[u.free]??0)}),m=new Map,[d,x]=a.restack??[0,1],l=V.inOut(rt((c-d)/Math.max(1e-6,x-d)));for(let u=0;u<r;u++){let g=n.tracks[u][i];if(g.chain.length){let y=g.chain.join(","),v=m.get(y);if(!v){v=kt();for(let k of g.chain)v=R(P[k],v);m.set(y,v)}s.T[u]=R(v,g.T)}else s.T[u]=g.T;s.z[u]=de(g.z0,g.z1,l),this.lift(s,u,i,g.chain.length>0)}s.group.set(this.groupIds[i]);let b=V[a.ease??"inOut"](c),M=Math.sin(Math.PI*c),w=this.poseAt(i);for(let u of pe){let g=a.pose?.[u];s.pose[u]=(g===void 0?w[u]:de(w[u],g,b))+(a.arc?.[u]??0)*M}if(a.path){let u=a.path(c);for(let g of pe)s.pose[g]+=u[g]??0}return s.step=i,s.local=c,s}lift(e,o,n,r){let s=this.model.tracks[o][n],i=e.T[o],a=e.lift,c=3*o,h=Ut(s.T)&&this.endsFlat[n][o];if(!r&&Ut(i)||r&&h){a[c]=0,a[c+1]=0,a[c+2]=e.z[o];return}let p=this.anchors[n][o],f=p[8],P=p[9],m=p[10],d=i[0]*f+i[1]*P+i[2]*m,x=i[4]*f+i[5]*P+i[6]*m,l=i[8]*f+i[9]*P+i[10]*m,b=Math.min(1,Math.max(0,(.3-l)/.2)),M=e.z[o];a[c]=b*s.z0*d,a[c+1]=b*s.z0*x,a[c+2]=(1-b)*M+b*s.z0*l}poseAt(e){if(!this.poses){let o={...this.model.pose};this.poses=this.model.steps.map(n=>{let r=o;return o={...o,...n.pose},r})}return this.poses[e]}};var Z=Math.SQRT1_2,nn=[0,Z],I=[0,-Z],on=[Z,0],rn=[-Z,0],we=1-Z,D=[Math.SQRT2-1,we],Y=[1-Math.SQRT2,we],dn=t=>[t*Math.sin(Math.PI/16),-Z+Math.cos(Math.PI/16)],ye=dn(1),no=dn(-1),an=(()=>{let t=[0,2-Z],e=[ye[0]-I[0],ye[1]-I[1]],o=[t[0]-D[0],t[1]-D[1]],n=e[0]*o[1]-e[1]*o[0],r=((D[0]-I[0])*o[1]-(D[1]-I[1])*o[0])/n;return I[1]+e[1]*r})(),Ht=.263,sn=9*Math.PI/180,cn=.26,oo=-55*Math.PI/180;function ln(t,[e,o]){let n=[o[0]-e[0],o[1]-e[1]],r=((t[0]-e[0])*n[0]+(t[1]-e[1])*n[1])/(n[0]*n[0]+n[1]*n[1]);return[2*(e[0]+n[0]*r)-t[0],2*(e[1]+n[1]*r)-t[1]]}var Pe=([t,e])=>t>0&&e>0,ro=([t,e])=>t<0&&e>0,ao=([t,e])=>t>0&&e<0,Me=([t,e])=>t<0&&e<0,Qt=([t,e])=>e>Math.abs(t),It=([t,e])=>t>Math.abs(e),xe=([t,e])=>e<-Math.abs(t),ve=([t,e])=>t<-Math.abs(e),hn=t=>t>0?Qt:ve,un=t=>t>0?It:xe,me=t=>t>0?Pe:Me,so=t=>t>0?e=>Qt(e)&&e[0]<0:e=>ve(e)&&e[1]>0,io=t=>t>0?e=>It(e)&&e[1]<0:e=>xe(e)&&e[0]>0,be=t=>t>0?[0,1]:[-1,0],ge=t=>t>0?[1,0]:[0,-1],X=t=>e=>t(e.sheet),pt=(t,e,o)=>(e[0]-t[0])*(o[1]-t[1])-(e[1]-t[1])*(o[0]-t[0])>0;function ft(t,e){let o=t.find(n=>n.poly.some(r=>Math.hypot(r[0]-e[0],r[1]-e[1])<1e-7));if(!o)throw new Error(`crane: no face holds sheet point ${e}`);return o}function ke(){let t=new O({rx:-30,ry:12,ty:.7,tz:.5,o:0}),e=(l,b,M,w,u,g,y={})=>{let v=[];t.step({diagram:l,label:b,duration:.7,...y},k=>{v=k.fold(M,w,{side:u,toward:g,at:[.06,1]})}),t.step({diagram:l,label:"Unfold",duration:.42,ease:"inOut"},k=>{k.attach(v,k.hinge(M,w,u,-g,180,{ease:"inOut"}))})};t.step({diagram:1,label:"Start with a square",duration:1.1,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}}),e(2,"Fold in half diagonally",[-1,1],[1,-1],[1,1],1),e(2,"Fold the other diagonal",[-1,-1],[1,1],[1,-1],1),t.step({diagram:3,label:"Turn the paper over",duration:.8,ease:"inOut",pose:{ry:192},arc:{tz:.35}}),e(3,"Fold in half",[0,-1],[0,1],[-.5,0],-1),e(3,"Fold in half the other way",[-1,0],[1,0],[0,.5],-1),t.step({diagram:4,label:"Collapse into a square base",duration:1.4,ease:"inOut",pose:{s:1.22}},l=>{let b=[0,0],M=l.hinge(b,[0,1],[-.3,.8],-1),w=l.rot(b,[-1,1],"free",{free:0}),u=l.hinge(b,[-1,0],[-.8,-.3],-1),g=l.hinge(b,[0,-1],[.3,-.8],-1),y=l.rot(b,[1,-1],"free",{free:0}),v=l.rot([0,0,0],[0,0,1],-135),k=l.move([0,Z,0]),F=A=>l.select(X(A)),E=F(A=>It(A)&&A[1]>0),S=F(A=>It(A)&&A[1]<0);l.attach(F(Pe),v,k),l.attach(F(A=>Qt(A)&&A[0]<0),M,v,k),l.attach(F(A=>ve(A)&&A[1]>0),w,M,v,k),l.attach(F(Me),u,w,M,v,k),l.attach(F(A=>xe(A)&&A[0]>0),g,u,w,M,v,k),l.attach(S,y,g,u,w,M,v,k),l.pin(ft(S,[1,0]),ft(E,[1,0]),[1,0])});let o=(l,b)=>{let M=b?.8:1,w=[],u=[],g=[];t.step({diagram:5,label:b?"Repeat: edges to the centre":"Fold the edges to the centre",duration:.95*M},y=>{w=y.fold(I,D,{where:X(hn(l)),side:on,toward:l,at:[0,.72]}),u=y.fold(I,Y,{where:X(un(l)),side:rn,toward:l,at:[.28,1]})}),t.step({diagram:6,label:b?"Fold the top down":"Fold the top triangle down",duration:.65*M},y=>{g=y.fold(Y,D,{side:nn,toward:l})}),t.step({diagram:6,label:"Unfold the last three folds",duration:.8*M,ease:"inOut"},y=>{y.attach(g,y.hinge(Y,D,nn,-l,180,{at:[0,.6],ease:"inOut"})),y.attach(w,y.hinge(I,D,on,-l,180,{at:[.3,1],ease:"inOut"})),y.attach(u,y.hinge(I,Y,rn,-l,180,{at:[.3,1],ease:"inOut"}))}),t.step({diagram:7,label:b?"Petal fold the back":"Petal fold: lift the bottom point",duration:1.3*M,ease:"inOut",pose:{s:1.2,ty:-.33}},y=>{let v=(z,Dt)=>y.select(nt=>z(nt.sheet)&&nt.model[1]<we&&Dt(nt.model)),k=z=>pt(I,D,z)&&!pt(I,Y,z),F=v(me(l),k),E=v(me(l),z=>!pt(I,D,z)),S=v(me(l),z=>pt(I,Y,z)),A=v(so(l),z=>!pt(I,D,z)),j=v(io(l),z=>pt(I,Y,z)),_=y.hinge(Y,D,I,l),C=y.rot(I,D,"free"),G=y.rot(I,Y,"free"),N=y.rot(I,D,"free"),J=y.rot(I,Y,"free");y.attach(F,_),y.attach(E,C,_),y.attach(S,G,_),y.attach(A,N),y.attach(j,J),y.pin(ft(E,be(l)),ft(A,be(l)),be(l)),y.pin(ft(S,ge(l)),ft(j,ge(l)),ge(l))})};o(-1,!1),t.step({diagram:7,label:"Turn over",duration:.8,ease:"inOut",pose:{ry:372},arc:{tz:.3}}),o(1,!0);let n=(l,b,M)=>t.step({diagram:b,label:M,duration:1,ease:"inOut",pose:{s:1.3,ty:-.36}},w=>{w.fold(I,ye,{where:X(hn(l)),side:[.35,.1],toward:l,at:[0,.7]}),w.fold(I,no,{where:X(un(l)),side:[-.35,.1],toward:l,at:[.3,1]})});n(1,8,"Narrow the legs"),t.step({diagram:9,label:"Turn over",duration:.8,ease:"inOut",pose:{ry:552},arc:{tz:.3}}),n(-1,9,"Narrow the other side");let r=X(l=>Qt(l)||It(l)),s=l=>[I,[l*.097,Ht]],i=l=>[[0,Ht],[l*Math.cos(sn),Ht-Math.sin(sn)]],a=(l,b,M,w)=>{let u=[];return t.step({diagram:l,label:b,duration:1,ease:"inOut",pose:{s:1.45,ty:-.95}},g=>{u=g.reverse(g.select(y=>M(y.sheet)&&y.flat&&y.model[1]<Ht),i(w),{side:I,axis:s(w),front:r,kind:"inside"})}),()=>u},c=a(10,"Reverse fold the neck up",ro,1);a(11,"Reverse fold the tail up",ao,-1);let h=ln(I,i(1)),p=ln(s(1)[1],i(1)),f=[],P=[],m=[-1,an],d=[1,an],x=[0,1.2];return t.step({diagram:12,label:"Fold the wings down",duration:.9,ease:"inOut",pose:{s:1.55,ty:-.8}},l=>{f=l.fold(m,d,{where:X(b=>Pe(b)&&b[0]+b[1]>2-Math.SQRT2),side:x,toward:1,at:[0,.7]}),P=l.fold(m,d,{where:X(b=>Me(b)&&b[0]+b[1]<Math.SQRT2-2),side:x,toward:-1,at:[.3,1]})}),t.step({diagram:13,label:"Reverse fold the head",duration:.8,ease:"inOut"},l=>{let b=h[0]-p[0],M=h[1]-p[1],w=Math.hypot(b,M),u=Math.atan2(M,b),g=[h[0]-b/w*cn,h[1]-M/w*cn],y=(u+oo)/2,v=[g,[g[0]+Math.cos(y),g[1]+Math.sin(y)]];l.reverse(c(),v,{side:h,axis:[p,h],front:r,kind:"inside"})}),t.step({diagram:14,label:"Spread the wings",duration:1.5,ease:"inOut",pose:{ry:585,rx:-14,s:1.7,ty:-.9}},l=>{l.attach(f,l.hinge(m,d,x,-1,95,{ease:"inOut"})),l.attach(P,l.hinge(m,d,x,1,95,{ease:"inOut"}))}),t.step({diagram:14,label:"Finished crane",duration:.9,ease:"inOut"}),t.step({diagram:14,label:"Fly",duration:1,phase:"outro",ease:"in",pose:{ty:.7,tx:-.6,tz:.8,s:1.5,o:0}},l=>{l.attach(f,l.hinge(m,d,x,1,28,{ease:"flap"})),l.attach(P,l.hinge(m,d,x,-1,28,{ease:"flap"}))}),t.compile()}var B=Math.SQRT1_2,tt=[0,1],mn=Math.tan(Math.PI/8),co=Math.tan(Math.PI/16),lo=[-B,1-B/mn],ho=[B,1-B/mn],Kt=[-2*co,-1],Yt=.62,pn=.42,fn=50*Math.PI/180,Wt=[Math.cos(fn),Math.sin(fn)],et=[-Wt[1],Wt[0]];function uo(t){if(t<Yt){let o=2*Math.PI*V.inOut(t/Yt),n=Math.cos(o),r=Math.sin(o),s=[et[0]*n-et[1]*r,et[0]*r+et[1]*n],i=(1-n)/2;return{tx:pn*(et[0]-s[0]-et[0]*i),ty:pn*(et[1]-s[1]-et[1]*i),spin:o*180/Math.PI,rz:14*Math.sin(o)}}let e=V.in((t-Yt)/(1-Yt));return{tx:2.6*e*Wt[0],ty:2.6*e*Wt[1],spin:360,s:-.35*e,o:-e}}function Fe(){let t=new O({rx:-30,ry:12,ty:.7,tz:.5,o:0},[[-B,-1],[B,-1],[B,1],[-B,1]]);t.step({diagram:1,label:"Start with a sheet of paper",duration:1,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}});let e=[];t.step({diagram:2,label:"Fold in half lengthwise",duration:.65},r=>{e=r.fold([0,-1],[0,1],{side:[.3,0],toward:1,at:[.06,1]})}),t.step({diagram:2,label:"Unfold",duration:.4,ease:"inOut"},r=>{r.attach(e,r.hinge([0,-1],[0,1],[.3,0],-1,180,{ease:"inOut"}))}),t.step({diagram:3,label:"Fold the top corners to the centre",duration:.95},r=>{r.fold(tt,[-B,1-B],{side:[-B+.05,.98],toward:1,at:[0,.7]}),r.fold(tt,[B,1-B],{side:[B-.05,.98],toward:1,at:[.3,1]})}),t.step({diagram:4,label:"Fold the edges to the centre again",duration:.95,pose:{s:1.05}},r=>{r.fold(tt,lo,{side:[-.65,.2],toward:1,at:[0,.7]}),r.fold(tt,ho,{side:[.65,.2],toward:1,at:[.3,1]})}),t.step({diagram:5,label:"Fold the plane in half",duration:1,ease:"inOut",pose:{rz:-90,s:1.25,ty:-.3,tx:0}},r=>{r.fold([0,-1],[0,1],{side:[.3,0],toward:-1})});let o=[],n=[];return t.step({diagram:6,label:"Fold the wings down",duration:1,ease:"inOut"},r=>{o=r.fold(tt,Kt,{where:s=>s.sheet[0]<0,side:[-.6,-.8],toward:1,at:[0,.65]}),n=r.fold(tt,Kt,{where:s=>s.sheet[0]>0,side:[-.6,-.8],toward:-1,at:[.35,1]})}),t.step({diagram:7,label:"Open the wings",duration:1.3,ease:"inOut",pose:{rx:-30,ry:90,rz:0,spin:-40,s:1.25,ty:0,tx:0}},r=>{r.attach(o,r.hinge(tt,Kt,[-.6,-.8],-1,82,{ease:"inOut"})),r.attach(n,r.hinge(tt,Kt,[-.6,-.8],1,82,{ease:"inOut"}))}),t.step({diagram:7,label:"Ready to fly",duration:.6,ease:"inOut"}),t.step({diagram:7,label:"Fly",duration:2.1,phase:"outro",ease:"linear",path:uo}),t.compile({colourDown:!0})}var Ot=5,Se=2/Ot,it=(Ot-1)/2,po=84,fo=6,bn=t=>[[-1+t*Se,-1],[-1+t*Se,1]];function Ee(){let t=new O({rx:-42,ry:28,ty:.55,tz:.4,o:0});t.step({diagram:1,label:"Start with a square",duration:.6,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1}}),t.step({diagram:2,label:"Crease the pleats",duration:.01},e=>{for(let o=1;o<Ot;o++)e.split(e.select(),...bn(o))});for(let e=0;e<fo;e++)t.step({diagram:2,label:"Pleat",duration:1.45,ease:"breathe"},o=>{let n=[];for(let s=1;s<Ot;s++){let[i,a]=bn(s),c=s>it?1:-1,h=[i[0]+.1*c,0],p=.16*Math.abs(s-(it+.5))/it;n[s]=o.hinge(i,a,h,s%2?1:-1,po,{at:[p,.84+p],ease:"breathe"})}let r=s=>o.select(i=>Math.floor((i.sheet[0]+1)/Se)===s);for(let s=0;s<Ot;s++){if(s===it)continue;let i=[];if(s>it)for(let a=s;a>it;a--)i.push(n[a]);else for(let a=s+1;a<=it;a++)i.push(n[a]);o.attach(r(s),...i)}});return t.step({diagram:2,label:"Done",duration:.5,phase:"outro",ease:"in",pose:{o:0,s:.92}}),t.compile()}var mo=[{label:"Fold the top corner down",line:[[1,0],[0,1]],corner:[1,1]},{label:"Fold the bottom corner up",line:[[-1,0],[0,-1]],corner:[-1,-1]},{label:"Fold the right corner in",line:[[0,-1],[1,0]],corner:[1,-1]},{label:"Fold the left corner in",line:[[0,1],[-1,0]],corner:[-1,1]}];function Ae(){let t=new O({rx:-26,ry:8,rz:45,s:.92,ty:.55,tz:.4,o:0});return t.step({diagram:1,label:"Start with a square",duration:.7,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1}}),mo.forEach(({label:e,line:o,corner:n},r)=>{let s=r===3?{s:1.3}:r===1?{s:1.08}:void 0;t.step({diagram:r+2,label:e,duration:.6,pose:s},i=>{i.fold(o[0],o[1],{side:n,toward:1,at:[.05,1]})})}),t.step({diagram:5,label:"Sealed",duration:.7,ease:"inOut",arc:{s:-.05}}),t.step({diagram:5,label:"Into the inbox",duration:.6,phase:"outro",ease:"in",pose:{ty:-.5,s:1,o:0}}),t.compile({colourDown:!0})}var bo=-.3,mt=-.65,gn=mt-bo,go=t=>({rz:3.5*Math.sin(t*Math.PI*4),ty:.025*Math.sin(t*Math.PI*4+1.2)});function _e(){let t=new O({rx:-24,ry:190,ty:.6,tz:.4,o:0});return t.step({diagram:1,label:"Start with a square",duration:.8,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}}),t.step({diagram:2,label:"Fold in half diagonally",duration:.8},e=>{e.fold([-1,-1],[1,1],{side:[-1,1],toward:-1,at:[.05,1]})}),t.step({diagram:3,label:"Fold the bottom up for the hull",duration:.8,pose:{s:1.1,ty:.12}},e=>{e.fold([-1,mt],[1,mt],{side:[0,-.9],toward:-1})}),t.step({diagram:4,label:"Fold the stern corner behind",duration:.7,pose:{s:1.2,ty:.18}},e=>{e.fold([1,mt-gn*.62],[1+gn*.62,mt],{side:[1,mt],toward:1})}),t.step({diagram:5,label:"Afloat",duration:2.4,ease:"linear",path:go}),t.step({diagram:5,label:"Sail away",duration:1,phase:"outro",ease:"in",pose:{tx:1.5,s:1.05,o:0},arc:{rz:-3}}),t.compile()}var L=t=>[t[0],t[1],t[2]??0],bt=(t,e)=>[t[0]-e[0],t[1]-e[1],t[2]-e[2]],gt=(t,e)=>t[0]*e[0]+t[1]*e[1]+t[2]*e[2],yo=(t,e)=>[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]],Jt=t=>{let e=Math.hypot(t[0],t[1],t[2]);return[t[0]/e,t[1]/e,t[2]/e]};function U(t,e,o,n){let r=ot(L(t),Jt(bt(L(e),L(t))),o*Math.PI/180);return q(r,n[0],n[1],n[2])}function Ie(t,e,o,n){let r=Jt(bt(L(e),L(t))),s=c=>{let h=bt(c,L(t)),p=gt(h,r);return bt(h,[r[0]*p,r[1]*p,r[2]*p])},i=s(o),a=s(n);return Math.atan2(gt(r,yo(i,a)),gt(i,a))*180/Math.PI}function yn(t,e,o={}){let n=o.samples??181,r=o.window??30,s=o.step??.25,i=new Float64Array(n);i[0]=e;for(let a=1;a<n;a++){let c=a/(n-1),h=i[a-1],p=h,f=1/0;for(let P=-r;P<r;P+=s){let m=h+P,d=m+s,x=t(c,m),l=t(c,d);if(x===0||x*l<0){let b=m,M=d,w=x;for(let g=0;g<40;g++){let y=(b+M)/2,v=t(c,y);w*v<=0?M=y:(b=y,w=v)}let u=(b+M)/2;if(o.ok&&!o.ok(c,u))continue;Math.abs(u-h)<f&&(f=Math.abs(u-h),p=u)}}i[a]=p}return a=>{let c=Math.min(1,Math.max(0,a))*(n-1),h=Math.min(n-2,Math.floor(c));return i[h]+(i[h+1]-i[h])*(c-h)}}var W=.5,$=[0,.5],Le=[-W,1],Re=[W,1],Zt=[W,0],te=[-W,0],Te=[-W,.5],Ve=[W,.5],K=[0,0],Oe=55,Pn=42,Po=25,Mn=t=>{let e=(270+Po)/2*Math.PI/180;return[-t*Math.cos(e),Math.sin(e)]},wn=t=>[t*Math.sin(Math.PI/8),-Math.cos(Math.PI/8)],Xt=.125;function Mo([t,e]){if(e<0)return"body";let o=t-$[0],n=e-$[1];return n>Math.abs(o)?"top":n<-Math.abs(o)?"bottom":o<0?n>0?"upL":"lowL":n>0?"upR":"lowR"}var Lt=(...t)=>e=>t.includes(Mo(e.sheet)),Sn=([t,e])=>[t,e>-.5?e:-1-e];function wo(t){let[e,o]=Sn(t),n=Math.abs(e);return n<.25?o>-.25?"back":"rise":o>n-.5?"upper":o<-n?"lower":"middle"}var xo=t=>t[0]<0?-1:1,Rt=t=>t.sheet[1]<0,yt=(t,...e)=>o=>Rt(o)&&e.includes(wo(o.sheet))&&(t===0||xo(o.sheet)===t),ee=t=>180*V.inOut(t),En=t=>{let e=ee(t);return e>=180-1e-9?180:2*Math.atan(Math.tan(e/2*Math.PI/180)/Math.SQRT2)*180/Math.PI},xn=t=>e=>{let o=t<0?Le:Re,n=t<0?te:Zt,r=t<0?Te:Ve,s=t<0?-1:1,i=U($,[$[0]+1,$[1]],En(e),L(o)),a=U($,n,-s*ee(e),i);return Ie($,r,L(o),a)},vn=(t,e,o)=>U(t,e,10,L(o))[2]>0?1:-1;function kn(t){let e=[t*.25,-.25],o=[0,-.5],n=[t*.25,-.5],r=[-1,-.25],s=[1,-.25],i=vn(r,s,o),a=vn(e,K,o),c=M=>U(r,s,i*180*M,L(n)),h=M=>U(e,K,a*M,L(o)),p=M=>Jt(bt(M,L(e))),f=p(L(o)),P=p(h(90)),m=M=>{let w=p(c(M)),u=gt(w,f),g=gt(w,P),y=Math.atan2(g,u);return y<-Math.PI/2&&(y+=2*Math.PI),(y+Math.acos(Math.min(1,Math.SQRT1_2/Math.hypot(u,g))))*180/Math.PI},d=181,x=new Float64Array(d);for(let M=1;M<d;M++){let w=M/(d-1),u=U(r,s,-i*180*w,h(m(w))),g=Ie(e,n,L(o),u);for(;g-x[M-1]>180;)g-=360;for(;g-x[M-1]<-180;)g+=360;x[M]=g}let l=M=>{let w=Math.min(1,Math.max(0,M))*(d-1),u=Math.min(d-2,Math.floor(w));return x[u]+(x[u+1]-x[u])*(w-u)},b=V.inOut;return{rise:M=>i*180*b(M),mid:M=>a*m(b(M)),low:M=>l(b(M)),P:e,hinge:n}}var Fn=t=>{let e=t<.18?Math.sin(t/.18*Math.PI):0,o=t>.18?Math.min(1,(t-.18)/.62):0,n=t>.8?Math.sin((t-.8)/.2*Math.PI):0;return{ty:.5*Math.sin(o*Math.PI)-.03*e,spin:-12*Math.sin(o*Math.PI),s:-.05*(e+n)}},vo=t=>({ty:.45*Math.abs(Math.sin(t*Math.PI*2)),tx:-1.3*t,o:-Math.max(0,(t-.35)/.65)});function Ce(){let t=new O({rx:-28,s:.92,ty:.6,tz:.4,o:0},[[-W,-1],[W,-1],[W,1],[-W,1]]),e=(a,c,h,p,f,P)=>{let m=[];t.step({diagram:a,label:c,duration:.6},d=>{m=d.fold(h,p,{side:f,toward:P,at:[0,1]})}),t.step({diagram:a,label:"Unfold",duration:.38,ease:"inOut"},d=>{d.attach(m,d.hinge(h,p,f,-P,180,{ease:"inOut"}))})};t.step({diagram:3,label:"Start with a 1 : 2 rectangle",duration:.7,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}}),e(4,"Fold the corner to the far edge",Re,te,Le,1),e(5,"And the other corner",Le,Zt,Re,1),e(7,"Fold the top behind",Te,Ve,[0,.9],-1),t.step({diagram:9,label:"Collapse into a waterbomb base",duration:1.3,ease:"inOut",pose:{s:1.15,ty:-.25}},a=>{let c=a.rot($,te,d=>-ee(d)),h=a.rot($,Zt,d=>ee(d)),p=a.rot($,[$[0]+1,$[1]],En),f=a.rot($,Te,xn(-1)),P=a.rot($,Ve,xn(1)),m=d=>a.select(Lt(d));a.attach(m("lowL"),c),a.attach(m("upL"),f,c),a.attach(m("lowR"),h),a.attach(m("upR"),P,h),a.attach(m("top"),p),a.layer(m("top"),[...m("upL"),...m("upR")]),a.layer([...m("upL"),...m("upR")],[...m("lowL"),...m("lowR")]),a.layer([...m("lowL"),...m("lowR")],m("bottom"))});let o=[];t.step({diagram:10,label:"Fold the front legs up",duration:1,pose:{s:1.25}},a=>{o=[...a.fold(K,Mn(-1),{where:Lt("top","upL"),side:te,toward:1,at:[0,.7]}),...a.fold(K,Mn(1),{where:Lt("top","upR"),side:Zt,toward:1,at:[.3,1]})]}),t.step({diagram:12,label:"Fold the bottom up",duration:.8},a=>{a.fold([-1,-.5],[1,-.5],{where:Rt,side:[0,-1],toward:1})}),t.step({diagram:13,label:"Fold the sides to the centre",duration:.9,pose:{s:1.3,ty:.05}},a=>{let c=a.fold([-.25,-1],[-.25,1],{where:Lt("body","bottom","lowL"),side:[-.5,-.5],toward:1,at:[0,.7]}),h=a.fold([.25,-1],[.25,1],{where:Lt("body","bottom","lowR"),side:[.5,-.5],toward:1,at:[.3,1]}),p=new Set(a.select());a.layer(o.filter(f=>p.has(f)),[...c,...h])}),t.step({diagram:17,label:"Squash the bottom flaps out",duration:1.5,ease:"inOut",pose:{s:1.4,ty:.15}},a=>{a.split(a.select(yt(0,"back","rise")),[-1,-.25],[1,-.25]);for(let P of[-1,1]){let m=yt(P,"upper","middle","lower");a.split(a.select(m),[P*.25,-.25],K),a.split(a.select(m),[P*.25,-.25],[0,-.5])}let c=(P,...m)=>a.select(yt(P,...m)),[h,p]=[kn(-1),kn(1)],f=a.rot([-1,-.25],[1,-.25],h.rise);a.attach(c(0,"rise"),f);for(let[P,m]of[[-1,h],[1,p]])a.attach(c(P,"middle"),a.rot(m.P,K,m.mid)),a.attach(c(P,"lower"),a.rot(m.P,m.hinge,m.low),f);a.layer([...c(0,"rise"),...c(0,"lower")],c(0,"middle")),a.layer(c(0,"middle"),[...c(0,"upper"),...c(0,"back")]),a.layer(c(0,"rise"),[...c(0,"upper"),...c(0,"back")])});let n=a=>c=>{let[h,p]=Sn(c.sheet);return-.5-p>-a*h},r=a=>c=>yt(a,"middle","lower")(c)||yt(0,"rise")(c)&&n(a)(c);t.step({diagram:18,label:"Fold the flaps down",duration:.9},a=>{for(let c of[-1,1])a.split(a.select(yt(0,"rise")),[c*.25,-.25],K);a.fold([-.25,-.25],K,{where:r(-1),side:[-.4,-.05],toward:1,at:[0,.7]}),a.fold([.25,-.25],K,{where:r(1),side:[.4,-.05],toward:1,at:[.3,1]})}),t.step({diagram:19,label:"Fold the back legs out",duration:.9},a=>{a.fold(K,wn(-1),{where:r(-1),side:[-.02,-.45],toward:1,at:[0,.7]}),a.fold(K,wn(1),{where:r(1),side:[.02,-.45],toward:1,at:[.3,1]})}),t.step({diagram:20,label:"Fold the back legs up",duration:.8,pose:{s:1.7,ty:-.15}},a=>{a.split(a.select(),[-1,0],[1,0]),a.fold([-1,0],[1,0],{where:Rt,side:[0,-.2],toward:1})});let s=[];t.step({diagram:21,label:"Fold them back down in half",duration:.8},a=>{s=a.fold([-1,Xt],[1,Xt],{where:Rt,side:[0,.3],toward:1})});let i=(a,c,h,p={})=>{let f=new Set(s),P=a.select(Rt),m=h*Math.PI/180,d=Xt*Math.cos(m),x=Xt*Math.sin(m),l=a.rot([-1,0,0],[1,0,0],c,p),b=a.rot([-1,d,x],[1,d,x],-c,p);a.attach(P.filter(M=>!f.has(M)),l),a.attach(P.filter(M=>f.has(M)),b,l)};return t.step({diagram:22,label:"Turn over",duration:1,ease:"inOut",pose:{ry:180,rx:-70,rz:-35,s:2.1,ty:.25},arc:{tz:.3}},a=>{i(a,Oe,0,{ease:"inOut",at:[.4,1]})}),t.step({diagram:22,label:"Hop",duration:1,ease:"linear",path:Fn},a=>i(a,-Pn,Oe,{ease:"breathe",at:[0,.36]})),t.step({diagram:22,label:"Hop again",duration:1,ease:"linear",path:Fn},a=>i(a,-Pn,Oe,{ease:"breathe",at:[0,.36]})),t.step({diagram:22,label:"Hop away",duration:1.2,phase:"outro",ease:"linear",path:vo}),t.compile({colourDown:!0})}var Tt=[0,-1],Pt=(t,e,o=3)=>{let n=t*Math.PI/180;return[e*o*Math.sin(n),-1+o*Math.cos(n)]},An=t=>t*Math.PI/180,_n=15,ko=278,Fo=11.25,In=.29,On=.3;function Ln(t,[e,o]){let n=[o[0]-e[0],o[1]-e[1]],r=((t[0]-e[0])*n[0]+(t[1]-e[1])*n[1])/(n[0]*n[0]+n[1]*n[1]);return[2*(e[0]+n[0]*r)-t[0],2*(e[1]+n[1]*r)-t[1]]}var Rn=(t,e)=>[t,[t[0]+Math.cos(An(e)),t[1]+Math.sin(An(e))]];function So(t,e){let o=0;for(let n=0;n<t.length;n++){let r=t[n],s=t[(n+1)%t.length],i=(s[0]-r[0])*(e[1]-r[1])-(s[1]-r[1])*(e[0]-r[0]);if(!(Math.abs(i)<1e-9)){if(o&&Math.sign(i)!==o)return!1;o=Math.sign(i)}}return!0}var Eo=t=>({ty:.03*Math.sin(t*Math.PI*2),rz:1.5*Math.sin(t*Math.PI*2+.8)});function ze(){let t=new O({rx:-20,ry:180,ty:.6,tz:.4,o:0},[[0,-1],[1,0],[0,1],[-1,0]]);t.step({diagram:1,label:"Start with a square",duration:.7,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}}),t.step({diagram:2,label:"Fold the edges to the centre",duration:.9},a=>{a.fold(Tt,Pt(22.5,-1),{side:[-1,0],toward:-1,at:[0,.7]}),a.fold(Tt,Pt(22.5,1),{side:[1,0],toward:-1,at:[.3,1]})}),t.step({diagram:3,label:"Turn over",duration:.7,ease:"inOut",pose:{ry:360},arc:{tz:.3}}),t.step({diagram:4,label:"Fold the edges to the centre again",duration:.9,pose:{s:1.1}},a=>{a.fold(Tt,Pt(11.25,-1),{side:Pt(17,-1,.75),toward:1,at:[0,.7]}),a.fold(Tt,Pt(11.25,1),{side:Pt(17,1,.75),toward:1,at:[.3,1]})});let e=[];t.step({diagram:5,label:"Fold the point up to the top",duration:.8,pose:{s:1.25,ty:-.3}},a=>{e=a.fold([-1,0],[1,0],{side:Tt,toward:1}).map(c=>c.poly)});let o=a=>e.some(c=>So(c,Ao(a.poly)));t.step({diagram:6,label:"Fold in half",duration:.9,ease:"inOut",pose:{rz:90,rx:-10,s:1.5,tx:.62,ty:.2}},a=>{a.fold([0,-1],[0,1],{side:[.5,.5],toward:-1})});let n=a=>a.sheet[0]<0,r=Rn([0,In],(90+_n)/2),s=[[0,In],[0,1]],i=[];return t.step({diagram:7,label:"Pull the neck up",duration:1.1,ease:"inOut",pose:{rz:90-Fo,s:1.6,tx:.34,ty:-.22}},a=>{i=a.reverse(a.select(c=>c.flat).filter(o),r,{side:[0,1],axis:s,front:n,kind:"outside",roll:"last",book:!0})}),t.step({diagram:8,label:"Reverse fold the head",duration:.8,ease:"inOut"},a=>{let c=Ln([0,1],r),h=Ln(s[0],r),p=Math.hypot(c[0]-h[0],c[1]-h[1]),f=[c[0]+(h[0]-c[0])/p*On,c[1]+(h[1]-c[1])/p*On];a.reverse(i,Rn(f,(_n+ko)/2),{side:c,axis:[h,c],front:n,kind:"inside"})}),t.step({diagram:8,label:"Drift",duration:2.4,ease:"linear",path:Eo}),t.step({diagram:8,label:"Glide away",duration:1.1,phase:"outro",ease:"in",pose:{tx:2.4,o:0}}),t.compile()}function Ao(t){let e=0,o=0;for(let n of t)e+=n[0],o+=n[1];return[e/t.length,o/t.length]}var Ne=.5,Vt=-.25,De=[0,Vt],Tn=.12,Vn=t=>{let e=(o,n,r)=>r*Math.exp(-(((t-o)/n)**2));return{s:e(.18,.06,.09)+e(.36,.07,.06)}};function Be(){let t=new O({rx:-16,ry:180,ty:.6,tz:.4,o:0},[[0,-1],[1,0],[0,1],[-1,0]]);return t.step({diagram:1,label:"Start with a square",duration:.7,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}}),t.step({diagram:2,label:"Fold the top corner to the centre",duration:.7},e=>{e.fold([-1,Ne],[1,Ne],{side:[0,1],toward:-1,at:[.05,1]})}),t.step({diagram:3,label:"Fold the bottom corner up",duration:.8},e=>{e.fold([-1,Vt],[1,Vt],{side:[0,-1],toward:-1})}),t.step({diagram:4,label:"Fold the sides up to the centre",duration:1,pose:{s:1.3,ty:-.2}},e=>{e.fold(De,[-1,Vt+1],{side:[-.9,-.05],toward:-1,at:[0,.7]}),e.fold(De,[1,Vt+1],{side:[.9,-.05],toward:-1,at:[.3,1]})}),t.step({diagram:5,label:"Fold the corners behind",duration:.9,pose:{s:1.55,ty:-.4}},e=>{let o=[];for(let n of[-1,1]){let r=[n*.25,.75],s=[n*.625,.375],i=[0,Ne];o.push({p:r,a:i,b:s,top:!0},{p:s,a:r,b:De,top:!1})}o.forEach(({p:n,a:r,b:s,top:i},a)=>{let c=p=>{let f=[p[0]-n[0],p[1]-n[1]],P=Math.hypot(f[0],f[1]);return[n[0]+f[0]/P*Tn,n[1]+f[1]/P*Tn]},h=Math.sign(n[0]);e.fold(c(r),c(s),{where:i?p=>p.model[0]*h>-.1:void 0,side:n,toward:1,at:[a*.12,.64+a*.12]})})}),t.step({diagram:5,label:"Beat",duration:1.1,ease:"linear",path:Vn}),t.step({diagram:5,label:"Beat again",duration:1.1,ease:"linear",path:Vn}),t.step({diagram:5,label:"Float away",duration:1,phase:"outro",ease:"in",pose:{ty:.4,s:1.35,o:0}}),t.compile()}var wt=Math.SQRT2-1,ae=[0,1],Ct=[0,-1],ne=[0,0],H=t=>[t*wt,0],xt=t=>[t,0],se=t=>[t*Math.SQRT1_2,1-Math.SQRT1_2],ie=t=>[t*Math.SQRT1_2,Math.SQRT1_2-1],Cn=.3,zn=(1+wt)/2,oe=-.7,_o=350,Io=12;function Bn([t,e]){if(Math.abs(t)/wt+Math.abs(e)<1)return"centre";let o=t<0?-1:1,n=e>0,r=H(o),s=n?se(o):ie(o);return Math.sign(T(r,s,[t,e]))===Math.sign(T(r,s,xt(o)))?n?"upEar":"lowEar":n?"upMain":"lowMain"}var Mt=(...t)=>e=>t.includes(Bn(e.sheet)),re=Mt("upEar","lowEar"),Oo=(t,e,o)=>U(t,e,10,L(o))[2]<0?1:-1,Nn=t=>180*V.inOut(t);function Lo(t,e){let o=e?ae:Ct,n=e?se(t):ie(t),r=Oo(H(t),o,xt(t)),s=(a,c)=>U(H(t),o,r*180*a,U(H(t),n,c,L(xt(t)))),i=yn((a,c)=>s(a,c)[1],0,{ok:(a,c)=>s(a,c)[2]<=1e-9});return{kite:a=>r*Nn(a),ear:a=>i(Nn(a)/180)}}var Dn=t=>({ty:.04*Math.sin(t*Math.PI*2),rz:2.5*Math.sin(t*Math.PI*2-.6)});function $e(){let t=new O({rx:-20,ry:180,ty:.6,tz:.4,o:0},[[0,-1],[1,0],[0,1],[-1,0]]);t.step({diagram:1,label:"Start with a square",duration:.7,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}});let e=(n,r,s)=>{let i=[];t.step({diagram:n,label:r,duration:.8},a=>{i=[-1,1].map(c=>a.fold(s,H(c),{side:xt(c),toward:-1,at:c<0?[0,.7]:[.3,1]}))}),t.step({diagram:n,label:"Unfold",duration:.45,ease:"inOut"},a=>{[-1,1].forEach((c,h)=>a.attach(i[h],a.hinge(s,H(c),xt(c),1,180,{ease:"inOut"})))})};e(2,"Fold the bottom edges to the centre",Ct),e(3,"Fold the top edges to the centre",ae),t.step({diagram:4,label:"Collapse into a fish base",duration:1.4,ease:"inOut",pose:{s:1.1}},n=>{for(let r of[-1,1]){let s=i=>Bn(n.info(i).sheet)!=="centre"&&r*n.info(i).sheet[0]>0;n.split(n.select().filter(s),[-1,0],[1,0]),n.split(n.select(Mt("upMain","upEar")).filter(s),H(r),se(r)),n.split(n.select(Mt("lowMain","lowEar")).filter(s),H(r),ie(r));for(let i of[!0,!1]){let a=i?ae:Ct,c=i?se(r):ie(r),h=Lo(r,i),p=n.rot(H(r),a,h.kite),f=n.rot(H(r),c,h.ear),P=m=>n.select(Mt(m)).filter(d=>r*n.info(d).sheet[0]>0);n.attach(P(i?"upMain":"lowMain"),p),n.attach(P(i?"upEar":"lowEar"),f,p)}}}),t.step({diagram:4,label:"Flatten the ears down",duration:.8,ease:"inOut"},n=>{for(let r of[-1,1]){let i=U(H(r),ne,90,[0,0,-wt])[1]<0?90:-90;n.attach(n.select(re).filter(a=>r*n.info(a).sheet[0]>0),n.rot(L(H(r)),L(ne),i,{ease:"inOut"}))}n.layer(n.select(Mt("lowEar")),n.select(Mt("upEar")))}),t.step({diagram:5,label:"Fold the tip back",duration:.7},n=>{n.fold([-1,zn],[1,zn],{side:ae,toward:1})}),t.step({diagram:5,label:"Turn over",duration:.8,ease:"inOut",pose:{ry:360},arc:{tz:.3}}),t.step({diagram:6,label:"Fold the corners in",duration:.7,pose:{s:1.15}},n=>{for(let r of[-1,1])n.fold([r*Cn,-1],[r*Cn,1],{side:xt(r),toward:1,at:r<0?[0,.7]:[.3,1]})}),t.step({diagram:7,label:"Fold in half",duration:.9,ease:"inOut",pose:{rz:90,rx:-12,s:1.45,tx:.2,ty:-.05}},n=>{n.fold([0,-1],[0,1],{side:[.3,0],toward:1})}),t.step({diagram:8,label:"Fold the flippers down",duration:.8},n=>{n.fold(ne,[-1,-1],{where:r=>re(r)&&r.sheet[0]>0,side:[0,-wt],toward:1,at:[0,.7]}),n.fold(ne,[-1,-1],{where:r=>re(r)&&r.sheet[0]<0,side:[0,-wt],toward:-1,at:[.3,1]})});let o=[];return t.step({diagram:9,label:"Lift the tail",duration:.9,ease:"inOut",pose:{s:1.5}},n=>{let r=(270+_o)/2*Math.PI/180,s=[[0,oe],[-Math.cos(r),oe-Math.sin(r)]];o=n.reverse(n.select(i=>i.flat&&!re(i)),s,{side:Ct,axis:[[0,oe],Ct],front:i=>i.sheet[0]>0,kind:"outside",roll:"last",book:!0})}),t.step({diagram:10,label:"Swim",duration:1.4,ease:"linear",path:Dn},n=>{n.attach(o,n.swing([0,oe],Io,{ease:"breathe"}))}),t.step({diagram:10,label:"Swim on",duration:1.4,ease:"linear",path:Dn}),t.step({diagram:10,label:"Dive",duration:1,phase:"outro",ease:"in",pose:{ty:-.9,rz:112,o:0}}),t.compile()}var $n=[0,0],jn=[0,-1],Ro=-.3,Gn=-.9,To=28,Vo=t=>t[0]<-Math.abs(t[1]),Co=t=>t[0]>Math.abs(t[1]),qn=t=>[[t*.5,-.5],[0,Ro]],zo=t=>({rz:9*Math.sin(t*Math.PI*2)*Math.sin(t*Math.PI)});function je(){let t=new O({rx:-14,ry:180,ty:.6,tz:.4,o:0},[[0,-1],[1,0],[0,1],[-1,0]]);t.step({diagram:1,label:"Start with a square",duration:.7,phase:"intro",ease:"out",pose:{ty:0,tz:0,o:1},arc:{rz:-4}}),t.step({diagram:2,label:"Fold the top corner down",duration:.7},o=>{o.fold([-1,0],[1,0],{side:[0,1],toward:-1,at:[.05,1]})}),t.step({diagram:3,label:"Fold the corners to the bottom",duration:.9,pose:{s:1.4,ty:.25}},o=>{o.fold($n,[-.5,-.5],{side:[-1,0],toward:-1,at:[0,.7]}),o.fold($n,[.5,-.5],{side:[1,0],toward:-1,at:[.3,1]})});let e=[];return t.step({diagram:4,label:"Fold the ears up",duration:1,pose:{s:1.55,ty:.2}},o=>{e=[-1,1].map((n,r)=>o.fold(...qn(n),{where:s=>(n<0?Vo:Co)(s.sheet),side:jn,toward:-1,at:r?[.3,1]:[0,.7]}))}),t.step({diagram:5,label:"Tuck the nose behind",duration:.6,pose:{s:1.6,ty:.28}},o=>{o.fold([-1,Gn],[1,Gn],{side:jn,toward:1})}),t.step({diagram:6,label:"Tilt the head",duration:1.6,ease:"linear",path:zo}),t.step({diagram:6,label:"Twitch the ears",duration:.9,ease:"linear"},o=>{e.forEach((n,r)=>{let s=r?1:-1,[i,a]=qn(s);o.attach(n,o.hinge(i,a,[s*.6,.3],-1,To,{ease:"breathe",at:r?[.25,1]:[0,.75]}))})}),t.step({diagram:6,label:"Trot off",duration:.9,phase:"outro",ease:"in",pose:{tx:-1.4,o:0},arc:{ty:.08}}),t.compile()}var qe=new Map([["crane",ke],["plane",Fe],["pleat",Ee],["envelope",Ae],["boat",_e],["frog",Ce],["swan",ze],["heart",Be],["whale",$e],["fox",je]]),Ge=new Map;function No(){return[...qe.keys()]}function Do(t,e){qe.set(t,e),Ge.delete(t)}function Ue(t){let e=Ge.get(t);if(!e){let o=qe.get(t);if(!o)return;e=new _t(o()),Ge.set(t,e)}return e}var ce={distance:5,light:St([-.45,.7,.75])};function Bo(t){return R(lt(t.tx,t.ty,t.tz),R(ue(t.spin*Q),R(Je(t.s),R(Ye(t.rx*Q),R(We(t.ry*Q),ue(t.rz*Q))))))}var Un=1e-6;function Hn(t,e,o){let n=t.normal,r=at(n,Ft(o,t.center))>=0?1:-1,s=!1,i=!1;for(let a of e.pts){let c=at(n,Ft(a,t.center))*r;if(c>Un?s=!0:c<-Un&&(i=!0),s&&i)return 0}return s?1:i?-1:0}function $o(t,e){for(let o of[t,e])for(let n=0;n<o.length;n++){let r=o[n],s=o[(n+1)%o.length],i=r[1]-s[1],a=s[0]-r[0],c=Math.hypot(i,a);if(c<1e-9)continue;let h=1/0,p=-1/0,f=1/0,P=-1/0;for(let m of t){let d=(m[0]*i+m[1]*a)/c;d<h&&(h=d),d>p&&(p=d)}for(let m of e){let d=(m[0]*i+m[1]*a)/c;d<f&&(f=d),d>P&&(P=d)}if(p<=f+1e-4||P<=h+1e-4)return!1}return!0}function jo(t,e,o){let n=0,r;for(let h of t.polys)for(let p of e.polys){let f=Bt(h,p);if(f.length<3)continue;let P=Math.abs(st(f));P>n&&(n=P,r=Et(f))}if(!r||n<1e-7)return 0;let s=[r[0],-r[1],-o],i=h=>{let p=at(h.normal,s);return Math.abs(p)<1e-12?1/0:(h.normal[0]*h.center[0]+h.normal[1]*h.center[1]+h.normal[2]*(h.center[2]-o))/p},a=i(t),c=i(e);return!isFinite(a)||!isFinite(c)||a===c?0:c<a?1:-1}function Qn(t,e=ce){let o=[0,0,e.distance],n=t.length,r=t.map(h=>tn(h.scr)),s=t.map(()=>[]),i=new Int32Array(n);for(let h=0;h<n;h++){let p=t[h];for(let f=h+1;f<n;f++){let P=t[f];if(p.box[2]<=P.box[0]||P.box[2]<=p.box[0]||p.box[3]<=P.box[1]||P.box[3]<=p.box[1]||!$o(r[h],r[f]))continue;let m=-Hn(p,P,o);m||(m=Hn(P,p,o)),m||(m=-jo(p,P,e.distance)),m&&(m<0?(s[h].push(f),i[f]++):(s[f].push(h),i[h]++))}}let a=[],c=new Uint8Array(n);for(let h=0;h<n;h++){let p=-1;for(let f=0;f<n;f++)!c[f]&&i[f]===0&&(p<0||t[f].depth>t[p].depth)&&(p=f);if(p<0)for(let f=0;f<n;f++)!c[f]&&(p<0||t[f].depth>t[p].depth)&&(p=f);c[p]=1,a.push(p);for(let f of s[p])i[f]--}return a}function Go(t,e,o=ce){let n=t.faces.length,r=Bo(e.pose),s=o.distance,i=[0,0,s],a=new Array(n),c=new Array(n),h=new Array(n),p=new Array(n);for(let l=0;l<n;l++){let b=e.T[l];p[l]=[b[2],b[6],b[10]],a[l]=R(r,R(lt(e.lift[3*l],e.lift[3*l+1],e.lift[3*l+2]),b)),c[l]=t.faces[l].map(M=>q(a[l],t.verts[M][0],t.verts[M][1],0)),h[l]=c[l].map(([M,w,u])=>{let g=s/(s-u);return[M*g,-w*g]})}let f=Int32Array.from({length:n},(l,b)=>b),P=l=>f[l]===l?l:f[l]=P(f[l]),m=new Uint8Array(t.edges.length);t.edges.forEach((l,b)=>{if(l.faces.length!==2)return;let[M,w]=l.faces;if(at(p[M],p[w])>1-1e-9){m[b]=1;let u=e.lift;Math.abs(u[3*M]-u[3*w])+Math.abs(u[3*M+1]-u[3*w+1])+Math.abs(u[3*M+2]-u[3*w+2])<1e-9&&(f[P(M)]=P(w))}});let d=new Map;for(let l=0;l<n;l++){let b=P(l),M=d.get(b);M?M.push(l):d.set(b,[l])}let x=[];for(let l of d.values()){let b=[],M=[],w=[0,0,0],u=[1/0,1/0,-1/0,-1/0];for(let v of l)for(let k=0;k<c[v].length;k++){b.push(c[v][k]),M.push(h[v][k]);let[F,E]=h[v][k];F<u[0]&&(u[0]=F),F>u[2]&&(u[2]=F),E<u[1]&&(u[1]=E),E>u[3]&&(u[3]=E)}for(let v of b)w[0]+=v[0]/b.length,w[1]+=v[1]/b.length,w[2]+=v[2]/b.length;let g=a[l[0]],y=Ft(i,w);x.push({faces:l,pts:b,scr:M,polys:l.map(v=>ht(h[v].slice())),normal:St([g[2],g[6],g[10]]),center:w,depth:Math.hypot(y[0],y[1],y[2]),box:u})}return{W:a,pts:c,scr:h,flat:m,panels:x,order:Qn(x,o)}}var He="http://www.w3.org/2000/svg",ct=t=>Math.round(t*1e3)/1e3,zt=class{constructor(e,o,n=ce){this.root=e;this.m=o;this.cam=n;this.slots=[];this.uid=Math.random().toString(36).slice(2,8);e.textContent="",this.defs=document.createElementNS(He,"defs"),this.image=document.createElementNS(He,"image"),this.image.id=`${this.uid}-img`;for(let[r,s]of[["width","2"],["height","2"],["preserveAspectRatio","none"]])this.image.setAttribute(r,s);this.defs.appendChild(this.image),e.appendChild(this.defs)}setTexture(e){this.image.setAttribute("href",e)}slot(e){let o=this.slots[e];if(o)return o;let n=(P,m)=>{let d=document.createElementNS(He,P);return m&&d.setAttribute("class",m),d},r=n("pattern");r.id=`${this.uid}-t${e}`,r.setAttribute("patternUnits","userSpaceOnUse"),r.setAttribute("width","2"),r.setAttribute("height","2");let s=n("use");s.setAttribute("href",`#${this.uid}-img`),r.appendChild(s),this.defs.appendChild(r);let i=n("path","f"),a=n("path","t");a.style.fill=`url(#${r.id})`;let c=n("g"),h=c.appendChild(n("path","m")),p=c.appendChild(n("path","a")),f=c.appendChild(n("path","e"));return this.root.append(i,a,c),o={fill:i,tex:a,pattern:r,lines:c,mem:h,act:p,edge:f,cache:["","","","","","","",""]},this.slots[e]=o,o}render(e){let o=this.m,n=this.cam.distance,r=[0,0,n],{W:s,scr:i,flat:a,panels:c,order:h}=Go(o,e,this.cam),p=e.step;for(let f=0;f<h.length;f++){let P=c[h[f]],m=this.slot(f),d="",x="",l="",b="";for(let C of P.faces){let G=i[C];for(let N=0;N<G.length;N++)d+=(N?"L":"M")+ct(G[N][0])+" "+ct(G[N][1]);d+="Z",o.faceEdges[C].forEach((N,J)=>{let z=G[J],Dt=G[(J+1)%G.length],nt=`M${ct(z[0])} ${ct(z[1])}L${ct(Dt[0])} ${ct(Dt[1])}`,vt=o.edges[N];if(vt.faces.length<2||!a[N])b+=nt;else{let Jn=vt.faces[0]===C?vt.faces[1]:vt.faces[0];vt.born<=p&&(x+=nt),e.group[C]!==e.group[Jn]&&(l+=nt)}})}let M=s[P.faces[0]],w=at(P.normal,Ft(r,P.center))>0,u=w?P.normal:[-P.normal[0],-P.normal[1],-P.normal[2]],g=Math.max(0,at(u,this.cam.light)),y=w!==!!o.colourDown,v=y?"f":"b",k=`color-mix(in oklab,var(--_l${v}) ${Math.round((.15+.85*g)*100)}%,var(--_s${v}))`,F=y?"front":"back",E=o.faces[P.faces[0]],S=0,A=0;for(let C of E)S+=o.verts[C][0]/E.length,A+=o.verts[C][1]/E.length;let j=qo(M,n,S,A),_=m.cache;_[0]!==d&&(m.fill.setAttribute("d",_[0]=d),m.tex.setAttribute("d",d)),_[1]!==x&&m.mem.setAttribute("d",_[1]=x),_[2]!==l&&m.act.setAttribute("d",_[2]=l),_[3]!==b&&m.edge.setAttribute("d",_[3]=b),_[4]!==k&&m.fill.style.setProperty("--f",_[4]=k),_[5]!==F&&m.lines.setAttribute("class",_[5]=F),_[6]!==j&&m.pattern.setAttribute("patternTransform",_[6]=j),_[7]!=="1"&&(_[7]="1",m.fill.style.display=m.tex.style.display=m.lines.style.display="")}for(let f=h.length;f<this.slots.length;f++){let P=this.slots[f];P.cache[7]!=="0"&&(P.cache[7]="0",P.fill.style.display=P.tex.style.display=P.lines.style.display="none")}this.root.style.opacity=String(ct(e.pose.o))}};function qo(t,e,o,n){let r=(b,M)=>{let[w,u,g]=q(t,b,M,0),y=e/(e-g);return[w*y,-u*y]},i=r(o,n),a=r(o+.25,n),c=r(o,n+.25),h=(a[0]-i[0])/.25,p=(a[1]-i[1])/.25,f=-(c[0]-i[0])/.25,P=-(c[1]-i[1])/.25,m=o+1,d=1-n,x=i[0]-h*m-f*d,l=i[1]-p*m-P*d;return`matrix(${[h,p,f,P,x,l].map(b=>Math.round(b*1e4)/1e4).join(" ")})`}var Kn=`
2
2
  :host{display:inline-block;width:160px;height:160px;vertical-align:middle;contain:layout paint style;
3
3
  --_ink:var(--ol-ink,#17171a);--_bg:var(--ol-bg,#fff);--_paper:var(--ol-paper,#fffefb);--_sw:var(--ol-stroke,1.5px);
4
4
  --_front:var(--ol-front,#e2553a);--_back:var(--ol-back,#f6f3ec);
@@ -38,4 +38,4 @@ path{vector-effect:non-scaling-stroke;stroke-linejoin:round;stroke-linecap:round
38
38
  [data-look=paper]{--_lf:var(--_front);--_sf:color-mix(in oklab,var(--_front) 68%,#1a0f0c);--_lb:var(--_back);--_sb:color-mix(in oklab,var(--_back) 82%,#6f6a60);--_grain:.7}
39
39
  [data-look=paper] .e{stroke:#000;stroke-opacity:.28;stroke-width:calc(var(--_sw)*.55)}
40
40
  [data-look=paper] .m{stroke:#000;stroke-opacity:.12;stroke-width:calc(var(--_sw)*.5)}
41
- `;var Un=new Map,Hn=t=>t<=220?256:t<=460?512:1024;function Ge(t,e="paper"){let o=`${e}:${t}`,n=Un.get(o);if(!n){let r=()=>new Promise(a=>setTimeout(()=>$o(t,a),0));n=e==="grain"?r():import("./chunks/paper-shader-ZKC3EUTY.js").then(a=>a.renderPaperShader(t)).catch(()=>{}).then(a=>a??r()),Un.set(o,n)}return n}function Bo(t){return()=>{t|=0,t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}function ae(t,e,o){let n=e+1,r=new Float32Array(n*n);for(let s=0;s<r.length;s++)r[s]=o();let a=new Float32Array(t*t),i=e/t;for(let s=0;s<t;s++){let l=s*i,h=l|0,d=l-h,p=d*d*(3-2*d);for(let x=0;x<t;x++){let y=x*i,f=y|0,P=y-f,c=P*P*(3-2*P),m=h*n+f,v=r[m]+(r[m+1]-r[m])*c,M=r[m+n]+(r[m+n+1]-r[m+n])*c;a[s*t+x]=v+(M-v)*p}}return a}function $o(t,e){if(typeof document>"u")return e("");let o=document.createElement("canvas");o.width=o.height=t;let n=o.getContext("2d");if(!n)return e("");let r=Bo(61469),a=t/512,i=t*t;n.fillStyle="#000",n.fillRect(0,0,t,t),n.lineCap="round";let s=Math.round(420*a*a);for(let M=0;M<s;M++){let u=r()*t,b=r()*t,g=r()*Math.PI,w=(6+r()*r()*70)*a,k=(r()-.5)*w*.9,F=Math.cos(g),E=Math.sin(g);n.strokeStyle=`rgba(255,255,255,${.12+r()*.4})`,n.lineWidth=(.5+r()*1.2)*a,n.beginPath(),n.moveTo(u,b),n.quadraticCurveTo(u+F*w/2-E*k,b+E*w/2+F*k,u+F*w,b+E*w),n.stroke()}let l=n.getImageData(0,0,t,t).data,h=new Float32Array(i);for(let M=0;M<i;M++)h[M]=r();let d=ae(t,Math.round(110*a),r),p=new Float32Array(i);for(let M=0;M<t;M++)for(let u=0;u<t;u++){let b=0;for(let w=-1;w<=1;w++){let k=Math.min(t-1,Math.max(0,M+w))*t;for(let F=-1;F<=1;F++)b+=h[k+Math.min(t-1,Math.max(0,u+F))]}let g=M*t+u;p[g]=b/9*.55+d[g]*.45+l[g*4]/255*.9}let x=ae(t,3,r),y=ae(t,7,r),f=ae(t,16,r),P=n.createImageData(t,t),c=P.data,m=-.62,v=-.78;for(let M=0;M<t;M++){let u=Math.max(0,M-1)*t,b=Math.min(t-1,M+1)*t;for(let g=0;g<t;g++){let w=M*t+g,k=Math.max(0,g-1),F=Math.min(t-1,g+1),E=p[M*t+F]-p[M*t+k],S=p[b+g]-p[u+g],A=-(E*m+S*v)*.55,j=(x[w]*.5+y[w]*.3+f[w]*.2-.5)*.16,_=l[w*4]/255*.05,R=A+j+_,G=Math.min(1,Math.abs(R))*255,z=R>0?255:0;c[w*4]=c[w*4+1]=c[w*4+2]=z,c[w*4+3]=G}}n.putImageData(P,0,0),o.toBlob&&typeof URL<"u"&&URL.createObjectURL?o.toBlob(M=>e(M?URL.createObjectURL(M):o.toDataURL("image/png")),"image/png"):e(o.toDataURL("image/png"))}var jo=["ink","blueprint","graphite","paper"],Rt=typeof matchMedia=="function"?matchMedia("(prefers-reduced-motion: reduce)"):void 0,Go=typeof HTMLElement>"u"?class{}:HTMLElement,se=class extends Go{constructor(){super();this.time=0;this.raf=0;this.last=0;this.visible=!0;this.step=-1;this.finishing=!1;this.finished=!1;this.onMotion=()=>this.sync();this.tick=o=>{this.raf=requestAnimationFrame(this.tick);let n=this.last?Math.min(.1,(o-this.last)/1e3):0;this.last=o;let r=this.duration;if(r){if(this.finishing){if(this.time+=n*this.speed,this.time>=r){this.time=r,this.finishing=!1,this.finished=!0,this.stop(),this.draw(),this.dispatchEvent(new CustomEvent("ol-complete"));return}}else this.time=(this.time+n*this.speed)%r;this.draw()}};let o=this.attachShadow({mode:"open"});o.innerHTML=`<style>${Gn}</style><svg part="svg" viewBox="-1.6 -1.6 3.2 3.2" aria-hidden="true"><g></g></svg>`,this.svg=o.querySelector("svg")}static get observedAttributes(){return["model","look","speed","progress","paused","texture"]}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","progressbar"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Loading"),this.load(),this.applyLook(),typeof IntersectionObserver=="function"&&(this.io=new IntersectionObserver(o=>{this.visible=o[o.length-1].isIntersecting,this.sync()}),this.io.observe(this)),Rt?.addEventListener?.("change",this.onMotion),this.sync()}disconnectedCallback(){this.io?.disconnect(),Rt?.removeEventListener?.("change",this.onMotion),this.stop()}attributeChangedCallback(o){this.isConnected&&(o==="model"&&this.load(),o==="look"&&this.applyLook(),o==="texture"&&this.loadTexture(),o==="progress"&&this.hasAttribute("progress")&&(this.finishing=this.finished=!1),this.sync())}complete(){let o=this.player;o&&(this.finished=!1,this.finishing=!0,this.time=o.model.content[1],Rt?.matches&&(this.finishing=!1,this.finished=!0),this.hasAttribute("progress")?this.removeAttribute("progress"):this.sync(),this.finished&&this.dispatchEvent(new CustomEvent("ol-complete")))}restart(){this.finishing=this.finished=!1,this.time=this.player?.model.content[0]??0,this.sync(),this.draw()}get duration(){return this.player?.duration??0}get stepCount(){return this.player?Math.max(...this.player.model.steps.map(o=>o.diagram)):0}get currentStep(){let o=this.player;if(!o)return;let n=o.stepAt(this.displayTime()),r=o.model.steps[n];return{index:n,diagram:r.diagram,label:r.label}}seek(o){let n=this.duration;this.time=n?(o%n+n)%n:0,this.draw()}load(){let o=this.getAttribute("model")||"crane";if(this.player=$e(o),!this.player){console.warn(`<origami-loader>: unknown model "${o}"`);return}this.scene=new Lt(this.svg.firstElementChild,this.player.model),this.frame=void 0,this.step=-1,this.finishing=this.finished=!1,this.time=this.player.model.content[0],this.loadTexture(),this.draw()}loadTexture(){let o=this.scene,n=this.getAttribute("texture")==="none";if(this.svg.dataset.tex=n?"off":"loading",!o||n)return;let r=(this.getBoundingClientRect().width||160)*(globalThis.devicePixelRatio||1)*(2/3.2),a=this.getAttribute("texture")==="grain"?"grain":"paper";Ge(Hn(r),a).then(i=>{o!==this.scene||!i||(o.setTexture(i),this.svg.dataset.tex!=="off"&&(this.svg.dataset.tex="on"))})}applyLook(){let o=this.getAttribute("look");this.svg.dataset.look=jo.includes(o)?o:"ink"}get speed(){let o=parseFloat(this.getAttribute("speed")??"");return Number.isFinite(o)&&o>0?o:1}get progress(){let o=this.getAttribute("progress");if(o===null||o==="")return;let n=parseFloat(o);return Number.isFinite(n)?ot(n):void 0}displayTime(){let o=this.player;if(!o)return 0;let[n,r]=o.model.content;if(this.finished)return o.duration;if(this.finishing)return this.time;let a=this.progress;return a!==void 0?n+a*(r-n):Rt?.matches?r-.001:this.time}draw(){let o=this.player;if(!o||!this.scene)return;let n=this.progress;n!==void 0?(this.setAttribute("aria-valuenow",String(Math.round(n*100))),this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax","100")):this.removeAttribute("aria-valuenow"),this.frame=o.evaluate(this.displayTime(),this.frame),this.scene.render(this.frame),this.frame.step!==this.step&&(this.step=this.frame.step,this.dispatchEvent(new CustomEvent("ol-step",{detail:this.currentStep})))}sync(){let o=this.isConnected&&this.visible&&!this.hasAttribute("paused")&&!this.finished&&this.progress===void 0&&(this.finishing||!Rt?.matches);o&&!this.raf?(this.last=0,this.raf=requestAnimationFrame(this.tick)):o||(this.stop(),this.draw())}stop(){this.raf&&cancelAnimationFrame(this.raf),this.raf=0}};function Ue(t="origami-loader"){typeof customElements<"u"&&!customElements.get(t)&&customElements.define(t,class extends se{})}Ue();export{V as Folder,he as LAYER,se as OrigamiLoader,St as Player,Nt as StepBuilder,Lt as SvgScene,Fe as buildBoat,Me as buildCrane,ke as buildEnvelope,Ne as buildFox,Oe as buildFrog,Ce as buildHeart,xe as buildPlane,ve as buildPleat,Le as buildSwan,ze as buildWhale,re as defaultCamera,ht as defaultPose,Ue as defineOrigamiLoader,C as eases,$e as getModel,Lo as listModels,jn as paintOrder,Ge as paperTexture,Ro as registerModel};
41
+ `;var Yn=new Map,Wn=t=>t<=220?256:t<=460?512:1024;function Qe(t,e="paper"){let o=`${e}:${t}`,n=Yn.get(o);if(!n){let r=()=>new Promise(s=>setTimeout(()=>Ho(t,s),0));n=e==="grain"?r():import("./chunks/paper-shader-ZKC3EUTY.js").then(s=>s.renderPaperShader(t)).catch(()=>{}).then(s=>s??r()),Yn.set(o,n)}return n}function Uo(t){return()=>{t|=0,t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}function le(t,e,o){let n=e+1,r=new Float32Array(n*n);for(let a=0;a<r.length;a++)r[a]=o();let s=new Float32Array(t*t),i=e/t;for(let a=0;a<t;a++){let c=a*i,h=c|0,p=c-h,f=p*p*(3-2*p);for(let P=0;P<t;P++){let m=P*i,d=m|0,x=m-d,l=x*x*(3-2*x),b=h*n+d,M=r[b]+(r[b+1]-r[b])*l,w=r[b+n]+(r[b+n+1]-r[b+n])*l;s[a*t+P]=M+(w-M)*f}}return s}function Ho(t,e){if(typeof document>"u")return e("");let o=document.createElement("canvas");o.width=o.height=t;let n=o.getContext("2d");if(!n)return e("");let r=Uo(61469),s=t/512,i=t*t;n.fillStyle="#000",n.fillRect(0,0,t,t),n.lineCap="round";let a=Math.round(420*s*s);for(let w=0;w<a;w++){let u=r()*t,g=r()*t,y=r()*Math.PI,v=(6+r()*r()*70)*s,k=(r()-.5)*v*.9,F=Math.cos(y),E=Math.sin(y);n.strokeStyle=`rgba(255,255,255,${.12+r()*.4})`,n.lineWidth=(.5+r()*1.2)*s,n.beginPath(),n.moveTo(u,g),n.quadraticCurveTo(u+F*v/2-E*k,g+E*v/2+F*k,u+F*v,g+E*v),n.stroke()}let c=n.getImageData(0,0,t,t).data,h=new Float32Array(i);for(let w=0;w<i;w++)h[w]=r();let p=le(t,Math.round(110*s),r),f=new Float32Array(i);for(let w=0;w<t;w++)for(let u=0;u<t;u++){let g=0;for(let v=-1;v<=1;v++){let k=Math.min(t-1,Math.max(0,w+v))*t;for(let F=-1;F<=1;F++)g+=h[k+Math.min(t-1,Math.max(0,u+F))]}let y=w*t+u;f[y]=g/9*.55+p[y]*.45+c[y*4]/255*.9}let P=le(t,3,r),m=le(t,7,r),d=le(t,16,r),x=n.createImageData(t,t),l=x.data,b=-.62,M=-.78;for(let w=0;w<t;w++){let u=Math.max(0,w-1)*t,g=Math.min(t-1,w+1)*t;for(let y=0;y<t;y++){let v=w*t+y,k=Math.max(0,y-1),F=Math.min(t-1,y+1),E=f[w*t+F]-f[w*t+k],S=f[g+y]-f[u+y],A=-(E*b+S*M)*.55,j=(P[v]*.5+m[v]*.3+d[v]*.2-.5)*.16,_=c[v*4]/255*.05,C=A+j+_,G=Math.min(1,Math.abs(C))*255,N=C>0?255:0;l[v*4]=l[v*4+1]=l[v*4+2]=N,l[v*4+3]=G}}n.putImageData(x,0,0),o.toBlob&&typeof URL<"u"&&URL.createObjectURL?o.toBlob(w=>e(w?URL.createObjectURL(w):o.toDataURL("image/png")),"image/png"):e(o.toDataURL("image/png"))}var Qo=["ink","blueprint","graphite","paper"],Nt=typeof matchMedia=="function"?matchMedia("(prefers-reduced-motion: reduce)"):void 0,Ko=typeof HTMLElement>"u"?class{}:HTMLElement,he=class extends Ko{constructor(){super();this.time=0;this.raf=0;this.last=0;this.visible=!0;this.step=-1;this.finishing=!1;this.finished=!1;this.onMotion=()=>this.sync();this.tick=o=>{this.raf=requestAnimationFrame(this.tick);let n=this.last?Math.min(.1,(o-this.last)/1e3):0;this.last=o;let r=this.duration;if(r){if(this.finishing){if(this.time+=n*this.speed,this.time>=r){this.time=r,this.finishing=!1,this.finished=!0,this.stop(),this.draw(),this.dispatchEvent(new CustomEvent("ol-complete"));return}}else this.time=(this.time+n*this.speed)%r;this.draw()}};let o=this.attachShadow({mode:"open"});o.innerHTML=`<style>${Kn}</style><svg part="svg" viewBox="-1.6 -1.6 3.2 3.2" aria-hidden="true"><g></g></svg>`,this.svg=o.querySelector("svg")}static get observedAttributes(){return["model","look","speed","progress","paused","texture"]}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","progressbar"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Loading"),this.load(),this.applyLook(),typeof IntersectionObserver=="function"&&(this.io=new IntersectionObserver(o=>{this.visible=o[o.length-1].isIntersecting,this.sync()}),this.io.observe(this)),Nt?.addEventListener?.("change",this.onMotion),this.sync()}disconnectedCallback(){this.io?.disconnect(),Nt?.removeEventListener?.("change",this.onMotion),this.stop()}attributeChangedCallback(o){this.isConnected&&(o==="model"&&this.load(),o==="look"&&this.applyLook(),o==="texture"&&this.loadTexture(),o==="progress"&&this.hasAttribute("progress")&&(this.finishing=this.finished=!1),this.sync())}complete(){let o=this.player;o&&(this.finished=!1,this.finishing=!0,this.time=o.model.content[1],Nt?.matches&&(this.finishing=!1,this.finished=!0),this.hasAttribute("progress")?this.removeAttribute("progress"):this.sync(),this.finished&&this.dispatchEvent(new CustomEvent("ol-complete")))}restart(){this.finishing=this.finished=!1,this.time=this.player?.model.content[0]??0,this.sync(),this.draw()}get duration(){return this.player?.duration??0}get stepCount(){return this.player?Math.max(...this.player.model.steps.map(o=>o.diagram)):0}get currentStep(){let o=this.player;if(!o)return;let n=o.stepAt(this.displayTime()),r=o.model.steps[n];return{index:n,diagram:r.diagram,label:r.label}}seek(o){let n=this.duration;this.time=n?(o%n+n)%n:0,this.draw()}load(){let o=this.getAttribute("model")||"crane";if(this.player=Ue(o),!this.player){console.warn(`<origami-loader>: unknown model "${o}"`);return}this.scene=new zt(this.svg.firstElementChild,this.player.model),this.frame=void 0,this.step=-1,this.finishing=this.finished=!1,this.time=this.player.model.content[0],this.loadTexture(),this.draw()}loadTexture(){let o=this.scene,n=this.getAttribute("texture")==="none";if(this.svg.dataset.tex=n?"off":"loading",!o||n)return;let r=(this.getBoundingClientRect().width||160)*(globalThis.devicePixelRatio||1)*(2/3.2),s=this.getAttribute("texture")==="grain"?"grain":"paper";Qe(Wn(r),s).then(i=>{o!==this.scene||!i||(o.setTexture(i),this.svg.dataset.tex!=="off"&&(this.svg.dataset.tex="on"))})}applyLook(){let o=this.getAttribute("look");this.svg.dataset.look=Qo.includes(o)?o:"ink"}get speed(){let o=parseFloat(this.getAttribute("speed")??"");return Number.isFinite(o)&&o>0?o:1}get progress(){let o=this.getAttribute("progress");if(o===null||o==="")return;let n=parseFloat(o);return Number.isFinite(n)?rt(n):void 0}displayTime(){let o=this.player;if(!o)return 0;let[n,r]=o.model.content;if(this.finished)return o.duration;if(this.finishing)return this.time;let s=this.progress;return s!==void 0?n+s*(r-n):Nt?.matches?r-.001:this.time}draw(){let o=this.player;if(!o||!this.scene)return;let n=this.progress;n!==void 0?(this.setAttribute("aria-valuenow",String(Math.round(n*100))),this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax","100")):this.removeAttribute("aria-valuenow"),this.frame=o.evaluate(this.displayTime(),this.frame),this.scene.render(this.frame),this.frame.step!==this.step&&(this.step=this.frame.step,this.dispatchEvent(new CustomEvent("ol-step",{detail:this.currentStep})))}sync(){let o=this.isConnected&&this.visible&&!this.hasAttribute("paused")&&!this.finished&&this.progress===void 0&&(this.finishing||!Nt?.matches);o&&!this.raf?(this.last=0,this.raf=requestAnimationFrame(this.tick)):o||(this.stop(),this.draw())}stop(){this.raf&&cancelAnimationFrame(this.raf),this.raf=0}};function Ke(t="origami-loader"){typeof customElements<"u"&&!customElements.get(t)&&customElements.define(t,class extends he{})}Ke();export{O as Folder,fe as LAYER,he as OrigamiLoader,_t as Player,jt as StepBuilder,zt as SvgScene,_e as buildBoat,ke as buildCrane,Ae as buildEnvelope,je as buildFox,Ce as buildFrog,Be as buildHeart,Fe as buildPlane,Ee as buildPleat,ze as buildSwan,$e as buildWhale,ce as defaultCamera,ut as defaultPose,Ke as defineOrigamiLoader,V as eases,Ue as getModel,No as listModels,Qn as paintOrder,Qe as paperTexture,Do as registerModel};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "origami-loaders",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Loaders that fold: ten 3D origami models, from a paper crane to a jumping frog, as live SVG. One web component, zero dependencies.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -16,7 +16,7 @@
16
16
  "paper",
17
17
  "crane"
18
18
  ],
19
- "homepage": "https://github.com/rishiashar/origami-loaders#readme",
19
+ "homepage": "https://origami-loaders.vercel.app",
20
20
  "bugs": {
21
21
  "url": "https://github.com/rishiashar/origami-loaders/issues"
22
22
  },