shotops-mcp 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ import{S as Kt,G as qt,A as Yt,D as ae,M as Xt,R as Jt,a as Zt,C as Qt,b as en,c as tn}from"./three-addons-CvX38LO6.js";import{aa as Qe,P as et,b as nn,V as q,a4 as rn,C as k,ab as on,J as Oe,$ as V,M as an,a2 as sn,B as ln}from"./three-webgl-DCw804Ic.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))o(r);new MutationObserver(r=>{for(const a of r)if(a.type==="childList")for(const i of a.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&o(i)}).observe(document,{childList:!0,subtree:!0});function n(r){const a={};return r.integrity&&(a.integrity=r.integrity),r.referrerPolicy&&(a.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?a.credentials="include":r.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function o(r){if(r.ep)return;r.ep=!0;const a=n(r);fetch(r.href,a)}})();const cn=""+new URL("iphone-optimized-BdcJzlHi.glb",import.meta.url).href,dn="data:model/gltf-binary;base64,Z2xURgIAAADUAAAAwAAAAEpTT057ImFzc2V0Ijp7InZlcnNpb24iOiIyLjAiLCJnZW5lcmF0b3IiOiJTaG90T3BzIHBsYWNlaG9sZGVyIOKAlCB0aGUgUGl4ZWwgbW9kZWwgaXMgZGVsaWJlcmF0ZWx5IG5vdCBidW5kbGVkIGluIHRoZSBucG0gcGFja2FnZSJ9LCJzY2VuZXMiOlt7Im5hbWUiOiJwaXhlbC1ub3QtYnVuZGxlZCIsIm5vZGVzIjpbXX1dLCJzY2VuZSI6MH0gICA=",un=[{id:"grey",label:"Grey",color:11579568},{id:"white",label:"White",color:15263458},{id:"charcoal",label:"Charcoal",color:3815996}],fn=[{id:"silver",label:"Silver",frame:16119285,back:16514043,accent:13816532},{id:"blue",label:"Deep Blue",frame:3290954,back:4409953,accent:2172211},{id:"orange",label:"Cosmic Orange",frame:16219693,back:16487504,accent:12738072}],hn=[{id:"silver",label:"Moonstone",frame:9345186,back:8621205,accent:7041658},{id:"blue",label:"Obsidian",frame:2763308,back:2565928,accent:2105377},{id:"orange",label:"Porcelain",frame:15920872,back:14670805,accent:11973550},{id:"green",label:"Jade",frame:9412240,back:8688005,accent:7042924}],Y={id:"iphone-17-pro",glb:cn,fitSize:3.6,baseEuler:{x:0,y:0,z:0},pruneNamePrefixes:[],screen:{material:"OLED",repeat:{x:-1,y:1},coverFill:1.001,coverCornerRatio:.18,coverRepeat:{x:-1,y:-1}},body:{frame:["Anodized aluminum"],back:["Frosted glass"],accent:["Plastic antena","PaletteMaterial001"]},colorways:fn},Te={id:"pixel-10-pro",glb:dn,fitSize:3.6,baseEuler:{x:0,y:Math.PI,z:0},pruneNamePrefixes:["Google Pixel 10 Pro Moonstone.1"],screen:{material:"GP10p_display",repeat:{x:1,y:1},coverFill:1.001,coverCornerRatio:.14,coverRepeat:{x:1,y:-1}},body:{frame:["GP10p_mid","GP10p_camera"],back:["GP10p_back","GP10p_plastic"],accent:["GP10p_logo"]},colorways:hn},pn={[Y.id]:Y,[Te.id]:Te};function we(e){return e&&pn[e]||Y}const mn=7,ke={front:{x:0,y:0,z:-1},left:{x:-2.6,y:.6,z:-5.2},right:{x:2.6,y:.6,z:-5.2}};function tt(e){const t=ke[e]??ke.front,n=Math.hypot(t.x,t.y,t.z),o=mn/n;return{x:t.x*o,y:t.y*o,z:t.z*o}}function gn(e){return Math.atan2(e.x,-e.z)*180/Math.PI}function he(e){const t=tt(e);return new q(t.x,t.y,t.z)}const yn=1.4;function bn(e,t){return(t?new q(t.x,t.y,t.z):he(e)).multiplyScalar(yn)}const nt=35;function Sn(e){e.traverse(t=>{const n=t;n.geometry?.dispose();const o=n.material;Array.isArray(o)?o.forEach(Ce):o&&Ce(o)}),e.clear()}function Ce(e){for(const t of Object.values(e))t&&typeof t=="object"&&t.isTexture&&t.dispose();e.dispose()}function rt(e,t){const n=document.createElement("canvas"),o=new Qe({canvas:n,antialias:!0,preserveDrawingBuffer:!0,alpha:!0});o.setSize(e,t,!1),o.shadowMap.enabled=!0;const r=new Kt;r.background=null;const{ambient:a,directionals:i}=wn(r),l=new et(nt,e/t,.01,100);l.position.copy(he("front")),l.lookAt(0,0,0);function s(f){l.position.copy(he(f)),l.lookAt(0,0,0)}function d(f){l.position.set(f.x,f.y,f.z),l.lookAt(0,0,0)}function u(f){i.forEach(c=>c.visible=f),a.intensity=f?.75:1.6}let p=!1;function h(){p||(p=!0,r.environment?.dispose(),r.environment=null,Sn(r),o.dispose(),o.forceContextLoss())}return{scene:r,camera:l,renderer:o,dispose:h,setAngle:s,setCameraPosition:d,getCameraPosition:()=>({x:l.position.x,y:l.position.y,z:l.position.z}),onUserPose:()=>{},previewOrbit:()=>{},commitOrbit:()=>{},setOrbitEnabled:()=>{},setBackground:()=>{},setStudioLighting:u,resize:()=>{}}}function wn(e){const t=new Yt(16777215,.75);e.add(t);const n=new ae(16777215,2.2);n.position.set(3,5,5);const o=new ae(12571903,.7);o.position.set(-4,1,2);const r=new ae(16777215,1);r.position.set(0,3,-5);const a=[n,o,r];return a.forEach(i=>e.add(i)),{ambient:t,directionals:a}}function ot(e,t){const n=we(t);return new Promise((o,r)=>{new qt().load(n.glb,a=>{const i=a.scene;if(n.pruneNamePrefixes.length){const h=[];i.traverse(f=>{n.pruneNamePrefixes.some(c=>f.name.startsWith(c))&&h.push(f)}),h.forEach(f=>f.removeFromParent())}i.rotation.set(n.baseEuler.x,n.baseEuler.y,n.baseEuler.z),i.updateMatrixWorld(!0);const l=new nn().setFromObject(i),s=l.getSize(new q),d=l.getCenter(new q),u=n.fitSize/Math.max(s.x,s.y,s.z);i.scale.multiplyScalar(u),i.position.copy(d.multiplyScalar(-u));const p=new rn;p.add(i),e.scene.add(p),e.setAngle("front"),o(p)},void 0,r)})}function vn(e){return ot(e)}Y.colorways;class at{frame=[];back=[];accent=[];allBody=[];model;scene;renderer;profile;envTexture=null;constructor(t,n,o,r){this.model=t,this.scene=n,this.renderer=o,this.profile=we(r);const{frame:a,back:i,accent:l}=this.profile.body;t.traverse(s=>{const d=s;if(!d.isMesh)return;(Array.isArray(d.material)?d.material:[d.material]).forEach(p=>{const h=p;!h||!h.name||(a.includes(h.name)?this.push(this.frame,h):i.includes(h.name)?this.push(this.back,h):l.includes(h.name)&&this.push(this.accent,h),this.push(this.allBody,h))})})}push(t,n){t.includes(n)||t.push(n)}get finishMaterials(){return[...this.frame,...this.back]}paint(t,n){const o=n instanceof k?n:new k(n);t.forEach(r=>{r.color=o.clone(),r.needsUpdate=!0})}setColorway(t){if(t==="custom")return;const n=this.profile.colorways.find(o=>o.id===t)??this.profile.colorways[0];n&&(this.paint(this.frame,n.frame),this.paint(this.back,n.back),this.paint(this.accent,n.accent))}setCustomColor(t){const n=new k(t),o=n.clone().lerp(new k(16777215),.2),r=n.clone().multiplyScalar(.6);this.paint(this.frame,n),this.paint(this.back,o),this.paint(this.accent,r)}setFinish(t){const n=Number.isFinite(t)?Math.max(0,Math.min(1,t)):0;this.finishMaterials.forEach(o=>{o.userData.baseRoughness===void 0&&(o.userData.baseRoughness=o.roughness);const r=o.userData.baseRoughness;o.roughness=r*(1-n),o.needsUpdate=!0})}clearcoatUpgraded=!1;setClearcoat(t){const n=Math.max(0,Math.min(1,t));n>0&&!this.clearcoatUpgraded&&this.upgradeFinishToPhysical(),this.clearcoatUpgraded&&this.finishMaterials.forEach(o=>{const r=o;r.clearcoat=n,r.clearcoatRoughness=.1,r.needsUpdate=!0})}upgradeFinishToPhysical(){this.clearcoatUpgraded=!0;const t=new Map;for(const o of Array.from(new Set(this.finishMaterials))){const r=new Xt;r.color.copy(o.color),r.metalness=o.metalness,r.roughness=o.roughness,r.map=o.map,r.normalMap=o.normalMap,r.normalScale.copy(o.normalScale),r.roughnessMap=o.roughnessMap,r.metalnessMap=o.metalnessMap,r.aoMap=o.aoMap,r.aoMapIntensity=o.aoMapIntensity,r.emissive.copy(o.emissive),r.emissiveMap=o.emissiveMap,r.emissiveIntensity=o.emissiveIntensity,r.envMapIntensity=o.envMapIntensity,r.transparent=o.transparent,r.opacity=o.opacity,r.alphaTest=o.alphaTest,r.side=o.side,r.flatShading=o.flatShading,r.vertexColors=o.vertexColors,r.name=o.name,r.userData={...o.userData},r.clearcoat=0,t.set(o,r)}this.model.traverse(o=>{const r=o;if(r.isMesh)if(Array.isArray(r.material))r.material=r.material.map(a=>t.get(a)??a);else{const a=t.get(r.material);a&&(r.material=a)}});const n=o=>o.map(r=>t.get(r)??r);this.frame=n(this.frame),this.back=n(this.back),this.allBody=n(this.allBody)}environmentMap(){if(!this.envTexture){const t=new on(this.renderer);this.envTexture=t.fromScene(new Jt,.04).texture,t.dispose()}return this.envTexture}setClay(t){const n=un.find(r=>r.id===t),o=n?new k(n.color):new k(t);this.allBody.forEach(r=>{r.userData.clayStashedMap===void 0&&(r.userData.clayStashedMap=r.map),r.color=o.clone(),r.metalness=0,r.roughness=.85,r.map=null,r.needsUpdate=!0})}clayOff(){this.allBody.forEach(t=>{t.userData.clayStashedMap!==void 0&&(t.map=t.userData.clayStashedMap,t.userData.clayStashedMap=void 0,t.needsUpdate=!0)})}setReflections(t){this.scene.environment=t?this.environmentMap():null}setRoll(t){this.model.rotation.z=t*Math.PI/180}}const Ee=1.35;class it{materials=[];glassOverlays=[];screenMesh=null;flatPlane=null;texture=null;flatScreenOn=!1;profile;constructor(t,n){this.profile=we(n);const o=this.profile.screen.material;t.traverse(r=>{const a=r;if(!a.isMesh)return;(Array.isArray(a.material)?a.material:[a.material]).forEach(l=>{const s=l;s&&s.name===o&&!this.materials.includes(s)&&(this.materials.push(s),this.screenMesh=a)})}),this.dimGlassOverlay(t),this.prepareScreen(),this.setGlare(null)}get found(){return this.materials.length>0}setGlare(t){this.materials.forEach(n=>{n.envMap=t,n.envMapIntensity=t?.6:0,n.metalness=t?.5:0,n.roughness=t?.15:1,n.needsUpdate=!0}),this.glassOverlays.forEach(n=>{n.opacity=t?.08:0,n.needsUpdate=!0})}setFlatScreen(t){if(this.flatScreenOn=t,!this.screenMesh)return;if(this.flatPlane){this.screenMesh.remove(this.flatPlane);const y=this.flatPlane.material;y.map?.dispose(),y.dispose(),this.flatPlane.geometry.dispose(),this.flatPlane=null}if(!t||!this.texture)return;this.screenMesh.geometry.computeBoundingBox();const n=this.screenMesh.geometry.boundingBox;if(!n)return;const o=n.max.x-n.min.x,r=n.max.y-n.min.y,a=n.max.z-n.min.z,i=(n.max.x+n.min.x)/2,l=(n.max.y+n.min.y)/2,s=(n.max.z+n.min.z)/2,d=r<=o&&r<=a?"y":a<=o&&a<=r?"z":"x",u=this.texture.clone();u.needsUpdate=!0,u.colorSpace=Oe,u.flipY=!1,u.center.set(.5,.5),u.wrapS=V,u.wrapT=V;const{coverFill:p,coverCornerRatio:h,coverRepeat:f}=this.profile.screen;u.repeat.set(f.x,f.y);const c=d==="x"?a:o,g=d==="z"||d==="x"?r:a,m=Math.min(c,g)*p*h,b=In(c*p,g*p,m),S=new an(b,new Zt({map:u,emissive:new k(16777215),emissiveMap:u,emissiveIntensity:Ee,color:new k(0),toneMapped:!1,side:sn,depthTest:!0,depthWrite:!0,polygonOffset:!0,polygonOffsetFactor:-4,polygonOffsetUnits:-4}));d==="y"?(S.rotation.x=-Math.PI/2,S.position.set(i,n.max.y,s)):d==="x"?(S.rotation.y=Math.PI/2,S.position.set(n.max.x,l,s)):S.position.set(i,l,n.max.z),S.renderOrder=999,this.screenMesh.add(S),this.flatPlane=S}restoreScreen(){this.prepareScreen()}prepareScreen(){this.materials.forEach(t=>{t.color=new k(0),t.emissive=new k(16777215),t.emissiveIntensity=1,t.roughness=1,t.metalness=0,t.needsUpdate=!0})}dimGlassOverlay(t){t.traverse(n=>{const o=n;if(!o.isMesh)return;(Array.isArray(o.material)?o.material:[o.material]).forEach(a=>{const i=a;i&&i.name!==this.profile.screen.material&&i.transparent&&i.opacity>.2&&this.glassOverlays.push(i)})})}applyWallpaper(t){const n=new Blob([t],{type:"image/png"}),o=URL.createObjectURL(n),r=this.texture;return new Promise((a,i)=>{const l=new Image;l.onload=()=>{try{const s=document.createElement("canvas");s.width=l.naturalWidth,s.height=l.naturalHeight;const d=s.getContext("2d");if(!d)throw new Error("2D context unavailable for wallpaper blit");d.drawImage(l,0,0);const u=new Qt(s);u.colorSpace=Oe,u.flipY=!1,u.center.set(.5,.5),u.wrapS=V,u.wrapT=V,u.repeat.set(this.profile.screen.repeat.x,this.profile.screen.repeat.y),u.needsUpdate=!0,this.texture=u,this.materials.forEach(p=>{p.map=u,p.emissiveMap=u,p.emissive=new k(16777215),p.emissiveIntensity=Ee,p.color=new k(0),p.needsUpdate=!0}),this.flatScreenOn&&this.setFlatScreen(!0),r?.dispose(),URL.revokeObjectURL(o),a()}catch(s){URL.revokeObjectURL(o),i(s)}},l.onerror=()=>{URL.revokeObjectURL(o),i(new Error("wallpaper image failed to decode"))},l.src=o})}}function In(e,t,n){const o=e/2,r=t/2,a=Math.min(n,o,r),i=new en;i.moveTo(-o+a,-r),i.lineTo(o-a,-r),i.quadraticCurveTo(o,-r,o,-r+a),i.lineTo(o,r-a),i.quadraticCurveTo(o,r,o-a,r),i.lineTo(-o+a,r),i.quadraticCurveTo(-o,r,-o,r-a),i.lineTo(-o,-r+a),i.quadraticCurveTo(-o,-r,-o+a,-r);const l=new tn(i,16),s=l.attributes.position,d=new Float32Array(s.count*2);for(let u=0;u<s.count;u++)d[u*2]=(s.getX(u)+o)/e,d[u*2+1]=(s.getY(u)+r)/t;return l.setAttribute("uv",new ln(d,2)),l}const Me={sizePt:{min:20,max:120},maxWidth:{min:.1,max:1},lineHeight:{min:.5,max:3},bandInset:{min:0,max:.5},bandCenter:{min:0,max:1},reserveLines:{min:1,max:8}},X=[{id:"inter",family:"Inter",label:"Inter"},{id:"manrope",family:"Manrope",label:"Manrope"},{id:"poppins",family:"Poppins",label:"Poppins"},{id:"fraunces",family:"Fraunces",label:"Fraunces"},{id:"space-grotesk",family:"Space Grotesk",label:"Space Grotesk"}],Le=X.map(e=>e.id);[Le[0],...Le.slice(1)];const J=600;function st(e){return X.find(t=>t.id===e)??X[0]}const lt=[{id:"standard",label:"Standard",blurb:"Headline on top, whole device below it, nothing cropped. The safe default.",character:"safe",shotLook:{phoneHeight:"82",hOffset:"0",vOffset:"18",angle:"front",cameraPos:null,roll:"0"},caption:{sizePt:32,maxWidth:.86,reserveLines:2}},{id:"bleed",label:"Bleed",blurb:"Room for a longer headline, device running off the bottom edge. What the market looks like.",character:"conventional",shotLook:{phoneHeight:"82",hOffset:"0",vOffset:"38",angle:"front",cameraPos:null,roll:"0"},caption:{sizePt:32,maxWidth:.86,reserveLines:4}},{id:"top-bleed",label:"Top bleed",blurb:"Device running off the TOP edge, headline underneath it. Inverts the usual reading order.",character:"expressive",shotLook:{phoneHeight:"82",hOffset:"0",vOffset:"-38",angle:"front",cameraPos:null,roll:"0"},caption:{sizePt:32,maxWidth:.86,reserveLines:4,band:"bottom"}}],ct=lt,Fe=ct.map(e=>e.id);[Fe[0],...Fe.slice(1)];Array.from(new Set(lt.flatMap(e=>Object.keys(e.caption))));const dt=[{id:"noir",label:"Noir",blurb:"Near-black, high contrast, glossy silver device. The default premium look.",background:{gradientFrom:"#1C1C22",gradientTo:"#08080B",gradientDir:"vertical",shadow:!0,floorReflection:!1},shotLook:{material:"real",colorway:"silver",finish:"0",clearcoat:"1",reflections:!0,lighting:!0,angle:"front"},caption:{fontId:"inter",color:"FFFFFF"}},{id:"daylight",label:"Daylight",blurb:"Warm off-white, soft matte white device, dark text. Calm and editorial.",background:{gradientFrom:"#F4F1EA",gradientTo:"#DFD8CA",gradientDir:"vertical",shadow:!0,floorReflection:!1},shotLook:{material:"clay",clayTone:"white",finish:"0",clearcoat:"0",reflections:!1,lighting:!0,angle:"front"},caption:{fontId:"manrope",color:"1A1A1F"}},{id:"pop",label:"Pop",blurb:"Saturated indigo-to-violet, orange device. Loud, consumer, scroll-stopping.",background:{gradientFrom:"#5B6CF0",gradientTo:"#9B4DF0",gradientDir:"vertical",shadow:!0,floorReflection:!1},shotLook:{material:"real",colorway:"orange",finish:"0",clearcoat:"0.4",reflections:!0,lighting:!0,angle:"front"},caption:{fontId:"poppins",color:"FFFFFF"}},{id:"clay",label:"Clay",blurb:"Warm terracotta, matte charcoal device, tilted. Reads like a product photo.",background:{gradientFrom:"#E9BBAC",gradientTo:"#C88C7C",gradientDir:"vertical",shadow:!0,floorReflection:!1},shotLook:{material:"clay",clayTone:"charcoal",finish:"0",clearcoat:"0",reflections:!1,lighting:!0,angle:"left",roll:"-6"},caption:{fontId:"fraunces",color:"2A2320"}},{id:"studio",label:"Studio",blurb:"Mid slate with a floor reflection, blue device. Technical and precise.",background:{gradientFrom:"#5A6678",gradientTo:"#2B3340",gradientDir:"vertical",shadow:!0,floorReflection:!0},shotLook:{material:"real",colorway:"blue",finish:"0",clearcoat:"0",reflections:!0,lighting:!0,angle:"front"},caption:{fontId:"space-grotesk",color:"FFFFFF"}}],Re=dt.map(e=>e.id);[Re[0],...Re.slice(1)];const x={angle:"front",cameraPos:null,roll:"0",phoneHeight:"82",hOffset:"0",vOffset:"18",material:"real",colorway:"silver",customColor:"F5F5F5",finish:"0",clearcoat:"0",clayTone:"grey",clayCustom:"B0B0B0",flatScreen:!1,glare:!1,lighting:!0,reflections:!1},_e={angle:{valueKind:"angle",required:!0,defaultSource:"default-look",defaultValue:x.angle,persistence:"always"},cameraPos:{valueKind:"camera-position",required:!0,defaultSource:"default-look",defaultValue:x.cameraPos,persistence:"always"},roll:{valueKind:"numeric-string",required:!0,defaultSource:"default-look",defaultValue:x.roll,persistence:"always"},phoneHeight:{valueKind:"numeric-string",required:!0,defaultSource:"default-look",defaultValue:x.phoneHeight,persistence:"always"},hOffset:{valueKind:"numeric-string",required:!0,defaultSource:"default-look",defaultValue:x.hOffset,persistence:"always"},vOffset:{valueKind:"numeric-string",required:!0,defaultSource:"default-look",defaultValue:x.vOffset,persistence:"always"},material:{valueKind:"material",required:!0,defaultSource:"default-look",defaultValue:x.material,persistence:"always"},colorway:{valueKind:"colorway",required:!0,defaultSource:"default-look",defaultValue:x.colorway,persistence:"always"},customColor:{valueKind:"string",required:!0,defaultSource:"default-look",defaultValue:x.customColor,persistence:"always"},finish:{valueKind:"numeric-string",required:!0,defaultSource:"default-look",defaultValue:x.finish,persistence:"always"},clearcoat:{valueKind:"numeric-string",required:!0,defaultSource:"default-look",defaultValue:x.clearcoat,persistence:"always"},clayTone:{valueKind:"clay-tone",required:!0,defaultSource:"default-look",defaultValue:x.clayTone,persistence:"always"},clayCustom:{valueKind:"string",required:!0,defaultSource:"default-look",defaultValue:x.clayCustom,persistence:"always"},flatScreen:{valueKind:"boolean",required:!0,defaultSource:"default-look",defaultValue:x.flatScreen,persistence:"always"},clipToFrame:{valueKind:"boolean",required:!1,defaultSource:"explicit",defaultValue:!1,persistence:"omit-default"},glare:{valueKind:"boolean",required:!0,defaultSource:"default-look",defaultValue:x.glare,persistence:"always"},lighting:{valueKind:"boolean",required:!0,defaultSource:"default-look",defaultValue:x.lighting,persistence:"always"},reflections:{valueKind:"boolean",required:!0,defaultSource:"default-look",defaultValue:x.reflections,persistence:"always"}},xn={roll:{min:-45,max:45},phoneHeight:{min:20,max:200},hOffset:{min:-100,max:100},vOffset:{min:-200,max:200},finish:{min:0,max:1},clearcoat:{min:0,max:1}},H={x:.5,y:.06},ve={fontId:"inter",sizePt:32,color:"FFFFFF",align:"center",anchor:H,maxWidth:.86},Ne=[{id:"r69",label:"6.9″ iPhone · 1290×2796",width:1290,height:2796},{id:"r65",label:"6.5″ iPhone · 1242×2688",width:1242,height:2688},{id:"r55",label:"5.5″ iPhone · 1242×2208",width:1242,height:2208},{id:"pixel69",label:"Pixel 10 Pro · 1290×2796",width:1290,height:2796},{id:"ipad13",label:"13″ iPad · 2064×2752",width:2064,height:2752},{id:"ipad129",label:"12.9″ iPad · 2048×2732",width:2048,height:2732}];function G(e){return Ne.find(t=>t.id===e)??Ne[0]}const te=932,pe="iphone-17-pro",Pn="pixel-10-pro",Ie=[{id:"iphone-6-9",label:"iPhone 17 Pro",panelPresetId:"r69",ascDeviceSet:"APP_IPHONE_67",modelId:pe,screenFamily:"iphone"},{id:"iphone-6-5",label:"iPhone 17",panelPresetId:"r65",ascDeviceSet:"APP_IPHONE_65",modelId:pe,screenFamily:"iphone"},{id:"pixel-10-pro",label:"Pixel 10 Pro",panelPresetId:"pixel69",ascDeviceSet:"ANDROID_PHONE",modelId:Pn,screenFamily:"android"},{id:"ipad-13",label:"iPad 13″",panelPresetId:"ipad13",ascDeviceSet:"APP_IPAD_PRO_129",modelId:"ipad-pro",screenFamily:"ipad",comingSoon:!0},{id:"ipad-12-9",label:"iPad 12.9″",panelPresetId:"ipad129",ascDeviceSet:"APP_IPAD_PRO_3GEN_129",modelId:"ipad-pro",screenFamily:"ipad",comingSoon:!0}];function An(e){return Ie.find(t=>t.panelPresetId===e)?.modelId??pe}const ut="iphone-6-9";function ft(e){return Ie.find(t=>t.id===e)}function On(){return Ie.filter(e=>!e.comingSoon)}function ht(e,t){if(Array.isArray(e)){const n=new Set,o=[];for(const r of e){const a=ft(r);a&&!a.comingSoon&&!n.has(r)&&(n.add(r),o.push(r))}if(o.length>0)return o}if(t){const n=On().find(o=>o.panelPresetId===t);if(n)return[n.id]}return[ut]}const pt=ft(ut)?.screenFamily??"iphone";function mt(e){const t={...e},n=t,o=Object.keys(_e);for(const r of o){const a=_e[r];a.persistence==="omit-default"&&(n[r]===void 0||n[r]===a.defaultValue)&&delete n[r]}return t}function gt(e){return mt({...x,...e})}function yt(e){return mt(gt(e))}function R(e,t){const{min:n,max:o}=xn[e],r=typeof t=="number"?t:Number.parseFloat(t??""),a=Number.isFinite(r)?r:Number.parseFloat(x[e]);return Math.max(n,Math.min(o,a))}const Tn=90,bt=180,kn="#1b1b2e",Cn="#0a0a14";function En(e){return e==="horizontal"?Tn:bt}function Mn(e){const t=(e%180+180)%180;return t>=45&&t<135?"horizontal":"vertical"}function St(e,t,n){return{stops:[{color:e,at:0},{color:t,at:1}],angle:En(n)}}const wt=e=>e*Math.PI/180;function Ln(e){const t=wt(e);return{dx:Math.sin(t),dy:-Math.cos(t)}}function Fn(e,t,n){const o=wt(n);return Math.abs(e*Math.sin(o))+Math.abs(t*Math.cos(o))}function Rn(e,t,n){const{dx:o,dy:r}=Ln(n),a=Fn(e,t,n)/2,i=e/2,l=t/2;return{x0:i-a*o,y0:l-a*r,x1:i+a*o,y1:l+a*r}}function Z(e){const t=e.stops[0],n=e.stops[e.stops.length-1];return{gradientFrom:t?.color??"#000000",gradientTo:n?.color??t?.color??"#000000",gradientDir:Mn(e.angle)}}function ne(e,t){if(!Array.isArray(e)||e.length===0)return null;const n=[];for(const r of e){if(!r||typeof r!="object")return null;const a=r;if(typeof a.color!="string"||typeof a.at!="number"||!Number.isFinite(a.at))return null;n.push({color:a.color,at:Math.min(1,Math.max(0,a.at))})}const o=typeof t=="number"&&Number.isFinite(t)?_n(t):bt;return{stops:n,angle:o}}function Q(e){return ne(e.gradientStops,e.gradientAngle)??St(e.gradientFrom,e.gradientTo,e.gradientDir)}function _n(e){return(e%360+360)%360}function Nn(e){return ne(e.stops,e.angle)??St(e.from,e.to,e.dir)}function vt(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[n,o]of Object.entries(e)){if(!o||typeof o!="object")continue;const r=o;if(r.kind==="solid"&&typeof r.color=="string")t[n]={kind:"solid",color:r.color};else if(r.kind==="gradient"&&typeof r.from=="string"&&typeof r.to=="string"&&(r.dir==="horizontal"||r.dir==="vertical")){const a=ne(r.stops,r.angle);t[n]=a?{kind:"gradient",stops:a.stops,angle:a.angle,from:r.from,to:r.to,dir:r.dir}:{kind:"gradient",from:r.from,to:r.to,dir:r.dir}}}return t}function B(e){return!e||e.x===H.x&&e.y===H.y}function Bn(e){const{text:t,anchor:n,...o}=e;return B(n)?{...o}:{...o,anchor:n}}const Dn=.55,M="en-US";function zn(e){const t=e.lastIndexOf(":");if(t<=0)return null;const n=Number(e.slice(t+1));return!Number.isSafeInteger(n)||n<0?null:{panelId:e.slice(0,t),index:n}}function It(e,t,n,o){if(!e||typeof e!="object"||Array.isArray(e))return{};const r={};for(const[a,i]of Object.entries(e)){if(a===n||!t.includes(a)||!Array.isArray(i))continue;const l=Array.from(new Set(i.filter(s=>typeof s=="string"))).filter(s=>{const d=zn(s);return!!d&&!!o[n]?.[d.panelId]?.[d.index]&&!!o[a]?.[d.panelId]?.[d.index]});l.length>0&&(r[a]=l)}return r}function xt(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[n,o]of Object.entries(e))!o||typeof o!="object"||Array.isArray(o)||(t[n]=D(o));return t}function jn(e){if(!e||typeof e!="object")return;const t=e,n=typeof t.x=="number"?t.x:H.x,o=typeof t.y=="number"?t.y:H.y;return B({x:n,y:o})?void 0:{x:n,y:o}}function D(e){const t=e&&typeof e=="object"?e:{},n=jn(t.anchor),o={...ve,...t};n?o.anchor=n:delete o.anchor,typeof o.reserveLines!="number"||!Number.isFinite(o.reserveLines)||o.reserveLines<Me.reserveLines.min?delete o.reserveLines:o.reserveLines=Math.floor(o.reserveLines),o.band!=="bottom"&&delete o.band;for(const r of["bandInset","lineHeight","bandCenter"]){const{min:a,max:i}=Me[r],l=o[r];(typeof l!="number"||!Number.isFinite(l)||l<a||l>i)&&delete o[r]}return o}function Hn(e){const t=e&&typeof e=="object"?e:{};return{...D(t),text:typeof t.text=="string"?t.text:""}}function Pt(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[n,o]of Object.entries(e))Array.isArray(o)?o.length>0&&(t[n]=o.map(D)):o&&typeof o=="object"&&(t[n]=[D(o)]);return t}function Gn(e,t){const n=[{...D(t),text:e.headline}];return typeof e.subtitle=="string"&&e.subtitle.trim()&&n.push({...D({...t,sizePt:t.sizePt*Dn}),text:e.subtitle}),n}function re(e,t,n=M){if(!e||typeof e!="object"||Array.isArray(e))return{};const o=xt(t),r=d=>o[d]??ve,a=d=>{if(!d||typeof d!="object"||Array.isArray(d))return{};const u={};for(const[p,h]of Object.entries(d))Array.isArray(h)?h.length>0&&(u[p]=h.map(Hn)):h&&typeof h=="object"&&typeof h.headline=="string"&&(u[p]=Gn(h,r(p)));return u},i=Object.entries(e);if(i.some(([,d])=>!!d&&typeof d=="object"&&typeof d.headline=="string"))return{[n]:a(e)};const s={};for(const[d,u]of i)s[d]=a(u);return s}function At(e,t,n=M){return e[t??n]??e[n]??{}}function Ot(e,t=M){const n={},o=Object.keys(e),r=o.includes(t)?[t,...o.filter(a=>a!==t)]:o;for(const a of r){const i=e[a];if(i)for(const[l,s]of Object.entries(i))n[l]===void 0&&Array.isArray(s)&&s.length>0&&(n[l]=s.map(Bn))}return n}function me(e,t=M,n=pt){const o={};return e.family!==void 0&&e.family!==n&&(o.family=e.family),e.locale!==void 0&&e.locale!==t&&(o.locale=e.locale),o}function Be(e){const t=[];return e.family!==void 0&&t.push(`family=${e.family}`),e.locale!==void 0&&t.push(`locale=${e.locale}`),t.join("&")}function ge(e){const t=[];return e.family!==void 0&&t.push("family"),e.locale!==void 0&&t.push("locale"),t}const Un={order:["family","locale"],reach:"strict"};function $n(e,t){const n=ge(e),o=t.order.filter(a=>n.includes(a));return Array.from({length:o.length+1},(a,i)=>o.slice(0,o.length-i)).map(a=>{const i={};return a.includes("family")&&(i.family=e.family),a.includes("locale")&&(i.locale=e.locale),i})}function Wn(e,t,n,o,r=M){const a=me(n,r);for(const i of $n(a,o)){const l=e(t,i);if(l!==void 0){const s=ge(i);return{value:l,resolvedAt:i,inherited:ge(a).filter(d=>!s.includes(d))}}}return{value:void 0,resolvedAt:null,inherited:[]}}function ye(e,t,n=M){const o=r=>{const a=new Set,i=[];for(const l of r)typeof l=="string"&&l&&!a.has(l)&&(a.add(l),i.push(l));return i};if(Array.isArray(t)){const r=o(t);if(r.length>0)return r.includes(n)?r:[...r,n]}return o([n,...Object.keys(e)])}function xe(e,t=M){return typeof e=="string"&&e.length>0?e:t}const z={"it-IT":"it"};function De(e,t){if(!(Object.keys(e).some(r=>r in z)||(t?.some(r=>r in z)??!1)))return{captionText:e,locales:t};const o={};for(const[r,a]of Object.entries(e))r in z||(o[r]=a);for(const[r,a]of Object.entries(e)){const i=z[r];i&&(o[i]={...a,...o[i]??{}})}return{captionText:o,locales:t?.map(r=>z[r]??r)}}function Tt(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[n,o]of Object.entries(e)){if(n===pt||!o||typeof o!="object"||Array.isArray(o))continue;const r={};for(const[a,i]of Object.entries(o)){if(!i||typeof i!="object"||Array.isArray(i))continue;const l={};for(const[s,d]of Object.entries(i))Array.isArray(d)&&d.every(u=>typeof u=="string")&&(l[s]=d);Object.keys(l).length>0&&(r[a]=l)}Object.keys(r).length>0&&(t[n]=r)}return t}function U(e,t){return t.flatMap(n=>e.filter(o=>o.panelId===n.id))}let ze=0,je=0;function Vn(e,t){const n=(o,r)=>o.reduce((a,i)=>{const l=i.startsWith(r)?Number.parseInt(i.slice(r.length),10):NaN;return Number.isFinite(l)&&l>a?l:a},0);ze=Math.max(ze,n(e,"shot-")),je=Math.max(je,n(t,"panel-"))}const Kn=.49;function qn(e,t,n){return e.map(o=>{const r=n*o.heightFrac,a=o.height>0?o.width*(r/o.height):r*Kn,l=o.panelIndex*t+t/2-a/2+o.hOffset*(t/2),d=(n-r)/2+o.vOffset*(n/2);return{shotId:o.shotId,bytes:o.bytes,x:Math.round(l),y:Math.round(d),width:Math.round(a),height:Math.round(r),panelIndex:o.panelIndex,...o.clipToFrame===!0?{clipToFrame:!0}:{}}})}function Yn(e,t){const n=t.panelBackgrounds??{},o=Q(t),r=o.stops[0]?.color??t.gradientFrom;if(!e.some(s=>n[s.id]))return t.bgMode==="gradient"?{kind:"gradient",gradient:o}:{kind:"perPanel",colors:e.map(s=>t.panelColors[s.id]??r)};const i=s=>t.bgMode==="gradient"?{kind:"gradient",gradient:o}:{kind:"solid",color:t.panelColors[s]??r};return{kind:"perPanelFills",fills:e.map(s=>{const d=n[s.id];return d?d.kind==="solid"?{kind:"solid",color:d.color}:{kind:"gradient",gradient:Nn(d)}:i(s.id)})}}function kt(e,t,n=M){const o=Q(e);return{panelPresetId:e.panelPresetId,bgMode:e.bgMode,gradientStops:o.stops,gradientAngle:o.angle,...Z(o),panelColors:e.panelColors,shadow:e.shadow,floorReflection:e.floorReflection??!1,panelBackgrounds:e.panelBackgrounds??{},captionStyles:{...Pt(e.captionStyles),...Ot(t,n)}}}function Xn(e){const t=e.caption.reserveLines,n=typeof t=="number"?` Reserves ${t} headline lines (~${t*18} characters).`:"";return`${e.blurb}${n} Character: [${e.character}].`}function Jn(e,t){return Math.max(0,...Object.values(e).map(n=>n[t]?.length??0))}function Ct(e,t,n){const o=e&&typeof e=="object"&&!Array.isArray(e)?e:{},r=new Set,a={};let i=1;const l=()=>{for(;r.has(`caption-${i}`);)i+=1;const s=`caption-${i}`;return r.add(s),i+=1,s};for(const s of n){const d=Jn(t,s);if(d===0)continue;const u=Array.isArray(o[s])?o[s]:[];a[s]=Array.from({length:d},(p,h)=>{const f=u[h];return typeof f=="string"&&f.length>0&&!r.has(f)?(r.add(f),f):l()})}return a}const Et=2;function Zn(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return t.schema===Et&&Array.isArray(t.shots)&&Array.isArray(t.panels)&&t.panels.length>0}function Qn(e){let t;try{t=JSON.parse(e)}catch{return null}if(!Zn(t))return null;const n=t,o=new Set(n.panels.map(c=>c.id)),r=n.shots.filter(c=>o.has(c.panelId)).map(c=>({id:c.id,panelId:c.panelId,frameNodeId:c.frameNodeId,frameName:c.frameName,bytes:null,look:gt(c.look),thumb:null,thumbStale:!0,inputAnchor:c.inputAnchor,outputAnchor:c.outputAnchor})),a=n.panels.map(c=>({id:c.id}));Vn(r.map(c=>c.id),a.map(c=>c.id));const i=n.selectedShotId&&r.some(c=>c.id===n.selectedShotId)?n.selectedShotId:r[0]?.id??null,l=xe(n.baseLocale),{captionText:s,locales:d}=De(re(n.captionText,n.captionStyles,l),n.locales),u=De({[l]:{}},[l]).locales?.[0]??l,p=ye(s,d,u),h=Ct(n.captionSlotIds,s,a.map(c=>c.id)),f=ne(n.gradientStops,n.gradientAngle);return{shots:U(r,a),panels:a,selectedShotId:i,panelPresetId:G(n.panelPresetId).id,bgMode:n.bgMode==="perPanel"?"perPanel":"gradient",...f?{gradientStops:f.stops,gradientAngle:f.angle,...Z(f)}:{gradientFrom:n.gradientFrom??"5B6CF0",gradientTo:n.gradientTo??"9B4DF0",gradientDir:n.gradientDir==="vertical"?"vertical":"horizontal"},panelColors:n.panelColors??{},shadow:n.shadow!==!1,floorReflection:n.floorReflection===!0,panelBackgrounds:vt(n.panelBackgrounds),captionText:s,locales:p,baseLocale:u,staleCaptionTranslations:It(n.staleCaptionTranslations,p,u,s),outputs:ht(n.outputs,n.panelPresetId),localeScreens:{},outputCaptions:Tt(n.outputCaptions),captionSlotIds:h,frameTemplates:n.frameTemplates&&typeof n.frameTemplates=="object"&&!Array.isArray(n.frameTemplates)?n.frameTemplates:{}}}function Mt(e){const n=U(e.shots,e.panels).map(a=>({id:a.id,panelId:a.panelId,frameNodeId:a.frameNodeId,frameName:a.frameName,look:yt(a.look),inputAnchor:a.inputAnchor,outputAnchor:a.outputAnchor})),o=xe(e.baseLocale),r=re(e.captionText,e.captionStyles,o);return{schema:Et,shots:n,panels:e.panels,selectedShotId:e.selectedShotId,captionText:r,locales:ye(r,e.locales,o),baseLocale:o,staleCaptionTranslations:It(e.staleCaptionTranslations,ye(r,e.locales,o),o,r),outputs:ht(e.outputs,e.panelPresetId),outputCaptions:Tt(e.outputCaptions),...(()=>{const a=Ct(e.captionSlotIds,r,e.panels.map(i=>i.id));return Object.keys(a).length>0?{captionSlotIds:a}:{}})(),...e.frameTemplates&&Object.keys(e.frameTemplates).length>0?{frameTemplates:e.frameTemplates}:{},...kt(e,r,o)}}const er=1;function tr(e){const t=U(e.shots,e.panels),n=re(e.captionText,e.captionStyles),o=xe(e.baseLocale);return{schema:er,shots:t.map(r=>({panelId:r.panelId,look:yt(r.look)})),...kt(e,n,o)}}dt.map(e=>({id:e.id,label:e.label,description:e.blurb}));ct.map(e=>({id:e.id,label:e.label,description:Xn(e),character:e.character}));const Lt=[{code:"ar-SA",name:"Arabic",script:"rtl",dir:"rtl"},{code:"bn-BD",name:"Bengali",script:"indic",dir:"ltr"},{code:"ca",name:"Catalan",script:"latin",dir:"ltr"},{code:"cs",name:"Czech",script:"latin",dir:"ltr"},{code:"da",name:"Danish",script:"latin",dir:"ltr"},{code:"de-DE",name:"German",script:"latin",dir:"ltr"},{code:"el",name:"Greek",script:"greek",dir:"ltr"},{code:"en-AU",name:"English (Australia)",script:"latin",dir:"ltr"},{code:"en-CA",name:"English (Canada)",script:"latin",dir:"ltr"},{code:"en-GB",name:"English (U.K.)",script:"latin",dir:"ltr"},{code:"en-US",name:"English (U.S.)",script:"latin",dir:"ltr"},{code:"es-ES",name:"Spanish (Spain)",script:"latin",dir:"ltr"},{code:"es-MX",name:"Spanish (Mexico)",script:"latin",dir:"ltr"},{code:"fi",name:"Finnish",script:"latin",dir:"ltr"},{code:"fr-CA",name:"French (Canada)",script:"latin",dir:"ltr"},{code:"fr-FR",name:"French",script:"latin",dir:"ltr"},{code:"gu-IN",name:"Gujarati",script:"indic",dir:"ltr"},{code:"he",name:"Hebrew",script:"rtl",dir:"rtl"},{code:"hi",name:"Hindi",script:"indic",dir:"ltr"},{code:"hr",name:"Croatian",script:"latin",dir:"ltr"},{code:"hu",name:"Hungarian",script:"latin",dir:"ltr"},{code:"id",name:"Indonesian",script:"latin",dir:"ltr"},{code:"it",name:"Italian",script:"latin",dir:"ltr"},{code:"ja",name:"Japanese",script:"cjk",dir:"ltr"},{code:"kn-IN",name:"Kannada",script:"indic",dir:"ltr"},{code:"ko",name:"Korean",script:"cjk",dir:"ltr"},{code:"ml-IN",name:"Malayalam",script:"indic",dir:"ltr"},{code:"mr-IN",name:"Marathi",script:"indic",dir:"ltr"},{code:"ms",name:"Malay",script:"latin",dir:"ltr"},{code:"nl-NL",name:"Dutch",script:"latin",dir:"ltr"},{code:"no",name:"Norwegian",script:"latin",dir:"ltr"},{code:"or-IN",name:"Odia",script:"indic",dir:"ltr"},{code:"pa-IN",name:"Punjabi",script:"indic",dir:"ltr"},{code:"pl",name:"Polish",script:"latin",dir:"ltr"},{code:"pt-BR",name:"Portuguese (Brazil)",script:"latin",dir:"ltr"},{code:"pt-PT",name:"Portuguese (Portugal)",script:"latin",dir:"ltr"},{code:"ro",name:"Romanian",script:"latin",dir:"ltr"},{code:"ru",name:"Russian",script:"cyrillic",dir:"ltr"},{code:"sk",name:"Slovak",script:"latin",dir:"ltr"},{code:"sl-SI",name:"Slovenian",script:"latin",dir:"ltr"},{code:"sv",name:"Swedish",script:"latin",dir:"ltr"},{code:"ta-IN",name:"Tamil",script:"indic",dir:"ltr"},{code:"te-IN",name:"Telugu",script:"indic",dir:"ltr"},{code:"th",name:"Thai",script:"thai",dir:"ltr"},{code:"tr",name:"Turkish",script:"latin",dir:"ltr"},{code:"uk",name:"Ukrainian",script:"cyrillic",dir:"ltr"},{code:"ur-PK",name:"Urdu",script:"rtl",dir:"rtl"},{code:"vi",name:"Vietnamese",script:"latin",dir:"ltr"},{code:"zh-Hans",name:"Chinese (Simplified)",script:"cjk",dir:"ltr"},{code:"zh-Hant",name:"Chinese (Traditional)",script:"cjk",dir:"ltr"}];Lt.map(e=>e.code);Object.fromEntries(Lt.map(e=>[e.code,e]));({...ve});function nr(e,t){t.material==="clay"?(e.setClay(t.clayTone==="custom"?`#${t.clayCustom}`:t.clayTone),e.setClearcoat(0)):(e.clayOff(),t.colorway==="custom"?e.setCustomColor(`#${t.customColor}`):e.setColorway(t.colorway),e.setFinish(R("finish",t.finish)),e.setClearcoat(R("clearcoat",t.clearcoat)))}function rr(e,t,n){e.screen.setGlare(!n&&t?e.device.environmentMap():null)}async function or(e,t,n,o){const{stage:r,device:a,screen:i}=e,l=t.material==="clay";if(t.cameraPos?r.setCameraPosition(t.cameraPos):r.setAngle(t.angle),a.setRoll(R("roll",t.roll)),nr(a,t),i.restoreScreen(),r.setStudioLighting(t.lighting),a.setReflections(t.reflections),i.setFlatScreen(t.flatScreen),n){try{await i.applyWallpaper(n)}catch{}if(!o())return}rr(e,t.glare,l)}function Ft(){const e=new Qe({antialias:!0,preserveDrawingBuffer:!0,alpha:!0});return e.setPixelRatio(1),e.shadowMap.enabled=!0,e}async function ar(e,t,n,o={}){const r=!o.renderer,a=o.renderer??Ft();a.setSize(t,n,!1);let i;o.cameraPosition?(i=new et(nt,t/n,.01,100),i.position.copy(o.cameraPosition),i.lookAt(0,0,0)):(i=e.camera.clone(),i.aspect=t/n,i.updateProjectionMatrix());try{const l=e.scene.background;e.scene.background=null;try{a.render(e.scene,i)}finally{e.scene.background=l}const s=document.createElement("canvas");let d=null;try{s.width=t,s.height=n,s.getContext("2d")?.drawImage(a.domElement,0,0);const u=ir(s);d=u;const p=u.width,h=u.height;return{bytes:await new Promise((c,g)=>{u.toBlob(m=>{if(!m){g(new Error("toBlob returned null"));return}m.arrayBuffer().then(b=>c(new Uint8Array(b)),g)},"image/png")}),width:p,height:h}}finally{d&&d!==s&&(d.width=0,d.height=0),s.width=0,s.height=0}}finally{r&&a.dispose()}}function ir(e,t=2){const n=e.getContext("2d",{willReadFrequently:!0});if(!n)return e;const{width:o,height:r}=e,a=n.getImageData(0,0,o,r).data;let i=o,l=r,s=-1,d=-1;for(let f=0;f<r;f++)for(let c=0;c<o;c++)a[(f*o+c)*4+3]!==0&&(c<i&&(i=c),c>s&&(s=c),f<l&&(l=f),f>d&&(d=f));if(s<i||d<l)return e;i=Math.max(0,i-t),l=Math.max(0,l-t),s=Math.min(o-1,s+t),d=Math.min(r-1,d+t);const u=s-i+1,p=d-l+1,h=document.createElement("canvas");return h.width=u,h.height=p,h.getContext("2d")?.drawImage(e,i,l,u,p,0,0,u,p),h}const sr=1900,lr=2800;function cr(e,t,n){return{shots:e,panels:t,selectedShotId:n.selectedShotId,panelPresetId:n.panelPresetId,bgMode:n.bgMode,gradientStops:n.gradientStops,gradientAngle:n.gradientAngle,gradientFrom:n.gradientFrom,gradientTo:n.gradientTo,gradientDir:n.gradientDir,panelColors:n.panelColors,shadow:n.shadow,floorReflection:n.floorReflection,panelBackgrounds:n.panelBackgrounds,captionStyles:n.captionStyles,captionText:n.captionText,locales:n.locales,baseLocale:n.baseLocale,outputs:n.outputs}}async function dr(e,t,n,o,r,a){const i=U(n,o),l=i.filter(c=>c.bytes);if(l.length===0)return null;const s=G(r.panelPresetId),d=new Map(o.map((c,g)=>[c.id,g])),u=r.renderScale!=null&&r.renderScale>0&&r.renderScale<=1?r.renderScale:1,p=Math.max(1,Math.round(sr*u)),h=Math.max(1,Math.round(lr*u)),f=Ft();try{const c=[];for(let S=0;S<l.length;S++){const y=l[S];a(`Rendering ${S+1}/${l.length}${r.locale?` (${r.locale})`:""}…`),await or(t,y.look,y.bytes,()=>!0);const P=await ar(e,p,h,{renderer:f,cameraPosition:bn(y.look.angle,y.look.cameraPos)});c.push({shotId:y.id,bytes:P.bytes,width:P.width,height:P.height,heightFrac:R("phoneHeight",y.look.phoneHeight)/100,hOffset:R("hOffset",y.look.hOffset)/100,vOffset:R("vOffset",y.look.vOffset)/100,panelIndex:d.get(y.panelId)??0,...y.look.clipToFrame===!0?{clipToFrame:!0}:{}})}const g=qn(c,s.width,s.height),m=Yn(o,r);a("Saving project…");const b=Mt(cr(i,o,r));return{panelWidth:s.width,panelHeight:s.height,count:o.length,background:m,phones:g,shadow:r.shadow,floorReflection:r.floorReflection??!1,project:JSON.stringify(b)}}finally{f.dispose(),f.forceContextLoss()}}function ee(e){return/^[0-9a-fA-F]{3,8}$/.test(e)?`#${e}`:e}function be(e,t,n,o){const{x0:r,y0:a,x1:i,y1:l}=Rn(n,o,t.angle),s=e.createLinearGradient(r,a,i,l);for(const d of t.stops)s.addColorStop(Math.min(1,Math.max(0,d.at)),ee(d.color));return s}function He(e,t,n,o,r,a,i){const l=document.createElement("canvas");l.width=n,l.height=o;try{const s=l.getContext("2d");if(!s)return;s.fillStyle=be(s,t,n,o),s.fillRect(r,0,a,o),e.drawImage(l,r,0,a,o,i,0,a,o)}finally{l.width=0,l.height=0}}function Ge(e){return URL.createObjectURL(new Blob([e],{type:"image/png"}))}function Ue(e){return new Promise((t,n)=>{const o=new Image;o.onload=()=>t(o),o.onerror=n,o.src=e})}const ur=16*1024*1024;function $e(e){const t=(e.img.naturalWidth||0)*(e.img.naturalHeight||0),n=e.reflection?e.reflection.canvas.width*e.reflection.canvas.height:0;return t+n}function Rt(){let e=0;const t=Array.from(F.values());for(const r of t)e+=$e(r);const n=Array.from(F.keys());let o=0;for(;e>ur&&o<n.length-1;){const r=F.get(n[o]);r&&(e-=$e(r),r.reflection&&(r.reflection.canvas.width=0,r.reflection.canvas.height=0),F.delete(n[o])),o++}}const F=new Map,ie=new Map;async function fr(e,t){if(!t){const a=Ge(e);try{return{img:await Ue(a)}}finally{URL.revokeObjectURL(a)}}const n=F.get(e);if(n)return F.delete(e),F.set(e,n),n;const o=ie.get(e);if(o)return o;const r=(async()=>{const a=Ge(e);try{return{img:await Ue(a)}}finally{URL.revokeObjectURL(a)}})();ie.set(e,r);try{const a=await r;return F.set(e,a),Rt(),a}finally{ie.delete(e)}}async function hr(e,t,n){const o=t.panelWidth*t.count,r=t.panelHeight,a=n?.backgroundViewport,i=a?t.panelWidth*a.panelCount:o,l=a?t.panelWidth*a.panelIndex:0;e.width=o,e.height=r;const s=e.getContext("2d");if(!s)return;n?.transparentBg?s.clearRect(0,0,o,r):t.background.kind==="gradient"?a?He(s,t.background.gradient,i,r,l,o,0):(s.fillStyle=be(s,t.background.gradient,o,r),s.fillRect(0,0,o,r)):t.background.kind==="perPanel"?t.background.colors.forEach((h,f)=>{s.fillStyle=ee(h),s.fillRect(f*t.panelWidth,0,t.panelWidth,r)}):t.background.fills.forEach((h,f)=>{const c=f*t.panelWidth;h.kind==="solid"?(s.fillStyle=ee(h.color),s.fillRect(c,0,t.panelWidth,r)):a?He(s,h.gradient,i,r,l+c,t.panelWidth,c):(s.fillStyle=be(s,h.gradient,o,r),s.fillRect(c,0,t.panelWidth,r))});const d=n?.phoneRange?Math.max(0,n.phoneRange.start):0,u=n?.phoneRange?Math.min(t.phones.length,n.phoneRange.end):t.phones.length,p=n?.reuseDecodedPhones===!0;for(let h=d;h<u;h++){const f=t.phones[h],c=n?.clip==="panel"||n?.clip===void 0&&f.clipToFrame===!0;if(n?.skipShotId&&f.shotId===n.skipShotId)continue;const g=await fr(f.bytes,p),m=g.img;c&&(s.save(),s.beginPath(),s.rect(f.panelIndex*t.panelWidth,0,t.panelWidth,r),s.clip()),t.floorReflection&&pr(s,g,f,p),s.save(),t.shadow&&(s.shadowColor="rgba(0,0,0,0.35)",s.shadowBlur=t.panelWidth*.03,s.shadowOffsetY=t.panelHeight*.012),s.drawImage(m,f.x,f.y,f.width,f.height),s.restore(),c&&s.restore()}}function pr(e,t,n,o){const r=Math.round(n.height*.45);if(r<=0||n.width<=0)return;const a=o?t.reflection:void 0;if(a&&a.width===n.width&&a.height===n.height){e.drawImage(a.canvas,n.x,n.y+n.height,n.width,r);return}const i=t.img,l=document.createElement("canvas");l.width=Math.max(1,n.width),l.height=Math.max(1,r);const s=l.getContext("2d");if(!s)return;s.save(),s.translate(0,r),s.scale(1,-1),s.drawImage(i,0,r-n.height,n.width,n.height),s.restore();const d=s.createLinearGradient(0,0,0,r);d.addColorStop(0,"rgba(0,0,0,0.34)"),d.addColorStop(1,"rgba(0,0,0,0)"),s.globalCompositeOperation="destination-in",s.fillStyle=d,s.fillRect(0,0,n.width,r),e.drawImage(l,n.x,n.y+n.height,n.width,r),o&&(t.reflection={width:n.width,height:n.height,canvas:l},Rt())}const _t=1.2,mr=.06,gr=.5;function yr(e,t,n){if(!e)return[t];const o=t.split(/\s+/).filter(Boolean),r=[];let a="";for(const i of o){const l=a?`${a} ${i}`:i;a&&e.measureText(l).width>n?(r.push(a),a=i):a=l}return a&&r.push(a),r}function br(e,t){if(!e)return 0;let n=0;for(const o of t)n=Math.max(n,e.measureText(o).width);return n}function Nt(e,t,n,o){const r=t.map((c,g)=>{const m=c.text.trim();if(!m)return null;const b=c.sizePt*(o/te),S=st(c.fontId).family;e&&(e.font=`${J} ${b}px "${S}"`);const y=yr(e,m,c.maxWidth*n),P=b*(c.lineHeight??_t),A=y.length*P,v=Math.max(A,(c.reserveLines??y.length)*P);return{layer:c,index:g,lines:y,px:b,lineH:P,width:br(e,y),blockH:A,reservedH:v}}),a=r.filter(c=>c!==null&&B(c.layer.anchor)),i=a.filter(c=>c.layer.band==="bottom"),l=a.filter(c=>c.layer.band!=="bottom"),s=c=>c[0]?.layer.bandInset??mr,d=(1-s(i))*o-i.reduce((c,g)=>c+g.reservedH,0);let u=s(l)*o,p=d,h=0;const f=[];for(const c of r){if(!c)continue;if(!B(c.layer.anchor)){f.push({layer:c.layer,index:c.index,x:c.layer.anchor.x*n,yTop:c.layer.anchor.y*o,lines:c.lines,px:c.px,lineH:c.lineH,width:c.width});continue}const g=c.layer.band==="bottom",b=(g?p:u)+(c.reservedH-c.blockH)/2,S=(c.layer.bandCenter??gr)*n;f.push({layer:c.layer,index:c.index,x:S,yTop:b,lines:c.lines,px:c.px,lineH:c.lineH,width:c.width}),g?p+=c.reservedH:u+=c.reservedH,h=Math.max(h,b+c.blockH)}return{placed:f,bandBottom:h}}function Sr(e,t,n,o){e.save(),e.textBaseline="top";const{placed:r}=Nt(e,t,n,o);for(const a of r){e.fillStyle=ee(a.layer.color),e.textAlign=a.layer.align,e.font=`${J} ${a.px}px "${st(a.layer.fontId).family}"`;let i=a.yTop;for(const l of a.lines)e.fillText(l,a.x,i),i+=a.lineH}e.restore()}function wr(e,t){return e.sizePt*(t/te)*(e.lineHeight??_t)}function vr(e,t,n,o){return Nt(e,t,n,o).placed.map(r=>{const a=r.layer.align==="center"?r.x-r.width/2:r.layer.align==="right"?r.x-r.width:r.x;return{index:r.index,anchorX:r.x/n,top:r.yTop/o,left:a/n,width:r.width/n,height:r.lines.length*r.lineH/o}})}function Ir(e,t,n,o,r){t.forEach((a,i)=>{const l=r[a];!l||l.length===0||(e.save(),e.translate(i*n,0),Sr(e,l,n,o),e.restore())})}const xr=""+new URL("Inter-SemiBold-B9yU462S.woff2",import.meta.url).href,Pr=""+new URL("Manrope-SemiBold-44nuYf5T.woff2",import.meta.url).href,Ar=""+new URL("Poppins-SemiBold-DJVo7c07.woff2",import.meta.url).href,Or=""+new URL("Fraunces-SemiBold-BtraKtER.woff2",import.meta.url).href,Tr=""+new URL("SpaceGrotesk-SemiBold-CyO2J5Y0.woff2",import.meta.url).href,kr={inter:xr,manrope:Pr,poppins:Ar,fraunces:Or,"space-grotesk":Tr},Cr=X.map(e=>({...e,url:kr[e.id]}));let K=null;function Er(){return K||(K=(async()=>{const e=new Set;document.fonts.forEach(t=>e.add(`${t.family}/${t.weight}`)),await Promise.all(Cr.filter(t=>!e.has(`${t.family}/${String(J)}`)).map(async t=>{const n=new FontFace(t.family,`url(${t.url})`,{weight:String(J)});await n.load(),document.fonts.add(n)})),await document.fonts.ready})().catch(e=>{throw K=null,e})),K}const Mr=22/te,Lr=1.1,We=4,Fr=.063,Rr=.167,Ve=Math.round(Mr*te),_r=.02,Nr=50;function j(e,t){const n=Math.max(e.x,t.x),o=Math.max(e.y,t.y),r=Math.min(e.x+e.width,t.x+t.width),a=Math.min(e.y+e.height,t.y+t.height);return r<=n||a<=o?null:{x:n,y:o,width:r-n,height:a-o}}function Bt(e,t){return j(e,t)}function Ke(e,t){const n=Math.abs(e-t)%360;return n>180?360-n:n}function qe(e){return gn(e.cameraPos??tt(e.angle))}function Dt(e,t,n,o,r,a,i){if(t.length===0)return[];const l=[];for(const s of vr(e,t,r,a)){const d=t[s.index];if(!d)continue;const u=Bt({x:(o+s.left)*r,y:s.top*a,width:s.width*r,height:s.height*a},i);u&&l.push({ref:{panelId:n,panelIndex:o,layerIndex:s.index,band:B(d.anchor)},box:u,lineHeightPx:wr(d,a)})}return l}function Br(e,t,n,o){return n.height<=Se(e,t,o)}function Se(e,t,n){const o=e.y+e.height/2<=t.y+t.height/2;return n*(o?Rr:Fr)}function Dr(e,t,n){return n.height<=Se(e.box,t.box,e.lineHeightPx)+Se(t.box,e.box,t.lineHeightPx)}function zr(e){const{ctx:t,panelIds:n,panelWidth:o,panelHeight:r}=e,a={x:0,y:0,width:o*n.length,height:r};t?.save();try{return jr(e,a)}finally{t?.restore()}}function jr(e,t){const{ctx:n,panelIds:o,panelWidth:r,panelHeight:a,captionLayers:i}=e,l=o.flatMap((c,g)=>Dt(n,i[c]??[],c,g,r,a,t)),s=[];for(const c of e.phones){const m=e.clip==="panel"||e.clip===void 0&&c.clipToFrame===!0?{x:c.panelIndex*r,y:0,width:r,height:a}:t,b=Bt({x:c.x,y:c.y,width:c.width,height:c.height},m);b&&s.push({shotId:c.shotId,box:b,layoutHeight:c.height})}const d=[];for(let c=0;c<l.length;c++)for(let g=c+1;g<l.length;g++){const m=j(l[c].box,l[g].box);m&&d.push({a:l[c].ref,b:l[g].ref,overlap:m,depthFrac:a>0?m.height/a:0,inkUncertain:Dr(l[c],l[g],m)})}const u=[];for(const c of l)for(const g of s){const m=j(c.box,g.box);m&&u.push({caption:c.ref,shotId:g.shotId,overlap:m,depthFrac:a>0?m.height/a:0,inkUncertain:Br(c.box,g.box,m,c.lineHeightPx)})}const p=[];for(let c=0;c<s.length;c++)for(let g=c+1;g<s.length;g++){const m=s[c],b=s[g],S=j(m.box,b.box);if(!S)continue;const y=[],P=Math.max(m.layoutHeight,b.layoutHeight),A=Math.min(m.layoutHeight,b.layoutHeight);A>0&&P/A>=Lr&&y.push("scale");const v=e.looks?.[m.shotId],w=e.looks?.[b.shotId],I=!!v&&!!w;v&&w&&(Ke(qe(v),qe(w))>=We&&y.push("angle"),Ke(R("roll",v.roll),R("roll",w.roll))>=We&&y.push("roll"));const O=Math.min(m.box.width*m.box.height,b.box.width*b.box.height);p.push({shotIdA:m.shotId,shotIdB:b.shotId,overlap:S,coverage:O>0?S.width*S.height/O:0,deliberate:y.length>0,signals:y,anglesKnown:I})}const h=new Set;for(const c of d)c.a.band&&h.add(c.a.panelId),c.b.band&&h.add(c.b.panelId);for(const c of u)c.caption.band&&h.add(c.caption.panelId);const f=[];return o.forEach((c,g)=>{if(!h.has(c))return;const m=Hr(e,c,g,t,l,s);m&&f.push(m)}),{captionsMeasurable:n!=null,captionOverlaps:d,captionDeviceOverlaps:u,deviceOverlaps:p,suggestions:f,hasWarning:d.length>0||u.length>0||p.some(c=>!c.deliberate)}}function Hr(e,t,n,o,r,a){const i=e.captionLayers[t]??[],l=i.flatMap((u,p)=>B(u.anchor)&&u.text.trim()?[p]:[]);if(l.length===0||!(Math.min(...l.map(u=>i[u].sizePt))>Ve))return null;const d=[...a.map(u=>u.box),...r.filter(u=>!(u.ref.panelId===t&&u.ref.band)).map(u=>u.box)];for(let u=1;u<=Nr;u++){const p=1-u*_r,h=new Map(l.map(m=>[m,Math.floor(i[m].sizePt*p)]));if(Math.min(...h.values())<Ve)return null;const f=i.map((m,b)=>{const S=h.get(b);return S===void 0?m:{...m,sizePt:S}});if(Dt(e.ctx,f,t,n,e.panelWidth,e.panelHeight,o).filter(m=>m.ref.band).every(m=>!d.some(b=>j(m.box,b))))return{panelId:t,scale:p,layers:l.map(m=>({layerIndex:m,fromSizePt:i[m].sizePt,toSizePt:h.get(m)}))}}return null}function zt(e){return`build-shot-${e+1}`}function jt(e){const t=[];for(const n of e.shots)t.includes(n.panelId)||t.push(n.panelId);return t}const Gr=1900,Ur=2800;function $r(e){return new Promise((t,n)=>{e.toBlob(o=>{if(!o)return n(new Error("canvas toBlob returned null"));o.arrayBuffer().then(r=>t(new Uint8Array(r)),n)},"image/png")})}async function Ht(e,t,n,o={}){await Er();const r=jt(e),a=r.map(h=>({id:h})),i=e.shots.map((h,f)=>({id:zt(f),panelId:h.panelId,frameNodeId:"",frameName:`screen-${f+1}`,bytes:t.screens[f]??null,look:h.look,thumb:null,thumbStale:!1})),s={panelPresetId:G(e.panelPresetId).id,bgMode:e.bgMode,gradientStops:e.gradientStops,gradientAngle:e.gradientAngle,gradientFrom:e.gradientFrom,gradientTo:e.gradientTo,gradientDir:e.gradientDir,panelColors:e.panelColors,shadow:e.shadow,floorReflection:e.floorReflection,panelBackgrounds:e.panelBackgrounds,selectedShotId:null,renderScale:o.renderScale,locale:n},d=o.onProgress??(()=>{});let u=o.refs,p=null;if(!u){const h=An(e.panelPresetId);p=rt(Gr,Ur);const f=await ot(p,h);u={stage:p,device:new at(f,p.scene,p.renderer,h),screen:new it(f,h)}}try{const h=await dr(u.stage,u,i,a,s,d);if(!h)throw new Error("buildStrip: nothing renderable (no shots)");const f=document.createElement("canvas");try{const c={...o.clip?{clip:o.clip}:{},...o.backgroundViewport?{backgroundViewport:o.backgroundViewport}:{}};await hr(f,h,Object.keys(c).length>0?c:void 0);const g=h.panelWidth,m=h.panelHeight,b=f.getContext("2d");if(!b)throw new Error("buildStrip: 2D context unavailable");Ir(b,r,g,m,t.captionText??{});const S=zr({phones:h.phones,panelIds:r,captionLayers:t.captionText??{},panelWidth:g,panelHeight:m,ctx:b,looks:Object.fromEntries(i.map(A=>[A.id,A.look])),clip:o.clip}),y=o.renderScale&&o.renderScale>0&&o.renderScale<1?o.renderScale:1,P=[];for(let A=0;A<h.count;A++){const v=document.createElement("canvas");v.width=Math.max(1,Math.round(g*y)),v.height=Math.max(1,Math.round(m*y));const w=v.width,I=v.height;try{const O=v.getContext("2d");if(!O)throw new Error("buildStrip: 2D context unavailable");O.drawImage(f,A*g,0,g,m,0,0,w,I),P.push({index:A,bytes:await $r(v),width:w,height:I})}finally{v.width=0,v.height=0}}return{panels:P,layout:S}}finally{f.width=0,f.height=0}}finally{p&&p.dispose()}}const Ye=.005,Wr=.02,Vr=12;function se(e){return Math.max(1,Math.round(e*100))}function le(e){return`${e.kind}:${e.frames.join(",")}:${e.anchored}`}function Kr(e,t){const n=new Map(e.suggestions.map(a=>[a.panelId,a.scale])),o=[];for(const a of e.captionOverlaps){if(a.inkUncertain||a.depthFrac<Ye)continue;const[i,l]=a.a.band===a.b.band?[a.a,a.b]:a.a.band?[a.a,a.b]:[a.b,a.a],s=ce([t.frameOfPanel(i.panelId),t.frameOfPanel(l.panelId)]);s.length!==0&&o.push({kind:"caption-caption",frames:s,depthPct:se(a.depthFrac),anchored:!a.a.band||!a.b.band,...Xe(n,i.band?i.panelId:null)})}for(const a of e.captionDeviceOverlaps){if(a.inkUncertain||a.depthFrac<Ye)continue;const i=ce([t.frameOfPanel(a.caption.panelId),t.frameOfShot(a.shotId)]);i.length!==0&&o.push({kind:"caption-device",frames:i,depthPct:se(a.depthFrac),anchored:!a.caption.band,...Xe(n,a.caption.band?a.caption.panelId:null)})}for(const a of e.deviceOverlaps){if(a.deliberate||a.coverage<Wr)continue;const i=ce([t.frameOfShot(a.shotIdA),t.frameOfShot(a.shotIdB)]);i.length!==0&&o.push({kind:"device-device",frames:i,depthPct:se(a.coverage),anchored:!1})}const r=new Map;for(const a of o){const i=r.get(le(a));i?a.depthPct>i.depthPct?r.set(le(a),{...a,clearAtScale:a.clearAtScale??i.clearAtScale}):i.clearAtScale==null&&a.clearAtScale!=null&&(i.clearAtScale=a.clearAtScale):r.set(le(a),a)}return[...r.values()].sort((a,i)=>i.depthPct-a.depthPct).slice(0,Vr).sort((a,i)=>a.frames[0]-i.frames[0]||a.kind.localeCompare(i.kind))}function ce(e){const[t,...n]=e;return t<0?[]:[t,...n.filter(o=>o>=0&&o!==t)]}function Xe(e,t){const n=t==null?void 0:e.get(t);return n==null?{}:{clearAtScale:Math.round(n*100)/100}}function qr(e,t){if(t.length===0)return e;const n=e.captionStyles;if(!n)return e;const o={};for(const[r,a]of Object.entries(n))o[r]=a.map(i=>({...i}));for(const r of t){const a=o[r.panelId];if(a)for(const i of r.layers){const l=a[i.layerIndex];l&&(l.sizePt=i.toSizePt)}}return{...e,captionStyles:o}}function de(e){return e.frames.map(t=>`frame ${t+1}`).join(" + ")}function Yr(e,t,n){if(!e.captionsMeasurable)return null;const o=Kr(e,t);if(o.length===0)return null;const r=o.filter(d=>d.kind==="device-device"),a=o.filter(d=>d.kind!=="device-device"&&d.clearAtScale==null);if(r.length>0||a.length>0||!n){const d=[];r.length>0&&d.push(`${r.map(de).join(", ")}: two devices overlap without reading as composed. There is no deterministic repair — give the pair a real difference in scale, camera angle or roll (that is what makes an overlap read as deliberate), or leave it if it already is.`);for(const u of a)d.push(u.anchored?`${de(u)}: the caption is anchored by hand, so it is reported and never rewritten — move it, or drop its \`anchor\` to let the band place it.`:`${de(u)}: no caption size above the legibility floor clears it — shorten the headline, or pick a layout with a bigger text region (\`style.layout: "bleed"\`).`);return d.length===0&&d.push("The rendered look was not available here, so no corrected look could be built."),{findings:o,note:`No corrected look is offered. ${d.join(" ")}`}}const i=new Set(o.filter(d=>d.kind!=="device-device").map(d=>d.frames[0])),l=e.suggestions.filter(d=>i.has(t.frameOfPanel(d.panelId))),s=l.flatMap(d=>{const u=t.frameOfPanel(d.panelId)+1;return d.layers.map(p=>`frame ${u} layer ${p.layerIndex+1}: sizePt ${p.fromSizePt} → ${p.toSizePt}`)}).join("; ");return{findings:o,correctedLook:qr(n,l),note:`\`layout.correctedLook\` is this same look with every caption shrunk to the largest size that was verified to clear the overlap (${s}). Nothing here is applied for you — re-render with it, or show the user the finding and let them decide. On render_strip pass it back as \`look\` together with the SAME \`style.captions\` you just sent: the words come from \`style.captions\` and every style field you leave out of them now comes from this look. The one thing that still beats it is a field you set EXPLICITLY on a caption entry, so if your \`style.captions\` pin \`sizePt\` at the original numbers, drop them or set them to the sizes above.`}}function Xr(e){return String(Math.max(-100,Math.min(100,e*35)))}const Jr=["roll","phoneHeight","hOffset","vOffset","finish","clearcoat"];function Je(e){if(!e||typeof e!="object")return{};const t={...e};for(const n of Jr)typeof t[n]=="number"&&(t[n]=String(t[n]));return t}function Zr(e){const{subtitle:t,sizePt:n,maxWidth:o,...r}=e;return{...r,...n!==void 0?{sizePt:Number(n)}:{},...o!==void 0?{maxWidth:Number(o)}:{}}}function Ze(e){const t={};for(const[n,o]of Object.entries(e))o!==void 0&&(t[n]=o);return t}function ue(e,t,n){const o={};return e&&t.forEach((r,a)=>{const i=n[a];i!==void 0&&e[r]!==void 0&&(o[i]=e[r])}),o}function Qr(e){const t=e.slotSizes.filter(w=>Number.isInteger(w)&&w>0),n=t.map((w,I)=>`panel-${I+1}`);let o={};const r=e.look&&typeof e.look=="object"?e.look:null,a=e.style??null,i=r&&Array.isArray(r.shots)?r.shots:[],l=i.length>0,s=a?Je(a.shotLook):null,d=[];let u=0;t.forEach((w,I)=>{for(let O=0;O<w;O++){const T=l?Je(i[u]?.look??i[0]?.look??{}):s??{},$=T.hOffset!==void 0&&T.hOffset!==null?String(T.hOffset):Xr(O);d.push({panelId:n[I],look:{...x,...T,hOffset:$}}),u++}});let p={},h={},f={},c="gradient",g=kn,m=Cn,b="vertical",S,y,P=!0,A=!1;if(r){c=r.bgMode==="perPanel"?"perPanel":"gradient";const w=Q({gradientStops:Array.isArray(r.gradientStops)?r.gradientStops:void 0,gradientAngle:typeof r.gradientAngle=="number"?r.gradientAngle:void 0,gradientFrom:typeof r.gradientFrom=="string"?r.gradientFrom:g,gradientTo:typeof r.gradientTo=="string"?r.gradientTo:m,gradientDir:r.gradientDir==="horizontal"?"horizontal":b});S=w.stops,y=w.angle,{gradientFrom:g,gradientTo:m,gradientDir:b}=Z(w),r.shadow===!1&&(P=!1),r.floorReflection===!0&&(A=!0);const I=[];for(const O of i){const T=typeof O?.panelId=="string"?O.panelId:null;T&&!I.includes(T)&&I.push(T)}p=ue(r.panelColors,I,n),h=ue(Pt(r.captionStyles),I,n),f=ue(vt(r.panelBackgrounds),I,n)}else if(a){const w=a.background??{};c=w.mode==="perPanel"?"perPanel":"gradient";const I=Q({gradientStops:w.stops,gradientAngle:w.angle,gradientFrom:g,gradientTo:m,gradientDir:b});S=I.stops,y=I.angle,{gradientFrom:g,gradientTo:m,gradientDir:b}=Z(I),w.shadow===!1&&(P=!1),w.floorReflection===!0&&(A=!0),Array.isArray(w.panelColors)&&w.panelColors.forEach((O,T)=>{typeof O=="string"&&O&&n[T]!==void 0&&(p[n[T]]=O)})}if(a&&Array.isArray(a.captions)){const w=h,I=(L,oe)=>({...w[L]?.[oe]??{}}),O={},T={};a.captions.forEach((L,oe)=>{const _=n[oe];if(!(_===void 0||L===null||L===void 0)){if(Array.isArray(L)){const N=L.filter(E=>!!E&&typeof E=="object"&&typeof E.text=="string"&&E.text.trim()!=="").map((E,W)=>({...I(_,W),...Ze(Zr(E))}));N.length>0&&(T[_]=N)}else if(typeof L=="object"){const{text:N,subtitle:E,sizePt:W,maxWidth:Ae,...Vt}=L;O[_]={...I(_,0),...Ze({...Vt,...W!==void 0?{sizePt:Number(W)}:{},...Ae!==void 0?{maxWidth:Number(Ae)}:{}})},typeof N=="string"&&N.trim()&&(T[_]={headline:N,...typeof E=="string"&&E?{subtitle:E}:{}})}}});const $=re({[M]:T},xt(O));h=Ot($),o=At($)}return{look:{panelPresetId:e.panelPresetId??(typeof r?.panelPresetId=="string"?r.panelPresetId:void 0)??"r69",bgMode:c,gradientStops:S,gradientAngle:y,gradientFrom:g,gradientTo:m,gradientDir:b,panelColors:p,shadow:P,floorReflection:A,panelBackgrounds:f,captionStyles:h,shots:d},panelIds:n,captionText:o}}function eo(e){const t=e?.trim();return t?/\.(png|jpe?g|webp)$/i.test(t)?t:`${t}.png`:null}function to(e,t){const n=new Map;return e.map((o,r)=>{const a=eo(t?.[r]);if(!a)return`screen-${r+1}.png`;const i=n.get(a)??0;if(n.set(a,i+1),i===0)return a;const l=a.lastIndexOf(".");return`${a.slice(0,l)}-${i+1}${a.slice(l)}`})}function no(e){const{look:t,panelIds:n,captionText:o,locale:r,shotNames:a,outputs:i}=e,l=n.map(u=>({id:u})),s=to(t.shots,a),d=t.shots.map((u,p)=>({id:`shot-${p+1}`,panelId:u.panelId,frameNodeId:s[p],frameName:s[p],bytes:null,look:u.look,thumb:null,thumbStale:!0}));return Mt({shots:d,panels:l,selectedShotId:d[0]?.id??null,panelPresetId:t.panelPresetId,bgMode:t.bgMode,gradientStops:t.gradientStops,gradientAngle:t.gradientAngle,gradientFrom:t.gradientFrom,gradientTo:t.gradientTo,gradientDir:t.gradientDir,panelColors:t.panelColors,shadow:t.shadow,floorReflection:t.floorReflection,panelBackgrounds:t.panelBackgrounds,captionStyles:t.captionStyles,outputs:i,captionText:o&&Object.keys(o).length>0?{[r||M]:o}:{}})}function C(e){console.log("[render]",e)}const ro=1900,oo=2800;let fe=null;async function Gt(){return fe||(fe=(async()=>{C("booting headless stage + loading model (once)…");const e=rt(ro,oo),t=await vn(e);return{stage:e,device:new at(t,e.scene,e.renderer),screen:new it(t)}})()),fe}function Ut(e){const t=atob(e),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return n}function Pe(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function ao(e){return new Promise((t,n)=>{e.toBlob(async o=>{if(!o)return n(new Error("toBlob null"));t(Pe(new Uint8Array(await o.arrayBuffer())))},"image/png")})}function $t(e,t){const n=jt(t),o=new Map(t.shots.map((a,i)=>[zt(i),n.indexOf(a.panelId)])),r=Yr(e.layout,{frameOfPanel:a=>n.indexOf(a),frameOfShot:a=>o.get(a)??-1},t);if(r)return{layout:{findings:r.findings,...r.correctedLook?{correctedLook:r.correctedLook}:{}},layoutNote:r.note}}async function Wt(e){const t=await Promise.all(e.map(a=>createImageBitmap(new Blob([new Uint8Array(a.bytes)],{type:"image/png"})))),n=document.createElement("canvas");n.width=t.reduce((a,i)=>a+i.width,0),n.height=t[0]?.height??1;const o=n.getContext("2d");let r=0;for(const a of t)o.drawImage(a,r,0),r+=a.width,a.close();return{base64:await ao(n),width:n.width,height:n.height}}window.renderStrip=async function(t){try{if(!t||!Array.isArray(t.screenshots)||t.screenshots.length===0)throw new Error("renderStrip: input.screenshots must be a non-empty nested array of slots");const n=await Gt(),o=t.screenshots.map(y=>Array.isArray(y)?y:[y]),{look:r,panelIds:a,captionText:i}=Qr({slotSizes:o.map(y=>y.length),panelPresetId:t.panelPresetId,look:t.look??void 0,style:t.style??void 0}),l=o.flat().map(Ut),s=Array.isArray(t.captionLayers)&&a[0]?{[a[0]]:t.captionLayers}:i,d=t.preview?.25:1;C(`buildStrip (${o.length} panel${o.length===1?"":"s"}${t.locale?`, ${t.locale}`:""})…`);const u=performance.now(),p=await Ht(r,{screens:l,captionText:s},t.locale,{refs:n,renderScale:d,onProgress:y=>C(" "+y),...t.clip?{clip:t.clip}:{},...t.backgroundViewport?{backgroundViewport:t.backgroundViewport}:{}});C("encoding panels + stitching the strip preview…");const h=p.panels.map(y=>Pe(y.bytes)),f=await Wt(p.panels),c=G(r.panelPresetId),g=Math.round(performance.now()-u),m=$t(p,r),b=Array.isArray(t.screenshotNames)?t.screenshotNames.flat():void 0,S=t.buildRecord?no({look:r,panelIds:a,captionText:i,locale:t.locale,shotNames:b,outputs:t.outputs}):void 0;return C(`done: ${p.panels.length} panels, strip ${f.width}x${f.height}, ${g}ms`),{ok:!0,ms:g,count:p.panels.length,panelPresetId:c.id,panelWidth:c.width,panelHeight:c.height,stripWidth:f.width,stripHeight:f.height,panels:h,stripBase64:f.base64,preview:d<1,...S?{projectRecord:S}:{},...m??{}}}catch(n){const o=n&&n.stack?n.stack:String(n);return C("ERROR: "+o),{ok:!1,error:String(n&&n.message?n.message:n)}}};window.renderProject=async function(t){try{if(!t||t.projectFile==null||typeof t.projectFile!="object")throw new Error("renderProject: input.projectFile (the saved ProjectFile) is required");const n=Qn(JSON.stringify(t.projectFile));if(!n)throw new Error("renderProject: the saved project could not be restored (wrong schema or malformed record)");const o=await Gt(),r=t.locale||n.baseLocale||n.locales?.[0]||"en-US",a=U(n.shots,n.panels),i=me(t.variant||{},n.baseLocale),l=new Map((t.screenManifest||[]).map(v=>[`${v.shotId} ${Be(me(v.variant||{},n.baseLocale))}`,v])),s=(v,w)=>l.get(`${v} ${Be(w)}`),d=a.map(v=>Wn(s,v.id,i,Un,n.baseLocale)),u=a.map((v,w)=>({frameName:v.frameName,matched:d[w].value!==void 0,requestedVariant:i,resolvedAt:d[w].resolvedAt,inherited:d[w].inherited,...d[w].value?.source?{source:d[w].value.source}:{}})),p=d.map(({value:v})=>v?.bytes?Ut(v.bytes):null),h=At(n.captionText,r,n.baseLocale),f=tr({...n,selectedShotId:null,panelPresetId:t.panelPresetId??n.panelPresetId,captionText:{[r]:h}}),c=t.preview?.25:1;C(`renderProject (${a.length} shot${a.length===1?"":"s"}, ${r})…`);const g=performance.now(),m=await Ht(f,{screens:p,captionText:h},r,{refs:o,renderScale:c,onProgress:v=>C(" "+v)});C("encoding panels + stitching the strip preview…");const b=m.panels.map(v=>Pe(v.bytes)),S=await Wt(m.panels),y=G(f.panelPresetId),P=Math.round(performance.now()-g),A=$t(m,f);return C(`done: ${m.panels.length} panels, strip ${S.width}x${S.height}, ${P}ms`),{ok:!0,ms:P,count:m.panels.length,panelPresetId:y.id,panelWidth:y.width,panelHeight:y.height,stripWidth:S.width,stripHeight:S.height,panels:b,stripBase64:S.base64,preview:c<1,shots:u,locale:r,...A??{}}}catch(n){const o=n&&n.stack?n.stack:String(n);return C("ERROR: "+o),{ok:!1,error:String(n&&n.message?n.message:n)}}};window.__RENDER_READY=!0;C("harness ready ✓");
@@ -0,0 +1 @@
1
+ import{O as k,E as ot,S as Cs,g as ee,w as Ps,V as b,d as he,n as I,B as me,M as R,A as Rt,a as E,b as ze,c as q,R as yt,e as B,D as Os,T as be,N as at,f as ks,F as cs,h as Bs,i as te,C as L,j as Ge,k as ge,l as w,m as ct,o as Ds,Z as Nt,W as Lt,p as It,I as Je,q as ve,r as we,Q as xt,s as Fs,t as Hs,u as Us,P as At,v as Vs,x as hs,y as ls,z as zs,G as ht,H as us,L as z,J as _e,K as ds,U as Gs,X as js,Y as Ks,_ as fs,$ as lt,a0 as Ws,a1 as Js,a2 as Xs,a3 as Q,a4 as Xe,a5 as qs,a6 as Ct,a7 as Zs,a8 as Ys,a9 as Qs}from"./three-webgl-DCw804Ic.js";class $s extends k{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ot,this.environmentIntensity=1,this.environmentRotation=new ot,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class en{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Cs,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=ee()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return Ps("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,s){e*=this.stride,s*=t.stride;for(let n=0,i=this.stride;n<i;n++)this.array[e+n]=t.array[s+n];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ee()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),s=new this.constructor(t,this.stride);return s.setUsage(this.usage),s}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ee()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const N=new b;class Tt{constructor(e,t,s,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=s,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,s=this.data.count;t<s;t++)N.fromBufferAttribute(this,t),N.applyMatrix4(e),this.setXYZ(t,N.x,N.y,N.z);return this}applyNormalMatrix(e){for(let t=0,s=this.count;t<s;t++)N.fromBufferAttribute(this,t),N.applyNormalMatrix(e),this.setXYZ(t,N.x,N.y,N.z);return this}transformDirection(e){for(let t=0,s=this.count;t<s;t++)N.fromBufferAttribute(this,t),N.transformDirection(e),this.setXYZ(t,N.x,N.y,N.z);return this}getComponent(e,t){let s=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(s=he(s,this.array)),s}setComponent(e,t,s){return this.normalized&&(s=I(s,this.array)),this.data.array[e*this.data.stride+this.offset+t]=s,this}setX(e,t){return this.normalized&&(t=I(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=I(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=I(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=I(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=he(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=he(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=he(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=he(t,this.array)),t}setXY(e,t,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=I(t,this.array),s=I(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=s,this}setXYZ(e,t,s,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=I(t,this.array),s=I(s,this.array),n=I(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=s,this.data.array[e+2]=n,this}setXYZW(e,t,s,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=I(t,this.array),s=I(s,this.array),n=I(n,this.array),i=I(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=s,this.data.array[e+2]=n,this.data.array[e+3]=i,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let s=0;s<this.count;s++){const n=s*this.data.stride+this.offset;for(let i=0;i<this.itemSize;i++)t.push(this.data.array[n+i])}return new me(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Tt(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let s=0;s<this.count;s++){const n=s*this.data.stride+this.offset;for(let i=0;i<this.itemSize;i++)t.push(this.data.array[n+i])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}const Pt=new b,Ot=new B,kt=new B,tn=new b,Bt=new E,Le=new b,qe=new q,Dt=new E,Ze=new yt;class sn extends R{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Rt,this.bindMatrix=new E,this.bindMatrixInverse=new E,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new ze),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let s=0;s<t.count;s++)this.getVertexPosition(s,Le),this.boundingBox.expandByPoint(Le)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new q),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let s=0;s<t.count;s++)this.getVertexPosition(s,Le),this.boundingSphere.expandByPoint(Le)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const s=this.material,n=this.matrixWorld;s!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),qe.copy(this.boundingSphere),qe.applyMatrix4(n),e.ray.intersectsSphere(qe)!==!1&&(Dt.copy(n).invert(),Ze.copy(e.ray).applyMatrix4(Dt),!(this.boundingBox!==null&&Ze.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Ze)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new B,t=this.geometry.attributes.skinWeight;for(let s=0,n=t.count;s<n;s++){e.fromBufferAttribute(t,s);const i=1/e.manhattanLength();i!==1/0?e.multiplyScalar(i):e.set(1,0,0,0),t.setXYZW(s,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Rt?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Os?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const s=this.skeleton,n=this.geometry;Ot.fromBufferAttribute(n.attributes.skinIndex,e),kt.fromBufferAttribute(n.attributes.skinWeight,e),Pt.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let i=0;i<4;i++){const r=kt.getComponent(i);if(r!==0){const o=Ot.getComponent(i);Bt.multiplyMatrices(s.bones[o].matrixWorld,s.boneInverses[o]),t.addScaledVector(tn.copy(Pt).applyMatrix4(Bt),r)}}return t.applyMatrix4(this.bindMatrixInverse)}}class ps extends k{constructor(){super(),this.isBone=!0,this.type="Bone"}}class ms extends be{constructor(e=null,t=1,s=1,n,i,r,o,c,h=at,l=at,u,d){super(null,r,o,c,h,l,n,i,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:s},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Ft=new E,nn=new E;class bt{constructor(e=[],t=[]){this.uuid=ee(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let s=0,n=this.bones.length;s<n;s++)this.boneInverses.push(new E)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const s=new E;this.bones[e]&&s.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(s)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const s=this.bones[e];s&&s.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const s=this.bones[e];s&&(s.parent&&s.parent.isBone?(s.matrix.copy(s.parent.matrixWorld).invert(),s.matrix.multiply(s.matrixWorld)):s.matrix.copy(s.matrixWorld),s.matrix.decompose(s.position,s.quaternion,s.scale))}}update(){const e=this.bones,t=this.boneInverses,s=this.boneMatrices,n=this.boneTexture;for(let i=0,r=e.length;i<r;i++){const o=e[i]?e[i].matrixWorld:nn;Ft.multiplyMatrices(o,t[i]),Ft.toArray(s,i*16)}n!==null&&(n.needsUpdate=!0)}clone(){return new bt(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const s=new ms(t,e,e,ks,cs);return s.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=s,this}getBoneByName(e){for(let t=0,s=this.bones.length;t<s;t++){const n=this.bones[t];if(n.name===e)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let s=0,n=e.bones.length;s<n;s++){const i=e.bones[s];let r=t[i];r===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",i),r=new ps),this.bones.push(r),this.boneInverses.push(new E().fromArray(e.boneInverses[s]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,s=this.boneInverses;for(let n=0,i=t.length;n<i;n++){const r=t[n];e.bones.push(r.uuid);const o=s[n];e.boneInverses.push(o.toArray())}return e}}class ut extends me{constructor(e,t,s,n=1){super(e,t,s),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Z=new E,Ht=new E,Ie=[],Ut=new ze,rn=new E,le=new R,ue=new q;class on extends R{constructor(e,t,s){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new ut(new Float32Array(s*16),16),this.instanceColor=null,this.morphTexture=null,this.count=s,this.boundingBox=null,this.boundingSphere=null;for(let n=0;n<s;n++)this.setMatrixAt(n,rn)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new ze),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let s=0;s<t;s++)this.getMatrixAt(s,Z),Ut.copy(e.boundingBox).applyMatrix4(Z),this.boundingBox.union(Ut)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new q),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let s=0;s<t;s++)this.getMatrixAt(s,Z),ue.copy(e.boundingSphere).applyMatrix4(Z),this.boundingSphere.union(ue)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const s=t.morphTargetInfluences,n=this.morphTexture.source.data.data,i=s.length+1,r=e*i+1;for(let o=0;o<s.length;o++)s[o]=n[r+o]}raycast(e,t){const s=this.matrixWorld,n=this.count;if(le.geometry=this.geometry,le.material=this.material,le.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ue.copy(this.boundingSphere),ue.applyMatrix4(s),e.ray.intersectsSphere(ue)!==!1))for(let i=0;i<n;i++){this.getMatrixAt(i,Z),Ht.multiplyMatrices(s,Z),le.matrixWorld=Ht,le.raycast(e,Ie);for(let r=0,o=Ie.length;r<o;r++){const c=Ie[r];c.instanceId=i,c.object=this,t.push(c)}Ie.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new ut(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const s=t.morphTargetInfluences,n=s.length+1;this.morphTexture===null&&(this.morphTexture=new ms(new Float32Array(n*this.count),n,this.count,Bs,cs));const i=this.morphTexture.source.data.data;let r=0;for(let h=0;h<s.length;h++)r+=s[h];const o=this.geometry.morphTargetsRelative?1:1-r,c=n*e;i[c]=o,i.set(s,c+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}}class gs extends te{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new L(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Ue=new b,Ve=new b,Vt=new E,de=new yt,Ce=new q,Ye=new b,zt=new b;class vt extends k{constructor(e=new Ge,t=new gs){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,s=[0];for(let n=1,i=t.count;n<i;n++)Ue.fromBufferAttribute(t,n-1),Ve.fromBufferAttribute(t,n),s[n]=s[n-1],s[n]+=Ue.distanceTo(Ve);e.setAttribute("lineDistance",new ge(s,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const s=this.geometry,n=this.matrixWorld,i=e.params.Line.threshold,r=s.drawRange;if(s.boundingSphere===null&&s.computeBoundingSphere(),Ce.copy(s.boundingSphere),Ce.applyMatrix4(n),Ce.radius+=i,e.ray.intersectsSphere(Ce)===!1)return;Vt.copy(n).invert(),de.copy(e.ray).applyMatrix4(Vt);const o=i/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,h=this.isLineSegments?2:1,l=s.index,d=s.attributes.position;if(l!==null){const f=Math.max(0,r.start),p=Math.min(l.count,r.start+r.count);for(let g=f,m=p-1;g<m;g+=h){const y=l.getX(g),T=l.getX(g+1),A=Pe(this,e,de,c,y,T);A&&t.push(A)}if(this.isLineLoop){const g=l.getX(p-1),m=l.getX(f),y=Pe(this,e,de,c,g,m);y&&t.push(y)}}else{const f=Math.max(0,r.start),p=Math.min(d.count,r.start+r.count);for(let g=f,m=p-1;g<m;g+=h){const y=Pe(this,e,de,c,g,g+1);y&&t.push(y)}if(this.isLineLoop){const g=Pe(this,e,de,c,p-1,f);g&&t.push(g)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,s=Object.keys(t);if(s.length>0){const n=t[s[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let i=0,r=n.length;i<r;i++){const o=n[i].name||String(i);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=i}}}}}function Pe(a,e,t,s,n,i){const r=a.geometry.attributes.position;if(Ue.fromBufferAttribute(r,n),Ve.fromBufferAttribute(r,i),t.distanceSqToSegment(Ue,Ve,Ye,zt)>s)return;Ye.applyMatrix4(a.matrixWorld);const c=e.ray.origin.distanceTo(Ye);if(!(c<e.near||c>e.far))return{distance:c,point:zt.clone().applyMatrix4(a.matrixWorld),index:n,face:null,faceIndex:null,object:a}}const Gt=new b,jt=new b;class an extends vt{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,s=[];for(let n=0,i=t.count;n<i;n+=2)Gt.fromBufferAttribute(t,n),jt.fromBufferAttribute(t,n+1),s[n]=n===0?0:s[n-1],s[n+1]=s[n]+Gt.distanceTo(jt);e.setAttribute("lineDistance",new ge(s,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class cn extends vt{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class ys extends te{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new L(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const Kt=new E,dt=new yt,Oe=new q,ke=new b;class hn extends k{constructor(e=new Ge,t=new ys){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const s=this.geometry,n=this.matrixWorld,i=e.params.Points.threshold,r=s.drawRange;if(s.boundingSphere===null&&s.computeBoundingSphere(),Oe.copy(s.boundingSphere),Oe.applyMatrix4(n),Oe.radius+=i,e.ray.intersectsSphere(Oe)===!1)return;Kt.copy(n).invert(),dt.copy(e.ray).applyMatrix4(Kt);const o=i/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,h=s.index,u=s.attributes.position;if(h!==null){const d=Math.max(0,r.start),f=Math.min(h.count,r.start+r.count);for(let p=d,g=f;p<g;p++){const m=h.getX(p);ke.fromBufferAttribute(u,m),Wt(ke,m,c,n,e,t,this)}}else{const d=Math.max(0,r.start),f=Math.min(u.count,r.start+r.count);for(let p=d,g=f;p<g;p++)ke.fromBufferAttribute(u,p),Wt(ke,p,c,n,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,s=Object.keys(t);if(s.length>0){const n=t[s[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let i=0,r=n.length;i<r;i++){const o=n[i].name||String(i);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=i}}}}}function Wt(a,e,t,s,n,i,r){const o=dt.distanceSqToPoint(a);if(o<t){const c=new b;dt.closestPointToPoint(a,c),c.applyMatrix4(s);const h=n.ray.origin.distanceTo(c);if(h<n.near||h>n.far)return;i.push({distance:h,distanceToRay:Math.sqrt(o),point:c,index:e,face:null,object:r})}}class Qi extends be{constructor(e,t,s,n,i,r,o,c,h){super(e,t,s,n,i,r,o,c,h),this.isCanvasTexture=!0,this.needsUpdate=!0}}class D{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const s=this.getUtoTmapping(e);return this.getPoint(s,t)}getPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPoint(s/e));return t}getSpacedPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPointAt(s/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let s,n=this.getPoint(0),i=0;t.push(0);for(let r=1;r<=e;r++)s=this.getPoint(r/e),i+=s.distanceTo(n),t.push(i),n=s;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const s=this.getLengths();let n=0;const i=s.length;let r;t?r=t:r=e*s[i-1];let o=0,c=i-1,h;for(;o<=c;)if(n=Math.floor(o+(c-o)/2),h=s[n]-r,h<0)o=n+1;else if(h>0)c=n-1;else{c=n;break}if(n=c,s[n]===r)return n/(i-1);const l=s[n],d=s[n+1]-l,f=(r-l)/d;return(n+f)/(i-1)}getTangent(e,t){let n=e-1e-4,i=e+1e-4;n<0&&(n=0),i>1&&(i=1);const r=this.getPoint(n),o=this.getPoint(i),c=t||(r.isVector2?new w:new b);return c.copy(o).sub(r).normalize(),c}getTangentAt(e,t){const s=this.getUtoTmapping(e);return this.getTangent(s,t)}computeFrenetFrames(e,t){const s=new b,n=[],i=[],r=[],o=new b,c=new E;for(let f=0;f<=e;f++){const p=f/e;n[f]=this.getTangentAt(p,new b)}i[0]=new b,r[0]=new b;let h=Number.MAX_VALUE;const l=Math.abs(n[0].x),u=Math.abs(n[0].y),d=Math.abs(n[0].z);l<=h&&(h=l,s.set(1,0,0)),u<=h&&(h=u,s.set(0,1,0)),d<=h&&s.set(0,0,1),o.crossVectors(n[0],s).normalize(),i[0].crossVectors(n[0],o),r[0].crossVectors(n[0],i[0]);for(let f=1;f<=e;f++){if(i[f]=i[f-1].clone(),r[f]=r[f-1].clone(),o.crossVectors(n[f-1],n[f]),o.length()>Number.EPSILON){o.normalize();const p=Math.acos(ct(n[f-1].dot(n[f]),-1,1));i[f].applyMatrix4(c.makeRotationAxis(o,p))}r[f].crossVectors(n[f],i[f])}if(t===!0){let f=Math.acos(ct(i[0].dot(i[e]),-1,1));f/=e,n[0].dot(o.crossVectors(i[0],i[e]))>0&&(f=-f);for(let p=1;p<=e;p++)i[p].applyMatrix4(c.makeRotationAxis(n[p],f*p)),r[p].crossVectors(n[p],i[p])}return{tangents:n,normals:i,binormals:r}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class wt extends D{constructor(e=0,t=0,s=1,n=1,i=0,r=Math.PI*2,o=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=s,this.yRadius=n,this.aStartAngle=i,this.aEndAngle=r,this.aClockwise=o,this.aRotation=c}getPoint(e,t=new w){const s=t,n=Math.PI*2;let i=this.aEndAngle-this.aStartAngle;const r=Math.abs(i)<Number.EPSILON;for(;i<0;)i+=n;for(;i>n;)i-=n;i<Number.EPSILON&&(r?i=0:i=n),this.aClockwise===!0&&!r&&(i===n?i=-n:i=i-n);const o=this.aStartAngle+e*i;let c=this.aX+this.xRadius*Math.cos(o),h=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const l=Math.cos(this.aRotation),u=Math.sin(this.aRotation),d=c-this.aX,f=h-this.aY;c=d*l-f*u+this.aX,h=d*u+f*l+this.aY}return s.set(c,h)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class ln extends wt{constructor(e,t,s,n,i,r){super(e,t,s,s,n,i,r),this.isArcCurve=!0,this.type="ArcCurve"}}function _t(){let a=0,e=0,t=0,s=0;function n(i,r,o,c){a=i,e=o,t=-3*i+3*r-2*o-c,s=2*i-2*r+o+c}return{initCatmullRom:function(i,r,o,c,h){n(r,o,h*(o-i),h*(c-r))},initNonuniformCatmullRom:function(i,r,o,c,h,l,u){let d=(r-i)/h-(o-i)/(h+l)+(o-r)/l,f=(o-r)/l-(c-r)/(l+u)+(c-o)/u;d*=l,f*=l,n(r,o,d,f)},calc:function(i){const r=i*i,o=r*i;return a+e*i+t*r+s*o}}}const Be=new b,Qe=new _t,$e=new _t,et=new _t;class un extends D{constructor(e=[],t=!1,s="centripetal",n=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=s,this.tension=n}getPoint(e,t=new b){const s=t,n=this.points,i=n.length,r=(i-(this.closed?0:1))*e;let o=Math.floor(r),c=r-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/i)+1)*i:c===0&&o===i-1&&(o=i-2,c=1);let h,l;this.closed||o>0?h=n[(o-1)%i]:(Be.subVectors(n[0],n[1]).add(n[0]),h=Be);const u=n[o%i],d=n[(o+1)%i];if(this.closed||o+2<i?l=n[(o+2)%i]:(Be.subVectors(n[i-1],n[i-2]).add(n[i-1]),l=Be),this.curveType==="centripetal"||this.curveType==="chordal"){const f=this.curveType==="chordal"?.5:.25;let p=Math.pow(h.distanceToSquared(u),f),g=Math.pow(u.distanceToSquared(d),f),m=Math.pow(d.distanceToSquared(l),f);g<1e-4&&(g=1),p<1e-4&&(p=g),m<1e-4&&(m=g),Qe.initNonuniformCatmullRom(h.x,u.x,d.x,l.x,p,g,m),$e.initNonuniformCatmullRom(h.y,u.y,d.y,l.y,p,g,m),et.initNonuniformCatmullRom(h.z,u.z,d.z,l.z,p,g,m)}else this.curveType==="catmullrom"&&(Qe.initCatmullRom(h.x,u.x,d.x,l.x,this.tension),$e.initCatmullRom(h.y,u.y,d.y,l.y,this.tension),et.initCatmullRom(h.z,u.z,d.z,l.z,this.tension));return s.set(Qe.calc(c),$e.calc(c),et.calc(c)),s}copy(e){super.copy(e),this.points=[];for(let t=0,s=e.points.length;t<s;t++){const n=e.points[t];this.points.push(n.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,s=this.points.length;t<s;t++){const n=this.points[t];e.points.push(n.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,s=e.points.length;t<s;t++){const n=e.points[t];this.points.push(new b().fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function Jt(a,e,t,s,n){const i=(s-e)*.5,r=(n-t)*.5,o=a*a,c=a*o;return(2*t-2*s+i+r)*c+(-3*t+3*s-2*i-r)*o+i*a+t}function dn(a,e){const t=1-a;return t*t*e}function fn(a,e){return 2*(1-a)*a*e}function pn(a,e){return a*a*e}function ye(a,e,t,s){return dn(a,e)+fn(a,t)+pn(a,s)}function mn(a,e){const t=1-a;return t*t*t*e}function gn(a,e){const t=1-a;return 3*t*t*a*e}function yn(a,e){return 3*(1-a)*a*a*e}function xn(a,e){return a*a*a*e}function xe(a,e,t,s,n){return mn(a,e)+gn(a,t)+yn(a,s)+xn(a,n)}class xs extends D{constructor(e=new w,t=new w,s=new w,n=new w){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=s,this.v3=n}getPoint(e,t=new w){const s=t,n=this.v0,i=this.v1,r=this.v2,o=this.v3;return s.set(xe(e,n.x,i.x,r.x,o.x),xe(e,n.y,i.y,r.y,o.y)),s}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class An extends D{constructor(e=new b,t=new b,s=new b,n=new b){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=s,this.v3=n}getPoint(e,t=new b){const s=t,n=this.v0,i=this.v1,r=this.v2,o=this.v3;return s.set(xe(e,n.x,i.x,r.x,o.x),xe(e,n.y,i.y,r.y,o.y),xe(e,n.z,i.z,r.z,o.z)),s}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class As extends D{constructor(e=new w,t=new w){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new w){const s=t;return e===1?s.copy(this.v2):(s.copy(this.v2).sub(this.v1),s.multiplyScalar(e).add(this.v1)),s}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new w){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Tn extends D{constructor(e=new b,t=new b){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new b){const s=t;return e===1?s.copy(this.v2):(s.copy(this.v2).sub(this.v1),s.multiplyScalar(e).add(this.v1)),s}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new b){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Ts extends D{constructor(e=new w,t=new w,s=new w){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=s}getPoint(e,t=new w){const s=t,n=this.v0,i=this.v1,r=this.v2;return s.set(ye(e,n.x,i.x,r.x),ye(e,n.y,i.y,r.y)),s}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class bn extends D{constructor(e=new b,t=new b,s=new b){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=s}getPoint(e,t=new b){const s=t,n=this.v0,i=this.v1,r=this.v2;return s.set(ye(e,n.x,i.x,r.x),ye(e,n.y,i.y,r.y),ye(e,n.z,i.z,r.z)),s}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class bs extends D{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new w){const s=t,n=this.points,i=(n.length-1)*e,r=Math.floor(i),o=i-r,c=n[r===0?r:r-1],h=n[r],l=n[r>n.length-2?n.length-1:r+1],u=n[r>n.length-3?n.length-1:r+2];return s.set(Jt(o,c.x,h.x,l.x,u.x),Jt(o,c.y,h.y,l.y,u.y)),s}copy(e){super.copy(e),this.points=[];for(let t=0,s=e.points.length;t<s;t++){const n=e.points[t];this.points.push(n.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,s=this.points.length;t<s;t++){const n=this.points[t];e.points.push(n.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,s=e.points.length;t<s;t++){const n=e.points[t];this.points.push(new w().fromArray(n))}return this}}const Xt=Object.freeze(Object.defineProperty({__proto__:null,ArcCurve:ln,CatmullRomCurve3:un,CubicBezierCurve:xs,CubicBezierCurve3:An,EllipseCurve:wt,LineCurve:As,LineCurve3:Tn,QuadraticBezierCurve:Ts,QuadraticBezierCurve3:bn,SplineCurve:bs},Symbol.toStringTag,{value:"Module"}));class vn extends D{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const s=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Xt[s](t,e))}return this}getPoint(e,t){const s=e*this.getLength(),n=this.getCurveLengths();let i=0;for(;i<n.length;){if(n[i]>=s){const r=n[i]-s,o=this.curves[i],c=o.getLength(),h=c===0?0:1-r/c;return o.getPointAt(h,t)}i++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let s=0,n=this.curves.length;s<n;s++)t+=this.curves[s].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let s=0;s<=e;s++)t.push(this.getPoint(s/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let s;for(let n=0,i=this.curves;n<i.length;n++){const r=i[n],o=r.isEllipseCurve?e*2:r.isLineCurve||r.isLineCurve3?1:r.isSplineCurve?e*r.points.length:e,c=r.getPoints(o);for(let h=0;h<c.length;h++){const l=c[h];s&&s.equals(l)||(t.push(l),s=l)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,s=e.curves.length;t<s;t++){const n=e.curves[t];this.curves.push(n.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,s=this.curves.length;t<s;t++){const n=this.curves[t];e.curves.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,s=e.curves.length;t<s;t++){const n=e.curves[t];this.curves.push(new Xt[n.type]().fromJSON(n))}return this}}class qt extends vn{constructor(e){super(),this.type="Path",this.currentPoint=new w,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,s=e.length;t<s;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const s=new As(this.currentPoint.clone(),new w(e,t));return this.curves.push(s),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,s,n){const i=new Ts(this.currentPoint.clone(),new w(e,t),new w(s,n));return this.curves.push(i),this.currentPoint.set(s,n),this}bezierCurveTo(e,t,s,n,i,r){const o=new xs(this.currentPoint.clone(),new w(e,t),new w(s,n),new w(i,r));return this.curves.push(o),this.currentPoint.set(i,r),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),s=new bs(t);return this.curves.push(s),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,s,n,i,r){const o=this.currentPoint.x,c=this.currentPoint.y;return this.absarc(e+o,t+c,s,n,i,r),this}absarc(e,t,s,n,i,r){return this.absellipse(e,t,s,s,n,i,r),this}ellipse(e,t,s,n,i,r,o,c){const h=this.currentPoint.x,l=this.currentPoint.y;return this.absellipse(e+h,t+l,s,n,i,r,o,c),this}absellipse(e,t,s,n,i,r,o,c){const h=new wt(e,t,s,n,i,r,o,c);if(this.curves.length>0){const u=h.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(h);const l=h.getPoint(1);return this.currentPoint.copy(l),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class wn extends qt{constructor(e){super(e),this.uuid=ee(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let s=0,n=this.holes.length;s<n;s++)t[s]=this.holes[s].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,s=e.holes.length;t<s;t++){const n=e.holes[t];this.holes.push(n.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,s=this.holes.length;t<s;t++){const n=this.holes[t];e.holes.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,s=e.holes.length;t<s;t++){const n=e.holes[t];this.holes.push(new qt().fromJSON(n))}return this}}const _n={triangulate:function(a,e,t=2){const s=e&&e.length,n=s?e[0]*t:a.length;let i=vs(a,0,n,t,!0);const r=[];if(!i||i.next===i.prev)return r;let o,c,h,l,u,d,f;if(s&&(i=Nn(a,e,i,t)),a.length>80*t){o=h=a[0],c=l=a[1];for(let p=t;p<n;p+=t)u=a[p],d=a[p+1],u<o&&(o=u),d<c&&(c=d),u>h&&(h=u),d>l&&(l=d);f=Math.max(h-o,l-c),f=f!==0?32767/f:0}return Se(i,r,t,o,c,f,0),r}};function vs(a,e,t,s,n){let i,r;if(n===Un(a,e,t,s)>0)for(i=e;i<t;i+=s)r=Zt(i,a[i],a[i+1],r);else for(i=t-s;i>=e;i-=s)r=Zt(i,a[i],a[i+1],r);return r&&je(r,r.next)&&(Ee(r),r=r.next),r}function X(a,e){if(!a)return a;e||(e=a);let t=a,s;do if(s=!1,!t.steiner&&(je(t,t.next)||S(t.prev,t,t.next)===0)){if(Ee(t),t=e=t.prev,t===t.next)break;s=!0}else t=t.next;while(s||t!==e);return e}function Se(a,e,t,s,n,i,r){if(!a)return;!r&&i&&On(a,s,n,i);let o=a,c,h;for(;a.prev!==a.next;){if(c=a.prev,h=a.next,i?Mn(a,s,n,i):Sn(a)){e.push(c.i/t|0),e.push(a.i/t|0),e.push(h.i/t|0),Ee(a),a=h.next,o=h.next;continue}if(a=h,a===o){r?r===1?(a=En(X(a),e,t),Se(a,e,t,s,n,i,2)):r===2&&Rn(a,e,t,s,n,i):Se(X(a),e,t,s,n,i,1);break}}}function Sn(a){const e=a.prev,t=a,s=a.next;if(S(e,t,s)>=0)return!1;const n=e.x,i=t.x,r=s.x,o=e.y,c=t.y,h=s.y,l=n<i?n<r?n:r:i<r?i:r,u=o<c?o<h?o:h:c<h?c:h,d=n>i?n>r?n:r:i>r?i:r,f=o>c?o>h?o:h:c>h?c:h;let p=s.next;for(;p!==e;){if(p.x>=l&&p.x<=d&&p.y>=u&&p.y<=f&&$(n,o,i,c,r,h,p.x,p.y)&&S(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Mn(a,e,t,s){const n=a.prev,i=a,r=a.next;if(S(n,i,r)>=0)return!1;const o=n.x,c=i.x,h=r.x,l=n.y,u=i.y,d=r.y,f=o<c?o<h?o:h:c<h?c:h,p=l<u?l<d?l:d:u<d?u:d,g=o>c?o>h?o:h:c>h?c:h,m=l>u?l>d?l:d:u>d?u:d,y=ft(f,p,e,t,s),T=ft(g,m,e,t,s);let A=a.prevZ,x=a.nextZ;for(;A&&A.z>=y&&x&&x.z<=T;){if(A.x>=f&&A.x<=g&&A.y>=p&&A.y<=m&&A!==n&&A!==r&&$(o,l,c,u,h,d,A.x,A.y)&&S(A.prev,A,A.next)>=0||(A=A.prevZ,x.x>=f&&x.x<=g&&x.y>=p&&x.y<=m&&x!==n&&x!==r&&$(o,l,c,u,h,d,x.x,x.y)&&S(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;A&&A.z>=y;){if(A.x>=f&&A.x<=g&&A.y>=p&&A.y<=m&&A!==n&&A!==r&&$(o,l,c,u,h,d,A.x,A.y)&&S(A.prev,A,A.next)>=0)return!1;A=A.prevZ}for(;x&&x.z<=T;){if(x.x>=f&&x.x<=g&&x.y>=p&&x.y<=m&&x!==n&&x!==r&&$(o,l,c,u,h,d,x.x,x.y)&&S(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function En(a,e,t){let s=a;do{const n=s.prev,i=s.next.next;!je(n,i)&&ws(n,s,s.next,i)&&Me(n,i)&&Me(i,n)&&(e.push(n.i/t|0),e.push(s.i/t|0),e.push(i.i/t|0),Ee(s),Ee(s.next),s=a=i),s=s.next}while(s!==a);return X(s)}function Rn(a,e,t,s,n,i){let r=a;do{let o=r.next.next;for(;o!==r.prev;){if(r.i!==o.i&&Dn(r,o)){let c=_s(r,o);r=X(r,r.next),c=X(c,c.next),Se(r,e,t,s,n,i,0),Se(c,e,t,s,n,i,0);return}o=o.next}r=r.next}while(r!==a)}function Nn(a,e,t,s){const n=[];let i,r,o,c,h;for(i=0,r=e.length;i<r;i++)o=e[i]*s,c=i<r-1?e[i+1]*s:a.length,h=vs(a,o,c,s,!1),h===h.next&&(h.steiner=!0),n.push(Bn(h));for(n.sort(Ln),i=0;i<n.length;i++)t=In(n[i],t);return t}function Ln(a,e){return a.x-e.x}function In(a,e){const t=Cn(a,e);if(!t)return e;const s=_s(t,a);return X(s,s.next),X(t,t.next)}function Cn(a,e){let t=e,s=-1/0,n;const i=a.x,r=a.y;do{if(r<=t.y&&r>=t.next.y&&t.next.y!==t.y){const d=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=i&&d>s&&(s=d,n=t.x<t.next.x?t:t.next,d===i))return n}t=t.next}while(t!==e);if(!n)return null;const o=n,c=n.x,h=n.y;let l=1/0,u;t=n;do i>=t.x&&t.x>=c&&i!==t.x&&$(r<h?i:s,r,c,h,r<h?s:i,r,t.x,t.y)&&(u=Math.abs(r-t.y)/(i-t.x),Me(t,a)&&(u<l||u===l&&(t.x>n.x||t.x===n.x&&Pn(n,t)))&&(n=t,l=u)),t=t.next;while(t!==o);return n}function Pn(a,e){return S(a.prev,a,e.prev)<0&&S(e.next,a,a.next)<0}function On(a,e,t,s){let n=a;do n.z===0&&(n.z=ft(n.x,n.y,e,t,s)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==a);n.prevZ.nextZ=null,n.prevZ=null,kn(n)}function kn(a){let e,t,s,n,i,r,o,c,h=1;do{for(t=a,a=null,i=null,r=0;t;){for(r++,s=t,o=0,e=0;e<h&&(o++,s=s.nextZ,!!s);e++);for(c=h;o>0||c>0&&s;)o!==0&&(c===0||!s||t.z<=s.z)?(n=t,t=t.nextZ,o--):(n=s,s=s.nextZ,c--),i?i.nextZ=n:a=n,n.prevZ=i,i=n;t=s}i.nextZ=null,h*=2}while(r>1);return a}function ft(a,e,t,s,n){return a=(a-t)*n|0,e=(e-s)*n|0,a=(a|a<<8)&16711935,a=(a|a<<4)&252645135,a=(a|a<<2)&858993459,a=(a|a<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,a|e<<1}function Bn(a){let e=a,t=a;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==a);return t}function $(a,e,t,s,n,i,r,o){return(n-r)*(e-o)>=(a-r)*(i-o)&&(a-r)*(s-o)>=(t-r)*(e-o)&&(t-r)*(i-o)>=(n-r)*(s-o)}function Dn(a,e){return a.next.i!==e.i&&a.prev.i!==e.i&&!Fn(a,e)&&(Me(a,e)&&Me(e,a)&&Hn(a,e)&&(S(a.prev,a,e.prev)||S(a,e.prev,e))||je(a,e)&&S(a.prev,a,a.next)>0&&S(e.prev,e,e.next)>0)}function S(a,e,t){return(e.y-a.y)*(t.x-e.x)-(e.x-a.x)*(t.y-e.y)}function je(a,e){return a.x===e.x&&a.y===e.y}function ws(a,e,t,s){const n=Fe(S(a,e,t)),i=Fe(S(a,e,s)),r=Fe(S(t,s,a)),o=Fe(S(t,s,e));return!!(n!==i&&r!==o||n===0&&De(a,t,e)||i===0&&De(a,s,e)||r===0&&De(t,a,s)||o===0&&De(t,e,s))}function De(a,e,t){return e.x<=Math.max(a.x,t.x)&&e.x>=Math.min(a.x,t.x)&&e.y<=Math.max(a.y,t.y)&&e.y>=Math.min(a.y,t.y)}function Fe(a){return a>0?1:a<0?-1:0}function Fn(a,e){let t=a;do{if(t.i!==a.i&&t.next.i!==a.i&&t.i!==e.i&&t.next.i!==e.i&&ws(t,t.next,a,e))return!0;t=t.next}while(t!==a);return!1}function Me(a,e){return S(a.prev,a,a.next)<0?S(a,e,a.next)>=0&&S(a,a.prev,e)>=0:S(a,e,a.prev)<0||S(a,a.next,e)<0}function Hn(a,e){let t=a,s=!1;const n=(a.x+e.x)/2,i=(a.y+e.y)/2;do t.y>i!=t.next.y>i&&t.next.y!==t.y&&n<(t.next.x-t.x)*(i-t.y)/(t.next.y-t.y)+t.x&&(s=!s),t=t.next;while(t!==a);return s}function _s(a,e){const t=new pt(a.i,a.x,a.y),s=new pt(e.i,e.x,e.y),n=a.next,i=e.prev;return a.next=e,e.prev=a,t.next=n,n.prev=t,s.next=t,t.prev=s,i.next=s,s.prev=i,s}function Zt(a,e,t,s){const n=new pt(a,e,t);return s?(n.next=s.next,n.prev=s,s.next.prev=n,s.next=n):(n.prev=n,n.next=n),n}function Ee(a){a.next.prev=a.prev,a.prev.next=a.next,a.prevZ&&(a.prevZ.nextZ=a.nextZ),a.nextZ&&(a.nextZ.prevZ=a.prevZ)}function pt(a,e,t){this.i=a,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Un(a,e,t,s){let n=0;for(let i=e,r=t-s;i<t;i+=s)n+=(a[r]-a[i])*(a[i+1]+a[r+1]),r=i;return n}class Ae{static area(e){const t=e.length;let s=0;for(let n=t-1,i=0;i<t;n=i++)s+=e[n].x*e[i].y-e[i].x*e[n].y;return s*.5}static isClockWise(e){return Ae.area(e)<0}static triangulateShape(e,t){const s=[],n=[],i=[];Yt(e),Qt(s,e);let r=e.length;t.forEach(Yt);for(let c=0;c<t.length;c++)n.push(r),r+=t[c].length,Qt(s,t[c]);const o=_n.triangulate(s,n);for(let c=0;c<o.length;c+=3)i.push(o.slice(c,c+3));return i}}function Yt(a){const e=a.length;e>2&&a[e-1].equals(a[0])&&a.pop()}function Qt(a,e){for(let t=0;t<e.length;t++)a.push(e[t].x),a.push(e[t].y)}class Ss extends Ge{constructor(e=new wn([new w(0,.5),new w(-.5,-.5),new w(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const s=[],n=[],i=[],r=[];let o=0,c=0;if(Array.isArray(e)===!1)h(e);else for(let l=0;l<e.length;l++)h(e[l]),this.addGroup(o,c,l),o+=c,c=0;this.setIndex(s),this.setAttribute("position",new ge(n,3)),this.setAttribute("normal",new ge(i,3)),this.setAttribute("uv",new ge(r,2));function h(l){const u=n.length/3,d=l.extractPoints(t);let f=d.shape;const p=d.holes;Ae.isClockWise(f)===!1&&(f=f.reverse());for(let m=0,y=p.length;m<y;m++){const T=p[m];Ae.isClockWise(T)===!0&&(p[m]=T.reverse())}const g=Ae.triangulateShape(f,p);for(let m=0,y=p.length;m<y;m++){const T=p[m];f=f.concat(T)}for(let m=0,y=f.length;m<y;m++){const T=f[m];n.push(T.x,T.y,0),i.push(0,0,1),r.push(T.x,T.y)}for(let m=0,y=g.length;m<y;m++){const T=g[m],A=T[0]+u,x=T[1]+u,M=T[2]+u;s.push(A,x,M),c+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return Vn(t,e)}static fromJSON(e,t){const s=[];for(let n=0,i=e.shapes.length;n<i;n++){const r=t[e.shapes[n]];s.push(r)}return new Ss(s,e.curveSegments)}}function Vn(a,e){if(e.shapes=[],Array.isArray(a))for(let t=0,s=a.length;t<s;t++){const n=a[t];e.shapes.push(n.uuid)}else e.shapes.push(a.uuid);return e}class Re extends te{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new L(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new L(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ds,this.normalScale=new w(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ot,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class F extends Re{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new w(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return ct(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new L(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new L(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new L(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}function He(a,e,t){return!a||!t&&a.constructor===e?a:typeof e.BYTES_PER_ELEMENT=="number"?new e(a):Array.prototype.slice.call(a)}function zn(a){return ArrayBuffer.isView(a)&&!(a instanceof DataView)}function Gn(a){function e(n,i){return a[n]-a[i]}const t=a.length,s=new Array(t);for(let n=0;n!==t;++n)s[n]=n;return s.sort(e),s}function $t(a,e,t){const s=a.length,n=new a.constructor(s);for(let i=0,r=0;r!==s;++i){const o=t[i]*e;for(let c=0;c!==e;++c)n[r++]=a[o+c]}return n}function Ms(a,e,t,s){let n=1,i=a[0];for(;i!==void 0&&i[s]===void 0;)i=a[n++];if(i===void 0)return;let r=i[s];if(r!==void 0)if(Array.isArray(r))do r=i[s],r!==void 0&&(e.push(i.time),t.push.apply(t,r)),i=a[n++];while(i!==void 0);else if(r.toArray!==void 0)do r=i[s],r!==void 0&&(e.push(i.time),r.toArray(t,t.length)),i=a[n++];while(i!==void 0);else do r=i[s],r!==void 0&&(e.push(i.time),t.push(r)),i=a[n++];while(i!==void 0)}class Ne{constructor(e,t,s,n){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=n!==void 0?n:new t.constructor(s),this.sampleValues=t,this.valueSize=s,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let s=this._cachedIndex,n=t[s],i=t[s-1];s:{e:{let r;t:{n:if(!(e<n)){for(let o=s+2;;){if(n===void 0){if(e<i)break n;return s=t.length,this._cachedIndex=s,this.copySampleValue_(s-1)}if(s===o)break;if(i=n,n=t[++s],e<n)break e}r=t.length;break t}if(!(e>=i)){const o=t[1];e<o&&(s=2,i=o);for(let c=s-2;;){if(i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(s===c)break;if(n=i,i=t[--s-1],e>=i)break e}r=s,s=0;break t}break s}for(;s<r;){const o=s+r>>>1;e<t[o]?r=o:s=o+1}if(n=t[s],i=t[s-1],i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===void 0)return s=t.length,this._cachedIndex=s,this.copySampleValue_(s-1)}this._cachedIndex=s,this.intervalChanged_(s,i,n)}return this.interpolate_(s,i,e,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,n=this.valueSize,i=e*n;for(let r=0;r!==n;++r)t[r]=s[i+r];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class jn extends Ne{constructor(e,t,s,n){super(e,t,s,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Nt,endingEnd:Nt}}intervalChanged_(e,t,s){const n=this.parameterPositions;let i=e-2,r=e+1,o=n[i],c=n[r];if(o===void 0)switch(this.getSettings_().endingStart){case It:i=e,o=2*t-s;break;case Lt:i=n.length-2,o=t+n[i]-n[i+1];break;default:i=e,o=s}if(c===void 0)switch(this.getSettings_().endingEnd){case It:r=e,c=2*s-t;break;case Lt:r=1,c=s+n[1]-n[0];break;default:r=e-1,c=t}const h=(s-t)*.5,l=this.valueSize;this._weightPrev=h/(t-o),this._weightNext=h/(c-s),this._offsetPrev=i*l,this._offsetNext=r*l}interpolate_(e,t,s,n){const i=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=e*o,h=c-o,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(s-t)/(n-t),g=p*p,m=g*p,y=-d*m+2*d*g-d*p,T=(1+d)*m+(-1.5-2*d)*g+(-.5+d)*p+1,A=(-1-f)*m+(1.5+f)*g+.5*p,x=f*m-f*g;for(let M=0;M!==o;++M)i[M]=y*r[l+M]+T*r[h+M]+A*r[c+M]+x*r[u+M];return i}}class Kn extends Ne{constructor(e,t,s,n){super(e,t,s,n)}interpolate_(e,t,s,n){const i=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=e*o,h=c-o,l=(s-t)/(n-t),u=1-l;for(let d=0;d!==o;++d)i[d]=r[h+d]*u+r[c+d]*l;return i}}class Wn extends Ne{constructor(e,t,s,n){super(e,t,s,n)}interpolate_(e){return this.copySampleValue_(e-1)}}class H{constructor(e,t,s,n){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=He(t,this.TimeBufferType),this.values=He(s,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let s;if(t.toJSON!==this.toJSON)s=t.toJSON(e);else{s={name:e.name,times:He(e.times,Array),values:He(e.values,Array)};const n=e.getInterpolation();n!==e.DefaultInterpolation&&(s.interpolation=n)}return s.type=e.ValueTypeName,s}InterpolantFactoryMethodDiscrete(e){return new Wn(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Kn(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new jn(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case we:t=this.InterpolantFactoryMethodDiscrete;break;case ve:t=this.InterpolantFactoryMethodLinear;break;case Je:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const s="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(s);return console.warn("THREE.KeyframeTrack:",s),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return we;case this.InterpolantFactoryMethodLinear:return ve;case this.InterpolantFactoryMethodSmooth:return Je}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let s=0,n=t.length;s!==n;++s)t[s]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let s=0,n=t.length;s!==n;++s)t[s]*=e}return this}trim(e,t){const s=this.times,n=s.length;let i=0,r=n-1;for(;i!==n&&s[i]<e;)++i;for(;r!==-1&&s[r]>t;)--r;if(++r,i!==0||r!==n){i>=r&&(r=Math.max(r,1),i=r-1);const o=this.getValueSize();this.times=s.slice(i,r),this.values=this.values.slice(i*o,r*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const s=this.times,n=this.values,i=s.length;i===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let r=null;for(let o=0;o!==i;o++){const c=s[o];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,c),e=!1;break}if(r!==null&&r>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,c,r),e=!1;break}r=c}if(n!==void 0&&zn(n))for(let o=0,c=n.length;o!==c;++o){const h=n[o];if(isNaN(h)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,h),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),s=this.getValueSize(),n=this.getInterpolation()===Je,i=e.length-1;let r=1;for(let o=1;o<i;++o){let c=!1;const h=e[o],l=e[o+1];if(h!==l&&(o!==1||h!==e[0]))if(n)c=!0;else{const u=o*s,d=u-s,f=u+s;for(let p=0;p!==s;++p){const g=t[u+p];if(g!==t[d+p]||g!==t[f+p]){c=!0;break}}}if(c){if(o!==r){e[r]=e[o];const u=o*s,d=r*s;for(let f=0;f!==s;++f)t[d+f]=t[u+f]}++r}}if(i>0){e[r]=e[i];for(let o=i*s,c=r*s,h=0;h!==s;++h)t[c+h]=t[o+h];++r}return r!==e.length?(this.times=e.slice(0,r),this.values=t.slice(0,r*s)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),s=this.constructor,n=new s(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}H.prototype.TimeBufferType=Float32Array;H.prototype.ValueBufferType=Float32Array;H.prototype.DefaultInterpolation=ve;class oe extends H{constructor(e,t,s){super(e,t,s)}}oe.prototype.ValueTypeName="bool";oe.prototype.ValueBufferType=Array;oe.prototype.DefaultInterpolation=we;oe.prototype.InterpolantFactoryMethodLinear=void 0;oe.prototype.InterpolantFactoryMethodSmooth=void 0;class Es extends H{}Es.prototype.ValueTypeName="color";class ne extends H{}ne.prototype.ValueTypeName="number";class Jn extends Ne{constructor(e,t,s,n){super(e,t,s,n)}interpolate_(e,t,s,n){const i=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=(s-t)/(n-t);let h=e*o;for(let l=h+o;h!==l;h+=4)xt.slerpFlat(i,0,r,h-o,r,h,c);return i}}class ie extends H{InterpolantFactoryMethodLinear(e){return new Jn(this.times,this.values,this.getValueSize(),e)}}ie.prototype.ValueTypeName="quaternion";ie.prototype.InterpolantFactoryMethodSmooth=void 0;class ae extends H{constructor(e,t,s){super(e,t,s)}}ae.prototype.ValueTypeName="string";ae.prototype.ValueBufferType=Array;ae.prototype.DefaultInterpolation=we;ae.prototype.InterpolantFactoryMethodLinear=void 0;ae.prototype.InterpolantFactoryMethodSmooth=void 0;class re extends H{}re.prototype.ValueTypeName="vector";class Xn{constructor(e="",t=-1,s=[],n=Fs){this.name=e,this.tracks=s,this.duration=t,this.blendMode=n,this.uuid=ee(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],s=e.tracks,n=1/(e.fps||1);for(let r=0,o=s.length;r!==o;++r)t.push(Zn(s[r]).scale(n));const i=new this(e.name,e.duration,t,e.blendMode);return i.uuid=e.uuid,i}static toJSON(e){const t=[],s=e.tracks,n={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let i=0,r=s.length;i!==r;++i)t.push(H.toJSON(s[i]));return n}static CreateFromMorphTargetSequence(e,t,s,n){const i=t.length,r=[];for(let o=0;o<i;o++){let c=[],h=[];c.push((o+i-1)%i,o,(o+1)%i),h.push(0,1,0);const l=Gn(c);c=$t(c,1,l),h=$t(h,1,l),!n&&c[0]===0&&(c.push(i),h.push(h[0])),r.push(new ne(".morphTargetInfluences["+t[o].name+"]",c,h).scale(1/s))}return new this(e,-1,r)}static findByName(e,t){let s=e;if(!Array.isArray(e)){const n=e;s=n.geometry&&n.geometry.animations||n.animations}for(let n=0;n<s.length;n++)if(s[n].name===t)return s[n];return null}static CreateClipsFromMorphTargetSequences(e,t,s){const n={},i=/^([\w-]*?)([\d]+)$/;for(let o=0,c=e.length;o<c;o++){const h=e[o],l=h.name.match(i);if(l&&l.length>1){const u=l[1];let d=n[u];d||(n[u]=d=[]),d.push(h)}}const r=[];for(const o in n)r.push(this.CreateFromMorphTargetSequence(o,n[o],t,s));return r}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const s=function(u,d,f,p,g){if(f.length!==0){const m=[],y=[];Ms(f,m,y,p),m.length!==0&&g.push(new u(d,m,y))}},n=[],i=e.name||"default",r=e.fps||30,o=e.blendMode;let c=e.length||-1;const h=e.hierarchy||[];for(let u=0;u<h.length;u++){const d=h[u].keys;if(!(!d||d.length===0))if(d[0].morphTargets){const f={};let p;for(p=0;p<d.length;p++)if(d[p].morphTargets)for(let g=0;g<d[p].morphTargets.length;g++)f[d[p].morphTargets[g]]=-1;for(const g in f){const m=[],y=[];for(let T=0;T!==d[p].morphTargets.length;++T){const A=d[p];m.push(A.time),y.push(A.morphTarget===g?1:0)}n.push(new ne(".morphTargetInfluence["+g+"]",m,y))}c=f.length*r}else{const f=".bones["+t[u].name+"]";s(re,f+".position",d,"pos",n),s(ie,f+".quaternion",d,"rot",n),s(re,f+".scale",d,"scl",n)}}return n.length===0?null:new this(i,c,n,o)}resetDuration(){const e=this.tracks;let t=0;for(let s=0,n=e.length;s!==n;++s){const i=this.tracks[s];t=Math.max(t,i.times[i.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function qn(a){switch(a.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ne;case"vector":case"vector2":case"vector3":case"vector4":return re;case"color":return Es;case"quaternion":return ie;case"bool":case"boolean":return oe;case"string":return ae}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+a)}function Zn(a){if(a.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=qn(a.type);if(a.times===void 0){const t=[],s=[];Ms(a.keys,t,s,"value"),a.times=t,a.values=s}return e.parse!==void 0?e.parse(a):new e(a.name,a.times,a.values,a.interpolation)}const W={enabled:!1,files:{},add:function(a,e){this.enabled!==!1&&(this.files[a]=e)},get:function(a){if(this.enabled!==!1)return this.files[a]},remove:function(a){delete this.files[a]},clear:function(){this.files={}}};class Yn{constructor(e,t,s){const n=this;let i=!1,r=0,o=0,c;const h=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=s,this.itemStart=function(l){o++,i===!1&&n.onStart!==void 0&&n.onStart(l,r,o),i=!0},this.itemEnd=function(l){r++,n.onProgress!==void 0&&n.onProgress(l,r,o),r===o&&(i=!1,n.onLoad!==void 0&&n.onLoad())},this.itemError=function(l){n.onError!==void 0&&n.onError(l)},this.resolveURL=function(l){return c?c(l):l},this.setURLModifier=function(l){return c=l,this},this.addHandler=function(l,u){return h.push(l,u),this},this.removeHandler=function(l){const u=h.indexOf(l);return u!==-1&&h.splice(u,2),this},this.getHandler=function(l){for(let u=0,d=h.length;u<d;u+=2){const f=h[u],p=h[u+1];if(f.global&&(f.lastIndex=0),f.test(l))return p}return null}}}const Qn=new Yn;class ce{constructor(e){this.manager=e!==void 0?e:Qn,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const s=this;return new Promise(function(n,i){s.load(e,n,t,i)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}ce.DEFAULT_MATERIAL_NAME="__DEFAULT";const U={};class $n extends Error{constructor(e,t){super(e),this.response=t}}class Rs extends ce{constructor(e){super(e)}load(e,t,s,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const i=W.get(e);if(i!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(i),this.manager.itemEnd(e)},0),i;if(U[e]!==void 0){U[e].push({onLoad:t,onProgress:s,onError:n});return}U[e]=[],U[e].push({onLoad:t,onProgress:s,onError:n});const r=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,c=this.responseType;fetch(r).then(h=>{if(h.status===200||h.status===0){if(h.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||h.body===void 0||h.body.getReader===void 0)return h;const l=U[e],u=h.body.getReader(),d=h.headers.get("X-File-Size")||h.headers.get("Content-Length"),f=d?parseInt(d):0,p=f!==0;let g=0;const m=new ReadableStream({start(y){T();function T(){u.read().then(({done:A,value:x})=>{if(A)y.close();else{g+=x.byteLength;const M=new ProgressEvent("progress",{lengthComputable:p,loaded:g,total:f});for(let P=0,C=l.length;P<C;P++){const G=l[P];G.onProgress&&G.onProgress(M)}y.enqueue(x),T()}},A=>{y.error(A)})}}});return new Response(m)}else throw new $n(`fetch for "${h.url}" responded with ${h.status}: ${h.statusText}`,h)}).then(h=>{switch(c){case"arraybuffer":return h.arrayBuffer();case"blob":return h.blob();case"document":return h.text().then(l=>new DOMParser().parseFromString(l,o));case"json":return h.json();default:if(o===void 0)return h.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return h.arrayBuffer().then(p=>f.decode(p))}}}).then(h=>{W.add(e,h);const l=U[e];delete U[e];for(let u=0,d=l.length;u<d;u++){const f=l[u];f.onLoad&&f.onLoad(h)}}).catch(h=>{const l=U[e];if(l===void 0)throw this.manager.itemError(e),h;delete U[e];for(let u=0,d=l.length;u<d;u++){const f=l[u];f.onError&&f.onError(h)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class ei extends ce{constructor(e){super(e)}load(e,t,s,n){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const i=this,r=W.get(e);if(r!==void 0)return i.manager.itemStart(e),setTimeout(function(){t&&t(r),i.manager.itemEnd(e)},0),r;const o=Hs("img");function c(){l(),W.add(e,this),t&&t(this),i.manager.itemEnd(e)}function h(u){l(),n&&n(u),i.manager.itemError(e),i.manager.itemEnd(e)}function l(){o.removeEventListener("load",c,!1),o.removeEventListener("error",h,!1)}return o.addEventListener("load",c,!1),o.addEventListener("error",h,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),i.manager.itemStart(e),o.src=e,o}}class ti extends ce{constructor(e){super(e)}load(e,t,s,n){const i=new be,r=new ei(this.manager);return r.setCrossOrigin(this.crossOrigin),r.setPath(this.path),r.load(e,function(o){i.image=o,i.needsUpdate=!0,t!==void 0&&t(i)},s,n),i}}class Ke extends k{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new L(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}}const tt=new E,es=new b,ts=new b;class St{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new w(512,512),this.map=null,this.mapPass=null,this.matrix=new E,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Us,this._frameExtents=new w(1,1),this._viewportCount=1,this._viewports=[new B(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,s=this.matrix;es.setFromMatrixPosition(e.matrixWorld),t.position.copy(es),ts.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ts),t.updateMatrixWorld(),tt.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(tt),s.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),s.multiply(tt)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class si extends St{constructor(){super(new At(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,s=Vs*2*e.angle*this.focus,n=this.mapSize.width/this.mapSize.height,i=e.distance||t.far;(s!==t.fov||n!==t.aspect||i!==t.far)&&(t.fov=s,t.aspect=n,t.far=i,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class ni extends Ke{constructor(e,t,s=0,n=Math.PI/3,i=0,r=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(k.DEFAULT_UP),this.updateMatrix(),this.target=new k,this.distance=s,this.angle=n,this.penumbra=i,this.decay=r,this.map=null,this.shadow=new si}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const ss=new E,fe=new b,st=new b;class ii extends St{constructor(){super(new At(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new w(4,2),this._viewportCount=6,this._viewports=[new B(2,1,1,1),new B(0,1,1,1),new B(3,1,1,1),new B(1,1,1,1),new B(3,0,1,1),new B(1,0,1,1)],this._cubeDirections=[new b(1,0,0),new b(-1,0,0),new b(0,0,1),new b(0,0,-1),new b(0,1,0),new b(0,-1,0)],this._cubeUps=[new b(0,1,0),new b(0,1,0),new b(0,1,0),new b(0,1,0),new b(0,0,1),new b(0,0,-1)]}updateMatrices(e,t=0){const s=this.camera,n=this.matrix,i=e.distance||s.far;i!==s.far&&(s.far=i,s.updateProjectionMatrix()),fe.setFromMatrixPosition(e.matrixWorld),s.position.copy(fe),st.copy(s.position),st.add(this._cubeDirections[t]),s.up.copy(this._cubeUps[t]),s.lookAt(st),s.updateMatrixWorld(),n.makeTranslation(-fe.x,-fe.y,-fe.z),ss.multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ss)}}class Ns extends Ke{constructor(e,t,s=0,n=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=s,this.decay=n,this.shadow=new ii}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class ri extends St{constructor(){super(new hs(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class oi extends Ke{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(k.DEFAULT_UP),this.updateMatrix(),this.target=new k,this.shadow=new ri}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class $i extends Ke{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Te{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let s=0,n=e.length;s<n;s++)t+=String.fromCharCode(e[s]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class ai extends ce{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,s,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const i=this,r=W.get(e);if(r!==void 0){if(i.manager.itemStart(e),r.then){r.then(h=>{t&&t(h),i.manager.itemEnd(e)}).catch(h=>{n&&n(h)});return}return setTimeout(function(){t&&t(r),i.manager.itemEnd(e)},0),r}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;const c=fetch(e,o).then(function(h){return h.blob()}).then(function(h){return createImageBitmap(h,Object.assign(i.options,{colorSpaceConversion:"none"}))}).then(function(h){return W.add(e,h),t&&t(h),i.manager.itemEnd(e),h}).catch(function(h){n&&n(h),W.remove(e),i.manager.itemError(e),i.manager.itemEnd(e)});W.add(e,c),i.manager.itemStart(e)}}const Mt="\\[\\]\\.:\\/",ci=new RegExp("["+Mt+"]","g"),Et="[^"+Mt+"]",hi="[^"+Mt.replace("\\.","")+"]",li=/((?:WC+[\/:])*)/.source.replace("WC",Et),ui=/(WCOD+)?/.source.replace("WCOD",hi),di=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Et),fi=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Et),pi=new RegExp("^"+li+ui+di+fi+"$"),mi=["material","materials","bones","map"];class gi{constructor(e,t,s){const n=s||_.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,n)}getValue(e,t){this.bind();const s=this._targetGroup.nCachedObjects_,n=this._bindings[s];n!==void 0&&n.getValue(e,t)}setValue(e,t){const s=this._bindings;for(let n=this._targetGroup.nCachedObjects_,i=s.length;n!==i;++n)s[n].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,s=e.length;t!==s;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,s=e.length;t!==s;++t)e[t].unbind()}}class _{constructor(e,t,s){this.path=t,this.parsedPath=s||_.parseTrackName(t),this.node=_.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,s){return e&&e.isAnimationObjectGroup?new _.Composite(e,t,s):new _(e,t,s)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(ci,"")}static parseTrackName(e){const t=pi.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const s={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},n=s.nodeName&&s.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){const i=s.nodeName.substring(n+1);mi.indexOf(i)!==-1&&(s.nodeName=s.nodeName.substring(0,n),s.objectName=i)}if(s.propertyName===null||s.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return s}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const s=e.skeleton.getBoneByName(t);if(s!==void 0)return s}if(e.children){const s=function(i){for(let r=0;r<i.length;r++){const o=i[r];if(o.name===t||o.uuid===t)return o;const c=s(o.children);if(c)return c}return null},n=s(e.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const s=this.resolvedProperty;for(let n=0,i=s.length;n!==i;++n)e[t++]=s[n]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const s=this.resolvedProperty;for(let n=0,i=s.length;n!==i;++n)s[n]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const s=this.resolvedProperty;for(let n=0,i=s.length;n!==i;++n)s[n]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const s=this.resolvedProperty;for(let n=0,i=s.length;n!==i;++n)s[n]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,s=t.objectName,n=t.propertyName;let i=t.propertyIndex;if(e||(e=_.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(s){let h=t.objectIndex;switch(s){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let l=0;l<e.length;l++)if(e[l].name===h){h=l;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[s]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[s]}if(h!==void 0){if(e[h]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[h]}}const r=e[n];if(r===void 0){const h=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+h+"."+n+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?o=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(i!==void 0){if(n==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[i]!==void 0&&(i=e.morphTargetDictionary[i])}c=this.BindingType.ArrayElement,this.resolvedProperty=r,this.propertyIndex=i}else r.fromArray!==void 0&&r.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=r):Array.isArray(r)?(c=this.BindingType.EntireArray,this.resolvedProperty=r):this.propertyName=n;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}_.Composite=gi;_.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};_.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};_.prototype.GetterByBindingType=[_.prototype._getValue_direct,_.prototype._getValue_array,_.prototype._getValue_arrayElement,_.prototype._getValue_toArray];_.prototype.SetterByBindingTypeAndVersioning=[[_.prototype._setValue_direct,_.prototype._setValue_direct_setNeedsUpdate,_.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[_.prototype._setValue_array,_.prototype._setValue_array_setNeedsUpdate,_.prototype._setValue_array_setMatrixWorldNeedsUpdate],[_.prototype._setValue_arrayElement,_.prototype._setValue_arrayElement_setNeedsUpdate,_.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[_.prototype._setValue_fromArray,_.prototype._setValue_fromArray_setNeedsUpdate,_.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:ls}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ls);function ns(a,e){if(e===zs)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),a;if(e===ht||e===us){let t=a.getIndex();if(t===null){const r=[],o=a.getAttribute("position");if(o!==void 0){for(let c=0;c<o.count;c++)r.push(c);a.setIndex(r),t=a.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),a}const s=t.count-2,n=[];if(e===ht)for(let r=1;r<=s;r++)n.push(t.getX(0)),n.push(t.getX(r)),n.push(t.getX(r+1));else for(let r=0;r<s;r++)r%2===0?(n.push(t.getX(r)),n.push(t.getX(r+1)),n.push(t.getX(r+2))):(n.push(t.getX(r+2)),n.push(t.getX(r+1)),n.push(t.getX(r)));n.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=a.clone();return i.setIndex(n),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),a}class er extends ce{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new bi(t)}),this.register(function(t){return new vi(t)}),this.register(function(t){return new Ii(t)}),this.register(function(t){return new Ci(t)}),this.register(function(t){return new Pi(t)}),this.register(function(t){return new _i(t)}),this.register(function(t){return new Si(t)}),this.register(function(t){return new Mi(t)}),this.register(function(t){return new Ei(t)}),this.register(function(t){return new Ti(t)}),this.register(function(t){return new Ri(t)}),this.register(function(t){return new wi(t)}),this.register(function(t){return new Li(t)}),this.register(function(t){return new Ni(t)}),this.register(function(t){return new xi(t)}),this.register(function(t){return new Oi(t)}),this.register(function(t){return new ki(t)})}load(e,t,s,n){const i=this;let r;if(this.resourcePath!=="")r=this.resourcePath;else if(this.path!==""){const h=Te.extractUrlBase(e);r=Te.resolveURL(h,this.path)}else r=Te.extractUrlBase(e);this.manager.itemStart(e);const o=function(h){n?n(h):console.error(h),i.manager.itemError(e),i.manager.itemEnd(e)},c=new Rs(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(h){try{i.parse(h,r,function(l){t(l),i.manager.itemEnd(e)},o)}catch(l){o(l)}},s,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,s,n){let i;const r={},o={},c=new TextDecoder;if(typeof e=="string")i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===Ls){try{r[v.KHR_BINARY_GLTF]=new Bi(e)}catch(u){n&&n(u);return}i=JSON.parse(r[v.KHR_BINARY_GLTF].content)}else i=JSON.parse(c.decode(e));else i=e;if(i.asset===void 0||i.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const h=new qi(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});h.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){const u=this.pluginCallbacks[l](h);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),o[u.name]=u,r[u.name]=!0}if(i.extensionsUsed)for(let l=0;l<i.extensionsUsed.length;++l){const u=i.extensionsUsed[l],d=i.extensionsRequired||[];switch(u){case v.KHR_MATERIALS_UNLIT:r[u]=new Ai;break;case v.KHR_DRACO_MESH_COMPRESSION:r[u]=new Di(i,this.dracoLoader);break;case v.KHR_TEXTURE_TRANSFORM:r[u]=new Fi;break;case v.KHR_MESH_QUANTIZATION:r[u]=new Hi;break;default:d.indexOf(u)>=0&&o[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}h.setExtensions(r),h.setPlugins(o),h.parse(s,n)}parseAsync(e,t){const s=this;return new Promise(function(n,i){s.parse(e,t,n,i)})}}function yi(){let a={};return{get:function(e){return a[e]},add:function(e,t){a[e]=t},remove:function(e){delete a[e]},removeAll:function(){a={}}}}const v={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class xi{constructor(e){this.parser=e,this.name=v.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,n=t.length;s<n;s++){const i=t[s];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,s="light:"+e;let n=t.cache.get(s);if(n)return n;const i=t.json,c=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let h;const l=new L(16777215);c.color!==void 0&&l.setRGB(c.color[0],c.color[1],c.color[2],z);const u=c.range!==void 0?c.range:0;switch(c.type){case"directional":h=new oi(l),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new Ns(l),h.distance=u;break;case"spot":h=new ni(l),h.distance=u,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,h.angle=c.spot.outerConeAngle,h.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,h.target.position.set(0,0,-1),h.add(h.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return h.position.set(0,0,0),h.decay=2,V(h,c),c.intensity!==void 0&&(h.intensity=c.intensity),h.name=t.createUniqueName(c.name||"light_"+e),n=Promise.resolve(h),t.cache.add(s,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,i=s.json.nodes[e],o=(i.extensions&&i.extensions[this.name]||{}).light;return o===void 0?null:this._loadLight(o).then(function(c){return s._getNodeRef(t.cache,o,c)})}}class Ai{constructor(){this.name=v.KHR_MATERIALS_UNLIT}getMaterialType(){return Q}extendParams(e,t,s){const n=[];e.color=new L(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const r=i.baseColorFactor;e.color.setRGB(r[0],r[1],r[2],z),e.opacity=r[3]}i.baseColorTexture!==void 0&&n.push(s.assignTexture(e,"map",i.baseColorTexture,_e))}return Promise.all(n)}}class Ti{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return i!==void 0&&(t.emissiveIntensity=i),Promise.resolve()}}class bi{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:F}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];if(r.clearcoatFactor!==void 0&&(t.clearcoat=r.clearcoatFactor),r.clearcoatTexture!==void 0&&i.push(s.assignTexture(t,"clearcoatMap",r.clearcoatTexture)),r.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=r.clearcoatRoughnessFactor),r.clearcoatRoughnessTexture!==void 0&&i.push(s.assignTexture(t,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),r.clearcoatNormalTexture!==void 0&&(i.push(s.assignTexture(t,"clearcoatNormalMap",r.clearcoatNormalTexture)),r.clearcoatNormalTexture.scale!==void 0)){const o=r.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new w(o,o)}return Promise.all(i)}}class vi{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_DISPERSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:F}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.dispersion=i.dispersion!==void 0?i.dispersion:0,Promise.resolve()}}class wi{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:F}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];return r.iridescenceFactor!==void 0&&(t.iridescence=r.iridescenceFactor),r.iridescenceTexture!==void 0&&i.push(s.assignTexture(t,"iridescenceMap",r.iridescenceTexture)),r.iridescenceIor!==void 0&&(t.iridescenceIOR=r.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),r.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=r.iridescenceThicknessMinimum),r.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=r.iridescenceThicknessMaximum),r.iridescenceThicknessTexture!==void 0&&i.push(s.assignTexture(t,"iridescenceThicknessMap",r.iridescenceThicknessTexture)),Promise.all(i)}}class _i{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_SHEEN}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:F}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new L(0,0,0),t.sheenRoughness=0,t.sheen=1;const r=n.extensions[this.name];if(r.sheenColorFactor!==void 0){const o=r.sheenColorFactor;t.sheenColor.setRGB(o[0],o[1],o[2],z)}return r.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=r.sheenRoughnessFactor),r.sheenColorTexture!==void 0&&i.push(s.assignTexture(t,"sheenColorMap",r.sheenColorTexture,_e)),r.sheenRoughnessTexture!==void 0&&i.push(s.assignTexture(t,"sheenRoughnessMap",r.sheenRoughnessTexture)),Promise.all(i)}}class Si{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:F}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];return r.transmissionFactor!==void 0&&(t.transmission=r.transmissionFactor),r.transmissionTexture!==void 0&&i.push(s.assignTexture(t,"transmissionMap",r.transmissionTexture)),Promise.all(i)}}class Mi{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_VOLUME}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:F}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];t.thickness=r.thicknessFactor!==void 0?r.thicknessFactor:0,r.thicknessTexture!==void 0&&i.push(s.assignTexture(t,"thicknessMap",r.thicknessTexture)),t.attenuationDistance=r.attenuationDistance||1/0;const o=r.attenuationColor||[1,1,1];return t.attenuationColor=new L().setRGB(o[0],o[1],o[2],z),Promise.all(i)}}class Ei{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_IOR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:F}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.ior=i.ior!==void 0?i.ior:1.5,Promise.resolve()}}class Ri{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_SPECULAR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:F}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];t.specularIntensity=r.specularFactor!==void 0?r.specularFactor:1,r.specularTexture!==void 0&&i.push(s.assignTexture(t,"specularIntensityMap",r.specularTexture));const o=r.specularColorFactor||[1,1,1];return t.specularColor=new L().setRGB(o[0],o[1],o[2],z),r.specularColorTexture!==void 0&&i.push(s.assignTexture(t,"specularColorMap",r.specularColorTexture,_e)),Promise.all(i)}}class Ni{constructor(e){this.parser=e,this.name=v.EXT_MATERIALS_BUMP}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:F}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];return t.bumpScale=r.bumpFactor!==void 0?r.bumpFactor:1,r.bumpTexture!==void 0&&i.push(s.assignTexture(t,"bumpMap",r.bumpTexture)),Promise.all(i)}}class Li{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:F}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];return r.anisotropyStrength!==void 0&&(t.anisotropy=r.anisotropyStrength),r.anisotropyRotation!==void 0&&(t.anisotropyRotation=r.anisotropyRotation),r.anisotropyTexture!==void 0&&i.push(s.assignTexture(t,"anisotropyMap",r.anisotropyTexture)),Promise.all(i)}}class Ii{constructor(e){this.parser=e,this.name=v.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,n=s.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const i=n.extensions[this.name],r=t.options.ktx2Loader;if(!r){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,r)}}class Ci{constructor(e){this.parser=e,this.name=v.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,n=s.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;const r=i.extensions[t],o=n.images[r.source];let c=s.textureLoader;if(o.uri){const h=s.options.manager.getHandler(o.uri);h!==null&&(c=h)}return this.detectSupport().then(function(h){if(h)return s.loadTextureImage(e,r.source,c);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Pi{constructor(e){this.parser=e,this.name=v.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,n=s.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;const r=i.extensions[t],o=n.images[r.source];let c=s.textureLoader;if(o.uri){const h=s.options.manager.getHandler(o.uri);h!==null&&(c=h)}return this.detectSupport().then(function(h){if(h)return s.loadTextureImage(e,r.source,c);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Oi{constructor(e){this.name=v.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const n=s.extensions[this.name],i=this.parser.getDependency("buffer",n.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(o){const c=n.byteOffset||0,h=n.byteLength||0,l=n.count,u=n.byteStride,d=new Uint8Array(o,c,h);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(l,u,d,n.mode,n.filter).then(function(f){return f.buffer}):r.ready.then(function(){const f=new ArrayBuffer(l*u);return r.decodeGltfBuffer(new Uint8Array(f),l,u,d,n.mode,n.filter),f})})}else return null}}class ki{constructor(e){this.name=v.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,s=t.nodes[e];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const n=t.meshes[s.mesh];for(const h of n.primitives)if(h.mode!==O.TRIANGLES&&h.mode!==O.TRIANGLE_STRIP&&h.mode!==O.TRIANGLE_FAN&&h.mode!==void 0)return null;const r=s.extensions[this.name].attributes,o=[],c={};for(const h in r)o.push(this.parser.getDependency("accessor",r[h]).then(l=>(c[h]=l,c[h])));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then(h=>{const l=h.pop(),u=l.isGroup?l.children:[l],d=h[0].count,f=[];for(const p of u){const g=new E,m=new b,y=new xt,T=new b(1,1,1),A=new on(p.geometry,p.material,d);for(let x=0;x<d;x++)c.TRANSLATION&&m.fromBufferAttribute(c.TRANSLATION,x),c.ROTATION&&y.fromBufferAttribute(c.ROTATION,x),c.SCALE&&T.fromBufferAttribute(c.SCALE,x),A.setMatrixAt(x,g.compose(m,y,T));for(const x in c)if(x==="_COLOR_0"){const M=c[x];A.instanceColor=new ut(M.array,M.itemSize,M.normalized)}else x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"&&p.geometry.setAttribute(x,c[x]);k.prototype.copy.call(A,p),this.parser.assignFinalMaterial(A),f.push(A)}return l.isGroup?(l.clear(),l.add(...f),l):f[0]}))}}const Ls="glTF",pe=12,is={JSON:1313821514,BIN:5130562};class Bi{constructor(e){this.name=v.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,pe),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Ls)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-pe,i=new DataView(e,pe);let r=0;for(;r<n;){const o=i.getUint32(r,!0);r+=4;const c=i.getUint32(r,!0);if(r+=4,c===is.JSON){const h=new Uint8Array(e,pe+r,o);this.content=s.decode(h)}else if(c===is.BIN){const h=pe+r;this.body=e.slice(h,h+o)}r+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Di{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=v.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const s=this.json,n=this.dracoLoader,i=e.extensions[this.name].bufferView,r=e.extensions[this.name].attributes,o={},c={},h={};for(const l in r){const u=mt[l]||l.toLowerCase();o[u]=r[l]}for(const l in e.attributes){const u=mt[l]||l.toLowerCase();if(r[l]!==void 0){const d=s.accessors[e.attributes[l]],f=se[d.componentType];h[u]=f.name,c[u]=d.normalized===!0}}return t.getDependency("bufferView",i).then(function(l){return new Promise(function(u,d){n.decodeDracoFile(l,function(f){for(const p in f.attributes){const g=f.attributes[p],m=c[p];m!==void 0&&(g.normalized=m)}u(f)},o,h,z,d)})})}}class Fi{constructor(){this.name=v.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class Hi{constructor(){this.name=v.KHR_MESH_QUANTIZATION}}class Is extends Ne{constructor(e,t,s,n){super(e,t,s,n)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,n=this.valueSize,i=e*n*3+n;for(let r=0;r!==n;r++)t[r]=s[i+r];return t}interpolate_(e,t,s,n){const i=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=o*2,h=o*3,l=n-t,u=(s-t)/l,d=u*u,f=d*u,p=e*h,g=p-h,m=-2*f+3*d,y=f-d,T=1-m,A=y-d+u;for(let x=0;x!==o;x++){const M=r[g+x+o],P=r[g+x+c]*l,C=r[p+x+o],G=r[p+x]*l;i[x]=T*M+A*P+m*C+y*G}return i}}const Ui=new xt;class Vi extends Is{interpolate_(e,t,s,n){const i=super.interpolate_(e,t,s,n);return Ui.fromArray(i).normalize().toArray(i),i}}const O={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},se={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},rs={9728:at,9729:fs,9984:Ks,9985:js,9986:Gs,9987:ds},os={33071:Js,33648:Ws,10497:lt},nt={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},mt={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},K={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},zi={CUBICSPLINE:void 0,LINEAR:ve,STEP:we},it={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Gi(a){return a.DefaultMaterial===void 0&&(a.DefaultMaterial=new Re({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Zs})),a.DefaultMaterial}function J(a,e,t){for(const s in t.extensions)a[s]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=t.extensions[s])}function V(a,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(a.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function ji(a,e,t){let s=!1,n=!1,i=!1;for(let h=0,l=e.length;h<l;h++){const u=e[h];if(u.POSITION!==void 0&&(s=!0),u.NORMAL!==void 0&&(n=!0),u.COLOR_0!==void 0&&(i=!0),s&&n&&i)break}if(!s&&!n&&!i)return Promise.resolve(a);const r=[],o=[],c=[];for(let h=0,l=e.length;h<l;h++){const u=e[h];if(s){const d=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):a.attributes.position;r.push(d)}if(n){const d=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):a.attributes.normal;o.push(d)}if(i){const d=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):a.attributes.color;c.push(d)}}return Promise.all([Promise.all(r),Promise.all(o),Promise.all(c)]).then(function(h){const l=h[0],u=h[1],d=h[2];return s&&(a.morphAttributes.position=l),n&&(a.morphAttributes.normal=u),i&&(a.morphAttributes.color=d),a.morphTargetsRelative=!0,a})}function Ki(a,e){if(a.updateMorphTargets(),e.weights!==void 0)for(let t=0,s=e.weights.length;t<s;t++)a.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(a.morphTargetInfluences.length===t.length){a.morphTargetDictionary={};for(let s=0,n=t.length;s<n;s++)a.morphTargetDictionary[t[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Wi(a){let e;const t=a.extensions&&a.extensions[v.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+rt(t.attributes):e=a.indices+":"+rt(a.attributes)+":"+a.mode,a.targets!==void 0)for(let s=0,n=a.targets.length;s<n;s++)e+=":"+rt(a.targets[s]);return e}function rt(a){let e="";const t=Object.keys(a).sort();for(let s=0,n=t.length;s<n;s++)e+=t[s]+":"+a[t[s]]+";";return e}function gt(a){switch(a){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function Ji(a){return a.search(/\.jpe?g($|\?)/i)>0||a.search(/^data\:image\/jpeg/)===0?"image/jpeg":a.search(/\.webp($|\?)/i)>0||a.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Xi=new E;class qi{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new yi,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,n=!1,i=-1;typeof navigator<"u"&&(s=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,n=navigator.userAgent.indexOf("Firefox")>-1,i=n?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||s||n&&i<98?this.textureLoader=new ti(this.options.manager):this.textureLoader=new ai(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Rs(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const s=this,n=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(r){const o={scene:r[0][n.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:n.asset,parser:s,userData:{}};return J(i,o,n),V(o,n),Promise.all(s._invokeAll(function(c){return c.afterRoot&&c.afterRoot(o)})).then(function(){for(const c of o.scenes)c.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let n=0,i=t.length;n<i;n++){const r=t[n].joints;for(let o=0,c=r.length;o<c;o++)e[r[o]].isBone=!0}for(let n=0,i=e.length;n<i;n++){const r=e[n];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(s[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;const n=s.clone(),i=(r,o)=>{const c=this.associations.get(r);c!=null&&this.associations.set(o,c);for(const[h,l]of r.children.entries())i(l,o.children[h])};return i(s,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const n=e(t[s]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let n=0;n<t.length;n++){const i=e(t[n]);i&&s.push(i)}return s}getDependency(e,t){const s=e+":"+t;let n=this.cache.get(s);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(i){return i.loadNode&&i.loadNode(t)});break;case"mesh":n=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(s,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(i,r){return s.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],s=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[v.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(i,r){s.load(Te.resolveURL(t.uri,n.path),i,void 0,function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(s){const n=t.byteLength||0,i=t.byteOffset||0;return s.slice(i,i+n)})}loadAccessor(e){const t=this,s=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const r=nt[n.type],o=se[n.componentType],c=n.normalized===!0,h=new o(n.count*r);return Promise.resolve(new me(h,r,c))}const i=[];return n.bufferView!==void 0?i.push(this.getDependency("bufferView",n.bufferView)):i.push(null),n.sparse!==void 0&&(i.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(i).then(function(r){const o=r[0],c=nt[n.type],h=se[n.componentType],l=h.BYTES_PER_ELEMENT,u=l*c,d=n.byteOffset||0,f=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,p=n.normalized===!0;let g,m;if(f&&f!==u){const y=Math.floor(d/f),T="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+y+":"+n.count;let A=t.cache.get(T);A||(g=new h(o,y*f,n.count*f/l),A=new en(g,f/l),t.cache.add(T,A)),m=new Tt(A,c,d%f/l,p)}else o===null?g=new h(n.count*c):g=new h(o,d,n.count*c),m=new me(g,c,p);if(n.sparse!==void 0){const y=nt.SCALAR,T=se[n.sparse.indices.componentType],A=n.sparse.indices.byteOffset||0,x=n.sparse.values.byteOffset||0,M=new T(r[1],A,n.sparse.count*y),P=new h(r[2],x,n.sparse.count*c);o!==null&&(m=new me(m.array.slice(),m.itemSize,m.normalized));for(let C=0,G=M.length;C<G;C++){const j=M[C];if(m.setX(j,P[C*c]),c>=2&&m.setY(j,P[C*c+1]),c>=3&&m.setZ(j,P[C*c+2]),c>=4&&m.setW(j,P[C*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m})}loadTexture(e){const t=this.json,s=this.options,i=t.textures[e].source,r=t.images[i];let o=this.textureLoader;if(r.uri){const c=s.manager.getHandler(r.uri);c!==null&&(o=c)}return this.loadTextureImage(e,i,o)}loadTextureImage(e,t,s){const n=this,i=this.json,r=i.textures[e],o=i.images[t],c=(o.uri||o.bufferView)+":"+r.sampler;if(this.textureCache[c])return this.textureCache[c];const h=this.loadImageSource(t,s).then(function(l){l.flipY=!1,l.name=r.name||o.name||"",l.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(l.name=o.uri);const d=(i.samplers||{})[r.sampler]||{};return l.magFilter=rs[d.magFilter]||fs,l.minFilter=rs[d.minFilter]||ds,l.wrapS=os[d.wrapS]||lt,l.wrapT=os[d.wrapT]||lt,n.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[c]=h,h}loadImageSource(e,t){const s=this,n=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const r=n.images[e],o=self.URL||self.webkitURL;let c=r.uri||"",h=!1;if(r.bufferView!==void 0)c=s.getDependency("bufferView",r.bufferView).then(function(u){h=!0;const d=new Blob([u],{type:r.mimeType});return c=o.createObjectURL(d),c});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const l=Promise.resolve(c).then(function(u){return new Promise(function(d,f){let p=d;t.isImageBitmapLoader===!0&&(p=function(g){const m=new be(g);m.needsUpdate=!0,d(m)}),t.load(Te.resolveURL(u,i.path),p,void 0,f)})}).then(function(u){return h===!0&&o.revokeObjectURL(c),V(u,r),u.userData.mimeType=r.mimeType||Ji(r.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),u});return this.sourceCache[e]=l,l}assignTexture(e,t,s,n){const i=this;return this.getDependency("texture",s.index).then(function(r){if(!r)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(r=r.clone(),r.channel=s.texCoord),i.extensions[v.KHR_TEXTURE_TRANSFORM]){const o=s.extensions!==void 0?s.extensions[v.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const c=i.associations.get(r);r=i.extensions[v.KHR_TEXTURE_TRANSFORM].extendTexture(r,o),i.associations.set(r,c)}}return n!==void 0&&(r.colorSpace=n),e[t]=r,r})}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const n=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,r=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+s.uuid;let c=this.cache.get(o);c||(c=new ys,te.prototype.copy.call(c,s),c.color.copy(s.color),c.map=s.map,c.sizeAttenuation=!1,this.cache.add(o,c)),s=c}else if(e.isLine){const o="LineBasicMaterial:"+s.uuid;let c=this.cache.get(o);c||(c=new gs,te.prototype.copy.call(c,s),c.color.copy(s.color),c.map=s.map,this.cache.add(o,c)),s=c}if(n||i||r){let o="ClonedMaterial:"+s.uuid+":";n&&(o+="derivative-tangents:"),i&&(o+="vertex-colors:"),r&&(o+="flat-shading:");let c=this.cache.get(o);c||(c=s.clone(),i&&(c.vertexColors=!0),r&&(c.flatShading=!0),n&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(o,c),this.associations.set(c,this.associations.get(s))),s=c}e.material=s}getMaterialType(){return Re}loadMaterial(e){const t=this,s=this.json,n=this.extensions,i=s.materials[e];let r;const o={},c=i.extensions||{},h=[];if(c[v.KHR_MATERIALS_UNLIT]){const u=n[v.KHR_MATERIALS_UNLIT];r=u.getMaterialType(),h.push(u.extendParams(o,i,t))}else{const u=i.pbrMetallicRoughness||{};if(o.color=new L(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){const d=u.baseColorFactor;o.color.setRGB(d[0],d[1],d[2],z),o.opacity=d[3]}u.baseColorTexture!==void 0&&h.push(t.assignTexture(o,"map",u.baseColorTexture,_e)),o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(h.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),h.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture))),r=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),h.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,o)})))}i.doubleSided===!0&&(o.side=Xs);const l=i.alphaMode||it.OPAQUE;if(l===it.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,l===it.MASK&&(o.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&r!==Q&&(h.push(t.assignTexture(o,"normalMap",i.normalTexture)),o.normalScale=new w(1,1),i.normalTexture.scale!==void 0)){const u=i.normalTexture.scale;o.normalScale.set(u,u)}if(i.occlusionTexture!==void 0&&r!==Q&&(h.push(t.assignTexture(o,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&r!==Q){const u=i.emissiveFactor;o.emissive=new L().setRGB(u[0],u[1],u[2],z)}return i.emissiveTexture!==void 0&&r!==Q&&h.push(t.assignTexture(o,"emissiveMap",i.emissiveTexture,_e)),Promise.all(h).then(function(){const u=new r(o);return i.name&&(u.name=i.name),V(u,i),t.associations.set(u,{materials:e}),i.extensions&&J(n,u,i),u})}createUniqueName(e){const t=_.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,s=this.extensions,n=this.primitiveCache;function i(o){return s[v.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(c){return as(c,o,t)})}const r=[];for(let o=0,c=e.length;o<c;o++){const h=e[o],l=Wi(h),u=n[l];if(u)r.push(u.promise);else{let d;h.extensions&&h.extensions[v.KHR_DRACO_MESH_COMPRESSION]?d=i(h):d=as(new Ge,h,t),n[l]={primitive:h,promise:d},r.push(d)}}return Promise.all(r)}loadMesh(e){const t=this,s=this.json,n=this.extensions,i=s.meshes[e],r=i.primitives,o=[];for(let c=0,h=r.length;c<h;c++){const l=r[c].material===void 0?Gi(this.cache):this.getDependency("material",r[c].material);o.push(l)}return o.push(t.loadGeometries(r)),Promise.all(o).then(function(c){const h=c.slice(0,c.length-1),l=c[c.length-1],u=[];for(let f=0,p=l.length;f<p;f++){const g=l[f],m=r[f];let y;const T=h[f];if(m.mode===O.TRIANGLES||m.mode===O.TRIANGLE_STRIP||m.mode===O.TRIANGLE_FAN||m.mode===void 0)y=i.isSkinnedMesh===!0?new sn(g,T):new R(g,T),y.isSkinnedMesh===!0&&y.normalizeSkinWeights(),m.mode===O.TRIANGLE_STRIP?y.geometry=ns(y.geometry,us):m.mode===O.TRIANGLE_FAN&&(y.geometry=ns(y.geometry,ht));else if(m.mode===O.LINES)y=new an(g,T);else if(m.mode===O.LINE_STRIP)y=new vt(g,T);else if(m.mode===O.LINE_LOOP)y=new cn(g,T);else if(m.mode===O.POINTS)y=new hn(g,T);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(y.geometry.morphAttributes).length>0&&Ki(y,i),y.name=t.createUniqueName(i.name||"mesh_"+e),V(y,i),m.extensions&&J(n,y,m),t.assignFinalMaterial(y),u.push(y)}for(let f=0,p=u.length;f<p;f++)t.associations.set(u[f],{meshes:e,primitives:f});if(u.length===1)return i.extensions&&J(n,u[0],i),u[0];const d=new Xe;i.extensions&&J(n,d,i),t.associations.set(d,{meshes:e});for(let f=0,p=u.length;f<p;f++)d.add(u[f]);return d})}loadCamera(e){let t;const s=this.json.cameras[e],n=s[s.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?t=new At(qs.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):s.type==="orthographic"&&(t=new hs(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(t.name=this.createUniqueName(s.name)),V(t,s),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],s=[];for(let n=0,i=t.joints.length;n<i;n++)s.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",t.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(n){const i=n.pop(),r=n,o=[],c=[];for(let h=0,l=r.length;h<l;h++){const u=r[h];if(u){o.push(u);const d=new E;i!==null&&d.fromArray(i.array,h*16),c.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[h])}return new bt(o,c)})}loadAnimation(e){const t=this.json,s=this,n=t.animations[e],i=n.name?n.name:"animation_"+e,r=[],o=[],c=[],h=[],l=[];for(let u=0,d=n.channels.length;u<d;u++){const f=n.channels[u],p=n.samplers[f.sampler],g=f.target,m=g.node,y=n.parameters!==void 0?n.parameters[p.input]:p.input,T=n.parameters!==void 0?n.parameters[p.output]:p.output;g.node!==void 0&&(r.push(this.getDependency("node",m)),o.push(this.getDependency("accessor",y)),c.push(this.getDependency("accessor",T)),h.push(p),l.push(g))}return Promise.all([Promise.all(r),Promise.all(o),Promise.all(c),Promise.all(h),Promise.all(l)]).then(function(u){const d=u[0],f=u[1],p=u[2],g=u[3],m=u[4],y=[];for(let T=0,A=d.length;T<A;T++){const x=d[T],M=f[T],P=p[T],C=g[T],G=m[T];if(x===void 0)continue;x.updateMatrix&&x.updateMatrix();const j=s._createAnimationTracks(x,M,P,C,G);if(j)for(let We=0;We<j.length;We++)y.push(j[We])}return new Xn(i,void 0,y)})}createNodeMesh(e){const t=this.json,s=this,n=t.nodes[e];return n.mesh===void 0?null:s.getDependency("mesh",n.mesh).then(function(i){const r=s._getNodeRef(s.meshCache,n.mesh,i);return n.weights!==void 0&&r.traverse(function(o){if(o.isMesh)for(let c=0,h=n.weights.length;c<h;c++)o.morphTargetInfluences[c]=n.weights[c]}),r})}loadNode(e){const t=this.json,s=this,n=t.nodes[e],i=s._loadNodeShallow(e),r=[],o=n.children||[];for(let h=0,l=o.length;h<l;h++)r.push(s.getDependency("node",o[h]));const c=n.skin===void 0?Promise.resolve(null):s.getDependency("skin",n.skin);return Promise.all([i,Promise.all(r),c]).then(function(h){const l=h[0],u=h[1],d=h[2];d!==null&&l.traverse(function(f){f.isSkinnedMesh&&f.bind(d,Xi)});for(let f=0,p=u.length;f<p;f++)l.add(u[f]);return l})}_loadNodeShallow(e){const t=this.json,s=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const i=t.nodes[e],r=i.name?n.createUniqueName(i.name):"",o=[],c=n._invokeOne(function(h){return h.createNodeMesh&&h.createNodeMesh(e)});return c&&o.push(c),i.camera!==void 0&&o.push(n.getDependency("camera",i.camera).then(function(h){return n._getNodeRef(n.cameraCache,i.camera,h)})),n._invokeAll(function(h){return h.createNodeAttachment&&h.createNodeAttachment(e)}).forEach(function(h){o.push(h)}),this.nodeCache[e]=Promise.all(o).then(function(h){let l;if(i.isBone===!0?l=new ps:h.length>1?l=new Xe:h.length===1?l=h[0]:l=new k,l!==h[0])for(let u=0,d=h.length;u<d;u++)l.add(h[u]);if(i.name&&(l.userData.name=i.name,l.name=r),V(l,i),i.extensions&&J(s,l,i),i.matrix!==void 0){const u=new E;u.fromArray(i.matrix),l.applyMatrix4(u)}else i.translation!==void 0&&l.position.fromArray(i.translation),i.rotation!==void 0&&l.quaternion.fromArray(i.rotation),i.scale!==void 0&&l.scale.fromArray(i.scale);return n.associations.has(l)||n.associations.set(l,{}),n.associations.get(l).nodes=e,l}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],n=this,i=new Xe;s.name&&(i.name=n.createUniqueName(s.name)),V(i,s),s.extensions&&J(t,i,s);const r=s.nodes||[],o=[];for(let c=0,h=r.length;c<h;c++)o.push(n.getDependency("node",r[c]));return Promise.all(o).then(function(c){for(let l=0,u=c.length;l<u;l++)i.add(c[l]);const h=l=>{const u=new Map;for(const[d,f]of n.associations)(d instanceof te||d instanceof be)&&u.set(d,f);return l.traverse(d=>{const f=n.associations.get(d);f!=null&&u.set(d,f)}),u};return n.associations=h(i),i})}_createAnimationTracks(e,t,s,n,i){const r=[],o=e.name?e.name:e.uuid,c=[];K[i.path]===K.weights?e.traverse(function(d){d.morphTargetInfluences&&c.push(d.name?d.name:d.uuid)}):c.push(o);let h;switch(K[i.path]){case K.weights:h=ne;break;case K.rotation:h=ie;break;case K.position:case K.scale:h=re;break;default:s.itemSize===1?h=ne:h=re;break}const l=n.interpolation!==void 0?zi[n.interpolation]:ve,u=this._getArrayFromAccessor(s);for(let d=0,f=c.length;d<f;d++){const p=new h(c[d]+"."+K[i.path],t.array,u,l);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(p),r.push(p)}return r}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const s=gt(t.constructor),n=new Float32Array(t.length);for(let i=0,r=t.length;i<r;i++)n[i]=t[i]*s;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(s){const n=this instanceof ie?Vi:Is;return new n(this.times,this.values,this.getValueSize()/3,s)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Zi(a,e,t){const s=e.attributes,n=new ze;if(s.POSITION!==void 0){const o=t.json.accessors[s.POSITION],c=o.min,h=o.max;if(c!==void 0&&h!==void 0){if(n.set(new b(c[0],c[1],c[2]),new b(h[0],h[1],h[2])),o.normalized){const l=gt(se[o.componentType]);n.min.multiplyScalar(l),n.max.multiplyScalar(l)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=e.targets;if(i!==void 0){const o=new b,c=new b;for(let h=0,l=i.length;h<l;h++){const u=i[h];if(u.POSITION!==void 0){const d=t.json.accessors[u.POSITION],f=d.min,p=d.max;if(f!==void 0&&p!==void 0){if(c.setX(Math.max(Math.abs(f[0]),Math.abs(p[0]))),c.setY(Math.max(Math.abs(f[1]),Math.abs(p[1]))),c.setZ(Math.max(Math.abs(f[2]),Math.abs(p[2]))),d.normalized){const g=gt(se[d.componentType]);c.multiplyScalar(g)}o.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(o)}a.boundingBox=n;const r=new q;n.getCenter(r.center),r.radius=n.min.distanceTo(n.max)/2,a.boundingSphere=r}function as(a,e,t){const s=e.attributes,n=[];function i(r,o){return t.getDependency("accessor",r).then(function(c){a.setAttribute(o,c)})}for(const r in s){const o=mt[r]||r.toLowerCase();o in a.attributes||n.push(i(s[r],o))}if(e.indices!==void 0&&!a.index){const r=t.getDependency("accessor",e.indices).then(function(o){a.setIndex(o)});n.push(r)}return Ct.workingColorSpace!==z&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Ct.workingColorSpace}" not supported.`),V(a,e),Zi(a,e,t),Promise.all(n).then(function(){return e.targets!==void 0?ji(a,e.targets,t):a})}class tr extends $s{constructor(e=null){super();const t=new Ys;t.deleteAttribute("uv");const s=new Re({side:Qs}),n=new Re,i=new Ns(16777215,900,28,2);i.position.set(.418,16.199,.3),this.add(i);const r=new R(t,s);r.position.set(-.757,13.219,.717),r.scale.set(31.713,28.305,28.591),this.add(r);const o=new R(t,n);o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-.195,0),o.scale.set(2.328,7.905,4.651),this.add(o);const c=new R(t,n);c.position.set(-5.607,-.754,-.758),c.rotation.set(0,.994,0),c.scale.set(1.97,1.534,3.955),this.add(c);const h=new R(t,n);h.position.set(6.167,.857,7.803),h.rotation.set(0,.561,0),h.scale.set(3.927,6.285,3.687),this.add(h);const l=new R(t,n);l.position.set(-2.017,.018,6.124),l.rotation.set(0,.333,0),l.scale.set(2.002,4.566,2.064),this.add(l);const u=new R(t,n);u.position.set(2.291,-.756,-2.621),u.rotation.set(0,-.286,0),u.scale.set(1.546,1.552,1.496),this.add(u);const d=new R(t,n);d.position.set(-2.193,-.369,-5.547),d.rotation.set(0,.516,0),d.scale.set(3.875,3.487,2.986),this.add(d);const f=new R(t,Y(50));f.position.set(-16.116,14.37,8.208),f.scale.set(.1,2.428,2.739),this.add(f);const p=new R(t,Y(50));p.position.set(-16.109,18.021,-8.207),p.scale.set(.1,2.425,2.751),this.add(p);const g=new R(t,Y(17));g.position.set(14.904,12.198,-1.832),g.scale.set(.15,4.265,6.331),this.add(g);const m=new R(t,Y(43));m.position.set(-.462,8.89,14.52),m.scale.set(4.38,5.441,.088),this.add(m);const y=new R(t,Y(20));y.position.set(3.235,11.486,-12.541),y.scale.set(2.5,2,.1),this.add(y);const T=new R(t,Y(100));T.position.set(0,20,0),T.scale.set(1,.1,1),this.add(T)}dispose(){const e=new Set;this.traverse(t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))});for(const t of e)t.dispose()}}function Y(a){const e=new Q;return e.color.setScalar(a),e}export{$i as A,Qi as C,oi as D,er as G,F as M,tr as R,$s as S,Re as a,wn as b,Ss as c};