@shotstack/shotstack-studio 1.8.0 → 1.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.
@@ -1,4 +1,4 @@
1
- (function(q,Be){typeof exports=="object"&&typeof module<"u"?Be(exports,require("pixi.js"),require("howler"),require("opentype.js")):typeof define=="function"&&define.amd?define(["exports","pixi.js","howler","opentype.js"],Be):(q=typeof globalThis<"u"?globalThis:q||self,Be(q.ShotstackStudio={},q.PIXI,q.Howler,q.opentype))})(this,function(q,Be,zn,Hn){"use strict";function Oi(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}function Nn(s,e){for(var t=0;t<e.length;t++){const i=e[t];if(typeof i!="string"&&!Array.isArray(i)){for(const r in i)if(r!=="default"&&!(r in s)){const n=Object.getOwnPropertyDescriptor(i,r);n&&Object.defineProperty(s,r,n.get?n:{enumerable:!0,get:()=>i[r]})}}}return Object.freeze(Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}))}const R=Oi(Be),Un=Oi(zn),Rs=Oi(Hn);class jn{curves={};constructor(){this.initializeCurves()}initializeCurves(){this.curves={ease:[[.25,.1],[.25,1]],easeIn:[[.42,0],[1,1]],easeOut:[[0,0],[.58,1]],easeInOut:[[.42,0],[.58,1]],easeInQuad:[[.55,.085],[.68,.53]],easeInCubic:[[.55,.055],[.675,.19]],easeInQuart:[[.895,.03],[.685,.22]],easeInQuint:[[.755,.05],[.855,.06]],easeInSine:[[.47,0],[.745,.715]],easeInExpo:[[.95,.05],[.795,.035]],easeInCirc:[[.6,.04],[.98,.335]],easeInBack:[[.6,-.28],[.735,.045]],easeOutQuad:[[.25,.46],[.45,.94]],easeOutCubic:[[.215,.61],[.355,1]],easeOutQuart:[[.165,.84],[.44,1]],easeOutQuint:[[.23,1],[.32,1]],easeOutSine:[[.39,.575],[.565,1]],easeOutExpo:[[.19,1],[.22,1]],easeOutCirc:[[.075,.82],[.165,1]],easeOutBack:[[.175,.885],[.32,1.275]],easeInOutQuad:[[.455,.03],[.515,.955]],easeInOutCubic:[[.645,.045],[.355,1]],easeInOutQuart:[[.77,0],[.175,1]],easeInOutQuint:[[.86,0],[.07,1]],easeInOutSine:[[.445,.05],[.55,.95]],easeInOutExpo:[[1,0],[0,1]],easeInOutCirc:[[.785,.135],[.15,.86]],easeInOutBack:[[.68,-.55],[.265,1.55]]}}getValue(e,t,i,r){const n=this.curves[r??""]??this.curves.ease,[[o,a],[p,m]]=n,d=i+(3*o-3*p+1)*i*(1-i),l=e,c=e+(t-e)*a,u=e+(t-e)*m,h=t,f=d,b=1-f;return b**3*l+3*b**2*f*c+3*b*f**2*u+f**3*h}}class ke{property;length;cubicBuilder;constructor(e,t,i=0){this.property=this.createKeyframes(e,t,i),this.length=t,this.cubicBuilder=new jn}getValue(e){const t=this.property.find(r=>e>=r.start&&e<r.start+r.length);if(!t){if(this.property.length>0){if(e>=this.length)return this.property[this.property.length-1].to;if(e<0)return this.property[0].from}return 1}const i=(e-t.start)/t.length;switch(t.interpolation){case"bezier":return this.cubicBuilder.getValue(t.from,t.to,i,t.easing);case"constant":return t.from;case"linear":default:return t.from+(t.to-t.from)*i}}createKeyframes(e,t,i=0){if(typeof e=="number")return[{start:0,length:t,from:e,to:e}];if(!e.length)throw new Error("Keyframes should have at least one value.");const r=this.createNormalizedKeyframes(e);try{this.validateKeyframes(r)}catch(n){console.warn("Keyframe configuration issues detected:",n)}return this.insertFillerKeyframes(r,t,i)}createNormalizedKeyframes(e){return e.toSorted((t,i)=>t.start-i.start).map(t=>({...t,start:t.start*1e3,length:t.length*1e3}))}validateKeyframes(e){for(let t=0;t<e.length;t+=1){const i=e[t],r=e[t+1];if(!r){if(i.start+i.length>this.length)throw new Error("Last keyframe exceeds the maximum duration.");break}if(i.start+i.length>r.start)throw new Error("Overlapping keyframes detected.")}}insertFillerKeyframes(e,t,i=0){const r=[];for(let n=0;n<e.length;n+=1){const o=e[n],a=e[n+1];if(n===0&&o.start!==0){const d={start:0,length:o.start,from:i,to:o.from};r.push(d)}if(r.push(o),!a){if(o.start+o.length<t){const l=o.start+o.length,c={start:l,length:t-l,from:o.to,to:o.to};r.push(c)}break}if(o.start+o.length!==a.start){const d={start:o.start+o.length,length:a.start,from:o.to,to:a.from};r.push(d)}}return r}}class zt{static Name="AudioLoadParser";id;name;extension;validAudioExtensions;constructor(){this.id=zt.Name,this.name=zt.Name,this.extension={type:[R.ExtensionType.LoadParser],priority:R.LoaderParserPriority.Normal,ref:null},this.validAudioExtensions=["mp3","mpeg","ogg","wav"]}test(e){const t=e.split("?")[0]?.split(".").pop()??"";return this.validAudioExtensions.includes(t)}async load(e,t,i){return new Promise(r=>{const n={src:e},o=new Howl(n);o.on("load",()=>r(o)),o.on("loaderror",()=>r(null))})}unload(e){e?.unload()}}class Vn{clipConfiguration;constructor(e){this.clipConfiguration=e}build(e,t){const i=[],r=[],n=[],o=[],a=[],{effect:p,length:m}=this.clipConfiguration;if(!p)return{offsetXKeyframes:i,offsetYKeyframes:r,opacityKeyframes:n,scaleKeyframes:o,rotationKeyframes:a};const d=0;switch(this.getPresetName()){case"zoomIn":{const c=this.getZoomSpeed(),u=1*this.clipConfiguration.scale,h=c*this.clipConfiguration.scale;o.push({from:u,to:h,start:d,length:m,interpolation:"linear"});break}case"zoomOut":{const u=this.getZoomSpeed()*this.clipConfiguration.scale,h=1*this.clipConfiguration.scale;o.push({from:u,to:h,start:d,length:m,interpolation:"linear"});break}case"slideLeft":{let c=this.getSlideStart();const u=e.width+e.width*c*2,h=t.height/t.width*e.height;if(h<u){const f=Math.abs(u/e.width);o.push({from:f,to:f,start:d,length:m,interpolation:"linear"})}else c=(h-e.width)/2/e.width;i.push({from:c,to:-c,start:d,length:m});break}case"slideRight":{let c=this.getSlideStart();const u=e.width+e.width*c*2,h=t.height/t.width*e.height;if(h<u){const f=Math.abs(u/e.width);o.push({from:f,to:f,start:d,length:m,interpolation:"linear"})}else c=(h-e.width)/2/e.width;i.push({from:-c,to:c,start:d,length:m});break}case"slideUp":{let c=this.getSlideStart();const u=e.height+e.height*c*2,h=t.height/t.width*e.width;if(h<u){const f=Math.abs(u/e.height);o.push({from:f,to:f,start:d,length:m,interpolation:"linear"})}else c=(h-e.height)/2/e.height;r.push({from:c,to:-c,start:d,length:m});break}case"slideDown":{let c=this.getSlideStart();const u=e.height+e.height*c*2,h=t.height/t.width*e.width;if(h<u){const f=Math.abs(u/e.height);o.push({from:f,to:f,start:d,length:m,interpolation:"linear"})}else c=(h-e.height)/2/e.height;r.push({from:-c,to:c,start:d,length:m});break}}return{offsetXKeyframes:i,offsetYKeyframes:r,opacityKeyframes:n,scaleKeyframes:o,rotationKeyframes:a}}getPresetName(){const[e]=(this.clipConfiguration.effect??"").split(/(Slow|Fast)/);return e}getZoomSpeed(){const[e,t]=(this.clipConfiguration.effect??"").split(/(Slow|Fast)/);if(e.startsWith("zoom"))switch(t){case"Slow":return 1.1;case"Fast":return 1.7;default:return 1.3}return 0}getSlideStart(){const[e,t]=(this.clipConfiguration.effect??"").split(/(Slow|Fast)/);if(e.startsWith("slide"))switch(t){case"Slow":return .03;case"Fast":return 1.7;default:return .12}return 0}}class Wn{clipConfiguration;constructor(e){this.clipConfiguration=e}build(){const e=[],t=[],i=[],r=[],n=[],o=this.buildInPreset();e.push(...o.offsetXKeyframes),t.push(...o.offsetYKeyframes),i.push(...o.opacityKeyframes),r.push(...o.scaleKeyframes),n.push(...o.rotationKeyframes);const a=this.buildOutPreset();return e.push(...a.offsetXKeyframes),t.push(...a.offsetYKeyframes),i.push(...a.opacityKeyframes),r.push(...a.scaleKeyframes),n.push(...a.rotationKeyframes),{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:i,scaleKeyframes:r,rotationKeyframes:n}}buildInPreset(){const e=[],t=[],i=[],r=[],n=[];if(!this.clipConfiguration.transition?.in)return{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:i,scaleKeyframes:r,rotationKeyframes:n};const o=0,a=this.getInPresetLength();switch(this.getInPresetName()){case"fade":{const d=Math.max(0,Math.min(this.clipConfiguration.opacity??1,1));i.push({from:0,to:d,start:o,length:a,interpolation:"linear"});break}case"zoom":{const d=this.clipConfiguration.scale+9,l=this.clipConfiguration.scale;r.push({from:d,to:l,start:o,length:a,interpolation:"bezier",easing:"easeIn"}),i.push({from:0,to:1,start:o,length:a,interpolation:"bezier",easing:"easeIn"});break}case"slideLeft":{const m=this.clipConfiguration.offset?.x+.025,d=this.clipConfiguration.offset?.x;e.push({from:m,to:d,start:o,length:a,interpolation:"bezier",easing:"easeIn"}),i.push({from:0,to:1,start:o,length:a,interpolation:"bezier",easing:"easeIn"});break}case"slideRight":{const m=this.clipConfiguration.offset?.x-.025,d=this.clipConfiguration.offset?.x;e.push({from:m,to:d,start:o,length:a,interpolation:"bezier",easing:"easeIn"}),i.push({from:0,to:1,start:o,length:a,interpolation:"bezier",easing:"easeIn"});break}case"slideUp":{const m=this.clipConfiguration.offset?.y+.025,d=this.clipConfiguration.offset?.y;t.push({from:m,to:d,start:o,length:a,interpolation:"bezier",easing:"easeIn"}),i.push({from:0,to:1,start:o,length:a,interpolation:"bezier",easing:"easeIn"});break}case"slideDown":{const m=this.clipConfiguration.offset?.y-.025,d=this.clipConfiguration.offset?.y;t.push({from:m,to:d,start:o,length:a,interpolation:"bezier",easing:"easeOut"}),i.push({from:0,to:1,start:o,length:a,interpolation:"bezier",easing:"easeOut"});break}case"carouselLeft":case"carouselRight":case"carouselUp":case"carouselDown":case"shuffleTopRight":case"shuffleRightTop":case"shuffleRightBottom":case"shuffleBottomRight":case"shuffleBottomLeft":case"shuffleLeftBottom":case"shuffleLeftTop":case"shuffleTopLeft":default:console.warn(`Unimplemented transition:in preset "${this.clipConfiguration.transition.in}"`);break}return{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:i,scaleKeyframes:r,rotationKeyframes:n}}buildOutPreset(){const e=[],t=[],i=[],r=[],n=[];if(!this.clipConfiguration.transition?.out)return{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:i,scaleKeyframes:r,rotationKeyframes:n};const o=this.getOutPresetLength(),a=this.clipConfiguration.length-o;switch(this.getOutPresetName()){case"fade":{const m=Math.max(0,Math.min(this.clipConfiguration.opacity??1,1));i.push({from:m,to:0,start:a,length:o,interpolation:"linear"});break}case"zoom":{const d=this.clipConfiguration.scale,l=d+9;r.push({from:d,to:l,start:a,length:o,interpolation:"bezier",easing:"easeOut"}),i.push({from:1,to:0,start:a,length:o,interpolation:"bezier",easing:"easeOut"});break}case"slideLeft":{const m=this.clipConfiguration.offset?.x,d=m-.025;e.push({from:m,to:d,start:a,length:o,interpolation:"bezier",easing:"easeOut"}),i.push({from:1,to:0,start:a,length:o,interpolation:"bezier",easing:"easeOut"});break}case"slideRight":{const m=this.clipConfiguration.offset?.x,d=m+.025;e.push({from:m,to:d,start:a,length:o,interpolation:"bezier",easing:"easeOut"}),i.push({from:1,to:0,start:a,length:o,interpolation:"bezier",easing:"easeOut"});break}case"slideUp":{const m=this.clipConfiguration.offset?.y,d=m-.025;t.push({from:m,to:d,start:a,length:o,interpolation:"bezier",easing:"easeIn"}),i.push({from:1,to:0,start:a,length:o,interpolation:"bezier",easing:"easeIn"});break}case"slideDown":{const m=this.clipConfiguration.offset?.y,d=m+.025;t.push({from:m,to:d,start:a,length:o,interpolation:"bezier",easing:"easeIn"}),i.push({from:1,to:0,start:a,length:o,interpolation:"bezier",easing:"easeIn"});break}case"carouselLeft":case"carouselRight":case"carouselUp":case"carouselDown":case"shuffleTopRight":case"shuffleRightTop":case"shuffleRightBottom":case"shuffleBottomRight":case"shuffleBottomLeft":case"shuffleLeftBottom":case"shuffleLeftTop":case"shuffleTopLeft":default:console.warn(`Unimplemented transition:out preset "${this.clipConfiguration.transition.out}"`);break}return{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:i,scaleKeyframes:r,rotationKeyframes:n}}getInPresetName(){const[e]=(this.clipConfiguration.transition?.in??"").split(/(Slow|Fast|VeryFast)/);return e}getOutPresetName(){const[e]=(this.clipConfiguration.transition?.out??"").split(/(Slow|Fast|VeryFast)/);return e}getInPresetLength(){const[,e]=(this.clipConfiguration.transition?.in??"").split(/(Slow|Fast|VeryFast)/);switch(e){case"Slow":return 2;case"Fast":return .5;case"VeryFast":return .25;default:return 1}}getOutPresetLength(){const[,e]=(this.clipConfiguration.transition?.out??"").split(/(Slow|Fast|VeryFast)/);switch(e){case"Slow":return 2;case"Fast":return .5;case"VeryFast":return .25;default:return 1}}}class Gn{static ButtonLeftClick=0;static ButtonRightClick=3}class Zn{containerSize;constructor(e){this.containerSize=e}relativeToAbsolute(e,t,i){switch(t){case"topLeft":return{x:i.x*this.containerSize.width,y:-i.y*this.containerSize.height};case"topRight":return{x:(i.x+1)*this.containerSize.width-e.width,y:-i.y*this.containerSize.height};case"bottomLeft":return{x:i.x*this.containerSize.width,y:(-i.y+1)*this.containerSize.height-e.height};case"bottomRight":return{x:(i.x+1)*this.containerSize.width-e.width,y:(-i.y+1)*this.containerSize.height-e.height};case"left":return{x:i.x*this.containerSize.width,y:(-i.y+.5)*this.containerSize.height-e.height/2};case"right":return{x:(i.x+1)*this.containerSize.width-e.width,y:(-i.y+.5)*this.containerSize.height-e.height/2};case"top":return{x:(i.x+.5)*this.containerSize.width-e.width/2,y:-i.y*this.containerSize.height};case"bottom":return{x:(i.x+.5)*this.containerSize.width-e.width/2,y:(-i.y+1)*this.containerSize.height-e.height};case"center":default:return{x:(i.x+.5)*this.containerSize.width-e.width/2,y:(-i.y+.5)*this.containerSize.height-e.height/2}}}absoluteToRelative(e,t,i){switch(t){case"topLeft":return{x:i.x/this.containerSize.width,y:-(i.y/this.containerSize.height)};case"topRight":return{x:(i.x+e.width)/this.containerSize.width-1,y:-(i.y/this.containerSize.height)};case"bottomLeft":return{x:i.x/this.containerSize.width,y:-((i.y+e.height)/this.containerSize.height-1)};case"bottomRight":return{x:(i.x+e.width)/this.containerSize.width-1,y:-((i.y+e.height)/this.containerSize.height-1)};case"left":return{x:i.x/this.containerSize.width,y:-((i.y+e.height/2)/this.containerSize.height-.5)};case"right":return{x:(i.x+e.width)/this.containerSize.width-1,y:-((i.y+e.height/2)/this.containerSize.height-.5)};case"top":return{x:(i.x+e.width/2)/this.containerSize.width-.5,y:-(i.y/this.containerSize.height)};case"bottom":return{x:(i.x+e.width/2)/this.containerSize.width-.5,y:-((i.y+e.height)/this.containerSize.height-1)};case"center":default:return{x:(i.x+e.width/2)/this.containerSize.width-.5,y:-((i.y+e.height/2)/this.containerSize.height-.5)}}}}class Je{container;constructor(){this.container=new R.Container}getContainer(){return this.container}}class we extends Je{static SnapThreshold=20;static DiscardedFrameCount=Math.ceil(1/30*1e3);static ScaleHandleRadius=10;static RotationHandleRadius=10;static RotationHandleOffset=50;static OutlineWidth=5;static MinScale=.1;static MaxScale=5;layer;shouldDispose;edit;clipConfiguration;positionBuilder;offsetXKeyframeBuilder;offsetYKeyframeBuilder;scaleKeyframeBuilder;opacityKeyframeBuilder;rotationKeyframeBuilder;outline;topLeftScaleHandle;topRightScaleHandle;bottomLeftScaleHandle;bottomRightScaleHandle;rotationHandle;isHovering;isDragging;dragOffset;scaleDirection;scaleStart;scaleOffset;isRotating;rotationStart;rotationOffset;initialClipConfiguration;contentContainer;constructor(e,t){super(),this.edit=e,this.layer=0,this.shouldDispose=!1,this.clipConfiguration=t,this.positionBuilder=new Zn(e.size),this.outline=null,this.topLeftScaleHandle=null,this.topRightScaleHandle=null,this.bottomRightScaleHandle=null,this.bottomLeftScaleHandle=null,this.rotationHandle=null,this.isHovering=!1,this.isDragging=!1,this.dragOffset={x:0,y:0},this.scaleDirection=null,this.scaleStart=null,this.scaleOffset={x:0,y:0},this.isRotating=!1,this.rotationStart=null,this.rotationOffset={x:0,y:0},this.initialClipConfiguration=null,this.contentContainer=new R.Container,this.getContainer().addChild(this.contentContainer)}reconfigureAfterRestore(){this.configureKeyframes()}configureKeyframes(){if(this.offsetXKeyframeBuilder=new ke(this.clipConfiguration.offset?.x??0,this.getLength()),this.offsetYKeyframeBuilder=new ke(this.clipConfiguration.offset?.y??0,this.getLength()),this.scaleKeyframeBuilder=new ke(this.clipConfiguration.scale??1,this.getLength(),1),this.opacityKeyframeBuilder=new ke(this.clipConfiguration.opacity??1,this.getLength(),1),this.rotationKeyframeBuilder=new ke(this.clipConfiguration.transform?.rotate?.angle??0,this.getLength()),this.clipHasKeyframes())return;const e=[],t=[],i=[],r=[],n=[],o=new Vn(this.clipConfiguration).build(this.edit.size,this.getSize());e.push(...o.offsetXKeyframes),t.push(...o.offsetYKeyframes),i.push(...o.opacityKeyframes),r.push(...o.scaleKeyframes),n.push(...o.rotationKeyframes);const a=new Wn(this.clipConfiguration).build();e.push(...a.offsetXKeyframes),t.push(...a.offsetYKeyframes),i.push(...a.opacityKeyframes),r.push(...a.scaleKeyframes),n.push(...a.rotationKeyframes),e.length&&(this.offsetXKeyframeBuilder=new ke(e,this.getLength())),t.length&&(this.offsetYKeyframeBuilder=new ke(t,this.getLength())),i.length&&(this.opacityKeyframeBuilder=new ke(i,this.getLength(),1)),r.length&&(this.scaleKeyframeBuilder=new ke(r,this.getLength(),1)),n.length&&(this.rotationKeyframeBuilder=new ke(n,this.getLength()))}async load(){this.outline=new R.Graphics,this.getContainer().addChild(this.outline),this.topLeftScaleHandle=new R.Graphics,this.topRightScaleHandle=new R.Graphics,this.bottomRightScaleHandle=new R.Graphics,this.bottomLeftScaleHandle=new R.Graphics,this.rotationHandle=new R.Graphics,this.topLeftScaleHandle.zIndex=1e3,this.topRightScaleHandle.zIndex=1e3,this.bottomRightScaleHandle.zIndex=1e3,this.bottomLeftScaleHandle.zIndex=1e3,this.rotationHandle.zIndex=1e3,this.getContainer().addChild(this.topLeftScaleHandle),this.getContainer().addChild(this.topRightScaleHandle),this.getContainer().addChild(this.bottomRightScaleHandle),this.getContainer().addChild(this.bottomLeftScaleHandle),this.getContainer().addChild(this.rotationHandle),this.getContainer().sortableChildren=!0,this.getContainer().cursor="pointer",this.getContainer().eventMode="static",this.getContainer().on("pointerdown",this.onPointerStart.bind(this)),this.getContainer().on("pointermove",this.onPointerMove.bind(this)),this.getContainer().on("globalpointermove",this.onPointerMove.bind(this)),this.getContainer().on("pointerup",this.onPointerUp.bind(this)),this.getContainer().on("pointerupoutside",this.onPointerUp.bind(this)),this.getContainer().on("pointerover",this.onPointerOver.bind(this)),this.getContainer().on("pointerout",this.onPointerOut.bind(this))}update(e,t){if(this.getContainer().visible=this.isActive(),this.getContainer().zIndex=1e5-this.layer*100,!this.isActive())return;const i=this.getPivot(),r=this.getPosition(),n=this.getContainerScale();this.getContainer().scale.set(n.x,n.y),this.getContainer().pivot.set(i.x,i.y),this.getContainer().position.set(r.x+i.x,r.y+i.y);const o=this.getRotation();this.contentContainer.alpha=this.getOpacity(),this.getContainer().angle=o,this.clipConfiguration.width&&this.clipConfiguration.height&&this.applyFixedDimensions(),this.shouldDiscardFrame()&&(this.contentContainer.alpha=0)}draw(){if(!this.outline)return;const e=this.edit.isPlayerSelected(this),t=this.edit.isInExportMode();if((!this.isActive()||!e)&&!this.isHovering||t){this.outline.clear(),this.topLeftScaleHandle?.clear(),this.topRightScaleHandle?.clear(),this.bottomRightScaleHandle?.clear(),this.bottomLeftScaleHandle?.clear(),this.rotationHandle?.clear();return}const i=this.isHovering||this.isDragging?65535:16777215,r=this.getSize(),n=this.getScale();if(this.outline.clear(),this.outline.strokeStyle={width:we.OutlineWidth/n,color:i},this.outline.rect(0,0,r.width,r.height),this.outline.stroke(),!this.topLeftScaleHandle||!this.topRightScaleHandle||!this.bottomRightScaleHandle||!this.bottomLeftScaleHandle||!this.isActive()||!e)return;this.topLeftScaleHandle.fillStyle={color:i},this.topLeftScaleHandle.clear();const o=we.ScaleHandleRadius*2/n;if(this.topLeftScaleHandle.rect(-o/2,-o/2,o,o),this.topLeftScaleHandle.fill(),this.topRightScaleHandle.fillStyle={color:i},this.topRightScaleHandle.clear(),this.topRightScaleHandle.rect(r.width-o/2,-o/2,o,o),this.topRightScaleHandle.fill(),this.bottomRightScaleHandle.fillStyle={color:i},this.bottomRightScaleHandle.clear(),this.bottomRightScaleHandle.rect(r.width-o/2,r.height-o/2,o,o),this.bottomRightScaleHandle.fill(),this.bottomLeftScaleHandle.fillStyle={color:i},this.bottomLeftScaleHandle.clear(),this.bottomLeftScaleHandle.rect(-o/2,r.height-o/2,o,o),this.bottomLeftScaleHandle.fill(),!this.rotationHandle)return;const a=r.width/2,p=-50/n;this.rotationHandle.clear(),this.rotationHandle.fillStyle={color:i},this.rotationHandle.circle(a,p,we.RotationHandleRadius/n),this.rotationHandle.fill(),this.outline.strokeStyle={width:we.OutlineWidth/n,color:i},this.outline.moveTo(a,0),this.outline.lineTo(a,p),this.outline.stroke()}dispose(){this.outline?.destroy(),this.outline=null,this.topLeftScaleHandle?.destroy(),this.topLeftScaleHandle=null,this.topRightScaleHandle?.destroy(),this.topRightScaleHandle=null,this.bottomLeftScaleHandle?.destroy(),this.bottomLeftScaleHandle=null,this.bottomRightScaleHandle?.destroy(),this.bottomRightScaleHandle=null,this.rotationHandle?.destroy(),this.rotationHandle=null,this.contentContainer?.destroy()}getStart(){return this.clipConfiguration.start*1e3}getLength(){return this.clipConfiguration.length*1e3}getEnd(){return this.getStart()+this.getLength()}getPlaybackTime(){const e=this.edit.playbackTime-this.getStart();return e<0?0:e>this.getLength()?this.getLength():e}getOpacity(){return this.opacityKeyframeBuilder?.getValue(this.getPlaybackTime())??1}getPosition(){const e={x:this.offsetXKeyframeBuilder?.getValue(this.getPlaybackTime())??0,y:this.offsetYKeyframeBuilder?.getValue(this.getPlaybackTime())??0};return this.positionBuilder.relativeToAbsolute(this.getSize(),this.clipConfiguration.position??"center",e)}getPivot(){const e=this.getSize();return{x:e.width/2,y:e.height/2}}getFitScale(){if(this.clipConfiguration.width&&this.clipConfiguration.height)return 1;switch(this.clipConfiguration.fit??"crop"){case"crop":{const e=this.edit.size.width/this.getSize().width,t=this.edit.size.height/this.getSize().height;return this.edit.size.height>=this.edit.size.width?t:e}case"cover":return Math.max(this.edit.size.width/this.getSize().width,this.edit.size.height/this.getSize().height);case"contain":return Math.min(this.edit.size.width/this.getSize().width,this.edit.size.height/this.getSize().height);case"none":default:return 1}}getScale(){return(this.scaleKeyframeBuilder?.getValue(this.getPlaybackTime())??1)*this.getFitScale()}getContainerScale(){if(this.clipConfiguration.width&&this.clipConfiguration.height)return{x:1,y:1};const e=this.scaleKeyframeBuilder?.getValue(this.getPlaybackTime())??1,t=this.getSize(),i=this.clipConfiguration.fit??"crop";if(t.width===0||t.height===0)return{x:e,y:e};const r=this.edit.size.width/t.width,n=this.edit.size.height/t.height;switch(i){case"contain":{const o=Math.min(r,n)*e;return{x:o,y:o}}case"crop":{const a=(this.edit.size.height>=this.edit.size.width?n:r)*e;return{x:a,y:a}}case"cover":return{x:r*e,y:n*e};case"none":default:return{x:e,y:e}}}getRotation(){return this.rotationKeyframeBuilder?.getValue(this.getPlaybackTime())??0}isActive(){return this.edit.playbackTime>=this.getStart()&&this.edit.playbackTime<this.getEnd()}shouldDiscardFrame(){return this.getPlaybackTime()<we.DiscardedFrameCount}onPointerStart(e){if(e.button!==Gn.ButtonLeftClick||(this.edit.events.emit("canvas:clip:clicked",{player:this}),this.initialClipConfiguration=structuredClone(this.clipConfiguration),this.clipHasKeyframes()))return;if(this.scaleDirection=null,this.topLeftScaleHandle?.getBounds().containsPoint(e.globalX,e.globalY)&&(this.scaleDirection="topLeft"),this.topRightScaleHandle?.getBounds().containsPoint(e.globalX,e.globalY)&&(this.scaleDirection="topRight"),this.bottomRightScaleHandle?.getBounds().containsPoint(e.globalX,e.globalY)&&(this.scaleDirection="bottomRight"),this.bottomLeftScaleHandle?.getBounds().containsPoint(e.globalX,e.globalY)&&(this.scaleDirection="bottomLeft"),this.scaleDirection!==null){this.scaleStart=this.getScale()/this.getFitScale();const p=e.getLocalPosition(this.edit.getContainer());this.scaleOffset=p;return}if(this.rotationHandle?.getBounds().containsPoint(e.globalX,e.globalY)){this.isRotating=!0,this.rotationStart=this.getRotation();const p=e.getLocalPosition(this.edit.getContainer());this.rotationOffset=p;return}this.isDragging=!0;const a=e.getLocalPosition(this.edit.getContainer());this.dragOffset={x:a.x-this.getContainer().position.x,y:a.y-this.getContainer().position.y}}onPointerMove(e){if(this.scaleDirection!==null&&this.scaleStart!==null){const t=e.getLocalPosition(this.edit.getContainer()),i=this.getPosition(),r=this.getPivot(),n={x:i.x+r.x,y:i.y+r.y},o=Math.sqrt((this.scaleOffset.x-n.x)**2+(this.scaleOffset.y-n.y)**2),p=Math.sqrt((t.x-n.x)**2+(t.y-n.y)**2)/o,m=this.scaleStart*p;this.clipConfiguration.scale=Math.max(we.MinScale,Math.min(m,we.MaxScale)),this.scaleKeyframeBuilder=new ke(this.clipConfiguration.scale,this.getLength(),1);return}if(this.isRotating&&this.rotationStart!==null){const t=e.getLocalPosition(this.edit.getContainer()),i=this.getPosition(),r=this.getPivot(),n={x:i.x+r.x,y:i.y+r.y},o=Math.atan2(this.rotationOffset.y-n.y,this.rotationOffset.x-n.x),p=(Math.atan2(t.y-n.y,t.x-n.x)-o)*(180/Math.PI);let m=this.rotationStart+p;const d=45,l=m%d,c=2;Math.abs(l)<c?m=Math.floor(m/d)*d:Math.abs(l-d)<c&&(m=Math.ceil(m/d)*d),this.clipConfiguration.transform||(this.clipConfiguration.transform={rotate:{angle:0}}),this.clipConfiguration.transform.rotate||(this.clipConfiguration.transform.rotate={angle:0}),this.clipConfiguration.transform.rotate.angle=m,this.rotationKeyframeBuilder=new ke(this.clipConfiguration.transform.rotate.angle,this.getLength());return}if(this.isDragging){const t=e.getLocalPosition(this.edit.getContainer()),i=this.getPivot(),r={x:t.x-this.dragOffset.x,y:t.y-this.dragOffset.y},n={x:r.x-i.x,y:r.y-i.y},o=[{x:0,y:0},{x:this.edit.size.width,y:0},{x:0,y:this.edit.size.height},{x:this.edit.size.width,y:this.edit.size.height}],a={x:this.edit.size.width/2,y:this.edit.size.height/2},p=[...o,a],m=[{x:n.x,y:n.y},{x:n.x+this.getSize().width,y:n.y},{x:n.x,y:n.y+this.getSize().height},{x:n.x+this.getSize().width,y:n.y+this.getSize().height}],d={x:n.x+this.getSize().width/2,y:n.y+this.getSize().height/2},l=[...m,d];let c=we.SnapThreshold,u=we.SnapThreshold,h=null,f=null;for(const g of l)for(const y of p){const v=Math.abs(g.x-y.x);v<c&&(c=v,h=n.x+(y.x-g.x));const _=Math.abs(g.y-y.y);_<u&&(u=_,f=n.y+(y.y-g.y))}h!==null&&(n.x=h),f!==null&&(n.y=f);const b=this.positionBuilder.absoluteToRelative(this.getSize(),this.clipConfiguration.position??"center",n);this.clipConfiguration.offset||(this.clipConfiguration.offset={x:0,y:0}),this.clipConfiguration.offset.x=b.x,this.clipConfiguration.offset.y=b.y,this.offsetXKeyframeBuilder=new ke(this.clipConfiguration.offset.x,this.getLength()),this.offsetYKeyframeBuilder=new ke(this.clipConfiguration.offset.y,this.getLength())}}onPointerUp(){(this.isDragging||this.scaleDirection!==null||this.isRotating)&&this.hasStateChanged()&&this.edit.setUpdatedClip(this,this.initialClipConfiguration,structuredClone(this.clipConfiguration)),this.isDragging=!1,this.dragOffset={x:0,y:0},this.scaleDirection=null,this.scaleStart=null,this.scaleOffset={x:0,y:0},this.isRotating=!1,this.rotationStart=null,this.rotationOffset={x:0,y:0},this.initialClipConfiguration=null}onPointerOver(){this.isHovering=!0}onPointerOut(){this.isHovering=!1}clipHasPresets(){return!!this.clipConfiguration.effect||!!this.clipConfiguration.transition?.in||!!this.clipConfiguration.transition?.out}clipHasKeyframes(){return[this.clipConfiguration.scale,this.clipConfiguration.offset?.x,this.clipConfiguration.offset?.y,this.clipConfiguration.transform?.rotate?.angle].some(e=>e&&typeof e!="number")}hasStateChanged(){if(!this.initialClipConfiguration)return!1;const e=this.clipConfiguration.offset?.x,t=this.clipConfiguration.offset?.y,i=this.clipConfiguration.scale,r=Number(this.clipConfiguration.transform?.rotate?.angle??0),n=this.initialClipConfiguration.offset?.x,o=this.initialClipConfiguration.offset?.y,a=this.initialClipConfiguration.scale,p=Number(this.initialClipConfiguration.transform?.rotate?.angle??0);return n!==void 0&&e!==n||o!==void 0&&t!==o||a!==void 0&&i!==a||r!==p}applyFixedDimensions(){const e=this.clipConfiguration.width,t=this.clipConfiguration.height;if(!e||!t)return;const i=this.contentContainer.children[0];if(!i||!i.texture)return;const r=i.texture.width,n=i.texture.height,o=this.clipConfiguration.fit||"crop";if(!this.contentContainer.mask){const p=new R.Graphics;p.rect(0,0,e,t),p.fill(16777215),this.contentContainer.addChild(p),this.contentContainer.mask=p}const a=this.scaleKeyframeBuilder?.getValue(this.getPlaybackTime())??1;switch(i.anchor.set(.5,.5),o){case"cover":{const p=e/r,m=t/n;i.scale.set(p,m),i.position.set(e/2,t/2);break}case"crop":{const p=this.edit.size.width,m=this.edit.size.height;let d=1;(r>p||n>m)&&(d=Math.min(p/r,m/n));const l=r*d,c=n*d,u=Math.max(e/l,t/c),h=d<1?d*u:Math.max(1,u);i.scale.set(h,h),i.anchor.set(.5,.5),i.position.set(e/2,t/2);break}case"contain":{const p=e/r,m=t/n,d=Math.min(p,m);i.scale.set(d,d),i.position.set(e/2,t/2);break}case"none":default:{i.scale.set(1,1),i.position.set(e/2,t/2);break}}this.contentContainer.scale.set(a,a),this.contentContainer.position.set(e/2*(1-a),t/2*(1-a))}applyAnchorPositioning(e,t,i,r){const n=r.width,o=r.height;if(!!r.mask){r.position.set(0,0);return}const p=(e??"center").toLowerCase();let m=0,d=0;p.includes("left")||p==="left"?m=0:p.includes("right")||p==="right"?m=t-n:m=(t-n)/2,p.includes("top")||p==="top"?d=0:p.includes("bottom")||p==="bottom"?d=i-o:d=(i-o)/2,r.position.set(m,d)}}class Os extends we{audioResource;isPlaying;volumeKeyframeBuilder;syncTimer;constructor(e,t){super(e,t),this.audioResource=null,this.isPlaying=!1;const i=t.asset;this.volumeKeyframeBuilder=new ke(i.volume??1,this.getLength()),this.syncTimer=0}async load(){await super.load();const e=this.clipConfiguration.asset,t=e.src,i={src:t,loadParser:zt.Name},r=await this.edit.assetLoader.load(t,i);if(!(r instanceof Un.Howl))throw new Error(`Invalid audio source '${e.src}'.`);this.audioResource=r,this.configureKeyframes()}update(e,t){super.update(e,t);const{trim:i=0}=this.clipConfiguration.asset;if(this.syncTimer+=t,this.getContainer().alpha=0,!this.audioResource)return;const r=this.edit.isPlaying&&this.isActive(),n=this.getPlaybackTime();r&&(this.isPlaying||(this.isPlaying=!0,this.audioResource.seek(n/1e3+i),this.audioResource.play()),this.audioResource.volume()!==this.getVolume()&&this.audioResource.volume(this.getVolume()),Math.abs((this.audioResource.seek()-i)*1e3-n)>100&&this.audioResource.seek(n/1e3+i)),this.isPlaying&&!r&&(this.isPlaying=!1,this.audioResource.pause());const o=this.syncTimer>100;!this.edit.isPlaying&&this.isActive()&&o&&(this.syncTimer=0,this.audioResource.seek(n/1e3+i))}draw(){super.draw()}dispose(){this.audioResource?.unload(),this.audioResource=null}getSize(){return{width:0,height:0}}getVolume(){return this.volumeKeyframeBuilder.getValue(this.getPlaybackTime())}}var Kn=`in vec2 aPosition;
1
+ (function(ve,Vt){typeof exports=="object"&&typeof module<"u"?Vt(exports,require("pixi.js"),require("howler"),require("opentype.js")):typeof define=="function"&&define.amd?define(["exports","pixi.js","howler","opentype.js"],Vt):(ve=typeof globalThis<"u"?globalThis:ve||self,Vt(ve.ShotstackStudio={},ve.PIXI,ve.Howler,ve.opentype))})(this,function(ve,Vt,lh,ch){"use strict";var hr=typeof document<"u"?document.currentScript:null;function ea(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const U=ea(Vt),uh=ea(lh),Zo=ea(ch);class hh{curves={};constructor(){this.initializeCurves()}initializeCurves(){this.curves={ease:[[.25,.1],[.25,1]],easeIn:[[.42,0],[1,1]],easeOut:[[0,0],[.58,1]],easeInOut:[[.42,0],[.58,1]],easeInQuad:[[.55,.085],[.68,.53]],easeInCubic:[[.55,.055],[.675,.19]],easeInQuart:[[.895,.03],[.685,.22]],easeInQuint:[[.755,.05],[.855,.06]],easeInSine:[[.47,0],[.745,.715]],easeInExpo:[[.95,.05],[.795,.035]],easeInCirc:[[.6,.04],[.98,.335]],easeInBack:[[.6,-.28],[.735,.045]],easeOutQuad:[[.25,.46],[.45,.94]],easeOutCubic:[[.215,.61],[.355,1]],easeOutQuart:[[.165,.84],[.44,1]],easeOutQuint:[[.23,1],[.32,1]],easeOutSine:[[.39,.575],[.565,1]],easeOutExpo:[[.19,1],[.22,1]],easeOutCirc:[[.075,.82],[.165,1]],easeOutBack:[[.175,.885],[.32,1.275]],easeInOutQuad:[[.455,.03],[.515,.955]],easeInOutCubic:[[.645,.045],[.355,1]],easeInOutQuart:[[.77,0],[.175,1]],easeInOutQuint:[[.86,0],[.07,1]],easeInOutSine:[[.445,.05],[.55,.95]],easeInOutExpo:[[1,0],[0,1]],easeInOutCirc:[[.785,.135],[.15,.86]],easeInOutBack:[[.68,-.55],[.265,1.55]]}}getValue(e,t,r,i){const n=this.curves[i??""]??this.curves.ease,[[a,o],[c,u]]=n,h=r+(3*a-3*c+1)*r*(1-r),l=e,d=e+(t-e)*o,f=e+(t-e)*u,p=t,m=h,v=1-m;return v**3*l+3*v**2*m*d+3*v*m**2*f+m**3*p}}class gt{property;length;cubicBuilder;constructor(e,t,r=0){this.property=this.createKeyframes(e,t,r),this.length=t,this.cubicBuilder=new hh}getValue(e){const t=this.property.find(i=>e>=i.start&&e<i.start+i.length);if(!t){if(this.property.length>0){if(e>=this.length)return this.property[this.property.length-1].to;if(e<0)return this.property[0].from}return 1}const r=(e-t.start)/t.length;switch(t.interpolation){case"bezier":return this.cubicBuilder.getValue(t.from,t.to,r,t.easing);case"constant":return t.from;case"linear":default:return t.from+(t.to-t.from)*r}}createKeyframes(e,t,r=0){if(typeof e=="number")return[{start:0,length:t,from:e,to:e}];if(!e.length)throw new Error("Keyframes should have at least one value.");const i=this.createNormalizedKeyframes(e);try{this.validateKeyframes(i)}catch(n){console.warn("Keyframe configuration issues detected:",n)}return this.insertFillerKeyframes(i,t,r)}createNormalizedKeyframes(e){return e.toSorted((t,r)=>t.start-r.start).map(t=>({...t,start:t.start*1e3,length:t.length*1e3}))}validateKeyframes(e){for(let t=0;t<e.length;t+=1){const r=e[t],i=e[t+1];if(!i){if(r.start+r.length>this.length)throw new Error("Last keyframe exceeds the maximum duration.");break}if(r.start+r.length>i.start)throw new Error("Overlapping keyframes detected.")}}insertFillerKeyframes(e,t,r=0){const i=[];for(let n=0;n<e.length;n+=1){const a=e[n],o=e[n+1];if(n===0&&a.start!==0){const h={start:0,length:a.start,from:r,to:a.from};i.push(h)}if(i.push(a),!o){if(a.start+a.length<t){const l=a.start+a.length,d={start:l,length:t-l,from:a.to,to:a.to};i.push(d)}break}if(a.start+a.length!==o.start){const h={start:a.start+a.length,length:o.start,from:a.to,to:o.from};i.push(h)}}return i}}class Wi{static Name="AudioLoadParser";id;name;extension;validAudioExtensions;constructor(){this.id=Wi.Name,this.name=Wi.Name,this.extension={type:[U.ExtensionType.LoadParser],priority:U.LoaderParserPriority.Normal,ref:null},this.validAudioExtensions=["mp3","mpeg","ogg","wav"]}test(e){const t=e.split("?")[0]?.split(".").pop()??"";return this.validAudioExtensions.includes(t)}async load(e,t,r){return new Promise(i=>{const n={src:e},a=new Howl(n);a.on("load",()=>i(a)),a.on("loaderror",()=>i(null))})}unload(e){e?.unload()}}class dh{clipConfiguration;constructor(e){this.clipConfiguration=e}build(e,t){const r=[],i=[],n=[],a=[],o=[],{effect:c,length:u}=this.clipConfiguration;if(!c)return{offsetXKeyframes:r,offsetYKeyframes:i,opacityKeyframes:n,scaleKeyframes:a,rotationKeyframes:o};const h=0;switch(this.getPresetName()){case"zoomIn":{const d=this.getZoomSpeed(),f=1*this.clipConfiguration.scale,p=d*this.clipConfiguration.scale;a.push({from:f,to:p,start:h,length:u,interpolation:"linear"});break}case"zoomOut":{const f=this.getZoomSpeed()*this.clipConfiguration.scale,p=1*this.clipConfiguration.scale;a.push({from:f,to:p,start:h,length:u,interpolation:"linear"});break}case"slideLeft":{let d=this.getSlideStart();const f=e.width+e.width*d*2,p=t.height/t.width*e.height;if(p<f){const m=Math.abs(f/e.width);a.push({from:m,to:m,start:h,length:u,interpolation:"linear"})}else d=(p-e.width)/2/e.width;r.push({from:d,to:-d,start:h,length:u});break}case"slideRight":{let d=this.getSlideStart();const f=e.width+e.width*d*2,p=t.height/t.width*e.height;if(p<f){const m=Math.abs(f/e.width);a.push({from:m,to:m,start:h,length:u,interpolation:"linear"})}else d=(p-e.width)/2/e.width;r.push({from:-d,to:d,start:h,length:u});break}case"slideUp":{let d=this.getSlideStart();const f=e.height+e.height*d*2,p=t.height/t.width*e.width;if(p<f){const m=Math.abs(f/e.height);a.push({from:m,to:m,start:h,length:u,interpolation:"linear"})}else d=(p-e.height)/2/e.height;i.push({from:d,to:-d,start:h,length:u});break}case"slideDown":{let d=this.getSlideStart();const f=e.height+e.height*d*2,p=t.height/t.width*e.width;if(p<f){const m=Math.abs(f/e.height);a.push({from:m,to:m,start:h,length:u,interpolation:"linear"})}else d=(p-e.height)/2/e.height;i.push({from:-d,to:d,start:h,length:u});break}}return{offsetXKeyframes:r,offsetYKeyframes:i,opacityKeyframes:n,scaleKeyframes:a,rotationKeyframes:o}}getPresetName(){const[e]=(this.clipConfiguration.effect??"").split(/(Slow|Fast)/);return e}getZoomSpeed(){const[e,t]=(this.clipConfiguration.effect??"").split(/(Slow|Fast)/);if(e.startsWith("zoom"))switch(t){case"Slow":return 1.1;case"Fast":return 1.7;default:return 1.3}return 0}getSlideStart(){const[e,t]=(this.clipConfiguration.effect??"").split(/(Slow|Fast)/);if(e.startsWith("slide"))switch(t){case"Slow":return .03;case"Fast":return 1.7;default:return .12}return 0}}class fh{clipConfiguration;constructor(e){this.clipConfiguration=e}build(){const e=[],t=[],r=[],i=[],n=[],a=this.buildInPreset();e.push(...a.offsetXKeyframes),t.push(...a.offsetYKeyframes),r.push(...a.opacityKeyframes),i.push(...a.scaleKeyframes),n.push(...a.rotationKeyframes);const o=this.buildOutPreset();return e.push(...o.offsetXKeyframes),t.push(...o.offsetYKeyframes),r.push(...o.opacityKeyframes),i.push(...o.scaleKeyframes),n.push(...o.rotationKeyframes),{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:r,scaleKeyframes:i,rotationKeyframes:n}}buildInPreset(){const e=[],t=[],r=[],i=[],n=[];if(!this.clipConfiguration.transition?.in)return{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:r,scaleKeyframes:i,rotationKeyframes:n};const a=0,o=this.getInPresetLength();switch(this.getInPresetName()){case"fade":{const h=Math.max(0,Math.min(this.clipConfiguration.opacity??1,1));r.push({from:0,to:h,start:a,length:o,interpolation:"linear"});break}case"zoom":{const h=this.clipConfiguration.scale+9,l=this.clipConfiguration.scale;i.push({from:h,to:l,start:a,length:o,interpolation:"bezier",easing:"easeIn"}),r.push({from:0,to:1,start:a,length:o,interpolation:"bezier",easing:"easeIn"});break}case"slideLeft":{const u=this.clipConfiguration.offset?.x+.025,h=this.clipConfiguration.offset?.x;e.push({from:u,to:h,start:a,length:o,interpolation:"bezier",easing:"easeIn"}),r.push({from:0,to:1,start:a,length:o,interpolation:"bezier",easing:"easeIn"});break}case"slideRight":{const u=this.clipConfiguration.offset?.x-.025,h=this.clipConfiguration.offset?.x;e.push({from:u,to:h,start:a,length:o,interpolation:"bezier",easing:"easeIn"}),r.push({from:0,to:1,start:a,length:o,interpolation:"bezier",easing:"easeIn"});break}case"slideUp":{const u=this.clipConfiguration.offset?.y+.025,h=this.clipConfiguration.offset?.y;t.push({from:u,to:h,start:a,length:o,interpolation:"bezier",easing:"easeIn"}),r.push({from:0,to:1,start:a,length:o,interpolation:"bezier",easing:"easeIn"});break}case"slideDown":{const u=this.clipConfiguration.offset?.y-.025,h=this.clipConfiguration.offset?.y;t.push({from:u,to:h,start:a,length:o,interpolation:"bezier",easing:"easeOut"}),r.push({from:0,to:1,start:a,length:o,interpolation:"bezier",easing:"easeOut"});break}case"carouselLeft":case"carouselRight":case"carouselUp":case"carouselDown":case"shuffleTopRight":case"shuffleRightTop":case"shuffleRightBottom":case"shuffleBottomRight":case"shuffleBottomLeft":case"shuffleLeftBottom":case"shuffleLeftTop":case"shuffleTopLeft":default:console.warn(`Unimplemented transition:in preset "${this.clipConfiguration.transition.in}"`);break}return{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:r,scaleKeyframes:i,rotationKeyframes:n}}buildOutPreset(){const e=[],t=[],r=[],i=[],n=[];if(!this.clipConfiguration.transition?.out)return{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:r,scaleKeyframes:i,rotationKeyframes:n};const a=this.getOutPresetLength(),o=this.clipConfiguration.length-a;switch(this.getOutPresetName()){case"fade":{const u=Math.max(0,Math.min(this.clipConfiguration.opacity??1,1));r.push({from:u,to:0,start:o,length:a,interpolation:"linear"});break}case"zoom":{const h=this.clipConfiguration.scale,l=h+9;i.push({from:h,to:l,start:o,length:a,interpolation:"bezier",easing:"easeOut"}),r.push({from:1,to:0,start:o,length:a,interpolation:"bezier",easing:"easeOut"});break}case"slideLeft":{const u=this.clipConfiguration.offset?.x,h=u-.025;e.push({from:u,to:h,start:o,length:a,interpolation:"bezier",easing:"easeOut"}),r.push({from:1,to:0,start:o,length:a,interpolation:"bezier",easing:"easeOut"});break}case"slideRight":{const u=this.clipConfiguration.offset?.x,h=u+.025;e.push({from:u,to:h,start:o,length:a,interpolation:"bezier",easing:"easeOut"}),r.push({from:1,to:0,start:o,length:a,interpolation:"bezier",easing:"easeOut"});break}case"slideUp":{const u=this.clipConfiguration.offset?.y,h=u-.025;t.push({from:u,to:h,start:o,length:a,interpolation:"bezier",easing:"easeIn"}),r.push({from:1,to:0,start:o,length:a,interpolation:"bezier",easing:"easeIn"});break}case"slideDown":{const u=this.clipConfiguration.offset?.y,h=u+.025;t.push({from:u,to:h,start:o,length:a,interpolation:"bezier",easing:"easeIn"}),r.push({from:1,to:0,start:o,length:a,interpolation:"bezier",easing:"easeIn"});break}case"carouselLeft":case"carouselRight":case"carouselUp":case"carouselDown":case"shuffleTopRight":case"shuffleRightTop":case"shuffleRightBottom":case"shuffleBottomRight":case"shuffleBottomLeft":case"shuffleLeftBottom":case"shuffleLeftTop":case"shuffleTopLeft":default:console.warn(`Unimplemented transition:out preset "${this.clipConfiguration.transition.out}"`);break}return{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:r,scaleKeyframes:i,rotationKeyframes:n}}getInPresetName(){const[e]=(this.clipConfiguration.transition?.in??"").split(/(Slow|Fast|VeryFast)/);return e}getOutPresetName(){const[e]=(this.clipConfiguration.transition?.out??"").split(/(Slow|Fast|VeryFast)/);return e}getInPresetLength(){const[,e]=(this.clipConfiguration.transition?.in??"").split(/(Slow|Fast|VeryFast)/);switch(e){case"Slow":return 2;case"Fast":return .5;case"VeryFast":return .25;default:return 1}}getOutPresetLength(){const[,e]=(this.clipConfiguration.transition?.out??"").split(/(Slow|Fast|VeryFast)/);switch(e){case"Slow":return 2;case"Fast":return .5;case"VeryFast":return .25;default:return 1}}}let ph=class{static ButtonLeftClick=0;static ButtonRightClick=3};class mh{containerSize;constructor(e){this.containerSize=e}relativeToAbsolute(e,t,r){switch(t){case"topLeft":return{x:r.x*this.containerSize.width,y:-r.y*this.containerSize.height};case"topRight":return{x:(r.x+1)*this.containerSize.width-e.width,y:-r.y*this.containerSize.height};case"bottomLeft":return{x:r.x*this.containerSize.width,y:(-r.y+1)*this.containerSize.height-e.height};case"bottomRight":return{x:(r.x+1)*this.containerSize.width-e.width,y:(-r.y+1)*this.containerSize.height-e.height};case"left":return{x:r.x*this.containerSize.width,y:(-r.y+.5)*this.containerSize.height-e.height/2};case"right":return{x:(r.x+1)*this.containerSize.width-e.width,y:(-r.y+.5)*this.containerSize.height-e.height/2};case"top":return{x:(r.x+.5)*this.containerSize.width-e.width/2,y:-r.y*this.containerSize.height};case"bottom":return{x:(r.x+.5)*this.containerSize.width-e.width/2,y:(-r.y+1)*this.containerSize.height-e.height};case"center":default:return{x:(r.x+.5)*this.containerSize.width-e.width/2,y:(-r.y+.5)*this.containerSize.height-e.height/2}}}absoluteToRelative(e,t,r){switch(t){case"topLeft":return{x:r.x/this.containerSize.width,y:-(r.y/this.containerSize.height)};case"topRight":return{x:(r.x+e.width)/this.containerSize.width-1,y:-(r.y/this.containerSize.height)};case"bottomLeft":return{x:r.x/this.containerSize.width,y:-((r.y+e.height)/this.containerSize.height-1)};case"bottomRight":return{x:(r.x+e.width)/this.containerSize.width-1,y:-((r.y+e.height)/this.containerSize.height-1)};case"left":return{x:r.x/this.containerSize.width,y:-((r.y+e.height/2)/this.containerSize.height-.5)};case"right":return{x:(r.x+e.width)/this.containerSize.width-1,y:-((r.y+e.height/2)/this.containerSize.height-.5)};case"top":return{x:(r.x+e.width/2)/this.containerSize.width-.5,y:-(r.y/this.containerSize.height)};case"bottom":return{x:(r.x+e.width/2)/this.containerSize.width-.5,y:-((r.y+e.height)/this.containerSize.height-1)};case"center":default:return{x:(r.x+e.width/2)/this.containerSize.width-.5,y:-((r.y+e.height/2)/this.containerSize.height-.5)}}}}class xr{container;constructor(){this.container=new U.Container}getContainer(){return this.container}}class ut extends xr{static SnapThreshold=20;static DiscardedFrameCount=Math.ceil(1/30*1e3);static ScaleHandleRadius=10;static RotationHandleRadius=10;static RotationHandleOffset=50;static OutlineWidth=5;static MinScale=.1;static MaxScale=5;layer;shouldDispose;edit;clipConfiguration;positionBuilder;offsetXKeyframeBuilder;offsetYKeyframeBuilder;scaleKeyframeBuilder;opacityKeyframeBuilder;rotationKeyframeBuilder;outline;topLeftScaleHandle;topRightScaleHandle;bottomLeftScaleHandle;bottomRightScaleHandle;rotationHandle;isHovering;isDragging;dragOffset;scaleDirection;scaleStart;scaleOffset;isRotating;rotationStart;rotationOffset;initialClipConfiguration;contentContainer;constructor(e,t){super(),this.edit=e,this.layer=0,this.shouldDispose=!1,this.clipConfiguration=t,this.positionBuilder=new mh(e.size),this.outline=null,this.topLeftScaleHandle=null,this.topRightScaleHandle=null,this.bottomRightScaleHandle=null,this.bottomLeftScaleHandle=null,this.rotationHandle=null,this.isHovering=!1,this.isDragging=!1,this.dragOffset={x:0,y:0},this.scaleDirection=null,this.scaleStart=null,this.scaleOffset={x:0,y:0},this.isRotating=!1,this.rotationStart=null,this.rotationOffset={x:0,y:0},this.initialClipConfiguration=null,this.contentContainer=new U.Container,this.getContainer().addChild(this.contentContainer)}reconfigureAfterRestore(){this.configureKeyframes()}configureKeyframes(){if(this.offsetXKeyframeBuilder=new gt(this.clipConfiguration.offset?.x??0,this.getLength()),this.offsetYKeyframeBuilder=new gt(this.clipConfiguration.offset?.y??0,this.getLength()),this.scaleKeyframeBuilder=new gt(this.clipConfiguration.scale??1,this.getLength(),1),this.opacityKeyframeBuilder=new gt(this.clipConfiguration.opacity??1,this.getLength(),1),this.rotationKeyframeBuilder=new gt(this.clipConfiguration.transform?.rotate?.angle??0,this.getLength()),this.clipHasKeyframes())return;const e=[],t=[],r=[],i=[],n=[],a=new dh(this.clipConfiguration).build(this.edit.size,this.getSize());e.push(...a.offsetXKeyframes),t.push(...a.offsetYKeyframes),r.push(...a.opacityKeyframes),i.push(...a.scaleKeyframes),n.push(...a.rotationKeyframes);const o=new fh(this.clipConfiguration).build();e.push(...o.offsetXKeyframes),t.push(...o.offsetYKeyframes),r.push(...o.opacityKeyframes),i.push(...o.scaleKeyframes),n.push(...o.rotationKeyframes),e.length&&(this.offsetXKeyframeBuilder=new gt(e,this.getLength())),t.length&&(this.offsetYKeyframeBuilder=new gt(t,this.getLength())),r.length&&(this.opacityKeyframeBuilder=new gt(r,this.getLength(),1)),i.length&&(this.scaleKeyframeBuilder=new gt(i,this.getLength(),1)),n.length&&(this.rotationKeyframeBuilder=new gt(n,this.getLength()))}async load(){this.outline=new U.Graphics,this.getContainer().addChild(this.outline),this.topLeftScaleHandle=new U.Graphics,this.topRightScaleHandle=new U.Graphics,this.bottomRightScaleHandle=new U.Graphics,this.bottomLeftScaleHandle=new U.Graphics,this.rotationHandle=new U.Graphics,this.topLeftScaleHandle.zIndex=1e3,this.topRightScaleHandle.zIndex=1e3,this.bottomRightScaleHandle.zIndex=1e3,this.bottomLeftScaleHandle.zIndex=1e3,this.rotationHandle.zIndex=1e3,this.getContainer().addChild(this.topLeftScaleHandle),this.getContainer().addChild(this.topRightScaleHandle),this.getContainer().addChild(this.bottomRightScaleHandle),this.getContainer().addChild(this.bottomLeftScaleHandle),this.getContainer().addChild(this.rotationHandle),this.getContainer().sortableChildren=!0,this.getContainer().cursor="pointer",this.getContainer().eventMode="static",this.getContainer().on("pointerdown",this.onPointerStart.bind(this)),this.getContainer().on("pointermove",this.onPointerMove.bind(this)),this.getContainer().on("globalpointermove",this.onPointerMove.bind(this)),this.getContainer().on("pointerup",this.onPointerUp.bind(this)),this.getContainer().on("pointerupoutside",this.onPointerUp.bind(this)),this.getContainer().on("pointerover",this.onPointerOver.bind(this)),this.getContainer().on("pointerout",this.onPointerOut.bind(this))}update(e,t){if(this.getContainer().visible=this.isActive(),this.getContainer().zIndex=1e5-this.layer*100,!this.isActive())return;const r=this.getPivot(),i=this.getPosition(),n=this.getContainerScale();this.getContainer().scale.set(n.x,n.y),this.getContainer().pivot.set(r.x,r.y),this.getContainer().position.set(i.x+r.x,i.y+r.y);const a=this.getRotation();this.contentContainer.alpha=this.getOpacity(),this.getContainer().angle=a,this.clipConfiguration.width&&this.clipConfiguration.height&&this.applyFixedDimensions(),this.shouldDiscardFrame()&&(this.contentContainer.alpha=0)}draw(){if(!this.outline)return;const e=this.edit.isPlayerSelected(this),t=this.edit.isInExportMode();if((!this.isActive()||!e)&&!this.isHovering||t){this.outline.clear(),this.topLeftScaleHandle?.clear(),this.topRightScaleHandle?.clear(),this.bottomRightScaleHandle?.clear(),this.bottomLeftScaleHandle?.clear(),this.rotationHandle?.clear();return}const r=this.isHovering||this.isDragging?65535:16777215,i=this.getSize(),n=this.getScale();if(this.outline.clear(),this.outline.strokeStyle={width:ut.OutlineWidth/n,color:r},this.outline.rect(0,0,i.width,i.height),this.outline.stroke(),!this.topLeftScaleHandle||!this.topRightScaleHandle||!this.bottomRightScaleHandle||!this.bottomLeftScaleHandle||!this.isActive()||!e)return;this.topLeftScaleHandle.fillStyle={color:r},this.topLeftScaleHandle.clear();const a=ut.ScaleHandleRadius*2/n;if(this.topLeftScaleHandle.rect(-a/2,-a/2,a,a),this.topLeftScaleHandle.fill(),this.topRightScaleHandle.fillStyle={color:r},this.topRightScaleHandle.clear(),this.topRightScaleHandle.rect(i.width-a/2,-a/2,a,a),this.topRightScaleHandle.fill(),this.bottomRightScaleHandle.fillStyle={color:r},this.bottomRightScaleHandle.clear(),this.bottomRightScaleHandle.rect(i.width-a/2,i.height-a/2,a,a),this.bottomRightScaleHandle.fill(),this.bottomLeftScaleHandle.fillStyle={color:r},this.bottomLeftScaleHandle.clear(),this.bottomLeftScaleHandle.rect(-a/2,i.height-a/2,a,a),this.bottomLeftScaleHandle.fill(),!this.rotationHandle)return;const o=i.width/2,c=-50/n;this.rotationHandle.clear(),this.rotationHandle.fillStyle={color:r},this.rotationHandle.circle(o,c,ut.RotationHandleRadius/n),this.rotationHandle.fill(),this.outline.strokeStyle={width:ut.OutlineWidth/n,color:r},this.outline.moveTo(o,0),this.outline.lineTo(o,c),this.outline.stroke()}dispose(){this.outline?.destroy(),this.outline=null,this.topLeftScaleHandle?.destroy(),this.topLeftScaleHandle=null,this.topRightScaleHandle?.destroy(),this.topRightScaleHandle=null,this.bottomLeftScaleHandle?.destroy(),this.bottomLeftScaleHandle=null,this.bottomRightScaleHandle?.destroy(),this.bottomRightScaleHandle=null,this.rotationHandle?.destroy(),this.rotationHandle=null,this.contentContainer?.destroy()}getStart(){return this.clipConfiguration.start*1e3}getLength(){return this.clipConfiguration.length*1e3}getEnd(){return this.getStart()+this.getLength()}getPlaybackTime(){const e=this.edit.playbackTime-this.getStart();return e<0?0:e>this.getLength()?this.getLength():e}getOpacity(){return this.opacityKeyframeBuilder?.getValue(this.getPlaybackTime())??1}getPosition(){const e={x:this.offsetXKeyframeBuilder?.getValue(this.getPlaybackTime())??0,y:this.offsetYKeyframeBuilder?.getValue(this.getPlaybackTime())??0};return this.positionBuilder.relativeToAbsolute(this.getSize(),this.clipConfiguration.position??"center",e)}getPivot(){const e=this.getSize();return{x:e.width/2,y:e.height/2}}getFitScale(){if(this.clipConfiguration.width&&this.clipConfiguration.height)return 1;switch(this.clipConfiguration.fit??"crop"){case"crop":{const e=this.edit.size.width/this.getSize().width,t=this.edit.size.height/this.getSize().height;return this.edit.size.height>=this.edit.size.width?t:e}case"cover":return Math.max(this.edit.size.width/this.getSize().width,this.edit.size.height/this.getSize().height);case"contain":return Math.min(this.edit.size.width/this.getSize().width,this.edit.size.height/this.getSize().height);case"none":default:return 1}}getScale(){return(this.scaleKeyframeBuilder?.getValue(this.getPlaybackTime())??1)*this.getFitScale()}getContainerScale(){if(this.clipConfiguration.width&&this.clipConfiguration.height)return{x:1,y:1};const e=this.scaleKeyframeBuilder?.getValue(this.getPlaybackTime())??1,t=this.getSize(),r=this.clipConfiguration.fit??"crop";if(t.width===0||t.height===0)return{x:e,y:e};const i=this.edit.size.width/t.width,n=this.edit.size.height/t.height;switch(r){case"contain":{const a=Math.min(i,n)*e;return{x:a,y:a}}case"crop":{const o=(this.edit.size.height>=this.edit.size.width?n:i)*e;return{x:o,y:o}}case"cover":return{x:i*e,y:n*e};case"none":default:return{x:e,y:e}}}getRotation(){return this.rotationKeyframeBuilder?.getValue(this.getPlaybackTime())??0}isActive(){return this.edit.playbackTime>=this.getStart()&&this.edit.playbackTime<this.getEnd()}shouldDiscardFrame(){return this.getPlaybackTime()<ut.DiscardedFrameCount}onPointerStart(e){if(e.button!==ph.ButtonLeftClick||(this.edit.events.emit("canvas:clip:clicked",{player:this}),this.initialClipConfiguration=structuredClone(this.clipConfiguration),this.clipHasKeyframes()))return;if(this.scaleDirection=null,this.topLeftScaleHandle?.getBounds().containsPoint(e.globalX,e.globalY)&&(this.scaleDirection="topLeft"),this.topRightScaleHandle?.getBounds().containsPoint(e.globalX,e.globalY)&&(this.scaleDirection="topRight"),this.bottomRightScaleHandle?.getBounds().containsPoint(e.globalX,e.globalY)&&(this.scaleDirection="bottomRight"),this.bottomLeftScaleHandle?.getBounds().containsPoint(e.globalX,e.globalY)&&(this.scaleDirection="bottomLeft"),this.scaleDirection!==null){this.scaleStart=this.getScale()/this.getFitScale();const c=e.getLocalPosition(this.edit.getContainer());this.scaleOffset=c;return}if(this.rotationHandle?.getBounds().containsPoint(e.globalX,e.globalY)){this.isRotating=!0,this.rotationStart=this.getRotation();const c=e.getLocalPosition(this.edit.getContainer());this.rotationOffset=c;return}this.isDragging=!0;const o=e.getLocalPosition(this.edit.getContainer());this.dragOffset={x:o.x-this.getContainer().position.x,y:o.y-this.getContainer().position.y}}onPointerMove(e){if(this.scaleDirection!==null&&this.scaleStart!==null){const t=e.getLocalPosition(this.edit.getContainer()),r=this.getPosition(),i=this.getPivot(),n={x:r.x+i.x,y:r.y+i.y},a=Math.sqrt((this.scaleOffset.x-n.x)**2+(this.scaleOffset.y-n.y)**2),c=Math.sqrt((t.x-n.x)**2+(t.y-n.y)**2)/a,u=this.scaleStart*c;this.clipConfiguration.scale=Math.max(ut.MinScale,Math.min(u,ut.MaxScale)),this.scaleKeyframeBuilder=new gt(this.clipConfiguration.scale,this.getLength(),1);return}if(this.isRotating&&this.rotationStart!==null){const t=e.getLocalPosition(this.edit.getContainer()),r=this.getPosition(),i=this.getPivot(),n={x:r.x+i.x,y:r.y+i.y},a=Math.atan2(this.rotationOffset.y-n.y,this.rotationOffset.x-n.x),c=(Math.atan2(t.y-n.y,t.x-n.x)-a)*(180/Math.PI);let u=this.rotationStart+c;const h=45,l=u%h,d=2;Math.abs(l)<d?u=Math.floor(u/h)*h:Math.abs(l-h)<d&&(u=Math.ceil(u/h)*h),this.clipConfiguration.transform||(this.clipConfiguration.transform={rotate:{angle:0}}),this.clipConfiguration.transform.rotate||(this.clipConfiguration.transform.rotate={angle:0}),this.clipConfiguration.transform.rotate.angle=u,this.rotationKeyframeBuilder=new gt(this.clipConfiguration.transform.rotate.angle,this.getLength());return}if(this.isDragging){const t=e.getLocalPosition(this.edit.getContainer()),r=this.getPivot(),i={x:t.x-this.dragOffset.x,y:t.y-this.dragOffset.y},n={x:i.x-r.x,y:i.y-r.y},a=[{x:0,y:0},{x:this.edit.size.width,y:0},{x:0,y:this.edit.size.height},{x:this.edit.size.width,y:this.edit.size.height}],o={x:this.edit.size.width/2,y:this.edit.size.height/2},c=[...a,o],u=[{x:n.x,y:n.y},{x:n.x+this.getSize().width,y:n.y},{x:n.x,y:n.y+this.getSize().height},{x:n.x+this.getSize().width,y:n.y+this.getSize().height}],h={x:n.x+this.getSize().width/2,y:n.y+this.getSize().height/2},l=[...u,h];let d=ut.SnapThreshold,f=ut.SnapThreshold,p=null,m=null;for(const g of l)for(const y of c){const b=Math.abs(g.x-y.x);b<d&&(d=b,p=n.x+(y.x-g.x));const k=Math.abs(g.y-y.y);k<f&&(f=k,m=n.y+(y.y-g.y))}p!==null&&(n.x=p),m!==null&&(n.y=m);const v=this.positionBuilder.absoluteToRelative(this.getSize(),this.clipConfiguration.position??"center",n);this.clipConfiguration.offset||(this.clipConfiguration.offset={x:0,y:0}),this.clipConfiguration.offset.x=v.x,this.clipConfiguration.offset.y=v.y,this.offsetXKeyframeBuilder=new gt(this.clipConfiguration.offset.x,this.getLength()),this.offsetYKeyframeBuilder=new gt(this.clipConfiguration.offset.y,this.getLength())}}onPointerUp(){(this.isDragging||this.scaleDirection!==null||this.isRotating)&&this.hasStateChanged()&&this.edit.setUpdatedClip(this,this.initialClipConfiguration,structuredClone(this.clipConfiguration)),this.isDragging=!1,this.dragOffset={x:0,y:0},this.scaleDirection=null,this.scaleStart=null,this.scaleOffset={x:0,y:0},this.isRotating=!1,this.rotationStart=null,this.rotationOffset={x:0,y:0},this.initialClipConfiguration=null}onPointerOver(){this.isHovering=!0}onPointerOut(){this.isHovering=!1}clipHasPresets(){return!!this.clipConfiguration.effect||!!this.clipConfiguration.transition?.in||!!this.clipConfiguration.transition?.out}clipHasKeyframes(){return[this.clipConfiguration.scale,this.clipConfiguration.offset?.x,this.clipConfiguration.offset?.y,this.clipConfiguration.transform?.rotate?.angle].some(e=>e&&typeof e!="number")}hasStateChanged(){if(!this.initialClipConfiguration)return!1;const e=this.clipConfiguration.offset?.x,t=this.clipConfiguration.offset?.y,r=this.clipConfiguration.scale,i=Number(this.clipConfiguration.transform?.rotate?.angle??0),n=this.initialClipConfiguration.offset?.x,a=this.initialClipConfiguration.offset?.y,o=this.initialClipConfiguration.scale,c=Number(this.initialClipConfiguration.transform?.rotate?.angle??0);return n!==void 0&&e!==n||a!==void 0&&t!==a||o!==void 0&&r!==o||i!==c}applyFixedDimensions(){const e=this.clipConfiguration.width,t=this.clipConfiguration.height;if(!e||!t)return;const r=this.contentContainer.children[0];if(!r||!r.texture)return;const i=r.texture.width,n=r.texture.height,a=this.clipConfiguration.fit||"crop";if(!this.contentContainer.mask){const c=new U.Graphics;c.rect(0,0,e,t),c.fill(16777215),this.contentContainer.addChild(c),this.contentContainer.mask=c}const o=this.scaleKeyframeBuilder?.getValue(this.getPlaybackTime())??1;switch(r.anchor.set(.5,.5),a){case"cover":{const c=e/i,u=t/n;r.scale.set(c,u),r.position.set(e/2,t/2);break}case"crop":{const c=this.edit.size.width,u=this.edit.size.height;let h=1;(i>c||n>u)&&(h=Math.min(c/i,u/n));const l=i*h,d=n*h,f=Math.max(e/l,t/d),p=h<1?h*f:Math.max(1,f);r.scale.set(p,p),r.anchor.set(.5,.5),r.position.set(e/2,t/2);break}case"contain":{const c=e/i,u=t/n,h=Math.min(c,u);r.scale.set(h,h),r.position.set(e/2,t/2);break}case"none":default:{r.scale.set(1,1),r.position.set(e/2,t/2);break}}this.contentContainer.scale.set(o,o),this.contentContainer.position.set(e/2*(1-o),t/2*(1-o))}applyAnchorPositioning(e,t,r,i){const n=i.width,a=i.height;if(!!i.mask){i.position.set(0,0);return}const c=(e??"center").toLowerCase();let u=0,h=0;c.includes("left")||c==="left"?u=0:c.includes("right")||c==="right"?u=t-n:u=(t-n)/2,c.includes("top")||c==="top"?h=0:c.includes("bottom")||c==="bottom"?h=r-a:h=(r-a)/2,i.position.set(u,h)}}class Ko extends ut{audioResource;isPlaying;volumeKeyframeBuilder;syncTimer;constructor(e,t){super(e,t),this.audioResource=null,this.isPlaying=!1;const r=t.asset;this.volumeKeyframeBuilder=new gt(r.volume??1,this.getLength()),this.syncTimer=0}async load(){await super.load();const e=this.clipConfiguration.asset,t=e.src,r={src:t,loadParser:Wi.Name},i=await this.edit.assetLoader.load(t,r);if(!(i instanceof uh.Howl))throw new Error(`Invalid audio source '${e.src}'.`);this.audioResource=i,this.configureKeyframes()}update(e,t){super.update(e,t);const{trim:r=0}=this.clipConfiguration.asset;if(this.syncTimer+=t,this.getContainer().alpha=0,!this.audioResource)return;const i=this.edit.isPlaying&&this.isActive(),n=this.getPlaybackTime();i&&(this.isPlaying||(this.isPlaying=!0,this.audioResource.seek(n/1e3+r),this.audioResource.play()),this.audioResource.volume()!==this.getVolume()&&this.audioResource.volume(this.getVolume()),Math.abs((this.audioResource.seek()-r)*1e3-n)>100&&this.audioResource.seek(n/1e3+r)),this.isPlaying&&!i&&(this.isPlaying=!1,this.audioResource.pause());const a=this.syncTimer>100;!this.edit.isPlaying&&this.isActive()&&a&&(this.syncTimer=0,this.audioResource.seek(n/1e3+r))}draw(){super.draw()}dispose(){this.audioResource?.unload(),this.audioResource=null}getSize(){return{width:0,height:0}}getVolume(){return this.volumeKeyframeBuilder.getValue(this.getPlaybackTime())}}var gh=`in vec2 aPosition;
2
2
  out vec2 vTextureCoord;
3
3
 
4
4
  uniform vec4 uInputSize;
@@ -25,7 +25,7 @@ void main(void)
25
25
  gl_Position = filterVertexPosition();
26
26
  vTextureCoord = filterTextureCoord();
27
27
  }
28
- `,qn=`struct GlobalFilterUniforms {
28
+ `,yh=`struct GlobalFilterUniforms {
29
29
  uInputSize:vec4<f32>,
30
30
  uInputPixel:vec4<f32>,
31
31
  uInputClamp:vec4<f32>,
@@ -74,7 +74,7 @@ fn mainVertex(
74
74
  filterVertexPosition(aPosition),
75
75
  filterTextureCoord(aPosition)
76
76
  );
77
- }`,Xn=`precision highp float;
77
+ }`,bh=`precision highp float;
78
78
  in vec2 vTextureCoord;
79
79
  out vec4 finalColor;
80
80
 
@@ -115,7 +115,7 @@ void main(void) {
115
115
  vec4 outlineColor = vec4(vec3(uColor) * outlineAlpha, outlineAlpha);
116
116
  finalColor = contentColor + outlineColor;
117
117
  }
118
- `,Yn=`struct OutlineUniforms {
118
+ `,vh=`struct OutlineUniforms {
119
119
  uThickness:vec2<f32>,
120
120
  uColor:vec3<f32>,
121
121
  uAlpha:f32,
@@ -179,126 +179,128 @@ fn outlineMaxAlphaAtPos(uv: vec2<f32>) -> f32 {
179
179
  return maxAlpha;
180
180
  }
181
181
 
182
- const DOUBLE_PI: f32 = 3.14159265358979323846264 * 2.;`,Qn=Object.defineProperty,Jn=(s,e,t)=>e in s?Qn(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,pt=(s,e,t)=>(Jn(s,typeof e!="symbol"?e+"":e,t),t);const oi=class kt extends Be.Filter{constructor(...e){let t=e[0]??{};typeof t=="number"&&(Be.deprecation("6.0.0","OutlineFilter constructor params are now options object. See params: { thickness, color, quality, alpha, knockout }"),t={thickness:t},e[1]!==void 0&&(t.color=e[1]),e[2]!==void 0&&(t.quality=e[2]),e[3]!==void 0&&(t.alpha=e[3]),e[4]!==void 0&&(t.knockout=e[4])),t={...kt.DEFAULT_OPTIONS,...t};const i=t.quality??.1,r=Be.GpuProgram.from({vertex:{source:qn,entryPoint:"mainVertex"},fragment:{source:Yn,entryPoint:"mainFragment"}}),n=Be.GlProgram.from({vertex:Kn,fragment:Xn.replace(/\$\{ANGLE_STEP\}/,kt.getAngleStep(i).toFixed(7)),name:"outline-filter"});super({gpuProgram:r,glProgram:n,resources:{outlineUniforms:{uThickness:{value:new Float32Array(2),type:"vec2<f32>"},uColor:{value:new Float32Array(3),type:"vec3<f32>"},uAlpha:{value:t.alpha,type:"f32"},uAngleStep:{value:0,type:"f32"},uKnockout:{value:t.knockout?1:0,type:"f32"}}}}),pt(this,"uniforms"),pt(this,"_thickness"),pt(this,"_quality"),pt(this,"_color"),this.uniforms=this.resources.outlineUniforms.uniforms,this.uniforms.uAngleStep=kt.getAngleStep(i),this._color=new Be.Color,this.color=t.color??0,Object.assign(this,t)}apply(e,t,i,r){this.uniforms.uThickness[0]=this.thickness/t.source.width,this.uniforms.uThickness[1]=this.thickness/t.source.height,e.applyFilter(this,t,i,r)}static getAngleStep(e){return parseFloat((Math.PI*2/Math.max(e*kt.MAX_SAMPLES,kt.MIN_SAMPLES)).toFixed(7))}get thickness(){return this._thickness}set thickness(e){this._thickness=this.padding=e}get color(){return this._color.value}set color(e){this._color.setValue(e);const[t,i,r]=this._color.toArray();this.uniforms.uColor[0]=t,this.uniforms.uColor[1]=i,this.uniforms.uColor[2]=r}get alpha(){return this.uniforms.uAlpha}set alpha(e){this.uniforms.uAlpha=e}get quality(){return this._quality}set quality(e){this._quality=e,this.uniforms.uAngleStep=kt.getAngleStep(e)}get knockout(){return this.uniforms.uKnockout===1}set knockout(e){this.uniforms.uKnockout=e?1:0}};pt(oi,"DEFAULT_OPTIONS",{thickness:1,color:0,alpha:1,quality:.1,knockout:!1}),pt(oi,"MIN_SAMPLES",1),pt(oi,"MAX_SAMPLES",100);let Fi=oi;class ea extends we{background;text;constructor(e,t){super(e,t),this.background=null,this.text=null}async load(){await super.load();const e=this.clipConfiguration.asset,t=await this.parseDocument();if(!t)return;const i=new R.Graphics;t.background.color&&(i.fillStyle={color:t.background.color,alpha:t.background.opacity??1},i.rect(0,0,e.width??this.edit.size.width,e.height??this.edit.size.height),i.fill());const r=new R.Text;r.text=t.text;const{horizontal:n,vertical:o}=t.alignment;r.style={fontFamily:t.font?.family??"Open Sans",fontSize:t.font?.size??32,fill:t.font?.color??"#ffffff",fontWeight:(t.font?.weight??"400").toString(),wordWrap:!0,wordWrapWidth:e.width??this.edit.size.width,lineHeight:(t.font?.lineHeight??1)*(t.font?.size??32),align:n};let a=(e.width??this.edit.size.width)/2-r.width/2,p=(e.height??this.edit.size.height)/2-r.height/2;if(n==="left"&&(a=0),n==="right"&&(a=(e.width??this.edit.size.width)-r.width),o==="top"&&(p=0),o==="bottom"&&(p=(e.height??this.edit.size.height)-r.height),r.position={x:a,y:p},t.stroke.color&&t.stroke.width){const m=new Fi({thickness:t.stroke.width,color:t.stroke.color});r.filters=[m]}this.background=i,this.text=r,this.contentContainer.addChild(i),this.contentContainer.addChild(r),this.configureKeyframes()}update(e,t){super.update(e,t)}draw(){super.draw()}dispose(){super.dispose(),this.background?.destroy(),this.background=null,this.text?.destroy(),this.text=null}getSize(){const e=this.clipConfiguration.asset;return{width:e.width??this.edit.size.width,height:e.height??this.edit.size.height}}getFitScale(){return 1}async parseDocument(){const e=this.clipConfiguration.asset,{html:t,css:i,position:r}=e;if(!t.includes('data-html-type="text"'))return console.warn("Unsupported html format."),null;const o=new DOMParser().parseFromString(t,"text/html").body.textContent??"",p=(await new CSSStyleSheet().replace(i)).cssRules[0],m={text:o,font:{},alignment:{},background:{},stroke:{}};if(p?.constructor.name!=="CSSStyleRule"||!("style"in p))return console.warn("Unsupported css format."),m;const d=p.style,l=this.parseAlignment(r??"center");m.font={color:d.color.length?d.color:void 0,family:d.fontFamily.length?d.fontFamily:void 0,size:d.fontSize.length?parseInt(d.fontSize,10):void 0,weight:d.fontWeight.length?parseInt(d.fontWeight,10):void 0,lineHeight:d.lineHeight.length?parseInt(d.lineHeight,10):void 0},m.alignment=l;let c="";return d.background.length&&(c=d.background),d.backgroundColor.length&&(c=d.backgroundColor),m.background={color:c.length?c:void 0,opacity:d.opacity.length?parseInt(d.opacity,10):void 0},m.stroke={width:d.strokeWidth.length?parseInt(d.strokeWidth,10):void 0,color:d.stroke.length?d.stroke:void 0},m}parseAlignment(e){switch(e){case"topLeft":return{horizontal:"left",vertical:"top"};case"top":return{horizontal:"center",vertical:"top"};case"topRight":return{horizontal:"right",vertical:"top"};case"left":return{horizontal:"left",vertical:"center"};case"right":return{horizontal:"right",vertical:"center"};case"bottomLeft":return{horizontal:"left",vertical:"bottom"};case"bottom":return{horizontal:"center",vertical:"bottom"};case"bottomRight":return{horizontal:"right",vertical:"bottom"};case"center":default:return{horizontal:"center",vertical:"center"}}}}class ta extends we{texture;sprite;originalSize;constructor(e,t){super(e,t),this.texture=null,this.sprite=null,this.originalSize=null}async load(){await super.load();const e=this.clipConfiguration.asset,t=e.src,i={src:t,crossovern:"anonymous",data:{}},r=await this.edit.assetLoader.load(t,i);if(!(r?.source instanceof R.ImageSource))throw new Error(`Invalid image source '${e.src}'.`);this.texture=this.createCroppedTexture(r),this.sprite=new R.Sprite(this.texture),this.contentContainer.addChild(this.sprite),this.clipConfiguration.width&&this.clipConfiguration.height&&this.applyFixedDimensions(),this.configureKeyframes()}update(e,t){super.update(e,t)}draw(){super.draw()}dispose(){super.dispose(),this.sprite?.destroy(),this.sprite=null,this.texture?.destroy(),this.texture=null,this.originalSize=null}getSize(){return this.clipConfiguration.width&&this.clipConfiguration.height?{width:this.clipConfiguration.width,height:this.clipConfiguration.height}:{width:this.sprite?.width??0,height:this.sprite?.height??0}}createCroppedTexture(e){const t=this.clipConfiguration.asset;if(!t.crop)return e;const i=e.width,r=e.height,n=Math.floor((t.crop?.left??0)*i),o=Math.floor((t.crop?.right??0)*i),a=Math.floor((t.crop?.top??0)*r),p=Math.floor((t.crop?.bottom??0)*r),m=n,d=a,l=i-n-o,c=r-a-p,u=new R.Rectangle(m,d,l,c);return new R.Texture({source:e.source,frame:u})}}class Fs extends we{texture;sprite;isPlaying;constructor(e,t){super(e,t),this.texture=null,this.sprite=null,this.isPlaying=!1}async load(){await super.load();const e=this.clipConfiguration.asset,t=e.src,i={src:t,data:{autoPlay:!1,muted:!0}},r=await this.edit.assetLoader.load(t,i);if(!(r?.source instanceof R.ImageSource||r?.source instanceof R.VideoSource))throw new Error(`Invalid luma source '${e.src}'.`);this.texture=r,this.sprite=new R.Sprite(this.texture),this.contentContainer.addChild(this.sprite),this.configureKeyframes()}update(e,t){if(super.update(e,t),!this.texture||!(this.texture.source instanceof R.VideoSource))return;const i=this.getPlaybackTime(),r=this.edit.isPlaying&&this.isActive();r&&(this.isPlaying||(this.isPlaying=!0,this.texture.source.resource.currentTime=i/1e3,this.texture.source.resource.play().catch(console.error)),this.texture.source.resource.volume!==this.getVolume()&&(this.texture.source.resource.volume=this.getVolume()),Math.abs(this.texture.source.resource.currentTime*1e3-i)>100&&(this.texture.source.resource.currentTime=i/1e3)),!r&&this.isPlaying&&(this.isPlaying=!1,this.texture.source.resource.pause()),!this.edit.isPlaying&&this.isActive()&&(this.texture.source.resource.currentTime=i/1e3)}draw(){super.draw()}dispose(){super.dispose(),this.sprite?.destroy(),this.sprite=null,this.texture?.destroy(),this.texture=null}getSize(){return{width:this.sprite?.width??0,height:this.sprite?.height??0}}getVolume(){return 0}getMask(){return this.sprite}}var oe;(function(s){s.assertEqual=r=>{};function e(r){}s.assertIs=e;function t(r){throw new Error}s.assertNever=t,s.arrayToEnum=r=>{const n={};for(const o of r)n[o]=o;return n},s.getValidEnumValues=r=>{const n=s.objectKeys(r).filter(a=>typeof r[r[a]]!="number"),o={};for(const a of n)o[a]=r[a];return s.objectValues(o)},s.objectValues=r=>s.objectKeys(r).map(function(n){return r[n]}),s.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const n=[];for(const o in r)Object.prototype.hasOwnProperty.call(r,o)&&n.push(o);return n},s.find=(r,n)=>{for(const o of r)if(n(o))return o},s.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function i(r,n=" | "){return r.map(o=>typeof o=="string"?`'${o}'`:o).join(n)}s.joinValues=i,s.jsonStringifyReplacer=(r,n)=>typeof n=="bigint"?n.toString():n})(oe||(oe={}));var Ms;(function(s){s.mergeShapes=(e,t)=>({...e,...t})})(Ms||(Ms={}));const j=oe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),et=s=>{switch(typeof s){case"undefined":return j.undefined;case"string":return j.string;case"number":return Number.isNaN(s)?j.nan:j.number;case"boolean":return j.boolean;case"function":return j.function;case"bigint":return j.bigint;case"symbol":return j.symbol;case"object":return Array.isArray(s)?j.array:s===null?j.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?j.promise:typeof Map<"u"&&s instanceof Map?j.map:typeof Set<"u"&&s instanceof Set?j.set:typeof Date<"u"&&s instanceof Date?j.date:j.object;default:return j.unknown}},M=oe.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class qe extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=i=>{this.issues=[...this.issues,i]},this.addIssues=(i=[])=>{this.issues=[...this.issues,...i]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(n){return n.message},i={_errors:[]},r=n=>{for(const o of n.issues)if(o.code==="invalid_union")o.unionErrors.map(r);else if(o.code==="invalid_return_type")r(o.returnTypeError);else if(o.code==="invalid_arguments")r(o.argumentsError);else if(o.path.length===0)i._errors.push(t(o));else{let a=i,p=0;for(;p<o.path.length;){const m=o.path[p];p===o.path.length-1?(a[m]=a[m]||{_errors:[]},a[m]._errors.push(t(o))):a[m]=a[m]||{_errors:[]},a=a[m],p++}}};return r(this),i}static assert(e){if(!(e instanceof qe))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,oe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},i=[];for(const r of this.issues)if(r.path.length>0){const n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else i.push(e(r));return{formErrors:i,fieldErrors:t}}get formErrors(){return this.flatten()}}qe.create=s=>new qe(s);const Mi=(s,e)=>{let t;switch(s.code){case M.invalid_type:s.received===j.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case M.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,oe.jsonStringifyReplacer)}`;break;case M.unrecognized_keys:t=`Unrecognized key(s) in object: ${oe.joinValues(s.keys,", ")}`;break;case M.invalid_union:t="Invalid input";break;case M.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${oe.joinValues(s.options)}`;break;case M.invalid_enum_value:t=`Invalid enum value. Expected ${oe.joinValues(s.options)}, received '${s.received}'`;break;case M.invalid_arguments:t="Invalid function arguments";break;case M.invalid_return_type:t="Invalid function return type";break;case M.invalid_date:t="Invalid date";break;case M.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:oe.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case M.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="bigint"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case M.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case M.custom:t="Invalid input";break;case M.invalid_intersection_types:t="Intersection results could not be merged";break;case M.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case M.not_finite:t="Number must be finite";break;default:t=e.defaultError,oe.assertNever(s)}return{message:t}};let ia=Mi;function sa(){return ia}const ra=s=>{const{data:e,path:t,errorMaps:i,issueData:r}=s,n=[...t,...r.path||[]],o={...r,path:n};if(r.message!==void 0)return{...r,path:n,message:r.message};let a="";const p=i.filter(m=>!!m).slice().reverse();for(const m of p)a=m(o,{data:e,defaultError:a}).message;return{...r,path:n,message:a}};function H(s,e){const t=sa(),i=ra({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,t,t===Mi?void 0:Mi].filter(r=>!!r)});s.common.issues.push(i)}class Ie{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const i=[];for(const r of t){if(r.status==="aborted")return J;r.status==="dirty"&&e.dirty(),i.push(r.value)}return{status:e.value,value:i}}static async mergeObjectAsync(e,t){const i=[];for(const r of t){const n=await r.key,o=await r.value;i.push({key:n,value:o})}return Ie.mergeObjectSync(e,i)}static mergeObjectSync(e,t){const i={};for(const r of t){const{key:n,value:o}=r;if(n.status==="aborted"||o.status==="aborted")return J;n.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),n.value!=="__proto__"&&(typeof o.value<"u"||r.alwaysSet)&&(i[n.value]=o.value)}return{status:e.value,value:i}}}const J=Object.freeze({status:"aborted"}),Ht=s=>({status:"dirty",value:s}),Re=s=>({status:"valid",value:s}),Ls=s=>s.status==="aborted",Bs=s=>s.status==="dirty",Tt=s=>s.status==="valid",li=s=>typeof Promise<"u"&&s instanceof Promise;var V;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e?.message})(V||(V={}));class tt{constructor(e,t,i,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=i,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const $s=(s,e)=>{if(Tt(e))return{success:!0,data:e.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new qe(s.common.issues);return this._error=t,this._error}}};function ie(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:i,description:r}=s;if(e&&(t||i))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(o,a)=>{const{message:p}=s;return o.code==="invalid_enum_value"?{message:p??a.defaultError}:typeof a.data>"u"?{message:p??i??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:p??t??a.defaultError}},description:r}}class ae{get description(){return this._def.description}_getType(e){return et(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:et(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ie,ctx:{common:e.parent.common,data:e.data,parsedType:et(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(li(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const i=this.safeParse(e,t);if(i.success)return i.data;throw i.error}safeParse(e,t){const i={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:et(e)},r=this._parseSync({data:e,path:i.path,parent:i});return $s(i,r)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:et(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:t});return Tt(i)?{value:i.value}:{issues:t.common.issues}}catch(i){i?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(i=>Tt(i)?{value:i.value}:{issues:t.common.issues})}async parseAsync(e,t){const i=await this.safeParseAsync(e,t);if(i.success)return i.data;throw i.error}async safeParseAsync(e,t){const i={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:et(e)},r=this._parse({data:e,path:i.path,parent:i}),n=await(li(r)?r:Promise.resolve(r));return $s(i,n)}refine(e,t){const i=r=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,n)=>{const o=e(r),a=()=>n.addIssue({code:M.custom,...i(r)});return typeof Promise<"u"&&o instanceof Promise?o.then(p=>p?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,t){return this._refinement((i,r)=>e(i)?!0:(r.addIssue(typeof t=="function"?t(i,r):t),!1))}_refinement(e){return new It({schema:this,typeName:ee.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return rt.create(this,this._def)}nullable(){return Pt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return $e.create(this)}promise(){return di.create(this,this._def)}or(e){return hi.create([this,e],this._def)}and(e){return ui.create(this,e,this._def)}transform(e){return new It({...ie(this._def),schema:this,typeName:ee.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new zi({...ie(this._def),innerType:this,defaultValue:t,typeName:ee.ZodDefault})}brand(){return new Ea({typeName:ee.ZodBranded,type:this,...ie(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Hi({...ie(this._def),innerType:this,catchValue:t,typeName:ee.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ni.create(this,e)}readonly(){return Ui.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const na=/^c[^\s-]{8,}$/i,aa=/^[0-9a-z]+$/,oa=/^[0-9A-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,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ba=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,va=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ds="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",wa=new RegExp(`^${Ds}$`);function zs(s){let e="[0-5]\\d";s.precision?e=`${e}\\.\\d{${s.precision}}`:s.precision==null&&(e=`${e}(\\.\\d+)?`);const t=s.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function _a(s){return new RegExp(`^${zs(s)}$`)}function xa(s){let e=`${Ds}T${zs(s)}`;const t=[];return t.push(s.local?"Z?":"Z"),s.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Ca(s,e){return!!((e==="v4"||!e)&&pa.test(s)||(e==="v6"||!e)&&ga.test(s))}function ka(s,e){if(!ha.test(s))return!1;try{const[t]=s.split(".");if(!t)return!1;const i=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),r=JSON.parse(atob(i));return!(typeof r!="object"||r===null||"typ"in r&&r?.typ!=="JWT"||!r.alg||e&&r.alg!==e)}catch{return!1}}function Ta(s,e){return!!((e==="v4"||!e)&&ma.test(s)||(e==="v6"||!e)&&ya.test(s))}class it extends ae{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==j.string){const n=this._getOrReturnCtx(e);return H(n,{code:M.invalid_type,expected:j.string,received:n.parsedType}),J}const i=new Ie;let r;for(const n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(r=this._getOrReturnCtx(e,r),H(r,{code:M.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),i.dirty());else if(n.kind==="max")e.data.length>n.value&&(r=this._getOrReturnCtx(e,r),H(r,{code:M.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),i.dirty());else if(n.kind==="length"){const o=e.data.length>n.value,a=e.data.length<n.value;(o||a)&&(r=this._getOrReturnCtx(e,r),o?H(r,{code:M.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):a&&H(r,{code:M.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),i.dirty())}else if(n.kind==="email")da.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"email",code:M.invalid_string,message:n.message}),i.dirty());else if(n.kind==="emoji")Li||(Li=new RegExp(fa,"u")),Li.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"emoji",code:M.invalid_string,message:n.message}),i.dirty());else if(n.kind==="uuid")la.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"uuid",code:M.invalid_string,message:n.message}),i.dirty());else if(n.kind==="nanoid")ca.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"nanoid",code:M.invalid_string,message:n.message}),i.dirty());else if(n.kind==="cuid")na.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"cuid",code:M.invalid_string,message:n.message}),i.dirty());else if(n.kind==="cuid2")aa.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"cuid2",code:M.invalid_string,message:n.message}),i.dirty());else if(n.kind==="ulid")oa.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"ulid",code:M.invalid_string,message:n.message}),i.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),H(r,{validation:"url",code:M.invalid_string,message:n.message}),i.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"regex",code:M.invalid_string,message:n.message}),i.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(r=this._getOrReturnCtx(e,r),H(r,{code:M.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),i.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(r=this._getOrReturnCtx(e,r),H(r,{code:M.invalid_string,validation:{startsWith:n.value},message:n.message}),i.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(r=this._getOrReturnCtx(e,r),H(r,{code:M.invalid_string,validation:{endsWith:n.value},message:n.message}),i.dirty()):n.kind==="datetime"?xa(n).test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{code:M.invalid_string,validation:"datetime",message:n.message}),i.dirty()):n.kind==="date"?wa.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{code:M.invalid_string,validation:"date",message:n.message}),i.dirty()):n.kind==="time"?_a(n).test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{code:M.invalid_string,validation:"time",message:n.message}),i.dirty()):n.kind==="duration"?ua.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"duration",code:M.invalid_string,message:n.message}),i.dirty()):n.kind==="ip"?Ca(e.data,n.version)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"ip",code:M.invalid_string,message:n.message}),i.dirty()):n.kind==="jwt"?ka(e.data,n.alg)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"jwt",code:M.invalid_string,message:n.message}),i.dirty()):n.kind==="cidr"?Ta(e.data,n.version)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"cidr",code:M.invalid_string,message:n.message}),i.dirty()):n.kind==="base64"?ba.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"base64",code:M.invalid_string,message:n.message}),i.dirty()):n.kind==="base64url"?va.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"base64url",code:M.invalid_string,message:n.message}),i.dirty()):oe.assertNever(n);return{status:i.value,value:e.data}}_regex(e,t,i){return this.refinement(r=>e.test(r),{validation:t,code:M.invalid_string,...V.errToObj(i)})}_addCheck(e){return new it({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...V.errToObj(e)})}url(e){return this._addCheck({kind:"url",...V.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...V.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...V.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...V.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...V.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...V.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...V.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...V.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...V.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...V.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...V.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...V.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...V.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...V.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...V.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...V.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...V.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...V.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...V.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...V.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...V.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...V.errToObj(t)})}nonempty(e){return this.min(1,V.errToObj(e))}trim(){return new it({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new it({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new it({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}it.create=s=>new it({checks:[],typeName:ee.ZodString,coerce:s?.coerce??!1,...ie(s)});function Sa(s,e){const t=(s.toString().split(".")[1]||"").length,i=(e.toString().split(".")[1]||"").length,r=t>i?t:i,n=Number.parseInt(s.toFixed(r).replace(".","")),o=Number.parseInt(e.toFixed(r).replace(".",""));return n%o/10**r}class St extends ae{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==j.number){const n=this._getOrReturnCtx(e);return H(n,{code:M.invalid_type,expected:j.number,received:n.parsedType}),J}let i;const r=new Ie;for(const n of this._def.checks)n.kind==="int"?oe.isInteger(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{code:M.invalid_type,expected:"integer",received:"float",message:n.message}),r.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(i=this._getOrReturnCtx(e,i),H(i,{code:M.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(i=this._getOrReturnCtx(e,i),H(i,{code:M.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):n.kind==="multipleOf"?Sa(e.data,n.value)!==0&&(i=this._getOrReturnCtx(e,i),H(i,{code:M.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{code:M.not_finite,message:n.message}),r.dirty()):oe.assertNever(n);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,V.toString(t))}gt(e,t){return this.setLimit("min",e,!1,V.toString(t))}lte(e,t){return this.setLimit("max",e,!0,V.toString(t))}lt(e,t){return this.setLimit("max",e,!1,V.toString(t))}setLimit(e,t,i,r){return new St({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:i,message:V.toString(r)}]})}_addCheck(e){return new St({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:V.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:V.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:V.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:V.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:V.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:V.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:V.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:V.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:V.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&oe.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const i of this._def.checks){if(i.kind==="finite"||i.kind==="int"||i.kind==="multipleOf")return!0;i.kind==="min"?(t===null||i.value>t)&&(t=i.value):i.kind==="max"&&(e===null||i.value<e)&&(e=i.value)}return Number.isFinite(t)&&Number.isFinite(e)}}St.create=s=>new St({checks:[],typeName:ee.ZodNumber,coerce:s?.coerce||!1,...ie(s)});class Nt extends ae{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==j.bigint)return this._getInvalidInput(e);let i;const r=new Ie;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(i=this._getOrReturnCtx(e,i),H(i,{code:M.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(i=this._getOrReturnCtx(e,i),H(i,{code:M.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(i=this._getOrReturnCtx(e,i),H(i,{code:M.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):oe.assertNever(n);return{status:r.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return H(t,{code:M.invalid_type,expected:j.bigint,received:t.parsedType}),J}gte(e,t){return this.setLimit("min",e,!0,V.toString(t))}gt(e,t){return this.setLimit("min",e,!1,V.toString(t))}lte(e,t){return this.setLimit("max",e,!0,V.toString(t))}lt(e,t){return this.setLimit("max",e,!1,V.toString(t))}setLimit(e,t,i,r){return new Nt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:i,message:V.toString(r)}]})}_addCheck(e){return new Nt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:V.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:V.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:V.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:V.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:V.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Nt.create=s=>new Nt({checks:[],typeName:ee.ZodBigInt,coerce:s?.coerce??!1,...ie(s)});class Bi extends ae{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==j.boolean){const i=this._getOrReturnCtx(e);return H(i,{code:M.invalid_type,expected:j.boolean,received:i.parsedType}),J}return Re(e.data)}}Bi.create=s=>new Bi({typeName:ee.ZodBoolean,coerce:s?.coerce||!1,...ie(s)});class ci extends ae{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==j.date){const n=this._getOrReturnCtx(e);return H(n,{code:M.invalid_type,expected:j.date,received:n.parsedType}),J}if(Number.isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return H(n,{code:M.invalid_date}),J}const i=new Ie;let r;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(r=this._getOrReturnCtx(e,r),H(r,{code:M.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),i.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(r=this._getOrReturnCtx(e,r),H(r,{code:M.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),i.dirty()):oe.assertNever(n);return{status:i.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ci({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:V.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:V.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}ci.create=s=>new ci({checks:[],coerce:s?.coerce||!1,typeName:ee.ZodDate,...ie(s)});class Hs extends ae{_parse(e){if(this._getType(e)!==j.symbol){const i=this._getOrReturnCtx(e);return H(i,{code:M.invalid_type,expected:j.symbol,received:i.parsedType}),J}return Re(e.data)}}Hs.create=s=>new Hs({typeName:ee.ZodSymbol,...ie(s)});class Ns extends ae{_parse(e){if(this._getType(e)!==j.undefined){const i=this._getOrReturnCtx(e);return H(i,{code:M.invalid_type,expected:j.undefined,received:i.parsedType}),J}return Re(e.data)}}Ns.create=s=>new Ns({typeName:ee.ZodUndefined,...ie(s)});class Us extends ae{_parse(e){if(this._getType(e)!==j.null){const i=this._getOrReturnCtx(e);return H(i,{code:M.invalid_type,expected:j.null,received:i.parsedType}),J}return Re(e.data)}}Us.create=s=>new Us({typeName:ee.ZodNull,...ie(s)});class js extends ae{constructor(){super(...arguments),this._any=!0}_parse(e){return Re(e.data)}}js.create=s=>new js({typeName:ee.ZodAny,...ie(s)});class Vs extends ae{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Re(e.data)}}Vs.create=s=>new Vs({typeName:ee.ZodUnknown,...ie(s)});class st extends ae{_parse(e){const t=this._getOrReturnCtx(e);return H(t,{code:M.invalid_type,expected:j.never,received:t.parsedType}),J}}st.create=s=>new st({typeName:ee.ZodNever,...ie(s)});class Ws extends ae{_parse(e){if(this._getType(e)!==j.undefined){const i=this._getOrReturnCtx(e);return H(i,{code:M.invalid_type,expected:j.void,received:i.parsedType}),J}return Re(e.data)}}Ws.create=s=>new Ws({typeName:ee.ZodVoid,...ie(s)});class $e extends ae{_parse(e){const{ctx:t,status:i}=this._processInputParams(e),r=this._def;if(t.parsedType!==j.array)return H(t,{code:M.invalid_type,expected:j.array,received:t.parsedType}),J;if(r.exactLength!==null){const o=t.data.length>r.exactLength.value,a=t.data.length<r.exactLength.value;(o||a)&&(H(t,{code:o?M.too_big:M.too_small,minimum:a?r.exactLength.value:void 0,maximum:o?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),i.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(H(t,{code:M.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),i.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(H(t,{code:M.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),i.dirty()),t.common.async)return Promise.all([...t.data].map((o,a)=>r.type._parseAsync(new tt(t,o,t.path,a)))).then(o=>Ie.mergeArray(i,o));const n=[...t.data].map((o,a)=>r.type._parseSync(new tt(t,o,t.path,a)));return Ie.mergeArray(i,n)}get element(){return this._def.type}min(e,t){return new $e({...this._def,minLength:{value:e,message:V.toString(t)}})}max(e,t){return new $e({...this._def,maxLength:{value:e,message:V.toString(t)}})}length(e,t){return new $e({...this._def,exactLength:{value:e,message:V.toString(t)}})}nonempty(e){return this.min(1,e)}}$e.create=(s,e)=>new $e({type:s,minLength:null,maxLength:null,exactLength:null,typeName:ee.ZodArray,...ie(e)});function Et(s){if(s instanceof ye){const e={};for(const t in s.shape){const i=s.shape[t];e[t]=rt.create(Et(i))}return new ye({...s._def,shape:()=>e})}else return s instanceof $e?new $e({...s._def,type:Et(s.element)}):s instanceof rt?rt.create(Et(s.unwrap())):s instanceof Pt?Pt.create(Et(s.unwrap())):s instanceof mt?mt.create(s.items.map(e=>Et(e))):s}class ye extends ae{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=oe.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==j.object){const m=this._getOrReturnCtx(e);return H(m,{code:M.invalid_type,expected:j.object,received:m.parsedType}),J}const{status:i,ctx:r}=this._processInputParams(e),{shape:n,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof st&&this._def.unknownKeys==="strip"))for(const m in r.data)o.includes(m)||a.push(m);const p=[];for(const m of o){const d=n[m],l=r.data[m];p.push({key:{status:"valid",value:m},value:d._parse(new tt(r,l,r.path,m)),alwaysSet:m in r.data})}if(this._def.catchall instanceof st){const m=this._def.unknownKeys;if(m==="passthrough")for(const d of a)p.push({key:{status:"valid",value:d},value:{status:"valid",value:r.data[d]}});else if(m==="strict")a.length>0&&(H(r,{code:M.unrecognized_keys,keys:a}),i.dirty());else if(m!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const m=this._def.catchall;for(const d of a){const l=r.data[d];p.push({key:{status:"valid",value:d},value:m._parse(new tt(r,l,r.path,d)),alwaysSet:d in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const m=[];for(const d of p){const l=await d.key,c=await d.value;m.push({key:l,value:c,alwaysSet:d.alwaysSet})}return m}).then(m=>Ie.mergeObjectSync(i,m)):Ie.mergeObjectSync(i,p)}get shape(){return this._def.shape()}strict(e){return V.errToObj,new ye({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,i)=>{const r=this._def.errorMap?.(t,i).message??i.defaultError;return t.code==="unrecognized_keys"?{message:V.errToObj(e).message??r}:{message:r}}}:{}})}strip(){return new ye({...this._def,unknownKeys:"strip"})}passthrough(){return new ye({...this._def,unknownKeys:"passthrough"})}extend(e){return new ye({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ye({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ee.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ye({...this._def,catchall:e})}pick(e){const t={};for(const i of oe.objectKeys(e))e[i]&&this.shape[i]&&(t[i]=this.shape[i]);return new ye({...this._def,shape:()=>t})}omit(e){const t={};for(const i of oe.objectKeys(this.shape))e[i]||(t[i]=this.shape[i]);return new ye({...this._def,shape:()=>t})}deepPartial(){return Et(this)}partial(e){const t={};for(const i of oe.objectKeys(this.shape)){const r=this.shape[i];e&&!e[i]?t[i]=r:t[i]=r.optional()}return new ye({...this._def,shape:()=>t})}required(e){const t={};for(const i of oe.objectKeys(this.shape))if(e&&!e[i])t[i]=this.shape[i];else{let n=this.shape[i];for(;n instanceof rt;)n=n._def.innerType;t[i]=n}return new ye({...this._def,shape:()=>t})}keyof(){return Ks(oe.objectKeys(this.shape))}}ye.create=(s,e)=>new ye({shape:()=>s,unknownKeys:"strip",catchall:st.create(),typeName:ee.ZodObject,...ie(e)}),ye.strictCreate=(s,e)=>new ye({shape:()=>s,unknownKeys:"strict",catchall:st.create(),typeName:ee.ZodObject,...ie(e)}),ye.lazycreate=(s,e)=>new ye({shape:s,unknownKeys:"strip",catchall:st.create(),typeName:ee.ZodObject,...ie(e)});class hi extends ae{_parse(e){const{ctx:t}=this._processInputParams(e),i=this._def.options;function r(n){for(const a of n)if(a.result.status==="valid")return a.result;for(const a of n)if(a.result.status==="dirty")return t.common.issues.push(...a.ctx.common.issues),a.result;const o=n.map(a=>new qe(a.ctx.common.issues));return H(t,{code:M.invalid_union,unionErrors:o}),J}if(t.common.async)return Promise.all(i.map(async n=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await n._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(r);{let n;const o=[];for(const p of i){const m={...t,common:{...t.common,issues:[]},parent:null},d=p._parseSync({data:t.data,path:t.path,parent:m});if(d.status==="valid")return d;d.status==="dirty"&&!n&&(n={result:d,ctx:m}),m.common.issues.length&&o.push(m.common.issues)}if(n)return t.common.issues.push(...n.ctx.common.issues),n.result;const a=o.map(p=>new qe(p));return H(t,{code:M.invalid_union,unionErrors:a}),J}}get options(){return this._def.options}}hi.create=(s,e)=>new hi({options:s,typeName:ee.ZodUnion,...ie(e)});function $i(s,e){const t=et(s),i=et(e);if(s===e)return{valid:!0,data:s};if(t===j.object&&i===j.object){const r=oe.objectKeys(e),n=oe.objectKeys(s).filter(a=>r.indexOf(a)!==-1),o={...s,...e};for(const a of n){const p=$i(s[a],e[a]);if(!p.valid)return{valid:!1};o[a]=p.data}return{valid:!0,data:o}}else if(t===j.array&&i===j.array){if(s.length!==e.length)return{valid:!1};const r=[];for(let n=0;n<s.length;n++){const o=s[n],a=e[n],p=$i(o,a);if(!p.valid)return{valid:!1};r.push(p.data)}return{valid:!0,data:r}}else return t===j.date&&i===j.date&&+s==+e?{valid:!0,data:s}:{valid:!1}}class ui extends ae{_parse(e){const{status:t,ctx:i}=this._processInputParams(e),r=(n,o)=>{if(Ls(n)||Ls(o))return J;const a=$i(n.value,o.value);return a.valid?((Bs(n)||Bs(o))&&t.dirty(),{status:t.value,value:a.data}):(H(i,{code:M.invalid_intersection_types}),J)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([n,o])=>r(n,o)):r(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}}ui.create=(s,e,t)=>new ui({left:s,right:e,typeName:ee.ZodIntersection,...ie(t)});class mt extends ae{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==j.array)return H(i,{code:M.invalid_type,expected:j.array,received:i.parsedType}),J;if(i.data.length<this._def.items.length)return H(i,{code:M.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),J;!this._def.rest&&i.data.length>this._def.items.length&&(H(i,{code:M.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...i.data].map((o,a)=>{const p=this._def.items[a]||this._def.rest;return p?p._parse(new tt(i,o,i.path,a)):null}).filter(o=>!!o);return i.common.async?Promise.all(n).then(o=>Ie.mergeArray(t,o)):Ie.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new mt({...this._def,rest:e})}}mt.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new mt({items:s,typeName:ee.ZodTuple,rest:null,...ie(e)})};class Gs extends ae{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==j.map)return H(i,{code:M.invalid_type,expected:j.map,received:i.parsedType}),J;const r=this._def.keyType,n=this._def.valueType,o=[...i.data.entries()].map(([a,p],m)=>({key:r._parse(new tt(i,a,i.path,[m,"key"])),value:n._parse(new tt(i,p,i.path,[m,"value"]))}));if(i.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const p of o){const m=await p.key,d=await p.value;if(m.status==="aborted"||d.status==="aborted")return J;(m.status==="dirty"||d.status==="dirty")&&t.dirty(),a.set(m.value,d.value)}return{status:t.value,value:a}})}else{const a=new Map;for(const p of o){const m=p.key,d=p.value;if(m.status==="aborted"||d.status==="aborted")return J;(m.status==="dirty"||d.status==="dirty")&&t.dirty(),a.set(m.value,d.value)}return{status:t.value,value:a}}}}Gs.create=(s,e,t)=>new Gs({valueType:e,keyType:s,typeName:ee.ZodMap,...ie(t)});class Ut extends ae{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==j.set)return H(i,{code:M.invalid_type,expected:j.set,received:i.parsedType}),J;const r=this._def;r.minSize!==null&&i.data.size<r.minSize.value&&(H(i,{code:M.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&i.data.size>r.maxSize.value&&(H(i,{code:M.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const n=this._def.valueType;function o(p){const m=new Set;for(const d of p){if(d.status==="aborted")return J;d.status==="dirty"&&t.dirty(),m.add(d.value)}return{status:t.value,value:m}}const a=[...i.data.values()].map((p,m)=>n._parse(new tt(i,p,i.path,m)));return i.common.async?Promise.all(a).then(p=>o(p)):o(a)}min(e,t){return new Ut({...this._def,minSize:{value:e,message:V.toString(t)}})}max(e,t){return new Ut({...this._def,maxSize:{value:e,message:V.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ut.create=(s,e)=>new Ut({valueType:s,minSize:null,maxSize:null,typeName:ee.ZodSet,...ie(e)});class Zs extends ae{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Zs.create=(s,e)=>new Zs({getter:s,typeName:ee.ZodLazy,...ie(e)});class Di extends ae{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return H(t,{received:t.data,code:M.invalid_literal,expected:this._def.value}),J}return{status:"valid",value:e.data}}get value(){return this._def.value}}Di.create=(s,e)=>new Di({value:s,typeName:ee.ZodLiteral,...ie(e)});function Ks(s,e){return new At({values:s,typeName:ee.ZodEnum,...ie(e)})}class At extends ae{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),i=this._def.values;return H(t,{expected:oe.joinValues(i),received:t.parsedType,code:M.invalid_type}),J}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),i=this._def.values;return H(t,{received:t.data,code:M.invalid_enum_value,options:i}),J}return Re(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return At.create(e,{...this._def,...t})}exclude(e,t=this._def){return At.create(this.options.filter(i=>!e.includes(i)),{...this._def,...t})}}At.create=Ks;class qs extends ae{_parse(e){const t=oe.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(e);if(i.parsedType!==j.string&&i.parsedType!==j.number){const r=oe.objectValues(t);return H(i,{expected:oe.joinValues(r),received:i.parsedType,code:M.invalid_type}),J}if(this._cache||(this._cache=new Set(oe.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const r=oe.objectValues(t);return H(i,{received:i.data,code:M.invalid_enum_value,options:r}),J}return Re(e.data)}get enum(){return this._def.values}}qs.create=(s,e)=>new qs({values:s,typeName:ee.ZodNativeEnum,...ie(e)});class di extends ae{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==j.promise&&t.common.async===!1)return H(t,{code:M.invalid_type,expected:j.promise,received:t.parsedType}),J;const i=t.parsedType===j.promise?t.data:Promise.resolve(t.data);return Re(i.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}}di.create=(s,e)=>new di({type:s,typeName:ee.ZodPromise,...ie(e)});class It extends ae{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ee.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:i}=this._processInputParams(e),r=this._def.effect||null,n={addIssue:o=>{H(i,o),o.fatal?t.abort():t.dirty()},get path(){return i.path}};if(n.addIssue=n.addIssue.bind(n),r.type==="preprocess"){const o=r.transform(i.data,n);if(i.common.async)return Promise.resolve(o).then(async a=>{if(t.value==="aborted")return J;const p=await this._def.schema._parseAsync({data:a,path:i.path,parent:i});return p.status==="aborted"?J:p.status==="dirty"||t.value==="dirty"?Ht(p.value):p});{if(t.value==="aborted")return J;const a=this._def.schema._parseSync({data:o,path:i.path,parent:i});return a.status==="aborted"?J:a.status==="dirty"||t.value==="dirty"?Ht(a.value):a}}if(r.type==="refinement"){const o=a=>{const p=r.refinement(a,n);if(i.common.async)return Promise.resolve(p);if(p instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(i.common.async===!1){const a=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return a.status==="aborted"?J:(a.status==="dirty"&&t.dirty(),o(a.value),{status:t.value,value:a.value})}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(a=>a.status==="aborted"?J:(a.status==="dirty"&&t.dirty(),o(a.value).then(()=>({status:t.value,value:a.value}))))}if(r.type==="transform")if(i.common.async===!1){const o=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if(!Tt(o))return J;const a=r.transform(o.value,n);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(o=>Tt(o)?Promise.resolve(r.transform(o.value,n)).then(a=>({status:t.value,value:a})):J);oe.assertNever(r)}}It.create=(s,e,t)=>new It({schema:s,typeName:ee.ZodEffects,effect:e,...ie(t)}),It.createWithPreprocess=(s,e,t)=>new It({schema:e,effect:{type:"preprocess",transform:s},typeName:ee.ZodEffects,...ie(t)});class rt extends ae{_parse(e){return this._getType(e)===j.undefined?Re(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}rt.create=(s,e)=>new rt({innerType:s,typeName:ee.ZodOptional,...ie(e)});class Pt extends ae{_parse(e){return this._getType(e)===j.null?Re(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Pt.create=(s,e)=>new Pt({innerType:s,typeName:ee.ZodNullable,...ie(e)});class zi extends ae{_parse(e){const{ctx:t}=this._processInputParams(e);let i=t.data;return t.parsedType===j.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}zi.create=(s,e)=>new zi({innerType:s,typeName:ee.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ie(e)});class Hi extends ae{_parse(e){const{ctx:t}=this._processInputParams(e),i={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:i.data,path:i.path,parent:{...i}});return li(r)?r.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new qe(i.common.issues)},input:i.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new qe(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}}Hi.create=(s,e)=>new Hi({innerType:s,typeName:ee.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ie(e)});class Xs extends ae{_parse(e){if(this._getType(e)!==j.nan){const i=this._getOrReturnCtx(e);return H(i,{code:M.invalid_type,expected:j.nan,received:i.parsedType}),J}return{status:"valid",value:e.data}}}Xs.create=s=>new Xs({typeName:ee.ZodNaN,...ie(s)});class Ea extends ae{_parse(e){const{ctx:t}=this._processInputParams(e),i=t.data;return this._def.type._parse({data:i,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ni extends ae{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:i.data,path:i.path,parent:i});return n.status==="aborted"?J:n.status==="dirty"?(t.dirty(),Ht(n.value)):this._def.out._parseAsync({data:n.value,path:i.path,parent:i})})();{const r=this._def.in._parseSync({data:i.data,path:i.path,parent:i});return r.status==="aborted"?J:r.status==="dirty"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:i.path,parent:i})}}static create(e,t){return new Ni({in:e,out:t,typeName:ee.ZodPipeline})}}class Ui extends ae{_parse(e){const t=this._def.innerType._parse(e),i=r=>(Tt(r)&&(r.value=Object.freeze(r.value)),r);return li(t)?t.then(r=>i(r)):i(t)}unwrap(){return this._def.innerType}}Ui.create=(s,e)=>new Ui({innerType:s,typeName:ee.ZodReadonly,...ie(e)});var ee;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(ee||(ee={}));const pe=it.create,D=St.create,Aa=Bi.create;st.create;const Ys=$e.create,te=ye.create,ji=hi.create;ui.create,mt.create;const nt=Di.create,_e=At.create;di.create,rt.create,Pt.create;const jt=pe().regex(/^#[A-Fa-f0-9]{6}$/,"Invalid hex color format"),Ia=te({offset:D().min(0).max(1),color:jt}).strict(),Pa=te({type:_e(["linear","radial"]).default("linear"),angle:D().min(0).max(360).default(0),stops:Ys(Ia).min(2)}).strict(),Ra=te({family:pe().default("Roboto"),size:D().min(8).max(500).default(48),weight:ji([pe(),D()]).default("400"),style:_e(["normal","italic","oblique"]).default("normal"),color:jt.default("#000000"),opacity:D().min(0).max(1).default(1)}).strict(),Oa=te({letterSpacing:D().default(0),lineHeight:D().min(.1).max(10).default(1.2),textTransform:_e(["none","uppercase","lowercase","capitalize"]).default("none"),textDecoration:_e(["none","underline","line-through"]).default("none"),gradient:Pa.optional()}).strict(),Fa=te({width:D().min(0).default(0),color:jt.default("#000000"),opacity:D().min(0).max(1).default(1)}).strict(),Ma=te({offsetX:D().default(0),offsetY:D().default(0),blur:D().min(0).default(0),color:jt.default("#000000"),opacity:D().min(0).max(1).default(.5)}).strict(),La=te({color:jt.optional(),opacity:D().min(0).max(1).default(1),borderRadius:D().min(0).default(0)}).strict(),Ba=te({horizontal:_e(["left","center","right"]).default("left"),vertical:_e(["top","middle","bottom"]).default("middle")}).strict(),$a=te({preset:_e(["fadeIn","slideIn","typewriter","shift","ascend","movingLetters","bounce","elastic","pulse"]),speed:D().min(.1).max(10).default(1),duration:D().min(.1).max(60).optional(),style:_e(["character","word"]).optional(),direction:_e(["left","right","up","down"]).optional()}).strict(),Da=te({src:pe().url("Invalid font URL"),family:pe(),weight:ji([pe(),D()]).default("400"),style:_e(["normal","italic","oblique"]).default("normal")}).strict(),fi=te({type:nt("rich-text"),text:pe().max(1e4).default(""),width:D().min(1).max(8192).optional(),height:D().min(1).max(8192).optional(),font:Ra.optional(),style:Oa.optional(),stroke:Fa.optional(),shadow:Ma.optional(),background:La.optional(),align:Ba.optional(),animation:$a.optional(),cacheEnabled:Aa().default(!0),pixelRatio:D().min(1).max(4).default(2),customFonts:Ys(Da).optional()}).strict();function Qs(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function za(s){if(s.__esModule)return s;var e=s.default;if(typeof e=="function"){var t=function i(){return this instanceof i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(s).forEach(function(i){var r=Object.getOwnPropertyDescriptor(s,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:function(){return s[i]}})}),t}var Js={exports:{}};(function(s,e){(function(t,i){s.exports=i()})(self,()=>{return t={7629:(r,n,o)=>{const a=o(375),p=o(8571),m=o(9474),d=o(1687),l=o(8652),c=o(8160),u=o(3292),h=o(6354),f=o(8901),b=o(9708),g=o(6914),y=o(2294),v=o(6133),_=o(1152),C=o(8863),S=o(2036),T={Base:class{constructor(w){this.type=w,this.$_root=null,this._definition={},this._reset()}_reset(){this._ids=new y.Ids,this._preferences=null,this._refs=new v.Manager,this._cache=null,this._valids=null,this._invalids=null,this._flags={},this._rules=[],this._singleRules=new Map,this.$_terms={},this.$_temp={ruleset:null,whens:{}}}describe(){return a(typeof b.describe=="function","Manifest functionality disabled"),b.describe(this)}allow(...w){return c.verifyFlat(w,"allow"),this._values(w,"_valids")}alter(w){a(w&&typeof w=="object"&&!Array.isArray(w),"Invalid targets argument"),a(!this._inRuleset(),"Cannot set alterations inside a ruleset");const x=this.clone();x.$_terms.alterations=x.$_terms.alterations||[];for(const k in w){const E=w[k];a(typeof E=="function","Alteration adjuster for",k,"must be a function"),x.$_terms.alterations.push({target:k,adjuster:E})}return x.$_temp.ruleset=!1,x}artifact(w){return a(w!==void 0,"Artifact cannot be undefined"),a(!this._cache,"Cannot set an artifact with a rule cache"),this.$_setFlag("artifact",w)}cast(w){return a(w===!1||typeof w=="string","Invalid to value"),a(w===!1||this._definition.cast[w],"Type",this.type,"does not support casting to",w),this.$_setFlag("cast",w===!1?void 0:w)}default(w,x){return this._default("default",w,x)}description(w){return a(w&&typeof w=="string","Description must be a non-empty string"),this.$_setFlag("description",w)}empty(w){const x=this.clone();return w!==void 0&&(w=x.$_compile(w,{override:!1})),x.$_setFlag("empty",w,{clone:!1})}error(w){return a(w,"Missing error"),a(w instanceof Error||typeof w=="function","Must provide a valid Error object or a function"),this.$_setFlag("error",w)}example(w,x={}){return a(w!==void 0,"Missing example"),c.assertOptions(x,["override"]),this._inner("examples",w,{single:!0,override:x.override})}external(w,x){return typeof w=="object"&&(a(!x,"Cannot combine options with description"),x=w.description,w=w.method),a(typeof w=="function","Method must be a function"),a(x===void 0||x&&typeof x=="string","Description must be a non-empty string"),this._inner("externals",{method:w,description:x},{single:!0})}failover(w,x){return this._default("failover",w,x)}forbidden(){return this.presence("forbidden")}id(w){return w?(a(typeof w=="string","id must be a non-empty string"),a(/^[^\.]+$/.test(w),"id cannot contain period character"),this.$_setFlag("id",w)):this.$_setFlag("id",void 0)}invalid(...w){return this._values(w,"_invalids")}label(w){return a(w&&typeof w=="string","Label name must be a non-empty string"),this.$_setFlag("label",w)}meta(w){return a(w!==void 0,"Meta cannot be undefined"),this._inner("metas",w,{single:!0})}note(...w){a(w.length,"Missing notes");for(const x of w)a(x&&typeof x=="string","Notes must be non-empty strings");return this._inner("notes",w)}only(w=!0){return a(typeof w=="boolean","Invalid mode:",w),this.$_setFlag("only",w)}optional(){return this.presence("optional")}prefs(w){a(w,"Missing preferences"),a(w.context===void 0,"Cannot override context"),a(w.externals===void 0,"Cannot override externals"),a(w.warnings===void 0,"Cannot override warnings"),a(w.debug===void 0,"Cannot override debug"),c.checkPreferences(w);const x=this.clone();return x._preferences=c.preferences(x._preferences,w),x}presence(w){return a(["optional","required","forbidden"].includes(w),"Unknown presence mode",w),this.$_setFlag("presence",w)}raw(w=!0){return this.$_setFlag("result",w?"raw":void 0)}result(w){return a(["raw","strip"].includes(w),"Unknown result mode",w),this.$_setFlag("result",w)}required(){return this.presence("required")}strict(w){const x=this.clone(),k=w!==void 0&&!w;return x._preferences=c.preferences(x._preferences,{convert:k}),x}strip(w=!0){return this.$_setFlag("result",w?"strip":void 0)}tag(...w){a(w.length,"Missing tags");for(const x of w)a(x&&typeof x=="string","Tags must be non-empty strings");return this._inner("tags",w)}unit(w){return a(w&&typeof w=="string","Unit name must be a non-empty string"),this.$_setFlag("unit",w)}valid(...w){c.verifyFlat(w,"valid");const x=this.allow(...w);return x.$_setFlag("only",!!x._valids,{clone:!1}),x}when(w,x){const k=this.clone();k.$_terms.whens||(k.$_terms.whens=[]);const E=u.when(k,w,x);if(!["any","link"].includes(k.type)){const P=E.is?[E]:E.switch;for(const O of P)a(!O.then||O.then.type==="any"||O.then.type===k.type,"Cannot combine",k.type,"with",O.then&&O.then.type),a(!O.otherwise||O.otherwise.type==="any"||O.otherwise.type===k.type,"Cannot combine",k.type,"with",O.otherwise&&O.otherwise.type)}return k.$_terms.whens.push(E),k.$_mutateRebuild()}cache(w){a(!this._inRuleset(),"Cannot set caching inside a ruleset"),a(!this._cache,"Cannot override schema cache"),a(this._flags.artifact===void 0,"Cannot cache a rule with an artifact");const x=this.clone();return x._cache=w||l.provider.provision(),x.$_temp.ruleset=!1,x}clone(){const w=Object.create(Object.getPrototypeOf(this));return this._assign(w)}concat(w){a(c.isSchema(w),"Invalid schema object"),a(this.type==="any"||w.type==="any"||w.type===this.type,"Cannot merge type",this.type,"with another type:",w.type),a(!this._inRuleset(),"Cannot concatenate onto a schema with open ruleset"),a(!w._inRuleset(),"Cannot concatenate a schema with open ruleset");let x=this.clone();if(this.type==="any"&&w.type!=="any"){const k=w.clone();for(const E of Object.keys(x))E!=="type"&&(k[E]=x[E]);x=k}x._ids.concat(w._ids),x._refs.register(w,v.toSibling),x._preferences=x._preferences?c.preferences(x._preferences,w._preferences):w._preferences,x._valids=S.merge(x._valids,w._valids,w._invalids),x._invalids=S.merge(x._invalids,w._invalids,w._valids);for(const k of w._singleRules.keys())x._singleRules.has(k)&&(x._rules=x._rules.filter(E=>E.keep||E.name!==k),x._singleRules.delete(k));for(const k of w._rules)w._definition.rules[k.method].multi||x._singleRules.set(k.name,k),x._rules.push(k);if(x._flags.empty&&w._flags.empty){x._flags.empty=x._flags.empty.concat(w._flags.empty);const k=Object.assign({},w._flags);delete k.empty,d(x._flags,k)}else if(w._flags.empty){x._flags.empty=w._flags.empty;const k=Object.assign({},w._flags);delete k.empty,d(x._flags,k)}else d(x._flags,w._flags);for(const k in w.$_terms){const E=w.$_terms[k];E?x.$_terms[k]?x.$_terms[k]=x.$_terms[k].concat(E):x.$_terms[k]=E.slice():x.$_terms[k]||(x.$_terms[k]=E)}return this.$_root._tracer&&this.$_root._tracer._combine(x,[this,w]),x.$_mutateRebuild()}extend(w){return a(!w.base,"Cannot extend type with another base"),f.type(this,w)}extract(w){return w=Array.isArray(w)?w:w.split("."),this._ids.reach(w)}fork(w,x){a(!this._inRuleset(),"Cannot fork inside a ruleset");let k=this;for(let E of[].concat(w))E=Array.isArray(E)?E:E.split("."),k=k._ids.fork(E,x,k);return k.$_temp.ruleset=!1,k}rule(w){const x=this._definition;c.assertOptions(w,Object.keys(x.modifiers)),a(this.$_temp.ruleset!==!1,"Cannot apply rules to empty ruleset or the last rule added does not support rule properties");const k=this.$_temp.ruleset===null?this._rules.length-1:this.$_temp.ruleset;a(k>=0&&k<this._rules.length,"Cannot apply rules to empty ruleset");const E=this.clone();for(let P=k;P<E._rules.length;++P){const O=E._rules[P],z=p(O);for(const I in w)x.modifiers[I](z,w[I]),a(z.name===O.name,"Cannot change rule name");E._rules[P]=z,E._singleRules.get(z.name)===O&&E._singleRules.set(z.name,z)}return E.$_temp.ruleset=!1,E.$_mutateRebuild()}get ruleset(){a(!this._inRuleset(),"Cannot start a new ruleset without closing the previous one");const w=this.clone();return w.$_temp.ruleset=w._rules.length,w}get $(){return this.ruleset}tailor(w){w=[].concat(w),a(!this._inRuleset(),"Cannot tailor inside a ruleset");let x=this;if(this.$_terms.alterations)for(const{target:k,adjuster:E}of this.$_terms.alterations)w.includes(k)&&(x=E(x),a(c.isSchema(x),"Alteration adjuster for",k,"failed to return a schema object"));return x=x.$_modify({each:k=>k.tailor(w),ref:!1}),x.$_temp.ruleset=!1,x.$_mutateRebuild()}tracer(){return _.location?_.location(this):this}validate(w,x){return C.entry(w,this,x)}validateAsync(w,x){return C.entryAsync(w,this,x)}$_addRule(w){typeof w=="string"&&(w={name:w}),a(w&&typeof w=="object","Invalid options"),a(w.name&&typeof w.name=="string","Invalid rule name");for(const O in w)a(O[0]!=="_","Cannot set private rule properties");const x=Object.assign({},w);x._resolve=[],x.method=x.method||x.name;const k=this._definition.rules[x.method],E=x.args;a(k,"Unknown rule",x.method);const P=this.clone();if(E){a(Object.keys(E).length===1||Object.keys(E).length===this._definition.rules[x.name].args.length,"Invalid rule definition for",this.type,x.name);for(const O in E){let z=E[O];if(k.argsByName){const I=k.argsByName.get(O);if(I.ref&&c.isResolvable(z))x._resolve.push(O),P.$_mutateRegister(z);else if(I.normalize&&(z=I.normalize(z),E[O]=z),I.assert){const L=c.validateArg(z,O,I);a(!L,L,"or reference")}}z!==void 0?E[O]=z:delete E[O]}}return k.multi||(P._ruleRemove(x.name,{clone:!1}),P._singleRules.set(x.name,x)),P.$_temp.ruleset===!1&&(P.$_temp.ruleset=null),k.priority?P._rules.unshift(x):P._rules.push(x),P}$_compile(w,x){return u.schema(this.$_root,w,x)}$_createError(w,x,k,E,P,O={}){const z=O.flags!==!1?this._flags:{},I=O.messages?g.merge(this._definition.messages,O.messages):this._definition.messages;return new h.Report(w,x,k,z,I,E,P)}$_getFlag(w){return this._flags[w]}$_getRule(w){return this._singleRules.get(w)}$_mapLabels(w){return w=Array.isArray(w)?w:w.split("."),this._ids.labels(w)}$_match(w,x,k,E){(k=Object.assign({},k)).abortEarly=!0,k._externals=!1,x.snapshot();const P=!C.validate(w,this,x,k,E).errors;return x.restore(),P}$_modify(w){return c.assertOptions(w,["each","once","ref","schema"]),y.schema(this,w)||this}$_mutateRebuild(){return a(!this._inRuleset(),"Cannot add this rule inside a ruleset"),this._refs.reset(),this._ids.reset(),this.$_modify({each:(w,{source:x,name:k,path:E,key:P})=>{const O=this._definition[x][k]&&this._definition[x][k].register;O!==!1&&this.$_mutateRegister(w,{family:O,key:P})}}),this._definition.rebuild&&this._definition.rebuild(this),this.$_temp.ruleset=!1,this}$_mutateRegister(w,{family:x,key:k}={}){this._refs.register(w,x),this._ids.register(w,{key:k})}$_property(w){return this._definition.properties[w]}$_reach(w){return this._ids.reach(w)}$_rootReferences(){return this._refs.roots()}$_setFlag(w,x,k={}){a(w[0]==="_"||!this._inRuleset(),"Cannot set flag inside a ruleset");const E=this._definition.flags[w]||{};if(m(x,E.default)&&(x=void 0),m(x,this._flags[w]))return this;const P=k.clone!==!1?this.clone():this;return x!==void 0?(P._flags[w]=x,P.$_mutateRegister(x)):delete P._flags[w],w[0]!=="_"&&(P.$_temp.ruleset=!1),P}$_parent(w,...x){return this[w][c.symbols.parent].call(this,...x)}$_validate(w,x,k){return C.validate(w,this,x,k)}_assign(w){w.type=this.type,w.$_root=this.$_root,w.$_temp=Object.assign({},this.$_temp),w.$_temp.whens={},w._ids=this._ids.clone(),w._preferences=this._preferences,w._valids=this._valids&&this._valids.clone(),w._invalids=this._invalids&&this._invalids.clone(),w._rules=this._rules.slice(),w._singleRules=p(this._singleRules,{shallow:!0}),w._refs=this._refs.clone(),w._flags=Object.assign({},this._flags),w._cache=null,w.$_terms={};for(const x in this.$_terms)w.$_terms[x]=this.$_terms[x]?this.$_terms[x].slice():null;w.$_super={};for(const x in this.$_super)w.$_super[x]=this._super[x].bind(w);return w}_bare(){const w=this.clone();w._reset();const x=w._definition.terms;for(const k in x){const E=x[k];w.$_terms[k]=E.init}return w.$_mutateRebuild()}_default(w,x,k={}){return c.assertOptions(k,"literal"),a(x!==void 0,"Missing",w,"value"),a(typeof x=="function"||!k.literal,"Only function value supports literal option"),typeof x=="function"&&k.literal&&(x={[c.symbols.literal]:!0,literal:x}),this.$_setFlag(w,x)}_generate(w,x,k){if(!this.$_terms.whens)return{schema:this};const E=[],P=[];for(let I=0;I<this.$_terms.whens.length;++I){const L=this.$_terms.whens[I];if(L.concat){E.push(L.concat),P.push(`${I}.concat`);continue}const F=L.ref?L.ref.resolve(w,x,k):w,Z=L.is?[L]:L.switch,Q=P.length;for(let X=0;X<Z.length;++X){const{is:Y,then:se,otherwise:re}=Z[X],Ce=`${I}${L.switch?"."+X:""}`;if(Y.$_match(F,x.nest(Y,`${Ce}.is`),k)){if(se){const ve=x.localize([...x.path,`${Ce}.then`],x.ancestors,x.schemas),{schema:ge,id:de}=se._generate(w,ve,k);E.push(ge),P.push(`${Ce}.then${de?`(${de})`:""}`);break}}else if(re){const ve=x.localize([...x.path,`${Ce}.otherwise`],x.ancestors,x.schemas),{schema:ge,id:de}=re._generate(w,ve,k);E.push(ge),P.push(`${Ce}.otherwise${de?`(${de})`:""}`);break}}if(L.break&&P.length>Q)break}const O=P.join(", ");if(x.mainstay.tracer.debug(x,"rule","when",O),!O)return{schema:this};if(!x.mainstay.tracer.active&&this.$_temp.whens[O])return{schema:this.$_temp.whens[O],id:O};let z=this;this._definition.generate&&(z=this._definition.generate(this,w,x,k));for(const I of E)z=z.concat(I);return this.$_root._tracer&&this.$_root._tracer._combine(z,[this,...E]),this.$_temp.whens[O]=z,{schema:z,id:O}}_inner(w,x,k={}){a(!this._inRuleset(),`Cannot set ${w} inside a ruleset`);const E=this.clone();return E.$_terms[w]&&!k.override||(E.$_terms[w]=[]),k.single?E.$_terms[w].push(x):E.$_terms[w].push(...x),E.$_temp.ruleset=!1,E}_inRuleset(){return this.$_temp.ruleset!==null&&this.$_temp.ruleset!==!1}_ruleRemove(w,x={}){if(!this._singleRules.has(w))return this;const k=x.clone!==!1?this.clone():this;k._singleRules.delete(w);const E=[];for(let P=0;P<k._rules.length;++P){const O=k._rules[P];O.name!==w||O.keep?E.push(O):k._inRuleset()&&P<k.$_temp.ruleset&&--k.$_temp.ruleset}return k._rules=E,k}_values(w,x){c.verifyFlat(w,x.slice(1,-1));const k=this.clone(),E=w[0]===c.symbols.override;if(E&&(w=w.slice(1)),!k[x]&&w.length?k[x]=new S:E&&(k[x]=w.length?new S:null,k.$_mutateRebuild()),!k[x])return k;E&&k[x].override();for(const P of w){a(P!==void 0,"Cannot call allow/valid/invalid with undefined"),a(P!==c.symbols.override,"Override must be the first value");const O=x==="_invalids"?"_valids":"_invalids";k[O]&&(k[O].remove(P),k[O].length||(a(x==="_valids"||!k._flags.only,"Setting invalid value",P,"leaves schema rejecting all values due to previous valid rule"),k[O]=null)),k[x].add(P,k._refs)}return k}}};T.Base.prototype[c.symbols.any]={version:c.version,compile:u.compile,root:"$_root"},T.Base.prototype.isImmutable=!0,T.Base.prototype.deny=T.Base.prototype.invalid,T.Base.prototype.disallow=T.Base.prototype.invalid,T.Base.prototype.equal=T.Base.prototype.valid,T.Base.prototype.exist=T.Base.prototype.required,T.Base.prototype.not=T.Base.prototype.invalid,T.Base.prototype.options=T.Base.prototype.prefs,T.Base.prototype.preferences=T.Base.prototype.prefs,r.exports=new T.Base},8652:(r,n,o)=>{const a=o(375),p=o(8571),m=o(8160),d={max:1e3,supported:new Set(["undefined","boolean","number","string"])};n.provider={provision:l=>new d.Cache(l)},d.Cache=class{constructor(l={}){m.assertOptions(l,["max"]),a(l.max===void 0||l.max&&l.max>0&&isFinite(l.max),"Invalid max cache size"),this._max=l.max||d.max,this._map=new Map,this._list=new d.List}get length(){return this._map.size}set(l,c){if(l!==null&&!d.supported.has(typeof l))return;let u=this._map.get(l);if(u)return u.value=c,void this._list.first(u);u=this._list.unshift({key:l,value:c}),this._map.set(l,u),this._compact()}get(l){const c=this._map.get(l);if(c)return this._list.first(c),p(c.value)}_compact(){if(this._map.size>this._max){const l=this._list.pop();this._map.delete(l.key)}}},d.List=class{constructor(){this.tail=null,this.head=null}unshift(l){return l.next=null,l.prev=this.head,this.head&&(this.head.next=l),this.head=l,this.tail||(this.tail=l),l}first(l){l!==this.head&&(this._remove(l),this.unshift(l))}pop(){return this._remove(this.tail)}_remove(l){const{next:c,prev:u}=l;return c.prev=u,u&&(u.next=c),l===this.tail&&(this.tail=c),l.prev=null,l.next=null,l}}},8160:(r,n,o)=>{const a=o(375),p=o(7916),m=o(5934);let d,l;const c={isoDate:/^(?:[-+]\d{2})?(?:\d{4}(?!\d{2}\b))(?:(-?)(?:(?:0[1-9]|1[0-2])(?:\1(?:[12]\d|0[1-9]|3[01]))?|W(?:[0-4]\d|5[0-2])(?:-?[1-7])?|(?:00[1-9]|0[1-9]\d|[12]\d{2}|3(?:[0-5]\d|6[1-6])))(?![T]$|[T][\d]+Z$)(?:[T\s](?:(?:(?:[01]\d|2[0-3])(?:(:?)[0-5]\d)?|24\:?00)(?:[.,]\d+(?!:))?)(?:\2[0-5]\d(?:[.,]\d+)?)?(?:[Z]|(?:[+-])(?:[01]\d|2[0-3])(?::?[0-5]\d)?)?)?)?$/};n.version=m.version,n.defaults={abortEarly:!0,allowUnknown:!1,artifacts:!1,cache:!0,context:null,convert:!0,dateFormat:"iso",errors:{escapeHtml:!1,label:"path",language:null,render:!0,stack:!1,wrap:{label:'"',array:"[]"}},externals:!0,messages:{},nonEnumerables:!1,noDefaults:!1,presence:"optional",skipFunctions:!1,stripUnknown:!1,warnings:!1},n.symbols={any:Symbol.for("@hapi/joi/schema"),arraySingle:Symbol("arraySingle"),deepDefault:Symbol("deepDefault"),errors:Symbol("errors"),literal:Symbol("literal"),override:Symbol("override"),parent:Symbol("parent"),prefs:Symbol("prefs"),ref:Symbol("ref"),template:Symbol("template"),values:Symbol("values")},n.assertOptions=function(u,h,f="Options"){a(u&&typeof u=="object"&&!Array.isArray(u),"Options must be of type object");const b=Object.keys(u).filter(g=>!h.includes(g));a(b.length===0,`${f} contain unknown keys: ${b}`)},n.checkPreferences=function(u){l=l||o(3378);const h=l.preferences.validate(u);if(h.error)throw new p([h.error.details[0].message])},n.compare=function(u,h,f){switch(f){case"=":return u===h;case">":return u>h;case"<":return u<h;case">=":return u>=h;case"<=":return u<=h}},n.default=function(u,h){return u===void 0?h:u},n.isIsoDate=function(u){return c.isoDate.test(u)},n.isNumber=function(u){return typeof u=="number"&&!isNaN(u)},n.isResolvable=function(u){return!!u&&(u[n.symbols.ref]||u[n.symbols.template])},n.isSchema=function(u,h={}){const f=u&&u[n.symbols.any];return!!f&&(a(h.legacy||f.version===n.version,"Cannot mix different versions of joi schemas"),!0)},n.isValues=function(u){return u[n.symbols.values]},n.limit=function(u){return Number.isSafeInteger(u)&&u>=0},n.preferences=function(u,h){d=d||o(6914),u=u||{},h=h||{};const f=Object.assign({},u,h);return h.errors&&u.errors&&(f.errors=Object.assign({},u.errors,h.errors),f.errors.wrap=Object.assign({},u.errors.wrap,h.errors.wrap)),h.messages&&(f.messages=d.compile(h.messages,u.messages)),delete f[n.symbols.prefs],f},n.tryWithPath=function(u,h,f={}){try{return u()}catch(b){throw b.path!==void 0?b.path=h+"."+b.path:b.path=h,f.append&&(b.message=`${b.message} (${b.path})`),b}},n.validateArg=function(u,h,{assert:f,message:b}){if(n.isSchema(f)){const g=f.validate(u);return g.error?g.error.message:void 0}if(!f(u))return h?`${h} ${b}`:b},n.verifyFlat=function(u,h){for(const f of u)a(!Array.isArray(f),"Method no longer accepts array arguments:",h)}},3292:(r,n,o)=>{const a=o(375),p=o(8160),m=o(6133),d={};n.schema=function(l,c,u={}){p.assertOptions(u,["appendPath","override"]);try{return d.schema(l,c,u)}catch(h){throw u.appendPath&&h.path!==void 0&&(h.message=`${h.message} (${h.path})`),h}},d.schema=function(l,c,u){a(c!==void 0,"Invalid undefined schema"),Array.isArray(c)&&(a(c.length,"Invalid empty array schema"),c.length===1&&(c=c[0]));const h=(f,...b)=>u.override!==!1?f.valid(l.override,...b):f.valid(...b);if(d.simple(c))return h(l,c);if(typeof c=="function")return l.custom(c);if(a(typeof c=="object","Invalid schema content:",typeof c),p.isResolvable(c))return h(l,c);if(p.isSchema(c))return c;if(Array.isArray(c)){for(const f of c)if(!d.simple(f))return l.alternatives().try(...c);return h(l,...c)}return c instanceof RegExp?l.string().regex(c):c instanceof Date?h(l.date(),c):(a(Object.getPrototypeOf(c)===Object.getPrototypeOf({}),"Schema can only contain plain objects"),l.object().keys(c))},n.ref=function(l,c){return m.isRef(l)?l:m.create(l,c)},n.compile=function(l,c,u={}){p.assertOptions(u,["legacy"]);const h=c&&c[p.symbols.any];if(h)return a(u.legacy||h.version===p.version,"Cannot mix different versions of joi schemas:",h.version,p.version),c;if(typeof c!="object"||!u.legacy)return n.schema(l,c,{appendPath:!0});const f=d.walk(c);return f?f.compile(f.root,c):n.schema(l,c,{appendPath:!0})},d.walk=function(l){if(typeof l!="object")return null;if(Array.isArray(l)){for(const u of l){const h=d.walk(u);if(h)return h}return null}const c=l[p.symbols.any];if(c)return{root:l[c.root],compile:c.compile};a(Object.getPrototypeOf(l)===Object.getPrototypeOf({}),"Schema can only contain plain objects");for(const u in l){const h=d.walk(l[u]);if(h)return h}return null},d.simple=function(l){return l===null||["boolean","string","number"].includes(typeof l)},n.when=function(l,c,u){if(u===void 0&&(a(c&&typeof c=="object","Missing options"),u=c,c=m.create(".")),Array.isArray(u)&&(u={switch:u}),p.assertOptions(u,["is","not","then","otherwise","switch","break"]),p.isSchema(c))return a(u.is===void 0,'"is" can not be used with a schema condition'),a(u.not===void 0,'"not" can not be used with a schema condition'),a(u.switch===void 0,'"switch" can not be used with a schema condition'),d.condition(l,{is:c,then:u.then,otherwise:u.otherwise,break:u.break});if(a(m.isRef(c)||typeof c=="string","Invalid condition:",c),a(u.not===void 0||u.is===void 0,'Cannot combine "is" with "not"'),u.switch===void 0){let f=u;u.not!==void 0&&(f={is:u.not,then:u.otherwise,otherwise:u.then,break:u.break});let b=f.is!==void 0?l.$_compile(f.is):l.$_root.invalid(null,!1,0,"").required();return a(f.then!==void 0||f.otherwise!==void 0,'options must have at least one of "then", "otherwise", or "switch"'),a(f.break===void 0||f.then===void 0||f.otherwise===void 0,"Cannot specify then, otherwise, and break all together"),u.is===void 0||m.isRef(u.is)||p.isSchema(u.is)||(b=b.required()),d.condition(l,{ref:n.ref(c),is:b,then:f.then,otherwise:f.otherwise,break:f.break})}a(Array.isArray(u.switch),'"switch" must be an array'),a(u.is===void 0,'Cannot combine "switch" with "is"'),a(u.not===void 0,'Cannot combine "switch" with "not"'),a(u.then===void 0,'Cannot combine "switch" with "then"');const h={ref:n.ref(c),switch:[],break:u.break};for(let f=0;f<u.switch.length;++f){const b=u.switch[f],g=f===u.switch.length-1;p.assertOptions(b,g?["is","then","otherwise"]:["is","then"]),a(b.is!==void 0,'Switch statement missing "is"'),a(b.then!==void 0,'Switch statement missing "then"');const y={is:l.$_compile(b.is),then:l.$_compile(b.then)};if(m.isRef(b.is)||p.isSchema(b.is)||(y.is=y.is.required()),g){a(u.otherwise===void 0||b.otherwise===void 0,'Cannot specify "otherwise" inside and outside a "switch"');const v=u.otherwise!==void 0?u.otherwise:b.otherwise;v!==void 0&&(a(h.break===void 0,"Cannot specify both otherwise and break"),y.otherwise=l.$_compile(v))}h.switch.push(y)}return h},d.condition=function(l,c){for(const u of["then","otherwise"])c[u]===void 0?delete c[u]:c[u]=l.$_compile(c[u]);return c}},6354:(r,n,o)=>{const a=o(5688),p=o(8160),m=o(3328);n.Report=class{constructor(d,l,c,u,h,f,b){if(this.code=d,this.flags=u,this.messages=h,this.path=f.path,this.prefs=b,this.state=f,this.value=l,this.message=null,this.template=null,this.local=c||{},this.local.label=n.label(this.flags,this.state,this.prefs,this.messages),this.value===void 0||this.local.hasOwnProperty("value")||(this.local.value=this.value),this.path.length){const g=this.path[this.path.length-1];typeof g!="object"&&(this.local.key=g)}}_setTemplate(d){if(this.template=d,!this.flags.label&&this.path.length===0){const l=this._template(this.template,"root");l&&(this.local.label=l)}}toString(){if(this.message)return this.message;const d=this.code;if(!this.prefs.errors.render)return this.code;const l=this._template(this.template)||this._template(this.prefs.messages)||this._template(this.messages);return l===void 0?`Error code "${d}" is not defined, your custom type is missing the correct messages definition`:(this.message=l.render(this.value,this.state,this.prefs,this.local,{errors:this.prefs.errors,messages:[this.prefs.messages,this.messages]}),this.prefs.errors.label||(this.message=this.message.replace(/^"" /,"").trim()),this.message)}_template(d,l){return n.template(this.value,d,l||this.code,this.state,this.prefs)}},n.path=function(d){let l="";for(const c of d)typeof c!="object"&&(typeof c=="string"?(l&&(l+="."),l+=c):l+=`[${c}]`);return l},n.template=function(d,l,c,u,h){if(!l)return;if(m.isTemplate(l))return c!=="root"?l:null;let f=h.errors.language;if(p.isResolvable(f)&&(f=f.resolve(d,u,h)),f&&l[f]){if(l[f][c]!==void 0)return l[f][c];if(l[f]["*"]!==void 0)return l[f]["*"]}return l[c]?l[c]:l["*"]},n.label=function(d,l,c,u){if(!c.errors.label)return"";if(d.label)return d.label;let h=l.path;return c.errors.label==="key"&&l.path.length>1&&(h=l.path.slice(-1)),n.path(h)||n.template(null,c.messages,"root",l,c)||u&&n.template(null,u,"root",l,c)||"value"},n.process=function(d,l,c){if(!d)return null;const{override:u,message:h,details:f}=n.details(d);if(u)return u;if(c.errors.stack)return new n.ValidationError(h,f,l);const b=Error.stackTraceLimit;Error.stackTraceLimit=0;const g=new n.ValidationError(h,f,l);return Error.stackTraceLimit=b,g},n.details=function(d,l={}){let c=[];const u=[];for(const h of d){if(h instanceof Error){if(l.override!==!1)return{override:h};const b=h.toString();c.push(b),u.push({message:b,type:"override",context:{error:h}});continue}const f=h.toString();c.push(f),u.push({message:f,path:h.path.filter(b=>typeof b!="object"),type:h.code,context:h.local})}return c.length>1&&(c=[...new Set(c)]),{message:c.join(". "),details:u}},n.ValidationError=class extends Error{constructor(d,l,c){super(d),this._original=c,this.details=l}static isError(d){return d instanceof n.ValidationError}},n.ValidationError.prototype.isJoi=!0,n.ValidationError.prototype.name="ValidationError",n.ValidationError.prototype.annotate=a.error},8901:(r,n,o)=>{const a=o(375),p=o(8571),m=o(8160),d=o(6914),l={};n.type=function(c,u){const h=Object.getPrototypeOf(c),f=p(h),b=c._assign(Object.create(f)),g=Object.assign({},u);delete g.base,f._definition=g;const y=h._definition||{};g.messages=d.merge(y.messages,g.messages),g.properties=Object.assign({},y.properties,g.properties),b.type=g.type,g.flags=Object.assign({},y.flags,g.flags);const v=Object.assign({},y.terms);if(g.terms)for(const T in g.terms){const w=g.terms[T];a(b.$_terms[T]===void 0,"Invalid term override for",g.type,T),b.$_terms[T]=w.init,v[T]=w}g.terms=v,g.args||(g.args=y.args),g.prepare=l.prepare(g.prepare,y.prepare),g.coerce&&(typeof g.coerce=="function"&&(g.coerce={method:g.coerce}),g.coerce.from&&!Array.isArray(g.coerce.from)&&(g.coerce={method:g.coerce.method,from:[].concat(g.coerce.from)})),g.coerce=l.coerce(g.coerce,y.coerce),g.validate=l.validate(g.validate,y.validate);const _=Object.assign({},y.rules);if(g.rules)for(const T in g.rules){const w=g.rules[T];a(typeof w=="object","Invalid rule definition for",g.type,T);let x=w.method;if(x===void 0&&(x=function(){return this.$_addRule(T)}),x&&(a(!f[T],"Rule conflict in",g.type,T),f[T]=x),a(!_[T],"Rule conflict in",g.type,T),_[T]=w,w.alias){const k=[].concat(w.alias);for(const E of k)f[E]=w.method}w.args&&(w.argsByName=new Map,w.args=w.args.map(k=>(typeof k=="string"&&(k={name:k}),a(!w.argsByName.has(k.name),"Duplicated argument name",k.name),m.isSchema(k.assert)&&(k.assert=k.assert.strict().label(k.name)),w.argsByName.set(k.name,k),k)))}g.rules=_;const C=Object.assign({},y.modifiers);if(g.modifiers)for(const T in g.modifiers){a(!f[T],"Rule conflict in",g.type,T);const w=g.modifiers[T];a(typeof w=="function","Invalid modifier definition for",g.type,T);const x=function(k){return this.rule({[T]:k})};f[T]=x,C[T]=w}if(g.modifiers=C,g.overrides){f._super=h,b.$_super={};for(const T in g.overrides)a(h[T],"Cannot override missing",T),g.overrides[T][m.symbols.parent]=h[T],b.$_super[T]=h[T].bind(b);Object.assign(f,g.overrides)}g.cast=Object.assign({},y.cast,g.cast);const S=Object.assign({},y.manifest,g.manifest);return S.build=l.build(g.manifest&&g.manifest.build,y.manifest&&y.manifest.build),g.manifest=S,g.rebuild=l.rebuild(g.rebuild,y.rebuild),b},l.build=function(c,u){return c&&u?function(h,f){return u(c(h,f),f)}:c||u},l.coerce=function(c,u){return c&&u?{from:c.from&&u.from?[...new Set([...c.from,...u.from])]:null,method(h,f){let b;if((!u.from||u.from.includes(typeof h))&&(b=u.method(h,f),b)){if(b.errors||b.value===void 0)return b;h=b.value}if(!c.from||c.from.includes(typeof h)){const g=c.method(h,f);if(g)return g}return b}}:c||u},l.prepare=function(c,u){return c&&u?function(h,f){const b=c(h,f);if(b){if(b.errors||b.value===void 0)return b;h=b.value}return u(h,f)||b}:c||u},l.rebuild=function(c,u){return c&&u?function(h){u(h),c(h)}:c||u},l.validate=function(c,u){return c&&u?function(h,f){const b=u(h,f);if(b){if(b.errors&&(!Array.isArray(b.errors)||b.errors.length))return b;h=b.value}return c(h,f)||b}:c||u}},5107:(r,n,o)=>{const a=o(375),p=o(8571),m=o(8652),d=o(8160),l=o(3292),c=o(6354),u=o(8901),h=o(9708),f=o(6133),b=o(3328),g=o(1152);let y;const v={types:{alternatives:o(4946),any:o(8068),array:o(546),boolean:o(4937),date:o(7500),function:o(390),link:o(8785),number:o(3832),object:o(8966),string:o(7417),symbol:o(8826)},aliases:{alt:"alternatives",bool:"boolean",func:"function"},root:function(){const _={_types:new Set(Object.keys(v.types))};for(const C of _._types)_[C]=function(...S){return a(!S.length||["alternatives","link","object"].includes(C),"The",C,"type does not allow arguments"),v.generate(this,v.types[C],S)};for(const C of["allow","custom","disallow","equal","exist","forbidden","invalid","not","only","optional","options","prefs","preferences","required","strip","valid","when"])_[C]=function(...S){return this.any()[C](...S)};Object.assign(_,v.methods);for(const C in v.aliases){const S=v.aliases[C];_[C]=_[S]}return _.x=_.expression,g.setup&&g.setup(_),_}};v.methods={ValidationError:c.ValidationError,version:d.version,cache:m.provider,assert(_,C,...S){v.assert(_,C,!0,S)},attempt:(_,C,...S)=>v.assert(_,C,!1,S),build(_){return a(typeof h.build=="function","Manifest functionality disabled"),h.build(this,_)},checkPreferences(_){d.checkPreferences(_)},compile(_,C){return l.compile(this,_,C)},defaults(_){a(typeof _=="function","modifier must be a function");const C=Object.assign({},this);for(const S of C._types){const T=_(C[S]());a(d.isSchema(T),"modifier must return a valid schema object"),C[S]=function(...w){return v.generate(this,T,w)}}return C},expression:(..._)=>new b(..._),extend(..._){d.verifyFlat(_,"extend"),y=y||o(3378),a(_.length,"You need to provide at least one extension"),this.assert(_,y.extensions);const C=Object.assign({},this);C._types=new Set(C._types);for(let S of _){typeof S=="function"&&(S=S(C)),this.assert(S,y.extension);const T=v.expandExtension(S,C);for(const w of T){a(C[w.type]===void 0||C._types.has(w.type),"Cannot override name",w.type);const x=w.base||this.any(),k=u.type(x,w);C._types.add(w.type),C[w.type]=function(...E){return v.generate(this,k,E)}}}return C},isError:c.ValidationError.isError,isExpression:b.isTemplate,isRef:f.isRef,isSchema:d.isSchema,in:(..._)=>f.in(..._),override:d.symbols.override,ref:(..._)=>f.create(..._),types(){const _={};for(const C of this._types)_[C]=this[C]();for(const C in v.aliases)_[C]=this[C]();return _}},v.assert=function(_,C,S,T){const w=T[0]instanceof Error||typeof T[0]=="string"?T[0]:null,x=w!==null?T[1]:T[0],k=C.validate(_,d.preferences({errors:{stack:!0}},x||{}));let E=k.error;if(!E)return k.value;if(w instanceof Error)throw w;const P=S&&typeof E.annotate=="function"?E.annotate():E.message;throw E instanceof c.ValidationError==0&&(E=p(E)),E.message=w?`${w} ${P}`:P,E},v.generate=function(_,C,S){return a(_,"Must be invoked on a Joi instance."),C.$_root=_,C._definition.args&&S.length?C._definition.args(C,...S):C},v.expandExtension=function(_,C){if(typeof _.type=="string")return[_];const S=[];for(const T of C._types)if(_.type.test(T)){const w=Object.assign({},_);w.type=T,w.base=C[T](),S.push(w)}return S},r.exports=v.root()},6914:(r,n,o)=>{const a=o(375),p=o(8571),m=o(3328);n.compile=function(d,l){if(typeof d=="string")return a(!l,"Cannot set single message string"),new m(d);if(m.isTemplate(d))return a(!l,"Cannot set single message template"),d;a(typeof d=="object"&&!Array.isArray(d),"Invalid message options"),l=l?p(l):{};for(let c in d){const u=d[c];if(c==="root"||m.isTemplate(u)){l[c]=u;continue}if(typeof u=="string"){l[c]=new m(u);continue}a(typeof u=="object"&&!Array.isArray(u),"Invalid message for",c);const h=c;for(c in l[h]=l[h]||{},u){const f=u[c];c==="root"||m.isTemplate(f)?l[h][c]=f:(a(typeof f=="string","Invalid message for",c,"in",h),l[h][c]=new m(f))}}return l},n.decompile=function(d){const l={};for(let c in d){const u=d[c];if(c==="root"){l.root=u;continue}if(m.isTemplate(u)){l[c]=u.describe({compact:!0});continue}const h=c;for(c in l[h]={},u){const f=u[c];c!=="root"?l[h][c]=f.describe({compact:!0}):l[h].root=f}}return l},n.merge=function(d,l){if(!d)return n.compile(l);if(!l)return d;if(typeof l=="string")return new m(l);if(m.isTemplate(l))return l;const c=p(d);for(let u in l){const h=l[u];if(u==="root"||m.isTemplate(h)){c[u]=h;continue}if(typeof h=="string"){c[u]=new m(h);continue}a(typeof h=="object"&&!Array.isArray(h),"Invalid message for",u);const f=u;for(u in c[f]=c[f]||{},h){const b=h[u];u==="root"||m.isTemplate(b)?c[f][u]=b:(a(typeof b=="string","Invalid message for",u,"in",f),c[f][u]=new m(b))}}return c}},2294:(r,n,o)=>{const a=o(375),p=o(8160),m=o(6133),d={};n.Ids=d.Ids=class{constructor(){this._byId=new Map,this._byKey=new Map,this._schemaChain=!1}clone(){const l=new d.Ids;return l._byId=new Map(this._byId),l._byKey=new Map(this._byKey),l._schemaChain=this._schemaChain,l}concat(l){l._schemaChain&&(this._schemaChain=!0);for(const[c,u]of l._byId.entries())a(!this._byKey.has(c),"Schema id conflicts with existing key:",c),this._byId.set(c,u);for(const[c,u]of l._byKey.entries())a(!this._byId.has(c),"Schema key conflicts with existing id:",c),this._byKey.set(c,u)}fork(l,c,u){const h=this._collect(l);h.push({schema:u});const f=h.shift();let b={id:f.id,schema:c(f.schema)};a(p.isSchema(b.schema),"adjuster function failed to return a joi schema type");for(const g of h)b={id:g.id,schema:d.fork(g.schema,b.id,b.schema)};return b.schema}labels(l,c=[]){const u=l[0],h=this._get(u);if(!h)return[...c,...l].join(".");const f=l.slice(1);return c=[...c,h.schema._flags.label||u],f.length?h.schema._ids.labels(f,c):c.join(".")}reach(l,c=[]){const u=l[0],h=this._get(u);a(h,"Schema does not contain path",[...c,...l].join("."));const f=l.slice(1);return f.length?h.schema._ids.reach(f,[...c,u]):h.schema}register(l,{key:c}={}){if(!l||!p.isSchema(l))return;(l.$_property("schemaChain")||l._ids._schemaChain)&&(this._schemaChain=!0);const u=l._flags.id;if(u){const h=this._byId.get(u);a(!h||h.schema===l,"Cannot add different schemas with the same id:",u),a(!this._byKey.has(u),"Schema id conflicts with existing key:",u),this._byId.set(u,{schema:l,id:u})}c&&(a(!this._byKey.has(c),"Schema already contains key:",c),a(!this._byId.has(c),"Schema key conflicts with existing id:",c),this._byKey.set(c,{schema:l,id:c}))}reset(){this._byId=new Map,this._byKey=new Map,this._schemaChain=!1}_collect(l,c=[],u=[]){const h=l[0],f=this._get(h);a(f,"Schema does not contain path",[...c,...l].join(".")),u=[f,...u];const b=l.slice(1);return b.length?f.schema._ids._collect(b,[...c,h],u):u}_get(l){return this._byId.get(l)||this._byKey.get(l)}},d.fork=function(l,c,u){const h=n.schema(l,{each:(f,{key:b})=>{if(c===(f._flags.id||b))return u},ref:!1});return h?h.$_mutateRebuild():l},n.schema=function(l,c){let u;for(const h in l._flags){if(h[0]==="_")continue;const f=d.scan(l._flags[h],{source:"flags",name:h},c);f!==void 0&&(u=u||l.clone(),u._flags[h]=f)}for(let h=0;h<l._rules.length;++h){const f=l._rules[h],b=d.scan(f.args,{source:"rules",name:f.name},c);if(b!==void 0){u=u||l.clone();const g=Object.assign({},f);g.args=b,u._rules[h]=g,u._singleRules.get(f.name)===f&&u._singleRules.set(f.name,g)}}for(const h in l.$_terms){if(h[0]==="_")continue;const f=d.scan(l.$_terms[h],{source:"terms",name:h},c);f!==void 0&&(u=u||l.clone(),u.$_terms[h]=f)}return u},d.scan=function(l,c,u,h,f){const b=h||[];if(l===null||typeof l!="object")return;let g;if(Array.isArray(l)){for(let y=0;y<l.length;++y){const v=c.source==="terms"&&c.name==="keys"&&l[y].key,_=d.scan(l[y],c,u,[y,...b],v);_!==void 0&&(g=g||l.slice(),g[y]=_)}return g}if(u.schema!==!1&&p.isSchema(l)||u.ref!==!1&&m.isRef(l)){const y=u.each(l,{...c,path:b,key:f});return y===l?void 0:y}for(const y in l){if(y[0]==="_")continue;const v=d.scan(l[y],c,u,[y,...b],f);v!==void 0&&(g=g||Object.assign({},l),g[y]=v)}return g}},6133:(r,n,o)=>{const a=o(375),p=o(8571),m=o(9621),d=o(8160);let l;const c={symbol:Symbol("ref"),defaults:{adjust:null,in:!1,iterables:null,map:null,separator:".",type:"value"}};n.create=function(u,h={}){a(typeof u=="string","Invalid reference key:",u),d.assertOptions(h,["adjust","ancestor","in","iterables","map","prefix","render","separator"]),a(!h.prefix||typeof h.prefix=="object","options.prefix must be of type object");const f=Object.assign({},c.defaults,h);delete f.prefix;const b=f.separator,g=c.context(u,b,h.prefix);if(f.type=g.type,u=g.key,f.type==="value")if(g.root&&(a(!b||u[0]!==b,"Cannot specify relative path with root prefix"),f.ancestor="root",u||(u=null)),b&&b===u)u=null,f.ancestor=0;else if(f.ancestor!==void 0)a(!b||!u||u[0]!==b,"Cannot combine prefix with ancestor option");else{const[y,v]=c.ancestor(u,b);v&&(u=u.slice(v))===""&&(u=null),f.ancestor=y}return f.path=b?u===null?[]:u.split(b):[u],new c.Ref(f)},n.in=function(u,h={}){return n.create(u,{...h,in:!0})},n.isRef=function(u){return!!u&&!!u[d.symbols.ref]},c.Ref=class{constructor(u){a(typeof u=="object","Invalid reference construction"),d.assertOptions(u,["adjust","ancestor","in","iterables","map","path","render","separator","type","depth","key","root","display"]),a([!1,void 0].includes(u.separator)||typeof u.separator=="string"&&u.separator.length===1,"Invalid separator"),a(!u.adjust||typeof u.adjust=="function","options.adjust must be a function"),a(!u.map||Array.isArray(u.map),"options.map must be an array"),a(!u.map||!u.adjust,"Cannot set both map and adjust options"),Object.assign(this,c.defaults,u),a(this.type==="value"||this.ancestor===void 0,"Non-value references cannot reference ancestors"),Array.isArray(this.map)&&(this.map=new Map(this.map)),this.depth=this.path.length,this.key=this.path.length?this.path.join(this.separator):null,this.root=this.path[0],this.updateDisplay()}resolve(u,h,f,b,g={}){return a(!this.in||g.in,"Invalid in() reference usage"),this.type==="global"?this._resolve(f.context,h,g):this.type==="local"?this._resolve(b,h,g):this.ancestor?this.ancestor==="root"?this._resolve(h.ancestors[h.ancestors.length-1],h,g):(a(this.ancestor<=h.ancestors.length,"Invalid reference exceeds the schema root:",this.display),this._resolve(h.ancestors[this.ancestor-1],h,g)):this._resolve(u,h,g)}_resolve(u,h,f){let b;if(this.type==="value"&&h.mainstay.shadow&&f.shadow!==!1&&(b=h.mainstay.shadow.get(this.absolute(h))),b===void 0&&(b=m(u,this.path,{iterables:this.iterables,functions:!0})),this.adjust&&(b=this.adjust(b)),this.map){const g=this.map.get(b);g!==void 0&&(b=g)}return h.mainstay&&h.mainstay.tracer.resolve(h,this,b),b}toString(){return this.display}absolute(u){return[...u.path.slice(0,-this.ancestor),...this.path]}clone(){return new c.Ref(this)}describe(){const u={path:this.path};this.type!=="value"&&(u.type=this.type),this.separator!=="."&&(u.separator=this.separator),this.type==="value"&&this.ancestor!==1&&(u.ancestor=this.ancestor),this.map&&(u.map=[...this.map]);for(const h of["adjust","iterables","render"])this[h]!==null&&this[h]!==void 0&&(u[h]=this[h]);return this.in!==!1&&(u.in=!0),{ref:u}}updateDisplay(){const u=this.key!==null?this.key:"";if(this.type!=="value")return void(this.display=`ref:${this.type}:${u}`);if(!this.separator)return void(this.display=`ref:${u}`);if(!this.ancestor)return void(this.display=`ref:${this.separator}${u}`);if(this.ancestor==="root")return void(this.display=`ref:root:${u}`);if(this.ancestor===1)return void(this.display=`ref:${u||".."}`);const h=new Array(this.ancestor+1).fill(this.separator).join("");this.display=`ref:${h}${u||""}`}},c.Ref.prototype[d.symbols.ref]=!0,n.build=function(u){return(u=Object.assign({},c.defaults,u)).type==="value"&&u.ancestor===void 0&&(u.ancestor=1),new c.Ref(u)},c.context=function(u,h,f={}){if(u=u.trim(),f){const b=f.global===void 0?"$":f.global;if(b!==h&&u.startsWith(b))return{key:u.slice(b.length),type:"global"};const g=f.local===void 0?"#":f.local;if(g!==h&&u.startsWith(g))return{key:u.slice(g.length),type:"local"};const y=f.root===void 0?"/":f.root;if(y!==h&&u.startsWith(y))return{key:u.slice(y.length),type:"value",root:!0}}return{key:u,type:"value"}},c.ancestor=function(u,h){if(!h)return[1,0];if(u[0]!==h)return[1,0];if(u[1]!==h)return[0,1];let f=2;for(;u[f]===h;)++f;return[f-1,f]},n.toSibling=0,n.toParent=1,n.Manager=class{constructor(){this.refs=[]}register(u,h){if(u)if(h=h===void 0?n.toParent:h,Array.isArray(u))for(const f of u)this.register(f,h);else if(d.isSchema(u))for(const f of u._refs.refs)f.ancestor-h>=0&&this.refs.push({ancestor:f.ancestor-h,root:f.root});else n.isRef(u)&&u.type==="value"&&u.ancestor-h>=0&&this.refs.push({ancestor:u.ancestor-h,root:u.root}),l=l||o(3328),l.isTemplate(u)&&this.register(u.refs(),h)}get length(){return this.refs.length}clone(){const u=new n.Manager;return u.refs=p(this.refs),u}reset(){this.refs=[]}roots(){return this.refs.filter(u=>!u.ancestor).map(u=>u.root)}}},3378:(r,n,o)=>{const a=o(5107),p={};p.wrap=a.string().min(1).max(2).allow(!1),n.preferences=a.object({allowUnknown:a.boolean(),abortEarly:a.boolean(),artifacts:a.boolean(),cache:a.boolean(),context:a.object(),convert:a.boolean(),dateFormat:a.valid("date","iso","string","time","utc"),debug:a.boolean(),errors:{escapeHtml:a.boolean(),label:a.valid("path","key",!1),language:[a.string(),a.object().ref()],render:a.boolean(),stack:a.boolean(),wrap:{label:p.wrap,array:p.wrap,string:p.wrap}},externals:a.boolean(),messages:a.object(),noDefaults:a.boolean(),nonEnumerables:a.boolean(),presence:a.valid("required","optional","forbidden"),skipFunctions:a.boolean(),stripUnknown:a.object({arrays:a.boolean(),objects:a.boolean()}).or("arrays","objects").allow(!0,!1),warnings:a.boolean()}).strict(),p.nameRx=/^[a-zA-Z0-9]\w*$/,p.rule=a.object({alias:a.array().items(a.string().pattern(p.nameRx)).single(),args:a.array().items(a.string(),a.object({name:a.string().pattern(p.nameRx).required(),ref:a.boolean(),assert:a.alternatives([a.function(),a.object().schema()]).conditional("ref",{is:!0,then:a.required()}),normalize:a.function(),message:a.string().when("assert",{is:a.function(),then:a.required()})})),convert:a.boolean(),manifest:a.boolean(),method:a.function().allow(!1),multi:a.boolean(),validate:a.function()}),n.extension=a.object({type:a.alternatives([a.string(),a.object().regex()]).required(),args:a.function(),cast:a.object().pattern(p.nameRx,a.object({from:a.function().maxArity(1).required(),to:a.function().minArity(1).maxArity(2).required()})),base:a.object().schema().when("type",{is:a.object().regex(),then:a.forbidden()}),coerce:[a.function().maxArity(3),a.object({method:a.function().maxArity(3).required(),from:a.array().items(a.string()).single()})],flags:a.object().pattern(p.nameRx,a.object({setter:a.string(),default:a.any()})),manifest:{build:a.function().arity(2)},messages:[a.object(),a.string()],modifiers:a.object().pattern(p.nameRx,a.function().minArity(1).maxArity(2)),overrides:a.object().pattern(p.nameRx,a.function()),prepare:a.function().maxArity(3),rebuild:a.function().arity(1),rules:a.object().pattern(p.nameRx,p.rule),terms:a.object().pattern(p.nameRx,a.object({init:a.array().allow(null).required(),manifest:a.object().pattern(/.+/,[a.valid("schema","single"),a.object({mapped:a.object({from:a.string().required(),to:a.string().required()}).required()})])})),validate:a.function().maxArity(3)}).strict(),n.extensions=a.array().items(a.object(),a.function().arity(1)).strict(),p.desc={buffer:a.object({buffer:a.string()}),func:a.object({function:a.function().required(),options:{literal:!0}}),override:a.object({override:!0}),ref:a.object({ref:a.object({type:a.valid("value","global","local"),path:a.array().required(),separator:a.string().length(1).allow(!1),ancestor:a.number().min(0).integer().allow("root"),map:a.array().items(a.array().length(2)).min(1),adjust:a.function(),iterables:a.boolean(),in:a.boolean(),render:a.boolean()}).required()}),regex:a.object({regex:a.string().min(3)}),special:a.object({special:a.valid("deep").required()}),template:a.object({template:a.string().required(),options:a.object()}),value:a.object({value:a.alternatives([a.object(),a.array()]).required()})},p.desc.entity=a.alternatives([a.array().items(a.link("...")),a.boolean(),a.function(),a.number(),a.string(),p.desc.buffer,p.desc.func,p.desc.ref,p.desc.regex,p.desc.special,p.desc.template,p.desc.value,a.link("/")]),p.desc.values=a.array().items(null,a.boolean(),a.function(),a.number().allow(1/0,-1/0),a.string().allow(""),a.symbol(),p.desc.buffer,p.desc.func,p.desc.override,p.desc.ref,p.desc.regex,p.desc.template,p.desc.value),p.desc.messages=a.object().pattern(/.+/,[a.string(),p.desc.template,a.object().pattern(/.+/,[a.string(),p.desc.template])]),n.description=a.object({type:a.string().required(),flags:a.object({cast:a.string(),default:a.any(),description:a.string(),empty:a.link("/"),failover:p.desc.entity,id:a.string(),label:a.string(),only:!0,presence:["optional","required","forbidden"],result:["raw","strip"],strip:a.boolean(),unit:a.string()}).unknown(),preferences:{allowUnknown:a.boolean(),abortEarly:a.boolean(),artifacts:a.boolean(),cache:a.boolean(),convert:a.boolean(),dateFormat:["date","iso","string","time","utc"],errors:{escapeHtml:a.boolean(),label:["path","key"],language:[a.string(),p.desc.ref],wrap:{label:p.wrap,array:p.wrap}},externals:a.boolean(),messages:p.desc.messages,noDefaults:a.boolean(),nonEnumerables:a.boolean(),presence:["required","optional","forbidden"],skipFunctions:a.boolean(),stripUnknown:a.object({arrays:a.boolean(),objects:a.boolean()}).or("arrays","objects").allow(!0,!1),warnings:a.boolean()},allow:p.desc.values,invalid:p.desc.values,rules:a.array().min(1).items({name:a.string().required(),args:a.object().min(1),keep:a.boolean(),message:[a.string(),p.desc.messages],warn:a.boolean()}),keys:a.object().pattern(/.*/,a.link("/")),link:p.desc.ref}).pattern(/^[a-z]\w*$/,a.any())},493:(r,n,o)=>{const a=o(8571),p=o(9621),m=o(8160),d={value:Symbol("value")};r.exports=d.State=class{constructor(l,c,u){this.path=l,this.ancestors=c,this.mainstay=u.mainstay,this.schemas=u.schemas,this.debug=null}localize(l,c=null,u=null){const h=new d.State(l,c,this);return u&&h.schemas&&(h.schemas=[d.schemas(u),...h.schemas]),h}nest(l,c){const u=new d.State(this.path,this.ancestors,this);return u.schemas=u.schemas&&[d.schemas(l),...u.schemas],u.debug=c,u}shadow(l,c){this.mainstay.shadow=this.mainstay.shadow||new d.Shadow,this.mainstay.shadow.set(this.path,l,c)}snapshot(){this.mainstay.shadow&&(this._snapshot=a(this.mainstay.shadow.node(this.path))),this.mainstay.snapshot()}restore(){this.mainstay.shadow&&(this.mainstay.shadow.override(this.path,this._snapshot),this._snapshot=void 0),this.mainstay.restore()}commit(){this.mainstay.shadow&&(this.mainstay.shadow.override(this.path,this._snapshot),this._snapshot=void 0),this.mainstay.commit()}},d.schemas=function(l){return m.isSchema(l)?{schema:l}:l},d.Shadow=class{constructor(){this._values=null}set(l,c,u){if(!l.length||u==="strip"&&typeof l[l.length-1]=="number")return;this._values=this._values||new Map;let h=this._values;for(let f=0;f<l.length;++f){const b=l[f];let g=h.get(b);g||(g=new Map,h.set(b,g)),h=g}h[d.value]=c}get(l){const c=this.node(l);if(c)return c[d.value]}node(l){if(this._values)return p(this._values,l,{iterables:!0})}override(l,c){if(!this._values)return;const u=l.slice(0,-1),h=l[l.length-1],f=p(this._values,u,{iterables:!0});c?f.set(h,c):f&&f.delete(h)}}},3328:(r,n,o)=>{const a=o(375),p=o(8571),m=o(5277),d=o(1447),l=o(8160),c=o(6354),u=o(6133),h={symbol:Symbol("template"),opens:new Array(1e3).join("\0"),closes:new Array(1e3).join(""),dateFormat:{date:Date.prototype.toDateString,iso:Date.prototype.toISOString,string:Date.prototype.toString,time:Date.prototype.toTimeString,utc:Date.prototype.toUTCString}};r.exports=h.Template=class{constructor(f,b){if(a(typeof f=="string","Template source must be a string"),a(!f.includes("\0")&&!f.includes(""),"Template source cannot contain reserved control characters"),this.source=f,this.rendered=f,this._template=null,b){const{functions:g,...y}=b;this._settings=Object.keys(y).length?p(y):void 0,this._functions=g,this._functions&&(a(Object.keys(this._functions).every(v=>typeof v=="string"),"Functions keys must be strings"),a(Object.values(this._functions).every(v=>typeof v=="function"),"Functions values must be functions"))}else this._settings=void 0,this._functions=void 0;this._parse()}_parse(){if(!this.source.includes("{"))return;const f=h.encode(this.source),b=h.split(f);let g=!1;const y=[],v=b.shift();v&&y.push(v);for(const _ of b){const C=_[0]!=="{",S=C?"}":"}}",T=_.indexOf(S);if(T===-1||_[1]==="{"){y.push(`{${h.decode(_)}`);continue}let w=_.slice(C?0:1,T);const x=w[0]===":";x&&(w=w.slice(1));const k=this._ref(h.decode(w),{raw:C,wrapped:x});y.push(k),typeof k!="string"&&(g=!0);const E=_.slice(T+S.length);E&&y.push(h.decode(E))}g?this._template=y:this.rendered=y.join("")}static date(f,b){return h.dateFormat[b.dateFormat].call(f)}describe(f={}){if(!this._settings&&f.compact)return this.source;const b={template:this.source};return this._settings&&(b.options=this._settings),this._functions&&(b.functions=this._functions),b}static build(f){return new h.Template(f.template,f.options||f.functions?{...f.options,functions:f.functions}:void 0)}isDynamic(){return!!this._template}static isTemplate(f){return!!f&&!!f[l.symbols.template]}refs(){if(!this._template)return;const f=[];for(const b of this._template)typeof b!="string"&&f.push(...b.refs);return f}resolve(f,b,g,y){return this._template&&this._template.length===1?this._part(this._template[0],f,b,g,y,{}):this.render(f,b,g,y)}_part(f,...b){return f.ref?f.ref.resolve(...b):f.formula.evaluate(b)}render(f,b,g,y,v={}){if(!this.isDynamic())return this.rendered;const _=[];for(const C of this._template)if(typeof C=="string")_.push(C);else{const S=this._part(C,f,b,g,y,v),T=h.stringify(S,f,b,g,y,v);if(T!==void 0){const w=C.raw||(v.errors&&v.errors.escapeHtml)===!1?T:m(T);_.push(h.wrap(w,C.wrapped&&g.errors.wrap.label))}}return _.join("")}_ref(f,{raw:b,wrapped:g}){const y=[],v=C=>{const S=u.create(C,this._settings);return y.push(S),T=>{const w=S.resolve(...T);return w!==void 0?w:null}};try{const C=this._functions?{...h.functions,...this._functions}:h.functions;var _=new d.Parser(f,{reference:v,functions:C,constants:h.constants})}catch(C){throw C.message=`Invalid template variable "${f}" fails due to: ${C.message}`,C}if(_.single){if(_.single.type==="reference"){const C=y[0];return{ref:C,raw:b,refs:y,wrapped:g||C.type==="local"&&C.key==="label"}}return h.stringify(_.single.value)}return{formula:_,raw:b,refs:y}}toString(){return this.source}},h.Template.prototype[l.symbols.template]=!0,h.Template.prototype.isImmutable=!0,h.encode=function(f){return f.replace(/\\(\{+)/g,(b,g)=>h.opens.slice(0,g.length)).replace(/\\(\}+)/g,(b,g)=>h.closes.slice(0,g.length))},h.decode=function(f){return f.replace(/\u0000/g,"{").replace(/\u0001/g,"}")},h.split=function(f){const b=[];let g="";for(let y=0;y<f.length;++y){const v=f[y];if(v==="{"){let _="";for(;y+1<f.length&&f[y+1]==="{";)_+="{",++y;b.push(g),g=_}else g+=v}return b.push(g),b},h.wrap=function(f,b){return b?b.length===1?`${b}${f}${b}`:`${b[0]}${f}${b[1]}`:f},h.stringify=function(f,b,g,y,v,_={}){const C=typeof f,S=y&&y.errors&&y.errors.wrap||{};let T=!1;if(u.isRef(f)&&f.render&&(T=f.in,f=f.resolve(b,g,y,v,{in:f.in,..._})),f===null)return"null";if(C==="string")return h.wrap(f,_.arrayItems&&S.string);if(C==="number"||C==="function"||C==="symbol")return f.toString();if(C!=="object")return JSON.stringify(f);if(f instanceof Date)return h.Template.date(f,y);if(f instanceof Map){const x=[];for(const[k,E]of f.entries())x.push(`${k.toString()} -> ${E.toString()}`);f=x}if(!Array.isArray(f))return f.toString();const w=[];for(const x of f)w.push(h.stringify(x,b,g,y,v,{arrayItems:!0,..._}));return h.wrap(w.join(", "),!T&&S.array)},h.constants={true:!0,false:!1,null:null,second:1e3,minute:6e4,hour:36e5,day:864e5},h.functions={if:(f,b,g)=>f?b:g,length:f=>typeof f=="string"?f.length:f&&typeof f=="object"?Array.isArray(f)?f.length:Object.keys(f).length:null,msg(f){const[b,g,y,v,_]=this,C=_.messages;if(!C)return"";const S=c.template(b,C[0],f,g,y)||c.template(b,C[1],f,g,y);return S?S.render(b,g,y,v,_):""},number:f=>typeof f=="number"?f:typeof f=="string"?parseFloat(f):typeof f=="boolean"?f?1:0:f instanceof Date?f.getTime():null}},4946:(r,n,o)=>{const a=o(375),p=o(1687),m=o(8068),d=o(8160),l=o(3292),c=o(6354),u=o(6133),h={};r.exports=m.extend({type:"alternatives",flags:{match:{default:"any"}},terms:{matches:{init:[],register:u.toSibling}},args:(f,...b)=>b.length===1&&Array.isArray(b[0])?f.try(...b[0]):f.try(...b),validate(f,b){const{schema:g,error:y,state:v,prefs:_}=b;if(g._flags.match){const S=[],T=[];for(let x=0;x<g.$_terms.matches.length;++x){const k=g.$_terms.matches[x],E=v.nest(k.schema,`match.${x}`);E.snapshot();const P=k.schema.$_validate(f,E,_);P.errors?(T.push(P.errors),E.restore()):(S.push(P.value),E.commit())}if(S.length===0)return{errors:y("alternatives.any",{details:T.map(x=>c.details(x,{override:!1}))})};if(g._flags.match==="one")return S.length===1?{value:S[0]}:{errors:y("alternatives.one")};if(S.length!==g.$_terms.matches.length)return{errors:y("alternatives.all",{details:T.map(x=>c.details(x,{override:!1}))})};const w=x=>x.$_terms.matches.some(k=>k.schema.type==="object"||k.schema.type==="alternatives"&&w(k.schema));return w(g)?{value:S.reduce((x,k)=>p(x,k,{mergeArrays:!1}))}:{value:S[S.length-1]}}const C=[];for(let S=0;S<g.$_terms.matches.length;++S){const T=g.$_terms.matches[S];if(T.schema){const k=v.nest(T.schema,`match.${S}`);k.snapshot();const E=T.schema.$_validate(f,k,_);if(!E.errors)return k.commit(),E;k.restore(),C.push({schema:T.schema,reports:E.errors});continue}const w=T.ref?T.ref.resolve(f,v,_):f,x=T.is?[T]:T.switch;for(let k=0;k<x.length;++k){const E=x[k],{is:P,then:O,otherwise:z}=E,I=`match.${S}${T.switch?"."+k:""}`;if(P.$_match(w,v.nest(P,`${I}.is`),_)){if(O)return O.$_validate(f,v.nest(O,`${I}.then`),_)}else if(z)return z.$_validate(f,v.nest(z,`${I}.otherwise`),_)}}return h.errors(C,b)},rules:{conditional:{method(f,b){a(!this._flags._endedSwitch,"Unreachable condition"),a(!this._flags.match,"Cannot combine match mode",this._flags.match,"with conditional rule"),a(b.break===void 0,"Cannot use break option with alternatives conditional");const g=this.clone(),y=l.when(g,f,b),v=y.is?[y]:y.switch;for(const _ of v)if(_.then&&_.otherwise){g.$_setFlag("_endedSwitch",!0,{clone:!1});break}return g.$_terms.matches.push(y),g.$_mutateRebuild()}},match:{method(f){if(a(["any","one","all"].includes(f),"Invalid alternatives match mode",f),f!=="any")for(const b of this.$_terms.matches)a(b.schema,"Cannot combine match mode",f,"with conditional rules");return this.$_setFlag("match",f)}},try:{method(...f){a(f.length,"Missing alternative schemas"),d.verifyFlat(f,"try"),a(!this._flags._endedSwitch,"Unreachable condition");const b=this.clone();for(const g of f)b.$_terms.matches.push({schema:b.$_compile(g)});return b.$_mutateRebuild()}}},overrides:{label(f){return this.$_parent("label",f).$_modify({each:(b,g)=>g.path[0]!=="is"&&typeof b._flags.label!="string"?b.label(f):void 0,ref:!1})}},rebuild(f){f.$_modify({each:b=>{d.isSchema(b)&&b.type==="array"&&f.$_setFlag("_arrayItems",!0,{clone:!1})}})},manifest:{build(f,b){if(b.matches)for(const g of b.matches){const{schema:y,ref:v,is:_,not:C,then:S,otherwise:T}=g;f=y?f.try(y):v?f.conditional(v,{is:_,then:S,not:C,otherwise:T,switch:g.switch}):f.conditional(_,{then:S,otherwise:T})}return f}},messages:{"alternatives.all":"{{#label}} does not match all of the required types","alternatives.any":"{{#label}} does not match any of the allowed types","alternatives.match":"{{#label}} does not match any of the allowed types","alternatives.one":"{{#label}} matches more than one allowed type","alternatives.types":"{{#label}} must be one of {{#types}}"}}),h.errors=function(f,{error:b,state:g}){if(!f.length)return{errors:b("alternatives.any")};if(f.length===1)return{errors:f[0].reports};const y=new Set,v=[];for(const{reports:_,schema:C}of f){if(_.length>1)return h.unmatched(f,b);const S=_[0];if(S instanceof c.Report==0)return h.unmatched(f,b);if(S.state.path.length!==g.path.length){v.push({type:C.type,report:S});continue}if(S.code==="any.only"){for(const x of S.local.valids)y.add(x);continue}const[T,w]=S.code.split(".");w!=="base"?v.push({type:C.type,report:S}):S.code==="object.base"?y.add(S.local.type):y.add(T)}return v.length?v.length===1?{errors:v[0].report}:h.unmatched(f,b):{errors:b("alternatives.types",{types:[...y]})}},h.unmatched=function(f,b){const g=[];for(const y of f)g.push(...y.reports);return{errors:b("alternatives.match",c.details(g,{override:!1}))}}},8068:(r,n,o)=>{const a=o(375),p=o(7629),m=o(8160),d=o(6914);r.exports=p.extend({type:"any",flags:{only:{default:!1}},terms:{alterations:{init:null},examples:{init:null},externals:{init:null},metas:{init:[]},notes:{init:[]},shared:{init:null},tags:{init:[]},whens:{init:null}},rules:{custom:{method(l,c){return a(typeof l=="function","Method must be a function"),a(c===void 0||c&&typeof c=="string","Description must be a non-empty string"),this.$_addRule({name:"custom",args:{method:l,description:c}})},validate(l,c,{method:u}){try{return u(l,c)}catch(h){return c.error("any.custom",{error:h})}},args:["method","description"],multi:!0},messages:{method(l){return this.prefs({messages:l})}},shared:{method(l){a(m.isSchema(l)&&l._flags.id,"Schema must be a schema with an id");const c=this.clone();return c.$_terms.shared=c.$_terms.shared||[],c.$_terms.shared.push(l),c.$_mutateRegister(l),c}},warning:{method(l,c){return a(l&&typeof l=="string","Invalid warning code"),this.$_addRule({name:"warning",args:{code:l,local:c},warn:!0})},validate:(l,c,{code:u,local:h})=>c.error(u,h),args:["code","local"],multi:!0}},modifiers:{keep(l,c=!0){l.keep=c},message(l,c){l.message=d.compile(c)},warn(l,c=!0){l.warn=c}},manifest:{build(l,c){for(const u in c){const h=c[u];if(["examples","externals","metas","notes","tags"].includes(u))for(const f of h)l=l[u.slice(0,-1)](f);else if(u!=="alterations")if(u!=="whens"){if(u==="shared")for(const f of h)l=l.shared(f)}else for(const f of h){const{ref:b,is:g,not:y,then:v,otherwise:_,concat:C}=f;l=C?l.concat(C):b?l.when(b,{is:g,not:y,then:v,otherwise:_,switch:f.switch,break:f.break}):l.when(g,{then:v,otherwise:_,break:f.break})}else{const f={};for(const{target:b,adjuster:g}of h)f[b]=g;l=l.alter(f)}}return l}},messages:{"any.custom":"{{#label}} failed custom validation because {{#error.message}}","any.default":"{{#label}} threw an error when running default method","any.failover":"{{#label}} threw an error when running failover method","any.invalid":"{{#label}} contains an invalid value","any.only":'{{#label}} must be {if(#valids.length == 1, "", "one of ")}{{#valids}}',"any.ref":"{{#label}} {{#arg}} references {{:#ref}} which {{#reason}}","any.required":"{{#label}} is required","any.unknown":"{{#label}} is not allowed"}})},546:(r,n,o)=>{const a=o(375),p=o(9474),m=o(9621),d=o(8068),l=o(8160),c=o(3292),u={};r.exports=d.extend({type:"array",flags:{single:{default:!1},sparse:{default:!1}},terms:{items:{init:[],manifest:"schema"},ordered:{init:[],manifest:"schema"},_exclusions:{init:[]},_inclusions:{init:[]},_requireds:{init:[]}},coerce:{from:"object",method(h,{schema:f,state:b,prefs:g}){if(!Array.isArray(h))return;const y=f.$_getRule("sort");return y?u.sort(f,h,y.args.options,b,g):void 0}},validate(h,{schema:f,error:b}){if(!Array.isArray(h)){if(f._flags.single){const g=[h];return g[l.symbols.arraySingle]=!0,{value:g}}return{errors:b("array.base")}}if(f.$_getRule("items")||f.$_terms.externals)return{value:h.slice()}},rules:{has:{method(h){h=this.$_compile(h,{appendPath:!0});const f=this.$_addRule({name:"has",args:{schema:h}});return f.$_mutateRegister(h),f},validate(h,{state:f,prefs:b,error:g},{schema:y}){const v=[h,...f.ancestors];for(let C=0;C<h.length;++C){const S=f.localize([...f.path,C],v,y);if(y.$_match(h[C],S,b))return h}const _=y._flags.label;return _?g("array.hasKnown",{patternLabel:_}):g("array.hasUnknown",null)},multi:!0},items:{method(...h){l.verifyFlat(h,"items");const f=this.$_addRule("items");for(let b=0;b<h.length;++b){const g=l.tryWithPath(()=>this.$_compile(h[b]),b,{append:!0});f.$_terms.items.push(g)}return f.$_mutateRebuild()},validate(h,{schema:f,error:b,state:g,prefs:y,errorsArray:v}){const _=f.$_terms._requireds.slice(),C=f.$_terms.ordered.slice(),S=[...f.$_terms._inclusions,..._],T=!h[l.symbols.arraySingle];delete h[l.symbols.arraySingle];const w=v();let x=h.length;for(let k=0;k<x;++k){const E=h[k];let P=!1,O=!1;const z=T?k:new Number(k),I=[...g.path,z];if(!f._flags.sparse&&E===void 0){if(w.push(b("array.sparse",{key:z,path:I,pos:k,value:void 0},g.localize(I))),y.abortEarly)return w;C.shift();continue}const L=[h,...g.ancestors];for(const X of f.$_terms._exclusions)if(X.$_match(E,g.localize(I,L,X),y,{presence:"ignore"})){if(w.push(b("array.excludes",{pos:k,value:E},g.localize(I))),y.abortEarly)return w;P=!0,C.shift();break}if(P)continue;if(f.$_terms.ordered.length){if(C.length){const X=C.shift(),Y=X.$_validate(E,g.localize(I,L,X),y);if(Y.errors){if(w.push(...Y.errors),y.abortEarly)return w}else if(X._flags.result==="strip")u.fastSplice(h,k),--k,--x;else{if(!f._flags.sparse&&Y.value===void 0){if(w.push(b("array.sparse",{key:z,path:I,pos:k,value:void 0},g.localize(I))),y.abortEarly)return w;continue}h[k]=Y.value}continue}if(!f.$_terms.items.length){if(w.push(b("array.orderedLength",{pos:k,limit:f.$_terms.ordered.length})),y.abortEarly)return w;break}}const F=[];let Z=_.length;for(let X=0;X<Z;++X){const Y=g.localize(I,L,_[X]);Y.snapshot();const se=_[X].$_validate(E,Y,y);if(F[X]=se,!se.errors){if(Y.commit(),h[k]=se.value,O=!0,u.fastSplice(_,X),--X,--Z,!f._flags.sparse&&se.value===void 0&&(w.push(b("array.sparse",{key:z,path:I,pos:k,value:void 0},g.localize(I))),y.abortEarly))return w;break}Y.restore()}if(O)continue;const Q=y.stripUnknown&&!!y.stripUnknown.arrays||!1;Z=S.length;for(const X of S){let Y;const se=_.indexOf(X);if(se!==-1)Y=F[se];else{const re=g.localize(I,L,X);if(re.snapshot(),Y=X.$_validate(E,re,y),!Y.errors){re.commit(),X._flags.result==="strip"?(u.fastSplice(h,k),--k,--x):f._flags.sparse||Y.value!==void 0?h[k]=Y.value:(w.push(b("array.sparse",{key:z,path:I,pos:k,value:void 0},g.localize(I))),P=!0),O=!0;break}re.restore()}if(Z===1){if(Q){u.fastSplice(h,k),--k,--x,O=!0;break}if(w.push(...Y.errors),y.abortEarly)return w;P=!0;break}}if(!P&&(f.$_terms._inclusions.length||f.$_terms._requireds.length)&&!O){if(Q){u.fastSplice(h,k),--k,--x;continue}if(w.push(b("array.includes",{pos:k,value:E},g.localize(I))),y.abortEarly)return w}}return _.length&&u.fillMissedErrors(f,w,_,h,g,y),C.length&&(u.fillOrderedErrors(f,w,C,h,g,y),w.length||u.fillDefault(C,h,g,y)),w.length?w:h},priority:!0,manifest:!1},length:{method(h){return this.$_addRule({name:"length",args:{limit:h},operator:"="})},validate:(h,f,{limit:b},{name:g,operator:y,args:v})=>l.compare(h.length,b,y)?h:f.error("array."+g,{limit:v.limit,value:h}),args:[{name:"limit",ref:!0,assert:l.limit,message:"must be a positive integer"}]},max:{method(h){return this.$_addRule({name:"max",method:"length",args:{limit:h},operator:"<="})}},min:{method(h){return this.$_addRule({name:"min",method:"length",args:{limit:h},operator:">="})}},ordered:{method(...h){l.verifyFlat(h,"ordered");const f=this.$_addRule("items");for(let b=0;b<h.length;++b){const g=l.tryWithPath(()=>this.$_compile(h[b]),b,{append:!0});u.validateSingle(g,f),f.$_mutateRegister(g),f.$_terms.ordered.push(g)}return f.$_mutateRebuild()}},single:{method(h){const f=h===void 0||!!h;return a(!f||!this._flags._arrayItems,"Cannot specify single rule when array has array items"),this.$_setFlag("single",f)}},sort:{method(h={}){l.assertOptions(h,["by","order"]);const f={order:h.order||"ascending"};return h.by&&(f.by=c.ref(h.by,{ancestor:0}),a(!f.by.ancestor,"Cannot sort by ancestor")),this.$_addRule({name:"sort",args:{options:f}})},validate(h,{error:f,state:b,prefs:g,schema:y},{options:v}){const{value:_,errors:C}=u.sort(y,h,v,b,g);if(C)return C;for(let S=0;S<h.length;++S)if(h[S]!==_[S])return f("array.sort",{order:v.order,by:v.by?v.by.key:"value"});return h},convert:!0},sparse:{method(h){const f=h===void 0||!!h;return this._flags.sparse===f?this:(f?this.clone():this.$_addRule("items")).$_setFlag("sparse",f,{clone:!1})}},unique:{method(h,f={}){a(!h||typeof h=="function"||typeof h=="string","comparator must be a function or a string"),l.assertOptions(f,["ignoreUndefined","separator"]);const b={name:"unique",args:{options:f,comparator:h}};if(h)if(typeof h=="string"){const g=l.default(f.separator,".");b.path=g?h.split(g):[h]}else b.comparator=h;return this.$_addRule(b)},validate(h,{state:f,error:b,schema:g},{comparator:y,options:v},{comparator:_,path:C}){const S={string:Object.create(null),number:Object.create(null),undefined:Object.create(null),boolean:Object.create(null),bigint:Object.create(null),object:new Map,function:new Map,custom:new Map},T=_||p,w=v.ignoreUndefined;for(let x=0;x<h.length;++x){const k=C?m(h[x],C):h[x],E=_?S.custom:S[typeof k];if(a(E,"Failed to find unique map container for type",typeof k),E instanceof Map){const P=E.entries();let O;for(;!(O=P.next()).done;)if(T(O.value[0],k)){const z=f.localize([...f.path,x],[h,...f.ancestors]),I={pos:x,value:h[x],dupePos:O.value[1],dupeValue:h[O.value[1]]};return C&&(I.path=y),b("array.unique",I,z)}E.set(k,x)}else{if((!w||k!==void 0)&&E[k]!==void 0){const P={pos:x,value:h[x],dupePos:E[k],dupeValue:h[E[k]]};return C&&(P.path=y),b("array.unique",P,f.localize([...f.path,x],[h,...f.ancestors]))}E[k]=x}}return h},args:["comparator","options"],multi:!0}},cast:{set:{from:Array.isArray,to:(h,f)=>new Set(h)}},rebuild(h){h.$_terms._inclusions=[],h.$_terms._exclusions=[],h.$_terms._requireds=[];for(const f of h.$_terms.items)u.validateSingle(f,h),f._flags.presence==="required"?h.$_terms._requireds.push(f):f._flags.presence==="forbidden"?h.$_terms._exclusions.push(f):h.$_terms._inclusions.push(f);for(const f of h.$_terms.ordered)u.validateSingle(f,h)},manifest:{build:(h,f)=>(f.items&&(h=h.items(...f.items)),f.ordered&&(h=h.ordered(...f.ordered)),h)},messages:{"array.base":"{{#label}} must be an array","array.excludes":"{{#label}} contains an excluded value","array.hasKnown":"{{#label}} does not contain at least one required match for type {:#patternLabel}","array.hasUnknown":"{{#label}} does not contain at least one required match","array.includes":"{{#label}} does not match any of the allowed types","array.includesRequiredBoth":"{{#label}} does not contain {{#knownMisses}} and {{#unknownMisses}} other required value(s)","array.includesRequiredKnowns":"{{#label}} does not contain {{#knownMisses}}","array.includesRequiredUnknowns":"{{#label}} does not contain {{#unknownMisses}} required value(s)","array.length":"{{#label}} must contain {{#limit}} items","array.max":"{{#label}} must contain less than or equal to {{#limit}} items","array.min":"{{#label}} must contain at least {{#limit}} items","array.orderedLength":"{{#label}} must contain at most {{#limit}} items","array.sort":"{{#label}} must be sorted in {#order} order by {{#by}}","array.sort.mismatching":"{{#label}} cannot be sorted due to mismatching types","array.sort.unsupported":"{{#label}} cannot be sorted due to unsupported type {#type}","array.sparse":"{{#label}} must not be a sparse array item","array.unique":"{{#label}} contains a duplicate value"}}),u.fillMissedErrors=function(h,f,b,g,y,v){const _=[];let C=0;for(const S of b){const T=S._flags.label;T?_.push(T):++C}_.length?C?f.push(h.$_createError("array.includesRequiredBoth",g,{knownMisses:_,unknownMisses:C},y,v)):f.push(h.$_createError("array.includesRequiredKnowns",g,{knownMisses:_},y,v)):f.push(h.$_createError("array.includesRequiredUnknowns",g,{unknownMisses:C},y,v))},u.fillOrderedErrors=function(h,f,b,g,y,v){const _=[];for(const C of b)C._flags.presence==="required"&&_.push(C);_.length&&u.fillMissedErrors(h,f,_,g,y,v)},u.fillDefault=function(h,f,b,g){const y=[];let v=!0;for(let _=h.length-1;_>=0;--_){const C=h[_],S=[f,...b.ancestors],T=C.$_validate(void 0,b.localize(b.path,S,C),g).value;if(v){if(T===void 0)continue;v=!1}y.unshift(T)}y.length&&f.push(...y)},u.fastSplice=function(h,f){let b=f;for(;b<h.length;)h[b++]=h[b];--h.length},u.validateSingle=function(h,f){(h.type==="array"||h._flags._arrayItems)&&(a(!f._flags.single,"Cannot specify array item with single rule enabled"),f.$_setFlag("_arrayItems",!0,{clone:!1}))},u.sort=function(h,f,b,g,y){const v=b.order==="ascending"?1:-1,_=-1*v,C=v,S=(T,w)=>{let x=u.compare(T,w,_,C);if(x!==null||(b.by&&(T=b.by.resolve(T,g,y),w=b.by.resolve(w,g,y)),x=u.compare(T,w,_,C),x!==null))return x;const k=typeof T;if(k!==typeof w)throw h.$_createError("array.sort.mismatching",f,null,g,y);if(k!=="number"&&k!=="string")throw h.$_createError("array.sort.unsupported",f,{type:k},g,y);return k==="number"?(T-w)*v:T<w?_:C};try{return{value:f.slice().sort(S)}}catch(T){return{errors:T}}},u.compare=function(h,f,b,g){return h===f?0:h===void 0?1:f===void 0?-1:h===null?g:f===null?b:null}},4937:(r,n,o)=>{const a=o(375),p=o(8068),m=o(8160),d=o(2036),l={isBool:function(c){return typeof c=="boolean"}};r.exports=p.extend({type:"boolean",flags:{sensitive:{default:!1}},terms:{falsy:{init:null,manifest:"values"},truthy:{init:null,manifest:"values"}},coerce(c,{schema:u}){if(typeof c!="boolean"){if(typeof c=="string"){const h=u._flags.sensitive?c:c.toLowerCase();c=h==="true"||h!=="false"&&c}return typeof c!="boolean"&&(c=u.$_terms.truthy&&u.$_terms.truthy.has(c,null,null,!u._flags.sensitive)||(!u.$_terms.falsy||!u.$_terms.falsy.has(c,null,null,!u._flags.sensitive))&&c),{value:c}}},validate(c,{error:u}){if(typeof c!="boolean")return{value:c,errors:u("boolean.base")}},rules:{truthy:{method(...c){m.verifyFlat(c,"truthy");const u=this.clone();u.$_terms.truthy=u.$_terms.truthy||new d;for(let h=0;h<c.length;++h){const f=c[h];a(f!==void 0,"Cannot call truthy with undefined"),u.$_terms.truthy.add(f)}return u}},falsy:{method(...c){m.verifyFlat(c,"falsy");const u=this.clone();u.$_terms.falsy=u.$_terms.falsy||new d;for(let h=0;h<c.length;++h){const f=c[h];a(f!==void 0,"Cannot call falsy with undefined"),u.$_terms.falsy.add(f)}return u}},sensitive:{method(c=!0){return this.$_setFlag("sensitive",c)}}},cast:{number:{from:l.isBool,to:(c,u)=>c?1:0},string:{from:l.isBool,to:(c,u)=>c?"true":"false"}},manifest:{build:(c,u)=>(u.truthy&&(c=c.truthy(...u.truthy)),u.falsy&&(c=c.falsy(...u.falsy)),c)},messages:{"boolean.base":"{{#label}} must be a boolean"}})},7500:(r,n,o)=>{const a=o(375),p=o(8068),m=o(8160),d=o(3328),l={isDate:function(c){return c instanceof Date}};r.exports=p.extend({type:"date",coerce:{from:["number","string"],method:(c,{schema:u})=>({value:l.parse(c,u._flags.format)||c})},validate(c,{schema:u,error:h,prefs:f}){if(c instanceof Date&&!isNaN(c.getTime()))return;const b=u._flags.format;return f.convert&&b&&typeof c=="string"?{value:c,errors:h("date.format",{format:b})}:{value:c,errors:h("date.base")}},rules:{compare:{method:!1,validate(c,u,{date:h},{name:f,operator:b,args:g}){const y=h==="now"?Date.now():h.getTime();return m.compare(c.getTime(),y,b)?c:u.error("date."+f,{limit:g.date,value:c})},args:[{name:"date",ref:!0,normalize:c=>c==="now"?c:l.parse(c),assert:c=>c!==null,message:"must have a valid date format"}]},format:{method(c){return a(["iso","javascript","unix"].includes(c),"Unknown date format",c),this.$_setFlag("format",c)}},greater:{method(c){return this.$_addRule({name:"greater",method:"compare",args:{date:c},operator:">"})}},iso:{method(){return this.format("iso")}},less:{method(c){return this.$_addRule({name:"less",method:"compare",args:{date:c},operator:"<"})}},max:{method(c){return this.$_addRule({name:"max",method:"compare",args:{date:c},operator:"<="})}},min:{method(c){return this.$_addRule({name:"min",method:"compare",args:{date:c},operator:">="})}},timestamp:{method(c="javascript"){return a(["javascript","unix"].includes(c),'"type" must be one of "javascript, unix"'),this.format(c)}}},cast:{number:{from:l.isDate,to:(c,u)=>c.getTime()},string:{from:l.isDate,to:(c,{prefs:u})=>d.date(c,u)}},messages:{"date.base":"{{#label}} must be a valid date","date.format":'{{#label}} must be in {msg("date.format." + #format) || #format} format',"date.greater":"{{#label}} must be greater than {{:#limit}}","date.less":"{{#label}} must be less than {{:#limit}}","date.max":"{{#label}} must be less than or equal to {{:#limit}}","date.min":"{{#label}} must be greater than or equal to {{:#limit}}","date.format.iso":"ISO 8601 date","date.format.javascript":"timestamp or number of milliseconds","date.format.unix":"timestamp or number of seconds"}}),l.parse=function(c,u){if(c instanceof Date)return c;if(typeof c!="string"&&(isNaN(c)||!isFinite(c))||/^\s*$/.test(c))return null;if(u==="iso")return m.isIsoDate(c)?l.date(c.toString()):null;const h=c;if(typeof c=="string"&&/^[+-]?\d+(\.\d+)?$/.test(c)&&(c=parseFloat(c)),u){if(u==="javascript")return l.date(1*c);if(u==="unix")return l.date(1e3*c);if(typeof h=="string")return null}return l.date(c)},l.date=function(c){const u=new Date(c);return isNaN(u.getTime())?null:u}},390:(r,n,o)=>{const a=o(375),p=o(7824);r.exports=p.extend({type:"function",properties:{typeof:"function"},rules:{arity:{method(m){return a(Number.isSafeInteger(m)&&m>=0,"n must be a positive integer"),this.$_addRule({name:"arity",args:{n:m}})},validate:(m,d,{n:l})=>m.length===l?m:d.error("function.arity",{n:l})},class:{method(){return this.$_addRule("class")},validate:(m,d)=>/^\s*class\s/.test(m.toString())?m:d.error("function.class",{value:m})},minArity:{method(m){return a(Number.isSafeInteger(m)&&m>0,"n must be a strict positive integer"),this.$_addRule({name:"minArity",args:{n:m}})},validate:(m,d,{n:l})=>m.length>=l?m:d.error("function.minArity",{n:l})},maxArity:{method(m){return a(Number.isSafeInteger(m)&&m>=0,"n must be a positive integer"),this.$_addRule({name:"maxArity",args:{n:m}})},validate:(m,d,{n:l})=>m.length<=l?m:d.error("function.maxArity",{n:l})}},messages:{"function.arity":"{{#label}} must have an arity of {{#n}}","function.class":"{{#label}} must be a class","function.maxArity":"{{#label}} must have an arity lesser or equal to {{#n}}","function.minArity":"{{#label}} must have an arity greater or equal to {{#n}}"}})},7824:(r,n,o)=>{const a=o(978),p=o(375),m=o(8571),d=o(3652),l=o(8068),c=o(8160),u=o(3292),h=o(6354),f=o(6133),b=o(3328),g={renameDefaults:{alias:!1,multiple:!1,override:!1}};r.exports=l.extend({type:"_keys",properties:{typeof:"object"},flags:{unknown:{default:void 0}},terms:{dependencies:{init:null},keys:{init:null,manifest:{mapped:{from:"schema",to:"key"}}},patterns:{init:null},renames:{init:null}},args:(y,v)=>y.keys(v),validate(y,{schema:v,error:_,state:C,prefs:S}){if(!y||typeof y!==v.$_property("typeof")||Array.isArray(y))return{value:y,errors:_("object.base",{type:v.$_property("typeof")})};if(!(v.$_terms.renames||v.$_terms.dependencies||v.$_terms.keys||v.$_terms.patterns||v.$_terms.externals))return;y=g.clone(y,S);const T=[];if(v.$_terms.renames&&!g.rename(v,y,C,S,T))return{value:y,errors:T};if(!v.$_terms.keys&&!v.$_terms.patterns&&!v.$_terms.dependencies)return{value:y,errors:T};const w=new Set(Object.keys(y));if(v.$_terms.keys){const x=[y,...C.ancestors];for(const k of v.$_terms.keys){const E=k.key,P=y[E];w.delete(E);const O=C.localize([...C.path,E],x,k),z=k.schema.$_validate(P,O,S);if(z.errors){if(S.abortEarly)return{value:y,errors:z.errors};z.value!==void 0&&(y[E]=z.value),T.push(...z.errors)}else k.schema._flags.result==="strip"||z.value===void 0&&P!==void 0?delete y[E]:z.value!==void 0&&(y[E]=z.value)}}if(w.size||v._flags._hasPatternMatch){const x=g.unknown(v,y,w,T,C,S);if(x)return x}if(v.$_terms.dependencies)for(const x of v.$_terms.dependencies){if(x.key!==null&&g.isPresent(x.options)(x.key.resolve(y,C,S,null,{shadow:!1}))===!1)continue;const k=g.dependencies[x.rel](v,x,y,C,S);if(k){const E=v.$_createError(k.code,y,k.context,C,S);if(S.abortEarly)return{value:y,errors:E};T.push(E)}}return{value:y,errors:T}},rules:{and:{method(...y){return c.verifyFlat(y,"and"),g.dependency(this,"and",null,y)}},append:{method(y){return y==null||Object.keys(y).length===0?this:this.keys(y)}},assert:{method(y,v,_){b.isTemplate(y)||(y=u.ref(y)),p(_===void 0||typeof _=="string","Message must be a string"),v=this.$_compile(v,{appendPath:!0});const C=this.$_addRule({name:"assert",args:{subject:y,schema:v,message:_}});return C.$_mutateRegister(y),C.$_mutateRegister(v),C},validate(y,{error:v,prefs:_,state:C},{subject:S,schema:T,message:w}){const x=S.resolve(y,C,_),k=f.isRef(S)?S.absolute(C):[];return T.$_match(x,C.localize(k,[y,...C.ancestors],T),_)?y:v("object.assert",{subject:S,message:w})},args:["subject","schema","message"],multi:!0},instance:{method(y,v){return p(typeof y=="function","constructor must be a function"),v=v||y.name,this.$_addRule({name:"instance",args:{constructor:y,name:v}})},validate:(y,v,{constructor:_,name:C})=>y instanceof _?y:v.error("object.instance",{type:C,value:y}),args:["constructor","name"]},keys:{method(y){p(y===void 0||typeof y=="object","Object schema must be a valid object"),p(!c.isSchema(y),"Object schema cannot be a joi schema");const v=this.clone();if(y)if(Object.keys(y).length){v.$_terms.keys=v.$_terms.keys?v.$_terms.keys.filter(_=>!y.hasOwnProperty(_.key)):new g.Keys;for(const _ in y)c.tryWithPath(()=>v.$_terms.keys.push({key:_,schema:this.$_compile(y[_])}),_)}else v.$_terms.keys=new g.Keys;else v.$_terms.keys=null;return v.$_mutateRebuild()}},length:{method(y){return this.$_addRule({name:"length",args:{limit:y},operator:"="})},validate:(y,v,{limit:_},{name:C,operator:S,args:T})=>c.compare(Object.keys(y).length,_,S)?y:v.error("object."+C,{limit:T.limit,value:y}),args:[{name:"limit",ref:!0,assert:c.limit,message:"must be a positive integer"}]},max:{method(y){return this.$_addRule({name:"max",method:"length",args:{limit:y},operator:"<="})}},min:{method(y){return this.$_addRule({name:"min",method:"length",args:{limit:y},operator:">="})}},nand:{method(...y){return c.verifyFlat(y,"nand"),g.dependency(this,"nand",null,y)}},or:{method(...y){return c.verifyFlat(y,"or"),g.dependency(this,"or",null,y)}},oxor:{method(...y){return g.dependency(this,"oxor",null,y)}},pattern:{method(y,v,_={}){const C=y instanceof RegExp;C||(y=this.$_compile(y,{appendPath:!0})),p(v!==void 0,"Invalid rule"),c.assertOptions(_,["fallthrough","matches"]),C&&p(!y.flags.includes("g")&&!y.flags.includes("y"),"pattern should not use global or sticky mode"),v=this.$_compile(v,{appendPath:!0});const S=this.clone();S.$_terms.patterns=S.$_terms.patterns||[];const T={[C?"regex":"schema"]:y,rule:v};return _.matches&&(T.matches=this.$_compile(_.matches),T.matches.type!=="array"&&(T.matches=T.matches.$_root.array().items(T.matches)),S.$_mutateRegister(T.matches),S.$_setFlag("_hasPatternMatch",!0,{clone:!1})),_.fallthrough&&(T.fallthrough=!0),S.$_terms.patterns.push(T),S.$_mutateRegister(v),S}},ref:{method(){return this.$_addRule("ref")},validate:(y,v)=>f.isRef(y)?y:v.error("object.refType",{value:y})},regex:{method(){return this.$_addRule("regex")},validate:(y,v)=>y instanceof RegExp?y:v.error("object.regex",{value:y})},rename:{method(y,v,_={}){p(typeof y=="string"||y instanceof RegExp,"Rename missing the from argument"),p(typeof v=="string"||v instanceof b,"Invalid rename to argument"),p(v!==y,"Cannot rename key to same name:",y),c.assertOptions(_,["alias","ignoreUndefined","override","multiple"]);const C=this.clone();C.$_terms.renames=C.$_terms.renames||[];for(const S of C.$_terms.renames)p(S.from!==y,"Cannot rename the same key multiple times");return v instanceof b&&C.$_mutateRegister(v),C.$_terms.renames.push({from:y,to:v,options:a(g.renameDefaults,_)}),C}},schema:{method(y="any"){return this.$_addRule({name:"schema",args:{type:y}})},validate:(y,v,{type:_})=>!c.isSchema(y)||_!=="any"&&y.type!==_?v.error("object.schema",{type:_}):y},unknown:{method(y){return this.$_setFlag("unknown",y!==!1)}},with:{method(y,v,_={}){return g.dependency(this,"with",y,v,_)}},without:{method(y,v,_={}){return g.dependency(this,"without",y,v,_)}},xor:{method(...y){return c.verifyFlat(y,"xor"),g.dependency(this,"xor",null,y)}}},overrides:{default(y,v){return y===void 0&&(y=c.symbols.deepDefault),this.$_parent("default",y,v)}},rebuild(y){if(y.$_terms.keys){const v=new d.Sorter;for(const _ of y.$_terms.keys)c.tryWithPath(()=>v.add(_,{after:_.schema.$_rootReferences(),group:_.key}),_.key);y.$_terms.keys=new g.Keys(...v.nodes)}},manifest:{build(y,v){if(v.keys&&(y=y.keys(v.keys)),v.dependencies)for(const{rel:_,key:C=null,peers:S,options:T}of v.dependencies)y=g.dependency(y,_,C,S,T);if(v.patterns)for(const{regex:_,schema:C,rule:S,fallthrough:T,matches:w}of v.patterns)y=y.pattern(_||C,S,{fallthrough:T,matches:w});if(v.renames)for(const{from:_,to:C,options:S}of v.renames)y=y.rename(_,C,S);return y}},messages:{"object.and":"{{#label}} contains {{#presentWithLabels}} without its required peers {{#missingWithLabels}}","object.assert":'{{#label}} is invalid because {if(#subject.key, `"` + #subject.key + `" failed to ` + (#message || "pass the assertion test"), #message || "the assertion failed")}',"object.base":"{{#label}} must be of type {{#type}}","object.instance":"{{#label}} must be an instance of {{:#type}}","object.length":'{{#label}} must have {{#limit}} key{if(#limit == 1, "", "s")}',"object.max":'{{#label}} must have less than or equal to {{#limit}} key{if(#limit == 1, "", "s")}',"object.min":'{{#label}} must have at least {{#limit}} key{if(#limit == 1, "", "s")}',"object.missing":"{{#label}} must contain at least one of {{#peersWithLabels}}","object.nand":"{{:#mainWithLabel}} must not exist simultaneously with {{#peersWithLabels}}","object.oxor":"{{#label}} contains a conflict between optional exclusive peers {{#peersWithLabels}}","object.pattern.match":"{{#label}} keys failed to match pattern requirements","object.refType":"{{#label}} must be a Joi reference","object.regex":"{{#label}} must be a RegExp object","object.rename.multiple":"{{#label}} cannot rename {{:#from}} because multiple renames are disabled and another key was already renamed to {{:#to}}","object.rename.override":"{{#label}} cannot rename {{:#from}} because override is disabled and target {{:#to}} exists","object.schema":"{{#label}} must be a Joi schema of {{#type}} type","object.unknown":"{{#label}} is not allowed","object.with":"{{:#mainWithLabel}} missing required peer {{:#peerWithLabel}}","object.without":"{{:#mainWithLabel}} conflict with forbidden peer {{:#peerWithLabel}}","object.xor":"{{#label}} contains a conflict between exclusive peers {{#peersWithLabels}}"}}),g.clone=function(y,v){if(typeof y=="object"){if(v.nonEnumerables)return m(y,{shallow:!0});const C=Object.create(Object.getPrototypeOf(y));return Object.assign(C,y),C}const _=function(...C){return y.apply(this,C)};return _.prototype=m(y.prototype),Object.defineProperty(_,"name",{value:y.name,writable:!1}),Object.defineProperty(_,"length",{value:y.length,writable:!1}),Object.assign(_,y),_},g.dependency=function(y,v,_,C,S){p(_===null||typeof _=="string",v,"key must be a strings"),S||(S=C.length>1&&typeof C[C.length-1]=="object"?C.pop():{}),c.assertOptions(S,["separator","isPresent"]),C=[].concat(C);const T=c.default(S.separator,"."),w=[];for(const k of C)p(typeof k=="string",v,"peers must be strings"),w.push(u.ref(k,{separator:T,ancestor:0,prefix:!1}));_!==null&&(_=u.ref(_,{separator:T,ancestor:0,prefix:!1}));const x=y.clone();return x.$_terms.dependencies=x.$_terms.dependencies||[],x.$_terms.dependencies.push(new g.Dependency(v,_,w,C,S)),x},g.dependencies={and(y,v,_,C,S){const T=[],w=[],x=v.peers.length,k=g.isPresent(v.options);for(const E of v.peers)k(E.resolve(_,C,S,null,{shadow:!1}))===!1?T.push(E.key):w.push(E.key);if(T.length!==x&&w.length!==x)return{code:"object.and",context:{present:w,presentWithLabels:g.keysToLabels(y,w),missing:T,missingWithLabels:g.keysToLabels(y,T)}}},nand(y,v,_,C,S){const T=[],w=g.isPresent(v.options);for(const E of v.peers)w(E.resolve(_,C,S,null,{shadow:!1}))&&T.push(E.key);if(T.length!==v.peers.length)return;const x=v.paths[0],k=v.paths.slice(1);return{code:"object.nand",context:{main:x,mainWithLabel:g.keysToLabels(y,x),peers:k,peersWithLabels:g.keysToLabels(y,k)}}},or(y,v,_,C,S){const T=g.isPresent(v.options);for(const w of v.peers)if(T(w.resolve(_,C,S,null,{shadow:!1})))return;return{code:"object.missing",context:{peers:v.paths,peersWithLabels:g.keysToLabels(y,v.paths)}}},oxor(y,v,_,C,S){const T=[],w=g.isPresent(v.options);for(const k of v.peers)w(k.resolve(_,C,S,null,{shadow:!1}))&&T.push(k.key);if(!T.length||T.length===1)return;const x={peers:v.paths,peersWithLabels:g.keysToLabels(y,v.paths)};return x.present=T,x.presentWithLabels=g.keysToLabels(y,T),{code:"object.oxor",context:x}},with(y,v,_,C,S){const T=g.isPresent(v.options);for(const w of v.peers)if(T(w.resolve(_,C,S,null,{shadow:!1}))===!1)return{code:"object.with",context:{main:v.key.key,mainWithLabel:g.keysToLabels(y,v.key.key),peer:w.key,peerWithLabel:g.keysToLabels(y,w.key)}}},without(y,v,_,C,S){const T=g.isPresent(v.options);for(const w of v.peers)if(T(w.resolve(_,C,S,null,{shadow:!1})))return{code:"object.without",context:{main:v.key.key,mainWithLabel:g.keysToLabels(y,v.key.key),peer:w.key,peerWithLabel:g.keysToLabels(y,w.key)}}},xor(y,v,_,C,S){const T=[],w=g.isPresent(v.options);for(const k of v.peers)w(k.resolve(_,C,S,null,{shadow:!1}))&&T.push(k.key);if(T.length===1)return;const x={peers:v.paths,peersWithLabels:g.keysToLabels(y,v.paths)};return T.length===0?{code:"object.missing",context:x}:(x.present=T,x.presentWithLabels=g.keysToLabels(y,T),{code:"object.xor",context:x})}},g.keysToLabels=function(y,v){return Array.isArray(v)?v.map(_=>y.$_mapLabels(_)):y.$_mapLabels(v)},g.isPresent=function(y){return typeof y.isPresent=="function"?y.isPresent:v=>v!==void 0},g.rename=function(y,v,_,C,S){const T={};for(const w of y.$_terms.renames){const x=[],k=typeof w.from!="string";if(k)for(const E in v){if(v[E]===void 0&&w.options.ignoreUndefined||E===w.to)continue;const P=w.from.exec(E);P&&x.push({from:E,to:w.to,match:P})}else!Object.prototype.hasOwnProperty.call(v,w.from)||v[w.from]===void 0&&w.options.ignoreUndefined||x.push(w);for(const E of x){const P=E.from;let O=E.to;if(O instanceof b&&(O=O.render(v,_,C,E.match)),P!==O){if(!w.options.multiple&&T[O]&&(S.push(y.$_createError("object.rename.multiple",v,{from:P,to:O,pattern:k},_,C)),C.abortEarly)||Object.prototype.hasOwnProperty.call(v,O)&&!w.options.override&&!T[O]&&(S.push(y.$_createError("object.rename.override",v,{from:P,to:O,pattern:k},_,C)),C.abortEarly))return!1;v[P]===void 0?delete v[O]:v[O]=v[P],T[O]=!0,w.options.alias||delete v[P]}}}return!0},g.unknown=function(y,v,_,C,S,T){if(y.$_terms.patterns){let w=!1;const x=y.$_terms.patterns.map(E=>{if(E.matches)return w=!0,[]}),k=[v,...S.ancestors];for(const E of _){const P=v[E],O=[...S.path,E];for(let z=0;z<y.$_terms.patterns.length;++z){const I=y.$_terms.patterns[z];if(I.regex){const Z=I.regex.test(E);if(S.mainstay.tracer.debug(S,"rule",`pattern.${z}`,Z?"pass":"error"),!Z)continue}else if(!I.schema.$_match(E,S.nest(I.schema,`pattern.${z}`),T))continue;_.delete(E);const L=S.localize(O,k,{schema:I.rule,key:E}),F=I.rule.$_validate(P,L,T);if(F.errors){if(T.abortEarly)return{value:v,errors:F.errors};C.push(...F.errors)}if(I.matches&&x[z].push(E),v[E]=F.value,!I.fallthrough)break}}if(w)for(let E=0;E<x.length;++E){const P=x[E];if(!P)continue;const O=y.$_terms.patterns[E].matches,z=S.localize(S.path,k,O),I=O.$_validate(P,z,T);if(I.errors){const L=h.details(I.errors,{override:!1});L.matches=P;const F=y.$_createError("object.pattern.match",v,L,S,T);if(T.abortEarly)return{value:v,errors:F};C.push(F)}}}if(_.size&&(y.$_terms.keys||y.$_terms.patterns)){if(T.stripUnknown&&y._flags.unknown===void 0||T.skipFunctions){const w=!(!T.stripUnknown||T.stripUnknown!==!0&&!T.stripUnknown.objects);for(const x of _)w?(delete v[x],_.delete(x)):typeof v[x]=="function"&&_.delete(x)}if(!c.default(y._flags.unknown,T.allowUnknown))for(const w of _){const x=S.localize([...S.path,w],[]),k=y.$_createError("object.unknown",v[w],{child:w},x,T,{flags:!1});if(T.abortEarly)return{value:v,errors:k};C.push(k)}}},g.Dependency=class{constructor(y,v,_,C,S){this.rel=y,this.key=v,this.peers=_,this.paths=C,this.options=S}describe(){const y={rel:this.rel,peers:this.paths};return this.key!==null&&(y.key=this.key.key),this.peers[0].separator!=="."&&(y.options={...y.options,separator:this.peers[0].separator}),this.options.isPresent&&(y.options={...y.options,isPresent:this.options.isPresent}),y}},g.Keys=class extends Array{concat(y){const v=this.slice(),_=new Map;for(let C=0;C<v.length;++C)_.set(v[C].key,C);for(const C of y){const S=C.key,T=_.get(S);T!==void 0?v[T]={key:S,schema:v[T].schema.concat(C.schema)}:v.push(C)}return v}}},8785:(r,n,o)=>{const a=o(375),p=o(8068),m=o(8160),d=o(3292),l=o(6354),c={};r.exports=p.extend({type:"link",properties:{schemaChain:!0},terms:{link:{init:null,manifest:"single",register:!1}},args:(u,h)=>u.ref(h),validate(u,{schema:h,state:f,prefs:b}){a(h.$_terms.link,"Uninitialized link schema");const g=c.generate(h,u,f,b),y=h.$_terms.link[0].ref;return g.$_validate(u,f.nest(g,`link:${y.display}:${g.type}`),b)},generate:(u,h,f,b)=>c.generate(u,h,f,b),rules:{ref:{method(u){a(!this.$_terms.link,"Cannot reinitialize schema"),u=d.ref(u),a(u.type==="value"||u.type==="local","Invalid reference type:",u.type),a(u.type==="local"||u.ancestor==="root"||u.ancestor>0,"Link cannot reference itself");const h=this.clone();return h.$_terms.link=[{ref:u}],h}},relative:{method(u=!0){return this.$_setFlag("relative",u)}}},overrides:{concat(u){a(this.$_terms.link,"Uninitialized link schema"),a(m.isSchema(u),"Invalid schema object"),a(u.type!=="link","Cannot merge type link with another link");const h=this.clone();return h.$_terms.whens||(h.$_terms.whens=[]),h.$_terms.whens.push({concat:u}),h.$_mutateRebuild()}},manifest:{build:(u,h)=>(a(h.link,"Invalid link description missing link"),u.ref(h.link))}}),c.generate=function(u,h,f,b){let g=f.mainstay.links.get(u);if(g)return g._generate(h,f,b).schema;const y=u.$_terms.link[0].ref,{perspective:v,path:_}=c.perspective(y,f);c.assert(v,"which is outside of schema boundaries",y,u,f,b);try{g=_.length?v.$_reach(_):v}catch{c.assert(!1,"to non-existing schema",y,u,f,b)}return c.assert(g.type!=="link","which is another link",y,u,f,b),u._flags.relative||f.mainstay.links.set(u,g),g._generate(h,f,b).schema},c.perspective=function(u,h){if(u.type==="local"){for(const{schema:f,key:b}of h.schemas){if((f._flags.id||b)===u.path[0])return{perspective:f,path:u.path.slice(1)};if(f.$_terms.shared){for(const g of f.$_terms.shared)if(g._flags.id===u.path[0])return{perspective:g,path:u.path.slice(1)}}}return{perspective:null,path:null}}return u.ancestor==="root"?{perspective:h.schemas[h.schemas.length-1].schema,path:u.path}:{perspective:h.schemas[u.ancestor]&&h.schemas[u.ancestor].schema,path:u.path}},c.assert=function(u,h,f,b,g,y){u||a(!1,`"${l.label(b._flags,g,y)}" contains link reference "${f.display}" ${h}`)}},3832:(r,n,o)=>{const a=o(375),p=o(8068),m=o(8160),d={numberRx:/^\s*[+-]?(?:(?:\d+(?:\.\d*)?)|(?:\.\d+))(?:e([+-]?\d+))?\s*$/i,precisionRx:/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/,exponentialPartRegex:/[eE][+-]?\d+$/,leadingSignAndZerosRegex:/^[+-]?(0*)?/,dotRegex:/\./,trailingZerosRegex:/0+$/,decimalPlaces(l){const c=l.toString(),u=c.indexOf("."),h=c.indexOf("e");return(u<0?0:(h<0?c.length:h)-u-1)+(h<0?0:Math.max(0,-parseInt(c.slice(h+1))))}};r.exports=p.extend({type:"number",flags:{unsafe:{default:!1}},coerce:{from:"string",method(l,{schema:c,error:u}){if(!l.match(d.numberRx))return;l=l.trim();const h={value:parseFloat(l)};if(h.value===0&&(h.value=0),!c._flags.unsafe)if(l.match(/e/i)){if(d.extractSignificantDigits(l)!==d.extractSignificantDigits(String(h.value)))return h.errors=u("number.unsafe"),h}else{const f=h.value.toString();if(f.match(/e/i))return h;if(f!==d.normalizeDecimal(l))return h.errors=u("number.unsafe"),h}return h}},validate(l,{schema:c,error:u,prefs:h}){if(l===1/0||l===-1/0)return{value:l,errors:u("number.infinity")};if(!m.isNumber(l))return{value:l,errors:u("number.base")};const f={value:l};if(h.convert){const b=c.$_getRule("precision");if(b){const g=Math.pow(10,b.args.limit);f.value=Math.round(f.value*g)/g}}return f.value===0&&(f.value=0),!c._flags.unsafe&&(l>Number.MAX_SAFE_INTEGER||l<Number.MIN_SAFE_INTEGER)&&(f.errors=u("number.unsafe")),f},rules:{compare:{method:!1,validate:(l,c,{limit:u},{name:h,operator:f,args:b})=>m.compare(l,u,f)?l:c.error("number."+h,{limit:b.limit,value:l}),args:[{name:"limit",ref:!0,assert:m.isNumber,message:"must be a number"}]},greater:{method(l){return this.$_addRule({name:"greater",method:"compare",args:{limit:l},operator:">"})}},integer:{method(){return this.$_addRule("integer")},validate:(l,c)=>Math.trunc(l)-l==0?l:c.error("number.integer")},less:{method(l){return this.$_addRule({name:"less",method:"compare",args:{limit:l},operator:"<"})}},max:{method(l){return this.$_addRule({name:"max",method:"compare",args:{limit:l},operator:"<="})}},min:{method(l){return this.$_addRule({name:"min",method:"compare",args:{limit:l},operator:">="})}},multiple:{method(l){const c=typeof l=="number"?d.decimalPlaces(l):null,u=Math.pow(10,c);return this.$_addRule({name:"multiple",args:{base:l,baseDecimalPlace:c,pfactor:u}})},validate:(l,c,{base:u,baseDecimalPlace:h,pfactor:f},b)=>d.decimalPlaces(l)>h?c.error("number.multiple",{multiple:b.args.base,value:l}):Math.round(f*l)%Math.round(f*u)==0?l:c.error("number.multiple",{multiple:b.args.base,value:l}),args:[{name:"base",ref:!0,assert:l=>typeof l=="number"&&isFinite(l)&&l>0,message:"must be a positive number"},"baseDecimalPlace","pfactor"],multi:!0},negative:{method(){return this.sign("negative")}},port:{method(){return this.$_addRule("port")},validate:(l,c)=>Number.isSafeInteger(l)&&l>=0&&l<=65535?l:c.error("number.port")},positive:{method(){return this.sign("positive")}},precision:{method(l){return a(Number.isSafeInteger(l),"limit must be an integer"),this.$_addRule({name:"precision",args:{limit:l}})},validate(l,c,{limit:u}){const h=l.toString().match(d.precisionRx);return Math.max((h[1]?h[1].length:0)-(h[2]?parseInt(h[2],10):0),0)<=u?l:c.error("number.precision",{limit:u,value:l})},convert:!0},sign:{method(l){return a(["negative","positive"].includes(l),"Invalid sign",l),this.$_addRule({name:"sign",args:{sign:l}})},validate:(l,c,{sign:u})=>u==="negative"&&l<0||u==="positive"&&l>0?l:c.error(`number.${u}`)},unsafe:{method(l=!0){return a(typeof l=="boolean","enabled must be a boolean"),this.$_setFlag("unsafe",l)}}},cast:{string:{from:l=>typeof l=="number",to:(l,c)=>l.toString()}},messages:{"number.base":"{{#label}} must be a number","number.greater":"{{#label}} must be greater than {{#limit}}","number.infinity":"{{#label}} cannot be infinity","number.integer":"{{#label}} must be an integer","number.less":"{{#label}} must be less than {{#limit}}","number.max":"{{#label}} must be less than or equal to {{#limit}}","number.min":"{{#label}} must be greater than or equal to {{#limit}}","number.multiple":"{{#label}} must be a multiple of {{#multiple}}","number.negative":"{{#label}} must be a negative number","number.port":"{{#label}} must be a valid port","number.positive":"{{#label}} must be a positive number","number.precision":"{{#label}} must have no more than {{#limit}} decimal places","number.unsafe":"{{#label}} must be a safe number"}}),d.extractSignificantDigits=function(l){return l.replace(d.exponentialPartRegex,"").replace(d.dotRegex,"").replace(d.trailingZerosRegex,"").replace(d.leadingSignAndZerosRegex,"")},d.normalizeDecimal=function(l){return(l=l.replace(/^\+/,"").replace(/\.0*$/,"").replace(/^(-?)\.([^\.]*)$/,"$10.$2").replace(/^(-?)0+([0-9])/,"$1$2")).includes(".")&&l.endsWith("0")&&(l=l.replace(/0+$/,"")),l==="-0"?"0":l}},8966:(r,n,o)=>{const a=o(7824);r.exports=a.extend({type:"object",cast:{map:{from:p=>p&&typeof p=="object",to:(p,m)=>new Map(Object.entries(p))}}})},7417:(r,n,o)=>{const a=o(375),p=o(5380),m=o(1745),d=o(9959),l=o(6064),c=o(9926),u=o(5752),h=o(8068),f=o(8160),b={tlds:c instanceof Set&&{tlds:{allow:c,deny:null}},base64Regex:{true:{true:/^(?:[\w\-]{2}[\w\-]{2})*(?:[\w\-]{2}==|[\w\-]{3}=)?$/,false:/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/},false:{true:/^(?:[\w\-]{2}[\w\-]{2})*(?:[\w\-]{2}(==)?|[\w\-]{3}=?)?$/,false:/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}(==)?|[A-Za-z0-9+\/]{3}=?)?$/}},dataUriRegex:/^data:[\w+.-]+\/[\w+.-]+;((charset=[\w-]+|base64),)?(.*)$/,hexRegex:{withPrefix:/^0x[0-9a-f]+$/i,withOptionalPrefix:/^(?:0x)?[0-9a-f]+$/i,withoutPrefix:/^[0-9a-f]+$/i},ipRegex:d.regex({cidr:"forbidden"}).regex,isoDurationRegex:/^P(?!$)(\d+Y)?(\d+M)?(\d+W)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?$/,guidBrackets:{"{":"}","[":"]","(":")","":""},guidVersions:{uuidv1:"1",uuidv2:"2",uuidv3:"3",uuidv4:"4",uuidv5:"5",uuidv6:"6",uuidv7:"7",uuidv8:"8"},guidSeparators:new Set([void 0,!0,!1,"-",":"]),normalizationForms:["NFC","NFD","NFKC","NFKD"]};r.exports=h.extend({type:"string",flags:{insensitive:{default:!1},truncate:{default:!1}},terms:{replacements:{init:null}},coerce:{from:"string",method(g,{schema:y,state:v,prefs:_}){const C=y.$_getRule("normalize");C&&(g=g.normalize(C.args.form));const S=y.$_getRule("case");S&&(g=S.args.direction==="upper"?g.toLocaleUpperCase():g.toLocaleLowerCase());const T=y.$_getRule("trim");if(T&&T.args.enabled&&(g=g.trim()),y.$_terms.replacements)for(const x of y.$_terms.replacements)g=g.replace(x.pattern,x.replacement);const w=y.$_getRule("hex");if(w&&w.args.options.byteAligned&&g.length%2!=0&&(g=`0${g}`),y.$_getRule("isoDate")){const x=b.isoDate(g);x&&(g=x)}if(y._flags.truncate){const x=y.$_getRule("max");if(x){let k=x.args.limit;if(f.isResolvable(k)&&(k=k.resolve(g,v,_),!f.limit(k)))return{value:g,errors:y.$_createError("any.ref",k,{ref:x.args.limit,arg:"limit",reason:"must be a positive integer"},v,_)};g=g.slice(0,k)}}return{value:g}}},validate(g,{schema:y,error:v}){if(typeof g!="string")return{value:g,errors:v("string.base")};if(g===""){const _=y.$_getRule("min");return _&&_.args.limit===0?void 0:{value:g,errors:v("string.empty")}}},rules:{alphanum:{method(){return this.$_addRule("alphanum")},validate:(g,y)=>/^[a-zA-Z0-9]+$/.test(g)?g:y.error("string.alphanum")},base64:{method(g={}){return f.assertOptions(g,["paddingRequired","urlSafe"]),g={urlSafe:!1,paddingRequired:!0,...g},a(typeof g.paddingRequired=="boolean","paddingRequired must be boolean"),a(typeof g.urlSafe=="boolean","urlSafe must be boolean"),this.$_addRule({name:"base64",args:{options:g}})},validate:(g,y,{options:v})=>b.base64Regex[v.paddingRequired][v.urlSafe].test(g)?g:y.error("string.base64")},case:{method(g){return a(["lower","upper"].includes(g),"Invalid case:",g),this.$_addRule({name:"case",args:{direction:g}})},validate:(g,y,{direction:v})=>v==="lower"&&g===g.toLocaleLowerCase()||v==="upper"&&g===g.toLocaleUpperCase()?g:y.error(`string.${v}case`),convert:!0},creditCard:{method(){return this.$_addRule("creditCard")},validate(g,y){let v=g.length,_=0,C=1;for(;v--;){const S=g.charAt(v)*C;_+=S-9*(S>9),C^=3}return _>0&&_%10==0?g:y.error("string.creditCard")}},dataUri:{method(g={}){return f.assertOptions(g,["paddingRequired"]),g={paddingRequired:!0,...g},a(typeof g.paddingRequired=="boolean","paddingRequired must be boolean"),this.$_addRule({name:"dataUri",args:{options:g}})},validate(g,y,{options:v}){const _=g.match(b.dataUriRegex);return _&&(!_[2]||_[2]!=="base64"||b.base64Regex[v.paddingRequired].false.test(_[3]))?g:y.error("string.dataUri")}},domain:{method(g){g&&f.assertOptions(g,["allowFullyQualified","allowUnicode","maxDomainSegments","minDomainSegments","tlds"]);const y=b.addressOptions(g);return this.$_addRule({name:"domain",args:{options:g},address:y})},validate:(g,y,v,{address:_})=>p.isValid(g,_)?g:y.error("string.domain")},email:{method(g={}){f.assertOptions(g,["allowFullyQualified","allowUnicode","ignoreLength","maxDomainSegments","minDomainSegments","multiple","separator","tlds"]),a(g.multiple===void 0||typeof g.multiple=="boolean","multiple option must be an boolean");const y=b.addressOptions(g),v=new RegExp(`\\s*[${g.separator?l(g.separator):","}]\\s*`);return this.$_addRule({name:"email",args:{options:g},regex:v,address:y})},validate(g,y,{options:v},{regex:_,address:C}){const S=v.multiple?g.split(_):[g],T=[];for(const w of S)m.isValid(w,C)||T.push(w);return T.length?y.error("string.email",{value:g,invalids:T}):g}},guid:{alias:"uuid",method(g={}){f.assertOptions(g,["version","separator"]);let y="";if(g.version){const C=[].concat(g.version);a(C.length>=1,"version must have at least 1 valid version specified");const S=new Set;for(let T=0;T<C.length;++T){const w=C[T];a(typeof w=="string","version at position "+T+" must be a string");const x=b.guidVersions[w.toLowerCase()];a(x,"version at position "+T+" must be one of "+Object.keys(b.guidVersions).join(", ")),a(!S.has(x),"version at position "+T+" must not be a duplicate"),y+=x,S.add(x)}}a(b.guidSeparators.has(g.separator),'separator must be one of true, false, "-", or ":"');const v=g.separator===void 0?"[:-]?":g.separator===!0?"[:-]":g.separator===!1?"[]?":`\\${g.separator}`,_=new RegExp(`^([\\[{\\(]?)[0-9A-F]{8}(${v})[0-9A-F]{4}\\2?[${y||"0-9A-F"}][0-9A-F]{3}\\2?[${y?"89AB":"0-9A-F"}][0-9A-F]{3}\\2?[0-9A-F]{12}([\\]}\\)]?)$`,"i");return this.$_addRule({name:"guid",args:{options:g},regex:_})},validate(g,y,v,{regex:_}){const C=_.exec(g);return C?b.guidBrackets[C[1]]!==C[C.length-1]?y.error("string.guid"):g:y.error("string.guid")}},hex:{method(g={}){return f.assertOptions(g,["byteAligned","prefix"]),g={byteAligned:!1,prefix:!1,...g},a(typeof g.byteAligned=="boolean","byteAligned must be boolean"),a(typeof g.prefix=="boolean"||g.prefix==="optional",'prefix must be boolean or "optional"'),this.$_addRule({name:"hex",args:{options:g}})},validate:(g,y,{options:v})=>(v.prefix==="optional"?b.hexRegex.withOptionalPrefix:v.prefix===!0?b.hexRegex.withPrefix:b.hexRegex.withoutPrefix).test(g)?v.byteAligned&&g.length%2!=0?y.error("string.hexAlign"):g:y.error("string.hex")},hostname:{method(){return this.$_addRule("hostname")},validate:(g,y)=>p.isValid(g,{minDomainSegments:1})||b.ipRegex.test(g)?g:y.error("string.hostname")},insensitive:{method(){return this.$_setFlag("insensitive",!0)}},ip:{method(g={}){f.assertOptions(g,["cidr","version"]);const{cidr:y,versions:v,regex:_}=d.regex(g),C=g.version?v:void 0;return this.$_addRule({name:"ip",args:{options:{cidr:y,version:C}},regex:_})},validate:(g,y,{options:v},{regex:_})=>_.test(g)?g:v.version?y.error("string.ipVersion",{value:g,cidr:v.cidr,version:v.version}):y.error("string.ip",{value:g,cidr:v.cidr})},isoDate:{method(){return this.$_addRule("isoDate")},validate:(g,{error:y})=>b.isoDate(g)?g:y("string.isoDate")},isoDuration:{method(){return this.$_addRule("isoDuration")},validate:(g,y)=>b.isoDurationRegex.test(g)?g:y.error("string.isoDuration")},length:{method(g,y){return b.length(this,"length",g,"=",y)},validate(g,y,{limit:v,encoding:_},{name:C,operator:S,args:T}){const w=!_&&g.length;return f.compare(w,v,S)?g:y.error("string."+C,{limit:T.limit,value:g,encoding:_})},args:[{name:"limit",ref:!0,assert:f.limit,message:"must be a positive integer"},"encoding"]},lowercase:{method(){return this.case("lower")}},max:{method(g,y){return b.length(this,"max",g,"<=",y)},args:["limit","encoding"]},min:{method(g,y){return b.length(this,"min",g,">=",y)},args:["limit","encoding"]},normalize:{method(g="NFC"){return a(b.normalizationForms.includes(g),"normalization form must be one of "+b.normalizationForms.join(", ")),this.$_addRule({name:"normalize",args:{form:g}})},validate:(g,{error:y},{form:v})=>g===g.normalize(v)?g:y("string.normalize",{value:g,form:v}),convert:!0},pattern:{alias:"regex",method(g,y={}){a(g instanceof RegExp,"regex must be a RegExp"),a(!g.flags.includes("g")&&!g.flags.includes("y"),"regex should not use global or sticky mode"),typeof y=="string"&&(y={name:y}),f.assertOptions(y,["invert","name"]);const v=["string.pattern",y.invert?".invert":"",y.name?".name":".base"].join("");return this.$_addRule({name:"pattern",args:{regex:g,options:y},errorCode:v})},validate:(g,y,{regex:v,options:_},{errorCode:C})=>v.test(g)^_.invert?g:y.error(C,{name:_.name,regex:v,value:g}),args:["regex","options"],multi:!0},replace:{method(g,y){typeof g=="string"&&(g=new RegExp(l(g),"g")),a(g instanceof RegExp,"pattern must be a RegExp"),a(typeof y=="string","replacement must be a String");const v=this.clone();return v.$_terms.replacements||(v.$_terms.replacements=[]),v.$_terms.replacements.push({pattern:g,replacement:y}),v}},token:{method(){return this.$_addRule("token")},validate:(g,y)=>/^\w+$/.test(g)?g:y.error("string.token")},trim:{method(g=!0){return a(typeof g=="boolean","enabled must be a boolean"),this.$_addRule({name:"trim",args:{enabled:g}})},validate:(g,y,{enabled:v})=>v&&g!==g.trim()?y.error("string.trim"):g,convert:!0},truncate:{method(g=!0){return a(typeof g=="boolean","enabled must be a boolean"),this.$_setFlag("truncate",g)}},uppercase:{method(){return this.case("upper")}},uri:{method(g={}){f.assertOptions(g,["allowRelative","allowQuerySquareBrackets","domain","relativeOnly","scheme","encodeUri"]),g.domain&&f.assertOptions(g.domain,["allowFullyQualified","allowUnicode","maxDomainSegments","minDomainSegments","tlds"]);const{regex:y,scheme:v}=u.regex(g),_=g.domain?b.addressOptions(g.domain):null;return this.$_addRule({name:"uri",args:{options:g},regex:y,domain:_,scheme:v})},validate(g,y,{options:v},{regex:_,domain:C,scheme:S}){if(["http:/","https:/"].includes(g))return y.error("string.uri");let T=_.exec(g);if(!T&&y.prefs.convert&&v.encodeUri){const w=encodeURI(g);T=_.exec(w),T&&(g=w)}if(T){const w=T[1]||T[2];return!C||v.allowRelative&&!w||p.isValid(w,C)?g:y.error("string.domain",{value:w})}return v.relativeOnly?y.error("string.uriRelativeOnly"):v.scheme?y.error("string.uriCustomScheme",{scheme:S,value:g}):y.error("string.uri")}}},manifest:{build(g,y){if(y.replacements)for(const{pattern:v,replacement:_}of y.replacements)g=g.replace(v,_);return g}},messages:{"string.alphanum":"{{#label}} must only contain alpha-numeric characters","string.base":"{{#label}} must be a string","string.base64":"{{#label}} must be a valid base64 string","string.creditCard":"{{#label}} must be a credit card","string.dataUri":"{{#label}} must be a valid dataUri string","string.domain":"{{#label}} must contain a valid domain name","string.email":"{{#label}} must be a valid email","string.empty":"{{#label}} is not allowed to be empty","string.guid":"{{#label}} must be a valid GUID","string.hex":"{{#label}} must only contain hexadecimal characters","string.hexAlign":"{{#label}} hex decoded representation must be byte aligned","string.hostname":"{{#label}} must be a valid hostname","string.ip":"{{#label}} must be a valid ip address with a {{#cidr}} CIDR","string.ipVersion":"{{#label}} must be a valid ip address of one of the following versions {{#version}} with a {{#cidr}} CIDR","string.isoDate":"{{#label}} must be in iso format","string.isoDuration":"{{#label}} must be a valid ISO 8601 duration","string.length":"{{#label}} length must be {{#limit}} characters long","string.lowercase":"{{#label}} must only contain lowercase characters","string.max":"{{#label}} length must be less than or equal to {{#limit}} characters long","string.min":"{{#label}} length must be at least {{#limit}} characters long","string.normalize":"{{#label}} must be unicode normalized in the {{#form}} form","string.token":"{{#label}} must only contain alpha-numeric and underscore characters","string.pattern.base":"{{#label}} with value {:[.]} fails to match the required pattern: {{#regex}}","string.pattern.name":"{{#label}} with value {:[.]} fails to match the {{#name}} pattern","string.pattern.invert.base":"{{#label}} with value {:[.]} matches the inverted pattern: {{#regex}}","string.pattern.invert.name":"{{#label}} with value {:[.]} matches the inverted {{#name}} pattern","string.trim":"{{#label}} must not have leading or trailing whitespace","string.uri":"{{#label}} must be a valid uri","string.uriCustomScheme":"{{#label}} must be a valid uri with a scheme matching the {{#scheme}} pattern","string.uriRelativeOnly":"{{#label}} must be a valid relative uri","string.uppercase":"{{#label}} must only contain uppercase characters"}}),b.addressOptions=function(g){if(!g)return b.tlds||g;if(a(g.minDomainSegments===void 0||Number.isSafeInteger(g.minDomainSegments)&&g.minDomainSegments>0,"minDomainSegments must be a positive integer"),a(g.maxDomainSegments===void 0||Number.isSafeInteger(g.maxDomainSegments)&&g.maxDomainSegments>0,"maxDomainSegments must be a positive integer"),g.tlds===!1)return g;if(g.tlds===!0||g.tlds===void 0)return a(b.tlds,"Built-in TLD list disabled"),Object.assign({},g,b.tlds);a(typeof g.tlds=="object","tlds must be true, false, or an object");const y=g.tlds.deny;if(y)return Array.isArray(y)&&(g=Object.assign({},g,{tlds:{deny:new Set(y)}})),a(g.tlds.deny instanceof Set,"tlds.deny must be an array, Set, or boolean"),a(!g.tlds.allow,"Cannot specify both tlds.allow and tlds.deny lists"),b.validateTlds(g.tlds.deny,"tlds.deny"),g;const v=g.tlds.allow;return v?v===!0?(a(b.tlds,"Built-in TLD list disabled"),Object.assign({},g,b.tlds)):(Array.isArray(v)&&(g=Object.assign({},g,{tlds:{allow:new Set(v)}})),a(g.tlds.allow instanceof Set,"tlds.allow must be an array, Set, or boolean"),b.validateTlds(g.tlds.allow,"tlds.allow"),g):g},b.validateTlds=function(g,y){for(const v of g)a(p.isValid(v,{minDomainSegments:1,maxDomainSegments:1}),`${y} must contain valid top level domain names`)},b.isoDate=function(g){if(!f.isIsoDate(g))return null;/.*T.*[+-]\d\d$/.test(g)&&(g+="00");const y=new Date(g);return isNaN(y.getTime())?null:y.toISOString()},b.length=function(g,y,v,_,C){return a(!C||!1,"Invalid encoding:",C),g.$_addRule({name:y,method:"length",args:{limit:v,encoding:C},operator:_})}},8826:(r,n,o)=>{const a=o(375),p=o(8068),m={};m.Map=class extends Map{slice(){return new m.Map(this)}},r.exports=p.extend({type:"symbol",terms:{map:{init:new m.Map}},coerce:{method(d,{schema:l,error:c}){const u=l.$_terms.map.get(d);return u&&(d=u),l._flags.only&&typeof d!="symbol"?{value:d,errors:c("symbol.map",{map:l.$_terms.map})}:{value:d}}},validate(d,{error:l}){if(typeof d!="symbol")return{value:d,errors:l("symbol.base")}},rules:{map:{method(d){d&&!d[Symbol.iterator]&&typeof d=="object"&&(d=Object.entries(d)),a(d&&d[Symbol.iterator],"Iterable must be an iterable or object");const l=this.clone(),c=[];for(const u of d){a(u&&u[Symbol.iterator],"Entry must be an iterable");const[h,f]=u;a(typeof h!="object"&&typeof h!="function"&&typeof h!="symbol","Key must not be of type object, function, or Symbol"),a(typeof f=="symbol","Value must be a Symbol"),l.$_terms.map.set(h,f),c.push(f)}return l.valid(...c)}}},manifest:{build:(d,l)=>(l.map&&(d=d.map(l.map)),d)},messages:{"symbol.base":"{{#label}} must be a symbol","symbol.map":"{{#label}} must be one of {{#map}}"}})},8863:(r,n,o)=>{const a=o(375),p=o(8571),m=o(738),d=o(9621),l=o(8160),c=o(6354),u=o(493),h={result:Symbol("result")};n.entry=function(f,b,g){let y=l.defaults;g&&(a(g.warnings===void 0,"Cannot override warnings preference in synchronous validation"),a(g.artifacts===void 0,"Cannot override artifacts preference in synchronous validation"),y=l.preferences(l.defaults,g));const v=h.entry(f,b,y);a(!v.mainstay.externals.length,"Schema with external rules must use validateAsync()");const _={value:v.value};return v.error&&(_.error=v.error),v.mainstay.warnings.length&&(_.warning=c.details(v.mainstay.warnings)),v.mainstay.debug&&(_.debug=v.mainstay.debug),v.mainstay.artifacts&&(_.artifacts=v.mainstay.artifacts),_},n.entryAsync=async function(f,b,g){let y=l.defaults;g&&(y=l.preferences(l.defaults,g));const v=h.entry(f,b,y),_=v.mainstay;if(v.error)throw _.debug&&(v.error.debug=_.debug),v.error;if(_.externals.length){let S=v.value;const T=[];for(const w of _.externals){const x=w.state.path,k=w.schema.type==="link"?_.links.get(w.schema):null;let E,P,O=S;const z=x.length?[S]:[],I=x.length?d(f,x):f;if(x.length){E=x[x.length-1];let L=S;for(const F of x.slice(0,-1))L=L[F],z.unshift(L);P=z[0],O=P[E]}try{const L=(Z,Q)=>(k||w.schema).$_createError(Z,O,Q,w.state,y),F=await w.method(O,{schema:w.schema,linked:k,state:w.state,prefs:g,original:I,error:L,errorsArray:h.errorsArray,warn:(Z,Q)=>_.warnings.push((k||w.schema).$_createError(Z,O,Q,w.state,y)),message:(Z,Q)=>(k||w.schema).$_createError("external",O,Q,w.state,y,{messages:Z})});if(F===void 0||F===O)continue;if(F instanceof c.Report){if(_.tracer.log(w.schema,w.state,"rule","external","error"),T.push(F),y.abortEarly)break;continue}if(Array.isArray(F)&&F[l.symbols.errors]){if(_.tracer.log(w.schema,w.state,"rule","external","error"),T.push(...F),y.abortEarly)break;continue}P?(_.tracer.value(w.state,"rule",O,F,"external"),P[E]=F):(_.tracer.value(w.state,"rule",S,F,"external"),S=F)}catch(L){throw y.errors.label&&(L.message+=` (${w.label})`),L}}if(v.value=S,T.length)throw v.error=c.process(T,f,y),_.debug&&(v.error.debug=_.debug),v.error}if(!y.warnings&&!y.debug&&!y.artifacts)return v.value;const C={value:v.value};return _.warnings.length&&(C.warning=c.details(_.warnings)),_.debug&&(C.debug=_.debug),_.artifacts&&(C.artifacts=_.artifacts),C},h.Mainstay=class{constructor(f,b,g){this.externals=[],this.warnings=[],this.tracer=f,this.debug=b,this.links=g,this.shadow=null,this.artifacts=null,this._snapshots=[]}snapshot(){this._snapshots.push({externals:this.externals.slice(),warnings:this.warnings.slice()})}restore(){const f=this._snapshots.pop();this.externals=f.externals,this.warnings=f.warnings}commit(){this._snapshots.pop()}},h.entry=function(f,b,g){const{tracer:y,cleanup:v}=h.tracer(b,g),_=g.debug?[]:null,C=b._ids._schemaChain?new Map:null,S=new h.Mainstay(y,_,C),T=b._ids._schemaChain?[{schema:b}]:null,w=new u([],[],{mainstay:S,schemas:T}),x=n.validate(f,b,w,g);v&&b.$_root.untrace();const k=c.process(x.errors,f,g);return{value:x.value,error:k,mainstay:S}},h.tracer=function(f,b){return f.$_root._tracer?{tracer:f.$_root._tracer._register(f)}:b.debug?(a(f.$_root.trace,"Debug mode not supported"),{tracer:f.$_root.trace()._register(f),cleanup:!0}):{tracer:h.ignore}},n.validate=function(f,b,g,y,v={}){if(b.$_terms.whens&&(b=b._generate(f,g,y).schema),b._preferences&&(y=h.prefs(b,y)),b._cache&&y.cache){const k=b._cache.get(f);if(g.mainstay.tracer.debug(g,"validate","cached",!!k),k)return k}const _=(k,E,P)=>b.$_createError(k,f,E,P||g,y),C={original:f,prefs:y,schema:b,state:g,error:_,errorsArray:h.errorsArray,warn:(k,E,P)=>g.mainstay.warnings.push(_(k,E,P)),message:(k,E)=>b.$_createError("custom",f,E,g,y,{messages:k})};g.mainstay.tracer.entry(b,g);const S=b._definition;if(S.prepare&&f!==void 0&&y.convert){const k=S.prepare(f,C);if(k){if(g.mainstay.tracer.value(g,"prepare",f,k.value),k.errors)return h.finalize(k.value,[].concat(k.errors),C);f=k.value}}if(S.coerce&&f!==void 0&&y.convert&&(!S.coerce.from||S.coerce.from.includes(typeof f))){const k=S.coerce.method(f,C);if(k){if(g.mainstay.tracer.value(g,"coerced",f,k.value),k.errors)return h.finalize(k.value,[].concat(k.errors),C);f=k.value}}const T=b._flags.empty;T&&T.$_match(h.trim(f,b),g.nest(T),l.defaults)&&(g.mainstay.tracer.value(g,"empty",f,void 0),f=void 0);const w=v.presence||b._flags.presence||(b._flags._endedSwitch?null:y.presence);if(f===void 0){if(w==="forbidden")return h.finalize(f,null,C);if(w==="required")return h.finalize(f,[b.$_createError("any.required",f,null,g,y)],C);if(w==="optional"){if(b._flags.default!==l.symbols.deepDefault)return h.finalize(f,null,C);g.mainstay.tracer.value(g,"default",f,{}),f={}}}else if(w==="forbidden")return h.finalize(f,[b.$_createError("any.unknown",f,null,g,y)],C);const x=[];if(b._valids){const k=b._valids.get(f,g,y,b._flags.insensitive);if(k)return y.convert&&(g.mainstay.tracer.value(g,"valids",f,k.value),f=k.value),g.mainstay.tracer.filter(b,g,"valid",k),h.finalize(f,null,C);if(b._flags.only){const E=b.$_createError("any.only",f,{valids:b._valids.values({display:!0})},g,y);if(y.abortEarly)return h.finalize(f,[E],C);x.push(E)}}if(b._invalids){const k=b._invalids.get(f,g,y,b._flags.insensitive);if(k){g.mainstay.tracer.filter(b,g,"invalid",k);const E=b.$_createError("any.invalid",f,{invalids:b._invalids.values({display:!0})},g,y);if(y.abortEarly)return h.finalize(f,[E],C);x.push(E)}}if(S.validate){const k=S.validate(f,C);if(k&&(g.mainstay.tracer.value(g,"base",f,k.value),f=k.value,k.errors)){if(!Array.isArray(k.errors))return x.push(k.errors),h.finalize(f,x,C);if(k.errors.length)return x.push(...k.errors),h.finalize(f,x,C)}}return b._rules.length?h.rules(f,x,C):h.finalize(f,x,C)},h.rules=function(f,b,g){const{schema:y,state:v,prefs:_}=g;for(const C of y._rules){const S=y._definition.rules[C.method];if(S.convert&&_.convert){v.mainstay.tracer.log(y,v,"rule",C.name,"full");continue}let T,w=C.args;if(C._resolve.length){w=Object.assign({},w);for(const k of C._resolve){const E=S.argsByName.get(k),P=w[k].resolve(f,v,_),O=E.normalize?E.normalize(P):P,z=l.validateArg(O,null,E);if(z){T=y.$_createError("any.ref",P,{arg:k,ref:w[k],reason:z},v,_);break}w[k]=O}}T=T||S.validate(f,g,w,C);const x=h.rule(T,C);if(x.errors){if(v.mainstay.tracer.log(y,v,"rule",C.name,"error"),C.warn){v.mainstay.warnings.push(...x.errors);continue}if(_.abortEarly)return h.finalize(f,x.errors,g);b.push(...x.errors)}else v.mainstay.tracer.log(y,v,"rule",C.name,"pass"),v.mainstay.tracer.value(v,"rule",f,x.value,C.name),f=x.value}return h.finalize(f,b,g)},h.rule=function(f,b){return f instanceof c.Report?(h.error(f,b),{errors:[f],value:null}):Array.isArray(f)&&f[l.symbols.errors]?(f.forEach(g=>h.error(g,b)),{errors:f,value:null}):{errors:null,value:f}},h.error=function(f,b){return b.message&&f._setTemplate(b.message),f},h.finalize=function(f,b,g){b=b||[];const{schema:y,state:v,prefs:_}=g;if(b.length){const S=h.default("failover",void 0,b,g);S!==void 0&&(v.mainstay.tracer.value(v,"failover",f,S),f=S,b=[])}if(b.length&&y._flags.error)if(typeof y._flags.error=="function"){b=y._flags.error(b),Array.isArray(b)||(b=[b]);for(const S of b)a(S instanceof Error||S instanceof c.Report,"error() must return an Error object")}else b=[y._flags.error];if(f===void 0){const S=h.default("default",f,b,g);v.mainstay.tracer.value(v,"default",f,S),f=S}if(y._flags.cast&&f!==void 0){const S=y._definition.cast[y._flags.cast];if(S.from(f)){const T=S.to(f,g);v.mainstay.tracer.value(v,"cast",f,T,y._flags.cast),f=T}}if(y.$_terms.externals&&_.externals&&_._externals!==!1)for(const{method:S}of y.$_terms.externals)v.mainstay.externals.push({method:S,schema:y,state:v,label:c.label(y._flags,v,_)});const C={value:f,errors:b.length?b:null};return y._flags.result&&(C.value=y._flags.result==="strip"?void 0:g.original,v.mainstay.tracer.value(v,y._flags.result,f,C.value),v.shadow(f,y._flags.result)),y._cache&&_.cache!==!1&&!y._refs.length&&y._cache.set(g.original,C),f===void 0||C.errors||y._flags.artifact===void 0||(v.mainstay.artifacts=v.mainstay.artifacts||new Map,v.mainstay.artifacts.has(y._flags.artifact)||v.mainstay.artifacts.set(y._flags.artifact,[]),v.mainstay.artifacts.get(y._flags.artifact).push(v.path)),C},h.prefs=function(f,b){const g=b===l.defaults;return g&&f._preferences[l.symbols.prefs]?f._preferences[l.symbols.prefs]:(b=l.preferences(b,f._preferences),g&&(f._preferences[l.symbols.prefs]=b),b)},h.default=function(f,b,g,y){const{schema:v,state:_,prefs:C}=y,S=v._flags[f];if(C.noDefaults||S===void 0)return b;if(_.mainstay.tracer.log(v,_,"rule",f,"full"),!S)return S;if(typeof S=="function"){const T=S.length?[p(_.ancestors[0]),y]:[];try{return S(...T)}catch(w){return void g.push(v.$_createError(`any.${f}`,null,{error:w},_,C))}}return typeof S!="object"?S:S[l.symbols.literal]?S.literal:l.isResolvable(S)?S.resolve(b,_,C):p(S)},h.trim=function(f,b){if(typeof f!="string")return f;const g=b.$_getRule("trim");return g&&g.args.enabled?f.trim():f},h.ignore={active:!1,debug:m,entry:m,filter:m,log:m,resolve:m,value:m},h.errorsArray=function(){const f=[];return f[l.symbols.errors]=!0,f}},2036:(r,n,o)=>{const a=o(375),p=o(9474),m=o(8160),d={};r.exports=d.Values=class{constructor(l,c){this._values=new Set(l),this._refs=new Set(c),this._lowercase=d.lowercases(l),this._override=!1}get length(){return this._values.size+this._refs.size}add(l,c){m.isResolvable(l)?this._refs.has(l)||(this._refs.add(l),c&&c.register(l)):this.has(l,null,null,!1)||(this._values.add(l),typeof l=="string"&&this._lowercase.set(l.toLowerCase(),l))}static merge(l,c,u){if(l=l||new d.Values,c){if(c._override)return c.clone();for(const h of[...c._values,...c._refs])l.add(h)}if(u)for(const h of[...u._values,...u._refs])l.remove(h);return l.length?l:null}remove(l){m.isResolvable(l)?this._refs.delete(l):(this._values.delete(l),typeof l=="string"&&this._lowercase.delete(l.toLowerCase()))}has(l,c,u,h){return!!this.get(l,c,u,h)}get(l,c,u,h){if(!this.length)return!1;if(this._values.has(l))return{value:l};if(typeof l=="string"&&l&&h){const f=this._lowercase.get(l.toLowerCase());if(f)return{value:f}}if(!this._refs.size&&typeof l!="object")return!1;if(typeof l=="object"){for(const f of this._values)if(p(f,l))return{value:f}}if(c)for(const f of this._refs){const b=f.resolve(l,c,u,null,{in:!0});if(b===void 0)continue;const g=f.in&&typeof b=="object"?Array.isArray(b)?b:Object.keys(b):[b];for(const y of g)if(typeof y==typeof l){if(h&&l&&typeof l=="string"){if(y.toLowerCase()===l.toLowerCase())return{value:y,ref:f}}else if(p(y,l))return{value:y,ref:f}}}return!1}override(){this._override=!0}values(l){if(l&&l.display){const c=[];for(const u of[...this._values,...this._refs])u!==void 0&&c.push(u);return c}return Array.from([...this._values,...this._refs])}clone(){const l=new d.Values(this._values,this._refs);return l._override=this._override,l}concat(l){a(!l._override,"Cannot concat override set of values");const c=new d.Values([...this._values,...l._values],[...this._refs,...l._refs]);return c._override=this._override,c}describe(){const l=[];this._override&&l.push({override:!0});for(const c of this._values.values())l.push(c&&typeof c=="object"?{value:c}:c);for(const c of this._refs.values())l.push(c.describe());return l}},d.Values.prototype[m.symbols.values]=!0,d.Values.prototype.slice=d.Values.prototype.clone,d.lowercases=function(l){const c=new Map;if(l)for(const u of l)typeof u=="string"&&c.set(u.toLowerCase(),u);return c}},978:(r,n,o)=>{const a=o(375),p=o(8571),m=o(1687),d=o(9621),l={};r.exports=function(c,u,h={}){if(a(c&&typeof c=="object","Invalid defaults value: must be an object"),a(!u||u===!0||typeof u=="object","Invalid source value: must be true, falsy or an object"),a(typeof h=="object","Invalid options: must be an object"),!u)return null;if(h.shallow)return l.applyToDefaultsWithShallow(c,u,h);const f=p(c);if(u===!0)return f;const b=h.nullOverride!==void 0&&h.nullOverride;return m(f,u,{nullOverride:b,mergeArrays:!1})},l.applyToDefaultsWithShallow=function(c,u,h){const f=h.shallow;a(Array.isArray(f),"Invalid keys");const b=new Map,g=u===!0?null:new Set;for(let _ of f){_=Array.isArray(_)?_:_.split(".");const C=d(c,_);C&&typeof C=="object"?b.set(C,g&&d(u,_)||C):g&&g.add(_)}const y=p(c,{},b);if(!g)return y;for(const _ of g)l.reachCopy(y,u,_);const v=h.nullOverride!==void 0&&h.nullOverride;return m(y,u,{nullOverride:v,mergeArrays:!1})},l.reachCopy=function(c,u,h){for(const g of h){if(!(g in u))return;const y=u[g];if(typeof y!="object"||y===null)return;u=y}const f=u;let b=c;for(let g=0;g<h.length-1;++g){const y=h[g];typeof b[y]!="object"&&(b[y]={}),b=b[y]}b[h[h.length-1]]=f}},375:(r,n,o)=>{const a=o(7916);r.exports=function(p,...m){if(!p)throw m.length===1&&m[0]instanceof Error?m[0]:new a(m)}},8571:(r,n,o)=>{const a=o(9621),p=o(4277),m=o(7043),d={needsProtoHack:new Set([p.set,p.map,p.weakSet,p.weakMap])};r.exports=d.clone=function(l,c={},u=null){if(typeof l!="object"||l===null)return l;let h=d.clone,f=u;if(c.shallow){if(c.shallow!==!0)return d.cloneWithShallow(l,c);h=v=>v}else if(f){const v=f.get(l);if(v)return v}else f=new Map;const b=p.getInternalProto(l);if(b===p.buffer)return!1;if(b===p.date)return new Date(l.getTime());if(b===p.regex)return new RegExp(l);const g=d.base(l,b,c);if(g===l)return l;if(f&&f.set(l,g),b===p.set)for(const v of l)g.add(h(v,c,f));else if(b===p.map)for(const[v,_]of l)g.set(v,h(_,c,f));const y=m.keys(l,c);for(const v of y){if(v==="__proto__")continue;if(b===p.array&&v==="length"){g.length=l.length;continue}const _=Object.getOwnPropertyDescriptor(l,v);_?_.get||_.set?Object.defineProperty(g,v,_):_.enumerable?g[v]=h(l[v],c,f):Object.defineProperty(g,v,{enumerable:!1,writable:!0,configurable:!0,value:h(l[v],c,f)}):Object.defineProperty(g,v,{enumerable:!0,writable:!0,configurable:!0,value:h(l[v],c,f)})}return g},d.cloneWithShallow=function(l,c){const u=c.shallow;(c=Object.assign({},c)).shallow=!1;const h=new Map;for(const f of u){const b=a(l,f);typeof b!="object"&&typeof b!="function"||h.set(b,b)}return d.clone(l,c,h)},d.base=function(l,c,u){if(u.prototype===!1)return d.needsProtoHack.has(c)?new c.constructor:c===p.array?[]:{};const h=Object.getPrototypeOf(l);if(h&&h.isImmutable)return l;if(c===p.array){const f=[];return h!==c&&Object.setPrototypeOf(f,h),f}if(d.needsProtoHack.has(c)){const f=new h.constructor;return h!==c&&Object.setPrototypeOf(f,h),f}return Object.create(h)}},9474:(r,n,o)=>{const a=o(4277),p={mismatched:null};r.exports=function(m,d,l){return l=Object.assign({prototype:!0},l),!!p.isDeepEqual(m,d,l,[])},p.isDeepEqual=function(m,d,l,c){if(m===d)return m!==0||1/m==1/d;const u=typeof m;if(u!==typeof d||m===null||d===null)return!1;if(u==="function"){if(!l.deepFunction||m.toString()!==d.toString())return!1}else if(u!=="object")return m!=m&&d!=d;const h=p.getSharedType(m,d,!!l.prototype);switch(h){case a.buffer:return!1;case a.promise:return m===d;case a.regex:return m.toString()===d.toString();case p.mismatched:return!1}for(let f=c.length-1;f>=0;--f)if(c[f].isSame(m,d))return!0;c.push(new p.SeenEntry(m,d));try{return!!p.isDeepEqualObj(h,m,d,l,c)}finally{c.pop()}},p.getSharedType=function(m,d,l){if(l)return Object.getPrototypeOf(m)!==Object.getPrototypeOf(d)?p.mismatched:a.getInternalProto(m);const c=a.getInternalProto(m);return c!==a.getInternalProto(d)?p.mismatched:c},p.valueOf=function(m){const d=m.valueOf;if(d===void 0)return m;try{return d.call(m)}catch(l){return l}},p.hasOwnEnumerableProperty=function(m,d){return Object.prototype.propertyIsEnumerable.call(m,d)},p.isSetSimpleEqual=function(m,d){for(const l of Set.prototype.values.call(m))if(!Set.prototype.has.call(d,l))return!1;return!0},p.isDeepEqualObj=function(m,d,l,c,u){const{isDeepEqual:h,valueOf:f,hasOwnEnumerableProperty:b}=p,{keys:g,getOwnPropertySymbols:y}=Object;if(m===a.array){if(!c.part){if(d.length!==l.length)return!1;for(let T=0;T<d.length;++T)if(!h(d[T],l[T],c,u))return!1;return!0}for(const T of d)for(const w of l)if(h(T,w,c,u))return!0}else if(m===a.set){if(d.size!==l.size)return!1;if(!p.isSetSimpleEqual(d,l)){const T=new Set(Set.prototype.values.call(l));for(const w of Set.prototype.values.call(d)){if(T.delete(w))continue;let x=!1;for(const k of T)if(h(w,k,c,u)){T.delete(k),x=!0;break}if(!x)return!1}}}else if(m===a.map){if(d.size!==l.size)return!1;for(const[T,w]of Map.prototype.entries.call(d))if(w===void 0&&!Map.prototype.has.call(l,T)||!h(w,Map.prototype.get.call(l,T),c,u))return!1}else if(m===a.error&&(d.name!==l.name||d.message!==l.message))return!1;const v=f(d),_=f(l);if((d!==v||l!==_)&&!h(v,_,c,u))return!1;const C=g(d);if(!c.part&&C.length!==g(l).length&&!c.skip)return!1;let S=0;for(const T of C)if(c.skip&&c.skip.includes(T))l[T]===void 0&&++S;else if(!b(l,T)||!h(d[T],l[T],c,u))return!1;if(!c.part&&C.length-S!==g(l).length)return!1;if(c.symbols!==!1){const T=y(d),w=new Set(y(l));for(const x of T){if(!c.skip||!c.skip.includes(x)){if(b(d,x)){if(!b(l,x)||!h(d[x],l[x],c,u))return!1}else if(b(l,x))return!1}w.delete(x)}for(const x of w)if(b(l,x))return!1}return!0},p.SeenEntry=class{constructor(m,d){this.obj=m,this.ref=d}isSame(m,d){return this.obj===m&&this.ref===d}}},7916:(r,n,o)=>{const a=o(8761);r.exports=class extends Error{constructor(p){super(p.filter(m=>m!=="").map(m=>typeof m=="string"?m:m instanceof Error?m.message:a(m)).join(" ")||"Unknown error"),typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,n.assert)}}},5277:r=>{const n={};r.exports=function(o){if(!o)return"";let a="";for(let p=0;p<o.length;++p){const m=o.charCodeAt(p);n.isSafe(m)?a+=o[p]:a+=n.escapeHtmlChar(m)}return a},n.escapeHtmlChar=function(o){return n.namedHtml.get(o)||(o>=256?"&#"+o+";":`&#x${o.toString(16).padStart(2,"0")};`)},n.isSafe=function(o){return n.safeCharCodes.has(o)},n.namedHtml=new Map([[38,"&amp;"],[60,"&lt;"],[62,"&gt;"],[34,"&quot;"],[160,"&nbsp;"],[162,"&cent;"],[163,"&pound;"],[164,"&curren;"],[169,"&copy;"],[174,"&reg;"]]),n.safeCharCodes=function(){const o=new Set;for(let a=32;a<123;++a)(a>=97||a>=65&&a<=90||a>=48&&a<=57||a===32||a===46||a===44||a===45||a===58||a===95)&&o.add(a);return o}()},6064:r=>{r.exports=function(n){return n.replace(/[\^\$\.\*\+\-\?\=\!\:\|\\\/\(\)\[\]\{\}\,]/g,"\\$&")}},738:r=>{r.exports=function(){}},1687:(r,n,o)=>{const a=o(375),p=o(8571),m=o(7043),d={};r.exports=d.merge=function(l,c,u){if(a(l&&typeof l=="object","Invalid target value: must be an object"),a(c==null||typeof c=="object","Invalid source value: must be null, undefined, or an object"),!c)return l;if(u=Object.assign({nullOverride:!0,mergeArrays:!0},u),Array.isArray(c)){a(Array.isArray(l),"Cannot merge array onto an object"),u.mergeArrays||(l.length=0);for(let f=0;f<c.length;++f)l.push(p(c[f],{symbols:u.symbols}));return l}const h=m.keys(c,u);for(let f=0;f<h.length;++f){const b=h[f];if(b==="__proto__"||!Object.prototype.propertyIsEnumerable.call(c,b))continue;const g=c[b];if(g&&typeof g=="object"){if(l[b]===g)continue;!l[b]||typeof l[b]!="object"||Array.isArray(l[b])!==Array.isArray(g)||g instanceof Date||g instanceof RegExp?l[b]=p(g,{symbols:u.symbols}):d.merge(l[b],g,u)}else(g!=null||u.nullOverride)&&(l[b]=g)}return l}},9621:(r,n,o)=>{const a=o(375),p={};r.exports=function(m,d,l){if(d===!1||d==null)return m;typeof(l=l||{})=="string"&&(l={separator:l});const c=Array.isArray(d);a(!c||!l.separator,"Separator option is not valid for array-based chain");const u=c?d:d.split(l.separator||".");let h=m;for(let f=0;f<u.length;++f){let b=u[f];const g=l.iterables&&p.iterables(h);if(Array.isArray(h)||g==="set"){const y=Number(b);Number.isInteger(y)&&(b=y<0?h.length+y:y)}if(!h||typeof h=="function"&&l.functions===!1||!g&&h[b]===void 0){a(!l.strict||f+1===u.length,"Missing segment",b,"in reach path ",d),a(typeof h=="object"||l.functions===!0||typeof h!="function","Invalid segment",b,"in reach path ",d),h=l.default;break}h=g?g==="set"?[...h][b]:h.get(b):h[b]}return h},p.iterables=function(m){return m instanceof Set?"set":m instanceof Map?"map":void 0}},8761:r=>{r.exports=function(...n){try{return JSON.stringify(...n)}catch(o){return"[Cannot display object: "+o.message+"]"}}},4277:(r,n)=>{const o={};n=r.exports={array:Array.prototype,buffer:!1,date:Date.prototype,error:Error.prototype,generic:Object.prototype,map:Map.prototype,promise:Promise.prototype,regex:RegExp.prototype,set:Set.prototype,weakMap:WeakMap.prototype,weakSet:WeakSet.prototype},o.typeMap=new Map([["[object Error]",n.error],["[object Map]",n.map],["[object Promise]",n.promise],["[object Set]",n.set],["[object WeakMap]",n.weakMap],["[object WeakSet]",n.weakSet]]),n.getInternalProto=function(a){if(Array.isArray(a))return n.array;if(a instanceof Date)return n.date;if(a instanceof RegExp)return n.regex;if(a instanceof Error)return n.error;const p=Object.prototype.toString.call(a);return o.typeMap.get(p)||n.generic}},7043:(r,n)=>{n.keys=function(o,a={}){return a.symbols!==!1?Reflect.ownKeys(o):Object.getOwnPropertyNames(o)}},3652:(r,n,o)=>{const a=o(375),p={};n.Sorter=class{constructor(){this._items=[],this.nodes=[]}add(m,d){const l=[].concat((d=d||{}).before||[]),c=[].concat(d.after||[]),u=d.group||"?",h=d.sort||0;a(!l.includes(u),`Item cannot come before itself: ${u}`),a(!l.includes("?"),"Item cannot come before unassociated items"),a(!c.includes(u),`Item cannot come after itself: ${u}`),a(!c.includes("?"),"Item cannot come after unassociated items"),Array.isArray(m)||(m=[m]);for(const f of m){const b={seq:this._items.length,sort:h,before:l,after:c,group:u,node:f};this._items.push(b)}if(!d.manual){const f=this._sort();a(f,"item",u!=="?"?`added into group ${u}`:"","created a dependencies error")}return this.nodes}merge(m){Array.isArray(m)||(m=[m]);for(const l of m)if(l)for(const c of l._items)this._items.push(Object.assign({},c));this._items.sort(p.mergeSort);for(let l=0;l<this._items.length;++l)this._items[l].seq=l;const d=this._sort();return a(d,"merge created a dependencies error"),this.nodes}sort(){const m=this._sort();return a(m,"sort created a dependencies error"),this.nodes}_sort(){const m={},d=Object.create(null),l=Object.create(null);for(const b of this._items){const g=b.seq,y=b.group;l[y]=l[y]||[],l[y].push(g),m[g]=b.before;for(const v of b.after)d[v]=d[v]||[],d[v].push(g)}for(const b in m){const g=[];for(const y in m[b]){const v=m[b][y];l[v]=l[v]||[],g.push(...l[v])}m[b]=g}for(const b in d)if(l[b])for(const g of l[b])m[g].push(...d[b]);const c={};for(const b in m){const g=m[b];for(const y of g)c[y]=c[y]||[],c[y].push(b)}const u={},h=[];for(let b=0;b<this._items.length;++b){let g=b;if(c[b]){g=null;for(let y=0;y<this._items.length;++y){if(u[y]===!0)continue;c[y]||(c[y]=[]);const v=c[y].length;let _=0;for(let C=0;C<v;++C)u[c[y][C]]&&++_;if(_===v){g=y;break}}}g!==null&&(u[g]=!0,h.push(g))}if(h.length!==this._items.length)return!1;const f={};for(const b of this._items)f[b.seq]=b;this._items=[],this.nodes=[];for(const b of h){const g=f[b];this.nodes.push(g.node),this._items.push(g)}return!0}},p.mergeSort=(m,d)=>m.sort===d.sort?0:m.sort<d.sort?-1:1},5380:(r,n,o)=>{const a=o(443),p=o(2178),m={minDomainSegments:2,nonAsciiRx:/[^\x00-\x7f]/,domainControlRx:/[\x00-\x20@\:\/\\#!\$&\'\(\)\*\+,;=\?]/,tldSegmentRx:/^[a-zA-Z](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?$/,domainSegmentRx:/^[a-zA-Z0-9](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?$/,URL:a.URL||URL};n.analyze=function(d,l={}){if(!d)return p.code("DOMAIN_NON_EMPTY_STRING");if(typeof d!="string")throw new Error("Invalid input: domain must be a string");if(d.length>256)return p.code("DOMAIN_TOO_LONG");if(m.nonAsciiRx.test(d)){if(l.allowUnicode===!1)return p.code("DOMAIN_INVALID_UNICODE_CHARS");d=d.normalize("NFC")}if(m.domainControlRx.test(d))return p.code("DOMAIN_INVALID_CHARS");d=m.punycode(d),l.allowFullyQualified&&d[d.length-1]==="."&&(d=d.slice(0,-1));const c=l.minDomainSegments||m.minDomainSegments,u=d.split(".");if(u.length<c)return p.code("DOMAIN_SEGMENTS_COUNT");if(l.maxDomainSegments&&u.length>l.maxDomainSegments)return p.code("DOMAIN_SEGMENTS_COUNT_MAX");const h=l.tlds;if(h){const f=u[u.length-1].toLowerCase();if(h.deny&&h.deny.has(f)||h.allow&&!h.allow.has(f))return p.code("DOMAIN_FORBIDDEN_TLDS")}for(let f=0;f<u.length;++f){const b=u[f];if(!b.length)return p.code("DOMAIN_EMPTY_SEGMENT");if(b.length>63)return p.code("DOMAIN_LONG_SEGMENT");if(f<u.length-1){if(!m.domainSegmentRx.test(b))return p.code("DOMAIN_INVALID_CHARS")}else if(!m.tldSegmentRx.test(b))return p.code("DOMAIN_INVALID_TLDS_CHARS")}return null},n.isValid=function(d,l){return!n.analyze(d,l)},m.punycode=function(d){d.includes("%")&&(d=d.replace(/%/g,"%25"));try{return new m.URL(`http://${d}`).host}catch{return d}}},1745:(r,n,o)=>{const a=o(9848),p=o(5380),m=o(2178),d={nonAsciiRx:/[^\x00-\x7f]/,encoder:new(a.TextEncoder||TextEncoder)};n.analyze=function(l,c){return d.email(l,c)},n.isValid=function(l,c){return!d.email(l,c)},d.email=function(l,c={}){if(typeof l!="string")throw new Error("Invalid input: email must be a string");if(!l)return m.code("EMPTY_STRING");const u=!d.nonAsciiRx.test(l);if(!u){if(c.allowUnicode===!1)return m.code("FORBIDDEN_UNICODE");l=l.normalize("NFC")}const h=l.split("@");if(h.length!==2)return h.length>2?m.code("MULTIPLE_AT_CHAR"):m.code("MISSING_AT_CHAR");const[f,b]=h;if(!f)return m.code("EMPTY_LOCAL");if(!c.ignoreLength){if(l.length>254)return m.code("ADDRESS_TOO_LONG");if(d.encoder.encode(f).length>64)return m.code("LOCAL_TOO_LONG")}return d.local(f,u)||p.analyze(b,c)},d.local=function(l,c){const u=l.split(".");for(const h of u){if(!h.length)return m.code("EMPTY_LOCAL_SEGMENT");if(c){if(!d.atextRx.test(h))return m.code("INVALID_LOCAL_CHARS")}else for(const f of h){if(d.atextRx.test(f))continue;const b=d.binary(f);if(!d.atomRx.test(b))return m.code("INVALID_LOCAL_CHARS")}}},d.binary=function(l){return Array.from(d.encoder.encode(l)).map(c=>String.fromCharCode(c)).join("")},d.atextRx=/^[\w!#\$%&'\*\+\-/=\?\^`\{\|\}~]+$/,d.atomRx=new RegExp(["(?:[\\xc2-\\xdf][\\x80-\\xbf])","(?:\\xe0[\\xa0-\\xbf][\\x80-\\xbf])|(?:[\\xe1-\\xec][\\x80-\\xbf]{2})|(?:\\xed[\\x80-\\x9f][\\x80-\\xbf])|(?:[\\xee-\\xef][\\x80-\\xbf]{2})","(?:\\xf0[\\x90-\\xbf][\\x80-\\xbf]{2})|(?:[\\xf1-\\xf3][\\x80-\\xbf]{3})|(?:\\xf4[\\x80-\\x8f][\\x80-\\xbf]{2})"].join("|"))},2178:(r,n)=>{n.codes={EMPTY_STRING:"Address must be a non-empty string",FORBIDDEN_UNICODE:"Address contains forbidden Unicode characters",MULTIPLE_AT_CHAR:"Address cannot contain more than one @ character",MISSING_AT_CHAR:"Address must contain one @ character",EMPTY_LOCAL:"Address local part cannot be empty",ADDRESS_TOO_LONG:"Address too long",LOCAL_TOO_LONG:"Address local part too long",EMPTY_LOCAL_SEGMENT:"Address local part contains empty dot-separated segment",INVALID_LOCAL_CHARS:"Address local part contains invalid character",DOMAIN_NON_EMPTY_STRING:"Domain must be a non-empty string",DOMAIN_TOO_LONG:"Domain too long",DOMAIN_INVALID_UNICODE_CHARS:"Domain contains forbidden Unicode characters",DOMAIN_INVALID_CHARS:"Domain contains invalid character",DOMAIN_INVALID_TLDS_CHARS:"Domain contains invalid tld character",DOMAIN_SEGMENTS_COUNT:"Domain lacks the minimum required number of segments",DOMAIN_SEGMENTS_COUNT_MAX:"Domain contains too many segments",DOMAIN_FORBIDDEN_TLDS:"Domain uses forbidden TLD",DOMAIN_EMPTY_SEGMENT:"Domain contains empty dot-separated segment",DOMAIN_LONG_SEGMENT:"Domain contains dot-separated segment that is too long"},n.code=function(o){return{code:o,error:n.codes[o]}}},9959:(r,n,o)=>{const a=o(375),p=o(5752);n.regex=function(m={}){a(m.cidr===void 0||typeof m.cidr=="string","options.cidr must be a string");const d=m.cidr?m.cidr.toLowerCase():"optional";a(["required","optional","forbidden"].includes(d),"options.cidr must be one of required, optional, forbidden"),a(m.version===void 0||typeof m.version=="string"||Array.isArray(m.version),"options.version must be a string or an array of string");let l=m.version||["ipv4","ipv6","ipvfuture"];Array.isArray(l)||(l=[l]),a(l.length>=1,"options.version must have at least 1 version specified");for(let h=0;h<l.length;++h)a(typeof l[h]=="string","options.version must only contain strings"),l[h]=l[h].toLowerCase(),a(["ipv4","ipv6","ipvfuture"].includes(l[h]),"options.version contains unknown version "+l[h]+" - must be one of ipv4, ipv6, ipvfuture");l=Array.from(new Set(l));const c=`(?:${l.map(h=>{if(d==="forbidden")return p.ip[h];const f=`\\/${h==="ipv4"?p.ip.v4Cidr:p.ip.v6Cidr}`;return d==="required"?`${p.ip[h]}${f}`:`${p.ip[h]}(?:${f})?`}).join("|")})`,u=new RegExp(`^${c}$`);return{cidr:d,versions:l,regex:u,raw:c}}},5752:(r,n,o)=>{const a=o(375),p=o(6064),m={generate:function(){const d={},l="\\dA-Fa-f",c="["+l+"]",u="\\w-\\.~",h="!\\$&'\\(\\)\\*\\+,;=",f="%"+l,b=u+f+h+":@",g="["+b+"]",y="(?:0{0,2}\\d|0?[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])";d.ipv4address="(?:"+y+"\\.){3}"+y;const v=c+"{1,4}",_="(?:"+v+":"+v+"|"+d.ipv4address+")",C="(?:"+v+":){6}"+_,S="::(?:"+v+":){5}"+_,T="(?:"+v+")?::(?:"+v+":){4}"+_,w="(?:(?:"+v+":){0,1}"+v+")?::(?:"+v+":){3}"+_,x="(?:(?:"+v+":){0,2}"+v+")?::(?:"+v+":){2}"+_,k="(?:(?:"+v+":){0,3}"+v+")?::"+v+":"+_,E="(?:(?:"+v+":){0,4}"+v+")?::"+_,P="(?:(?:"+v+":){0,5}"+v+")?::"+v,O="(?:(?:"+v+":){0,6}"+v+")?::";d.ipv4Cidr="(?:\\d|[1-2]\\d|3[0-2])",d.ipv6Cidr="(?:0{0,2}\\d|0?[1-9]\\d|1[01]\\d|12[0-8])",d.ipv6address="(?:"+C+"|"+S+"|"+T+"|"+w+"|"+x+"|"+k+"|"+E+"|"+P+"|"+O+")",d.ipvFuture="v"+c+"+\\.["+u+h+":]+",d.scheme="[a-zA-Z][a-zA-Z\\d+-\\.]*",d.schemeRegex=new RegExp(d.scheme);const z="["+u+f+h+":]*",I="["+u+f+h+"]{1,255}",L="(?:\\[(?:"+d.ipv6address+"|"+d.ipvFuture+")\\]|"+d.ipv4address+"|"+I+")",F="(?:"+z+"@)?"+L+"(?::\\d*)?",Z="(?:"+z+"@)?("+L+")(?::\\d*)?",Q=g+"*",X=g+"+",Y="(?:\\/"+Q+")*",se="\\/(?:"+X+Y+")?",re=X+Y,Ce="["+u+f+h+"@]+"+Y,ve="(?:\\/\\/\\/"+Q+Y+")";return d.hierPart="(?:(?:\\/\\/"+F+Y+")|"+se+"|"+re+"|"+ve+")",d.hierPartCapture="(?:(?:\\/\\/"+Z+Y+")|"+se+"|"+re+")",d.relativeRef="(?:(?:\\/\\/"+F+Y+")|"+se+"|"+Ce+"|)",d.relativeRefCapture="(?:(?:\\/\\/"+Z+Y+")|"+se+"|"+Ce+"|)",d.query="["+b+"\\/\\?]*(?=#|$)",d.queryWithSquareBrackets="["+b+"\\[\\]\\/\\?]*(?=#|$)",d.fragment="["+b+"\\/\\?]*",d}};m.rfc3986=m.generate(),n.ip={v4Cidr:m.rfc3986.ipv4Cidr,v6Cidr:m.rfc3986.ipv6Cidr,ipv4:m.rfc3986.ipv4address,ipv6:m.rfc3986.ipv6address,ipvfuture:m.rfc3986.ipvFuture},m.createRegex=function(d){const l=m.rfc3986,c="(?:\\?"+(d.allowQuerySquareBrackets?l.queryWithSquareBrackets:l.query)+")?(?:#"+l.fragment+")?",u=d.domain?l.relativeRefCapture:l.relativeRef;if(d.relativeOnly)return m.wrap(u+c);let h="";if(d.scheme){a(d.scheme instanceof RegExp||typeof d.scheme=="string"||Array.isArray(d.scheme),"scheme must be a RegExp, String, or Array");const g=[].concat(d.scheme);a(g.length>=1,"scheme must have at least 1 scheme specified");const y=[];for(let v=0;v<g.length;++v){const _=g[v];a(_ instanceof RegExp||typeof _=="string","scheme at position "+v+" must be a RegExp or String"),_ instanceof RegExp?y.push(_.source.toString()):(a(l.schemeRegex.test(_),"scheme at position "+v+" must be a valid scheme"),y.push(p(_)))}h=y.join("|")}const f="(?:"+(h?"(?:"+h+")":l.scheme)+":"+(d.domain?l.hierPartCapture:l.hierPart)+")",b=d.allowRelative?"(?:"+f+"|"+u+")":f;return m.wrap(b+c,h)},m.wrap=function(d,l){return{raw:d=`(?=.)(?!https?:/(?:$|[^/]))(?!https?:///)(?!https?:[^/])${d}`,regex:new RegExp(`^${d}$`),scheme:l}},m.uriRegex=m.createRegex({}),n.regex=function(d={}){return d.scheme||d.allowRelative||d.relativeOnly||d.allowQuerySquareBrackets||d.domain?m.createRegex(d):m.uriRegex}},1447:(r,n)=>{const o={operators:["!","^","*","/","%","+","-","<","<=",">",">=","==","!=","&&","||","??"],operatorCharacters:["!","^","*","/","%","+","-","<","=",">","&","|","?"],operatorsOrder:[["^"],["*","/","%"],["+","-"],["<","<=",">",">="],["==","!="],["&&"],["||","??"]],operatorsPrefix:["!","n"],literals:{'"':'"',"`":"`","'":"'","[":"]"},numberRx:/^(?:[0-9]*(\.[0-9]*)?){1}$/,tokenRx:/^[\w\$\#\.\@\:\{\}]+$/,symbol:Symbol("formula"),settings:Symbol("settings")};n.Parser=class{constructor(a,p={}){if(!p[o.settings]&&p.constants)for(const m in p.constants){const d=p.constants[m];if(d!==null&&!["boolean","number","string"].includes(typeof d))throw new Error(`Formula constant ${m} contains invalid ${typeof d} value type`)}this.settings=p[o.settings]?p:Object.assign({[o.settings]:!0,constants:{},functions:{}},p),this.single=null,this._parts=null,this._parse(a)}_parse(a){let p=[],m="",d=0,l=!1;const c=h=>{if(d)throw new Error("Formula missing closing parenthesis");const f=p.length?p[p.length-1]:null;if(l||m||h){if(f&&f.type==="reference"&&h===")")return f.type="function",f.value=this._subFormula(m,f.value),void(m="");if(h===")"){const b=new n.Parser(m,this.settings);p.push({type:"segment",value:b})}else if(l){if(l==="]")return p.push({type:"reference",value:m}),void(m="");p.push({type:"literal",value:m})}else if(o.operatorCharacters.includes(m))f&&f.type==="operator"&&o.operators.includes(f.value+m)?f.value+=m:p.push({type:"operator",value:m});else if(m.match(o.numberRx))p.push({type:"constant",value:parseFloat(m)});else if(this.settings.constants[m]!==void 0)p.push({type:"constant",value:this.settings.constants[m]});else{if(!m.match(o.tokenRx))throw new Error(`Formula contains invalid token: ${m}`);p.push({type:"reference",value:m})}m=""}};for(const h of a)l?h===l?(c(),l=!1):m+=h:d?h==="("?(m+=h,++d):h===")"?(--d,d?m+=h:c(h)):m+=h:h in o.literals?l=o.literals[h]:h==="("?(c(),++d):o.operatorCharacters.includes(h)?(c(),m=h,c()):h!==" "?m+=h:c();c(),p=p.map((h,f)=>h.type!=="operator"||h.value!=="-"||f&&p[f-1].type!=="operator"?h:{type:"operator",value:"n"});let u=!1;for(const h of p){if(h.type==="operator"){if(o.operatorsPrefix.includes(h.value))continue;if(!u)throw new Error("Formula contains an operator in invalid position");if(!o.operators.includes(h.value))throw new Error(`Formula contains an unknown operator ${h.value}`)}else if(u)throw new Error("Formula missing expected operator");u=!u}if(!u)throw new Error("Formula contains invalid trailing operator");p.length===1&&["reference","literal","constant"].includes(p[0].type)&&(this.single={type:p[0].type==="reference"?"reference":"value",value:p[0].value}),this._parts=p.map(h=>{if(h.type==="operator")return o.operatorsPrefix.includes(h.value)?h:h.value;if(h.type!=="reference")return h.value;if(this.settings.tokenRx&&!this.settings.tokenRx.test(h.value))throw new Error(`Formula contains invalid reference ${h.value}`);return this.settings.reference?this.settings.reference(h.value):o.reference(h.value)})}_subFormula(a,p){const m=this.settings.functions[p];if(typeof m!="function")throw new Error(`Formula contains unknown function ${p}`);let d=[];if(a){let l="",c=0,u=!1;const h=()=>{if(!l)throw new Error(`Formula contains function ${p} with invalid arguments ${a}`);d.push(l),l=""};for(let f=0;f<a.length;++f){const b=a[f];u?(l+=b,b===u&&(u=!1)):b in o.literals&&!c?(l+=b,u=o.literals[b]):b!==","||c?(l+=b,b==="("?++c:b===")"&&--c):h()}h()}return d=d.map(l=>new n.Parser(l,this.settings)),function(l){const c=[];for(const u of d)c.push(u.evaluate(l));return m.call(l,...c)}}evaluate(a){const p=this._parts.slice();for(let m=p.length-2;m>=0;--m){const d=p[m];if(d&&d.type==="operator"){const l=p[m+1];p.splice(m+1,1);const c=o.evaluate(l,a);p[m]=o.single(d.value,c)}}return o.operatorsOrder.forEach(m=>{for(let d=1;d<p.length-1;)if(m.includes(p[d])){const l=p[d],c=o.evaluate(p[d-1],a),u=o.evaluate(p[d+1],a);p.splice(d,2);const h=o.calculate(l,c,u);p[d-1]=h===0?0:h}else d+=2}),o.evaluate(p[0],a)}},n.Parser.prototype[o.symbol]=!0,o.reference=function(a){return function(p){return p&&p[a]!==void 0?p[a]:null}},o.evaluate=function(a,p){return a===null?null:typeof a=="function"?a(p):a[o.symbol]?a.evaluate(p):a},o.single=function(a,p){if(a==="!")return!p;const m=-p;return m===0?0:m},o.calculate=function(a,p,m){if(a==="??")return o.exists(p)?p:m;if(typeof p=="string"||typeof m=="string"){if(a==="+")return(p=o.exists(p)?p:"")+(o.exists(m)?m:"")}else switch(a){case"^":return Math.pow(p,m);case"*":return p*m;case"/":return p/m;case"%":return p%m;case"+":return p+m;case"-":return p-m}switch(a){case"<":return p<m;case"<=":return p<=m;case">":return p>m;case">=":return p>=m;case"==":return p===m;case"!=":return p!==m;case"&&":return p&&m;case"||":return p||m}return null},o.exists=function(a){return a!=null}},9926:()=>{},5688:()=>{},9708:()=>{},1152:()=>{},443:()=>{},9848:()=>{},5934:r=>{r.exports=JSON.parse('{"version":"17.13.3"}')}},i={},function r(n){var o=i[n];if(o!==void 0)return o.exports;var a=i[n]={exports:{}};return t[n](a,a.exports,r),a.exports}(5107);var t,i})})(Js);var Ha=Js.exports;const N=Qs(Ha);var Na=Object.defineProperty,Ua=(s,e,t)=>e in s?Na(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,gt=(s,e,t)=>Ua(s,typeof e!="symbol"?e+"":e,t),be={DEFAULTS:{width:800,height:400,pixelRatio:2,fontFamily:"Roboto",fontSize:48,color:"#000000",textAlign:"left"},LIMITS:{minWidth:1,maxWidth:4096,minHeight:1,maxHeight:4096,minFontSize:1,maxFontSize:512,minDuration:.1,maxDuration:120,maxTextLength:1e4},ANIMATION_TYPES:["typewriter","fadeIn","slideIn","shift","ascend","movingLetters"]},Vt=/^#[A-Fa-f0-9]{6}$/,ja=N.object({type:N.string().valid("linear","radial").default("linear"),angle:N.number().min(0).max(360).default(0),stops:N.array().items(N.object({offset:N.number().min(0).max(1).required(),color:N.string().pattern(Vt).required()}).unknown(!1)).min(2).required()}).unknown(!1),Va=N.object({offsetX:N.number().default(0),offsetY:N.number().default(0),blur:N.number().min(0).default(0),color:N.string().pattern(Vt).default("#000000"),opacity:N.number().min(0).max(1).default(.5)}).unknown(!1),Wa=N.object({width:N.number().min(0).default(0),color:N.string().pattern(Vt).default("#000000"),opacity:N.number().min(0).max(1).default(1)}).unknown(!1),Ga=N.object({family:N.string().default(be.DEFAULTS.fontFamily),size:N.number().min(be.LIMITS.minFontSize).max(be.LIMITS.maxFontSize).default(be.DEFAULTS.fontSize),weight:N.alternatives().try(N.string(),N.number()).default("400"),style:N.string().valid("normal","italic","oblique").default("normal"),color:N.string().pattern(Vt).default(be.DEFAULTS.color),opacity:N.number().min(0).max(1).default(1)}).unknown(!1),Za=N.object({letterSpacing:N.number().default(0),lineHeight:N.number().min(0).max(10).default(1.2),textTransform:N.string().valid("none","uppercase","lowercase","capitalize").default("none"),textDecoration:N.string().valid("none","underline","line-through").default("none"),gradient:ja.optional()}).unknown(!1),Ka=N.object({horizontal:N.string().valid("left","center","right").default(be.DEFAULTS.textAlign),vertical:N.string().valid("top","middle","bottom").default("middle")}).unknown(!1),qa=N.object({preset:N.string().valid(...be.ANIMATION_TYPES),speed:N.number().min(.1).max(10).default(1),duration:N.number().min(be.LIMITS.minDuration).max(be.LIMITS.maxDuration).optional(),style:N.string().valid("character","word").optional().when("preset",{is:N.valid("typewriter","shift"),then:N.optional(),otherwise:N.forbidden()}),direction:N.string().optional().when("preset",{switch:[{is:"ascend",then:N.valid("up","down")},{is:"shift",then:N.valid("left","right","up","down")},{is:"slideIn",then:N.valid("left","right","up","down")},{is:"movingLetters",then:N.valid("left","right","up","down")}],otherwise:N.forbidden()})}).unknown(!1),Xa=N.object({color:N.string().pattern(Vt).optional(),opacity:N.number().min(0).max(1).default(1),borderRadius:N.number().min(0).default(0)}).unknown(!1),Ya=N.object({src:N.string().uri().required(),family:N.string().required(),weight:N.alternatives().try(N.string(),N.number()).optional(),style:N.string().optional(),originalFamily:N.string().optional()}).unknown(!1),Qa=N.object({type:N.string().valid("rich-text").required(),text:N.string().allow("").max(be.LIMITS.maxTextLength).default(""),width:N.number().min(be.LIMITS.minWidth).max(be.LIMITS.maxWidth).default(be.DEFAULTS.width).optional(),height:N.number().min(be.LIMITS.minHeight).max(be.LIMITS.maxHeight).default(be.DEFAULTS.height).optional(),font:Ga.optional(),style:Za.optional(),stroke:Wa.optional(),shadow:Va.optional(),background:Xa.optional(),align:Ka.optional(),animation:qa.optional(),customFonts:N.array().items(Ya).optional(),cacheEnabled:N.boolean().default(!0),pixelRatio:N.number().min(1).max(3).default(be.DEFAULTS.pixelRatio)}).unknown(!1),pi=null;async function Ja(s){if(pi)return pi;try{const t=(await Promise.resolve().then(()=>Yh)).default;let i;if(typeof t=="function"?i=await t():t&&typeof t.then=="function"?i=await t:i=t,!i||typeof i.createBuffer!="function"||typeof i.createFont!="function")throw new Error("Failed to initialize HarfBuzz: unexpected export shape from 'harfbuzzjs'.");return pi=i,pi}catch(e){throw new Error(`Failed to initialize HarfBuzz: ${e instanceof Error?e.message:String(e)}`)}}var er=class Ps{constructor(e){gt(this,"hb"),gt(this,"faces",new Map),gt(this,"fonts",new Map),gt(this,"blobs",new Map),gt(this,"wasmBaseURL"),gt(this,"initPromise"),this.wasmBaseURL=e}static setFallbackLoader(e){Ps.fallbackLoader=e}async init(){if(this.initPromise){await this.initPromise;return}if(!this.hb){this.initPromise=this._doInit();try{await this.initPromise}catch(e){throw new Error(`Failed to initialize FontRegistry: ${e instanceof Error?e.message:String(e)}`)}}}async _doInit(){try{this.hb=await Ja(this.wasmBaseURL)}catch(e){throw this.initPromise=void 0,e}}async getHB(){if(!this.hb)try{await this.init()}catch(e){throw new Error(`Failed to get HarfBuzz instance: ${e instanceof Error?e.message:String(e)}`)}return this.hb}key(e){return`${e.family}__${e.weight??"400"}__${e.style??"normal"}`}async registerFromBytes(e,t){try{this.hb||await this.init();const i=this.key(t);if(this.fonts.has(i))return;const r=this.hb.createBlob(e),n=this.hb.createFace(r,0),o=this.hb.createFont(n),a=n.upem||1e3;o.setScale(a,a),this.blobs.set(i,r),this.faces.set(i,n),this.fonts.set(i,o)}catch(i){throw new Error(`Failed to register font "${t.family}": ${i instanceof Error?i.message:String(i)}`)}}async tryFallbackInstall(e){const t=Ps.fallbackLoader;if(!t)return!1;try{const i=await t({family:e.family,weight:e.weight??"400",style:e.style??"normal"});return i?(await this.registerFromBytes(i,{family:e.family,weight:e.weight??"400",style:e.style??"normal"}),!0):!1}catch{return!1}}async getFont(e){try{this.hb||await this.init();const t=this.key(e);let i=this.fonts.get(t);if(i||(i=await this.tryFallbackInstall(e)?this.fonts.get(t):void 0),!i)throw new Error(`Font not registered for ${t}`);return i}catch(t){throw t instanceof Error&&t.message.includes("Font not registered")?t:new Error(`Failed to get font "${e.family}": ${t instanceof Error?t.message:String(t)}`)}}async getFace(e){try{this.hb||await this.init();const t=this.key(e);let i=this.faces.get(t);return i||(i=await this.tryFallbackInstall(e)?this.faces.get(t):void 0),i}catch(t){throw new Error(`Failed to get face for "${e.family}": ${t instanceof Error?t.message:String(t)}`)}}async getUnitsPerEm(e){try{return(await this.getFace(e))?.upem||1e3}catch(t){throw new Error(`Failed to get units per em for "${e.family}": ${t instanceof Error?t.message:String(t)}`)}}async glyphPath(e,t){try{const r=(await this.getFont(e)).glyphToPath(t);return r&&r!==""?r:"M 0 0"}catch(i){throw new Error(`Failed to get glyph path for glyph ${t} in font "${e.family}": ${i instanceof Error?i.message:String(i)}`)}}destroy(){try{for(const[,e]of this.fonts)try{e.destroy()}catch(t){console.error(`Error destroying font: ${t instanceof Error?t.message:String(t)}`)}for(const[,e]of this.faces)try{e.destroy()}catch(t){console.error(`Error destroying face: ${t instanceof Error?t.message:String(t)}`)}for(const[,e]of this.blobs)try{e.destroy()}catch(t){console.error(`Error destroying blob: ${t instanceof Error?t.message:String(t)}`)}this.fonts.clear(),this.faces.clear(),this.blobs.clear(),this.hb=void 0,this.initPromise=void 0}catch(e){console.error(`Error during FontRegistry cleanup: ${e instanceof Error?e.message:String(e)}`)}}};gt(er,"fallbackLoader");var tr=er,eo=class{constructor(s){this.fonts=s}transformText(s,e){switch(e){case"uppercase":return s.toUpperCase();case"lowercase":return s.toLowerCase();case"capitalize":return s.replace(/\b\w/g,t=>t.toUpperCase());default:return s}}async shapeFull(s,e){try{const t=await this.fonts.getHB(),i=t.createBuffer();try{i.addText(s),i.guessSegmentProperties();const r=await this.fonts.getFont(e),o=(await this.fonts.getFace(e))?.upem||1e3;return r.setScale(o,o),t.shape(r,i),i.json()}finally{try{i.destroy()}catch(r){console.error(`Error destroying HarfBuzz buffer: ${r instanceof Error?r.message:String(r)}`)}}}catch(t){throw new Error(`Failed to shape text with font "${e.family}": ${t instanceof Error?t.message:String(t)}`)}}async layout(s){try{const{textTransform:e,desc:t,fontSize:i,letterSpacing:r,width:n}=s,o=this.transformText(s.text,e);if(!o||o.length===0)return[];let a;try{a=await this.shapeFull(o,t)}catch(g){throw new Error(`Text shaping failed: ${g instanceof Error?g.message:String(g)}`)}let p;try{p=(await this.fonts.getFace(t))?.upem||1e3}catch(g){throw new Error(`Failed to get font metrics: ${g instanceof Error?g.message:String(g)}`)}const m=i/p,d=a.map(g=>{const y=g.cl;let v;return y>=0&&y<o.length&&(v=o[y]),{id:g.g,xAdvance:g.ax*m+r,xOffset:g.dx*m,yOffset:-g.dy*m,cluster:g.cl,char:v}}),l=[];let c=[],u=0;const h=new Set;for(let g=0;g<o.length;g++)o[g]===" "&&h.add(g);let f=-1;for(let g=0;g<d.length;g++){const y=d[g],v=y.xAdvance;if(y.char===`
183
- `){c.length>0&&l.push({glyphs:c,width:u,y:0}),c=[],u=0,f=g;continue}if(u+v>n&&c.length>0){if(f>-1){const _=f-(g-c.length)+1,C=c.splice(_),S=c.reduce((T,w)=>T+w.xAdvance,0);l.push({glyphs:c,width:S,y:0}),c=C,u=C.reduce((T,w)=>T+w.xAdvance,0)}else l.push({glyphs:c,width:u,y:0}),c=[],u=0;f=-1}c.push(y),u+=v,h.has(y.cluster)&&(f=g)}c.length>0&&l.push({glyphs:c,width:u,y:0});const b=s.lineHeight*i;for(let g=0;g<l.length;g++)l[g].y=(g+1)*b;return l}catch(e){throw e instanceof Error?e:new Error(`Layout failed: ${String(e)}`)}}};function to(s,e){return s.type==="linear"?{kind:"linear",angle:s.angle,stops:s.stops,opacity:e}:{kind:"radial",stops:s.stops,opacity:e}}function io(s,e){const t=Math.max(1,Math.round(e.fontSize*.05));let i=e.baselineY+Math.round(e.fontSize*.1);return s==="line-through"&&(i=e.baselineY-Math.round(e.fontSize*.3)),{x1:e.xStart,x2:e.xStart+e.lineWidth,y:i,width:t}}async function so(s){const e=[];if(e.push({op:"BeginFrame",width:s.canvas.width,height:s.canvas.height,pixelRatio:s.canvas.pixelRatio,clear:!0,bg:s.background?{color:s.background.color,opacity:s.background.opacity,radius:s.background.borderRadius}:void 0}),s.lines.length===0)return e;const t=Math.max(1,await s.getUnitsPerEm()),i=s.font.size/t,r=s.lines[s.lines.length-1].y;let n;switch(s.align.vertical){case"top":n=s.font.size;break;case"bottom":n=s.textRect.height-r+s.font.size;break;case"middle":default:n=(s.textRect.height-r)/2+s.font.size;break}const o=s.style.gradient?to(s.style.gradient,1):{kind:"solid",color:s.font.color,opacity:s.font.opacity},a=s.style.gradient?s.style.gradient.stops[s.style.gradient.stops.length-1]?.color??s.font.color:s.font.color;let p=1/0,m=1/0,d=-1/0,l=-1/0;for(const c of s.lines){let u;switch(s.align.horizontal){case"left":u=0;break;case"right":u=s.textRect.width-c.width;break;case"center":default:u=(s.textRect.width-c.width)/2;break}let h=u;const f=n+c.y-s.font.size;for(const b of c.glyphs){const g=await s.glyphPathProvider(b.id);if(!g||g==="M 0 0"){h+=b.xAdvance;continue}const y=h+b.xOffset,v=f+b.yOffset,_=no(g),C=y+i*_.x,S=y+i*(_.x+_.w),T=v-i*(_.y+_.h),w=v-i*_.y;C<p&&(p=C),T<m&&(m=T),S>d&&(d=S),w>l&&(l=w),s.shadow&&s.shadow.blur>0&&e.push({isShadow:!0,op:"FillPath",path:g,x:y+s.shadow.offsetX,y:v+s.shadow.offsetY,scale:i,fill:{kind:"solid",color:s.shadow.color,opacity:s.shadow.opacity}}),s.stroke&&s.stroke.width>0&&e.push({op:"StrokePath",path:g,x:y,y:v,scale:i,width:s.stroke.width,color:s.stroke.color,opacity:s.stroke.opacity}),e.push({op:"FillPath",path:g,x:y,y:v,scale:i,fill:o}),h+=b.xAdvance}if(s.style.textDecoration!=="none"){const b=io(s.style.textDecoration,{baselineY:f,fontSize:s.font.size,lineWidth:c.width,xStart:u});e.push({op:"DecorationLine",from:{x:b.x1,y:b.y},to:{x:b.x2,y:b.y},width:b.width,color:a,opacity:s.font.opacity})}}if(p!==1/0){const c={x:p,y:m,w:Math.max(1,d-p),h:Math.max(1,l-m)};for(const u of e)u.op==="FillPath"&&!u.isShadow&&(u.gradientBBox=c)}return e}function ro(s){return s.match(/[MLCQZ]|-?\d*\.?\d+(?:e[-+]?\d+)?/gi)??[]}function no(s){const e=ro(s);let t=0,i=1/0,r=1/0,n=-1/0,o=-1/0;const a=(p,m)=>{p<i&&(i=p),m<r&&(r=m),p>n&&(n=p),m>o&&(o=m)};for(;t<e.length;)switch(e[t++]){case"M":case"L":{const m=parseFloat(e[t++]),d=parseFloat(e[t++]);a(m,d);break}case"C":{const m=parseFloat(e[t++]),d=parseFloat(e[t++]),l=parseFloat(e[t++]),c=parseFloat(e[t++]),u=parseFloat(e[t++]),h=parseFloat(e[t++]);a(m,d),a(l,c),a(u,h);break}case"Q":{const m=parseFloat(e[t++]),d=parseFloat(e[t++]),l=parseFloat(e[t++]),c=parseFloat(e[t++]);a(m,d),a(l,c);break}}return i===1/0?{x:0,y:0,w:0,h:0}:{x:i,y:r,w:n-i,h:o-r}}var Vi=.999;function ao(s,e,t){if(!t.anim||!t.anim.preset)return s;const{preset:i}=t.anim,r=e.reduce((a,p)=>a+p.glyphs.length,0),n=t.anim.duration??Math.max(.3,r/30/t.anim.speed),o=Math.max(0,Math.min(1,t.t/n));switch(i){case"typewriter":return lo(s,e,o,t.anim.style,t.fontSize,t.t);case"fadeIn":return uo(s,o);case"slideIn":return fo(s,o,t.anim.direction??"left",t.fontSize);case"shift":return ho(s,e,o,t.anim.direction??"left",t.fontSize,t.anim.style,n);case"ascend":return co(s,e,o,t.anim.direction??"up",t.fontSize,n);case"movingLetters":return po(s,o,t.anim.direction??"up",t.fontSize);default:return s}}var mi=s=>s.op==="FillPath"&&s.isShadow===!0,ir=s=>s.op==="FillPath"&&!s.isShadow;function oo(s){for(const e of s)if(e.op==="FillPath"){const t=e.fill;if(t?.kind==="solid")return t.color;if((t?.kind==="linear"||t?.kind==="radial")&&Array.isArray(t.stops)&&t.stops.length)return t.stops[t.stops.length-1].color||"#000000"}return"#000000"}function lo(s,e,t,i,r,n,o){if(i==="word"){const p=Wi(e),m=p.length,d=Math.floor(t*m);if(d===0)return s.filter(h=>h.op==="BeginFrame");let l=0;for(let h=0;h<Math.min(d,p.length);h++)l+=p[h].glyphCount;const c=sr(s,l),u=t>=Vi?c:c.filter(h=>h.op!=="DecorationLine");return t<1&&l>0?rr(u,l,r,n):u}else{const p=e.reduce((c,u)=>c+u.glyphs.length,0),m=Math.floor(t*p);if(m===0)return s.filter(c=>c.op==="BeginFrame");const d=sr(s,m),l=t>=Vi?d:d.filter(c=>c.op!=="DecorationLine");return t<1&&m>0?rr(l,m,r,n):l}}function co(s,e,t,i,r,n){const o=Wi(e),a=o.length;if(a===0)return s;const p=[];let m=0;for(const d of s)if(d.op==="BeginFrame"){p.push(d);break}for(const d of s)if(d.op==="FillPath"||d.op==="StrokePath"){let l=-1,c=0;for(let u=0;u<o.length;u++){const h=o[u].glyphCount;if(m>=c&&m<c+h){l=u;break}c+=h}if(l>=0){const u=l/Math.max(1,a)*(n/n),h=Math.min(1,u+.3);if(t>=h)p.push(d);else if(t>u){const f=(t-u)/Math.max(1e-6,h-u),b=Gi(Math.min(1,f)),g=i==="up"?r*.4:-r*.4,y={...d,y:d.y+g*(1-b)};d.op==="FillPath"?y.fill.kind==="solid"?y.fill={...y.fill,opacity:y.fill.opacity*b}:y.fill={...y.fill,opacity:(y.fill.opacity??1)*b}:y.opacity=y.opacity*b,p.push(y)}}ir(d)&&m++}else d.op==="DecorationLine"&&t>=Vi&&p.push(d);return p}function ho(s,e,t,i,r,n,o){const a=n==="word",m={left:{x:r*.6,y:0},right:{x:-r*.6,y:0},up:{x:0,y:r*.6},down:{x:0,y:-r*.6}}[i],d=a?Wi(e):[],l=e.reduce((v,_)=>v+_.glyphs.length,0),c=a?d.length:l;if(c===0)return s;const u=[];for(const v of s)if(v.op==="BeginFrame"){u.push(v);break}const h=.3,b=o*.7/Math.max(1,c-1),g=v=>{const _=v*b,C=_/o,S=Math.min(1,(_+h)/o);return{startF:C,endF:S}};let y=0;for(const v of s){if(v.op!=="FillPath"&&v.op!=="StrokePath"){v.op==="DecorationLine"&&t>.8&&u.push(v);continue}let _;if(!a)_=y;else{let T=-1,w=0;for(let x=0;x<d.length;x++){const k=d[x].glyphCount;if(y>=w&&y<w+k){T=x;break}w+=k}_=Math.max(0,T)}const{startF:C,endF:S}=g(_);if(t<=C){const T={...v,x:v.x+m.x,y:v.y+m.y};v.op==="FillPath"?T.fill.kind==="solid"?T.fill={...T.fill,opacity:0}:T.fill={...T.fill,opacity:0}:T.opacity=0,u.push(T)}else if(t>=S)u.push(v);else{const T=(t-C)/Math.max(1e-6,S-C),w=Gi(Math.min(1,T)),x=m.x*(1-w),k=m.y*(1-w),E={...v,x:v.x+x,y:v.y+k};if(v.op==="FillPath"){const P=E.fill.kind==="solid"?E.fill.opacity:E.fill.opacity??1;E.fill.kind==="solid"?E.fill={...E.fill,opacity:P*w}:E.fill={...E.fill,opacity:P*w}}else E.opacity=E.opacity*w;u.push(E)}ir(v)&&y++}return u}function uo(s,e){const t=nr(e),i=.95+.05*t;return go(s,t,i)}function fo(s,e,t,i){const r=Gi(e),n=vo(1-r,t,i*2),o=nr(e);return yo(s,n.dx,n.dy,o)}function po(s,e,t,i){const r=i*.3;return bo(s,t,r,e)}function Wi(s){const e=[];let t=0;for(let i=0;i<s.length;i++){const r=s[i],n=mo(r);for(const o of n)o.length>0&&e.push({startGlyph:t,glyphCount:o.length,lineIndex:i}),t+=o.length}return e}function mo(s){const e=[];let t=[];for(const i of s.glyphs)i.char===" "||i.char===" "||i.char===`
184
- `?t.length&&(e.push([...t]),t=[]):t.push(i);return t.length&&e.push(t),e}function sr(s,e){const t=[];let i=0,r=!1;for(const n of s){if(n.op==="BeginFrame"){t.push(n);continue}if(n.op==="FillPath"&&!mi(n)){i<e&&(t.push(n),r=!0),i++;continue}if(n.op==="StrokePath"){i<e&&t.push(n);continue}if(n.op==="FillPath"&&mi(n)){i<e&&t.push(n);continue}if(n.op==="DecorationLine"&&r){t.push(n);continue}}return t}function rr(s,e,t,i){if(!(Math.floor(i*2*2)%2===0)||e===0)return s;let o=null,a=0;for(const p of s)if(p.op==="FillPath"&&!mi(p)&&(a++,a===e)){o=p;break}if(o&&o.op==="FillPath"){const p=oo(s),m=o.x+t*.5,d=o.y,l={op:"DecorationLine",from:{x:m,y:d-t*.7},to:{x:m,y:d+t*.1},width:Math.max(2,t/25),color:p,opacity:1};return[...s,l]}return s}function go(s,e,t){let i=0,r=0,n=0;return s.forEach(o=>{o.op==="FillPath"&&(i+=o.x,r+=o.y,n++)}),n>0&&(i/=n,r/=n),s.map(o=>{if(o.op==="FillPath"){const a={...o};if(a.fill.kind==="solid"?a.fill={...a.fill,opacity:a.fill.opacity*e}:a.fill={...a.fill,opacity:(a.fill.opacity??1)*e},t!==1&&n>0){const p=o.x-i,m=o.y-r;a.x=i+p*t,a.y=r+m*t}return a}if(o.op==="StrokePath"){const a={...o,opacity:o.opacity*e};if(t!==1&&n>0){const p=o.x-i,m=o.y-r;a.x=i+p*t,a.y=r+m*t}return a}return o.op==="DecorationLine"?{...o,opacity:o.opacity*e}:o})}function yo(s,e,t,i=1){return s.map(r=>{if(r.op==="FillPath"){const n={...r,x:r.x+e,y:r.y+t};return i<1&&(n.fill.kind==="solid"?n.fill={...n.fill,opacity:n.fill.opacity*i}:n.fill={...n.fill,opacity:(n.fill.opacity??1)*i}),n}return r.op==="StrokePath"?{...r,x:r.x+e,y:r.y+t,opacity:r.opacity*i}:r.op==="DecorationLine"?{...r,from:{x:r.from.x+e,y:r.from.y+t},to:{x:r.to.x+e,y:r.to.y+t},opacity:r.opacity*i}:r})}function bo(s,e,t,i){let r=0;return s.map(n=>{if(n.op==="FillPath"||n.op==="StrokePath"){const o=Math.sin(r/5*Math.PI+i*Math.PI*4),a=e==="left"||e==="right"?o*t*(e==="left"?-1:1):0,p=e==="up"||e==="down"?o*t*(e==="up"?-1:1):0,m=Math.min(1,i*2);if(n.op==="FillPath"){mi(n)||r++;const d={...n,x:n.x+a,y:n.y+p};return d.fill.kind==="solid"?d.fill={...d.fill,opacity:d.fill.opacity*m}:d.fill={...d.fill,opacity:(d.fill.opacity??1)*m},d}return{...n,x:n.x+a,y:n.y+p,opacity:n.opacity*m}}return n})}function vo(s,e,t){const i=s*t;switch(e){case"left":return{dx:-i,dy:0};case"right":return{dx:i,dy:0};case"up":return{dx:0,dy:-i};case"down":return{dx:0,dy:i}}}function nr(s){return s*(2-s)}function Gi(s){return 1-Math.pow(1-s,3)}function Wt(s,e=1){const t=/^#?([a-f0-9]{6})$/i.exec(s);if(!t)throw new Error(`Invalid color ${s}`);const i=parseInt(t[1],16),r=i>>16&255,n=i>>8&255,o=i&255;return{r,g:n,b:o,a:e}}function wo(s){const e=s.getContext("2d");if(!e)throw new Error("2D context unavailable");return{async render(t){const i=Co(t);for(const r of t){if(r.op==="BeginFrame"){const n=r.pixelRatio,o=r.width,a=r.height;if("width"in s&&"height"in s&&(s.width=Math.floor(o*n),s.height=Math.floor(a*n)),"style"in s&&(s.style.width=`${o}px`,s.style.height=`${a}px`),e.setTransform(n,0,0,n,0,0),r.clear&&e.clearRect(0,0,o,a),r.bg){const{color:p,opacity:m,radius:d}=r.bg;if(p){const l=Wt(p,m);e.fillStyle=`rgba(${l.r},${l.g},${l.b},${l.a})`,d&&d>0?(_o(e,0,0,o,a,d),e.fill()):e.fillRect(0,0,o,a)}}continue}if(r.op==="FillPath"){const n=r,o=new Path2D(n.path);e.save(),e.translate(n.x,n.y);const a=n.scale??1;e.scale(a,-a);const p=n.gradientBBox??i,m=xo(e,n.fill,p);e.fillStyle=m,e.fill(o),e.restore();continue}if(r.op==="StrokePath"){const n=r,o=new Path2D(n.path);e.save(),e.translate(n.x,n.y);const a=n.scale??1;e.scale(a,-a);const p=1/Math.abs(a),m=Wt(n.color,n.opacity);e.strokeStyle=`rgba(${m.r},${m.g},${m.b},${m.a})`,e.lineWidth=n.width*p,e.lineJoin="round",e.lineCap="round",e.stroke(o),e.restore();continue}if(r.op==="DecorationLine"){e.save();const n=Wt(r.color,r.opacity);e.strokeStyle=`rgba(${n.r},${n.g},${n.b},${n.a})`,e.lineWidth=r.width,e.beginPath(),e.moveTo(r.from.x,r.from.y),e.lineTo(r.to.x,r.to.y),e.stroke(),e.restore();continue}}}}}function _o(s,e,t,i,r,n){const o=new Path2D;o.moveTo(e+n,t),o.arcTo(e+i,t,e+i,t+r,n),o.arcTo(e+i,t+r,e,t+r,n),o.arcTo(e,t+r,e,t,n),o.arcTo(e,t,e+i,t,n),o.closePath(),s.save(),s.fill(o),s.restore()}function xo(s,e,t){if(e.kind==="solid"){const a=Wt(e.color,e.opacity);return`rgba(${a.r},${a.g},${a.b},${a.a})`}const i=t.x+t.w/2,r=t.y+t.h/2,n=Math.max(t.w,t.h)/2,o=a=>{const p=e.kind==="linear"||e.kind==="radial"?e.opacity:1,m=e.kind==="linear"||e.kind==="radial"?e.stops:[];for(const d of m){const l=Wt(d.color,p);a.addColorStop(d.offset,`rgba(${l.r},${l.g},${l.b},${l.a})`)}return a};if(e.kind==="linear"){const a=e.angle*Math.PI/180,p=i+Math.cos(a+Math.PI)*n,m=r+Math.sin(a+Math.PI)*n,d=i+Math.cos(a)*n,l=r+Math.sin(a)*n;return o(s.createLinearGradient(p,m,d,l))}else return o(s.createRadialGradient(i,r,0,i,r,n))}function Co(s){let e=1/0,t=1/0,i=-1/0,r=-1/0;for(const n of s){if(n.op!=="FillPath")continue;const o=n;if(o.isShadow)continue;const a=ko(o.path),p=o.scale??1,m=o.x+p*a.x,d=o.x+p*(a.x+a.w),l=o.y-p*(a.y+a.h),c=o.y-p*a.y;m<e&&(e=m),l<t&&(t=l),d>i&&(i=d),c>r&&(r=c)}return e===1/0?{x:0,y:0,w:1,h:1}:{x:e,y:t,w:Math.max(1,i-e),h:Math.max(1,r-t)}}function ko(s){const e=To(s);let t=0,i=1/0,r=1/0,n=-1/0,o=-1/0;const a=(p,m)=>{p<i&&(i=p),m<r&&(r=m),p>n&&(n=p),m>o&&(o=m)};for(;t<e.length;)switch(e[t++]){case"M":case"L":{const m=parseFloat(e[t++]),d=parseFloat(e[t++]);a(m,d);break}case"C":{const m=parseFloat(e[t++]),d=parseFloat(e[t++]),l=parseFloat(e[t++]),c=parseFloat(e[t++]),u=parseFloat(e[t++]),h=parseFloat(e[t++]);a(m,d),a(l,c),a(u,h);break}case"Q":{const m=parseFloat(e[t++]),d=parseFloat(e[t++]),l=parseFloat(e[t++]),c=parseFloat(e[t++]);a(m,d),a(l,c);break}}return i===1/0?{x:0,y:0,w:0,h:0}:{x:i,y:r,w:n-i,h:o-r}}function To(s){return s.match(/[MLCQZ]|-?\d*\.?\d+(?:e[-+]?\d+)?/gi)??[]}async function Gt(s){try{const e=await fetch(s);if(!e.ok)throw new Error(`Failed to fetch ${s}: ${e.status} ${e.statusText}`);try{return await e.arrayBuffer()}catch(t){throw new Error(`Failed to read response body as ArrayBuffer from ${s}: ${t instanceof Error?t.message:String(t)}`)}}catch(e){throw e instanceof Error?e.message.includes("Failed to fetch")||e.message.includes("Failed to read")?e:new Error(`Failed to fetch ${s}: ${e.message}`):new Error(`Failed to fetch ${s}: ${String(e)}`)}}var ar="https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Mu4mxP.ttf";async function So(s={}){const e=s.width??be.DEFAULTS.width,t=s.height??be.DEFAULTS.height,i=s.pixelRatio??be.DEFAULTS.pixelRatio,r=s.wasmBaseURL,n=new tr(r),o=new eo(n);try{tr.setFallbackLoader(async p=>{const m=(p.family??"Roboto").toLowerCase(),d=`${p.weight??"400"}`,l=p.style??"normal";if(m==="roboto"&&d==="400"&&l==="normal")return Gt(ar)}),await n.init()}catch(p){throw new Error(`Failed to initialize font registry: ${p instanceof Error?p.message:String(p)}`)}async function a(p){try{if(p.customFonts)for(const c of p.customFonts)try{const u=await Gt(c.src);await n.registerFromBytes(u,{family:c.family,weight:c.weight??"400",style:c.style??"normal"})}catch(u){throw new Error(`Failed to load custom font "${c.family}" from ${c.src}: ${u instanceof Error?u.message:String(u)}`)}const m=p.font??{family:"Roboto",weight:"400",style:"normal",size:48,color:"#000000",opacity:1},d={family:m.family,weight:`${m.weight}`,style:m.style};return await(async()=>{try{await n.getFace(d)}catch{if((m.family||"Roboto").toLowerCase()==="roboto"&&`${m.weight}`=="400"&&m.style==="normal"){const u=await Gt(ar);await n.registerFromBytes(u,{family:"Roboto",weight:"400",style:"normal"})}else throw new Error(`Font not registered for ${d.family}__${d.weight}__${d.style}`)}})(),m}catch(m){throw m instanceof Error?m:new Error(`Failed to ensure fonts: ${String(m)}`)}}return{validate(p){try{const{value:m,error:d}=Qa.validate(p,{abortEarly:!1,convert:!0});if(d)throw d;return{value:m}}catch(m){throw m instanceof Error?new Error(`Validation failed: ${m.message}`):new Error(`Validation failed: ${String(m)}`)}},async registerFontFromUrl(p,m){try{const d=await Gt(p);await n.registerFromBytes(d,m)}catch(d){throw new Error(`Failed to register font "${m.family}" from URL ${p}: ${d instanceof Error?d.message:String(d)}`)}},async registerFontFromFile(p,m){try{let d;if(typeof p=="string")try{d=await Gt(p)}catch(l){throw new Error(`Failed to fetch font from ${p}: ${l instanceof Error?l.message:String(l)}`)}else try{d=await p.arrayBuffer()}catch(l){throw new Error(`Failed to read Blob as ArrayBuffer: ${l instanceof Error?l.message:String(l)}`)}await n.registerFromBytes(d,m)}catch(d){throw d instanceof Error?d:new Error(`Failed to register font "${m.family}" from ${typeof p=="string"?p:"Blob"}: ${String(d)}`)}},async renderFrame(p,m){try{const d=await a(p),l={family:d.family,weight:`${d.weight}`,style:d.style};let c;try{c=await o.layout({text:p.text,width:p.width??e,letterSpacing:p.style?.letterSpacing??0,fontSize:d.size,lineHeight:p.style?.lineHeight??1.2,desc:l,textTransform:p.style?.textTransform??"none"})}catch(y){throw new Error(`Failed to layout text: ${y instanceof Error?y.message:String(y)}`)}const u={x:0,y:0,width:p.width??e,height:p.height??t},h=p.width??e,f=p.height??t,b=p.pixelRatio??i;let g;try{g=await so({canvas:{width:h,height:f,pixelRatio:b},textRect:u,lines:c,font:{family:d.family,size:d.size,weight:`${d.weight}`,style:d.style,color:d.color,opacity:d.opacity},style:{lineHeight:p.style?.lineHeight??1.2,textDecoration:p.style?.textDecoration??"none",gradient:p.style?.gradient},stroke:p.stroke,shadow:p.shadow,align:p.align??{horizontal:"center",vertical:"middle"},background:p.background,glyphPathProvider:y=>n.glyphPath(l,y),getUnitsPerEm:()=>n.getUnitsPerEm(l)})}catch(y){throw new Error(`Failed to build draw operations: ${y instanceof Error?y.message:String(y)}`)}try{return ao(g,c,{t:m,fontSize:d.size,anim:p.animation?{preset:p.animation.preset,speed:p.animation.speed,duration:p.animation.duration,style:p.animation.style,direction:p.animation.direction}:void 0})}catch(y){throw new Error(`Failed to apply animation: ${y instanceof Error?y.message:String(y)}`)}}catch(d){throw d instanceof Error?d:new Error(`Failed to render frame at time ${m}s: ${String(d)}`)}},createRenderer(p){try{return wo(p)}catch(m){throw new Error(`Failed to create renderer: ${m instanceof Error?m.message:String(m)}`)}},destroy(){try{n.destroy()}catch(p){console.error(`Error during cleanup: ${p instanceof Error?p.message:String(p)}`)}}}}const or=s=>{const t=(s.split("/").pop()||"").replace(/\.(ttf|otf|woff|woff2)$/i,""),i=t.replace(/-(Bold|Light|Regular|Italic|Medium|SemiBold|Black|Thin|ExtraLight|ExtraBold|Heavy)$/i,"");return{full:t,base:i}};class Eo extends we{textEngine=null;renderer=null;canvas=null;texture=null;sprite=null;lastRenderedTime=-1;cachedFrames=new Map;isRendering=!1;targetFPS=30;validatedAsset=null;createFontMapping(){const e=new Map;return e.set("Arapey","/assets/fonts/Arapey-Regular.ttf"),e.set("ClearSans","/assets/fonts/ClearSans-Regular.ttf"),e.set("Clear Sans","/assets/fonts/ClearSans-Regular.ttf"),e.set("DidactGothic","/assets/fonts/DidactGothic-Regular.ttf"),e.set("Didact Gothic","/assets/fonts/DidactGothic-Regular.ttf"),e.set("Montserrat","/assets/fonts/Montserrat-SemiBold.ttf"),e.set("MovLette","/assets/fonts/MovLette.ttf"),e.set("OpenSans","/assets/fonts/OpenSans-Bold.ttf"),e.set("Open Sans","/assets/fonts/OpenSans-Bold.ttf"),e.set("PermanentMarker","/assets/fonts/PermanentMarker-Regular.ttf"),e.set("Permanent Marker","/assets/fonts/PermanentMarker-Regular.ttf"),e.set("Roboto","/assets/fonts/Roboto-BlackItalic.ttf"),e.set("SueEllenFrancisco","/assets/fonts/SueEllenFrancisco.ttf"),e.set("Sue Ellen Francisco","/assets/fonts/SueEllenFrancisco.ttf"),e.set("UniNeue","/assets/fonts/UniNeue-Bold.otf"),e.set("Uni Neue","/assets/fonts/UniNeue-Bold.otf"),e.set("WorkSans","/assets/fonts/WorkSans-Light.ttf"),e.set("Work Sans","/assets/fonts/WorkSans-Light.ttf"),e}async load(){await super.load();const e=this.clipConfiguration.asset;try{const t=this.edit.getEdit();if(this.targetFPS=t?.output?.fps||30,e.width=e.width||this.edit.size.width,e.height=e.height||this.edit.size.height,e.pixelRatio=e.pixelRatio||2,e.cacheEnabled=e.cacheEnabled??!0,Array.isArray(t?.timeline?.fonts)&&t.timeline.fonts.length>0){const a=e.font?.family;if(a){const p=t.timeline.fonts?.find(m=>{const{full:d,base:l}=or(m.src),c=a.toLowerCase();return d.toLowerCase()===c||l.toLowerCase()===c});p&&(e.customFonts=[{src:p.src,family:a,weight:e.font?.weight?.toString()||"400",style:e.font?.style||"normal"}])}}const i=fi.safeParse(e);if(!i.success){console.error("Rich-text asset validation failed:",i.error),this.createFallbackText(e);return}this.textEngine=await So({width:e.width,height:e.height,pixelRatio:e.pixelRatio,fps:this.targetFPS});const{value:r}=this.textEngine.validate(e);this.validatedAsset=r;const n=this.createFontMapping();this.canvas=document.createElement("canvas"),this.canvas.width=e.width*e.pixelRatio,this.canvas.height=e.height*e.pixelRatio,this.renderer=this.textEngine.createRenderer(this.canvas);const o=t?.timeline?.fonts||[];if(o.length>0){const a=e.font?.family;if(a){const p=o.find(m=>{const{full:d,base:l}=or(m.src),c=a.toLowerCase();return d.toLowerCase()===c||l.toLowerCase()===c});if(p)try{const m={family:a,weight:e.font?.weight?.toString()||"400",style:e.font?.style||"normal"};await this.textEngine.registerFontFromUrl(p.src,m)}catch(m){console.warn(`Failed to load font ${a}:`,m)}}}else if(e.font?.family){const a=e.font.family,p=n.get(a);if(p)try{const m={family:e.font.family,weight:e.font.weight||"400",style:e.font.style||"normal"};await this.textEngine.registerFontFromFile(p,m)}catch(m){console.warn(`Failed to load local font: ${a}`,m)}else console.warn(`Font ${a} not found in local assets. Available fonts:`,Array.from(n.keys()))}await this.renderFrame(0),this.configureKeyframes()}catch(t){console.error("Failed to initialize rich text player:",t),this.cleanupResources(),this.createFallbackText(e)}}cleanupResources(){if(this.textEngine){try{this.textEngine.destroy()}catch(e){console.warn("Error destroying text engine:",e)}this.textEngine=null}this.renderer=null,this.canvas=null,this.validatedAsset=null}async renderFrame(e){if(!this.textEngine||!this.renderer||!this.canvas||!this.validatedAsset)return;const t=Math.floor(e*this.targetFPS);if(this.validatedAsset.cacheEnabled&&this.cachedFrames.has(t)){const i=this.cachedFrames.get(t);this.sprite&&this.sprite.texture!==i&&(this.sprite.texture=i),this.lastRenderedTime=e;return}try{const i=await this.textEngine.renderFrame(this.validatedAsset,e),r=this.canvas.getContext("2d");r&&r.clearRect(0,0,this.canvas.width,this.canvas.height),await this.renderer.render(i);const n=R.Texture.from(this.canvas);this.sprite?(this.texture&&!this.cachedFrames.has(t)&&this.texture.destroy(),this.sprite.texture=n):(this.sprite=new R.Sprite(n),this.sprite.scale.set(1/this.validatedAsset.pixelRatio),this.contentContainer.addChild(this.sprite)),this.texture=n,this.validatedAsset.cacheEnabled&&this.cachedFrames.size<150&&this.cachedFrames.set(t,n),this.lastRenderedTime=e}catch(i){console.error("Failed to render rich text frame:",i)}}createFallbackText(e){const t=new R.TextStyle({fontFamily:e.font?.family||"Arial",fontSize:e.font?.size||48,fill:e.font?.color||"#ffffff",align:e.align?.horizontal||"center",wordWrap:!0,wordWrapWidth:e.width||this.edit.size.width}),i=new R.Text(e.text,t),r=e.width||this.edit.size.width,n=e.height||this.edit.size.height;switch(e.align?.horizontal){case"left":i.anchor.set(0,.5),i.x=0;break;case"right":i.anchor.set(1,.5),i.x=r;break;default:i.anchor.set(.5,.5),i.x=r/2}switch(e.align?.vertical){case"top":i.anchor.set(i.anchor.x,0),i.y=0;break;case"bottom":i.anchor.set(i.anchor.x,1),i.y=n;break;default:i.anchor.set(i.anchor.x,.5),i.y=n/2}this.contentContainer.addChild(i)}renderFrameSafe(e){this.isRendering||(this.isRendering=!0,this.renderFrame(e).catch(t=>console.error("Failed to render rich text frame:",t)).finally(()=>{this.isRendering=!1}))}update(e,t){if(super.update(e,t),this.textEngine&&this.renderer&&!this.isRendering){const i=this.getCurrentTime()/1e3,o=1/(this.edit.getEdit()?.output?.fps||30);Math.abs(i-this.lastRenderedTime)>o&&this.renderFrameSafe(i)}}dispose(){super.dispose();for(const e of this.cachedFrames.values())e.destroy();this.cachedFrames.clear(),this.texture&&!this.cachedFrames.has(Math.floor(this.lastRenderedTime*this.targetFPS))&&this.texture.destroy(),this.texture=null,this.sprite&&(this.sprite.destroy(),this.sprite=null),this.canvas&&(this.canvas=null),this.textEngine&&(this.textEngine.destroy(),this.textEngine=null),this.renderer=null,this.validatedAsset=null}getSize(){const e=this.clipConfiguration.asset;return{width:e.width||this.edit.size.width,height:e.height||this.edit.size.height}}getFitScale(){return 1}updateTextContent(e){const t=this.clipConfiguration.asset;if(t.text=e,this.textEngine){const{value:i}=this.textEngine.validate(t);this.validatedAsset=i}for(const i of this.cachedFrames.values())i.destroy();this.cachedFrames.clear(),this.lastRenderedTime=-1,this.textEngine&&this.renderer&&this.renderFrameSafe(this.getCurrentTime()/1e3)}getCurrentTime(){return this.edit.playbackTime}}class Ao extends we{shape;shapeBackground;constructor(e,t){super(e,t),this.shape=null,this.shapeBackground=null}async load(){await super.load();const e=this.clipConfiguration.asset,t=new R.Graphics,i=e.width??this.edit.size.width,r=e.height??this.edit.size.height;t.fillStyle={color:"transparent"},t.rect(0,0,i,r),t.fill();const n=new R.Graphics;switch(e.shape){case"rectangle":{const o=e.rectangle,a=i/2-o.width/2,p=r/2-o.height/2;n.rect(a,p,o.width,o.height);break}case"circle":{const o=e.circle,a=i/2,p=r/2;n.circle(a,p,o.radius);break}case"line":{const o=e.line,a=i/2-o.length/2,p=r/2-o.thickness/2;n.rect(a,p,o.length,o.thickness);break}default:console.warn("Unsupported shape asset type.");break}if(n.fillStyle={color:e.fill?.color??"#ffffff",alpha:e.fill?.opacity??1},n.fill(),e.stroke){const o=new Fi({thickness:e.stroke.width,color:e.stroke.color});n.filters=[o]}this.shapeBackground=t,this.shape=n,this.contentContainer.addChild(t),t.addChild(n),this.configureKeyframes()}update(e,t){super.update(e,t)}draw(){super.draw()}dispose(){super.dispose(),this.shape?.destroy(),this.shape=null,this.shapeBackground?.destroy(),this.shapeBackground=null}getSize(){const e=this.clipConfiguration.asset;return{width:e.width??this.edit.size.width,height:e.height??this.edit.size.height}}getFitScale(){return 1}}class Zt{static DEFAULT_BLINK_INTERVAL_MS=500;static DEFAULT_CURSOR_WIDTH_PX=2;static DEFAULT_CURSOR_COLOR=16777215;cursor=null;parent;textElement;clipConfig;textPosition=0;pixelX=0;pixelY=0;currentLine=0;isBlinking=!1;blinkInterval=null;blinkIntervalMs=500;width=2;color=16777215;isVisible=!0;constructor(e,t,i,r){this.parent=e,this.textElement=t,this.clipConfig=i,this.width=r?.width??Zt.DEFAULT_CURSOR_WIDTH_PX,this.color=r?.color??Zt.DEFAULT_CURSOR_COLOR,this.blinkIntervalMs=r?.blinkInterval??Zt.DEFAULT_BLINK_INTERVAL_MS,this.textPosition=0,this.isBlinking=!1,this.isVisible=!0,this.blinkInterval=null,this.createCursor()}updatePosition(e){if(!this.cursor||!this.textElement){console.warn("TextCursor: Cannot update position, cursor not initialized");return}this.textPosition=this.validateTextPosition(e),this.calculateAndApplyPixelPosition()}setPosition(e,t){if(!this.cursor){console.warn("TextCursor: Cannot set position, cursor not initialized");return}this.pixelX=e,this.pixelY=t,this.updateGraphicsPosition()}show(){this.setVisible(!0)}hide(){this.setVisible(!1)}setVisible(e){this.isVisible=e,this.cursor&&!this.isBlinking&&(this.cursor.visible=e)}startBlinking(){if(!this.cursor){console.warn("TextCursor: Cannot start blinking, cursor not initialized");return}this.isBlinking||this.startBlinkingAnimation()}stopBlinking(){this.stopBlinkingAnimation()}setBlinkInterval(e){this.blinkIntervalMs=e,this.isBlinking&&(this.stopBlinking(),this.startBlinking())}dispose(){if(this.stopBlinkingAnimation(),this.cursor&&this.parent)try{this.parent.removeChild(this.cursor)}catch(e){console.warn("TextCursor: Error removing cursor from parent:",e)}if(this.cursor)try{this.cursor.destroy()}catch(e){console.warn("TextCursor: Error destroying cursor graphics:",e)}finally{this.cursor=null}this.textPosition=0,this.pixelX=0,this.pixelY=0,this.currentLine=0,this.isVisible=!0}createCursor(){if(!this.textElement)return;this.cursor=new R.Graphics,this.cursor.fillStyle={color:this.color};const e=this.textElement.style.fontSize;this.cursor.rect(0,0,this.width,e),this.cursor.fill(),this.parent.addChild(this.cursor),this.cursor.visible=this.isVisible}validateTextPosition(e){return this.textElement?Math.max(0,Math.min(e,this.textElement.text.length)):0}calculateAndApplyPixelPosition(){this.calculatePixelPositionFromText(),this.updateGraphicsPosition()}calculatePixelPositionFromText(){if(!this.textElement)return;const{text:e}=this.textElement,t=this.textElement.style,i=e.substring(0,this.textPosition),r=i.match(/\n/g);this.currentLine=r?r.length:0;const n=e.split(`
185
- `),o=this.currentLine<n.length?n[this.currentLine]:"",a=i.lastIndexOf(`
186
- `),p=a===-1?this.textPosition:this.textPosition-a-1,m=o.substring(0,p);let d;m.length>0&&m.endsWith(" ")?d=this.measureText(`${m}x`,t)-this.measureText("x",t):d=this.measureText(m,t);const l=t.lineHeight;this.pixelY=this.currentLine*l;const u=this.clipConfig.asset.alignment?.horizontal??"center";let h=d;if(u!=="left"){const f=this.measureText(o,t),b=this.textElement.width;let g=0;u==="center"?g=(b-f)/2:u==="right"&&(g=b-f),h=g+d}this.pixelX=h}updateGraphicsPosition(){this.cursor&&this.cursor.position.set(this.pixelX,this.pixelY)}startBlinkingAnimation(){!this.cursor||this.isBlinking||(this.isBlinking=!0,this.blinkInterval=window.setInterval(()=>{this.cursor&&this.isBlinking&&(this.cursor.visible=!this.cursor.visible)},this.blinkIntervalMs))}stopBlinkingAnimation(){this.blinkInterval!==null&&(window.clearInterval(this.blinkInterval),this.blinkInterval=null),this.isBlinking=!1,this.cursor&&(this.cursor.visible=this.isVisible)}measureText(e,t){const i=new R.Text(e,t),{width:r}=i;return i.destroy(),r}isInitialized(){return this.cursor!==null}getState(){return{isInitialized:this.isInitialized(),isBlinking:this.isBlinking,isVisible:this.isVisible,textPosition:this.textPosition,pixelPosition:{x:this.pixelX,y:this.pixelY},currentLine:this.currentLine}}}class gi{static DEFAULT_FOCUS_DELAY_MS=50;hiddenInput=null;isFocused=!1;focusRetryCount=0;maxFocusRetries=3;focusDelay=gi.DEFAULT_FOCUS_DELAY_MS;eventHandlers={};abortController=null;textChangeCallback=null;lastSyncedText="";isComposing=!1;setupInput(e,t){this.focusDelay=t?.focusDelay??gi.DEFAULT_FOCUS_DELAY_MS,this.createHiddenTextarea(),this.hiddenInput&&(this.hiddenInput.value=e,this.lastSyncedText=e),this.setupEventListeners(),t?.autoFocus!==!1&&this.focusInput()}updateInputValue(e){this.hiddenInput&&(this.hiddenInput.value=e,this.lastSyncedText=e)}focusInput(){this.hiddenInput&&setTimeout(()=>{this.hiddenInput&&!this.isFocused&&(this.hiddenInput.focus(),setTimeout(()=>{!this.isFocused&&this.focusRetryCount<this.maxFocusRetries&&(this.focusRetryCount+=1,this.focusInput())},10))},this.focusDelay)}blurInput(){this.hiddenInput&&this.hiddenInput.blur()}setSelectionRange(e,t){if(!this.hiddenInput)return;const i=this.hiddenInput.value.length,r=Math.max(0,Math.min(e,i)),n=Math.max(r,Math.min(t,i));this.hiddenInput.setSelectionRange(r,n)}getCursorPosition(){return this.hiddenInput?.selectionStart||0}getValue(){return this.hiddenInput?.value||""}setTextInputHandler(e){this.textChangeCallback=e}setEventHandlers(e){this.eventHandlers={...this.eventHandlers,...e}}isFocusedInput(){return this.isFocused}dispose(){this.removeAllEventListeners(),this.hiddenInput&&this.hiddenInput.parentNode&&this.hiddenInput.parentNode.removeChild(this.hiddenInput),this.hiddenInput=null,this.isFocused=!1,this.focusRetryCount=0,this.textChangeCallback=null,this.eventHandlers={}}createHiddenTextarea(){this.hiddenInput=document.createElement("textarea");const e={position:"absolute",opacity:"0.01",pointerEvents:"none",zIndex:"999",left:"0px",top:"0px",width:"1px",height:"1px",border:"none",outline:"none",resize:"none",backgroundColor:"transparent"};Object.assign(this.hiddenInput.style,e),this.hiddenInput.tabIndex=0,document.body.appendChild(this.hiddenInput)}setupEventListeners(){if(!this.hiddenInput)return;this.abortController=new AbortController;const{signal:e}=this.abortController;this.hiddenInput.addEventListener("input",this.handleTextInput,{signal:e}),this.hiddenInput.addEventListener("keydown",this.handleKeyDown,{signal:e}),this.hiddenInput.addEventListener("compositionstart",this.handleCompositionStart,{signal:e}),this.hiddenInput.addEventListener("compositionend",this.handleCompositionEnd,{signal:e}),this.hiddenInput.addEventListener("focus",this.handleFocus,{signal:e}),this.hiddenInput.addEventListener("blur",this.handleBlur,{signal:e}),this.hiddenInput.addEventListener("paste",this.handlePaste,{signal:e})}removeAllEventListeners(){this.abortController?.abort(),this.abortController=null}handleTextInput=e=>{if(!this.hiddenInput||this.isComposing)return;const t=this.hiddenInput.value,i=this.hiddenInput.selectionStart||0;this.lastSyncedText=t,this.textChangeCallback?.(t,i)};handleKeyDown=e=>{if(document.activeElement!==this.hiddenInput)return;let t=!1;if((e.ctrlKey||e.metaKey)&&(t=this.handleKeyboardShortcuts(e),t)){e.preventDefault();return}if(e.key==="Tab"){const i=e.shiftKey?"backward":"forward";this.eventHandlers.onTabNavigation?.(i),e.preventDefault();return}switch(e.key){case"Escape":this.eventHandlers.onEscape?.(e),t=!0;break;case"Enter":t=!1;break;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":setTimeout(()=>{if(this.hiddenInput){const i=this.hiddenInput.value,r=this.hiddenInput.selectionStart||0;this.textChangeCallback?.(i,r)}},0),t=!1;break;case"Backspace":case"Delete":t=!1;break;default:t=this.eventHandlers.onCustomKey?.(e.key,e)||!1;break}t&&e.preventDefault()};handleKeyboardShortcuts(e){const{key:t}=e;switch(t.toLowerCase()){case"a":return this.selectAll(),!0;case"c":case"v":return!1;case"z":return this.eventHandlers.onCustomKey?.("undo",e),!0;case"y":return this.eventHandlers.onCustomKey?.("redo",e),!0;default:return!1}}handleCompositionStart=e=>{this.isComposing=!0};handleCompositionEnd=e=>{if(this.isComposing=!1,this.hiddenInput){const t=this.hiddenInput.value,i=this.hiddenInput.selectionStart||0;this.textChangeCallback?.(t,i)}};handleFocus=e=>{this.isFocused=!0,this.focusRetryCount=0,this.eventHandlers.onFocus?.(e)};handleBlur=e=>{this.isFocused=!1,this.eventHandlers.onBlur?.(e)};handlePaste=e=>{setTimeout(()=>{this.handleTextInput(e)},0)};selectAll(){this.hiddenInput&&this.hiddenInput.select()}}class De{static DOUBLE_CLICK_THRESHOLD_MS=300;static EDITING_BG_PADDING_PX=5;static EDITING_BG_ALPHA=.2;static CLICK_HANDLER_DELAY_MS=100;parent;targetText;clipConfig;isEditing=!1;lastClickTime=0;editingContainer=null;editableText=null;textCursor=null;textInputHandler=null;outsideClickHandler=null;constructor(e,t,i){this.parent=e,this.targetText=t,this.clipConfig=i,this.parent.getContainer().eventMode="static",this.parent.getContainer().on("click",this.checkForDoubleClick)}dispose(){this.parent.getContainer().off("click",this.checkForDoubleClick),this.stopEditing(),this.outsideClickHandler&&(window.removeEventListener("click",this.outsideClickHandler),this.outsideClickHandler=null)}startEditing(){if(this.isEditing||!this.targetText)return;const e=structuredClone(this.clipConfig);this.targetText.visible=!1,this.createEditingEnvironment(),this.setupOutsideClickHandler(e),this.isEditing=!0}stopEditing(e=!1,t){if(!this.isEditing)return;let i="";this.editableText&&(i=this.editableText.text),this.editingContainer&&(this.parent.getContainer().removeChild(this.editingContainer),this.editingContainer.destroy(),this.editingContainer=null),this.editableText=null,this.textCursor&&(this.textCursor.dispose(),this.textCursor=null),this.textInputHandler&&(this.textInputHandler.dispose(),this.textInputHandler=null),this.targetText.visible=!0,e&&t&&i!==""&&this.parent.updateTextContent(i,t),this.isEditing=!1}checkForDoubleClick=e=>{const t=Date.now();t-this.lastClickTime<De.DOUBLE_CLICK_THRESHOLD_MS&&this.startEditing(),this.lastClickTime=t};setupOutsideClickHandler(e){this.outsideClickHandler=t=>{const r=this.parent.getContainer().getBounds(),n=t.clientX,o=t.clientY;(n<r.x||n>r.x+r.width||o<r.y||o>r.y+r.height)&&(this.stopEditing(!0,e),this.outsideClickHandler&&(window.removeEventListener("click",this.outsideClickHandler),this.outsideClickHandler=null))},setTimeout(()=>{this.outsideClickHandler&&window.addEventListener("click",this.outsideClickHandler)},De.CLICK_HANDLER_DELAY_MS)}createEditingEnvironment(){this.setupEditingContainer(),this.editingContainer&&this.editableText&&(this.textCursor=new Zt(this.editingContainer,this.editableText,this.clipConfig),this.textCursor.updatePosition(this.targetText.text.length),this.textCursor.startBlinking()),this.setupTextInputHandler(),this.updateTextAlignment()}setupEditingContainer(){this.editingContainer=new R.Container,this.parent.getContainer().addChild(this.editingContainer);const e=new R.Graphics;e.fillStyle={color:0,alpha:De.EDITING_BG_ALPHA},e.rect(-5,-5,this.targetText.width+2*De.EDITING_BG_PADDING_PX,this.targetText.height+2*De.EDITING_BG_PADDING_PX),e.fill(),this.editingContainer.addChild(e),this.editableText=new R.Text(this.targetText.text,this.targetText.style),this.editableText.eventMode="static",this.editableText.cursor="text",this.editingContainer.addChild(this.editableText)}setupTextInputHandler(){this.textInputHandler=new gi,this.textInputHandler.setTextInputHandler((e,t)=>{this.editableText&&(this.editableText.text=e,this.updateTextAlignment()),this.textCursor?.updatePosition(t)}),this.textInputHandler.setEventHandlers({onEscape:e=>this.stopEditing(!1),onTabNavigation:e=>this.stopEditing(!0)}),this.textInputHandler.setupInput(this.targetText.text,{autoFocus:!0})}updateTextAlignment(){if(!this.editableText||!this.editingContainer)return;const e=this.getContainerDimensions(),t=this.getAlignmentSettings(),i=this.calculateHorizontalPosition({width:this.editableText.width},e,t.horizontal),r=this.calculateVerticalPosition({height:this.editableText.height},e,t.vertical);if(this.editingContainer.position.set(i,r),this.editingContainer.children.length>0){const n=this.editingContainer.getChildAt(0);n instanceof R.Graphics&&(n.clear(),n.fillStyle={color:0,alpha:De.EDITING_BG_ALPHA},n.rect(-5,-5,this.editableText.width+2*De.EDITING_BG_PADDING_PX,this.editableText.height+2*De.EDITING_BG_PADDING_PX),n.fill())}}calculateHorizontalPosition(e,t,i="center"){switch(i){case"center":return t.width/2-e.width/2;case"right":return t.width-e.width;case"left":default:return 0}}calculateVerticalPosition(e,t,i="center"){switch(i){case"center":return t.height/2-e.height/2;case"bottom":return t.height-e.height;case"top":default:return 0}}getContainerDimensions(){const e=this.clipConfig.asset;return{width:e.width??this.parent.getSize().width,height:e.height??this.parent.getSize().height}}getAlignmentSettings(){const e=this.clipConfig.asset;return{horizontal:e.alignment?.horizontal??"center",vertical:e.alignment?.vertical??"center"}}}class Io extends we{background=null;text=null;textEditor=null;async load(){await super.load();const e=this.clipConfiguration.asset;if(this.background=new R.Graphics,e.background&&(this.background.fillStyle={color:e.background.color,alpha:e.background.opacity},this.background.rect(0,0,e.width??this.edit.size.width,e.height??this.edit.size.height),this.background.fill()),this.text=new R.Text(e.text,this.createTextStyle(e)),this.positionText(e),e.stroke){const t=new Fi({thickness:e.stroke.width,color:e.stroke.color});this.text.filters=[t]}this.contentContainer.addChild(this.background),this.contentContainer.addChild(this.text),this.configureKeyframes(),this.textEditor=new De(this,this.text,this.clipConfiguration)}update(e,t){super.update(e,t)}dispose(){super.dispose(),this.background?.destroy(),this.background=null,this.text?.destroy(),this.text=null,this.textEditor?.dispose(),this.textEditor=null}getSize(){const e=this.clipConfiguration.asset;return{width:e.width??this.edit.size.width,height:e.height??this.edit.size.height}}getFitScale(){return 1}createTextStyle(e){return new R.TextStyle({fontFamily:e.font?.family??"Open Sans",fontSize:e.font?.size??32,fill:e.font?.color??"#ffffff",fontWeight:(e.font?.weight??"400").toString(),wordWrap:!0,wordWrapWidth:e.width??this.edit.size.width,lineHeight:(e.font?.lineHeight??1)*(e.font?.size??32),align:e.alignment?.horizontal??"center"})}positionText(e){if(!this.text)return;const t=e.alignment?.horizontal??"center",i=e.alignment?.vertical??"center",r=e.width??this.edit.size.width,n=e.height??this.edit.size.height;let o=r/2-this.text.width/2,a=n/2-this.text.height/2;t==="left"?o=0:t==="right"&&(o=r-this.text.width),i==="top"?a=0:i==="bottom"&&(a=n-this.text.height),this.text.position.set(o,a)}updateTextContent(e,t){this.edit.updateTextContent(this,e,t)}}class Po extends we{texture;sprite;isPlaying;originalSize;volumeKeyframeBuilder;syncTimer;skipVideoUpdate;constructor(e,t){super(e,t),this.texture=null,this.sprite=null,this.isPlaying=!1,this.originalSize=null;const i=this.clipConfiguration.asset;this.volumeKeyframeBuilder=new ke(i.volume??1,this.getLength()),this.syncTimer=0,this.skipVideoUpdate=!1}async load(){await super.load();const e=this.clipConfiguration.asset,t=e.src;if(t.endsWith(".mov")||t.endsWith(".webm"))throw new Error(`Video source '${e.src}' is not supported. .mov and .webm files are currently not supported.`);const i={src:t,data:{autoPlay:!1,muted:!1}},r=await this.edit.assetLoader.load(t,i);if(!(r?.source instanceof R.VideoSource))throw new Error(`Invalid video source '${e.src}'.`);this.texture=this.createCroppedTexture(r),this.sprite=new R.Sprite(this.texture),this.contentContainer.addChild(this.sprite),this.clipConfiguration.width&&this.clipConfiguration.height&&this.applyFixedDimensions(),this.configureKeyframes()}update(e,t){if(super.update(e,t),this.skipVideoUpdate)return;const{trim:i=0}=this.clipConfiguration.asset;if(this.syncTimer+=t,!this.texture)return;const r=this.getPlaybackTime(),n=this.edit.isPlaying&&this.isActive();n&&(this.isPlaying||(this.isPlaying=!0,this.texture.source.resource.currentTime=r/1e3+i,this.texture.source.resource.play().catch(console.error)),this.texture.source.resource.volume!==this.getVolume()&&(this.texture.source.resource.volume=this.getVolume()),Math.abs((this.texture.source.resource.currentTime-i)*1e3-r)>100&&(this.texture.source.resource.currentTime=r/1e3+i)),!n&&this.isPlaying&&(this.isPlaying=!1,this.texture.source.resource.pause());const o=this.syncTimer>100;!this.edit.isPlaying&&this.isActive()&&o&&(this.syncTimer=0,this.texture.source.resource.currentTime=r/1e3+i)}draw(){super.draw()}dispose(){super.dispose(),this.sprite?.destroy(),this.sprite=null,this.texture?.destroy(),this.texture=null,this.originalSize=null}getSize(){return this.clipConfiguration.width&&this.clipConfiguration.height?{width:this.clipConfiguration.width,height:this.clipConfiguration.height}:{width:this.sprite?.width??0,height:this.sprite?.height??0}}getVolume(){return this.volumeKeyframeBuilder.getValue(this.getPlaybackTime())}createCroppedTexture(e){const t=this.clipConfiguration.asset;if(!t.crop)return e;const i=e.width,r=e.height,n=Math.floor((t.crop?.left??0)*i),o=Math.floor((t.crop?.right??0)*i),a=Math.floor((t.crop?.top??0)*r),p=Math.floor((t.crop?.bottom??0)*r),m=n,d=a,l=i-n-o,c=r-a-p,u=new R.Rectangle(m,d,l,c);return new R.Texture({source:e.source,frame:u})}}const lr=_e(["linear","bezier","constant"]),cr=_e(["ease","easeIn","easeOut","easeInOut","easeInQuad","easeInCubic","easeInQuart","easeInQuint","easeInSine","easeInExpo","easeInCirc","easeInBack","easeOutQuad","easeOutCubic","easeOutQuart","easeOutQuint","easeOutSine","easeOutExpo","easeOutCirc","easeOutBack","easeInOutQuad","easeInOutCubic","easeInOutQuart","easeInOutQuint","easeInOutSine","easeInOutExpo","easeInOutCirc","easeInOutBack"]),at=te({from:D(),to:D(),start:D().min(0),length:D().positive(),interpolation:lr.optional(),easing:cr.optional()}),hr=pe().url("Invalid audio url format."),ur=at.extend({from:D().min(0).max(1),to:D().min(0).max(1)}).array().or(D().min(0).max(1)),Zi=te({type:nt("audio"),src:hr,trim:D().optional(),volume:ur.optional()}),Ro=_e(["top","topRight","right","bottomRight","bottom","bottomLeft","left","topLeft","center"]),Ki=te({type:nt("html"),html:pe(),css:pe(),width:D().positive().optional(),height:D().positive().optional(),position:Ro.optional()}),dr=pe().url("Invalid image url format."),fr=te({top:D().min(0).optional(),right:D().min(0).optional(),bottom:D().min(0).optional(),left:D().min(0).optional()}),qi=te({type:nt("image"),src:dr,crop:fr.optional()}),pr=pe().url("Invalid luma url format."),Xi=te({type:nt("luma"),src:pr}),Yi=pe().regex(/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})|transparent$/,"Invalid color format."),Qi=te({width:D().positive(),height:D().positive()}),Ji=te({radius:D().positive()}),es=te({length:D().positive(),thickness:D().positive()}),mr=te({color:Yi,opacity:D().min(0).max(1)}),gr=te({color:Yi,width:D().positive()}),ts=te({type:nt("shape"),width:D().positive().optional(),height:D().positive().optional(),shape:_e(["rectangle","circle","line"]),fill:mr.optional(),stroke:gr.optional(),rectangle:Qi.optional(),circle:Ji.optional(),line:es.optional()}).refine(s=>s.shape==="rectangle"?Qi.safeParse(s.rectangle):s.shape==="circle"?Ji.safeParse(s.circle):s.shape==="line"?es.safeParse(s.line):!1),yi=pe().regex(/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})|transparent$/,"Invalid color format."),yr=te({color:yi.optional(),family:pe().optional(),size:D().positive().optional(),weight:D().optional(),lineHeight:D().optional()}),br=te({horizontal:_e(["left","center","right"]).optional(),vertical:_e(["top","center","bottom"]).optional()}),vr=te({color:yi,opacity:D().min(0).max(1)}),wr=te({width:D().positive(),color:yi}),is=te({type:nt("text"),text:pe(),width:D().positive().optional(),height:D().positive().optional(),font:yr.optional(),alignment:br.optional(),background:vr.optional(),stroke:wr.optional()}),_r=pe().url("Invalid video url format."),xr=te({top:D().min(0).optional(),right:D().min(0).optional(),bottom:D().min(0).optional(),left:D().min(0).optional()}),Cr=at.extend({from:D().min(0).max(1),to:D().min(0).max(1)}).array().or(D().min(0).max(1)),ss=te({type:nt("video"),src:_r,trim:D().optional(),crop:xr.optional(),volume:Cr.optional()}),kr=ji([is,fi,ts,Ki,qi,ss,Xi,Zi]).refine(s=>s.type==="text"?is.safeParse(s):s.type==="rich-text"?fi.safeParse(s):s.type==="shape"?ts.safeParse(s):s.type==="html"?Ki.safeParse(s):s.type==="image"?qi.safeParse(s):s.type==="video"?ss.safeParse(s):s.type==="luma"?Xi.safeParse(s):s.type==="audio"?Zi.safeParse(s):!1),Oo=_e(["topLeft","top","topRight","left","center","right","bottomLeft","bottom","bottomRight"]),Fo=_e(["crop","cover","contain","none"]),Rt=D().min(-10).max(10).default(0),Mo=at.extend({from:Rt,to:Rt}).array().or(Rt),Lo=at.extend({from:Rt,to:Rt}).array().or(Rt),Bo=te({x:Mo.default(0),y:Lo.default(0)}),$o=at.extend({from:D().min(0).max(1),to:D().min(0).max(1)}).array().or(D().min(0).max(1)),Do=at.extend({from:D().min(0),to:D().min(0)}).array().or(D().min(0)),zo=te({angle:at.extend({from:D(),to:D()}).array().or(D())}),Ho=pe(),Tr=pe(),No=te({in:Tr.optional(),out:Tr.optional()}),Uo=te({rotate:zo.default({angle:0})}),rs=te({asset:kr,start:D().min(0),length:D().positive(),position:Oo.default("center").optional(),fit:Fo.optional(),offset:Bo.default({x:0,y:0}).optional(),opacity:$o.default(1).optional(),scale:Do.default(1).optional(),transform:Uo.default({rotate:{angle:0}}).optional(),effect:Ho.optional(),transition:No.optional(),width:D().min(1).max(3840).optional(),height:D().min(1).max(2160).optional()}).transform(s=>{if(s.fit!==void 0)return s;const e=s.asset.type==="rich-text"?"none":"crop";return{...s,fit:e}});class jo{constructor(e,t){this.trackIdx=e,this.clip=t}name="addClip";addedPlayer;async execute(e){if(!e)return;const t=rs.parse(this.clip),i=e.createPlayerFromAssetType(t);i.layer=this.trackIdx+1,await e.addPlayer(this.trackIdx,i),e.updateDuration(),this.addedPlayer=i}async undo(e){!e||!this.addedPlayer||(e.queueDisposeClip(this.addedPlayer),e.updateDuration())}}class Sr{constructor(e){this.trackIdx=e}name="addTrack";execute(e){if(!e)return;const t=e.getTracks(),i=e.getClips();t.splice(this.trackIdx,0,[]),i.forEach(r=>{if(r.layer>=this.trackIdx){const n=1e5-r.layer*100,o=e.getContainer().getChildByLabel(`shotstack-track-${n}`,!1);o&&o.removeChild(r.getContainer()),r.layer+=1;const a=1e5-r.layer*100;let p=e.getContainer().getChildByLabel(`shotstack-track-${a}`,!1);p||(p=new R.Container({label:`shotstack-track-${a}`,zIndex:a}),e.getContainer().addChild(p)),p.addChild(r.getContainer())}}),e.updateDuration(),e.emitEvent("track:added",{trackIndex:this.trackIdx,totalTracks:t.length})}undo(e){if(!e)return;const t=e.getTracks(),i=e.getClips();t.splice(this.trackIdx,1),i.forEach(r=>{r.layer>this.trackIdx&&(r.layer-=1)}),e.updateDuration()}}class Vo{name="ClearSelection";previousSelection=null;execute(e){const t=e.getSelectedClip();if(t){const i=e.findClipIndices(t);i&&(this.previousSelection={player:t,trackIndex:i.trackIndex,clipIndex:i.clipIndex})}e.setSelectedClip(null),e.emitEvent("selection:cleared",{})}undo(e){if(this.previousSelection){const t=e.getClipAt(this.previousSelection.trackIndex,this.previousSelection.clipIndex);t&&(e.setSelectedClip(t),e.emitEvent("clip:selected",{clip:t.clipConfiguration,trackIndex:this.previousSelection.trackIndex,clipIndex:this.previousSelection.clipIndex}))}}}class Wo{constructor(e,t){this.trackIdx=e,this.clipIdx=t}name="deleteClip";deletedClip;execute(e){if(!e)return;const i=e.getClips().filter(r=>r.layer===this.trackIdx+1);this.deletedClip=i[this.clipIdx],this.deletedClip&&(e.queueDisposeClip(this.deletedClip),e.updateDuration())}undo(e){!e||!this.deletedClip||e.undeleteClip(this.trackIdx,this.deletedClip)}}class Go{constructor(e){this.trackIdx=e}name="deleteTrack";deletedClips=[];execute(e){if(!e)return;const t=e.getClips(),i=e.getTracks();this.deletedClips=t.filter(o=>o.layer===this.trackIdx+1).map(o=>({config:structuredClone(o.clipConfiguration)})),t.forEach((o,a)=>{o.layer===this.trackIdx+1&&(t[a].shouldDispose=!0)}),e.disposeClips(),i.splice(this.trackIdx,1);const r=e.getClips(),n=e.getContainer();r.forEach((o,a)=>{if(o.layer>this.trackIdx+1){n.getChildByLabel(`shotstack-track-${1e5-o.layer*100}`,!1)?.removeChild(o.getContainer()),r[a].layer-=1;const m=1e5-r[a].layer*100;let d=n.getChildByLabel(`shotstack-track-${m}`,!1);d||(d=new R.Container({label:`shotstack-track-${m}`,zIndex:m}),n.addChild(d)),d.addChild(r[a].getContainer())}}),e.updateDuration()}async undo(e){if(!e||this.deletedClips.length===0)return;const t=e.getTracks(),i=e.getClips();t.splice(this.trackIdx,0,[]),i.forEach((r,n)=>{r.layer>=this.trackIdx+1&&(i[n].layer+=1)});for(const{config:r}of this.deletedClips){const n=e.createPlayerFromAssetType(r);n.layer=this.trackIdx+1,await e.addPlayer(this.trackIdx,n)}e.updateDuration()}}class Zo{constructor(e,t){this.trackIndex=e,this.clipIndex=t}name="SelectClip";previousSelection=null;execute(e){const t=e.getSelectedClip();if(t){const r=e.findClipIndices(t);r&&(this.previousSelection=r)}const i=e.getClipAt(this.trackIndex,this.clipIndex);i&&(e.setSelectedClip(i),e.emitEvent("clip:selected",{clip:i.clipConfiguration,trackIndex:this.trackIndex,clipIndex:this.clipIndex}))}undo(e){if(e.setSelectedClip(null),this.previousSelection){const t=e.getClipAt(this.previousSelection.trackIndex,this.previousSelection.clipIndex);t&&(e.setSelectedClip(t),e.emitEvent("clip:selected",{clip:t.clipConfiguration,trackIndex:this.previousSelection.trackIndex,clipIndex:this.previousSelection.clipIndex}))}else e.emitEvent("selection:cleared",{})}}class Ko{constructor(e,t,i){this.clip=e,this.initialClipConfig=t,this.finalClipConfig=i,this.storedInitialConfig=t?structuredClone(t):null,this.storedFinalConfig=i?structuredClone(i):structuredClone(this.clip.clipConfiguration)}name="setUpdatedClip";storedInitialConfig;storedFinalConfig;execute(e){if(!e)return;this.storedFinalConfig&&e.restoreClipConfiguration(this.clip,this.storedFinalConfig),e.setUpdatedClip(this.clip);const t=this.clip.layer-1,n=e.getClips().filter(o=>o.layer===this.clip.layer).indexOf(this.clip);e.emitEvent("clip:updated",{previous:{clip:this.storedInitialConfig||this.initialClipConfig,trackIndex:t,clipIndex:n},current:{clip:this.storedFinalConfig||this.clip.clipConfiguration,trackIndex:t,clipIndex:n}})}undo(e){if(!e||!this.storedInitialConfig)return;e.restoreClipConfiguration(this.clip,this.storedInitialConfig),e.setUpdatedClip(this.clip);const t=this.clip.layer-1,n=e.getClips().filter(o=>o.layer===this.clip.layer).indexOf(this.clip);e.emitEvent("clip:updated",{previous:{clip:this.storedFinalConfig,trackIndex:t,clipIndex:n},current:{clip:this.storedInitialConfig,trackIndex:t,clipIndex:n}})}}class qo{constructor(e,t,i){this.trackIndex=e,this.clipIndex=t,this.splitTime=i}name="SplitClip";originalClipConfig=null;rightClipPlayer=null;splitSuccessful=!1;execute(e){const t=e.getClipAt(this.trackIndex,this.clipIndex);if(!t||!t.clipConfiguration)throw new Error("Cannot split clip: invalid player or clip configuration");const i=t.clipConfiguration,r=i.start||0,n=i.length,o=.1,a=this.splitTime-r;if(a<=o||a>=n-o)throw new Error("Cannot split clip: split point too close to clip boundaries");this.originalClipConfig={...i};const p={...i,length:a},m={...i,start:r+a,length:n-a};if(i.asset&&(p.asset={...i.asset},m.asset={...i.asset}),i.asset&&(i.asset.type==="video"||i.asset.type==="audio")){const u=i.asset.trim||0;p.asset&&(p.asset.type==="video"||p.asset.type==="audio")&&(p.asset.trim=u),m.asset&&(m.asset.type==="video"||m.asset.type==="audio")&&(m.asset.trim=u+a)}if(Object.assign(t.clipConfiguration,p),t.reconfigureAfterRestore(),t.draw(),this.rightClipPlayer=e.createPlayerFromAssetType(m),!this.rightClipPlayer)throw Object.assign(t.clipConfiguration,this.originalClipConfig),t.reconfigureAfterRestore(),new Error("Failed to create right clip player");this.rightClipPlayer.layer=this.trackIndex+1;const d=e.getTrack(this.trackIndex);if(!d)throw new Error("Invalid track index");d.splice(this.clipIndex+1,0,this.rightClipPlayer);const l=e.getClips(),c=l.indexOf(t);c!==-1&&l.splice(c+1,0,this.rightClipPlayer),e.addPlayerToContainer(this.trackIndex,this.rightClipPlayer),this.rightClipPlayer.reconfigureAfterRestore(),this.rightClipPlayer.load().then(()=>{this.splitSuccessful=!0,this.rightClipPlayer&&this.rightClipPlayer.draw(),e.updateDuration(),e.emitEvent("timeline:updated",{current:e.getEditState()})}).catch(u=>{console.error("Failed to load split clip:",u)})}undo(e){if(!this.originalClipConfig)return;const t=e.getClipAt(this.trackIndex,this.clipIndex);if(t){if(Object.assign(t.clipConfiguration,this.originalClipConfig),t.reconfigureAfterRestore(),this.rightClipPlayer){const i=e.getTrack(this.trackIndex);if(i){const o=i.indexOf(this.rightClipPlayer);o!==-1&&i.splice(o,1)}const r=e.getClips(),n=r.indexOf(this.rightClipPlayer);n!==-1&&r.splice(n,1),e.queueDisposeClip(this.rightClipPlayer),this.rightClipPlayer=null}e.updateDuration(),e.emitEvent("timeline:updated",{current:e.getEditState()})}}}class Xo{constructor(e,t,i){this.clip=e,this.newText=t,this.initialConfig=i;const{asset:r}=this.clip.clipConfiguration;this.previousText=r&&"text"in r?r.text:""}name="updateTextContent";previousText;execute(e){if(e&&this.clip.clipConfiguration.asset&&"text"in this.clip.clipConfiguration.asset){this.clip.clipConfiguration.asset.text=this.newText;const t=this.clip.text;t&&(t.text=this.newText,this.clip.positionText(this.clip.clipConfiguration.asset)),e.setUpdatedClip(this.clip);const i=this.clip.layer-1,o=e.getClips().filter(a=>a.layer===this.clip.layer).indexOf(this.clip);e.emitEvent("clip:updated",{previous:{clip:this.initialConfig,trackIndex:i,clipIndex:o},current:{clip:this.clip.clipConfiguration,trackIndex:i,clipIndex:o}})}}undo(e){if(e&&this.clip.clipConfiguration.asset&&"text"in this.clip.clipConfiguration.asset){this.clip.clipConfiguration.asset.text=this.previousText;const t=this.clip.text;t&&(t.text=this.previousText,this.clip.positionText(this.clip.clipConfiguration.asset)),e.setUpdatedClip(this.clip);const i=this.clip.layer-1,o=e.getClips().filter(a=>a.layer===this.clip.layer).indexOf(this.clip);e.emitEvent("clip:updated",{previous:{clip:this.clip.clipConfiguration,trackIndex:i,clipIndex:o},current:{clip:this.initialConfig,trackIndex:i,clipIndex:o}})}}}class Kt{events;constructor(){this.events={}}on(e,t){this.events[e]||(this.events[e]=new Set),this.events[e].add(t)}off(e,t){this.events[e]&&(this.events[e].delete(t),!(this.events[e].size>0)&&delete this.events[e])}clear(e){delete this.events[e]}emit(e,t){if(this.events[e])for(const i of this.events[e])i(t)}}class Yo extends Kt{registry;constructor(){super(),this.registry={}}}class bi{static VIDEO_EXTENSIONS=[".mp4",".m4v",".webm",".ogg",".ogv"];static VIDEO_MIME={".mp4":"video/mp4",".m4v":"video/mp4",".webm":"video/webm",".ogg":"video/ogg",".ogv":"video/ogg"};loadTracker=new Yo;async load(e,t){this.updateAssetLoadMetadata(e,"pending",0);try{if(await this.shouldUseSafariVideoLoader(t))return await this.loadVideoForSafari(e,t);const i=await R.Assets.load(t,r=>{this.updateAssetLoadMetadata(e,"loading",r)});return this.updateAssetLoadMetadata(e,"success",1),i}catch{return this.updateAssetLoadMetadata(e,"failed",1),null}}getProgress(){const e=Object.keys(this.loadTracker.registry);return e.length===0?0:e.reduce((i,r)=>i+this.loadTracker.registry[r].progress,0)/e.length}extractUrl(e){if(typeof e=="string")return e;const t=Array.isArray(e.src)?e.src[0]:e.src;return typeof t=="string"?t:t?.src}hasVideoExtension(e){const t=new URL(e,window.location.origin).pathname.toLowerCase();return bi.VIDEO_EXTENSIONS.some(i=>t.endsWith(i))}async getContentType(e){try{return(await fetch(e,{method:"HEAD"})).headers.get("content-type")}catch{return null}}canPlayVideo(e){const t=new URL(e,window.location.origin).pathname.toLowerCase(),i=t.slice(t.lastIndexOf(".")),r=bi.VIDEO_MIME[i];return r?document.createElement("video").canPlayType(r)!=="":!1}async isPlayableVideo(e){if(this.hasVideoExtension(e))return this.canPlayVideo(e);const t=await this.getContentType(e);return t?.startsWith("video/")?document.createElement("video").canPlayType(t)!=="":!1}async shouldUseSafariVideoLoader(e){const t=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),i=this.extractUrl(e);return t&&i!==void 0&&await this.isPlayableVideo(i)}async loadVideoForSafari(e,t){const i=this.extractUrl(t),r=typeof t=="object"?t.data??{}:{},n=await new Promise((o,a)=>{const p=document.createElement("video");p.crossOrigin="anonymous",p.playsInline=!0,p.muted=!0,p.preload="metadata",p.addEventListener("loadedmetadata",()=>{try{const m=new R.VideoSource({resource:p,autoPlay:r.autoPlay??!1,...r});o(new R.Texture({source:m}))}catch(m){a(m)}},{once:!0}),p.addEventListener("error",()=>a(new Error("Video loading failed")),{once:!0}),this.updateAssetLoadMetadata(e,"loading",.5),p.src=i});return this.updateAssetLoadMetadata(e,"success",1),n}updateAssetLoadMetadata(e,t,i){this.loadTracker.registry[e]?(this.loadTracker.registry[e].progress=i,this.loadTracker.registry[e].status=t):this.loadTracker.registry[e]={progress:i,status:t};const r={...this.loadTracker.registry};this.loadTracker.emit("onAssetLoadInfoUpdated",{registry:r})}}class qt{static Name="FontLoadParser";id;name;extension;validFontExtensions;woff2Decompressor;constructor(){this.id=qt.Name,this.name=qt.Name,this.extension={type:[R.ExtensionType.LoadParser],priority:R.LoaderParserPriority.High,ref:null},this.validFontExtensions=["ttf","otf","woff","woff2"],this.woff2Decompressor=null}test(e){const t=e.split("?")[0]?.split(".").pop()?.toLowerCase()??"";return this.validFontExtensions.includes(t)}async load(e,t,i){const r=e.split("?")[0]?.split(".").pop()?.toLowerCase()??"",n=await fetch(e).then(c=>c.arrayBuffer());if(r!=="woff2"){const c=Rs.parse(new Uint8Array(n).buffer),u=c.names.fontFamily.en||c.names.fontFamily[Object.keys(c.names.fontFamily)[0]],h=new FontFace(u,`url(${e})`);return await h.load(),document.fonts.add(h),h}if(await this.loadWoff2Decompressor(),!this.woff2Decompressor)throw new Error("Cannot initialize Woff2 decompressor.");const o=this.woff2Decompressor.decompress(n),a=Rs.parse(new Uint8Array(o).buffer),p=a.names.fontFamily.en||a.names.fontFamily[Object.keys(a.names.fontFamily)[0]],m=new Blob([o],{type:"font/ttf"}),d=URL.createObjectURL(m),l=new FontFace(p,`url(${d})`);return await l.load(),document.fonts.add(l),l}async loadWoff2Decompressor(){if(this.woff2Decompressor)return;const t=`${await fetch("https://unpkg.com/wawoff2@2.0.1/build/decompress_binding.js").then(i=>i.text())}; return Module`;this.woff2Decompressor=new Function(t)(),await new Promise(i=>{this.woff2Decompressor.onRuntimeInitialized=i})}unload(e){e&&document.fonts.delete(e)}}const Er=te({clips:rs.array()}),Ar=pe().url("Invalid image url format."),Ir=te({src:Ar}),Pr=te({background:pe().optional(),fonts:Ir.array().optional(),tracks:Er.array()}),Rr=te({size:te({width:D().positive(),height:D().positive()}),fps:D().positive().optional(),format:pe()}),Or=te({timeline:Pr,output:Rr});class Ot extends Je{static ZIndexPadding=100;assetLoader;events;edit;tracks;clipsToDispose;clips;commandHistory=[];commandIndex=-1;playbackTime;size;backgroundColor;totalDuration;isPlaying;selectedClip;updatedClip;viewportMask;isExporting=!1;constructor(e,t="#ffffff"){super(),this.assetLoader=new bi,this.edit=null,this.tracks=[],this.clipsToDispose=[],this.clips=[],this.events=new Kt,this.size=e,this.playbackTime=0,this.totalDuration=0,this.isPlaying=!1,this.selectedClip=null,this.updatedClip=null,this.backgroundColor=t,this.setupIntentListeners()}async load(){const e=new R.Graphics;e.fillStyle={color:this.backgroundColor},e.rect(0,0,this.size.width,this.size.height),e.fill(),this.getContainer().addChild(e),this.viewportMask=new R.Graphics,this.viewportMask.rect(0,0,this.size.width,this.size.height),this.viewportMask.fill(16777215),this.getContainer().addChild(this.viewportMask),this.getContainer().setMask({mask:this.viewportMask})}update(e,t){for(const i of this.clips)i.shouldDispose&&this.queueDisposeClip(i),i.update(e,t);this.disposeClips(),this.isPlaying&&(this.playbackTime=Math.max(0,Math.min(this.playbackTime+t,this.totalDuration)),this.playbackTime===this.totalDuration&&this.pause())}draw(){for(const e of this.clips)e.draw()}dispose(){if(this.clearClips(),this.viewportMask){try{this.getContainer().setMask(null)}catch{}this.viewportMask.destroy(),this.viewportMask=void 0}}play(){this.isPlaying=!0,this.events.emit("playback:play",{})}pause(){this.isPlaying=!1,this.events.emit("playback:pause",{})}seek(e){this.playbackTime=Math.max(0,Math.min(e,this.totalDuration)),this.pause()}stop(){this.seek(0)}async loadEdit(e){this.clearClips(),this.edit=Or.parse(e),this.backgroundColor=this.edit.timeline.background||"#000000",await Promise.all((this.edit.timeline.fonts??[]).map(async t=>{const i=t.src,r={src:i,loadParser:qt.Name};return this.assetLoader.load(i,r)}));for(const[t,i]of this.edit.timeline.tracks.entries())for(const r of i.clips){const n=this.createPlayerFromAssetType(r);n.layer=t+1,await this.addPlayer(t,n)}this.updateTotalDuration()}getEdit(){const e=this.tracks.map((t,i)=>({clips:t.filter(n=>n&&!this.clipsToDispose.includes(n)).map(n=>n.clipConfiguration)}));return{timeline:{background:this.backgroundColor,tracks:e,fonts:this.edit?.timeline.fonts||[]},output:this.edit?.output||{size:this.size,format:"mp4"}}}addClip(e,t){const i=new jo(e,t);this.executeCommand(i)}getClip(e,t){const i=this.clips.filter(r=>r.layer===e+1);return t<0||t>=i.length?null:i[t].clipConfiguration}getPlayerClip(e,t){const i=this.clips.filter(r=>r.layer===e+1);return t<0||t>=i.length?null:i[t]}deleteClip(e,t){const i=new Wo(e,t);this.executeCommand(i)}splitClip(e,t,i){const r=new qo(e,t,i);this.executeCommand(r)}addTrack(e,t){const i=new Sr(e);this.executeCommand(i),t?.clips?.forEach(r=>this.addClip(e,r))}getTrack(e){const t=this.clips.filter(i=>i.layer===e+1);return t.length===0?null:{clips:t.map(i=>i.clipConfiguration)}}deleteTrack(e){const t=new Go(e);this.executeCommand(t)}getTotalDuration(){return this.totalDuration}undo(){if(this.commandIndex>=0){const e=this.commandHistory[this.commandIndex];if(e.undo){const t=this.createCommandContext();e.undo(t),this.commandIndex-=1,this.events.emit("edit:undo",{command:e.name})}}}redo(){if(this.commandIndex<this.commandHistory.length-1){this.commandIndex+=1;const e=this.commandHistory[this.commandIndex],t=this.createCommandContext();e.execute(t),this.events.emit("edit:redo",{command:e.name})}}setUpdatedClip(e,t=null,i=null){const r=new Ko(e,t,i);this.executeCommand(r)}updateTextContent(e,t,i){const r=new Xo(e,t,i);this.executeCommand(r)}executeEditCommand(e){return this.executeCommand(e)}executeCommand(e){const t=this.createCommandContext(),i=e.execute(t);return this.commandHistory=this.commandHistory.slice(0,this.commandIndex+1),this.commandHistory.push(e),this.commandIndex+=1,i}createCommandContext(){return{getClips:()=>this.clips,getTracks:()=>this.tracks,getTrack:e=>e>=0&&e<this.tracks.length?this.tracks[e]:null,getContainer:()=>this.getContainer(),addPlayer:(e,t)=>this.addPlayer(e,t),addPlayerToContainer:(e,t)=>{this.addPlayerToContainer(e,t)},createPlayerFromAssetType:e=>this.createPlayerFromAssetType(e),queueDisposeClip:e=>this.queueDisposeClip(e),disposeClips:()=>this.disposeClips(),undeleteClip:(e,t)=>{this.clips.push(t),this.updateTotalDuration()},setUpdatedClip:e=>{this.updatedClip=e},restoreClipConfiguration:(e,t)=>{Object.assign(e.clipConfiguration,structuredClone(t)),e.reconfigureAfterRestore(),e.draw()},updateDuration:()=>this.updateTotalDuration(),emitEvent:(e,t)=>this.events.emit(e,t),findClipIndices:e=>this.findClipIndices(e),getClipAt:(e,t)=>this.getClipAt(e,t),getSelectedClip:()=>this.selectedClip,setSelectedClip:e=>{this.selectedClip=e},movePlayerToTrackContainer:(e,t,i)=>this.movePlayerToTrackContainer(e,t,i),getEditState:()=>this.getEdit()}}queueDisposeClip(e){this.clipsToDispose.push(e)}disposeClips(){if(this.clipsToDispose.length!==0){for(const e of this.clipsToDispose)this.disposeClip(e);this.clips=this.clips.filter(e=>!this.clipsToDispose.includes(e)),this.clipsToDispose=[],this.updateTotalDuration()}}disposeClip(e){try{if(this.getContainer().children.includes(e.getContainer())){const t=this.getContainer().getChildIndex(e.getContainer());this.getContainer().removeChildAt(t)}else for(const t of this.getContainer().children)if(t instanceof R.Container&&t.label?.toString().startsWith("shotstack-track-")&&t.children.includes(e.getContainer())){t.removeChild(e.getContainer());break}}catch(t){console.warn(`Attempting to unmount an unmounted clip: ${t}`)}this.unloadClipAssets(e),e.dispose()}unloadClipAssets(e){const{asset:t}=e.clipConfiguration;if(t&&"src"in t&&typeof t.src=="string")try{R.Assets.unload(t.src)}catch(i){console.warn(`Failed to unload asset: ${t.src}`,i)}}clearClips(){for(const e of this.clips)this.disposeClip(e);this.clips=[],this.clipsToDispose=[],this.updateTotalDuration()}updateTotalDuration(){let e=0;for(const i of this.tracks)for(const r of i)e=Math.max(e,r.getEnd());const t=this.totalDuration;this.totalDuration=e,t!==this.totalDuration&&this.events.emit("duration:changed",{duration:this.totalDuration})}addPlayerToContainer(e,t){const i=1e5-(e+1)*Ot.ZIndexPadding,r=`shotstack-track-${i}`;let n=this.getContainer().getChildByLabel(r,!1);n||(n=new R.Container({label:r,zIndex:i}),this.getContainer().addChild(n)),n.addChild(t.getContainer())}movePlayerToTrackContainer(e,t,i){if(t===i)return;const r=1e5-(t+1)*Ot.ZIndexPadding,n=1e5-(i+1)*Ot.ZIndexPadding,o=`shotstack-track-${r}`,a=`shotstack-track-${n}`,p=this.getContainer().getChildByLabel(o,!1);let m=this.getContainer().getChildByLabel(a,!1);m||(m=new R.Container({label:a,zIndex:n}),this.getContainer().addChild(m)),p&&p.removeChild(e.getContainer()),m.addChild(e.getContainer())}createPlayerFromAssetType(e){if(!e.asset?.type)throw new Error("Invalid clip configuration: missing asset type");let t;switch(e.asset.type){case"text":{t=new Io(this,e);break}case"rich-text":{t=new Eo(this,e);break}case"shape":{t=new Ao(this,e);break}case"html":{t=new ea(this,e);break}case"image":{t=new ta(this,e);break}case"video":{t=new Po(this,e);break}case"audio":{t=new Os(this,e);break}case"luma":{t=new Fs(this,e);break}default:throw new Error(`Unsupported clip type: ${e.asset.type}`)}return t}async addPlayer(e,t){for(;this.tracks.length<=e;)this.tracks.push([]);this.tracks[e].push(t),this.clips.push(t);const i=1e5-(e+1)*Ot.ZIndexPadding,r=`shotstack-track-${i}`;let n=this.getContainer().getChildByLabel(r,!1);n||(n=new R.Container({label:r,zIndex:i}),this.getContainer().addChild(n)),n.addChild(t.getContainer());const o=t instanceof Fs;await t.load(),o&&n.setMask({mask:t.getMask(),inverse:!0}),this.updateTotalDuration()}selectClip(e,t){const i=new Zo(e,t);this.executeCommand(i)}clearSelection(){const e=new Vo;this.executeCommand(e)}isClipSelected(e,t){if(!this.selectedClip)return!1;const i=this.selectedClip.layer-1,r=this.tracks[i].indexOf(this.selectedClip);return e===i&&t===r}getSelectedClipInfo(){if(!this.selectedClip)return null;const e=this.selectedClip.layer-1,t=this.tracks[e].indexOf(this.selectedClip);return{trackIndex:e,clipIndex:t,player:this.selectedClip}}findClipIndices(e){for(let t=0;t<this.tracks.length;t+=1){const i=this.tracks[t].indexOf(e);if(i!==-1)return{trackIndex:t,clipIndex:i}}return null}getClipAt(e,t){return e>=0&&e<this.tracks.length&&t>=0&&t<this.tracks[e].length?this.tracks[e][t]:null}selectPlayer(e){const t=this.findClipIndices(e);t&&this.selectClip(t.trackIndex,t.clipIndex)}isPlayerSelected(e){return this.isExporting?!1:this.selectedClip===e}setExportMode(e){this.isExporting=e}isInExportMode(){return this.isExporting}setupIntentListeners(){this.events.on("timeline:clip:clicked",e=>{e.player?this.selectPlayer(e.player):this.selectClip(e.trackIndex,e.clipIndex)}),this.events.on("timeline:background:clicked",()=>{this.clearSelection()}),this.events.on("canvas:clip:clicked",e=>{this.selectPlayer(e.player)}),this.events.on("canvas:background:clicked",()=>{this.clearSelection()})}}class Xt extends Je{static Width=250;static Height=100;fps;playbackTime;playbackDuration;isPlaying;background;text;constructor(){super(),this.background=null,this.text=null,this.fps=0,this.playbackTime=0,this.playbackDuration=0,this.isPlaying=!1}async load(){const e=new R.Graphics;e.fillStyle={color:"#424242",alpha:.5},e.rect(0,0,Xt.Width,Xt.Height),e.fill(),this.getContainer().addChild(e),this.background=e;const t=new R.Text;t.text="",t.style={fontFamily:"monospace",fontSize:14,fill:"#ffffff",wordWrap:!0,wordWrapWidth:Xt.Width},this.getContainer().addChild(t),this.text=t}update(e,t){if(!this.text)return;const i=this.getMemoryInfo(),r=[`FPS: ${this.fps}`,`Playback: ${(this.playbackTime/1e3).toFixed(2)}/${(this.playbackDuration/1e3).toFixed(2)}`,`Playing: ${this.isPlaying}`,`Total Heap Size: ${i.totalHeapSize?`${this.bytesToMegabytes(i.totalHeapSize)}MB`:"N/A"}`,`Used Heap Size: ${i.usedHeapSize?`${this.bytesToMegabytes(i.usedHeapSize)}MB`:"N/A"}`,`Heap Size Limit: ${i.heapSizeLimit?`${this.bytesToMegabytes(i.heapSizeLimit)}MB`:"N/A"}`];this.text.text=r.join(`
187
- `)}draw(){}dispose(){this.background?.destroy(),this.background=null,this.text?.destroy(),this.text=null}getMemoryInfo(){const e={};return"memory"in performance&&(e.totalHeapSize=performance.memory.totalJSHeapSize,e.usedHeapSize=performance.memory.usedJSHeapSize,e.heapSizeLimit=performance.memory.jsHeapSizeLimit),e}bytesToMegabytes(e){return Math.round(e/1024/1024)}}class yt{static CanvasSelector="[data-shotstack-studio]";static extensionsRegistered=!1;size;application;edit;inspector;container;background;timeline;minZoom=.1;maxZoom=4;currentZoom=.8;onTickBound;constructor(e,t){this.size=e,this.application=new R.Application,this.edit=t,this.inspector=new Xt,this.onTickBound=this.onTick.bind(this)}async load(){const e=document.querySelector(yt.CanvasSelector);if(!e)throw new Error(`Shotstack canvas root element '${yt.CanvasSelector}' not found.`);this.registerExtensions(),this.container=new R.Container,this.background=new R.Graphics,this.background.fillStyle={color:"#424242"},this.background.rect(0,0,this.size.width,this.size.height),this.background.fill(),await this.configureApplication(),this.configureStage(),this.setupTouchHandling(e),this.edit.getContainer().scale=this.currentZoom,e.appendChild(this.application.canvas)}setupTouchHandling(e){const t=this.edit.getContainer();e.addEventListener("wheel",i=>{if(i.preventDefault(),i.stopPropagation(),i.ctrlKey){const r=Math.exp(-i.deltaY/100),n=this.currentZoom*r,o=this.currentZoom;this.currentZoom=Math.min(Math.max(n,this.minZoom),this.maxZoom);const a={x:this.application.canvas.width/2,y:this.application.canvas.height/2},p={x:t.position.x-a.x,y:t.position.y-a.y},m=this.currentZoom/o;t.position.x=a.x+p.x*m,t.position.y=a.y+p.y*m,t.scale.x=this.currentZoom,t.scale.y=this.currentZoom}},{passive:!1,capture:!0})}centerEdit(){if(!this.edit)return;const e=this.edit.getContainer();e.position={x:this.application.canvas.width/2-this.edit.size.width*this.currentZoom/2,y:this.application.canvas.height/2-this.edit.size.height*this.currentZoom/2}}zoomToFit(){if(!this.edit)return;const e=this.application.canvas.width/this.edit.size.width,t=this.application.canvas.height/this.edit.size.height,i=Math.min(e,t);this.currentZoom=Math.min(Math.max(i,this.minZoom),this.maxZoom);const r=this.edit.getContainer();r.scale.x=this.currentZoom,r.scale.y=this.currentZoom,this.centerEdit()}setZoom(e){this.currentZoom=Math.min(Math.max(e,this.minZoom),this.maxZoom);const t=this.edit.getContainer();t.scale.x=this.currentZoom,t.scale.y=this.currentZoom}registerTimeline(e){this.timeline=e}registerExtensions(){yt.extensionsRegistered||(R.extensions.add(new zt),R.extensions.add(new qt),yt.extensionsRegistered=!0)}async configureApplication(){const e={background:"#000000",width:this.size.width,height:this.size.height,antialias:!0};await this.application.init(e),this.application.ticker.add(this.onTickBound),this.application.ticker.minFPS=60,this.application.ticker.maxFPS=60}onTick(e){this.edit.update(e.deltaTime,e.deltaMS),this.edit.draw(),this.inspector.fps=Math.ceil(e.FPS),this.inspector.playbackTime=this.edit.playbackTime,this.inspector.playbackDuration=this.edit.totalDuration,this.inspector.isPlaying=this.edit.isPlaying,this.inspector.update(e.deltaTime,e.deltaMS),this.inspector.draw(),this.timeline&&(this.timeline.update(e.deltaTime,e.deltaMS),this.timeline.draw())}configureStage(){if(!this.container||!this.background)throw new Error("Shotstack canvas container not set up.");this.container.addChild(this.background),this.container.addChild(this.edit.getContainer()),this.container.addChild(this.inspector.getContainer()),this.application.stage.addChild(this.container),this.application.stage.eventMode="static",this.application.stage.hitArea=new R.Rectangle(0,0,this.size.width,this.size.height),this.background.eventMode="static",this.background.on("pointerdown",this.onBackgroundClick.bind(this)),this.application.stage.on("click",this.onClick.bind(this)),this.edit.getContainer().position={x:this.application.canvas.width/2-this.edit.size.width*this.currentZoom/2,y:this.application.canvas.height/2-this.edit.size.height*this.currentZoom/2}}onClick(){this.edit.pause()}onBackgroundClick(e){e.target===this.background&&this.edit.events.emit("canvas:background:clicked",{})}pauseTicker(){this.application.ticker.remove(this.onTickBound)}resumeTicker(){this.application.ticker.add(this.onTickBound)}dispose(){const e=document.querySelector(yt.CanvasSelector);e&&e.contains(this.application.canvas)&&e.removeChild(this.application.canvas),this.application.ticker.remove(this.onTickBound),this.application.stage.off("click",this.onClick,this),this.background?.off("pointerdown",this.onBackgroundClick,this),this.background?.destroy(),this.container?.destroy(),this.inspector.dispose(),this.application.destroy(!0,{children:!0,texture:!0})}}class Qo{edit;seekDistance=50;seekDistanceLarge=500;frameTime=16.67;constructor(e){this.edit=e}async load(){document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}dispose(){document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)}handleKeyDown=e=>{if(!(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement))switch(e.code){case"Space":{this.edit.isPlaying?this.edit.pause():this.edit.play();break}case"ArrowLeft":{if(e.metaKey)this.edit.seek(0);else{const t=e.shiftKey?this.seekDistanceLarge:this.seekDistance;this.edit.seek(this.edit.playbackTime-t)}break}case"ArrowRight":{if(e.metaKey)this.edit.seek(this.edit.getTotalDuration());else{const t=e.shiftKey?this.seekDistanceLarge:this.seekDistance;this.edit.seek(this.edit.playbackTime+t)}break}case"KeyJ":{this.edit.stop();break}case"KeyK":{this.edit.pause();break}case"KeyL":{this.edit.play();break}case"Comma":{this.edit.seek(this.edit.playbackTime-this.frameTime);break}case"Period":{this.edit.seek(this.edit.playbackTime+this.frameTime);break}case"KeyZ":{(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.shiftKey?this.edit.redo():this.edit.undo());break}case"Delete":case"Backspace":{const t=this.edit.getSelectedClipInfo();t&&(e.preventDefault(),this.edit.deleteClip(t.trackIndex,t.clipIndex));break}}};handleKeyUp=e=>{if(!(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement))switch(e.code){case"KeyI":console.log(this.edit.getEdit());break}}}class Jo{name="export";clips=[];tracks=[];execute(e){this.clips=e.getClips(),this.tracks=e.getTracks()}getClips(){return this.clips}getTracks(){return this.tracks}}/*!
182
+ const DOUBLE_PI: f32 = 3.14159265358979323846264 * 2.;`,wh=Object.defineProperty,xh=(s,e,t)=>e in s?wh(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,qr=(s,e,t)=>(xh(s,typeof e!="symbol"?e+"":e,t),t);const Ls=class fi extends Vt.Filter{constructor(...e){let t=e[0]??{};typeof t=="number"&&(Vt.deprecation("6.0.0","OutlineFilter constructor params are now options object. See params: { thickness, color, quality, alpha, knockout }"),t={thickness:t},e[1]!==void 0&&(t.color=e[1]),e[2]!==void 0&&(t.quality=e[2]),e[3]!==void 0&&(t.alpha=e[3]),e[4]!==void 0&&(t.knockout=e[4])),t={...fi.DEFAULT_OPTIONS,...t};const r=t.quality??.1,i=Vt.GpuProgram.from({vertex:{source:yh,entryPoint:"mainVertex"},fragment:{source:vh,entryPoint:"mainFragment"}}),n=Vt.GlProgram.from({vertex:gh,fragment:bh.replace(/\$\{ANGLE_STEP\}/,fi.getAngleStep(r).toFixed(7)),name:"outline-filter"});super({gpuProgram:i,glProgram:n,resources:{outlineUniforms:{uThickness:{value:new Float32Array(2),type:"vec2<f32>"},uColor:{value:new Float32Array(3),type:"vec3<f32>"},uAlpha:{value:t.alpha,type:"f32"},uAngleStep:{value:0,type:"f32"},uKnockout:{value:t.knockout?1:0,type:"f32"}}}}),qr(this,"uniforms"),qr(this,"_thickness"),qr(this,"_quality"),qr(this,"_color"),this.uniforms=this.resources.outlineUniforms.uniforms,this.uniforms.uAngleStep=fi.getAngleStep(r),this._color=new Vt.Color,this.color=t.color??0,Object.assign(this,t)}apply(e,t,r,i){this.uniforms.uThickness[0]=this.thickness/t.source.width,this.uniforms.uThickness[1]=this.thickness/t.source.height,e.applyFilter(this,t,r,i)}static getAngleStep(e){return parseFloat((Math.PI*2/Math.max(e*fi.MAX_SAMPLES,fi.MIN_SAMPLES)).toFixed(7))}get thickness(){return this._thickness}set thickness(e){this._thickness=this.padding=e}get color(){return this._color.value}set color(e){this._color.setValue(e);const[t,r,i]=this._color.toArray();this.uniforms.uColor[0]=t,this.uniforms.uColor[1]=r,this.uniforms.uColor[2]=i}get alpha(){return this.uniforms.uAlpha}set alpha(e){this.uniforms.uAlpha=e}get quality(){return this._quality}set quality(e){this._quality=e,this.uniforms.uAngleStep=fi.getAngleStep(e)}get knockout(){return this.uniforms.uKnockout===1}set knockout(e){this.uniforms.uKnockout=e?1:0}};qr(Ls,"DEFAULT_OPTIONS",{thickness:1,color:0,alpha:1,quality:.1,knockout:!1}),qr(Ls,"MIN_SAMPLES",1),qr(Ls,"MAX_SAMPLES",100);let ta=Ls;class Ch extends ut{background;text;constructor(e,t){super(e,t),this.background=null,this.text=null}async load(){await super.load();const e=this.clipConfiguration.asset,t=await this.parseDocument();if(!t)return;const r=new U.Graphics;t.background.color&&(r.fillStyle={color:t.background.color,alpha:t.background.opacity??1},r.rect(0,0,e.width??this.edit.size.width,e.height??this.edit.size.height),r.fill());const i=new U.Text;i.text=t.text;const{horizontal:n,vertical:a}=t.alignment;i.style={fontFamily:t.font?.family??"Open Sans",fontSize:t.font?.size??32,fill:t.font?.color??"#ffffff",fontWeight:(t.font?.weight??"400").toString(),wordWrap:!0,wordWrapWidth:e.width??this.edit.size.width,lineHeight:(t.font?.lineHeight??1)*(t.font?.size??32),align:n};let o=(e.width??this.edit.size.width)/2-i.width/2,c=(e.height??this.edit.size.height)/2-i.height/2;if(n==="left"&&(o=0),n==="right"&&(o=(e.width??this.edit.size.width)-i.width),a==="top"&&(c=0),a==="bottom"&&(c=(e.height??this.edit.size.height)-i.height),i.position={x:o,y:c},t.stroke.color&&t.stroke.width){const u=new ta({thickness:t.stroke.width,color:t.stroke.color});i.filters=[u]}this.background=r,this.text=i,this.contentContainer.addChild(r),this.contentContainer.addChild(i),this.configureKeyframes()}update(e,t){super.update(e,t)}draw(){super.draw()}dispose(){super.dispose(),this.background?.destroy(),this.background=null,this.text?.destroy(),this.text=null}getSize(){const e=this.clipConfiguration.asset;return{width:e.width??this.edit.size.width,height:e.height??this.edit.size.height}}getFitScale(){return 1}async parseDocument(){const e=this.clipConfiguration.asset,{html:t,css:r,position:i}=e;if(!t.includes('data-html-type="text"'))return console.warn("Unsupported html format."),null;const a=new DOMParser().parseFromString(t,"text/html").body.textContent??"",c=(await new CSSStyleSheet().replace(r)).cssRules[0],u={text:a,font:{},alignment:{},background:{},stroke:{}};if(c?.constructor.name!=="CSSStyleRule"||!("style"in c))return console.warn("Unsupported css format."),u;const h=c.style,l=this.parseAlignment(i??"center");u.font={color:h.color.length?h.color:void 0,family:h.fontFamily.length?h.fontFamily:void 0,size:h.fontSize.length?parseInt(h.fontSize,10):void 0,weight:h.fontWeight.length?parseInt(h.fontWeight,10):void 0,lineHeight:h.lineHeight.length?parseInt(h.lineHeight,10):void 0},u.alignment=l;let d="";return h.background.length&&(d=h.background),h.backgroundColor.length&&(d=h.backgroundColor),u.background={color:d.length?d:void 0,opacity:h.opacity.length?parseInt(h.opacity,10):void 0},u.stroke={width:h.strokeWidth.length?parseInt(h.strokeWidth,10):void 0,color:h.stroke.length?h.stroke:void 0},u}parseAlignment(e){switch(e){case"topLeft":return{horizontal:"left",vertical:"top"};case"top":return{horizontal:"center",vertical:"top"};case"topRight":return{horizontal:"right",vertical:"top"};case"left":return{horizontal:"left",vertical:"center"};case"right":return{horizontal:"right",vertical:"center"};case"bottomLeft":return{horizontal:"left",vertical:"bottom"};case"bottom":return{horizontal:"center",vertical:"bottom"};case"bottomRight":return{horizontal:"right",vertical:"bottom"};case"center":default:return{horizontal:"center",vertical:"center"}}}}class kh extends ut{texture;sprite;originalSize;constructor(e,t){super(e,t),this.texture=null,this.sprite=null,this.originalSize=null}async load(){await super.load();const e=this.clipConfiguration.asset,t=e.src,r={src:t,crossovern:"anonymous",data:{}},i=await this.edit.assetLoader.load(t,r);if(!(i?.source instanceof U.ImageSource))throw new Error(`Invalid image source '${e.src}'.`);this.texture=this.createCroppedTexture(i),this.sprite=new U.Sprite(this.texture),this.contentContainer.addChild(this.sprite),this.clipConfiguration.width&&this.clipConfiguration.height&&this.applyFixedDimensions(),this.configureKeyframes()}update(e,t){super.update(e,t)}draw(){super.draw()}dispose(){super.dispose(),this.sprite?.destroy(),this.sprite=null,this.texture?.destroy(),this.texture=null,this.originalSize=null}getSize(){return this.clipConfiguration.width&&this.clipConfiguration.height?{width:this.clipConfiguration.width,height:this.clipConfiguration.height}:{width:this.sprite?.width??0,height:this.sprite?.height??0}}createCroppedTexture(e){const t=this.clipConfiguration.asset;if(!t.crop)return e;const r=e.width,i=e.height,n=Math.floor((t.crop?.left??0)*r),a=Math.floor((t.crop?.right??0)*r),o=Math.floor((t.crop?.top??0)*i),c=Math.floor((t.crop?.bottom??0)*i),u=n,h=o,l=r-n-a,d=i-o-c,f=new U.Rectangle(u,h,l,d);return new U.Texture({source:e.source,frame:f})}}class Yo extends ut{texture;sprite;isPlaying;constructor(e,t){super(e,t),this.texture=null,this.sprite=null,this.isPlaying=!1}async load(){await super.load();const e=this.clipConfiguration.asset,t=e.src,r={src:t,data:{autoPlay:!1,muted:!0}},i=await this.edit.assetLoader.load(t,r);if(!(i?.source instanceof U.ImageSource||i?.source instanceof U.VideoSource))throw new Error(`Invalid luma source '${e.src}'.`);this.texture=i,this.sprite=new U.Sprite(this.texture),this.contentContainer.addChild(this.sprite),this.configureKeyframes()}update(e,t){if(super.update(e,t),!this.texture||!(this.texture.source instanceof U.VideoSource))return;const r=this.getPlaybackTime(),i=this.edit.isPlaying&&this.isActive();i&&(this.isPlaying||(this.isPlaying=!0,this.texture.source.resource.currentTime=r/1e3,this.texture.source.resource.play().catch(console.error)),this.texture.source.resource.volume!==this.getVolume()&&(this.texture.source.resource.volume=this.getVolume()),Math.abs(this.texture.source.resource.currentTime*1e3-r)>100&&(this.texture.source.resource.currentTime=r/1e3)),!i&&this.isPlaying&&(this.isPlaying=!1,this.texture.source.resource.pause()),!this.edit.isPlaying&&this.isActive()&&(this.texture.source.resource.currentTime=r/1e3)}draw(){super.draw()}dispose(){super.dispose(),this.sprite?.destroy(),this.sprite=null,this.texture?.destroy(),this.texture=null}getSize(){return{width:this.sprite?.width??0,height:this.sprite?.height??0}}getVolume(){return 0}getMask(){return this.sprite}}var $e;(function(s){s.assertEqual=i=>{};function e(i){}s.assertIs=e;function t(i){throw new Error}s.assertNever=t,s.arrayToEnum=i=>{const n={};for(const a of i)n[a]=a;return n},s.getValidEnumValues=i=>{const n=s.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),a={};for(const o of n)a[o]=i[o];return s.objectValues(a)},s.objectValues=i=>s.objectKeys(i).map(function(n){return i[n]}),s.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const n=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&n.push(a);return n},s.find=(i,n)=>{for(const a of i)if(n(a))return a},s.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,n=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(n)}s.joinValues=r,s.jsonStringifyReplacer=(i,n)=>typeof n=="bigint"?n.toString():n})($e||($e={}));var Jo;(function(s){s.mergeShapes=(e,t)=>({...e,...t})})(Jo||(Jo={}));const ce=$e.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Cr=s=>{switch(typeof s){case"undefined":return ce.undefined;case"string":return ce.string;case"number":return Number.isNaN(s)?ce.nan:ce.number;case"boolean":return ce.boolean;case"function":return ce.function;case"bigint":return ce.bigint;case"symbol":return ce.symbol;case"object":return Array.isArray(s)?ce.array:s===null?ce.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?ce.promise:typeof Map<"u"&&s instanceof Map?ce.map:typeof Set<"u"&&s instanceof Set?ce.set:typeof Date<"u"&&s instanceof Date?ce.date:ce.object;default:return ce.unknown}},q=$e.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class dr extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(n){return n.message},r={_errors:[]},i=n=>{for(const a of n.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)r._errors.push(t(a));else{let o=r,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return i(this),r}static assert(e){if(!(e instanceof dr))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,$e.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const i of this.issues)if(i.path.length>0){const n=i.path[0];t[n]=t[n]||[],t[n].push(e(i))}else r.push(e(i));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}dr.create=s=>new dr(s);const ra=(s,e)=>{let t;switch(s.code){case q.invalid_type:s.received===ce.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case q.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,$e.jsonStringifyReplacer)}`;break;case q.unrecognized_keys:t=`Unrecognized key(s) in object: ${$e.joinValues(s.keys,", ")}`;break;case q.invalid_union:t="Invalid input";break;case q.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${$e.joinValues(s.options)}`;break;case q.invalid_enum_value:t=`Invalid enum value. Expected ${$e.joinValues(s.options)}, received '${s.received}'`;break;case q.invalid_arguments:t="Invalid function arguments";break;case q.invalid_return_type:t="Invalid function return type";break;case q.invalid_date:t="Invalid date";break;case q.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:$e.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case q.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="bigint"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case q.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case q.custom:t="Invalid input";break;case q.invalid_intersection_types:t="Intersection results could not be merged";break;case q.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case q.not_finite:t="Number must be finite";break;default:t=e.defaultError,$e.assertNever(s)}return{message:t}};let Sh=ra;function _h(){return Sh}const Th=s=>{const{data:e,path:t,errorMaps:r,issueData:i}=s,n=[...t,...i.path||[]],a={...i,path:n};if(i.message!==void 0)return{...i,path:n,message:i.message};let o="";const c=r.filter(u=>!!u).slice().reverse();for(const u of c)o=u(a,{data:e,defaultError:o}).message;return{...i,path:n,message:o}};function se(s,e){const t=_h(),r=Th({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,t,t===ra?void 0:ra].filter(i=>!!i)});s.common.issues.push(r)}class Et{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const i of t){if(i.status==="aborted")return xe;i.status==="dirty"&&e.dirty(),r.push(i.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const i of t){const n=await i.key,a=await i.value;r.push({key:n,value:a})}return Et.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const i of t){const{key:n,value:a}=i;if(n.status==="aborted"||a.status==="aborted")return xe;n.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),n.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(r[n.value]=a.value)}return{status:e.value,value:r}}}const xe=Object.freeze({status:"aborted"}),Gi=s=>({status:"dirty",value:s}),Ft=s=>({status:"valid",value:s}),Qo=s=>s.status==="aborted",el=s=>s.status==="dirty",pi=s=>s.status==="valid",zs=s=>typeof Promise<"u"&&s instanceof Promise;var pe;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e?.message})(pe||(pe={}));class kr{constructor(e,t,r,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const tl=(s,e)=>{if(pi(e))return{success:!0,data:e.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new dr(s.common.issues);return this._error=t,this._error}}};function Pe(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:i}=s;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(a,o)=>{const{message:c}=s;return a.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??r??o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:c??t??o.defaultError}},description:i}}class ze{get description(){return this._def.description}_getType(e){return Cr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Cr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Et,ctx:{common:e.parent.common,data:e.data,parsedType:Cr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(zs(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){const r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Cr(e)},i=this._parseSync({data:e,path:r.path,parent:r});return tl(r,i)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Cr(e)};if(!this["~standard"].async)try{const r=this._parseSync({data:e,path:[],parent:t});return pi(r)?{value:r.value}:{issues:t.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(r=>pi(r)?{value:r.value}:{issues:t.common.issues})}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Cr(e)},i=this._parse({data:e,path:r.path,parent:r}),n=await(zs(i)?i:Promise.resolve(i));return tl(r,n)}refine(e,t){const r=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,n)=>{const a=e(i),o=()=>n.addIssue({code:q.custom,...r(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((r,i)=>e(r)?!0:(i.addIssue(typeof t=="function"?t(r,i):t),!1))}_refinement(e){return new bi({schema:this,typeName:Ce.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return Tr.create(this,this._def)}nullable(){return vi.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return jt.create(this)}promise(){return Hs.create(this,this._def)}or(e){return Ns.create([this,e],this._def)}and(e){return Us.create(this,e,this._def)}transform(e){return new bi({...Pe(this._def),schema:this,typeName:Ce.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new oa({...Pe(this._def),innerType:this,defaultValue:t,typeName:Ce.ZodDefault})}brand(){return new Zh({typeName:Ce.ZodBranded,type:this,...Pe(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new la({...Pe(this._def),innerType:this,catchValue:t,typeName:Ce.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ca.create(this,e)}readonly(){return ua.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Eh=/^c[^\s-]{8,}$/i,Ah=/^[0-9a-z]+$/,Ih=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ph=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Oh=/^[a-z0-9_-]{21}$/i,Fh=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Rh=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Mh=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+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1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Nh=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Uh=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,rl="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Hh=new RegExp(`^${rl}$`);function il(s){let e="[0-5]\\d";s.precision?e=`${e}\\.\\d{${s.precision}}`:s.precision==null&&(e=`${e}(\\.\\d+)?`);const t=s.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function Vh(s){return new RegExp(`^${il(s)}$`)}function jh(s){let e=`${rl}T${il(s)}`;const t=[];return t.push(s.local?"Z?":"Z"),s.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Wh(s,e){return!!((e==="v4"||!e)&&Bh.test(s)||(e==="v6"||!e)&&zh.test(s))}function Gh(s,e){if(!Fh.test(s))return!1;try{const[t]=s.split(".");if(!t)return!1;const r=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||e&&i.alg!==e)}catch{return!1}}function qh(s,e){return!!((e==="v4"||!e)&&Lh.test(s)||(e==="v6"||!e)&&$h.test(s))}class Sr extends ze{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==ce.string){const n=this._getOrReturnCtx(e);return se(n,{code:q.invalid_type,expected:ce.string,received:n.parsedType}),xe}const r=new Et;let i;for(const n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(i=this._getOrReturnCtx(e,i),se(i,{code:q.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),r.dirty());else if(n.kind==="max")e.data.length>n.value&&(i=this._getOrReturnCtx(e,i),se(i,{code:q.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),r.dirty());else if(n.kind==="length"){const a=e.data.length>n.value,o=e.data.length<n.value;(a||o)&&(i=this._getOrReturnCtx(e,i),a?se(i,{code:q.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):o&&se(i,{code:q.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),r.dirty())}else if(n.kind==="email")Mh.test(e.data)||(i=this._getOrReturnCtx(e,i),se(i,{validation:"email",code:q.invalid_string,message:n.message}),r.dirty());else if(n.kind==="emoji")ia||(ia=new RegExp(Dh,"u")),ia.test(e.data)||(i=this._getOrReturnCtx(e,i),se(i,{validation:"emoji",code:q.invalid_string,message:n.message}),r.dirty());else if(n.kind==="uuid")Ph.test(e.data)||(i=this._getOrReturnCtx(e,i),se(i,{validation:"uuid",code:q.invalid_string,message:n.message}),r.dirty());else if(n.kind==="nanoid")Oh.test(e.data)||(i=this._getOrReturnCtx(e,i),se(i,{validation:"nanoid",code:q.invalid_string,message:n.message}),r.dirty());else if(n.kind==="cuid")Eh.test(e.data)||(i=this._getOrReturnCtx(e,i),se(i,{validation:"cuid",code:q.invalid_string,message:n.message}),r.dirty());else if(n.kind==="cuid2")Ah.test(e.data)||(i=this._getOrReturnCtx(e,i),se(i,{validation:"cuid2",code:q.invalid_string,message:n.message}),r.dirty());else if(n.kind==="ulid")Ih.test(e.data)||(i=this._getOrReturnCtx(e,i),se(i,{validation:"ulid",code:q.invalid_string,message:n.message}),r.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),se(i,{validation:"url",code:q.invalid_string,message:n.message}),r.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),se(i,{validation:"regex",code:q.invalid_string,message:n.message}),r.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(i=this._getOrReturnCtx(e,i),se(i,{code:q.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),r.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(i=this._getOrReturnCtx(e,i),se(i,{code:q.invalid_string,validation:{startsWith:n.value},message:n.message}),r.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(i=this._getOrReturnCtx(e,i),se(i,{code:q.invalid_string,validation:{endsWith:n.value},message:n.message}),r.dirty()):n.kind==="datetime"?jh(n).test(e.data)||(i=this._getOrReturnCtx(e,i),se(i,{code:q.invalid_string,validation:"datetime",message:n.message}),r.dirty()):n.kind==="date"?Hh.test(e.data)||(i=this._getOrReturnCtx(e,i),se(i,{code:q.invalid_string,validation:"date",message:n.message}),r.dirty()):n.kind==="time"?Vh(n).test(e.data)||(i=this._getOrReturnCtx(e,i),se(i,{code:q.invalid_string,validation:"time",message:n.message}),r.dirty()):n.kind==="duration"?Rh.test(e.data)||(i=this._getOrReturnCtx(e,i),se(i,{validation:"duration",code:q.invalid_string,message:n.message}),r.dirty()):n.kind==="ip"?Wh(e.data,n.version)||(i=this._getOrReturnCtx(e,i),se(i,{validation:"ip",code:q.invalid_string,message:n.message}),r.dirty()):n.kind==="jwt"?Gh(e.data,n.alg)||(i=this._getOrReturnCtx(e,i),se(i,{validation:"jwt",code:q.invalid_string,message:n.message}),r.dirty()):n.kind==="cidr"?qh(e.data,n.version)||(i=this._getOrReturnCtx(e,i),se(i,{validation:"cidr",code:q.invalid_string,message:n.message}),r.dirty()):n.kind==="base64"?Nh.test(e.data)||(i=this._getOrReturnCtx(e,i),se(i,{validation:"base64",code:q.invalid_string,message:n.message}),r.dirty()):n.kind==="base64url"?Uh.test(e.data)||(i=this._getOrReturnCtx(e,i),se(i,{validation:"base64url",code:q.invalid_string,message:n.message}),r.dirty()):$e.assertNever(n);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(i=>e.test(i),{validation:t,code:q.invalid_string,...pe.errToObj(r)})}_addCheck(e){return new Sr({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...pe.errToObj(e)})}url(e){return this._addCheck({kind:"url",...pe.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...pe.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...pe.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...pe.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...pe.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...pe.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...pe.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...pe.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...pe.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...pe.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...pe.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...pe.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...pe.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...pe.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...pe.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...pe.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...pe.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...pe.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...pe.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...pe.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...pe.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...pe.errToObj(t)})}nonempty(e){return this.min(1,pe.errToObj(e))}trim(){return new Sr({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Sr({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Sr({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Sr.create=s=>new Sr({checks:[],typeName:Ce.ZodString,coerce:s?.coerce??!1,...Pe(s)});function Xh(s,e){const t=(s.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,i=t>r?t:r,n=Number.parseInt(s.toFixed(i).replace(".","")),a=Number.parseInt(e.toFixed(i).replace(".",""));return n%a/10**i}class mi extends ze{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==ce.number){const n=this._getOrReturnCtx(e);return se(n,{code:q.invalid_type,expected:ce.number,received:n.parsedType}),xe}let r;const i=new Et;for(const n of this._def.checks)n.kind==="int"?$e.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),se(r,{code:q.invalid_type,expected:"integer",received:"float",message:n.message}),i.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(r=this._getOrReturnCtx(e,r),se(r,{code:q.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),i.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(r=this._getOrReturnCtx(e,r),se(r,{code:q.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),i.dirty()):n.kind==="multipleOf"?Xh(e.data,n.value)!==0&&(r=this._getOrReturnCtx(e,r),se(r,{code:q.not_multiple_of,multipleOf:n.value,message:n.message}),i.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),se(r,{code:q.not_finite,message:n.message}),i.dirty()):$e.assertNever(n);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,pe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,pe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,pe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,pe.toString(t))}setLimit(e,t,r,i){return new mi({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:pe.toString(i)}]})}_addCheck(e){return new mi({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:pe.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:pe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:pe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:pe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:pe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:pe.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:pe.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:pe.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:pe.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&$e.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}mi.create=s=>new mi({checks:[],typeName:Ce.ZodNumber,coerce:s?.coerce||!1,...Pe(s)});class qi extends ze{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==ce.bigint)return this._getInvalidInput(e);let r;const i=new Et;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(r=this._getOrReturnCtx(e,r),se(r,{code:q.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),i.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(r=this._getOrReturnCtx(e,r),se(r,{code:q.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),i.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),se(r,{code:q.not_multiple_of,multipleOf:n.value,message:n.message}),i.dirty()):$e.assertNever(n);return{status:i.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return se(t,{code:q.invalid_type,expected:ce.bigint,received:t.parsedType}),xe}gte(e,t){return this.setLimit("min",e,!0,pe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,pe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,pe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,pe.toString(t))}setLimit(e,t,r,i){return new qi({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:pe.toString(i)}]})}_addCheck(e){return new qi({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:pe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:pe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:pe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:pe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:pe.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}qi.create=s=>new qi({checks:[],typeName:Ce.ZodBigInt,coerce:s?.coerce??!1,...Pe(s)});class sa extends ze{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==ce.boolean){const r=this._getOrReturnCtx(e);return se(r,{code:q.invalid_type,expected:ce.boolean,received:r.parsedType}),xe}return Ft(e.data)}}sa.create=s=>new sa({typeName:Ce.ZodBoolean,coerce:s?.coerce||!1,...Pe(s)});class $s extends ze{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==ce.date){const n=this._getOrReturnCtx(e);return se(n,{code:q.invalid_type,expected:ce.date,received:n.parsedType}),xe}if(Number.isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return se(n,{code:q.invalid_date}),xe}const r=new Et;let i;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(i=this._getOrReturnCtx(e,i),se(i,{code:q.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),r.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(i=this._getOrReturnCtx(e,i),se(i,{code:q.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),r.dirty()):$e.assertNever(n);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new $s({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:pe.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:pe.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}$s.create=s=>new $s({checks:[],coerce:s?.coerce||!1,typeName:Ce.ZodDate,...Pe(s)});class sl extends ze{_parse(e){if(this._getType(e)!==ce.symbol){const r=this._getOrReturnCtx(e);return se(r,{code:q.invalid_type,expected:ce.symbol,received:r.parsedType}),xe}return Ft(e.data)}}sl.create=s=>new sl({typeName:Ce.ZodSymbol,...Pe(s)});class nl extends ze{_parse(e){if(this._getType(e)!==ce.undefined){const r=this._getOrReturnCtx(e);return se(r,{code:q.invalid_type,expected:ce.undefined,received:r.parsedType}),xe}return Ft(e.data)}}nl.create=s=>new nl({typeName:Ce.ZodUndefined,...Pe(s)});class al extends ze{_parse(e){if(this._getType(e)!==ce.null){const r=this._getOrReturnCtx(e);return se(r,{code:q.invalid_type,expected:ce.null,received:r.parsedType}),xe}return Ft(e.data)}}al.create=s=>new al({typeName:Ce.ZodNull,...Pe(s)});class ol extends ze{constructor(){super(...arguments),this._any=!0}_parse(e){return Ft(e.data)}}ol.create=s=>new ol({typeName:Ce.ZodAny,...Pe(s)});class ll extends ze{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ft(e.data)}}ll.create=s=>new ll({typeName:Ce.ZodUnknown,...Pe(s)});class _r extends ze{_parse(e){const t=this._getOrReturnCtx(e);return se(t,{code:q.invalid_type,expected:ce.never,received:t.parsedType}),xe}}_r.create=s=>new _r({typeName:Ce.ZodNever,...Pe(s)});class cl extends ze{_parse(e){if(this._getType(e)!==ce.undefined){const r=this._getOrReturnCtx(e);return se(r,{code:q.invalid_type,expected:ce.void,received:r.parsedType}),xe}return Ft(e.data)}}cl.create=s=>new cl({typeName:Ce.ZodVoid,...Pe(s)});class jt extends ze{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),i=this._def;if(t.parsedType!==ce.array)return se(t,{code:q.invalid_type,expected:ce.array,received:t.parsedType}),xe;if(i.exactLength!==null){const a=t.data.length>i.exactLength.value,o=t.data.length<i.exactLength.value;(a||o)&&(se(t,{code:a?q.too_big:q.too_small,minimum:o?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(se(t,{code:q.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(se(t,{code:q.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>i.type._parseAsync(new kr(t,a,t.path,o)))).then(a=>Et.mergeArray(r,a));const n=[...t.data].map((a,o)=>i.type._parseSync(new kr(t,a,t.path,o)));return Et.mergeArray(r,n)}get element(){return this._def.type}min(e,t){return new jt({...this._def,minLength:{value:e,message:pe.toString(t)}})}max(e,t){return new jt({...this._def,maxLength:{value:e,message:pe.toString(t)}})}length(e,t){return new jt({...this._def,exactLength:{value:e,message:pe.toString(t)}})}nonempty(e){return this.min(1,e)}}jt.create=(s,e)=>new jt({type:s,minLength:null,maxLength:null,exactLength:null,typeName:Ce.ZodArray,...Pe(e)});function gi(s){if(s instanceof nt){const e={};for(const t in s.shape){const r=s.shape[t];e[t]=Tr.create(gi(r))}return new nt({...s._def,shape:()=>e})}else return s instanceof jt?new jt({...s._def,type:gi(s.element)}):s instanceof Tr?Tr.create(gi(s.unwrap())):s instanceof vi?vi.create(gi(s.unwrap())):s instanceof Xr?Xr.create(s.items.map(e=>gi(e))):s}class nt extends ze{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=$e.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==ce.object){const u=this._getOrReturnCtx(e);return se(u,{code:q.invalid_type,expected:ce.object,received:u.parsedType}),xe}const{status:r,ctx:i}=this._processInputParams(e),{shape:n,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof _r&&this._def.unknownKeys==="strip"))for(const u in i.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const h=n[u],l=i.data[u];c.push({key:{status:"valid",value:u},value:h._parse(new kr(i,l,i.path,u)),alwaysSet:u in i.data})}if(this._def.catchall instanceof _r){const u=this._def.unknownKeys;if(u==="passthrough")for(const h of o)c.push({key:{status:"valid",value:h},value:{status:"valid",value:i.data[h]}});else if(u==="strict")o.length>0&&(se(i,{code:q.unrecognized_keys,keys:o}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const h of o){const l=i.data[h];c.push({key:{status:"valid",value:h},value:u._parse(new kr(i,l,i.path,h)),alwaysSet:h in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const u=[];for(const h of c){const l=await h.key,d=await h.value;u.push({key:l,value:d,alwaysSet:h.alwaysSet})}return u}).then(u=>Et.mergeObjectSync(r,u)):Et.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return pe.errToObj,new nt({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{const i=this._def.errorMap?.(t,r).message??r.defaultError;return t.code==="unrecognized_keys"?{message:pe.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new nt({...this._def,unknownKeys:"strip"})}passthrough(){return new nt({...this._def,unknownKeys:"passthrough"})}extend(e){return new nt({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new nt({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ce.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new nt({...this._def,catchall:e})}pick(e){const t={};for(const r of $e.objectKeys(e))e[r]&&this.shape[r]&&(t[r]=this.shape[r]);return new nt({...this._def,shape:()=>t})}omit(e){const t={};for(const r of $e.objectKeys(this.shape))e[r]||(t[r]=this.shape[r]);return new nt({...this._def,shape:()=>t})}deepPartial(){return gi(this)}partial(e){const t={};for(const r of $e.objectKeys(this.shape)){const i=this.shape[r];e&&!e[r]?t[r]=i:t[r]=i.optional()}return new nt({...this._def,shape:()=>t})}required(e){const t={};for(const r of $e.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let n=this.shape[r];for(;n instanceof Tr;)n=n._def.innerType;t[r]=n}return new nt({...this._def,shape:()=>t})}keyof(){return dl($e.objectKeys(this.shape))}}nt.create=(s,e)=>new nt({shape:()=>s,unknownKeys:"strip",catchall:_r.create(),typeName:Ce.ZodObject,...Pe(e)}),nt.strictCreate=(s,e)=>new nt({shape:()=>s,unknownKeys:"strict",catchall:_r.create(),typeName:Ce.ZodObject,...Pe(e)}),nt.lazycreate=(s,e)=>new nt({shape:s,unknownKeys:"strip",catchall:_r.create(),typeName:Ce.ZodObject,...Pe(e)});class Ns extends ze{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function i(n){for(const o of n)if(o.result.status==="valid")return o.result;for(const o of n)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=n.map(o=>new dr(o.ctx.common.issues));return se(t,{code:q.invalid_union,unionErrors:a}),xe}if(t.common.async)return Promise.all(r.map(async n=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await n._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(i);{let n;const a=[];for(const c of r){const u={...t,common:{...t.common,issues:[]},parent:null},h=c._parseSync({data:t.data,path:t.path,parent:u});if(h.status==="valid")return h;h.status==="dirty"&&!n&&(n={result:h,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(n)return t.common.issues.push(...n.ctx.common.issues),n.result;const o=a.map(c=>new dr(c));return se(t,{code:q.invalid_union,unionErrors:o}),xe}}get options(){return this._def.options}}Ns.create=(s,e)=>new Ns({options:s,typeName:Ce.ZodUnion,...Pe(e)});function na(s,e){const t=Cr(s),r=Cr(e);if(s===e)return{valid:!0,data:s};if(t===ce.object&&r===ce.object){const i=$e.objectKeys(e),n=$e.objectKeys(s).filter(o=>i.indexOf(o)!==-1),a={...s,...e};for(const o of n){const c=na(s[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===ce.array&&r===ce.array){if(s.length!==e.length)return{valid:!1};const i=[];for(let n=0;n<s.length;n++){const a=s[n],o=e[n],c=na(a,o);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return t===ce.date&&r===ce.date&&+s==+e?{valid:!0,data:s}:{valid:!1}}class Us extends ze{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),i=(n,a)=>{if(Qo(n)||Qo(a))return xe;const o=na(n.value,a.value);return o.valid?((el(n)||el(a))&&t.dirty(),{status:t.value,value:o.data}):(se(r,{code:q.invalid_intersection_types}),xe)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([n,a])=>i(n,a)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Us.create=(s,e,t)=>new Us({left:s,right:e,typeName:Ce.ZodIntersection,...Pe(t)});class Xr extends ze{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==ce.array)return se(r,{code:q.invalid_type,expected:ce.array,received:r.parsedType}),xe;if(r.data.length<this._def.items.length)return se(r,{code:q.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),xe;!this._def.rest&&r.data.length>this._def.items.length&&(se(r,{code:q.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...r.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new kr(r,a,r.path,o)):null}).filter(a=>!!a);return r.common.async?Promise.all(n).then(a=>Et.mergeArray(t,a)):Et.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new Xr({...this._def,rest:e})}}Xr.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Xr({items:s,typeName:Ce.ZodTuple,rest:null,...Pe(e)})};class ul extends ze{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==ce.map)return se(r,{code:q.invalid_type,expected:ce.map,received:r.parsedType}),xe;const i=this._def.keyType,n=this._def.valueType,a=[...r.data.entries()].map(([o,c],u)=>({key:i._parse(new kr(r,o,r.path,[u,"key"])),value:n._parse(new kr(r,c,r.path,[u,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const u=await c.key,h=await c.value;if(u.status==="aborted"||h.status==="aborted")return xe;(u.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(u.value,h.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,h=c.value;if(u.status==="aborted"||h.status==="aborted")return xe;(u.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(u.value,h.value)}return{status:t.value,value:o}}}}ul.create=(s,e,t)=>new ul({valueType:e,keyType:s,typeName:Ce.ZodMap,...Pe(t)});class Xi extends ze{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==ce.set)return se(r,{code:q.invalid_type,expected:ce.set,received:r.parsedType}),xe;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(se(r,{code:q.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(se(r,{code:q.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const n=this._def.valueType;function a(c){const u=new Set;for(const h of c){if(h.status==="aborted")return xe;h.status==="dirty"&&t.dirty(),u.add(h.value)}return{status:t.value,value:u}}const o=[...r.data.values()].map((c,u)=>n._parse(new kr(r,c,r.path,u)));return r.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new Xi({...this._def,minSize:{value:e,message:pe.toString(t)}})}max(e,t){return new Xi({...this._def,maxSize:{value:e,message:pe.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Xi.create=(s,e)=>new Xi({valueType:s,minSize:null,maxSize:null,typeName:Ce.ZodSet,...Pe(e)});class hl extends ze{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}hl.create=(s,e)=>new hl({getter:s,typeName:Ce.ZodLazy,...Pe(e)});class aa extends ze{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return se(t,{received:t.data,code:q.invalid_literal,expected:this._def.value}),xe}return{status:"valid",value:e.data}}get value(){return this._def.value}}aa.create=(s,e)=>new aa({value:s,typeName:Ce.ZodLiteral,...Pe(e)});function dl(s,e){return new yi({values:s,typeName:Ce.ZodEnum,...Pe(e)})}class yi extends ze{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return se(t,{expected:$e.joinValues(r),received:t.parsedType,code:q.invalid_type}),xe}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return se(t,{received:t.data,code:q.invalid_enum_value,options:r}),xe}return Ft(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return yi.create(e,{...this._def,...t})}exclude(e,t=this._def){return yi.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}yi.create=dl;class fl extends ze{_parse(e){const t=$e.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==ce.string&&r.parsedType!==ce.number){const i=$e.objectValues(t);return se(r,{expected:$e.joinValues(i),received:r.parsedType,code:q.invalid_type}),xe}if(this._cache||(this._cache=new Set($e.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const i=$e.objectValues(t);return se(r,{received:r.data,code:q.invalid_enum_value,options:i}),xe}return Ft(e.data)}get enum(){return this._def.values}}fl.create=(s,e)=>new fl({values:s,typeName:Ce.ZodNativeEnum,...Pe(e)});class Hs extends ze{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ce.promise&&t.common.async===!1)return se(t,{code:q.invalid_type,expected:ce.promise,received:t.parsedType}),xe;const r=t.parsedType===ce.promise?t.data:Promise.resolve(t.data);return Ft(r.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Hs.create=(s,e)=>new Hs({type:s,typeName:Ce.ZodPromise,...Pe(e)});class bi extends ze{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ce.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),i=this._def.effect||null,n={addIssue:a=>{se(r,a),a.fatal?t.abort():t.dirty()},get path(){return r.path}};if(n.addIssue=n.addIssue.bind(n),i.type==="preprocess"){const a=i.transform(r.data,n);if(r.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return xe;const c=await this._def.schema._parseAsync({data:o,path:r.path,parent:r});return c.status==="aborted"?xe:c.status==="dirty"||t.value==="dirty"?Gi(c.value):c});{if(t.value==="aborted")return xe;const o=this._def.schema._parseSync({data:a,path:r.path,parent:r});return o.status==="aborted"?xe:o.status==="dirty"||t.value==="dirty"?Gi(o.value):o}}if(i.type==="refinement"){const a=o=>{const c=i.refinement(o,n);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?xe:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?xe:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(i.type==="transform")if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!pi(a))return xe;const o=i.transform(a.value,n);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>pi(a)?Promise.resolve(i.transform(a.value,n)).then(o=>({status:t.value,value:o})):xe);$e.assertNever(i)}}bi.create=(s,e,t)=>new bi({schema:s,typeName:Ce.ZodEffects,effect:e,...Pe(t)}),bi.createWithPreprocess=(s,e,t)=>new bi({schema:e,effect:{type:"preprocess",transform:s},typeName:Ce.ZodEffects,...Pe(t)});class Tr extends ze{_parse(e){return this._getType(e)===ce.undefined?Ft(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Tr.create=(s,e)=>new Tr({innerType:s,typeName:Ce.ZodOptional,...Pe(e)});class vi extends ze{_parse(e){return this._getType(e)===ce.null?Ft(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}vi.create=(s,e)=>new vi({innerType:s,typeName:Ce.ZodNullable,...Pe(e)});class oa extends ze{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===ce.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}oa.create=(s,e)=>new oa({innerType:s,typeName:Ce.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Pe(e)});class la extends ze{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return zs(i)?i.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new dr(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new dr(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}la.create=(s,e)=>new la({innerType:s,typeName:Ce.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Pe(e)});class pl extends ze{_parse(e){if(this._getType(e)!==ce.nan){const r=this._getOrReturnCtx(e);return se(r,{code:q.invalid_type,expected:ce.nan,received:r.parsedType}),xe}return{status:"valid",value:e.data}}}pl.create=s=>new pl({typeName:Ce.ZodNaN,...Pe(s)});class Zh extends ze{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class ca extends ze{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return n.status==="aborted"?xe:n.status==="dirty"?(t.dirty(),Gi(n.value)):this._def.out._parseAsync({data:n.value,path:r.path,parent:r})})();{const i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?xe:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(e,t){return new ca({in:e,out:t,typeName:Ce.ZodPipeline})}}class ua extends ze{_parse(e){const t=this._def.innerType._parse(e),r=i=>(pi(i)&&(i.value=Object.freeze(i.value)),i);return zs(t)?t.then(i=>r(i)):r(t)}unwrap(){return this._def.innerType}}ua.create=(s,e)=>new ua({innerType:s,typeName:Ce.ZodReadonly,...Pe(e)});var Ce;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(Ce||(Ce={}));const Qe=Sr.create,Q=mi.create,Kh=sa.create;_r.create;const ml=jt.create,_e=nt.create,ha=Ns.create;Us.create,Xr.create;const Er=aa.create,yt=yi.create;Hs.create,Tr.create,vi.create;const Zi=Qe().regex(/^#[A-Fa-f0-9]{6}$/,"Invalid hex color format"),Yh=_e({offset:Q().min(0).max(1),color:Zi}).strict(),Jh=_e({type:yt(["linear","radial"]).default("linear"),angle:Q().min(0).max(360).default(0),stops:ml(Yh).min(2)}).strict(),Qh=_e({family:Qe().default("Roboto"),size:Q().min(8).max(500).default(48),weight:ha([Qe(),Q()]).default("400"),color:Zi.default("#000000"),opacity:Q().min(0).max(1).default(1)}).strict(),ed=_e({letterSpacing:Q().default(0),lineHeight:Q().min(.1).max(10).default(1.2),textTransform:yt(["none","uppercase","lowercase","capitalize"]).default("none"),textDecoration:yt(["none","underline","line-through"]).default("none"),gradient:Jh.optional()}).strict(),td=_e({width:Q().min(0).default(0),color:Zi.default("#000000"),opacity:Q().min(0).max(1).default(1)}).strict(),rd=_e({offsetX:Q().default(0),offsetY:Q().default(0),blur:Q().min(0).default(0),color:Zi.default("#000000"),opacity:Q().min(0).max(1).default(.5)}).strict(),id=_e({color:Zi.optional(),opacity:Q().min(0).max(1).default(1),borderRadius:Q().min(0).default(0)}).strict(),sd=_e({horizontal:yt(["left","center","right"]).default("left"),vertical:yt(["top","middle","bottom"]).default("middle")}).strict(),nd=_e({preset:yt(["fadeIn","slideIn","typewriter","shift","ascend","movingLetters","bounce","elastic","pulse"]),speed:Q().min(.1).max(10).default(1),duration:Q().min(.1).max(60).optional(),style:yt(["character","word"]).optional(),direction:yt(["left","right","up","down"]).optional()}).strict(),ad=_e({src:Qe().url("Invalid font URL"),family:Qe(),weight:ha([Qe(),Q()]).default("400")}).strict(),Vs=_e({type:Er("rich-text"),text:Qe().max(1e4).default(""),width:Q().min(1).max(8192).optional(),height:Q().min(1).max(8192).optional(),font:Qh.optional(),style:ed.optional(),stroke:td.optional(),shadow:rd.optional(),background:id.optional(),align:sd.optional(),animation:nd.optional(),cacheEnabled:Kh().default(!0),pixelRatio:Q().min(1).max(4).default(2),customFonts:ml(ad).optional()}).strict();var od=Object.defineProperty,ld=Object.getOwnPropertyNames,cd=(s,e,t)=>e in s?od(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,ud=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')}),gl=(s,e)=>function(){return e||(0,s[ld(s)[0]])((e={exports:{}}).exports,e),e.exports},Wt=(s,e,t)=>cd(s,typeof e!="symbol"?e+"":e,t);function Zr(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var yl={exports:{}};(function(s,e){(function(t,r){s.exports=r()})(self,()=>{return t={7629:(i,n,a)=>{const o=a(375),c=a(8571),u=a(9474),h=a(1687),l=a(8652),d=a(8160),f=a(3292),p=a(6354),m=a(8901),v=a(9708),g=a(6914),y=a(2294),b=a(6133),k=a(1152),x=a(8863),E=a(2036),T={Base:class{constructor(w){this.type=w,this.$_root=null,this._definition={},this._reset()}_reset(){this._ids=new y.Ids,this._preferences=null,this._refs=new b.Manager,this._cache=null,this._valids=null,this._invalids=null,this._flags={},this._rules=[],this._singleRules=new Map,this.$_terms={},this.$_temp={ruleset:null,whens:{}}}describe(){return o(typeof v.describe=="function","Manifest functionality disabled"),v.describe(this)}allow(...w){return d.verifyFlat(w,"allow"),this._values(w,"_valids")}alter(w){o(w&&typeof w=="object"&&!Array.isArray(w),"Invalid targets argument"),o(!this._inRuleset(),"Cannot set alterations inside a ruleset");const S=this.clone();S.$_terms.alterations=S.$_terms.alterations||[];for(const _ in w){const A=w[_];o(typeof A=="function","Alteration adjuster for",_,"must be a function"),S.$_terms.alterations.push({target:_,adjuster:A})}return S.$_temp.ruleset=!1,S}artifact(w){return o(w!==void 0,"Artifact cannot be undefined"),o(!this._cache,"Cannot set an artifact with a rule cache"),this.$_setFlag("artifact",w)}cast(w){return o(w===!1||typeof w=="string","Invalid to value"),o(w===!1||this._definition.cast[w],"Type",this.type,"does not support casting to",w),this.$_setFlag("cast",w===!1?void 0:w)}default(w,S){return this._default("default",w,S)}description(w){return o(w&&typeof w=="string","Description must be a non-empty string"),this.$_setFlag("description",w)}empty(w){const S=this.clone();return w!==void 0&&(w=S.$_compile(w,{override:!1})),S.$_setFlag("empty",w,{clone:!1})}error(w){return o(w,"Missing error"),o(w instanceof Error||typeof w=="function","Must provide a valid Error object or a function"),this.$_setFlag("error",w)}example(w,S={}){return o(w!==void 0,"Missing example"),d.assertOptions(S,["override"]),this._inner("examples",w,{single:!0,override:S.override})}external(w,S){return typeof w=="object"&&(o(!S,"Cannot combine options with description"),S=w.description,w=w.method),o(typeof w=="function","Method must be a function"),o(S===void 0||S&&typeof S=="string","Description must be a non-empty string"),this._inner("externals",{method:w,description:S},{single:!0})}failover(w,S){return this._default("failover",w,S)}forbidden(){return this.presence("forbidden")}id(w){return w?(o(typeof w=="string","id must be a non-empty string"),o(/^[^\.]+$/.test(w),"id cannot contain period character"),this.$_setFlag("id",w)):this.$_setFlag("id",void 0)}invalid(...w){return this._values(w,"_invalids")}label(w){return o(w&&typeof w=="string","Label name must be a non-empty string"),this.$_setFlag("label",w)}meta(w){return o(w!==void 0,"Meta cannot be undefined"),this._inner("metas",w,{single:!0})}note(...w){o(w.length,"Missing notes");for(const S of w)o(S&&typeof S=="string","Notes must be non-empty strings");return this._inner("notes",w)}only(w=!0){return o(typeof w=="boolean","Invalid mode:",w),this.$_setFlag("only",w)}optional(){return this.presence("optional")}prefs(w){o(w,"Missing preferences"),o(w.context===void 0,"Cannot override context"),o(w.externals===void 0,"Cannot override externals"),o(w.warnings===void 0,"Cannot override warnings"),o(w.debug===void 0,"Cannot override debug"),d.checkPreferences(w);const S=this.clone();return S._preferences=d.preferences(S._preferences,w),S}presence(w){return o(["optional","required","forbidden"].includes(w),"Unknown presence mode",w),this.$_setFlag("presence",w)}raw(w=!0){return this.$_setFlag("result",w?"raw":void 0)}result(w){return o(["raw","strip"].includes(w),"Unknown result mode",w),this.$_setFlag("result",w)}required(){return this.presence("required")}strict(w){const S=this.clone(),_=w!==void 0&&!w;return S._preferences=d.preferences(S._preferences,{convert:_}),S}strip(w=!0){return this.$_setFlag("result",w?"strip":void 0)}tag(...w){o(w.length,"Missing tags");for(const S of w)o(S&&typeof S=="string","Tags must be non-empty strings");return this._inner("tags",w)}unit(w){return o(w&&typeof w=="string","Unit name must be a non-empty string"),this.$_setFlag("unit",w)}valid(...w){d.verifyFlat(w,"valid");const S=this.allow(...w);return S.$_setFlag("only",!!S._valids,{clone:!1}),S}when(w,S){const _=this.clone();_.$_terms.whens||(_.$_terms.whens=[]);const A=f.when(_,w,S);if(!["any","link"].includes(_.type)){const M=A.is?[A]:A.switch;for(const D of M)o(!D.then||D.then.type==="any"||D.then.type===_.type,"Cannot combine",_.type,"with",D.then&&D.then.type),o(!D.otherwise||D.otherwise.type==="any"||D.otherwise.type===_.type,"Cannot combine",_.type,"with",D.otherwise&&D.otherwise.type)}return _.$_terms.whens.push(A),_.$_mutateRebuild()}cache(w){o(!this._inRuleset(),"Cannot set caching inside a ruleset"),o(!this._cache,"Cannot override schema cache"),o(this._flags.artifact===void 0,"Cannot cache a rule with an artifact");const S=this.clone();return S._cache=w||l.provider.provision(),S.$_temp.ruleset=!1,S}clone(){const w=Object.create(Object.getPrototypeOf(this));return this._assign(w)}concat(w){o(d.isSchema(w),"Invalid schema object"),o(this.type==="any"||w.type==="any"||w.type===this.type,"Cannot merge type",this.type,"with another type:",w.type),o(!this._inRuleset(),"Cannot concatenate onto a schema with open ruleset"),o(!w._inRuleset(),"Cannot concatenate a schema with open ruleset");let S=this.clone();if(this.type==="any"&&w.type!=="any"){const _=w.clone();for(const A of Object.keys(S))A!=="type"&&(_[A]=S[A]);S=_}S._ids.concat(w._ids),S._refs.register(w,b.toSibling),S._preferences=S._preferences?d.preferences(S._preferences,w._preferences):w._preferences,S._valids=E.merge(S._valids,w._valids,w._invalids),S._invalids=E.merge(S._invalids,w._invalids,w._valids);for(const _ of w._singleRules.keys())S._singleRules.has(_)&&(S._rules=S._rules.filter(A=>A.keep||A.name!==_),S._singleRules.delete(_));for(const _ of w._rules)w._definition.rules[_.method].multi||S._singleRules.set(_.name,_),S._rules.push(_);if(S._flags.empty&&w._flags.empty){S._flags.empty=S._flags.empty.concat(w._flags.empty);const _=Object.assign({},w._flags);delete _.empty,h(S._flags,_)}else if(w._flags.empty){S._flags.empty=w._flags.empty;const _=Object.assign({},w._flags);delete _.empty,h(S._flags,_)}else h(S._flags,w._flags);for(const _ in w.$_terms){const A=w.$_terms[_];A?S.$_terms[_]?S.$_terms[_]=S.$_terms[_].concat(A):S.$_terms[_]=A.slice():S.$_terms[_]||(S.$_terms[_]=A)}return this.$_root._tracer&&this.$_root._tracer._combine(S,[this,w]),S.$_mutateRebuild()}extend(w){return o(!w.base,"Cannot extend type with another base"),m.type(this,w)}extract(w){return w=Array.isArray(w)?w:w.split("."),this._ids.reach(w)}fork(w,S){o(!this._inRuleset(),"Cannot fork inside a ruleset");let _=this;for(let A of[].concat(w))A=Array.isArray(A)?A:A.split("."),_=_._ids.fork(A,S,_);return _.$_temp.ruleset=!1,_}rule(w){const S=this._definition;d.assertOptions(w,Object.keys(S.modifiers)),o(this.$_temp.ruleset!==!1,"Cannot apply rules to empty ruleset or the last rule added does not support rule properties");const _=this.$_temp.ruleset===null?this._rules.length-1:this.$_temp.ruleset;o(_>=0&&_<this._rules.length,"Cannot apply rules to empty ruleset");const A=this.clone();for(let M=_;M<A._rules.length;++M){const D=A._rules[M],W=c(D);for(const G in w)S.modifiers[G](W,w[G]),o(W.name===D.name,"Cannot change rule name");A._rules[M]=W,A._singleRules.get(W.name)===D&&A._singleRules.set(W.name,W)}return A.$_temp.ruleset=!1,A.$_mutateRebuild()}get ruleset(){o(!this._inRuleset(),"Cannot start a new ruleset without closing the previous one");const w=this.clone();return w.$_temp.ruleset=w._rules.length,w}get $(){return this.ruleset}tailor(w){w=[].concat(w),o(!this._inRuleset(),"Cannot tailor inside a ruleset");let S=this;if(this.$_terms.alterations)for(const{target:_,adjuster:A}of this.$_terms.alterations)w.includes(_)&&(S=A(S),o(d.isSchema(S),"Alteration adjuster for",_,"failed to return a schema object"));return S=S.$_modify({each:_=>_.tailor(w),ref:!1}),S.$_temp.ruleset=!1,S.$_mutateRebuild()}tracer(){return k.location?k.location(this):this}validate(w,S){return x.entry(w,this,S)}validateAsync(w,S){return x.entryAsync(w,this,S)}$_addRule(w){typeof w=="string"&&(w={name:w}),o(w&&typeof w=="object","Invalid options"),o(w.name&&typeof w.name=="string","Invalid rule name");for(const D in w)o(D[0]!=="_","Cannot set private rule properties");const S=Object.assign({},w);S._resolve=[],S.method=S.method||S.name;const _=this._definition.rules[S.method],A=S.args;o(_,"Unknown rule",S.method);const M=this.clone();if(A){o(Object.keys(A).length===1||Object.keys(A).length===this._definition.rules[S.name].args.length,"Invalid rule definition for",this.type,S.name);for(const D in A){let W=A[D];if(_.argsByName){const G=_.argsByName.get(D);if(G.ref&&d.isResolvable(W))S._resolve.push(D),M.$_mutateRegister(W);else if(G.normalize&&(W=G.normalize(W),A[D]=W),G.assert){const ue=d.validateArg(W,D,G);o(!ue,ue,"or reference")}}W!==void 0?A[D]=W:delete A[D]}}return _.multi||(M._ruleRemove(S.name,{clone:!1}),M._singleRules.set(S.name,S)),M.$_temp.ruleset===!1&&(M.$_temp.ruleset=null),_.priority?M._rules.unshift(S):M._rules.push(S),M}$_compile(w,S){return f.schema(this.$_root,w,S)}$_createError(w,S,_,A,M,D={}){const W=D.flags!==!1?this._flags:{},G=D.messages?g.merge(this._definition.messages,D.messages):this._definition.messages;return new p.Report(w,S,_,W,G,A,M)}$_getFlag(w){return this._flags[w]}$_getRule(w){return this._singleRules.get(w)}$_mapLabels(w){return w=Array.isArray(w)?w:w.split("."),this._ids.labels(w)}$_match(w,S,_,A){(_=Object.assign({},_)).abortEarly=!0,_._externals=!1,S.snapshot();const M=!x.validate(w,this,S,_,A).errors;return S.restore(),M}$_modify(w){return d.assertOptions(w,["each","once","ref","schema"]),y.schema(this,w)||this}$_mutateRebuild(){return o(!this._inRuleset(),"Cannot add this rule inside a ruleset"),this._refs.reset(),this._ids.reset(),this.$_modify({each:(w,{source:S,name:_,path:A,key:M})=>{const D=this._definition[S][_]&&this._definition[S][_].register;D!==!1&&this.$_mutateRegister(w,{family:D,key:M})}}),this._definition.rebuild&&this._definition.rebuild(this),this.$_temp.ruleset=!1,this}$_mutateRegister(w,{family:S,key:_}={}){this._refs.register(w,S),this._ids.register(w,{key:_})}$_property(w){return this._definition.properties[w]}$_reach(w){return this._ids.reach(w)}$_rootReferences(){return this._refs.roots()}$_setFlag(w,S,_={}){o(w[0]==="_"||!this._inRuleset(),"Cannot set flag inside a ruleset");const A=this._definition.flags[w]||{};if(u(S,A.default)&&(S=void 0),u(S,this._flags[w]))return this;const M=_.clone!==!1?this.clone():this;return S!==void 0?(M._flags[w]=S,M.$_mutateRegister(S)):delete M._flags[w],w[0]!=="_"&&(M.$_temp.ruleset=!1),M}$_parent(w,...S){return this[w][d.symbols.parent].call(this,...S)}$_validate(w,S,_){return x.validate(w,this,S,_)}_assign(w){w.type=this.type,w.$_root=this.$_root,w.$_temp=Object.assign({},this.$_temp),w.$_temp.whens={},w._ids=this._ids.clone(),w._preferences=this._preferences,w._valids=this._valids&&this._valids.clone(),w._invalids=this._invalids&&this._invalids.clone(),w._rules=this._rules.slice(),w._singleRules=c(this._singleRules,{shallow:!0}),w._refs=this._refs.clone(),w._flags=Object.assign({},this._flags),w._cache=null,w.$_terms={};for(const S in this.$_terms)w.$_terms[S]=this.$_terms[S]?this.$_terms[S].slice():null;w.$_super={};for(const S in this.$_super)w.$_super[S]=this._super[S].bind(w);return w}_bare(){const w=this.clone();w._reset();const S=w._definition.terms;for(const _ in S){const A=S[_];w.$_terms[_]=A.init}return w.$_mutateRebuild()}_default(w,S,_={}){return d.assertOptions(_,"literal"),o(S!==void 0,"Missing",w,"value"),o(typeof S=="function"||!_.literal,"Only function value supports literal option"),typeof S=="function"&&_.literal&&(S={[d.symbols.literal]:!0,literal:S}),this.$_setFlag(w,S)}_generate(w,S,_){if(!this.$_terms.whens)return{schema:this};const A=[],M=[];for(let G=0;G<this.$_terms.whens.length;++G){const ue=this.$_terms.whens[G];if(ue.concat){A.push(ue.concat),M.push(`${G}.concat`);continue}const re=ue.ref?ue.ref.resolve(w,S,_):w,$=ue.is?[ue]:ue.switch,H=M.length;for(let z=0;z<$.length;++z){const{is:te,then:he,otherwise:Se}=$[z],Fe=`${G}${ue.switch?"."+z:""}`;if(te.$_match(re,S.nest(te,`${Fe}.is`),_)){if(he){const Re=S.localize([...S.path,`${Fe}.then`],S.ancestors,S.schemas),{schema:Me,id:Ke}=he._generate(w,Re,_);A.push(Me),M.push(`${Fe}.then${Ke?`(${Ke})`:""}`);break}}else if(Se){const Re=S.localize([...S.path,`${Fe}.otherwise`],S.ancestors,S.schemas),{schema:Me,id:Ke}=Se._generate(w,Re,_);A.push(Me),M.push(`${Fe}.otherwise${Ke?`(${Ke})`:""}`);break}}if(ue.break&&M.length>H)break}const D=M.join(", ");if(S.mainstay.tracer.debug(S,"rule","when",D),!D)return{schema:this};if(!S.mainstay.tracer.active&&this.$_temp.whens[D])return{schema:this.$_temp.whens[D],id:D};let W=this;this._definition.generate&&(W=this._definition.generate(this,w,S,_));for(const G of A)W=W.concat(G);return this.$_root._tracer&&this.$_root._tracer._combine(W,[this,...A]),this.$_temp.whens[D]=W,{schema:W,id:D}}_inner(w,S,_={}){o(!this._inRuleset(),`Cannot set ${w} inside a ruleset`);const A=this.clone();return A.$_terms[w]&&!_.override||(A.$_terms[w]=[]),_.single?A.$_terms[w].push(S):A.$_terms[w].push(...S),A.$_temp.ruleset=!1,A}_inRuleset(){return this.$_temp.ruleset!==null&&this.$_temp.ruleset!==!1}_ruleRemove(w,S={}){if(!this._singleRules.has(w))return this;const _=S.clone!==!1?this.clone():this;_._singleRules.delete(w);const A=[];for(let M=0;M<_._rules.length;++M){const D=_._rules[M];D.name!==w||D.keep?A.push(D):_._inRuleset()&&M<_.$_temp.ruleset&&--_.$_temp.ruleset}return _._rules=A,_}_values(w,S){d.verifyFlat(w,S.slice(1,-1));const _=this.clone(),A=w[0]===d.symbols.override;if(A&&(w=w.slice(1)),!_[S]&&w.length?_[S]=new E:A&&(_[S]=w.length?new E:null,_.$_mutateRebuild()),!_[S])return _;A&&_[S].override();for(const M of w){o(M!==void 0,"Cannot call allow/valid/invalid with undefined"),o(M!==d.symbols.override,"Override must be the first value");const D=S==="_invalids"?"_valids":"_invalids";_[D]&&(_[D].remove(M),_[D].length||(o(S==="_valids"||!_._flags.only,"Setting invalid value",M,"leaves schema rejecting all values due to previous valid rule"),_[D]=null)),_[S].add(M,_._refs)}return _}}};T.Base.prototype[d.symbols.any]={version:d.version,compile:f.compile,root:"$_root"},T.Base.prototype.isImmutable=!0,T.Base.prototype.deny=T.Base.prototype.invalid,T.Base.prototype.disallow=T.Base.prototype.invalid,T.Base.prototype.equal=T.Base.prototype.valid,T.Base.prototype.exist=T.Base.prototype.required,T.Base.prototype.not=T.Base.prototype.invalid,T.Base.prototype.options=T.Base.prototype.prefs,T.Base.prototype.preferences=T.Base.prototype.prefs,i.exports=new T.Base},8652:(i,n,a)=>{const o=a(375),c=a(8571),u=a(8160),h={max:1e3,supported:new Set(["undefined","boolean","number","string"])};n.provider={provision:l=>new h.Cache(l)},h.Cache=class{constructor(l={}){u.assertOptions(l,["max"]),o(l.max===void 0||l.max&&l.max>0&&isFinite(l.max),"Invalid max cache size"),this._max=l.max||h.max,this._map=new Map,this._list=new h.List}get length(){return this._map.size}set(l,d){if(l!==null&&!h.supported.has(typeof l))return;let f=this._map.get(l);if(f)return f.value=d,void this._list.first(f);f=this._list.unshift({key:l,value:d}),this._map.set(l,f),this._compact()}get(l){const d=this._map.get(l);if(d)return this._list.first(d),c(d.value)}_compact(){if(this._map.size>this._max){const l=this._list.pop();this._map.delete(l.key)}}},h.List=class{constructor(){this.tail=null,this.head=null}unshift(l){return l.next=null,l.prev=this.head,this.head&&(this.head.next=l),this.head=l,this.tail||(this.tail=l),l}first(l){l!==this.head&&(this._remove(l),this.unshift(l))}pop(){return this._remove(this.tail)}_remove(l){const{next:d,prev:f}=l;return d.prev=f,f&&(f.next=d),l===this.tail&&(this.tail=d),l.prev=null,l.next=null,l}}},8160:(i,n,a)=>{const o=a(375),c=a(7916),u=a(5934);let h,l;const d={isoDate:/^(?:[-+]\d{2})?(?:\d{4}(?!\d{2}\b))(?:(-?)(?:(?:0[1-9]|1[0-2])(?:\1(?:[12]\d|0[1-9]|3[01]))?|W(?:[0-4]\d|5[0-2])(?:-?[1-7])?|(?:00[1-9]|0[1-9]\d|[12]\d{2}|3(?:[0-5]\d|6[1-6])))(?![T]$|[T][\d]+Z$)(?:[T\s](?:(?:(?:[01]\d|2[0-3])(?:(:?)[0-5]\d)?|24\:?00)(?:[.,]\d+(?!:))?)(?:\2[0-5]\d(?:[.,]\d+)?)?(?:[Z]|(?:[+-])(?:[01]\d|2[0-3])(?::?[0-5]\d)?)?)?)?$/};n.version=u.version,n.defaults={abortEarly:!0,allowUnknown:!1,artifacts:!1,cache:!0,context:null,convert:!0,dateFormat:"iso",errors:{escapeHtml:!1,label:"path",language:null,render:!0,stack:!1,wrap:{label:'"',array:"[]"}},externals:!0,messages:{},nonEnumerables:!1,noDefaults:!1,presence:"optional",skipFunctions:!1,stripUnknown:!1,warnings:!1},n.symbols={any:Symbol.for("@hapi/joi/schema"),arraySingle:Symbol("arraySingle"),deepDefault:Symbol("deepDefault"),errors:Symbol("errors"),literal:Symbol("literal"),override:Symbol("override"),parent:Symbol("parent"),prefs:Symbol("prefs"),ref:Symbol("ref"),template:Symbol("template"),values:Symbol("values")},n.assertOptions=function(f,p,m="Options"){o(f&&typeof f=="object"&&!Array.isArray(f),"Options must be of type object");const v=Object.keys(f).filter(g=>!p.includes(g));o(v.length===0,`${m} contain unknown keys: ${v}`)},n.checkPreferences=function(f){l=l||a(3378);const p=l.preferences.validate(f);if(p.error)throw new c([p.error.details[0].message])},n.compare=function(f,p,m){switch(m){case"=":return f===p;case">":return f>p;case"<":return f<p;case">=":return f>=p;case"<=":return f<=p}},n.default=function(f,p){return f===void 0?p:f},n.isIsoDate=function(f){return d.isoDate.test(f)},n.isNumber=function(f){return typeof f=="number"&&!isNaN(f)},n.isResolvable=function(f){return!!f&&(f[n.symbols.ref]||f[n.symbols.template])},n.isSchema=function(f,p={}){const m=f&&f[n.symbols.any];return!!m&&(o(p.legacy||m.version===n.version,"Cannot mix different versions of joi schemas"),!0)},n.isValues=function(f){return f[n.symbols.values]},n.limit=function(f){return Number.isSafeInteger(f)&&f>=0},n.preferences=function(f,p){h=h||a(6914),f=f||{},p=p||{};const m=Object.assign({},f,p);return p.errors&&f.errors&&(m.errors=Object.assign({},f.errors,p.errors),m.errors.wrap=Object.assign({},f.errors.wrap,p.errors.wrap)),p.messages&&(m.messages=h.compile(p.messages,f.messages)),delete m[n.symbols.prefs],m},n.tryWithPath=function(f,p,m={}){try{return f()}catch(v){throw v.path!==void 0?v.path=p+"."+v.path:v.path=p,m.append&&(v.message=`${v.message} (${v.path})`),v}},n.validateArg=function(f,p,{assert:m,message:v}){if(n.isSchema(m)){const g=m.validate(f);return g.error?g.error.message:void 0}if(!m(f))return p?`${p} ${v}`:v},n.verifyFlat=function(f,p){for(const m of f)o(!Array.isArray(m),"Method no longer accepts array arguments:",p)}},3292:(i,n,a)=>{const o=a(375),c=a(8160),u=a(6133),h={};n.schema=function(l,d,f={}){c.assertOptions(f,["appendPath","override"]);try{return h.schema(l,d,f)}catch(p){throw f.appendPath&&p.path!==void 0&&(p.message=`${p.message} (${p.path})`),p}},h.schema=function(l,d,f){o(d!==void 0,"Invalid undefined schema"),Array.isArray(d)&&(o(d.length,"Invalid empty array schema"),d.length===1&&(d=d[0]));const p=(m,...v)=>f.override!==!1?m.valid(l.override,...v):m.valid(...v);if(h.simple(d))return p(l,d);if(typeof d=="function")return l.custom(d);if(o(typeof d=="object","Invalid schema content:",typeof d),c.isResolvable(d))return p(l,d);if(c.isSchema(d))return d;if(Array.isArray(d)){for(const m of d)if(!h.simple(m))return l.alternatives().try(...d);return p(l,...d)}return d instanceof RegExp?l.string().regex(d):d instanceof Date?p(l.date(),d):(o(Object.getPrototypeOf(d)===Object.getPrototypeOf({}),"Schema can only contain plain objects"),l.object().keys(d))},n.ref=function(l,d){return u.isRef(l)?l:u.create(l,d)},n.compile=function(l,d,f={}){c.assertOptions(f,["legacy"]);const p=d&&d[c.symbols.any];if(p)return o(f.legacy||p.version===c.version,"Cannot mix different versions of joi schemas:",p.version,c.version),d;if(typeof d!="object"||!f.legacy)return n.schema(l,d,{appendPath:!0});const m=h.walk(d);return m?m.compile(m.root,d):n.schema(l,d,{appendPath:!0})},h.walk=function(l){if(typeof l!="object")return null;if(Array.isArray(l)){for(const f of l){const p=h.walk(f);if(p)return p}return null}const d=l[c.symbols.any];if(d)return{root:l[d.root],compile:d.compile};o(Object.getPrototypeOf(l)===Object.getPrototypeOf({}),"Schema can only contain plain objects");for(const f in l){const p=h.walk(l[f]);if(p)return p}return null},h.simple=function(l){return l===null||["boolean","string","number"].includes(typeof l)},n.when=function(l,d,f){if(f===void 0&&(o(d&&typeof d=="object","Missing options"),f=d,d=u.create(".")),Array.isArray(f)&&(f={switch:f}),c.assertOptions(f,["is","not","then","otherwise","switch","break"]),c.isSchema(d))return o(f.is===void 0,'"is" can not be used with a schema condition'),o(f.not===void 0,'"not" can not be used with a schema condition'),o(f.switch===void 0,'"switch" can not be used with a schema condition'),h.condition(l,{is:d,then:f.then,otherwise:f.otherwise,break:f.break});if(o(u.isRef(d)||typeof d=="string","Invalid condition:",d),o(f.not===void 0||f.is===void 0,'Cannot combine "is" with "not"'),f.switch===void 0){let m=f;f.not!==void 0&&(m={is:f.not,then:f.otherwise,otherwise:f.then,break:f.break});let v=m.is!==void 0?l.$_compile(m.is):l.$_root.invalid(null,!1,0,"").required();return o(m.then!==void 0||m.otherwise!==void 0,'options must have at least one of "then", "otherwise", or "switch"'),o(m.break===void 0||m.then===void 0||m.otherwise===void 0,"Cannot specify then, otherwise, and break all together"),f.is===void 0||u.isRef(f.is)||c.isSchema(f.is)||(v=v.required()),h.condition(l,{ref:n.ref(d),is:v,then:m.then,otherwise:m.otherwise,break:m.break})}o(Array.isArray(f.switch),'"switch" must be an array'),o(f.is===void 0,'Cannot combine "switch" with "is"'),o(f.not===void 0,'Cannot combine "switch" with "not"'),o(f.then===void 0,'Cannot combine "switch" with "then"');const p={ref:n.ref(d),switch:[],break:f.break};for(let m=0;m<f.switch.length;++m){const v=f.switch[m],g=m===f.switch.length-1;c.assertOptions(v,g?["is","then","otherwise"]:["is","then"]),o(v.is!==void 0,'Switch statement missing "is"'),o(v.then!==void 0,'Switch statement missing "then"');const y={is:l.$_compile(v.is),then:l.$_compile(v.then)};if(u.isRef(v.is)||c.isSchema(v.is)||(y.is=y.is.required()),g){o(f.otherwise===void 0||v.otherwise===void 0,'Cannot specify "otherwise" inside and outside a "switch"');const b=f.otherwise!==void 0?f.otherwise:v.otherwise;b!==void 0&&(o(p.break===void 0,"Cannot specify both otherwise and break"),y.otherwise=l.$_compile(b))}p.switch.push(y)}return p},h.condition=function(l,d){for(const f of["then","otherwise"])d[f]===void 0?delete d[f]:d[f]=l.$_compile(d[f]);return d}},6354:(i,n,a)=>{const o=a(5688),c=a(8160),u=a(3328);n.Report=class{constructor(h,l,d,f,p,m,v){if(this.code=h,this.flags=f,this.messages=p,this.path=m.path,this.prefs=v,this.state=m,this.value=l,this.message=null,this.template=null,this.local=d||{},this.local.label=n.label(this.flags,this.state,this.prefs,this.messages),this.value===void 0||this.local.hasOwnProperty("value")||(this.local.value=this.value),this.path.length){const g=this.path[this.path.length-1];typeof g!="object"&&(this.local.key=g)}}_setTemplate(h){if(this.template=h,!this.flags.label&&this.path.length===0){const l=this._template(this.template,"root");l&&(this.local.label=l)}}toString(){if(this.message)return this.message;const h=this.code;if(!this.prefs.errors.render)return this.code;const l=this._template(this.template)||this._template(this.prefs.messages)||this._template(this.messages);return l===void 0?`Error code "${h}" is not defined, your custom type is missing the correct messages definition`:(this.message=l.render(this.value,this.state,this.prefs,this.local,{errors:this.prefs.errors,messages:[this.prefs.messages,this.messages]}),this.prefs.errors.label||(this.message=this.message.replace(/^"" /,"").trim()),this.message)}_template(h,l){return n.template(this.value,h,l||this.code,this.state,this.prefs)}},n.path=function(h){let l="";for(const d of h)typeof d!="object"&&(typeof d=="string"?(l&&(l+="."),l+=d):l+=`[${d}]`);return l},n.template=function(h,l,d,f,p){if(!l)return;if(u.isTemplate(l))return d!=="root"?l:null;let m=p.errors.language;if(c.isResolvable(m)&&(m=m.resolve(h,f,p)),m&&l[m]){if(l[m][d]!==void 0)return l[m][d];if(l[m]["*"]!==void 0)return l[m]["*"]}return l[d]?l[d]:l["*"]},n.label=function(h,l,d,f){if(!d.errors.label)return"";if(h.label)return h.label;let p=l.path;return d.errors.label==="key"&&l.path.length>1&&(p=l.path.slice(-1)),n.path(p)||n.template(null,d.messages,"root",l,d)||f&&n.template(null,f,"root",l,d)||"value"},n.process=function(h,l,d){if(!h)return null;const{override:f,message:p,details:m}=n.details(h);if(f)return f;if(d.errors.stack)return new n.ValidationError(p,m,l);const v=Error.stackTraceLimit;Error.stackTraceLimit=0;const g=new n.ValidationError(p,m,l);return Error.stackTraceLimit=v,g},n.details=function(h,l={}){let d=[];const f=[];for(const p of h){if(p instanceof Error){if(l.override!==!1)return{override:p};const v=p.toString();d.push(v),f.push({message:v,type:"override",context:{error:p}});continue}const m=p.toString();d.push(m),f.push({message:m,path:p.path.filter(v=>typeof v!="object"),type:p.code,context:p.local})}return d.length>1&&(d=[...new Set(d)]),{message:d.join(". "),details:f}},n.ValidationError=class extends Error{constructor(h,l,d){super(h),this._original=d,this.details=l}static isError(h){return h instanceof n.ValidationError}},n.ValidationError.prototype.isJoi=!0,n.ValidationError.prototype.name="ValidationError",n.ValidationError.prototype.annotate=o.error},8901:(i,n,a)=>{const o=a(375),c=a(8571),u=a(8160),h=a(6914),l={};n.type=function(d,f){const p=Object.getPrototypeOf(d),m=c(p),v=d._assign(Object.create(m)),g=Object.assign({},f);delete g.base,m._definition=g;const y=p._definition||{};g.messages=h.merge(y.messages,g.messages),g.properties=Object.assign({},y.properties,g.properties),v.type=g.type,g.flags=Object.assign({},y.flags,g.flags);const b=Object.assign({},y.terms);if(g.terms)for(const T in g.terms){const w=g.terms[T];o(v.$_terms[T]===void 0,"Invalid term override for",g.type,T),v.$_terms[T]=w.init,b[T]=w}g.terms=b,g.args||(g.args=y.args),g.prepare=l.prepare(g.prepare,y.prepare),g.coerce&&(typeof g.coerce=="function"&&(g.coerce={method:g.coerce}),g.coerce.from&&!Array.isArray(g.coerce.from)&&(g.coerce={method:g.coerce.method,from:[].concat(g.coerce.from)})),g.coerce=l.coerce(g.coerce,y.coerce),g.validate=l.validate(g.validate,y.validate);const k=Object.assign({},y.rules);if(g.rules)for(const T in g.rules){const w=g.rules[T];o(typeof w=="object","Invalid rule definition for",g.type,T);let S=w.method;if(S===void 0&&(S=function(){return this.$_addRule(T)}),S&&(o(!m[T],"Rule conflict in",g.type,T),m[T]=S),o(!k[T],"Rule conflict in",g.type,T),k[T]=w,w.alias){const _=[].concat(w.alias);for(const A of _)m[A]=w.method}w.args&&(w.argsByName=new Map,w.args=w.args.map(_=>(typeof _=="string"&&(_={name:_}),o(!w.argsByName.has(_.name),"Duplicated argument name",_.name),u.isSchema(_.assert)&&(_.assert=_.assert.strict().label(_.name)),w.argsByName.set(_.name,_),_)))}g.rules=k;const x=Object.assign({},y.modifiers);if(g.modifiers)for(const T in g.modifiers){o(!m[T],"Rule conflict in",g.type,T);const w=g.modifiers[T];o(typeof w=="function","Invalid modifier definition for",g.type,T);const S=function(_){return this.rule({[T]:_})};m[T]=S,x[T]=w}if(g.modifiers=x,g.overrides){m._super=p,v.$_super={};for(const T in g.overrides)o(p[T],"Cannot override missing",T),g.overrides[T][u.symbols.parent]=p[T],v.$_super[T]=p[T].bind(v);Object.assign(m,g.overrides)}g.cast=Object.assign({},y.cast,g.cast);const E=Object.assign({},y.manifest,g.manifest);return E.build=l.build(g.manifest&&g.manifest.build,y.manifest&&y.manifest.build),g.manifest=E,g.rebuild=l.rebuild(g.rebuild,y.rebuild),v},l.build=function(d,f){return d&&f?function(p,m){return f(d(p,m),m)}:d||f},l.coerce=function(d,f){return d&&f?{from:d.from&&f.from?[...new Set([...d.from,...f.from])]:null,method(p,m){let v;if((!f.from||f.from.includes(typeof p))&&(v=f.method(p,m),v)){if(v.errors||v.value===void 0)return v;p=v.value}if(!d.from||d.from.includes(typeof p)){const g=d.method(p,m);if(g)return g}return v}}:d||f},l.prepare=function(d,f){return d&&f?function(p,m){const v=d(p,m);if(v){if(v.errors||v.value===void 0)return v;p=v.value}return f(p,m)||v}:d||f},l.rebuild=function(d,f){return d&&f?function(p){f(p),d(p)}:d||f},l.validate=function(d,f){return d&&f?function(p,m){const v=f(p,m);if(v){if(v.errors&&(!Array.isArray(v.errors)||v.errors.length))return v;p=v.value}return d(p,m)||v}:d||f}},5107:(i,n,a)=>{const o=a(375),c=a(8571),u=a(8652),h=a(8160),l=a(3292),d=a(6354),f=a(8901),p=a(9708),m=a(6133),v=a(3328),g=a(1152);let y;const b={types:{alternatives:a(4946),any:a(8068),array:a(546),boolean:a(4937),date:a(7500),function:a(390),link:a(8785),number:a(3832),object:a(8966),string:a(7417),symbol:a(8826)},aliases:{alt:"alternatives",bool:"boolean",func:"function"},root:function(){const k={_types:new Set(Object.keys(b.types))};for(const x of k._types)k[x]=function(...E){return o(!E.length||["alternatives","link","object"].includes(x),"The",x,"type does not allow arguments"),b.generate(this,b.types[x],E)};for(const x of["allow","custom","disallow","equal","exist","forbidden","invalid","not","only","optional","options","prefs","preferences","required","strip","valid","when"])k[x]=function(...E){return this.any()[x](...E)};Object.assign(k,b.methods);for(const x in b.aliases){const E=b.aliases[x];k[x]=k[E]}return k.x=k.expression,g.setup&&g.setup(k),k}};b.methods={ValidationError:d.ValidationError,version:h.version,cache:u.provider,assert(k,x,...E){b.assert(k,x,!0,E)},attempt:(k,x,...E)=>b.assert(k,x,!1,E),build(k){return o(typeof p.build=="function","Manifest functionality disabled"),p.build(this,k)},checkPreferences(k){h.checkPreferences(k)},compile(k,x){return l.compile(this,k,x)},defaults(k){o(typeof k=="function","modifier must be a function");const x=Object.assign({},this);for(const E of x._types){const T=k(x[E]());o(h.isSchema(T),"modifier must return a valid schema object"),x[E]=function(...w){return b.generate(this,T,w)}}return x},expression:(...k)=>new v(...k),extend(...k){h.verifyFlat(k,"extend"),y=y||a(3378),o(k.length,"You need to provide at least one extension"),this.assert(k,y.extensions);const x=Object.assign({},this);x._types=new Set(x._types);for(let E of k){typeof E=="function"&&(E=E(x)),this.assert(E,y.extension);const T=b.expandExtension(E,x);for(const w of T){o(x[w.type]===void 0||x._types.has(w.type),"Cannot override name",w.type);const S=w.base||this.any(),_=f.type(S,w);x._types.add(w.type),x[w.type]=function(...A){return b.generate(this,_,A)}}}return x},isError:d.ValidationError.isError,isExpression:v.isTemplate,isRef:m.isRef,isSchema:h.isSchema,in:(...k)=>m.in(...k),override:h.symbols.override,ref:(...k)=>m.create(...k),types(){const k={};for(const x of this._types)k[x]=this[x]();for(const x in b.aliases)k[x]=this[x]();return k}},b.assert=function(k,x,E,T){const w=T[0]instanceof Error||typeof T[0]=="string"?T[0]:null,S=w!==null?T[1]:T[0],_=x.validate(k,h.preferences({errors:{stack:!0}},S||{}));let A=_.error;if(!A)return _.value;if(w instanceof Error)throw w;const M=E&&typeof A.annotate=="function"?A.annotate():A.message;throw A instanceof d.ValidationError==0&&(A=c(A)),A.message=w?`${w} ${M}`:M,A},b.generate=function(k,x,E){return o(k,"Must be invoked on a Joi instance."),x.$_root=k,x._definition.args&&E.length?x._definition.args(x,...E):x},b.expandExtension=function(k,x){if(typeof k.type=="string")return[k];const E=[];for(const T of x._types)if(k.type.test(T)){const w=Object.assign({},k);w.type=T,w.base=x[T](),E.push(w)}return E},i.exports=b.root()},6914:(i,n,a)=>{const o=a(375),c=a(8571),u=a(3328);n.compile=function(h,l){if(typeof h=="string")return o(!l,"Cannot set single message string"),new u(h);if(u.isTemplate(h))return o(!l,"Cannot set single message template"),h;o(typeof h=="object"&&!Array.isArray(h),"Invalid message options"),l=l?c(l):{};for(let d in h){const f=h[d];if(d==="root"||u.isTemplate(f)){l[d]=f;continue}if(typeof f=="string"){l[d]=new u(f);continue}o(typeof f=="object"&&!Array.isArray(f),"Invalid message for",d);const p=d;for(d in l[p]=l[p]||{},f){const m=f[d];d==="root"||u.isTemplate(m)?l[p][d]=m:(o(typeof m=="string","Invalid message for",d,"in",p),l[p][d]=new u(m))}}return l},n.decompile=function(h){const l={};for(let d in h){const f=h[d];if(d==="root"){l.root=f;continue}if(u.isTemplate(f)){l[d]=f.describe({compact:!0});continue}const p=d;for(d in l[p]={},f){const m=f[d];d!=="root"?l[p][d]=m.describe({compact:!0}):l[p].root=m}}return l},n.merge=function(h,l){if(!h)return n.compile(l);if(!l)return h;if(typeof l=="string")return new u(l);if(u.isTemplate(l))return l;const d=c(h);for(let f in l){const p=l[f];if(f==="root"||u.isTemplate(p)){d[f]=p;continue}if(typeof p=="string"){d[f]=new u(p);continue}o(typeof p=="object"&&!Array.isArray(p),"Invalid message for",f);const m=f;for(f in d[m]=d[m]||{},p){const v=p[f];f==="root"||u.isTemplate(v)?d[m][f]=v:(o(typeof v=="string","Invalid message for",f,"in",m),d[m][f]=new u(v))}}return d}},2294:(i,n,a)=>{const o=a(375),c=a(8160),u=a(6133),h={};n.Ids=h.Ids=class{constructor(){this._byId=new Map,this._byKey=new Map,this._schemaChain=!1}clone(){const l=new h.Ids;return l._byId=new Map(this._byId),l._byKey=new Map(this._byKey),l._schemaChain=this._schemaChain,l}concat(l){l._schemaChain&&(this._schemaChain=!0);for(const[d,f]of l._byId.entries())o(!this._byKey.has(d),"Schema id conflicts with existing key:",d),this._byId.set(d,f);for(const[d,f]of l._byKey.entries())o(!this._byId.has(d),"Schema key conflicts with existing id:",d),this._byKey.set(d,f)}fork(l,d,f){const p=this._collect(l);p.push({schema:f});const m=p.shift();let v={id:m.id,schema:d(m.schema)};o(c.isSchema(v.schema),"adjuster function failed to return a joi schema type");for(const g of p)v={id:g.id,schema:h.fork(g.schema,v.id,v.schema)};return v.schema}labels(l,d=[]){const f=l[0],p=this._get(f);if(!p)return[...d,...l].join(".");const m=l.slice(1);return d=[...d,p.schema._flags.label||f],m.length?p.schema._ids.labels(m,d):d.join(".")}reach(l,d=[]){const f=l[0],p=this._get(f);o(p,"Schema does not contain path",[...d,...l].join("."));const m=l.slice(1);return m.length?p.schema._ids.reach(m,[...d,f]):p.schema}register(l,{key:d}={}){if(!l||!c.isSchema(l))return;(l.$_property("schemaChain")||l._ids._schemaChain)&&(this._schemaChain=!0);const f=l._flags.id;if(f){const p=this._byId.get(f);o(!p||p.schema===l,"Cannot add different schemas with the same id:",f),o(!this._byKey.has(f),"Schema id conflicts with existing key:",f),this._byId.set(f,{schema:l,id:f})}d&&(o(!this._byKey.has(d),"Schema already contains key:",d),o(!this._byId.has(d),"Schema key conflicts with existing id:",d),this._byKey.set(d,{schema:l,id:d}))}reset(){this._byId=new Map,this._byKey=new Map,this._schemaChain=!1}_collect(l,d=[],f=[]){const p=l[0],m=this._get(p);o(m,"Schema does not contain path",[...d,...l].join(".")),f=[m,...f];const v=l.slice(1);return v.length?m.schema._ids._collect(v,[...d,p],f):f}_get(l){return this._byId.get(l)||this._byKey.get(l)}},h.fork=function(l,d,f){const p=n.schema(l,{each:(m,{key:v})=>{if(d===(m._flags.id||v))return f},ref:!1});return p?p.$_mutateRebuild():l},n.schema=function(l,d){let f;for(const p in l._flags){if(p[0]==="_")continue;const m=h.scan(l._flags[p],{source:"flags",name:p},d);m!==void 0&&(f=f||l.clone(),f._flags[p]=m)}for(let p=0;p<l._rules.length;++p){const m=l._rules[p],v=h.scan(m.args,{source:"rules",name:m.name},d);if(v!==void 0){f=f||l.clone();const g=Object.assign({},m);g.args=v,f._rules[p]=g,f._singleRules.get(m.name)===m&&f._singleRules.set(m.name,g)}}for(const p in l.$_terms){if(p[0]==="_")continue;const m=h.scan(l.$_terms[p],{source:"terms",name:p},d);m!==void 0&&(f=f||l.clone(),f.$_terms[p]=m)}return f},h.scan=function(l,d,f,p,m){const v=p||[];if(l===null||typeof l!="object")return;let g;if(Array.isArray(l)){for(let y=0;y<l.length;++y){const b=d.source==="terms"&&d.name==="keys"&&l[y].key,k=h.scan(l[y],d,f,[y,...v],b);k!==void 0&&(g=g||l.slice(),g[y]=k)}return g}if(f.schema!==!1&&c.isSchema(l)||f.ref!==!1&&u.isRef(l)){const y=f.each(l,{...d,path:v,key:m});return y===l?void 0:y}for(const y in l){if(y[0]==="_")continue;const b=h.scan(l[y],d,f,[y,...v],m);b!==void 0&&(g=g||Object.assign({},l),g[y]=b)}return g}},6133:(i,n,a)=>{const o=a(375),c=a(8571),u=a(9621),h=a(8160);let l;const d={symbol:Symbol("ref"),defaults:{adjust:null,in:!1,iterables:null,map:null,separator:".",type:"value"}};n.create=function(f,p={}){o(typeof f=="string","Invalid reference key:",f),h.assertOptions(p,["adjust","ancestor","in","iterables","map","prefix","render","separator"]),o(!p.prefix||typeof p.prefix=="object","options.prefix must be of type object");const m=Object.assign({},d.defaults,p);delete m.prefix;const v=m.separator,g=d.context(f,v,p.prefix);if(m.type=g.type,f=g.key,m.type==="value")if(g.root&&(o(!v||f[0]!==v,"Cannot specify relative path with root prefix"),m.ancestor="root",f||(f=null)),v&&v===f)f=null,m.ancestor=0;else if(m.ancestor!==void 0)o(!v||!f||f[0]!==v,"Cannot combine prefix with ancestor option");else{const[y,b]=d.ancestor(f,v);b&&(f=f.slice(b))===""&&(f=null),m.ancestor=y}return m.path=v?f===null?[]:f.split(v):[f],new d.Ref(m)},n.in=function(f,p={}){return n.create(f,{...p,in:!0})},n.isRef=function(f){return!!f&&!!f[h.symbols.ref]},d.Ref=class{constructor(f){o(typeof f=="object","Invalid reference construction"),h.assertOptions(f,["adjust","ancestor","in","iterables","map","path","render","separator","type","depth","key","root","display"]),o([!1,void 0].includes(f.separator)||typeof f.separator=="string"&&f.separator.length===1,"Invalid separator"),o(!f.adjust||typeof f.adjust=="function","options.adjust must be a function"),o(!f.map||Array.isArray(f.map),"options.map must be an array"),o(!f.map||!f.adjust,"Cannot set both map and adjust options"),Object.assign(this,d.defaults,f),o(this.type==="value"||this.ancestor===void 0,"Non-value references cannot reference ancestors"),Array.isArray(this.map)&&(this.map=new Map(this.map)),this.depth=this.path.length,this.key=this.path.length?this.path.join(this.separator):null,this.root=this.path[0],this.updateDisplay()}resolve(f,p,m,v,g={}){return o(!this.in||g.in,"Invalid in() reference usage"),this.type==="global"?this._resolve(m.context,p,g):this.type==="local"?this._resolve(v,p,g):this.ancestor?this.ancestor==="root"?this._resolve(p.ancestors[p.ancestors.length-1],p,g):(o(this.ancestor<=p.ancestors.length,"Invalid reference exceeds the schema root:",this.display),this._resolve(p.ancestors[this.ancestor-1],p,g)):this._resolve(f,p,g)}_resolve(f,p,m){let v;if(this.type==="value"&&p.mainstay.shadow&&m.shadow!==!1&&(v=p.mainstay.shadow.get(this.absolute(p))),v===void 0&&(v=u(f,this.path,{iterables:this.iterables,functions:!0})),this.adjust&&(v=this.adjust(v)),this.map){const g=this.map.get(v);g!==void 0&&(v=g)}return p.mainstay&&p.mainstay.tracer.resolve(p,this,v),v}toString(){return this.display}absolute(f){return[...f.path.slice(0,-this.ancestor),...this.path]}clone(){return new d.Ref(this)}describe(){const f={path:this.path};this.type!=="value"&&(f.type=this.type),this.separator!=="."&&(f.separator=this.separator),this.type==="value"&&this.ancestor!==1&&(f.ancestor=this.ancestor),this.map&&(f.map=[...this.map]);for(const p of["adjust","iterables","render"])this[p]!==null&&this[p]!==void 0&&(f[p]=this[p]);return this.in!==!1&&(f.in=!0),{ref:f}}updateDisplay(){const f=this.key!==null?this.key:"";if(this.type!=="value")return void(this.display=`ref:${this.type}:${f}`);if(!this.separator)return void(this.display=`ref:${f}`);if(!this.ancestor)return void(this.display=`ref:${this.separator}${f}`);if(this.ancestor==="root")return void(this.display=`ref:root:${f}`);if(this.ancestor===1)return void(this.display=`ref:${f||".."}`);const p=new Array(this.ancestor+1).fill(this.separator).join("");this.display=`ref:${p}${f||""}`}},d.Ref.prototype[h.symbols.ref]=!0,n.build=function(f){return(f=Object.assign({},d.defaults,f)).type==="value"&&f.ancestor===void 0&&(f.ancestor=1),new d.Ref(f)},d.context=function(f,p,m={}){if(f=f.trim(),m){const v=m.global===void 0?"$":m.global;if(v!==p&&f.startsWith(v))return{key:f.slice(v.length),type:"global"};const g=m.local===void 0?"#":m.local;if(g!==p&&f.startsWith(g))return{key:f.slice(g.length),type:"local"};const y=m.root===void 0?"/":m.root;if(y!==p&&f.startsWith(y))return{key:f.slice(y.length),type:"value",root:!0}}return{key:f,type:"value"}},d.ancestor=function(f,p){if(!p)return[1,0];if(f[0]!==p)return[1,0];if(f[1]!==p)return[0,1];let m=2;for(;f[m]===p;)++m;return[m-1,m]},n.toSibling=0,n.toParent=1,n.Manager=class{constructor(){this.refs=[]}register(f,p){if(f)if(p=p===void 0?n.toParent:p,Array.isArray(f))for(const m of f)this.register(m,p);else if(h.isSchema(f))for(const m of f._refs.refs)m.ancestor-p>=0&&this.refs.push({ancestor:m.ancestor-p,root:m.root});else n.isRef(f)&&f.type==="value"&&f.ancestor-p>=0&&this.refs.push({ancestor:f.ancestor-p,root:f.root}),l=l||a(3328),l.isTemplate(f)&&this.register(f.refs(),p)}get length(){return this.refs.length}clone(){const f=new n.Manager;return f.refs=c(this.refs),f}reset(){this.refs=[]}roots(){return this.refs.filter(f=>!f.ancestor).map(f=>f.root)}}},3378:(i,n,a)=>{const o=a(5107),c={};c.wrap=o.string().min(1).max(2).allow(!1),n.preferences=o.object({allowUnknown:o.boolean(),abortEarly:o.boolean(),artifacts:o.boolean(),cache:o.boolean(),context:o.object(),convert:o.boolean(),dateFormat:o.valid("date","iso","string","time","utc"),debug:o.boolean(),errors:{escapeHtml:o.boolean(),label:o.valid("path","key",!1),language:[o.string(),o.object().ref()],render:o.boolean(),stack:o.boolean(),wrap:{label:c.wrap,array:c.wrap,string:c.wrap}},externals:o.boolean(),messages:o.object(),noDefaults:o.boolean(),nonEnumerables:o.boolean(),presence:o.valid("required","optional","forbidden"),skipFunctions:o.boolean(),stripUnknown:o.object({arrays:o.boolean(),objects:o.boolean()}).or("arrays","objects").allow(!0,!1),warnings:o.boolean()}).strict(),c.nameRx=/^[a-zA-Z0-9]\w*$/,c.rule=o.object({alias:o.array().items(o.string().pattern(c.nameRx)).single(),args:o.array().items(o.string(),o.object({name:o.string().pattern(c.nameRx).required(),ref:o.boolean(),assert:o.alternatives([o.function(),o.object().schema()]).conditional("ref",{is:!0,then:o.required()}),normalize:o.function(),message:o.string().when("assert",{is:o.function(),then:o.required()})})),convert:o.boolean(),manifest:o.boolean(),method:o.function().allow(!1),multi:o.boolean(),validate:o.function()}),n.extension=o.object({type:o.alternatives([o.string(),o.object().regex()]).required(),args:o.function(),cast:o.object().pattern(c.nameRx,o.object({from:o.function().maxArity(1).required(),to:o.function().minArity(1).maxArity(2).required()})),base:o.object().schema().when("type",{is:o.object().regex(),then:o.forbidden()}),coerce:[o.function().maxArity(3),o.object({method:o.function().maxArity(3).required(),from:o.array().items(o.string()).single()})],flags:o.object().pattern(c.nameRx,o.object({setter:o.string(),default:o.any()})),manifest:{build:o.function().arity(2)},messages:[o.object(),o.string()],modifiers:o.object().pattern(c.nameRx,o.function().minArity(1).maxArity(2)),overrides:o.object().pattern(c.nameRx,o.function()),prepare:o.function().maxArity(3),rebuild:o.function().arity(1),rules:o.object().pattern(c.nameRx,c.rule),terms:o.object().pattern(c.nameRx,o.object({init:o.array().allow(null).required(),manifest:o.object().pattern(/.+/,[o.valid("schema","single"),o.object({mapped:o.object({from:o.string().required(),to:o.string().required()}).required()})])})),validate:o.function().maxArity(3)}).strict(),n.extensions=o.array().items(o.object(),o.function().arity(1)).strict(),c.desc={buffer:o.object({buffer:o.string()}),func:o.object({function:o.function().required(),options:{literal:!0}}),override:o.object({override:!0}),ref:o.object({ref:o.object({type:o.valid("value","global","local"),path:o.array().required(),separator:o.string().length(1).allow(!1),ancestor:o.number().min(0).integer().allow("root"),map:o.array().items(o.array().length(2)).min(1),adjust:o.function(),iterables:o.boolean(),in:o.boolean(),render:o.boolean()}).required()}),regex:o.object({regex:o.string().min(3)}),special:o.object({special:o.valid("deep").required()}),template:o.object({template:o.string().required(),options:o.object()}),value:o.object({value:o.alternatives([o.object(),o.array()]).required()})},c.desc.entity=o.alternatives([o.array().items(o.link("...")),o.boolean(),o.function(),o.number(),o.string(),c.desc.buffer,c.desc.func,c.desc.ref,c.desc.regex,c.desc.special,c.desc.template,c.desc.value,o.link("/")]),c.desc.values=o.array().items(null,o.boolean(),o.function(),o.number().allow(1/0,-1/0),o.string().allow(""),o.symbol(),c.desc.buffer,c.desc.func,c.desc.override,c.desc.ref,c.desc.regex,c.desc.template,c.desc.value),c.desc.messages=o.object().pattern(/.+/,[o.string(),c.desc.template,o.object().pattern(/.+/,[o.string(),c.desc.template])]),n.description=o.object({type:o.string().required(),flags:o.object({cast:o.string(),default:o.any(),description:o.string(),empty:o.link("/"),failover:c.desc.entity,id:o.string(),label:o.string(),only:!0,presence:["optional","required","forbidden"],result:["raw","strip"],strip:o.boolean(),unit:o.string()}).unknown(),preferences:{allowUnknown:o.boolean(),abortEarly:o.boolean(),artifacts:o.boolean(),cache:o.boolean(),convert:o.boolean(),dateFormat:["date","iso","string","time","utc"],errors:{escapeHtml:o.boolean(),label:["path","key"],language:[o.string(),c.desc.ref],wrap:{label:c.wrap,array:c.wrap}},externals:o.boolean(),messages:c.desc.messages,noDefaults:o.boolean(),nonEnumerables:o.boolean(),presence:["required","optional","forbidden"],skipFunctions:o.boolean(),stripUnknown:o.object({arrays:o.boolean(),objects:o.boolean()}).or("arrays","objects").allow(!0,!1),warnings:o.boolean()},allow:c.desc.values,invalid:c.desc.values,rules:o.array().min(1).items({name:o.string().required(),args:o.object().min(1),keep:o.boolean(),message:[o.string(),c.desc.messages],warn:o.boolean()}),keys:o.object().pattern(/.*/,o.link("/")),link:c.desc.ref}).pattern(/^[a-z]\w*$/,o.any())},493:(i,n,a)=>{const o=a(8571),c=a(9621),u=a(8160),h={value:Symbol("value")};i.exports=h.State=class{constructor(l,d,f){this.path=l,this.ancestors=d,this.mainstay=f.mainstay,this.schemas=f.schemas,this.debug=null}localize(l,d=null,f=null){const p=new h.State(l,d,this);return f&&p.schemas&&(p.schemas=[h.schemas(f),...p.schemas]),p}nest(l,d){const f=new h.State(this.path,this.ancestors,this);return f.schemas=f.schemas&&[h.schemas(l),...f.schemas],f.debug=d,f}shadow(l,d){this.mainstay.shadow=this.mainstay.shadow||new h.Shadow,this.mainstay.shadow.set(this.path,l,d)}snapshot(){this.mainstay.shadow&&(this._snapshot=o(this.mainstay.shadow.node(this.path))),this.mainstay.snapshot()}restore(){this.mainstay.shadow&&(this.mainstay.shadow.override(this.path,this._snapshot),this._snapshot=void 0),this.mainstay.restore()}commit(){this.mainstay.shadow&&(this.mainstay.shadow.override(this.path,this._snapshot),this._snapshot=void 0),this.mainstay.commit()}},h.schemas=function(l){return u.isSchema(l)?{schema:l}:l},h.Shadow=class{constructor(){this._values=null}set(l,d,f){if(!l.length||f==="strip"&&typeof l[l.length-1]=="number")return;this._values=this._values||new Map;let p=this._values;for(let m=0;m<l.length;++m){const v=l[m];let g=p.get(v);g||(g=new Map,p.set(v,g)),p=g}p[h.value]=d}get(l){const d=this.node(l);if(d)return d[h.value]}node(l){if(this._values)return c(this._values,l,{iterables:!0})}override(l,d){if(!this._values)return;const f=l.slice(0,-1),p=l[l.length-1],m=c(this._values,f,{iterables:!0});d?m.set(p,d):m&&m.delete(p)}}},3328:(i,n,a)=>{const o=a(375),c=a(8571),u=a(5277),h=a(1447),l=a(8160),d=a(6354),f=a(6133),p={symbol:Symbol("template"),opens:new Array(1e3).join("\0"),closes:new Array(1e3).join(""),dateFormat:{date:Date.prototype.toDateString,iso:Date.prototype.toISOString,string:Date.prototype.toString,time:Date.prototype.toTimeString,utc:Date.prototype.toUTCString}};i.exports=p.Template=class{constructor(m,v){if(o(typeof m=="string","Template source must be a string"),o(!m.includes("\0")&&!m.includes(""),"Template source cannot contain reserved control characters"),this.source=m,this.rendered=m,this._template=null,v){const{functions:g,...y}=v;this._settings=Object.keys(y).length?c(y):void 0,this._functions=g,this._functions&&(o(Object.keys(this._functions).every(b=>typeof b=="string"),"Functions keys must be strings"),o(Object.values(this._functions).every(b=>typeof b=="function"),"Functions values must be functions"))}else this._settings=void 0,this._functions=void 0;this._parse()}_parse(){if(!this.source.includes("{"))return;const m=p.encode(this.source),v=p.split(m);let g=!1;const y=[],b=v.shift();b&&y.push(b);for(const k of v){const x=k[0]!=="{",E=x?"}":"}}",T=k.indexOf(E);if(T===-1||k[1]==="{"){y.push(`{${p.decode(k)}`);continue}let w=k.slice(x?0:1,T);const S=w[0]===":";S&&(w=w.slice(1));const _=this._ref(p.decode(w),{raw:x,wrapped:S});y.push(_),typeof _!="string"&&(g=!0);const A=k.slice(T+E.length);A&&y.push(p.decode(A))}g?this._template=y:this.rendered=y.join("")}static date(m,v){return p.dateFormat[v.dateFormat].call(m)}describe(m={}){if(!this._settings&&m.compact)return this.source;const v={template:this.source};return this._settings&&(v.options=this._settings),this._functions&&(v.functions=this._functions),v}static build(m){return new p.Template(m.template,m.options||m.functions?{...m.options,functions:m.functions}:void 0)}isDynamic(){return!!this._template}static isTemplate(m){return!!m&&!!m[l.symbols.template]}refs(){if(!this._template)return;const m=[];for(const v of this._template)typeof v!="string"&&m.push(...v.refs);return m}resolve(m,v,g,y){return this._template&&this._template.length===1?this._part(this._template[0],m,v,g,y,{}):this.render(m,v,g,y)}_part(m,...v){return m.ref?m.ref.resolve(...v):m.formula.evaluate(v)}render(m,v,g,y,b={}){if(!this.isDynamic())return this.rendered;const k=[];for(const x of this._template)if(typeof x=="string")k.push(x);else{const E=this._part(x,m,v,g,y,b),T=p.stringify(E,m,v,g,y,b);if(T!==void 0){const w=x.raw||(b.errors&&b.errors.escapeHtml)===!1?T:u(T);k.push(p.wrap(w,x.wrapped&&g.errors.wrap.label))}}return k.join("")}_ref(m,{raw:v,wrapped:g}){const y=[],b=x=>{const E=f.create(x,this._settings);return y.push(E),T=>{const w=E.resolve(...T);return w!==void 0?w:null}};try{const x=this._functions?{...p.functions,...this._functions}:p.functions;var k=new h.Parser(m,{reference:b,functions:x,constants:p.constants})}catch(x){throw x.message=`Invalid template variable "${m}" fails due to: ${x.message}`,x}if(k.single){if(k.single.type==="reference"){const x=y[0];return{ref:x,raw:v,refs:y,wrapped:g||x.type==="local"&&x.key==="label"}}return p.stringify(k.single.value)}return{formula:k,raw:v,refs:y}}toString(){return this.source}},p.Template.prototype[l.symbols.template]=!0,p.Template.prototype.isImmutable=!0,p.encode=function(m){return m.replace(/\\(\{+)/g,(v,g)=>p.opens.slice(0,g.length)).replace(/\\(\}+)/g,(v,g)=>p.closes.slice(0,g.length))},p.decode=function(m){return m.replace(/\u0000/g,"{").replace(/\u0001/g,"}")},p.split=function(m){const v=[];let g="";for(let y=0;y<m.length;++y){const b=m[y];if(b==="{"){let k="";for(;y+1<m.length&&m[y+1]==="{";)k+="{",++y;v.push(g),g=k}else g+=b}return v.push(g),v},p.wrap=function(m,v){return v?v.length===1?`${v}${m}${v}`:`${v[0]}${m}${v[1]}`:m},p.stringify=function(m,v,g,y,b,k={}){const x=typeof m,E=y&&y.errors&&y.errors.wrap||{};let T=!1;if(f.isRef(m)&&m.render&&(T=m.in,m=m.resolve(v,g,y,b,{in:m.in,...k})),m===null)return"null";if(x==="string")return p.wrap(m,k.arrayItems&&E.string);if(x==="number"||x==="function"||x==="symbol")return m.toString();if(x!=="object")return JSON.stringify(m);if(m instanceof Date)return p.Template.date(m,y);if(m instanceof Map){const S=[];for(const[_,A]of m.entries())S.push(`${_.toString()} -> ${A.toString()}`);m=S}if(!Array.isArray(m))return m.toString();const w=[];for(const S of m)w.push(p.stringify(S,v,g,y,b,{arrayItems:!0,...k}));return p.wrap(w.join(", "),!T&&E.array)},p.constants={true:!0,false:!1,null:null,second:1e3,minute:6e4,hour:36e5,day:864e5},p.functions={if:(m,v,g)=>m?v:g,length:m=>typeof m=="string"?m.length:m&&typeof m=="object"?Array.isArray(m)?m.length:Object.keys(m).length:null,msg(m){const[v,g,y,b,k]=this,x=k.messages;if(!x)return"";const E=d.template(v,x[0],m,g,y)||d.template(v,x[1],m,g,y);return E?E.render(v,g,y,b,k):""},number:m=>typeof m=="number"?m:typeof m=="string"?parseFloat(m):typeof m=="boolean"?m?1:0:m instanceof Date?m.getTime():null}},4946:(i,n,a)=>{const o=a(375),c=a(1687),u=a(8068),h=a(8160),l=a(3292),d=a(6354),f=a(6133),p={};i.exports=u.extend({type:"alternatives",flags:{match:{default:"any"}},terms:{matches:{init:[],register:f.toSibling}},args:(m,...v)=>v.length===1&&Array.isArray(v[0])?m.try(...v[0]):m.try(...v),validate(m,v){const{schema:g,error:y,state:b,prefs:k}=v;if(g._flags.match){const E=[],T=[];for(let S=0;S<g.$_terms.matches.length;++S){const _=g.$_terms.matches[S],A=b.nest(_.schema,`match.${S}`);A.snapshot();const M=_.schema.$_validate(m,A,k);M.errors?(T.push(M.errors),A.restore()):(E.push(M.value),A.commit())}if(E.length===0)return{errors:y("alternatives.any",{details:T.map(S=>d.details(S,{override:!1}))})};if(g._flags.match==="one")return E.length===1?{value:E[0]}:{errors:y("alternatives.one")};if(E.length!==g.$_terms.matches.length)return{errors:y("alternatives.all",{details:T.map(S=>d.details(S,{override:!1}))})};const w=S=>S.$_terms.matches.some(_=>_.schema.type==="object"||_.schema.type==="alternatives"&&w(_.schema));return w(g)?{value:E.reduce((S,_)=>c(S,_,{mergeArrays:!1}))}:{value:E[E.length-1]}}const x=[];for(let E=0;E<g.$_terms.matches.length;++E){const T=g.$_terms.matches[E];if(T.schema){const _=b.nest(T.schema,`match.${E}`);_.snapshot();const A=T.schema.$_validate(m,_,k);if(!A.errors)return _.commit(),A;_.restore(),x.push({schema:T.schema,reports:A.errors});continue}const w=T.ref?T.ref.resolve(m,b,k):m,S=T.is?[T]:T.switch;for(let _=0;_<S.length;++_){const A=S[_],{is:M,then:D,otherwise:W}=A,G=`match.${E}${T.switch?"."+_:""}`;if(M.$_match(w,b.nest(M,`${G}.is`),k)){if(D)return D.$_validate(m,b.nest(D,`${G}.then`),k)}else if(W)return W.$_validate(m,b.nest(W,`${G}.otherwise`),k)}}return p.errors(x,v)},rules:{conditional:{method(m,v){o(!this._flags._endedSwitch,"Unreachable condition"),o(!this._flags.match,"Cannot combine match mode",this._flags.match,"with conditional rule"),o(v.break===void 0,"Cannot use break option with alternatives conditional");const g=this.clone(),y=l.when(g,m,v),b=y.is?[y]:y.switch;for(const k of b)if(k.then&&k.otherwise){g.$_setFlag("_endedSwitch",!0,{clone:!1});break}return g.$_terms.matches.push(y),g.$_mutateRebuild()}},match:{method(m){if(o(["any","one","all"].includes(m),"Invalid alternatives match mode",m),m!=="any")for(const v of this.$_terms.matches)o(v.schema,"Cannot combine match mode",m,"with conditional rules");return this.$_setFlag("match",m)}},try:{method(...m){o(m.length,"Missing alternative schemas"),h.verifyFlat(m,"try"),o(!this._flags._endedSwitch,"Unreachable condition");const v=this.clone();for(const g of m)v.$_terms.matches.push({schema:v.$_compile(g)});return v.$_mutateRebuild()}}},overrides:{label(m){return this.$_parent("label",m).$_modify({each:(v,g)=>g.path[0]!=="is"&&typeof v._flags.label!="string"?v.label(m):void 0,ref:!1})}},rebuild(m){m.$_modify({each:v=>{h.isSchema(v)&&v.type==="array"&&m.$_setFlag("_arrayItems",!0,{clone:!1})}})},manifest:{build(m,v){if(v.matches)for(const g of v.matches){const{schema:y,ref:b,is:k,not:x,then:E,otherwise:T}=g;m=y?m.try(y):b?m.conditional(b,{is:k,then:E,not:x,otherwise:T,switch:g.switch}):m.conditional(k,{then:E,otherwise:T})}return m}},messages:{"alternatives.all":"{{#label}} does not match all of the required types","alternatives.any":"{{#label}} does not match any of the allowed types","alternatives.match":"{{#label}} does not match any of the allowed types","alternatives.one":"{{#label}} matches more than one allowed type","alternatives.types":"{{#label}} must be one of {{#types}}"}}),p.errors=function(m,{error:v,state:g}){if(!m.length)return{errors:v("alternatives.any")};if(m.length===1)return{errors:m[0].reports};const y=new Set,b=[];for(const{reports:k,schema:x}of m){if(k.length>1)return p.unmatched(m,v);const E=k[0];if(E instanceof d.Report==0)return p.unmatched(m,v);if(E.state.path.length!==g.path.length){b.push({type:x.type,report:E});continue}if(E.code==="any.only"){for(const S of E.local.valids)y.add(S);continue}const[T,w]=E.code.split(".");w!=="base"?b.push({type:x.type,report:E}):E.code==="object.base"?y.add(E.local.type):y.add(T)}return b.length?b.length===1?{errors:b[0].report}:p.unmatched(m,v):{errors:v("alternatives.types",{types:[...y]})}},p.unmatched=function(m,v){const g=[];for(const y of m)g.push(...y.reports);return{errors:v("alternatives.match",d.details(g,{override:!1}))}}},8068:(i,n,a)=>{const o=a(375),c=a(7629),u=a(8160),h=a(6914);i.exports=c.extend({type:"any",flags:{only:{default:!1}},terms:{alterations:{init:null},examples:{init:null},externals:{init:null},metas:{init:[]},notes:{init:[]},shared:{init:null},tags:{init:[]},whens:{init:null}},rules:{custom:{method(l,d){return o(typeof l=="function","Method must be a function"),o(d===void 0||d&&typeof d=="string","Description must be a non-empty string"),this.$_addRule({name:"custom",args:{method:l,description:d}})},validate(l,d,{method:f}){try{return f(l,d)}catch(p){return d.error("any.custom",{error:p})}},args:["method","description"],multi:!0},messages:{method(l){return this.prefs({messages:l})}},shared:{method(l){o(u.isSchema(l)&&l._flags.id,"Schema must be a schema with an id");const d=this.clone();return d.$_terms.shared=d.$_terms.shared||[],d.$_terms.shared.push(l),d.$_mutateRegister(l),d}},warning:{method(l,d){return o(l&&typeof l=="string","Invalid warning code"),this.$_addRule({name:"warning",args:{code:l,local:d},warn:!0})},validate:(l,d,{code:f,local:p})=>d.error(f,p),args:["code","local"],multi:!0}},modifiers:{keep(l,d=!0){l.keep=d},message(l,d){l.message=h.compile(d)},warn(l,d=!0){l.warn=d}},manifest:{build(l,d){for(const f in d){const p=d[f];if(["examples","externals","metas","notes","tags"].includes(f))for(const m of p)l=l[f.slice(0,-1)](m);else if(f!=="alterations")if(f!=="whens"){if(f==="shared")for(const m of p)l=l.shared(m)}else for(const m of p){const{ref:v,is:g,not:y,then:b,otherwise:k,concat:x}=m;l=x?l.concat(x):v?l.when(v,{is:g,not:y,then:b,otherwise:k,switch:m.switch,break:m.break}):l.when(g,{then:b,otherwise:k,break:m.break})}else{const m={};for(const{target:v,adjuster:g}of p)m[v]=g;l=l.alter(m)}}return l}},messages:{"any.custom":"{{#label}} failed custom validation because {{#error.message}}","any.default":"{{#label}} threw an error when running default method","any.failover":"{{#label}} threw an error when running failover method","any.invalid":"{{#label}} contains an invalid value","any.only":'{{#label}} must be {if(#valids.length == 1, "", "one of ")}{{#valids}}',"any.ref":"{{#label}} {{#arg}} references {{:#ref}} which {{#reason}}","any.required":"{{#label}} is required","any.unknown":"{{#label}} is not allowed"}})},546:(i,n,a)=>{const o=a(375),c=a(9474),u=a(9621),h=a(8068),l=a(8160),d=a(3292),f={};i.exports=h.extend({type:"array",flags:{single:{default:!1},sparse:{default:!1}},terms:{items:{init:[],manifest:"schema"},ordered:{init:[],manifest:"schema"},_exclusions:{init:[]},_inclusions:{init:[]},_requireds:{init:[]}},coerce:{from:"object",method(p,{schema:m,state:v,prefs:g}){if(!Array.isArray(p))return;const y=m.$_getRule("sort");return y?f.sort(m,p,y.args.options,v,g):void 0}},validate(p,{schema:m,error:v}){if(!Array.isArray(p)){if(m._flags.single){const g=[p];return g[l.symbols.arraySingle]=!0,{value:g}}return{errors:v("array.base")}}if(m.$_getRule("items")||m.$_terms.externals)return{value:p.slice()}},rules:{has:{method(p){p=this.$_compile(p,{appendPath:!0});const m=this.$_addRule({name:"has",args:{schema:p}});return m.$_mutateRegister(p),m},validate(p,{state:m,prefs:v,error:g},{schema:y}){const b=[p,...m.ancestors];for(let x=0;x<p.length;++x){const E=m.localize([...m.path,x],b,y);if(y.$_match(p[x],E,v))return p}const k=y._flags.label;return k?g("array.hasKnown",{patternLabel:k}):g("array.hasUnknown",null)},multi:!0},items:{method(...p){l.verifyFlat(p,"items");const m=this.$_addRule("items");for(let v=0;v<p.length;++v){const g=l.tryWithPath(()=>this.$_compile(p[v]),v,{append:!0});m.$_terms.items.push(g)}return m.$_mutateRebuild()},validate(p,{schema:m,error:v,state:g,prefs:y,errorsArray:b}){const k=m.$_terms._requireds.slice(),x=m.$_terms.ordered.slice(),E=[...m.$_terms._inclusions,...k],T=!p[l.symbols.arraySingle];delete p[l.symbols.arraySingle];const w=b();let S=p.length;for(let _=0;_<S;++_){const A=p[_];let M=!1,D=!1;const W=T?_:new Number(_),G=[...g.path,W];if(!m._flags.sparse&&A===void 0){if(w.push(v("array.sparse",{key:W,path:G,pos:_,value:void 0},g.localize(G))),y.abortEarly)return w;x.shift();continue}const ue=[p,...g.ancestors];for(const z of m.$_terms._exclusions)if(z.$_match(A,g.localize(G,ue,z),y,{presence:"ignore"})){if(w.push(v("array.excludes",{pos:_,value:A},g.localize(G))),y.abortEarly)return w;M=!0,x.shift();break}if(M)continue;if(m.$_terms.ordered.length){if(x.length){const z=x.shift(),te=z.$_validate(A,g.localize(G,ue,z),y);if(te.errors){if(w.push(...te.errors),y.abortEarly)return w}else if(z._flags.result==="strip")f.fastSplice(p,_),--_,--S;else{if(!m._flags.sparse&&te.value===void 0){if(w.push(v("array.sparse",{key:W,path:G,pos:_,value:void 0},g.localize(G))),y.abortEarly)return w;continue}p[_]=te.value}continue}if(!m.$_terms.items.length){if(w.push(v("array.orderedLength",{pos:_,limit:m.$_terms.ordered.length})),y.abortEarly)return w;break}}const re=[];let $=k.length;for(let z=0;z<$;++z){const te=g.localize(G,ue,k[z]);te.snapshot();const he=k[z].$_validate(A,te,y);if(re[z]=he,!he.errors){if(te.commit(),p[_]=he.value,D=!0,f.fastSplice(k,z),--z,--$,!m._flags.sparse&&he.value===void 0&&(w.push(v("array.sparse",{key:W,path:G,pos:_,value:void 0},g.localize(G))),y.abortEarly))return w;break}te.restore()}if(D)continue;const H=y.stripUnknown&&!!y.stripUnknown.arrays||!1;$=E.length;for(const z of E){let te;const he=k.indexOf(z);if(he!==-1)te=re[he];else{const Se=g.localize(G,ue,z);if(Se.snapshot(),te=z.$_validate(A,Se,y),!te.errors){Se.commit(),z._flags.result==="strip"?(f.fastSplice(p,_),--_,--S):m._flags.sparse||te.value!==void 0?p[_]=te.value:(w.push(v("array.sparse",{key:W,path:G,pos:_,value:void 0},g.localize(G))),M=!0),D=!0;break}Se.restore()}if($===1){if(H){f.fastSplice(p,_),--_,--S,D=!0;break}if(w.push(...te.errors),y.abortEarly)return w;M=!0;break}}if(!M&&(m.$_terms._inclusions.length||m.$_terms._requireds.length)&&!D){if(H){f.fastSplice(p,_),--_,--S;continue}if(w.push(v("array.includes",{pos:_,value:A},g.localize(G))),y.abortEarly)return w}}return k.length&&f.fillMissedErrors(m,w,k,p,g,y),x.length&&(f.fillOrderedErrors(m,w,x,p,g,y),w.length||f.fillDefault(x,p,g,y)),w.length?w:p},priority:!0,manifest:!1},length:{method(p){return this.$_addRule({name:"length",args:{limit:p},operator:"="})},validate:(p,m,{limit:v},{name:g,operator:y,args:b})=>l.compare(p.length,v,y)?p:m.error("array."+g,{limit:b.limit,value:p}),args:[{name:"limit",ref:!0,assert:l.limit,message:"must be a positive integer"}]},max:{method(p){return this.$_addRule({name:"max",method:"length",args:{limit:p},operator:"<="})}},min:{method(p){return this.$_addRule({name:"min",method:"length",args:{limit:p},operator:">="})}},ordered:{method(...p){l.verifyFlat(p,"ordered");const m=this.$_addRule("items");for(let v=0;v<p.length;++v){const g=l.tryWithPath(()=>this.$_compile(p[v]),v,{append:!0});f.validateSingle(g,m),m.$_mutateRegister(g),m.$_terms.ordered.push(g)}return m.$_mutateRebuild()}},single:{method(p){const m=p===void 0||!!p;return o(!m||!this._flags._arrayItems,"Cannot specify single rule when array has array items"),this.$_setFlag("single",m)}},sort:{method(p={}){l.assertOptions(p,["by","order"]);const m={order:p.order||"ascending"};return p.by&&(m.by=d.ref(p.by,{ancestor:0}),o(!m.by.ancestor,"Cannot sort by ancestor")),this.$_addRule({name:"sort",args:{options:m}})},validate(p,{error:m,state:v,prefs:g,schema:y},{options:b}){const{value:k,errors:x}=f.sort(y,p,b,v,g);if(x)return x;for(let E=0;E<p.length;++E)if(p[E]!==k[E])return m("array.sort",{order:b.order,by:b.by?b.by.key:"value"});return p},convert:!0},sparse:{method(p){const m=p===void 0||!!p;return this._flags.sparse===m?this:(m?this.clone():this.$_addRule("items")).$_setFlag("sparse",m,{clone:!1})}},unique:{method(p,m={}){o(!p||typeof p=="function"||typeof p=="string","comparator must be a function or a string"),l.assertOptions(m,["ignoreUndefined","separator"]);const v={name:"unique",args:{options:m,comparator:p}};if(p)if(typeof p=="string"){const g=l.default(m.separator,".");v.path=g?p.split(g):[p]}else v.comparator=p;return this.$_addRule(v)},validate(p,{state:m,error:v,schema:g},{comparator:y,options:b},{comparator:k,path:x}){const E={string:Object.create(null),number:Object.create(null),undefined:Object.create(null),boolean:Object.create(null),bigint:Object.create(null),object:new Map,function:new Map,custom:new Map},T=k||c,w=b.ignoreUndefined;for(let S=0;S<p.length;++S){const _=x?u(p[S],x):p[S],A=k?E.custom:E[typeof _];if(o(A,"Failed to find unique map container for type",typeof _),A instanceof Map){const M=A.entries();let D;for(;!(D=M.next()).done;)if(T(D.value[0],_)){const W=m.localize([...m.path,S],[p,...m.ancestors]),G={pos:S,value:p[S],dupePos:D.value[1],dupeValue:p[D.value[1]]};return x&&(G.path=y),v("array.unique",G,W)}A.set(_,S)}else{if((!w||_!==void 0)&&A[_]!==void 0){const M={pos:S,value:p[S],dupePos:A[_],dupeValue:p[A[_]]};return x&&(M.path=y),v("array.unique",M,m.localize([...m.path,S],[p,...m.ancestors]))}A[_]=S}}return p},args:["comparator","options"],multi:!0}},cast:{set:{from:Array.isArray,to:(p,m)=>new Set(p)}},rebuild(p){p.$_terms._inclusions=[],p.$_terms._exclusions=[],p.$_terms._requireds=[];for(const m of p.$_terms.items)f.validateSingle(m,p),m._flags.presence==="required"?p.$_terms._requireds.push(m):m._flags.presence==="forbidden"?p.$_terms._exclusions.push(m):p.$_terms._inclusions.push(m);for(const m of p.$_terms.ordered)f.validateSingle(m,p)},manifest:{build:(p,m)=>(m.items&&(p=p.items(...m.items)),m.ordered&&(p=p.ordered(...m.ordered)),p)},messages:{"array.base":"{{#label}} must be an array","array.excludes":"{{#label}} contains an excluded value","array.hasKnown":"{{#label}} does not contain at least one required match for type {:#patternLabel}","array.hasUnknown":"{{#label}} does not contain at least one required match","array.includes":"{{#label}} does not match any of the allowed types","array.includesRequiredBoth":"{{#label}} does not contain {{#knownMisses}} and {{#unknownMisses}} other required value(s)","array.includesRequiredKnowns":"{{#label}} does not contain {{#knownMisses}}","array.includesRequiredUnknowns":"{{#label}} does not contain {{#unknownMisses}} required value(s)","array.length":"{{#label}} must contain {{#limit}} items","array.max":"{{#label}} must contain less than or equal to {{#limit}} items","array.min":"{{#label}} must contain at least {{#limit}} items","array.orderedLength":"{{#label}} must contain at most {{#limit}} items","array.sort":"{{#label}} must be sorted in {#order} order by {{#by}}","array.sort.mismatching":"{{#label}} cannot be sorted due to mismatching types","array.sort.unsupported":"{{#label}} cannot be sorted due to unsupported type {#type}","array.sparse":"{{#label}} must not be a sparse array item","array.unique":"{{#label}} contains a duplicate value"}}),f.fillMissedErrors=function(p,m,v,g,y,b){const k=[];let x=0;for(const E of v){const T=E._flags.label;T?k.push(T):++x}k.length?x?m.push(p.$_createError("array.includesRequiredBoth",g,{knownMisses:k,unknownMisses:x},y,b)):m.push(p.$_createError("array.includesRequiredKnowns",g,{knownMisses:k},y,b)):m.push(p.$_createError("array.includesRequiredUnknowns",g,{unknownMisses:x},y,b))},f.fillOrderedErrors=function(p,m,v,g,y,b){const k=[];for(const x of v)x._flags.presence==="required"&&k.push(x);k.length&&f.fillMissedErrors(p,m,k,g,y,b)},f.fillDefault=function(p,m,v,g){const y=[];let b=!0;for(let k=p.length-1;k>=0;--k){const x=p[k],E=[m,...v.ancestors],T=x.$_validate(void 0,v.localize(v.path,E,x),g).value;if(b){if(T===void 0)continue;b=!1}y.unshift(T)}y.length&&m.push(...y)},f.fastSplice=function(p,m){let v=m;for(;v<p.length;)p[v++]=p[v];--p.length},f.validateSingle=function(p,m){(p.type==="array"||p._flags._arrayItems)&&(o(!m._flags.single,"Cannot specify array item with single rule enabled"),m.$_setFlag("_arrayItems",!0,{clone:!1}))},f.sort=function(p,m,v,g,y){const b=v.order==="ascending"?1:-1,k=-1*b,x=b,E=(T,w)=>{let S=f.compare(T,w,k,x);if(S!==null||(v.by&&(T=v.by.resolve(T,g,y),w=v.by.resolve(w,g,y)),S=f.compare(T,w,k,x),S!==null))return S;const _=typeof T;if(_!==typeof w)throw p.$_createError("array.sort.mismatching",m,null,g,y);if(_!=="number"&&_!=="string")throw p.$_createError("array.sort.unsupported",m,{type:_},g,y);return _==="number"?(T-w)*b:T<w?k:x};try{return{value:m.slice().sort(E)}}catch(T){return{errors:T}}},f.compare=function(p,m,v,g){return p===m?0:p===void 0?1:m===void 0?-1:p===null?g:m===null?v:null}},4937:(i,n,a)=>{const o=a(375),c=a(8068),u=a(8160),h=a(2036),l={isBool:function(d){return typeof d=="boolean"}};i.exports=c.extend({type:"boolean",flags:{sensitive:{default:!1}},terms:{falsy:{init:null,manifest:"values"},truthy:{init:null,manifest:"values"}},coerce(d,{schema:f}){if(typeof d!="boolean"){if(typeof d=="string"){const p=f._flags.sensitive?d:d.toLowerCase();d=p==="true"||p!=="false"&&d}return typeof d!="boolean"&&(d=f.$_terms.truthy&&f.$_terms.truthy.has(d,null,null,!f._flags.sensitive)||(!f.$_terms.falsy||!f.$_terms.falsy.has(d,null,null,!f._flags.sensitive))&&d),{value:d}}},validate(d,{error:f}){if(typeof d!="boolean")return{value:d,errors:f("boolean.base")}},rules:{truthy:{method(...d){u.verifyFlat(d,"truthy");const f=this.clone();f.$_terms.truthy=f.$_terms.truthy||new h;for(let p=0;p<d.length;++p){const m=d[p];o(m!==void 0,"Cannot call truthy with undefined"),f.$_terms.truthy.add(m)}return f}},falsy:{method(...d){u.verifyFlat(d,"falsy");const f=this.clone();f.$_terms.falsy=f.$_terms.falsy||new h;for(let p=0;p<d.length;++p){const m=d[p];o(m!==void 0,"Cannot call falsy with undefined"),f.$_terms.falsy.add(m)}return f}},sensitive:{method(d=!0){return this.$_setFlag("sensitive",d)}}},cast:{number:{from:l.isBool,to:(d,f)=>d?1:0},string:{from:l.isBool,to:(d,f)=>d?"true":"false"}},manifest:{build:(d,f)=>(f.truthy&&(d=d.truthy(...f.truthy)),f.falsy&&(d=d.falsy(...f.falsy)),d)},messages:{"boolean.base":"{{#label}} must be a boolean"}})},7500:(i,n,a)=>{const o=a(375),c=a(8068),u=a(8160),h=a(3328),l={isDate:function(d){return d instanceof Date}};i.exports=c.extend({type:"date",coerce:{from:["number","string"],method:(d,{schema:f})=>({value:l.parse(d,f._flags.format)||d})},validate(d,{schema:f,error:p,prefs:m}){if(d instanceof Date&&!isNaN(d.getTime()))return;const v=f._flags.format;return m.convert&&v&&typeof d=="string"?{value:d,errors:p("date.format",{format:v})}:{value:d,errors:p("date.base")}},rules:{compare:{method:!1,validate(d,f,{date:p},{name:m,operator:v,args:g}){const y=p==="now"?Date.now():p.getTime();return u.compare(d.getTime(),y,v)?d:f.error("date."+m,{limit:g.date,value:d})},args:[{name:"date",ref:!0,normalize:d=>d==="now"?d:l.parse(d),assert:d=>d!==null,message:"must have a valid date format"}]},format:{method(d){return o(["iso","javascript","unix"].includes(d),"Unknown date format",d),this.$_setFlag("format",d)}},greater:{method(d){return this.$_addRule({name:"greater",method:"compare",args:{date:d},operator:">"})}},iso:{method(){return this.format("iso")}},less:{method(d){return this.$_addRule({name:"less",method:"compare",args:{date:d},operator:"<"})}},max:{method(d){return this.$_addRule({name:"max",method:"compare",args:{date:d},operator:"<="})}},min:{method(d){return this.$_addRule({name:"min",method:"compare",args:{date:d},operator:">="})}},timestamp:{method(d="javascript"){return o(["javascript","unix"].includes(d),'"type" must be one of "javascript, unix"'),this.format(d)}}},cast:{number:{from:l.isDate,to:(d,f)=>d.getTime()},string:{from:l.isDate,to:(d,{prefs:f})=>h.date(d,f)}},messages:{"date.base":"{{#label}} must be a valid date","date.format":'{{#label}} must be in {msg("date.format." + #format) || #format} format',"date.greater":"{{#label}} must be greater than {{:#limit}}","date.less":"{{#label}} must be less than {{:#limit}}","date.max":"{{#label}} must be less than or equal to {{:#limit}}","date.min":"{{#label}} must be greater than or equal to {{:#limit}}","date.format.iso":"ISO 8601 date","date.format.javascript":"timestamp or number of milliseconds","date.format.unix":"timestamp or number of seconds"}}),l.parse=function(d,f){if(d instanceof Date)return d;if(typeof d!="string"&&(isNaN(d)||!isFinite(d))||/^\s*$/.test(d))return null;if(f==="iso")return u.isIsoDate(d)?l.date(d.toString()):null;const p=d;if(typeof d=="string"&&/^[+-]?\d+(\.\d+)?$/.test(d)&&(d=parseFloat(d)),f){if(f==="javascript")return l.date(1*d);if(f==="unix")return l.date(1e3*d);if(typeof p=="string")return null}return l.date(d)},l.date=function(d){const f=new Date(d);return isNaN(f.getTime())?null:f}},390:(i,n,a)=>{const o=a(375),c=a(7824);i.exports=c.extend({type:"function",properties:{typeof:"function"},rules:{arity:{method(u){return o(Number.isSafeInteger(u)&&u>=0,"n must be a positive integer"),this.$_addRule({name:"arity",args:{n:u}})},validate:(u,h,{n:l})=>u.length===l?u:h.error("function.arity",{n:l})},class:{method(){return this.$_addRule("class")},validate:(u,h)=>/^\s*class\s/.test(u.toString())?u:h.error("function.class",{value:u})},minArity:{method(u){return o(Number.isSafeInteger(u)&&u>0,"n must be a strict positive integer"),this.$_addRule({name:"minArity",args:{n:u}})},validate:(u,h,{n:l})=>u.length>=l?u:h.error("function.minArity",{n:l})},maxArity:{method(u){return o(Number.isSafeInteger(u)&&u>=0,"n must be a positive integer"),this.$_addRule({name:"maxArity",args:{n:u}})},validate:(u,h,{n:l})=>u.length<=l?u:h.error("function.maxArity",{n:l})}},messages:{"function.arity":"{{#label}} must have an arity of {{#n}}","function.class":"{{#label}} must be a class","function.maxArity":"{{#label}} must have an arity lesser or equal to {{#n}}","function.minArity":"{{#label}} must have an arity greater or equal to {{#n}}"}})},7824:(i,n,a)=>{const o=a(978),c=a(375),u=a(8571),h=a(3652),l=a(8068),d=a(8160),f=a(3292),p=a(6354),m=a(6133),v=a(3328),g={renameDefaults:{alias:!1,multiple:!1,override:!1}};i.exports=l.extend({type:"_keys",properties:{typeof:"object"},flags:{unknown:{default:void 0}},terms:{dependencies:{init:null},keys:{init:null,manifest:{mapped:{from:"schema",to:"key"}}},patterns:{init:null},renames:{init:null}},args:(y,b)=>y.keys(b),validate(y,{schema:b,error:k,state:x,prefs:E}){if(!y||typeof y!==b.$_property("typeof")||Array.isArray(y))return{value:y,errors:k("object.base",{type:b.$_property("typeof")})};if(!(b.$_terms.renames||b.$_terms.dependencies||b.$_terms.keys||b.$_terms.patterns||b.$_terms.externals))return;y=g.clone(y,E);const T=[];if(b.$_terms.renames&&!g.rename(b,y,x,E,T))return{value:y,errors:T};if(!b.$_terms.keys&&!b.$_terms.patterns&&!b.$_terms.dependencies)return{value:y,errors:T};const w=new Set(Object.keys(y));if(b.$_terms.keys){const S=[y,...x.ancestors];for(const _ of b.$_terms.keys){const A=_.key,M=y[A];w.delete(A);const D=x.localize([...x.path,A],S,_),W=_.schema.$_validate(M,D,E);if(W.errors){if(E.abortEarly)return{value:y,errors:W.errors};W.value!==void 0&&(y[A]=W.value),T.push(...W.errors)}else _.schema._flags.result==="strip"||W.value===void 0&&M!==void 0?delete y[A]:W.value!==void 0&&(y[A]=W.value)}}if(w.size||b._flags._hasPatternMatch){const S=g.unknown(b,y,w,T,x,E);if(S)return S}if(b.$_terms.dependencies)for(const S of b.$_terms.dependencies){if(S.key!==null&&g.isPresent(S.options)(S.key.resolve(y,x,E,null,{shadow:!1}))===!1)continue;const _=g.dependencies[S.rel](b,S,y,x,E);if(_){const A=b.$_createError(_.code,y,_.context,x,E);if(E.abortEarly)return{value:y,errors:A};T.push(A)}}return{value:y,errors:T}},rules:{and:{method(...y){return d.verifyFlat(y,"and"),g.dependency(this,"and",null,y)}},append:{method(y){return y==null||Object.keys(y).length===0?this:this.keys(y)}},assert:{method(y,b,k){v.isTemplate(y)||(y=f.ref(y)),c(k===void 0||typeof k=="string","Message must be a string"),b=this.$_compile(b,{appendPath:!0});const x=this.$_addRule({name:"assert",args:{subject:y,schema:b,message:k}});return x.$_mutateRegister(y),x.$_mutateRegister(b),x},validate(y,{error:b,prefs:k,state:x},{subject:E,schema:T,message:w}){const S=E.resolve(y,x,k),_=m.isRef(E)?E.absolute(x):[];return T.$_match(S,x.localize(_,[y,...x.ancestors],T),k)?y:b("object.assert",{subject:E,message:w})},args:["subject","schema","message"],multi:!0},instance:{method(y,b){return c(typeof y=="function","constructor must be a function"),b=b||y.name,this.$_addRule({name:"instance",args:{constructor:y,name:b}})},validate:(y,b,{constructor:k,name:x})=>y instanceof k?y:b.error("object.instance",{type:x,value:y}),args:["constructor","name"]},keys:{method(y){c(y===void 0||typeof y=="object","Object schema must be a valid object"),c(!d.isSchema(y),"Object schema cannot be a joi schema");const b=this.clone();if(y)if(Object.keys(y).length){b.$_terms.keys=b.$_terms.keys?b.$_terms.keys.filter(k=>!y.hasOwnProperty(k.key)):new g.Keys;for(const k in y)d.tryWithPath(()=>b.$_terms.keys.push({key:k,schema:this.$_compile(y[k])}),k)}else b.$_terms.keys=new g.Keys;else b.$_terms.keys=null;return b.$_mutateRebuild()}},length:{method(y){return this.$_addRule({name:"length",args:{limit:y},operator:"="})},validate:(y,b,{limit:k},{name:x,operator:E,args:T})=>d.compare(Object.keys(y).length,k,E)?y:b.error("object."+x,{limit:T.limit,value:y}),args:[{name:"limit",ref:!0,assert:d.limit,message:"must be a positive integer"}]},max:{method(y){return this.$_addRule({name:"max",method:"length",args:{limit:y},operator:"<="})}},min:{method(y){return this.$_addRule({name:"min",method:"length",args:{limit:y},operator:">="})}},nand:{method(...y){return d.verifyFlat(y,"nand"),g.dependency(this,"nand",null,y)}},or:{method(...y){return d.verifyFlat(y,"or"),g.dependency(this,"or",null,y)}},oxor:{method(...y){return g.dependency(this,"oxor",null,y)}},pattern:{method(y,b,k={}){const x=y instanceof RegExp;x||(y=this.$_compile(y,{appendPath:!0})),c(b!==void 0,"Invalid rule"),d.assertOptions(k,["fallthrough","matches"]),x&&c(!y.flags.includes("g")&&!y.flags.includes("y"),"pattern should not use global or sticky mode"),b=this.$_compile(b,{appendPath:!0});const E=this.clone();E.$_terms.patterns=E.$_terms.patterns||[];const T={[x?"regex":"schema"]:y,rule:b};return k.matches&&(T.matches=this.$_compile(k.matches),T.matches.type!=="array"&&(T.matches=T.matches.$_root.array().items(T.matches)),E.$_mutateRegister(T.matches),E.$_setFlag("_hasPatternMatch",!0,{clone:!1})),k.fallthrough&&(T.fallthrough=!0),E.$_terms.patterns.push(T),E.$_mutateRegister(b),E}},ref:{method(){return this.$_addRule("ref")},validate:(y,b)=>m.isRef(y)?y:b.error("object.refType",{value:y})},regex:{method(){return this.$_addRule("regex")},validate:(y,b)=>y instanceof RegExp?y:b.error("object.regex",{value:y})},rename:{method(y,b,k={}){c(typeof y=="string"||y instanceof RegExp,"Rename missing the from argument"),c(typeof b=="string"||b instanceof v,"Invalid rename to argument"),c(b!==y,"Cannot rename key to same name:",y),d.assertOptions(k,["alias","ignoreUndefined","override","multiple"]);const x=this.clone();x.$_terms.renames=x.$_terms.renames||[];for(const E of x.$_terms.renames)c(E.from!==y,"Cannot rename the same key multiple times");return b instanceof v&&x.$_mutateRegister(b),x.$_terms.renames.push({from:y,to:b,options:o(g.renameDefaults,k)}),x}},schema:{method(y="any"){return this.$_addRule({name:"schema",args:{type:y}})},validate:(y,b,{type:k})=>!d.isSchema(y)||k!=="any"&&y.type!==k?b.error("object.schema",{type:k}):y},unknown:{method(y){return this.$_setFlag("unknown",y!==!1)}},with:{method(y,b,k={}){return g.dependency(this,"with",y,b,k)}},without:{method(y,b,k={}){return g.dependency(this,"without",y,b,k)}},xor:{method(...y){return d.verifyFlat(y,"xor"),g.dependency(this,"xor",null,y)}}},overrides:{default(y,b){return y===void 0&&(y=d.symbols.deepDefault),this.$_parent("default",y,b)}},rebuild(y){if(y.$_terms.keys){const b=new h.Sorter;for(const k of y.$_terms.keys)d.tryWithPath(()=>b.add(k,{after:k.schema.$_rootReferences(),group:k.key}),k.key);y.$_terms.keys=new g.Keys(...b.nodes)}},manifest:{build(y,b){if(b.keys&&(y=y.keys(b.keys)),b.dependencies)for(const{rel:k,key:x=null,peers:E,options:T}of b.dependencies)y=g.dependency(y,k,x,E,T);if(b.patterns)for(const{regex:k,schema:x,rule:E,fallthrough:T,matches:w}of b.patterns)y=y.pattern(k||x,E,{fallthrough:T,matches:w});if(b.renames)for(const{from:k,to:x,options:E}of b.renames)y=y.rename(k,x,E);return y}},messages:{"object.and":"{{#label}} contains {{#presentWithLabels}} without its required peers {{#missingWithLabels}}","object.assert":'{{#label}} is invalid because {if(#subject.key, `"` + #subject.key + `" failed to ` + (#message || "pass the assertion test"), #message || "the assertion failed")}',"object.base":"{{#label}} must be of type {{#type}}","object.instance":"{{#label}} must be an instance of {{:#type}}","object.length":'{{#label}} must have {{#limit}} key{if(#limit == 1, "", "s")}',"object.max":'{{#label}} must have less than or equal to {{#limit}} key{if(#limit == 1, "", "s")}',"object.min":'{{#label}} must have at least {{#limit}} key{if(#limit == 1, "", "s")}',"object.missing":"{{#label}} must contain at least one of {{#peersWithLabels}}","object.nand":"{{:#mainWithLabel}} must not exist simultaneously with {{#peersWithLabels}}","object.oxor":"{{#label}} contains a conflict between optional exclusive peers {{#peersWithLabels}}","object.pattern.match":"{{#label}} keys failed to match pattern requirements","object.refType":"{{#label}} must be a Joi reference","object.regex":"{{#label}} must be a RegExp object","object.rename.multiple":"{{#label}} cannot rename {{:#from}} because multiple renames are disabled and another key was already renamed to {{:#to}}","object.rename.override":"{{#label}} cannot rename {{:#from}} because override is disabled and target {{:#to}} exists","object.schema":"{{#label}} must be a Joi schema of {{#type}} type","object.unknown":"{{#label}} is not allowed","object.with":"{{:#mainWithLabel}} missing required peer {{:#peerWithLabel}}","object.without":"{{:#mainWithLabel}} conflict with forbidden peer {{:#peerWithLabel}}","object.xor":"{{#label}} contains a conflict between exclusive peers {{#peersWithLabels}}"}}),g.clone=function(y,b){if(typeof y=="object"){if(b.nonEnumerables)return u(y,{shallow:!0});const x=Object.create(Object.getPrototypeOf(y));return Object.assign(x,y),x}const k=function(...x){return y.apply(this,x)};return k.prototype=u(y.prototype),Object.defineProperty(k,"name",{value:y.name,writable:!1}),Object.defineProperty(k,"length",{value:y.length,writable:!1}),Object.assign(k,y),k},g.dependency=function(y,b,k,x,E){c(k===null||typeof k=="string",b,"key must be a strings"),E||(E=x.length>1&&typeof x[x.length-1]=="object"?x.pop():{}),d.assertOptions(E,["separator","isPresent"]),x=[].concat(x);const T=d.default(E.separator,"."),w=[];for(const _ of x)c(typeof _=="string",b,"peers must be strings"),w.push(f.ref(_,{separator:T,ancestor:0,prefix:!1}));k!==null&&(k=f.ref(k,{separator:T,ancestor:0,prefix:!1}));const S=y.clone();return S.$_terms.dependencies=S.$_terms.dependencies||[],S.$_terms.dependencies.push(new g.Dependency(b,k,w,x,E)),S},g.dependencies={and(y,b,k,x,E){const T=[],w=[],S=b.peers.length,_=g.isPresent(b.options);for(const A of b.peers)_(A.resolve(k,x,E,null,{shadow:!1}))===!1?T.push(A.key):w.push(A.key);if(T.length!==S&&w.length!==S)return{code:"object.and",context:{present:w,presentWithLabels:g.keysToLabels(y,w),missing:T,missingWithLabels:g.keysToLabels(y,T)}}},nand(y,b,k,x,E){const T=[],w=g.isPresent(b.options);for(const A of b.peers)w(A.resolve(k,x,E,null,{shadow:!1}))&&T.push(A.key);if(T.length!==b.peers.length)return;const S=b.paths[0],_=b.paths.slice(1);return{code:"object.nand",context:{main:S,mainWithLabel:g.keysToLabels(y,S),peers:_,peersWithLabels:g.keysToLabels(y,_)}}},or(y,b,k,x,E){const T=g.isPresent(b.options);for(const w of b.peers)if(T(w.resolve(k,x,E,null,{shadow:!1})))return;return{code:"object.missing",context:{peers:b.paths,peersWithLabels:g.keysToLabels(y,b.paths)}}},oxor(y,b,k,x,E){const T=[],w=g.isPresent(b.options);for(const _ of b.peers)w(_.resolve(k,x,E,null,{shadow:!1}))&&T.push(_.key);if(!T.length||T.length===1)return;const S={peers:b.paths,peersWithLabels:g.keysToLabels(y,b.paths)};return S.present=T,S.presentWithLabels=g.keysToLabels(y,T),{code:"object.oxor",context:S}},with(y,b,k,x,E){const T=g.isPresent(b.options);for(const w of b.peers)if(T(w.resolve(k,x,E,null,{shadow:!1}))===!1)return{code:"object.with",context:{main:b.key.key,mainWithLabel:g.keysToLabels(y,b.key.key),peer:w.key,peerWithLabel:g.keysToLabels(y,w.key)}}},without(y,b,k,x,E){const T=g.isPresent(b.options);for(const w of b.peers)if(T(w.resolve(k,x,E,null,{shadow:!1})))return{code:"object.without",context:{main:b.key.key,mainWithLabel:g.keysToLabels(y,b.key.key),peer:w.key,peerWithLabel:g.keysToLabels(y,w.key)}}},xor(y,b,k,x,E){const T=[],w=g.isPresent(b.options);for(const _ of b.peers)w(_.resolve(k,x,E,null,{shadow:!1}))&&T.push(_.key);if(T.length===1)return;const S={peers:b.paths,peersWithLabels:g.keysToLabels(y,b.paths)};return T.length===0?{code:"object.missing",context:S}:(S.present=T,S.presentWithLabels=g.keysToLabels(y,T),{code:"object.xor",context:S})}},g.keysToLabels=function(y,b){return Array.isArray(b)?b.map(k=>y.$_mapLabels(k)):y.$_mapLabels(b)},g.isPresent=function(y){return typeof y.isPresent=="function"?y.isPresent:b=>b!==void 0},g.rename=function(y,b,k,x,E){const T={};for(const w of y.$_terms.renames){const S=[],_=typeof w.from!="string";if(_)for(const A in b){if(b[A]===void 0&&w.options.ignoreUndefined||A===w.to)continue;const M=w.from.exec(A);M&&S.push({from:A,to:w.to,match:M})}else!Object.prototype.hasOwnProperty.call(b,w.from)||b[w.from]===void 0&&w.options.ignoreUndefined||S.push(w);for(const A of S){const M=A.from;let D=A.to;if(D instanceof v&&(D=D.render(b,k,x,A.match)),M!==D){if(!w.options.multiple&&T[D]&&(E.push(y.$_createError("object.rename.multiple",b,{from:M,to:D,pattern:_},k,x)),x.abortEarly)||Object.prototype.hasOwnProperty.call(b,D)&&!w.options.override&&!T[D]&&(E.push(y.$_createError("object.rename.override",b,{from:M,to:D,pattern:_},k,x)),x.abortEarly))return!1;b[M]===void 0?delete b[D]:b[D]=b[M],T[D]=!0,w.options.alias||delete b[M]}}}return!0},g.unknown=function(y,b,k,x,E,T){if(y.$_terms.patterns){let w=!1;const S=y.$_terms.patterns.map(A=>{if(A.matches)return w=!0,[]}),_=[b,...E.ancestors];for(const A of k){const M=b[A],D=[...E.path,A];for(let W=0;W<y.$_terms.patterns.length;++W){const G=y.$_terms.patterns[W];if(G.regex){const $=G.regex.test(A);if(E.mainstay.tracer.debug(E,"rule",`pattern.${W}`,$?"pass":"error"),!$)continue}else if(!G.schema.$_match(A,E.nest(G.schema,`pattern.${W}`),T))continue;k.delete(A);const ue=E.localize(D,_,{schema:G.rule,key:A}),re=G.rule.$_validate(M,ue,T);if(re.errors){if(T.abortEarly)return{value:b,errors:re.errors};x.push(...re.errors)}if(G.matches&&S[W].push(A),b[A]=re.value,!G.fallthrough)break}}if(w)for(let A=0;A<S.length;++A){const M=S[A];if(!M)continue;const D=y.$_terms.patterns[A].matches,W=E.localize(E.path,_,D),G=D.$_validate(M,W,T);if(G.errors){const ue=p.details(G.errors,{override:!1});ue.matches=M;const re=y.$_createError("object.pattern.match",b,ue,E,T);if(T.abortEarly)return{value:b,errors:re};x.push(re)}}}if(k.size&&(y.$_terms.keys||y.$_terms.patterns)){if(T.stripUnknown&&y._flags.unknown===void 0||T.skipFunctions){const w=!(!T.stripUnknown||T.stripUnknown!==!0&&!T.stripUnknown.objects);for(const S of k)w?(delete b[S],k.delete(S)):typeof b[S]=="function"&&k.delete(S)}if(!d.default(y._flags.unknown,T.allowUnknown))for(const w of k){const S=E.localize([...E.path,w],[]),_=y.$_createError("object.unknown",b[w],{child:w},S,T,{flags:!1});if(T.abortEarly)return{value:b,errors:_};x.push(_)}}},g.Dependency=class{constructor(y,b,k,x,E){this.rel=y,this.key=b,this.peers=k,this.paths=x,this.options=E}describe(){const y={rel:this.rel,peers:this.paths};return this.key!==null&&(y.key=this.key.key),this.peers[0].separator!=="."&&(y.options={...y.options,separator:this.peers[0].separator}),this.options.isPresent&&(y.options={...y.options,isPresent:this.options.isPresent}),y}},g.Keys=class extends Array{concat(y){const b=this.slice(),k=new Map;for(let x=0;x<b.length;++x)k.set(b[x].key,x);for(const x of y){const E=x.key,T=k.get(E);T!==void 0?b[T]={key:E,schema:b[T].schema.concat(x.schema)}:b.push(x)}return b}}},8785:(i,n,a)=>{const o=a(375),c=a(8068),u=a(8160),h=a(3292),l=a(6354),d={};i.exports=c.extend({type:"link",properties:{schemaChain:!0},terms:{link:{init:null,manifest:"single",register:!1}},args:(f,p)=>f.ref(p),validate(f,{schema:p,state:m,prefs:v}){o(p.$_terms.link,"Uninitialized link schema");const g=d.generate(p,f,m,v),y=p.$_terms.link[0].ref;return g.$_validate(f,m.nest(g,`link:${y.display}:${g.type}`),v)},generate:(f,p,m,v)=>d.generate(f,p,m,v),rules:{ref:{method(f){o(!this.$_terms.link,"Cannot reinitialize schema"),f=h.ref(f),o(f.type==="value"||f.type==="local","Invalid reference type:",f.type),o(f.type==="local"||f.ancestor==="root"||f.ancestor>0,"Link cannot reference itself");const p=this.clone();return p.$_terms.link=[{ref:f}],p}},relative:{method(f=!0){return this.$_setFlag("relative",f)}}},overrides:{concat(f){o(this.$_terms.link,"Uninitialized link schema"),o(u.isSchema(f),"Invalid schema object"),o(f.type!=="link","Cannot merge type link with another link");const p=this.clone();return p.$_terms.whens||(p.$_terms.whens=[]),p.$_terms.whens.push({concat:f}),p.$_mutateRebuild()}},manifest:{build:(f,p)=>(o(p.link,"Invalid link description missing link"),f.ref(p.link))}}),d.generate=function(f,p,m,v){let g=m.mainstay.links.get(f);if(g)return g._generate(p,m,v).schema;const y=f.$_terms.link[0].ref,{perspective:b,path:k}=d.perspective(y,m);d.assert(b,"which is outside of schema boundaries",y,f,m,v);try{g=k.length?b.$_reach(k):b}catch{d.assert(!1,"to non-existing schema",y,f,m,v)}return d.assert(g.type!=="link","which is another link",y,f,m,v),f._flags.relative||m.mainstay.links.set(f,g),g._generate(p,m,v).schema},d.perspective=function(f,p){if(f.type==="local"){for(const{schema:m,key:v}of p.schemas){if((m._flags.id||v)===f.path[0])return{perspective:m,path:f.path.slice(1)};if(m.$_terms.shared){for(const g of m.$_terms.shared)if(g._flags.id===f.path[0])return{perspective:g,path:f.path.slice(1)}}}return{perspective:null,path:null}}return f.ancestor==="root"?{perspective:p.schemas[p.schemas.length-1].schema,path:f.path}:{perspective:p.schemas[f.ancestor]&&p.schemas[f.ancestor].schema,path:f.path}},d.assert=function(f,p,m,v,g,y){f||o(!1,`"${l.label(v._flags,g,y)}" contains link reference "${m.display}" ${p}`)}},3832:(i,n,a)=>{const o=a(375),c=a(8068),u=a(8160),h={numberRx:/^\s*[+-]?(?:(?:\d+(?:\.\d*)?)|(?:\.\d+))(?:e([+-]?\d+))?\s*$/i,precisionRx:/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/,exponentialPartRegex:/[eE][+-]?\d+$/,leadingSignAndZerosRegex:/^[+-]?(0*)?/,dotRegex:/\./,trailingZerosRegex:/0+$/,decimalPlaces(l){const d=l.toString(),f=d.indexOf("."),p=d.indexOf("e");return(f<0?0:(p<0?d.length:p)-f-1)+(p<0?0:Math.max(0,-parseInt(d.slice(p+1))))}};i.exports=c.extend({type:"number",flags:{unsafe:{default:!1}},coerce:{from:"string",method(l,{schema:d,error:f}){if(!l.match(h.numberRx))return;l=l.trim();const p={value:parseFloat(l)};if(p.value===0&&(p.value=0),!d._flags.unsafe)if(l.match(/e/i)){if(h.extractSignificantDigits(l)!==h.extractSignificantDigits(String(p.value)))return p.errors=f("number.unsafe"),p}else{const m=p.value.toString();if(m.match(/e/i))return p;if(m!==h.normalizeDecimal(l))return p.errors=f("number.unsafe"),p}return p}},validate(l,{schema:d,error:f,prefs:p}){if(l===1/0||l===-1/0)return{value:l,errors:f("number.infinity")};if(!u.isNumber(l))return{value:l,errors:f("number.base")};const m={value:l};if(p.convert){const v=d.$_getRule("precision");if(v){const g=Math.pow(10,v.args.limit);m.value=Math.round(m.value*g)/g}}return m.value===0&&(m.value=0),!d._flags.unsafe&&(l>Number.MAX_SAFE_INTEGER||l<Number.MIN_SAFE_INTEGER)&&(m.errors=f("number.unsafe")),m},rules:{compare:{method:!1,validate:(l,d,{limit:f},{name:p,operator:m,args:v})=>u.compare(l,f,m)?l:d.error("number."+p,{limit:v.limit,value:l}),args:[{name:"limit",ref:!0,assert:u.isNumber,message:"must be a number"}]},greater:{method(l){return this.$_addRule({name:"greater",method:"compare",args:{limit:l},operator:">"})}},integer:{method(){return this.$_addRule("integer")},validate:(l,d)=>Math.trunc(l)-l==0?l:d.error("number.integer")},less:{method(l){return this.$_addRule({name:"less",method:"compare",args:{limit:l},operator:"<"})}},max:{method(l){return this.$_addRule({name:"max",method:"compare",args:{limit:l},operator:"<="})}},min:{method(l){return this.$_addRule({name:"min",method:"compare",args:{limit:l},operator:">="})}},multiple:{method(l){const d=typeof l=="number"?h.decimalPlaces(l):null,f=Math.pow(10,d);return this.$_addRule({name:"multiple",args:{base:l,baseDecimalPlace:d,pfactor:f}})},validate:(l,d,{base:f,baseDecimalPlace:p,pfactor:m},v)=>h.decimalPlaces(l)>p?d.error("number.multiple",{multiple:v.args.base,value:l}):Math.round(m*l)%Math.round(m*f)==0?l:d.error("number.multiple",{multiple:v.args.base,value:l}),args:[{name:"base",ref:!0,assert:l=>typeof l=="number"&&isFinite(l)&&l>0,message:"must be a positive number"},"baseDecimalPlace","pfactor"],multi:!0},negative:{method(){return this.sign("negative")}},port:{method(){return this.$_addRule("port")},validate:(l,d)=>Number.isSafeInteger(l)&&l>=0&&l<=65535?l:d.error("number.port")},positive:{method(){return this.sign("positive")}},precision:{method(l){return o(Number.isSafeInteger(l),"limit must be an integer"),this.$_addRule({name:"precision",args:{limit:l}})},validate(l,d,{limit:f}){const p=l.toString().match(h.precisionRx);return Math.max((p[1]?p[1].length:0)-(p[2]?parseInt(p[2],10):0),0)<=f?l:d.error("number.precision",{limit:f,value:l})},convert:!0},sign:{method(l){return o(["negative","positive"].includes(l),"Invalid sign",l),this.$_addRule({name:"sign",args:{sign:l}})},validate:(l,d,{sign:f})=>f==="negative"&&l<0||f==="positive"&&l>0?l:d.error(`number.${f}`)},unsafe:{method(l=!0){return o(typeof l=="boolean","enabled must be a boolean"),this.$_setFlag("unsafe",l)}}},cast:{string:{from:l=>typeof l=="number",to:(l,d)=>l.toString()}},messages:{"number.base":"{{#label}} must be a number","number.greater":"{{#label}} must be greater than {{#limit}}","number.infinity":"{{#label}} cannot be infinity","number.integer":"{{#label}} must be an integer","number.less":"{{#label}} must be less than {{#limit}}","number.max":"{{#label}} must be less than or equal to {{#limit}}","number.min":"{{#label}} must be greater than or equal to {{#limit}}","number.multiple":"{{#label}} must be a multiple of {{#multiple}}","number.negative":"{{#label}} must be a negative number","number.port":"{{#label}} must be a valid port","number.positive":"{{#label}} must be a positive number","number.precision":"{{#label}} must have no more than {{#limit}} decimal places","number.unsafe":"{{#label}} must be a safe number"}}),h.extractSignificantDigits=function(l){return l.replace(h.exponentialPartRegex,"").replace(h.dotRegex,"").replace(h.trailingZerosRegex,"").replace(h.leadingSignAndZerosRegex,"")},h.normalizeDecimal=function(l){return(l=l.replace(/^\+/,"").replace(/\.0*$/,"").replace(/^(-?)\.([^\.]*)$/,"$10.$2").replace(/^(-?)0+([0-9])/,"$1$2")).includes(".")&&l.endsWith("0")&&(l=l.replace(/0+$/,"")),l==="-0"?"0":l}},8966:(i,n,a)=>{const o=a(7824);i.exports=o.extend({type:"object",cast:{map:{from:c=>c&&typeof c=="object",to:(c,u)=>new Map(Object.entries(c))}}})},7417:(i,n,a)=>{const o=a(375),c=a(5380),u=a(1745),h=a(9959),l=a(6064),d=a(9926),f=a(5752),p=a(8068),m=a(8160),v={tlds:d instanceof Set&&{tlds:{allow:d,deny:null}},base64Regex:{true:{true:/^(?:[\w\-]{2}[\w\-]{2})*(?:[\w\-]{2}==|[\w\-]{3}=)?$/,false:/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/},false:{true:/^(?:[\w\-]{2}[\w\-]{2})*(?:[\w\-]{2}(==)?|[\w\-]{3}=?)?$/,false:/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}(==)?|[A-Za-z0-9+\/]{3}=?)?$/}},dataUriRegex:/^data:[\w+.-]+\/[\w+.-]+;((charset=[\w-]+|base64),)?(.*)$/,hexRegex:{withPrefix:/^0x[0-9a-f]+$/i,withOptionalPrefix:/^(?:0x)?[0-9a-f]+$/i,withoutPrefix:/^[0-9a-f]+$/i},ipRegex:h.regex({cidr:"forbidden"}).regex,isoDurationRegex:/^P(?!$)(\d+Y)?(\d+M)?(\d+W)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?$/,guidBrackets:{"{":"}","[":"]","(":")","":""},guidVersions:{uuidv1:"1",uuidv2:"2",uuidv3:"3",uuidv4:"4",uuidv5:"5",uuidv6:"6",uuidv7:"7",uuidv8:"8"},guidSeparators:new Set([void 0,!0,!1,"-",":"]),normalizationForms:["NFC","NFD","NFKC","NFKD"]};i.exports=p.extend({type:"string",flags:{insensitive:{default:!1},truncate:{default:!1}},terms:{replacements:{init:null}},coerce:{from:"string",method(g,{schema:y,state:b,prefs:k}){const x=y.$_getRule("normalize");x&&(g=g.normalize(x.args.form));const E=y.$_getRule("case");E&&(g=E.args.direction==="upper"?g.toLocaleUpperCase():g.toLocaleLowerCase());const T=y.$_getRule("trim");if(T&&T.args.enabled&&(g=g.trim()),y.$_terms.replacements)for(const S of y.$_terms.replacements)g=g.replace(S.pattern,S.replacement);const w=y.$_getRule("hex");if(w&&w.args.options.byteAligned&&g.length%2!=0&&(g=`0${g}`),y.$_getRule("isoDate")){const S=v.isoDate(g);S&&(g=S)}if(y._flags.truncate){const S=y.$_getRule("max");if(S){let _=S.args.limit;if(m.isResolvable(_)&&(_=_.resolve(g,b,k),!m.limit(_)))return{value:g,errors:y.$_createError("any.ref",_,{ref:S.args.limit,arg:"limit",reason:"must be a positive integer"},b,k)};g=g.slice(0,_)}}return{value:g}}},validate(g,{schema:y,error:b}){if(typeof g!="string")return{value:g,errors:b("string.base")};if(g===""){const k=y.$_getRule("min");return k&&k.args.limit===0?void 0:{value:g,errors:b("string.empty")}}},rules:{alphanum:{method(){return this.$_addRule("alphanum")},validate:(g,y)=>/^[a-zA-Z0-9]+$/.test(g)?g:y.error("string.alphanum")},base64:{method(g={}){return m.assertOptions(g,["paddingRequired","urlSafe"]),g={urlSafe:!1,paddingRequired:!0,...g},o(typeof g.paddingRequired=="boolean","paddingRequired must be boolean"),o(typeof g.urlSafe=="boolean","urlSafe must be boolean"),this.$_addRule({name:"base64",args:{options:g}})},validate:(g,y,{options:b})=>v.base64Regex[b.paddingRequired][b.urlSafe].test(g)?g:y.error("string.base64")},case:{method(g){return o(["lower","upper"].includes(g),"Invalid case:",g),this.$_addRule({name:"case",args:{direction:g}})},validate:(g,y,{direction:b})=>b==="lower"&&g===g.toLocaleLowerCase()||b==="upper"&&g===g.toLocaleUpperCase()?g:y.error(`string.${b}case`),convert:!0},creditCard:{method(){return this.$_addRule("creditCard")},validate(g,y){let b=g.length,k=0,x=1;for(;b--;){const E=g.charAt(b)*x;k+=E-9*(E>9),x^=3}return k>0&&k%10==0?g:y.error("string.creditCard")}},dataUri:{method(g={}){return m.assertOptions(g,["paddingRequired"]),g={paddingRequired:!0,...g},o(typeof g.paddingRequired=="boolean","paddingRequired must be boolean"),this.$_addRule({name:"dataUri",args:{options:g}})},validate(g,y,{options:b}){const k=g.match(v.dataUriRegex);return k&&(!k[2]||k[2]!=="base64"||v.base64Regex[b.paddingRequired].false.test(k[3]))?g:y.error("string.dataUri")}},domain:{method(g){g&&m.assertOptions(g,["allowFullyQualified","allowUnicode","maxDomainSegments","minDomainSegments","tlds"]);const y=v.addressOptions(g);return this.$_addRule({name:"domain",args:{options:g},address:y})},validate:(g,y,b,{address:k})=>c.isValid(g,k)?g:y.error("string.domain")},email:{method(g={}){m.assertOptions(g,["allowFullyQualified","allowUnicode","ignoreLength","maxDomainSegments","minDomainSegments","multiple","separator","tlds"]),o(g.multiple===void 0||typeof g.multiple=="boolean","multiple option must be an boolean");const y=v.addressOptions(g),b=new RegExp(`\\s*[${g.separator?l(g.separator):","}]\\s*`);return this.$_addRule({name:"email",args:{options:g},regex:b,address:y})},validate(g,y,{options:b},{regex:k,address:x}){const E=b.multiple?g.split(k):[g],T=[];for(const w of E)u.isValid(w,x)||T.push(w);return T.length?y.error("string.email",{value:g,invalids:T}):g}},guid:{alias:"uuid",method(g={}){m.assertOptions(g,["version","separator"]);let y="";if(g.version){const x=[].concat(g.version);o(x.length>=1,"version must have at least 1 valid version specified");const E=new Set;for(let T=0;T<x.length;++T){const w=x[T];o(typeof w=="string","version at position "+T+" must be a string");const S=v.guidVersions[w.toLowerCase()];o(S,"version at position "+T+" must be one of "+Object.keys(v.guidVersions).join(", ")),o(!E.has(S),"version at position "+T+" must not be a duplicate"),y+=S,E.add(S)}}o(v.guidSeparators.has(g.separator),'separator must be one of true, false, "-", or ":"');const b=g.separator===void 0?"[:-]?":g.separator===!0?"[:-]":g.separator===!1?"[]?":`\\${g.separator}`,k=new RegExp(`^([\\[{\\(]?)[0-9A-F]{8}(${b})[0-9A-F]{4}\\2?[${y||"0-9A-F"}][0-9A-F]{3}\\2?[${y?"89AB":"0-9A-F"}][0-9A-F]{3}\\2?[0-9A-F]{12}([\\]}\\)]?)$`,"i");return this.$_addRule({name:"guid",args:{options:g},regex:k})},validate(g,y,b,{regex:k}){const x=k.exec(g);return x?v.guidBrackets[x[1]]!==x[x.length-1]?y.error("string.guid"):g:y.error("string.guid")}},hex:{method(g={}){return m.assertOptions(g,["byteAligned","prefix"]),g={byteAligned:!1,prefix:!1,...g},o(typeof g.byteAligned=="boolean","byteAligned must be boolean"),o(typeof g.prefix=="boolean"||g.prefix==="optional",'prefix must be boolean or "optional"'),this.$_addRule({name:"hex",args:{options:g}})},validate:(g,y,{options:b})=>(b.prefix==="optional"?v.hexRegex.withOptionalPrefix:b.prefix===!0?v.hexRegex.withPrefix:v.hexRegex.withoutPrefix).test(g)?b.byteAligned&&g.length%2!=0?y.error("string.hexAlign"):g:y.error("string.hex")},hostname:{method(){return this.$_addRule("hostname")},validate:(g,y)=>c.isValid(g,{minDomainSegments:1})||v.ipRegex.test(g)?g:y.error("string.hostname")},insensitive:{method(){return this.$_setFlag("insensitive",!0)}},ip:{method(g={}){m.assertOptions(g,["cidr","version"]);const{cidr:y,versions:b,regex:k}=h.regex(g),x=g.version?b:void 0;return this.$_addRule({name:"ip",args:{options:{cidr:y,version:x}},regex:k})},validate:(g,y,{options:b},{regex:k})=>k.test(g)?g:b.version?y.error("string.ipVersion",{value:g,cidr:b.cidr,version:b.version}):y.error("string.ip",{value:g,cidr:b.cidr})},isoDate:{method(){return this.$_addRule("isoDate")},validate:(g,{error:y})=>v.isoDate(g)?g:y("string.isoDate")},isoDuration:{method(){return this.$_addRule("isoDuration")},validate:(g,y)=>v.isoDurationRegex.test(g)?g:y.error("string.isoDuration")},length:{method(g,y){return v.length(this,"length",g,"=",y)},validate(g,y,{limit:b,encoding:k},{name:x,operator:E,args:T}){const w=!k&&g.length;return m.compare(w,b,E)?g:y.error("string."+x,{limit:T.limit,value:g,encoding:k})},args:[{name:"limit",ref:!0,assert:m.limit,message:"must be a positive integer"},"encoding"]},lowercase:{method(){return this.case("lower")}},max:{method(g,y){return v.length(this,"max",g,"<=",y)},args:["limit","encoding"]},min:{method(g,y){return v.length(this,"min",g,">=",y)},args:["limit","encoding"]},normalize:{method(g="NFC"){return o(v.normalizationForms.includes(g),"normalization form must be one of "+v.normalizationForms.join(", ")),this.$_addRule({name:"normalize",args:{form:g}})},validate:(g,{error:y},{form:b})=>g===g.normalize(b)?g:y("string.normalize",{value:g,form:b}),convert:!0},pattern:{alias:"regex",method(g,y={}){o(g instanceof RegExp,"regex must be a RegExp"),o(!g.flags.includes("g")&&!g.flags.includes("y"),"regex should not use global or sticky mode"),typeof y=="string"&&(y={name:y}),m.assertOptions(y,["invert","name"]);const b=["string.pattern",y.invert?".invert":"",y.name?".name":".base"].join("");return this.$_addRule({name:"pattern",args:{regex:g,options:y},errorCode:b})},validate:(g,y,{regex:b,options:k},{errorCode:x})=>b.test(g)^k.invert?g:y.error(x,{name:k.name,regex:b,value:g}),args:["regex","options"],multi:!0},replace:{method(g,y){typeof g=="string"&&(g=new RegExp(l(g),"g")),o(g instanceof RegExp,"pattern must be a RegExp"),o(typeof y=="string","replacement must be a String");const b=this.clone();return b.$_terms.replacements||(b.$_terms.replacements=[]),b.$_terms.replacements.push({pattern:g,replacement:y}),b}},token:{method(){return this.$_addRule("token")},validate:(g,y)=>/^\w+$/.test(g)?g:y.error("string.token")},trim:{method(g=!0){return o(typeof g=="boolean","enabled must be a boolean"),this.$_addRule({name:"trim",args:{enabled:g}})},validate:(g,y,{enabled:b})=>b&&g!==g.trim()?y.error("string.trim"):g,convert:!0},truncate:{method(g=!0){return o(typeof g=="boolean","enabled must be a boolean"),this.$_setFlag("truncate",g)}},uppercase:{method(){return this.case("upper")}},uri:{method(g={}){m.assertOptions(g,["allowRelative","allowQuerySquareBrackets","domain","relativeOnly","scheme","encodeUri"]),g.domain&&m.assertOptions(g.domain,["allowFullyQualified","allowUnicode","maxDomainSegments","minDomainSegments","tlds"]);const{regex:y,scheme:b}=f.regex(g),k=g.domain?v.addressOptions(g.domain):null;return this.$_addRule({name:"uri",args:{options:g},regex:y,domain:k,scheme:b})},validate(g,y,{options:b},{regex:k,domain:x,scheme:E}){if(["http:/","https:/"].includes(g))return y.error("string.uri");let T=k.exec(g);if(!T&&y.prefs.convert&&b.encodeUri){const w=encodeURI(g);T=k.exec(w),T&&(g=w)}if(T){const w=T[1]||T[2];return!x||b.allowRelative&&!w||c.isValid(w,x)?g:y.error("string.domain",{value:w})}return b.relativeOnly?y.error("string.uriRelativeOnly"):b.scheme?y.error("string.uriCustomScheme",{scheme:E,value:g}):y.error("string.uri")}}},manifest:{build(g,y){if(y.replacements)for(const{pattern:b,replacement:k}of y.replacements)g=g.replace(b,k);return g}},messages:{"string.alphanum":"{{#label}} must only contain alpha-numeric characters","string.base":"{{#label}} must be a string","string.base64":"{{#label}} must be a valid base64 string","string.creditCard":"{{#label}} must be a credit card","string.dataUri":"{{#label}} must be a valid dataUri string","string.domain":"{{#label}} must contain a valid domain name","string.email":"{{#label}} must be a valid email","string.empty":"{{#label}} is not allowed to be empty","string.guid":"{{#label}} must be a valid GUID","string.hex":"{{#label}} must only contain hexadecimal characters","string.hexAlign":"{{#label}} hex decoded representation must be byte aligned","string.hostname":"{{#label}} must be a valid hostname","string.ip":"{{#label}} must be a valid ip address with a {{#cidr}} CIDR","string.ipVersion":"{{#label}} must be a valid ip address of one of the following versions {{#version}} with a {{#cidr}} CIDR","string.isoDate":"{{#label}} must be in iso format","string.isoDuration":"{{#label}} must be a valid ISO 8601 duration","string.length":"{{#label}} length must be {{#limit}} characters long","string.lowercase":"{{#label}} must only contain lowercase characters","string.max":"{{#label}} length must be less than or equal to {{#limit}} characters long","string.min":"{{#label}} length must be at least {{#limit}} characters long","string.normalize":"{{#label}} must be unicode normalized in the {{#form}} form","string.token":"{{#label}} must only contain alpha-numeric and underscore characters","string.pattern.base":"{{#label}} with value {:[.]} fails to match the required pattern: {{#regex}}","string.pattern.name":"{{#label}} with value {:[.]} fails to match the {{#name}} pattern","string.pattern.invert.base":"{{#label}} with value {:[.]} matches the inverted pattern: {{#regex}}","string.pattern.invert.name":"{{#label}} with value {:[.]} matches the inverted {{#name}} pattern","string.trim":"{{#label}} must not have leading or trailing whitespace","string.uri":"{{#label}} must be a valid uri","string.uriCustomScheme":"{{#label}} must be a valid uri with a scheme matching the {{#scheme}} pattern","string.uriRelativeOnly":"{{#label}} must be a valid relative uri","string.uppercase":"{{#label}} must only contain uppercase characters"}}),v.addressOptions=function(g){if(!g)return v.tlds||g;if(o(g.minDomainSegments===void 0||Number.isSafeInteger(g.minDomainSegments)&&g.minDomainSegments>0,"minDomainSegments must be a positive integer"),o(g.maxDomainSegments===void 0||Number.isSafeInteger(g.maxDomainSegments)&&g.maxDomainSegments>0,"maxDomainSegments must be a positive integer"),g.tlds===!1)return g;if(g.tlds===!0||g.tlds===void 0)return o(v.tlds,"Built-in TLD list disabled"),Object.assign({},g,v.tlds);o(typeof g.tlds=="object","tlds must be true, false, or an object");const y=g.tlds.deny;if(y)return Array.isArray(y)&&(g=Object.assign({},g,{tlds:{deny:new Set(y)}})),o(g.tlds.deny instanceof Set,"tlds.deny must be an array, Set, or boolean"),o(!g.tlds.allow,"Cannot specify both tlds.allow and tlds.deny lists"),v.validateTlds(g.tlds.deny,"tlds.deny"),g;const b=g.tlds.allow;return b?b===!0?(o(v.tlds,"Built-in TLD list disabled"),Object.assign({},g,v.tlds)):(Array.isArray(b)&&(g=Object.assign({},g,{tlds:{allow:new Set(b)}})),o(g.tlds.allow instanceof Set,"tlds.allow must be an array, Set, or boolean"),v.validateTlds(g.tlds.allow,"tlds.allow"),g):g},v.validateTlds=function(g,y){for(const b of g)o(c.isValid(b,{minDomainSegments:1,maxDomainSegments:1}),`${y} must contain valid top level domain names`)},v.isoDate=function(g){if(!m.isIsoDate(g))return null;/.*T.*[+-]\d\d$/.test(g)&&(g+="00");const y=new Date(g);return isNaN(y.getTime())?null:y.toISOString()},v.length=function(g,y,b,k,x){return o(!x||!1,"Invalid encoding:",x),g.$_addRule({name:y,method:"length",args:{limit:b,encoding:x},operator:k})}},8826:(i,n,a)=>{const o=a(375),c=a(8068),u={};u.Map=class extends Map{slice(){return new u.Map(this)}},i.exports=c.extend({type:"symbol",terms:{map:{init:new u.Map}},coerce:{method(h,{schema:l,error:d}){const f=l.$_terms.map.get(h);return f&&(h=f),l._flags.only&&typeof h!="symbol"?{value:h,errors:d("symbol.map",{map:l.$_terms.map})}:{value:h}}},validate(h,{error:l}){if(typeof h!="symbol")return{value:h,errors:l("symbol.base")}},rules:{map:{method(h){h&&!h[Symbol.iterator]&&typeof h=="object"&&(h=Object.entries(h)),o(h&&h[Symbol.iterator],"Iterable must be an iterable or object");const l=this.clone(),d=[];for(const f of h){o(f&&f[Symbol.iterator],"Entry must be an iterable");const[p,m]=f;o(typeof p!="object"&&typeof p!="function"&&typeof p!="symbol","Key must not be of type object, function, or Symbol"),o(typeof m=="symbol","Value must be a Symbol"),l.$_terms.map.set(p,m),d.push(m)}return l.valid(...d)}}},manifest:{build:(h,l)=>(l.map&&(h=h.map(l.map)),h)},messages:{"symbol.base":"{{#label}} must be a symbol","symbol.map":"{{#label}} must be one of {{#map}}"}})},8863:(i,n,a)=>{const o=a(375),c=a(8571),u=a(738),h=a(9621),l=a(8160),d=a(6354),f=a(493),p={result:Symbol("result")};n.entry=function(m,v,g){let y=l.defaults;g&&(o(g.warnings===void 0,"Cannot override warnings preference in synchronous validation"),o(g.artifacts===void 0,"Cannot override artifacts preference in synchronous validation"),y=l.preferences(l.defaults,g));const b=p.entry(m,v,y);o(!b.mainstay.externals.length,"Schema with external rules must use validateAsync()");const k={value:b.value};return b.error&&(k.error=b.error),b.mainstay.warnings.length&&(k.warning=d.details(b.mainstay.warnings)),b.mainstay.debug&&(k.debug=b.mainstay.debug),b.mainstay.artifacts&&(k.artifacts=b.mainstay.artifacts),k},n.entryAsync=async function(m,v,g){let y=l.defaults;g&&(y=l.preferences(l.defaults,g));const b=p.entry(m,v,y),k=b.mainstay;if(b.error)throw k.debug&&(b.error.debug=k.debug),b.error;if(k.externals.length){let E=b.value;const T=[];for(const w of k.externals){const S=w.state.path,_=w.schema.type==="link"?k.links.get(w.schema):null;let A,M,D=E;const W=S.length?[E]:[],G=S.length?h(m,S):m;if(S.length){A=S[S.length-1];let ue=E;for(const re of S.slice(0,-1))ue=ue[re],W.unshift(ue);M=W[0],D=M[A]}try{const ue=($,H)=>(_||w.schema).$_createError($,D,H,w.state,y),re=await w.method(D,{schema:w.schema,linked:_,state:w.state,prefs:g,original:G,error:ue,errorsArray:p.errorsArray,warn:($,H)=>k.warnings.push((_||w.schema).$_createError($,D,H,w.state,y)),message:($,H)=>(_||w.schema).$_createError("external",D,H,w.state,y,{messages:$})});if(re===void 0||re===D)continue;if(re instanceof d.Report){if(k.tracer.log(w.schema,w.state,"rule","external","error"),T.push(re),y.abortEarly)break;continue}if(Array.isArray(re)&&re[l.symbols.errors]){if(k.tracer.log(w.schema,w.state,"rule","external","error"),T.push(...re),y.abortEarly)break;continue}M?(k.tracer.value(w.state,"rule",D,re,"external"),M[A]=re):(k.tracer.value(w.state,"rule",E,re,"external"),E=re)}catch(ue){throw y.errors.label&&(ue.message+=` (${w.label})`),ue}}if(b.value=E,T.length)throw b.error=d.process(T,m,y),k.debug&&(b.error.debug=k.debug),b.error}if(!y.warnings&&!y.debug&&!y.artifacts)return b.value;const x={value:b.value};return k.warnings.length&&(x.warning=d.details(k.warnings)),k.debug&&(x.debug=k.debug),k.artifacts&&(x.artifacts=k.artifacts),x},p.Mainstay=class{constructor(m,v,g){this.externals=[],this.warnings=[],this.tracer=m,this.debug=v,this.links=g,this.shadow=null,this.artifacts=null,this._snapshots=[]}snapshot(){this._snapshots.push({externals:this.externals.slice(),warnings:this.warnings.slice()})}restore(){const m=this._snapshots.pop();this.externals=m.externals,this.warnings=m.warnings}commit(){this._snapshots.pop()}},p.entry=function(m,v,g){const{tracer:y,cleanup:b}=p.tracer(v,g),k=g.debug?[]:null,x=v._ids._schemaChain?new Map:null,E=new p.Mainstay(y,k,x),T=v._ids._schemaChain?[{schema:v}]:null,w=new f([],[],{mainstay:E,schemas:T}),S=n.validate(m,v,w,g);b&&v.$_root.untrace();const _=d.process(S.errors,m,g);return{value:S.value,error:_,mainstay:E}},p.tracer=function(m,v){return m.$_root._tracer?{tracer:m.$_root._tracer._register(m)}:v.debug?(o(m.$_root.trace,"Debug mode not supported"),{tracer:m.$_root.trace()._register(m),cleanup:!0}):{tracer:p.ignore}},n.validate=function(m,v,g,y,b={}){if(v.$_terms.whens&&(v=v._generate(m,g,y).schema),v._preferences&&(y=p.prefs(v,y)),v._cache&&y.cache){const _=v._cache.get(m);if(g.mainstay.tracer.debug(g,"validate","cached",!!_),_)return _}const k=(_,A,M)=>v.$_createError(_,m,A,M||g,y),x={original:m,prefs:y,schema:v,state:g,error:k,errorsArray:p.errorsArray,warn:(_,A,M)=>g.mainstay.warnings.push(k(_,A,M)),message:(_,A)=>v.$_createError("custom",m,A,g,y,{messages:_})};g.mainstay.tracer.entry(v,g);const E=v._definition;if(E.prepare&&m!==void 0&&y.convert){const _=E.prepare(m,x);if(_){if(g.mainstay.tracer.value(g,"prepare",m,_.value),_.errors)return p.finalize(_.value,[].concat(_.errors),x);m=_.value}}if(E.coerce&&m!==void 0&&y.convert&&(!E.coerce.from||E.coerce.from.includes(typeof m))){const _=E.coerce.method(m,x);if(_){if(g.mainstay.tracer.value(g,"coerced",m,_.value),_.errors)return p.finalize(_.value,[].concat(_.errors),x);m=_.value}}const T=v._flags.empty;T&&T.$_match(p.trim(m,v),g.nest(T),l.defaults)&&(g.mainstay.tracer.value(g,"empty",m,void 0),m=void 0);const w=b.presence||v._flags.presence||(v._flags._endedSwitch?null:y.presence);if(m===void 0){if(w==="forbidden")return p.finalize(m,null,x);if(w==="required")return p.finalize(m,[v.$_createError("any.required",m,null,g,y)],x);if(w==="optional"){if(v._flags.default!==l.symbols.deepDefault)return p.finalize(m,null,x);g.mainstay.tracer.value(g,"default",m,{}),m={}}}else if(w==="forbidden")return p.finalize(m,[v.$_createError("any.unknown",m,null,g,y)],x);const S=[];if(v._valids){const _=v._valids.get(m,g,y,v._flags.insensitive);if(_)return y.convert&&(g.mainstay.tracer.value(g,"valids",m,_.value),m=_.value),g.mainstay.tracer.filter(v,g,"valid",_),p.finalize(m,null,x);if(v._flags.only){const A=v.$_createError("any.only",m,{valids:v._valids.values({display:!0})},g,y);if(y.abortEarly)return p.finalize(m,[A],x);S.push(A)}}if(v._invalids){const _=v._invalids.get(m,g,y,v._flags.insensitive);if(_){g.mainstay.tracer.filter(v,g,"invalid",_);const A=v.$_createError("any.invalid",m,{invalids:v._invalids.values({display:!0})},g,y);if(y.abortEarly)return p.finalize(m,[A],x);S.push(A)}}if(E.validate){const _=E.validate(m,x);if(_&&(g.mainstay.tracer.value(g,"base",m,_.value),m=_.value,_.errors)){if(!Array.isArray(_.errors))return S.push(_.errors),p.finalize(m,S,x);if(_.errors.length)return S.push(..._.errors),p.finalize(m,S,x)}}return v._rules.length?p.rules(m,S,x):p.finalize(m,S,x)},p.rules=function(m,v,g){const{schema:y,state:b,prefs:k}=g;for(const x of y._rules){const E=y._definition.rules[x.method];if(E.convert&&k.convert){b.mainstay.tracer.log(y,b,"rule",x.name,"full");continue}let T,w=x.args;if(x._resolve.length){w=Object.assign({},w);for(const _ of x._resolve){const A=E.argsByName.get(_),M=w[_].resolve(m,b,k),D=A.normalize?A.normalize(M):M,W=l.validateArg(D,null,A);if(W){T=y.$_createError("any.ref",M,{arg:_,ref:w[_],reason:W},b,k);break}w[_]=D}}T=T||E.validate(m,g,w,x);const S=p.rule(T,x);if(S.errors){if(b.mainstay.tracer.log(y,b,"rule",x.name,"error"),x.warn){b.mainstay.warnings.push(...S.errors);continue}if(k.abortEarly)return p.finalize(m,S.errors,g);v.push(...S.errors)}else b.mainstay.tracer.log(y,b,"rule",x.name,"pass"),b.mainstay.tracer.value(b,"rule",m,S.value,x.name),m=S.value}return p.finalize(m,v,g)},p.rule=function(m,v){return m instanceof d.Report?(p.error(m,v),{errors:[m],value:null}):Array.isArray(m)&&m[l.symbols.errors]?(m.forEach(g=>p.error(g,v)),{errors:m,value:null}):{errors:null,value:m}},p.error=function(m,v){return v.message&&m._setTemplate(v.message),m},p.finalize=function(m,v,g){v=v||[];const{schema:y,state:b,prefs:k}=g;if(v.length){const E=p.default("failover",void 0,v,g);E!==void 0&&(b.mainstay.tracer.value(b,"failover",m,E),m=E,v=[])}if(v.length&&y._flags.error)if(typeof y._flags.error=="function"){v=y._flags.error(v),Array.isArray(v)||(v=[v]);for(const E of v)o(E instanceof Error||E instanceof d.Report,"error() must return an Error object")}else v=[y._flags.error];if(m===void 0){const E=p.default("default",m,v,g);b.mainstay.tracer.value(b,"default",m,E),m=E}if(y._flags.cast&&m!==void 0){const E=y._definition.cast[y._flags.cast];if(E.from(m)){const T=E.to(m,g);b.mainstay.tracer.value(b,"cast",m,T,y._flags.cast),m=T}}if(y.$_terms.externals&&k.externals&&k._externals!==!1)for(const{method:E}of y.$_terms.externals)b.mainstay.externals.push({method:E,schema:y,state:b,label:d.label(y._flags,b,k)});const x={value:m,errors:v.length?v:null};return y._flags.result&&(x.value=y._flags.result==="strip"?void 0:g.original,b.mainstay.tracer.value(b,y._flags.result,m,x.value),b.shadow(m,y._flags.result)),y._cache&&k.cache!==!1&&!y._refs.length&&y._cache.set(g.original,x),m===void 0||x.errors||y._flags.artifact===void 0||(b.mainstay.artifacts=b.mainstay.artifacts||new Map,b.mainstay.artifacts.has(y._flags.artifact)||b.mainstay.artifacts.set(y._flags.artifact,[]),b.mainstay.artifacts.get(y._flags.artifact).push(b.path)),x},p.prefs=function(m,v){const g=v===l.defaults;return g&&m._preferences[l.symbols.prefs]?m._preferences[l.symbols.prefs]:(v=l.preferences(v,m._preferences),g&&(m._preferences[l.symbols.prefs]=v),v)},p.default=function(m,v,g,y){const{schema:b,state:k,prefs:x}=y,E=b._flags[m];if(x.noDefaults||E===void 0)return v;if(k.mainstay.tracer.log(b,k,"rule",m,"full"),!E)return E;if(typeof E=="function"){const T=E.length?[c(k.ancestors[0]),y]:[];try{return E(...T)}catch(w){return void g.push(b.$_createError(`any.${m}`,null,{error:w},k,x))}}return typeof E!="object"?E:E[l.symbols.literal]?E.literal:l.isResolvable(E)?E.resolve(v,k,x):c(E)},p.trim=function(m,v){if(typeof m!="string")return m;const g=v.$_getRule("trim");return g&&g.args.enabled?m.trim():m},p.ignore={active:!1,debug:u,entry:u,filter:u,log:u,resolve:u,value:u},p.errorsArray=function(){const m=[];return m[l.symbols.errors]=!0,m}},2036:(i,n,a)=>{const o=a(375),c=a(9474),u=a(8160),h={};i.exports=h.Values=class{constructor(l,d){this._values=new Set(l),this._refs=new Set(d),this._lowercase=h.lowercases(l),this._override=!1}get length(){return this._values.size+this._refs.size}add(l,d){u.isResolvable(l)?this._refs.has(l)||(this._refs.add(l),d&&d.register(l)):this.has(l,null,null,!1)||(this._values.add(l),typeof l=="string"&&this._lowercase.set(l.toLowerCase(),l))}static merge(l,d,f){if(l=l||new h.Values,d){if(d._override)return d.clone();for(const p of[...d._values,...d._refs])l.add(p)}if(f)for(const p of[...f._values,...f._refs])l.remove(p);return l.length?l:null}remove(l){u.isResolvable(l)?this._refs.delete(l):(this._values.delete(l),typeof l=="string"&&this._lowercase.delete(l.toLowerCase()))}has(l,d,f,p){return!!this.get(l,d,f,p)}get(l,d,f,p){if(!this.length)return!1;if(this._values.has(l))return{value:l};if(typeof l=="string"&&l&&p){const m=this._lowercase.get(l.toLowerCase());if(m)return{value:m}}if(!this._refs.size&&typeof l!="object")return!1;if(typeof l=="object"){for(const m of this._values)if(c(m,l))return{value:m}}if(d)for(const m of this._refs){const v=m.resolve(l,d,f,null,{in:!0});if(v===void 0)continue;const g=m.in&&typeof v=="object"?Array.isArray(v)?v:Object.keys(v):[v];for(const y of g)if(typeof y==typeof l){if(p&&l&&typeof l=="string"){if(y.toLowerCase()===l.toLowerCase())return{value:y,ref:m}}else if(c(y,l))return{value:y,ref:m}}}return!1}override(){this._override=!0}values(l){if(l&&l.display){const d=[];for(const f of[...this._values,...this._refs])f!==void 0&&d.push(f);return d}return Array.from([...this._values,...this._refs])}clone(){const l=new h.Values(this._values,this._refs);return l._override=this._override,l}concat(l){o(!l._override,"Cannot concat override set of values");const d=new h.Values([...this._values,...l._values],[...this._refs,...l._refs]);return d._override=this._override,d}describe(){const l=[];this._override&&l.push({override:!0});for(const d of this._values.values())l.push(d&&typeof d=="object"?{value:d}:d);for(const d of this._refs.values())l.push(d.describe());return l}},h.Values.prototype[u.symbols.values]=!0,h.Values.prototype.slice=h.Values.prototype.clone,h.lowercases=function(l){const d=new Map;if(l)for(const f of l)typeof f=="string"&&d.set(f.toLowerCase(),f);return d}},978:(i,n,a)=>{const o=a(375),c=a(8571),u=a(1687),h=a(9621),l={};i.exports=function(d,f,p={}){if(o(d&&typeof d=="object","Invalid defaults value: must be an object"),o(!f||f===!0||typeof f=="object","Invalid source value: must be true, falsy or an object"),o(typeof p=="object","Invalid options: must be an object"),!f)return null;if(p.shallow)return l.applyToDefaultsWithShallow(d,f,p);const m=c(d);if(f===!0)return m;const v=p.nullOverride!==void 0&&p.nullOverride;return u(m,f,{nullOverride:v,mergeArrays:!1})},l.applyToDefaultsWithShallow=function(d,f,p){const m=p.shallow;o(Array.isArray(m),"Invalid keys");const v=new Map,g=f===!0?null:new Set;for(let k of m){k=Array.isArray(k)?k:k.split(".");const x=h(d,k);x&&typeof x=="object"?v.set(x,g&&h(f,k)||x):g&&g.add(k)}const y=c(d,{},v);if(!g)return y;for(const k of g)l.reachCopy(y,f,k);const b=p.nullOverride!==void 0&&p.nullOverride;return u(y,f,{nullOverride:b,mergeArrays:!1})},l.reachCopy=function(d,f,p){for(const g of p){if(!(g in f))return;const y=f[g];if(typeof y!="object"||y===null)return;f=y}const m=f;let v=d;for(let g=0;g<p.length-1;++g){const y=p[g];typeof v[y]!="object"&&(v[y]={}),v=v[y]}v[p[p.length-1]]=m}},375:(i,n,a)=>{const o=a(7916);i.exports=function(c,...u){if(!c)throw u.length===1&&u[0]instanceof Error?u[0]:new o(u)}},8571:(i,n,a)=>{const o=a(9621),c=a(4277),u=a(7043),h={needsProtoHack:new Set([c.set,c.map,c.weakSet,c.weakMap])};i.exports=h.clone=function(l,d={},f=null){if(typeof l!="object"||l===null)return l;let p=h.clone,m=f;if(d.shallow){if(d.shallow!==!0)return h.cloneWithShallow(l,d);p=b=>b}else if(m){const b=m.get(l);if(b)return b}else m=new Map;const v=c.getInternalProto(l);if(v===c.buffer)return!1;if(v===c.date)return new Date(l.getTime());if(v===c.regex)return new RegExp(l);const g=h.base(l,v,d);if(g===l)return l;if(m&&m.set(l,g),v===c.set)for(const b of l)g.add(p(b,d,m));else if(v===c.map)for(const[b,k]of l)g.set(b,p(k,d,m));const y=u.keys(l,d);for(const b of y){if(b==="__proto__")continue;if(v===c.array&&b==="length"){g.length=l.length;continue}const k=Object.getOwnPropertyDescriptor(l,b);k?k.get||k.set?Object.defineProperty(g,b,k):k.enumerable?g[b]=p(l[b],d,m):Object.defineProperty(g,b,{enumerable:!1,writable:!0,configurable:!0,value:p(l[b],d,m)}):Object.defineProperty(g,b,{enumerable:!0,writable:!0,configurable:!0,value:p(l[b],d,m)})}return g},h.cloneWithShallow=function(l,d){const f=d.shallow;(d=Object.assign({},d)).shallow=!1;const p=new Map;for(const m of f){const v=o(l,m);typeof v!="object"&&typeof v!="function"||p.set(v,v)}return h.clone(l,d,p)},h.base=function(l,d,f){if(f.prototype===!1)return h.needsProtoHack.has(d)?new d.constructor:d===c.array?[]:{};const p=Object.getPrototypeOf(l);if(p&&p.isImmutable)return l;if(d===c.array){const m=[];return p!==d&&Object.setPrototypeOf(m,p),m}if(h.needsProtoHack.has(d)){const m=new p.constructor;return p!==d&&Object.setPrototypeOf(m,p),m}return Object.create(p)}},9474:(i,n,a)=>{const o=a(4277),c={mismatched:null};i.exports=function(u,h,l){return l=Object.assign({prototype:!0},l),!!c.isDeepEqual(u,h,l,[])},c.isDeepEqual=function(u,h,l,d){if(u===h)return u!==0||1/u==1/h;const f=typeof u;if(f!==typeof h||u===null||h===null)return!1;if(f==="function"){if(!l.deepFunction||u.toString()!==h.toString())return!1}else if(f!=="object")return u!=u&&h!=h;const p=c.getSharedType(u,h,!!l.prototype);switch(p){case o.buffer:return!1;case o.promise:return u===h;case o.regex:return u.toString()===h.toString();case c.mismatched:return!1}for(let m=d.length-1;m>=0;--m)if(d[m].isSame(u,h))return!0;d.push(new c.SeenEntry(u,h));try{return!!c.isDeepEqualObj(p,u,h,l,d)}finally{d.pop()}},c.getSharedType=function(u,h,l){if(l)return Object.getPrototypeOf(u)!==Object.getPrototypeOf(h)?c.mismatched:o.getInternalProto(u);const d=o.getInternalProto(u);return d!==o.getInternalProto(h)?c.mismatched:d},c.valueOf=function(u){const h=u.valueOf;if(h===void 0)return u;try{return h.call(u)}catch(l){return l}},c.hasOwnEnumerableProperty=function(u,h){return Object.prototype.propertyIsEnumerable.call(u,h)},c.isSetSimpleEqual=function(u,h){for(const l of Set.prototype.values.call(u))if(!Set.prototype.has.call(h,l))return!1;return!0},c.isDeepEqualObj=function(u,h,l,d,f){const{isDeepEqual:p,valueOf:m,hasOwnEnumerableProperty:v}=c,{keys:g,getOwnPropertySymbols:y}=Object;if(u===o.array){if(!d.part){if(h.length!==l.length)return!1;for(let T=0;T<h.length;++T)if(!p(h[T],l[T],d,f))return!1;return!0}for(const T of h)for(const w of l)if(p(T,w,d,f))return!0}else if(u===o.set){if(h.size!==l.size)return!1;if(!c.isSetSimpleEqual(h,l)){const T=new Set(Set.prototype.values.call(l));for(const w of Set.prototype.values.call(h)){if(T.delete(w))continue;let S=!1;for(const _ of T)if(p(w,_,d,f)){T.delete(_),S=!0;break}if(!S)return!1}}}else if(u===o.map){if(h.size!==l.size)return!1;for(const[T,w]of Map.prototype.entries.call(h))if(w===void 0&&!Map.prototype.has.call(l,T)||!p(w,Map.prototype.get.call(l,T),d,f))return!1}else if(u===o.error&&(h.name!==l.name||h.message!==l.message))return!1;const b=m(h),k=m(l);if((h!==b||l!==k)&&!p(b,k,d,f))return!1;const x=g(h);if(!d.part&&x.length!==g(l).length&&!d.skip)return!1;let E=0;for(const T of x)if(d.skip&&d.skip.includes(T))l[T]===void 0&&++E;else if(!v(l,T)||!p(h[T],l[T],d,f))return!1;if(!d.part&&x.length-E!==g(l).length)return!1;if(d.symbols!==!1){const T=y(h),w=new Set(y(l));for(const S of T){if(!d.skip||!d.skip.includes(S)){if(v(h,S)){if(!v(l,S)||!p(h[S],l[S],d,f))return!1}else if(v(l,S))return!1}w.delete(S)}for(const S of w)if(v(l,S))return!1}return!0},c.SeenEntry=class{constructor(u,h){this.obj=u,this.ref=h}isSame(u,h){return this.obj===u&&this.ref===h}}},7916:(i,n,a)=>{const o=a(8761);i.exports=class extends Error{constructor(c){super(c.filter(u=>u!=="").map(u=>typeof u=="string"?u:u instanceof Error?u.message:o(u)).join(" ")||"Unknown error"),typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,n.assert)}}},5277:i=>{const n={};i.exports=function(a){if(!a)return"";let o="";for(let c=0;c<a.length;++c){const u=a.charCodeAt(c);n.isSafe(u)?o+=a[c]:o+=n.escapeHtmlChar(u)}return o},n.escapeHtmlChar=function(a){return n.namedHtml.get(a)||(a>=256?"&#"+a+";":`&#x${a.toString(16).padStart(2,"0")};`)},n.isSafe=function(a){return n.safeCharCodes.has(a)},n.namedHtml=new Map([[38,"&amp;"],[60,"&lt;"],[62,"&gt;"],[34,"&quot;"],[160,"&nbsp;"],[162,"&cent;"],[163,"&pound;"],[164,"&curren;"],[169,"&copy;"],[174,"&reg;"]]),n.safeCharCodes=function(){const a=new Set;for(let o=32;o<123;++o)(o>=97||o>=65&&o<=90||o>=48&&o<=57||o===32||o===46||o===44||o===45||o===58||o===95)&&a.add(o);return a}()},6064:i=>{i.exports=function(n){return n.replace(/[\^\$\.\*\+\-\?\=\!\:\|\\\/\(\)\[\]\{\}\,]/g,"\\$&")}},738:i=>{i.exports=function(){}},1687:(i,n,a)=>{const o=a(375),c=a(8571),u=a(7043),h={};i.exports=h.merge=function(l,d,f){if(o(l&&typeof l=="object","Invalid target value: must be an object"),o(d==null||typeof d=="object","Invalid source value: must be null, undefined, or an object"),!d)return l;if(f=Object.assign({nullOverride:!0,mergeArrays:!0},f),Array.isArray(d)){o(Array.isArray(l),"Cannot merge array onto an object"),f.mergeArrays||(l.length=0);for(let m=0;m<d.length;++m)l.push(c(d[m],{symbols:f.symbols}));return l}const p=u.keys(d,f);for(let m=0;m<p.length;++m){const v=p[m];if(v==="__proto__"||!Object.prototype.propertyIsEnumerable.call(d,v))continue;const g=d[v];if(g&&typeof g=="object"){if(l[v]===g)continue;!l[v]||typeof l[v]!="object"||Array.isArray(l[v])!==Array.isArray(g)||g instanceof Date||g instanceof RegExp?l[v]=c(g,{symbols:f.symbols}):h.merge(l[v],g,f)}else(g!=null||f.nullOverride)&&(l[v]=g)}return l}},9621:(i,n,a)=>{const o=a(375),c={};i.exports=function(u,h,l){if(h===!1||h==null)return u;typeof(l=l||{})=="string"&&(l={separator:l});const d=Array.isArray(h);o(!d||!l.separator,"Separator option is not valid for array-based chain");const f=d?h:h.split(l.separator||".");let p=u;for(let m=0;m<f.length;++m){let v=f[m];const g=l.iterables&&c.iterables(p);if(Array.isArray(p)||g==="set"){const y=Number(v);Number.isInteger(y)&&(v=y<0?p.length+y:y)}if(!p||typeof p=="function"&&l.functions===!1||!g&&p[v]===void 0){o(!l.strict||m+1===f.length,"Missing segment",v,"in reach path ",h),o(typeof p=="object"||l.functions===!0||typeof p!="function","Invalid segment",v,"in reach path ",h),p=l.default;break}p=g?g==="set"?[...p][v]:p.get(v):p[v]}return p},c.iterables=function(u){return u instanceof Set?"set":u instanceof Map?"map":void 0}},8761:i=>{i.exports=function(...n){try{return JSON.stringify(...n)}catch(a){return"[Cannot display object: "+a.message+"]"}}},4277:(i,n)=>{const a={};n=i.exports={array:Array.prototype,buffer:!1,date:Date.prototype,error:Error.prototype,generic:Object.prototype,map:Map.prototype,promise:Promise.prototype,regex:RegExp.prototype,set:Set.prototype,weakMap:WeakMap.prototype,weakSet:WeakSet.prototype},a.typeMap=new Map([["[object Error]",n.error],["[object Map]",n.map],["[object Promise]",n.promise],["[object Set]",n.set],["[object WeakMap]",n.weakMap],["[object WeakSet]",n.weakSet]]),n.getInternalProto=function(o){if(Array.isArray(o))return n.array;if(o instanceof Date)return n.date;if(o instanceof RegExp)return n.regex;if(o instanceof Error)return n.error;const c=Object.prototype.toString.call(o);return a.typeMap.get(c)||n.generic}},7043:(i,n)=>{n.keys=function(a,o={}){return o.symbols!==!1?Reflect.ownKeys(a):Object.getOwnPropertyNames(a)}},3652:(i,n,a)=>{const o=a(375),c={};n.Sorter=class{constructor(){this._items=[],this.nodes=[]}add(u,h){const l=[].concat((h=h||{}).before||[]),d=[].concat(h.after||[]),f=h.group||"?",p=h.sort||0;o(!l.includes(f),`Item cannot come before itself: ${f}`),o(!l.includes("?"),"Item cannot come before unassociated items"),o(!d.includes(f),`Item cannot come after itself: ${f}`),o(!d.includes("?"),"Item cannot come after unassociated items"),Array.isArray(u)||(u=[u]);for(const m of u){const v={seq:this._items.length,sort:p,before:l,after:d,group:f,node:m};this._items.push(v)}if(!h.manual){const m=this._sort();o(m,"item",f!=="?"?`added into group ${f}`:"","created a dependencies error")}return this.nodes}merge(u){Array.isArray(u)||(u=[u]);for(const l of u)if(l)for(const d of l._items)this._items.push(Object.assign({},d));this._items.sort(c.mergeSort);for(let l=0;l<this._items.length;++l)this._items[l].seq=l;const h=this._sort();return o(h,"merge created a dependencies error"),this.nodes}sort(){const u=this._sort();return o(u,"sort created a dependencies error"),this.nodes}_sort(){const u={},h=Object.create(null),l=Object.create(null);for(const v of this._items){const g=v.seq,y=v.group;l[y]=l[y]||[],l[y].push(g),u[g]=v.before;for(const b of v.after)h[b]=h[b]||[],h[b].push(g)}for(const v in u){const g=[];for(const y in u[v]){const b=u[v][y];l[b]=l[b]||[],g.push(...l[b])}u[v]=g}for(const v in h)if(l[v])for(const g of l[v])u[g].push(...h[v]);const d={};for(const v in u){const g=u[v];for(const y of g)d[y]=d[y]||[],d[y].push(v)}const f={},p=[];for(let v=0;v<this._items.length;++v){let g=v;if(d[v]){g=null;for(let y=0;y<this._items.length;++y){if(f[y]===!0)continue;d[y]||(d[y]=[]);const b=d[y].length;let k=0;for(let x=0;x<b;++x)f[d[y][x]]&&++k;if(k===b){g=y;break}}}g!==null&&(f[g]=!0,p.push(g))}if(p.length!==this._items.length)return!1;const m={};for(const v of this._items)m[v.seq]=v;this._items=[],this.nodes=[];for(const v of p){const g=m[v];this.nodes.push(g.node),this._items.push(g)}return!0}},c.mergeSort=(u,h)=>u.sort===h.sort?0:u.sort<h.sort?-1:1},5380:(i,n,a)=>{const o=a(443),c=a(2178),u={minDomainSegments:2,nonAsciiRx:/[^\x00-\x7f]/,domainControlRx:/[\x00-\x20@\:\/\\#!\$&\'\(\)\*\+,;=\?]/,tldSegmentRx:/^[a-zA-Z](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?$/,domainSegmentRx:/^[a-zA-Z0-9](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?$/,URL:o.URL||URL};n.analyze=function(h,l={}){if(!h)return c.code("DOMAIN_NON_EMPTY_STRING");if(typeof h!="string")throw new Error("Invalid input: domain must be a string");if(h.length>256)return c.code("DOMAIN_TOO_LONG");if(u.nonAsciiRx.test(h)){if(l.allowUnicode===!1)return c.code("DOMAIN_INVALID_UNICODE_CHARS");h=h.normalize("NFC")}if(u.domainControlRx.test(h))return c.code("DOMAIN_INVALID_CHARS");h=u.punycode(h),l.allowFullyQualified&&h[h.length-1]==="."&&(h=h.slice(0,-1));const d=l.minDomainSegments||u.minDomainSegments,f=h.split(".");if(f.length<d)return c.code("DOMAIN_SEGMENTS_COUNT");if(l.maxDomainSegments&&f.length>l.maxDomainSegments)return c.code("DOMAIN_SEGMENTS_COUNT_MAX");const p=l.tlds;if(p){const m=f[f.length-1].toLowerCase();if(p.deny&&p.deny.has(m)||p.allow&&!p.allow.has(m))return c.code("DOMAIN_FORBIDDEN_TLDS")}for(let m=0;m<f.length;++m){const v=f[m];if(!v.length)return c.code("DOMAIN_EMPTY_SEGMENT");if(v.length>63)return c.code("DOMAIN_LONG_SEGMENT");if(m<f.length-1){if(!u.domainSegmentRx.test(v))return c.code("DOMAIN_INVALID_CHARS")}else if(!u.tldSegmentRx.test(v))return c.code("DOMAIN_INVALID_TLDS_CHARS")}return null},n.isValid=function(h,l){return!n.analyze(h,l)},u.punycode=function(h){h.includes("%")&&(h=h.replace(/%/g,"%25"));try{return new u.URL(`http://${h}`).host}catch{return h}}},1745:(i,n,a)=>{const o=a(9848),c=a(5380),u=a(2178),h={nonAsciiRx:/[^\x00-\x7f]/,encoder:new(o.TextEncoder||TextEncoder)};n.analyze=function(l,d){return h.email(l,d)},n.isValid=function(l,d){return!h.email(l,d)},h.email=function(l,d={}){if(typeof l!="string")throw new Error("Invalid input: email must be a string");if(!l)return u.code("EMPTY_STRING");const f=!h.nonAsciiRx.test(l);if(!f){if(d.allowUnicode===!1)return u.code("FORBIDDEN_UNICODE");l=l.normalize("NFC")}const p=l.split("@");if(p.length!==2)return p.length>2?u.code("MULTIPLE_AT_CHAR"):u.code("MISSING_AT_CHAR");const[m,v]=p;if(!m)return u.code("EMPTY_LOCAL");if(!d.ignoreLength){if(l.length>254)return u.code("ADDRESS_TOO_LONG");if(h.encoder.encode(m).length>64)return u.code("LOCAL_TOO_LONG")}return h.local(m,f)||c.analyze(v,d)},h.local=function(l,d){const f=l.split(".");for(const p of f){if(!p.length)return u.code("EMPTY_LOCAL_SEGMENT");if(d){if(!h.atextRx.test(p))return u.code("INVALID_LOCAL_CHARS")}else for(const m of p){if(h.atextRx.test(m))continue;const v=h.binary(m);if(!h.atomRx.test(v))return u.code("INVALID_LOCAL_CHARS")}}},h.binary=function(l){return Array.from(h.encoder.encode(l)).map(d=>String.fromCharCode(d)).join("")},h.atextRx=/^[\w!#\$%&'\*\+\-/=\?\^`\{\|\}~]+$/,h.atomRx=new RegExp(["(?:[\\xc2-\\xdf][\\x80-\\xbf])","(?:\\xe0[\\xa0-\\xbf][\\x80-\\xbf])|(?:[\\xe1-\\xec][\\x80-\\xbf]{2})|(?:\\xed[\\x80-\\x9f][\\x80-\\xbf])|(?:[\\xee-\\xef][\\x80-\\xbf]{2})","(?:\\xf0[\\x90-\\xbf][\\x80-\\xbf]{2})|(?:[\\xf1-\\xf3][\\x80-\\xbf]{3})|(?:\\xf4[\\x80-\\x8f][\\x80-\\xbf]{2})"].join("|"))},2178:(i,n)=>{n.codes={EMPTY_STRING:"Address must be a non-empty string",FORBIDDEN_UNICODE:"Address contains forbidden Unicode characters",MULTIPLE_AT_CHAR:"Address cannot contain more than one @ character",MISSING_AT_CHAR:"Address must contain one @ character",EMPTY_LOCAL:"Address local part cannot be empty",ADDRESS_TOO_LONG:"Address too long",LOCAL_TOO_LONG:"Address local part too long",EMPTY_LOCAL_SEGMENT:"Address local part contains empty dot-separated segment",INVALID_LOCAL_CHARS:"Address local part contains invalid character",DOMAIN_NON_EMPTY_STRING:"Domain must be a non-empty string",DOMAIN_TOO_LONG:"Domain too long",DOMAIN_INVALID_UNICODE_CHARS:"Domain contains forbidden Unicode characters",DOMAIN_INVALID_CHARS:"Domain contains invalid character",DOMAIN_INVALID_TLDS_CHARS:"Domain contains invalid tld character",DOMAIN_SEGMENTS_COUNT:"Domain lacks the minimum required number of segments",DOMAIN_SEGMENTS_COUNT_MAX:"Domain contains too many segments",DOMAIN_FORBIDDEN_TLDS:"Domain uses forbidden TLD",DOMAIN_EMPTY_SEGMENT:"Domain contains empty dot-separated segment",DOMAIN_LONG_SEGMENT:"Domain contains dot-separated segment that is too long"},n.code=function(a){return{code:a,error:n.codes[a]}}},9959:(i,n,a)=>{const o=a(375),c=a(5752);n.regex=function(u={}){o(u.cidr===void 0||typeof u.cidr=="string","options.cidr must be a string");const h=u.cidr?u.cidr.toLowerCase():"optional";o(["required","optional","forbidden"].includes(h),"options.cidr must be one of required, optional, forbidden"),o(u.version===void 0||typeof u.version=="string"||Array.isArray(u.version),"options.version must be a string or an array of string");let l=u.version||["ipv4","ipv6","ipvfuture"];Array.isArray(l)||(l=[l]),o(l.length>=1,"options.version must have at least 1 version specified");for(let p=0;p<l.length;++p)o(typeof l[p]=="string","options.version must only contain strings"),l[p]=l[p].toLowerCase(),o(["ipv4","ipv6","ipvfuture"].includes(l[p]),"options.version contains unknown version "+l[p]+" - must be one of ipv4, ipv6, ipvfuture");l=Array.from(new Set(l));const d=`(?:${l.map(p=>{if(h==="forbidden")return c.ip[p];const m=`\\/${p==="ipv4"?c.ip.v4Cidr:c.ip.v6Cidr}`;return h==="required"?`${c.ip[p]}${m}`:`${c.ip[p]}(?:${m})?`}).join("|")})`,f=new RegExp(`^${d}$`);return{cidr:h,versions:l,regex:f,raw:d}}},5752:(i,n,a)=>{const o=a(375),c=a(6064),u={generate:function(){const h={},l="\\dA-Fa-f",d="["+l+"]",f="\\w-\\.~",p="!\\$&'\\(\\)\\*\\+,;=",m="%"+l,v=f+m+p+":@",g="["+v+"]",y="(?:0{0,2}\\d|0?[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])";h.ipv4address="(?:"+y+"\\.){3}"+y;const b=d+"{1,4}",k="(?:"+b+":"+b+"|"+h.ipv4address+")",x="(?:"+b+":){6}"+k,E="::(?:"+b+":){5}"+k,T="(?:"+b+")?::(?:"+b+":){4}"+k,w="(?:(?:"+b+":){0,1}"+b+")?::(?:"+b+":){3}"+k,S="(?:(?:"+b+":){0,2}"+b+")?::(?:"+b+":){2}"+k,_="(?:(?:"+b+":){0,3}"+b+")?::"+b+":"+k,A="(?:(?:"+b+":){0,4}"+b+")?::"+k,M="(?:(?:"+b+":){0,5}"+b+")?::"+b,D="(?:(?:"+b+":){0,6}"+b+")?::";h.ipv4Cidr="(?:\\d|[1-2]\\d|3[0-2])",h.ipv6Cidr="(?:0{0,2}\\d|0?[1-9]\\d|1[01]\\d|12[0-8])",h.ipv6address="(?:"+x+"|"+E+"|"+T+"|"+w+"|"+S+"|"+_+"|"+A+"|"+M+"|"+D+")",h.ipvFuture="v"+d+"+\\.["+f+p+":]+",h.scheme="[a-zA-Z][a-zA-Z\\d+-\\.]*",h.schemeRegex=new RegExp(h.scheme);const W="["+f+m+p+":]*",G="["+f+m+p+"]{1,255}",ue="(?:\\[(?:"+h.ipv6address+"|"+h.ipvFuture+")\\]|"+h.ipv4address+"|"+G+")",re="(?:"+W+"@)?"+ue+"(?::\\d*)?",$="(?:"+W+"@)?("+ue+")(?::\\d*)?",H=g+"*",z=g+"+",te="(?:\\/"+H+")*",he="\\/(?:"+z+te+")?",Se=z+te,Fe="["+f+m+p+"@]+"+te,Re="(?:\\/\\/\\/"+H+te+")";return h.hierPart="(?:(?:\\/\\/"+re+te+")|"+he+"|"+Se+"|"+Re+")",h.hierPartCapture="(?:(?:\\/\\/"+$+te+")|"+he+"|"+Se+")",h.relativeRef="(?:(?:\\/\\/"+re+te+")|"+he+"|"+Fe+"|)",h.relativeRefCapture="(?:(?:\\/\\/"+$+te+")|"+he+"|"+Fe+"|)",h.query="["+v+"\\/\\?]*(?=#|$)",h.queryWithSquareBrackets="["+v+"\\[\\]\\/\\?]*(?=#|$)",h.fragment="["+v+"\\/\\?]*",h}};u.rfc3986=u.generate(),n.ip={v4Cidr:u.rfc3986.ipv4Cidr,v6Cidr:u.rfc3986.ipv6Cidr,ipv4:u.rfc3986.ipv4address,ipv6:u.rfc3986.ipv6address,ipvfuture:u.rfc3986.ipvFuture},u.createRegex=function(h){const l=u.rfc3986,d="(?:\\?"+(h.allowQuerySquareBrackets?l.queryWithSquareBrackets:l.query)+")?(?:#"+l.fragment+")?",f=h.domain?l.relativeRefCapture:l.relativeRef;if(h.relativeOnly)return u.wrap(f+d);let p="";if(h.scheme){o(h.scheme instanceof RegExp||typeof h.scheme=="string"||Array.isArray(h.scheme),"scheme must be a RegExp, String, or Array");const g=[].concat(h.scheme);o(g.length>=1,"scheme must have at least 1 scheme specified");const y=[];for(let b=0;b<g.length;++b){const k=g[b];o(k instanceof RegExp||typeof k=="string","scheme at position "+b+" must be a RegExp or String"),k instanceof RegExp?y.push(k.source.toString()):(o(l.schemeRegex.test(k),"scheme at position "+b+" must be a valid scheme"),y.push(c(k)))}p=y.join("|")}const m="(?:"+(p?"(?:"+p+")":l.scheme)+":"+(h.domain?l.hierPartCapture:l.hierPart)+")",v=h.allowRelative?"(?:"+m+"|"+f+")":m;return u.wrap(v+d,p)},u.wrap=function(h,l){return{raw:h=`(?=.)(?!https?:/(?:$|[^/]))(?!https?:///)(?!https?:[^/])${h}`,regex:new RegExp(`^${h}$`),scheme:l}},u.uriRegex=u.createRegex({}),n.regex=function(h={}){return h.scheme||h.allowRelative||h.relativeOnly||h.allowQuerySquareBrackets||h.domain?u.createRegex(h):u.uriRegex}},1447:(i,n)=>{const a={operators:["!","^","*","/","%","+","-","<","<=",">",">=","==","!=","&&","||","??"],operatorCharacters:["!","^","*","/","%","+","-","<","=",">","&","|","?"],operatorsOrder:[["^"],["*","/","%"],["+","-"],["<","<=",">",">="],["==","!="],["&&"],["||","??"]],operatorsPrefix:["!","n"],literals:{'"':'"',"`":"`","'":"'","[":"]"},numberRx:/^(?:[0-9]*(\.[0-9]*)?){1}$/,tokenRx:/^[\w\$\#\.\@\:\{\}]+$/,symbol:Symbol("formula"),settings:Symbol("settings")};n.Parser=class{constructor(o,c={}){if(!c[a.settings]&&c.constants)for(const u in c.constants){const h=c.constants[u];if(h!==null&&!["boolean","number","string"].includes(typeof h))throw new Error(`Formula constant ${u} contains invalid ${typeof h} value type`)}this.settings=c[a.settings]?c:Object.assign({[a.settings]:!0,constants:{},functions:{}},c),this.single=null,this._parts=null,this._parse(o)}_parse(o){let c=[],u="",h=0,l=!1;const d=p=>{if(h)throw new Error("Formula missing closing parenthesis");const m=c.length?c[c.length-1]:null;if(l||u||p){if(m&&m.type==="reference"&&p===")")return m.type="function",m.value=this._subFormula(u,m.value),void(u="");if(p===")"){const v=new n.Parser(u,this.settings);c.push({type:"segment",value:v})}else if(l){if(l==="]")return c.push({type:"reference",value:u}),void(u="");c.push({type:"literal",value:u})}else if(a.operatorCharacters.includes(u))m&&m.type==="operator"&&a.operators.includes(m.value+u)?m.value+=u:c.push({type:"operator",value:u});else if(u.match(a.numberRx))c.push({type:"constant",value:parseFloat(u)});else if(this.settings.constants[u]!==void 0)c.push({type:"constant",value:this.settings.constants[u]});else{if(!u.match(a.tokenRx))throw new Error(`Formula contains invalid token: ${u}`);c.push({type:"reference",value:u})}u=""}};for(const p of o)l?p===l?(d(),l=!1):u+=p:h?p==="("?(u+=p,++h):p===")"?(--h,h?u+=p:d(p)):u+=p:p in a.literals?l=a.literals[p]:p==="("?(d(),++h):a.operatorCharacters.includes(p)?(d(),u=p,d()):p!==" "?u+=p:d();d(),c=c.map((p,m)=>p.type!=="operator"||p.value!=="-"||m&&c[m-1].type!=="operator"?p:{type:"operator",value:"n"});let f=!1;for(const p of c){if(p.type==="operator"){if(a.operatorsPrefix.includes(p.value))continue;if(!f)throw new Error("Formula contains an operator in invalid position");if(!a.operators.includes(p.value))throw new Error(`Formula contains an unknown operator ${p.value}`)}else if(f)throw new Error("Formula missing expected operator");f=!f}if(!f)throw new Error("Formula contains invalid trailing operator");c.length===1&&["reference","literal","constant"].includes(c[0].type)&&(this.single={type:c[0].type==="reference"?"reference":"value",value:c[0].value}),this._parts=c.map(p=>{if(p.type==="operator")return a.operatorsPrefix.includes(p.value)?p:p.value;if(p.type!=="reference")return p.value;if(this.settings.tokenRx&&!this.settings.tokenRx.test(p.value))throw new Error(`Formula contains invalid reference ${p.value}`);return this.settings.reference?this.settings.reference(p.value):a.reference(p.value)})}_subFormula(o,c){const u=this.settings.functions[c];if(typeof u!="function")throw new Error(`Formula contains unknown function ${c}`);let h=[];if(o){let l="",d=0,f=!1;const p=()=>{if(!l)throw new Error(`Formula contains function ${c} with invalid arguments ${o}`);h.push(l),l=""};for(let m=0;m<o.length;++m){const v=o[m];f?(l+=v,v===f&&(f=!1)):v in a.literals&&!d?(l+=v,f=a.literals[v]):v!==","||d?(l+=v,v==="("?++d:v===")"&&--d):p()}p()}return h=h.map(l=>new n.Parser(l,this.settings)),function(l){const d=[];for(const f of h)d.push(f.evaluate(l));return u.call(l,...d)}}evaluate(o){const c=this._parts.slice();for(let u=c.length-2;u>=0;--u){const h=c[u];if(h&&h.type==="operator"){const l=c[u+1];c.splice(u+1,1);const d=a.evaluate(l,o);c[u]=a.single(h.value,d)}}return a.operatorsOrder.forEach(u=>{for(let h=1;h<c.length-1;)if(u.includes(c[h])){const l=c[h],d=a.evaluate(c[h-1],o),f=a.evaluate(c[h+1],o);c.splice(h,2);const p=a.calculate(l,d,f);c[h-1]=p===0?0:p}else h+=2}),a.evaluate(c[0],o)}},n.Parser.prototype[a.symbol]=!0,a.reference=function(o){return function(c){return c&&c[o]!==void 0?c[o]:null}},a.evaluate=function(o,c){return o===null?null:typeof o=="function"?o(c):o[a.symbol]?o.evaluate(c):o},a.single=function(o,c){if(o==="!")return!c;const u=-c;return u===0?0:u},a.calculate=function(o,c,u){if(o==="??")return a.exists(c)?c:u;if(typeof c=="string"||typeof u=="string"){if(o==="+")return(c=a.exists(c)?c:"")+(a.exists(u)?u:"")}else switch(o){case"^":return Math.pow(c,u);case"*":return c*u;case"/":return c/u;case"%":return c%u;case"+":return c+u;case"-":return c-u}switch(o){case"<":return c<u;case"<=":return c<=u;case">":return c>u;case">=":return c>=u;case"==":return c===u;case"!=":return c!==u;case"&&":return c&&u;case"||":return c||u}return null},a.exists=function(o){return o!=null}},9926:()=>{},5688:()=>{},9708:()=>{},1152:()=>{},443:()=>{},9848:()=>{},5934:i=>{i.exports=JSON.parse('{"version":"17.13.3"}')}},r={},function i(n){var a=r[n];if(a!==void 0)return a.exports;var o=r[n]={exports:{}};return t[n](o,o.exports,i),o.exports}(5107);var t,r})})(yl);var hd=yl.exports;const oe=Zr(hd),dd={utf16le:"utf-16le",ucs2:"utf-16le",utf16be:"utf-16be"};class ft{constructor(e){this.buffer=e,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.pos=0,this.length=this.buffer.length}readString(e,t="ascii"){t=dd[t]||t;let r=this.readBuffer(e);try{return new TextDecoder(t).decode(r)}catch{return r}}readBuffer(e){return this.buffer.slice(this.pos,this.pos+=e)}readUInt24BE(){return(this.readUInt16BE()<<8)+this.readUInt8()}readUInt24LE(){return this.readUInt16LE()+(this.readUInt8()<<16)}readInt24BE(){return(this.readInt16BE()<<8)+this.readUInt8()}readInt24LE(){return this.readUInt16LE()+(this.readInt8()<<16)}}ft.TYPES={UInt8:1,UInt16:2,UInt24:3,UInt32:4,Int8:1,Int16:2,Int24:3,Int32:4,Float:4,Double:8};for(let s of Object.getOwnPropertyNames(DataView.prototype))if(s.slice(0,3)==="get"){let e=s.slice(3).replace("Ui","UI");e==="Float32"?e="Float":e==="Float64"&&(e="Double");let t=ft.TYPES[e];ft.prototype["read"+e+(t===1?"":"BE")]=function(){const r=this.view[s](this.pos,!1);return this.pos+=t,r},t!==1&&(ft.prototype["read"+e+"LE"]=function(){const r=this.view[s](this.pos,!0);return this.pos+=t,r})}const fd=new TextEncoder,bl=new Uint8Array(new Uint16Array([4660]).buffer)[0]==18;class js{constructor(e){this.buffer=e,this.view=new DataView(this.buffer.buffer,this.buffer.byteOffset,this.buffer.byteLength),this.pos=0}writeBuffer(e){this.buffer.set(e,this.pos),this.pos+=e.length}writeString(e,t="ascii"){let r;switch(t){case"utf16le":case"utf16-le":case"ucs2":r=vl(e,bl);break;case"utf16be":case"utf16-be":r=vl(e,!bl);break;case"utf8":r=fd.encode(e);break;case"ascii":r=pd(e);break;default:throw new Error(`Unsupported encoding: ${t}`)}this.writeBuffer(r)}writeUInt24BE(e){this.buffer[this.pos++]=e>>>16&255,this.buffer[this.pos++]=e>>>8&255,this.buffer[this.pos++]=e&255}writeUInt24LE(e){this.buffer[this.pos++]=e&255,this.buffer[this.pos++]=e>>>8&255,this.buffer[this.pos++]=e>>>16&255}writeInt24BE(e){e>=0?this.writeUInt24BE(e):this.writeUInt24BE(e+16777215+1)}writeInt24LE(e){e>=0?this.writeUInt24LE(e):this.writeUInt24LE(e+16777215+1)}fill(e,t){if(t<this.buffer.length)this.buffer.fill(e,this.pos,this.pos+t),this.pos+=t;else{const r=new Uint8Array(t);r.fill(e),this.writeBuffer(r)}}}function vl(s,e){let t=new Uint16Array(s.length);for(let r=0;r<s.length;r++){let i=s.charCodeAt(r);e&&(i=i>>8|(i&255)<<8),t[r]=i}return new Uint8Array(t.buffer)}function pd(s){let e=new Uint8Array(s.length);for(let t=0;t<s.length;t++)e[t]=s.charCodeAt(t);return e}for(let s of Object.getOwnPropertyNames(DataView.prototype))if(s.slice(0,3)==="set"){let e=s.slice(3).replace("Ui","UI");e==="Float32"?e="Float":e==="Float64"&&(e="Double");let t=ft.TYPES[e];js.prototype["write"+e+(t===1?"":"BE")]=function(r){this.view[s](this.pos,r,!1),this.pos+=t},t!==1&&(js.prototype["write"+e+"LE"]=function(r){this.view[s](this.pos,r,!0),this.pos+=t})}class fr{fromBuffer(e){let t=new ft(e);return this.decode(t)}toBuffer(e){let t=this.size(e),r=new Uint8Array(t),i=new js(r);return this.encode(i,e),r}}class Ue extends fr{constructor(e,t="BE"){super(),this.type=e,this.endian=t,this.fn=this.type,this.type[this.type.length-1]!=="8"&&(this.fn+=this.endian)}size(){return ft.TYPES[this.type]}decode(e){return e[`read${this.fn}`]()}encode(e,t){return e[`write${this.fn}`](t)}}const K=new Ue("UInt8"),C=new Ue("UInt16","BE");new Ue("UInt16","LE");const Ar=new Ue("UInt24","BE");new Ue("UInt24","LE");const F=new Ue("UInt32","BE");new Ue("UInt32","LE");const ot=new Ue("Int8"),V=new Ue("Int16","BE");new Ue("Int16","LE"),new Ue("Int24","BE"),new Ue("Int24","LE");const Kr=new Ue("Int32","BE");new Ue("Int32","LE"),new Ue("Float","BE"),new Ue("Float","LE"),new Ue("Double","BE"),new Ue("Double","LE");class Yr extends Ue{constructor(e,t,r=e>>1){super(`Int${e}`,t),this._point=1<<r}decode(e){return super.decode(e)/this._point}encode(e,t){return super.encode(e,t*this._point|0)}}const md=new Yr(16,"BE");new Yr(16,"LE");const et=new Yr(32,"BE");new Yr(32,"LE");function Gt(s,e,t){let r;if(typeof s=="number"?r=s:typeof s=="function"?r=s.call(t,t):t&&typeof s=="string"?r=t[s]:e&&s instanceof Ue&&(r=s.decode(e)),isNaN(r))throw new Error("Not a fixed size");return r}class da{constructor(e={}){this.enumerable=!0,this.configurable=!0;for(let t in e){const r=e[t];this[t]=r}}}class I extends fr{constructor(e,t,r="count"){super(),this.type=e,this.length=t,this.lengthType=r}decode(e,t){let r;const{pos:i}=e,n=[];let a=t;if(this.length!=null&&(r=Gt(this.length,e,t)),this.length instanceof Ue&&(Object.defineProperties(n,{parent:{value:t},_startOffset:{value:i},_currentOffset:{value:0,writable:!0},_length:{value:r}}),a=n),r==null||this.lengthType==="bytes"){const o=r!=null?e.pos+r:t?._length?t._startOffset+t._length:e.length;for(;e.pos<o;)n.push(this.type.decode(e,a))}else for(let o=0,c=r;o<c;o++)n.push(this.type.decode(e,a));return n}size(e,t,r=!0){if(!e)return this.type.size(null,t)*Gt(this.length,null,t);let i=0;this.length instanceof Ue&&(i+=this.length.size(),t={parent:t,pointerSize:0});for(let n of e)i+=this.type.size(n,t);return t&&r&&this.length instanceof Ue&&(i+=t.pointerSize),i}encode(e,t,r){let i=r;this.length instanceof Ue&&(i={pointers:[],startOffset:e.pos,parent:r},i.pointerOffset=e.pos+this.size(t,i,!1),this.length.encode(e,t.length));for(let n of t)this.type.encode(e,n,i);if(this.length instanceof Ue){let n=0;for(;n<i.pointers.length;){const a=i.pointers[n++];a.type.encode(e,a.val,a.parent)}}}}class We extends I{decode(e,t){const{pos:r}=e,i=Gt(this.length,e,t);this.length instanceof Ue&&(t={parent:t,_startOffset:r,_currentOffset:0,_length:i});const n=new fa(this.type,i,e,t);return e.pos+=i*this.type.size(null,t),n}size(e,t){return e instanceof fa&&(e=e.toArray()),super.size(e,t)}encode(e,t,r){return t instanceof fa&&(t=t.toArray()),super.encode(e,t,r)}}class fa{constructor(e,t,r,i){this.type=e,this.length=t,this.stream=r,this.ctx=i,this.base=this.stream.pos,this.items=[]}get(e){if(!(e<0||e>=this.length)){if(this.items[e]==null){const{pos:t}=this.stream;this.stream.pos=this.base+this.type.size(null,this.ctx)*e,this.items[e]=this.type.decode(this.stream,this.ctx),this.stream.pos=t}return this.items[e]}}toArray(){const e=[];for(let t=0,r=this.length;t<r;t++)e.push(this.get(t));return e}}class Dt extends fr{constructor(e,t=[]){super(),this.type=e,this.flags=t}decode(e){const t=this.type.decode(e),r={};for(let i=0;i<this.flags.length;i++){const n=this.flags[i];n!=null&&(r[n]=!!(t&1<<i))}return r}size(){return this.type.size()}encode(e,t){let r=0;for(let i=0;i<this.flags.length;i++){const n=this.flags[i];n!=null&&t[n]&&(r|=1<<i)}return this.type.encode(e,r)}}class qt extends fr{constructor(e){super(),this.length=e}decode(e,t){const r=Gt(this.length,e,t);return e.readBuffer(r)}size(e,t){if(!e)return Gt(this.length,null,t);let r=e.length;return this.length instanceof Ue&&(r+=this.length.size()),r}encode(e,t,r){return this.length instanceof Ue&&this.length.encode(e,t.length),e.writeBuffer(t)}}class Ws extends fr{constructor(e,t=!0){super(),this.type=e,this.condition=t}decode(e,t){let{condition:r}=this;if(typeof r=="function"&&(r=r.call(t,t)),r)return this.type.decode(e,t)}size(e,t){let{condition:r}=this;return typeof r=="function"&&(r=r.call(t,t)),r?this.type.size(e,t):0}encode(e,t,r){let{condition:i}=this;if(typeof i=="function"&&(i=i.call(r,r)),i)return this.type.encode(e,t,r)}}class Ze extends fr{constructor(e,t=1){super(),this.type=e,this.count=t}decode(e,t){e.pos+=this.size(null,t)}size(e,t){const r=Gt(this.count,null,t);return this.type.size()*r}encode(e,t,r){return e.fill(0,this.size(t,r))}}class He extends fr{constructor(e,t="ascii"){super(),this.length=e,this.encoding=t}decode(e,t){let r,i,{encoding:n}=this;typeof n=="function"&&(n=n.call(t,t)||"ascii");let a=pa(n);if(this.length!=null)r=Gt(this.length,e,t);else{let c;for({buffer:c,length:r,pos:i}=e;i<r-a+1&&(c[i]!==0||a===2&&c[i+1]!==0);)i+=a;r=i-e.pos}const o=e.readString(r,n);return this.length==null&&e.pos<e.length&&(e.pos+=a),o}size(e,t){if(e==null)return Gt(this.length,null,t);let{encoding:r}=this;typeof r=="function"&&(r=r.call(t?.val,t?.val)||"ascii"),r==="utf16be"&&(r="utf16le");let i=wl(e,r);return this.length instanceof Ue&&(i+=this.length.size()),this.length==null&&(i+=pa(r)),i}encode(e,t,r){let{encoding:i}=this;if(typeof i=="function"&&(i=i.call(r?.val,r?.val)||"ascii"),this.length instanceof Ue&&this.length.encode(e,wl(t,i)),e.writeString(t,i),this.length==null)return pa(i)==2?e.writeUInt16LE(0):e.writeUInt8(0)}}function pa(s){switch(s){case"ascii":case"utf8":return 1;case"utf16le":case"utf16-le":case"utf-16be":case"utf-16le":case"utf16be":case"utf16-be":case"ucs2":return 2;default:return 1}}function wl(s,e){switch(e){case"ascii":return s.length;case"utf8":let t=0;for(let r=0;r<s.length;r++){let i=s.charCodeAt(r);if(i>=55296&&i<=56319&&r<s.length-1){let n=s.charCodeAt(++r);(n&64512)===56320?i=((i&1023)<<10)+(n&1023)+65536:r--}i&4294967168?i&4294965248?i&4294901760?i&4292870144||(t+=4):t+=3:t+=2:t++}return t;case"utf16le":case"utf16-le":case"utf16be":case"utf16-be":case"ucs2":return s.length*2;default:throw new Error("Unknown encoding "+e)}}class R extends fr{constructor(e={}){super(),this.fields=e}decode(e,t,r=0){const i=this._setup(e,t,r);return this._parseFields(e,i,this.fields),this.process!=null&&this.process.call(i,e),i}_setup(e,t,r){const i={};return Object.defineProperties(i,{parent:{value:t},_startOffset:{value:e.pos},_currentOffset:{value:0,writable:!0},_length:{value:r}}),i}_parseFields(e,t,r){for(let n in r){var i;const a=r[n];typeof a=="function"?i=a.call(t,t):i=a.decode(e,t),i!==void 0&&(i instanceof da?Object.defineProperty(t,n,i):t[n]=i),t._currentOffset=e.pos-t._startOffset}}size(e,t,r=!0){e==null&&(e={});const i={parent:t,val:e,pointerSize:0};this.preEncode!=null&&this.preEncode.call(e);let n=0;for(let a in this.fields){const o=this.fields[a];o.size!=null&&(n+=o.size(e[a],i))}return r&&(n+=i.pointerSize),n}encode(e,t,r){let i;this.preEncode!=null&&this.preEncode.call(t,e);const n={pointers:[],startOffset:e.pos,parent:r,val:t,pointerSize:0};n.pointerOffset=e.pos+this.size(t,n,!1);for(let o in this.fields)i=this.fields[o],i.encode!=null&&i.encode(e,t[o],n);let a=0;for(;a<n.pointers.length;){const o=n.pointers[a++];o.type.encode(e,o.val,o.parent)}}}const gd=(s,e)=>e.reduce((t,r)=>t&&t[r],s);class Ee extends R{constructor(e,t={}){super(),this.type=e,this.versions=t,typeof e=="string"&&(this.versionPath=e.split("."))}decode(e,t,r=0){const i=this._setup(e,t,r);typeof this.type=="string"?i.version=gd(t,this.versionPath):i.version=this.type.decode(e),this.versions.header&&this._parseFields(e,i,this.versions.header);const n=this.versions[i.version];if(n==null)throw new Error(`Unknown version ${i.version}`);return n instanceof Ee?n.decode(e,t):(this._parseFields(e,i,n),this.process!=null&&this.process.call(i,e),i)}size(e,t,r=!0){let i,n;if(!e)throw new Error("Not a fixed size");this.preEncode!=null&&this.preEncode.call(e);const a={parent:t,val:e,pointerSize:0};let o=0;if(typeof this.type!="string"&&(o+=this.type.size(e.version,a)),this.versions.header)for(i in this.versions.header)n=this.versions.header[i],n.size!=null&&(o+=n.size(e[i],a));const c=this.versions[e.version];if(c==null)throw new Error(`Unknown version ${e.version}`);for(i in c)n=c[i],n.size!=null&&(o+=n.size(e[i],a));return r&&(o+=a.pointerSize),o}encode(e,t,r){let i,n;this.preEncode!=null&&this.preEncode.call(t,e);const a={pointers:[],startOffset:e.pos,parent:r,val:t,pointerSize:0};if(a.pointerOffset=e.pos+this.size(t,a,!1),typeof this.type!="string"&&this.type.encode(e,t.version),this.versions.header)for(i in this.versions.header)n=this.versions.header[i],n.encode!=null&&n.encode(e,t[i],a);const o=this.versions[t.version];for(i in o)n=o[i],n.encode!=null&&n.encode(e,t[i],a);let c=0;for(;c<a.pointers.length;){const u=a.pointers[c++];u.type.encode(e,u.val,u.parent)}}}class O extends fr{constructor(e,t,r={}){if(super(),this.offsetType=e,this.type=t,this.options=r,this.type==="void"&&(this.type=null),this.options.type==null&&(this.options.type="local"),this.options.allowNull==null&&(this.options.allowNull=!0),this.options.nullValue==null&&(this.options.nullValue=0),this.options.lazy==null&&(this.options.lazy=!1),this.options.relativeTo){if(typeof this.options.relativeTo!="function")throw new Error("relativeTo option must be a function");this.relativeToGetter=r.relativeTo}}decode(e,t){const r=this.offsetType.decode(e,t);if(r===this.options.nullValue&&this.options.allowNull)return null;let i;switch(this.options.type){case"local":i=t._startOffset;break;case"immediate":i=e.pos-this.offsetType.size();break;case"parent":i=t.parent._startOffset;break;default:for(var n=t;n.parent;)n=n.parent;i=n._startOffset||0}this.options.relativeTo&&(i+=this.relativeToGetter(t));const a=r+i;if(this.type!=null){let o=null;const c=()=>{if(o!=null)return o;const{pos:u}=e;return e.pos=a,o=this.type.decode(e,t),e.pos=u,o};return this.options.lazy?new da({get:c}):c()}else return a}size(e,t){const r=t;switch(this.options.type){case"local":case"immediate":break;case"parent":t=t.parent;break;default:for(;t.parent;)t=t.parent}let{type:i}=this;if(i==null){if(!(e instanceof ma))throw new Error("Must be a VoidPointer");({type:i}=e),e=e.value}if(e&&t){let n=i.size(e,r);t.pointerSize+=n}return this.offsetType.size()}encode(e,t,r){let i;const n=r;if(t==null){this.offsetType.encode(e,this.options.nullValue);return}switch(this.options.type){case"local":i=r.startOffset;break;case"immediate":i=e.pos+this.offsetType.size(t,n);break;case"parent":r=r.parent,i=r.startOffset;break;default:for(i=0;r.parent;)r=r.parent}this.options.relativeTo&&(i+=this.relativeToGetter(n.val)),this.offsetType.encode(e,r.pointerOffset-i);let{type:a}=this;if(a==null){if(!(t instanceof ma))throw new Error("Must be a VoidPointer");({type:a}=t),t=t.value}return r.pointers.push({type:a,val:t,parent:n}),r.pointerOffset+=a.size(t,n)}}class ma{constructor(e,t){this.type=e,this.value=t}}function Ct(s,e,t){return e in s?Object.defineProperty(s,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[e]=t,s}function pt(s,e,t,r){var i=arguments.length,n=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(s,e,t,r);else for(var o=s.length-1;o>=0;o--)(a=s[o])&&(n=(i<3?a(n):i>3?a(e,t,n):a(e,t))||n);return i>3&&n&&Object.defineProperty(e,t,n),n}typeof SuppressedError=="function"&&SuppressedError;var yd=function s(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var r,i,n;if(Array.isArray(e)){if(r=e.length,r!=t.length)return!1;for(i=r;i--!==0;)if(!s(e[i],t[i]))return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(n=Object.keys(e),r=n.length,r!==Object.keys(t).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(t,n[i]))return!1;for(i=r;i--!==0;){var a=n[i];if(!s(e[a],t[a]))return!1}return!0}return e!==e&&t!==t};const xl=Zr(yd);var Ki={};Ki.byteLength=wd,Ki.toByteArray=Cd,Ki.fromByteArray=_d;for(var Xt=[],Rt=[],bd=typeof Uint8Array<"u"?Uint8Array:Array,ga="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",wi=0,vd=ga.length;wi<vd;++wi)Xt[wi]=ga[wi],Rt[ga.charCodeAt(wi)]=wi;Rt[45]=62,Rt[95]=63;function Cl(s){var e=s.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=s.indexOf("=");t===-1&&(t=e);var r=t===e?0:4-t%4;return[t,r]}function wd(s){var e=Cl(s),t=e[0],r=e[1];return(t+r)*3/4-r}function xd(s,e,t){return(e+t)*3/4-t}function Cd(s){var e,t=Cl(s),r=t[0],i=t[1],n=new bd(xd(s,r,i)),a=0,o=i>0?r-4:r,c;for(c=0;c<o;c+=4)e=Rt[s.charCodeAt(c)]<<18|Rt[s.charCodeAt(c+1)]<<12|Rt[s.charCodeAt(c+2)]<<6|Rt[s.charCodeAt(c+3)],n[a++]=e>>16&255,n[a++]=e>>8&255,n[a++]=e&255;return i===2&&(e=Rt[s.charCodeAt(c)]<<2|Rt[s.charCodeAt(c+1)]>>4,n[a++]=e&255),i===1&&(e=Rt[s.charCodeAt(c)]<<10|Rt[s.charCodeAt(c+1)]<<4|Rt[s.charCodeAt(c+2)]>>2,n[a++]=e>>8&255,n[a++]=e&255),n}function kd(s){return Xt[s>>18&63]+Xt[s>>12&63]+Xt[s>>6&63]+Xt[s&63]}function Sd(s,e,t){for(var r,i=[],n=e;n<t;n+=3)r=(s[n]<<16&16711680)+(s[n+1]<<8&65280)+(s[n+2]&255),i.push(kd(r));return i.join("")}function _d(s){for(var e,t=s.length,r=t%3,i=[],n=16383,a=0,o=t-r;a<o;a+=n)i.push(Sd(s,a,a+n>o?o:a+n));return r===1?(e=s[t-1],i.push(Xt[e>>2]+Xt[e<<4&63]+"==")):r===2&&(e=(s[t-2]<<8)+s[t-1],i.push(Xt[e>>10]+Xt[e>>4&63]+Xt[e<<2&63]+"=")),i.join("")}var ya=0,kl=-3;function Yi(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function Td(s,e){this.source=s,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=e,this.destLen=0,this.ltree=new Yi,this.dtree=new Yi}var Sl=new Yi,_l=new Yi,ba=new Uint8Array(30),va=new Uint16Array(30),Tl=new Uint8Array(30),El=new Uint16Array(30),Ed=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Al=new Yi,Zt=new Uint8Array(320);function Il(s,e,t,r){var i,n;for(i=0;i<t;++i)s[i]=0;for(i=0;i<30-t;++i)s[i+t]=i/t|0;for(n=r,i=0;i<30;++i)e[i]=n,n+=1<<s[i]}function Ad(s,e){var t;for(t=0;t<7;++t)s.table[t]=0;for(s.table[7]=24,s.table[8]=152,s.table[9]=112,t=0;t<24;++t)s.trans[t]=256+t;for(t=0;t<144;++t)s.trans[24+t]=t;for(t=0;t<8;++t)s.trans[168+t]=280+t;for(t=0;t<112;++t)s.trans[176+t]=144+t;for(t=0;t<5;++t)e.table[t]=0;for(e.table[5]=32,t=0;t<32;++t)e.trans[t]=t}var Pl=new Uint16Array(16);function wa(s,e,t,r){var i,n;for(i=0;i<16;++i)s.table[i]=0;for(i=0;i<r;++i)s.table[e[t+i]]++;for(s.table[0]=0,n=0,i=0;i<16;++i)Pl[i]=n,n+=s.table[i];for(i=0;i<r;++i)e[t+i]&&(s.trans[Pl[e[t+i]]++]=i)}function Id(s){s.bitcount--||(s.tag=s.source[s.sourceIndex++],s.bitcount=7);var e=s.tag&1;return s.tag>>>=1,e}function Kt(s,e,t){if(!e)return t;for(;s.bitcount<24;)s.tag|=s.source[s.sourceIndex++]<<s.bitcount,s.bitcount+=8;var r=s.tag&65535>>>16-e;return s.tag>>>=e,s.bitcount-=e,r+t}function xa(s,e){for(;s.bitcount<24;)s.tag|=s.source[s.sourceIndex++]<<s.bitcount,s.bitcount+=8;var t=0,r=0,i=0,n=s.tag;do r=2*r+(n&1),n>>>=1,++i,t+=e.table[i],r-=e.table[i];while(r>=0);return s.tag=n,s.bitcount-=i,e.trans[t+r]}function Pd(s,e,t){var r,i,n,a,o,c;for(r=Kt(s,5,257),i=Kt(s,5,1),n=Kt(s,4,4),a=0;a<19;++a)Zt[a]=0;for(a=0;a<n;++a){var u=Kt(s,3,0);Zt[Ed[a]]=u}for(wa(Al,Zt,0,19),o=0;o<r+i;){var h=xa(s,Al);switch(h){case 16:var l=Zt[o-1];for(c=Kt(s,2,3);c;--c)Zt[o++]=l;break;case 17:for(c=Kt(s,3,3);c;--c)Zt[o++]=0;break;case 18:for(c=Kt(s,7,11);c;--c)Zt[o++]=0;break;default:Zt[o++]=h;break}}wa(e,Zt,0,r),wa(t,Zt,r,i)}function Ol(s,e,t){for(;;){var r=xa(s,e);if(r===256)return ya;if(r<256)s.dest[s.destLen++]=r;else{var i,n,a,o;for(r-=257,i=Kt(s,ba[r],va[r]),n=xa(s,t),a=s.destLen-Kt(s,Tl[n],El[n]),o=a;o<a+i;++o)s.dest[s.destLen++]=s.dest[o]}}}function Od(s){for(var e,t,r;s.bitcount>8;)s.sourceIndex--,s.bitcount-=8;if(e=s.source[s.sourceIndex+1],e=256*e+s.source[s.sourceIndex],t=s.source[s.sourceIndex+3],t=256*t+s.source[s.sourceIndex+2],e!==(~t&65535))return kl;for(s.sourceIndex+=4,r=e;r;--r)s.dest[s.destLen++]=s.source[s.sourceIndex++];return s.bitcount=0,ya}function Fd(s,e){var t=new Td(s,e),r,i,n;do{switch(r=Id(t),i=Kt(t,2,0),i){case 0:n=Od(t);break;case 1:n=Ol(t,Sl,_l);break;case 2:Pd(t,t.ltree,t.dtree),n=Ol(t,t.ltree,t.dtree);break;default:n=kl}if(n!==ya)throw new Error("Data error")}while(!r);return t.destLen<t.dest.length?typeof t.dest.slice=="function"?t.dest.slice(0,t.destLen):t.dest.subarray(0,t.destLen):t.dest}Ad(Sl,_l),Il(ba,va,4,3),Il(Tl,El,2,1),ba[28]=0,va[28]=258;var Fl=Fd;const Rd=Zr(Fl),Md=new Uint8Array(new Uint32Array([305419896]).buffer)[0]===18,Rl=(s,e,t)=>{let r=s[e];s[e]=s[t],s[t]=r},Dd=s=>{const e=s.length;for(let t=0;t<e;t+=4)Rl(s,t,t+3),Rl(s,t+1,t+2)};var Bd={swap32LE:s=>{Md&&Dd(s)}};const Ml=Fl,{swap32LE:Ld}=Bd,Ca=11,Jr=5,zd=Ca-Jr,$d=65536>>Ca,Nd=(1<<zd)-1,Gs=2,ka=(1<<Jr)-1,Dl=65536>>Jr,Ud=1024>>Jr,Hd=Dl+Ud+32,Vd=1<<Gs;class jd{constructor(e){const t=typeof e.readUInt32BE=="function"&&typeof e.slice=="function";if(t||e instanceof Uint8Array){let r;if(t)this.highStart=e.readUInt32LE(0),this.errorValue=e.readUInt32LE(4),r=e.readUInt32LE(8),e=e.slice(12);else{const i=new DataView(e.buffer);this.highStart=i.getUint32(0,!0),this.errorValue=i.getUint32(4,!0),r=i.getUint32(8,!0),e=e.subarray(12)}e=Ml(e,new Uint8Array(r)),e=Ml(e,new Uint8Array(r)),Ld(e),this.data=new Uint32Array(e.buffer)}else({data:this.data,highStart:this.highStart,errorValue:this.errorValue}=e)}get(e){let t;return e<0||e>1114111?this.errorValue:e<55296||e>56319&&e<=65535?(t=(this.data[e>>Jr]<<Gs)+(e&ka),this.data[t]):e<=65535?(t=(this.data[Dl+(e-55296>>Jr)]<<Gs)+(e&ka),this.data[t]):e<this.highStart?(t=this.data[Hd-$d+(e>>Ca)],t=this.data[t+(e>>Jr&Nd)],t=(t<<Gs)+(e&ka),this.data[t]):this.data[this.data.length-Vd]}}var Wd=jd;const qs=Zr(Wd);function Qr(s){return s&&s.__esModule?s.default:s}var Ir={};Ir=JSON.parse('{"categories":["Cc","Zs","Po","Sc","Ps","Pe","Sm","Pd","Nd","Lu","Sk","Pc","Ll","So","Lo","Pi","Cf","No","Pf","Lt","Lm","Mn","Me","Mc","Nl","Zl","Zp","Cs","Co"],"combiningClasses":["Not_Reordered","Above","Above_Right","Below","Attached_Above_Right","Attached_Below","Overlay","Iota_Subscript","Double_Below","Double_Above","Below_Right","Above_Left","CCC10","CCC11","CCC12","CCC13","CCC14","CCC15","CCC16","CCC17","CCC18","CCC19","CCC20","CCC21","CCC22","CCC23","CCC24","CCC25","CCC30","CCC31","CCC32","CCC27","CCC28","CCC29","CCC33","CCC34","CCC35","CCC36","Nukta","Virama","CCC84","CCC91","CCC103","CCC107","CCC118","CCC122","CCC129","CCC130","CCC132","Attached_Above","Below_Left","Left","Kana_Voicing","CCC26","Right"],"scripts":["Common","Latin","Bopomofo","Inherited","Greek","Coptic","Cyrillic","Armenian","Hebrew","Arabic","Syriac","Thaana","Nko","Samaritan","Mandaic","Devanagari","Bengali","Gurmukhi","Gujarati","Oriya","Tamil","Telugu","Kannada","Malayalam","Sinhala","Thai","Lao","Tibetan","Myanmar","Georgian","Hangul","Ethiopic","Cherokee","Canadian_Aboriginal","Ogham","Runic","Tagalog","Hanunoo","Buhid","Tagbanwa","Khmer","Mongolian","Limbu","Tai_Le","New_Tai_Lue","Buginese","Tai_Tham","Balinese","Sundanese","Batak","Lepcha","Ol_Chiki","Braille","Glagolitic","Tifinagh","Han","Hiragana","Katakana","Yi","Lisu","Vai","Bamum","Syloti_Nagri","Phags_Pa","Saurashtra","Kayah_Li","Rejang","Javanese","Cham","Tai_Viet","Meetei_Mayek","null","Linear_B","Lycian","Carian","Old_Italic","Gothic","Old_Permic","Ugaritic","Old_Persian","Deseret","Shavian","Osmanya","Osage","Elbasan","Caucasian_Albanian","Linear_A","Cypriot","Imperial_Aramaic","Palmyrene","Nabataean","Hatran","Phoenician","Lydian","Meroitic_Hieroglyphs","Meroitic_Cursive","Kharoshthi","Old_South_Arabian","Old_North_Arabian","Manichaean","Avestan","Inscriptional_Parthian","Inscriptional_Pahlavi","Psalter_Pahlavi","Old_Turkic","Old_Hungarian","Hanifi_Rohingya","Old_Sogdian","Sogdian","Elymaic","Brahmi","Kaithi","Sora_Sompeng","Chakma","Mahajani","Sharada","Khojki","Multani","Khudawadi","Grantha","Newa","Tirhuta","Siddham","Modi","Takri","Ahom","Dogra","Warang_Citi","Nandinagari","Zanabazar_Square","Soyombo","Pau_Cin_Hau","Bhaiksuki","Marchen","Masaram_Gondi","Gunjala_Gondi","Makasar","Cuneiform","Egyptian_Hieroglyphs","Anatolian_Hieroglyphs","Mro","Bassa_Vah","Pahawh_Hmong","Medefaidrin","Miao","Tangut","Nushu","Duployan","SignWriting","Nyiakeng_Puachue_Hmong","Wancho","Mende_Kikakui","Adlam"],"eaw":["N","Na","A","W","H","F"]}');const Sa=new qs(Ki.toByteArray("AAARAAAAAADwfAEAZXl5ONRt+/5bPVFZimRfKoTQJNm37CGE7Iw0j3UsTWKsoyI7kwyyTiEUzSD7NiEzhWYijH0wMVkHE4Mx49fzfo+3nuP4/fdZjvv+XNd5n/d9nef1WZvmKhTxiZndzDQBSEYQqxqKwnsKvGQucFh+6t6cJ792ePQBZv5S9yXSwkyjf/P4T7mT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a)-1;function Zs(s){const e=Sa.get(s);return Qr(Ir).categories[e>>Xd&Yd]}function ef(s){const e=Sa.get(s);return Qr(Ir).combiningClasses[e>>Zd&Jd]}function Ll(s){const e=Sa.get(s);return Qr(Ir).scripts[e>>Kd&Qd]}function zl(s){return Zs(s)==="Nd"}function $l(s){const e=Zs(s);return e==="Mn"||e==="Me"||e==="Mc"}var Aa=1,Ia=0;class tf{constructor(e){this.stateTable=e.stateTable,this.accepting=e.accepting,this.tags=e.tags}match(e){var t=this;return{*[Symbol.iterator](){for(var r=Aa,i=null,n=null,a=null,o=0;o<e.length;o++){var c=e[o];a=r,r=t.stateTable[r][c],r===Ia&&(i!=null&&n!=null&&n>=i&&(yield[i,n,t.tags[a]]),r=t.stateTable[Aa][c],i=null),r!==Ia&&i==null&&(i=o),t.accepting[r]&&(n=o),r===Ia&&(r=Aa)}i!=null&&n!=null&&n>=i&&(yield[i,n,t.tags[r]])}}}apply(e,t){for(var[r,i,n]of this.match(e))for(var a of n)typeof t[a]=="function"&&t[a](r,i,e.slice(r,i+1))}}var rf=tf;const Nl=Zr(rf);var Ul={exports:{}};(function(s){var e=function(){function t(d,f){return f!=null&&d instanceof f}var r;try{r=Map}catch{r=function(){}}var i;try{i=Set}catch{i=function(){}}var n;try{n=Promise}catch{n=function(){}}function a(d,f,p,m,v){typeof f=="object"&&(p=f.depth,m=f.prototype,v=f.includeNonEnumerable,f=f.circular);var g=[],y=[],b=typeof Buffer<"u";typeof f>"u"&&(f=!0),typeof p>"u"&&(p=1/0);function k(x,E){if(x===null)return null;if(E===0)return x;var T,w;if(typeof x!="object")return x;if(t(x,r))T=new r;else if(t(x,i))T=new i;else if(t(x,n))T=new n(function(re,$){x.then(function(H){re(k(H,E-1))},function(H){$(k(H,E-1))})});else if(a.__isArray(x))T=[];else if(a.__isRegExp(x))T=new RegExp(x.source,l(x)),x.lastIndex&&(T.lastIndex=x.lastIndex);else if(a.__isDate(x))T=new Date(x.getTime());else{if(b&&Buffer.isBuffer(x))return Buffer.allocUnsafe?T=Buffer.allocUnsafe(x.length):T=new Buffer(x.length),x.copy(T),T;t(x,Error)?T=Object.create(x):typeof m>"u"?(w=Object.getPrototypeOf(x),T=Object.create(w)):(T=Object.create(m),w=m)}if(f){var S=g.indexOf(x);if(S!=-1)return y[S];g.push(x),y.push(T)}t(x,r)&&x.forEach(function(re,$){var H=k($,E-1),z=k(re,E-1);T.set(H,z)}),t(x,i)&&x.forEach(function(re){var $=k(re,E-1);T.add($)});for(var _ in x){var A;w&&(A=Object.getOwnPropertyDescriptor(w,_)),!(A&&A.set==null)&&(T[_]=k(x[_],E-1))}if(Object.getOwnPropertySymbols)for(var M=Object.getOwnPropertySymbols(x),_=0;_<M.length;_++){var D=M[_],W=Object.getOwnPropertyDescriptor(x,D);W&&!W.enumerable&&!v||(T[D]=k(x[D],E-1),W.enumerable||Object.defineProperty(T,D,{enumerable:!1}))}if(v)for(var G=Object.getOwnPropertyNames(x),_=0;_<G.length;_++){var ue=G[_],W=Object.getOwnPropertyDescriptor(x,ue);W&&W.enumerable||(T[ue]=k(x[ue],E-1),Object.defineProperty(T,ue,{enumerable:!1}))}return T}return k(d,p)}a.clonePrototype=function(f){if(f===null)return null;var p=function(){};return p.prototype=f,new p};function o(d){return Object.prototype.toString.call(d)}a.__objToStr=o;function c(d){return typeof d=="object"&&o(d)==="[object Date]"}a.__isDate=c;function u(d){return typeof d=="object"&&o(d)==="[object Array]"}a.__isArray=u;function h(d){return typeof d=="object"&&o(d)==="[object RegExp]"}a.__isRegExp=h;function l(d){var f="";return d.global&&(f+="g"),d.ignoreCase&&(f+="i"),d.multiline&&(f+="m"),f}return a.__getRegExpFlags=l,a}();s.exports&&(s.exports=e)})(Ul);var sf=Ul.exports;const Pa=Zr(sf);var Ji={},Ks={};function Hl(s){this.buffer=s,this.pos=0}Hl.prototype.read=function(s,e,t){this.pos+t>this.buffer.length&&(t=this.buffer.length-this.pos);for(var r=0;r<t;r++)s[e+r]=this.buffer[this.pos+r];return this.pos+=t,t},Ks.BrotliInput=Hl;function Vl(s){this.buffer=s,this.pos=0}Vl.prototype.write=function(s,e){if(this.pos+e>this.buffer.length)throw new Error("Output buffer is not large enough");return this.buffer.set(s.subarray(0,e),this.pos),this.pos+=e,e},Ks.BrotliOutput=Vl;var ei=4096,nf=2*ei+32,jl=2*ei-1,af=new Uint32Array([0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535,131071,262143,524287,1048575,2097151,4194303,8388607,16777215]);function ti(s){this.buf_=new Uint8Array(nf),this.input_=s,this.reset()}ti.READ_SIZE=ei,ti.IBUF_MASK=jl,ti.prototype.reset=function(){this.buf_ptr_=0,this.val_=0,this.pos_=0,this.bit_pos_=0,this.bit_end_pos_=0,this.eos_=0,this.readMoreInput();for(var s=0;s<4;s++)this.val_|=this.buf_[this.pos_]<<8*s,++this.pos_;return this.bit_end_pos_>0},ti.prototype.readMoreInput=function(){if(!(this.bit_end_pos_>256))if(this.eos_){if(this.bit_pos_>this.bit_end_pos_)throw new Error("Unexpected end of input "+this.bit_pos_+" "+this.bit_end_pos_)}else{var s=this.buf_ptr_,e=this.input_.read(this.buf_,s,ei);if(e<0)throw new Error("Unexpected end of input");if(e<ei){this.eos_=1;for(var t=0;t<32;t++)this.buf_[s+e+t]=0}if(s===0){for(var t=0;t<32;t++)this.buf_[(ei<<1)+t]=this.buf_[t];this.buf_ptr_=ei}else this.buf_ptr_=0;this.bit_end_pos_+=e<<3}},ti.prototype.fillBitWindow=function(){for(;this.bit_pos_>=8;)this.val_>>>=8,this.val_|=this.buf_[this.pos_&jl]<<24,++this.pos_,this.bit_pos_=this.bit_pos_-8>>>0,this.bit_end_pos_=this.bit_end_pos_-8>>>0},ti.prototype.readBits=function(s){32-this.bit_pos_<s&&this.fillBitWindow();var e=this.val_>>>this.bit_pos_&af[s];return this.bit_pos_+=s,e};var of=ti,Pr={},Oa={},Fa,Wl;function lf(){return Wl||(Wl=1,Fa="W5/fcQLn5gKf2XUbAiQ1XUL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otliDecompressBuffer,t=s.toByteArray(lf());return e(t)},Oa}var ql;function Xl(){if(ql)return Pr;ql=1;var s=cf();return Pr.init=function(){Pr.dictionary=s.init()},Pr.offsetsByLength=new Uint32Array([0,0,0,0,0,4096,9216,21504,35840,44032,53248,63488,74752,87040,93696,100864,104704,106752,108928,113536,115968,118528,119872,121280,122016]),Pr.sizeBitsByLength=new Uint8Array([0,0,0,0,10,10,11,11,10,10,10,10,10,9,9,8,7,7,8,7,7,6,6,5,5]),Pr.minDictionaryWordLength=4,Pr.maxDictionaryWordLength=24,Pr}var Ys={};function xi(s,e){this.bits=s,this.value=e}Ys.HuffmanCode=xi;var Ci=15;function Zl(s,e){for(var t=1<<e-1;s&t;)t>>=1;return(s&t-1)+t}function Kl(s,e,t,r,i){do r-=t,s[e+r]=new xi(i.bits,i.value);while(r>0)}function uf(s,e,t){for(var r=1<<e-t;e<Ci&&(r-=s[e],!(r<=0));)++e,r<<=1;return e-t}Ys.BrotliBuildHuffmanTable=function(s,e,t,r,i){var n=e,a,o,c,u,h,l,d,f,p,m,v,g=new Int32Array(Ci+1),y=new Int32Array(Ci+1);for(v=new Int32Array(i),c=0;c<i;c++)g[r[c]]++;for(y[1]=0,o=1;o<Ci;o++)y[o+1]=y[o]+g[o];for(c=0;c<i;c++)r[c]!==0&&(v[y[r[c]]++]=c);if(f=t,p=1<<f,m=p,y[Ci]===1){for(u=0;u<m;++u)s[e+u]=new xi(0,v[0]&65535);return m}for(u=0,c=0,o=1,h=2;o<=t;++o,h<<=1)for(;g[o]>0;--g[o])a=new xi(o&255,v[c++]&65535),Kl(s,e+u,h,p,a),u=Zl(u,o);for(d=m-1,l=-1,o=t+1,h=2;o<=Ci;++o,h<<=1)for(;g[o]>0;--g[o])(u&d)!==l&&(e+=p,f=uf(g,o,t),p=1<<f,m+=p,l=u&d,s[n+l]=new xi(f+t&255,e-n-l&65535)),a=new xi(o-t&255,v[c++]&65535),Kl(s,e+(u>>t),h,p,a),u=Zl(u,o);return m};var Ra={};Ra.lookup=new Uint8Array([0,0,0,0,0,0,0,0,0,4,4,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,12,16,12,12,20,12,16,24,28,12,12,32,12,36,12,44,44,44,44,44,44,44,44,44,44,32,32,24,40,28,12,12,48,52,52,52,48,52,52,52,48,52,52,52,52,52,48,52,52,52,52,52,48,52,52,52,52,52,24,12,28,12,12,12,56,60,60,60,56,60,60,60,56,60,60,60,60,60,56,60,60,60,60,60,56,60,60,60,60,60,24,12,28,12,0,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,0,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,56,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,11,11,11,11,12,12,12,12,13,13,13,13,14,14,14,14,15,15,15,15,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,22,22,22,22,23,23,23,23,24,24,24,24,25,25,25,25,26,26,26,26,27,27,27,27,28,28,28,28,29,29,29,29,30,30,30,30,31,31,31,31,32,32,32,32,33,33,33,33,34,34,34,34,35,35,35,35,36,36,36,36,37,37,37,37,38,38,38,38,39,39,39,39,40,40,40,40,41,41,41,41,42,42,42,42,43,43,43,43,44,44,44,44,45,45,45,45,46,46,46,46,47,47,47,47,48,48,48,48,49,49,49,49,50,50,50,50,51,51,51,51,52,52,52,52,53,53,53,53,54,54,54,54,55,55,55,55,56,56,56,56,57,57,57,57,58,58,58,58,59,59,59,59,60,60,60,60,61,61,61,61,62,62,62,62,63,63,63,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Ra.lookupOffsets=new Uint16Array([1024,1536,1280,1536,0,256,768,512]);var ki={};function ee(s,e){this.offset=s,this.nbits=e}ki.kBlockLengthPrefixCode=[new ee(1,2),new ee(5,2),new ee(9,2),new ee(13,2),new ee(17,3),new ee(25,3),new ee(33,3),new ee(41,3),new ee(49,4),new ee(65,4),new ee(81,4),new ee(97,4),new ee(113,5),new ee(145,5),new ee(177,5),new ee(209,5),new ee(241,6),new ee(305,6),new ee(369,7),new ee(497,8),new ee(753,9),new ee(1265,10),new ee(2289,11),new ee(4337,12),new ee(8433,13),new ee(16625,24)],ki.kInsertLengthPrefixCode=[new ee(0,0),new ee(1,0),new ee(2,0),new ee(3,0),new ee(4,0),new ee(5,0),new ee(6,1),new ee(8,1),new ee(10,2),new ee(14,2),new ee(18,3),new ee(26,3),new ee(34,4),new ee(50,4),new ee(66,5),new ee(98,5),new ee(130,6),new ee(194,7),new ee(322,8),new ee(578,9),new ee(1090,10),new ee(2114,12),new ee(6210,14),new ee(22594,24)],ki.kCopyLengthPrefixCode=[new ee(2,0),new ee(3,0),new ee(4,0),new ee(5,0),new ee(6,0),new ee(7,0),new ee(8,0),new ee(9,0),new ee(10,1),new ee(12,1),new ee(14,2),new ee(18,2),new ee(22,3),new ee(30,3),new ee(38,4),new ee(54,4),new ee(70,5),new ee(102,5),new ee(134,6),new ee(198,7),new ee(326,8),new ee(582,9),new ee(1094,10),new ee(2118,24)],ki.kInsertRangeLut=[0,0,8,8,0,16,8,16,16],ki.kCopyRangeLut=[0,8,0,8,16,0,16,8,16];var Qi={},Yl;function hf(){if(Yl)return Qi;Yl=1;var s=Xl(),e=0,t=1,r=2,i=3,n=4,a=5,o=6,c=7,u=8,h=9,l=10,d=11,f=12,p=13,m=14,v=15,g=16,y=17,b=18,k=20;function x(w,S,_){this.prefix=new Uint8Array(w.length),this.transform=S,this.suffix=new Uint8Array(_.length);for(var A=0;A<w.length;A++)this.prefix[A]=w.charCodeAt(A);for(var A=0;A<_.length;A++)this.suffix[A]=_.charCodeAt(A)}var E=[new x("",e,""),new x("",e," "),new x(" ",e," "),new x("",f,""),new x("",l," "),new x("",e," the "),new x(" ",e,""),new x("s ",e," "),new x("",e," of "),new x("",l,""),new x("",e," and "),new x("",p,""),new x("",t,""),new x(", ",e," "),new x("",e,", "),new x(" ",l," "),new x("",e," in "),new x("",e," to "),new x("e ",e," "),new x("",e,'"'),new x("",e,"."),new x("",e,'">'),new x("",e,`
183
+ `),new x("",i,""),new x("",e,"]"),new x("",e," for "),new x("",m,""),new x("",r,""),new x("",e," a "),new x("",e," that "),new x(" ",l,""),new x("",e,". "),new x(".",e,""),new x(" ",e,", "),new x("",v,""),new x("",e," with "),new x("",e,"'"),new x("",e," from "),new x("",e," by "),new x("",g,""),new x("",y,""),new x(" the ",e,""),new x("",n,""),new x("",e,". The "),new x("",d,""),new x("",e," on "),new x("",e," as "),new x("",e," is "),new x("",c,""),new x("",t,"ing "),new x("",e,`
184
+ `),new x("",e,":"),new x(" ",e,". "),new x("",e,"ed "),new x("",k,""),new x("",b,""),new x("",o,""),new x("",e,"("),new x("",l,", "),new x("",u,""),new x("",e," at "),new x("",e,"ly "),new x(" the ",e," of "),new x("",a,""),new x("",h,""),new x(" ",l,", "),new x("",l,'"'),new x(".",e,"("),new x("",d," "),new x("",l,'">'),new x("",e,'="'),new x(" ",e,"."),new x(".com/",e,""),new x(" the ",e," of the "),new x("",l,"'"),new x("",e,". This "),new x("",e,","),new x(".",e," "),new x("",l,"("),new x("",l,"."),new x("",e," not "),new x(" ",e,'="'),new x("",e,"er "),new x(" ",d," "),new x("",e,"al "),new x(" ",d,""),new x("",e,"='"),new x("",d,'"'),new x("",l,". "),new x(" ",e,"("),new x("",e,"ful "),new x(" ",l,". "),new x("",e,"ive "),new x("",e,"less "),new x("",d,"'"),new x("",e,"est "),new x(" ",l,"."),new x("",d,'">'),new x(" ",e,"='"),new x("",l,","),new x("",e,"ize "),new x("",d,"."),new x(" ",e,""),new x(" ",e,","),new x("",l,'="'),new x("",d,'="'),new x("",e,"ous "),new x("",d,", "),new x("",l,"='"),new x(" ",l,","),new x(" ",d,'="'),new x(" ",d,", "),new x("",d,","),new x("",d,"("),new x("",d,". "),new x(" ",d,"."),new x("",d,"='"),new x(" ",d,". "),new x(" ",l,'="'),new x(" ",d,"='"),new x(" ",l,"='")];Qi.kTransforms=E,Qi.kNumTransforms=E.length;function T(w,S){return w[S]<192?(w[S]>=97&&w[S]<=122&&(w[S]^=32),1):w[S]<224?(w[S+1]^=32,2):(w[S+2]^=5,3)}return Qi.transformDictionaryWord=function(w,S,_,A,M){var D=E[M].prefix,W=E[M].suffix,G=E[M].transform,ue=G<f?0:G-(f-1),re=0,$=S,H;ue>A&&(ue=A);for(var z=0;z<D.length;)w[S++]=D[z++];for(_+=ue,A-=ue,G<=h&&(A-=G),re=0;re<A;re++)w[S++]=s.dictionary[_+re];if(H=S-A,G===l)T(w,H);else if(G===d)for(;A>0;){var te=T(w,H);H+=te,A-=te}for(var he=0;he<W.length;)w[S++]=W[he++];return S-$},Qi}var Jl;function Ql(){if(Jl)return Ji;Jl=1;var s=Ks.BrotliInput,e=Ks.BrotliOutput,t=of,r=Xl(),i=Ys.HuffmanCode,n=Ys.BrotliBuildHuffmanTable,a=Ra,o=ki,c=hf(),u=8,h=16,l=256,d=704,f=26,p=6,m=2,v=8,g=255,y=1080,b=18,k=new Uint8Array([1,2,3,4,0,5,17,6,16,7,8,9,10,11,12,13,14,15]),x=16,E=new Uint8Array([3,2,1,0,3,3,3,3,3,3,2,2,2,2,2,2]),T=new Int8Array([0,0,0,0,-1,1,-2,2,-3,3,-1,1,-2,2,-3,3]),w=new Uint16Array([256,402,436,468,500,534,566,598,630,662,694,726,758,790,822,854,886,920,952,984,1016,1048,1080]);function S(j){var N;return j.readBits(1)===0?16:(N=j.readBits(3),N>0?17+N:(N=j.readBits(3),N>0?8+N:17))}function _(j){if(j.readBits(1)){var N=j.readBits(3);return N===0?1:j.readBits(N)+(1<<N)}return 0}function A(){this.meta_block_length=0,this.input_end=0,this.is_uncompressed=0,this.is_metadata=!1}function M(j){var N=new A,L,B,ie;if(N.input_end=j.readBits(1),N.input_end&&j.readBits(1))return N;if(L=j.readBits(2)+4,L===7){if(N.is_metadata=!0,j.readBits(1)!==0)throw new Error("Invalid reserved bit");if(B=j.readBits(2),B===0)return N;for(ie=0;ie<B;ie++){var fe=j.readBits(8);if(ie+1===B&&B>1&&fe===0)throw new Error("Invalid size byte");N.meta_block_length|=fe<<ie*8}}else for(ie=0;ie<L;++ie){var ae=j.readBits(4);if(ie+1===L&&L>4&&ae===0)throw new Error("Invalid size nibble");N.meta_block_length|=ae<<ie*4}return++N.meta_block_length,!N.input_end&&!N.is_metadata&&(N.is_uncompressed=j.readBits(1)),N}function D(j,N,L){var B;return L.fillBitWindow(),N+=L.val_>>>L.bit_pos_&g,B=j[N].bits-v,B>0&&(L.bit_pos_+=v,N+=j[N].value,N+=L.val_>>>L.bit_pos_&(1<<B)-1),L.bit_pos_+=j[N].bits,j[N].value}function W(j,N,L,B){for(var ie=0,fe=u,ae=0,de=0,ke=32768,le=[],J=0;J<32;J++)le.push(new i(0,0));for(n(le,0,5,j,b);ie<N&&ke>0;){var Te=0,Je;if(B.readMoreInput(),B.fillBitWindow(),Te+=B.val_>>>B.bit_pos_&31,B.bit_pos_+=le[Te].bits,Je=le[Te].value&255,Je<h)ae=0,L[ie++]=Je,Je!==0&&(fe=Je,ke-=32768>>Je);else{var dt=Je-14,Xe,it,st=0;if(Je===h&&(st=fe),de!==st&&(ae=0,de=st),Xe=ae,ae>0&&(ae-=2,ae<<=dt),ae+=B.readBits(dt)+3,it=ae-Xe,ie+it>N)throw new Error("[ReadHuffmanCodeLengths] symbol + repeat_delta > num_symbols");for(var wt=0;wt<it;wt++)L[ie+wt]=de;ie+=it,de!==0&&(ke-=it<<15-de)}}if(ke!==0)throw new Error("[ReadHuffmanCodeLengths] space = "+ke);for(;ie<N;ie++)L[ie]=0}function G(j,N,L,B){var ie=0,fe,ae=new Uint8Array(j);if(B.readMoreInput(),fe=B.readBits(2),fe===1){for(var de,ke=j-1,le=0,J=new Int32Array(4),Te=B.readBits(2)+1;ke;)ke>>=1,++le;for(de=0;de<Te;++de)J[de]=B.readBits(le)%j,ae[J[de]]=2;switch(ae[J[0]]=1,Te){case 1:break;case 3:if(J[0]===J[1]||J[0]===J[2]||J[1]===J[2])throw new Error("[ReadHuffmanCode] invalid symbols");break;case 2:if(J[0]===J[1])throw new Error("[ReadHuffmanCode] invalid symbols");ae[J[1]]=1;break;case 4:if(J[0]===J[1]||J[0]===J[2]||J[0]===J[3]||J[1]===J[2]||J[1]===J[3]||J[2]===J[3])throw new Error("[ReadHuffmanCode] invalid symbols");B.readBits(1)?(ae[J[2]]=3,ae[J[3]]=3):ae[J[0]]=2;break}}else{var de,Je=new Uint8Array(b),dt=32,Xe=0,it=[new i(2,0),new i(2,4),new i(2,3),new i(3,2),new i(2,0),new i(2,4),new i(2,3),new i(4,1),new i(2,0),new i(2,4),new i(2,3),new i(3,2),new i(2,0),new i(2,4),new i(2,3),new i(4,5)];for(de=fe;de<b&&dt>0;++de){var st=k[de],wt=0,_t;B.fillBitWindow(),wt+=B.val_>>>B.bit_pos_&15,B.bit_pos_+=it[wt].bits,_t=it[wt].value,Je[st]=_t,_t!==0&&(dt-=32>>_t,++Xe)}if(!(Xe===1||dt===0))throw new Error("[ReadHuffmanCode] invalid num_codes or space");W(Je,j,ae,B)}if(ie=n(N,L,v,ae,j),ie===0)throw new Error("[ReadHuffmanCode] BuildHuffmanTable failed: ");return ie}function ue(j,N,L){var B,ie;return B=D(j,N,L),ie=o.kBlockLengthPrefixCode[B].nbits,o.kBlockLengthPrefixCode[B].offset+L.readBits(ie)}function re(j,N,L){var B;return j<x?(L+=E[j],L&=3,B=N[L]+T[j]):B=j-x+1,B}function $(j,N){for(var L=j[N],B=N;B;--B)j[B]=j[B-1];j[0]=L}function H(j,N){var L=new Uint8Array(256),B;for(B=0;B<256;++B)L[B]=B;for(B=0;B<N;++B){var ie=j[B];j[B]=L[ie],ie&&$(L,ie)}}function z(j,N){this.alphabet_size=j,this.num_htrees=N,this.codes=new Array(N+N*w[j+31>>>5]),this.htrees=new Uint32Array(N)}z.prototype.decode=function(j){var N,L,B=0;for(N=0;N<this.num_htrees;++N)this.htrees[N]=B,L=G(this.alphabet_size,this.codes,B,j),B+=L};function te(j,N){var L={num_htrees:null,context_map:null},B,ie=0,fe,ae;N.readMoreInput();var de=L.num_htrees=_(N)+1,ke=L.context_map=new Uint8Array(j);if(de<=1)return L;for(B=N.readBits(1),B&&(ie=N.readBits(4)+1),fe=[],ae=0;ae<y;ae++)fe[ae]=new i(0,0);for(G(de+ie,fe,0,N),ae=0;ae<j;){var le;if(N.readMoreInput(),le=D(fe,0,N),le===0)ke[ae]=0,++ae;else if(le<=ie)for(var J=1+(1<<le)+N.readBits(le);--J;){if(ae>=j)throw new Error("[DecodeContextMap] i >= context_map_size");ke[ae]=0,++ae}else ke[ae]=le-ie,++ae}return N.readBits(1)&&H(ke,j),L}function he(j,N,L,B,ie,fe,ae){var de=L*2,ke=L,le=D(N,L*y,ae),J;le===0?J=ie[de+(fe[ke]&1)]:le===1?J=ie[de+(fe[ke]-1&1)]+1:J=le-2,J>=j&&(J-=j),B[L]=J,ie[de+(fe[ke]&1)]=J,++fe[ke]}function Se(j,N,L,B,ie,fe){var ae=ie+1,de=L&ie,ke=fe.pos_&t.IBUF_MASK,le;if(N<8||fe.bit_pos_+(N<<3)<fe.bit_end_pos_){for(;N-- >0;)fe.readMoreInput(),B[de++]=fe.readBits(8),de===ae&&(j.write(B,ae),de=0);return}if(fe.bit_end_pos_<32)throw new Error("[CopyUncompressedBlockToOutput] br.bit_end_pos_ < 32");for(;fe.bit_pos_<32;)B[de]=fe.val_>>>fe.bit_pos_,fe.bit_pos_+=8,++de,--N;if(le=fe.bit_end_pos_-fe.bit_pos_>>3,ke+le>t.IBUF_MASK){for(var J=t.IBUF_MASK+1-ke,Te=0;Te<J;Te++)B[de+Te]=fe.buf_[ke+Te];le-=J,de+=J,N-=J,ke=0}for(var Te=0;Te<le;Te++)B[de+Te]=fe.buf_[ke+Te];if(de+=le,N-=le,de>=ae){j.write(B,ae),de-=ae;for(var Te=0;Te<de;Te++)B[Te]=B[ae+Te]}for(;de+N>=ae;){if(le=ae-de,fe.input_.read(B,de,le)<le)throw new Error("[CopyUncompressedBlockToOutput] not enough bytes");j.write(B,ae),N-=le,de=0}if(fe.input_.read(B,de,N)<N)throw new Error("[CopyUncompressedBlockToOutput] not enough bytes");fe.reset()}function Fe(j){var N=j.bit_pos_+7&-8,L=j.readBits(N-j.bit_pos_);return L==0}function Re(j){var N=new s(j),L=new t(N);S(L);var B=M(L);return B.meta_block_length}Ji.BrotliDecompressedSize=Re;function Me(j,N){var L=new s(j);N==null&&(N=Re(j));var B=new Uint8Array(N),ie=new e(B);return Ke(L,ie),ie.pos<ie.buffer.length&&(ie.buffer=ie.buffer.subarray(0,ie.pos)),ie.buffer}Ji.BrotliDecompressBuffer=Me;function Ke(j,N){var L,B=0,ie=0,fe=0,ae,de=0,ke,le,J,Te,Je=[16,15,11,4],dt=0,Xe=0,it=0,st=[new z(0,0),new z(0,0),new z(0,0)],wt,_t,Ie,Uo=128+t.READ_SIZE;Ie=new t(j),fe=S(Ie),ae=(1<<fe)-16,ke=1<<fe,le=ke-1,J=new Uint8Array(ke+Uo+r.maxDictionaryWordLength),Te=ke,wt=[],_t=[];for(var $i=0;$i<3*y;$i++)wt[$i]=new i(0,0),_t[$i]=new i(0,0);for(;!ie;){var lt=0,Ps,Mt=[1<<28,1<<28,1<<28],Ut=[0],It=[1,1,1],vr=[0,1,0,1,0,1],di=[0],Wr,Pt,Gn,Ni,qn=null,Gr=null,Xn,Zn=null,Os,Kn=0,Ui=null,Ht=0,Hi=0,Fs=null,P=0,ne=0,Le=0,je,Ge;for(L=0;L<3;++L)st[L].codes=null,st[L].htrees=null;Ie.readMoreInput();var ct=M(Ie);if(lt=ct.meta_block_length,B+lt>N.buffer.length){var Vi=new Uint8Array(B+lt);Vi.set(N.buffer),N.buffer=Vi}if(ie=ct.input_end,Ps=ct.is_uncompressed,ct.is_metadata){for(Fe(Ie);lt>0;--lt)Ie.readMoreInput(),Ie.readBits(8);continue}if(lt!==0){if(Ps){Ie.bit_pos_=Ie.bit_pos_+7&-8,Se(N,lt,B,J,le,Ie),B+=lt;continue}for(L=0;L<3;++L)It[L]=_(Ie)+1,It[L]>=2&&(G(It[L]+2,wt,L*y,Ie),G(f,_t,L*y,Ie),Mt[L]=ue(_t,L*y,Ie),di[L]=1);for(Ie.readMoreInput(),Wr=Ie.readBits(2),Pt=x+(Ie.readBits(4)<<Wr),Gn=(1<<Wr)-1,Ni=Pt+(48<<Wr),Gr=new Uint8Array(It[0]),L=0;L<It[0];++L)Ie.readMoreInput(),Gr[L]=Ie.readBits(2)<<1;var Yn=te(It[0]<<p,Ie);Xn=Yn.num_htrees,qn=Yn.context_map;var Ho=te(It[2]<<m,Ie);for(Os=Ho.num_htrees,Zn=Ho.context_map,st[0]=new z(l,Xn),st[1]=new z(d,It[1]),st[2]=new z(Ni,Os),L=0;L<3;++L)st[L].decode(Ie);for(Ui=0,Fs=0,je=Gr[Ut[0]],ne=a.lookupOffsets[je],Le=a.lookupOffsets[je+1],Ge=st[1].htrees[0];lt>0;){var Jn,Rs,Vo,jo,Wo,Tt,Ot,wr,Ms,ji,Ds;for(Ie.readMoreInput(),Mt[1]===0&&(he(It[1],wt,1,Ut,vr,di,Ie),Mt[1]=ue(_t,y,Ie),Ge=st[1].htrees[Ut[1]]),--Mt[1],Jn=D(st[1].codes,Ge,Ie),Rs=Jn>>6,Rs>=2?(Rs-=2,Ot=-1):Ot=0,Vo=o.kInsertRangeLut[Rs]+(Jn>>3&7),jo=o.kCopyRangeLut[Rs]+(Jn&7),Wo=o.kInsertLengthPrefixCode[Vo].offset+Ie.readBits(o.kInsertLengthPrefixCode[Vo].nbits),Tt=o.kCopyLengthPrefixCode[jo].offset+Ie.readBits(o.kCopyLengthPrefixCode[jo].nbits),Xe=J[B-1&le],it=J[B-2&le],ji=0;ji<Wo;++ji)Ie.readMoreInput(),Mt[0]===0&&(he(It[0],wt,0,Ut,vr,di,Ie),Mt[0]=ue(_t,0,Ie),Kn=Ut[0]<<p,Ui=Kn,je=Gr[Ut[0]],ne=a.lookupOffsets[je],Le=a.lookupOffsets[je+1]),Ms=a.lookup[ne+Xe]|a.lookup[Le+it],Ht=qn[Ui+Ms],--Mt[0],it=Xe,Xe=D(st[0].codes,st[0].htrees[Ht],Ie),J[B&le]=Xe,(B&le)===le&&N.write(J,ke),++B;if(lt-=Wo,lt<=0)break;if(Ot<0){var Ms;if(Ie.readMoreInput(),Mt[2]===0&&(he(It[2],wt,2,Ut,vr,di,Ie),Mt[2]=ue(_t,2*y,Ie),Hi=Ut[2]<<m,Fs=Hi),--Mt[2],Ms=(Tt>4?3:Tt-2)&255,P=Zn[Fs+Ms],Ot=D(st[2].codes,st[2].htrees[P],Ie),Ot>=Pt){var Go,sh,Bs;Ot-=Pt,sh=Ot&Gn,Ot>>=Wr,Go=(Ot>>1)+1,Bs=(2+(Ot&1)<<Go)-4,Ot=Pt+(Bs+Ie.readBits(Go)<<Wr)+sh}}if(wr=re(Ot,Je,dt),wr<0)throw new Error("[BrotliDecompress] invalid distance");if(B<ae&&de!==ae?de=B:de=ae,Ds=B&le,wr>de)if(Tt>=r.minDictionaryWordLength&&Tt<=r.maxDictionaryWordLength){var Bs=r.offsetsByLength[Tt],nh=wr-de-1,ah=r.sizeBitsByLength[Tt],dx=(1<<ah)-1,fx=nh&dx,oh=nh>>ah;if(Bs+=fx*Tt,oh<c.kNumTransforms){var qo=c.transformDictionaryWord(J,Ds,Bs,Tt,oh);if(Ds+=qo,B+=qo,lt-=qo,Ds>=Te){N.write(J,ke);for(var Qn=0;Qn<Ds-Te;Qn++)J[Qn]=J[Te+Qn]}}else throw new Error("Invalid backward reference. pos: "+B+" distance: "+wr+" len: "+Tt+" bytes left: "+lt)}else throw new Error("Invalid backward reference. pos: "+B+" distance: "+wr+" len: "+Tt+" bytes left: "+lt);else{if(Ot>0&&(Je[dt&3]=wr,++dt),Tt>lt)throw new Error("Invalid backward reference. pos: "+B+" distance: "+wr+" len: "+Tt+" bytes left: "+lt);for(ji=0;ji<Tt;++ji)J[B&le]=J[B-wr&le],(B&le)===le&&N.write(J,ke),++B,--lt}Xe=J[B-1&le],it=J[B-2&le]}B&=1073741823}}N.write(J,B&le)}return Ji.BrotliDecompress=Ke,r.init(),Ji}var df=Ql().BrotliDecompressBuffer;const ff=Zr(df);function es(s,e,t,r){Object.defineProperty(s,e,{get:t,set:r,enumerable:!0,configurable:!0})}function Js(s){return s&&s.__esModule?s.default:s}var ts={};es(ts,"logErrors",()=>pf),es(ts,"registerFormat",()=>Si),es(ts,"create",()=>ec),es(ts,"defaultLanguage",()=>Qs),es(ts,"setDefaultLanguage",()=>mf);let pf=!1,Ma=[];function Si(s){Ma.push(s)}function ec(s,e){for(let t=0;t<Ma.length;t++){let r=Ma[t];if(r.probe(s)){let i=new r(new ft(s));return e?i.getFont(e):i}}throw new Error("Unknown font format")}let Qs="en";function mf(s="en"){Qs=s}function mt(s,e,t){if(t.get){let r=t.get;t.get=function(){let i=r.call(this);return Object.defineProperty(this,e,{value:i}),i}}else if(typeof t.value=="function"){let r=t.value;return{get(){let i=new Map;function n(...a){let o=a.length>0?a[0]:"value";if(i.has(o))return i.get(o);let c=r.apply(this,a);return i.set(o,c),c}return Object.defineProperty(this,e,{value:n}),n}}}}let gf=new R({firstCode:C,entryCount:C,idDelta:V,idRangeOffset:C}),Da=new R({startCharCode:F,endCharCode:F,glyphID:F}),yf=new R({startUnicodeValue:Ar,additionalCount:K}),bf=new R({unicodeValue:Ar,glyphID:C}),vf=new I(yf,F),wf=new I(bf,F),xf=new R({varSelector:Ar,defaultUVS:new O(F,vf,{type:"parent"}),nonDefaultUVS:new O(F,wf,{type:"parent"})}),Cf=new Ee(C,{0:{length:C,language:C,codeMap:new We(K,256)},2:{length:C,language:C,subHeaderKeys:new I(C,256),subHeaderCount:s=>Math.max.apply(Math,s.subHeaderKeys),subHeaders:new We(gf,"subHeaderCount"),glyphIndexArray:new We(C,"subHeaderCount")},4:{length:C,language:C,segCountX2:C,segCount:s=>s.segCountX2>>1,searchRange:C,entrySelector:C,rangeShift:C,endCode:new We(C,"segCount"),reservedPad:new Ze(C),startCode:new We(C,"segCount"),idDelta:new We(V,"segCount"),idRangeOffset:new We(C,"segCount"),glyphIndexArray:new We(C,s=>(s.length-s._currentOffset)/2)},6:{length:C,language:C,firstCode:C,entryCount:C,glyphIndices:new We(C,"entryCount")},8:{reserved:new Ze(C),length:F,language:C,is32:new We(K,8192),nGroups:F,groups:new We(Da,"nGroups")},10:{reserved:new Ze(C),length:F,language:F,firstCode:F,entryCount:F,glyphIndices:new We(C,"numChars")},12:{reserved:new Ze(C),length:F,language:F,nGroups:F,groups:new We(Da,"nGroups")},13:{reserved:new Ze(C),length:F,language:F,nGroups:F,groups:new We(Da,"nGroups")},14:{length:F,numRecords:F,varSelectors:new We(xf,"numRecords")}}),kf=new R({platformID:C,encodingID:C,table:new O(F,Cf,{type:"parent",lazy:!0})});var Sf=new R({version:C,numSubtables:C,tables:new I(kf,"numSubtables")}),_f=new R({version:Kr,revision:Kr,checkSumAdjustment:F,magicNumber:F,flags:C,unitsPerEm:C,created:new I(Kr,2),modified:new I(Kr,2),xMin:V,yMin:V,xMax:V,yMax:V,macStyle:new Dt(C,["bold","italic","underline","outline","shadow","condensed","extended"]),lowestRecPPEM:C,fontDirectionHint:V,indexToLocFormat:V,glyphDataFormat:V}),Tf=new R({version:Kr,ascent:V,descent:V,lineGap:V,advanceWidthMax:C,minLeftSideBearing:V,minRightSideBearing:V,xMaxExtent:V,caretSlopeRise:V,caretSlopeRun:V,caretOffset:V,reserved:new Ze(V,4),metricDataFormat:V,numberOfMetrics:C});let Ef=new R({advance:C,bearing:V});var Af=new R({metrics:new We(Ef,s=>s.parent.hhea.numberOfMetrics),bearings:new We(V,s=>s.parent.maxp.numGlyphs-s.parent.hhea.numberOfMetrics)}),If=new R({version:Kr,numGlyphs:C,maxPoints:C,maxContours:C,maxComponentPoints:C,maxComponentContours:C,maxZones:C,maxTwilightPoints:C,maxStorage:C,maxFunctionDefs:C,maxInstructionDefs:C,maxStackElements:C,maxSizeOfInstructions:C,maxComponentElements:C,maxComponentDepth:C});function tc(s,e,t=0){return s===1&&rc[t]?rc[t]:Rf[s][e]}const Pf=new Set(["x-mac-roman","x-mac-cyrillic","iso-8859-6","iso-8859-8"]),Of={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈ƫȅ ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ­","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüݰ¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"},Ba=new Map;function Ff(s){let e=Ba.get(s);if(e)return e;let t=Of[s];if(t){let r=new Map;for(let i=0;i<t.length;i++)r.set(t.charCodeAt(i),128+i);return Ba.set(s,r),r}if(Pf.has(s)){let r=new TextDecoder(s),i=new Uint8Array(128);for(let o=0;o<128;o++)i[o]=128+o;let n=new Map,a=r.decode(i);for(let o=0;o<128;o++)n.set(a.charCodeAt(o),128+o);return Ba.set(s,n),n}}const Rf=[["utf-16be","utf-16be","utf-16be","utf-16be","utf-16be","utf-16be","utf-16be"],["x-mac-roman","shift-jis","big5","euc-kr","iso-8859-6","iso-8859-8","x-mac-greek","x-mac-cyrillic","x-mac-symbol","x-mac-devanagari","x-mac-gurmukhi","x-mac-gujarati","Oriya","Bengali","Tamil","Telugu","Kannada","Malayalam","Sinhalese","Burmese","Khmer","iso-8859-11","Laotian","Georgian","Armenian","gbk","Tibetan","Mongolian","Geez","x-mac-ce","Vietnamese","Sindhi"],["ascii",null,"iso-8859-1"],["symbol","utf-16be","shift-jis","gb18030","big5","euc-kr","johab",null,null,null,"utf-16be"]],rc={15:"x-mac-icelandic",17:"x-mac-turkish",18:"x-mac-croatian",24:"x-mac-ce",25:"x-mac-ce",26:"x-mac-ce",27:"x-mac-ce",28:"x-mac-ce",30:"x-mac-icelandic",37:"x-mac-romanian",38:"x-mac-ce",39:"x-mac-ce",40:"x-mac-ce",143:"x-mac-inuit",146:"x-mac-gaelic"},Mf=[[],{0:"en",30:"fo",60:"ks",90:"rw",1:"fr",31:"fa",61:"ku",91:"rn",2:"de",32:"ru",62:"sd",92:"ny",3:"it",33:"zh",63:"bo",93:"mg",4:"nl",34:"nl-BE",64:"ne",94:"eo",5:"sv",35:"ga",65:"sa",128:"cy",6:"es",36:"sq",66:"mr",129:"eu",7:"da",37:"ro",67:"bn",130:"ca",8:"pt",38:"cz",68:"as",131:"la",9:"no",39:"sk",69:"gu",132:"qu",10:"he",40:"si",70:"pa",133:"gn",11:"ja",41:"yi",71:"or",134:"ay",12:"ar",42:"sr",72:"ml",135:"tt",13:"fi",43:"mk",73:"kn",136:"ug",14:"el",44:"bg",74:"ta",137:"dz",15:"is",45:"uk",75:"te",138:"jv",16:"mt",46:"be",76:"si",139:"su",17:"tr",47:"uz",77:"my",140:"gl",18:"hr",48:"kk",78:"km",141:"af",19:"zh-Hant",49:"az-Cyrl",79:"lo",142:"br",20:"ur",50:"az-Arab",80:"vi",143:"iu",21:"hi",51:"hy",81:"id",144:"gd",22:"th",52:"ka",82:"tl",145:"gv",23:"ko",53:"mo",83:"ms",146:"ga",24:"lt",54:"ky",84:"ms-Arab",147:"to",25:"pl",55:"tg",85:"am",148:"el-polyton",26:"hu",56:"tk",86:"ti",149:"kl",27:"es",57:"mn-CN",87:"om",150:"az",28:"lv",58:"mn",88:"so",151:"nn",29:"se",59:"ps",89:"sw"},[],{1078:"af",16393:"en-IN",1159:"rw",1074:"tn",1052:"sq",6153:"en-IE",1089:"sw",1115:"si",1156:"gsw",8201:"en-JM",1111:"kok",1051:"sk",1118:"am",17417:"en-MY",1042:"ko",1060:"sl",5121:"ar-DZ",5129:"en-NZ",1088:"ky",11274:"es-AR",15361:"ar-BH",13321:"en-PH",1108:"lo",16394:"es-BO",3073:"ar",18441:"en-SG",1062:"lv",13322:"es-CL",2049:"ar-IQ",7177:"en-ZA",1063:"lt",9226:"es-CO",11265:"ar-JO",11273:"en-TT",2094:"dsb",5130:"es-CR",13313:"ar-KW",2057:"en-GB",1134:"lb",7178:"es-DO",12289:"ar-LB",1033:"en",1071:"mk",12298:"es-EC",4097:"ar-LY",12297:"en-ZW",2110:"ms-BN",17418:"es-SV",6145:"ary",1061:"et",1086:"ms",4106:"es-GT",8193:"ar-OM",1080:"fo",1100:"ml",18442:"es-HN",16385:"ar-QA",1124:"fil",1082:"mt",2058:"es-MX",1025:"ar-SA",1035:"fi",1153:"mi",19466:"es-NI",10241:"ar-SY",2060:"fr-BE",1146:"arn",6154:"es-PA",7169:"aeb",3084:"fr-CA",1102:"mr",15370:"es-PY",14337:"ar-AE",1036:"fr",1148:"moh",10250:"es-PE",9217:"ar-YE",5132:"fr-LU",1104:"mn",20490:"es-PR",1067:"hy",6156:"fr-MC",2128:"mn-CN",3082:"es",1101:"as",4108:"fr-CH",1121:"ne",1034:"es",2092:"az-Cyrl",1122:"fy",1044:"nb",21514:"es-US",1068:"az",1110:"gl",2068:"nn",14346:"es-UY",1133:"ba",1079:"ka",1154:"oc",8202:"es-VE",1069:"eu",3079:"de-AT",1096:"or",2077:"sv-FI",1059:"be",1031:"de",1123:"ps",1053:"sv",2117:"bn",5127:"de-LI",1045:"pl",1114:"syr",1093:"bn-IN",4103:"de-LU",1046:"pt",1064:"tg",8218:"bs-Cyrl",2055:"de-CH",2070:"pt-PT",2143:"tzm",5146:"bs",1032:"el",1094:"pa",1097:"ta",1150:"br",1135:"kl",1131:"qu-BO",1092:"tt",1026:"bg",1095:"gu",2155:"qu-EC",1098:"te",1027:"ca",1128:"ha",3179:"qu",1054:"th",3076:"zh-HK",1037:"he",1048:"ro",1105:"bo",5124:"zh-MO",1081:"hi",1047:"rm",1055:"tr",2052:"zh",1038:"hu",1049:"ru",1090:"tk",4100:"zh-SG",1039:"is",9275:"smn",1152:"ug",1028:"zh-TW",1136:"ig",4155:"smj-NO",1058:"uk",1155:"co",1057:"id",5179:"smj",1070:"hsb",1050:"hr",1117:"iu",3131:"se-FI",1056:"ur",4122:"hr-BA",2141:"iu-Latn",1083:"se",2115:"uz-Cyrl",1029:"cs",2108:"ga",2107:"se-SE",1091:"uz",1030:"da",1076:"xh",8251:"sms",1066:"vi",1164:"prs",1077:"zu",6203:"sma-NO",1106:"cy",1125:"dv",1040:"it",7227:"sms",1160:"wo",2067:"nl-BE",2064:"it-CH",1103:"sa",1157:"sah",1043:"nl",1041:"ja",7194:"sr-Cyrl-BA",1144:"ii",3081:"en-AU",1099:"kn",3098:"sr",1130:"yo",10249:"en-BZ",1087:"kk",6170:"sr-Latn-BA",4105:"en-CA",1107:"km",2074:"sr-Latn",9225:"en-029",1158:"quc",1132:"nso"}];let ic=new R({platformID:C,encodingID:C,languageID:C,nameID:C,length:C,string:new O(C,new He("length",s=>tc(s.platformID,s.encodingID,s.languageID)),{type:"parent",relativeTo:s=>s.parent.stringOffset,allowNull:!1})}),Df=new R({length:C,tag:new O(C,new He("length","utf16be"),{type:"parent",relativeTo:s=>s.stringOffset})});var en=new Ee(C,{0:{count:C,stringOffset:C,records:new I(ic,"count")},1:{count:C,stringOffset:C,records:new I(ic,"count"),langTagCount:C,langTags:new I(Df,"langTagCount")}}),Bf=en;const La=["copyright","fontFamily","fontSubfamily","uniqueSubfamily","fullName","version","postscriptName","trademark","manufacturer","designer","description","vendorURL","designerURL","license","licenseURL",null,"preferredFamily","preferredSubfamily","compatibleFull","sampleText","postscriptCIDFontName","wwsFamilyName","wwsSubfamilyName"];en.process=function(s){var e={};for(let t of this.records){let r=Mf[t.platformID][t.languageID];r==null&&this.langTags!=null&&t.languageID>=32768&&(r=this.langTags[t.languageID-32768].tag),r==null&&(r=t.platformID+"-"+t.languageID);let i=t.nameID>=256?"fontFeatures":La[t.nameID]||t.nameID;e[i]==null&&(e[i]={});let n=e[i];t.nameID>=256&&(n=n[t.nameID]||(n[t.nameID]={})),(typeof t.string=="string"||typeof n[r]!="string")&&(n[r]=t.string)}this.records=e},en.preEncode=function(){if(Array.isArray(this.records))return;this.version=0;let s=[];for(let e in this.records){let t=this.records[e];e!=="fontFeatures"&&(s.push({platformID:3,encodingID:1,languageID:1033,nameID:La.indexOf(e),length:t.en.length*2,string:t.en}),e==="postscriptName"&&s.push({platformID:1,encodingID:0,languageID:0,nameID:La.indexOf(e),length:t.en.length,string:t.en}))}this.records=s,this.count=s.length,this.stringOffset=en.size(this,null,!1)};var sc=new Ee(C,{header:{xAvgCharWidth:V,usWeightClass:C,usWidthClass:C,fsType:new Dt(C,[null,"noEmbedding","viewOnly","editable",null,null,null,null,"noSubsetting","bitmapOnly"]),ySubscriptXSize:V,ySubscriptYSize:V,ySubscriptXOffset:V,ySubscriptYOffset:V,ySuperscriptXSize:V,ySuperscriptYSize:V,ySuperscriptXOffset:V,ySuperscriptYOffset:V,yStrikeoutSize:V,yStrikeoutPosition:V,sFamilyClass:V,panose:new I(K,10),ulCharRange:new I(F,4),vendorID:new He(4),fsSelection:new Dt(C,["italic","underscore","negative","outlined","strikeout","bold","regular","useTypoMetrics","wws","oblique"]),usFirstCharIndex:C,usLastCharIndex:C},0:{},1:{typoAscender:V,typoDescender:V,typoLineGap:V,winAscent:C,winDescent:C,codePageRange:new I(F,2)},2:{typoAscender:V,typoDescender:V,typoLineGap:V,winAscent:C,winDescent:C,codePageRange:new I(F,2),xHeight:V,capHeight:V,defaultChar:C,breakChar:C,maxContent:C},5:{typoAscender:V,typoDescender:V,typoLineGap:V,winAscent:C,winDescent:C,codePageRange:new I(F,2),xHeight:V,capHeight:V,defaultChar:C,breakChar:C,maxContent:C,usLowerOpticalPointSize:C,usUpperOpticalPointSize:C}});let za=sc.versions;za[3]=za[4]=za[2];var Lf=sc,zf=new Ee(et,{header:{italicAngle:et,underlinePosition:V,underlineThickness:V,isFixedPitch:F,minMemType42:F,maxMemType42:F,minMemType1:F,maxMemType1:F},1:{},2:{numberOfGlyphs:C,glyphNameIndex:new I(C,"numberOfGlyphs"),names:new I(new He(K))},2.5:{numberOfGlyphs:C,offsets:new I(K,"numberOfGlyphs")},3:{},4:{map:new I(F,s=>s.parent.maxp.numGlyphs)}}),$f=new R({controlValues:new I(V)}),Nf=new R({instructions:new I(K)});let $a=new Ee("head.indexToLocFormat",{0:{offsets:new I(C)},1:{offsets:new I(F)}});$a.process=function(){if(this.version===0&&!this._processed){for(let s=0;s<this.offsets.length;s++)this.offsets[s]<<=1;this._processed=!0}},$a.preEncode=function(){if(this.version===0&&this._processed!==!1){for(let s=0;s<this.offsets.length;s++)this.offsets[s]>>>=1;this._processed=!1}};var Uf=$a,Hf=new R({controlValueProgram:new I(K)}),Vf=new I(new qt);class Yt{getCFFVersion(e){for(;e&&!e.hdrSize;)e=e.parent;return e?e.version:-1}decode(e,t){let i=this.getCFFVersion(t)>=2?e.readUInt32BE():e.readUInt16BE();if(i===0)return[];let n=e.readUInt8(),a;if(n===1)a=K;else if(n===2)a=C;else if(n===3)a=Ar;else if(n===4)a=F;else throw new Error(`Bad offset size in CFFIndex: ${n} ${e.pos}`);let o=[],c=e.pos+(i+1)*n-1,u=a.decode(e);for(let h=0;h<i;h++){let l=a.decode(e);if(this.type!=null){let d=e.pos;e.pos=c+u,t.length=l-u,o.push(this.type.decode(e,t)),e.pos=d}else o.push({offset:c+u,length:l-u});u=l}return e.pos=c+u,o}size(e,t){let r=2;if(e.length===0)return r;let i=this.type||new qt,n=1;for(let o=0;o<e.length;o++){let c=e[o];n+=i.size(c,t)}let a;if(n<=255)a=K;else if(n<=65535)a=C;else if(n<=16777215)a=Ar;else if(n<=4294967295)a=F;else throw new Error("Bad offset in CFFIndex");return r+=1+a.size()*(e.length+1),r+=n-1,r}encode(e,t,r){if(e.writeUInt16BE(t.length),t.length===0)return;let i=this.type||new qt,n=[],a=1;for(let c of t){let u=i.size(c,r);n.push(u),a+=u}let o;if(a<=255)o=K;else if(a<=65535)o=C;else if(a<=16777215)o=Ar;else if(a<=4294967295)o=F;else throw new Error("Bad offset in CFFIndex");e.writeUInt8(o.size()),a=1,o.encode(e,a);for(let c of n)a+=c,o.encode(e,a);for(let c of t)i.encode(e,c,r)}constructor(e){this.type=e}}const rs=15,nc=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"],ac={".":10,E:11,"E-":12,"-":14};class Na{static decode(e,t){if(32<=t&&t<=246)return t-139;if(247<=t&&t<=250)return(t-247)*256+e.readUInt8()+108;if(251<=t&&t<=254)return-(t-251)*256-e.readUInt8()-108;if(t===28)return e.readInt16BE();if(t===29)return e.readInt32BE();if(t===30){let r="";for(;;){let i=e.readUInt8(),n=i>>4;if(n===rs)break;r+=nc[n];let a=i&15;if(a===rs)break;r+=nc[a]}return parseFloat(r)}return null}static size(e){if(e.forceLarge&&(e=32768),(e|0)!==e){let t=""+e;return 1+Math.ceil((t.length+1)/2)}else return-107<=e&&e<=107?1:108<=e&&e<=1131||-1131<=e&&e<=-108?2:-32768<=e&&e<=32767?3:5}static encode(e,t){let r=Number(t);if(t.forceLarge)return e.writeUInt8(29),e.writeInt32BE(r);if((r|0)!==r){e.writeUInt8(30);let n=""+r;for(let a=0;a<n.length;a+=2){let o=n[a],c=ac[o]||+o;if(a===n.length-1)var i=rs;else{let u=n[a+1];var i=ac[u]||+u}e.writeUInt8(c<<4|i&15)}if(i!==rs)return e.writeUInt8(rs<<4)}else return-107<=r&&r<=107?e.writeUInt8(r+139):108<=r&&r<=1131?(r-=108,e.writeUInt8((r>>8)+247),e.writeUInt8(r&255)):-1131<=r&&r<=-108?(r=-r-108,e.writeUInt8((r>>8)+251),e.writeUInt8(r&255)):-32768<=r&&r<=32767?(e.writeUInt8(28),e.writeInt16BE(r)):(e.writeUInt8(29),e.writeInt32BE(r))}}class tn{decodeOperands(e,t,r,i){if(Array.isArray(e))return i.map((n,a)=>this.decodeOperands(e[a],t,r,[n]));if(e.decode!=null)return e.decode(t,r,i);switch(e){case"number":case"offset":case"sid":return i[0];case"boolean":return!!i[0];default:return i}}encodeOperands(e,t,r,i){return Array.isArray(e)?i.map((n,a)=>this.encodeOperands(e[a],t,r,n)[0]):e.encode!=null?e.encode(t,i,r):typeof i=="number"?[i]:typeof i=="boolean"?[+i]:Array.isArray(i)?i:[i]}decode(e,t){let r=e.pos+t.length,i={},n=[];Object.defineProperties(i,{parent:{value:t},_startOffset:{value:e.pos}});for(let a in this.fields){let o=this.fields[a];i[o[1]]=o[3]}for(;e.pos<r;){let a=e.readUInt8();if(a<28){a===12&&(a=a<<8|e.readUInt8());let o=this.fields[a];if(!o)throw new Error(`Unknown operator ${a}`);let c=this.decodeOperands(o[2],e,i,n);c!=null&&(c instanceof da?Object.defineProperty(i,o[1],c):i[o[1]]=c),n=[]}else n.push(Na.decode(e,a))}return i}size(e,t,r=!0){let i={parent:t,val:e,pointerSize:0,startOffset:t.startOffset||0},n=0;for(let a in this.fields){let o=this.fields[a],c=e[o[1]];if(c==null||xl(c,o[3]))continue;let u=this.encodeOperands(o[2],null,i,c);for(let l of u)n+=Na.size(l);let h=Array.isArray(o[0])?o[0]:[o[0]];n+=h.length}return r&&(n+=i.pointerSize),n}encode(e,t,r){let i={pointers:[],startOffset:e.pos,parent:r,val:t,pointerSize:0};i.pointerOffset=e.pos+this.size(t,i,!1);for(let a of this.ops){let o=t[a[1]];if(o==null||xl(o,a[3]))continue;let c=this.encodeOperands(a[2],e,i,o);for(let h of c)Na.encode(e,h);let u=Array.isArray(a[0])?a[0]:[a[0]];for(let h of u)e.writeUInt8(h)}let n=0;for(;n<i.pointers.length;){let a=i.pointers[n++];a.type.encode(e,a.val,a.parent)}}constructor(e=[]){this.ops=e,this.fields={};for(let t of e){let r=Array.isArray(t[0])?t[0][0]<<8|t[0][1]:t[0];this.fields[r]=t}}}class Bt extends O{decode(e,t,r){return this.offsetType={decode:()=>r[0]},super.decode(e,t,r)}encode(e,t,r){if(!e)return this.offsetType={size:()=>0},this.size(t,r),[new oc(0)];let i=null;return this.offsetType={encode:(n,a)=>i=a},super.encode(e,t,r),[new oc(i)]}constructor(e,t={}){t.type==null&&(t.type="global"),super(null,e,t)}}class oc{valueOf(){return this.val}constructor(e){this.val=e,this.forceLarge=!0}}class jf{static decode(e,t,r){let i=r.pop();for(;r.length>i;)r.pop()}}var Ua=new tn([[6,"BlueValues","delta",null],[7,"OtherBlues","delta",null],[8,"FamilyBlues","delta",null],[9,"FamilyOtherBlues","delta",null],[[12,9],"BlueScale","number",.039625],[[12,10],"BlueShift","number",7],[[12,11],"BlueFuzz","number",1],[10,"StdHW","number",null],[11,"StdVW","number",null],[[12,12],"StemSnapH","delta",null],[[12,13],"StemSnapV","delta",null],[[12,14],"ForceBold","boolean",!1],[[12,17],"LanguageGroup","number",0],[[12,18],"ExpansionFactor","number",.06],[[12,19],"initialRandomSeed","number",0],[20,"defaultWidthX","number",0],[21,"nominalWidthX","number",0],[22,"vsindex","number",0],[23,"blend",jf,null],[19,"Subrs",new Bt(new Yt,{type:"local"}),null]]),rn=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"];let lc=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","","endash","dagger","daggerdbl","periodcentered","","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","","questiondown","","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","","ring","cedilla","","hungarumlaut","ogonek","caron","emdash","","","","","","","","","","","","","","","","","AE","","ordfeminine","","","","","Lslash","Oslash","OE","ordmasculine","","","","","","ae","","","","dotlessi","","","lslash","oslash","oe","germandbls"],Wf=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","","asuperior","bsuperior","centsuperior","dsuperior","esuperior","","","isuperior","","","lsuperior","msuperior","nsuperior","osuperior","","","rsuperior","ssuperior","tsuperior","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdownsmall","centoldstyle","Lslashsmall","","","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","","Dotaccentsmall","","","Macronsmall","","","figuredash","hypheninferior","","","Ogoneksmall","Ringsmall","Cedillasmall","","","","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],cc=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron"],Gf=[".notdef","space","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],qf=[".notdef","space","dollaroldstyle","dollarsuperior","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","hyphensuperior","colonmonetary","onefitted","rupiah","centoldstyle","figuredash","hypheninferior","onequarter","onehalf","threequarters","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior"],uc=new R({reserved:new Ze(C),reqFeatureIndex:C,featureCount:C,featureIndexes:new I(C,"featureCount")}),Xf=new R({tag:new He(4),langSys:new O(C,uc,{type:"parent"})}),Zf=new R({defaultLangSys:new O(C,uc),count:C,langSysRecords:new I(Xf,"count")}),Kf=new R({tag:new He(4),script:new O(C,Zf,{type:"parent"})}),hc=new I(Kf,C),Yf=new R({version:C,nameID:C}),dc=new R({featureParams:new O(C,Yf),lookupCount:C,lookupListIndexes:new I(C,"lookupCount")}),Jf=new R({tag:new He(4),feature:new O(C,dc,{type:"parent"})}),fc=new I(Jf,C),Qf=new R({markAttachmentType:K,flags:new Dt(K,["rightToLeft","ignoreBaseGlyphs","ignoreLigatures","ignoreMarks","useMarkFilteringSet"])});function sn(s){let e=new R({lookupType:C,flags:Qf,subTableCount:C,subTables:new I(new O(C,s),"subTableCount"),markFilteringSet:new Ws(C,t=>t.flags.flags.useMarkFilteringSet)});return new We(new O(C,e),C)}let ep=new R({start:C,end:C,startCoverageIndex:C}),Ve=new Ee(C,{1:{glyphCount:C,glyphs:new I(C,"glyphCount")},2:{rangeCount:C,rangeRecords:new I(ep,"rangeCount")}}),tp=new R({start:C,end:C,class:C}),Or=new Ee(C,{1:{startGlyph:C,glyphCount:C,classValueArray:new I(C,"glyphCount")},2:{classRangeCount:C,classRangeRecord:new I(tp,"classRangeCount")}}),Fr=new R({a:C,b:C,deltaFormat:C}),is=new R({sequenceIndex:C,lookupListIndex:C}),rp=new R({glyphCount:C,lookupCount:C,input:new I(C,s=>s.glyphCount-1),lookupRecords:new I(is,"lookupCount")}),ip=new I(new O(C,rp),C),sp=new R({glyphCount:C,lookupCount:C,classes:new I(C,s=>s.glyphCount-1),lookupRecords:new I(is,"lookupCount")}),np=new I(new O(C,sp),C),pc=new Ee(C,{1:{coverage:new O(C,Ve),ruleSetCount:C,ruleSets:new I(new O(C,ip),"ruleSetCount")},2:{coverage:new O(C,Ve),classDef:new O(C,Or),classSetCnt:C,classSet:new I(new O(C,np),"classSetCnt")},3:{glyphCount:C,lookupCount:C,coverages:new I(new O(C,Ve),"glyphCount"),lookupRecords:new I(is,"lookupCount")}}),ap=new R({backtrackGlyphCount:C,backtrack:new I(C,"backtrackGlyphCount"),inputGlyphCount:C,input:new I(C,s=>s.inputGlyphCount-1),lookaheadGlyphCount:C,lookahead:new I(C,"lookaheadGlyphCount"),lookupCount:C,lookupRecords:new I(is,"lookupCount")}),mc=new I(new O(C,ap),C),gc=new Ee(C,{1:{coverage:new O(C,Ve),chainCount:C,chainRuleSets:new I(new O(C,mc),"chainCount")},2:{coverage:new O(C,Ve),backtrackClassDef:new O(C,Or),inputClassDef:new O(C,Or),lookaheadClassDef:new O(C,Or),chainCount:C,chainClassSet:new I(new O(C,mc),"chainCount")},3:{backtrackGlyphCount:C,backtrackCoverage:new I(new O(C,Ve),"backtrackGlyphCount"),inputGlyphCount:C,inputCoverage:new I(new O(C,Ve),"inputGlyphCount"),lookaheadGlyphCount:C,lookaheadCoverage:new I(new O(C,Ve),"lookaheadGlyphCount"),lookupCount:C,lookupRecords:new I(is,"lookupCount")}}),ss=new Yr(16,"BE",14),op=new R({startCoord:ss,peakCoord:ss,endCoord:ss}),lp=new R({axisCount:C,regionCount:C,variationRegions:new I(new I(op,"axisCount"),"regionCount")}),cp=new R({shortDeltas:new I(V,s=>s.parent.shortDeltaCount),regionDeltas:new I(ot,s=>s.parent.regionIndexCount-s.parent.shortDeltaCount),deltas:s=>s.shortDeltas.concat(s.regionDeltas)}),up=new R({itemCount:C,shortDeltaCount:C,regionIndexCount:C,regionIndexes:new I(C,"regionIndexCount"),deltaSets:new I(cp,"itemCount")}),nn=new R({format:C,variationRegionList:new O(F,lp),variationDataCount:C,itemVariationData:new I(new O(F,up),"variationDataCount")}),hp=new Ee(C,{1:{axisIndex:C,axisIndex:C,filterRangeMinValue:ss,filterRangeMaxValue:ss}}),dp=new R({conditionCount:C,conditionTable:new I(new O(F,hp),"conditionCount")}),fp=new R({featureIndex:C,alternateFeatureTable:new O(F,dc,{type:"parent"})}),pp=new R({version:et,substitutionCount:C,substitutions:new I(fp,"substitutionCount")}),mp=new R({conditionSet:new O(F,dp,{type:"parent"}),featureTableSubstitution:new O(F,pp,{type:"parent"})}),yc=new R({majorVersion:C,minorVersion:C,featureVariationRecordCount:F,featureVariationRecords:new I(mp,"featureVariationRecordCount")});class bc{decode(e,t,r){return this.predefinedOps[r[0]]?this.predefinedOps[r[0]]:this.type.decode(e,t,r)}size(e,t){return this.type.size(e,t)}encode(e,t,r){let i=this.predefinedOps.indexOf(t);return i!==-1?i:this.type.encode(e,t,r)}constructor(e,t){this.predefinedOps=e,this.type=t}}class gp extends Ue{decode(e){return K.decode(e)&127}constructor(){super("UInt8")}}let vc=new R({first:C,nLeft:K}),yp=new R({first:C,nLeft:C}),bp=new Ee(new gp,{0:{nCodes:K,codes:new I(K,"nCodes")},1:{nRanges:K,ranges:new I(vc,"nRanges")}}),vp=new bc([lc,Wf],new Bt(bp,{lazy:!0}));class wc extends I{decode(e,t){let r=Gt(this.length,e,t),i=0,n=[];for(;i<r;){let a=this.type.decode(e,t);a.offset=i,i+=a.nLeft+1,n.push(a)}return n}}let wp=new Ee(K,{0:{glyphs:new I(C,s=>s.parent.CharStrings.length-1)},1:{ranges:new wc(vc,s=>s.parent.CharStrings.length-1)},2:{ranges:new wc(yp,s=>s.parent.CharStrings.length-1)}}),xp=new bc([cc,Gf,qf],new Bt(wp,{lazy:!0})),Cp=new R({first:C,fd:K}),kp=new R({first:F,fd:C}),xc=new Ee(K,{0:{fds:new I(K,s=>s.parent.CharStrings.length)},3:{nRanges:C,ranges:new I(Cp,"nRanges"),sentinel:C},4:{nRanges:F,ranges:new I(kp,"nRanges"),sentinel:F}}),Ha=new Bt(Ua);class Cc{decode(e,t,r){return t.length=r[0],Ha.decode(e,t,[r[1]])}size(e,t){return[Ua.size(e,t,!1),Ha.size(e,t)[0]]}encode(e,t,r){return[Ua.size(t,r,!1),Ha.encode(e,t,r)[0]]}}let kc=new tn([[18,"Private",new Cc,null],[[12,38],"FontName","sid",null],[[12,7],"FontMatrix","array",[.001,0,0,.001,0,0]],[[12,5],"PaintType","number",0]]),Sp=new tn([[[12,30],"ROS",["sid","sid","number"],null],[0,"version","sid",null],[1,"Notice","sid",null],[[12,0],"Copyright","sid",null],[2,"FullName","sid",null],[3,"FamilyName","sid",null],[4,"Weight","sid",null],[[12,1],"isFixedPitch","boolean",!1],[[12,2],"ItalicAngle","number",0],[[12,3],"UnderlinePosition","number",-100],[[12,4],"UnderlineThickness","number",50],[[12,5],"PaintType","number",0],[[12,6],"CharstringType","number",2],[[12,7],"FontMatrix","array",[.001,0,0,.001,0,0]],[13,"UniqueID","number",null],[5,"FontBBox","array",[0,0,0,0]],[[12,8],"StrokeWidth","number",0],[14,"XUID","array",null],[15,"charset",xp,cc],[16,"Encoding",vp,lc],[17,"CharStrings",new Bt(new Yt),null],[18,"Private",new Cc,null],[[12,20],"SyntheticBase","number",null],[[12,21],"PostScript","sid",null],[[12,22],"BaseFontName","sid",null],[[12,23],"BaseFontBlend","delta",null],[[12,31],"CIDFontVersion","number",0],[[12,32],"CIDFontRevision","number",0],[[12,33],"CIDFontType","number",0],[[12,34],"CIDCount","number",8720],[[12,35],"UIDBase","number",null],[[12,37],"FDSelect",new Bt(xc),null],[[12,36],"FDArray",new Bt(new Yt(kc)),null],[[12,38],"FontName","sid",null]]),_p=new R({length:C,itemVariationStore:nn}),Tp=new tn([[[12,7],"FontMatrix","array",[.001,0,0,.001,0,0]],[17,"CharStrings",new Bt(new Yt),null],[[12,37],"FDSelect",new Bt(xc),null],[[12,36],"FDArray",new Bt(new Yt(kc)),null],[24,"vstore",new Bt(_p),null],[25,"maxstack","number",193]]);var Sc=new Ee(md,{1:{hdrSize:K,offSize:K,nameIndex:new Yt(new He("length")),topDictIndex:new Yt(Sp),stringIndex:new Yt(new He("length")),globalSubrIndex:new Yt},2:{hdrSize:K,length:C,topDict:Tp,globalSubrIndex:new Yt}});class Va{static decode(e){return new Va(e)}decode(){this.stream.pos;let e=Sc.decode(this.stream);for(let t in e){let r=e[t];this[t]=r}if(this.version<2){if(this.topDictIndex.length!==1)throw new Error("Only a single font is allowed in CFF");this.topDict=this.topDictIndex[0]}return this.isCIDFont=this.topDict.ROS!=null,this}string(e){return this.version>=2?null:e<rn.length?rn[e]:this.stringIndex[e-rn.length]}get postscriptName(){return this.version<2?this.nameIndex[0]:null}get fullName(){return this.string(this.topDict.FullName)}get familyName(){return this.string(this.topDict.FamilyName)}getCharString(e){return this.stream.pos=this.topDict.CharStrings[e].offset,this.stream.readBuffer(this.topDict.CharStrings[e].length)}getGlyphName(e){if(this.version>=2||this.isCIDFont)return null;let{charset:t}=this.topDict;if(Array.isArray(t))return t[e];if(e===0)return".notdef";switch(e-=1,t.version){case 0:return this.string(t.glyphs[e]);case 1:case 2:for(let r=0;r<t.ranges.length;r++){let i=t.ranges[r];if(i.offset<=e&&e<=i.offset+i.nLeft)return this.string(i.first+(e-i.offset))}break}return null}fdForGlyph(e){if(!this.topDict.FDSelect)return null;switch(this.topDict.FDSelect.version){case 0:return this.topDict.FDSelect.fds[e];case 3:case 4:let{ranges:t}=this.topDict.FDSelect,r=0,i=t.length-1;for(;r<=i;){let n=r+i>>1;if(e<t[n].first)i=n-1;else if(n<i&&e>=t[n+1].first)r=n+1;else return t[n].fd}default:throw new Error(`Unknown FDSelect version: ${this.topDict.FDSelect.version}`)}}privateDictForGlyph(e){if(this.topDict.FDSelect){let t=this.fdForGlyph(e);return this.topDict.FDArray[t]?this.topDict.FDArray[t].Private:null}return this.version<2?this.topDict.Private:this.topDict.FDArray[0].Private}constructor(e){this.stream=e,this.decode()}}var _c=Va;let Ep=new R({glyphIndex:C,vertOriginY:V});var Ap=new R({majorVersion:C,minorVersion:C,defaultVertOriginY:V,numVertOriginYMetrics:C,metrics:new I(Ep,"numVertOriginYMetrics")});let _i=new R({height:K,width:K,horiBearingX:ot,horiBearingY:ot,horiAdvance:K,vertBearingX:ot,vertBearingY:ot,vertAdvance:K}),an=new R({height:K,width:K,bearingX:ot,bearingY:ot,advance:K}),Tc=new R({glyph:C,xOffset:ot,yOffset:ot});class Ec{}class ja{}new Ee("version",{1:{metrics:an,data:Ec},2:{metrics:an,data:ja},5:{data:ja},6:{metrics:_i,data:Ec},7:{metrics:_i,data:ja},8:{metrics:an,pad:new Ze(K),numComponents:C,components:new I(Tc,"numComponents")},9:{metrics:_i,pad:new Ze(K),numComponents:C,components:new I(Tc,"numComponents")},17:{metrics:an,dataLen:F,data:new qt("dataLen")},18:{metrics:_i,dataLen:F,data:new qt("dataLen")},19:{dataLen:F,data:new qt("dataLen")}});let Ac=new R({ascender:ot,descender:ot,widthMax:K,caretSlopeNumerator:ot,caretSlopeDenominator:ot,caretOffset:ot,minOriginSB:ot,minAdvanceSB:ot,maxBeforeBL:ot,minAfterBL:ot,pad:new Ze(ot,2)}),Ip=new R({glyphCode:C,offset:C}),Pp=new Ee(C,{header:{imageFormat:C,imageDataOffset:F},1:{offsetArray:new I(F,s=>s.parent.lastGlyphIndex-s.parent.firstGlyphIndex+1)},2:{imageSize:F,bigMetrics:_i},3:{offsetArray:new I(C,s=>s.parent.lastGlyphIndex-s.parent.firstGlyphIndex+1)},4:{numGlyphs:F,glyphArray:new I(Ip,s=>s.numGlyphs+1)},5:{imageSize:F,bigMetrics:_i,numGlyphs:F,glyphCodeArray:new I(C,"numGlyphs")}}),Op=new R({firstGlyphIndex:C,lastGlyphIndex:C,subtable:new O(F,Pp)}),Fp=new R({indexSubTableArray:new O(F,new I(Op,1),{type:"parent"}),indexTablesSize:F,numberOfIndexSubTables:F,colorRef:F,hori:Ac,vert:Ac,startGlyphIndex:C,endGlyphIndex:C,ppemX:K,ppemY:K,bitDepth:K,flags:new Dt(K,["horizontal","vertical"])});var Rp=new R({version:F,numSizes:F,sizes:new I(Fp,"numSizes")});let Mp=new R({ppem:C,resolution:C,imageOffsets:new I(new O(F,"void"),s=>s.parent.parent.maxp.numGlyphs+1)});var Dp=new R({version:C,flags:new Dt(C,["renderOutlines"]),numImgTables:F,imageTables:new I(new O(F,Mp),"numImgTables")});let Bp=new R({gid:C,paletteIndex:C}),Lp=new R({gid:C,firstLayerIndex:C,numLayers:C});var zp=new R({version:C,numBaseGlyphRecords:C,baseGlyphRecord:new O(F,new I(Lp,"numBaseGlyphRecords")),layerRecords:new O(F,new I(Bp,"numLayerRecords"),{lazy:!0}),numLayerRecords:C});let $p=new R({blue:K,green:K,red:K,alpha:K});var Np=new Ee(C,{header:{numPaletteEntries:C,numPalettes:C,numColorRecords:C,colorRecords:new O(F,new I($p,"numColorRecords")),colorRecordIndices:new I(C,"numPalettes")},0:{},1:{offsetPaletteTypeArray:new O(F,new I(F,"numPalettes")),offsetPaletteLabelArray:new O(F,new I(C,"numPalettes")),offsetPaletteEntryLabelArray:new O(F,new I(C,"numPaletteEntries"))}});let ns=new Ee(C,{1:{coordinate:V},2:{coordinate:V,referenceGlyph:C,baseCoordPoint:C},3:{coordinate:V,deviceTable:new O(C,Fr)}}),Up=new R({defaultIndex:C,baseCoordCount:C,baseCoords:new I(new O(C,ns),"baseCoordCount")}),Hp=new R({tag:new He(4),minCoord:new O(C,ns,{type:"parent"}),maxCoord:new O(C,ns,{type:"parent"})}),Ic=new R({minCoord:new O(C,ns),maxCoord:new O(C,ns),featMinMaxCount:C,featMinMaxRecords:new I(Hp,"featMinMaxCount")}),Vp=new R({tag:new He(4),minMax:new O(C,Ic,{type:"parent"})}),jp=new R({baseValues:new O(C,Up),defaultMinMax:new O(C,Ic),baseLangSysCount:C,baseLangSysRecords:new I(Vp,"baseLangSysCount")}),Wp=new R({tag:new He(4),script:new O(C,jp,{type:"parent"})}),Gp=new I(Wp,C),qp=new I(new He(4),C),Pc=new R({baseTagList:new O(C,qp),baseScriptList:new O(C,Gp)});var Xp=new Ee(F,{header:{horizAxis:new O(C,Pc),vertAxis:new O(C,Pc)},65536:{},65537:{itemVariationStore:new O(F,nn)}});let Zp=new I(C,C),Kp=new R({coverage:new O(C,Ve),glyphCount:C,attachPoints:new I(new O(C,Zp),"glyphCount")}),Yp=new Ee(C,{1:{coordinate:V},2:{caretValuePoint:C},3:{coordinate:V,deviceTable:new O(C,Fr)}}),Jp=new I(new O(C,Yp),C),Qp=new R({coverage:new O(C,Ve),ligGlyphCount:C,ligGlyphs:new I(new O(C,Jp),"ligGlyphCount")}),Oc=new R({markSetTableFormat:C,markSetCount:C,coverage:new I(new O(F,Ve),"markSetCount")});var em=new Ee(F,{header:{glyphClassDef:new O(C,Or),attachList:new O(C,Kp),ligCaretList:new O(C,Qp),markAttachClassDef:new O(C,Or)},65536:{},65538:{markGlyphSetsDef:new O(C,Oc)},65539:{markGlyphSetsDef:new O(C,Oc),itemVariationStore:new O(F,nn)}});let Ti=new Dt(C,["xPlacement","yPlacement","xAdvance","yAdvance","xPlaDevice","yPlaDevice","xAdvDevice","yAdvDevice"]),tm={xPlacement:V,yPlacement:V,xAdvance:V,yAdvance:V,xPlaDevice:new O(C,Fr,{type:"global",relativeTo:s=>s.rel}),yPlaDevice:new O(C,Fr,{type:"global",relativeTo:s=>s.rel}),xAdvDevice:new O(C,Fr,{type:"global",relativeTo:s=>s.rel}),yAdvDevice:new O(C,Fr,{type:"global",relativeTo:s=>s.rel})};class Ei{buildStruct(e){let t=e;for(;!t[this.key]&&t.parent;)t=t.parent;if(!t[this.key])return;let r={};r.rel=()=>t._startOffset;let i=t[this.key];for(let n in i)i[n]&&(r[n]=tm[n]);return new R(r)}size(e,t){return this.buildStruct(t).size(e,t)}decode(e,t){let r=this.buildStruct(t).decode(e,t);return delete r.rel,r}constructor(e="valueFormat"){this.key=e}}let rm=new R({secondGlyph:C,value1:new Ei("valueFormat1"),value2:new Ei("valueFormat2")}),im=new I(rm,C),sm=new R({value1:new Ei("valueFormat1"),value2:new Ei("valueFormat2")}),as=new Ee(C,{1:{xCoordinate:V,yCoordinate:V},2:{xCoordinate:V,yCoordinate:V,anchorPoint:C},3:{xCoordinate:V,yCoordinate:V,xDeviceTable:new O(C,Fr),yDeviceTable:new O(C,Fr)}}),nm=new R({entryAnchor:new O(C,as,{type:"parent"}),exitAnchor:new O(C,as,{type:"parent"})}),am=new R({class:C,markAnchor:new O(C,as,{type:"parent"})}),Wa=new I(am,C),om=new I(new O(C,as),s=>s.parent.classCount),Fc=new I(om,C),lm=new I(new O(C,as),s=>s.parent.parent.classCount),cm=new I(lm,C),um=new I(new O(C,cm),C),os=new Ee("lookupType",{1:new Ee(C,{1:{coverage:new O(C,Ve),valueFormat:Ti,value:new Ei},2:{coverage:new O(C,Ve),valueFormat:Ti,valueCount:C,values:new We(new Ei,"valueCount")}}),2:new Ee(C,{1:{coverage:new O(C,Ve),valueFormat1:Ti,valueFormat2:Ti,pairSetCount:C,pairSets:new We(new O(C,im),"pairSetCount")},2:{coverage:new O(C,Ve),valueFormat1:Ti,valueFormat2:Ti,classDef1:new O(C,Or),classDef2:new O(C,Or),class1Count:C,class2Count:C,classRecords:new We(new We(sm,"class2Count"),"class1Count")}}),3:{format:C,coverage:new O(C,Ve),entryExitCount:C,entryExitRecords:new I(nm,"entryExitCount")},4:{format:C,markCoverage:new O(C,Ve),baseCoverage:new O(C,Ve),classCount:C,markArray:new O(C,Wa),baseArray:new O(C,Fc)},5:{format:C,markCoverage:new O(C,Ve),ligatureCoverage:new O(C,Ve),classCount:C,markArray:new O(C,Wa),ligatureArray:new O(C,um)},6:{format:C,mark1Coverage:new O(C,Ve),mark2Coverage:new O(C,Ve),classCount:C,mark1Array:new O(C,Wa),mark2Array:new O(C,Fc)},7:pc,8:gc,9:{posFormat:C,lookupType:C,extension:new O(F,null)}});os.versions[9].extension.type=os;var hm=new Ee(F,{header:{scriptList:new O(C,hc),featureList:new O(C,fc),lookupList:new O(C,new sn(os))},65536:{},65537:{featureVariations:new O(F,yc)}});let Rc=new I(C,C),dm=Rc,fm=new R({glyph:C,compCount:C,components:new I(C,s=>s.compCount-1)}),pm=new I(new O(C,fm),C),Ga=new Ee("lookupType",{1:new Ee(C,{1:{coverage:new O(C,Ve),deltaGlyphID:V},2:{coverage:new O(C,Ve),glyphCount:C,substitute:new We(C,"glyphCount")}}),2:{substFormat:C,coverage:new O(C,Ve),count:C,sequences:new We(new O(C,Rc),"count")},3:{substFormat:C,coverage:new O(C,Ve),count:C,alternateSet:new We(new O(C,dm),"count")},4:{substFormat:C,coverage:new O(C,Ve),count:C,ligatureSets:new We(new O(C,pm),"count")},5:pc,6:gc,7:{substFormat:C,lookupType:C,extension:new O(F,null)},8:{substFormat:C,coverage:new O(C,Ve),backtrackCoverage:new I(new O(C,Ve),"backtrackGlyphCount"),lookaheadGlyphCount:C,lookaheadCoverage:new I(new O(C,Ve),"lookaheadGlyphCount"),glyphCount:C,substitutes:new I(C,"glyphCount")}});Ga.versions[7].extension.type=Ga;var mm=new Ee(F,{header:{scriptList:new O(C,hc),featureList:new O(C,fc),lookupList:new O(C,new sn(Ga))},65536:{},65537:{featureVariations:new O(F,yc)}});let Rr=new I(C,C),gm=new R({shrinkageEnableGSUB:new O(C,Rr),shrinkageDisableGSUB:new O(C,Rr),shrinkageEnableGPOS:new O(C,Rr),shrinkageDisableGPOS:new O(C,Rr),shrinkageJstfMax:new O(C,new sn(os)),extensionEnableGSUB:new O(C,Rr),extensionDisableGSUB:new O(C,Rr),extensionEnableGPOS:new O(C,Rr),extensionDisableGPOS:new O(C,Rr),extensionJstfMax:new O(C,new sn(os))}),Mc=new I(new O(C,gm),C),ym=new R({tag:new He(4),jstfLangSys:new O(C,Mc)}),bm=new R({extenderGlyphs:new O(C,new I(C,C)),defaultLangSys:new O(C,Mc),langSysCount:C,langSysRecords:new I(ym,"langSysCount")}),vm=new R({tag:new He(4),script:new O(C,bm,{type:"parent"})});var wm=new R({version:F,scriptCount:C,scriptList:new I(vm,"scriptCount")});class xm{decode(e,t){switch(this.size(0,t)){case 1:return e.readUInt8();case 2:return e.readUInt16BE();case 3:return e.readUInt24BE();case 4:return e.readUInt32BE()}}size(e,t){return Gt(this._size,null,t)}constructor(e){this._size=e}}let Cm=new R({entry:new xm(s=>((s.parent.entryFormat&48)>>4)+1),outerIndex:s=>s.entry>>(s.parent.entryFormat&15)+1,innerIndex:s=>s.entry&(1<<(s.parent.entryFormat&15)+1)-1}),qa=new R({entryFormat:C,mapCount:C,mapData:new I(Cm,"mapCount")});var km=new R({majorVersion:C,minorVersion:C,itemVariationStore:new O(F,nn),advanceWidthMapping:new O(F,qa),LSBMapping:new O(F,qa),RSBMapping:new O(F,qa)});let Sm=new R({format:F,length:F,offset:F}),_m=new R({reserved:new Ze(C,2),cbSignature:F,signature:new qt("cbSignature")});var Tm=new R({ulVersion:F,usNumSigs:C,usFlag:C,signatures:new I(Sm,"usNumSigs"),signatureBlocks:new I(_m,"usNumSigs")});let Em=new R({rangeMaxPPEM:C,rangeGaspBehavior:new Dt(C,["grayscale","gridfit","symmetricSmoothing","symmetricGridfit"])});var Am=new R({version:C,numRanges:C,gaspRanges:new I(Em,"numRanges")});let Im=new R({pixelSize:K,maximumWidth:K,widths:new I(K,s=>s.parent.parent.maxp.numGlyphs)});var Pm=new R({version:C,numRecords:V,sizeDeviceRecord:Kr,records:new I(Im,"numRecords")});let Om=new R({left:C,right:C,value:V}),Dc=new R({firstGlyph:C,nGlyphs:C,offsets:new I(C,"nGlyphs"),max:s=>s.offsets.length&&Math.max.apply(Math,s.offsets)}),Fm=new R({off:s=>s._startOffset-s.parent.parent._startOffset,len:s=>((s.parent.leftTable.max-s.off)/s.parent.rowWidth+1)*(s.parent.rowWidth/2),values:new We(V,"len")}),Bc=new Ee("format",{0:{nPairs:C,searchRange:C,entrySelector:C,rangeShift:C,pairs:new I(Om,"nPairs")},2:{rowWidth:C,leftTable:new O(C,Dc,{type:"parent"}),rightTable:new O(C,Dc,{type:"parent"}),array:new O(C,Fm,{type:"parent"})},3:{glyphCount:C,kernValueCount:K,leftClassCount:K,rightClassCount:K,flags:K,kernValue:new I(V,"kernValueCount"),leftClass:new I(K,"glyphCount"),rightClass:new I(K,"glyphCount"),kernIndex:new I(K,s=>s.leftClassCount*s.rightClassCount)}}),Lc=new Ee("version",{0:{subVersion:C,length:C,format:K,coverage:new Dt(K,["horizontal","minimum","crossStream","override"]),subtable:Bc,padding:new Ze(K,s=>s.length-s._currentOffset)},1:{length:F,coverage:new Dt(K,[null,null,null,null,null,"variation","crossStream","vertical"]),format:K,tupleIndex:C,subtable:Bc,padding:new Ze(K,s=>s.length-s._currentOffset)}});var Rm=new Ee(C,{0:{nTables:C,tables:new I(Lc,"nTables")},1:{reserved:new Ze(C),nTables:F,tables:new I(Lc,"nTables")}}),Mm=new R({version:C,numGlyphs:C,yPels:new I(K,"numGlyphs")}),Dm=new R({version:C,fontNumber:F,pitch:C,xHeight:C,style:C,typeFamily:C,capHeight:C,symbolSet:C,typeface:new He(16),characterComplement:new He(8),fileName:new He(6),strokeWeight:new He(1),widthType:new He(1),serifStyle:K,reserved:new Ze(K)});let Bm=new R({bCharSet:K,xRatio:K,yStartRatio:K,yEndRatio:K}),Lm=new R({yPelHeight:C,yMax:V,yMin:V}),zm=new R({recs:C,startsz:K,endsz:K,entries:new I(Lm,"recs")});var $m=new R({version:C,numRecs:C,numRatios:C,ratioRanges:new I(Bm,"numRatios"),offsets:new I(C,"numRatios"),groups:new I(zm,"numRecs")}),Nm=new R({version:C,ascent:V,descent:V,lineGap:V,advanceHeightMax:V,minTopSideBearing:V,minBottomSideBearing:V,yMaxExtent:V,caretSlopeRise:V,caretSlopeRun:V,caretOffset:V,reserved:new Ze(V,4),metricDataFormat:V,numberOfMetrics:C});let Um=new R({advance:C,bearing:V});var Hm=new R({metrics:new We(Um,s=>s.parent.vhea.numberOfMetrics),bearings:new We(V,s=>s.parent.maxp.numGlyphs-s.parent.vhea.numberOfMetrics)});let zc=new Yr(16,"BE",14),Vm=new R({fromCoord:zc,toCoord:zc}),jm=new R({pairCount:C,correspondence:new I(Vm,"pairCount")});var Wm=new R({version:et,axisCount:F,segment:new I(jm,"axisCount")});class Gm{getItem(e){if(this._items[e]==null){let t=this.stream.pos;this.stream.pos=this.base+this.type.size(null,this.parent)*e,this._items[e]=this.type.decode(this.stream,this.parent),this.stream.pos=t}return this._items[e]}inspect(){return`[UnboundedArray ${this.type.constructor.name}]`}constructor(e,t,r){this.type=e,this.stream=t,this.parent=r,this.base=this.stream.pos,this._items=[]}}class Jt extends I{decode(e,t){return new Gm(this.type,e,t)}constructor(e){super(e,0)}}let Mr=function(s=C){class e{decode(o,c){return c=c.parent.parent,this.type.decode(o,c)}size(o,c){return c=c.parent.parent,this.type.size(o,c)}encode(o,c,u){return u=u.parent.parent,this.type.encode(o,c,u)}constructor(o){this.type=o}}s=new e(s);let t=new R({unitSize:C,nUnits:C,searchRange:C,entrySelector:C,rangeShift:C}),r=new R({lastGlyph:C,firstGlyph:C,value:s}),i=new R({lastGlyph:C,firstGlyph:C,values:new O(C,new I(s,a=>a.lastGlyph-a.firstGlyph+1),{type:"parent"})}),n=new R({glyph:C,value:s});return new Ee(C,{0:{values:new Jt(s)},2:{binarySearchHeader:t,segments:new I(r,a=>a.binarySearchHeader.nUnits)},4:{binarySearchHeader:t,segments:new I(i,a=>a.binarySearchHeader.nUnits)},6:{binarySearchHeader:t,segments:new I(n,a=>a.binarySearchHeader.nUnits)},8:{firstGlyph:C,count:C,values:new I(s,"count")}})};function on(s={},e=C){let t=Object.assign({newState:C,flags:C},s),r=new R(t),i=new Jt(new I(C,a=>a.nClasses));return new R({nClasses:F,classTable:new O(F,new Mr(e)),stateArray:new O(F,i),entryTable:new O(F,new Jt(r))})}function qm(s={},e=C){let t=new R({version(){return 8},firstGlyph:C,values:new I(K,C)}),r=Object.assign({newStateOffset:C,newState:o=>(o.newStateOffset-(o.parent.stateArray.base-o.parent._startOffset))/o.parent.nClasses,flags:C},s),i=new R(r),n=new Jt(new I(K,o=>o.nClasses));return new R({nClasses:C,classTable:new O(C,t),stateArray:new O(C,n),entryTable:new O(C,new Jt(i))})}let Xm=new Ee("format",{0:{deltas:new I(V,32)},1:{deltas:new I(V,32),mappingData:new Mr(C)},2:{standardGlyph:C,controlPoints:new I(C,32)},3:{standardGlyph:C,controlPoints:new I(C,32),mappingData:new Mr(C)}});var Zm=new R({version:et,format:C,defaultBaseline:C,subtable:Xm});let Km=new R({setting:C,nameIndex:V,name:s=>s.parent.parent.parent.name.records.fontFeatures[s.nameIndex]}),Ym=new R({feature:C,nSettings:C,settingTable:new O(F,new I(Km,"nSettings"),{type:"parent"}),featureFlags:new Dt(K,[null,null,null,null,null,null,"hasDefault","exclusive"]),defaultSetting:K,nameIndex:V,name:s=>s.parent.parent.name.records.fontFeatures[s.nameIndex]});var Jm=new R({version:et,featureNameCount:C,reserved1:new Ze(C),reserved2:new Ze(F),featureNames:new I(Ym,"featureNameCount")});let Qm=new R({axisTag:new He(4),minValue:et,defaultValue:et,maxValue:et,flags:C,nameID:C,name:s=>s.parent.parent.name.records.fontFeatures[s.nameID]}),eg=new R({nameID:C,name:s=>s.parent.parent.name.records.fontFeatures[s.nameID],flags:C,coord:new I(et,s=>s.parent.axisCount),postscriptNameID:new Ws(C,s=>s.parent.instanceSize-s._currentOffset>0)});var tg=new R({version:et,offsetToData:C,countSizePairs:C,axisCount:C,axisSize:C,instanceCount:C,instanceSize:C,axis:new I(Qm,"axisCount"),instance:new I(eg,"instanceCount")});let rg=new Yr(16,"BE",14);class ig{static decode(e,t){return t.flags?e.readUInt32BE():e.readUInt16BE()*2}}var sg=new R({version:C,reserved:new Ze(C),axisCount:C,globalCoordCount:C,globalCoords:new O(F,new I(new I(rg,"axisCount"),"globalCoordCount")),glyphCount:C,flags:C,offsetToData:F,offsets:new I(new O(ig,"void",{relativeTo:s=>s.offsetToData,allowNull:!1}),s=>s.glyphCount+1)});let ng=new R({length:C,coverage:C,subFeatureFlags:F,stateTable:new qm}),ag=new R({justClass:F,beforeGrowLimit:et,beforeShrinkLimit:et,afterGrowLimit:et,afterShrinkLimit:et,growFlags:C,shrinkFlags:C}),og=new I(ag,F),lg=new Ee("actionType",{0:{lowerLimit:et,upperLimit:et,order:C,glyphs:new I(C,C)},1:{addGlyph:C},2:{substThreshold:et,addGlyph:C,substGlyph:C},3:{},4:{variationAxis:F,minimumLimit:et,noStretchValue:et,maximumLimit:et},5:{flags:C,glyph:C}}),cg=new R({actionClass:C,actionType:C,actionLength:F,actionData:lg,padding:new Ze(K,s=>s.actionLength-s._currentOffset)}),ug=new I(cg,F),hg=new R({lookupTable:new Mr(new O(C,ug))}),$c=new R({classTable:new O(C,ng,{type:"parent"}),wdcOffset:C,postCompensationTable:new O(C,hg,{type:"parent"}),widthDeltaClusters:new Mr(new O(C,og,{type:"parent",relativeTo:s=>s.wdcOffset}))});var dg=new R({version:F,format:C,horizontal:new O(C,$c),vertical:new O(C,$c)});let fg={action:C},pg={markIndex:C,currentIndex:C},mg={currentInsertIndex:C,markedInsertIndex:C},gg=new R({items:new Jt(new O(F,new Mr))}),yg=new Ee("type",{0:{stateTable:new on},1:{stateTable:new on(pg),substitutionTable:new O(F,gg)},2:{stateTable:new on(fg),ligatureActions:new O(F,new Jt(F)),components:new O(F,new Jt(C)),ligatureList:new O(F,new Jt(C))},4:{lookupTable:new Mr},5:{stateTable:new on(mg),insertionActions:new O(F,new Jt(C))}}),bg=new R({length:F,coverage:Ar,type:K,subFeatureFlags:F,table:yg,padding:new Ze(K,s=>s.length-s._currentOffset)}),vg=new R({featureType:C,featureSetting:C,enableFlags:F,disableFlags:F}),wg=new R({defaultFlags:F,chainLength:F,nFeatureEntries:F,nSubtables:F,features:new I(vg,"nFeatureEntries"),subtables:new I(bg,"nSubtables")});var xg=new R({version:C,unused:new Ze(C),nChains:F,chains:new I(wg,"nChains")});let Cg=new R({left:V,top:V,right:V,bottom:V});var kg=new R({version:et,format:C,lookupTable:new Mr(Cg)});let we={};var ln=we;we.cmap=Sf,we.head=_f,we.hhea=Tf,we.hmtx=Af,we.maxp=If,we.name=Bf,we["OS/2"]=Lf,we.post=zf,we.fpgm=Nf,we.loca=Uf,we.prep=Hf,we["cvt "]=$f,we.glyf=Vf,we["CFF "]=_c,we.CFF2=_c,we.VORG=Ap,we.EBLC=Rp,we.CBLC=we.EBLC,we.sbix=Dp,we.COLR=zp,we.CPAL=Np,we.BASE=Xp,we.GDEF=em,we.GPOS=hm,we.GSUB=mm,we.JSTF=wm,we.HVAR=km,we.DSIG=Tm,we.gasp=Am,we.hdmx=Pm,we.kern=Rm,we.LTSH=Mm,we.PCLT=Dm,we.VDMX=$m,we.vhea=Nm,we.vmtx=Hm,we.avar=Wm,we.bsln=Zm,we.feat=Jm,we.fvar=tg,we.gvar=sg,we.just=dg,we.morx=xg,we.opbd=kg;let Sg=new R({tag:new He(4),checkSum:F,offset:new O(F,"void",{type:"global"}),length:F}),Xa=new R({tag:new He(4),numTables:C,searchRange:C,entrySelector:C,rangeShift:C,tables:new I(Sg,"numTables")});Xa.process=function(){let s={};for(let e of this.tables)s[e.tag]=e;this.tables=s},Xa.preEncode=function(){if(!Array.isArray(this.tables)){let t=[];for(let r in this.tables){let i=this.tables[r];i&&t.push({tag:r,checkSum:0,offset:new ma(ln[r],i),length:ln[r].size(i)})}this.tables=t}this.tag="true",this.numTables=this.tables.length;let s=Math.floor(Math.log(this.numTables)/Math.LN2),e=Math.pow(2,s);this.searchRange=e*16,this.entrySelector=Math.log(e)/Math.LN2,this.rangeShift=this.numTables*16-this.searchRange};var Nc=Xa;function cn(s,e){let t=0,r=s.length-1;for(;t<=r;){let i=t+r>>1,n=e(s[i]);if(n<0)r=i-1;else if(n>0)t=i+1;else return i}return-1}function Ai(s,e){let t=[];for(;s<e;)t.push(s++);return t}const un=new TextDecoder("ascii"),Uc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ls=new Uint8Array(256);for(let s=0;s<Uc.length;s++)ls[Uc.charCodeAt(s)]=s;function Za(s){let e=s.length*.75;s[s.length-1]==="="&&(e--,s[s.length-2]==="="&&e--);let t=new Uint8Array(e),r=0;for(let i=0,n=s.length;i<n;i+=4){let a=ls[s.charCodeAt(i)],o=ls[s.charCodeAt(i+1)],c=ls[s.charCodeAt(i+2)],u=ls[s.charCodeAt(i+3)];t[r++]=a<<2|o>>4,t[r++]=(o&15)<<4|c>>2,t[r++]=(c&3)<<6|u&63}return t}class Ka{findSubtable(e,t){for(let[r,i]of t)for(let n of e.tables)if(n.platformID===r&&n.encodingID===i)return n.table;return null}lookup(e,t){if(this.encoding)e=this.encoding.get(e)||e;else if(t){let i=this.getVariationSelector(e,t);if(i)return i}let r=this.cmap;switch(r.version){case 0:return r.codeMap.get(e)||0;case 4:{let i=0,n=r.segCount-1;for(;i<=n;){let a=i+n>>1;if(e<r.startCode.get(a))n=a-1;else if(e>r.endCode.get(a))i=a+1;else{let o=r.idRangeOffset.get(a),c;if(o===0)c=e+r.idDelta.get(a);else{let u=o/2+(e-r.startCode.get(a))-(r.segCount-a);c=r.glyphIndexArray.get(u)||0,c!==0&&(c+=r.idDelta.get(a))}return c&65535}}return 0}case 8:throw new Error("TODO: cmap format 8");case 6:case 10:return r.glyphIndices.get(e-r.firstCode)||0;case 12:case 13:{let i=0,n=r.nGroups-1;for(;i<=n;){let a=i+n>>1,o=r.groups.get(a);if(e<o.startCharCode)n=a-1;else if(e>o.endCharCode)i=a+1;else return r.version===12?o.glyphID+(e-o.startCharCode):o.glyphID}return 0}case 14:throw new Error("TODO: cmap format 14");default:throw new Error(`Unknown cmap format ${r.version}`)}}getVariationSelector(e,t){if(!this.uvs)return 0;let r=this.uvs.varSelectors.toArray(),i=cn(r,a=>t-a.varSelector),n=r[i];return i!==-1&&n.defaultUVS&&(i=cn(n.defaultUVS,a=>e<a.startUnicodeValue?-1:e>a.startUnicodeValue+a.additionalCount?1:0)),i!==-1&&n.nonDefaultUVS&&(i=cn(n.nonDefaultUVS,a=>e-a.unicodeValue),i!==-1)?n.nonDefaultUVS[i].glyphID:0}getCharacterSet(){let e=this.cmap;switch(e.version){case 0:return Ai(0,e.codeMap.length);case 4:{let t=[],r=e.endCode.toArray();for(let i=0;i<r.length;i++){let n=r[i]+1,a=e.startCode.get(i);t.push(...Ai(a,n))}return t}case 8:throw new Error("TODO: cmap format 8");case 6:case 10:return Ai(e.firstCode,e.firstCode+e.glyphIndices.length);case 12:case 13:{let t=[];for(let r of e.groups.toArray())t.push(...Ai(r.startCharCode,r.endCharCode+1));return t}case 14:throw new Error("TODO: cmap format 14");default:throw new Error(`Unknown cmap format ${e.version}`)}}codePointsForGlyph(e){let t=this.cmap;switch(t.version){case 0:{let i=[];for(let n=0;n<256;n++)t.codeMap.get(n)===e&&i.push(n);return i}case 4:{let i=[];for(let n=0;n<t.segCount;n++){let a=t.endCode.get(n),o=t.startCode.get(n),c=t.idRangeOffset.get(n),u=t.idDelta.get(n);for(var r=o;r<=a;r++){let h=0;if(c===0)h=r+u;else{let l=c/2+(r-o)-(t.segCount-n);h=t.glyphIndexArray.get(l)||0,h!==0&&(h+=u)}h===e&&i.push(r)}}return i}case 12:{let i=[];for(let n of t.groups.toArray())e>=n.glyphID&&e<=n.glyphID+(n.endCharCode-n.startCharCode)&&i.push(n.startCharCode+(e-n.glyphID));return i}case 13:{let i=[];for(let n of t.groups.toArray())e===n.glyphID&&i.push(...Ai(n.startCharCode,n.endCharCode+1));return i}default:throw new Error(`Unknown cmap format ${t.version}`)}}constructor(e){if(this.encoding=null,this.cmap=this.findSubtable(e,[[3,10],[0,6],[0,4],[3,1],[0,3],[0,2],[0,1],[0,0]]),!this.cmap)for(let t of e.tables){let r=tc(t.platformID,t.encodingID,t.table.language-1),i=Ff(r);i&&(this.cmap=t.table,this.encoding=i)}if(!this.cmap)throw new Error("Could not find a supported cmap table");this.uvs=this.findSubtable(e,[[0,5]]),this.uvs&&this.uvs.version!==14&&(this.uvs=null)}}pt([mt],Ka.prototype,"getCharacterSet",null),pt([mt],Ka.prototype,"codePointsForGlyph",null);class _g{process(e,t){for(let r=0;r<e.length-1;r++){let i=e[r].id,n=e[r+1].id;t[r].xAdvance+=this.getKerning(i,n)}}getKerning(e,t){let r=0;for(let i of this.kern.tables){if(i.coverage.crossStream)continue;switch(i.version){case 0:if(!i.coverage.horizontal)continue;break;case 1:if(i.coverage.vertical||i.coverage.variation)continue;break;default:throw new Error(`Unsupported kerning table version ${i.version}`)}let n=0,a=i.subtable;switch(i.format){case 0:let o=cn(a.pairs,function(l){return e-l.left||t-l.right});o>=0&&(n=a.pairs[o].value);break;case 2:let c=0,u=0;e>=a.leftTable.firstGlyph&&e<a.leftTable.firstGlyph+a.leftTable.nGlyphs?c=a.leftTable.offsets[e-a.leftTable.firstGlyph]:c=a.array.off,t>=a.rightTable.firstGlyph&&t<a.rightTable.firstGlyph+a.rightTable.nGlyphs&&(u=a.rightTable.offsets[t-a.rightTable.firstGlyph]);let h=(c+u-a.array.off)/2;n=a.array.values.get(h);break;case 3:if(e>=a.glyphCount||t>=a.glyphCount)return 0;n=a.kernValue[a.kernIndex[a.leftClass[e]*a.rightClassCount+a.rightClass[t]]];break;default:throw new Error(`Unsupported kerning sub-table format ${i.format}`)}i.coverage.override?r=n:r+=n}return r}constructor(e){this.kern=e.kern}}class Tg{positionGlyphs(e,t){let r=0,i=0;for(let n=0;n<e.length;n++)e[n].isMark?i=n:(r!==i&&this.positionCluster(e,t,r,i),r=i=n);return r!==i&&this.positionCluster(e,t,r,i),t}positionCluster(e,t,r,i){let n=e[r],a=n.cbox.copy();n.codePoints.length>1&&(a.minX+=(n.codePoints.length-1)*a.width/n.codePoints.length);let o=-t[r].xAdvance,c=0,u=this.font.unitsPerEm/16;for(let h=r+1;h<=i;h++){let l=e[h],d=l.cbox,f=t[h],p=this.getCombiningClass(l.codePoints[0]);if(p!=="Not_Reordered"){switch(f.xOffset=f.yOffset=0,p){case"Double_Above":case"Double_Below":f.xOffset+=a.minX-d.width/2-d.minX;break;case"Attached_Below_Left":case"Below_Left":case"Above_Left":f.xOffset+=a.minX-d.minX;break;case"Attached_Above_Right":case"Below_Right":case"Above_Right":f.xOffset+=a.maxX-d.width-d.minX;break;default:f.xOffset+=a.minX+(a.width-d.width)/2-d.minX}switch(p){case"Double_Below":case"Below_Left":case"Below":case"Below_Right":case"Attached_Below_Left":case"Attached_Below":(p==="Attached_Below_Left"||p==="Attached_Below")&&(a.minY+=u),f.yOffset=-a.minY-d.maxY,a.minY+=d.height;break;case"Double_Above":case"Above_Left":case"Above":case"Above_Right":case"Attached_Above":case"Attached_Above_Right":(p==="Attached_Above"||p==="Attached_Above_Right")&&(a.maxY+=u),f.yOffset=a.maxY-d.minY,a.maxY+=d.height;break}f.xAdvance=f.yAdvance=0,f.xOffset+=o,f.yOffset+=c}else o-=f.xAdvance,c-=f.yAdvance}}getCombiningClass(e){let t=ef(e);if((e&-256)===3584){if(t==="Not_Reordered")switch(e){case 3633:case 3636:case 3637:case 3638:case 3639:case 3655:case 3660:case 3645:case 3662:return"Above_Right";case 3761:case 3764:case 3765:case 3766:case 3767:case 3771:case 3788:case 3789:return"Above";case 3772:return"Below"}else if(e===3642)return"Below_Right"}switch(t){case"CCC10":case"CCC11":case"CCC12":case"CCC13":case"CCC14":case"CCC15":case"CCC16":case"CCC17":case"CCC18":case"CCC20":case"CCC22":return"Below";case"CCC23":return"Attached_Above";case"CCC24":return"Above_Right";case"CCC25":case"CCC19":return"Above_Left";case"CCC26":return"Above";case"CCC21":break;case"CCC27":case"CCC28":case"CCC30":case"CCC31":case"CCC33":case"CCC34":case"CCC35":case"CCC36":return"Above";case"CCC29":case"CCC32":return"Below";case"CCC103":return"Below_Right";case"CCC107":return"Above_Right";case"CCC118":return"Below";case"CCC122":return"Above";case"CCC129":case"CCC132":return"Below";case"CCC130":return"Above"}return t}constructor(e){this.font=e}}class Dr{get width(){return this.maxX-this.minX}get height(){return this.maxY-this.minY}addPoint(e,t){Math.abs(e)!==1/0&&(e<this.minX&&(this.minX=e),e>this.maxX&&(this.maxX=e)),Math.abs(t)!==1/0&&(t<this.minY&&(this.minY=t),t>this.maxY&&(this.maxY=t))}copy(){return new Dr(this.minX,this.minY,this.maxX,this.maxY)}constructor(e=1/0,t=1/0,r=-1/0,i=-1/0){this.minX=e,this.minY=t,this.maxX=r,this.maxY=i}}const Ii={Caucasian_Albanian:"aghb",Arabic:"arab",Imperial_Aramaic:"armi",Armenian:"armn",Avestan:"avst",Balinese:"bali",Bamum:"bamu",Bassa_Vah:"bass",Batak:"batk",Bengali:["bng2","beng"],Bopomofo:"bopo",Brahmi:"brah",Braille:"brai",Buginese:"bugi",Buhid:"buhd",Chakma:"cakm",Canadian_Aboriginal:"cans",Carian:"cari",Cham:"cham",Cherokee:"cher",Coptic:"copt",Cypriot:"cprt",Cyrillic:"cyrl",Devanagari:["dev2","deva"],Deseret:"dsrt",Duployan:"dupl",Egyptian_Hieroglyphs:"egyp",Elbasan:"elba",Ethiopic:"ethi",Georgian:"geor",Glagolitic:"glag",Gothic:"goth",Grantha:"gran",Greek:"grek",Gujarati:["gjr2","gujr"],Gurmukhi:["gur2","guru"],Hangul:"hang",Han:"hani",Hanunoo:"hano",Hebrew:"hebr",Hiragana:"hira",Pahawh_Hmong:"hmng",Katakana_Or_Hiragana:"hrkt",Old_Italic:"ital",Javanese:"java",Kayah_Li:"kali",Katakana:"kana",Kharoshthi:"khar",Khmer:"khmr",Khojki:"khoj",Kannada:["knd2","knda"],Kaithi:"kthi",Tai_Tham:"lana",Lao:"lao ",Latin:"latn",Lepcha:"lepc",Limbu:"limb",Linear_A:"lina",Linear_B:"linb",Lisu:"lisu",Lycian:"lyci",Lydian:"lydi",Mahajani:"mahj",Mandaic:"mand",Manichaean:"mani",Mende_Kikakui:"mend",Meroitic_Cursive:"merc",Meroitic_Hieroglyphs:"mero",Malayalam:["mlm2","mlym"],Modi:"modi",Mongolian:"mong",Mro:"mroo",Meetei_Mayek:"mtei",Myanmar:["mym2","mymr"],Old_North_Arabian:"narb",Nabataean:"nbat",Nko:"nko ",Ogham:"ogam",Ol_Chiki:"olck",Old_Turkic:"orkh",Oriya:["ory2","orya"],Osmanya:"osma",Palmyrene:"palm",Pau_Cin_Hau:"pauc",Old_Permic:"perm",Phags_Pa:"phag",Inscriptional_Pahlavi:"phli",Psalter_Pahlavi:"phlp",Phoenician:"phnx",Miao:"plrd",Inscriptional_Parthian:"prti",Rejang:"rjng",Runic:"runr",Samaritan:"samr",Old_South_Arabian:"sarb",Saurashtra:"saur",Shavian:"shaw",Sharada:"shrd",Siddham:"sidd",Khudawadi:"sind",Sinhala:"sinh",Sora_Sompeng:"sora",Sundanese:"sund",Syloti_Nagri:"sylo",Syriac:"syrc",Tagbanwa:"tagb",Takri:"takr",Tai_Le:"tale",New_Tai_Lue:"talu",Tamil:["tml2","taml"],Tai_Viet:"tavt",Telugu:["tel2","telu"],Tifinagh:"tfng",Tagalog:"tglg",Thaana:"thaa",Thai:"thai",Tibetan:"tibt",Tirhuta:"tirh",Ugaritic:"ugar",Vai:"vai ",Warang_Citi:"wara",Old_Persian:"xpeo",Cuneiform:"xsux",Yi:"yi ",Inherited:"zinh",Common:"zyyy",Unknown:"zzzz"},Ya={};for(let s in Ii){let e=Ii[s];if(Array.isArray(e))for(let t of e)Ya[t]=s;else Ya[e]=s}function Eg(s){return Ya[s]}function Ag(s){let e=s.length,t=0;for(;t<e;){let r=s.charCodeAt(t++);if(55296<=r&&r<=56319&&t<e){let n=s.charCodeAt(t);56320<=n&&n<=57343&&(t++,r=((r&1023)<<10)+(n&1023)+65536)}let i=Ll(r);if(i!=="Common"&&i!=="Inherited"&&i!=="Unknown")return Ii[i]}return Ii.Unknown}function Ig(s){for(let e=0;e<s.length;e++){let t=s[e],r=Ll(t);if(r!=="Common"&&r!=="Inherited"&&r!=="Unknown")return Ii[r]}return Ii.Unknown}const Pg={arab:!0,hebr:!0,syrc:!0,thaa:!0,cprt:!0,khar:!0,phnx:!0,"nko ":!0,lydi:!0,avst:!0,armi:!0,phli:!0,prti:!0,sarb:!0,orkh:!0,samr:!0,mand:!0,merc:!0,mero:!0,mani:!0,mend:!0,nbat:!0,narb:!0,palm:!0,phlp:!0};function Hc(s){return Pg[s]?"rtl":"ltr"}class Og{get advanceWidth(){let e=0;for(let t of this.positions)e+=t.xAdvance;return e}get advanceHeight(){let e=0;for(let t of this.positions)e+=t.yAdvance;return e}get bbox(){let e=new Dr,t=0,r=0;for(let i=0;i<this.glyphs.length;i++){let n=this.glyphs[i],a=this.positions[i],o=n.bbox;e.addPoint(o.minX+t+a.xOffset,o.minY+r+a.yOffset),e.addPoint(o.maxX+t+a.xOffset,o.maxY+r+a.yOffset),t+=a.xAdvance,r+=a.yAdvance}return e}constructor(e,t,r,i,n){if(this.glyphs=e,this.positions=null,this.script=r,this.language=i||null,this.direction=n||Hc(r),this.features={},Array.isArray(t))for(let a of t)this.features[a]=!0;else typeof t=="object"&&(this.features=t)}}class Fg{constructor(e=0,t=0,r=0,i=0){this.xAdvance=e,this.yAdvance=t,this.xOffset=r,this.yOffset=i}}const ri={allTypographicFeatures:{code:0,exclusive:!1,allTypeFeatures:0},ligatures:{code:1,exclusive:!1,requiredLigatures:0,commonLigatures:2,rareLigatures:4,rebusPictures:8,diphthongLigatures:10,squaredLigatures:12,abbrevSquaredLigatures:14,symbolLigatures:16,contextualLigatures:18,historicalLigatures:20},cursiveConnection:{code:2,exclusive:!0,unconnected:0,partiallyConnected:1,cursive:2},letterCase:{code:3,exclusive:!0},verticalSubstitution:{code:4,exclusive:!1,substituteVerticalForms:0},linguisticRearrangement:{code:5,exclusive:!1,linguisticRearrangement:0},numberSpacing:{code:6,exclusive:!0,monospacedNumbers:0,proportionalNumbers:1,thirdWidthNumbers:2,quarterWidthNumbers:3},smartSwash:{code:8,exclusive:!1,wordInitialSwashes:0,wordFinalSwashes:2,nonFinalSwashes:8},diacritics:{code:9,exclusive:!0,showDiacritics:0,hideDiacritics:1,decomposeDiacritics:2},verticalPosition:{code:10,exclusive:!0,normalPosition:0,superiors:1,inferiors:2,ordinals:3,scientificInferiors:4},fractions:{code:11,exclusive:!0,noFractions:0,verticalFractions:1,diagonalFractions:2},overlappingCharacters:{code:13,exclusive:!1,preventOverlap:0},typographicExtras:{code:14,exclusive:!1,slashedZero:4},mathematicalExtras:{code:15,exclusive:!1,mathematicalGreek:10},ornamentSets:{code:16,exclusive:!0,noOrnaments:0,dingbats:1,piCharacters:2,fleurons:3,decorativeBorders:4,internationalSymbols:5,mathSymbols:6},characterAlternatives:{code:17,exclusive:!0,noAlternates:0},designComplexity:{code:18,exclusive:!0,designLevel1:0,designLevel2:1,designLevel3:2,designLevel4:3,designLevel5:4},styleOptions:{code:19,exclusive:!0,noStyleOptions:0,displayText:1,engravedText:2,illuminatedCaps:3,titlingCaps:4,tallCaps:5},characterShape:{code:20,exclusive:!0,traditionalCharacters:0,simplifiedCharacters:1,JIS1978Characters:2,JIS1983Characters:3,JIS1990Characters:4,traditionalAltOne:5,traditionalAltTwo:6,traditionalAltThree:7,traditionalAltFour:8,traditionalAltFive:9,expertCharacters:10,JIS2004Characters:11,hojoCharacters:12,NLCCharacters:13,traditionalNamesCharacters:14},numberCase:{code:21,exclusive:!0,lowerCaseNumbers:0,upperCaseNumbers:1},textSpacing:{code:22,exclusive:!0,proportionalText:0,monospacedText:1,halfWidthText:2,thirdWidthText:3,quarterWidthText:4,altProportionalText:5,altHalfWidthText:6},transliteration:{code:23,exclusive:!0,noTransliteration:0},annotation:{code:24,exclusive:!0,noAnnotation:0,boxAnnotation:1,roundedBoxAnnotation:2,circleAnnotation:3,invertedCircleAnnotation:4,parenthesisAnnotation:5,periodAnnotation:6,romanNumeralAnnotation:7,diamondAnnotation:8,invertedBoxAnnotation:9,invertedRoundedBoxAnnotation:10},kanaSpacing:{code:25,exclusive:!0,fullWidthKana:0,proportionalKana:1},ideographicSpacing:{code:26,exclusive:!0,fullWidthIdeographs:0,proportionalIdeographs:1,halfWidthIdeographs:2},unicodeDecomposition:{code:27,exclusive:!1,canonicalComposition:0,compatibilityComposition:2,transcodingComposition:4},rubyKana:{code:28,exclusive:!1,rubyKana:2},CJKSymbolAlternatives:{code:29,exclusive:!0,noCJKSymbolAlternatives:0,CJKSymbolAltOne:1,CJKSymbolAltTwo:2,CJKSymbolAltThree:3,CJKSymbolAltFour:4,CJKSymbolAltFive:5},ideographicAlternatives:{code:30,exclusive:!0,noIdeographicAlternatives:0,ideographicAltOne:1,ideographicAltTwo:2,ideographicAltThree:3,ideographicAltFour:4,ideographicAltFive:5},CJKVerticalRomanPlacement:{code:31,exclusive:!0,CJKVerticalRomanCentered:0,CJKVerticalRomanHBaseline:1},italicCJKRoman:{code:32,exclusive:!1,CJKItalicRoman:2},caseSensitiveLayout:{code:33,exclusive:!1,caseSensitiveLayout:0,caseSensitiveSpacing:2},alternateKana:{code:34,exclusive:!1,alternateHorizKana:0,alternateVertKana:2},stylisticAlternatives:{code:35,exclusive:!1,noStylisticAlternates:0,stylisticAltOne:2,stylisticAltTwo:4,stylisticAltThree:6,stylisticAltFour:8,stylisticAltFive:10,stylisticAltSix:12,stylisticAltSeven:14,stylisticAltEight:16,stylisticAltNine:18,stylisticAltTen:20,stylisticAltEleven:22,stylisticAltTwelve:24,stylisticAltThirteen:26,stylisticAltFourteen:28,stylisticAltFifteen:30,stylisticAltSixteen:32,stylisticAltSeventeen:34,stylisticAltEighteen:36,stylisticAltNineteen:38,stylisticAltTwenty:40},contextualAlternates:{code:36,exclusive:!1,contextualAlternates:0,swashAlternates:2,contextualSwashAlternates:4},lowerCase:{code:37,exclusive:!0,defaultLowerCase:0,lowerCaseSmallCaps:1,lowerCasePetiteCaps:2},upperCase:{code:38,exclusive:!0,defaultUpperCase:0,upperCaseSmallCaps:1,upperCasePetiteCaps:2},languageTag:{code:39,exclusive:!0},CJKRomanSpacing:{code:103,exclusive:!0,halfWidthCJKRoman:0,proportionalCJKRoman:1,defaultCJKRoman:2,fullWidthCJKRoman:3}},Z=(s,e)=>[ri[s].code,ri[s][e]],hn={rlig:Z("ligatures","requiredLigatures"),clig:Z("ligatures","contextualLigatures"),dlig:Z("ligatures","rareLigatures"),hlig:Z("ligatures","historicalLigatures"),liga:Z("ligatures","commonLigatures"),hist:Z("ligatures","historicalLigatures"),smcp:Z("lowerCase","lowerCaseSmallCaps"),pcap:Z("lowerCase","lowerCasePetiteCaps"),frac:Z("fractions","diagonalFractions"),dnom:Z("fractions","diagonalFractions"),numr:Z("fractions","diagonalFractions"),afrc:Z("fractions","verticalFractions"),case:Z("caseSensitiveLayout","caseSensitiveLayout"),ccmp:Z("unicodeDecomposition","canonicalComposition"),cpct:Z("CJKVerticalRomanPlacement","CJKVerticalRomanCentered"),valt:Z("CJKVerticalRomanPlacement","CJKVerticalRomanCentered"),swsh:Z("contextualAlternates","swashAlternates"),cswh:Z("contextualAlternates","contextualSwashAlternates"),curs:Z("cursiveConnection","cursive"),c2pc:Z("upperCase","upperCasePetiteCaps"),c2sc:Z("upperCase","upperCaseSmallCaps"),init:Z("smartSwash","wordInitialSwashes"),fin2:Z("smartSwash","wordFinalSwashes"),medi:Z("smartSwash","nonFinalSwashes"),med2:Z("smartSwash","nonFinalSwashes"),fin3:Z("smartSwash","wordFinalSwashes"),fina:Z("smartSwash","wordFinalSwashes"),pkna:Z("kanaSpacing","proportionalKana"),half:Z("textSpacing","halfWidthText"),halt:Z("textSpacing","altHalfWidthText"),hkna:Z("alternateKana","alternateHorizKana"),vkna:Z("alternateKana","alternateVertKana"),ital:Z("italicCJKRoman","CJKItalicRoman"),lnum:Z("numberCase","upperCaseNumbers"),onum:Z("numberCase","lowerCaseNumbers"),mgrk:Z("mathematicalExtras","mathematicalGreek"),calt:Z("contextualAlternates","contextualAlternates"),vrt2:Z("verticalSubstitution","substituteVerticalForms"),vert:Z("verticalSubstitution","substituteVerticalForms"),tnum:Z("numberSpacing","monospacedNumbers"),pnum:Z("numberSpacing","proportionalNumbers"),sups:Z("verticalPosition","superiors"),subs:Z("verticalPosition","inferiors"),ordn:Z("verticalPosition","ordinals"),pwid:Z("textSpacing","proportionalText"),hwid:Z("textSpacing","halfWidthText"),qwid:Z("textSpacing","quarterWidthText"),twid:Z("textSpacing","thirdWidthText"),fwid:Z("textSpacing","proportionalText"),palt:Z("textSpacing","altProportionalText"),trad:Z("characterShape","traditionalCharacters"),smpl:Z("characterShape","simplifiedCharacters"),jp78:Z("characterShape","JIS1978Characters"),jp83:Z("characterShape","JIS1983Characters"),jp90:Z("characterShape","JIS1990Characters"),jp04:Z("characterShape","JIS2004Characters"),expt:Z("characterShape","expertCharacters"),hojo:Z("characterShape","hojoCharacters"),nlck:Z("characterShape","NLCCharacters"),tnam:Z("characterShape","traditionalNamesCharacters"),ruby:Z("rubyKana","rubyKana"),titl:Z("styleOptions","titlingCaps"),zero:Z("typographicExtras","slashedZero"),ss01:Z("stylisticAlternatives","stylisticAltOne"),ss02:Z("stylisticAlternatives","stylisticAltTwo"),ss03:Z("stylisticAlternatives","stylisticAltThree"),ss04:Z("stylisticAlternatives","stylisticAltFour"),ss05:Z("stylisticAlternatives","stylisticAltFive"),ss06:Z("stylisticAlternatives","stylisticAltSix"),ss07:Z("stylisticAlternatives","stylisticAltSeven"),ss08:Z("stylisticAlternatives","stylisticAltEight"),ss09:Z("stylisticAlternatives","stylisticAltNine"),ss10:Z("stylisticAlternatives","stylisticAltTen"),ss11:Z("stylisticAlternatives","stylisticAltEleven"),ss12:Z("stylisticAlternatives","stylisticAltTwelve"),ss13:Z("stylisticAlternatives","stylisticAltThirteen"),ss14:Z("stylisticAlternatives","stylisticAltFourteen"),ss15:Z("stylisticAlternatives","stylisticAltFifteen"),ss16:Z("stylisticAlternatives","stylisticAltSixteen"),ss17:Z("stylisticAlternatives","stylisticAltSeventeen"),ss18:Z("stylisticAlternatives","stylisticAltEighteen"),ss19:Z("stylisticAlternatives","stylisticAltNineteen"),ss20:Z("stylisticAlternatives","stylisticAltTwenty")};for(let s=1;s<=99;s++)hn[`cv${`00${s}`.slice(-2)}`]=[ri.characterAlternatives.code,s];let ii={};for(let s in hn){let e=hn[s];ii[e[0]]==null&&(ii[e[0]]={}),ii[e[0]][e[1]]=s}function Rg(s){let e={};for(let t in s){let r;(r=hn[t])&&(e[r[0]]==null&&(e[r[0]]={}),e[r[0]][r[1]]=s[t])}return e}function Vc(s){let[e,t]=s;if(isNaN(e))var r=ri[e]&&ri[e].code;else var r=e;if(isNaN(t))var i=ri[e]&&ri[e][t];else var i=t;return[r,i]}function Mg(s){let e={};if(Array.isArray(s))for(let t=0;t<s.length;t++){let r,i=Vc(s[t]);(r=ii[i[0]]&&ii[i[0]][i[1]])&&(e[r]=!0)}else if(typeof s=="object")for(let t in s){let r=s[t];for(let i in r){let n,a=Vc([t,i]);r[i]&&(n=ii[a[0]]&&ii[a[0]][a[1]])&&(e[n]=!0)}}return Object.keys(e)}class cs{lookup(e){switch(this.table.version){case 0:return this.table.values.getItem(e);case 2:case 4:{let i=0,n=this.table.binarySearchHeader.nUnits-1;for(;i<=n;){var t=i+n>>1,r=this.table.segments[t];if(r.firstGlyph===65535)return null;if(e<r.firstGlyph)n=t-1;else if(e>r.lastGlyph)i=t+1;else return this.table.version===2?r.value:r.values[e-r.firstGlyph]}return null}case 6:{let i=0,n=this.table.binarySearchHeader.nUnits-1;for(;i<=n;){var t=i+n>>1,r=this.table.segments[t];if(r.glyph===65535)return null;if(e<r.glyph)n=t-1;else if(e>r.glyph)i=t+1;else return r.value}return null}case 8:return this.table.values[e-this.table.firstGlyph];default:throw new Error(`Unknown lookup table format: ${this.table.version}`)}}glyphsForValue(e){let t=[];switch(this.table.version){case 2:case 4:for(let r of this.table.segments)if(this.table.version===2&&r.value===e)t.push(...Ai(r.firstGlyph,r.lastGlyph+1));else for(let i=0;i<r.values.length;i++)r.values[i]===e&&t.push(r.firstGlyph+i);break;case 6:for(let r of this.table.segments)r.value===e&&t.push(r.glyph);break;case 8:for(let r=0;r<this.table.values.length;r++)this.table.values[r]===e&&t.push(this.table.firstGlyph+r);break;default:throw new Error(`Unknown lookup table format: ${this.table.version}`)}return t}constructor(e){this.table=e}}pt([mt],cs.prototype,"glyphsForValue",null);const Dg=0,jc=0,Wc=1,Gc=2,Bg=16384;class Lg{process(e,t,r){let i=Dg,n=t?e.length-1:0,a=t?-1:1;for(;a===1&&n<=e.length||a===-1&&n>=-1;){let o=null,c=Wc,u=!0;n===e.length||n===-1?c=jc:(o=e[n],o.id===65535?c=Gc:(c=this.lookupTable.lookup(o.id),c==null&&(c=Wc)));let l=this.stateTable.stateArray.getItem(i)[c],d=this.stateTable.entryTable.getItem(l);c!==jc&&c!==Gc&&(r(o,d,n),u=!(d.flags&Bg)),i=d.newState,u&&(n+=a)}return e}traverse(e,t=0,r=new Set){if(r.has(t))return;r.add(t);let{nClasses:i,stateArray:n,entryTable:a}=this.stateTable,o=n.getItem(t);for(let c=4;c<i;c++){let u=o[c],h=a.getItem(u);for(let l of this.lookupTable.glyphsForValue(c))e.enter&&e.enter(l,h),h.newState!==0&&this.traverse(e,h.newState,r),e.exit&&e.exit(l,h)}}constructor(e){this.stateTable=e,this.lookupTable=new cs(e.classTable)}}const zg=32768,$g=8192,Ng=15,qc=32768,Ug=32768,Hg=8192,Vg=2147483648,jg=1073741824,Wg=1073741823,Xc=4194304,Gg=2048,qg=1024,Xg=992,Zg=31;class Zc{process(e,t={}){for(let i of this.morx.chains){let n=i.defaultFlags;for(let a of i.features){let o;(o=t[a.featureType])&&(o[a.featureSetting]?(n&=a.disableFlags,n|=a.enableFlags):o[a.featureSetting]===!1&&(n|=~a.disableFlags,n&=~a.enableFlags))}for(let a of i.subtables)a.subFeatureFlags&n&&this.processSubtable(a,e)}let r=e.length-1;for(;r>=0;)e[r].id===65535&&e.splice(r,1),r--;return e}processSubtable(e,t){if(this.subtable=e,this.glyphs=t,this.subtable.type===4){this.processNoncontextualSubstitutions(this.subtable,this.glyphs);return}this.ligatureStack=[],this.markedGlyph=null,this.firstGlyph=null,this.lastGlyph=null,this.markedIndex=null;let r=this.getStateMachine(e),i=this.getProcessor(),n=!!(this.subtable.coverage&Xc);return r.process(this.glyphs,n,i)}getStateMachine(e){return new Lg(e.table.stateTable)}getProcessor(){switch(this.subtable.type){case 0:return this.processIndicRearragement;case 1:return this.processContextualSubstitution;case 2:return this.processLigature;case 4:return this.processNoncontextualSubstitutions;case 5:return this.processGlyphInsertion;default:throw new Error(`Invalid morx subtable type: ${this.subtable.type}`)}}processIndicRearragement(e,t,r){t.flags&zg&&(this.firstGlyph=r),t.flags&$g&&(this.lastGlyph=r),Kg(this.glyphs,t.flags&Ng,this.firstGlyph,this.lastGlyph)}processContextualSubstitution(e,t,r){let i=this.subtable.table.substitutionTable.items;if(t.markIndex!==65535){let a=i.getItem(t.markIndex),o=new cs(a);e=this.glyphs[this.markedGlyph];var n=o.lookup(e.id);n&&(this.glyphs[this.markedGlyph]=this.font.getGlyph(n,e.codePoints))}if(t.currentIndex!==65535){let a=i.getItem(t.currentIndex),o=new cs(a);e=this.glyphs[r];var n=o.lookup(e.id);n&&(this.glyphs[r]=this.font.getGlyph(n,e.codePoints))}t.flags&qc&&(this.markedGlyph=r)}processLigature(e,t,r){if(t.flags&Ug&&this.ligatureStack.push(r),t.flags&Hg){let i=this.subtable.table.ligatureActions,n=this.subtable.table.components,a=this.subtable.table.ligatureList,o=t.action,c=!1,u=0,h=[],l=[];for(;!c;){let d=this.ligatureStack.pop();h.unshift(...this.glyphs[d].codePoints);let f=i.getItem(o++);c=!!(f&Vg);let p=!!(f&jg),m=(f&Wg)<<2>>2;m+=this.glyphs[d].id;let v=n.getItem(m);if(u+=v,c||p){let g=a.getItem(u);this.glyphs[d]=this.font.getGlyph(g,h),l.push(d),u=0,h=[]}else this.glyphs[d]=this.font.getGlyph(65535)}this.ligatureStack.push(...l)}}processNoncontextualSubstitutions(e,t,r){let i=new cs(e.table.lookupTable);for(r=0;r<t.length;r++){let n=t[r];if(n.id!==65535){let a=i.lookup(n.id);a&&(t[r]=this.font.getGlyph(a,n.codePoints))}}}_insertGlyphs(e,t,r,i){let n=[];for(;r--;){let a=this.subtable.table.insertionActions.getItem(t++);n.push(this.font.getGlyph(a))}i||e++,this.glyphs.splice(e,0,...n)}processGlyphInsertion(e,t,r){if(t.flags&qc&&(this.markedIndex=r),t.markedInsertIndex!==65535){let i=(t.flags&Zg)>>>5,n=!!(t.flags&qg);this._insertGlyphs(this.markedIndex,t.markedInsertIndex,i,n)}if(t.currentInsertIndex!==65535){let i=(t.flags&Xg)>>>5,n=!!(t.flags&Gg);this._insertGlyphs(r,t.currentInsertIndex,i,n)}}getSupportedFeatures(){let e=[];for(let t of this.morx.chains)for(let r of t.features)e.push([r.featureType,r.featureSetting]);return e}generateInputs(e){return this.inputCache||this.generateInputCache(),this.inputCache[e]||[]}generateInputCache(){this.inputCache={};for(let e of this.morx.chains){let t=e.defaultFlags;for(let r of e.subtables)r.subFeatureFlags&t&&this.generateInputsForSubtable(r)}}generateInputsForSubtable(e){if(e.type!==2)return;if(!!(e.coverage&Xc))throw new Error("Reverse subtable, not supported.");this.subtable=e,this.ligatureStack=[];let r=this.getStateMachine(e),i=this.getProcessor(),n=[],a=[];this.glyphs=[],r.traverse({enter:(o,c)=>{let u=this.glyphs;a.push({glyphs:u.slice(),ligatureStack:this.ligatureStack.slice()});let h=this.font.getGlyph(o);n.push(h),u.push(n[n.length-1]),i(u[u.length-1],c,u.length-1);let l=0,d=0;for(let f=0;f<u.length&&l<=1;f++)u[f].id!==65535&&(l++,d=u[f].id);if(l===1){let f=n.map(m=>m.id),p=this.inputCache[d];p?p.push(f):this.inputCache[d]=[f]}},exit:()=>{({glyphs:this.glyphs,ligatureStack:this.ligatureStack}=a.pop()),n.pop()}})}constructor(e){this.processIndicRearragement=this.processIndicRearragement.bind(this),this.processContextualSubstitution=this.processContextualSubstitution.bind(this),this.processLigature=this.processLigature.bind(this),this.processNoncontextualSubstitutions=this.processNoncontextualSubstitutions.bind(this),this.processGlyphInsertion=this.processGlyphInsertion.bind(this),this.font=e,this.morx=e.morx,this.inputCache=null}}pt([mt],Zc.prototype,"getStateMachine",null);function xt(s,e,t,r=!1,i=!1){let n=s.splice(t[0]-(t[1]-1),t[1]);i&&n.reverse();let a=s.splice(e[0],e[1],...n);return r&&a.reverse(),s.splice(t[0]-(e[1]-1),0,...a),s}function Kg(s,e,t,r){switch(e){case 0:return s;case 1:return xt(s,[t,1],[r,0]);case 2:return xt(s,[t,0],[r,1]);case 3:return xt(s,[t,1],[r,1]);case 4:return xt(s,[t,2],[r,0]);case 5:return xt(s,[t,2],[r,0],!0,!1);case 6:return xt(s,[t,0],[r,2]);case 7:return xt(s,[t,0],[r,2],!1,!0);case 8:return xt(s,[t,1],[r,2]);case 9:return xt(s,[t,1],[r,2],!1,!0);case 10:return xt(s,[t,2],[r,1]);case 11:return xt(s,[t,2],[r,1],!0,!1);case 12:return xt(s,[t,2],[r,2]);case 13:return xt(s,[t,2],[r,2],!0,!1);case 14:return xt(s,[t,2],[r,2],!1,!0);case 15:return xt(s,[t,2],[r,2],!0,!0);default:throw new Error(`Unknown verb: ${e}`)}}class Yg{substitute(e){e.direction==="rtl"&&e.glyphs.reverse(),this.morxProcessor.process(e.glyphs,Rg(e.features))}getAvailableFeatures(e,t){return Mg(this.morxProcessor.getSupportedFeatures())}stringsForGlyph(e){let t=this.morxProcessor.generateInputs(e),r=new Set;for(let i of t)this._addStrings(i,0,r,"");return r}_addStrings(e,t,r,i){let n=this.font._cmapProcessor.codePointsForGlyph(e[t]);for(let a of n){let o=i+String.fromCodePoint(a);t<e.length-1?this._addStrings(e,t+1,r,o):r.add(o)}}constructor(e){this.font=e,this.morxProcessor=new Zc(e),this.fallbackPosition=!1}}class Jg{_addFeatures(e,t){let r=this.stages.length-1,i=this.stages[r];for(let n of e)this.allFeatures[n]==null&&(i.push(n),this.allFeatures[n]=r,t&&(this.globalFeatures[n]=!0))}add(e,t=!0){if(this.stages.length===0&&this.stages.push([]),typeof e=="string"&&(e=[e]),Array.isArray(e))this._addFeatures(e,t);else if(typeof e=="object")this._addFeatures(e.global||[],!0),this._addFeatures(e.local||[],!1);else throw new Error("Unsupported argument to ShapingPlan#add")}addStage(e,t){typeof e=="function"?this.stages.push(e,[]):(this.stages.push([]),this.add(e,t))}setFeatureOverrides(e){if(Array.isArray(e))this.add(e);else if(typeof e=="object"){for(let t in e)if(e[t])this.add(t);else if(this.allFeatures[t]!=null){let r=this.stages[this.allFeatures[t]];r.splice(r.indexOf(t),1),delete this.allFeatures[t],delete this.globalFeatures[t]}}}assignGlobalFeatures(e){for(let t of e)for(let r in this.globalFeatures)t.features[r]=!0}process(e,t,r){for(let i of this.stages)typeof i=="function"?r||i(this.font,t,this):i.length>0&&e.applyFeatures(i,t,r)}constructor(e,t,r){this.font=e,this.script=t,this.direction=r,this.stages=[],this.globalFeatures={},this.allFeatures={}}}const Qg=["rvrn"],ey=["ccmp","locl","rlig","mark","mkmk"],ty=["frac","numr","dnom"],ry=["calt","clig","liga","rclt","curs","kern"],iy={ltr:["ltra","ltrm"],rtl:["rtla","rtlm"]};class Br{static plan(e,t,r){this.planPreprocessing(e),this.planFeatures(e),this.planPostprocessing(e,r),e.assignGlobalFeatures(t),this.assignFeatures(e,t)}static planPreprocessing(e){e.add({global:[...Qg,...iy[e.direction]],local:ty})}static planFeatures(e){}static planPostprocessing(e,t){e.add([...ey,...ry]),e.setFeatureOverrides(t)}static assignFeatures(e,t){for(let r=0;r<t.length;r++){let i=t[r];if(i.codePoints[0]===8260){let n=r,a=r+1;for(;n>0&&zl(t[n-1].codePoints[0]);)t[n-1].features.numr=!0,t[n-1].features.frac=!0,n--;for(;a<t.length&&zl(t[a].codePoints[0]);)t[a].features.dnom=!0,t[a].features.frac=!0,a++;i.features.frac=!0,r=a-1}}}}Ct(Br,"zeroMarkWidths","AFTER_GPOS");const sy=new qs(Za("APABAAAAAAAAOAAAAf0BAv7tmi1MxDAUx7vtvjhAgcDgkEgEAnmXEBIMCYaEcygEiqBQ4FAkCE4ikUgMiiBJSAgSiUQSDMn9L9eSl6bddddug9t7yS/trevre+3r27pcNxZiG+yCfdCVv/9LeQxOwRm4AJegD27ALbgD9+ABPJF+z+BN/h7yDj5k/VOWX6SdmU5+wLWknggxDxaS8u0qiiX4uiz9XamQ3wzDMAzDMAzDMAzDVI/h959V/v7BMAzDMAzDMLlyNTNiMSdewVxbiA44B4/guz1qW58VYlMI0WsJ0W+N6kXw0spvPtdwhtkwnGM6uLaV4Xyzg3v3PM9DPfQ/sOg4xPWjipy31P8LTqbU304c/cLCUmWJLNB2Uz2U1KTeRKNmKHVMfbJC+/0loTZRH/W5cvEvBJPMbREkWt3FD1NcqXZBSpuE2Ad0PBehPtNrPtIEdYP+hiRt/V1jIiE69X4NT/uVZI3PUHE9bm5M7ePGdZWy951v7Nn6j8v1WWKP3mt6ttnsigx6VN7Vc0VomSSGqW2mGNP1muZPl7LfjNUaKNFtDGVf2fvE9O7VlBS5j333c5p/eeoOqcs1R/hIqDWLJ7TTlksirVT1SI7l8k4Yp+g3jafGcrU1RM6l9th80XOpnlN97bDNY4i4s61B0Si/ipa0uHMl6zqEjlFfCZm/TM8KmzQDjmuTAQ==")),Kc=["isol","fina","fin2","fin3","medi","med2","init"],Ja={Non_Joining:0,Transparent:6},qe="isol",Lr="fina",Qa="fin2",ny="fin3",dn="medi",fn="med2",pn="init",De=null,ay=[[[De,De,0],[De,qe,2],[De,qe,1],[De,qe,2],[De,qe,1],[De,qe,6]],[[De,De,0],[De,qe,2],[De,qe,1],[De,qe,2],[De,Qa,5],[De,qe,6]],[[De,De,0],[De,qe,2],[pn,Lr,1],[pn,Lr,3],[pn,Lr,4],[pn,Lr,6]],[[De,De,0],[De,qe,2],[dn,Lr,1],[dn,Lr,3],[dn,Lr,4],[dn,Lr,6]],[[De,De,0],[De,qe,2],[fn,qe,1],[fn,qe,2],[fn,Qa,5],[fn,qe,6]],[[De,De,0],[De,qe,2],[qe,qe,1],[qe,qe,2],[qe,Qa,5],[qe,qe,6]],[[De,De,0],[De,qe,2],[De,qe,1],[De,qe,2],[De,ny,5],[De,qe,6]]];class zr extends Br{static planFeatures(e){e.add(["ccmp","locl"]);for(let t=0;t<Kc.length;t++){let r=Kc[t];e.addStage(r,!1)}e.addStage("mset")}static assignFeatures(e,t){super.assignFeatures(e,t);let r=-1,i=0,n=[];for(let o=0;o<t.length;o++){let c,u;var a=t[o];let h=oy(a.codePoints[0]);if(h===Ja.Transparent){n[o]=De;continue}[u,c,i]=ay[i][h],u!==De&&r!==-1&&(n[r]=u),n[o]=c,r=o}for(let o=0;o<t.length;o++){let c;var a=t[o];(c=n[o])&&(a.features[c]=!0)}}}function oy(s){let e=sy.get(s);if(e)return e-1;let t=Zs(s);return t==="Mn"||t==="Me"||t==="Cf"?Ja.Transparent:Ja.Non_Joining}class ly{reset(e={},t=0){this.options=e,this.flags=e.flags||{},this.markAttachmentType=e.markAttachmentType||0,this.index=t}get cur(){return this.glyphs[this.index]||null}shouldIgnore(e){return this.flags.ignoreMarks&&e.isMark||this.flags.ignoreBaseGlyphs&&e.isBase||this.flags.ignoreLigatures&&e.isLigature||this.markAttachmentType&&e.isMark&&e.markAttachmentType!==this.markAttachmentType}move(e){for(this.index+=e;0<=this.index&&this.index<this.glyphs.length&&this.shouldIgnore(this.glyphs[this.index]);)this.index+=e;return 0>this.index||this.index>=this.glyphs.length?null:this.glyphs[this.index]}next(){return this.move(1)}prev(){return this.move(-1)}peek(e=1){let t=this.index,r=this.increment(e);return this.index=t,r}peekIndex(e=1){let t=this.index;this.increment(e);let r=this.index;return this.index=t,r}increment(e=1){let t=e<0?-1:1;for(e=Math.abs(e);e--;)this.move(t);return this.glyphs[this.index]}constructor(e,t){this.glyphs=e,this.reset(t)}}const cy=["DFLT","dflt","latn"];class mn{findScript(e){if(this.table.scriptList==null)return null;Array.isArray(e)||(e=[e]);for(let t of e)for(let r of this.table.scriptList)if(r.tag===t)return r;return null}selectScript(e,t,r){let i=!1,n;if(!this.script||e!==this.scriptTag){if(n=this.findScript(e),n||(n=this.findScript(cy)),!n)return this.scriptTag;this.scriptTag=n.tag,this.script=n.script,this.language=null,this.languageTag=null,i=!0}if((!r||r!==this.direction)&&(this.direction=r||Hc(e)),t&&t.length<4&&(t+=" ".repeat(4-t.length)),!t||t!==this.languageTag){this.language=null;for(let a of this.script.langSysRecords)if(a.tag===t){this.language=a.langSys,this.languageTag=a.tag;break}this.language||(this.language=this.script.defaultLangSys,this.languageTag=null),i=!0}if(i&&(this.features={},this.language))for(let a of this.language.featureIndexes){let o=this.table.featureList[a],c=this.substituteFeatureForVariations(a);this.features[o.tag]=c||o.feature}return this.scriptTag}lookupsForFeatures(e=[],t){let r=[];for(let i of e){let n=this.features[i];if(n)for(let a of n.lookupListIndexes)t&&t.indexOf(a)!==-1||r.push({feature:i,index:a,lookup:this.table.lookupList.get(a)})}return r.sort((i,n)=>i.index-n.index),r}substituteFeatureForVariations(e){if(this.variationsIndex===-1)return null;let r=this.table.featureVariations.featureVariationRecords[this.variationsIndex].featureTableSubstitution.substitutions;for(let i of r)if(i.featureIndex===e)return i.alternateFeatureTable;return null}findVariationsIndex(e){let t=this.table.featureVariations;if(!t)return-1;let r=t.featureVariationRecords;for(let i=0;i<r.length;i++){let n=r[i].conditionSet.conditionTable;if(this.variationConditionsMatch(n,e))return i}return-1}variationConditionsMatch(e,t){return e.every(r=>{let i=r.axisIndex<t.length?t[r.axisIndex]:0;return r.filterRangeMinValue<=i&&i<=r.filterRangeMaxValue})}applyFeatures(e,t,r){let i=this.lookupsForFeatures(e);this.applyLookups(i,t,r)}applyLookups(e,t,r){this.glyphs=t,this.positions=r,this.glyphIterator=new ly(t);for(let{feature:i,lookup:n}of e)for(this.currentFeature=i,this.glyphIterator.reset(n.flags);this.glyphIterator.index<t.length;){if(!(i in this.glyphIterator.cur.features)){this.glyphIterator.next();continue}for(let a of n.subTables)if(this.applyLookup(n.lookupType,a))break;this.glyphIterator.next()}}applyLookup(e,t){throw new Error("applyLookup must be implemented by subclasses")}applyLookupList(e){let t=this.glyphIterator.options,r=this.glyphIterator.index;for(let i of e){this.glyphIterator.reset(t,r),this.glyphIterator.increment(i.sequenceIndex);let n=this.table.lookupList.get(i.lookupListIndex);this.glyphIterator.reset(n.flags,this.glyphIterator.index);for(let a of n.subTables)if(this.applyLookup(n.lookupType,a))break}return this.glyphIterator.reset(t,r),!0}coverageIndex(e,t){switch(t==null&&(t=this.glyphIterator.cur.id),e.version){case 1:return e.glyphs.indexOf(t);case 2:for(let r of e.rangeRecords)if(r.start<=t&&t<=r.end)return r.startCoverageIndex+t-r.start;break}return-1}match(e,t,r,i){let n=this.glyphIterator.index,a=this.glyphIterator.increment(e),o=0;for(;o<t.length&&a&&r(t[o],a);)i&&i.push(this.glyphIterator.index),o++,a=this.glyphIterator.next();return this.glyphIterator.index=n,o<t.length?!1:i||!0}sequenceMatches(e,t){return this.match(e,t,(r,i)=>r===i.id)}sequenceMatchIndices(e,t){return this.match(e,t,(r,i)=>this.currentFeature in i.features?r===i.id:!1,[])}coverageSequenceMatches(e,t){return this.match(e,t,(r,i)=>this.coverageIndex(r,i.id)>=0)}getClassID(e,t){switch(t.version){case 1:let r=e-t.startGlyph;if(r>=0&&r<t.classValueArray.length)return t.classValueArray[r];break;case 2:for(let i of t.classRangeRecord)if(i.start<=e&&e<=i.end)return i.class;break}return 0}classSequenceMatches(e,t,r){return this.match(e,t,(i,n)=>i===this.getClassID(n.id,r))}applyContext(e){let t,r;switch(e.version){case 1:if(t=this.coverageIndex(e.coverage),t===-1)return!1;r=e.ruleSets[t];for(let i of r)if(this.sequenceMatches(1,i.input))return this.applyLookupList(i.lookupRecords);break;case 2:if(this.coverageIndex(e.coverage)===-1||(t=this.getClassID(this.glyphIterator.cur.id,e.classDef),t===-1))return!1;r=e.classSet[t];for(let i of r)if(this.classSequenceMatches(1,i.classes,e.classDef))return this.applyLookupList(i.lookupRecords);break;case 3:if(this.coverageSequenceMatches(0,e.coverages))return this.applyLookupList(e.lookupRecords);break}return!1}applyChainingContext(e){let t;switch(e.version){case 1:if(t=this.coverageIndex(e.coverage),t===-1)return!1;let r=e.chainRuleSets[t];for(let n of r)if(this.sequenceMatches(-n.backtrack.length,n.backtrack)&&this.sequenceMatches(1,n.input)&&this.sequenceMatches(1+n.input.length,n.lookahead))return this.applyLookupList(n.lookupRecords);break;case 2:if(this.coverageIndex(e.coverage)===-1)return!1;t=this.getClassID(this.glyphIterator.cur.id,e.inputClassDef);let i=e.chainClassSet[t];if(!i)return!1;for(let n of i)if(this.classSequenceMatches(-n.backtrack.length,n.backtrack,e.backtrackClassDef)&&this.classSequenceMatches(1,n.input,e.inputClassDef)&&this.classSequenceMatches(1+n.input.length,n.lookahead,e.lookaheadClassDef))return this.applyLookupList(n.lookupRecords);break;case 3:if(this.coverageSequenceMatches(-e.backtrackGlyphCount,e.backtrackCoverage)&&this.coverageSequenceMatches(0,e.inputCoverage)&&this.coverageSequenceMatches(e.inputGlyphCount,e.lookaheadCoverage))return this.applyLookupList(e.lookupRecords);break}return!1}constructor(e,t){this.font=e,this.table=t,this.script=null,this.scriptTag=null,this.language=null,this.languageTag=null,this.features={},this.lookups={},this.variationsIndex=e._variationProcessor?this.findVariationsIndex(e._variationProcessor.normalizedCoords):-1,this.selectScript(),this.glyphs=[],this.positions=[],this.ligatureID=1,this.currentFeature=null}}class Lt{get id(){return this._id}set id(e){this._id=e,this.substituted=!0;let t=this._font.GDEF;if(t&&t.glyphClassDef){let r=mn.prototype.getClassID(e,t.glyphClassDef);this.isBase=r===1,this.isLigature=r===2,this.isMark=r===3,this.markAttachmentType=t.markAttachClassDef?mn.prototype.getClassID(e,t.markAttachClassDef):0}else this.isMark=this.codePoints.length>0&&this.codePoints.every($l),this.isBase=!this.isMark,this.isLigature=this.codePoints.length>1,this.markAttachmentType=0}copy(){return new Lt(this._font,this.id,this.codePoints,this.features)}constructor(e,t,r=[],i){if(this._font=e,this.codePoints=r,this.id=t,this.features={},Array.isArray(i))for(let n=0;n<i.length;n++){let a=i[n];this.features[a]=!0}else typeof i=="object"&&Object.assign(this.features,i);this.ligatureID=null,this.ligatureComponent=null,this.isLigated=!1,this.cursiveAttachment=null,this.markAttachment=null,this.shaperInfo=null,this.substituted=!1,this.isMultiplied=!1}}class Yc extends Br{static planFeatures(e){e.add(["ljmo","vjmo","tjmo"],!1)}static assignFeatures(e,t){let r=0,i=0;for(;i<t.length;){let n,o=t[i].codePoints[0],c=xn(o);switch([n,r]=Ey[r][c],n){case pr:e.font.hasGlyphForCodePoint(o)||(i=tu(t,i,e.font));break;case to:i=Ay(t,i,e.font);break;case ro:Py(t,i,e.font);break;case io:i=Oy(t,i,e.font);break}i++}}}Ct(Yc,"zeroMarkWidths","NONE");const Pi=44032,Jc=55204,uy=Jc-Pi+1,gn=4352,yn=4449,si=4519,hy=19,bn=21,us=28,dy=gn+hy-1,fy=yn+bn-1,py=si+us-1,Qc=9676,my=s=>4352<=s&&s<=4447||43360<=s&&s<=43388,gy=s=>4448<=s&&s<=4519||55216<=s&&s<=55238,yy=s=>4520<=s&&s<=4607||55243<=s&&s<=55291,by=s=>12334<=s&&s<=12335,vy=s=>Pi<=s&&s<=Jc,wy=s=>s-Pi<uy&&(s-Pi)%us===0,xy=s=>gn<=s&&s<=dy,Cy=s=>yn<=s&&s<=fy,ky=s=>1<=s&&s<=py,Sy=0,_y=1,vn=2,eo=3,wn=4,eu=5,Ty=6;function xn(s){return my(s)?_y:gy(s)?vn:yy(s)?eo:wy(s)?wn:vy(s)?eu:by(s)?Ty:Sy}const kt=0,pr=1,to=2,ro=4,io=5,Ey=[[[kt,0],[kt,1],[kt,0],[kt,0],[pr,2],[pr,3],[io,0]],[[kt,0],[kt,1],[to,2],[kt,0],[pr,2],[pr,3],[io,0]],[[kt,0],[kt,1],[kt,0],[to,3],[pr,2],[pr,3],[ro,0]],[[kt,0],[kt,1],[kt,0],[kt,0],[pr,2],[pr,3],[ro,0]]];function hs(s,e,t){return new Lt(s,s.glyphForCodePoint(e).id,[e],t)}function tu(s,e,t){let r=s[e],n=r.codePoints[0]-Pi,a=si+n%us;n=n/us|0;let o=gn+n/bn|0,c=yn+n%bn;if(!t.hasGlyphForCodePoint(o)||!t.hasGlyphForCodePoint(c)||a!==si&&!t.hasGlyphForCodePoint(a))return e;let u=hs(t,o,r.features);u.features.ljmo=!0;let h=hs(t,c,r.features);h.features.vjmo=!0;let l=[u,h];if(a>si){let d=hs(t,a,r.features);d.features.tjmo=!0,l.push(d)}return s.splice(e,1,...l),e+l.length-1}function Ay(s,e,t){let r=s[e],i=s[e].codePoints[0],n=xn(i),a=s[e-1].codePoints[0],o=xn(a),c,u,h,l;if(o===wn&&n===eo)c=a,l=r;else{n===vn?(u=s[e-1],h=r):(u=s[e-2],h=s[e-1],l=r);let f=u.codePoints[0],p=h.codePoints[0];xy(f)&&Cy(p)&&(c=Pi+((f-gn)*bn+(p-yn))*us)}let d=l&&l.codePoints[0]||si;if(c!=null&&(d===si||ky(d))){let f=c+(d-si);if(t.hasGlyphForCodePoint(f)){let p=o===vn?3:2;return s.splice(e-p+1,p,hs(t,f,r.features)),e-p+1}}return u&&(u.features.ljmo=!0),h&&(h.features.vjmo=!0),l&&(l.features.tjmo=!0),o===wn?(tu(s,e-1,t),e+1):e}function Iy(s){switch(xn(s)){case wn:case eu:return 1;case vn:return 2;case eo:return 3}}function Py(s,e,t){let r=s[e],i=s[e].codePoints[0];if(t.glyphForCodePoint(i).advanceWidth===0)return;let n=s[e-1].codePoints[0],a=Iy(n);return s.splice(e,1),s.splice(e-a,0,r)}function Oy(s,e,t){let r=s[e],i=s[e].codePoints[0];if(t.hasGlyphForCodePoint(Qc)){let n=hs(t,Qc,r.features),a=t.glyphForCodePoint(i).advanceWidth===0?e:e+1;s.splice(a,0,n),e++}return e}var ru={};ru=JSON.parse('{"stateTable":[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,2,3,4,5,6,7,8,9,0,10,11,11,12,13,14,15,16,17],[0,0,0,18,19,20,21,22,23,0,24,0,0,25,26,0,0,27,0],[0,0,0,28,29,30,31,32,33,0,34,0,0,35,36,0,0,37,0],[0,0,0,38,5,7,7,8,9,0,10,0,0,0,13,0,0,16,0],[0,39,0,0,0,40,41,0,9,0,10,0,0,0,42,0,39,0,0],[0,0,0,0,43,44,44,8,9,0,0,0,0,12,43,0,0,0,0],[0,0,0,0,43,44,44,8,9,0,0,0,0,0,43,0,0,0,0],[0,0,0,45,46,47,48,49,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,50,0,0,51,0,10,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,52,0,0,0,0,0,0,0,0],[0,0,0,53,54,55,56,57,58,0,59,0,0,60,61,0,0,62,0],[0,0,0,4,5,7,7,8,9,0,10,0,0,0,13,0,0,16,0],[0,63,64,0,0,40,41,0,9,0,10,0,0,0,42,0,63,0,0],[0,2,3,4,5,6,7,8,9,0,10,11,11,12,13,0,2,16,0],[0,0,0,18,65,20,21,22,23,0,24,0,0,25,26,0,0,27,0],[0,0,0,0,66,67,67,8,9,0,10,0,0,0,68,0,0,0,0],[0,0,0,69,0,70,70,0,71,0,72,0,0,0,0,0,0,0,0],[0,0,0,73,19,74,74,22,23,0,24,0,0,0,26,0,0,27,0],[0,75,0,0,0,76,77,0,23,0,24,0,0,0,78,0,75,0,0],[0,0,0,0,79,80,80,22,23,0,0,0,0,25,79,0,0,0,0],[0,0,0,18,19,20,74,22,23,0,24,0,0,25,26,0,0,27,0],[0,0,0,81,82,83,84,85,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,86,0,0,87,0,24,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,88,0,0,0,0,0,0,0,0],[0,0,0,18,19,74,74,22,23,0,24,0,0,0,26,0,0,27,0],[0,89,90,0,0,76,77,0,23,0,24,0,0,0,78,0,89,0,0],[0,0,0,0,91,92,92,22,23,0,24,0,0,0,93,0,0,0,0],[0,0,0,94,29,95,31,32,33,0,34,0,0,0,36,0,0,37,0],[0,96,0,0,0,97,98,0,33,0,34,0,0,0,99,0,96,0,0],[0,0,0,0,100,101,101,32,33,0,0,0,0,35,100,0,0,0,0],[0,0,0,0,100,101,101,32,33,0,0,0,0,0,100,0,0,0,0],[0,0,0,102,103,104,105,106,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,107,0,0,108,0,34,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,109,0,0,0,0,0,0,0,0],[0,0,0,28,29,95,31,32,33,0,34,0,0,0,36,0,0,37,0],[0,110,111,0,0,97,98,0,33,0,34,0,0,0,99,0,110,0,0],[0,0,0,0,112,113,113,32,33,0,34,0,0,0,114,0,0,0,0],[0,0,0,0,5,7,7,8,9,0,10,0,0,0,13,0,0,16,0],[0,0,0,115,116,117,118,8,9,0,10,0,0,119,120,0,0,16,0],[0,0,0,0,0,121,121,0,9,0,10,0,0,0,42,0,0,0,0],[0,39,0,122,0,123,123,8,9,0,10,0,0,0,42,0,39,0,0],[0,124,64,0,0,0,0,0,0,0,0,0,0,0,0,0,124,0,0],[0,39,0,0,0,121,125,0,9,0,10,0,0,0,42,0,39,0,0],[0,0,0,0,0,126,126,8,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,46,47,48,49,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,47,47,49,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,127,127,49,9,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,128,127,127,49,9,0,0,0,0,0,0,0,0,0,0],[0,0,0,129,130,131,132,133,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0],[0,0,0,0,0,50,0,0,0,0,10,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,134,0,0,0,0,0,0,0,0],[0,0,0,135,54,56,56,57,58,0,59,0,0,0,61,0,0,62,0],[0,136,0,0,0,137,138,0,58,0,59,0,0,0,139,0,136,0,0],[0,0,0,0,140,141,141,57,58,0,0,0,0,60,140,0,0,0,0],[0,0,0,0,140,141,141,57,58,0,0,0,0,0,140,0,0,0,0],[0,0,0,142,143,144,145,146,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,147,0,0,148,0,59,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,149,0,0,0,0,0,0,0,0],[0,0,0,53,54,56,56,57,58,0,59,0,0,0,61,0,0,62,0],[0,150,151,0,0,137,138,0,58,0,59,0,0,0,139,0,150,0,0],[0,0,0,0,152,153,153,57,58,0,59,0,0,0,154,0,0,0,0],[0,0,0,155,116,156,157,8,9,0,10,0,0,158,120,0,0,16,0],[0,0,0,0,0,121,121,0,9,0,10,0,0,0,0,0,0,0,0],[0,75,3,4,5,159,160,8,161,0,162,0,11,12,163,0,75,16,0],[0,0,0,0,0,40,164,0,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,165,44,44,8,9,0,0,0,0,0,165,0,0,0,0],[0,124,64,0,0,40,164,0,9,0,10,0,0,0,42,0,124,0,0],[0,0,0,0,0,70,70,0,71,0,72,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,71,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,166,0,0,167,0,72,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,168,0,0,0,0,0,0,0,0],[0,0,0,0,19,74,74,22,23,0,24,0,0,0,26,0,0,27,0],[0,0,0,0,79,80,80,22,23,0,0,0,0,0,79,0,0,0,0],[0,0,0,169,170,171,172,22,23,0,24,0,0,173,174,0,0,27,0],[0,0,0,0,0,175,175,0,23,0,24,0,0,0,78,0,0,0,0],[0,75,0,176,0,177,177,22,23,0,24,0,0,0,78,0,75,0,0],[0,178,90,0,0,0,0,0,0,0,0,0,0,0,0,0,178,0,0],[0,75,0,0,0,175,179,0,23,0,24,0,0,0,78,0,75,0,0],[0,0,0,0,0,180,180,22,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,82,83,84,85,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,83,83,85,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,181,181,85,23,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,182,181,181,85,23,0,0,0,0,0,0,0,0,0,0],[0,0,0,183,184,185,186,187,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0],[0,0,0,0,0,86,0,0,0,0,24,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,188,0,0,0,0,0,0,0,0],[0,0,0,189,170,190,191,22,23,0,24,0,0,192,174,0,0,27,0],[0,0,0,0,0,175,175,0,23,0,24,0,0,0,0,0,0,0,0],[0,0,0,0,0,76,193,0,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,194,80,80,22,23,0,0,0,0,0,194,0,0,0,0],[0,178,90,0,0,76,193,0,23,0,24,0,0,0,78,0,178,0,0],[0,0,0,0,29,95,31,32,33,0,34,0,0,0,36,0,0,37,0],[0,0,0,0,100,101,101,32,33,0,0,0,0,0,100,0,0,0,0],[0,0,0,195,196,197,198,32,33,0,34,0,0,199,200,0,0,37,0],[0,0,0,0,0,201,201,0,33,0,34,0,0,0,99,0,0,0,0],[0,96,0,202,0,203,203,32,33,0,34,0,0,0,99,0,96,0,0],[0,204,111,0,0,0,0,0,0,0,0,0,0,0,0,0,204,0,0],[0,96,0,0,0,201,205,0,33,0,34,0,0,0,99,0,96,0,0],[0,0,0,0,0,206,206,32,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,103,104,105,106,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,104,104,106,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,207,207,106,33,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,208,207,207,106,33,0,0,0,0,0,0,0,0,0,0],[0,0,0,209,210,211,212,213,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,34,0,0,0,0,0,0,0,0],[0,0,0,0,0,107,0,0,0,0,34,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,214,0,0,0,0,0,0,0,0],[0,0,0,215,196,216,217,32,33,0,34,0,0,218,200,0,0,37,0],[0,0,0,0,0,201,201,0,33,0,34,0,0,0,0,0,0,0,0],[0,0,0,0,0,97,219,0,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,220,101,101,32,33,0,0,0,0,0,220,0,0,0,0],[0,204,111,0,0,97,219,0,33,0,34,0,0,0,99,0,204,0,0],[0,0,0,221,116,222,222,8,9,0,10,0,0,0,120,0,0,16,0],[0,223,0,0,0,40,224,0,9,0,10,0,0,0,42,0,223,0,0],[0,0,0,0,225,44,44,8,9,0,0,0,0,119,225,0,0,0,0],[0,0,0,115,116,117,222,8,9,0,10,0,0,119,120,0,0,16,0],[0,0,0,115,116,222,222,8,9,0,10,0,0,0,120,0,0,16,0],[0,226,64,0,0,40,224,0,9,0,10,0,0,0,42,0,226,0,0],[0,0,0,0,0,0,0,0,9,0,0,0,0,0,0,0,0,0,0],[0,39,0,0,0,121,121,0,9,0,10,0,0,0,42,0,39,0,0],[0,0,0,0,0,44,44,8,9,0,0,0,0,0,0,0,0,0,0],[0,0,0,227,0,228,229,0,9,0,10,0,0,230,0,0,0,0,0],[0,39,0,122,0,121,121,0,9,0,10,0,0,0,42,0,39,0,0],[0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,231,231,49,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,232,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,130,131,132,133,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,131,131,133,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,233,233,133,9,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,234,233,233,133,9,0,0,0,0,0,0,0,0,0,0],[0,0,0,235,236,237,238,239,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,54,56,56,57,58,0,59,0,0,0,61,0,0,62,0],[0,0,0,240,241,242,243,57,58,0,59,0,0,244,245,0,0,62,0],[0,0,0,0,0,246,246,0,58,0,59,0,0,0,139,0,0,0,0],[0,136,0,247,0,248,248,57,58,0,59,0,0,0,139,0,136,0,0],[0,249,151,0,0,0,0,0,0,0,0,0,0,0,0,0,249,0,0],[0,136,0,0,0,246,250,0,58,0,59,0,0,0,139,0,136,0,0],[0,0,0,0,0,251,251,57,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,143,144,145,146,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,144,144,146,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,252,252,146,58,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,253,252,252,146,58,0,0,0,0,0,0,0,0,0,0],[0,0,0,254,255,256,257,258,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,59,0,0,0,0,0,0,0,0],[0,0,0,0,0,147,0,0,0,0,59,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,259,0,0,0,0,0,0,0,0],[0,0,0,260,241,261,262,57,58,0,59,0,0,263,245,0,0,62,0],[0,0,0,0,0,246,246,0,58,0,59,0,0,0,0,0,0,0,0],[0,0,0,0,0,137,264,0,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,265,141,141,57,58,0,0,0,0,0,265,0,0,0,0],[0,249,151,0,0,137,264,0,58,0,59,0,0,0,139,0,249,0,0],[0,0,0,221,116,222,222,8,9,0,10,0,0,0,120,0,0,16,0],[0,0,0,0,225,44,44,8,9,0,0,0,0,158,225,0,0,0,0],[0,0,0,155,116,156,222,8,9,0,10,0,0,158,120,0,0,16,0],[0,0,0,155,116,222,222,8,9,0,10,0,0,0,120,0,0,16,0],[0,0,0,0,43,266,266,8,161,0,24,0,0,12,267,0,0,0,0],[0,75,0,176,43,268,268,269,161,0,24,0,0,0,267,0,75,0,0],[0,0,0,0,0,270,0,0,271,0,162,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,272,0,0,0,0,0,0,0,0],[0,273,274,0,0,40,41,0,9,0,10,0,0,0,42,0,273,0,0],[0,0,0,40,0,123,123,8,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,121,275,0,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,72,0,0,0,0,0,0,0,0],[0,0,0,0,0,166,0,0,0,0,72,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,276,0,0,0,0,0,0,0,0],[0,0,0,277,170,278,278,22,23,0,24,0,0,0,174,0,0,27,0],[0,279,0,0,0,76,280,0,23,0,24,0,0,0,78,0,279,0,0],[0,0,0,0,281,80,80,22,23,0,0,0,0,173,281,0,0,0,0],[0,0,0,169,170,171,278,22,23,0,24,0,0,173,174,0,0,27,0],[0,0,0,169,170,278,278,22,23,0,24,0,0,0,174,0,0,27,0],[0,282,90,0,0,76,280,0,23,0,24,0,0,0,78,0,282,0,0],[0,0,0,0,0,0,0,0,23,0,0,0,0,0,0,0,0,0,0],[0,75,0,0,0,175,175,0,23,0,24,0,0,0,78,0,75,0,0],[0,0,0,0,0,80,80,22,23,0,0,0,0,0,0,0,0,0,0],[0,0,0,283,0,284,285,0,23,0,24,0,0,286,0,0,0,0,0],[0,75,0,176,0,175,175,0,23,0,24,0,0,0,78,0,75,0,0],[0,0,0,0,0,0,0,22,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,287,287,85,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,288,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,184,185,186,187,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,185,185,187,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,289,289,187,23,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,290,289,289,187,23,0,0,0,0,0,0,0,0,0,0],[0,0,0,291,292,293,294,295,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,277,170,278,278,22,23,0,24,0,0,0,174,0,0,27,0],[0,0,0,0,281,80,80,22,23,0,0,0,0,192,281,0,0,0,0],[0,0,0,189,170,190,278,22,23,0,24,0,0,192,174,0,0,27,0],[0,0,0,189,170,278,278,22,23,0,24,0,0,0,174,0,0,27,0],[0,0,0,76,0,177,177,22,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,175,296,0,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,297,196,298,298,32,33,0,34,0,0,0,200,0,0,37,0],[0,299,0,0,0,97,300,0,33,0,34,0,0,0,99,0,299,0,0],[0,0,0,0,301,101,101,32,33,0,0,0,0,199,301,0,0,0,0],[0,0,0,195,196,197,298,32,33,0,34,0,0,199,200,0,0,37,0],[0,0,0,195,196,298,298,32,33,0,34,0,0,0,200,0,0,37,0],[0,302,111,0,0,97,300,0,33,0,34,0,0,0,99,0,302,0,0],[0,0,0,0,0,0,0,0,33,0,0,0,0,0,0,0,0,0,0],[0,96,0,0,0,201,201,0,33,0,34,0,0,0,99,0,96,0,0],[0,0,0,0,0,101,101,32,33,0,0,0,0,0,0,0,0,0,0],[0,0,0,303,0,304,305,0,33,0,34,0,0,306,0,0,0,0,0],[0,96,0,202,0,201,201,0,33,0,34,0,0,0,99,0,96,0,0],[0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,307,307,106,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,308,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,210,211,212,213,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,211,211,213,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,309,309,213,33,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,310,309,309,213,33,0,0,0,0,0,0,0,0,0,0],[0,0,0,311,312,313,314,315,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,297,196,298,298,32,33,0,34,0,0,0,200,0,0,37,0],[0,0,0,0,301,101,101,32,33,0,0,0,0,218,301,0,0,0,0],[0,0,0,215,196,216,298,32,33,0,34,0,0,218,200,0,0,37,0],[0,0,0,215,196,298,298,32,33,0,34,0,0,0,200,0,0,37,0],[0,0,0,97,0,203,203,32,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,201,316,0,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,116,222,222,8,9,0,10,0,0,0,120,0,0,16,0],[0,0,0,0,225,44,44,8,9,0,0,0,0,0,225,0,0,0,0],[0,0,0,317,318,319,320,8,9,0,10,0,0,321,322,0,0,16,0],[0,223,0,323,0,123,123,8,9,0,10,0,0,0,42,0,223,0,0],[0,223,0,0,0,121,324,0,9,0,10,0,0,0,42,0,223,0,0],[0,0,0,325,318,326,327,8,9,0,10,0,0,328,322,0,0,16,0],[0,0,0,64,0,121,121,0,9,0,10,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,9,0,0,0,0,230,0,0,0,0,0],[0,0,0,227,0,228,121,0,9,0,10,0,0,230,0,0,0,0,0],[0,0,0,227,0,121,121,0,9,0,10,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,49,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,46,0,0],[0,0,0,0,0,329,329,133,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,330,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,236,237,238,239,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,237,237,239,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,331,331,239,9,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,332,331,331,239,9,0,0,0,0,0,0,0,0,0,0],[0,0,0,333,40,121,334,0,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,335,241,336,336,57,58,0,59,0,0,0,245,0,0,62,0],[0,337,0,0,0,137,338,0,58,0,59,0,0,0,139,0,337,0,0],[0,0,0,0,339,141,141,57,58,0,0,0,0,244,339,0,0,0,0],[0,0,0,240,241,242,336,57,58,0,59,0,0,244,245,0,0,62,0],[0,0,0,240,241,336,336,57,58,0,59,0,0,0,245,0,0,62,0],[0,340,151,0,0,137,338,0,58,0,59,0,0,0,139,0,340,0,0],[0,0,0,0,0,0,0,0,58,0,0,0,0,0,0,0,0,0,0],[0,136,0,0,0,246,246,0,58,0,59,0,0,0,139,0,136,0,0],[0,0,0,0,0,141,141,57,58,0,0,0,0,0,0,0,0,0,0],[0,0,0,341,0,342,343,0,58,0,59,0,0,344,0,0,0,0,0],[0,136,0,247,0,246,246,0,58,0,59,0,0,0,139,0,136,0,0],[0,0,0,0,0,0,0,57,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,345,345,146,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,346,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,255,256,257,258,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,256,256,258,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,347,347,258,58,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,348,347,347,258,58,0,0,0,0,0,0,0,0,0,0],[0,0,0,349,350,351,352,353,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,335,241,336,336,57,58,0,59,0,0,0,245,0,0,62,0],[0,0,0,0,339,141,141,57,58,0,0,0,0,263,339,0,0,0,0],[0,0,0,260,241,261,336,57,58,0,59,0,0,263,245,0,0,62,0],[0,0,0,260,241,336,336,57,58,0,59,0,0,0,245,0,0,62,0],[0,0,0,137,0,248,248,57,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,246,354,0,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,126,126,8,23,0,0,0,0,0,0,0,0,0,0],[0,355,90,0,0,121,125,0,9,0,10,0,0,0,42,0,355,0,0],[0,0,0,0,0,356,356,269,23,0,0,0,0,0,0,0,0,0,0],[0,0,0,357,358,359,360,361,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,162,0,0,0,0,0,0,0,0],[0,0,0,0,0,270,0,0,0,0,162,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,363,0,0,0,0,0,0,0,0],[0,0,0,364,116,365,366,8,161,0,162,0,0,367,120,0,0,16,0],[0,0,0,0,0,368,368,0,161,0,162,0,0,0,0,0,0,0,0],[0,0,0,40,0,121,121,0,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,170,278,278,22,23,0,24,0,0,0,174,0,0,27,0],[0,0,0,0,281,80,80,22,23,0,0,0,0,0,281,0,0,0,0],[0,0,0,369,370,371,372,22,23,0,24,0,0,373,374,0,0,27,0],[0,279,0,375,0,177,177,22,23,0,24,0,0,0,78,0,279,0,0],[0,279,0,0,0,175,376,0,23,0,24,0,0,0,78,0,279,0,0],[0,0,0,377,370,378,379,22,23,0,24,0,0,380,374,0,0,27,0],[0,0,0,90,0,175,175,0,23,0,24,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,23,0,0,0,0,286,0,0,0,0,0],[0,0,0,283,0,284,175,0,23,0,24,0,0,286,0,0,0,0,0],[0,0,0,283,0,175,175,0,23,0,24,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,85,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,82,0,0],[0,0,0,0,0,381,381,187,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,382,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,292,293,294,295,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,293,293,295,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,383,383,295,23,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,384,383,383,295,23,0,0,0,0,0,0,0,0,0,0],[0,0,0,385,76,175,386,0,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,76,0,175,175,0,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,196,298,298,32,33,0,34,0,0,0,200,0,0,37,0],[0,0,0,0,301,101,101,32,33,0,0,0,0,0,301,0,0,0,0],[0,0,0,387,388,389,390,32,33,0,34,0,0,391,392,0,0,37,0],[0,299,0,393,0,203,203,32,33,0,34,0,0,0,99,0,299,0,0],[0,299,0,0,0,201,394,0,33,0,34,0,0,0,99,0,299,0,0],[0,0,0,395,388,396,397,32,33,0,34,0,0,398,392,0,0,37,0],[0,0,0,111,0,201,201,0,33,0,34,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,33,0,0,0,0,306,0,0,0,0,0],[0,0,0,303,0,304,201,0,33,0,34,0,0,306,0,0,0,0,0],[0,0,0,303,0,201,201,0,33,0,34,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,106,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,103,0,0],[0,0,0,0,0,399,399,213,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,400,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,312,313,314,315,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,313,313,315,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,401,401,315,33,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,402,401,401,315,33,0,0,0,0,0,0,0,0,0,0],[0,0,0,403,97,201,404,0,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,97,0,201,201,0,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,405,318,406,406,8,9,0,10,0,0,0,322,0,0,16,0],[0,407,0,0,0,40,408,0,9,0,10,0,0,0,42,0,407,0,0],[0,0,0,0,409,44,44,8,9,0,0,0,0,321,409,0,0,0,0],[0,0,0,317,318,319,406,8,9,0,10,0,0,321,322,0,0,16,0],[0,0,0,317,318,406,406,8,9,0,10,0,0,0,322,0,0,16,0],[0,410,64,0,0,40,408,0,9,0,10,0,0,0,42,0,410,0,0],[0,223,0,0,0,121,121,0,9,0,10,0,0,0,42,0,223,0,0],[0,223,0,323,0,121,121,0,9,0,10,0,0,0,42,0,223,0,0],[0,0,0,405,318,406,406,8,9,0,10,0,0,0,322,0,0,16,0],[0,0,0,0,409,44,44,8,9,0,0,0,0,328,409,0,0,0,0],[0,0,0,325,318,326,406,8,9,0,10,0,0,328,322,0,0,16,0],[0,0,0,325,318,406,406,8,9,0,10,0,0,0,322,0,0,16,0],[0,0,0,0,0,0,0,133,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,130,0,0],[0,0,0,0,0,411,411,239,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,412,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,40,121,334,0,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,413,0,0,0,9,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,241,336,336,57,58,0,59,0,0,0,245,0,0,62,0],[0,0,0,0,339,141,141,57,58,0,0,0,0,0,339,0,0,0,0],[0,0,0,414,415,416,417,57,58,0,59,0,0,418,419,0,0,62,0],[0,337,0,420,0,248,248,57,58,0,59,0,0,0,139,0,337,0,0],[0,337,0,0,0,246,421,0,58,0,59,0,0,0,139,0,337,0,0],[0,0,0,422,415,423,424,57,58,0,59,0,0,425,419,0,0,62,0],[0,0,0,151,0,246,246,0,58,0,59,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,58,0,0,0,0,344,0,0,0,0,0],[0,0,0,341,0,342,246,0,58,0,59,0,0,344,0,0,0,0,0],[0,0,0,341,0,246,246,0,58,0,59,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,146,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,143,0,0],[0,0,0,0,0,426,426,258,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,427,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,350,351,352,353,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,351,351,353,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,428,428,353,58,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,429,428,428,353,58,0,0,0,0,0,0,0,0,0,0],[0,0,0,430,137,246,431,0,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,137,0,246,246,0,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,432,116,433,434,8,161,0,162,0,0,435,120,0,0,16,0],[0,0,0,0,0,180,180,269,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,358,359,360,361,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,0,0,359,359,361,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,0,0,436,436,361,161,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,437,436,436,361,161,0,0,0,0,0,0,0,0,0,0],[0,0,0,438,439,440,441,442,161,0,162,0,0,0,362,0,0,0,0],[0,443,274,0,0,0,0,0,0,0,0,0,0,0,0,0,443,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,444,116,445,445,8,161,0,162,0,0,0,120,0,0,16,0],[0,0,0,0,225,44,44,8,161,0,0,0,0,367,225,0,0,0,0],[0,0,0,364,116,365,445,8,161,0,162,0,0,367,120,0,0,16,0],[0,0,0,364,116,445,445,8,161,0,162,0,0,0,120,0,0,16,0],[0,0,0,0,0,0,0,0,161,0,0,0,0,0,0,0,0,0,0],[0,0,0,446,370,447,447,22,23,0,24,0,0,0,374,0,0,27,0],[0,448,0,0,0,76,449,0,23,0,24,0,0,0,78,0,448,0,0],[0,0,0,0,450,80,80,22,23,0,0,0,0,373,450,0,0,0,0],[0,0,0,369,370,371,447,22,23,0,24,0,0,373,374,0,0,27,0],[0,0,0,369,370,447,447,22,23,0,24,0,0,0,374,0,0,27,0],[0,451,90,0,0,76,449,0,23,0,24,0,0,0,78,0,451,0,0],[0,279,0,0,0,175,175,0,23,0,24,0,0,0,78,0,279,0,0],[0,279,0,375,0,175,175,0,23,0,24,0,0,0,78,0,279,0,0],[0,0,0,446,370,447,447,22,23,0,24,0,0,0,374,0,0,27,0],[0,0,0,0,450,80,80,22,23,0,0,0,0,380,450,0,0,0,0],[0,0,0,377,370,378,447,22,23,0,24,0,0,380,374,0,0,27,0],[0,0,0,377,370,447,447,22,23,0,24,0,0,0,374,0,0,27,0],[0,0,0,0,0,0,0,187,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,184,0,0],[0,0,0,0,0,452,452,295,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,453,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,76,175,386,0,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,454,0,0,0,23,0,0,0,0,0,0,0,0,0,0],[0,0,0,455,388,456,456,32,33,0,34,0,0,0,392,0,0,37,0],[0,457,0,0,0,97,458,0,33,0,34,0,0,0,99,0,457,0,0],[0,0,0,0,459,101,101,32,33,0,0,0,0,391,459,0,0,0,0],[0,0,0,387,388,389,456,32,33,0,34,0,0,391,392,0,0,37,0],[0,0,0,387,388,456,456,32,33,0,34,0,0,0,392,0,0,37,0],[0,460,111,0,0,97,458,0,33,0,34,0,0,0,99,0,460,0,0],[0,299,0,0,0,201,201,0,33,0,34,0,0,0,99,0,299,0,0],[0,299,0,393,0,201,201,0,33,0,34,0,0,0,99,0,299,0,0],[0,0,0,455,388,456,456,32,33,0,34,0,0,0,392,0,0,37,0],[0,0,0,0,459,101,101,32,33,0,0,0,0,398,459,0,0,0,0],[0,0,0,395,388,396,456,32,33,0,34,0,0,398,392,0,0,37,0],[0,0,0,395,388,456,456,32,33,0,34,0,0,0,392,0,0,37,0],[0,0,0,0,0,0,0,213,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,210,0,0],[0,0,0,0,0,461,461,315,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,462,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,97,201,404,0,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,463,0,0,0,33,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,318,406,406,8,9,0,10,0,0,0,322,0,0,16,0],[0,0,0,0,409,44,44,8,9,0,0,0,0,0,409,0,0,0,0],[0,0,0,464,465,466,467,8,9,0,10,0,0,468,469,0,0,16,0],[0,407,0,470,0,123,123,8,9,0,10,0,0,0,42,0,407,0,0],[0,407,0,0,0,121,471,0,9,0,10,0,0,0,42,0,407,0,0],[0,0,0,472,465,473,474,8,9,0,10,0,0,475,469,0,0,16,0],[0,0,0,0,0,0,0,239,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,236,0,0],[0,0,0,0,0,0,476,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,477,415,478,478,57,58,0,59,0,0,0,419,0,0,62,0],[0,479,0,0,0,137,480,0,58,0,59,0,0,0,139,0,479,0,0],[0,0,0,0,481,141,141,57,58,0,0,0,0,418,481,0,0,0,0],[0,0,0,414,415,416,478,57,58,0,59,0,0,418,419,0,0,62,0],[0,0,0,414,415,478,478,57,58,0,59,0,0,0,419,0,0,62,0],[0,482,151,0,0,137,480,0,58,0,59,0,0,0,139,0,482,0,0],[0,337,0,0,0,246,246,0,58,0,59,0,0,0,139,0,337,0,0],[0,337,0,420,0,246,246,0,58,0,59,0,0,0,139,0,337,0,0],[0,0,0,477,415,478,478,57,58,0,59,0,0,0,419,0,0,62,0],[0,0,0,0,481,141,141,57,58,0,0,0,0,425,481,0,0,0,0],[0,0,0,422,415,423,478,57,58,0,59,0,0,425,419,0,0,62,0],[0,0,0,422,415,478,478,57,58,0,59,0,0,0,419,0,0,62,0],[0,0,0,0,0,0,0,258,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,0],[0,0,0,0,0,483,483,353,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,484,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,137,246,431,0,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,485,0,0,0,58,0,0,0,0,0,0,0,0,0,0],[0,0,0,444,116,445,445,8,161,0,162,0,0,0,120,0,0,16,0],[0,0,0,0,225,44,44,8,161,0,0,0,0,435,225,0,0,0,0],[0,0,0,432,116,433,445,8,161,0,162,0,0,435,120,0,0,16,0],[0,0,0,432,116,445,445,8,161,0,162,0,0,0,120,0,0,16,0],[0,0,0,0,0,486,486,361,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,487,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,439,440,441,442,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,0,0,440,440,442,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,0,0,488,488,442,161,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,489,488,488,442,161,0,0,0,0,0,0,0,0,0,0],[0,0,0,490,491,492,493,494,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,495,0,496,497,0,161,0,162,0,0,498,0,0,0,0,0],[0,0,0,0,116,445,445,8,161,0,162,0,0,0,120,0,0,16,0],[0,0,0,0,225,44,44,8,161,0,0,0,0,0,225,0,0,0,0],[0,0,0,0,370,447,447,22,23,0,24,0,0,0,374,0,0,27,0],[0,0,0,0,450,80,80,22,23,0,0,0,0,0,450,0,0,0,0],[0,0,0,499,500,501,502,22,23,0,24,0,0,503,504,0,0,27,0],[0,448,0,505,0,177,177,22,23,0,24,0,0,0,78,0,448,0,0],[0,448,0,0,0,175,506,0,23,0,24,0,0,0,78,0,448,0,0],[0,0,0,507,500,508,509,22,23,0,24,0,0,510,504,0,0,27,0],[0,0,0,0,0,0,0,295,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,292,0,0],[0,0,0,0,0,0,511,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,388,456,456,32,33,0,34,0,0,0,392,0,0,37,0],[0,0,0,0,459,101,101,32,33,0,0,0,0,0,459,0,0,0,0],[0,0,0,512,513,514,515,32,33,0,34,0,0,516,517,0,0,37,0],[0,457,0,518,0,203,203,32,33,0,34,0,0,0,99,0,457,0,0],[0,457,0,0,0,201,519,0,33,0,34,0,0,0,99,0,457,0,0],[0,0,0,520,513,521,522,32,33,0,34,0,0,523,517,0,0,37,0],[0,0,0,0,0,0,0,315,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,312,0,0],[0,0,0,0,0,0,524,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,525,465,526,526,8,9,0,10,0,0,0,469,0,0,16,0],[0,527,0,0,0,40,528,0,9,0,10,0,0,0,42,0,527,0,0],[0,0,0,0,529,44,44,8,9,0,0,0,0,468,529,0,0,0,0],[0,0,0,464,465,466,526,8,9,0,10,0,0,468,469,0,0,16,0],[0,0,0,464,465,526,526,8,9,0,10,0,0,0,469,0,0,16,0],[0,530,64,0,0,40,528,0,9,0,10,0,0,0,42,0,530,0,0],[0,407,0,0,0,121,121,0,9,0,10,0,0,0,42,0,407,0,0],[0,407,0,470,0,121,121,0,9,0,10,0,0,0,42,0,407,0,0],[0,0,0,525,465,526,526,8,9,0,10,0,0,0,469,0,0,16,0],[0,0,0,0,529,44,44,8,9,0,0,0,0,475,529,0,0,0,0],[0,0,0,472,465,473,526,8,9,0,10,0,0,475,469,0,0,16,0],[0,0,0,472,465,526,526,8,9,0,10,0,0,0,469,0,0,16,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,40,0,0],[0,0,0,0,415,478,478,57,58,0,59,0,0,0,419,0,0,62,0],[0,0,0,0,481,141,141,57,58,0,0,0,0,0,481,0,0,0,0],[0,0,0,531,532,533,534,57,58,0,59,0,0,535,536,0,0,62,0],[0,479,0,537,0,248,248,57,58,0,59,0,0,0,139,0,479,0,0],[0,479,0,0,0,246,538,0,58,0,59,0,0,0,139,0,479,0,0],[0,0,0,539,532,540,541,57,58,0,59,0,0,542,536,0,0,62,0],[0,0,0,0,0,0,0,353,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,350,0,0],[0,0,0,0,0,0,543,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,361,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,358,0,0],[0,0,0,0,0,544,544,442,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,545,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,491,492,493,494,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,0,0,492,492,494,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,0,0,546,546,494,161,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,547,546,546,494,161,0,0,0,0,0,0,0,0,0,0],[0,0,0,548,549,368,550,0,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,274,0,368,368,0,161,0,162,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,161,0,0,0,0,498,0,0,0,0,0],[0,0,0,495,0,496,368,0,161,0,162,0,0,498,0,0,0,0,0],[0,0,0,495,0,368,368,0,161,0,162,0,0,0,0,0,0,0,0],[0,0,0,551,500,552,552,22,23,0,24,0,0,0,504,0,0,27,0],[0,553,0,0,0,76,554,0,23,0,24,0,0,0,78,0,553,0,0],[0,0,0,0,555,80,80,22,23,0,0,0,0,503,555,0,0,0,0],[0,0,0,499,500,501,552,22,23,0,24,0,0,503,504,0,0,27,0],[0,0,0,499,500,552,552,22,23,0,24,0,0,0,504,0,0,27,0],[0,556,90,0,0,76,554,0,23,0,24,0,0,0,78,0,556,0,0],[0,448,0,0,0,175,175,0,23,0,24,0,0,0,78,0,448,0,0],[0,448,0,505,0,175,175,0,23,0,24,0,0,0,78,0,448,0,0],[0,0,0,551,500,552,552,22,23,0,24,0,0,0,504,0,0,27,0],[0,0,0,0,555,80,80,22,23,0,0,0,0,510,555,0,0,0,0],[0,0,0,507,500,508,552,22,23,0,24,0,0,510,504,0,0,27,0],[0,0,0,507,500,552,552,22,23,0,24,0,0,0,504,0,0,27,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,76,0,0],[0,0,0,557,513,558,558,32,33,0,34,0,0,0,517,0,0,37,0],[0,559,0,0,0,97,560,0,33,0,34,0,0,0,99,0,559,0,0],[0,0,0,0,561,101,101,32,33,0,0,0,0,516,561,0,0,0,0],[0,0,0,512,513,514,558,32,33,0,34,0,0,516,517,0,0,37,0],[0,0,0,512,513,558,558,32,33,0,34,0,0,0,517,0,0,37,0],[0,562,111,0,0,97,560,0,33,0,34,0,0,0,99,0,562,0,0],[0,457,0,0,0,201,201,0,33,0,34,0,0,0,99,0,457,0,0],[0,457,0,518,0,201,201,0,33,0,34,0,0,0,99,0,457,0,0],[0,0,0,557,513,558,558,32,33,0,34,0,0,0,517,0,0,37,0],[0,0,0,0,561,101,101,32,33,0,0,0,0,523,561,0,0,0,0],[0,0,0,520,513,521,558,32,33,0,34,0,0,523,517,0,0,37,0],[0,0,0,520,513,558,558,32,33,0,34,0,0,0,517,0,0,37,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,97,0,0],[0,0,0,0,465,526,526,8,9,0,10,0,0,0,469,0,0,16,0],[0,0,0,0,529,44,44,8,9,0,0,0,0,0,529,0,0,0,0],[0,0,0,563,66,564,565,8,9,0,10,0,0,566,68,0,0,16,0],[0,527,0,567,0,123,123,8,9,0,10,0,0,0,42,0,527,0,0],[0,527,0,0,0,121,568,0,9,0,10,0,0,0,42,0,527,0,0],[0,0,0,569,66,570,571,8,9,0,10,0,0,572,68,0,0,16,0],[0,0,0,573,532,574,574,57,58,0,59,0,0,0,536,0,0,62,0],[0,575,0,0,0,137,576,0,58,0,59,0,0,0,139,0,575,0,0],[0,0,0,0,577,141,141,57,58,0,0,0,0,535,577,0,0,0,0],[0,0,0,531,532,533,574,57,58,0,59,0,0,535,536,0,0,62,0],[0,0,0,531,532,574,574,57,58,0,59,0,0,0,536,0,0,62,0],[0,578,151,0,0,137,576,0,58,0,59,0,0,0,139,0,578,0,0],[0,479,0,0,0,246,246,0,58,0,59,0,0,0,139,0,479,0,0],[0,479,0,537,0,246,246,0,58,0,59,0,0,0,139,0,479,0,0],[0,0,0,573,532,574,574,57,58,0,59,0,0,0,536,0,0,62,0],[0,0,0,0,577,141,141,57,58,0,0,0,0,542,577,0,0,0,0],[0,0,0,539,532,540,574,57,58,0,59,0,0,542,536,0,0,62,0],[0,0,0,539,532,574,574,57,58,0,59,0,0,0,536,0,0,62,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,137,0,0],[0,0,0,0,0,0,0,442,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,439,0,0],[0,0,0,0,0,579,579,494,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,580,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,549,368,550,0,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,0,0,368,368,0,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,0,581,0,0,0,161,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,500,552,552,22,23,0,24,0,0,0,504,0,0,27,0],[0,0,0,0,555,80,80,22,23,0,0,0,0,0,555,0,0,0,0],[0,0,0,582,91,583,584,22,23,0,24,0,0,585,93,0,0,27,0],[0,553,0,586,0,177,177,22,23,0,24,0,0,0,78,0,553,0,0],[0,553,0,0,0,175,587,0,23,0,24,0,0,0,78,0,553,0,0],[0,0,0,588,91,589,590,22,23,0,24,0,0,591,93,0,0,27,0],[0,0,0,0,513,558,558,32,33,0,34,0,0,0,517,0,0,37,0],[0,0,0,0,561,101,101,32,33,0,0,0,0,0,561,0,0,0,0],[0,0,0,592,112,593,594,32,33,0,34,0,0,595,114,0,0,37,0],[0,559,0,596,0,203,203,32,33,0,34,0,0,0,99,0,559,0,0],[0,559,0,0,0,201,597,0,33,0,34,0,0,0,99,0,559,0,0],[0,0,0,598,112,599,600,32,33,0,34,0,0,601,114,0,0,37,0],[0,0,0,602,66,67,67,8,9,0,10,0,0,0,68,0,0,16,0],[0,0,0,0,165,44,44,8,9,0,0,0,0,566,165,0,0,0,0],[0,0,0,563,66,564,67,8,9,0,10,0,0,566,68,0,0,16,0],[0,0,0,563,66,67,67,8,9,0,10,0,0,0,68,0,0,16,0],[0,527,0,0,0,121,121,0,9,0,10,0,0,0,42,0,527,0,0],[0,527,0,567,0,121,121,0,9,0,10,0,0,0,42,0,527,0,0],[0,0,0,602,66,67,67,8,9,0,10,0,0,0,68,0,0,16,0],[0,0,0,0,165,44,44,8,9,0,0,0,0,572,165,0,0,0,0],[0,0,0,569,66,570,67,8,9,0,10,0,0,572,68,0,0,16,0],[0,0,0,569,66,67,67,8,9,0,10,0,0,0,68,0,0,16,0],[0,0,0,0,532,574,574,57,58,0,59,0,0,0,536,0,0,62,0],[0,0,0,0,577,141,141,57,58,0,0,0,0,0,577,0,0,0,0],[0,0,0,603,152,604,605,57,58,0,59,0,0,606,154,0,0,62,0],[0,575,0,607,0,248,248,57,58,0,59,0,0,0,139,0,575,0,0],[0,575,0,0,0,246,608,0,58,0,59,0,0,0,139,0,575,0,0],[0,0,0,609,152,610,611,57,58,0,59,0,0,612,154,0,0,62,0],[0,0,0,0,0,0,0,494,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,491,0,0],[0,0,0,0,0,0,613,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,614,91,92,92,22,23,0,24,0,0,0,93,0,0,27,0],[0,0,0,0,194,80,80,22,23,0,0,0,0,585,194,0,0,0,0],[0,0,0,582,91,583,92,22,23,0,24,0,0,585,93,0,0,27,0],[0,0,0,582,91,92,92,22,23,0,24,0,0,0,93,0,0,27,0],[0,553,0,0,0,175,175,0,23,0,24,0,0,0,78,0,553,0,0],[0,553,0,586,0,175,175,0,23,0,24,0,0,0,78,0,553,0,0],[0,0,0,614,91,92,92,22,23,0,24,0,0,0,93,0,0,27,0],[0,0,0,0,194,80,80,22,23,0,0,0,0,591,194,0,0,0,0],[0,0,0,588,91,589,92,22,23,0,24,0,0,591,93,0,0,27,0],[0,0,0,588,91,92,92,22,23,0,24,0,0,0,93,0,0,27,0],[0,0,0,615,112,113,113,32,33,0,34,0,0,0,114,0,0,37,0],[0,0,0,0,220,101,101,32,33,0,0,0,0,595,220,0,0,0,0],[0,0,0,592,112,593,113,32,33,0,34,0,0,595,114,0,0,37,0],[0,0,0,592,112,113,113,32,33,0,34,0,0,0,114,0,0,37,0],[0,559,0,0,0,201,201,0,33,0,34,0,0,0,99,0,559,0,0],[0,559,0,596,0,201,201,0,33,0,34,0,0,0,99,0,559,0,0],[0,0,0,615,112,113,113,32,33,0,34,0,0,0,114,0,0,37,0],[0,0,0,0,220,101,101,32,33,0,0,0,0,601,220,0,0,0,0],[0,0,0,598,112,599,113,32,33,0,34,0,0,601,114,0,0,37,0],[0,0,0,598,112,113,113,32,33,0,34,0,0,0,114,0,0,37,0],[0,0,0,0,66,67,67,8,9,0,10,0,0,0,68,0,0,16,0],[0,0,0,616,152,153,153,57,58,0,59,0,0,0,154,0,0,62,0],[0,0,0,0,265,141,141,57,58,0,0,0,0,606,265,0,0,0,0],[0,0,0,603,152,604,153,57,58,0,59,0,0,606,154,0,0,62,0],[0,0,0,603,152,153,153,57,58,0,59,0,0,0,154,0,0,62,0],[0,575,0,0,0,246,246,0,58,0,59,0,0,0,139,0,575,0,0],[0,575,0,607,0,246,246,0,58,0,59,0,0,0,139,0,575,0,0],[0,0,0,616,152,153,153,57,58,0,59,0,0,0,154,0,0,62,0],[0,0,0,0,265,141,141,57,58,0,0,0,0,612,265,0,0,0,0],[0,0,0,609,152,610,153,57,58,0,59,0,0,612,154,0,0,62,0],[0,0,0,609,152,153,153,57,58,0,59,0,0,0,154,0,0,62,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,549,0,0],[0,0,0,0,91,92,92,22,23,0,24,0,0,0,93,0,0,27,0],[0,0,0,0,112,113,113,32,33,0,34,0,0,0,114,0,0,37,0],[0,0,0,0,152,153,153,57,58,0,59,0,0,0,154,0,0,62,0]],"accepting":[false,true,true,true,true,true,false,false,true,true,true,true,true,true,true,true,true,true,true,true,false,true,true,true,true,true,true,true,true,true,false,true,true,true,true,true,true,true,true,true,true,true,false,true,false,true,true,false,false,true,true,true,true,true,true,false,false,true,true,true,true,true,true,true,true,true,true,false,true,true,false,true,true,true,false,true,true,true,false,true,false,true,true,false,false,true,true,true,true,true,true,true,false,true,true,false,true,true,true,false,true,false,true,true,false,false,true,true,true,true,true,true,true,false,true,true,true,false,true,true,true,false,true,false,true,true,false,false,false,true,true,false,false,true,true,true,true,true,true,false,true,false,true,true,false,false,true,true,true,true,true,true,true,false,true,true,false,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,true,true,true,false,true,false,true,true,false,false,false,true,true,false,false,true,true,true,false,true,true,true,true,true,true,false,true,true,true,false,true,false,true,true,false,false,false,true,true,false,false,true,true,true,false,true,true,true,true,true,false,true,true,true,true,true,false,true,true,false,false,false,false,true,true,false,false,true,true,true,false,true,true,true,false,true,false,true,true,false,false,false,true,true,false,false,true,true,true,false,true,true,true,true,false,true,false,true,true,true,true,true,true,true,true,true,false,true,true,true,true,true,false,true,true,false,false,false,false,true,true,false,false,true,true,true,false,true,true,true,true,true,false,true,true,false,false,false,false,true,true,false,false,true,true,true,true,false,true,true,true,true,true,true,false,true,true,false,false,false,false,true,false,true,false,true,true,true,true,true,false,true,true,false,false,false,false,true,true,false,false,true,true,true,false,true,true,false,false,true,false,true,true,false,true,true,false,true,true,false,true,true,true,true,true,true,false,true,true,false,false,false,false,true,false,true,true,false,true,true,true,true,true,true,false,true,true,false,false,false,false,true,false,true,false,true,true,true,true,false,false,false,true,true,false,true,true,true,true,true,true,false,true,true,false,false,false,false,true,false,true,false,true,true,false,false,true,true,false,false,true,true,true,false,true,false,true,true,true,true,false,false,false,true,false,true,true,true,true,false,false,false,true,true,false,true,true,true,true,true,true,false,true,true,false,true,false,true,true,true,true,false,false,false,false,false,false,false,true,true,false,false,true,true,false,true,true,true,true,false,true,true,true,true,true,true,false,true,true,false,true,true,false,true,true,true,true,true,true,false,true,true,false,true,false,true,true,true,true,true,true,false,true,true,true,true,true,true,false,true,true,false,false,false,false,false,true,true,false,true,false,true,true,true,true,true,false,true,true,true,true,true,false,true,true,true,true,true,false,true,true,true,false,true,true,true,true,false,false,false,true,false,true,true,true,true,true,false,true,true,true,false,true,true,true,true,true,false,true,true,true,true,false,true,true,true,true,true,false,true,true,false,true,true,true],"tags":[[],["broken_cluster"],["consonant_syllable"],["vowel_syllable"],["broken_cluster"],["broken_cluster"],[],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],["standalone_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["consonant_syllable"],["broken_cluster"],["symbol_cluster"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],[],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["standalone_cluster"],["standalone_cluster"],[],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["broken_cluster"],["broken_cluster"],["consonant_syllable","broken_cluster"],["broken_cluster"],[],["broken_cluster"],["symbol_cluster"],[],["symbol_cluster"],["symbol_cluster"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],[],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],[],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],[],[],[],["broken_cluster"],["broken_cluster"],[],[],["broken_cluster"],["broken_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],[],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["symbol_cluster"],["symbol_cluster"],["symbol_cluster"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],[],[],[],["consonant_syllable"],["consonant_syllable"],[],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],[],[],[],["vowel_syllable"],["vowel_syllable"],[],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],[],[],[],[],["broken_cluster"],["broken_cluster"],[],[],["broken_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],[],[],[],["standalone_cluster"],["standalone_cluster"],[],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],["broken_cluster"],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],["broken_cluster"],["symbol_cluster"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],[],[],[],[],["consonant_syllable"],["consonant_syllable"],[],[],["consonant_syllable"],["consonant_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],[],[],[],[],["vowel_syllable"],["vowel_syllable"],[],[],["vowel_syllable"],["vowel_syllable"],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],[],[],[],[],["broken_cluster"],[],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],[],[],[],[],["standalone_cluster"],["standalone_cluster"],[],[],["standalone_cluster"],["standalone_cluster"],["consonant_syllable","broken_cluster"],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],[],[],["consonant_syllable","broken_cluster"],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],[],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],[],[],[],[],["consonant_syllable"],[],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],[],[],[],[],["vowel_syllable"],[],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],[],[],[],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],[],[],[],[],["standalone_cluster"],[],["consonant_syllable","broken_cluster"],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],[],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],[],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],[],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],[],[],[],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],[],[],[],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],[],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],[],[],[],[],[],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],[],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],[],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],[],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],[],[],[],[],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],[],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],[],[],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["broken_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],[],["consonant_syllable"],["vowel_syllable"],["standalone_cluster"]]}');var Cn={};Cn=JSON.parse('{"categories":["O","IND","S","GB","B","FM","CGJ","VMAbv","VMPst","VAbv","VPst","CMBlw","VPre","VBlw","H","VMBlw","CMAbv","MBlw","CS","R","SUB","MPst","MPre","FAbv","FPst","FBlw","null","SMAbv","SMBlw","VMPre","ZWNJ","ZWJ","WJ","M","VS","N","HN","MAbv"],"decompositions":{"2507":[2503,2494],"2508":[2503,2519],"2888":[2887,2902],"2891":[2887,2878],"2892":[2887,2903],"3018":[3014,3006],"3019":[3015,3006],"3020":[3014,3031],"3144":[3142,3158],"3264":[3263,3285],"3271":[3270,3285],"3272":[3270,3286],"3274":[3270,3266],"3275":[3270,3266,3285],"3402":[3398,3390],"3403":[3399,3390],"3404":[3398,3415],"3546":[3545,3530],"3548":[3545,3535],"3549":[3545,3535,3530],"3550":[3545,3551],"3635":[3661,3634],"3763":[3789,3762],"3955":[3953,3954],"3957":[3953,3956],"3958":[4018,3968],"3959":[4018,3953,3968],"3960":[4019,3968],"3961":[4019,3953,3968],"3969":[3953,3968],"6971":[6970,6965],"6973":[6972,6965],"6976":[6974,6965],"6977":[6975,6965],"6979":[6978,6965],"69934":[69937,69927],"69935":[69938,69927],"70475":[70471,70462],"70476":[70471,70487],"70843":[70841,70842],"70844":[70841,70832],"70846":[70841,70845],"71098":[71096,71087],"71099":[71097,71087]},"stateTable":[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[2,2,3,4,4,5,0,6,7,8,9,10,11,12,13,14,15,16,0,17,18,11,19,20,21,22,0,0,0,23,0,0,2,0,0,24,0,25],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,26,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,27,28,0,0,0,0,0,27,0,0,0],[0,0,0,0,0,29,0,30,31,32,33,34,35,36,37,38,39,40,0,0,41,35,42,43,44,45,0,0,0,46,0,0,0,0,39,0,0,47],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,6,7,0,0,0,0,0,0,14,0,0,0,0,0,0,0,20,21,22,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,21,22,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,6,7,8,9,0,0,12,0,14,0,0,0,0,0,0,0,20,21,22,0,0,0,23,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,6,7,0,9,0,0,0,0,14,0,0,0,0,0,0,0,20,21,22,0,0,0,23,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,6,7,8,9,10,11,12,13,14,0,16,0,0,18,11,19,20,21,22,0,0,0,23,0,0,0,0,0,0,0,25],[0,0,0,0,0,5,0,6,7,8,9,0,11,12,0,14,0,0,0,0,0,0,0,20,21,22,0,0,0,23,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,6,7,0,9,0,0,12,0,14,0,0,0,0,0,0,0,20,21,22,0,0,0,23,0,0,0,0,0,0,0,0],[0,0,0,0,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,0,7,0,0,0,0,0,0,14,0,0,0,0,0,0,0,20,21,22,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,6,7,8,9,10,11,12,13,14,15,16,0,0,18,11,19,20,21,22,0,0,0,23,0,0,0,0,0,0,0,25],[0,0,0,0,0,5,0,6,7,8,9,0,11,12,0,14,0,0,0,0,0,11,0,20,21,22,0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[0,0,0,0,0,29,0,30,31,0,0,0,0,0,0,38,0,0,0,0,0,0,0,43,44,45,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,0,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,43,44,45,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,30,31,32,33,0,0,36,0,38,0,0,0,0,0,0,0,43,44,45,0,0,0,46,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,30,31,0,33,0,0,0,0,38,0,0,0,0,0,0,0,43,44,45,0,0,0,46,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,30,31,32,33,34,35,36,37,38,0,40,0,0,41,35,42,43,44,45,0,0,0,46,0,0,0,0,0,0,0,47],[0,0,0,0,0,29,0,30,31,32,33,0,35,36,0,38,0,0,0,0,0,0,0,43,44,45,0,0,0,46,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,30,31,0,33,0,0,36,0,38,0,0,0,0,0,0,0,43,44,45,0,0,0,46,0,0,0,0,0,0,0,0],[0,0,0,0,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,0,31,0,0,0,0,0,0,38,0,0,0,0,0,0,0,43,44,45,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,30,31,32,33,34,35,36,37,38,39,40,0,0,41,35,42,43,44,45,0,0,0,46,0,0,0,0,0,0,0,47],[0,0,0,0,0,29,0,30,31,32,33,0,35,36,0,38,0,0,0,0,0,35,0,43,44,45,0,0,0,46,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,30,31,32,33,52,35,36,37,38,52,40,0,0,41,35,42,43,44,45,0,0,0,46,0,0,0,0,53,0,0,47],[0,0,0,0,0,29,0,30,31,32,33,0,35,36,0,38,0,40,0,0,0,35,0,43,44,45,0,0,0,46,0,0,0,0,0,0,0,47],[0,0,0,0,0,29,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,43,44,45,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,44,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,44,45,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,30,31,0,0,0,0,0,0,38,0,0,0,0,0,0,0,43,44,45,0,0,0,46,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,30,31,32,33,0,35,36,0,38,0,40,0,0,0,35,0,43,44,45,0,0,0,46,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,6,7,8,9,48,11,12,13,14,0,16,0,0,18,11,19,20,21,22,0,0,0,23,0,0,0,0,0,0,0,25],[0,0,0,0,0,5,0,6,7,8,9,48,11,12,13,14,48,16,0,0,18,11,19,20,21,22,0,0,0,23,0,0,0,0,0,0,0,25],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,51,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,54,0,0],[0,0,0,0,0,29,0,30,31,32,33,52,35,36,37,38,0,40,0,0,41,35,42,43,44,45,0,0,0,46,0,0,0,0,0,0,0,47],[0,0,0,0,0,29,0,30,31,32,33,52,35,36,37,38,52,40,0,0,41,35,42,43,44,45,0,0,0,46,0,0,0,0,0,0,0,47],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,50,0,51,0]],"accepting":[false,true,true,true,true,true,true,true,true,true,true,true,true,false,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true],"tags":[[],["broken_cluster"],["independent_cluster"],["symbol_cluster"],["standard_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["numeral_cluster"],["broken_cluster"],["independent_cluster"],["symbol_cluster"],["symbol_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["virama_terminated_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["broken_cluster"],["broken_cluster"],["numeral_cluster"],["number_joiner_terminated_cluster"],["standard_cluster"],["standard_cluster"],["numeral_cluster"]]}');const Oe={X:1,C:2,V:4,N:8,H:16,ZWNJ:32,ZWJ:64,M:128,Placeholder:2048,Dotted_Circle:4096,RS:8192,Coeng:16384,Repha:32768,Ra:65536,CM:131072},ye={Start:1,Ra_To_Become_Reph:2,Pre_M:4,Pre_C:8,Base_C:16,After_Main:32,Before_Sub:128,Below_C:256,After_Sub:512,Before_Post:1024,Post_C:2048,After_Post:4096,Final_C:8192,SMVD:16384,End:32768},Fy=Oe.C|Oe.Ra|Oe.CM|Oe.V|Oe.Placeholder|Oe.Dotted_Circle,iu=Oe.ZWJ|Oe.ZWNJ,ds=Oe.H|Oe.Coeng,su={Default:{hasOldSpec:!1,virama:0,basePos:"Last",rephPos:ye.Before_Post,rephMode:"Implicit",blwfMode:"Pre_And_Post"},Devanagari:{hasOldSpec:!0,virama:2381,basePos:"Last",rephPos:ye.Before_Post,rephMode:"Implicit",blwfMode:"Pre_And_Post"},Bengali:{hasOldSpec:!0,virama:2509,basePos:"Last",rephPos:ye.After_Sub,rephMode:"Implicit",blwfMode:"Pre_And_Post"},Gurmukhi:{hasOldSpec:!0,virama:2637,basePos:"Last",rephPos:ye.Before_Sub,rephMode:"Implicit",blwfMode:"Pre_And_Post"},Gujarati:{hasOldSpec:!0,virama:2765,basePos:"Last",rephPos:ye.Before_Post,rephMode:"Implicit",blwfMode:"Pre_And_Post"},Oriya:{hasOldSpec:!0,virama:2893,basePos:"Last",rephPos:ye.After_Main,rephMode:"Implicit",blwfMode:"Pre_And_Post"},Tamil:{hasOldSpec:!0,virama:3021,basePos:"Last",rephPos:ye.After_Post,rephMode:"Implicit",blwfMode:"Pre_And_Post"},Telugu:{hasOldSpec:!0,virama:3149,basePos:"Last",rephPos:ye.After_Post,rephMode:"Explicit",blwfMode:"Post_Only"},Kannada:{hasOldSpec:!0,virama:3277,basePos:"Last",rephPos:ye.After_Post,rephMode:"Implicit",blwfMode:"Post_Only"},Malayalam:{hasOldSpec:!0,virama:3405,basePos:"Last",rephPos:ye.After_Main,rephMode:"Log_Repha",blwfMode:"Pre_And_Post"},Khmer:{hasOldSpec:!1,virama:6098,basePos:"First",rephPos:ye.Ra_To_Become_Reph,rephMode:"Vis_Repha",blwfMode:"Pre_And_Post"}},Ry={6078:[6081,6078],6079:[6081,6079],6080:[6081,6080],6084:[6081,6084],6085:[6081,6085]},{decompositions:My}=Js(Cn),nu=new qs(Za("AAARAAAAAABg2AAAAWYPmfDtnXuMXFUdx+/uzs7M7szudAtECGJRIMRQbUAithQWkGAKiVhNpFVRRAmIQVCDkDYICGotIA9BTCz8IeUviv7BQ2PBtBIRLBBQIWAUsKg1BKxRAqIgfs/cc+aeOXPej3tnZX7JJ/dxzj3nd36/8753Z5fUsuxgsAwcAU4Gp4BPgM+Cd4P3RjieDs4GXwLrHJ5bDy4DG8A14LvgZrAZbAF3gns0z18ALgY/B78C94NHwBPgabAE/AX8DbwM5sF/QX0yD5vFcU/wVnAgWAoOAyvAceBE8CGwBpwGzgJfAF8BXwXfAFeC68EmsBlsAXeCreA+8CB4DDwF/gh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cxPpnmRS/1mvmJjju3v7absI2xspQrvs1dNbjOj/wP7h1RlZyKGy8occ408UL8En4v6xfC/K3z52XzJd62T8vuZGGsxo/6O46ntmNqqFb/jps2/hHV4rPKH0svT4pstU7t2tZ9u/ZdqbJL1MwP6O86Fyt4jYaIrGz9mjEt8lFL4PtVE6votG2P6fpdf/GZRse7s3bf4BtSl/DIbKMctx++Z+8o6K6z9FPOwKsRmXiaNl7C+6NYRpjlbqG1j72f49qsuY4brd/amb4ZVc8TQ+sSH985LrEe8iPWJnfPrJRbWbb+dwn4x6o+r/aS2S7w3qWt//LnYz2ntE0vH1uDcyKatx1rH+EiMPEN1SZG/iz6+9o01Rob6O7Q+xLZ1jHobK61U+pWVvo2EpuWqzzD6Poa+pvhli0wn8Zq/72Mzm2d90o5VN1x9ZKuzbTgvqWwUIin8FSpl1CXXvFRxU0iozVPYJDRtF3uFphn6XAyJUUdD7SjTJ8v6n9fVbVObkKWp001lc9VRlqdOf5v0ZM+bymdbfp1NfG0bq27Y5JMyfxeJkU6o/inKH8O2Zfgidb6h/g3VJ7QcVbWL0Pxt6rlrPqa4KfQ25a2zl4/E8GdM/4fK/wA=")),Dy=new Nl(Js(ru));class rt extends Br{static planFeatures(e){e.addStage(By),e.addStage(["locl","ccmp"]),e.addStage(zy),e.addStage("nukt"),e.addStage("akhn"),e.addStage("rphf",!1),e.addStage("rkrf"),e.addStage("pref",!1),e.addStage("blwf",!1),e.addStage("abvf",!1),e.addStage("half",!1),e.addStage("pstf",!1),e.addStage("vatu"),e.addStage("cjct"),e.addStage("cfar",!1),e.addStage($y),e.addStage({local:["init"],global:["pres","abvs","blws","psts","haln","dist","abvm","blwm","calt","clig"]}),e.unicodeScript=Eg(e.script),e.indicConfig=su[e.unicodeScript]||su.Default,e.isOldSpec=e.indicConfig.hasOldSpec&&e.script[e.script.length-1]!=="2"}static assignFeatures(e,t){for(let r=t.length-1;r>=0;r--){let i=t[r].codePoints[0],n=Ry[i]||My[i];if(n){let a=n.map(o=>{let c=e.font.glyphForCodePoint(o);return new Lt(e.font,c.id,[o],t[r].features)});t.splice(r,1,...a)}}}}Ct(rt,"zeroMarkWidths","NONE");function so(s){return nu.get(s.codePoints[0])>>8}function au(s){return 1<<(nu.get(s.codePoints[0])&255)}class kn{constructor(e,t,r,i){this.category=e,this.position=t,this.syllableType=r,this.syllable=i}}function By(s,e){let t=0,r=0;for(let[i,n,a]of Dy.match(e.map(so))){if(i>r){++t;for(let o=r;o<i;o++)e[o].shaperInfo=new kn(Oe.X,ye.End,"non_indic_cluster",t)}++t;for(let o=i;o<=n;o++)e[o].shaperInfo=new kn(1<<so(e[o]),au(e[o]),a[0],t);r=n+1}if(r<e.length){++t;for(let i=r;i<e.length;i++)e[i].shaperInfo=new kn(Oe.X,ye.End,"non_indic_cluster",t)}}function ni(s){return s.shaperInfo.category&Fy}function Qt(s){return s.shaperInfo.category&iu}function mr(s){return s.shaperInfo.category&ds}function gr(s,e){for(let r of s)r.features={[e]:!0};return s[0]._font._layoutEngine.engine.GSUBProcessor.applyFeatures([e],s),s.length===1}function Ly(s,e,t){let r=[t,e,t];return gr(r.slice(0,2),"blwf")||gr(r.slice(1,3),"blwf")?ye.Below_C:gr(r.slice(0,2),"pstf")||gr(r.slice(1,3),"pstf")||gr(r.slice(0,2),"pref")||gr(r.slice(1,3),"pref")?ye.Post_C:ye.Base_C}function zy(s,e,t){let r=t.indicConfig,i=s._layoutEngine.engine.GSUBProcessor.features,n=s.glyphForCodePoint(9676).id,a=s.glyphForCodePoint(r.virama).id;if(a){let o=new Lt(s,a,[r.virama]);for(let c=0;c<e.length;c++)e[c].shaperInfo.position===ye.Base_C&&(e[c].shaperInfo.position=Ly(s,e[c].copy(),o))}for(let o=0,c=Sn(e,0);o<e.length;o=c,c=Sn(e,o)){let{category:u,syllableType:h}=e[o].shaperInfo;if(h==="symbol_cluster"||h==="non_indic_cluster")continue;if(h==="broken_cluster"&&n){let b=new Lt(s,n,[9676]);b.shaperInfo=new kn(1<<so(b),au(b),e[o].shaperInfo.syllableType,e[o].shaperInfo.syllable);let k=o;for(;k<c&&e[k].shaperInfo.category===Oe.Repha;)k++;e.splice(k++,0,b),c++}let l=c,d=o,f=!1;if(r.rephPos!==ye.Ra_To_Become_Reph&&i.rphf&&o+3<=c&&(r.rephMode==="Implicit"&&!Qt(e[o+2])||r.rephMode==="Explicit"&&e[o+2].shaperInfo.category===Oe.ZWJ)){let b=[e[o].copy(),e[o+1].copy(),e[o+2].copy()];if(gr(b.slice(0,2),"rphf")||r.rephMode==="Explicit"&&gr(b,"rphf")){for(d+=2;d<c&&Qt(e[d]);)d++;l=o,f=!0}}else if(r.rephMode==="Log_Repha"&&e[o].shaperInfo.category===Oe.Repha){for(d++;d<c&&Qt(e[d]);)d++;l=o,f=!0}switch(r.basePos){case"Last":{let b=c,k=!1;do{let x=e[--b].shaperInfo;if(ni(e[b])){if(x.position!==ye.Below_C&&(x.position!==ye.Post_C||k)){l=b;break}x.position===ye.Below_C&&(k=!0),l=b}else if(o<b&&x.category===Oe.ZWJ&&e[b-1].shaperInfo.category===Oe.H)break}while(b>d);break}case"First":l=o;for(let b=l+1;b<c;b++)ni(e[b])&&(e[b].shaperInfo.position=ye.Below_C)}f&&l===o&&d-l<=2&&(f=!1);for(let b=o;b<l;b++){let k=e[b].shaperInfo;k.position=Math.min(ye.Pre_C,k.position)}l<c&&(e[l].shaperInfo.position=ye.Base_C);for(let b=l+1;b<c;b++)if(e[b].shaperInfo.category===Oe.M){for(let k=b+1;k<c;k++)if(ni(e[k])){e[k].shaperInfo.position=ye.Final_C;break}break}if(f&&(e[o].shaperInfo.position=ye.Ra_To_Become_Reph),t.isOldSpec){let b=t.unicodeScript!=="Malayalam";for(let k=l+1;k<c;k++)if(e[k].shaperInfo.category===Oe.H){let x;for(x=c-1;x>k&&!(ni(e[x])||b&&e[x].shaperInfo.category===Oe.H);x--);if(e[x].shaperInfo.category!==Oe.H&&x>k){let E=e[k];e.splice(k,0,...e.splice(k+1,x-k)),e[x]=E}break}}let p=ye.Start;for(let b=o;b<c;b++){let k=e[b].shaperInfo;if(k.category&(iu|Oe.N|Oe.RS|Oe.CM|ds&k.category)){if(k.position=p,k.category===Oe.H&&k.position===ye.Pre_M){for(let x=b;x>o;x--)if(e[x-1].shaperInfo.position!==ye.Pre_M){k.position=e[x-1].shaperInfo.position;break}}}else k.position!==ye.SMVD&&(p=k.position)}let m=l;for(let b=l+1;b<c;b++)if(ni(e[b])){for(let k=m+1;k<b;k++)e[k].shaperInfo.position<ye.SMVD&&(e[k].shaperInfo.position=e[b].shaperInfo.position);m=b}else e[b].shaperInfo.category===Oe.M&&(m=b);let v=e.slice(o,c);v.sort((b,k)=>b.shaperInfo.position-k.shaperInfo.position),e.splice(o,v.length,...v);for(let b=o;b<c;b++)if(e[b].shaperInfo.position===ye.Base_C){l=b;break}for(let b=o;b<c&&e[b].shaperInfo.position===ye.Ra_To_Become_Reph;b++)e[b].features.rphf=!0;let g=!t.isOldSpec&&r.blwfMode==="Pre_And_Post";for(let b=o;b<l;b++)e[b].features.half=!0,g&&(e[b].features.blwf=!0);for(let b=l+1;b<c;b++)e[b].features.abvf=!0,e[b].features.pstf=!0,e[b].features.blwf=!0;if(t.isOldSpec&&t.unicodeScript==="Devanagari")for(let b=o;b+1<l;b++)e[b].shaperInfo.category===Oe.Ra&&e[b+1].shaperInfo.category===Oe.H&&(b+1===l||e[b+2].shaperInfo.category===Oe.ZWJ)&&(e[b].features.blwf=!0,e[b+1].features.blwf=!0);let y=2;if(i.pref&&l+y<c)for(let b=l+1;b+y-1<c;b++){let k=[e[b].copy(),e[b+1].copy()];if(gr(k,"pref")){for(let x=0;x<y;x++)e[b++].features.pref=!0;if(i.cfar)for(;b<c;b++)e[b].features.cfar=!0;break}}for(let b=o+1;b<c;b++)if(Qt(e[b])){let k=e[b].shaperInfo.category===Oe.ZWNJ,x=b;do x--,k&&delete e[x].features.half;while(x>o&&!ni(e[x]))}}}function $y(s,e,t){let r=t.indicConfig,i=s._layoutEngine.engine.GSUBProcessor.features;for(let n=0,a=Sn(e,0);n<e.length;n=a,a=Sn(e,n)){let o=!!i.pref,c=n;for(;c<a;c++)if(e[c].shaperInfo.position>=ye.Base_C){if(o&&c+1<a){for(let u=c+1;u<a;u++)if(e[u].features.pref){if(!(e[u].substituted&&e[u].isLigated&&!e[u].isMultiplied)){for(c=u;c<a&&mr(e[c]);)c++;e[c].shaperInfo.position=ye.BASE_C,o=!1}break}}if(t.unicodeScript==="Malayalam")for(let u=c+1;u<a;u++){for(;u<a&&Qt(e[u]);)u++;if(u===a||!mr(e[u]))break;for(u++;u<a&&Qt(e[u]);)u++;u<a&&ni(e[u])&&e[u].shaperInfo.position===ye.Below_C&&(c=u,e[c].shaperInfo.position=ye.Base_C)}n<c&&e[c].shaperInfo.position>ye.Base_C&&c--;break}if(c===a&&n<c&&e[c-1].shaperInfo.category===Oe.ZWJ&&c--,c<a)for(;n<c&&e[c].shaperInfo.category&(Oe.N|ds);)c--;if(n+1<a&&n<c){let u=c===a?c-2:c-1;if(t.unicodeScript!=="Malayalam"&&t.unicodeScript!=="Tamil"){for(;u>n&&!(e[u].shaperInfo.category&(Oe.M|ds));)u--;mr(e[u])&&e[u].shaperInfo.position!==ye.Pre_M?u+1<a&&Qt(e[u+1])&&u++:u=n}if(n<u&&e[u].shaperInfo.position!==ye.Pre_M){for(let h=u;h>n;h--)if(e[h-1].shaperInfo.position===ye.Pre_M){let l=h-1;l<c&&c<=u&&c--;let d=e[l];e.splice(l,0,...e.splice(l+1,u-l)),e[u]=d,u--}}}if(n+1<a&&e[n].shaperInfo.position===ye.Ra_To_Become_Reph&&e[n].shaperInfo.category===Oe.Repha!==(e[n].isLigated&&!e[n].isMultiplied)){let u,h=r.rephPos,l=!1;if(h!==ye.After_Post){for(u=n+1;u<c&&!mr(e[u]);)u++;if(u<c&&mr(e[u])&&(u+1<c&&Qt(e[u+1])&&u++,l=!0),!l&&h===ye.After_Main){for(u=c;u+1<a&&e[u+1].shaperInfo.position<=ye.After_Main;)u++;l=u<a}if(!l&&h===ye.After_Sub){for(u=c;u+1<a&&!(e[u+1].shaperInfo.position&(ye.Post_C|ye.After_Post|ye.SMVD));)u++;l=u<a}}if(!l){for(u=n+1;u<c&&!mr(e[u]);)u++;u<c&&mr(e[u])&&(u+1<c&&Qt(e[u+1])&&u++,l=!0)}if(!l){for(u=a-1;u>n&&e[u].shaperInfo.position===ye.SMVD;)u--;if(mr(e[u]))for(let f=c+1;f<u;f++)e[f].shaperInfo.category===Oe.M&&u--}let d=e[n];e.splice(n,0,...e.splice(n+1,u-n)),e[u]=d,n<c&&c<=u&&c--}if(o&&c+1<a){for(let u=c+1;u<a;u++)if(e[u].features.pref){if(e[u].isLigated&&!e[u].isMultiplied){let h=c;if(t.unicodeScript!=="Malayalam"&&t.unicodeScript!=="Tamil"){for(;h>n&&!(e[h-1].shaperInfo.category&(Oe.M|ds));)h--;if(h>n&&e[h-1].shaperInfo.category===Oe.M){let f=u;for(let p=c+1;p<f;p++)if(e[p].shaperInfo.category===Oe.M){h--;break}}}h>n&&mr(e[h-1])&&h<a&&Qt(e[h])&&h++;let l=u,d=e[l];e.splice(h+1,0,...e.splice(h,l-h)),e[h]=d,h<=c&&c<l&&c++}break}}e[n].shaperInfo.position===ye.Pre_M&&(!n||!/Cf|Mn/.test(Zs(e[n-1].codePoints[0])))&&(e[n].features.init=!0)}}function Sn(s,e){if(e>=s.length)return e;let t=s[e].shaperInfo.syllable;for(;++e<s.length&&s[e].shaperInfo.syllable===t;);return e}const{categories:Ny,decompositions:ou}=Js(Cn),Uy=new qs(Za("AAACAAAAAAAQugAAAQUO+vHtnHuMX0UVx2d3u/t7bXe7FlqgvB+mpQhFmhikMRAg0ZQmakMU+cPWBzZisEGNjUpoiIYCEgmGUGOEGqOVNPUZUGNA+QNIBU2KREEFFSMBUYRISMXE+B3vnPzOzp553tcWfif5ZO5jnufMzJ2ZO/eumlDqFLAWnAMuBBvBZnC5uXZeBe4WsA1sBzs8/naCXcL1G8GtYD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vvU1/M9jSnj+Nh6FPJbBld/w6XHXH5MZeXrOfS/65g9RTl1JCa8chzX2RZ9/3lXSh4/VqWfEBNq4b82Ytp6m+9Qqxir1jX+rfPdT1vvsWhM6bPbmON6E1LnPCZW7L0qqXswmtqf0MQelZj4myrzYtzvIYmURlvtqapyx+gzRfd0XPfahVSOquMoG+dibBdl46iyfdbV1qvUW9m8+KTudMvkzZe/pqTJ+pWTflX5zw1fVfox6ZTVc8hvHflOSb+OuG1JsZ0kufXAJf8D")),Hy=new Nl(Js(Cn));class Ae extends Br{static planFeatures(e){e.addStage(jy),e.addStage(["locl","ccmp","nukt","akhn"]),e.addStage(cu),e.addStage(["rphf"],!1),e.addStage(Wy),e.addStage(cu),e.addStage(["pref"]),e.addStage(Gy),e.addStage(["rkrf","abvf","blwf","half","pstf","vatu","cjct"]),e.addStage(qy),e.addStage(["abvs","blws","pres","psts","dist","abvm","blwm"])}static assignFeatures(e,t){for(let r=t.length-1;r>=0;r--){let i=t[r].codePoints[0];if(ou[i]){let n=ou[i].map(a=>{let o=e.font.glyphForCodePoint(a);return new Lt(e.font,o.id,[a],t[r].features)});t.splice(r,1,...n)}}}}Ct(Ae,"zeroMarkWidths","BEFORE_GPOS");function lu(s){return Uy.get(s.codePoints[0])}class Vy{constructor(e,t,r){this.category=e,this.syllableType=t,this.syllable=r}}function jy(s,e){let t=0;for(let[r,i,n]of Hy.match(e.map(lu))){++t;for(let o=r;o<=i;o++)e[o].shaperInfo=new Vy(Ny[lu(e[o])],n[0],t);let a=e[r].shaperInfo.category==="R"?1:Math.min(3,i-r);for(let o=r;o<r+a;o++)e[o].features.rphf=!0}}function cu(s,e){for(let t of e)t.substituted=!1}function Wy(s,e){for(let t of e)t.substituted&&t.features.rphf&&(t.shaperInfo.category="R")}function Gy(s,e){for(let t of e)t.substituted&&(t.shaperInfo.category="VPre")}function qy(s,e){let t=s.glyphForCodePoint(9676).id;for(let r=0,i=uu(e,0);r<e.length;r=i,i=uu(e,r)){let n,a,o=e[r].shaperInfo,c=o.syllableType;if(!(c!=="virama_terminated_cluster"&&c!=="standard_cluster"&&c!=="broken_cluster")){if(c==="broken_cluster"&&t){let u=new Lt(s,t,[9676]);for(u.shaperInfo=o,n=r;n<i&&e[n].shaperInfo.category==="R";n++);e.splice(++n,0,u),i++}if(o.category==="R"&&i-r>1){for(n=r+1;n<i;n++)if(o=e[n].shaperInfo,hu(o)||_n(e[n])){_n(e[n])&&n--,e.splice(r,0,...e.splice(r+1,n-r),e[n]);break}}for(n=r,a=i;n<i;n++)o=e[n].shaperInfo,hu(o)||_n(e[n])?a=_n(e[n])?n+1:n:(o.category==="VPre"||o.category==="VMPre")&&a<n&&e.splice(a,1,e[n],...e.splice(a,n-a))}}}function uu(s,e){if(e>=s.length)return e;let t=s[e].shaperInfo.syllable;for(;++e<s.length&&s[e].shaperInfo.syllable===t;);return e}function _n(s){return s.shaperInfo.category==="H"&&!s.isLigated}function hu(s){return s.category==="B"||s.category==="GB"}const Xy={arab:zr,mong:zr,syrc:zr,"nko ":zr,phag:zr,mand:zr,mani:zr,phlp:zr,hang:Yc,bng2:rt,beng:rt,dev2:rt,deva:rt,gjr2:rt,gujr:rt,guru:rt,gur2:rt,knda:rt,knd2:rt,mlm2:rt,mlym:rt,ory2:rt,orya:rt,taml:rt,tml2:rt,telu:rt,tel2:rt,khmr:rt,bali:Ae,batk:Ae,brah:Ae,bugi:Ae,buhd:Ae,cakm:Ae,cham:Ae,dupl:Ae,egyp:Ae,gran:Ae,hano:Ae,java:Ae,kthi:Ae,kali:Ae,khar:Ae,khoj:Ae,sind:Ae,lepc:Ae,limb:Ae,mahj:Ae,mtei:Ae,modi:Ae,hmng:Ae,rjng:Ae,saur:Ae,shrd:Ae,sidd:Ae,sinh:rt,sund:Ae,sylo:Ae,tglg:Ae,tagb:Ae,tale:Ae,lana:Ae,tavt:Ae,takr:Ae,tibt:Ae,tfng:Ae,tirh:Ae,latn:Br,DFLT:Br};function Zy(s){Array.isArray(s)||(s=[s]);for(let e of s){let t=Xy[e];if(t)return t}return Br}class Ky extends mn{applyLookup(e,t){switch(e){case 1:{let i=this.coverageIndex(t.coverage);if(i===-1)return!1;let n=this.glyphIterator.cur;switch(t.version){case 1:n.id=n.id+t.deltaGlyphID&65535;break;case 2:n.id=t.substitute.get(i);break}return!0}case 2:{let i=this.coverageIndex(t.coverage);if(i!==-1){let n=t.sequences.get(i);if(n.length===0)return this.glyphs.splice(this.glyphIterator.index,1),!0;this.glyphIterator.cur.id=n[0],this.glyphIterator.cur.ligatureComponent=0;let a=this.glyphIterator.cur.features,o=this.glyphIterator.cur,c=n.slice(1).map((u,h)=>{let l=new Lt(this.font,u,void 0,a);return l.shaperInfo=o.shaperInfo,l.isLigated=o.isLigated,l.ligatureComponent=h+1,l.substituted=!0,l.isMultiplied=!0,l});return this.glyphs.splice(this.glyphIterator.index+1,0,...c),!0}return!1}case 3:{let i=this.coverageIndex(t.coverage);if(i!==-1){let n=0;return this.glyphIterator.cur.id=t.alternateSet.get(i)[n],!0}return!1}case 4:{let i=this.coverageIndex(t.coverage);if(i===-1)return!1;for(let n of t.ligatureSets.get(i)){let a=this.sequenceMatchIndices(1,n.components);if(!a)continue;let o=this.glyphIterator.cur,c=o.codePoints.slice();for(let m of a)c.push(...this.glyphs[m].codePoints);let u=new Lt(this.font,n.glyph,c,o.features);u.shaperInfo=o.shaperInfo,u.isLigated=!0,u.substituted=!0;let h=o.isMark;for(let m=0;m<a.length&&h;m++)h=this.glyphs[a[m]].isMark;u.ligatureID=h?null:this.ligatureID++;let l=o.ligatureID,d=o.codePoints.length,f=d,p=this.glyphIterator.index+1;for(let m of a){if(h)p=m;else for(;p<m;){var r=f-d+Math.min(this.glyphs[p].ligatureComponent||1,d);this.glyphs[p].ligatureID=u.ligatureID,this.glyphs[p].ligatureComponent=r,p++}l=this.glyphs[p].ligatureID,d=this.glyphs[p].codePoints.length,f+=d,p++}if(l&&!h)for(let m=p;m<this.glyphs.length&&this.glyphs[m].ligatureID===l;m++){var r=f-d+Math.min(this.glyphs[m].ligatureComponent||1,d);this.glyphs[m].ligatureComponent=r}for(let m=a.length-1;m>=0;m--)this.glyphs.splice(a[m],1);return this.glyphs[this.glyphIterator.index]=u,!0}return!1}case 5:return this.applyContext(t);case 6:return this.applyChainingContext(t);case 7:return this.applyLookup(t.lookupType,t.extension);default:throw new Error(`GSUB lookupType ${e} is not supported`)}}}class Yy extends mn{applyPositionValue(e,t){let r=this.positions[this.glyphIterator.peekIndex(e)];t.xAdvance!=null&&(r.xAdvance+=t.xAdvance),t.yAdvance!=null&&(r.yAdvance+=t.yAdvance),t.xPlacement!=null&&(r.xOffset+=t.xPlacement),t.yPlacement!=null&&(r.yOffset+=t.yPlacement);let i=this.font._variationProcessor,n=this.font.GDEF&&this.font.GDEF.itemVariationStore;i&&n&&(t.xPlaDevice&&(r.xOffset+=i.getDelta(n,t.xPlaDevice.a,t.xPlaDevice.b)),t.yPlaDevice&&(r.yOffset+=i.getDelta(n,t.yPlaDevice.a,t.yPlaDevice.b)),t.xAdvDevice&&(r.xAdvance+=i.getDelta(n,t.xAdvDevice.a,t.xAdvDevice.b)),t.yAdvDevice&&(r.yAdvance+=i.getDelta(n,t.yAdvDevice.a,t.yAdvDevice.b)))}applyLookup(e,t){switch(e){case 1:{let i=this.coverageIndex(t.coverage);if(i===-1)return!1;switch(t.version){case 1:this.applyPositionValue(0,t.value);break;case 2:this.applyPositionValue(0,t.values.get(i));break}return!0}case 2:{let i=this.glyphIterator.peek();if(!i)return!1;let n=this.coverageIndex(t.coverage);if(n===-1)return!1;switch(t.version){case 1:let a=t.pairSets.get(n);for(let u of a)if(u.secondGlyph===i.id)return this.applyPositionValue(0,u.value1),this.applyPositionValue(1,u.value2),!0;return!1;case 2:let o=this.getClassID(this.glyphIterator.cur.id,t.classDef1),c=this.getClassID(i.id,t.classDef2);if(o===-1||c===-1)return!1;var r=t.classRecords.get(o).get(c);return this.applyPositionValue(0,r.value1),this.applyPositionValue(1,r.value2),!0}}case 3:{let i=this.glyphIterator.peekIndex(),n=this.glyphs[i];if(!n)return!1;let a=t.entryExitRecords[this.coverageIndex(t.coverage)];if(!a||!a.exitAnchor)return!1;let o=t.entryExitRecords[this.coverageIndex(t.coverage,n.id)];if(!o||!o.entryAnchor)return!1;let c=this.getAnchor(o.entryAnchor),u=this.getAnchor(a.exitAnchor),h=this.positions[this.glyphIterator.index],l=this.positions[i],d;switch(this.direction){case"ltr":h.xAdvance=u.x+h.xOffset,d=c.x+l.xOffset,l.xAdvance-=d,l.xOffset-=d;break;case"rtl":d=u.x+h.xOffset,h.xAdvance-=d,h.xOffset-=d,l.xAdvance=c.x+l.xOffset;break}return this.glyphIterator.flags.rightToLeft?(this.glyphIterator.cur.cursiveAttachment=i,h.yOffset=c.y-u.y):(n.cursiveAttachment=this.glyphIterator.index,h.yOffset=u.y-c.y),!0}case 4:{let i=this.coverageIndex(t.markCoverage);if(i===-1)return!1;let n=this.glyphIterator.index;for(;--n>=0&&(this.glyphs[n].isMark||this.glyphs[n].ligatureComponent>0););if(n<0)return!1;let a=this.coverageIndex(t.baseCoverage,this.glyphs[n].id);if(a===-1)return!1;let o=t.markArray[i],c=t.baseArray[a][o.class];return this.applyAnchor(o,c,n),!0}case 5:{let i=this.coverageIndex(t.markCoverage);if(i===-1)return!1;let n=this.glyphIterator.index;for(;--n>=0&&this.glyphs[n].isMark;);if(n<0)return!1;let a=this.coverageIndex(t.ligatureCoverage,this.glyphs[n].id);if(a===-1)return!1;let o=t.ligatureArray[a],c=this.glyphIterator.cur,u=this.glyphs[n],h=u.ligatureID&&u.ligatureID===c.ligatureID&&c.ligatureComponent>0?Math.min(c.ligatureComponent,u.codePoints.length)-1:u.codePoints.length-1,l=t.markArray[i],d=o[h][l.class];return this.applyAnchor(l,d,n),!0}case 6:{let i=this.coverageIndex(t.mark1Coverage);if(i===-1)return!1;let n=this.glyphIterator.peekIndex(-1),a=this.glyphs[n];if(!a||!a.isMark)return!1;let o=this.glyphIterator.cur,c=!1;if(o.ligatureID===a.ligatureID?o.ligatureID?o.ligatureComponent===a.ligatureComponent&&(c=!0):c=!0:(o.ligatureID&&!o.ligatureComponent||a.ligatureID&&!a.ligatureComponent)&&(c=!0),!c)return!1;let u=this.coverageIndex(t.mark2Coverage,a.id);if(u===-1)return!1;let h=t.mark1Array[i],l=t.mark2Array[u][h.class];return this.applyAnchor(h,l,n),!0}case 7:return this.applyContext(t);case 8:return this.applyChainingContext(t);case 9:return this.applyLookup(t.lookupType,t.extension);default:throw new Error(`Unsupported GPOS table: ${e}`)}}applyAnchor(e,t,r){let i=this.getAnchor(t),n=this.getAnchor(e.markAnchor);this.positions[r];let a=this.positions[this.glyphIterator.index];a.xOffset=i.x-n.x,a.yOffset=i.y-n.y,this.glyphIterator.cur.markAttachment=r}getAnchor(e){let t=e.xCoordinate,r=e.yCoordinate,i=this.font._variationProcessor,n=this.font.GDEF&&this.font.GDEF.itemVariationStore;return i&&n&&(e.xDeviceTable&&(t+=i.getDelta(n,e.xDeviceTable.a,e.xDeviceTable.b)),e.yDeviceTable&&(r+=i.getDelta(n,e.yDeviceTable.a,e.yDeviceTable.b))),{x:t,y:r}}applyFeatures(e,t,r){super.applyFeatures(e,t,r);for(var i=0;i<this.glyphs.length;i++)this.fixCursiveAttachment(i);this.fixMarkAttachment()}fixCursiveAttachment(e){let t=this.glyphs[e];if(t.cursiveAttachment!=null){let r=t.cursiveAttachment;t.cursiveAttachment=null,this.fixCursiveAttachment(r),this.positions[e].yOffset+=this.positions[r].yOffset}}fixMarkAttachment(){for(let e=0;e<this.glyphs.length;e++){let t=this.glyphs[e];if(t.markAttachment!=null){let r=t.markAttachment;if(this.positions[e].xOffset+=this.positions[r].xOffset,this.positions[e].yOffset+=this.positions[r].yOffset,this.direction==="ltr")for(let i=r;i<e;i++)this.positions[e].xOffset-=this.positions[i].xAdvance,this.positions[e].yOffset-=this.positions[i].yAdvance;else for(let i=r+1;i<e+1;i++)this.positions[e].xOffset+=this.positions[i].xAdvance,this.positions[e].yOffset+=this.positions[i].yAdvance}}}}class Jy{setup(e){this.glyphInfos=e.glyphs.map(r=>new Lt(this.font,r.id,[...r.codePoints]));let t=null;this.GPOSProcessor&&(t=this.GPOSProcessor.selectScript(e.script,e.language,e.direction)),this.GSUBProcessor&&(t=this.GSUBProcessor.selectScript(e.script,e.language,e.direction)),this.shaper=Zy(t),this.plan=new Jg(this.font,t,e.direction),this.shaper.plan(this.plan,this.glyphInfos,e.features);for(let r in this.plan.allFeatures)e.features[r]=!0}substitute(e){this.GSUBProcessor&&(this.plan.process(this.GSUBProcessor,this.glyphInfos),e.glyphs=this.glyphInfos.map(t=>this.font.getGlyph(t.id,t.codePoints)))}position(e){return this.shaper.zeroMarkWidths==="BEFORE_GPOS"&&this.zeroMarkAdvances(e.positions),this.GPOSProcessor&&this.plan.process(this.GPOSProcessor,this.glyphInfos,e.positions),this.shaper.zeroMarkWidths==="AFTER_GPOS"&&this.zeroMarkAdvances(e.positions),e.direction==="rtl"&&(e.glyphs.reverse(),e.positions.reverse()),this.GPOSProcessor&&this.GPOSProcessor.features}zeroMarkAdvances(e){for(let t=0;t<this.glyphInfos.length;t++)this.glyphInfos[t].isMark&&(e[t].xAdvance=0,e[t].yAdvance=0)}cleanup(){this.glyphInfos=null,this.plan=null,this.shaper=null}getAvailableFeatures(e,t){let r=[];return this.GSUBProcessor&&(this.GSUBProcessor.selectScript(e,t),r.push(...Object.keys(this.GSUBProcessor.features))),this.GPOSProcessor&&(this.GPOSProcessor.selectScript(e,t),r.push(...Object.keys(this.GPOSProcessor.features))),r}constructor(e){this.font=e,this.glyphInfos=null,this.plan=null,this.GSUBProcessor=null,this.GPOSProcessor=null,this.fallbackPosition=!0,e.GSUB&&(this.GSUBProcessor=new Ky(e,e.GSUB)),e.GPOS&&(this.GPOSProcessor=new Yy(e,e.GPOS))}}class Qy{layout(e,t,r,i,n){if(typeof t=="string"&&(n=i,i=r,r=t,t=[]),typeof e=="string"){r==null&&(r=Ag(e));var a=this.font.glyphsForString(e)}else{if(r==null){let u=[];for(let h of e)u.push(...h.codePoints);r=Ig(u)}var a=e}let o=new Og(a,t,r,i,n);return a.length===0?(o.positions=[],o):(this.engine&&this.engine.setup&&this.engine.setup(o),this.substitute(o),this.position(o),this.hideDefaultIgnorables(o.glyphs,o.positions),this.engine&&this.engine.cleanup&&this.engine.cleanup(),o)}substitute(e){this.engine&&this.engine.substitute&&this.engine.substitute(e)}position(e){e.positions=e.glyphs.map(r=>new Fg(r.advanceWidth));let t=null;this.engine&&this.engine.position&&(t=this.engine.position(e)),!t&&(!this.engine||this.engine.fallbackPosition)&&(this.unicodeLayoutEngine||(this.unicodeLayoutEngine=new Tg(this.font)),this.unicodeLayoutEngine.positionGlyphs(e.glyphs,e.positions)),(!t||!t.kern)&&e.features.kern!==!1&&this.font.kern&&(this.kernProcessor||(this.kernProcessor=new _g(this.font)),this.kernProcessor.process(e.glyphs,e.positions),e.features.kern=!0)}hideDefaultIgnorables(e,t){let r=this.font.glyphForCodePoint(32);for(let i=0;i<e.length;i++)this.isDefaultIgnorable(e[i].codePoints[0])&&(e[i]=r,t[i].xAdvance=0,t[i].yAdvance=0)}isDefaultIgnorable(e){let t=e>>16;if(t===0)switch(e>>8){case 0:return e===173;case 3:return e===847;case 6:return e===1564;case 23:return 6068<=e&&e<=6069;case 24:return 6155<=e&&e<=6158;case 32:return 8203<=e&&e<=8207||8234<=e&&e<=8238||8288<=e&&e<=8303;case 254:return 65024<=e&&e<=65039||e===65279;case 255:return 65520<=e&&e<=65528;default:return!1}else switch(t){case 1:return 113824<=e&&e<=113827||119155<=e&&e<=119162;case 14:return 917504<=e&&e<=921599;default:return!1}}getAvailableFeatures(e,t){let r=[];return this.engine&&r.push(...this.engine.getAvailableFeatures(e,t)),this.font.kern&&r.indexOf("kern")===-1&&r.push("kern"),r}stringsForGlyph(e){let t=new Set,r=this.font._cmapProcessor.codePointsForGlyph(e);for(let i of r)t.add(String.fromCodePoint(i));if(this.engine&&this.engine.stringsForGlyph)for(let i of this.engine.stringsForGlyph(e))t.add(i);return Array.from(t)}constructor(e){this.font=e,this.unicodeLayoutEngine=null,this.kernProcessor=null,this.font.morx?this.engine=new Yg(this.font):(this.font.GSUB||this.font.GPOS)&&(this.engine=new Jy(this.font))}}const eb={moveTo:"M",lineTo:"L",quadraticCurveTo:"Q",bezierCurveTo:"C",closePath:"Z"};class Oi{toFunction(){return e=>{this.commands.forEach(t=>e[t.command].apply(e,t.args))}}toSVG(){return this.commands.map(t=>{let r=t.args.map(i=>Math.round(i*100)/100);return`${eb[t.command]}${r.join(" ")}`}).join("")}get cbox(){if(!this._cbox){let e=new Dr;for(let t of this.commands)for(let r=0;r<t.args.length;r+=2)e.addPoint(t.args[r],t.args[r+1]);this._cbox=Object.freeze(e)}return this._cbox}get bbox(){if(this._bbox)return this._bbox;let e=new Dr,t=0,r=0,i=y=>Math.pow(1-y,3)*f[g]+3*Math.pow(1-y,2)*y*p[g]+3*(1-y)*Math.pow(y,2)*m[g]+Math.pow(y,3)*v[g];for(let y of this.commands)switch(y.command){case"moveTo":case"lineTo":let[b,k]=y.args;e.addPoint(b,k),t=b,r=k;break;case"quadraticCurveTo":case"bezierCurveTo":if(y.command==="quadraticCurveTo")var[n,a,l,d]=y.args,o=t+2/3*(n-t),c=r+2/3*(a-r),u=l+2/3*(n-l),h=d+2/3*(a-d);else var[o,c,u,h,l,d]=y.args;e.addPoint(l,d);for(var f=[t,r],p=[o,c],m=[u,h],v=[l,d],g=0;g<=1;g++){let x=6*f[g]-12*p[g]+6*m[g],E=-3*f[g]+9*p[g]-9*m[g]+3*v[g];if(y=3*p[g]-3*f[g],E===0){if(x===0)continue;let _=-y/x;0<_&&_<1&&(g===0?e.addPoint(i(_),e.maxY):g===1&&e.addPoint(e.maxX,i(_)));continue}let T=Math.pow(x,2)-4*y*E;if(T<0)continue;let w=(-x+Math.sqrt(T))/(2*E);0<w&&w<1&&(g===0?e.addPoint(i(w),e.maxY):g===1&&e.addPoint(e.maxX,i(w)));let S=(-x-Math.sqrt(T))/(2*E);0<S&&S<1&&(g===0?e.addPoint(i(S),e.maxY):g===1&&e.addPoint(e.maxX,i(S)))}t=l,r=d;break}return this._bbox=Object.freeze(e)}mapPoints(e){let t=new Oi;for(let r of this.commands){let i=[];for(let n=0;n<r.args.length;n+=2){let[a,o]=e(r.args[n],r.args[n+1]);i.push(a,o)}t[r.command](...i)}return t}transform(e,t,r,i,n,a){return this.mapPoints((o,c)=>{const u=e*o+r*c+n,h=t*o+i*c+a;return[u,h]})}translate(e,t){return this.transform(1,0,0,1,e,t)}rotate(e){let t=Math.cos(e),r=Math.sin(e);return this.transform(t,r,-r,t,0,0)}scale(e,t=e){return this.transform(e,0,0,t,0,0)}constructor(){this.commands=[],this._bbox=null,this._cbox=null}}for(let s of["moveTo","lineTo","quadraticCurveTo","bezierCurveTo","closePath"])Oi.prototype[s]=function(...e){return this._bbox=this._cbox=null,this.commands.push({command:s,args:e}),this};var fs=[".notdef",".null","nonmarkingreturn","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quotesingle","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","grave","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","Adieresis","Aring","Ccedilla","Eacute","Ntilde","Odieresis","Udieresis","aacute","agrave","acircumflex","adieresis","atilde","aring","ccedilla","eacute","egrave","ecircumflex","edieresis","iacute","igrave","icircumflex","idieresis","ntilde","oacute","ograve","ocircumflex","odieresis","otilde","uacute","ugrave","ucircumflex","udieresis","dagger","degree","cent","sterling","section","bullet","paragraph","germandbls","registered","copyright","trademark","acute","dieresis","notequal","AE","Oslash","infinity","plusminus","lessequal","greaterequal","yen","mu","partialdiff","summation","product","pi","integral","ordfeminine","ordmasculine","Omega","ae","oslash","questiondown","exclamdown","logicalnot","radical","florin","approxequal","Delta","guillemotleft","guillemotright","ellipsis","nonbreakingspace","Agrave","Atilde","Otilde","OE","oe","endash","emdash","quotedblleft","quotedblright","quoteleft","quoteright","divide","lozenge","ydieresis","Ydieresis","fraction","currency","guilsinglleft","guilsinglright","fi","fl","daggerdbl","periodcentered","quotesinglbase","quotedblbase","perthousand","Acircumflex","Ecircumflex","Aacute","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Oacute","Ocircumflex","apple","Ograve","Uacute","Ucircumflex","Ugrave","dotlessi","circumflex","tilde","macron","breve","dotaccent","ring","cedilla","hungarumlaut","ogonek","caron","Lslash","lslash","Scaron","scaron","Zcaron","zcaron","brokenbar","Eth","eth","Yacute","yacute","Thorn","thorn","minus","multiply","onesuperior","twosuperior","threesuperior","onehalf","onequarter","threequarters","franc","Gbreve","gbreve","Idotaccent","Scedilla","scedilla","Cacute","cacute","Ccaron","ccaron","dcroat"];class er{_getPath(){return new Oi}_getCBox(){return this.path.cbox}_getBBox(){return this.path.bbox}_getTableMetrics(e){if(this.id<e.metrics.length)return e.metrics.get(this.id);let t=e.metrics.get(e.metrics.length-1);return{advance:t?t.advance:0,bearing:e.bearings.get(this.id-e.metrics.length)||0}}_getMetrics(e){if(this._metrics)return this._metrics;let{advance:t,bearing:r}=this._getTableMetrics(this._font.hmtx);if(this._font.vmtx)var{advance:i,bearing:n}=this._getTableMetrics(this._font.vmtx);else{let a;if((typeof e>"u"||e===null)&&({cbox:e}=this),(a=this._font["OS/2"])&&a.version>0)var i=Math.abs(a.typoAscender-a.typoDescender),n=a.typoAscender-e.maxY;else{let{hhea:o}=this._font;var i=Math.abs(o.ascent-o.descent),n=o.ascent-e.maxY}}return this._font._variationProcessor&&this._font.HVAR&&(t+=this._font._variationProcessor.getAdvanceAdjustment(this.id,this._font.HVAR)),this._metrics={advanceWidth:t,advanceHeight:i,leftBearing:r,topBearing:n}}get cbox(){return this._getCBox()}get bbox(){return this._getBBox()}get path(){return this._getPath()}getScaledPath(e){let t=1/this._font.unitsPerEm*e;return this.path.scale(t)}get advanceWidth(){return this._getMetrics().advanceWidth}get advanceHeight(){return this._getMetrics().advanceHeight}get ligatureCaretPositions(){}_getName(){let{post:e}=this._font;if(!e)return null;switch(e.version){case 1:return fs[this.id];case 2:let t=e.glyphNameIndex[this.id];return t<fs.length?fs[t]:e.names[t-fs.length];case 2.5:return fs[this.id+e.offsets[this.id]];case 4:return String.fromCharCode(e.map[this.id])}}get name(){return this._getName()}render(e,t){e.save();let r=1/this._font.head.unitsPerEm*t;e.scale(r,r),this.path.toFunction()(e),e.fill(),e.restore()}constructor(e,t,r){this.id=e,this.codePoints=t,this._font=r,this.isMark=this.codePoints.length>0&&this.codePoints.every($l),this.isLigature=this.codePoints.length>1}}pt([mt],er.prototype,"cbox",null),pt([mt],er.prototype,"bbox",null),pt([mt],er.prototype,"path",null),pt([mt],er.prototype,"advanceWidth",null),pt([mt],er.prototype,"advanceHeight",null),pt([mt],er.prototype,"name",null);let du=new R({numberOfContours:V,xMin:V,yMin:V,xMax:V,yMax:V});const tb=1,rb=2,ib=4,sb=8,nb=16,ab=32,ob=1,lb=8,fu=32,cb=64,ub=128,hb=256;class zt{copy(){return new zt(this.onCurve,this.endContour,this.x,this.y)}constructor(e,t,r=0,i=0){this.onCurve=e,this.endContour=t,this.x=r,this.y=i}}class db{constructor(e,t,r){this.glyphID=e,this.dx=t,this.dy=r,this.pos=0,this.scaleX=this.scaleY=1,this.scale01=this.scale10=0}}class Tn extends er{_getCBox(e){if(this._font._variationProcessor&&!e)return this.path.cbox;let t=this._font._getTableStream("glyf");t.pos+=this._font.loca.offsets[this.id];let r=du.decode(t),i=new Dr(r.xMin,r.yMin,r.xMax,r.yMax);return Object.freeze(i)}_parseGlyphCoord(e,t,r,i){if(r){var n=e.readUInt8();i||(n=-n),n+=t}else if(i)var n=t;else var n=t+e.readInt16BE();return n}_decode(){let e=this._font.loca.offsets[this.id],t=this._font.loca.offsets[this.id+1];if(e===t)return null;let r=this._font._getTableStream("glyf");r.pos+=e;let i=r.pos,n=du.decode(r);return n.numberOfContours>0?this._decodeSimple(n,r):n.numberOfContours<0&&this._decodeComposite(n,r,i),n}_decodeSimple(e,t){e.points=[];let r=new I(C,e.numberOfContours).decode(t);e.instructions=new I(K,C).decode(t);let i=[],n=r[r.length-1]+1;for(;i.length<n;){var a=t.readUInt8();if(i.push(a),a&sb){let h=t.readUInt8();for(let l=0;l<h;l++)i.push(a)}}for(var o=0;o<i.length;o++){var a=i[o];let l=new zt(!!(a&tb),r.indexOf(o)>=0,0,0);e.points.push(l)}let c=0;for(var o=0;o<i.length;o++){var a=i[o];e.points[o].x=c=this._parseGlyphCoord(t,c,a&rb,a&nb)}let u=0;for(var o=0;o<i.length;o++){var a=i[o];e.points[o].y=u=this._parseGlyphCoord(t,u,a&ib,a&ab)}if(this._font._variationProcessor){let h=e.points.slice();h.push(...this._getPhantomPoints(e)),this._font._variationProcessor.transformPoints(this.id,h),e.phantomPoints=h.slice(-4)}}_decodeComposite(e,t,r=0){e.components=[];let i=!1,n=fu;for(;n&fu;){n=t.readUInt16BE();let u=t.pos-r,h=t.readUInt16BE();if(i||(i=(n&hb)!==0),n&ob)var a=t.readInt16BE(),o=t.readInt16BE();else var a=t.readInt8(),o=t.readInt8();var c=new db(h,a,o);c.pos=u,n&lb?c.scaleX=c.scaleY=(t.readUInt8()<<24|t.readUInt8()<<16)/1073741824:n&cb?(c.scaleX=(t.readUInt8()<<24|t.readUInt8()<<16)/1073741824,c.scaleY=(t.readUInt8()<<24|t.readUInt8()<<16)/1073741824):n&ub&&(c.scaleX=(t.readUInt8()<<24|t.readUInt8()<<16)/1073741824,c.scale01=(t.readUInt8()<<24|t.readUInt8()<<16)/1073741824,c.scale10=(t.readUInt8()<<24|t.readUInt8()<<16)/1073741824,c.scaleY=(t.readUInt8()<<24|t.readUInt8()<<16)/1073741824),e.components.push(c)}if(this._font._variationProcessor){let u=[];for(let h=0;h<e.components.length;h++){var c=e.components[h];u.push(new zt(!0,!0,c.dx,c.dy))}u.push(...this._getPhantomPoints(e)),this._font._variationProcessor.transformPoints(this.id,u),e.phantomPoints=u.splice(-4,4);for(let h=0;h<u.length;h++){let l=u[h];e.components[h].dx=l.x,e.components[h].dy=l.y}}return i}_getPhantomPoints(e){let t=this._getCBox(!0);this._metrics==null&&(this._metrics=er.prototype._getMetrics.call(this,t));let{advanceWidth:r,advanceHeight:i,leftBearing:n,topBearing:a}=this._metrics;return[new zt(!1,!0,e.xMin-n,0),new zt(!1,!0,e.xMin-n+r,0),new zt(!1,!0,0,e.yMax+a),new zt(!1,!0,0,e.yMax+a+i)]}_getContours(){let e=this._decode();if(!e)return[];let t=[];if(e.numberOfContours<0)for(let a of e.components){let o=this._font.getGlyph(a.glyphID)._getContours();for(let c=0;c<o.length;c++){let u=o[c];for(let h=0;h<u.length;h++){let l=u[h],d=l.x*a.scaleX+l.y*a.scale01+a.dx,f=l.y*a.scaleY+l.x*a.scale10+a.dy;t.push(new zt(l.onCurve,l.endContour,d,f))}}}else t=e.points||[];e.phantomPoints&&!this._font.directory.tables.HVAR&&(this._metrics.advanceWidth=e.phantomPoints[1].x-e.phantomPoints[0].x,this._metrics.advanceHeight=e.phantomPoints[3].y-e.phantomPoints[2].y,this._metrics.leftBearing=e.xMin-e.phantomPoints[0].x,this._metrics.topBearing=e.phantomPoints[2].y-e.yMax);let r=[],i=[];for(let a=0;a<t.length;a++){var n=t[a];i.push(n),n.endContour&&(r.push(i),i=[])}return r}_getMetrics(){if(this._metrics)return this._metrics;let e=this._getCBox(!0);return super._getMetrics(e),this._font._variationProcessor&&!this._font.HVAR&&this.path,this._metrics}_getPath(){let e=this._getContours(),t=new Oi;for(let i=0;i<e.length;i++){let n=e[i],a=n[0],o=n[n.length-1],c=0;if(a.onCurve){var r=null;c=1}else{o.onCurve?a=o:a=new zt(!1,!1,(a.x+o.x)/2,(a.y+o.y)/2);var r=a}t.moveTo(a.x,a.y);for(let u=c;u<n.length;u++){let h=n[u],l=u===0?a:n[u-1];if(l.onCurve&&h.onCurve)t.lineTo(h.x,h.y);else if(l.onCurve&&!h.onCurve)var r=h;else if(!l.onCurve&&!h.onCurve){let f=(l.x+h.x)/2,p=(l.y+h.y)/2;t.quadraticCurveTo(l.x,l.y,f,p);var r=h}else if(!l.onCurve&&h.onCurve){t.quadraticCurveTo(r.x,r.y,h.x,h.y);var r=null}else throw new Error("Unknown TTF path state")}r&&t.quadraticCurveTo(r.x,r.y,a.x,a.y),t.closePath()}return t}constructor(...e){super(...e),Ct(this,"type","TTF")}}class fb extends er{_getName(){return this._font.CFF2?super._getName():this._font["CFF "].getGlyphName(this.id)}bias(e){return e.length<1240?107:e.length<33900?1131:32768}_getPath(){let e=this._font.CFF2||this._font["CFF "],{stream:t}=e,r=e.topDict.CharStrings[this.id],i=r.offset+r.length;t.pos=r.offset;let n=new Oi,a=[],o=[],c=null,u=0,h=0,l=0,d,f,p=!1;this._usedGsubrs=d={},this._usedSubrs=f={};let m=e.globalSubrIndex||[],v=this.bias(m),g=e.privateDictForGlyph(this.id)||{},y=g.Subrs||[],b=this.bias(y),k=e.topDict.vstore&&e.topDict.vstore.itemVariationStore,x=g.vsindex,E=this._font._variationProcessor;function T(){c==null&&(c=a.shift()+g.nominalWidthX)}function w(){return a.length%2!==0&&T(),u+=a.length>>1,a.length=0}function S(A,M){p&&n.closePath(),n.moveTo(A,M),p=!0}let _=function(){for(;t.pos<i;){let D=t.readUInt8();if(D<32){let W,G,ue,re,$,H,z,te,he,Se,Fe,Re,Me,Ke,j,N;switch(D){case 1:case 3:case 18:case 23:w();break;case 4:a.length>1&&T(),l+=a.shift(),S(h,l);break;case 5:for(;a.length>=2;)h+=a.shift(),l+=a.shift(),n.lineTo(h,l);break;case 6:case 7:for(ue=D===6;a.length>=1;)ue?h+=a.shift():l+=a.shift(),n.lineTo(h,l),ue=!ue;break;case 8:for(;a.length>0;)re=h+a.shift(),$=l+a.shift(),H=re+a.shift(),z=$+a.shift(),h=H+a.shift(),l=z+a.shift(),n.bezierCurveTo(re,$,H,z,h,l);break;case 10:if(W=a.pop()+b,G=y[W],G){f[W]=!0;let L=t.pos,B=i;t.pos=G.offset,i=G.offset+G.length,_(),t.pos=L,i=B}break;case 11:if(e.version>=2)break;return;case 14:if(e.version>=2)break;a.length>0&&T(),p&&(n.closePath(),p=!1);break;case 15:if(e.version<2)throw new Error("vsindex operator not supported in CFF v1");x=a.pop();break;case 16:{if(e.version<2)throw new Error("blend operator not supported in CFF v1");if(!E)throw new Error("blend operator in non-variation font");let L=E.getBlendVector(k,x),B=a.pop(),ie=B*L.length,fe=a.length-ie,ae=fe-B;for(let de=0;de<B;de++){let ke=a[ae+de];for(let le=0;le<L.length;le++)ke+=L[le]*a[fe++];a[ae+de]=ke}for(;ie--;)a.pop();break}case 19:case 20:w(),t.pos+=u+7>>3;break;case 21:a.length>2&&T(),h+=a.shift(),l+=a.shift(),S(h,l);break;case 22:a.length>1&&T(),h+=a.shift(),S(h,l);break;case 24:for(;a.length>=8;)re=h+a.shift(),$=l+a.shift(),H=re+a.shift(),z=$+a.shift(),h=H+a.shift(),l=z+a.shift(),n.bezierCurveTo(re,$,H,z,h,l);h+=a.shift(),l+=a.shift(),n.lineTo(h,l);break;case 25:for(;a.length>=8;)h+=a.shift(),l+=a.shift(),n.lineTo(h,l);re=h+a.shift(),$=l+a.shift(),H=re+a.shift(),z=$+a.shift(),h=H+a.shift(),l=z+a.shift(),n.bezierCurveTo(re,$,H,z,h,l);break;case 26:for(a.length%2&&(h+=a.shift());a.length>=4;)re=h,$=l+a.shift(),H=re+a.shift(),z=$+a.shift(),h=H,l=z+a.shift(),n.bezierCurveTo(re,$,H,z,h,l);break;case 27:for(a.length%2&&(l+=a.shift());a.length>=4;)re=h+a.shift(),$=l,H=re+a.shift(),z=$+a.shift(),h=H+a.shift(),l=z,n.bezierCurveTo(re,$,H,z,h,l);break;case 28:a.push(t.readInt16BE());break;case 29:if(W=a.pop()+v,G=m[W],G){d[W]=!0;let L=t.pos,B=i;t.pos=G.offset,i=G.offset+G.length,_(),t.pos=L,i=B}break;case 30:case 31:for(ue=D===31;a.length>=4;)ue?(re=h+a.shift(),$=l,H=re+a.shift(),z=$+a.shift(),l=z+a.shift(),h=H+(a.length===1?a.shift():0)):(re=h,$=l+a.shift(),H=re+a.shift(),z=$+a.shift(),h=H+a.shift(),l=z+(a.length===1?a.shift():0)),n.bezierCurveTo(re,$,H,z,h,l),ue=!ue;break;case 12:switch(D=t.readUInt8(),D){case 3:let L=a.pop(),B=a.pop();a.push(L&&B?1:0);break;case 4:L=a.pop(),B=a.pop(),a.push(L||B?1:0);break;case 5:L=a.pop(),a.push(L?0:1);break;case 9:L=a.pop(),a.push(Math.abs(L));break;case 10:L=a.pop(),B=a.pop(),a.push(L+B);break;case 11:L=a.pop(),B=a.pop(),a.push(L-B);break;case 12:L=a.pop(),B=a.pop(),a.push(L/B);break;case 14:L=a.pop(),a.push(-L);break;case 15:L=a.pop(),B=a.pop(),a.push(L===B?1:0);break;case 18:a.pop();break;case 20:let ie=a.pop(),fe=a.pop();o[fe]=ie;break;case 21:fe=a.pop(),a.push(o[fe]||0);break;case 22:let ae=a.pop(),de=a.pop(),ke=a.pop(),le=a.pop();a.push(ke<=le?ae:de);break;case 23:a.push(Math.random());break;case 24:L=a.pop(),B=a.pop(),a.push(L*B);break;case 26:L=a.pop(),a.push(Math.sqrt(L));break;case 27:L=a.pop(),a.push(L,L);break;case 28:L=a.pop(),B=a.pop(),a.push(B,L);break;case 29:fe=a.pop(),fe<0?fe=0:fe>a.length-1&&(fe=a.length-1),a.push(a[fe]);break;case 30:let J=a.pop(),Te=a.pop();if(Te>=0)for(;Te>0;){var A=a[J-1];for(let Xe=J-2;Xe>=0;Xe--)a[Xe+1]=a[Xe];a[0]=A,Te--}else for(;Te<0;){var A=a[0];for(let it=0;it<=J;it++)a[it]=a[it+1];a[J-1]=A,Te++}break;case 34:re=h+a.shift(),$=l,H=re+a.shift(),z=$+a.shift(),te=H+a.shift(),he=z,Se=te+a.shift(),Fe=he,Re=Se+a.shift(),Me=Fe,Ke=Re+a.shift(),j=Me,h=Ke,l=j,n.bezierCurveTo(re,$,H,z,te,he),n.bezierCurveTo(Se,Fe,Re,Me,Ke,j);break;case 35:N=[];for(let Xe=0;Xe<=5;Xe++)h+=a.shift(),l+=a.shift(),N.push(h,l);n.bezierCurveTo(...N.slice(0,6)),n.bezierCurveTo(...N.slice(6)),a.shift();break;case 36:re=h+a.shift(),$=l+a.shift(),H=re+a.shift(),z=$+a.shift(),te=H+a.shift(),he=z,Se=te+a.shift(),Fe=he,Re=Se+a.shift(),Me=Fe+a.shift(),Ke=Re+a.shift(),j=Me,h=Ke,l=j,n.bezierCurveTo(re,$,H,z,te,he),n.bezierCurveTo(Se,Fe,Re,Me,Ke,j);break;case 37:let Je=h,dt=l;N=[];for(let Xe=0;Xe<=4;Xe++)h+=a.shift(),l+=a.shift(),N.push(h,l);Math.abs(h-Je)>Math.abs(l-dt)?(h+=a.shift(),l=dt):(h=Je,l+=a.shift()),N.push(h,l),n.bezierCurveTo(...N.slice(0,6)),n.bezierCurveTo(...N.slice(6));break;default:throw new Error(`Unknown op: 12 ${D}`)}break;default:throw new Error(`Unknown op: ${D}`)}}else if(D<247)a.push(D-139);else if(D<251){var M=t.readUInt8();a.push((D-247)*256+M+108)}else if(D<255){var M=t.readUInt8();a.push(-(D-251)*256-M-108)}else a.push(t.readInt32BE()/65536)}};return _(),p&&n.closePath(),n}constructor(...e){super(...e),Ct(this,"type","CFF")}}let pb=new R({originX:C,originY:C,type:new He(4),data:new qt(s=>s.parent.buflen-s._currentOffset)});class mb extends Tn{getImageForSize(e){for(let a=0;a<this._font.sbix.imageTables.length;a++){var t=this._font.sbix.imageTables[a];if(t.ppem>=e)break}let r=t.imageOffsets,i=r[this.id],n=r[this.id+1];return i===n?null:(this._font.stream.pos=i,pb.decode(this._font.stream,{buflen:n-i}))}render(e,t){let r=this.getImageForSize(t);if(r!=null){let i=t/this._font.unitsPerEm;e.image(r.data,{height:t,x:r.originX,y:(this.bbox.minY-r.originY)*i})}this._font.sbix.flags.renderOutlines&&super.render(e,t)}constructor(...e){super(...e),Ct(this,"type","SBIX")}}class pu{constructor(e,t){this.glyph=e,this.color=t}}class gb extends er{_getBBox(){let e=new Dr;for(let t=0;t<this.layers.length;t++){let i=this.layers[t].glyph.bbox;e.addPoint(i.minX,i.minY),e.addPoint(i.maxX,i.maxY)}return e}get layers(){let e=this._font.CPAL,t=this._font.COLR,r=0,i=t.baseGlyphRecord.length-1;for(;r<=i;){let h=r+i>>1;var n=t.baseGlyphRecord[h];if(this.id<n.gid)i=h-1;else if(this.id>n.gid)r=h+1;else{var a=n;break}}if(a==null){var o=this._font._getBaseGlyph(this.id),c={red:0,green:0,blue:0,alpha:255};return[new pu(o,c)]}let u=[];for(let h=a.firstLayerIndex;h<a.firstLayerIndex+a.numLayers;h++){var n=t.layerRecords[h],c=e.colorRecords[n.paletteIndex],o=this._font._getBaseGlyph(n.gid);u.push(new pu(o,c))}return u}render(e,t){for(let{glyph:r,color:i}of this.layers)e.fillColor([i.red,i.green,i.blue],i.alpha/255*100),r.render(e,t)}constructor(...e){super(...e),Ct(this,"type","COLR")}}const yb=32768,bb=4095,vb=32768,mu=16384,wb=8192,gu=4095,yu=128,bu=127,xb=128,Cb=64,kb=63;class Sb{normalizeCoords(e){let t=[];for(var r=0;r<this.font.fvar.axis.length;r++){let i=this.font.fvar.axis[r];e[r]<i.defaultValue?t.push((e[r]-i.defaultValue+Number.EPSILON)/(i.defaultValue-i.minValue+Number.EPSILON)):t.push((e[r]-i.defaultValue+Number.EPSILON)/(i.maxValue-i.defaultValue+Number.EPSILON))}if(this.font.avar)for(var r=0;r<this.font.avar.segment.length;r++){let n=this.font.avar.segment[r];for(let a=0;a<n.correspondence.length;a++){let o=n.correspondence[a];if(a>=1&&t[r]<o.fromCoord){let c=n.correspondence[a-1];t[r]=((t[r]-c.fromCoord)*(o.toCoord-c.toCoord)+Number.EPSILON)/(o.fromCoord-c.fromCoord+Number.EPSILON)+c.toCoord;break}}}return t}transformPoints(e,t){if(!this.font.fvar||!this.font.gvar)return;let{gvar:r}=this.font;if(e>=r.glyphCount)return;let i=r.offsets[e];if(i===r.offsets[e+1])return;let{stream:n}=this.font;if(n.pos=i,n.pos>=n.length)return;let a=n.readUInt16BE(),o=i+n.readUInt16BE();if(a&yb){var c=n.pos;n.pos=o;var u=this.decodePoints();o=n.pos,n.pos=c}let h=t.map(v=>v.copy());a&=bb;for(let v=0;v<a;v++){let g=n.readUInt16BE(),y=n.readUInt16BE();if(y&vb){var l=[];for(let w=0;w<r.axisCount;w++)l.push(n.readInt16BE()/16384)}else{if((y&gu)>=r.globalCoordCount)throw new Error("Invalid gvar table");var l=r.globalCoords[y&gu]}if(y&mu){var d=[];for(let w=0;w<r.axisCount;w++)d.push(n.readInt16BE()/16384);var f=[];for(let w=0;w<r.axisCount;w++)f.push(n.readInt16BE()/16384)}let b=this.tupleFactor(y,l,d,f);if(b===0){o+=g;continue}var c=n.pos;if(n.pos=o,y&wb)var p=this.decodePoints();else var p=u;let x=p.length===0?t.length:p.length,E=this.decodeDeltas(x),T=this.decodeDeltas(x);if(p.length===0)for(let w=0;w<t.length;w++){var m=t[w];m.x+=Math.round(E[w]*b),m.y+=Math.round(T[w]*b)}else{let w=h.map(_=>_.copy()),S=t.map(()=>!1);for(let _=0;_<p.length;_++){let A=p[_];if(A<t.length){let M=w[A];S[A]=!0,M.x+=E[_]*b,M.y+=T[_]*b}}this.interpolateMissingDeltas(w,h,S);for(let _=0;_<t.length;_++){let A=w[_].x-h[_].x,M=w[_].y-h[_].y;t[_].x=Math.round(t[_].x+A),t[_].y=Math.round(t[_].y+M)}}o+=g,n.pos=c}}decodePoints(){let e=this.font.stream,t=e.readUInt8();t&yu&&(t=(t&bu)<<8|e.readUInt8());let r=new Uint16Array(t),i=0,n=0;for(;i<t;){let a=e.readUInt8(),o=(a&bu)+1,c=a&yu?e.readUInt16:e.readUInt8;for(let u=0;u<o&&i<t;u++)n+=c.call(e),r[i++]=n}return r}decodeDeltas(e){let t=this.font.stream,r=0,i=new Int16Array(e);for(;r<e;){let n=t.readUInt8(),a=(n&kb)+1;if(n&xb)r+=a;else{let o=n&Cb?t.readInt16BE:t.readInt8;for(let c=0;c<a&&r<e;c++)i[r++]=o.call(t)}}return i}tupleFactor(e,t,r,i){let n=this.normalizedCoords,{gvar:a}=this.font,o=1;for(let c=0;c<a.axisCount;c++)if(t[c]!==0){if(n[c]===0)return 0;if(e&mu){if(n[c]<r[c]||n[c]>i[c])return 0;n[c]<t[c]?o=o*(n[c]-r[c]+Number.EPSILON)/(t[c]-r[c]+Number.EPSILON):o=o*(i[c]-n[c]+Number.EPSILON)/(i[c]-t[c]+Number.EPSILON)}else{if(n[c]<Math.min(0,t[c])||n[c]>Math.max(0,t[c]))return 0;o=(o*n[c]+Number.EPSILON)/(t[c]+Number.EPSILON)}}return o}interpolateMissingDeltas(e,t,r){if(e.length===0)return;let i=0;for(;i<e.length;){let n=i,a=i,o=e[a];for(;!o.endContour;)o=e[++a];for(;i<=a&&!r[i];)i++;if(i>a)continue;let c=i,u=i;for(i++;i<=a;)r[i]&&(this.deltaInterpolate(u+1,i-1,u,i,t,e),u=i),i++;u===c?this.deltaShift(n,a,u,t,e):(this.deltaInterpolate(u+1,a,u,c,t,e),c>0&&this.deltaInterpolate(n,c-1,u,c,t,e)),i=a+1}}deltaInterpolate(e,t,r,i,n,a){if(e>t)return;let o=["x","y"];for(let u=0;u<o.length;u++){let h=o[u];if(n[r][h]>n[i][h]){var c=r;r=i,i=c}let l=n[r][h],d=n[i][h],f=a[r][h],p=a[i][h];if(l!==d||f===p){let m=l===d?0:(p-f)/(d-l);for(let v=e;v<=t;v++){let g=n[v][h];g<=l?g+=f-l:g>=d?g+=p-d:g=f+(g-l)*m,a[v][h]=g}}}}deltaShift(e,t,r,i,n){let a=n[r].x-i[r].x,o=n[r].y-i[r].y;if(!(a===0&&o===0))for(let c=e;c<=t;c++)c!==r&&(n[c].x+=a,n[c].y+=o)}getAdvanceAdjustment(e,t){let r,i;if(t.advanceWidthMapping){let n=e;n>=t.advanceWidthMapping.mapCount&&(n=t.advanceWidthMapping.mapCount-1),t.advanceWidthMapping.entryFormat,{outerIndex:r,innerIndex:i}=t.advanceWidthMapping.mapData[n]}else r=0,i=e;return this.getDelta(t.itemVariationStore,r,i)}getDelta(e,t,r){if(t>=e.itemVariationData.length)return 0;let i=e.itemVariationData[t];if(r>=i.deltaSets.length)return 0;let n=i.deltaSets[r],a=this.getBlendVector(e,t),o=0;for(let c=0;c<i.regionIndexCount;c++)o+=n.deltas[c]*a[c];return o}getBlendVector(e,t){let r=e.itemVariationData[t];if(this.blendVectors.has(r))return this.blendVectors.get(r);let i=this.normalizedCoords,n=[];for(let a=0;a<r.regionIndexCount;a++){let o=1,c=r.regionIndexes[a],u=e.variationRegionList.variationRegions[c];for(let h=0;h<u.length;h++){let l=u[h],d;l.startCoord>l.peakCoord||l.peakCoord>l.endCoord||l.startCoord<0&&l.endCoord>0&&l.peakCoord!==0||l.peakCoord===0?d=1:i[h]<l.startCoord||i[h]>l.endCoord?d=0:i[h]===l.peakCoord?d=1:i[h]<l.peakCoord?d=(i[h]-l.startCoord+Number.EPSILON)/(l.peakCoord-l.startCoord+Number.EPSILON):d=(l.endCoord-i[h]+Number.EPSILON)/(l.endCoord-l.peakCoord+Number.EPSILON),o*=d}n[a]=o}return this.blendVectors.set(r,n),n}constructor(e,t){this.font=e,this.normalizedCoords=this.normalizeCoords(t),this.blendVectors=new Map}}Promise.resolve();class vu{includeGlyph(e){return typeof e=="object"&&(e=e.id),this.mapping[e]==null&&(this.glyphs.push(e),this.mapping[e]=this.glyphs.length-1),this.mapping[e]}constructor(e){this.font=e,this.glyphs=[],this.mapping={},this.includeGlyph(0)}}const _b=1,Tb=2,Eb=4,Ab=8,Ib=16,Pb=32;class wu{static size(e){return e>=0&&e<=255?1:2}static encode(e,t){t>=0&&t<=255?e.writeUInt8(t):e.writeInt16BE(t)}}let xu=new R({numberOfContours:V,xMin:V,yMin:V,xMax:V,yMax:V,endPtsOfContours:new I(C,"numberOfContours"),instructions:new I(K,C),flags:new I(K,0),xPoints:new I(wu,0),yPoints:new I(wu,0)});class Ob{encodeSimple(e,t=[]){let r=[],i=[],n=[],a=[],o=0,c=0,u=0,h=0,l=0;for(let g=0;g<e.commands.length;g++){let y=e.commands[g];for(let b=0;b<y.args.length;b+=2){let k=y.args[b],x=y.args[b+1],E=0;if(y.command==="quadraticCurveTo"&&b===2){let T=e.commands[g+1];if(T&&T.command==="quadraticCurveTo"){let w=(c+T.args[0])/2,S=(u+T.args[1])/2;if(k===w&&x===S)continue}}y.command==="quadraticCurveTo"&&b===0||(E|=_b),E=this._encodePoint(k,c,i,E,Tb,Ib),E=this._encodePoint(x,u,n,E,Eb,Pb),E===h&&o<255?(a[a.length-1]|=Ab,o++):(o>0&&(a.push(o),o=0),a.push(E),h=E),c=k,u=x,l++}y.command==="closePath"&&r.push(l-1)}e.commands.length>1&&e.commands[e.commands.length-1].command!=="closePath"&&r.push(l-1);let d=e.bbox,f={numberOfContours:r.length,xMin:d.minX,yMin:d.minY,xMax:d.maxX,yMax:d.maxY,endPtsOfContours:r,instructions:t,flags:a,xPoints:i,yPoints:n},p=xu.size(f),m=4-p%4,v=new js(p+m);return xu.encode(v,f),m!==0&&v.fill(0,m),v.buffer}_encodePoint(e,t,r,i,n,a){let o=e-t;return e===t?i|=a:(-255<=o&&o<=255&&(i|=n,o<0?o=-o:i|=a),r.push(o)),i}}class Fb extends vu{_addGlyph(e){let t=this.font.getGlyph(e),r=t._decode(),i=this.font.loca.offsets[e],n=this.font.loca.offsets[e+1],a=this.font._getTableStream("glyf");a.pos+=i;let o=a.readBuffer(n-i);if(r&&r.numberOfContours<0){o=new Uint8Array(o);let c=new DataView(o.buffer);for(let u of r.components)e=this.includeGlyph(u.glyphID),c.setUint16(u.pos,e)}else r&&this.font._variationProcessor&&(o=this.glyphEncoder.encodeSimple(t.path,r.instructions));return this.glyf.push(o),this.loca.offsets.push(this.offset),this.hmtx.metrics.push({advance:t.advanceWidth,bearing:t._getMetrics().leftBearing}),this.offset+=o.length,this.glyf.length-1}encode(){this.glyf=[],this.offset=0,this.loca={offsets:[],version:this.font.loca.version},this.hmtx={metrics:[],bearings:[]};let e=0;for(;e<this.glyphs.length;)this._addGlyph(this.glyphs[e++]);let t=Pa(this.font.maxp);t.numGlyphs=this.glyf.length,this.loca.offsets.push(this.offset);let r=Pa(this.font.head);r.indexToLocFormat=this.loca.version;let i=Pa(this.font.hhea);return i.numberOfMetrics=this.hmtx.metrics.length,Nc.toBuffer({tables:{head:r,hhea:i,loca:this.loca,maxp:t,"cvt ":this.font["cvt "],prep:this.font.prep,glyf:this.glyf,hmtx:this.hmtx,fpgm:this.font.fpgm}})}constructor(e){super(e),this.glyphEncoder=new Ob}}class Rb extends vu{subsetCharstrings(){this.charstrings=[];let e={};for(let t of this.glyphs){this.charstrings.push(this.cff.getCharString(t));let r=this.font.getGlyph(t);r.path;for(let i in r._usedGsubrs)e[i]=!0}this.gsubrs=this.subsetSubrs(this.cff.globalSubrIndex,e)}subsetSubrs(e,t){let r=[];for(let i=0;i<e.length;i++){let n=e[i];t[i]?(this.cff.stream.pos=n.offset,r.push(this.cff.stream.readBuffer(n.length))):r.push(new Uint8Array([11]))}return r}subsetFontdict(e){e.FDArray=[],e.FDSelect={version:0,fds:[]};let t={},r=[],i={};for(let n of this.glyphs){let a=this.cff.fdForGlyph(n);if(a==null)continue;t[a]||(e.FDArray.push(Object.assign({},this.cff.topDict.FDArray[a])),r.push({}),i[a]=e.FDArray.length-1),t[a]=!0,e.FDSelect.fds.push(i[a]);let o=this.font.getGlyph(n);o.path;for(let c in o._usedSubrs)r[i[a]][c]=!0}for(let n=0;n<e.FDArray.length;n++){let a=e.FDArray[n];delete a.FontName,a.Private&&a.Private.Subrs&&(a.Private=Object.assign({},a.Private),a.Private.Subrs=this.subsetSubrs(a.Private.Subrs,r[n]))}}createCIDFontdict(e){let t={};for(let i of this.glyphs){let n=this.font.getGlyph(i);n.path;for(let a in n._usedSubrs)t[a]=!0}let r=Object.assign({},this.cff.topDict.Private);return this.cff.topDict.Private&&this.cff.topDict.Private.Subrs&&(r.Subrs=this.subsetSubrs(this.cff.topDict.Private.Subrs,t)),e.FDArray=[{Private:r}],e.FDSelect={version:3,nRanges:1,ranges:[{first:0,fd:0}],sentinel:this.charstrings.length}}addString(e){return e?(this.strings||(this.strings=[]),this.strings.push(e),rn.length+this.strings.length-1):null}encode(){this.subsetCharstrings();let e={version:this.charstrings.length>255?2:1,ranges:[{first:1,nLeft:this.charstrings.length-2}]},t=Object.assign({},this.cff.topDict);t.Private=null,t.charset=e,t.Encoding=null,t.CharStrings=this.charstrings;for(let i of["version","Notice","Copyright","FullName","FamilyName","Weight","PostScript","BaseFontName","FontName"])t[i]=this.addString(this.cff.string(t[i]));t.ROS=[this.addString("Adobe"),this.addString("Identity"),0],t.CIDCount=this.charstrings.length,this.cff.isCIDFont?this.subsetFontdict(t):this.createCIDFontdict(t);let r={version:1,hdrSize:this.cff.hdrSize,offSize:4,header:this.cff.header,nameIndex:[this.cff.postscriptName],topDictIndex:[t],stringIndex:this.strings,globalSubrIndex:this.gsubrs};return Sc.toBuffer(r)}constructor(e){if(super(e),this.cff=this.font["CFF "],!this.cff)throw new Error("Not a CFF Font")}}class bt{static probe(e){let t=un.decode(e.slice(0,4));return t==="true"||t==="OTTO"||t==="\0\0\0"}setDefaultLanguage(e=null){this.defaultLanguage=e}_getTable(e){if(!(e.tag in this._tables))try{this._tables[e.tag]=this._decodeTable(e)}catch{}return this._tables[e.tag]}_getTableStream(e){let t=this.directory.tables[e];return t?(this.stream.pos=t.offset,this.stream):null}_decodeDirectory(){return this.directory=Nc.decode(this.stream,{_startOffset:0})}_decodeTable(e){let t=this.stream.pos,r=this._getTableStream(e.tag),i=ln[e.tag].decode(r,this,e.length);return this.stream.pos=t,i}getName(e,t=this.defaultLanguage||Qs){let r=this.name&&this.name.records[e];return r&&(r[t]||r[this.defaultLanguage]||r[Qs]||r.en||r[Object.keys(r)[0]])||null}get postscriptName(){return this.getName("postscriptName")}get fullName(){return this.getName("fullName")}get familyName(){return this.getName("fontFamily")}get subfamilyName(){return this.getName("fontSubfamily")}get copyright(){return this.getName("copyright")}get version(){return this.getName("version")}get ascent(){return this.hhea.ascent}get descent(){return this.hhea.descent}get lineGap(){return this.hhea.lineGap}get underlinePosition(){return this.post.underlinePosition}get underlineThickness(){return this.post.underlineThickness}get italicAngle(){return this.post.italicAngle}get capHeight(){let e=this["OS/2"];return e?e.capHeight:this.ascent}get xHeight(){let e=this["OS/2"];return e?e.xHeight:0}get numGlyphs(){return this.maxp.numGlyphs}get unitsPerEm(){return this.head.unitsPerEm}get bbox(){return Object.freeze(new Dr(this.head.xMin,this.head.yMin,this.head.xMax,this.head.yMax))}get _cmapProcessor(){return new Ka(this.cmap)}get characterSet(){return this._cmapProcessor.getCharacterSet()}hasGlyphForCodePoint(e){return!!this._cmapProcessor.lookup(e)}glyphForCodePoint(e){return this.getGlyph(this._cmapProcessor.lookup(e),[e])}glyphsForString(e){let t=[],r=e.length,i=0,n=-1,a=-1;for(;i<=r;){let o=0,c=0;if(i<r){if(o=e.charCodeAt(i++),55296<=o&&o<=56319&&i<r){let u=e.charCodeAt(i);56320<=u&&u<=57343&&(i++,o=((o&1023)<<10)+(u&1023)+65536)}c=65024<=o&&o<=65039||917760<=o&&o<=917999?1:0}else i++;a===0&&c===1?t.push(this.getGlyph(this._cmapProcessor.lookup(n,o),[n,o])):a===0&&c===0&&t.push(this.glyphForCodePoint(n)),n=o,a=c}return t}get _layoutEngine(){return new Qy(this)}layout(e,t,r,i,n){return this._layoutEngine.layout(e,t,r,i,n)}stringsForGlyph(e){return this._layoutEngine.stringsForGlyph(e)}get availableFeatures(){return this._layoutEngine.getAvailableFeatures()}getAvailableFeatures(e,t){return this._layoutEngine.getAvailableFeatures(e,t)}_getBaseGlyph(e,t=[]){return this._glyphs[e]||(this.directory.tables.glyf?this._glyphs[e]=new Tn(e,t,this):(this.directory.tables["CFF "]||this.directory.tables.CFF2)&&(this._glyphs[e]=new fb(e,t,this))),this._glyphs[e]||null}getGlyph(e,t=[]){return this._glyphs[e]||(this.directory.tables.sbix?this._glyphs[e]=new mb(e,t,this):this.directory.tables.COLR&&this.directory.tables.CPAL?this._glyphs[e]=new gb(e,t,this):this._getBaseGlyph(e,t)),this._glyphs[e]||null}createSubset(){return this.directory.tables["CFF "]?new Rb(this):new Fb(this)}get variationAxes(){let e={};if(!this.fvar)return e;for(let t of this.fvar.axis)e[t.axisTag.trim()]={name:t.name.en,min:t.minValue,default:t.defaultValue,max:t.maxValue};return e}get namedVariations(){let e={};if(!this.fvar)return e;for(let t of this.fvar.instance){let r={};for(let i=0;i<this.fvar.axis.length;i++){let n=this.fvar.axis[i];r[n.axisTag.trim()]=t.coord[i]}e[t.name.en]=r}return e}getVariation(e){if(!(this.directory.tables.fvar&&(this.directory.tables.gvar&&this.directory.tables.glyf||this.directory.tables.CFF2)))throw new Error("Variations require a font with the fvar, gvar and glyf, or CFF2 tables.");if(typeof e=="string"&&(e=this.namedVariations[e]),typeof e!="object")throw new Error("Variation settings must be either a variation name or settings object.");let t=this.fvar.axis.map((n,a)=>{let o=n.axisTag.trim();return o in e?Math.max(n.minValue,Math.min(n.maxValue,e[o])):n.defaultValue}),r=new ft(this.stream.buffer);r.pos=this._directoryPos;let i=new bt(r,t);return i._tables=this._tables,i}get _variationProcessor(){if(!this.fvar)return null;let e=this.variationCoords;return!e&&!this.CFF2?null:(e||(e=this.fvar.axis.map(t=>t.defaultValue)),new Sb(this,e))}getFont(e){return this.getVariation(e)}constructor(e,t=null){Ct(this,"type","TTF"),this.defaultLanguage=null,this.stream=e,this.variationCoords=t,this._directoryPos=this.stream.pos,this._tables={},this._glyphs={},this._decodeDirectory();for(let r in this.directory.tables){let i=this.directory.tables[r];ln[r]&&i.length>0&&Object.defineProperty(this,r,{get:this._getTable.bind(this,i)})}}}pt([mt],bt.prototype,"bbox",null),pt([mt],bt.prototype,"_cmapProcessor",null),pt([mt],bt.prototype,"characterSet",null),pt([mt],bt.prototype,"_layoutEngine",null),pt([mt],bt.prototype,"variationAxes",null),pt([mt],bt.prototype,"namedVariations",null),pt([mt],bt.prototype,"_variationProcessor",null);let Mb=new R({tag:new He(4),offset:new O(F,"void",{type:"global"}),compLength:F,length:F,origChecksum:F}),Cu=new R({tag:new He(4),flavor:F,length:F,numTables:C,reserved:new Ze(C),totalSfntSize:F,majorVersion:C,minorVersion:C,metaOffset:F,metaLength:F,metaOrigLength:F,privOffset:F,privLength:F,tables:new I(Mb,"numTables")});Cu.process=function(){let s={};for(let e of this.tables)s[e.tag]=e;this.tables=s};var Db=Cu;class Bb extends bt{static probe(e){return un.decode(e.slice(0,4))==="wOFF"}_decodeDirectory(){this.directory=Db.decode(this.stream,{_startOffset:0})}_getTableStream(e){let t=this.directory.tables[e];if(t)if(this.stream.pos=t.offset,t.compLength<t.length){this.stream.pos+=2;let r=new Uint8Array(t.length),i=Rd(this.stream.readBuffer(t.compLength-2),r);return new ft(i)}else return this.stream;return null}constructor(...e){super(...e),Ct(this,"type","WOFF")}}class Lb extends Tn{_decode(){return this._font._transformedGlyphs[this.id]}_getCBox(){return this.path.bbox}constructor(...e){super(...e),Ct(this,"type","WOFF2")}}const ku={decode(s){let e=0,t=[0,1,2,3,4];for(let r=0;r<t.length;r++){let i=s.readUInt8();if(e&3758096384)throw new Error("Overflow");if(e=e<<7|i&127,!(i&128))return e}throw new Error("Bad base 128 number")}};let zb=["cmap","head","hhea","hmtx","maxp","name","OS/2","post","cvt ","fpgm","glyf","loca","prep","CFF ","VORG","EBDT","EBLC","gasp","hdmx","kern","LTSH","PCLT","VDMX","vhea","vmtx","BASE","GDEF","GPOS","GSUB","EBSC","JSTF","MATH","CBDT","CBLC","COLR","CPAL","SVG ","sbix","acnt","avar","bdat","bloc","bsln","cvar","fdsc","feat","fmtx","fvar","gvar","hsty","just","lcar","mort","morx","opbd","prop","trak","Zapf","Silf","Glat","Gloc","Feat","Sill"],$b=new R({flags:K,customTag:new Ws(new He(4),s=>(s.flags&63)===63),tag:s=>s.customTag||zb[s.flags&63],length:ku,transformVersion:s=>s.flags>>>6&3,transformed:s=>s.tag==="glyf"||s.tag==="loca"?s.transformVersion===0:s.transformVersion!==0,transformLength:new Ws(ku,s=>s.transformed)}),Su=new R({tag:new He(4),flavor:F,length:F,numTables:C,reserved:new Ze(C),totalSfntSize:F,totalCompressedSize:F,majorVersion:C,minorVersion:C,metaOffset:F,metaLength:F,metaOrigLength:F,privOffset:F,privLength:F,tables:new I($b,"numTables")});Su.process=function(){let s={};for(let e=0;e<this.tables.length;e++){let t=this.tables[e];s[t.tag]=t}return this.tables=s};var Nb=Su;class Ub extends bt{static probe(e){return un.decode(e.slice(0,4))==="wOF2"}_decodeDirectory(){this.directory=Nb.decode(this.stream),this._dataPos=this.stream.pos}_decompress(){if(!this._decompressed){this.stream.pos=this._dataPos;let e=this.stream.readBuffer(this.directory.totalCompressedSize),t=0;for(let i in this.directory.tables){let n=this.directory.tables[i];n.offset=t,t+=n.transformLength!=null?n.transformLength:n.length}let r=ff(e,t);if(!r)throw new Error("Error decoding compressed data in WOFF2");this.stream=new ft(r),this._decompressed=!0}}_decodeTable(e){return this._decompress(),super._decodeTable(e)}_getBaseGlyph(e,t=[]){if(!this._glyphs[e])return this.directory.tables.glyf&&this.directory.tables.glyf.transformed?(this._transformedGlyphs||this._transformGlyfTable(),this._glyphs[e]=new Lb(e,t,this)):super._getBaseGlyph(e,t)}_transformGlyfTable(){this._decompress(),this.stream.pos=this.directory.tables.glyf.offset;let e=Hb.decode(this.stream),t=[];for(let i=0;i<e.numGlyphs;i++){let n={},a=e.nContours.readInt16BE();if(n.numberOfContours=a,a>0){let o=[],c=0;for(let u=0;u<a;u++){let h=no(e.nPoints);c+=h,o.push(c)}n.points=Gb(e.flags,e.glyphs,c);for(let u=0;u<a;u++)n.points[o[u]-1].endContour=!0;var r=no(e.glyphs)}else if(a<0&&Tn.prototype._decodeComposite.call({_font:this},n,e.composites))var r=no(e.glyphs);t.push(n)}this._transformedGlyphs=t}constructor(...e){super(...e),Ct(this,"type","WOFF2")}}class ai{decode(e,t){return new ft(this._buf.decode(e,t))}constructor(e){this.length=e,this._buf=new qt(e)}}let Hb=new R({version:F,numGlyphs:C,indexFormat:C,nContourStreamSize:F,nPointsStreamSize:F,flagStreamSize:F,glyphStreamSize:F,compositeStreamSize:F,bboxStreamSize:F,instructionStreamSize:F,nContours:new ai("nContourStreamSize"),nPoints:new ai("nPointsStreamSize"),flags:new ai("flagStreamSize"),glyphs:new ai("glyphStreamSize"),composites:new ai("compositeStreamSize"),bboxes:new ai("bboxStreamSize"),instructions:new ai("instructionStreamSize")});const Vb=253,jb=254,Wb=255,_u=253;function no(s){let e=s.readUInt8();return e===Vb?s.readUInt16BE():e===Wb?s.readUInt8()+_u:e===jb?s.readUInt8()+_u*2:e}function tr(s,e){return s&1?e:-e}function Gb(s,e,t){let r,i=r=0,n=[];for(let c=0;c<t;c++){let u=0,h=0,l=s.readUInt8(),d=!(l>>7);if(l&=127,l<10)u=0,h=tr(l,((l&14)<<7)+e.readUInt8());else if(l<20)u=tr(l,((l-10&14)<<7)+e.readUInt8()),h=0;else if(l<84){var a=l-20,o=e.readUInt8();u=tr(l,1+(a&48)+(o>>4)),h=tr(l>>1,1+((a&12)<<2)+(o&15))}else if(l<120){var a=l-84;u=tr(l,1+(a/12<<8)+e.readUInt8()),h=tr(l>>1,1+(a%12>>2<<8)+e.readUInt8())}else if(l<124){var o=e.readUInt8();let p=e.readUInt8();u=tr(l,(o<<4)+(p>>4)),h=tr(l>>1,((p&15)<<8)+e.readUInt8())}else u=tr(l,e.readUInt16BE()),h=tr(l>>1,e.readUInt16BE());i+=u,r+=h,n.push(new zt(d,!1,i,r))}return n}let qb=new Ee(F,{65536:{numFonts:F,offsets:new I(F,"numFonts")},131072:{numFonts:F,offsets:new I(F,"numFonts"),dsigTag:F,dsigLength:F,dsigOffset:F}});class Xb{static probe(e){return un.decode(e.slice(0,4))==="ttcf"}getFont(e){for(let t of this.header.offsets){let r=new ft(this.stream.buffer);r.pos=t;let i=new bt(r);if(i.postscriptName===e||i.postscriptName instanceof Uint8Array&&e instanceof Uint8Array&&i.postscriptName.every((n,a)=>e[a]===n))return i}return null}get fonts(){let e=[];for(let t of this.header.offsets){let r=new ft(this.stream.buffer);r.pos=t,e.push(new bt(r))}return e}constructor(e){if(Ct(this,"type","TTC"),this.stream=e,e.readString(4)!=="ttcf")throw new Error("Not a TrueType collection");this.header=qb.decode(e)}}let Zb=new He(K);new R({len:F,buf:new qt("len")});let Kb=new R({id:C,nameOffset:V,attr:K,dataOffset:Ar,handle:F}),Yb=new R({name:new He(4),maxTypeIndex:C,refList:new O(C,new I(Kb,s=>s.maxTypeIndex+1),{type:"parent"})}),Jb=new R({length:C,types:new I(Yb,s=>s.length+1)}),Qb=new R({reserved:new Ze(K,24),typeList:new O(C,Jb),nameListOffset:new O(C,"void")}),Tu=new R({dataOffset:F,map:new O(F,Qb),dataLength:F,mapLength:F});class e1{static probe(e){let t=new ft(e);try{var r=Tu.decode(t)}catch{return!1}for(let i of r.map.typeList.types)if(i.name==="sfnt")return!0;return!1}getFont(e){if(!this.sfnt)return null;for(let t of this.sfnt.refList){let r=this.header.dataOffset+t.dataOffset+4,i=new ft(this.stream.buffer.slice(r)),n=new bt(i);if(n.postscriptName===e||n.postscriptName instanceof Uint8Array&&e instanceof Uint8Array&&n.postscriptName.every((a,o)=>e[o]===a))return n}return null}get fonts(){let e=[];for(let t of this.sfnt.refList){let r=this.header.dataOffset+t.dataOffset+4,i=new ft(this.stream.buffer.slice(r));e.push(new bt(i))}return e}constructor(e){Ct(this,"type","DFont"),this.stream=e,this.header=Tu.decode(this.stream);for(let t of this.header.map.typeList.types){for(let r of t.refList)r.nameOffset>=0?(this.stream.pos=r.nameOffset+this.header.map.nameListOffset,r.name=Zb.decode(this.stream)):r.name=null;t.name==="sfnt"&&(this.sfnt=t)}}}Si(bt),Si(Bb),Si(Ub),Si(Xb),Si(e1);var at={DEFAULTS:{width:800,height:400,pixelRatio:2,fontFamily:"Roboto",fontSize:48,color:"#000000",textAlign:"center"},LIMITS:{minWidth:1,maxWidth:4096,minHeight:1,maxHeight:4096,minFontSize:1,maxFontSize:512,minDuration:.1,maxDuration:120,maxTextLength:1e4},ANIMATION_TYPES:["typewriter","fadeIn","slideIn","shift","ascend","movingLetters"]},ps=/^#[A-Fa-f0-9]{6}$/,t1=oe.object({type:oe.string().valid("linear","radial").default("linear"),angle:oe.number().min(0).max(360).default(0),stops:oe.array().items(oe.object({offset:oe.number().min(0).max(1).required(),color:oe.string().pattern(ps).required()}).unknown(!1)).min(2).required()}).unknown(!1),r1=oe.object({offsetX:oe.number().default(0),offsetY:oe.number().default(0),blur:oe.number().min(0).default(0),color:oe.string().pattern(ps).default("#000000"),opacity:oe.number().min(0).max(1).default(.5)}).unknown(!1),i1=oe.object({width:oe.number().min(0).default(0),color:oe.string().pattern(ps).default("#000000"),opacity:oe.number().min(0).max(1).default(1)}).unknown(!1),s1=oe.object({family:oe.string().default(at.DEFAULTS.fontFamily),size:oe.number().min(at.LIMITS.minFontSize).max(at.LIMITS.maxFontSize).default(at.DEFAULTS.fontSize),weight:oe.alternatives().try(oe.string(),oe.number()).default("400"),color:oe.string().pattern(ps).default(at.DEFAULTS.color),opacity:oe.number().min(0).max(1).default(1)}).unknown(!1),n1=oe.object({letterSpacing:oe.number().default(0),lineHeight:oe.number().min(0).max(10).default(1.2),textTransform:oe.string().valid("none","uppercase","lowercase","capitalize").default("none"),textDecoration:oe.string().valid("none","underline","line-through").default("none"),gradient:t1.optional()}).unknown(!1),a1=oe.object({horizontal:oe.string().valid("left","center","right").default(at.DEFAULTS.textAlign),vertical:oe.string().valid("top","middle","bottom").default("middle")}).unknown(!1),o1=oe.object({preset:oe.string().valid(...at.ANIMATION_TYPES),speed:oe.number().min(.1).max(10).default(1),duration:oe.number().min(at.LIMITS.minDuration).max(at.LIMITS.maxDuration).optional(),style:oe.string().valid("character","word").optional().when("preset",{is:oe.valid("typewriter","shift","fadeIn","slideIn"),then:oe.optional(),otherwise:oe.forbidden()}),direction:oe.string().optional().when("preset",{switch:[{is:"ascend",then:oe.valid("up","down")},{is:"shift",then:oe.valid("left","right","up","down")},{is:"slideIn",then:oe.valid("left","right","up","down")},{is:"movingLetters",then:oe.valid("left","right","up","down")}],otherwise:oe.forbidden()})}).unknown(!1),l1=oe.object({color:oe.string().pattern(ps).optional(),opacity:oe.number().min(0).max(1).default(1),borderRadius:oe.number().min(0).default(0)}).unknown(!1),c1=oe.object({src:oe.string().uri().required(),family:oe.string().required(),weight:oe.alternatives().try(oe.string(),oe.number()).optional(),style:oe.string().optional(),originalFamily:oe.string().optional()}).unknown(!1),u1=oe.object({type:oe.string().valid("rich-text").required(),text:oe.string().allow("").max(at.LIMITS.maxTextLength).default(""),width:oe.number().min(at.LIMITS.minWidth).max(at.LIMITS.maxWidth).default(at.DEFAULTS.width).optional(),height:oe.number().min(at.LIMITS.minHeight).max(at.LIMITS.maxHeight).default(at.DEFAULTS.height).optional(),font:s1.optional(),style:n1.optional(),stroke:i1.optional(),shadow:r1.optional(),background:l1.optional(),align:a1.optional(),animation:o1.optional(),customFonts:oe.array().items(c1).optional(),cacheEnabled:oe.boolean().default(!0),pixelRatio:oe.number().min(1).max(3).default(at.DEFAULTS.pixelRatio)}).unknown(!1),En=null;function Eu(){return typeof process<"u"&&process.versions!=null&&process.versions.node!=null}function h1(s){if(s.buffer instanceof ArrayBuffer)return s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength);const e=new ArrayBuffer(s.byteLength),t=new Uint8Array(e);for(let r=0;r<s.byteLength;r++)t[r]=s[r];return e}var Au="https://shotstack-ingest-api-dev-sources.s3.ap-southeast-2.amazonaws.com/euo5r93oyr/zzz01k9h-yycyx-2x2y6-qx9bj-7n567b/source.wasm";async function Iu(s){try{console.log(`🌐 Fetching WASM from URL: ${s}`);const e=await fetch(s);if(e.ok){const t=await e.arrayBuffer(),r=new Uint8Array(t);if(r.length>=4&&r[0]===0&&r[1]===97&&r[2]===115&&r[3]===109)return console.log(`✅ Fetched WASM from URL (${r.length} bytes)`),t;console.error(`❌ Invalid WASM magic number from URL: ${s}`)}else console.error(`❌ Failed to fetch WASM from URL: ${s}, status: ${e.status}`);return}catch(e){console.error(`❌ Error fetching WASM from ${s}:`,e);return}}async function d1(){try{const{readFile:s}=await Promise.resolve().then(()=>Nn),e=await Promise.resolve().then(()=>Nn),t=[];try{const{createRequire:i}=await Promise.resolve().then(()=>Nn),a=i((typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:hr&&hr.tagName.toUpperCase()==="SCRIPT"&&hr.src||new URL("shotstack-studio.umd.js",document.baseURI).href)||`file://${process.cwd()}/`).resolve("harfbuzzjs/package.json"),o=e.dirname(a);t.push(e.join(o,"hb.wasm"))}catch{}let r;try{if(typeof(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:hr&&hr.tagName.toUpperCase()==="SCRIPT"&&hr.src||new URL("shotstack-studio.umd.js",document.baseURI).href)=="string"){const{fileURLToPath:i}=await Promise.resolve().then(()=>Nn);r=e.dirname(i(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:hr&&hr.tagName.toUpperCase()==="SCRIPT"&&hr.src||new URL("shotstack-studio.umd.js",document.baseURI).href))}}catch{}r||(r=process.cwd()),t.push(e.join(r,"dist/hb.wasm"),e.join(r,"assets/wasm/hb.wasm"),e.join(r,"node_modules/harfbuzzjs/hb.wasm"),e.join(r,"node_modules/@shotstack/shotstack-canvas/assets/wasm/hb.wasm")),t.push("/var/task/node_modules/harfbuzzjs/hb.wasm","/var/task/node_modules/@shotstack/shotstack-canvas/assets/wasm/hb.wasm"),console.log(`🔍 Searching for WASM in ${t.length} local paths...`);for(const i of t)try{const n=await s(i);return console.log(`✅ Found WASM at: ${i}`),h1(n)}catch{continue}return console.log("📂 Local WASM not found, fetching from URL..."),await Iu(Au)}catch(s){return console.error("Error in loadWasmNode:",s),console.log("⚠️ Error during local search, falling back to URL..."),await Iu(Au)}}async function f1(s){try{if(s){const e=s.endsWith(".wasm")?s:s.endsWith("/")?`${s}hb.wasm`:`${s}/hb.wasm`;console.log(`Fetching WASM from: ${e}`);const t=await fetch(e);if(t.ok){const r=await t.arrayBuffer(),i=new Uint8Array(r);if(i.length>=4&&i[0]===0&&i[1]===97&&i[2]===115&&i[3]===109)return console.log(`✅ Valid WASM binary loaded (${i.length} bytes)`),r}}return}catch(e){console.error("Error in loadWasmWeb:",e);return}}function p1(s){const e=window.fetch;window.fetch=function(i,n){const a=typeof i=="string"?i:i instanceof URL?i.href:i.url;return a.includes("hb.wasm")||a.endsWith(".wasm")&&!a.includes("source.wasm")?(console.log(`🔄 Intercepted fetch for: ${a}`),Promise.resolve(new Response(s.slice(0),{status:200,statusText:"OK",headers:{"Content-Type":"application/wasm","Content-Length":s.byteLength.toString()}}))):e.apply(this,[i,n])};const t=WebAssembly.instantiate;WebAssembly.instantiate=async function(i,n){if(console.log(`🔄 WebAssembly.instantiate called, type: ${i instanceof WebAssembly.Module?"Module":"BufferSource"}`),i instanceof WebAssembly.Module)return t.call(WebAssembly,i,n);console.log("🔄 Intercepted WebAssembly.instantiate, using pre-loaded WASM binary");const a=await WebAssembly.compile(s),o=await t.call(WebAssembly,a,n);return{module:a,instance:o}};const r=WebAssembly.instantiateStreaming;r&&(WebAssembly.instantiateStreaming=async function(i,n){try{const a=await i,o=a.url||"";if(o.includes("hb.wasm")||o.endsWith(".wasm")&&!o.includes("source.wasm")){console.log(`🔄 Intercepted instantiateStreaming for: ${o}`);const c=await WebAssembly.compile(s),u=await WebAssembly.instantiate(c,n);return{module:c,instance:u}}return r.call(WebAssembly,a,n)}catch{console.log("🔄 instantiateStreaming failed, using pre-loaded binary");const o=await WebAssembly.compile(s),c=await WebAssembly.instantiate(o,n);return{module:o,instance:c}}})}async function m1(s){if(En)return En;try{let e;if(Eu()?e=await d1():e=await f1(s),!e)throw new Error("Failed to load WASM binary from any source");console.log(`✅ WASM binary loaded successfully (${e.byteLength} bytes)`),Eu()||(p1(e),window.Module={wasmBinary:e,locateFile:c=>(console.log(`🔍 locateFile called for: ${c}`),c)},console.log(`🌍 Set global Module.wasmBinary (${e.byteLength} bytes)`)),console.log("🔄 Importing harfbuzzjs/hb.js (factory)");const t=await Promise.resolve().then(()=>lx),r=t.default||t;console.log("🔄 Calling hb factory with wasmBinary");const i=await r({wasmBinary:e});console.log("🔄 Importing harfbuzzjs/hbjs.js (wrapper)");const n=await Promise.resolve().then(()=>hx),a=n.default||n;console.log("🔄 Wrapping hb instance");const o=a(i);if(!o||typeof o.createBuffer!="function"||typeof o.createFont!="function")throw new Error("Failed to initialize HarfBuzz: unexpected export shape from 'harfbuzzjs'.");return En=o,console.log("✅ HarfBuzz initialized successfully"),En}catch(e){throw console.error("Failed to initialize HarfBuzz:",e),new Error(`Failed to initialize HarfBuzz: ${e instanceof Error?e.message:String(e)}`)}}var Pu=class Xo{constructor(e){Wt(this,"hb"),Wt(this,"faces",new Map),Wt(this,"fonts",new Map),Wt(this,"blobs",new Map),Wt(this,"fontkitFonts",new Map),Wt(this,"wasmBaseURL"),Wt(this,"initPromise"),Wt(this,"emojiFallbackDesc"),this.wasmBaseURL=e}static setFallbackLoader(e){Xo.fallbackLoader=e}setEmojiFallback(e){this.emojiFallbackDesc=e}async init(){if(this.initPromise){await this.initPromise;return}if(!this.hb){this.initPromise=this._doInit();try{await this.initPromise}catch(e){throw new Error(`Failed to initialize FontRegistry: ${e instanceof Error?e.message:String(e)}`)}}}async _doInit(){try{this.hb=await m1("https://shotstack-ingest-api-dev-sources.s3.ap-southeast-2.amazonaws.com/euo5r93oyr/zzz01k9h-yycyx-2x2y6-qx9bj-7n567b/source.wasm")}catch(e){throw this.initPromise=void 0,e}}async getHB(){if(!this.hb)try{await this.init()}catch(e){throw new Error(`Failed to get HarfBuzz instance: ${e instanceof Error?e.message:String(e)}`)}return this.hb}key(e){return`${e.family}__${e.weight??"400"}`}async registerFromBytes(e,t){try{this.hb||await this.init();const r=this.key(t);if(this.fonts.has(r))return;const i=this.hb.createBlob(e),n=this.hb.createFace(i,0),a=this.hb.createFont(n),o=n.upem||1e3;a.setScale(o,o);const c=t.weight??"400",u=typeof c=="string"?parseInt(c,10):c;if(u!==400&&typeof a.setVariations=="function")try{a.setVariations(`wght=${u}`)}catch{}this.blobs.set(r,i),this.faces.set(r,n),this.fonts.set(r,a);try{const h=typeof Buffer<"u"?Buffer.from(e):new Uint8Array(e),l=ec(h);if(l.variationAxes&&Object.keys(l.variationAxes).length>0){const d=l.getVariation({wght:u});this.fontkitFonts.set(r,d),console.log(`✅ Registered variable font: ${t.family} weight=${u}`)}else this.fontkitFonts.set(r,l),console.log(`✅ Registered static font: ${t.family}`)}catch(h){console.warn(`⚠️ Fontkit failed for ${t.family}:`,h)}}catch(r){throw new Error(`Failed to register font "${t.family}": ${r instanceof Error?r.message:String(r)}`)}}async tryFallbackInstall(e){const t=Xo.fallbackLoader;if(!t)return!1;try{const r=await t({family:e.family,weight:e.weight??"400"});return r?(await this.registerFromBytes(r,{family:e.family,weight:e.weight??"400"}),!0):!1}catch{return!1}}async getFont(e){try{this.hb||await this.init();const t=this.key(e);let r=this.fonts.get(t);if(r||(r=await this.tryFallbackInstall(e)?this.fonts.get(t):void 0),!r)throw new Error(`Font not registered for ${t}`);return r}catch(t){throw t instanceof Error&&t.message.includes("Font not registered")?t:new Error(`Failed to get font "${e.family}": ${t instanceof Error?t.message:String(t)}`)}}async getFace(e){try{this.hb||await this.init();const t=this.key(e);let r=this.faces.get(t);return r||(r=await this.tryFallbackInstall(e)?this.faces.get(t):void 0),r}catch(t){throw new Error(`Failed to get face for "${e.family}": ${t instanceof Error?t.message:String(t)}`)}}async getUnitsPerEm(e){try{return(await this.getFace(e))?.upem||1e3}catch(t){throw new Error(`Failed to get units per em for "${e.family}": ${t instanceof Error?t.message:String(t)}`)}}async glyphPath(e,t){const r=this.key(e);try{const i=this.fontkitFonts.get(r);if(i){const o=i.getGlyph(t);if(o&&o.path){const c=o.path.toSVG();return c&&c!==""?c:"M 0 0"}}const a=(await this.getFont(e)).glyphToPath(t);return a&&a!==""?a:"M 0 0"}catch(i){throw new Error(`Failed to get glyph path for glyph ${t} in font "${e.family}": ${i instanceof Error?i.message:String(i)}`)}}destroy(){try{for(const[,e]of this.fonts)try{e.destroy()}catch(t){console.error(`Error destroying font: ${t instanceof Error?t.message:String(t)}`)}for(const[,e]of this.faces)try{e.destroy()}catch(t){console.error(`Error destroying face: ${t instanceof Error?t.message:String(t)}`)}for(const[,e]of this.blobs)try{e.destroy()}catch(t){console.error(`Error destroying blob: ${t instanceof Error?t.message:String(t)}`)}this.fonts.clear(),this.faces.clear(),this.blobs.clear(),this.fontkitFonts.clear(),this.hb=void 0,this.initPromise=void 0}catch(e){console.error(`Error during FontRegistry cleanup: ${e instanceof Error?e.message:String(e)}`)}}};Wt(Pu,"fallbackLoader");var Ou=Pu;function g1(s){const e=s.codePointAt(0);return e?e>=127744&&e<=129535||e>=9728&&e<=9983||e>=9984&&e<=10175||e>=65024&&e<=65039||e>=128512&&e<=128591||e>=128640&&e<=128767||e>=129280&&e<=129535||e>=129648&&e<=129791:!1}var y1=class{constructor(s){this.fonts=s}transformText(s,e){switch(e){case"uppercase":return s.toUpperCase();case"lowercase":return s.toLowerCase();case"capitalize":return s.replace(/\b\w/g,t=>t.toUpperCase());default:return s}}async shapeFull(s,e){try{const t=await this.fonts.getHB(),r=t.createBuffer();try{r.addText(s),r.guessSegmentProperties();const i=await this.fonts.getFont(e),a=(await this.fonts.getFace(e))?.upem||1e3;return i.setScale(a,a),t.shape(i,r),r.json()}finally{try{r.destroy()}catch(i){console.error(`Error destroying HarfBuzz buffer: ${i instanceof Error?i.message:String(i)}`)}}}catch(t){throw new Error(`Failed to shape text with font "${e.family}": ${t instanceof Error?t.message:String(t)}`)}}async layout(s){try{const{textTransform:e,desc:t,fontSize:r,letterSpacing:i,width:n,emojiFallback:a}=s,o=this.transformText(s.text,e);if(!o||o.length===0)return[];let c;try{if(!a)c=await this.shapeFull(o,t);else{const y=Array.from(o),b=[];let k={text:"",startIndex:0,isEmoji:!1};for(let x=0;x<y.length;x++){const E=y[x],T=g1(E);x===0?k={text:E,startIndex:0,isEmoji:T}:k.isEmoji===T?k.text+=E:(b.push(k),k={text:E,startIndex:k.startIndex+k.text.length,isEmoji:T})}k.text&&b.push(k),c=[];for(const x of b){const E=x.isEmoji?a:t,T=await this.shapeFull(x.text,E);for(const w of T)w.cl+=x.startIndex,w.fontDesc=E;c.push(...T)}}}catch(y){throw new Error(`Text shaping failed: ${y instanceof Error?y.message:String(y)}`)}let u;try{u=(await this.fonts.getFace(t))?.upem||1e3}catch(y){throw new Error(`Failed to get font metrics: ${y instanceof Error?y.message:String(y)}`)}const h=r/u,l=c.map(y=>{const b=y.cl;let k;return b>=0&&b<o.length&&(k=o[b]),{id:y.g,xAdvance:y.ax*h+i,xOffset:y.dx*h,yOffset:-y.dy*h,cluster:y.cl,char:k,fontDesc:y.fontDesc}}),d=[];let f=[],p=0;const m=new Set;for(let y=0;y<o.length;y++)o[y]===" "&&m.add(y);let v=-1;for(let y=0;y<l.length;y++){const b=l[y],k=b.xAdvance;if(b.char===`
185
+ `){d.push({glyphs:f,width:p,y:0}),f=[],p=0,v=y;continue}if(p+k>n&&f.length>0){if(v>-1){const x=v-(y-f.length)+1,E=f.splice(x),T=f.reduce((w,S)=>w+S.xAdvance,0);d.push({glyphs:f,width:T,y:0}),f=E,p=E.reduce((w,S)=>w+S.xAdvance,0)}else d.push({glyphs:f,width:p,y:0}),f=[],p=0;v=-1}f.push(b),p+=k,m.has(b.cluster)&&(v=y)}f.length>0&&d.push({glyphs:f,width:p,y:0});const g=s.lineHeight*r;for(let y=0;y<d.length;y++)d[y].y=(y+1)*g;return d}catch(e){throw e instanceof Error?e:new Error(`Layout failed: ${String(e)}`)}}};function b1(s,e){return s.type==="linear"?{kind:"linear",angle:s.angle,stops:s.stops,opacity:e}:{kind:"radial",stops:s.stops,opacity:e}}function v1(s,e){const t=Math.max(1,Math.round(e.fontSize*.05));let r=e.baselineY+Math.round(e.fontSize*.1);return s==="line-through"&&(r=e.baselineY-Math.round(e.fontSize*.3)),{x1:e.xStart,x2:e.xStart+e.lineWidth,y:r,width:t}}async function w1(s){const e=[];if(e.push({op:"BeginFrame",width:s.canvas.width,height:s.canvas.height,pixelRatio:s.canvas.pixelRatio,clear:!0,bg:s.background&&s.background.color?{color:s.background.color,opacity:s.background.opacity,radius:s.background.borderRadius}:void 0}),s.lines.length===0)return e;const t=Math.max(1,await s.getUnitsPerEm()),r=s.font.size/t,i=s.lines.length,n=s.font.size*s.style.lineHeight;let a;switch(s.align.vertical){case"top":a=s.font.size;break;case"bottom":a=s.textRect.height-(i-1)*n;break;case"middle":default:const p=s.font.size*.35;a=(s.textRect.height-(i-1)*n)/2+p;break}const o=s.style.gradient?b1(s.style.gradient,1):{kind:"solid",color:s.font.color,opacity:s.font.opacity},c=s.style.gradient?s.style.gradient.stops[s.style.gradient.stops.length-1]?.color??s.font.color:s.font.color;let u=1/0,h=1/0,l=-1/0,d=-1/0;for(const f of s.lines){let p;switch(s.align.horizontal){case"left":p=0;break;case"right":p=s.textRect.width-f.width;break;case"center":default:p=(s.textRect.width-f.width)/2;break}let m=p;const v=s.lines.indexOf(f),g=a+v*n;for(const y of f.glyphs){const b=await s.glyphPathProvider(y.id,y.fontDesc);if(!b||b==="M 0 0"){m+=y.xAdvance;continue}const k=m+y.xOffset,x=g+y.yOffset,E=C1(b),T=k+r*E.x,w=k+r*(E.x+E.w),S=x-r*(E.y+E.h),_=x-r*E.y;T<u&&(u=T),S<h&&(h=S),w>l&&(l=w),_>d&&(d=_),s.shadow&&s.shadow.blur>0&&e.push({isShadow:!0,op:"FillPath",path:b,x:k+s.shadow.offsetX,y:x+s.shadow.offsetY,scale:r,fill:{kind:"solid",color:s.shadow.color,opacity:s.shadow.opacity}}),s.stroke&&s.stroke.width>0&&e.push({op:"StrokePath",path:b,x:k,y:x,scale:r,width:s.stroke.width,color:s.stroke.color,opacity:s.stroke.opacity}),e.push({op:"FillPath",path:b,x:k,y:x,scale:r,fill:o}),m+=y.xAdvance}if(s.style.textDecoration!=="none"){const y=v1(s.style.textDecoration,{baselineY:g,fontSize:s.font.size,lineWidth:f.width,xStart:p});e.push({op:"DecorationLine",from:{x:y.x1,y:y.y},to:{x:y.x2,y:y.y},width:y.width,color:c,opacity:s.font.opacity})}}if(u!==1/0){const f={x:u,y:h,w:Math.max(1,l-u),h:Math.max(1,d-h)};for(const p of e)p.op==="FillPath"&&!p.isShadow&&(p.gradientBBox=f)}return e}function x1(s){return s.match(/[MLCQZ]|-?\d*\.?\d+(?:e[-+]?\d+)?/gi)??[]}function C1(s){const e=x1(s);let t=0,r=1/0,i=1/0,n=-1/0,a=-1/0;const o=(c,u)=>{c<r&&(r=c),u<i&&(i=u),c>n&&(n=c),u>a&&(a=u)};for(;t<e.length;)switch(e[t++]){case"M":case"L":{const u=parseFloat(e[t++]),h=parseFloat(e[t++]);o(u,h);break}case"C":{const u=parseFloat(e[t++]),h=parseFloat(e[t++]),l=parseFloat(e[t++]),d=parseFloat(e[t++]),f=parseFloat(e[t++]),p=parseFloat(e[t++]);o(u,h),o(l,d),o(f,p);break}case"Q":{const u=parseFloat(e[t++]),h=parseFloat(e[t++]),l=parseFloat(e[t++]),d=parseFloat(e[t++]);o(u,h),o(l,d);break}}return r===1/0?{x:0,y:0,w:0,h:0}:{x:r,y:i,w:n-r,h:a-i}}var ao=.999;function k1(s,e,t){if(!t.anim||!t.anim.preset)return s;const{preset:r}=t.anim,i=e.reduce((c,u)=>c+u.glyphs.length,0);let n=Math.max(.3,i/(30*t.anim.speed));t.clipDuration&&!t.anim.duration&&(n=Math.min(n,t.clipDuration*.9));const a=t.anim.duration??n,o=Math.max(0,Math.min(1,t.t/a));switch(r){case"typewriter":return _1(s,e,o,t.anim.style,t.fontSize,t.t);case"fadeIn":return A1(s,e,o,t.anim.style,t.fontSize,a);case"slideIn":return I1(s,e,o,t.anim.direction??"left",t.fontSize,t.anim.style,a);case"shift":return E1(s,e,o,t.anim.direction??"left",t.fontSize,t.anim.style,a);case"ascend":return T1(s,e,o,t.anim.direction??"up",t.fontSize,a);case"movingLetters":return P1(s,t.t,t.anim.direction??"up",t.fontSize);default:return s}}var An=s=>s.op==="FillPath"&&s.isShadow===!0,In=s=>s.op==="FillPath"&&!s.isShadow;function S1(s){for(const e of s)if(e.op==="FillPath"){const t=e.fill;if(t?.kind==="solid")return t.color;if((t?.kind==="linear"||t?.kind==="radial")&&Array.isArray(t.stops)&&t.stops.length)return t.stops[t.stops.length-1].color||"#000000"}return"#000000"}function _1(s,e,t,r,i,n,a){if(r==="word"){const c=ms(e),u=c.length,h=Math.floor(t*u);if(h===0)return s.filter(p=>p.op==="BeginFrame");let l=0;for(let p=0;p<Math.min(h,c.length);p++)l+=c[p].glyphCount;const d=Fu(s,l),f=t>=ao?d:d.filter(p=>p.op!=="DecorationLine");return t<1&&l>0?Ru(f,l,i,n):f}else{const c=e.reduce((d,f)=>d+f.glyphs.length,0),u=Math.floor(t*c);if(u===0)return s.filter(d=>d.op==="BeginFrame");const h=Fu(s,u),l=t>=ao?h:h.filter(d=>d.op!=="DecorationLine");return t<1&&u>0?Ru(l,u,i,n):l}}function T1(s,e,t,r,i,n){const a=ms(e),o=a.length;if(o===0)return s;const c=[];let u=0;for(const h of s)if(h.op==="BeginFrame"){c.push(h);break}for(const h of s)if(h.op==="FillPath"||h.op==="StrokePath"){let l=-1,d=0;for(let f=0;f<a.length;f++){const p=a[f].glyphCount;if(u>=d&&u<d+p){l=f;break}d+=p}if(l>=0){const f=l/Math.max(1,o)*(n/n),p=Math.min(1,f+.3);if(t>=p)c.push(h);else if(t>f){const m=(t-f)/Math.max(1e-6,p-f),v=Pn(Math.min(1,m)),g=r==="up"?i*.4:-i*.4,y={...h,y:h.y+g*(1-v)};h.op==="FillPath"?y.fill.kind==="solid"?y.fill={...y.fill,opacity:y.fill.opacity*v}:y.fill={...y.fill,opacity:(y.fill.opacity??1)*v}:y.opacity=y.opacity*v,c.push(y)}}In(h)&&u++}else h.op==="DecorationLine"&&t>=ao&&c.push(h);return c}function E1(s,e,t,r,i,n,a){const o=n==="word",u={left:{x:i*.6,y:0},right:{x:-i*.6,y:0},up:{x:0,y:i*.6},down:{x:0,y:-i*.6}}[r],h=o?ms(e):[],l=e.reduce((b,k)=>b+k.glyphs.length,0),d=o?h.length:l;if(d===0)return s;const f=[];for(const b of s)if(b.op==="BeginFrame"){f.push(b);break}const p=.3,v=a*.7/Math.max(1,d-1),g=b=>{const k=b*v,x=k/a,E=Math.min(1,(k+p)/a);return{startF:x,endF:E}};let y=0;for(const b of s){if(b.op!=="FillPath"&&b.op!=="StrokePath"){b.op==="DecorationLine"&&t>.8&&f.push(b);continue}let k;if(!o)k=y;else{let T=-1,w=0;for(let S=0;S<h.length;S++){const _=h[S].glyphCount;if(y>=w&&y<w+_){T=S;break}w+=_}k=Math.max(0,T)}const{startF:x,endF:E}=g(k);if(t<=x){const T={...b,x:b.x+u.x,y:b.y+u.y};b.op==="FillPath"?T.fill.kind==="solid"?T.fill={...T.fill,opacity:0}:T.fill={...T.fill,opacity:0}:T.opacity=0,f.push(T)}else if(t>=E)f.push(b);else{const T=(t-x)/Math.max(1e-6,E-x),w=Pn(Math.min(1,T)),S=u.x*(1-w),_=u.y*(1-w),A={...b,x:b.x+S,y:b.y+_};if(b.op==="FillPath"){const M=A.fill.kind==="solid"?A.fill.opacity:A.fill.opacity??1;A.fill.kind==="solid"?A.fill={...A.fill,opacity:M*w}:A.fill={...A.fill,opacity:M*w}}else A.opacity=A.opacity*w;f.push(A)}In(b)&&y++}return f}function A1(s,e,t,r,i,n){const a=r==="word";if(!a&&!(r==="character")){const g=oo(t),y=.95+.05*g;return F1(s,g,y)}const c=a?ms(e):[],u=e.reduce((g,y)=>g+y.glyphs.length,0),h=a?c.length:u;if(h===0)return s;const l=[];for(const g of s)if(g.op==="BeginFrame"){l.push(g);break}const d=.3,p=n*.7/Math.max(1,h-1),m=g=>{const y=g*p,b=y/n,k=Math.min(1,(y+d)/n);return{startF:b,endF:k}};let v=0;for(const g of s){if(g.op!=="FillPath"&&g.op!=="StrokePath"){g.op==="DecorationLine"&&t>.8&&l.push(g);continue}let y;if(!a)y=v;else{let x=-1,E=0;for(let T=0;T<c.length;T++){const w=c[T].glyphCount;if(v>=E&&v<E+w){x=T;break}E+=w}y=Math.max(0,x)}const{startF:b,endF:k}=m(y);if(t<=b){const x={...g};g.op==="FillPath"?x.fill.kind==="solid"?x.fill={...x.fill,opacity:0}:x.fill={...x.fill,opacity:0}:x.opacity=0,l.push(x)}else if(t>=k)l.push(g);else{const x=(t-b)/Math.max(1e-6,k-b),E=oo(Math.min(1,x)),T={...g};if(g.op==="FillPath"){const w=T.fill.kind==="solid"?T.fill.opacity:T.fill.opacity??1;T.fill.kind==="solid"?T.fill={...T.fill,opacity:w*E}:T.fill={...T.fill,opacity:w*E}}else T.opacity=T.opacity*E;l.push(T)}In(g)&&v++}return l}function I1(s,e,t,r,i,n,a){const o=n==="word";if(!o&&!(n==="character")){const k=Pn(t),x=D1(1-k,r,i*2),E=oo(t);return R1(s,x.dx,x.dy,E)}const h={left:{x:i*2,y:0},right:{x:-i*2,y:0},up:{x:0,y:i*2},down:{x:0,y:-i*2}}[r],l=o?ms(e):[],d=e.reduce((k,x)=>k+x.glyphs.length,0),f=o?l.length:d;if(f===0)return s;const p=[];for(const k of s)if(k.op==="BeginFrame"){p.push(k);break}const m=.3,g=a*.7/Math.max(1,f-1),y=k=>{const x=k*g,E=x/a,T=Math.min(1,(x+m)/a);return{startF:E,endF:T}};let b=0;for(const k of s){if(k.op!=="FillPath"&&k.op!=="StrokePath"){k.op==="DecorationLine"&&t>.8&&p.push(k);continue}let x;if(!o)x=b;else{let w=-1,S=0;for(let _=0;_<l.length;_++){const A=l[_].glyphCount;if(b>=S&&b<S+A){w=_;break}S+=A}x=Math.max(0,w)}const{startF:E,endF:T}=y(x);if(t<=E){const w={...k,x:k.x+h.x,y:k.y+h.y};k.op==="FillPath"?w.fill.kind==="solid"?w.fill={...w.fill,opacity:0}:w.fill={...w.fill,opacity:0}:w.opacity=0,p.push(w)}else if(t>=T)p.push(k);else{const w=(t-E)/Math.max(1e-6,T-E),S=Pn(Math.min(1,w)),_=h.x*(1-S),A=h.y*(1-S),M={...k,x:k.x+_,y:k.y+A};if(k.op==="FillPath"){const D=M.fill.kind==="solid"?M.fill.opacity:M.fill.opacity??1;M.fill.kind==="solid"?M.fill={...M.fill,opacity:D*S}:M.fill={...M.fill,opacity:D*S}}else M.opacity=M.opacity*S;p.push(M)}In(k)&&b++}return p}function P1(s,e,t,r){const i=r*.3;return M1(s,t,i,e)}function ms(s){const e=[];let t=0;for(let r=0;r<s.length;r++){const i=s[r],n=O1(i);for(const a of n)a.length>0&&e.push({startGlyph:t,glyphCount:a.length,lineIndex:r}),t+=a.length}return e}function O1(s){const e=[];let t=[];for(const r of s.glyphs)r.char===" "||r.char===" "||r.char===`
186
+ `?t.length&&(e.push([...t]),t=[]):t.push(r);return t.length&&e.push(t),e}function Fu(s,e){const t=[];let r=0,i=!1;for(const n of s){if(n.op==="BeginFrame"){t.push(n);continue}if(n.op==="FillPath"&&!An(n)){r<e&&(t.push(n),i=!0),r++;continue}if(n.op==="StrokePath"){r<e&&t.push(n);continue}if(n.op==="FillPath"&&An(n)){r<e&&t.push(n);continue}if(n.op==="DecorationLine"&&i){t.push(n);continue}}return t}function Ru(s,e,t,r){if(!(Math.floor(r*2*2)%2===0)||e===0)return s;let a=null,o=0;for(const c of s)if(c.op==="FillPath"&&!An(c)&&(o++,o===e)){a=c;break}if(a&&a.op==="FillPath"){const c=S1(s),u=a.x+t*.5,h=a.y,l={op:"DecorationLine",from:{x:u,y:h-t*.7},to:{x:u,y:h+t*.1},width:Math.max(2,t/25),color:c,opacity:1};return[...s,l]}return s}function F1(s,e,t){let r=0,i=0,n=0;return s.forEach(a=>{a.op==="FillPath"&&(r+=a.x,i+=a.y,n++)}),n>0&&(r/=n,i/=n),s.map(a=>{if(a.op==="FillPath"){const o={...a};if(o.fill.kind==="solid"?o.fill={...o.fill,opacity:o.fill.opacity*e}:o.fill={...o.fill,opacity:(o.fill.opacity??1)*e},t!==1&&n>0){const c=a.x-r,u=a.y-i;o.x=r+c*t,o.y=i+u*t}return o}if(a.op==="StrokePath"){const o={...a,opacity:a.opacity*e};if(t!==1&&n>0){const c=a.x-r,u=a.y-i;o.x=r+c*t,o.y=i+u*t}return o}return a.op==="DecorationLine"?{...a,opacity:a.opacity*e}:a})}function R1(s,e,t,r=1){return s.map(i=>{if(i.op==="FillPath"){const n={...i,x:i.x+e,y:i.y+t};return r<1&&(n.fill.kind==="solid"?n.fill={...n.fill,opacity:n.fill.opacity*r}:n.fill={...n.fill,opacity:(n.fill.opacity??1)*r}),n}return i.op==="StrokePath"?{...i,x:i.x+e,y:i.y+t,opacity:i.opacity*r}:i.op==="DecorationLine"?{...i,from:{x:i.from.x+e,y:i.from.y+t},to:{x:i.to.x+e,y:i.to.y+t},opacity:i.opacity*r}:i})}function M1(s,e,t,r){let i=0;const a=Math.min(1,r/.5);return s.map(o=>{if(o.op==="FillPath"||o.op==="StrokePath"){const c=Math.sin(i/5*Math.PI+r*Math.PI*2),u=e==="left"||e==="right"?c*t*(e==="left"?-1:1):0,h=e==="up"||e==="down"?c*t*(e==="up"?-1:1):0;if(o.op==="FillPath"){An(o)||i++;const l={...o,x:o.x+u,y:o.y+h};return l.fill.kind==="solid"?l.fill={...l.fill,opacity:l.fill.opacity*a}:l.fill={...l.fill,opacity:(l.fill.opacity??1)*a},l}return{...o,x:o.x+u,y:o.y+h,opacity:o.opacity*a}}return o})}function D1(s,e,t){const r=s*t;switch(e){case"left":return{dx:-r,dy:0};case"right":return{dx:r,dy:0};case"up":return{dx:0,dy:-r};case"down":return{dx:0,dy:r}}}function oo(s){return s*(2-s)}function Pn(s){return 1-Math.pow(1-s,3)}function gs(s,e=1){const t=/^#?([a-f0-9]{6})$/i.exec(s);if(!t)throw new Error(`Invalid color ${s}`);const r=parseInt(t[1],16),i=r>>16&255,n=r>>8&255,a=r&255;return{r:i,g:n,b:a,a:e}}function B1(s){const e=s.getContext("2d");if(!e)throw new Error("2D context unavailable");return{async render(t){const r=$1(t),i=new Map;for(const n of t){if(n.op==="BeginFrame"){const a=n.pixelRatio,o=n.width,c=n.height;if("width"in s&&"height"in s&&(s.width=Math.floor(o*a),s.height=Math.floor(c*a)),"style"in s&&(s.style.width=`${o}px`,s.style.height=`${c}px`),e.setTransform(a,0,0,a,0,0),n.clear&&e.clearRect(0,0,o,c),n.bg&&n.bg.color){const{color:u,opacity:h,radius:l}=n.bg;if(u){const d=gs(u,h);l&&l>0?(e.fillStyle=`rgba(${d.r},${d.g},${d.b},${d.a})`,L1(e,0,0,o,c,l),e.fill()):(e.fillStyle=`rgba(${d.r},${d.g},${d.b},${d.a})`,e.fillRect(0,0,o,c))}}continue}if(n.op==="FillPath"){const a=n,o=new Path2D(a.path);e.save(),e.translate(a.x,a.y);const c=a.scale??1;e.scale(c,-c);const u=a.gradientBBox??r,h={x:(u.x-a.x)/c,y:-(u.y-a.y)/c,w:u.w/c,h:u.h/c},l=JSON.stringify({fill:a.fill,bbox:h});let d=i.get(l);d||(d=z1(e,a.fill,h),i.set(l,d)),e.fillStyle=d,e.fill(o),e.restore();continue}if(n.op==="StrokePath"){const a=n,o=new Path2D(a.path);e.save(),e.translate(a.x,a.y);const c=a.scale??1;e.scale(c,-c);const u=1/Math.abs(c),h=gs(a.color,a.opacity);e.strokeStyle=`rgba(${h.r},${h.g},${h.b},${h.a})`,e.lineWidth=a.width*u,e.lineJoin="round",e.lineCap="round",e.stroke(o),e.restore();continue}if(n.op==="DecorationLine"){e.save();const a=gs(n.color,n.opacity);e.strokeStyle=`rgba(${a.r},${a.g},${a.b},${a.a})`,e.lineWidth=n.width,e.beginPath(),e.moveTo(n.from.x,n.from.y),e.lineTo(n.to.x,n.to.y),e.stroke(),e.restore();continue}}}}}function L1(s,e,t,r,i,n){const a=new Path2D;a.moveTo(e+n,t),a.arcTo(e+r,t,e+r,t+i,n),a.arcTo(e+r,t+i,e,t+i,n),a.arcTo(e,t+i,e,t,n),a.arcTo(e,t,e+r,t,n),a.closePath(),s.save(),s.fill(a),s.restore()}function z1(s,e,t){if(e.kind==="solid"){const o=gs(e.color,e.opacity);return`rgba(${o.r},${o.g},${o.b},${o.a})`}const r=t.x+t.w/2,i=t.y+t.h/2,n=Math.max(t.w,t.h)/2,a=o=>{const c=e.kind==="linear"||e.kind==="radial"?e.opacity:1,u=e.kind==="linear"||e.kind==="radial"?e.stops:[];for(const h of u){const l=gs(h.color,c);o.addColorStop(h.offset,`rgba(${l.r},${l.g},${l.b},${l.a})`)}return o};if(e.kind==="linear"){const o=e.angle*Math.PI/180,c=r+Math.cos(o+Math.PI)*n,u=i+Math.sin(o+Math.PI)*n,h=r+Math.cos(o)*n,l=i+Math.sin(o)*n;return a(s.createLinearGradient(c,u,h,l))}else return a(s.createRadialGradient(r,i,0,r,i,n))}function $1(s){let e=1/0,t=1/0,r=-1/0,i=-1/0;for(const n of s){if(n.op!=="FillPath")continue;const a=n;if(a.isShadow)continue;const o=N1(a.path),c=a.scale??1,u=a.x+c*o.x,h=a.x+c*(o.x+o.w),l=a.y-c*(o.y+o.h),d=a.y-c*o.y;u<e&&(e=u),l<t&&(t=l),h>r&&(r=h),d>i&&(i=d)}return e===1/0?{x:0,y:0,w:1,h:1}:{x:e,y:t,w:Math.max(1,r-e),h:Math.max(1,i-t)}}function N1(s){const e=U1(s);let t=0,r=1/0,i=1/0,n=-1/0,a=-1/0;const o=(c,u)=>{c<r&&(r=c),u<i&&(i=u),c>n&&(n=c),u>a&&(a=u)};for(;t<e.length;)switch(e[t++]){case"M":case"L":{const u=parseFloat(e[t++]),h=parseFloat(e[t++]);o(u,h);break}case"C":{const u=parseFloat(e[t++]),h=parseFloat(e[t++]),l=parseFloat(e[t++]),d=parseFloat(e[t++]),f=parseFloat(e[t++]),p=parseFloat(e[t++]);o(u,h),o(l,d),o(f,p);break}case"Q":{const u=parseFloat(e[t++]),h=parseFloat(e[t++]),l=parseFloat(e[t++]),d=parseFloat(e[t++]);o(u,h),o(l,d);break}}return r===1/0?{x:0,y:0,w:0,h:0}:{x:r,y:i,w:n-r,h:a-i}}function U1(s){return s.match(/[MLCQZ]|-?\d*\.?\d+(?:e[-+]?\d+)?/gi)??[]}async function ys(s){try{const e=await fetch(s);if(!e.ok)throw new Error(`Failed to fetch ${s}: ${e.status} ${e.statusText}`);try{return await e.arrayBuffer()}catch(t){throw new Error(`Failed to read response body as ArrayBuffer from ${s}: ${t instanceof Error?t.message:String(t)}`)}}catch(e){throw e instanceof Error?e.message.includes("Failed to fetch")||e.message.includes("Failed to read")?e:new Error(`Failed to fetch ${s}: ${e.message}`):new Error(`Failed to fetch ${s}: ${String(e)}`)}}var Mu="https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Mu4mxP.ttf";async function H1(s={}){const e=s.width??at.DEFAULTS.width,t=s.height??at.DEFAULTS.height,r=s.pixelRatio??at.DEFAULTS.pixelRatio,i="https://shotstack-ingest-api-dev-sources.s3.ap-southeast-2.amazonaws.com/euo5r93oyr/zzz01k9h-yycyx-2x2y6-qx9bj-7n567b/source.wasm",n=new Ou(i),a=new y1(n);try{Ou.setFallbackLoader(async c=>{const u=(c.family??"Roboto").toLowerCase(),h=`${c.weight??"400"}`;if(u==="roboto"&&h==="400")return ys(Mu)}),await n.init()}catch(c){throw new Error(`Failed to initialize font registry: ${c instanceof Error?c.message:String(c)}`)}async function o(c){try{if(c.customFonts)for(const d of c.customFonts)try{const f=await ys(d.src);await n.registerFromBytes(f,{family:d.family,weight:d.weight??"400"})}catch(f){throw new Error(`Failed to load custom font "${d.family}" from ${d.src}: ${f instanceof Error?f.message:String(f)}`)}const u=c.font??{family:"Roboto",weight:"400",size:48,color:"#000000",opacity:1},h={family:u.family,weight:`${u.weight}`};return await(async()=>{try{await n.getFace(h)}catch{if((u.family||"Roboto").toLowerCase()==="roboto"&&`${u.weight}`=="400"){const f=await ys(Mu);await n.registerFromBytes(f,{family:"Roboto",weight:"400"})}else throw new Error(`Font not registered for ${h.family}__${h.weight}`)}})(),u}catch(u){throw u instanceof Error?u:new Error(`Failed to ensure fonts: ${String(u)}`)}}return{validate(c){try{const{value:u,error:h}=u1.validate(c,{abortEarly:!1,convert:!0});if(h)throw h;return{value:u}}catch(u){throw u instanceof Error?new Error(`Validation failed: ${u.message}`):new Error(`Validation failed: ${String(u)}`)}},async registerFontFromUrl(c,u){try{const h=await ys(c);await n.registerFromBytes(h,u)}catch(h){throw new Error(`Failed to register font "${u.family}" from URL ${c}: ${h instanceof Error?h.message:String(h)}`)}},async registerFontFromFile(c,u){try{let h;if(typeof c=="string")try{h=await ys(c)}catch(l){throw new Error(`Failed to fetch font from ${c}: ${l instanceof Error?l.message:String(l)}`)}else try{h=await c.arrayBuffer()}catch(l){throw new Error(`Failed to read Blob as ArrayBuffer: ${l instanceof Error?l.message:String(l)}`)}await n.registerFromBytes(h,u)}catch(h){throw h instanceof Error?h:new Error(`Failed to register font "${u.family}" from ${typeof c=="string"?c:"Blob"}: ${String(h)}`)}},async renderFrame(c,u,h){try{const l=await o(c),d={family:l.family,weight:`${l.weight}`};let f;try{const b={family:"NotoEmoji",weight:"400"};let k=!1;try{await n.getFace(b),k=!0}catch{}f=await a.layout({text:c.text,width:c.width??e,letterSpacing:c.style?.letterSpacing??0,fontSize:l.size,lineHeight:c.style?.lineHeight??1.2,desc:d,textTransform:c.style?.textTransform??"none",emojiFallback:k?b:void 0})}catch(b){throw new Error(`Failed to layout text: ${b instanceof Error?b.message:String(b)}`)}const p={x:0,y:0,width:c.width??e,height:c.height??t},m=c.width??e,v=c.height??t,g=c.pixelRatio??r;let y;try{y=await w1({canvas:{width:m,height:v,pixelRatio:g},textRect:p,lines:f,font:{family:l.family,size:l.size,weight:`${l.weight}`,color:l.color,opacity:l.opacity},style:{lineHeight:c.style?.lineHeight??1.2,textDecoration:c.style?.textDecoration??"none",gradient:c.style?.gradient},stroke:c.stroke,shadow:c.shadow,align:{horizontal:c.align?.horizontal??"center",vertical:c.align?.vertical??"middle"},background:c.background,glyphPathProvider:(b,k)=>n.glyphPath(k||d,b),getUnitsPerEm:b=>n.getUnitsPerEm(b||d)})}catch(b){throw new Error(`Failed to build draw operations: ${b instanceof Error?b.message:String(b)}`)}try{return k1(y,f,{t:u,fontSize:l.size,clipDuration:h,anim:c.animation?{preset:c.animation.preset,speed:c.animation.speed,duration:c.animation.duration,style:c.animation.style,direction:c.animation.direction}:void 0})}catch(b){throw new Error(`Failed to apply animation: ${b instanceof Error?b.message:String(b)}`)}}catch(l){throw l instanceof Error?l:new Error(`Failed to render frame at time ${u}s: ${String(l)}`)}},createRenderer(c){try{return B1(c)}catch(u){throw new Error(`Failed to create renderer: ${u instanceof Error?u.message:String(u)}`)}},destroy(){try{n.destroy()}catch(c){console.error(`Error during cleanup: ${c instanceof Error?c.message:String(c)}`)}}}}const Du=s=>{const t=(s.split("/").pop()||"").replace(/\.(ttf|otf|woff|woff2)$/i,""),r=t.replace(/-(Bold|Light|Regular|Italic|Medium|SemiBold|Black|Thin|ExtraLight|ExtraBold|Heavy)$/i,"");return{full:t,base:r}};class V1 extends ut{textEngine=null;renderer=null;canvas=null;texture=null;sprite=null;lastRenderedTime=-1;cachedFrames=new Map;isRendering=!1;targetFPS=30;validatedAsset=null;createFontMapping(){const e=new Map;return e.set("Arapey","/assets/fonts/Arapey-Regular.ttf"),e.set("ClearSans","/assets/fonts/ClearSans-Regular.ttf"),e.set("Clear Sans","/assets/fonts/ClearSans-Regular.ttf"),e.set("DidactGothic","/assets/fonts/DidactGothic-Regular.ttf"),e.set("Didact Gothic","/assets/fonts/DidactGothic-Regular.ttf"),e.set("Montserrat","/assets/fonts/Montserrat-SemiBold.ttf"),e.set("MovLette","/assets/fonts/MovLette.ttf"),e.set("OpenSans","/assets/fonts/OpenSans-Bold.ttf"),e.set("Open Sans","/assets/fonts/OpenSans-Bold.ttf"),e.set("PermanentMarker","/assets/fonts/PermanentMarker-Regular.ttf"),e.set("Permanent Marker","/assets/fonts/PermanentMarker-Regular.ttf"),e.set("Roboto","/assets/fonts/Roboto-BlackItalic.ttf"),e.set("SueEllenFrancisco","/assets/fonts/SueEllenFrancisco.ttf"),e.set("Sue Ellen Francisco","/assets/fonts/SueEllenFrancisco.ttf"),e.set("UniNeue","/assets/fonts/UniNeue-Bold.otf"),e.set("Uni Neue","/assets/fonts/UniNeue-Bold.otf"),e.set("WorkSans","/assets/fonts/WorkSans-Light.ttf"),e.set("Work Sans","/assets/fonts/WorkSans-Light.ttf"),e}async load(){await super.load();const e=this.clipConfiguration.asset;try{const t=this.edit.getEdit();if(this.targetFPS=t?.output?.fps||30,e.width=e.width||this.edit.size.width,e.height=e.height||this.edit.size.height,e.pixelRatio=e.pixelRatio||2,e.cacheEnabled=e.cacheEnabled??!0,Array.isArray(t?.timeline?.fonts)&&t.timeline.fonts.length>0){const o=e.font?.family;if(o){const c=t.timeline.fonts?.find(u=>{const{full:h,base:l}=Du(u.src),d=o.toLowerCase();return h.toLowerCase()===d||l.toLowerCase()===d});c&&(e.customFonts=[{src:c.src,family:o,weight:e.font?.weight?.toString()||"400"}])}}const r=Vs.safeParse(e);if(!r.success){console.error("Rich-text asset validation failed:",r.error),this.createFallbackText(e);return}this.textEngine=await H1({width:e.width,height:e.height,pixelRatio:e.pixelRatio,fps:this.targetFPS});const{value:i}=this.textEngine.validate(e);this.validatedAsset=i;const n=this.createFontMapping();this.canvas=document.createElement("canvas"),this.canvas.width=e.width*e.pixelRatio,this.canvas.height=e.height*e.pixelRatio,this.renderer=this.textEngine.createRenderer(this.canvas);const a=t?.timeline?.fonts||[];if(a.length>0){const o=e.font?.family;if(o){const c=a.find(u=>{const{full:h,base:l}=Du(u.src),d=o.toLowerCase();return h.toLowerCase()===d||l.toLowerCase()===d});if(c)try{const u={family:o,weight:e.font?.weight?.toString()||"400"};await this.textEngine.registerFontFromUrl(c.src,u)}catch(u){console.warn(`Failed to load font ${o}:`,u)}}}else if(e.font?.family){const o=e.font.family,c=n.get(o);if(c)try{const u={family:e.font.family,weight:e.font.weight||"400"};await this.textEngine.registerFontFromFile(c,u)}catch(u){console.warn(`Failed to load local font: ${o}`,u)}else console.warn(`Font ${o} not found in local assets. Available fonts:`,Array.from(n.keys()))}await this.renderFrame(0),this.configureKeyframes()}catch(t){console.error("Failed to initialize rich text player:",t),this.cleanupResources(),this.createFallbackText(e)}}cleanupResources(){if(this.textEngine){try{this.textEngine.destroy()}catch(e){console.warn("Error destroying text engine:",e)}this.textEngine=null}this.renderer=null,this.canvas=null,this.validatedAsset=null}async renderFrame(e){if(!this.textEngine||!this.renderer||!this.canvas||!this.validatedAsset)return;const t=Math.floor(e*this.targetFPS);if(this.validatedAsset.cacheEnabled&&this.cachedFrames.has(t)){const r=this.cachedFrames.get(t);this.sprite&&this.sprite.texture!==r&&(this.sprite.texture=r),this.lastRenderedTime=e;return}try{const r=await this.textEngine.renderFrame(this.validatedAsset,e),i=this.canvas.getContext("2d");i&&i.clearRect(0,0,this.canvas.width,this.canvas.height),await this.renderer.render(r);const n=U.Texture.from(this.canvas);this.sprite?(this.texture&&!this.cachedFrames.has(t)&&this.texture.destroy(),this.sprite.texture=n):(this.sprite=new U.Sprite(n),this.sprite.scale.set(1/this.validatedAsset.pixelRatio),this.contentContainer.addChild(this.sprite)),this.texture=n,this.validatedAsset.cacheEnabled&&this.cachedFrames.size<150&&this.cachedFrames.set(t,n),this.lastRenderedTime=e}catch(r){console.error("Failed to render rich text frame:",r)}}createFallbackText(e){const t=new U.TextStyle({fontFamily:e.font?.family||"Arial",fontSize:e.font?.size||48,fill:e.font?.color||"#ffffff",align:e.align?.horizontal||"center",wordWrap:!0,wordWrapWidth:e.width||this.edit.size.width}),r=new U.Text(e.text,t),i=e.width||this.edit.size.width,n=e.height||this.edit.size.height;switch(e.align?.horizontal){case"left":r.anchor.set(0,.5),r.x=0;break;case"right":r.anchor.set(1,.5),r.x=i;break;default:r.anchor.set(.5,.5),r.x=i/2}switch(e.align?.vertical){case"top":r.anchor.set(r.anchor.x,0),r.y=0;break;case"bottom":r.anchor.set(r.anchor.x,1),r.y=n;break;default:r.anchor.set(r.anchor.x,.5),r.y=n/2}this.contentContainer.addChild(r)}renderFrameSafe(e){this.isRendering||(this.isRendering=!0,this.renderFrame(e).catch(t=>console.error("Failed to render rich text frame:",t)).finally(()=>{this.isRendering=!1}))}update(e,t){if(super.update(e,t),this.textEngine&&this.renderer&&!this.isRendering){const r=this.getCurrentTime()/1e3,a=1/(this.edit.getEdit()?.output?.fps||30);Math.abs(r-this.lastRenderedTime)>a&&this.renderFrameSafe(r)}}dispose(){super.dispose();for(const e of this.cachedFrames.values())e.destroy();this.cachedFrames.clear(),this.texture&&!this.cachedFrames.has(Math.floor(this.lastRenderedTime*this.targetFPS))&&this.texture.destroy(),this.texture=null,this.sprite&&(this.sprite.destroy(),this.sprite=null),this.canvas&&(this.canvas=null),this.textEngine&&(this.textEngine.destroy(),this.textEngine=null),this.renderer=null,this.validatedAsset=null}getSize(){const e=this.clipConfiguration.asset;return{width:e.width||this.edit.size.width,height:e.height||this.edit.size.height}}getFitScale(){return 1}updateTextContent(e){const t=this.clipConfiguration.asset;if(t.text=e,this.textEngine){const{value:r}=this.textEngine.validate(t);this.validatedAsset=r}for(const r of this.cachedFrames.values())r.destroy();this.cachedFrames.clear(),this.lastRenderedTime=-1,this.textEngine&&this.renderer&&this.renderFrameSafe(this.getCurrentTime()/1e3)}getCurrentTime(){return this.edit.playbackTime}}class j1 extends ut{shape;shapeBackground;constructor(e,t){super(e,t),this.shape=null,this.shapeBackground=null}async load(){await super.load();const e=this.clipConfiguration.asset,t=new U.Graphics,r=e.width??this.edit.size.width,i=e.height??this.edit.size.height;t.fillStyle={color:"transparent"},t.rect(0,0,r,i),t.fill();const n=new U.Graphics;switch(e.shape){case"rectangle":{const a=e.rectangle,o=r/2-a.width/2,c=i/2-a.height/2;n.rect(o,c,a.width,a.height);break}case"circle":{const a=e.circle,o=r/2,c=i/2;n.circle(o,c,a.radius);break}case"line":{const a=e.line,o=r/2-a.length/2,c=i/2-a.thickness/2;n.rect(o,c,a.length,a.thickness);break}default:console.warn("Unsupported shape asset type.");break}if(n.fillStyle={color:e.fill?.color??"#ffffff",alpha:e.fill?.opacity??1},n.fill(),e.stroke){const a=new ta({thickness:e.stroke.width,color:e.stroke.color});n.filters=[a]}this.shapeBackground=t,this.shape=n,this.contentContainer.addChild(t),t.addChild(n),this.configureKeyframes()}update(e,t){super.update(e,t)}draw(){super.draw()}dispose(){super.dispose(),this.shape?.destroy(),this.shape=null,this.shapeBackground?.destroy(),this.shapeBackground=null}getSize(){const e=this.clipConfiguration.asset;return{width:e.width??this.edit.size.width,height:e.height??this.edit.size.height}}getFitScale(){return 1}}class bs{static DEFAULT_BLINK_INTERVAL_MS=500;static DEFAULT_CURSOR_WIDTH_PX=2;static DEFAULT_CURSOR_COLOR=16777215;cursor=null;parent;textElement;clipConfig;textPosition=0;pixelX=0;pixelY=0;currentLine=0;isBlinking=!1;blinkInterval=null;blinkIntervalMs=500;width=2;color=16777215;isVisible=!0;constructor(e,t,r,i){this.parent=e,this.textElement=t,this.clipConfig=r,this.width=i?.width??bs.DEFAULT_CURSOR_WIDTH_PX,this.color=i?.color??bs.DEFAULT_CURSOR_COLOR,this.blinkIntervalMs=i?.blinkInterval??bs.DEFAULT_BLINK_INTERVAL_MS,this.textPosition=0,this.isBlinking=!1,this.isVisible=!0,this.blinkInterval=null,this.createCursor()}updatePosition(e){if(!this.cursor||!this.textElement){console.warn("TextCursor: Cannot update position, cursor not initialized");return}this.textPosition=this.validateTextPosition(e),this.calculateAndApplyPixelPosition()}setPosition(e,t){if(!this.cursor){console.warn("TextCursor: Cannot set position, cursor not initialized");return}this.pixelX=e,this.pixelY=t,this.updateGraphicsPosition()}show(){this.setVisible(!0)}hide(){this.setVisible(!1)}setVisible(e){this.isVisible=e,this.cursor&&!this.isBlinking&&(this.cursor.visible=e)}startBlinking(){if(!this.cursor){console.warn("TextCursor: Cannot start blinking, cursor not initialized");return}this.isBlinking||this.startBlinkingAnimation()}stopBlinking(){this.stopBlinkingAnimation()}setBlinkInterval(e){this.blinkIntervalMs=e,this.isBlinking&&(this.stopBlinking(),this.startBlinking())}dispose(){if(this.stopBlinkingAnimation(),this.cursor&&this.parent)try{this.parent.removeChild(this.cursor)}catch(e){console.warn("TextCursor: Error removing cursor from parent:",e)}if(this.cursor)try{this.cursor.destroy()}catch(e){console.warn("TextCursor: Error destroying cursor graphics:",e)}finally{this.cursor=null}this.textPosition=0,this.pixelX=0,this.pixelY=0,this.currentLine=0,this.isVisible=!0}createCursor(){if(!this.textElement)return;this.cursor=new U.Graphics,this.cursor.fillStyle={color:this.color};const e=this.textElement.style.fontSize;this.cursor.rect(0,0,this.width,e),this.cursor.fill(),this.parent.addChild(this.cursor),this.cursor.visible=this.isVisible}validateTextPosition(e){return this.textElement?Math.max(0,Math.min(e,this.textElement.text.length)):0}calculateAndApplyPixelPosition(){this.calculatePixelPositionFromText(),this.updateGraphicsPosition()}calculatePixelPositionFromText(){if(!this.textElement)return;const{text:e}=this.textElement,t=this.textElement.style,r=e.substring(0,this.textPosition),i=r.match(/\n/g);this.currentLine=i?i.length:0;const n=e.split(`
187
+ `),a=this.currentLine<n.length?n[this.currentLine]:"",o=r.lastIndexOf(`
188
+ `),c=o===-1?this.textPosition:this.textPosition-o-1,u=a.substring(0,c);let h;u.length>0&&u.endsWith(" ")?h=this.measureText(`${u}x`,t)-this.measureText("x",t):h=this.measureText(u,t);const l=t.lineHeight;this.pixelY=this.currentLine*l;const f=this.clipConfig.asset.alignment?.horizontal??"center";let p=h;if(f!=="left"){const m=this.measureText(a,t),v=this.textElement.width;let g=0;f==="center"?g=(v-m)/2:f==="right"&&(g=v-m),p=g+h}this.pixelX=p}updateGraphicsPosition(){this.cursor&&this.cursor.position.set(this.pixelX,this.pixelY)}startBlinkingAnimation(){!this.cursor||this.isBlinking||(this.isBlinking=!0,this.blinkInterval=window.setInterval(()=>{this.cursor&&this.isBlinking&&(this.cursor.visible=!this.cursor.visible)},this.blinkIntervalMs))}stopBlinkingAnimation(){this.blinkInterval!==null&&(window.clearInterval(this.blinkInterval),this.blinkInterval=null),this.isBlinking=!1,this.cursor&&(this.cursor.visible=this.isVisible)}measureText(e,t){const r=new U.Text(e,t),{width:i}=r;return r.destroy(),i}isInitialized(){return this.cursor!==null}getState(){return{isInitialized:this.isInitialized(),isBlinking:this.isBlinking,isVisible:this.isVisible,textPosition:this.textPosition,pixelPosition:{x:this.pixelX,y:this.pixelY},currentLine:this.currentLine}}}class On{static DEFAULT_FOCUS_DELAY_MS=50;hiddenInput=null;isFocused=!1;focusRetryCount=0;maxFocusRetries=3;focusDelay=On.DEFAULT_FOCUS_DELAY_MS;eventHandlers={};abortController=null;textChangeCallback=null;lastSyncedText="";isComposing=!1;setupInput(e,t){this.focusDelay=t?.focusDelay??On.DEFAULT_FOCUS_DELAY_MS,this.createHiddenTextarea(),this.hiddenInput&&(this.hiddenInput.value=e,this.lastSyncedText=e),this.setupEventListeners(),t?.autoFocus!==!1&&this.focusInput()}updateInputValue(e){this.hiddenInput&&(this.hiddenInput.value=e,this.lastSyncedText=e)}focusInput(){this.hiddenInput&&setTimeout(()=>{this.hiddenInput&&!this.isFocused&&(this.hiddenInput.focus(),setTimeout(()=>{!this.isFocused&&this.focusRetryCount<this.maxFocusRetries&&(this.focusRetryCount+=1,this.focusInput())},10))},this.focusDelay)}blurInput(){this.hiddenInput&&this.hiddenInput.blur()}setSelectionRange(e,t){if(!this.hiddenInput)return;const r=this.hiddenInput.value.length,i=Math.max(0,Math.min(e,r)),n=Math.max(i,Math.min(t,r));this.hiddenInput.setSelectionRange(i,n)}getCursorPosition(){return this.hiddenInput?.selectionStart||0}getValue(){return this.hiddenInput?.value||""}setTextInputHandler(e){this.textChangeCallback=e}setEventHandlers(e){this.eventHandlers={...this.eventHandlers,...e}}isFocusedInput(){return this.isFocused}dispose(){this.removeAllEventListeners(),this.hiddenInput&&this.hiddenInput.parentNode&&this.hiddenInput.parentNode.removeChild(this.hiddenInput),this.hiddenInput=null,this.isFocused=!1,this.focusRetryCount=0,this.textChangeCallback=null,this.eventHandlers={}}createHiddenTextarea(){this.hiddenInput=document.createElement("textarea");const e={position:"absolute",opacity:"0.01",pointerEvents:"none",zIndex:"999",left:"0px",top:"0px",width:"1px",height:"1px",border:"none",outline:"none",resize:"none",backgroundColor:"transparent"};Object.assign(this.hiddenInput.style,e),this.hiddenInput.tabIndex=0,document.body.appendChild(this.hiddenInput)}setupEventListeners(){if(!this.hiddenInput)return;this.abortController=new AbortController;const{signal:e}=this.abortController;this.hiddenInput.addEventListener("input",this.handleTextInput,{signal:e}),this.hiddenInput.addEventListener("keydown",this.handleKeyDown,{signal:e}),this.hiddenInput.addEventListener("compositionstart",this.handleCompositionStart,{signal:e}),this.hiddenInput.addEventListener("compositionend",this.handleCompositionEnd,{signal:e}),this.hiddenInput.addEventListener("focus",this.handleFocus,{signal:e}),this.hiddenInput.addEventListener("blur",this.handleBlur,{signal:e}),this.hiddenInput.addEventListener("paste",this.handlePaste,{signal:e})}removeAllEventListeners(){this.abortController?.abort(),this.abortController=null}handleTextInput=e=>{if(!this.hiddenInput||this.isComposing)return;const t=this.hiddenInput.value,r=this.hiddenInput.selectionStart||0;this.lastSyncedText=t,this.textChangeCallback?.(t,r)};handleKeyDown=e=>{if(document.activeElement!==this.hiddenInput)return;let t=!1;if((e.ctrlKey||e.metaKey)&&(t=this.handleKeyboardShortcuts(e),t)){e.preventDefault();return}if(e.key==="Tab"){const r=e.shiftKey?"backward":"forward";this.eventHandlers.onTabNavigation?.(r),e.preventDefault();return}switch(e.key){case"Escape":this.eventHandlers.onEscape?.(e),t=!0;break;case"Enter":t=!1;break;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":setTimeout(()=>{if(this.hiddenInput){const r=this.hiddenInput.value,i=this.hiddenInput.selectionStart||0;this.textChangeCallback?.(r,i)}},0),t=!1;break;case"Backspace":case"Delete":t=!1;break;default:t=this.eventHandlers.onCustomKey?.(e.key,e)||!1;break}t&&e.preventDefault()};handleKeyboardShortcuts(e){const{key:t}=e;switch(t.toLowerCase()){case"a":return this.selectAll(),!0;case"c":case"v":return!1;case"z":return this.eventHandlers.onCustomKey?.("undo",e),!0;case"y":return this.eventHandlers.onCustomKey?.("redo",e),!0;default:return!1}}handleCompositionStart=e=>{this.isComposing=!0};handleCompositionEnd=e=>{if(this.isComposing=!1,this.hiddenInput){const t=this.hiddenInput.value,r=this.hiddenInput.selectionStart||0;this.textChangeCallback?.(t,r)}};handleFocus=e=>{this.isFocused=!0,this.focusRetryCount=0,this.eventHandlers.onFocus?.(e)};handleBlur=e=>{this.isFocused=!1,this.eventHandlers.onBlur?.(e)};handlePaste=e=>{setTimeout(()=>{this.handleTextInput(e)},0)};selectAll(){this.hiddenInput&&this.hiddenInput.select()}}class rr{static DOUBLE_CLICK_THRESHOLD_MS=300;static EDITING_BG_PADDING_PX=5;static EDITING_BG_ALPHA=.2;static CLICK_HANDLER_DELAY_MS=100;parent;targetText;clipConfig;isEditing=!1;lastClickTime=0;editingContainer=null;editableText=null;textCursor=null;textInputHandler=null;outsideClickHandler=null;constructor(e,t,r){this.parent=e,this.targetText=t,this.clipConfig=r,this.parent.getContainer().eventMode="static",this.parent.getContainer().on("click",this.checkForDoubleClick)}dispose(){this.parent.getContainer().off("click",this.checkForDoubleClick),this.stopEditing(),this.outsideClickHandler&&(window.removeEventListener("click",this.outsideClickHandler),this.outsideClickHandler=null)}startEditing(){if(this.isEditing||!this.targetText)return;const e=structuredClone(this.clipConfig);this.targetText.visible=!1,this.createEditingEnvironment(),this.setupOutsideClickHandler(e),this.isEditing=!0}stopEditing(e=!1,t){if(!this.isEditing)return;let r="";this.editableText&&(r=this.editableText.text),this.editingContainer&&(this.parent.getContainer().removeChild(this.editingContainer),this.editingContainer.destroy(),this.editingContainer=null),this.editableText=null,this.textCursor&&(this.textCursor.dispose(),this.textCursor=null),this.textInputHandler&&(this.textInputHandler.dispose(),this.textInputHandler=null),this.targetText.visible=!0,e&&t&&r!==""&&this.parent.updateTextContent(r,t),this.isEditing=!1}checkForDoubleClick=e=>{const t=Date.now();t-this.lastClickTime<rr.DOUBLE_CLICK_THRESHOLD_MS&&this.startEditing(),this.lastClickTime=t};setupOutsideClickHandler(e){this.outsideClickHandler=t=>{const i=this.parent.getContainer().getBounds(),n=t.clientX,a=t.clientY;(n<i.x||n>i.x+i.width||a<i.y||a>i.y+i.height)&&(this.stopEditing(!0,e),this.outsideClickHandler&&(window.removeEventListener("click",this.outsideClickHandler),this.outsideClickHandler=null))},setTimeout(()=>{this.outsideClickHandler&&window.addEventListener("click",this.outsideClickHandler)},rr.CLICK_HANDLER_DELAY_MS)}createEditingEnvironment(){this.setupEditingContainer(),this.editingContainer&&this.editableText&&(this.textCursor=new bs(this.editingContainer,this.editableText,this.clipConfig),this.textCursor.updatePosition(this.targetText.text.length),this.textCursor.startBlinking()),this.setupTextInputHandler(),this.updateTextAlignment()}setupEditingContainer(){this.editingContainer=new U.Container,this.parent.getContainer().addChild(this.editingContainer);const e=new U.Graphics;e.fillStyle={color:0,alpha:rr.EDITING_BG_ALPHA},e.rect(-5,-5,this.targetText.width+2*rr.EDITING_BG_PADDING_PX,this.targetText.height+2*rr.EDITING_BG_PADDING_PX),e.fill(),this.editingContainer.addChild(e),this.editableText=new U.Text(this.targetText.text,this.targetText.style),this.editableText.eventMode="static",this.editableText.cursor="text",this.editingContainer.addChild(this.editableText)}setupTextInputHandler(){this.textInputHandler=new On,this.textInputHandler.setTextInputHandler((e,t)=>{this.editableText&&(this.editableText.text=e,this.updateTextAlignment()),this.textCursor?.updatePosition(t)}),this.textInputHandler.setEventHandlers({onEscape:e=>this.stopEditing(!1),onTabNavigation:e=>this.stopEditing(!0)}),this.textInputHandler.setupInput(this.targetText.text,{autoFocus:!0})}updateTextAlignment(){if(!this.editableText||!this.editingContainer)return;const e=this.getContainerDimensions(),t=this.getAlignmentSettings(),r=this.calculateHorizontalPosition({width:this.editableText.width},e,t.horizontal),i=this.calculateVerticalPosition({height:this.editableText.height},e,t.vertical);if(this.editingContainer.position.set(r,i),this.editingContainer.children.length>0){const n=this.editingContainer.getChildAt(0);n instanceof U.Graphics&&(n.clear(),n.fillStyle={color:0,alpha:rr.EDITING_BG_ALPHA},n.rect(-5,-5,this.editableText.width+2*rr.EDITING_BG_PADDING_PX,this.editableText.height+2*rr.EDITING_BG_PADDING_PX),n.fill())}}calculateHorizontalPosition(e,t,r="center"){switch(r){case"center":return t.width/2-e.width/2;case"right":return t.width-e.width;case"left":default:return 0}}calculateVerticalPosition(e,t,r="center"){switch(r){case"center":return t.height/2-e.height/2;case"bottom":return t.height-e.height;case"top":default:return 0}}getContainerDimensions(){const e=this.clipConfig.asset;return{width:e.width??this.parent.getSize().width,height:e.height??this.parent.getSize().height}}getAlignmentSettings(){const e=this.clipConfig.asset;return{horizontal:e.alignment?.horizontal??"center",vertical:e.alignment?.vertical??"center"}}}class W1 extends ut{background=null;text=null;textEditor=null;async load(){await super.load();const e=this.clipConfiguration.asset;if(this.background=new U.Graphics,e.background&&(this.background.fillStyle={color:e.background.color,alpha:e.background.opacity},this.background.rect(0,0,e.width??this.edit.size.width,e.height??this.edit.size.height),this.background.fill()),this.text=new U.Text(e.text,this.createTextStyle(e)),this.positionText(e),e.stroke){const t=new ta({thickness:e.stroke.width,color:e.stroke.color});this.text.filters=[t]}this.contentContainer.addChild(this.background),this.contentContainer.addChild(this.text),this.configureKeyframes(),this.textEditor=new rr(this,this.text,this.clipConfiguration)}update(e,t){super.update(e,t)}dispose(){super.dispose(),this.background?.destroy(),this.background=null,this.text?.destroy(),this.text=null,this.textEditor?.dispose(),this.textEditor=null}getSize(){const e=this.clipConfiguration.asset;return{width:e.width??this.edit.size.width,height:e.height??this.edit.size.height}}getFitScale(){return 1}createTextStyle(e){return new U.TextStyle({fontFamily:e.font?.family??"Open Sans",fontSize:e.font?.size??32,fill:e.font?.color??"#ffffff",fontWeight:(e.font?.weight??"400").toString(),wordWrap:!0,wordWrapWidth:e.width??this.edit.size.width,lineHeight:(e.font?.lineHeight??1)*(e.font?.size??32),align:e.alignment?.horizontal??"center"})}positionText(e){if(!this.text)return;const t=e.alignment?.horizontal??"center",r=e.alignment?.vertical??"center",i=e.width??this.edit.size.width,n=e.height??this.edit.size.height;let a=i/2-this.text.width/2,o=n/2-this.text.height/2;t==="left"?a=0:t==="right"&&(a=i-this.text.width),r==="top"?o=0:r==="bottom"&&(o=n-this.text.height),this.text.position.set(a,o)}updateTextContent(e,t){this.edit.updateTextContent(this,e,t)}}class G1 extends ut{texture;sprite;isPlaying;originalSize;volumeKeyframeBuilder;syncTimer;skipVideoUpdate;constructor(e,t){super(e,t),this.texture=null,this.sprite=null,this.isPlaying=!1,this.originalSize=null;const r=this.clipConfiguration.asset;this.volumeKeyframeBuilder=new gt(r.volume??1,this.getLength()),this.syncTimer=0,this.skipVideoUpdate=!1}async load(){await super.load();const e=this.clipConfiguration.asset,t=e.src;if(t.endsWith(".mov")||t.endsWith(".webm"))throw new Error(`Video source '${e.src}' is not supported. .mov and .webm files are currently not supported.`);const r={src:t,data:{autoPlay:!1,muted:!1}},i=await this.edit.assetLoader.load(t,r);if(!(i?.source instanceof U.VideoSource))throw new Error(`Invalid video source '${e.src}'.`);this.texture=this.createCroppedTexture(i),this.sprite=new U.Sprite(this.texture),this.contentContainer.addChild(this.sprite),this.clipConfiguration.width&&this.clipConfiguration.height&&this.applyFixedDimensions(),this.configureKeyframes()}update(e,t){if(super.update(e,t),this.skipVideoUpdate)return;const{trim:r=0}=this.clipConfiguration.asset;if(this.syncTimer+=t,!this.texture)return;const i=this.getPlaybackTime(),n=this.edit.isPlaying&&this.isActive();n&&(this.isPlaying||(this.isPlaying=!0,this.texture.source.resource.currentTime=i/1e3+r,this.texture.source.resource.play().catch(console.error)),this.texture.source.resource.volume!==this.getVolume()&&(this.texture.source.resource.volume=this.getVolume()),Math.abs((this.texture.source.resource.currentTime-r)*1e3-i)>100&&(this.texture.source.resource.currentTime=i/1e3+r)),!n&&this.isPlaying&&(this.isPlaying=!1,this.texture.source.resource.pause());const a=this.syncTimer>100;!this.edit.isPlaying&&this.isActive()&&a&&(this.syncTimer=0,this.texture.source.resource.currentTime=i/1e3+r)}draw(){super.draw()}dispose(){super.dispose(),this.sprite?.destroy(),this.sprite=null,this.texture?.destroy(),this.texture=null,this.originalSize=null}getSize(){return this.clipConfiguration.width&&this.clipConfiguration.height?{width:this.clipConfiguration.width,height:this.clipConfiguration.height}:{width:this.sprite?.width??0,height:this.sprite?.height??0}}getVolume(){return this.volumeKeyframeBuilder.getValue(this.getPlaybackTime())}createCroppedTexture(e){const t=this.clipConfiguration.asset;if(!t.crop)return e;const r=e.width,i=e.height,n=Math.floor((t.crop?.left??0)*r),a=Math.floor((t.crop?.right??0)*r),o=Math.floor((t.crop?.top??0)*i),c=Math.floor((t.crop?.bottom??0)*i),u=n,h=o,l=r-n-a,d=i-o-c,f=new U.Rectangle(u,h,l,d);return new U.Texture({source:e.source,frame:f})}}const Bu=yt(["linear","bezier","constant"]),Lu=yt(["ease","easeIn","easeOut","easeInOut","easeInQuad","easeInCubic","easeInQuart","easeInQuint","easeInSine","easeInExpo","easeInCirc","easeInBack","easeOutQuad","easeOutCubic","easeOutQuart","easeOutQuint","easeOutSine","easeOutExpo","easeOutCirc","easeOutBack","easeInOutQuad","easeInOutCubic","easeInOutQuart","easeInOutQuint","easeInOutSine","easeInOutExpo","easeInOutCirc","easeInOutBack"]),$r=_e({from:Q(),to:Q(),start:Q().min(0),length:Q().positive(),interpolation:Bu.optional(),easing:Lu.optional()}),zu=Qe().url("Invalid audio url format."),$u=$r.extend({from:Q().min(0).max(1),to:Q().min(0).max(1)}).array().or(Q().min(0).max(1)),lo=_e({type:Er("audio"),src:zu,trim:Q().optional(),volume:$u.optional()}),q1=yt(["top","topRight","right","bottomRight","bottom","bottomLeft","left","topLeft","center"]),co=_e({type:Er("html"),html:Qe(),css:Qe(),width:Q().positive().optional(),height:Q().positive().optional(),position:q1.optional()}),Nu=Qe().url("Invalid image url format."),Uu=_e({top:Q().min(0).optional(),right:Q().min(0).optional(),bottom:Q().min(0).optional(),left:Q().min(0).optional()}),uo=_e({type:Er("image"),src:Nu,crop:Uu.optional()}),Hu=Qe().url("Invalid luma url format."),ho=_e({type:Er("luma"),src:Hu}),fo=Qe().regex(/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})|transparent$/,"Invalid color format."),po=_e({width:Q().positive(),height:Q().positive()}),mo=_e({radius:Q().positive()}),go=_e({length:Q().positive(),thickness:Q().positive()}),Vu=_e({color:fo,opacity:Q().min(0).max(1)}),ju=_e({color:fo,width:Q().positive()}),yo=_e({type:Er("shape"),width:Q().positive().optional(),height:Q().positive().optional(),shape:yt(["rectangle","circle","line"]),fill:Vu.optional(),stroke:ju.optional(),rectangle:po.optional(),circle:mo.optional(),line:go.optional()}).refine(s=>s.shape==="rectangle"?po.safeParse(s.rectangle):s.shape==="circle"?mo.safeParse(s.circle):s.shape==="line"?go.safeParse(s.line):!1),Fn=Qe().regex(/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})|transparent$/,"Invalid color format."),Wu=_e({color:Fn.optional(),family:Qe().optional(),size:Q().positive().optional(),weight:Q().optional(),lineHeight:Q().optional()}),Gu=_e({horizontal:yt(["left","center","right"]).optional(),vertical:yt(["top","center","bottom"]).optional()}),qu=_e({color:Fn,opacity:Q().min(0).max(1)}),Xu=_e({width:Q().positive(),color:Fn}),bo=_e({type:Er("text"),text:Qe(),width:Q().positive().optional(),height:Q().positive().optional(),font:Wu.optional(),alignment:Gu.optional(),background:qu.optional(),stroke:Xu.optional()}),Zu=Qe().url("Invalid video url format."),Ku=_e({top:Q().min(0).optional(),right:Q().min(0).optional(),bottom:Q().min(0).optional(),left:Q().min(0).optional()}),Yu=$r.extend({from:Q().min(0).max(1),to:Q().min(0).max(1)}).array().or(Q().min(0).max(1)),vo=_e({type:Er("video"),src:Zu,trim:Q().optional(),crop:Ku.optional(),volume:Yu.optional()}),Ju=ha([bo,Vs,yo,co,uo,vo,ho,lo]).refine(s=>s.type==="text"?bo.safeParse(s):s.type==="rich-text"?Vs.safeParse(s):s.type==="shape"?yo.safeParse(s):s.type==="html"?co.safeParse(s):s.type==="image"?uo.safeParse(s):s.type==="video"?vo.safeParse(s):s.type==="luma"?ho.safeParse(s):s.type==="audio"?lo.safeParse(s):!1),X1=yt(["topLeft","top","topRight","left","center","right","bottomLeft","bottom","bottomRight"]),Z1=yt(["crop","cover","contain","none"]),Fi=Q().min(-10).max(10).default(0),K1=$r.extend({from:Fi,to:Fi}).array().or(Fi),Y1=$r.extend({from:Fi,to:Fi}).array().or(Fi),J1=_e({x:K1.default(0),y:Y1.default(0)}),Q1=$r.extend({from:Q().min(0).max(1),to:Q().min(0).max(1)}).array().or(Q().min(0).max(1)),ev=$r.extend({from:Q().min(0),to:Q().min(0)}).array().or(Q().min(0)),tv=_e({angle:$r.extend({from:Q(),to:Q()}).array().or(Q())}),rv=Qe(),Qu=Qe(),iv=_e({in:Qu.optional(),out:Qu.optional()}),sv=_e({rotate:tv.default({angle:0})}),wo=_e({asset:Ju,start:Q().min(0),length:Q().positive(),position:X1.default("center").optional(),fit:Z1.optional(),offset:J1.default({x:0,y:0}).optional(),opacity:Q1.default(1).optional(),scale:ev.default(1).optional(),transform:sv.default({rotate:{angle:0}}).optional(),effect:rv.optional(),transition:iv.optional(),width:Q().min(1).max(3840).optional(),height:Q().min(1).max(2160).optional()}).transform(s=>{if(s.fit!==void 0)return s;const e=s.asset.type==="rich-text"?"none":"crop";return{...s,fit:e}});class nv{constructor(e,t){this.trackIdx=e,this.clip=t}name="addClip";addedPlayer;async execute(e){if(!e)return;const t=wo.parse(this.clip),r=e.createPlayerFromAssetType(t);r.layer=this.trackIdx+1,await e.addPlayer(this.trackIdx,r),e.updateDuration(),this.addedPlayer=r}async undo(e){!e||!this.addedPlayer||(e.queueDisposeClip(this.addedPlayer),e.updateDuration())}}class e0{constructor(e){this.trackIdx=e}name="addTrack";execute(e){if(!e)return;const t=e.getTracks(),r=e.getClips();t.splice(this.trackIdx,0,[]),r.forEach(i=>{if(i.layer>=this.trackIdx){const n=1e5-i.layer*100,a=e.getContainer().getChildByLabel(`shotstack-track-${n}`,!1);a&&a.removeChild(i.getContainer()),i.layer+=1;const o=1e5-i.layer*100;let c=e.getContainer().getChildByLabel(`shotstack-track-${o}`,!1);c||(c=new U.Container({label:`shotstack-track-${o}`,zIndex:o}),e.getContainer().addChild(c)),c.addChild(i.getContainer())}}),e.updateDuration(),e.emitEvent("track:added",{trackIndex:this.trackIdx,totalTracks:t.length})}undo(e){if(!e)return;const t=e.getTracks(),r=e.getClips();t.splice(this.trackIdx,1),r.forEach(i=>{i.layer>this.trackIdx&&(i.layer-=1)}),e.updateDuration()}}class av{name="ClearSelection";previousSelection=null;execute(e){const t=e.getSelectedClip();if(t){const r=e.findClipIndices(t);r&&(this.previousSelection={player:t,trackIndex:r.trackIndex,clipIndex:r.clipIndex})}e.setSelectedClip(null),e.emitEvent("selection:cleared",{})}undo(e){if(this.previousSelection){const t=e.getClipAt(this.previousSelection.trackIndex,this.previousSelection.clipIndex);t&&(e.setSelectedClip(t),e.emitEvent("clip:selected",{clip:t.clipConfiguration,trackIndex:this.previousSelection.trackIndex,clipIndex:this.previousSelection.clipIndex}))}}}class ov{constructor(e,t){this.trackIdx=e,this.clipIdx=t}name="deleteClip";deletedClip;execute(e){if(!e)return;const r=e.getClips().filter(i=>i.layer===this.trackIdx+1);this.deletedClip=r[this.clipIdx],this.deletedClip&&(e.queueDisposeClip(this.deletedClip),e.updateDuration())}undo(e){!e||!this.deletedClip||e.undeleteClip(this.trackIdx,this.deletedClip)}}class lv{constructor(e){this.trackIdx=e}name="deleteTrack";deletedClips=[];execute(e){if(!e)return;const t=e.getClips(),r=e.getTracks();this.deletedClips=t.filter(a=>a.layer===this.trackIdx+1).map(a=>({config:structuredClone(a.clipConfiguration)})),t.forEach((a,o)=>{a.layer===this.trackIdx+1&&(t[o].shouldDispose=!0)}),e.disposeClips(),r.splice(this.trackIdx,1);const i=e.getClips(),n=e.getContainer();i.forEach((a,o)=>{if(a.layer>this.trackIdx+1){n.getChildByLabel(`shotstack-track-${1e5-a.layer*100}`,!1)?.removeChild(a.getContainer()),i[o].layer-=1;const u=1e5-i[o].layer*100;let h=n.getChildByLabel(`shotstack-track-${u}`,!1);h||(h=new U.Container({label:`shotstack-track-${u}`,zIndex:u}),n.addChild(h)),h.addChild(i[o].getContainer())}}),e.updateDuration()}async undo(e){if(!e||this.deletedClips.length===0)return;const t=e.getTracks(),r=e.getClips();t.splice(this.trackIdx,0,[]),r.forEach((i,n)=>{i.layer>=this.trackIdx+1&&(r[n].layer+=1)});for(const{config:i}of this.deletedClips){const n=e.createPlayerFromAssetType(i);n.layer=this.trackIdx+1,await e.addPlayer(this.trackIdx,n)}e.updateDuration()}}class cv{constructor(e,t){this.trackIndex=e,this.clipIndex=t}name="SelectClip";previousSelection=null;execute(e){const t=e.getSelectedClip();if(t){const i=e.findClipIndices(t);i&&(this.previousSelection=i)}const r=e.getClipAt(this.trackIndex,this.clipIndex);r&&(e.setSelectedClip(r),e.emitEvent("clip:selected",{clip:r.clipConfiguration,trackIndex:this.trackIndex,clipIndex:this.clipIndex}))}undo(e){if(e.setSelectedClip(null),this.previousSelection){const t=e.getClipAt(this.previousSelection.trackIndex,this.previousSelection.clipIndex);t&&(e.setSelectedClip(t),e.emitEvent("clip:selected",{clip:t.clipConfiguration,trackIndex:this.previousSelection.trackIndex,clipIndex:this.previousSelection.clipIndex}))}else e.emitEvent("selection:cleared",{})}}class uv{constructor(e,t,r){this.clip=e,this.initialClipConfig=t,this.finalClipConfig=r,this.storedInitialConfig=t?structuredClone(t):null,this.storedFinalConfig=r?structuredClone(r):structuredClone(this.clip.clipConfiguration)}name="setUpdatedClip";storedInitialConfig;storedFinalConfig;execute(e){if(!e)return;this.storedFinalConfig&&e.restoreClipConfiguration(this.clip,this.storedFinalConfig),e.setUpdatedClip(this.clip);const t=this.clip.layer-1,n=e.getClips().filter(a=>a.layer===this.clip.layer).indexOf(this.clip);e.emitEvent("clip:updated",{previous:{clip:this.storedInitialConfig||this.initialClipConfig,trackIndex:t,clipIndex:n},current:{clip:this.storedFinalConfig||this.clip.clipConfiguration,trackIndex:t,clipIndex:n}})}undo(e){if(!e||!this.storedInitialConfig)return;e.restoreClipConfiguration(this.clip,this.storedInitialConfig),e.setUpdatedClip(this.clip);const t=this.clip.layer-1,n=e.getClips().filter(a=>a.layer===this.clip.layer).indexOf(this.clip);e.emitEvent("clip:updated",{previous:{clip:this.storedFinalConfig,trackIndex:t,clipIndex:n},current:{clip:this.storedInitialConfig,trackIndex:t,clipIndex:n}})}}class hv{constructor(e,t,r){this.trackIndex=e,this.clipIndex=t,this.splitTime=r}name="SplitClip";originalClipConfig=null;rightClipPlayer=null;splitSuccessful=!1;execute(e){const t=e.getClipAt(this.trackIndex,this.clipIndex);if(!t||!t.clipConfiguration)throw new Error("Cannot split clip: invalid player or clip configuration");const r=t.clipConfiguration,i=r.start||0,n=r.length,a=.1,o=this.splitTime-i;if(o<=a||o>=n-a)throw new Error("Cannot split clip: split point too close to clip boundaries");this.originalClipConfig={...r};const c={...r,length:o},u={...r,start:i+o,length:n-o};if(r.asset&&(c.asset={...r.asset},u.asset={...r.asset}),r.asset&&(r.asset.type==="video"||r.asset.type==="audio")){const f=r.asset.trim||0;c.asset&&(c.asset.type==="video"||c.asset.type==="audio")&&(c.asset.trim=f),u.asset&&(u.asset.type==="video"||u.asset.type==="audio")&&(u.asset.trim=f+o)}if(Object.assign(t.clipConfiguration,c),t.reconfigureAfterRestore(),t.draw(),this.rightClipPlayer=e.createPlayerFromAssetType(u),!this.rightClipPlayer)throw Object.assign(t.clipConfiguration,this.originalClipConfig),t.reconfigureAfterRestore(),new Error("Failed to create right clip player");this.rightClipPlayer.layer=this.trackIndex+1;const h=e.getTrack(this.trackIndex);if(!h)throw new Error("Invalid track index");h.splice(this.clipIndex+1,0,this.rightClipPlayer);const l=e.getClips(),d=l.indexOf(t);d!==-1&&l.splice(d+1,0,this.rightClipPlayer),e.addPlayerToContainer(this.trackIndex,this.rightClipPlayer),this.rightClipPlayer.reconfigureAfterRestore(),this.rightClipPlayer.load().then(()=>{this.splitSuccessful=!0,this.rightClipPlayer&&this.rightClipPlayer.draw(),e.updateDuration(),e.emitEvent("timeline:updated",{current:e.getEditState()})}).catch(f=>{console.error("Failed to load split clip:",f)})}undo(e){if(!this.originalClipConfig)return;const t=e.getClipAt(this.trackIndex,this.clipIndex);if(t){if(Object.assign(t.clipConfiguration,this.originalClipConfig),t.reconfigureAfterRestore(),this.rightClipPlayer){const r=e.getTrack(this.trackIndex);if(r){const a=r.indexOf(this.rightClipPlayer);a!==-1&&r.splice(a,1)}const i=e.getClips(),n=i.indexOf(this.rightClipPlayer);n!==-1&&i.splice(n,1),e.queueDisposeClip(this.rightClipPlayer),this.rightClipPlayer=null}e.updateDuration(),e.emitEvent("timeline:updated",{current:e.getEditState()})}}}class dv{constructor(e,t,r){this.clip=e,this.newText=t,this.initialConfig=r;const{asset:i}=this.clip.clipConfiguration;this.previousText=i&&"text"in i?i.text:""}name="updateTextContent";previousText;execute(e){if(e&&this.clip.clipConfiguration.asset&&"text"in this.clip.clipConfiguration.asset){this.clip.clipConfiguration.asset.text=this.newText;const t=this.clip.text;t&&(t.text=this.newText,this.clip.positionText(this.clip.clipConfiguration.asset)),e.setUpdatedClip(this.clip);const r=this.clip.layer-1,a=e.getClips().filter(o=>o.layer===this.clip.layer).indexOf(this.clip);e.emitEvent("clip:updated",{previous:{clip:this.initialConfig,trackIndex:r,clipIndex:a},current:{clip:this.clip.clipConfiguration,trackIndex:r,clipIndex:a}})}}undo(e){if(e&&this.clip.clipConfiguration.asset&&"text"in this.clip.clipConfiguration.asset){this.clip.clipConfiguration.asset.text=this.previousText;const t=this.clip.text;t&&(t.text=this.previousText,this.clip.positionText(this.clip.clipConfiguration.asset)),e.setUpdatedClip(this.clip);const r=this.clip.layer-1,a=e.getClips().filter(o=>o.layer===this.clip.layer).indexOf(this.clip);e.emitEvent("clip:updated",{previous:{clip:this.clip.clipConfiguration,trackIndex:r,clipIndex:a},current:{clip:this.initialConfig,trackIndex:r,clipIndex:a}})}}}class vs{events;constructor(){this.events={}}on(e,t){this.events[e]||(this.events[e]=new Set),this.events[e].add(t)}off(e,t){this.events[e]&&(this.events[e].delete(t),!(this.events[e].size>0)&&delete this.events[e])}clear(e){delete this.events[e]}emit(e,t){if(this.events[e])for(const r of this.events[e])r(t)}}class fv extends vs{registry;constructor(){super(),this.registry={}}}class Rn{static VIDEO_EXTENSIONS=[".mp4",".m4v",".webm",".ogg",".ogv"];static VIDEO_MIME={".mp4":"video/mp4",".m4v":"video/mp4",".webm":"video/webm",".ogg":"video/ogg",".ogv":"video/ogg"};loadTracker=new fv;async load(e,t){this.updateAssetLoadMetadata(e,"pending",0);try{if(await this.shouldUseSafariVideoLoader(t))return await this.loadVideoForSafari(e,t);const r=await U.Assets.load(t,i=>{this.updateAssetLoadMetadata(e,"loading",i)});return this.updateAssetLoadMetadata(e,"success",1),r}catch{return this.updateAssetLoadMetadata(e,"failed",1),null}}getProgress(){const e=Object.keys(this.loadTracker.registry);return e.length===0?0:e.reduce((r,i)=>r+this.loadTracker.registry[i].progress,0)/e.length}extractUrl(e){if(typeof e=="string")return e;const t=Array.isArray(e.src)?e.src[0]:e.src;return typeof t=="string"?t:t?.src}hasVideoExtension(e){const t=new URL(e,window.location.origin).pathname.toLowerCase();return Rn.VIDEO_EXTENSIONS.some(r=>t.endsWith(r))}async getContentType(e){try{return(await fetch(e,{method:"HEAD"})).headers.get("content-type")}catch{return null}}canPlayVideo(e){const t=new URL(e,window.location.origin).pathname.toLowerCase(),r=t.slice(t.lastIndexOf(".")),i=Rn.VIDEO_MIME[r];return i?document.createElement("video").canPlayType(i)!=="":!1}async isPlayableVideo(e){if(this.hasVideoExtension(e))return this.canPlayVideo(e);const t=await this.getContentType(e);return t?.startsWith("video/")?document.createElement("video").canPlayType(t)!=="":!1}async shouldUseSafariVideoLoader(e){const t=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),r=this.extractUrl(e);return t&&r!==void 0&&await this.isPlayableVideo(r)}async loadVideoForSafari(e,t){const r=this.extractUrl(t),i=typeof t=="object"?t.data??{}:{},n=await new Promise((a,o)=>{const c=document.createElement("video");c.crossOrigin="anonymous",c.playsInline=!0,c.muted=!0,c.preload="metadata",c.addEventListener("loadedmetadata",()=>{try{const u=new U.VideoSource({resource:c,autoPlay:i.autoPlay??!1,...i});a(new U.Texture({source:u}))}catch(u){o(u)}},{once:!0}),c.addEventListener("error",()=>o(new Error("Video loading failed")),{once:!0}),this.updateAssetLoadMetadata(e,"loading",.5),c.src=r});return this.updateAssetLoadMetadata(e,"success",1),n}updateAssetLoadMetadata(e,t,r){this.loadTracker.registry[e]?(this.loadTracker.registry[e].progress=r,this.loadTracker.registry[e].status=t):this.loadTracker.registry[e]={progress:r,status:t};const i={...this.loadTracker.registry};this.loadTracker.emit("onAssetLoadInfoUpdated",{registry:i})}}class ws{static Name="FontLoadParser";id;name;extension;validFontExtensions;woff2Decompressor;constructor(){this.id=ws.Name,this.name=ws.Name,this.extension={type:[U.ExtensionType.LoadParser],priority:U.LoaderParserPriority.High,ref:null},this.validFontExtensions=["ttf","otf","woff","woff2"],this.woff2Decompressor=null}test(e){const t=e.split("?")[0]?.split(".").pop()?.toLowerCase()??"";return this.validFontExtensions.includes(t)}async load(e,t,r){const i=e.split("?")[0]?.split(".").pop()?.toLowerCase()??"",n=await fetch(e).then(d=>d.arrayBuffer());if(i!=="woff2"){const d=Zo.parse(new Uint8Array(n).buffer),f=d.names.fontFamily.en||d.names.fontFamily[Object.keys(d.names.fontFamily)[0]],p=new FontFace(f,`url(${e})`);return await p.load(),document.fonts.add(p),p}if(await this.loadWoff2Decompressor(),!this.woff2Decompressor)throw new Error("Cannot initialize Woff2 decompressor.");const a=this.woff2Decompressor.decompress(n),o=Zo.parse(new Uint8Array(a).buffer),c=o.names.fontFamily.en||o.names.fontFamily[Object.keys(o.names.fontFamily)[0]],u=new Blob([a],{type:"font/ttf"}),h=URL.createObjectURL(u),l=new FontFace(c,`url(${h})`);return await l.load(),document.fonts.add(l),l}async loadWoff2Decompressor(){if(this.woff2Decompressor)return;const t=`${await fetch("https://unpkg.com/wawoff2@2.0.1/build/decompress_binding.js").then(r=>r.text())}; return Module`;this.woff2Decompressor=new Function(t)(),await new Promise(r=>{this.woff2Decompressor.onRuntimeInitialized=r})}unload(e){e&&document.fonts.delete(e)}}const t0=_e({clips:wo.array()}),r0=Qe().url("Invalid image url format."),i0=_e({src:r0}),s0=_e({background:Qe().optional(),fonts:i0.array().optional(),tracks:t0.array()}),n0=_e({size:_e({width:Q().positive(),height:Q().positive()}),fps:Q().positive().optional(),format:Qe()}),a0=_e({timeline:s0,output:n0});class Ri extends xr{static ZIndexPadding=100;assetLoader;events;edit;tracks;clipsToDispose;clips;commandHistory=[];commandIndex=-1;playbackTime;size;backgroundColor;totalDuration;isPlaying;selectedClip;updatedClip;viewportMask;isExporting=!1;constructor(e,t="#ffffff"){super(),this.assetLoader=new Rn,this.edit=null,this.tracks=[],this.clipsToDispose=[],this.clips=[],this.events=new vs,this.size=e,this.playbackTime=0,this.totalDuration=0,this.isPlaying=!1,this.selectedClip=null,this.updatedClip=null,this.backgroundColor=t,this.setupIntentListeners()}async load(){const e=new U.Graphics;e.fillStyle={color:this.backgroundColor},e.rect(0,0,this.size.width,this.size.height),e.fill(),this.getContainer().addChild(e),this.viewportMask=new U.Graphics,this.viewportMask.rect(0,0,this.size.width,this.size.height),this.viewportMask.fill(16777215),this.getContainer().addChild(this.viewportMask),this.getContainer().setMask({mask:this.viewportMask})}update(e,t){for(const r of this.clips)r.shouldDispose&&this.queueDisposeClip(r),r.update(e,t);this.disposeClips(),this.isPlaying&&(this.playbackTime=Math.max(0,Math.min(this.playbackTime+t,this.totalDuration)),this.playbackTime===this.totalDuration&&this.pause())}draw(){for(const e of this.clips)e.draw()}dispose(){if(this.clearClips(),this.viewportMask){try{this.getContainer().setMask(null)}catch{}this.viewportMask.destroy(),this.viewportMask=void 0}}play(){this.isPlaying=!0,this.events.emit("playback:play",{})}pause(){this.isPlaying=!1,this.events.emit("playback:pause",{})}seek(e){this.playbackTime=Math.max(0,Math.min(e,this.totalDuration)),this.pause()}stop(){this.seek(0)}async loadEdit(e){this.clearClips(),this.edit=a0.parse(e),this.backgroundColor=this.edit.timeline.background||"#000000",await Promise.all((this.edit.timeline.fonts??[]).map(async t=>{const r=t.src,i={src:r,loadParser:ws.Name};return this.assetLoader.load(r,i)}));for(const[t,r]of this.edit.timeline.tracks.entries())for(const i of r.clips){const n=this.createPlayerFromAssetType(i);n.layer=t+1,await this.addPlayer(t,n)}this.updateTotalDuration()}getEdit(){const e=this.tracks.map((t,r)=>({clips:t.filter(n=>n&&!this.clipsToDispose.includes(n)).map(n=>n.clipConfiguration)}));return{timeline:{background:this.backgroundColor,tracks:e,fonts:this.edit?.timeline.fonts||[]},output:this.edit?.output||{size:this.size,format:"mp4"}}}addClip(e,t){const r=new nv(e,t);this.executeCommand(r)}getClip(e,t){const r=this.clips.filter(i=>i.layer===e+1);return t<0||t>=r.length?null:r[t].clipConfiguration}getPlayerClip(e,t){const r=this.clips.filter(i=>i.layer===e+1);return t<0||t>=r.length?null:r[t]}deleteClip(e,t){const r=new ov(e,t);this.executeCommand(r)}splitClip(e,t,r){const i=new hv(e,t,r);this.executeCommand(i)}addTrack(e,t){const r=new e0(e);this.executeCommand(r),t?.clips?.forEach(i=>this.addClip(e,i))}getTrack(e){const t=this.clips.filter(r=>r.layer===e+1);return t.length===0?null:{clips:t.map(r=>r.clipConfiguration)}}deleteTrack(e){const t=new lv(e);this.executeCommand(t)}getTotalDuration(){return this.totalDuration}undo(){if(this.commandIndex>=0){const e=this.commandHistory[this.commandIndex];if(e.undo){const t=this.createCommandContext();e.undo(t),this.commandIndex-=1,this.events.emit("edit:undo",{command:e.name})}}}redo(){if(this.commandIndex<this.commandHistory.length-1){this.commandIndex+=1;const e=this.commandHistory[this.commandIndex],t=this.createCommandContext();e.execute(t),this.events.emit("edit:redo",{command:e.name})}}setUpdatedClip(e,t=null,r=null){const i=new uv(e,t,r);this.executeCommand(i)}updateTextContent(e,t,r){const i=new dv(e,t,r);this.executeCommand(i)}executeEditCommand(e){return this.executeCommand(e)}executeCommand(e){const t=this.createCommandContext(),r=e.execute(t);return this.commandHistory=this.commandHistory.slice(0,this.commandIndex+1),this.commandHistory.push(e),this.commandIndex+=1,r}createCommandContext(){return{getClips:()=>this.clips,getTracks:()=>this.tracks,getTrack:e=>e>=0&&e<this.tracks.length?this.tracks[e]:null,getContainer:()=>this.getContainer(),addPlayer:(e,t)=>this.addPlayer(e,t),addPlayerToContainer:(e,t)=>{this.addPlayerToContainer(e,t)},createPlayerFromAssetType:e=>this.createPlayerFromAssetType(e),queueDisposeClip:e=>this.queueDisposeClip(e),disposeClips:()=>this.disposeClips(),undeleteClip:(e,t)=>{this.clips.push(t),this.updateTotalDuration()},setUpdatedClip:e=>{this.updatedClip=e},restoreClipConfiguration:(e,t)=>{Object.assign(e.clipConfiguration,structuredClone(t)),e.reconfigureAfterRestore(),e.draw()},updateDuration:()=>this.updateTotalDuration(),emitEvent:(e,t)=>this.events.emit(e,t),findClipIndices:e=>this.findClipIndices(e),getClipAt:(e,t)=>this.getClipAt(e,t),getSelectedClip:()=>this.selectedClip,setSelectedClip:e=>{this.selectedClip=e},movePlayerToTrackContainer:(e,t,r)=>this.movePlayerToTrackContainer(e,t,r),getEditState:()=>this.getEdit()}}queueDisposeClip(e){this.clipsToDispose.push(e)}disposeClips(){if(this.clipsToDispose.length!==0){for(const e of this.clipsToDispose)this.disposeClip(e);this.clips=this.clips.filter(e=>!this.clipsToDispose.includes(e)),this.clipsToDispose=[],this.updateTotalDuration()}}disposeClip(e){try{if(this.getContainer().children.includes(e.getContainer())){const t=this.getContainer().getChildIndex(e.getContainer());this.getContainer().removeChildAt(t)}else for(const t of this.getContainer().children)if(t instanceof U.Container&&t.label?.toString().startsWith("shotstack-track-")&&t.children.includes(e.getContainer())){t.removeChild(e.getContainer());break}}catch(t){console.warn(`Attempting to unmount an unmounted clip: ${t}`)}this.unloadClipAssets(e),e.dispose()}unloadClipAssets(e){const{asset:t}=e.clipConfiguration;if(t&&"src"in t&&typeof t.src=="string")try{U.Assets.unload(t.src)}catch(r){console.warn(`Failed to unload asset: ${t.src}`,r)}}clearClips(){for(const e of this.clips)this.disposeClip(e);this.clips=[],this.clipsToDispose=[],this.updateTotalDuration()}updateTotalDuration(){let e=0;for(const r of this.tracks)for(const i of r)e=Math.max(e,i.getEnd());const t=this.totalDuration;this.totalDuration=e,t!==this.totalDuration&&this.events.emit("duration:changed",{duration:this.totalDuration})}addPlayerToContainer(e,t){const r=1e5-(e+1)*Ri.ZIndexPadding,i=`shotstack-track-${r}`;let n=this.getContainer().getChildByLabel(i,!1);n||(n=new U.Container({label:i,zIndex:r}),this.getContainer().addChild(n)),n.addChild(t.getContainer())}movePlayerToTrackContainer(e,t,r){if(t===r)return;const i=1e5-(t+1)*Ri.ZIndexPadding,n=1e5-(r+1)*Ri.ZIndexPadding,a=`shotstack-track-${i}`,o=`shotstack-track-${n}`,c=this.getContainer().getChildByLabel(a,!1);let u=this.getContainer().getChildByLabel(o,!1);u||(u=new U.Container({label:o,zIndex:n}),this.getContainer().addChild(u)),c&&c.removeChild(e.getContainer()),u.addChild(e.getContainer())}createPlayerFromAssetType(e){if(!e.asset?.type)throw new Error("Invalid clip configuration: missing asset type");let t;switch(e.asset.type){case"text":{t=new W1(this,e);break}case"rich-text":{t=new V1(this,e);break}case"shape":{t=new j1(this,e);break}case"html":{t=new Ch(this,e);break}case"image":{t=new kh(this,e);break}case"video":{t=new G1(this,e);break}case"audio":{t=new Ko(this,e);break}case"luma":{t=new Yo(this,e);break}default:throw new Error(`Unsupported clip type: ${e.asset.type}`)}return t}async addPlayer(e,t){for(;this.tracks.length<=e;)this.tracks.push([]);this.tracks[e].push(t),this.clips.push(t);const r=1e5-(e+1)*Ri.ZIndexPadding,i=`shotstack-track-${r}`;let n=this.getContainer().getChildByLabel(i,!1);n||(n=new U.Container({label:i,zIndex:r}),this.getContainer().addChild(n)),n.addChild(t.getContainer());const a=t instanceof Yo;await t.load(),a&&n.setMask({mask:t.getMask(),inverse:!0}),this.updateTotalDuration()}selectClip(e,t){const r=new cv(e,t);this.executeCommand(r)}clearSelection(){const e=new av;this.executeCommand(e)}isClipSelected(e,t){if(!this.selectedClip)return!1;const r=this.selectedClip.layer-1,i=this.tracks[r].indexOf(this.selectedClip);return e===r&&t===i}getSelectedClipInfo(){if(!this.selectedClip)return null;const e=this.selectedClip.layer-1,t=this.tracks[e].indexOf(this.selectedClip);return{trackIndex:e,clipIndex:t,player:this.selectedClip}}findClipIndices(e){for(let t=0;t<this.tracks.length;t+=1){const r=this.tracks[t].indexOf(e);if(r!==-1)return{trackIndex:t,clipIndex:r}}return null}getClipAt(e,t){return e>=0&&e<this.tracks.length&&t>=0&&t<this.tracks[e].length?this.tracks[e][t]:null}selectPlayer(e){const t=this.findClipIndices(e);t&&this.selectClip(t.trackIndex,t.clipIndex)}isPlayerSelected(e){return this.isExporting?!1:this.selectedClip===e}setExportMode(e){this.isExporting=e}isInExportMode(){return this.isExporting}setupIntentListeners(){this.events.on("timeline:clip:clicked",e=>{e.player?this.selectPlayer(e.player):this.selectClip(e.trackIndex,e.clipIndex)}),this.events.on("timeline:background:clicked",()=>{this.clearSelection()}),this.events.on("canvas:clip:clicked",e=>{this.selectPlayer(e.player)}),this.events.on("canvas:background:clicked",()=>{this.clearSelection()})}}class xs extends xr{static Width=250;static Height=100;fps;playbackTime;playbackDuration;isPlaying;background;text;constructor(){super(),this.background=null,this.text=null,this.fps=0,this.playbackTime=0,this.playbackDuration=0,this.isPlaying=!1}async load(){const e=new U.Graphics;e.fillStyle={color:"#424242",alpha:.5},e.rect(0,0,xs.Width,xs.Height),e.fill(),this.getContainer().addChild(e),this.background=e;const t=new U.Text;t.text="",t.style={fontFamily:"monospace",fontSize:14,fill:"#ffffff",wordWrap:!0,wordWrapWidth:xs.Width},this.getContainer().addChild(t),this.text=t}update(e,t){if(!this.text)return;const r=this.getMemoryInfo(),i=[`FPS: ${this.fps}`,`Playback: ${(this.playbackTime/1e3).toFixed(2)}/${(this.playbackDuration/1e3).toFixed(2)}`,`Playing: ${this.isPlaying}`,`Total Heap Size: ${r.totalHeapSize?`${this.bytesToMegabytes(r.totalHeapSize)}MB`:"N/A"}`,`Used Heap Size: ${r.usedHeapSize?`${this.bytesToMegabytes(r.usedHeapSize)}MB`:"N/A"}`,`Heap Size Limit: ${r.heapSizeLimit?`${this.bytesToMegabytes(r.heapSizeLimit)}MB`:"N/A"}`];this.text.text=i.join(`
189
+ `)}draw(){}dispose(){this.background?.destroy(),this.background=null,this.text?.destroy(),this.text=null}getMemoryInfo(){const e={};return"memory"in performance&&(e.totalHeapSize=performance.memory.totalJSHeapSize,e.usedHeapSize=performance.memory.usedJSHeapSize,e.heapSizeLimit=performance.memory.jsHeapSizeLimit),e}bytesToMegabytes(e){return Math.round(e/1024/1024)}}class oi{static CanvasSelector="[data-shotstack-studio]";static extensionsRegistered=!1;size;application;edit;inspector;container;background;timeline;minZoom=.1;maxZoom=4;currentZoom=.8;onTickBound;constructor(e,t){this.size=e,this.application=new U.Application,this.edit=t,this.inspector=new xs,this.onTickBound=this.onTick.bind(this)}async load(){const e=document.querySelector(oi.CanvasSelector);if(!e)throw new Error(`Shotstack canvas root element '${oi.CanvasSelector}' not found.`);this.registerExtensions(),this.container=new U.Container,this.background=new U.Graphics,this.background.fillStyle={color:"#424242"},this.background.rect(0,0,this.size.width,this.size.height),this.background.fill(),await this.configureApplication(),this.configureStage(),this.setupTouchHandling(e),this.edit.getContainer().scale=this.currentZoom,e.appendChild(this.application.canvas)}setupTouchHandling(e){const t=this.edit.getContainer();e.addEventListener("wheel",r=>{if(r.preventDefault(),r.stopPropagation(),r.ctrlKey){const i=Math.exp(-r.deltaY/100),n=this.currentZoom*i,a=this.currentZoom;this.currentZoom=Math.min(Math.max(n,this.minZoom),this.maxZoom);const o={x:this.application.canvas.width/2,y:this.application.canvas.height/2},c={x:t.position.x-o.x,y:t.position.y-o.y},u=this.currentZoom/a;t.position.x=o.x+c.x*u,t.position.y=o.y+c.y*u,t.scale.x=this.currentZoom,t.scale.y=this.currentZoom}},{passive:!1,capture:!0})}centerEdit(){if(!this.edit)return;const e=this.edit.getContainer();e.position={x:this.application.canvas.width/2-this.edit.size.width*this.currentZoom/2,y:this.application.canvas.height/2-this.edit.size.height*this.currentZoom/2}}zoomToFit(){if(!this.edit)return;const e=this.application.canvas.width/this.edit.size.width,t=this.application.canvas.height/this.edit.size.height,r=Math.min(e,t);this.currentZoom=Math.min(Math.max(r,this.minZoom),this.maxZoom);const i=this.edit.getContainer();i.scale.x=this.currentZoom,i.scale.y=this.currentZoom,this.centerEdit()}setZoom(e){this.currentZoom=Math.min(Math.max(e,this.minZoom),this.maxZoom);const t=this.edit.getContainer();t.scale.x=this.currentZoom,t.scale.y=this.currentZoom}registerTimeline(e){this.timeline=e}registerExtensions(){oi.extensionsRegistered||(U.extensions.add(new Wi),U.extensions.add(new ws),oi.extensionsRegistered=!0)}async configureApplication(){const e={background:"#000000",width:this.size.width,height:this.size.height,antialias:!0};await this.application.init(e),this.application.ticker.add(this.onTickBound),this.application.ticker.minFPS=60,this.application.ticker.maxFPS=60}onTick(e){this.edit.update(e.deltaTime,e.deltaMS),this.edit.draw(),this.inspector.fps=Math.ceil(e.FPS),this.inspector.playbackTime=this.edit.playbackTime,this.inspector.playbackDuration=this.edit.totalDuration,this.inspector.isPlaying=this.edit.isPlaying,this.inspector.update(e.deltaTime,e.deltaMS),this.inspector.draw(),this.timeline&&(this.timeline.update(e.deltaTime,e.deltaMS),this.timeline.draw())}configureStage(){if(!this.container||!this.background)throw new Error("Shotstack canvas container not set up.");this.container.addChild(this.background),this.container.addChild(this.edit.getContainer()),this.container.addChild(this.inspector.getContainer()),this.application.stage.addChild(this.container),this.application.stage.eventMode="static",this.application.stage.hitArea=new U.Rectangle(0,0,this.size.width,this.size.height),this.background.eventMode="static",this.background.on("pointerdown",this.onBackgroundClick.bind(this)),this.application.stage.on("click",this.onClick.bind(this)),this.edit.getContainer().position={x:this.application.canvas.width/2-this.edit.size.width*this.currentZoom/2,y:this.application.canvas.height/2-this.edit.size.height*this.currentZoom/2}}onClick(){this.edit.pause()}onBackgroundClick(e){e.target===this.background&&this.edit.events.emit("canvas:background:clicked",{})}pauseTicker(){this.application.ticker.remove(this.onTickBound)}resumeTicker(){this.application.ticker.add(this.onTickBound)}dispose(){const e=document.querySelector(oi.CanvasSelector);e&&e.contains(this.application.canvas)&&e.removeChild(this.application.canvas),this.application.ticker.remove(this.onTickBound),this.application.stage.off("click",this.onClick,this),this.background?.off("pointerdown",this.onBackgroundClick,this),this.background?.destroy(),this.container?.destroy(),this.inspector.dispose(),this.application.destroy(!0,{children:!0,texture:!0})}}class pv{edit;seekDistance=50;seekDistanceLarge=500;frameTime=16.67;constructor(e){this.edit=e}async load(){document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}dispose(){document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)}handleKeyDown=e=>{if(!(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement))switch(e.code){case"Space":{this.edit.isPlaying?this.edit.pause():this.edit.play();break}case"ArrowLeft":{if(e.metaKey)this.edit.seek(0);else{const t=e.shiftKey?this.seekDistanceLarge:this.seekDistance;this.edit.seek(this.edit.playbackTime-t)}break}case"ArrowRight":{if(e.metaKey)this.edit.seek(this.edit.getTotalDuration());else{const t=e.shiftKey?this.seekDistanceLarge:this.seekDistance;this.edit.seek(this.edit.playbackTime+t)}break}case"KeyJ":{this.edit.stop();break}case"KeyK":{this.edit.pause();break}case"KeyL":{this.edit.play();break}case"Comma":{this.edit.seek(this.edit.playbackTime-this.frameTime);break}case"Period":{this.edit.seek(this.edit.playbackTime+this.frameTime);break}case"KeyZ":{(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.shiftKey?this.edit.redo():this.edit.undo());break}case"Delete":case"Backspace":{const t=this.edit.getSelectedClipInfo();t&&(e.preventDefault(),this.edit.deleteClip(t.trackIndex,t.clipIndex));break}}};handleKeyUp=e=>{if(!(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement))switch(e.code){case"KeyI":console.log(this.edit.getEdit());break}}}class mv{name="export";clips=[];tracks=[];execute(e){this.clips=e.getClips(),this.tracks=e.getTracks()}getClips(){return this.clips}getTracks(){return this.tracks}}/*!
188
190
  * Copyright (c) 2025-present, Vanilagy and contributors
189
191
  *
190
192
  * This Source Code Form is subject to the terms of the Mozilla Public
191
193
  * License, v. 2.0. If a copy of the MPL was not distributed with this
192
194
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
193
- */function $(s){if(!s)throw new Error("Assertion failed.")}const ze=s=>s&&s[s.length-1],Ft=s=>s>=0&&s<2**32;class Yt{constructor(e){this.bytes=e,this.pos=0}seekToByte(e){this.pos=8*e}readBit(){const e=Math.floor(this.pos/8),t=this.bytes[e]??0,i=7-(this.pos&7),r=(t&1<<i)>>i;return this.pos++,r}readBits(e){if(e===1)return this.readBit();let t=0;for(let i=0;i<e;i++)t<<=1,t|=this.readBit();return t}writeBits(e,t){const i=this.pos+e;for(let r=this.pos;r<i;r++){const n=Math.floor(r/8);let o=this.bytes[n];const a=7-(r&7);o&=~(1<<a),o|=(t&1<<i-r-1)>>i-r-1<<a,this.bytes[n]=o}this.pos=i}readAlignedByte(){if(this.pos%8!==0)throw new Error("Bitstream is not byte-aligned.");const e=this.pos/8,t=this.bytes[e]??0;return this.pos+=8,t}skipBits(e){this.pos+=e}getBitsLeft(){return this.bytes.length*8-this.pos}clone(){const e=new Yt(this.bytes);return e.pos=this.pos,e}}const W=s=>{let e=0;for(;s.readBits(1)===0&&e<32;)e++;if(e>=32)throw new Error("Invalid exponential-Golomb code.");return(1<<e)-1+s.readBits(e)},Qt=s=>{const e=W(s);return e&1?e+1>>1:-(e>>1)},ot=s=>s.constructor===Uint8Array?s:s instanceof ArrayBuffer?new Uint8Array(s):new Uint8Array(s.buffer,s.byteOffset,s.byteLength),Fr=s=>s.constructor===DataView?s:s instanceof ArrayBuffer?new DataView(s):new DataView(s.buffer,s.byteOffset,s.byteLength);new TextDecoder;const He=new TextEncoder,ns=s=>Object.fromEntries(Object.entries(s).map(([e,t])=>[t,e])),vi={bt709:1,bt470bg:5,smpte170m:6,bt2020:9,smpte432:12};ns(vi);const wi={bt709:1,smpte170m:6,linear:8,"iec61966-2-1":13,pg:16,hlg:18};ns(wi);const _i={rgb:0,bt709:1,bt470bg:5,smpte170m:6,"bt2020-ncl":9};ns(_i);const el=s=>!!s&&!!s.primaries&&!!s.transfer&&!!s.matrix&&s.fullRange!==void 0,xi=s=>s instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&s instanceof SharedArrayBuffer||ArrayBuffer.isView(s);class Mr{constructor(){this.currentPromise=Promise.resolve()}async acquire(){let e;const t=new Promise(r=>{e=r}),i=this.currentPromise;return this.currentPromise=t,await i,e}}const tl=()=>{let s,e;return{promise:new Promise((i,r)=>{s=i,e=r}),resolve:s,reject:e}},as=s=>{throw new Error(`Unexpected value: ${s}`)},Lr=(s,e,t,i)=>{t=t>>>0,t=t&16777215,i?(s.setUint8(e,t&255),s.setUint8(e+1,t>>>8&255),s.setUint8(e+2,t>>>16&255)):(s.setUint8(e,t>>>16&255),s.setUint8(e+1,t>>>8&255),s.setUint8(e+2,t&255))},il=(s,e,t,i)=>{t=Se(t,-8388608,8388607),t<0&&(t=t+16777216&16777215),Lr(s,e,t,i)},Se=(s,e,t)=>Math.max(e,Math.min(t,s)),sl="und",rl=/^[a-z]{3}$/,nl=s=>rl.test(s),lt=1e6*(1+Number.EPSILON),al=(s,e)=>{const t=s<0?-1:1;s=Math.abs(s);let i=0,r=1,n=1,o=0,a=s;for(;;){const p=Math.floor(a),m=p*n+i,d=p*o+r;if(d>e)return{numerator:t*n,denominator:o};if(i=n,r=o,n=m,o=d,a=1/(a-p),!isFinite(a))break}return{numerator:t*n,denominator:o}};class Br{constructor(){this.currentPromise=Promise.resolve()}call(e){return this.currentPromise=this.currentPromise.then(e)}}let os=null;const ls=()=>os!==null?os:os=typeof navigator<"u"&&navigator.userAgent?.includes("Firefox"),$r=function*(s){for(const e in s){const t=s[e];t!==void 0&&(yield{key:e,value:t})}},ol=()=>{Symbol.dispose??=Symbol("Symbol.dispose")};/*!
195
+ */function Y(s){if(!s)throw new Error("Assertion failed.")}const ir=s=>s&&s[s.length-1],Mi=s=>s>=0&&s<2**32;class Cs{constructor(e){this.bytes=e,this.pos=0}seekToByte(e){this.pos=8*e}readBit(){const e=Math.floor(this.pos/8),t=this.bytes[e]??0,r=7-(this.pos&7),i=(t&1<<r)>>r;return this.pos++,i}readBits(e){if(e===1)return this.readBit();let t=0;for(let r=0;r<e;r++)t<<=1,t|=this.readBit();return t}writeBits(e,t){const r=this.pos+e;for(let i=this.pos;i<r;i++){const n=Math.floor(i/8);let a=this.bytes[n];const o=7-(i&7);a&=~(1<<o),a|=(t&1<<r-i-1)>>r-i-1<<o,this.bytes[n]=a}this.pos=r}readAlignedByte(){if(this.pos%8!==0)throw new Error("Bitstream is not byte-aligned.");const e=this.pos/8,t=this.bytes[e]??0;return this.pos+=8,t}skipBits(e){this.pos+=e}getBitsLeft(){return this.bytes.length*8-this.pos}clone(){const e=new Cs(this.bytes);return e.pos=this.pos,e}}const me=s=>{let e=0;for(;s.readBits(1)===0&&e<32;)e++;if(e>=32)throw new Error("Invalid exponential-Golomb code.");return(1<<e)-1+s.readBits(e)},ks=s=>{const e=me(s);return e&1?e+1>>1:-(e>>1)},Nr=s=>s.constructor===Uint8Array?s:s instanceof ArrayBuffer?new Uint8Array(s):new Uint8Array(s.buffer,s.byteOffset,s.byteLength),o0=s=>s.constructor===DataView?s:s instanceof ArrayBuffer?new DataView(s):new DataView(s.buffer,s.byteOffset,s.byteLength);new TextDecoder;const sr=new TextEncoder,xo=s=>Object.fromEntries(Object.entries(s).map(([e,t])=>[t,e])),Mn={bt709:1,bt470bg:5,smpte170m:6,bt2020:9,smpte432:12};xo(Mn);const Dn={bt709:1,smpte170m:6,linear:8,"iec61966-2-1":13,pg:16,hlg:18};xo(Dn);const Bn={rgb:0,bt709:1,bt470bg:5,smpte170m:6,"bt2020-ncl":9};xo(Bn);const gv=s=>!!s&&!!s.primaries&&!!s.transfer&&!!s.matrix&&s.fullRange!==void 0,Ln=s=>s instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&s instanceof SharedArrayBuffer||ArrayBuffer.isView(s);class l0{constructor(){this.currentPromise=Promise.resolve()}async acquire(){let e;const t=new Promise(i=>{e=i}),r=this.currentPromise;return this.currentPromise=t,await r,e}}const yv=()=>{let s,e;return{promise:new Promise((r,i)=>{s=r,e=i}),resolve:s,reject:e}},Co=s=>{throw new Error(`Unexpected value: ${s}`)},c0=(s,e,t,r)=>{t=t>>>0,t=t&16777215,r?(s.setUint8(e,t&255),s.setUint8(e+1,t>>>8&255),s.setUint8(e+2,t>>>16&255)):(s.setUint8(e,t>>>16&255),s.setUint8(e+1,t>>>8&255),s.setUint8(e+2,t&255))},bv=(s,e,t,r)=>{t=St(t,-8388608,8388607),t<0&&(t=t+16777216&16777215),c0(s,e,t,r)},St=(s,e,t)=>Math.max(e,Math.min(t,s)),vv="und",wv=/^[a-z]{3}$/,xv=s=>wv.test(s),Ur=1e6*(1+Number.EPSILON),Cv=(s,e)=>{const t=s<0?-1:1;s=Math.abs(s);let r=0,i=1,n=1,a=0,o=s;for(;;){const c=Math.floor(o),u=c*n+r,h=c*a+i;if(h>e)return{numerator:t*n,denominator:a};if(r=n,i=a,n=u,a=h,o=1/(o-c),!isFinite(o))break}return{numerator:t*n,denominator:a}};class u0{constructor(){this.currentPromise=Promise.resolve()}call(e){return this.currentPromise=this.currentPromise.then(e)}}let ko=null;const So=()=>ko!==null?ko:ko=typeof navigator<"u"&&navigator.userAgent?.includes("Firefox"),h0=function*(s){for(const e in s){const t=s[e];t!==void 0&&(yield{key:e,value:t})}},kv=()=>{Symbol.dispose??=Symbol("Symbol.dispose")};/*!
194
196
  * Copyright (c) 2025-present, Vanilagy and contributors
195
197
  *
196
198
  * This Source Code Form is subject to the terms of the Mozilla Public
197
199
  * License, v. 2.0. If a copy of the MPL was not distributed with this
198
200
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
199
- */class Dr{constructor(e,t){if(this.data=e,this.mimeType=t,!(e instanceof Uint8Array))throw new TypeError("data must be a Uint8Array.");if(typeof t!="string")throw new TypeError("mimeType must be a string.")}}class ll{constructor(e,t,i,r){if(this.data=e,this.mimeType=t,this.name=i,this.description=r,!(e instanceof Uint8Array))throw new TypeError("data must be a Uint8Array.");if(t!==void 0&&typeof t!="string")throw new TypeError("mimeType, when provided, must be a string.");if(i!==void 0&&typeof i!="string")throw new TypeError("name, when provided, must be a string.");if(r!==void 0&&typeof r!="string")throw new TypeError("description, when provided, must be a string.")}}const cl=s=>{if(!s||typeof s!="object")throw new TypeError("tags must be an object.");if(s.title!==void 0&&typeof s.title!="string")throw new TypeError("tags.title, when provided, must be a string.");if(s.description!==void 0&&typeof s.description!="string")throw new TypeError("tags.description, when provided, must be a string.");if(s.artist!==void 0&&typeof s.artist!="string")throw new TypeError("tags.artist, when provided, must be a string.");if(s.album!==void 0&&typeof s.album!="string")throw new TypeError("tags.album, when provided, must be a string.");if(s.albumArtist!==void 0&&typeof s.albumArtist!="string")throw new TypeError("tags.albumArtist, when provided, must be a string.");if(s.trackNumber!==void 0&&(!Number.isInteger(s.trackNumber)||s.trackNumber<=0))throw new TypeError("tags.trackNumber, when provided, must be a positive integer.");if(s.tracksTotal!==void 0&&(!Number.isInteger(s.tracksTotal)||s.tracksTotal<=0))throw new TypeError("tags.tracksTotal, when provided, must be a positive integer.");if(s.discNumber!==void 0&&(!Number.isInteger(s.discNumber)||s.discNumber<=0))throw new TypeError("tags.discNumber, when provided, must be a positive integer.");if(s.discsTotal!==void 0&&(!Number.isInteger(s.discsTotal)||s.discsTotal<=0))throw new TypeError("tags.discsTotal, when provided, must be a positive integer.");if(s.genre!==void 0&&typeof s.genre!="string")throw new TypeError("tags.genre, when provided, must be a string.");if(s.date!==void 0&&(!(s.date instanceof Date)||Number.isNaN(s.date.getTime())))throw new TypeError("tags.date, when provided, must be a valid Date.");if(s.lyrics!==void 0&&typeof s.lyrics!="string")throw new TypeError("tags.lyrics, when provided, must be a string.");if(s.images!==void 0){if(!Array.isArray(s.images))throw new TypeError("tags.images, when provided, must be an array.");for(const e of s.images){if(!e||typeof e!="object")throw new TypeError("Each image in tags.images must be an object.");if(!(e.data instanceof Uint8Array))throw new TypeError("Each image.data must be a Uint8Array.");if(typeof e.mimeType!="string")throw new TypeError("Each image.mimeType must be a string.");if(!["coverFront","coverBack","unknown"].includes(e.kind))throw new TypeError("Each image.kind must be 'coverFront', 'coverBack', or 'unknown'.")}}if(s.comment!==void 0&&typeof s.comment!="string")throw new TypeError("tags.comment, when provided, must be a string.");if(s.raw!==void 0){if(!s.raw||typeof s.raw!="object")throw new TypeError("tags.raw, when provided, must be an object.");for(const e of Object.values(s.raw))if(e!==null&&typeof e!="string"&&!(e instanceof Uint8Array)&&!(e instanceof Dr)&&!(e instanceof ll))throw new TypeError("Each value in tags.raw must be a string, Uint8Array, RichImageData, AttachedFile, or null.")}};/*!
201
+ */class d0{constructor(e,t){if(this.data=e,this.mimeType=t,!(e instanceof Uint8Array))throw new TypeError("data must be a Uint8Array.");if(typeof t!="string")throw new TypeError("mimeType must be a string.")}}class Sv{constructor(e,t,r,i){if(this.data=e,this.mimeType=t,this.name=r,this.description=i,!(e instanceof Uint8Array))throw new TypeError("data must be a Uint8Array.");if(t!==void 0&&typeof t!="string")throw new TypeError("mimeType, when provided, must be a string.");if(r!==void 0&&typeof r!="string")throw new TypeError("name, when provided, must be a string.");if(i!==void 0&&typeof i!="string")throw new TypeError("description, when provided, must be a string.")}}const _v=s=>{if(!s||typeof s!="object")throw new TypeError("tags must be an object.");if(s.title!==void 0&&typeof s.title!="string")throw new TypeError("tags.title, when provided, must be a string.");if(s.description!==void 0&&typeof s.description!="string")throw new TypeError("tags.description, when provided, must be a string.");if(s.artist!==void 0&&typeof s.artist!="string")throw new TypeError("tags.artist, when provided, must be a string.");if(s.album!==void 0&&typeof s.album!="string")throw new TypeError("tags.album, when provided, must be a string.");if(s.albumArtist!==void 0&&typeof s.albumArtist!="string")throw new TypeError("tags.albumArtist, when provided, must be a string.");if(s.trackNumber!==void 0&&(!Number.isInteger(s.trackNumber)||s.trackNumber<=0))throw new TypeError("tags.trackNumber, when provided, must be a positive integer.");if(s.tracksTotal!==void 0&&(!Number.isInteger(s.tracksTotal)||s.tracksTotal<=0))throw new TypeError("tags.tracksTotal, when provided, must be a positive integer.");if(s.discNumber!==void 0&&(!Number.isInteger(s.discNumber)||s.discNumber<=0))throw new TypeError("tags.discNumber, when provided, must be a positive integer.");if(s.discsTotal!==void 0&&(!Number.isInteger(s.discsTotal)||s.discsTotal<=0))throw new TypeError("tags.discsTotal, when provided, must be a positive integer.");if(s.genre!==void 0&&typeof s.genre!="string")throw new TypeError("tags.genre, when provided, must be a string.");if(s.date!==void 0&&(!(s.date instanceof Date)||Number.isNaN(s.date.getTime())))throw new TypeError("tags.date, when provided, must be a valid Date.");if(s.lyrics!==void 0&&typeof s.lyrics!="string")throw new TypeError("tags.lyrics, when provided, must be a string.");if(s.images!==void 0){if(!Array.isArray(s.images))throw new TypeError("tags.images, when provided, must be an array.");for(const e of s.images){if(!e||typeof e!="object")throw new TypeError("Each image in tags.images must be an object.");if(!(e.data instanceof Uint8Array))throw new TypeError("Each image.data must be a Uint8Array.");if(typeof e.mimeType!="string")throw new TypeError("Each image.mimeType must be a string.");if(!["coverFront","coverBack","unknown"].includes(e.kind))throw new TypeError("Each image.kind must be 'coverFront', 'coverBack', or 'unknown'.")}}if(s.comment!==void 0&&typeof s.comment!="string")throw new TypeError("tags.comment, when provided, must be a string.");if(s.raw!==void 0){if(!s.raw||typeof s.raw!="object")throw new TypeError("tags.raw, when provided, must be an object.");for(const e of Object.values(s.raw))if(e!==null&&typeof e!="string"&&!(e instanceof Uint8Array)&&!(e instanceof d0)&&!(e instanceof Sv))throw new TypeError("Each value in tags.raw must be a string, Uint8Array, RichImageData, AttachedFile, or null.")}};/*!
200
202
  * Copyright (c) 2025-present, Vanilagy and contributors
201
203
  *
202
204
  * This Source Code Form is subject to the terms of the Mozilla Public
203
205
  * License, v. 2.0. If a copy of the MPL was not distributed with this
204
206
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
205
- */const bt=["avc","hevc","vp9","av1","vp8"],Ne=["pcm-s16","pcm-s16be","pcm-s24","pcm-s24be","pcm-s32","pcm-s32be","pcm-f32","pcm-f32be","pcm-f64","pcm-f64be","pcm-u8","pcm-s8","ulaw","alaw"],zr=["aac","opus","mp3","vorbis","flac"],Mt=[...zr,...Ne],Ci=["webvtt"],Hr=[{maxMacroblocks:99,maxBitrate:64e3,level:10},{maxMacroblocks:396,maxBitrate:192e3,level:11},{maxMacroblocks:396,maxBitrate:384e3,level:12},{maxMacroblocks:396,maxBitrate:768e3,level:13},{maxMacroblocks:396,maxBitrate:2e6,level:20},{maxMacroblocks:792,maxBitrate:4e6,level:21},{maxMacroblocks:1620,maxBitrate:4e6,level:22},{maxMacroblocks:1620,maxBitrate:1e7,level:30},{maxMacroblocks:3600,maxBitrate:14e6,level:31},{maxMacroblocks:5120,maxBitrate:2e7,level:32},{maxMacroblocks:8192,maxBitrate:2e7,level:40},{maxMacroblocks:8192,maxBitrate:5e7,level:41},{maxMacroblocks:8704,maxBitrate:5e7,level:42},{maxMacroblocks:22080,maxBitrate:135e6,level:50},{maxMacroblocks:36864,maxBitrate:24e7,level:51},{maxMacroblocks:36864,maxBitrate:24e7,level:52},{maxMacroblocks:139264,maxBitrate:24e7,level:60},{maxMacroblocks:139264,maxBitrate:48e7,level:61},{maxMacroblocks:139264,maxBitrate:8e8,level:62}],Nr=[{maxPictureSize:36864,maxBitrate:128e3,tier:"L",level:30},{maxPictureSize:122880,maxBitrate:15e5,tier:"L",level:60},{maxPictureSize:245760,maxBitrate:3e6,tier:"L",level:63},{maxPictureSize:552960,maxBitrate:6e6,tier:"L",level:90},{maxPictureSize:983040,maxBitrate:1e7,tier:"L",level:93},{maxPictureSize:2228224,maxBitrate:12e6,tier:"L",level:120},{maxPictureSize:2228224,maxBitrate:3e7,tier:"H",level:120},{maxPictureSize:2228224,maxBitrate:2e7,tier:"L",level:123},{maxPictureSize:2228224,maxBitrate:5e7,tier:"H",level:123},{maxPictureSize:8912896,maxBitrate:25e6,tier:"L",level:150},{maxPictureSize:8912896,maxBitrate:1e8,tier:"H",level:150},{maxPictureSize:8912896,maxBitrate:4e7,tier:"L",level:153},{maxPictureSize:8912896,maxBitrate:16e7,tier:"H",level:153},{maxPictureSize:8912896,maxBitrate:6e7,tier:"L",level:156},{maxPictureSize:8912896,maxBitrate:24e7,tier:"H",level:156},{maxPictureSize:35651584,maxBitrate:6e7,tier:"L",level:180},{maxPictureSize:35651584,maxBitrate:24e7,tier:"H",level:180},{maxPictureSize:35651584,maxBitrate:12e7,tier:"L",level:183},{maxPictureSize:35651584,maxBitrate:48e7,tier:"H",level:183},{maxPictureSize:35651584,maxBitrate:24e7,tier:"L",level:186},{maxPictureSize:35651584,maxBitrate:8e8,tier:"H",level:186}],Ur=[{maxPictureSize:36864,maxBitrate:2e5,level:10},{maxPictureSize:73728,maxBitrate:8e5,level:11},{maxPictureSize:122880,maxBitrate:18e5,level:20},{maxPictureSize:245760,maxBitrate:36e5,level:21},{maxPictureSize:552960,maxBitrate:72e5,level:30},{maxPictureSize:983040,maxBitrate:12e6,level:31},{maxPictureSize:2228224,maxBitrate:18e6,level:40},{maxPictureSize:2228224,maxBitrate:3e7,level:41},{maxPictureSize:8912896,maxBitrate:6e7,level:50},{maxPictureSize:8912896,maxBitrate:12e7,level:51},{maxPictureSize:8912896,maxBitrate:18e7,level:52},{maxPictureSize:35651584,maxBitrate:18e7,level:60},{maxPictureSize:35651584,maxBitrate:24e7,level:61},{maxPictureSize:35651584,maxBitrate:48e7,level:62}],jr=[{maxPictureSize:147456,maxBitrate:15e5,tier:"M",level:0},{maxPictureSize:278784,maxBitrate:3e6,tier:"M",level:1},{maxPictureSize:665856,maxBitrate:6e6,tier:"M",level:4},{maxPictureSize:1065024,maxBitrate:1e7,tier:"M",level:5},{maxPictureSize:2359296,maxBitrate:12e6,tier:"M",level:8},{maxPictureSize:2359296,maxBitrate:3e7,tier:"H",level:8},{maxPictureSize:2359296,maxBitrate:2e7,tier:"M",level:9},{maxPictureSize:2359296,maxBitrate:5e7,tier:"H",level:9},{maxPictureSize:8912896,maxBitrate:3e7,tier:"M",level:12},{maxPictureSize:8912896,maxBitrate:1e8,tier:"H",level:12},{maxPictureSize:8912896,maxBitrate:4e7,tier:"M",level:13},{maxPictureSize:8912896,maxBitrate:16e7,tier:"H",level:13},{maxPictureSize:8912896,maxBitrate:6e7,tier:"M",level:14},{maxPictureSize:8912896,maxBitrate:24e7,tier:"H",level:14},{maxPictureSize:35651584,maxBitrate:6e7,tier:"M",level:15},{maxPictureSize:35651584,maxBitrate:24e7,tier:"H",level:15},{maxPictureSize:35651584,maxBitrate:6e7,tier:"M",level:16},{maxPictureSize:35651584,maxBitrate:24e7,tier:"H",level:16},{maxPictureSize:35651584,maxBitrate:1e8,tier:"M",level:17},{maxPictureSize:35651584,maxBitrate:48e7,tier:"H",level:17},{maxPictureSize:35651584,maxBitrate:16e7,tier:"M",level:18},{maxPictureSize:35651584,maxBitrate:8e8,tier:"H",level:18},{maxPictureSize:35651584,maxBitrate:16e7,tier:"M",level:19},{maxPictureSize:35651584,maxBitrate:8e8,tier:"H",level:19}],hl=(s,e,t,i)=>{if(s==="avc"){const n=Math.ceil(e/16)*Math.ceil(t/16),o=Hr.find(l=>n<=l.maxMacroblocks&&i<=l.maxBitrate)??ze(Hr),a=o?o.level:0,p="64".padStart(2,"0"),m="00",d=a.toString(16).padStart(2,"0");return`avc1.${p}${m}${d}`}else if(s==="hevc"){const r="",o="6",a=e*t,p=Nr.find(d=>a<=d.maxPictureSize&&i<=d.maxBitrate)??ze(Nr);return`hev1.${r}1.${o}.${p.tier}${p.level}.B0`}else{if(s==="vp8")return"vp8";if(s==="vp9"){const r="00",n=e*t,o=Ur.find(p=>n<=p.maxPictureSize&&i<=p.maxBitrate)??ze(Ur);return`vp09.${r}.${o.level.toString().padStart(2,"0")}.08`}else if(s==="av1"){const n=e*t,o=jr.find(m=>n<=m.maxPictureSize&&i<=m.maxBitrate)??ze(jr);return`av01.0.${o.level.toString().padStart(2,"0")}${o.tier}.08`}}throw new TypeError(`Unhandled codec '${s}'.`)},ul=s=>{const e=s.split("."),r=(1<<7)+1,n=Number(e[1]),o=e[2],a=Number(o.slice(0,-1)),p=(n<<5)+a,m=o.slice(-1)==="H"?1:0,l=Number(e[3])===8?0:1,c=0,u=e[4]?Number(e[4]):0,h=e[5]?Number(e[5][0]):1,f=e[5]?Number(e[5][1]):1,b=e[5]?Number(e[5][2]):0,g=(m<<7)+(l<<6)+(c<<5)+(u<<4)+(h<<3)+(f<<2)+b;return[r,p,g,0]},dl=(s,e,t)=>{if(s==="aac")return e>=2&&t<=24e3?"mp4a.40.29":t<=24e3?"mp4a.40.5":"mp4a.40.2";if(s==="mp3")return"mp3";if(s==="opus")return"opus";if(s==="vorbis")return"vorbis";if(s==="flac")return"flac";if(Ne.includes(s))return s;throw new TypeError(`Unhandled codec '${s}'.`)},Vr=/^pcm-([usf])(\d+)+(be)?$/,Lt=s=>{if($(Ne.includes(s)),s==="ulaw")return{dataType:"ulaw",sampleSize:1,littleEndian:!0,silentValue:255};if(s==="alaw")return{dataType:"alaw",sampleSize:1,littleEndian:!0,silentValue:213};const e=Vr.exec(s);$(e);let t;e[1]==="u"?t="unsigned":e[1]==="s"?t="signed":t="float";const i=Number(e[2])/8,r=e[3]!=="be",n=s==="pcm-u8"?2**7:0;return{dataType:t,sampleSize:i,littleEndian:r,silentValue:n}},Wr=s=>s.startsWith("avc1")||s.startsWith("avc3")?"avc":s.startsWith("hev1")||s.startsWith("hvc1")?"hevc":s==="vp8"?"vp8":s.startsWith("vp09")?"vp9":s.startsWith("av01")?"av1":s.startsWith("mp4a.40")||s==="mp4a.67"?"aac":s==="mp3"||s==="mp4a.69"||s==="mp4a.6B"||s==="mp4a.6b"?"mp3":s==="opus"?"opus":s==="vorbis"?"vorbis":s==="flac"?"flac":s==="ulaw"?"ulaw":s==="alaw"?"alaw":Vr.test(s)?s:s==="webvtt"?"webvtt":null,fl=s=>s==="avc"?{avc:{format:"avc"}}:s==="hevc"?{hevc:{format:"hevc"}}:{},pl=s=>s==="aac"?{aac:{format:"aac"}}:s==="opus"?{opus:{format:"opus"}}:{},ml=["avc1","avc3","hev1","hvc1","vp8","vp09","av01"],gl=/^(avc1|avc3)\.[0-9a-fA-F]{6}$/,yl=/^(hev1|hvc1)\.(?:[ABC]?\d+)\.[0-9a-fA-F]{1,8}\.[LH]\d+(?:\.[0-9a-fA-F]{1,2}){0,6}$/,bl=/^vp09(?:\.\d{2}){3}(?:(?:\.\d{2}){5})?$/,vl=/^av01\.\d\.\d{2}[MH]\.\d{2}(?:\.\d\.\d{3}\.\d{2}\.\d{2}\.\d{2}\.\d)?$/,wl=s=>{if(!s)throw new TypeError("Video chunk metadata must be provided.");if(typeof s!="object")throw new TypeError("Video chunk metadata must be an object.");if(!s.decoderConfig)throw new TypeError("Video chunk metadata must include a decoder configuration.");if(typeof s.decoderConfig!="object")throw new TypeError("Video chunk metadata decoder configuration must be an object.");if(typeof s.decoderConfig.codec!="string")throw new TypeError("Video chunk metadata decoder configuration must specify a codec string.");if(!ml.some(e=>s.decoderConfig.codec.startsWith(e)))throw new TypeError("Video chunk metadata decoder configuration codec string must be a valid video codec string as specified in the WebCodecs Codec Registry.");if(!Number.isInteger(s.decoderConfig.codedWidth)||s.decoderConfig.codedWidth<=0)throw new TypeError("Video chunk metadata decoder configuration must specify a valid codedWidth (positive integer).");if(!Number.isInteger(s.decoderConfig.codedHeight)||s.decoderConfig.codedHeight<=0)throw new TypeError("Video chunk metadata decoder configuration must specify a valid codedHeight (positive integer).");if(s.decoderConfig.description!==void 0&&!xi(s.decoderConfig.description))throw new TypeError("Video chunk metadata decoder configuration description, when defined, must be an ArrayBuffer or an ArrayBuffer view.");if(s.decoderConfig.colorSpace!==void 0){const{colorSpace:e}=s.decoderConfig;if(typeof e!="object")throw new TypeError("Video chunk metadata decoder configuration colorSpace, when provided, must be an object.");const t=Object.keys(vi);if(e.primaries!=null&&!t.includes(e.primaries))throw new TypeError(`Video chunk metadata decoder configuration colorSpace primaries, when defined, must be one of ${t.join(", ")}.`);const i=Object.keys(wi);if(e.transfer!=null&&!i.includes(e.transfer))throw new TypeError(`Video chunk metadata decoder configuration colorSpace transfer, when defined, must be one of ${i.join(", ")}.`);const r=Object.keys(_i);if(e.matrix!=null&&!r.includes(e.matrix))throw new TypeError(`Video chunk metadata decoder configuration colorSpace matrix, when defined, must be one of ${r.join(", ")}.`);if(e.fullRange!=null&&typeof e.fullRange!="boolean")throw new TypeError("Video chunk metadata decoder configuration colorSpace fullRange, when defined, must be a boolean.")}if(s.decoderConfig.codec.startsWith("avc1")||s.decoderConfig.codec.startsWith("avc3")){if(!gl.test(s.decoderConfig.codec))throw new TypeError("Video chunk metadata decoder configuration codec string for AVC must be a valid AVC codec string as specified in Section 3.4 of RFC 6381.")}else if(s.decoderConfig.codec.startsWith("hev1")||s.decoderConfig.codec.startsWith("hvc1")){if(!yl.test(s.decoderConfig.codec))throw new TypeError("Video chunk metadata decoder configuration codec string for HEVC must be a valid HEVC codec string as specified in Section E.3 of ISO 14496-15.")}else if(s.decoderConfig.codec.startsWith("vp8")){if(s.decoderConfig.codec!=="vp8")throw new TypeError('Video chunk metadata decoder configuration codec string for VP8 must be "vp8".')}else if(s.decoderConfig.codec.startsWith("vp09")){if(!bl.test(s.decoderConfig.codec))throw new TypeError('Video chunk metadata decoder configuration codec string for VP9 must be a valid VP9 codec string as specified in Section "Codecs Parameter String" of https://www.webmproject.org/vp9/mp4/.')}else if(s.decoderConfig.codec.startsWith("av01")&&!vl.test(s.decoderConfig.codec))throw new TypeError('Video chunk metadata decoder configuration codec string for AV1 must be a valid AV1 codec string as specified in Section "Codecs Parameter String" of https://aomediacodec.github.io/av1-isobmff/.')},_l=["mp4a","mp3","opus","vorbis","flac","ulaw","alaw","pcm"],xl=s=>{if(!s)throw new TypeError("Audio chunk metadata must be provided.");if(typeof s!="object")throw new TypeError("Audio chunk metadata must be an object.");if(!s.decoderConfig)throw new TypeError("Audio chunk metadata must include a decoder configuration.");if(typeof s.decoderConfig!="object")throw new TypeError("Audio chunk metadata decoder configuration must be an object.");if(typeof s.decoderConfig.codec!="string")throw new TypeError("Audio chunk metadata decoder configuration must specify a codec string.");if(!_l.some(e=>s.decoderConfig.codec.startsWith(e)))throw new TypeError("Audio chunk metadata decoder configuration codec string must be a valid audio codec string as specified in the WebCodecs Codec Registry.");if(!Number.isInteger(s.decoderConfig.sampleRate)||s.decoderConfig.sampleRate<=0)throw new TypeError("Audio chunk metadata decoder configuration must specify a valid sampleRate (positive integer).");if(!Number.isInteger(s.decoderConfig.numberOfChannels)||s.decoderConfig.numberOfChannels<=0)throw new TypeError("Audio chunk metadata decoder configuration must specify a valid numberOfChannels (positive integer).");if(s.decoderConfig.description!==void 0&&!xi(s.decoderConfig.description))throw new TypeError("Audio chunk metadata decoder configuration description, when defined, must be an ArrayBuffer or an ArrayBuffer view.");if(s.decoderConfig.codec.startsWith("mp4a")&&s.decoderConfig.codec!=="mp4a.69"&&s.decoderConfig.codec!=="mp4a.6B"&&s.decoderConfig.codec!=="mp4a.6b"){if(!["mp4a.40.2","mp4a.40.02","mp4a.40.5","mp4a.40.05","mp4a.40.29","mp4a.67"].includes(s.decoderConfig.codec))throw new TypeError("Audio chunk metadata decoder configuration codec string for AAC must be a valid AAC codec string as specified in https://www.w3.org/TR/webcodecs-aac-codec-registration/.");if(!s.decoderConfig.description)throw new TypeError("Audio chunk metadata decoder configuration for AAC must include a description, which is expected to be an AudioSpecificConfig as specified in ISO 14496-3.")}else if(s.decoderConfig.codec.startsWith("mp3")||s.decoderConfig.codec.startsWith("mp4a")){if(s.decoderConfig.codec!=="mp3"&&s.decoderConfig.codec!=="mp4a.69"&&s.decoderConfig.codec!=="mp4a.6B"&&s.decoderConfig.codec!=="mp4a.6b")throw new TypeError('Audio chunk metadata decoder configuration codec string for MP3 must be "mp3", "mp4a.69" or "mp4a.6B".')}else if(s.decoderConfig.codec.startsWith("opus")){if(s.decoderConfig.codec!=="opus")throw new TypeError('Audio chunk metadata decoder configuration codec string for Opus must be "opus".');if(s.decoderConfig.description&&s.decoderConfig.description.byteLength<18)throw new TypeError("Audio chunk metadata decoder configuration description, when specified, is expected to be an Identification Header as specified in Section 5.1 of RFC 7845.")}else if(s.decoderConfig.codec.startsWith("vorbis")){if(s.decoderConfig.codec!=="vorbis")throw new TypeError('Audio chunk metadata decoder configuration codec string for Vorbis must be "vorbis".');if(!s.decoderConfig.description)throw new TypeError("Audio chunk metadata decoder configuration for Vorbis must include a description, which is expected to adhere to the format described in https://www.w3.org/TR/webcodecs-vorbis-codec-registration/.")}else if(s.decoderConfig.codec.startsWith("flac")){if(s.decoderConfig.codec!=="flac")throw new TypeError('Audio chunk metadata decoder configuration codec string for FLAC must be "flac".');if(!s.decoderConfig.description||s.decoderConfig.description.byteLength<42)throw new TypeError("Audio chunk metadata decoder configuration for FLAC must include a description, which is expected to adhere to the format described in https://www.w3.org/TR/webcodecs-flac-codec-registration/.")}else if((s.decoderConfig.codec.startsWith("pcm")||s.decoderConfig.codec.startsWith("ulaw")||s.decoderConfig.codec.startsWith("alaw"))&&!Ne.includes(s.decoderConfig.codec))throw new TypeError(`Audio chunk metadata decoder configuration codec string for PCM must be one of the supported PCM codecs (${Ne.join(", ")}).`)},Cl=s=>{if(!s)throw new TypeError("Subtitle metadata must be provided.");if(typeof s!="object")throw new TypeError("Subtitle metadata must be an object.");if(!s.config)throw new TypeError("Subtitle metadata must include a config object.");if(typeof s.config!="object")throw new TypeError("Subtitle metadata config must be an object.");if(typeof s.config.description!="string")throw new TypeError("Subtitle metadata config description must be a string.")};/*!
207
+ */const li=["avc","hevc","vp9","av1","vp8"],nr=["pcm-s16","pcm-s16be","pcm-s24","pcm-s24be","pcm-s32","pcm-s32be","pcm-f32","pcm-f32be","pcm-f64","pcm-f64be","pcm-u8","pcm-s8","ulaw","alaw"],f0=["aac","opus","mp3","vorbis","flac"],Di=[...f0,...nr],zn=["webvtt"],p0=[{maxMacroblocks:99,maxBitrate:64e3,level:10},{maxMacroblocks:396,maxBitrate:192e3,level:11},{maxMacroblocks:396,maxBitrate:384e3,level:12},{maxMacroblocks:396,maxBitrate:768e3,level:13},{maxMacroblocks:396,maxBitrate:2e6,level:20},{maxMacroblocks:792,maxBitrate:4e6,level:21},{maxMacroblocks:1620,maxBitrate:4e6,level:22},{maxMacroblocks:1620,maxBitrate:1e7,level:30},{maxMacroblocks:3600,maxBitrate:14e6,level:31},{maxMacroblocks:5120,maxBitrate:2e7,level:32},{maxMacroblocks:8192,maxBitrate:2e7,level:40},{maxMacroblocks:8192,maxBitrate:5e7,level:41},{maxMacroblocks:8704,maxBitrate:5e7,level:42},{maxMacroblocks:22080,maxBitrate:135e6,level:50},{maxMacroblocks:36864,maxBitrate:24e7,level:51},{maxMacroblocks:36864,maxBitrate:24e7,level:52},{maxMacroblocks:139264,maxBitrate:24e7,level:60},{maxMacroblocks:139264,maxBitrate:48e7,level:61},{maxMacroblocks:139264,maxBitrate:8e8,level:62}],m0=[{maxPictureSize:36864,maxBitrate:128e3,tier:"L",level:30},{maxPictureSize:122880,maxBitrate:15e5,tier:"L",level:60},{maxPictureSize:245760,maxBitrate:3e6,tier:"L",level:63},{maxPictureSize:552960,maxBitrate:6e6,tier:"L",level:90},{maxPictureSize:983040,maxBitrate:1e7,tier:"L",level:93},{maxPictureSize:2228224,maxBitrate:12e6,tier:"L",level:120},{maxPictureSize:2228224,maxBitrate:3e7,tier:"H",level:120},{maxPictureSize:2228224,maxBitrate:2e7,tier:"L",level:123},{maxPictureSize:2228224,maxBitrate:5e7,tier:"H",level:123},{maxPictureSize:8912896,maxBitrate:25e6,tier:"L",level:150},{maxPictureSize:8912896,maxBitrate:1e8,tier:"H",level:150},{maxPictureSize:8912896,maxBitrate:4e7,tier:"L",level:153},{maxPictureSize:8912896,maxBitrate:16e7,tier:"H",level:153},{maxPictureSize:8912896,maxBitrate:6e7,tier:"L",level:156},{maxPictureSize:8912896,maxBitrate:24e7,tier:"H",level:156},{maxPictureSize:35651584,maxBitrate:6e7,tier:"L",level:180},{maxPictureSize:35651584,maxBitrate:24e7,tier:"H",level:180},{maxPictureSize:35651584,maxBitrate:12e7,tier:"L",level:183},{maxPictureSize:35651584,maxBitrate:48e7,tier:"H",level:183},{maxPictureSize:35651584,maxBitrate:24e7,tier:"L",level:186},{maxPictureSize:35651584,maxBitrate:8e8,tier:"H",level:186}],g0=[{maxPictureSize:36864,maxBitrate:2e5,level:10},{maxPictureSize:73728,maxBitrate:8e5,level:11},{maxPictureSize:122880,maxBitrate:18e5,level:20},{maxPictureSize:245760,maxBitrate:36e5,level:21},{maxPictureSize:552960,maxBitrate:72e5,level:30},{maxPictureSize:983040,maxBitrate:12e6,level:31},{maxPictureSize:2228224,maxBitrate:18e6,level:40},{maxPictureSize:2228224,maxBitrate:3e7,level:41},{maxPictureSize:8912896,maxBitrate:6e7,level:50},{maxPictureSize:8912896,maxBitrate:12e7,level:51},{maxPictureSize:8912896,maxBitrate:18e7,level:52},{maxPictureSize:35651584,maxBitrate:18e7,level:60},{maxPictureSize:35651584,maxBitrate:24e7,level:61},{maxPictureSize:35651584,maxBitrate:48e7,level:62}],y0=[{maxPictureSize:147456,maxBitrate:15e5,tier:"M",level:0},{maxPictureSize:278784,maxBitrate:3e6,tier:"M",level:1},{maxPictureSize:665856,maxBitrate:6e6,tier:"M",level:4},{maxPictureSize:1065024,maxBitrate:1e7,tier:"M",level:5},{maxPictureSize:2359296,maxBitrate:12e6,tier:"M",level:8},{maxPictureSize:2359296,maxBitrate:3e7,tier:"H",level:8},{maxPictureSize:2359296,maxBitrate:2e7,tier:"M",level:9},{maxPictureSize:2359296,maxBitrate:5e7,tier:"H",level:9},{maxPictureSize:8912896,maxBitrate:3e7,tier:"M",level:12},{maxPictureSize:8912896,maxBitrate:1e8,tier:"H",level:12},{maxPictureSize:8912896,maxBitrate:4e7,tier:"M",level:13},{maxPictureSize:8912896,maxBitrate:16e7,tier:"H",level:13},{maxPictureSize:8912896,maxBitrate:6e7,tier:"M",level:14},{maxPictureSize:8912896,maxBitrate:24e7,tier:"H",level:14},{maxPictureSize:35651584,maxBitrate:6e7,tier:"M",level:15},{maxPictureSize:35651584,maxBitrate:24e7,tier:"H",level:15},{maxPictureSize:35651584,maxBitrate:6e7,tier:"M",level:16},{maxPictureSize:35651584,maxBitrate:24e7,tier:"H",level:16},{maxPictureSize:35651584,maxBitrate:1e8,tier:"M",level:17},{maxPictureSize:35651584,maxBitrate:48e7,tier:"H",level:17},{maxPictureSize:35651584,maxBitrate:16e7,tier:"M",level:18},{maxPictureSize:35651584,maxBitrate:8e8,tier:"H",level:18},{maxPictureSize:35651584,maxBitrate:16e7,tier:"M",level:19},{maxPictureSize:35651584,maxBitrate:8e8,tier:"H",level:19}],Tv=(s,e,t,r)=>{if(s==="avc"){const n=Math.ceil(e/16)*Math.ceil(t/16),a=p0.find(l=>n<=l.maxMacroblocks&&r<=l.maxBitrate)??ir(p0),o=a?a.level:0,c="64".padStart(2,"0"),u="00",h=o.toString(16).padStart(2,"0");return`avc1.${c}${u}${h}`}else if(s==="hevc"){const i="",a="6",o=e*t,c=m0.find(h=>o<=h.maxPictureSize&&r<=h.maxBitrate)??ir(m0);return`hev1.${i}1.${a}.${c.tier}${c.level}.B0`}else{if(s==="vp8")return"vp8";if(s==="vp9"){const i="00",n=e*t,a=g0.find(c=>n<=c.maxPictureSize&&r<=c.maxBitrate)??ir(g0);return`vp09.${i}.${a.level.toString().padStart(2,"0")}.08`}else if(s==="av1"){const n=e*t,a=y0.find(u=>n<=u.maxPictureSize&&r<=u.maxBitrate)??ir(y0);return`av01.0.${a.level.toString().padStart(2,"0")}${a.tier}.08`}}throw new TypeError(`Unhandled codec '${s}'.`)},Ev=s=>{const e=s.split("."),i=(1<<7)+1,n=Number(e[1]),a=e[2],o=Number(a.slice(0,-1)),c=(n<<5)+o,u=a.slice(-1)==="H"?1:0,l=Number(e[3])===8?0:1,d=0,f=e[4]?Number(e[4]):0,p=e[5]?Number(e[5][0]):1,m=e[5]?Number(e[5][1]):1,v=e[5]?Number(e[5][2]):0,g=(u<<7)+(l<<6)+(d<<5)+(f<<4)+(p<<3)+(m<<2)+v;return[i,c,g,0]},Av=(s,e,t)=>{if(s==="aac")return e>=2&&t<=24e3?"mp4a.40.29":t<=24e3?"mp4a.40.5":"mp4a.40.2";if(s==="mp3")return"mp3";if(s==="opus")return"opus";if(s==="vorbis")return"vorbis";if(s==="flac")return"flac";if(nr.includes(s))return s;throw new TypeError(`Unhandled codec '${s}'.`)},b0=/^pcm-([usf])(\d+)+(be)?$/,Bi=s=>{if(Y(nr.includes(s)),s==="ulaw")return{dataType:"ulaw",sampleSize:1,littleEndian:!0,silentValue:255};if(s==="alaw")return{dataType:"alaw",sampleSize:1,littleEndian:!0,silentValue:213};const e=b0.exec(s);Y(e);let t;e[1]==="u"?t="unsigned":e[1]==="s"?t="signed":t="float";const r=Number(e[2])/8,i=e[3]!=="be",n=s==="pcm-u8"?2**7:0;return{dataType:t,sampleSize:r,littleEndian:i,silentValue:n}},v0=s=>s.startsWith("avc1")||s.startsWith("avc3")?"avc":s.startsWith("hev1")||s.startsWith("hvc1")?"hevc":s==="vp8"?"vp8":s.startsWith("vp09")?"vp9":s.startsWith("av01")?"av1":s.startsWith("mp4a.40")||s==="mp4a.67"?"aac":s==="mp3"||s==="mp4a.69"||s==="mp4a.6B"||s==="mp4a.6b"?"mp3":s==="opus"?"opus":s==="vorbis"?"vorbis":s==="flac"?"flac":s==="ulaw"?"ulaw":s==="alaw"?"alaw":b0.test(s)?s:s==="webvtt"?"webvtt":null,Iv=s=>s==="avc"?{avc:{format:"avc"}}:s==="hevc"?{hevc:{format:"hevc"}}:{},Pv=s=>s==="aac"?{aac:{format:"aac"}}:s==="opus"?{opus:{format:"opus"}}:{},Ov=["avc1","avc3","hev1","hvc1","vp8","vp09","av01"],Fv=/^(avc1|avc3)\.[0-9a-fA-F]{6}$/,Rv=/^(hev1|hvc1)\.(?:[ABC]?\d+)\.[0-9a-fA-F]{1,8}\.[LH]\d+(?:\.[0-9a-fA-F]{1,2}){0,6}$/,Mv=/^vp09(?:\.\d{2}){3}(?:(?:\.\d{2}){5})?$/,Dv=/^av01\.\d\.\d{2}[MH]\.\d{2}(?:\.\d\.\d{3}\.\d{2}\.\d{2}\.\d{2}\.\d)?$/,Bv=s=>{if(!s)throw new TypeError("Video chunk metadata must be provided.");if(typeof s!="object")throw new TypeError("Video chunk metadata must be an object.");if(!s.decoderConfig)throw new TypeError("Video chunk metadata must include a decoder configuration.");if(typeof s.decoderConfig!="object")throw new TypeError("Video chunk metadata decoder configuration must be an object.");if(typeof s.decoderConfig.codec!="string")throw new TypeError("Video chunk metadata decoder configuration must specify a codec string.");if(!Ov.some(e=>s.decoderConfig.codec.startsWith(e)))throw new TypeError("Video chunk metadata decoder configuration codec string must be a valid video codec string as specified in the WebCodecs Codec Registry.");if(!Number.isInteger(s.decoderConfig.codedWidth)||s.decoderConfig.codedWidth<=0)throw new TypeError("Video chunk metadata decoder configuration must specify a valid codedWidth (positive integer).");if(!Number.isInteger(s.decoderConfig.codedHeight)||s.decoderConfig.codedHeight<=0)throw new TypeError("Video chunk metadata decoder configuration must specify a valid codedHeight (positive integer).");if(s.decoderConfig.description!==void 0&&!Ln(s.decoderConfig.description))throw new TypeError("Video chunk metadata decoder configuration description, when defined, must be an ArrayBuffer or an ArrayBuffer view.");if(s.decoderConfig.colorSpace!==void 0){const{colorSpace:e}=s.decoderConfig;if(typeof e!="object")throw new TypeError("Video chunk metadata decoder configuration colorSpace, when provided, must be an object.");const t=Object.keys(Mn);if(e.primaries!=null&&!t.includes(e.primaries))throw new TypeError(`Video chunk metadata decoder configuration colorSpace primaries, when defined, must be one of ${t.join(", ")}.`);const r=Object.keys(Dn);if(e.transfer!=null&&!r.includes(e.transfer))throw new TypeError(`Video chunk metadata decoder configuration colorSpace transfer, when defined, must be one of ${r.join(", ")}.`);const i=Object.keys(Bn);if(e.matrix!=null&&!i.includes(e.matrix))throw new TypeError(`Video chunk metadata decoder configuration colorSpace matrix, when defined, must be one of ${i.join(", ")}.`);if(e.fullRange!=null&&typeof e.fullRange!="boolean")throw new TypeError("Video chunk metadata decoder configuration colorSpace fullRange, when defined, must be a boolean.")}if(s.decoderConfig.codec.startsWith("avc1")||s.decoderConfig.codec.startsWith("avc3")){if(!Fv.test(s.decoderConfig.codec))throw new TypeError("Video chunk metadata decoder configuration codec string for AVC must be a valid AVC codec string as specified in Section 3.4 of RFC 6381.")}else if(s.decoderConfig.codec.startsWith("hev1")||s.decoderConfig.codec.startsWith("hvc1")){if(!Rv.test(s.decoderConfig.codec))throw new TypeError("Video chunk metadata decoder configuration codec string for HEVC must be a valid HEVC codec string as specified in Section E.3 of ISO 14496-15.")}else if(s.decoderConfig.codec.startsWith("vp8")){if(s.decoderConfig.codec!=="vp8")throw new TypeError('Video chunk metadata decoder configuration codec string for VP8 must be "vp8".')}else if(s.decoderConfig.codec.startsWith("vp09")){if(!Mv.test(s.decoderConfig.codec))throw new TypeError('Video chunk metadata decoder configuration codec string for VP9 must be a valid VP9 codec string as specified in Section "Codecs Parameter String" of https://www.webmproject.org/vp9/mp4/.')}else if(s.decoderConfig.codec.startsWith("av01")&&!Dv.test(s.decoderConfig.codec))throw new TypeError('Video chunk metadata decoder configuration codec string for AV1 must be a valid AV1 codec string as specified in Section "Codecs Parameter String" of https://aomediacodec.github.io/av1-isobmff/.')},Lv=["mp4a","mp3","opus","vorbis","flac","ulaw","alaw","pcm"],zv=s=>{if(!s)throw new TypeError("Audio chunk metadata must be provided.");if(typeof s!="object")throw new TypeError("Audio chunk metadata must be an object.");if(!s.decoderConfig)throw new TypeError("Audio chunk metadata must include a decoder configuration.");if(typeof s.decoderConfig!="object")throw new TypeError("Audio chunk metadata decoder configuration must be an object.");if(typeof s.decoderConfig.codec!="string")throw new TypeError("Audio chunk metadata decoder configuration must specify a codec string.");if(!Lv.some(e=>s.decoderConfig.codec.startsWith(e)))throw new TypeError("Audio chunk metadata decoder configuration codec string must be a valid audio codec string as specified in the WebCodecs Codec Registry.");if(!Number.isInteger(s.decoderConfig.sampleRate)||s.decoderConfig.sampleRate<=0)throw new TypeError("Audio chunk metadata decoder configuration must specify a valid sampleRate (positive integer).");if(!Number.isInteger(s.decoderConfig.numberOfChannels)||s.decoderConfig.numberOfChannels<=0)throw new TypeError("Audio chunk metadata decoder configuration must specify a valid numberOfChannels (positive integer).");if(s.decoderConfig.description!==void 0&&!Ln(s.decoderConfig.description))throw new TypeError("Audio chunk metadata decoder configuration description, when defined, must be an ArrayBuffer or an ArrayBuffer view.");if(s.decoderConfig.codec.startsWith("mp4a")&&s.decoderConfig.codec!=="mp4a.69"&&s.decoderConfig.codec!=="mp4a.6B"&&s.decoderConfig.codec!=="mp4a.6b"){if(!["mp4a.40.2","mp4a.40.02","mp4a.40.5","mp4a.40.05","mp4a.40.29","mp4a.67"].includes(s.decoderConfig.codec))throw new TypeError("Audio chunk metadata decoder configuration codec string for AAC must be a valid AAC codec string as specified in https://www.w3.org/TR/webcodecs-aac-codec-registration/.");if(!s.decoderConfig.description)throw new TypeError("Audio chunk metadata decoder configuration for AAC must include a description, which is expected to be an AudioSpecificConfig as specified in ISO 14496-3.")}else if(s.decoderConfig.codec.startsWith("mp3")||s.decoderConfig.codec.startsWith("mp4a")){if(s.decoderConfig.codec!=="mp3"&&s.decoderConfig.codec!=="mp4a.69"&&s.decoderConfig.codec!=="mp4a.6B"&&s.decoderConfig.codec!=="mp4a.6b")throw new TypeError('Audio chunk metadata decoder configuration codec string for MP3 must be "mp3", "mp4a.69" or "mp4a.6B".')}else if(s.decoderConfig.codec.startsWith("opus")){if(s.decoderConfig.codec!=="opus")throw new TypeError('Audio chunk metadata decoder configuration codec string for Opus must be "opus".');if(s.decoderConfig.description&&s.decoderConfig.description.byteLength<18)throw new TypeError("Audio chunk metadata decoder configuration description, when specified, is expected to be an Identification Header as specified in Section 5.1 of RFC 7845.")}else if(s.decoderConfig.codec.startsWith("vorbis")){if(s.decoderConfig.codec!=="vorbis")throw new TypeError('Audio chunk metadata decoder configuration codec string for Vorbis must be "vorbis".');if(!s.decoderConfig.description)throw new TypeError("Audio chunk metadata decoder configuration for Vorbis must include a description, which is expected to adhere to the format described in https://www.w3.org/TR/webcodecs-vorbis-codec-registration/.")}else if(s.decoderConfig.codec.startsWith("flac")){if(s.decoderConfig.codec!=="flac")throw new TypeError('Audio chunk metadata decoder configuration codec string for FLAC must be "flac".');if(!s.decoderConfig.description||s.decoderConfig.description.byteLength<42)throw new TypeError("Audio chunk metadata decoder configuration for FLAC must include a description, which is expected to adhere to the format described in https://www.w3.org/TR/webcodecs-flac-codec-registration/.")}else if((s.decoderConfig.codec.startsWith("pcm")||s.decoderConfig.codec.startsWith("ulaw")||s.decoderConfig.codec.startsWith("alaw"))&&!nr.includes(s.decoderConfig.codec))throw new TypeError(`Audio chunk metadata decoder configuration codec string for PCM must be one of the supported PCM codecs (${nr.join(", ")}).`)},$v=s=>{if(!s)throw new TypeError("Subtitle metadata must be provided.");if(typeof s!="object")throw new TypeError("Subtitle metadata must be an object.");if(!s.config)throw new TypeError("Subtitle metadata must include a config object.");if(typeof s.config!="object")throw new TypeError("Subtitle metadata config must be an object.");if(typeof s.config.description!="string")throw new TypeError("Subtitle metadata config description must be a string.")};/*!
206
208
  * Copyright (c) 2025-present, Vanilagy and contributors
207
209
  *
208
210
  * This Source Code Form is subject to the terms of the Mozilla Public
209
211
  * License, v. 2.0. If a copy of the MPL was not distributed with this
210
212
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
211
- */class kl{constructor(e){this.mutex=new Mr,this.firstMediaStreamTimestamp=null,this.trackTimestampInfo=new WeakMap,this.output=e}onTrackClose(e){}validateAndNormalizeTimestamp(e,t,i){t+=e.source._timestampOffset;let r=this.trackTimestampInfo.get(e);if(!r){if(!i)throw new Error("First frame must be a key frame.");r={maxTimestamp:t,maxTimestampBeforeLastKeyFrame:t},this.trackTimestampInfo.set(e,r)}if(t<0)throw new Error(`Timestamps must be non-negative (got ${t}s).`);if(i&&(r.maxTimestampBeforeLastKeyFrame=r.maxTimestamp),t<r.maxTimestampBeforeLastKeyFrame)throw new Error(`Timestamps cannot be smaller than the highest timestamp of the previous GOP (a GOP begins with a key frame and ends right before the next key frame). Got ${t}s, but highest timestamp is ${r.maxTimestampBeforeLastKeyFrame}s.`);return r.maxTimestamp=Math.max(r.maxTimestamp,t),t}}/*!
213
+ */class Nv{constructor(e){this.mutex=new l0,this.firstMediaStreamTimestamp=null,this.trackTimestampInfo=new WeakMap,this.output=e}onTrackClose(e){}validateAndNormalizeTimestamp(e,t,r){t+=e.source._timestampOffset;let i=this.trackTimestampInfo.get(e);if(!i){if(!r)throw new Error("First frame must be a key frame.");i={maxTimestamp:t,maxTimestampBeforeLastKeyFrame:t},this.trackTimestampInfo.set(e,i)}if(t<0)throw new Error(`Timestamps must be non-negative (got ${t}s).`);if(r&&(i.maxTimestampBeforeLastKeyFrame=i.maxTimestamp),t<i.maxTimestampBeforeLastKeyFrame)throw new Error(`Timestamps cannot be smaller than the highest timestamp of the previous GOP (a GOP begins with a key frame and ends right before the next key frame). Got ${t}s, but highest timestamp is ${i.maxTimestampBeforeLastKeyFrame}s.`);return i.maxTimestamp=Math.max(i.maxTimestamp,t),t}}/*!
212
214
  * Copyright (c) 2025-present, Vanilagy and contributors
213
215
  *
214
216
  * This Source Code Form is subject to the terms of the Mozilla Public
215
217
  * License, v. 2.0. If a copy of the MPL was not distributed with this
216
218
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
217
- */var Jt;(function(s){s[s.IDR=5]="IDR",s[s.SPS=7]="SPS",s[s.PPS=8]="PPS",s[s.SPS_EXT=13]="SPS_EXT"})(Jt||(Jt={}));var Ue;(function(s){s[s.RASL_N=8]="RASL_N",s[s.RASL_R=9]="RASL_R",s[s.BLA_W_LP=16]="BLA_W_LP",s[s.RSV_IRAP_VCL23=23]="RSV_IRAP_VCL23",s[s.VPS_NUT=32]="VPS_NUT",s[s.SPS_NUT=33]="SPS_NUT",s[s.PPS_NUT=34]="PPS_NUT",s[s.PREFIX_SEI_NUT=39]="PREFIX_SEI_NUT",s[s.SUFFIX_SEI_NUT=40]="SUFFIX_SEI_NUT"})(Ue||(Ue={}));const cs=s=>{const e=[];let t=0;for(;t<s.length;){let i=-1,r=0;for(let n=t;n<s.length-3;n++){if(s[n]===0&&s[n+1]===0&&s[n+2]===1){i=n,r=3;break}if(n<s.length-4&&s[n]===0&&s[n+1]===0&&s[n+2]===0&&s[n+3]===1){i=n,r=4;break}}if(i===-1)break;if(t>0&&i>t){const n=s.subarray(t,i);n.length>0&&e.push(n)}t=i+r}if(t<s.length){const i=s.subarray(t);i.length>0&&e.push(i)}return e},hs=s=>{const e=[],t=s.length;for(let i=0;i<t;i++)i+2<t&&s[i]===0&&s[i+1]===0&&s[i+2]===3?(e.push(0,0),i+=2):e.push(s[i]);return new Uint8Array(e)},Tl=s=>{const t=cs(s);if(t.length===0)return null;let i=0;for(const a of t)i+=4+a.byteLength;const r=new Uint8Array(i),n=new DataView(r.buffer);let o=0;for(const a of t){const p=a.byteLength;n.setUint32(o,p,!1),o+=4,r.set(a,o),o+=a.byteLength}return r},us=s=>s[0]&31,Sl=s=>{try{const e=cs(s),t=e.filter(c=>us(c)===Jt.SPS),i=e.filter(c=>us(c)===Jt.PPS),r=e.filter(c=>us(c)===Jt.SPS_EXT);if(t.length===0||i.length===0)return null;const n=t[0],o=new Yt(hs(n));if(o.skipBits(1),o.skipBits(2),o.readBits(5)!==7)return console.error("Invalid SPS NAL unit type"),null;const p=o.readAlignedByte(),m=o.readAlignedByte(),d=o.readAlignedByte(),l={configurationVersion:1,avcProfileIndication:p,profileCompatibility:m,avcLevelIndication:d,lengthSizeMinusOne:3,sequenceParameterSets:t,pictureParameterSets:i,chromaFormat:null,bitDepthLumaMinus8:null,bitDepthChromaMinus8:null,sequenceParameterSetExt:null};if(p===100||p===110||p===122||p===144){W(o);const c=W(o);c===3&&o.skipBits(1);const u=W(o),h=W(o);l.chromaFormat=c,l.bitDepthLumaMinus8=u,l.bitDepthChromaMinus8=h,l.sequenceParameterSetExt=r}return l}catch(e){return console.error("Error building AVC Decoder Configuration Record:",e),null}},El=s=>{const e=[];e.push(s.configurationVersion),e.push(s.avcProfileIndication),e.push(s.profileCompatibility),e.push(s.avcLevelIndication),e.push(252|s.lengthSizeMinusOne&3),e.push(224|s.sequenceParameterSets.length&31);for(const t of s.sequenceParameterSets){const i=t.byteLength;e.push(i>>8),e.push(i&255);for(let r=0;r<i;r++)e.push(t[r])}e.push(s.pictureParameterSets.length);for(const t of s.pictureParameterSets){const i=t.byteLength;e.push(i>>8),e.push(i&255);for(let r=0;r<i;r++)e.push(t[r])}if(s.avcProfileIndication===100||s.avcProfileIndication===110||s.avcProfileIndication===122||s.avcProfileIndication===144){$(s.chromaFormat!==null),$(s.bitDepthLumaMinus8!==null),$(s.bitDepthChromaMinus8!==null),$(s.sequenceParameterSetExt!==null),e.push(252|s.chromaFormat&3),e.push(248|s.bitDepthLumaMinus8&7),e.push(248|s.bitDepthChromaMinus8&7),e.push(s.sequenceParameterSetExt.length);for(const t of s.sequenceParameterSetExt){const i=t.byteLength;e.push(i>>8),e.push(i&255);for(let r=0;r<i;r++)e.push(t[r])}}return new Uint8Array(e)},Bt=s=>s[0]>>1&63,Al=s=>{try{const e=cs(s),t=e.filter(k=>Bt(k)===Ue.VPS_NUT),i=e.filter(k=>Bt(k)===Ue.SPS_NUT),r=e.filter(k=>Bt(k)===Ue.PPS_NUT),n=e.filter(k=>Bt(k)===Ue.PREFIX_SEI_NUT||Bt(k)===Ue.SUFFIX_SEI_NUT);if(i.length===0||r.length===0)return null;const o=i[0],a=new Yt(hs(o));a.skipBits(16),a.readBits(4);const p=a.readBits(3),m=a.readBits(1),{general_profile_space:d,general_tier_flag:l,general_profile_idc:c,general_profile_compatibility_flags:u,general_constraint_indicator_flags:h,general_level_idc:f}=Il(a,p);W(a);const b=W(a);b===3&&a.skipBits(1),W(a),W(a),a.readBits(1)&&(W(a),W(a),W(a),W(a));const g=W(a),y=W(a);W(a);const _=a.readBits(1)?0:p;for(let k=_;k<=p;k++)W(a),W(a),W(a);W(a),W(a),W(a),W(a),W(a),W(a),a.readBits(1)&&a.readBits(1)&&Pl(a),a.skipBits(1),a.skipBits(1),a.readBits(1)&&(a.skipBits(4),a.skipBits(4),W(a),W(a),a.skipBits(1));const C=W(a);if(Rl(a,C),a.readBits(1)){const k=W(a);for(let E=0;E<k;E++)W(a),a.skipBits(1)}a.skipBits(1),a.skipBits(1);let S=0;a.readBits(1)&&(S=Fl(a,p));let T=0;if(r.length>0){const k=r[0],E=new Yt(hs(k));E.skipBits(16),W(E),W(E),E.skipBits(1),E.skipBits(1),E.skipBits(3),E.skipBits(1),E.skipBits(1),W(E),W(E),Qt(E),E.skipBits(1),E.skipBits(1),E.readBits(1)&&W(E),Qt(E),Qt(E),E.skipBits(1),E.skipBits(1),E.skipBits(1),E.skipBits(1);const P=E.readBits(1),O=E.readBits(1);!P&&!O?T=0:P&&!O?T=2:!P&&O?T=3:T=0}const w=[...t.length?[{arrayCompleteness:1,nalUnitType:Ue.VPS_NUT,nalUnits:t}]:[],...i.length?[{arrayCompleteness:1,nalUnitType:Ue.SPS_NUT,nalUnits:i}]:[],...r.length?[{arrayCompleteness:1,nalUnitType:Ue.PPS_NUT,nalUnits:r}]:[],...n.length?[{arrayCompleteness:1,nalUnitType:Bt(n[0]),nalUnits:n}]:[]];return{configurationVersion:1,generalProfileSpace:d,generalTierFlag:l,generalProfileIdc:c,generalProfileCompatibilityFlags:u,generalConstraintIndicatorFlags:h,generalLevelIdc:f,minSpatialSegmentationIdc:S,parallelismType:T,chromaFormatIdc:b,bitDepthLumaMinus8:g,bitDepthChromaMinus8:y,avgFrameRate:0,constantFrameRate:0,numTemporalLayers:p+1,temporalIdNested:m,lengthSizeMinusOne:3,arrays:w}}catch(e){return console.error("Error building HEVC Decoder Configuration Record:",e),null}},Il=(s,e)=>{const t=s.readBits(2),i=s.readBits(1),r=s.readBits(5);let n=0;for(let d=0;d<32;d++)n=n<<1|s.readBits(1);const o=new Uint8Array(6);for(let d=0;d<6;d++)o[d]=s.readBits(8);const a=s.readBits(8),p=[],m=[];for(let d=0;d<e;d++)p.push(s.readBits(1)),m.push(s.readBits(1));if(e>0)for(let d=e;d<8;d++)s.skipBits(2);for(let d=0;d<e;d++)p[d]&&s.skipBits(88),m[d]&&s.skipBits(8);return{general_profile_space:t,general_tier_flag:i,general_profile_idc:r,general_profile_compatibility_flags:n,general_constraint_indicator_flags:o,general_level_idc:a}},Pl=s=>{for(let e=0;e<4;e++)for(let t=0;t<(e===3?2:6);t++)if(!s.readBits(1))W(s);else{const r=Math.min(64,1<<4+(e<<1));e>1&&Qt(s);for(let n=0;n<r;n++)Qt(s)}},Rl=(s,e)=>{const t=[];for(let i=0;i<e;i++)t[i]=Ol(s,i,e,t)},Ol=(s,e,t,i)=>{let r=0,n=0,o=0;if(e!==0&&(n=s.readBits(1)),n){if(e===t){const p=W(s);o=e-(p+1)}else o=e-1;s.readBits(1),W(s);const a=i[o]??0;for(let p=0;p<=a;p++)s.readBits(1)||s.readBits(1);r=i[o]}else{const a=W(s),p=W(s);for(let m=0;m<a;m++)W(s),s.readBits(1);for(let m=0;m<p;m++)W(s),s.readBits(1);r=a+p}return r},Fl=(s,e)=>{if(s.readBits(1)&&s.readBits(8)===255&&(s.readBits(16),s.readBits(16)),s.readBits(1)&&s.readBits(1),s.readBits(1)&&(s.readBits(3),s.readBits(1),s.readBits(1)&&(s.readBits(8),s.readBits(8),s.readBits(8))),s.readBits(1)&&(W(s),W(s)),s.readBits(1),s.readBits(1),s.readBits(1),s.readBits(1)&&(W(s),W(s),W(s),W(s)),s.readBits(1)&&(s.readBits(32),s.readBits(32),s.readBits(1)&&W(s),s.readBits(1)&&Ml(s,!0,e)),s.readBits(1)){s.readBits(1),s.readBits(1),s.readBits(1);const t=W(s);return W(s),W(s),W(s),W(s),t}return 0},Ml=(s,e,t)=>{let i=!1,r=!1,n=!1;i=s.readBits(1)===1,r=s.readBits(1)===1,(i||r)&&(n=s.readBits(1)===1,n&&(s.readBits(8),s.readBits(5),s.readBits(1),s.readBits(5)),s.readBits(4),s.readBits(4),n&&s.readBits(4),s.readBits(5),s.readBits(5),s.readBits(5));for(let o=0;o<=t;o++){const a=s.readBits(1)===1;let p=!0;a||(p=s.readBits(1)===1);let m=!1;p?W(s):m=s.readBits(1)===1;let d=1;m||(d=W(s)+1),i&&Gr(s,d,n),r&&Gr(s,d,n)}},Gr=(s,e,t)=>{for(let i=0;i<e;i++)W(s),W(s),t&&(W(s),W(s)),s.readBits(1)},Ll=s=>{const e=[];e.push(s.configurationVersion),e.push((s.generalProfileSpace&3)<<6|(s.generalTierFlag&1)<<5|s.generalProfileIdc&31),e.push(s.generalProfileCompatibilityFlags>>>24&255),e.push(s.generalProfileCompatibilityFlags>>>16&255),e.push(s.generalProfileCompatibilityFlags>>>8&255),e.push(s.generalProfileCompatibilityFlags&255),e.push(...s.generalConstraintIndicatorFlags),e.push(s.generalLevelIdc&255),e.push(240|s.minSpatialSegmentationIdc>>8&15),e.push(s.minSpatialSegmentationIdc&255),e.push(252|s.parallelismType&3),e.push(252|s.chromaFormatIdc&3),e.push(248|s.bitDepthLumaMinus8&7),e.push(248|s.bitDepthChromaMinus8&7),e.push(s.avgFrameRate>>8&255),e.push(s.avgFrameRate&255),e.push((s.constantFrameRate&3)<<6|(s.numTemporalLayers&7)<<3|(s.temporalIdNested&1)<<2|s.lengthSizeMinusOne&3),e.push(s.arrays.length&255);for(const t of s.arrays){e.push((t.arrayCompleteness&1)<<7|0|t.nalUnitType&63),e.push(t.nalUnits.length>>8&255),e.push(t.nalUnits.length&255);for(const i of t.nalUnits){e.push(i.length>>8&255),e.push(i.length&255);for(let r=0;r<i.length;r++)e.push(i[r])}}return new Uint8Array(e)},Bl=s=>{const e=Fr(s),t=e.getUint8(9),i=e.getUint16(10,!0),r=e.getUint32(12,!0),n=e.getInt16(16,!0),o=e.getUint8(18);let a=null;return o&&(a=s.subarray(19,21+t)),{outputChannelCount:t,preSkip:i,inputSampleRate:r,outputGain:n,channelMappingFamily:o,channelMappingTable:a}};var Zr;(function(s){s[s.STREAMINFO=0]="STREAMINFO",s[s.VORBIS_COMMENT=4]="VORBIS_COMMENT",s[s.PICTURE=6]="PICTURE"})(Zr||(Zr={}));/*!
219
+ */var Ss;(function(s){s[s.IDR=5]="IDR",s[s.SPS=7]="SPS",s[s.PPS=8]="PPS",s[s.SPS_EXT=13]="SPS_EXT"})(Ss||(Ss={}));var ar;(function(s){s[s.RASL_N=8]="RASL_N",s[s.RASL_R=9]="RASL_R",s[s.BLA_W_LP=16]="BLA_W_LP",s[s.RSV_IRAP_VCL23=23]="RSV_IRAP_VCL23",s[s.VPS_NUT=32]="VPS_NUT",s[s.SPS_NUT=33]="SPS_NUT",s[s.PPS_NUT=34]="PPS_NUT",s[s.PREFIX_SEI_NUT=39]="PREFIX_SEI_NUT",s[s.SUFFIX_SEI_NUT=40]="SUFFIX_SEI_NUT"})(ar||(ar={}));const _o=s=>{const e=[];let t=0;for(;t<s.length;){let r=-1,i=0;for(let n=t;n<s.length-3;n++){if(s[n]===0&&s[n+1]===0&&s[n+2]===1){r=n,i=3;break}if(n<s.length-4&&s[n]===0&&s[n+1]===0&&s[n+2]===0&&s[n+3]===1){r=n,i=4;break}}if(r===-1)break;if(t>0&&r>t){const n=s.subarray(t,r);n.length>0&&e.push(n)}t=r+i}if(t<s.length){const r=s.subarray(t);r.length>0&&e.push(r)}return e},To=s=>{const e=[],t=s.length;for(let r=0;r<t;r++)r+2<t&&s[r]===0&&s[r+1]===0&&s[r+2]===3?(e.push(0,0),r+=2):e.push(s[r]);return new Uint8Array(e)},Uv=s=>{const t=_o(s);if(t.length===0)return null;let r=0;for(const o of t)r+=4+o.byteLength;const i=new Uint8Array(r),n=new DataView(i.buffer);let a=0;for(const o of t){const c=o.byteLength;n.setUint32(a,c,!1),a+=4,i.set(o,a),a+=o.byteLength}return i},Eo=s=>s[0]&31,Hv=s=>{try{const e=_o(s),t=e.filter(d=>Eo(d)===Ss.SPS),r=e.filter(d=>Eo(d)===Ss.PPS),i=e.filter(d=>Eo(d)===Ss.SPS_EXT);if(t.length===0||r.length===0)return null;const n=t[0],a=new Cs(To(n));if(a.skipBits(1),a.skipBits(2),a.readBits(5)!==7)return console.error("Invalid SPS NAL unit type"),null;const c=a.readAlignedByte(),u=a.readAlignedByte(),h=a.readAlignedByte(),l={configurationVersion:1,avcProfileIndication:c,profileCompatibility:u,avcLevelIndication:h,lengthSizeMinusOne:3,sequenceParameterSets:t,pictureParameterSets:r,chromaFormat:null,bitDepthLumaMinus8:null,bitDepthChromaMinus8:null,sequenceParameterSetExt:null};if(c===100||c===110||c===122||c===144){me(a);const d=me(a);d===3&&a.skipBits(1);const f=me(a),p=me(a);l.chromaFormat=d,l.bitDepthLumaMinus8=f,l.bitDepthChromaMinus8=p,l.sequenceParameterSetExt=i}return l}catch(e){return console.error("Error building AVC Decoder Configuration Record:",e),null}},Vv=s=>{const e=[];e.push(s.configurationVersion),e.push(s.avcProfileIndication),e.push(s.profileCompatibility),e.push(s.avcLevelIndication),e.push(252|s.lengthSizeMinusOne&3),e.push(224|s.sequenceParameterSets.length&31);for(const t of s.sequenceParameterSets){const r=t.byteLength;e.push(r>>8),e.push(r&255);for(let i=0;i<r;i++)e.push(t[i])}e.push(s.pictureParameterSets.length);for(const t of s.pictureParameterSets){const r=t.byteLength;e.push(r>>8),e.push(r&255);for(let i=0;i<r;i++)e.push(t[i])}if(s.avcProfileIndication===100||s.avcProfileIndication===110||s.avcProfileIndication===122||s.avcProfileIndication===144){Y(s.chromaFormat!==null),Y(s.bitDepthLumaMinus8!==null),Y(s.bitDepthChromaMinus8!==null),Y(s.sequenceParameterSetExt!==null),e.push(252|s.chromaFormat&3),e.push(248|s.bitDepthLumaMinus8&7),e.push(248|s.bitDepthChromaMinus8&7),e.push(s.sequenceParameterSetExt.length);for(const t of s.sequenceParameterSetExt){const r=t.byteLength;e.push(r>>8),e.push(r&255);for(let i=0;i<r;i++)e.push(t[i])}}return new Uint8Array(e)},Li=s=>s[0]>>1&63,jv=s=>{try{const e=_o(s),t=e.filter(_=>Li(_)===ar.VPS_NUT),r=e.filter(_=>Li(_)===ar.SPS_NUT),i=e.filter(_=>Li(_)===ar.PPS_NUT),n=e.filter(_=>Li(_)===ar.PREFIX_SEI_NUT||Li(_)===ar.SUFFIX_SEI_NUT);if(r.length===0||i.length===0)return null;const a=r[0],o=new Cs(To(a));o.skipBits(16),o.readBits(4);const c=o.readBits(3),u=o.readBits(1),{general_profile_space:h,general_tier_flag:l,general_profile_idc:d,general_profile_compatibility_flags:f,general_constraint_indicator_flags:p,general_level_idc:m}=Wv(o,c);me(o);const v=me(o);v===3&&o.skipBits(1),me(o),me(o),o.readBits(1)&&(me(o),me(o),me(o),me(o));const g=me(o),y=me(o);me(o);const k=o.readBits(1)?0:c;for(let _=k;_<=c;_++)me(o),me(o),me(o);me(o),me(o),me(o),me(o),me(o),me(o),o.readBits(1)&&o.readBits(1)&&Gv(o),o.skipBits(1),o.skipBits(1),o.readBits(1)&&(o.skipBits(4),o.skipBits(4),me(o),me(o),o.skipBits(1));const x=me(o);if(qv(o,x),o.readBits(1)){const _=me(o);for(let A=0;A<_;A++)me(o),o.skipBits(1)}o.skipBits(1),o.skipBits(1);let E=0;o.readBits(1)&&(E=Zv(o,c));let T=0;if(i.length>0){const _=i[0],A=new Cs(To(_));A.skipBits(16),me(A),me(A),A.skipBits(1),A.skipBits(1),A.skipBits(3),A.skipBits(1),A.skipBits(1),me(A),me(A),ks(A),A.skipBits(1),A.skipBits(1),A.readBits(1)&&me(A),ks(A),ks(A),A.skipBits(1),A.skipBits(1),A.skipBits(1),A.skipBits(1);const M=A.readBits(1),D=A.readBits(1);!M&&!D?T=0:M&&!D?T=2:!M&&D?T=3:T=0}const w=[...t.length?[{arrayCompleteness:1,nalUnitType:ar.VPS_NUT,nalUnits:t}]:[],...r.length?[{arrayCompleteness:1,nalUnitType:ar.SPS_NUT,nalUnits:r}]:[],...i.length?[{arrayCompleteness:1,nalUnitType:ar.PPS_NUT,nalUnits:i}]:[],...n.length?[{arrayCompleteness:1,nalUnitType:Li(n[0]),nalUnits:n}]:[]];return{configurationVersion:1,generalProfileSpace:h,generalTierFlag:l,generalProfileIdc:d,generalProfileCompatibilityFlags:f,generalConstraintIndicatorFlags:p,generalLevelIdc:m,minSpatialSegmentationIdc:E,parallelismType:T,chromaFormatIdc:v,bitDepthLumaMinus8:g,bitDepthChromaMinus8:y,avgFrameRate:0,constantFrameRate:0,numTemporalLayers:c+1,temporalIdNested:u,lengthSizeMinusOne:3,arrays:w}}catch(e){return console.error("Error building HEVC Decoder Configuration Record:",e),null}},Wv=(s,e)=>{const t=s.readBits(2),r=s.readBits(1),i=s.readBits(5);let n=0;for(let h=0;h<32;h++)n=n<<1|s.readBits(1);const a=new Uint8Array(6);for(let h=0;h<6;h++)a[h]=s.readBits(8);const o=s.readBits(8),c=[],u=[];for(let h=0;h<e;h++)c.push(s.readBits(1)),u.push(s.readBits(1));if(e>0)for(let h=e;h<8;h++)s.skipBits(2);for(let h=0;h<e;h++)c[h]&&s.skipBits(88),u[h]&&s.skipBits(8);return{general_profile_space:t,general_tier_flag:r,general_profile_idc:i,general_profile_compatibility_flags:n,general_constraint_indicator_flags:a,general_level_idc:o}},Gv=s=>{for(let e=0;e<4;e++)for(let t=0;t<(e===3?2:6);t++)if(!s.readBits(1))me(s);else{const i=Math.min(64,1<<4+(e<<1));e>1&&ks(s);for(let n=0;n<i;n++)ks(s)}},qv=(s,e)=>{const t=[];for(let r=0;r<e;r++)t[r]=Xv(s,r,e,t)},Xv=(s,e,t,r)=>{let i=0,n=0,a=0;if(e!==0&&(n=s.readBits(1)),n){if(e===t){const c=me(s);a=e-(c+1)}else a=e-1;s.readBits(1),me(s);const o=r[a]??0;for(let c=0;c<=o;c++)s.readBits(1)||s.readBits(1);i=r[a]}else{const o=me(s),c=me(s);for(let u=0;u<o;u++)me(s),s.readBits(1);for(let u=0;u<c;u++)me(s),s.readBits(1);i=o+c}return i},Zv=(s,e)=>{if(s.readBits(1)&&s.readBits(8)===255&&(s.readBits(16),s.readBits(16)),s.readBits(1)&&s.readBits(1),s.readBits(1)&&(s.readBits(3),s.readBits(1),s.readBits(1)&&(s.readBits(8),s.readBits(8),s.readBits(8))),s.readBits(1)&&(me(s),me(s)),s.readBits(1),s.readBits(1),s.readBits(1),s.readBits(1)&&(me(s),me(s),me(s),me(s)),s.readBits(1)&&(s.readBits(32),s.readBits(32),s.readBits(1)&&me(s),s.readBits(1)&&Kv(s,!0,e)),s.readBits(1)){s.readBits(1),s.readBits(1),s.readBits(1);const t=me(s);return me(s),me(s),me(s),me(s),t}return 0},Kv=(s,e,t)=>{let r=!1,i=!1,n=!1;r=s.readBits(1)===1,i=s.readBits(1)===1,(r||i)&&(n=s.readBits(1)===1,n&&(s.readBits(8),s.readBits(5),s.readBits(1),s.readBits(5)),s.readBits(4),s.readBits(4),n&&s.readBits(4),s.readBits(5),s.readBits(5),s.readBits(5));for(let a=0;a<=t;a++){const o=s.readBits(1)===1;let c=!0;o||(c=s.readBits(1)===1);let u=!1;c?me(s):u=s.readBits(1)===1;let h=1;u||(h=me(s)+1),r&&w0(s,h,n),i&&w0(s,h,n)}},w0=(s,e,t)=>{for(let r=0;r<e;r++)me(s),me(s),t&&(me(s),me(s)),s.readBits(1)},Yv=s=>{const e=[];e.push(s.configurationVersion),e.push((s.generalProfileSpace&3)<<6|(s.generalTierFlag&1)<<5|s.generalProfileIdc&31),e.push(s.generalProfileCompatibilityFlags>>>24&255),e.push(s.generalProfileCompatibilityFlags>>>16&255),e.push(s.generalProfileCompatibilityFlags>>>8&255),e.push(s.generalProfileCompatibilityFlags&255),e.push(...s.generalConstraintIndicatorFlags),e.push(s.generalLevelIdc&255),e.push(240|s.minSpatialSegmentationIdc>>8&15),e.push(s.minSpatialSegmentationIdc&255),e.push(252|s.parallelismType&3),e.push(252|s.chromaFormatIdc&3),e.push(248|s.bitDepthLumaMinus8&7),e.push(248|s.bitDepthChromaMinus8&7),e.push(s.avgFrameRate>>8&255),e.push(s.avgFrameRate&255),e.push((s.constantFrameRate&3)<<6|(s.numTemporalLayers&7)<<3|(s.temporalIdNested&1)<<2|s.lengthSizeMinusOne&3),e.push(s.arrays.length&255);for(const t of s.arrays){e.push((t.arrayCompleteness&1)<<7|0|t.nalUnitType&63),e.push(t.nalUnits.length>>8&255),e.push(t.nalUnits.length&255);for(const r of t.nalUnits){e.push(r.length>>8&255),e.push(r.length&255);for(let i=0;i<r.length;i++)e.push(r[i])}}return new Uint8Array(e)},Jv=s=>{const e=o0(s),t=e.getUint8(9),r=e.getUint16(10,!0),i=e.getUint32(12,!0),n=e.getInt16(16,!0),a=e.getUint8(18);let o=null;return a&&(o=s.subarray(19,21+t)),{outputChannelCount:t,preSkip:r,inputSampleRate:i,outputGain:n,channelMappingFamily:a,channelMappingTable:o}};var x0;(function(s){s[s.STREAMINFO=0]="STREAMINFO",s[s.VORBIS_COMMENT=4]="VORBIS_COMMENT",s[s.PICTURE=6]="PICTURE"})(x0||(x0={}));/*!
218
220
  * Copyright (c) 2025-present, Vanilagy and contributors
219
221
  *
220
222
  * This Source Code Form is subject to the terms of the Mozilla Public
221
223
  * License, v. 2.0. If a copy of the MPL was not distributed with this
222
224
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
223
- */const $l=[],Dl=[];/*!
225
+ */const Qv=[],ew=[];/*!
224
226
  * Copyright (c) 2025-present, Vanilagy and contributors
225
227
  *
226
228
  * This Source Code Form is subject to the terms of the Mozilla Public
227
229
  * License, v. 2.0. If a copy of the MPL was not distributed with this
228
230
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
229
- */const Kr=new Uint8Array(0);class ct{constructor(e,t,i,r,n=-1,o,a){if(this.data=e,this.type=t,this.timestamp=i,this.duration=r,this.sequenceNumber=n,e===Kr&&o===void 0)throw new Error("Internal error: byteLength must be explicitly provided when constructing metadata-only packets.");if(o===void 0&&(o=e.byteLength),!(e instanceof Uint8Array))throw new TypeError("data must be a Uint8Array.");if(t!=="key"&&t!=="delta")throw new TypeError('type must be either "key" or "delta".');if(!Number.isFinite(i))throw new TypeError("timestamp must be a number.");if(!Number.isFinite(r)||r<0)throw new TypeError("duration must be a non-negative number.");if(!Number.isFinite(n))throw new TypeError("sequenceNumber must be a number.");if(!Number.isInteger(o)||o<0)throw new TypeError("byteLength must be a non-negative integer.");if(a!==void 0&&(typeof a!="object"||!a))throw new TypeError("sideData, when provided, must be an object.");if(a?.alpha!==void 0&&!(a.alpha instanceof Uint8Array))throw new TypeError("sideData.alpha, when provided, must be a Uint8Array.");if(a?.alphaByteLength!==void 0&&(!Number.isInteger(a.alphaByteLength)||a.alphaByteLength<0))throw new TypeError("sideData.alphaByteLength, when provided, must be a non-negative integer.");this.byteLength=o,this.sideData=a??{},this.sideData.alpha&&this.sideData.alphaByteLength===void 0&&(this.sideData.alphaByteLength=this.sideData.alpha.byteLength)}get isMetadataOnly(){return this.data===Kr}get microsecondTimestamp(){return Math.trunc(lt*this.timestamp)}get microsecondDuration(){return Math.trunc(lt*this.duration)}toEncodedVideoChunk(){if(this.isMetadataOnly)throw new TypeError("Metadata-only packets cannot be converted to a video chunk.");if(typeof EncodedVideoChunk>"u")throw new Error("Your browser does not support EncodedVideoChunk.");return new EncodedVideoChunk({data:this.data,type:this.type,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}alphaToEncodedVideoChunk(e=this.type){if(!this.sideData.alpha)throw new TypeError("This packet does not contain alpha side data.");if(this.isMetadataOnly)throw new TypeError("Metadata-only packets cannot be converted to a video chunk.");if(typeof EncodedVideoChunk>"u")throw new Error("Your browser does not support EncodedVideoChunk.");return new EncodedVideoChunk({data:this.sideData.alpha,type:e,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}toEncodedAudioChunk(){if(this.isMetadataOnly)throw new TypeError("Metadata-only packets cannot be converted to an audio chunk.");if(typeof EncodedAudioChunk>"u")throw new Error("Your browser does not support EncodedAudioChunk.");return new EncodedAudioChunk({data:this.data,type:this.type,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}static fromEncodedChunk(e,t){if(!(e instanceof EncodedVideoChunk||e instanceof EncodedAudioChunk))throw new TypeError("chunk must be an EncodedVideoChunk or EncodedAudioChunk.");const i=new Uint8Array(e.byteLength);return e.copyTo(i),new ct(i,e.type,e.timestamp/1e6,(e.duration??0)/1e6,void 0,void 0,t)}clone(e){if(e!==void 0&&(typeof e!="object"||e===null))throw new TypeError("options, when provided, must be an object.");if(e?.timestamp!==void 0&&!Number.isFinite(e.timestamp))throw new TypeError("options.timestamp, when provided, must be a number.");if(e?.duration!==void 0&&!Number.isFinite(e.duration))throw new TypeError("options.duration, when provided, must be a number.");return new ct(this.data,this.type,e?.timestamp??this.timestamp,e?.duration??this.duration,this.sequenceNumber,this.byteLength)}}/*!
231
+ */const C0=new Uint8Array(0);class Hr{constructor(e,t,r,i,n=-1,a,o){if(this.data=e,this.type=t,this.timestamp=r,this.duration=i,this.sequenceNumber=n,e===C0&&a===void 0)throw new Error("Internal error: byteLength must be explicitly provided when constructing metadata-only packets.");if(a===void 0&&(a=e.byteLength),!(e instanceof Uint8Array))throw new TypeError("data must be a Uint8Array.");if(t!=="key"&&t!=="delta")throw new TypeError('type must be either "key" or "delta".');if(!Number.isFinite(r))throw new TypeError("timestamp must be a number.");if(!Number.isFinite(i)||i<0)throw new TypeError("duration must be a non-negative number.");if(!Number.isFinite(n))throw new TypeError("sequenceNumber must be a number.");if(!Number.isInteger(a)||a<0)throw new TypeError("byteLength must be a non-negative integer.");if(o!==void 0&&(typeof o!="object"||!o))throw new TypeError("sideData, when provided, must be an object.");if(o?.alpha!==void 0&&!(o.alpha instanceof Uint8Array))throw new TypeError("sideData.alpha, when provided, must be a Uint8Array.");if(o?.alphaByteLength!==void 0&&(!Number.isInteger(o.alphaByteLength)||o.alphaByteLength<0))throw new TypeError("sideData.alphaByteLength, when provided, must be a non-negative integer.");this.byteLength=a,this.sideData=o??{},this.sideData.alpha&&this.sideData.alphaByteLength===void 0&&(this.sideData.alphaByteLength=this.sideData.alpha.byteLength)}get isMetadataOnly(){return this.data===C0}get microsecondTimestamp(){return Math.trunc(Ur*this.timestamp)}get microsecondDuration(){return Math.trunc(Ur*this.duration)}toEncodedVideoChunk(){if(this.isMetadataOnly)throw new TypeError("Metadata-only packets cannot be converted to a video chunk.");if(typeof EncodedVideoChunk>"u")throw new Error("Your browser does not support EncodedVideoChunk.");return new EncodedVideoChunk({data:this.data,type:this.type,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}alphaToEncodedVideoChunk(e=this.type){if(!this.sideData.alpha)throw new TypeError("This packet does not contain alpha side data.");if(this.isMetadataOnly)throw new TypeError("Metadata-only packets cannot be converted to a video chunk.");if(typeof EncodedVideoChunk>"u")throw new Error("Your browser does not support EncodedVideoChunk.");return new EncodedVideoChunk({data:this.sideData.alpha,type:e,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}toEncodedAudioChunk(){if(this.isMetadataOnly)throw new TypeError("Metadata-only packets cannot be converted to an audio chunk.");if(typeof EncodedAudioChunk>"u")throw new Error("Your browser does not support EncodedAudioChunk.");return new EncodedAudioChunk({data:this.data,type:this.type,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}static fromEncodedChunk(e,t){if(!(e instanceof EncodedVideoChunk||e instanceof EncodedAudioChunk))throw new TypeError("chunk must be an EncodedVideoChunk or EncodedAudioChunk.");const r=new Uint8Array(e.byteLength);return e.copyTo(r),new Hr(r,e.type,e.timestamp/1e6,(e.duration??0)/1e6,void 0,void 0,t)}clone(e){if(e!==void 0&&(typeof e!="object"||e===null))throw new TypeError("options, when provided, must be an object.");if(e?.timestamp!==void 0&&!Number.isFinite(e.timestamp))throw new TypeError("options.timestamp, when provided, must be a number.");if(e?.duration!==void 0&&!Number.isFinite(e.duration))throw new TypeError("options.duration, when provided, must be a number.");return new Hr(this.data,this.type,e?.timestamp??this.timestamp,e?.duration??this.duration,this.sequenceNumber,this.byteLength)}}/*!
230
232
  * Copyright (c) 2025-present, Vanilagy and contributors
231
233
  *
232
234
  * This Source Code Form is subject to the terms of the Mozilla Public
233
235
  * License, v. 2.0. If a copy of the MPL was not distributed with this
234
236
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
235
- */const zl=s=>{let i=s,r=4096,n=0,o=12,a=0;for(i<0&&(i=-i,n=128),i+=33,i>8191&&(i=8191);(i&r)!==r&&o>=5;)r>>=1,o--;return a=i>>o-4&15,~(n|o-5<<4|a)&255},Hl=s=>{let t=2048,i=0,r=11,n=0,o=s;for(o<0&&(o=-o,i=128),o>4095&&(o=4095);(o&t)!==t&&r>=5;)t>>=1,r--;return n=o>>(r===4?1:r-4)&15,(i|r-4<<4|n)^85};/*!
237
+ */const tw=s=>{let r=s,i=4096,n=0,a=12,o=0;for(r<0&&(r=-r,n=128),r+=33,r>8191&&(r=8191);(r&i)!==i&&a>=5;)i>>=1,a--;return o=r>>a-4&15,~(n|a-5<<4|o)&255},rw=s=>{let t=2048,r=0,i=11,n=0,a=s;for(a<0&&(a=-a,r=128),a>4095&&(a=4095);(a&t)!==t&&i>=5;)t>>=1,i--;return n=a>>(i===4?1:i-4)&15,(r|i-4<<4|n)^85};/*!
236
238
  * Copyright (c) 2025-present, Vanilagy and contributors
237
239
  *
238
240
  * This Source Code Form is subject to the terms of the Mozilla Public
239
241
  * License, v. 2.0. If a copy of the MPL was not distributed with this
240
242
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
241
- */ol();class vt{get displayWidth(){return this.rotation%180===0?this.codedWidth:this.codedHeight}get displayHeight(){return this.rotation%180===0?this.codedHeight:this.codedWidth}get microsecondTimestamp(){return Math.trunc(lt*this.timestamp)}get microsecondDuration(){return Math.trunc(lt*this.duration)}get hasAlpha(){return this.format&&this.format.includes("A")}constructor(e,t){if(this._closed=!1,e instanceof ArrayBuffer||ArrayBuffer.isView(e)){if(!t||typeof t!="object")throw new TypeError("init must be an object.");if(!("format"in t)||typeof t.format!="string")throw new TypeError("init.format must be a string.");if(!Number.isInteger(t.codedWidth)||t.codedWidth<=0)throw new TypeError("init.codedWidth must be a positive integer.");if(!Number.isInteger(t.codedHeight)||t.codedHeight<=0)throw new TypeError("init.codedHeight must be a positive integer.");if(t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if(!Number.isFinite(t.timestamp))throw new TypeError("init.timestamp must be a number.");if(t.duration!==void 0&&(!Number.isFinite(t.duration)||t.duration<0))throw new TypeError("init.duration, when provided, must be a non-negative number.");this._data=ot(e).slice(),this.format=t.format,this.codedWidth=t.codedWidth,this.codedHeight=t.codedHeight,this.rotation=t.rotation??0,this.timestamp=t.timestamp,this.duration=t.duration??0,this.colorSpace=new VideoColorSpace(t.colorSpace)}else if(typeof VideoFrame<"u"&&e instanceof VideoFrame){if(t?.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if(t?.timestamp!==void 0&&!Number.isFinite(t?.timestamp))throw new TypeError("init.timestamp, when provided, must be a number.");if(t?.duration!==void 0&&(!Number.isFinite(t.duration)||t.duration<0))throw new TypeError("init.duration, when provided, must be a non-negative number.");this._data=e,this.format=e.format,this.codedWidth=e.displayWidth,this.codedHeight=e.displayHeight,this.rotation=t?.rotation??0,this.timestamp=t?.timestamp??e.timestamp/1e6,this.duration=t?.duration??(e.duration??0)/1e6,this.colorSpace=e.colorSpace}else if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof SVGImageElement<"u"&&e instanceof SVGImageElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas){if(!t||typeof t!="object")throw new TypeError("init must be an object.");if(t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if(!Number.isFinite(t.timestamp))throw new TypeError("init.timestamp must be a number.");if(t.duration!==void 0&&(!Number.isFinite(t.duration)||t.duration<0))throw new TypeError("init.duration, when provided, must be a non-negative number.");if(typeof VideoFrame<"u")return new vt(new VideoFrame(e,{timestamp:Math.trunc(t.timestamp*lt),duration:Math.trunc((t.duration??0)*lt)||void 0}),t);let i=0,r=0;if("naturalWidth"in e?(i=e.naturalWidth,r=e.naturalHeight):"videoWidth"in e?(i=e.videoWidth,r=e.videoHeight):"width"in e&&(i=Number(e.width),r=Number(e.height)),!i||!r)throw new TypeError("Could not determine dimensions.");const n=new OffscreenCanvas(i,r),o=n.getContext("2d",{alpha:ls(),willReadFrequently:!0});$(o),o.drawImage(e,0,0),this._data=n,this.format="RGBX",this.codedWidth=i,this.codedHeight=r,this.rotation=t.rotation??0,this.timestamp=t.timestamp,this.duration=t.duration??0,this.colorSpace=new VideoColorSpace({matrix:"rgb",primaries:"bt709",transfer:"iec61966-2-1",fullRange:!0})}else throw new TypeError("Invalid data type: Must be a BufferSource or CanvasImageSource.")}clone(){if(this._closed)throw new Error("VideoSample is closed.");return $(this._data!==null),ei(this._data)?new vt(this._data.clone(),{timestamp:this.timestamp,duration:this.duration,rotation:this.rotation}):this._data instanceof Uint8Array?new vt(this._data.slice(),{format:this.format,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.timestamp,duration:this.duration,colorSpace:this.colorSpace,rotation:this.rotation}):new vt(this._data,{format:this.format,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.timestamp,duration:this.duration,colorSpace:this.colorSpace,rotation:this.rotation})}close(){this._closed||(ei(this._data)?this._data.close():this._data=null,this._closed=!0)}allocationSize(){if(this._closed)throw new Error("VideoSample is closed.");return $(this._data!==null),ei(this._data)?this._data.allocationSize():this._data instanceof Uint8Array?this._data.byteLength:this.codedWidth*this.codedHeight*4}async copyTo(e){if(!xi(e))throw new TypeError("destination must be an ArrayBuffer or an ArrayBuffer view.");if(this._closed)throw new Error("VideoSample is closed.");if($(this._data!==null),ei(this._data))await this._data.copyTo(e);else if(this._data instanceof Uint8Array)ot(e).set(this._data);else{const i=this._data.getContext("2d");$(i);const r=i.getImageData(0,0,this.codedWidth,this.codedHeight);ot(e).set(r.data)}}toVideoFrame(){if(this._closed)throw new Error("VideoSample is closed.");return $(this._data!==null),ei(this._data)?new VideoFrame(this._data,{timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0}):this._data instanceof Uint8Array?new VideoFrame(this._data,{format:this.format,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0,colorSpace:this.colorSpace}):new VideoFrame(this._data,{timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0})}draw(e,t,i,r,n,o,a,p,m){let d=0,l=0,c=this.displayWidth,u=this.displayHeight,h=0,f=0,b=this.displayWidth,g=this.displayHeight;if(o!==void 0?(d=t,l=i,c=r,u=n,h=o,f=a,p!==void 0?(b=p,g=m):(b=c,g=u)):(h=t,f=i,r!==void 0&&(b=r,g=n)),!(typeof CanvasRenderingContext2D<"u"&&e instanceof CanvasRenderingContext2D||typeof OffscreenCanvasRenderingContext2D<"u"&&e instanceof OffscreenCanvasRenderingContext2D))throw new TypeError("context must be a CanvasRenderingContext2D or OffscreenCanvasRenderingContext2D.");if(!Number.isFinite(d))throw new TypeError("sx must be a number.");if(!Number.isFinite(l))throw new TypeError("sy must be a number.");if(!Number.isFinite(c)||c<0)throw new TypeError("sWidth must be a non-negative number.");if(!Number.isFinite(u)||u<0)throw new TypeError("sHeight must be a non-negative number.");if(!Number.isFinite(h))throw new TypeError("dx must be a number.");if(!Number.isFinite(f))throw new TypeError("dy must be a number.");if(!Number.isFinite(b)||b<0)throw new TypeError("dWidth must be a non-negative number.");if(!Number.isFinite(g)||g<0)throw new TypeError("dHeight must be a non-negative number.");if(this._closed)throw new Error("VideoSample is closed.");({sx:d,sy:l,sWidth:c,sHeight:u}=this._rotateSourceRegion(d,l,c,u,this.rotation));const y=this.toCanvasImageSource();e.save();const v=h+b/2,_=f+g/2;e.translate(v,_),e.rotate(this.rotation*Math.PI/180);const C=this.rotation%180===0?1:b/g;e.scale(1/C,C),e.drawImage(y,d,l,c,u,-b/2,-g/2,b,g),e.restore()}drawWithFit(e,t){if(!(typeof CanvasRenderingContext2D<"u"&&e instanceof CanvasRenderingContext2D||typeof OffscreenCanvasRenderingContext2D<"u"&&e instanceof OffscreenCanvasRenderingContext2D))throw new TypeError("context must be a CanvasRenderingContext2D or OffscreenCanvasRenderingContext2D.");if(!t||typeof t!="object")throw new TypeError("options must be an object.");if(!["fill","contain","cover"].includes(t.fit))throw new TypeError("options.fit must be 'fill', 'contain', or 'cover'.");if(t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError("options.rotation, when provided, must be 0, 90, 180, or 270.");t.crop!==void 0&&Ul(t.crop,"options.");const i=e.canvas.width,r=e.canvas.height,n=t.rotation??this.rotation,[o,a]=n%180===0?[this.codedWidth,this.codedHeight]:[this.codedHeight,this.codedWidth];t.crop&&Nl(t.crop,o,a);let p,m,d,l;const{sx:c,sy:u,sWidth:h,sHeight:f}=this._rotateSourceRegion(t.crop?.left??0,t.crop?.top??0,t.crop?.width??o,t.crop?.height??a,n);if(t.fit==="fill")p=0,m=0,d=i,l=r;else{const[g,y]=t.crop?[t.crop.width,t.crop.height]:[o,a],v=t.fit==="contain"?Math.min(i/g,r/y):Math.max(i/g,r/y);d=g*v,l=y*v,p=(i-d)/2,m=(r-l)/2}const b=n%180===0?1:d/l;e.translate(i/2,r/2),e.rotate(n*Math.PI/180),e.scale(1/b,b),e.translate(-i/2,-r/2),e.drawImage(this.toCanvasImageSource(),c,u,h,f,p,m,d,l)}_rotateSourceRegion(e,t,i,r,n){return n===90?[e,t,i,r]=[t,this.codedHeight-e-i,r,i]:n===180?[e,t]=[this.codedWidth-e-i,this.codedHeight-t-r]:n===270&&([e,t,i,r]=[this.codedWidth-t-r,e,r,i]),{sx:e,sy:t,sWidth:i,sHeight:r}}toCanvasImageSource(){if(this._closed)throw new Error("VideoSample is closed.");if($(this._data!==null),this._data instanceof Uint8Array){const e=this.toVideoFrame();return queueMicrotask(()=>e.close()),e}else return this._data}setRotation(e){if(![0,90,180,270].includes(e))throw new TypeError("newRotation must be 0, 90, 180, or 270.");this.rotation=e}setTimestamp(e){if(!Number.isFinite(e))throw new TypeError("newTimestamp must be a number.");this.timestamp=e}setDuration(e){if(!Number.isFinite(e)||e<0)throw new TypeError("newDuration must be a non-negative number.");this.duration=e}[Symbol.dispose](){this.close()}}const ei=s=>typeof VideoFrame<"u"&&s instanceof VideoFrame,Nl=(s,e,t)=>{s.left=Math.min(s.left,e),s.top=Math.min(s.top,t),s.width=Math.min(s.width,e-s.left),s.height=Math.min(s.height,t-s.top),$(s.width>=0),$(s.height>=0)},Ul=(s,e)=>{if(!s||typeof s!="object")throw new TypeError(e+"crop, when provided, must be an object.");if(!Number.isInteger(s.left)||s.left<0)throw new TypeError(e+"crop.left must be a non-negative integer.");if(!Number.isInteger(s.top)||s.top<0)throw new TypeError(e+"crop.top must be a non-negative integer.");if(!Number.isInteger(s.width)||s.width<0)throw new TypeError(e+"crop.width must be a non-negative integer.");if(!Number.isInteger(s.height)||s.height<0)throw new TypeError(e+"crop.height must be a non-negative integer.")},ds=new Set(["f32","f32-planar","s16","s16-planar","s32","s32-planar","u8","u8-planar"]);class wt{get microsecondTimestamp(){return Math.trunc(lt*this.timestamp)}get microsecondDuration(){return Math.trunc(lt*this.duration)}constructor(e){if(this._closed=!1,ii(e)){if(e.format===null)throw new TypeError("AudioData with null format is not supported.");this._data=e,this.format=e.format,this.sampleRate=e.sampleRate,this.numberOfFrames=e.numberOfFrames,this.numberOfChannels=e.numberOfChannels,this.timestamp=e.timestamp/1e6,this.duration=e.numberOfFrames/e.sampleRate}else{if(!e||typeof e!="object")throw new TypeError("Invalid AudioDataInit: must be an object.");if(!ds.has(e.format))throw new TypeError("Invalid AudioDataInit: invalid format.");if(!Number.isFinite(e.sampleRate)||e.sampleRate<=0)throw new TypeError("Invalid AudioDataInit: sampleRate must be > 0.");if(!Number.isInteger(e.numberOfChannels)||e.numberOfChannels===0)throw new TypeError("Invalid AudioDataInit: numberOfChannels must be an integer > 0.");if(!Number.isFinite(e?.timestamp))throw new TypeError("init.timestamp must be a number.");const t=e.data.byteLength/(ti(e.format)*e.numberOfChannels);if(!Number.isInteger(t))throw new TypeError("Invalid AudioDataInit: data size is not a multiple of frame size.");this.format=e.format,this.sampleRate=e.sampleRate,this.numberOfFrames=t,this.numberOfChannels=e.numberOfChannels,this.timestamp=e.timestamp,this.duration=t/e.sampleRate;let i;if(e.data instanceof ArrayBuffer)i=new Uint8Array(e.data);else if(ArrayBuffer.isView(e.data))i=new Uint8Array(e.data.buffer,e.data.byteOffset,e.data.byteLength);else throw new TypeError("Invalid AudioDataInit: data is not a BufferSource.");const r=this.numberOfFrames*this.numberOfChannels*ti(this.format);if(i.byteLength<r)throw new TypeError("Invalid AudioDataInit: insufficient data size.");this._data=i}}allocationSize(e){if(!e||typeof e!="object")throw new TypeError("options must be an object.");if(!Number.isInteger(e.planeIndex)||e.planeIndex<0)throw new TypeError("planeIndex must be a non-negative integer.");if(e.format!==void 0&&!ds.has(e.format))throw new TypeError("Invalid format.");if(e.frameOffset!==void 0&&(!Number.isInteger(e.frameOffset)||e.frameOffset<0))throw new TypeError("frameOffset must be a non-negative integer.");if(e.frameCount!==void 0&&(!Number.isInteger(e.frameCount)||e.frameCount<0))throw new TypeError("frameCount must be a non-negative integer.");if(this._closed)throw new Error("AudioSample is closed.");const t=e.format??this.format,i=e.frameOffset??0;if(i>=this.numberOfFrames)throw new RangeError("frameOffset out of range");const r=e.frameCount!==void 0?e.frameCount:this.numberOfFrames-i;if(r>this.numberOfFrames-i)throw new RangeError("frameCount out of range");const n=ti(t),o=ki(t);if(o&&e.planeIndex>=this.numberOfChannels)throw new RangeError("planeIndex out of range");if(!o&&e.planeIndex!==0)throw new RangeError("planeIndex out of range");return(o?r:r*this.numberOfChannels)*n}copyTo(e,t){if(!xi(e))throw new TypeError("destination must be an ArrayBuffer or an ArrayBuffer view.");if(!t||typeof t!="object")throw new TypeError("options must be an object.");if(!Number.isInteger(t.planeIndex)||t.planeIndex<0)throw new TypeError("planeIndex must be a non-negative integer.");if(t.format!==void 0&&!ds.has(t.format))throw new TypeError("Invalid format.");if(t.frameOffset!==void 0&&(!Number.isInteger(t.frameOffset)||t.frameOffset<0))throw new TypeError("frameOffset must be a non-negative integer.");if(t.frameCount!==void 0&&(!Number.isInteger(t.frameCount)||t.frameCount<0))throw new TypeError("frameCount must be a non-negative integer.");if(this._closed)throw new Error("AudioSample is closed.");const{planeIndex:i,format:r,frameCount:n,frameOffset:o}=t,a=r??this.format;if(!a)throw new Error("Destination format not determined");const p=this.numberOfFrames,m=this.numberOfChannels,d=o??0;if(d>=p)throw new RangeError("frameOffset out of range");const l=n!==void 0?n:p-d;if(l>p-d)throw new RangeError("frameCount out of range");const c=ti(a),u=ki(a);if(u&&i>=m)throw new RangeError("planeIndex out of range");if(!u&&i!==0)throw new RangeError("planeIndex out of range");const f=(u?l:l*m)*c;if(e.byteLength<f)throw new RangeError("Destination buffer is too small");const b=Fr(e),g=Vl(a);if(ii(this._data))if(u)if(a==="f32-planar")this._data.copyTo(e,{planeIndex:i,frameOffset:d,frameCount:l,format:"f32-planar"});else{const y=new ArrayBuffer(l*4),v=new Float32Array(y);this._data.copyTo(v,{planeIndex:i,frameOffset:d,frameCount:l,format:"f32-planar"});const _=new DataView(y);for(let C=0;C<l;C++){const S=C*c,T=_.getFloat32(C*4,!0);g(b,S,T)}}else{const y=m,v=new Float32Array(l);for(let _=0;_<y;_++){this._data.copyTo(v,{planeIndex:_,frameOffset:d,frameCount:l,format:"f32-planar"});for(let C=0;C<l;C++){const T=(C*y+_)*c;g(b,T,v[C])}}}else{const y=this._data,v=new DataView(y.buffer,y.byteOffset,y.byteLength),_=this.format,C=jl(_),S=ti(_),T=ki(_);for(let w=0;w<l;w++)if(u){const x=w*c;let k;T?k=(i*p+(w+d))*S:k=((w+d)*m+i)*S;const E=C(v,k);g(b,x,E)}else for(let x=0;x<m;x++){const E=(w*m+x)*c;let P;T?P=(x*p+(w+d))*S:P=((w+d)*m+x)*S;const O=C(v,P);g(b,E,O)}}}clone(){if(this._closed)throw new Error("AudioSample is closed.");if(ii(this._data)){const e=new wt(this._data.clone());return e.setTimestamp(this.timestamp),e}else return new wt({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.timestamp,data:this._data})}close(){this._closed||(ii(this._data)?this._data.close():this._data=new Uint8Array(0),this._closed=!0)}toAudioData(){if(this._closed)throw new Error("AudioSample is closed.");if(ii(this._data)){if(this._data.timestamp===this.microsecondTimestamp)return this._data.clone();if(ki(this.format)){const e=this.allocationSize({planeIndex:0,format:this.format}),t=new ArrayBuffer(e*this.numberOfChannels);for(let i=0;i<this.numberOfChannels;i++)this.copyTo(new Uint8Array(t,i*e,e),{planeIndex:i,format:this.format});return new AudioData({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.microsecondTimestamp,data:t})}else{const e=new ArrayBuffer(this.allocationSize({planeIndex:0,format:this.format}));return this.copyTo(e,{planeIndex:0,format:this.format}),new AudioData({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.microsecondTimestamp,data:e})}}else return new AudioData({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.microsecondTimestamp,data:this._data})}toAudioBuffer(){if(this._closed)throw new Error("AudioSample is closed.");const e=new AudioBuffer({numberOfChannels:this.numberOfChannels,length:this.numberOfFrames,sampleRate:this.sampleRate}),t=new Float32Array(this.allocationSize({planeIndex:0,format:"f32-planar"})/4);for(let i=0;i<this.numberOfChannels;i++)this.copyTo(t,{planeIndex:i,format:"f32-planar"}),e.copyToChannel(t,i);return e}setTimestamp(e){if(!Number.isFinite(e))throw new TypeError("newTimestamp must be a number.");this.timestamp=e}[Symbol.dispose](){this.close()}static*_fromAudioBuffer(e,t){if(!(e instanceof AudioBuffer))throw new TypeError("audioBuffer must be an AudioBuffer.");const i=48e3*5,r=e.numberOfChannels,n=e.sampleRate,o=e.length,a=Math.floor(i/r);let p=0,m=o;for(;m>0;){const d=Math.min(a,m),l=new Float32Array(r*d);for(let c=0;c<r;c++)e.copyFromChannel(l.subarray(c*d,(c+1)*d),c,p);yield new wt({format:"f32-planar",sampleRate:n,numberOfFrames:d,numberOfChannels:r,timestamp:t+p/n,data:l}),p+=d,m-=d}}static fromAudioBuffer(e,t){if(!(e instanceof AudioBuffer))throw new TypeError("audioBuffer must be an AudioBuffer.");const i=48e3*5,r=e.numberOfChannels,n=e.sampleRate,o=e.length,a=Math.floor(i/r);let p=0,m=o;const d=[];for(;m>0;){const l=Math.min(a,m),c=new Float32Array(r*l);for(let h=0;h<r;h++)e.copyFromChannel(c.subarray(h*l,(h+1)*l),h,p);const u=new wt({format:"f32-planar",sampleRate:n,numberOfFrames:l,numberOfChannels:r,timestamp:t+p/n,data:c});d.push(u),p+=l,m-=l}return d}}const ti=s=>{switch(s){case"u8":case"u8-planar":return 1;case"s16":case"s16-planar":return 2;case"s32":case"s32-planar":return 4;case"f32":case"f32-planar":return 4;default:throw new Error("Unknown AudioSampleFormat")}},ki=s=>{switch(s){case"u8-planar":case"s16-planar":case"s32-planar":case"f32-planar":return!0;default:return!1}},jl=s=>{switch(s){case"u8":case"u8-planar":return(e,t)=>(e.getUint8(t)-128)/128;case"s16":case"s16-planar":return(e,t)=>e.getInt16(t,!0)/32768;case"s32":case"s32-planar":return(e,t)=>e.getInt32(t,!0)/2147483648;case"f32":case"f32-planar":return(e,t)=>e.getFloat32(t,!0)}},Vl=s=>{switch(s){case"u8":case"u8-planar":return(e,t,i)=>e.setUint8(t,Se((i+1)*127.5,0,255));case"s16":case"s16-planar":return(e,t,i)=>e.setInt16(t,Se(Math.round(i*32767),-32768,32767),!0);case"s32":case"s32-planar":return(e,t,i)=>e.setInt32(t,Se(Math.round(i*2147483647),-2147483648,2147483647),!0);case"f32":case"f32-planar":return(e,t,i)=>e.setFloat32(t,i,!0)}},ii=s=>typeof AudioData<"u"&&s instanceof AudioData;/*!
243
+ */kv();class ci{get displayWidth(){return this.rotation%180===0?this.codedWidth:this.codedHeight}get displayHeight(){return this.rotation%180===0?this.codedHeight:this.codedWidth}get microsecondTimestamp(){return Math.trunc(Ur*this.timestamp)}get microsecondDuration(){return Math.trunc(Ur*this.duration)}get hasAlpha(){return this.format&&this.format.includes("A")}constructor(e,t){if(this._closed=!1,e instanceof ArrayBuffer||ArrayBuffer.isView(e)){if(!t||typeof t!="object")throw new TypeError("init must be an object.");if(!("format"in t)||typeof t.format!="string")throw new TypeError("init.format must be a string.");if(!Number.isInteger(t.codedWidth)||t.codedWidth<=0)throw new TypeError("init.codedWidth must be a positive integer.");if(!Number.isInteger(t.codedHeight)||t.codedHeight<=0)throw new TypeError("init.codedHeight must be a positive integer.");if(t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if(!Number.isFinite(t.timestamp))throw new TypeError("init.timestamp must be a number.");if(t.duration!==void 0&&(!Number.isFinite(t.duration)||t.duration<0))throw new TypeError("init.duration, when provided, must be a non-negative number.");this._data=Nr(e).slice(),this.format=t.format,this.codedWidth=t.codedWidth,this.codedHeight=t.codedHeight,this.rotation=t.rotation??0,this.timestamp=t.timestamp,this.duration=t.duration??0,this.colorSpace=new VideoColorSpace(t.colorSpace)}else if(typeof VideoFrame<"u"&&e instanceof VideoFrame){if(t?.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if(t?.timestamp!==void 0&&!Number.isFinite(t?.timestamp))throw new TypeError("init.timestamp, when provided, must be a number.");if(t?.duration!==void 0&&(!Number.isFinite(t.duration)||t.duration<0))throw new TypeError("init.duration, when provided, must be a non-negative number.");this._data=e,this.format=e.format,this.codedWidth=e.displayWidth,this.codedHeight=e.displayHeight,this.rotation=t?.rotation??0,this.timestamp=t?.timestamp??e.timestamp/1e6,this.duration=t?.duration??(e.duration??0)/1e6,this.colorSpace=e.colorSpace}else if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof SVGImageElement<"u"&&e instanceof SVGImageElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas){if(!t||typeof t!="object")throw new TypeError("init must be an object.");if(t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if(!Number.isFinite(t.timestamp))throw new TypeError("init.timestamp must be a number.");if(t.duration!==void 0&&(!Number.isFinite(t.duration)||t.duration<0))throw new TypeError("init.duration, when provided, must be a non-negative number.");if(typeof VideoFrame<"u")return new ci(new VideoFrame(e,{timestamp:Math.trunc(t.timestamp*Ur),duration:Math.trunc((t.duration??0)*Ur)||void 0}),t);let r=0,i=0;if("naturalWidth"in e?(r=e.naturalWidth,i=e.naturalHeight):"videoWidth"in e?(r=e.videoWidth,i=e.videoHeight):"width"in e&&(r=Number(e.width),i=Number(e.height)),!r||!i)throw new TypeError("Could not determine dimensions.");const n=new OffscreenCanvas(r,i),a=n.getContext("2d",{alpha:So(),willReadFrequently:!0});Y(a),a.drawImage(e,0,0),this._data=n,this.format="RGBX",this.codedWidth=r,this.codedHeight=i,this.rotation=t.rotation??0,this.timestamp=t.timestamp,this.duration=t.duration??0,this.colorSpace=new VideoColorSpace({matrix:"rgb",primaries:"bt709",transfer:"iec61966-2-1",fullRange:!0})}else throw new TypeError("Invalid data type: Must be a BufferSource or CanvasImageSource.")}clone(){if(this._closed)throw new Error("VideoSample is closed.");return Y(this._data!==null),_s(this._data)?new ci(this._data.clone(),{timestamp:this.timestamp,duration:this.duration,rotation:this.rotation}):this._data instanceof Uint8Array?new ci(this._data.slice(),{format:this.format,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.timestamp,duration:this.duration,colorSpace:this.colorSpace,rotation:this.rotation}):new ci(this._data,{format:this.format,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.timestamp,duration:this.duration,colorSpace:this.colorSpace,rotation:this.rotation})}close(){this._closed||(_s(this._data)?this._data.close():this._data=null,this._closed=!0)}allocationSize(){if(this._closed)throw new Error("VideoSample is closed.");return Y(this._data!==null),_s(this._data)?this._data.allocationSize():this._data instanceof Uint8Array?this._data.byteLength:this.codedWidth*this.codedHeight*4}async copyTo(e){if(!Ln(e))throw new TypeError("destination must be an ArrayBuffer or an ArrayBuffer view.");if(this._closed)throw new Error("VideoSample is closed.");if(Y(this._data!==null),_s(this._data))await this._data.copyTo(e);else if(this._data instanceof Uint8Array)Nr(e).set(this._data);else{const r=this._data.getContext("2d");Y(r);const i=r.getImageData(0,0,this.codedWidth,this.codedHeight);Nr(e).set(i.data)}}toVideoFrame(){if(this._closed)throw new Error("VideoSample is closed.");return Y(this._data!==null),_s(this._data)?new VideoFrame(this._data,{timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0}):this._data instanceof Uint8Array?new VideoFrame(this._data,{format:this.format,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0,colorSpace:this.colorSpace}):new VideoFrame(this._data,{timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0})}draw(e,t,r,i,n,a,o,c,u){let h=0,l=0,d=this.displayWidth,f=this.displayHeight,p=0,m=0,v=this.displayWidth,g=this.displayHeight;if(a!==void 0?(h=t,l=r,d=i,f=n,p=a,m=o,c!==void 0?(v=c,g=u):(v=d,g=f)):(p=t,m=r,i!==void 0&&(v=i,g=n)),!(typeof CanvasRenderingContext2D<"u"&&e instanceof CanvasRenderingContext2D||typeof OffscreenCanvasRenderingContext2D<"u"&&e instanceof OffscreenCanvasRenderingContext2D))throw new TypeError("context must be a CanvasRenderingContext2D or OffscreenCanvasRenderingContext2D.");if(!Number.isFinite(h))throw new TypeError("sx must be a number.");if(!Number.isFinite(l))throw new TypeError("sy must be a number.");if(!Number.isFinite(d)||d<0)throw new TypeError("sWidth must be a non-negative number.");if(!Number.isFinite(f)||f<0)throw new TypeError("sHeight must be a non-negative number.");if(!Number.isFinite(p))throw new TypeError("dx must be a number.");if(!Number.isFinite(m))throw new TypeError("dy must be a number.");if(!Number.isFinite(v)||v<0)throw new TypeError("dWidth must be a non-negative number.");if(!Number.isFinite(g)||g<0)throw new TypeError("dHeight must be a non-negative number.");if(this._closed)throw new Error("VideoSample is closed.");({sx:h,sy:l,sWidth:d,sHeight:f}=this._rotateSourceRegion(h,l,d,f,this.rotation));const y=this.toCanvasImageSource();e.save();const b=p+v/2,k=m+g/2;e.translate(b,k),e.rotate(this.rotation*Math.PI/180);const x=this.rotation%180===0?1:v/g;e.scale(1/x,x),e.drawImage(y,h,l,d,f,-v/2,-g/2,v,g),e.restore()}drawWithFit(e,t){if(!(typeof CanvasRenderingContext2D<"u"&&e instanceof CanvasRenderingContext2D||typeof OffscreenCanvasRenderingContext2D<"u"&&e instanceof OffscreenCanvasRenderingContext2D))throw new TypeError("context must be a CanvasRenderingContext2D or OffscreenCanvasRenderingContext2D.");if(!t||typeof t!="object")throw new TypeError("options must be an object.");if(!["fill","contain","cover"].includes(t.fit))throw new TypeError("options.fit must be 'fill', 'contain', or 'cover'.");if(t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError("options.rotation, when provided, must be 0, 90, 180, or 270.");t.crop!==void 0&&sw(t.crop,"options.");const r=e.canvas.width,i=e.canvas.height,n=t.rotation??this.rotation,[a,o]=n%180===0?[this.codedWidth,this.codedHeight]:[this.codedHeight,this.codedWidth];t.crop&&iw(t.crop,a,o);let c,u,h,l;const{sx:d,sy:f,sWidth:p,sHeight:m}=this._rotateSourceRegion(t.crop?.left??0,t.crop?.top??0,t.crop?.width??a,t.crop?.height??o,n);if(t.fit==="fill")c=0,u=0,h=r,l=i;else{const[g,y]=t.crop?[t.crop.width,t.crop.height]:[a,o],b=t.fit==="contain"?Math.min(r/g,i/y):Math.max(r/g,i/y);h=g*b,l=y*b,c=(r-h)/2,u=(i-l)/2}const v=n%180===0?1:h/l;e.translate(r/2,i/2),e.rotate(n*Math.PI/180),e.scale(1/v,v),e.translate(-r/2,-i/2),e.drawImage(this.toCanvasImageSource(),d,f,p,m,c,u,h,l)}_rotateSourceRegion(e,t,r,i,n){return n===90?[e,t,r,i]=[t,this.codedHeight-e-r,i,r]:n===180?[e,t]=[this.codedWidth-e-r,this.codedHeight-t-i]:n===270&&([e,t,r,i]=[this.codedWidth-t-i,e,i,r]),{sx:e,sy:t,sWidth:r,sHeight:i}}toCanvasImageSource(){if(this._closed)throw new Error("VideoSample is closed.");if(Y(this._data!==null),this._data instanceof Uint8Array){const e=this.toVideoFrame();return queueMicrotask(()=>e.close()),e}else return this._data}setRotation(e){if(![0,90,180,270].includes(e))throw new TypeError("newRotation must be 0, 90, 180, or 270.");this.rotation=e}setTimestamp(e){if(!Number.isFinite(e))throw new TypeError("newTimestamp must be a number.");this.timestamp=e}setDuration(e){if(!Number.isFinite(e)||e<0)throw new TypeError("newDuration must be a non-negative number.");this.duration=e}[Symbol.dispose](){this.close()}}const _s=s=>typeof VideoFrame<"u"&&s instanceof VideoFrame,iw=(s,e,t)=>{s.left=Math.min(s.left,e),s.top=Math.min(s.top,t),s.width=Math.min(s.width,e-s.left),s.height=Math.min(s.height,t-s.top),Y(s.width>=0),Y(s.height>=0)},sw=(s,e)=>{if(!s||typeof s!="object")throw new TypeError(e+"crop, when provided, must be an object.");if(!Number.isInteger(s.left)||s.left<0)throw new TypeError(e+"crop.left must be a non-negative integer.");if(!Number.isInteger(s.top)||s.top<0)throw new TypeError(e+"crop.top must be a non-negative integer.");if(!Number.isInteger(s.width)||s.width<0)throw new TypeError(e+"crop.width must be a non-negative integer.");if(!Number.isInteger(s.height)||s.height<0)throw new TypeError(e+"crop.height must be a non-negative integer.")},Ao=new Set(["f32","f32-planar","s16","s16-planar","s32","s32-planar","u8","u8-planar"]);class ui{get microsecondTimestamp(){return Math.trunc(Ur*this.timestamp)}get microsecondDuration(){return Math.trunc(Ur*this.duration)}constructor(e){if(this._closed=!1,Es(e)){if(e.format===null)throw new TypeError("AudioData with null format is not supported.");this._data=e,this.format=e.format,this.sampleRate=e.sampleRate,this.numberOfFrames=e.numberOfFrames,this.numberOfChannels=e.numberOfChannels,this.timestamp=e.timestamp/1e6,this.duration=e.numberOfFrames/e.sampleRate}else{if(!e||typeof e!="object")throw new TypeError("Invalid AudioDataInit: must be an object.");if(!Ao.has(e.format))throw new TypeError("Invalid AudioDataInit: invalid format.");if(!Number.isFinite(e.sampleRate)||e.sampleRate<=0)throw new TypeError("Invalid AudioDataInit: sampleRate must be > 0.");if(!Number.isInteger(e.numberOfChannels)||e.numberOfChannels===0)throw new TypeError("Invalid AudioDataInit: numberOfChannels must be an integer > 0.");if(!Number.isFinite(e?.timestamp))throw new TypeError("init.timestamp must be a number.");const t=e.data.byteLength/(Ts(e.format)*e.numberOfChannels);if(!Number.isInteger(t))throw new TypeError("Invalid AudioDataInit: data size is not a multiple of frame size.");this.format=e.format,this.sampleRate=e.sampleRate,this.numberOfFrames=t,this.numberOfChannels=e.numberOfChannels,this.timestamp=e.timestamp,this.duration=t/e.sampleRate;let r;if(e.data instanceof ArrayBuffer)r=new Uint8Array(e.data);else if(ArrayBuffer.isView(e.data))r=new Uint8Array(e.data.buffer,e.data.byteOffset,e.data.byteLength);else throw new TypeError("Invalid AudioDataInit: data is not a BufferSource.");const i=this.numberOfFrames*this.numberOfChannels*Ts(this.format);if(r.byteLength<i)throw new TypeError("Invalid AudioDataInit: insufficient data size.");this._data=r}}allocationSize(e){if(!e||typeof e!="object")throw new TypeError("options must be an object.");if(!Number.isInteger(e.planeIndex)||e.planeIndex<0)throw new TypeError("planeIndex must be a non-negative integer.");if(e.format!==void 0&&!Ao.has(e.format))throw new TypeError("Invalid format.");if(e.frameOffset!==void 0&&(!Number.isInteger(e.frameOffset)||e.frameOffset<0))throw new TypeError("frameOffset must be a non-negative integer.");if(e.frameCount!==void 0&&(!Number.isInteger(e.frameCount)||e.frameCount<0))throw new TypeError("frameCount must be a non-negative integer.");if(this._closed)throw new Error("AudioSample is closed.");const t=e.format??this.format,r=e.frameOffset??0;if(r>=this.numberOfFrames)throw new RangeError("frameOffset out of range");const i=e.frameCount!==void 0?e.frameCount:this.numberOfFrames-r;if(i>this.numberOfFrames-r)throw new RangeError("frameCount out of range");const n=Ts(t),a=$n(t);if(a&&e.planeIndex>=this.numberOfChannels)throw new RangeError("planeIndex out of range");if(!a&&e.planeIndex!==0)throw new RangeError("planeIndex out of range");return(a?i:i*this.numberOfChannels)*n}copyTo(e,t){if(!Ln(e))throw new TypeError("destination must be an ArrayBuffer or an ArrayBuffer view.");if(!t||typeof t!="object")throw new TypeError("options must be an object.");if(!Number.isInteger(t.planeIndex)||t.planeIndex<0)throw new TypeError("planeIndex must be a non-negative integer.");if(t.format!==void 0&&!Ao.has(t.format))throw new TypeError("Invalid format.");if(t.frameOffset!==void 0&&(!Number.isInteger(t.frameOffset)||t.frameOffset<0))throw new TypeError("frameOffset must be a non-negative integer.");if(t.frameCount!==void 0&&(!Number.isInteger(t.frameCount)||t.frameCount<0))throw new TypeError("frameCount must be a non-negative integer.");if(this._closed)throw new Error("AudioSample is closed.");const{planeIndex:r,format:i,frameCount:n,frameOffset:a}=t,o=i??this.format;if(!o)throw new Error("Destination format not determined");const c=this.numberOfFrames,u=this.numberOfChannels,h=a??0;if(h>=c)throw new RangeError("frameOffset out of range");const l=n!==void 0?n:c-h;if(l>c-h)throw new RangeError("frameCount out of range");const d=Ts(o),f=$n(o);if(f&&r>=u)throw new RangeError("planeIndex out of range");if(!f&&r!==0)throw new RangeError("planeIndex out of range");const m=(f?l:l*u)*d;if(e.byteLength<m)throw new RangeError("Destination buffer is too small");const v=o0(e),g=aw(o);if(Es(this._data))if(f)if(o==="f32-planar")this._data.copyTo(e,{planeIndex:r,frameOffset:h,frameCount:l,format:"f32-planar"});else{const y=new ArrayBuffer(l*4),b=new Float32Array(y);this._data.copyTo(b,{planeIndex:r,frameOffset:h,frameCount:l,format:"f32-planar"});const k=new DataView(y);for(let x=0;x<l;x++){const E=x*d,T=k.getFloat32(x*4,!0);g(v,E,T)}}else{const y=u,b=new Float32Array(l);for(let k=0;k<y;k++){this._data.copyTo(b,{planeIndex:k,frameOffset:h,frameCount:l,format:"f32-planar"});for(let x=0;x<l;x++){const T=(x*y+k)*d;g(v,T,b[x])}}}else{const y=this._data,b=new DataView(y.buffer,y.byteOffset,y.byteLength),k=this.format,x=nw(k),E=Ts(k),T=$n(k);for(let w=0;w<l;w++)if(f){const S=w*d;let _;T?_=(r*c+(w+h))*E:_=((w+h)*u+r)*E;const A=x(b,_);g(v,S,A)}else for(let S=0;S<u;S++){const A=(w*u+S)*d;let M;T?M=(S*c+(w+h))*E:M=((w+h)*u+S)*E;const D=x(b,M);g(v,A,D)}}}clone(){if(this._closed)throw new Error("AudioSample is closed.");if(Es(this._data)){const e=new ui(this._data.clone());return e.setTimestamp(this.timestamp),e}else return new ui({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.timestamp,data:this._data})}close(){this._closed||(Es(this._data)?this._data.close():this._data=new Uint8Array(0),this._closed=!0)}toAudioData(){if(this._closed)throw new Error("AudioSample is closed.");if(Es(this._data)){if(this._data.timestamp===this.microsecondTimestamp)return this._data.clone();if($n(this.format)){const e=this.allocationSize({planeIndex:0,format:this.format}),t=new ArrayBuffer(e*this.numberOfChannels);for(let r=0;r<this.numberOfChannels;r++)this.copyTo(new Uint8Array(t,r*e,e),{planeIndex:r,format:this.format});return new AudioData({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.microsecondTimestamp,data:t})}else{const e=new ArrayBuffer(this.allocationSize({planeIndex:0,format:this.format}));return this.copyTo(e,{planeIndex:0,format:this.format}),new AudioData({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.microsecondTimestamp,data:e})}}else return new AudioData({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.microsecondTimestamp,data:this._data})}toAudioBuffer(){if(this._closed)throw new Error("AudioSample is closed.");const e=new AudioBuffer({numberOfChannels:this.numberOfChannels,length:this.numberOfFrames,sampleRate:this.sampleRate}),t=new Float32Array(this.allocationSize({planeIndex:0,format:"f32-planar"})/4);for(let r=0;r<this.numberOfChannels;r++)this.copyTo(t,{planeIndex:r,format:"f32-planar"}),e.copyToChannel(t,r);return e}setTimestamp(e){if(!Number.isFinite(e))throw new TypeError("newTimestamp must be a number.");this.timestamp=e}[Symbol.dispose](){this.close()}static*_fromAudioBuffer(e,t){if(!(e instanceof AudioBuffer))throw new TypeError("audioBuffer must be an AudioBuffer.");const r=48e3*5,i=e.numberOfChannels,n=e.sampleRate,a=e.length,o=Math.floor(r/i);let c=0,u=a;for(;u>0;){const h=Math.min(o,u),l=new Float32Array(i*h);for(let d=0;d<i;d++)e.copyFromChannel(l.subarray(d*h,(d+1)*h),d,c);yield new ui({format:"f32-planar",sampleRate:n,numberOfFrames:h,numberOfChannels:i,timestamp:t+c/n,data:l}),c+=h,u-=h}}static fromAudioBuffer(e,t){if(!(e instanceof AudioBuffer))throw new TypeError("audioBuffer must be an AudioBuffer.");const r=48e3*5,i=e.numberOfChannels,n=e.sampleRate,a=e.length,o=Math.floor(r/i);let c=0,u=a;const h=[];for(;u>0;){const l=Math.min(o,u),d=new Float32Array(i*l);for(let p=0;p<i;p++)e.copyFromChannel(d.subarray(p*l,(p+1)*l),p,c);const f=new ui({format:"f32-planar",sampleRate:n,numberOfFrames:l,numberOfChannels:i,timestamp:t+c/n,data:d});h.push(f),c+=l,u-=l}return h}}const Ts=s=>{switch(s){case"u8":case"u8-planar":return 1;case"s16":case"s16-planar":return 2;case"s32":case"s32-planar":return 4;case"f32":case"f32-planar":return 4;default:throw new Error("Unknown AudioSampleFormat")}},$n=s=>{switch(s){case"u8-planar":case"s16-planar":case"s32-planar":case"f32-planar":return!0;default:return!1}},nw=s=>{switch(s){case"u8":case"u8-planar":return(e,t)=>(e.getUint8(t)-128)/128;case"s16":case"s16-planar":return(e,t)=>e.getInt16(t,!0)/32768;case"s32":case"s32-planar":return(e,t)=>e.getInt32(t,!0)/2147483648;case"f32":case"f32-planar":return(e,t)=>e.getFloat32(t,!0)}},aw=s=>{switch(s){case"u8":case"u8-planar":return(e,t,r)=>e.setUint8(t,St((r+1)*127.5,0,255));case"s16":case"s16-planar":return(e,t,r)=>e.setInt16(t,St(Math.round(r*32767),-32768,32767),!0);case"s32":case"s32-planar":return(e,t,r)=>e.setInt32(t,St(Math.round(r*2147483647),-2147483648,2147483647),!0);case"f32":case"f32-planar":return(e,t,r)=>e.setFloat32(t,r,!0)}},Es=s=>typeof AudioData<"u"&&s instanceof AudioData;/*!
242
244
  * Copyright (c) 2025-present, Vanilagy and contributors
243
245
  *
244
246
  * This Source Code Form is subject to the terms of the Mozilla Public
245
247
  * License, v. 2.0. If a copy of the MPL was not distributed with this
246
248
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
247
- */const Wl=s=>{let t=(s.hasVideo?"video/":s.hasAudio?"audio/":"application/")+(s.isQuickTime?"quicktime":"mp4");if(s.codecStrings.length>0){const i=[...new Set(s.codecStrings)];t+=`; codecs="${i.join(", ")}"`}return t};/*!
249
+ */const ow=s=>{let t=(s.hasVideo?"video/":s.hasAudio?"audio/":"application/")+(s.isQuickTime?"quicktime":"mp4");if(s.codecStrings.length>0){const r=[...new Set(s.codecStrings)];t+=`; codecs="${r.join(", ")}"`}return t};/*!
248
250
  * Copyright (c) 2025-present, Vanilagy and contributors
249
251
  *
250
252
  * This Source Code Form is subject to the terms of the Mozilla Public
251
253
  * License, v. 2.0. If a copy of the MPL was not distributed with this
252
254
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
253
- */const fs=8,qr=16,Gl=Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"}));/*!
255
+ */const Io=8,k0=16,Nn=Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"}));/*!
254
256
  * Copyright (c) 2025-present, Vanilagy and contributors
255
257
  *
256
258
  * This Source Code Form is subject to the terms of the Mozilla Public
257
259
  * License, v. 2.0. If a copy of the MPL was not distributed with this
258
260
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
259
- */const Xr=/<(?:(\d{2}):)?(\d{2}):(\d{2}).(\d{3})>/g,Zl=s=>{const e=Math.floor(s/36e5),t=Math.floor(s%(60*60*1e3)/(60*1e3)),i=Math.floor(s%(60*1e3)/1e3),r=s%1e3;return e.toString().padStart(2,"0")+":"+t.toString().padStart(2,"0")+":"+i.toString().padStart(2,"0")+"."+r.toString().padStart(3,"0")};/*!
261
+ */const S0=/<(?:(\d{2}):)?(\d{2}):(\d{2}).(\d{3})>/g,lw=s=>{const e=Math.floor(s/36e5),t=Math.floor(s%(60*60*1e3)/(60*1e3)),r=Math.floor(s%(60*1e3)/1e3),i=s%1e3;return e.toString().padStart(2,"0")+":"+t.toString().padStart(2,"0")+":"+r.toString().padStart(2,"0")+"."+i.toString().padStart(3,"0")};/*!
260
262
  * Copyright (c) 2025-present, Vanilagy and contributors
261
263
  *
262
264
  * This Source Code Form is subject to the terms of the Mozilla Public
263
265
  * License, v. 2.0. If a copy of the MPL was not distributed with this
264
266
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
265
- */class Yr{constructor(e){this.writer=e,this.helper=new Uint8Array(8),this.helperView=new DataView(this.helper.buffer),this.offsets=new WeakMap}writeU32(e){this.helperView.setUint32(0,e,!1),this.writer.write(this.helper.subarray(0,4))}writeU64(e){this.helperView.setUint32(0,Math.floor(e/2**32),!1),this.helperView.setUint32(4,e,!1),this.writer.write(this.helper.subarray(0,8))}writeAscii(e){for(let t=0;t<e.length;t++)this.helperView.setUint8(t%8,e.charCodeAt(t)),t%8===7&&this.writer.write(this.helper);e.length%8!==0&&this.writer.write(this.helper.subarray(0,e.length%8))}writeBox(e){if(this.offsets.set(e,this.writer.getPos()),e.contents&&!e.children)this.writeBoxHeader(e,e.size??e.contents.byteLength+8),this.writer.write(e.contents);else{const t=this.writer.getPos();if(this.writeBoxHeader(e,0),e.contents&&this.writer.write(e.contents),e.children)for(const n of e.children)n&&this.writeBox(n);const i=this.writer.getPos(),r=e.size??i-t;this.writer.seek(t),this.writeBoxHeader(e,r),this.writer.seek(i)}}writeBoxHeader(e,t){this.writeU32(e.largeSize?1:t),this.writeAscii(e.type),e.largeSize&&this.writeU64(t)}measureBoxHeader(e){return 8+(e.largeSize?8:0)}patchBox(e){const t=this.offsets.get(e);$(t!==void 0);const i=this.writer.getPos();this.writer.seek(t),this.writeBox(e),this.writer.seek(i)}measureBox(e){if(e.contents&&!e.children)return this.measureBoxHeader(e)+e.contents.byteLength;{let t=this.measureBoxHeader(e);if(e.contents&&(t+=e.contents.byteLength),e.children)for(const i of e.children)i&&(t+=this.measureBox(i));return t}}}const ne=new Uint8Array(8),je=new DataView(ne.buffer),me=s=>[(s%256+256)%256],G=s=>(je.setUint16(0,s,!1),[ne[0],ne[1]]),Qr=s=>(je.setInt16(0,s,!1),[ne[0],ne[1]]),Jr=s=>(je.setUint32(0,s,!1),[ne[1],ne[2],ne[3]]),B=s=>(je.setUint32(0,s,!1),[ne[0],ne[1],ne[2],ne[3]]),ht=s=>(je.setInt32(0,s,!1),[ne[0],ne[1],ne[2],ne[3]]),_t=s=>(je.setUint32(0,Math.floor(s/2**32),!1),je.setUint32(4,s,!1),[ne[0],ne[1],ne[2],ne[3],ne[4],ne[5],ne[6],ne[7]]),en=s=>(je.setInt16(0,2**8*s,!1),[ne[0],ne[1]]),Xe=s=>(je.setInt32(0,2**16*s,!1),[ne[0],ne[1],ne[2],ne[3]]),ps=s=>(je.setInt32(0,2**30*s,!1),[ne[0],ne[1],ne[2],ne[3]]),ms=(s,e)=>{const t=[];let i=s;do{let r=i&127;i>>=7,t.length>0&&(r|=128),t.push(r)}while(i>0||e);return t.reverse()},Te=(s,e=!1)=>{const t=Array(s.length).fill(null).map((i,r)=>s.charCodeAt(r));return e&&t.push(0),t},gs=s=>{let e=null;for(const t of s)(!e||t.timestamp>e.timestamp)&&(e=t);return e},tn=s=>{const e=s*(Math.PI/180),t=Math.round(Math.cos(e)),i=Math.round(Math.sin(e));return[t,i,0,-i,t,0,0,0,1]},sn=tn(0),rn=s=>[Xe(s[0]),Xe(s[1]),ps(s[2]),Xe(s[3]),Xe(s[4]),ps(s[5]),Xe(s[6]),Xe(s[7]),ps(s[8])],K=(s,e,t)=>({type:s,contents:e&&new Uint8Array(e.flat(10)),children:t}),le=(s,e,t,i,r)=>K(s,[me(e),Jr(t),i??[]],r),Kl=s=>s.isQuickTime?K("ftyp",[Te("qt "),B(512),Te("qt ")]):s.fragmented?K("ftyp",[Te("iso5"),B(512),Te("iso5"),Te("iso6"),Te("mp41")]):K("ftyp",[Te("isom"),B(512),Te("isom"),s.holdsAvc?Te("avc1"):[],Te("mp41")]),Ti=s=>({type:"mdat",largeSize:s}),ql=s=>({type:"free",size:s}),si=s=>K("moov",void 0,[Xl(s.creationTime,s.trackDatas),...s.trackDatas.map(e=>Yl(e,s.creationTime)),s.isFragmented?Ic(s.trackDatas):null,Uc(s)]),Xl=(s,e)=>{const t=xe(Math.max(0,...e.filter(o=>o.samples.length>0).map(o=>{const a=gs(o.samples);return a.timestamp+a.duration})),_s),i=Math.max(0,...e.map(o=>o.track.id))+1,r=!Ft(s)||!Ft(t),n=r?_t:B;return le("mvhd",+r,0,[n(s),n(s),B(_s),n(t),Xe(1),en(1),Array(10).fill(0),rn(sn),Array(24).fill(0),B(i)])},Yl=(s,e)=>{const t=Jc(s);return K("trak",void 0,[Ql(s,e),Jl(s,e),t.name!==void 0?K("udta",void 0,[K("name",[...He.encode(t.name)])]):null])},Ql=(s,e)=>{const t=gs(s.samples),i=xe(t?t.timestamp+t.duration:0,_s),r=!Ft(e)||!Ft(i),n=r?_t:B;let o;if(s.type==="video"){const a=s.track.metadata.rotation;o=tn(a??0)}else o=sn;return le("tkhd",+r,3,[n(e),n(e),B(s.track.id),B(0),n(i),Array(8).fill(0),G(0),G(s.track.id),en(s.type==="audio"?1:0),G(0),rn(o),Xe(s.type==="video"?s.info.width:0),Xe(s.type==="video"?s.info.height:0)])},Jl=(s,e)=>K("mdia",void 0,[ec(s,e),ys(!0,tc[s.type],ic[s.type]),sc(s)]),ec=(s,e)=>{const t=gs(s.samples),i=xe(t?t.timestamp+t.duration:0,s.timescale),r=!Ft(e)||!Ft(i),n=r?_t:B;return le("mdhd",+r,0,[n(e),n(e),B(s.timescale),n(i),G(un(s.track.metadata.languageCode??sl)),G(0)])},tc={video:"vide",audio:"soun",subtitle:"text"},ic={video:"MediabunnyVideoHandler",audio:"MediabunnySoundHandler",subtitle:"MediabunnyTextHandler"},ys=(s,e,t,i="\0\0\0\0")=>le("hdlr",0,0,[s?Te("mhlr"):B(0),Te(e),Te(i),B(0),B(0),Te(t,!0)]),sc=s=>K("minf",void 0,[rc[s.type](),nc(),lc(s)]),rc={video:()=>le("vmhd",0,1,[G(0),G(0),G(0),G(0)]),audio:()=>le("smhd",0,0,[G(0),G(0)]),subtitle:()=>le("nmhd",0,0)},nc=()=>K("dinf",void 0,[ac()]),ac=()=>le("dref",0,0,[B(1)],[oc()]),oc=()=>le("url ",0,1),lc=s=>{const e=s.compositionTimeOffsetTable.length>1||s.compositionTimeOffsetTable.some(t=>t.sampleCompositionTimeOffset!==0);return K("stbl",void 0,[cc(s),xc(s),e?Ec(s):null,e?Ac(s):null,kc(s),Tc(s),Sc(s),Cc(s)])},cc=s=>{let e;if(s.type==="video")e=hc(Gc[s.track.source._codec],s);else if(s.type==="audio"){const t=hn(s.track.source._codec,s.muxer.isQuickTime);$(t),e=mc(t,s)}else s.type==="subtitle"&&(e=wc(qc[s.track.source._codec],s));return $(e),le("stsd",0,0,[B(1)],[e])},hc=(s,e)=>K(s,[Array(6).fill(0),G(1),G(0),G(0),Array(12).fill(0),G(e.info.width),G(e.info.height),B(4718592),B(4718592),B(0),G(1),Array(32).fill(0),G(24),Qr(65535)],[Zc[e.track.source._codec](e),el(e.info.decoderConfig.colorSpace)?uc(e):null]),uc=s=>K("colr",[Te("nclx"),G(vi[s.info.decoderConfig.colorSpace.primaries]),G(wi[s.info.decoderConfig.colorSpace.transfer]),G(_i[s.info.decoderConfig.colorSpace.matrix]),me((s.info.decoderConfig.colorSpace.fullRange?1:0)<<7)]),dc=s=>s.info.decoderConfig&&K("avcC",[...ot(s.info.decoderConfig.description)]),fc=s=>s.info.decoderConfig&&K("hvcC",[...ot(s.info.decoderConfig.description)]),nn=s=>{if(!s.info.decoderConfig)return null;const e=s.info.decoderConfig,t=e.codec.split("."),i=Number(t[1]),r=Number(t[2]),n=Number(t[3]),o=t[4]?Number(t[4]):1,a=t[8]?Number(t[8]):Number(e.colorSpace?.fullRange??0),p=(n<<4)+(o<<1)+a,m=t[5]?Number(t[5]):e.colorSpace?.primaries?vi[e.colorSpace.primaries]:2,d=t[6]?Number(t[6]):e.colorSpace?.transfer?wi[e.colorSpace.transfer]:2,l=t[7]?Number(t[7]):e.colorSpace?.matrix?_i[e.colorSpace.matrix]:2;return le("vpcC",1,0,[me(i),me(r),me(p),me(m),me(d),me(l),G(0)])},pc=s=>K("av1C",ul(s.info.decoderConfig.codec)),mc=(s,e)=>{let t=0,i,r=16;if(Ne.includes(e.track.source._codec)){const n=e.track.source._codec,{sampleSize:o}=Lt(n);r=8*o,r>16&&(t=1)}return t===0?i=[Array(6).fill(0),G(1),G(t),G(0),B(0),G(e.info.numberOfChannels),G(r),G(0),G(0),G(e.info.sampleRate<2**16?e.info.sampleRate:0),G(0)]:i=[Array(6).fill(0),G(1),G(t),G(0),B(0),G(e.info.numberOfChannels),G(Math.min(r,16)),G(0),G(0),G(e.info.sampleRate<2**16?e.info.sampleRate:0),G(0),B(1),B(r/8),B(e.info.numberOfChannels*r/8),B(2)],K(s,i,[Kc(e.track.source._codec,e.muxer.isQuickTime)?.(e)??null])},bs=s=>{let e;switch(s.track.source._codec){case"aac":e=64;break;case"mp3":e=107;break;case"vorbis":e=221;break;default:throw new Error(`Unhandled audio codec: ${s.track.source._codec}`)}let t=[...me(e),...me(21),...Jr(0),...B(0),...B(0)];if(s.info.decoderConfig.description){const i=ot(s.info.decoderConfig.description);t=[...t,...me(5),...ms(i.byteLength),...i]}return t=[...G(1),...me(0),...me(4),...ms(t.length),...t,...me(6),...me(1),...me(2)],t=[...me(3),...ms(t.length),...t],le("esds",0,0,t)},ut=s=>K("wave",void 0,[gc(s),yc(s),K("\0\0\0\0")]),gc=s=>K("frma",[Te(hn(s.track.source._codec,s.muxer.isQuickTime))]),yc=s=>{const{littleEndian:e}=Lt(s.track.source._codec);return K("enda",[G(+e)])},bc=s=>{let e=s.info.numberOfChannels,t=3840,i=s.info.sampleRate,r=0,n=0,o=new Uint8Array(0);const a=s.info.decoderConfig?.description;if(a){$(a.byteLength>=18);const p=ot(a),m=Bl(p);e=m.outputChannelCount,t=m.preSkip,i=m.inputSampleRate,r=m.outputGain,n=m.channelMappingFamily,m.channelMappingTable&&(o=m.channelMappingTable)}return K("dOps",[me(0),me(e),G(t),B(i),Qr(r),me(n),...o])},vc=s=>{const e=s.info.decoderConfig?.description;$(e);const t=ot(e);return le("dfLa",0,0,[...t.subarray(4)])},Ve=s=>{const{littleEndian:e,sampleSize:t}=Lt(s.track.source._codec),i=+e;return le("pcmC",0,0,[me(i),me(8*t)])},wc=(s,e)=>K(s,[Array(6).fill(0),G(1)],[Xc[e.track.source._codec](e)]),_c=s=>K("vttC",[...He.encode(s.info.config.description)]),xc=s=>le("stts",0,0,[B(s.timeToSampleTable.length),s.timeToSampleTable.map(e=>[B(e.sampleCount),B(e.sampleDelta)])]),Cc=s=>{if(s.samples.every(t=>t.type==="key"))return null;const e=[...s.samples.entries()].filter(([,t])=>t.type==="key");return le("stss",0,0,[B(e.length),e.map(([t])=>B(t+1))])},kc=s=>le("stsc",0,0,[B(s.compactlyCodedChunkTable.length),s.compactlyCodedChunkTable.map(e=>[B(e.firstChunk),B(e.samplesPerChunk),B(1)])]),Tc=s=>{if(s.type==="audio"&&s.info.requiresPcmTransformation){const{sampleSize:e}=Lt(s.track.source._codec);return le("stsz",0,0,[B(e*s.info.numberOfChannels),B(s.samples.reduce((t,i)=>t+xe(i.duration,s.timescale),0))])}return le("stsz",0,0,[B(0),B(s.samples.length),s.samples.map(e=>B(e.size))])},Sc=s=>s.finalizedChunks.length>0&&ze(s.finalizedChunks).offset>=2**32?le("co64",0,0,[B(s.finalizedChunks.length),s.finalizedChunks.map(e=>_t(e.offset))]):le("stco",0,0,[B(s.finalizedChunks.length),s.finalizedChunks.map(e=>B(e.offset))]),Ec=s=>le("ctts",1,0,[B(s.compositionTimeOffsetTable.length),s.compositionTimeOffsetTable.map(e=>[B(e.sampleCount),ht(e.sampleCompositionTimeOffset)])]),Ac=s=>{let e=1/0,t=-1/0,i=1/0,r=-1/0;$(s.compositionTimeOffsetTable.length>0),$(s.samples.length>0);for(let o=0;o<s.compositionTimeOffsetTable.length;o++){const a=s.compositionTimeOffsetTable[o];e=Math.min(e,a.sampleCompositionTimeOffset),t=Math.max(t,a.sampleCompositionTimeOffset)}for(let o=0;o<s.samples.length;o++){const a=s.samples[o];i=Math.min(i,xe(a.timestamp,s.timescale)),r=Math.max(r,xe(a.timestamp+a.duration,s.timescale))}const n=Math.max(-e,0);return r>=2**31?null:le("cslg",0,0,[ht(n),ht(e),ht(t),ht(i),ht(r)])},Ic=s=>K("mvex",void 0,s.map(Pc)),Pc=s=>le("trex",0,0,[B(s.track.id),B(1),B(0),B(0),B(0)]),an=(s,e)=>K("moof",void 0,[Rc(s),...e.map(Oc)]),Rc=s=>le("mfhd",0,0,[B(s)]),on=s=>{let e=0,t=0;const i=0,r=0,n=s.type==="delta";return t|=+n,n?e|=1:e|=2,e<<24|t<<16|i<<8|r},Oc=s=>K("traf",void 0,[Fc(s),Mc(s),Lc(s)]),Fc=s=>{$(s.currentChunk);let e=0;e|=8,e|=16,e|=32,e|=131072;const t=s.currentChunk.samples[1]??s.currentChunk.samples[0],i={duration:t.timescaleUnitsToNextSample,size:t.size,flags:on(t)};return le("tfhd",0,e,[B(s.track.id),B(i.duration),B(i.size),B(i.flags)])},Mc=s=>($(s.currentChunk),le("tfdt",1,0,[_t(xe(s.currentChunk.startTimestamp,s.timescale))])),Lc=s=>{$(s.currentChunk);const e=s.currentChunk.samples.map(f=>f.timescaleUnitsToNextSample),t=s.currentChunk.samples.map(f=>f.size),i=s.currentChunk.samples.map(on),r=s.currentChunk.samples.map(f=>xe(f.timestamp-f.decodeTimestamp,s.timescale)),n=new Set(e),o=new Set(t),a=new Set(i),p=new Set(r),m=a.size===2&&i[0]!==i[1],d=n.size>1,l=o.size>1,c=!m&&a.size>1,u=p.size>1||[...p].some(f=>f!==0);let h=0;return h|=1,h|=4*+m,h|=256*+d,h|=512*+l,h|=1024*+c,h|=2048*+u,le("trun",1,h,[B(s.currentChunk.samples.length),B(s.currentChunk.offset-s.currentChunk.moofOffset||0),m?B(i[0]):[],s.currentChunk.samples.map((f,b)=>[d?B(e[b]):[],l?B(t[b]):[],c?B(i[b]):[],u?ht(r[b]):[]])])},Bc=s=>K("mfra",void 0,[...s.map($c),Dc()]),$c=(s,e)=>le("tfra",1,0,[B(s.track.id),B(63),B(s.finalizedChunks.length),s.finalizedChunks.map(i=>[_t(xe(i.samples[0].timestamp,s.timescale)),_t(i.moofOffset),B(e+1),B(1),B(1)])]),Dc=()=>le("mfro",0,0,[B(0)]),zc=()=>K("vtte"),Hc=(s,e,t,i,r)=>K("vttc",void 0,[r!==null?K("vsid",[ht(r)]):null,t!==null?K("iden",[...He.encode(t)]):null,e!==null?K("ctim",[...He.encode(Zl(e))]):null,i!==null?K("sttg",[...He.encode(i)]):null,K("payl",[...He.encode(s)])]),Nc=s=>K("vtta",[...He.encode(s)]),Uc=s=>{const e=[],t=s.format._options.metadataFormat??"auto",i=s.output._metadataTags;if(t==="mdir"||t==="auto"&&!s.isQuickTime){const r=Vc(i);r&&e.push(r)}else if(t==="mdta"){const r=Wc(i);r&&e.push(r)}else(t==="udta"||t==="auto"&&s.isQuickTime)&&jc(e,s.output._metadataTags);return e.length===0?null:K("udta",void 0,e)},jc=(s,e)=>{for(const{key:t,value:i}of $r(e))switch(t){case"title":s.push(We("©nam",i));break;case"description":s.push(We("©des",i));break;case"artist":s.push(We("©ART",i));break;case"album":s.push(We("©alb",i));break;case"albumArtist":s.push(We("albr",i));break;case"genre":s.push(We("©gen",i));break;case"date":s.push(We("©day",i.toISOString().slice(0,10)));break;case"comment":s.push(We("©cmt",i));break;case"lyrics":s.push(We("©lyr",i));break;case"raw":break;case"discNumber":case"discsTotal":case"trackNumber":case"tracksTotal":case"images":break;default:as(t)}if(e.raw)for(const t in e.raw){const i=e.raw[t];i==null||t.length!==4||s.some(r=>r.type===t)||(typeof i=="string"?s.push(We(t,i)):i instanceof Uint8Array&&s.push(K(t,Array.from(i))))}},We=(s,e)=>{const t=He.encode(e);return K(s,[G(t.length),G(un("und")),Array.from(t)])},ln={"image/jpeg":13,"image/png":14,"image/bmp":27},cn=(s,e)=>{const t=[];for(const{key:i,value:r}of $r(s))switch(i){case"title":t.push({key:e?"title":"©nam",value:Me(r)});break;case"description":t.push({key:e?"description":"©des",value:Me(r)});break;case"artist":t.push({key:e?"artist":"©ART",value:Me(r)});break;case"album":t.push({key:e?"album":"©alb",value:Me(r)});break;case"albumArtist":t.push({key:e?"album_artist":"aART",value:Me(r)});break;case"comment":t.push({key:e?"comment":"©cmt",value:Me(r)});break;case"genre":t.push({key:e?"genre":"©gen",value:Me(r)});break;case"lyrics":t.push({key:e?"lyrics":"©lyr",value:Me(r)});break;case"date":t.push({key:e?"date":"©day",value:Me(r.toISOString().slice(0,10))});break;case"images":for(const n of r)n.kind==="coverFront"&&t.push({key:"covr",value:K("data",[B(ln[n.mimeType]??0),B(0),Array.from(n.data)])});break;case"trackNumber":if(e){const n=s.tracksTotal!==void 0?`${r}/${s.tracksTotal}`:r.toString();t.push({key:"track",value:Me(n)})}else t.push({key:"trkn",value:K("data",[B(0),B(0),G(0),G(r),G(s.tracksTotal??0),G(0)])});break;case"discNumber":e||t.push({key:"disc",value:K("data",[B(0),B(0),G(0),G(r),G(s.discsTotal??0),G(0)])});break;case"tracksTotal":case"discsTotal":break;case"raw":break;default:as(i)}if(s.raw)for(const i in s.raw){const r=s.raw[i];r==null||!e&&i.length!==4||t.some(n=>n.key===i)||(typeof r=="string"?t.push({key:i,value:Me(r)}):r instanceof Uint8Array?t.push({key:i,value:K("data",[B(0),B(0),Array.from(r)])}):r instanceof Dr&&t.push({key:i,value:K("data",[B(ln[r.mimeType]??0),B(0),Array.from(r.data)])}))}return t},Vc=s=>{const e=cn(s,!1);return e.length===0?null:le("meta",0,0,void 0,[ys(!1,"mdir","","appl"),K("ilst",void 0,e.map(t=>K(t.key,void 0,[t.value])))])},Wc=s=>{const e=cn(s,!0);return e.length===0?null:K("meta",void 0,[ys(!1,"mdta",""),le("keys",0,0,[B(e.length)],e.map(t=>K("mdta",[...He.encode(t.key)]))),K("ilst",void 0,e.map((t,i)=>{const r=String.fromCharCode(...B(i+1));return K(r,void 0,[t.value])}))])},Me=s=>K("data",[B(1),B(0),...He.encode(s)]),Gc={avc:"avc1",hevc:"hvc1",vp8:"vp08",vp9:"vp09",av1:"av01"},Zc={avc:dc,hevc:fc,vp8:nn,vp9:nn,av1:pc},hn=(s,e)=>{switch(s){case"aac":return"mp4a";case"mp3":return"mp4a";case"opus":return"Opus";case"vorbis":return"mp4a";case"flac":return"fLaC";case"ulaw":return"ulaw";case"alaw":return"alaw";case"pcm-u8":return"raw ";case"pcm-s8":return"sowt"}if(e)switch(s){case"pcm-s16":return"sowt";case"pcm-s16be":return"twos";case"pcm-s24":return"in24";case"pcm-s24be":return"in24";case"pcm-s32":return"in32";case"pcm-s32be":return"in32";case"pcm-f32":return"fl32";case"pcm-f32be":return"fl32";case"pcm-f64":return"fl64";case"pcm-f64be":return"fl64"}else switch(s){case"pcm-s16":return"ipcm";case"pcm-s16be":return"ipcm";case"pcm-s24":return"ipcm";case"pcm-s24be":return"ipcm";case"pcm-s32":return"ipcm";case"pcm-s32be":return"ipcm";case"pcm-f32":return"fpcm";case"pcm-f32be":return"fpcm";case"pcm-f64":return"fpcm";case"pcm-f64be":return"fpcm"}},Kc=(s,e)=>{switch(s){case"aac":return bs;case"mp3":return bs;case"opus":return bc;case"vorbis":return bs;case"flac":return vc}if(e)switch(s){case"pcm-s24":return ut;case"pcm-s24be":return ut;case"pcm-s32":return ut;case"pcm-s32be":return ut;case"pcm-f32":return ut;case"pcm-f32be":return ut;case"pcm-f64":return ut;case"pcm-f64be":return ut}else switch(s){case"pcm-s16":return Ve;case"pcm-s16be":return Ve;case"pcm-s24":return Ve;case"pcm-s24be":return Ve;case"pcm-s32":return Ve;case"pcm-s32be":return Ve;case"pcm-f32":return Ve;case"pcm-f32be":return Ve;case"pcm-f64":return Ve;case"pcm-f64be":return Ve}return null},qc={webvtt:"wvtt"},Xc={webvtt:_c},un=s=>{$(s.length===3);let e=0;for(let t=0;t<3;t++)e<<=5,e+=s.charCodeAt(t)-96;return e};/*!
267
+ */class _0{constructor(e){this.writer=e,this.helper=new Uint8Array(8),this.helperView=new DataView(this.helper.buffer),this.offsets=new WeakMap}writeU32(e){this.helperView.setUint32(0,e,!1),this.writer.write(this.helper.subarray(0,4))}writeU64(e){this.helperView.setUint32(0,Math.floor(e/2**32),!1),this.helperView.setUint32(4,e,!1),this.writer.write(this.helper.subarray(0,8))}writeAscii(e){for(let t=0;t<e.length;t++)this.helperView.setUint8(t%8,e.charCodeAt(t)),t%8===7&&this.writer.write(this.helper);e.length%8!==0&&this.writer.write(this.helper.subarray(0,e.length%8))}writeBox(e){if(this.offsets.set(e,this.writer.getPos()),e.contents&&!e.children)this.writeBoxHeader(e,e.size??e.contents.byteLength+8),this.writer.write(e.contents);else{const t=this.writer.getPos();if(this.writeBoxHeader(e,0),e.contents&&this.writer.write(e.contents),e.children)for(const n of e.children)n&&this.writeBox(n);const r=this.writer.getPos(),i=e.size??r-t;this.writer.seek(t),this.writeBoxHeader(e,i),this.writer.seek(r)}}writeBoxHeader(e,t){this.writeU32(e.largeSize?1:t),this.writeAscii(e.type),e.largeSize&&this.writeU64(t)}measureBoxHeader(e){return 8+(e.largeSize?8:0)}patchBox(e){const t=this.offsets.get(e);Y(t!==void 0);const r=this.writer.getPos();this.writer.seek(t),this.writeBox(e),this.writer.seek(r)}measureBox(e){if(e.contents&&!e.children)return this.measureBoxHeader(e)+e.contents.byteLength;{let t=this.measureBoxHeader(e);if(e.contents&&(t+=e.contents.byteLength),e.children)for(const r of e.children)r&&(t+=this.measureBox(r));return t}}}const Be=new Uint8Array(8),or=new DataView(Be.buffer),tt=s=>[(s%256+256)%256],ge=s=>(or.setUint16(0,s,!1),[Be[0],Be[1]]),T0=s=>(or.setInt16(0,s,!1),[Be[0],Be[1]]),E0=s=>(or.setUint32(0,s,!1),[Be[1],Be[2],Be[3]]),X=s=>(or.setUint32(0,s,!1),[Be[0],Be[1],Be[2],Be[3]]),Vr=s=>(or.setInt32(0,s,!1),[Be[0],Be[1],Be[2],Be[3]]),hi=s=>(or.setUint32(0,Math.floor(s/2**32),!1),or.setUint32(4,s,!1),[Be[0],Be[1],Be[2],Be[3],Be[4],Be[5],Be[6],Be[7]]),A0=s=>(or.setInt16(0,2**8*s,!1),[Be[0],Be[1]]),yr=s=>(or.setInt32(0,2**16*s,!1),[Be[0],Be[1],Be[2],Be[3]]),Po=s=>(or.setInt32(0,2**30*s,!1),[Be[0],Be[1],Be[2],Be[3]]),Oo=(s,e)=>{const t=[];let r=s;do{let i=r&127;r>>=7,t.length>0&&(i|=128),t.push(i)}while(r>0||e);return t.reverse()},vt=(s,e=!1)=>{const t=Array(s.length).fill(null).map((r,i)=>s.charCodeAt(i));return e&&t.push(0),t},Fo=s=>{let e=null;for(const t of s)(!e||t.timestamp>e.timestamp)&&(e=t);return e},I0=s=>{const e=s*(Math.PI/180),t=Math.round(Math.cos(e)),r=Math.round(Math.sin(e));return[t,r,0,-r,t,0,0,0,1]},P0=I0(0),O0=s=>[yr(s[0]),yr(s[1]),Po(s[2]),yr(s[3]),yr(s[4]),Po(s[5]),yr(s[6]),yr(s[7]),Po(s[8])],be=(s,e,t)=>({type:s,contents:e&&new Uint8Array(e.flat(10)),children:t}),Ne=(s,e,t,r,i)=>be(s,[tt(e),E0(t),r??[]],i),cw=s=>s.isQuickTime?be("ftyp",[vt("qt "),X(512),vt("qt ")]):s.fragmented?be("ftyp",[vt("iso5"),X(512),vt("iso5"),vt("iso6"),vt("mp41")]):be("ftyp",[vt("isom"),X(512),vt("isom"),s.holdsAvc?vt("avc1"):[],vt("mp41")]),Un=s=>({type:"mdat",largeSize:s}),uw=s=>({type:"free",size:s}),As=s=>be("moov",void 0,[hw(s.creationTime,s.trackDatas),...s.trackDatas.map(e=>dw(e,s.creationTime)),s.isFragmented?jw(s.trackDatas):null,i2(s)]),hw=(s,e)=>{const t=ht(Math.max(0,...e.filter(a=>a.samples.length>0).map(a=>{const o=Fo(a.samples);return o.timestamp+o.duration})),Lo),r=Math.max(0,...e.map(a=>a.track.id))+1,i=!Mi(s)||!Mi(t),n=i?hi:X;return Ne("mvhd",+i,0,[n(s),n(s),X(Lo),n(t),yr(1),A0(1),Array(10).fill(0),O0(P0),Array(24).fill(0),X(r)])},dw=(s,e)=>{const t=p2(s);return be("trak",void 0,[fw(s,e),pw(s,e),t.name!==void 0?be("udta",void 0,[be("name",[...sr.encode(t.name)])]):null])},fw=(s,e)=>{const t=Fo(s.samples),r=ht(t?t.timestamp+t.duration:0,Lo),i=!Mi(e)||!Mi(r),n=i?hi:X;let a;if(s.type==="video"){const o=s.track.metadata.rotation;a=I0(o??0)}else a=P0;return Ne("tkhd",+i,3,[n(e),n(e),X(s.track.id),X(0),n(r),Array(8).fill(0),ge(0),ge(s.track.id),A0(s.type==="audio"?1:0),ge(0),O0(a),yr(s.type==="video"?s.info.width:0),yr(s.type==="video"?s.info.height:0)])},pw=(s,e)=>be("mdia",void 0,[mw(s,e),Ro(!0,gw[s.type],yw[s.type]),bw(s)]),mw=(s,e)=>{const t=Fo(s.samples),r=ht(t?t.timestamp+t.duration:0,s.timescale),i=!Mi(e)||!Mi(r),n=i?hi:X;return Ne("mdhd",+i,0,[n(e),n(e),X(s.timescale),n(r),ge(z0(s.track.metadata.languageCode??vv)),ge(0)])},gw={video:"vide",audio:"soun",subtitle:"text"},yw={video:"MediabunnyVideoHandler",audio:"MediabunnySoundHandler",subtitle:"MediabunnyTextHandler"},Ro=(s,e,t,r="\0\0\0\0")=>Ne("hdlr",0,0,[s?vt("mhlr"):X(0),vt(e),vt(r),X(0),X(0),vt(t,!0)]),bw=s=>be("minf",void 0,[vw[s.type](),ww(),kw(s)]),vw={video:()=>Ne("vmhd",0,1,[ge(0),ge(0),ge(0),ge(0)]),audio:()=>Ne("smhd",0,0,[ge(0),ge(0)]),subtitle:()=>Ne("nmhd",0,0)},ww=()=>be("dinf",void 0,[xw()]),xw=()=>Ne("dref",0,0,[X(1)],[Cw()]),Cw=()=>Ne("url ",0,1),kw=s=>{const e=s.compositionTimeOffsetTable.length>1||s.compositionTimeOffsetTable.some(t=>t.sampleCompositionTimeOffset!==0);return be("stbl",void 0,[Sw(s),Lw(s),e?Hw(s):null,e?Vw(s):null,$w(s),Nw(s),Uw(s),zw(s)])},Sw=s=>{let e;if(s.type==="video")e=_w(o2[s.track.source._codec],s);else if(s.type==="audio"){const t=L0(s.track.source._codec,s.muxer.isQuickTime);Y(t),e=Pw(t,s)}else s.type==="subtitle"&&(e=Dw(u2[s.track.source._codec],s));return Y(e),Ne("stsd",0,0,[X(1)],[e])},_w=(s,e)=>be(s,[Array(6).fill(0),ge(1),ge(0),ge(0),Array(12).fill(0),ge(e.info.width),ge(e.info.height),X(4718592),X(4718592),X(0),ge(1),Array(32).fill(0),ge(24),T0(65535)],[l2[e.track.source._codec](e),gv(e.info.decoderConfig.colorSpace)?Tw(e):null]),Tw=s=>be("colr",[vt("nclx"),ge(Mn[s.info.decoderConfig.colorSpace.primaries]),ge(Dn[s.info.decoderConfig.colorSpace.transfer]),ge(Bn[s.info.decoderConfig.colorSpace.matrix]),tt((s.info.decoderConfig.colorSpace.fullRange?1:0)<<7)]),Ew=s=>s.info.decoderConfig&&be("avcC",[...Nr(s.info.decoderConfig.description)]),Aw=s=>s.info.decoderConfig&&be("hvcC",[...Nr(s.info.decoderConfig.description)]),F0=s=>{if(!s.info.decoderConfig)return null;const e=s.info.decoderConfig,t=e.codec.split("."),r=Number(t[1]),i=Number(t[2]),n=Number(t[3]),a=t[4]?Number(t[4]):1,o=t[8]?Number(t[8]):Number(e.colorSpace?.fullRange??0),c=(n<<4)+(a<<1)+o,u=t[5]?Number(t[5]):e.colorSpace?.primaries?Mn[e.colorSpace.primaries]:2,h=t[6]?Number(t[6]):e.colorSpace?.transfer?Dn[e.colorSpace.transfer]:2,l=t[7]?Number(t[7]):e.colorSpace?.matrix?Bn[e.colorSpace.matrix]:2;return Ne("vpcC",1,0,[tt(r),tt(i),tt(c),tt(u),tt(h),tt(l),ge(0)])},Iw=s=>be("av1C",Ev(s.info.decoderConfig.codec)),Pw=(s,e)=>{let t=0,r,i=16;if(nr.includes(e.track.source._codec)){const n=e.track.source._codec,{sampleSize:a}=Bi(n);i=8*a,i>16&&(t=1)}return t===0?r=[Array(6).fill(0),ge(1),ge(t),ge(0),X(0),ge(e.info.numberOfChannels),ge(i),ge(0),ge(0),ge(e.info.sampleRate<2**16?e.info.sampleRate:0),ge(0)]:r=[Array(6).fill(0),ge(1),ge(t),ge(0),X(0),ge(e.info.numberOfChannels),ge(Math.min(i,16)),ge(0),ge(0),ge(e.info.sampleRate<2**16?e.info.sampleRate:0),ge(0),X(1),X(i/8),X(e.info.numberOfChannels*i/8),X(2)],be(s,r,[c2(e.track.source._codec,e.muxer.isQuickTime)?.(e)??null])},Mo=s=>{let e;switch(s.track.source._codec){case"aac":e=64;break;case"mp3":e=107;break;case"vorbis":e=221;break;default:throw new Error(`Unhandled audio codec: ${s.track.source._codec}`)}let t=[...tt(e),...tt(21),...E0(0),...X(0),...X(0)];if(s.info.decoderConfig.description){const r=Nr(s.info.decoderConfig.description);t=[...t,...tt(5),...Oo(r.byteLength),...r]}return t=[...ge(1),...tt(0),...tt(4),...Oo(t.length),...t,...tt(6),...tt(1),...tt(2)],t=[...tt(3),...Oo(t.length),...t],Ne("esds",0,0,t)},jr=s=>be("wave",void 0,[Ow(s),Fw(s),be("\0\0\0\0")]),Ow=s=>be("frma",[vt(L0(s.track.source._codec,s.muxer.isQuickTime))]),Fw=s=>{const{littleEndian:e}=Bi(s.track.source._codec);return be("enda",[ge(+e)])},Rw=s=>{let e=s.info.numberOfChannels,t=3840,r=s.info.sampleRate,i=0,n=0,a=new Uint8Array(0);const o=s.info.decoderConfig?.description;if(o){Y(o.byteLength>=18);const c=Nr(o),u=Jv(c);e=u.outputChannelCount,t=u.preSkip,r=u.inputSampleRate,i=u.outputGain,n=u.channelMappingFamily,u.channelMappingTable&&(a=u.channelMappingTable)}return be("dOps",[tt(0),tt(e),ge(t),X(r),T0(i),tt(n),...a])},Mw=s=>{const e=s.info.decoderConfig?.description;Y(e);const t=Nr(e);return Ne("dfLa",0,0,[...t.subarray(4)])},lr=s=>{const{littleEndian:e,sampleSize:t}=Bi(s.track.source._codec),r=+e;return Ne("pcmC",0,0,[tt(r),tt(8*t)])},Dw=(s,e)=>be(s,[Array(6).fill(0),ge(1)],[h2[e.track.source._codec](e)]),Bw=s=>be("vttC",[...sr.encode(s.info.config.description)]),Lw=s=>Ne("stts",0,0,[X(s.timeToSampleTable.length),s.timeToSampleTable.map(e=>[X(e.sampleCount),X(e.sampleDelta)])]),zw=s=>{if(s.samples.every(t=>t.type==="key"))return null;const e=[...s.samples.entries()].filter(([,t])=>t.type==="key");return Ne("stss",0,0,[X(e.length),e.map(([t])=>X(t+1))])},$w=s=>Ne("stsc",0,0,[X(s.compactlyCodedChunkTable.length),s.compactlyCodedChunkTable.map(e=>[X(e.firstChunk),X(e.samplesPerChunk),X(1)])]),Nw=s=>{if(s.type==="audio"&&s.info.requiresPcmTransformation){const{sampleSize:e}=Bi(s.track.source._codec);return Ne("stsz",0,0,[X(e*s.info.numberOfChannels),X(s.samples.reduce((t,r)=>t+ht(r.duration,s.timescale),0))])}return Ne("stsz",0,0,[X(0),X(s.samples.length),s.samples.map(e=>X(e.size))])},Uw=s=>s.finalizedChunks.length>0&&ir(s.finalizedChunks).offset>=2**32?Ne("co64",0,0,[X(s.finalizedChunks.length),s.finalizedChunks.map(e=>hi(e.offset))]):Ne("stco",0,0,[X(s.finalizedChunks.length),s.finalizedChunks.map(e=>X(e.offset))]),Hw=s=>Ne("ctts",1,0,[X(s.compositionTimeOffsetTable.length),s.compositionTimeOffsetTable.map(e=>[X(e.sampleCount),Vr(e.sampleCompositionTimeOffset)])]),Vw=s=>{let e=1/0,t=-1/0,r=1/0,i=-1/0;Y(s.compositionTimeOffsetTable.length>0),Y(s.samples.length>0);for(let a=0;a<s.compositionTimeOffsetTable.length;a++){const o=s.compositionTimeOffsetTable[a];e=Math.min(e,o.sampleCompositionTimeOffset),t=Math.max(t,o.sampleCompositionTimeOffset)}for(let a=0;a<s.samples.length;a++){const o=s.samples[a];r=Math.min(r,ht(o.timestamp,s.timescale)),i=Math.max(i,ht(o.timestamp+o.duration,s.timescale))}const n=Math.max(-e,0);return i>=2**31?null:Ne("cslg",0,0,[Vr(n),Vr(e),Vr(t),Vr(r),Vr(i)])},jw=s=>be("mvex",void 0,s.map(Ww)),Ww=s=>Ne("trex",0,0,[X(s.track.id),X(1),X(0),X(0),X(0)]),R0=(s,e)=>be("moof",void 0,[Gw(s),...e.map(qw)]),Gw=s=>Ne("mfhd",0,0,[X(s)]),M0=s=>{let e=0,t=0;const r=0,i=0,n=s.type==="delta";return t|=+n,n?e|=1:e|=2,e<<24|t<<16|r<<8|i},qw=s=>be("traf",void 0,[Xw(s),Zw(s),Kw(s)]),Xw=s=>{Y(s.currentChunk);let e=0;e|=8,e|=16,e|=32,e|=131072;const t=s.currentChunk.samples[1]??s.currentChunk.samples[0],r={duration:t.timescaleUnitsToNextSample,size:t.size,flags:M0(t)};return Ne("tfhd",0,e,[X(s.track.id),X(r.duration),X(r.size),X(r.flags)])},Zw=s=>(Y(s.currentChunk),Ne("tfdt",1,0,[hi(ht(s.currentChunk.startTimestamp,s.timescale))])),Kw=s=>{Y(s.currentChunk);const e=s.currentChunk.samples.map(m=>m.timescaleUnitsToNextSample),t=s.currentChunk.samples.map(m=>m.size),r=s.currentChunk.samples.map(M0),i=s.currentChunk.samples.map(m=>ht(m.timestamp-m.decodeTimestamp,s.timescale)),n=new Set(e),a=new Set(t),o=new Set(r),c=new Set(i),u=o.size===2&&r[0]!==r[1],h=n.size>1,l=a.size>1,d=!u&&o.size>1,f=c.size>1||[...c].some(m=>m!==0);let p=0;return p|=1,p|=4*+u,p|=256*+h,p|=512*+l,p|=1024*+d,p|=2048*+f,Ne("trun",1,p,[X(s.currentChunk.samples.length),X(s.currentChunk.offset-s.currentChunk.moofOffset||0),u?X(r[0]):[],s.currentChunk.samples.map((m,v)=>[h?X(e[v]):[],l?X(t[v]):[],d?X(r[v]):[],f?Vr(i[v]):[]])])},Yw=s=>be("mfra",void 0,[...s.map(Jw),Qw()]),Jw=(s,e)=>Ne("tfra",1,0,[X(s.track.id),X(63),X(s.finalizedChunks.length),s.finalizedChunks.map(r=>[hi(ht(r.samples[0].timestamp,s.timescale)),hi(r.moofOffset),X(e+1),X(1),X(1)])]),Qw=()=>Ne("mfro",0,0,[X(0)]),e2=()=>be("vtte"),t2=(s,e,t,r,i)=>be("vttc",void 0,[i!==null?be("vsid",[Vr(i)]):null,t!==null?be("iden",[...sr.encode(t)]):null,e!==null?be("ctim",[...sr.encode(lw(e))]):null,r!==null?be("sttg",[...sr.encode(r)]):null,be("payl",[...sr.encode(s)])]),r2=s=>be("vtta",[...sr.encode(s)]),i2=s=>{const e=[],t=s.format._options.metadataFormat??"auto",r=s.output._metadataTags;if(t==="mdir"||t==="auto"&&!s.isQuickTime){const i=n2(r);i&&e.push(i)}else if(t==="mdta"){const i=a2(r);i&&e.push(i)}else(t==="udta"||t==="auto"&&s.isQuickTime)&&s2(e,s.output._metadataTags);return e.length===0?null:be("udta",void 0,e)},s2=(s,e)=>{for(const{key:t,value:r}of h0(e))switch(t){case"title":s.push(cr("©nam",r));break;case"description":s.push(cr("©des",r));break;case"artist":s.push(cr("©ART",r));break;case"album":s.push(cr("©alb",r));break;case"albumArtist":s.push(cr("albr",r));break;case"genre":s.push(cr("©gen",r));break;case"date":s.push(cr("©day",r.toISOString().slice(0,10)));break;case"comment":s.push(cr("©cmt",r));break;case"lyrics":s.push(cr("©lyr",r));break;case"raw":break;case"discNumber":case"discsTotal":case"trackNumber":case"tracksTotal":case"images":break;default:Co(t)}if(e.raw)for(const t in e.raw){const r=e.raw[t];r==null||t.length!==4||s.some(i=>i.type===t)||(typeof r=="string"?s.push(cr(t,r)):r instanceof Uint8Array&&s.push(be(t,Array.from(r))))}},cr=(s,e)=>{const t=sr.encode(e);return be(s,[ge(t.length),ge(z0("und")),Array.from(t)])},D0={"image/jpeg":13,"image/png":14,"image/bmp":27},B0=(s,e)=>{const t=[];for(const{key:r,value:i}of h0(s))switch(r){case"title":t.push({key:e?"title":"©nam",value:$t(i)});break;case"description":t.push({key:e?"description":"©des",value:$t(i)});break;case"artist":t.push({key:e?"artist":"©ART",value:$t(i)});break;case"album":t.push({key:e?"album":"©alb",value:$t(i)});break;case"albumArtist":t.push({key:e?"album_artist":"aART",value:$t(i)});break;case"comment":t.push({key:e?"comment":"©cmt",value:$t(i)});break;case"genre":t.push({key:e?"genre":"©gen",value:$t(i)});break;case"lyrics":t.push({key:e?"lyrics":"©lyr",value:$t(i)});break;case"date":t.push({key:e?"date":"©day",value:$t(i.toISOString().slice(0,10))});break;case"images":for(const n of i)n.kind==="coverFront"&&t.push({key:"covr",value:be("data",[X(D0[n.mimeType]??0),X(0),Array.from(n.data)])});break;case"trackNumber":if(e){const n=s.tracksTotal!==void 0?`${i}/${s.tracksTotal}`:i.toString();t.push({key:"track",value:$t(n)})}else t.push({key:"trkn",value:be("data",[X(0),X(0),ge(0),ge(i),ge(s.tracksTotal??0),ge(0)])});break;case"discNumber":e||t.push({key:"disc",value:be("data",[X(0),X(0),ge(0),ge(i),ge(s.discsTotal??0),ge(0)])});break;case"tracksTotal":case"discsTotal":break;case"raw":break;default:Co(r)}if(s.raw)for(const r in s.raw){const i=s.raw[r];i==null||!e&&r.length!==4||t.some(n=>n.key===r)||(typeof i=="string"?t.push({key:r,value:$t(i)}):i instanceof Uint8Array?t.push({key:r,value:be("data",[X(0),X(0),Array.from(i)])}):i instanceof d0&&t.push({key:r,value:be("data",[X(D0[i.mimeType]??0),X(0),Array.from(i.data)])}))}return t},n2=s=>{const e=B0(s,!1);return e.length===0?null:Ne("meta",0,0,void 0,[Ro(!1,"mdir","","appl"),be("ilst",void 0,e.map(t=>be(t.key,void 0,[t.value])))])},a2=s=>{const e=B0(s,!0);return e.length===0?null:be("meta",void 0,[Ro(!1,"mdta",""),Ne("keys",0,0,[X(e.length)],e.map(t=>be("mdta",[...sr.encode(t.key)]))),be("ilst",void 0,e.map((t,r)=>{const i=String.fromCharCode(...X(r+1));return be(i,void 0,[t.value])}))])},$t=s=>be("data",[X(1),X(0),...sr.encode(s)]),o2={avc:"avc1",hevc:"hvc1",vp8:"vp08",vp9:"vp09",av1:"av01"},l2={avc:Ew,hevc:Aw,vp8:F0,vp9:F0,av1:Iw},L0=(s,e)=>{switch(s){case"aac":return"mp4a";case"mp3":return"mp4a";case"opus":return"Opus";case"vorbis":return"mp4a";case"flac":return"fLaC";case"ulaw":return"ulaw";case"alaw":return"alaw";case"pcm-u8":return"raw ";case"pcm-s8":return"sowt"}if(e)switch(s){case"pcm-s16":return"sowt";case"pcm-s16be":return"twos";case"pcm-s24":return"in24";case"pcm-s24be":return"in24";case"pcm-s32":return"in32";case"pcm-s32be":return"in32";case"pcm-f32":return"fl32";case"pcm-f32be":return"fl32";case"pcm-f64":return"fl64";case"pcm-f64be":return"fl64"}else switch(s){case"pcm-s16":return"ipcm";case"pcm-s16be":return"ipcm";case"pcm-s24":return"ipcm";case"pcm-s24be":return"ipcm";case"pcm-s32":return"ipcm";case"pcm-s32be":return"ipcm";case"pcm-f32":return"fpcm";case"pcm-f32be":return"fpcm";case"pcm-f64":return"fpcm";case"pcm-f64be":return"fpcm"}},c2=(s,e)=>{switch(s){case"aac":return Mo;case"mp3":return Mo;case"opus":return Rw;case"vorbis":return Mo;case"flac":return Mw}if(e)switch(s){case"pcm-s24":return jr;case"pcm-s24be":return jr;case"pcm-s32":return jr;case"pcm-s32be":return jr;case"pcm-f32":return jr;case"pcm-f32be":return jr;case"pcm-f64":return jr;case"pcm-f64be":return jr}else switch(s){case"pcm-s16":return lr;case"pcm-s16be":return lr;case"pcm-s24":return lr;case"pcm-s24be":return lr;case"pcm-s32":return lr;case"pcm-s32be":return lr;case"pcm-f32":return lr;case"pcm-f32be":return lr;case"pcm-f64":return lr;case"pcm-f64be":return lr}return null},u2={webvtt:"wvtt"},h2={webvtt:Bw},z0=s=>{Y(s.length===3);let e=0;for(let t=0;t<3;t++)e<<=5,e+=s.charCodeAt(t)-96;return e};/*!
266
268
  * Copyright (c) 2025-present, Vanilagy and contributors
267
269
  *
268
270
  * This Source Code Form is subject to the terms of the Mozilla Public
269
271
  * License, v. 2.0. If a copy of the MPL was not distributed with this
270
272
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
271
- */class Yc{constructor(){this.ensureMonotonicity=!1,this.trackedWrites=null,this.trackedStart=-1,this.trackedEnd=-1}start(){}maybeTrackWrites(e){if(!this.trackedWrites)return;let t=this.getPos();if(t<this.trackedStart){if(t+e.byteLength<=this.trackedStart)return;e=e.subarray(this.trackedStart-t),t=0}const i=t+e.byteLength-this.trackedStart;let r=this.trackedWrites.byteLength;for(;r<i;)r*=2;if(r!==this.trackedWrites.byteLength){const n=new Uint8Array(r);n.set(this.trackedWrites,0),this.trackedWrites=n}this.trackedWrites.set(e,t-this.trackedStart),this.trackedEnd=Math.max(this.trackedEnd,t+e.byteLength)}startTrackingWrites(){this.trackedWrites=new Uint8Array(2**10),this.trackedStart=this.getPos(),this.trackedEnd=this.trackedStart}stopTrackingWrites(){if(!this.trackedWrites)throw new Error("Internal error: Can't get tracked writes since nothing was tracked.");const t={data:this.trackedWrites.subarray(0,this.trackedEnd-this.trackedStart),start:this.trackedStart,end:this.trackedEnd};return this.trackedWrites=null,t}}const vs=2**16,ws=2**32;class dn extends Yc{constructor(e){if(super(),this.pos=0,this.maxPos=0,this.target=e,this.supportsResize="resize"in new ArrayBuffer(0),this.supportsResize)try{this.buffer=new ArrayBuffer(vs,{maxByteLength:ws})}catch{this.buffer=new ArrayBuffer(vs),this.supportsResize=!1}else this.buffer=new ArrayBuffer(vs);this.bytes=new Uint8Array(this.buffer)}ensureSize(e){let t=this.buffer.byteLength;for(;t<e;)t*=2;if(t!==this.buffer.byteLength){if(t>ws)throw new Error(`ArrayBuffer exceeded maximum size of ${ws} bytes. Please consider using another target.`);if(this.supportsResize)this.buffer.resize(t);else{const i=new ArrayBuffer(t),r=new Uint8Array(i);r.set(this.bytes,0),this.buffer=i,this.bytes=r}}}write(e){this.maybeTrackWrites(e),this.ensureSize(this.pos+e.byteLength),this.bytes.set(e,this.pos),this.target.onwrite?.(this.pos,this.pos+e.byteLength),this.pos+=e.byteLength,this.maxPos=Math.max(this.maxPos,this.pos)}seek(e){this.pos=e}getPos(){return this.pos}async flush(){}async finalize(){this.ensureSize(this.pos),this.target.buffer=this.buffer.slice(0,Math.max(this.maxPos,this.pos))}async close(){}getSlice(e,t){return this.bytes.slice(e,t)}}/*!
273
+ */class d2{constructor(){this.ensureMonotonicity=!1,this.trackedWrites=null,this.trackedStart=-1,this.trackedEnd=-1}start(){}maybeTrackWrites(e){if(!this.trackedWrites)return;let t=this.getPos();if(t<this.trackedStart){if(t+e.byteLength<=this.trackedStart)return;e=e.subarray(this.trackedStart-t),t=0}const r=t+e.byteLength-this.trackedStart;let i=this.trackedWrites.byteLength;for(;i<r;)i*=2;if(i!==this.trackedWrites.byteLength){const n=new Uint8Array(i);n.set(this.trackedWrites,0),this.trackedWrites=n}this.trackedWrites.set(e,t-this.trackedStart),this.trackedEnd=Math.max(this.trackedEnd,t+e.byteLength)}startTrackingWrites(){this.trackedWrites=new Uint8Array(2**10),this.trackedStart=this.getPos(),this.trackedEnd=this.trackedStart}stopTrackingWrites(){if(!this.trackedWrites)throw new Error("Internal error: Can't get tracked writes since nothing was tracked.");const t={data:this.trackedWrites.subarray(0,this.trackedEnd-this.trackedStart),start:this.trackedStart,end:this.trackedEnd};return this.trackedWrites=null,t}}const Do=2**16,Bo=2**32;class $0 extends d2{constructor(e){if(super(),this.pos=0,this.maxPos=0,this.target=e,this.supportsResize="resize"in new ArrayBuffer(0),this.supportsResize)try{this.buffer=new ArrayBuffer(Do,{maxByteLength:Bo})}catch{this.buffer=new ArrayBuffer(Do),this.supportsResize=!1}else this.buffer=new ArrayBuffer(Do);this.bytes=new Uint8Array(this.buffer)}ensureSize(e){let t=this.buffer.byteLength;for(;t<e;)t*=2;if(t!==this.buffer.byteLength){if(t>Bo)throw new Error(`ArrayBuffer exceeded maximum size of ${Bo} bytes. Please consider using another target.`);if(this.supportsResize)this.buffer.resize(t);else{const r=new ArrayBuffer(t),i=new Uint8Array(r);i.set(this.bytes,0),this.buffer=r,this.bytes=i}}}write(e){this.maybeTrackWrites(e),this.ensureSize(this.pos+e.byteLength),this.bytes.set(e,this.pos),this.target.onwrite?.(this.pos,this.pos+e.byteLength),this.pos+=e.byteLength,this.maxPos=Math.max(this.maxPos,this.pos)}seek(e){this.pos=e}getPos(){return this.pos}async flush(){}async finalize(){this.ensureSize(this.pos),this.target.buffer=this.buffer.slice(0,Math.max(this.maxPos,this.pos))}async close(){}getSlice(e,t){return this.bytes.slice(e,t)}}/*!
272
274
  * Copyright (c) 2025-present, Vanilagy and contributors
273
275
  *
274
276
  * This Source Code Form is subject to the terms of the Mozilla Public
275
277
  * License, v. 2.0. If a copy of the MPL was not distributed with this
276
278
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
277
- */class fn{constructor(){this._output=null,this.onwrite=null}}class pn extends fn{constructor(){super(...arguments),this.buffer=null}_createWriter(){return new dn(this)}}/*!
279
+ */class N0{constructor(){this._output=null,this.onwrite=null}}class U0 extends N0{constructor(){super(...arguments),this.buffer=null}_createWriter(){return new $0(this)}}/*!
278
280
  * Copyright (c) 2025-present, Vanilagy and contributors
279
281
  *
280
282
  * This Source Code Form is subject to the terms of the Mozilla Public
281
283
  * License, v. 2.0. If a copy of the MPL was not distributed with this
282
284
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
283
- */const _s=1e3,Qc=2082844800,Jc=s=>{const e={},t=s.track;return t.metadata.name!==void 0&&(e.name=t.metadata.name),e},xe=(s,e,t=!0)=>{const i=s*e;return t?Math.round(i):i};class eh extends kl{constructor(e,t){super(e),this.auxTarget=new pn,this.auxWriter=this.auxTarget._createWriter(),this.auxBoxWriter=new Yr(this.auxWriter),this.mdat=null,this.ftypSize=null,this.trackDatas=[],this.allTracksKnown=tl(),this.creationTime=Math.floor(Date.now()/1e3)+Qc,this.finalizedChunks=[],this.nextFragmentNumber=1,this.maxWrittenTimestamp=-1/0,this.format=t,this.writer=e._writer,this.boxWriter=new Yr(this.writer),this.isQuickTime=t instanceof bn;const i=this.writer instanceof dn?"in-memory":!1;this.fastStart=t._options.fastStart??i,this.isFragmented=this.fastStart==="fragmented",(this.fastStart==="in-memory"||this.isFragmented)&&(this.writer.ensureMonotonicity=!0),this.minimumFragmentDuration=t._options.minimumFragmentDuration??1}async start(){const e=await this.mutex.acquire(),t=this.output._tracks.some(i=>i.type==="video"&&i.source._codec==="avc");if(this.format._options.onFtyp&&this.writer.startTrackingWrites(),this.boxWriter.writeBox(Kl({isQuickTime:this.isQuickTime,holdsAvc:t,fragmented:this.isFragmented})),this.format._options.onFtyp){const{data:i,start:r}=this.writer.stopTrackingWrites();this.format._options.onFtyp(i,r)}if(this.ftypSize=this.writer.getPos(),this.fastStart!=="in-memory")if(this.fastStart==="reserve"){for(const i of this.output._tracks)if(i.metadata.maximumPacketCount===void 0)throw new Error("All tracks must specify maximumPacketCount in their metadata when using fastStart: 'reserve'.")}else this.isFragmented||(this.format._options.onMdat&&this.writer.startTrackingWrites(),this.mdat=Ti(!0),this.boxWriter.writeBox(this.mdat));await this.writer.flush(),e()}allTracksAreKnown(){for(const e of this.output._tracks)if(!e.source._closed&&!this.trackDatas.some(t=>t.track===e))return!1;return!0}async getMimeType(){await this.allTracksKnown.promise;const e=this.trackDatas.map(t=>t.type==="video"||t.type==="audio"?t.info.decoderConfig.codec:{webvtt:"wvtt"}[t.track.source._codec]);return Wl({isQuickTime:this.isQuickTime,hasVideo:this.trackDatas.some(t=>t.type==="video"),hasAudio:this.trackDatas.some(t=>t.type==="audio"),codecStrings:e})}getVideoTrackData(e,t,i){const r=this.trackDatas.find(m=>m.track===e);if(r)return r;wl(i),$(i),$(i.decoderConfig);const n={...i.decoderConfig};$(n.codedWidth!==void 0),$(n.codedHeight!==void 0);let o=!1;if(e.source._codec==="avc"&&!n.description){const m=Sl(t.data);if(!m)throw new Error("Couldn't extract an AVCDecoderConfigurationRecord from the AVC packet. Make sure the packets are in Annex B format (as specified in ITU-T-REC-H.264) when not providing a description, or provide a description (must be an AVCDecoderConfigurationRecord as specified in ISO 14496-15) and ensure the packets are in AVCC format.");n.description=El(m),o=!0}else if(e.source._codec==="hevc"&&!n.description){const m=Al(t.data);if(!m)throw new Error("Couldn't extract an HEVCDecoderConfigurationRecord from the HEVC packet. Make sure the packets are in Annex B format (as specified in ITU-T-REC-H.265) when not providing a description, or provide a description (must be an HEVCDecoderConfigurationRecord as specified in ISO 14496-15) and ensure the packets are in HEVC format.");n.description=Ll(m),o=!0}const a=al(1/(e.metadata.frameRate??57600),1e6).denominator,p={muxer:this,track:e,type:"video",info:{width:n.codedWidth,height:n.codedHeight,decoderConfig:n,requiresAnnexBTransformation:o},timescale:a,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[]};return this.trackDatas.push(p),this.trackDatas.sort((m,d)=>m.track.id-d.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),p}getAudioTrackData(e,t){const i=this.trackDatas.find(n=>n.track===e);if(i)return i;xl(t),$(t),$(t.decoderConfig);const r={muxer:this,track:e,type:"audio",info:{numberOfChannels:t.decoderConfig.numberOfChannels,sampleRate:t.decoderConfig.sampleRate,decoderConfig:t.decoderConfig,requiresPcmTransformation:!this.isFragmented&&Ne.includes(e.source._codec)},timescale:t.decoderConfig.sampleRate,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[]};return this.trackDatas.push(r),this.trackDatas.sort((n,o)=>n.track.id-o.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),r}getSubtitleTrackData(e,t){const i=this.trackDatas.find(n=>n.track===e);if(i)return i;Cl(t),$(t),$(t.config);const r={muxer:this,track:e,type:"subtitle",info:{config:t.config},timescale:1e3,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[],lastCueEndTimestamp:0,cueQueue:[],nextSourceId:0,cueToSourceId:new WeakMap};return this.trackDatas.push(r),this.trackDatas.sort((n,o)=>n.track.id-o.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),r}async addEncodedVideoPacket(e,t,i){const r=await this.mutex.acquire();try{const n=this.getVideoTrackData(e,t,i);let o=t.data;if(n.info.requiresAnnexBTransformation){const m=Tl(o);if(!m)throw new Error("Failed to transform packet data. Make sure all packets are provided in Annex B format, as specified in ITU-T-REC-H.264 and ITU-T-REC-H.265.");o=m}const a=this.validateAndNormalizeTimestamp(n.track,t.timestamp,t.type==="key"),p=this.createSampleForTrack(n,o,a,t.duration,t.type);await this.registerSample(n,p)}finally{r()}}async addEncodedAudioPacket(e,t,i){const r=await this.mutex.acquire();try{const n=this.getAudioTrackData(e,i),o=this.validateAndNormalizeTimestamp(n.track,t.timestamp,t.type==="key"),a=this.createSampleForTrack(n,t.data,o,t.duration,t.type);n.info.requiresPcmTransformation&&await this.maybePadWithSilence(n,o),await this.registerSample(n,a)}finally{r()}}async maybePadWithSilence(e,t){const i=ze(e.samples),r=i?i.timestamp+i.duration:0,n=t-r,o=xe(n,e.timescale);if(o>0){const{sampleSize:a,silentValue:p}=Lt(e.info.decoderConfig.codec),m=o*e.info.numberOfChannels,d=new Uint8Array(a*m).fill(p),l=this.createSampleForTrack(e,new Uint8Array(d.buffer),r,n,"key");await this.registerSample(e,l)}}async addSubtitleCue(e,t,i){const r=await this.mutex.acquire();try{const n=this.getSubtitleTrackData(e,i);this.validateAndNormalizeTimestamp(n.track,t.timestamp,!0),e.source._codec==="webvtt"&&(n.cueQueue.push(t),await this.processWebVTTCues(n,t.timestamp))}finally{r()}}async processWebVTTCues(e,t){for(;e.cueQueue.length>0;){const i=new Set([]);for(const m of e.cueQueue)$(m.timestamp<=t),$(e.lastCueEndTimestamp<=m.timestamp+m.duration),i.add(Math.max(m.timestamp,e.lastCueEndTimestamp)),i.add(m.timestamp+m.duration);const r=[...i].sort((m,d)=>m-d),n=r[0],o=r[1]??n;if(t<o)break;if(e.lastCueEndTimestamp<n){this.auxWriter.seek(0);const m=zc();this.auxBoxWriter.writeBox(m);const d=this.auxWriter.getSlice(0,this.auxWriter.getPos()),l=this.createSampleForTrack(e,d,e.lastCueEndTimestamp,n-e.lastCueEndTimestamp,"key");await this.registerSample(e,l),e.lastCueEndTimestamp=n}this.auxWriter.seek(0);for(let m=0;m<e.cueQueue.length;m++){const d=e.cueQueue[m];if(d.timestamp>=o)break;Xr.lastIndex=0;const l=Xr.test(d.text),c=d.timestamp+d.duration;let u=e.cueToSourceId.get(d);if(u===void 0&&o<c&&(u=e.nextSourceId++,e.cueToSourceId.set(d,u)),d.notes){const f=Nc(d.notes);this.auxBoxWriter.writeBox(f)}const h=Hc(d.text,l?n:null,d.identifier??null,d.settings??null,u??null);this.auxBoxWriter.writeBox(h),c===o&&e.cueQueue.splice(m--,1)}const a=this.auxWriter.getSlice(0,this.auxWriter.getPos()),p=this.createSampleForTrack(e,a,n,o-n,"key");await this.registerSample(e,p),e.lastCueEndTimestamp=o}}createSampleForTrack(e,t,i,r,n){return{timestamp:i,decodeTimestamp:i,duration:r,data:t,size:t.byteLength,type:n,timescaleUnitsToNextSample:xe(r,e.timescale)}}processTimestamps(e,t){if(e.timestampProcessingQueue.length===0)return;if(e.type==="audio"&&e.info.requiresPcmTransformation){let r=0;for(let n=0;n<e.timestampProcessingQueue.length;n++){const o=e.timestampProcessingQueue[n],a=xe(o.duration,e.timescale);r+=a}if(e.timeToSampleTable.length===0)e.timeToSampleTable.push({sampleCount:r,sampleDelta:1});else{const n=ze(e.timeToSampleTable);n.sampleCount+=r}e.timestampProcessingQueue.length=0;return}const i=e.timestampProcessingQueue.map(r=>r.timestamp).sort((r,n)=>r-n);for(let r=0;r<e.timestampProcessingQueue.length;r++){const n=e.timestampProcessingQueue[r];n.decodeTimestamp=i[r],!this.isFragmented&&e.lastTimescaleUnits===null&&(n.decodeTimestamp=0);const o=xe(n.timestamp-n.decodeTimestamp,e.timescale),a=xe(n.duration,e.timescale);if(e.lastTimescaleUnits!==null){$(e.lastSample);const p=xe(n.decodeTimestamp,e.timescale,!1),m=Math.round(p-e.lastTimescaleUnits);if($(m>=0),e.lastTimescaleUnits+=m,e.lastSample.timescaleUnitsToNextSample=m,!this.isFragmented){let d=ze(e.timeToSampleTable);if($(d),d.sampleCount===1){d.sampleDelta=m;const c=e.timeToSampleTable[e.timeToSampleTable.length-2];c&&c.sampleDelta===m&&(c.sampleCount++,e.timeToSampleTable.pop(),d=c)}else d.sampleDelta!==m&&(d.sampleCount--,e.timeToSampleTable.push(d={sampleCount:1,sampleDelta:m}));d.sampleDelta===a?d.sampleCount++:e.timeToSampleTable.push({sampleCount:1,sampleDelta:a});const l=ze(e.compositionTimeOffsetTable);$(l),l.sampleCompositionTimeOffset===o?l.sampleCount++:e.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:o})}}else e.lastTimescaleUnits=xe(n.decodeTimestamp,e.timescale,!1),this.isFragmented||(e.timeToSampleTable.push({sampleCount:1,sampleDelta:a}),e.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:o}));e.lastSample=n}if(e.timestampProcessingQueue.length=0,$(e.lastSample),$(e.lastTimescaleUnits!==null),t!==void 0&&e.lastSample.timescaleUnitsToNextSample===0){$(t.type==="key");const r=xe(t.timestamp,e.timescale,!1),n=Math.round(r-e.lastTimescaleUnits);e.lastSample.timescaleUnitsToNextSample=n}}async registerSample(e,t){t.type==="key"&&this.processTimestamps(e,t),e.timestampProcessingQueue.push(t),this.isFragmented?(e.sampleQueue.push(t),await this.interleaveSamples()):this.fastStart==="reserve"?await this.registerSampleFastStartReserve(e,t):await this.addSampleToTrack(e,t)}async addSampleToTrack(e,t){if(!this.isFragmented&&(e.samples.push(t),this.fastStart==="reserve")){const r=e.track.metadata.maximumPacketCount;if($(r!==void 0),e.samples.length>r)throw new Error(`Track #${e.track.id} has already reached the maximum packet count (${r}). Either add less packets or increase the maximum packet count.`)}let i=!1;if(!e.currentChunk)i=!0;else{e.currentChunk.startTimestamp=Math.min(e.currentChunk.startTimestamp,t.timestamp);const r=t.timestamp-e.currentChunk.startTimestamp;if(this.isFragmented){const n=this.trackDatas.every(o=>{if(e===o)return t.type==="key";const a=o.sampleQueue[0];return a?a.type==="key":o.track.source._closed});r>=this.minimumFragmentDuration&&n&&t.timestamp>this.maxWrittenTimestamp&&(i=!0,await this.finalizeFragment())}else i=r>=.5}i&&(e.currentChunk&&await this.finalizeCurrentChunk(e),e.currentChunk={startTimestamp:t.timestamp,samples:[],offset:null,moofOffset:null}),$(e.currentChunk),e.currentChunk.samples.push(t),this.isFragmented&&(this.maxWrittenTimestamp=Math.max(this.maxWrittenTimestamp,t.timestamp))}async finalizeCurrentChunk(e){if($(!this.isFragmented),!e.currentChunk)return;e.finalizedChunks.push(e.currentChunk),this.finalizedChunks.push(e.currentChunk);let t=e.currentChunk.samples.length;if(e.type==="audio"&&e.info.requiresPcmTransformation&&(t=e.currentChunk.samples.reduce((i,r)=>i+xe(r.duration,e.timescale),0)),(e.compactlyCodedChunkTable.length===0||ze(e.compactlyCodedChunkTable).samplesPerChunk!==t)&&e.compactlyCodedChunkTable.push({firstChunk:e.finalizedChunks.length,samplesPerChunk:t}),this.fastStart==="in-memory"){e.currentChunk.offset=0;return}e.currentChunk.offset=this.writer.getPos();for(const i of e.currentChunk.samples)$(i.data),this.writer.write(i.data),i.data=null;await this.writer.flush()}async interleaveSamples(e=!1){if($(this.isFragmented),!(!e&&!this.allTracksAreKnown()))e:for(;;){let t=null,i=1/0;for(const n of this.trackDatas){if(!e&&n.sampleQueue.length===0&&!n.track.source._closed)break e;n.sampleQueue.length>0&&n.sampleQueue[0].timestamp<i&&(t=n,i=n.sampleQueue[0].timestamp)}if(!t)break;const r=t.sampleQueue.shift();await this.addSampleToTrack(t,r)}}async finalizeFragment(e=!0){$(this.isFragmented);const t=this.nextFragmentNumber++;if(t===1){this.format._options.onMoov&&this.writer.startTrackingWrites();const u=si(this);if(this.boxWriter.writeBox(u),this.format._options.onMoov){const{data:h,start:f}=this.writer.stopTrackingWrites();this.format._options.onMoov(h,f)}}const i=this.trackDatas.filter(u=>u.currentChunk),r=an(t,i),n=this.writer.getPos(),o=n+this.boxWriter.measureBox(r);let a=o+fs,p=1/0;for(const u of i){u.currentChunk.offset=a,u.currentChunk.moofOffset=n;for(const h of u.currentChunk.samples)a+=h.size;p=Math.min(p,u.currentChunk.startTimestamp)}const m=a-o,d=m>=2**32;if(d)for(const u of i)u.currentChunk.offset+=qr-fs;this.format._options.onMoof&&this.writer.startTrackingWrites();const l=an(t,i);if(this.boxWriter.writeBox(l),this.format._options.onMoof){const{data:u,start:h}=this.writer.stopTrackingWrites();this.format._options.onMoof(u,h,p)}$(this.writer.getPos()===o),this.format._options.onMdat&&this.writer.startTrackingWrites();const c=Ti(d);c.size=m,this.boxWriter.writeBox(c),this.writer.seek(o+(d?qr:fs));for(const u of i)for(const h of u.currentChunk.samples)this.writer.write(h.data),h.data=null;if(this.format._options.onMdat){const{data:u,start:h}=this.writer.stopTrackingWrites();this.format._options.onMdat(u,h)}for(const u of i)u.finalizedChunks.push(u.currentChunk),this.finalizedChunks.push(u.currentChunk),u.currentChunk=null;e&&await this.writer.flush()}async registerSampleFastStartReserve(e,t){if(this.allTracksAreKnown()){if(!this.mdat){const i=si(this),n=this.boxWriter.measureBox(i)+this.computeSampleTableSizeUpperBound()+4096;$(this.ftypSize!==null),this.writer.seek(this.ftypSize+n),this.format._options.onMdat&&this.writer.startTrackingWrites(),this.mdat=Ti(!0),this.boxWriter.writeBox(this.mdat);for(const o of this.trackDatas){for(const a of o.sampleQueue)await this.addSampleToTrack(o,a);o.sampleQueue.length=0}}await this.addSampleToTrack(e,t)}else e.sampleQueue.push(t)}computeSampleTableSizeUpperBound(){$(this.fastStart==="reserve");let e=0;for(const t of this.trackDatas){const i=t.track.metadata.maximumPacketCount;$(i!==void 0),e+=8*Math.ceil(2/3*i),e+=4*i,e+=8*Math.ceil(2/3*i),e+=12*Math.ceil(2/3*i),e+=4*i,e+=8*i}return e}async onTrackClose(e){const t=await this.mutex.acquire();if(e.type==="subtitle"&&e.source._codec==="webvtt"){const i=this.trackDatas.find(r=>r.track===e);i&&await this.processWebVTTCues(i,1/0)}this.allTracksAreKnown()&&this.allTracksKnown.resolve(),this.isFragmented&&await this.interleaveSamples(),t()}async finalize(){const e=await this.mutex.acquire();this.allTracksKnown.resolve();for(const t of this.trackDatas)t.type==="subtitle"&&t.track.source._codec==="webvtt"&&await this.processWebVTTCues(t,1/0);if(this.isFragmented){await this.interleaveSamples(!0);for(const t of this.trackDatas)this.processTimestamps(t);await this.finalizeFragment(!1)}else for(const t of this.trackDatas)this.processTimestamps(t),await this.finalizeCurrentChunk(t);if(this.fastStart==="in-memory"){this.mdat=Ti(!1);let t;for(let r=0;r<2;r++){const n=si(this),o=this.boxWriter.measureBox(n);t=this.boxWriter.measureBox(this.mdat);let a=this.writer.getPos()+o+t;for(const p of this.finalizedChunks){p.offset=a;for(const{data:m}of p.samples)$(m),a+=m.byteLength,t+=m.byteLength}if(a<2**32)break;t>=2**32&&(this.mdat.largeSize=!0)}this.format._options.onMoov&&this.writer.startTrackingWrites();const i=si(this);if(this.boxWriter.writeBox(i),this.format._options.onMoov){const{data:r,start:n}=this.writer.stopTrackingWrites();this.format._options.onMoov(r,n)}this.format._options.onMdat&&this.writer.startTrackingWrites(),this.mdat.size=t,this.boxWriter.writeBox(this.mdat);for(const r of this.finalizedChunks)for(const n of r.samples)$(n.data),this.writer.write(n.data),n.data=null;if(this.format._options.onMdat){const{data:r,start:n}=this.writer.stopTrackingWrites();this.format._options.onMdat(r,n)}}else if(this.isFragmented){const t=this.writer.getPos(),i=Bc(this.trackDatas);this.boxWriter.writeBox(i);const r=this.writer.getPos()-t;this.writer.seek(this.writer.getPos()-4),this.boxWriter.writeU32(r)}else{$(this.mdat);const t=this.boxWriter.offsets.get(this.mdat);$(t!==void 0);const i=this.writer.getPos()-t;if(this.mdat.size=i,this.mdat.largeSize=i>=2**32,this.boxWriter.patchBox(this.mdat),this.format._options.onMdat){const{data:n,start:o}=this.writer.stopTrackingWrites();this.format._options.onMdat(n,o)}const r=si(this);if(this.fastStart==="reserve"){$(this.ftypSize!==null),this.writer.seek(this.ftypSize),this.format._options.onMoov&&this.writer.startTrackingWrites(),this.boxWriter.writeBox(r);const n=this.boxWriter.offsets.get(this.mdat)-this.writer.getPos();this.boxWriter.writeBox(ql(n))}else this.format._options.onMoov&&this.writer.startTrackingWrites(),this.boxWriter.writeBox(r);if(this.format._options.onMoov){const{data:n,start:o}=this.writer.stopTrackingWrites();this.format._options.onMoov(n,o)}}e()}}/*!
285
+ */const Lo=1e3,f2=2082844800,p2=s=>{const e={},t=s.track;return t.metadata.name!==void 0&&(e.name=t.metadata.name),e},ht=(s,e,t=!0)=>{const r=s*e;return t?Math.round(r):r};class m2 extends Nv{constructor(e,t){super(e),this.auxTarget=new U0,this.auxWriter=this.auxTarget._createWriter(),this.auxBoxWriter=new _0(this.auxWriter),this.mdat=null,this.ftypSize=null,this.trackDatas=[],this.allTracksKnown=yv(),this.creationTime=Math.floor(Date.now()/1e3)+f2,this.finalizedChunks=[],this.nextFragmentNumber=1,this.maxWrittenTimestamp=-1/0,this.format=t,this.writer=e._writer,this.boxWriter=new _0(this.writer),this.isQuickTime=t instanceof W0;const r=this.writer instanceof $0?"in-memory":!1;this.fastStart=t._options.fastStart??r,this.isFragmented=this.fastStart==="fragmented",(this.fastStart==="in-memory"||this.isFragmented)&&(this.writer.ensureMonotonicity=!0),this.minimumFragmentDuration=t._options.minimumFragmentDuration??1}async start(){const e=await this.mutex.acquire(),t=this.output._tracks.some(r=>r.type==="video"&&r.source._codec==="avc");if(this.format._options.onFtyp&&this.writer.startTrackingWrites(),this.boxWriter.writeBox(cw({isQuickTime:this.isQuickTime,holdsAvc:t,fragmented:this.isFragmented})),this.format._options.onFtyp){const{data:r,start:i}=this.writer.stopTrackingWrites();this.format._options.onFtyp(r,i)}if(this.ftypSize=this.writer.getPos(),this.fastStart!=="in-memory")if(this.fastStart==="reserve"){for(const r of this.output._tracks)if(r.metadata.maximumPacketCount===void 0)throw new Error("All tracks must specify maximumPacketCount in their metadata when using fastStart: 'reserve'.")}else this.isFragmented||(this.format._options.onMdat&&this.writer.startTrackingWrites(),this.mdat=Un(!0),this.boxWriter.writeBox(this.mdat));await this.writer.flush(),e()}allTracksAreKnown(){for(const e of this.output._tracks)if(!e.source._closed&&!this.trackDatas.some(t=>t.track===e))return!1;return!0}async getMimeType(){await this.allTracksKnown.promise;const e=this.trackDatas.map(t=>t.type==="video"||t.type==="audio"?t.info.decoderConfig.codec:{webvtt:"wvtt"}[t.track.source._codec]);return ow({isQuickTime:this.isQuickTime,hasVideo:this.trackDatas.some(t=>t.type==="video"),hasAudio:this.trackDatas.some(t=>t.type==="audio"),codecStrings:e})}getVideoTrackData(e,t,r){const i=this.trackDatas.find(u=>u.track===e);if(i)return i;Bv(r),Y(r),Y(r.decoderConfig);const n={...r.decoderConfig};Y(n.codedWidth!==void 0),Y(n.codedHeight!==void 0);let a=!1;if(e.source._codec==="avc"&&!n.description){const u=Hv(t.data);if(!u)throw new Error("Couldn't extract an AVCDecoderConfigurationRecord from the AVC packet. Make sure the packets are in Annex B format (as specified in ITU-T-REC-H.264) when not providing a description, or provide a description (must be an AVCDecoderConfigurationRecord as specified in ISO 14496-15) and ensure the packets are in AVCC format.");n.description=Vv(u),a=!0}else if(e.source._codec==="hevc"&&!n.description){const u=jv(t.data);if(!u)throw new Error("Couldn't extract an HEVCDecoderConfigurationRecord from the HEVC packet. Make sure the packets are in Annex B format (as specified in ITU-T-REC-H.265) when not providing a description, or provide a description (must be an HEVCDecoderConfigurationRecord as specified in ISO 14496-15) and ensure the packets are in HEVC format.");n.description=Yv(u),a=!0}const o=Cv(1/(e.metadata.frameRate??57600),1e6).denominator,c={muxer:this,track:e,type:"video",info:{width:n.codedWidth,height:n.codedHeight,decoderConfig:n,requiresAnnexBTransformation:a},timescale:o,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[]};return this.trackDatas.push(c),this.trackDatas.sort((u,h)=>u.track.id-h.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),c}getAudioTrackData(e,t){const r=this.trackDatas.find(n=>n.track===e);if(r)return r;zv(t),Y(t),Y(t.decoderConfig);const i={muxer:this,track:e,type:"audio",info:{numberOfChannels:t.decoderConfig.numberOfChannels,sampleRate:t.decoderConfig.sampleRate,decoderConfig:t.decoderConfig,requiresPcmTransformation:!this.isFragmented&&nr.includes(e.source._codec)},timescale:t.decoderConfig.sampleRate,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[]};return this.trackDatas.push(i),this.trackDatas.sort((n,a)=>n.track.id-a.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),i}getSubtitleTrackData(e,t){const r=this.trackDatas.find(n=>n.track===e);if(r)return r;$v(t),Y(t),Y(t.config);const i={muxer:this,track:e,type:"subtitle",info:{config:t.config},timescale:1e3,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[],lastCueEndTimestamp:0,cueQueue:[],nextSourceId:0,cueToSourceId:new WeakMap};return this.trackDatas.push(i),this.trackDatas.sort((n,a)=>n.track.id-a.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),i}async addEncodedVideoPacket(e,t,r){const i=await this.mutex.acquire();try{const n=this.getVideoTrackData(e,t,r);let a=t.data;if(n.info.requiresAnnexBTransformation){const u=Uv(a);if(!u)throw new Error("Failed to transform packet data. Make sure all packets are provided in Annex B format, as specified in ITU-T-REC-H.264 and ITU-T-REC-H.265.");a=u}const o=this.validateAndNormalizeTimestamp(n.track,t.timestamp,t.type==="key"),c=this.createSampleForTrack(n,a,o,t.duration,t.type);await this.registerSample(n,c)}finally{i()}}async addEncodedAudioPacket(e,t,r){const i=await this.mutex.acquire();try{const n=this.getAudioTrackData(e,r),a=this.validateAndNormalizeTimestamp(n.track,t.timestamp,t.type==="key"),o=this.createSampleForTrack(n,t.data,a,t.duration,t.type);n.info.requiresPcmTransformation&&await this.maybePadWithSilence(n,a),await this.registerSample(n,o)}finally{i()}}async maybePadWithSilence(e,t){const r=ir(e.samples),i=r?r.timestamp+r.duration:0,n=t-i,a=ht(n,e.timescale);if(a>0){const{sampleSize:o,silentValue:c}=Bi(e.info.decoderConfig.codec),u=a*e.info.numberOfChannels,h=new Uint8Array(o*u).fill(c),l=this.createSampleForTrack(e,new Uint8Array(h.buffer),i,n,"key");await this.registerSample(e,l)}}async addSubtitleCue(e,t,r){const i=await this.mutex.acquire();try{const n=this.getSubtitleTrackData(e,r);this.validateAndNormalizeTimestamp(n.track,t.timestamp,!0),e.source._codec==="webvtt"&&(n.cueQueue.push(t),await this.processWebVTTCues(n,t.timestamp))}finally{i()}}async processWebVTTCues(e,t){for(;e.cueQueue.length>0;){const r=new Set([]);for(const u of e.cueQueue)Y(u.timestamp<=t),Y(e.lastCueEndTimestamp<=u.timestamp+u.duration),r.add(Math.max(u.timestamp,e.lastCueEndTimestamp)),r.add(u.timestamp+u.duration);const i=[...r].sort((u,h)=>u-h),n=i[0],a=i[1]??n;if(t<a)break;if(e.lastCueEndTimestamp<n){this.auxWriter.seek(0);const u=e2();this.auxBoxWriter.writeBox(u);const h=this.auxWriter.getSlice(0,this.auxWriter.getPos()),l=this.createSampleForTrack(e,h,e.lastCueEndTimestamp,n-e.lastCueEndTimestamp,"key");await this.registerSample(e,l),e.lastCueEndTimestamp=n}this.auxWriter.seek(0);for(let u=0;u<e.cueQueue.length;u++){const h=e.cueQueue[u];if(h.timestamp>=a)break;S0.lastIndex=0;const l=S0.test(h.text),d=h.timestamp+h.duration;let f=e.cueToSourceId.get(h);if(f===void 0&&a<d&&(f=e.nextSourceId++,e.cueToSourceId.set(h,f)),h.notes){const m=r2(h.notes);this.auxBoxWriter.writeBox(m)}const p=t2(h.text,l?n:null,h.identifier??null,h.settings??null,f??null);this.auxBoxWriter.writeBox(p),d===a&&e.cueQueue.splice(u--,1)}const o=this.auxWriter.getSlice(0,this.auxWriter.getPos()),c=this.createSampleForTrack(e,o,n,a-n,"key");await this.registerSample(e,c),e.lastCueEndTimestamp=a}}createSampleForTrack(e,t,r,i,n){return{timestamp:r,decodeTimestamp:r,duration:i,data:t,size:t.byteLength,type:n,timescaleUnitsToNextSample:ht(i,e.timescale)}}processTimestamps(e,t){if(e.timestampProcessingQueue.length===0)return;if(e.type==="audio"&&e.info.requiresPcmTransformation){let i=0;for(let n=0;n<e.timestampProcessingQueue.length;n++){const a=e.timestampProcessingQueue[n],o=ht(a.duration,e.timescale);i+=o}if(e.timeToSampleTable.length===0)e.timeToSampleTable.push({sampleCount:i,sampleDelta:1});else{const n=ir(e.timeToSampleTable);n.sampleCount+=i}e.timestampProcessingQueue.length=0;return}const r=e.timestampProcessingQueue.map(i=>i.timestamp).sort((i,n)=>i-n);for(let i=0;i<e.timestampProcessingQueue.length;i++){const n=e.timestampProcessingQueue[i];n.decodeTimestamp=r[i],!this.isFragmented&&e.lastTimescaleUnits===null&&(n.decodeTimestamp=0);const a=ht(n.timestamp-n.decodeTimestamp,e.timescale),o=ht(n.duration,e.timescale);if(e.lastTimescaleUnits!==null){Y(e.lastSample);const c=ht(n.decodeTimestamp,e.timescale,!1),u=Math.round(c-e.lastTimescaleUnits);if(Y(u>=0),e.lastTimescaleUnits+=u,e.lastSample.timescaleUnitsToNextSample=u,!this.isFragmented){let h=ir(e.timeToSampleTable);if(Y(h),h.sampleCount===1){h.sampleDelta=u;const d=e.timeToSampleTable[e.timeToSampleTable.length-2];d&&d.sampleDelta===u&&(d.sampleCount++,e.timeToSampleTable.pop(),h=d)}else h.sampleDelta!==u&&(h.sampleCount--,e.timeToSampleTable.push(h={sampleCount:1,sampleDelta:u}));h.sampleDelta===o?h.sampleCount++:e.timeToSampleTable.push({sampleCount:1,sampleDelta:o});const l=ir(e.compositionTimeOffsetTable);Y(l),l.sampleCompositionTimeOffset===a?l.sampleCount++:e.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:a})}}else e.lastTimescaleUnits=ht(n.decodeTimestamp,e.timescale,!1),this.isFragmented||(e.timeToSampleTable.push({sampleCount:1,sampleDelta:o}),e.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:a}));e.lastSample=n}if(e.timestampProcessingQueue.length=0,Y(e.lastSample),Y(e.lastTimescaleUnits!==null),t!==void 0&&e.lastSample.timescaleUnitsToNextSample===0){Y(t.type==="key");const i=ht(t.timestamp,e.timescale,!1),n=Math.round(i-e.lastTimescaleUnits);e.lastSample.timescaleUnitsToNextSample=n}}async registerSample(e,t){t.type==="key"&&this.processTimestamps(e,t),e.timestampProcessingQueue.push(t),this.isFragmented?(e.sampleQueue.push(t),await this.interleaveSamples()):this.fastStart==="reserve"?await this.registerSampleFastStartReserve(e,t):await this.addSampleToTrack(e,t)}async addSampleToTrack(e,t){if(!this.isFragmented&&(e.samples.push(t),this.fastStart==="reserve")){const i=e.track.metadata.maximumPacketCount;if(Y(i!==void 0),e.samples.length>i)throw new Error(`Track #${e.track.id} has already reached the maximum packet count (${i}). Either add less packets or increase the maximum packet count.`)}let r=!1;if(!e.currentChunk)r=!0;else{e.currentChunk.startTimestamp=Math.min(e.currentChunk.startTimestamp,t.timestamp);const i=t.timestamp-e.currentChunk.startTimestamp;if(this.isFragmented){const n=this.trackDatas.every(a=>{if(e===a)return t.type==="key";const o=a.sampleQueue[0];return o?o.type==="key":a.track.source._closed});i>=this.minimumFragmentDuration&&n&&t.timestamp>this.maxWrittenTimestamp&&(r=!0,await this.finalizeFragment())}else r=i>=.5}r&&(e.currentChunk&&await this.finalizeCurrentChunk(e),e.currentChunk={startTimestamp:t.timestamp,samples:[],offset:null,moofOffset:null}),Y(e.currentChunk),e.currentChunk.samples.push(t),this.isFragmented&&(this.maxWrittenTimestamp=Math.max(this.maxWrittenTimestamp,t.timestamp))}async finalizeCurrentChunk(e){if(Y(!this.isFragmented),!e.currentChunk)return;e.finalizedChunks.push(e.currentChunk),this.finalizedChunks.push(e.currentChunk);let t=e.currentChunk.samples.length;if(e.type==="audio"&&e.info.requiresPcmTransformation&&(t=e.currentChunk.samples.reduce((r,i)=>r+ht(i.duration,e.timescale),0)),(e.compactlyCodedChunkTable.length===0||ir(e.compactlyCodedChunkTable).samplesPerChunk!==t)&&e.compactlyCodedChunkTable.push({firstChunk:e.finalizedChunks.length,samplesPerChunk:t}),this.fastStart==="in-memory"){e.currentChunk.offset=0;return}e.currentChunk.offset=this.writer.getPos();for(const r of e.currentChunk.samples)Y(r.data),this.writer.write(r.data),r.data=null;await this.writer.flush()}async interleaveSamples(e=!1){if(Y(this.isFragmented),!(!e&&!this.allTracksAreKnown()))e:for(;;){let t=null,r=1/0;for(const n of this.trackDatas){if(!e&&n.sampleQueue.length===0&&!n.track.source._closed)break e;n.sampleQueue.length>0&&n.sampleQueue[0].timestamp<r&&(t=n,r=n.sampleQueue[0].timestamp)}if(!t)break;const i=t.sampleQueue.shift();await this.addSampleToTrack(t,i)}}async finalizeFragment(e=!0){Y(this.isFragmented);const t=this.nextFragmentNumber++;if(t===1){this.format._options.onMoov&&this.writer.startTrackingWrites();const f=As(this);if(this.boxWriter.writeBox(f),this.format._options.onMoov){const{data:p,start:m}=this.writer.stopTrackingWrites();this.format._options.onMoov(p,m)}}const r=this.trackDatas.filter(f=>f.currentChunk),i=R0(t,r),n=this.writer.getPos(),a=n+this.boxWriter.measureBox(i);let o=a+Io,c=1/0;for(const f of r){f.currentChunk.offset=o,f.currentChunk.moofOffset=n;for(const p of f.currentChunk.samples)o+=p.size;c=Math.min(c,f.currentChunk.startTimestamp)}const u=o-a,h=u>=2**32;if(h)for(const f of r)f.currentChunk.offset+=k0-Io;this.format._options.onMoof&&this.writer.startTrackingWrites();const l=R0(t,r);if(this.boxWriter.writeBox(l),this.format._options.onMoof){const{data:f,start:p}=this.writer.stopTrackingWrites();this.format._options.onMoof(f,p,c)}Y(this.writer.getPos()===a),this.format._options.onMdat&&this.writer.startTrackingWrites();const d=Un(h);d.size=u,this.boxWriter.writeBox(d),this.writer.seek(a+(h?k0:Io));for(const f of r)for(const p of f.currentChunk.samples)this.writer.write(p.data),p.data=null;if(this.format._options.onMdat){const{data:f,start:p}=this.writer.stopTrackingWrites();this.format._options.onMdat(f,p)}for(const f of r)f.finalizedChunks.push(f.currentChunk),this.finalizedChunks.push(f.currentChunk),f.currentChunk=null;e&&await this.writer.flush()}async registerSampleFastStartReserve(e,t){if(this.allTracksAreKnown()){if(!this.mdat){const r=As(this),n=this.boxWriter.measureBox(r)+this.computeSampleTableSizeUpperBound()+4096;Y(this.ftypSize!==null),this.writer.seek(this.ftypSize+n),this.format._options.onMdat&&this.writer.startTrackingWrites(),this.mdat=Un(!0),this.boxWriter.writeBox(this.mdat);for(const a of this.trackDatas){for(const o of a.sampleQueue)await this.addSampleToTrack(a,o);a.sampleQueue.length=0}}await this.addSampleToTrack(e,t)}else e.sampleQueue.push(t)}computeSampleTableSizeUpperBound(){Y(this.fastStart==="reserve");let e=0;for(const t of this.trackDatas){const r=t.track.metadata.maximumPacketCount;Y(r!==void 0),e+=8*Math.ceil(2/3*r),e+=4*r,e+=8*Math.ceil(2/3*r),e+=12*Math.ceil(2/3*r),e+=4*r,e+=8*r}return e}async onTrackClose(e){const t=await this.mutex.acquire();if(e.type==="subtitle"&&e.source._codec==="webvtt"){const r=this.trackDatas.find(i=>i.track===e);r&&await this.processWebVTTCues(r,1/0)}this.allTracksAreKnown()&&this.allTracksKnown.resolve(),this.isFragmented&&await this.interleaveSamples(),t()}async finalize(){const e=await this.mutex.acquire();this.allTracksKnown.resolve();for(const t of this.trackDatas)t.type==="subtitle"&&t.track.source._codec==="webvtt"&&await this.processWebVTTCues(t,1/0);if(this.isFragmented){await this.interleaveSamples(!0);for(const t of this.trackDatas)this.processTimestamps(t);await this.finalizeFragment(!1)}else for(const t of this.trackDatas)this.processTimestamps(t),await this.finalizeCurrentChunk(t);if(this.fastStart==="in-memory"){this.mdat=Un(!1);let t;for(let i=0;i<2;i++){const n=As(this),a=this.boxWriter.measureBox(n);t=this.boxWriter.measureBox(this.mdat);let o=this.writer.getPos()+a+t;for(const c of this.finalizedChunks){c.offset=o;for(const{data:u}of c.samples)Y(u),o+=u.byteLength,t+=u.byteLength}if(o<2**32)break;t>=2**32&&(this.mdat.largeSize=!0)}this.format._options.onMoov&&this.writer.startTrackingWrites();const r=As(this);if(this.boxWriter.writeBox(r),this.format._options.onMoov){const{data:i,start:n}=this.writer.stopTrackingWrites();this.format._options.onMoov(i,n)}this.format._options.onMdat&&this.writer.startTrackingWrites(),this.mdat.size=t,this.boxWriter.writeBox(this.mdat);for(const i of this.finalizedChunks)for(const n of i.samples)Y(n.data),this.writer.write(n.data),n.data=null;if(this.format._options.onMdat){const{data:i,start:n}=this.writer.stopTrackingWrites();this.format._options.onMdat(i,n)}}else if(this.isFragmented){const t=this.writer.getPos(),r=Yw(this.trackDatas);this.boxWriter.writeBox(r);const i=this.writer.getPos()-t;this.writer.seek(this.writer.getPos()-4),this.boxWriter.writeU32(i)}else{Y(this.mdat);const t=this.boxWriter.offsets.get(this.mdat);Y(t!==void 0);const r=this.writer.getPos()-t;if(this.mdat.size=r,this.mdat.largeSize=r>=2**32,this.boxWriter.patchBox(this.mdat),this.format._options.onMdat){const{data:n,start:a}=this.writer.stopTrackingWrites();this.format._options.onMdat(n,a)}const i=As(this);if(this.fastStart==="reserve"){Y(this.ftypSize!==null),this.writer.seek(this.ftypSize),this.format._options.onMoov&&this.writer.startTrackingWrites(),this.boxWriter.writeBox(i);const n=this.boxWriter.offsets.get(this.mdat)-this.writer.getPos();this.boxWriter.writeBox(uw(n))}else this.format._options.onMoov&&this.writer.startTrackingWrites(),this.boxWriter.writeBox(i);if(this.format._options.onMoov){const{data:n,start:a}=this.writer.stopTrackingWrites();this.format._options.onMoov(n,a)}}e()}}/*!
284
286
  * Copyright (c) 2025-present, Vanilagy and contributors
285
287
  *
286
288
  * This Source Code Form is subject to the terms of the Mozilla Public
287
289
  * License, v. 2.0. If a copy of the MPL was not distributed with this
288
290
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
289
- */class mn{getSupportedVideoCodecs(){return this.getSupportedCodecs().filter(e=>bt.includes(e))}getSupportedAudioCodecs(){return this.getSupportedCodecs().filter(e=>Mt.includes(e))}getSupportedSubtitleCodecs(){return this.getSupportedCodecs().filter(e=>Ci.includes(e))}_codecUnsupportedHint(e){return""}}class gn extends mn{constructor(e={}){if(!e||typeof e!="object")throw new TypeError("options must be an object.");if(e.fastStart!==void 0&&![!1,"in-memory","reserve","fragmented"].includes(e.fastStart))throw new TypeError("options.fastStart, when provided, must be false, 'in-memory', 'reserve', or 'fragmented'.");if(e.minimumFragmentDuration!==void 0&&(!Number.isFinite(e.minimumFragmentDuration)||e.minimumFragmentDuration<0))throw new TypeError("options.minimumFragmentDuration, when provided, must be a non-negative number.");if(e.onFtyp!==void 0&&typeof e.onFtyp!="function")throw new TypeError("options.onFtyp, when provided, must be a function.");if(e.onMoov!==void 0&&typeof e.onMoov!="function")throw new TypeError("options.onMoov, when provided, must be a function.");if(e.onMdat!==void 0&&typeof e.onMdat!="function")throw new TypeError("options.onMdat, when provided, must be a function.");if(e.onMoof!==void 0&&typeof e.onMoof!="function")throw new TypeError("options.onMoof, when provided, must be a function.");if(e.metadataFormat!==void 0&&!["mdir","mdta","udta","auto"].includes(e.metadataFormat))throw new TypeError("options.metadataFormat, when provided, must be either 'auto', 'mdir', 'mdta', or 'udta'.");super(),this._options=e}getSupportedTrackCounts(){return{video:{min:0,max:1/0},audio:{min:0,max:1/0},subtitle:{min:0,max:1/0},total:{min:1,max:2**32-1}}}get supportsVideoRotationMetadata(){return!0}_createMuxer(e){return new eh(e,this)}}class yn extends gn{constructor(e){super(e)}get _name(){return"MP4"}get fileExtension(){return".mp4"}get mimeType(){return"video/mp4"}getSupportedCodecs(){return[...bt,...zr,"pcm-s16","pcm-s16be","pcm-s24","pcm-s24be","pcm-s32","pcm-s32be","pcm-f32","pcm-f32be","pcm-f64","pcm-f64be",...Ci]}_codecUnsupportedHint(e){return new bn().getSupportedCodecs().includes(e)?" Switching to MOV will grant support for this codec.":""}}class bn extends gn{constructor(e){super(e)}get _name(){return"MOV"}get fileExtension(){return".mov"}get mimeType(){return"video/quicktime"}getSupportedCodecs(){return[...bt,...Mt]}_codecUnsupportedHint(e){return new yn().getSupportedCodecs().includes(e)?" Switching to MP4 will grant support for this codec.":""}}/*!
291
+ */class H0{getSupportedVideoCodecs(){return this.getSupportedCodecs().filter(e=>li.includes(e))}getSupportedAudioCodecs(){return this.getSupportedCodecs().filter(e=>Di.includes(e))}getSupportedSubtitleCodecs(){return this.getSupportedCodecs().filter(e=>zn.includes(e))}_codecUnsupportedHint(e){return""}}class V0 extends H0{constructor(e={}){if(!e||typeof e!="object")throw new TypeError("options must be an object.");if(e.fastStart!==void 0&&![!1,"in-memory","reserve","fragmented"].includes(e.fastStart))throw new TypeError("options.fastStart, when provided, must be false, 'in-memory', 'reserve', or 'fragmented'.");if(e.minimumFragmentDuration!==void 0&&(!Number.isFinite(e.minimumFragmentDuration)||e.minimumFragmentDuration<0))throw new TypeError("options.minimumFragmentDuration, when provided, must be a non-negative number.");if(e.onFtyp!==void 0&&typeof e.onFtyp!="function")throw new TypeError("options.onFtyp, when provided, must be a function.");if(e.onMoov!==void 0&&typeof e.onMoov!="function")throw new TypeError("options.onMoov, when provided, must be a function.");if(e.onMdat!==void 0&&typeof e.onMdat!="function")throw new TypeError("options.onMdat, when provided, must be a function.");if(e.onMoof!==void 0&&typeof e.onMoof!="function")throw new TypeError("options.onMoof, when provided, must be a function.");if(e.metadataFormat!==void 0&&!["mdir","mdta","udta","auto"].includes(e.metadataFormat))throw new TypeError("options.metadataFormat, when provided, must be either 'auto', 'mdir', 'mdta', or 'udta'.");super(),this._options=e}getSupportedTrackCounts(){return{video:{min:0,max:1/0},audio:{min:0,max:1/0},subtitle:{min:0,max:1/0},total:{min:1,max:2**32-1}}}get supportsVideoRotationMetadata(){return!0}_createMuxer(e){return new m2(e,this)}}class j0 extends V0{constructor(e){super(e)}get _name(){return"MP4"}get fileExtension(){return".mp4"}get mimeType(){return"video/mp4"}getSupportedCodecs(){return[...li,...f0,"pcm-s16","pcm-s16be","pcm-s24","pcm-s24be","pcm-s32","pcm-s32be","pcm-f32","pcm-f32be","pcm-f64","pcm-f64be",...zn]}_codecUnsupportedHint(e){return new W0().getSupportedCodecs().includes(e)?" Switching to MOV will grant support for this codec.":""}}class W0 extends V0{constructor(e){super(e)}get _name(){return"MOV"}get fileExtension(){return".mov"}get mimeType(){return"video/quicktime"}getSupportedCodecs(){return[...li,...Di]}_codecUnsupportedHint(e){return new j0().getSupportedCodecs().includes(e)?" Switching to MP4 will grant support for this codec.":""}}/*!
290
292
  * Copyright (c) 2025-present, Vanilagy and contributors
291
293
  *
292
294
  * This Source Code Form is subject to the terms of the Mozilla Public
293
295
  * License, v. 2.0. If a copy of the MPL was not distributed with this
294
296
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
295
- */const th=s=>{if(!s||typeof s!="object")throw new TypeError("Encoding config must be an object.");if(!bt.includes(s.codec))throw new TypeError(`Invalid video codec '${s.codec}'. Must be one of: ${bt.join(", ")}.`);if(!(s.bitrate instanceof Si)&&(!Number.isInteger(s.bitrate)||s.bitrate<=0))throw new TypeError("config.bitrate must be a positive integer or a quality.");if(s.keyFrameInterval!==void 0&&(!Number.isFinite(s.keyFrameInterval)||s.keyFrameInterval<0))throw new TypeError("config.keyFrameInterval, when provided, must be a non-negative number.");if(s.sizeChangeBehavior!==void 0&&!["deny","passThrough","fill","contain","cover"].includes(s.sizeChangeBehavior))throw new TypeError("config.sizeChangeBehavior, when provided, must be 'deny', 'passThrough', 'fill', 'contain' or 'cover'.");if(s.onEncodedPacket!==void 0&&typeof s.onEncodedPacket!="function")throw new TypeError("config.onEncodedChunk, when provided, must be a function.");if(s.onEncoderConfig!==void 0&&typeof s.onEncoderConfig!="function")throw new TypeError("config.onEncoderConfig, when provided, must be a function.");ih(s.codec,s)},ih=(s,e)=>{if(!e||typeof e!="object")throw new TypeError("Encoding options must be an object.");if(e.alpha!==void 0&&!["discard","keep"].includes(e.alpha))throw new TypeError("options.alpha, when provided, must be 'discard' or 'keep'.");if(e.bitrateMode!==void 0&&!["constant","variable"].includes(e.bitrateMode))throw new TypeError("bitrateMode, when provided, must be 'constant' or 'variable'.");if(e.latencyMode!==void 0&&!["quality","realtime"].includes(e.latencyMode))throw new TypeError("latencyMode, when provided, must be 'quality' or 'realtime'.");if(e.fullCodecString!==void 0&&typeof e.fullCodecString!="string")throw new TypeError("fullCodecString, when provided, must be a string.");if(e.fullCodecString!==void 0&&Wr(e.fullCodecString)!==s)throw new TypeError(`fullCodecString, when provided, must be a string that matches the specified codec (${s}).`);if(e.hardwareAcceleration!==void 0&&!["no-preference","prefer-hardware","prefer-software"].includes(e.hardwareAcceleration))throw new TypeError("hardwareAcceleration, when provided, must be 'no-preference', 'prefer-hardware' or 'prefer-software'.");if(e.scalabilityMode!==void 0&&typeof e.scalabilityMode!="string")throw new TypeError("scalabilityMode, when provided, must be a string.");if(e.contentHint!==void 0&&typeof e.contentHint!="string")throw new TypeError("contentHint, when provided, must be a string.")},sh=s=>{const e=s.bitrate instanceof Si?s.bitrate._toVideoBitrate(s.codec,s.width,s.height):s.bitrate;return{codec:s.fullCodecString??hl(s.codec,s.width,s.height,e),width:s.width,height:s.height,bitrate:e,bitrateMode:s.bitrateMode,alpha:s.alpha??"discard",framerate:s.framerate,latencyMode:s.latencyMode,hardwareAcceleration:s.hardwareAcceleration,scalabilityMode:s.scalabilityMode,contentHint:s.contentHint,...fl(s.codec)}},rh=s=>{if(!s||typeof s!="object")throw new TypeError("Encoding config must be an object.");if(!Mt.includes(s.codec))throw new TypeError(`Invalid audio codec '${s.codec}'. Must be one of: ${Mt.join(", ")}.`);if(s.bitrate===void 0&&(!Ne.includes(s.codec)||s.codec==="flac"))throw new TypeError("config.bitrate must be provided for compressed audio codecs.");if(s.bitrate!==void 0&&!(s.bitrate instanceof Si)&&(!Number.isInteger(s.bitrate)||s.bitrate<=0))throw new TypeError("config.bitrate, when provided, must be a positive integer or a quality.");if(s.onEncodedPacket!==void 0&&typeof s.onEncodedPacket!="function")throw new TypeError("config.onEncodedChunk, when provided, must be a function.");if(s.onEncoderConfig!==void 0&&typeof s.onEncoderConfig!="function")throw new TypeError("config.onEncoderConfig, when provided, must be a function.");nh(s.codec,s)},nh=(s,e)=>{if(!e||typeof e!="object")throw new TypeError("Encoding options must be an object.");if(e.bitrateMode!==void 0&&!["constant","variable"].includes(e.bitrateMode))throw new TypeError("bitrateMode, when provided, must be 'constant' or 'variable'.");if(e.fullCodecString!==void 0&&typeof e.fullCodecString!="string")throw new TypeError("fullCodecString, when provided, must be a string.");if(e.fullCodecString!==void 0&&Wr(e.fullCodecString)!==s)throw new TypeError(`fullCodecString, when provided, must be a string that matches the specified codec (${s}).`)},ah=s=>{const e=s.bitrate instanceof Si?s.bitrate._toAudioBitrate(s.codec):s.bitrate;return{codec:s.fullCodecString??dl(s.codec,s.numberOfChannels,s.sampleRate),numberOfChannels:s.numberOfChannels,sampleRate:s.sampleRate,bitrate:e,bitrateMode:s.bitrateMode,...pl(s.codec)}};class Si{constructor(e){this._factor=e}_toVideoBitrate(e,t,i){const r=t*i,n={avc:1,hevc:.6,vp9:.6,av1:.4,vp8:1.2},o=1920*1080,a=3e6,p=Math.pow(r/o,.95),l=a*p*n[e]*this._factor;return Math.ceil(l/1e3)*1e3}_toAudioBitrate(e){if(Ne.includes(e)||e==="flac")return;const i={aac:128e3,opus:64e3,mp3:16e4,vorbis:64e3}[e];if(!i)throw new Error(`Unhandled codec: ${e}`);let r=i*this._factor;return e==="aac"?r=[96e3,128e3,16e4,192e3].reduce((o,a)=>Math.abs(a-r)<Math.abs(o-r)?a:o):e==="opus"||e==="vorbis"?r=Math.max(6e3,r):e==="mp3"&&(r=[8e3,16e3,24e3,32e3,4e4,48e3,64e3,8e4,96e3,112e3,128e3,16e4,192e3,224e3,256e3,32e4].reduce((o,a)=>Math.abs(a-r)<Math.abs(o-r)?a:o)),Math.round(r/1e3)*1e3}}/*!
297
+ */const g2=s=>{if(!s||typeof s!="object")throw new TypeError("Encoding config must be an object.");if(!li.includes(s.codec))throw new TypeError(`Invalid video codec '${s.codec}'. Must be one of: ${li.join(", ")}.`);if(!(s.bitrate instanceof Hn)&&(!Number.isInteger(s.bitrate)||s.bitrate<=0))throw new TypeError("config.bitrate must be a positive integer or a quality.");if(s.keyFrameInterval!==void 0&&(!Number.isFinite(s.keyFrameInterval)||s.keyFrameInterval<0))throw new TypeError("config.keyFrameInterval, when provided, must be a non-negative number.");if(s.sizeChangeBehavior!==void 0&&!["deny","passThrough","fill","contain","cover"].includes(s.sizeChangeBehavior))throw new TypeError("config.sizeChangeBehavior, when provided, must be 'deny', 'passThrough', 'fill', 'contain' or 'cover'.");if(s.onEncodedPacket!==void 0&&typeof s.onEncodedPacket!="function")throw new TypeError("config.onEncodedChunk, when provided, must be a function.");if(s.onEncoderConfig!==void 0&&typeof s.onEncoderConfig!="function")throw new TypeError("config.onEncoderConfig, when provided, must be a function.");y2(s.codec,s)},y2=(s,e)=>{if(!e||typeof e!="object")throw new TypeError("Encoding options must be an object.");if(e.alpha!==void 0&&!["discard","keep"].includes(e.alpha))throw new TypeError("options.alpha, when provided, must be 'discard' or 'keep'.");if(e.bitrateMode!==void 0&&!["constant","variable"].includes(e.bitrateMode))throw new TypeError("bitrateMode, when provided, must be 'constant' or 'variable'.");if(e.latencyMode!==void 0&&!["quality","realtime"].includes(e.latencyMode))throw new TypeError("latencyMode, when provided, must be 'quality' or 'realtime'.");if(e.fullCodecString!==void 0&&typeof e.fullCodecString!="string")throw new TypeError("fullCodecString, when provided, must be a string.");if(e.fullCodecString!==void 0&&v0(e.fullCodecString)!==s)throw new TypeError(`fullCodecString, when provided, must be a string that matches the specified codec (${s}).`);if(e.hardwareAcceleration!==void 0&&!["no-preference","prefer-hardware","prefer-software"].includes(e.hardwareAcceleration))throw new TypeError("hardwareAcceleration, when provided, must be 'no-preference', 'prefer-hardware' or 'prefer-software'.");if(e.scalabilityMode!==void 0&&typeof e.scalabilityMode!="string")throw new TypeError("scalabilityMode, when provided, must be a string.");if(e.contentHint!==void 0&&typeof e.contentHint!="string")throw new TypeError("contentHint, when provided, must be a string.")},b2=s=>{const e=s.bitrate instanceof Hn?s.bitrate._toVideoBitrate(s.codec,s.width,s.height):s.bitrate;return{codec:s.fullCodecString??Tv(s.codec,s.width,s.height,e),width:s.width,height:s.height,bitrate:e,bitrateMode:s.bitrateMode,alpha:s.alpha??"discard",framerate:s.framerate,latencyMode:s.latencyMode,hardwareAcceleration:s.hardwareAcceleration,scalabilityMode:s.scalabilityMode,contentHint:s.contentHint,...Iv(s.codec)}},v2=s=>{if(!s||typeof s!="object")throw new TypeError("Encoding config must be an object.");if(!Di.includes(s.codec))throw new TypeError(`Invalid audio codec '${s.codec}'. Must be one of: ${Di.join(", ")}.`);if(s.bitrate===void 0&&(!nr.includes(s.codec)||s.codec==="flac"))throw new TypeError("config.bitrate must be provided for compressed audio codecs.");if(s.bitrate!==void 0&&!(s.bitrate instanceof Hn)&&(!Number.isInteger(s.bitrate)||s.bitrate<=0))throw new TypeError("config.bitrate, when provided, must be a positive integer or a quality.");if(s.onEncodedPacket!==void 0&&typeof s.onEncodedPacket!="function")throw new TypeError("config.onEncodedChunk, when provided, must be a function.");if(s.onEncoderConfig!==void 0&&typeof s.onEncoderConfig!="function")throw new TypeError("config.onEncoderConfig, when provided, must be a function.");w2(s.codec,s)},w2=(s,e)=>{if(!e||typeof e!="object")throw new TypeError("Encoding options must be an object.");if(e.bitrateMode!==void 0&&!["constant","variable"].includes(e.bitrateMode))throw new TypeError("bitrateMode, when provided, must be 'constant' or 'variable'.");if(e.fullCodecString!==void 0&&typeof e.fullCodecString!="string")throw new TypeError("fullCodecString, when provided, must be a string.");if(e.fullCodecString!==void 0&&v0(e.fullCodecString)!==s)throw new TypeError(`fullCodecString, when provided, must be a string that matches the specified codec (${s}).`)},x2=s=>{const e=s.bitrate instanceof Hn?s.bitrate._toAudioBitrate(s.codec):s.bitrate;return{codec:s.fullCodecString??Av(s.codec,s.numberOfChannels,s.sampleRate),numberOfChannels:s.numberOfChannels,sampleRate:s.sampleRate,bitrate:e,bitrateMode:s.bitrateMode,...Pv(s.codec)}};class Hn{constructor(e){this._factor=e}_toVideoBitrate(e,t,r){const i=t*r,n={avc:1,hevc:.6,vp9:.6,av1:.4,vp8:1.2},a=1920*1080,o=3e6,c=Math.pow(i/a,.95),l=o*c*n[e]*this._factor;return Math.ceil(l/1e3)*1e3}_toAudioBitrate(e){if(nr.includes(e)||e==="flac")return;const r={aac:128e3,opus:64e3,mp3:16e4,vorbis:64e3}[e];if(!r)throw new Error(`Unhandled codec: ${e}`);let i=r*this._factor;return e==="aac"?i=[96e3,128e3,16e4,192e3].reduce((a,o)=>Math.abs(o-i)<Math.abs(a-i)?o:a):e==="opus"||e==="vorbis"?i=Math.max(6e3,i):e==="mp3"&&(i=[8e3,16e3,24e3,32e3,4e4,48e3,64e3,8e4,96e3,112e3,128e3,16e4,192e3,224e3,256e3,32e4].reduce((a,o)=>Math.abs(o-i)<Math.abs(a-i)?o:a)),Math.round(i/1e3)*1e3}}/*!
296
298
  * Copyright (c) 2025-present, Vanilagy and contributors
297
299
  *
298
300
  * This Source Code Form is subject to the terms of the Mozilla Public
299
301
  * License, v. 2.0. If a copy of the MPL was not distributed with this
300
302
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
301
- */class xs{constructor(){this._connectedTrack=null,this._closingPromise=null,this._closed=!1,this._timestampOffset=0}_ensureValidAdd(){if(!this._connectedTrack)throw new Error("Source is not connected to an output track.");if(this._connectedTrack.output.state==="canceled")throw new Error("Output has been canceled.");if(this._connectedTrack.output.state==="finalizing"||this._connectedTrack.output.state==="finalized")throw new Error("Output has been finalized.");if(this._connectedTrack.output.state==="pending")throw new Error("Output has not started.");if(this._closed)throw new Error("Source is closed.")}async _start(){}async _flushAndClose(e){}close(){if(this._closingPromise)return;const e=this._connectedTrack;if(!e)throw new Error("Cannot call close without connecting the source to an output track.");if(e.output.state==="pending")throw new Error("Cannot call close before output has been started.");this._closingPromise=(async()=>{await this._flushAndClose(!1),this._closed=!0,!(e.output.state==="finalizing"||e.output.state==="finalized")&&e.output._muxer.onTrackClose(e)})()}async _flushOrWaitForOngoingClose(e){return this._closingPromise?this._closingPromise:this._flushAndClose(e)}}class vn extends xs{constructor(e){if(super(),this._connectedTrack=null,!bt.includes(e))throw new TypeError(`Invalid video codec '${e}'. Must be one of: ${bt.join(", ")}.`);this._codec=e}}class oh{constructor(e,t){this.source=e,this.encodingConfig=t,this.ensureEncoderPromise=null,this.encoderInitialized=!1,this.encoder=null,this.muxer=null,this.lastMultipleOfKeyFrameInterval=-1,this.codedWidth=null,this.codedHeight=null,this.resizeCanvas=null,this.customEncoder=null,this.customEncoderCallSerializer=new Br,this.customEncoderQueueSize=0,this.alphaEncoder=null,this.splitter=null,this.splitterCreationFailed=!1,this.alphaFrameQueue=[],this.error=null,this.errorNeedsNewStack=!0}async add(e,t,i){try{if(this.checkForEncoderError(),this.source._ensureValidAdd(),this.codedWidth!==null&&this.codedHeight!==null){if(e.codedWidth!==this.codedWidth||e.codedHeight!==this.codedHeight){const a=this.encodingConfig.sizeChangeBehavior??"deny";if(a!=="passThrough"){if(a==="deny")throw new Error(`Video sample size must remain constant. Expected ${this.codedWidth}x${this.codedHeight}, got ${e.codedWidth}x${e.codedHeight}. To allow the sample size to change over time, set \`sizeChangeBehavior\` to a value other than 'strict' in the encoding options.`);{let p=!1;this.resizeCanvas||(typeof document<"u"?(this.resizeCanvas=document.createElement("canvas"),this.resizeCanvas.width=this.codedWidth,this.resizeCanvas.height=this.codedHeight):this.resizeCanvas=new OffscreenCanvas(this.codedWidth,this.codedHeight),p=!0);const m=this.resizeCanvas.getContext("2d",{alpha:ls()});$(m),p||(ls()?(m.fillStyle="black",m.fillRect(0,0,this.codedWidth,this.codedHeight)):m.clearRect(0,0,this.codedWidth,this.codedHeight)),e.drawWithFit(m,{fit:a}),t&&e.close(),e=new vt(this.resizeCanvas,{timestamp:e.timestamp,duration:e.duration,rotation:e.rotation}),t=!0}}}}else this.codedWidth=e.codedWidth,this.codedHeight=e.codedHeight;this.encoderInitialized||(this.ensureEncoderPromise||this.ensureEncoder(e),this.encoderInitialized||await this.ensureEncoderPromise),$(this.encoderInitialized);const r=this.encodingConfig.keyFrameInterval??5,n=Math.floor(e.timestamp/r),o={...i,keyFrame:i?.keyFrame||r===0||n!==this.lastMultipleOfKeyFrameInterval};if(this.lastMultipleOfKeyFrameInterval=n,this.customEncoder){this.customEncoderQueueSize++;const a=e.clone(),p=this.customEncoderCallSerializer.call(()=>this.customEncoder.encode(a,o)).then(()=>this.customEncoderQueueSize--).catch(m=>this.error??=m).finally(()=>{a.close()});this.customEncoderQueueSize>=4&&await p}else{$(this.encoder);const a=e.toVideoFrame();if(!this.alphaEncoder)this.encoder.encode(a,o),a.close();else if(!!a.format&&!a.format.includes("A")||this.splitterCreationFailed)this.alphaFrameQueue.push(null),this.encoder.encode(a,o),a.close();else{const m=a.displayWidth,d=a.displayHeight;if(!this.splitter)try{this.splitter=new lh(m,d)}catch(l){console.error("Due to an error, only color data will be encoded.",l),this.splitterCreationFailed=!0,this.alphaFrameQueue.push(null),this.encoder.encode(a,o),a.close()}if(this.splitter){const l=this.splitter.extractColor(a),c=this.splitter.extractAlpha(a);this.alphaFrameQueue.push(c),this.encoder.encode(l,o),l.close(),a.close()}}t&&e.close(),this.encoder.encodeQueueSize>=4&&await new Promise(p=>this.encoder.addEventListener("dequeue",p,{once:!0}))}await this.muxer.mutex.currentPromise}finally{t&&e.close()}}ensureEncoder(e){const t=new Error;this.ensureEncoderPromise=(async()=>{const i=sh({width:e.codedWidth,height:e.codedHeight,...this.encodingConfig,framerate:this.source._connectedTrack?.metadata.frameRate});this.encodingConfig.onEncoderConfig?.(i);const r=$l.find(n=>n.supports(this.encodingConfig.codec,i));if(r)this.customEncoder=new r,this.customEncoder.codec=this.encodingConfig.codec,this.customEncoder.config=i,this.customEncoder.onPacket=(n,o)=>{if(!(n instanceof ct))throw new TypeError("The first argument passed to onPacket must be an EncodedPacket.");if(o!==void 0&&(!o||typeof o!="object"))throw new TypeError("The second argument passed to onPacket must be an object or undefined.");this.encodingConfig.onEncodedPacket?.(n,o),this.muxer.addEncodedVideoPacket(this.source._connectedTrack,n,o).catch(a=>{this.error??=a,this.errorNeedsNewStack=!1})},await this.customEncoder.init();else{if(typeof VideoEncoder>"u")throw new Error("VideoEncoder is not supported by this browser.");if(i.alpha="discard",this.encodingConfig.alpha==="keep"&&(i.latencyMode="quality"),(i.width%2===1||i.height%2===1)&&(this.encodingConfig.codec==="avc"||this.encodingConfig.codec==="hevc"))throw new Error(`The dimensions ${i.width}x${i.height} are not supported for codec '${this.encodingConfig.codec}'; both width and height must be even numbers. Make sure to round your dimensions to the nearest even number.`);if(!(await VideoEncoder.isConfigSupported(i)).supported)throw new Error(`This specific encoder configuration (${i.codec}, ${i.bitrate} bps, ${i.width}x${i.height}, hardware acceleration: ${i.hardwareAcceleration??"no-preference"}) is not supported by this browser. Consider using another codec or changing your video parameters.`);const a=[],p=[];let m=0,d=0;const l=(c,u,h)=>{const f={};if(u){const g=new Uint8Array(u.byteLength);u.copyTo(g),f.alpha=g}const b=ct.fromEncodedChunk(c,f);this.encodingConfig.onEncodedPacket?.(b,h),this.muxer.addEncodedVideoPacket(this.source._connectedTrack,b,h).catch(g=>{this.error??=g,this.errorNeedsNewStack=!1})};this.encoder=new VideoEncoder({output:(c,u)=>{if(!this.alphaEncoder){l(c,null,u);return}const h=this.alphaFrameQueue.shift();$(h!==void 0),h?(this.alphaEncoder.encode(h,{keyFrame:c.type==="key"}),d++,h.close(),a.push({chunk:c,meta:u})):d===0?l(c,null,u):(p.push(m+d),a.push({chunk:c,meta:u}))},error:c=>{c.stack=t.stack,this.error??=c}}),this.encoder.configure(i),this.encodingConfig.alpha==="keep"&&(this.alphaEncoder=new VideoEncoder({output:(c,u)=>{d--;const h=a.shift();for($(h!==void 0),l(h.chunk,c,h.meta),m++;p.length>0&&p[0]===m;){p.shift();const f=a.shift();$(f!==void 0),l(f.chunk,null,f.meta)}},error:c=>{c.stack=t.stack,this.error??=c}}),this.alphaEncoder.configure(i))}$(this.source._connectedTrack),this.muxer=this.source._connectedTrack.output._muxer,this.encoderInitialized=!0})()}async flushAndClose(e){e||this.checkForEncoderError(),this.customEncoder?(e||this.customEncoderCallSerializer.call(()=>this.customEncoder.flush()),await this.customEncoderCallSerializer.call(()=>this.customEncoder.close())):this.encoder&&(e||(await this.encoder.flush(),await this.alphaEncoder?.flush()),this.encoder.state!=="closed"&&this.encoder.close(),this.alphaEncoder&&this.alphaEncoder.state!=="closed"&&this.alphaEncoder.close(),this.alphaFrameQueue.forEach(t=>t?.close()),this.splitter?.close()),e||this.checkForEncoderError()}getQueueSize(){return this.customEncoder?this.customEncoderQueueSize:this.encoder?.encodeQueueSize??0}checkForEncoderError(){if(this.error)throw this.errorNeedsNewStack&&(this.error.stack=new Error().stack),this.error}}class lh{constructor(e,t){this.lastFrame=null,typeof OffscreenCanvas<"u"?this.canvas=new OffscreenCanvas(e,t):(this.canvas=document.createElement("canvas"),this.canvas.width=e,this.canvas.height=t);const i=this.canvas.getContext("webgl2",{alpha:!0});if(!i)throw new Error("Couldn't acquire WebGL 2 context.");this.gl=i,this.colorProgram=this.createColorProgram(),this.alphaProgram=this.createAlphaProgram(),this.vao=this.createVAO(),this.sourceTexture=this.createTexture(),this.alphaResolutionLocation=this.gl.getUniformLocation(this.alphaProgram,"u_resolution"),this.gl.useProgram(this.colorProgram),this.gl.uniform1i(this.gl.getUniformLocation(this.colorProgram,"u_sourceTexture"),0),this.gl.useProgram(this.alphaProgram),this.gl.uniform1i(this.gl.getUniformLocation(this.alphaProgram,"u_sourceTexture"),0)}createVertexShader(){return this.createShader(this.gl.VERTEX_SHADER,`#version 300 es
303
+ */class zo{constructor(){this._connectedTrack=null,this._closingPromise=null,this._closed=!1,this._timestampOffset=0}_ensureValidAdd(){if(!this._connectedTrack)throw new Error("Source is not connected to an output track.");if(this._connectedTrack.output.state==="canceled")throw new Error("Output has been canceled.");if(this._connectedTrack.output.state==="finalizing"||this._connectedTrack.output.state==="finalized")throw new Error("Output has been finalized.");if(this._connectedTrack.output.state==="pending")throw new Error("Output has not started.");if(this._closed)throw new Error("Source is closed.")}async _start(){}async _flushAndClose(e){}close(){if(this._closingPromise)return;const e=this._connectedTrack;if(!e)throw new Error("Cannot call close without connecting the source to an output track.");if(e.output.state==="pending")throw new Error("Cannot call close before output has been started.");this._closingPromise=(async()=>{await this._flushAndClose(!1),this._closed=!0,!(e.output.state==="finalizing"||e.output.state==="finalized")&&e.output._muxer.onTrackClose(e)})()}async _flushOrWaitForOngoingClose(e){return this._closingPromise?this._closingPromise:this._flushAndClose(e)}}class G0 extends zo{constructor(e){if(super(),this._connectedTrack=null,!li.includes(e))throw new TypeError(`Invalid video codec '${e}'. Must be one of: ${li.join(", ")}.`);this._codec=e}}class C2{constructor(e,t){this.source=e,this.encodingConfig=t,this.ensureEncoderPromise=null,this.encoderInitialized=!1,this.encoder=null,this.muxer=null,this.lastMultipleOfKeyFrameInterval=-1,this.codedWidth=null,this.codedHeight=null,this.resizeCanvas=null,this.customEncoder=null,this.customEncoderCallSerializer=new u0,this.customEncoderQueueSize=0,this.alphaEncoder=null,this.splitter=null,this.splitterCreationFailed=!1,this.alphaFrameQueue=[],this.error=null,this.errorNeedsNewStack=!0}async add(e,t,r){try{if(this.checkForEncoderError(),this.source._ensureValidAdd(),this.codedWidth!==null&&this.codedHeight!==null){if(e.codedWidth!==this.codedWidth||e.codedHeight!==this.codedHeight){const o=this.encodingConfig.sizeChangeBehavior??"deny";if(o!=="passThrough"){if(o==="deny")throw new Error(`Video sample size must remain constant. Expected ${this.codedWidth}x${this.codedHeight}, got ${e.codedWidth}x${e.codedHeight}. To allow the sample size to change over time, set \`sizeChangeBehavior\` to a value other than 'strict' in the encoding options.`);{let c=!1;this.resizeCanvas||(typeof document<"u"?(this.resizeCanvas=document.createElement("canvas"),this.resizeCanvas.width=this.codedWidth,this.resizeCanvas.height=this.codedHeight):this.resizeCanvas=new OffscreenCanvas(this.codedWidth,this.codedHeight),c=!0);const u=this.resizeCanvas.getContext("2d",{alpha:So()});Y(u),c||(So()?(u.fillStyle="black",u.fillRect(0,0,this.codedWidth,this.codedHeight)):u.clearRect(0,0,this.codedWidth,this.codedHeight)),e.drawWithFit(u,{fit:o}),t&&e.close(),e=new ci(this.resizeCanvas,{timestamp:e.timestamp,duration:e.duration,rotation:e.rotation}),t=!0}}}}else this.codedWidth=e.codedWidth,this.codedHeight=e.codedHeight;this.encoderInitialized||(this.ensureEncoderPromise||this.ensureEncoder(e),this.encoderInitialized||await this.ensureEncoderPromise),Y(this.encoderInitialized);const i=this.encodingConfig.keyFrameInterval??5,n=Math.floor(e.timestamp/i),a={...r,keyFrame:r?.keyFrame||i===0||n!==this.lastMultipleOfKeyFrameInterval};if(this.lastMultipleOfKeyFrameInterval=n,this.customEncoder){this.customEncoderQueueSize++;const o=e.clone(),c=this.customEncoderCallSerializer.call(()=>this.customEncoder.encode(o,a)).then(()=>this.customEncoderQueueSize--).catch(u=>this.error??=u).finally(()=>{o.close()});this.customEncoderQueueSize>=4&&await c}else{Y(this.encoder);const o=e.toVideoFrame();if(!this.alphaEncoder)this.encoder.encode(o,a),o.close();else if(!!o.format&&!o.format.includes("A")||this.splitterCreationFailed)this.alphaFrameQueue.push(null),this.encoder.encode(o,a),o.close();else{const u=o.displayWidth,h=o.displayHeight;if(!this.splitter)try{this.splitter=new k2(u,h)}catch(l){console.error("Due to an error, only color data will be encoded.",l),this.splitterCreationFailed=!0,this.alphaFrameQueue.push(null),this.encoder.encode(o,a),o.close()}if(this.splitter){const l=this.splitter.extractColor(o),d=this.splitter.extractAlpha(o);this.alphaFrameQueue.push(d),this.encoder.encode(l,a),l.close(),o.close()}}t&&e.close(),this.encoder.encodeQueueSize>=4&&await new Promise(c=>this.encoder.addEventListener("dequeue",c,{once:!0}))}await this.muxer.mutex.currentPromise}finally{t&&e.close()}}ensureEncoder(e){const t=new Error;this.ensureEncoderPromise=(async()=>{const r=b2({width:e.codedWidth,height:e.codedHeight,...this.encodingConfig,framerate:this.source._connectedTrack?.metadata.frameRate});this.encodingConfig.onEncoderConfig?.(r);const i=Qv.find(n=>n.supports(this.encodingConfig.codec,r));if(i)this.customEncoder=new i,this.customEncoder.codec=this.encodingConfig.codec,this.customEncoder.config=r,this.customEncoder.onPacket=(n,a)=>{if(!(n instanceof Hr))throw new TypeError("The first argument passed to onPacket must be an EncodedPacket.");if(a!==void 0&&(!a||typeof a!="object"))throw new TypeError("The second argument passed to onPacket must be an object or undefined.");this.encodingConfig.onEncodedPacket?.(n,a),this.muxer.addEncodedVideoPacket(this.source._connectedTrack,n,a).catch(o=>{this.error??=o,this.errorNeedsNewStack=!1})},await this.customEncoder.init();else{if(typeof VideoEncoder>"u")throw new Error("VideoEncoder is not supported by this browser.");if(r.alpha="discard",this.encodingConfig.alpha==="keep"&&(r.latencyMode="quality"),(r.width%2===1||r.height%2===1)&&(this.encodingConfig.codec==="avc"||this.encodingConfig.codec==="hevc"))throw new Error(`The dimensions ${r.width}x${r.height} are not supported for codec '${this.encodingConfig.codec}'; both width and height must be even numbers. Make sure to round your dimensions to the nearest even number.`);if(!(await VideoEncoder.isConfigSupported(r)).supported)throw new Error(`This specific encoder configuration (${r.codec}, ${r.bitrate} bps, ${r.width}x${r.height}, hardware acceleration: ${r.hardwareAcceleration??"no-preference"}) is not supported by this browser. Consider using another codec or changing your video parameters.`);const o=[],c=[];let u=0,h=0;const l=(d,f,p)=>{const m={};if(f){const g=new Uint8Array(f.byteLength);f.copyTo(g),m.alpha=g}const v=Hr.fromEncodedChunk(d,m);this.encodingConfig.onEncodedPacket?.(v,p),this.muxer.addEncodedVideoPacket(this.source._connectedTrack,v,p).catch(g=>{this.error??=g,this.errorNeedsNewStack=!1})};this.encoder=new VideoEncoder({output:(d,f)=>{if(!this.alphaEncoder){l(d,null,f);return}const p=this.alphaFrameQueue.shift();Y(p!==void 0),p?(this.alphaEncoder.encode(p,{keyFrame:d.type==="key"}),h++,p.close(),o.push({chunk:d,meta:f})):h===0?l(d,null,f):(c.push(u+h),o.push({chunk:d,meta:f}))},error:d=>{d.stack=t.stack,this.error??=d}}),this.encoder.configure(r),this.encodingConfig.alpha==="keep"&&(this.alphaEncoder=new VideoEncoder({output:(d,f)=>{h--;const p=o.shift();for(Y(p!==void 0),l(p.chunk,d,p.meta),u++;c.length>0&&c[0]===u;){c.shift();const m=o.shift();Y(m!==void 0),l(m.chunk,null,m.meta)}},error:d=>{d.stack=t.stack,this.error??=d}}),this.alphaEncoder.configure(r))}Y(this.source._connectedTrack),this.muxer=this.source._connectedTrack.output._muxer,this.encoderInitialized=!0})()}async flushAndClose(e){e||this.checkForEncoderError(),this.customEncoder?(e||this.customEncoderCallSerializer.call(()=>this.customEncoder.flush()),await this.customEncoderCallSerializer.call(()=>this.customEncoder.close())):this.encoder&&(e||(await this.encoder.flush(),await this.alphaEncoder?.flush()),this.encoder.state!=="closed"&&this.encoder.close(),this.alphaEncoder&&this.alphaEncoder.state!=="closed"&&this.alphaEncoder.close(),this.alphaFrameQueue.forEach(t=>t?.close()),this.splitter?.close()),e||this.checkForEncoderError()}getQueueSize(){return this.customEncoder?this.customEncoderQueueSize:this.encoder?.encodeQueueSize??0}checkForEncoderError(){if(this.error)throw this.errorNeedsNewStack&&(this.error.stack=new Error().stack),this.error}}class k2{constructor(e,t){this.lastFrame=null,typeof OffscreenCanvas<"u"?this.canvas=new OffscreenCanvas(e,t):(this.canvas=document.createElement("canvas"),this.canvas.width=e,this.canvas.height=t);const r=this.canvas.getContext("webgl2",{alpha:!0});if(!r)throw new Error("Couldn't acquire WebGL 2 context.");this.gl=r,this.colorProgram=this.createColorProgram(),this.alphaProgram=this.createAlphaProgram(),this.vao=this.createVAO(),this.sourceTexture=this.createTexture(),this.alphaResolutionLocation=this.gl.getUniformLocation(this.alphaProgram,"u_resolution"),this.gl.useProgram(this.colorProgram),this.gl.uniform1i(this.gl.getUniformLocation(this.colorProgram,"u_sourceTexture"),0),this.gl.useProgram(this.alphaProgram),this.gl.uniform1i(this.gl.getUniformLocation(this.alphaProgram,"u_sourceTexture"),0)}createVertexShader(){return this.createShader(this.gl.VERTEX_SHADER,`#version 300 es
302
304
  in vec2 a_position;
303
305
  in vec2 a_texCoord;
304
306
  out vec2 v_texCoord;
@@ -318,7 +320,7 @@ const DOUBLE_PI: f32 = 3.14159265358979323846264 * 2.;`,Qn=Object.defineProperty
318
320
  vec4 source = texture(u_sourceTexture, v_texCoord);
319
321
  fragColor = vec4(source.rgb, 1.0);
320
322
  }
321
- `),i=this.gl.createProgram();return this.gl.attachShader(i,e),this.gl.attachShader(i,t),this.gl.linkProgram(i),i}createAlphaProgram(){const e=this.createVertexShader(),t=this.createShader(this.gl.FRAGMENT_SHADER,`#version 300 es
323
+ `),r=this.gl.createProgram();return this.gl.attachShader(r,e),this.gl.attachShader(r,t),this.gl.linkProgram(r),r}createAlphaProgram(){const e=this.createVertexShader(),t=this.createShader(this.gl.FRAGMENT_SHADER,`#version 300 es
322
324
  precision highp float;
323
325
 
324
326
  uniform sampler2D u_sourceTexture;
@@ -362,10 +364,10 @@ const DOUBLE_PI: f32 = 3.14159265358979323846264 * 2.;`,Qn=Object.defineProperty
362
364
 
363
365
  fragColor = result;
364
366
  }
365
- `),i=this.gl.createProgram();return this.gl.attachShader(i,e),this.gl.attachShader(i,t),this.gl.linkProgram(i),i}createShader(e,t){const i=this.gl.createShader(e);return this.gl.shaderSource(i,t),this.gl.compileShader(i),this.gl.getShaderParameter(i,this.gl.COMPILE_STATUS)||console.error("Shader compile error:",this.gl.getShaderInfoLog(i)),i}createVAO(){const e=this.gl.createVertexArray();this.gl.bindVertexArray(e);const t=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,1,1,1,0]),i=this.gl.createBuffer();this.gl.bindBuffer(this.gl.ARRAY_BUFFER,i),this.gl.bufferData(this.gl.ARRAY_BUFFER,t,this.gl.STATIC_DRAW);const r=this.gl.getAttribLocation(this.colorProgram,"a_position"),n=this.gl.getAttribLocation(this.colorProgram,"a_texCoord");return this.gl.enableVertexAttribArray(r),this.gl.vertexAttribPointer(r,2,this.gl.FLOAT,!1,16,0),this.gl.enableVertexAttribArray(n),this.gl.vertexAttribPointer(n,2,this.gl.FLOAT,!1,16,8),e}createTexture(){const e=this.gl.createTexture();return this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),e}updateTexture(e){this.lastFrame!==e&&((e.displayWidth!==this.canvas.width||e.displayHeight!==this.canvas.height)&&(this.canvas.width=e.displayWidth,this.canvas.height=e.displayHeight),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this.sourceTexture),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,e),this.lastFrame=e)}extractColor(e){return this.updateTexture(e),this.gl.useProgram(this.colorProgram),this.gl.viewport(0,0,this.canvas.width,this.canvas.height),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.bindVertexArray(this.vao),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),new VideoFrame(this.canvas,{timestamp:e.timestamp,duration:e.duration??void 0,alpha:"discard"})}extractAlpha(e){this.updateTexture(e),this.gl.useProgram(this.alphaProgram),this.gl.uniform2f(this.alphaResolutionLocation,this.canvas.width,this.canvas.height),this.gl.viewport(0,0,this.canvas.width,this.canvas.height),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.bindVertexArray(this.vao),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4);const{width:t,height:i}=this.canvas,r=Math.ceil(t/2)*Math.ceil(i/2),n=t*i+r*2,o=Math.ceil(n/(t*4));let a=new Uint8Array(4*t*o);this.gl.readPixels(0,0,t,o,this.gl.RGBA,this.gl.UNSIGNED_BYTE,a),a=a.subarray(0,n),$(a[t*i]===128),$(a[a.length-1]===128);const p={format:"I420",codedWidth:t,codedHeight:i,timestamp:e.timestamp,duration:e.duration??void 0,transfer:[a.buffer]};return new VideoFrame(a,p)}close(){this.gl.getExtension("WEBGL_lose_context")?.loseContext(),this.gl=null}}class ch extends vn{constructor(e,t){if(!(typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement)&&!(typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas))throw new TypeError("canvas must be an HTMLCanvasElement or OffscreenCanvas.");th(t),super(t.codec),this._encoder=new oh(this,t),this._canvas=e}add(e,t=0,i){if(!Number.isFinite(e)||e<0)throw new TypeError("timestamp must be a non-negative number.");if(!Number.isFinite(t)||t<0)throw new TypeError("duration must be a non-negative number.");const r=new vt(this._canvas,{timestamp:e,duration:t});return this._encoder.add(r,!0,i)}_flushAndClose(e){return this._encoder.flushAndClose(e)}}class wn extends xs{constructor(e){if(super(),this._connectedTrack=null,!Mt.includes(e))throw new TypeError(`Invalid audio codec '${e}'. Must be one of: ${Mt.join(", ")}.`);this._codec=e}}class hh{constructor(e,t){this.source=e,this.encodingConfig=t,this.ensureEncoderPromise=null,this.encoderInitialized=!1,this.encoder=null,this.muxer=null,this.lastNumberOfChannels=null,this.lastSampleRate=null,this.isPcmEncoder=!1,this.outputSampleSize=null,this.writeOutputValue=null,this.customEncoder=null,this.customEncoderCallSerializer=new Br,this.customEncoderQueueSize=0,this.error=null,this.errorNeedsNewStack=!0}async add(e,t){try{if(this.checkForEncoderError(),this.source._ensureValidAdd(),this.lastNumberOfChannels!==null&&this.lastSampleRate!==null){if(e.numberOfChannels!==this.lastNumberOfChannels||e.sampleRate!==this.lastSampleRate)throw new Error(`Audio parameters must remain constant. Expected ${this.lastNumberOfChannels} channels at ${this.lastSampleRate} Hz, got ${e.numberOfChannels} channels at ${e.sampleRate} Hz.`)}else this.lastNumberOfChannels=e.numberOfChannels,this.lastSampleRate=e.sampleRate;if(this.encoderInitialized||(this.ensureEncoderPromise||this.ensureEncoder(e),this.encoderInitialized||await this.ensureEncoderPromise),$(this.encoderInitialized),this.customEncoder){this.customEncoderQueueSize++;const i=e.clone(),r=this.customEncoderCallSerializer.call(()=>this.customEncoder.encode(i)).then(()=>this.customEncoderQueueSize--).catch(n=>this.error??=n).finally(()=>{i.close()});this.customEncoderQueueSize>=4&&await r,await this.muxer.mutex.currentPromise}else if(this.isPcmEncoder)await this.doPcmEncoding(e,t);else{$(this.encoder);const i=e.toAudioData();this.encoder.encode(i),i.close(),t&&e.close(),this.encoder.encodeQueueSize>=4&&await new Promise(r=>this.encoder.addEventListener("dequeue",r,{once:!0})),await this.muxer.mutex.currentPromise}}finally{t&&e.close()}}async doPcmEncoding(e,t){$(this.outputSampleSize),$(this.writeOutputValue);const{numberOfChannels:i,numberOfFrames:r,sampleRate:n,timestamp:o}=e,a=2048,p=[];for(let c=0;c<r;c+=a){const u=Math.min(a,e.numberOfFrames-c),h=u*i*this.outputSampleSize,f=new ArrayBuffer(h),b=new DataView(f);p.push({frameCount:u,view:b})}const m=e.allocationSize({planeIndex:0,format:"f32-planar"}),d=new Float32Array(m/Float32Array.BYTES_PER_ELEMENT);for(let c=0;c<i;c++){e.copyTo(d,{planeIndex:c,format:"f32-planar"});for(let u=0;u<p.length;u++){const{frameCount:h,view:f}=p[u];for(let b=0;b<h;b++)this.writeOutputValue(f,(b*i+c)*this.outputSampleSize,d[u*a+b])}}t&&e.close();const l={decoderConfig:{codec:this.encodingConfig.codec,numberOfChannels:i,sampleRate:n}};for(let c=0;c<p.length;c++){const{frameCount:u,view:h}=p[c],f=h.buffer,b=c*a,g=new ct(new Uint8Array(f),"key",o+b/n,u/n);this.encodingConfig.onEncodedPacket?.(g,l),await this.muxer.addEncodedAudioPacket(this.source._connectedTrack,g,l)}}ensureEncoder(e){const t=new Error;this.ensureEncoderPromise=(async()=>{const{numberOfChannels:i,sampleRate:r}=e,n=ah({numberOfChannels:i,sampleRate:r,...this.encodingConfig});this.encodingConfig.onEncoderConfig?.(n);const o=Dl.find(a=>a.supports(this.encodingConfig.codec,n));if(o)this.customEncoder=new o,this.customEncoder.codec=this.encodingConfig.codec,this.customEncoder.config=n,this.customEncoder.onPacket=(a,p)=>{if(!(a instanceof ct))throw new TypeError("The first argument passed to onPacket must be an EncodedPacket.");if(p!==void 0&&(!p||typeof p!="object"))throw new TypeError("The second argument passed to onPacket must be an object or undefined.");this.encodingConfig.onEncodedPacket?.(a,p),this.muxer.addEncodedAudioPacket(this.source._connectedTrack,a,p).catch(m=>{this.error??=m,this.errorNeedsNewStack=!1})},await this.customEncoder.init();else if(Ne.includes(this.encodingConfig.codec))this.initPcmEncoder();else{if(typeof AudioEncoder>"u")throw new Error("AudioEncoder is not supported by this browser.");if(!(await AudioEncoder.isConfigSupported(n)).supported)throw new Error(`This specific encoder configuration (${n.codec}, ${n.bitrate} bps, ${n.numberOfChannels} channels, ${n.sampleRate} Hz) is not supported by this browser. Consider using another codec or changing your audio parameters.`);this.encoder=new AudioEncoder({output:(p,m)=>{const d=ct.fromEncodedChunk(p);this.encodingConfig.onEncodedPacket?.(d,m),this.muxer.addEncodedAudioPacket(this.source._connectedTrack,d,m).catch(l=>{this.error??=l,this.errorNeedsNewStack=!1})},error:p=>{p.stack=t.stack,this.error??=p}}),this.encoder.configure(n)}$(this.source._connectedTrack),this.muxer=this.source._connectedTrack.output._muxer,this.encoderInitialized=!0})()}initPcmEncoder(){this.isPcmEncoder=!0;const e=this.encodingConfig.codec,{dataType:t,sampleSize:i,littleEndian:r}=Lt(e);switch(this.outputSampleSize=i,i){case 1:t==="unsigned"?this.writeOutputValue=(n,o,a)=>n.setUint8(o,Se((a+1)*127.5,0,255)):t==="signed"?this.writeOutputValue=(n,o,a)=>{n.setInt8(o,Se(Math.round(a*128),-128,127))}:t==="ulaw"?this.writeOutputValue=(n,o,a)=>{const p=Se(Math.floor(a*32767),-32768,32767);n.setUint8(o,zl(p))}:t==="alaw"?this.writeOutputValue=(n,o,a)=>{const p=Se(Math.floor(a*32767),-32768,32767);n.setUint8(o,Hl(p))}:$(!1);break;case 2:t==="unsigned"?this.writeOutputValue=(n,o,a)=>n.setUint16(o,Se((a+1)*32767.5,0,65535),r):t==="signed"?this.writeOutputValue=(n,o,a)=>n.setInt16(o,Se(Math.round(a*32767),-32768,32767),r):$(!1);break;case 3:t==="unsigned"?this.writeOutputValue=(n,o,a)=>Lr(n,o,Se((a+1)*83886075e-1,0,16777215),r):t==="signed"?this.writeOutputValue=(n,o,a)=>il(n,o,Se(Math.round(a*8388607),-8388608,8388607),r):$(!1);break;case 4:t==="unsigned"?this.writeOutputValue=(n,o,a)=>n.setUint32(o,Se((a+1)*21474836475e-1,0,4294967295),r):t==="signed"?this.writeOutputValue=(n,o,a)=>n.setInt32(o,Se(Math.round(a*2147483647),-2147483648,2147483647),r):t==="float"?this.writeOutputValue=(n,o,a)=>n.setFloat32(o,a,r):$(!1);break;case 8:t==="float"?this.writeOutputValue=(n,o,a)=>n.setFloat64(o,a,r):$(!1);break;default:as(i),$(!1)}}async flushAndClose(e){e||this.checkForEncoderError(),this.customEncoder?(e||this.customEncoderCallSerializer.call(()=>this.customEncoder.flush()),await this.customEncoderCallSerializer.call(()=>this.customEncoder.close())):this.encoder&&(e||await this.encoder.flush(),this.encoder.state!=="closed"&&this.encoder.close()),e||this.checkForEncoderError()}getQueueSize(){return this.customEncoder?this.customEncoderQueueSize:this.isPcmEncoder?0:this.encoder?.encodeQueueSize??0}checkForEncoderError(){if(this.error)throw this.errorNeedsNewStack&&(this.error.stack=new Error().stack),this.error}}class uh extends wn{constructor(e){rh(e),super(e.codec),this._encoder=new hh(this,e)}add(e){if(!(e instanceof wt))throw new TypeError("audioSample must be an AudioSample.");return this._encoder.add(e,!1)}_flushAndClose(e){return this._encoder.flushAndClose(e)}}class dh extends xs{constructor(e){if(super(),this._connectedTrack=null,!Ci.includes(e))throw new TypeError(`Invalid subtitle codec '${e}'. Must be one of: ${Ci.join(", ")}.`);this._codec=e}}/*!
367
+ `),r=this.gl.createProgram();return this.gl.attachShader(r,e),this.gl.attachShader(r,t),this.gl.linkProgram(r),r}createShader(e,t){const r=this.gl.createShader(e);return this.gl.shaderSource(r,t),this.gl.compileShader(r),this.gl.getShaderParameter(r,this.gl.COMPILE_STATUS)||console.error("Shader compile error:",this.gl.getShaderInfoLog(r)),r}createVAO(){const e=this.gl.createVertexArray();this.gl.bindVertexArray(e);const t=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,1,1,1,0]),r=this.gl.createBuffer();this.gl.bindBuffer(this.gl.ARRAY_BUFFER,r),this.gl.bufferData(this.gl.ARRAY_BUFFER,t,this.gl.STATIC_DRAW);const i=this.gl.getAttribLocation(this.colorProgram,"a_position"),n=this.gl.getAttribLocation(this.colorProgram,"a_texCoord");return this.gl.enableVertexAttribArray(i),this.gl.vertexAttribPointer(i,2,this.gl.FLOAT,!1,16,0),this.gl.enableVertexAttribArray(n),this.gl.vertexAttribPointer(n,2,this.gl.FLOAT,!1,16,8),e}createTexture(){const e=this.gl.createTexture();return this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),e}updateTexture(e){this.lastFrame!==e&&((e.displayWidth!==this.canvas.width||e.displayHeight!==this.canvas.height)&&(this.canvas.width=e.displayWidth,this.canvas.height=e.displayHeight),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this.sourceTexture),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,e),this.lastFrame=e)}extractColor(e){return this.updateTexture(e),this.gl.useProgram(this.colorProgram),this.gl.viewport(0,0,this.canvas.width,this.canvas.height),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.bindVertexArray(this.vao),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),new VideoFrame(this.canvas,{timestamp:e.timestamp,duration:e.duration??void 0,alpha:"discard"})}extractAlpha(e){this.updateTexture(e),this.gl.useProgram(this.alphaProgram),this.gl.uniform2f(this.alphaResolutionLocation,this.canvas.width,this.canvas.height),this.gl.viewport(0,0,this.canvas.width,this.canvas.height),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.bindVertexArray(this.vao),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4);const{width:t,height:r}=this.canvas,i=Math.ceil(t/2)*Math.ceil(r/2),n=t*r+i*2,a=Math.ceil(n/(t*4));let o=new Uint8Array(4*t*a);this.gl.readPixels(0,0,t,a,this.gl.RGBA,this.gl.UNSIGNED_BYTE,o),o=o.subarray(0,n),Y(o[t*r]===128),Y(o[o.length-1]===128);const c={format:"I420",codedWidth:t,codedHeight:r,timestamp:e.timestamp,duration:e.duration??void 0,transfer:[o.buffer]};return new VideoFrame(o,c)}close(){this.gl.getExtension("WEBGL_lose_context")?.loseContext(),this.gl=null}}class S2 extends G0{constructor(e,t){if(!(typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement)&&!(typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas))throw new TypeError("canvas must be an HTMLCanvasElement or OffscreenCanvas.");g2(t),super(t.codec),this._encoder=new C2(this,t),this._canvas=e}add(e,t=0,r){if(!Number.isFinite(e)||e<0)throw new TypeError("timestamp must be a non-negative number.");if(!Number.isFinite(t)||t<0)throw new TypeError("duration must be a non-negative number.");const i=new ci(this._canvas,{timestamp:e,duration:t});return this._encoder.add(i,!0,r)}_flushAndClose(e){return this._encoder.flushAndClose(e)}}class q0 extends zo{constructor(e){if(super(),this._connectedTrack=null,!Di.includes(e))throw new TypeError(`Invalid audio codec '${e}'. Must be one of: ${Di.join(", ")}.`);this._codec=e}}class _2{constructor(e,t){this.source=e,this.encodingConfig=t,this.ensureEncoderPromise=null,this.encoderInitialized=!1,this.encoder=null,this.muxer=null,this.lastNumberOfChannels=null,this.lastSampleRate=null,this.isPcmEncoder=!1,this.outputSampleSize=null,this.writeOutputValue=null,this.customEncoder=null,this.customEncoderCallSerializer=new u0,this.customEncoderQueueSize=0,this.error=null,this.errorNeedsNewStack=!0}async add(e,t){try{if(this.checkForEncoderError(),this.source._ensureValidAdd(),this.lastNumberOfChannels!==null&&this.lastSampleRate!==null){if(e.numberOfChannels!==this.lastNumberOfChannels||e.sampleRate!==this.lastSampleRate)throw new Error(`Audio parameters must remain constant. Expected ${this.lastNumberOfChannels} channels at ${this.lastSampleRate} Hz, got ${e.numberOfChannels} channels at ${e.sampleRate} Hz.`)}else this.lastNumberOfChannels=e.numberOfChannels,this.lastSampleRate=e.sampleRate;if(this.encoderInitialized||(this.ensureEncoderPromise||this.ensureEncoder(e),this.encoderInitialized||await this.ensureEncoderPromise),Y(this.encoderInitialized),this.customEncoder){this.customEncoderQueueSize++;const r=e.clone(),i=this.customEncoderCallSerializer.call(()=>this.customEncoder.encode(r)).then(()=>this.customEncoderQueueSize--).catch(n=>this.error??=n).finally(()=>{r.close()});this.customEncoderQueueSize>=4&&await i,await this.muxer.mutex.currentPromise}else if(this.isPcmEncoder)await this.doPcmEncoding(e,t);else{Y(this.encoder);const r=e.toAudioData();this.encoder.encode(r),r.close(),t&&e.close(),this.encoder.encodeQueueSize>=4&&await new Promise(i=>this.encoder.addEventListener("dequeue",i,{once:!0})),await this.muxer.mutex.currentPromise}}finally{t&&e.close()}}async doPcmEncoding(e,t){Y(this.outputSampleSize),Y(this.writeOutputValue);const{numberOfChannels:r,numberOfFrames:i,sampleRate:n,timestamp:a}=e,o=2048,c=[];for(let d=0;d<i;d+=o){const f=Math.min(o,e.numberOfFrames-d),p=f*r*this.outputSampleSize,m=new ArrayBuffer(p),v=new DataView(m);c.push({frameCount:f,view:v})}const u=e.allocationSize({planeIndex:0,format:"f32-planar"}),h=new Float32Array(u/Float32Array.BYTES_PER_ELEMENT);for(let d=0;d<r;d++){e.copyTo(h,{planeIndex:d,format:"f32-planar"});for(let f=0;f<c.length;f++){const{frameCount:p,view:m}=c[f];for(let v=0;v<p;v++)this.writeOutputValue(m,(v*r+d)*this.outputSampleSize,h[f*o+v])}}t&&e.close();const l={decoderConfig:{codec:this.encodingConfig.codec,numberOfChannels:r,sampleRate:n}};for(let d=0;d<c.length;d++){const{frameCount:f,view:p}=c[d],m=p.buffer,v=d*o,g=new Hr(new Uint8Array(m),"key",a+v/n,f/n);this.encodingConfig.onEncodedPacket?.(g,l),await this.muxer.addEncodedAudioPacket(this.source._connectedTrack,g,l)}}ensureEncoder(e){const t=new Error;this.ensureEncoderPromise=(async()=>{const{numberOfChannels:r,sampleRate:i}=e,n=x2({numberOfChannels:r,sampleRate:i,...this.encodingConfig});this.encodingConfig.onEncoderConfig?.(n);const a=ew.find(o=>o.supports(this.encodingConfig.codec,n));if(a)this.customEncoder=new a,this.customEncoder.codec=this.encodingConfig.codec,this.customEncoder.config=n,this.customEncoder.onPacket=(o,c)=>{if(!(o instanceof Hr))throw new TypeError("The first argument passed to onPacket must be an EncodedPacket.");if(c!==void 0&&(!c||typeof c!="object"))throw new TypeError("The second argument passed to onPacket must be an object or undefined.");this.encodingConfig.onEncodedPacket?.(o,c),this.muxer.addEncodedAudioPacket(this.source._connectedTrack,o,c).catch(u=>{this.error??=u,this.errorNeedsNewStack=!1})},await this.customEncoder.init();else if(nr.includes(this.encodingConfig.codec))this.initPcmEncoder();else{if(typeof AudioEncoder>"u")throw new Error("AudioEncoder is not supported by this browser.");if(!(await AudioEncoder.isConfigSupported(n)).supported)throw new Error(`This specific encoder configuration (${n.codec}, ${n.bitrate} bps, ${n.numberOfChannels} channels, ${n.sampleRate} Hz) is not supported by this browser. Consider using another codec or changing your audio parameters.`);this.encoder=new AudioEncoder({output:(c,u)=>{const h=Hr.fromEncodedChunk(c);this.encodingConfig.onEncodedPacket?.(h,u),this.muxer.addEncodedAudioPacket(this.source._connectedTrack,h,u).catch(l=>{this.error??=l,this.errorNeedsNewStack=!1})},error:c=>{c.stack=t.stack,this.error??=c}}),this.encoder.configure(n)}Y(this.source._connectedTrack),this.muxer=this.source._connectedTrack.output._muxer,this.encoderInitialized=!0})()}initPcmEncoder(){this.isPcmEncoder=!0;const e=this.encodingConfig.codec,{dataType:t,sampleSize:r,littleEndian:i}=Bi(e);switch(this.outputSampleSize=r,r){case 1:t==="unsigned"?this.writeOutputValue=(n,a,o)=>n.setUint8(a,St((o+1)*127.5,0,255)):t==="signed"?this.writeOutputValue=(n,a,o)=>{n.setInt8(a,St(Math.round(o*128),-128,127))}:t==="ulaw"?this.writeOutputValue=(n,a,o)=>{const c=St(Math.floor(o*32767),-32768,32767);n.setUint8(a,tw(c))}:t==="alaw"?this.writeOutputValue=(n,a,o)=>{const c=St(Math.floor(o*32767),-32768,32767);n.setUint8(a,rw(c))}:Y(!1);break;case 2:t==="unsigned"?this.writeOutputValue=(n,a,o)=>n.setUint16(a,St((o+1)*32767.5,0,65535),i):t==="signed"?this.writeOutputValue=(n,a,o)=>n.setInt16(a,St(Math.round(o*32767),-32768,32767),i):Y(!1);break;case 3:t==="unsigned"?this.writeOutputValue=(n,a,o)=>c0(n,a,St((o+1)*83886075e-1,0,16777215),i):t==="signed"?this.writeOutputValue=(n,a,o)=>bv(n,a,St(Math.round(o*8388607),-8388608,8388607),i):Y(!1);break;case 4:t==="unsigned"?this.writeOutputValue=(n,a,o)=>n.setUint32(a,St((o+1)*21474836475e-1,0,4294967295),i):t==="signed"?this.writeOutputValue=(n,a,o)=>n.setInt32(a,St(Math.round(o*2147483647),-2147483648,2147483647),i):t==="float"?this.writeOutputValue=(n,a,o)=>n.setFloat32(a,o,i):Y(!1);break;case 8:t==="float"?this.writeOutputValue=(n,a,o)=>n.setFloat64(a,o,i):Y(!1);break;default:Co(r),Y(!1)}}async flushAndClose(e){e||this.checkForEncoderError(),this.customEncoder?(e||this.customEncoderCallSerializer.call(()=>this.customEncoder.flush()),await this.customEncoderCallSerializer.call(()=>this.customEncoder.close())):this.encoder&&(e||await this.encoder.flush(),this.encoder.state!=="closed"&&this.encoder.close()),e||this.checkForEncoderError()}getQueueSize(){return this.customEncoder?this.customEncoderQueueSize:this.isPcmEncoder?0:this.encoder?.encodeQueueSize??0}checkForEncoderError(){if(this.error)throw this.errorNeedsNewStack&&(this.error.stack=new Error().stack),this.error}}class T2 extends q0{constructor(e){v2(e),super(e.codec),this._encoder=new _2(this,e)}add(e){if(!(e instanceof ui))throw new TypeError("audioSample must be an AudioSample.");return this._encoder.add(e,!1)}_flushAndClose(e){return this._encoder.flushAndClose(e)}}class E2 extends zo{constructor(e){if(super(),this._connectedTrack=null,!zn.includes(e))throw new TypeError(`Invalid subtitle codec '${e}'. Must be one of: ${zn.join(", ")}.`);this._codec=e}}/*!
366
368
  * Copyright (c) 2025-present, Vanilagy and contributors
367
369
  *
368
370
  * This Source Code Form is subject to the terms of the Mozilla Public
369
371
  * License, v. 2.0. If a copy of the MPL was not distributed with this
370
372
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
371
- */const fh=["video","audio","subtitle"],Cs=s=>{if(!s||typeof s!="object")throw new TypeError("metadata must be an object.");if(s.languageCode!==void 0&&!nl(s.languageCode))throw new TypeError("metadata.languageCode, when provided, must be a three-letter, ISO 639-2/T language code.");if(s.name!==void 0&&typeof s.name!="string")throw new TypeError("metadata.name, when provided, must be a string.");if(s.maximumPacketCount!==void 0&&(!Number.isInteger(s.maximumPacketCount)||s.maximumPacketCount<0))throw new TypeError("metadata.maximumPacketCount, when provided, must be a non-negative integer.")};class ph{constructor(e){if(this.state="pending",this._tracks=[],this._startPromise=null,this._cancelPromise=null,this._finalizePromise=null,this._mutex=new Mr,this._metadataTags={},!e||typeof e!="object")throw new TypeError("options must be an object.");if(!(e.format instanceof mn))throw new TypeError("options.format must be an OutputFormat.");if(!(e.target instanceof fn))throw new TypeError("options.target must be a Target.");if(e.target._output)throw new Error("Target is already used for another output.");e.target._output=this,this.format=e.format,this.target=e.target,this._writer=e.target._createWriter(),this._muxer=e.format._createMuxer(this)}addVideoTrack(e,t={}){if(!(e instanceof vn))throw new TypeError("source must be a VideoSource.");if(Cs(t),t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError(`Invalid video rotation: ${t.rotation}. Has to be 0, 90, 180 or 270.`);if(!this.format.supportsVideoRotationMetadata&&t.rotation)throw new Error(`${this.format._name} does not support video rotation metadata.`);if(t.frameRate!==void 0&&(!Number.isFinite(t.frameRate)||t.frameRate<=0))throw new TypeError(`Invalid video frame rate: ${t.frameRate}. Must be a positive number.`);this._addTrack("video",e,t)}addAudioTrack(e,t={}){if(!(e instanceof wn))throw new TypeError("source must be an AudioSource.");Cs(t),this._addTrack("audio",e,t)}addSubtitleTrack(e,t={}){if(!(e instanceof dh))throw new TypeError("source must be a SubtitleSource.");Cs(t),this._addTrack("subtitle",e,t)}setMetadataTags(e){if(cl(e),this.state!=="pending")throw new Error("Cannot set metadata tags after output has been started or canceled.");this._metadataTags=e}_addTrack(e,t,i){if(this.state!=="pending")throw new Error("Cannot add track after output has been started or canceled.");if(t._connectedTrack)throw new Error("Source is already used for a track.");const r=this.format.getSupportedTrackCounts(),n=this._tracks.reduce((m,d)=>m+(d.type===e?1:0),0),o=r[e].max;if(n===o)throw new Error(o===0?`${this.format._name} does not support ${e} tracks.`:`${this.format._name} does not support more than ${o} ${e} track${o===1?"":"s"}.`);const a=r.total.max;if(this._tracks.length===a)throw new Error(`${this.format._name} does not support more than ${a} tracks${a===1?"":"s"} in total.`);const p={id:this._tracks.length+1,output:this,type:e,source:t,metadata:i};if(p.type==="video"){const m=this.format.getSupportedVideoCodecs();if(m.length===0)throw new Error(`${this.format._name} does not support video tracks.`+this.format._codecUnsupportedHint(p.source._codec));if(!m.includes(p.source._codec))throw new Error(`Codec '${p.source._codec}' cannot be contained within ${this.format._name}. Supported video codecs are: ${m.map(d=>`'${d}'`).join(", ")}.`+this.format._codecUnsupportedHint(p.source._codec))}else if(p.type==="audio"){const m=this.format.getSupportedAudioCodecs();if(m.length===0)throw new Error(`${this.format._name} does not support audio tracks.`+this.format._codecUnsupportedHint(p.source._codec));if(!m.includes(p.source._codec))throw new Error(`Codec '${p.source._codec}' cannot be contained within ${this.format._name}. Supported audio codecs are: ${m.map(d=>`'${d}'`).join(", ")}.`+this.format._codecUnsupportedHint(p.source._codec))}else if(p.type==="subtitle"){const m=this.format.getSupportedSubtitleCodecs();if(m.length===0)throw new Error(`${this.format._name} does not support subtitle tracks.`+this.format._codecUnsupportedHint(p.source._codec));if(!m.includes(p.source._codec))throw new Error(`Codec '${p.source._codec}' cannot be contained within ${this.format._name}. Supported subtitle codecs are: ${m.map(d=>`'${d}'`).join(", ")}.`+this.format._codecUnsupportedHint(p.source._codec))}this._tracks.push(p),t._connectedTrack=p}async start(){const e=this.format.getSupportedTrackCounts();for(const i of fh){const r=this._tracks.reduce((o,a)=>o+(a.type===i?1:0),0),n=e[i].min;if(r<n)throw new Error(n===e[i].max?`${this.format._name} requires exactly ${n} ${i} track${n===1?"":"s"}.`:`${this.format._name} requires at least ${n} ${i} track${n===1?"":"s"}.`)}const t=e.total.min;if(this._tracks.length<t)throw new Error(t===e.total.max?`${this.format._name} requires exactly ${t} track${t===1?"":"s"}.`:`${this.format._name} requires at least ${t} track${t===1?"":"s"}.`);if(this.state==="canceled")throw new Error("Output has been canceled.");return this._startPromise?(console.warn("Output has already been started."),this._startPromise):this._startPromise=(async()=>{this.state="started",this._writer.start();const i=await this._mutex.acquire();await this._muxer.start();const r=this._tracks.map(n=>n.source._start());await Promise.all(r),i()})()}getMimeType(){return this._muxer.getMimeType()}async cancel(){if(this._cancelPromise)return console.warn("Output has already been canceled."),this._cancelPromise;if(this.state==="finalizing"||this.state==="finalized"){console.warn("Output has already been finalized.");return}return this._cancelPromise=(async()=>{this.state="canceled";const e=await this._mutex.acquire(),t=this._tracks.map(i=>i.source._flushOrWaitForOngoingClose(!0));await Promise.all(t),await this._writer.close(),e()})()}async finalize(){if(this.state==="pending")throw new Error("Cannot finalize before starting.");if(this.state==="canceled")throw new Error("Cannot finalize after canceling.");return this._finalizePromise?(console.warn("Output has already been finalized."),this._finalizePromise):this._finalizePromise=(async()=>{this.state="finalizing";const e=await this._mutex.acquire(),t=this._tracks.map(i=>i.source._flushOrWaitForOngoingClose(!1));await Promise.all(t),await this._muxer.finalize(),await this._writer.flush(),await this._writer.finalize(),this.state="finalized",e()})()}}class mh{audioTracks=[];async setupAudioTracks(e,t){const i=this.findAudioPlayers(e);if(!i.length)return null;this.audioTracks=[];for(const n of i){const o=await this.processAudioTrack(n);o&&this.audioTracks.push(o)}if(!this.audioTracks.length)return null;const r=new uh({codec:"aac",bitrate:128e3});return t.addAudioTrack(r),r}async processAudioSamples(e){if(!this.audioTracks?.length)return;const t=new AudioContext;for(const i of this.audioTracks){const r=await t.decodeAudioData(i.data.slice(0)),{numberOfChannels:n,sampleRate:o,length:a}=r,p=Math.min(a,Math.floor(o*i.duration/1e3)),m=new Float32Array(p*n);for(let d=0;d<n;d+=1){const l=r.getChannelData(d);for(let c=0;c<p;c+=1)m[c*n+d]=l[c]*i.volume}await e.add(new wt({data:m,format:"f32",numberOfChannels:n,sampleRate:o,timestamp:i.start/1e3}))}this.audioTracks=[]}findAudioPlayers(e){const t=[];for(const i of e)for(const r of i)this.isAudioPlayer(r)&&!t.includes(r)&&t.push(r);return t}async processAudioTrack(e){try{const t=e.clipConfiguration?.asset;if(!t?.src)return null;const i=await fetch(t.src);return i.ok?{data:await i.arrayBuffer(),start:e.getStart(),duration:e.getLength(),volume:e.getVolume()}:null}catch(t){return console.warn("Failed to process audio track:",t),null}}isAudioPlayer(e){if(e instanceof Os)return!0;if(!e||typeof e!="object")return!1;const t=e,i=t.constructor?.name==="AudioPlayer",o=t.clipConfiguration?.asset?.type==="audio";return i||o}}class gh{overlay=null;bar=null;percent=null;status=null;create(){this.overlay=Object.assign(document.createElement("div"),{style:"position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.5);z-index:9999;display:flex;justify-content:center;align-items:center;color:white;font-family:Arial"});const e=Object.assign(document.createElement("div"),{style:"background:#222;border-radius:8px;padding:20px;box-shadow:0 4px 8px rgba(0,0,0,0.2);width:300px;text-align:center"});e.innerHTML='<h3 style="margin:0 0 15px 0;font-weight:normal">Exporting Video</h3>',this.status=Object.assign(document.createElement("div"),{style:"font-size:12px;margin-bottom:10px;opacity:0.8"}),e.appendChild(this.status);const t=Object.assign(document.createElement("div"),{style:"width:100%;height:6px;background:#444;border-radius:3px;overflow:hidden;margin-bottom:10px"});this.bar=Object.assign(document.createElement("div"),{style:"width:0%;height:100%;background:#3498db;transition:width 0.3s"}),t.appendChild(this.bar),e.appendChild(t),this.percent=Object.assign(document.createElement("div"),{style:"font-size:12px",innerText:"0%"}),e.appendChild(this.percent),this.overlay.appendChild(e),document.body.appendChild(this.overlay)}update(e,t,i){if(!this.overlay)return;const r=Math.round(e/t*100);this.bar&&(this.bar.style.width=`${r}%`),this.percent&&(this.percent.innerText=`${r}%`),this.status&&i&&(this.status.innerText=i)}remove(){this.overlay?.remove(),this.overlay=null,this.bar=null,this.percent=null,this.status=null}}class _n extends Map{constructor(e){super(),this.maxSize=e}get(e){const t=super.get(e);if(t!==void 0)return super.delete(e),super.set(e,t),t}set(e,t){if(super.delete(e),super.set(e,t),this.size>this.maxSize){const i=this.keys().next().value;i&&this.delete(i)}return this}}class Ei extends Error{constructor(e,t="unknown",i={},r){super(e),this.phase=t,this.context=i,this.name="ExportError",this.cause=r}}class yh extends Ei{constructor(e,t){super(e,"initialization",{missingFeatures:t}),this.name="BrowserCompatibilityError"}}function xn(s){if(!s||typeof s!="object")return!1;const e=s,t=e.constructor?.name==="VideoPlayer",r=e.texture?.source?.resource instanceof HTMLVideoElement;return e.constructor?.name==="RichTextPlayer"?!1:t||r}class bh{frameCache=new _n(10);textureCache=new _n(5);videoElements=new Map;extractionCanvas=null;extractionContext=null;async initialize(e){for(const t of e)if(xn(t)){const i=t,r=i.texture?.source?.resource;r&&this.videoElements.set(this.getVideoKey(i),{element:r,player:i})}this.extractionCanvas=document.createElement("canvas"),this.extractionCanvas.width=3840,this.extractionCanvas.height=2160,this.extractionContext=this.extractionCanvas.getContext("2d",{willReadFrequently:!0,alpha:!0})}async extractFrame(e,t){const i=`${e}-${t}`,r=this.frameCache.get(i);if(r)return r;const n=this.videoElements.get(e);if(!n||!this.extractionContext||!this.extractionCanvas)return null;try{const{element:o,player:a}=n,p=(t-(a.getStart?.()||0))/1e3+(a.clipConfiguration?.asset?.trim||0);await this.seekToTime(o,p);const m=o.videoWidth||o.width||1920,d=o.videoHeight||o.height||1080;this.extractionContext.clearRect(0,0,m,d),this.extractionContext.drawImage(o,0,0,m,d);const l=this.extractionContext.getImageData(0,0,m,d);return this.frameCache.set(i,l),l}catch{return null}}async replaceVideoTexture(e,t){const i=await this.extractFrame(this.getVideoKey(e),t);if(!i)return;const r=`${this.getVideoKey(e)}-${t}`;let n=this.textureCache.get(r);if(!n){const o=document.createElement("canvas");o.width=i.width,o.height=i.height;const a=o.getContext("2d");a&&(a.putImageData(i,0,0),n=R.Texture.from(o),this.textureCache.set(r,n))}n&&e.texture&&(e.originalTextureSource||(e.originalTextureSource=e.texture.source,e.texture.source?.resource instanceof HTMLVideoElement&&(e.originalVideoElement=e.texture.source.resource)),e.texture=n,e.sprite?.texture&&(e.sprite.texture=n),e.lastReplacedTimestamp=t)}disableVideoPlayback(e){const t=[];for(const i of e)if(xn(i)){const r=i;t.push(r),r.texture?.source?.resource instanceof HTMLVideoElement&&r.texture.source.resource.pause(),r.skipVideoUpdate=!0}return t}getVideoKey(e){return e.clipConfiguration?.asset?.src||""}dispose(){this.frameCache.clear(),this.textureCache.clear(),this.videoElements.clear(),this.extractionCanvas=null,this.extractionContext=null}async seekToTime(e,t){return new Promise(i=>{if(Math.abs(e.currentTime-t)<.1){i();return}const r=()=>{e.removeEventListener("seeked",r),setTimeout(i,1)};e.addEventListener("seeked",r),e.currentTime=t})}}class vh{edit;canvas;app;isExporting=!1;videoProcessor=new bh;audioProcessor=new mh;progressUI=new gh;exportCommand=new Jo;constructor(e,t){this.edit=e,this.canvas=t,this.app=t.application,document.addEventListener("keydown",this.handleKeyDown)}async export(e="shotstack-export.mp4",t){if(typeof VideoEncoder>"u")throw new yh("WebCodecs API not supported",["VideoEncoder"]);if(this.isExporting)throw new Ei("Export in progress","init");this.isExporting=!0;const i=this.saveEditState();this.edit.setExportMode(!0);try{this.progressUI.create(),this.canvas.pauseTicker();const r=this.prepareConfig(t??this.edit.getEdit().output?.fps??30);this.progressUI.update(0,100,"Preparing..."),this.edit.executeEditCommand(this.exportCommand),await this.videoProcessor.initialize(this.exportCommand.getClips()),this.progressUI.update(10,100,"Video ready");const n=new ph({format:new yn,target:new pn}),o=document.createElement("canvas");o.width=r.size.width,o.height=r.size.height;const a=o.getContext("2d");if(!a)throw new Error("No 2D context");const p=new ch(o,{codec:"avc",bitrate:5e6});n.addVideoTrack(p),this.progressUI.update(15,100,"Audio...");const m=await this.audioProcessor.setupAudioTracks(this.exportCommand.getTracks(),n);await n.start(),m&&(this.progressUI.update(20,100,"Encoding audio..."),await this.audioProcessor.processAudioSamples(m)),this.progressUI.update(25,100,"Exporting..."),await this.processFrames(r,p,o,a),await n.finalize();const d=n.target.buffer;if(!d)throw new Error("No video data");const l=new Blob([d],{type:"video/mp4"}),c=URL.createObjectURL(l),u=document.createElement("a");u.href=c,u.download=e,u.click(),URL.revokeObjectURL(c),this.progressUI.update(100,100,"Complete!")}catch(r){throw r instanceof Ei?r:new Ei(`Export failed: ${r}`,"export")}finally{this.isExporting=!1,this.edit.setExportMode(!1),this.canvas.resumeTicker(),this.progressUI.remove(),this.restoreEditState(i)}}async processFrames(e,t,i,r){const n=this.edit.getContainer();this.edit.pause(),Object.assign(n.position,{x:0,y:0}),Object.assign(n.scale,{x:1,y:1}),n.visible=!0;const o=this.videoProcessor.disableVideoPlayback(this.exportCommand.getClips());for(let a=0;a<e.frames;a+=1){const p=a*e.frameDuration;this.edit.playbackTime=p;for(const l of this.exportCommand.getClips())l.update(0,0);for(const l of o){const c=l.getStart?.()||0,u=l.getEnd?.()||c+(l.getLength?.()||0);p>=c&&p<u&&await this.videoProcessor.replaceVideoTexture(l,p)}this.edit.draw(),this.app.renderer.render(this.app.stage);const m=this.app.renderer.extract.pixels({target:n,frame:new R.Rectangle(0,0,e.size.width,e.size.height)}),d=new ImageData(new Uint8ClampedArray(m.pixels),m.width,m.height);r.putImageData(d,0,0),await t.add(a/e.fps,1/e.fps),this.progressUI.update(25+Math.round((a+1)/e.frames*75),100,"Exporting...")}}handleKeyDown=e=>{e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement||e.code==="KeyE"&&(e.metaKey||e.ctrlKey)&&!this.isExporting&&(e.preventDefault(),this.export("shotstack-export.mp4",this.edit.getEdit().output?.fps||30).catch(t=>console.error("Export failed:",t)))};dispose(){document.removeEventListener("keydown",this.handleKeyDown),this.videoProcessor.dispose(),this.progressUI.remove()}prepareConfig(e){const t=this.edit.getEdit().output?.size||{width:1920,height:1080},i=this.edit.totalDuration/1e3;return{fps:e,size:t,frames:Math.ceil(i*e),frameDuration:1e3/e}}saveEditState(){const e=this.edit.getContainer();return{wasPlaying:this.edit.isPlaying,time:this.edit.playbackTime,visible:e.visible,pos:{x:e.position.x,y:e.position.y},scale:{x:e.scale.x,y:e.scale.y}}}restoreEditState(e){const t=this.edit.getContainer();this.edit.setExportMode(!1);for(const i of this.exportCommand.getClips())if(this.isVideoPlayer(i)){const r=i;if(r.skipVideoUpdate=!1,r.originalVideoElement&&r.texture){const n=R.Texture.from(r.originalVideoElement);r.texture=n,r.sprite&&(r.sprite.texture=n),delete r.originalVideoElement,delete r.originalTextureSource,delete r.lastReplacedTimestamp}else r.originalTextureSource&&r.texture&&(r.texture.source=r.originalTextureSource,delete r.originalTextureSource,delete r.lastReplacedTimestamp)}Object.assign(t.position,e.pos),Object.assign(t.scale,e.scale),t.visible=e.visible,this.edit.seek(e.time),e.wasPlaying&&this.edit.play()}isVideoPlayer(e){if(!e||typeof e!="object")return!1;const t=e,i=t.constructor?.name==="VideoPlayer",n=t.texture?.source?.resource instanceof HTMLVideoElement;return i||n}}function Cn(s){const e=s.replace("#",""),t=parseInt(e,16);return Number.isNaN(t)?(console.warn(`Invalid hex color: ${s}, defaulting to black`),0):t}function wh(s){const e=t=>{if(typeof t=="string")return Cn(t);if(typeof t=="object"&&t!==null){const i=Array.isArray(t)?[]:{};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=e(t[r]));return i}return t};return e(s)}function kn(s){if(typeof s=="string")return Cn(s);if(typeof s=="object"&&s!==null){const e=Array.isArray(s)?[]:{};for(const t in s)Object.prototype.hasOwnProperty.call(s,t)&&(e[t]=kn(s[t]));return e}return s}const Tn=wh({timeline:{background:"#1a1a1a",divider:"#1a1a1a",toolbar:{background:"#1a1a1a",surface:"#2a2a2a",hover:"#3a3a3a",active:"#007acc",divider:"#3a3a3a",icon:"#888888",text:"#ffffff",height:36},ruler:{background:"#404040",text:"#ffffff",markers:"#666666",height:40},tracks:{surface:"#2a2a2a",surfaceAlt:"#242424",border:"#3a3a3a",height:60},clips:{video:"#4a90e2",audio:"#7ed321",image:"#f5a623",text:"#d0021b",shape:"#9013fe",html:"#50e3c2",luma:"#b8e986",default:"#8e8e93",selected:"#007acc",radius:4},playhead:"#ff4444",snapGuide:"#888888",dropZone:"#00ff00",trackInsertion:"#00ff00"}});class Sn{static resolveTheme(e){if(!e||!e.theme)return this.deepClone(Tn);const t=kn(e.theme),i=this.deepClone(Tn);return this.deepMerge(i,t)}static validateTheme(e){try{if(!e.timeline)return!1;const{timeline:t}=e;if(typeof t.background!="number"||typeof t.divider!="number"||typeof t.playhead!="number"||typeof t.snapGuide!="number"||typeof t.dropZone!="number"||typeof t.trackInsertion!="number"||!t.toolbar)return!1;const{toolbar:i}=t;if(typeof i.background!="number"||typeof i.surface!="number"||typeof i.hover!="number"||typeof i.active!="number"||typeof i.divider!="number"||typeof i.icon!="number"||typeof i.text!="number"||typeof i.height!="number"||i.height<=0||!t.ruler)return!1;const{ruler:r}=t;if(typeof r.background!="number"||typeof r.text!="number"||typeof r.markers!="number"||typeof r.height!="number"||r.height<=0||!t.tracks)return!1;const{tracks:n}=t;if(typeof n.surface!="number"||typeof n.surfaceAlt!="number"||typeof n.border!="number"||typeof n.height!="number"||n.height<=0||!t.clips)return!1;const{clips:o}=t,a=["video","audio","image","text","shape","html","luma","default","selected"];for(const p of a)if(typeof o[p]!="number")return!1;return!(typeof o.radius!="number"||o.radius<0)}catch(t){return console.error("Theme validation error:",t),!1}}static deepClone(e){if(e===null||typeof e!="object")return e;if(e instanceof Array)return e.map(i=>this.deepClone(i));const t={};for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=this.deepClone(e[i]));return t}static deepMerge(e,t){const i={...e};for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)){const n=t[r],o=i[r];n!==void 0&&(typeof n=="object"&&n!==null&&!Array.isArray(n)&&typeof o=="object"&&o!==null&&!Array.isArray(o)?i[r]=this.deepMerge(o,n):i[r]=n)}return i}}class _h{timeline;constructor(e){this.timeline=e}getValidDropPosition(e,t,i,r){const n=this.timeline.getVisualTracks()[i];if(!n)return{validTime:e,wouldOverlap:!1};const o=this.getOtherClipBounds(n,r),a=e+t,p=o.find(u=>!(a<=u.start||e>=u.end));if(!p)return{validTime:e,wouldOverlap:!1};const m=p.start-t,d=p.end,l=Math.abs(e-m)<Math.abs(e-d)&&m>=0?m:d;return{validTime:this.getValidDropPosition(l,t,i,r).validTime,wouldOverlap:!0}}checkOverlap(e,t,i,r){const n=this.timeline.getVisualTracks()[i];if(!n)return!1;const o=this.getOtherClipBounds(n,r),a=e+t;return o.some(p=>!(a<=p.start||e>=p.end))}getOtherClipBounds(e,t){return e.getClips().map((i,r)=>({clip:i,index:r})).filter(({index:i})=>i!==t).map(({clip:i})=>{const r=i.getClipConfig();return r?{start:r.start||0,end:(r.start||0)+(r.length||0)}:null}).filter(i=>i!==null).sort((i,r)=>i.start-r.start)}findAvailableGaps(e,t){const i=this.timeline.getVisualTracks()[e];if(!i)return[];const r=this.getOtherClipBounds(i),n=[];r.length>0&&r[0].start>=t&&n.push({start:0,end:r[0].start});for(let o=0;o<r.length-1;o+=1)r[o+1].start-r[o].end>=t&&n.push({start:r[o].end,end:r[o+1].start});return n}}class En{constructor(e,t,i,r){this.fromTrackIndex=e,this.fromClipIndex=t,this.toTrackIndex=i,this.newStart=r,this.originalTrackIndex=e,this.originalClipIndex=t}name="moveClip";player;originalTrackIndex;originalClipIndex;originalStart;execute(e){if(!e)return;const t=e.getTracks();if(this.fromTrackIndex<0||this.fromTrackIndex>=t.length){console.warn(`Invalid source track index: ${this.fromTrackIndex}`);return}const i=t[this.fromTrackIndex];if(this.fromClipIndex<0||this.fromClipIndex>=i.length){console.warn(`Invalid clip index: ${this.fromClipIndex}`);return}if(this.player=i[this.fromClipIndex],this.originalStart=this.player.clipConfiguration.start,this.fromTrackIndex!==this.toTrackIndex){if(this.toTrackIndex<0||this.toTrackIndex>=t.length){console.warn(`Invalid destination track index: ${this.toTrackIndex}`);return}i.splice(this.fromClipIndex,1),this.player.layer=this.toTrackIndex+1;const r=t[this.toTrackIndex];let n=0;for(let o=0;o<r.length;o+=1){const a=r[o];if(a.clipConfiguration&&a.clipConfiguration.start!==void 0&&this.newStart<a.clipConfiguration.start)break;n+=1}r.splice(n,0,this.player),this.originalClipIndex=n}if(this.player.clipConfiguration.start=this.newStart,e.movePlayerToTrackContainer(this.player,this.fromTrackIndex,this.toTrackIndex),this.player.reconfigureAfterRestore(),this.player.draw(),e.updateDuration(),this.fromTrackIndex!==this.toTrackIndex){const r=t[this.fromTrackIndex],n=t[this.toTrackIndex];[...r,...n].forEach(o=>{o&&o!==this.player&&o.draw()})}e.emitEvent("clip:updated",{previous:{clip:{...this.player.clipConfiguration,start:this.originalStart},trackIndex:this.fromTrackIndex,clipIndex:this.fromClipIndex},current:{clip:this.player.clipConfiguration,trackIndex:this.toTrackIndex,clipIndex:this.originalClipIndex}})}undo(e){if(!e||!this.player||this.originalStart===void 0)return;const t=e.getTracks();if(this.fromTrackIndex!==this.toTrackIndex){const i=t[this.toTrackIndex],r=i.indexOf(this.player);r!==-1&&i.splice(r,1),this.player.layer=this.fromTrackIndex+1,t[this.fromTrackIndex].splice(this.fromClipIndex,0,this.player)}this.player.clipConfiguration.start=this.originalStart,e.movePlayerToTrackContainer(this.player,this.toTrackIndex,this.fromTrackIndex),this.player.reconfigureAfterRestore(),this.player.draw(),e.updateDuration(),e.emitEvent("clip:updated",{previous:{clip:{...this.player.clipConfiguration,start:this.newStart},trackIndex:this.toTrackIndex,clipIndex:this.originalClipIndex},current:{clip:this.player.clipConfiguration,trackIndex:this.fromTrackIndex,clipIndex:this.fromClipIndex}})}}class xh{constructor(e,t,i,r){this.insertionIndex=e,this.fromTrackIndex=t,this.fromClipIndex=i,this.newStart=r,this.addTrackCommand=new Sr(e);const n=t>=e?t+1:t;this.moveClipCommand=new En(n,i,e,r)}name="createTrackAndMoveClip";addTrackCommand;moveClipCommand;wasExecuted=!1;async execute(e){if(e)try{this.addTrackCommand.execute(e),this.moveClipCommand.execute(e),this.wasExecuted=!0}catch(t){if(this.wasExecuted)try{this.undo(e)}catch{}throw t}}undo(e){!e||!this.wasExecuted||(this.moveClipCommand.undo(e),this.addTrackCommand.undo(e),this.wasExecuted=!1,e.emitEvent("track:created:undone",{trackIndex:this.insertionIndex}))}}class Ch{timeline;thresholds;snapManager;collisionDetector;visualFeedback;dragInfo=null;currentDropZone=null;constructor(e,t,i,r,n){this.timeline=e,this.thresholds=t,this.snapManager=i,this.collisionDetector=r,this.visualFeedback=n}activate(){}deactivate(){this.endDrag()}canStartDrag(e,t){const i=Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),{trackHeight:r}=this.timeline.getLayout(),n=r<20?2:this.thresholds.drag.base;return i>n}startDrag(e,t){const i=this.timeline.getClipData(e.trackIndex,e.clipIndex);if(!i)return console.warn(`Clip data not found for track ${e.trackIndex}, clip ${e.clipIndex}`),!1;const r=this.timeline.getContainer().toLocal(t.global),n=this.timeline.getLayout(),o=n.getXAtTime(i.start||0),a=e.trackIndex*n.trackHeight;return this.dragInfo={trackIndex:e.trackIndex,clipIndex:e.clipIndex,startTime:i.start||0,offsetX:r.x-o,offsetY:r.y-a},this.timeline.getPixiApp().canvas.style.cursor="grabbing",this.timeline.getEdit().events.emit("drag:started",this.dragInfo),!0}updateDrag(e){if(!this.dragInfo)return;const t=this.calculateDragPosition(e),i=this.detectDropZone(t.y);i?this.handleDropZonePreview(i,t):this.handleNormalDragPreview(t),this.emitDragUpdate(t,i)}completeDrag(e){if(!this.dragInfo)return;const t={...this.dragInfo},i=this.calculateDragPosition(e),r=this.detectDropZone(i.y);this.endDrag(),r?this.executeDropZoneMove(r,t,i):this.executeNormalMove(t,i)}calculateDragPosition(e){if(!this.dragInfo)throw new Error("No drag info available");const t=this.timeline.getContainer().toLocal(e.global),i=this.timeline.getLayout(),r=Math.max(0,i.getTimeAtX(t.x-this.dragInfo.offsetX)),n=t.y-this.dragInfo.offsetY,o=n+i.trackHeight/2,a=Math.max(0,Math.floor(o/i.trackHeight)),p=this.timeline.getVisualTracks().length-1,m=Math.max(0,Math.min(p,a));return{x:t.x,y:t.y+i.viewportY,time:r,track:m,ghostY:n}}detectDropZone(e){const t=this.timeline.getLayout(),i=this.timeline.getVisualTracks(),r=t.trackHeight*this.thresholds.dropZone.ratio;for(let n=0;n<=i.length;n+=1){const o=t.tracksY+n*t.trackHeight;if(Math.abs(e-o)<r){let a;return n===0?a="above":n===i.length?a="below":a="between",{type:a,position:n}}}return null}handleDropZonePreview(e,t){(!this.currentDropZone||this.currentDropZone.type!==e.type||this.currentDropZone.position!==e.position)&&(this.currentDropZone=e,this.visualFeedback.showDropZone(e)),this.timeline.hideDragGhost(),this.visualFeedback.hideSnapGuidelines(),this.visualFeedback.hideTargetTrack()}handleNormalDragPreview(e){if(!this.dragInfo)return;this.currentDropZone&&(this.visualFeedback.hideDropZone(),this.currentDropZone=null);const t=this.timeline.getClipData(this.dragInfo.trackIndex,this.dragInfo.clipIndex);if(!t)return;const i=t.length||0,r=e.track===this.dragInfo.trackIndex?this.dragInfo.clipIndex:void 0,n=this.calculateFinalPosition(e.time,e.track,i,r),o=this.snapManager.findAlignedElements(n,i,e.track,r);o.length>0?this.visualFeedback.showSnapGuidelines(o):this.visualFeedback.hideSnapGuidelines(),this.visualFeedback.showTargetTrack(e.track),this.timeline.showDragGhost(e.track,n,e.ghostY)}calculateFinalPosition(e,t,i,r){const n=this.snapManager.calculateSnapPosition(e,t,i,r);return this.collisionDetector.getValidDropPosition(n.time,i,t,r).validTime}emitDragUpdate(e,t){if(!this.dragInfo)return;const i=this.timeline.getClipData(this.dragInfo.trackIndex,this.dragInfo.clipIndex);if(!i)return;const r=i.length||0,n=t?e.time:this.calculateFinalPosition(e.time,e.track,r,e.track===this.dragInfo.trackIndex?this.dragInfo.clipIndex:void 0);this.timeline.getEdit().events.emit("drag:moved",{...this.dragInfo,currentTime:n,currentTrack:t?-1:e.track})}executeDropZoneMove(e,t,i){const r=new xh(e.position,t.trackIndex,t.clipIndex,i.time);this.timeline.getEdit().executeEditCommand(r)}executeNormalMove(e,t){const i=this.timeline.getClipData(e.trackIndex,e.clipIndex);if(!i)return;const r=i.length||0,n=t.track===e.trackIndex?e.clipIndex:void 0,o=this.calculateFinalPosition(t.time,t.track,r,n);if(t.track!==e.trackIndex||Math.abs(o-e.startTime)>.01){const p=new En(e.trackIndex,e.clipIndex,t.track,o);this.timeline.getEdit().executeEditCommand(p)}}endDrag(){this.dragInfo=null,this.currentDropZone=null,this.visualFeedback.hideAll(),this.timeline.getPixiApp().canvas.style.cursor="default",this.timeline.getEdit().events.emit("drag:ended",{})}getDragInfo(){return this.dragInfo}dispose(){this.endDrag()}}class kh{constructor(e,t,i){this.trackIndex=e,this.clipIndex=t,this.newLength=i}name="resizeClip";originalLength;player;execute(e){if(!e)return;const t=e.getTrack(this.trackIndex);if(!t){console.warn(`Invalid track index: ${this.trackIndex}`);return}if(this.clipIndex<0||this.clipIndex>=t.length){console.warn(`Invalid clip index: ${this.clipIndex} for track ${this.trackIndex}`);return}this.player=t[this.clipIndex],this.originalLength=this.player.clipConfiguration.length,this.player.clipConfiguration.length=this.newLength,this.player.reconfigureAfterRestore(),this.player.draw(),e.updateDuration(),e.emitEvent("clip:updated",{previous:{clip:{...this.player.clipConfiguration,length:this.originalLength},trackIndex:this.trackIndex,clipIndex:this.clipIndex},current:{clip:this.player.clipConfiguration,trackIndex:this.trackIndex,clipIndex:this.clipIndex}})}undo(e){!e||!this.player||this.originalLength===void 0||(this.player.clipConfiguration.length=this.originalLength,this.player.reconfigureAfterRestore(),this.player.draw(),e.updateDuration(),e.emitEvent("clip:updated",{previous:{clip:{...this.player.clipConfiguration,length:this.newLength},trackIndex:this.trackIndex,clipIndex:this.clipIndex},current:{clip:this.player.clipConfiguration,trackIndex:this.trackIndex,clipIndex:this.clipIndex}}))}}class Th{timeline;thresholds;resizeInfo=null;constructor(e,t){this.timeline=e,this.thresholds=t}activate(){}deactivate(){this.endResize()}isOnClipRightEdge(e,t){const i=this.timeline.getVisualTracks()[e.trackIndex];if(!i)return!1;const r=i.getClip(e.clipIndex);if(!r)return!1;const o=r.getContainer().getBounds(),a=o.x+o.width,p=Math.abs(t.global.x-a),m=this.getResizeThreshold();return p<=m}startResize(e,t){const i=this.timeline.getClipData(e.trackIndex,e.clipIndex);if(!i)return!1;this.resizeInfo={trackIndex:e.trackIndex,clipIndex:e.clipIndex,originalLength:i.length||0,startX:t.global.x},this.timeline.getPixiApp().canvas.style.cursor="ew-resize";const r=this.timeline.getVisualTracks()[e.trackIndex];if(r){const n=r.getClip(e.clipIndex);n&&n.setResizing(!0)}return this.timeline.getEdit().events.emit("resize:started",this.resizeInfo),!0}updateResize(e){if(!this.resizeInfo)return;const t=e.global.x-this.resizeInfo.startX,i=this.timeline.getOptions().pixelsPerSecond||50,r=t/i,n=Math.max(.1,this.resizeInfo.originalLength+r),o=this.timeline.getVisualTracks()[this.resizeInfo.trackIndex];if(o){const a=o.getClip(this.resizeInfo.clipIndex);if(a){const p=n*i;a.setPreviewWidth(p),this.timeline.getEdit().events.emit("resize:updated",{width:p})}}}completeResize(e){if(!this.resizeInfo)return;const t=e.global.x-this.resizeInfo.startX,i=this.timeline.getOptions().pixelsPerSecond||50,r=t/i,n=Math.max(.1,this.resizeInfo.originalLength+r),o=this.timeline.getVisualTracks()[this.resizeInfo.trackIndex];if(o){const a=o.getClip(this.resizeInfo.clipIndex);a&&(a.setResizing(!1),a.setPreviewWidth(null))}if(Math.abs(n-this.resizeInfo.originalLength)>.01){const a=new kh(this.resizeInfo.trackIndex,this.resizeInfo.clipIndex,n);this.timeline.getEdit().executeEditCommand(a),this.timeline.getEdit().events.emit("resize:ended",{newLength:n})}this.endResize()}getCursorForPosition(e,t){return e&&this.isOnClipRightEdge(e,t)?"ew-resize":""}getResizeThreshold(){const{trackHeight:e}=this.timeline.getLayout();return Math.max(this.thresholds.resize.min,Math.min(this.thresholds.resize.max,e*this.thresholds.resize.ratio))}endResize(){this.resizeInfo=null,this.timeline.getPixiApp().canvas.style.cursor="default"}getResizeInfo(){return this.resizeInfo}dispose(){this.endResize()}}class Sh{timeline;thresholds;constructor(e,t){this.timeline=e,this.thresholds=t}getAllSnapPoints(e,t){const i=[];this.timeline.getVisualTracks().forEach((o,a)=>{o.getClips().forEach((m,d)=>{if(a===e&&d===t)return;const l=m.getClipConfig();l&&(i.push({time:l.start||0,type:"clip-start",trackIndex:a,clipIndex:d}),i.push({time:(l.start||0)+(l.length||0),type:"clip-end",trackIndex:a,clipIndex:d}))})});const n=this.timeline.getPlayheadTime();return i.push({time:n,type:"playhead"}),i}getTrackSnapPoints(e,t){return this.getAllSnapPoints(e,t).filter(i=>i.trackIndex===void 0||i.trackIndex===e)}calculateSnapPosition(e,t,i,r){const n=this.timeline.getOptions().pixelsPerSecond||50,o=this.thresholds.snap.pixels/n,a=this.getTrackSnapPoints(t,r);let p=null;for(const m of a){const d=Math.abs(e-m.time);d<o&&(!p||d<p.distance)&&(p={time:m.time,type:m.type,distance:d});const l=Math.abs(e+i-m.time);l<o&&(!p||l<p.distance)&&(p={time:m.time-i,type:m.type,distance:l})}return p?{time:p.time,snapped:!0,snapType:p.type}:{time:e,snapped:!1}}findAlignedElements(e,t,i,r){const o=e+t,a=new Map;this.timeline.getVisualTracks().forEach((m,d)=>{m.getClips().forEach((l,c)=>{if(d===i&&c===r)return;const u=l.getClipConfig();if(!u)return;const h=u.start||0,f=h+(u.length||0);[{time:h,aligns:[e,o]},{time:f,aligns:[e,o]}].forEach(({time:b,aligns:g})=>{g.some(y=>Math.abs(y-b)<.1)&&(a.has(b)||a.set(b,{tracks:new Set,isPlayhead:!1}),a.get(b).tracks.add(d))})})});const p=this.timeline.getPlayheadTime();return(Math.abs(e-p)<.1||Math.abs(o-p)<.1)&&(a.has(p)||a.set(p,{tracks:new Set,isPlayhead:!0}),a.get(p).isPlayhead=!0),Array.from(a.entries()).map(([m,d])=>({time:m,tracks:Array.from(d.tracks).concat(i),isPlayhead:d.isPlayhead}))}}class Eh{timeline;graphics=new Map;constructor(e){this.timeline=e}showDropZone(e){this.hideDropZone();const t=new R.Graphics,i=this.timeline.getLayout(),r=this.timeline.getExtendedTimelineWidth(),n=e.position*i.trackHeight,a=this.timeline.getTheme().timeline.trackInsertion;t.setStrokeStyle({width:4,color:a,alpha:.8}),t.moveTo(0,n),t.lineTo(r,n),t.stroke(),t.setStrokeStyle({width:8,color:a,alpha:.3}),t.moveTo(0,n),t.lineTo(r,n),t.stroke(),this.timeline.getContainer().addChild(t),this.graphics.set("dropZone",t)}hideDropZone(){this.hideGraphics("dropZone")}showSnapGuidelines(e){this.hideSnapGuidelines();const t=new R.Graphics,i=this.timeline.getLayout(),r=this.timeline.getTheme();e.forEach(({time:n,tracks:o,isPlayhead:a})=>{const p=i.getXAtTime(n),m=Math.min(...o),d=Math.max(...o),l=m*i.trackHeight,c=(d+1)*i.trackHeight,u=a?r.timeline.playhead:r.timeline.snapGuide;t.setStrokeStyle({width:3,color:u,alpha:.3}),t.moveTo(p,l),t.lineTo(p,c),t.stroke(),t.setStrokeStyle({width:1,color:u,alpha:.8}),t.moveTo(p,l),t.lineTo(p,c),t.stroke()}),this.timeline.getContainer().addChild(t),this.graphics.set("snapGuidelines",t)}hideSnapGuidelines(){this.hideGraphics("snapGuidelines")}showTargetTrack(e){this.hideTargetTrack();const t=new R.Graphics,i=this.timeline.getLayout(),r=this.timeline.getExtendedTimelineWidth(),n=e*i.trackHeight,o=i.trackHeight,p=this.timeline.getTheme().timeline.dropZone;t.rect(0,n,r,o),t.fill({color:p,alpha:.1}),t.setStrokeStyle({width:1,color:p,alpha:.3}),t.rect(0,n,r,o),t.stroke(),this.timeline.getContainer().addChild(t),this.graphics.set("targetTrack",t)}hideTargetTrack(){this.hideGraphics("targetTrack")}hideAll(){this.graphics.forEach((e,t)=>this.hideGraphics(t))}hideGraphics(e){const t=this.graphics.get(e);t&&(t.clear(),t.parent&&t.parent.removeChild(t),t.destroy(),this.graphics.delete(e))}dispose(){this.hideAll(),this.graphics.clear()}}class Ah{timeline;state={type:"idle"};abortController;dragHandler;resizeHandler;snapManager;collisionDetector;visualFeedback;thresholds={drag:{base:3,small:2},resize:{min:12,max:20,ratio:.4},dropZone:{ratio:.15},snap:{pixels:10,time:.1}};constructor(e,t){if(this.timeline=e,t){const i=structuredClone(this.thresholds);t.drag&&Object.assign(i.drag,t.drag),t.resize&&Object.assign(i.resize,t.resize),t.dropZone&&Object.assign(i.dropZone,t.dropZone),t.snap&&Object.assign(i.snap,t.snap),this.thresholds=i}this.snapManager=new Sh(e,this.thresholds),this.collisionDetector=new _h(e),this.visualFeedback=new Eh(e),this.dragHandler=new Ch(e,this.thresholds,this.snapManager,this.collisionDetector,this.visualFeedback),this.resizeHandler=new Th(e,this.thresholds)}activate(){this.abortController=new AbortController,this.setupEventListeners(),this.dragHandler.activate(),this.resizeHandler.activate()}deactivate(){this.abortController&&(this.abortController.abort(),this.abortController=void 0),this.resetState(),this.dragHandler.deactivate(),this.resizeHandler.deactivate()}setupEventListeners(){const e=this.timeline.getPixiApp();e.stage.interactive=!0,e.stage.on("pointerdown",this.handlePointerDown.bind(this),{signal:this.abortController?.signal}),e.stage.on("pointermove",this.handlePointerMove.bind(this),{signal:this.abortController?.signal}),e.stage.on("pointerup",this.handlePointerUp.bind(this),{signal:this.abortController?.signal}),e.stage.on("pointerupoutside",this.handlePointerUp.bind(this),{signal:this.abortController?.signal})}handlePointerDown(e){const t=e.target;if(t.label){const i=this.parseClipLabel(t.label);if(i){if(this.resizeHandler.isOnClipRightEdge(i,e)){if(this.resizeHandler.startResize(i,e)){const r=this.resizeHandler.getResizeInfo();r&&(this.state={type:"resizing",resizeInfo:r})}return}this.state={type:"selecting",startPos:{x:e.global.x,y:e.global.y},clipInfo:i},this.timeline.getPixiApp().canvas.style.cursor="grab";return}}this.timeline.getEdit().clearSelection()}handlePointerMove(e){switch(this.state.type){case"selecting":this.handleSelectingMove(e);break;case"dragging":this.timeline.getPixiApp().canvas.style.cursor="grabbing",this.dragHandler.updateDrag(e);break;case"resizing":this.timeline.getPixiApp().canvas.style.cursor="ew-resize",this.resizeHandler.updateResize(e);break;case"idle":this.updateCursorForPosition(e);break}}handlePointerUp(e){switch(this.state.type){case"selecting":this.timeline.getEdit().selectClip(this.state.clipInfo.trackIndex,this.state.clipInfo.clipIndex);break;case"dragging":this.dragHandler.completeDrag(e);break;case"resizing":this.resizeHandler.completeResize(e);break}this.resetState()}handleSelectingMove(e){if(this.state.type!=="selecting")return;const t={x:e.global.x,y:e.global.y};if(this.dragHandler.canStartDrag(this.state.startPos,t)&&this.dragHandler.startDrag(this.state.clipInfo,e)){const i=this.dragHandler.getDragInfo();i&&(this.state={type:"dragging",dragInfo:i})}}updateCursorForPosition(e){const t=e.target;if(t.label){const i=this.parseClipLabel(t.label);if(i){const r=this.resizeHandler.getCursorForPosition(i,e);if(r){this.timeline.getPixiApp().canvas.style.cursor=r;return}this.timeline.getPixiApp().canvas.style.cursor="grab";return}}this.timeline.getPixiApp().canvas.style.cursor="default"}parseClipLabel(e){if(!e?.startsWith("clip-"))return null;const t=e.split("-");if(t.length!==3)return null;const i=parseInt(t[1],10),r=parseInt(t[2],10);return Number.isNaN(i)||Number.isNaN(r)?null:{trackIndex:i,clipIndex:r}}resetState(){this.state={type:"idle"},this.visualFeedback.hideAll(),this.timeline.getPixiApp().canvas.style.cursor="default"}dispose(){this.deactivate(),this.dragHandler.dispose(),this.resizeHandler.dispose(),this.visualFeedback.dispose()}}class Ih{constructor(e,t,i,r,n){this.container=e,this.layout=t,this.getPixelsPerSecond=i,this.getTrackHeight=r,this.getVisualTracks=n}dragPreviewContainer=null;dragPreviewGraphics=null;draggedClipInfo=null;showDragPreview(e,t,i){if(!i)return;this.draggedClipInfo={trackIndex:e,clipIndex:t,clipConfig:i},this.dragPreviewContainer=new R.Container,this.dragPreviewGraphics=new R.Graphics,this.dragPreviewContainer.addChild(this.dragPreviewGraphics),this.container.addChild(this.dragPreviewContainer),this.getVisualTracks()[e]?.getClip(t)?.setDragging(!0),this.drawDragPreview(e,i.start||0)}drawDragPreview(e,t){if(!this.dragPreviewContainer||!this.dragPreviewGraphics||!this.draggedClipInfo)return;const{clipConfig:i}=this.draggedClipInfo,r=this.layout.getXAtTime(t),n=e*this.layout.trackHeight,o=(i.length||0)*this.getPixelsPerSecond();this.dragPreviewGraphics.clear(),this.dragPreviewGraphics.roundRect(0,0,o,this.getTrackHeight(),4),this.dragPreviewGraphics.fill({color:9342611,alpha:.6}),this.dragPreviewGraphics.stroke({width:2,color:65280}),this.dragPreviewContainer.position.set(r,n)}drawDragPreviewAtPosition(e,t,i){if(!this.dragPreviewContainer||!this.dragPreviewGraphics||!this.draggedClipInfo)return;const{clipConfig:r}=this.draggedClipInfo,n=this.layout.getXAtTime(e),o=(r.length||0)*this.getPixelsPerSecond(),a=this.getTrackHeight();this.dragPreviewGraphics.clear(),this.dragPreviewGraphics.roundRect(0,0,o,a,4),this.dragPreviewGraphics.fill({color:9342611,alpha:.6});const p=i*this.layout.trackHeight,d=Math.abs(t-p)<5?65280:16755200;this.dragPreviewGraphics.stroke({width:2,color:d}),this.dragPreviewContainer.position.set(n,t)}hideDragPreview(){this.dragPreviewContainer&&(this.dragPreviewContainer.destroy({children:!0}),this.dragPreviewContainer=null,this.dragPreviewGraphics=null),this.draggedClipInfo&&(this.getVisualTracks()[this.draggedClipInfo.trackIndex]?.getClip(this.draggedClipInfo.clipIndex)?.setDragging(!1),this.draggedClipInfo=null)}hideDragGhost(){this.dragPreviewContainer&&(this.dragPreviewContainer.visible=!1)}showDragGhost(e,t,i){!this.dragPreviewContainer||!this.draggedClipInfo||(this.dragPreviewContainer.visible=!0,i!==void 0?this.drawDragPreviewAtPosition(t,i,e):this.drawDragPreview(e,t))}getDraggedClipInfo(){return this.draggedClipInfo}hasActivePreview(){return this.dragPreviewContainer!==null}dispose(){this.hideDragPreview()}}class Ph{constructor(e,t,i,r,n){this.layout=e,this.trackLayer=t,this.overlayLayer=i,this.entityContainer=r,this.onRender=n}scrollX=0;scrollY=0;zoomLevel=1;viewport;rulerViewport;playheadContainer;async setupViewport(){this.rulerViewport=new R.Container,this.rulerViewport.label="ruler-viewport",this.overlayLayer.addChild(this.rulerViewport),this.playheadContainer=new R.Container,this.playheadContainer.label="playhead-container",this.overlayLayer.addChild(this.playheadContainer),this.viewport=new R.Container,this.viewport.label="viewport",this.trackLayer.addChild(this.viewport),this.viewport.addChild(this.entityContainer)}updateViewportTransform(){const e=this.layout.calculateViewportPosition(this.scrollX,this.scrollY);this.viewport.position.set(e.x,e.y),this.viewport.scale.set(this.zoomLevel,this.zoomLevel),this.rulerViewport.position.x=e.x,this.rulerViewport.scale.x=this.zoomLevel,this.playheadContainer.position.x=e.x,this.playheadContainer.scale.x=this.zoomLevel}setScroll(e,t){this.scrollX=e,this.scrollY=t,this.updateViewportTransform(),this.onRender()}setZoom(e){this.zoomLevel=Math.max(.1,Math.min(10,e)),this.updateViewportTransform(),this.onRender()}getViewport(){return{x:this.scrollX,y:this.scrollY,zoom:this.zoomLevel}}getMainViewport(){return this.viewport}getRulerViewport(){return this.rulerViewport}getPlayheadContainer(){return this.playheadContainer}}const Pe={MIN_WIDTH:50,PADDING:4,DEFAULT_ALPHA:1,DRAG_OPACITY:.6,RESIZE_OPACITY:.9,BORDER_WIDTH:2,CORNER_RADIUS:4,SELECTED_BORDER_MULTIPLIER:2,TEXT_FONT_SIZE:12,TEXT_TRUNCATE_SUFFIX_LENGTH:3},ri={PADDING:2,LABEL_PADDING:8,DEFAULT_OPACITY:.8,BORDER_WIDTH:1},Le={TOOLBAR_HEIGHT_RATIO:.12,RULER_HEIGHT_RATIO:.133,TOOLBAR_HEIGHT_DEFAULT:36,RULER_HEIGHT_DEFAULT:40,TRACK_HEIGHT_DEFAULT:80,BORDER_WIDTH:2,CORNER_RADIUS:4,CLIP_PADDING:4,LABEL_PADDING:8,TRACK_PADDING:2,MIN_CLIP_WIDTH:50};function Ai(s){const e=s.split("/");return e[e.length-1]||s}function Rh(s){switch(s.type){case"video":return s.src?Ai(s.src):"Video";case"audio":return s.src?Ai(s.src):"Audio";case"image":return s.src?Ai(s.src):"Image";case"text":return s.text||"Text";case"rich-text":return s.text||"Rich Text";case"shape":return s.shape||"Shape";case"html":return"HTML";case"luma":return s.src?Ai(s.src):"Luma";default:return"Unknown Asset"}}class Oh extends Je{clipConfig;options;graphics;background;text;selectionRenderer;lastGlobalX=-1;lastGlobalY=-1;visualState={mode:"normal"};CLIP_PADDING=Pe.PADDING;BORDER_WIDTH=Pe.BORDER_WIDTH;get CORNER_RADIUS(){return this.options.theme.timeline.clips.radius||Pe.CORNER_RADIUS}constructor(e,t){super(),this.clipConfig=e,this.options=t,this.selectionRenderer=t.selectionRenderer,this.graphics=new R.Graphics,this.background=new R.Graphics,this.text=new R.Text,this.setupContainer()}async load(){this.setupGraphics(),this.updateVisualState()}setupContainer(){const e=this.getContainer();e.label=`clip-${this.options.trackIndex}-${this.options.clipIndex}`,e.interactive=!0,e.cursor="pointer",e.addChild(this.background),e.addChild(this.graphics),e.addChild(this.text)}setupGraphics(){this.text.style=new R.TextStyle({fontSize:Pe.TEXT_FONT_SIZE,fill:this.options.theme.timeline.toolbar.text,fontWeight:"bold",wordWrap:!1,fontFamily:"Arial, sans-serif"}),this.text.anchor.set(0,0),this.text.x=this.CLIP_PADDING,this.text.y=this.CLIP_PADDING}updateFromConfig(e){this.clipConfig=e,this.updateVisualState()}updateVisualState(){this.updatePosition(),this.updateAppearance(),this.updateSize(),this.updateText()}setVisualState(e){this.visualState={...this.visualState,...e},this.updateVisualState()}updatePosition(){const e=this.getContainer(),t=this.clipConfig.start||0;e.x=t*this.options.pixelsPerSecond,e.y=0}updateSize(){const e=this.getEffectiveWidth(),t=this.options.trackHeight;this.drawClipBackground(e,t),this.drawClipBorder(e,t)}getEffectiveWidth(){if(this.visualState.previewWidth!==void 0)return this.visualState.previewWidth;const t=(this.clipConfig.length||0)*this.options.pixelsPerSecond;return Math.max(Pe.MIN_WIDTH,t)}drawClipBackground(e,t){const i=this.getClipColor(),r=this.getStateStyles();this.background.clear(),this.background.roundRect(0,0,e,t,this.CORNER_RADIUS),this.background.fill({color:i,alpha:r.alpha})}drawClipBorder(e,t){const i=this.getStateStyles(),r=this.BORDER_WIDTH;this.graphics.clear(),this.graphics.roundRect(0,0,e,t,this.CORNER_RADIUS),this.graphics.stroke({width:r,color:i.borderColor}),this.updateSelectionState(e,t)}updateSelectionState(e,t){if(!this.selectionRenderer)return;const i=this.visualState.mode==="selected",r=this.getClipId();if(!i){this.selectionRenderer.clearSelection(r);return}const o=this.getContainer().toGlobal(new R.Point(0,0)),p=this.selectionRenderer.getOverlay().toLocal(o);this.selectionRenderer.renderSelection(r,{x:p.x,y:p.y,width:e,height:t,cornerRadius:this.CORNER_RADIUS,borderWidth:this.BORDER_WIDTH},i)}getClipColor(){const e=this.clipConfig.asset?.type,t=this.options.theme.timeline.clips;switch(e){case"video":return t.video;case"audio":return t.audio;case"image":return t.image;case"text":return t.text;case"rich-text":return t["rich-text"]||t.text;case"shape":return t.shape;case"html":return t.html;case"luma":return t.luma;default:return t.default}}updateAppearance(){const e=this.getContainer();e.alpha=this.visualState.mode==="dragging"?Pe.DRAG_OPACITY:Pe.DEFAULT_ALPHA}updateText(){const e=this.clipConfig.asset?Rh(this.clipConfig.asset):"Clip";this.text.text=e;const i=(this.clipConfig.length||0)*this.options.pixelsPerSecond-this.CLIP_PADDING*2;if(this.text.width>i){const r=i/this.text.width,n=Math.floor(e.length*r)-Pe.TEXT_TRUNCATE_SUFFIX_LENGTH;this.text.text=`${e.substring(0,Math.max(1,n))}...`}}getStateStyles(){const{theme:e}=this.options;switch(this.visualState.mode){case"dragging":return{alpha:Pe.DRAG_OPACITY,borderColor:e.timeline.tracks.border};case"resizing":return{alpha:Pe.RESIZE_OPACITY,borderColor:e.timeline.dropZone};case"selected":return{alpha:Pe.DEFAULT_ALPHA,borderColor:e.timeline.clips.selected};default:return{alpha:Pe.DEFAULT_ALPHA,borderColor:e.timeline.tracks.border}}}setSelected(e){this.setVisualState({mode:e?"selected":"normal"})}setDragging(e){this.setVisualState({mode:e?"dragging":"normal"})}setResizing(e){this.setVisualState({mode:e?"resizing":"normal",...e?{}:{previewWidth:void 0}})}setPreviewWidth(e){this.setVisualState({previewWidth:e||void 0})}setPixelsPerSecond(e){if(this.updateOptions({pixelsPerSecond:e}),this.visualState.mode==="selected"){const t=this.getEffectiveWidth(),i=this.options.trackHeight;this.updateSelectionState(t,i)}}updateOptions(e){this.options={...this.options,...e},this.updateVisualState()}getClipConfig(){return this.clipConfig}getOptions(){return{...this.options}}getVisualState(){return{...this.visualState}}getSelected(){return this.visualState.mode==="selected"}getClipId(){return`${this.options.trackIndex}-${this.options.clipIndex}`}getDragging(){return this.visualState.mode==="dragging"}getRightEdgeX(){const e=this.getEffectiveWidth();return(this.clipConfig.start||0)*this.options.pixelsPerSecond+e}update(e,t){if(this.visualState.mode==="selected"&&this.selectionRenderer){const r=this.getContainer().toGlobal(new R.Point(0,0));if(r.x!==this.lastGlobalX||r.y!==this.lastGlobalY){this.lastGlobalX=r.x,this.lastGlobalY=r.y;const n=this.getEffectiveWidth(),o=this.options.trackHeight;this.updateSelectionState(n,o)}}}draw(){}dispose(){this.selectionRenderer&&this.selectionRenderer.clearSelection(this.getClipId()),this.background.destroy(),this.graphics.destroy(),this.text.destroy()}}class Fh extends Je{clips=[];options;background;TRACK_PADDING=ri.PADDING;LABEL_PADDING=ri.LABEL_PADDING;constructor(e){super(),this.options=e,this.background=new R.Graphics,this.setupContainer()}async load(){this.updateTrackAppearance()}setupContainer(){const e=this.getContainer();e.label=`track-${this.options.trackIndex}`,e.addChild(this.background),e.y=this.options.trackIndex*this.options.trackHeight}updateTrackAppearance(){const{width:e}=this.options,t=this.options.trackHeight,{theme:i}=this.options;this.background.clear();const r=this.options.trackIndex%2===0?i.timeline.tracks.surface:i.timeline.tracks.surfaceAlt;this.background.rect(0,0,e,t),this.background.fill({color:r,alpha:ri.DEFAULT_OPACITY}),this.background.rect(0,0,e,t),this.background.stroke({width:ri.BORDER_WIDTH,color:i.timeline.tracks.border}),this.background.moveTo(0,t-1),this.background.lineTo(e,t-1),this.background.stroke({width:ri.BORDER_WIDTH,color:i.timeline.divider})}rebuildFromTrackData(e,t){this.options={...this.options,pixelsPerSecond:t},this.clearAllClips(),e.clips&&e.clips.forEach((i,r)=>{const n={pixelsPerSecond:this.options.pixelsPerSecond,trackHeight:this.options.trackHeight,trackIndex:this.options.trackIndex,clipIndex:r,theme:this.options.theme,selectionRenderer:this.options.selectionRenderer},o=new Oh(i,n);this.addClip(o)}),this.updateTrackAppearance()}async addClip(e){this.clips.push(e),await e.load(),this.getContainer().addChild(e.getContainer())}clearAllClips(){const e=this.getContainer();for(const t of this.clips)e.removeChild(t.getContainer()),t.dispose();this.clips=[]}removeClip(e){if(e>=0&&e<this.clips.length){const t=this.clips[e];this.getContainer().removeChild(t.getContainer()),t.dispose(),this.clips.splice(e,1)}}updateClip(e,t){e>=0&&e<this.clips.length&&this.clips[e].updateFromConfig(t)}setPixelsPerSecond(e){this.options={...this.options,pixelsPerSecond:e},this.clips.forEach(t=>{t.setPixelsPerSecond(e)})}setWidth(e){this.options={...this.options,width:e},this.updateTrackAppearance()}setTrackIndex(e){this.options={...this.options,trackIndex:e};const t=this.getContainer();t.y=e*this.options.trackHeight,this.clips.forEach((i,r)=>{i.updateOptions({trackIndex:e})})}selectClip(e){this.clearAllSelections(),e>=0&&e<this.clips.length&&this.clips[e].setSelected(!0)}clearAllSelections(){this.clips.forEach(e=>{e.setSelected(!1)})}getSelectedClip(){return this.clips.find(e=>e.getSelected())||null}getSelectedClipIndex(){return this.clips.findIndex(e=>e.getSelected())}getClips(){return[...this.clips]}getClip(e){return this.clips[e]||null}getClipCount(){return this.clips.length}getTrackIndex(){return this.options.trackIndex}getTrackHeight(){return this.options.trackHeight}getOptions(){return{...this.options}}findClipAtPosition(e,t){if(t<0||t>this.options.trackHeight)return null;const i=e/this.options.pixelsPerSecond;for(let r=0;r<this.clips.length;r+=1){const n=this.clips[r],o=n.getClipConfig(),a=o.start||0,p=a+(o.length||0);if(i>=a&&i<=p)return{clip:n,clipIndex:r}}return null}update(e,t){this.clips.forEach(i=>{i.update(e,t)})}draw(){this.clips.forEach(e=>{e.draw()})}dispose(){this.clearAllClips(),this.background.destroy()}}class Mh{constructor(e,t){this.overlay=e,this.theme=t}selectionGraphics=new Map;renderSelection(e,t,i){if(!i){this.clearSelection(e);return}let r=this.selectionGraphics.get(e);r||(r=new R.Graphics,r.label=`selection-border-${e}`,this.selectionGraphics.set(e,r),this.overlay.addChild(r)),r.position.set(t.x,t.y),r.clear(),r.setStrokeStyle({width:t.borderWidth*Pe.SELECTED_BORDER_MULTIPLIER,color:this.theme.timeline.clips.selected}),r.roundRect(0,0,t.width,t.height,t.cornerRadius),r.stroke()}clearSelection(e){const t=this.selectionGraphics.get(e);t&&(this.overlay.removeChild(t),t.destroy(),this.selectionGraphics.delete(e))}clearAllSelections(){this.selectionGraphics.forEach((e,t)=>{this.clearSelection(t)})}updateTheme(e){this.theme=e,this.selectionGraphics.forEach(t=>{t.clear()})}getOverlay(){return this.overlay}dispose(){this.clearAllSelections()}}class Lh{constructor(e,t,i,r,n){this.container=e,this.layout=t,this.theme=i,this.getPixelsPerSecond=r,this.getExtendedTimelineWidth=n,this.selectionOverlay=new R.Container,this.selectionOverlay.label="selectionOverlay",this.container.addChild(this.selectionOverlay),this.selectionRenderer=new Mh(this.selectionOverlay,this.theme)}visualTracks=[];selectionOverlay;selectionRenderer;async rebuildFromEdit(e,t){if(e?.timeline?.tracks){this.clearAllVisualState();for(let i=0;i<e.timeline.tracks.length;i+=1){const r=e.timeline.tracks[i],n={pixelsPerSecond:t,trackHeight:this.layout.trackHeight,trackIndex:i,width:this.getExtendedTimelineWidth(),theme:this.theme,selectionRenderer:this.selectionRenderer},o=new Fh(n);await o.load(),o.rebuildFromTrackData(r,t),this.container.addChild(o.getContainer()),this.visualTracks.push(o)}this.container.setChildIndex(this.selectionOverlay,this.container.children.length-1)}}clearAllVisualState(){this.visualTracks.forEach(e=>{this.container.removeChild(e.getContainer()),e.dispose()}),this.visualTracks=[],this.selectionRenderer.clearAllSelections()}updateVisualSelection(e,t){this.clearVisualSelection();const i=this.visualTracks[e];if(i){const r=i.getClip(t);r&&r.setSelected(!0)}}clearVisualSelection(){this.visualTracks.forEach(e=>{e.getClips().forEach(i=>{i.setSelected(!1)})})}findClipAtPosition(e,t){const i=Math.floor(t/this.layout.trackHeight);if(i<0||i>=this.visualTracks.length)return null;const r=this.visualTracks[i],n=t-i*this.layout.trackHeight,o=r.findClipAtPosition(e,n);return o?{trackIndex:i,clipIndex:o.clipIndex,clipConfig:o.clip.getClipConfig(),x:(o.clip.getClipConfig().start||0)*this.getPixelsPerSecond(),y:i*this.layout.trackHeight,width:(o.clip.getClipConfig().length||0)*this.getPixelsPerSecond(),height:this.layout.trackHeight}:null}updateTrackWidths(e){this.visualTracks.forEach(t=>{t.setWidth(e)})}getVisualTracks(){return this.visualTracks}updatePixelsPerSecond(e){this.visualTracks.forEach(t=>{t.setPixelsPerSecond(e)})}getSelectionOverlay(){return this.selectionOverlay}getSelectionRenderer(){return this.selectionRenderer}dispose(){this.clearAllVisualState(),this.selectionRenderer&&this.selectionRenderer.dispose(),this.selectionOverlay&&this.container&&(this.container.removeChild(this.selectionOverlay),this.selectionOverlay.destroy())}}class Bh{constructor(e,t){this.edit=e,this.callbacks=t}setupEventListeners(){this.edit.events.on("timeline:updated",this.handleTimelineUpdated.bind(this)),this.edit.events.on("clip:updated",this.handleClipUpdated.bind(this)),this.edit.events.on("clip:selected",this.handleClipSelected.bind(this)),this.edit.events.on("selection:cleared",this.handleSelectionCleared.bind(this)),this.edit.events.on("drag:started",this.handleDragStarted.bind(this)),this.edit.events.on("drag:ended",this.handleDragEnded.bind(this)),this.edit.events.on("track:created",this.handleTrackCreated.bind(this))}async handleTimelineUpdated(e){await this.callbacks.onEditChange(e.current)}async handleClipUpdated(){await this.callbacks.onEditChange()}handleClipSelected(e){this.callbacks.onClipSelected(e.trackIndex,e.clipIndex)}handleSelectionCleared(){this.callbacks.onSelectionCleared()}handleDragStarted(e){this.callbacks.onDragStarted(e.trackIndex,e.clipIndex)}handleDragEnded(){this.callbacks.onDragEnded()}async handleTrackCreated(){await this.callbacks.onEditChange()}handleSeek(e){this.callbacks.onSeek(e.time*1e3)}dispose(){this.edit.events.off("timeline:updated",this.handleTimelineUpdated.bind(this)),this.edit.events.off("clip:updated",this.handleClipUpdated.bind(this)),this.edit.events.off("clip:selected",this.handleClipSelected.bind(this)),this.edit.events.off("selection:cleared",this.handleSelectionCleared.bind(this)),this.edit.events.off("drag:started",this.handleDragStarted.bind(this)),this.edit.events.off("drag:ended",this.handleDragEnded.bind(this)),this.edit.events.off("track:created",this.handleTrackCreated.bind(this))}}class $h{constructor(e,t){this.options=e,this.onUpdate=t}app;trackLayer;overlayLayer;animationFrameId=null;async initializePixiApp(){this.app=new R.Application,await this.app.init({width:this.options.width,height:this.options.height,backgroundColor:this.options.backgroundColor,antialias:this.options.antialias,resolution:this.options.resolution,autoDensity:!0,preference:"webgl"});const e=document.querySelector("[data-shotstack-timeline]");if(!e)throw new Error("Timeline container element [data-shotstack-timeline] not found");e.appendChild(this.app.canvas)}async setupRenderLayers(){this.trackLayer=new R.Container,this.overlayLayer=new R.Container,this.trackLayer.label="track-layer",this.overlayLayer.label="overlay-layer",this.app.stage.addChild(this.trackLayer),this.app.stage.addChild(this.overlayLayer)}startAnimationLoop(){let e=performance.now();const t=i=>{const r=i-e;e=i;const n=r/16.667;this.onUpdate(n,r),this.draw(),this.animationFrameId=requestAnimationFrame(t)};this.animationFrameId=requestAnimationFrame(t)}draw(){this.app.render()}render(){this.app.render()}updateBackgroundColor(e){this.app&&(this.app.renderer.background.color=e)}getApp(){return this.app}getStage(){return this.app.stage}getTrackLayer(){return this.trackLayer}getOverlayLayer(){return this.overlayLayer}dispose(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.app&&this.app.destroy(!0)}}const $t={RULER:{DEFAULT_HEIGHT:40,LABEL_FONT_SIZE:10,LABEL_PADDING_X:2},PLAYHEAD:{LINE_WIDTH:2},SCROLL:{HORIZONTAL_SPEED:2,VERTICAL_SPEED:.5}};class An extends Je{events;rulerContainer;rulerBackground;timeMarkers;timeLabels;pixelsPerSecond;timelineDuration;rulerHeight;theme;constructor(e){super(),this.events=new Kt,this.pixelsPerSecond=e.pixelsPerSecond,this.timelineDuration=e.timelineDuration,this.rulerHeight=e.rulerHeight??$t.RULER.DEFAULT_HEIGHT,this.theme=e.theme,this.rulerContainer=new R.Container,this.rulerBackground=new R.Graphics,this.timeMarkers=new R.Graphics,this.timeLabels=new R.Container}async load(){this.setupRuler(),this.draw()}setupRuler(){this.rulerContainer.label="ruler",this.rulerContainer.addChild(this.rulerBackground),this.rulerContainer.addChild(this.timeMarkers),this.rulerContainer.addChild(this.timeLabels),this.rulerContainer.eventMode="static",this.rulerContainer.cursor="pointer",this.rulerContainer.on("pointerdown",this.onRulerPointerDown.bind(this)),this.getContainer().addChild(this.rulerContainer)}drawRulerBackground(){this.rulerBackground.clear();const e=this.calculateRulerWidth(),t=this.theme?.timeline.ruler.background||4210752,i=this.theme?.timeline.tracks.border||6316128;this.rulerBackground.rect(0,0,e,this.rulerHeight),this.rulerBackground.fill(t),this.rulerBackground.rect(0,this.rulerHeight-1,e,1),this.rulerBackground.fill(i)}drawTimeMarkers(){this.timeMarkers.clear();const e=this.getTimeInterval(),t=this.getVisibleDuration(),i=this.theme?.timeline.ruler.markers||6710886,r=this.rulerHeight*.5;let n=4;e===10?n=9:(e===30||e===60)&&(n=5);const o=e/(n+1);for(let a=0;a<=t;a+=e)for(let p=1;p<=n;p+=1){const m=a+p*o;if(m<=t){const d=m*this.pixelsPerSecond;this.timeMarkers.circle(d,r,1.5),this.timeMarkers.fill(i)}}}drawTimeLabels(){this.timeLabels.removeChildren();const e=this.getTimeInterval(),t=this.getVisibleDuration(),i=this.theme?.timeline.ruler.text||16777215,r={fontSize:$t.RULER.LABEL_FONT_SIZE,fill:i,fontFamily:"Arial"};for(let n=0;n<=t;n+=e){const o=new R.Text({text:this.formatTime(n),style:r}),a=n*this.pixelsPerSecond;n===0?(o.anchor.set(0,.5),o.x=a+$t.RULER.LABEL_PADDING_X):(o.anchor.set(.5,.5),o.x=a),o.y=this.rulerHeight*.5,this.timeLabels.addChild(o)}}onRulerPointerDown(e){const t=this.rulerContainer.toLocal(e.global),i=Math.max(0,t.x/this.pixelsPerSecond);this.events.emit("ruler:seeked",{time:i})}updateRuler(e,t){this.pixelsPerSecond=e,this.timelineDuration=t,this.draw()}update(e,t){}draw(){this.drawRulerBackground(),this.drawTimeMarkers(),this.drawTimeLabels()}dispose(){this.timeLabels.removeChildren(),this.rulerContainer.removeChildren(),this.events.clear("*")}getViewportWidth(){return this.getContainer().parent?.width||800}calculateRulerWidth(){const e=this.timelineDuration*this.pixelsPerSecond;return Math.max(e,this.getViewportWidth())}getVisibleDuration(){return Math.max(this.timelineDuration,this.getViewportWidth()/this.pixelsPerSecond)}getTimeInterval(){const e=[1,5,10,30,60,120,300,600],t=80;for(const i of e)if(i*this.pixelsPerSecond>=t)return i;return Math.ceil(this.getVisibleDuration()/10)}formatTime(e){if(e===0)return"0s";const t=Math.floor(e/60),i=e%60;if(e<60)return`${e}s`;if(i===0)return`${t}m`;const r=i.toString().padStart(2,"0");return`${t}:${r}`}}class In extends Je{constructor(e){super(),this.options=e,this.graphics=new R.Graphics}events=new Kt;graphics;currentTime=0;isDragging=!1;async load(){this.setupPlayhead(),this.draw()}setupPlayhead(){this.graphics.label="playhead",this.graphics.eventMode="static",this.graphics.cursor="pointer",this.graphics.on("pointerdown",this.onPointerDown.bind(this)).on("pointermove",this.onPointerMove.bind(this)).on("pointerup",this.onPointerUp.bind(this)).on("pointerupoutside",this.onPointerUp.bind(this)),this.getContainer().addChild(this.graphics)}drawPlayhead(){const e=this.currentTime*this.options.pixelsPerSecond,t=this.options.theme?.timeline.playhead??16729156,i=$t.PLAYHEAD.LINE_WIDTH,r=e+i/2;this.graphics.clear(),this.graphics.fill(t),this.graphics.rect(e,0,i,this.options.timelineHeight);const n=8;this.graphics.moveTo(r,10),this.graphics.lineTo(r-n,0),this.graphics.lineTo(r+n,0),this.graphics.closePath(),this.graphics.fill()}onPointerDown(e){this.isDragging=!0,this.graphics.cursor="grabbing",this.updateTimeFromPointer(e)}onPointerMove(e){this.isDragging&&this.updateTimeFromPointer(e)}onPointerUp(){this.isDragging=!1,this.graphics.cursor="pointer"}updateTimeFromPointer(e){if(!this.graphics.parent)return;const t=this.graphics.parent.toLocal(e.global),i=Math.max(0,t.x/this.options.pixelsPerSecond);this.setTime(i),this.events.emit("playhead:seeked",{time:i})}setTime(e){this.currentTime=e,this.draw(),this.events.emit("playhead:timeChanged",{time:e})}getTime(){return this.currentTime}updatePlayhead(e,t){this.options.pixelsPerSecond=e,this.options.timelineHeight=t,this.draw()}update(){}draw(){this.drawPlayhead()}dispose(){this.graphics.removeAllListeners(),this.events.clear("*")}}class Dh{events;timeline;abortController;scrollX=0;scrollY=0;constructor(e){this.events=new Kt,this.timeline=e.timeline}async initialize(){this.setupEventListeners()}setupEventListeners(){this.abortController=new AbortController;const{canvas:e}=this.timeline.getPixiApp();e.addEventListener("wheel",this.handleWheel.bind(this),{passive:!1,signal:this.abortController.signal})}handleWheel(e){if(e.preventDefault(),e.ctrlKey||e.metaKey){this.handleZoom(e);return}this.handleScroll(e)}handleZoom(e){const t=e.deltaY>0?"out":"in",i=this.timeline.getPlayheadTime(),r=this.timeline.getActualEditDuration();t==="in"?this.timeline.zoomIn():this.timeline.zoomOut();const n=this.timeline.getOptions().pixelsPerSecond||50,o=i*n,a=this.timeline.getOptions().width||800,m=this.timeline.timeRange.endTime*n,d=r*n,l=this.calculateZoomScrollPosition({playheadXAfterZoom:o,viewportWidth:a,contentWidth:m,maxPlayheadX:d,actualEditDuration:r,playheadTime:i});this.scrollX=l,this.timeline.setScroll(this.scrollX,this.scrollY);const c=o-l;this.events.emit("zoom",{pixelsPerSecond:n,focusX:c,focusTime:i})}handleScroll(e){let{deltaX:t}=e,{deltaY:i}=e;e.shiftKey&&(t=i,i=0);const r=$t.SCROLL.HORIZONTAL_SPEED,n=$t.SCROLL.VERTICAL_SPEED;this.scrollX+=t*r,this.scrollY+=i*n,this.scrollX=this.clampScrollX(this.scrollX),this.scrollY=this.clampScrollY(this.scrollY),this.timeline.setScroll(this.scrollX,this.scrollY),this.events.emit("scroll",{x:this.scrollX,y:this.scrollY})}setScroll(e,t){this.scrollX=this.clampScrollX(e),this.scrollY=this.clampScrollY(t),this.timeline.setScroll(this.scrollX,this.scrollY),this.events.emit("scroll",{x:this.scrollX,y:this.scrollY})}clampScrollX(e){const t=this.timeline.getExtendedTimelineWidth(),i=this.timeline.getOptions().width||0,r=Math.max(0,t-i);return Math.max(0,Math.min(e,r))}clampScrollY(e){const t=this.timeline.getLayout(),i=this.timeline.getVisualTracks().length,r=this.timeline.getOptions().height||0,n=Math.max(0,i*t.trackHeight-(r-t.rulerHeight));return Math.max(0,Math.min(e,n))}getScroll(){return{x:this.scrollX,y:this.scrollY}}calculateZoomScrollPosition(e){const{playheadXAfterZoom:t,viewportWidth:i,contentWidth:r,maxPlayheadX:n,actualEditDuration:o,playheadTime:a}=e,p=t-i/2,m=Math.max(0,r-i);let d;const l=p+i,c=Math.max(0,n-i);r<=i||p<0?d=0:l>n&&a<=o?d=Math.min(c,m):p>m?d=m:d=p;const u=t-d;return(u<0||u>i)&&(t>r-i?d=Math.max(0,t-i+50):d=Math.max(0,t-50),d=Math.max(0,Math.min(d,m))),d}dispose(){this.abortController&&(this.abortController.abort(),this.abortController=void 0),this.events.clear("*")}}const ue={BUTTON_SIZE:24,BUTTON_HOVER_PADDING:4,BORDER_RADIUS:4,TEXT_SPACING:16,EDGE_MARGIN:10,FRAME_TIME_MS:16.67,ICON:{PLAY:{LEFT:6,TOP:4,RIGHT:18,MIDDLE:12,BOTTOM:20},PAUSE:{RECT1_X:6,RECT2_X:14,TOP:4,WIDTH:4,HEIGHT:16},FRAME_STEP:{TRIANGLE1:{BACK:{LEFT:11,RIGHT:3,MIDDLE:12},FORWARD:{LEFT:4,RIGHT:12,MIDDLE:12}},TRIANGLE2:{BACK:{LEFT:20,RIGHT:12,MIDDLE:12},FORWARD:{LEFT:13,RIGHT:21,MIDDLE:12}},TOP:4,BOTTOM:20}},CUT_BUTTON:{WIDTH:60,HEIGHT:24,FONT_SIZE:12},TIME_DISPLAY:{FONT_SIZE:14,FONT_FAMILY:"monospace"},HOVER_ANIMATION_ALPHA:1,ACTIVE_ANIMATION_ALPHA:.3,DIVIDER_ALPHA:.5};class Ii{static createIcon(e,t,i){const r=i?i/ue.BUTTON_SIZE:1;switch(e){case"play":return this.createPlayIcon(t,r);case"pause":return this.createPauseIcon(t,r);case"frame-back":return this.createFrameBackIcon(t,r);case"frame-forward":return this.createFrameForwardIcon(t,r);default:throw new Error(`Unknown icon type: ${e}`)}}static createPlayIcon(e,t=1){const i=new R.Graphics,{PLAY:r}=ue.ICON;return i.fill({color:e.timeline.toolbar.icon}),i.moveTo(r.LEFT*t,r.TOP*t),i.lineTo(r.RIGHT*t,r.MIDDLE*t),i.lineTo(r.LEFT*t,r.BOTTOM*t),i.closePath(),i.fill(),i}static createPauseIcon(e,t=1){const i=new R.Graphics,{PAUSE:r}=ue.ICON;return i.fill({color:e.timeline.toolbar.icon}),i.rect(r.RECT1_X*t,r.TOP*t,r.WIDTH*t,r.HEIGHT*t),i.rect(r.RECT2_X*t,r.TOP*t,r.WIDTH*t,r.HEIGHT*t),i.fill(),i}static createFrameBackIcon(e,t=1){const i=new R.Graphics,{FRAME_STEP:r}=ue.ICON;return i.fill({color:e.timeline.toolbar.icon}),i.moveTo(r.TRIANGLE1.BACK.LEFT*t,r.TOP*t),i.lineTo(r.TRIANGLE1.BACK.RIGHT*t,r.TRIANGLE1.BACK.MIDDLE*t),i.lineTo(r.TRIANGLE1.BACK.LEFT*t,r.BOTTOM*t),i.closePath(),i.moveTo(r.TRIANGLE2.BACK.LEFT*t,r.TOP*t),i.lineTo(r.TRIANGLE2.BACK.RIGHT*t,r.TRIANGLE2.BACK.MIDDLE*t),i.lineTo(r.TRIANGLE2.BACK.LEFT*t,r.BOTTOM*t),i.closePath(),i.fill(),i}static createFrameForwardIcon(e,t=1){const i=new R.Graphics,{FRAME_STEP:r}=ue.ICON;return i.fill({color:e.timeline.toolbar.icon}),i.moveTo(r.TRIANGLE1.FORWARD.LEFT*t,r.TOP*t),i.lineTo(r.TRIANGLE1.FORWARD.RIGHT*t,r.TRIANGLE1.FORWARD.MIDDLE*t),i.lineTo(r.TRIANGLE1.FORWARD.LEFT*t,r.BOTTOM*t),i.closePath(),i.moveTo(r.TRIANGLE2.FORWARD.LEFT*t,r.TOP*t),i.lineTo(r.TRIANGLE2.FORWARD.RIGHT*t,r.TRIANGLE2.FORWARD.MIDDLE*t),i.lineTo(r.TRIANGLE2.FORWARD.LEFT*t,r.BOTTOM*t),i.closePath(),i.fill(),i}static updateIconColor(e,t){const i=e.getBounds();e.clear(),e.position.set(i.x,i.y)}}class Pn extends R.Container{background;hoverBackground;icon;alternateIcon;state={isHovering:!1,isPressed:!1,isActive:!1};size;theme;onClick;constructor(e){super(),this.size=e.size||ue.BUTTON_SIZE,this.theme=e.theme,this.onClick=e.onClick,this.eventMode="static",this.cursor="pointer",this.background=new R.Graphics,this.addChild(this.background),this.hoverBackground=new R.Graphics,this.addChild(this.hoverBackground);const i=this.size*.6,r=(this.size-i)/2;e.iconType&&(this.icon=Ii.createIcon(e.iconType,this.theme,i),this.icon.position.set(r,r),this.addChild(this.icon)),e.alternateIconType&&(this.alternateIcon=Ii.createIcon(e.alternateIconType,this.theme,i),this.alternateIcon.position.set(r,r),this.alternateIcon.visible=!1,this.addChild(this.alternateIcon)),this.setupEventListeners(),this.updateVisuals()}setupEventListeners(){this.on("pointerdown",this.handlePointerDown,this),this.on("pointerup",this.handlePointerUp,this),this.on("pointerupoutside",this.handlePointerUp,this),this.on("pointerover",this.handlePointerOver,this),this.on("pointerout",this.handlePointerOut,this)}handlePointerDown(){this.state.isPressed=!0,this.updateVisuals()}handlePointerUp(){this.state.isPressed&&this.onClick(),this.state.isPressed=!1,this.updateVisuals()}handlePointerOver(){this.state.isHovering=!0,this.updateVisuals()}handlePointerOut(){this.state.isHovering=!1,this.state.isPressed=!1,this.updateVisuals()}updateVisuals(){const e=ue.BUTTON_HOVER_PADDING,t=this.size/2;this.background.clear(),this.background.circle(t,t,t),this.background.fill({color:this.theme.timeline.toolbar.surface,alpha:.8}),this.hoverBackground.clear(),this.hoverBackground.circle(t,t,t+e),this.state.isPressed?this.hoverBackground.fill({color:this.theme.timeline.toolbar.active,alpha:ue.ACTIVE_ANIMATION_ALPHA}):this.state.isHovering?this.hoverBackground.fill({color:this.theme.timeline.toolbar.hover,alpha:ue.HOVER_ANIMATION_ALPHA}):this.hoverBackground.fill({color:this.theme.timeline.toolbar.hover,alpha:0})}setActive(e){this.state.isActive=e,this.icon&&this.alternateIcon&&(this.icon.visible=!e,this.alternateIcon.visible=e)}updateTheme(e){this.theme=e;const i=this.size*.6,r=(this.size-i)/2;if(this.icon){const n=this.getIconType(this.icon);n&&(this.removeChild(this.icon),this.icon=Ii.createIcon(n,e,i),this.icon.position.set(r,r),this.addChild(this.icon))}if(this.alternateIcon){const n=this.getIconType(this.alternateIcon);n&&(this.removeChild(this.alternateIcon),this.alternateIcon=Ii.createIcon(n,e,i),this.alternateIcon.position.set(r,r),this.alternateIcon.visible=this.state.isActive,this.addChild(this.alternateIcon))}this.updateVisuals()}getIconType(e){return null}destroy(){this.removeAllListeners(),super.destroy()}}class zh extends R.Container{edit;theme;toolbarHeight;frameBackButton;playPauseButton;frameForwardButton;constructor(e,t,i){super(),this.edit=e,this.theme=t,this.toolbarHeight=i||36,this.createButtons(),this.subscribeToEditEvents(),this.updatePlayPauseState()}createButtons(){const e=this.calculateButtonSizes(),t=(e.playButton-e.regularButton)/2,i=(r,n,o,a)=>new Pn({iconType:r,onClick:n,tooltip:o,theme:this.theme,size:a});this.frameBackButton=i("frame-back",()=>this.handleFrameBack(),"Previous frame",e.regularButton),this.frameBackButton.position.set(0,t),this.playPauseButton=new Pn({iconType:"play",alternateIconType:"pause",onClick:()=>this.handlePlayPause(),tooltip:"Play/Pause",theme:this.theme,size:e.playButton}),this.playPauseButton.position.set(e.regularButton+e.spacing,0),this.frameForwardButton=i("frame-forward",()=>this.handleFrameForward(),"Next frame",e.regularButton),this.frameForwardButton.position.set(e.regularButton+e.spacing+e.playButton+e.spacing,t),this.addChild(this.frameBackButton,this.playPauseButton,this.frameForwardButton)}calculateButtonSizes(){const e=Math.round(this.toolbarHeight*.5);return{regularButton:e,playButton:Math.round(e*1.5),spacing:Math.round(this.toolbarHeight*.15)}}handleFrameBack(){this.edit.seek(this.edit.playbackTime-ue.FRAME_TIME_MS)}handlePlayPause(){this.edit.isPlaying?this.edit.pause():this.edit.play()}handleFrameForward(){this.edit.seek(this.edit.playbackTime+ue.FRAME_TIME_MS)}subscribeToEditEvents(){this.edit.events.on("playback:play",this.updatePlayPauseState),this.edit.events.on("playback:pause",this.updatePlayPauseState)}updatePlayPauseState=()=>{this.playPauseButton.setActive(this.edit.isPlaying)};update(){}resize(e){}updateTheme(e){this.theme=e,this.frameBackButton.updateTheme(e),this.playPauseButton.updateTheme(e),this.frameForwardButton.updateTheme(e)}destroy(){this.edit.events.off("playback:play",this.updatePlayPauseState),this.edit.events.off("playback:pause",this.updatePlayPauseState),this.frameBackButton.destroy(),this.playPauseButton.destroy(),this.frameForwardButton.destroy(),super.destroy()}getWidth(){const e=this.calculateButtonSizes();return e.regularButton*2+e.playButton+e.spacing*2}}class Hh extends R.Container{edit;theme;timeText;formatOptions;constructor(e,t,i={}){super(),this.edit=e,this.theme=t,this.formatOptions={showMilliseconds:!1,showHours:!1,...i},this.createDisplay(),this.subscribeToEditEvents(),this.updateTimeDisplay()}createDisplay(){const e=new R.TextStyle({fontFamily:ue.TIME_DISPLAY.FONT_FAMILY,fontSize:ue.TIME_DISPLAY.FONT_SIZE,fill:this.theme.timeline.toolbar.text});this.timeText=new R.Text("0:00 / 0:00",e),this.timeText.anchor.set(0,.5),this.addChild(this.timeText)}subscribeToEditEvents(){this.edit.events.on("playback:time",this.updateTimeDisplay),this.edit.events.on("duration:changed",this.updateTimeDisplay)}updateTimeDisplay=()=>{const e=this.formatTime(this.edit.playbackTime/1e3),t=this.formatTime(this.edit.getTotalDuration()/1e3);this.timeText.text=`${e} / ${t}`};formatTime(e){const t=Math.floor(e/3600),i=Math.floor(e%3600/60),r=Math.floor(e%60),n=Math.floor(e%1*10);let o="";return this.formatOptions.showHours||t>0?o+=`${t}:${i.toString().padStart(2,"0")}`:o+=`${i}`,o+=`:${r.toString().padStart(2,"0")}`,this.formatOptions.showMilliseconds?o+=`.${n}`:o+=`.${n}`,o}update(){this.updateTimeDisplay()}resize(e){}updateTheme(e){this.theme=e,this.timeText.style.fill=e.timeline.toolbar.text}destroy(){this.edit.events.off("playback:time",this.updateTimeDisplay),this.edit.events.off("duration:changed",this.updateTimeDisplay),super.destroy()}getWidth(){return this.timeText.width}}class Nh extends R.Container{edit;theme;cutButton;cutButtonBackground;cutButtonText;constructor(e,t){super(),this.edit=e,this.theme=t,this.createCutButton()}createCutButton(){this.cutButton=new R.Container,this.cutButton.eventMode="static",this.cutButton.cursor="pointer";const{WIDTH:e,HEIGHT:t,FONT_SIZE:i}=ue.CUT_BUTTON;this.cutButtonBackground=new R.Graphics,this.cutButtonBackground.roundRect(0,0,e,t,ue.BORDER_RADIUS),this.cutButtonBackground.fill({color:this.theme.timeline.toolbar.surface||4473924}),this.cutButtonBackground.stroke({color:this.theme.timeline.tracks.border||6710886,width:1}),this.cutButton.addChild(this.cutButtonBackground);const r=new R.TextStyle({fontFamily:"Arial",fontSize:i,fill:this.theme.timeline.toolbar.text||16777215});this.cutButtonText=new R.Text("SPLIT",r),this.cutButtonText.anchor.set(.5),this.cutButtonText.position.set(e/2,t/2),this.cutButton.addChild(this.cutButtonText),this.cutButton.on("click",this.handleCutClick,this),this.cutButton.on("pointerdown",this.handlePointerDown,this),this.cutButton.on("pointerover",this.handlePointerOver,this),this.cutButton.on("pointerout",this.handlePointerOut,this),this.addChild(this.cutButton)}handleCutClick=e=>{e.stopPropagation(),this.performCutClip()};handlePointerDown=e=>{e.stopPropagation(),this.updateButtonVisual(!0,!1)};handlePointerOver=()=>{this.updateButtonVisual(!1,!0)};handlePointerOut=()=>{this.updateButtonVisual(!1,!1)};updateButtonVisual(e,t){this.cutButtonBackground.clear(),this.cutButtonBackground.roundRect(0,0,ue.CUT_BUTTON.WIDTH,ue.CUT_BUTTON.HEIGHT,ue.BORDER_RADIUS);let i=this.theme.timeline.toolbar.surface||4473924;const r=1;e?i=this.theme.timeline.toolbar.active||3355443:t&&(i=this.theme.timeline.toolbar.hover||5592405),this.cutButtonBackground.fill({color:i,alpha:r}),this.cutButtonBackground.stroke({color:this.theme.timeline.tracks.border||6710886,width:1})}performCutClip(){const e=this.edit.getSelectedClipInfo();if(!e)return;const{trackIndex:t,clipIndex:i}=e,r=this.edit.playbackTime/1e3;this.edit.splitClip(t,i,r)}update(){const e=this.edit.getSelectedClipInfo()!==null;this.cutButton.alpha=e?1:.5,this.cutButton.eventMode=e?"static":"none",this.cutButton.cursor=e?"pointer":"default"}resize(e){}updateTheme(e){this.theme=e,this.updateButtonVisual(!1,!1),this.cutButtonText.style.fill=e.timeline.toolbar.text||16777215}destroy(){this.cutButton.removeAllListeners(),super.destroy()}getWidth(){return ue.CUT_BUTTON.WIDTH}}class Uh{config;constructor(e,t){this.config={width:e,height:t,buttonSize:Math.round(t*.5),buttonSpacing:Math.round(t*.15),edgeMargin:ue.EDGE_MARGIN}}getPlaybackControlsPosition(){const e=this.calculatePlaybackControlsWidth(),t=(this.config.width-e)/2,i=(this.config.height-this.getMaxButtonHeight())/2;return{x:t,y:i}}getMaxButtonHeight(){const e=this.config.buttonSize;return Math.round(e*1.5)}getTimeDisplayPosition(e){const i=(this.config.width-e)/2+e+ue.TEXT_SPACING,r=this.config.height/2;return{x:i,y:r}}getEditControlsPosition(){const e=this.config.width-ue.CUT_BUTTON.WIDTH-this.config.edgeMargin,t=(this.config.height-ue.CUT_BUTTON.HEIGHT)/2;return{x:e,y:t}}calculatePlaybackControlsWidth(){const e=this.config.buttonSize,t=Math.round(e*1.5);return e*2+t+this.config.buttonSpacing*2}updateWidth(e){this.config.width=e}getConfig(){return{...this.config}}}class jh extends R.Container{constructor(e,t,i,r){super(),this.edit=e,this.theme=t,this.layout=i,this.toolbarWidth=r,this.toolbarHeight=i.toolbarHeight,this.position.set(0,i.toolbarY),this.toolbarLayout=new Uh(r,this.toolbarHeight),this.createBackground(),this.createComponents(),this.positionComponents(),this.subscribeToEditEvents()}background;playbackControls;timeDisplay;editControls;toolbarLayout;toolbarWidth;toolbarHeight;get width(){return this.toolbarWidth}get height(){return this.toolbarHeight}createBackground(){this.background=new R.Graphics,this.drawBackground(),this.addChild(this.background)}drawBackground(){this.background.clear(),this.background.rect(0,0,this.toolbarWidth,this.toolbarHeight),this.background.fill({color:this.theme.timeline.toolbar.background}),this.background.setStrokeStyle({width:1,color:this.theme.timeline.toolbar.divider,alpha:ue.DIVIDER_ALPHA}),this.background.moveTo(0,this.toolbarHeight-.5),this.background.lineTo(this.toolbarWidth,this.toolbarHeight-.5),this.background.stroke()}createComponents(){this.playbackControls=new zh(this.edit,this.theme,this.toolbarHeight),this.addChild(this.playbackControls),this.timeDisplay=new Hh(this.edit,this.theme),this.addChild(this.timeDisplay),this.editControls=new Nh(this.edit,this.theme),this.addChild(this.editControls)}positionComponents(){const e=this.toolbarLayout.getPlaybackControlsPosition();this.playbackControls.position.set(e.x,e.y);const t=this.toolbarLayout.getTimeDisplayPosition(this.playbackControls.getWidth());this.timeDisplay.position.set(t.x,t.y);const i=this.toolbarLayout.getEditControlsPosition();this.editControls.position.set(i.x,i.y)}subscribeToEditEvents(){this.edit.events.on("clip:selected",this.updateEditControls),this.edit.events.on("selection:cleared",this.updateEditControls)}updateEditControls=()=>{this.editControls.update()};resize(e){this.toolbarWidth=e,this.toolbarLayout.updateWidth(e),this.drawBackground(),this.positionComponents(),this.playbackControls.resize(e),this.timeDisplay.resize(e),this.editControls.resize(e)}updateTheme(e){this.theme=e,this.drawBackground(),this.playbackControls.updateTheme(e),this.timeDisplay.updateTheme(e),this.editControls.updateTheme(e)}updateTimeDisplay=()=>{this.timeDisplay.update()};destroy(){this.edit.events.off("clip:selected",this.updateEditControls),this.edit.events.off("selection:cleared",this.updateEditControls),this.playbackControls.destroy(),this.timeDisplay.destroy(),this.editControls.destroy(),super.destroy()}}class Vh{constructor(e,t,i,r,n,o){this.edit=e,this.layout=t,this.renderer=i,this.viewportManager=r,this.eventHandler=n,this.getTimelineContext=o}toolbar;ruler;playhead;scroll;async setupTimelineFeatures(e,t,i,r,n){this.toolbar=new jh(this.edit,e,this.layout,i),this.renderer.getStage().addChild(this.toolbar);const o={pixelsPerSecond:t,timelineDuration:n,rulerHeight:this.layout.rulerHeight,theme:e};this.ruler=new An(o),await this.ruler.load(),this.ruler.getContainer().y=this.layout.rulerY,this.viewportManager.getRulerViewport().addChild(this.ruler.getContainer()),this.ruler.events.on("ruler:seeked",this.eventHandler.handleSeek.bind(this.eventHandler));const a={pixelsPerSecond:t,timelineHeight:r,theme:e};this.playhead=new In(a),await this.playhead.load(),this.playhead.getContainer().y=this.layout.rulerY,this.viewportManager.getPlayheadContainer().addChild(this.playhead.getContainer()),this.playhead.events.on("playhead:seeked",this.eventHandler.handleSeek.bind(this.eventHandler));const p={timeline:this.getTimelineContext()};this.scroll=new Dh(p),await this.scroll.initialize(),this.viewportManager.updateViewportTransform()}recreateTimelineFeatures(e,t,i,r){if(this.ruler){this.ruler.dispose();const{rulerHeight:n}=this.layout,o={pixelsPerSecond:t,timelineDuration:r,rulerHeight:n,theme:e};this.ruler=new An(o),this.ruler.load(),this.ruler.getContainer().y=this.layout.rulerY,this.viewportManager.getRulerViewport().addChild(this.ruler.getContainer()),this.ruler.events.on("ruler:seeked",this.eventHandler.handleSeek.bind(this.eventHandler))}if(this.playhead){this.playhead.dispose();const n={pixelsPerSecond:t,timelineHeight:i,theme:e};this.playhead=new In(n),this.playhead.load(),this.playhead.getContainer().y=this.layout.rulerY,this.viewportManager.getPlayheadContainer().addChild(this.playhead.getContainer()),this.playhead.events.on("playhead:seeked",this.eventHandler.handleSeek.bind(this.eventHandler))}}updateRuler(e,t){this.ruler.updateRuler(e,t)}updatePlayhead(e,t){this.playhead&&this.playhead.updatePlayhead(e,t)}getFeatures(){return{toolbar:this.toolbar,ruler:this.ruler,playhead:this.playhead,scroll:this.scroll}}getToolbar(){return this.toolbar}getPlayhead(){return this.playhead}dispose(){this.toolbar&&this.toolbar.destroy(),this.ruler&&this.ruler.dispose(),this.playhead&&this.playhead.dispose(),this.scroll&&this.scroll.dispose()}}class Ye{constructor(e,t){this.options=e,this.theme=t,this.config=this.calculateLayout()}static TOOLBAR_HEIGHT_RATIO=Le.TOOLBAR_HEIGHT_RATIO;static RULER_HEIGHT_RATIO=Le.RULER_HEIGHT_RATIO;static TOOLBAR_HEIGHT_DEFAULT=Le.TOOLBAR_HEIGHT_DEFAULT;static RULER_HEIGHT_DEFAULT=Le.RULER_HEIGHT_DEFAULT;static TRACK_HEIGHT_DEFAULT=Le.TRACK_HEIGHT_DEFAULT;static CLIP_PADDING=Le.CLIP_PADDING;static BORDER_WIDTH=Le.BORDER_WIDTH;static CORNER_RADIUS=Le.CORNER_RADIUS;static LABEL_PADDING=Le.LABEL_PADDING;static TRACK_PADDING=Le.TRACK_PADDING;config;calculateLayout(){const e=this.options.height;let t=this.theme?.timeline.toolbar.height||Math.round(e*Ye.TOOLBAR_HEIGHT_RATIO),i=this.theme?.timeline.ruler.height||Math.round(e*Ye.RULER_HEIGHT_RATIO);t=Math.max(t,Ye.TOOLBAR_HEIGHT_DEFAULT),i=Math.max(i,Ye.RULER_HEIGHT_DEFAULT);const{trackHeight:r}=this.options;return{toolbarHeight:t,rulerHeight:i,trackHeight:r,toolbarY:0,rulerY:t,tracksY:t+i,gridY:t+i,playheadY:t,viewportY:t+i}}get toolbarHeight(){return this.config.toolbarHeight}get toolbarY(){return this.config.toolbarY}get rulerHeight(){return this.config.rulerHeight}get trackHeight(){return this.config.trackHeight}get rulerY(){return this.config.rulerY}get tracksY(){return this.config.tracksY}get gridY(){return this.config.gridY}get playheadY(){return this.config.playheadY}get viewportY(){return this.config.viewportY}positionTrack(e){return e*this.trackHeight}positionClip(e){return e*this.options.pixelsPerSecond}calculateClipWidth(e){return Math.max(Le.MIN_CLIP_WIDTH,e*this.options.pixelsPerSecond)}calculateDropPosition(e,t){const i=t-this.tracksY,r=Math.floor(i/this.trackHeight),n=Math.max(0,e/this.options.pixelsPerSecond);return{track:Math.max(0,r),time:n,x:e,y:i}}getTrackAtY(e){const t=e-this.tracksY;return Math.floor(t/this.trackHeight)}getTimeAtX(e){return e/this.options.pixelsPerSecond}getXAtTime(e){return e*this.options.pixelsPerSecond}getYAtTrack(e){return this.tracksY+e*this.trackHeight}getGridHeight(){return this.options.height-this.toolbarHeight-this.rulerHeight}getRulerWidth(){return this.options.width}getGridWidth(){return this.options.width}calculateViewportPosition(e,t){return{x:-e,y:this.viewportY-t}}updateOptions(e,t){this.options=e,this.theme=t,this.config=this.calculateLayout()}isPointInToolbar(e,t){return t>=this.toolbarY&&t<=this.toolbarY+this.toolbarHeight}isPointInRuler(e,t){return t>=this.rulerY&&t<=this.rulerY+this.rulerHeight}isPointInTracks(e,t){return t>=this.tracksY&&t<=this.options.height}getVisibleTrackRange(e,t){const i=e,r=Math.floor(i/this.trackHeight),n=Math.ceil((i+t)/this.trackHeight);return{start:Math.max(0,r),end:Math.max(0,n)}}}class Ge{constructor(e,t,i,r){this.layout=i,this.onResize=r,this.width=e.width,this.height=e.height,this.pixelsPerSecond=50;const n=t.timeline.tracks.height||Ye.TRACK_HEIGHT_DEFAULT;this.trackHeight=Math.max(40,n),this.backgroundColor=t.timeline.background,this.antialias=!0,this.resolution=window.devicePixelRatio||1}pixelsPerSecond;trackHeight;backgroundColor;antialias;resolution;width;height;static MIN_PIXELS_PER_SECOND=10;static MAX_PIXELS_PER_SECOND=500;static ZOOM_FACTOR=1.1;getOptions(){return{width:this.width,height:this.height,pixelsPerSecond:this.pixelsPerSecond,trackHeight:this.trackHeight,backgroundColor:this.backgroundColor,antialias:this.antialias,resolution:this.resolution}}setOptions(e){e.width!==void 0&&(this.width=e.width,this.onResize&&this.onResize(this.width)),e.height!==void 0&&(this.height=e.height),e.pixelsPerSecond!==void 0&&(this.pixelsPerSecond=e.pixelsPerSecond),e.trackHeight!==void 0&&(this.trackHeight=e.trackHeight),e.backgroundColor!==void 0&&(this.backgroundColor=e.backgroundColor),e.antialias!==void 0&&(this.antialias=e.antialias),e.resolution!==void 0&&(this.resolution=e.resolution),this.layout.updateOptions(this.getOptions())}updateFromTheme(e){this.backgroundColor=e.timeline.background;const t=e.timeline.tracks.height||Ye.TRACK_HEIGHT_DEFAULT;this.trackHeight=Math.max(40,t),this.layout.updateOptions(this.getOptions(),e)}getWidth(){return this.width}getHeight(){return this.height}getPixelsPerSecond(){return this.pixelsPerSecond}getTrackHeight(){return this.trackHeight}getBackgroundColor(){return this.backgroundColor}getAntialias(){return this.antialias}getResolution(){return this.resolution}zoomIn(){const e=Math.min(this.pixelsPerSecond*Ge.ZOOM_FACTOR,Ge.MAX_PIXELS_PER_SECOND);this.setPixelsPerSecond(e)}zoomOut(){const e=Math.max(this.pixelsPerSecond/Ge.ZOOM_FACTOR,Ge.MIN_PIXELS_PER_SECOND);this.setPixelsPerSecond(e)}setPixelsPerSecond(e){this.pixelsPerSecond=Math.max(Ge.MIN_PIXELS_PER_SECOND,Math.min(Ge.MAX_PIXELS_PER_SECOND,e)),this.layout.updateOptions(this.getOptions())}canZoomIn(){return this.pixelsPerSecond<Ge.MAX_PIXELS_PER_SECOND}canZoomOut(){return this.pixelsPerSecond>Ge.MIN_PIXELS_PER_SECOND}}class ks extends Je{constructor(e,t,i){super(),this.edit=e,this.theme=Sn.resolveTheme(i),this.layout=new Ye({width:t.width,height:t.height,pixelsPerSecond:50,trackHeight:Math.max(40,this.theme.timeline.tracks.height||Ye.TRACK_HEIGHT_DEFAULT),backgroundColor:this.theme.timeline.background,antialias:!0,resolution:window.devicePixelRatio||1},this.theme),this.optionsManager=new Ge(t,this.theme,this.layout,r=>this.featureManager?.getToolbar()?.resize(r)),this.initializeManagers(),this.setupInteraction()}currentEditType=null;layout;theme;lastPlaybackTime=0;static TIMELINE_BUFFER_MULTIPLIER=1.5;interaction;dragPreviewManager;viewportManager;visualTrackManager;eventHandler;renderer;featureManager;optionsManager;initializeManagers(){const e=this.optionsManager.getOptions();this.renderer=new $h({width:e.width||800,height:e.height||600,backgroundColor:e.backgroundColor||0,antialias:e.antialias??!0,resolution:e.resolution||window.devicePixelRatio||1},(t,i)=>this.update(t,i)),this.eventHandler=new Bh(this.edit,{onEditChange:this.handleEditChange.bind(this),onSeek:t=>this.edit.seek(t),onClipSelected:(t,i)=>this.visualTrackManager.updateVisualSelection(t,i),onSelectionCleared:()=>this.visualTrackManager.clearVisualSelection(),onDragStarted:(t,i)=>{const r=this.getClipData(t,i);r&&this.dragPreviewManager.showDragPreview(t,i,r)},onDragEnded:()=>this.dragPreviewManager.hideDragPreview()}),this.eventHandler.setupEventListeners()}async load(){await this.renderer.initializePixiApp(),await this.renderer.setupRenderLayers(),await this.setupViewport(),await this.setupTimelineFeatures(),this.interaction.activate();try{const e=this.edit.getEdit();e&&(this.currentEditType=e,await this.rebuildFromEdit(e))}catch{}this.renderer.startAnimationLoop()}async setupViewport(){this.viewportManager=new Ph(this.layout,this.renderer.getTrackLayer(),this.renderer.getOverlayLayer(),this.getContainer(),()=>this.renderer.render()),await this.viewportManager.setupViewport(),this.visualTrackManager=new Lh(this.getContainer(),this.layout,this.theme,()=>this.optionsManager.getPixelsPerSecond(),()=>this.getExtendedTimelineWidth()),this.dragPreviewManager=new Ih(this.getContainer(),this.layout,()=>this.optionsManager.getPixelsPerSecond(),()=>this.optionsManager.getTrackHeight(),()=>this.visualTrackManager.getVisualTracks()),this.featureManager=new Vh(this.edit,this.layout,this.renderer,this.viewportManager,this.eventHandler,()=>this)}async setupTimelineFeatures(){const e=this.getExtendedTimelineDuration();await this.featureManager.setupTimelineFeatures(this.theme,this.optionsManager.getPixelsPerSecond(),this.optionsManager.getWidth(),this.optionsManager.getHeight(),e)}recreateTimelineFeatures(){const e=this.getExtendedTimelineDuration();this.featureManager.recreateTimelineFeatures(this.theme,this.optionsManager.getPixelsPerSecond(),this.optionsManager.getHeight(),e)}setScroll(e,t){this.viewportManager.setScroll(e,t)}setZoom(e){this.viewportManager.setZoom(e)}getViewport(){return this.viewportManager.getViewport()}getPixiApp(){return this.renderer.getApp()}getTrackLayer(){return this.renderer.getTrackLayer()}getOverlayLayer(){return this.renderer.getOverlayLayer()}getClipData(e,t){return this.currentEditType?.timeline?.tracks&&this.currentEditType.timeline.tracks[e]?.clips?.[t]||null}getLayout(){return this.layout}getVisualTracks(){return this.visualTrackManager.getVisualTracks()}getEdit(){return this.edit}getExtendedTimelineWidth(){const e=this.getExtendedTimelineDuration()*this.optionsManager.getPixelsPerSecond(),t=this.optionsManager.getWidth();return Math.max(e,t)}hideDragGhost(){this.dragPreviewManager.hideDragGhost()}showDragGhost(e,t,i){this.dragPreviewManager.showDragGhost(e,t,i)}setPlayheadTime(e){this.featureManager.getPlayhead().setTime(e)}getPlayheadTime(){return this.featureManager.getPlayhead().getTime()}getActualEditDuration(){return this.edit.totalDuration/1e3||60}setupInteraction(){this.interaction=new Ah(this)}async handleEditChange(e){this.dragPreviewManager.hideDragPreview();const t=e||this.edit.getEdit();t&&(this.currentEditType=t,this.updateRulerDuration(),this.clearAllVisualState(),await this.rebuildFromEdit(t))}getExtendedTimelineDuration(){const e=this.edit.totalDuration/1e3||60;return Math.max(60,e*ks.TIMELINE_BUFFER_MULTIPLIER)}updateRulerDuration(){const e=this.getExtendedTimelineDuration(),t=this.getExtendedTimelineWidth();this.featureManager.updateRuler(this.optionsManager.getPixelsPerSecond(),e),this.visualTrackManager.updateTrackWidths(t)}clearAllVisualState(){this.dragPreviewManager.hideDragPreview(),this.visualTrackManager.clearAllVisualState()}async rebuildFromEdit(e){await this.visualTrackManager.rebuildFromEdit(e,this.optionsManager.getPixelsPerSecond()),this.renderer.render()}findClipAtPosition(e,t){return this.currentEditType?this.visualTrackManager.findClipAtPosition(e,t):null}setTheme(e){this.theme=Sn.resolveTheme(e),this.optionsManager.updateFromTheme(this.theme),this.featureManager.getToolbar()&&this.featureManager.getToolbar().updateTheme(this.theme),this.recreateTimelineFeatures(),this.currentEditType&&(this.clearAllVisualState(),this.rebuildFromEdit(this.currentEditType)),this.renderer.updateBackgroundColor(this.optionsManager.getBackgroundColor()),this.renderer.render()}getTheme(){return this.theme}getCurrentEditType(){return this.currentEditType}getOptions(){return this.optionsManager.getOptions()}setOptions(e){this.optionsManager.setOptions(e)}update(e,t){(this.edit.isPlaying||this.lastPlaybackTime!==this.edit.playbackTime)&&(this.featureManager.getPlayhead().setTime(this.edit.playbackTime/1e3),this.lastPlaybackTime=this.edit.playbackTime,this.featureManager.getToolbar()&&this.featureManager.getToolbar().updateTimeDisplay())}draw(){this.renderer.draw()}getTimeDisplay(){return this.featureManager.getToolbar()}updateTime(e,t){this.setPlayheadTime(e),t&&this.edit.seek(e*1e3)}get timeRange(){return{startTime:0,endTime:this.getExtendedTimelineDuration()}}get viewportHeight(){return this.optionsManager.getHeight()}get zoomLevelIndex(){const e=this.viewportManager.getViewport();return Math.round(Math.log2(e.zoom)+5)}zoomIn(){this.optionsManager.zoomIn(),this.onZoomChanged()}zoomOut(){this.optionsManager.zoomOut(),this.onZoomChanged()}onZoomChanged(){const e=this.optionsManager.getPixelsPerSecond();this.visualTrackManager.updatePixelsPerSecond(e);const t=this.getExtendedTimelineWidth();this.visualTrackManager.updateTrackWidths(t),this.featureManager.updateRuler(e,this.getExtendedTimelineDuration()),this.featureManager.updatePlayhead(e,this.optionsManager.getHeight()),this.renderer.render()}dispose(){this.dragPreviewManager.dispose(),this.visualTrackManager.dispose(),this.eventHandler.dispose(),this.featureManager.dispose(),this.interaction&&this.interaction.dispose(),this.renderer.dispose()}}var Rn={exports:{}};function Wh(s){var e=s.wasmExports,t=new TextDecoder("utf8");let i=s.addFunction,r=s.removeFunction;var n=i(function(I){e.free(I)},"vi"),o=2,a=-1,p=2,m=0,d=1,l=2;function c(I){return(I.charCodeAt(0)&255)<<24|(I.charCodeAt(1)&255)<<16|(I.charCodeAt(2)&255)<<8|(I.charCodeAt(3)&255)<<0}var u=c("JSON"),h=4;function f(I){return[String.fromCharCode(I>>24&255),String.fromCharCode(I>>16&255),String.fromCharCode(I>>8&255),String.fromCharCode(I>>0&255)].join("")}function b(I){return I=="BOT"?1:I=="EOT"?2:I=="PRESERVE_DEFAULT_IGNORABLES"?4:I=="REMOVE_DEFAULT_IGNORABLES"?8:I=="DO_NOT_INSERT_DOTTED_CIRCLE"?16:I=="PRODUCE_UNSAFE_TO_CONCAT"?64:0}function g(I){var L=e.malloc(I.byteLength);s.HEAPU8.set(new Uint8Array(I),L);var F=e.hb_blob_create(L,I.byteLength,o,L,n);return{ptr:F,destroy:function(){e.hb_blob_destroy(F)}}}function y(I){const L=e.hb_set_get_population(I),F=e.malloc(L<<2),Z=F>>2,Q=s.HEAPU32.subarray(Z,Z+L);return s.HEAPU32.set(Q,Z),e.hb_set_next_many(I,a,F,L),Q}function v(I,L){var F=e.hb_face_create(I.ptr,L);const Z=e.hb_face_get_upem(F);return{ptr:F,upem:Z,reference_table:function(Q){var X=e.hb_face_reference_table(F,c(Q)),Y=e.hb_blob_get_length(X);if(Y){var se=e.hb_blob_get_data(X,null),re=s.HEAPU8.subarray(se,se+Y);return re}},getAxisInfos:function(){var Q=e.malloc(2048),X=e.malloc(4);s.HEAPU32[X/4]=64,e.hb_ot_var_get_axis_infos(F,0,X,Q);var Y={};return Array.from({length:s.HEAPU32[X/4]}).forEach(function(se,re){Y[f(s.HEAPU32[Q/4+re*8+1])]={min:s.HEAPF32[Q/4+re*8+4],default:s.HEAPF32[Q/4+re*8+5],max:s.HEAPF32[Q/4+re*8+6]}}),e.free(X),e.free(Q),Y},collectUnicodes:function(){var Q=e.hb_set_create();e.hb_face_collect_unicodes(F,Q);var X=y(Q);return e.hb_set_destroy(Q),X},destroy:function(){e.hb_face_destroy(F)}}}var _="",C=256,S=e.malloc(C);function T(I){var L=e.hb_font_create(I.ptr),F=null,Z=null,Q=null,X=null,Y=null,se=null;function re(ve){if(!F){var ge=function(Fe,Dt,dt,Ze,Ke,xt){_+=`M${Ze},${Ke}`},de=function(Fe,Dt,dt,Ze,Ke,xt){_+=`L${Ze},${Ke}`},Oe=function(Fe,Dt,dt,Ze,Ke,xt,Qe,ni,Ri,Ts){_+=`C${Ze},${Ke} ${xt},${Qe} ${ni},${Ri}`},Ee=function(Fe,Dt,dt,Ze,Ke,xt,Qe,ni){_+=`Q${Ze},${Ke} ${xt},${Qe}`},Pi=function(Fe,Dt,dt,Ze){_+="Z"};Z=i(ge,"viiiffi"),Q=i(de,"viiiffi"),X=i(Oe,"viiiffffffi"),Y=i(Ee,"viiiffffi"),se=i(Pi,"viiii"),F=e.hb_draw_funcs_create(),e.hb_draw_funcs_set_move_to_func(F,Z,0,0),e.hb_draw_funcs_set_line_to_func(F,Q,0,0),e.hb_draw_funcs_set_cubic_to_func(F,X,0,0),e.hb_draw_funcs_set_quadratic_to_func(F,Y,0,0),e.hb_draw_funcs_set_close_path_func(F,se,0,0)}return _="",e.hb_font_draw_glyph(L,ve,F,0),_}function Ce(ve){e.hb_font_glyph_to_string(L,ve,S,C);var ge=s.HEAPU8.subarray(S,S+C);return t.decode(ge.slice(0,ge.indexOf(0)))}return{ptr:L,glyphName:Ce,glyphToPath:re,glyphToJson:function(ve){var ge=re(ve);return ge.replace(/([MLQCZ])/g,"|$1 ").split("|").filter(function(de){return de.length}).map(function(de){var Oe=de.split(/[ ,]/g);return{type:Oe[0],values:Oe.slice(1).filter(function(Ee){return Ee.length}).map(function(Ee){return+Ee})}})},setScale:function(ve,ge){e.hb_font_set_scale(L,ve,ge)},setVariations:function(ve){var ge=Object.entries(ve),de=e.malloc(8*ge.length);ge.forEach(function(Oe,Ee){s.HEAPU32[de/4+Ee*2+0]=c(Oe[0]),s.HEAPF32[de/4+Ee*2+1]=Oe[1]}),e.hb_font_set_variations(L,de,ge.length),e.free(de)},destroy:function(){e.hb_font_destroy(L),F&&(e.hb_draw_funcs_destroy(F),F=null,r(Z),r(Q),r(X),r(Y),r(se))}}}function w(I){var L=e.malloc(I.length+1);for(let F=0;F<I.length;++F){const Z=I.charCodeAt(F);if(Z>127)throw new Error("Expected ASCII text");s.HEAPU8[L+F]=Z}return s.HEAPU8[L+I.length]=0,{ptr:L,length:I.length,free:function(){e.free(L)}}}function x(I){const L=e.malloc(I.length*2),F=new Uint16Array(s.wasmMemory.buffer,L,I.length);for(let Z=0;Z<F.length;++Z)F[Z]=I.charCodeAt(Z);return{ptr:L,length:F.length,free:function(){e.free(L)}}}function k(){var I=e.hb_buffer_create();return{ptr:I,addText:function(L){const F=x(L);e.hb_buffer_add_utf16(I,F.ptr,F.length,0,F.length),F.free()},guessSegmentProperties:function(){return e.hb_buffer_guess_segment_properties(I)},setDirection:function(L){e.hb_buffer_set_direction(I,{ltr:4,rtl:5,ttb:6,btt:7}[L]||0)},setFlags:function(L){var F=0;L.forEach(function(Z){F|=b(Z)}),e.hb_buffer_set_flags(I,F)},setLanguage:function(L){var F=w(L);e.hb_buffer_set_language(I,e.hb_language_from_string(F.ptr,-1)),F.free()},setScript:function(L){var F=w(L);e.hb_buffer_set_script(I,e.hb_script_from_string(F.ptr,-1)),F.free()},setClusterLevel:function(L){e.hb_buffer_set_cluster_level(I,L)},json:function(){for(var L=e.hb_buffer_get_length(I),F=[],Z=e.hb_buffer_get_glyph_infos(I,0),Q=Z/4,X=e.hb_buffer_get_glyph_positions(I,0)/4,Y=s.HEAPU32.subarray(Q,Q+5*L),se=s.HEAP32.subarray(X,X+5*L),re=0;re<L;++re)F.push({g:Y[re*5+0],cl:Y[re*5+2],ax:se[re*5+0],ay:se[re*5+1],dx:se[re*5+2],dy:se[re*5+3],flags:e.hb_glyph_info_get_glyph_flags(Z+re*20)});return F},destroy:function(){e.hb_buffer_destroy(I)}}}function E(I,L,F){var Z=0,Q=0;F&&(F=F.split(","),Z=e.malloc(16*F.length),F.forEach(function(X,Y){var se=w(X);e.hb_feature_from_string(se.ptr,-1,Z+Q*16)&&Q++,se.free()})),e.hb_shape(I.ptr,L.ptr,Z,Q),Z&&e.free(Z)}function P(I,L,F,Z,Q){var X=[],Y=m,se=!1,re=1024*1024,Ce=e.malloc(re),ve=function(de,Oe,Ee,Pi){var Fe=t.decode(s.HEAPU8.subarray(Ee,s.HEAPU8.indexOf(0,Ee)));return Fe.startsWith("start table GSUB")?Y=d:Fe.startsWith("start table GPOS")&&(Y=l),Y!=Q&&(se=!1),Q!=m&&Y==Q&&Fe.startsWith("end lookup "+Z)&&(se=!0),se?0:(e.hb_buffer_serialize_glyphs(de,0,e.hb_buffer_get_length(de),Ce,re,0,Oe,u,h),X.push({m:Fe,t:JSON.parse(t.decode(s.HEAPU8.subarray(Ce,s.HEAPU8.indexOf(0,Ce)))),glyphs:e.hb_buffer_get_content_type(de)==p}),1)},ge=i(ve,"iiiii");return e.hb_buffer_set_message_func(L.ptr,ge,0,0),E(I,L,F),e.free(Ce),r(ge),X}function O(){var I=e.malloc(12);e.hb_version(I,I+4,I+8);var L={major:s.HEAPU32[I/4],minor:s.HEAPU32[(I+4)/4],micro:s.HEAPU32[(I+8)/4]};return e.free(I),L}function z(){var I=e.hb_version_string(),L=t.decode(s.HEAPU8.subarray(I,s.HEAPU8.indexOf(0,I)));return L}return{createBlob:g,createFace:v,createFont:T,createBuffer:k,shape:E,shapeWithTrace:P,version:O,version_string:z}}try{Rn.exports=Wh}catch{}var Gh=Rn.exports,On={exports:{}};const Zh=za(Gl);(function(s,e){var t=(()=>{var i=typeof document<"u"?document.currentScript?.src:void 0;return async function(r={}){var n,o=r,a=typeof window=="object",p=typeof WorkerGlobalScope<"u",m=typeof process=="object"&&process.versions?.node&&process.type!="renderer",d=(A,U)=>{throw U};typeof __filename<"u"?i=__filename:p&&(i=self.location.href);var l="";function c(A){return o.locateFile?o.locateFile(A,l):l+A}var u,h;if(m){var f=Zh;l=__dirname+"/",h=A=>{A=_(A)?new URL(A):A;var U=f.readFileSync(A);return U},u=async(A,U=!0)=>{A=_(A)?new URL(A):A;var ce=f.readFileSync(A,U?void 0:"utf8");return ce},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),d=(A,U)=>{throw process.exitCode=A,U}}else if(a||p){try{l=new URL(".",i).href}catch{}p&&(h=A=>{var U=new XMLHttpRequest;return U.open("GET",A,!1),U.responseType="arraybuffer",U.send(null),new Uint8Array(U.response)}),u=async A=>{if(_(A))return new Promise((ce,fe)=>{var he=new XMLHttpRequest;he.open("GET",A,!0),he.responseType="arraybuffer",he.onload=()=>{if(he.status==200||he.status==0&&he.response){ce(he.response);return}fe(he.status)},he.onerror=fe,he.send(null)});var U=await fetch(A,{credentials:"same-origin"});if(U.ok)return U.arrayBuffer();throw new Error(U.status+" : "+U.url)}}console.log.bind(console);var b=console.error.bind(console),g,y=!1,v,_=A=>A.startsWith("file://"),C,S,T,w,x=!1;function k(){var A=T.buffer;o.HEAP8=new Int8Array(A),o.HEAPU8=w=new Uint8Array(A),o.HEAP32=new Int32Array(A),o.HEAPU32=new Uint32Array(A),o.HEAPF32=new Float32Array(A),new BigInt64Array(A),new BigUint64Array(A)}function E(){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)Dt(o.preRun.shift());Oe(Fe)}function P(){x=!0,ft.__wasm_call_ctors()}function O(){if(o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;)Pi(o.postRun.shift());Oe(Ee)}var z=0,I=null;function L(A){z++,o.monitorRunDependencies?.(z)}function F(A){if(z--,o.monitorRunDependencies?.(z),z==0&&I){var U=I;I=null,U()}}function Z(A){o.onAbort?.(A),A="Aborted("+A+")",b(A),y=!0,A+=". Build with -sASSERTIONS for more info.";var U=new WebAssembly.RuntimeError(A);throw S?.(U),U}var Q;function X(){return c("hb.wasm")}function Y(A){if(A==Q&&g)return new Uint8Array(g);if(h)return h(A);throw"both async and sync fetching of the wasm failed"}async function se(A){if(!g)try{var U=await u(A);return new Uint8Array(U)}catch{}return Y(A)}async function re(A,U){try{var ce=await se(A),fe=await WebAssembly.instantiate(ce,U);return fe}catch(he){b(`failed to asynchronously prepare wasm: ${he}`),Z(he)}}async function Ce(A,U,ce){if(!A&&!_(U)&&!m)try{var fe=fetch(U,{credentials:"same-origin"}),he=await WebAssembly.instantiateStreaming(fe,ce);return he}catch(Ae){b(`wasm streaming compile failed: ${Ae}`),b("falling back to ArrayBuffer instantiation")}return re(U,ce)}function ve(){return{env:Dn,wasi_snapshot_preview1:Dn}}async function ge(){function A(Ae,Is){return ft=Ae.exports,o.wasmExports=ft,T=ft.memory,o.wasmMemory=T,k(),ai=ft.__indirect_function_table,mu(ft),F(),ft}L();function U(Ae){return A(Ae.instance)}var ce=ve();if(o.instantiateWasm)return new Promise((Ae,Is)=>{o.instantiateWasm(ce,(yu,ku)=>{Ae(A(yu))})});Q??=X();var fe=await Ce(g,Q,ce),he=U(fe);return he}class de{name="ExitStatus";constructor(U){this.message=`Program terminated with exit(${U})`,this.status=U}}var Oe=A=>{for(;A.length>0;)A.shift()(o)},Ee=[],Pi=A=>Ee.push(A),Fe=[],Dt=A=>Fe.push(A),dt=!0,Ze=()=>Z(""),Ke=0,xt=()=>{dt=!1,Ke=0},Qe={},ni=A=>{if(A instanceof de||A=="unwind")return v;d(1,A)},Ri=()=>dt||Ke>0,Ts=A=>{v=A,Ri()||(o.onExit?.(A),y=!0),d(A,new de(A))},Qh=(A,U)=>{v=A,Ts(A)},Jh=Qh,eu=()=>{if(!Ri())try{Jh(v)}catch(A){ni(A)}},tu=A=>{if(!y)try{A(),eu()}catch(U){ni(U)}},iu=()=>performance.now(),su=(A,U)=>{if(Qe[A]&&(clearTimeout(Qe[A].id),delete Qe[A]),!U)return 0;var ce=setTimeout(()=>{delete Qe[A],tu(()=>$n(A,iu()))},U);return Qe[A]={id:ce,timeout_ms:U},0},ru=()=>2147483648,nu=(A,U)=>Math.ceil(A/U)*U,au=A=>{var U=T.buffer.byteLength,ce=(A-U+65535)/65536|0;try{return T.grow(ce),k(),1}catch{}},ou=A=>{var U=w.length;A>>>=0;var ce=ru();if(A>ce)return!1;for(var fe=1;fe<=4;fe*=2){var he=U*(1+.2/fe);he=Math.min(he,A+100663296);var Ae=Math.min(ce,nu(Math.max(A,he),65536)),Is=au(Ae);if(Is)return!0}return!1},Mn=A=>{const U=A.length;return[U%128|128,U>>7,...A]},lu={i:127,p:127,j:126,f:125,d:124,e:111},Ln=A=>Mn(Array.from(A,U=>{var ce=lu[U];return ce})),cu=(A,U)=>{var ce=Uint8Array.of(0,97,115,109,1,0,0,0,1,...Mn([1,96,...Ln(U.slice(1)),...Ln(U[0]==="v"?"":U[0])]),2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0),fe=new WebAssembly.Module(ce),he=new WebAssembly.Instance(fe,{e:{f:A}}),Ae=he.exports.f;return Ae},ai,Bn=A=>ai.get(A),hu=(A,U)=>{if(Ct)for(var ce=A;ce<A+U;ce++){var fe=Bn(ce);fe&&Ct.set(fe,ce)}},Ct,uu=A=>(Ct||(Ct=new WeakMap,hu(0,ai.length)),Ct.get(A)||0),Ss=[],du=()=>Ss.length?Ss.pop():ai.grow(1),Es=(A,U)=>ai.set(A,U),fu=(A,U)=>{var ce=uu(A);if(ce)return ce;var fe=du();try{Es(fe,A)}catch(Ae){if(!(Ae instanceof TypeError))throw Ae;var he=cu(A,U);Es(fe,he)}return Ct.set(A,fe),fe},pu=A=>{Ct.delete(Bn(A)),Es(A,null),Ss.push(A)};o.noExitRuntime&&(dt=o.noExitRuntime),o.print&&o.print,o.printErr&&(b=o.printErr),o.wasmBinary&&(g=o.wasmBinary),o.arguments&&o.arguments,o.thisProgram&&o.thisProgram,o.wasmMemory=T,o.wasmExports=ft,o.addFunction=fu,o.removeFunction=pu;var $n;function mu(A){o._hb_blob_create=A.hb_blob_create,o._hb_blob_destroy=A.hb_blob_destroy,o._hb_blob_get_length=A.hb_blob_get_length,o._hb_blob_get_data=A.hb_blob_get_data,o._hb_buffer_serialize_glyphs=A.hb_buffer_serialize_glyphs,o._hb_buffer_create=A.hb_buffer_create,o._hb_buffer_destroy=A.hb_buffer_destroy,o._hb_buffer_get_content_type=A.hb_buffer_get_content_type,o._hb_buffer_set_direction=A.hb_buffer_set_direction,o._hb_buffer_set_script=A.hb_buffer_set_script,o._hb_buffer_set_language=A.hb_buffer_set_language,o._hb_buffer_set_flags=A.hb_buffer_set_flags,o._hb_buffer_set_cluster_level=A.hb_buffer_set_cluster_level,o._hb_buffer_get_length=A.hb_buffer_get_length,o._hb_buffer_get_glyph_infos=A.hb_buffer_get_glyph_infos,o._hb_buffer_get_glyph_positions=A.hb_buffer_get_glyph_positions,o._hb_glyph_info_get_glyph_flags=A.hb_glyph_info_get_glyph_flags,o._hb_buffer_guess_segment_properties=A.hb_buffer_guess_segment_properties,o._hb_buffer_add_utf8=A.hb_buffer_add_utf8,o._hb_buffer_add_utf16=A.hb_buffer_add_utf16,o._hb_buffer_set_message_func=A.hb_buffer_set_message_func,o._hb_language_from_string=A.hb_language_from_string,o._hb_script_from_string=A.hb_script_from_string,o._hb_version=A.hb_version,o._hb_version_string=A.hb_version_string,o._hb_feature_from_string=A.hb_feature_from_string,o._malloc=A.malloc,o._free=A.free,o._hb_draw_funcs_set_move_to_func=A.hb_draw_funcs_set_move_to_func,o._hb_draw_funcs_set_line_to_func=A.hb_draw_funcs_set_line_to_func,o._hb_draw_funcs_set_quadratic_to_func=A.hb_draw_funcs_set_quadratic_to_func,o._hb_draw_funcs_set_cubic_to_func=A.hb_draw_funcs_set_cubic_to_func,o._hb_draw_funcs_set_close_path_func=A.hb_draw_funcs_set_close_path_func,o._hb_draw_funcs_create=A.hb_draw_funcs_create,o._hb_draw_funcs_destroy=A.hb_draw_funcs_destroy,o._hb_face_create=A.hb_face_create,o._hb_face_destroy=A.hb_face_destroy,o._hb_face_reference_table=A.hb_face_reference_table,o._hb_face_get_upem=A.hb_face_get_upem,o._hb_face_collect_unicodes=A.hb_face_collect_unicodes,o._hb_font_draw_glyph=A.hb_font_draw_glyph,o._hb_font_glyph_to_string=A.hb_font_glyph_to_string,o._hb_font_create=A.hb_font_create,o._hb_font_set_variations=A.hb_font_set_variations,o._hb_font_destroy=A.hb_font_destroy,o._hb_font_set_scale=A.hb_font_set_scale,o._hb_set_create=A.hb_set_create,o._hb_set_destroy=A.hb_set_destroy,o._hb_ot_var_get_axis_infos=A.hb_ot_var_get_axis_infos,o._hb_set_get_population=A.hb_set_get_population,o._hb_set_next_many=A.hb_set_next_many,o._hb_shape=A.hb_shape,$n=A._emscripten_timeout}var Dn={_abort_js:Ze,_emscripten_runtime_keepalive_clear:xt,_setitimer_js:su,emscripten_resize_heap:ou,proc_exit:Ts},ft=await ge();function As(){if(z>0){I=As;return}if(E(),z>0){I=As;return}function A(){o.calledRun=!0,!y&&(P(),C?.(o),o.onRuntimeInitialized?.(),O())}o.setStatus?(o.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>o.setStatus(""),1),A()},1)):A()}function gu(){if(o.preInit)for(typeof o.preInit=="function"&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.shift()()}return gu(),As(),x?n=o:n=new Promise((A,U)=>{C=A,S=U}),n}})();s.exports=t,s.exports.default=t})(On);var Kh=On.exports,qh=Gh,Xh=Kh,Fn=new Promise(function(s,e){Xh().then(t=>{s(qh(t))},e)});const Yh=Nn({__proto__:null,default:Qs(Fn)},[Fn]);q.AssetSchema=kr,q.AudioAssetSchema=Zi,q.AudioAssetUrlSchema=hr,q.AudioAssetVolumeSchema=ur,q.Canvas=yt,q.ClipSchema=rs,q.Controls=Qo,q.Edit=Ot,q.EditSchema=Or,q.FontSourceSchema=Ir,q.FontSourceUrlSchema=Ar,q.HtmlAssetSchema=Ki,q.ImageAssetCropSchema=fr,q.ImageAssetSchema=qi,q.ImageAssetUrlSchema=dr,q.KeyframeEasingSchema=cr,q.KeyframeInterpolationSchema=lr,q.KeyframeSchema=at,q.LumaAssetSchema=Xi,q.LumaAssetUrlSchema=pr,q.OutputSchema=Rr,q.RichTextAssetSchema=fi,q.ShapeAssetCircleSchema=Ji,q.ShapeAssetColorSchema=Yi,q.ShapeAssetFillSchema=mr,q.ShapeAssetLineSchema=es,q.ShapeAssetRectangleSchema=Qi,q.ShapeAssetSchema=ts,q.ShapeAssetStrokeSchema=gr,q.TextAssetAlignmentSchema=br,q.TextAssetBackgroundSchema=vr,q.TextAssetColorSchema=yi,q.TextAssetFontSchema=yr,q.TextAssetSchema=is,q.TextAssetStrokeSchema=wr,q.Timeline=ks,q.TimelineSchema=Pr,q.TrackSchema=Er,q.VideoAssetCropSchema=xr,q.VideoAssetSchema=ss,q.VideoAssetUrlSchema=_r,q.VideoAssetVolumeSchema=Cr,q.VideoExporter=vh,Object.defineProperty(q,Symbol.toStringTag,{value:"Module"})});
373
+ */const A2=["video","audio","subtitle"],$o=s=>{if(!s||typeof s!="object")throw new TypeError("metadata must be an object.");if(s.languageCode!==void 0&&!xv(s.languageCode))throw new TypeError("metadata.languageCode, when provided, must be a three-letter, ISO 639-2/T language code.");if(s.name!==void 0&&typeof s.name!="string")throw new TypeError("metadata.name, when provided, must be a string.");if(s.maximumPacketCount!==void 0&&(!Number.isInteger(s.maximumPacketCount)||s.maximumPacketCount<0))throw new TypeError("metadata.maximumPacketCount, when provided, must be a non-negative integer.")};class I2{constructor(e){if(this.state="pending",this._tracks=[],this._startPromise=null,this._cancelPromise=null,this._finalizePromise=null,this._mutex=new l0,this._metadataTags={},!e||typeof e!="object")throw new TypeError("options must be an object.");if(!(e.format instanceof H0))throw new TypeError("options.format must be an OutputFormat.");if(!(e.target instanceof N0))throw new TypeError("options.target must be a Target.");if(e.target._output)throw new Error("Target is already used for another output.");e.target._output=this,this.format=e.format,this.target=e.target,this._writer=e.target._createWriter(),this._muxer=e.format._createMuxer(this)}addVideoTrack(e,t={}){if(!(e instanceof G0))throw new TypeError("source must be a VideoSource.");if($o(t),t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError(`Invalid video rotation: ${t.rotation}. Has to be 0, 90, 180 or 270.`);if(!this.format.supportsVideoRotationMetadata&&t.rotation)throw new Error(`${this.format._name} does not support video rotation metadata.`);if(t.frameRate!==void 0&&(!Number.isFinite(t.frameRate)||t.frameRate<=0))throw new TypeError(`Invalid video frame rate: ${t.frameRate}. Must be a positive number.`);this._addTrack("video",e,t)}addAudioTrack(e,t={}){if(!(e instanceof q0))throw new TypeError("source must be an AudioSource.");$o(t),this._addTrack("audio",e,t)}addSubtitleTrack(e,t={}){if(!(e instanceof E2))throw new TypeError("source must be a SubtitleSource.");$o(t),this._addTrack("subtitle",e,t)}setMetadataTags(e){if(_v(e),this.state!=="pending")throw new Error("Cannot set metadata tags after output has been started or canceled.");this._metadataTags=e}_addTrack(e,t,r){if(this.state!=="pending")throw new Error("Cannot add track after output has been started or canceled.");if(t._connectedTrack)throw new Error("Source is already used for a track.");const i=this.format.getSupportedTrackCounts(),n=this._tracks.reduce((u,h)=>u+(h.type===e?1:0),0),a=i[e].max;if(n===a)throw new Error(a===0?`${this.format._name} does not support ${e} tracks.`:`${this.format._name} does not support more than ${a} ${e} track${a===1?"":"s"}.`);const o=i.total.max;if(this._tracks.length===o)throw new Error(`${this.format._name} does not support more than ${o} tracks${o===1?"":"s"} in total.`);const c={id:this._tracks.length+1,output:this,type:e,source:t,metadata:r};if(c.type==="video"){const u=this.format.getSupportedVideoCodecs();if(u.length===0)throw new Error(`${this.format._name} does not support video tracks.`+this.format._codecUnsupportedHint(c.source._codec));if(!u.includes(c.source._codec))throw new Error(`Codec '${c.source._codec}' cannot be contained within ${this.format._name}. Supported video codecs are: ${u.map(h=>`'${h}'`).join(", ")}.`+this.format._codecUnsupportedHint(c.source._codec))}else if(c.type==="audio"){const u=this.format.getSupportedAudioCodecs();if(u.length===0)throw new Error(`${this.format._name} does not support audio tracks.`+this.format._codecUnsupportedHint(c.source._codec));if(!u.includes(c.source._codec))throw new Error(`Codec '${c.source._codec}' cannot be contained within ${this.format._name}. Supported audio codecs are: ${u.map(h=>`'${h}'`).join(", ")}.`+this.format._codecUnsupportedHint(c.source._codec))}else if(c.type==="subtitle"){const u=this.format.getSupportedSubtitleCodecs();if(u.length===0)throw new Error(`${this.format._name} does not support subtitle tracks.`+this.format._codecUnsupportedHint(c.source._codec));if(!u.includes(c.source._codec))throw new Error(`Codec '${c.source._codec}' cannot be contained within ${this.format._name}. Supported subtitle codecs are: ${u.map(h=>`'${h}'`).join(", ")}.`+this.format._codecUnsupportedHint(c.source._codec))}this._tracks.push(c),t._connectedTrack=c}async start(){const e=this.format.getSupportedTrackCounts();for(const r of A2){const i=this._tracks.reduce((a,o)=>a+(o.type===r?1:0),0),n=e[r].min;if(i<n)throw new Error(n===e[r].max?`${this.format._name} requires exactly ${n} ${r} track${n===1?"":"s"}.`:`${this.format._name} requires at least ${n} ${r} track${n===1?"":"s"}.`)}const t=e.total.min;if(this._tracks.length<t)throw new Error(t===e.total.max?`${this.format._name} requires exactly ${t} track${t===1?"":"s"}.`:`${this.format._name} requires at least ${t} track${t===1?"":"s"}.`);if(this.state==="canceled")throw new Error("Output has been canceled.");return this._startPromise?(console.warn("Output has already been started."),this._startPromise):this._startPromise=(async()=>{this.state="started",this._writer.start();const r=await this._mutex.acquire();await this._muxer.start();const i=this._tracks.map(n=>n.source._start());await Promise.all(i),r()})()}getMimeType(){return this._muxer.getMimeType()}async cancel(){if(this._cancelPromise)return console.warn("Output has already been canceled."),this._cancelPromise;if(this.state==="finalizing"||this.state==="finalized"){console.warn("Output has already been finalized.");return}return this._cancelPromise=(async()=>{this.state="canceled";const e=await this._mutex.acquire(),t=this._tracks.map(r=>r.source._flushOrWaitForOngoingClose(!0));await Promise.all(t),await this._writer.close(),e()})()}async finalize(){if(this.state==="pending")throw new Error("Cannot finalize before starting.");if(this.state==="canceled")throw new Error("Cannot finalize after canceling.");return this._finalizePromise?(console.warn("Output has already been finalized."),this._finalizePromise):this._finalizePromise=(async()=>{this.state="finalizing";const e=await this._mutex.acquire(),t=this._tracks.map(r=>r.source._flushOrWaitForOngoingClose(!1));await Promise.all(t),await this._muxer.finalize(),await this._writer.flush(),await this._writer.finalize(),this.state="finalized",e()})()}}class P2{audioTracks=[];async setupAudioTracks(e,t){const r=this.findAudioPlayers(e);if(!r.length)return null;this.audioTracks=[];for(const n of r){const a=await this.processAudioTrack(n);a&&this.audioTracks.push(a)}if(!this.audioTracks.length)return null;const i=new T2({codec:"aac",bitrate:128e3});return t.addAudioTrack(i),i}async processAudioSamples(e){if(!this.audioTracks?.length)return;const t=new AudioContext;for(const r of this.audioTracks){const i=await t.decodeAudioData(r.data.slice(0)),{numberOfChannels:n,sampleRate:a,length:o}=i,c=Math.min(o,Math.floor(a*r.duration/1e3)),u=new Float32Array(c*n);for(let h=0;h<n;h+=1){const l=i.getChannelData(h);for(let d=0;d<c;d+=1)u[d*n+h]=l[d]*r.volume}await e.add(new ui({data:u,format:"f32",numberOfChannels:n,sampleRate:a,timestamp:r.start/1e3}))}this.audioTracks=[]}findAudioPlayers(e){const t=[];for(const r of e)for(const i of r)this.isAudioPlayer(i)&&!t.includes(i)&&t.push(i);return t}async processAudioTrack(e){try{const t=e.clipConfiguration?.asset;if(!t?.src)return null;const r=await fetch(t.src);return r.ok?{data:await r.arrayBuffer(),start:e.getStart(),duration:e.getLength(),volume:e.getVolume()}:null}catch(t){return console.warn("Failed to process audio track:",t),null}}isAudioPlayer(e){if(e instanceof Ko)return!0;if(!e||typeof e!="object")return!1;const t=e,r=t.constructor?.name==="AudioPlayer",a=t.clipConfiguration?.asset?.type==="audio";return r||a}}class O2{overlay=null;bar=null;percent=null;status=null;create(){this.overlay=Object.assign(document.createElement("div"),{style:"position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.5);z-index:9999;display:flex;justify-content:center;align-items:center;color:white;font-family:Arial"});const e=Object.assign(document.createElement("div"),{style:"background:#222;border-radius:8px;padding:20px;box-shadow:0 4px 8px rgba(0,0,0,0.2);width:300px;text-align:center"});e.innerHTML='<h3 style="margin:0 0 15px 0;font-weight:normal">Exporting Video</h3>',this.status=Object.assign(document.createElement("div"),{style:"font-size:12px;margin-bottom:10px;opacity:0.8"}),e.appendChild(this.status);const t=Object.assign(document.createElement("div"),{style:"width:100%;height:6px;background:#444;border-radius:3px;overflow:hidden;margin-bottom:10px"});this.bar=Object.assign(document.createElement("div"),{style:"width:0%;height:100%;background:#3498db;transition:width 0.3s"}),t.appendChild(this.bar),e.appendChild(t),this.percent=Object.assign(document.createElement("div"),{style:"font-size:12px",innerText:"0%"}),e.appendChild(this.percent),this.overlay.appendChild(e),document.body.appendChild(this.overlay)}update(e,t,r){if(!this.overlay)return;const i=Math.round(e/t*100);this.bar&&(this.bar.style.width=`${i}%`),this.percent&&(this.percent.innerText=`${i}%`),this.status&&r&&(this.status.innerText=r)}remove(){this.overlay?.remove(),this.overlay=null,this.bar=null,this.percent=null,this.status=null}}class X0 extends Map{constructor(e){super(),this.maxSize=e}get(e){const t=super.get(e);if(t!==void 0)return super.delete(e),super.set(e,t),t}set(e,t){if(super.delete(e),super.set(e,t),this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}class Vn extends Error{constructor(e,t="unknown",r={},i){super(e),this.phase=t,this.context=r,this.name="ExportError",this.cause=i}}class F2 extends Vn{constructor(e,t){super(e,"initialization",{missingFeatures:t}),this.name="BrowserCompatibilityError"}}function Z0(s){if(!s||typeof s!="object")return!1;const e=s,t=e.constructor?.name==="VideoPlayer",i=e.texture?.source?.resource instanceof HTMLVideoElement;return e.constructor?.name==="RichTextPlayer"?!1:t||i}class R2{frameCache=new X0(10);textureCache=new X0(5);videoElements=new Map;extractionCanvas=null;extractionContext=null;async initialize(e){for(const t of e)if(Z0(t)){const r=t,i=r.texture?.source?.resource;i&&this.videoElements.set(this.getVideoKey(r),{element:i,player:r})}this.extractionCanvas=document.createElement("canvas"),this.extractionCanvas.width=3840,this.extractionCanvas.height=2160,this.extractionContext=this.extractionCanvas.getContext("2d",{willReadFrequently:!0,alpha:!0})}async extractFrame(e,t){const r=`${e}-${t}`,i=this.frameCache.get(r);if(i)return i;const n=this.videoElements.get(e);if(!n||!this.extractionContext||!this.extractionCanvas)return null;try{const{element:a,player:o}=n,c=(t-(o.getStart?.()||0))/1e3+(o.clipConfiguration?.asset?.trim||0);await this.seekToTime(a,c);const u=a.videoWidth||a.width||1920,h=a.videoHeight||a.height||1080;this.extractionContext.clearRect(0,0,u,h),this.extractionContext.drawImage(a,0,0,u,h);const l=this.extractionContext.getImageData(0,0,u,h);return this.frameCache.set(r,l),l}catch{return null}}async replaceVideoTexture(e,t){const r=await this.extractFrame(this.getVideoKey(e),t);if(!r)return;const i=`${this.getVideoKey(e)}-${t}`;let n=this.textureCache.get(i);if(!n){const a=document.createElement("canvas");a.width=r.width,a.height=r.height;const o=a.getContext("2d");o&&(o.putImageData(r,0,0),n=U.Texture.from(a),this.textureCache.set(i,n))}n&&e.texture&&(e.originalTextureSource||(e.originalTextureSource=e.texture.source,e.texture.source?.resource instanceof HTMLVideoElement&&(e.originalVideoElement=e.texture.source.resource)),e.texture=n,e.sprite?.texture&&(e.sprite.texture=n),e.lastReplacedTimestamp=t)}disableVideoPlayback(e){const t=[];for(const r of e)if(Z0(r)){const i=r;t.push(i),i.texture?.source?.resource instanceof HTMLVideoElement&&i.texture.source.resource.pause(),i.skipVideoUpdate=!0}return t}getVideoKey(e){return e.clipConfiguration?.asset?.src||""}dispose(){this.frameCache.clear(),this.textureCache.clear(),this.videoElements.clear(),this.extractionCanvas=null,this.extractionContext=null}async seekToTime(e,t){return new Promise(r=>{if(Math.abs(e.currentTime-t)<.1){r();return}const i=()=>{e.removeEventListener("seeked",i),setTimeout(r,1)};e.addEventListener("seeked",i),e.currentTime=t})}}class M2{edit;canvas;app;isExporting=!1;videoProcessor=new R2;audioProcessor=new P2;progressUI=new O2;exportCommand=new mv;constructor(e,t){this.edit=e,this.canvas=t,this.app=t.application,document.addEventListener("keydown",this.handleKeyDown)}async export(e="shotstack-export.mp4",t){if(typeof VideoEncoder>"u")throw new F2("WebCodecs API not supported",["VideoEncoder"]);if(this.isExporting)throw new Vn("Export in progress","init");this.isExporting=!0;const r=this.saveEditState();this.edit.setExportMode(!0);try{this.progressUI.create(),this.canvas.pauseTicker();const i=this.prepareConfig(t??this.edit.getEdit().output?.fps??30);this.progressUI.update(0,100,"Preparing..."),this.edit.executeEditCommand(this.exportCommand),await this.videoProcessor.initialize(this.exportCommand.getClips()),this.progressUI.update(10,100,"Video ready");const n=new I2({format:new j0,target:new U0}),a=document.createElement("canvas");a.width=i.size.width,a.height=i.size.height;const o=a.getContext("2d");if(!o)throw new Error("No 2D context");const c=new S2(a,{codec:"avc",bitrate:5e6});n.addVideoTrack(c),this.progressUI.update(15,100,"Audio...");const u=await this.audioProcessor.setupAudioTracks(this.exportCommand.getTracks(),n);await n.start(),u&&(this.progressUI.update(20,100,"Encoding audio..."),await this.audioProcessor.processAudioSamples(u)),this.progressUI.update(25,100,"Exporting..."),await this.processFrames(i,c,a,o),await n.finalize();const h=n.target.buffer;if(!h)throw new Error("No video data");const l=new Blob([h],{type:"video/mp4"}),d=URL.createObjectURL(l),f=document.createElement("a");f.href=d,f.download=e,f.click(),URL.revokeObjectURL(d),this.progressUI.update(100,100,"Complete!")}catch(i){throw i instanceof Vn?i:new Vn(`Export failed: ${i}`,"export")}finally{this.isExporting=!1,this.edit.setExportMode(!1),this.canvas.resumeTicker(),this.progressUI.remove(),this.restoreEditState(r)}}async processFrames(e,t,r,i){const n=this.edit.getContainer();this.edit.pause(),Object.assign(n.position,{x:0,y:0}),Object.assign(n.scale,{x:1,y:1}),n.visible=!0;const a=this.videoProcessor.disableVideoPlayback(this.exportCommand.getClips());for(let o=0;o<e.frames;o+=1){const c=o*e.frameDuration;this.edit.playbackTime=c;for(const l of this.exportCommand.getClips())l.update(0,0);for(const l of a){const d=l.getStart?.()||0,f=l.getEnd?.()||d+(l.getLength?.()||0);c>=d&&c<f&&await this.videoProcessor.replaceVideoTexture(l,c)}this.edit.draw(),this.app.renderer.render(this.app.stage);const u=this.app.renderer.extract.pixels({target:n,frame:new U.Rectangle(0,0,e.size.width,e.size.height)}),h=new ImageData(new Uint8ClampedArray(u.pixels),u.width,u.height);i.putImageData(h,0,0),await t.add(o/e.fps,1/e.fps),this.progressUI.update(25+Math.round((o+1)/e.frames*75),100,"Exporting...")}}handleKeyDown=e=>{e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement||e.code==="KeyE"&&(e.metaKey||e.ctrlKey)&&!this.isExporting&&(e.preventDefault(),this.export("shotstack-export.mp4",this.edit.getEdit().output?.fps||30).catch(t=>console.error("Export failed:",t)))};dispose(){document.removeEventListener("keydown",this.handleKeyDown),this.videoProcessor.dispose(),this.progressUI.remove()}prepareConfig(e){const t=this.edit.getEdit().output?.size||{width:1920,height:1080},r=this.edit.totalDuration/1e3;return{fps:e,size:t,frames:Math.ceil(r*e),frameDuration:1e3/e}}saveEditState(){const e=this.edit.getContainer();return{wasPlaying:this.edit.isPlaying,time:this.edit.playbackTime,visible:e.visible,pos:{x:e.position.x,y:e.position.y},scale:{x:e.scale.x,y:e.scale.y}}}restoreEditState(e){const t=this.edit.getContainer();this.edit.setExportMode(!1);for(const r of this.exportCommand.getClips())if(this.isVideoPlayer(r)){const i=r;if(i.skipVideoUpdate=!1,i.originalVideoElement&&i.texture){const n=U.Texture.from(i.originalVideoElement);i.texture=n,i.sprite&&(i.sprite.texture=n),delete i.originalVideoElement,delete i.originalTextureSource,delete i.lastReplacedTimestamp}else i.originalTextureSource&&i.texture&&(i.texture.source=i.originalTextureSource,delete i.originalTextureSource,delete i.lastReplacedTimestamp)}Object.assign(t.position,e.pos),Object.assign(t.scale,e.scale),t.visible=e.visible,this.edit.seek(e.time),e.wasPlaying&&this.edit.play()}isVideoPlayer(e){if(!e||typeof e!="object")return!1;const t=e,r=t.constructor?.name==="VideoPlayer",n=t.texture?.source?.resource instanceof HTMLVideoElement;return r||n}}function K0(s){const e=s.replace("#",""),t=parseInt(e,16);return Number.isNaN(t)?(console.warn(`Invalid hex color: ${s}, defaulting to black`),0):t}function D2(s){const e=t=>{if(typeof t=="string")return K0(t);if(typeof t=="object"&&t!==null){const r=Array.isArray(t)?[]:{};for(const i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[i]=e(t[i]));return r}return t};return e(s)}function Y0(s){if(typeof s=="string")return K0(s);if(typeof s=="object"&&s!==null){const e=Array.isArray(s)?[]:{};for(const t in s)Object.prototype.hasOwnProperty.call(s,t)&&(e[t]=Y0(s[t]));return e}return s}const J0=D2({timeline:{background:"#1a1a1a",divider:"#1a1a1a",toolbar:{background:"#1a1a1a",surface:"#2a2a2a",hover:"#3a3a3a",active:"#007acc",divider:"#3a3a3a",icon:"#888888",text:"#ffffff",height:36},ruler:{background:"#404040",text:"#ffffff",markers:"#666666",height:40},tracks:{surface:"#2a2a2a",surfaceAlt:"#242424",border:"#3a3a3a",height:60},clips:{video:"#4a90e2",audio:"#7ed321",image:"#f5a623",text:"#d0021b",shape:"#9013fe",html:"#50e3c2",luma:"#b8e986",default:"#8e8e93",selected:"#007acc",radius:4},playhead:"#ff4444",snapGuide:"#888888",dropZone:"#00ff00",trackInsertion:"#00ff00"}});class Q0{static resolveTheme(e){if(!e||!e.theme)return this.deepClone(J0);const t=Y0(e.theme),r=this.deepClone(J0);return this.deepMerge(r,t)}static validateTheme(e){try{if(!e.timeline)return!1;const{timeline:t}=e;if(typeof t.background!="number"||typeof t.divider!="number"||typeof t.playhead!="number"||typeof t.snapGuide!="number"||typeof t.dropZone!="number"||typeof t.trackInsertion!="number"||!t.toolbar)return!1;const{toolbar:r}=t;if(typeof r.background!="number"||typeof r.surface!="number"||typeof r.hover!="number"||typeof r.active!="number"||typeof r.divider!="number"||typeof r.icon!="number"||typeof r.text!="number"||typeof r.height!="number"||r.height<=0||!t.ruler)return!1;const{ruler:i}=t;if(typeof i.background!="number"||typeof i.text!="number"||typeof i.markers!="number"||typeof i.height!="number"||i.height<=0||!t.tracks)return!1;const{tracks:n}=t;if(typeof n.surface!="number"||typeof n.surfaceAlt!="number"||typeof n.border!="number"||typeof n.height!="number"||n.height<=0||!t.clips)return!1;const{clips:a}=t,o=["video","audio","image","text","shape","html","luma","default","selected"];for(const c of o)if(typeof a[c]!="number")return!1;return!(typeof a.radius!="number"||a.radius<0)}catch(t){return console.error("Theme validation error:",t),!1}}static deepClone(e){if(e===null||typeof e!="object")return e;if(e instanceof Array)return e.map(r=>this.deepClone(r));const t={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=this.deepClone(e[r]));return t}static deepMerge(e,t){const r={...e};for(const i in t)if(Object.prototype.hasOwnProperty.call(t,i)){const n=t[i],a=r[i];n!==void 0&&(typeof n=="object"&&n!==null&&!Array.isArray(n)&&typeof a=="object"&&a!==null&&!Array.isArray(a)?r[i]=this.deepMerge(a,n):r[i]=n)}return r}}class B2{timeline;constructor(e){this.timeline=e}getValidDropPosition(e,t,r,i){const n=this.timeline.getVisualTracks()[r];if(!n)return{validTime:e,wouldOverlap:!1};const a=this.getOtherClipBounds(n,i),o=e+t,c=a.find(f=>!(o<=f.start||e>=f.end));if(!c)return{validTime:e,wouldOverlap:!1};const u=c.start-t,h=c.end,l=Math.abs(e-u)<Math.abs(e-h)&&u>=0?u:h;return{validTime:this.getValidDropPosition(l,t,r,i).validTime,wouldOverlap:!0}}checkOverlap(e,t,r,i){const n=this.timeline.getVisualTracks()[r];if(!n)return!1;const a=this.getOtherClipBounds(n,i),o=e+t;return a.some(c=>!(o<=c.start||e>=c.end))}getOtherClipBounds(e,t){return e.getClips().map((r,i)=>({clip:r,index:i})).filter(({index:r})=>r!==t).map(({clip:r})=>{const i=r.getClipConfig();return i?{start:i.start||0,end:(i.start||0)+(i.length||0)}:null}).filter(r=>r!==null).sort((r,i)=>r.start-i.start)}findAvailableGaps(e,t){const r=this.timeline.getVisualTracks()[e];if(!r)return[];const i=this.getOtherClipBounds(r),n=[];i.length>0&&i[0].start>=t&&n.push({start:0,end:i[0].start});for(let a=0;a<i.length-1;a+=1)i[a+1].start-i[a].end>=t&&n.push({start:i[a].end,end:i[a+1].start});return n}}class eh{constructor(e,t,r,i){this.fromTrackIndex=e,this.fromClipIndex=t,this.toTrackIndex=r,this.newStart=i,this.originalTrackIndex=e,this.originalClipIndex=t}name="moveClip";player;originalTrackIndex;originalClipIndex;originalStart;execute(e){if(!e)return;const t=e.getTracks();if(this.fromTrackIndex<0||this.fromTrackIndex>=t.length){console.warn(`Invalid source track index: ${this.fromTrackIndex}`);return}const r=t[this.fromTrackIndex];if(this.fromClipIndex<0||this.fromClipIndex>=r.length){console.warn(`Invalid clip index: ${this.fromClipIndex}`);return}if(this.player=r[this.fromClipIndex],this.originalStart=this.player.clipConfiguration.start,this.fromTrackIndex!==this.toTrackIndex){if(this.toTrackIndex<0||this.toTrackIndex>=t.length){console.warn(`Invalid destination track index: ${this.toTrackIndex}`);return}r.splice(this.fromClipIndex,1),this.player.layer=this.toTrackIndex+1;const i=t[this.toTrackIndex];let n=0;for(let a=0;a<i.length;a+=1){const o=i[a];if(o.clipConfiguration&&o.clipConfiguration.start!==void 0&&this.newStart<o.clipConfiguration.start)break;n+=1}i.splice(n,0,this.player),this.originalClipIndex=n}if(this.player.clipConfiguration.start=this.newStart,e.movePlayerToTrackContainer(this.player,this.fromTrackIndex,this.toTrackIndex),this.player.reconfigureAfterRestore(),this.player.draw(),e.updateDuration(),this.fromTrackIndex!==this.toTrackIndex){const i=t[this.fromTrackIndex],n=t[this.toTrackIndex];[...i,...n].forEach(a=>{a&&a!==this.player&&a.draw()})}e.emitEvent("clip:updated",{previous:{clip:{...this.player.clipConfiguration,start:this.originalStart},trackIndex:this.fromTrackIndex,clipIndex:this.fromClipIndex},current:{clip:this.player.clipConfiguration,trackIndex:this.toTrackIndex,clipIndex:this.originalClipIndex}})}undo(e){if(!e||!this.player||this.originalStart===void 0)return;const t=e.getTracks();if(this.fromTrackIndex!==this.toTrackIndex){const r=t[this.toTrackIndex],i=r.indexOf(this.player);i!==-1&&r.splice(i,1),this.player.layer=this.fromTrackIndex+1,t[this.fromTrackIndex].splice(this.fromClipIndex,0,this.player)}this.player.clipConfiguration.start=this.originalStart,e.movePlayerToTrackContainer(this.player,this.toTrackIndex,this.fromTrackIndex),this.player.reconfigureAfterRestore(),this.player.draw(),e.updateDuration(),e.emitEvent("clip:updated",{previous:{clip:{...this.player.clipConfiguration,start:this.newStart},trackIndex:this.toTrackIndex,clipIndex:this.originalClipIndex},current:{clip:this.player.clipConfiguration,trackIndex:this.fromTrackIndex,clipIndex:this.fromClipIndex}})}}class L2{constructor(e,t,r,i){this.insertionIndex=e,this.fromTrackIndex=t,this.fromClipIndex=r,this.newStart=i,this.addTrackCommand=new e0(e);const n=t>=e?t+1:t;this.moveClipCommand=new eh(n,r,e,i)}name="createTrackAndMoveClip";addTrackCommand;moveClipCommand;wasExecuted=!1;async execute(e){if(e)try{this.addTrackCommand.execute(e),this.moveClipCommand.execute(e),this.wasExecuted=!0}catch(t){if(this.wasExecuted)try{this.undo(e)}catch{}throw t}}undo(e){!e||!this.wasExecuted||(this.moveClipCommand.undo(e),this.addTrackCommand.undo(e),this.wasExecuted=!1,e.emitEvent("track:created:undone",{trackIndex:this.insertionIndex}))}}class z2{timeline;thresholds;snapManager;collisionDetector;visualFeedback;dragInfo=null;currentDropZone=null;constructor(e,t,r,i,n){this.timeline=e,this.thresholds=t,this.snapManager=r,this.collisionDetector=i,this.visualFeedback=n}activate(){}deactivate(){this.endDrag()}canStartDrag(e,t){const r=Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),{trackHeight:i}=this.timeline.getLayout(),n=i<20?2:this.thresholds.drag.base;return r>n}startDrag(e,t){const r=this.timeline.getClipData(e.trackIndex,e.clipIndex);if(!r)return console.warn(`Clip data not found for track ${e.trackIndex}, clip ${e.clipIndex}`),!1;const i=this.timeline.getContainer().toLocal(t.global),n=this.timeline.getLayout(),a=n.getXAtTime(r.start||0),o=e.trackIndex*n.trackHeight;return this.dragInfo={trackIndex:e.trackIndex,clipIndex:e.clipIndex,startTime:r.start||0,offsetX:i.x-a,offsetY:i.y-o},this.timeline.getPixiApp().canvas.style.cursor="grabbing",this.timeline.getEdit().events.emit("drag:started",this.dragInfo),!0}updateDrag(e){if(!this.dragInfo)return;const t=this.calculateDragPosition(e),r=this.detectDropZone(t.y);r?this.handleDropZonePreview(r,t):this.handleNormalDragPreview(t),this.emitDragUpdate(t,r)}completeDrag(e){if(!this.dragInfo)return;const t={...this.dragInfo},r=this.calculateDragPosition(e),i=this.detectDropZone(r.y);this.endDrag(),i?this.executeDropZoneMove(i,t,r):this.executeNormalMove(t,r)}calculateDragPosition(e){if(!this.dragInfo)throw new Error("No drag info available");const t=this.timeline.getContainer().toLocal(e.global),r=this.timeline.getLayout(),i=Math.max(0,r.getTimeAtX(t.x-this.dragInfo.offsetX)),n=t.y-this.dragInfo.offsetY,a=n+r.trackHeight/2,o=Math.max(0,Math.floor(a/r.trackHeight)),c=this.timeline.getVisualTracks().length-1,u=Math.max(0,Math.min(c,o));return{x:t.x,y:t.y+r.viewportY,time:i,track:u,ghostY:n}}detectDropZone(e){const t=this.timeline.getLayout(),r=this.timeline.getVisualTracks(),i=t.trackHeight*this.thresholds.dropZone.ratio;for(let n=0;n<=r.length;n+=1){const a=t.tracksY+n*t.trackHeight;if(Math.abs(e-a)<i){let o;return n===0?o="above":n===r.length?o="below":o="between",{type:o,position:n}}}return null}handleDropZonePreview(e,t){(!this.currentDropZone||this.currentDropZone.type!==e.type||this.currentDropZone.position!==e.position)&&(this.currentDropZone=e,this.visualFeedback.showDropZone(e)),this.timeline.hideDragGhost(),this.visualFeedback.hideSnapGuidelines(),this.visualFeedback.hideTargetTrack()}handleNormalDragPreview(e){if(!this.dragInfo)return;this.currentDropZone&&(this.visualFeedback.hideDropZone(),this.currentDropZone=null);const t=this.timeline.getClipData(this.dragInfo.trackIndex,this.dragInfo.clipIndex);if(!t)return;const r=t.length||0,i=e.track===this.dragInfo.trackIndex?this.dragInfo.clipIndex:void 0,n=this.calculateFinalPosition(e.time,e.track,r,i),a=this.snapManager.findAlignedElements(n,r,e.track,i);a.length>0?this.visualFeedback.showSnapGuidelines(a):this.visualFeedback.hideSnapGuidelines(),this.visualFeedback.showTargetTrack(e.track),this.timeline.showDragGhost(e.track,n,e.ghostY)}calculateFinalPosition(e,t,r,i){const n=this.snapManager.calculateSnapPosition(e,t,r,i);return this.collisionDetector.getValidDropPosition(n.time,r,t,i).validTime}emitDragUpdate(e,t){if(!this.dragInfo)return;const r=this.timeline.getClipData(this.dragInfo.trackIndex,this.dragInfo.clipIndex);if(!r)return;const i=r.length||0,n=t?e.time:this.calculateFinalPosition(e.time,e.track,i,e.track===this.dragInfo.trackIndex?this.dragInfo.clipIndex:void 0);this.timeline.getEdit().events.emit("drag:moved",{...this.dragInfo,currentTime:n,currentTrack:t?-1:e.track})}executeDropZoneMove(e,t,r){const i=new L2(e.position,t.trackIndex,t.clipIndex,r.time);this.timeline.getEdit().executeEditCommand(i)}executeNormalMove(e,t){const r=this.timeline.getClipData(e.trackIndex,e.clipIndex);if(!r)return;const i=r.length||0,n=t.track===e.trackIndex?e.clipIndex:void 0,a=this.calculateFinalPosition(t.time,t.track,i,n);if(t.track!==e.trackIndex||Math.abs(a-e.startTime)>.01){const c=new eh(e.trackIndex,e.clipIndex,t.track,a);this.timeline.getEdit().executeEditCommand(c)}}endDrag(){this.dragInfo=null,this.currentDropZone=null,this.visualFeedback.hideAll(),this.timeline.getPixiApp().canvas.style.cursor="default",this.timeline.getEdit().events.emit("drag:ended",{})}getDragInfo(){return this.dragInfo}dispose(){this.endDrag()}}class $2{constructor(e,t,r){this.trackIndex=e,this.clipIndex=t,this.newLength=r}name="resizeClip";originalLength;player;execute(e){if(!e)return;const t=e.getTrack(this.trackIndex);if(!t){console.warn(`Invalid track index: ${this.trackIndex}`);return}if(this.clipIndex<0||this.clipIndex>=t.length){console.warn(`Invalid clip index: ${this.clipIndex} for track ${this.trackIndex}`);return}this.player=t[this.clipIndex],this.originalLength=this.player.clipConfiguration.length,this.player.clipConfiguration.length=this.newLength,this.player.reconfigureAfterRestore(),this.player.draw(),e.updateDuration(),e.emitEvent("clip:updated",{previous:{clip:{...this.player.clipConfiguration,length:this.originalLength},trackIndex:this.trackIndex,clipIndex:this.clipIndex},current:{clip:this.player.clipConfiguration,trackIndex:this.trackIndex,clipIndex:this.clipIndex}})}undo(e){!e||!this.player||this.originalLength===void 0||(this.player.clipConfiguration.length=this.originalLength,this.player.reconfigureAfterRestore(),this.player.draw(),e.updateDuration(),e.emitEvent("clip:updated",{previous:{clip:{...this.player.clipConfiguration,length:this.newLength},trackIndex:this.trackIndex,clipIndex:this.clipIndex},current:{clip:this.player.clipConfiguration,trackIndex:this.trackIndex,clipIndex:this.clipIndex}}))}}class N2{timeline;thresholds;resizeInfo=null;constructor(e,t){this.timeline=e,this.thresholds=t}activate(){}deactivate(){this.endResize()}isOnClipRightEdge(e,t){const r=this.timeline.getVisualTracks()[e.trackIndex];if(!r)return!1;const i=r.getClip(e.clipIndex);if(!i)return!1;const a=i.getContainer().getBounds(),o=a.x+a.width,c=Math.abs(t.global.x-o),u=this.getResizeThreshold();return c<=u}startResize(e,t){const r=this.timeline.getClipData(e.trackIndex,e.clipIndex);if(!r)return!1;this.resizeInfo={trackIndex:e.trackIndex,clipIndex:e.clipIndex,originalLength:r.length||0,startX:t.global.x},this.timeline.getPixiApp().canvas.style.cursor="ew-resize";const i=this.timeline.getVisualTracks()[e.trackIndex];if(i){const n=i.getClip(e.clipIndex);n&&n.setResizing(!0)}return this.timeline.getEdit().events.emit("resize:started",this.resizeInfo),!0}updateResize(e){if(!this.resizeInfo)return;const t=e.global.x-this.resizeInfo.startX,r=this.timeline.getOptions().pixelsPerSecond||50,i=t/r,n=Math.max(.1,this.resizeInfo.originalLength+i),a=this.timeline.getVisualTracks()[this.resizeInfo.trackIndex];if(a){const o=a.getClip(this.resizeInfo.clipIndex);if(o){const c=n*r;o.setPreviewWidth(c),this.timeline.getEdit().events.emit("resize:updated",{width:c})}}}completeResize(e){if(!this.resizeInfo)return;const t=e.global.x-this.resizeInfo.startX,r=this.timeline.getOptions().pixelsPerSecond||50,i=t/r,n=Math.max(.1,this.resizeInfo.originalLength+i),a=this.timeline.getVisualTracks()[this.resizeInfo.trackIndex];if(a){const o=a.getClip(this.resizeInfo.clipIndex);o&&(o.setResizing(!1),o.setPreviewWidth(null))}if(Math.abs(n-this.resizeInfo.originalLength)>.01){const o=new $2(this.resizeInfo.trackIndex,this.resizeInfo.clipIndex,n);this.timeline.getEdit().executeEditCommand(o),this.timeline.getEdit().events.emit("resize:ended",{newLength:n})}this.endResize()}getCursorForPosition(e,t){return e&&this.isOnClipRightEdge(e,t)?"ew-resize":""}getResizeThreshold(){const{trackHeight:e}=this.timeline.getLayout();return Math.max(this.thresholds.resize.min,Math.min(this.thresholds.resize.max,e*this.thresholds.resize.ratio))}endResize(){this.resizeInfo=null,this.timeline.getPixiApp().canvas.style.cursor="default"}getResizeInfo(){return this.resizeInfo}dispose(){this.endResize()}}class U2{timeline;thresholds;constructor(e,t){this.timeline=e,this.thresholds=t}getAllSnapPoints(e,t){const r=[];this.timeline.getVisualTracks().forEach((a,o)=>{a.getClips().forEach((u,h)=>{if(o===e&&h===t)return;const l=u.getClipConfig();l&&(r.push({time:l.start||0,type:"clip-start",trackIndex:o,clipIndex:h}),r.push({time:(l.start||0)+(l.length||0),type:"clip-end",trackIndex:o,clipIndex:h}))})});const n=this.timeline.getPlayheadTime();return r.push({time:n,type:"playhead"}),r}getTrackSnapPoints(e,t){return this.getAllSnapPoints(e,t).filter(r=>r.trackIndex===void 0||r.trackIndex===e)}calculateSnapPosition(e,t,r,i){const n=this.timeline.getOptions().pixelsPerSecond||50,a=this.thresholds.snap.pixels/n,o=this.getTrackSnapPoints(t,i);let c=null;for(const u of o){const h=Math.abs(e-u.time);h<a&&(!c||h<c.distance)&&(c={time:u.time,type:u.type,distance:h});const l=Math.abs(e+r-u.time);l<a&&(!c||l<c.distance)&&(c={time:u.time-r,type:u.type,distance:l})}return c?{time:c.time,snapped:!0,snapType:c.type}:{time:e,snapped:!1}}findAlignedElements(e,t,r,i){const a=e+t,o=new Map;this.timeline.getVisualTracks().forEach((u,h)=>{u.getClips().forEach((l,d)=>{if(h===r&&d===i)return;const f=l.getClipConfig();if(!f)return;const p=f.start||0,m=p+(f.length||0);[{time:p,aligns:[e,a]},{time:m,aligns:[e,a]}].forEach(({time:v,aligns:g})=>{g.some(y=>Math.abs(y-v)<.1)&&(o.has(v)||o.set(v,{tracks:new Set,isPlayhead:!1}),o.get(v).tracks.add(h))})})});const c=this.timeline.getPlayheadTime();return(Math.abs(e-c)<.1||Math.abs(a-c)<.1)&&(o.has(c)||o.set(c,{tracks:new Set,isPlayhead:!0}),o.get(c).isPlayhead=!0),Array.from(o.entries()).map(([u,h])=>({time:u,tracks:Array.from(h.tracks).concat(r),isPlayhead:h.isPlayhead}))}}class H2{timeline;graphics=new Map;constructor(e){this.timeline=e}showDropZone(e){this.hideDropZone();const t=new U.Graphics,r=this.timeline.getLayout(),i=this.timeline.getExtendedTimelineWidth(),n=e.position*r.trackHeight,o=this.timeline.getTheme().timeline.trackInsertion;t.setStrokeStyle({width:4,color:o,alpha:.8}),t.moveTo(0,n),t.lineTo(i,n),t.stroke(),t.setStrokeStyle({width:8,color:o,alpha:.3}),t.moveTo(0,n),t.lineTo(i,n),t.stroke(),this.timeline.getContainer().addChild(t),this.graphics.set("dropZone",t)}hideDropZone(){this.hideGraphics("dropZone")}showSnapGuidelines(e){this.hideSnapGuidelines();const t=new U.Graphics,r=this.timeline.getLayout(),i=this.timeline.getTheme();e.forEach(({time:n,tracks:a,isPlayhead:o})=>{const c=r.getXAtTime(n),u=Math.min(...a),h=Math.max(...a),l=u*r.trackHeight,d=(h+1)*r.trackHeight,f=o?i.timeline.playhead:i.timeline.snapGuide;t.setStrokeStyle({width:3,color:f,alpha:.3}),t.moveTo(c,l),t.lineTo(c,d),t.stroke(),t.setStrokeStyle({width:1,color:f,alpha:.8}),t.moveTo(c,l),t.lineTo(c,d),t.stroke()}),this.timeline.getContainer().addChild(t),this.graphics.set("snapGuidelines",t)}hideSnapGuidelines(){this.hideGraphics("snapGuidelines")}showTargetTrack(e){this.hideTargetTrack();const t=new U.Graphics,r=this.timeline.getLayout(),i=this.timeline.getExtendedTimelineWidth(),n=e*r.trackHeight,a=r.trackHeight,c=this.timeline.getTheme().timeline.dropZone;t.rect(0,n,i,a),t.fill({color:c,alpha:.1}),t.setStrokeStyle({width:1,color:c,alpha:.3}),t.rect(0,n,i,a),t.stroke(),this.timeline.getContainer().addChild(t),this.graphics.set("targetTrack",t)}hideTargetTrack(){this.hideGraphics("targetTrack")}hideAll(){this.graphics.forEach((e,t)=>this.hideGraphics(t))}hideGraphics(e){const t=this.graphics.get(e);t&&(t.clear(),t.parent&&t.parent.removeChild(t),t.destroy(),this.graphics.delete(e))}dispose(){this.hideAll(),this.graphics.clear()}}class V2{timeline;state={type:"idle"};abortController;dragHandler;resizeHandler;snapManager;collisionDetector;visualFeedback;thresholds={drag:{base:3,small:2},resize:{min:12,max:20,ratio:.4},dropZone:{ratio:.15},snap:{pixels:10,time:.1}};constructor(e,t){if(this.timeline=e,t){const r=structuredClone(this.thresholds);t.drag&&Object.assign(r.drag,t.drag),t.resize&&Object.assign(r.resize,t.resize),t.dropZone&&Object.assign(r.dropZone,t.dropZone),t.snap&&Object.assign(r.snap,t.snap),this.thresholds=r}this.snapManager=new U2(e,this.thresholds),this.collisionDetector=new B2(e),this.visualFeedback=new H2(e),this.dragHandler=new z2(e,this.thresholds,this.snapManager,this.collisionDetector,this.visualFeedback),this.resizeHandler=new N2(e,this.thresholds)}activate(){this.abortController=new AbortController,this.setupEventListeners(),this.dragHandler.activate(),this.resizeHandler.activate()}deactivate(){this.abortController&&(this.abortController.abort(),this.abortController=void 0),this.resetState(),this.dragHandler.deactivate(),this.resizeHandler.deactivate()}setupEventListeners(){const e=this.timeline.getPixiApp();e.stage.interactive=!0,e.stage.on("pointerdown",this.handlePointerDown.bind(this),{signal:this.abortController?.signal}),e.stage.on("pointermove",this.handlePointerMove.bind(this),{signal:this.abortController?.signal}),e.stage.on("pointerup",this.handlePointerUp.bind(this),{signal:this.abortController?.signal}),e.stage.on("pointerupoutside",this.handlePointerUp.bind(this),{signal:this.abortController?.signal})}handlePointerDown(e){const t=e.target;if(t.label){const r=this.parseClipLabel(t.label);if(r){if(this.resizeHandler.isOnClipRightEdge(r,e)){if(this.resizeHandler.startResize(r,e)){const i=this.resizeHandler.getResizeInfo();i&&(this.state={type:"resizing",resizeInfo:i})}return}this.state={type:"selecting",startPos:{x:e.global.x,y:e.global.y},clipInfo:r},this.timeline.getPixiApp().canvas.style.cursor="grab";return}}this.timeline.getEdit().clearSelection()}handlePointerMove(e){switch(this.state.type){case"selecting":this.handleSelectingMove(e);break;case"dragging":this.timeline.getPixiApp().canvas.style.cursor="grabbing",this.dragHandler.updateDrag(e);break;case"resizing":this.timeline.getPixiApp().canvas.style.cursor="ew-resize",this.resizeHandler.updateResize(e);break;case"idle":this.updateCursorForPosition(e);break}}handlePointerUp(e){switch(this.state.type){case"selecting":this.timeline.getEdit().selectClip(this.state.clipInfo.trackIndex,this.state.clipInfo.clipIndex);break;case"dragging":this.dragHandler.completeDrag(e);break;case"resizing":this.resizeHandler.completeResize(e);break}this.resetState()}handleSelectingMove(e){if(this.state.type!=="selecting")return;const t={x:e.global.x,y:e.global.y};if(this.dragHandler.canStartDrag(this.state.startPos,t)&&this.dragHandler.startDrag(this.state.clipInfo,e)){const r=this.dragHandler.getDragInfo();r&&(this.state={type:"dragging",dragInfo:r})}}updateCursorForPosition(e){const t=e.target;if(t.label){const r=this.parseClipLabel(t.label);if(r){const i=this.resizeHandler.getCursorForPosition(r,e);if(i){this.timeline.getPixiApp().canvas.style.cursor=i;return}this.timeline.getPixiApp().canvas.style.cursor="grab";return}}this.timeline.getPixiApp().canvas.style.cursor="default"}parseClipLabel(e){if(!e?.startsWith("clip-"))return null;const t=e.split("-");if(t.length!==3)return null;const r=parseInt(t[1],10),i=parseInt(t[2],10);return Number.isNaN(r)||Number.isNaN(i)?null:{trackIndex:r,clipIndex:i}}resetState(){this.state={type:"idle"},this.visualFeedback.hideAll(),this.timeline.getPixiApp().canvas.style.cursor="default"}dispose(){this.deactivate(),this.dragHandler.dispose(),this.resizeHandler.dispose(),this.visualFeedback.dispose()}}class j2{constructor(e,t,r,i,n){this.container=e,this.layout=t,this.getPixelsPerSecond=r,this.getTrackHeight=i,this.getVisualTracks=n}dragPreviewContainer=null;dragPreviewGraphics=null;draggedClipInfo=null;showDragPreview(e,t,r){if(!r)return;this.draggedClipInfo={trackIndex:e,clipIndex:t,clipConfig:r},this.dragPreviewContainer=new U.Container,this.dragPreviewGraphics=new U.Graphics,this.dragPreviewContainer.addChild(this.dragPreviewGraphics),this.container.addChild(this.dragPreviewContainer),this.getVisualTracks()[e]?.getClip(t)?.setDragging(!0),this.drawDragPreview(e,r.start||0)}drawDragPreview(e,t){if(!this.dragPreviewContainer||!this.dragPreviewGraphics||!this.draggedClipInfo)return;const{clipConfig:r}=this.draggedClipInfo,i=this.layout.getXAtTime(t),n=e*this.layout.trackHeight,a=(r.length||0)*this.getPixelsPerSecond();this.dragPreviewGraphics.clear(),this.dragPreviewGraphics.roundRect(0,0,a,this.getTrackHeight(),4),this.dragPreviewGraphics.fill({color:9342611,alpha:.6}),this.dragPreviewGraphics.stroke({width:2,color:65280}),this.dragPreviewContainer.position.set(i,n)}drawDragPreviewAtPosition(e,t,r){if(!this.dragPreviewContainer||!this.dragPreviewGraphics||!this.draggedClipInfo)return;const{clipConfig:i}=this.draggedClipInfo,n=this.layout.getXAtTime(e),a=(i.length||0)*this.getPixelsPerSecond(),o=this.getTrackHeight();this.dragPreviewGraphics.clear(),this.dragPreviewGraphics.roundRect(0,0,a,o,4),this.dragPreviewGraphics.fill({color:9342611,alpha:.6});const c=r*this.layout.trackHeight,h=Math.abs(t-c)<5?65280:16755200;this.dragPreviewGraphics.stroke({width:2,color:h}),this.dragPreviewContainer.position.set(n,t)}hideDragPreview(){this.dragPreviewContainer&&(this.dragPreviewContainer.destroy({children:!0}),this.dragPreviewContainer=null,this.dragPreviewGraphics=null),this.draggedClipInfo&&(this.getVisualTracks()[this.draggedClipInfo.trackIndex]?.getClip(this.draggedClipInfo.clipIndex)?.setDragging(!1),this.draggedClipInfo=null)}hideDragGhost(){this.dragPreviewContainer&&(this.dragPreviewContainer.visible=!1)}showDragGhost(e,t,r){!this.dragPreviewContainer||!this.draggedClipInfo||(this.dragPreviewContainer.visible=!0,r!==void 0?this.drawDragPreviewAtPosition(t,r,e):this.drawDragPreview(e,t))}getDraggedClipInfo(){return this.draggedClipInfo}hasActivePreview(){return this.dragPreviewContainer!==null}dispose(){this.hideDragPreview()}}class W2{constructor(e,t,r,i,n){this.layout=e,this.trackLayer=t,this.overlayLayer=r,this.entityContainer=i,this.onRender=n}scrollX=0;scrollY=0;zoomLevel=1;viewport;rulerViewport;playheadContainer;async setupViewport(){this.rulerViewport=new U.Container,this.rulerViewport.label="ruler-viewport",this.overlayLayer.addChild(this.rulerViewport),this.playheadContainer=new U.Container,this.playheadContainer.label="playhead-container",this.overlayLayer.addChild(this.playheadContainer),this.viewport=new U.Container,this.viewport.label="viewport",this.trackLayer.addChild(this.viewport),this.viewport.addChild(this.entityContainer)}updateViewportTransform(){const e=this.layout.calculateViewportPosition(this.scrollX,this.scrollY);this.viewport.position.set(e.x,e.y),this.viewport.scale.set(this.zoomLevel,this.zoomLevel),this.rulerViewport.position.x=e.x,this.rulerViewport.scale.x=this.zoomLevel,this.playheadContainer.position.x=e.x,this.playheadContainer.scale.x=this.zoomLevel}setScroll(e,t){this.scrollX=e,this.scrollY=t,this.updateViewportTransform(),this.onRender()}setZoom(e){this.zoomLevel=Math.max(.1,Math.min(10,e)),this.updateViewportTransform(),this.onRender()}getViewport(){return{x:this.scrollX,y:this.scrollY,zoom:this.zoomLevel}}getMainViewport(){return this.viewport}getRulerViewport(){return this.rulerViewport}getPlayheadContainer(){return this.playheadContainer}}const At={MIN_WIDTH:50,PADDING:4,DEFAULT_ALPHA:1,DRAG_OPACITY:.6,RESIZE_OPACITY:.9,BORDER_WIDTH:2,CORNER_RADIUS:4,SELECTED_BORDER_MULTIPLIER:2,TEXT_FONT_SIZE:12,TEXT_TRUNCATE_SUFFIX_LENGTH:3},Is={PADDING:2,LABEL_PADDING:8,DEFAULT_OPACITY:.8,BORDER_WIDTH:1},Nt={TOOLBAR_HEIGHT_RATIO:.12,RULER_HEIGHT_RATIO:.133,TOOLBAR_HEIGHT_DEFAULT:36,RULER_HEIGHT_DEFAULT:40,TRACK_HEIGHT_DEFAULT:80,BORDER_WIDTH:2,CORNER_RADIUS:4,CLIP_PADDING:4,LABEL_PADDING:8,TRACK_PADDING:2,MIN_CLIP_WIDTH:50};function jn(s){const e=s.split("/");return e[e.length-1]||s}function G2(s){switch(s.type){case"video":return s.src?jn(s.src):"Video";case"audio":return s.src?jn(s.src):"Audio";case"image":return s.src?jn(s.src):"Image";case"text":return s.text||"Text";case"rich-text":return s.text||"Rich Text";case"shape":return s.shape||"Shape";case"html":return"HTML";case"luma":return s.src?jn(s.src):"Luma";default:return"Unknown Asset"}}class q2 extends xr{clipConfig;options;graphics;background;text;selectionRenderer;lastGlobalX=-1;lastGlobalY=-1;visualState={mode:"normal"};CLIP_PADDING=At.PADDING;BORDER_WIDTH=At.BORDER_WIDTH;get CORNER_RADIUS(){return this.options.theme.timeline.clips.radius||At.CORNER_RADIUS}constructor(e,t){super(),this.clipConfig=e,this.options=t,this.selectionRenderer=t.selectionRenderer,this.graphics=new U.Graphics,this.background=new U.Graphics,this.text=new U.Text,this.setupContainer()}async load(){this.setupGraphics(),this.updateVisualState()}setupContainer(){const e=this.getContainer();e.label=`clip-${this.options.trackIndex}-${this.options.clipIndex}`,e.interactive=!0,e.cursor="pointer",e.addChild(this.background),e.addChild(this.graphics),e.addChild(this.text)}setupGraphics(){this.text.style=new U.TextStyle({fontSize:At.TEXT_FONT_SIZE,fill:this.options.theme.timeline.toolbar.text,fontWeight:"bold",wordWrap:!1,fontFamily:"Arial, sans-serif"}),this.text.anchor.set(0,0),this.text.x=this.CLIP_PADDING,this.text.y=this.CLIP_PADDING}updateFromConfig(e){this.clipConfig=e,this.updateVisualState()}updateVisualState(){this.updatePosition(),this.updateAppearance(),this.updateSize(),this.updateText()}setVisualState(e){this.visualState={...this.visualState,...e},this.updateVisualState()}updatePosition(){const e=this.getContainer(),t=this.clipConfig.start||0;e.x=t*this.options.pixelsPerSecond,e.y=0}updateSize(){const e=this.getEffectiveWidth(),t=this.options.trackHeight;this.drawClipBackground(e,t),this.drawClipBorder(e,t)}getEffectiveWidth(){if(this.visualState.previewWidth!==void 0)return this.visualState.previewWidth;const t=(this.clipConfig.length||0)*this.options.pixelsPerSecond;return Math.max(At.MIN_WIDTH,t)}drawClipBackground(e,t){const r=this.getClipColor(),i=this.getStateStyles();this.background.clear(),this.background.roundRect(0,0,e,t,this.CORNER_RADIUS),this.background.fill({color:r,alpha:i.alpha})}drawClipBorder(e,t){const r=this.getStateStyles(),i=this.BORDER_WIDTH;this.graphics.clear(),this.graphics.roundRect(0,0,e,t,this.CORNER_RADIUS),this.graphics.stroke({width:i,color:r.borderColor}),this.updateSelectionState(e,t)}updateSelectionState(e,t){if(!this.selectionRenderer)return;const r=this.visualState.mode==="selected",i=this.getClipId();if(!r){this.selectionRenderer.clearSelection(i);return}const a=this.getContainer().toGlobal(new U.Point(0,0)),c=this.selectionRenderer.getOverlay().toLocal(a);this.selectionRenderer.renderSelection(i,{x:c.x,y:c.y,width:e,height:t,cornerRadius:this.CORNER_RADIUS,borderWidth:this.BORDER_WIDTH},r)}getClipColor(){const e=this.clipConfig.asset?.type,t=this.options.theme.timeline.clips;switch(e){case"video":return t.video;case"audio":return t.audio;case"image":return t.image;case"text":return t.text;case"rich-text":return t["rich-text"]||t.text;case"shape":return t.shape;case"html":return t.html;case"luma":return t.luma;default:return t.default}}updateAppearance(){const e=this.getContainer();e.alpha=this.visualState.mode==="dragging"?At.DRAG_OPACITY:At.DEFAULT_ALPHA}updateText(){const e=this.clipConfig.asset?G2(this.clipConfig.asset):"Clip";this.text.text=e;const r=(this.clipConfig.length||0)*this.options.pixelsPerSecond-this.CLIP_PADDING*2;if(this.text.width>r){const i=r/this.text.width,n=Math.floor(e.length*i)-At.TEXT_TRUNCATE_SUFFIX_LENGTH;this.text.text=`${e.substring(0,Math.max(1,n))}...`}}getStateStyles(){const{theme:e}=this.options;switch(this.visualState.mode){case"dragging":return{alpha:At.DRAG_OPACITY,borderColor:e.timeline.tracks.border};case"resizing":return{alpha:At.RESIZE_OPACITY,borderColor:e.timeline.dropZone};case"selected":return{alpha:At.DEFAULT_ALPHA,borderColor:e.timeline.clips.selected};default:return{alpha:At.DEFAULT_ALPHA,borderColor:e.timeline.tracks.border}}}setSelected(e){this.setVisualState({mode:e?"selected":"normal"})}setDragging(e){this.setVisualState({mode:e?"dragging":"normal"})}setResizing(e){this.setVisualState({mode:e?"resizing":"normal",...e?{}:{previewWidth:void 0}})}setPreviewWidth(e){this.setVisualState({previewWidth:e||void 0})}setPixelsPerSecond(e){if(this.updateOptions({pixelsPerSecond:e}),this.visualState.mode==="selected"){const t=this.getEffectiveWidth(),r=this.options.trackHeight;this.updateSelectionState(t,r)}}updateOptions(e){this.options={...this.options,...e},this.updateVisualState()}getClipConfig(){return this.clipConfig}getOptions(){return{...this.options}}getVisualState(){return{...this.visualState}}getSelected(){return this.visualState.mode==="selected"}getClipId(){return`${this.options.trackIndex}-${this.options.clipIndex}`}getDragging(){return this.visualState.mode==="dragging"}getRightEdgeX(){const e=this.getEffectiveWidth();return(this.clipConfig.start||0)*this.options.pixelsPerSecond+e}update(e,t){if(this.visualState.mode==="selected"&&this.selectionRenderer){const i=this.getContainer().toGlobal(new U.Point(0,0));if(i.x!==this.lastGlobalX||i.y!==this.lastGlobalY){this.lastGlobalX=i.x,this.lastGlobalY=i.y;const n=this.getEffectiveWidth(),a=this.options.trackHeight;this.updateSelectionState(n,a)}}}draw(){}dispose(){this.selectionRenderer&&this.selectionRenderer.clearSelection(this.getClipId()),this.background.destroy(),this.graphics.destroy(),this.text.destroy()}}class X2 extends xr{clips=[];options;background;TRACK_PADDING=Is.PADDING;LABEL_PADDING=Is.LABEL_PADDING;constructor(e){super(),this.options=e,this.background=new U.Graphics,this.setupContainer()}async load(){this.updateTrackAppearance()}setupContainer(){const e=this.getContainer();e.label=`track-${this.options.trackIndex}`,e.addChild(this.background),e.y=this.options.trackIndex*this.options.trackHeight}updateTrackAppearance(){const{width:e}=this.options,t=this.options.trackHeight,{theme:r}=this.options;this.background.clear();const i=this.options.trackIndex%2===0?r.timeline.tracks.surface:r.timeline.tracks.surfaceAlt;this.background.rect(0,0,e,t),this.background.fill({color:i,alpha:Is.DEFAULT_OPACITY}),this.background.rect(0,0,e,t),this.background.stroke({width:Is.BORDER_WIDTH,color:r.timeline.tracks.border}),this.background.moveTo(0,t-1),this.background.lineTo(e,t-1),this.background.stroke({width:Is.BORDER_WIDTH,color:r.timeline.divider})}rebuildFromTrackData(e,t){this.options={...this.options,pixelsPerSecond:t},this.clearAllClips(),e.clips&&e.clips.forEach((r,i)=>{const n={pixelsPerSecond:this.options.pixelsPerSecond,trackHeight:this.options.trackHeight,trackIndex:this.options.trackIndex,clipIndex:i,theme:this.options.theme,selectionRenderer:this.options.selectionRenderer},a=new q2(r,n);this.addClip(a)}),this.updateTrackAppearance()}async addClip(e){this.clips.push(e),await e.load(),this.getContainer().addChild(e.getContainer())}clearAllClips(){const e=this.getContainer();for(const t of this.clips)e.removeChild(t.getContainer()),t.dispose();this.clips=[]}removeClip(e){if(e>=0&&e<this.clips.length){const t=this.clips[e];this.getContainer().removeChild(t.getContainer()),t.dispose(),this.clips.splice(e,1)}}updateClip(e,t){e>=0&&e<this.clips.length&&this.clips[e].updateFromConfig(t)}setPixelsPerSecond(e){this.options={...this.options,pixelsPerSecond:e},this.clips.forEach(t=>{t.setPixelsPerSecond(e)})}setWidth(e){this.options={...this.options,width:e},this.updateTrackAppearance()}setTrackIndex(e){this.options={...this.options,trackIndex:e};const t=this.getContainer();t.y=e*this.options.trackHeight,this.clips.forEach((r,i)=>{r.updateOptions({trackIndex:e})})}selectClip(e){this.clearAllSelections(),e>=0&&e<this.clips.length&&this.clips[e].setSelected(!0)}clearAllSelections(){this.clips.forEach(e=>{e.setSelected(!1)})}getSelectedClip(){return this.clips.find(e=>e.getSelected())||null}getSelectedClipIndex(){return this.clips.findIndex(e=>e.getSelected())}getClips(){return[...this.clips]}getClip(e){return this.clips[e]||null}getClipCount(){return this.clips.length}getTrackIndex(){return this.options.trackIndex}getTrackHeight(){return this.options.trackHeight}getOptions(){return{...this.options}}findClipAtPosition(e,t){if(t<0||t>this.options.trackHeight)return null;const r=e/this.options.pixelsPerSecond;for(let i=0;i<this.clips.length;i+=1){const n=this.clips[i],a=n.getClipConfig(),o=a.start||0,c=o+(a.length||0);if(r>=o&&r<=c)return{clip:n,clipIndex:i}}return null}update(e,t){this.clips.forEach(r=>{r.update(e,t)})}draw(){this.clips.forEach(e=>{e.draw()})}dispose(){this.clearAllClips(),this.background.destroy()}}class Z2{constructor(e,t){this.overlay=e,this.theme=t}selectionGraphics=new Map;renderSelection(e,t,r){if(!r){this.clearSelection(e);return}let i=this.selectionGraphics.get(e);i||(i=new U.Graphics,i.label=`selection-border-${e}`,this.selectionGraphics.set(e,i),this.overlay.addChild(i)),i.position.set(t.x,t.y),i.clear(),i.setStrokeStyle({width:t.borderWidth*At.SELECTED_BORDER_MULTIPLIER,color:this.theme.timeline.clips.selected}),i.roundRect(0,0,t.width,t.height,t.cornerRadius),i.stroke()}clearSelection(e){const t=this.selectionGraphics.get(e);t&&(this.overlay.removeChild(t),t.destroy(),this.selectionGraphics.delete(e))}clearAllSelections(){this.selectionGraphics.forEach((e,t)=>{this.clearSelection(t)})}updateTheme(e){this.theme=e,this.selectionGraphics.forEach(t=>{t.clear()})}getOverlay(){return this.overlay}dispose(){this.clearAllSelections()}}class K2{constructor(e,t,r,i,n){this.container=e,this.layout=t,this.theme=r,this.getPixelsPerSecond=i,this.getExtendedTimelineWidth=n,this.selectionOverlay=new U.Container,this.selectionOverlay.label="selectionOverlay",this.container.addChild(this.selectionOverlay),this.selectionRenderer=new Z2(this.selectionOverlay,this.theme)}visualTracks=[];selectionOverlay;selectionRenderer;async rebuildFromEdit(e,t){if(e?.timeline?.tracks){this.clearAllVisualState();for(let r=0;r<e.timeline.tracks.length;r+=1){const i=e.timeline.tracks[r],n={pixelsPerSecond:t,trackHeight:this.layout.trackHeight,trackIndex:r,width:this.getExtendedTimelineWidth(),theme:this.theme,selectionRenderer:this.selectionRenderer},a=new X2(n);await a.load(),a.rebuildFromTrackData(i,t),this.container.addChild(a.getContainer()),this.visualTracks.push(a)}this.container.setChildIndex(this.selectionOverlay,this.container.children.length-1)}}clearAllVisualState(){this.visualTracks.forEach(e=>{this.container.removeChild(e.getContainer()),e.dispose()}),this.visualTracks=[],this.selectionRenderer.clearAllSelections()}updateVisualSelection(e,t){this.clearVisualSelection();const r=this.visualTracks[e];if(r){const i=r.getClip(t);i&&i.setSelected(!0)}}clearVisualSelection(){this.visualTracks.forEach(e=>{e.getClips().forEach(r=>{r.setSelected(!1)})})}findClipAtPosition(e,t){const r=Math.floor(t/this.layout.trackHeight);if(r<0||r>=this.visualTracks.length)return null;const i=this.visualTracks[r],n=t-r*this.layout.trackHeight,a=i.findClipAtPosition(e,n);return a?{trackIndex:r,clipIndex:a.clipIndex,clipConfig:a.clip.getClipConfig(),x:(a.clip.getClipConfig().start||0)*this.getPixelsPerSecond(),y:r*this.layout.trackHeight,width:(a.clip.getClipConfig().length||0)*this.getPixelsPerSecond(),height:this.layout.trackHeight}:null}updateTrackWidths(e){this.visualTracks.forEach(t=>{t.setWidth(e)})}getVisualTracks(){return this.visualTracks}updatePixelsPerSecond(e){this.visualTracks.forEach(t=>{t.setPixelsPerSecond(e)})}getSelectionOverlay(){return this.selectionOverlay}getSelectionRenderer(){return this.selectionRenderer}dispose(){this.clearAllVisualState(),this.selectionRenderer&&this.selectionRenderer.dispose(),this.selectionOverlay&&this.container&&(this.container.removeChild(this.selectionOverlay),this.selectionOverlay.destroy())}}class Y2{constructor(e,t){this.edit=e,this.callbacks=t}setupEventListeners(){this.edit.events.on("timeline:updated",this.handleTimelineUpdated.bind(this)),this.edit.events.on("clip:updated",this.handleClipUpdated.bind(this)),this.edit.events.on("clip:selected",this.handleClipSelected.bind(this)),this.edit.events.on("selection:cleared",this.handleSelectionCleared.bind(this)),this.edit.events.on("drag:started",this.handleDragStarted.bind(this)),this.edit.events.on("drag:ended",this.handleDragEnded.bind(this)),this.edit.events.on("track:created",this.handleTrackCreated.bind(this))}async handleTimelineUpdated(e){await this.callbacks.onEditChange(e.current)}async handleClipUpdated(){await this.callbacks.onEditChange()}handleClipSelected(e){this.callbacks.onClipSelected(e.trackIndex,e.clipIndex)}handleSelectionCleared(){this.callbacks.onSelectionCleared()}handleDragStarted(e){this.callbacks.onDragStarted(e.trackIndex,e.clipIndex)}handleDragEnded(){this.callbacks.onDragEnded()}async handleTrackCreated(){await this.callbacks.onEditChange()}handleSeek(e){this.callbacks.onSeek(e.time*1e3)}dispose(){this.edit.events.off("timeline:updated",this.handleTimelineUpdated.bind(this)),this.edit.events.off("clip:updated",this.handleClipUpdated.bind(this)),this.edit.events.off("clip:selected",this.handleClipSelected.bind(this)),this.edit.events.off("selection:cleared",this.handleSelectionCleared.bind(this)),this.edit.events.off("drag:started",this.handleDragStarted.bind(this)),this.edit.events.off("drag:ended",this.handleDragEnded.bind(this)),this.edit.events.off("track:created",this.handleTrackCreated.bind(this))}}class J2{constructor(e,t){this.options=e,this.onUpdate=t}app;trackLayer;overlayLayer;animationFrameId=null;async initializePixiApp(){this.app=new U.Application,await this.app.init({width:this.options.width,height:this.options.height,backgroundColor:this.options.backgroundColor,antialias:this.options.antialias,resolution:this.options.resolution,autoDensity:!0,preference:"webgl"});const e=document.querySelector("[data-shotstack-timeline]");if(!e)throw new Error("Timeline container element [data-shotstack-timeline] not found");e.appendChild(this.app.canvas)}async setupRenderLayers(){this.trackLayer=new U.Container,this.overlayLayer=new U.Container,this.trackLayer.label="track-layer",this.overlayLayer.label="overlay-layer",this.app.stage.addChild(this.trackLayer),this.app.stage.addChild(this.overlayLayer)}startAnimationLoop(){let e=performance.now();const t=r=>{const i=r-e;e=r;const n=i/16.667;this.onUpdate(n,i),this.draw(),this.animationFrameId=requestAnimationFrame(t)};this.animationFrameId=requestAnimationFrame(t)}draw(){this.app.render()}render(){this.app.render()}updateBackgroundColor(e){this.app&&(this.app.renderer.background.color=e)}getApp(){return this.app}getStage(){return this.app.stage}getTrackLayer(){return this.trackLayer}getOverlayLayer(){return this.overlayLayer}dispose(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.app&&this.app.destroy(!0)}}const zi={RULER:{DEFAULT_HEIGHT:40,LABEL_FONT_SIZE:10,LABEL_PADDING_X:2},PLAYHEAD:{LINE_WIDTH:2},SCROLL:{HORIZONTAL_SPEED:2,VERTICAL_SPEED:.5}};class th extends xr{events;rulerContainer;rulerBackground;timeMarkers;timeLabels;pixelsPerSecond;timelineDuration;rulerHeight;theme;constructor(e){super(),this.events=new vs,this.pixelsPerSecond=e.pixelsPerSecond,this.timelineDuration=e.timelineDuration,this.rulerHeight=e.rulerHeight??zi.RULER.DEFAULT_HEIGHT,this.theme=e.theme,this.rulerContainer=new U.Container,this.rulerBackground=new U.Graphics,this.timeMarkers=new U.Graphics,this.timeLabels=new U.Container}async load(){this.setupRuler(),this.draw()}setupRuler(){this.rulerContainer.label="ruler",this.rulerContainer.addChild(this.rulerBackground),this.rulerContainer.addChild(this.timeMarkers),this.rulerContainer.addChild(this.timeLabels),this.rulerContainer.eventMode="static",this.rulerContainer.cursor="pointer",this.rulerContainer.on("pointerdown",this.onRulerPointerDown.bind(this)),this.getContainer().addChild(this.rulerContainer)}drawRulerBackground(){this.rulerBackground.clear();const e=this.calculateRulerWidth(),t=this.theme?.timeline.ruler.background||4210752,r=this.theme?.timeline.tracks.border||6316128;this.rulerBackground.rect(0,0,e,this.rulerHeight),this.rulerBackground.fill(t),this.rulerBackground.rect(0,this.rulerHeight-1,e,1),this.rulerBackground.fill(r)}drawTimeMarkers(){this.timeMarkers.clear();const e=this.getTimeInterval(),t=this.getVisibleDuration(),r=this.theme?.timeline.ruler.markers||6710886,i=this.rulerHeight*.5;let n=4;e===10?n=9:(e===30||e===60)&&(n=5);const a=e/(n+1);for(let o=0;o<=t;o+=e)for(let c=1;c<=n;c+=1){const u=o+c*a;if(u<=t){const h=u*this.pixelsPerSecond;this.timeMarkers.circle(h,i,1.5),this.timeMarkers.fill(r)}}}drawTimeLabels(){this.timeLabels.removeChildren();const e=this.getTimeInterval(),t=this.getVisibleDuration(),r=this.theme?.timeline.ruler.text||16777215,i={fontSize:zi.RULER.LABEL_FONT_SIZE,fill:r,fontFamily:"Arial"};for(let n=0;n<=t;n+=e){const a=new U.Text({text:this.formatTime(n),style:i}),o=n*this.pixelsPerSecond;n===0?(a.anchor.set(0,.5),a.x=o+zi.RULER.LABEL_PADDING_X):(a.anchor.set(.5,.5),a.x=o),a.y=this.rulerHeight*.5,this.timeLabels.addChild(a)}}onRulerPointerDown(e){const t=this.rulerContainer.toLocal(e.global),r=Math.max(0,t.x/this.pixelsPerSecond);this.events.emit("ruler:seeked",{time:r})}updateRuler(e,t){this.pixelsPerSecond=e,this.timelineDuration=t,this.draw()}update(e,t){}draw(){this.drawRulerBackground(),this.drawTimeMarkers(),this.drawTimeLabels()}dispose(){this.timeLabels.removeChildren(),this.rulerContainer.removeChildren(),this.events.clear("*")}getViewportWidth(){return this.getContainer().parent?.width||800}calculateRulerWidth(){const e=this.timelineDuration*this.pixelsPerSecond;return Math.max(e,this.getViewportWidth())}getVisibleDuration(){return Math.max(this.timelineDuration,this.getViewportWidth()/this.pixelsPerSecond)}getTimeInterval(){const e=[1,5,10,30,60,120,300,600],t=80;for(const r of e)if(r*this.pixelsPerSecond>=t)return r;return Math.ceil(this.getVisibleDuration()/10)}formatTime(e){if(e===0)return"0s";const t=Math.floor(e/60),r=e%60;if(e<60)return`${e}s`;if(r===0)return`${t}m`;const i=r.toString().padStart(2,"0");return`${t}:${i}`}}class rh extends xr{constructor(e){super(),this.options=e,this.graphics=new U.Graphics}events=new vs;graphics;currentTime=0;isDragging=!1;async load(){this.setupPlayhead(),this.draw()}setupPlayhead(){this.graphics.label="playhead",this.graphics.eventMode="static",this.graphics.cursor="pointer",this.graphics.on("pointerdown",this.onPointerDown.bind(this)).on("pointermove",this.onPointerMove.bind(this)).on("pointerup",this.onPointerUp.bind(this)).on("pointerupoutside",this.onPointerUp.bind(this)),this.getContainer().addChild(this.graphics)}drawPlayhead(){const e=this.currentTime*this.options.pixelsPerSecond,t=this.options.theme?.timeline.playhead??16729156,r=zi.PLAYHEAD.LINE_WIDTH,i=e+r/2;this.graphics.clear(),this.graphics.fill(t),this.graphics.rect(e,0,r,this.options.timelineHeight);const n=8;this.graphics.moveTo(i,10),this.graphics.lineTo(i-n,0),this.graphics.lineTo(i+n,0),this.graphics.closePath(),this.graphics.fill()}onPointerDown(e){this.isDragging=!0,this.graphics.cursor="grabbing",this.updateTimeFromPointer(e)}onPointerMove(e){this.isDragging&&this.updateTimeFromPointer(e)}onPointerUp(){this.isDragging=!1,this.graphics.cursor="pointer"}updateTimeFromPointer(e){if(!this.graphics.parent)return;const t=this.graphics.parent.toLocal(e.global),r=Math.max(0,t.x/this.options.pixelsPerSecond);this.setTime(r),this.events.emit("playhead:seeked",{time:r})}setTime(e){this.currentTime=e,this.draw(),this.events.emit("playhead:timeChanged",{time:e})}getTime(){return this.currentTime}updatePlayhead(e,t){this.options.pixelsPerSecond=e,this.options.timelineHeight=t,this.draw()}update(){}draw(){this.drawPlayhead()}dispose(){this.graphics.removeAllListeners(),this.events.clear("*")}}class Q2{events;timeline;abortController;scrollX=0;scrollY=0;constructor(e){this.events=new vs,this.timeline=e.timeline}async initialize(){this.setupEventListeners()}setupEventListeners(){this.abortController=new AbortController;const{canvas:e}=this.timeline.getPixiApp();e.addEventListener("wheel",this.handleWheel.bind(this),{passive:!1,signal:this.abortController.signal})}handleWheel(e){if(e.preventDefault(),e.ctrlKey||e.metaKey){this.handleZoom(e);return}this.handleScroll(e)}handleZoom(e){const t=e.deltaY>0?"out":"in",r=this.timeline.getPlayheadTime(),i=this.timeline.getActualEditDuration();t==="in"?this.timeline.zoomIn():this.timeline.zoomOut();const n=this.timeline.getOptions().pixelsPerSecond||50,a=r*n,o=this.timeline.getOptions().width||800,u=this.timeline.timeRange.endTime*n,h=i*n,l=this.calculateZoomScrollPosition({playheadXAfterZoom:a,viewportWidth:o,contentWidth:u,maxPlayheadX:h,actualEditDuration:i,playheadTime:r});this.scrollX=l,this.timeline.setScroll(this.scrollX,this.scrollY);const d=a-l;this.events.emit("zoom",{pixelsPerSecond:n,focusX:d,focusTime:r})}handleScroll(e){let{deltaX:t}=e,{deltaY:r}=e;e.shiftKey&&(t=r,r=0);const i=zi.SCROLL.HORIZONTAL_SPEED,n=zi.SCROLL.VERTICAL_SPEED;this.scrollX+=t*i,this.scrollY+=r*n,this.scrollX=this.clampScrollX(this.scrollX),this.scrollY=this.clampScrollY(this.scrollY),this.timeline.setScroll(this.scrollX,this.scrollY),this.events.emit("scroll",{x:this.scrollX,y:this.scrollY})}setScroll(e,t){this.scrollX=this.clampScrollX(e),this.scrollY=this.clampScrollY(t),this.timeline.setScroll(this.scrollX,this.scrollY),this.events.emit("scroll",{x:this.scrollX,y:this.scrollY})}clampScrollX(e){const t=this.timeline.getExtendedTimelineWidth(),r=this.timeline.getOptions().width||0,i=Math.max(0,t-r);return Math.max(0,Math.min(e,i))}clampScrollY(e){const t=this.timeline.getLayout(),r=this.timeline.getVisualTracks().length,i=this.timeline.getOptions().height||0,n=Math.max(0,r*t.trackHeight-(i-t.rulerHeight));return Math.max(0,Math.min(e,n))}getScroll(){return{x:this.scrollX,y:this.scrollY}}calculateZoomScrollPosition(e){const{playheadXAfterZoom:t,viewportWidth:r,contentWidth:i,maxPlayheadX:n,actualEditDuration:a,playheadTime:o}=e,c=t-r/2,u=Math.max(0,i-r);let h;const l=c+r,d=Math.max(0,n-r);i<=r||c<0?h=0:l>n&&o<=a?h=Math.min(d,u):c>u?h=u:h=c;const f=t-h;return(f<0||f>r)&&(t>i-r?h=Math.max(0,t-r+50):h=Math.max(0,t-50),h=Math.max(0,Math.min(h,u))),h}dispose(){this.abortController&&(this.abortController.abort(),this.abortController=void 0),this.events.clear("*")}}const Ye={BUTTON_SIZE:24,BUTTON_HOVER_PADDING:4,BORDER_RADIUS:4,TEXT_SPACING:16,EDGE_MARGIN:10,FRAME_TIME_MS:16.67,ICON:{PLAY:{LEFT:6,TOP:4,RIGHT:18,MIDDLE:12,BOTTOM:20},PAUSE:{RECT1_X:6,RECT2_X:14,TOP:4,WIDTH:4,HEIGHT:16},FRAME_STEP:{TRIANGLE1:{BACK:{LEFT:11,RIGHT:3,MIDDLE:12},FORWARD:{LEFT:4,RIGHT:12,MIDDLE:12}},TRIANGLE2:{BACK:{LEFT:20,RIGHT:12,MIDDLE:12},FORWARD:{LEFT:13,RIGHT:21,MIDDLE:12}},TOP:4,BOTTOM:20}},CUT_BUTTON:{WIDTH:60,HEIGHT:24,FONT_SIZE:12},TIME_DISPLAY:{FONT_SIZE:14,FONT_FAMILY:"monospace"},HOVER_ANIMATION_ALPHA:1,ACTIVE_ANIMATION_ALPHA:.3,DIVIDER_ALPHA:.5};class Wn{static createIcon(e,t,r){const i=r?r/Ye.BUTTON_SIZE:1;switch(e){case"play":return this.createPlayIcon(t,i);case"pause":return this.createPauseIcon(t,i);case"frame-back":return this.createFrameBackIcon(t,i);case"frame-forward":return this.createFrameForwardIcon(t,i);default:throw new Error(`Unknown icon type: ${e}`)}}static createPlayIcon(e,t=1){const r=new U.Graphics,{PLAY:i}=Ye.ICON;return r.fill({color:e.timeline.toolbar.icon}),r.moveTo(i.LEFT*t,i.TOP*t),r.lineTo(i.RIGHT*t,i.MIDDLE*t),r.lineTo(i.LEFT*t,i.BOTTOM*t),r.closePath(),r.fill(),r}static createPauseIcon(e,t=1){const r=new U.Graphics,{PAUSE:i}=Ye.ICON;return r.fill({color:e.timeline.toolbar.icon}),r.rect(i.RECT1_X*t,i.TOP*t,i.WIDTH*t,i.HEIGHT*t),r.rect(i.RECT2_X*t,i.TOP*t,i.WIDTH*t,i.HEIGHT*t),r.fill(),r}static createFrameBackIcon(e,t=1){const r=new U.Graphics,{FRAME_STEP:i}=Ye.ICON;return r.fill({color:e.timeline.toolbar.icon}),r.moveTo(i.TRIANGLE1.BACK.LEFT*t,i.TOP*t),r.lineTo(i.TRIANGLE1.BACK.RIGHT*t,i.TRIANGLE1.BACK.MIDDLE*t),r.lineTo(i.TRIANGLE1.BACK.LEFT*t,i.BOTTOM*t),r.closePath(),r.moveTo(i.TRIANGLE2.BACK.LEFT*t,i.TOP*t),r.lineTo(i.TRIANGLE2.BACK.RIGHT*t,i.TRIANGLE2.BACK.MIDDLE*t),r.lineTo(i.TRIANGLE2.BACK.LEFT*t,i.BOTTOM*t),r.closePath(),r.fill(),r}static createFrameForwardIcon(e,t=1){const r=new U.Graphics,{FRAME_STEP:i}=Ye.ICON;return r.fill({color:e.timeline.toolbar.icon}),r.moveTo(i.TRIANGLE1.FORWARD.LEFT*t,i.TOP*t),r.lineTo(i.TRIANGLE1.FORWARD.RIGHT*t,i.TRIANGLE1.FORWARD.MIDDLE*t),r.lineTo(i.TRIANGLE1.FORWARD.LEFT*t,i.BOTTOM*t),r.closePath(),r.moveTo(i.TRIANGLE2.FORWARD.LEFT*t,i.TOP*t),r.lineTo(i.TRIANGLE2.FORWARD.RIGHT*t,i.TRIANGLE2.FORWARD.MIDDLE*t),r.lineTo(i.TRIANGLE2.FORWARD.LEFT*t,i.BOTTOM*t),r.closePath(),r.fill(),r}static updateIconColor(e,t){const r=e.getBounds();e.clear(),e.position.set(r.x,r.y)}}class ih extends U.Container{background;hoverBackground;icon;alternateIcon;state={isHovering:!1,isPressed:!1,isActive:!1};size;theme;onClick;constructor(e){super(),this.size=e.size||Ye.BUTTON_SIZE,this.theme=e.theme,this.onClick=e.onClick,this.eventMode="static",this.cursor="pointer",this.background=new U.Graphics,this.addChild(this.background),this.hoverBackground=new U.Graphics,this.addChild(this.hoverBackground);const r=this.size*.6,i=(this.size-r)/2;e.iconType&&(this.icon=Wn.createIcon(e.iconType,this.theme,r),this.icon.position.set(i,i),this.addChild(this.icon)),e.alternateIconType&&(this.alternateIcon=Wn.createIcon(e.alternateIconType,this.theme,r),this.alternateIcon.position.set(i,i),this.alternateIcon.visible=!1,this.addChild(this.alternateIcon)),this.setupEventListeners(),this.updateVisuals()}setupEventListeners(){this.on("pointerdown",this.handlePointerDown,this),this.on("pointerup",this.handlePointerUp,this),this.on("pointerupoutside",this.handlePointerUp,this),this.on("pointerover",this.handlePointerOver,this),this.on("pointerout",this.handlePointerOut,this)}handlePointerDown(){this.state.isPressed=!0,this.updateVisuals()}handlePointerUp(){this.state.isPressed&&this.onClick(),this.state.isPressed=!1,this.updateVisuals()}handlePointerOver(){this.state.isHovering=!0,this.updateVisuals()}handlePointerOut(){this.state.isHovering=!1,this.state.isPressed=!1,this.updateVisuals()}updateVisuals(){const e=Ye.BUTTON_HOVER_PADDING,t=this.size/2;this.background.clear(),this.background.circle(t,t,t),this.background.fill({color:this.theme.timeline.toolbar.surface,alpha:.8}),this.hoverBackground.clear(),this.hoverBackground.circle(t,t,t+e),this.state.isPressed?this.hoverBackground.fill({color:this.theme.timeline.toolbar.active,alpha:Ye.ACTIVE_ANIMATION_ALPHA}):this.state.isHovering?this.hoverBackground.fill({color:this.theme.timeline.toolbar.hover,alpha:Ye.HOVER_ANIMATION_ALPHA}):this.hoverBackground.fill({color:this.theme.timeline.toolbar.hover,alpha:0})}setActive(e){this.state.isActive=e,this.icon&&this.alternateIcon&&(this.icon.visible=!e,this.alternateIcon.visible=e)}updateTheme(e){this.theme=e;const r=this.size*.6,i=(this.size-r)/2;if(this.icon){const n=this.getIconType(this.icon);n&&(this.removeChild(this.icon),this.icon=Wn.createIcon(n,e,r),this.icon.position.set(i,i),this.addChild(this.icon))}if(this.alternateIcon){const n=this.getIconType(this.alternateIcon);n&&(this.removeChild(this.alternateIcon),this.alternateIcon=Wn.createIcon(n,e,r),this.alternateIcon.position.set(i,i),this.alternateIcon.visible=this.state.isActive,this.addChild(this.alternateIcon))}this.updateVisuals()}getIconType(e){return null}destroy(){this.removeAllListeners(),super.destroy()}}class ex extends U.Container{edit;theme;toolbarHeight;frameBackButton;playPauseButton;frameForwardButton;constructor(e,t,r){super(),this.edit=e,this.theme=t,this.toolbarHeight=r||36,this.createButtons(),this.subscribeToEditEvents(),this.updatePlayPauseState()}createButtons(){const e=this.calculateButtonSizes(),t=(e.playButton-e.regularButton)/2,r=(i,n,a,o)=>new ih({iconType:i,onClick:n,tooltip:a,theme:this.theme,size:o});this.frameBackButton=r("frame-back",()=>this.handleFrameBack(),"Previous frame",e.regularButton),this.frameBackButton.position.set(0,t),this.playPauseButton=new ih({iconType:"play",alternateIconType:"pause",onClick:()=>this.handlePlayPause(),tooltip:"Play/Pause",theme:this.theme,size:e.playButton}),this.playPauseButton.position.set(e.regularButton+e.spacing,0),this.frameForwardButton=r("frame-forward",()=>this.handleFrameForward(),"Next frame",e.regularButton),this.frameForwardButton.position.set(e.regularButton+e.spacing+e.playButton+e.spacing,t),this.addChild(this.frameBackButton,this.playPauseButton,this.frameForwardButton)}calculateButtonSizes(){const e=Math.round(this.toolbarHeight*.5);return{regularButton:e,playButton:Math.round(e*1.5),spacing:Math.round(this.toolbarHeight*.15)}}handleFrameBack(){this.edit.seek(this.edit.playbackTime-Ye.FRAME_TIME_MS)}handlePlayPause(){this.edit.isPlaying?this.edit.pause():this.edit.play()}handleFrameForward(){this.edit.seek(this.edit.playbackTime+Ye.FRAME_TIME_MS)}subscribeToEditEvents(){this.edit.events.on("playback:play",this.updatePlayPauseState),this.edit.events.on("playback:pause",this.updatePlayPauseState)}updatePlayPauseState=()=>{this.playPauseButton.setActive(this.edit.isPlaying)};update(){}resize(e){}updateTheme(e){this.theme=e,this.frameBackButton.updateTheme(e),this.playPauseButton.updateTheme(e),this.frameForwardButton.updateTheme(e)}destroy(){this.edit.events.off("playback:play",this.updatePlayPauseState),this.edit.events.off("playback:pause",this.updatePlayPauseState),this.frameBackButton.destroy(),this.playPauseButton.destroy(),this.frameForwardButton.destroy(),super.destroy()}getWidth(){const e=this.calculateButtonSizes();return e.regularButton*2+e.playButton+e.spacing*2}}class tx extends U.Container{edit;theme;timeText;formatOptions;constructor(e,t,r={}){super(),this.edit=e,this.theme=t,this.formatOptions={showMilliseconds:!1,showHours:!1,...r},this.createDisplay(),this.subscribeToEditEvents(),this.updateTimeDisplay()}createDisplay(){const e=new U.TextStyle({fontFamily:Ye.TIME_DISPLAY.FONT_FAMILY,fontSize:Ye.TIME_DISPLAY.FONT_SIZE,fill:this.theme.timeline.toolbar.text});this.timeText=new U.Text("0:00 / 0:00",e),this.timeText.anchor.set(0,.5),this.addChild(this.timeText)}subscribeToEditEvents(){this.edit.events.on("playback:time",this.updateTimeDisplay),this.edit.events.on("duration:changed",this.updateTimeDisplay)}updateTimeDisplay=()=>{const e=this.formatTime(this.edit.playbackTime/1e3),t=this.formatTime(this.edit.getTotalDuration()/1e3);this.timeText.text=`${e} / ${t}`};formatTime(e){const t=Math.floor(e/3600),r=Math.floor(e%3600/60),i=Math.floor(e%60),n=Math.floor(e%1*10);let a="";return this.formatOptions.showHours||t>0?a+=`${t}:${r.toString().padStart(2,"0")}`:a+=`${r}`,a+=`:${i.toString().padStart(2,"0")}`,this.formatOptions.showMilliseconds?a+=`.${n}`:a+=`.${n}`,a}update(){this.updateTimeDisplay()}resize(e){}updateTheme(e){this.theme=e,this.timeText.style.fill=e.timeline.toolbar.text}destroy(){this.edit.events.off("playback:time",this.updateTimeDisplay),this.edit.events.off("duration:changed",this.updateTimeDisplay),super.destroy()}getWidth(){return this.timeText.width}}class rx extends U.Container{edit;theme;cutButton;cutButtonBackground;cutButtonText;constructor(e,t){super(),this.edit=e,this.theme=t,this.createCutButton()}createCutButton(){this.cutButton=new U.Container,this.cutButton.eventMode="static",this.cutButton.cursor="pointer";const{WIDTH:e,HEIGHT:t,FONT_SIZE:r}=Ye.CUT_BUTTON;this.cutButtonBackground=new U.Graphics,this.cutButtonBackground.roundRect(0,0,e,t,Ye.BORDER_RADIUS),this.cutButtonBackground.fill({color:this.theme.timeline.toolbar.surface||4473924}),this.cutButtonBackground.stroke({color:this.theme.timeline.tracks.border||6710886,width:1}),this.cutButton.addChild(this.cutButtonBackground);const i=new U.TextStyle({fontFamily:"Arial",fontSize:r,fill:this.theme.timeline.toolbar.text||16777215});this.cutButtonText=new U.Text("SPLIT",i),this.cutButtonText.anchor.set(.5),this.cutButtonText.position.set(e/2,t/2),this.cutButton.addChild(this.cutButtonText),this.cutButton.on("click",this.handleCutClick,this),this.cutButton.on("pointerdown",this.handlePointerDown,this),this.cutButton.on("pointerover",this.handlePointerOver,this),this.cutButton.on("pointerout",this.handlePointerOut,this),this.addChild(this.cutButton)}handleCutClick=e=>{e.stopPropagation(),this.performCutClip()};handlePointerDown=e=>{e.stopPropagation(),this.updateButtonVisual(!0,!1)};handlePointerOver=()=>{this.updateButtonVisual(!1,!0)};handlePointerOut=()=>{this.updateButtonVisual(!1,!1)};updateButtonVisual(e,t){this.cutButtonBackground.clear(),this.cutButtonBackground.roundRect(0,0,Ye.CUT_BUTTON.WIDTH,Ye.CUT_BUTTON.HEIGHT,Ye.BORDER_RADIUS);let r=this.theme.timeline.toolbar.surface||4473924;const i=1;e?r=this.theme.timeline.toolbar.active||3355443:t&&(r=this.theme.timeline.toolbar.hover||5592405),this.cutButtonBackground.fill({color:r,alpha:i}),this.cutButtonBackground.stroke({color:this.theme.timeline.tracks.border||6710886,width:1})}performCutClip(){const e=this.edit.getSelectedClipInfo();if(!e)return;const{trackIndex:t,clipIndex:r}=e,i=this.edit.playbackTime/1e3;this.edit.splitClip(t,r,i)}update(){const e=this.edit.getSelectedClipInfo()!==null;this.cutButton.alpha=e?1:.5,this.cutButton.eventMode=e?"static":"none",this.cutButton.cursor=e?"pointer":"default"}resize(e){}updateTheme(e){this.theme=e,this.updateButtonVisual(!1,!1),this.cutButtonText.style.fill=e.timeline.toolbar.text||16777215}destroy(){this.cutButton.removeAllListeners(),super.destroy()}getWidth(){return Ye.CUT_BUTTON.WIDTH}}class ix{config;constructor(e,t){this.config={width:e,height:t,buttonSize:Math.round(t*.5),buttonSpacing:Math.round(t*.15),edgeMargin:Ye.EDGE_MARGIN}}getPlaybackControlsPosition(){const e=this.calculatePlaybackControlsWidth(),t=(this.config.width-e)/2,r=(this.config.height-this.getMaxButtonHeight())/2;return{x:t,y:r}}getMaxButtonHeight(){const e=this.config.buttonSize;return Math.round(e*1.5)}getTimeDisplayPosition(e){const r=(this.config.width-e)/2+e+Ye.TEXT_SPACING,i=this.config.height/2;return{x:r,y:i}}getEditControlsPosition(){const e=this.config.width-Ye.CUT_BUTTON.WIDTH-this.config.edgeMargin,t=(this.config.height-Ye.CUT_BUTTON.HEIGHT)/2;return{x:e,y:t}}calculatePlaybackControlsWidth(){const e=this.config.buttonSize,t=Math.round(e*1.5);return e*2+t+this.config.buttonSpacing*2}updateWidth(e){this.config.width=e}getConfig(){return{...this.config}}}class sx extends U.Container{constructor(e,t,r,i){super(),this.edit=e,this.theme=t,this.layout=r,this.toolbarWidth=i,this.toolbarHeight=r.toolbarHeight,this.position.set(0,r.toolbarY),this.toolbarLayout=new ix(i,this.toolbarHeight),this.createBackground(),this.createComponents(),this.positionComponents(),this.subscribeToEditEvents()}background;playbackControls;timeDisplay;editControls;toolbarLayout;toolbarWidth;toolbarHeight;get width(){return this.toolbarWidth}get height(){return this.toolbarHeight}createBackground(){this.background=new U.Graphics,this.drawBackground(),this.addChild(this.background)}drawBackground(){this.background.clear(),this.background.rect(0,0,this.toolbarWidth,this.toolbarHeight),this.background.fill({color:this.theme.timeline.toolbar.background}),this.background.setStrokeStyle({width:1,color:this.theme.timeline.toolbar.divider,alpha:Ye.DIVIDER_ALPHA}),this.background.moveTo(0,this.toolbarHeight-.5),this.background.lineTo(this.toolbarWidth,this.toolbarHeight-.5),this.background.stroke()}createComponents(){this.playbackControls=new ex(this.edit,this.theme,this.toolbarHeight),this.addChild(this.playbackControls),this.timeDisplay=new tx(this.edit,this.theme),this.addChild(this.timeDisplay),this.editControls=new rx(this.edit,this.theme),this.addChild(this.editControls)}positionComponents(){const e=this.toolbarLayout.getPlaybackControlsPosition();this.playbackControls.position.set(e.x,e.y);const t=this.toolbarLayout.getTimeDisplayPosition(this.playbackControls.getWidth());this.timeDisplay.position.set(t.x,t.y);const r=this.toolbarLayout.getEditControlsPosition();this.editControls.position.set(r.x,r.y)}subscribeToEditEvents(){this.edit.events.on("clip:selected",this.updateEditControls),this.edit.events.on("selection:cleared",this.updateEditControls)}updateEditControls=()=>{this.editControls.update()};resize(e){this.toolbarWidth=e,this.toolbarLayout.updateWidth(e),this.drawBackground(),this.positionComponents(),this.playbackControls.resize(e),this.timeDisplay.resize(e),this.editControls.resize(e)}updateTheme(e){this.theme=e,this.drawBackground(),this.playbackControls.updateTheme(e),this.timeDisplay.updateTheme(e),this.editControls.updateTheme(e)}updateTimeDisplay=()=>{this.timeDisplay.update()};destroy(){this.edit.events.off("clip:selected",this.updateEditControls),this.edit.events.off("selection:cleared",this.updateEditControls),this.playbackControls.destroy(),this.timeDisplay.destroy(),this.editControls.destroy(),super.destroy()}}class nx{constructor(e,t,r,i,n,a){this.edit=e,this.layout=t,this.renderer=r,this.viewportManager=i,this.eventHandler=n,this.getTimelineContext=a}toolbar;ruler;playhead;scroll;async setupTimelineFeatures(e,t,r,i,n){this.toolbar=new sx(this.edit,e,this.layout,r),this.renderer.getStage().addChild(this.toolbar);const a={pixelsPerSecond:t,timelineDuration:n,rulerHeight:this.layout.rulerHeight,theme:e};this.ruler=new th(a),await this.ruler.load(),this.ruler.getContainer().y=this.layout.rulerY,this.viewportManager.getRulerViewport().addChild(this.ruler.getContainer()),this.ruler.events.on("ruler:seeked",this.eventHandler.handleSeek.bind(this.eventHandler));const o={pixelsPerSecond:t,timelineHeight:i,theme:e};this.playhead=new rh(o),await this.playhead.load(),this.playhead.getContainer().y=this.layout.rulerY,this.viewportManager.getPlayheadContainer().addChild(this.playhead.getContainer()),this.playhead.events.on("playhead:seeked",this.eventHandler.handleSeek.bind(this.eventHandler));const c={timeline:this.getTimelineContext()};this.scroll=new Q2(c),await this.scroll.initialize(),this.viewportManager.updateViewportTransform()}recreateTimelineFeatures(e,t,r,i){if(this.ruler){this.ruler.dispose();const{rulerHeight:n}=this.layout,a={pixelsPerSecond:t,timelineDuration:i,rulerHeight:n,theme:e};this.ruler=new th(a),this.ruler.load(),this.ruler.getContainer().y=this.layout.rulerY,this.viewportManager.getRulerViewport().addChild(this.ruler.getContainer()),this.ruler.events.on("ruler:seeked",this.eventHandler.handleSeek.bind(this.eventHandler))}if(this.playhead){this.playhead.dispose();const n={pixelsPerSecond:t,timelineHeight:r,theme:e};this.playhead=new rh(n),this.playhead.load(),this.playhead.getContainer().y=this.layout.rulerY,this.viewportManager.getPlayheadContainer().addChild(this.playhead.getContainer()),this.playhead.events.on("playhead:seeked",this.eventHandler.handleSeek.bind(this.eventHandler))}}updateRuler(e,t){this.ruler.updateRuler(e,t)}updatePlayhead(e,t){this.playhead&&this.playhead.updatePlayhead(e,t)}getFeatures(){return{toolbar:this.toolbar,ruler:this.ruler,playhead:this.playhead,scroll:this.scroll}}getToolbar(){return this.toolbar}getPlayhead(){return this.playhead}dispose(){this.toolbar&&this.toolbar.destroy(),this.ruler&&this.ruler.dispose(),this.playhead&&this.playhead.dispose(),this.scroll&&this.scroll.dispose()}}class br{constructor(e,t){this.options=e,this.theme=t,this.config=this.calculateLayout()}static TOOLBAR_HEIGHT_RATIO=Nt.TOOLBAR_HEIGHT_RATIO;static RULER_HEIGHT_RATIO=Nt.RULER_HEIGHT_RATIO;static TOOLBAR_HEIGHT_DEFAULT=Nt.TOOLBAR_HEIGHT_DEFAULT;static RULER_HEIGHT_DEFAULT=Nt.RULER_HEIGHT_DEFAULT;static TRACK_HEIGHT_DEFAULT=Nt.TRACK_HEIGHT_DEFAULT;static CLIP_PADDING=Nt.CLIP_PADDING;static BORDER_WIDTH=Nt.BORDER_WIDTH;static CORNER_RADIUS=Nt.CORNER_RADIUS;static LABEL_PADDING=Nt.LABEL_PADDING;static TRACK_PADDING=Nt.TRACK_PADDING;config;calculateLayout(){const e=this.options.height;let t=this.theme?.timeline.toolbar.height||Math.round(e*br.TOOLBAR_HEIGHT_RATIO),r=this.theme?.timeline.ruler.height||Math.round(e*br.RULER_HEIGHT_RATIO);t=Math.max(t,br.TOOLBAR_HEIGHT_DEFAULT),r=Math.max(r,br.RULER_HEIGHT_DEFAULT);const{trackHeight:i}=this.options;return{toolbarHeight:t,rulerHeight:r,trackHeight:i,toolbarY:0,rulerY:t,tracksY:t+r,gridY:t+r,playheadY:t,viewportY:t+r}}get toolbarHeight(){return this.config.toolbarHeight}get toolbarY(){return this.config.toolbarY}get rulerHeight(){return this.config.rulerHeight}get trackHeight(){return this.config.trackHeight}get rulerY(){return this.config.rulerY}get tracksY(){return this.config.tracksY}get gridY(){return this.config.gridY}get playheadY(){return this.config.playheadY}get viewportY(){return this.config.viewportY}positionTrack(e){return e*this.trackHeight}positionClip(e){return e*this.options.pixelsPerSecond}calculateClipWidth(e){return Math.max(Nt.MIN_CLIP_WIDTH,e*this.options.pixelsPerSecond)}calculateDropPosition(e,t){const r=t-this.tracksY,i=Math.floor(r/this.trackHeight),n=Math.max(0,e/this.options.pixelsPerSecond);return{track:Math.max(0,i),time:n,x:e,y:r}}getTrackAtY(e){const t=e-this.tracksY;return Math.floor(t/this.trackHeight)}getTimeAtX(e){return e/this.options.pixelsPerSecond}getXAtTime(e){return e*this.options.pixelsPerSecond}getYAtTrack(e){return this.tracksY+e*this.trackHeight}getGridHeight(){return this.options.height-this.toolbarHeight-this.rulerHeight}getRulerWidth(){return this.options.width}getGridWidth(){return this.options.width}calculateViewportPosition(e,t){return{x:-e,y:this.viewportY-t}}updateOptions(e,t){this.options=e,this.theme=t,this.config=this.calculateLayout()}isPointInToolbar(e,t){return t>=this.toolbarY&&t<=this.toolbarY+this.toolbarHeight}isPointInRuler(e,t){return t>=this.rulerY&&t<=this.rulerY+this.rulerHeight}isPointInTracks(e,t){return t>=this.tracksY&&t<=this.options.height}getVisibleTrackRange(e,t){const r=e,i=Math.floor(r/this.trackHeight),n=Math.ceil((r+t)/this.trackHeight);return{start:Math.max(0,i),end:Math.max(0,n)}}}class ur{constructor(e,t,r,i){this.layout=r,this.onResize=i,this.width=e.width,this.height=e.height,this.pixelsPerSecond=50;const n=t.timeline.tracks.height||br.TRACK_HEIGHT_DEFAULT;this.trackHeight=Math.max(40,n),this.backgroundColor=t.timeline.background,this.antialias=!0,this.resolution=window.devicePixelRatio||1}pixelsPerSecond;trackHeight;backgroundColor;antialias;resolution;width;height;static MIN_PIXELS_PER_SECOND=10;static MAX_PIXELS_PER_SECOND=500;static ZOOM_FACTOR=1.1;getOptions(){return{width:this.width,height:this.height,pixelsPerSecond:this.pixelsPerSecond,trackHeight:this.trackHeight,backgroundColor:this.backgroundColor,antialias:this.antialias,resolution:this.resolution}}setOptions(e){e.width!==void 0&&(this.width=e.width,this.onResize&&this.onResize(this.width)),e.height!==void 0&&(this.height=e.height),e.pixelsPerSecond!==void 0&&(this.pixelsPerSecond=e.pixelsPerSecond),e.trackHeight!==void 0&&(this.trackHeight=e.trackHeight),e.backgroundColor!==void 0&&(this.backgroundColor=e.backgroundColor),e.antialias!==void 0&&(this.antialias=e.antialias),e.resolution!==void 0&&(this.resolution=e.resolution),this.layout.updateOptions(this.getOptions())}updateFromTheme(e){this.backgroundColor=e.timeline.background;const t=e.timeline.tracks.height||br.TRACK_HEIGHT_DEFAULT;this.trackHeight=Math.max(40,t),this.layout.updateOptions(this.getOptions(),e)}getWidth(){return this.width}getHeight(){return this.height}getPixelsPerSecond(){return this.pixelsPerSecond}getTrackHeight(){return this.trackHeight}getBackgroundColor(){return this.backgroundColor}getAntialias(){return this.antialias}getResolution(){return this.resolution}zoomIn(){const e=Math.min(this.pixelsPerSecond*ur.ZOOM_FACTOR,ur.MAX_PIXELS_PER_SECOND);this.setPixelsPerSecond(e)}zoomOut(){const e=Math.max(this.pixelsPerSecond/ur.ZOOM_FACTOR,ur.MIN_PIXELS_PER_SECOND);this.setPixelsPerSecond(e)}setPixelsPerSecond(e){this.pixelsPerSecond=Math.max(ur.MIN_PIXELS_PER_SECOND,Math.min(ur.MAX_PIXELS_PER_SECOND,e)),this.layout.updateOptions(this.getOptions())}canZoomIn(){return this.pixelsPerSecond<ur.MAX_PIXELS_PER_SECOND}canZoomOut(){return this.pixelsPerSecond>ur.MIN_PIXELS_PER_SECOND}}class No extends xr{constructor(e,t,r){super(),this.edit=e,this.theme=Q0.resolveTheme(r),this.layout=new br({width:t.width,height:t.height,pixelsPerSecond:50,trackHeight:Math.max(40,this.theme.timeline.tracks.height||br.TRACK_HEIGHT_DEFAULT),backgroundColor:this.theme.timeline.background,antialias:!0,resolution:window.devicePixelRatio||1},this.theme),this.optionsManager=new ur(t,this.theme,this.layout,i=>this.featureManager?.getToolbar()?.resize(i)),this.initializeManagers(),this.setupInteraction()}currentEditType=null;layout;theme;lastPlaybackTime=0;static TIMELINE_BUFFER_MULTIPLIER=1.5;interaction;dragPreviewManager;viewportManager;visualTrackManager;eventHandler;renderer;featureManager;optionsManager;initializeManagers(){const e=this.optionsManager.getOptions();this.renderer=new J2({width:e.width||800,height:e.height||600,backgroundColor:e.backgroundColor||0,antialias:e.antialias??!0,resolution:e.resolution||window.devicePixelRatio||1},(t,r)=>this.update(t,r)),this.eventHandler=new Y2(this.edit,{onEditChange:this.handleEditChange.bind(this),onSeek:t=>this.edit.seek(t),onClipSelected:(t,r)=>this.visualTrackManager.updateVisualSelection(t,r),onSelectionCleared:()=>this.visualTrackManager.clearVisualSelection(),onDragStarted:(t,r)=>{const i=this.getClipData(t,r);i&&this.dragPreviewManager.showDragPreview(t,r,i)},onDragEnded:()=>this.dragPreviewManager.hideDragPreview()}),this.eventHandler.setupEventListeners()}async load(){await this.renderer.initializePixiApp(),await this.renderer.setupRenderLayers(),await this.setupViewport(),await this.setupTimelineFeatures(),this.interaction.activate();try{const e=this.edit.getEdit();e&&(this.currentEditType=e,await this.rebuildFromEdit(e))}catch{}this.renderer.startAnimationLoop()}async setupViewport(){this.viewportManager=new W2(this.layout,this.renderer.getTrackLayer(),this.renderer.getOverlayLayer(),this.getContainer(),()=>this.renderer.render()),await this.viewportManager.setupViewport(),this.visualTrackManager=new K2(this.getContainer(),this.layout,this.theme,()=>this.optionsManager.getPixelsPerSecond(),()=>this.getExtendedTimelineWidth()),this.dragPreviewManager=new j2(this.getContainer(),this.layout,()=>this.optionsManager.getPixelsPerSecond(),()=>this.optionsManager.getTrackHeight(),()=>this.visualTrackManager.getVisualTracks()),this.featureManager=new nx(this.edit,this.layout,this.renderer,this.viewportManager,this.eventHandler,()=>this)}async setupTimelineFeatures(){const e=this.getExtendedTimelineDuration();await this.featureManager.setupTimelineFeatures(this.theme,this.optionsManager.getPixelsPerSecond(),this.optionsManager.getWidth(),this.optionsManager.getHeight(),e)}recreateTimelineFeatures(){const e=this.getExtendedTimelineDuration();this.featureManager.recreateTimelineFeatures(this.theme,this.optionsManager.getPixelsPerSecond(),this.optionsManager.getHeight(),e)}setScroll(e,t){this.viewportManager.setScroll(e,t)}setZoom(e){this.viewportManager.setZoom(e)}getViewport(){return this.viewportManager.getViewport()}getPixiApp(){return this.renderer.getApp()}getTrackLayer(){return this.renderer.getTrackLayer()}getOverlayLayer(){return this.renderer.getOverlayLayer()}getClipData(e,t){return this.currentEditType?.timeline?.tracks&&this.currentEditType.timeline.tracks[e]?.clips?.[t]||null}getLayout(){return this.layout}getVisualTracks(){return this.visualTrackManager.getVisualTracks()}getEdit(){return this.edit}getExtendedTimelineWidth(){const e=this.getExtendedTimelineDuration()*this.optionsManager.getPixelsPerSecond(),t=this.optionsManager.getWidth();return Math.max(e,t)}hideDragGhost(){this.dragPreviewManager.hideDragGhost()}showDragGhost(e,t,r){this.dragPreviewManager.showDragGhost(e,t,r)}setPlayheadTime(e){this.featureManager.getPlayhead().setTime(e)}getPlayheadTime(){return this.featureManager.getPlayhead().getTime()}getActualEditDuration(){return this.edit.totalDuration/1e3||60}setupInteraction(){this.interaction=new V2(this)}async handleEditChange(e){this.dragPreviewManager.hideDragPreview();const t=e||this.edit.getEdit();t&&(this.currentEditType=t,this.updateRulerDuration(),this.clearAllVisualState(),await this.rebuildFromEdit(t))}getExtendedTimelineDuration(){const e=this.edit.totalDuration/1e3||60;return Math.max(60,e*No.TIMELINE_BUFFER_MULTIPLIER)}updateRulerDuration(){const e=this.getExtendedTimelineDuration(),t=this.getExtendedTimelineWidth();this.featureManager.updateRuler(this.optionsManager.getPixelsPerSecond(),e),this.visualTrackManager.updateTrackWidths(t)}clearAllVisualState(){this.dragPreviewManager.hideDragPreview(),this.visualTrackManager.clearAllVisualState()}async rebuildFromEdit(e){await this.visualTrackManager.rebuildFromEdit(e,this.optionsManager.getPixelsPerSecond()),this.renderer.render()}findClipAtPosition(e,t){return this.currentEditType?this.visualTrackManager.findClipAtPosition(e,t):null}setTheme(e){this.theme=Q0.resolveTheme(e),this.optionsManager.updateFromTheme(this.theme),this.featureManager.getToolbar()&&this.featureManager.getToolbar().updateTheme(this.theme),this.recreateTimelineFeatures(),this.currentEditType&&(this.clearAllVisualState(),this.rebuildFromEdit(this.currentEditType)),this.renderer.updateBackgroundColor(this.optionsManager.getBackgroundColor()),this.renderer.render()}getTheme(){return this.theme}getCurrentEditType(){return this.currentEditType}getOptions(){return this.optionsManager.getOptions()}setOptions(e){this.optionsManager.setOptions(e)}update(e,t){(this.edit.isPlaying||this.lastPlaybackTime!==this.edit.playbackTime)&&(this.featureManager.getPlayhead().setTime(this.edit.playbackTime/1e3),this.lastPlaybackTime=this.edit.playbackTime,this.featureManager.getToolbar()&&this.featureManager.getToolbar().updateTimeDisplay())}draw(){this.renderer.draw()}getTimeDisplay(){return this.featureManager.getToolbar()}updateTime(e,t){this.setPlayheadTime(e),t&&this.edit.seek(e*1e3)}get timeRange(){return{startTime:0,endTime:this.getExtendedTimelineDuration()}}get viewportHeight(){return this.optionsManager.getHeight()}get zoomLevelIndex(){const e=this.viewportManager.getViewport();return Math.round(Math.log2(e.zoom)+5)}zoomIn(){this.optionsManager.zoomIn(),this.onZoomChanged()}zoomOut(){this.optionsManager.zoomOut(),this.onZoomChanged()}onZoomChanged(){const e=this.optionsManager.getPixelsPerSecond();this.visualTrackManager.updatePixelsPerSecond(e);const t=this.getExtendedTimelineWidth();this.visualTrackManager.updateTrackWidths(t),this.featureManager.updateRuler(e,this.getExtendedTimelineDuration()),this.featureManager.updatePlayhead(e,this.optionsManager.getHeight()),this.renderer.render()}dispose(){this.dragPreviewManager.dispose(),this.visualTrackManager.dispose(),this.eventHandler.dispose(),this.featureManager.dispose(),this.interaction&&this.interaction.dispose(),this.renderer.dispose()}}var ax=gl({"node_modules/harfbuzzjs/hb.js"(s,e){var t=(()=>{var r=typeof document<"u"?document.currentScript?.src:void 0;return async function(i={}){var n,a=i,o=typeof window=="object",c=typeof WorkerGlobalScope<"u",u=typeof process=="object"&&process.versions?.node&&process.type!="renderer",h=(P,ne)=>{throw ne};typeof __filename<"u"?r=__filename:c&&(r=self.location.href);var l="";function d(P){return a.locateFile?a.locateFile(P,l):l+P}var f,p;if(u){var m=ud("fs");l=__dirname+"/",p=P=>{P=k(P)?new URL(P):P;var ne=m.readFileSync(P);return ne},f=async(P,ne=!0)=>{P=k(P)?new URL(P):P;var Le=m.readFileSync(P,ne?void 0:"utf8");return Le},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),h=(P,ne)=>{throw process.exitCode=P,ne}}else if(o||c){try{l=new URL(".",r).href}catch{}c&&(p=P=>{var ne=new XMLHttpRequest;return ne.open("GET",P,!1),ne.responseType="arraybuffer",ne.send(null),new Uint8Array(ne.response)}),f=async P=>{if(k(P))return new Promise((Le,je)=>{var Ge=new XMLHttpRequest;Ge.open("GET",P,!0),Ge.responseType="arraybuffer",Ge.onload=()=>{if(Ge.status==200||Ge.status==0&&Ge.response){Le(Ge.response);return}je(Ge.status)},Ge.onerror=je,Ge.send(null)});var ne=await fetch(P,{credentials:"same-origin"});if(ne.ok)return ne.arrayBuffer();throw new Error(ne.status+" : "+ne.url)}}console.log.bind(console);var v=console.error.bind(console),g,y=!1,b,k=P=>P.startsWith("file://"),x,E,T,w,S=!1;function _(){var P=T.buffer;a.HEAP8=new Int8Array(P),a.HEAPU8=w=new Uint8Array(P),a.HEAP32=new Int32Array(P),a.HEAPU32=new Uint32Array(P),a.HEAPF32=new Float32Array(P),new BigInt64Array(P),new BigUint64Array(P)}function A(){if(a.preRun)for(typeof a.preRun=="function"&&(a.preRun=[a.preRun]);a.preRun.length;)ie(a.preRun.shift());j(B)}function M(){S=!0,Ht.__wasm_call_ctors()}function D(){if(a.postRun)for(typeof a.postRun=="function"&&(a.postRun=[a.postRun]);a.postRun.length;)L(a.postRun.shift());j(N)}var W=0,G=null;function ue(P){W++,a.monitorRunDependencies?.(W)}function re(P){if(W--,a.monitorRunDependencies?.(W),W==0&&G){var ne=G;G=null,ne()}}function $(P){a.onAbort?.(P),P="Aborted("+P+")",v(P),y=!0,P+=". Build with -sASSERTIONS for more info.";var ne=new WebAssembly.RuntimeError(P);throw E?.(ne),ne}var H;function z(){return d("hb.wasm")}function te(P){if(P==H&&g)return new Uint8Array(g);if(p)return p(P);throw"both async and sync fetching of the wasm failed"}async function he(P){if(!g)try{var ne=await f(P);return new Uint8Array(ne)}catch{}return te(P)}async function Se(P,ne){try{var Le=await he(P),je=await WebAssembly.instantiate(Le,ne);return je}catch(Ge){v(`failed to asynchronously prepare wasm: ${Ge}`),$(Ge)}}async function Fe(P,ne,Le){if(!P&&!k(ne)&&!u)try{var je=fetch(ne,{credentials:"same-origin"}),Ge=await WebAssembly.instantiateStreaming(je,Le);return Ge}catch(ct){v(`wasm streaming compile failed: ${ct}`),v("falling back to ArrayBuffer instantiation")}return Se(ne,Le)}function Re(){return{env:Ui,wasi_snapshot_preview1:Ui}}async function Me(){function P(ct,Vi){return Ht=ct.exports,a.wasmExports=Ht,T=Ht.memory,a.wasmMemory=T,_(),vr=Ht.__indirect_function_table,Kn(Ht),re(),Ht}ue();function ne(ct){return P(ct.instance)}var Le=Re();if(a.instantiateWasm)return new Promise((ct,Vi)=>{a.instantiateWasm(Le,(Yn,Ho)=>{ct(P(Yn))})});H??(H=z());var je=await Fe(g,H,Le),Ge=ne(je);return Ge}class Ke{constructor(ne){Wt(this,"name","ExitStatus"),this.message=`Program terminated with exit(${ne})`,this.status=ne}}var j=P=>{for(;P.length>0;)P.shift()(a)},N=[],L=P=>N.push(P),B=[],ie=P=>B.push(P),fe=!0,ae=()=>$(""),de=0,ke=()=>{fe=!1,de=0},le={},J=P=>{if(P instanceof Ke||P=="unwind")return b;h(1,P)},Te=()=>fe||de>0,Je=P=>{b=P,Te()||(a.onExit?.(P),y=!0),h(P,new Ke(P))},dt=(P,ne)=>{b=P,Je(P)},Xe=dt,it=()=>{if(!Te())try{Xe(b)}catch(P){J(P)}},st=P=>{if(!y)try{P(),it()}catch(ne){J(ne)}},wt=()=>performance.now(),_t=(P,ne)=>{if(le[P]&&(clearTimeout(le[P].id),delete le[P]),!ne)return 0;var Le=setTimeout(()=>{delete le[P],st(()=>Os(P,wt()))},ne);return le[P]={id:Le,timeout_ms:ne},0},Ie=()=>2147483648,Uo=(P,ne)=>Math.ceil(P/ne)*ne,$i=P=>{var ne=T.buffer.byteLength,Le=(P-ne+65535)/65536|0;try{return T.grow(Le),_(),1}catch{}},lt=P=>{var ne=w.length;P>>>=0;var Le=Ie();if(P>Le)return!1;for(var je=1;je<=4;je*=2){var Ge=ne*(1+.2/je);Ge=Math.min(Ge,P+100663296);var ct=Math.min(Le,Uo(Math.max(P,Ge),65536)),Vi=$i(ct);if(Vi)return!0}return!1},Ps=P=>{const ne=P.length;return[ne%128|128,ne>>7,...P]},Mt={i:127,p:127,j:126,f:125,d:124,e:111},Ut=P=>Ps(Array.from(P,ne=>{var Le=Mt[ne];return Le})),It=(P,ne)=>{var Le=Uint8Array.of(0,97,115,109,1,0,0,0,1,...Ps([1,96,...Ut(ne.slice(1)),...Ut(ne[0]==="v"?"":ne[0])]),2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0),je=new WebAssembly.Module(Le),Ge=new WebAssembly.Instance(je,{e:{f:P}}),ct=Ge.exports.f;return ct},vr,di=P=>vr.get(P),Wr=(P,ne)=>{if(Pt)for(var Le=P;Le<P+ne;Le++){var je=di(Le);je&&Pt.set(je,Le)}},Pt,Gn=P=>(Pt||(Pt=new WeakMap,Wr(0,vr.length)),Pt.get(P)||0),Ni=[],qn=()=>Ni.length?Ni.pop():vr.grow(1),Gr=(P,ne)=>vr.set(P,ne),Xn=(P,ne)=>{var Le=Gn(P);if(Le)return Le;var je=qn();try{Gr(je,P)}catch(ct){if(!(ct instanceof TypeError))throw ct;var Ge=It(P,ne);Gr(je,Ge)}return Pt.set(P,je),je},Zn=P=>{Pt.delete(di(P)),Gr(P,null),Ni.push(P)};a.noExitRuntime&&(fe=a.noExitRuntime),a.print&&a.print,a.printErr&&(v=a.printErr),a.wasmBinary&&(g=a.wasmBinary),a.arguments&&a.arguments,a.thisProgram&&a.thisProgram,a.wasmMemory=T,a.wasmExports=Ht,a.addFunction=Xn,a.removeFunction=Zn;var Os;function Kn(P){a._hb_blob_create=P.hb_blob_create,a._hb_blob_destroy=P.hb_blob_destroy,a._hb_blob_get_length=P.hb_blob_get_length,a._hb_blob_get_data=P.hb_blob_get_data,a._hb_buffer_serialize_glyphs=P.hb_buffer_serialize_glyphs,a._hb_buffer_create=P.hb_buffer_create,a._hb_buffer_destroy=P.hb_buffer_destroy,a._hb_buffer_get_content_type=P.hb_buffer_get_content_type,a._hb_buffer_set_direction=P.hb_buffer_set_direction,a._hb_buffer_set_script=P.hb_buffer_set_script,a._hb_buffer_set_language=P.hb_buffer_set_language,a._hb_buffer_set_flags=P.hb_buffer_set_flags,a._hb_buffer_set_cluster_level=P.hb_buffer_set_cluster_level,a._hb_buffer_get_length=P.hb_buffer_get_length,a._hb_buffer_get_glyph_infos=P.hb_buffer_get_glyph_infos,a._hb_buffer_get_glyph_positions=P.hb_buffer_get_glyph_positions,a._hb_glyph_info_get_glyph_flags=P.hb_glyph_info_get_glyph_flags,a._hb_buffer_guess_segment_properties=P.hb_buffer_guess_segment_properties,a._hb_buffer_add_utf8=P.hb_buffer_add_utf8,a._hb_buffer_add_utf16=P.hb_buffer_add_utf16,a._hb_buffer_set_message_func=P.hb_buffer_set_message_func,a._hb_language_from_string=P.hb_language_from_string,a._hb_script_from_string=P.hb_script_from_string,a._hb_version=P.hb_version,a._hb_version_string=P.hb_version_string,a._hb_feature_from_string=P.hb_feature_from_string,a._malloc=P.malloc,a._free=P.free,a._hb_draw_funcs_set_move_to_func=P.hb_draw_funcs_set_move_to_func,a._hb_draw_funcs_set_line_to_func=P.hb_draw_funcs_set_line_to_func,a._hb_draw_funcs_set_quadratic_to_func=P.hb_draw_funcs_set_quadratic_to_func,a._hb_draw_funcs_set_cubic_to_func=P.hb_draw_funcs_set_cubic_to_func,a._hb_draw_funcs_set_close_path_func=P.hb_draw_funcs_set_close_path_func,a._hb_draw_funcs_create=P.hb_draw_funcs_create,a._hb_draw_funcs_destroy=P.hb_draw_funcs_destroy,a._hb_face_create=P.hb_face_create,a._hb_face_destroy=P.hb_face_destroy,a._hb_face_reference_table=P.hb_face_reference_table,a._hb_face_get_upem=P.hb_face_get_upem,a._hb_face_collect_unicodes=P.hb_face_collect_unicodes,a._hb_font_draw_glyph=P.hb_font_draw_glyph,a._hb_font_glyph_to_string=P.hb_font_glyph_to_string,a._hb_font_create=P.hb_font_create,a._hb_font_set_variations=P.hb_font_set_variations,a._hb_font_destroy=P.hb_font_destroy,a._hb_font_set_scale=P.hb_font_set_scale,a._hb_set_create=P.hb_set_create,a._hb_set_destroy=P.hb_set_destroy,a._hb_ot_var_get_axis_infos=P.hb_ot_var_get_axis_infos,a._hb_set_get_population=P.hb_set_get_population,a._hb_set_next_many=P.hb_set_next_many,a._hb_shape=P.hb_shape,Os=P._emscripten_timeout}var Ui={_abort_js:ae,_emscripten_runtime_keepalive_clear:ke,_setitimer_js:_t,emscripten_resize_heap:lt,proc_exit:Je},Ht=await Me();function Hi(){if(W>0){G=Hi;return}if(A(),W>0){G=Hi;return}function P(){a.calledRun=!0,!y&&(M(),x?.(a),a.onRuntimeInitialized?.(),D())}a.setStatus?(a.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>a.setStatus(""),1),P()},1)):P()}function Fs(){if(a.preInit)for(typeof a.preInit=="function"&&(a.preInit=[a.preInit]);a.preInit.length>0;)a.preInit.shift()()}return Fs(),Hi(),S?n=a:n=new Promise((P,ne)=>{x=P,E=ne}),n}})();typeof s=="object"&&typeof e=="object"?(e.exports=t,e.exports.default=t):typeof define=="function"&&define.amd&&define([],()=>t)}});const ox=ax(),lx=Object.freeze(Object.defineProperty({__proto__:null,default:ox},Symbol.toStringTag,{value:"Module"}));var cx=gl({"node_modules/harfbuzzjs/hbjs.js"(s,e){function t(r){var i=r.wasmExports,n=new TextDecoder("utf8");let a=r.addFunction,o=r.removeFunction;var c=a(function($){i.free($)},"vi"),u=2,h=-1,l=2,d=0,f=1,p=2;function m($){return($.charCodeAt(0)&255)<<24|($.charCodeAt(1)&255)<<16|($.charCodeAt(2)&255)<<8|($.charCodeAt(3)&255)<<0}var v=m("JSON"),g=4;function y($){return[String.fromCharCode($>>24&255),String.fromCharCode($>>16&255),String.fromCharCode($>>8&255),String.fromCharCode($>>0&255)].join("")}function b($){return $=="BOT"?1:$=="EOT"?2:$=="PRESERVE_DEFAULT_IGNORABLES"?4:$=="REMOVE_DEFAULT_IGNORABLES"?8:$=="DO_NOT_INSERT_DOTTED_CIRCLE"?16:$=="PRODUCE_UNSAFE_TO_CONCAT"?64:0}function k($){var H=i.malloc($.byteLength);r.HEAPU8.set(new Uint8Array($),H);var z=i.hb_blob_create(H,$.byteLength,u,H,c);return{ptr:z,destroy:function(){i.hb_blob_destroy(z)}}}function x($){const H=i.hb_set_get_population($),z=i.malloc(H<<2),te=z>>2,he=r.HEAPU32.subarray(te,te+H);return r.HEAPU32.set(he,te),i.hb_set_next_many($,h,z,H),he}function E($,H){var z=i.hb_face_create($.ptr,H);const te=i.hb_face_get_upem(z);return{ptr:z,upem:te,reference_table:function(he){var Se=i.hb_face_reference_table(z,m(he)),Fe=i.hb_blob_get_length(Se);if(Fe){var Re=i.hb_blob_get_data(Se,null),Me=r.HEAPU8.subarray(Re,Re+Fe);return Me}},getAxisInfos:function(){var he=i.malloc(2048),Se=i.malloc(4);r.HEAPU32[Se/4]=64,i.hb_ot_var_get_axis_infos(z,0,Se,he);var Fe={};return Array.from({length:r.HEAPU32[Se/4]}).forEach(function(Re,Me){Fe[y(r.HEAPU32[he/4+Me*8+1])]={min:r.HEAPF32[he/4+Me*8+4],default:r.HEAPF32[he/4+Me*8+5],max:r.HEAPF32[he/4+Me*8+6]}}),i.free(Se),i.free(he),Fe},collectUnicodes:function(){var he=i.hb_set_create();i.hb_face_collect_unicodes(z,he);var Se=x(he);return i.hb_set_destroy(he),Se},destroy:function(){i.hb_face_destroy(z)}}}var T="",w=256,S=i.malloc(w);function _($){var H=i.hb_font_create($.ptr),z=null,te=null,he=null,Se=null,Fe=null,Re=null;function Me(j){if(!z){var N=function(ae,de,ke,le,J,Te){T+=`M${le},${J}`},L=function(ae,de,ke,le,J,Te){T+=`L${le},${J}`},B=function(ae,de,ke,le,J,Te,Je,dt,Xe,it){T+=`C${le},${J} ${Te},${Je} ${dt},${Xe}`},ie=function(ae,de,ke,le,J,Te,Je,dt){T+=`Q${le},${J} ${Te},${Je}`},fe=function(ae,de,ke,le){T+="Z"};te=a(N,"viiiffi"),he=a(L,"viiiffi"),Se=a(B,"viiiffffffi"),Fe=a(ie,"viiiffffi"),Re=a(fe,"viiii"),z=i.hb_draw_funcs_create(),i.hb_draw_funcs_set_move_to_func(z,te,0,0),i.hb_draw_funcs_set_line_to_func(z,he,0,0),i.hb_draw_funcs_set_cubic_to_func(z,Se,0,0),i.hb_draw_funcs_set_quadratic_to_func(z,Fe,0,0),i.hb_draw_funcs_set_close_path_func(z,Re,0,0)}return T="",i.hb_font_draw_glyph(H,j,z,0),T}function Ke(j){i.hb_font_glyph_to_string(H,j,S,w);var N=r.HEAPU8.subarray(S,S+w);return n.decode(N.slice(0,N.indexOf(0)))}return{ptr:H,glyphName:Ke,glyphToPath:Me,glyphToJson:function(j){var N=Me(j);return N.replace(/([MLQCZ])/g,"|$1 ").split("|").filter(function(L){return L.length}).map(function(L){var B=L.split(/[ ,]/g);return{type:B[0],values:B.slice(1).filter(function(ie){return ie.length}).map(function(ie){return+ie})}})},setScale:function(j,N){i.hb_font_set_scale(H,j,N)},setVariations:function(j){var N=Object.entries(j),L=i.malloc(8*N.length);N.forEach(function(B,ie){r.HEAPU32[L/4+ie*2+0]=m(B[0]),r.HEAPF32[L/4+ie*2+1]=B[1]}),i.hb_font_set_variations(H,L,N.length),i.free(L)},destroy:function(){i.hb_font_destroy(H),z&&(i.hb_draw_funcs_destroy(z),z=null,o(te),o(he),o(Se),o(Fe),o(Re))}}}function A($){var H=i.malloc($.length+1);for(let z=0;z<$.length;++z){const te=$.charCodeAt(z);if(te>127)throw new Error("Expected ASCII text");r.HEAPU8[H+z]=te}return r.HEAPU8[H+$.length]=0,{ptr:H,length:$.length,free:function(){i.free(H)}}}function M($){const H=i.malloc($.length*2),z=new Uint16Array(r.wasmMemory.buffer,H,$.length);for(let te=0;te<z.length;++te)z[te]=$.charCodeAt(te);return{ptr:H,length:z.length,free:function(){i.free(H)}}}function D(){var $=i.hb_buffer_create();return{ptr:$,addText:function(H){const z=M(H);i.hb_buffer_add_utf16($,z.ptr,z.length,0,z.length),z.free()},guessSegmentProperties:function(){return i.hb_buffer_guess_segment_properties($)},setDirection:function(H){i.hb_buffer_set_direction($,{ltr:4,rtl:5,ttb:6,btt:7}[H]||0)},setFlags:function(H){var z=0;H.forEach(function(te){z|=b(te)}),i.hb_buffer_set_flags($,z)},setLanguage:function(H){var z=A(H);i.hb_buffer_set_language($,i.hb_language_from_string(z.ptr,-1)),z.free()},setScript:function(H){var z=A(H);i.hb_buffer_set_script($,i.hb_script_from_string(z.ptr,-1)),z.free()},setClusterLevel:function(H){i.hb_buffer_set_cluster_level($,H)},json:function(){for(var H=i.hb_buffer_get_length($),z=[],te=i.hb_buffer_get_glyph_infos($,0),he=te/4,Se=i.hb_buffer_get_glyph_positions($,0)/4,Fe=r.HEAPU32.subarray(he,he+5*H),Re=r.HEAP32.subarray(Se,Se+5*H),Me=0;Me<H;++Me)z.push({g:Fe[Me*5+0],cl:Fe[Me*5+2],ax:Re[Me*5+0],ay:Re[Me*5+1],dx:Re[Me*5+2],dy:Re[Me*5+3],flags:i.hb_glyph_info_get_glyph_flags(te+Me*20)});return z},destroy:function(){i.hb_buffer_destroy($)}}}function W($,H,z){var te=0,he=0;z&&(z=z.split(","),te=i.malloc(16*z.length),z.forEach(function(Se,Fe){var Re=A(Se);i.hb_feature_from_string(Re.ptr,-1,te+he*16)&&he++,Re.free()})),i.hb_shape($.ptr,H.ptr,te,he),te&&i.free(te)}function G($,H,z,te,he){var Se=[],Fe=d,Re=!1,Me=1024*1024,Ke=i.malloc(Me),j=function(L,B,ie,fe){var ae=n.decode(r.HEAPU8.subarray(ie,r.HEAPU8.indexOf(0,ie)));return ae.startsWith("start table GSUB")?Fe=f:ae.startsWith("start table GPOS")&&(Fe=p),Fe!=he&&(Re=!1),he!=d&&Fe==he&&ae.startsWith("end lookup "+te)&&(Re=!0),Re?0:(i.hb_buffer_serialize_glyphs(L,0,i.hb_buffer_get_length(L),Ke,Me,0,B,v,g),Se.push({m:ae,t:JSON.parse(n.decode(r.HEAPU8.subarray(Ke,r.HEAPU8.indexOf(0,Ke)))),glyphs:i.hb_buffer_get_content_type(L)==l}),1)},N=a(j,"iiiii");return i.hb_buffer_set_message_func(H.ptr,N,0,0),W($,H,z),i.free(Ke),o(N),Se}function ue(){var $=i.malloc(12);i.hb_version($,$+4,$+8);var H={major:r.HEAPU32[$/4],minor:r.HEAPU32[($+4)/4],micro:r.HEAPU32[($+8)/4]};return i.free($),H}function re(){var $=i.hb_version_string(),H=n.decode(r.HEAPU8.subarray($,r.HEAPU8.indexOf(0,$)));return H}return{createBlob:k,createFace:E,createFont:_,createBuffer:D,shape:W,shapeWithTrace:G,version:ue,version_string:re}}try{e.exports=t}catch{}}});const ux=cx(),hx=Object.freeze(Object.defineProperty({__proto__:null,default:ux},Symbol.toStringTag,{value:"Module"}));ve.AssetSchema=Ju,ve.AudioAssetSchema=lo,ve.AudioAssetUrlSchema=zu,ve.AudioAssetVolumeSchema=$u,ve.Canvas=oi,ve.ClipSchema=wo,ve.Controls=pv,ve.Edit=Ri,ve.EditSchema=a0,ve.FontSourceSchema=i0,ve.FontSourceUrlSchema=r0,ve.HtmlAssetSchema=co,ve.ImageAssetCropSchema=Uu,ve.ImageAssetSchema=uo,ve.ImageAssetUrlSchema=Nu,ve.KeyframeEasingSchema=Lu,ve.KeyframeInterpolationSchema=Bu,ve.KeyframeSchema=$r,ve.LumaAssetSchema=ho,ve.LumaAssetUrlSchema=Hu,ve.OutputSchema=n0,ve.RichTextAssetSchema=Vs,ve.ShapeAssetCircleSchema=mo,ve.ShapeAssetColorSchema=fo,ve.ShapeAssetFillSchema=Vu,ve.ShapeAssetLineSchema=go,ve.ShapeAssetRectangleSchema=po,ve.ShapeAssetSchema=yo,ve.ShapeAssetStrokeSchema=ju,ve.TextAssetAlignmentSchema=Gu,ve.TextAssetBackgroundSchema=qu,ve.TextAssetColorSchema=Fn,ve.TextAssetFontSchema=Wu,ve.TextAssetSchema=bo,ve.TextAssetStrokeSchema=Xu,ve.Timeline=No,ve.TimelineSchema=s0,ve.TrackSchema=t0,ve.VideoAssetCropSchema=Ku,ve.VideoAssetSchema=vo,ve.VideoAssetUrlSchema=Zu,ve.VideoAssetVolumeSchema=Yu,ve.VideoExporter=M2,Object.defineProperty(ve,Symbol.toStringTag,{value:"Module"})});