route-graphics 0.0.2-rc11 → 0.0.2-rc13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/RouteGraphics.js +1 -1
- package/package.json +1 -1
package/dist/RouteGraphics.js
CHANGED
|
@@ -1139,4 +1139,4 @@ ${u}`)}});return await Promise.all(c),o?s[n[0].src]:s}async unload(t){let r=Ot(t
|
|
|
1139
1139
|
})();
|
|
1140
1140
|
`,zi=null,Xo=class{constructor(){zi||(zi=URL.createObjectURL(new Blob([YE],{type:"application/javascript"}))),this.worker=new Worker(zi)}};Xo.revokeObjectURL=function(){zi&&(URL.revokeObjectURL(zi),zi=null)};var iT=0,ud,dd=class{constructor(){this._initialized=!1,this._createdWorkers=0,this._workerPool=[],this._queue=[],this._resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{let{worker:e}=new Wi;e.addEventListener("message",r=>{e.terminate(),Wi.revokeObjectURL(),t(r.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t,e){return this._run("loadImageBitmap",[t,e?.data?.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){ud===void 0&&(ud=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers<ud&&(this._createdWorkers++,t=new Xo().worker,t.addEventListener("message",e=>{this._complete(e.data),this._returnWorker(e.target),this._next()})),t}_returnWorker(t){this._workerPool.push(t)}_complete(t){t.error!==void 0?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),this._resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();let r=new Promise((s,o)=>{this._queue.push({id:t,arguments:e,resolve:s,reject:o})});return this._next(),r}_next(){if(!this._queue.length)return;let t=this._getWorker();if(!t)return;let e=this._queue.pop(),r=e.id;this._resolveHash[iT]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:iT++,id:r})}},fd=new dd;ze();var KE=[".jpeg",".jpg",".png",".webp",".avif"],qE=["image/jpeg","image/png","image/webp","image/avif"];async function ZE(i,t){let e=await D.get().fetch(i);if(!e.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${i}: ${e.status} ${e.statusText}`);let r=await e.blob();return t?.data?.alphaMode==="premultiplied-alpha"?createImageBitmap(r,{premultiplyAlpha:"none"}):createImageBitmap(r)}var rc={name:"loadTextures",extension:{type:x.LoadParser,priority:Et.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(i){return ue(i,qE)||de(i,KE)},async load(i,t,e){let r=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await fd.isImageBitmapSupported()?r=await fd.loadImageBitmap(i,t):r=await ZE(i,t):r=await new Promise((o,n)=>{r=new Image,r.crossOrigin=this.config.crossOrigin,r.src=i,r.complete?o(r):(r.onload=()=>{o(r)},r.onerror=n)});let s=new qt({resource:r,alphaMode:"premultiply-alpha-on-upload",resolution:t.data?.resolution||Li(i),...t.data});return Ni(s,e,i)},unload(i){i.destroy(!0)}};P();Al();Pl();var sT=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"],QE=sT.map(i=>`video/${i.substring(1)}`);function JE(i,t,e){e===void 0&&!t.startsWith("data:")?i.crossOrigin=eP(t):e!==!1&&(i.crossOrigin=typeof e=="string"?e:"anonymous")}function tP(i){return new Promise((t,e)=>{i.addEventListener("canplaythrough",r),i.addEventListener("error",s),i.load();function r(){o(),t()}function s(n){o(),e(n)}function o(){i.removeEventListener("canplaythrough",r),i.removeEventListener("error",s)}})}function eP(i,t=globalThis.location){if(i.startsWith("data:"))return"";t||(t=globalThis.location);let e=new URL(i,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}var oT={name:"loadVideo",extension:{type:x.LoadParser,name:"loadVideo"},test(i){let t=ue(i,QE),e=de(i,sT);return t||e},async load(i,t,e){let r={...ei.defaultOptions,resolution:t.data?.resolution||Li(i),alphaMode:t.data?.alphaMode||await Mn(),...t.data},s=document.createElement("video"),o={preload:r.autoLoad!==!1?"auto":void 0,"webkit-playsinline":r.playsinline!==!1?"":void 0,playsinline:r.playsinline!==!1?"":void 0,muted:r.muted===!0?"":void 0,loop:r.loop===!0?"":void 0,autoplay:r.autoPlay!==!1?"":void 0};Object.keys(o).forEach(c=>{let l=o[c];l!==void 0&&s.setAttribute(c,l)}),r.muted===!0&&(s.muted=!0),JE(s,i,r.crossorigin);let n=document.createElement("source"),a;if(i.startsWith("data:"))a=i.slice(5,i.indexOf(";"));else if(!i.startsWith("blob:")){let c=i.split("?")[0].slice(i.lastIndexOf(".")+1).toLowerCase();a=ei.MIME_TYPES[c]||`video/${c}`}return n.src=i,a&&(n.type=a),new Promise(c=>{let l=async()=>{let h=new ei({...r,resource:s});s.removeEventListener("canplay",l),t.data.preload&&await tP(s),c(Ni(h,e,i))};s.addEventListener("canplay",l),s.appendChild(n)})},unload(i){i.destroy(!0)}};P();Qr();P();Qr();var ic={extension:{type:x.ResolveParser,name:"resolveTexture"},test:rc.test,parse:i=>({resolution:parseFloat(se.RETINA_PREFIX.exec(i)?.[1]??"1"),format:i.split(".").pop(),src:i})};var nT={extension:{type:x.ResolveParser,priority:-2,name:"resolveJson"},test:i=>se.RETINA_PREFIX.test(i)&&i.endsWith(".json"),parse:ic.parse};Qr();ps();Sn();var sc=class{constructor(){this._detections=[],this._initialized=!1,this.resolver=new se,this.loader=new ec,this.cache=Q,this._backgroundLoader=new Ja(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){if(this._initialized){k("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let o=t.manifest;typeof o=="string"&&(o=await this.load(o)),this.resolver.addManifest(o)}let e=t.texturePreference?.resolution??1,r=typeof e=="number"?[e]:e,s=await this._detectFormats({preferredFormats:t.texturePreference?.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:s,resolution:r}}),t.preferences&&this.setPreferences(t.preferences)}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();let r=Pr(t),s=Ot(t).map(a=>{if(typeof a!="string"){let c=this.resolver.getAlias(a);return c.some(l=>!this.resolver.hasKey(l))&&this.add(a),Array.isArray(c)?c[0]:c}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),o=this.resolver.resolve(s),n=await this._mapLoadToResolve(o,e);return r?n[s[0]]:n}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let r=!1;typeof t=="string"&&(r=!0,t=[t]);let s=this.resolver.resolveBundle(t),o={},n=Object.keys(s),a=0,c=0,l=()=>{e?.(++a/c)},h=n.map(u=>{let d=s[u];return c+=Object.keys(d).length,this._mapLoadToResolve(d,l).then(f=>{o[u]=f})});return await Promise.all(h),r?o[t[0]]:o}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);let e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);let e=this.resolver.resolveBundle(t);Object.values(e).forEach(r=>{this._backgroundLoader.add(Object.values(r))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return Q.get(t);let e={};for(let r=0;r<t.length;r++)e[r]=Q.get(t[r]);return e}async _mapLoadToResolve(t,e){let r=[...new Set(Object.values(t))];this._backgroundLoader.active=!1;let s=await this.loader.load(r,e);this._backgroundLoader.active=!0;let o={};return r.forEach(n=>{let a=s[n.src],c=[n.src];n.alias&&c.push(...n.alias),c.forEach(l=>{o[l]=a}),Q.set(c,a)}),o}async unload(t){this._initialized||await this.init();let e=Ot(t).map(s=>typeof s!="string"?s.src:s),r=this.resolver.resolve(e);await this._unloadFromResolved(r)}async unloadBundle(t){this._initialized||await this.init(),t=Ot(t);let e=this.resolver.resolveBundle(t),r=Object.keys(e).map(s=>this._unloadFromResolved(e[s]));await Promise.all(r)}async _unloadFromResolved(t){let e=Object.values(t);e.forEach(r=>{Q.remove(r.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(let r of t.detections)t.skipDetections||await r.test()?e=await r.add(e):t.skipDetections||(e=await r.remove(e));return e=e.filter((r,s)=>e.indexOf(r)===s),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(r=>r in t).forEach(r=>{e.config[r]=t[r]})})}},be=new sc;I.handleByList(x.LoadParser,be.loader.parsers).handleByList(x.ResolveParser,be.resolver.parsers).handleByList(x.CacheParser,be.cache.parsers).handleByList(x.DetectionParser,be.detections);I.add(j0,Y0,X0,Q0,K0,q0,Z0,J0,tT,eT,rT,rc,oT,V0,z0,ic,nT);var aT={loader:x.LoadParser,resolver:x.ResolveParser,cache:x.CacheParser,detection:x.DetectionParser};I.handle(x.Asset,i=>{let t=i.ref;Object.entries(aT).filter(([e])=>!!t[e]).forEach(([e,r])=>I.add(Object.assign(t[e],{extension:t[e].extension??r})))},i=>{let t=i.ref;Object.keys(aT).filter(e=>!!t[e]).forEach(e=>I.remove(t[e]))});rn();dt();Tn();var oc=class extends Je{constructor(t,e){let{text:r,resolution:s,style:o,anchor:n,width:a,height:c,roundPixels:l,...h}=t;super({...h}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=r??"",this.style=o,this.resolution=s??null,this.allowChildren=!1,this._anchor=new Bt({_onUpdate:()=>{this.onViewUpdate()}}),n&&(this.anchor=n),this.roundPixels=l??!1,a!==void 0&&(this.width=a),c!==void 0&&(this.height=c)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}set resolution(t){this._autoResolution=t===null,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){t||(t={}),this._style?.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(t){this._setWidth(t,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(t){this._setHeight(t,this.bounds.height)}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this.bounds.width,t.height=Math.abs(this.scale.y)*this.bounds.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this.bounds.width),e!==void 0&&this._setHeight(e,this.bounds.height)}containsPoint(t){let e=this.bounds.width,r=this.bounds.height,s=-e*this.anchor.x,o=0;return t.x>=s&&t.x<=s+e&&(o=-r*this.anchor.y,t.y>=o&&t.y<=o+r)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}_getKey(){return`${this.text}:${this._style.styleKey}:${this._resolution}`}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t?.style)&&this._style.destroy(t),this._style=null,this._text=null}};function cT(i,t){let e=i[0]??{};return(typeof e=="string"||i[1])&&(U(H,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:i[1]}),e}Ls();Fr();var ur=class extends oc{constructor(...t){let e=cT(t,"Text");super(e,St),this.renderPipeId="text"}updateBounds(){let t=this._bounds,e=this._anchor,r=At.measureText(this._text,this._style),{width:s,height:o}=r;t.minX=-e._x*s,t.maxX=t.minX+s,t.minY=-e._y*o,t.maxY=t.minY+o}};ze();vt();tt();Bl();me();$h();Pn();Ls();Fr();It();var rP=Jo(sh(),1);I.add(gy,_y);var Vt={Add:"add",Remove:"remove"},nc=class{init(t){throw new Error("Method not implemented.")}render(t){throw new Error("Method not implemented.")}},dr=class{rendererName;rendererType;add=(t,e)=>{throw new Error("Method not implemented.")};remove=(t,e)=>{throw new Error("Method not implemented.")};update=(t,e)=>{throw new Error("Method not implemented.")}};var ac=(i=[],t=[])=>{let e=[],r=[],s=[],o=i.filter(a=>!a.hidden),n=t.filter(a=>!a.hidden);for(let a of o){let c=n.find(l=>l.id===a.id&&l.type===a.type);c?r.push({prev:a,next:c}):e.push(a)}for(let a of n)o.find(l=>l.id===a.id&&l.type===a.type)||s.push(a);for(let a of i){let c=t.find(l=>l.id===a.id&&l.type===a.type);c&&c.hidden&&!a.hidden&&e.push(a)}return{toDeleteElements:e,toUpdateElements:r,toAddElements:s}};var Or=new(window.AudioContext||window.webkitAudioContext),Vi=class i{static loadedAssets={};static load=async(t,e)=>{if(!i.loadedAssets[t]&&e.byteLength!==0)try{let r=await Or.decodeAudioData(e);i.loadedAssets[t]=r}catch(r){console.error(`AudioAsset.load: Failed to decode ${t}:`,r)}};static getAsset=t=>i.loadedAssets[t]},pd=class{_audioSource;_gainNode;volume=1;id;url;loop=!1;constructor(t,e){this.id=t,this.url=e.url,this.loop=e.loop||!1,this.volume=e.volume??1,this._gainNode=Or.createGain(),this._gainNode.gain.value=this.volume,this._gainNode.connect(Or.destination)}play=()=>{let t=Vi.getAsset(this.url);if(!t){console.warn("AudioPlayer.play: Asset not found",this.url);return}this._audioSource=Or.createBufferSource(),this._audioSource.buffer=t,this._audioSource.loop=this.loop,this._gainNode.gain.setValueAtTime(this.volume,Or.currentTime),this._audioSource.connect(this._gainNode),this._audioSource.start(0)};stop=()=>{this._audioSource&&(this._audioSource.stop(),this._audioSource.disconnect(),this._gainNode.disconnect(),this._gainNode=Or.createGain(),this._gainNode.gain.value=this.volume,this._gainNode.connect(Or.destination))}},cc=class{audioPlayers=[];stageAudios=[];add=t=>{this.stageAudios.push(t)};remove=t=>{this.stageAudios=this.stageAudios.filter(e=>e.id!==t)};getById=t=>this.stageAudios.find(e=>e.id===t);tick=()=>{for(let e of this.stageAudios){let r=this.audioPlayers.find(s=>s.id===e.id);if(!r){let s=new pd(e.id,{url:e.url,loop:e.loop,volume:e.volume??1});this.audioPlayers.push(s),s.play();return}(r.url!==e.url||r.loop!==e.loop)&&(r.stop(),r.url=e.url,r.loop=e.loop??!1,r.play()),r.volume!==(e.volume??1)&&(r.volume=e.volume??1,r._gainNode.gain.value=r.volume)}let t=[];for(let e of this.audioPlayers)this.stageAudios.find(r=>r.id===e.id)||(e.stop(),t.push(e.id));this.audioPlayers=this.audioPlayers.filter(e=>!t.includes(e.id))};destroy=()=>{for(let t of this.audioPlayers)t.stop();this.audioPlayers=[],this.stageAudios=[]}};var md=function(i,t){return md=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])},md(i,t)};function $o(i,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");md(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function lT(i,t,e,r){function s(o){return o instanceof e?o:new e(function(n){n(o)})}return new(e||(e=Promise))(function(o,n){function a(h){try{l(r.next(h))}catch(u){n(u)}}function c(h){try{l(r.throw(h))}catch(u){n(u)}}function l(h){h.done?o(h.value):s(h.value).then(a,c)}l((r=r.apply(i,t||[])).next())})}function lc(i,t){var e={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,s,o,n=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return n.next=a(0),n.throw=a(1),n.return=a(2),typeof Symbol=="function"&&(n[Symbol.iterator]=function(){return this}),n;function a(l){return function(h){return c([l,h])}}function c(l){if(r)throw new TypeError("Generator is already executing.");for(;n&&(n=0,l[0]&&(e=0)),e;)try{if(r=1,s&&(o=l[0]&2?s.return:l[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,l[1])).done)return o;switch(s=0,o&&(l=[l[0]&2,o.value]),l[0]){case 0:case 1:o=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,s=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(o=e.trys,!(o=o.length>0&&o[o.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!o||l[1]>o[0]&&l[1]<o[3])){e.label=l[1];break}if(l[0]===6&&e.label<o[1]){e.label=o[1],o=l;break}if(o&&e.label<o[2]){e.label=o[2],e.ops.push(l);break}o[2]&&e.ops.pop(),e.trys.pop();continue}l=t.call(i,e)}catch(h){l=[6,h],s=0}finally{r=o=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function Lr(i){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&i[t],r=0;if(e)return e.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&r>=i.length&&(i=void 0),{value:i&&i[r++],done:!i}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function ji(i,t){var e=typeof Symbol=="function"&&i[Symbol.iterator];if(!e)return i;var r=e.call(i),s,o=[],n;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)o.push(s.value)}catch(a){n={error:a}}finally{try{s&&!s.done&&(e=r.return)&&e.call(r)}finally{if(n)throw n.error}}return o}function Xi(i,t,e){if(e||arguments.length===2)for(var r=0,s=t.length,o;r<s;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return i.concat(o||Array.prototype.slice.call(t))}function Nr(i){return this instanceof Nr?(this.v=i,this):new Nr(i)}function hT(i,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e.apply(i,t||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",n),s[Symbol.asyncIterator]=function(){return this},s;function n(f){return function(m){return Promise.resolve(m).then(f,u)}}function a(f,m){r[f]&&(s[f]=function(g){return new Promise(function(_,y){o.push([f,g,_,y])>1||c(f,g)})},m&&(s[f]=m(s[f])))}function c(f,m){try{l(r[f](m))}catch(g){d(o[0][3],g)}}function l(f){f.value instanceof Nr?Promise.resolve(f.value.v).then(h,u):d(o[0][2],f)}function h(f){c("next",f)}function u(f){c("throw",f)}function d(f,m){f(m),o.shift(),o.length&&c(o[0][0],o[0][1])}}function uT(i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=i[Symbol.asyncIterator],e;return t?t.call(i):(i=typeof Lr=="function"?Lr(i):i[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(o){e[o]=i[o]&&function(n){return new Promise(function(a,c){n=i[o](n),s(a,c,n.done,n.value)})}}function s(o,n,a,c){Promise.resolve(c).then(function(l){o({value:l,done:a})},n)}}function et(i){return typeof i=="function"}function dT(i){var t=function(r){Error.call(r),r.stack=new Error().stack},e=i(t);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var hc=dT(function(i){return function(e){i(this),this.message=e?e.length+` errors occurred during unsubscription:
|
|
1141
1141
|
`+e.map(function(r,s){return s+1+") "+r.toString()}).join(`
|
|
1142
|
-
`):"",this.name="UnsubscriptionError",this.errors=e}});function gd(i,t){if(i){var e=i.indexOf(t);0<=e&&i.splice(e,1)}}var uc=function(){function i(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return i.prototype.unsubscribe=function(){var t,e,r,s,o;if(!this.closed){this.closed=!0;var n=this._parentage;if(n)if(this._parentage=null,Array.isArray(n))try{for(var a=Lr(n),c=a.next();!c.done;c=a.next()){var l=c.value;l.remove(this)}}catch(g){t={error:g}}finally{try{c&&!c.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}else n.remove(this);var h=this.initialTeardown;if(et(h))try{h()}catch(g){o=g instanceof hc?g.errors:[g]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var d=Lr(u),f=d.next();!f.done;f=d.next()){var m=f.value;try{fT(m)}catch(g){o=o??[],g instanceof hc?o=Xi(Xi([],ji(o)),ji(g.errors)):o.push(g)}}}catch(g){r={error:g}}finally{try{f&&!f.done&&(s=d.return)&&s.call(d)}finally{if(r)throw r.error}}}if(o)throw new hc(o)}},i.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)fT(t);else{if(t instanceof i){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},i.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},i.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},i.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&gd(e,t)},i.prototype.remove=function(t){var e=this._finalizers;e&&gd(e,t),t instanceof i&&t._removeParent(this)},i.EMPTY=function(){var t=new i;return t.closed=!0,t}(),i}();var $Y=uc.EMPTY;function dc(i){return i instanceof uc||i&&"closed"in i&&et(i.remove)&&et(i.add)&&et(i.unsubscribe)}function fT(i){et(i)?i():i.unsubscribe()}var ve={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var $i={setTimeout:function(i,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];var s=$i.delegate;return s?.setTimeout?s.setTimeout.apply(s,Xi([i,t],ji(e))):setTimeout.apply(void 0,Xi([i,t],ji(e)))},clearTimeout:function(i){var t=$i.delegate;return(t?.clearTimeout||clearTimeout)(i)},delegate:void 0};function fc(i){$i.setTimeout(function(){var t=ve.onUnhandledError;if(t)t(i);else throw i})}function xd(){}var pT=function(){return _d("C",void 0,void 0)}();function mT(i){return _d("E",void 0,i)}function gT(i){return _d("N",i,void 0)}function _d(i,t,e){return{kind:i,value:t,error:e}}var Hr=null;function xT(i){if(ve.useDeprecatedSynchronousErrorHandling){var t=!Hr;if(t&&(Hr={errorThrown:!1,error:null}),i(),t){var e=Hr,r=e.errorThrown,s=e.error;if(Hr=null,r)throw s}}else i()}function _T(i){ve.useDeprecatedSynchronousErrorHandling&&Hr&&(Hr.errorThrown=!0,Hr.error=i)}var Yo=function(i){$o(t,i);function t(e){var r=i.call(this)||this;return r.isStopped=!1,e?(r.destination=e,dc(e)&&e.add(r)):r.destination=nP,r}return t.create=function(e,r,s){return new mc(e,r,s)},t.prototype.next=function(e){this.isStopped?bd(gT(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?bd(mT(e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?bd(pT,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,i.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(uc);var iP=Function.prototype.bind;function yd(i,t){return iP.call(i,t)}var sP=function(){function i(t){this.partialObserver=t}return i.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(r){pc(r)}},i.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){pc(r)}else pc(t)},i.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){pc(e)}},i}(),mc=function(i){$o(t,i);function t(e,r,s){var o=i.call(this)||this,n;if(et(e)||!e)n={next:e??void 0,error:r??void 0,complete:s??void 0};else{var a;o&&ve.useDeprecatedNextContext?(a=Object.create(e),a.unsubscribe=function(){return o.unsubscribe()},n={next:e.next&&yd(e.next,a),error:e.error&&yd(e.error,a),complete:e.complete&&yd(e.complete,a)}):n=e}return o.destination=new sP(n),o}return t}(Yo);function pc(i){ve.useDeprecatedSynchronousErrorHandling?_T(i):fc(i)}function oP(i){throw i}function bd(i,t){var e=ve.onStoppedNotification;e&&$i.setTimeout(function(){return e(i,t)})}var nP={closed:!0,next:xd,error:oP,complete:xd};var Yi=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function yT(i){return i}function bT(i){return i.length===0?yT:i.length===1?i[0]:function(e){return i.reduce(function(r,s){return s(r)},e)}}var at=function(){function i(t){t&&(this._subscribe=t)}return i.prototype.lift=function(t){var e=new i;return e.source=this,e.operator=t,e},i.prototype.subscribe=function(t,e,r){var s=this,o=cP(t)?t:new mc(t,e,r);return xT(function(){var n=s,a=n.operator,c=n.source;o.add(a?a.call(o,c):c?s._subscribe(o):s._trySubscribe(o))}),o},i.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},i.prototype.forEach=function(t,e){var r=this;return e=vT(e),new e(function(s,o){var n=new mc({next:function(a){try{t(a)}catch(c){o(c),n.unsubscribe()}},error:o,complete:s});r.subscribe(n)})},i.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},i.prototype[Yi]=function(){return this},i.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return bT(t)(this)},i.prototype.toPromise=function(t){var e=this;return t=vT(t),new t(function(r,s){var o;e.subscribe(function(n){return o=n},function(n){return s(n)},function(){return r(o)})})},i.create=function(t){return new i(t)},i}();function vT(i){var t;return(t=i??ve.Promise)!==null&&t!==void 0?t:Promise}function aP(i){return i&&et(i.next)&&et(i.error)&&et(i.complete)}function cP(i){return i&&i instanceof Yo||aP(i)&&dc(i)}function lP(i){return et(i?.lift)}function Fe(i){return function(t){if(lP(t))return t.lift(function(e){try{return i(e,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function Wr(i,t,e,r,s){return new hP(i,t,e,r,s)}var hP=function(i){$o(t,i);function t(e,r,s,o,n,a){var c=i.call(this,e)||this;return c.onFinalize=n,c.shouldUnsubscribe=a,c._next=r?function(l){try{r(l)}catch(h){e.error(h)}}:i.prototype._next,c._error=o?function(l){try{o(l)}catch(h){e.error(h)}finally{this.unsubscribe()}}:i.prototype._error,c._complete=s?function(){try{s()}catch(l){e.error(l)}finally{this.unsubscribe()}}:i.prototype._complete,c}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;i.prototype.unsubscribe.call(this),!r&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t}(Yo);var gc=function(i){return i&&typeof i.length=="number"&&typeof i!="function"};function xc(i){return et(i?.then)}function _c(i){return et(i[Yi])}function yc(i){return Symbol.asyncIterator&&et(i?.[Symbol.asyncIterator])}function bc(i){return new TypeError("You provided "+(i!==null&&typeof i=="object"?"an invalid object":"'"+i+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function uP(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var vc=uP();function Tc(i){return et(i?.[vc])}function Sc(i){return hT(this,arguments,function(){var e,r,s,o;return lc(this,function(n){switch(n.label){case 0:e=i.getReader(),n.label=1;case 1:n.trys.push([1,,9,10]),n.label=2;case 2:return[4,Nr(e.read())];case 3:return r=n.sent(),s=r.value,o=r.done,o?[4,Nr(void 0)]:[3,5];case 4:return[2,n.sent()];case 5:return[4,Nr(s)];case 6:return[4,n.sent()];case 7:return n.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function wc(i){return et(i?.getReader)}function Ue(i){if(i instanceof at)return i;if(i!=null){if(_c(i))return dP(i);if(gc(i))return fP(i);if(xc(i))return pP(i);if(yc(i))return TT(i);if(Tc(i))return mP(i);if(wc(i))return gP(i)}throw bc(i)}function dP(i){return new at(function(t){var e=i[Yi]();if(et(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function fP(i){return new at(function(t){for(var e=0;e<i.length&&!t.closed;e++)t.next(i[e]);t.complete()})}function pP(i){return new at(function(t){i.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,fc)})}function mP(i){return new at(function(t){var e,r;try{for(var s=Lr(i),o=s.next();!o.done;o=s.next()){var n=o.value;if(t.next(n),t.closed)return}}catch(a){e={error:a}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}t.complete()})}function TT(i){return new at(function(t){xP(i,t).catch(function(e){return t.error(e)})})}function gP(i){return TT(Sc(i))}function xP(i,t){var e,r,s,o;return lT(this,void 0,void 0,function(){var n,a;return lc(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),e=uT(i),c.label=1;case 1:return[4,e.next()];case 2:if(r=c.sent(),!!r.done)return[3,4];if(n=r.value,t.next(n),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),s={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),r&&!r.done&&(o=e.return)?[4,o.call(e)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function fe(i,t,e,r,s){r===void 0&&(r=0),s===void 0&&(s=!1);var o=t.schedule(function(){e(),s?i.add(this.schedule(null,r)):this.unsubscribe()},r);if(i.add(o),!s)return o}function Ec(i,t){return t===void 0&&(t=0),Fe(function(e,r){e.subscribe(Wr(r,function(s){return fe(r,i,function(){return r.next(s)},t)},function(){return fe(r,i,function(){return r.complete()},t)},function(s){return fe(r,i,function(){return r.error(s)},t)}))})}function Pc(i,t){return t===void 0&&(t=0),Fe(function(e,r){r.add(i.schedule(function(){return e.subscribe(r)},t))})}function ST(i,t){return Ue(i).pipe(Pc(t),Ec(t))}function wT(i,t){return Ue(i).pipe(Pc(t),Ec(t))}function ET(i,t){return new at(function(e){var r=0;return t.schedule(function(){r===i.length?e.complete():(e.next(i[r++]),e.closed||this.schedule())})})}function PT(i,t){return new at(function(e){var r;return fe(e,t,function(){r=i[vc](),fe(e,t,function(){var s,o,n;try{s=r.next(),o=s.value,n=s.done}catch(a){e.error(a);return}n?e.complete():e.next(o)},0,!0)}),function(){return et(r?.return)&&r.return()}})}function Ac(i,t){if(!i)throw new Error("Iterable cannot be null");return new at(function(e){fe(e,t,function(){var r=i[Symbol.asyncIterator]();fe(e,t,function(){r.next().then(function(s){s.done?e.complete():e.next(s.value)})},0,!0)})})}function AT(i,t){return Ac(Sc(i),t)}function CT(i,t){if(i!=null){if(_c(i))return ST(i,t);if(gc(i))return ET(i,t);if(xc(i))return wT(i,t);if(yc(i))return Ac(i,t);if(Tc(i))return PT(i,t);if(wc(i))return AT(i,t)}throw bc(i)}function te(i,t){return t?CT(i,t):Ue(i)}function MT(i,t){return Fe(function(e,r){var s=0;e.subscribe(Wr(r,function(o){r.next(i.call(t,o,s++))}))})}function BT(i,t,e,r,s,o,n,a){var c=[],l=0,h=0,u=!1,d=function(){u&&!c.length&&!l&&t.complete()},f=function(g){return l<r?m(g):c.push(g)},m=function(g){o&&t.next(g),l++;var _=!1;Ue(e(g,h++)).subscribe(Wr(t,function(y){s?.(y),o?f(y):t.next(y)},function(){_=!0},void 0,function(){if(_)try{l--;for(var y=function(){var b=c.shift();n?fe(t,n,function(){return m(b)}):m(b)};c.length&&l<r;)y();d()}catch(b){t.error(b)}}))};return i.subscribe(Wr(t,f,function(){u=!0,d()})),function(){a?.()}}function jt(i,t,e){return e===void 0&&(e=1/0),et(t)?jt(function(r,s){return MT(function(o,n){return t(r,o,s,n)})(Ue(i(r,s)))},e):(typeof t=="number"&&(e=t),Fe(function(r,s){return BT(r,s,i,e)}))}function Ko(i){return Fe(function(t,e){try{t.subscribe(e)}finally{e.add(i)}})}var _P=i=>i.split("/").pop(),vd=class{name="advancedBufferLoader";priority=2;constructor(t){this.bufferMap=t}test(t){return!0}async load(t){let e=t.startsWith("file:")?t:_P(t),r=this.bufferMap[e];if(!r)throw new Error(`Buffer not found for key: ${e}`);return{data:r.buffer,type:r.type,metadata:null}}async testParse(t){return!0}async parse(t){if(t instanceof M)return t;let e=new Blob([t.data],{type:t.type}),r=await createImageBitmap(e);return new M.from(r)}async unload(t){t.destroy(!0)}},Td=class i extends nc{static rendererName="pixi";_app;_audioStage=new cc;_state={elements:[]};_eventHandler;_plugins;_currentSubscription;_advancedLoader;get canvas(){return this._app.canvas}init=async t=>{let{eventHandler:e,plugins:r,width:s,height:o,backgroundColor:n}=t;for(let c of r)if(c.rendererName!==i.rendererName)throw new Error("Plugin does not match renderer name");this._plugins=r,this._eventHandler=e,this._app=new Za,this._app.audioStage=this._audioStage,await this._app.init({width:s,height:o,backgroundColor:n});let a=new Wt;return a.rect(0,0,s,o),a.fill(n||0),this._app.stage.addChild(a),this._app.stage.width=s,this._app.stage.height=o,this._app.ticker.add(this._app.audioStage.tick),this};destroy=()=>{this._app.audioStage.destroy(),this._app.destroy()};loadAssets=async t=>{if(!t)throw new Error("assetBufferMap is required");let e={},r={};for(let[o,n]of Object.entries(t))n.type&&n.type.startsWith("audio/")?r[o]=n:e[o]=n;await Promise.all(Object.entries(r).map(([o,n])=>Vi.load(o,n.buffer))),this._advancedLoader?Object.assign(this._advancedLoader.bufferMap,e):(this._advancedLoader=new vd(e),be.loader.parsers.length=0,be.reset(),I.add({name:"advanced-buffer-loader",extension:x.Asset,priority:Et.High,loader:this._advancedLoader}),typeof be.registerPlugin=="function"&&be.registerPlugin(this._advancedLoader));let s=Object.keys(e);return Promise.all(s.map(o=>be.load(o)))};loadAudioAssets=async t=>Promise.all(t.map(async e=>{let s=await(await fetch(e)).arrayBuffer();return Vi.load(e,s)}));updatedBackgroundColor=t=>{this._app.renderer.background.color=t};render=t=>{this._render(this._app,this._app.stage,this._state,t,this._eventHandler),this._state=t};_getRendererByElement=t=>{for(let e of this._plugins)if(e.rendererType===t.type)return e;throw new Error(`No renderer found for element type: ${t.type}`)};_getTransitionByType=t=>{for(let e of this._plugins)if(e.transitionType===t)return e;throw new Error(`No transition found for transition type: ${t}`)};_render=async(t,e,r,s,o)=>{let n=Date.now(),{toAddElements:a,toUpdateElements:c,toDeleteElements:l}=ac(r.elements,s.elements),h=[];for(let u of l){let d=this._getRendererByElement(u);h.push(d.remove(t,{parent:e,element:u,transitions:s.transitions,getRendererByElement:this._getRendererByElement,getTransitionByType:this._getTransitionByType,eventHandler:o}))}for(let u of a){let d=this._getRendererByElement(u);h.push(d.add(t,{parent:e,element:u,getRendererByElement:this._getRendererByElement,transitions:s.transitions,getTransitionByType:this._getTransitionByType,eventHandler:o}))}for(let u of c){let d=this._getRendererByElement(u.next);h.push(d.update(t,{parent:e,prevElement:u.prev,nextElement:u.next,getRendererByElement:this._getRendererByElement,transitions:s.transitions,getTransitionByType:this._getTransitionByType,eventHandler:o}))}t.stage.children.sort((u,d)=>{let f=s.elements.findIndex(g=>g.id===u.label),m=s.elements.findIndex(g=>g.id===d.label);return f-m}),this._currentSubscription&&(this._currentSubscription.closed||this._currentSubscription.unsubscribe()),this._currentSubscription=te(h).pipe(jt(u=>u),Ko(()=>{o&&o("completed",{id:s.id,diffTime:Date.now()-n}),this._currentSubscription=void 0})).subscribe({error:u=>{console.error("Error:",u)}})}},RT=Td;var Sd=class extends dr{static rendererName="pixi";rendererName="pixi";rendererType="sprite";add=(t,e)=>new at(r=>{let{parent:s,element:o,transitions:n=[],getTransitionByType:a,eventHandler:c}=e,l=M.from(o.url),h,u,d=o.scaleX??1,f=o.scaleY??1;o.hoverUrl&&(h=M.from(o.hoverUrl)),o.clickUrl&&(u=M.from(o.clickUrl));let m=new Lt(l);m.label=o.id,(o.eventName||o.hoverUrl||o.clickUrl)&&(m.cursor="pointer",m.eventMode="static"),o.anchorX!==void 0&&(m.pivot.x=m.width*o.anchorX),o.anchorY!==void 0&&(m.pivot.y=m.height*o.anchorY),o.rotation!==void 0&&(m.rotation=o.rotation*Math.PI/180),o.x!==void 0&&(m.x=o.x),o.y!==void 0&&(m.y=o.y),o.width!==void 0?m.width=o.width*d:m.width*=d,o.height!==void 0?m.height=o.height*f:m.height*=f,o.zIndex!==void 0&&(m.zIndex=o.zIndex),o.alpha!==void 0&&(m.alpha=o.alpha),m.on("pointerup",()=>{m.texture=l}).on("pointerupoutside",()=>{m.texture=l}).on("pointerleave",()=>{m.texture=l}),u&&m.on("pointerdown",()=>{m.texture=u}),h&&m.on("pointerenter",()=>{m.texture=h}),m.on("pointerup",y=>{y.stopPropagation();let b=y.button;b===0?c&&c(o.eventName,o.eventPayload):b===2&&(o.rightClickEventName&&c?c(o.rightClickEventName):t.stage.emit("rightclick",event))});let g=[];for(let y of n)if(y.elementId===o.id&&y.event===Vt.Add){let b=a(y.type);if(!b)throw new Error(`Transition class not found for type ${y.type}`);g.push(b.add(t,m,y))}s.addChild(m);let _=te(g).pipe(jt(y=>y)).subscribe({error:y=>{console.error("Error:",y)},complete:()=>r.complete()});return()=>{_.unsubscribe()}});remove=(t,e)=>new at(r=>{let{parent:s,element:o,transitions:n=[],getTransitionByType:a}=e,c=s.getChildByName(o.id);if(!c)throw new Error(`Sprite with id ${o.id} not found`);let l=[];for(let u of n)if(u.elementId===o.id&&u.event===Vt.Remove){let d=a(u.type);if(!d)throw new Error(`Transition class not found for type ${u.type}`);l.push(d.remove(t,c,u))}let h=te(l).pipe(jt(u=>u)).subscribe({error:u=>{console.error("Error:",u)},complete:()=>{r.complete(),c&&c.destroy()}});return()=>{h.unsubscribe(),c&&c.destroy()}});update=(t,{parent:e,prevElement:r,nextElement:s,transitions:o,getTransitionByType:n,eventHandler:a})=>new at(c=>{let l=e.getChildByName(r.id);if(!l)throw new Error(`Sprite with id ${r.id} not found`);if(JSON.stringify(r)!==JSON.stringify(s)){let h=[this.add(t,{parent:e,element:s,transitions:o,getTransitionByType:n,eventHandler:a}),this.remove(t,{parent:e,element:r,transitions:o,getTransitionByType:n})],u=te(h).pipe(jt(d=>d)).subscribe({error:d=>{console.error("Error:",d)},complete:()=>c.complete()});return()=>{u.unsubscribe()}}else s.x!==void 0&&(l.x=s.x),s.y!==void 0&&(l.y=s.y),s.width!==void 0&&s.width!==r.width&&(l.width=s.width),s.height!==void 0&&s.height!==r.height&&(l.height=s.height),s.alpha!==void 0&&s.alpha!==r.alpha&&(l.alpha=s.alpha),c.complete();return()=>{}})};var Cc=(i,t=!1)=>new St({wordWrap:i.wordWrap||!0,breakWords:t,align:i.align,fill:i.fill,fontSize:i.fontSize,lineHeight:i.lineHeight,wordWrapWidth:i.wordWrapWidth,fontFamily:i.fontFamily||"Roboto",stroke:i.strokeColor?{color:i.strokeColor,width:i.strokeWidth}:void 0}),wd=class{static rendererName="pixi";rendererName="pixi";rendererType="text";add=(t,e)=>new at(r=>{let{parent:s,element:o,transitions:n=[],getTransitionByType:a,eventHandler:c}=e,l=Cc(o.style),h=new ur({text:o.text,style:l}),u;o.hoverStyle&&(u=Cc(o.hoverStyle));let d;if(o.clickedStyle&&(d=Cc(o.clickedStyle)),(o.eventName||o.clickedStyle||o.hoverStyle)&&(h.cursor="pointer",h.eventMode="static"),h.label=o.id,o.x!==void 0&&(h.x=o.x),o.y!==void 0&&(h.y=o.y),o.xa!==void 0&&(h.anchor.x=o.xa),o.ya!==void 0&&(h.anchor.y=o.ya),o.xa!==void 0||o.ya!==void 0){let g=h.getLocalBounds();h.hitArea=new z(-g.width*h.anchor.x,-g.height*h.anchor.y,g.width,g.height)}h.on("pointerupoutside",()=>{h.style=l}).on("pointerup",()=>{h.style=l}).on("pointerleave",()=>{h.style=l}),h.on("pointerup",g=>{o.clickSoundUrl&&t.soundStage&&t.soundStage.add({id:`${o.id}-click-${Math.random()}`,url:o.clickSoundUrl,loop:!1,volume:o.clickSoundVolume??50/100}),g.stopPropagation(),c&&c(o.eventName,o.eventPayload)}),d&&h.on("pointerdown",()=>{h.style=d}),u&&h.on("pointerenter",()=>{h.style=u,o.hoverSoundUrl&&t.soundStage&&o.hoverSoundVolume!==void 0&&t.soundStage.add({id:`${o.id}-hover-${Math.random()}`,url:o.hoverSoundUrl,loop:!1,volume:o.hoverSoundVolume/100})});let f=[];for(let g of n)if(g.elementId===o.id&&g.event===Vt.Add){let _=a(g.type);if(!_)throw new Error(`Transition class not found for type ${g.type}`);f.push(_.add(t,h,g))}s.addChild(h);let m=te(f).pipe(jt(g=>g)).subscribe({error:g=>{console.error("Error:",g),r.error(g)},complete:()=>r.complete()});return()=>{m.unsubscribe()}});remove=(t,e)=>new at(r=>{let{parent:s,element:o,transitions:n=[],getTransitionByType:a}=e,c=s.getChildByName(o.id);if(!c){console.warn(`Text with id ${o.id} not found`),r.complete();return}let l=[];for(let u of n)if(u.elementId===o.id&&u.event===Vt.Remove){let d=a(u.type);if(!d)throw new Error(`Transition class not found for type ${u.type}`);l.push(d.remove(t,c,u))}let h=te(l).pipe(jt(u=>u)).subscribe({error:u=>{console.error("Error:",u),r.error(u)},complete:()=>{c.destroy(),r.complete()}});return()=>{h.unsubscribe(),c&&c.destroy()}});update=(t,e)=>new at(r=>{let{parent:s,prevElement:o,nextElement:n,transitions:a,getTransitionByType:c,eventHandler:l}=e,h=s.getChildByName(o.id);if(!h){console.warn(`Text with id ${o.id} not found`),r.complete();return}if(JSON.stringify(o)!==JSON.stringify(n)){let u=[this.add(t,{parent:s,element:n,transitions:a,getTransitionByType:c,eventHandler:l}),this.remove(t,{parent:s,element:o,transitions:a,getTransitionByType:c})],d=te(u).pipe(jt(f=>f)).subscribe({error:f=>{console.error("Error:",f),r.error(f)},complete:()=>r.complete()});return()=>{d.unsubscribe()}}else o.text!==n.text&&(h.text=n.text),JSON.stringify(o.style)!==JSON.stringify(n.style)&&(h.style=Cc(n?.style)),n.x!==void 0&&(h.x=n.x),n.y!==void 0&&(h.y=n.y),r.complete();return()=>{}})};var Ki=(i,t=!1)=>new St({wordWrap:i.wordWrap||!0,breakWords:t,align:i.align,fill:i.fill,fontSize:i.fontSize,lineHeight:i.lineHeight,wordWrapWidth:i.wordWrapWidth,fontFamily:i.fontFamily||"Roboto",stroke:i.strokeColor?{color:i.strokeColor,width:i.strokeWidth}:void 0}),Ed=class{static rendererName="pixi";rendererName="pixi";rendererType="text-revealing";add=async(t,{parent:e,element:r})=>{let s=Ki(r.style,r.text),o=new ur({text:"",style:s});o.label=r.id,o.text_id=r.text;let n=new nt;r.x!==void 0&&(n.x=r.x),r.y!==void 0&&(n.y=r.y),n.addChild(o),n.label=r.id,e.addChild(n);let a=r.style.wordWrapWidth||500,c=r.text?[{text:r.text,style:r.style}]:r.segments,l=[],h=[],u=0,d=0,f=0;for(;;){let T=c[0];if(!T){h.length>0&&l.push({lineParts:h,y:d});break}if(d>1e4)break;let w={...T.style,wordWrapWidth:a-u},A=At.measureText(T.text,Ki(w));A.lineHeight>f&&(f=A.lineHeight);let R=At.measureText("a",Ki(w)),G=At.measureText("a a",Ki(w)).width-R.width*2;if(A.lineWidths[0]+u>a){u=0,l.push({lineParts:h,y:d}),d+=f,f=0,h=[];continue}let L=A.lines[0],Y=A.lines.slice(1).join(" "),mt={text:L,style:w,x:u,y:0};if(h.push(mt),Y&&Y.length>0?T.text=Y:c.shift(),!(!L||L.length===0)){if(T.furigana){let Xt=At.measureText(T.furigana.text,Ki(T.furigana.style)),N={text:T.furigana.text,style:T.furigana.style,x:u+(A.width-Xt.width)/2,y:-10};h.push(N)}u+=A.lineWidths[0]+G}}l.forEach(T=>{let w=new nt;w.y=T.y,w.alpha=0,T.lineParts.forEach(A=>{let R=new ur({text:A.text,style:Ki(A.style),x:A.x,y:A.y});w.addChild(R)}),n.addChild(w)});let m=new Wt,g=1e3,_=a/2,y=a/2;m.fill({color:16777215,alpha:1}),m.rect(0,0,_,g);for(let T=0;T<y;T++)m.fill({color:16777215,alpha:1-T/y}),m.rect(_+T,0,_+1,g);let b=t.renderer.generateTexture(m),v=new Lt(b);v.x=-1.35*_-y,t.stage.addChild(v);let S=0,E=1;if(l.length!==0){if(r.displaySpeed===100||r.hasEnded){n.children.forEach(T=>{t.stage.removeChild(v),T.mask=null,T.alpha=1});return}await new Promise(T=>{let w=A=>{if(E>n.children.length){T();return}n.getChildAt(E).mask||(n.getChildAt(E).mask=v,n.getChildAt(E).alpha=1),S+=A.deltaMS;let C=(r.displaySpeed||50)/1e3;v.x+=C*S,v.x>=0&&(n.getChildAt(E).mask=null,v.x=-1.35*_-y,E=E+1,S=0,E>=n.children.length&&(n.getChildAt(E-1).mask=null,t.ticker.remove(w),T()))};t.ticker.add(w)})}};remove=async(t,e)=>{let{parent:r,element:s,transitions:o=[],getTransitionByType:n}=e,a=r.getChildByName(s.id);if(!a){console.warn(`Text with id ${s.id} not found`,{parent:r});return}let c=[];for(let l of o)if(l.elementId===s.id&&l.event===Vt.Remove){let h=n(l.type);if(!h)throw new Error(`Transition class not found for type ${l.type}`);c.push(h.remove(t,a,l))}await Promise.all(c),a.destroy()};update=async(t,e)=>{let{parent:r,prevElement:s,nextElement:o}=e;if(!r.getChildByName(s.id)){console.warn(`Text with id ${s.id} not found`,{parent:r});return}await this.remove(t,{parent:r,element:s}),await this.add(t,{parent:r,element:o})}};var Pd=class{static rendererName="pixi";rendererName="pixi";rendererType="container";add=(t,e)=>new at(r=>{let{parent:s,element:o,transitions:n=[],getTransitionByType:a,getRendererByElement:c,eventHandler:l}=e,h=structuredClone(o),u=new nt;u.label=h.id;let d={};h.x!==void 0&&(typeof h.x=="string"&&h.x.endsWith("%")?u.x=Number(h.x.replace("%",""))*t.screen.width/100:u.x=h.x),h.y!==void 0&&(typeof h.y=="string"&&h.y.endsWith("%")?u.y=Number(h.y.replace("%",""))*t.screen.height/100:u.y=h.y),h.scaleX!==void 0&&(u.scale.x=h.scaleX),h.scaleY!==void 0&&(u.scale.y=h.scaleY),h.zIndex!==void 0&&(u.zIndex=h.zIndex),h.rotation!==void 0&&(u.rotation=h.rotation*Math.PI/180),h.propagateEvents&&(u.eventMode="static",["pointerup","pointerupoutside","pointerleave","pointerdown","pointerenter"].forEach(E=>{u.on(E,T=>{T.stopPropagation();for(let w of u.children)w.emit(E)})}));let f=h.gap||0,m=new Wt().roundRect(0,0,h.width||0,h.height||0,1).fill(h.fill?h.fill.color:"transparent"),g=[0,.5,1],_=h.anchorX??0,y=h.anchorY??0;if(!g.includes(_))throw new Error(`Invalid anchorX value: ${_}. Must be 0, 0.5, or 1`);if(!g.includes(y))throw new Error(`Invalid anchorY value: ${y}. Must be 0, 0.5, or 1`);if(h.direction){let E,T;h.direction==="horizontal"?(E=h.children.reduce((A,R)=>A+R.width+f,0),T=h.children.reduce((A,R)=>Math.max(A,R.height||0),0)):h.direction==="vertical"&&(E=h.children.reduce((A,R)=>Math.max(A,R.width||0),0),T=h.children.reduce((A,R)=>A+R.height+f,0));let w={x:_,y};h.direction==="horizontal"?this.layoutChildren({element:h,anchor:w,totalWidth:E,totalHeight:T,gap:f,direction:"horizontal",scroll:h.scroll}):h.direction==="vertical"&&this.layoutChildren({element:h,anchor:w,totalWidth:E,totalHeight:T,gap:f,direction:"vertical",scroll:h.scroll}),this.setupScrolling({container:u,element:h,totalHeight:T,totalWidth:E,eventHandler:l,sliderRef:d}),m=this.createContainerGraphic(h,E,T,w)}m.label=`${h.id}-container-background`,u.addChild(m);let b=[];(h.children||[]).forEach(E=>{let T=c(E),w=h.width||0,A=h.height||0,R=_*w,C=y*A,G={zIndex:h.zIndex,...E,x:(E.x||0)+R,y:(E.y||0)+C};b.push(T.add(t,{parent:u,element:G,transitions:n,getTransitionByType:a,getRendererByElement:c,eventHandler:l}))});let v=[];for(let E of n)if(E.elementId===h.id&&E.event===Vt.Add){let T=a(E.type);if(!T)throw new Error(`Transition class not found for type ${E.type}`);v.push(T.add(t,u,E))}s.addChild(u);let S=te(b).pipe(jt(E=>E)).subscribe({error:E=>{console.error("Error:",E)},complete:()=>{let{width:E,height:T}=this.getContainerDimensions(h,u),w=_*E,A=y*T;u.pivot.x=w,u.pivot.y=A,r.complete()}});return()=>{S.unsubscribe()}});remove=(t,e)=>(console.log("remove container 11111111111"),new at(r=>{let{parent:s,element:o}=e,n=s.getChildByName(o.id);if(!n){console.warn(`Container with id ${o.id} not found`);return}return n.destroy(),()=>{n.destroy()}}));update=(t,e)=>new at(r=>{let{parent:s,prevElement:o,nextElement:n,getRendererByElement:a,transitions:c=[],getTransitionByType:l,eventHandler:h}=e,u=structuredClone(o),d=structuredClone(n),f=s.getChildByName(u.id);if(!f){console.warn(`Container with id ${u.id} not found`);return}d.x!==void 0&&d.x!==u.x&&(f.x=d.x),d.y!==void 0&&d.y!==u.y&&(f.y=d.y),d.rotation!==void 0&&d.rotation!==u.rotation&&(f.rotation=d.rotation*Math.PI/180);let m=[0,.5,1],g=d.anchorX??0,_=d.anchorY??0;if(!m.includes(g))throw new Error(`Invalid anchorX value: ${g}. Must be 0, 0.5, or 1`);if(!m.includes(_))throw new Error(`Invalid anchorY value: ${_}. Must be 0, 0.5, or 1`);if(d.direction){let E=d.gap||0,T,w;d.direction==="horizontal"?(T=d.children.reduce((C,G)=>C+G.width+E,0),w=d.children.reduce((C,G)=>Math.max(C,G.height||0),0)):d.direction==="vertical"&&(T=d.children.reduce((C,G)=>Math.max(C,G.width||0),0),w=d.children.reduce((C,G)=>C+G.height+E,0));let A={x:g,y:_};d.direction==="horizontal"?this.layoutChildren({element:d,anchor:A,totalWidth:T,totalHeight:w,gap:E,direction:"horizontal",scroll:d.scroll}):d.direction==="vertical"&&this.layoutChildren({element:d,anchor:A,totalWidth:T,totalHeight:w,gap:E,direction:"vertical",scroll:d.scroll});let R=f.children.find(C=>C.label===`${d.id}-container-background`);if(R){R.destroy();let C=this.createContainerGraphic(d,T,w,A);C.label=`${d.id}-container-background`,f.addChildAt(C,0)}u.scroll!==d.scroll&&this.setupScrolling({container:f,element:d,totalHeight:w,totalWidth:T,eventHandler:h,sliderRef:{}})}let y=[],{toAddElements:b,toUpdateElements:v,toDeleteElements:S}=ac(u.children,d.children);for(let E of S){let T=a(E);y.push(T.remove(t,{parent:f,element:E,transitions:c,getTransitionByType:l,getRendererByElement:a,eventHandler:h}))}for(let E of b){let T=a(E),w=d.width||0,A=d.height||0,R=g*w,C=_*A,G={...E,x:(E.x||0)+R,y:(E.y||0)+C};y.push(T.add(t,{parent:f,element:G,transitions:c,getTransitionByType:l,getRendererByElement:a,eventHandler:h}))}for(let E of v){let T=a(E.next);y.push(T.update(t,{parent:f,prevElement:E.prev,nextElement:E.next,transitions:c,getTransitionByType:l,getRendererByElement:a,eventHandler:h}))}return f.children.sort((E,T)=>{let w=d.children?.findIndex(R=>R.id===E.label),A=d.children?.findIndex(R=>R.id===T.label);return w-A}),this._currentSubscription=te(y).pipe(jt(E=>E),Ko(()=>{let{width:E,height:T}=this.getContainerDimensions(d,f),w=g*E,A=_*T;f.pivot.x=w,f.pivot.y=A,r.complete()})).subscribe({error:E=>{r.error(E),console.error("Error:",E)}}),()=>{this._currentSubscription?.unsubscribe()}});layoutChildren({element:t,anchor:e,totalWidth:r,totalHeight:s,gap:o,direction:n,scroll:a}){let c=n==="horizontal",l=c?"x":"y",h=c?"y":"x",u=c?"width":"height",d=c?"height":"width",f=c?r:s,m=c?s:r,g=c?e.x:e.y,_=c?e.y:e.x;if(!a&&t[u]!==void 0&&t[u]<f){let b=0,v=0,S=0,E=0;(t.children||[]).forEach((T,w)=>{b>0&&b+T[u]>t[u]&&(this.alignRowElements(t.children.slice(E,w),l,g,t[u]),b=0,v+=S+o,S=0,E=w),T[l]=b,T[h]=v,b+=T[u]+o,S=Math.max(S,T[d]||0)}),E<t.children.length&&this.alignRowElements(t.children.slice(E),l,g,t[u])}else{if(g===0){let b=0;(t.children||[]).forEach(v=>{v[l]=b,b+=v[u]+o})}else if(g===1){let b=-f;(t.children||[]).forEach(v=>{v[l]=b,b+=v[u]+o})}else if(g===.5){let b=-f/2;(t.children||[]).forEach(v=>{v[l]=b,b+=v[u]+o})}_===0?(t.children||[]).forEach(b=>{b[h]=0}):_===.5?(t.children||[]).forEach(b=>{b[h]=-m/2}):_===1&&(t.children||[]).forEach(b=>{b[h]=-m})}}alignRowElements(t,e,r,s){if(!t.length)return;let o=t.reduce((n,a,c)=>n+a[e==="x"?"width":"height"]+(c>0,0),0);if(r===.5){let a=(s-o)/2;t.forEach(c=>{c[e]=a,a+=c[e==="x"?"width":"height"]+0})}else if(r===1){let a=s-o;t.forEach(c=>{c[e]=a,a+=c[e==="x"?"width":"height"]+0})}}createContainerGraphic(t,e,r,s){let o=new Wt().roundRect(0,0,e,r,1).fill(t.fill?t.fill.color:"transparent");return s.x===1&&(o.x-=t.width),s.x===.5&&(o.x-=t.width/2),s.y===1&&(o.y-=t.height),s.y===.5&&(o.y-=t.height/2),o}getContainerDimensions(t,e){let r=t.width||0,s=t.height||0;if(!t.direction&&(!t.width||!t.height)&&e.children&&e.children.length>0){let o=1/0,n=-1/0,a=1/0,c=-1/0;e.children.forEach(l=>{let h=l.x||0,u=l.y||0,d=l.width||0,f=l.height||0;o=Math.min(o,h),n=Math.max(n,h+d),a=Math.min(a,u),c=Math.max(c,u+f)}),t.width||(r=n-o,(isNaN(r)||!isFinite(r))&&(r=0)),t.height||(s=c-a,(isNaN(s)||!isFinite(s))&&(s=0))}return{width:r,height:s}}setupScrolling({container:t,element:e,totalHeight:r,totalWidth:s,eventHandler:o,sliderRef:n}){let a=e.scroll&&e.height&&r>e.height,c=e.scroll&&e.width&&s>e.width;if(a||c){let l=0,h=0,u=-r+e.height,d=-s+e.width,f=new Wt().rect(0,0,e.width||s,e.height||r).fill("red");t.mask=f,t.eventMode="static",t.addChild(f),t.on("wheel",m=>{if(a&&m.deltaY!==0&&(l-m.deltaY>0||l-m.deltaY<u||(l-=m.deltaY,t.y-=m.deltaY,f.y+=m.deltaY)),c&&(m.deltaX!==0||m.shiftKey&&m.deltaY!==0)){let g=m.deltaX!==0?m.deltaX:m.deltaY;if(h-g>0||h-g<d)return;h-=g,t.x-=g,f.x+=g}})}}};var yP={linear:i=>i},bP=(i,t,e,r)=>i+(t-i)*yP[r](e);function GT(i,t,e){typeof t=="string"&&(t=t.split("."));let r=i;for(let s of t){if(r==null)return e;r=r[s]}return r===void 0?e:r}function IT(i,t,e){typeof t=="string"&&(t=t.split("."));let r=i;for(let s=0;s<t.length-1;s++){let o=t[s];o in r||(r[o]={}),r=r[o]}return r[t[t.length-1]]=e,i}var vP=(i,t)=>{let e=[],r=0,s;i.forEach(({value:n,duration:a,easing:c,relative:l},h)=>{h===0?(s=n,e.push({time:r,value:n,easing:"linear"})):a!==void 0&&c!==void 0&&(r+=a,l?s=s+n:s=n,e.push({time:r,value:s,easing:c}))});let o=0;for(let n=0;n<e.length-1;n++){let{time:a,value:c,easing:l}=e[n],{time:h,value:u}=e[n+1];if(t>=a&&t<=h){let d=(t-a)/(h-a);o=bP(c,u,d,l);break}else t>h&&(o=u)}return o};function TP(i){return Math.max.apply(null,i)}var Ad=class{static rendererName="pixi";rendererName="pixi";transitionType="keyframes";_transition=(t,e,r)=>(console.log("keyframe transition setup"),new at(s=>{console.log("keyframe transition start");let{animationProperties:o}=r,n=Array.isArray(o)?o:Object.entries(o).map(([d,f])=>({...f,property:d})),a=n.map(d=>d.keyframes.reduce((f,m)=>f+m.duration||0,0)),c=TP(a),l=0,h={};n.forEach(d=>{h[d.property]=GT(e,d.property)});let u=d=>{if(l+=d.deltaMS,l>=c){t.ticker.remove(u),s.complete();return}let f={};n.forEach(m=>{let g=[];m.initialValue!==void 0?g=[{value:m.initialValue,duration:0}]:g=[{value:h[m.property],duration:0}],g=g.concat(m.keyframes),IT(f,m.property,vP(g,l))}),n.forEach(m=>{let{property:g}=m;e&&!e.destroyed&&IT(e,g,GT(f,g))})};return t.ticker.add(u),()=>{t.ticker.remove(u),u({deltaMS:c-l})}}));add=(t,e,r)=>this._transition(t,e,r);remove=(t,e,r)=>this._transition(t,e,r)};var Cd=class{static rendererName="pixi";rendererName="pixi";rendererType="rect";add=async(t,e)=>{let{parent:r,element:s,transitions:o=[],getTransitionByType:n,eventHandler:a}=e,c=new Wt;c.label=s.id,s.x!==void 0&&(c.x=s.x),s.y!==void 0&&(c.y=s.y),s.alpha!==void 0&&(c.alpha=s.alpha),s.scaleX!==void 0&&(c.scale.x=s.scaleX),s.scaleY!==void 0&&(c.scale.y=s.scaleY),s.rotation!==void 0&&(c.rotation=s.rotation*Math.PI/180);let l=s.width,h=s.height;c.rect(0,0,l,h),c.fill(s.fill),s.anchorX!==void 0&&(c.pivot.x=l*s.anchorX),s.anchorY!==void 0&&(c.pivot.y=h*s.anchorY),(s.clickEventName||s.rightClickEventName)&&a&&(c.eventMode="static",c.on("pointerup",d=>{d.button===0?a(s.clickEventName):d.button===2&&a(s.rightClickEventName)})),s.wheelEventName&&a&&(c.eventMode="static",c.on("wheel",d=>{a(s.wheelEventName,{deltaY:d.deltaY})}));let u=[];for(let d of o)if(d.elementId===s.id&&d.event===Vt.Add){let f=n(d.type);if(!f)throw new Error(`Transition class not found for type ${d.type}`);u.push(f.add(t,c,d))}r.addChild(c),await Promise.all(u)};remove=async(t,e)=>{let{parent:r,element:s}=e,o=r.getChildByName(s.id);if(!o)throw new Error(`Sprite with id ${s.id} not found`);o.destroy()};update=async(t,e)=>{let{parent:r,prevElement:s,nextElement:o,transitions:n=[],getTransitionByType:a,eventHandler:c}=e;if(!r.getChildByName(s.id))throw new Error(`Container with id ${s.id} not found`);JSON.stringify(s)!==JSON.stringify(o)&&await Promise.all([this.remove(t,{parent:r,element:s,transitions:n,getTransitionByType:a,eventHandler:c}),this.add(t,{parent:r,element:o,transitions:n,getTransitionByType:a,eventHandler:c})])}};var Md=class extends dr{static rendererName="pixi";rendererName="pixi";rendererType="slider";add=async(t,{parent:e,element:r,transitions:s=[],getTransitionByType:o,eventHandler:n,ref:a})=>{let{direction:c,idleThumb:l,hoverThumb:h,idleBar:u,hoverBar:d,dragEndEventName:f,dragEventName:m,dragEventPayload:g,initialValue:_}=r,y={horizontal:{axis:"x",size:"width"},vertical:{axis:"y",size:"height"}},b=y[c].axis,v=y[c].size,S=M.from(l),E=M.from(h),T=M.from(u),w=M.from(d),A=new Lt({texture:T,anchor:{x:0,y:0}});A.label=r.id;let R=A[v];A.x=r.x||0,A.y=r.y||0;let C=new Lt({texture:S,anchor:{x:.5,y:.5}});if(C.y=A.height/2,C.x=A.width/2,C.eventMode="static",C.cursor="pointer",A.eventMode="static",A.cursor="pointer",C.on("pointerdown",Y).on("pointerup",mt).on("pointerupoutside",mt),A.on("pointerdown",G).on("pointerup",L).on("pointerupoutside",L),A.addChild(C),_!==void 0){let F=C[v]/2;C[b]=_/100*(R-C[v])+F}function G(F){C.texture=E,A.texture=w,Xt(F),t.stage.eventMode="static",t.stage.addEventListener("pointermove",Xt)}function L(F){C.texture=S,A.texture=T,Xt(F),t.stage.eventMode="auto",t.stage.removeEventListener("pointermove",Xt)}function Y(F){F.stopPropagation(),C.texture=E,A.texture=w,t.stage.eventMode="static",t.stage.addEventListener("pointermove",Xt)}function mt(F){if(C.texture=S,A.texture=T,t.stage.eventMode="auto",t.stage.removeEventListener("pointermove",Xt),f){let Te=A.toLocal(F.global)[b],q=C[v]/2;C[b]=Math.max(0+q,Math.min(Te,R-q));let ee=Math.floor((C[b]-q)/(R-C[v])*100),De=JSON.stringify(g);n&&n(f,JSON.parse(De.replace('"{{ value }}"',String(ee))))}}function Xt(F){let Te=A.toLocal(F.global)[b],q=C[v]/2;C[b]=Math.max(0+q,Math.min(Te,R-q));let ee=Math.floor((C[b]-q)/(R-C[v])*100);if(m){let De=JSON.stringify(g);n&&n(m,JSON.parse(De.replace('"{{ value }}"',String(ee))))}return ee}a&&(a.current={updateValue:F=>{let Te=C[v]/2;C[b]=F/100*(R-C[v])+Te}});let N=[];for(let F of s)if(F.elementId===r.id&&F.event===Vt.Add){let Te=o(F.type);if(!Te)throw new Error(`Transition class not found for type ${F.type}`);N.push(Te.add(t,A,F))}e.addChild(A),await Promise.all(N)};remove=async(t,e)=>{let{parent:r,element:s,transitions:o=[],getTransitionByType:n}=e,a=r.getChildByName(s.id);if(!a){console.warn(`Sprite with id ${s.id} not found`);return}let c=[];for(let l of o)if(l.elementId===s.id&&l.event===Vt.Remove){let h=n(l.type);if(!h)throw new Error(`Transition class not found for type ${l.type}`);c.push(h.remove(t,a,l))}await Promise.all(c),a.destroy()};update=async(t,{parent:e,prevElement:r,nextElement:s,transitions:o,getTransitionByType:n,eventHandler:a})=>{if(!e.getChildByName(r.id)){console.warn(`Slider with id ${r.id} not found`,{parent:e});return}JSON.stringify(r)!==JSON.stringify(s)&&await Promise.all([this.remove(t,{parent:e,element:r,transitions:o,getTransitionByType:n,eventHandler:a}),this.add(t,{parent:e,element:s,transitions:o,getTransitionByType:n,eventHandler:a})])}};var Bd=class extends dr{static rendererName="pixi";rendererName="pixi";rendererType="audio";add=async(t,{parent:e,element:r,transitions:s=[],getTransitionByType:o})=>{r.delay?setTimeout(()=>{t.audioStage.add({id:r.id,url:r.url,loop:r.loop??!1,volume:r.volume??1})},r.delay):t.audioStage.add({id:r.id,url:r.url,loop:r.loop??!1,volume:r.volume??1})};remove=async(t,e)=>{let{element:r}=e;t.audioStage.remove(r.id)};update=async(t,{parent:e,prevElement:r,nextElement:s,transitions:o,getTransitionByType:n})=>{if(r.url!==s.url||r.volume!==s.volume){let a=t.audioStage.getById(r.id);a&&(a.url=s.url,a.volume=s.volume??1)}}};var Rd=class{constructor(){this.cache=new Map}async load(t){let e=[];for(let[r,s]of Object.entries(t))this.cache.has(r)||e.push([r,s]);e.length>0&&await Promise.all(e.map(async([r,s])=>{let a={buffer:await(await fetch(s.url)).arrayBuffer(),type:s.type};this.cache.set(r,a)}))}getBufferMap(){let t={};for(let[e,r]of this.cache.entries())t[e]=r;return t}clear(){this.cache.clear()}size(){return this.cache.size}has(t){return this.cache.has(t)}},SP=()=>new Rd;var m7=RT;export{Bd as AudioPlugin,Pd as ContainerRendererPlugin,Ad as KeyframeTransitionPlugin,Cd as RectRendererPlugin,Md as SliderRendererPlugin,Sd as SpriteRendererPlugin,wd as TextRendererPlugin,Ed as TextRevealingRendererPlugin,SP as createAssetBufferManager,m7 as default};
|
|
1142
|
+
`):"",this.name="UnsubscriptionError",this.errors=e}});function gd(i,t){if(i){var e=i.indexOf(t);0<=e&&i.splice(e,1)}}var uc=function(){function i(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return i.prototype.unsubscribe=function(){var t,e,r,s,o;if(!this.closed){this.closed=!0;var n=this._parentage;if(n)if(this._parentage=null,Array.isArray(n))try{for(var a=Lr(n),c=a.next();!c.done;c=a.next()){var l=c.value;l.remove(this)}}catch(g){t={error:g}}finally{try{c&&!c.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}else n.remove(this);var h=this.initialTeardown;if(et(h))try{h()}catch(g){o=g instanceof hc?g.errors:[g]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var d=Lr(u),f=d.next();!f.done;f=d.next()){var m=f.value;try{fT(m)}catch(g){o=o??[],g instanceof hc?o=Xi(Xi([],ji(o)),ji(g.errors)):o.push(g)}}}catch(g){r={error:g}}finally{try{f&&!f.done&&(s=d.return)&&s.call(d)}finally{if(r)throw r.error}}}if(o)throw new hc(o)}},i.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)fT(t);else{if(t instanceof i){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},i.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},i.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},i.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&gd(e,t)},i.prototype.remove=function(t){var e=this._finalizers;e&&gd(e,t),t instanceof i&&t._removeParent(this)},i.EMPTY=function(){var t=new i;return t.closed=!0,t}(),i}();var $Y=uc.EMPTY;function dc(i){return i instanceof uc||i&&"closed"in i&&et(i.remove)&&et(i.add)&&et(i.unsubscribe)}function fT(i){et(i)?i():i.unsubscribe()}var ve={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var $i={setTimeout:function(i,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];var s=$i.delegate;return s?.setTimeout?s.setTimeout.apply(s,Xi([i,t],ji(e))):setTimeout.apply(void 0,Xi([i,t],ji(e)))},clearTimeout:function(i){var t=$i.delegate;return(t?.clearTimeout||clearTimeout)(i)},delegate:void 0};function fc(i){$i.setTimeout(function(){var t=ve.onUnhandledError;if(t)t(i);else throw i})}function xd(){}var pT=function(){return _d("C",void 0,void 0)}();function mT(i){return _d("E",void 0,i)}function gT(i){return _d("N",i,void 0)}function _d(i,t,e){return{kind:i,value:t,error:e}}var Hr=null;function xT(i){if(ve.useDeprecatedSynchronousErrorHandling){var t=!Hr;if(t&&(Hr={errorThrown:!1,error:null}),i(),t){var e=Hr,r=e.errorThrown,s=e.error;if(Hr=null,r)throw s}}else i()}function _T(i){ve.useDeprecatedSynchronousErrorHandling&&Hr&&(Hr.errorThrown=!0,Hr.error=i)}var Yo=function(i){$o(t,i);function t(e){var r=i.call(this)||this;return r.isStopped=!1,e?(r.destination=e,dc(e)&&e.add(r)):r.destination=nP,r}return t.create=function(e,r,s){return new mc(e,r,s)},t.prototype.next=function(e){this.isStopped?bd(gT(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?bd(mT(e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?bd(pT,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,i.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(uc);var iP=Function.prototype.bind;function yd(i,t){return iP.call(i,t)}var sP=function(){function i(t){this.partialObserver=t}return i.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(r){pc(r)}},i.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){pc(r)}else pc(t)},i.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){pc(e)}},i}(),mc=function(i){$o(t,i);function t(e,r,s){var o=i.call(this)||this,n;if(et(e)||!e)n={next:e??void 0,error:r??void 0,complete:s??void 0};else{var a;o&&ve.useDeprecatedNextContext?(a=Object.create(e),a.unsubscribe=function(){return o.unsubscribe()},n={next:e.next&&yd(e.next,a),error:e.error&&yd(e.error,a),complete:e.complete&&yd(e.complete,a)}):n=e}return o.destination=new sP(n),o}return t}(Yo);function pc(i){ve.useDeprecatedSynchronousErrorHandling?_T(i):fc(i)}function oP(i){throw i}function bd(i,t){var e=ve.onStoppedNotification;e&&$i.setTimeout(function(){return e(i,t)})}var nP={closed:!0,next:xd,error:oP,complete:xd};var Yi=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function yT(i){return i}function bT(i){return i.length===0?yT:i.length===1?i[0]:function(e){return i.reduce(function(r,s){return s(r)},e)}}var at=function(){function i(t){t&&(this._subscribe=t)}return i.prototype.lift=function(t){var e=new i;return e.source=this,e.operator=t,e},i.prototype.subscribe=function(t,e,r){var s=this,o=cP(t)?t:new mc(t,e,r);return xT(function(){var n=s,a=n.operator,c=n.source;o.add(a?a.call(o,c):c?s._subscribe(o):s._trySubscribe(o))}),o},i.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},i.prototype.forEach=function(t,e){var r=this;return e=vT(e),new e(function(s,o){var n=new mc({next:function(a){try{t(a)}catch(c){o(c),n.unsubscribe()}},error:o,complete:s});r.subscribe(n)})},i.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},i.prototype[Yi]=function(){return this},i.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return bT(t)(this)},i.prototype.toPromise=function(t){var e=this;return t=vT(t),new t(function(r,s){var o;e.subscribe(function(n){return o=n},function(n){return s(n)},function(){return r(o)})})},i.create=function(t){return new i(t)},i}();function vT(i){var t;return(t=i??ve.Promise)!==null&&t!==void 0?t:Promise}function aP(i){return i&&et(i.next)&&et(i.error)&&et(i.complete)}function cP(i){return i&&i instanceof Yo||aP(i)&&dc(i)}function lP(i){return et(i?.lift)}function Fe(i){return function(t){if(lP(t))return t.lift(function(e){try{return i(e,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function Wr(i,t,e,r,s){return new hP(i,t,e,r,s)}var hP=function(i){$o(t,i);function t(e,r,s,o,n,a){var c=i.call(this,e)||this;return c.onFinalize=n,c.shouldUnsubscribe=a,c._next=r?function(l){try{r(l)}catch(h){e.error(h)}}:i.prototype._next,c._error=o?function(l){try{o(l)}catch(h){e.error(h)}finally{this.unsubscribe()}}:i.prototype._error,c._complete=s?function(){try{s()}catch(l){e.error(l)}finally{this.unsubscribe()}}:i.prototype._complete,c}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;i.prototype.unsubscribe.call(this),!r&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t}(Yo);var gc=function(i){return i&&typeof i.length=="number"&&typeof i!="function"};function xc(i){return et(i?.then)}function _c(i){return et(i[Yi])}function yc(i){return Symbol.asyncIterator&&et(i?.[Symbol.asyncIterator])}function bc(i){return new TypeError("You provided "+(i!==null&&typeof i=="object"?"an invalid object":"'"+i+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function uP(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var vc=uP();function Tc(i){return et(i?.[vc])}function Sc(i){return hT(this,arguments,function(){var e,r,s,o;return lc(this,function(n){switch(n.label){case 0:e=i.getReader(),n.label=1;case 1:n.trys.push([1,,9,10]),n.label=2;case 2:return[4,Nr(e.read())];case 3:return r=n.sent(),s=r.value,o=r.done,o?[4,Nr(void 0)]:[3,5];case 4:return[2,n.sent()];case 5:return[4,Nr(s)];case 6:return[4,n.sent()];case 7:return n.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function wc(i){return et(i?.getReader)}function Ue(i){if(i instanceof at)return i;if(i!=null){if(_c(i))return dP(i);if(gc(i))return fP(i);if(xc(i))return pP(i);if(yc(i))return TT(i);if(Tc(i))return mP(i);if(wc(i))return gP(i)}throw bc(i)}function dP(i){return new at(function(t){var e=i[Yi]();if(et(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function fP(i){return new at(function(t){for(var e=0;e<i.length&&!t.closed;e++)t.next(i[e]);t.complete()})}function pP(i){return new at(function(t){i.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,fc)})}function mP(i){return new at(function(t){var e,r;try{for(var s=Lr(i),o=s.next();!o.done;o=s.next()){var n=o.value;if(t.next(n),t.closed)return}}catch(a){e={error:a}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}t.complete()})}function TT(i){return new at(function(t){xP(i,t).catch(function(e){return t.error(e)})})}function gP(i){return TT(Sc(i))}function xP(i,t){var e,r,s,o;return lT(this,void 0,void 0,function(){var n,a;return lc(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),e=uT(i),c.label=1;case 1:return[4,e.next()];case 2:if(r=c.sent(),!!r.done)return[3,4];if(n=r.value,t.next(n),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),s={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),r&&!r.done&&(o=e.return)?[4,o.call(e)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function fe(i,t,e,r,s){r===void 0&&(r=0),s===void 0&&(s=!1);var o=t.schedule(function(){e(),s?i.add(this.schedule(null,r)):this.unsubscribe()},r);if(i.add(o),!s)return o}function Ec(i,t){return t===void 0&&(t=0),Fe(function(e,r){e.subscribe(Wr(r,function(s){return fe(r,i,function(){return r.next(s)},t)},function(){return fe(r,i,function(){return r.complete()},t)},function(s){return fe(r,i,function(){return r.error(s)},t)}))})}function Pc(i,t){return t===void 0&&(t=0),Fe(function(e,r){r.add(i.schedule(function(){return e.subscribe(r)},t))})}function ST(i,t){return Ue(i).pipe(Pc(t),Ec(t))}function wT(i,t){return Ue(i).pipe(Pc(t),Ec(t))}function ET(i,t){return new at(function(e){var r=0;return t.schedule(function(){r===i.length?e.complete():(e.next(i[r++]),e.closed||this.schedule())})})}function PT(i,t){return new at(function(e){var r;return fe(e,t,function(){r=i[vc](),fe(e,t,function(){var s,o,n;try{s=r.next(),o=s.value,n=s.done}catch(a){e.error(a);return}n?e.complete():e.next(o)},0,!0)}),function(){return et(r?.return)&&r.return()}})}function Ac(i,t){if(!i)throw new Error("Iterable cannot be null");return new at(function(e){fe(e,t,function(){var r=i[Symbol.asyncIterator]();fe(e,t,function(){r.next().then(function(s){s.done?e.complete():e.next(s.value)})},0,!0)})})}function AT(i,t){return Ac(Sc(i),t)}function CT(i,t){if(i!=null){if(_c(i))return ST(i,t);if(gc(i))return ET(i,t);if(xc(i))return wT(i,t);if(yc(i))return Ac(i,t);if(Tc(i))return PT(i,t);if(wc(i))return AT(i,t)}throw bc(i)}function te(i,t){return t?CT(i,t):Ue(i)}function MT(i,t){return Fe(function(e,r){var s=0;e.subscribe(Wr(r,function(o){r.next(i.call(t,o,s++))}))})}function BT(i,t,e,r,s,o,n,a){var c=[],l=0,h=0,u=!1,d=function(){u&&!c.length&&!l&&t.complete()},f=function(g){return l<r?m(g):c.push(g)},m=function(g){o&&t.next(g),l++;var _=!1;Ue(e(g,h++)).subscribe(Wr(t,function(y){s?.(y),o?f(y):t.next(y)},function(){_=!0},void 0,function(){if(_)try{l--;for(var y=function(){var b=c.shift();n?fe(t,n,function(){return m(b)}):m(b)};c.length&&l<r;)y();d()}catch(b){t.error(b)}}))};return i.subscribe(Wr(t,f,function(){u=!0,d()})),function(){a?.()}}function jt(i,t,e){return e===void 0&&(e=1/0),et(t)?jt(function(r,s){return MT(function(o,n){return t(r,o,s,n)})(Ue(i(r,s)))},e):(typeof t=="number"&&(e=t),Fe(function(r,s){return BT(r,s,i,e)}))}function Ko(i){return Fe(function(t,e){try{t.subscribe(e)}finally{e.add(i)}})}var _P=i=>i.split("/").pop(),vd=class{name="advancedBufferLoader";priority=2;constructor(t){this.bufferMap=t}test(t){return!0}async load(t){let e=t.startsWith("file:")?t:_P(t),r=this.bufferMap[e];if(!r)throw new Error(`Buffer not found for key: ${e}`);return{data:r.buffer,type:r.type,metadata:null}}async testParse(t){return!0}async parse(t){if(t instanceof M)return t;let e=new Blob([t.data],{type:t.type}),r=await createImageBitmap(e);return new M.from(r)}async unload(t){t.destroy(!0)}},Td=class i extends nc{static rendererName="pixi";_app;_audioStage=new cc;_state={elements:[]};_eventHandler;_plugins;_currentSubscription;_advancedLoader;get canvas(){return this._app.canvas}init=async t=>{let{eventHandler:e,plugins:r,width:s,height:o,backgroundColor:n}=t;for(let c of r)if(c.rendererName!==i.rendererName)throw new Error("Plugin does not match renderer name");this._plugins=r,this._eventHandler=e,this._app=new Za,this._app.audioStage=this._audioStage,await this._app.init({width:s,height:o,backgroundColor:n});let a=new Wt;return a.rect(0,0,s,o),a.fill(n||0),this._app.stage.addChild(a),this._app.stage.width=s,this._app.stage.height=o,this._app.ticker.add(this._app.audioStage.tick),this};destroy=()=>{this._app.audioStage.destroy(),this._app.destroy()};_classifyAsset=t=>t?t.startsWith("audio/")?"audio":t.startsWith("font/")||["application/font-woff","application/font-woff2","application/x-font-ttf","application/x-font-otf"].includes(t)?"font":"texture":"texture";loadAssets=async t=>{if(!t)throw new Error("assetBufferMap is required");let e={audio:{},font:{},texture:{}};for(let[s,o]of Object.entries(t)){let n=this._classifyAsset(o.type);e[n][s]=o}await Promise.all(Object.entries(e.audio).map(([s,o])=>Vi.load(s,o.buffer))),await Promise.all(Object.entries(e.font).map(async([s,o])=>{let n=new Blob([o.buffer],{type:o.type}),a=URL.createObjectURL(n),c=new FontFace(s,`url(${a})`);try{await c.load(),document.fonts.add(c),console.log(`Font loaded successfully: ${s}`)}catch(l){console.error(`Failed to load font ${s}:`,l)}finally{URL.revokeObjectURL(a)}})),this._advancedLoader?Object.assign(this._advancedLoader.bufferMap,e.texture):(this._advancedLoader=new vd(e.texture),be.loader.parsers.length=0,be.reset(),I.add({name:"advanced-buffer-loader",extension:x.Asset,priority:Et.High,loader:this._advancedLoader}),typeof be.registerPlugin=="function"&&be.registerPlugin(this._advancedLoader));let r=Object.keys(e.texture);return Promise.all(r.map(s=>be.load(s)))};loadAudioAssets=async t=>Promise.all(t.map(async e=>{let s=await(await fetch(e)).arrayBuffer();return Vi.load(e,s)}));updatedBackgroundColor=t=>{this._app.renderer.background.color=t};render=t=>{this._render(this._app,this._app.stage,this._state,t,this._eventHandler),this._state=t};_getRendererByElement=t=>{for(let e of this._plugins)if(e.rendererType===t.type)return e;throw new Error(`No renderer found for element type: ${t.type}`)};_getTransitionByType=t=>{for(let e of this._plugins)if(e.transitionType===t)return e;throw new Error(`No transition found for transition type: ${t}`)};_render=async(t,e,r,s,o)=>{let n=Date.now(),{toAddElements:a,toUpdateElements:c,toDeleteElements:l}=ac(r.elements,s.elements),h=[];for(let u of l){let d=this._getRendererByElement(u);h.push(d.remove(t,{parent:e,element:u,transitions:s.transitions,getRendererByElement:this._getRendererByElement,getTransitionByType:this._getTransitionByType,eventHandler:o}))}for(let u of a){let d=this._getRendererByElement(u);h.push(d.add(t,{parent:e,element:u,getRendererByElement:this._getRendererByElement,transitions:s.transitions,getTransitionByType:this._getTransitionByType,eventHandler:o}))}for(let u of c){let d=this._getRendererByElement(u.next);h.push(d.update(t,{parent:e,prevElement:u.prev,nextElement:u.next,getRendererByElement:this._getRendererByElement,transitions:s.transitions,getTransitionByType:this._getTransitionByType,eventHandler:o}))}t.stage.children.sort((u,d)=>{let f=s.elements.findIndex(g=>g.id===u.label),m=s.elements.findIndex(g=>g.id===d.label);return f-m}),this._currentSubscription&&(this._currentSubscription.closed||this._currentSubscription.unsubscribe()),this._currentSubscription=te(h).pipe(jt(u=>u),Ko(()=>{o&&o("completed",{id:s.id,diffTime:Date.now()-n}),this._currentSubscription=void 0})).subscribe({error:u=>{console.error("Error:",u)}})}},RT=Td;var Sd=class extends dr{static rendererName="pixi";rendererName="pixi";rendererType="sprite";add=(t,e)=>new at(r=>{let{parent:s,element:o,transitions:n=[],getTransitionByType:a,eventHandler:c}=e,l=M.from(o.url),h,u,d=o.scaleX??1,f=o.scaleY??1;o.hoverUrl&&(h=M.from(o.hoverUrl)),o.clickUrl&&(u=M.from(o.clickUrl));let m=new Lt(l);m.label=o.id,(o.eventName||o.hoverUrl||o.clickUrl)&&(m.cursor="pointer",m.eventMode="static"),o.anchorX!==void 0&&(m.pivot.x=m.width*o.anchorX),o.anchorY!==void 0&&(m.pivot.y=m.height*o.anchorY),o.rotation!==void 0&&(m.rotation=o.rotation*Math.PI/180),o.x!==void 0&&(m.x=o.x),o.y!==void 0&&(m.y=o.y),o.width!==void 0?m.width=o.width*d:m.width*=d,o.height!==void 0?m.height=o.height*f:m.height*=f,o.zIndex!==void 0&&(m.zIndex=o.zIndex),o.alpha!==void 0&&(m.alpha=o.alpha),m.on("pointerup",()=>{m.texture=l}).on("pointerupoutside",()=>{m.texture=l}).on("pointerleave",()=>{m.texture=l}),u&&m.on("pointerdown",()=>{m.texture=u}),h&&m.on("pointerenter",()=>{m.texture=h}),m.on("pointerup",y=>{y.stopPropagation();let b=y.button;b===0?c&&c(o.eventName,o.eventPayload):b===2&&(o.rightClickEventName&&c?c(o.rightClickEventName):t.stage.emit("rightclick",event))});let g=[];for(let y of n)if(y.elementId===o.id&&y.event===Vt.Add){let b=a(y.type);if(!b)throw new Error(`Transition class not found for type ${y.type}`);g.push(b.add(t,m,y))}s.addChild(m);let _=te(g).pipe(jt(y=>y)).subscribe({error:y=>{console.error("Error:",y)},complete:()=>r.complete()});return()=>{_.unsubscribe()}});remove=(t,e)=>new at(r=>{let{parent:s,element:o,transitions:n=[],getTransitionByType:a}=e,c=s.getChildByName(o.id);if(!c)throw new Error(`Sprite with id ${o.id} not found`);let l=[];for(let u of n)if(u.elementId===o.id&&u.event===Vt.Remove){let d=a(u.type);if(!d)throw new Error(`Transition class not found for type ${u.type}`);l.push(d.remove(t,c,u))}let h=te(l).pipe(jt(u=>u)).subscribe({error:u=>{console.error("Error:",u)},complete:()=>{r.complete(),c&&c.destroy()}});return()=>{h.unsubscribe(),c&&c.destroy()}});update=(t,{parent:e,prevElement:r,nextElement:s,transitions:o,getTransitionByType:n,eventHandler:a})=>new at(c=>{let l=e.getChildByName(r.id);if(!l)throw new Error(`Sprite with id ${r.id} not found`);if(JSON.stringify(r)!==JSON.stringify(s)){let h=[this.add(t,{parent:e,element:s,transitions:o,getTransitionByType:n,eventHandler:a}),this.remove(t,{parent:e,element:r,transitions:o,getTransitionByType:n})],u=te(h).pipe(jt(d=>d)).subscribe({error:d=>{console.error("Error:",d)},complete:()=>c.complete()});return()=>{u.unsubscribe()}}else s.x!==void 0&&(l.x=s.x),s.y!==void 0&&(l.y=s.y),s.width!==void 0&&s.width!==r.width&&(l.width=s.width),s.height!==void 0&&s.height!==r.height&&(l.height=s.height),s.alpha!==void 0&&s.alpha!==r.alpha&&(l.alpha=s.alpha),c.complete();return()=>{}})};var Cc=i=>new St({wordWrap:i.wordWrap||!0,breakWords:i.breakWords||!1,align:i.align,fill:i.fill,fontSize:i.fontSize,lineHeight:i.lineHeight,wordWrapWidth:i.wordWrapWidth,fontFamily:i.fontFamily||"Roboto",stroke:i.strokeColor?{color:i.strokeColor,width:i.strokeWidth}:void 0}),wd=class{static rendererName="pixi";rendererName="pixi";rendererType="text";add=(t,e)=>new at(r=>{let{parent:s,element:o,transitions:n=[],getTransitionByType:a,eventHandler:c}=e,l=Cc(o.style),h=new ur({text:o.text,style:l}),u;o.hoverStyle&&(u=Cc(o.hoverStyle));let d;if(o.clickedStyle&&(d=Cc(o.clickedStyle)),(o.eventName||o.clickedStyle||o.hoverStyle)&&(h.cursor="pointer",h.eventMode="static"),h.label=o.id,o.x!==void 0&&(h.x=o.x),o.y!==void 0&&(h.y=o.y),o.anchorX!==void 0&&(h.anchor.x=o.anchorX),o.anchorY!==void 0&&(h.anchor.y=o.anchorY),o.anchorX!==void 0||o.anchorY!==void 0){let g=h.getLocalBounds();h.hitArea=new z(-g.width*h.anchor.x,-g.height*h.anchor.y,g.width,g.height)}h.on("pointerupoutside",()=>{h.style=l}).on("pointerup",()=>{h.style=l}).on("pointerleave",()=>{h.style=l}),h.on("pointerup",g=>{o.clickSoundUrl&&t.soundStage&&t.soundStage.add({id:`${o.id}-click-${Math.random()}`,url:o.clickSoundUrl,loop:!1,volume:o.clickSoundVolume??50/100}),g.stopPropagation(),c&&c(o.eventName,o.eventPayload)}),d&&h.on("pointerdown",()=>{h.style=d}),u&&h.on("pointerenter",()=>{h.style=u,o.hoverSoundUrl&&t.soundStage&&o.hoverSoundVolume!==void 0&&t.soundStage.add({id:`${o.id}-hover-${Math.random()}`,url:o.hoverSoundUrl,loop:!1,volume:o.hoverSoundVolume/100})});let f=[];for(let g of n)if(g.elementId===o.id&&g.event===Vt.Add){let _=a(g.type);if(!_)throw new Error(`Transition class not found for type ${g.type}`);f.push(_.add(t,h,g))}s.addChild(h);let m=te(f).pipe(jt(g=>g)).subscribe({error:g=>{console.error("Error:",g),r.error(g)},complete:()=>r.complete()});return()=>{m.unsubscribe()}});remove=(t,e)=>new at(r=>{let{parent:s,element:o,transitions:n=[],getTransitionByType:a}=e,c=s.getChildByName(o.id);if(!c){console.warn(`Text with id ${o.id} not found`),r.complete();return}let l=[];for(let u of n)if(u.elementId===o.id&&u.event===Vt.Remove){let d=a(u.type);if(!d)throw new Error(`Transition class not found for type ${u.type}`);l.push(d.remove(t,c,u))}let h=te(l).pipe(jt(u=>u)).subscribe({error:u=>{console.error("Error:",u),r.error(u)},complete:()=>{c.destroy(),r.complete()}});return()=>{h.unsubscribe(),c&&c.destroy()}});update=(t,e)=>new at(r=>{let{parent:s,prevElement:o,nextElement:n,transitions:a,getTransitionByType:c,eventHandler:l}=e,h=s.getChildByName(o.id);if(!h){console.warn(`Text with id ${o.id} not found`),r.complete();return}if(JSON.stringify(o)!==JSON.stringify(n)){let u=[this.add(t,{parent:s,element:n,transitions:a,getTransitionByType:c,eventHandler:l}),this.remove(t,{parent:s,element:o,transitions:a,getTransitionByType:c})],d=te(u).pipe(jt(f=>f)).subscribe({error:f=>{console.error("Error:",f),r.error(f)},complete:()=>r.complete()});return()=>{d.unsubscribe()}}else o.text!==n.text&&(h.text=n.text),JSON.stringify(o.style)!==JSON.stringify(n.style)&&(h.style=Cc(n?.style)),n.x!==void 0&&(h.x=n.x),n.y!==void 0&&(h.y=n.y),r.complete();return()=>{}})};var Ki=(i,t=!1)=>new St({wordWrap:i.wordWrap||!0,breakWords:t,align:i.align,fill:i.fill,fontSize:i.fontSize,lineHeight:i.lineHeight,wordWrapWidth:i.wordWrapWidth,fontFamily:i.fontFamily||"Roboto",stroke:i.strokeColor?{color:i.strokeColor,width:i.strokeWidth}:void 0}),Ed=class{static rendererName="pixi";rendererName="pixi";rendererType="text-revealing";add=async(t,{parent:e,element:r})=>{let s=Ki(r.style,r.text),o=new ur({text:"",style:s});o.label=r.id,o.text_id=r.text;let n=new nt;r.x!==void 0&&(n.x=r.x),r.y!==void 0&&(n.y=r.y),n.addChild(o),n.label=r.id,e.addChild(n);let a=r.style.wordWrapWidth||500,c=r.text?[{text:r.text,style:r.style}]:r.segments,l=[],h=[],u=0,d=0,f=0;for(;;){let T=c[0];if(!T){h.length>0&&l.push({lineParts:h,y:d});break}if(d>1e4)break;let w={...T.style,wordWrapWidth:a-u},A=At.measureText(T.text,Ki(w));A.lineHeight>f&&(f=A.lineHeight);let R=At.measureText("a",Ki(w)),G=At.measureText("a a",Ki(w)).width-R.width*2;if(A.lineWidths[0]+u>a){u=0,l.push({lineParts:h,y:d}),d+=f,f=0,h=[];continue}let L=A.lines[0],Y=A.lines.slice(1).join(" "),mt={text:L,style:w,x:u,y:0};if(h.push(mt),Y&&Y.length>0?T.text=Y:c.shift(),!(!L||L.length===0)){if(T.furigana){let Xt=At.measureText(T.furigana.text,Ki(T.furigana.style)),N={text:T.furigana.text,style:T.furigana.style,x:u+(A.width-Xt.width)/2,y:-10};h.push(N)}u+=A.lineWidths[0]+G}}l.forEach(T=>{let w=new nt;w.y=T.y,w.alpha=0,T.lineParts.forEach(A=>{let R=new ur({text:A.text,style:Ki(A.style),x:A.x,y:A.y});w.addChild(R)}),n.addChild(w)});let m=new Wt,g=1e3,_=a/2,y=a/2;m.fill({color:16777215,alpha:1}),m.rect(0,0,_,g);for(let T=0;T<y;T++)m.fill({color:16777215,alpha:1-T/y}),m.rect(_+T,0,_+1,g);let b=t.renderer.generateTexture(m),v=new Lt(b);v.x=-1.35*_-y,t.stage.addChild(v);let S=0,E=1;if(l.length!==0){if(r.displaySpeed===100||r.hasEnded){n.children.forEach(T=>{t.stage.removeChild(v),T.mask=null,T.alpha=1});return}await new Promise(T=>{let w=A=>{if(E>n.children.length){T();return}n.getChildAt(E).mask||(n.getChildAt(E).mask=v,n.getChildAt(E).alpha=1),S+=A.deltaMS;let C=(r.displaySpeed||50)/1e3;v.x+=C*S,v.x>=0&&(n.getChildAt(E).mask=null,v.x=-1.35*_-y,E=E+1,S=0,E>=n.children.length&&(n.getChildAt(E-1).mask=null,t.ticker.remove(w),T()))};t.ticker.add(w)})}};remove=async(t,e)=>{let{parent:r,element:s,transitions:o=[],getTransitionByType:n}=e,a=r.getChildByName(s.id);if(!a){console.warn(`Text with id ${s.id} not found`,{parent:r});return}let c=[];for(let l of o)if(l.elementId===s.id&&l.event===Vt.Remove){let h=n(l.type);if(!h)throw new Error(`Transition class not found for type ${l.type}`);c.push(h.remove(t,a,l))}await Promise.all(c),a.destroy()};update=async(t,e)=>{let{parent:r,prevElement:s,nextElement:o}=e;if(!r.getChildByName(s.id)){console.warn(`Text with id ${s.id} not found`,{parent:r});return}await this.remove(t,{parent:r,element:s}),await this.add(t,{parent:r,element:o})}};var Pd=class{static rendererName="pixi";rendererName="pixi";rendererType="container";add=(t,e)=>new at(r=>{let{parent:s,element:o,transitions:n=[],getTransitionByType:a,getRendererByElement:c,eventHandler:l}=e,h=structuredClone(o),u=new nt;u.label=h.id;let d={};h.x!==void 0&&(typeof h.x=="string"&&h.x.endsWith("%")?u.x=Number(h.x.replace("%",""))*t.screen.width/100:u.x=h.x),h.y!==void 0&&(typeof h.y=="string"&&h.y.endsWith("%")?u.y=Number(h.y.replace("%",""))*t.screen.height/100:u.y=h.y),h.scaleX!==void 0&&(u.scale.x=h.scaleX),h.scaleY!==void 0&&(u.scale.y=h.scaleY),h.zIndex!==void 0&&(u.zIndex=h.zIndex),h.rotation!==void 0&&(u.rotation=h.rotation*Math.PI/180),h.propagateEvents&&(u.eventMode="static",["pointerup","pointerupoutside","pointerleave","pointerdown","pointerenter"].forEach(E=>{u.on(E,T=>{T.stopPropagation();for(let w of u.children)w.emit(E)})}));let f=h.gap||0,m=new Wt().roundRect(0,0,h.width||0,h.height||0,1).fill(h.fill?h.fill.color:"transparent"),g=[0,.5,1],_=h.anchorX??0,y=h.anchorY??0;if(!g.includes(_))throw new Error(`Invalid anchorX value: ${_}. Must be 0, 0.5, or 1`);if(!g.includes(y))throw new Error(`Invalid anchorY value: ${y}. Must be 0, 0.5, or 1`);if(h.direction){let E,T;h.direction==="horizontal"?(E=h.children.reduce((A,R)=>A+R.width+f,0),T=h.children.reduce((A,R)=>Math.max(A,R.height||0),0)):h.direction==="vertical"&&(E=h.children.reduce((A,R)=>Math.max(A,R.width||0),0),T=h.children.reduce((A,R)=>A+R.height+f,0));let w={x:_,y};h.direction==="horizontal"?this.layoutChildren({element:h,anchor:w,totalWidth:E,totalHeight:T,gap:f,direction:"horizontal",scroll:h.scroll}):h.direction==="vertical"&&this.layoutChildren({element:h,anchor:w,totalWidth:E,totalHeight:T,gap:f,direction:"vertical",scroll:h.scroll}),this.setupScrolling({container:u,element:h,totalHeight:T,totalWidth:E,eventHandler:l,sliderRef:d}),m=this.createContainerGraphic(h,E,T,w)}m.label=`${h.id}-container-background`,u.addChild(m);let b=[];(h.children||[]).forEach(E=>{let T=c(E),w=h.width||0,A=h.height||0,R=_*w,C=y*A,G={zIndex:h.zIndex,...E,x:(E.x||0)+R,y:(E.y||0)+C};b.push(T.add(t,{parent:u,element:G,transitions:n,getTransitionByType:a,getRendererByElement:c,eventHandler:l}))});let v=[];for(let E of n)if(E.elementId===h.id&&E.event===Vt.Add){let T=a(E.type);if(!T)throw new Error(`Transition class not found for type ${E.type}`);v.push(T.add(t,u,E))}s.addChild(u);let S=te(b).pipe(jt(E=>E)).subscribe({error:E=>{console.error("Error:",E)},complete:()=>{let{width:E,height:T}=this.getContainerDimensions(h,u),w=_*E,A=y*T;u.pivot.x=w,u.pivot.y=A,r.complete()}});return()=>{S.unsubscribe()}});remove=(t,e)=>(console.log("remove container 11111111111"),new at(r=>{let{parent:s,element:o}=e,n=s.getChildByName(o.id);if(!n){console.warn(`Container with id ${o.id} not found`);return}return n.destroy(),()=>{n.destroy()}}));update=(t,e)=>new at(r=>{let{parent:s,prevElement:o,nextElement:n,getRendererByElement:a,transitions:c=[],getTransitionByType:l,eventHandler:h}=e,u=structuredClone(o),d=structuredClone(n),f=s.getChildByName(u.id);if(!f){console.warn(`Container with id ${u.id} not found`);return}d.x!==void 0&&d.x!==u.x&&(f.x=d.x),d.y!==void 0&&d.y!==u.y&&(f.y=d.y),d.rotation!==void 0&&d.rotation!==u.rotation&&(f.rotation=d.rotation*Math.PI/180);let m=[0,.5,1],g=d.anchorX??0,_=d.anchorY??0;if(!m.includes(g))throw new Error(`Invalid anchorX value: ${g}. Must be 0, 0.5, or 1`);if(!m.includes(_))throw new Error(`Invalid anchorY value: ${_}. Must be 0, 0.5, or 1`);if(d.direction){let E=d.gap||0,T,w;d.direction==="horizontal"?(T=d.children.reduce((C,G)=>C+G.width+E,0),w=d.children.reduce((C,G)=>Math.max(C,G.height||0),0)):d.direction==="vertical"&&(T=d.children.reduce((C,G)=>Math.max(C,G.width||0),0),w=d.children.reduce((C,G)=>C+G.height+E,0));let A={x:g,y:_};d.direction==="horizontal"?this.layoutChildren({element:d,anchor:A,totalWidth:T,totalHeight:w,gap:E,direction:"horizontal",scroll:d.scroll}):d.direction==="vertical"&&this.layoutChildren({element:d,anchor:A,totalWidth:T,totalHeight:w,gap:E,direction:"vertical",scroll:d.scroll});let R=f.children.find(C=>C.label===`${d.id}-container-background`);if(R){R.destroy();let C=this.createContainerGraphic(d,T,w,A);C.label=`${d.id}-container-background`,f.addChildAt(C,0)}u.scroll!==d.scroll&&this.setupScrolling({container:f,element:d,totalHeight:w,totalWidth:T,eventHandler:h,sliderRef:{}})}let y=[],{toAddElements:b,toUpdateElements:v,toDeleteElements:S}=ac(u.children,d.children);for(let E of S){let T=a(E);y.push(T.remove(t,{parent:f,element:E,transitions:c,getTransitionByType:l,getRendererByElement:a,eventHandler:h}))}for(let E of b){let T=a(E),w=d.width||0,A=d.height||0,R=g*w,C=_*A,G={...E,x:(E.x||0)+R,y:(E.y||0)+C};y.push(T.add(t,{parent:f,element:G,transitions:c,getTransitionByType:l,getRendererByElement:a,eventHandler:h}))}for(let E of v){let T=a(E.next);y.push(T.update(t,{parent:f,prevElement:E.prev,nextElement:E.next,transitions:c,getTransitionByType:l,getRendererByElement:a,eventHandler:h}))}return f.children.sort((E,T)=>{let w=d.children?.findIndex(R=>R.id===E.label),A=d.children?.findIndex(R=>R.id===T.label);return w-A}),this._currentSubscription=te(y).pipe(jt(E=>E),Ko(()=>{let{width:E,height:T}=this.getContainerDimensions(d,f),w=g*E,A=_*T;f.pivot.x=w,f.pivot.y=A,r.complete()})).subscribe({error:E=>{r.error(E),console.error("Error:",E)}}),()=>{this._currentSubscription?.unsubscribe()}});layoutChildren({element:t,anchor:e,totalWidth:r,totalHeight:s,gap:o,direction:n,scroll:a}){let c=n==="horizontal",l=c?"x":"y",h=c?"y":"x",u=c?"width":"height",d=c?"height":"width",f=c?r:s,m=c?s:r,g=c?e.x:e.y,_=c?e.y:e.x;if(!a&&t[u]!==void 0&&t[u]<f){let b=0,v=0,S=0,E=0;(t.children||[]).forEach((T,w)=>{b>0&&b+T[u]>t[u]&&(this.alignRowElements(t.children.slice(E,w),l,g,t[u]),b=0,v+=S+o,S=0,E=w),T[l]=b,T[h]=v,b+=T[u]+o,S=Math.max(S,T[d]||0)}),E<t.children.length&&this.alignRowElements(t.children.slice(E),l,g,t[u])}else{if(g===0){let b=0;(t.children||[]).forEach(v=>{v[l]=b,b+=v[u]+o})}else if(g===1){let b=-f;(t.children||[]).forEach(v=>{v[l]=b,b+=v[u]+o})}else if(g===.5){let b=-f/2;(t.children||[]).forEach(v=>{v[l]=b,b+=v[u]+o})}_===0?(t.children||[]).forEach(b=>{b[h]=0}):_===.5?(t.children||[]).forEach(b=>{b[h]=-m/2}):_===1&&(t.children||[]).forEach(b=>{b[h]=-m})}}alignRowElements(t,e,r,s){if(!t.length)return;let o=t.reduce((n,a,c)=>n+a[e==="x"?"width":"height"]+(c>0,0),0);if(r===.5){let a=(s-o)/2;t.forEach(c=>{c[e]=a,a+=c[e==="x"?"width":"height"]+0})}else if(r===1){let a=s-o;t.forEach(c=>{c[e]=a,a+=c[e==="x"?"width":"height"]+0})}}createContainerGraphic(t,e,r,s){let o=new Wt().roundRect(0,0,e,r,1).fill(t.fill?t.fill.color:"transparent");return s.x===1&&(o.x-=t.width),s.x===.5&&(o.x-=t.width/2),s.y===1&&(o.y-=t.height),s.y===.5&&(o.y-=t.height/2),o}getContainerDimensions(t,e){let r=t.width||0,s=t.height||0;if(!t.direction&&(!t.width||!t.height)&&e.children&&e.children.length>0){let o=1/0,n=-1/0,a=1/0,c=-1/0;e.children.forEach(l=>{let h=l.x||0,u=l.y||0,d=l.width||0,f=l.height||0;o=Math.min(o,h),n=Math.max(n,h+d),a=Math.min(a,u),c=Math.max(c,u+f)}),t.width||(r=n-o,(isNaN(r)||!isFinite(r))&&(r=0)),t.height||(s=c-a,(isNaN(s)||!isFinite(s))&&(s=0))}return{width:r,height:s}}setupScrolling({container:t,element:e,totalHeight:r,totalWidth:s,eventHandler:o,sliderRef:n}){let a=e.scroll&&e.height&&r>e.height,c=e.scroll&&e.width&&s>e.width;if(a||c){let l=0,h=0,u=-r+e.height,d=-s+e.width,f=new Wt().rect(0,0,e.width||s,e.height||r).fill("red");t.mask=f,t.eventMode="static",t.addChild(f),t.on("wheel",m=>{if(a&&m.deltaY!==0&&(l-m.deltaY>0||l-m.deltaY<u||(l-=m.deltaY,t.y-=m.deltaY,f.y+=m.deltaY)),c&&(m.deltaX!==0||m.shiftKey&&m.deltaY!==0)){let g=m.deltaX!==0?m.deltaX:m.deltaY;if(h-g>0||h-g<d)return;h-=g,t.x-=g,f.x+=g}})}}};var yP={linear:i=>i},bP=(i,t,e,r)=>i+(t-i)*yP[r](e);function GT(i,t,e){typeof t=="string"&&(t=t.split("."));let r=i;for(let s of t){if(r==null)return e;r=r[s]}return r===void 0?e:r}function IT(i,t,e){typeof t=="string"&&(t=t.split("."));let r=i;for(let s=0;s<t.length-1;s++){let o=t[s];o in r||(r[o]={}),r=r[o]}return r[t[t.length-1]]=e,i}var vP=(i,t)=>{let e=[],r=0,s;i.forEach(({value:n,duration:a,easing:c,relative:l},h)=>{h===0?(s=n,e.push({time:r,value:n,easing:"linear"})):a!==void 0&&c!==void 0&&(r+=a,l?s=s+n:s=n,e.push({time:r,value:s,easing:c}))});let o=0;for(let n=0;n<e.length-1;n++){let{time:a,value:c,easing:l}=e[n],{time:h,value:u}=e[n+1];if(t>=a&&t<=h){let d=(t-a)/(h-a);o=bP(c,u,d,l);break}else t>h&&(o=u)}return o};function TP(i){return Math.max.apply(null,i)}var Ad=class{static rendererName="pixi";rendererName="pixi";transitionType="keyframes";_transition=(t,e,r)=>(console.log("keyframe transition setup"),new at(s=>{console.log("keyframe transition start");let{animationProperties:o}=r,n=Array.isArray(o)?o:Object.entries(o).map(([d,f])=>({...f,property:d})),a=n.map(d=>d.keyframes.reduce((f,m)=>f+m.duration||0,0)),c=TP(a),l=0,h={};n.forEach(d=>{h[d.property]=GT(e,d.property)});let u=d=>{if(l+=d.deltaMS,l>=c){t.ticker.remove(u),s.complete();return}let f={};n.forEach(m=>{let g=[];m.initialValue!==void 0?g=[{value:m.initialValue,duration:0}]:g=[{value:h[m.property],duration:0}],g=g.concat(m.keyframes),IT(f,m.property,vP(g,l))}),n.forEach(m=>{let{property:g}=m;e&&!e.destroyed&&IT(e,g,GT(f,g))})};return t.ticker.add(u),()=>{t.ticker.remove(u),u({deltaMS:c-l})}}));add=(t,e,r)=>this._transition(t,e,r);remove=(t,e,r)=>this._transition(t,e,r)};var Cd=class{static rendererName="pixi";rendererName="pixi";rendererType="rect";add=async(t,e)=>{let{parent:r,element:s,transitions:o=[],getTransitionByType:n,eventHandler:a}=e,c=new Wt;c.label=s.id,s.x!==void 0&&(c.x=s.x),s.y!==void 0&&(c.y=s.y),s.alpha!==void 0&&(c.alpha=s.alpha),s.scaleX!==void 0&&(c.scale.x=s.scaleX),s.scaleY!==void 0&&(c.scale.y=s.scaleY),s.rotation!==void 0&&(c.rotation=s.rotation*Math.PI/180);let l=s.width,h=s.height;c.rect(0,0,l,h),c.fill(s.fill),s.anchorX!==void 0&&(c.pivot.x=l*s.anchorX),s.anchorY!==void 0&&(c.pivot.y=h*s.anchorY),(s.clickEventName||s.rightClickEventName)&&a&&(c.eventMode="static",c.on("pointerup",d=>{d.button===0?a(s.clickEventName):d.button===2&&a(s.rightClickEventName)})),s.wheelEventName&&a&&(c.eventMode="static",c.on("wheel",d=>{a(s.wheelEventName,{deltaY:d.deltaY})}));let u=[];for(let d of o)if(d.elementId===s.id&&d.event===Vt.Add){let f=n(d.type);if(!f)throw new Error(`Transition class not found for type ${d.type}`);u.push(f.add(t,c,d))}r.addChild(c),await Promise.all(u)};remove=async(t,e)=>{let{parent:r,element:s}=e,o=r.getChildByName(s.id);if(!o)throw new Error(`Sprite with id ${s.id} not found`);o.destroy()};update=async(t,e)=>{let{parent:r,prevElement:s,nextElement:o,transitions:n=[],getTransitionByType:a,eventHandler:c}=e;if(!r.getChildByName(s.id))throw new Error(`Container with id ${s.id} not found`);JSON.stringify(s)!==JSON.stringify(o)&&await Promise.all([this.remove(t,{parent:r,element:s,transitions:n,getTransitionByType:a,eventHandler:c}),this.add(t,{parent:r,element:o,transitions:n,getTransitionByType:a,eventHandler:c})])}};var Md=class extends dr{static rendererName="pixi";rendererName="pixi";rendererType="slider";add=async(t,{parent:e,element:r,transitions:s=[],getTransitionByType:o,eventHandler:n,ref:a})=>{let{direction:c,idleThumb:l,hoverThumb:h,idleBar:u,hoverBar:d,dragEndEventName:f,dragEventName:m,dragEventPayload:g,initialValue:_}=r,y={horizontal:{axis:"x",size:"width"},vertical:{axis:"y",size:"height"}},b=y[c].axis,v=y[c].size,S=M.from(l),E=M.from(h),T=M.from(u),w=M.from(d),A=new Lt({texture:T,anchor:{x:0,y:0}});A.label=r.id;let R=A[v];A.x=r.x||0,A.y=r.y||0;let C=new Lt({texture:S,anchor:{x:.5,y:.5}});if(C.y=A.height/2,C.x=A.width/2,C.eventMode="static",C.cursor="pointer",A.eventMode="static",A.cursor="pointer",C.on("pointerdown",Y).on("pointerup",mt).on("pointerupoutside",mt),A.on("pointerdown",G).on("pointerup",L).on("pointerupoutside",L),A.addChild(C),_!==void 0){let F=C[v]/2;C[b]=_/100*(R-C[v])+F}function G(F){C.texture=E,A.texture=w,Xt(F),t.stage.eventMode="static",t.stage.addEventListener("pointermove",Xt)}function L(F){C.texture=S,A.texture=T,Xt(F),t.stage.eventMode="auto",t.stage.removeEventListener("pointermove",Xt)}function Y(F){F.stopPropagation(),C.texture=E,A.texture=w,t.stage.eventMode="static",t.stage.addEventListener("pointermove",Xt)}function mt(F){if(C.texture=S,A.texture=T,t.stage.eventMode="auto",t.stage.removeEventListener("pointermove",Xt),f){let Te=A.toLocal(F.global)[b],q=C[v]/2;C[b]=Math.max(0+q,Math.min(Te,R-q));let ee=Math.floor((C[b]-q)/(R-C[v])*100),De=JSON.stringify(g);n&&n(f,JSON.parse(De.replace('"{{ value }}"',String(ee))))}}function Xt(F){let Te=A.toLocal(F.global)[b],q=C[v]/2;C[b]=Math.max(0+q,Math.min(Te,R-q));let ee=Math.floor((C[b]-q)/(R-C[v])*100);if(m){let De=JSON.stringify(g);n&&n(m,JSON.parse(De.replace('"{{ value }}"',String(ee))))}return ee}a&&(a.current={updateValue:F=>{let Te=C[v]/2;C[b]=F/100*(R-C[v])+Te}});let N=[];for(let F of s)if(F.elementId===r.id&&F.event===Vt.Add){let Te=o(F.type);if(!Te)throw new Error(`Transition class not found for type ${F.type}`);N.push(Te.add(t,A,F))}e.addChild(A),await Promise.all(N)};remove=async(t,e)=>{let{parent:r,element:s,transitions:o=[],getTransitionByType:n}=e,a=r.getChildByName(s.id);if(!a){console.warn(`Sprite with id ${s.id} not found`);return}let c=[];for(let l of o)if(l.elementId===s.id&&l.event===Vt.Remove){let h=n(l.type);if(!h)throw new Error(`Transition class not found for type ${l.type}`);c.push(h.remove(t,a,l))}await Promise.all(c),a.destroy()};update=async(t,{parent:e,prevElement:r,nextElement:s,transitions:o,getTransitionByType:n,eventHandler:a})=>{if(!e.getChildByName(r.id)){console.warn(`Slider with id ${r.id} not found`,{parent:e});return}JSON.stringify(r)!==JSON.stringify(s)&&await Promise.all([this.remove(t,{parent:e,element:r,transitions:o,getTransitionByType:n,eventHandler:a}),this.add(t,{parent:e,element:s,transitions:o,getTransitionByType:n,eventHandler:a})])}};var Bd=class extends dr{static rendererName="pixi";rendererName="pixi";rendererType="audio";add=async(t,{parent:e,element:r,transitions:s=[],getTransitionByType:o})=>{r.delay?setTimeout(()=>{t.audioStage.add({id:r.id,url:r.url,loop:r.loop??!1,volume:r.volume??1})},r.delay):t.audioStage.add({id:r.id,url:r.url,loop:r.loop??!1,volume:r.volume??1})};remove=async(t,e)=>{let{element:r}=e;t.audioStage.remove(r.id)};update=async(t,{parent:e,prevElement:r,nextElement:s,transitions:o,getTransitionByType:n})=>{if(r.url!==s.url||r.volume!==s.volume){let a=t.audioStage.getById(r.id);a&&(a.url=s.url,a.volume=s.volume??1)}}};var Rd=class{constructor(){this.cache=new Map}async load(t){let e=[];for(let[r,s]of Object.entries(t))this.cache.has(r)||e.push([r,s]);e.length>0&&await Promise.all(e.map(async([r,s])=>{let a={buffer:await(await fetch(s.url)).arrayBuffer(),type:s.type};this.cache.set(r,a)}))}getBufferMap(){let t={};for(let[e,r]of this.cache.entries())t[e]=r;return t}clear(){this.cache.clear()}size(){return this.cache.size}has(t){return this.cache.has(t)}},SP=()=>new Rd;var m7=RT;export{Bd as AudioPlugin,Pd as ContainerRendererPlugin,Ad as KeyframeTransitionPlugin,Cd as RectRendererPlugin,Md as SliderRendererPlugin,Sd as SpriteRendererPlugin,wd as TextRendererPlugin,Ed as TextRevealingRendererPlugin,SP as createAssetBufferManager,m7 as default};
|
package/package.json
CHANGED