0x8a367d0f…028dsent to0x9c9a9c84…bf56·#25,806,610·view on Etherscan
",detail:"1080 x 1350",width:1080,height:1350,socialFrame:!0},{id:"story",label:"Story / Reel",detail:"1080 x 1920",width:1080,height:1920,socialFrame:!0},{id:"landscape",label:"Landscape post",detail:"1600 x 900",width:1600,height:900,socialFrame:!0}];var dc={caterpillar:0,pupa:1,butterfly:2},Nn=900,Fi=650;function Zo(t){return Ni.find(e=>e.id===t)??Ni[0]}function Oi(t){return t==="full-lifecycle"?18:t==="core-cycle"?12:6}var Kr=class{constructor(e,o,i){this.model=e;ae(this,"root");ae(this,"unawakenedCanvas",document.createElement("canvas"));ae(this,"dormantCanvas",document.createElement("canvas"));ae(this,"phenotypeCanvas",document.createElement("canvas"));ae(this,"proofCanvas",document.createElement("canvas"));ae(this,"unawakened");ae(this,"dormant");ae(this,"phenotype");ae(this,"transitionMs");ae(this,"sequence",null);ae(this,"stillStage",null);ae(this,"fired",new Set);this.root=document.createElement("div"),this.root.setAttribute("aria-hidden","true"),this.root.style.cssText="height:1024px;left:-12000px;pointer-events:none;position:fixed;top:0;width:1024px;z-index:-1";for(let l of[this.unawakenedCanvas,this.dormantCanvas,this.phenotypeCanvas,this.proofCanvas])l.style.cssText="height:1024px;inset:0;position:absolute;width:1024px",this.root.append(l);document.body.append(this.root),this.unawakened=Dn(this.unawakenedCanvas,e.cellCornerSize,{maxPixelRatio:1}),this.dormant=Tn(this.dormantCanvas,e.genome,e.tokenId,{background:e.palette.background,cell:e.palette.active},{maxPixelRatio:1}),this.phenotype=vn(this.phenotypeCanvas,e,void 0,o,i,{maxPixelRatio:1}),this.unawakened.stop(),this.dormant.stop(),this.phenotype.stop(),this.dormant.setLifeProfile(this.phenotype.cellLifeProfile);let u=kn(e.genome,e.tokenId,o,i);this.transitionMs=u.transitionDuration/(u.motion?.motionScale??1),jr(this.proofCanvas,qr(e))}renderStill(e,o){this.sequence=null;let i=this.stillStage!==e;return this.stillStage=e,e==="unawakened"?(this.unawakened.render(o),{canvas:this.unawakenedCanvas,label:"Unawakened"}):e==="dormant"?(this.dormant.render(o),{canvas:this.dormantCanvas,label:"Dormant"}):e==="proof"?{canvas:this.proofCanvas,label:"Ownership proof"}:(i&&this.phenotype.setStage(dc[e]),this.phenotype.render(o),{canvas:this.phenotypeCanvas,label:fc(e)})}renderSequence(e,o,i){return this.sequence!==e&&this.resetSequence(e),e==="core-cycle"?this.renderCoreCycle(o,i):this.renderFullLifecycle(o,i)}destroy(){this.unawakened.destroy(),this.dormant.destroy(),this.phenotype.destroy(),this.root.remove()}resetSequence(e){this.sequence=e,this.stillStage=null,this.fired.clear(),this.unawakened.render(0),this.dormant.render(0),this.phenotype.setStage(0),this.phenotype.setClock(0),this.phenotype.render(0)}renderCoreCycle(e,o){let i=this.transitionMs+Fi,u=[{id:"pupa",at:Nn,target:1},{id:"butterfly",at:Nn*2+i,target:2},{id:"caterpillar",at:Nn*3+i*2,target:0}],l=Nn*4+i*3,m=Ii(e,o,l);for(let a of u)m<a.at||this.fired.has(a.id)||(this.phenotype.render(a.at),this.phenotype.transitionToStage(a.target),this.phenotype.render(a.at),this.fired.add(a.id));this.phenotype.render(m);let w=m<u[0].at?"Caterpillar":m<u[1].at?"Caterpillar to pupa":m<u[2].at?"Pupa to butterfly":"Butterfly to caterpillar";return{canvas:this.phenotypeCanvas,label:w}}renderFullLifecycle(e,o){let i=this.transitionMs+Fi,u=1200,l=u+this.transitionMs,m=l+Nn,w=m+i+Nn,a=w+i+1100,s=a+this.transitionMs,c=s+1200,d=Ii(e,o,c);if(d>=u&&!this.fired.has("awakening")&&(this.unawakened.render(u),this.dormant.render(u),this.dormant.transitionTo(this.phenotype.states[0],this.transitionMs,{background:this.model.palette.background,cell:this.model.palette.active},this.phenotype.cellLifeProfile,this.unawakened.snapshot(),!0,()=>({state:this.unawakened.snapshot(),light:this.unawakened.lightSnapshot()})),this.dormant.render(u),this.fired.add("awakening")),d>=l&&!this.fired.has("caterpillar")){let h=this.dormant.finishTransition();this.phenotype.setStage(0),this.phenotype.setClock(h),this.phenotype.render(h),this.fired.add("caterpillar")}if(d>=m&&!this.fired.has("pupa")&&(this.phenotype.render(m),this.phenotype.transitionToStage(1),this.phenotype.render(m),this.fired.add("pupa")),d>=w&&!this.fired.has("butterfly")&&(this.phenotype.render(w),this.phenotype.transitionToStage(2),this.phenotype.render(w),this.fired.add("butterfly")),d>=a&&!this.fired.has("dormant")&&(this.phenotype.render(a),this.dormant.render(a),this.dormant.transitionFrom(this.phenotype.snapshot(),this.transitionMs,{background:this.model.palette.background,cell:this.model.palette.active}),this.dormant.render(a),this.fired.add("dormant")),d<u)return this.unawakened.render(d),{canvas:this.unawakenedCanvas,label:"Unawakened"};if(d<l)return this.unawakened.render(d),this.dormant.render(d),{canvas:this.dormantCanvas,label:"Unawakened to caterpillar"};if(d<a){this.phenotype.render(d);let h=d<m?"Caterpillar":d<w?"Caterpillar to pupa":"Pupa to butterfly";return{canvas:this.phenotypeCanvas,label:h}}return d<s?(this.dormant.render(d),{canvas:this.dormantCanvas,label:"Butterfly to dormant"}):(this.dormant.render(d),{canvas:this.dormantCanvas,label:"Dormant"})}};function Qo(t,e,o,i,u){t.width!==o.width&&(t.width=o.width),t.height!==o.height&&(t.height=o.height);let l=t.getContext("2d",{alpha:!1});if(!l)throw new Error("Export canvas is unavailable");if(l.setTransform(1,0,0,1,0,0),l.globalAlpha=1,l.imageSmoothingEnabled=!1,!o.socialFrame){l.fillStyle=i.palette.background,l.fillRect(0,0,o.width,o.height),l.drawImage(e,0,0,o.width,o.height);return}let m=o.width,w=o.height,a=Math.min(m,w),s=Math.round(a*.055),c=Math.round(a*.085),d=Math.round(a*.095),h=Math.floor(Math.min(m-s*2,w-s*2-c-d)),C=Math.round((m-h)/2),b=Math.round((w-h)/2-(d-c)/2);l.fillStyle="#080b0d",l.fillRect(0,0,m,w),l.fillStyle="rgba(140,149,159,.16)";let H=Math.max(18,Math.round(a*.027)),x=Math.max(1,Math.round(a*.0018));for(let T=H/2;T<w;T+=H)for(let K=H/2;K<m;K+=H)l.fillRect(K,T,x,x);l.fillStyle="#f3f4ef",l.font=`700 ${Math.round(a*.022)}px ui-monospace, SFMono-Regular, Menlo, monospace`,l.textBaseline="middle",l.fillText("MORPHOGEN / ART LAB",C,b-c*.5),l.fillStyle="#51d3c8",l.textAlign="right",l.fillText(`#${String(i.tokenId).padStart(4,"0")}`,C+h,b-c*.5),l.textAlign="left",l.strokeStyle="#283039",l.lineWidth=Math.max(1,Math.round(a*.0015)),l.strokeRect(C-1,b-1,h+2,h+2),l.fillStyle=i.palette.background,l.fillRect(C,b,h,h),l.drawImage(e,C,b,h,h);let Z=b+h+d*.48;l.fillStyle="#f3f4ef",l.font=`600 ${Math.round(a*.021)}px ui-sans-serif, system-ui, sans-serif`,l.fillText(u,C,Z),l.fillStyle="#8c959f",l.font=`500 ${Math.round(a*.015)}px ui-monospace, SFMono-Regular, Menlo, monospace`,l.textAlign="right",l.fillText(`${i.traits.wingform} / ${i.traits.rarity}`,C+h,Z),l.textAlign="left"}function Ii(t,e,o){return e<=0?0:Math.max(0,Math.min(o,t/e*o))}function fc(t){return t.charAt(0).toUpperCase()+t.slice(1)}var Fn=900,hc=650,pc=["Caterpillar","Pupa","Butterfly"],Zr=class{constructor(e,o){this.model=e;this.transition=o;ae(this,"root",document.createElement("div"));ae(this,"unawakenedCanvas",document.createElement("canvas"));ae(this,"dormantCanvas",document.createElement("canvas"));ae(this,"phenotypeCanvas",document.createElement("canvas"));ae(this,"unawakened");ae(this,"dormant");ae(this,"phenotype");ae(this,"transitionMs");ae(this,"fired",new Set);this.root.setAttribute("aria-hidden","true"),this.root.style.cssText="height:1024px;left:-12000px;pointer-events:none;position:fixed;top:0;width:1024px;z-index:-1";for(let u of[this.unawakenedCanvas,this.dormantCanvas,this.phenotypeCanvas])u.style.cssText="height:1024px;inset:0;position:absolute;width:1024px",this.root.append(u);document.body.append(this.root),this.unawakened=Dn(this.unawakenedCanvas,e.cellCornerSize,{maxPixelRatio:1}),this.dormant=Tn(this.dormantCanvas,e.genome,e.tokenId,{background:e.palette.background,cell:e.palette.active},{maxPixelRatio:1}),this.phenotype=vn(this.phenotypeCanvas,e,void 0,"morphogenesis",void 0,{maxPixelRatio:1}),this.unawakened.stop(),this.dormant.stop(),this.phenotype.stop(),this.dormant.setLifeProfile(this.phenotype.cellLifeProfile);let i=kn(e.genome,e.tokenId,"morphogenesis");this.transitionMs=i.transitionDuration/(i.motion?.motionScale??1),this.reset()}render(e,o){if(this.transition==="unawakened-to-caterpillar")return this.renderAwakening(e,o,!0);if(this.transition==="dormant-to-caterpillar")return this.renderAwakening(e,o,!1);if(this.transition==="butterfly-to-dormant")return this.renderButterflyDormant(e,o);let i=this.transition==="caterpillar-to-pupa"?0:this.transition==="pupa-to-butterfly"?1:2,u=this.transition==="caterpillar-to-pupa"?1:this.transition==="pupa-to-butterfly"?2:0,l=this.transition==="caterpillar-to-pupa"?"Caterpillar to pupa":this.transition==="pupa-to-butterfly"?"Pupa to butterfly":"Butterfly to caterpillar";return this.renderPhenotype(i,u,l,e,o)}destroy(){this.unawakened.destroy(),this.dormant.destroy(),this.phenotype.destroy(),this.root.remove()}reset(){let e=this.transition==="pupa-to-butterfly"?1:this.transition==="butterfly-to-caterpillar"||this.transition==="butterfly-to-dormant"?2:0;this.unawakened.render(0),this.dormant.render(0),this.phenotype.setStage(e),this.phenotype.setClock(0),this.phenotype.render(0)}renderPhenotype(e,o,i,u,l){let m=Fn,w=Fn*2+this.transitionMs+hc,a=Jo(u,l,w);return a>=m&&!this.fired.has("phenotype")&&(this.phenotype.setStage(e),this.phenotype.render(m),this.phenotype.transitionToStage(o),this.phenotype.render(m),this.fired.add("phenotype")),this.phenotype.render(a),{canvas:this.phenotypeCanvas,label:a<m?pc[e]:i}}renderAwakening(e,o,i){let u=Fn,l=u+this.transitionMs,m=l+Fn,w=Jo(e,o,m);if(w>=u&&!this.fired.has("awakening")&&(this.unawakened.render(u),this.dormant.render(u),this.dormant.transitionTo(this.phenotype.states[0],this.transitionMs,{background:this.model.palette.background,cell:this.model.palette.active},this.phenotype.cellLifeProfile,i?this.unawakened.snapshot():void 0,i,i?()=>({state:this.unawakened.snapshot(),light:this.unawakened.lightSnapshot()}):void 0),this.dormant.render(u),this.fired.add("awakening")),w>=l&&!this.fired.has("caterpillar")){let a=this.dormant.finishTransition();this.phenotype.setStage(0),this.phenotype.setClock(a),this.phenotype.render(a),this.fired.add("caterpillar")}return w<u?i?(this.unawakened.render(w),{canvas:this.unawakenedCanvas,label:"Unawakened"}):(this.dormant.render(w),{canvas:this.dormantCanvas,label:"Dormant"}):w<l?(i&&this.unawakened.render(w),this.dormant.render(w),{canvas:this.dormantCanvas,label:i?"Unawakened to caterpillar":"Dormant to caterpillar"}):(this.phenotype.render(w),{canvas:this.phenotypeCanvas,label:"Caterpillar"})}renderButterflyDormant(e,o){let i=Fn,u=i+this.transitionMs,l=u+Fn,m=Jo(e,o,l);return m>=i&&!this.fired.has("dormant")&&(this.phenotype.render(i),this.dormant.render(i),this.dormant.transitionFrom(this.phenotype.snapshot(),this.transitionMs,{background:this.model.palette.background,cell:this.model.palette.active}),this.dormant.render(i),this.fired.add("dormant")),m<i?(this.phenotype.render(m),{canvas:this.phenotypeCanvas,label:"Butterfly"}):(this.dormant.render(m),{canvas:this.dormantCanvas,label:m<u?"Butterfly to dormant":"Dormant"})}};function Jo(t,e,o){return e<=0?0:Math.max(0,Math.min(o,t/e*o))}var mc="phenotype-v20-checkpoint-boards",Tt=document.documentElement,nn=document.querySelector("#matrix");if(!nn)throw new Error("Canonical Morphogen artwork requires #matrix");var Qr=Rn({tokenId:Number.parseInt(Tt.dataset.token||"",10),lineageSeed:Tt.dataset.lineageSeed||qe,pupaSeed:Tt.dataset.pupaSeed||qe,finalSeed:Tt.dataset.finalSeed||qe}),Bi=Tt.dataset.mode||"current",Ui=wc(Bi==="current"&&Tt.dataset.stage?Tt.dataset.stage:Bi),On=Ui==="current"?Oo(Qr):Ui,Jr=Sc(On);if(Jr?!Ac(Qr,Jr):!Io(Qr,On))throw new RangeError(`Canonical artwork mode ${On} is unavailable`);Tt.dataset.engine=mc;Tt.dataset.artMode=On;if(On==="unawakened")In(lr),Dn(nn,3,{maxPixelRatio:2});else{let t=hi(Qr);if(!t)throw new RangeError("Canonical phenotype seed is unavailable");Jr?bc(t,Jr):gc(t,On)}function gc(t,e){if(e==="full-lifecycle"){yc(t);return}if(e==="dormant"){In(t.palette.background),Tn(nn,t.genome,t.tokenId,{background:t.palette.background,cell:t.palette.active},{maxPixelRatio:2});return}if(e==="proof"){let u=Tt.dataset.owner;if(!/^0x[0-9a-f]{40}$/i.test(u||""))throw new TypeError("Canonical owner proof requires data-owner");In(ur),jr(nn,qr(t,u.toLowerCase()));return}In(t.palette.background);let o=vn(nn,t,void 0,"morphogenesis",void 0,{maxPixelRatio:2}),i=e==="caterpillar"?0:e==="pupa"?1:e==="butterfly"?2:-1;o.setStage(i)}function yc(t){let e=new Kr(t,"morphogenesis"),o=Zo("artwork"),i=Oi("full-lifecycle")*1e3,u=performance.now();In(lr);let l=m=>{let w=Math.min(i,Math.max(0,m-u)),a=e.renderSequence("full-lifecycle",w,i);Qo(nn,a.canvas,o,t,a.label),w<i?window.requestAnimationFrame(l):e.destroy()};window.requestAnimationFrame(l)}function bc(t,e){let o=new Zr(t,e),i=Zo("artwork"),u=6e3,l=performance.now();In(e==="unawakened-to-caterpillar"?lr:t.palette.background);let m=w=>{let a=Math.min(u,Math.max(0,w-l)),s=o.render(a,u);Qo(nn,s.canvas,i,t,s.label),a<u?window.requestAnimationFrame(m):o.destroy()};window.requestAnimationFrame(m)}function wc(t){let e=t.trim().toLowerCase();return e==="metamorphosis"?"cycle":e}function Sc(t){switch(t){case"unawakened-to-caterpillar":case"dormant-to-caterpillar":case"caterpillar-to-pupa":case"pupa-to-butterfly":case"butterfly-to-caterpillar":case"butterfly-to-dormant":return t;default:return null}}function Ac(t,e){return t.lineageSeed===qe?!1:e==="unawakened-to-caterpillar"||e==="dormant-to-caterpillar"?!0:e==="caterpillar-to-pupa"?t.pupaSeed!==qe:t.finalSeed!==qe}function In(t){Tt.style.background=t,document.body&&(document.body.style.background=t),nn.style.background=t}})();