@pippit-dev/cli 1.0.20 → 1.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,16 +1,16 @@
1
- "use strict";var QG=Object.create;var Za=Object.defineProperty;var JG=Object.getOwnPropertyDescriptor;var ZG=Object.getOwnPropertyNames;var e1=Object.getPrototypeOf,t1=Object.prototype.hasOwnProperty;var A=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),n1=(e,t)=>{for(var n in t)Za(e,n,{get:t[n],enumerable:!0})},Ty=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ZG(t))!t1.call(e,o)&&o!==n&&Za(e,o,{get:()=>t[o],enumerable:!(r=JG(t,o))||r.enumerable});return e};var ed=(e,t,n)=>(n=e!=null?QG(e1(e)):{},Ty(t||!e||!e.__esModule?Za(n,"default",{value:e,enumerable:!0}):n,e)),r1=e=>Ty(Za({},"__esModule",{value:!0}),e);var PI=A((hCe,Ec)=>{var eI,tI,nI,rI,oI,sI,iI,aI,dI,cI,uI,pI,lI,_c,Ef,fI,mI,hI,jo,gI,yI,AI,vI,SI,bI,II,_I,RI,Rc,EI,CI;(function(e){var t=typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:{};typeof define=="function"&&define.amd?define("tslib",["exports"],function(r){e(n(t,n(r)))}):typeof Ec=="object"&&typeof Ec.exports=="object"?e(n(t,n(Ec.exports))):e(n(t));function n(r,o){return r!==t&&(typeof Object.create=="function"?Object.defineProperty(r,"__esModule",{value:!0}):r.__esModule=!0),function(s,i){return r[s]=o?o(s,i):i}}})(function(e){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(o,s){o.__proto__=s}||function(o,s){for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(o[i]=s[i])};eI=function(o,s){if(typeof s!="function"&&s!==null)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");t(o,s);function i(){this.constructor=o}o.prototype=s===null?Object.create(s):(i.prototype=s.prototype,new i)},tI=Object.assign||function(o){for(var s,i=1,a=arguments.length;i<a;i++){s=arguments[i];for(var d in s)Object.prototype.hasOwnProperty.call(s,d)&&(o[d]=s[d])}return o},nI=function(o,s){var i={};for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&s.indexOf(a)<0&&(i[a]=o[a]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var d=0,a=Object.getOwnPropertySymbols(o);d<a.length;d++)s.indexOf(a[d])<0&&Object.prototype.propertyIsEnumerable.call(o,a[d])&&(i[a[d]]=o[a[d]]);return i},rI=function(o,s,i,a){var d=arguments.length,c=d<3?s:a===null?a=Object.getOwnPropertyDescriptor(s,i):a,u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")c=Reflect.decorate(o,s,i,a);else for(var p=o.length-1;p>=0;p--)(u=o[p])&&(c=(d<3?u(c):d>3?u(s,i,c):u(s,i))||c);return d>3&&c&&Object.defineProperty(s,i,c),c},oI=function(o,s){return function(i,a){s(i,a,o)}},sI=function(o,s,i,a,d,c){function u(I){if(I!==void 0&&typeof I!="function")throw new TypeError("Function expected");return I}for(var p=a.kind,l=p==="getter"?"get":p==="setter"?"set":"value",f=!s&&o?a.static?o:o.prototype:null,h=s||(f?Object.getOwnPropertyDescriptor(f,a.name):{}),m,g=!1,y=i.length-1;y>=0;y--){var v={};for(var S in a)v[S]=S==="access"?{}:a[S];for(var S in a.access)v.access[S]=a.access[S];v.addInitializer=function(I){if(g)throw new TypeError("Cannot add initializers after decoration has completed");c.push(u(I||null))};var b=(0,i[y])(p==="accessor"?{get:h.get,set:h.set}:h[l],v);if(p==="accessor"){if(b===void 0)continue;if(b===null||typeof b!="object")throw new TypeError("Object expected");(m=u(b.get))&&(h.get=m),(m=u(b.set))&&(h.set=m),(m=u(b.init))&&d.unshift(m)}else(m=u(b))&&(p==="field"?d.unshift(m):h[l]=m)}f&&Object.defineProperty(f,a.name,h),g=!0},iI=function(o,s,i){for(var a=arguments.length>2,d=0;d<s.length;d++)i=a?s[d].call(o,i):s[d].call(o);return a?i:void 0},aI=function(o){return typeof o=="symbol"?o:"".concat(o)},dI=function(o,s,i){return typeof s=="symbol"&&(s=s.description?"[".concat(s.description,"]"):""),Object.defineProperty(o,"name",{configurable:!0,value:i?"".concat(i," ",s):s})},cI=function(o,s){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,s)},uI=function(o,s,i,a){function d(c){return c instanceof i?c:new i(function(u){u(c)})}return new(i||(i=Promise))(function(c,u){function p(h){try{f(a.next(h))}catch(m){u(m)}}function l(h){try{f(a.throw(h))}catch(m){u(m)}}function f(h){h.done?c(h.value):d(h.value).then(p,l)}f((a=a.apply(o,s||[])).next())})},pI=function(o,s){var i={label:0,sent:function(){if(c[0]&1)throw c[1];return c[1]},trys:[],ops:[]},a,d,c,u;return u={next:p(0),throw:p(1),return:p(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function p(f){return function(h){return l([f,h])}}function l(f){if(a)throw new TypeError("Generator is already executing.");for(;u&&(u=0,f[0]&&(i=0)),i;)try{if(a=1,d&&(c=f[0]&2?d.return:f[0]?d.throw||((c=d.return)&&c.call(d),0):d.next)&&!(c=c.call(d,f[1])).done)return c;switch(d=0,c&&(f=[f[0]&2,c.value]),f[0]){case 0:case 1:c=f;break;case 4:return i.label++,{value:f[1],done:!1};case 5:i.label++,d=f[1],f=[0];continue;case 7:f=i.ops.pop(),i.trys.pop();continue;default:if(c=i.trys,!(c=c.length>0&&c[c.length-1])&&(f[0]===6||f[0]===2)){i=0;continue}if(f[0]===3&&(!c||f[1]>c[0]&&f[1]<c[3])){i.label=f[1];break}if(f[0]===6&&i.label<c[1]){i.label=c[1],c=f;break}if(c&&i.label<c[2]){i.label=c[2],i.ops.push(f);break}c[2]&&i.ops.pop(),i.trys.pop();continue}f=s.call(o,i)}catch(h){f=[6,h],d=0}finally{a=c=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}},lI=function(o,s){for(var i in o)i!=="default"&&!Object.prototype.hasOwnProperty.call(s,i)&&Rc(s,o,i)},Rc=Object.create?function(o,s,i,a){a===void 0&&(a=i);var d=Object.getOwnPropertyDescriptor(s,i);(!d||("get"in d?!s.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return s[i]}}),Object.defineProperty(o,a,d)}:function(o,s,i,a){a===void 0&&(a=i),o[a]=s[i]},_c=function(o){var s=typeof Symbol=="function"&&Symbol.iterator,i=s&&o[s],a=0;if(i)return i.call(o);if(o&&typeof o.length=="number")return{next:function(){return o&&a>=o.length&&(o=void 0),{value:o&&o[a++],done:!o}}};throw new TypeError(s?"Object is not iterable.":"Symbol.iterator is not defined.")},Ef=function(o,s){var i=typeof Symbol=="function"&&o[Symbol.iterator];if(!i)return o;var a=i.call(o),d,c=[],u;try{for(;(s===void 0||s-- >0)&&!(d=a.next()).done;)c.push(d.value)}catch(p){u={error:p}}finally{try{d&&!d.done&&(i=a.return)&&i.call(a)}finally{if(u)throw u.error}}return c},fI=function(){for(var o=[],s=0;s<arguments.length;s++)o=o.concat(Ef(arguments[s]));return o},mI=function(){for(var o=0,s=0,i=arguments.length;s<i;s++)o+=arguments[s].length;for(var a=Array(o),d=0,s=0;s<i;s++)for(var c=arguments[s],u=0,p=c.length;u<p;u++,d++)a[d]=c[u];return a},hI=function(o,s,i){if(i||arguments.length===2)for(var a=0,d=s.length,c;a<d;a++)(c||!(a in s))&&(c||(c=Array.prototype.slice.call(s,0,a)),c[a]=s[a]);return o.concat(c||Array.prototype.slice.call(s))},jo=function(o){return this instanceof jo?(this.v=o,this):new jo(o)},gI=function(o,s,i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var a=i.apply(o,s||[]),d,c=[];return d={},u("next"),u("throw"),u("return"),d[Symbol.asyncIterator]=function(){return this},d;function u(g){a[g]&&(d[g]=function(y){return new Promise(function(v,S){c.push([g,y,v,S])>1||p(g,y)})})}function p(g,y){try{l(a[g](y))}catch(v){m(c[0][3],v)}}function l(g){g.value instanceof jo?Promise.resolve(g.value.v).then(f,h):m(c[0][2],g)}function f(g){p("next",g)}function h(g){p("throw",g)}function m(g,y){g(y),c.shift(),c.length&&p(c[0][0],c[0][1])}},yI=function(o){var s,i;return s={},a("next"),a("throw",function(d){throw d}),a("return"),s[Symbol.iterator]=function(){return this},s;function a(d,c){s[d]=o[d]?function(u){return(i=!i)?{value:jo(o[d](u)),done:!1}:c?c(u):u}:c}},AI=function(o){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=o[Symbol.asyncIterator],i;return s?s.call(o):(o=typeof _c=="function"?_c(o):o[Symbol.iterator](),i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i);function a(c){i[c]=o[c]&&function(u){return new Promise(function(p,l){u=o[c](u),d(p,l,u.done,u.value)})}}function d(c,u,p,l){Promise.resolve(l).then(function(f){c({value:f,done:p})},u)}},vI=function(o,s){return Object.defineProperty?Object.defineProperty(o,"raw",{value:s}):o.raw=s,o};var n=Object.create?function(o,s){Object.defineProperty(o,"default",{enumerable:!0,value:s})}:function(o,s){o.default=s};SI=function(o){if(o&&o.__esModule)return o;var s={};if(o!=null)for(var i in o)i!=="default"&&Object.prototype.hasOwnProperty.call(o,i)&&Rc(s,o,i);return n(s,o),s},bI=function(o){return o&&o.__esModule?o:{default:o}},II=function(o,s,i,a){if(i==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof s=="function"?o!==s||!a:!s.has(o))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?a:i==="a"?a.call(o):a?a.value:s.get(o)},_I=function(o,s,i,a,d){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!d)throw new TypeError("Private accessor was defined without a setter");if(typeof s=="function"?o!==s||!d:!s.has(o))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?d.call(o,i):d?d.value=i:s.set(o,i),i},RI=function(o,s){if(s===null||typeof s!="object"&&typeof s!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof o=="function"?s===o:o.has(s)},EI=function(o,s,i){if(s!=null){if(typeof s!="object"&&typeof s!="function")throw new TypeError("Object expected.");var a;if(i){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");a=s[Symbol.asyncDispose]}if(a===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");a=s[Symbol.dispose]}if(typeof a!="function")throw new TypeError("Object not disposable.");o.stack.push({value:s,dispose:a,async:i})}else i&&o.stack.push({async:!0});return s};var r=typeof SuppressedError=="function"?SuppressedError:function(o,s,i){var a=new Error(i);return a.name="SuppressedError",a.error=o,a.suppressed=s,a};CI=function(o){function s(a){o.error=o.hasError?new r(a,o.error,"An error was suppressed during disposal."):a,o.hasError=!0}function i(){for(;o.stack.length;){var a=o.stack.pop();try{var d=a.dispose&&a.dispose.call(a.value);if(a.async)return Promise.resolve(d).then(i,function(c){return s(c),i()})}catch(c){s(c)}}if(o.hasError)throw o.error}return i()},e("__extends",eI),e("__assign",tI),e("__rest",nI),e("__decorate",rI),e("__param",oI),e("__esDecorate",sI),e("__runInitializers",iI),e("__propKey",aI),e("__setFunctionName",dI),e("__metadata",cI),e("__awaiter",uI),e("__generator",pI),e("__exportStar",lI),e("__createBinding",Rc),e("__values",_c),e("__read",Ef),e("__spread",fI),e("__spreadArrays",mI),e("__spreadArray",hI),e("__await",jo),e("__asyncGenerator",gI),e("__asyncDelegator",yI),e("__asyncValues",AI),e("__makeTemplateObject",vI),e("__importStar",SI),e("__importDefault",bI),e("__classPrivateFieldGet",II),e("__classPrivateFieldSet",_I),e("__classPrivateFieldIn",RI),e("__addDisposableResource",EI),e("__disposeResources",CI)})});var QE=A((PLe,WE)=>{function $3(){this.__data__=[],this.size=0}WE.exports=$3});var eo=A((xLe,JE)=>{function W3(e,t){return e===t||e!==e&&t!==t}JE.exports=W3});var ha=A((TLe,ZE)=>{var Q3=eo();function J3(e,t){for(var n=e.length;n--;)if(Q3(e[n][0],t))return n;return-1}ZE.exports=J3});var tC=A((NLe,eC)=>{var Z3=ha(),e$=Array.prototype,t$=e$.splice;function n$(e){var t=this.__data__,n=Z3(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():t$.call(t,n,1),--this.size,!0}eC.exports=n$});var rC=A((wLe,nC)=>{var r$=ha();function o$(e){var t=this.__data__,n=r$(t,e);return n<0?void 0:t[n][1]}nC.exports=o$});var sC=A((OLe,oC)=>{var s$=ha();function i$(e){return s$(this.__data__,e)>-1}oC.exports=i$});var aC=A((DLe,iC)=>{var a$=ha();function d$(e,t){var n=this.__data__,r=a$(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}iC.exports=d$});var ga=A((kLe,dC)=>{var c$=QE(),u$=tC(),p$=rC(),l$=sC(),f$=aC();function fs(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}fs.prototype.clear=c$;fs.prototype.delete=u$;fs.prototype.get=p$;fs.prototype.has=l$;fs.prototype.set=f$;dC.exports=fs});var uC=A((MLe,cC)=>{var m$=ga();function h$(){this.__data__=new m$,this.size=0}cC.exports=h$});var lC=A((LLe,pC)=>{function g$(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}pC.exports=g$});var mC=A((BLe,fC)=>{function y$(e){return this.__data__.get(e)}fC.exports=y$});var gC=A((GLe,hC)=>{function A$(e){return this.__data__.has(e)}hC.exports=A$});var bh=A((ULe,yC)=>{var v$=typeof global=="object"&&global&&global.Object===Object&&global;yC.exports=v$});var yt=A((zLe,AC)=>{var S$=bh(),b$=typeof self=="object"&&self&&self.Object===Object&&self,I$=S$||b$||Function("return this")();AC.exports=I$});var to=A((qLe,vC)=>{var _$=yt(),R$=_$.Symbol;vC.exports=R$});var _C=A((FLe,IC)=>{var SC=to(),bC=Object.prototype,E$=bC.hasOwnProperty,C$=bC.toString,ya=SC?SC.toStringTag:void 0;function P$(e){var t=E$.call(e,ya),n=e[ya];try{e[ya]=void 0;var r=!0}catch{}var o=C$.call(e);return r&&(t?e[ya]=n:delete e[ya]),o}IC.exports=P$});var EC=A((jLe,RC)=>{var x$=Object.prototype,T$=x$.toString;function N$(e){return T$.call(e)}RC.exports=N$});var rr=A((VLe,xC)=>{var CC=to(),w$=_C(),O$=EC(),D$="[object Null]",k$="[object Undefined]",PC=CC?CC.toStringTag:void 0;function M$(e){return e==null?e===void 0?k$:D$:PC&&PC in Object(e)?w$(e):O$(e)}xC.exports=M$});var it=A((HLe,TC)=>{function L$(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}TC.exports=L$});var ms=A((YLe,NC)=>{var B$=rr(),G$=it(),U$="[object AsyncFunction]",z$="[object Function]",q$="[object GeneratorFunction]",F$="[object Proxy]";function j$(e){if(!G$(e))return!1;var t=B$(e);return t==z$||t==q$||t==U$||t==F$}NC.exports=j$});var OC=A((KLe,wC)=>{var V$=yt(),H$=V$["__core-js_shared__"];wC.exports=H$});var MC=A((XLe,kC)=>{var Ih=OC(),DC=function(){var e=/[^.]+$/.exec(Ih&&Ih.keys&&Ih.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Y$(e){return!!DC&&DC in e}kC.exports=Y$});var _h=A(($Le,LC)=>{var K$=Function.prototype,X$=K$.toString;function $$(e){if(e!=null){try{return X$.call(e)}catch{}try{return e+""}catch{}}return""}LC.exports=$$});var GC=A((WLe,BC)=>{var W$=ms(),Q$=MC(),J$=it(),Z$=_h(),e8=/[\\^$.*+?()[\]{}|]/g,t8=/^\[object .+?Constructor\]$/,n8=Function.prototype,r8=Object.prototype,o8=n8.toString,s8=r8.hasOwnProperty,i8=RegExp("^"+o8.call(s8).replace(e8,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function a8(e){if(!J$(e)||Q$(e))return!1;var t=W$(e)?i8:t8;return t.test(Z$(e))}BC.exports=a8});var zC=A((QLe,UC)=>{function d8(e,t){return e==null?void 0:e[t]}UC.exports=d8});var or=A((JLe,qC)=>{var c8=GC(),u8=zC();function p8(e,t){var n=u8(e,t);return c8(n)?n:void 0}qC.exports=p8});var Eu=A((ZLe,FC)=>{var l8=or(),f8=yt(),m8=l8(f8,"Map");FC.exports=m8});var Aa=A((eBe,jC)=>{var h8=or(),g8=h8(Object,"create");jC.exports=g8});var YC=A((tBe,HC)=>{var VC=Aa();function y8(){this.__data__=VC?VC(null):{},this.size=0}HC.exports=y8});var XC=A((nBe,KC)=>{function A8(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}KC.exports=A8});var WC=A((rBe,$C)=>{var v8=Aa(),S8="__lodash_hash_undefined__",b8=Object.prototype,I8=b8.hasOwnProperty;function _8(e){var t=this.__data__;if(v8){var n=t[e];return n===S8?void 0:n}return I8.call(t,e)?t[e]:void 0}$C.exports=_8});var JC=A((oBe,QC)=>{var R8=Aa(),E8=Object.prototype,C8=E8.hasOwnProperty;function P8(e){var t=this.__data__;return R8?t[e]!==void 0:C8.call(t,e)}QC.exports=P8});var eP=A((sBe,ZC)=>{var x8=Aa(),T8="__lodash_hash_undefined__";function N8(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=x8&&t===void 0?T8:t,this}ZC.exports=N8});var nP=A((iBe,tP)=>{var w8=YC(),O8=XC(),D8=WC(),k8=JC(),M8=eP();function hs(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}hs.prototype.clear=w8;hs.prototype.delete=O8;hs.prototype.get=D8;hs.prototype.has=k8;hs.prototype.set=M8;tP.exports=hs});var sP=A((aBe,oP)=>{var rP=nP(),L8=ga(),B8=Eu();function G8(){this.size=0,this.__data__={hash:new rP,map:new(B8||L8),string:new rP}}oP.exports=G8});var aP=A((dBe,iP)=>{function U8(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}iP.exports=U8});var va=A((cBe,dP)=>{var z8=aP();function q8(e,t){var n=e.__data__;return z8(t)?n[typeof t=="string"?"string":"hash"]:n.map}dP.exports=q8});var uP=A((uBe,cP)=>{var F8=va();function j8(e){var t=F8(this,e).delete(e);return this.size-=t?1:0,t}cP.exports=j8});var lP=A((pBe,pP)=>{var V8=va();function H8(e){return V8(this,e).get(e)}pP.exports=H8});var mP=A((lBe,fP)=>{var Y8=va();function K8(e){return Y8(this,e).has(e)}fP.exports=K8});var gP=A((fBe,hP)=>{var X8=va();function $8(e,t){var n=X8(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}hP.exports=$8});var Cu=A((mBe,yP)=>{var W8=sP(),Q8=uP(),J8=lP(),Z8=mP(),eW=gP();function gs(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}gs.prototype.clear=W8;gs.prototype.delete=Q8;gs.prototype.get=J8;gs.prototype.has=Z8;gs.prototype.set=eW;yP.exports=gs});var vP=A((hBe,AP)=>{var tW=ga(),nW=Eu(),rW=Cu(),oW=200;function sW(e,t){var n=this.__data__;if(n instanceof tW){var r=n.__data__;if(!nW||r.length<oW-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new rW(r)}return n.set(e,t),this.size=n.size,this}AP.exports=sW});var Sa=A((gBe,SP)=>{var iW=ga(),aW=uC(),dW=lC(),cW=mC(),uW=gC(),pW=vP();function ys(e){var t=this.__data__=new iW(e);this.size=t.size}ys.prototype.clear=aW;ys.prototype.delete=dW;ys.prototype.get=cW;ys.prototype.has=uW;ys.prototype.set=pW;SP.exports=ys});var Pu=A((yBe,bP)=>{function lW(e,t){for(var n=-1,r=e==null?0:e.length;++n<r&&t(e[n],n,e)!==!1;);return e}bP.exports=lW});var Rh=A((ABe,IP)=>{var fW=or(),mW=function(){try{var e=fW(Object,"defineProperty");return e({},"",{}),e}catch{}}();IP.exports=mW});var ba=A((vBe,RP)=>{var _P=Rh();function hW(e,t,n){t=="__proto__"&&_P?_P(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}RP.exports=hW});var Ia=A((SBe,EP)=>{var gW=ba(),yW=eo(),AW=Object.prototype,vW=AW.hasOwnProperty;function SW(e,t,n){var r=e[t];(!(vW.call(e,t)&&yW(r,n))||n===void 0&&!(t in e))&&gW(e,t,n)}EP.exports=SW});var As=A((bBe,CP)=>{var bW=Ia(),IW=ba();function _W(e,t,n,r){var o=!n;n||(n={});for(var s=-1,i=t.length;++s<i;){var a=t[s],d=r?r(n[a],e[a],a,n,e):void 0;d===void 0&&(d=e[a]),o?IW(n,a,d):bW(n,a,d)}return n}CP.exports=_W});var xP=A((IBe,PP)=>{function RW(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}PP.exports=RW});var Ot=A((_Be,TP)=>{function EW(e){return e!=null&&typeof e=="object"}TP.exports=EW});var wP=A((RBe,NP)=>{var CW=rr(),PW=Ot(),xW="[object Arguments]";function TW(e){return PW(e)&&CW(e)==xW}NP.exports=TW});var vs=A((EBe,kP)=>{var OP=wP(),NW=Ot(),DP=Object.prototype,wW=DP.hasOwnProperty,OW=DP.propertyIsEnumerable,DW=OP(function(){return arguments}())?OP:function(e){return NW(e)&&wW.call(e,"callee")&&!OW.call(e,"callee")};kP.exports=DW});var ve=A((CBe,MP)=>{var kW=Array.isArray;MP.exports=kW});var BP=A((PBe,LP)=>{function MW(){return!1}LP.exports=MW});var no=A((_a,Ss)=>{var LW=yt(),BW=BP(),zP=typeof _a=="object"&&_a&&!_a.nodeType&&_a,GP=zP&&typeof Ss=="object"&&Ss&&!Ss.nodeType&&Ss,GW=GP&&GP.exports===zP,UP=GW?LW.Buffer:void 0,UW=UP?UP.isBuffer:void 0,zW=UW||BW;Ss.exports=zW});var Ra=A((xBe,qP)=>{var qW=9007199254740991,FW=/^(?:0|[1-9]\d*)$/;function jW(e,t){var n=typeof e;return t=t??qW,!!t&&(n=="number"||n!="symbol"&&FW.test(e))&&e>-1&&e%1==0&&e<t}qP.exports=jW});var xu=A((TBe,FP)=>{var VW=9007199254740991;function HW(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=VW}FP.exports=HW});var VP=A((NBe,jP)=>{var YW=rr(),KW=xu(),XW=Ot(),$W="[object Arguments]",WW="[object Array]",QW="[object Boolean]",JW="[object Date]",ZW="[object Error]",e4="[object Function]",t4="[object Map]",n4="[object Number]",r4="[object Object]",o4="[object RegExp]",s4="[object Set]",i4="[object String]",a4="[object WeakMap]",d4="[object ArrayBuffer]",c4="[object DataView]",u4="[object Float32Array]",p4="[object Float64Array]",l4="[object Int8Array]",f4="[object Int16Array]",m4="[object Int32Array]",h4="[object Uint8Array]",g4="[object Uint8ClampedArray]",y4="[object Uint16Array]",A4="[object Uint32Array]",pe={};pe[u4]=pe[p4]=pe[l4]=pe[f4]=pe[m4]=pe[h4]=pe[g4]=pe[y4]=pe[A4]=!0;pe[$W]=pe[WW]=pe[d4]=pe[QW]=pe[c4]=pe[JW]=pe[ZW]=pe[e4]=pe[t4]=pe[n4]=pe[r4]=pe[o4]=pe[s4]=pe[i4]=pe[a4]=!1;function v4(e){return XW(e)&&KW(e.length)&&!!pe[YW(e)]}jP.exports=v4});var Ea=A((wBe,HP)=>{function S4(e){return function(t){return e(t)}}HP.exports=S4});var Tu=A((Ca,bs)=>{var b4=bh(),YP=typeof Ca=="object"&&Ca&&!Ca.nodeType&&Ca,Pa=YP&&typeof bs=="object"&&bs&&!bs.nodeType&&bs,I4=Pa&&Pa.exports===YP,Eh=I4&&b4.process,_4=function(){try{var e=Pa&&Pa.require&&Pa.require("util").types;return e||Eh&&Eh.binding&&Eh.binding("util")}catch{}}();bs.exports=_4});var Is=A((OBe,$P)=>{var R4=VP(),E4=Ea(),KP=Tu(),XP=KP&&KP.isTypedArray,C4=XP?E4(XP):R4;$P.exports=C4});var Ch=A((DBe,WP)=>{var P4=xP(),x4=vs(),T4=ve(),N4=no(),w4=Ra(),O4=Is(),D4=Object.prototype,k4=D4.hasOwnProperty;function M4(e,t){var n=T4(e),r=!n&&x4(e),o=!n&&!r&&N4(e),s=!n&&!r&&!o&&O4(e),i=n||r||o||s,a=i?P4(e.length,String):[],d=a.length;for(var c in e)(t||k4.call(e,c))&&!(i&&(c=="length"||o&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||w4(c,d)))&&a.push(c);return a}WP.exports=M4});var xa=A((kBe,QP)=>{var L4=Object.prototype;function B4(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||L4;return e===n}QP.exports=B4});var Ph=A((MBe,JP)=>{function G4(e,t){return function(n){return e(t(n))}}JP.exports=G4});var ex=A((LBe,ZP)=>{var U4=Ph(),z4=U4(Object.keys,Object);ZP.exports=z4});var Nu=A((BBe,tx)=>{var q4=xa(),F4=ex(),j4=Object.prototype,V4=j4.hasOwnProperty;function H4(e){if(!q4(e))return F4(e);var t=[];for(var n in Object(e))V4.call(e,n)&&n!="constructor"&&t.push(n);return t}tx.exports=H4});var tn=A((GBe,nx)=>{var Y4=ms(),K4=xu();function X4(e){return e!=null&&K4(e.length)&&!Y4(e)}nx.exports=X4});var Tn=A((UBe,rx)=>{var $4=Ch(),W4=Nu(),Q4=tn();function J4(e){return Q4(e)?$4(e):W4(e)}rx.exports=J4});var sx=A((zBe,ox)=>{var Z4=As(),e9=Tn();function t9(e,t){return e&&Z4(t,e9(t),e)}ox.exports=t9});var ax=A((qBe,ix)=>{function n9(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}ix.exports=n9});var cx=A((FBe,dx)=>{var r9=it(),o9=xa(),s9=ax(),i9=Object.prototype,a9=i9.hasOwnProperty;function d9(e){if(!r9(e))return s9(e);var t=o9(e),n=[];for(var r in e)r=="constructor"&&(t||!a9.call(e,r))||n.push(r);return n}dx.exports=d9});var sr=A((jBe,ux)=>{var c9=Ch(),u9=cx(),p9=tn();function l9(e){return p9(e)?c9(e,!0):u9(e)}ux.exports=l9});var lx=A((VBe,px)=>{var f9=As(),m9=sr();function h9(e,t){return e&&f9(t,m9(t),e)}px.exports=h9});var xh=A((Ta,_s)=>{var g9=yt(),gx=typeof Ta=="object"&&Ta&&!Ta.nodeType&&Ta,fx=gx&&typeof _s=="object"&&_s&&!_s.nodeType&&_s,y9=fx&&fx.exports===gx,mx=y9?g9.Buffer:void 0,hx=mx?mx.allocUnsafe:void 0;function A9(e,t){if(t)return e.slice();var n=e.length,r=hx?hx(n):new e.constructor(n);return e.copy(r),r}_s.exports=A9});var Th=A((HBe,yx)=>{function v9(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}yx.exports=v9});var Nh=A((YBe,Ax)=>{function S9(e,t){for(var n=-1,r=e==null?0:e.length,o=0,s=[];++n<r;){var i=e[n];t(i,n,e)&&(s[o++]=i)}return s}Ax.exports=S9});var wh=A((KBe,vx)=>{function b9(){return[]}vx.exports=b9});var wu=A((XBe,bx)=>{var I9=Nh(),_9=wh(),R9=Object.prototype,E9=R9.propertyIsEnumerable,Sx=Object.getOwnPropertySymbols,C9=Sx?function(e){return e==null?[]:(e=Object(e),I9(Sx(e),function(t){return E9.call(e,t)}))}:_9;bx.exports=C9});var _x=A(($Be,Ix)=>{var P9=As(),x9=wu();function T9(e,t){return P9(e,x9(e),t)}Ix.exports=T9});var Ou=A((WBe,Rx)=>{function N9(e,t){for(var n=-1,r=t.length,o=e.length;++n<r;)e[o+n]=t[n];return e}Rx.exports=N9});var Na=A((QBe,Ex)=>{var w9=Ph(),O9=w9(Object.getPrototypeOf,Object);Ex.exports=O9});var Oh=A((JBe,Cx)=>{var D9=Ou(),k9=Na(),M9=wu(),L9=wh(),B9=Object.getOwnPropertySymbols,G9=B9?function(e){for(var t=[];e;)D9(t,M9(e)),e=k9(e);return t}:L9;Cx.exports=G9});var xx=A((ZBe,Px)=>{var U9=As(),z9=Oh();function q9(e,t){return U9(e,z9(e),t)}Px.exports=q9});var Dh=A((eGe,Tx)=>{var F9=Ou(),j9=ve();function V9(e,t,n){var r=t(e);return j9(e)?r:F9(r,n(e))}Tx.exports=V9});var kh=A((tGe,Nx)=>{var H9=Dh(),Y9=wu(),K9=Tn();function X9(e){return H9(e,K9,Y9)}Nx.exports=X9});var Ox=A((nGe,wx)=>{var $9=Dh(),W9=Oh(),Q9=sr();function J9(e){return $9(e,Q9,W9)}wx.exports=J9});var kx=A((rGe,Dx)=>{var Z9=or(),e6=yt(),t6=Z9(e6,"DataView");Dx.exports=t6});var Lx=A((oGe,Mx)=>{var n6=or(),r6=yt(),o6=n6(r6,"Promise");Mx.exports=o6});var Mh=A((sGe,Bx)=>{var s6=or(),i6=yt(),a6=s6(i6,"Set");Bx.exports=a6});var Ux=A((iGe,Gx)=>{var d6=or(),c6=yt(),u6=d6(c6,"WeakMap");Gx.exports=u6});var oo=A((aGe,Yx)=>{var Lh=kx(),Bh=Eu(),Gh=Lx(),Uh=Mh(),zh=Ux(),Hx=rr(),Rs=_h(),zx="[object Map]",p6="[object Object]",qx="[object Promise]",Fx="[object Set]",jx="[object WeakMap]",Vx="[object DataView]",l6=Rs(Lh),f6=Rs(Bh),m6=Rs(Gh),h6=Rs(Uh),g6=Rs(zh),ro=Hx;(Lh&&ro(new Lh(new ArrayBuffer(1)))!=Vx||Bh&&ro(new Bh)!=zx||Gh&&ro(Gh.resolve())!=qx||Uh&&ro(new Uh)!=Fx||zh&&ro(new zh)!=jx)&&(ro=function(e){var t=Hx(e),n=t==p6?e.constructor:void 0,r=n?Rs(n):"";if(r)switch(r){case l6:return Vx;case f6:return zx;case m6:return qx;case h6:return Fx;case g6:return jx}return t});Yx.exports=ro});var Xx=A((dGe,Kx)=>{var y6=Object.prototype,A6=y6.hasOwnProperty;function v6(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]=="string"&&A6.call(e,"index")&&(n.index=e.index,n.input=e.input),n}Kx.exports=v6});var qh=A((cGe,$x)=>{var S6=yt(),b6=S6.Uint8Array;$x.exports=b6});var Du=A((uGe,Qx)=>{var Wx=qh();function I6(e){var t=new e.constructor(e.byteLength);return new Wx(t).set(new Wx(e)),t}Qx.exports=I6});var Zx=A((pGe,Jx)=>{var _6=Du();function R6(e,t){var n=t?_6(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}Jx.exports=R6});var tT=A((lGe,eT)=>{var E6=/\w*$/;function C6(e){var t=new e.constructor(e.source,E6.exec(e));return t.lastIndex=e.lastIndex,t}eT.exports=C6});var iT=A((fGe,sT)=>{var nT=to(),rT=nT?nT.prototype:void 0,oT=rT?rT.valueOf:void 0;function P6(e){return oT?Object(oT.call(e)):{}}sT.exports=P6});var Fh=A((mGe,aT)=>{var x6=Du();function T6(e,t){var n=t?x6(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}aT.exports=T6});var cT=A((hGe,dT)=>{var N6=Du(),w6=Zx(),O6=tT(),D6=iT(),k6=Fh(),M6="[object Boolean]",L6="[object Date]",B6="[object Map]",G6="[object Number]",U6="[object RegExp]",z6="[object Set]",q6="[object String]",F6="[object Symbol]",j6="[object ArrayBuffer]",V6="[object DataView]",H6="[object Float32Array]",Y6="[object Float64Array]",K6="[object Int8Array]",X6="[object Int16Array]",$6="[object Int32Array]",W6="[object Uint8Array]",Q6="[object Uint8ClampedArray]",J6="[object Uint16Array]",Z6="[object Uint32Array]";function e5(e,t,n){var r=e.constructor;switch(t){case j6:return N6(e);case M6:case L6:return new r(+e);case V6:return w6(e,n);case H6:case Y6:case K6:case X6:case $6:case W6:case Q6:case J6:case Z6:return k6(e,n);case B6:return new r;case G6:case q6:return new r(e);case U6:return O6(e);case z6:return new r;case F6:return D6(e)}}dT.exports=e5});var jh=A((gGe,pT)=>{var t5=it(),uT=Object.create,n5=function(){function e(){}return function(t){if(!t5(t))return{};if(uT)return uT(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();pT.exports=n5});var Vh=A((yGe,lT)=>{var r5=jh(),o5=Na(),s5=xa();function i5(e){return typeof e.constructor=="function"&&!s5(e)?r5(o5(e)):{}}lT.exports=i5});var mT=A((AGe,fT)=>{var a5=oo(),d5=Ot(),c5="[object Map]";function u5(e){return d5(e)&&a5(e)==c5}fT.exports=u5});var AT=A((vGe,yT)=>{var p5=mT(),l5=Ea(),hT=Tu(),gT=hT&&hT.isMap,f5=gT?l5(gT):p5;yT.exports=f5});var ST=A((SGe,vT)=>{var m5=oo(),h5=Ot(),g5="[object Set]";function y5(e){return h5(e)&&m5(e)==g5}vT.exports=y5});var RT=A((bGe,_T)=>{var A5=ST(),v5=Ea(),bT=Tu(),IT=bT&&bT.isSet,S5=IT?v5(IT):A5;_T.exports=S5});var Hh=A((IGe,xT)=>{var b5=Sa(),I5=Pu(),_5=Ia(),R5=sx(),E5=lx(),C5=xh(),P5=Th(),x5=_x(),T5=xx(),N5=kh(),w5=Ox(),O5=oo(),D5=Xx(),k5=cT(),M5=Vh(),L5=ve(),B5=no(),G5=AT(),U5=it(),z5=RT(),q5=Tn(),F5=sr(),j5=1,V5=2,H5=4,ET="[object Arguments]",Y5="[object Array]",K5="[object Boolean]",X5="[object Date]",$5="[object Error]",CT="[object Function]",W5="[object GeneratorFunction]",Q5="[object Map]",J5="[object Number]",PT="[object Object]",Z5="[object RegExp]",e7="[object Set]",t7="[object String]",n7="[object Symbol]",r7="[object WeakMap]",o7="[object ArrayBuffer]",s7="[object DataView]",i7="[object Float32Array]",a7="[object Float64Array]",d7="[object Int8Array]",c7="[object Int16Array]",u7="[object Int32Array]",p7="[object Uint8Array]",l7="[object Uint8ClampedArray]",f7="[object Uint16Array]",m7="[object Uint32Array]",ae={};ae[ET]=ae[Y5]=ae[o7]=ae[s7]=ae[K5]=ae[X5]=ae[i7]=ae[a7]=ae[d7]=ae[c7]=ae[u7]=ae[Q5]=ae[J5]=ae[PT]=ae[Z5]=ae[e7]=ae[t7]=ae[n7]=ae[p7]=ae[l7]=ae[f7]=ae[m7]=!0;ae[$5]=ae[CT]=ae[r7]=!1;function ku(e,t,n,r,o,s){var i,a=t&j5,d=t&V5,c=t&H5;if(n&&(i=o?n(e,r,o,s):n(e)),i!==void 0)return i;if(!U5(e))return e;var u=L5(e);if(u){if(i=D5(e),!a)return P5(e,i)}else{var p=O5(e),l=p==CT||p==W5;if(B5(e))return C5(e,a);if(p==PT||p==ET||l&&!o){if(i=d||l?{}:M5(e),!a)return d?T5(e,E5(i,e)):x5(e,R5(i,e))}else{if(!ae[p])return o?e:{};i=k5(e,p,a)}}s||(s=new b5);var f=s.get(e);if(f)return f;s.set(e,i),z5(e)?e.forEach(function(g){i.add(ku(g,t,n,g,e,s))}):G5(e)&&e.forEach(function(g,y){i.set(y,ku(g,t,n,y,e,s))});var h=c?d?w5:N5:d?F5:q5,m=u?void 0:h(e);return I5(m||e,function(g,y){m&&(y=g,g=e[y]),_5(i,y,ku(g,t,n,y,e,s))}),i}xT.exports=ku});var NT=A((_Ge,TT)=>{var h7=Hh(),g7=4;function y7(e){return h7(e,g7)}TT.exports=y7});var Mu=A((RGe,wT)=>{function A7(e){return function(){return e}}wT.exports=A7});var DT=A((EGe,OT)=>{function v7(e){return function(t,n,r){for(var o=-1,s=Object(t),i=r(t),a=i.length;a--;){var d=i[e?a:++o];if(n(s[d],d,s)===!1)break}return t}}OT.exports=v7});var Lu=A((CGe,kT)=>{var S7=DT(),b7=S7();kT.exports=b7});var Bu=A((PGe,MT)=>{var I7=Lu(),_7=Tn();function R7(e,t){return e&&I7(e,t,_7)}MT.exports=R7});var BT=A((xGe,LT)=>{var E7=tn();function C7(e,t){return function(n,r){if(n==null)return n;if(!E7(n))return e(n,r);for(var o=n.length,s=t?o:-1,i=Object(n);(t?s--:++s<o)&&r(i[s],s,i)!==!1;);return n}}LT.exports=C7});var wa=A((TGe,GT)=>{var P7=Bu(),x7=BT(),T7=x7(P7);GT.exports=T7});var ir=A((NGe,UT)=>{function N7(e){return e}UT.exports=N7});var Yh=A((wGe,zT)=>{var w7=ir();function O7(e){return typeof e=="function"?e:w7}zT.exports=O7});var Kh=A((OGe,qT)=>{var D7=Pu(),k7=wa(),M7=Yh(),L7=ve();function B7(e,t){var n=L7(e)?D7:k7;return n(e,M7(t))}qT.exports=B7});var Xh=A((DGe,FT)=>{FT.exports=Kh()});var VT=A((kGe,jT)=>{var G7=wa();function U7(e,t){var n=[];return G7(e,function(r,o,s){t(r,o,s)&&n.push(r)}),n}jT.exports=U7});var YT=A((MGe,HT)=>{var z7="__lodash_hash_undefined__";function q7(e){return this.__data__.set(e,z7),this}HT.exports=q7});var XT=A((LGe,KT)=>{function F7(e){return this.__data__.has(e)}KT.exports=F7});var $h=A((BGe,$T)=>{var j7=Cu(),V7=YT(),H7=XT();function Gu(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new j7;++t<n;)this.add(e[t])}Gu.prototype.add=Gu.prototype.push=V7;Gu.prototype.has=H7;$T.exports=Gu});var QT=A((GGe,WT)=>{function Y7(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}WT.exports=Y7});var Wh=A((UGe,JT)=>{function K7(e,t){return e.has(t)}JT.exports=K7});var Qh=A((zGe,ZT)=>{var X7=$h(),$7=QT(),W7=Wh(),Q7=1,J7=2;function Z7(e,t,n,r,o,s){var i=n&Q7,a=e.length,d=t.length;if(a!=d&&!(i&&d>a))return!1;var c=s.get(e),u=s.get(t);if(c&&u)return c==t&&u==e;var p=-1,l=!0,f=n&J7?new X7:void 0;for(s.set(e,t),s.set(t,e);++p<a;){var h=e[p],m=t[p];if(r)var g=i?r(m,h,p,t,e,s):r(h,m,p,e,t,s);if(g!==void 0){if(g)continue;l=!1;break}if(f){if(!$7(t,function(y,v){if(!W7(f,v)&&(h===y||o(h,y,n,r,s)))return f.push(v)})){l=!1;break}}else if(!(h===m||o(h,m,n,r,s))){l=!1;break}}return s.delete(e),s.delete(t),l}ZT.exports=Z7});var tN=A((qGe,eN)=>{function eQ(e){var t=-1,n=Array(e.size);return e.forEach(function(r,o){n[++t]=[o,r]}),n}eN.exports=eQ});var Uu=A((FGe,nN)=>{function tQ(e){var t=-1,n=Array(e.size);return e.forEach(function(r){n[++t]=r}),n}nN.exports=tQ});var aN=A((jGe,iN)=>{var rN=to(),oN=qh(),nQ=eo(),rQ=Qh(),oQ=tN(),sQ=Uu(),iQ=1,aQ=2,dQ="[object Boolean]",cQ="[object Date]",uQ="[object Error]",pQ="[object Map]",lQ="[object Number]",fQ="[object RegExp]",mQ="[object Set]",hQ="[object String]",gQ="[object Symbol]",yQ="[object ArrayBuffer]",AQ="[object DataView]",sN=rN?rN.prototype:void 0,Jh=sN?sN.valueOf:void 0;function vQ(e,t,n,r,o,s,i){switch(n){case AQ:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case yQ:return!(e.byteLength!=t.byteLength||!s(new oN(e),new oN(t)));case dQ:case cQ:case lQ:return nQ(+e,+t);case uQ:return e.name==t.name&&e.message==t.message;case fQ:case hQ:return e==t+"";case pQ:var a=oQ;case mQ:var d=r&iQ;if(a||(a=sQ),e.size!=t.size&&!d)return!1;var c=i.get(e);if(c)return c==t;r|=aQ,i.set(e,t);var u=rQ(a(e),a(t),r,o,s,i);return i.delete(e),u;case gQ:if(Jh)return Jh.call(e)==Jh.call(t)}return!1}iN.exports=vQ});var uN=A((VGe,cN)=>{var dN=kh(),SQ=1,bQ=Object.prototype,IQ=bQ.hasOwnProperty;function _Q(e,t,n,r,o,s){var i=n&SQ,a=dN(e),d=a.length,c=dN(t),u=c.length;if(d!=u&&!i)return!1;for(var p=d;p--;){var l=a[p];if(!(i?l in t:IQ.call(t,l)))return!1}var f=s.get(e),h=s.get(t);if(f&&h)return f==t&&h==e;var m=!0;s.set(e,t),s.set(t,e);for(var g=i;++p<d;){l=a[p];var y=e[l],v=t[l];if(r)var S=i?r(v,y,l,t,e,s):r(y,v,l,e,t,s);if(!(S===void 0?y===v||o(y,v,n,r,s):S)){m=!1;break}g||(g=l=="constructor")}if(m&&!g){var b=e.constructor,I=t.constructor;b!=I&&"constructor"in e&&"constructor"in t&&!(typeof b=="function"&&b instanceof b&&typeof I=="function"&&I instanceof I)&&(m=!1)}return s.delete(e),s.delete(t),m}cN.exports=_Q});var AN=A((HGe,yN)=>{var Zh=Sa(),RQ=Qh(),EQ=aN(),CQ=uN(),pN=oo(),lN=ve(),fN=no(),PQ=Is(),xQ=1,mN="[object Arguments]",hN="[object Array]",zu="[object Object]",TQ=Object.prototype,gN=TQ.hasOwnProperty;function NQ(e,t,n,r,o,s){var i=lN(e),a=lN(t),d=i?hN:pN(e),c=a?hN:pN(t);d=d==mN?zu:d,c=c==mN?zu:c;var u=d==zu,p=c==zu,l=d==c;if(l&&fN(e)){if(!fN(t))return!1;i=!0,u=!1}if(l&&!u)return s||(s=new Zh),i||PQ(e)?RQ(e,t,n,r,o,s):EQ(e,t,d,n,r,o,s);if(!(n&xQ)){var f=u&&gN.call(e,"__wrapped__"),h=p&&gN.call(t,"__wrapped__");if(f||h){var m=f?e.value():e,g=h?t.value():t;return s||(s=new Zh),o(m,g,n,r,s)}}return l?(s||(s=new Zh),CQ(e,t,n,r,o,s)):!1}yN.exports=NQ});var eg=A((YGe,bN)=>{var wQ=AN(),vN=Ot();function SN(e,t,n,r,o){return e===t?!0:e==null||t==null||!vN(e)&&!vN(t)?e!==e&&t!==t:wQ(e,t,n,r,SN,o)}bN.exports=SN});var _N=A((KGe,IN)=>{var OQ=Sa(),DQ=eg(),kQ=1,MQ=2;function LQ(e,t,n,r){var o=n.length,s=o,i=!r;if(e==null)return!s;for(e=Object(e);o--;){var a=n[o];if(i&&a[2]?a[1]!==e[a[0]]:!(a[0]in e))return!1}for(;++o<s;){a=n[o];var d=a[0],c=e[d],u=a[1];if(i&&a[2]){if(c===void 0&&!(d in e))return!1}else{var p=new OQ;if(r)var l=r(c,u,d,e,t,p);if(!(l===void 0?DQ(u,c,kQ|MQ,r,p):l))return!1}}return!0}IN.exports=LQ});var tg=A((XGe,RN)=>{var BQ=it();function GQ(e){return e===e&&!BQ(e)}RN.exports=GQ});var CN=A(($Ge,EN)=>{var UQ=tg(),zQ=Tn();function qQ(e){for(var t=zQ(e),n=t.length;n--;){var r=t[n],o=e[r];t[n]=[r,o,UQ(o)]}return t}EN.exports=qQ});var ng=A((WGe,PN)=>{function FQ(e,t){return function(n){return n==null?!1:n[e]===t&&(t!==void 0||e in Object(n))}}PN.exports=FQ});var TN=A((QGe,xN)=>{var jQ=_N(),VQ=CN(),HQ=ng();function YQ(e){var t=VQ(e);return t.length==1&&t[0][2]?HQ(t[0][0],t[0][1]):function(n){return n===e||jQ(n,e,t)}}xN.exports=YQ});var so=A((JGe,NN)=>{var KQ=rr(),XQ=Ot(),$Q="[object Symbol]";function WQ(e){return typeof e=="symbol"||XQ(e)&&KQ(e)==$Q}NN.exports=WQ});var qu=A((ZGe,wN)=>{var QQ=ve(),JQ=so(),ZQ=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,eJ=/^\w*$/;function tJ(e,t){if(QQ(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||JQ(e)?!0:eJ.test(e)||!ZQ.test(e)||t!=null&&e in Object(t)}wN.exports=tJ});var kN=A((e1e,DN)=>{var ON=Cu(),nJ="Expected a function";function rg(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(nJ);var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],s=n.cache;if(s.has(o))return s.get(o);var i=e.apply(this,r);return n.cache=s.set(o,i)||s,i};return n.cache=new(rg.Cache||ON),n}rg.Cache=ON;DN.exports=rg});var LN=A((t1e,MN)=>{var rJ=kN(),oJ=500;function sJ(e){var t=rJ(e,function(r){return n.size===oJ&&n.clear(),r}),n=t.cache;return t}MN.exports=sJ});var GN=A((n1e,BN)=>{var iJ=LN(),aJ=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,dJ=/\\(\\)?/g,cJ=iJ(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(aJ,function(n,r,o,s){t.push(o?s.replace(dJ,"$1"):r||n)}),t});BN.exports=cJ});var Oa=A((r1e,UN)=>{function uJ(e,t){for(var n=-1,r=e==null?0:e.length,o=Array(r);++n<r;)o[n]=t(e[n],n,e);return o}UN.exports=uJ});var HN=A((o1e,VN)=>{var zN=to(),pJ=Oa(),lJ=ve(),fJ=so(),mJ=1/0,qN=zN?zN.prototype:void 0,FN=qN?qN.toString:void 0;function jN(e){if(typeof e=="string")return e;if(lJ(e))return pJ(e,jN)+"";if(fJ(e))return FN?FN.call(e):"";var t=e+"";return t=="0"&&1/e==-mJ?"-0":t}VN.exports=jN});var og=A((s1e,YN)=>{var hJ=HN();function gJ(e){return e==null?"":hJ(e)}YN.exports=gJ});var Da=A((i1e,KN)=>{var yJ=ve(),AJ=qu(),vJ=GN(),SJ=og();function bJ(e,t){return yJ(e)?e:AJ(e,t)?[e]:vJ(SJ(e))}KN.exports=bJ});var Es=A((a1e,XN)=>{var IJ=so(),_J=1/0;function RJ(e){if(typeof e=="string"||IJ(e))return e;var t=e+"";return t=="0"&&1/e==-_J?"-0":t}XN.exports=RJ});var ka=A((d1e,$N)=>{var EJ=Da(),CJ=Es();function PJ(e,t){t=EJ(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[CJ(t[n++])];return n&&n==r?e:void 0}$N.exports=PJ});var QN=A((c1e,WN)=>{var xJ=ka();function TJ(e,t,n){var r=e==null?void 0:xJ(e,t);return r===void 0?n:r}WN.exports=TJ});var ZN=A((u1e,JN)=>{function NJ(e,t){return e!=null&&t in Object(e)}JN.exports=NJ});var sg=A((p1e,ew)=>{var wJ=Da(),OJ=vs(),DJ=ve(),kJ=Ra(),MJ=xu(),LJ=Es();function BJ(e,t,n){t=wJ(t,e);for(var r=-1,o=t.length,s=!1;++r<o;){var i=LJ(t[r]);if(!(s=e!=null&&n(e,i)))break;e=e[i]}return s||++r!=o?s:(o=e==null?0:e.length,!!o&&MJ(o)&&kJ(i,o)&&(DJ(e)||OJ(e)))}ew.exports=BJ});var ig=A((l1e,tw)=>{var GJ=ZN(),UJ=sg();function zJ(e,t){return e!=null&&UJ(e,t,GJ)}tw.exports=zJ});var rw=A((f1e,nw)=>{var qJ=eg(),FJ=QN(),jJ=ig(),VJ=qu(),HJ=tg(),YJ=ng(),KJ=Es(),XJ=1,$J=2;function WJ(e,t){return VJ(e)&&HJ(t)?YJ(KJ(e),t):function(n){var r=FJ(n,e);return r===void 0&&r===t?jJ(n,e):qJ(t,r,XJ|$J)}}nw.exports=WJ});var ag=A((m1e,ow)=>{function QJ(e){return function(t){return t==null?void 0:t[e]}}ow.exports=QJ});var iw=A((h1e,sw)=>{var JJ=ka();function ZJ(e){return function(t){return JJ(t,e)}}sw.exports=ZJ});var dw=A((g1e,aw)=>{var eZ=ag(),tZ=iw(),nZ=qu(),rZ=Es();function oZ(e){return nZ(e)?eZ(rZ(e)):tZ(e)}aw.exports=oZ});var nn=A((y1e,cw)=>{var sZ=TN(),iZ=rw(),aZ=ir(),dZ=ve(),cZ=dw();function uZ(e){return typeof e=="function"?e:e==null?aZ:typeof e=="object"?dZ(e)?iZ(e[0],e[1]):sZ(e):cZ(e)}cw.exports=uZ});var dg=A((A1e,uw)=>{var pZ=Nh(),lZ=VT(),fZ=nn(),mZ=ve();function hZ(e,t){var n=mZ(e)?pZ:lZ;return n(e,fZ(t,3))}uw.exports=hZ});var lw=A((v1e,pw)=>{var gZ=Object.prototype,yZ=gZ.hasOwnProperty;function AZ(e,t){return e!=null&&yZ.call(e,t)}pw.exports=AZ});var cg=A((S1e,fw)=>{var vZ=lw(),SZ=sg();function bZ(e,t){return e!=null&&SZ(e,t,vZ)}fw.exports=bZ});var hw=A((b1e,mw)=>{var IZ=Nu(),_Z=oo(),RZ=vs(),EZ=ve(),CZ=tn(),PZ=no(),xZ=xa(),TZ=Is(),NZ="[object Map]",wZ="[object Set]",OZ=Object.prototype,DZ=OZ.hasOwnProperty;function kZ(e){if(e==null)return!0;if(CZ(e)&&(EZ(e)||typeof e=="string"||typeof e.splice=="function"||PZ(e)||TZ(e)||RZ(e)))return!e.length;var t=_Z(e);if(t==NZ||t==wZ)return!e.size;if(xZ(e))return!IZ(e).length;for(var n in e)if(DZ.call(e,n))return!1;return!0}mw.exports=kZ});var ug=A((I1e,gw)=>{function MZ(e){return e===void 0}gw.exports=MZ});var pg=A((_1e,yw)=>{var LZ=wa(),BZ=tn();function GZ(e,t){var n=-1,r=BZ(e)?Array(e.length):[];return LZ(e,function(o,s,i){r[++n]=t(o,s,i)}),r}yw.exports=GZ});var lg=A((R1e,Aw)=>{var UZ=Oa(),zZ=nn(),qZ=pg(),FZ=ve();function jZ(e,t){var n=FZ(e)?UZ:qZ;return n(e,zZ(t,3))}Aw.exports=jZ});var Sw=A((E1e,vw)=>{function VZ(e,t,n,r){var o=-1,s=e==null?0:e.length;for(r&&s&&(n=e[++o]);++o<s;)n=t(n,e[o],o,e);return n}vw.exports=VZ});var Iw=A((C1e,bw)=>{function HZ(e,t,n,r,o){return o(e,function(s,i,a){n=r?(r=!1,s):t(n,s,i,a)}),n}bw.exports=HZ});var fg=A((P1e,_w)=>{var YZ=Sw(),KZ=wa(),XZ=nn(),$Z=Iw(),WZ=ve();function QZ(e,t,n){var r=WZ(e)?YZ:$Z,o=arguments.length<3;return r(e,XZ(t,4),n,o,KZ)}_w.exports=QZ});var Ew=A((x1e,Rw)=>{var JZ=rr(),ZZ=ve(),eee=Ot(),tee="[object String]";function nee(e){return typeof e=="string"||!ZZ(e)&&eee(e)&&JZ(e)==tee}Rw.exports=nee});var Pw=A((T1e,Cw)=>{var ree=ag(),oee=ree("length");Cw.exports=oee});var Tw=A((N1e,xw)=>{var see="\\ud800-\\udfff",iee="\\u0300-\\u036f",aee="\\ufe20-\\ufe2f",dee="\\u20d0-\\u20ff",cee=iee+aee+dee,uee="\\ufe0e\\ufe0f",pee="\\u200d",lee=RegExp("["+pee+see+cee+uee+"]");function fee(e){return lee.test(e)}xw.exports=fee});var Gw=A((w1e,Bw)=>{var ww="\\ud800-\\udfff",mee="\\u0300-\\u036f",hee="\\ufe20-\\ufe2f",gee="\\u20d0-\\u20ff",yee=mee+hee+gee,Aee="\\ufe0e\\ufe0f",vee="["+ww+"]",mg="["+yee+"]",hg="\\ud83c[\\udffb-\\udfff]",See="(?:"+mg+"|"+hg+")",Ow="[^"+ww+"]",Dw="(?:\\ud83c[\\udde6-\\uddff]){2}",kw="[\\ud800-\\udbff][\\udc00-\\udfff]",bee="\\u200d",Mw=See+"?",Lw="["+Aee+"]?",Iee="(?:"+bee+"(?:"+[Ow,Dw,kw].join("|")+")"+Lw+Mw+")*",_ee=Lw+Mw+Iee,Ree="(?:"+[Ow+mg+"?",mg,Dw,kw,vee].join("|")+")",Nw=RegExp(hg+"(?="+hg+")|"+Ree+_ee,"g");function Eee(e){for(var t=Nw.lastIndex=0;Nw.test(e);)++t;return t}Bw.exports=Eee});var zw=A((O1e,Uw)=>{var Cee=Pw(),Pee=Tw(),xee=Gw();function Tee(e){return Pee(e)?xee(e):Cee(e)}Uw.exports=Tee});var Fw=A((D1e,qw)=>{var Nee=Nu(),wee=oo(),Oee=tn(),Dee=Ew(),kee=zw(),Mee="[object Map]",Lee="[object Set]";function Bee(e){if(e==null)return 0;if(Oee(e))return Dee(e)?kee(e):e.length;var t=wee(e);return t==Mee||t==Lee?e.size:Nee(e).length}qw.exports=Bee});var Vw=A((k1e,jw)=>{var Gee=Pu(),Uee=jh(),zee=Bu(),qee=nn(),Fee=Na(),jee=ve(),Vee=no(),Hee=ms(),Yee=it(),Kee=Is();function Xee(e,t,n){var r=jee(e),o=r||Vee(e)||Kee(e);if(t=qee(t,4),n==null){var s=e&&e.constructor;o?n=r?new s:[]:Yee(e)?n=Hee(s)?Uee(Fee(e)):{}:n={}}return(o?Gee:zee)(e,function(i,a,d){return t(n,i,a,d)}),n}jw.exports=Xee});var Xw=A((M1e,Kw)=>{var Hw=to(),$ee=vs(),Wee=ve(),Yw=Hw?Hw.isConcatSpreadable:void 0;function Qee(e){return Wee(e)||$ee(e)||!!(Yw&&e&&e[Yw])}Kw.exports=Qee});var Fu=A((L1e,Ww)=>{var Jee=Ou(),Zee=Xw();function $w(e,t,n,r,o){var s=-1,i=e.length;for(n||(n=Zee),o||(o=[]);++s<i;){var a=e[s];t>0&&n(a)?t>1?$w(a,t-1,n,r,o):Jee(o,a):r||(o[o.length]=a)}return o}Ww.exports=$w});var Jw=A((B1e,Qw)=>{function ete(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}Qw.exports=ete});var gg=A((G1e,eO)=>{var tte=Jw(),Zw=Math.max;function nte(e,t,n){return t=Zw(t===void 0?e.length-1:t,0),function(){for(var r=arguments,o=-1,s=Zw(r.length-t,0),i=Array(s);++o<s;)i[o]=r[t+o];o=-1;for(var a=Array(t+1);++o<t;)a[o]=r[o];return a[t]=n(i),tte(e,this,a)}}eO.exports=nte});var rO=A((U1e,nO)=>{var rte=Mu(),tO=Rh(),ote=ir(),ste=tO?function(e,t){return tO(e,"toString",{configurable:!0,enumerable:!1,value:rte(t),writable:!0})}:ote;nO.exports=ste});var sO=A((z1e,oO)=>{var ite=800,ate=16,dte=Date.now;function cte(e){var t=0,n=0;return function(){var r=dte(),o=ate-(r-n);if(n=r,o>0){if(++t>=ite)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}oO.exports=cte});var yg=A((q1e,iO)=>{var ute=rO(),pte=sO(),lte=pte(ute);iO.exports=lte});var Ma=A((F1e,aO)=>{var fte=ir(),mte=gg(),hte=yg();function gte(e,t){return hte(mte(e,t,fte),e+"")}aO.exports=gte});var Ag=A((j1e,dO)=>{function yte(e,t,n,r){for(var o=e.length,s=n+(r?1:-1);r?s--:++s<o;)if(t(e[s],s,e))return s;return-1}dO.exports=yte});var uO=A((V1e,cO)=>{function Ate(e){return e!==e}cO.exports=Ate});var lO=A((H1e,pO)=>{function vte(e,t,n){for(var r=n-1,o=e.length;++r<o;)if(e[r]===t)return r;return-1}pO.exports=vte});var mO=A((Y1e,fO)=>{var Ste=Ag(),bte=uO(),Ite=lO();function _te(e,t,n){return t===t?Ite(e,t,n):Ste(e,bte,n)}fO.exports=_te});var gO=A((K1e,hO)=>{var Rte=mO();function Ete(e,t){var n=e==null?0:e.length;return!!n&&Rte(e,t,0)>-1}hO.exports=Ete});var AO=A((X1e,yO)=>{function Cte(e,t,n){for(var r=-1,o=e==null?0:e.length;++r<o;)if(n(t,e[r]))return!0;return!1}yO.exports=Cte});var SO=A(($1e,vO)=>{function Pte(){}vO.exports=Pte});var IO=A((W1e,bO)=>{var vg=Mh(),xte=SO(),Tte=Uu(),Nte=1/0,wte=vg&&1/Tte(new vg([,-0]))[1]==Nte?function(e){return new vg(e)}:xte;bO.exports=wte});var RO=A((Q1e,_O)=>{var Ote=$h(),Dte=gO(),kte=AO(),Mte=Wh(),Lte=IO(),Bte=Uu(),Gte=200;function Ute(e,t,n){var r=-1,o=Dte,s=e.length,i=!0,a=[],d=a;if(n)i=!1,o=kte;else if(s>=Gte){var c=t?null:Lte(e);if(c)return Bte(c);i=!1,o=Mte,d=new Ote}else d=t?[]:a;e:for(;++r<s;){var u=e[r],p=t?t(u):u;if(u=n||u!==0?u:0,i&&p===p){for(var l=d.length;l--;)if(d[l]===p)continue e;t&&d.push(p),a.push(u)}else o(d,p,n)||(d!==a&&d.push(p),a.push(u))}return a}_O.exports=Ute});var Sg=A((J1e,EO)=>{var zte=tn(),qte=Ot();function Fte(e){return qte(e)&&zte(e)}EO.exports=Fte});var PO=A((Z1e,CO)=>{var jte=Fu(),Vte=Ma(),Hte=RO(),Yte=Sg(),Kte=Vte(function(e){return Hte(jte(e,1,Yte,!0))});CO.exports=Kte});var TO=A((eUe,xO)=>{var Xte=Oa();function $te(e,t){return Xte(t,function(n){return e[n]})}xO.exports=$te});var bg=A((tUe,NO)=>{var Wte=TO(),Qte=Tn();function Jte(e){return e==null?[]:Wte(e,Qte(e))}NO.exports=Jte});var at=A((nUe,wO)=>{var ju;if(typeof require=="function")try{ju={clone:NT(),constant:Mu(),each:Xh(),filter:dg(),has:cg(),isArray:ve(),isEmpty:hw(),isFunction:ms(),isUndefined:ug(),keys:Tn(),map:lg(),reduce:fg(),size:Fw(),transform:Vw(),union:PO(),values:bg()}}catch{}ju||(ju=window._);wO.exports=ju});var Vu=A((rUe,MO)=>{"use strict";var D=at();MO.exports=G;var Zte="\0",io="\0",OO="";function G(e){this._isDirected=D.has(e,"directed")?e.directed:!0,this._isMultigraph=D.has(e,"multigraph")?e.multigraph:!1,this._isCompound=D.has(e,"compound")?e.compound:!1,this._label=void 0,this._defaultNodeLabelFn=D.constant(void 0),this._defaultEdgeLabelFn=D.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[io]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}G.prototype._nodeCount=0;G.prototype._edgeCount=0;G.prototype.isDirected=function(){return this._isDirected};G.prototype.isMultigraph=function(){return this._isMultigraph};G.prototype.isCompound=function(){return this._isCompound};G.prototype.setGraph=function(e){return this._label=e,this};G.prototype.graph=function(){return this._label};G.prototype.setDefaultNodeLabel=function(e){return D.isFunction(e)||(e=D.constant(e)),this._defaultNodeLabelFn=e,this};G.prototype.nodeCount=function(){return this._nodeCount};G.prototype.nodes=function(){return D.keys(this._nodes)};G.prototype.sources=function(){var e=this;return D.filter(this.nodes(),function(t){return D.isEmpty(e._in[t])})};G.prototype.sinks=function(){var e=this;return D.filter(this.nodes(),function(t){return D.isEmpty(e._out[t])})};G.prototype.setNodes=function(e,t){var n=arguments,r=this;return D.each(e,function(o){n.length>1?r.setNode(o,t):r.setNode(o)}),this};G.prototype.setNode=function(e,t){return D.has(this._nodes,e)?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=io,this._children[e]={},this._children[io][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)};G.prototype.node=function(e){return this._nodes[e]};G.prototype.hasNode=function(e){return D.has(this._nodes,e)};G.prototype.removeNode=function(e){var t=this;if(D.has(this._nodes,e)){var n=function(r){t.removeEdge(t._edgeObjs[r])};delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],D.each(this.children(e),function(r){t.setParent(r)}),delete this._children[e]),D.each(D.keys(this._in[e]),n),delete this._in[e],delete this._preds[e],D.each(D.keys(this._out[e]),n),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this};G.prototype.setParent=function(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(D.isUndefined(t))t=io;else{t+="";for(var n=t;!D.isUndefined(n);n=this.parent(n))if(n===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this};G.prototype._removeFromParentsChildList=function(e){delete this._children[this._parent[e]][e]};G.prototype.parent=function(e){if(this._isCompound){var t=this._parent[e];if(t!==io)return t}};G.prototype.children=function(e){if(D.isUndefined(e)&&(e=io),this._isCompound){var t=this._children[e];if(t)return D.keys(t)}else{if(e===io)return this.nodes();if(this.hasNode(e))return[]}};G.prototype.predecessors=function(e){var t=this._preds[e];if(t)return D.keys(t)};G.prototype.successors=function(e){var t=this._sucs[e];if(t)return D.keys(t)};G.prototype.neighbors=function(e){var t=this.predecessors(e);if(t)return D.union(t,this.successors(e))};G.prototype.isLeaf=function(e){var t;return this.isDirected()?t=this.successors(e):t=this.neighbors(e),t.length===0};G.prototype.filterNodes=function(e){var t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph());var n=this;D.each(this._nodes,function(s,i){e(i)&&t.setNode(i,s)}),D.each(this._edgeObjs,function(s){t.hasNode(s.v)&&t.hasNode(s.w)&&t.setEdge(s,n.edge(s))});var r={};function o(s){var i=n.parent(s);return i===void 0||t.hasNode(i)?(r[s]=i,i):i in r?r[i]:o(i)}return this._isCompound&&D.each(t.nodes(),function(s){t.setParent(s,o(s))}),t};G.prototype.setDefaultEdgeLabel=function(e){return D.isFunction(e)||(e=D.constant(e)),this._defaultEdgeLabelFn=e,this};G.prototype.edgeCount=function(){return this._edgeCount};G.prototype.edges=function(){return D.values(this._edgeObjs)};G.prototype.setPath=function(e,t){var n=this,r=arguments;return D.reduce(e,function(o,s){return r.length>1?n.setEdge(o,s,t):n.setEdge(o,s),s}),this};G.prototype.setEdge=function(){var e,t,n,r,o=!1,s=arguments[0];typeof s=="object"&&s!==null&&"v"in s?(e=s.v,t=s.w,n=s.name,arguments.length===2&&(r=arguments[1],o=!0)):(e=s,t=arguments[1],n=arguments[3],arguments.length>2&&(r=arguments[2],o=!0)),e=""+e,t=""+t,D.isUndefined(n)||(n=""+n);var i=La(this._isDirected,e,t,n);if(D.has(this._edgeLabels,i))return o&&(this._edgeLabels[i]=r),this;if(!D.isUndefined(n)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(t),this._edgeLabels[i]=o?r:this._defaultEdgeLabelFn(e,t,n);var a=ene(this._isDirected,e,t,n);return e=a.v,t=a.w,Object.freeze(a),this._edgeObjs[i]=a,DO(this._preds[t],e),DO(this._sucs[e],t),this._in[t][i]=a,this._out[e][i]=a,this._edgeCount++,this};G.prototype.edge=function(e,t,n){var r=arguments.length===1?Ig(this._isDirected,arguments[0]):La(this._isDirected,e,t,n);return this._edgeLabels[r]};G.prototype.hasEdge=function(e,t,n){var r=arguments.length===1?Ig(this._isDirected,arguments[0]):La(this._isDirected,e,t,n);return D.has(this._edgeLabels,r)};G.prototype.removeEdge=function(e,t,n){var r=arguments.length===1?Ig(this._isDirected,arguments[0]):La(this._isDirected,e,t,n),o=this._edgeObjs[r];return o&&(e=o.v,t=o.w,delete this._edgeLabels[r],delete this._edgeObjs[r],kO(this._preds[t],e),kO(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--),this};G.prototype.inEdges=function(e,t){var n=this._in[e];if(n){var r=D.values(n);return t?D.filter(r,function(o){return o.v===t}):r}};G.prototype.outEdges=function(e,t){var n=this._out[e];if(n){var r=D.values(n);return t?D.filter(r,function(o){return o.w===t}):r}};G.prototype.nodeEdges=function(e,t){var n=this.inEdges(e,t);if(n)return n.concat(this.outEdges(e,t))};function DO(e,t){e[t]?e[t]++:e[t]=1}function kO(e,t){--e[t]||delete e[t]}function La(e,t,n,r){var o=""+t,s=""+n;if(!e&&o>s){var i=o;o=s,s=i}return o+OO+s+OO+(D.isUndefined(r)?Zte:r)}function ene(e,t,n,r){var o=""+t,s=""+n;if(!e&&o>s){var i=o;o=s,s=i}var a={v:o,w:s};return r&&(a.name=r),a}function Ig(e,t){return La(e,t.v,t.w,t.name)}});var BO=A((oUe,LO)=>{LO.exports="2.1.8"});var UO=A((sUe,GO)=>{GO.exports={Graph:Vu(),version:BO()}});var qO=A((iUe,zO)=>{var rn=at(),tne=Vu();zO.exports={write:nne,read:sne};function nne(e){var t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:rne(e),edges:one(e)};return rn.isUndefined(e.graph())||(t.value=rn.clone(e.graph())),t}function rne(e){return rn.map(e.nodes(),function(t){var n=e.node(t),r=e.parent(t),o={v:t};return rn.isUndefined(n)||(o.value=n),rn.isUndefined(r)||(o.parent=r),o})}function one(e){return rn.map(e.edges(),function(t){var n=e.edge(t),r={v:t.v,w:t.w};return rn.isUndefined(t.name)||(r.name=t.name),rn.isUndefined(n)||(r.value=n),r})}function sne(e){var t=new tne(e.options).setGraph(e.value);return rn.each(e.nodes,function(n){t.setNode(n.v,n.value),n.parent&&t.setParent(n.v,n.parent)}),rn.each(e.edges,function(n){t.setEdge({v:n.v,w:n.w,name:n.name},n.value)}),t}});var jO=A((aUe,FO)=>{var Hu=at();FO.exports=ine;function ine(e){var t={},n=[],r;function o(s){Hu.has(t,s)||(t[s]=!0,r.push(s),Hu.each(e.successors(s),o),Hu.each(e.predecessors(s),o))}return Hu.each(e.nodes(),function(s){r=[],o(s),r.length&&n.push(r)}),n}});var _g=A((dUe,HO)=>{var VO=at();HO.exports=At;function At(){this._arr=[],this._keyIndices={}}At.prototype.size=function(){return this._arr.length};At.prototype.keys=function(){return this._arr.map(function(e){return e.key})};At.prototype.has=function(e){return VO.has(this._keyIndices,e)};At.prototype.priority=function(e){var t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority};At.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key};At.prototype.add=function(e,t){var n=this._keyIndices;if(e=String(e),!VO.has(n,e)){var r=this._arr,o=r.length;return n[e]=o,r.push({key:e,priority:t}),this._decrease(o),!0}return!1};At.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key};At.prototype.decrease=function(e,t){var n=this._keyIndices[e];if(t>this._arr[n].priority)throw new Error("New priority is greater than current priority. Key: "+e+" Old: "+this._arr[n].priority+" New: "+t);this._arr[n].priority=t,this._decrease(n)};At.prototype._heapify=function(e){var t=this._arr,n=2*e,r=n+1,o=e;n<t.length&&(o=t[n].priority<t[o].priority?n:o,r<t.length&&(o=t[r].priority<t[o].priority?r:o),o!==e&&(this._swap(e,o),this._heapify(o)))};At.prototype._decrease=function(e){for(var t=this._arr,n=t[e].priority,r;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r};At.prototype._swap=function(e,t){var n=this._arr,r=this._keyIndices,o=n[e],s=n[t];n[e]=s,n[t]=o,r[s.key]=e,r[o.key]=t}});var Rg=A((cUe,YO)=>{var ane=at(),dne=_g();YO.exports=une;var cne=ane.constant(1);function une(e,t,n,r){return pne(e,String(t),n||cne,r||function(o){return e.outEdges(o)})}function pne(e,t,n,r){var o={},s=new dne,i,a,d=function(c){var u=c.v!==i?c.v:c.w,p=o[u],l=n(c),f=a.distance+l;if(l<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+c+" Weight: "+l);f<p.distance&&(p.distance=f,p.predecessor=i,s.decrease(u,f))};for(e.nodes().forEach(function(c){var u=c===t?0:Number.POSITIVE_INFINITY;o[c]={distance:u},s.add(c,u)});s.size()>0&&(i=s.removeMin(),a=o[i],a.distance!==Number.POSITIVE_INFINITY);)r(i).forEach(d);return o}});var XO=A((uUe,KO)=>{var lne=Rg(),fne=at();KO.exports=mne;function mne(e,t,n){return fne.transform(e.nodes(),function(r,o){r[o]=lne(e,o,t,n)},{})}});var Eg=A((pUe,WO)=>{var $O=at();WO.exports=hne;function hne(e){var t=0,n=[],r={},o=[];function s(i){var a=r[i]={onStack:!0,lowlink:t,index:t++};if(n.push(i),e.successors(i).forEach(function(u){$O.has(r,u)?r[u].onStack&&(a.lowlink=Math.min(a.lowlink,r[u].index)):(s(u),a.lowlink=Math.min(a.lowlink,r[u].lowlink))}),a.lowlink===a.index){var d=[],c;do c=n.pop(),r[c].onStack=!1,d.push(c);while(i!==c);o.push(d)}}return e.nodes().forEach(function(i){$O.has(r,i)||s(i)}),o}});var JO=A((lUe,QO)=>{var gne=at(),yne=Eg();QO.exports=Ane;function Ane(e){return gne.filter(yne(e),function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}});var eD=A((fUe,ZO)=>{var vne=at();ZO.exports=bne;var Sne=vne.constant(1);function bne(e,t,n){return Ine(e,t||Sne,n||function(r){return e.outEdges(r)})}function Ine(e,t,n){var r={},o=e.nodes();return o.forEach(function(s){r[s]={},r[s][s]={distance:0},o.forEach(function(i){s!==i&&(r[s][i]={distance:Number.POSITIVE_INFINITY})}),n(s).forEach(function(i){var a=i.v===s?i.w:i.v,d=t(i);r[s][a]={distance:d,predecessor:s}})}),o.forEach(function(s){var i=r[s];o.forEach(function(a){var d=r[a];o.forEach(function(c){var u=d[s],p=i[c],l=d[c],f=u.distance+p.distance;f<l.distance&&(l.distance=f,l.predecessor=p.predecessor)})})}),r}});var Cg=A((mUe,nD)=>{var Ba=at();nD.exports=tD;tD.CycleException=Yu;function tD(e){var t={},n={},r=[];function o(s){if(Ba.has(n,s))throw new Yu;Ba.has(t,s)||(n[s]=!0,t[s]=!0,Ba.each(e.predecessors(s),o),delete n[s],r.push(s))}if(Ba.each(e.sinks(),o),Ba.size(t)!==e.nodeCount())throw new Yu;return r}function Yu(){}Yu.prototype=new Error});var sD=A((hUe,oD)=>{var rD=Cg();oD.exports=_ne;function _ne(e){try{rD(e)}catch(t){if(t instanceof rD.CycleException)return!1;throw t}return!0}});var Pg=A((gUe,aD)=>{var Ku=at();aD.exports=Rne;function Rne(e,t,n){Ku.isArray(t)||(t=[t]);var r=(e.isDirected()?e.successors:e.neighbors).bind(e),o=[],s={};return Ku.each(t,function(i){if(!e.hasNode(i))throw new Error("Graph does not have node: "+i);iD(e,i,n==="post",s,r,o)}),o}function iD(e,t,n,r,o,s){Ku.has(r,t)||(r[t]=!0,n||s.push(t),Ku.each(o(t),function(i){iD(e,i,n,r,o,s)}),n&&s.push(t))}});var cD=A((yUe,dD)=>{var Ene=Pg();dD.exports=Cne;function Cne(e,t){return Ene(e,t,"post")}});var pD=A((AUe,uD)=>{var Pne=Pg();uD.exports=xne;function xne(e,t){return Pne(e,t,"pre")}});var mD=A((vUe,fD)=>{var lD=at(),Tne=Vu(),Nne=_g();fD.exports=wne;function wne(e,t){var n=new Tne,r={},o=new Nne,s;function i(d){var c=d.v===s?d.w:d.v,u=o.priority(c);if(u!==void 0){var p=t(d);p<u&&(r[c]=s,o.decrease(c,p))}}if(e.nodeCount()===0)return n;lD.each(e.nodes(),function(d){o.add(d,Number.POSITIVE_INFINITY),n.setNode(d)}),o.decrease(e.nodes()[0],0);for(var a=!1;o.size()>0;){if(s=o.removeMin(),lD.has(r,s))n.setEdge(s,r[s]);else{if(a)throw new Error("Input graph is not connected: "+e);a=!0}e.nodeEdges(s).forEach(i)}return n}});var gD=A((SUe,hD)=>{hD.exports={components:jO(),dijkstra:Rg(),dijkstraAll:XO(),findCycles:JO(),floydWarshall:eD(),isAcyclic:sD(),postorder:cD(),preorder:pD(),prim:mD(),tarjan:Eg(),topsort:Cg()}});var vD=A((bUe,AD)=>{var yD=UO();AD.exports={Graph:yD.Graph,json:qO(),alg:gD(),version:yD.version}});var vt=A((IUe,SD)=>{var Xu;if(typeof require=="function")try{Xu=vD()}catch{}Xu||(Xu=window.graphlib);SD.exports=Xu});var ID=A((_Ue,bD)=>{var One=Hh(),Dne=1,kne=4;function Mne(e){return One(e,Dne|kne)}bD.exports=Mne});var Ga=A((RUe,_D)=>{var Lne=eo(),Bne=tn(),Gne=Ra(),Une=it();function zne(e,t,n){if(!Une(n))return!1;var r=typeof t;return(r=="number"?Bne(n)&&Gne(t,n.length):r=="string"&&t in n)?Lne(n[t],e):!1}_D.exports=zne});var CD=A((EUe,ED)=>{var qne=Ma(),Fne=eo(),jne=Ga(),Vne=sr(),RD=Object.prototype,Hne=RD.hasOwnProperty,Yne=qne(function(e,t){e=Object(e);var n=-1,r=t.length,o=r>2?t[2]:void 0;for(o&&jne(t[0],t[1],o)&&(r=1);++n<r;)for(var s=t[n],i=Vne(s),a=-1,d=i.length;++a<d;){var c=i[a],u=e[c];(u===void 0||Fne(u,RD[c])&&!Hne.call(e,c))&&(e[c]=s[c])}return e});ED.exports=Yne});var xD=A((CUe,PD)=>{var Kne=nn(),Xne=tn(),$ne=Tn();function Wne(e){return function(t,n,r){var o=Object(t);if(!Xne(t)){var s=Kne(n,3);t=$ne(t),n=function(a){return s(o[a],a,o)}}var i=e(t,n,r);return i>-1?o[s?t[i]:i]:void 0}}PD.exports=Wne});var ND=A((PUe,TD)=>{var Qne=/\s/;function Jne(e){for(var t=e.length;t--&&Qne.test(e.charAt(t)););return t}TD.exports=Jne});var OD=A((xUe,wD)=>{var Zne=ND(),ere=/^\s+/;function tre(e){return e&&e.slice(0,Zne(e)+1).replace(ere,"")}wD.exports=tre});var LD=A((TUe,MD)=>{var nre=OD(),DD=it(),rre=so(),kD=0/0,ore=/^[-+]0x[0-9a-f]+$/i,sre=/^0b[01]+$/i,ire=/^0o[0-7]+$/i,are=parseInt;function dre(e){if(typeof e=="number")return e;if(rre(e))return kD;if(DD(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=DD(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=nre(e);var n=sre.test(e);return n||ire.test(e)?are(e.slice(2),n?2:8):ore.test(e)?kD:+e}MD.exports=dre});var xg=A((NUe,GD)=>{var cre=LD(),BD=1/0,ure=17976931348623157e292;function pre(e){if(!e)return e===0?e:0;if(e=cre(e),e===BD||e===-BD){var t=e<0?-1:1;return t*ure}return e===e?e:0}GD.exports=pre});var zD=A((wUe,UD)=>{var lre=xg();function fre(e){var t=lre(e),n=t%1;return t===t?n?t-n:t:0}UD.exports=fre});var FD=A((OUe,qD)=>{var mre=Ag(),hre=nn(),gre=zD(),yre=Math.max;function Are(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var o=n==null?0:gre(n);return o<0&&(o=yre(r+o,0)),mre(e,hre(t,3),o)}qD.exports=Are});var VD=A((DUe,jD)=>{var vre=xD(),Sre=FD(),bre=vre(Sre);jD.exports=bre});var Tg=A((kUe,HD)=>{var Ire=Fu();function _re(e){var t=e==null?0:e.length;return t?Ire(e,1):[]}HD.exports=_re});var KD=A((MUe,YD)=>{var Rre=Lu(),Ere=Yh(),Cre=sr();function Pre(e,t){return e==null?e:Rre(e,Ere(t),Cre)}YD.exports=Pre});var $D=A((LUe,XD)=>{function xre(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}XD.exports=xre});var QD=A((BUe,WD)=>{var Tre=ba(),Nre=Bu(),wre=nn();function Ore(e,t){var n={};return t=wre(t,3),Nre(e,function(r,o,s){Tre(n,o,t(r,o,s))}),n}WD.exports=Ore});var $u=A((GUe,JD)=>{var Dre=so();function kre(e,t,n){for(var r=-1,o=e.length;++r<o;){var s=e[r],i=t(s);if(i!=null&&(a===void 0?i===i&&!Dre(i):n(i,a)))var a=i,d=s}return d}JD.exports=kre});var ek=A((UUe,ZD)=>{function Mre(e,t){return e>t}ZD.exports=Mre});var nk=A((zUe,tk)=>{var Lre=$u(),Bre=ek(),Gre=ir();function Ure(e){return e&&e.length?Lre(e,Gre,Bre):void 0}tk.exports=Ure});var Ng=A((qUe,rk)=>{var zre=ba(),qre=eo();function Fre(e,t,n){(n!==void 0&&!qre(e[t],n)||n===void 0&&!(t in e))&&zre(e,t,n)}rk.exports=Fre});var ik=A((FUe,sk)=>{var jre=rr(),Vre=Na(),Hre=Ot(),Yre="[object Object]",Kre=Function.prototype,Xre=Object.prototype,ok=Kre.toString,$re=Xre.hasOwnProperty,Wre=ok.call(Object);function Qre(e){if(!Hre(e)||jre(e)!=Yre)return!1;var t=Vre(e);if(t===null)return!0;var n=$re.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&ok.call(n)==Wre}sk.exports=Qre});var wg=A((jUe,ak)=>{function Jre(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}ak.exports=Jre});var ck=A((VUe,dk)=>{var Zre=As(),eoe=sr();function toe(e){return Zre(e,eoe(e))}dk.exports=toe});var hk=A((HUe,mk)=>{var uk=Ng(),noe=xh(),roe=Fh(),ooe=Th(),soe=Vh(),pk=vs(),lk=ve(),ioe=Sg(),aoe=no(),doe=ms(),coe=it(),uoe=ik(),poe=Is(),fk=wg(),loe=ck();function foe(e,t,n,r,o,s,i){var a=fk(e,n),d=fk(t,n),c=i.get(d);if(c){uk(e,n,c);return}var u=s?s(a,d,n+"",e,t,i):void 0,p=u===void 0;if(p){var l=lk(d),f=!l&&aoe(d),h=!l&&!f&&poe(d);u=d,l||f||h?lk(a)?u=a:ioe(a)?u=ooe(a):f?(p=!1,u=noe(d,!0)):h?(p=!1,u=roe(d,!0)):u=[]:uoe(d)||pk(d)?(u=a,pk(a)?u=loe(a):(!coe(a)||doe(a))&&(u=soe(d))):p=!1}p&&(i.set(d,u),o(u,d,r,s,i),i.delete(d)),uk(e,n,u)}mk.exports=foe});var Ak=A((YUe,yk)=>{var moe=Sa(),hoe=Ng(),goe=Lu(),yoe=hk(),Aoe=it(),voe=sr(),Soe=wg();function gk(e,t,n,r,o){e!==t&&goe(t,function(s,i){if(o||(o=new moe),Aoe(s))yoe(e,t,i,n,gk,r,o);else{var a=r?r(Soe(e,i),s,i+"",e,t,o):void 0;a===void 0&&(a=s),hoe(e,i,a)}},voe)}yk.exports=gk});var Sk=A((KUe,vk)=>{var boe=Ma(),Ioe=Ga();function _oe(e){return boe(function(t,n){var r=-1,o=n.length,s=o>1?n[o-1]:void 0,i=o>2?n[2]:void 0;for(s=e.length>3&&typeof s=="function"?(o--,s):void 0,i&&Ioe(n[0],n[1],i)&&(s=o<3?void 0:s,o=1),t=Object(t);++r<o;){var a=n[r];a&&e(t,a,r,s)}return t})}vk.exports=_oe});var Ik=A((XUe,bk)=>{var Roe=Ak(),Eoe=Sk(),Coe=Eoe(function(e,t,n){Roe(e,t,n)});bk.exports=Coe});var Og=A(($Ue,_k)=>{function Poe(e,t){return e<t}_k.exports=Poe});var Ek=A((WUe,Rk)=>{var xoe=$u(),Toe=Og(),Noe=ir();function woe(e){return e&&e.length?xoe(e,Noe,Toe):void 0}Rk.exports=woe});var Pk=A((QUe,Ck)=>{var Ooe=$u(),Doe=nn(),koe=Og();function Moe(e,t){return e&&e.length?Ooe(e,Doe(t,2),koe):void 0}Ck.exports=Moe});var Tk=A((JUe,xk)=>{var Loe=yt(),Boe=function(){return Loe.Date.now()};xk.exports=Boe});var Ok=A((ZUe,wk)=>{var Goe=Ia(),Uoe=Da(),zoe=Ra(),Nk=it(),qoe=Es();function Foe(e,t,n,r){if(!Nk(e))return e;t=Uoe(t,e);for(var o=-1,s=t.length,i=s-1,a=e;a!=null&&++o<s;){var d=qoe(t[o]),c=n;if(d==="__proto__"||d==="constructor"||d==="prototype")return e;if(o!=i){var u=a[d];c=r?r(u,d,a):void 0,c===void 0&&(c=Nk(u)?u:zoe(t[o+1])?[]:{})}Goe(a,d,c),a=a[d]}return e}wk.exports=Foe});var kk=A((eze,Dk)=>{var joe=ka(),Voe=Ok(),Hoe=Da();function Yoe(e,t,n){for(var r=-1,o=t.length,s={};++r<o;){var i=t[r],a=joe(e,i);n(a,i)&&Voe(s,Hoe(i,e),a)}return s}Dk.exports=Yoe});var Lk=A((tze,Mk)=>{var Koe=kk(),Xoe=ig();function $oe(e,t){return Koe(e,t,function(n,r){return Xoe(e,r)})}Mk.exports=$oe});var Gk=A((nze,Bk)=>{var Woe=Tg(),Qoe=gg(),Joe=yg();function Zoe(e){return Joe(Qoe(e,void 0,Woe),e+"")}Bk.exports=Zoe});var zk=A((rze,Uk)=>{var ese=Lk(),tse=Gk(),nse=tse(function(e,t){return e==null?{}:ese(e,t)});Uk.exports=nse});var Fk=A((oze,qk)=>{var rse=Math.ceil,ose=Math.max;function sse(e,t,n,r){for(var o=-1,s=ose(rse((t-e)/(n||1)),0),i=Array(s);s--;)i[r?s:++o]=e,e+=n;return i}qk.exports=sse});var Vk=A((sze,jk)=>{var ise=Fk(),ase=Ga(),Dg=xg();function dse(e){return function(t,n,r){return r&&typeof r!="number"&&ase(t,n,r)&&(n=r=void 0),t=Dg(t),n===void 0?(n=t,t=0):n=Dg(n),r=r===void 0?t<n?1:-1:Dg(r),ise(t,n,r,e)}}jk.exports=dse});var Yk=A((ize,Hk)=>{var cse=Vk(),use=cse();Hk.exports=use});var Xk=A((aze,Kk)=>{function pse(e,t){var n=e.length;for(e.sort(t);n--;)e[n]=e[n].value;return e}Kk.exports=pse});var Qk=A((dze,Wk)=>{var $k=so();function lse(e,t){if(e!==t){var n=e!==void 0,r=e===null,o=e===e,s=$k(e),i=t!==void 0,a=t===null,d=t===t,c=$k(t);if(!a&&!c&&!s&&e>t||s&&i&&d&&!a&&!c||r&&i&&d||!n&&d||!o)return 1;if(!r&&!s&&!c&&e<t||c&&n&&o&&!r&&!s||a&&n&&o||!i&&o||!d)return-1}return 0}Wk.exports=lse});var Zk=A((cze,Jk)=>{var fse=Qk();function mse(e,t,n){for(var r=-1,o=e.criteria,s=t.criteria,i=o.length,a=n.length;++r<i;){var d=fse(o[r],s[r]);if(d){if(r>=a)return d;var c=n[r];return d*(c=="desc"?-1:1)}}return e.index-t.index}Jk.exports=mse});var t0=A((uze,e0)=>{var kg=Oa(),hse=ka(),gse=nn(),yse=pg(),Ase=Xk(),vse=Ea(),Sse=Zk(),bse=ir(),Ise=ve();function _se(e,t,n){t.length?t=kg(t,function(s){return Ise(s)?function(i){return hse(i,s.length===1?s[0]:s)}:s}):t=[bse];var r=-1;t=kg(t,vse(gse));var o=yse(e,function(s,i,a){var d=kg(t,function(c){return c(s)});return{criteria:d,index:++r,value:s}});return Ase(o,function(s,i){return Sse(s,i,n)})}e0.exports=_se});var o0=A((pze,r0)=>{var Rse=Fu(),Ese=t0(),Cse=Ma(),n0=Ga(),Pse=Cse(function(e,t){if(e==null)return[];var n=t.length;return n>1&&n0(e,t[0],t[1])?t=[]:n>2&&n0(t[0],t[1],t[2])&&(t=[t[0]]),Ese(e,Rse(t,1),[])});r0.exports=Pse});var i0=A((lze,s0)=>{var xse=og(),Tse=0;function Nse(e){var t=++Tse;return xse(e)+t}s0.exports=Nse});var d0=A((fze,a0)=>{function wse(e,t,n){for(var r=-1,o=e.length,s=t.length,i={};++r<o;){var a=r<s?t[r]:void 0;n(i,e[r],a)}return i}a0.exports=wse});var u0=A((mze,c0)=>{var Ose=Ia(),Dse=d0();function kse(e,t){return Dse(e||[],t||[],Ose)}c0.exports=kse});var le=A((hze,p0)=>{var Wu;if(typeof require=="function")try{Wu={cloneDeep:ID(),constant:Mu(),defaults:CD(),each:Xh(),filter:dg(),find:VD(),flatten:Tg(),forEach:Kh(),forIn:KD(),has:cg(),isUndefined:ug(),last:$D(),map:lg(),mapValues:QD(),max:nk(),merge:Ik(),min:Ek(),minBy:Pk(),now:Tk(),pick:zk(),range:Yk(),reduce:fg(),sortBy:o0(),uniqueId:i0(),values:bg(),zipObject:u0()}}catch{}Wu||(Wu=window._);p0.exports=Wu});var m0=A((gze,f0)=>{f0.exports=Qu;function Qu(){var e={};e._next=e._prev=e,this._sentinel=e}Qu.prototype.dequeue=function(){var e=this._sentinel,t=e._prev;if(t!==e)return l0(t),t};Qu.prototype.enqueue=function(e){var t=this._sentinel;e._prev&&e._next&&l0(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t};Qu.prototype.toString=function(){for(var e=[],t=this._sentinel,n=t._prev;n!==t;)e.push(JSON.stringify(n,Mse)),n=n._prev;return"["+e.join(", ")+"]"};function l0(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function Mse(e,t){if(e!=="_next"&&e!=="_prev")return t}});var g0=A((yze,h0)=>{var Nn=le(),Lse=vt().Graph,Bse=m0();h0.exports=Use;var Gse=Nn.constant(1);function Use(e,t){if(e.nodeCount()<=1)return[];var n=qse(e,t||Gse),r=zse(n.graph,n.buckets,n.zeroIdx);return Nn.flatten(Nn.map(r,function(o){return e.outEdges(o.v,o.w)}),!0)}function zse(e,t,n){for(var r=[],o=t[t.length-1],s=t[0],i;e.nodeCount();){for(;i=s.dequeue();)Mg(e,t,n,i);for(;i=o.dequeue();)Mg(e,t,n,i);if(e.nodeCount()){for(var a=t.length-2;a>0;--a)if(i=t[a].dequeue(),i){r=r.concat(Mg(e,t,n,i,!0));break}}}return r}function Mg(e,t,n,r,o){var s=o?[]:void 0;return Nn.forEach(e.inEdges(r.v),function(i){var a=e.edge(i),d=e.node(i.v);o&&s.push({v:i.v,w:i.w}),d.out-=a,Lg(t,n,d)}),Nn.forEach(e.outEdges(r.v),function(i){var a=e.edge(i),d=i.w,c=e.node(d);c.in-=a,Lg(t,n,c)}),e.removeNode(r.v),s}function qse(e,t){var n=new Lse,r=0,o=0;Nn.forEach(e.nodes(),function(a){n.setNode(a,{v:a,in:0,out:0})}),Nn.forEach(e.edges(),function(a){var d=n.edge(a.v,a.w)||0,c=t(a),u=d+c;n.setEdge(a.v,a.w,u),o=Math.max(o,n.node(a.v).out+=c),r=Math.max(r,n.node(a.w).in+=c)});var s=Nn.range(o+r+3).map(function(){return new Bse}),i=r+1;return Nn.forEach(n.nodes(),function(a){Lg(s,i,n.node(a))}),{graph:n,buckets:s,zeroIdx:i}}function Lg(e,t,n){n.out?n.in?e[n.out-n.in+t].enqueue(n):e[e.length-1].enqueue(n):e[0].enqueue(n)}});var A0=A((Aze,y0)=>{"use strict";var ao=le(),Fse=g0();y0.exports={run:jse,undo:Hse};function jse(e){var t=e.graph().acyclicer==="greedy"?Fse(e,n(e)):Vse(e);ao.forEach(t,function(r){var o=e.edge(r);e.removeEdge(r),o.forwardName=r.name,o.reversed=!0,e.setEdge(r.w,r.v,o,ao.uniqueId("rev"))});function n(r){return function(o){return r.edge(o).weight}}}function Vse(e){var t=[],n={},r={};function o(s){ao.has(r,s)||(r[s]=!0,n[s]=!0,ao.forEach(e.outEdges(s),function(i){ao.has(n,i.w)?t.push(i):o(i.w)}),delete n[s])}return ao.forEach(e.nodes(),o),t}function Hse(e){ao.forEach(e.edges(),function(t){var n=e.edge(t);if(n.reversed){e.removeEdge(t);var r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}});var Ve=A((vze,I0)=>{"use strict";var Z=le(),v0=vt().Graph;I0.exports={addDummyNode:S0,simplify:Yse,asNonCompoundGraph:Kse,successorWeights:Xse,predecessorWeights:$se,intersectRect:Wse,buildLayerMatrix:Qse,normalizeRanks:Jse,removeEmptyRanks:Zse,addBorderNode:eie,maxRank:b0,partition:tie,time:nie,notime:rie};function S0(e,t,n,r){var o;do o=Z.uniqueId(r);while(e.hasNode(o));return n.dummy=t,e.setNode(o,n),o}function Yse(e){var t=new v0().setGraph(e.graph());return Z.forEach(e.nodes(),function(n){t.setNode(n,e.node(n))}),Z.forEach(e.edges(),function(n){var r=t.edge(n.v,n.w)||{weight:0,minlen:1},o=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+o.weight,minlen:Math.max(r.minlen,o.minlen)})}),t}function Kse(e){var t=new v0({multigraph:e.isMultigraph()}).setGraph(e.graph());return Z.forEach(e.nodes(),function(n){e.children(n).length||t.setNode(n,e.node(n))}),Z.forEach(e.edges(),function(n){t.setEdge(n,e.edge(n))}),t}function Xse(e){var t=Z.map(e.nodes(),function(n){var r={};return Z.forEach(e.outEdges(n),function(o){r[o.w]=(r[o.w]||0)+e.edge(o).weight}),r});return Z.zipObject(e.nodes(),t)}function $se(e){var t=Z.map(e.nodes(),function(n){var r={};return Z.forEach(e.inEdges(n),function(o){r[o.v]=(r[o.v]||0)+e.edge(o).weight}),r});return Z.zipObject(e.nodes(),t)}function Wse(e,t){var n=e.x,r=e.y,o=t.x-n,s=t.y-r,i=e.width/2,a=e.height/2;if(!o&&!s)throw new Error("Not possible to find intersection inside of the rectangle");var d,c;return Math.abs(s)*i>Math.abs(o)*a?(s<0&&(a=-a),d=a*o/s,c=a):(o<0&&(i=-i),d=i,c=i*s/o),{x:n+d,y:r+c}}function Qse(e){var t=Z.map(Z.range(b0(e)+1),function(){return[]});return Z.forEach(e.nodes(),function(n){var r=e.node(n),o=r.rank;Z.isUndefined(o)||(t[o][r.order]=n)}),t}function Jse(e){var t=Z.min(Z.map(e.nodes(),function(n){return e.node(n).rank}));Z.forEach(e.nodes(),function(n){var r=e.node(n);Z.has(r,"rank")&&(r.rank-=t)})}function Zse(e){var t=Z.min(Z.map(e.nodes(),function(s){return e.node(s).rank})),n=[];Z.forEach(e.nodes(),function(s){var i=e.node(s).rank-t;n[i]||(n[i]=[]),n[i].push(s)});var r=0,o=e.graph().nodeRankFactor;Z.forEach(n,function(s,i){Z.isUndefined(s)&&i%o!==0?--r:r&&Z.forEach(s,function(a){e.node(a).rank+=r})})}function eie(e,t,n,r){var o={width:0,height:0};return arguments.length>=4&&(o.rank=n,o.order=r),S0(e,"border",o,t)}function b0(e){return Z.max(Z.map(e.nodes(),function(t){var n=e.node(t).rank;if(!Z.isUndefined(n))return n}))}function tie(e,t){var n={lhs:[],rhs:[]};return Z.forEach(e,function(r){t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function nie(e,t){var n=Z.now();try{return t()}finally{console.log(e+" time: "+(Z.now()-n)+"ms")}}function rie(e,t){return t()}});var E0=A((Sze,R0)=>{"use strict";var _0=le(),oie=Ve();R0.exports={run:sie,undo:aie};function sie(e){e.graph().dummyChains=[],_0.forEach(e.edges(),function(t){iie(e,t)})}function iie(e,t){var n=t.v,r=e.node(n).rank,o=t.w,s=e.node(o).rank,i=t.name,a=e.edge(t),d=a.labelRank;if(s!==r+1){e.removeEdge(t);var c,u,p;for(p=0,++r;r<s;++p,++r)a.points=[],u={width:0,height:0,edgeLabel:a,edgeObj:t,rank:r},c=oie.addDummyNode(e,"edge",u,"_d"),r===d&&(u.width=a.width,u.height=a.height,u.dummy="edge-label",u.labelpos=a.labelpos),e.setEdge(n,c,{weight:a.weight},i),p===0&&e.graph().dummyChains.push(c),n=c;e.setEdge(n,o,{weight:a.weight},i)}}function aie(e){_0.forEach(e.graph().dummyChains,function(t){var n=e.node(t),r=n.edgeLabel,o;for(e.setEdge(n.edgeObj,r);n.dummy;)o=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy==="edge-label"&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=o,n=e.node(t)})}});var Ua=A((bze,C0)=>{"use strict";var Ju=le();C0.exports={longestPath:die,slack:cie};function die(e){var t={};function n(r){var o=e.node(r);if(Ju.has(t,r))return o.rank;t[r]=!0;var s=Ju.min(Ju.map(e.outEdges(r),function(i){return n(i.w)-e.edge(i).minlen}));return(s===Number.POSITIVE_INFINITY||s===void 0||s===null)&&(s=0),o.rank=s}Ju.forEach(e.sources(),n)}function cie(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}});var Bg=A((Ize,P0)=>{"use strict";var Zu=le(),uie=vt().Graph,ep=Ua().slack;P0.exports=pie;function pie(e){var t=new uie({directed:!1}),n=e.nodes()[0],r=e.nodeCount();t.setNode(n,{});for(var o,s;lie(t,e)<r;)o=fie(t,e),s=t.hasNode(o.v)?ep(e,o):-ep(e,o),mie(t,e,s);return t}function lie(e,t){function n(r){Zu.forEach(t.nodeEdges(r),function(o){var s=o.v,i=r===s?o.w:s;!e.hasNode(i)&&!ep(t,o)&&(e.setNode(i,{}),e.setEdge(r,i,{}),n(i))})}return Zu.forEach(e.nodes(),n),e.nodeCount()}function fie(e,t){return Zu.minBy(t.edges(),function(n){if(e.hasNode(n.v)!==e.hasNode(n.w))return ep(t,n)})}function mie(e,t,n){Zu.forEach(e.nodes(),function(r){t.node(r).rank+=n})}});var M0=A((_ze,k0)=>{"use strict";var wn=le(),hie=Bg(),gie=Ua().slack,yie=Ua().longestPath,Aie=vt().alg.preorder,vie=vt().alg.postorder,Sie=Ve().simplify;k0.exports=co;co.initLowLimValues=Ug;co.initCutValues=Gg;co.calcCutValue=T0;co.leaveEdge=w0;co.enterEdge=O0;co.exchangeEdges=D0;function co(e){e=Sie(e),yie(e);var t=hie(e);Ug(t),Gg(t,e);for(var n,r;n=w0(t);)r=O0(t,e,n),D0(t,e,n,r)}function Gg(e,t){var n=vie(e,e.nodes());n=n.slice(0,n.length-1),wn.forEach(n,function(r){bie(e,t,r)})}function bie(e,t,n){var r=e.node(n),o=r.parent;e.edge(n,o).cutvalue=T0(e,t,n)}function T0(e,t,n){var r=e.node(n),o=r.parent,s=!0,i=t.edge(n,o),a=0;return i||(s=!1,i=t.edge(o,n)),a=i.weight,wn.forEach(t.nodeEdges(n),function(d){var c=d.v===n,u=c?d.w:d.v;if(u!==o){var p=c===s,l=t.edge(d).weight;if(a+=p?l:-l,_ie(e,n,u)){var f=e.edge(n,u).cutvalue;a+=p?-f:f}}}),a}function Ug(e,t){arguments.length<2&&(t=e.nodes()[0]),N0(e,{},1,t)}function N0(e,t,n,r,o){var s=n,i=e.node(r);return t[r]=!0,wn.forEach(e.neighbors(r),function(a){wn.has(t,a)||(n=N0(e,t,n,a,r))}),i.low=s,i.lim=n++,o?i.parent=o:delete i.parent,n}function w0(e){return wn.find(e.edges(),function(t){return e.edge(t).cutvalue<0})}function O0(e,t,n){var r=n.v,o=n.w;t.hasEdge(r,o)||(r=n.w,o=n.v);var s=e.node(r),i=e.node(o),a=s,d=!1;s.lim>i.lim&&(a=i,d=!0);var c=wn.filter(t.edges(),function(u){return d===x0(e,e.node(u.v),a)&&d!==x0(e,e.node(u.w),a)});return wn.minBy(c,function(u){return gie(t,u)})}function D0(e,t,n,r){var o=n.v,s=n.w;e.removeEdge(o,s),e.setEdge(r.v,r.w,{}),Ug(e),Gg(e,t),Iie(e,t)}function Iie(e,t){var n=wn.find(e.nodes(),function(o){return!t.node(o).parent}),r=Aie(e,n);r=r.slice(1),wn.forEach(r,function(o){var s=e.node(o).parent,i=t.edge(o,s),a=!1;i||(i=t.edge(s,o),a=!0),t.node(o).rank=t.node(s).rank+(a?i.minlen:-i.minlen)})}function _ie(e,t,n){return e.hasEdge(t,n)}function x0(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}});var U0=A((Rze,G0)=>{"use strict";var Rie=Ua(),B0=Rie.longestPath,Eie=Bg(),Cie=M0();G0.exports=Pie;function Pie(e){switch(e.graph().ranker){case"network-simplex":L0(e);break;case"tight-tree":Tie(e);break;case"longest-path":xie(e);break;default:L0(e)}}var xie=B0;function Tie(e){B0(e),Eie(e)}function L0(e){Cie(e)}});var q0=A((Eze,z0)=>{var zg=le();z0.exports=Nie;function Nie(e){var t=Oie(e);zg.forEach(e.graph().dummyChains,function(n){for(var r=e.node(n),o=r.edgeObj,s=wie(e,t,o.v,o.w),i=s.path,a=s.lca,d=0,c=i[d],u=!0;n!==o.w;){if(r=e.node(n),u){for(;(c=i[d])!==a&&e.node(c).maxRank<r.rank;)d++;c===a&&(u=!1)}if(!u){for(;d<i.length-1&&e.node(c=i[d+1]).minRank<=r.rank;)d++;c=i[d]}e.setParent(n,c),n=e.successors(n)[0]}})}function wie(e,t,n,r){var o=[],s=[],i=Math.min(t[n].low,t[r].low),a=Math.max(t[n].lim,t[r].lim),d,c;d=n;do d=e.parent(d),o.push(d);while(d&&(t[d].low>i||a>t[d].lim));for(c=d,d=r;(d=e.parent(d))!==c;)s.push(d);return{path:o.concat(s.reverse()),lca:c}}function Oie(e){var t={},n=0;function r(o){var s=n;zg.forEach(e.children(o),r),t[o]={low:s,lim:n++}}return zg.forEach(e.children(),r),t}});var V0=A((Cze,j0)=>{var On=le(),qg=Ve();j0.exports={run:Die,cleanup:Lie};function Die(e){var t=qg.addDummyNode(e,"root",{},"_root"),n=kie(e),r=On.max(On.values(n))-1,o=2*r+1;e.graph().nestingRoot=t,On.forEach(e.edges(),function(i){e.edge(i).minlen*=o});var s=Mie(e)+1;On.forEach(e.children(),function(i){F0(e,t,o,s,r,n,i)}),e.graph().nodeRankFactor=o}function F0(e,t,n,r,o,s,i){var a=e.children(i);if(!a.length){i!==t&&e.setEdge(t,i,{weight:0,minlen:n});return}var d=qg.addBorderNode(e,"_bt"),c=qg.addBorderNode(e,"_bb"),u=e.node(i);e.setParent(d,i),u.borderTop=d,e.setParent(c,i),u.borderBottom=c,On.forEach(a,function(p){F0(e,t,n,r,o,s,p);var l=e.node(p),f=l.borderTop?l.borderTop:p,h=l.borderBottom?l.borderBottom:p,m=l.borderTop?r:2*r,g=f!==h?1:o-s[i]+1;e.setEdge(d,f,{weight:m,minlen:g,nestingEdge:!0}),e.setEdge(h,c,{weight:m,minlen:g,nestingEdge:!0})}),e.parent(i)||e.setEdge(t,d,{weight:0,minlen:o+s[i]})}function kie(e){var t={};function n(r,o){var s=e.children(r);s&&s.length&&On.forEach(s,function(i){n(i,o+1)}),t[r]=o}return On.forEach(e.children(),function(r){n(r,1)}),t}function Mie(e){return On.reduce(e.edges(),function(t,n){return t+e.edge(n).weight},0)}function Lie(e){var t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,On.forEach(e.edges(),function(n){var r=e.edge(n);r.nestingEdge&&e.removeEdge(n)})}});var K0=A((Pze,Y0)=>{var Fg=le(),Bie=Ve();Y0.exports=Gie;function Gie(e){function t(n){var r=e.children(n),o=e.node(n);if(r.length&&Fg.forEach(r,t),Fg.has(o,"minRank")){o.borderLeft=[],o.borderRight=[];for(var s=o.minRank,i=o.maxRank+1;s<i;++s)H0(e,"borderLeft","_bl",n,o,s),H0(e,"borderRight","_br",n,o,s)}}Fg.forEach(e.children(),t)}function H0(e,t,n,r,o,s){var i={width:0,height:0,rank:s,borderType:t},a=o[t][s-1],d=Bie.addDummyNode(e,"border",i,n);o[t][s]=d,e.setParent(d,r),a&&e.setEdge(a,d,{weight:1})}});var Q0=A((xze,W0)=>{"use strict";var on=le();W0.exports={adjust:Uie,undo:zie};function Uie(e){var t=e.graph().rankdir.toLowerCase();(t==="lr"||t==="rl")&&$0(e)}function zie(e){var t=e.graph().rankdir.toLowerCase();(t==="bt"||t==="rl")&&qie(e),(t==="lr"||t==="rl")&&(Fie(e),$0(e))}function $0(e){on.forEach(e.nodes(),function(t){X0(e.node(t))}),on.forEach(e.edges(),function(t){X0(e.edge(t))})}function X0(e){var t=e.width;e.width=e.height,e.height=t}function qie(e){on.forEach(e.nodes(),function(t){jg(e.node(t))}),on.forEach(e.edges(),function(t){var n=e.edge(t);on.forEach(n.points,jg),on.has(n,"y")&&jg(n)})}function jg(e){e.y=-e.y}function Fie(e){on.forEach(e.nodes(),function(t){Vg(e.node(t))}),on.forEach(e.edges(),function(t){var n=e.edge(t);on.forEach(n.points,Vg),on.has(n,"x")&&Vg(n)})}function Vg(e){var t=e.x;e.x=e.y,e.y=t}});var Z0=A((Tze,J0)=>{"use strict";var Dn=le();J0.exports=jie;function jie(e){var t={},n=Dn.filter(e.nodes(),function(a){return!e.children(a).length}),r=Dn.max(Dn.map(n,function(a){return e.node(a).rank})),o=Dn.map(Dn.range(r+1),function(){return[]});function s(a){if(!Dn.has(t,a)){t[a]=!0;var d=e.node(a);o[d.rank].push(a),Dn.forEach(e.successors(a),s)}}var i=Dn.sortBy(n,function(a){return e.node(a).rank});return Dn.forEach(i,s),o}});var tM=A((Nze,eM)=>{"use strict";var ar=le();eM.exports=Vie;function Vie(e,t){for(var n=0,r=1;r<t.length;++r)n+=Hie(e,t[r-1],t[r]);return n}function Hie(e,t,n){for(var r=ar.zipObject(n,ar.map(n,function(c,u){return u})),o=ar.flatten(ar.map(t,function(c){return ar.sortBy(ar.map(e.outEdges(c),function(u){return{pos:r[u.w],weight:e.edge(u).weight}}),"pos")}),!0),s=1;s<n.length;)s<<=1;var i=2*s-1;s-=1;var a=ar.map(new Array(i),function(){return 0}),d=0;return ar.forEach(o.forEach(function(c){var u=c.pos+s;a[u]+=c.weight;for(var p=0;u>0;)u%2&&(p+=a[u+1]),u=u-1>>1,a[u]+=c.weight;d+=c.weight*p})),d}});var oM=A((wze,rM)=>{var nM=le();rM.exports=Yie;function Yie(e,t){return nM.map(t,function(n){var r=e.inEdges(n);if(r.length){var o=nM.reduce(r,function(s,i){var a=e.edge(i),d=e.node(i.v);return{sum:s.sum+a.weight*d.order,weight:s.weight+a.weight}},{sum:0,weight:0});return{v:n,barycenter:o.sum/o.weight,weight:o.weight}}else return{v:n}})}});var iM=A((Oze,sM)=>{"use strict";var dt=le();sM.exports=Kie;function Kie(e,t){var n={};dt.forEach(e,function(o,s){var i=n[o.v]={indegree:0,in:[],out:[],vs:[o.v],i:s};dt.isUndefined(o.barycenter)||(i.barycenter=o.barycenter,i.weight=o.weight)}),dt.forEach(t.edges(),function(o){var s=n[o.v],i=n[o.w];!dt.isUndefined(s)&&!dt.isUndefined(i)&&(i.indegree++,s.out.push(n[o.w]))});var r=dt.filter(n,function(o){return!o.indegree});return Xie(r)}function Xie(e){var t=[];function n(s){return function(i){i.merged||(dt.isUndefined(i.barycenter)||dt.isUndefined(s.barycenter)||i.barycenter>=s.barycenter)&&$ie(s,i)}}function r(s){return function(i){i.in.push(s),--i.indegree===0&&e.push(i)}}for(;e.length;){var o=e.pop();t.push(o),dt.forEach(o.in.reverse(),n(o)),dt.forEach(o.out,r(o))}return dt.map(dt.filter(t,function(s){return!s.merged}),function(s){return dt.pick(s,["vs","i","barycenter","weight"])})}function $ie(e,t){var n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}});var cM=A((Dze,dM)=>{var za=le(),Wie=Ve();dM.exports=Qie;function Qie(e,t){var n=Wie.partition(e,function(u){return za.has(u,"barycenter")}),r=n.lhs,o=za.sortBy(n.rhs,function(u){return-u.i}),s=[],i=0,a=0,d=0;r.sort(Jie(!!t)),d=aM(s,o,d),za.forEach(r,function(u){d+=u.vs.length,s.push(u.vs),i+=u.barycenter*u.weight,a+=u.weight,d=aM(s,o,d)});var c={vs:za.flatten(s,!0)};return a&&(c.barycenter=i/a,c.weight=a),c}function aM(e,t,n){for(var r;t.length&&(r=za.last(t)).i<=n;)t.pop(),e.push(r.vs),n++;return n}function Jie(e){return function(t,n){return t.barycenter<n.barycenter?-1:t.barycenter>n.barycenter?1:e?n.i-t.i:t.i-n.i}}});var lM=A((kze,pM)=>{var dr=le(),Zie=oM(),eae=iM(),tae=cM();pM.exports=uM;function uM(e,t,n,r){var o=e.children(t),s=e.node(t),i=s?s.borderLeft:void 0,a=s?s.borderRight:void 0,d={};i&&(o=dr.filter(o,function(h){return h!==i&&h!==a}));var c=Zie(e,o);dr.forEach(c,function(h){if(e.children(h.v).length){var m=uM(e,h.v,n,r);d[h.v]=m,dr.has(m,"barycenter")&&rae(h,m)}});var u=eae(c,n);nae(u,d);var p=tae(u,r);if(i&&(p.vs=dr.flatten([i,p.vs,a],!0),e.predecessors(i).length)){var l=e.node(e.predecessors(i)[0]),f=e.node(e.predecessors(a)[0]);dr.has(p,"barycenter")||(p.barycenter=0,p.weight=0),p.barycenter=(p.barycenter*p.weight+l.order+f.order)/(p.weight+2),p.weight+=2}return p}function nae(e,t){dr.forEach(e,function(n){n.vs=dr.flatten(n.vs.map(function(r){return t[r]?t[r].vs:r}),!0)})}function rae(e,t){dr.isUndefined(e.barycenter)?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}});var mM=A((Mze,fM)=>{var qa=le(),oae=vt().Graph;fM.exports=sae;function sae(e,t,n){var r=iae(e),o=new oae({compound:!0}).setGraph({root:r}).setDefaultNodeLabel(function(s){return e.node(s)});return qa.forEach(e.nodes(),function(s){var i=e.node(s),a=e.parent(s);(i.rank===t||i.minRank<=t&&t<=i.maxRank)&&(o.setNode(s),o.setParent(s,a||r),qa.forEach(e[n](s),function(d){var c=d.v===s?d.w:d.v,u=o.edge(c,s),p=qa.isUndefined(u)?0:u.weight;o.setEdge(c,s,{weight:e.edge(d).weight+p})}),qa.has(i,"minRank")&&o.setNode(s,{borderLeft:i.borderLeft[t],borderRight:i.borderRight[t]}))}),o}function iae(e){for(var t;e.hasNode(t=qa.uniqueId("_root")););return t}});var gM=A((Lze,hM)=>{var aae=le();hM.exports=dae;function dae(e,t,n){var r={},o;aae.forEach(n,function(s){for(var i=e.parent(s),a,d;i;){if(a=e.parent(i),a?(d=r[a],r[a]=i):(d=o,o=i),d&&d!==i){t.setEdge(d,i);return}i=a}})}});var bM=A((Bze,SM)=>{"use strict";var cr=le(),cae=Z0(),uae=tM(),pae=lM(),lae=mM(),fae=gM(),mae=vt().Graph,yM=Ve();SM.exports=hae;function hae(e){var t=yM.maxRank(e),n=AM(e,cr.range(1,t+1),"inEdges"),r=AM(e,cr.range(t-1,-1,-1),"outEdges"),o=cae(e);vM(e,o);for(var s=Number.POSITIVE_INFINITY,i,a=0,d=0;d<4;++a,++d){gae(a%2?n:r,a%4>=2),o=yM.buildLayerMatrix(e);var c=uae(e,o);c<s&&(d=0,i=cr.cloneDeep(o),s=c)}vM(e,i)}function AM(e,t,n){return cr.map(t,function(r){return lae(e,r,n)})}function gae(e,t){var n=new mae;cr.forEach(e,function(r){var o=r.graph().root,s=pae(r,o,n,t);cr.forEach(s.vs,function(i,a){r.node(i).order=a}),fae(r,n,s.vs)})}function vM(e,t){cr.forEach(t,function(n){cr.forEach(n,function(r,o){e.node(r).order=o})})}});var wM=A((Gze,NM)=>{"use strict";var k=le(),yae=vt().Graph,Aae=Ve();NM.exports={positionX:bae,findType1Conflicts:IM,findType2Conflicts:_M,addConflict:Hg,hasConflict:RM,verticalAlignment:EM,horizontalCompaction:CM,alignCoordinates:xM,findSmallestWidthAlignment:PM,balance:TM};function IM(e,t){var n={};function r(o,s){var i=0,a=0,d=o.length,c=k.last(s);return k.forEach(s,function(u,p){var l=vae(e,u),f=l?e.node(l).order:d;(l||u===c)&&(k.forEach(s.slice(a,p+1),function(h){k.forEach(e.predecessors(h),function(m){var g=e.node(m),y=g.order;(y<i||f<y)&&!(g.dummy&&e.node(h).dummy)&&Hg(n,m,h)})}),a=p+1,i=f)}),s}return k.reduce(t,r),n}function _M(e,t){var n={};function r(s,i,a,d,c){var u;k.forEach(k.range(i,a),function(p){u=s[p],e.node(u).dummy&&k.forEach(e.predecessors(u),function(l){var f=e.node(l);f.dummy&&(f.order<d||f.order>c)&&Hg(n,l,u)})})}function o(s,i){var a=-1,d,c=0;return k.forEach(i,function(u,p){if(e.node(u).dummy==="border"){var l=e.predecessors(u);l.length&&(d=e.node(l[0]).order,r(i,c,p,a,d),c=p,a=d)}r(i,c,i.length,d,s.length)}),i}return k.reduce(t,o),n}function vae(e,t){if(e.node(t).dummy)return k.find(e.predecessors(t),function(n){return e.node(n).dummy})}function Hg(e,t,n){if(t>n){var r=t;t=n,n=r}var o=e[t];o||(e[t]=o={}),o[n]=!0}function RM(e,t,n){if(t>n){var r=t;t=n,n=r}return k.has(e[t],n)}function EM(e,t,n,r){var o={},s={},i={};return k.forEach(t,function(a){k.forEach(a,function(d,c){o[d]=d,s[d]=d,i[d]=c})}),k.forEach(t,function(a){var d=-1;k.forEach(a,function(c){var u=r(c);if(u.length){u=k.sortBy(u,function(m){return i[m]});for(var p=(u.length-1)/2,l=Math.floor(p),f=Math.ceil(p);l<=f;++l){var h=u[l];s[c]===c&&d<i[h]&&!RM(n,c,h)&&(s[h]=c,s[c]=o[c]=o[h],d=i[h])}}})}),{root:o,align:s}}function CM(e,t,n,r,o){var s={},i=Sae(e,t,n,o),a=o?"borderLeft":"borderRight";function d(p,l){for(var f=i.nodes(),h=f.pop(),m={};h;)m[h]?p(h):(m[h]=!0,f.push(h),f=f.concat(l(h))),h=f.pop()}function c(p){s[p]=i.inEdges(p).reduce(function(l,f){return Math.max(l,s[f.v]+i.edge(f))},0)}function u(p){var l=i.outEdges(p).reduce(function(h,m){return Math.min(h,s[m.w]-i.edge(m))},Number.POSITIVE_INFINITY),f=e.node(p);l!==Number.POSITIVE_INFINITY&&f.borderType!==a&&(s[p]=Math.max(s[p],l))}return d(c,i.predecessors.bind(i)),d(u,i.successors.bind(i)),k.forEach(r,function(p){s[p]=s[n[p]]}),s}function Sae(e,t,n,r){var o=new yae,s=e.graph(),i=Iae(s.nodesep,s.edgesep,r);return k.forEach(t,function(a){var d;k.forEach(a,function(c){var u=n[c];if(o.setNode(u),d){var p=n[d],l=o.edge(p,u);o.setEdge(p,u,Math.max(i(e,c,d),l||0))}d=c})}),o}function PM(e,t){return k.minBy(k.values(t),function(n){var r=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;return k.forIn(n,function(s,i){var a=_ae(e,i)/2;r=Math.max(s+a,r),o=Math.min(s-a,o)}),r-o})}function xM(e,t){var n=k.values(t),r=k.min(n),o=k.max(n);k.forEach(["u","d"],function(s){k.forEach(["l","r"],function(i){var a=s+i,d=e[a],c;if(d!==t){var u=k.values(d);c=i==="l"?r-k.min(u):o-k.max(u),c&&(e[a]=k.mapValues(d,function(p){return p+c}))}})})}function TM(e,t){return k.mapValues(e.ul,function(n,r){if(t)return e[t.toLowerCase()][r];var o=k.sortBy(k.map(e,r));return(o[1]+o[2])/2})}function bae(e){var t=Aae.buildLayerMatrix(e),n=k.merge(IM(e,t),_M(e,t)),r={},o;k.forEach(["u","d"],function(i){o=i==="u"?t:k.values(t).reverse(),k.forEach(["l","r"],function(a){a==="r"&&(o=k.map(o,function(p){return k.values(p).reverse()}));var d=(i==="u"?e.predecessors:e.successors).bind(e),c=EM(e,o,n,d),u=CM(e,o,c.root,c.align,a==="r");a==="r"&&(u=k.mapValues(u,function(p){return-p})),r[i+a]=u})});var s=PM(e,r);return xM(r,s),TM(r,e.graph().align)}function Iae(e,t,n){return function(r,o,s){var i=r.node(o),a=r.node(s),d=0,c;if(d+=i.width/2,k.has(i,"labelpos"))switch(i.labelpos.toLowerCase()){case"l":c=-i.width/2;break;case"r":c=i.width/2;break}if(c&&(d+=n?c:-c),c=0,d+=(i.dummy?t:e)/2,d+=(a.dummy?t:e)/2,d+=a.width/2,k.has(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":c=a.width/2;break;case"r":c=-a.width/2;break}return c&&(d+=n?c:-c),c=0,d}}function _ae(e,t){return e.node(t).width}});var kM=A((Uze,DM)=>{"use strict";var Fa=le(),OM=Ve(),Rae=wM().positionX;DM.exports=Eae;function Eae(e){e=OM.asNonCompoundGraph(e),Cae(e),Fa.forEach(Rae(e),function(t,n){e.node(n).x=t})}function Cae(e){var t=OM.buildLayerMatrix(e),n=e.graph().ranksep,r=0;Fa.forEach(t,function(o){var s=Fa.max(Fa.map(o,function(i){return e.node(i).height}));Fa.forEach(o,function(i){e.node(i).y=r+s/2}),r+=s+n})}});var zM=A((zze,UM)=>{"use strict";var B=le(),MM=A0(),LM=E0(),Pae=U0(),xae=Ve().normalizeRanks,Tae=q0(),Nae=Ve().removeEmptyRanks,BM=V0(),wae=K0(),GM=Q0(),Oae=bM(),Dae=kM(),ur=Ve(),kae=vt().Graph;UM.exports=Mae;function Mae(e,t){var n=t&&t.debugTiming?ur.time:ur.notime;n("layout",function(){var r=n(" buildLayoutGraph",function(){return Yae(e)});n(" runLayout",function(){Lae(r,n)}),n(" updateInputGraph",function(){Bae(e,r)})})}function Lae(e,t){t(" makeSpaceForEdgeLabels",function(){Kae(e)}),t(" removeSelfEdges",function(){nde(e)}),t(" acyclic",function(){MM.run(e)}),t(" nestingGraph.run",function(){BM.run(e)}),t(" rank",function(){Pae(ur.asNonCompoundGraph(e))}),t(" injectEdgeLabelProxies",function(){Xae(e)}),t(" removeEmptyRanks",function(){Nae(e)}),t(" nestingGraph.cleanup",function(){BM.cleanup(e)}),t(" normalizeRanks",function(){xae(e)}),t(" assignRankMinMax",function(){$ae(e)}),t(" removeEdgeLabelProxies",function(){Wae(e)}),t(" normalize.run",function(){LM.run(e)}),t(" parentDummyChains",function(){Tae(e)}),t(" addBorderSegments",function(){wae(e)}),t(" order",function(){Oae(e)}),t(" insertSelfEdges",function(){rde(e)}),t(" adjustCoordinateSystem",function(){GM.adjust(e)}),t(" position",function(){Dae(e)}),t(" positionSelfEdges",function(){ode(e)}),t(" removeBorderNodes",function(){tde(e)}),t(" normalize.undo",function(){LM.undo(e)}),t(" fixupEdgeLabelCoords",function(){Zae(e)}),t(" undoCoordinateSystem",function(){GM.undo(e)}),t(" translateGraph",function(){Qae(e)}),t(" assignNodeIntersects",function(){Jae(e)}),t(" reversePoints",function(){ede(e)}),t(" acyclic.undo",function(){MM.undo(e)})}function Bae(e,t){B.forEach(e.nodes(),function(n){var r=e.node(n),o=t.node(n);r&&(r.x=o.x,r.y=o.y,t.children(n).length&&(r.width=o.width,r.height=o.height))}),B.forEach(e.edges(),function(n){var r=e.edge(n),o=t.edge(n);r.points=o.points,B.has(o,"x")&&(r.x=o.x,r.y=o.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var Gae=["nodesep","edgesep","ranksep","marginx","marginy"],Uae={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},zae=["acyclicer","ranker","rankdir","align"],qae=["width","height"],Fae={width:0,height:0},jae=["minlen","weight","width","height","labeloffset"],Vae={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Hae=["labelpos"];function Yae(e){var t=new kae({multigraph:!0,compound:!0}),n=Kg(e.graph());return t.setGraph(B.merge({},Uae,Yg(n,Gae),B.pick(n,zae))),B.forEach(e.nodes(),function(r){var o=Kg(e.node(r));t.setNode(r,B.defaults(Yg(o,qae),Fae)),t.setParent(r,e.parent(r))}),B.forEach(e.edges(),function(r){var o=Kg(e.edge(r));t.setEdge(r,B.merge({},Vae,Yg(o,jae),B.pick(o,Hae)))}),t}function Kae(e){var t=e.graph();t.ranksep/=2,B.forEach(e.edges(),function(n){var r=e.edge(n);r.minlen*=2,r.labelpos.toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function Xae(e){B.forEach(e.edges(),function(t){var n=e.edge(t);if(n.width&&n.height){var r=e.node(t.v),o=e.node(t.w),s={rank:(o.rank-r.rank)/2+r.rank,e:t};ur.addDummyNode(e,"edge-proxy",s,"_ep")}})}function $ae(e){var t=0;B.forEach(e.nodes(),function(n){var r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=B.max(t,r.maxRank))}),e.graph().maxRank=t}function Wae(e){B.forEach(e.nodes(),function(t){var n=e.node(t);n.dummy==="edge-proxy"&&(e.edge(n.e).labelRank=n.rank,e.removeNode(t))})}function Qae(e){var t=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,o=0,s=e.graph(),i=s.marginx||0,a=s.marginy||0;function d(c){var u=c.x,p=c.y,l=c.width,f=c.height;t=Math.min(t,u-l/2),n=Math.max(n,u+l/2),r=Math.min(r,p-f/2),o=Math.max(o,p+f/2)}B.forEach(e.nodes(),function(c){d(e.node(c))}),B.forEach(e.edges(),function(c){var u=e.edge(c);B.has(u,"x")&&d(u)}),t-=i,r-=a,B.forEach(e.nodes(),function(c){var u=e.node(c);u.x-=t,u.y-=r}),B.forEach(e.edges(),function(c){var u=e.edge(c);B.forEach(u.points,function(p){p.x-=t,p.y-=r}),B.has(u,"x")&&(u.x-=t),B.has(u,"y")&&(u.y-=r)}),s.width=n-t+i,s.height=o-r+a}function Jae(e){B.forEach(e.edges(),function(t){var n=e.edge(t),r=e.node(t.v),o=e.node(t.w),s,i;n.points?(s=n.points[0],i=n.points[n.points.length-1]):(n.points=[],s=o,i=r),n.points.unshift(ur.intersectRect(r,s)),n.points.push(ur.intersectRect(o,i))})}function Zae(e){B.forEach(e.edges(),function(t){var n=e.edge(t);if(B.has(n,"x"))switch((n.labelpos==="l"||n.labelpos==="r")&&(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset;break}})}function ede(e){B.forEach(e.edges(),function(t){var n=e.edge(t);n.reversed&&n.points.reverse()})}function tde(e){B.forEach(e.nodes(),function(t){if(e.children(t).length){var n=e.node(t),r=e.node(n.borderTop),o=e.node(n.borderBottom),s=e.node(B.last(n.borderLeft)),i=e.node(B.last(n.borderRight));n.width=Math.abs(i.x-s.x),n.height=Math.abs(o.y-r.y),n.x=s.x+n.width/2,n.y=r.y+n.height/2}}),B.forEach(e.nodes(),function(t){e.node(t).dummy==="border"&&e.removeNode(t)})}function nde(e){B.forEach(e.edges(),function(t){if(t.v===t.w){var n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function rde(e){var t=ur.buildLayerMatrix(e);B.forEach(t,function(n){var r=0;B.forEach(n,function(o,s){var i=e.node(o);i.order=s+r,B.forEach(i.selfEdges,function(a){ur.addDummyNode(e,"selfedge",{width:a.label.width,height:a.label.height,rank:i.rank,order:s+ ++r,e:a.e,label:a.label},"_se")}),delete i.selfEdges})})}function ode(e){B.forEach(e.nodes(),function(t){var n=e.node(t);if(n.dummy==="selfedge"){var r=e.node(n.e.v),o=r.x+r.width/2,s=r.y,i=n.x-o,a=r.height/2;e.setEdge(n.e,n.label),e.removeNode(t),n.label.points=[{x:o+2*i/3,y:s-a},{x:o+5*i/6,y:s-a},{x:o+i,y:s},{x:o+5*i/6,y:s+a},{x:o+2*i/3,y:s+a}],n.label.x=n.x,n.label.y=n.y}})}function Yg(e,t){return B.mapValues(B.pick(e,t),Number)}function Kg(e){var t={};return B.forEach(e,function(n,r){t[r.toLowerCase()]=n}),t}});var FM=A((qze,qM)=>{var tp=le(),sde=Ve(),ide=vt().Graph;qM.exports={debugOrdering:ade};function ade(e){var t=sde.buildLayerMatrix(e),n=new ide({compound:!0,multigraph:!0}).setGraph({});return tp.forEach(e.nodes(),function(r){n.setNode(r,{label:r}),n.setParent(r,"layer"+e.node(r).rank)}),tp.forEach(e.edges(),function(r){n.setEdge(r.v,r.w,{},r.name)}),tp.forEach(t,function(r,o){var s="layer"+o;n.setNode(s,{rank:"same"}),tp.reduce(r,function(i,a){return n.setEdge(i,a,{style:"invis"}),a})}),n}});var VM=A((Fze,jM)=>{jM.exports="0.8.5"});var np=A((jze,HM)=>{HM.exports={graphlib:vt(),layout:zM(),debug:FM(),util:{time:Ve().time,notime:Ve().notime},version:VM()}});var Tme={};n1(Tme,{XYQ_CANVAS_OPENCODE_MUTATION_DEFINITIONS:()=>Cy,XYQ_CANVAS_REGISTERED_COMMAND_DEFINITIONS:()=>Py,createPippitAssetRuntime:()=>il,createPippitAssetSdkCanvasLoader:()=>UG,createPippitAssetServiceTransport:()=>yl,createXyqCanvasCommandRuntime:()=>kE,createXyqCanvasOpencodeToolDefinitions:()=>WG});module.exports=r1(Tme);var Dp={error:(...e)=>{var t,n;return(n=(t=globalThis.console)==null?void 0:t.error)==null?void 0:n.call(t,...e)},info:(...e)=>{var t,n;return(n=(t=globalThis.console)==null?void 0:t.info)==null?void 0:n.call(t,...e)},warn:(...e)=>{var t,n;return(n=(t=globalThis.console)==null?void 0:t.warn)==null?void 0:n.call(t,...e)}};function mo(e){return{error:(e==null?void 0:e.error)??Dp.error,info:(e==null?void 0:e.info)??Dp.info,warn:(e==null?void 0:e.warn)??Dp.warn}}function Ny(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e,n=t.pippitAssetId,r=t.assetId;return typeof n=="string"&&n.trim().length>0||typeof r=="string"&&r.trim().length>0}function wy(e){if(!Ny(e))throw new Error("Pippit asset SDK requires a structured asset ref: { pippitAssetId } or { assetId }.")}function K(e){var r,o;wy(e);let t=(r=e.pippitAssetId)==null?void 0:r.trim(),n=(o=e.assetId)==null?void 0:o.trim();return{...t?{pippitAssetId:t}:{},...n?{assetId:n}:{},...e.mediaType?{mediaType:e.mediaType}:{}}}function xe(e){return{asset_id:e.assetId,media_type:e.mediaType,pippit_asset_id:e.pippitAssetId}}function pt(e){let t=K(e);return[t.pippitAssetId?`pippit:${t.pippitAssetId}`:"",t.assetId?`asset:${t.assetId}`:"",t.mediaType?`type:${t.mediaType}`:""].filter(Boolean).join("|")}function kp(e){return{...e,context:o1(e.context)}}function Je(e){e&&typeof e.catch=="function"&&e.catch(()=>{})}function o1(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))t[n]=s1(r);return t}function s1(e){return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?Dy(e)?`[url:${td(e)}]`:e:e===null||typeof e=="number"||typeof e=="boolean"||typeof e>"u"?e:Array.isArray(e)?`[array:${e.length}]`:typeof e=="object"?"[object]":String(e)}function Oy(e){if(e)return Dy(e)?`[url:${td(e)}]`:e}function Dy(e){return/https?:\/\//i.test(e)||/[?&](x|token|sign|signature|expires?)=/i.test(e)}function td(e){if(!e)return;let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function Mp(e){var t;return{assetId:e.assetId,image:(t=e.image)!=null&&t.previews?{previewResolutions:Object.keys(e.image.previews),previewVariants:Object.keys(e.image.previewVariants??{})}:void 0,mediaType:e.mediaType,pippitAssetId:e.pippitAssetId,storageKey:a1(e),updatedAt:Date.now(),video:e.video?{durationMs:e.video.durationMs,height:e.video.height,width:e.video.width}:void 0}}function Lp(e,t){var o,s,i;let n=t.mediaType==="image"?t.imageVariant??"default":void 0,r=i1(e,t.source);return{assetId:r.assetId,expiresAt:(o=t.source)==null?void 0:o.expiresAt,imageVariant:n,mediaType:t.mediaType,pippitAssetId:r.pippitAssetId,purpose:t.purpose,resolution:t.resolution,sourceVersion:Oy((s=t.source)==null?void 0:s.version),storageKey:[pt(r),t.mediaType,t.purpose,t.resolution??"",n??""].join("|"),updatedAt:Date.now(),urlVersion:td(((i=t.source)==null?void 0:i.url)??t.url)}}function i1(e,t){let n=t==null?void 0:t.identity;return n!=null&&n.assetId?{assetId:n.assetId,...n.pippitAssetId?{pippitAssetId:n.pippitAssetId}:{}}:n!=null&&n.pippitAssetId?{pippitAssetId:n.pippitAssetId}:e}function a1(e){return[e.pippitAssetId?`pippit:${e.pippitAssetId}`:"",e.assetId?`asset:${e.assetId}`:""].filter(Boolean).join("|")}var js=class{constructor(t=500,n){this._limit=t;this._storage=n;this._records=[];this._listeners=new Set}add(t){var r;let n=kp(t);for(this._records.push(n);this._limit>=0&&this._records.length>this._limit;)this._records.shift();for(let o of this._listeners)o(n);Je((r=this._storage)==null?void 0:r.putOperationRecord(n))}clearRecords(){this._records.length=0}getRecords(t={}){return this._records.filter(n=>!(t.action&&n.action!==t.action||t.operationId&&n.operationId!==t.operationId||t.status&&n.status!==t.status||t.traceId&&n.traceId!==t.traceId))}subscribe(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}};var ky;function c1(){let e=globalThis.console;if(!e||typeof e!="object")return;let t=e.warn;return typeof t=="function"?t.bind(e):void 0}function Bp(e){var t;if(ky)try{ky({...e,context:u1(e.context),metrics:p1(e.metrics)})}catch(n){(t=c1())==null||t("[pippit-asset-sdk] telemetry reporter failed",n)}}function u1(e){if(!e)return;let t={},n=40;for(let[r,o]of Object.entries(e)){if(n<=0)break;t[r]=l1(o),n-=1}return t}function p1(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))Number.isFinite(r)&&(t[n]=r);return Object.keys(t).length?t:void 0}function l1(e){var t;return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e.length>500?`${e.slice(0,500)}...`:e:e===null||typeof e=="number"||typeof e=="boolean"||typeof e>"u"?e:Array.isArray(e)?`[array:${e.length}]`:typeof e=="object"?`[object:${((t=e.constructor)==null?void 0:t.name)||"Object"}]`:String(e)}var nd=class{constructor(t){this.storage=t.storage,this.ledger=t.ledger??new js(500,t.storage),this._logger=t.logger,this._context=t.context??{}}async run(t,n,r){let o=Date.now(),s=My(t),i=n.traceId??s,a={action:t,category:n.category??"pippit_asset",context:{...this._context,...n.context},operationId:s,parentOperationId:n.parentOperationId,startedAt:o,traceId:i};this._record({...a,metrics:n.metrics,status:"start"});try{let d=await r({operationId:s,traceId:i});return this._record({...a,durationMs:Date.now()-o,endedAt:Date.now(),metrics:{count:1,...n.metrics??{}},status:"success"}),d}catch(d){let c=f1(d);throw this._record({...a,context:{...this._context,...n.context,error:d},durationMs:Date.now()-o,endedAt:Date.now(),metrics:{count:1,...n.metrics??{}},status:c?"cancelled":"failure"}),c||this._logger.error("[pippit-asset-sdk] operation failed",t,d,n.context),d}}log(t,n={}){let r=Date.now(),o=My(t),s=n.traceId??o;this._record({action:t,category:n.category??"pippit_asset",context:{...this._context,...n.context},metrics:n.metrics,operationId:o,parentOperationId:n.parentOperationId,startedAt:r,status:n.status??"log",traceId:s})}_record(t){this.ledger.add(t),Bp({action:t.action,category:t.category,context:t.context,metrics:t.metrics,operationId:t.operationId,packageName:"pippit-asset-sdk",status:t.status,traceId:t.traceId})}};function My(e){var n;let t=typeof((n=globalThis.crypto)==null?void 0:n.randomUUID)=="function"?globalThis.crypto.randomUUID():`${Date.now()}_${Math.random().toString(36).slice(2)}`;return`${e}_${t}`}function f1(e){return!!(e&&typeof e=="object"&&"name"in e&&e.name==="AbortError")}var rd=["200p","360p","480p","720p","1080p","2048p","origin"],od=["720p","1080p","2048p","480p","360p","200p","origin"],ho=["2048p","1080p","720p","480p","360p","200p","origin"];var m1={"200p":["200p","360p",...rd.filter(e=>e!=="200p")],"360p":["360p","480p","720p","200p","1080p","2048p","origin"],"480p":["480p","720p","1080p","2048p","360p","200p","origin"],"720p":od,"1080p":["1080p","2048p","720p","480p","360p","200p","origin"],"2048p":ho,origin:["origin","2048p","1080p","720p","480p","360p","200p"]};function Vs(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:void 0}function h1(e){let t=Vs(e.width)??0,n=Vs(e.height)??0,r=Vs(e.zoom)??1,o=Vs(e.devicePixelRatio)??Vs(globalThis.devicePixelRatio)??1;return Math.max(t,n)*r*o}function Gp(e){if(!e)return"medium";let t=h1(e);return t>1440?"high":t>720?"medium":"low"}function Ly(e){if(e.resolution)return m1[e.resolution];let t=Gp(e.sourceOptions);return t==="high"?ho:t==="medium"?od:rd}function Lt(){return new DOMException("Pippit asset source polling aborted.","AbortError")}var sd=class{constructor(t,n){this._resolver=t;this._onDetach=n;this._abortController=new AbortController;this._detached=!1;this._retainWhenOrphaned=!1;this._result={status:"pending"};this._started=!1;this._waiters=new Map}waitForResult(t,n=!1){if(t!=null&&t.aborted)return Promise.reject(Lt());if(this._result.status==="fulfilled")return Promise.resolve(this._result.value);if(this._result.status==="rejected")return Promise.reject(this._result.error);if(this._result.status==="orphaned")return Promise.reject(Lt());this._retainWhenOrphaned||=n;let r=Symbol("source-resolve-waiter"),o=new Promise((s,i)=>{let a={reject:i,resolve:s,signal:t};t&&(a.onAbort=()=>this._abortWaiter(r)),this._waiters.set(r,a),t&&a.onAbort&&t.addEventListener("abort",a.onAbort,{once:!0})});return this._start(),o}cancel(){if(this._result.status!=="pending")return;this._result={status:"orphaned"};let t=Array.from(this._waiters.values());this._waiters.clear(),this._detach(),this._abortController.abort();for(let n of t)this._cleanupWaiter(n),n.reject(Lt())}_start(){if(this._started)return;this._started=!0;let t;try{t=this._resolver(this._abortController.signal)}catch(n){this._settle({status:"rejected",error:n});return}Promise.resolve(t).then(n=>this._settle({status:"fulfilled",value:n}),n=>this._settle({status:"rejected",error:n}))}_abortWaiter(t){let n=this._waiters.get(t);n&&(this._waiters.delete(t),this._cleanupWaiter(n),n.reject(Lt()),this._waiters.size===0&&this._result.status==="pending"&&!this._retainWhenOrphaned&&this.cancel())}_settle(t){if(this._result.status!=="pending")return;this._result=t;let n=Array.from(this._waiters.values());this._waiters.clear(),this._detach();for(let r of n)this._cleanupWaiter(r),t.status==="fulfilled"?r.resolve(t.value):r.reject(t.error)}_cleanupWaiter(t){t.signal&&t.onAbort&&t.signal.removeEventListener("abort",t.onAbort)}_detach(){this._detached||(this._detached=!0,this._onDetach(this))}};var g1=["expires","expire","expiration","x-expires","x-everphoto-expires","x_expire","sign_expire","sign_expires"],y1=["x-amz-date","x-tos-date"],A1=["x-amz-expires","x-tos-expires"],v1=/\/[0-9a-f]{32}\/([0-9a-f]{8})\/video(?:\/|$)/i,S1=Date.UTC(2020,0,1)/1e3,b1=Date.UTC(2100,0,1)/1e3;function Sr(e,t=Date.now()){let n=By(e.expiresAt,e.url,t);return n===e.expiresAt?e:{...e,expiresAt:n}}function br(e,t=Date.now()){return By(e.expiresAt,e.url,t)-t>1e4}function By(e,t,n){return typeof e=="number"&&Number.isFinite(e)?e:I1(t)??n+12e5}function I1(e){let t=_1(e);if(!t)return;let n=R1(t.searchParams);if(n)return n;let r=E1(t.searchParams),o=C1(t.searchParams);return r&&o?r+o:x1(t.pathname)}function _1(e){try{return new URL(e,"https://pippit-asset-sdk.local")}catch{return}}function R1(e){for(let t of g1){let n=P1(Up(e,t));if(n)return n}}function E1(e){for(let t of y1){let n=Up(e,t);if(!n)continue;let r=T1(n)??Date.parse(n);if(Number.isFinite(r))return r}}function C1(e){for(let t of A1){let n=Up(e,t),r=n?Number(n):NaN;if(Number.isFinite(r)&&r>0)return r*1e3}}function P1(e){if(!e)return;let t=Number(e);if(Number.isFinite(t)&&t>0)return t>1e10?t:t*1e3;let n=Date.parse(e);return Number.isFinite(n)?n:void 0}function x1(e){let t=v1.exec(e);if(!t)return;let n=Number.parseInt(t[1],16);if(!(!Number.isFinite(n)||n<S1||n>b1))return n*1e3}function T1(e){let t=/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z$/.exec(e);if(!t)return;let[,n,r,o,s,i,a]=t;return Date.UTC(Number(n),Number(r)-1,Number(o),Number(s),Number(i),Number(a))}function Up(e,t){let n=t.toLowerCase();for(let[r,o]of e.entries())if(r.toLowerCase()===n&&o.trim())return o.trim()}var zp=3e4,Gy=2,go=class{constructor(){this._entries=new Map;this._inFlightResolves=new Map;this._refreshBudgets=new Map;this._refreshSuppressions=new Map;this._aliasInvalidationRevisions=new Map;this._keyRevisions=new Map;this._clearRevision=0}getRevision(t,n){let r=Array.from(Bt(n)).sort().map(o=>`${o}:${this._aliasInvalidationRevisions.get(o)??0}`).join(",");return[this._clearRevision,this._keyRevisions.get(t)??0,r].join("|")}getCurrent(t,n,r){var o;return(o=this._findEntry(t,n,r))==null?void 0:o.entry.source}getUsable(t,n,r){let o=this._findEntry(t,n,r);if(o){if(br(o.entry.source))return o.entry.source;this._entries.delete(o.key),this._bumpKeyRevision(o.key)}}set(t,n,r,o,s){return s!==void 0&&s!==this.getRevision(t,r)?!1:(this._entries.set(t,N1(r,o,n)),this._bumpKeyRevision(t),!0)}setInitial(t,n,r,o){this.getUsable(t,r,o)||br(n)&&this.set(t,n,r,o)}resolveInFlight(t,n,r,o,s){var c;if((c=o.signal)!=null&&c.aborted)return Promise.reject(Lt());let i=this.getRevision(t,n),a=this._findInFlightResolve(t,n,r);if((a==null?void 0:a.entry.revision)===i)return a.entry.task.waitForResult(o.signal,o.inFlightLifetime==="client");let d=new sd(u=>s(i,u),u=>{this._deleteInFlightResolveByTask(u)});return this._inFlightResolves.set(t,{aliases:Bt(n),revision:i,scopeKey:ln(r),task:d}),d.waitForResult(o.signal,o.inFlightLifetime==="client")}hasInFlightResolve(t,n,r){let o=this._findInFlightResolve(t,n,r);return!!(o&&o.entry.revision===this.getRevision(t,n))}markRefreshRequested(t,n,r,o){var i;if(!o)return;let s=((i=this._findRefreshSuppression(t,n,r))==null?void 0:i.entry)??w1(n,r);s.versions.add(o),this._refreshSuppressions.set(t,s)}shouldSuppressRefresh(t,n,r,o){var s;return o?!!((s=this._findRefreshSuppression(t,n,r))!=null&&s.entry.versions.has(o)):!1}markRefreshAttempt(t,n,r,o){var d;let s=((d=this._findRefreshBudget(t,n,r))==null?void 0:d.entry)??O1(n,r),i=s.records.get(o),a=Date.now();!i||a-i.windowStartedAt>=zp?s.records.set(o,{attempts:1,windowStartedAt:a}):i.attempts+=1,this._refreshBudgets.set(t,s)}shouldSuppressRefreshByBudget(t,n,r,o){var i;let s=(i=this._findRefreshBudget(t,n,r))==null?void 0:i.entry.records.get(o);return!s||Date.now()-s.windowStartedAt>=zp?!1:s.attempts>=Gy}getRefreshBudgetPolicy(){return{maxAttempts:Gy,windowMs:zp}}dispose(){this._cancelInFlightResolves(this._inFlightResolves.values()),this.invalidate()}invalidate(t){if(!t){this._entries.clear(),this._inFlightResolves.clear(),this._refreshBudgets.clear(),this._refreshSuppressions.clear(),this._clearRevision+=1;return}let n=Bt(t);for(let[r,o]of Array.from(this._entries.entries()))zn(o.aliases,n)&&(this._entries.delete(r),this._bumpKeyRevision(r));for(let[r,o]of Array.from(this._inFlightResolves.entries()))zn(o.aliases,n)&&this._inFlightResolves.delete(r);for(let[r,o]of Array.from(this._refreshSuppressions.entries()))zn(o.aliases,n)&&this._refreshSuppressions.delete(r);for(let[r,o]of Array.from(this._refreshBudgets.entries()))zn(o.aliases,n)&&this._refreshBudgets.delete(r);for(let r of n)this._aliasInvalidationRevisions.set(r,(this._aliasInvalidationRevisions.get(r)??0)+1)}_findEntry(t,n,r){let o=this._entries.get(t);if(o)return{entry:o,key:t};if(!n||!r)return;let s=Bt(n),i=ln(r);for(let[a,d]of this._entries.entries())if(d.scopeKey===i&&zn(d.aliases,s))return{entry:d,key:a}}_findRefreshSuppression(t,n,r){let o=this._refreshSuppressions.get(t);if(o)return{entry:o,key:t};let s=Bt(n),i=ln(r);for(let[a,d]of this._refreshSuppressions.entries())if(d.scopeKey===i&&zn(d.aliases,s))return{entry:d,key:a}}_findRefreshBudget(t,n,r){let o=this._refreshBudgets.get(t);if(o)return{entry:o,key:t};let s=Bt(n),i=ln(r);for(let[a,d]of this._refreshBudgets.entries())if(d.scopeKey===i&&zn(d.aliases,s))return{entry:d,key:a}}_findInFlightResolve(t,n,r){let o=this._inFlightResolves.get(t);if(o)return{entry:o,key:t};let s=Bt(n),i=ln(r);for(let[a,d]of this._inFlightResolves.entries())if(d.scopeKey===i&&zn(d.aliases,s))return{entry:d,key:a}}_deleteInFlightResolveByTask(t){for(let[n,r]of this._inFlightResolves.entries())if(r.task===t){this._inFlightResolves.delete(n);return}}_cancelInFlightResolves(t){new Set(Array.from(t,n=>n.task)).forEach(n=>n.cancel())}_bumpKeyRevision(t){this._keyRevisions.set(t,(this._keyRevisions.get(t)??0)+1)}};function qy(e,t){return[D1(e),ln(t)].join("|")}function N1(e,t,n){return{aliases:Bt(e,n),scopeKey:ln(t),source:n}}function w1(e,t){return{aliases:Bt(e),scopeKey:ln(t),versions:new Set}}function O1(e,t){return{aliases:Bt(e),records:new Map,scopeKey:ln(t)}}function D1(e){return[e.pippitAssetId?`pippit:${e.pippitAssetId}`:"",e.assetId?`asset:${e.assetId}`:""].filter(Boolean).join("|")}function ln(e){let t=e.mediaType==="image"?e.resolution??Gp(e.sourceOptions):"",n=e.mediaType==="image"&&e.allowProvisionalImage===!1?"final-only":"";return[e.mediaType,e.purpose,e.imageVariant??"",t,n].join("|")}function Bt(e,t){let n=t==null?void 0:t.identity;return n!=null&&n.assetId||n!=null&&n.pippitAssetId?new Set([Uy(n.pippitAssetId),zy(n.assetId)].filter(r=>!!r)):new Set([Uy(e.pippitAssetId),zy(e.assetId)].filter(r=>!!r))}function Uy(e){return e?pt({pippitAssetId:e}):void 0}function zy(e){return e?pt({assetId:e}):void 0}function zn(e,t){for(let n of t)if(e.has(n))return!0;return!1}function Fy(e){return e instanceof File?e:new File([e],"pippit-upload.bin",{type:e.type||"application/octet-stream"})}function jy(){var t;return`upload_${typeof((t=globalThis.crypto)==null?void 0:t.randomUUID)=="function"?globalThis.crypto.randomUUID():`${Date.now()}_${Math.random().toString(36).slice(2)}`}`}function Vy(e){var t;Je((t=e.runtime.storage)==null?void 0:t.putUploadTask({assetId:e.result.assetId,pippitAssetId:e.result.pippitAssetId,status:e.status,taskId:e.taskId,updatedAt:Date.now()}))}function Hy(e){e.runtime.log("upload_task_success",{context:{asset_id:e.result.assetId,pippit_asset_id:e.result.pippitAssetId,task_id:e.taskId}})}function Yy(e){e.runtime.log("upload_task_failure",{context:{error:e.error,task_id:e.taskId},status:"failure"})}function Ky({runtime:e,transport:t}){return{createUploadTask(n,r={}){return new id(n,r,t,e)},async uploadFile(n,r={}){return new id(n,r,t,e).start()}}}var id=class{constructor(t,n,r,o){this._options=n;this._transport=r;this._runtime=o;this._status="pending";this._taskId=jy();this._file=Fy(t),this._runtime.log("upload_task_create",{context:{file_type:this._file.type,task_id:this._taskId},metrics:{file_size:this._file.size}})}cancel(){var t;this._status="cancelled",(t=this._abortController)==null||t.abort(),this._runtime.log("upload_task_cancel",{context:{task_id:this._taskId}})}getSnapshot(){return{error:this._error,progress:this._progress,result:this._result,status:this._status,taskId:this._taskId}}async retry(){return this._runtime.log("upload_task_retry",{context:{resume_mode:"restart",task_id:this._taskId}}),this.start()}async start(){if(this._status==="cancelled")throw new Error("Upload task has been cancelled.");return this._status="uploading",this._runtime.run("upload_task_start",{context:{file_type:this._file.type,task_id:this._taskId},metrics:{file_size:this._file.size}},async()=>{let t=this._createAbortController();this._abortController=t;try{let n=await this._transport.upload(this._file,{onProgress:r=>this._handleProgress(r),signal:t.signal});return this._handleUploadSuccess(n),n}catch(n){throw this._handleUploadFailure(n),n}finally{this._abortController===t&&(this._abortController=void 0)}})}_createAbortController(){var r,o;let t=new AbortController,n=()=>t.abort();return(r=this._options.signal)!=null&&r.aborted?(n(),t):((o=this._options.signal)==null||o.addEventListener("abort",n,{once:!0}),t)}_handleProgress(t){var n,r;this._progress=t,this._runtime.log("upload_task_progress",{context:{task_id:this._taskId},metrics:{loaded:t.loaded,percentage:t.percentage,total:t.total}}),(r=(n=this._options).onProgress)==null||r.call(n,t)}_handleUploadSuccess(t){this._result=t,this._status="success",Vy({result:t,runtime:this._runtime,status:this._status,taskId:this._taskId}),Hy({result:t,runtime:this._runtime,taskId:this._taskId})}_handleUploadFailure(t){this._error=t instanceof Error?t:new Error(String(t)),this._status!=="cancelled"&&(this._status="failed"),Yy({error:this._error,runtime:this._runtime,taskId:this._taskId})}};var k1=new Set(["audio","image","video"]),M1=new Set(["file","text"]);function Xy(e){return!!(e.mediaType&&k1.has(e.mediaType))}function qp(e,t){return e.some(n=>n.mediaType&&M1.has(n.mediaType))?{...t,cachePolicy:"refresh"}:t}function Jy(e){let{invalidateSources:t,runtime:n,transport:r}=e,o=(a,d)=>{let c=K(a);return n.run("asset_refresh",{context:xe(c)},async()=>{let u=await ad(r,c,{cachePolicy:"refresh",signal:d});return qn(n,u),u})},s=(a,d,c={})=>{let u=a.map(K),p=Hs(u),l,f=u;return n.run("asset_subscribe_open",p,()=>{var h;r.subscribeAssetEvents&&(l=r.subscribeAssetEvents(u,m=>{var y,v,S,b,I;let g=K(m.ref);(y=r.invalidateAssets)==null||y.call(r,[g]),t==null||t(g),Je((S=(v=n.storage)==null?void 0:v.deleteAssetMetadata)==null?void 0:S.call(v,g)),Je((I=(b=n.storage)==null?void 0:b.deleteUrlLeases)==null?void 0:I.call(b,g)),d({...m,ref:g})},c),(h=l.syncAssetRefs)==null||h.call(l,f))}).catch(()=>{}),{close:()=>{n.run("asset_subscribe_close",p,()=>{l==null||l.close(),l=void 0}).catch(()=>{})},syncAssetRefs:h=>{var g;let m=h.map(K);f=m,n.log("asset_subscribe_sync",{...Hs(m),metrics:{request_count:m.length}}),(g=l==null?void 0:l.syncAssetRefs)==null||g.call(l,m)}}};return{createAsset:async a=>n.run("asset_create",j1(a),async()=>{if(!r.createAsset)throw new Error("Pippit asset create transport is not configured.");let d=Wy(await r.createAsset(U1(a)));return $y(n,d),Qy(n,r,d,a.refresh!==!1,a.signal)}),getAsset:async(a,d={})=>{let c=K(a);return n.run("asset_query",{context:xe(c)},async()=>{let u=await ad(r,c,d);return qn(n,u),u})},getAssets:async(a,d={})=>{let c=a.map(K);return n.run("asset_batch_query",Hs(c),async()=>{let u=await Fp(r,c,d);return u.forEach(p=>qn(n,p)),u})},queryAssets:async(a,d={})=>{let c=a.map(K);return n.run("asset_batch_query",Hs(c),async()=>{let u=await L1(r,c,d);return u.forEach(({asset:p})=>{p&&qn(n,p)}),u})},invalidate:(a,d={})=>{var p,l,f,h,m;let c=K(a);(p=r.invalidateAssets)==null||p.call(r,[c]);let u=d.scope??"all";(u==="all"||u==="metadata")&&Je((f=(l=n.storage)==null?void 0:l.deleteAssetMetadata)==null?void 0:f.call(l,c)),(u==="all"||u==="source")&&(t==null||t(c),Je((m=(h=n.storage)==null?void 0:h.deleteUrlLeases)==null?void 0:m.call(h,c))),n.log("asset_invalidate",{context:{...xe(c),invalidate_scope:u}})},patchAssets:async a=>n.run("asset_batch_patch",V1(a),async()=>{var p;if(!r.patchAssets)throw new Error("Pippit asset patch transport is not configured.");let d=z1(a),c=await r.patchAssets(d),u=await q1(n,r,d,c,a.refresh!==!1);return dd(d.patches.map(l=>l.ref)).forEach(l=>t==null?void 0:t(l)),(p=r.invalidateAssets)==null||p.call(r,dd(d.patches.map(l=>l.ref))),u}),refresh:o,subscribeAssetEvents:s,updateAsset:async(a,d)=>{let c=K(a);return n.run("asset_update",{context:xe(c)},async()=>{if(!r.updateAsset)throw new Error("Pippit asset update transport is not configured.");let u=Wy(await r.updateAsset(c,d));$y(n,u);let p=await Qy(n,r,u,d.refresh!==!1,d.signal);return t==null||t(u.ref),p})},watchAsset:(a,d,c={})=>{let u=K(a);if(n.log("asset_subscribe_start",{context:xe(u)}),r.subscribeAssetEvents){let p=s([u],l=>{F1({event:l,invalidateSources:t,listener:d,ref:u,runtime:n,shouldRefresh:c.refreshOnChange!==!1,signal:c.signal,transport:r}).catch(f=>{n.log("asset_update_refresh_failure",{context:{...xe(u),error:f},status:"failure"})})},c);return()=>{n.log("asset_subscribe_stop",{context:xe(u)}),p.close()}}return n.log("asset_subscribe_unavailable",{context:xe(u)}),()=>{n.log("asset_subscribe_stop",{context:xe(u)})}}}}async function ad(e,t,n){let o=(await Fp(e,[t],n))[0];if(!o)throw new Error("Pippit asset query returned no asset.");return o}async function Fp(e,t,n){if(!e.queryAssets)throw new Error("Pippit asset query transport is not configured.");let r=await e.queryAssets(t,qp(t,{batchingStrategy:n.batchingStrategy,cachePolicy:n.cachePolicy,dispatchMode:n.dispatchMode,signal:n.signal}));return B1(t,r)}async function L1(e,t,n){if(!e.queryAssets)throw new Error("Pippit asset query transport is not configured.");let r=await e.queryAssets(t,qp(t,{batchingStrategy:n.batchingStrategy,cachePolicy:n.cachePolicy,dispatchMode:n.dispatchMode,signal:n.signal}));return G1(t,r)}function B1(e,t){let n=[...t];return e.map(r=>{let o=n.findIndex(i=>Zy(i,r));if(o<0)throw new Error(`Pippit asset query missing result for ref: ${pt(r)}`);let[s]=n.splice(o,1);if(!s)throw new Error(`Pippit asset query missing result for ref: ${pt(r)}`);return s})}function G1(e,t){let n=[...t];return e.map(r=>{let o=n.findIndex(i=>Zy(i,r));if(o<0)return{asset:null,ref:r};let[s]=n.splice(o,1);return{asset:s??null,ref:r}})}function Zy(e,t){return t.pippitAssetId&&e.pippitAssetId!==t.pippitAssetId||t.assetId&&e.assetId!==t.assetId?!1:!!(t.pippitAssetId||t.assetId)}function qn(e,t){var n;Xy(t)&&Je((n=e.storage)==null?void 0:n.putAssetMetadata(Mp(t)))}function $y(e,t){t.asset&&qn(e,t.asset)}function U1(e){return{...e,ref:e.ref?K(e.ref):void 0}}function z1(e){return{...e,patches:e.patches.map(t=>({...t,ref:K(t.ref)})),rootRef:e.rootRef?K(e.rootRef):void 0}}function Wy(e){return{...e,ref:K(e.ref)}}async function Qy(e,t,n,r,o){if(!r||!t.queryAssets)return n;let s=await ad(t,n.ref,{cachePolicy:"refresh",signal:o});return qn(e,s),{...n,asset:s}}async function q1(e,t,n,r,o){if(!o||!t.queryAssets)return r;let s=dd(n.patches.map(a=>a.ref)),i=await Fp(t,s,{cachePolicy:"refresh",signal:n.signal});return i.forEach(a=>qn(e,a)),{...r,assets:i}}async function F1(e){var r,o,s;let t=K({...e.ref,...e.event.ref});e.runtime.log("asset_update_received",{context:{...xe(t),event_type:e.event.eventType,version:e.event.version}}),(o=(r=e.transport).invalidateAssets)==null||o.call(r,[t]);let n=e.event.asset??(e.shouldRefresh&&e.transport.queryAssets?await ad(e.transport,t,{cachePolicy:"refresh",signal:e.signal}):void 0);if(!n){e.runtime.log("asset_update_refresh_skipped",{context:xe(t)});return}qn(e.runtime,n),(s=e.invalidateSources)==null||s.call(e,t),e.listener(n),e.runtime.log("asset_update_applied",{context:{...xe(t),event_type:e.event.eventType,version:e.event.version}})}function j1(e){return{context:{...e.ref?xe(K(e.ref)):{},media_type:e.mediaType}}}function V1(e){let t=dd(e.patches.map(n=>K(n.ref)));return{...Hs(t),metrics:{patch_count:e.patches.length,request_count:t.length}}}function dd(e){let t=new Set,n=[];for(let r of e){let o=pt(r);t.has(o)||(t.add(o),n.push(r))}return n}function Hs(e){return{context:{asset_id:e.map(t=>t.assetId).filter(Boolean).join(",")||void 0,pippit_asset_id:e.map(t=>t.pippitAssetId).filter(Boolean).join(",")||void 0,request_count:e.length},metrics:{request_count:e.length}}}var eA=(e,t)=>Number.isFinite(e)?Math.max(1,Math.floor(e)):t,jp=class{constructor(t,n){this.allocate=t;this.options=n;this.buffer=[];this.cursor=0;this.refillFailureCount=0;this.refillRetryAt=0;this.disposed=!1;this.seen=new Set;this.init=()=>this.refill();this.take=()=>{if(this.disposed)return;let t=this.buffer[this.cursor];if(t===void 0){this.refillIfNeeded();return}return this.cursor+=1,this.compactIfNeeded(),this.refillIfNeeded(),t};this.mustTake=()=>{let t=this.take();if(!t)throw new Error("[PippitAssetIdPool] id pool is empty");return t};this.takeMany=t=>{let n=[];for(let r=0;r<Math.max(0,Math.floor(t));r+=1){let o=this.take();if(!o)break;n.push(o)}return n};this.available=()=>this.buffer.length-this.cursor;this.isRefilling=()=>!!this.refillPromise;this.waitForIdle=()=>this.refillPromise??Promise.resolve();this.refill=(t=!1)=>{if(this.disposed)return Promise.resolve();if(this.refillPromise)return this.refillPromise;if(!t&&Date.now()<this.refillRetryAt)return Promise.resolve();let n=this.maxBufferSize-this.available();if(n<=0||!t&&this.available()>this.lowWaterMark)return Promise.resolve();let r=Math.min(this.batchSize,n);return this.refillPromise=this.allocate(r).then(o=>{for(let s of o){let i=s.trim();!i||this.seen.has(i)||this.available()>=this.maxBufferSize||(this.seen.add(i),this.buffer.push(i))}this.resetRefillFailures()}).catch(o=>{throw this.recordRefillFailure(),o}).finally(()=>{this.refillPromise=void 0}),this.refillPromise};this.clear=()=>{this.buffer=[],this.cursor=0,this.seen.clear(),this.resetRefillFailures()};this.dispose=()=>{this.disposed=!0,this.clear()};this.batchSize=eA(n.batchSize,1e3),this.lowWaterMark=Math.max(0,Math.floor(n.lowWaterMark??200)),this.maxBufferSize=eA(n.maxBufferSize,1e3)}refillIfNeeded(){this.available()>this.lowWaterMark||this.refill().catch(t=>{var n,r;return(r=(n=this.options).onRefillError)==null?void 0:r.call(n,t)})}recordRefillFailure(){if(this.refillFailureCount+=1,this.refillFailureCount===1)return;let t=Math.min(5e3*2**(this.refillFailureCount-2),6e4);this.refillRetryAt=Date.now()+t}resetRefillFailures(){this.refillFailureCount=0,this.refillRetryAt=0}compactIfNeeded(){this.cursor<=100||this.cursor<=this.buffer.length/2||(this.buffer=this.buffer.slice(this.cursor),this.cursor=0)}};function tA(e){let t=new Set,n=!1,r=async o=>{if(n)throw new Error("Pippit asset client is disposed.");let s=Math.max(0,Math.floor(o));if(s===0)return[];if(!e.allocateAssetIds)throw new Error("Pippit asset ID transport is not configured.");let a=(await e.allocateAssetIds(s)).map(d=>d.trim()).filter(Boolean);if(a.length<s)throw new Error(`Pippit asset ID allocation returned ${a.length}/${s} IDs.`);if(new Set(a).size!==a.length)throw new Error("Pippit asset ID allocation returned duplicate IDs.");return a};return{module:{allocate:r,createPool:(o={})=>{if(n)throw new Error("Pippit asset client is disposed.");let s=new jp(r,o);return t.add(s),s}},dispose:()=>{n=!0,t.forEach(o=>o.dispose()),t.clear()}}}var nA=new WeakMap,ze=class extends Error{constructor(n="Pippit asset source is not ready."){super(n);this.code="PIPPIT_ASSET_SOURCE_NOT_READY";this.name="PippitAssetSourceNotReadyError"}};function Gt(e){return e instanceof ze}function Vp(e,t){return nA.set(e,{...t}),e}function cd(e){let t=Gt(e)?nA.get(e):void 0;return t?{...t}:void 0}var H1=new Set(["200p","360p","480p","720p","1080p","2048p","origin"]);function rA(e){var r;let t=Sr(e.source),n=e.sourceOptions.resolution??Y1(t);Je((r=e.runtime.storage)==null?void 0:r.putUrlLease(Lp(e.ref,{imageVariant:e.sourceOptions.imageVariant,mediaType:e.sourceOptions.mediaType,purpose:e.sourceOptions.purpose,resolution:n,source:t})))}function Y1(e){var n;let t=(n=e.metadata)==null?void 0:n.resolution;return typeof t=="string"&&H1.has(t)?t:void 0}var K1=1500,X1=40,$1=new Set(["audio","image","video"]),W1="AssetQuery did not return an asset_id for source resolution.";function Yp(e){return Q1(e.sourceOptions.mediaType),new Hp(e)}var Hp=class{constructor(t){this._options=t;this._disposed=!1;this._actionPrefix=`${t.sourceOptions.mediaType}_source`,this._sourceKey=qy(t.ref,t.sourceOptions),this._store=t.store??new go,t.sourceOptions.initialSource&&!t.sourceOptions.shouldUseInitialSource&&(this._initialSourceAllowed=!0,this._store.setInitial(this._sourceKey,Sr(t.sourceOptions.initialSource),t.ref,t.sourceOptions))}dispose(){this._disposed=!0}getCurrentSource(){if(this._disposed||this._options.sourceOptions.shouldUseInitialSource&&this._initialSourceAllowed!==!0)return;let t=this._store.getCurrent(this._sourceKey,this._options.ref,this._options.sourceOptions);return t&&br(t)?t:void 0}async getSource(t){return this._assertActive(),this._options.runtime.run(`${this._actionPrefix}_resolve`,{context:this._buildContext()},()=>this._requiresInitialSourceDecision()?this._prepareInitialSource().then(()=>this._getSourceAfterInitialSourceDecision(t)):this._getSourceAfterInitialSourceDecision(t))}async refresh(t){if(this._assertActive(),this._shouldReturnSuppressedRefresh(t))return this._store.getCurrent(this._sourceKey,this._options.ref,this._options.sourceOptions);if(!this._store.hasInFlightResolve(this._sourceKey,this._options.ref,this._options.sourceOptions)){let n=this._getBudgetSuppressedRefreshSource(t);if(n)return n}return this._runRefresh(t).then(n=>(this._store.markRefreshRequested(this._sourceKey,this._options.ref,this._options.sourceOptions,t.sourceVersion),n))}_assertActive(){if(this._disposed)throw new Error("Pippit asset source controller is disposed.")}_requiresInitialSourceDecision(){let{initialSource:t,shouldUseInitialSource:n}=this._options.sourceOptions;return!!(t&&n&&this._initialSourceAllowed===void 0)}_getSourceAfterInitialSourceDecision(t){let n=this._store.getCurrent(this._sourceKey,this._options.ref,this._options.sourceOptions),r=this._store.getUsable(this._sourceKey,this._options.ref,this._options.sourceOptions);return r&&br(r)?(this._options.runtime.log(`${this._actionPrefix}_cache_hit`,{context:this._buildContext(),status:"log"}),r):this._resolveSource({inFlightLifetime:t==null?void 0:t.inFlightLifetime,refresh:!!n,signal:t==null?void 0:t.signal})}async _prepareInitialSource(){let{initialSource:t,shouldUseInitialSource:n}=this._options.sourceOptions;if(!t||!n||this._initialSourceAllowed!==void 0)return;this._initialSourceDecisionPromise??=Promise.resolve(n());let r=await this._initialSourceDecisionPromise;if(this._assertActive(),this._initialSourceAllowed=r,!r){this._store.invalidate(this._options.ref);return}this._store.setInitial(this._sourceKey,Sr(t),this._options.ref,this._options.sourceOptions)}_shouldReturnSuppressedRefresh(t){return this._store.shouldSuppressRefresh(this._sourceKey,this._options.ref,this._options.sourceOptions,t.sourceVersion)?(this._options.runtime.log(`${this._actionPrefix}_refresh`,{context:this._buildRefreshContext(t,{refresh_suppressed:!0}),status:"log"}),!!this._store.getCurrent(this._sourceKey,this._options.ref,this._options.sourceOptions)):!1}_getBudgetSuppressedRefreshSource(t){let n=this._store.getCurrent(this._sourceKey,this._options.ref,this._options.sourceOptions);if(!n||!this._store.shouldSuppressRefreshByBudget(this._sourceKey,this._options.ref,this._options.sourceOptions,t.reason))return;let r=this._store.getRefreshBudgetPolicy();return this._options.runtime.log(`${this._actionPrefix}_refresh`,{context:this._buildRefreshContext(t,{refresh_budget_max_attempts:r.maxAttempts,refresh_budget_window_ms:r.windowMs,refresh_suppressed:!0,refresh_suppression_reason:"refresh_budget_exhausted"}),status:"log"}),n}_runRefresh(t){return this._options.runtime.run(`${this._actionPrefix}_refresh`,{context:this._buildRefreshContext(t)},()=>this._resolveSource({onSharedResolveStart:()=>{this._store.markRefreshAttempt(this._sourceKey,this._options.ref,this._options.sourceOptions,t.reason)},refresh:!0,signal:t.signal}))}async _resolveSource(t){return this._throwIfAborted(t.signal),this._store.resolveInFlight(this._sourceKey,this._options.ref,this._options.sourceOptions,{inFlightLifetime:t.inFlightLifetime,signal:t.signal},(n,r)=>{var o;return(o=t.onSharedResolveStart)==null||o.call(t),this._resolveSourceWithRevision({refresh:t.refresh,signal:r},n,{commitAfterDispose:!0})})}async _resolveSourceWithRevision(t,n,r={}){let o={effectiveRef:this._options.ref},s=await this._resolveSourceWithPolling(t,o);this._throwIfAborted(t.signal);let i=Sr(this._applyResolvedRefIdentity(s,o.resolvedRef));if((r.commitAfterDispose||!this._disposed)&&this._store.set(this._sourceKey,i,this._options.ref,this._options.sourceOptions,n))return rA({ref:this._options.ref,runtime:this._options.runtime,source:i,sourceOptions:this._options.sourceOptions}),i;let d=this._store.getUsable(this._sourceKey,this._options.ref,this._options.sourceOptions);if(d)return d;throw new Error("Pippit asset source resolve was superseded.")}async _resolveSourceWithPolling(t,n){let r=this._resolvePollingOptions(),o;for(let s=1;s<=r.maxAttempts;s+=1){this._throwIfAborted(t.signal);try{return await this._resolveSourceOnce(t,n.effectiveRef)}catch(i){this._advanceResolvedVideoPreviewRef(i,n);let a=this._normalizeAssetBindingError(i);if(!Gt(a)||s>=r.maxAttempts){o=a;break}o=a,this._logPollAttempt(s,r.maxAttempts),await oA(t.signal,r.intervalMs)}}if(!this._shouldEnterSlowPolling(r,o))throw o instanceof Error?o:new Error("Pippit asset source polling exhausted.");return this._resolveSourceWithSlowPolling(t,r,n)}async _resolveSourceWithSlowPolling(t,n,r){this._logSlowPollingStart(n);let o=0;for(;n.slowMaxAttempts===void 0||o<n.slowMaxAttempts;){o+=1,await oA(t.signal,n.slowIntervalMs??0),this._throwIfAborted(t.signal);try{return await this._resolveSourceOnce(t,r.effectiveRef)}catch(s){this._advanceResolvedVideoPreviewRef(s,r);let i=this._normalizeAssetBindingError(s);if(!Gt(i))throw i;this._logSlowPollAttempt(o,n.slowMaxAttempts)}}throw new Error("Pippit asset source slow polling exhausted.")}async _resolveSourceOnce(t,n){let{sourceOptions:r,transport:o}=this._options;if(!o.resolveSource)throw new Error("Pippit asset source transport is not configured.");let{initialSource:s,shouldUseInitialSource:i,telemetry:a,waitForAssetBinding:d,...c}=r,u=Sr(await o.resolveSource(n,{...c,refresh:t.refresh,signal:t.signal}));if(br(u))return u;if(!t.refresh)return this._resolveSourceOnce({...t,refresh:!0},n);throw new Error("Pippit asset source transport returned an expired URL lease.")}_advanceResolvedVideoPreviewRef(t,n){var i;let{ref:r,sourceOptions:o}=this._options,s=cd(t);if(!(!Gt(t)||!s||o.mediaType!=="video"||o.purpose!=="preview"||!r.pippitAssetId||r.assetId)){if(!s.assetId||s.pippitAssetId!==r.pippitAssetId)throw new Error("Resolved video asset ref does not match the requested pippitAssetId.");if(s.mediaType&&s.mediaType!=="video")throw new Error("Resolved video asset ref has an incompatible mediaType.");if((i=n.resolvedRef)!=null&&i.assetId&&n.resolvedRef.assetId!==s.assetId)throw new Error("Resolved video asset ref changed during source polling.");n.resolvedRef={assetId:s.assetId,mediaType:"video",pippitAssetId:r.pippitAssetId},n.effectiveRef={assetId:s.assetId,mediaType:"video"}}}_applyResolvedRefIdentity(t,n){var r,o;if(!(n!=null&&n.assetId)||!n.pippitAssetId)return t;if((r=t.identity)!=null&&r.assetId&&t.identity.assetId!==n.assetId)throw new Error("Resolved video source assetId does not match the polled assetId.");if((o=t.identity)!=null&&o.pippitAssetId&&t.identity.pippitAssetId!==n.pippitAssetId)throw new Error("Resolved video source pippitAssetId does not match the requested asset.");return{...t,identity:{...t.identity,assetId:n.assetId,pippitAssetId:n.pippitAssetId},metadata:{...t.metadata,assetId:n.assetId,pippitAssetId:n.pippitAssetId}}}_normalizeAssetBindingError(t){return this._options.sourceOptions.waitForAssetBinding&&t instanceof Error&&t.message===W1?new ze(t.message):t}_resolvePollingOptions(){let t=this._options.sourceOptions.polling;if(t===!1)return{intervalMs:0,maxAttempts:1};let n=this._options.sourceOptions.mediaType==="video"&&this._options.sourceOptions.purpose==="preview";return{intervalMs:(t==null?void 0:t.intervalMs)??(n?K1:0),maxAttempts:(t==null?void 0:t.maxAttempts)??(n?X1:1),slowIntervalMs:t==null?void 0:t.slowIntervalMs,slowMaxAttempts:t==null?void 0:t.slowMaxAttempts}}_shouldEnterSlowPolling(t,n){return!!(t.slowIntervalMs&&Gt(n))}_logPollAttempt(t,n){this._options.runtime.log(`${this._actionPrefix}_wait`,{context:{...this._buildContext(),poll_attempt:t,poll_max_attempts:n,wait_reason:"source_not_ready"},metrics:{poll_attempt:t},status:"log"})}_logSlowPollingStart(t){this._options.runtime.log(`${this._actionPrefix}_slow_wait_start`,{context:{...this._buildContext(),poll_max_attempts:t.maxAttempts,slow_interval_ms:t.slowIntervalMs,slow_max_attempts:t.slowMaxAttempts,wait_reason:"source_not_ready"},metrics:{poll_max_attempts:t.maxAttempts},status:"log"})}_logSlowPollAttempt(t,n){this._options.runtime.log(`${this._actionPrefix}_slow_wait`,{context:{...this._buildContext(),slow_poll_attempt:t,slow_poll_max_attempts:n,wait_reason:"source_not_ready"},metrics:{slow_poll_attempt:t},status:"log"})}_throwIfAborted(t){if(t!=null&&t.aborted)throw Lt()}_buildContext(){let t=this._options.sourceOptions.sourceOptions;return{...xe(this._options.ref),image_variant:this._options.sourceOptions.imageVariant,media_type:this._options.sourceOptions.mediaType,purpose:this._options.sourceOptions.purpose,resolution:this._options.sourceOptions.resolution,source_device_pixel_ratio:t==null?void 0:t.devicePixelRatio,source_height:t==null?void 0:t.height,source_width:t==null?void 0:t.width,source_zoom:t==null?void 0:t.zoom,...this._options.sourceOptions.telemetry}}_buildRefreshContext(t,n={}){return{...this._buildContext(),refresh_reason:t.reason,source_version:t.sourceVersion,...n}}};function oA(e,t){return e!=null&&e.aborted?Promise.reject(Lt()):t<=0?Promise.resolve():new Promise((n,r)=>{let o=globalThis.setTimeout(()=>{e==null||e.removeEventListener("abort",s),n()},t),s=()=>{globalThis.clearTimeout(o),r(Lt())};e==null||e.addEventListener("abort",s,{once:!0})})}function Q1(e){if(!$1.has(e))throw new Error("Pippit asset source controller only supports image, video, and audio assets.")}function sA(e){let{runtime:t,sourceLeaseStore:n,transport:r}=e,o=(i,a)=>Yp({ref:K(i),runtime:t,sourceOptions:a,store:n,transport:r});return{createController:o,resolve:async(i,a,d={})=>{var u;let c=o(i,a);try{return d.cachePolicy==="refresh"?await c.refresh({reason:d.reason??"source_resolve_refresh",signal:d.signal,sourceVersion:(u=c.getCurrentSource())==null?void 0:u.version}):await c.getSource({inFlightLifetime:d.inFlightLifetime,signal:d.signal})}finally{c.dispose()}}}}function iA(e){return e.upload?e.upload:{async upload(){throw new Error("Pippit asset upload transport is not configured.")},resumeMode:"restart"}}function ud(e){let t=mo(e.logger),n=e.storage===!1?void 0:e.storage,r=new nd({context:{uid:e.uid,workspace:e.workspace,...e.telemetry??{}},logger:t,storage:n}),{transport:o}=e,s=iA(o),i=new go,a=sA({runtime:r,sourceLeaseStore:i,transport:o}),d=Jy({invalidateSources:p=>i.invalidate(p),runtime:r,transport:o}),c=tA(o),u=Ky({runtime:r,transport:s});return{assets:d,sources:a,diagnostics:{records:r.ledger},dispose:()=>{var p;i.dispose(),c.dispose(),(p=o.dispose)==null||p.call(o)},ids:c.module,upload:{createUploadTask:u.createUploadTask,uploadFile:(p,l)=>u.uploadFile(p,l)}}}var ld="AssetSnapshot",fd="AssetJsonUpdate",Z1=["audio","file","image","text","video"];function eU(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}}function tU(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}}function nU(e){return Z1.includes(e)?e:void 0}function pd(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function Ir(e,...t){for(let n of t)if(n in e)return e[n]}function Kp(e,...t){let n=Ir(e,...t);return typeof n=="string"&&n.trim()?n.trim():void 0}function aA(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()){let t=Number(e);return Number.isFinite(t)?t:void 0}}function rU(e){let t=Kp(e,"pippitAssetId","pippit_asset_id"),n=Kp(e,"assetId","asset_id"),r=nU(Kp(e,"mediaType","media_type"));if(!(!t&&!n))return K({...n?{assetId:n}:{},...r?{mediaType:r}:{},...t?{pippitAssetId:t}:{}})}function oU(e){return e===ld?"snapshot":e===fd||e==="message"?"update":e==="delete"||e==="AssetDelete"?"delete":"unknown"}function Xp(e,t){let n=eU(t),r=pd(n);if(!r)return;let o=pd(Ir(r,"data","Data")),s=pd(Ir(r,"assetEvent","asset_event"))??(o?pd(Ir(o,"assetEvent","asset_event")):void 0)??o??r,i=rU(s);if(i)return{content:tU(Ir(s,"content")),eventType:oU(e),raw:r,ref:i,startVersion:aA(Ir(s,"startVersion","start_version")),version:aA(Ir(s,"version","Version"))}}async function cA(e,t){let n=e.getReader(),r;for(;!(r=await n.read()).done;)t(r.value)}function uA(e){let t,n,r,o=!1;return function(i){t===void 0?(t=i,n=0,r=-1):t=sU(t,i);let a=t.length,d=0;for(;n<a;){o&&(t[n]===10&&(d=++n),o=!1);let c=-1;for(;n<a&&c===-1;++n)switch(t[n]){case 58:r===-1&&(r=n-d);break;case 13:o=!0;case 10:c=n;break}if(c===-1)break;e(t.subarray(d,c),r),d=n,r=-1}d===a?t=void 0:d!==0&&(t=t.subarray(d),n-=d)}}function pA(e,t,n){let r=dA(),o=new TextDecoder;return function(i,a){if(i.length===0)n==null||n(r),r=dA();else if(a>0){let d=o.decode(i.subarray(0,a)),c=a+(i[a+1]===32?2:1),u=o.decode(i.subarray(c));switch(d){case"data":r.data=r.data?r.data+`
2
- `+u:u;break;case"event":r.event=u;break;case"id":e(r.id=u);break;case"retry":let p=parseInt(u,10);isNaN(p)||t(r.retry=p);break}}}}function sU(e,t){let n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function dA(){return{data:"",event:"",id:"",retry:void 0}}var iU=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n},md="text/event-stream",aU=1e3,lA="last-event-id";function $p(e,t){var{signal:n,headers:r,onopen:o,onmessage:s,onclose:i,onerror:a,openWhenHidden:d,fetch:c}=t,u=iU(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((p,l)=>{let f=Object.assign({},r);f.accept||(f.accept=md);let h;function m(){h.abort(),document.hidden||I()}d||document.addEventListener("visibilitychange",m);let g=aU,y=0;function v(){document.removeEventListener("visibilitychange",m),window.clearTimeout(y),h.abort()}n==null||n.addEventListener("abort",()=>{v(),p()});let S=c??window.fetch,b=o??dU;async function I(){var N;h=new AbortController;try{let w=await S(e,Object.assign(Object.assign({},u),{headers:f,signal:h.signal}));await b(w),await cA(w.body,uA(pA(ne=>{ne?f[lA]=ne:delete f[lA]},ne=>{g=ne},s))),i==null||i(),v(),p()}catch(w){if(!h.signal.aborted)try{let ne=(N=a==null?void 0:a(w))!==null&&N!==void 0?N:g;window.clearTimeout(y),y=window.setTimeout(I,ne)}catch(ne){v(),l(ne)}}}I()})}function dU(e){let t=e.headers.get("content-type");if(!(t!=null&&t.startsWith(md)))throw new Error(`Expected content-type to be ${md}, Actual: ${t}`)}var cU="/api/biz/v1/asset/sse_asset",uU=["message",ld,fd],Wp={ADD:1,DEL:2};async function Qp(e){let t=await e,n=t&&typeof t=="object"?t:{},r=Number(n.ret??0);if(Number.isNaN(r)||r!==0)throw new Error(typeof n.errmsg=="string"?n.errmsg:"Pippit asset subscription failed.")}var Jp=class{constructor(t){this._options=t;this._closed=!1;this._desiredPippitAssetIds=new Set;this._isFlushing=!1;this._isOpen=!1;this._needsFlush=!1;this._subscribedPippitAssetIds=new Set}sync(t){this._desiredPippitAssetIds.clear();for(let n of t)n.pippitAssetId&&this._desiredPippitAssetIds.add(n.pippitAssetId);this._scheduleFlush()}open(){this._isOpen=!0,this._scheduleFlush()}suspend(){this._isOpen=!1,this._subscribedPippitAssetIds.clear()}async close(){if(this._closed)return;this._closed=!0,this._isOpen=!1,this._desiredPippitAssetIds.clear(),await this._flushTask;let t=[...this._subscribedPippitAssetIds];this._subscribedPippitAssetIds.clear(),t.length&&this._options.subscribeAsset&&await Qp(this._options.subscribeAsset({action_type:Wp.DEL,pippit_asset_ids:t,session_id:this._options.sessionId})).catch(this._options.onError)}_scheduleFlush(){if(this._closed||!this._isOpen||!this._options.subscribeAsset||(this._needsFlush=!0,this._isFlushing))return;let t=this._flush().catch(n=>{var r,o;return(o=(r=this._options).onError)==null?void 0:o.call(r,n)});this._flushTask=t,t.finally(()=>{this._flushTask===t&&(this._flushTask=void 0)})}async _flush(){this._isFlushing=!0;try{for(;this._needsFlush&&!this._closed&&this._isOpen&&this._options.subscribeAsset;){this._needsFlush=!1;let t=new Set(this._desiredPippitAssetIds);await this._syncAddedSubscriptions(t),await this._syncRemovedSubscriptions(t)}}finally{this._isFlushing=!1,this._needsFlush&&!this._closed&&this._isOpen&&this._scheduleFlush()}}async _syncAddedSubscriptions(t){let n=[...t].filter(r=>!this._subscribedPippitAssetIds.has(r));!n.length||!this._options.subscribeAsset||(await Qp(this._options.subscribeAsset({action_type:Wp.ADD,pippit_asset_ids:n,session_id:this._options.sessionId})),n.forEach(r=>this._subscribedPippitAssetIds.add(r)))}async _syncRemovedSubscriptions(t){let n=[...this._subscribedPippitAssetIds].filter(r=>!t.has(r));!n.length||!this._options.subscribeAsset||(await Qp(this._options.subscribeAsset({action_type:Wp.DEL,pippit_asset_ids:n,session_id:this._options.sessionId})),n.forEach(r=>this._subscribedPippitAssetIds.delete(r)))}};function pU(e,t){return(typeof e=="function"?e(t):e)??cU}function fA(e,t){return typeof e=="function"?e(t):e??{}}function lU(e,t){return typeof e=="string"?e:JSON.stringify({session_id:t,...e??{}})}function fU(e,t){let n=fA(e,t),r=lU(n.body,t.sessionId);return{body:r,credentials:n.withCredentials?"include":void 0,headers:{...r&&typeof r=="string"?{"content-type":"application/json"}:{},...n.headers??{}},method:n.method??"POST"}}function mU(e){let t=e.headers.get("content-type");if(!e.ok)throw new Error(`Failed to open Pippit asset event source: ${e.status} ${e.statusText}`);if(t&&!t.startsWith("text/event-stream"))throw new Error(`Unexpected Pippit asset event source content-type: ${t}`)}function hU(e,t){return e==="PING"||e==="ping"?!1:(t??uU).includes(e||"message")}function gU(){var t;return`pippit_asset_session_${typeof((t=globalThis.crypto)==null?void 0:t.randomUUID)=="function"?globalThis.crypto.randomUUID():`${Date.now()}_${Math.random().toString(36).slice(2)}`}`}function hd(e){var a,d;let t=((a=e.createSessionId)==null?void 0:a.call(e))??gU(),n={sessionId:t},r=new AbortController,o=new Jp({onError:e.onError,sessionId:t,subscribeAsset:e.subscribeAsset}),s=!1,i=0;return(d=e.onConnectionChange)==null||d.call(e,"connecting"),e.signal&&(e.signal.aborted?r.abort():e.signal.addEventListener("abort",()=>r.abort(),{once:!0})),o.sync(e.refs),$p(pU(e.url,n),{...fU(e.init,n),openWhenHidden:fA(e.init,n).openWhenHidden??!0,signal:r.signal,onopen:c=>{var u;return mU(c),i=0,o.open(),(u=e.onConnectionChange)==null||u.call(e,"open"),Promise.resolve()},onmessage:c=>{if(!hU(c.event,e.eventTypes))return;let u=Xp(c.event||"message",c.data);u&&e.onEvent(u)},onclose:()=>{var c;if(o.suspend(),!s)throw(c=e.onConnectionChange)==null||c.call(e,"reconnecting"),new Error("Pippit asset event source closed.")},onerror:c=>{var p,l,f;o.suspend(),(p=e.onError)==null||p.call(e,c),i+=1;let u=e.maxReconnectAttempts??10;if(i>u)throw(l=e.onConnectionChange)==null||l.call(e,"closed"),c;return(f=e.onConnectionChange)==null||f.call(e,"reconnecting"),Math.min(1e3*2**Math.max(i-1,0),1e4)}}).catch(c=>{var u,p;!s&&!r.signal.aborted&&((u=e.onConnectionChange)==null||u.call(e,"closed"),(p=e.onError)==null||p.call(e,c))}),{close:()=>{var c;s=!0,(c=e.onConnectionChange)==null||c.call(e,"closed"),o.close().finally(()=>r.abort())},syncAssetRefs:c=>{o.sync(c)}}}function mA(e){return new Set(e.map(t=>{var n;return(n=t.pippitAssetId)==null?void 0:n.trim()}).filter(t=>!!t))}function Zp(e){let t=new Map,n=0,r,o=!1,s=()=>{let u=new Set;for(let p of t.values())p.refs.forEach(l=>u.add(l));return[...u].map(p=>({pippitAssetId:p}))},i=u=>{var p,l;for(let f of t.values())(l=(p=f.options).onConnectionChange)==null||l.call(p,u)},a=u=>{var p,l;for(let f of t.values())(l=(p=f.options).onError)==null||l.call(p,u)},d=()=>{var p;let u=s();if(!t.size){r==null||r.close(),r=void 0;return}if(!r){r=hd({...e,onConnectionChange:i,onError:a,onEvent:l=>{var h;let f=(h=l.ref.pippitAssetId)==null?void 0:h.trim();if(f)for(let m of t.values())m.refs.has(f)&&m.listener(l)},refs:u});return}(p=r.syncAssetRefs)==null||p.call(r,u)};return{dispose:()=>{o||(o=!0,t.clear(),r==null||r.close(),r=void 0)},subscribe:(u,p,l={})=>{var y,v;if(o)throw new Error("Pippit asset subscription hub is disposed.");if((y=l.signal)!=null&&y.aborted)return{close:()=>{},syncAssetRefs:()=>{}};let f=++n,h={listener:p,options:l,refs:mA(u)},m=!1,g=()=>{m||(m=!0,t.delete(f),d())};return t.set(f,h),(v=l.signal)==null||v.addEventListener("abort",g,{once:!0}),d(),{close:g,syncAssetRefs:S=>{m||o||(h.refs=mA(S),d())}}}}}var yo=e=>{let t=new Map;return e.map(K).forEach(n=>t.set(pt(n),n)),[...t.values()]};function gd(e){let t=new Map,n=yo(e.pinnedRefs??[]),r,o=!1,s=()=>yo([...n,...Array.from(t.values()).flat()]),i=()=>{var c,u;if(o)return;let d=s();if(!r){if(!d.length)return;try{r=e.onError?e.assets.subscribeAssetEvents(d,e.onEvent,{onError:e.onError}):e.assets.subscribeAssetEvents(d,e.onEvent)}catch(p){(c=e.onError)==null||c.call(e,p)}return}(u=r.syncAssetRefs)==null||u.call(r,d)},a=d=>{t.delete(d)&&i()};return{dispose:()=>{var d;o||(o=!0,t.clear(),n=[],(d=r==null?void 0:r.syncAssetRefs)==null||d.call(r,[]),r==null||r.close(),r=void 0)},getTrackedRefs:s,pin:d=>{n=yo(d),i()},release:a,set:(d,c)=>{o||(t.set(d,yo(c)),i())},track:(d,c=[])=>{t.set(d,yo(c)),i();let u=!1;return{dispose:()=>{u||(u=!0,a(d))},setRefs:p=>{!u&&!o&&(t.set(d,yo(p)),i())}}}}}var _r=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:void 0,yd=(e,...t)=>{if(e)for(let n of t){let r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}},yU=e=>{let t=_r(e.raw),n=_r(t==null?void 0:t.data)??_r(t==null?void 0:t.Data);return{assetEvent:_r(t==null?void 0:t.assetEvent)??_r(t==null?void 0:t.asset_event)??_r(n==null?void 0:n.assetEvent)??_r(n==null?void 0:n.asset_event)??n??t,root:t}};function AU(e,t){let n=e.ref.pippitAssetId;if(!n||e.version===void 0)return;let{assetEvent:r,root:o}=yU(e);t({assetId:n,version:e.version,fromClientId:yd(r,"clientId","client_id")??yd(o,"clientId","client_id"),messageId:yd(o,"msgId","msg_id","messageId","message_id")??yd(r,"msgId","msg_id","messageId","message_id")})}function el(e){return{subscribe(t){let n=e.subscribeAssetEvents(t.assetIds.map(r=>({pippitAssetId:r})),r=>AU(r,t.onEvent),{onConnectionChange:t.onConnectionChange,onError:t.onError});return{close:n.close,syncAssetIds:r=>{var o;(o=n.syncAssetRefs)==null||o.call(n,r.map(s=>({pippitAssetId:s})))}}}}}var fn=class{constructor(){this._versions=new Map;this._listeners=new Map;this.getVersion=t=>this.get(t);this.getVersions=()=>this.snapshot();this.subscribe=(t,n)=>{let r=this._listeners.get(t)??new Set;return r.add(n),this._listeners.set(t,r),()=>{r.delete(n),r.size===0&&this._listeners.delete(t)}}}get(t){return this._versions.get(t)}remember(t,n){if(n===void 0||!Number.isFinite(n))return;let r=this._versions.get(t);if(r===void 0||n>r){this._versions.set(t,n);for(let o of Array.from(this._listeners.get(t)??[]))o(n)}}rememberAll(t){if(t)for(let[n,r]of Object.entries(t))this.remember(n,r)}hasNewerVersion(t,n){let r=this._versions.get(t);return r===void 0||n>r}snapshot(){return Object.fromEntries(this._versions)}clearListeners(){this._listeners.clear()}};var Ao=class extends Error{constructor(n){super(`Pippit asset version is unavailable for asset ${n}`);this.name="PippitAssetVersionUnavailableError",this.assetId=n}},Ys=class extends fn{getBaseVersion(t,n){if(n.patches.some(s=>s.assetId===t.assetId&&s.op==="add"&&s.path===""))return 0;let o=this.getVersion(t.assetId);if(o===void 0)throw new Ao(t.assetId);return o}};var yA=e=>!!(e&&typeof e=="object"&&!Array.isArray(e)),vd=e=>yA(e)?e:void 0,Ad=(e,...t)=>{for(let n of t)if(n in e)return e[n]},tl=(e,...t)=>{let n=Ad(e,...t);return typeof n=="string"&&n.trim()?n.trim():void 0},vU=e=>{if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()){let t=Number(e);return Number.isFinite(t)?t:void 0}},hA=e=>{if(!yA(e))return;let t={};for(let[n,r]of Object.entries(e)){let o=vU(r);o!==void 0&&(t[n]=o)}return Object.keys(t).length?t:void 0},gA=(e,t)=>{let n={};for(let r of e)Object.assign(n,r[t]);return Object.keys(n).length?n:void 0},SU=(e,t,n)=>{var o;let r={...e};for(let s of t.envelopes)if(((o=n.get(s.txId))==null?void 0:o.status)==="ack")for(let i of s.patches)i.op==="add"&&i.path===""&&r[i.assetId]===void 0&&(r[i.assetId]=1);return Object.keys(r).length?r:void 0},bU=e=>e==="ack"||e==="skipped"||e==="reject"?e:"reject",IU=e=>{let t=vd(e)??{};return{transactionId:tl(t,"transaction_id","transactionId")??"",status:bU(Ad(t,"status")),assetVersions:hA(Ad(t,"asset_versions","assetVersions")),currentAssetVersions:hA(Ad(t,"current_asset_versions","currentAssetVersions")),blockedBy:tl(t,"blocked_by","blockedBy"),message:tl(t,"error","message")}},_U=e=>"envelopes"in e&&Array.isArray(e.envelopes)?e:{...e,txIds:[e.txId],patches:[...e.patches],status:"in-flight",envelopes:[{...e,patches:[...e.patches]}]};function nl(e,t){var r;let n=_U(e);return{batch:n,request:{batch_id:((r=t.createBatchId)==null?void 0:r.call(t,n))??`batch_${n.txId}`,client_id:t.clientId,root_pippit_asset_id:t.scopeAssetId,transactions:n.envelopes.map(o=>({transaction_id:o.txId,intent:o.intent,merge_key:o.mergeKey,attempt:o.attempt,enqueued_at:o.enqueuedAt,patches:o.patches.map(s=>({asset_id:s.assetId,base_asset_version:t.versionRegistry.getBaseVersion(s,o),op:s.op,path:s.path,...s.op==="remove"?{}:{value:s.value}}))}))}}}function RU(e){let t=vd(e)??{},n=Number(t.ret??0);if(Number.isNaN(n)||n!==0)throw new Error(typeof t.errmsg=="string"?t.errmsg:"Pippit asset patch failed")}function EU(e){return{status:"transport-error",error:new Error(`Pippit asset patch returned no result for transaction ${e}`)}}function rl(e,t){RU(e);let n=vd(e)??{},r=vd(n.data)??n,s=(Array.isArray(r.results)?r.results:[]).map(IU),i=new Map(s.map(l=>[l.transactionId,l])),a=t.txIds.map(l=>i.get(l)),d=t.txIds.find((l,f)=>!a[f]),c=SU(gA(s,"assetVersions"),t,i),u=gA(s,"currentAssetVersions");if(d)return{response:EU(d),assetVersions:c,currentAssetVersions:u};let p=a.findIndex(l=>(l==null?void 0:l.status)!=="ack");if(p>=0){let l=a[p],f=t.txIds.slice(0,p);return{response:{status:"reject",explicit:l.status==="reject",...f.length?{ackedTxIds:f}:{},...l.status==="reject"?{error:new Error(l.message??`Pippit asset patch rejected transaction ${l.transactionId}`)}:{}},assetVersions:c,currentAssetVersions:u}}return{response:{status:"ack",...t.txIds.length>1?{ackedTxIds:t.txIds}:{}},assetVersions:c,currentAssetVersions:u}}function AA(e){return new Set(e.map(t=>t.trim()).filter(Boolean))}function ol(e){let t=AA(e.assetIds??[]),n=!1,r=0,o=!1,s=new Map,i=new Set,a=c=>{!n&&e.versions.hasNewerVersion(c.assetId,c.version)&&e.onNewerEvent(c)},d=()=>{if(!(n||!o||r>0)){for(let c of s.values())a(c);s.clear()}};return{close:()=>{n||(n=!0,t.clear(),s.clear(),i.clear())},handleEvent:c=>{if(!(n||!t.has(c.assetId))){if(c.messageId){if(i.has(c.messageId))return;if(i.add(c.messageId),i.size>1e3){let u=i.values().next().value;u&&i.delete(u)}}if(!o||r>0){let u=s.get(c.assetId);(!u||c.version>=u.version)&&s.set(c.assetId,c);return}a(c)}},runVersionedLoad:async c=>{r+=1;try{return await c(u=>e.versions.rememberAll(u))}finally{r-=1,r===0&&(o=!0,d())}},syncAssetIds:c=>{t=AA(c);for(let u of s.keys())t.has(u)||s.delete(u)}}}var CU=e=>{let t=[],n=new Set,r=o=>{let s=o.trim();!s||n.has(s)||(n.add(s),t.push(s))};return e.forEach(r),t},sl=class{constructor(t){this.options=t;this.invalidateListeners=new Set;this.connectionListeners=new Set;this.abortController=new AbortController;this.subscription=null;this.closed=!1;this.commit=async t=>{if(("envelopes"in t?t.envelopes.reduce((r,o)=>r+o.patches.length,0):t.patches.length)===0){let r="txIds"in t?t.txIds:[t.txId];return{status:"ack",...r.length>1?{ackedTxIds:r}:{}}}try{let{batch:r,request:o}=nl(t,{scopeAssetId:this.options.scopeAssetId,clientId:this.clientId,versionRegistry:this.versions,createBatchId:this.options.createBatchId}),s=await this.options.batchPatchAsset(o),i=rl(s,r);return this.versions.rememberAll(i.assetVersions),i.response}catch(r){if(r instanceof Ao)return this.logger.warn("[pippit-asset-sdk:sync:pippit] missing base asset version",{assetId:r.assetId}),{status:"transport-error",error:r,retryable:!0,requiresResync:!0};let o=r instanceof Error?r:new Error(String(r));return this.logger.error("[pippit-asset-sdk:sync:pippit] commit failed",o,{scopeAssetId:this.options.scopeAssetId,txId:t.txId}),{status:"transport-error",error:o}}};this.fetchSnapshot=t=>this.eventReconciler.runVersionedLoad(async n=>{let r=t==null?void 0:t.onProgress,o=await this.options.loader.fetchSnapshot({scopeAssetId:this.options.scopeAssetId,signal:this.abortController.signal,...r?{onProgress:s=>{try{r(s)}catch(i){this.logger.warn("[pippit-asset-sdk:sync:pippit] snapshot progress observer failed",{error:i instanceof Error?i.message:String(i),scopeAssetId:this.options.scopeAssetId})}}}:{}});return n(o.assetVersions),{state:o.state}});this.fetchAssets=t=>this.eventReconciler.runVersionedLoad(async()=>{let n=await this.options.loader.fetchAssets({scopeAssetId:this.options.scopeAssetId,requests:t,signal:this.abortController.signal});return{assets:n.assets.map(r=>({...r,assetVersion:r.assetVersion??n.assetVersions[r.assetId]}))}});this.onInvalidate=t=>(this.invalidateListeners.add(t),this.openSubscription(),()=>{this.invalidateListeners.delete(t)});this.onConnectionChange=t=>(this.connectionListeners.add(t),()=>{this.connectionListeners.delete(t)});this.getConnectionState=()=>this.connectionState;this.syncAssetSubscriptions=t=>{var n;this.assetIds=CU(t),this.eventReconciler.syncAssetIds(this.assetIds),(n=this.subscription)==null||n.syncAssetIds(this.assetIds)};this.getDebugAssetVersions=()=>this.versions.snapshot();this.close=()=>{var t;this.closed||(this.closed=!0,this.invalidateListeners.clear(),this.eventReconciler.close(),(t=this.subscription)==null||t.close(),this.subscription=null,this.abortController.abort(),this.versions.clearListeners(),this.setConnectionState("closed"))};this.clientId=t.clientId,this.versions=new Ys,this.assetIds=[],this.connectionState=t.assetEventSource?"closed":"open",this.logger=mo(t.logger),this.eventReconciler=ol({assetIds:this.assetIds,versions:this.versions,onNewerEvent:n=>{this.emitInvalidate({scopedAssetId:n.assetId,assetVersion:n.version,fromClientId:n.fromClientId})}})}get assetVersions(){return this.versions}openSubscription(){this.closed||this.subscription||!this.options.assetEventSource||(this.subscription=this.options.assetEventSource.subscribe({assetIds:this.assetIds,clientId:this.clientId,onConnectionChange:t=>{this.setConnectionState(t==="open"?"open":"closed")},onError:t=>{this.logger.error("[pippit-asset-sdk:sync:pippit] asset event source error",t,{scopeAssetId:this.options.scopeAssetId})},onEvent:t=>{this.eventReconciler.handleEvent(t)}}))}emitInvalidate(t){for(let n of Array.from(this.invalidateListeners))n(t)}setConnectionState(t){if(this.connectionState!==t){this.connectionState=t;for(let n of Array.from(this.connectionListeners))n(t)}}};function Sd(e){return new sl(e)}function il(e){let t=ud(e),n=new Set,r=!1,o=()=>{if(r)throw new Error("Pippit asset runtime is disposed.")};return{client:t,createSubscriptionTracker:s=>{o();let i=gd({...s,assets:t.assets});return n.add(i),i},createSyncTransport:s=>{var i;if(o(),!((i=e.sync)!=null&&i.batchPatchAsset))throw new Error("Pippit asset runtime sync transport is not configured.");return Sd({...s,assetEventSource:e.transport.subscribeAssetEvents?el(t.assets):void 0,batchPatchAsset:e.sync.batchPatchAsset})},dispose:()=>{r||(r=!0,n.forEach(s=>s.dispose()),n.clear(),t.dispose())}}}function R(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function ye(e){return Array.isArray(e)?e:void 0}function Ks(e){return typeof e=="string"&&e.trim().length>0}function E(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function oe(e){let t=typeof e=="number"?e:Number(e);return Number.isFinite(t)?t:void 0}function mn(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function bt(e){let t={};return e.assetId&&(t.assetId=e.assetId),e.pippitAssetId&&(t.pippitAssetId=e.pippitAssetId),t.assetId||t.pippitAssetId?t:void 0}function al(e,t){let n=e==null?void 0:e.audio;if(!n)return;let r=n.downloadUrl||n.previewUrl;if(!r)return;let o=e.assetId??e.pippitAssetId??"audio";return{identity:bt({assetId:e.assetId,pippitAssetId:e.pippitAssetId}),metadata:{assetId:e.assetId,downloadUrl:n.downloadUrl,durationMs:n.durationMs,mimeType:n.mimeType,name:n.name,pippitAssetId:e.pippitAssetId,size:n.size},preview:{metadata:{durationMs:n.durationMs,format:n.mimeType,name:n.name,size:n.size},raw:e.raw,type:"audio",urls:{download:n.downloadUrl??r,high:r,low:r,medium:r,url:r}},url:r,version:`${o}:${t.purpose}:${mn(r)}`}}var vA={WEB_DOMAIN:{online:"https://xyq.jianying.com",internal:""},CDN_DOMAIN:{cdnDomain:"https://lf-xiaoyunque.jianying.com",scmStorage:"https://lf-xiaoyunque.jianying.com/obj/pippit-app-buz/xiaoyunque_web"},TOS:{HOST:["https://lf-xiaoyunque.jianying.com"],cmsStaticAssetBaseUrl:"https://p11-xiaoyunque.byteimg.com/tos-cn-i-men7yzdrs1",resultUrlSuffix:{image:"~tplv-men7yzdrs1-webp.webp",video:"~tplv-men7yzdrs1-image.image"}},CMS:{baseUrl:""},SLARDAR:{appxpcode:"",bid:"xiaoyunque_web",pluginPathPrefix:"https://lf3-short.ibytedapm.com/slardar/fe/sdk-web/plugins",domain:"mon.zijieapi.com",sdkUrl:"https://lf3-short.ibytedapm.com/slardar/fe/sdk-web/browser.cn.js",region:"cn",reportUrl:"https://mon.zijieapi.com/monitor_browser/collect/batch/security/"},AGENT_CONNECT:{commandLine:"npx @pippit-dev/cli@latest install"},FIREBASE:{apiKey:"AIzaSyAh-sSmkqiMoEBYLy7yxkaKSCniBUpB6ts"},ASSETS:{entries:{"pippit-role":{path:"https://lf-xiaoyunque.jianying.com/obj/pippit-app-buz/xiaoyunque_web/novel_3d_director/pippit-role.glb"}}},SDK:{canvas:{capcutDownloadUrl:"https://www.capcut.cn/"},novel:{legacyImageOriginHostname:"everphoto-media.jianying.com"},pippitAsset:{imagePreviewBlockedUrlPatterns:["(?:^|/)everphoto-capcut-enc(?:-[^/?#]+)?(?:/|$)","^https://everphoto-media\\.jianying\\.com/download/bucket(?:/|$)"]}}};var dl="https://sf16-web-login-neutral.capcutstatic.com",bd=`${dl}/obj/capcut-web-login-static/ies/pippit/scm_storage`,PU={WEB_DOMAIN:{online:"https://www.pippit.ai"},CDN_DOMAIN:{cdnDomain:dl,scmStorage:bd},TOS:{HOST:[dl],cmsStaticAssetBaseUrl:"https://p16-capcut-sg.capcut.com/tos-alisg-i-hk1xnajzr6-sg",resultUrlSuffix:{image:"~tplv-hk1xnajzr6-webp.webp",video:"~tplv-hk1xnajzr6-image.image"}},CMS:{baseUrl:""},ARGUS_SDK:`${bd}/sdk/secsdk/sg/runtime_bundler_476.js`,SLARDAR:{appxpcode:"lvoverseas_web",bid:"capcut_business",pluginPathPrefix:`${bd}/sdk/slardar-sdk-web/plugins`,sdkUrl:`${bd}/sdk/browser.1.14.1.sg.js`,region:"i18n",domain:"mon-sg.capcutapi.com",reportUrl:"https://mon-sg.capcutapi.com/monitor_browser/collect/batch/security/"},BASE_DOMAIN:{feedAPIDomain:"https://feed-api.capcut.com"},AGENT_CONNECT:{commandLine:"npx skills add https://github.com/Pippit-dev/pippit-skills.git --skill pippit-skill -y -g"},ASSETS:{entries:{"pippit-role":{path:["https://lf-xiaoyunque.","jianying.com/obj/pippit-app-buz/xiaoyunque_web/novel_3d_director/pippit-role.glb"].join("")}}},SDK:{canvas:{capcutDownloadUrl:"https://www.capcut.com/tools/desktop-video-editor"},pippitAsset:{imagePreviewBlockedUrlPatterns:["(?:^|/)everphoto-capcut-enc(?:-[^/?#]+)?(?:/|$)"]}}},SA=PU;var cl="https://sf16-web-tos-buz.capcutcdn-us.com",bA=`${cl}/obj/capcut-web-buz-tx/ies/pippit/scm_storage`,xU={WEB_DOMAIN:{online:"https://www.pippit.ai"},CDN_DOMAIN:{cdnDomain:cl,scmStorage:bA},TOS:{HOST:[cl],cmsStaticAssetBaseUrl:"https://p16-capcut-sg-useast5.capcutcdn-us.com/tos-useast5-i-hk1xnajzr6-tx",resultUrlSuffix:{image:"~tplv-hk1xnajzr6-webp.webp",video:"~tplv-hk1xnajzr6-image.image"}},CMS:{baseUrl:""},SLARDAR:{appxpcode:"lvoverus_web",bid:"capcut_business",sdkUrl:"https://lf16-cdn-tos.tiktokcdn-us.com/obj/static-tx/slardar/fe/sdk-web/browser.1.14.1.oci.js",pluginPathPrefix:`${bA}/sdk/slardar-sdk-web/plugins`,region:"ttp",domain:"mon16-normal-us-ttp.capcutapi.us",reportUrl:"https://mon16-normal-us-ttp.capcutapi.us/monitor_browser/collect/batch/security/"},BASE_DOMAIN:{feedAPIDomain:"https://feed.us.capcut.com"},AGENT_CONNECT:{commandLine:""},ASSETS:{entries:{"pippit-role":{path:["https://lf-xiaoyunque.","jianying.com/obj/pippit-app-buz/xiaoyunque_web/novel_3d_director/pippit-role.glb"].join("")}}},SDK:{canvas:{capcutDownloadUrl:"https://www.capcut.com/tools/desktop-video-editor"},pippitAsset:{imagePreviewBlockedUrlPatterns:["(?:^|/)everphoto-capcut-enc(?:-[^/?#]+)?(?:/|$)"]}}},IA=xU;var vo=process.env.IS_US==="true"?IA:process.env.IS_OVERSEA==="true"?SA:vA;async function _A(e,t,n,r={}){if(!t)return;let o=E(t.asset_id??t.assetId),s=e;if(r.strictAssetId&&o&&o!==s)throw new Error(`Resolved assetId ${o} does not match requested assetId ${s}.`);let i=await kU(t,n.purpose,n.videoVariant,r);if(!i)return;let a=DU(t),d=await pl(r,t,"cover_url","cover_key"),c=await TU(t,r),u={durationMs:oe(t.duration_ms),format:E(t.format),height:oe(t.height),name:E(t.name)??o??s,size:oe(t.size),spriteFrames:c,width:oe(t.width)};return{encryptKey:MU(t),identity:bt({assetId:s}),metadata:{assetId:s,downloadUrl:a,...u,poster:d},preview:{metadata:u,raw:t,type:"video",urls:{download:a??i,high:i,low:i,medium:i,poster:d,url:i}},url:i,version:`${s}:${mn(i)}`}}async function TU(e,t){let n=NU(e),r=wU(n);if(!(r!=null&&r.length))return;let o=(await Promise.all(r.map(i=>OU(i,t)))).filter(i=>!!i);if(!o.length)return;let s=R((n==null?void 0:n.common_info)??(n==null?void 0:n.commonInfo));return{frameCount:oe((s==null?void 0:s.total_set_num)??(s==null?void 0:s.totalSetNum)),frameHeight:oe((s==null?void 0:s.single_frame_height)??(s==null?void 0:s.singleFrameHeight)),frameWidth:oe((s==null?void 0:s.single_frame_width)??(s==null?void 0:s.singleFrameWidth)),images:o}}function NU(e){let t=R(e.video_meta_info??e.videoMetaInfo);return R(e.sprite_frame??e.spriteFrame)??R((t==null?void 0:t.sprite_frame)??(t==null?void 0:t.spriteFrame))}function wU(e){return[e==null?void 0:e.image_list,e==null?void 0:e.imageList,e==null?void 0:e.detail_infos,e==null?void 0:e.detailInfos].find(n=>Array.isArray(n))}async function OU(e,t){let n=R(e),r=await pl(t,n,"url","encrypted_key");if(r)return{encryptKey:E((n==null?void 0:n.encrypted_key)??(n==null?void 0:n.encryptKey)),frameCount:oe((n==null?void 0:n.frame_count)??(n==null?void 0:n.frameCount)),height:oe(n==null?void 0:n.height),url:r,width:oe(n==null?void 0:n.width)}}function ul(e,t){var i,a;let n=e==null?void 0:e.video;if(!n)return;let r=t.purpose==="download"?t.videoVariant?(i=n.downloadVariants)==null?void 0:i[t.videoVariant]:n.downloadUrl:t.videoVariant?(a=n.previewVariants)==null?void 0:a[t.videoVariant]:n.previewUrl;if(!r)return;let o=e.assetId??e.pippitAssetId??"video",s={durationMs:n.durationMs,fps:n.fps,height:n.height,spriteFrames:n.spriteFrames,width:n.width};return{identity:bt({assetId:e.assetId,pippitAssetId:e.pippitAssetId}),metadata:{assetId:e.assetId,downloadUrl:n.downloadUrl,...s,pippitAssetId:e.pippitAssetId,poster:n.coverUrl},preview:{metadata:s,raw:e.raw,type:"video",urls:{download:n.downloadUrl??r,high:r,low:r,medium:r,poster:n.coverUrl,url:r}},refreshOnSourceError:!0,url:r,version:`${o}:${t.purpose}:${mn(r)}`}}function RA(e){let t=R(e.no_watermark_video_url??e.noWatermarkVideoUrl);return Fn([t==null?void 0:t.origin_cover_url,t==null?void 0:t.originCoverUrl,e.origin_cover_url,e.originCoverUrl])}function DU(e){let t=R(e.no_watermark_video_url);return Fn([e.download_url,t==null?void 0:t.download_url,e.origin_url])}function ke(e,t){let n=R(e[`preview_video_${t}`]??e[`previewVideo${t}`]);return(n==null?void 0:n.preview_url)??(n==null?void 0:n.previewUrl)??(n==null?void 0:n.download_url)??(n==null?void 0:n.downloadUrl)}async function kU(e,t,n,r){let o=R(e.no_watermark_video_url);if(t==="download")return Fn(n==="watermark"?[e.download_url]:n==="notWatermark"?[o==null?void 0:o.download_url,e.origin_url,o==null?void 0:o.preview_url,e.download_url]:[e.download_url,o==null?void 0:o.download_url,e.preview_url,e.preview_url_720p,ke(e,"720p"),e.preview_url_1080p,ke(e,"1080p"),e.preview_url_480p,ke(e,"480p"),e.preview_url_360p,ke(e,"360p")]);if(n==="watermark")return Fn([e.preview_url_720p,ke(e,"720p"),e.preview_url_1080p,ke(e,"1080p"),e.preview_url_480p,ke(e,"480p"),e.preview_url_360p,ke(e,"360p"),e.preview_url]);if(n==="notWatermark")return Fn([o==null?void 0:o.preview_url,o==null?void 0:o.download_url,e.origin_url,e.preview_url_720p,ke(e,"720p"),e.preview_url_1080p,ke(e,"1080p"),e.preview_url_480p,ke(e,"480p"),e.preview_url_360p,ke(e,"360p"),e.preview_url]);let s=Fn([e.preview_url_720p,ke(e,"720p"),e.preview_url_1080p,ke(e,"1080p"),e.preview_url_480p,ke(e,"480p"),e.preview_url_360p,ke(e,"360p"),e.preview_url,o==null?void 0:o.preview_url]);return s||await pl(r,e.encrypt_preview_url,"url","key")}function Fn(e){for(let t of e){let n=E(t);if(n)return n}}function MU(e){let t=n=>{let r=R(e[`preview_video_${n}`]??e[`previewVideo${n}`]);return(r==null?void 0:r.preview_key)??(r==null?void 0:r.previewKey)};return E(e.preview_key_720p)??E(t("720p"))??E(e.preview_key_1080p)??E(t("1080p"))??E(e.preview_key_480p)??E(t("480p"))??E(e.preview_key_360p)??E(t("360p"))??E(e.preview_key)}async function pl(e,t,n,r){let o=R(t),s=E(o==null?void 0:o[n]);if(!s)return;let i=E(o==null?void 0:o[r]);return!i||!e.resolveEncryptedUrl?s:await e.resolveEncryptedUrl({key:i,url:s})??s}var LU=["360p","480p","720p","1080p","2048p","origin"];function LA(e,t){return GA(e,GU(t))}function BA(e,t){return GA(e,BU(t))}function BU(e){if(e!=null&&e.assetId)return{assetId:e.assetId,...e.mediaType?{mediaType:e.mediaType}:{},preferRequestedAssetId:!0}}function GU(e){if(e!=null&&e.mediaType)return{mediaType:e.mediaType,pippitAssetId:e.pippitAssetId}}function GA(e,t){let n=UU(e),r=zU(e,n,t==null?void 0:t.mediaType),o=VU(e,n,r),s=E(e.pippit_asset_id??e.pippitAssetId??e.PippitAssetID)??(t==null?void 0:t.pippitAssetId);return{assetId:HU(e,n,r,t),audio:n.audio?xA({...e,...n.audio}):r==="audio"?xA(o):void 0,extra:fl(e.extra??e.Extra),file:n.file?NA(n.file):r==="file"?NA(o):void 0,image:n.image?EA(n.image):r==="image"?EA(o):void 0,mediaType:r,metadata:fl(e.metadata??e.Metadata),pippitAssetId:s,playerInfoVersion:oe(e.player_info_version??e.playerInfoVersion??e.PlayerInfoVersion),raw:e,text:n.text?TA(n.text):r==="text"?TA(o):void 0,video:n.video?PA(n.video):r==="video"?PA(o):void 0,version:oe(e.version??e.Version??e.asset_version??e.assetVersion)}}function fl(e){let t=R(e);if(t)return t;if(!(typeof e!="string"||!e.trim()))try{return R(JSON.parse(e))}catch{return}}function UU(e){return{audio:R(e.Audio)??R(e.audio),file:R(e.File)??R(e.FileInfo)??R(e.file)??R(e.fileInfo),image:R(e.Image)??R(e.image),text:R(e.Text)??R(e.TextInfo)??R(e.text)??R(e.textInfo),video:R(e.Video)??R(e.video)}}function zU(e,t,n){if(n)return n;let r=qU(e.media_type??e.mediaType??e.asset_type??e.type);if(r)return r;let o=FU(e.AssetType??e.assetType??(jU(e)?e.asset_type:void 0));if(o)return o;if(t.audio&&DA(t.audio))return"audio";if(t.video&&OA(t.video))return"video";if(t.image&&wA(t.image))return"image";if(t.text&&kA(t.text))return"text";if(t.file&&MA(t.file))return"file";if(DA(e))return"audio";if(OA(e))return"video";if(wA(e))return"image";if(kA(e))return"text";if(MA(e))return"file"}function qU(e){var n;let t=(n=E(e))==null?void 0:n.toLowerCase();if(t){if(t.includes("audio")||t.includes("music"))return"audio";if(t.includes("video"))return"video";if(t.includes("image")||t.includes("photo")||t.includes("picture"))return"image";if(t.includes("text"))return"text";if(t.includes("file")||t.includes("document"))return"file"}}function FU(e){let t=typeof e=="number"?e:Number(E(e));if(Number.isFinite(t)){if(t===1)return"image";if(t===2)return"video";if(t===3)return"audio";if(t===4)return"text";if(t===5)return"file"}}function jU(e){return!!(e.PippitAssetID||e.pippit_asset_id||e.pippitAssetId||e.AssetSourceType||e.asset_source_type)}function VU(e,t,n){return n==="audio"?t.audio?{...e,...t.audio}:e:n==="video"?t.video??e:n==="image"?t.image??e:n==="text"?t.text??e:n==="file"?t.file??e:e}function So(e){return E((e==null?void 0:e.asset_id)??(e==null?void 0:e.assetId)??(e==null?void 0:e.AssetID))}function HU(e,t,n,r){if(r!=null&&r.preferRequestedAssetId&&r.assetId)return r.assetId;let o=E(e.asset_id??e.assetId),s=n?So(t[n]):void 0,i=E(e.SourceID??e.source_id??e.sourceId);return o??s??So(t.image)??So(t.video)??So(t.audio)??So(t.text)??So(t.file)??((r==null?void 0:r.mediaType)==="audio"?i:void 0)??(r==null?void 0:r.assetId)}function EA(e){let t=ll(e,"default"),n={default:YU(e),notWatermark:KU(e),watermark:XU(e)},r=E(e.url),o=UA(e);return{download:Id(n.default,e,o),downloadVariants:{default:Id(n.default,e,o),notWatermark:Id(n.notWatermark,e,o),watermark:Id(n.watermark,e,o)},provisionalPreview:r?{url:r}:void 0,previews:t,previewVariants:{default:t,notWatermark:ll(e,"notWatermark"),watermark:ll(e,"watermark")}}}function Id(e,t,n){return e?{format:zA(void 0,void 0,n),height:qA(void 0,void 0,n,t),size:jA(void 0,void 0,n,t),url:e,width:FA(void 0,void 0,n,t)}:void 0}function ll(e,t){let n={},r=UA(e);for(let o of LU){let s=WU(e,o,t),i=CA(It(s))??CA(QU(e,o));if(i){let a=$U(s);n[o]={format:zA(s,a,r),height:qA(s,a,r,e),size:jA(s,a,r,e),url:i,width:FA(s,a,r,e)}}}return n}function CA(e){return e?vo.SDK.pippitAsset.imagePreviewBlockedUrlPatterns.some(n=>new RegExp(n,"i").test(e))?void 0:e:void 0}function YU(e){var t;return E(e.download_url)??E(e.url)??E(e.dowmload_url)??E(e.DownloadURL)??It($s(R(e.not_watermark_preview)))??It(Xs(R(e.not_watermark_preview)))??E((t=R(e.not_watermark_preview))==null?void 0:t.url)??It($s(R(e.download_preview)))??It(Xs(R(e.download_preview)))??E(e.downsample_url)}function KU(e){let t=R(e.not_watermark_preview),n=R(e.download_preview);return E(e.url)??E(e.dowmload_url)??E(e.DownloadURL)??It($s(t))??It(Xs(t))??E(t==null?void 0:t.url)??It($s(n))??It(Xs(n))??E(e.downsample_url)??E(e.download_url)}function XU(e){let t=R(e.watermark_preview);return E(e.download_url)??It($s(t))??It(Xs(t))??E(t==null?void 0:t.url)}function UA(e){return R(e.metadata)??R(e.Metadata)}function $U(e){return R(e==null?void 0:e.metadata)??R(e==null?void 0:e.Metadata)}function It(e){return E((e==null?void 0:e.preview_url)??(e==null?void 0:e.previewUrl)??(e==null?void 0:e.PreviewURL)??(e==null?void 0:e.url)??(e==null?void 0:e.URL))}function zA(e,t,n){return E((t==null?void 0:t.format)??(t==null?void 0:t.Format)??(t==null?void 0:t.fileFormat)??(t==null?void 0:t.FileFormat)??(e==null?void 0:e.format)??(e==null?void 0:e.Format)??(n==null?void 0:n.format)??(n==null?void 0:n.Format)??(n==null?void 0:n.fileFormat)??(n==null?void 0:n.FileFormat))}function qA(e,t,n,r){return oe((t==null?void 0:t.height)??(t==null?void 0:t.Height)??(e==null?void 0:e.height)??(e==null?void 0:e.Height)??(n==null?void 0:n.height)??(n==null?void 0:n.Height)??(r==null?void 0:r.height)??(r==null?void 0:r.Height))}function FA(e,t,n,r){return oe((t==null?void 0:t.width)??(t==null?void 0:t.Width)??(e==null?void 0:e.width)??(e==null?void 0:e.Width)??(n==null?void 0:n.width)??(n==null?void 0:n.Width)??(r==null?void 0:r.width)??(r==null?void 0:r.Width))}function jA(e,t,n,r){return oe((t==null?void 0:t.size)??(t==null?void 0:t.Size)??(e==null?void 0:e.size)??(e==null?void 0:e.Size)??(n==null?void 0:n.size)??(n==null?void 0:n.Size)??(r==null?void 0:r.size)??(r==null?void 0:r.Size))}function WU(e,t,n){let r=R(e.not_watermark_preview),o=R(e.watermark_preview),s=[R(e.download_preview),R(e.compliance_preview),R(e.brand_preview),R(e.dynamic_preview),R(e.fusion_preview),R(e.share_preview)];if(t==="origin"){let d=R(e.previewinfo)??R(e.preview_info)??R(e.PreviewInfo),c=s.map(u=>R(u==null?void 0:u.previewinfo)).find(Boolean);return n==="watermark"?R(o==null?void 0:o.previewinfo)??d??R(r==null?void 0:r.previewinfo)??c:R(r==null?void 0:r.previewinfo)??d??R(o==null?void 0:o.previewinfo)??c}let i=R(e[`previewinfo_${t}`])??R(e[`preview_info_${t}`])??R(e[`preview_${t}`])??R(e[`preview_video_${t}`])??R(e[VA(t)]),a=s.map(d=>hn(d,t)).find(Boolean);return n==="watermark"?hn(o,t)??i??hn(r,t)??a:hn(r,t)??i??hn(o,t)??a}function hn(e,t){return R(e==null?void 0:e[`previewinfo_${t}`])??R(e==null?void 0:e[`preview_info_${t}`])??R(e==null?void 0:e[`preview_${t}`])??R(e==null?void 0:e[VA(t)])}function Xs(e){return hn(e,"2048p")??hn(e,"1080p")??hn(e,"720p")??hn(e,"480p")??R(e==null?void 0:e.previewinfo)??R(e==null?void 0:e.preview_info)??R(e==null?void 0:e.PreviewInfo)}function $s(e){return R(e==null?void 0:e.previewinfo)??R(e==null?void 0:e.preview_info)??R(e==null?void 0:e.PreviewInfo)}function VA(e){return`PreviewInfo_${e.toUpperCase()}`}function QU(e,t){return t==="origin"?E(e.preview_url??e.previewUrl??e.PreviewURL??e.downsample_url):E(e[`preview_url_${t}`]??e[`previewUrl_${t}`]??e[`PreviewURL_${t.toUpperCase()}`]??e[`url_${t}`]??e[`URL_${t.toUpperCase()}`])}function PA(e){let t=R(e.no_watermark_video_url??e.noWatermarkVideoUrl),n=R(e.metadata),r=fl(e.extra??e.Extra),o=E(e.downloadUrl)??E(e.download_url),s=E(e.originUrl)??E(e.origin_url)??E(t==null?void 0:t.downloadUrl)??E(t==null?void 0:t.download_url),i=E(e.previewUrl)??E(e.preview_url),a=E(t==null?void 0:t.previewUrl)??E(t==null?void 0:t.preview_url)??E(e.originPreviewUrl)??E(e.origin_preview_url),d=a??E(e.previewUrl_720p)??E(e.preview_url_720p)??E(e.previewUrl_1080p)??E(e.preview_url_1080p)??E(e.previewUrl_480p)??E(e.preview_url_480p)??i??s??o;return{coverUrl:RA(e)??E(e.coverUrl)??E(e.cover_url),draftKey:E(e.draftKey??e.draft_key??e.DraftKey??(r==null?void 0:r.draftKey)??(r==null?void 0:r.draft_key)),downloadUrl:s??o,downloadVariants:{notWatermark:s,watermark:o},durationMs:oe(e.durationMs??e.duration_ms??(n==null?void 0:n.durationMs)??(n==null?void 0:n.duration_ms)),extra:r,fps:oe(e.fps??(n==null?void 0:n.fps)),height:oe(e.height??(n==null?void 0:n.height)),packageId:E(e.packageID??e.packageId??e.package_id??e.PackageID??(r==null?void 0:r.packageID)??(r==null?void 0:r.packageId)??(r==null?void 0:r.package_id)),previewUrl:d,previewVariants:{notWatermark:a,watermark:i},spriteFrames:JU(e),renderTaskId:E(e.renderTaskID??e.renderTaskId??e.render_task_id??e.RenderTaskID??(r==null?void 0:r.renderTaskID)??(r==null?void 0:r.renderTaskId)??(r==null?void 0:r.render_task_id)),width:oe(e.width??(n==null?void 0:n.width))}}function JU(e){let t=ye(e.sprite_info??e.spriteInfo??e.SpriteInfo);if(!(t!=null&&t.length))return;let n=t.map(ZU);if(n.some(i=>!i))return;let r=n,[{frameHeight:o,frameWidth:s}]=r;if(!r.some(i=>i.frameHeight!==o||i.frameWidth!==s))return{frameCount:r.reduce((i,a)=>i+a.image.frameCount,0),frameHeight:o,frameWidth:s,images:r.map(i=>i.image)}}function ZU(e){let t=R(e),n=Rr((t==null?void 0:t.sprite_num)??(t==null?void 0:t.spriteNum)),r=Rr((t==null?void 0:t.image_height)??(t==null?void 0:t.imageHeight)),o=Rr((t==null?void 0:t.image_width)??(t==null?void 0:t.imageWidth)),s=Rr((t==null?void 0:t.canvas_height)??(t==null?void 0:t.canvasHeight)),i=Rr((t==null?void 0:t.canvas_width)??(t==null?void 0:t.canvasWidth)),a=Rr((t==null?void 0:t.image_x_num)??(t==null?void 0:t.imageXNum)),d=Rr((t==null?void 0:t.image_y_num)??(t==null?void 0:t.imageYNum)),c=E((t==null?void 0:t.url)??(t==null?void 0:t.URL));if(!(!n||!r||!o||!s||!i||!a||!d||!c)&&!(n>a*d||i!==o*a||s!==r*d))return{frameHeight:r,frameWidth:o,image:{frameCount:n,height:s,url:c,width:i}}}function Rr(e){let t=oe(e);return t!==void 0&&Number.isInteger(t)&&t>0?t:void 0}function xA(e){return{downloadUrl:E(e.download_url??e.origin_url),durationMs:oe(e.duration_ms),mimeType:E(e.mime_type??e.mimeType??e.format),name:E(e.name??e.Name),previewUrl:E(e.preview_url??e.download_url??e.origin_url),size:oe(e.size)}}function TA(e){return{content:E(e.content??e.text),downloadUrl:E(e.download_url),mimeType:E(e.mime_type??e.mimeType),name:E(e.name),previewUrl:E(e.preview_url??e.origin_url),size:oe(e.size)}}function NA(e){return{downloadUrl:E(e.download_url??e.origin_url??e.internal_url),extension:E(e.extension??e.ext),format:E(e.format),mimeType:E(e.mime_type??e.mimeType),name:E(e.name),previewUrl:E(e.preview_url),size:oe(e.size)}}function wA(e){return!!(e.url||e.preview_url||e.download_url||e.dowmload_url||e.DownloadURL||e.downsample_url||e.PreviewURL||e.URL||e.previewinfo||e.PreviewInfo||e.previewinfo_720p||e.PreviewInfo_720P||e.previewinfo_1080p||e.PreviewInfo_1080P||e.previewinfo_480p||e.PreviewInfo_480P||e.previewinfo_2048p||e.PreviewInfo_2048P||e.not_watermark_preview||e.watermark_preview||e.download_preview||e.compliance_preview||e.brand_preview||e.dynamic_preview||e.fusion_preview||e.share_preview)}function OA(e){return!!(e.preview_url||e.download_url||e.origin_url||e.internal_url||e.preview_url_720p||e.preview_url_1080p||e.preview_url_480p||e.no_watermark_video_url||e.preview_key_720p||e.vid||e.render_task_id)}function DA(e){var r,o;let t=(r=E(e.mime_type??e.mimeType))==null?void 0:r.toLowerCase(),n=(o=E(e.format))==null?void 0:o.toLowerCase();return!!(t!=null&&t.startsWith("audio/")||["mp3","wav","aac","m4a","ogg"].includes(n??"")||e.audio_url||e.preview_url||e.download_url||e.origin_url||e.internal_url)}function kA(e){var n;let t=(n=E(e.mime_type??e.mimeType))==null?void 0:n.toLowerCase();return!!(t!=null&&t.startsWith("text/")||e.text||e.content||e.download_url)}function MA(e){return!!(e.download_url||e.origin_url||e.name)}function _d(e){let t=R(e),n=R(t==null?void 0:t.data),r=ye(t==null?void 0:t.assets)??ye(n==null?void 0:n.assets)??ye(t==null?void 0:t.Assets)??ye(n==null?void 0:n.Assets)??ye(t==null?void 0:t.AgentAsset)??ye(n==null?void 0:n.AgentAsset)??ye(t==null?void 0:t.agentAsset)??ye(n==null?void 0:n.agentAsset)??ye(t==null?void 0:t.asset_list);return HA(r)}function Ws(e){let t=R(e),n=R(t==null?void 0:t.data),r=ye(t==null?void 0:t.asset_infos)??ye(n==null?void 0:n.asset_infos)??ye(t==null?void 0:t.assets)??ye(n==null?void 0:n.assets)??ye(t==null?void 0:t.data);return HA(r)}function HA(e){return(e??[]).map(R).filter(Boolean)}var ez=200,tz=20;function YA(e){if((e==null?void 0:e.reason)!==void 0)return e.reason;let t=new Error("Pippit asset info caller aborted");return t.name="AbortError",t}function KA(){let e=new Error("Pippit asset info coordinator disposed");return e.name="AbortError",e}function XA(e,t){return Number.isFinite(e)&&Number(e)>0?Math.max(1,Math.floor(Number(e))):t}function $A(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))]}function nz(e){return[(e==null?void 0:e.cachePolicy)??"default",e!=null&&e.refresh?"refresh":"default",(e==null?void 0:e.mediaType)??"",(e==null?void 0:e.purpose)??""].join(":")}function ml(e){e.timer&&(clearTimeout(e.timer),e.timer=void 0)}function Rd(e,t){var n;e.settled||(e.settled=!0,(n=e.cleanupAbort)==null||n.call(e),t.status==="rejected"?e.reject(t.error):e.resolve(t.response))}function rz(e,t){let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}function oz(e){return E(e.asset_id??e.assetId)}function sz(e,t){let n=new Map,r=new Set,o=0;return e.forEach(s=>{let i=oz(s);!i||!t.includes(i)||r.has(i)||(o+=1,r.add(i),n.set(i,s))}),o===0&&e.length===t.length&&e.forEach((s,i)=>{let a=t[i];a&&n.set(a,s)}),n}function WA(e,t={}){let n=XA(t.batchDelayMs,ez),r=XA(t.maxBatchSize,tz),o=new Map,s=new Set,i=!1,a=async c=>{var h;let u=o.get(c);if(!u)return;o.delete(c),ml(u),s.add(u);let p=u.callers.filter(m=>!m.settled),l=$A(p.flatMap(m=>m.ids));if(!l.length){s.delete(u);return}let f={...(h=p[0])==null?void 0:h.options,signal:u.abortController.signal};try{let m=await Promise.all(rz(l,r).map(async y=>{let v=await e({asset_ids:y},f);return sz(Ws(v),y)})),g=new Map;m.forEach(y=>y.forEach((v,S)=>g.set(S,v))),p.forEach(y=>Rd(y,{response:{asset_infos:y.ids.map(v=>g.get(v)).filter(v=>!!v)},status:"resolved"}))}catch(m){p.forEach(g=>Rd(g,{error:m,status:"rejected"}))}finally{s.delete(u)}},d=(c,u)=>new Promise((p,l)=>{let f=nz(u),h=o.get(f),m=h??{abortController:new AbortController,callers:[]},g={ids:c,options:u,reject:l,resolve:p,settled:!1};m.callers.push(g);let y=u==null?void 0:u.signal;if(y){let S=()=>{Rd(g,{error:YA(y),status:"rejected"}),m.callers.every(b=>b.settled)&&(o.get(f)===m&&(o.delete(f),ml(m)),m.abortController.abort())};g.cleanupAbort=()=>y.removeEventListener("abort",S),y.addEventListener("abort",S,{once:!0}),y.aborted&&S()}if(g.settled)return;h||o.set(f,m),(u==null?void 0:u.dispatchMode)==="immediate"?a(f):h||(m.timer=setTimeout(()=>void a(f),n))});return{dispose:()=>{if(i)return;i=!0;let c=KA(),u=new Set([...o.values(),...s]);o.clear(),u.forEach(p=>{ml(p),p.abortController.abort(),p.callers.forEach(l=>Rd(l,{error:c,status:"rejected"}))}),s.clear()},query:(c,u)=>{var l;if(i)return Promise.reject(KA());if((l=u==null?void 0:u.signal)!=null&&l.aborted)return Promise.reject(YA(u.signal));let p=$A(c.asset_ids);return p.length?d(p,u):Promise.resolve({asset_infos:[]})}}}var iz=["origin",...ho.filter(e=>e!=="origin")];function JA(e,t){var n,r,o;return((r=(n=e==null?void 0:e.image)==null?void 0:n.previewVariants)==null?void 0:r[t])??((o=e==null?void 0:e.image)==null?void 0:o.previews)}function ZA(e,t){var n,r,o;return((r=(n=e==null?void 0:e.image)==null?void 0:n.downloadVariants)==null?void 0:r[t])??((o=e==null?void 0:e.image)==null?void 0:o.download)}function Qs(e,t,n){let r=JA(e,n);if(r)for(let o of t){let s=r[o];if(s!=null&&s.url)return s}}function az(e,t,n){var a,d;let r=Qs(e,rd,t),o=Qs(e,od,t),s=Qs(e,ho,t),i=Qs(e,[n],t)??o??s??r;if(i)return{metadata:{format:i.format??(s==null?void 0:s.format)??(o==null?void 0:o.format)??(r==null?void 0:r.format),height:i.height??(s==null?void 0:s.height)??(o==null?void 0:o.height)??(r==null?void 0:r.height),imageVariant:t,size:i.size??(s==null?void 0:s.size)??(o==null?void 0:o.size)??(r==null?void 0:r.size),width:i.width??(s==null?void 0:s.width)??(o==null?void 0:o.width)??(r==null?void 0:r.width)},raw:e==null?void 0:e.raw,type:"image",urls:{download:((a=ZA(e,t))==null?void 0:a.url)??((d=Qs(e,["origin",...ho],t))==null?void 0:d.url)??(s==null?void 0:s.url)??i.url,high:(s==null?void 0:s.url)??(o==null?void 0:o.url)??(r==null?void 0:r.url)??i.url,low:(r==null?void 0:r.url)??(o==null?void 0:o.url)??(s==null?void 0:s.url)??i.url,medium:(o==null?void 0:o.url)??(s==null?void 0:s.url)??(r==null?void 0:r.url)??i.url,url:i.url}}}function dz(e,t,n){let r=(e==null?void 0:e.assetId)??(e==null?void 0:e.pippitAssetId)??"image",{url:o}=n;return{identity:bt({assetId:e==null?void 0:e.assetId,pippitAssetId:e==null?void 0:e.pippitAssetId}),isProvisional:!0,metadata:{assetId:e==null?void 0:e.assetId,format:n.format,height:n.height,imageVariant:t,pippitAssetId:e==null?void 0:e.pippitAssetId,resolution:"origin",size:n.size,width:n.width},preview:{metadata:{format:n.format,height:n.height,imageVariant:t,size:n.size,width:n.width},raw:e==null?void 0:e.raw,type:"image",urls:{url:o}},url:o,version:`${r}:origin:${t}:provisional:${mn(o)}`}}function cz(e){var o,s,i;let t=(o=e==null?void 0:e.video)==null?void 0:o.coverUrl;if(!t)return;let n=(e==null?void 0:e.assetId)??(e==null?void 0:e.pippitAssetId)??"video-cover",r={height:(s=e==null?void 0:e.video)==null?void 0:s.height,width:(i=e==null?void 0:e.video)==null?void 0:i.width};return{identity:bt({assetId:e==null?void 0:e.assetId,pippitAssetId:e==null?void 0:e.pippitAssetId}),metadata:{assetId:e==null?void 0:e.assetId,...r,pippitAssetId:e==null?void 0:e.pippitAssetId,resolution:"origin"},preview:{metadata:r,raw:e==null?void 0:e.raw,type:"image",urls:{download:t,high:t,low:t,medium:t,poster:t,url:t}},url:t,version:`${n}:video-cover:${mn(t)}`}}function QA(e,t,n,r,o){let s=(e==null?void 0:e.assetId)??(e==null?void 0:e.pippitAssetId)??"image";return{identity:bt({assetId:e==null?void 0:e.assetId,pippitAssetId:e==null?void 0:e.pippitAssetId}),metadata:{assetId:e==null?void 0:e.assetId,format:r==null?void 0:r.format,height:r==null?void 0:r.height,imageVariant:t,pippitAssetId:e==null?void 0:e.pippitAssetId,resolution:n,size:r==null?void 0:r.size,width:r==null?void 0:r.width},preview:az(e,t,n),url:o,version:`${s}:${n}:${t}:${mn(o)}`}}function ev(e,t){var a,d;let n=t.imageVariant??"default",r=JA(e,n),o=ZA(e,n);if(t.purpose==="download"&&(o!=null&&o.url))return QA(e,n,"origin",o,o.url);let s=t.purpose==="download"?iz:Ly(t);for(let c of s){let u=(a=r==null?void 0:r[c])==null?void 0:a.url;if(u)return QA(e,n,c,r==null?void 0:r[c],u)}let i=(d=e==null?void 0:e.image)==null?void 0:d.provisionalPreview;return t.purpose==="preview"&&n==="default"&&(i!=null&&i.url)?dz(e,n,i):cz(e)}function nv(e){return e?{createAsset:async t=>{if(e.createAsset)return e.createAsset(t);let n=await uz(e,t),r=await hl(e,{intent:"asset.create",patches:[{baseVersion:0,op:"add",path:"",ref:n,value:hz(t)}],signal:t.signal});return{raw:r.raw,ref:n,version:tv(r,n)}},patchAssets:async t=>e.patchAssets?e.patchAssets(t):hl(e,t),updateAsset:async(t,n)=>{let r=K(t);if(e.updateAsset)return e.updateAsset(r,n);let o=await hl(e,{intent:n.intent??"asset.update",patches:pz(r,n),signal:n.signal,transactionId:n.transactionId});return{raw:o.raw,ref:r,version:tv(o,r)}}}:{}}async function uz(e,t){if(t.ref)return K(t.ref);if(!e.batchGeneratePippitAssetIds)throw new Error("Pippit asset create requires request.ref or batchGeneratePippitAssetIds.");let n=await e.batchGeneratePippitAssetIds({count:1}),r=gz(n);if(!r)throw new Error("Pippit asset ID generation returned no usable pippitAssetId.");return K({mediaType:t.mediaType,pippitAssetId:r})}function pz(e,t){var n;return(n=t.patches)!=null&&n.length?t.patches.map(r=>({...r,ref:K(r.ref)})):[{op:"replace",path:"",ref:e,value:t.content??{metadata:t.metadata}}]}async function hl(e,t){var s,i;if(!e.batchPatchAsset)throw new Error("Pippit asset batchPatchAsset transport is not configured.");let n=lz(t),r=n.transactionId||`asset_patch_${Date.now()}`,o=await e.batchPatchAsset({batch_id:n.batchId||`batch_${r}`,client_id:n.clientId||`client_${r}`,root_pippit_asset_id:((s=n.rootRef)==null?void 0:s.pippitAssetId)??((i=n.patches[0])==null?void 0:i.ref.pippitAssetId),transactions:[{attempt:1,enqueued_at:Date.now(),intent:n.intent,patches:n.patches.map(fz),transaction_id:r}]});return rv(o,"Pippit asset patch failed."),{raw:o,versions:yz(o,r)}}function lz(e){return{...e,patches:e.patches.map(t=>({...t,ref:K(t.ref)})),rootRef:e.rootRef?K(e.rootRef):void 0}}function fz(e){return{asset_id:mz(e.ref),base_asset_version:e.baseVersion,op:e.op,path:e.path,...e.op==="remove"?{}:{value:e.value}}}function mz(e){return e.pippitAssetId??e.assetId}function hz(e){return e.content!==void 0?e.content:{mediaType:e.mediaType,metadata:e.metadata}}function tv(e,t){var r;let n=t.pippitAssetId??t.assetId;return n?(r=e.versions)==null?void 0:r[n]:void 0}function gz(e){rv(e,"Pippit asset ID generation failed.");let t=R(e),n=R(t==null?void 0:t.data),r=ye(n==null?void 0:n.ids)??ye(t==null?void 0:t.ids),o=r==null?void 0:r.find(Ks);return o==null?void 0:o.trim()}function rv(e,t){let n=R(e),r=Number((n==null?void 0:n.ret)??0);if(Number.isNaN(r)||r!==0)throw new Error(typeof(n==null?void 0:n.errmsg)=="string"?n.errmsg:t)}function yz(e,t){let n=R(e),r=R(n==null?void 0:n.data),o=ye(r==null?void 0:r.results)??ye(n==null?void 0:n.results),s=o==null?void 0:o.find(c=>{let u=R(c);return(u==null?void 0:u.transaction_id)===t||(u==null?void 0:u.transactionId)===t}),i=R(s)??R(o==null?void 0:o[0]),a=R(i==null?void 0:i.asset_versions)??R(i==null?void 0:i.assetVersions);if(!a)return;let d={};for(let[c,u]of Object.entries(a)){let p=oe(u);p!==void 0&&(d[c]=p)}return Object.keys(d).length?d:void 0}function ov(e){return Number.isFinite(e)&&e>0?Math.max(1,Math.floor(e)):1}function gn(e,t,n){if(e.length===0)return[];let r=ov(t),o=ov(n),s=Math.ceil(e.length/r),i=Math.min(e.length,Math.max(s,o)),a=Math.floor(e.length/i),d=e.length%i,c=[],u=0;for(let p=0;p<i;p+=1){let l=a+(p<d?1:0);c.push(e.slice(u,u+l)),u+=l}return c}var Az=200,vz=150,Sz=20,bz=2,Iz=500,Ed=()=>{let e=new Error("Pippit asset query coordinator disposed");return e.name="AbortError",e},gl=e=>{e.timer&&(clearTimeout(e.timer),e.timer=void 0)},Cd=e=>{if((e==null?void 0:e.reason)!==void 0)return e.reason;let t=new Error("Pippit asset query caller aborted");return t.name="AbortError",t},Js=(e,t)=>{var n;e.settled||(e.settled=!0,(n=e.cleanupAbort)==null||n.call(e),t.status==="rejected"?e.reject(t.error):e.resolve(t.records))},sv=(e,t,n,r,o,s)=>new Promise((i,a)=>{let{cacheKey:d,queueKey:c}=t,u={ids:n,options:r,reject:a,resolve:i,settled:!1},p=e.get(c),l=p??{abortController:new AbortController,cacheKey:d,callers:[]};l.callers.push(u);let f=r==null?void 0:r.signal;if(f){let h=()=>{Js(u,{error:Cd(f),status:"rejected"}),l.callers.every(m=>m.settled)&&(e.get(c)===l&&(gl(l),e.delete(c)),l.abortController.abort())};u.cleanupAbort=()=>f.removeEventListener("abort",h),f.addEventListener("abort",h,{once:!0}),f.aborted&&h()}if(!u.settled){if(p){(r==null?void 0:r.dispatchMode)==="immediate"&&(gl(p),s.flush(e,c,o));return}if(e.set(c,l),(r==null?void 0:r.dispatchMode)==="immediate")return void s.flush(e,c,o);l.timer=setTimeout(()=>void s.flush(e,c,o),s.batchDelayMs)}}),Pd=e=>e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(Pd).join(",")}]`:`{${Object.entries(e).filter(([,t])=>t!==void 0).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>`${JSON.stringify(t)}:${Pd(n)}`).join(",")}}`,iv=e=>E(e.pippit_asset_id??e.pippitAssetId??e.PippitAssetID),av=(e,t)=>(e==null?void 0:e.batchingStrategy)??t.batchingStrategy??"max-size",_z=(e,t)=>Pd({batchingStrategy:t,cacheKey:e}),Rz=(e,t)=>{let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n},Ez=(e,t,n,r)=>t==="balanced"?gn(e,n,r):Rz(e,Math.max(1,n)),Cz=e=>{let t=n=>{let r={pippit_asset_ids:n};return(typeof e.bodyExtra=="function"?e.bodyExtra(r):e.bodyExtra)??{}};return{bodyExtraFor:t,cacheKeyFor:n=>Pd({bodyExtra:t(n),scopeKey:e.scopeKey})}};function xd(e,t={}){let n=new Map,r=new Map,o=new Map,s=new Map,i=new Set,a=t.batchDelayMs??Az,d=t.cacheTtlMs??Iz,c=t.maxBatchSize??vz,u=t.maxAttempts??bz,p=t.maxConcurrentChunks??Sz,l=Cz(t),f=0,h=0,m=!1,g=[],y=async Y=>{var T;if(m||(f>=p&&await new Promise(F=>g.push(F)),m))throw Ed();f+=1;try{return await Y()}finally{f-=1,(T=g.shift())==null||T()}},v=(Y,T)=>Ez(Y,av(T,t),c,p),S=(Y,T)=>{let F=Date.now(),j=[];for(let J of Y){let ie=`${T}:${J}`,Se=o.get(ie);if(!Se||Se.expiresAt<=F)return o.delete(ie),{complete:!1,records:[]};Se.record&&j.push(Se.record)}return{complete:!0,records:j}},b=async(Y,T)=>{var J,ie;let F={...l.bodyExtraFor(Y),pippit_asset_ids:Y},j;for(let Se=1;Se<=Math.max(1,u);Se+=1){if((J=T==null?void 0:T.signal)!=null&&J.aborted)throw Cd(T.signal);try{return _d(await e(F,T))}catch(He){if((ie=T==null?void 0:T.signal)!=null&&ie.aborted)throw Cd(T.signal);j=He}}throw j},I=async(Y,T,F)=>{let j=h,J=Date.now(),ie=new Map,Se=[],He=[];Y.forEach(re=>{let St=`${T}:${re}`,We=o.get(St);if(We&&We.expiresAt>J){We.record&&ie.set(re,We.record);return}o.delete(St);let pn=s.get(St);if(pn){Se.push(pn.then(Ue=>{Ue&&ie.set(re,Ue)}));return}He.push(re)});let ge=v(He,F).map(async re=>{let We=y(()=>b(re,F)).then(Ue=>{let Qe=new Map;return Ue.forEach(Mt=>{let ut=iv(Mt);ut&&Qe.set(ut,Mt)}),Qe});re.forEach(Ue=>{let Qe=`${T}:${Ue}`,Mt=We.then(Fs=>Fs.get(Ue)??null);s.set(Qe,Mt);let ut=()=>{s.get(Qe)===Mt&&s.delete(Qe)};Mt.then(ut,ut)});let pn=await We;re.forEach(Ue=>{let Qe=pn.get(Ue)??null;!m&&h===j&&o.set(`${T}:${Ue}`,{expiresAt:Date.now()+d,record:Qe}),Qe&&ie.set(Ue,Qe)})});return await Promise.all([...ge,...Se]),ie},N=async(Y,T,F)=>{let j=h,J=new Map;return await Promise.all(v(Y,F).map(async ie=>{let Se=await y(()=>b(ie,F)),He=new Map;Se.forEach(ge=>{let re=iv(ge);re&&He.set(re,ge)}),ie.forEach(ge=>{let re=He.get(ge)??null;!m&&h===j&&o.set(`${T}:${ge}`,{expiresAt:Date.now()+d,record:re}),re&&J.set(ge,re)})})),J},w=async(Y,T,F)=>{var He;let j=Y.get(T);if(!j)return;Y.delete(T),i.add(j);let J=j.callers.filter(ge=>!ge.settled),ie=[...new Set(J.flatMap(ge=>ge.ids))],Se={...(He=J[0])==null?void 0:He.options,signal:j.abortController.signal};try{let ge=await F(ie,j.cacheKey,Se);J.forEach(re=>Js(re,{records:re.ids.map(St=>ge.get(St)).filter(St=>!!St),status:"resolved"}))}catch(ge){J.forEach(re=>Js(re,{error:ge,status:"rejected"}))}finally{i.delete(j)}},ne=()=>{h+=1,o.clear(),s.clear()};return{clear:ne,dispose:()=>{if(m)return;m=!0,h+=1;let Y=Ed();[n,r].forEach(T=>{T.forEach(F=>{gl(F),F.abortController.abort(),F.callers.forEach(j=>Js(j,{error:Y,status:"rejected"}))}),T.clear()}),i.forEach(T=>{T.abortController.abort(),T.callers.forEach(F=>Js(F,{error:Y,status:"rejected"}))}),o.clear(),s.clear(),g.splice(0).forEach(T=>T())},invalidate:ne,query:(Y,T)=>{var Se;if(m)return Promise.reject(Ed());if((Se=T==null?void 0:T.signal)!=null&&Se.aborted)return Promise.reject(Cd(T.signal));let F=[...new Set(Y.map(He=>He.trim()).filter(Boolean))];if(!F.length)return Promise.resolve([]);let j=l.cacheKeyFor(F),J=_z(j,av(T,t));if((T==null?void 0:T.cachePolicy)==="refresh")return sv(r,{cacheKey:j,queueKey:J},F,T,N,{batchDelayMs:a,flush:w});let ie=S(F,j);return ie.complete?Promise.resolve(ie.records):sv(n,{cacheKey:j,queueKey:J},F,T,I,{batchDelayMs:a,flush:w})}}}function yl({assetInfo:e,assetQuery:t,mgetAssetInfo:n,mutation:r,query:o,resolveEncryptedUrl:s,shouldUseAssetQuerySource:i,subscription:a,upload:d}){let c=nv(r),u=t&&o?xd(t,o):void 0,p=u?(m,g)=>u.query(m.pippit_asset_ids,g).then(y=>({data:{Assets:y},ret:0})):t,l=n&&e!==!1?WA(n,e):void 0,f=l?(m,g)=>l.query(m,g):n,h=a?Zp(a):void 0;return{...c,allocateAssetIds:r!=null&&r.batchGeneratePippitAssetIds?async m=>{var g;return xz(await((g=r.batchGeneratePippitAssetIds)==null?void 0:g.call(r,{count:m})),m)}:void 0,dispose:()=>{l==null||l.dispose(),u==null||u.dispose(),h==null||h.dispose()},invalidateAssets:()=>u==null?void 0:u.invalidate(),async queryAssets(m,g){let y=await Td(m,{assetQuery:p},g),v=m.filter(I=>Tz(I,y)),S=await uv(v,{mgetAssetInfo:f},g),b=m.map(I=>{if(I.pippitAssetId){let N=y.get(I.pippitAssetId);return N?(Nd(I,N),N):dv(I,S)}return dv(I,S)}).filter(I=>!!I);return Promise.all(b.map(I=>Pz(I,g)))},async resolveSource(m,g){if(g.mediaType==="image"){let v=await cv(m,{assetQuery:p,mgetAssetInfo:f},g),S=ev(v,g);if(S!=null&&S.isProvisional&&g.allowProvisionalImage===!1)throw new ze("Public image preview is not ready yet.");if(!S)throw new ze("No image source URL found yet.");return S}if(g.mediaType==="audio"){let v=await cv(m,{assetQuery:p,mgetAssetInfo:f},g),S=al(v,g);if(!S)throw new ze("No audio source URL found yet.");return S}if(g.mediaType!=="video")throw new Error(`Source resolution for ${g.mediaType} assets is not supported.`);let y=await Dz(m,g,{assetQuery:p,mgetAssetInfo:f,resolveEncryptedUrl:s,shouldUseAssetQuerySource:i});if(!y)throw new ze("No video source URL found yet.");return y},subscribeAssetEvents:h?(m,g,y)=>h.subscribe(m,g,y):void 0,upload:d}}async function Pz(e,t){var r,o;if(e.mediaType!=="text"||(r=e.text)!=null&&r.content||!((o=e.text)!=null&&o.downloadUrl))return e;let n=await fetch(e.text.downloadUrl,{signal:t.signal});if(!n.ok)throw new Error(`Failed to download Pippit text asset: ${n.status} ${n.statusText}`);return{...e,text:{...e.text,content:await n.text()}}}function xz(e,t){let n=e&&typeof e=="object"?e:void 0,r=Number((n==null?void 0:n.ret)??0);if(Number.isNaN(r)||r!==0)throw new Error(typeof(n==null?void 0:n.errmsg)=="string"?n.errmsg:"Pippit asset ID generation failed.");let o=n!=null&&n.data&&typeof n.data=="object"&&!Array.isArray(n.data)?n.data:void 0,i=(Array.isArray(o==null?void 0:o.ids)?o.ids:Array.isArray(n==null?void 0:n.ids)?n.ids:[]).filter(a=>typeof a=="string"&&!!a.trim());if(i.length<t)throw new Error(`Pippit asset ID generation returned ${i.length}/${t} IDs.`);return i}function Tz(e,t){return e.assetId?e.pippitAssetId?!t.has(e.pippitAssetId):!0:!1}function dv(e,t){return e.assetId?t.get(e.assetId):void 0}async function Td(e,t,n){let r=pv(e.map(s=>s.pippitAssetId).filter(Ks));if(!r.length)return new Map;if(!t.assetQuery){if(e.filter(s=>s.pippitAssetId).every(s=>s.assetId))return new Map;throw new Error("assetQuery is not configured.")}let o=await t.assetQuery({pippit_asset_ids:r},n);return new Map(_d(o).map(s=>{let i=Nz(s),a=e.find(d=>d.pippitAssetId===i);return LA(s,a)}).filter(s=>s.pippitAssetId).map(s=>[s.pippitAssetId,s]))}function Nz(e){return E(e.pippit_asset_id??e.pippitAssetId??e.PippitAssetID)}async function uv(e,t,n){let r=e.filter(d=>Ks(d.assetId)),o=pv(r.map(d=>d.assetId));if(!o.length)return new Map;if(!t.mgetAssetInfo){if(r.every(d=>d.pippitAssetId))return new Map;throw new Error("mgetAssetInfo is not configured.")}let s=await t.mgetAssetInfo({asset_ids:o},n),i=Ws(s),a=Oz(i,r);return new Map(i.map((d,c)=>{let u=a[c],p=BA(d,u),l=(u==null?void 0:u.assetId)??p.assetId;return l?[l,p]:void 0}).filter(d=>!!d))}function wz(e){return typeof e.asset_id=="string"&&e.asset_id.trim()?e.asset_id.trim():typeof e.assetId=="string"&&e.assetId.trim()?e.assetId.trim():void 0}function Oz(e,t){let n=e.map(()=>{}),r=new Set,o=0;return e.forEach((i,a)=>{let d=wz(i);if(!d)return;let c=t.findIndex((u,p)=>!r.has(p)&&u.assetId===d);c>=0&&(r.add(c),n[a]=t[c],o+=1)}),o===0&&e.length===t.length&&e.forEach((i,a)=>{n[a]=t[a]}),n}function pv(e){return Array.from(new Set(e))}async function Dz(e,t,n){return kz(e)&&Mz(t,n)&&await Lz(e,t,n)?Bz(e,t,n):zz(e,t,n)}function kz(e){return!!e.pippitAssetId}function Mz(e,t){return!e.refresh&&!!(t.assetQuery&&t.shouldUseAssetQuerySource)}async function Lz(e,t,n){var r,o;try{return!!await((r=n.shouldUseAssetQuerySource)==null?void 0:r.call(n,{options:t,ref:e}))}catch(s){if((o=t.signal)!=null&&o.aborted)throw s;return!1}}async function Bz(e,t,n){let r=await Uz(e,t,n),o=lv(r)?void 0:ul(r,t);if(jz(o,t))return Zs(o,r);let s=Gz(e,r);return s?fv(e,s,t,n,r??hv(e)):o?Zs(o,r):void 0}function lv(e){return(e==null?void 0:e.playerInfoVersion)!==1}function Gz(e,t){return lv(t)?e.assetId??(t==null?void 0:t.assetId):(t==null?void 0:t.assetId)??e.assetId}async function Uz(e,t,n){var r;try{let s=(await Td([e],n,t)).get(e.pippitAssetId);return s&&Nd(e,s),s}catch(o){if((r=t.signal)!=null&&r.aborted)throw o;return}}async function zz(e,t,n){if(e.assetId){let s=await mv(e.assetId,t,n);return Vz(s,hv(e))}let r=await Fz(e,t,n);if(r!=null&&r.assetId)return fv(e,r.assetId,t,n,r,{strictAssetId:!0});let o=t.purpose==="download"?ul(r,t):void 0;if(o)return Zs(o,r);throw!e.pippitAssetId||!n.assetQuery?new Error("resolveSource requires assetId or assetQuery with pippitAssetId."):t.purpose==="preview"?new ze("AssetQuery did not return an asset_id for source resolution."):new Error("AssetQuery did not return an asset_id for source resolution.")}async function fv(e,t,n,r,o,s={}){let i=qz(e,t,n);try{let a=await mv(t,n,r,s);if(!a&&i)throw Vp(new ze("No video source URL found yet."),i);return a&&Zs(a,o)}catch(a){throw!i||!Gt(a)||cd(a)?a:Vp(a,i)}}function qz(e,t,n){if(!(e.assetId||!e.pippitAssetId||n.mediaType!=="video"||n.purpose!=="preview"))return{assetId:t,mediaType:"video",pippitAssetId:e.pippitAssetId}}async function Fz(e,t,n){if(!e.pippitAssetId||!n.assetQuery)return;let o=(await Td([e],n,t)).get(e.pippitAssetId);return o&&Nd(e,o),o}function jz(e,t){var n,r;return e?t.purpose==="download"||!!((r=(n=e.preview)==null?void 0:n.urls)!=null&&r.poster):!1}async function mv(e,t,n,r={}){if(!n.mgetAssetInfo)throw new Error("mgetAssetInfo is not configured.");let o=await n.mgetAssetInfo({asset_ids:[e]},t),s=Ws(o)[0];if(!s)throw t.purpose==="preview"?new ze("No video asset info found yet."):new Error("Pippit asset info was not found.");return _A(e,s,t,{resolveEncryptedUrl:n.resolveEncryptedUrl,strictAssetId:r.strictAssetId})}async function cv(e,t,n){if(e.pippitAssetId&&t.assetQuery){let s=(await Td([e],t,n)).get(e.pippitAssetId);if(s)return Nd(e,s),s}return e.assetId?(await uv([e],t,n)).get(e.assetId):void 0}function Nd(e,t){if(e.pippitAssetId&&t.pippitAssetId&&e.pippitAssetId!==t.pippitAssetId)throw new Error(`Resolved pippitAssetId ${t.pippitAssetId} does not match requested pippitAssetId ${e.pippitAssetId}.`);if(!e.pippitAssetId&&e.assetId&&t.assetId&&e.assetId!==t.assetId)throw new Error(`Resolved assetId ${t.assetId} does not match requested assetId ${e.assetId}.`)}function hv(e){return{assetId:e.assetId,mediaType:e.mediaType,pippitAssetId:e.pippitAssetId}}function Vz(e,t){return e?Zs(e,t):void 0}function Zs(e,t){var s,i,a,d,c;let n=bt({assetId:((s=e.identity)==null?void 0:s.assetId)??(t==null?void 0:t.assetId),pippitAssetId:((i=e.identity)==null?void 0:i.pippitAssetId)??(t==null?void 0:t.pippitAssetId)}),r=((d=(a=e.preview)==null?void 0:a.urls)==null?void 0:d.poster)??((c=t==null?void 0:t.video)==null?void 0:c.coverUrl),o={...n!=null&&n.assetId?{assetId:n.assetId}:{},...n!=null&&n.pippitAssetId?{pippitAssetId:n.pippitAssetId}:{}};return{...e,identity:n,metadata:{...e.metadata,...o,...r?{poster:r}:{}},preview:e.preview?{...e.preview,raw:e.preview.raw??(t==null?void 0:t.raw),urls:{...e.preview.urls,...r?{poster:r}:{}}}:void 0}}var lt="canvas";function Ut(e){return e.type===lt}function wd(e){let t=e.assets[e.rootCanvasId];if(!t)throw new Error(`Root canvas asset ${e.rootCanvasId} is missing`);if(!Ut(t))throw new Error(`Root asset ${e.rootCanvasId} is not a canvas`);return t}function x(e){return wd(e).content}var Hz={snap:{enabled:!0,threshold:8,targets:["grid","node"]},grid:{size:28,visible:!0}};function bo(e){let t={pippitAssetId:e,type:lt,content:{metadata:{title:"Canvas",globalBounds:{minX:-4e3,minY:-3e3,maxX:4e3,maxY:3e3}},settings:Hz,nodes:{},edges:{}},extra:{}};return{rootCanvasId:e,assets:{[e]:t}}}var gv;function yv(e){let t=globalThis.console;if(!t||typeof t!="object")return;let n=t[e];return typeof n=="function"?n.bind(t):void 0}function Al(e,t){var n;(n=yv(e))==null||n(...t),e==="error"&&Yz(t)}function Yz(e){var t;if(gv)try{gv({packageName:"canvas-sdk",message:Kz(e),error:Xz(e),context:$z(e)})}catch(n){(t=yv("warn"))==null||t("[canvas-sdk] error reporter failed",n)}}function Kz(e){return e.filter(n=>typeof n=="string"||typeof n=="number"||typeof n=="boolean").map(n=>String(n)).join(" ")||"[canvas-sdk] error"}function Xz(e){for(let t of e){if(t instanceof Error)return t;if(Av(t)&&t.error instanceof Error)return t.error}}function $z(e){let t={},n=20;for(let r of e){if(n<=0)break;if(!(r instanceof Error)&&Av(r))for(let[o,s]of Object.entries(r)){if(n<=0)break;t[o]=Wz(s),n-=1}}return t}function Wz(e){var t;return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e.length>500?`${e.slice(0,500)}...`:e:e===null||typeof e=="number"||typeof e=="boolean"||typeof e>"u"?e:Array.isArray(e)?`[array:${e.length}]`:typeof e=="object"?`[object:${((t=e.constructor)==null?void 0:t.name)||"Object"}]`:String(e)}function Av(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}var Re={error:(...e)=>Al("error",e),info:(...e)=>Al("info",e),warn:(...e)=>Al("warn",e)};var xl=Symbol.for("immer-nothing"),ei=Symbol.for("immer-draftable"),Ze=Symbol.for("immer-state");function Me(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Io=Object.getPrototypeOf;function Cr(e){return!!e&&!!e[Ze]}function jn(e){var t;return e?Rv(e)||Array.isArray(e)||!!e[ei]||!!((t=e.constructor)!=null&&t[ei])||_o(e)||ii(e):!1}var Qz=Object.prototype.constructor.toString(),vv=new WeakMap;function Rv(e){if(!e||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;let n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;if(n===Object)return!0;if(typeof n!="function")return!1;let r=vv.get(n);return r===void 0&&(r=Function.toString.call(n),vv.set(n,r)),r===Qz}function ti(e,t,n=!0){Pr(e)===0?(n?Reflect.ownKeys(e):Object.keys(e)).forEach(o=>{t(o,e[o],e)}):e.forEach((r,o)=>t(o,r,e))}function Pr(e){let t=e[Ze];return t?t.type_:Array.isArray(e)?1:_o(e)?2:ii(e)?3:0}function ni(e,t){return Pr(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function vl(e,t){return Pr(e)===2?e.get(t):e[t]}function Ev(e,t,n){let r=Pr(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function Jz(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function _o(e){return e instanceof Map}function ii(e){return e instanceof Set}function Er(e){return e.copy_||e.base_}function Il(e,t){if(_o(e))return new Map(e);if(ii(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let n=Rv(e);if(t===!0||t==="class_only"&&!n){let r=Object.getOwnPropertyDescriptors(e);delete r[Ze];let o=Reflect.ownKeys(r);for(let s=0;s<o.length;s++){let i=o[s],a=r[i];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(r[i]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[i]})}return Object.create(Io(e),r)}else{let r=Io(e);if(r!==null&&n)return{...e};let o=Object.create(r);return Object.assign(o,e)}}function Tl(e,t=!1){return Md(e)||Cr(e)||!jn(e)||(Pr(e)>1&&Object.defineProperties(e,{set:Od,add:Od,clear:Od,delete:Od}),Object.freeze(e),t&&Object.values(e).forEach(n=>Tl(n,!0))),e}function Zz(){Me(2)}var Od={value:Zz};function Md(e){return e===null||typeof e!="object"?!0:Object.isFrozen(e)}var _l={};function xr(e){let t=_l[e];return t||Me(0,e),t}function eq(e,t){_l[e]||(_l[e]=t)}var ri;function Cv(){return ri}function tq(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Sv(e,t){t&&(xr("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Rl(e){El(e),e.drafts_.forEach(nq),e.drafts_=null}function El(e){e===ri&&(ri=e.parent_)}function bv(e){return ri=tq(ri,e)}function nq(e){let t=e[Ze];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Iv(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];return e!==void 0&&e!==n?(n[Ze].modified_&&(Rl(t),Me(4)),jn(e)&&(e=Dd(t,e),t.parent_||kd(t,e)),t.patches_&&xr("Patches").generateReplacementPatches_(n[Ze].base_,e,t.patches_,t.inversePatches_)):e=Dd(t,n,[]),Rl(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==xl?e:void 0}function Dd(e,t,n){if(Md(t))return t;let r=e.immer_.shouldUseStrictIteration(),o=t[Ze];if(!o)return ti(t,(s,i)=>_v(e,o,t,s,i,n),r),t;if(o.scope_!==e)return t;if(!o.modified_)return kd(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;let s=o.copy_,i=s,a=!1;o.type_===3&&(i=new Set(s),s.clear(),a=!0),ti(i,(d,c)=>_v(e,o,s,d,c,n,a),r),kd(e,s,!1),n&&e.patches_&&xr("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function _v(e,t,n,r,o,s,i){if(o==null||typeof o!="object"&&!i)return;let a=Md(o);if(!(a&&!i)){if(Cr(o)){let d=s&&t&&t.type_!==3&&!ni(t.assigned_,r)?s.concat(r):void 0,c=Dd(e,o,d);if(Ev(n,r,c),Cr(c))e.canAutoFreeze_=!1;else return}else i&&n.add(o);if(jn(o)&&!a){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||t&&t.base_&&t.base_[r]===o&&a)return;Dd(e,o),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&(_o(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&kd(e,o)}}}function kd(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Tl(t,n)}function rq(e,t){let n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:Cv(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},o=r,s=Nl;n&&(o=[r],s=oi);let{revoke:i,proxy:a}=Proxy.revocable(o,s);return r.draft_=a,r.revoke_=i,a}var Nl={get(e,t){if(t===Ze)return e;let n=Er(e);if(!ni(n,t))return oq(e,n,t);let r=n[t];return e.finalized_||!jn(r)?r:r===Sl(e.base_,t)?(bl(e),e.copy_[t]=Pl(r,e)):r},has(e,t){return t in Er(e)},ownKeys(e){return Reflect.ownKeys(Er(e))},set(e,t,n){let r=Pv(Er(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let o=Sl(Er(e),t),s=o==null?void 0:o[Ze];if(s&&s.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(Jz(n,o)&&(n!==void 0||ni(e.base_,t)))return!0;bl(e),Cl(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Sl(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,bl(e),Cl(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=Er(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){Me(11)},getPrototypeOf(e){return Io(e.base_)},setPrototypeOf(){Me(12)}},oi={};ti(Nl,(e,t)=>{oi[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});oi.deleteProperty=function(e,t){return oi.set.call(this,e,t,void 0)};oi.set=function(e,t,n){return Nl.set.call(this,e[0],t,n,e[0])};function Sl(e,t){let n=e[Ze];return(n?Er(n):e)[t]}function oq(e,t,n){var o;let r=Pv(t,n);return r?"value"in r?r.value:(o=r.get)==null?void 0:o.call(e.draft_):void 0}function Pv(e,t){if(!(t in e))return;let n=Io(e);for(;n;){let r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Io(n)}}function Cl(e){e.modified_||(e.modified_=!0,e.parent_&&Cl(e.parent_))}function bl(e){e.copy_||(e.copy_=Il(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var sq=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){let s=n;n=t;let i=this;return function(d=s,...c){return i.produce(d,u=>n.call(this,u,...c))}}typeof n!="function"&&Me(6),r!==void 0&&typeof r!="function"&&Me(7);let o;if(jn(t)){let s=bv(this),i=Pl(t,void 0),a=!0;try{o=n(i),a=!1}finally{a?Rl(s):El(s)}return Sv(s,r),Iv(o,s)}else if(!t||typeof t!="object"){if(o=n(t),o===void 0&&(o=t),o===xl&&(o=void 0),this.autoFreeze_&&Tl(o,!0),r){let s=[],i=[];xr("Patches").generateReplacementPatches_(t,o,s,i),r(s,i)}return o}else Me(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(i,...a)=>this.produceWithPatches(i,d=>t(d,...a));let r,o;return[this.produce(t,n,(i,a)=>{r=i,o=a}),r,o]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),typeof(e==null?void 0:e.useStrictIteration)=="boolean"&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){jn(e)||Me(8),Cr(e)&&(e=iq(e));let t=bv(this),n=Pl(e,void 0);return n[Ze].isManual_=!0,El(t),n}finishDraft(e,t){let n=e&&e[Ze];(!n||!n.isManual_)&&Me(9);let{scope_:r}=n;return Sv(r,t),Iv(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){let o=t[n];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}n>-1&&(t=t.slice(n+1));let r=xr("Patches").applyPatches_;return Cr(e)?r(e,t):this.produce(e,o=>r(o,t))}};function Pl(e,t){let n=_o(e)?xr("MapSet").proxyMap_(e,t):ii(e)?xr("MapSet").proxySet_(e,t):rq(e,t);return(t?t.scope_:Cv()).drafts_.push(n),n}function iq(e){return Cr(e)||Me(10,e),xv(e)}function xv(e){if(!jn(e)||Md(e))return e;let t=e[Ze],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Il(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Il(e,!0);return ti(n,(o,s)=>{Ev(n,o,xv(s))},r),t&&(t.finalized_=!1),n}function zt(){let t="replace",n="add",r="remove";function o(l,f,h,m){switch(l.type_){case 0:case 2:return i(l,f,h,m);case 1:return s(l,f,h,m);case 3:return a(l,f,h,m)}}function s(l,f,h,m){let{base_:g,assigned_:y}=l,v=l.copy_;v.length<g.length&&([g,v]=[v,g],[h,m]=[m,h]);for(let S=0;S<g.length;S++)if(y[S]&&v[S]!==g[S]){let b=f.concat([S]);h.push({op:t,path:b,value:p(v[S])}),m.push({op:t,path:b,value:p(g[S])})}for(let S=g.length;S<v.length;S++){let b=f.concat([S]);h.push({op:n,path:b,value:p(v[S])})}for(let S=v.length-1;g.length<=S;--S){let b=f.concat([S]);m.push({op:r,path:b})}}function i(l,f,h,m){let{base_:g,copy_:y}=l;ti(l.assigned_,(v,S)=>{let b=vl(g,v),I=vl(y,v),N=S?ni(g,v)?t:n:r;if(b===I&&N===t)return;let w=f.concat(v);h.push(N===r?{op:N,path:w}:{op:N,path:w,value:I}),m.push(N===n?{op:r,path:w}:N===r?{op:n,path:w,value:p(b)}:{op:t,path:w,value:p(b)})})}function a(l,f,h,m){let{base_:g,copy_:y}=l,v=0;g.forEach(S=>{if(!y.has(S)){let b=f.concat([v]);h.push({op:r,path:b,value:S}),m.unshift({op:n,path:b,value:S})}v++}),v=0,y.forEach(S=>{if(!g.has(S)){let b=f.concat([v]);h.push({op:n,path:b,value:S}),m.unshift({op:r,path:b,value:S})}v++})}function d(l,f,h,m){h.push({op:t,path:[],value:f===xl?void 0:f}),m.push({op:t,path:[],value:l})}function c(l,f){return f.forEach(h=>{let{path:m,op:g}=h,y=l;for(let I=0;I<m.length-1;I++){let N=Pr(y),w=m[I];typeof w!="string"&&typeof w!="number"&&(w=""+w),(N===0||N===1)&&(w==="__proto__"||w==="constructor")&&Me(16+3),typeof y=="function"&&w==="prototype"&&Me(16+3),y=vl(y,w),typeof y!="object"&&Me(16+2,m.join("/"))}let v=Pr(y),S=u(h.value),b=m[m.length-1];switch(g){case t:switch(v){case 2:return y.set(b,S);case 3:Me(16);default:return y[b]=S}case n:switch(v){case 1:return b==="-"?y.push(S):y.splice(b,0,S);case 2:return y.set(b,S);case 3:return y.add(S);default:return y[b]=S}case r:switch(v){case 1:return y.splice(b,1);case 2:return y.delete(b);case 3:return y.delete(h.value);default:return delete y[b]}default:Me(16+1,g)}}),l}function u(l){if(!jn(l))return l;if(Array.isArray(l))return l.map(u);if(_o(l))return new Map(Array.from(l.entries()).map(([h,m])=>[h,u(m)]));if(ii(l))return new Set(Array.from(l).map(u));let f=Object.create(Io(l));for(let h in l)f[h]=u(l[h]);return ni(l,ei)&&(f[ei]=l[ei]),f}function p(l){return Cr(l)?u(l):l}eq("Patches",{applyPatches_:c,generatePatches_:o,generateReplacementPatches_:d})}var si=new sq,Ld=si.produce,qt=si.produceWithPatches.bind(si);var yn=si.applyPatches.bind(si);var Te=class extends Error{constructor(n,r,o){super(n);this.code=r;this.cause=o;this.name="TransactionError"}};zt();function Ye(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function aq(e,t){return JSON.stringify(e)===JSON.stringify(t)}function et(e,t){for(let n of Object.keys(e))n in t||delete e[n];for(let[n,r]of Object.entries(t)){let o=e[n];if(!aq(o,r)){if(Ye(o)&&Ye(r)){et(o,r);continue}e[n]=r}}}function dq(e){return!!(e&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function")}function wl(e,t){let n=t(e);if(dq(n))throw Promise.resolve(n).catch(()=>{}),new Te("transact recipe must be synchronous","ASYNC_RECIPE")}function Bd(e){if(e===void 0)return;if(Array.isArray(e)){let r=!1,o=e.map(s=>{let i=Bd(s);return i===void 0?(r=!0,null):(i!==s&&(r=!0),i)});return r?o:e}if(!Ye(e))return e;let t=!1,n={};for(let[r,o]of Object.entries(e)){let s=Bd(o);if(s===void 0){t=!0;continue}s!==o&&(t=!0),n[r]=s}return t?n:e}function ai(e){return Bd(e)}function di(e){let t=Bd(e);return Ye(t)?t:{}}var be="group",Ft="builtin/group";function An(e){return e?e!==be&&e!==Ft:!1}function Ol(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function cq(e){return di(e)}function Gd(e){return{pippitAssetId:e.id,type:e.type,content:cq(e.data),extra:{}}}function _t(e){return!!(e&&e.type!==lt&&e.content&&typeof e.content=="object"&&!Array.isArray(e.content))}function uq(e){if(_t(e))return Ol(e.content)?e.content:void 0}function ci(e,t){if(!(!t||!e||!Ol(e.assets)))return uq(e.assets[t])}function ui(e,t){if(!t||!An(t.type))return t;let n=ci(e,t.id);if(!n)return t;let r=Ol(t.data)?t.data:{};return{...t,data:{...r,...n}}}var Tv="unknown",Nv="unknown_node";function hq(e){if(e!==be&&!/^(builtin|biz|plugin)\//.test(e))throw new Error(`Node type must be namespaced with builtin/, biz/ or plugin/: ${e}`)}function kl(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Dl(e){return typeof e=="string"&&e.length>0?e:void 0}function Ud(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function gq(e){if(kl(e))return e}function zd(e,t){if(!kl(e))return{id:t??Nv,type:Tv,x:0,y:0,w:1,h:1,parentId:null,data:e,status:"unknown"};let n=Dl(e.type)??Tv;return{...e,id:Dl(e.id)??t??Nv,type:n,x:Ud(e.x,0),y:Ud(e.y,0),w:Ud(e.w,1),h:Ud(e.h,1),parentId:Dl(e.parentId)??null,order:typeof e.order=="number"?e.order:void 0,data:"data"in e?e.data:e,style:gq(e.style),status:"unknown"}}function yq(e,t,n,r){let o=zd(e,r);return{id:o.id,x:o.x,y:o.y,w:o.w,h:o.h,parentId:o.parentId,order:o.order,style:o.style,type:t.type,data:n}}function qd(){let e=new Map;return{register(t){if(hq(t.type),e.has(t.type))throw new Error(`Node definition already registered: ${t.type}`);return e.set(t.type,t),()=>{e.delete(t.type)}},get(t){return e.get(t)},has(t){return e.has(t)},hydrate(t,n){if(!kl(t))return zd(t,n);let r=typeof t.type=="string"?t.type:"",o=e.get(r);if(!o)return zd(t,n);let{data:s}=t;return o.validate(s)?yq(t,o,s,n):zd(t,n)}}}function Ml(){let e=new Map;return{register(t){if(e.has(t.type))throw new Error(`Directive handler already registered: ${t.type}`);return e.set(t.type,t),()=>{e.get(t.type)===t&&e.delete(t.type)}},resolve(t){return e.get(t)},has(t){return e.has(t)}}}var Ll="directive.apply";function pi(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Aq(e){if(!(!pi(e)||!pi(e.directives)))return e.directives}function vq(e){let t=x(e.getState()),n=[],r=t.directives;if(pi(r))for(let[o,s]of Object.entries(r))n.push({carrier:{kind:"canvas"},directiveId:o,directive:s});for(let[o,s]of Object.entries(t.nodes)){let i=Aq(s==null?void 0:s.data);if(i)for(let[a,d]of Object.entries(i))n.push({carrier:{kind:"node",nodeId:o},directiveId:a,directive:d})}return n}function Sq(e,t,n){var s;let r=x(e);if(t.kind==="canvas"){r.directives&&(delete r.directives[n],Object.keys(r.directives).length===0&&delete r.directives);return}let o=(s=r.nodes[t.nodeId])==null?void 0:s.data;pi(o)&&pi(o.directives)&&(delete o.directives[n],Object.keys(o.directives).length===0&&delete o.directives)}function Bl(e,t){let{registry:n,onError:r}=t,o=()=>{let s=vq(e);s.length!==0&&e.transact(i=>{for(let{carrier:a,directiveId:d,directive:c}of s){Sq(i,a,d);let u=n.resolve(c.type);if(!u){Re.info("[canvas-sdk:directive] no handler, directive removed",{type:c.type,directiveId:d,carrier:a});continue}try{u.run({directiveId:d,carrier:a,directive:c,commands:e.commands,store:e})}catch(p){Re.error("[canvas-sdk:directive] handler threw",p,{type:c.type,directiveId:d,carrier:a}),r==null||r(p,c,a)}}},{intent:Ll,source:"local",undoable:!1})};return o(),e.subscribe(({transaction:s})=>{s.intent!==Ll&&o()})}var Gl=(e,t)=>{t()};var Fd=["horizontal-directed-cluster","vertical-directed-cluster","dag-layered","component-packing","incremental-stress"],bq=["directed-cluster"];function Tr(e){return typeof e=="string"&&[...Fd,...bq].includes(e)}function wv(e,t){let n=new Map;return{batch(r,o,s){return e.transact(()=>{o(t())},{...s,intent:r})},register(r,o){return n.set(r,o),()=>{n.delete(r)}},invoke(r,...o){let s=n.get(r);return s?s(e,...o):{status:"aborted",reason:`Unknown command: ${r}`}}}}function Rt(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function ee(e){return!!(e&&Array.isArray(e.children))}function W(e){return x(e)}function Nr(e,t,n){let r=e.nodes[t];ee(r)&&(r.children=r.children.filter(o=>o!==n))}function Ov(e,t){let n=new Set,r=o=>{if(n.has(o))return;n.add(o);let s=e.nodes[o];if(ee(s))for(let i of s.children)r(i)};for(let o of t)r(o);return n}function Ee(e,t){let n=e[t];if(!n)return{x:0,y:0};if(!n.parentId)return{x:n.x,y:n.y};let r=Ee(e,n.parentId);return{x:r.x+n.x,y:r.y+n.y}}function vn(e,t){let n=e[t];if(!n)return;let r=Ee(e,t);return{minX:r.x,minY:r.y,maxX:r.x+n.w,maxY:r.y+n.h}}function Ne(e){if(e.length!==0)return e.reduce((t,n)=>({minX:Math.min(t.minX,n.minX),minY:Math.min(t.minY,n.minY),maxX:Math.max(t.maxX,n.maxX),maxY:Math.max(t.maxY,n.maxY)}),e[0])}function ft(e,t){let n=new Set(t);return t.filter(r=>{var s,i;let o=(s=e[r])==null?void 0:s.parentId;for(;o;){if(n.has(o))return!1;o=(i=e[o])==null?void 0:i.parentId}return!!e[r]})}function Dv(e,t){var r;if(t.length===0)return null;let n=((r=e[t[0]])==null?void 0:r.parentId)??null;return t.every(o=>{var s;return(((s=e[o])==null?void 0:s.parentId)??null)===n})?n:null}function kv(e,t,n="_"){let r=1,o=`${t}${n}${Date.now().toString(36)}`;for(;e[o];)r+=1,o=`${t}${n}${Date.now().toString(36)}${n}${r}`;return o}function Mv(e,t,n,r){let o=e.nodes[t];if(!ee(o))return;let s=new Set(n),i=o.children.findIndex(a=>s.has(a));o.children=o.children.filter(a=>!s.has(a)),o.children.splice(Math.max(i,0),0,r)}function Lv(e,t){let n=Object.values(e).filter(r=>r.parentId===t);return n.length===0?0:Math.max(...n.map(r=>r.order??0))+1}function Bv(e){return{createEdge(t){return e.transact(n=>{W(n).edges[t.id]=t},{intent:"edge.create"})},deleteEdges(t){return e.transact(n=>{let{edges:r}=W(n);for(let o of t)delete r[o]},{intent:"edge.delete"})},reconnectEdge(t,n){return e.transact(r=>{let o=W(r).edges[t];o&&(o.source=n.source,o.target=n.target,n.sourceHandle?o.sourceHandle=n.sourceHandle:delete o.sourceHandle,n.targetHandle?o.targetHandle=n.targetHandle:delete o.targetHandle)},{intent:"edge.reconnect"})},updateEdgeData(t,n){return e.transact(r=>{let o=W(r).edges[t];o&&(o.data={...Rt(o.data)?o.data:{},...n})},{intent:"edge.updateData"})}}}function Gv(e,t={}){let n=t.centerThreshold??1048576,r=t.targetCenter??{x:0,y:0};if(!Number.isFinite(n)||n<0||!Number.isFinite(r.x)||!Number.isFinite(r.y))return;let o=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY,d=!1;for(let l of e){if(![l.x,l.y,l.w,l.h].every(Number.isFinite))return;let f=l.x+l.w,h=l.y+l.h;if(!Number.isFinite(f)||!Number.isFinite(h))return;o=Math.min(o,l.x,f),s=Math.min(s,l.y,h),i=Math.max(i,l.x,f),a=Math.max(a,l.y,h),d=!0}if(!d)return;let c=o/2+i/2,u=s/2+a/2;if(Math.abs(c-r.x)<=n&&Math.abs(u-r.y)<=n)return;let p={dx:r.x-c,dy:r.y-u};return Number.isFinite(p.dx)&&Number.isFinite(p.dy)?p:void 0}function Uv(e){let t=new Set;return e.filter(n=>t.has(n)?!1:(t.add(n),!0))}function Ul(e,t){return!e||!t?e?-1:t?1:0:(e.order??0)-(t.order??0)||e.y-t.y||e.x-t.x||e.id.localeCompare(t.id)}function tt(e,t){return Ul(e.node,t.node)||e.rect.minY-t.rect.minY||e.rect.minX-t.rect.minX}function Vn(e,t){e.sort((n,r)=>{let o=t.get(n),s=t.get(r);return!o||!s?n.localeCompare(r):tt(o,s)})}function wr(e,t){return t.flatMap(n=>{let r=e[n],o=vn(e,n);return r&&o?[{node:r,rect:o}]:[]})}function zv(e,t,n){switch(n){case"left":return{dx:t.minX-e.minX,dy:0};case"center":return{dx:(t.minX+t.maxX)/2-(e.minX+e.maxX)/2,dy:0};case"right":return{dx:t.maxX-e.maxX,dy:0};case"top":return{dx:0,dy:t.minY-e.minY};case"middle":return{dx:0,dy:(t.minY+t.maxY)/2-(e.minY+e.maxY)/2};case"bottom":return{dx:0,dy:t.maxY-e.maxY}}}function jd(e,t){t.dx!==0&&(e.x+=t.dx),t.dy!==0&&(e.y+=t.dy)}var Iq=40,_q=40;function Rq(e,t){return e.x-t.x||e.y-t.y||e.id.localeCompare(t.id)}function Eq(e,t){return e.y-t.y||e.x-t.x||e.id.localeCompare(t.id)}function Vd(e,t){var s;let n=Uv(t);if(n.length===1){let i=e[n[0]];if(!ee(i))return;let a=i.children.filter(d=>{var c;return((c=e[d])==null?void 0:c.parentId)===i.id});return a.length>=2?{ids:a,parentId:i.id}:void 0}let r=ft(e,n);if(r.length<2)return;let o=((s=e[r[0]])==null?void 0:s.parentId)??null;if(r.every(i=>{var a;return(((a=e[i])==null?void 0:a.parentId)??null)===o}))return{ids:r,parentId:o}}function Hd(e,t,n,r){let o=t.map(m=>e[m]).filter(m=>!!m);if(o.length<2)return;let s=Math.min(...o.map(m=>m.x)),i=Math.min(...o.map(m=>m.y)),a=Math.max(...o.map(m=>m.w)),d=Math.max(...o.map(m=>m.h)),c=(r==null?void 0:r.horizontalGap)??Iq,u=(r==null?void 0:r.verticalGap)??_q,p=[...o].sort(n==="horizontal"?Rq:Eq);if(n==="horizontal"){let m=s;for(let g of p)g.x=m,g.y=i,m+=g.w+c;return}if(n==="vertical"){let m=i;for(let g of p)g.x=s,g.y=m,m+=g.h+u;return}let l=Math.max(1,(r==null?void 0:r.gridColumns)??Math.ceil(Math.sqrt(o.length))),f=a+c,h=d+u;p.forEach((m,g)=>{m.x=s+g%l*f,m.y=i+Math.floor(g/l)*h})}function Cq(e){return e.maxX-e.minX}function Pq(e){return e.maxY-e.minY}function jt(e){return{x:e.minX+Cq(e)/2,y:e.minY+Pq(e)/2}}function Yd(e,t){return{id:e,minX:t.minX,minY:t.minY,maxX:t.maxX,maxY:t.maxY}}function Kd(e){return{...e}}function Co(e,t,n){e.minX+=t,e.maxX+=t,e.minY+=n,e.maxY+=n}function Po(e){return(e.minX+e.maxX)/2}function xo(e){return(e.minY+e.maxY)/2}function To(e){return e.maxX-e.minX}function No(e){return e.maxY-e.minY}function zl(e,t){return Ne([...e.entries()].flatMap(([n,r])=>{let o=t.get(n);return o?[{minX:r.x,minY:r.y,maxX:r.x+o.node.w,maxY:r.y+o.node.h}]:[]}))}function xq(e,t){return t.flatMap(n=>{let r=e.get(n.node.id);return r?[{id:n.node.id,minX:r.x,minY:r.y,maxX:r.x+n.node.w,maxY:r.y+n.node.h}]:[]})}function Fv(e,t,n){let r=(To(e)+To(t))/2+n-Math.abs(Po(t)-Po(e)),o=(No(e)+No(t))/2+n-Math.abs(xo(t)-xo(e));return r>0&&o>0}function Tq(e,t,n){let r=Math.max(0,(To(e)+To(t))/2+n-Math.abs(Po(t)-Po(e))),o=Math.max(0,(No(e)+No(t))/2+n-Math.abs(xo(t)-xo(e)));return r*o}function ql(e,t,n){return t.reduce((r,o)=>r+Tq(e,o,n),0)}function qv(e,t,n){return e!==0?Math.sign(e):t.localeCompare(n)<=0?1:-1}function Nq(e,t,n){let r=Po(t)-Po(e),o=xo(t)-xo(e),s=(To(e)+To(t))/2+n-Math.abs(r),i=(No(e)+No(t))/2+n-Math.abs(o);if(s<=0||i<=0)return!1;if(s<=i){let c=qv(r,e.id,t.id),u=s/2;return Co(e,-c*u,0),Co(t,c*u,0),!0}let a=qv(o,e.id,t.id),d=i/2;return Co(e,0,-a*d),Co(t,0,a*d),!0}function Fl(e,t,n=Math.max(24,e.length*16)){if(!(e.length<2))for(let r=0;r<n;r+=1){let o=!1;for(let s=0;s<e.length;s+=1)for(let i=s+1;i<e.length;i+=1)o=Nq(e[s],e[i],t)||o;if(!o)return}}function jl(e,t,n){let r=new Map;for(let[o,s]of e)r.set(o,{x:s.x+t,y:s.y+n});return r}function li(e,t,n){let r=xq(e,t.items);Fl(r,n);let o=new Map;for(let d of r)o.set(d.id,{x:d.minX,y:d.minY});let s=new Map(t.items.map(d=>[d.node.id,d])),i=zl(o,s);if(!i)return o;let a=jt(i);return jl(o,t.center.x-a.x,t.center.y-a.y)}function Vl(e){return new Map(e.map(t=>[t.node.id,{x:t.rect.minX,y:t.rect.minY}]))}function Vv(e,t,n){var o;let r=t;for(;r;){if(n.has(r))return r;r=((o=e[r])==null?void 0:o.parentId)??null}}function Dq(e,t,n){let r=new Set(n),o=new Set,s=[];for(let i of Object.values(t)){let a=Vv(e,i.source,r),d=Vv(e,i.target,r);if(!a||!d||a===d)continue;let c=`${a}->${d}`;o.has(c)||(o.add(c),s.push({source:a,target:d}))}return s}function kq(e,t,n){var u,p;let r=wr(e,t).sort((l,f)=>tt(l,f)),o=new Map(r.map(l=>[l.node.id,l])),s=r.map(l=>l.node.id),i=Dq(e,n,s),a=new Map;for(let l of s)a.set(l,new Set);for(let l of i)(u=a.get(l.source))==null||u.add(l.target),(p=a.get(l.target))==null||p.add(l.source);let d=[],c=new Set;for(let l of s){if(c.has(l))continue;let f=[],h=[l];for(c.add(l);h.length>0;){let S=h.pop();f.push(S);let b=[...a.get(S)??[]].filter(I=>!c.has(I));Vn(b,o);for(let I of b.reverse())c.add(I),h.push(I)}f.sort((S,b)=>tt(o.get(S),o.get(b)));let m=f.flatMap(S=>{let b=o.get(S);return b?[b]:[]}),g=Ne(m.map(S=>S.rect));if(!g)continue;let y=new Set(f),v=i.filter(S=>y.has(S.source)&&y.has(S.target));d.push({ids:f,items:m,edges:v,bounds:g,center:jt(g),isolated:v.length===0&&f.length===1})}return d}function Mq(e,t,n){let r=n(e,t),o=new Map(e.items.map(i=>[i.node.id,i])),s=zl(r,o)??e.bounds;return{component:e,positions:r,bounds:s}}function Hl(e,t){return jl(e.positions,t.minX-e.bounds.minX,t.minY-e.bounds.minY)}function Lq(e,t,n){let r=jt(t),o=e.map((s,i)=>{let a={x:r.x+(s.component.center.x-r.x)*.78,y:r.y+(s.component.center.y-r.y)*.78},d=jt(s.bounds),c=a.x-d.x,u=a.y-d.y;return Yd(String(i),{minX:s.bounds.minX+c,minY:s.bounds.minY+u,maxX:s.bounds.maxX+c,maxY:s.bounds.maxY+u})});return Fl(o,n),o}function Hv(e,t,n){return t.some(r=>Fv(e,r,n))}function Bq(e,t){let n=[{x:0,y:0}],r=Math.max(0,Math.ceil(t/e));for(let o=1;o<=r;o+=1){for(let s=-o;s<=o;s+=1)n.push({x:s*e,y:-o*e}),n.push({x:s*e,y:o*e});for(let s=-o+1;s<=o-1;s+=1)n.push({x:-o*e,y:s*e}),n.push({x:o*e,y:s*e})}return n.filter(o=>Math.hypot(o.x,o.y)<=t).sort((o,s)=>Math.hypot(o.x,o.y)-Math.hypot(s.x,s.y)||o.y-s.y||o.x-s.x)}function Yl(e){var t;return((t=e.component.items[0])==null?void 0:t.node.id)??e.component.ids[0]??""}function fi(e){return{w:e.bounds.maxX-e.bounds.minX,h:e.bounds.maxY-e.bounds.minY}}function Gq(e,t,n,r){let o=[...e].sort((h,m)=>tt(h.component.items[0],m.component.items[0])),s=Math.max(0,t.maxY-t.minY),i=Math.max(0,...o.map(h=>fi(h).h)),a=o.reduce((h,m)=>h+fi(m).h+r,0),d=s>0?Math.max(s,i):a,c=[],u=[],p=0;for(let h of o){let{h:m}=fi(h);u.length>0&&p+m+r>d&&(c.push(u),u=[],p=0),u.push(h),p+=m+r}u.length>0&&c.push(u);let l=new Map,f=t.minX-n;for(let h of c){let m=Math.max(0,...h.map(v=>fi(v).w)),g=f-m,y=t.minY;for(let v of h){let{w:S,h:b}=fi(v);l.set(Yl(v),Yd(Yl(v),{minX:g,minY:y,maxX:g+S,maxY:y+b})),y+=b+r}f=g-n}return l}function Uq(e,t,n,r,o){if(!Hv(e,t,n))return Kd(e);let s=Kd(e),i=ql(s,t,n);for(let a of Bq(o,r)){let d=Kd(e);if(Co(d,a.x,a.y),!Hv(d,t,n))return d;let c=ql(d,t,n);c<i&&(i=c,s=d)}return s}function Or({nodes:e,edges:t,ids:n,options:r,resolveComponentPositions:o}){let s=kq(e,n,t),i=Ne(s.map(y=>y.bounds));if(!i)return new Map;let a=(r==null?void 0:r.componentGap)??180,d=(r==null?void 0:r.nodeGap)??40,c=(r==null?void 0:r.isolatedNodeMoveLimit)??360,u=s.map(y=>Mq(y,r,o)),p=u.filter(y=>!y.component.isolated),l=u.filter(y=>y.component.isolated),f=new Map,h=[],m=Lq(p,i,a);if(p.forEach((y,v)=>{let S=m[v];for(let[b,I]of Hl(y,S))f.set(b,I);h.push(S)}),(r==null?void 0:r.isolatedPlacement)==="left"&&l.length>0){let y=Ne(h)??i,v=Gq(l,y,a,d);for(let S of l){let b=v.get(Yl(S));if(b){for(let[I,N]of Hl(S,b))f.set(I,N);h.push(b)}}return f}let g=Math.max(40,d+20);return l.forEach((y,v)=>{let S=Yd(`isolated-${v}`,y.bounds),b=Uq(S,h,a,c,g);for(let[I,N]of Hl(y,b))f.set(I,N);h.push(b)}),f}var Yv=.86;function Kl(e,t){if(e.items.length<2)return Vl(e.items);let n=new Map;for(let o of e.items){let s=jt(o.rect),i={x:e.center.x+(s.x-e.center.x)*Yv,y:e.center.y+(s.y-e.center.y)*Yv};n.set(o.node.id,{x:i.x-o.node.w/2,y:i.y-o.node.h/2})}let r=(t==null?void 0:t.nodeGap)??40;return li(n,e,r)}function Kv({nodes:e,edges:t,ids:n,options:r}){return Or({nodes:e,edges:t,ids:n,options:r,resolveComponentPositions:Kl})}var zq=240,qq=40,Fq=240,jq=2.2;function Vq(e,t,n,r,o){let s=e.filter(a=>(n.get(a.node.id)??0)===0).map(a=>a.node.id);Vn(s,o);let i=[];for(;s.length>0;){let a=s.shift();i.push(a);let d=t.get(a)??[];Vn(d,o);for(let c of d){r.set(c,Math.max(r.get(c)??0,(r.get(a)??0)+1));let u=(n.get(c)??0)-1;n.set(c,u),u===0&&(s.push(c),Vn(s,o))}}return i}function Hq(e,t,n){let r=new Map;for(let o of e){let s=t.get(o);if(!s)continue;let i=n.get(o)??0,a=r.get(i)??[];a.push(s),r.set(i,a)}return r}function Yq(e,t,n){let r=[],o=e;for(let s=0;s<t.length;s+=1)r[s]=o,o+=t[s]+n;return r}function Kq({itemById:e,items:t,outgoing:n,indegree:r,layer:o,options:s}){let i=Vq(t,n,r,o,e);if(i.length!==t.length)return;let a=Ne(t.map(m=>m.rect));if(!a)return;let d=(s==null?void 0:s.horizontalGap)??zq,c=(s==null?void 0:s.verticalGap)??qq,u=Hq(i,e,o),p=Math.max(...u.keys()),l=Array.from({length:p+1},(m,g)=>Math.max(...(u.get(g)??[]).map(y=>y.node.w),0)),f=Yq(a.minX,l,d),h=new Map;for(let m=0;m<=p;m+=1){let g=u.get(m)??[],y=a.minY;for(let v of g)h.set(v.node.id,{x:f[m],y}),y+=v.node.h+c}return h}function Xq(e,t,n){var d;if(t.length===0)return;let r=new Map(e.map(c=>[c.node.id,c])),o=new Map,s=new Map,i=new Map;for(let c of e)o.set(c.node.id,[]),s.set(c.node.id,0),i.set(c.node.id,0);let a=new Set;for(let c of t){let u=`${c.source}->${c.target}`;a.has(u)||(a.add(u),(d=o.get(c.source))==null||d.push(c.target),s.set(c.target,(s.get(c.target)??0)+1))}return Kq({itemById:r,items:e,outgoing:o,indegree:s,layer:i,options:n})}function $q(e,t){let n=new Set,r=[];for(let o of t){if(o.source===o.target||!e.has(o.source)||!e.has(o.target))continue;let s=`${o.source}->${o.target}`;n.has(s)||(n.add(s),r.push(o))}return r}function Wq(e,t){var a,d;let n=new Map(e.map(c=>[c.node.id,c])),r=e.map(c=>c.node.id),o=new Map;for(let c of r)o.set(c,new Set);for(let c of t)(a=o.get(c.source))==null||a.add(c.target),(d=o.get(c.target))==null||d.add(c.source);let s=[],i=new Set;for(let c of r){if(i.has(c))continue;let u=[],p=[c];for(i.add(c);p.length>0;){let m=p.pop();u.push(m);let g=[...o.get(m)??[]].filter(y=>!i.has(y));Vn(g,n);for(let y of g.reverse())i.add(y),p.push(y)}Vn(u,n);let l=new Set(u),f=u.flatMap(m=>{let g=n.get(m);return g?[g]:[]}),h=t.filter(m=>l.has(m.source)&&l.has(m.target));s.push({edges:h,ids:u,items:f})}return s}function Qq(e,t){let n;for(let[r,o]of e){let s=t.get(r);if(!s)continue;let i={minX:o.x,minY:o.y,maxX:o.x+s.node.w,maxY:o.y+s.node.h};n=n?{minX:Math.min(n.minX,i.minX),minY:Math.min(n.minY,i.minY),maxX:Math.max(n.maxX,i.maxX),maxY:Math.max(n.maxY,i.maxY)}:i}return n}function Xv(e,t){let n=[...e].sort((h,m)=>tt(h,m)),r=Ne(n.map(h=>h.rect)),o=(r==null?void 0:r.minX)??0,s=(r==null?void 0:r.minY)??0,i=(t==null?void 0:t.horizontalGap)??120,a=(t==null?void 0:t.verticalGap)??80,d=Math.max(1,(t==null?void 0:t.gridColumns)??Math.ceil(Math.sqrt(n.length))),c=Math.max(...n.map(h=>h.node.w),0),u=Math.max(...n.map(h=>h.node.h),0),p=c+i,l=u+a,f=new Map;return n.forEach((h,m)=>{f.set(h.node.id,{x:o+m%d*p,y:s+Math.floor(m/d)*l})}),f}function Jq(e,t){let n=e.edges.length>0?Xq(e.items,e.edges,t):Xv(e.items,t);if(!n)return;let r=Qq(n,new Map(e.items.map(o=>[o.node.id,o])));if(r)return{bounds:r,positions:n}}function Zq(e,t,n){let r=(n==null?void 0:n.componentGap)??Fq,o=e.reduce((p,l)=>p+(l.bounds.maxX-l.bounds.minX)*(l.bounds.maxY-l.bounds.minY),0),s=Math.max(...e.map(p=>p.bounds.maxX-p.bounds.minX),0),i=Math.max(s,Math.sqrt(o)*jq),a=new Map,d=t.minX,c=t.minY,u=0;for(let p of e){let l=p.bounds.maxX-p.bounds.minX,f=p.bounds.maxY-p.bounds.minY;d>t.minX&&d+l>t.minX+i&&(d=t.minX,c+=u+r,u=0);let h=d-p.bounds.minX,m=c-p.bounds.minY;for(let[g,y]of p.positions)a.set(g,{x:y.x+h,y:y.y+m});d+=l+r,u=Math.max(u,f)}return a}function eF(e,t,n){let r=new Set(e.map(a=>a.node.id)),o=$q(r,t);if(o.length===0)return;let s=[];for(let a of Wq(e,o)){let d=Jq(a,n);if(!d)return;s.push(d)}if(s.length===0)return;if(s.length===1)return s[0].positions;let i=Ne(e.map(a=>a.rect));return i?Zq(s,i,n):void 0}function $v({nodes:e,edges:t,ids:n,options:r}){let o=wr(e,n);return eF(o,Object.values(t),r)??Xv(o,r)}function mi(e,t){let n=(e==null?void 0:e.horizontalGap)??(t==="horizontal"?240:48),r=(e==null?void 0:e.verticalGap)??(t==="horizontal"?96:480);return{horizontalGap:n,verticalGap:r,mainGap:t==="horizontal"?n:r,crossGap:t==="horizontal"?r:n}}function Wv(e,t){let{horizontalGap:n,verticalGap:r}=mi(e,t);return{...e,horizontalGap:n,verticalGap:r,nodeGap:(e==null?void 0:e.nodeGap)??80,componentGap:(e==null?void 0:e.componentGap)??240,isolatedPlacement:(e==null?void 0:e.isolatedPlacement)??"left"}}function Qv(e,t){var n;return((n=e.get(t))==null?void 0:n.node.h)??0}function Jv(e,t){var n;return((n=e.get(t))==null?void 0:n.node.w)??0}function Dr(e,t,n){return n==="horizontal"?Qv(e,t):Jv(e,t)}function Zv(e,t,n){return n==="horizontal"?Jv(e,t):Qv(e,t)}var aF=4;function eS(e){if(e.length===0)return-1;let t=[...e].sort((r,o)=>r-o),n=Math.floor(t.length/2);return t.length%2===1?t[n]:(t[n-1]+t[n])/2}function nS(e,t,n){var u;let r=new Map;for(let p of e)r.set(p,[]);let o=new Set;for(let p of t){if(p.source===p.target||!r.has(p.source)||!r.has(p.target))continue;let l=`${p.source}->${p.target}`;o.has(l)||(o.add(l),(u=r.get(p.source))==null||u.push(p.target))}for(let p of r.values())p.sort((l,f)=>tt(n.get(l),n.get(f)));let s=new Map,i=new Map;for(let p of e)s.set(p,[]),i.set(p,[]);let a=new Map;for(let p of e)a.set(p,0);let d=[...e].sort((p,l)=>tt(n.get(p),n.get(l))),c=p=>{var f,h;let l=[{id:p,index:0}];for(a.set(p,1);l.length>0;){let m=l[l.length-1],g=r.get(m.id)??[];if(m.index<g.length){let y=g[m.index];m.index+=1;let v=a.get(y);if(v===1)continue;(f=s.get(m.id))==null||f.push(y),(h=i.get(y))==null||h.push(m.id),v===0&&(a.set(y,1),l.push({id:y,index:0}))}else a.set(m.id,2),l.pop()}};for(let p of d)a.get(p)===0&&c(p);return{out:s,inn:i}}function dF(e,t,n){var a;let r=new Map;for(let d of e)r.set(d,((a=t.inn.get(d))==null?void 0:a.length)??0);let o=new Map;for(let d of e)o.set(d,0);let s=e.filter(d=>(r.get(d)??0)===0).sort((d,c)=>tt(n.get(d),n.get(c))),i=0;for(;i<s.length;){let d=s[i];i+=1;for(let c of t.out.get(d)??[]){o.set(c,Math.max(o.get(c)??0,(o.get(d)??0)+1));let u=(r.get(c)??0)-1;r.set(c,u),u===0&&s.push(c)}}return o}function cF(e,t,n){let r=Math.max(0,...e.map(s=>t.get(s)??0)),o=Array.from({length:r+1},()=>[]);for(let s of e)o[t.get(s)??0].push(s);for(let s of o)s.sort((i,a)=>tt(n.get(i),n.get(a)));return o}function tS(e,t,n){let r=new Map(e.map((s,i)=>[s,i])),o=new Map;for(let s of e){let i=t(s);o.set(s,i<0?r.get(s)??0:i)}e.sort((s,i)=>(o.get(s)??0)-(o.get(i)??0)||tt(n.get(s),n.get(i)))}function uF(e,t,n){let r=new Map,o=s=>{s.forEach((i,a)=>r.set(i,a))};e.forEach(o);for(let s=0;s<aF;s+=1)if(s%2===0)for(let a=1;a<e.length;a+=1)tS(e[a],d=>eS((t.inn.get(d)??[]).map(c=>r.get(c)).filter(c=>c!==void 0)),n),o(e[a]);else for(let a=e.length-2;a>=0;a-=1)tS(e[a],d=>eS((t.out.get(d)??[]).map(c=>r.get(c)).filter(c=>c!==void 0)),n),o(e[a])}function rS(e,t,n){let r=dF(e,t,n),o=cF(e,r,n);return uF(o,t,n),o}var pF=6;function Xl(e){return e.length===0?0:e.reduce((t,n)=>t+n,0)/e.length}function lF(e,t,n,r,o,s,i){if(e.length===0)return;let a=e.map(p=>(t.get(p)??r.get(p)??0)-Dr(o,p,i)/2);for(let p=1;p<e.length;p+=1){let l=a[p-1]+Dr(o,e[p-1],i)+s;a[p]<l&&(a[p]=l)}let d=e.map((p,l)=>a[l]+Dr(o,p,i)/2),c=e.map(p=>t.get(p)??r.get(p)??0),u=Xl(c)-Xl(d);e.forEach((p,l)=>{let f=a[l]+u;n.set(p,f),r.set(p,f+Dr(o,p,i)/2)})}function fF(e,t,n,r,o){let s=new Map,i=new Map;for(let a of e){let d=0;for(let c of a)s.set(c,d),i.set(c,d+Dr(n,c,o)/2),d+=Dr(n,c,o)+r}for(let a=0;a<pF;a+=1){let d=a%2===0,c=d?e.map((u,p)=>p):e.map((u,p)=>p).reverse();for(let u of c){let p=e[u],l=new Map;for(let f of p){let h=d?t.inn.get(f)??[]:t.out.get(f)??[],m=[...t.inn.get(f)??[],...t.out.get(f)??[]],y=(h.length>0?h:m).map(v=>i.get(v)).filter(v=>v!==void 0);l.set(f,y.length>0?Xl(y):i.get(f)??0)}lF(p,l,s,i,n,r,o)}}return s}function mF(e,t,n){let r=new Map,o=0;for(let s of e)r.set(s.node.id,n==="horizontal"?{x:0,y:o}:{x:o,y:0}),o+=(n==="horizontal"?s.node.h:s.node.w)+t;return r}function oS(e,t,n="horizontal"){let r=new Map(e.items.map(f=>[f.node.id,f])),o=e.items.map(f=>f.node.id),{mainGap:s,crossGap:i}=mi(t,n);if(e.items.length<2||e.edges.length===0)return mF(e.items,i,n);let a=nS(o,e.edges,r),d=rS(o,a,r),c=fF(d,a,r,i,n),u=[],p=0;for(let f=0;f<d.length;f+=1){u[f]=p;let h=Math.max(0,...d[f].map(m=>Zv(r,m,n)));p+=h+s}let l=new Map;for(let f=0;f<d.length;f+=1)for(let h of d[f]){let m=c.get(h)??0;l.set(h,n==="horizontal"?{x:u[f],y:m}:{x:m,y:u[f]})}return l}function sS({nodes:e,edges:t,ids:n,options:r,axis:o}){let s=Wv(r,o);return Or({nodes:e,edges:t,ids:n,options:s,resolveComponentPositions:(i,a)=>oS(i,a,o)})}function iS({nodes:e,edges:t,ids:n,options:r}){return sS({nodes:e,edges:t,ids:n,options:r,axis:"horizontal"})}function aS({nodes:e,edges:t,ids:n,options:r}){return sS({nodes:e,edges:t,ids:n,options:r,axis:"vertical"})}var dS=.9;function hF(e,t){return(e==null?void 0:e.stressIterations)!==void 0?Math.max(0,e.stressIterations):Math.max(24,Math.min(80,Math.floor(2400/Math.max(1,t))))}function gF(e,t){let n=e.items.reduce((i,a)=>i+a.node.w,0)/e.items.length,r=e.items.reduce((i,a)=>i+a.node.h,0)/e.items.length,o=(t==null?void 0:t.horizontalGap)??120,s=(t==null?void 0:t.verticalGap)??80;return Math.max(120,Math.min(520,Math.max(n+o,r+s)))}function yF(e,t){if(e.items.length<2||e.edges.length===0)return Kl(e,t);let n=(t==null?void 0:t.nodeGap)??40,r=gF(e,t),o=hF(t,e.items.length),s=new Map,i=new Map,a=new Map,d=0,c=0;for(let p of e.items){let l=jt(p.rect),f={x:e.center.x+(l.x-e.center.x)*dS,y:e.center.y+(l.y-e.center.y)*dS};s.set(p.node.id,{...l}),i.set(p.node.id,f),a.set(p.node.id,{w:p.node.w,h:p.node.h}),d+=f.x,c+=f.y}d/=e.items.length,c/=e.items.length;for(let p=0;p<o;p+=1){for(let g of e.edges){let y=s.get(g.source),v=s.get(g.target);if(!y||!v)continue;let S=v.x-y.x,b=v.y-y.y,I=Math.max(1,Math.hypot(S,b)),N=Math.max(-r*.18,Math.min(r*.18,(I-r)*.08)),w=S/I*N*.5,ne=b/I*N*.5;y.x+=w,y.y+=ne,v.x-=w,v.y-=ne}for(let g=0;g<e.items.length;g+=1)for(let y=g+1;y<e.items.length;y+=1){let v=e.items[g],S=e.items[y],b=s.get(v.node.id),I=s.get(S.node.id),N=a.get(v.node.id),w=a.get(S.node.id);if(!b||!I||!N||!w)continue;let ne=I.x-b.x,Ge=I.y-b.y,Y=(N.w+w.w)/2+n-Math.abs(ne),T=(N.h+w.h)/2+n-Math.abs(Ge);if(Y>0&&T>0){if(Y<=T){let j=ne===0?v.node.id.localeCompare(S.node.id)<=0?1:-1:Math.sign(ne),J=Y/2;b.x-=j*J,I.x+=j*J}else{let j=Ge===0?v.node.id.localeCompare(S.node.id)<=0?1:-1:Math.sign(Ge),J=T/2;b.y-=j*J,I.y+=j*J}continue}let F=Math.max(1,Math.hypot(ne,Ge));if(F<r*.55){let j=ne===0?v.node.id.localeCompare(S.node.id)<=0?1:-1:ne/F,J=Ge===0?0:Ge/F,ie=(r*.55-F)*.015;b.x-=j*ie,b.y-=J*ie,I.x+=j*ie,I.y+=J*ie}}let l=0,f=0;for(let g of e.items){let y=s.get(g.node.id),v=i.get(g.node.id);!y||!v||(y.x+=(v.x-y.x)*.035,y.y+=(v.y-y.y)*.035,l+=y.x,f+=y.y)}l/=e.items.length,f/=e.items.length;let h=(d-l)*.15,m=(c-f)*.15;for(let g of s.values())g.x+=h,g.y+=m}let u=new Map;for(let p of e.items){let l=s.get(p.node.id);l&&u.set(p.node.id,{x:l.x-p.node.w/2,y:l.y-p.node.h/2})}return li(u,e,n)}function cS({nodes:e,edges:t,ids:n,options:r}){return Or({nodes:e,edges:t,ids:n,options:r,resolveComponentPositions:yF})}var AF="horizontal-directed-cluster";function uS(e,t){let n=t!=null&&t.length?ft(e,t):Object.values(e).filter(o=>o.parentId===null).map(o=>o.id),r=new Set;return n.filter(o=>{let s=e[o];return!s||s.parentId!==null||r.has(o)?!1:(r.add(o),!0)}).sort((o,s)=>Ul(e[o],e[s]))}function Oo(e,t,n,r){let o=(r==null?void 0:r.strategy)??AF;return o==="component-packing"?Kv({nodes:e,edges:t,ids:n,options:r}):o==="incremental-stress"?cS({nodes:e,edges:t,ids:n,options:r}):o==="dag-layered"?$v({nodes:e,edges:t,ids:n,options:r}):o==="vertical-directed-cluster"?aS({nodes:e,edges:t,ids:n,options:r}):iS({nodes:e,edges:t,ids:n,options:r})}function Qd(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Do(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function $l(e){if(!(!Qd(e)||!Do(e.w)||!Do(e.h)))return{w:e.w,h:e.h}}function Wd(e){return{w:Do(e.w)?e.w:320,h:Do(e.h)?e.h:180}}function Jd(e){return!!(e&&(e.type===be||e.type===Ft)&&Array.isArray(e.children))}function kr(e){return Jd(e)&&Qd(e.data)&&e.data.collapsed===!0}function Wl(e){return Jd(e)&&Qd(e.data)?$l(e.data.expandedSize):void 0}function hi(e){return kr(e)?Wl(e)??Wd(e):Wd(e)}function gi(e,t){if(kr(e)){e.data.expandedSize={...t};return}e.w=t.w,e.h=t.h}function Zd(e){if(!Jd(e))return!1;Qd(e.data)||(e.data={});let{data:t}=e,n=$l(t.expandedSize);if(t.collapsed===!0){let r=!1;return n?(!Do(e.w)||!Do(e.h))&&(e.w=320,e.h=180,r=!0):(t.expandedSize=Wd(e),e.w=320,e.h=180,r=!0),r}return n?(e.w=n.w,e.h=n.h,delete t.expandedSize,!0):!1}function pS(e,t){if(!Jd(e))return!1;let n=Zd(e),{data:r}=e;if(r.collapsed===!0===t)return n;if(t)return r.expandedSize=Wd(e),r.collapsed=!0,e.w=320,e.h=180,!0;let o=$l(r.expandedSize);return r.collapsed=!1,o&&(e.w=o.w,e.h=o.h),delete r.expandedSize,!0}function lS(e,t){return e.minX>=t.minX-.001&&e.minY>=t.minY-.001&&e.maxX<=t.maxX+.001&&e.maxY<=t.maxY+.001}function fS(e,t){e.x+=t.minX,e.y+=t.minY,gi(e,{w:Math.max(1,t.maxX-t.minX),h:Math.max(1,t.maxY-t.minY)})}function vF(e,t){return Ne(t.map(n=>{let r=typeof n=="string"?e[n]:void 0;return r?{minX:r.x,minY:r.y,maxX:r.x+r.w,maxY:r.y+r.h}:void 0}).filter(n=>!!n))}function SF(e,t){return Ne(t.children.map(n=>e[n]).filter(n=>!!(n&&n.parentId===t.id)).map(n=>({minX:n.x,minY:n.y,maxX:n.x+n.w,maxY:n.y+n.h})))}function bF(e,t,n,r){for(let o of t){let s=typeof o=="string"?e[o]:void 0;s&&(s.x-=n,s.y-=r)}}function IF(e,t,n,r){for(let o of t.children){let s=e[o];(s==null?void 0:s.parentId)===t.id&&(s.x-=n,s.y-=r)}}function mS(e,t,n,r){let o=e[t];if(o){if(o.x*=n,o.y*=r,kr(o)){let s=hi(o);gi(o,{w:s.w*n,h:s.h*r})}else o.w*=n,o.h*=r;if(ee(o))for(let s of o.children)mS(e,s,n,r)}}function hS(e,t,n){if(n.has(t))return;n.add(t);let r=e[t];if(ee(r))for(let o of r.children)hS(e,o,n)}function _F(e,t,n){let r=vn(e,t);if(!r)return null;let o=null,s=Number.POSITIVE_INFINITY;for(let i of Object.values(e)){if(!ee(i)||n.has(i.id))continue;let a=vn(e,i.id);if(!a||!lS(r,a))continue;let d=i.w*i.h;d<s&&(o=i.id,s=d)}return o}function RF(e,t){let{nodes:n}=e;for(let r of t){let o=n[r],s=o==null?void 0:o.parentId;if(!o||!s)continue;let i=vn(n,r),a=vn(n,s);if(i&&a&&lS(i,a))continue;let d=Ee(n,r);Nr(e,s,r),o.parentId=null,o.x=d.x,o.y=d.y}}function EF(e,t,n){let{nodes:r}=e;for(let o of t){let s=r[o];if(!s||s.parentId)continue;let i=_F(r,o,n),a=i?r[i]:void 0;if(!i||!ee(a))continue;let d=Ee(r,o),c=Ee(r,i);s.parentId=i,s.x=d.x-c.x,s.y=d.y-c.y,a.children=[...a.children.filter(u=>u!==o),o]}}function CF(e,t){var o,s;let n=[],r=new Set;for(let i of t){let a=((o=e[i])==null?void 0:o.parentId)??null;for(;a;)r.has(a)||(r.add(a),n.push(a)),a=((s=e[a])==null?void 0:s.parentId)??null}return n}function PF(e,t){let n=e[t];if(!Array.isArray(n==null?void 0:n.children)||n.children.length===0)return;let r=vF(e,n.children);if(!r)return;let o=hi(n),s={minX:Math.min(0,r.minX-40),minY:Math.min(0,r.minY-40),maxX:Math.max(o.w,r.maxX+40),maxY:Math.max(o.h,r.maxY+40)};fS(n,s),bF(e,n.children,s.minX,s.minY)}function gS(e,t,n){if(!ee(t)||kr(t)||t.w===n.w&&t.h===n.h)return;let r=t.w===0?1:n.w/t.w,o=t.h===0?1:n.h/t.h;for(let s of t.children)mS(e,s,r,o)}function yS(e,t){let{nodes:n}=e,r=ft(n,t),o=new Set;for(let s of r)hS(n,s,o);RF(e,r),EF(e,r,o)}function ec(e,t){let n=CF(e,t);for(let r of n)PF(e,r)}function ko(e,t,n=new Set){if(!t||n.has(t))return;let r=e[t];if(!ee(r))return;n.add(t);let o=SF(e,r);if(!o)return;let s={minX:o.minX-40,minY:o.minY-40,maxX:o.maxX+40,maxY:o.maxY+40};fS(r,s),IF(e,r,s.minX,s.minY),ko(e,r.parentId??null,n)}function xF(e,t){let n=[],r=new Set,o=s=>{let i=e[s];if(!(!ee(i)||r.has(s))){r.add(s);for(let a of i.children)o(a);n.push(s)}};for(let s of t)o(s);return n}function TF(e,t){let n=e[t];return ee(n)?n.children.filter(r=>{var o;return((o=e[r])==null?void 0:o.parentId)===t}):[]}function vS(e){return e==="horizontal-directed-cluster"||e==="vertical-directed-cluster"}function AS(e,t,n){var o;let r=t;for(;r;){if(n.has(r))return r;r=((o=e[r])==null?void 0:o.parentId)??null}}function NF(e,t,n){let r=new Set(n);return Object.values(t).some(o=>{let s=AS(e,o.source,r),i=AS(e,o.target,r);return!!(s&&i&&s!==i)})}function wF(e,t){let n=new Set(t);return Object.fromEntries(Object.entries(e).map(([r,o])=>[r,n.has(r)?{...o,parentId:null}:{...o}]))}function OF(e,t){let n;for(let[r,o]of t)e[r]&&(n=n?{minX:Math.min(n.minX,o.x),minY:Math.min(n.minY,o.y)}:{minX:o.x,minY:o.y});return n}function DF(e,t,n){let r=Object.fromEntries(Object.entries(e).map(([a,d])=>[a,{...d}])),o=n==="horizontal-directed-cluster"?"horizontal":"vertical",{horizontalGap:s,verticalGap:i}=mi(void 0,o);return Hd(r,t,o==="horizontal"?"vertical":"horizontal",{horizontalGap:s,verticalGap:i}),new Map(t.flatMap(a=>{let d=r[a];return d?[[a,{x:d.x,y:d.y}]]:[]}))}function kF(e,t,n){let{nodes:r}=e,o=wF(r,t),s=NF(r,e.edges,t)?Oo(o,e.edges,t,{strategy:n}):DF(o,t,n),i=OF(o,s);return i?new Map([...s.entries()].map(([a,d])=>[a,{x:d.x-i.minX+40,y:d.y-i.minY+40}])):s}function SS(e,t,n){let{nodes:r}=e,o=Vd(r,t);if(!o)return;let s=o.parentId?kF(e,o.ids,n):Oo(r,e.edges,o.ids,{strategy:n});if(s.size!==0){for(let[i,a]of s){let d=r[i];d&&(d.x=a.x,d.y=a.y)}ko(r,o.parentId)}}function bS(e,t,n,r){let o=r.strategy??"horizontal-directed-cluster";if(!["directed-cluster","horizontal-directed-cluster","vertical-directed-cluster"].includes(o)||!r.sortGroupChildren)return!1;let i=!1;for(let a of xF(e,n)){let d=TF(e,a);if(d.length<2)continue;let c=Oo(e,t,d,r);if(c.size===0)continue;let u=Ee(e,a);for(let[p,l]of c){let f=e[p];!f||f.parentId!==a||(f.x=l.x-u.x,f.y=l.y-u.y,i=!0)}ko(e,a)}return i}function MF(e,t,n){let r=ft(e,t);if(r.length<3)return;let o=wr(e,r).sort((p,l)=>n==="horizontal"?p.rect.minX-l.rect.minX:p.rect.minY-l.rect.minY);if(o.length<3)return;let s=o[0],i=o[o.length-1],a=o.reduce((p,l)=>{let f=n==="horizontal"?l.rect.maxX-l.rect.minX:l.rect.maxY-l.rect.minY;return p+f},0),c=((n==="horizontal"?i.rect.maxX-s.rect.minX:i.rect.maxY-s.rect.minY)-a)/(o.length-1),u=n==="horizontal"?s.rect.maxX+c:s.rect.maxY+c;for(let p=1;p<o.length-1;p+=1){let l=o[p];n==="horizontal"?(jd(l.node,{dx:u-l.rect.minX,dy:0}),u+=l.rect.maxX-l.rect.minX+c):(jd(l.node,{dx:0,dy:u-l.rect.minY}),u+=l.rect.maxY-l.rect.minY+c)}}function IS(e,t){let n=t.flatMap(o=>{let s=e[o];return s?[s]:[]}),r=Gv(n);if(r)for(let o of t){let s=e[o];s&&(s.x+=r.dx,s.y+=r.dy)}}function _S(e){return{moveNodes(t,n,r){return e.transact(o=>{let s=W(o),{nodes:i}=s,a=ft(i,t);for(let d of a){let c=i[d];c&&(c.x+=n.dx,c.y+=n.dy)}r!=null&&r.reparentToContainingGroup?yS(s,a):ec(i,a)},{intent:"geometry.moveNodes",mergeKey:r==null?void 0:r.mergeKey})},resizeNode(t,n,r){return e.transact(o=>{let{nodes:s}=W(o),i=s[t];i&&(gS(s,i,n),i.w=n.w,i.h=n.h),ec(s,[t])},{intent:"geometry.resizeNode",mergeKey:r==null?void 0:r.mergeKey})},setNodePosition(t,n,r){return e.transact(o=>{let{nodes:s}=W(o),i=s[t];i&&(i.x=n.x,i.y=n.y),ec(s,[t])},{intent:"geometry.setNodePosition",mergeKey:r==null?void 0:r.mergeKey})},alignNodes(t,n){return e.transact(r=>{let{nodes:o}=W(r),s=ft(o,t);if(s.length<2)return;let i=wr(o,s),a=Ne(i.map(d=>d.rect));if(a)for(let d of i)jd(d.node,zv(d.rect,a,n))},{intent:`geometry.alignNodes.${n}`})},distributeNodes(t,n){return e.transact(r=>{MF(W(r).nodes,t,n)},{intent:`geometry.distributeNodes.${n}`})},arrangeNodes(t,n,r){return e.transact(o=>{let s=W(o);if(vS(n)){SS(s,t,n);return}let{nodes:i}=s,a=Vd(i,t);a&&(Hd(i,a.ids,n,r),ko(i,a.parentId))},{intent:`geometry.arrangeNodes.${n}`})},autoLayoutNodes(t){return e.transact(n=>{var c,u,p;let r=W(n),o=uS(r.nodes,t==null?void 0:t.ids),s=(c=r.settings.autoLayout)==null?void 0:c.strategy,i=(t==null?void 0:t.strategy)??(Tr(s)?s:void 0),a=i?{...t,strategy:i}:t;if(a&&bS(r.nodes,r.edges,o,a),o.length<2){(u=t==null?void 0:t.ids)!=null&&u.length||IS(r.nodes,o);return}let d=Oo(r.nodes,r.edges,o,a);for(let[l,f]of d){let h=r.nodes[l];h&&(h.x=f.x,h.y=f.y)}(p=t==null?void 0:t.ids)!=null&&p.length||IS(r.nodes,o)},{intent:"geometry.autoLayoutNodes"})}}}function RS(e,t){let n=[],r=new Set,o=s=>{let i=e[s];if(!(!i||r.has(s))){if(ee(i)){r.add(s);for(let a of i.children)o(a);return}r.add(s),n.push(s)}};for(let s of t)o(s);return n}function ES(e,t,n){var s;let r=new Set,o=i=>{let a=e[i];if(!(!ee(a)||r.has(i))){r.add(i);for(let d of a.children)o(d)}};for(let i of t)o(i);for(let i of n){let a=((s=e[i])==null?void 0:s.parentId)??null;for(;a;){let d=e[a];ee(d)&&r.add(a),a=(d==null?void 0:d.parentId)??null}}return[...r]}function CS(e,t,n){let{nodes:r}=e,o=r[n];if(!ee(o))return;let s=[...o.children],i=Ee(r,n),{parentId:a}=o,d=a?Ee(r,a):{x:0,y:0};for(let c of s){let u=r[c];u&&(u.parentId=a,u.x=i.x+u.x-d.x,u.y=i.y+u.y-d.y)}if(a){let c=r[a];if(ee(c)){let u=c.children.indexOf(n);c.children=c.children.filter(p=>p!==n),c.children.splice(Math.max(u,0),0,...s)}}delete r[n],delete t[n];for(let c of Object.values(e.edges))(c.source===n||c.target===n)&&delete e.edges[c.id]}function LF(e,t){let n=e;if(!_t(n)||!Rt(n.content))return;let r=Rt(n.content.data)?n.content.data:n.content;r.collapsed=Rt(t.data)&&t.data.collapsed===!0;let o=Wl(t);o?r.expandedSize={...o}:delete r.expandedSize}function PS(e){return{group(t){return e.transact(n=>{let r=W(n),{nodes:o}=r,s=ft(o,t);if(s.length===0)return;let i=RS(o,s);if(i.length<2)return;let a=Ne(i.map(h=>vn(o,h)).filter(h=>!!h));if(!a)return;let d=ES(o,s,i),c=kv(o,"group","$");for(let h of d)CS(r,n.assets,h);let u=Dv(o,i),p=u?Ee(o,u):{x:0,y:0},l={x:a.minX-40,y:a.minY-40},f={id:c,type:be,x:l.x-p.x,y:l.y-p.y,w:Math.max(1,a.maxX-a.minX+40*2),h:Math.max(1,a.maxY-a.minY+40*2),parentId:u,order:Lv(o,u),data:{},children:[...i]};u&&Mv(r,u,i,c);for(let h of i){let m=o[h],g=Ee(o,h);m&&(m.parentId&&m.parentId!==u&&Nr(r,m.parentId,h),m.parentId=c,m.x=g.x-l.x,m.y=g.y-l.y)}o[c]=f},{intent:"group.create"})},ungroup(t){return e.transact(n=>{let r=W(n),{nodes:o}=r,s=o[t];if(!ee(s))return;let i=Ee(o,t),a=s.parentId?Ee(o,s.parentId):{x:0,y:0},{parentId:d}=s;for(let c of s.children){let u=o[c];u&&(u.parentId=d,u.x=i.x+u.x-a.x,u.y=i.y+u.y-a.y)}if(d){let c=o[d];if(ee(c)){let u=c.children.indexOf(t);c.children=c.children.filter(p=>p!==t),c.children.splice(Math.max(u,0),0,...s.children)}}delete o[t],delete n.assets[t];for(let c of Object.values(r.edges))(c.source===t||c.target===t)&&delete r.edges[c.id]},{intent:"group.ungroup"})},reparent(t,n,r){return e.transact(o=>{let s=W(o),{nodes:i}=s,a=i[t];if(!a||t===n)return;let d=n?i[n]:void 0;if(n&&!ee(d))return;let c=Ee(i,t);a.parentId&&Nr(s,a.parentId,t),a.parentId=n;let u=n?Ee(i,n):{x:0,y:0};if(a.x=c.x-u.x,a.y=c.y-u.y,d&&ee(d)){let p=d.children.filter(f=>f!==t),l=r===void 0?p.length:Math.max(0,Math.min(r,p.length));p.splice(l,0,t),d.children=p}},{intent:"group.reparent"})},reorderChildren(t,n){return e.transact(r=>{let o=W(r).nodes[t];ee(o)&&(o.children=[...n])},{intent:"group.reorderChildren"})},setGroupCollapsed(t,n){return e.transact(r=>{let o=W(r).nodes[t];ee(o)&&(pS(o,n),LF(r.assets[t],o))},{intent:"group.setCollapsed"})}}}function BF(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function GF(e){let t=BF(e.pippitAssetId);if(t)return{pippitAssetId:t}}function xS(e){return{setTitle(t){return e.transact(n=>{W(n).metadata.title=t},{intent:"metadata.setTitle"})},setCover(t){return e.transact(n=>{var s;let r=GF(t);if(!r)return;let{metadata:o}=W(n);((s=o.cover)==null?void 0:s.pippitAssetId)!==r.pippitAssetId&&(o.cover=r)},{intent:"metadata.setCover",undoable:!1})},setGlobalBounds(t){return e.transact(n=>{W(n).metadata.globalBounds=t},{intent:"metadata.setGlobalBounds"})}}}function UF(e){return typeof structuredClone=="function"?ai(structuredClone(e)):ai(JSON.parse(JSON.stringify(e)))}function TS(e){return{createNode(t,n={}){return e.transact(r=>{let o=W(r),s=e.registry.hydrate(t),i=n.autoCreateNodeAsset??!0,a=An(s.type);for(let d of n.assets??[]){if(r.assets[d.pippitAssetId])throw new Error(`Asset already exists: ${d.pippitAssetId}`);a&&d.pippitAssetId===s.id&&d.type!==lt&&!_t(d)&&Re.error("[canvas-sdk] biz node companion asset must be NodeAsset shape (flat content: object)",{nodeId:s.id,nodeType:s.type,assetType:d.type}),r.assets[d.pippitAssetId]=UF(d)}if(i&&a){if(r.assets[s.id])throw new Error(`Node asset already exists: ${s.id}`);r.assets[s.id]=Gd(s)}if(o.nodes[s.id]=s,s.parentId){let d=o.nodes[s.parentId];ee(d)&&!d.children.includes(s.id)&&d.children.push(s.id)}},{intent:"node.create"})},deleteNodes(t){return e.transact(n=>{let r=W(n),o=Ov(r,t);for(let s of o){let i=r.nodes[s];i!=null&&i.parentId&&Nr(r,i.parentId,s)}for(let s of o)delete r.nodes[s];for(let s of Object.values(r.edges))(o.has(s.source)||o.has(s.target))&&delete r.edges[s.id]},{intent:"node.delete"})},updateNodeData(t,n){return e.transact(r=>{let o=W(r).nodes[t];if(!o)return;if(!An(o.type)){if(Rt(o.data)||(o.data={}),typeof n=="function"){wl(o.data,n);return}let a=Rt(n)?di(n):{};if(Object.keys(a).length===0)return;Object.assign(o.data,a);return}let s=r.assets[t];if(!_t(s))throw new Te(`biz node "${t}" missing NodeAsset; cannot apply updateNodeData`,"INVARIANT_VIOLATION");if(Rt(s.content)||(s.content={}),typeof n=="function"){wl(s.content,n);return}let i=Rt(n)?di(n):{};Object.keys(i).length!==0&&Object.assign(s.content,i)},{intent:"node.updateData"})},setNodeStyle(t,n){return e.transact(r=>{let o=W(r).nodes[t];o&&(o.style={...o.style??{},...n})},{intent:"node.setStyle"})}}}function NS(e){return{updateSnapSettings(t){return e.transact(n=>{let{settings:r}=W(n);r.snap={...r.snap,...t}},{intent:"settings.updateSnap"})},setSnapEnabled(t){return e.transact(n=>{W(n).settings.snap.enabled=t},{intent:"settings.setSnapEnabled"})},setAutoLayoutStrategy(t){return e.transact(n=>{let{settings:r}=W(n);if(!t){delete r.autoLayout;return}r.autoLayout={...r.autoLayout,strategy:t}},{intent:"settings.setAutoLayoutStrategy"})}}}function Ql(e){let t={...TS(e),..._S(e),...PS(e),...Bv(e),...xS(e),...NS(e),...wv(e,()=>t)};return t}var zF=[[1,0],[0,1],[-1,0],[0,-1],[1,1],[-1,1],[1,-1],[-1,-1]];function qF(e,t){return e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y}function FF(e,t){return{x:e.x-t,y:e.y-t,w:e.w+t*2,h:e.h+t*2}}function jF(e){return{x:e.x,y:e.y,w:e.w,h:e.h}}function VF({base:e,gap:t,searchRings:n,size:r}){let o=[e],s=r.w+t,i=r.h+t;for(let a=1;a<=n;a+=1)for(let[d,c]of zF)o.push({x:e.x+d*s*a,y:e.y+c*i*a});return o}function HF(e,t,n){return t.some(r=>qF(e,FF(r,n)))}function wS({center:e,existingNodes:t={},gap:n=24,searchRings:r=8,size:o}){let s={x:e.x-o.w/2,y:e.y-o.h/2},i=Object.values(t).filter(d=>!d.parentId).map(jF);if(i.length===0)return s;let a=VF({base:s,gap:n,searchRings:r,size:o});return a.find(d=>!HF({...d,...o},i,n))??a[0]}var OS;function YF(){let e=globalThis.console;if(!e||typeof e!="object")return;let t=e.warn;return typeof t=="function"?t.bind(e):void 0}function yi(e){var t;if(OS)try{OS({...e,context:KF(e.context),metrics:XF(e.metrics)})}catch(n){(t=YF())==null||t("[canvas-sdk] telemetry reporter failed",n)}}function KF(e){if(!e)return;let t={},n=40;for(let[r,o]of Object.entries(e)){if(n<=0)break;t[r]=$F(o),n-=1}return t}function XF(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))Number.isFinite(r)&&(t[n]=r);return Object.keys(t).length?t:void 0}function $F(e){var t;return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e.length>500?`${e.slice(0,500)}...`:e:e===null||typeof e=="number"||typeof e=="boolean"||typeof e>"u"?e:Array.isArray(e)?`[array:${e.length}]`:typeof e=="object"?`[object:${((t=e.constructor)==null?void 0:t.name)||"Object"}]`:String(e)}var WF=e=>String(e).replace(/~/g,"~0").replace(/\//g,"~1"),QF=e=>e.replace(/~1/g,"/").replace(/~0/g,"~"),JF=e=>/^\d+$/.test(e)?Number(e):e,ZF=e=>e.length===0?"":`/${e.map(WF).join("/")}`,Jl=e=>{if(e==="")return[];if(!e.startsWith("/"))throw new Error(`Invalid JSON pointer: ${e}`);return e.slice(1).split("/").map(QF).map(JF)},e2=e=>{if(e.path[0]==="revision"||e.path[0]!=="assets"||e.path[1]===void 0)return null;let t=String(e.path[1]),n=e.path.slice(2),r={assetId:t,op:e.op,path:ZF(n)};return e.op!=="remove"&&(r.value=e.value),r},Hn=e=>{let t=[];for(let n of e){let r=e2(n);r&&t.push(r)}return t},t2=e=>{let t={op:e.op,path:["assets",e.assetId,...Jl(e.path)]};return e.op!=="remove"&&(t.value=e.value),t},tc=e=>e.map(t2);function Mo(e,t,n){e.assets[t]=n}function Zl(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function n2(e){let t=e;if(!(!_t(t)||!Zl(t.content)))return Zl(t.content.data)?t.content.data:t.content}function Ai(e,t){let n=Ld(e,r=>{for(let o of Object.values(r.assets))if(Ut(o)){for(let s of Object.keys(o.content.nodes)){let i=t.hydrate(o.content.nodes[s],s),a=r.assets[s];if(!An(i.type)){let c=n2(a),u=Zl(i.data)?i.data:{};o.content.nodes[s]=t.hydrate({...i,data:c?{...c,...u}:i.data},s);continue}if(_t(a)){o.content.nodes[s]=t.hydrate({...i,type:a.type},s);continue}if(!a){o.content.nodes[s]=i;continue}Re.error("[canvas-sdk:hydrate] biz node companion asset has invalid shape",{nodeId:s,nodeType:i.type,assetType:a.type}),o.content.nodes[s]=i}for(let s of Object.values(o.content.nodes))Zd(s)}});return ai(n)}function DS(e){return Object.keys(e).sort()}function ef(e,t){return JSON.stringify(e)===JSON.stringify(t)}function kS(e,t){et(e,t)}function r2(e,t){let n=DS(e),r=DS(t);return n.length===r.length&&n.every((o,s)=>o===r[s]&&ef(e[o],t[o]))}function MS(e,t){let[n,r,o]=qt(e,s=>{s.rootCanvasId=t.rootCanvasId;for(let i of Object.keys(s.assets))i in t.assets||delete s.assets[i];for(let[i,a]of Object.entries(t.assets)){let d=s.assets[i];if(!d){Mo(s,i,a);continue}ef(d,a)||kS(d,a)}});return{forwardPatches:Hn(r),reversePatches:Hn(o),nextState:n}}function LS(e,t){return e.rootCanvasId===t.rootCanvasId&&r2(e.assets,t.assets)}function tf(e,t,n={}){let r=e.getState();return r.rootCanvasId!==t.rootCanvasId?{status:"aborted",reason:"root-canvas-id-mismatch"}:t.assets[t.rootCanvasId]?LS(r,t)?{status:"noop",reason:"no-changes"}:e.transact(o=>{for(let s of Object.keys(o.assets))s in t.assets||delete o.assets[s];for(let[s,i]of Object.entries(t.assets)){let a=o.assets[s];if(!a){Mo(o,s,i);continue}ef(a,i)||kS(a,i)}for(let s of Object.values(o.assets))if(Ut(s))for(let i of Object.values(s.content.nodes))Zd(i)},n):{status:"aborted",reason:"missing-root-canvas-asset"}}function BS(e={}){return{undoStack:[],redoStack:[],limit:e.limit??200,mergeWindow:e.mergeWindow??500}}function o2(e,t){if(!t.historyGroupKey||t.historyGroupMode!=="append")return-1;for(let n=e.length-1;n>=0;n-=1)if(e[n].historyGroupKey===t.historyGroupKey)return n;return-1}function s2(e,t){return{...e,forwardPatches:[...e.forwardPatches,...t.forwardPatches],reversePatches:[...t.reversePatches,...e.reversePatches],timestamp:t.timestamp}}function nf(e,t,n){if(!n||t.source!=="local")return;let r=o2(e.undoStack,t);if(r>=0){e.undoStack[r]=s2(e.undoStack[r],t),e.redoStack=[];return}let o=e.undoStack[e.undoStack.length-1];o&&t.mergeKey&&o.mergeKey===t.mergeKey&&t.timestamp-o.timestamp<=e.mergeWindow?e.undoStack[e.undoStack.length-1]={...o,forwardPatches:[...o.forwardPatches,...t.forwardPatches],reversePatches:[...t.reversePatches,...o.reversePatches],timestamp:t.timestamp}:(e.undoStack.push(t),e.undoStack.length>e.limit&&e.undoStack.shift()),e.redoStack=[]}function rf(e){e.undoStack=[],e.redoStack=[]}function of(e,t,n,r){let o=-1,s=a=>{throw new Te(a,"MIDDLEWARE_REJECTED")},i=a=>{if(a<=o)throw new Te("Middleware called next() multiple times","MIDDLEWARE_REJECTED");o=a;let d=e[a];d&&d({txId:t.id,forwardPatches:t.forwardPatches,reversePatches:t.reversePatches,intent:t.intent,source:t.source,nextState:r,prevState:n,reject:s},()=>i(a+1))};i(0)}function GS(e){let t={id:e.txId,intent:e.intent,forwardPatches:e.forwardPatches,reversePatches:e.reversePatches,timestamp:Date.now(),source:"remote"};return t.undoable=!1,t}function US(e){return{applyRemoteSnapshot(t,n){let r=e.getState(),{forwardPatches:o,reversePatches:s,nextState:i}=MS(r,t);if(o.length===0)return{status:"noop",reason:"no-changes"};let a=GS({forwardPatches:o,intent:"remote.snapshot",reversePatches:s,txId:e.nextTransactionId()}),d=Ai(i,e.registry);return e.setState(d),e.onStateCommitted(),e.notify(a,o,r,d),e.reportCommit(a,d),n==null||n.conflicts,{status:"committed",transaction:a}},applyRemotePatches(t,n){if(t.length===0)return{status:"noop",reason:"no-changes"};let r=e.getState();try{let[o,,s]=qt(r,d=>yn(d,tc(t))),i=Ai(o,e.registry),a=GS({forwardPatches:[...t],intent:"remote.patches",reversePatches:Hn(s),txId:e.nextTransactionId()});return e.setState(i),e.onStateCommitted(),e.notify(a,a.forwardPatches,r,i),e.reportCommit(a,i),n==null||n.conflicts,{status:"committed",transaction:a}}catch(o){return e.logAbort({error:o,intent:"remote.patches",source:"remote"}),{status:"aborted",reason:o instanceof Error?o.message:String(o),error:o instanceof Error?o:void 0}}}}}function zS(){let e=new Set,t=new Set;return{notify(n,r,o,s){let i={transaction:n,prevState:o,nextState:s};for(let d of Array.from(e))d(i);if(r.length===0)return;let a={transaction:n,patches:r,prevState:o,nextState:s};for(let d of Array.from(t))d(a)},subscribe(n){return e.add(n),()=>{e.delete(n)}},subscribePatches(n,r){let o=r?s=>{let i=s.patches.filter(a=>a.assetId===r.assetId);i.length!==0&&n({...s,patches:i})}:n;return t.add(o),()=>{t.delete(o)}}}}var i2=/\b(node|edge|asset|canvas|group|tx|run|request|workflow)[_-][A-Za-z0-9_-]+\b/gi,a2=/\b[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\b/gi;function d2(e){return e instanceof Error?e.message:String(e)}function c2(e){return e instanceof Error?e.name:typeof e}function qS(e){if(e instanceof Te)return e.code}function u2(e){return e.replace(i2,"$1_<id>").replace(a2,"<uuid>").replace(/\b\d{6,}\b/g,"<number>").replace(/\s+/g," ").trim()||"unknown"}function p2(e,t){let n=qS(e);return n&&n!=="MIDDLEWARE_REJECTED"?n:u2(t)}function FS(e){let t=d2(e),n=qS(e);return{canvas_sdk_error_reason:p2(e,t),error_name:c2(e),reason:t,...n?{transaction_error_code:n}:{}}}zt();function sf(e){let t=e.registry??qd(),n=zS(),r=[Gl,...e.middlewares??[]],o=BS({limit:e.historyLimit,mergeWindow:e.mergeWindow}),s=Ai(e.initialDocument,t),i=null,a=0,d=0,c,u=(m,g)=>{l2(m,g,e.getTelemetryContext)},p=()=>{a+=1;let m=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;return`tx_${a}_${m}`},l=(m,g,y)=>{if(m.length===0)return{status:"noop",reason:"no-changes"};let v=s,b=Ld(v,N=>yn(N,tc(m))),I={id:p(),intent:y.intent,forwardPatches:[...m],reversePatches:[...g],timestamp:Date.now(),mergeKey:y.mergeKey,historyGroupKey:y.historyGroupKey,historyGroupMode:y.historyGroupMode,source:y.source};return I.undoable=y.undoable,y.skipMiddleware||of(r,I,v,b),s=b,d+=1,nf(o,I,y.undoable),n.notify(I,I.forwardPatches,v,s),u(I,s),{status:"committed",transaction:I}},f=US({clearHistory:()=>rf(o),getState:()=>s,logAbort:VS,nextTransactionId:p,notify:n.notify,registry:t,reportCommit:u,setState:m=>{s=m},onStateCommitted:()=>{d+=1}}),h={transact(m,g={}){if(i){let b=m(i);if(jS(b))throw new Te("transact recipe must be synchronous","ASYNC_RECIPE");return{status:"noop",reason:"merged-into-outer"}}let y=s,v=g.source??"local",S=g.undoable??!0;try{let[b,I,N]=qt(y,T=>{i=T;try{let F=m(T);if(jS(F))throw new Te("transact recipe must be synchronous","ASYNC_RECIPE")}finally{i=null}}),w=Hn(I),ne=Hn(N);if(w.length===0)return{status:"noop",reason:"no-changes"};let Ge=b,Y={id:p(),intent:g.intent,forwardPatches:w,reversePatches:ne,timestamp:Date.now(),mergeKey:g.mergeKey,historyGroupKey:g.historyGroupKey,historyGroupMode:g.historyGroupMode,source:v};return Y.undoable=S,g.skipMiddleware||of(r,Y,y,Ge),s=Ge,d+=1,nf(o,Y,S),n.notify(Y,w,y,s),u(Y,s),{status:"committed",transaction:Y}}catch(b){return i=null,m2(b)&&VS({error:b,intent:g.intent,source:v}),{status:"aborted",reason:b instanceof Error?b.message:String(b),error:b instanceof Error?b:void 0}}},getState(){return s},getRevision(){return d},getRootCanvas(){return wd(s)},getRootCanvasContent(){return x(s)},subscribe:n.subscribe,subscribePatches:n.subscribePatches,subscribeSelector(m,g,y){let v=(y==null?void 0:y.equalityFn)??Object.is,S=m(s);return h.subscribe(({nextState:b})=>{let I=m(b);if(!v(I,S)){let N=S;S=I,g(I,N)}})},undo(){let m=o.undoStack.pop();if(!m)return{status:"noop",reason:"no-changes"};let g=l(m.reversePatches,m.forwardPatches,{intent:m.intent?`undo:${m.intent}`:"undo",source:"local",undoable:!1});return g.status==="committed"?o.redoStack.push(m):o.undoStack.push(m),g},redo(){let m=o.redoStack.pop();if(!m)return{status:"noop",reason:"no-changes"};let g=l(m.forwardPatches,m.reversePatches,{intent:m.intent?`redo:${m.intent}`:"redo",source:"local",undoable:!1});return g.status==="committed"?o.undoStack.push(m):o.redoStack.push(m),g},canUndo(){return o.undoStack.length>0},canRedo(){return o.redoStack.length>0},clearHistory(){rf(o)},use(m){return r.push(m),()=>{let g=r.indexOf(m);g>=0&&r.splice(g,1)}},applyRemoteSnapshot:f.applyRemoteSnapshot,applyRemotePatches:f.applyRemotePatches,get commands(){return c},registry:t};return c=Ql(h),h}function l2(e,t,n){let r=new Set(e.forwardPatches.map(s=>s.assetId)),o=x(t);yi({action:"canvas_transaction_commit",category:"canvas",packageName:"canvas-sdk",status:"success",context:{...f2(n),root_canvas_id:t.rootCanvasId,transaction_id:e.id,transaction_history_group_key:e.historyGroupKey,transaction_history_group_mode:e.historyGroupMode,transaction_intent:e.intent,transaction_merge_key:e.mergeKey,transaction_source:e.source,undoable:e.undoable??!0},metrics:{asset_count:r.size,count:1,node_count:Object.keys(o.nodes).length,patch_count:e.forwardPatches.length}})}function f2(e){try{return e==null?void 0:e()}catch{return}}function jS(e){return!!(e&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function")}function VS({error:e,intent:t,source:n}){Re.error("[canvas-sdk] transaction aborted",{error:e,...FS(e),intent:t,source:n})}function m2(e){return!(e instanceof Te&&e.code==="READ_ONLY")}function A2(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function HS(){let e,t=0;return{getCanvasClipboard(){return e},setCanvasClipboard(n){e=A2(n),t=0},clearCanvasClipboard(){e=void 0,t=0},getCanvasClipboardPasteCount(){return t},markCanvasClipboardPasted(){t+=1}}}function mt(e,t,n){let r=e.get(t)??new Set;r.add(n),e.set(t,r)}function ht(e,t,n){let r=e.get(t);r&&(r.delete(n),r.size===0&&e.delete(t))}function qe(e,t,n){for(let r of Array.from(e.get(t)??[]))r(n)}function Ae(e,t){return()=>{e.delete(t)}}function YS(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n}]))}function KS(e,t){return(e==null?void 0:e.x)===(t==null?void 0:t.x)&&(e==null?void 0:e.y)===(t==null?void 0:t.y)}function XS(){let e={},t=new Set,n=new Map,r=o=>{let s=e;e=YS(o);for(let a of Array.from(t))a(e);let i=new Set([...Object.keys(s),...Object.keys(e)]);for(let a of i){let d=s[a],c=e[a];KS(d,c)||qe(n,a,c)}};return{getDragPreview(){return e},getPreviewOf(o){return e[o]},setDragPreview:r,update(o,s){r({...e,[o]:{...s}})},updateMany(o){let s={...e};for(let{id:i,position:a}of o)s[i]={...a};r(s)},clear(o){if(o){let s={...e};delete s[o],r(s);return}r({})},clearDragPreview(){r({})},subscribeDragPreview(o){return t.add(o),Ae(t,o)},subscribePreviewOf(o,s){return mt(n,o,s),()=>ht(n,o,s)}}}function $S(){let e,t=new Set,n=new Map,r=o=>{if(e===o)return;let s=e;e=o;for(let i of Array.from(t))i(e);s&&qe(n,s,!1),e&&qe(n,e,!0)};return{getHoveredEdgeId(){return e},isEdgeHovered(o){return e===o},setHoveredEdge:r,clearEdgeHover(){r(void 0)},subscribeEdgeHover(o){return t.add(o),Ae(t,o)},subscribeEdgeHoverOf(o,s){return mt(n,o,s),()=>ht(n,o,s)}}}function WS(){let e,t=new Set,n=new Map,r=s=>{if(s!==e){for(let i of Array.from(t))i(e);s&&qe(n,s,!1),e&&qe(n,e,!0)}},o=s=>{let i=e;e=s,r(i)};return{getSelectedEdgeId(){return e},isEdgeSelected(s){return e===s},setSelectedEdge(s){o(s)},clearEdgeSelection(){o(void 0)},subscribeEdgeSelection(s){return t.add(s),Ae(t,s)},subscribeEdgeSelectionOf(s,i){return mt(n,s,i),()=>ht(n,s,i)}}}function QS(){let e=null,t=new Set,n=new Map,r=o=>{if(e===o)return;let s=e;e=o;for(let i of Array.from(t))i(e);s&&qe(n,s,!1),e&&qe(n,e,!0)};return{getHovered(){return e},isHovered(o){return e===o},setHovered:r,clear(){r(null)},subscribeHover(o){return t.add(o),Ae(t,o)},subscribeHoverOf(o,s){return mt(n,o,s),()=>ht(n,o,s)}}}function JS(e=!1){let t=e,n=new Set,r=o=>{if(t!==o){t=o;for(let s of Array.from(n))s(t)}};return{isMiniMapVisible(){return t},setMiniMapVisible:r,toggleMiniMapVisible(){r(!t)},subscribeMiniMapVisible(o){return n.add(o),Ae(n,o)}}}function v2(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function ZS(){let e=new Set,t=new Set,n=new Map,r=o=>{let s=e,i=new Set(o);if(v2(s,i))return;e=i;for(let d of Array.from(t))d(e);let a=new Set([...s,...i]);for(let d of a)s.has(d)!==i.has(d)&&qe(n,d,i.has(d))};return{getHighlightedNodeIds(){return e},isNodeHighlighted(o){return e.has(o)},setHighlightedNodes:r,clearHighlightedNodes(){r([])},subscribeNodeHighlight(o){return t.add(o),Ae(t,o)},subscribeNodeHighlightOf(o,s){return mt(n,o,s),()=>ht(n,o,s)}}}function S2(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function eb(){let e=new Set,t=new Set,n=r=>{let o=new Set([...r].map(s=>s.trim()).filter(s=>!!s));if(!S2(e,o)){e=o;for(let s of Array.from(t))s(e)}};return{getHighlightedNodeTypes(){return e},isNodeTypeHighlighted(r){return e.has(r)},setHighlightedNodeTypes:n,clearHighlightedNodeTypes(){n([])},subscribeNodeTypeHighlight(r){return t.add(r),Ae(t,r)}}}function Vt(e){switch(e.type){case"single_node":return new Set([e.activeId]);case"multi_node_discrete":case"multi_node_region":return new Set(e.selectedIds);case"none":default:return new Set}}function nc(e){let t=new Set(e);return t.size===0?{type:"none"}:t.size===1?{type:"single_node",activeId:[...t][0]}:{type:"multi_node_discrete",selectedIds:t}}function af(e){if(e.type==="multi_node_discrete"){let t=new Set(e.selectedIds);return{...nc(t),...t.size>1&&e.activeId&&t.has(e.activeId)?{activeId:e.activeId}:{}}}if(e.type==="multi_node_region"){let t=new Set(e.selectedIds);return t.size===0?{type:"none"}:{...e,selectedIds:t}}return e}function tb(e,t,n){let r=new Set(t),o=new Set(n==="replace"?[]:Vt(e));if(n==="replace")return r;for(let s of r)n==="add"?o.add(s):n==="subtract"||o.has(s)?o.delete(s):o.add(s);return o}function df(e,t){let n=Vt(e),r=Vt(t);if(n.size!==r.size)return!1;for(let o of n)if(!r.has(o))return!1;return e.type===t.type}function nb(e={type:"none"}){let t=af(e),n=Vt(t),r=new Set,o=new Map,s=a=>{if(df(a,t))return;for(let p of Array.from(r))p(t);let d=Vt(a),c=n,u=new Set([...d,...c]);for(let p of u)d.has(p)!==c.has(p)&&qe(o,p,c.has(p))},i=a=>{let d=t;t=af(a),df(d,t)||(n=Vt(t)),s(d)};return{getSelection(){return t},has(a){return n.has(a)},getSelectedIds(){return n},setSelection:i,clear(){i({type:"none"})},apply(a,d){i(nc(tb(t,a,d)))},subscribeSelection(a){return r.add(a),Ae(r,a)},subscribeSelectionOf(a,d){return mt(o,a,d),()=>ht(o,a,d)}}}function vi(e){let t=new Set(e.targets);return{enabled:e.enabled,tolerance:e.threshold,snapToGrid:t.has("grid"),snapToNodes:t.has("node"),snapToGuidelines:t.has("guide")}}function cf(e,t){return e.enabled===t.enabled&&e.threshold===t.threshold&&e.targets.length===t.targets.length&&e.targets.every((n,r)=>n===t.targets[r])}function uf(e,t){let n=new Set(t),r={vertical:[],horizontal:[]};for(let[o,s]of e.entries())n.has(o)||(r.vertical.push({value:s.x,nodeId:o,type:"min"},{value:s.x+s.w/2,nodeId:o,type:"mid"},{value:s.x+s.w,nodeId:o,type:"max"}),r.horizontal.push({value:s.y,nodeId:o,type:"min"},{value:s.y+s.h/2,nodeId:o,type:"mid"},{value:s.y+s.h,nodeId:o,type:"max"}));return r}function b2(e,t){let n=t.candidate.value-t.moved,r=Math.abs(n);return r>t.tolerance||e&&r>=e.distance?e:{offset:n,distance:r,line:{id:`${t.axis}:${t.draggingId}:${t.candidate.nodeId}:${t.candidate.value}`,type:t.axis==="x"?"v":"h",value:t.candidate.value,sourceNodeId:t.candidate.nodeId,targetNodeIds:[t.draggingId]}}}function rc(e,t,n,r,o,s){if(!s.snapToNodes||e.length===0)return;let i;for(let a of t){let d=n.get(a);if(!d)continue;let c=o==="x"?[d.x,d.x+d.w/2,d.x+d.w]:[d.y,d.y+d.h/2,d.y+d.h];for(let u of c){let p=u+r;for(let l of e)i=b2(i,{axis:o,candidate:l,draggingId:a,moved:p,tolerance:s.tolerance})}}return i}var I2={enabled:!0,tolerance:6,snapToGrid:!1,snapToNodes:!0,snapToGuidelines:!0,edgeSnapping:!0,centerSnapping:!0,spacingSnapping:!1};function rb(e){let t={...I2,...e??{}},n={activeLines:[],snapOffset:{x:0,y:0}},r={vertical:[],horizontal:[]},o=new Set,s=i=>{n={activeLines:[...i.activeLines],snapOffset:{...i.snapOffset}};for(let a of Array.from(o))a(n)};return{getSnapConfig(){return t},setSnapConfig(i){t={...t,...i}},getSnappingState(){return n},setSnappingState:s,clearSnapping(){s({activeLines:[],snapOffset:{x:0,y:0}})},buildCandidatePool(i,a){let d=new Set(i);r=a?uf(a,i):{vertical:r.vertical.filter(c=>!d.has(c.nodeId)),horizontal:r.horizontal.filter(c=>!d.has(c.nodeId))}},clearCandidatePool(){r={vertical:[],horizontal:[]}},computeSnapResult(i,a,d){if(!t.enabled){let m={adjustedDelta:a,snapOffset:{x:0,y:0},activeLines:[]};return s({activeLines:m.activeLines,snapOffset:m.snapOffset}),m}let c=new Set(i),u=rc(r.vertical.filter(m=>!c.has(m.nodeId)),i,d,a.x,"x",t),p=rc(r.horizontal.filter(m=>!c.has(m.nodeId)),i,d,a.y,"y",t),l={x:(u==null?void 0:u.offset)??0,y:(p==null?void 0:p.offset)??0},f=[...u?[u.line]:[],...p?[p.line]:[]],h={adjustedDelta:{x:a.x+l.x,y:a.y+l.y},snapOffset:l,activeLines:f};return s({activeLines:f,snapOffset:l}),h},subscribeSnapping(i){return o.add(i),Ae(o,i)}}}function ob(e=!1){let t=e,n=new Set,r=o=>{if(t!==o){t=o;for(let s of Array.from(n))s(t)}};return{isViewportPanModeEnabled(){return t},setViewportPanModeEnabled:r,toggleViewportPanModeEnabled(){r(!t)},subscribeViewportPanModeEnabled(o){return n.add(o),Ae(n,o)}}}function sb(){let e=new Set;return{emitGeometryChange(t){if(t.nodeIds.size!==0)for(let n of Array.from(e))n(t)},subscribeGeometryChange(t){return e.add(t),Ae(e,t)}}}function pf(e){let t=nb(e==null?void 0:e.initialSelection),n=WS(),r=$S(),o=QS(),s=ZS(),i=eb(),a=JS(),d=ob(),c=rb(e==null?void 0:e.initialSnapConfig),u=XS(),p=HS(),l=sb();return{...t,...n,...r,...o,...s,...i,...a,...d,...c,...u,...p,...l,setSelection:m=>{t.setSelection(m),Vt(t.getSelection()).size>0&&n.clearEdgeSelection()},apply:(m,g)=>{t.apply(m,g),t.getSelectedIds().size>0&&n.clearEdgeSelection()},setSelectedEdge(m){t.clear(),n.setSelectedEdge(m)},clearEdgeSelection:n.clearEdgeSelection,clear(m){if(m){u.clear(m);return}t.clear(),n.clearEdgeSelection(),r.clearEdgeHover(),o.clear(),s.clearHighlightedNodes()}}}var _2=e=>String(e).replace(/~/g,"~0").replace(/\//g,"~1"),R2=e=>e.replace(/~1/g,"/").replace(/~0/g,"~"),E2=e=>/^\d+$/.test(e)?Number(e):e,ib=e=>e.length===0?"":`/${e.map(_2).join("/")}`,lf=e=>{if(e==="")return[];if(!e.startsWith("/"))throw new Error(`Invalid JSON pointer: ${e}`);return e.slice(1).split("/").map(R2).map(E2)},ab=e=>{if(e.path[0]==="revision"||e.path[0]!=="assets"||e.path[1]===void 0)return null;let t={assetId:String(e.path[1]),op:e.op,path:ib(e.path.slice(2))};return e.op!=="remove"&&(t.value=e.value),t},oc=e=>{let t=[];for(let n of e){let r=ab(n);r&&t.push(r)}return t},db=e=>{let t={op:e.op,path:["assets",e.assetId,...lf(e.path)]};return e.op!=="remove"&&(t.value=e.value),t},Lo=e=>e.map(db),cb=e=>`${e.assetId}\0${e.path}`,ub=e=>lf(e).some(t=>typeof t=="number"),C2=(e,t)=>e===t||e===""||t===""?!0:e.startsWith(`${t}/`)||t.startsWith(`${e}/`);function P2(e,t){if(e.op==="add"&&t.op==="remove")return null;if((e.op==="add"||e.op==="replace")&&t.op==="replace")return{...t,op:e.op};if((e.op==="add"||e.op==="replace")&&t.op==="add")return{...t,op:e.op};if(e.op==="replace"&&t.op==="remove")return t;if(e.op==="remove"&&t.op==="add")return{...t,op:"replace"};if(e.op==="remove"&&t.op==="remove")return t}function x2(e){let t=new Map;for(let n=0;n<e.length;n+=1){let r=e[n];ub(r.path)||t.set(cb(r),n)}return t}var Mr=e=>{let t=[],n=new Map;for(let r of e){let o=!ub(r.path),s=cb(r),i=o?n.get(s):void 0,a=i===void 0?void 0:t[i],d=a?P2(a,r):void 0;if(i!==void 0&&a&&d!==void 0){t.splice(i,1),d!==null&&t.push(d),n=x2(t);continue}for(let[c,u]of Array.from(n.entries())){let p=t[u];p.assetId===r.assetId&&C2(p.path,r.path)&&n.delete(c)}t.push(r),o&&n.set(s,t.length-1)}return t};function pb(e,t){return!Number.isFinite(e)||e===void 0?t:Math.max(1,Math.floor(e))}function Si(e){let t=pb(e==null?void 0:e.maxBatchSize,10),n=pb(e==null?void 0:e.maxBatchPatchCount,50),r=[],o=[],s=(a,d)=>{for(let c of a.patches)c.op==="add"&&c.path===""&&d.add(c.assetId)};return{enqueue(a){let d={txId:a.id,patches:Mr(a.forwardPatches),intent:a.intent,mergeKey:a.mergeKey,attempt:0,enqueuedAt:Date.now(),status:"pending"};return r.push(d),d},takeNextBatch(){if(r.length===0||r[0].status==="in-flight")return null;let a=[r[0]],d=new Set;s(r[0],d);let c=a[0].patches.length;for(let p=1;p<r.length;p+=1){let l=r[p],f=l.patches.length,h=l.patches.some(m=>d.has(m.assetId));if(l.status!=="pending"||a.length>=t||c+f>n||h)break;a.push(l),s(l,d),c+=f}for(let p of a)p.status="in-flight",p.attempt+=1;return o=a.map(p=>p.txId),{...a[0],txIds:[...o],patches:a.flatMap(p=>p.patches),attempt:Math.max(...a.map(p=>p.attempt)),status:"in-flight",envelopes:a.map(p=>({...p,patches:[...p.patches]}))}},ack(a){let d=Array.isArray(a)?a:[a],c=new Set(d),u=r.filter(p=>c.has(p.txId)).map(p=>p.txId);return r=r.filter(p=>!c.has(p.txId)),o=o.filter(p=>!c.has(p)),Promise.resolve(u)},markRebasing(a){let d=Array.isArray(a)?a:[a],c=new Set(d);for(let u of r)c.has(u.txId)&&(u.status="rebasing");o=o.filter(u=>!c.has(u))},replaceAll(a){let d=new Set(o);return r=a.map(c=>({...c,patches:[...c.patches],status:d.has(c.txId)?"in-flight":c.status==="in-flight"?"pending":c.status})),o=r.filter(c=>c.status==="in-flight").map(c=>c.txId),Promise.resolve()},size:()=>r.length,snapshot:()=>r.map(a=>({...a,patches:[...a.patches]})),releaseInflight(){let a=new Set(o);for(let d of r)a.has(d.txId)&&(d.status="pending");o=[]}}}var sc=class{constructor(t){this.onFailure=t;this.pending=new Set;this.failure=null;this.tail=Promise.resolve()}track(t){this.run(t).catch(()=>{})}run(t){let n=this.tail.then(async()=>{this.throwIfFailed();try{await t()}catch(r){throw this.recordFailure(r)}}).finally(()=>{this.pending.delete(n)});return this.pending.add(n),this.tail=n.catch(()=>{}),n}async waitForCaptured(){for(;;){this.throwIfFailed();let t=[...this.pending];if(t.length===0)return;await Promise.all(t)}}hasFailed(){return this.failure!==null}recordFailure(t){let n=t instanceof Error?t:new Error(String(t));return this.failure||(this.failure=n,this.onFailure(n)),this.failure}throwIfFailed(){if(this.failure)throw this.failure}};var ic=class{constructor(t){this.options=t;this.ready=!1;this.retryAttempt=0;this.retryTimer=null}isReady(){return this.ready}reset(){this.dispose(),this.ready=!1,this.retryAttempt=0}markReady(){this.ready=!0,this.retryAttempt=0,this.dispose()}schedule(){if(this.options.isClosed()||this.ready||this.retryTimer||!this.options.hasAttachedStore())return;let t=Math.min(this.options.retryMaxMs,this.options.retryBaseMs*2**this.retryAttempt);this.retryAttempt+=1,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.options.sync().then(n=>{n||this.schedule()},()=>{this.schedule()})},t)}dispose(){this.retryTimer&&(clearTimeout(this.retryTimer),this.retryTimer=null)}};zt();var lb=e=>`${e.assetId}\0${e.path}`;function T2(e,t){let n=new Set(e.filter(r=>r.op==="add"&&r.path==="").map(lb));return n.size===0?t:t.map(r=>r.op==="replace"&&r.path===""&&n.has(lb(r))?{...r,op:"add"}:r)}function N2(e,t,n){var o;if(!e.observeRebasedEnvelope)return;let r={state:t,envelope:n};try{e.observeRebasedEnvelope(r)}catch(s){try{(o=e.onObserverError)==null||o.call(e,s,r)}catch{}}}function ac(e){let t=e.baseState,n=[],r=[];for(let o of e.envelopes)try{let[s,i]=qt(t,c=>yn(c,Lo(o.patches))),a=T2(o.patches,Mr(oc(i)));if(a.length===0){t=s;continue}let d={...o,patches:a,status:"pending"};N2(e,t,d),t=s,n.push(d)}catch(s){r.push({txId:o.txId,intent:o.intent,reason:s instanceof Error?s.message:String(s),cause:s instanceof Error?s:void 0})}return{rebased:n,conflicts:r,resultState:t}}zt();var w2=500;function Sn(e){return e instanceof Error?e:new Error(String(e))}async function ff(e,t){if(e.runPersistenceMutation){await e.runPersistenceMutation(t);return}await t()}function Ht(e,t,n){var r;return!e.closed&&e.attachedStore===t&&(n===void 0||((r=e.getAttachmentEpoch)==null?void 0:r.call(e))===n)}async function O2(e,t,n){await ff(e,async()=>{if(e.persistence.replaceOutboundPartition){await e.persistence.replaceOutboundPartition(t,n);return}let r=new Set(n),o=new Set(t.map(a=>a.txId)),i=(await e.persistence.loadOutbound()).filter(a=>!r.has(a.txId)&&!o.has(a.txId));await e.persistence.replaceOutbound([...t,...i])})}var dc=new WeakMap;function D2(e,t){return e===void 0?t:t===void 0?e:Math.max(e,t)}function k2(e,t,n){let r=new Set(n.rebased.map(a=>a.txId)),o=new Set(n.conflicts.map(a=>a.txId)),s=[],i=[];for(let a of t)r.has(a.txId)||(o.has(a.txId)?i.push(a.txId):s.push(a.txId));s.length>0&&e.emit({kind:"discarded",txId:s[0],txIds:s,reason:"rebase-noop"}),i.length>0&&e.emit({kind:"discarded",txId:i[0],txIds:i,reason:"rebase-conflict"})}function fb(e){let t=dc.get(e);if(t)return t;let n={pending:new Map,timer:null,applyQueue:Promise.resolve(),disposed:!1};return dc.set(e,n),n}function mf(e,t){for(let n of t){let r=e.pending.get(n.assetId);e.pending.set(n.assetId,{assetId:n.assetId,minimumAssetVersion:D2(r==null?void 0:r.minimumAssetVersion,n.minimumAssetVersion)})}}function mb(e){return e.assetVersion}function hb(e,t){let n=e,r=[];for(let o of t)try{n=yn(n,Lo(o.patches))}catch(s){r.push({txId:o.txId,intent:o.intent,reason:s instanceof Error?s.message:String(s),cause:s instanceof Error?s:void 0})}return{conflicts:r,resultState:n}}function gb(e,t,n){return n.filter(r=>{var a;let o=(a=t.assets.find(d=>d.assetId===r.assetId))==null?void 0:a.minimumAssetVersion,s=mb(r),i=e.assetVersions.getVersion(r.assetId)??0;return s===void 0||o!==void 0&&s<o?(e.logger.warn(`${e.logPrefix} skip scoped asset: fetched version is below event version`,{assetId:r.assetId,remoteAssetVersion:s,minimumAssetVersion:o,localAssetVersion:i}),!1):s<=i?(e.logger.info(`${e.logPrefix} skip scoped asset: remote asset version is not newer`,{assetId:r.assetId,remoteAssetVersion:s,localAssetVersion:i}),!1):!0})}function M2(e,t,n){return{assets:n,requests:n.map(r=>e.stateAdapter.createRemoteAssetRequest(t,r.assetId))}}function L2(e,t,n,r){let o=e.attachedStore;if(!o||e.closed||t.disposed)return null;let s=gb(e,n,r);if(s.length===0)return e.setState(e.transport.getConnectionState()==="open"?{phase:"idle"}:{phase:"offline"}),e.scheduleFlush(),null;let i=e.stateAdapter.mergeRemoteAssets(o.getState(),s);e.setState({phase:"rebasing"});let a=hb(i,e.outbound.snapshot());a.conflicts.length>0&&e.logger.warn(`${e.logPrefix} scoped asset overlay conflicts`,{assetIds:s.map(c=>c.assetId),conflicts:a.conflicts});let d=()=>{o.applyRemoteSnapshot(a.resultState,{conflicts:a.conflicts})};e.withApplyingRemoteAssets?e.withApplyingRemoteAssets(s.map(c=>c.assetId),d):d();for(let c of s)e.assetVersions.remember(c.assetId,mb(c));return{acceptedAssets:s,remoteState:i,conflicts:a.conflicts}}async function B2(e,t,n,r){var s,i;await((s=e.waitForCapturedPersistenceWrites)==null?void 0:s.call(e));let o=L2(e,t,n,r);if(!(!o||!e.attachedStore||e.closed||t.disposed)&&(e.readOnly||(await ff(e,()=>e.persistence.saveSnapshot({state:o.remoteState})),await((i=e.waitForCapturedPersistenceWrites)==null?void 0:i.call(e))),!(!e.attachedStore||e.closed||t.disposed))){if(e.emit({kind:"snapshot-applied"}),e.conflictPolicy==="conflict-event")for(let a of o.conflicts)e.emit({kind:"conflict",conflict:a});e.setState(e.transport.getConnectionState()==="open"?{phase:"idle"}:{phase:"offline"}),e.scheduleFlush()}}function G2(e,t,n,r){t.applyQueue=t.applyQueue.catch(()=>{}).then(()=>B2(e,t,n,r)).catch(o=>{var s;(s=e.hasPersistenceWriteFailure)!=null&&s.call(e)||e.closed||t.disposed||(e.logger.error(`${e.logPrefix} failed to apply scoped asset`,o),e.setState({phase:"error",error:Sn(o),reason:"remote-sync-failed"}))})}async function U2(e,t){var s,i,a;let n=e.attachedStore;if(!n||e.closed||t.disposed||(s=e.hasPersistenceWriteFailure)!=null&&s.call(e)||!e.transport.fetchAssets)return;let r=Array.from(t.pending.values());if(t.pending.clear(),r.length===0)return;let o=M2(e,n.getState(),r);e.setState({phase:"syncing",reason:"invalidate"});try{let d=await e.transport.fetchAssets(o.requests);if(t.disposed||e.closed||(i=e.hasPersistenceWriteFailure)!=null&&i.call(e))return;let c=gb(e,o,d.assets);if(c.length===0){e.setState(e.transport.getConnectionState()==="open"?{phase:"idle"}:{phase:"offline"}),e.scheduleFlush();return}G2(e,t,o,c)}catch(d){if((a=e.hasPersistenceWriteFailure)!=null&&a.call(e)||e.closed||t.disposed)return;!t.disposed&&!e.closed&&mf(t,r),e.logger.error(`${e.logPrefix} failed to sync scoped assets`,d),e.setState({phase:"error",error:Sn(d),reason:"remote-sync-failed"})}}function yb(e,t){t.timer||t.disposed||(t.timer=setTimeout(()=>{t.timer=null,U2(e,t)},w2))}function Ab(e){let t=dc.get(e);t&&(t.timer&&clearTimeout(t.timer),t.disposed=!0,t.pending.clear(),dc.delete(e))}async function bi(e){var f,h,m,g,y,v,S;let t=e.attachedStore;if(!t||e.closed)return;let n=(f=e.getAttachmentEpoch)==null?void 0:f.call(e);if(await((h=e.waitForCapturedPersistenceWrites)==null?void 0:h.call(e)),!Ht(e,t,n))return;e.setState({phase:"syncing",reason:"bootstrap"});let r=await e.transport.fetchSnapshot();if(!Ht(e,t,n)||(await((m=e.waitForCapturedPersistenceWrites)==null?void 0:m.call(e)),!Ht(e,t,n)))return;e.setState({phase:"rebasing"});let o=e.outbound.snapshot(),s=ac({baseState:r.state,envelopes:o,observeRebasedEnvelope:e.observeOutboundEnvelope?({state:b,envelope:I})=>{var N;return(N=e.observeOutboundEnvelope)==null?void 0:N.call(e,b,I,"rebase")}:void 0,onObserverError:(b,{envelope:I})=>{e.logger.warn(`${e.logPrefix} outbound observer failed`,{error:b instanceof Error?b.message:String(b),phase:"rebase",txId:I.txId})}});s.conflicts.length>0&&e.logger.warn(`${e.logPrefix} rebase conflicts`,{conflicts:s.conflicts});let i=o.map(b=>b.txId),a=new Set(i);if(await((g=e.waitForCapturedPersistenceWrites)==null?void 0:g.call(e)),!Ht(e,t,n))return;let d=e.outbound.snapshot().filter(b=>!a.has(b.txId)),c=hb(s.resultState,d),u=[...s.conflicts,...c.conflicts];if(t.applyRemoteSnapshot(c.resultState,{conflicts:u}),!Ht(e,t,n))return;let p=e.readOnly?void 0:O2(e,s.rebased,i),l=e.outbound.snapshot().filter(b=>!a.has(b.txId));if(await e.outbound.replaceAll(e.readOnly?[]:[...s.rebased,...l]),!!Ht(e,t,n)){if(e.emitOutboundChange(),!e.readOnly){if(await p,!Ht(e,t,n)||(await((y=e.waitForCapturedPersistenceWrites)==null?void 0:y.call(e)),!Ht(e,t,n))||(await ff(e,()=>e.persistence.saveSnapshot({state:r.state})),!Ht(e,t,n)))return;await((v=e.waitForCapturedPersistenceWrites)==null?void 0:v.call(e))}if(Ht(e,t,n)){if((S=e.markRemoteBaselineReady)==null||S.call(e),k2(e,o,s),e.emit({kind:"snapshot-applied"}),e.conflictPolicy==="conflict-event")for(let b of u)e.emit({kind:"conflict",conflict:b});e.setState(e.transport.getConnectionState()==="open"?{phase:"idle"}:{phase:"offline"}),e.scheduleFlush()}}}function vb(e,t){if(!e.attachedStore||e.closed||!t.scopedAssetId||!e.transport.fetchAssets)return Promise.resolve(!1);let r=fb(e);return mf(r,[{assetId:t.scopedAssetId,minimumAssetVersion:t.assetVersion}]),yb(e,r),Promise.resolve(!0)}function Sb(e,t){if(!e.attachedStore||e.closed||!e.transport.fetchAssets)return Promise.resolve(!1);let n=fb(e);return mf(n,[{assetId:t}]),yb(e,n),Promise.resolve(!0)}function Et(e,t,n){return!e.closed&&e.attachedStore===t&&e.getAttachmentEpoch()===n}function z2(e,t){return e.closed&&t!==null&&typeof t=="object"&&"name"in t&&t.name==="AbortError"}function bb(e,t){if(e.hasPersistenceWriteFailure())return;let n=e.attachedStore,r=e.getAttachmentEpoch();(async()=>{try{if(!t.scopedAssetId){e.logger.info(`${e.logPrefix} skip invalidate: only scoped asset refresh is supported`);return}await vb(e,t)}catch(o){if(e.hasPersistenceWriteFailure()||e.attachedStore!==n||e.getAttachmentEpoch()!==r)return;e.logger.error(`${e.logPrefix} failed to handle invalidate`,o),e.setState({phase:"error",error:Sn(o),reason:"remote-sync-failed"})}})()}function Ib(e,t){if(!e.hasPersistenceWriteFailure()){if(t==="closed"){e.setState({phase:"offline"});return}e.setState({phase:"idle"}),e.scheduleFlush()}}async function q2(e,t,n){if(e.isOutboundHydrated())return Et(e,t,n);if(e.readOnly)await e.outbound.replaceAll([]);else{if(await e.waitForCapturedPersistenceWrites(),!Et(e,t,n))return!1;let r=await e.persistence.loadOutbound();if(!Et(e,t,n))return!1;let o=new Set(r.map(i=>i.txId)),s=e.outbound.snapshot().filter(i=>!o.has(i.txId));await e.outbound.replaceAll([...r,...s])}return Et(e,t,n)?(e.markOutboundHydrated(),e.emitOutboundChange(),!0):!1}async function hf(e,t,n){if(!e.isClientIdentityHydrated()){let r=await e.persistence.loadClientId();if(!Et(e,t,n)||!r&&(await e.runPersistenceMutation(()=>e.persistence.saveClientId(e.transport.clientId)),!Et(e,t,n)))return!1;e.markClientIdentityHydrated()}if(!e.isLocalSnapshotHydrated()){let r=await e.persistence.loadSnapshot();if(!Et(e,t,n)||r&&(t.applyRemoteSnapshot(r.state),!Et(e,t,n)))return!1;e.markLocalSnapshotHydrated()}return q2(e,t,n)}async function _b(e,t,n){var o;let r=e.getAttachmentEpoch();try{if(!await hf(e,t,r)||!Et(e,t,r))return;await bi(e)}catch(s){Et(e,t,r)&&!z2(e,s)&&!e.hasPersistenceWriteFailure()&&(e.logger.error(`${e.logPrefix} bootstrap failed`,s),e.setState({phase:"error",error:Sn(s),reason:"bootstrap-failed"}),e.scheduleRemoteBaselineRetry())}finally{e.getAttachmentEpoch()===r&&e.markBootstrapSettled(),Et(e,t,r)&&((o=n.onBootstrapSettled)==null||o.call(n))}}var cc=class{constructor(t){this.options=t;this.listeners=new Set;this.ackSinceSnapshot=0;this.storeUnsubscribe=null;this.invalidateUnsubscribe=null;this.connectionUnsubscribe=null;this.flushTimer=null;this.resyncTimer=null;this.applyingRemoteAssetIds=new Set;this.attachmentEpoch=0;this.bootstrapSettled=!1;this.clientIdentityHydrated=!1;this.localSnapshotHydrated=!1;this.outboundHydrated=!1;this.attachedStore=null;this.closed=!1;this.attach=t=>{this.detachListeners(),this.attachmentEpoch+=1,this.attachedStore=t,this.bootstrapSettled=!1,this.clientIdentityHydrated=!1,this.localSnapshotHydrated=!1,this.outboundHydrated=!1,this.remoteBaselineGate.reset();let{attachmentEpoch:n}=this;return this.storeUnsubscribe=t.subscribe(({prevState:r,nextState:o,transaction:s})=>{if(this.syncTransportAssetSubscriptions(o),this.syncDiscoveredRemoteAssets(r,o,s.source),this.readOnly||s.source!=="local"||s.forwardPatches.length===0)return;let i=this.outbound.enqueue(s);this.emitOutboundChange(),this.observeOutboundEnvelope(r,i,"local"),this.persistenceWriteBarrier.track(()=>this.persistence.appendOutbound(i)),this.scheduleFlush()}),this.syncTransportAssetSubscriptions(t.getState()),this.invalidateUnsubscribe=this.transport.onInvalidate(r=>bb(this,r)),this.connectionUnsubscribe=this.transport.onConnectionChange(r=>Ib(this,r)),this.bootstrap(t),()=>{this.attachedStore!==t||this.attachmentEpoch!==n||(this.detachListeners(),this.attachmentEpoch+=1,this.attachedStore=null,this.clientIdentityHydrated=!1,this.localSnapshotHydrated=!1,this.outboundHydrated=!1,this.remoteBaselineGate.reset())}};this.getState=()=>this.state;this.subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t)});this.getPendingOutboundCount=()=>this.outbound.size();this.getPendingTransactionIds=()=>this.outbound.snapshot().map(t=>t.txId);this.isBootstrapSettled=()=>this.bootstrapSettled;this.getAttachmentEpoch=()=>this.attachmentEpoch;this.isClientIdentityHydrated=()=>this.clientIdentityHydrated;this.isLocalSnapshotHydrated=()=>this.localSnapshotHydrated;this.isOutboundHydrated=()=>this.outboundHydrated;this.markBootstrapSettled=()=>{this.bootstrapSettled=!0};this.markClientIdentityHydrated=()=>{this.clientIdentityHydrated=!0};this.markLocalSnapshotHydrated=()=>{this.localSnapshotHydrated=!0};this.markOutboundHydrated=()=>{this.outboundHydrated=!0};this.markRemoteBaselineReady=()=>{this.persistenceWriteBarrier.hasFailed()||this.remoteBaselineGate.markReady()};this.scheduleRemoteBaselineRetry=()=>{this.persistenceWriteBarrier.hasFailed()||this.remoteBaselineGate.schedule()};this.hasPersistenceWriteFailure=()=>this.persistenceWriteBarrier.hasFailed();this.waitForCapturedPersistenceWrites=()=>this.persistenceWriteBarrier.waitForCaptured();this.runPersistenceMutation=t=>this.persistenceWriteBarrier.run(t);this.flush=()=>{this.readOnly||this.scheduleFlush(0)};this.close=()=>{this.closed=!0,this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=null),this.resyncTimer&&(clearTimeout(this.resyncTimer),this.resyncTimer=null),this.detachListeners(),this.transport.close(),this.setState({phase:"offline"})};var n,r,o,s,i,a,d;this.transport=t.transport,this.persistence=t.persistence,this.stateAdapter=t.stateAdapter,this.assetVersions=t.transport.assetVersions??new fn,this.readOnly=!!t.readOnly,this.outbound=Si({maxBatchSize:(n=t.flush)==null?void 0:n.maxBatchSize,maxBatchPatchCount:(r=t.flush)==null?void 0:r.maxBatchPatchCount}),this.conflictPolicy=t.conflictPolicy??"remote-wins",this.logger=mo(t.logger),this.logPrefix=t.logPrefix??"[pippit-asset-sdk:sync]",this.debounceMs=((o=t.flush)==null?void 0:o.debounceMs)??0,this.retryBaseMs=((s=t.flush)==null?void 0:s.retryBaseMs)??500,this.retryMaxMs=((i=t.flush)==null?void 0:i.retryMaxMs)??3e4,this.maxAttempts=((a=t.flush)==null?void 0:a.maxAttempts)??1/0,this.saveEveryNAcks=((d=t.snapshot)==null?void 0:d.saveEveryNAcks)??50,this.remoteBaselineGate=new ic({hasAttachedStore:()=>!!this.attachedStore,isClosed:()=>this.closed,retryBaseMs:this.retryBaseMs,retryMaxMs:this.retryMaxMs,sync:()=>this.syncRemoteBaseline()}),this.persistenceWriteBarrier=new sc(c=>this.handlePersistenceWriteFailure(c)),this.state=t.transport.getConnectionState()==="open"?{phase:"idle"}:{phase:"offline"}}emit(t){for(let n of Array.from(this.listeners))n(t)}emitOutboundChange(){this.emit({kind:"outbound-change",pendingOutboundCount:this.outbound.size()})}observeOutboundEnvelope(t,n,r){var o,s;try{(s=(o=this.options).observeOutboundEnvelope)==null||s.call(o,{state:t,envelope:n,phase:r})}catch(i){this.logger.warn(`${this.logPrefix} outbound observer failed`,{error:i instanceof Error?i.message:String(i),phase:r,txId:n.txId})}}withApplyingRemoteAssets(t,n){for(let r of t)this.applyingRemoteAssetIds.add(r);try{n()}finally{for(let r of t)this.applyingRemoteAssetIds.delete(r)}}setState(t){this.persistenceWriteBarrier.hasFailed()&&!(t.phase==="error"&&t.reason==="persistence-failed")&&!(this.closed&&t.phase==="offline")||(this.state=t,this.emit({kind:"state-change",state:t}))}scheduleFlush(t=this.debounceMs){this.closed||this.readOnly||this.persistenceWriteBarrier.hasFailed()||(this.flushTimer&&clearTimeout(this.flushTimer),this.flushTimer=setTimeout(()=>{this.flushTimer=null,this.flushNow().catch(n=>{if(this.persistenceWriteBarrier.hasFailed())return;let r=Sn(n);this.logger.error(`${this.logPrefix} flush failed`,r),this.setState({phase:"error",error:r,reason:"commit-failed"})})},t))}releaseInflight(){var t,n;(n=(t=this.outbound).releaseInflight)==null||n.call(t)}handlePersistenceWriteFailure(t){this.remoteBaselineGate.reset(),this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=null),this.resyncTimer&&(clearTimeout(this.resyncTimer),this.resyncTimer=null),!this.closed&&(this.logger.error(`${this.logPrefix} persistence write failed`,t),this.setState({phase:"error",error:t,reason:"persistence-failed"}))}syncTransportAssetSubscriptions(t){!t||!this.transport.syncAssetSubscriptions||this.transport.syncAssetSubscriptions(this.stateAdapter.collectAssetIds(t))}syncDiscoveredRemoteAssets(t,n,r){if(r!=="remote"||!this.bootstrapSettled||!this.transport.fetchAssets)return;let o=new Set(this.stateAdapter.collectAssetIds(t)),s=this.stateAdapter.collectAssetIds(n).filter(i=>!o.has(i)&&!this.applyingRemoteAssetIds.has(i));for(let i of s)Sb(this,i)}async flushNow(){if(!this.attachedStore||this.closed||this.readOnly||this.persistenceWriteBarrier.hasFailed())return;if(this.transport.getConnectionState()!=="open"){this.setState({phase:"offline"});return}if(!this.remoteBaselineGate.isReady()){this.bootstrapSettled&&this.scheduleRemoteBaselineRetry();return}try{await this.waitForCapturedPersistenceWrites()}catch{return}if(!this.attachedStore||this.closed||this.transport.getConnectionState()!=="open"||!this.remoteBaselineGate.isReady()||this.state.phase==="flushing"||this.state.phase==="syncing"||this.state.phase==="rebasing")return;let t=this.outbound.takeNextBatch();if(!t){this.setState({phase:"idle"});return}if(this.observeOutboundBatch(t,"commit"),t.patches.length===0){let o;try{o=await this.removeAckedOutbound(t.txIds)}catch{return}this.emit({kind:"committed",txId:t.txId,ackedTxIds:o}),this.setState({phase:"idle"}),this.scheduleFlush();return}this.setState({phase:"flushing",inflight:t.txId,inflightTxIds:t.txIds});let n=await this.transport.commit(t);if(this.closed||this.persistenceWriteBarrier.hasFailed())return;if(n.status==="ack"){try{await this.handleAck(t,n.ackedTxIds)}catch{return}return}if(n.status==="reject"){try{await this.handleCommitReject(t,n.ackedTxIds,n.error)}catch{return}return}if(n.retryable===!1){try{await this.removeAckedOutbound(t.txIds)}catch{return}this.logger.error(`${this.logPrefix} non-retryable commit failed`,n.error,{txIds:t.txIds,attempt:t.attempt}),this.setState({phase:"error",error:n.error,reason:"commit-failed"});return}if(this.releaseInflight(),t.attempt>=this.maxAttempts){this.logger.error(`${this.logPrefix} commit retry attempts exhausted`,n.error,{txIds:t.txIds,attempt:t.attempt,maxAttempts:this.maxAttempts}),this.setState({phase:"error",error:n.error,reason:"commit-failed"});return}let r=Math.min(this.retryMaxMs,this.retryBaseMs*2**Math.max(0,t.attempt-1));if(n.requiresResync){this.logger.warn(`${this.logPrefix} commit blocked on missing base versions, scheduling resync`,{txIds:t.txIds,attempt:t.attempt,delay:r}),this.setState({phase:"idle"}),this.scheduleResync(r);return}this.setState({phase:"idle"}),this.scheduleFlush(r)}scheduleResync(t){this.closed||this.readOnly||this.persistenceWriteBarrier.hasFailed()||this.resyncTimer||(this.resyncTimer=setTimeout(()=>{this.resyncTimer=null,this.resyncNow()},t))}async resyncNow(){let{attachedStore:t,attachmentEpoch:n}=this;if(!(!t||this.closed||this.readOnly||this.persistenceWriteBarrier.hasFailed())){if(this.state.phase==="flushing"||this.state.phase==="syncing"||this.state.phase==="rebasing"){this.scheduleResync(this.retryBaseMs);return}try{await bi(this)}catch(r){if(this.persistenceWriteBarrier.hasFailed()||this.attachedStore!==t||this.attachmentEpoch!==n)return;this.logger.error(`${this.logPrefix} resync after blocked commit failed`,r),this.setState({phase:"error",error:Sn(r),reason:"remote-sync-failed"}),this.scheduleResync(this.retryMaxMs)}}}async syncRemoteBaseline(){let{attachedStore:t,attachmentEpoch:n}=this;if(!t||this.closed)return!1;if(this.persistenceWriteBarrier.hasFailed())return!0;if(this.state.phase==="flushing"||this.state.phase==="syncing"||this.state.phase==="rebasing")return!1;try{return!await hf(this,t,n)||this.attachedStore!==t||this.attachmentEpoch!==n||(await bi(this),this.attachedStore!==t||this.attachmentEpoch!==n)?!0:this.remoteBaselineGate.isReady()}catch(r){return this.closed?!1:this.persistenceWriteBarrier.hasFailed()||this.attachedStore!==t||this.attachmentEpoch!==n?!0:(this.logger.error(`${this.logPrefix} remote baseline retry failed`,r),this.setState({phase:"error",error:Sn(r),reason:"remote-sync-failed"}),!1)}}async handleCommitReject(t,n,r){let o=n!=null&&n.length?await this.removeAckedOutbound(n):[];o.length>0&&(this.ackSinceSnapshot+=o.length,this.emit({kind:"committed",txId:o[0],ackedTxIds:o}));let s=new Set(o),i=t.txIds.filter(d=>!s.has(d));i.length>0&&await this.removeAckedOutbound(i);let a=r??new Error(`Asset sync commit rejected for transaction ${t.txId}`);this.logger.error(`${this.logPrefix} commit rejected`,a,{txIds:t.txIds,ackedTxIds:o,rejectedTxIds:i}),this.setState({phase:"error",error:a,reason:"commit-rejected"})}async handleAck(t,n){let r=await this.removeAckedOutbound(n!=null&&n.length?n:t.txIds);if(this.ackSinceSnapshot+=Math.max(1,r.length),this.emit({kind:"committed",txId:t.txId,ackedTxIds:r}),this.ackSinceSnapshot>=this.saveEveryNAcks&&this.attachedStore){this.ackSinceSnapshot=0;let o=this.attachedStore.getState();await this.runPersistenceMutation(()=>this.persistence.saveSnapshot({state:o}))}this.setState({phase:"idle"}),this.scheduleFlush()}async removeAckedOutbound(t){let n=new Set(Array.isArray(t)?t:[t]),r=this.outbound.snapshot().filter(s=>n.has(s.txId)).map(s=>s.txId);for(let s of r)await this.runPersistenceMutation(()=>this.persistence.removeOutbound(s));let o=await this.outbound.ack(r);return this.emitOutboundChange(),o}observeOutboundBatch(t,n){var o;let r=(o=this.attachedStore)==null?void 0:o.getState();if(!(!r||!this.options.observeOutboundEnvelope))for(let s of t.envelopes)this.observeOutboundEnvelope(r,s,n)}async bootstrap(t){await _b(this,t,this.options)}detachListeners(){var t,n,r;Ab(this),this.remoteBaselineGate.dispose(),(t=this.storeUnsubscribe)==null||t.call(this),(n=this.invalidateUnsubscribe)==null||n.call(this),(r=this.connectionUnsubscribe)==null||r.call(this),this.storeUnsubscribe=null,this.invalidateUnsubscribe=null,this.connectionUnsubscribe=null}};function Ii(e){return new cc(e)}zt();function gf(e,t){if(typeof t!="string")return;let n=t.trim();n&&e.add(n)}function Rb(e){let t=new Set;gf(t,e.rootCanvasId);for(let[n,r]of Object.entries(e.assets))gf(t,n),gf(t,r==null?void 0:r.pippitAssetId);return[...t]}function K2(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function X2(e){let t=K2(e.data)?e.data:void 0,n=(t==null?void 0:t.pippitAssetId)??e.pippitAssetId;return typeof n=="string"&&n.trim()?n:typeof e.id=="string"&&e.id.trim()?e.id:void 0}function $2(e,t){for(let n of Object.values(e.assets))if(Ut(n)){for(let r of Object.values(n.content.nodes))if(X2(r)===t)return r.type}}function Eb(e,t){let n=e.assets[t],r=$2(e,t);return{assetId:t,assetKind:n&&Ut(n)?"canvas":"node",...r?{nodeType:r}:{}}}function Cb(e,t){let n={...e.assets};for(let r of t)r.asset&&(n[r.assetId]=r.asset);return{...e,assets:n}}var W2={collectAssetIds:Rb,createRemoteAssetRequest:Eb,mergeRemoteAssets:Cb};function Q2(e,t){return{...e,assetVersions:e.assetVersions,fetchSnapshot:async()=>({state:(await e.fetchSnapshot({onProgress:r=>{try{t(r.kind==="root-ready"?{kind:"bootstrap-root-ready",document:r.document}:{kind:"bootstrap-assets-ready",document:r.document,readyAssetIds:r.readyAssetIds})}catch(o){Re.warn("[canvas-sdk:sync] bootstrap progress observer failed",{error:o instanceof Error?o.message:String(o),kind:r.kind})}}})).document})}}function J2(e){return{...e,replaceOutboundPartition:e.replaceOutboundPartition,loadSnapshot:async()=>{let t=await e.loadSnapshot();return t?{state:t.document}:null},saveSnapshot:({state:t})=>e.saveSnapshot({document:t})}}function yf(e){let t=new Set,n=s=>{for(let i of Array.from(t))i(s)},r=Ii({...e,transport:Q2(e.transport,n),persistence:J2(e.persistence),stateAdapter:W2,observeOutboundEnvelope:e.observeOutboundEnvelope?({state:s,envelope:i,phase:a})=>{var d;return(d=e.observeOutboundEnvelope)==null?void 0:d.call(e,{document:s,envelope:i,phase:a})}:void 0,logger:Re,logPrefix:"[canvas-sdk:sync]"}),o=r.subscribe(s=>n(s));return{attach:s=>r.attach(s),getState:r.getState,subscribe:s=>(t.add(s),()=>t.delete(s)),getPendingOutboundCount:()=>{var s;return((s=r.getPendingOutboundCount)==null?void 0:s.call(r))??0},flush:r.flush,close:()=>{r.close(),o(),t.clear()}}}var Pb=new WeakMap;function Z2(e){return{txId:e.id,patches:Mr(e.forwardPatches),intent:e.intent,mergeKey:e.mergeKey,attempt:0,enqueuedAt:Date.now(),status:"pending"}}function xb(e,t,n){e.pendingEnvelopes.get(t)===n&&e.pendingEnvelopes.delete(t),e.pendingEnvelopes.size===0&&(e.captureFailure=void 0,e.failedPersistence=void 0)}function Tb(e,t,n,r){e.captureFailure=r,e.failedPersistence=t,Re.error("[canvas-sdk:sync] failed to persist a transaction between sync engines",r,{txId:n})}function ej(e,t){let n,r=e.captureTail.then(async()=>{n=e.persistence,await n.appendOutbound(t),xb(e,t.txId,t)});e.captureTail=r.then(()=>{},o=>Tb(e,n,t.txId,o))}function tj(e){if(e.pendingEnvelopes.size===0||e.failedPersistence===e.persistence)return;let t,n,r=e.captureTail.then(async()=>{t=e.persistence;for(let[o,s]of Array.from(e.pendingEnvelopes.entries()))n=o,await t.appendOutbound(s),xb(e,o,s)});e.captureTail=r.then(()=>{},o=>Tb(e,t,n??"unknown",o))}function nj(e,t){if(!e.captureEnabled||e.liveEngineTokens.size>0||t.source!=="local"||t.forwardPatches.length===0)return;let n=Z2(t);e.pendingEnvelopes.set(n.txId,n),ej(e,n)}function rj(e,t,n){let r={captureEnabled:n,captureTail:Promise.resolve(),liveEngineTokens:new Set,pendingEnvelopes:new Map,persistence:t};return e.subscribe(({transaction:o})=>nj(r,o)),r}function Nb(e,t,n){let r=Pb.get(e)??rj(e,t,n);Pb.set(e,r),r.persistence=t,r.captureEnabled=n;let o={};return{activateEngine:()=>r.liveEngineTokens.add(o),deactivateEngine:()=>r.liveEngineTokens.delete(o),waitForCaptures:async()=>{for(;;){let s=r.captureTail;if(await s,s===r.captureTail&&(tj(r),s===r.captureTail))break}if(r.pendingEnvelopes.size>0)throw r.captureFailure??new Error("Canvas outbound journal is not durable")}}}var uc=new WeakMap;function wb(){return`client_${typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`}async function oj(e,t,n){var c,u;let r=await e.persistence.loadClientId(),o=r??((c=e.createClientId)==null?void 0:c.call(e))??wb();if(r||await e.persistence.saveClientId(o),n.isDisposed()||(await t.waitForCaptures(),n.isDisposed()))return;let s=e.transportFactory({canvasId:e.canvasId,clientId:o});try{await t.waitForCaptures()}catch(p){throw s.close(),p}if(n.isDisposed()){s.close();return}let i=yf({...e.sync??{},transport:s,persistence:e.persistence}),a=e.onSyncEvent?i.subscribe(e.onSyncEvent):void 0,d;try{d=i.attach(e.store)}catch(p){throw a==null||a(),i.close(),p}if(n.isDisposed()){a==null||a(),d(),i.close();return}t.activateEngine();try{(u=e.onAttached)==null||u.call(e,i)}catch(p){throw t.deactivateEngine(),a==null||a(),d(),i.close(),p}n.onAttached(i,()=>{t.deactivateEngine(),a==null||a(),d()})}function sj(e){return e instanceof Error?e:new Error(String(e))}function Af(e){var d;let t=Nb(e.store,e.persistence,((d=e.sync)==null?void 0:d.readOnly)!==!0),n={},r=!1,o,s,i=()=>{let c=uc.get(e.store);(c==null?void 0:c.token)===n&&uc.delete(e.store),r=!0,o==null||o(),s==null||s.close(),o=void 0,s=void 0},a=uc.get(e.store);return uc.set(e.store,{dispose:i,token:n}),a==null||a.dispose(),r||oj(e,t,{isDisposed:()=>r,onAttached:(c,u)=>{s=c,o=u,r&&i()}}).catch(c=>{var u;r||(Re.error("[canvas-sdk:sync] failed to attach sync engine",c),(u=e.onError)==null||u.call(e,sj(c)))}),i}var ij="__xyq_idb_success_debug__";function Ob(){return globalThis}function aj(){var t;let e=Ob();try{return((t=e.localStorage)==null?void 0:t.getItem(ij))==="1"}catch{return!1}}function Lr(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}function gt(e){var t;if(e==null)return{type:String(e)};if(typeof e=="string")return{type:"string",length:e.length};if(typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer)return{type:"ArrayBuffer",byteLength:e.byteLength};if(typeof Blob<"u"&&e instanceof Blob)return{type:"Blob",size:e.size};if(Array.isArray(e)){let n=0,r={};for(let o of e){if(!o||typeof o!="object")continue;let s=o;Array.isArray(s.patches)&&(n+=s.patches.length),s.status&&(r[s.status]=(r[s.status]??0)+1)}return{type:"Array",length:e.length,patchCount:n,statusCounts:r}}if(typeof e=="object"){let n=e;return{type:((t=e.constructor)==null?void 0:t.name)??"Object",keyCount:Object.keys(n).length,txId:n.txId,status:n.status,patchCount:Array.isArray(n.patches)?n.patches.length:void 0}}return{type:typeof e}}function Yn(e,t,n){if(!aj())return;let r=n===void 0?void 0:Math.round((Lr()-n)*10)/10;Ob().console.info("[xyq-idb-success]",e,{...t,...r===void 0?{}:{elapsedMs:r}})}var kb="canvas-sync",Mb="outbound",dj="clientId",pc=new Map,_i=new Map,Ri=new Map;function Bo(e,t,n=!1){let o=(_i.get(e)??Promise.resolve()).then(t,t).catch(i=>{throw n&&!Ri.has(e)&&Ri.set(e,i),i}),s=o.then(()=>{},()=>{});return _i.set(e,s),s.then(()=>{_i.get(e)===s&&_i.delete(e)}),o}async function Db(e,t=!1){if(await _i.get(e),t&&Ri.has(e))throw Ri.get(e)}function cj(e){if(typeof indexedDB>"u")return Promise.resolve(null);let t=e.dbName??kb,n=e.storeName??Mb;return new Promise(r=>{let o=Lr(),s=indexedDB.open(t,1);s.onupgradeneeded=()=>{let i=s.result;i.objectStoreNames.contains(n)||i.createObjectStore(n)},s.onsuccess=()=>{Yn("canvas.open",{dbName:t,storeName:n},o),r(s.result)},s.onerror=()=>r(null),s.onblocked=()=>r(null)})}function uj(e,t,n){return new Promise((r,o)=>{let s=Lr(),i=e.transaction(t,"readonly").objectStore(t).get(n);i.onsuccess=()=>{Yn("canvas.get",{dbName:e.name,storeName:t,key:n,result:gt(i.result)},s),r(i.result)},i.onerror=()=>o(i.error)})}function pj(e,t,n,r){return new Promise((o,s)=>{let i=Lr(),a=e.transaction(t,"readwrite"),d=a.objectStore(t),c=d.get(n),u,p;c.onsuccess=()=>{let l=c.result;try{let f=r(l);p={after:f,before:l},f===void 0?d.delete(n):d.put(f,n)}catch(f){u=f,a.abort()}},a.oncomplete=()=>{Yn("canvas.mutate",{dbName:e.name,storeName:t,key:n,before:gt(p==null?void 0:p.before),after:gt(p==null?void 0:p.after)},i),o(p??{after:void 0,before:void 0})},a.onerror=()=>s(u??a.error??new Error("IndexedDB mutation failed")),a.onabort=()=>s(u??a.error??new Error("IndexedDB mutation aborted"))})}function Lb(e){return{...e,patches:e.patches.map(t=>({...t})),status:e.status==="in-flight"?"pending":e.status}}function Go(e){return e.map(Lb)}function vf(e,t={}){let n=t.dbName??kb,r=t.storeName??Mb,o=cj(t),s=`outbound:${e}`,i=t.clientIdKey??dj,a=f=>`${n}\0${r}\0${f}`,d=a(s),c=a(i),u=async f=>{let h=await o;return h?uj(h,r,f):pc.get(a(f))},p=async(f,h)=>{let m=await o;if(!m){let g=a(f),y=pc.get(g),v=h(y);return v===void 0?pc.delete(g):pc.set(g,v),{after:v,before:y}}return pj(m,r,f,h)};return{async loadClientId(){return await Db(c),await u(i)??null},async saveClientId(f){await Bo(c,()=>p(i,()=>f).then(()=>{}))},loadSnapshot(){return Promise.resolve(null)},async saveSnapshot(){},loadOutbound:async()=>(await Db(d,!0),Go(await u(s)??[])),async appendOutbound(f){await Bo(d,async()=>{let h=Lr(),m=await p(s,g=>[...Go(g??[]).filter(v=>v.txId!==f.txId),Lb(f)]);Yn("canvas.appendOutbound.plan",{key:s,txId:f.txId,env:gt(f),before:gt(m.before),after:gt(m.after)},h)},!0)},async removeOutbound(f){await Bo(d,async()=>{let h=Lr(),m=await p(s,g=>Go(g??[]).filter(y=>y.txId!==f));Yn("canvas.removeOutbound.plan",{key:s,txId:f,before:gt(m.before),after:gt(m.after)},h)},!0)},async replaceOutboundPartition(f,h){await Bo(d,async()=>{let m=Go(f),g=new Set(h),y=new Set(m.map(S=>S.txId)),v=await p(s,S=>{let b=Go(S??[]).filter(I=>!g.has(I.txId)&&!y.has(I.txId));return[...m,...b]});Yn("canvas.replaceOutboundPartition.plan",{key:s,capturedTxIds:[...h],before:gt(v.before),after:gt(v.after)})},!0)},async replaceOutbound(f){await Bo(d,async()=>{let h=Go(f);Yn("canvas.replaceOutbound.plan",{key:s,value:gt(h)}),await p(s,()=>h)},!0)},async clear(){await Bo(d,()=>p(s,()=>{}).then(()=>{}),!0),Ri.delete(d)}}}function lc(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function lj(e){if(!lc(e))throw new Error("Mutation must be an object");return e}function fj(e){throw new Error(`Unsupported canvas mutation kind: ${String(e)}`)}function mj(e,t,n){if(typeof t!="number"||!Number.isSafeInteger(t)||t<0)throw new Error(`Invalid array index for op ${n.op} at ${n.path}: ${String(t)}`);if(!(n.op==="add"?t<=e.length:t<e.length))throw new Error(`Array index out of bounds for op ${n.op} at ${n.path}: ${t}`);return t}function hj(e,t,n){if(!e||typeof e!="object")throw new Error(`Cannot apply patch at ${n.path}`);if(Array.isArray(e)){let o=mj(e,t,n);if(n.op==="remove"){e.splice(o,1);return}if(!("value"in n)||n.value===void 0)throw new Error(`Patch value is required for op ${n.op} at ${n.path}`);if(n.op==="add"){e.splice(o,0,n.value);return}e[o]=n.value;return}let r=e;if(n.op==="remove"){delete r[String(t)];return}if(!("value"in n)||n.value===void 0)throw new Error(`Patch value is required for op ${n.op} at ${n.path}`);r[String(t)]=n.value}function gj(e,t){let n=e,r=t;for(let o of Object.keys(n))o in r||delete n[o];for(let[o,s]of Object.entries(r))n[o]=s}function yj(e,t){if(t.op!=="remove"&&(!("value"in t)||t.value===void 0))throw new Error(`Patch value is required for op ${t.op} at ${t.path}`);if(t.path===""){if(t.op==="remove"){if(t.assetId===e.rootCanvasId)throw new Error(`Cannot remove root canvas asset: ${t.assetId}`);if(!Object.prototype.hasOwnProperty.call(e.assets,t.assetId))throw new Error(`Unknown patch target asset: ${t.assetId}`);delete e.assets[t.assetId];return}let i=t.value;if(!lc(i)||i.pippitAssetId!==t.assetId)throw new Error(`Invalid asset payload for ${t.assetId}`);let a=e.assets[t.assetId];if(!a){Mo(e,t.assetId,i);return}gj(a,i);return}let n=e.assets[t.assetId];if(!n)throw new Error(`Unknown patch target asset: ${t.assetId}`);let r=Jl(t.path),o=n;for(let i=0;i<r.length-1;i+=1){let a=r[i];if(!o||typeof o!="object")throw new Error(`Cannot apply patch at ${t.path}`);o=o[String(a)]}let s=r[r.length-1];if(s===void 0)throw new Error(`Invalid patch path: ${t.path}`);hj(o,s,t)}function Aj(e,t,n){return e.store.transact(r=>{let o=r.assets[t.assetId];if(!o)throw new Error(`Unknown asset: ${t.assetId}`);t.contentPatch&&lc(o.content)?Object.assign(o.content,t.contentPatch):t.contentPatch&&(o.content=t.contentPatch),t.extraPatch&&lc(o.extra)?Object.assign(o.extra,t.extraPatch):t.extraPatch&&(o.extra=t.extraPatch)},{intent:n})}function vj(e,t,n){return e.store.transact(r=>{for(let o of t.patches)yj(r,o)},{intent:n})}function Sj(e,t,n,r){var s,i;let o;switch(t.kind){case"set_title":o=e.store.commands.setTitle(t.title);break;case"set_cover":o=e.store.commands.setCover(t.cover);break;case"set_global_bounds":o=e.store.commands.setGlobalBounds(t.bounds);break;case"create_node":o=e.store.commands.createNode(t.node,{assets:t.assets,autoCreateNodeAsset:t.autoCreateNodeAsset});break;case"delete_nodes":o=e.store.commands.deleteNodes(t.ids);break;case"update_node_data":o=e.store.commands.updateNodeData(t.id,t.patch);break;case"set_node_style":o=e.store.commands.setNodeStyle(t.id,t.style);break;case"update_asset":o=Aj(e,t,n);break;case"move_nodes":o=e.store.commands.moveNodes(t.ids,t.delta);break;case"resize_node":o=e.store.commands.resizeNode(t.id,t.size);break;case"set_node_position":o=e.store.commands.setNodePosition(t.id,t.position);break;case"align_nodes":o=e.store.commands.alignNodes(t.ids,t.direction);break;case"distribute_nodes":o=e.store.commands.distributeNodes(t.ids,t.axis);break;case"arrange_nodes":o=e.store.commands.arrangeNodes(t.ids,t.layout,t.options);break;case"auto_layout_nodes":o=e.store.commands.autoLayoutNodes(t.options);break;case"group_nodes":o=e.store.commands.group(t.ids);break;case"ungroup":o=e.store.commands.ungroup(t.groupId);break;case"reparent":o=e.store.commands.reparent(t.nodeId,t.newParentId,t.index);break;case"reorder_children":o=e.store.commands.reorderChildren(t.groupId,t.orderedChildren);break;case"set_group_collapsed":o=e.store.commands.setGroupCollapsed(t.groupId,t.collapsed);break;case"create_edge":o=e.store.commands.createEdge(t.edge);break;case"delete_edges":o=e.store.commands.deleteEdges(t.ids);break;case"reconnect_edge":o=e.store.commands.reconnectEdge(t.id,t.patch);break;case"update_edge_data":o=e.store.commands.updateEdgeData(t.id,t.patch);break;case"update_snap_settings":o=e.store.commands.updateSnapSettings(t.patch);break;case"set_snap_enabled":o=e.store.commands.setSnapEnabled(t.enabled);break;case"set_auto_layout_strategy":o=e.store.commands.setAutoLayoutStrategy(t.strategy);break;case"invoke_command":o=e.store.commands.invoke(t.name,...t.args??[]);break;case"delete":(s=t.edgeIds)!=null&&s.length&&r(e.store.commands.deleteEdges(t.edgeIds)),(i=t.nodeIds)!=null&&i.length&&r(e.store.commands.deleteNodes(t.nodeIds));return;case"apply_patches":o=vj(e,t,n);break;default:fj(t)}r(o)}function Ei({atomic:e,dryRun:t,expectedRevision:n,intent:r,mutations:o,runtime:s}){if(typeof n=="number"&&s.store.getRevision()!==n)throw new Error(`Expected revision ${n}, current revision ${s.store.getRevision()}`);if(t)return{dryRun:!0,results:[]};let i=[],a=u=>{if(i.push(u),e&&u.status==="aborted")throw u.error??new Error(u.reason)},d=()=>{for(let u of o)Sj(s,lj(u),r,a)};if(!e)return d(),{results:i};let c=s.store.commands.batch(r,d);if(c.status==="aborted")throw c.error??new Error(c.reason);return{results:[c]}}function fc(e){return JSON.parse(JSON.stringify(e))}function bj(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Sf(e){return Array.isArray(e)?`[${e.map(Sf).join(",")}]`:bj(e)?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${Sf(e[t])}`).join(",")}}`:JSON.stringify(e)}function Ij(e){let t=5381;for(let n=0;n<e.length;n+=1)t=t*33^e.charCodeAt(n);return`hash_${(t>>>0).toString(36)}`}function _j(e){return Ij(Sf(e))}function Rj(){let e=new Map;return{create(t){e.set(t.checkpointId,fc(t))},get(t){let n=e.get(t);return n?fc(n):void 0},list(t){return Array.from(e.values()).filter(n=>n.canvasId===t).map(n=>fc(n))}}}var Bb=new WeakMap;function Uo(e){if(e.checkpoints)return e.checkpoints;let t=Bb.get(e);return t||(t=Rj(),Bb.set(e,t)),t}async function Ej(e,t){let n=typeof e.permissions=="function"?await e.permissions(t):e.permissions;return new Set(n)}function Ct(e,t,n){return{code:t,message:n,ok:!1,revision:e.store.getRevision()}}function se(e){return JSON.stringify(e,null,2)}function bn(e,t){return{data:t,ok:!0,revision:e.store.getRevision()}}function zo(e){return e.store.getState().rootCanvasId}function mc(e){var t;return!!((t=e.store.getRootCanvasContent().settings)!=null&&t.readOnly)}async function hc(e,t,n){let r=await Ej(e,t),o=n.filter(s=>!r.has(s));return o.length>0?Ct(e,"PERMISSION_DENIED",`Missing canvas tool permission(s): ${o.join(", ")}`):null}function bf(e,t){var o,s;let n=fc(e.store.getState()),r=((o=e.now)==null?void 0:o.call(e))??Date.now();return{canvasId:n.rootCanvasId,checkpointId:((s=e.createCheckpointId)==null?void 0:s.call(e))??`canvas_checkpoint_${r}`,createdAt:r,document:n,documentHash:_j(n),reason:t,revision:e.store.getRevision()}}function Gb(e,t){return tf(e.store,t.document,{intent:"opencode.checkpoint.restore"})}var Cj="__debug_i18n__",Pj="1",xj="0",Ub=new WeakMap;function If(e){try{return e()}catch{return}}function zb(e,t){try{e(t)}catch{}}function Tj(e,t){if(e)try{return new URL(e,"http://pippit-business-shared.local").searchParams.get(t)??void 0}catch{return}}function Nj(e){try{return decodeURIComponent(e)}catch{return}}function wj(e,t){if(e===void 0)return;let n=`${encodeURIComponent(t)}=`,r=e.split(";").map(o=>o.trim()).find(o=>o.startsWith(n));return r?Nj(r.slice(n.length)):void 0}function qb(e,t,n,r){let o=r===void 0?"":`; Max-Age=${r}`;return`${encodeURIComponent(e)}=${encodeURIComponent(t)}; path=${n}${o}`}function Oj(){return{readHref:()=>typeof window>"u"?void 0:window.location.href,readCookie:()=>typeof document>"u"?void 0:document.cookie,writeCookie:e=>{typeof document<"u"&&(document.cookie=e)}}}function Dj(e={}){let t=e.cookieKey??Cj,n=e.enabledValue??Pj,r=e.disabledValue??xj,o=e.cookiePath??"/",s=e.environment??Oj(),i=e.refreshOnHrefChange??!1,a,d,c=p=>{d=p;let l=Tj(p,t);if(l===n)return zb(h=>s.writeCookie(h),qb(t,n,o)),a=!0,a;if(l===r)return zb(h=>s.writeCookie(h),qb(t,"",o,0)),a=!1,a;let f=If(()=>s.readCookie());return p===void 0&&f===void 0?(a=void 0,!1):(a=wj(f,t)===n,a)},u=()=>c(If(()=>s.readHref()));return{isEnabled:()=>{if(a===void 0)return u();if(i){let p=If(()=>s.readHref());if(p!==d)return c(p)}return a},refresh:u,invalidate:()=>{a=void 0,d=void 0}}}function kj(e){return Array.isArray(e)?`${e[0]??""}`:`${e??""}`}var Mj=Dj({refreshOnHrefChange:!0});function gc(){return{memoize:!0,memoizeFallback:!0,bindI18n:"languageChanged",bindI18nStore:"added removed"}}function yc(e,t={}){let n=t.runtime??Mj,r=t.resolveKeyText??kj,o=Ub.get(e)??e.t.bind(e);return Ub.set(e,o),e.t=(...s)=>n.isEnabled()?r(s[0]):o(...s),e}function Fe(e){"@babel/helpers - typeof";return Fe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Fe(e)}function Fb(e,t){if(Fe(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Fe(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Ac(e){var t=Fb(e,"string");return Fe(t)=="symbol"?t:t+""}function jb(e,t,n){return(t=Ac(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function we(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?Object(arguments[t]):{},r=Object.keys(n);typeof Object.getOwnPropertySymbols=="function"&&r.push.apply(r,Object.getOwnPropertySymbols(n).filter(function(o){return Object.getOwnPropertyDescriptor(n,o).enumerable})),r.forEach(function(o){jb(e,o,n[o])})}return e}function Yt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Vb(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,Ac(r.key),r)}}function Kt(e,t,n){return t&&Vb(e.prototype,t),n&&Vb(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function In(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function qo(e,t){if(t&&(Fe(t)=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return In(e)}function Br(e){return Br=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Br(e)}function vc(e,t){return vc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},vc(e,t)}function Ci(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&vc(e,t)}var Lj={type:"logger",log:function(t){this.output("log",t)},warn:function(t){this.output("warn",t)},error:function(t){this.output("error",t)},output:function(t,n){console&&console[t]&&console[t].apply(console,n)}},Bj=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Yt(this,e),this.init(t,n)}return Kt(e,[{key:"init",value:function(n){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=r.prefix||"i18next:",this.logger=n||Lj,this.options=r,this.debug=r.debug}},{key:"setDebug",value:function(n){this.debug=n}},{key:"log",value:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return this.forward(r,"log","",!0)}},{key:"warn",value:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return this.forward(r,"warn","",!0)}},{key:"error",value:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return this.forward(r,"error","")}},{key:"deprecate",value:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return this.forward(r,"warn","WARNING DEPRECATED: ",!0)}},{key:"forward",value:function(n,r,o,s){return s&&!this.debug?null:(typeof n[0]=="string"&&(n[0]="".concat(o).concat(this.prefix," ").concat(n[0])),this.logger[r](n))}},{key:"create",value:function(n){return new e(this.logger,we({},{prefix:"".concat(this.prefix,":").concat(n,":")},this.options))}}]),e}(),_n=new Bj,Kn=function(){function e(){Yt(this,e),this.observers={}}return Kt(e,[{key:"on",value:function(n,r){var o=this;return n.split(" ").forEach(function(s){o.observers[s]=o.observers[s]||[],o.observers[s].push(r)}),this}},{key:"off",value:function(n,r){if(this.observers[n]){if(!r){delete this.observers[n];return}this.observers[n]=this.observers[n].filter(function(o){return o!==r})}}},{key:"emit",value:function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),s=1;s<r;s++)o[s-1]=arguments[s];if(this.observers[n]){var i=[].concat(this.observers[n]);i.forEach(function(d){d.apply(void 0,o)})}if(this.observers["*"]){var a=[].concat(this.observers["*"]);a.forEach(function(d){d.apply(d,[n].concat(o))})}}}]),e}();function Pi(){var e,t,n=new Promise(function(r,o){e=r,t=o});return n.resolve=e,n.reject=t,n}function Hb(e){return e==null?"":""+e}function Gj(e,t,n){e.forEach(function(r){t[r]&&(n[r]=t[r])})}function Rf(e,t,n){function r(a){return a&&a.indexOf("###")>-1?a.replace(/###/g,"."):a}function o(){return!e||typeof e=="string"}for(var s=typeof t!="string"?[].concat(t):t.split(".");s.length>1;){if(o())return{};var i=r(s.shift());!e[i]&&n&&(e[i]=new n),Object.prototype.hasOwnProperty.call(e,i)?e=e[i]:e={}}return o()?{}:{obj:e,k:r(s.shift())}}function Yb(e,t,n){var r=Rf(e,t,Object),o=r.obj,s=r.k;o[s]=n}function Uj(e,t,n,r){var o=Rf(e,t,Object),s=o.obj,i=o.k;s[i]=s[i]||[],r&&(s[i]=s[i].concat(n)),r||s[i].push(n)}function bc(e,t){var n=Rf(e,t),r=n.obj,o=n.k;if(r)return r[o]}function Kb(e,t,n){var r=bc(e,n);return r!==void 0?r:bc(t,n)}function Qb(e,t,n){for(var r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?typeof e[r]=="string"||e[r]instanceof String||typeof t[r]=="string"||t[r]instanceof String?n&&(e[r]=t[r]):Qb(e[r],t[r],n):e[r]=t[r]);return e}function Fo(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var zj={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};function qj(e){return typeof e=="string"?e.replace(/[&<>"'\/]/g,function(t){return zj[t]}):e}var Ic=typeof window<"u"&&window.navigator&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,Fj=function(e){Ci(t,e);function t(n){var r,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};return Yt(this,t),r=qo(this,Br(t).call(this)),Ic&&Kn.call(In(r)),r.data=n||{},r.options=o,r.options.keySeparator===void 0&&(r.options.keySeparator="."),r}return Kt(t,[{key:"addNamespaces",value:function(r){this.options.ns.indexOf(r)<0&&this.options.ns.push(r)}},{key:"removeNamespaces",value:function(r){var o=this.options.ns.indexOf(r);o>-1&&this.options.ns.splice(o,1)}},{key:"getResource",value:function(r,o,s){var i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},a=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,d=[r,o];return s&&typeof s!="string"&&(d=d.concat(s)),s&&typeof s=="string"&&(d=d.concat(a?s.split(a):s)),r.indexOf(".")>-1&&(d=r.split(".")),bc(this.data,d)}},{key:"addResource",value:function(r,o,s,i){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1},d=this.options.keySeparator;d===void 0&&(d=".");var c=[r,o];s&&(c=c.concat(d?s.split(d):s)),r.indexOf(".")>-1&&(c=r.split("."),i=o,o=c[1]),this.addNamespaces(o),Yb(this.data,c,i),a.silent||this.emit("added",r,o,s,i)}},{key:"addResources",value:function(r,o,s){var i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(var a in s)(typeof s[a]=="string"||Object.prototype.toString.apply(s[a])==="[object Array]")&&this.addResource(r,o,a,s[a],{silent:!0});i.silent||this.emit("added",r,o,s)}},{key:"addResourceBundle",value:function(r,o,s,i,a){var d=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1},c=[r,o];r.indexOf(".")>-1&&(c=r.split("."),i=s,s=o,o=c[1]),this.addNamespaces(o);var u=bc(this.data,c)||{};i?Qb(u,s,a):u=we({},u,s),Yb(this.data,c,u),d.silent||this.emit("added",r,o,s)}},{key:"removeResourceBundle",value:function(r,o){this.hasResourceBundle(r,o)&&delete this.data[r][o],this.removeNamespaces(o),this.emit("removed",r,o)}},{key:"hasResourceBundle",value:function(r,o){return this.getResource(r,o)!==void 0}},{key:"getResourceBundle",value:function(r,o){return o||(o=this.options.defaultNS),this.options.compatibilityAPI==="v1"?we({},{},this.getResource(r,o)):this.getResource(r,o)}},{key:"getDataByLanguage",value:function(r){return this.data[r]}},{key:"toJSON",value:function(){return this.data}}]),t}(Kn),Jb={processors:{},addPostProcessor:function(t){this.processors[t.name]=t},handle:function(t,n,r,o,s){var i=this;return t.forEach(function(a){i.processors[a]&&(n=i.processors[a].process(n,r,o,s))}),n}},Xb={},$b=function(e){Ci(t,e);function t(n){var r,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Yt(this,t),r=qo(this,Br(t).call(this)),Ic&&Kn.call(In(r)),Gj(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],n,In(r)),r.options=o,r.options.keySeparator===void 0&&(r.options.keySeparator="."),r.logger=_n.create("translator"),r}return Kt(t,[{key:"changeLanguage",value:function(r){r&&(this.language=r)}},{key:"exists",value:function(r){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}},s=this.resolve(r,o);return s&&s.res!==void 0}},{key:"extractFromKey",value:function(r,o){var s=o.nsSeparator!==void 0?o.nsSeparator:this.options.nsSeparator;s===void 0&&(s=":");var i=o.keySeparator!==void 0?o.keySeparator:this.options.keySeparator,a=o.ns||this.options.defaultNS;if(s&&r.indexOf(s)>-1){var d=r.match(this.interpolator.nestingRegexp);if(d&&d.length>0)return{key:r,namespaces:a};var c=r.split(s);(s!==i||s===i&&this.options.ns.indexOf(c[0])>-1)&&(a=c.shift()),r=c.join(i)}return typeof a=="string"&&(a=[a]),{key:r,namespaces:a}}},{key:"translate",value:function(r,o,s){var i=this;if(Fe(o)!=="object"&&this.options.overloadTranslationOptionHandler&&(o=this.options.overloadTranslationOptionHandler(arguments)),o||(o={}),r==null)return"";Array.isArray(r)||(r=[String(r)]);var a=o.keySeparator!==void 0?o.keySeparator:this.options.keySeparator,d=this.extractFromKey(r[r.length-1],o),c=d.key,u=d.namespaces,p=u[u.length-1],l=o.lng||this.language,f=o.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(l&&l.toLowerCase()==="cimode"){if(f){var h=o.nsSeparator||this.options.nsSeparator;return p+h+c}return c}var m=this.resolve(r,o),g=m&&m.res,y=m&&m.usedKey||c,v=m&&m.exactUsedKey||c,S=Object.prototype.toString.apply(g),b=["[object Number]","[object Function]","[object RegExp]"],I=o.joinArrays!==void 0?o.joinArrays:this.options.joinArrays,N=!this.i18nFormat||this.i18nFormat.handleAsObject,w=typeof g!="string"&&typeof g!="boolean"&&typeof g!="number";if(N&&g&&w&&b.indexOf(S)<0&&!(typeof I=="string"&&S==="[object Array]")){if(!o.returnObjects&&!this.options.returnObjects)return this.logger.warn("accessing an object - but returnObjects options is not enabled!"),this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,g,o):"key '".concat(c," (").concat(this.language,")' returned an object instead of string.");if(a){var ne=S==="[object Array]",Ge=ne?[]:{},Y=ne?v:y;for(var T in g)if(Object.prototype.hasOwnProperty.call(g,T)){var F="".concat(Y).concat(a).concat(T);Ge[T]=this.translate(F,we({},o,{joinArrays:!1,ns:u})),Ge[T]===F&&(Ge[T]=g[T])}g=Ge}}else if(N&&typeof I=="string"&&S==="[object Array]")g=g.join(I),g&&(g=this.extendTranslation(g,r,o,s));else{var j=!1,J=!1,ie=o.count!==void 0&&typeof o.count!="string",Se=t.hasDefaultValue(o),He=ie?this.pluralResolver.getSuffix(l,o.count):"",ge=o["defaultValue".concat(He)]||o.defaultValue;!this.isValidLookup(g)&&Se&&(j=!0,g=ge),this.isValidLookup(g)||(J=!0,g=c);var re=Se&&ge!==g&&this.options.updateMissing;if(J||j||re){if(this.logger.log(re?"updateKey":"missingKey",l,p,c,re?ge:g),a){var St=this.resolve(c,we({},o,{keySeparator:!1}));St&&St.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}var We=[],pn=this.languageUtils.getFallbackCodes(this.options.fallbackLng,o.lng||this.language);if(this.options.saveMissingTo==="fallback"&&pn&&pn[0])for(var Ue=0;Ue<pn.length;Ue++)We.push(pn[Ue]);else this.options.saveMissingTo==="all"?We=this.languageUtils.toResolveHierarchy(o.lng||this.language):We.push(o.lng||this.language);var Qe=function(ut,Fs,xy){i.options.missingKeyHandler?i.options.missingKeyHandler(ut,p,Fs,re?xy:g,re,o):i.backendConnector&&i.backendConnector.saveMissing&&i.backendConnector.saveMissing(ut,p,Fs,re?xy:g,re,o),i.emit("missingKey",ut,p,Fs,g)};this.options.saveMissing&&(this.options.saveMissingPlurals&&ie?We.forEach(function(Mt){i.pluralResolver.getSuffixes(Mt).forEach(function(ut){Qe([Mt],c+ut,o["defaultValue".concat(ut)]||ge)})}):Qe(We,c,ge))}g=this.extendTranslation(g,r,o,m,s),J&&g===c&&this.options.appendNamespaceToMissingKey&&(g="".concat(p,":").concat(c)),J&&this.options.parseMissingKeyHandler&&(g=this.options.parseMissingKeyHandler(g))}return g}},{key:"extendTranslation",value:function(r,o,s,i,a){var d=this;if(this.i18nFormat&&this.i18nFormat.parse)r=this.i18nFormat.parse(r,s,i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init(we({},s,{interpolation:we({},this.options.interpolation,s.interpolation)}));var c=s.interpolation&&s.interpolation.skipOnVariables||this.options.interpolation.skipOnVariables,u;if(c){var p=r.match(this.interpolator.nestingRegexp);u=p&&p.length}var l=s.replace&&typeof s.replace!="string"?s.replace:s;if(this.options.interpolation.defaultVariables&&(l=we({},this.options.interpolation.defaultVariables,l)),r=this.interpolator.interpolate(r,l,s.lng||this.language,s),c){var f=r.match(this.interpolator.nestingRegexp),h=f&&f.length;u<h&&(s.nest=!1)}s.nest!==!1&&(r=this.interpolator.nest(r,function(){for(var y=arguments.length,v=new Array(y),S=0;S<y;S++)v[S]=arguments[S];return a&&a[0]===v[0]&&!s.context?(d.logger.warn("It seems you are nesting recursively key: ".concat(v[0]," in key: ").concat(o[0])),null):d.translate.apply(d,v.concat([o]))},s)),s.interpolation&&this.interpolator.reset()}var m=s.postProcess||this.options.postProcess,g=typeof m=="string"?[m]:m;return r!=null&&g&&g.length&&s.applyPostProcessor!==!1&&(r=Jb.handle(g,r,o,this.options&&this.options.postProcessPassResolved?we({i18nResolved:i},s):s,this)),r}},{key:"resolve",value:function(r){var o=this,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i,a,d,c,u;return typeof r=="string"&&(r=[r]),r.forEach(function(p){if(!o.isValidLookup(i)){var l=o.extractFromKey(p,s),f=l.key;a=f;var h=l.namespaces;o.options.fallbackNS&&(h=h.concat(o.options.fallbackNS));var m=s.count!==void 0&&typeof s.count!="string",g=s.context!==void 0&&typeof s.context=="string"&&s.context!=="",y=s.lngs?s.lngs:o.languageUtils.toResolveHierarchy(s.lng||o.language,s.fallbackLng);h.forEach(function(v){o.isValidLookup(i)||(u=v,!Xb["".concat(y[0],"-").concat(v)]&&o.utils&&o.utils.hasLoadedNamespace&&!o.utils.hasLoadedNamespace(u)&&(Xb["".concat(y[0],"-").concat(v)]=!0,o.logger.warn('key "'.concat(a,'" for languages "').concat(y.join(", "),`" won't get resolved as namespace "`).concat(u,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),y.forEach(function(S){if(!o.isValidLookup(i)){c=S;var b=f,I=[b];if(o.i18nFormat&&o.i18nFormat.addLookupKeys)o.i18nFormat.addLookupKeys(I,f,S,v,s);else{var N;m&&(N=o.pluralResolver.getSuffix(S,s.count)),m&&g&&I.push(b+N),g&&I.push(b+="".concat(o.options.contextSeparator).concat(s.context)),m&&I.push(b+=N)}for(var w;w=I.pop();)o.isValidLookup(i)||(d=w,i=o.getResource(S,v,w,s))}}))})}}),{res:i,usedKey:a,exactUsedKey:d,usedLng:c,usedNS:u}}},{key:"isValidLookup",value:function(r){return r!==void 0&&!(!this.options.returnNull&&r===null)&&!(!this.options.returnEmptyString&&r==="")}},{key:"getResource",value:function(r,o,s){var i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(r,o,s,i):this.resourceStore.getResource(r,o,s,i)}}],[{key:"hasDefaultValue",value:function(r){var o="defaultValue";for(var s in r)if(Object.prototype.hasOwnProperty.call(r,s)&&o===s.substring(0,o.length)&&r[s]!==void 0)return!0;return!1}}]),t}(Kn);function _f(e){return e.charAt(0).toUpperCase()+e.slice(1)}var jj=function(){function e(t){Yt(this,e),this.options=t,this.whitelist=this.options.supportedLngs||!1,this.supportedLngs=this.options.supportedLngs||!1,this.logger=_n.create("languageUtils")}return Kt(e,[{key:"getScriptPartFromCode",value:function(n){if(!n||n.indexOf("-")<0)return null;var r=n.split("-");return r.length===2||(r.pop(),r[r.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(r.join("-"))}},{key:"getLanguagePartFromCode",value:function(n){if(!n||n.indexOf("-")<0)return n;var r=n.split("-");return this.formatLanguageCode(r[0])}},{key:"formatLanguageCode",value:function(n){if(typeof n=="string"&&n.indexOf("-")>-1){var r=["hans","hant","latn","cyrl","cans","mong","arab"],o=n.split("-");return this.options.lowerCaseLng?o=o.map(function(s){return s.toLowerCase()}):o.length===2?(o[0]=o[0].toLowerCase(),o[1]=o[1].toUpperCase(),r.indexOf(o[1].toLowerCase())>-1&&(o[1]=_f(o[1].toLowerCase()))):o.length===3&&(o[0]=o[0].toLowerCase(),o[1].length===2&&(o[1]=o[1].toUpperCase()),o[0]!=="sgn"&&o[2].length===2&&(o[2]=o[2].toUpperCase()),r.indexOf(o[1].toLowerCase())>-1&&(o[1]=_f(o[1].toLowerCase())),r.indexOf(o[2].toLowerCase())>-1&&(o[2]=_f(o[2].toLowerCase()))),o.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?n.toLowerCase():n}},{key:"isWhitelisted",value:function(n){return this.logger.deprecate("languageUtils.isWhitelisted",`function "isWhitelisted" will be renamed to "isSupportedCode" in the next major - please make sure to rename it's usage asap.`),this.isSupportedCode(n)}},{key:"isSupportedCode",value:function(n){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(n=this.getLanguagePartFromCode(n)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(n)>-1}},{key:"getBestMatchFromCodes",value:function(n){var r=this;if(!n)return null;var o;return n.forEach(function(s){if(!o){var i=r.formatLanguageCode(s);(!r.options.supportedLngs||r.isSupportedCode(i))&&(o=i)}}),!o&&this.options.supportedLngs&&n.forEach(function(s){if(!o){var i=r.getLanguagePartFromCode(s);if(r.isSupportedCode(i))return o=i;o=r.options.supportedLngs.find(function(a){if(a.indexOf(i)===0)return a})}}),o||(o=this.getFallbackCodes(this.options.fallbackLng)[0]),o}},{key:"getFallbackCodes",value:function(n,r){if(!n)return[];if(typeof n=="function"&&(n=n(r)),typeof n=="string"&&(n=[n]),Object.prototype.toString.apply(n)==="[object Array]")return n;if(!r)return n.default||[];var o=n[r];return o||(o=n[this.getScriptPartFromCode(r)]),o||(o=n[this.formatLanguageCode(r)]),o||(o=n[this.getLanguagePartFromCode(r)]),o||(o=n.default),o||[]}},{key:"toResolveHierarchy",value:function(n,r){var o=this,s=this.getFallbackCodes(r||this.options.fallbackLng||[],n),i=[],a=function(c){c&&(o.isSupportedCode(c)?i.push(c):o.logger.warn("rejecting language code not found in supportedLngs: ".concat(c)))};return typeof n=="string"&&n.indexOf("-")>-1?(this.options.load!=="languageOnly"&&a(this.formatLanguageCode(n)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&a(this.getScriptPartFromCode(n)),this.options.load!=="currentOnly"&&a(this.getLanguagePartFromCode(n))):typeof n=="string"&&a(this.formatLanguageCode(n)),s.forEach(function(d){i.indexOf(d)<0&&a(o.formatLanguageCode(d))}),i}}]),e}(),Vj=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","kk","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],Hj={1:function(t){return+(t>1)},2:function(t){return+(t!=1)},3:function(t){return 0},4:function(t){return t%10==1&&t%100!=11?0:t%10>=2&&t%10<=4&&(t%100<10||t%100>=20)?1:2},5:function(t){return t==0?0:t==1?1:t==2?2:t%100>=3&&t%100<=10?3:t%100>=11?4:5},6:function(t){return t==1?0:t>=2&&t<=4?1:2},7:function(t){return t==1?0:t%10>=2&&t%10<=4&&(t%100<10||t%100>=20)?1:2},8:function(t){return t==1?0:t==2?1:t!=8&&t!=11?2:3},9:function(t){return+(t>=2)},10:function(t){return t==1?0:t==2?1:t<7?2:t<11?3:4},11:function(t){return t==1||t==11?0:t==2||t==12?1:t>2&&t<20?2:3},12:function(t){return+(t%10!=1||t%100==11)},13:function(t){return+(t!==0)},14:function(t){return t==1?0:t==2?1:t==3?2:3},15:function(t){return t%10==1&&t%100!=11?0:t%10>=2&&(t%100<10||t%100>=20)?1:2},16:function(t){return t%10==1&&t%100!=11?0:t!==0?1:2},17:function(t){return t==1||t%10==1&&t%100!=11?0:1},18:function(t){return t==0?0:t==1?1:2},19:function(t){return t==1?0:t==0||t%100>1&&t%100<11?1:t%100>10&&t%100<20?2:3},20:function(t){return t==1?0:t==0||t%100>0&&t%100<20?1:2},21:function(t){return t%100==1?1:t%100==2?2:t%100==3||t%100==4?3:0},22:function(t){return t==1?0:t==2?1:(t<0||t>10)&&t%10==0?2:3}};function Yj(){var e={};return Vj.forEach(function(t){t.lngs.forEach(function(n){e[n]={numbers:t.nr,plurals:Hj[t.fc]}})}),e}var Kj=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Yt(this,e),this.languageUtils=t,this.options=n,this.logger=_n.create("pluralResolver"),this.rules=Yj()}return Kt(e,[{key:"addRule",value:function(n,r){this.rules[n]=r}},{key:"getRule",value:function(n){return this.rules[n]||this.rules[this.languageUtils.getLanguagePartFromCode(n)]}},{key:"needsPlural",value:function(n){var r=this.getRule(n);return r&&r.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(n,r){return this.getSuffixes(n).map(function(o){return r+o})}},{key:"getSuffixes",value:function(n){var r=this,o=this.getRule(n);return o?o.numbers.map(function(s){return r.getSuffix(n,s)}):[]}},{key:"getSuffix",value:function(n,r){var o=this,s=this.getRule(n);if(s){var i=s.noAbs?s.plurals(r):s.plurals(Math.abs(r)),a=s.numbers[i];this.options.simplifyPluralSuffix&&s.numbers.length===2&&s.numbers[0]===1&&(a===2?a="plural":a===1&&(a=""));var d=function(){return o.options.prepend&&a.toString()?o.options.prepend+a.toString():a.toString()};return this.options.compatibilityJSON==="v1"?a===1?"":typeof a=="number"?"_plural_".concat(a.toString()):d():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&s.numbers.length===2&&s.numbers[0]===1?d():this.options.prepend&&i.toString()?this.options.prepend+i.toString():i.toString()}return this.logger.warn("no plural rule found for: ".concat(n)),""}}]),e}(),Xj=function(){function e(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Yt(this,e),this.logger=_n.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(n){return n},this.init(t)}return Kt(e,[{key:"init",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};n.interpolation||(n.interpolation={escapeValue:!0});var r=n.interpolation;this.escape=r.escape!==void 0?r.escape:qj,this.escapeValue=r.escapeValue!==void 0?r.escapeValue:!0,this.useRawValueToEscape=r.useRawValueToEscape!==void 0?r.useRawValueToEscape:!1,this.prefix=r.prefix?Fo(r.prefix):r.prefixEscaped||"{{",this.suffix=r.suffix?Fo(r.suffix):r.suffixEscaped||"}}",this.formatSeparator=r.formatSeparator?r.formatSeparator:r.formatSeparator||",",this.unescapePrefix=r.unescapeSuffix?"":r.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":r.unescapeSuffix||"",this.nestingPrefix=r.nestingPrefix?Fo(r.nestingPrefix):r.nestingPrefixEscaped||Fo("$t("),this.nestingSuffix=r.nestingSuffix?Fo(r.nestingSuffix):r.nestingSuffixEscaped||Fo(")"),this.nestingOptionsSeparator=r.nestingOptionsSeparator?r.nestingOptionsSeparator:r.nestingOptionsSeparator||",",this.maxReplaces=r.maxReplaces?r.maxReplaces:1e3,this.alwaysFormat=r.alwaysFormat!==void 0?r.alwaysFormat:!1,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var n="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=new RegExp(n,"g");var r="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=new RegExp(r,"g");var o="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=new RegExp(o,"g")}},{key:"interpolate",value:function(n,r,o,s){var i=this,a,d,c,u=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function p(g){return g.replace(/\$/g,"$$$$")}var l=function(y){if(y.indexOf(i.formatSeparator)<0){var v=Kb(r,u,y);return i.alwaysFormat?i.format(v,void 0,o):v}var S=y.split(i.formatSeparator),b=S.shift().trim(),I=S.join(i.formatSeparator).trim();return i.format(Kb(r,u,b),I,o,s)};this.resetRegExp();var f=s&&s.missingInterpolationHandler||this.options.missingInterpolationHandler,h=s&&s.interpolation&&s.interpolation.skipOnVariables||this.options.interpolation.skipOnVariables,m=[{regex:this.regexpUnescape,safeValue:function(y){return p(y)}},{regex:this.regexp,safeValue:function(y){return i.escapeValue?p(i.escape(y)):p(y)}}];return m.forEach(function(g){for(c=0;a=g.regex.exec(n);){if(d=l(a[1].trim()),d===void 0)if(typeof f=="function"){var y=f(n,a,s);d=typeof y=="string"?y:""}else if(h){d=a[0];continue}else i.logger.warn("missed to pass in variable ".concat(a[1]," for interpolating ").concat(n)),d="";else typeof d!="string"&&!i.useRawValueToEscape&&(d=Hb(d));if(n=n.replace(a[0],g.safeValue(d)),g.regex.lastIndex=0,c++,c>=i.maxReplaces)break}}),n}},{key:"nest",value:function(n,r){var o=this,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i,a,d=we({},s);d.applyPostProcessor=!1,delete d.defaultValue;function c(f,h){var m=this.nestingOptionsSeparator;if(f.indexOf(m)<0)return f;var g=f.split(new RegExp("".concat(m,"[ ]*{"))),y="{".concat(g[1]);f=g[0],y=this.interpolate(y,d),y=y.replace(/'/g,'"');try{d=JSON.parse(y),h&&(d=we({},h,d))}catch(v){return this.logger.warn("failed parsing options string in nesting for key ".concat(f),v),"".concat(f).concat(m).concat(y)}return delete d.defaultValue,f}for(;i=this.nestingRegexp.exec(n);){var u=[],p=!1;if(i[0].includes(this.formatSeparator)&&!/{.*}/.test(i[1])){var l=i[1].split(this.formatSeparator).map(function(f){return f.trim()});i[1]=l.shift(),u=l,p=!0}if(a=r(c.call(this,i[1].trim(),d),d),a&&i[0]===n&&typeof a!="string")return a;typeof a!="string"&&(a=Hb(a)),a||(this.logger.warn("missed to resolve ".concat(i[1]," for nesting ").concat(n)),a=""),p&&(a=u.reduce(function(f,h){return o.format(f,h,s.lng,s)},a.trim())),n=n.replace(i[0],a),this.regexp.lastIndex=0}return n}}]),e}();function $j(e,t){for(var n=e.indexOf(t);n!==-1;)e.splice(n,1),n=e.indexOf(t)}var Wj=function(e){Ci(t,e);function t(n,r,o){var s,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return Yt(this,t),s=qo(this,Br(t).call(this)),Ic&&Kn.call(In(s)),s.backend=n,s.store=r,s.services=o,s.languageUtils=o.languageUtils,s.options=i,s.logger=_n.create("backendConnector"),s.state={},s.queue=[],s.backend&&s.backend.init&&s.backend.init(o,i.backend,i),s}return Kt(t,[{key:"queueLoad",value:function(r,o,s,i){var a=this,d=[],c=[],u=[],p=[];return r.forEach(function(l){var f=!0;o.forEach(function(h){var m="".concat(l,"|").concat(h);!s.reload&&a.store.hasResourceBundle(l,h)?a.state[m]=2:a.state[m]<0||(a.state[m]===1?c.indexOf(m)<0&&c.push(m):(a.state[m]=1,f=!1,c.indexOf(m)<0&&c.push(m),d.indexOf(m)<0&&d.push(m),p.indexOf(h)<0&&p.push(h)))}),f||u.push(l)}),(d.length||c.length)&&this.queue.push({pending:c,loaded:{},errors:[],callback:i}),{toLoad:d,pending:c,toLoadLanguages:u,toLoadNamespaces:p}}},{key:"loaded",value:function(r,o,s){var i=r.split("|"),a=i[0],d=i[1];o&&this.emit("failedLoading",a,d,o),s&&this.store.addResourceBundle(a,d,s),this.state[r]=o?-1:2;var c={};this.queue.forEach(function(u){Uj(u.loaded,[a],d),$j(u.pending,r),o&&u.errors.push(o),u.pending.length===0&&!u.done&&(Object.keys(u.loaded).forEach(function(p){c[p]||(c[p]=[]),u.loaded[p].length&&u.loaded[p].forEach(function(l){c[p].indexOf(l)<0&&c[p].push(l)})}),u.done=!0,u.errors.length?u.callback(u.errors):u.callback())}),this.emit("loaded",c),this.queue=this.queue.filter(function(u){return!u.done})}},{key:"read",value:function(r,o,s){var i=this,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,d=arguments.length>4&&arguments[4]!==void 0?arguments[4]:350,c=arguments.length>5?arguments[5]:void 0;return r.length?this.backend[s](r,o,function(u,p){if(u&&p&&a<5){setTimeout(function(){i.read.call(i,r,o,s,a+1,d*2,c)},d);return}c(u,p)}):c(null,{})}},{key:"prepareLoading",value:function(r,o){var s=this,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),a&&a();typeof r=="string"&&(r=this.languageUtils.toResolveHierarchy(r)),typeof o=="string"&&(o=[o]);var d=this.queueLoad(r,o,i,a);if(!d.toLoad.length)return d.pending.length||a(),null;d.toLoad.forEach(function(c){s.loadOne(c)})}},{key:"load",value:function(r,o,s){this.prepareLoading(r,o,{},s)}},{key:"reload",value:function(r,o,s){this.prepareLoading(r,o,{reload:!0},s)}},{key:"loadOne",value:function(r){var o=this,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",i=r.split("|"),a=i[0],d=i[1];this.read(a,d,"read",void 0,void 0,function(c,u){c&&o.logger.warn("".concat(s,"loading namespace ").concat(d," for language ").concat(a," failed"),c),!c&&u&&o.logger.log("".concat(s,"loaded namespace ").concat(d," for language ").concat(a),u),o.loaded(r,c,u)})}},{key:"saveMissing",value:function(r,o,s,i,a){var d=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(o)){this.logger.warn('did not save key "'.concat(s,'" as the namespace "').concat(o,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}s==null||s===""||(this.backend&&this.backend.create&&this.backend.create(r,o,s,i,null,we({},d,{isUpdate:a})),!(!r||!r[0])&&this.store.addResource(r[0],o,s,i))}}]),t}(Kn);function Qj(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,whitelist:!1,nonExplicitWhitelist:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(t){var n={};if(Fe(t[1])==="object"&&(n=t[1]),typeof t[1]=="string"&&(n.defaultValue=t[1]),typeof t[2]=="string"&&(n.tDescription=t[2]),Fe(t[2])==="object"||Fe(t[3])==="object"){var r=t[3]||t[2];Object.keys(r).forEach(function(o){n[o]=r[o]})}return n},interpolation:{escapeValue:!0,format:function(t,n,r,o){return t},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!1}}}function Wb(e){return typeof e.ns=="string"&&(e.ns=[e.ns]),typeof e.fallbackLng=="string"&&(e.fallbackLng=[e.fallbackLng]),typeof e.fallbackNS=="string"&&(e.fallbackNS=[e.fallbackNS]),e.whitelist&&(e.whitelist&&e.whitelist.indexOf("cimode")<0&&(e.whitelist=e.whitelist.concat(["cimode"])),e.supportedLngs=e.whitelist),e.nonExplicitWhitelist&&(e.nonExplicitSupportedLngs=e.nonExplicitWhitelist),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e}function Sc(){}var Jj=function(e){Ci(t,e);function t(){var n,r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=arguments.length>1?arguments[1]:void 0;if(Yt(this,t),n=qo(this,Br(t).call(this)),Ic&&Kn.call(In(n)),n.options=Wb(r),n.services={},n.logger=_n,n.modules={external:[]},o&&!n.isInitialized&&!r.isClone){if(!n.options.initImmediate)return n.init(r,o),qo(n,In(n));setTimeout(function(){n.init(r,o)},0)}return n}return Kt(t,[{key:"init",value:function(){var r=this,o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0;typeof o=="function"&&(s=o,o={}),o.whitelist&&!o.supportedLngs&&this.logger.deprecate("whitelist",'option "whitelist" will be renamed to "supportedLngs" in the next major - please make sure to rename this option asap.'),o.nonExplicitWhitelist&&!o.nonExplicitSupportedLngs&&this.logger.deprecate("whitelist",'options "nonExplicitWhitelist" will be renamed to "nonExplicitSupportedLngs" in the next major - please make sure to rename this option asap.'),this.options=we({},Qj(),this.options,Wb(o)),this.format=this.options.interpolation.format,s||(s=Sc);function i(h){return h?typeof h=="function"?new h:h:null}if(!this.options.isClone){this.modules.logger?_n.init(i(this.modules.logger),this.options):_n.init(null,this.options);var a=new jj(this.options);this.store=new Fj(this.options.resources,this.options);var d=this.services;d.logger=_n,d.resourceStore=this.store,d.languageUtils=a,d.pluralResolver=new Kj(a,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),d.interpolator=new Xj(this.options),d.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},d.backendConnector=new Wj(i(this.modules.backend),d.resourceStore,d,this.options),d.backendConnector.on("*",function(h){for(var m=arguments.length,g=new Array(m>1?m-1:0),y=1;y<m;y++)g[y-1]=arguments[y];r.emit.apply(r,[h].concat(g))}),this.modules.languageDetector&&(d.languageDetector=i(this.modules.languageDetector),d.languageDetector.init(d,this.options.detection,this.options)),this.modules.i18nFormat&&(d.i18nFormat=i(this.modules.i18nFormat),d.i18nFormat.init&&d.i18nFormat.init(this)),this.translator=new $b(this.services,this.options),this.translator.on("*",function(h){for(var m=arguments.length,g=new Array(m>1?m-1:0),y=1;y<m;y++)g[y-1]=arguments[y];r.emit.apply(r,[h].concat(g))}),this.modules.external.forEach(function(h){h.init&&h.init(r)})}if(this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){var c=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);c.length>0&&c[0]!=="dev"&&(this.options.lng=c[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined");var u=["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"];u.forEach(function(h){r[h]=function(){var m;return(m=r.store)[h].apply(m,arguments)}});var p=["addResource","addResources","addResourceBundle","removeResourceBundle"];p.forEach(function(h){r[h]=function(){var m;return(m=r.store)[h].apply(m,arguments),r}});var l=Pi(),f=function(){var m=function(y,v){r.isInitialized&&r.logger.warn("init: i18next is already initialized. You should call init just once!"),r.isInitialized=!0,r.options.isClone||r.logger.log("initialized",r.options),r.emit("initialized",r.options),l.resolve(v),s(y,v)};if(r.languages&&r.options.compatibilityAPI!=="v1"&&!r.isInitialized)return m(null,r.t.bind(r));r.changeLanguage(r.options.lng,m)};return this.options.resources||!this.options.initImmediate?f():setTimeout(f,0),l}},{key:"loadResources",value:function(r){var o=this,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Sc,i=s,a=typeof r=="string"?r:this.language;if(typeof r=="function"&&(i=r),!this.options.resources||this.options.partialBundledLanguages){if(a&&a.toLowerCase()==="cimode")return i();var d=[],c=function(l){if(l){var f=o.services.languageUtils.toResolveHierarchy(l);f.forEach(function(h){d.indexOf(h)<0&&d.push(h)})}};if(a)c(a);else{var u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.forEach(function(p){return c(p)})}this.options.preload&&this.options.preload.forEach(function(p){return c(p)}),this.services.backendConnector.load(d,this.options.ns,i)}else i(null)}},{key:"reloadResources",value:function(r,o,s){var i=Pi();return r||(r=this.languages),o||(o=this.options.ns),s||(s=Sc),this.services.backendConnector.reload(r,o,function(a){i.resolve(),s(a)}),i}},{key:"use",value:function(r){if(!r)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!r.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return r.type==="backend"&&(this.modules.backend=r),(r.type==="logger"||r.log&&r.warn&&r.error)&&(this.modules.logger=r),r.type==="languageDetector"&&(this.modules.languageDetector=r),r.type==="i18nFormat"&&(this.modules.i18nFormat=r),r.type==="postProcessor"&&Jb.addPostProcessor(r),r.type==="3rdParty"&&this.modules.external.push(r),this}},{key:"changeLanguage",value:function(r,o){var s=this;this.isLanguageChangingTo=r;var i=Pi();this.emit("languageChanging",r);var a=function(u,p){p?(s.language=p,s.languages=s.services.languageUtils.toResolveHierarchy(p),s.translator.changeLanguage(p),s.isLanguageChangingTo=void 0,s.emit("languageChanged",p),s.logger.log("languageChanged",p)):s.isLanguageChangingTo=void 0,i.resolve(function(){return s.t.apply(s,arguments)}),o&&o(u,function(){return s.t.apply(s,arguments)})},d=function(u){var p=typeof u=="string"?u:s.services.languageUtils.getBestMatchFromCodes(u);p&&(s.language||(s.language=p,s.languages=s.services.languageUtils.toResolveHierarchy(p)),s.translator.language||s.translator.changeLanguage(p),s.services.languageDetector&&s.services.languageDetector.cacheUserLanguage(p)),s.loadResources(p,function(l){a(l,p)})};return!r&&this.services.languageDetector&&!this.services.languageDetector.async?d(this.services.languageDetector.detect()):!r&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect(d):d(r),i}},{key:"getFixedT",value:function(r,o){var s=this,i=function a(d,c){var u;if(Fe(c)!=="object"){for(var p=arguments.length,l=new Array(p>2?p-2:0),f=2;f<p;f++)l[f-2]=arguments[f];u=s.options.overloadTranslationOptionHandler([d,c].concat(l))}else u=we({},c);return u.lng=u.lng||a.lng,u.lngs=u.lngs||a.lngs,u.ns=u.ns||a.ns,s.t(d,u)};return typeof r=="string"?i.lng=r:i.lngs=r,i.ns=o,i}},{key:"t",value:function(){var r;return this.translator&&(r=this.translator).translate.apply(r,arguments)}},{key:"exists",value:function(){var r;return this.translator&&(r=this.translator).exists.apply(r,arguments)}},{key:"setDefaultNamespace",value:function(r){this.options.defaultNS=r}},{key:"hasLoadedNamespace",value:function(r){var o=this,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var i=this.languages[0],a=this.options?this.options.fallbackLng:!1,d=this.languages[this.languages.length-1];if(i.toLowerCase()==="cimode")return!0;var c=function(l,f){var h=o.services.backendConnector.state["".concat(l,"|").concat(f)];return h===-1||h===2};if(s.precheck){var u=s.precheck(this,c);if(u!==void 0)return u}return!!(this.hasResourceBundle(i,r)||!this.services.backendConnector.backend||c(i,r)&&(!a||c(d,r)))}},{key:"loadNamespaces",value:function(r,o){var s=this,i=Pi();return this.options.ns?(typeof r=="string"&&(r=[r]),r.forEach(function(a){s.options.ns.indexOf(a)<0&&s.options.ns.push(a)}),this.loadResources(function(a){i.resolve(),o&&o(a)}),i):(o&&o(),Promise.resolve())}},{key:"loadLanguages",value:function(r,o){var s=Pi();typeof r=="string"&&(r=[r]);var i=this.options.preload||[],a=r.filter(function(d){return i.indexOf(d)<0});return a.length?(this.options.preload=i.concat(a),this.loadResources(function(d){s.resolve(),o&&o(d)}),s):(o&&o(),Promise.resolve())}},{key:"dir",value:function(r){if(r||(r=this.languages&&this.languages.length>0?this.languages[0]:this.language),!r)return"rtl";var o=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam"];return o.indexOf(this.services.languageUtils.getLanguagePartFromCode(r))>=0?"rtl":"ltr"}},{key:"createInstance",value:function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=arguments.length>1?arguments[1]:void 0;return new t(r,o)}},{key:"cloneInstance",value:function(){var r=this,o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Sc,i=we({},this.options,o,{isClone:!0}),a=new t(i),d=["store","services","language"];return d.forEach(function(c){a[c]=r[c]}),a.services=we({},this.services),a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a.translator=new $b(a.services,a.options),a.translator.on("*",function(c){for(var u=arguments.length,p=new Array(u>1?u-1:0),l=1;l<u;l++)p[l-1]=arguments[l];a.emit.apply(a,[c].concat(p))}),a.init(i,s),a.translator.options=a.options,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}}]),t}(Kn),Zj=new Jj,Zb=Zj;var xI=ed(PI(),1),{__extends:xi,__assign:V,__rest:TI,__decorate:gCe,__param:yCe,__esDecorate:ACe,__runInitializers:vCe,__propKey:SCe,__setFunctionName:bCe,__metadata:ICe,__awaiter:_Ce,__generator:RCe,__exportStar:ECe,__createBinding:CCe,__values:PCe,__read:xCe,__spread:TCe,__spreadArrays:NCe,__spreadArray:Cc,__await:wCe,__asyncGenerator:OCe,__asyncDelegator:DCe,__asyncValues:kCe,__makeTemplateObject:MCe,__importStar:LCe,__importDefault:BCe,__classPrivateFieldGet:GCe,__classPrivateFieldSet:UCe,__classPrivateFieldIn:zCe,__addDisposableResource:qCe,__disposeResources:FCe}=xI.default;var U;(function(e){e[e.EXPECT_ARGUMENT_CLOSING_BRACE=1]="EXPECT_ARGUMENT_CLOSING_BRACE",e[e.EMPTY_ARGUMENT=2]="EMPTY_ARGUMENT",e[e.MALFORMED_ARGUMENT=3]="MALFORMED_ARGUMENT",e[e.EXPECT_ARGUMENT_TYPE=4]="EXPECT_ARGUMENT_TYPE",e[e.INVALID_ARGUMENT_TYPE=5]="INVALID_ARGUMENT_TYPE",e[e.EXPECT_ARGUMENT_STYLE=6]="EXPECT_ARGUMENT_STYLE",e[e.INVALID_NUMBER_SKELETON=7]="INVALID_NUMBER_SKELETON",e[e.INVALID_DATE_TIME_SKELETON=8]="INVALID_DATE_TIME_SKELETON",e[e.EXPECT_NUMBER_SKELETON=9]="EXPECT_NUMBER_SKELETON",e[e.EXPECT_DATE_TIME_SKELETON=10]="EXPECT_DATE_TIME_SKELETON",e[e.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE=11]="UNCLOSED_QUOTE_IN_ARGUMENT_STYLE",e[e.EXPECT_SELECT_ARGUMENT_OPTIONS=12]="EXPECT_SELECT_ARGUMENT_OPTIONS",e[e.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE=13]="EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE",e[e.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE=14]="INVALID_PLURAL_ARGUMENT_OFFSET_VALUE",e[e.EXPECT_SELECT_ARGUMENT_SELECTOR=15]="EXPECT_SELECT_ARGUMENT_SELECTOR",e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR=16]="EXPECT_PLURAL_ARGUMENT_SELECTOR",e[e.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT=17]="EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT",e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT=18]="EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT",e[e.INVALID_PLURAL_ARGUMENT_SELECTOR=19]="INVALID_PLURAL_ARGUMENT_SELECTOR",e[e.DUPLICATE_PLURAL_ARGUMENT_SELECTOR=20]="DUPLICATE_PLURAL_ARGUMENT_SELECTOR",e[e.DUPLICATE_SELECT_ARGUMENT_SELECTOR=21]="DUPLICATE_SELECT_ARGUMENT_SELECTOR",e[e.MISSING_OTHER_CLAUSE=22]="MISSING_OTHER_CLAUSE",e[e.INVALID_TAG=23]="INVALID_TAG",e[e.INVALID_TAG_NAME=25]="INVALID_TAG_NAME",e[e.UNMATCHED_CLOSING_TAG=26]="UNMATCHED_CLOSING_TAG",e[e.UNCLOSED_TAG=27]="UNCLOSED_TAG"})(U||(U={}));var ce;(function(e){e[e.literal=0]="literal",e[e.argument=1]="argument",e[e.number=2]="number",e[e.date=3]="date",e[e.time=4]="time",e[e.select=5]="select",e[e.plural=6]="plural",e[e.pound=7]="pound",e[e.tag=8]="tag"})(ce||(ce={}));var Gr;(function(e){e[e.number=0]="number",e[e.dateTime=1]="dateTime"})(Gr||(Gr={}));function Cf(e){return e.type===ce.literal}function NI(e){return e.type===ce.argument}function Pc(e){return e.type===ce.number}function xc(e){return e.type===ce.date}function Tc(e){return e.type===ce.time}function Nc(e){return e.type===ce.select}function wc(e){return e.type===ce.plural}function wI(e){return e.type===ce.pound}function Oc(e){return e.type===ce.tag}function Dc(e){return!!(e&&typeof e=="object"&&e.type===Gr.number)}function Ti(e){return!!(e&&typeof e=="object"&&e.type===Gr.dateTime)}var Pf=/[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/;var eV=/(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;function OI(e){var t={};return e.replace(eV,function(n){var r=n.length;switch(n[0]){case"G":t.era=r===4?"long":r===5?"narrow":"short";break;case"y":t.year=r===2?"2-digit":"numeric";break;case"Y":case"u":case"U":case"r":throw new RangeError("`Y/u/U/r` (year) patterns are not supported, use `y` instead");case"q":case"Q":throw new RangeError("`q/Q` (quarter) patterns are not supported");case"M":case"L":t.month=["numeric","2-digit","short","long","narrow"][r-1];break;case"w":case"W":throw new RangeError("`w/W` (week) patterns are not supported");case"d":t.day=["numeric","2-digit"][r-1];break;case"D":case"F":case"g":throw new RangeError("`D/F/g` (day) patterns are not supported, use `d` instead");case"E":t.weekday=r===4?"short":r===5?"narrow":"short";break;case"e":if(r<4)throw new RangeError("`e..eee` (weekday) patterns are not supported");t.weekday=["short","long","narrow","short"][r-4];break;case"c":if(r<4)throw new RangeError("`c..ccc` (weekday) patterns are not supported");t.weekday=["short","long","narrow","short"][r-4];break;case"a":t.hour12=!0;break;case"b":case"B":throw new RangeError("`b/B` (period) patterns are not supported, use `a` instead");case"h":t.hourCycle="h12",t.hour=["numeric","2-digit"][r-1];break;case"H":t.hourCycle="h23",t.hour=["numeric","2-digit"][r-1];break;case"K":t.hourCycle="h11",t.hour=["numeric","2-digit"][r-1];break;case"k":t.hourCycle="h24",t.hour=["numeric","2-digit"][r-1];break;case"j":case"J":case"C":throw new RangeError("`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead");case"m":t.minute=["numeric","2-digit"][r-1];break;case"s":t.second=["numeric","2-digit"][r-1];break;case"S":case"A":throw new RangeError("`S/A` (second) patterns are not supported, use `s` instead");case"z":t.timeZoneName=r<4?"short":"long";break;case"Z":case"O":case"v":case"V":case"X":case"x":throw new RangeError("`Z/O/v/V/X/x` (timeZone) patterns are not supported, use `z` instead")}return""}),t}var DI=/[\t-\r \x85\u200E\u200F\u2028\u2029]/i;function BI(e){if(e.length===0)throw new Error("Number skeleton cannot be empty");for(var t=e.split(DI).filter(function(l){return l.length>0}),n=[],r=0,o=t;r<o.length;r++){var s=o[r],i=s.split("/");if(i.length===0)throw new Error("Invalid number skeleton");for(var a=i[0],d=i.slice(1),c=0,u=d;c<u.length;c++){var p=u[c];if(p.length===0)throw new Error("Invalid number skeleton")}n.push({stem:a,options:d})}return n}function tV(e){return e.replace(/^(.*?)-/,"")}var kI=/^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g,GI=/^(@+)?(\+|#+)?[rs]?$/g,nV=/(\*)(0+)|(#+)(0+)|(0+)/g,UI=/^(0+)$/;function MI(e){var t={};return e[e.length-1]==="r"?t.roundingPriority="morePrecision":e[e.length-1]==="s"&&(t.roundingPriority="lessPrecision"),e.replace(GI,function(n,r,o){return typeof o!="string"?(t.minimumSignificantDigits=r.length,t.maximumSignificantDigits=r.length):o==="+"?t.minimumSignificantDigits=r.length:r[0]==="#"?t.maximumSignificantDigits=r.length:(t.minimumSignificantDigits=r.length,t.maximumSignificantDigits=r.length+(typeof o=="string"?o.length:0)),""}),t}function zI(e){switch(e){case"sign-auto":return{signDisplay:"auto"};case"sign-accounting":case"()":return{currencySign:"accounting"};case"sign-always":case"+!":return{signDisplay:"always"};case"sign-accounting-always":case"()!":return{signDisplay:"always",currencySign:"accounting"};case"sign-except-zero":case"+?":return{signDisplay:"exceptZero"};case"sign-accounting-except-zero":case"()?":return{signDisplay:"exceptZero",currencySign:"accounting"};case"sign-never":case"+_":return{signDisplay:"never"}}}function rV(e){var t;if(e[0]==="E"&&e[1]==="E"?(t={notation:"engineering"},e=e.slice(2)):e[0]==="E"&&(t={notation:"scientific"},e=e.slice(1)),t){var n=e.slice(0,2);if(n==="+!"?(t.signDisplay="always",e=e.slice(2)):n==="+?"&&(t.signDisplay="exceptZero",e=e.slice(2)),!UI.test(e))throw new Error("Malformed concise eng/scientific notation");t.minimumIntegerDigits=e.length}return t}function LI(e){var t={},n=zI(e);return n||t}function qI(e){for(var t={},n=0,r=e;n<r.length;n++){var o=r[n];switch(o.stem){case"percent":case"%":t.style="percent";continue;case"%x100":t.style="percent",t.scale=100;continue;case"currency":t.style="currency",t.currency=o.options[0];continue;case"group-off":case",_":t.useGrouping=!1;continue;case"precision-integer":case".":t.maximumFractionDigits=0;continue;case"measure-unit":case"unit":t.style="unit",t.unit=tV(o.options[0]);continue;case"compact-short":case"K":t.notation="compact",t.compactDisplay="short";continue;case"compact-long":case"KK":t.notation="compact",t.compactDisplay="long";continue;case"scientific":t=V(V(V({},t),{notation:"scientific"}),o.options.reduce(function(d,c){return V(V({},d),LI(c))},{}));continue;case"engineering":t=V(V(V({},t),{notation:"engineering"}),o.options.reduce(function(d,c){return V(V({},d),LI(c))},{}));continue;case"notation-simple":t.notation="standard";continue;case"unit-width-narrow":t.currencyDisplay="narrowSymbol",t.unitDisplay="narrow";continue;case"unit-width-short":t.currencyDisplay="code",t.unitDisplay="short";continue;case"unit-width-full-name":t.currencyDisplay="name",t.unitDisplay="long";continue;case"unit-width-iso-code":t.currencyDisplay="symbol";continue;case"scale":t.scale=parseFloat(o.options[0]);continue;case"integer-width":if(o.options.length>1)throw new RangeError("integer-width stems only accept a single optional option");o.options[0].replace(nV,function(d,c,u,p,l,f){if(c)t.minimumIntegerDigits=u.length;else{if(p&&l)throw new Error("We currently do not support maximum integer digits");if(f)throw new Error("We currently do not support exact integer digits")}return""});continue}if(UI.test(o.stem)){t.minimumIntegerDigits=o.stem.length;continue}if(kI.test(o.stem)){if(o.options.length>1)throw new RangeError("Fraction-precision stems only accept a single optional option");o.stem.replace(kI,function(d,c,u,p,l,f){return u==="*"?t.minimumFractionDigits=c.length:p&&p[0]==="#"?t.maximumFractionDigits=p.length:l&&f?(t.minimumFractionDigits=l.length,t.maximumFractionDigits=l.length+f.length):(t.minimumFractionDigits=c.length,t.maximumFractionDigits=c.length),""});var s=o.options[0];s==="w"?t=V(V({},t),{trailingZeroDisplay:"stripIfInteger"}):s&&(t=V(V({},t),MI(s)));continue}if(GI.test(o.stem)){t=V(V({},t),MI(o.stem));continue}var i=zI(o.stem);i&&(t=V(V({},t),i));var a=rV(o.stem);a&&(t=V(V({},t),a))}return t}var Ni={"001":["H","h"],AC:["H","h","hb","hB"],AD:["H","hB"],AE:["h","hB","hb","H"],AF:["H","hb","hB","h"],AG:["h","hb","H","hB"],AI:["H","h","hb","hB"],AL:["h","H","hB"],AM:["H","hB"],AO:["H","hB"],AR:["H","h","hB","hb"],AS:["h","H"],AT:["H","hB"],AU:["h","hb","H","hB"],AW:["H","hB"],AX:["H"],AZ:["H","hB","h"],BA:["H","hB","h"],BB:["h","hb","H","hB"],BD:["h","hB","H"],BE:["H","hB"],BF:["H","hB"],BG:["H","hB","h"],BH:["h","hB","hb","H"],BJ:["H","hB"],BL:["H","hB"],BM:["h","hb","H","hB"],BN:["hb","hB","h","H"],BO:["H","hB","h","hb"],BQ:["H"],BR:["H","hB"],BS:["h","hb","H","hB"],BT:["h","H"],BW:["H","h","hb","hB"],BZ:["H","h","hb","hB"],CA:["h","hb","H","hB"],CC:["H","h","hb","hB"],CD:["hB","H"],CF:["H","h","hB"],CG:["H","hB"],CH:["H","hB","h"],CI:["H","hB"],CK:["H","h","hb","hB"],CL:["H","h","hB","hb"],CM:["H","h","hB"],CN:["H","hB","hb","h"],CO:["h","H","hB","hb"],CP:["H"],CR:["H","h","hB","hb"],CU:["H","h","hB","hb"],CV:["H","hB"],CX:["H","h","hb","hB"],CY:["h","H","hb","hB"],CZ:["H"],DE:["H","hB"],DG:["H","h","hb","hB"],DJ:["h","H"],DK:["H"],DM:["h","hb","H","hB"],DO:["h","H","hB","hb"],DZ:["h","hB","hb","H"],EA:["H","h","hB","hb"],EC:["H","hB","h","hb"],EE:["H","hB"],EG:["h","hB","hb","H"],EH:["h","hB","hb","H"],ER:["h","H"],ES:["H","hB","h","hb"],ET:["hB","hb","h","H"],FI:["H"],FJ:["h","hb","H","hB"],FK:["H","h","hb","hB"],FM:["h","hb","H","hB"],FR:["H","hB"],GA:["H","hB"],GB:["H","h","hb","hB"],GD:["h","hb","H","hB"],GE:["H","hB","h"],GF:["H","hB"],GG:["H","h","hb","hB"],GH:["h","H"],GI:["H","h","hb","hB"],GM:["h","hb","H","hB"],GN:["H","hB"],GP:["H","hB"],GQ:["H","hB","h","hb"],GR:["h","H","hb","hB"],GT:["H","h","hB","hb"],GU:["h","hb","H","hB"],GW:["H","hB"],GY:["h","hb","H","hB"],HK:["h","hB","hb","H"],HN:["H","h","hB","hb"],HR:["H","hB"],IC:["H","h","hB","hb"],ID:["H"],IE:["H","h","hb","hB"],IL:["H","hB"],IM:["H","h","hb","hB"],IN:["h","H"],IO:["H","h","hb","hB"],IQ:["h","hB","hb","H"],IR:["hB","H"],IS:["H"],IT:["H","hB"],JE:["H","h","hb","hB"],JM:["h","hb","H","hB"],JO:["h","hB","hb","H"],JP:["H","h","K"],KE:["hB","hb","H","h"],KG:["H","h","hB","hb"],KH:["hB","h","H","hb"],KI:["h","hb","H","hB"],KM:["H","h","hB","hb"],KN:["h","hb","H","hB"],KP:["h","H","hB","hb"],KR:["h","H","hB","hb"],KW:["h","hB","hb","H"],KY:["h","hb","H","hB"],KZ:["H","hB"],LA:["H","hb","hB","h"],LB:["h","hB","hb","H"],LC:["h","hb","H","hB"],LI:["H","hB","h"],LK:["H","h","hB","hb"],LR:["h","hb","H","hB"],LS:["h","H"],LT:["H","h","hb","hB"],LU:["H","h","hB"],LV:["H","hB","hb","h"],LY:["h","hB","hb","H"],MA:["H","h","hB","hb"],MC:["H","hB"],MD:["H","hB"],ME:["H","hB","h"],MF:["H","hB"],MH:["h","hb","H","hB"],MK:["H","h","hb","hB"],ML:["H"],MM:["hB","hb","H","h"],MN:["H","h","hb","hB"],MO:["h","hB","hb","H"],MP:["h","hb","H","hB"],MQ:["H","hB"],MR:["h","hB","hb","H"],MS:["H","h","hb","hB"],MW:["h","hb","H","hB"],MX:["H","h","hB","hb"],MY:["hb","hB","h","H"],MZ:["H","hB"],NA:["h","H","hB","hb"],NC:["H","hB"],NE:["H"],NF:["H","h","hb","hB"],NG:["H","h","hb","hB"],NI:["H","h","hB","hb"],NL:["H","hB"],NP:["H","h","hB"],NR:["H","h","hb","hB"],NU:["H","h","hb","hB"],NZ:["h","hb","H","hB"],OM:["h","hB","hb","H"],PA:["h","H","hB","hb"],PE:["H","hB","h","hb"],PF:["H","h","hB"],PG:["h","H"],PH:["h","hB","hb","H"],PK:["h","hB","H"],PM:["H","hB"],PN:["H","h","hb","hB"],PR:["h","H","hB","hb"],PS:["h","hB","hb","H"],PT:["H","hB"],PW:["h","H"],PY:["H","h","hB","hb"],QA:["h","hB","hb","H"],RE:["H","hB"],RO:["H","hB"],RS:["H","hB","h"],RU:["H"],SA:["h","hB","hb","H"],SB:["h","hb","H","hB"],SC:["H","h","hB"],SD:["h","hB","hb","H"],SE:["H"],SG:["h","hb","H","hB"],SH:["H","h","hb","hB"],SI:["H","hB"],SJ:["H"],SK:["H"],SL:["h","hb","H","hB"],SM:["H","h","hB"],SN:["H","h","hB"],SO:["h","H"],SR:["H","hB"],SS:["h","hb","H","hB"],ST:["H","hB"],SV:["H","h","hB","hb"],SX:["H","h","hb","hB"],SY:["h","hB","hb","H"],SZ:["h","hb","H","hB"],TA:["H","h","hb","hB"],TC:["h","hb","H","hB"],TD:["h","H","hB"],TF:["H","h","hB"],TG:["H","hB"],TL:["H","hB","hb","h"],TN:["h","hB","hb","H"],TO:["h","H"],TR:["H","hB"],TT:["h","hb","H","hB"],TW:["hB","hb","h","H"],TZ:["hB","hb","H","h"],UA:["H","hB","h"],UG:["hB","hb","H","h"],UM:["h","hb","H","hB"],US:["h","hb","H","hB"],UY:["H","h","hB","hb"],UZ:["H","hB","h"],VA:["H","h","hB"],VC:["h","hb","H","hB"],VE:["h","H","hB","hb"],VG:["h","hb","H","hB"],VI:["h","hb","H","hB"],VU:["h","H"],WF:["H","hB"],WS:["h","H"],XK:["H","hB","h"],YE:["h","hB","hb","H"],YT:["H","hB"],ZA:["H","h","hb","hB"],ZM:["h","hb","H","hB"],"af-ZA":["H","h","hB","hb"],"ar-001":["h","hB","hb","H"],"ca-ES":["H","h","hB"],"en-001":["h","hb","H","hB"],"es-BO":["H","h","hB","hb"],"es-BR":["H","h","hB","hb"],"es-EC":["H","h","hB","hb"],"es-ES":["H","h","hB","hb"],"es-GQ":["H","h","hB","hb"],"es-PE":["H","h","hB","hb"],"fr-CA":["H","h","hB"],"gl-ES":["H","h","hB"],"gu-IN":["hB","hb","h","H"],"hi-IN":["hB","h","H"],"it-CH":["H","h","hB"],"it-IT":["H","h","hB"],"kn-IN":["hB","h","H"],"ml-IN":["hB","h","H"],"mr-IN":["hB","hb","h","H"],"pa-IN":["hB","hb","h","H"],"ta-IN":["hB","h","hb","H"],"te-IN":["hB","h","H"],"zu-ZA":["H","hB","hb","h"]};function FI(e,t){for(var n="",r=0;r<e.length;r++){var o=e.charAt(r);if(o==="j"){for(var s=0;r+1<e.length&&e.charAt(r+1)===o;)s++,r++;var i=1+(s&1),a=s<2?1:3+(s>>1),d="a",c=oV(t);for((c=="H"||c=="k")&&(a=0);a-- >0;)n+=d;for(;i-- >0;)n=c+n}else o==="J"?n+="H":n+=o}return n}function oV(e){var t=e.hourCycle;if(t===void 0&&e.hourCycles&&e.hourCycles.length&&(t=e.hourCycles[0]),t)switch(t){case"h24":return"k";case"h23":return"H";case"h12":return"h";case"h11":return"K";default:throw new Error("Invalid hourCycle")}var n=e.language,r;n!=="root"&&(r=e.maximize().region);var o=Ni[r||""]||Ni[n||""]||Ni["".concat(n,"-001")]||Ni["001"];return o[0]}var xf,sV=new RegExp("^".concat(Pf.source,"*")),iV=new RegExp("".concat(Pf.source,"*$"));function H(e,t){return{start:e,end:t}}var aV=!!String.prototype.startsWith&&"_a".startsWith("a",1),dV=!!String.fromCodePoint,cV=!!Object.fromEntries,uV=!!String.prototype.codePointAt,pV=!!String.prototype.trimStart,lV=!!String.prototype.trimEnd,fV=!!Number.isSafeInteger,mV=fV?Number.isSafeInteger:function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e&&Math.abs(e)<=9007199254740991},Nf=!0;try{jI=KI("([^\\p{White_Space}\\p{Pattern_Syntax}]*)","yu"),Nf=((xf=jI.exec("a"))===null||xf===void 0?void 0:xf[0])==="a"}catch{Nf=!1}var jI,VI=aV?function(t,n,r){return t.startsWith(n,r)}:function(t,n,r){return t.slice(r,r+n.length)===n},wf=dV?String.fromCodePoint:function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];for(var r="",o=t.length,s=0,i;o>s;){if(i=t[s++],i>1114111)throw RangeError(i+" is not a valid code point");r+=i<65536?String.fromCharCode(i):String.fromCharCode(((i-=65536)>>10)+55296,i%1024+56320)}return r},HI=cV?Object.fromEntries:function(t){for(var n={},r=0,o=t;r<o.length;r++){var s=o[r],i=s[0],a=s[1];n[i]=a}return n},YI=uV?function(t,n){return t.codePointAt(n)}:function(t,n){var r=t.length;if(!(n<0||n>=r)){var o=t.charCodeAt(n),s;return o<55296||o>56319||n+1===r||(s=t.charCodeAt(n+1))<56320||s>57343?o:(o-55296<<10)+(s-56320)+65536}},hV=pV?function(t){return t.trimStart()}:function(t){return t.replace(sV,"")},gV=lV?function(t){return t.trimEnd()}:function(t){return t.replace(iV,"")};function KI(e,t){return new RegExp(e,t)}var Of;Nf?(Tf=KI("([^\\p{White_Space}\\p{Pattern_Syntax}]*)","yu"),Of=function(t,n){var r;Tf.lastIndex=n;var o=Tf.exec(t);return(r=o[1])!==null&&r!==void 0?r:""}):Of=function(t,n){for(var r=[];;){var o=YI(t,n);if(o===void 0||$I(o)||vV(o))break;r.push(o),n+=o>=65536?2:1}return wf.apply(void 0,r)};var Tf,XI=function(){function e(t,n){n===void 0&&(n={}),this.message=t,this.position={offset:0,line:1,column:1},this.ignoreTag=!!n.ignoreTag,this.locale=n.locale,this.requiresOtherClause=!!n.requiresOtherClause,this.shouldParseSkeletons=!!n.shouldParseSkeletons}return e.prototype.parse=function(){if(this.offset()!==0)throw Error("parser can only be used once");return this.parseMessage(0,"",!1)},e.prototype.parseMessage=function(t,n,r){for(var o=[];!this.isEOF();){var s=this.char();if(s===123){var i=this.parseArgument(t,r);if(i.err)return i;o.push(i.val)}else{if(s===125&&t>0)break;if(s===35&&(n==="plural"||n==="selectordinal")){var a=this.clonePosition();this.bump(),o.push({type:ce.pound,location:H(a,this.clonePosition())})}else if(s===60&&!this.ignoreTag&&this.peek()===47){if(r)break;return this.error(U.UNMATCHED_CLOSING_TAG,H(this.clonePosition(),this.clonePosition()))}else if(s===60&&!this.ignoreTag&&Df(this.peek()||0)){var i=this.parseTag(t,n);if(i.err)return i;o.push(i.val)}else{var i=this.parseLiteral(t,n);if(i.err)return i;o.push(i.val)}}}return{val:o,err:null}},e.prototype.parseTag=function(t,n){var r=this.clonePosition();this.bump();var o=this.parseTagName();if(this.bumpSpace(),this.bumpIf("/>"))return{val:{type:ce.literal,value:"<".concat(o,"/>"),location:H(r,this.clonePosition())},err:null};if(this.bumpIf(">")){var s=this.parseMessage(t+1,n,!0);if(s.err)return s;var i=s.val,a=this.clonePosition();if(this.bumpIf("</")){if(this.isEOF()||!Df(this.char()))return this.error(U.INVALID_TAG,H(a,this.clonePosition()));var d=this.clonePosition(),c=this.parseTagName();return o!==c?this.error(U.UNMATCHED_CLOSING_TAG,H(d,this.clonePosition())):(this.bumpSpace(),this.bumpIf(">")?{val:{type:ce.tag,value:o,children:i,location:H(r,this.clonePosition())},err:null}:this.error(U.INVALID_TAG,H(a,this.clonePosition())))}else return this.error(U.UNCLOSED_TAG,H(r,this.clonePosition()))}else return this.error(U.INVALID_TAG,H(r,this.clonePosition()))},e.prototype.parseTagName=function(){var t=this.offset();for(this.bump();!this.isEOF()&&AV(this.char());)this.bump();return this.message.slice(t,this.offset())},e.prototype.parseLiteral=function(t,n){for(var r=this.clonePosition(),o="";;){var s=this.tryParseQuote(n);if(s){o+=s;continue}var i=this.tryParseUnquoted(t,n);if(i){o+=i;continue}var a=this.tryParseLeftAngleBracket();if(a){o+=a;continue}break}var d=H(r,this.clonePosition());return{val:{type:ce.literal,value:o,location:d},err:null}},e.prototype.tryParseLeftAngleBracket=function(){return!this.isEOF()&&this.char()===60&&(this.ignoreTag||!yV(this.peek()||0))?(this.bump(),"<"):null},e.prototype.tryParseQuote=function(t){if(this.isEOF()||this.char()!==39)return null;switch(this.peek()){case 39:return this.bump(),this.bump(),"'";case 123:case 60:case 62:case 125:break;case 35:if(t==="plural"||t==="selectordinal")break;return null;default:return null}this.bump();var n=[this.char()];for(this.bump();!this.isEOF();){var r=this.char();if(r===39)if(this.peek()===39)n.push(39),this.bump();else{this.bump();break}else n.push(r);this.bump()}return wf.apply(void 0,n)},e.prototype.tryParseUnquoted=function(t,n){if(this.isEOF())return null;var r=this.char();return r===60||r===123||r===35&&(n==="plural"||n==="selectordinal")||r===125&&t>0?null:(this.bump(),wf(r))},e.prototype.parseArgument=function(t,n){var r=this.clonePosition();if(this.bump(),this.bumpSpace(),this.isEOF())return this.error(U.EXPECT_ARGUMENT_CLOSING_BRACE,H(r,this.clonePosition()));if(this.char()===125)return this.bump(),this.error(U.EMPTY_ARGUMENT,H(r,this.clonePosition()));var o=this.parseIdentifierIfPossible().value;if(!o)return this.error(U.MALFORMED_ARGUMENT,H(r,this.clonePosition()));if(this.bumpSpace(),this.isEOF())return this.error(U.EXPECT_ARGUMENT_CLOSING_BRACE,H(r,this.clonePosition()));switch(this.char()){case 125:return this.bump(),{val:{type:ce.argument,value:o,location:H(r,this.clonePosition())},err:null};case 44:return this.bump(),this.bumpSpace(),this.isEOF()?this.error(U.EXPECT_ARGUMENT_CLOSING_BRACE,H(r,this.clonePosition())):this.parseArgumentOptions(t,n,o,r);default:return this.error(U.MALFORMED_ARGUMENT,H(r,this.clonePosition()))}},e.prototype.parseIdentifierIfPossible=function(){var t=this.clonePosition(),n=this.offset(),r=Of(this.message,n),o=n+r.length;this.bumpTo(o);var s=this.clonePosition(),i=H(t,s);return{value:r,location:i}},e.prototype.parseArgumentOptions=function(t,n,r,o){var s,i=this.clonePosition(),a=this.parseIdentifierIfPossible().value,d=this.clonePosition();switch(a){case"":return this.error(U.EXPECT_ARGUMENT_TYPE,H(i,d));case"number":case"date":case"time":{this.bumpSpace();var c=null;if(this.bumpIf(",")){this.bumpSpace();var u=this.clonePosition(),p=this.parseSimpleArgStyleIfPossible();if(p.err)return p;var l=gV(p.val);if(l.length===0)return this.error(U.EXPECT_ARGUMENT_STYLE,H(this.clonePosition(),this.clonePosition()));var f=H(u,this.clonePosition());c={style:l,styleLocation:f}}var h=this.tryParseArgumentClose(o);if(h.err)return h;var m=H(o,this.clonePosition());if(c&&VI(c==null?void 0:c.style,"::",0)){var g=hV(c.style.slice(2));if(a==="number"){var p=this.parseNumberSkeletonFromString(g,c.styleLocation);return p.err?p:{val:{type:ce.number,value:r,location:m,style:p.val},err:null}}else{if(g.length===0)return this.error(U.EXPECT_DATE_TIME_SKELETON,m);var y=g;this.locale&&(y=FI(g,this.locale));var l={type:Gr.dateTime,pattern:y,location:c.styleLocation,parsedOptions:this.shouldParseSkeletons?OI(y):{}},v=a==="date"?ce.date:ce.time;return{val:{type:v,value:r,location:m,style:l},err:null}}}return{val:{type:a==="number"?ce.number:a==="date"?ce.date:ce.time,value:r,location:m,style:(s=c==null?void 0:c.style)!==null&&s!==void 0?s:null},err:null}}case"plural":case"selectordinal":case"select":{var S=this.clonePosition();if(this.bumpSpace(),!this.bumpIf(","))return this.error(U.EXPECT_SELECT_ARGUMENT_OPTIONS,H(S,V({},S)));this.bumpSpace();var b=this.parseIdentifierIfPossible(),I=0;if(a!=="select"&&b.value==="offset"){if(!this.bumpIf(":"))return this.error(U.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE,H(this.clonePosition(),this.clonePosition()));this.bumpSpace();var p=this.tryParseDecimalInteger(U.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE,U.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);if(p.err)return p;this.bumpSpace(),b=this.parseIdentifierIfPossible(),I=p.val}var N=this.tryParsePluralOrSelectOptions(t,a,n,b);if(N.err)return N;var h=this.tryParseArgumentClose(o);if(h.err)return h;var w=H(o,this.clonePosition());return a==="select"?{val:{type:ce.select,value:r,options:HI(N.val),location:w},err:null}:{val:{type:ce.plural,value:r,options:HI(N.val),offset:I,pluralType:a==="plural"?"cardinal":"ordinal",location:w},err:null}}default:return this.error(U.INVALID_ARGUMENT_TYPE,H(i,d))}},e.prototype.tryParseArgumentClose=function(t){return this.isEOF()||this.char()!==125?this.error(U.EXPECT_ARGUMENT_CLOSING_BRACE,H(t,this.clonePosition())):(this.bump(),{val:!0,err:null})},e.prototype.parseSimpleArgStyleIfPossible=function(){for(var t=0,n=this.clonePosition();!this.isEOF();){var r=this.char();switch(r){case 39:{this.bump();var o=this.clonePosition();if(!this.bumpUntil("'"))return this.error(U.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE,H(o,this.clonePosition()));this.bump();break}case 123:{t+=1,this.bump();break}case 125:{if(t>0)t-=1;else return{val:this.message.slice(n.offset,this.offset()),err:null};break}default:this.bump();break}}return{val:this.message.slice(n.offset,this.offset()),err:null}},e.prototype.parseNumberSkeletonFromString=function(t,n){var r=[];try{r=BI(t)}catch{return this.error(U.INVALID_NUMBER_SKELETON,n)}return{val:{type:Gr.number,tokens:r,location:n,parsedOptions:this.shouldParseSkeletons?qI(r):{}},err:null}},e.prototype.tryParsePluralOrSelectOptions=function(t,n,r,o){for(var s,i=!1,a=[],d=new Set,c=o.value,u=o.location;;){if(c.length===0){var p=this.clonePosition();if(n!=="select"&&this.bumpIf("=")){var l=this.tryParseDecimalInteger(U.EXPECT_PLURAL_ARGUMENT_SELECTOR,U.INVALID_PLURAL_ARGUMENT_SELECTOR);if(l.err)return l;u=H(p,this.clonePosition()),c=this.message.slice(p.offset,this.offset())}else break}if(d.has(c))return this.error(n==="select"?U.DUPLICATE_SELECT_ARGUMENT_SELECTOR:U.DUPLICATE_PLURAL_ARGUMENT_SELECTOR,u);c==="other"&&(i=!0),this.bumpSpace();var f=this.clonePosition();if(!this.bumpIf("{"))return this.error(n==="select"?U.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT:U.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT,H(this.clonePosition(),this.clonePosition()));var h=this.parseMessage(t+1,n,r);if(h.err)return h;var m=this.tryParseArgumentClose(f);if(m.err)return m;a.push([c,{value:h.val,location:H(f,this.clonePosition())}]),d.add(c),this.bumpSpace(),s=this.parseIdentifierIfPossible(),c=s.value,u=s.location}return a.length===0?this.error(n==="select"?U.EXPECT_SELECT_ARGUMENT_SELECTOR:U.EXPECT_PLURAL_ARGUMENT_SELECTOR,H(this.clonePosition(),this.clonePosition())):this.requiresOtherClause&&!i?this.error(U.MISSING_OTHER_CLAUSE,H(this.clonePosition(),this.clonePosition())):{val:a,err:null}},e.prototype.tryParseDecimalInteger=function(t,n){var r=1,o=this.clonePosition();this.bumpIf("+")||this.bumpIf("-")&&(r=-1);for(var s=!1,i=0;!this.isEOF();){var a=this.char();if(a>=48&&a<=57)s=!0,i=i*10+(a-48),this.bump();else break}var d=H(o,this.clonePosition());return s?(i*=r,mV(i)?{val:i,err:null}:this.error(n,d)):this.error(t,d)},e.prototype.offset=function(){return this.position.offset},e.prototype.isEOF=function(){return this.offset()===this.message.length},e.prototype.clonePosition=function(){return{offset:this.position.offset,line:this.position.line,column:this.position.column}},e.prototype.char=function(){var t=this.position.offset;if(t>=this.message.length)throw Error("out of bound");var n=YI(this.message,t);if(n===void 0)throw Error("Offset ".concat(t," is at invalid UTF-16 code unit boundary"));return n},e.prototype.error=function(t,n){return{val:null,err:{kind:t,message:this.message,location:n}}},e.prototype.bump=function(){if(!this.isEOF()){var t=this.char();t===10?(this.position.line+=1,this.position.column=1,this.position.offset+=1):(this.position.column+=1,this.position.offset+=t<65536?1:2)}},e.prototype.bumpIf=function(t){if(VI(this.message,t,this.offset())){for(var n=0;n<t.length;n++)this.bump();return!0}return!1},e.prototype.bumpUntil=function(t){var n=this.offset(),r=this.message.indexOf(t,n);return r>=0?(this.bumpTo(r),!0):(this.bumpTo(this.message.length),!1)},e.prototype.bumpTo=function(t){if(this.offset()>t)throw Error("targetOffset ".concat(t," must be greater than or equal to the current offset ").concat(this.offset()));for(t=Math.min(t,this.message.length);;){var n=this.offset();if(n===t)break;if(n>t)throw Error("targetOffset ".concat(t," is at invalid UTF-16 code unit boundary"));if(this.bump(),this.isEOF())break}},e.prototype.bumpSpace=function(){for(;!this.isEOF()&&$I(this.char());)this.bump()},e.prototype.peek=function(){if(this.isEOF())return null;var t=this.char(),n=this.offset(),r=this.message.charCodeAt(n+(t>=65536?2:1));return r??null},e}();function Df(e){return e>=97&&e<=122||e>=65&&e<=90}function yV(e){return Df(e)||e===47}function AV(e){return e===45||e===46||e>=48&&e<=57||e===95||e>=97&&e<=122||e>=65&&e<=90||e==183||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=893||e>=895&&e<=8191||e>=8204&&e<=8205||e>=8255&&e<=8256||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}function $I(e){return e>=9&&e<=13||e===32||e===133||e>=8206&&e<=8207||e===8232||e===8233}function vV(e){return e>=33&&e<=35||e===36||e>=37&&e<=39||e===40||e===41||e===42||e===43||e===44||e===45||e>=46&&e<=47||e>=58&&e<=59||e>=60&&e<=62||e>=63&&e<=64||e===91||e===92||e===93||e===94||e===96||e===123||e===124||e===125||e===126||e===161||e>=162&&e<=165||e===166||e===167||e===169||e===171||e===172||e===174||e===176||e===177||e===182||e===187||e===191||e===215||e===247||e>=8208&&e<=8213||e>=8214&&e<=8215||e===8216||e===8217||e===8218||e>=8219&&e<=8220||e===8221||e===8222||e===8223||e>=8224&&e<=8231||e>=8240&&e<=8248||e===8249||e===8250||e>=8251&&e<=8254||e>=8257&&e<=8259||e===8260||e===8261||e===8262||e>=8263&&e<=8273||e===8274||e===8275||e>=8277&&e<=8286||e>=8592&&e<=8596||e>=8597&&e<=8601||e>=8602&&e<=8603||e>=8604&&e<=8607||e===8608||e>=8609&&e<=8610||e===8611||e>=8612&&e<=8613||e===8614||e>=8615&&e<=8621||e===8622||e>=8623&&e<=8653||e>=8654&&e<=8655||e>=8656&&e<=8657||e===8658||e===8659||e===8660||e>=8661&&e<=8691||e>=8692&&e<=8959||e>=8960&&e<=8967||e===8968||e===8969||e===8970||e===8971||e>=8972&&e<=8991||e>=8992&&e<=8993||e>=8994&&e<=9e3||e===9001||e===9002||e>=9003&&e<=9083||e===9084||e>=9085&&e<=9114||e>=9115&&e<=9139||e>=9140&&e<=9179||e>=9180&&e<=9185||e>=9186&&e<=9254||e>=9255&&e<=9279||e>=9280&&e<=9290||e>=9291&&e<=9311||e>=9472&&e<=9654||e===9655||e>=9656&&e<=9664||e===9665||e>=9666&&e<=9719||e>=9720&&e<=9727||e>=9728&&e<=9838||e===9839||e>=9840&&e<=10087||e===10088||e===10089||e===10090||e===10091||e===10092||e===10093||e===10094||e===10095||e===10096||e===10097||e===10098||e===10099||e===10100||e===10101||e>=10132&&e<=10175||e>=10176&&e<=10180||e===10181||e===10182||e>=10183&&e<=10213||e===10214||e===10215||e===10216||e===10217||e===10218||e===10219||e===10220||e===10221||e===10222||e===10223||e>=10224&&e<=10239||e>=10240&&e<=10495||e>=10496&&e<=10626||e===10627||e===10628||e===10629||e===10630||e===10631||e===10632||e===10633||e===10634||e===10635||e===10636||e===10637||e===10638||e===10639||e===10640||e===10641||e===10642||e===10643||e===10644||e===10645||e===10646||e===10647||e===10648||e>=10649&&e<=10711||e===10712||e===10713||e===10714||e===10715||e>=10716&&e<=10747||e===10748||e===10749||e>=10750&&e<=11007||e>=11008&&e<=11055||e>=11056&&e<=11076||e>=11077&&e<=11078||e>=11079&&e<=11084||e>=11085&&e<=11123||e>=11124&&e<=11125||e>=11126&&e<=11157||e===11158||e>=11159&&e<=11263||e>=11776&&e<=11777||e===11778||e===11779||e===11780||e===11781||e>=11782&&e<=11784||e===11785||e===11786||e===11787||e===11788||e===11789||e>=11790&&e<=11798||e===11799||e>=11800&&e<=11801||e===11802||e===11803||e===11804||e===11805||e>=11806&&e<=11807||e===11808||e===11809||e===11810||e===11811||e===11812||e===11813||e===11814||e===11815||e===11816||e===11817||e>=11818&&e<=11822||e===11823||e>=11824&&e<=11833||e>=11834&&e<=11835||e>=11836&&e<=11839||e===11840||e===11841||e===11842||e>=11843&&e<=11855||e>=11856&&e<=11857||e===11858||e>=11859&&e<=11903||e>=12289&&e<=12291||e===12296||e===12297||e===12298||e===12299||e===12300||e===12301||e===12302||e===12303||e===12304||e===12305||e>=12306&&e<=12307||e===12308||e===12309||e===12310||e===12311||e===12312||e===12313||e===12314||e===12315||e===12316||e===12317||e>=12318&&e<=12319||e===12320||e===12336||e===64830||e===64831||e>=65093&&e<=65094}function kf(e){e.forEach(function(t){if(delete t.location,Nc(t)||wc(t))for(var n in t.options)delete t.options[n].location,kf(t.options[n].value);else Pc(t)&&Dc(t.style)||(xc(t)||Tc(t))&&Ti(t.style)?delete t.style.location:Oc(t)&&kf(t.children)})}function WI(e,t){t===void 0&&(t={}),t=V({shouldParseSkeletons:!0,requiresOtherClause:!0},t);var n=new XI(e,t).parse();if(n.err){var r=SyntaxError(U[n.err.kind]);throw r.location=n.err.location,r.originalMessage=n.err.message,r}return t!=null&&t.captureLocation||kf(n.val),n.val}function kc(e,t){var n=t&&t.cache?t.cache:EV,r=t&&t.serializer?t.serializer:RV,o=t&&t.strategy?t.strategy:bV;return o(e,{cache:n,serializer:r})}function SV(e){return e==null||typeof e=="number"||typeof e=="boolean"}function QI(e,t,n,r){var o=SV(r)?r:n(r),s=t.get(o);return typeof s>"u"&&(s=e.call(this,r),t.set(o,s)),s}function JI(e,t,n){var r=Array.prototype.slice.call(arguments,3),o=n(r),s=t.get(o);return typeof s>"u"&&(s=e.apply(this,r),t.set(o,s)),s}function Mf(e,t,n,r,o){return n.bind(t,e,r,o)}function bV(e,t){var n=e.length===1?QI:JI;return Mf(e,this,n,t.cache.create(),t.serializer)}function IV(e,t){return Mf(e,this,JI,t.cache.create(),t.serializer)}function _V(e,t){return Mf(e,this,QI,t.cache.create(),t.serializer)}var RV=function(){return JSON.stringify(arguments)};function Lf(){this.cache=Object.create(null)}Lf.prototype.get=function(e){return this.cache[e]};Lf.prototype.set=function(e,t){this.cache[e]=t};var EV={create:function(){return new Lf}},Mc={variadic:IV,monadic:_V};var Ur;(function(e){e.MISSING_VALUE="MISSING_VALUE",e.INVALID_VALUE="INVALID_VALUE",e.MISSING_INTL_API="MISSING_INTL_API"})(Ur||(Ur={}));var wi=function(e){xi(t,e);function t(n,r,o){var s=e.call(this,n)||this;return s.code=r,s.originalMessage=o,s}return t.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},t}(Error);var Bf=function(e){xi(t,e);function t(n,r,o,s){return e.call(this,'Invalid values for "'.concat(n,'": "').concat(r,'". Options are "').concat(Object.keys(o).join('", "'),'"'),Ur.INVALID_VALUE,s)||this}return t}(wi);var ZI=function(e){xi(t,e);function t(n,r,o){return e.call(this,'Value for "'.concat(n,'" must be of type ').concat(r),Ur.INVALID_VALUE,o)||this}return t}(wi);var e_=function(e){xi(t,e);function t(n,r){return e.call(this,'The intl string context variable "'.concat(n,'" was not provided to the string "').concat(r,'"'),Ur.MISSING_VALUE,r)||this}return t}(wi);var Le;(function(e){e[e.literal=0]="literal",e[e.object=1]="object"})(Le||(Le={}));function CV(e){return e.length<2?e:e.reduce(function(t,n){var r=t[t.length-1];return!r||r.type!==Le.literal||n.type!==Le.literal?t.push(n):r.value+=n.value,t},[])}function PV(e){return typeof e=="function"}function Oi(e,t,n,r,o,s,i){if(e.length===1&&Cf(e[0]))return[{type:Le.literal,value:e[0].value}];for(var a=[],d=0,c=e;d<c.length;d++){var u=c[d];if(Cf(u)){a.push({type:Le.literal,value:u.value});continue}if(wI(u)){typeof s=="number"&&a.push({type:Le.literal,value:n.getNumberFormat(t).format(s)});continue}var p=u.value;if(!(o&&p in o))throw new e_(p,i);var l=o[p];if(NI(u)){(!l||typeof l=="string"||typeof l=="number")&&(l=typeof l=="string"||typeof l=="number"?String(l):""),a.push({type:typeof l=="string"?Le.literal:Le.object,value:l});continue}if(xc(u)){var f=typeof u.style=="string"?r.date[u.style]:Ti(u.style)?u.style.parsedOptions:void 0;a.push({type:Le.literal,value:n.getDateTimeFormat(t,f).format(l)});continue}if(Tc(u)){var f=typeof u.style=="string"?r.time[u.style]:Ti(u.style)?u.style.parsedOptions:r.time.medium;a.push({type:Le.literal,value:n.getDateTimeFormat(t,f).format(l)});continue}if(Pc(u)){var f=typeof u.style=="string"?r.number[u.style]:Dc(u.style)?u.style.parsedOptions:void 0;f&&f.scale&&(l=l*(f.scale||1)),a.push({type:Le.literal,value:n.getNumberFormat(t,f).format(l)});continue}if(Oc(u)){var h=u.children,m=u.value,g=o[m];if(!PV(g))throw new ZI(m,"function",i);var y=Oi(h,t,n,r,o,s),v=g(y.map(function(I){return I.value}));Array.isArray(v)||(v=[v]),a.push.apply(a,v.map(function(I){return{type:typeof I=="string"?Le.literal:Le.object,value:I}}))}if(Nc(u)){var S=u.options[l]||u.options.other;if(!S)throw new Bf(u.value,l,Object.keys(u.options),i);a.push.apply(a,Oi(S.value,t,n,r,o));continue}if(wc(u)){var S=u.options["=".concat(l)];if(!S){if(!Intl.PluralRules)throw new wi(`Intl.PluralRules is not available in this environment.
1
+ "use strict";var Q5=Object.create;var om=Object.defineProperty;var Z5=Object.getOwnPropertyDescriptor;var e6=Object.getOwnPropertyNames;var t6=Object.getPrototypeOf,n6=Object.prototype.hasOwnProperty;var b=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),X_=(e,t)=>{for(var n in t)om(e,n,{get:t[n],enumerable:!0})},xP=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of e6(t))!n6.call(e,i)&&i!==n&&om(e,i,{get:()=>t[i],enumerable:!(r=Z5(t,i))||r.enumerable});return e};var am=(e,t,n)=>(n=e!=null?Q5(t6(e)):{},xP(t||!e||!e.__esModule?om(n,"default",{value:e,enumerable:!0}):n,e)),r6=e=>xP(om({},"__esModule",{value:!0}),e);var nk=b((uXe,Qf)=>{var Dw,Ew,Mw,Nw,ww,kw,Ow,Lw,Fw,Bw,Gw,zw,Uw,Wf,rb,Vw,qw,Kw,dc,jw,Hw,$w,Yw,Xw,Ww,Jw,Qw,Zw,Jf,ek,tk;(function(e){var t=typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:{};typeof define=="function"&&define.amd?define("tslib",["exports"],function(r){e(n(t,n(r)))}):typeof Qf=="object"&&typeof Qf.exports=="object"?e(n(t,n(Qf.exports))):e(n(t));function n(r,i){return r!==t&&(typeof Object.create=="function"?Object.defineProperty(r,"__esModule",{value:!0}):r.__esModule=!0),function(o,a){return r[o]=i?i(o,a):a}}})(function(e){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,o){i.__proto__=o}||function(i,o){for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&(i[a]=o[a])};Dw=function(i,o){if(typeof o!="function"&&o!==null)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");t(i,o);function a(){this.constructor=i}i.prototype=o===null?Object.create(o):(a.prototype=o.prototype,new a)},Ew=Object.assign||function(i){for(var o,a=1,s=arguments.length;a<s;a++){o=arguments[a];for(var c in o)Object.prototype.hasOwnProperty.call(o,c)&&(i[c]=o[c])}return i},Mw=function(i,o){var a={};for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&o.indexOf(s)<0&&(a[s]=i[s]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var c=0,s=Object.getOwnPropertySymbols(i);c<s.length;c++)o.indexOf(s[c])<0&&Object.prototype.propertyIsEnumerable.call(i,s[c])&&(a[s[c]]=i[s[c]]);return a},Nw=function(i,o,a,s){var c=arguments.length,d=c<3?o:s===null?s=Object.getOwnPropertyDescriptor(o,a):s,u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")d=Reflect.decorate(i,o,a,s);else for(var p=i.length-1;p>=0;p--)(u=i[p])&&(d=(c<3?u(d):c>3?u(o,a,d):u(o,a))||d);return c>3&&d&&Object.defineProperty(o,a,d),d},ww=function(i,o){return function(a,s){o(a,s,i)}},kw=function(i,o,a,s,c,d){function u(I){if(I!==void 0&&typeof I!="function")throw new TypeError("Function expected");return I}for(var p=s.kind,m=p==="getter"?"get":p==="setter"?"set":"value",f=!o&&i?s.static?i:i.prototype:null,h=o||(f?Object.getOwnPropertyDescriptor(f,s.name):{}),g,y=!1,_=a.length-1;_>=0;_--){var S={};for(var T in s)S[T]=T==="access"?{}:s[T];for(var T in s.access)S.access[T]=s.access[T];S.addInitializer=function(I){if(y)throw new TypeError("Cannot add initializers after decoration has completed");d.push(u(I||null))};var C=(0,a[_])(p==="accessor"?{get:h.get,set:h.set}:h[m],S);if(p==="accessor"){if(C===void 0)continue;if(C===null||typeof C!="object")throw new TypeError("Object expected");(g=u(C.get))&&(h.get=g),(g=u(C.set))&&(h.set=g),(g=u(C.init))&&c.unshift(g)}else(g=u(C))&&(p==="field"?c.unshift(g):h[m]=g)}f&&Object.defineProperty(f,s.name,h),y=!0},Ow=function(i,o,a){for(var s=arguments.length>2,c=0;c<o.length;c++)a=s?o[c].call(i,a):o[c].call(i);return s?a:void 0},Lw=function(i){return typeof i=="symbol"?i:"".concat(i)},Fw=function(i,o,a){return typeof o=="symbol"&&(o=o.description?"[".concat(o.description,"]"):""),Object.defineProperty(i,"name",{configurable:!0,value:a?"".concat(a," ",o):o})},Bw=function(i,o){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,o)},Gw=function(i,o,a,s){function c(d){return d instanceof a?d:new a(function(u){u(d)})}return new(a||(a=Promise))(function(d,u){function p(h){try{f(s.next(h))}catch(g){u(g)}}function m(h){try{f(s.throw(h))}catch(g){u(g)}}function f(h){h.done?d(h.value):c(h.value).then(p,m)}f((s=s.apply(i,o||[])).next())})},zw=function(i,o){var a={label:0,sent:function(){if(d[0]&1)throw d[1];return d[1]},trys:[],ops:[]},s,c,d,u;return u={next:p(0),throw:p(1),return:p(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function p(f){return function(h){return m([f,h])}}function m(f){if(s)throw new TypeError("Generator is already executing.");for(;u&&(u=0,f[0]&&(a=0)),a;)try{if(s=1,c&&(d=f[0]&2?c.return:f[0]?c.throw||((d=c.return)&&d.call(c),0):c.next)&&!(d=d.call(c,f[1])).done)return d;switch(c=0,d&&(f=[f[0]&2,d.value]),f[0]){case 0:case 1:d=f;break;case 4:return a.label++,{value:f[1],done:!1};case 5:a.label++,c=f[1],f=[0];continue;case 7:f=a.ops.pop(),a.trys.pop();continue;default:if(d=a.trys,!(d=d.length>0&&d[d.length-1])&&(f[0]===6||f[0]===2)){a=0;continue}if(f[0]===3&&(!d||f[1]>d[0]&&f[1]<d[3])){a.label=f[1];break}if(f[0]===6&&a.label<d[1]){a.label=d[1],d=f;break}if(d&&a.label<d[2]){a.label=d[2],a.ops.push(f);break}d[2]&&a.ops.pop(),a.trys.pop();continue}f=o.call(i,a)}catch(h){f=[6,h],c=0}finally{s=d=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}},Uw=function(i,o){for(var a in i)a!=="default"&&!Object.prototype.hasOwnProperty.call(o,a)&&Jf(o,i,a)},Jf=Object.create?function(i,o,a,s){s===void 0&&(s=a);var c=Object.getOwnPropertyDescriptor(o,a);(!c||("get"in c?!o.__esModule:c.writable||c.configurable))&&(c={enumerable:!0,get:function(){return o[a]}}),Object.defineProperty(i,s,c)}:function(i,o,a,s){s===void 0&&(s=a),i[s]=o[a]},Wf=function(i){var o=typeof Symbol=="function"&&Symbol.iterator,a=o&&i[o],s=0;if(a)return a.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&s>=i.length&&(i=void 0),{value:i&&i[s++],done:!i}}};throw new TypeError(o?"Object is not iterable.":"Symbol.iterator is not defined.")},rb=function(i,o){var a=typeof Symbol=="function"&&i[Symbol.iterator];if(!a)return i;var s=a.call(i),c,d=[],u;try{for(;(o===void 0||o-- >0)&&!(c=s.next()).done;)d.push(c.value)}catch(p){u={error:p}}finally{try{c&&!c.done&&(a=s.return)&&a.call(s)}finally{if(u)throw u.error}}return d},Vw=function(){for(var i=[],o=0;o<arguments.length;o++)i=i.concat(rb(arguments[o]));return i},qw=function(){for(var i=0,o=0,a=arguments.length;o<a;o++)i+=arguments[o].length;for(var s=Array(i),c=0,o=0;o<a;o++)for(var d=arguments[o],u=0,p=d.length;u<p;u++,c++)s[c]=d[u];return s},Kw=function(i,o,a){if(a||arguments.length===2)for(var s=0,c=o.length,d;s<c;s++)(d||!(s in o))&&(d||(d=Array.prototype.slice.call(o,0,s)),d[s]=o[s]);return i.concat(d||Array.prototype.slice.call(o))},dc=function(i){return this instanceof dc?(this.v=i,this):new dc(i)},jw=function(i,o,a){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=a.apply(i,o||[]),c,d=[];return c={},u("next"),u("throw"),u("return"),c[Symbol.asyncIterator]=function(){return this},c;function u(y){s[y]&&(c[y]=function(_){return new Promise(function(S,T){d.push([y,_,S,T])>1||p(y,_)})})}function p(y,_){try{m(s[y](_))}catch(S){g(d[0][3],S)}}function m(y){y.value instanceof dc?Promise.resolve(y.value.v).then(f,h):g(d[0][2],y)}function f(y){p("next",y)}function h(y){p("throw",y)}function g(y,_){y(_),d.shift(),d.length&&p(d[0][0],d[0][1])}},Hw=function(i){var o,a;return o={},s("next"),s("throw",function(c){throw c}),s("return"),o[Symbol.iterator]=function(){return this},o;function s(c,d){o[c]=i[c]?function(u){return(a=!a)?{value:dc(i[c](u)),done:!1}:d?d(u):u}:d}},$w=function(i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=i[Symbol.asyncIterator],a;return o?o.call(i):(i=typeof Wf=="function"?Wf(i):i[Symbol.iterator](),a={},s("next"),s("throw"),s("return"),a[Symbol.asyncIterator]=function(){return this},a);function s(d){a[d]=i[d]&&function(u){return new Promise(function(p,m){u=i[d](u),c(p,m,u.done,u.value)})}}function c(d,u,p,m){Promise.resolve(m).then(function(f){d({value:f,done:p})},u)}},Yw=function(i,o){return Object.defineProperty?Object.defineProperty(i,"raw",{value:o}):i.raw=o,i};var n=Object.create?function(i,o){Object.defineProperty(i,"default",{enumerable:!0,value:o})}:function(i,o){i.default=o};Xw=function(i){if(i&&i.__esModule)return i;var o={};if(i!=null)for(var a in i)a!=="default"&&Object.prototype.hasOwnProperty.call(i,a)&&Jf(o,i,a);return n(o,i),o},Ww=function(i){return i&&i.__esModule?i:{default:i}},Jw=function(i,o,a,s){if(a==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof o=="function"?i!==o||!s:!o.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return a==="m"?s:a==="a"?s.call(i):s?s.value:o.get(i)},Qw=function(i,o,a,s,c){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!c)throw new TypeError("Private accessor was defined without a setter");if(typeof o=="function"?i!==o||!c:!o.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?c.call(i,a):c?c.value=a:o.set(i,a),a},Zw=function(i,o){if(o===null||typeof o!="object"&&typeof o!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof i=="function"?o===i:i.has(o)},ek=function(i,o,a){if(o!=null){if(typeof o!="object"&&typeof o!="function")throw new TypeError("Object expected.");var s;if(a){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=o[Symbol.asyncDispose]}if(s===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=o[Symbol.dispose]}if(typeof s!="function")throw new TypeError("Object not disposable.");i.stack.push({value:o,dispose:s,async:a})}else a&&i.stack.push({async:!0});return o};var r=typeof SuppressedError=="function"?SuppressedError:function(i,o,a){var s=new Error(a);return s.name="SuppressedError",s.error=i,s.suppressed=o,s};tk=function(i){function o(s){i.error=i.hasError?new r(s,i.error,"An error was suppressed during disposal."):s,i.hasError=!0}function a(){for(;i.stack.length;){var s=i.stack.pop();try{var c=s.dispose&&s.dispose.call(s.value);if(s.async)return Promise.resolve(c).then(a,function(d){return o(d),a()})}catch(d){o(d)}}if(i.hasError)throw i.error}return a()},e("__extends",Dw),e("__assign",Ew),e("__rest",Mw),e("__decorate",Nw),e("__param",ww),e("__esDecorate",kw),e("__runInitializers",Ow),e("__propKey",Lw),e("__setFunctionName",Fw),e("__metadata",Bw),e("__awaiter",Gw),e("__generator",zw),e("__exportStar",Uw),e("__createBinding",Jf),e("__values",Wf),e("__read",rb),e("__spread",Vw),e("__spreadArrays",qw),e("__spreadArray",Kw),e("__await",dc),e("__asyncGenerator",jw),e("__asyncDelegator",Hw),e("__asyncValues",$w),e("__makeTemplateObject",Yw),e("__importStar",Xw),e("__importDefault",Ww),e("__classPrivateFieldGet",Jw),e("__classPrivateFieldSet",Qw),e("__classPrivateFieldIn",Zw),e("__addDisposableResource",ek),e("__disposeResources",tk)})});var fU=b((Ggt,mU)=>{function Eme(){this.__data__=[],this.size=0}mU.exports=Eme});var Ts=b((zgt,hU)=>{function Mme(e,t){return e===t||e!==e&&t!==t}hU.exports=Mme});var Sl=b((Ugt,gU)=>{var Nme=Ts();function wme(e,t){for(var n=e.length;n--;)if(Nme(e[n][0],t))return n;return-1}gU.exports=wme});var _U=b((Vgt,yU)=>{var kme=Sl(),Ome=Array.prototype,Lme=Ome.splice;function Fme(e){var t=this.__data__,n=kme(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():Lme.call(t,n,1),--this.size,!0}yU.exports=Fme});var SU=b((qgt,TU)=>{var Bme=Sl();function Gme(e){var t=this.__data__,n=Bme(t,e);return n<0?void 0:t[n][1]}TU.exports=Gme});var CU=b((Kgt,bU)=>{var zme=Sl();function Ume(e){return zme(this.__data__,e)>-1}bU.exports=Ume});var IU=b((jgt,AU)=>{var Vme=Sl();function qme(e,t){var n=this.__data__,r=Vme(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}AU.exports=qme});var bl=b((Hgt,vU)=>{var Kme=fU(),jme=_U(),Hme=SU(),$me=CU(),Yme=IU();function gd(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}gd.prototype.clear=Kme;gd.prototype.delete=jme;gd.prototype.get=Hme;gd.prototype.has=$me;gd.prototype.set=Yme;vU.exports=gd});var RU=b(($gt,xU)=>{var Xme=bl();function Wme(){this.__data__=new Xme,this.size=0}xU.exports=Wme});var DU=b((Ygt,PU)=>{function Jme(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}PU.exports=Jme});var MU=b((Xgt,EU)=>{function Qme(e){return this.__data__.get(e)}EU.exports=Qme});var wU=b((Wgt,NU)=>{function Zme(e){return this.__data__.has(e)}NU.exports=Zme});var ax=b((Jgt,kU)=>{var efe=typeof global=="object"&&global&&global.Object===Object&&global;kU.exports=efe});var jn=b((Qgt,OU)=>{var tfe=ax(),nfe=typeof self=="object"&&self&&self.Object===Object&&self,rfe=tfe||nfe||Function("return this")();OU.exports=rfe});var Ss=b((Zgt,LU)=>{var ife=jn(),ofe=ife.Symbol;LU.exports=ofe});var zU=b((eyt,GU)=>{var FU=Ss(),BU=Object.prototype,afe=BU.hasOwnProperty,sfe=BU.toString,Cl=FU?FU.toStringTag:void 0;function cfe(e){var t=afe.call(e,Cl),n=e[Cl];try{e[Cl]=void 0;var r=!0}catch{}var i=sfe.call(e);return r&&(t?e[Cl]=n:delete e[Cl]),i}GU.exports=cfe});var VU=b((tyt,UU)=>{var dfe=Object.prototype,ufe=dfe.toString;function pfe(e){return ufe.call(e)}UU.exports=pfe});var Uo=b((nyt,jU)=>{var qU=Ss(),lfe=zU(),mfe=VU(),ffe="[object Null]",hfe="[object Undefined]",KU=qU?qU.toStringTag:void 0;function gfe(e){return e==null?e===void 0?hfe:ffe:KU&&KU in Object(e)?lfe(e):mfe(e)}jU.exports=gfe});var xn=b((ryt,HU)=>{function yfe(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}HU.exports=yfe});var yd=b((iyt,$U)=>{var _fe=Uo(),Tfe=xn(),Sfe="[object AsyncFunction]",bfe="[object Function]",Cfe="[object GeneratorFunction]",Afe="[object Proxy]";function Ife(e){if(!Tfe(e))return!1;var t=_fe(e);return t==bfe||t==Cfe||t==Sfe||t==Afe}$U.exports=Ife});var XU=b((oyt,YU)=>{var vfe=jn(),xfe=vfe["__core-js_shared__"];YU.exports=xfe});var QU=b((ayt,JU)=>{var sx=XU(),WU=function(){var e=/[^.]+$/.exec(sx&&sx.keys&&sx.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Rfe(e){return!!WU&&WU in e}JU.exports=Rfe});var cx=b((syt,ZU)=>{var Pfe=Function.prototype,Dfe=Pfe.toString;function Efe(e){if(e!=null){try{return Dfe.call(e)}catch{}try{return e+""}catch{}}return""}ZU.exports=Efe});var t3=b((cyt,e3)=>{var Mfe=yd(),Nfe=QU(),wfe=xn(),kfe=cx(),Ofe=/[\\^$.*+?()[\]{}|]/g,Lfe=/^\[object .+?Constructor\]$/,Ffe=Function.prototype,Bfe=Object.prototype,Gfe=Ffe.toString,zfe=Bfe.hasOwnProperty,Ufe=RegExp("^"+Gfe.call(zfe).replace(Ofe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Vfe(e){if(!wfe(e)||Nfe(e))return!1;var t=Mfe(e)?Ufe:Lfe;return t.test(kfe(e))}e3.exports=Vfe});var r3=b((dyt,n3)=>{function qfe(e,t){return e==null?void 0:e[t]}n3.exports=qfe});var Vo=b((uyt,i3)=>{var Kfe=t3(),jfe=r3();function Hfe(e,t){var n=jfe(e,t);return Kfe(n)?n:void 0}i3.exports=Hfe});var Oy=b((pyt,o3)=>{var $fe=Vo(),Yfe=jn(),Xfe=$fe(Yfe,"Map");o3.exports=Xfe});var Al=b((lyt,a3)=>{var Wfe=Vo(),Jfe=Wfe(Object,"create");a3.exports=Jfe});var d3=b((myt,c3)=>{var s3=Al();function Qfe(){this.__data__=s3?s3(null):{},this.size=0}c3.exports=Qfe});var p3=b((fyt,u3)=>{function Zfe(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}u3.exports=Zfe});var m3=b((hyt,l3)=>{var ehe=Al(),the="__lodash_hash_undefined__",nhe=Object.prototype,rhe=nhe.hasOwnProperty;function ihe(e){var t=this.__data__;if(ehe){var n=t[e];return n===the?void 0:n}return rhe.call(t,e)?t[e]:void 0}l3.exports=ihe});var h3=b((gyt,f3)=>{var ohe=Al(),ahe=Object.prototype,she=ahe.hasOwnProperty;function che(e){var t=this.__data__;return ohe?t[e]!==void 0:she.call(t,e)}f3.exports=che});var y3=b((yyt,g3)=>{var dhe=Al(),uhe="__lodash_hash_undefined__";function phe(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=dhe&&t===void 0?uhe:t,this}g3.exports=phe});var T3=b((_yt,_3)=>{var lhe=d3(),mhe=p3(),fhe=m3(),hhe=h3(),ghe=y3();function _d(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}_d.prototype.clear=lhe;_d.prototype.delete=mhe;_d.prototype.get=fhe;_d.prototype.has=hhe;_d.prototype.set=ghe;_3.exports=_d});var C3=b((Tyt,b3)=>{var S3=T3(),yhe=bl(),_he=Oy();function The(){this.size=0,this.__data__={hash:new S3,map:new(_he||yhe),string:new S3}}b3.exports=The});var I3=b((Syt,A3)=>{function She(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}A3.exports=She});var Il=b((byt,v3)=>{var bhe=I3();function Che(e,t){var n=e.__data__;return bhe(t)?n[typeof t=="string"?"string":"hash"]:n.map}v3.exports=Che});var R3=b((Cyt,x3)=>{var Ahe=Il();function Ihe(e){var t=Ahe(this,e).delete(e);return this.size-=t?1:0,t}x3.exports=Ihe});var D3=b((Ayt,P3)=>{var vhe=Il();function xhe(e){return vhe(this,e).get(e)}P3.exports=xhe});var M3=b((Iyt,E3)=>{var Rhe=Il();function Phe(e){return Rhe(this,e).has(e)}E3.exports=Phe});var w3=b((vyt,N3)=>{var Dhe=Il();function Ehe(e,t){var n=Dhe(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}N3.exports=Ehe});var Ly=b((xyt,k3)=>{var Mhe=C3(),Nhe=R3(),whe=D3(),khe=M3(),Ohe=w3();function Td(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Td.prototype.clear=Mhe;Td.prototype.delete=Nhe;Td.prototype.get=whe;Td.prototype.has=khe;Td.prototype.set=Ohe;k3.exports=Td});var L3=b((Ryt,O3)=>{var Lhe=bl(),Fhe=Oy(),Bhe=Ly(),Ghe=200;function zhe(e,t){var n=this.__data__;if(n instanceof Lhe){var r=n.__data__;if(!Fhe||r.length<Ghe-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Bhe(r)}return n.set(e,t),this.size=n.size,this}O3.exports=zhe});var vl=b((Pyt,F3)=>{var Uhe=bl(),Vhe=RU(),qhe=DU(),Khe=MU(),jhe=wU(),Hhe=L3();function Sd(e){var t=this.__data__=new Uhe(e);this.size=t.size}Sd.prototype.clear=Vhe;Sd.prototype.delete=qhe;Sd.prototype.get=Khe;Sd.prototype.has=jhe;Sd.prototype.set=Hhe;F3.exports=Sd});var Fy=b((Dyt,B3)=>{function $he(e,t){for(var n=-1,r=e==null?0:e.length;++n<r&&t(e[n],n,e)!==!1;);return e}B3.exports=$he});var dx=b((Eyt,G3)=>{var Yhe=Vo(),Xhe=function(){try{var e=Yhe(Object,"defineProperty");return e({},"",{}),e}catch{}}();G3.exports=Xhe});var xl=b((Myt,U3)=>{var z3=dx();function Whe(e,t,n){t=="__proto__"&&z3?z3(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}U3.exports=Whe});var Rl=b((Nyt,V3)=>{var Jhe=xl(),Qhe=Ts(),Zhe=Object.prototype,ege=Zhe.hasOwnProperty;function tge(e,t,n){var r=e[t];(!(ege.call(e,t)&&Qhe(r,n))||n===void 0&&!(t in e))&&Jhe(e,t,n)}V3.exports=tge});var bd=b((wyt,q3)=>{var nge=Rl(),rge=xl();function ige(e,t,n,r){var i=!n;n||(n={});for(var o=-1,a=t.length;++o<a;){var s=t[o],c=r?r(n[s],e[s],s,n,e):void 0;c===void 0&&(c=e[s]),i?rge(n,s,c):nge(n,s,c)}return n}q3.exports=ige});var j3=b((kyt,K3)=>{function oge(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}K3.exports=oge});var ur=b((Oyt,H3)=>{function age(e){return e!=null&&typeof e=="object"}H3.exports=age});var Y3=b((Lyt,$3)=>{var sge=Uo(),cge=ur(),dge="[object Arguments]";function uge(e){return cge(e)&&sge(e)==dge}$3.exports=uge});var Cd=b((Fyt,J3)=>{var X3=Y3(),pge=ur(),W3=Object.prototype,lge=W3.hasOwnProperty,mge=W3.propertyIsEnumerable,fge=X3(function(){return arguments}())?X3:function(e){return pge(e)&&lge.call(e,"callee")&&!mge.call(e,"callee")};J3.exports=fge});var at=b((Byt,Q3)=>{var hge=Array.isArray;Q3.exports=hge});var eV=b((Gyt,Z3)=>{function gge(){return!1}Z3.exports=gge});var bs=b((Pl,Ad)=>{var yge=jn(),_ge=eV(),rV=typeof Pl=="object"&&Pl&&!Pl.nodeType&&Pl,tV=rV&&typeof Ad=="object"&&Ad&&!Ad.nodeType&&Ad,Tge=tV&&tV.exports===rV,nV=Tge?yge.Buffer:void 0,Sge=nV?nV.isBuffer:void 0,bge=Sge||_ge;Ad.exports=bge});var Dl=b((zyt,iV)=>{var Cge=9007199254740991,Age=/^(?:0|[1-9]\d*)$/;function Ige(e,t){var n=typeof e;return t=t??Cge,!!t&&(n=="number"||n!="symbol"&&Age.test(e))&&e>-1&&e%1==0&&e<t}iV.exports=Ige});var By=b((Uyt,oV)=>{var vge=9007199254740991;function xge(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=vge}oV.exports=xge});var sV=b((Vyt,aV)=>{var Rge=Uo(),Pge=By(),Dge=ur(),Ege="[object Arguments]",Mge="[object Array]",Nge="[object Boolean]",wge="[object Date]",kge="[object Error]",Oge="[object Function]",Lge="[object Map]",Fge="[object Number]",Bge="[object Object]",Gge="[object RegExp]",zge="[object Set]",Uge="[object String]",Vge="[object WeakMap]",qge="[object ArrayBuffer]",Kge="[object DataView]",jge="[object Float32Array]",Hge="[object Float64Array]",$ge="[object Int8Array]",Yge="[object Int16Array]",Xge="[object Int32Array]",Wge="[object Uint8Array]",Jge="[object Uint8ClampedArray]",Qge="[object Uint16Array]",Zge="[object Uint32Array]",He={};He[jge]=He[Hge]=He[$ge]=He[Yge]=He[Xge]=He[Wge]=He[Jge]=He[Qge]=He[Zge]=!0;He[Ege]=He[Mge]=He[qge]=He[Nge]=He[Kge]=He[wge]=He[kge]=He[Oge]=He[Lge]=He[Fge]=He[Bge]=He[Gge]=He[zge]=He[Uge]=He[Vge]=!1;function eye(e){return Dge(e)&&Pge(e.length)&&!!He[Rge(e)]}aV.exports=eye});var El=b((qyt,cV)=>{function tye(e){return function(t){return e(t)}}cV.exports=tye});var Gy=b((Ml,Id)=>{var nye=ax(),dV=typeof Ml=="object"&&Ml&&!Ml.nodeType&&Ml,Nl=dV&&typeof Id=="object"&&Id&&!Id.nodeType&&Id,rye=Nl&&Nl.exports===dV,ux=rye&&nye.process,iye=function(){try{var e=Nl&&Nl.require&&Nl.require("util").types;return e||ux&&ux.binding&&ux.binding("util")}catch{}}();Id.exports=iye});var vd=b((Kyt,lV)=>{var oye=sV(),aye=El(),uV=Gy(),pV=uV&&uV.isTypedArray,sye=pV?aye(pV):oye;lV.exports=sye});var px=b((jyt,mV)=>{var cye=j3(),dye=Cd(),uye=at(),pye=bs(),lye=Dl(),mye=vd(),fye=Object.prototype,hye=fye.hasOwnProperty;function gye(e,t){var n=uye(e),r=!n&&dye(e),i=!n&&!r&&pye(e),o=!n&&!r&&!i&&mye(e),a=n||r||i||o,s=a?cye(e.length,String):[],c=s.length;for(var d in e)(t||hye.call(e,d))&&!(a&&(d=="length"||i&&(d=="offset"||d=="parent")||o&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||lye(d,c)))&&s.push(d);return s}mV.exports=gye});var wl=b((Hyt,fV)=>{var yye=Object.prototype;function _ye(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||yye;return e===n}fV.exports=_ye});var lx=b(($yt,hV)=>{function Tye(e,t){return function(n){return e(t(n))}}hV.exports=Tye});var yV=b((Yyt,gV)=>{var Sye=lx(),bye=Sye(Object.keys,Object);gV.exports=bye});var zy=b((Xyt,_V)=>{var Cye=wl(),Aye=yV(),Iye=Object.prototype,vye=Iye.hasOwnProperty;function xye(e){if(!Cye(e))return Aye(e);var t=[];for(var n in Object(e))vye.call(e,n)&&n!="constructor"&&t.push(n);return t}_V.exports=xye});var Kr=b((Wyt,TV)=>{var Rye=yd(),Pye=By();function Dye(e){return e!=null&&Pye(e.length)&&!Rye(e)}TV.exports=Dye});var Gi=b((Jyt,SV)=>{var Eye=px(),Mye=zy(),Nye=Kr();function wye(e){return Nye(e)?Eye(e):Mye(e)}SV.exports=wye});var CV=b((Qyt,bV)=>{var kye=bd(),Oye=Gi();function Lye(e,t){return e&&kye(t,Oye(t),e)}bV.exports=Lye});var IV=b((Zyt,AV)=>{function Fye(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}AV.exports=Fye});var xV=b((e_t,vV)=>{var Bye=xn(),Gye=wl(),zye=IV(),Uye=Object.prototype,Vye=Uye.hasOwnProperty;function qye(e){if(!Bye(e))return zye(e);var t=Gye(e),n=[];for(var r in e)r=="constructor"&&(t||!Vye.call(e,r))||n.push(r);return n}vV.exports=qye});var qo=b((t_t,RV)=>{var Kye=px(),jye=xV(),Hye=Kr();function $ye(e){return Hye(e)?Kye(e,!0):jye(e)}RV.exports=$ye});var DV=b((n_t,PV)=>{var Yye=bd(),Xye=qo();function Wye(e,t){return e&&Yye(t,Xye(t),e)}PV.exports=Wye});var mx=b((kl,xd)=>{var Jye=jn(),wV=typeof kl=="object"&&kl&&!kl.nodeType&&kl,EV=wV&&typeof xd=="object"&&xd&&!xd.nodeType&&xd,Qye=EV&&EV.exports===wV,MV=Qye?Jye.Buffer:void 0,NV=MV?MV.allocUnsafe:void 0;function Zye(e,t){if(t)return e.slice();var n=e.length,r=NV?NV(n):new e.constructor(n);return e.copy(r),r}xd.exports=Zye});var fx=b((r_t,kV)=>{function e_e(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}kV.exports=e_e});var hx=b((i_t,OV)=>{function t_e(e,t){for(var n=-1,r=e==null?0:e.length,i=0,o=[];++n<r;){var a=e[n];t(a,n,e)&&(o[i++]=a)}return o}OV.exports=t_e});var gx=b((o_t,LV)=>{function n_e(){return[]}LV.exports=n_e});var Uy=b((a_t,BV)=>{var r_e=hx(),i_e=gx(),o_e=Object.prototype,a_e=o_e.propertyIsEnumerable,FV=Object.getOwnPropertySymbols,s_e=FV?function(e){return e==null?[]:(e=Object(e),r_e(FV(e),function(t){return a_e.call(e,t)}))}:i_e;BV.exports=s_e});var zV=b((s_t,GV)=>{var c_e=bd(),d_e=Uy();function u_e(e,t){return c_e(e,d_e(e),t)}GV.exports=u_e});var Vy=b((c_t,UV)=>{function p_e(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}UV.exports=p_e});var Ol=b((d_t,VV)=>{var l_e=lx(),m_e=l_e(Object.getPrototypeOf,Object);VV.exports=m_e});var yx=b((u_t,qV)=>{var f_e=Vy(),h_e=Ol(),g_e=Uy(),y_e=gx(),__e=Object.getOwnPropertySymbols,T_e=__e?function(e){for(var t=[];e;)f_e(t,g_e(e)),e=h_e(e);return t}:y_e;qV.exports=T_e});var jV=b((p_t,KV)=>{var S_e=bd(),b_e=yx();function C_e(e,t){return S_e(e,b_e(e),t)}KV.exports=C_e});var _x=b((l_t,HV)=>{var A_e=Vy(),I_e=at();function v_e(e,t,n){var r=t(e);return I_e(e)?r:A_e(r,n(e))}HV.exports=v_e});var Tx=b((m_t,$V)=>{var x_e=_x(),R_e=Uy(),P_e=Gi();function D_e(e){return x_e(e,P_e,R_e)}$V.exports=D_e});var XV=b((f_t,YV)=>{var E_e=_x(),M_e=yx(),N_e=qo();function w_e(e){return E_e(e,N_e,M_e)}YV.exports=w_e});var JV=b((h_t,WV)=>{var k_e=Vo(),O_e=jn(),L_e=k_e(O_e,"DataView");WV.exports=L_e});var ZV=b((g_t,QV)=>{var F_e=Vo(),B_e=jn(),G_e=F_e(B_e,"Promise");QV.exports=G_e});var Sx=b((y_t,eq)=>{var z_e=Vo(),U_e=jn(),V_e=z_e(U_e,"Set");eq.exports=V_e});var nq=b((__t,tq)=>{var q_e=Vo(),K_e=jn(),j_e=q_e(K_e,"WeakMap");tq.exports=j_e});var As=b((T_t,dq)=>{var bx=JV(),Cx=Oy(),Ax=ZV(),Ix=Sx(),vx=nq(),cq=Uo(),Rd=cx(),rq="[object Map]",H_e="[object Object]",iq="[object Promise]",oq="[object Set]",aq="[object WeakMap]",sq="[object DataView]",$_e=Rd(bx),Y_e=Rd(Cx),X_e=Rd(Ax),W_e=Rd(Ix),J_e=Rd(vx),Cs=cq;(bx&&Cs(new bx(new ArrayBuffer(1)))!=sq||Cx&&Cs(new Cx)!=rq||Ax&&Cs(Ax.resolve())!=iq||Ix&&Cs(new Ix)!=oq||vx&&Cs(new vx)!=aq)&&(Cs=function(e){var t=cq(e),n=t==H_e?e.constructor:void 0,r=n?Rd(n):"";if(r)switch(r){case $_e:return sq;case Y_e:return rq;case X_e:return iq;case W_e:return oq;case J_e:return aq}return t});dq.exports=Cs});var pq=b((S_t,uq)=>{var Q_e=Object.prototype,Z_e=Q_e.hasOwnProperty;function eTe(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]=="string"&&Z_e.call(e,"index")&&(n.index=e.index,n.input=e.input),n}uq.exports=eTe});var xx=b((b_t,lq)=>{var tTe=jn(),nTe=tTe.Uint8Array;lq.exports=nTe});var qy=b((C_t,fq)=>{var mq=xx();function rTe(e){var t=new e.constructor(e.byteLength);return new mq(t).set(new mq(e)),t}fq.exports=rTe});var gq=b((A_t,hq)=>{var iTe=qy();function oTe(e,t){var n=t?iTe(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}hq.exports=oTe});var _q=b((I_t,yq)=>{var aTe=/\w*$/;function sTe(e){var t=new e.constructor(e.source,aTe.exec(e));return t.lastIndex=e.lastIndex,t}yq.exports=sTe});var Aq=b((v_t,Cq)=>{var Tq=Ss(),Sq=Tq?Tq.prototype:void 0,bq=Sq?Sq.valueOf:void 0;function cTe(e){return bq?Object(bq.call(e)):{}}Cq.exports=cTe});var Rx=b((x_t,Iq)=>{var dTe=qy();function uTe(e,t){var n=t?dTe(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}Iq.exports=uTe});var xq=b((R_t,vq)=>{var pTe=qy(),lTe=gq(),mTe=_q(),fTe=Aq(),hTe=Rx(),gTe="[object Boolean]",yTe="[object Date]",_Te="[object Map]",TTe="[object Number]",STe="[object RegExp]",bTe="[object Set]",CTe="[object String]",ATe="[object Symbol]",ITe="[object ArrayBuffer]",vTe="[object DataView]",xTe="[object Float32Array]",RTe="[object Float64Array]",PTe="[object Int8Array]",DTe="[object Int16Array]",ETe="[object Int32Array]",MTe="[object Uint8Array]",NTe="[object Uint8ClampedArray]",wTe="[object Uint16Array]",kTe="[object Uint32Array]";function OTe(e,t,n){var r=e.constructor;switch(t){case ITe:return pTe(e);case gTe:case yTe:return new r(+e);case vTe:return lTe(e,n);case xTe:case RTe:case PTe:case DTe:case ETe:case MTe:case NTe:case wTe:case kTe:return hTe(e,n);case _Te:return new r;case TTe:case CTe:return new r(e);case STe:return mTe(e);case bTe:return new r;case ATe:return fTe(e)}}vq.exports=OTe});var Px=b((P_t,Pq)=>{var LTe=xn(),Rq=Object.create,FTe=function(){function e(){}return function(t){if(!LTe(t))return{};if(Rq)return Rq(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();Pq.exports=FTe});var Dx=b((D_t,Dq)=>{var BTe=Px(),GTe=Ol(),zTe=wl();function UTe(e){return typeof e.constructor=="function"&&!zTe(e)?BTe(GTe(e)):{}}Dq.exports=UTe});var Mq=b((E_t,Eq)=>{var VTe=As(),qTe=ur(),KTe="[object Map]";function jTe(e){return qTe(e)&&VTe(e)==KTe}Eq.exports=jTe});var Oq=b((M_t,kq)=>{var HTe=Mq(),$Te=El(),Nq=Gy(),wq=Nq&&Nq.isMap,YTe=wq?$Te(wq):HTe;kq.exports=YTe});var Fq=b((N_t,Lq)=>{var XTe=As(),WTe=ur(),JTe="[object Set]";function QTe(e){return WTe(e)&&XTe(e)==JTe}Lq.exports=QTe});var Uq=b((w_t,zq)=>{var ZTe=Fq(),eSe=El(),Bq=Gy(),Gq=Bq&&Bq.isSet,tSe=Gq?eSe(Gq):ZTe;zq.exports=tSe});var Ex=b((k_t,jq)=>{var nSe=vl(),rSe=Fy(),iSe=Rl(),oSe=CV(),aSe=DV(),sSe=mx(),cSe=fx(),dSe=zV(),uSe=jV(),pSe=Tx(),lSe=XV(),mSe=As(),fSe=pq(),hSe=xq(),gSe=Dx(),ySe=at(),_Se=bs(),TSe=Oq(),SSe=xn(),bSe=Uq(),CSe=Gi(),ASe=qo(),ISe=1,vSe=2,xSe=4,Vq="[object Arguments]",RSe="[object Array]",PSe="[object Boolean]",DSe="[object Date]",ESe="[object Error]",qq="[object Function]",MSe="[object GeneratorFunction]",NSe="[object Map]",wSe="[object Number]",Kq="[object Object]",kSe="[object RegExp]",OSe="[object Set]",LSe="[object String]",FSe="[object Symbol]",BSe="[object WeakMap]",GSe="[object ArrayBuffer]",zSe="[object DataView]",USe="[object Float32Array]",VSe="[object Float64Array]",qSe="[object Int8Array]",KSe="[object Int16Array]",jSe="[object Int32Array]",HSe="[object Uint8Array]",$Se="[object Uint8ClampedArray]",YSe="[object Uint16Array]",XSe="[object Uint32Array]",Fe={};Fe[Vq]=Fe[RSe]=Fe[GSe]=Fe[zSe]=Fe[PSe]=Fe[DSe]=Fe[USe]=Fe[VSe]=Fe[qSe]=Fe[KSe]=Fe[jSe]=Fe[NSe]=Fe[wSe]=Fe[Kq]=Fe[kSe]=Fe[OSe]=Fe[LSe]=Fe[FSe]=Fe[HSe]=Fe[$Se]=Fe[YSe]=Fe[XSe]=!0;Fe[ESe]=Fe[qq]=Fe[BSe]=!1;function Ky(e,t,n,r,i,o){var a,s=t&ISe,c=t&vSe,d=t&xSe;if(n&&(a=i?n(e,r,i,o):n(e)),a!==void 0)return a;if(!SSe(e))return e;var u=ySe(e);if(u){if(a=fSe(e),!s)return cSe(e,a)}else{var p=mSe(e),m=p==qq||p==MSe;if(_Se(e))return sSe(e,s);if(p==Kq||p==Vq||m&&!i){if(a=c||m?{}:gSe(e),!s)return c?uSe(e,aSe(a,e)):dSe(e,oSe(a,e))}else{if(!Fe[p])return i?e:{};a=hSe(e,p,s)}}o||(o=new nSe);var f=o.get(e);if(f)return f;o.set(e,a),bSe(e)?e.forEach(function(y){a.add(Ky(y,t,n,y,e,o))}):TSe(e)&&e.forEach(function(y,_){a.set(_,Ky(y,t,n,_,e,o))});var h=d?c?lSe:pSe:c?ASe:CSe,g=u?void 0:h(e);return rSe(g||e,function(y,_){g&&(_=y,y=e[_]),iSe(a,_,Ky(y,t,n,_,e,o))}),a}jq.exports=Ky});var $q=b((O_t,Hq)=>{var WSe=Ex(),JSe=4;function QSe(e){return WSe(e,JSe)}Hq.exports=QSe});var jy=b((L_t,Yq)=>{function ZSe(e){return function(){return e}}Yq.exports=ZSe});var Wq=b((F_t,Xq)=>{function ebe(e){return function(t,n,r){for(var i=-1,o=Object(t),a=r(t),s=a.length;s--;){var c=a[e?s:++i];if(n(o[c],c,o)===!1)break}return t}}Xq.exports=ebe});var Hy=b((B_t,Jq)=>{var tbe=Wq(),nbe=tbe();Jq.exports=nbe});var $y=b((G_t,Qq)=>{var rbe=Hy(),ibe=Gi();function obe(e,t){return e&&rbe(e,t,ibe)}Qq.exports=obe});var e2=b((z_t,Zq)=>{var abe=Kr();function sbe(e,t){return function(n,r){if(n==null)return n;if(!abe(n))return e(n,r);for(var i=n.length,o=t?i:-1,a=Object(n);(t?o--:++o<i)&&r(a[o],o,a)!==!1;);return n}}Zq.exports=sbe});var Ll=b((U_t,t2)=>{var cbe=$y(),dbe=e2(),ube=dbe(cbe);t2.exports=ube});var Ko=b((V_t,n2)=>{function pbe(e){return e}n2.exports=pbe});var Mx=b((q_t,r2)=>{var lbe=Ko();function mbe(e){return typeof e=="function"?e:lbe}r2.exports=mbe});var Nx=b((K_t,i2)=>{var fbe=Fy(),hbe=Ll(),gbe=Mx(),ybe=at();function _be(e,t){var n=ybe(e)?fbe:hbe;return n(e,gbe(t))}i2.exports=_be});var wx=b((j_t,o2)=>{o2.exports=Nx()});var s2=b((H_t,a2)=>{var Tbe=Ll();function Sbe(e,t){var n=[];return Tbe(e,function(r,i,o){t(r,i,o)&&n.push(r)}),n}a2.exports=Sbe});var d2=b(($_t,c2)=>{var bbe="__lodash_hash_undefined__";function Cbe(e){return this.__data__.set(e,bbe),this}c2.exports=Cbe});var p2=b((Y_t,u2)=>{function Abe(e){return this.__data__.has(e)}u2.exports=Abe});var kx=b((X_t,l2)=>{var Ibe=Ly(),vbe=d2(),xbe=p2();function Yy(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new Ibe;++t<n;)this.add(e[t])}Yy.prototype.add=Yy.prototype.push=vbe;Yy.prototype.has=xbe;l2.exports=Yy});var f2=b((W_t,m2)=>{function Rbe(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}m2.exports=Rbe});var Ox=b((J_t,h2)=>{function Pbe(e,t){return e.has(t)}h2.exports=Pbe});var Lx=b((Q_t,g2)=>{var Dbe=kx(),Ebe=f2(),Mbe=Ox(),Nbe=1,wbe=2;function kbe(e,t,n,r,i,o){var a=n&Nbe,s=e.length,c=t.length;if(s!=c&&!(a&&c>s))return!1;var d=o.get(e),u=o.get(t);if(d&&u)return d==t&&u==e;var p=-1,m=!0,f=n&wbe?new Dbe:void 0;for(o.set(e,t),o.set(t,e);++p<s;){var h=e[p],g=t[p];if(r)var y=a?r(g,h,p,t,e,o):r(h,g,p,e,t,o);if(y!==void 0){if(y)continue;m=!1;break}if(f){if(!Ebe(t,function(_,S){if(!Mbe(f,S)&&(h===_||i(h,_,n,r,o)))return f.push(S)})){m=!1;break}}else if(!(h===g||i(h,g,n,r,o))){m=!1;break}}return o.delete(e),o.delete(t),m}g2.exports=kbe});var _2=b((Z_t,y2)=>{function Obe(e){var t=-1,n=Array(e.size);return e.forEach(function(r,i){n[++t]=[i,r]}),n}y2.exports=Obe});var Xy=b((eTt,T2)=>{function Lbe(e){var t=-1,n=Array(e.size);return e.forEach(function(r){n[++t]=r}),n}T2.exports=Lbe});var I2=b((tTt,A2)=>{var S2=Ss(),b2=xx(),Fbe=Ts(),Bbe=Lx(),Gbe=_2(),zbe=Xy(),Ube=1,Vbe=2,qbe="[object Boolean]",Kbe="[object Date]",jbe="[object Error]",Hbe="[object Map]",$be="[object Number]",Ybe="[object RegExp]",Xbe="[object Set]",Wbe="[object String]",Jbe="[object Symbol]",Qbe="[object ArrayBuffer]",Zbe="[object DataView]",C2=S2?S2.prototype:void 0,Fx=C2?C2.valueOf:void 0;function eCe(e,t,n,r,i,o,a){switch(n){case Zbe:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case Qbe:return!(e.byteLength!=t.byteLength||!o(new b2(e),new b2(t)));case qbe:case Kbe:case $be:return Fbe(+e,+t);case jbe:return e.name==t.name&&e.message==t.message;case Ybe:case Wbe:return e==t+"";case Hbe:var s=Gbe;case Xbe:var c=r&Ube;if(s||(s=zbe),e.size!=t.size&&!c)return!1;var d=a.get(e);if(d)return d==t;r|=Vbe,a.set(e,t);var u=Bbe(s(e),s(t),r,i,o,a);return a.delete(e),u;case Jbe:if(Fx)return Fx.call(e)==Fx.call(t)}return!1}A2.exports=eCe});var R2=b((nTt,x2)=>{var v2=Tx(),tCe=1,nCe=Object.prototype,rCe=nCe.hasOwnProperty;function iCe(e,t,n,r,i,o){var a=n&tCe,s=v2(e),c=s.length,d=v2(t),u=d.length;if(c!=u&&!a)return!1;for(var p=c;p--;){var m=s[p];if(!(a?m in t:rCe.call(t,m)))return!1}var f=o.get(e),h=o.get(t);if(f&&h)return f==t&&h==e;var g=!0;o.set(e,t),o.set(t,e);for(var y=a;++p<c;){m=s[p];var _=e[m],S=t[m];if(r)var T=a?r(S,_,m,t,e,o):r(_,S,m,e,t,o);if(!(T===void 0?_===S||i(_,S,n,r,o):T)){g=!1;break}y||(y=m=="constructor")}if(g&&!y){var C=e.constructor,I=t.constructor;C!=I&&"constructor"in e&&"constructor"in t&&!(typeof C=="function"&&C instanceof C&&typeof I=="function"&&I instanceof I)&&(g=!1)}return o.delete(e),o.delete(t),g}x2.exports=iCe});var O2=b((rTt,k2)=>{var Bx=vl(),oCe=Lx(),aCe=I2(),sCe=R2(),P2=As(),D2=at(),E2=bs(),cCe=vd(),dCe=1,M2="[object Arguments]",N2="[object Array]",Wy="[object Object]",uCe=Object.prototype,w2=uCe.hasOwnProperty;function pCe(e,t,n,r,i,o){var a=D2(e),s=D2(t),c=a?N2:P2(e),d=s?N2:P2(t);c=c==M2?Wy:c,d=d==M2?Wy:d;var u=c==Wy,p=d==Wy,m=c==d;if(m&&E2(e)){if(!E2(t))return!1;a=!0,u=!1}if(m&&!u)return o||(o=new Bx),a||cCe(e)?oCe(e,t,n,r,i,o):aCe(e,t,c,n,r,i,o);if(!(n&dCe)){var f=u&&w2.call(e,"__wrapped__"),h=p&&w2.call(t,"__wrapped__");if(f||h){var g=f?e.value():e,y=h?t.value():t;return o||(o=new Bx),i(g,y,n,r,o)}}return m?(o||(o=new Bx),sCe(e,t,n,r,i,o)):!1}k2.exports=pCe});var Gx=b((iTt,B2)=>{var lCe=O2(),L2=ur();function F2(e,t,n,r,i){return e===t?!0:e==null||t==null||!L2(e)&&!L2(t)?e!==e&&t!==t:lCe(e,t,n,r,F2,i)}B2.exports=F2});var z2=b((oTt,G2)=>{var mCe=vl(),fCe=Gx(),hCe=1,gCe=2;function yCe(e,t,n,r){var i=n.length,o=i,a=!r;if(e==null)return!o;for(e=Object(e);i--;){var s=n[i];if(a&&s[2]?s[1]!==e[s[0]]:!(s[0]in e))return!1}for(;++i<o;){s=n[i];var c=s[0],d=e[c],u=s[1];if(a&&s[2]){if(d===void 0&&!(c in e))return!1}else{var p=new mCe;if(r)var m=r(d,u,c,e,t,p);if(!(m===void 0?fCe(u,d,hCe|gCe,r,p):m))return!1}}return!0}G2.exports=yCe});var zx=b((aTt,U2)=>{var _Ce=xn();function TCe(e){return e===e&&!_Ce(e)}U2.exports=TCe});var q2=b((sTt,V2)=>{var SCe=zx(),bCe=Gi();function CCe(e){for(var t=bCe(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,SCe(i)]}return t}V2.exports=CCe});var Ux=b((cTt,K2)=>{function ACe(e,t){return function(n){return n==null?!1:n[e]===t&&(t!==void 0||e in Object(n))}}K2.exports=ACe});var H2=b((dTt,j2)=>{var ICe=z2(),vCe=q2(),xCe=Ux();function RCe(e){var t=vCe(e);return t.length==1&&t[0][2]?xCe(t[0][0],t[0][1]):function(n){return n===e||ICe(n,e,t)}}j2.exports=RCe});var Is=b((uTt,$2)=>{var PCe=Uo(),DCe=ur(),ECe="[object Symbol]";function MCe(e){return typeof e=="symbol"||DCe(e)&&PCe(e)==ECe}$2.exports=MCe});var Jy=b((pTt,Y2)=>{var NCe=at(),wCe=Is(),kCe=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,OCe=/^\w*$/;function LCe(e,t){if(NCe(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||wCe(e)?!0:OCe.test(e)||!kCe.test(e)||t!=null&&e in Object(t)}Y2.exports=LCe});var J2=b((lTt,W2)=>{var X2=Ly(),FCe="Expected a function";function Vx(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(FCe);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var a=e.apply(this,r);return n.cache=o.set(i,a)||o,a};return n.cache=new(Vx.Cache||X2),n}Vx.Cache=X2;W2.exports=Vx});var Z2=b((mTt,Q2)=>{var BCe=J2(),GCe=500;function zCe(e){var t=BCe(e,function(r){return n.size===GCe&&n.clear(),r}),n=t.cache;return t}Q2.exports=zCe});var tK=b((fTt,eK)=>{var UCe=Z2(),VCe=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,qCe=/\\(\\)?/g,KCe=UCe(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(VCe,function(n,r,i,o){t.push(i?o.replace(qCe,"$1"):r||n)}),t});eK.exports=KCe});var Fl=b((hTt,nK)=>{function jCe(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}nK.exports=jCe});var cK=b((gTt,sK)=>{var rK=Ss(),HCe=Fl(),$Ce=at(),YCe=Is(),XCe=1/0,iK=rK?rK.prototype:void 0,oK=iK?iK.toString:void 0;function aK(e){if(typeof e=="string")return e;if($Ce(e))return HCe(e,aK)+"";if(YCe(e))return oK?oK.call(e):"";var t=e+"";return t=="0"&&1/e==-XCe?"-0":t}sK.exports=aK});var qx=b((yTt,dK)=>{var WCe=cK();function JCe(e){return e==null?"":WCe(e)}dK.exports=JCe});var Bl=b((_Tt,uK)=>{var QCe=at(),ZCe=Jy(),eAe=tK(),tAe=qx();function nAe(e,t){return QCe(e)?e:ZCe(e,t)?[e]:eAe(tAe(e))}uK.exports=nAe});var Pd=b((TTt,pK)=>{var rAe=Is(),iAe=1/0;function oAe(e){if(typeof e=="string"||rAe(e))return e;var t=e+"";return t=="0"&&1/e==-iAe?"-0":t}pK.exports=oAe});var Gl=b((STt,lK)=>{var aAe=Bl(),sAe=Pd();function cAe(e,t){t=aAe(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[sAe(t[n++])];return n&&n==r?e:void 0}lK.exports=cAe});var fK=b((bTt,mK)=>{var dAe=Gl();function uAe(e,t,n){var r=e==null?void 0:dAe(e,t);return r===void 0?n:r}mK.exports=uAe});var gK=b((CTt,hK)=>{function pAe(e,t){return e!=null&&t in Object(e)}hK.exports=pAe});var Kx=b((ATt,yK)=>{var lAe=Bl(),mAe=Cd(),fAe=at(),hAe=Dl(),gAe=By(),yAe=Pd();function _Ae(e,t,n){t=lAe(t,e);for(var r=-1,i=t.length,o=!1;++r<i;){var a=yAe(t[r]);if(!(o=e!=null&&n(e,a)))break;e=e[a]}return o||++r!=i?o:(i=e==null?0:e.length,!!i&&gAe(i)&&hAe(a,i)&&(fAe(e)||mAe(e)))}yK.exports=_Ae});var jx=b((ITt,_K)=>{var TAe=gK(),SAe=Kx();function bAe(e,t){return e!=null&&SAe(e,t,TAe)}_K.exports=bAe});var SK=b((vTt,TK)=>{var CAe=Gx(),AAe=fK(),IAe=jx(),vAe=Jy(),xAe=zx(),RAe=Ux(),PAe=Pd(),DAe=1,EAe=2;function MAe(e,t){return vAe(e)&&xAe(t)?RAe(PAe(e),t):function(n){var r=AAe(n,e);return r===void 0&&r===t?IAe(n,e):CAe(t,r,DAe|EAe)}}TK.exports=MAe});var Hx=b((xTt,bK)=>{function NAe(e){return function(t){return t==null?void 0:t[e]}}bK.exports=NAe});var AK=b((RTt,CK)=>{var wAe=Gl();function kAe(e){return function(t){return wAe(t,e)}}CK.exports=kAe});var vK=b((PTt,IK)=>{var OAe=Hx(),LAe=AK(),FAe=Jy(),BAe=Pd();function GAe(e){return FAe(e)?OAe(BAe(e)):LAe(e)}IK.exports=GAe});var jr=b((DTt,xK)=>{var zAe=H2(),UAe=SK(),VAe=Ko(),qAe=at(),KAe=vK();function jAe(e){return typeof e=="function"?e:e==null?VAe:typeof e=="object"?qAe(e)?UAe(e[0],e[1]):zAe(e):KAe(e)}xK.exports=jAe});var $x=b((ETt,RK)=>{var HAe=hx(),$Ae=s2(),YAe=jr(),XAe=at();function WAe(e,t){var n=XAe(e)?HAe:$Ae;return n(e,YAe(t,3))}RK.exports=WAe});var DK=b((MTt,PK)=>{var JAe=Object.prototype,QAe=JAe.hasOwnProperty;function ZAe(e,t){return e!=null&&QAe.call(e,t)}PK.exports=ZAe});var Yx=b((NTt,EK)=>{var eIe=DK(),tIe=Kx();function nIe(e,t){return e!=null&&tIe(e,t,eIe)}EK.exports=nIe});var NK=b((wTt,MK)=>{var rIe=zy(),iIe=As(),oIe=Cd(),aIe=at(),sIe=Kr(),cIe=bs(),dIe=wl(),uIe=vd(),pIe="[object Map]",lIe="[object Set]",mIe=Object.prototype,fIe=mIe.hasOwnProperty;function hIe(e){if(e==null)return!0;if(sIe(e)&&(aIe(e)||typeof e=="string"||typeof e.splice=="function"||cIe(e)||uIe(e)||oIe(e)))return!e.length;var t=iIe(e);if(t==pIe||t==lIe)return!e.size;if(dIe(e))return!rIe(e).length;for(var n in e)if(fIe.call(e,n))return!1;return!0}MK.exports=hIe});var Xx=b((kTt,wK)=>{function gIe(e){return e===void 0}wK.exports=gIe});var Wx=b((OTt,kK)=>{var yIe=Ll(),_Ie=Kr();function TIe(e,t){var n=-1,r=_Ie(e)?Array(e.length):[];return yIe(e,function(i,o,a){r[++n]=t(i,o,a)}),r}kK.exports=TIe});var Jx=b((LTt,OK)=>{var SIe=Fl(),bIe=jr(),CIe=Wx(),AIe=at();function IIe(e,t){var n=AIe(e)?SIe:CIe;return n(e,bIe(t,3))}OK.exports=IIe});var FK=b((FTt,LK)=>{function vIe(e,t,n,r){var i=-1,o=e==null?0:e.length;for(r&&o&&(n=e[++i]);++i<o;)n=t(n,e[i],i,e);return n}LK.exports=vIe});var GK=b((BTt,BK)=>{function xIe(e,t,n,r,i){return i(e,function(o,a,s){n=r?(r=!1,o):t(n,o,a,s)}),n}BK.exports=xIe});var Qx=b((GTt,zK)=>{var RIe=FK(),PIe=Ll(),DIe=jr(),EIe=GK(),MIe=at();function NIe(e,t,n){var r=MIe(e)?RIe:EIe,i=arguments.length<3;return r(e,DIe(t,4),n,i,PIe)}zK.exports=NIe});var VK=b((zTt,UK)=>{var wIe=Uo(),kIe=at(),OIe=ur(),LIe="[object String]";function FIe(e){return typeof e=="string"||!kIe(e)&&OIe(e)&&wIe(e)==LIe}UK.exports=FIe});var KK=b((UTt,qK)=>{var BIe=Hx(),GIe=BIe("length");qK.exports=GIe});var HK=b((VTt,jK)=>{var zIe="\\ud800-\\udfff",UIe="\\u0300-\\u036f",VIe="\\ufe20-\\ufe2f",qIe="\\u20d0-\\u20ff",KIe=UIe+VIe+qIe,jIe="\\ufe0e\\ufe0f",HIe="\\u200d",$Ie=RegExp("["+HIe+zIe+KIe+jIe+"]");function YIe(e){return $Ie.test(e)}jK.exports=YIe});var tj=b((qTt,ej)=>{var YK="\\ud800-\\udfff",XIe="\\u0300-\\u036f",WIe="\\ufe20-\\ufe2f",JIe="\\u20d0-\\u20ff",QIe=XIe+WIe+JIe,ZIe="\\ufe0e\\ufe0f",eve="["+YK+"]",Zx="["+QIe+"]",eR="\\ud83c[\\udffb-\\udfff]",tve="(?:"+Zx+"|"+eR+")",XK="[^"+YK+"]",WK="(?:\\ud83c[\\udde6-\\uddff]){2}",JK="[\\ud800-\\udbff][\\udc00-\\udfff]",nve="\\u200d",QK=tve+"?",ZK="["+ZIe+"]?",rve="(?:"+nve+"(?:"+[XK,WK,JK].join("|")+")"+ZK+QK+")*",ive=ZK+QK+rve,ove="(?:"+[XK+Zx+"?",Zx,WK,JK,eve].join("|")+")",$K=RegExp(eR+"(?="+eR+")|"+ove+ive,"g");function ave(e){for(var t=$K.lastIndex=0;$K.test(e);)++t;return t}ej.exports=ave});var rj=b((KTt,nj)=>{var sve=KK(),cve=HK(),dve=tj();function uve(e){return cve(e)?dve(e):sve(e)}nj.exports=uve});var oj=b((jTt,ij)=>{var pve=zy(),lve=As(),mve=Kr(),fve=VK(),hve=rj(),gve="[object Map]",yve="[object Set]";function _ve(e){if(e==null)return 0;if(mve(e))return fve(e)?hve(e):e.length;var t=lve(e);return t==gve||t==yve?e.size:pve(e).length}ij.exports=_ve});var sj=b((HTt,aj)=>{var Tve=Fy(),Sve=Px(),bve=$y(),Cve=jr(),Ave=Ol(),Ive=at(),vve=bs(),xve=yd(),Rve=xn(),Pve=vd();function Dve(e,t,n){var r=Ive(e),i=r||vve(e)||Pve(e);if(t=Cve(t,4),n==null){var o=e&&e.constructor;i?n=r?new o:[]:Rve(e)?n=xve(o)?Sve(Ave(e)):{}:n={}}return(i?Tve:bve)(e,function(a,s,c){return t(n,a,s,c)}),n}aj.exports=Dve});var pj=b(($Tt,uj)=>{var cj=Ss(),Eve=Cd(),Mve=at(),dj=cj?cj.isConcatSpreadable:void 0;function Nve(e){return Mve(e)||Eve(e)||!!(dj&&e&&e[dj])}uj.exports=Nve});var Qy=b((YTt,mj)=>{var wve=Vy(),kve=pj();function lj(e,t,n,r,i){var o=-1,a=e.length;for(n||(n=kve),i||(i=[]);++o<a;){var s=e[o];t>0&&n(s)?t>1?lj(s,t-1,n,r,i):wve(i,s):r||(i[i.length]=s)}return i}mj.exports=lj});var hj=b((XTt,fj)=>{function Ove(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}fj.exports=Ove});var tR=b((WTt,yj)=>{var Lve=hj(),gj=Math.max;function Fve(e,t,n){return t=gj(t===void 0?e.length-1:t,0),function(){for(var r=arguments,i=-1,o=gj(r.length-t,0),a=Array(o);++i<o;)a[i]=r[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=r[i];return s[t]=n(a),Lve(e,this,s)}}yj.exports=Fve});var Sj=b((JTt,Tj)=>{var Bve=jy(),_j=dx(),Gve=Ko(),zve=_j?function(e,t){return _j(e,"toString",{configurable:!0,enumerable:!1,value:Bve(t),writable:!0})}:Gve;Tj.exports=zve});var Cj=b((QTt,bj)=>{var Uve=800,Vve=16,qve=Date.now;function Kve(e){var t=0,n=0;return function(){var r=qve(),i=Vve-(r-n);if(n=r,i>0){if(++t>=Uve)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}bj.exports=Kve});var nR=b((ZTt,Aj)=>{var jve=Sj(),Hve=Cj(),$ve=Hve(jve);Aj.exports=$ve});var zl=b((eSt,Ij)=>{var Yve=Ko(),Xve=tR(),Wve=nR();function Jve(e,t){return Wve(Xve(e,t,Yve),e+"")}Ij.exports=Jve});var rR=b((tSt,vj)=>{function Qve(e,t,n,r){for(var i=e.length,o=n+(r?1:-1);r?o--:++o<i;)if(t(e[o],o,e))return o;return-1}vj.exports=Qve});var Rj=b((nSt,xj)=>{function Zve(e){return e!==e}xj.exports=Zve});var Dj=b((rSt,Pj)=>{function exe(e,t,n){for(var r=n-1,i=e.length;++r<i;)if(e[r]===t)return r;return-1}Pj.exports=exe});var Mj=b((iSt,Ej)=>{var txe=rR(),nxe=Rj(),rxe=Dj();function ixe(e,t,n){return t===t?rxe(e,t,n):txe(e,nxe,n)}Ej.exports=ixe});var wj=b((oSt,Nj)=>{var oxe=Mj();function axe(e,t){var n=e==null?0:e.length;return!!n&&oxe(e,t,0)>-1}Nj.exports=axe});var Oj=b((aSt,kj)=>{function sxe(e,t,n){for(var r=-1,i=e==null?0:e.length;++r<i;)if(n(t,e[r]))return!0;return!1}kj.exports=sxe});var Fj=b((sSt,Lj)=>{function cxe(){}Lj.exports=cxe});var Gj=b((cSt,Bj)=>{var iR=Sx(),dxe=Fj(),uxe=Xy(),pxe=1/0,lxe=iR&&1/uxe(new iR([,-0]))[1]==pxe?function(e){return new iR(e)}:dxe;Bj.exports=lxe});var Uj=b((dSt,zj)=>{var mxe=kx(),fxe=wj(),hxe=Oj(),gxe=Ox(),yxe=Gj(),_xe=Xy(),Txe=200;function Sxe(e,t,n){var r=-1,i=fxe,o=e.length,a=!0,s=[],c=s;if(n)a=!1,i=hxe;else if(o>=Txe){var d=t?null:yxe(e);if(d)return _xe(d);a=!1,i=gxe,c=new mxe}else c=t?[]:s;e:for(;++r<o;){var u=e[r],p=t?t(u):u;if(u=n||u!==0?u:0,a&&p===p){for(var m=c.length;m--;)if(c[m]===p)continue e;t&&c.push(p),s.push(u)}else i(c,p,n)||(c!==s&&c.push(p),s.push(u))}return s}zj.exports=Sxe});var oR=b((uSt,Vj)=>{var bxe=Kr(),Cxe=ur();function Axe(e){return Cxe(e)&&bxe(e)}Vj.exports=Axe});var Kj=b((pSt,qj)=>{var Ixe=Qy(),vxe=zl(),xxe=Uj(),Rxe=oR(),Pxe=vxe(function(e){return xxe(Ixe(e,1,Rxe,!0))});qj.exports=Pxe});var Hj=b((lSt,jj)=>{var Dxe=Fl();function Exe(e,t){return Dxe(t,function(n){return e[n]})}jj.exports=Exe});var aR=b((mSt,$j)=>{var Mxe=Hj(),Nxe=Gi();function wxe(e){return e==null?[]:Mxe(e,Nxe(e))}$j.exports=wxe});var Rn=b((fSt,Yj)=>{var Zy;if(typeof require=="function")try{Zy={clone:$q(),constant:jy(),each:wx(),filter:$x(),has:Yx(),isArray:at(),isEmpty:NK(),isFunction:yd(),isUndefined:Xx(),keys:Gi(),map:Jx(),reduce:Qx(),size:oj(),transform:sj(),union:Kj(),values:aR()}}catch{}Zy||(Zy=window._);Yj.exports=Zy});var e_=b((hSt,Qj)=>{"use strict";var te=Rn();Qj.exports=pe;var kxe="\0",vs="\0",Xj="";function pe(e){this._isDirected=te.has(e,"directed")?e.directed:!0,this._isMultigraph=te.has(e,"multigraph")?e.multigraph:!1,this._isCompound=te.has(e,"compound")?e.compound:!1,this._label=void 0,this._defaultNodeLabelFn=te.constant(void 0),this._defaultEdgeLabelFn=te.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[vs]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}pe.prototype._nodeCount=0;pe.prototype._edgeCount=0;pe.prototype.isDirected=function(){return this._isDirected};pe.prototype.isMultigraph=function(){return this._isMultigraph};pe.prototype.isCompound=function(){return this._isCompound};pe.prototype.setGraph=function(e){return this._label=e,this};pe.prototype.graph=function(){return this._label};pe.prototype.setDefaultNodeLabel=function(e){return te.isFunction(e)||(e=te.constant(e)),this._defaultNodeLabelFn=e,this};pe.prototype.nodeCount=function(){return this._nodeCount};pe.prototype.nodes=function(){return te.keys(this._nodes)};pe.prototype.sources=function(){var e=this;return te.filter(this.nodes(),function(t){return te.isEmpty(e._in[t])})};pe.prototype.sinks=function(){var e=this;return te.filter(this.nodes(),function(t){return te.isEmpty(e._out[t])})};pe.prototype.setNodes=function(e,t){var n=arguments,r=this;return te.each(e,function(i){n.length>1?r.setNode(i,t):r.setNode(i)}),this};pe.prototype.setNode=function(e,t){return te.has(this._nodes,e)?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=vs,this._children[e]={},this._children[vs][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)};pe.prototype.node=function(e){return this._nodes[e]};pe.prototype.hasNode=function(e){return te.has(this._nodes,e)};pe.prototype.removeNode=function(e){var t=this;if(te.has(this._nodes,e)){var n=function(r){t.removeEdge(t._edgeObjs[r])};delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],te.each(this.children(e),function(r){t.setParent(r)}),delete this._children[e]),te.each(te.keys(this._in[e]),n),delete this._in[e],delete this._preds[e],te.each(te.keys(this._out[e]),n),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this};pe.prototype.setParent=function(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(te.isUndefined(t))t=vs;else{t+="";for(var n=t;!te.isUndefined(n);n=this.parent(n))if(n===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this};pe.prototype._removeFromParentsChildList=function(e){delete this._children[this._parent[e]][e]};pe.prototype.parent=function(e){if(this._isCompound){var t=this._parent[e];if(t!==vs)return t}};pe.prototype.children=function(e){if(te.isUndefined(e)&&(e=vs),this._isCompound){var t=this._children[e];if(t)return te.keys(t)}else{if(e===vs)return this.nodes();if(this.hasNode(e))return[]}};pe.prototype.predecessors=function(e){var t=this._preds[e];if(t)return te.keys(t)};pe.prototype.successors=function(e){var t=this._sucs[e];if(t)return te.keys(t)};pe.prototype.neighbors=function(e){var t=this.predecessors(e);if(t)return te.union(t,this.successors(e))};pe.prototype.isLeaf=function(e){var t;return this.isDirected()?t=this.successors(e):t=this.neighbors(e),t.length===0};pe.prototype.filterNodes=function(e){var t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph());var n=this;te.each(this._nodes,function(o,a){e(a)&&t.setNode(a,o)}),te.each(this._edgeObjs,function(o){t.hasNode(o.v)&&t.hasNode(o.w)&&t.setEdge(o,n.edge(o))});var r={};function i(o){var a=n.parent(o);return a===void 0||t.hasNode(a)?(r[o]=a,a):a in r?r[a]:i(a)}return this._isCompound&&te.each(t.nodes(),function(o){t.setParent(o,i(o))}),t};pe.prototype.setDefaultEdgeLabel=function(e){return te.isFunction(e)||(e=te.constant(e)),this._defaultEdgeLabelFn=e,this};pe.prototype.edgeCount=function(){return this._edgeCount};pe.prototype.edges=function(){return te.values(this._edgeObjs)};pe.prototype.setPath=function(e,t){var n=this,r=arguments;return te.reduce(e,function(i,o){return r.length>1?n.setEdge(i,o,t):n.setEdge(i,o),o}),this};pe.prototype.setEdge=function(){var e,t,n,r,i=!1,o=arguments[0];typeof o=="object"&&o!==null&&"v"in o?(e=o.v,t=o.w,n=o.name,arguments.length===2&&(r=arguments[1],i=!0)):(e=o,t=arguments[1],n=arguments[3],arguments.length>2&&(r=arguments[2],i=!0)),e=""+e,t=""+t,te.isUndefined(n)||(n=""+n);var a=Ul(this._isDirected,e,t,n);if(te.has(this._edgeLabels,a))return i&&(this._edgeLabels[a]=r),this;if(!te.isUndefined(n)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(t),this._edgeLabels[a]=i?r:this._defaultEdgeLabelFn(e,t,n);var s=Oxe(this._isDirected,e,t,n);return e=s.v,t=s.w,Object.freeze(s),this._edgeObjs[a]=s,Wj(this._preds[t],e),Wj(this._sucs[e],t),this._in[t][a]=s,this._out[e][a]=s,this._edgeCount++,this};pe.prototype.edge=function(e,t,n){var r=arguments.length===1?sR(this._isDirected,arguments[0]):Ul(this._isDirected,e,t,n);return this._edgeLabels[r]};pe.prototype.hasEdge=function(e,t,n){var r=arguments.length===1?sR(this._isDirected,arguments[0]):Ul(this._isDirected,e,t,n);return te.has(this._edgeLabels,r)};pe.prototype.removeEdge=function(e,t,n){var r=arguments.length===1?sR(this._isDirected,arguments[0]):Ul(this._isDirected,e,t,n),i=this._edgeObjs[r];return i&&(e=i.v,t=i.w,delete this._edgeLabels[r],delete this._edgeObjs[r],Jj(this._preds[t],e),Jj(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--),this};pe.prototype.inEdges=function(e,t){var n=this._in[e];if(n){var r=te.values(n);return t?te.filter(r,function(i){return i.v===t}):r}};pe.prototype.outEdges=function(e,t){var n=this._out[e];if(n){var r=te.values(n);return t?te.filter(r,function(i){return i.w===t}):r}};pe.prototype.nodeEdges=function(e,t){var n=this.inEdges(e,t);if(n)return n.concat(this.outEdges(e,t))};function Wj(e,t){e[t]?e[t]++:e[t]=1}function Jj(e,t){--e[t]||delete e[t]}function Ul(e,t,n,r){var i=""+t,o=""+n;if(!e&&i>o){var a=i;i=o,o=a}return i+Xj+o+Xj+(te.isUndefined(r)?kxe:r)}function Oxe(e,t,n,r){var i=""+t,o=""+n;if(!e&&i>o){var a=i;i=o,o=a}var s={v:i,w:o};return r&&(s.name=r),s}function sR(e,t){return Ul(e,t.v,t.w,t.name)}});var eH=b((gSt,Zj)=>{Zj.exports="2.1.8"});var nH=b((ySt,tH)=>{tH.exports={Graph:e_(),version:eH()}});var iH=b((_St,rH)=>{var Hr=Rn(),Lxe=e_();rH.exports={write:Fxe,read:zxe};function Fxe(e){var t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:Bxe(e),edges:Gxe(e)};return Hr.isUndefined(e.graph())||(t.value=Hr.clone(e.graph())),t}function Bxe(e){return Hr.map(e.nodes(),function(t){var n=e.node(t),r=e.parent(t),i={v:t};return Hr.isUndefined(n)||(i.value=n),Hr.isUndefined(r)||(i.parent=r),i})}function Gxe(e){return Hr.map(e.edges(),function(t){var n=e.edge(t),r={v:t.v,w:t.w};return Hr.isUndefined(t.name)||(r.name=t.name),Hr.isUndefined(n)||(r.value=n),r})}function zxe(e){var t=new Lxe(e.options).setGraph(e.value);return Hr.each(e.nodes,function(n){t.setNode(n.v,n.value),n.parent&&t.setParent(n.v,n.parent)}),Hr.each(e.edges,function(n){t.setEdge({v:n.v,w:n.w,name:n.name},n.value)}),t}});var aH=b((TSt,oH)=>{var t_=Rn();oH.exports=Uxe;function Uxe(e){var t={},n=[],r;function i(o){t_.has(t,o)||(t[o]=!0,r.push(o),t_.each(e.successors(o),i),t_.each(e.predecessors(o),i))}return t_.each(e.nodes(),function(o){r=[],i(o),r.length&&n.push(r)}),n}});var cR=b((SSt,cH)=>{var sH=Rn();cH.exports=Hn;function Hn(){this._arr=[],this._keyIndices={}}Hn.prototype.size=function(){return this._arr.length};Hn.prototype.keys=function(){return this._arr.map(function(e){return e.key})};Hn.prototype.has=function(e){return sH.has(this._keyIndices,e)};Hn.prototype.priority=function(e){var t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority};Hn.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key};Hn.prototype.add=function(e,t){var n=this._keyIndices;if(e=String(e),!sH.has(n,e)){var r=this._arr,i=r.length;return n[e]=i,r.push({key:e,priority:t}),this._decrease(i),!0}return!1};Hn.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key};Hn.prototype.decrease=function(e,t){var n=this._keyIndices[e];if(t>this._arr[n].priority)throw new Error("New priority is greater than current priority. Key: "+e+" Old: "+this._arr[n].priority+" New: "+t);this._arr[n].priority=t,this._decrease(n)};Hn.prototype._heapify=function(e){var t=this._arr,n=2*e,r=n+1,i=e;n<t.length&&(i=t[n].priority<t[i].priority?n:i,r<t.length&&(i=t[r].priority<t[i].priority?r:i),i!==e&&(this._swap(e,i),this._heapify(i)))};Hn.prototype._decrease=function(e){for(var t=this._arr,n=t[e].priority,r;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r};Hn.prototype._swap=function(e,t){var n=this._arr,r=this._keyIndices,i=n[e],o=n[t];n[e]=o,n[t]=i,r[o.key]=e,r[i.key]=t}});var dR=b((bSt,dH)=>{var Vxe=Rn(),qxe=cR();dH.exports=jxe;var Kxe=Vxe.constant(1);function jxe(e,t,n,r){return Hxe(e,String(t),n||Kxe,r||function(i){return e.outEdges(i)})}function Hxe(e,t,n,r){var i={},o=new qxe,a,s,c=function(d){var u=d.v!==a?d.v:d.w,p=i[u],m=n(d),f=s.distance+m;if(m<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+d+" Weight: "+m);f<p.distance&&(p.distance=f,p.predecessor=a,o.decrease(u,f))};for(e.nodes().forEach(function(d){var u=d===t?0:Number.POSITIVE_INFINITY;i[d]={distance:u},o.add(d,u)});o.size()>0&&(a=o.removeMin(),s=i[a],s.distance!==Number.POSITIVE_INFINITY);)r(a).forEach(c);return i}});var pH=b((CSt,uH)=>{var $xe=dR(),Yxe=Rn();uH.exports=Xxe;function Xxe(e,t,n){return Yxe.transform(e.nodes(),function(r,i){r[i]=$xe(e,i,t,n)},{})}});var uR=b((ASt,mH)=>{var lH=Rn();mH.exports=Wxe;function Wxe(e){var t=0,n=[],r={},i=[];function o(a){var s=r[a]={onStack:!0,lowlink:t,index:t++};if(n.push(a),e.successors(a).forEach(function(u){lH.has(r,u)?r[u].onStack&&(s.lowlink=Math.min(s.lowlink,r[u].index)):(o(u),s.lowlink=Math.min(s.lowlink,r[u].lowlink))}),s.lowlink===s.index){var c=[],d;do d=n.pop(),r[d].onStack=!1,c.push(d);while(a!==d);i.push(c)}}return e.nodes().forEach(function(a){lH.has(r,a)||o(a)}),i}});var hH=b((ISt,fH)=>{var Jxe=Rn(),Qxe=uR();fH.exports=Zxe;function Zxe(e){return Jxe.filter(Qxe(e),function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}});var yH=b((vSt,gH)=>{var eRe=Rn();gH.exports=nRe;var tRe=eRe.constant(1);function nRe(e,t,n){return rRe(e,t||tRe,n||function(r){return e.outEdges(r)})}function rRe(e,t,n){var r={},i=e.nodes();return i.forEach(function(o){r[o]={},r[o][o]={distance:0},i.forEach(function(a){o!==a&&(r[o][a]={distance:Number.POSITIVE_INFINITY})}),n(o).forEach(function(a){var s=a.v===o?a.w:a.v,c=t(a);r[o][s]={distance:c,predecessor:o}})}),i.forEach(function(o){var a=r[o];i.forEach(function(s){var c=r[s];i.forEach(function(d){var u=c[o],p=a[d],m=c[d],f=u.distance+p.distance;f<m.distance&&(m.distance=f,m.predecessor=p.predecessor)})})}),r}});var pR=b((xSt,TH)=>{var Vl=Rn();TH.exports=_H;_H.CycleException=n_;function _H(e){var t={},n={},r=[];function i(o){if(Vl.has(n,o))throw new n_;Vl.has(t,o)||(n[o]=!0,t[o]=!0,Vl.each(e.predecessors(o),i),delete n[o],r.push(o))}if(Vl.each(e.sinks(),i),Vl.size(t)!==e.nodeCount())throw new n_;return r}function n_(){}n_.prototype=new Error});var CH=b((RSt,bH)=>{var SH=pR();bH.exports=iRe;function iRe(e){try{SH(e)}catch(t){if(t instanceof SH.CycleException)return!1;throw t}return!0}});var lR=b((PSt,IH)=>{var r_=Rn();IH.exports=oRe;function oRe(e,t,n){r_.isArray(t)||(t=[t]);var r=(e.isDirected()?e.successors:e.neighbors).bind(e),i=[],o={};return r_.each(t,function(a){if(!e.hasNode(a))throw new Error("Graph does not have node: "+a);AH(e,a,n==="post",o,r,i)}),i}function AH(e,t,n,r,i,o){r_.has(r,t)||(r[t]=!0,n||o.push(t),r_.each(i(t),function(a){AH(e,a,n,r,i,o)}),n&&o.push(t))}});var xH=b((DSt,vH)=>{var aRe=lR();vH.exports=sRe;function sRe(e,t){return aRe(e,t,"post")}});var PH=b((ESt,RH)=>{var cRe=lR();RH.exports=dRe;function dRe(e,t){return cRe(e,t,"pre")}});var MH=b((MSt,EH)=>{var DH=Rn(),uRe=e_(),pRe=cR();EH.exports=lRe;function lRe(e,t){var n=new uRe,r={},i=new pRe,o;function a(c){var d=c.v===o?c.w:c.v,u=i.priority(d);if(u!==void 0){var p=t(c);p<u&&(r[d]=o,i.decrease(d,p))}}if(e.nodeCount()===0)return n;DH.each(e.nodes(),function(c){i.add(c,Number.POSITIVE_INFINITY),n.setNode(c)}),i.decrease(e.nodes()[0],0);for(var s=!1;i.size()>0;){if(o=i.removeMin(),DH.has(r,o))n.setEdge(o,r[o]);else{if(s)throw new Error("Input graph is not connected: "+e);s=!0}e.nodeEdges(o).forEach(a)}return n}});var wH=b((NSt,NH)=>{NH.exports={components:aH(),dijkstra:dR(),dijkstraAll:pH(),findCycles:hH(),floydWarshall:yH(),isAcyclic:CH(),postorder:xH(),preorder:PH(),prim:MH(),tarjan:uR(),topsort:pR()}});var LH=b((wSt,OH)=>{var kH=nH();OH.exports={Graph:kH.Graph,json:iH(),alg:wH(),version:kH.version}});var $n=b((kSt,FH)=>{var i_;if(typeof require=="function")try{i_=LH()}catch{}i_||(i_=window.graphlib);FH.exports=i_});var GH=b((OSt,BH)=>{var mRe=Ex(),fRe=1,hRe=4;function gRe(e){return mRe(e,fRe|hRe)}BH.exports=gRe});var ql=b((LSt,zH)=>{var yRe=Ts(),_Re=Kr(),TRe=Dl(),SRe=xn();function bRe(e,t,n){if(!SRe(n))return!1;var r=typeof t;return(r=="number"?_Re(n)&&TRe(t,n.length):r=="string"&&t in n)?yRe(n[t],e):!1}zH.exports=bRe});var qH=b((FSt,VH)=>{var CRe=zl(),ARe=Ts(),IRe=ql(),vRe=qo(),UH=Object.prototype,xRe=UH.hasOwnProperty,RRe=CRe(function(e,t){e=Object(e);var n=-1,r=t.length,i=r>2?t[2]:void 0;for(i&&IRe(t[0],t[1],i)&&(r=1);++n<r;)for(var o=t[n],a=vRe(o),s=-1,c=a.length;++s<c;){var d=a[s],u=e[d];(u===void 0||ARe(u,UH[d])&&!xRe.call(e,d))&&(e[d]=o[d])}return e});VH.exports=RRe});var jH=b((BSt,KH)=>{var PRe=jr(),DRe=Kr(),ERe=Gi();function MRe(e){return function(t,n,r){var i=Object(t);if(!DRe(t)){var o=PRe(n,3);t=ERe(t),n=function(s){return o(i[s],s,i)}}var a=e(t,n,r);return a>-1?i[o?t[a]:a]:void 0}}KH.exports=MRe});var $H=b((GSt,HH)=>{var NRe=/\s/;function wRe(e){for(var t=e.length;t--&&NRe.test(e.charAt(t)););return t}HH.exports=wRe});var XH=b((zSt,YH)=>{var kRe=$H(),ORe=/^\s+/;function LRe(e){return e&&e.slice(0,kRe(e)+1).replace(ORe,"")}YH.exports=LRe});var ZH=b((USt,QH)=>{var FRe=XH(),WH=xn(),BRe=Is(),JH=0/0,GRe=/^[-+]0x[0-9a-f]+$/i,zRe=/^0b[01]+$/i,URe=/^0o[0-7]+$/i,VRe=parseInt;function qRe(e){if(typeof e=="number")return e;if(BRe(e))return JH;if(WH(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=WH(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=FRe(e);var n=zRe.test(e);return n||URe.test(e)?VRe(e.slice(2),n?2:8):GRe.test(e)?JH:+e}QH.exports=qRe});var mR=b((VSt,t$)=>{var KRe=ZH(),e$=1/0,jRe=17976931348623157e292;function HRe(e){if(!e)return e===0?e:0;if(e=KRe(e),e===e$||e===-e$){var t=e<0?-1:1;return t*jRe}return e===e?e:0}t$.exports=HRe});var r$=b((qSt,n$)=>{var $Re=mR();function YRe(e){var t=$Re(e),n=t%1;return t===t?n?t-n:t:0}n$.exports=YRe});var o$=b((KSt,i$)=>{var XRe=rR(),WRe=jr(),JRe=r$(),QRe=Math.max;function ZRe(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var i=n==null?0:JRe(n);return i<0&&(i=QRe(r+i,0)),XRe(e,WRe(t,3),i)}i$.exports=ZRe});var s$=b((jSt,a$)=>{var ePe=jH(),tPe=o$(),nPe=ePe(tPe);a$.exports=nPe});var fR=b((HSt,c$)=>{var rPe=Qy();function iPe(e){var t=e==null?0:e.length;return t?rPe(e,1):[]}c$.exports=iPe});var u$=b(($St,d$)=>{var oPe=Hy(),aPe=Mx(),sPe=qo();function cPe(e,t){return e==null?e:oPe(e,aPe(t),sPe)}d$.exports=cPe});var l$=b((YSt,p$)=>{function dPe(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}p$.exports=dPe});var f$=b((XSt,m$)=>{var uPe=xl(),pPe=$y(),lPe=jr();function mPe(e,t){var n={};return t=lPe(t,3),pPe(e,function(r,i,o){uPe(n,i,t(r,i,o))}),n}m$.exports=mPe});var o_=b((WSt,h$)=>{var fPe=Is();function hPe(e,t,n){for(var r=-1,i=e.length;++r<i;){var o=e[r],a=t(o);if(a!=null&&(s===void 0?a===a&&!fPe(a):n(a,s)))var s=a,c=o}return c}h$.exports=hPe});var y$=b((JSt,g$)=>{function gPe(e,t){return e>t}g$.exports=gPe});var T$=b((QSt,_$)=>{var yPe=o_(),_Pe=y$(),TPe=Ko();function SPe(e){return e&&e.length?yPe(e,TPe,_Pe):void 0}_$.exports=SPe});var hR=b((ZSt,S$)=>{var bPe=xl(),CPe=Ts();function APe(e,t,n){(n!==void 0&&!CPe(e[t],n)||n===void 0&&!(t in e))&&bPe(e,t,n)}S$.exports=APe});var A$=b((ebt,C$)=>{var IPe=Uo(),vPe=Ol(),xPe=ur(),RPe="[object Object]",PPe=Function.prototype,DPe=Object.prototype,b$=PPe.toString,EPe=DPe.hasOwnProperty,MPe=b$.call(Object);function NPe(e){if(!xPe(e)||IPe(e)!=RPe)return!1;var t=vPe(e);if(t===null)return!0;var n=EPe.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&b$.call(n)==MPe}C$.exports=NPe});var gR=b((tbt,I$)=>{function wPe(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}I$.exports=wPe});var x$=b((nbt,v$)=>{var kPe=bd(),OPe=qo();function LPe(e){return kPe(e,OPe(e))}v$.exports=LPe});var N$=b((rbt,M$)=>{var R$=hR(),FPe=mx(),BPe=Rx(),GPe=fx(),zPe=Dx(),P$=Cd(),D$=at(),UPe=oR(),VPe=bs(),qPe=yd(),KPe=xn(),jPe=A$(),HPe=vd(),E$=gR(),$Pe=x$();function YPe(e,t,n,r,i,o,a){var s=E$(e,n),c=E$(t,n),d=a.get(c);if(d){R$(e,n,d);return}var u=o?o(s,c,n+"",e,t,a):void 0,p=u===void 0;if(p){var m=D$(c),f=!m&&VPe(c),h=!m&&!f&&HPe(c);u=c,m||f||h?D$(s)?u=s:UPe(s)?u=GPe(s):f?(p=!1,u=FPe(c,!0)):h?(p=!1,u=BPe(c,!0)):u=[]:jPe(c)||P$(c)?(u=s,P$(s)?u=$Pe(s):(!KPe(s)||qPe(s))&&(u=zPe(c))):p=!1}p&&(a.set(c,u),i(u,c,r,o,a),a.delete(c)),R$(e,n,u)}M$.exports=YPe});var O$=b((ibt,k$)=>{var XPe=vl(),WPe=hR(),JPe=Hy(),QPe=N$(),ZPe=xn(),eDe=qo(),tDe=gR();function w$(e,t,n,r,i){e!==t&&JPe(t,function(o,a){if(i||(i=new XPe),ZPe(o))QPe(e,t,a,n,w$,r,i);else{var s=r?r(tDe(e,a),o,a+"",e,t,i):void 0;s===void 0&&(s=o),WPe(e,a,s)}},eDe)}k$.exports=w$});var F$=b((obt,L$)=>{var nDe=zl(),rDe=ql();function iDe(e){return nDe(function(t,n){var r=-1,i=n.length,o=i>1?n[i-1]:void 0,a=i>2?n[2]:void 0;for(o=e.length>3&&typeof o=="function"?(i--,o):void 0,a&&rDe(n[0],n[1],a)&&(o=i<3?void 0:o,i=1),t=Object(t);++r<i;){var s=n[r];s&&e(t,s,r,o)}return t})}L$.exports=iDe});var G$=b((abt,B$)=>{var oDe=O$(),aDe=F$(),sDe=aDe(function(e,t,n){oDe(e,t,n)});B$.exports=sDe});var yR=b((sbt,z$)=>{function cDe(e,t){return e<t}z$.exports=cDe});var V$=b((cbt,U$)=>{var dDe=o_(),uDe=yR(),pDe=Ko();function lDe(e){return e&&e.length?dDe(e,pDe,uDe):void 0}U$.exports=lDe});var K$=b((dbt,q$)=>{var mDe=o_(),fDe=jr(),hDe=yR();function gDe(e,t){return e&&e.length?mDe(e,fDe(t,2),hDe):void 0}q$.exports=gDe});var H$=b((ubt,j$)=>{var yDe=jn(),_De=function(){return yDe.Date.now()};j$.exports=_De});var X$=b((pbt,Y$)=>{var TDe=Rl(),SDe=Bl(),bDe=Dl(),$$=xn(),CDe=Pd();function ADe(e,t,n,r){if(!$$(e))return e;t=SDe(t,e);for(var i=-1,o=t.length,a=o-1,s=e;s!=null&&++i<o;){var c=CDe(t[i]),d=n;if(c==="__proto__"||c==="constructor"||c==="prototype")return e;if(i!=a){var u=s[c];d=r?r(u,c,s):void 0,d===void 0&&(d=$$(u)?u:bDe(t[i+1])?[]:{})}TDe(s,c,d),s=s[c]}return e}Y$.exports=ADe});var J$=b((lbt,W$)=>{var IDe=Gl(),vDe=X$(),xDe=Bl();function RDe(e,t,n){for(var r=-1,i=t.length,o={};++r<i;){var a=t[r],s=IDe(e,a);n(s,a)&&vDe(o,xDe(a,e),s)}return o}W$.exports=RDe});var Z$=b((mbt,Q$)=>{var PDe=J$(),DDe=jx();function EDe(e,t){return PDe(e,t,function(n,r){return DDe(e,r)})}Q$.exports=EDe});var tY=b((fbt,eY)=>{var MDe=fR(),NDe=tR(),wDe=nR();function kDe(e){return wDe(NDe(e,void 0,MDe),e+"")}eY.exports=kDe});var rY=b((hbt,nY)=>{var ODe=Z$(),LDe=tY(),FDe=LDe(function(e,t){return e==null?{}:ODe(e,t)});nY.exports=FDe});var oY=b((gbt,iY)=>{var BDe=Math.ceil,GDe=Math.max;function zDe(e,t,n,r){for(var i=-1,o=GDe(BDe((t-e)/(n||1)),0),a=Array(o);o--;)a[r?o:++i]=e,e+=n;return a}iY.exports=zDe});var sY=b((ybt,aY)=>{var UDe=oY(),VDe=ql(),_R=mR();function qDe(e){return function(t,n,r){return r&&typeof r!="number"&&VDe(t,n,r)&&(n=r=void 0),t=_R(t),n===void 0?(n=t,t=0):n=_R(n),r=r===void 0?t<n?1:-1:_R(r),UDe(t,n,r,e)}}aY.exports=qDe});var dY=b((_bt,cY)=>{var KDe=sY(),jDe=KDe();cY.exports=jDe});var pY=b((Tbt,uY)=>{function HDe(e,t){var n=e.length;for(e.sort(t);n--;)e[n]=e[n].value;return e}uY.exports=HDe});var fY=b((Sbt,mY)=>{var lY=Is();function $De(e,t){if(e!==t){var n=e!==void 0,r=e===null,i=e===e,o=lY(e),a=t!==void 0,s=t===null,c=t===t,d=lY(t);if(!s&&!d&&!o&&e>t||o&&a&&c&&!s&&!d||r&&a&&c||!n&&c||!i)return 1;if(!r&&!o&&!d&&e<t||d&&n&&i&&!r&&!o||s&&n&&i||!a&&i||!c)return-1}return 0}mY.exports=$De});var gY=b((bbt,hY)=>{var YDe=fY();function XDe(e,t,n){for(var r=-1,i=e.criteria,o=t.criteria,a=i.length,s=n.length;++r<a;){var c=YDe(i[r],o[r]);if(c){if(r>=s)return c;var d=n[r];return c*(d=="desc"?-1:1)}}return e.index-t.index}hY.exports=XDe});var _Y=b((Cbt,yY)=>{var TR=Fl(),WDe=Gl(),JDe=jr(),QDe=Wx(),ZDe=pY(),eEe=El(),tEe=gY(),nEe=Ko(),rEe=at();function iEe(e,t,n){t.length?t=TR(t,function(o){return rEe(o)?function(a){return WDe(a,o.length===1?o[0]:o)}:o}):t=[nEe];var r=-1;t=TR(t,eEe(JDe));var i=QDe(e,function(o,a,s){var c=TR(t,function(d){return d(o)});return{criteria:c,index:++r,value:o}});return ZDe(i,function(o,a){return tEe(o,a,n)})}yY.exports=iEe});var bY=b((Abt,SY)=>{var oEe=Qy(),aEe=_Y(),sEe=zl(),TY=ql(),cEe=sEe(function(e,t){if(e==null)return[];var n=t.length;return n>1&&TY(e,t[0],t[1])?t=[]:n>2&&TY(t[0],t[1],t[2])&&(t=[t[0]]),aEe(e,oEe(t,1),[])});SY.exports=cEe});var AY=b((Ibt,CY)=>{var dEe=qx(),uEe=0;function pEe(e){var t=++uEe;return dEe(e)+t}CY.exports=pEe});var vY=b((vbt,IY)=>{function lEe(e,t,n){for(var r=-1,i=e.length,o=t.length,a={};++r<i;){var s=r<o?t[r]:void 0;n(a,e[r],s)}return a}IY.exports=lEe});var RY=b((xbt,xY)=>{var mEe=Rl(),fEe=vY();function hEe(e,t){return fEe(e||[],t||[],mEe)}xY.exports=hEe});var $e=b((Rbt,PY)=>{var a_;if(typeof require=="function")try{a_={cloneDeep:GH(),constant:jy(),defaults:qH(),each:wx(),filter:$x(),find:s$(),flatten:fR(),forEach:Nx(),forIn:u$(),has:Yx(),isUndefined:Xx(),last:l$(),map:Jx(),mapValues:f$(),max:T$(),merge:G$(),min:V$(),minBy:K$(),now:H$(),pick:rY(),range:dY(),reduce:Qx(),sortBy:bY(),uniqueId:AY(),values:aR(),zipObject:RY()}}catch{}a_||(a_=window._);PY.exports=a_});var MY=b((Pbt,EY)=>{EY.exports=s_;function s_(){var e={};e._next=e._prev=e,this._sentinel=e}s_.prototype.dequeue=function(){var e=this._sentinel,t=e._prev;if(t!==e)return DY(t),t};s_.prototype.enqueue=function(e){var t=this._sentinel;e._prev&&e._next&&DY(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t};s_.prototype.toString=function(){for(var e=[],t=this._sentinel,n=t._prev;n!==t;)e.push(JSON.stringify(n,gEe)),n=n._prev;return"["+e.join(", ")+"]"};function DY(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function gEe(e,t){if(e!=="_next"&&e!=="_prev")return t}});var wY=b((Dbt,NY)=>{var zi=$e(),yEe=$n().Graph,_Ee=MY();NY.exports=SEe;var TEe=zi.constant(1);function SEe(e,t){if(e.nodeCount()<=1)return[];var n=CEe(e,t||TEe),r=bEe(n.graph,n.buckets,n.zeroIdx);return zi.flatten(zi.map(r,function(i){return e.outEdges(i.v,i.w)}),!0)}function bEe(e,t,n){for(var r=[],i=t[t.length-1],o=t[0],a;e.nodeCount();){for(;a=o.dequeue();)SR(e,t,n,a);for(;a=i.dequeue();)SR(e,t,n,a);if(e.nodeCount()){for(var s=t.length-2;s>0;--s)if(a=t[s].dequeue(),a){r=r.concat(SR(e,t,n,a,!0));break}}}return r}function SR(e,t,n,r,i){var o=i?[]:void 0;return zi.forEach(e.inEdges(r.v),function(a){var s=e.edge(a),c=e.node(a.v);i&&o.push({v:a.v,w:a.w}),c.out-=s,bR(t,n,c)}),zi.forEach(e.outEdges(r.v),function(a){var s=e.edge(a),c=a.w,d=e.node(c);d.in-=s,bR(t,n,d)}),e.removeNode(r.v),o}function CEe(e,t){var n=new yEe,r=0,i=0;zi.forEach(e.nodes(),function(s){n.setNode(s,{v:s,in:0,out:0})}),zi.forEach(e.edges(),function(s){var c=n.edge(s.v,s.w)||0,d=t(s),u=c+d;n.setEdge(s.v,s.w,u),i=Math.max(i,n.node(s.v).out+=d),r=Math.max(r,n.node(s.w).in+=d)});var o=zi.range(i+r+3).map(function(){return new _Ee}),a=r+1;return zi.forEach(n.nodes(),function(s){bR(o,a,n.node(s))}),{graph:n,buckets:o,zeroIdx:a}}function bR(e,t,n){n.out?n.in?e[n.out-n.in+t].enqueue(n):e[e.length-1].enqueue(n):e[0].enqueue(n)}});var OY=b((Ebt,kY)=>{"use strict";var xs=$e(),AEe=wY();kY.exports={run:IEe,undo:xEe};function IEe(e){var t=e.graph().acyclicer==="greedy"?AEe(e,n(e)):vEe(e);xs.forEach(t,function(r){var i=e.edge(r);e.removeEdge(r),i.forwardName=r.name,i.reversed=!0,e.setEdge(r.w,r.v,i,xs.uniqueId("rev"))});function n(r){return function(i){return r.edge(i).weight}}}function vEe(e){var t=[],n={},r={};function i(o){xs.has(r,o)||(r[o]=!0,n[o]=!0,xs.forEach(e.outEdges(o),function(a){xs.has(n,a.w)?t.push(a):i(a.w)}),delete n[o])}return xs.forEach(e.nodes(),i),t}function xEe(e){xs.forEach(e.edges(),function(t){var n=e.edge(t);if(n.reversed){e.removeEdge(t);var r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}});var Qt=b((Mbt,GY)=>{"use strict";var be=$e(),LY=$n().Graph;GY.exports={addDummyNode:FY,simplify:REe,asNonCompoundGraph:PEe,successorWeights:DEe,predecessorWeights:EEe,intersectRect:MEe,buildLayerMatrix:NEe,normalizeRanks:wEe,removeEmptyRanks:kEe,addBorderNode:OEe,maxRank:BY,partition:LEe,time:FEe,notime:BEe};function FY(e,t,n,r){var i;do i=be.uniqueId(r);while(e.hasNode(i));return n.dummy=t,e.setNode(i,n),i}function REe(e){var t=new LY().setGraph(e.graph());return be.forEach(e.nodes(),function(n){t.setNode(n,e.node(n))}),be.forEach(e.edges(),function(n){var r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function PEe(e){var t=new LY({multigraph:e.isMultigraph()}).setGraph(e.graph());return be.forEach(e.nodes(),function(n){e.children(n).length||t.setNode(n,e.node(n))}),be.forEach(e.edges(),function(n){t.setEdge(n,e.edge(n))}),t}function DEe(e){var t=be.map(e.nodes(),function(n){var r={};return be.forEach(e.outEdges(n),function(i){r[i.w]=(r[i.w]||0)+e.edge(i).weight}),r});return be.zipObject(e.nodes(),t)}function EEe(e){var t=be.map(e.nodes(),function(n){var r={};return be.forEach(e.inEdges(n),function(i){r[i.v]=(r[i.v]||0)+e.edge(i).weight}),r});return be.zipObject(e.nodes(),t)}function MEe(e,t){var n=e.x,r=e.y,i=t.x-n,o=t.y-r,a=e.width/2,s=e.height/2;if(!i&&!o)throw new Error("Not possible to find intersection inside of the rectangle");var c,d;return Math.abs(o)*a>Math.abs(i)*s?(o<0&&(s=-s),c=s*i/o,d=s):(i<0&&(a=-a),c=a,d=a*o/i),{x:n+c,y:r+d}}function NEe(e){var t=be.map(be.range(BY(e)+1),function(){return[]});return be.forEach(e.nodes(),function(n){var r=e.node(n),i=r.rank;be.isUndefined(i)||(t[i][r.order]=n)}),t}function wEe(e){var t=be.min(be.map(e.nodes(),function(n){return e.node(n).rank}));be.forEach(e.nodes(),function(n){var r=e.node(n);be.has(r,"rank")&&(r.rank-=t)})}function kEe(e){var t=be.min(be.map(e.nodes(),function(o){return e.node(o).rank})),n=[];be.forEach(e.nodes(),function(o){var a=e.node(o).rank-t;n[a]||(n[a]=[]),n[a].push(o)});var r=0,i=e.graph().nodeRankFactor;be.forEach(n,function(o,a){be.isUndefined(o)&&a%i!==0?--r:r&&be.forEach(o,function(s){e.node(s).rank+=r})})}function OEe(e,t,n,r){var i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),FY(e,"border",i,t)}function BY(e){return be.max(be.map(e.nodes(),function(t){var n=e.node(t).rank;if(!be.isUndefined(n))return n}))}function LEe(e,t){var n={lhs:[],rhs:[]};return be.forEach(e,function(r){t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function FEe(e,t){var n=be.now();try{return t()}finally{console.log(e+" time: "+(be.now()-n)+"ms")}}function BEe(e,t){return t()}});var VY=b((Nbt,UY)=>{"use strict";var zY=$e(),GEe=Qt();UY.exports={run:zEe,undo:VEe};function zEe(e){e.graph().dummyChains=[],zY.forEach(e.edges(),function(t){UEe(e,t)})}function UEe(e,t){var n=t.v,r=e.node(n).rank,i=t.w,o=e.node(i).rank,a=t.name,s=e.edge(t),c=s.labelRank;if(o!==r+1){e.removeEdge(t);var d,u,p;for(p=0,++r;r<o;++p,++r)s.points=[],u={width:0,height:0,edgeLabel:s,edgeObj:t,rank:r},d=GEe.addDummyNode(e,"edge",u,"_d"),r===c&&(u.width=s.width,u.height=s.height,u.dummy="edge-label",u.labelpos=s.labelpos),e.setEdge(n,d,{weight:s.weight},a),p===0&&e.graph().dummyChains.push(d),n=d;e.setEdge(n,i,{weight:s.weight},a)}}function VEe(e){zY.forEach(e.graph().dummyChains,function(t){var n=e.node(t),r=n.edgeLabel,i;for(e.setEdge(n.edgeObj,r);n.dummy;)i=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy==="edge-label"&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=i,n=e.node(t)})}});var Kl=b((wbt,qY)=>{"use strict";var c_=$e();qY.exports={longestPath:qEe,slack:KEe};function qEe(e){var t={};function n(r){var i=e.node(r);if(c_.has(t,r))return i.rank;t[r]=!0;var o=c_.min(c_.map(e.outEdges(r),function(a){return n(a.w)-e.edge(a).minlen}));return(o===Number.POSITIVE_INFINITY||o===void 0||o===null)&&(o=0),i.rank=o}c_.forEach(e.sources(),n)}function KEe(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}});var CR=b((kbt,KY)=>{"use strict";var d_=$e(),jEe=$n().Graph,u_=Kl().slack;KY.exports=HEe;function HEe(e){var t=new jEe({directed:!1}),n=e.nodes()[0],r=e.nodeCount();t.setNode(n,{});for(var i,o;$Ee(t,e)<r;)i=YEe(t,e),o=t.hasNode(i.v)?u_(e,i):-u_(e,i),XEe(t,e,o);return t}function $Ee(e,t){function n(r){d_.forEach(t.nodeEdges(r),function(i){var o=i.v,a=r===o?i.w:o;!e.hasNode(a)&&!u_(t,i)&&(e.setNode(a,{}),e.setEdge(r,a,{}),n(a))})}return d_.forEach(e.nodes(),n),e.nodeCount()}function YEe(e,t){return d_.minBy(t.edges(),function(n){if(e.hasNode(n.v)!==e.hasNode(n.w))return u_(t,n)})}function XEe(e,t,n){d_.forEach(e.nodes(),function(r){t.node(r).rank+=n})}});var QY=b((Obt,JY)=>{"use strict";var Ui=$e(),WEe=CR(),JEe=Kl().slack,QEe=Kl().longestPath,ZEe=$n().alg.preorder,eMe=$n().alg.postorder,tMe=Qt().simplify;JY.exports=Rs;Rs.initLowLimValues=IR;Rs.initCutValues=AR;Rs.calcCutValue=HY;Rs.leaveEdge=YY;Rs.enterEdge=XY;Rs.exchangeEdges=WY;function Rs(e){e=tMe(e),QEe(e);var t=WEe(e);IR(t),AR(t,e);for(var n,r;n=YY(t);)r=XY(t,e,n),WY(t,e,n,r)}function AR(e,t){var n=eMe(e,e.nodes());n=n.slice(0,n.length-1),Ui.forEach(n,function(r){nMe(e,t,r)})}function nMe(e,t,n){var r=e.node(n),i=r.parent;e.edge(n,i).cutvalue=HY(e,t,n)}function HY(e,t,n){var r=e.node(n),i=r.parent,o=!0,a=t.edge(n,i),s=0;return a||(o=!1,a=t.edge(i,n)),s=a.weight,Ui.forEach(t.nodeEdges(n),function(c){var d=c.v===n,u=d?c.w:c.v;if(u!==i){var p=d===o,m=t.edge(c).weight;if(s+=p?m:-m,iMe(e,n,u)){var f=e.edge(n,u).cutvalue;s+=p?-f:f}}}),s}function IR(e,t){arguments.length<2&&(t=e.nodes()[0]),$Y(e,{},1,t)}function $Y(e,t,n,r,i){var o=n,a=e.node(r);return t[r]=!0,Ui.forEach(e.neighbors(r),function(s){Ui.has(t,s)||(n=$Y(e,t,n,s,r))}),a.low=o,a.lim=n++,i?a.parent=i:delete a.parent,n}function YY(e){return Ui.find(e.edges(),function(t){return e.edge(t).cutvalue<0})}function XY(e,t,n){var r=n.v,i=n.w;t.hasEdge(r,i)||(r=n.w,i=n.v);var o=e.node(r),a=e.node(i),s=o,c=!1;o.lim>a.lim&&(s=a,c=!0);var d=Ui.filter(t.edges(),function(u){return c===jY(e,e.node(u.v),s)&&c!==jY(e,e.node(u.w),s)});return Ui.minBy(d,function(u){return JEe(t,u)})}function WY(e,t,n,r){var i=n.v,o=n.w;e.removeEdge(i,o),e.setEdge(r.v,r.w,{}),IR(e),AR(e,t),rMe(e,t)}function rMe(e,t){var n=Ui.find(e.nodes(),function(i){return!t.node(i).parent}),r=ZEe(e,n);r=r.slice(1),Ui.forEach(r,function(i){var o=e.node(i).parent,a=t.edge(i,o),s=!1;a||(a=t.edge(o,i),s=!0),t.node(i).rank=t.node(o).rank+(s?a.minlen:-a.minlen)})}function iMe(e,t,n){return e.hasEdge(t,n)}function jY(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}});var nX=b((Lbt,tX)=>{"use strict";var oMe=Kl(),eX=oMe.longestPath,aMe=CR(),sMe=QY();tX.exports=cMe;function cMe(e){switch(e.graph().ranker){case"network-simplex":ZY(e);break;case"tight-tree":uMe(e);break;case"longest-path":dMe(e);break;default:ZY(e)}}var dMe=eX;function uMe(e){eX(e),aMe(e)}function ZY(e){sMe(e)}});var iX=b((Fbt,rX)=>{var vR=$e();rX.exports=pMe;function pMe(e){var t=mMe(e);vR.forEach(e.graph().dummyChains,function(n){for(var r=e.node(n),i=r.edgeObj,o=lMe(e,t,i.v,i.w),a=o.path,s=o.lca,c=0,d=a[c],u=!0;n!==i.w;){if(r=e.node(n),u){for(;(d=a[c])!==s&&e.node(d).maxRank<r.rank;)c++;d===s&&(u=!1)}if(!u){for(;c<a.length-1&&e.node(d=a[c+1]).minRank<=r.rank;)c++;d=a[c]}e.setParent(n,d),n=e.successors(n)[0]}})}function lMe(e,t,n,r){var i=[],o=[],a=Math.min(t[n].low,t[r].low),s=Math.max(t[n].lim,t[r].lim),c,d;c=n;do c=e.parent(c),i.push(c);while(c&&(t[c].low>a||s>t[c].lim));for(d=c,c=r;(c=e.parent(c))!==d;)o.push(c);return{path:i.concat(o.reverse()),lca:d}}function mMe(e){var t={},n=0;function r(i){var o=n;vR.forEach(e.children(i),r),t[i]={low:o,lim:n++}}return vR.forEach(e.children(),r),t}});var sX=b((Bbt,aX)=>{var Vi=$e(),xR=Qt();aX.exports={run:fMe,cleanup:yMe};function fMe(e){var t=xR.addDummyNode(e,"root",{},"_root"),n=hMe(e),r=Vi.max(Vi.values(n))-1,i=2*r+1;e.graph().nestingRoot=t,Vi.forEach(e.edges(),function(a){e.edge(a).minlen*=i});var o=gMe(e)+1;Vi.forEach(e.children(),function(a){oX(e,t,i,o,r,n,a)}),e.graph().nodeRankFactor=i}function oX(e,t,n,r,i,o,a){var s=e.children(a);if(!s.length){a!==t&&e.setEdge(t,a,{weight:0,minlen:n});return}var c=xR.addBorderNode(e,"_bt"),d=xR.addBorderNode(e,"_bb"),u=e.node(a);e.setParent(c,a),u.borderTop=c,e.setParent(d,a),u.borderBottom=d,Vi.forEach(s,function(p){oX(e,t,n,r,i,o,p);var m=e.node(p),f=m.borderTop?m.borderTop:p,h=m.borderBottom?m.borderBottom:p,g=m.borderTop?r:2*r,y=f!==h?1:i-o[a]+1;e.setEdge(c,f,{weight:g,minlen:y,nestingEdge:!0}),e.setEdge(h,d,{weight:g,minlen:y,nestingEdge:!0})}),e.parent(a)||e.setEdge(t,c,{weight:0,minlen:i+o[a]})}function hMe(e){var t={};function n(r,i){var o=e.children(r);o&&o.length&&Vi.forEach(o,function(a){n(a,i+1)}),t[r]=i}return Vi.forEach(e.children(),function(r){n(r,1)}),t}function gMe(e){return Vi.reduce(e.edges(),function(t,n){return t+e.edge(n).weight},0)}function yMe(e){var t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,Vi.forEach(e.edges(),function(n){var r=e.edge(n);r.nestingEdge&&e.removeEdge(n)})}});var uX=b((Gbt,dX)=>{var RR=$e(),_Me=Qt();dX.exports=TMe;function TMe(e){function t(n){var r=e.children(n),i=e.node(n);if(r.length&&RR.forEach(r,t),RR.has(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(var o=i.minRank,a=i.maxRank+1;o<a;++o)cX(e,"borderLeft","_bl",n,i,o),cX(e,"borderRight","_br",n,i,o)}}RR.forEach(e.children(),t)}function cX(e,t,n,r,i,o){var a={width:0,height:0,rank:o,borderType:t},s=i[t][o-1],c=_Me.addDummyNode(e,"border",a,n);i[t][o]=c,e.setParent(c,r),s&&e.setEdge(s,c,{weight:1})}});var fX=b((zbt,mX)=>{"use strict";var $r=$e();mX.exports={adjust:SMe,undo:bMe};function SMe(e){var t=e.graph().rankdir.toLowerCase();(t==="lr"||t==="rl")&&lX(e)}function bMe(e){var t=e.graph().rankdir.toLowerCase();(t==="bt"||t==="rl")&&CMe(e),(t==="lr"||t==="rl")&&(AMe(e),lX(e))}function lX(e){$r.forEach(e.nodes(),function(t){pX(e.node(t))}),$r.forEach(e.edges(),function(t){pX(e.edge(t))})}function pX(e){var t=e.width;e.width=e.height,e.height=t}function CMe(e){$r.forEach(e.nodes(),function(t){PR(e.node(t))}),$r.forEach(e.edges(),function(t){var n=e.edge(t);$r.forEach(n.points,PR),$r.has(n,"y")&&PR(n)})}function PR(e){e.y=-e.y}function AMe(e){$r.forEach(e.nodes(),function(t){DR(e.node(t))}),$r.forEach(e.edges(),function(t){var n=e.edge(t);$r.forEach(n.points,DR),$r.has(n,"x")&&DR(n)})}function DR(e){var t=e.x;e.x=e.y,e.y=t}});var gX=b((Ubt,hX)=>{"use strict";var qi=$e();hX.exports=IMe;function IMe(e){var t={},n=qi.filter(e.nodes(),function(s){return!e.children(s).length}),r=qi.max(qi.map(n,function(s){return e.node(s).rank})),i=qi.map(qi.range(r+1),function(){return[]});function o(s){if(!qi.has(t,s)){t[s]=!0;var c=e.node(s);i[c.rank].push(s),qi.forEach(e.successors(s),o)}}var a=qi.sortBy(n,function(s){return e.node(s).rank});return qi.forEach(a,o),i}});var _X=b((Vbt,yX)=>{"use strict";var jo=$e();yX.exports=vMe;function vMe(e,t){for(var n=0,r=1;r<t.length;++r)n+=xMe(e,t[r-1],t[r]);return n}function xMe(e,t,n){for(var r=jo.zipObject(n,jo.map(n,function(d,u){return u})),i=jo.flatten(jo.map(t,function(d){return jo.sortBy(jo.map(e.outEdges(d),function(u){return{pos:r[u.w],weight:e.edge(u).weight}}),"pos")}),!0),o=1;o<n.length;)o<<=1;var a=2*o-1;o-=1;var s=jo.map(new Array(a),function(){return 0}),c=0;return jo.forEach(i.forEach(function(d){var u=d.pos+o;s[u]+=d.weight;for(var p=0;u>0;)u%2&&(p+=s[u+1]),u=u-1>>1,s[u]+=d.weight;c+=d.weight*p})),c}});var bX=b((qbt,SX)=>{var TX=$e();SX.exports=RMe;function RMe(e,t){return TX.map(t,function(n){var r=e.inEdges(n);if(r.length){var i=TX.reduce(r,function(o,a){var s=e.edge(a),c=e.node(a.v);return{sum:o.sum+s.weight*c.order,weight:o.weight+s.weight}},{sum:0,weight:0});return{v:n,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:n}})}});var AX=b((Kbt,CX)=>{"use strict";var Pn=$e();CX.exports=PMe;function PMe(e,t){var n={};Pn.forEach(e,function(i,o){var a=n[i.v]={indegree:0,in:[],out:[],vs:[i.v],i:o};Pn.isUndefined(i.barycenter)||(a.barycenter=i.barycenter,a.weight=i.weight)}),Pn.forEach(t.edges(),function(i){var o=n[i.v],a=n[i.w];!Pn.isUndefined(o)&&!Pn.isUndefined(a)&&(a.indegree++,o.out.push(n[i.w]))});var r=Pn.filter(n,function(i){return!i.indegree});return DMe(r)}function DMe(e){var t=[];function n(o){return function(a){a.merged||(Pn.isUndefined(a.barycenter)||Pn.isUndefined(o.barycenter)||a.barycenter>=o.barycenter)&&EMe(o,a)}}function r(o){return function(a){a.in.push(o),--a.indegree===0&&e.push(a)}}for(;e.length;){var i=e.pop();t.push(i),Pn.forEach(i.in.reverse(),n(i)),Pn.forEach(i.out,r(i))}return Pn.map(Pn.filter(t,function(o){return!o.merged}),function(o){return Pn.pick(o,["vs","i","barycenter","weight"])})}function EMe(e,t){var n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}});var xX=b((jbt,vX)=>{var jl=$e(),MMe=Qt();vX.exports=NMe;function NMe(e,t){var n=MMe.partition(e,function(u){return jl.has(u,"barycenter")}),r=n.lhs,i=jl.sortBy(n.rhs,function(u){return-u.i}),o=[],a=0,s=0,c=0;r.sort(wMe(!!t)),c=IX(o,i,c),jl.forEach(r,function(u){c+=u.vs.length,o.push(u.vs),a+=u.barycenter*u.weight,s+=u.weight,c=IX(o,i,c)});var d={vs:jl.flatten(o,!0)};return s&&(d.barycenter=a/s,d.weight=s),d}function IX(e,t,n){for(var r;t.length&&(r=jl.last(t)).i<=n;)t.pop(),e.push(r.vs),n++;return n}function wMe(e){return function(t,n){return t.barycenter<n.barycenter?-1:t.barycenter>n.barycenter?1:e?n.i-t.i:t.i-n.i}}});var DX=b((Hbt,PX)=>{var Ho=$e(),kMe=bX(),OMe=AX(),LMe=xX();PX.exports=RX;function RX(e,t,n,r){var i=e.children(t),o=e.node(t),a=o?o.borderLeft:void 0,s=o?o.borderRight:void 0,c={};a&&(i=Ho.filter(i,function(h){return h!==a&&h!==s}));var d=kMe(e,i);Ho.forEach(d,function(h){if(e.children(h.v).length){var g=RX(e,h.v,n,r);c[h.v]=g,Ho.has(g,"barycenter")&&BMe(h,g)}});var u=OMe(d,n);FMe(u,c);var p=LMe(u,r);if(a&&(p.vs=Ho.flatten([a,p.vs,s],!0),e.predecessors(a).length)){var m=e.node(e.predecessors(a)[0]),f=e.node(e.predecessors(s)[0]);Ho.has(p,"barycenter")||(p.barycenter=0,p.weight=0),p.barycenter=(p.barycenter*p.weight+m.order+f.order)/(p.weight+2),p.weight+=2}return p}function FMe(e,t){Ho.forEach(e,function(n){n.vs=Ho.flatten(n.vs.map(function(r){return t[r]?t[r].vs:r}),!0)})}function BMe(e,t){Ho.isUndefined(e.barycenter)?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}});var MX=b(($bt,EX)=>{var Hl=$e(),GMe=$n().Graph;EX.exports=zMe;function zMe(e,t,n){var r=UMe(e),i=new GMe({compound:!0}).setGraph({root:r}).setDefaultNodeLabel(function(o){return e.node(o)});return Hl.forEach(e.nodes(),function(o){var a=e.node(o),s=e.parent(o);(a.rank===t||a.minRank<=t&&t<=a.maxRank)&&(i.setNode(o),i.setParent(o,s||r),Hl.forEach(e[n](o),function(c){var d=c.v===o?c.w:c.v,u=i.edge(d,o),p=Hl.isUndefined(u)?0:u.weight;i.setEdge(d,o,{weight:e.edge(c).weight+p})}),Hl.has(a,"minRank")&&i.setNode(o,{borderLeft:a.borderLeft[t],borderRight:a.borderRight[t]}))}),i}function UMe(e){for(var t;e.hasNode(t=Hl.uniqueId("_root")););return t}});var wX=b((Ybt,NX)=>{var VMe=$e();NX.exports=qMe;function qMe(e,t,n){var r={},i;VMe.forEach(n,function(o){for(var a=e.parent(o),s,c;a;){if(s=e.parent(a),s?(c=r[s],r[s]=a):(c=i,i=a),c&&c!==a){t.setEdge(c,a);return}a=s}})}});var BX=b((Xbt,FX)=>{"use strict";var $o=$e(),KMe=gX(),jMe=_X(),HMe=DX(),$Me=MX(),YMe=wX(),XMe=$n().Graph,kX=Qt();FX.exports=WMe;function WMe(e){var t=kX.maxRank(e),n=OX(e,$o.range(1,t+1),"inEdges"),r=OX(e,$o.range(t-1,-1,-1),"outEdges"),i=KMe(e);LX(e,i);for(var o=Number.POSITIVE_INFINITY,a,s=0,c=0;c<4;++s,++c){JMe(s%2?n:r,s%4>=2),i=kX.buildLayerMatrix(e);var d=jMe(e,i);d<o&&(c=0,a=$o.cloneDeep(i),o=d)}LX(e,a)}function OX(e,t,n){return $o.map(t,function(r){return $Me(e,r,n)})}function JMe(e,t){var n=new XMe;$o.forEach(e,function(r){var i=r.graph().root,o=HMe(r,i,n,t);$o.forEach(o.vs,function(a,s){r.node(a).order=s}),YMe(r,n,o.vs)})}function LX(e,t){$o.forEach(t,function(n){$o.forEach(n,function(r,i){e.node(r).order=i})})}});var YX=b((Wbt,$X)=>{"use strict";var ne=$e(),QMe=$n().Graph,ZMe=Qt();$X.exports={positionX:nNe,findType1Conflicts:GX,findType2Conflicts:zX,addConflict:ER,hasConflict:UX,verticalAlignment:VX,horizontalCompaction:qX,alignCoordinates:jX,findSmallestWidthAlignment:KX,balance:HX};function GX(e,t){var n={};function r(i,o){var a=0,s=0,c=i.length,d=ne.last(o);return ne.forEach(o,function(u,p){var m=eNe(e,u),f=m?e.node(m).order:c;(m||u===d)&&(ne.forEach(o.slice(s,p+1),function(h){ne.forEach(e.predecessors(h),function(g){var y=e.node(g),_=y.order;(_<a||f<_)&&!(y.dummy&&e.node(h).dummy)&&ER(n,g,h)})}),s=p+1,a=f)}),o}return ne.reduce(t,r),n}function zX(e,t){var n={};function r(o,a,s,c,d){var u;ne.forEach(ne.range(a,s),function(p){u=o[p],e.node(u).dummy&&ne.forEach(e.predecessors(u),function(m){var f=e.node(m);f.dummy&&(f.order<c||f.order>d)&&ER(n,m,u)})})}function i(o,a){var s=-1,c,d=0;return ne.forEach(a,function(u,p){if(e.node(u).dummy==="border"){var m=e.predecessors(u);m.length&&(c=e.node(m[0]).order,r(a,d,p,s,c),d=p,s=c)}r(a,d,a.length,c,o.length)}),a}return ne.reduce(t,i),n}function eNe(e,t){if(e.node(t).dummy)return ne.find(e.predecessors(t),function(n){return e.node(n).dummy})}function ER(e,t,n){if(t>n){var r=t;t=n,n=r}var i=e[t];i||(e[t]=i={}),i[n]=!0}function UX(e,t,n){if(t>n){var r=t;t=n,n=r}return ne.has(e[t],n)}function VX(e,t,n,r){var i={},o={},a={};return ne.forEach(t,function(s){ne.forEach(s,function(c,d){i[c]=c,o[c]=c,a[c]=d})}),ne.forEach(t,function(s){var c=-1;ne.forEach(s,function(d){var u=r(d);if(u.length){u=ne.sortBy(u,function(g){return a[g]});for(var p=(u.length-1)/2,m=Math.floor(p),f=Math.ceil(p);m<=f;++m){var h=u[m];o[d]===d&&c<a[h]&&!UX(n,d,h)&&(o[h]=d,o[d]=i[d]=i[h],c=a[h])}}})}),{root:i,align:o}}function qX(e,t,n,r,i){var o={},a=tNe(e,t,n,i),s=i?"borderLeft":"borderRight";function c(p,m){for(var f=a.nodes(),h=f.pop(),g={};h;)g[h]?p(h):(g[h]=!0,f.push(h),f=f.concat(m(h))),h=f.pop()}function d(p){o[p]=a.inEdges(p).reduce(function(m,f){return Math.max(m,o[f.v]+a.edge(f))},0)}function u(p){var m=a.outEdges(p).reduce(function(h,g){return Math.min(h,o[g.w]-a.edge(g))},Number.POSITIVE_INFINITY),f=e.node(p);m!==Number.POSITIVE_INFINITY&&f.borderType!==s&&(o[p]=Math.max(o[p],m))}return c(d,a.predecessors.bind(a)),c(u,a.successors.bind(a)),ne.forEach(r,function(p){o[p]=o[n[p]]}),o}function tNe(e,t,n,r){var i=new QMe,o=e.graph(),a=rNe(o.nodesep,o.edgesep,r);return ne.forEach(t,function(s){var c;ne.forEach(s,function(d){var u=n[d];if(i.setNode(u),c){var p=n[c],m=i.edge(p,u);i.setEdge(p,u,Math.max(a(e,d,c),m||0))}c=d})}),i}function KX(e,t){return ne.minBy(ne.values(t),function(n){var r=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;return ne.forIn(n,function(o,a){var s=iNe(e,a)/2;r=Math.max(o+s,r),i=Math.min(o-s,i)}),r-i})}function jX(e,t){var n=ne.values(t),r=ne.min(n),i=ne.max(n);ne.forEach(["u","d"],function(o){ne.forEach(["l","r"],function(a){var s=o+a,c=e[s],d;if(c!==t){var u=ne.values(c);d=a==="l"?r-ne.min(u):i-ne.max(u),d&&(e[s]=ne.mapValues(c,function(p){return p+d}))}})})}function HX(e,t){return ne.mapValues(e.ul,function(n,r){if(t)return e[t.toLowerCase()][r];var i=ne.sortBy(ne.map(e,r));return(i[1]+i[2])/2})}function nNe(e){var t=ZMe.buildLayerMatrix(e),n=ne.merge(GX(e,t),zX(e,t)),r={},i;ne.forEach(["u","d"],function(a){i=a==="u"?t:ne.values(t).reverse(),ne.forEach(["l","r"],function(s){s==="r"&&(i=ne.map(i,function(p){return ne.values(p).reverse()}));var c=(a==="u"?e.predecessors:e.successors).bind(e),d=VX(e,i,n,c),u=qX(e,i,d.root,d.align,s==="r");s==="r"&&(u=ne.mapValues(u,function(p){return-p})),r[a+s]=u})});var o=KX(e,r);return jX(r,o),HX(r,e.graph().align)}function rNe(e,t,n){return function(r,i,o){var a=r.node(i),s=r.node(o),c=0,d;if(c+=a.width/2,ne.has(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":d=-a.width/2;break;case"r":d=a.width/2;break}if(d&&(c+=n?d:-d),d=0,c+=(a.dummy?t:e)/2,c+=(s.dummy?t:e)/2,c+=s.width/2,ne.has(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":d=s.width/2;break;case"r":d=-s.width/2;break}return d&&(c+=n?d:-d),d=0,c}}function iNe(e,t){return e.node(t).width}});var JX=b((Jbt,WX)=>{"use strict";var $l=$e(),XX=Qt(),oNe=YX().positionX;WX.exports=aNe;function aNe(e){e=XX.asNonCompoundGraph(e),sNe(e),$l.forEach(oNe(e),function(t,n){e.node(n).x=t})}function sNe(e){var t=XX.buildLayerMatrix(e),n=e.graph().ranksep,r=0;$l.forEach(t,function(i){var o=$l.max($l.map(i,function(a){return e.node(a).height}));$l.forEach(i,function(a){e.node(a).y=r+o/2}),r+=o+n})}});var rW=b((Qbt,nW)=>{"use strict";var ce=$e(),QX=OY(),ZX=VY(),cNe=nX(),dNe=Qt().normalizeRanks,uNe=iX(),pNe=Qt().removeEmptyRanks,eW=sX(),lNe=uX(),tW=fX(),mNe=BX(),fNe=JX(),Yo=Qt(),hNe=$n().Graph;nW.exports=gNe;function gNe(e,t){var n=t&&t.debugTiming?Yo.time:Yo.notime;n("layout",function(){var r=n(" buildLayoutGraph",function(){return RNe(e)});n(" runLayout",function(){yNe(r,n)}),n(" updateInputGraph",function(){_Ne(e,r)})})}function yNe(e,t){t(" makeSpaceForEdgeLabels",function(){PNe(e)}),t(" removeSelfEdges",function(){FNe(e)}),t(" acyclic",function(){QX.run(e)}),t(" nestingGraph.run",function(){eW.run(e)}),t(" rank",function(){cNe(Yo.asNonCompoundGraph(e))}),t(" injectEdgeLabelProxies",function(){DNe(e)}),t(" removeEmptyRanks",function(){pNe(e)}),t(" nestingGraph.cleanup",function(){eW.cleanup(e)}),t(" normalizeRanks",function(){dNe(e)}),t(" assignRankMinMax",function(){ENe(e)}),t(" removeEdgeLabelProxies",function(){MNe(e)}),t(" normalize.run",function(){ZX.run(e)}),t(" parentDummyChains",function(){uNe(e)}),t(" addBorderSegments",function(){lNe(e)}),t(" order",function(){mNe(e)}),t(" insertSelfEdges",function(){BNe(e)}),t(" adjustCoordinateSystem",function(){tW.adjust(e)}),t(" position",function(){fNe(e)}),t(" positionSelfEdges",function(){GNe(e)}),t(" removeBorderNodes",function(){LNe(e)}),t(" normalize.undo",function(){ZX.undo(e)}),t(" fixupEdgeLabelCoords",function(){kNe(e)}),t(" undoCoordinateSystem",function(){tW.undo(e)}),t(" translateGraph",function(){NNe(e)}),t(" assignNodeIntersects",function(){wNe(e)}),t(" reversePoints",function(){ONe(e)}),t(" acyclic.undo",function(){QX.undo(e)})}function _Ne(e,t){ce.forEach(e.nodes(),function(n){var r=e.node(n),i=t.node(n);r&&(r.x=i.x,r.y=i.y,t.children(n).length&&(r.width=i.width,r.height=i.height))}),ce.forEach(e.edges(),function(n){var r=e.edge(n),i=t.edge(n);r.points=i.points,ce.has(i,"x")&&(r.x=i.x,r.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var TNe=["nodesep","edgesep","ranksep","marginx","marginy"],SNe={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},bNe=["acyclicer","ranker","rankdir","align"],CNe=["width","height"],ANe={width:0,height:0},INe=["minlen","weight","width","height","labeloffset"],vNe={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},xNe=["labelpos"];function RNe(e){var t=new hNe({multigraph:!0,compound:!0}),n=NR(e.graph());return t.setGraph(ce.merge({},SNe,MR(n,TNe),ce.pick(n,bNe))),ce.forEach(e.nodes(),function(r){var i=NR(e.node(r));t.setNode(r,ce.defaults(MR(i,CNe),ANe)),t.setParent(r,e.parent(r))}),ce.forEach(e.edges(),function(r){var i=NR(e.edge(r));t.setEdge(r,ce.merge({},vNe,MR(i,INe),ce.pick(i,xNe)))}),t}function PNe(e){var t=e.graph();t.ranksep/=2,ce.forEach(e.edges(),function(n){var r=e.edge(n);r.minlen*=2,r.labelpos.toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function DNe(e){ce.forEach(e.edges(),function(t){var n=e.edge(t);if(n.width&&n.height){var r=e.node(t.v),i=e.node(t.w),o={rank:(i.rank-r.rank)/2+r.rank,e:t};Yo.addDummyNode(e,"edge-proxy",o,"_ep")}})}function ENe(e){var t=0;ce.forEach(e.nodes(),function(n){var r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=ce.max(t,r.maxRank))}),e.graph().maxRank=t}function MNe(e){ce.forEach(e.nodes(),function(t){var n=e.node(t);n.dummy==="edge-proxy"&&(e.edge(n.e).labelRank=n.rank,e.removeNode(t))})}function NNe(e){var t=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,i=0,o=e.graph(),a=o.marginx||0,s=o.marginy||0;function c(d){var u=d.x,p=d.y,m=d.width,f=d.height;t=Math.min(t,u-m/2),n=Math.max(n,u+m/2),r=Math.min(r,p-f/2),i=Math.max(i,p+f/2)}ce.forEach(e.nodes(),function(d){c(e.node(d))}),ce.forEach(e.edges(),function(d){var u=e.edge(d);ce.has(u,"x")&&c(u)}),t-=a,r-=s,ce.forEach(e.nodes(),function(d){var u=e.node(d);u.x-=t,u.y-=r}),ce.forEach(e.edges(),function(d){var u=e.edge(d);ce.forEach(u.points,function(p){p.x-=t,p.y-=r}),ce.has(u,"x")&&(u.x-=t),ce.has(u,"y")&&(u.y-=r)}),o.width=n-t+a,o.height=i-r+s}function wNe(e){ce.forEach(e.edges(),function(t){var n=e.edge(t),r=e.node(t.v),i=e.node(t.w),o,a;n.points?(o=n.points[0],a=n.points[n.points.length-1]):(n.points=[],o=i,a=r),n.points.unshift(Yo.intersectRect(r,o)),n.points.push(Yo.intersectRect(i,a))})}function kNe(e){ce.forEach(e.edges(),function(t){var n=e.edge(t);if(ce.has(n,"x"))switch((n.labelpos==="l"||n.labelpos==="r")&&(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset;break}})}function ONe(e){ce.forEach(e.edges(),function(t){var n=e.edge(t);n.reversed&&n.points.reverse()})}function LNe(e){ce.forEach(e.nodes(),function(t){if(e.children(t).length){var n=e.node(t),r=e.node(n.borderTop),i=e.node(n.borderBottom),o=e.node(ce.last(n.borderLeft)),a=e.node(ce.last(n.borderRight));n.width=Math.abs(a.x-o.x),n.height=Math.abs(i.y-r.y),n.x=o.x+n.width/2,n.y=r.y+n.height/2}}),ce.forEach(e.nodes(),function(t){e.node(t).dummy==="border"&&e.removeNode(t)})}function FNe(e){ce.forEach(e.edges(),function(t){if(t.v===t.w){var n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function BNe(e){var t=Yo.buildLayerMatrix(e);ce.forEach(t,function(n){var r=0;ce.forEach(n,function(i,o){var a=e.node(i);a.order=o+r,ce.forEach(a.selfEdges,function(s){Yo.addDummyNode(e,"selfedge",{width:s.label.width,height:s.label.height,rank:a.rank,order:o+ ++r,e:s.e,label:s.label},"_se")}),delete a.selfEdges})})}function GNe(e){ce.forEach(e.nodes(),function(t){var n=e.node(t);if(n.dummy==="selfedge"){var r=e.node(n.e.v),i=r.x+r.width/2,o=r.y,a=n.x-i,s=r.height/2;e.setEdge(n.e,n.label),e.removeNode(t),n.label.points=[{x:i+2*a/3,y:o-s},{x:i+5*a/6,y:o-s},{x:i+a,y:o},{x:i+5*a/6,y:o+s},{x:i+2*a/3,y:o+s}],n.label.x=n.x,n.label.y=n.y}})}function MR(e,t){return ce.mapValues(ce.pick(e,t),Number)}function NR(e){var t={};return ce.forEach(e,function(n,r){t[r.toLowerCase()]=n}),t}});var oW=b((Zbt,iW)=>{var p_=$e(),zNe=Qt(),UNe=$n().Graph;iW.exports={debugOrdering:VNe};function VNe(e){var t=zNe.buildLayerMatrix(e),n=new UNe({compound:!0,multigraph:!0}).setGraph({});return p_.forEach(e.nodes(),function(r){n.setNode(r,{label:r}),n.setParent(r,"layer"+e.node(r).rank)}),p_.forEach(e.edges(),function(r){n.setEdge(r.v,r.w,{},r.name)}),p_.forEach(t,function(r,i){var o="layer"+i;n.setNode(o,{rank:"same"}),p_.reduce(r,function(a,s){return n.setEdge(a,s,{style:"invis"}),s})}),n}});var sW=b((eCt,aW)=>{aW.exports="0.8.5"});var l_=b((tCt,cW)=>{cW.exports={graphlib:$n(),layout:rW(),debug:oW(),util:{time:Qt().time,notime:Qt().notime},version:sW()}});var LFe={};X_(LFe,{XYQ_CANVAS_OPENCODE_MUTATION_DEFINITIONS:()=>Y_,XYQ_CANVAS_REGISTERED_COMMAND_DEFINITIONS:()=>IP,createPippitAssetRuntime:()=>AT,createPippitAssetSdkCanvasLoader:()=>y5,createPippitAssetServiceTransport:()=>BT,createXyqCanvasCommandRuntime:()=>Jz,createXyqCanvasOpencodeToolDefinitions:()=>X5});module.exports=r6(LFe);var W_={error:(...e)=>{var t,n;return(n=(t=globalThis.console)==null?void 0:t.error)==null?void 0:n.call(t,...e)},info:(...e)=>{var t,n;return(n=(t=globalThis.console)==null?void 0:t.info)==null?void 0:n.call(t,...e)},warn:(...e)=>{var t,n;return(n=(t=globalThis.console)==null?void 0:t.warn)==null?void 0:n.call(t,...e)}};function ws(e){return{error:(e==null?void 0:e.error)??W_.error,info:(e==null?void 0:e.info)??W_.info,warn:(e==null?void 0:e.warn)??W_.warn}}function RP(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e,n=t.pippitAssetId,r=t.assetId;return typeof n=="string"&&n.trim().length>0||typeof r=="string"&&r.trim().length>0}function PP(e){if(!RP(e))throw new Error("Pippit asset SDK requires a structured asset ref: { pippitAssetId } or { assetId }.")}function _e(e){var r,i;PP(e);let t=(r=e.pippitAssetId)==null?void 0:r.trim(),n=(i=e.assetId)==null?void 0:i.trim();return{...t?{pippitAssetId:t}:{},...n?{assetId:n}:{},...e.mediaType?{mediaType:e.mediaType}:{}}}function vt(e){return{asset_id:e.assetId,media_type:e.mediaType,pippit_asset_id:e.pippitAssetId}}function En(e){let t=_e(e);return[t.pippitAssetId?`pippit:${t.pippitAssetId}`:"",t.assetId?`asset:${t.assetId}`:"",t.mediaType?`type:${t.mediaType}`:""].filter(Boolean).join("|")}function J_(e){return{...e,context:i6(e.context)}}function sn(e){e&&typeof e.catch=="function"&&e.catch(()=>{})}function i6(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))t[n]=o6(r);return t}function o6(e){return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?EP(e)?`[url:${sm(e)}]`:e:e===null||typeof e=="number"||typeof e=="boolean"||typeof e>"u"?e:Array.isArray(e)?`[array:${e.length}]`:typeof e=="object"?"[object]":String(e)}function DP(e){if(e)return EP(e)?`[url:${sm(e)}]`:e}function EP(e){return/https?:\/\//i.test(e)||/[?&](x|token|sign|signature|expires?)=/i.test(e)}function sm(e){if(!e)return;let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function Q_(e){var t;return{assetId:e.assetId,image:(t=e.image)!=null&&t.previews?{previewResolutions:Object.keys(e.image.previews),previewVariants:Object.keys(e.image.previewVariants??{})}:void 0,mediaType:e.mediaType,pippitAssetId:e.pippitAssetId,storageKey:s6(e),updatedAt:Date.now(),video:e.video?{durationMs:e.video.durationMs,height:e.video.height,width:e.video.width}:void 0}}function Z_(e,t){var i,o,a;let n=t.mediaType==="image"?t.imageVariant??"default":void 0,r=a6(e,t.source);return{assetId:r.assetId,expiresAt:(i=t.source)==null?void 0:i.expiresAt,imageVariant:n,mediaType:t.mediaType,pippitAssetId:r.pippitAssetId,purpose:t.purpose,resolution:t.resolution,sourceVersion:DP((o=t.source)==null?void 0:o.version),storageKey:[En(r),t.mediaType,t.purpose,t.resolution??"",n??""].join("|"),updatedAt:Date.now(),urlVersion:sm(((a=t.source)==null?void 0:a.url)??t.url)}}function a6(e,t){let n=t==null?void 0:t.identity;return n!=null&&n.assetId?{assetId:n.assetId,...n.pippitAssetId?{pippitAssetId:n.pippitAssetId}:{}}:n!=null&&n.pippitAssetId?{pippitAssetId:n.pippitAssetId}:e}function s6(e){return[e.pippitAssetId?`pippit:${e.pippitAssetId}`:"",e.assetId?`asset:${e.assetId}`:""].filter(Boolean).join("|")}var Wd=class{constructor(t=500,n){this._limit=t;this._storage=n;this._records=[];this._listeners=new Set}add(t){var r;let n=J_(t);for(this._records.push(n);this._limit>=0&&this._records.length>this._limit;)this._records.shift();for(let i of this._listeners)i(n);sn((r=this._storage)==null?void 0:r.putOperationRecord(n))}clearRecords(){this._records.length=0}getRecords(t={}){return this._records.filter(n=>!(t.action&&n.action!==t.action||t.operationId&&n.operationId!==t.operationId||t.status&&n.status!==t.status||t.traceId&&n.traceId!==t.traceId))}subscribe(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}};var MP;function d6(){let e=globalThis.console;if(!e||typeof e!="object")return;let t=e.warn;return typeof t=="function"?t.bind(e):void 0}function eT(e){var t;if(MP)try{MP({...e,context:u6(e.context),metrics:p6(e.metrics)})}catch(n){(t=d6())==null||t("[pippit-asset-sdk] telemetry reporter failed",n)}}function u6(e){if(!e)return;let t={},n=40;for(let[r,i]of Object.entries(e)){if(n<=0)break;t[r]=l6(i),n-=1}return t}function p6(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))Number.isFinite(r)&&(t[n]=r);return Object.keys(t).length?t:void 0}function l6(e){var t;return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e.length>500?`${e.slice(0,500)}...`:e:e===null||typeof e=="number"||typeof e=="boolean"||typeof e>"u"?e:Array.isArray(e)?`[array:${e.length}]`:typeof e=="object"?`[object:${((t=e.constructor)==null?void 0:t.name)||"Object"}]`:String(e)}var cm=class{constructor(t){this.storage=t.storage,this.ledger=t.ledger??new Wd(500,t.storage),this._logger=t.logger,this._context=t.context??{}}async run(t,n,r){let i=Date.now(),o=NP(t),a=n.traceId??o,s={action:t,category:n.category??"pippit_asset",context:{...this._context,...n.context},operationId:o,parentOperationId:n.parentOperationId,startedAt:i,traceId:a};this._record({...s,metrics:n.metrics,status:"start"});try{let c=await r({operationId:o,traceId:a});return this._record({...s,durationMs:Date.now()-i,endedAt:Date.now(),metrics:{count:1,...n.metrics??{}},status:"success"}),c}catch(c){let d=m6(c);throw this._record({...s,context:{...this._context,...n.context,error:c},durationMs:Date.now()-i,endedAt:Date.now(),metrics:{count:1,...n.metrics??{}},status:d?"cancelled":"failure"}),d||this._logger.error("[pippit-asset-sdk] operation failed",t,c,n.context),c}}log(t,n={}){let r=Date.now(),i=NP(t),o=n.traceId??i;this._record({action:t,category:n.category??"pippit_asset",context:{...this._context,...n.context},metrics:n.metrics,operationId:i,parentOperationId:n.parentOperationId,startedAt:r,status:n.status??"log",traceId:o})}_record(t){this.ledger.add(t),eT({action:t.action,category:t.category,context:t.context,metrics:t.metrics,operationId:t.operationId,packageName:"pippit-asset-sdk",status:t.status,traceId:t.traceId})}};function NP(e){var n;let t=typeof((n=globalThis.crypto)==null?void 0:n.randomUUID)=="function"?globalThis.crypto.randomUUID():`${Date.now()}_${Math.random().toString(36).slice(2)}`;return`${e}_${t}`}function m6(e){return!!(e&&typeof e=="object"&&"name"in e&&e.name==="AbortError")}var dm=["200p","360p","480p","720p","1080p","2048p","origin"],um=["720p","1080p","2048p","480p","360p","200p","origin"],ks=["2048p","1080p","720p","480p","360p","200p","origin"];var f6={"200p":["200p","360p",...dm.filter(e=>e!=="200p")],"360p":["360p","480p","720p","200p","1080p","2048p","origin"],"480p":["480p","720p","1080p","2048p","360p","200p","origin"],"720p":um,"1080p":["1080p","2048p","720p","480p","360p","200p","origin"],"2048p":ks,origin:["origin","2048p","1080p","720p","480p","360p","200p"]};function Jd(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:void 0}function h6(e){let t=Jd(e.width)??0,n=Jd(e.height)??0,r=Jd(e.zoom)??1,i=Jd(e.devicePixelRatio)??Jd(globalThis.devicePixelRatio)??1;return Math.max(t,n)*r*i}function tT(e){if(!e)return"medium";let t=h6(e);return t>1440?"high":t>720?"medium":"low"}function wP(e){if(e.resolution)return f6[e.resolution];let t=tT(e.sourceOptions);return t==="high"?ks:t==="medium"?um:dm}function lr(){return new DOMException("Pippit asset source polling aborted.","AbortError")}var pm=class{constructor(t,n){this._resolver=t;this._onDetach=n;this._abortController=new AbortController;this._detached=!1;this._retainWhenOrphaned=!1;this._result={status:"pending"};this._started=!1;this._waiters=new Map}waitForResult(t,n=!1){if(t!=null&&t.aborted)return Promise.reject(lr());if(this._result.status==="fulfilled")return Promise.resolve(this._result.value);if(this._result.status==="rejected")return Promise.reject(this._result.error);if(this._result.status==="orphaned")return Promise.reject(lr());this._retainWhenOrphaned||=n;let r=Symbol("source-resolve-waiter"),i=new Promise((o,a)=>{let s={reject:a,resolve:o,signal:t};t&&(s.onAbort=()=>this._abortWaiter(r)),this._waiters.set(r,s),t&&s.onAbort&&t.addEventListener("abort",s.onAbort,{once:!0})});return this._start(),i}cancel(){if(this._result.status!=="pending")return;this._result={status:"orphaned"};let t=Array.from(this._waiters.values());this._waiters.clear(),this._detach(),this._abortController.abort();for(let n of t)this._cleanupWaiter(n),n.reject(lr())}_start(){if(this._started)return;this._started=!0;let t;try{t=this._resolver(this._abortController.signal)}catch(n){this._settle({status:"rejected",error:n});return}Promise.resolve(t).then(n=>this._settle({status:"fulfilled",value:n}),n=>this._settle({status:"rejected",error:n}))}_abortWaiter(t){let n=this._waiters.get(t);n&&(this._waiters.delete(t),this._cleanupWaiter(n),n.reject(lr()),this._waiters.size===0&&this._result.status==="pending"&&!this._retainWhenOrphaned&&this.cancel())}_settle(t){if(this._result.status!=="pending")return;this._result=t;let n=Array.from(this._waiters.values());this._waiters.clear(),this._detach();for(let r of n)this._cleanupWaiter(r),t.status==="fulfilled"?r.resolve(t.value):r.reject(t.error)}_cleanupWaiter(t){t.signal&&t.onAbort&&t.signal.removeEventListener("abort",t.onAbort)}_detach(){this._detached||(this._detached=!0,this._onDetach(this))}};var g6=["expires","expire","expiration","x-expires","x-everphoto-expires","x_expire","sign_expire","sign_expires"],y6=["x-amz-date","x-tos-date"],_6=["x-amz-expires","x-tos-expires"],T6=/\/[0-9a-f]{32}\/([0-9a-f]{8})\/video(?:\/|$)/i,S6=Date.UTC(2020,0,1)/1e3,b6=Date.UTC(2100,0,1)/1e3;function ia(e,t=Date.now()){let n=kP(e,t);return n===e.expiresAt?e:{...e,expiresAt:n}}function oa(e,t=Date.now()){return kP(e,t)-t>1e4}function kP(e,t){var a,s,c,d;let n=C6(e.expiresAt,e.url,t),r=(a=e.preview)==null?void 0:a.urls,o=[r==null?void 0:r.url,r==null?void 0:r.low,r==null?void 0:r.medium,r==null?void 0:r.high,r==null?void 0:r.poster,...((d=(c=(s=e.preview)==null?void 0:s.metadata)==null?void 0:c.spriteFrames)==null?void 0:d.images.map(u=>u.url))??[]].reduce((u,p)=>{let m=p?OP(p):void 0;return m===void 0?u:u===void 0?m:Math.min(u,m)},void 0);return o===void 0?n:Math.min(n,o)}function C6(e,t,n){return typeof e=="number"&&Number.isFinite(e)?e:OP(t)??n+12e5}function OP(e){let t=A6(e);if(!t)return;let n=I6(t.searchParams);if(n)return n;let r=v6(t.searchParams),i=x6(t.searchParams);return r&&i?r+i:P6(t.pathname)}function A6(e){try{return new URL(e,"https://pippit-asset-sdk.local")}catch{return}}function I6(e){for(let t of g6){let n=R6(nT(e,t));if(n)return n}}function v6(e){for(let t of y6){let n=nT(e,t);if(!n)continue;let r=D6(n)??Date.parse(n);if(Number.isFinite(r))return r}}function x6(e){for(let t of _6){let n=nT(e,t),r=n?Number(n):NaN;if(Number.isFinite(r)&&r>0)return r*1e3}}function R6(e){if(!e)return;let t=Number(e);if(Number.isFinite(t)&&t>0)return t>1e10?t:t*1e3;let n=Date.parse(e);return Number.isFinite(n)?n:void 0}function P6(e){let t=T6.exec(e);if(!t)return;let n=Number.parseInt(t[1],16);if(!(!Number.isFinite(n)||n<S6||n>b6))return n*1e3}function D6(e){let t=/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z$/.exec(e);if(!t)return;let[,n,r,i,o,a,s]=t;return Date.UTC(Number(n),Number(r)-1,Number(i),Number(o),Number(a),Number(s))}function nT(e,t){let n=t.toLowerCase();for(let[r,i]of e.entries())if(r.toLowerCase()===n&&i.trim())return i.trim()}var rT=3e4,LP=2,Os=class{constructor(){this._entries=new Map;this._inFlightResolves=new Map;this._refreshBudgets=new Map;this._refreshSuppressions=new Map;this._aliasInvalidationRevisions=new Map;this._keyRevisions=new Map;this._clearRevision=0}getRevision(t,n){let r=Array.from(mr(n)).sort().map(i=>`${i}:${this._aliasInvalidationRevisions.get(i)??0}`).join(",");return[this._clearRevision,this._keyRevisions.get(t)??0,r].join("|")}getCurrent(t,n,r){var i;return(i=this._findEntry(t,n,r))==null?void 0:i.entry.source}getUsable(t,n,r){let i=this._findEntry(t,n,r);if(i){if(oa(i.entry.source))return i.entry.source;this._entries.delete(i.key),this._bumpKeyRevision(i.key)}}set(t,n,r,i,o){return o!==void 0&&o!==this.getRevision(t,r)?!1:(this._entries.set(t,E6(r,i,n)),this._bumpKeyRevision(t),!0)}setInitial(t,n,r,i){this.getUsable(t,r,i)||oa(n)&&this.set(t,n,r,i)}resolveInFlight(t,n,r,i,o){var d;if((d=i.signal)!=null&&d.aborted)return Promise.reject(lr());let a=this.getRevision(t,n),s=this._findInFlightResolve(t,n,r);if((s==null?void 0:s.entry.revision)===a)return s.entry.task.waitForResult(i.signal,i.inFlightLifetime==="client");let c=new pm(u=>o(a,u),u=>{this._deleteInFlightResolveByTask(u)});return this._inFlightResolves.set(t,{aliases:mr(n),revision:a,scopeKey:ti(r),task:c}),c.waitForResult(i.signal,i.inFlightLifetime==="client")}hasInFlightResolve(t,n,r){let i=this._findInFlightResolve(t,n,r);return!!(i&&i.entry.revision===this.getRevision(t,n))}markRefreshRequested(t,n,r,i){var a;if(!i)return;let o=((a=this._findRefreshSuppression(t,n,r))==null?void 0:a.entry)??M6(n,r);o.versions.add(i),this._refreshSuppressions.set(t,o)}shouldSuppressRefresh(t,n,r,i){var o;return i?!!((o=this._findRefreshSuppression(t,n,r))!=null&&o.entry.versions.has(i)):!1}markRefreshAttempt(t,n,r,i){var c;let o=((c=this._findRefreshBudget(t,n,r))==null?void 0:c.entry)??N6(n,r),a=o.records.get(i),s=Date.now();!a||s-a.windowStartedAt>=rT?o.records.set(i,{attempts:1,windowStartedAt:s}):a.attempts+=1,this._refreshBudgets.set(t,o)}shouldSuppressRefreshByBudget(t,n,r,i){var a;let o=(a=this._findRefreshBudget(t,n,r))==null?void 0:a.entry.records.get(i);return!o||Date.now()-o.windowStartedAt>=rT?!1:o.attempts>=LP}getRefreshBudgetPolicy(){return{maxAttempts:LP,windowMs:rT}}dispose(){this._cancelInFlightResolves(this._inFlightResolves.values()),this.invalidate()}invalidate(t){if(!t){this._entries.clear(),this._inFlightResolves.clear(),this._refreshBudgets.clear(),this._refreshSuppressions.clear(),this._clearRevision+=1;return}let n=mr(t);for(let[r,i]of Array.from(this._entries.entries()))Ji(i.aliases,n)&&(this._entries.delete(r),this._bumpKeyRevision(r));for(let[r,i]of Array.from(this._inFlightResolves.entries()))Ji(i.aliases,n)&&this._inFlightResolves.delete(r);for(let[r,i]of Array.from(this._refreshSuppressions.entries()))Ji(i.aliases,n)&&this._refreshSuppressions.delete(r);for(let[r,i]of Array.from(this._refreshBudgets.entries()))Ji(i.aliases,n)&&this._refreshBudgets.delete(r);for(let r of n)this._aliasInvalidationRevisions.set(r,(this._aliasInvalidationRevisions.get(r)??0)+1)}_findEntry(t,n,r){let i=this._entries.get(t);if(i)return{entry:i,key:t};if(!n||!r)return;let o=mr(n),a=ti(r);for(let[s,c]of this._entries.entries())if(c.scopeKey===a&&Ji(c.aliases,o))return{entry:c,key:s}}_findRefreshSuppression(t,n,r){let i=this._refreshSuppressions.get(t);if(i)return{entry:i,key:t};let o=mr(n),a=ti(r);for(let[s,c]of this._refreshSuppressions.entries())if(c.scopeKey===a&&Ji(c.aliases,o))return{entry:c,key:s}}_findRefreshBudget(t,n,r){let i=this._refreshBudgets.get(t);if(i)return{entry:i,key:t};let o=mr(n),a=ti(r);for(let[s,c]of this._refreshBudgets.entries())if(c.scopeKey===a&&Ji(c.aliases,o))return{entry:c,key:s}}_findInFlightResolve(t,n,r){let i=this._inFlightResolves.get(t);if(i)return{entry:i,key:t};let o=mr(n),a=ti(r);for(let[s,c]of this._inFlightResolves.entries())if(c.scopeKey===a&&Ji(c.aliases,o))return{entry:c,key:s}}_deleteInFlightResolveByTask(t){for(let[n,r]of this._inFlightResolves.entries())if(r.task===t){this._inFlightResolves.delete(n);return}}_cancelInFlightResolves(t){new Set(Array.from(t,n=>n.task)).forEach(n=>n.cancel())}_bumpKeyRevision(t){this._keyRevisions.set(t,(this._keyRevisions.get(t)??0)+1)}};function GP(e,t){return[w6(e),ti(t)].join("|")}function E6(e,t,n){return{aliases:mr(e,n),scopeKey:ti(t),source:n}}function M6(e,t){return{aliases:mr(e),scopeKey:ti(t),versions:new Set}}function N6(e,t){return{aliases:mr(e),records:new Map,scopeKey:ti(t)}}function w6(e){return[e.pippitAssetId?`pippit:${e.pippitAssetId}`:"",e.assetId?`asset:${e.assetId}`:""].filter(Boolean).join("|")}function ti(e){let t=e.mediaType==="image"?e.resolution??tT(e.sourceOptions):"",n=e.mediaType==="image"&&e.allowProvisionalImage===!1?"final-only":"";return[e.mediaType,e.purpose,e.imageVariant??"",t,n].join("|")}function mr(e,t){let n=t==null?void 0:t.identity;return n!=null&&n.assetId||n!=null&&n.pippitAssetId?new Set([FP(n.pippitAssetId),BP(n.assetId)].filter(r=>!!r)):new Set([FP(e.pippitAssetId),BP(e.assetId)].filter(r=>!!r))}function FP(e){return e?En({pippitAssetId:e}):void 0}function BP(e){return e?En({assetId:e}):void 0}function Ji(e,t){for(let n of t)if(e.has(n))return!0;return!1}function zP(e){return e instanceof File?e:new File([e],"pippit-upload.bin",{type:e.type||"application/octet-stream"})}function UP(){var t;return`upload_${typeof((t=globalThis.crypto)==null?void 0:t.randomUUID)=="function"?globalThis.crypto.randomUUID():`${Date.now()}_${Math.random().toString(36).slice(2)}`}`}function VP(e){var t;sn((t=e.runtime.storage)==null?void 0:t.putUploadTask({assetId:e.result.assetId,pippitAssetId:e.result.pippitAssetId,status:e.status,taskId:e.taskId,updatedAt:Date.now()}))}function qP(e){e.runtime.log("upload_task_success",{context:{asset_id:e.result.assetId,pippit_asset_id:e.result.pippitAssetId,task_id:e.taskId}})}function KP(e){e.runtime.log("upload_task_failure",{context:{error:e.error,task_id:e.taskId},status:"failure"})}function jP({runtime:e,transport:t}){return{createUploadTask(n,r={}){return new lm(n,r,t,e)},async uploadFile(n,r={}){return new lm(n,r,t,e).start()}}}var lm=class{constructor(t,n,r,i){this._options=n;this._transport=r;this._runtime=i;this._status="pending";this._taskId=UP();this._file=zP(t),this._runtime.log("upload_task_create",{context:{file_type:this._file.type,task_id:this._taskId},metrics:{file_size:this._file.size}})}cancel(){var t;this._status="cancelled",(t=this._abortController)==null||t.abort(),this._runtime.log("upload_task_cancel",{context:{task_id:this._taskId}})}getSnapshot(){return{error:this._error,progress:this._progress,result:this._result,status:this._status,taskId:this._taskId}}async retry(){return this._runtime.log("upload_task_retry",{context:{resume_mode:"restart",task_id:this._taskId}}),this.start()}async start(){if(this._status==="cancelled")throw new Error("Upload task has been cancelled.");return this._status="uploading",this._runtime.run("upload_task_start",{context:{file_type:this._file.type,task_id:this._taskId},metrics:{file_size:this._file.size}},async()=>{let t=this._createAbortController();this._abortController=t;try{let n=await this._transport.upload(this._file,{onProgress:r=>this._handleProgress(r),signal:t.signal});return this._handleUploadSuccess(n),n}catch(n){throw this._handleUploadFailure(n),n}finally{this._abortController===t&&(this._abortController=void 0)}})}_createAbortController(){var r,i;let t=new AbortController,n=()=>t.abort();return(r=this._options.signal)!=null&&r.aborted?(n(),t):((i=this._options.signal)==null||i.addEventListener("abort",n,{once:!0}),t)}_handleProgress(t){var n,r;this._progress=t,this._runtime.log("upload_task_progress",{context:{task_id:this._taskId},metrics:{loaded:t.loaded,percentage:t.percentage,total:t.total}}),(r=(n=this._options).onProgress)==null||r.call(n,t)}_handleUploadSuccess(t){this._result=t,this._status="success",VP({result:t,runtime:this._runtime,status:this._status,taskId:this._taskId}),qP({result:t,runtime:this._runtime,taskId:this._taskId})}_handleUploadFailure(t){this._error=t instanceof Error?t:new Error(String(t)),this._status!=="cancelled"&&(this._status="failed"),KP({error:this._error,runtime:this._runtime,taskId:this._taskId})}};var k6=new Set(["audio","image","video"]),O6=new Set(["file","text"]);function HP(e){return!!(e.mediaType&&k6.has(e.mediaType))}function iT(e,t){return e.some(n=>n.mediaType&&O6.has(n.mediaType))?{...t,cachePolicy:"refresh"}:t}function WP(e){let{invalidateSources:t,runtime:n,transport:r}=e,i=(s,c)=>{let d=_e(s);return n.run("asset_refresh",{context:vt(d)},async()=>{let u=await mm(r,d,{cachePolicy:"refresh",signal:c});return Qi(n,u),u})},o=(s,c,d={})=>{let u=s.map(_e),p=Qd(u),m,f=u;return n.run("asset_subscribe_open",p,()=>{var h;r.subscribeAssetEvents&&(m=r.subscribeAssetEvents(u,g=>{var _,S,T,C,I;let y=_e(g.ref);(_=r.invalidateAssets)==null||_.call(r,[y]),t==null||t(y),sn((T=(S=n.storage)==null?void 0:S.deleteAssetMetadata)==null?void 0:T.call(S,y)),sn((I=(C=n.storage)==null?void 0:C.deleteUrlLeases)==null?void 0:I.call(C,y)),c({...g,ref:y})},d),(h=m.syncAssetRefs)==null||h.call(m,f))}).catch(()=>{}),{close:()=>{n.run("asset_subscribe_close",p,()=>{m==null||m.close(),m=void 0}).catch(()=>{})},syncAssetRefs:h=>{var y;let g=h.map(_e);f=g,n.log("asset_subscribe_sync",{...Qd(g),metrics:{request_count:g.length}}),(y=m==null?void 0:m.syncAssetRefs)==null||y.call(m,g)}}};return{createAsset:async s=>n.run("asset_create",q6(s),async()=>{if(!r.createAsset)throw new Error("Pippit asset create transport is not configured.");let c=YP(await r.createAsset(G6(s)));return $P(n,c),XP(n,r,c,s.refresh!==!1,s.signal)}),getAsset:async(s,c={})=>{let d=_e(s);return n.run("asset_query",{context:vt(d)},async()=>{let u=await mm(r,d,c);return Qi(n,u),u})},getAssets:async(s,c={})=>{let d=s.map(_e);return n.run("asset_batch_query",Qd(d),async()=>{let u=await oT(r,d,c);return u.forEach(p=>Qi(n,p)),u})},queryAssets:async(s,c={})=>{let d=s.map(_e);return n.run("asset_batch_query",Qd(d),async()=>{let u=await L6(r,d,c);return u.forEach(({asset:p})=>{p&&Qi(n,p)}),u})},invalidate:(s,c={})=>{var p,m,f,h,g;let d=_e(s);(p=r.invalidateAssets)==null||p.call(r,[d]);let u=c.scope??"all";(u==="all"||u==="metadata")&&sn((f=(m=n.storage)==null?void 0:m.deleteAssetMetadata)==null?void 0:f.call(m,d)),(u==="all"||u==="source")&&(t==null||t(d),sn((g=(h=n.storage)==null?void 0:h.deleteUrlLeases)==null?void 0:g.call(h,d))),n.log("asset_invalidate",{context:{...vt(d),invalidate_scope:u}})},patchAssets:async s=>n.run("asset_batch_patch",K6(s),async()=>{var p;if(!r.patchAssets)throw new Error("Pippit asset patch transport is not configured.");let c=z6(s),d=await r.patchAssets(c),u=await U6(n,r,c,d,s.refresh!==!1);return fm(c.patches.map(m=>m.ref)).forEach(m=>t==null?void 0:t(m)),(p=r.invalidateAssets)==null||p.call(r,fm(c.patches.map(m=>m.ref))),u}),refresh:i,subscribeAssetEvents:o,updateAsset:async(s,c)=>{let d=_e(s);return n.run("asset_update",{context:vt(d)},async()=>{if(!r.updateAsset)throw new Error("Pippit asset update transport is not configured.");let u=YP(await r.updateAsset(d,c));$P(n,u);let p=await XP(n,r,u,c.refresh!==!1,c.signal);return t==null||t(u.ref),p})},watchAsset:(s,c,d={})=>{let u=_e(s);if(n.log("asset_subscribe_start",{context:vt(u)}),r.subscribeAssetEvents){let p=o([u],m=>{V6({event:m,invalidateSources:t,listener:c,ref:u,runtime:n,shouldRefresh:d.refreshOnChange!==!1,signal:d.signal,transport:r}).catch(f=>{n.log("asset_update_refresh_failure",{context:{...vt(u),error:f},status:"failure"})})},d);return()=>{n.log("asset_subscribe_stop",{context:vt(u)}),p.close()}}return n.log("asset_subscribe_unavailable",{context:vt(u)}),()=>{n.log("asset_subscribe_stop",{context:vt(u)})}}}}async function mm(e,t,n){let i=(await oT(e,[t],n))[0];if(!i)throw new Error("Pippit asset query returned no asset.");return i}async function oT(e,t,n){if(!e.queryAssets)throw new Error("Pippit asset query transport is not configured.");let r=await e.queryAssets(t,iT(t,{batchingStrategy:n.batchingStrategy,cachePolicy:n.cachePolicy,dispatchMode:n.dispatchMode,signal:n.signal}));return F6(t,r)}async function L6(e,t,n){if(!e.queryAssets)throw new Error("Pippit asset query transport is not configured.");let r=await e.queryAssets(t,iT(t,{batchingStrategy:n.batchingStrategy,cachePolicy:n.cachePolicy,dispatchMode:n.dispatchMode,signal:n.signal}));return B6(t,r)}function F6(e,t){let n=[...t];return e.map(r=>{let i=n.findIndex(a=>JP(a,r));if(i<0)throw new Error(`Pippit asset query missing result for ref: ${En(r)}`);let[o]=n.splice(i,1);if(!o)throw new Error(`Pippit asset query missing result for ref: ${En(r)}`);return o})}function B6(e,t){let n=[...t];return e.map(r=>{let i=n.findIndex(a=>JP(a,r));if(i<0)return{asset:null,ref:r};let[o]=n.splice(i,1);return{asset:o??null,ref:r}})}function JP(e,t){return t.pippitAssetId&&e.pippitAssetId!==t.pippitAssetId||t.assetId&&e.assetId!==t.assetId?!1:!!(t.pippitAssetId||t.assetId)}function Qi(e,t){var n;HP(t)&&sn((n=e.storage)==null?void 0:n.putAssetMetadata(Q_(t)))}function $P(e,t){t.asset&&Qi(e,t.asset)}function G6(e){return{...e,ref:e.ref?_e(e.ref):void 0}}function z6(e){return{...e,patches:e.patches.map(t=>({...t,ref:_e(t.ref)})),rootRef:e.rootRef?_e(e.rootRef):void 0}}function YP(e){return{...e,ref:_e(e.ref)}}async function XP(e,t,n,r,i){if(!r||!t.queryAssets)return n;let o=await mm(t,n.ref,{cachePolicy:"refresh",signal:i});return Qi(e,o),{...n,asset:o}}async function U6(e,t,n,r,i){if(!i||!t.queryAssets)return r;let o=fm(n.patches.map(s=>s.ref)),a=await oT(t,o,{cachePolicy:"refresh",signal:n.signal});return a.forEach(s=>Qi(e,s)),{...r,assets:a}}async function V6(e){var r,i,o;let t=_e({...e.ref,...e.event.ref});e.runtime.log("asset_update_received",{context:{...vt(t),event_type:e.event.eventType,version:e.event.version}}),(i=(r=e.transport).invalidateAssets)==null||i.call(r,[t]);let n=e.event.asset??(e.shouldRefresh&&e.transport.queryAssets?await mm(e.transport,t,{cachePolicy:"refresh",signal:e.signal}):void 0);if(!n){e.runtime.log("asset_update_refresh_skipped",{context:vt(t)});return}Qi(e.runtime,n),(o=e.invalidateSources)==null||o.call(e,t),e.listener(n),e.runtime.log("asset_update_applied",{context:{...vt(t),event_type:e.event.eventType,version:e.event.version}})}function q6(e){return{context:{...e.ref?vt(_e(e.ref)):{},media_type:e.mediaType}}}function K6(e){let t=fm(e.patches.map(n=>_e(n.ref)));return{...Qd(t),metrics:{patch_count:e.patches.length,request_count:t.length}}}function fm(e){let t=new Set,n=[];for(let r of e){let i=En(r);t.has(i)||(t.add(i),n.push(r))}return n}function Qd(e){return{context:{asset_id:e.map(t=>t.assetId).filter(Boolean).join(",")||void 0,pippit_asset_id:e.map(t=>t.pippitAssetId).filter(Boolean).join(",")||void 0,request_count:e.length},metrics:{request_count:e.length}}}var QP=(e,t)=>Number.isFinite(e)?Math.max(1,Math.floor(e)):t,aT=class{constructor(t,n){this.allocate=t;this.options=n;this.buffer=[];this.cursor=0;this.refillFailureCount=0;this.refillRetryAt=0;this.disposed=!1;this.seen=new Set;this.init=()=>this.refill();this.take=()=>{if(this.disposed)return;let t=this.buffer[this.cursor];if(t===void 0){this.refillIfNeeded();return}return this.cursor+=1,this.compactIfNeeded(),this.refillIfNeeded(),t};this.mustTake=()=>{let t=this.take();if(!t)throw new Error("[PippitAssetIdPool] id pool is empty");return t};this.takeMany=t=>{let n=[];for(let r=0;r<Math.max(0,Math.floor(t));r+=1){let i=this.take();if(!i)break;n.push(i)}return n};this.available=()=>this.buffer.length-this.cursor;this.isRefilling=()=>!!this.refillPromise;this.waitForIdle=()=>this.refillPromise??Promise.resolve();this.refill=(t=!1)=>{if(this.disposed)return Promise.resolve();if(this.refillPromise)return this.refillPromise;if(!t&&Date.now()<this.refillRetryAt)return Promise.resolve();let n=this.maxBufferSize-this.available();if(n<=0||!t&&this.available()>this.lowWaterMark)return Promise.resolve();let r=Math.min(this.batchSize,n);return this.refillPromise=this.allocate(r).then(i=>{for(let o of i){let a=o.trim();!a||this.seen.has(a)||this.available()>=this.maxBufferSize||(this.seen.add(a),this.buffer.push(a))}this.resetRefillFailures()}).catch(i=>{throw this.recordRefillFailure(),i}).finally(()=>{this.refillPromise=void 0}),this.refillPromise};this.clear=()=>{this.buffer=[],this.cursor=0,this.seen.clear(),this.resetRefillFailures()};this.dispose=()=>{this.disposed=!0,this.clear()};this.batchSize=QP(n.batchSize,1e3),this.lowWaterMark=Math.max(0,Math.floor(n.lowWaterMark??200)),this.maxBufferSize=QP(n.maxBufferSize,1e3)}refillIfNeeded(){this.available()>this.lowWaterMark||this.refill().catch(t=>{var n,r;return(r=(n=this.options).onRefillError)==null?void 0:r.call(n,t)})}recordRefillFailure(){if(this.refillFailureCount+=1,this.refillFailureCount===1)return;let t=Math.min(5e3*2**(this.refillFailureCount-2),6e4);this.refillRetryAt=Date.now()+t}resetRefillFailures(){this.refillFailureCount=0,this.refillRetryAt=0}compactIfNeeded(){this.cursor<=100||this.cursor<=this.buffer.length/2||(this.buffer=this.buffer.slice(this.cursor),this.cursor=0)}};function ZP(e){let t=new Set,n=!1,r=async i=>{if(n)throw new Error("Pippit asset client is disposed.");let o=Math.max(0,Math.floor(i));if(o===0)return[];if(!e.allocateAssetIds)throw new Error("Pippit asset ID transport is not configured.");let s=(await e.allocateAssetIds(o)).map(c=>c.trim()).filter(Boolean);if(s.length<o)throw new Error(`Pippit asset ID allocation returned ${s.length}/${o} IDs.`);if(new Set(s).size!==s.length)throw new Error("Pippit asset ID allocation returned duplicate IDs.");return s};return{module:{allocate:r,createPool:(i={})=>{if(n)throw new Error("Pippit asset client is disposed.");let o=new aT(r,i);return t.add(o),o}},dispose:()=>{n=!0,t.forEach(i=>i.dispose()),t.clear()}}}var eD=new WeakMap,xt=class extends Error{constructor(n="Pippit asset source is not ready.",r={}){super(n);this.code="PIPPIT_ASSET_SOURCE_NOT_READY";this.name="PippitAssetSourceNotReadyError",this.logId=r.logId}};function fr(e){return e instanceof xt}function sT(e,t){return eD.set(e,{...t}),e}function hm(e){let t=fr(e)?eD.get(e):void 0;return t?{...t}:void 0}var j6=new Set(["200p","360p","480p","720p","1080p","2048p","origin"]);function tD(e){var r;let t=ia(e.source),n=e.sourceOptions.resolution??H6(t);sn((r=e.runtime.storage)==null?void 0:r.putUrlLease(Z_(e.ref,{imageVariant:e.sourceOptions.imageVariant,mediaType:e.sourceOptions.mediaType,purpose:e.sourceOptions.purpose,resolution:n,source:t})))}function H6(e){var n;let t=(n=e.metadata)==null?void 0:n.resolution;return typeof t=="string"&&j6.has(t)?t:void 0}var $6=1500,Y6=40,X6=new Set(["audio","image","video"]),W6="AssetQuery did not return an asset_id for source resolution.";function dT(e){return J6(e.sourceOptions.mediaType),new cT(e)}var cT=class{constructor(t){this._options=t;this._disposed=!1;this._actionPrefix=`${t.sourceOptions.mediaType}_source`,this._sourceKey=GP(t.ref,t.sourceOptions),this._store=t.store??new Os,t.sourceOptions.initialSource&&!t.sourceOptions.shouldUseInitialSource&&(this._initialSourceAllowed=!0,this._store.setInitial(this._sourceKey,ia(t.sourceOptions.initialSource),t.ref,t.sourceOptions))}dispose(){this._disposed=!0}getCurrentSource(){if(this._disposed||this._options.sourceOptions.shouldUseInitialSource&&this._initialSourceAllowed!==!0)return;let t=this._store.getCurrent(this._sourceKey,this._options.ref,this._options.sourceOptions);return t&&oa(t)?t:void 0}async getSource(t){return this._assertActive(),this._options.runtime.run(`${this._actionPrefix}_resolve`,{context:this._buildContext()},()=>this._requiresInitialSourceDecision()?this._prepareInitialSource().then(()=>this._getSourceAfterInitialSourceDecision(t)):this._getSourceAfterInitialSourceDecision(t))}async refresh(t){if(this._assertActive(),this._shouldReturnSuppressedRefresh(t))return this._store.getCurrent(this._sourceKey,this._options.ref,this._options.sourceOptions);if(!this._store.hasInFlightResolve(this._sourceKey,this._options.ref,this._options.sourceOptions)){let n=this._getBudgetSuppressedRefreshSource(t);if(n)return n}return this._runRefresh(t).then(n=>(this._store.markRefreshRequested(this._sourceKey,this._options.ref,this._options.sourceOptions,t.sourceVersion),n))}_assertActive(){if(this._disposed)throw new Error("Pippit asset source controller is disposed.")}_requiresInitialSourceDecision(){let{initialSource:t,shouldUseInitialSource:n}=this._options.sourceOptions;return!!(t&&n&&this._initialSourceAllowed===void 0)}_getSourceAfterInitialSourceDecision(t){let n=this._store.getCurrent(this._sourceKey,this._options.ref,this._options.sourceOptions),r=this._store.getUsable(this._sourceKey,this._options.ref,this._options.sourceOptions);return r&&oa(r)?(this._options.runtime.log(`${this._actionPrefix}_cache_hit`,{context:this._buildContext(),status:"log"}),r):this._resolveSource({inFlightLifetime:t==null?void 0:t.inFlightLifetime,refresh:!!n,signal:t==null?void 0:t.signal})}async _prepareInitialSource(){let{initialSource:t,shouldUseInitialSource:n}=this._options.sourceOptions;if(!t||!n||this._initialSourceAllowed!==void 0)return;this._initialSourceDecisionPromise??=Promise.resolve(n());let r=await this._initialSourceDecisionPromise;if(this._assertActive(),this._initialSourceAllowed=r,!r){this._store.invalidate(this._options.ref);return}this._store.setInitial(this._sourceKey,ia(t),this._options.ref,this._options.sourceOptions)}_shouldReturnSuppressedRefresh(t){return this._store.shouldSuppressRefresh(this._sourceKey,this._options.ref,this._options.sourceOptions,t.sourceVersion)?(this._options.runtime.log(`${this._actionPrefix}_refresh`,{context:this._buildRefreshContext(t,{refresh_suppressed:!0}),status:"log"}),!!this._store.getCurrent(this._sourceKey,this._options.ref,this._options.sourceOptions)):!1}_getBudgetSuppressedRefreshSource(t){let n=this._store.getCurrent(this._sourceKey,this._options.ref,this._options.sourceOptions);if(!n||!this._store.shouldSuppressRefreshByBudget(this._sourceKey,this._options.ref,this._options.sourceOptions,t.reason))return;let r=this._store.getRefreshBudgetPolicy();return this._options.runtime.log(`${this._actionPrefix}_refresh`,{context:this._buildRefreshContext(t,{refresh_budget_max_attempts:r.maxAttempts,refresh_budget_window_ms:r.windowMs,refresh_suppressed:!0,refresh_suppression_reason:"refresh_budget_exhausted"}),status:"log"}),n}_runRefresh(t){return this._options.runtime.run(`${this._actionPrefix}_refresh`,{context:this._buildRefreshContext(t)},()=>this._resolveSource({onSharedResolveStart:()=>{this._store.markRefreshAttempt(this._sourceKey,this._options.ref,this._options.sourceOptions,t.reason)},refresh:!0,signal:t.signal}))}async _resolveSource(t){return this._throwIfAborted(t.signal),this._store.resolveInFlight(this._sourceKey,this._options.ref,this._options.sourceOptions,{inFlightLifetime:t.inFlightLifetime,signal:t.signal},(n,r)=>{var i;return(i=t.onSharedResolveStart)==null||i.call(t),this._resolveSourceWithRevision({refresh:t.refresh,signal:r},n,{commitAfterDispose:!0})})}async _resolveSourceWithRevision(t,n,r={}){let i={effectiveRef:this._options.ref},o=await this._resolveSourceWithPolling(t,i);this._throwIfAborted(t.signal);let a=ia(this._applyResolvedRefIdentity(o,i.resolvedRef));if((r.commitAfterDispose||!this._disposed)&&this._store.set(this._sourceKey,a,this._options.ref,this._options.sourceOptions,n))return tD({ref:this._options.ref,runtime:this._options.runtime,source:a,sourceOptions:this._options.sourceOptions}),a;let c=this._store.getUsable(this._sourceKey,this._options.ref,this._options.sourceOptions);if(c)return c;throw new Error("Pippit asset source resolve was superseded.")}async _resolveSourceWithPolling(t,n){let r=this._resolvePollingOptions(),i;for(let o=1;o<=r.maxAttempts;o+=1){this._throwIfAborted(t.signal);try{return await this._resolveSourceOnce(t,n.effectiveRef)}catch(a){this._advanceResolvedVideoPreviewRef(a,n);let s=this._normalizeAssetBindingError(a);if(!fr(s)||o>=r.maxAttempts){i=s;break}i=s,this._logPollAttempt(o,r.maxAttempts),await nD(t.signal,r.intervalMs)}}if(!this._shouldEnterSlowPolling(r,i))throw i instanceof Error?i:new Error("Pippit asset source polling exhausted.");return this._resolveSourceWithSlowPolling(t,r,n)}async _resolveSourceWithSlowPolling(t,n,r){this._logSlowPollingStart(n);let i=0;for(;n.slowMaxAttempts===void 0||i<n.slowMaxAttempts;){i+=1,await nD(t.signal,n.slowIntervalMs??0),this._throwIfAborted(t.signal);try{return await this._resolveSourceOnce(t,r.effectiveRef)}catch(o){this._advanceResolvedVideoPreviewRef(o,r);let a=this._normalizeAssetBindingError(o);if(!fr(a))throw a;this._logSlowPollAttempt(i,n.slowMaxAttempts)}}throw new Error("Pippit asset source slow polling exhausted.")}async _resolveSourceOnce(t,n){let{sourceOptions:r,transport:i}=this._options;if(!i.resolveSource)throw new Error("Pippit asset source transport is not configured.");let{initialSource:o,shouldUseInitialSource:a,telemetry:s,waitForAssetBinding:c,...d}=r,u=ia(await i.resolveSource(n,{...d,refresh:t.refresh,signal:t.signal}));if(oa(u))return u;if(!t.refresh)return this._resolveSourceOnce({...t,refresh:!0},n);throw new Error("Pippit asset source transport returned an expired URL lease.")}_advanceResolvedVideoPreviewRef(t,n){var a;let{ref:r,sourceOptions:i}=this._options,o=hm(t);if(!(!fr(t)||!o||i.mediaType!=="video"||i.purpose!=="preview"||!r.pippitAssetId||r.assetId)){if(!o.assetId||o.pippitAssetId!==r.pippitAssetId)throw new Error("Resolved video asset ref does not match the requested pippitAssetId.");if(o.mediaType&&o.mediaType!=="video")throw new Error("Resolved video asset ref has an incompatible mediaType.");if((a=n.resolvedRef)!=null&&a.assetId&&n.resolvedRef.assetId!==o.assetId)throw new Error("Resolved video asset ref changed during source polling.");n.resolvedRef={assetId:o.assetId,mediaType:"video",pippitAssetId:r.pippitAssetId},n.effectiveRef={assetId:o.assetId,mediaType:"video"}}}_applyResolvedRefIdentity(t,n){var r,i;if(!(n!=null&&n.assetId)||!n.pippitAssetId)return t;if((r=t.identity)!=null&&r.assetId&&t.identity.assetId!==n.assetId)throw new Error("Resolved video source assetId does not match the polled assetId.");if((i=t.identity)!=null&&i.pippitAssetId&&t.identity.pippitAssetId!==n.pippitAssetId)throw new Error("Resolved video source pippitAssetId does not match the requested asset.");return{...t,identity:{...t.identity,assetId:n.assetId,pippitAssetId:n.pippitAssetId},metadata:{...t.metadata,assetId:n.assetId,pippitAssetId:n.pippitAssetId}}}_normalizeAssetBindingError(t){return this._options.sourceOptions.waitForAssetBinding&&t instanceof Error&&t.message===W6?new xt(t.message):t}_resolvePollingOptions(){let t=this._options.sourceOptions.polling;if(t===!1)return{intervalMs:0,maxAttempts:1};let n=this._options.sourceOptions.mediaType==="video"&&this._options.sourceOptions.purpose==="preview";return{intervalMs:(t==null?void 0:t.intervalMs)??(n?$6:0),maxAttempts:(t==null?void 0:t.maxAttempts)??(n?Y6:1),slowIntervalMs:t==null?void 0:t.slowIntervalMs,slowMaxAttempts:t==null?void 0:t.slowMaxAttempts}}_shouldEnterSlowPolling(t,n){return!!(t.slowIntervalMs&&fr(n))}_logPollAttempt(t,n){this._options.runtime.log(`${this._actionPrefix}_wait`,{context:{...this._buildContext(),poll_attempt:t,poll_max_attempts:n,wait_reason:"source_not_ready"},metrics:{poll_attempt:t},status:"log"})}_logSlowPollingStart(t){this._options.runtime.log(`${this._actionPrefix}_slow_wait_start`,{context:{...this._buildContext(),poll_max_attempts:t.maxAttempts,slow_interval_ms:t.slowIntervalMs,slow_max_attempts:t.slowMaxAttempts,wait_reason:"source_not_ready"},metrics:{poll_max_attempts:t.maxAttempts},status:"log"})}_logSlowPollAttempt(t,n){this._options.runtime.log(`${this._actionPrefix}_slow_wait`,{context:{...this._buildContext(),slow_poll_attempt:t,slow_poll_max_attempts:n,wait_reason:"source_not_ready"},metrics:{slow_poll_attempt:t},status:"log"})}_throwIfAborted(t){if(t!=null&&t.aborted)throw lr()}_buildContext(){let t=this._options.sourceOptions.sourceOptions;return{...vt(this._options.ref),image_variant:this._options.sourceOptions.imageVariant,media_type:this._options.sourceOptions.mediaType,purpose:this._options.sourceOptions.purpose,resolution:this._options.sourceOptions.resolution,source_device_pixel_ratio:t==null?void 0:t.devicePixelRatio,source_height:t==null?void 0:t.height,source_width:t==null?void 0:t.width,source_zoom:t==null?void 0:t.zoom,...this._options.sourceOptions.telemetry}}_buildRefreshContext(t,n={}){return{...this._buildContext(),refresh_reason:t.reason,source_version:t.sourceVersion,...n}}};function nD(e,t){return e!=null&&e.aborted?Promise.reject(lr()):t<=0?Promise.resolve():new Promise((n,r)=>{let i=globalThis.setTimeout(()=>{e==null||e.removeEventListener("abort",o),n()},t),o=()=>{globalThis.clearTimeout(i),r(lr())};e==null||e.addEventListener("abort",o,{once:!0})})}function J6(e){if(!X6.has(e))throw new Error("Pippit asset source controller only supports image, video, and audio assets.")}function rD(e){let{runtime:t,sourceLeaseStore:n,transport:r}=e,i=(a,s)=>dT({ref:_e(a),runtime:t,sourceOptions:s,store:n,transport:r});return{createController:i,resolve:async(a,s,c={})=>{var u;let d=i(a,s);try{return c.cachePolicy==="refresh"?await d.refresh({reason:c.reason??"source_resolve_refresh",signal:c.signal,sourceVersion:(u=d.getCurrentSource())==null?void 0:u.version}):await d.getSource({inFlightLifetime:c.inFlightLifetime,signal:c.signal})}finally{d.dispose()}}}}function iD(e){return e.upload?e.upload:{async upload(){throw new Error("Pippit asset upload transport is not configured.")},resumeMode:"restart"}}function gm(e){let t=ws(e.logger),n=e.storage===!1?void 0:e.storage,r=new cm({context:{uid:e.uid,workspace:e.workspace,...e.telemetry??{}},logger:t,storage:n}),{transport:i}=e,o=iD(i),a=new Os,s=rD({runtime:r,sourceLeaseStore:a,transport:i}),c=WP({invalidateSources:p=>a.invalidate(p),runtime:r,transport:i}),d=ZP(i),u=jP({runtime:r,transport:o});return{assets:c,sources:s,diagnostics:{records:r.ledger},dispose:()=>{var p;a.dispose(),d.dispose(),(p=i.dispose)==null||p.call(i)},ids:d.module,upload:{createUploadTask:u.createUploadTask,uploadFile:(p,m)=>u.uploadFile(p,m)}}}var _m="AssetSnapshot",Tm="AssetJsonUpdate",Z6=["audio","file","image","text","video"];function e9(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}}function t9(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}}function n9(e){return Z6.includes(e)?e:void 0}function ym(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function aa(e,...t){for(let n of t)if(n in e)return e[n]}function uT(e,...t){let n=aa(e,...t);return typeof n=="string"&&n.trim()?n.trim():void 0}function oD(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()){let t=Number(e);return Number.isFinite(t)?t:void 0}}function r9(e){let t=uT(e,"pippitAssetId","pippit_asset_id"),n=uT(e,"assetId","asset_id"),r=n9(uT(e,"mediaType","media_type"));if(!(!t&&!n))return _e({...n?{assetId:n}:{},...r?{mediaType:r}:{},...t?{pippitAssetId:t}:{}})}function i9(e){return e===_m?"snapshot":e===Tm||e==="message"?"update":e==="delete"||e==="AssetDelete"?"delete":"unknown"}function pT(e,t){let n=e9(t),r=ym(n);if(!r)return;let i=ym(aa(r,"data","Data")),o=ym(aa(r,"assetEvent","asset_event"))??(i?ym(aa(i,"assetEvent","asset_event")):void 0)??i??r,a=r9(o);if(a)return{content:t9(aa(o,"content")),eventType:i9(e),raw:r,ref:a,startVersion:oD(aa(o,"startVersion","start_version")),version:oD(aa(o,"version","Version"))}}async function sD(e,t){let n=e.getReader(),r;for(;!(r=await n.read()).done;)t(r.value)}function cD(e){let t,n,r,i=!1;return function(a){t===void 0?(t=a,n=0,r=-1):t=o9(t,a);let s=t.length,c=0;for(;n<s;){i&&(t[n]===10&&(c=++n),i=!1);let d=-1;for(;n<s&&d===-1;++n)switch(t[n]){case 58:r===-1&&(r=n-c);break;case 13:i=!0;case 10:d=n;break}if(d===-1)break;e(t.subarray(c,d),r),c=n,r=-1}c===s?t=void 0:c!==0&&(t=t.subarray(c),n-=c)}}function dD(e,t,n){let r=aD(),i=new TextDecoder;return function(a,s){if(a.length===0)n==null||n(r),r=aD();else if(s>0){let c=i.decode(a.subarray(0,s)),d=s+(a[s+1]===32?2:1),u=i.decode(a.subarray(d));switch(c){case"data":r.data=r.data?r.data+`
2
+ `+u:u;break;case"event":r.event=u;break;case"id":e(r.id=u);break;case"retry":let p=parseInt(u,10);isNaN(p)||t(r.retry=p);break}}}}function o9(e,t){let n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function aD(){return{data:"",event:"",id:"",retry:void 0}}var a9=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n},Sm="text/event-stream",s9=1e3,uD="last-event-id";function lT(e,t){var{signal:n,headers:r,onopen:i,onmessage:o,onclose:a,onerror:s,openWhenHidden:c,fetch:d}=t,u=a9(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((p,m)=>{let f=Object.assign({},r);f.accept||(f.accept=Sm);let h;function g(){h.abort(),document.hidden||I()}c||document.addEventListener("visibilitychange",g);let y=s9,_=0;function S(){document.removeEventListener("visibilitychange",g),window.clearTimeout(_),h.abort()}n==null||n.addEventListener("abort",()=>{S(),p()});let T=d??window.fetch,C=i??c9;async function I(){var x;h=new AbortController;try{let R=await T(e,Object.assign(Object.assign({},u),{headers:f,signal:h.signal}));await C(R),await sD(R.body,cD(dD(G=>{G?f[uD]=G:delete f[uD]},G=>{y=G},o))),a==null||a(),S(),p()}catch(R){if(!h.signal.aborted)try{let G=(x=s==null?void 0:s(R))!==null&&x!==void 0?x:y;window.clearTimeout(_),_=window.setTimeout(I,G)}catch(G){S(),m(G)}}}I()})}function c9(e){let t=e.headers.get("content-type");if(!(t!=null&&t.startsWith(Sm)))throw new Error(`Expected content-type to be ${Sm}, Actual: ${t}`)}var d9="/api/biz/v1/asset/sse_asset",u9=["message",_m,Tm],mT={ADD:1,DEL:2};async function fT(e){let t=await e,n=t&&typeof t=="object"?t:{},r=Number(n.ret??0);if(Number.isNaN(r)||r!==0)throw new Error(typeof n.errmsg=="string"?n.errmsg:"Pippit asset subscription failed.")}var hT=class{constructor(t){this._options=t;this._closed=!1;this._desiredPippitAssetIds=new Set;this._isFlushing=!1;this._isOpen=!1;this._needsFlush=!1;this._subscribedPippitAssetIds=new Set}sync(t){this._desiredPippitAssetIds.clear();for(let n of t)n.pippitAssetId&&this._desiredPippitAssetIds.add(n.pippitAssetId);this._scheduleFlush()}open(){this._isOpen=!0,this._scheduleFlush()}suspend(){this._isOpen=!1,this._subscribedPippitAssetIds.clear()}async close(){if(this._closed)return;this._closed=!0,this._isOpen=!1,this._desiredPippitAssetIds.clear(),await this._flushTask;let t=[...this._subscribedPippitAssetIds];this._subscribedPippitAssetIds.clear(),t.length&&this._options.subscribeAsset&&await fT(this._options.subscribeAsset({action_type:mT.DEL,pippit_asset_ids:t,session_id:this._options.sessionId})).catch(this._options.onError)}_scheduleFlush(){if(this._closed||!this._isOpen||!this._options.subscribeAsset||(this._needsFlush=!0,this._isFlushing))return;let t=this._flush().catch(n=>{var r,i;return(i=(r=this._options).onError)==null?void 0:i.call(r,n)});this._flushTask=t,t.finally(()=>{this._flushTask===t&&(this._flushTask=void 0)})}async _flush(){this._isFlushing=!0;try{for(;this._needsFlush&&!this._closed&&this._isOpen&&this._options.subscribeAsset;){this._needsFlush=!1;let t=new Set(this._desiredPippitAssetIds);await this._syncAddedSubscriptions(t),await this._syncRemovedSubscriptions(t)}}finally{this._isFlushing=!1,this._needsFlush&&!this._closed&&this._isOpen&&this._scheduleFlush()}}async _syncAddedSubscriptions(t){let n=[...t].filter(r=>!this._subscribedPippitAssetIds.has(r));!n.length||!this._options.subscribeAsset||(await fT(this._options.subscribeAsset({action_type:mT.ADD,pippit_asset_ids:n,session_id:this._options.sessionId})),n.forEach(r=>this._subscribedPippitAssetIds.add(r)))}async _syncRemovedSubscriptions(t){let n=[...this._subscribedPippitAssetIds].filter(r=>!t.has(r));!n.length||!this._options.subscribeAsset||(await fT(this._options.subscribeAsset({action_type:mT.DEL,pippit_asset_ids:n,session_id:this._options.sessionId})),n.forEach(r=>this._subscribedPippitAssetIds.delete(r)))}};function p9(e,t){return(typeof e=="function"?e(t):e)??d9}function pD(e,t){return typeof e=="function"?e(t):e??{}}function l9(e,t){return typeof e=="string"?e:JSON.stringify({session_id:t,...e??{}})}function m9(e,t){let n=pD(e,t),r=l9(n.body,t.sessionId);return{body:r,credentials:n.withCredentials?"include":void 0,headers:{...r&&typeof r=="string"?{"content-type":"application/json"}:{},...n.headers??{}},method:n.method??"POST"}}function f9(e){let t=e.headers.get("content-type");if(!e.ok)throw new Error(`Failed to open Pippit asset event source: ${e.status} ${e.statusText}`);if(t&&!t.startsWith("text/event-stream"))throw new Error(`Unexpected Pippit asset event source content-type: ${t}`)}function h9(e,t){return e==="PING"||e==="ping"?!1:(t??u9).includes(e||"message")}function g9(){var t;return`pippit_asset_session_${typeof((t=globalThis.crypto)==null?void 0:t.randomUUID)=="function"?globalThis.crypto.randomUUID():`${Date.now()}_${Math.random().toString(36).slice(2)}`}`}function bm(e){var s,c;let t=((s=e.createSessionId)==null?void 0:s.call(e))??g9(),n={sessionId:t},r=new AbortController,i=new hT({onError:e.onError,sessionId:t,subscribeAsset:e.subscribeAsset}),o=!1,a=0;return(c=e.onConnectionChange)==null||c.call(e,"connecting"),e.signal&&(e.signal.aborted?r.abort():e.signal.addEventListener("abort",()=>r.abort(),{once:!0})),i.sync(e.refs),lT(p9(e.url,n),{...m9(e.init,n),openWhenHidden:pD(e.init,n).openWhenHidden??!0,signal:r.signal,onopen:d=>{var u;return f9(d),a=0,i.open(),(u=e.onConnectionChange)==null||u.call(e,"open"),Promise.resolve()},onmessage:d=>{if(!h9(d.event,e.eventTypes))return;let u=pT(d.event||"message",d.data);u&&e.onEvent(u)},onclose:()=>{var d;if(i.suspend(),!o)throw(d=e.onConnectionChange)==null||d.call(e,"reconnecting"),new Error("Pippit asset event source closed.")},onerror:d=>{var p,m,f;i.suspend(),(p=e.onError)==null||p.call(e,d),a+=1;let u=e.maxReconnectAttempts??10;if(a>u)throw(m=e.onConnectionChange)==null||m.call(e,"closed"),d;return(f=e.onConnectionChange)==null||f.call(e,"reconnecting"),Math.min(1e3*2**Math.max(a-1,0),1e4)}}).catch(d=>{var u,p;!o&&!r.signal.aborted&&((u=e.onConnectionChange)==null||u.call(e,"closed"),(p=e.onError)==null||p.call(e,d))}),{close:()=>{var d;o=!0,(d=e.onConnectionChange)==null||d.call(e,"closed"),i.close().finally(()=>r.abort())},syncAssetRefs:d=>{i.sync(d)}}}function lD(e){return new Set(e.map(t=>{var n;return(n=t.pippitAssetId)==null?void 0:n.trim()}).filter(t=>!!t))}function gT(e){let t=new Map,n=0,r,i="closed",o=!1,a=()=>{let p=new Set;for(let m of t.values())m.refs.forEach(f=>p.add(f));return[...p].map(m=>({pippitAssetId:m}))},s=p=>{var m,f;i=p;for(let h of t.values())(f=(m=h.options).onConnectionChange)==null||f.call(m,p)},c=p=>{var m,f;for(let h of t.values())(f=(m=h.options).onError)==null||f.call(m,p)},d=()=>{var m;let p=a();if(!t.size){r==null||r.close(),r=void 0,i="closed";return}if(!r){r=bm({...e,onConnectionChange:s,onError:c,onEvent:f=>{var g;let h=(g=f.ref.pippitAssetId)==null?void 0:g.trim();if(h)for(let y of t.values())y.refs.has(h)&&y.listener(f)},refs:p});return}(m=r.syncAssetRefs)==null||m.call(r,p)};return{dispose:()=>{o||(o=!0,t.clear(),r==null||r.close(),r=void 0)},subscribe:(p,m,f={})=>{var S,T,C;if(o)throw new Error("Pippit asset subscription hub is disposed.");if((S=f.signal)!=null&&S.aborted)return{close:()=>{},syncAssetRefs:()=>{}};let h=++n,g={listener:m,options:f,refs:lD(p)},y=!1,_=()=>{y||(y=!0,t.delete(h),d())};return t.set(h,g),(T=f.signal)==null||T.addEventListener("abort",_,{once:!0}),r&&((C=f.onConnectionChange)==null||C.call(f,i)),d(),{close:_,syncAssetRefs:I=>{y||o||(g.refs=lD(I),d())}}}}}var Ls=e=>{let t=new Map;return e.map(_e).forEach(n=>t.set(En(n),n)),[...t.values()]};function Cm(e){let t=new Map,n=Ls(e.pinnedRefs??[]),r,i=!1,o=()=>Ls([...n,...Array.from(t.values()).flat()]),a=()=>{var d,u;if(i)return;let c=o();if(!r){if(!c.length)return;try{r=e.onError?e.assets.subscribeAssetEvents(c,e.onEvent,{onError:e.onError}):e.assets.subscribeAssetEvents(c,e.onEvent)}catch(p){(d=e.onError)==null||d.call(e,p)}return}(u=r.syncAssetRefs)==null||u.call(r,c)},s=c=>{t.delete(c)&&a()};return{dispose:()=>{var c;i||(i=!0,t.clear(),n=[],(c=r==null?void 0:r.syncAssetRefs)==null||c.call(r,[]),r==null||r.close(),r=void 0)},getTrackedRefs:o,pin:c=>{n=Ls(c),a()},release:s,set:(c,d)=>{i||(t.set(c,Ls(d)),a())},track:(c,d=[])=>{t.set(c,Ls(d)),a();let u=!1;return{dispose:()=>{u||(u=!0,s(c))},setRefs:p=>{!u&&!i&&(t.set(c,Ls(p)),a())}}}}}var sa=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:void 0,Am=(e,...t)=>{if(e)for(let n of t){let r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}},y9=e=>{let t=sa(e.raw),n=sa(t==null?void 0:t.data)??sa(t==null?void 0:t.Data);return{assetEvent:sa(t==null?void 0:t.assetEvent)??sa(t==null?void 0:t.asset_event)??sa(n==null?void 0:n.assetEvent)??sa(n==null?void 0:n.asset_event)??n??t,root:t}};function _9(e,t){let n=e.ref.pippitAssetId;if(!n||e.version===void 0)return;let{assetEvent:r,root:i}=y9(e);t({assetId:n,version:e.version,fromClientId:Am(r,"clientId","client_id")??Am(i,"clientId","client_id"),messageId:Am(i,"msgId","msg_id","messageId","message_id")??Am(r,"msgId","msg_id","messageId","message_id")})}function yT(e){return{subscribe(t){let n=e.subscribeAssetEvents(t.assetIds.map(r=>({pippitAssetId:r})),r=>_9(r,t.onEvent),{onConnectionChange:t.onConnectionChange,onError:t.onError});return{close:n.close,syncAssetIds:r=>{var i;(i=n.syncAssetRefs)==null||i.call(n,r.map(o=>({pippitAssetId:o})))}}}}}var ni=class{constructor(){this._versions=new Map;this._listeners=new Map;this.getVersion=t=>this.get(t);this.getVersions=()=>this.snapshot();this.subscribe=(t,n)=>{let r=this._listeners.get(t)??new Set;return r.add(n),this._listeners.set(t,r),()=>{r.delete(n),r.size===0&&this._listeners.delete(t)}}}get(t){return this._versions.get(t)}remember(t,n){if(n===void 0||!Number.isFinite(n))return;let r=this._versions.get(t);if(r===void 0||n>r){this._versions.set(t,n);for(let i of Array.from(this._listeners.get(t)??[]))i(n)}}rememberAll(t){if(t)for(let[n,r]of Object.entries(t))this.remember(n,r)}hasNewerVersion(t,n){let r=this._versions.get(t);return r===void 0||n>r}snapshot(){return Object.fromEntries(this._versions)}clearListeners(){this._listeners.clear()}};var Fs=class extends Error{constructor(n){super(`Pippit asset version is unavailable for asset ${n}`);this.name="PippitAssetVersionUnavailableError",this.assetId=n}},Zd=class extends ni{getBaseVersion(t,n){if(n.patches.some(o=>o.assetId===t.assetId&&o.op==="add"&&o.path===""))return 0;let i=this.getVersion(t.assetId);if(i===void 0)throw new Fs(t.assetId);return i}};var hD=e=>!!(e&&typeof e=="object"&&!Array.isArray(e)),vm=e=>hD(e)?e:void 0,Im=(e,...t)=>{for(let n of t)if(n in e)return e[n]},_T=(e,...t)=>{let n=Im(e,...t);return typeof n=="string"&&n.trim()?n.trim():void 0},T9=e=>{if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()){let t=Number(e);return Number.isFinite(t)?t:void 0}},mD=e=>{if(!hD(e))return;let t={};for(let[n,r]of Object.entries(e)){let i=T9(r);i!==void 0&&(t[n]=i)}return Object.keys(t).length?t:void 0},fD=(e,t)=>{let n={};for(let r of e)Object.assign(n,r[t]);return Object.keys(n).length?n:void 0},S9=(e,t,n)=>{var i;let r={...e};for(let o of t.envelopes)if(((i=n.get(o.txId))==null?void 0:i.status)==="ack")for(let a of o.patches)a.op==="add"&&a.path===""&&r[a.assetId]===void 0&&(r[a.assetId]=1);return Object.keys(r).length?r:void 0},b9=e=>e==="ack"||e==="skipped"||e==="reject"?e:"reject",C9=e=>{let t=vm(e)??{};return{transactionId:_T(t,"transaction_id","transactionId")??"",status:b9(Im(t,"status")),assetVersions:mD(Im(t,"asset_versions","assetVersions")),currentAssetVersions:mD(Im(t,"current_asset_versions","currentAssetVersions")),blockedBy:_T(t,"blocked_by","blockedBy"),message:_T(t,"error","message")}},A9=e=>"envelopes"in e&&Array.isArray(e.envelopes)?e:{...e,txIds:[e.txId],patches:[...e.patches],status:"in-flight",envelopes:[{...e,patches:[...e.patches]}]};function TT(e,t){var r;let n=A9(e);return{batch:n,request:{batch_id:((r=t.createBatchId)==null?void 0:r.call(t,n))??`batch_${n.txId}`,client_id:t.clientId,root_pippit_asset_id:t.scopeAssetId,transactions:n.envelopes.map(i=>({transaction_id:i.txId,intent:i.intent,merge_key:i.mergeKey,attempt:i.attempt,enqueued_at:i.enqueuedAt,patches:i.patches.map(o=>({asset_id:o.assetId,base_asset_version:t.versionRegistry.getBaseVersion(o,i),op:o.op,path:o.path,...o.op==="remove"?{}:{value:o.value}}))}))}}}function I9(e){let t=vm(e)??{},n=Number(t.ret??0);if(Number.isNaN(n)||n!==0)throw new Error(typeof t.errmsg=="string"?t.errmsg:"Pippit asset patch failed")}function v9(e){return{status:"transport-error",error:new Error(`Pippit asset patch returned no result for transaction ${e}`)}}function ST(e,t){I9(e);let n=vm(e)??{},r=vm(n.data)??n,o=(Array.isArray(r.results)?r.results:[]).map(C9),a=new Map(o.map(m=>[m.transactionId,m])),s=t.txIds.map(m=>a.get(m)),c=t.txIds.find((m,f)=>!s[f]),d=S9(fD(o,"assetVersions"),t,a),u=fD(o,"currentAssetVersions");if(c)return{response:v9(c),assetVersions:d,currentAssetVersions:u};let p=s.findIndex(m=>(m==null?void 0:m.status)!=="ack");if(p>=0){let m=s[p],f=t.txIds.slice(0,p);return m.status==="skipped"||m.currentAssetVersions!==void 0?{response:{status:"transport-error",retryable:!0,requiresResync:!0,error:new Error(m.message??(m.status==="skipped"?`Pippit asset patch skipped transaction ${m.transactionId}${m.blockedBy?` because it was blocked by ${m.blockedBy}`:""}`:`Pippit asset patch found a version conflict for transaction ${m.transactionId}`)),...f.length?{ackedTxIds:f}:{}},assetVersions:d,currentAssetVersions:u}:{response:{status:"reject",explicit:m.status==="reject",...f.length?{ackedTxIds:f}:{},...m.status==="reject"?{error:new Error(m.message??`Pippit asset patch rejected transaction ${m.transactionId}`)}:{}},assetVersions:d,currentAssetVersions:u}}return{response:{status:"ack",...t.txIds.length>1?{ackedTxIds:t.txIds}:{}},assetVersions:d,currentAssetVersions:u}}function gD(e){return new Set(e.map(t=>t.trim()).filter(Boolean))}function bT(e){let t=gD(e.assetIds??[]),n=!1,r=0,i=!1,o=new Map,a=new Set,s=d=>{!n&&e.versions.hasNewerVersion(d.assetId,d.version)&&e.onNewerEvent(d)},c=()=>{if(!(n||!i||r>0)){for(let d of o.values())s(d);o.clear()}};return{close:()=>{n||(n=!0,t.clear(),o.clear(),a.clear())},handleEvent:d=>{if(!(n||!t.has(d.assetId))){if(d.messageId){if(a.has(d.messageId))return;if(a.add(d.messageId),a.size>1e3){let u=a.values().next().value;u&&a.delete(u)}}if(!i||r>0){let u=o.get(d.assetId);(!u||d.version>=u.version)&&o.set(d.assetId,d);return}s(d)}},runVersionedLoad:async d=>{r+=1;try{return await d(u=>e.versions.rememberAll(u))}finally{r-=1,r===0&&(i=!0,c())}},syncAssetIds:d=>{t=gD(d);for(let u of o.keys())t.has(u)||o.delete(u)}}}var x9=e=>{let t=[],n=new Set,r=i=>{let o=i.trim();!o||n.has(o)||(n.add(o),t.push(o))};return e.forEach(r),t},CT=class{constructor(t){this.options=t;this.invalidateListeners=new Set;this.connectionListeners=new Set;this.abortController=new AbortController;this.subscription=null;this.closed=!1;this.commit=async t=>{if(("envelopes"in t?t.envelopes.reduce((r,i)=>r+i.patches.length,0):t.patches.length)===0){let r="txIds"in t?t.txIds:[t.txId];return{status:"ack",...r.length>1?{ackedTxIds:r}:{}}}try{let{batch:r,request:i}=TT(t,{scopeAssetId:this.options.scopeAssetId,clientId:this.clientId,versionRegistry:this.versions,createBatchId:this.options.createBatchId}),o=await this.options.batchPatchAsset(i),a=ST(o,r);return this.versions.rememberAll(a.assetVersions),a.response}catch(r){if(r instanceof Fs)return this.logger.warn("[pippit-asset-sdk:sync:pippit] missing base asset version",{assetId:r.assetId}),{status:"transport-error",error:r,retryable:!0,requiresResync:!0};let i=r instanceof Error?r:new Error(String(r));return this.logger.error("[pippit-asset-sdk:sync:pippit] commit failed",i,{scopeAssetId:this.options.scopeAssetId,txId:t.txId}),{status:"transport-error",error:i}}};this.fetchSnapshot=t=>this.eventReconciler.runVersionedLoad(async n=>{let r=t==null?void 0:t.onProgress,i=await this.options.loader.fetchSnapshot({scopeAssetId:this.options.scopeAssetId,signal:this.abortController.signal,...r?{onProgress:o=>{try{r(o)}catch(a){this.logger.warn("[pippit-asset-sdk:sync:pippit] snapshot progress observer failed",{error:a instanceof Error?a.message:String(a),scopeAssetId:this.options.scopeAssetId})}}}:{}});return n(i.assetVersions),{state:i.state}});this.fetchAssets=t=>this.eventReconciler.runVersionedLoad(async()=>{let n=await this.options.loader.fetchAssets({scopeAssetId:this.options.scopeAssetId,requests:t,signal:this.abortController.signal});return{assets:n.assets.map(r=>({...r,assetVersion:r.assetVersion??n.assetVersions[r.assetId]}))}});this.onInvalidate=t=>(this.invalidateListeners.add(t),this.openSubscription(),()=>{this.invalidateListeners.delete(t)});this.onConnectionChange=t=>(this.connectionListeners.add(t),()=>{this.connectionListeners.delete(t)});this.getConnectionState=()=>this.connectionState;this.syncAssetSubscriptions=t=>{var n;this.assetIds=x9(t),this.eventReconciler.syncAssetIds(this.assetIds),(n=this.subscription)==null||n.syncAssetIds(this.assetIds)};this.getDebugAssetVersions=()=>this.versions.snapshot();this.close=()=>{var t;this.closed||(this.closed=!0,this.invalidateListeners.clear(),this.eventReconciler.close(),(t=this.subscription)==null||t.close(),this.subscription=null,this.abortController.abort(),this.versions.clearListeners(),this.setConnectionState("closed"))};this.clientId=t.clientId,this.versions=new Zd,this.assetIds=[],this.connectionState=t.assetEventSource?"closed":"open",this.logger=ws(t.logger),this.eventReconciler=bT({assetIds:this.assetIds,versions:this.versions,onNewerEvent:n=>{this.emitInvalidate({scopedAssetId:n.assetId,assetVersion:n.version,fromClientId:n.fromClientId})}})}get assetVersions(){return this.versions}openSubscription(){this.closed||this.subscription||!this.options.assetEventSource||(this.subscription=this.options.assetEventSource.subscribe({assetIds:this.assetIds,clientId:this.clientId,onConnectionChange:t=>{this.setConnectionState(t==="open"?"open":"closed")},onError:t=>{this.logger.error("[pippit-asset-sdk:sync:pippit] asset event source error",t,{scopeAssetId:this.options.scopeAssetId})},onEvent:t=>{this.eventReconciler.handleEvent(t)}}))}emitInvalidate(t){for(let n of Array.from(this.invalidateListeners))n(t)}setConnectionState(t){if(this.connectionState!==t){this.connectionState=t;for(let n of Array.from(this.connectionListeners))n(t)}}};function xm(e){return new CT(e)}function AT(e){let t=gm(e),n=new Set,r=!1,i=()=>{if(r)throw new Error("Pippit asset runtime is disposed.")};return{client:t,createSubscriptionTracker:o=>{i();let a=Cm({...o,assets:t.assets});return n.add(a),a},createSyncTransport:o=>{var a;if(i(),!((a=e.sync)!=null&&a.batchPatchAsset))throw new Error("Pippit asset runtime sync transport is not configured.");return xm({...o,assetEventSource:e.transport.subscribeAssetEvents?yT(t.assets):void 0,batchPatchAsset:e.sync.batchPatchAsset})},dispose:()=>{r||(r=!0,n.forEach(o=>o.dispose()),n.clear(),t.dispose())}}}function P(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function Qe(e){return Array.isArray(e)?e:void 0}function eu(e){return typeof e=="string"&&e.trim().length>0}function D(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function Ae(e){let t=typeof e=="number"?e:Number(e);return Number.isFinite(t)?t:void 0}function ri(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function Yn(e){let t={};return e.assetId&&(t.assetId=e.assetId),e.pippitAssetId&&(t.pippitAssetId=e.pippitAssetId),t.assetId||t.pippitAssetId?t:void 0}function IT(e,t){let n=e==null?void 0:e.audio;if(!n)return;let r=n.downloadUrl||n.previewUrl;if(!r)return;let i=e.assetId??e.pippitAssetId??"audio";return{identity:Yn({assetId:e.assetId,pippitAssetId:e.pippitAssetId}),metadata:{assetId:e.assetId,downloadUrl:n.downloadUrl,durationMs:n.durationMs,mimeType:n.mimeType,name:n.name,pippitAssetId:e.pippitAssetId,size:n.size},preview:{metadata:{durationMs:n.durationMs,format:n.mimeType,name:n.name,size:n.size},raw:e.raw,type:"audio",urls:{download:n.downloadUrl??r,high:r,low:r,medium:r,url:r}},url:r,version:`${i}:${t.purpose}:${ri(r)}`}}function yD(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Rm(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{},r=Object.keys(n);typeof Object.getOwnPropertySymbols=="function"&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable}))),r.forEach(function(i){yD(e,i,n[i])})}return e}function R9(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Pm(e,t){return t=t??{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):R9(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}var _D={WEB_DOMAIN:{online:"https://xyq.jianying.com",online_new:"https://www.xiaoyunque.com",internal:""},CDN_DOMAIN:{cdnDomain:"https://lf-xiaoyunque.jianying.com",scmStorage:"https://lf-xiaoyunque.jianying.com/obj/pippit-app-buz/xiaoyunque_web",draftStaticDomain:"https://lf3-cdn-tos.draftstatic.com"},TOS:{HOST:["https://lf-xiaoyunque.jianying.com"],cmsStaticAssetBaseUrl:"https://p11-xiaoyunque.byteimg.com/tos-cn-i-men7yzdrs1",resultUrlSuffix:{image:"~tplv-men7yzdrs1-webp.webp",video:"~tplv-men7yzdrs1-image.image"}},CMS:{baseUrl:""},SLARDAR:{appxpcode:"",bid:"xiaoyunque_web",pluginPathPrefix:"https://lf3-short.ibytedapm.com/slardar/fe/sdk-web/plugins",domain:"mon.zijieapi.com",sdkUrl:"https://lf3-short.ibytedapm.com/slardar/fe/sdk-web/browser.cn.js",region:"cn",reportUrl:"https://mon.zijieapi.com/monitor_browser/collect/batch/security/"},AGENT_CONNECT:{commandLine:"npx @pippit-dev/cli@latest install"},FIREBASE:{apiKey:"AIzaSyAh-sSmkqiMoEBYLy7yxkaKSCniBUpB6ts"},ASSETS:{entries:{"pippit-role":{path:"https://lf-xiaoyunque.jianying.com/obj/pippit-app-buz/xiaoyunque_web/novel_3d_director/pippit-role.glb"}}},SDK:{canvas:{capcutDownloadUrl:"https://www.capcut.cn/"},novel:{legacyImageOriginHostname:"everphoto-media.jianying.com"},pippitAsset:{imagePreviewBlockedUrlPatterns:["(?:^|/)everphoto-capcut-enc(?:-[^/?#]+)?(?:/|$)","^https://everphoto-media\\.jianying\\.com/download/bucket(?:/|$)"]}}};var P9=["j","i","a","n","y","i","n","g"].join(""),vT="https://sf16-web-login-neutral.capcutstatic.com",Dm=`${vT}/obj/capcut-web-login-static/ies/pippit/scm_storage`,D9={WEB_DOMAIN:{online:"https://www.pippit.ai"},CDN_DOMAIN:{cdnDomain:vT,scmStorage:Dm},TOS:{HOST:[vT],cmsStaticAssetBaseUrl:"https://p16-capcut-sg.capcut.com/tos-alisg-i-hk1xnajzr6-sg",resultUrlSuffix:{image:"~tplv-hk1xnajzr6-webp.webp",video:"~tplv-hk1xnajzr6-image.image"}},CMS:{baseUrl:""},ARGUS_SDK:`${Dm}/sdk/secsdk/sg/runtime_bundler_476.js`,SLARDAR:{appxpcode:"lvoverseas_web",bid:"capcut_business",pluginPathPrefix:`${Dm}/sdk/slardar-sdk-web/plugins`,sdkUrl:`${Dm}/sdk/browser.1.14.1.sg.js`,region:"i18n",domain:"mon-sg.capcutapi.com",reportUrl:"https://mon-sg.capcutapi.com/monitor_browser/collect/batch/security/"},BASE_DOMAIN:{feedAPIDomain:"https://feed-api.capcut.com"},AGENT_CONNECT:{commandLine:"npx skills add https://github.com/Pippit-dev/pippit-skills.git --skill pippit-skill -y -g"},ASSETS:{entries:{"pippit-role":{path:`https://lf-xiaoyunque.${P9}.com/obj/pippit-app-buz/xiaoyunque_web/novel_3d_director/pippit-role.glb`}}},SDK:{canvas:{capcutDownloadUrl:"https://www.capcut.com/tools/desktop-video-editor"},pippitAsset:{imagePreviewBlockedUrlPatterns:["(?:^|/)everphoto-capcut-enc(?:-[^/?#]+)?(?:/|$)"]}}},TD=D9;var xT="https://sf16-web-tos-buz.capcutcdn-us.com",SD=`${xT}/obj/capcut-web-buz-tx/ies/pippit/scm_storage`,E9={WEB_DOMAIN:{online:"https://www.pippit.ai"},CDN_DOMAIN:{cdnDomain:xT,scmStorage:SD},TOS:{HOST:[xT],cmsStaticAssetBaseUrl:"https://p16-capcut-sg-useast5.capcutcdn-us.com/tos-useast5-i-hk1xnajzr6-tx",resultUrlSuffix:{image:"~tplv-hk1xnajzr6-webp.webp",video:"~tplv-hk1xnajzr6-image.image"}},CMS:{baseUrl:""},SLARDAR:{appxpcode:"lvoverus_web",bid:"capcut_business",sdkUrl:"https://lf16-cdn-tos.tiktokcdn-us.com/obj/static-tx/slardar/fe/sdk-web/browser.1.14.1.oci.js",pluginPathPrefix:`${SD}/sdk/slardar-sdk-web/plugins`,region:"ttp",domain:"mon16-normal-us-ttp.capcutapi.us",reportUrl:"https://mon16-normal-us-ttp.capcutapi.us/monitor_browser/collect/batch/security/"},BASE_DOMAIN:{feedAPIDomain:"https://feed.us.capcut.com"},AGENT_CONNECT:{commandLine:""},ASSETS:{entries:{"pippit-role":{path:"https://sf16-web-tos-buz.capcutcdn-us.com/obj/capcut-web-buz-tx/pippit-3d/character/pippit-role.glb"}}},SDK:{canvas:{capcutDownloadUrl:"https://www.capcut.com/tools/desktop-video-editor"},pippitAsset:{imagePreviewBlockedUrlPatterns:["(?:^|/)everphoto-capcut-enc(?:-[^/?#]+)?(?:/|$)"]}}},bD=E9;var Em=process.env.IS_US==="true"?bD:process.env.IS_OVERSEA==="true"?TD:_D,Bs=Pm(Rm({},Em),{SDK:Pm(Rm({},Em.SDK),{pippitAsset:Pm(Rm({},Em.SDK.pippitAsset),{imagePreviewBlockedUrlPatterns:["(?:^|/)everphoto-(?:capcut|jiangying)-enc(?:-[^/?#]+)?(?:/|$)",...Em.SDK.pippitAsset.imagePreviewBlockedUrlPatterns]})})});async function CD(e,t,n,r={}){if(!t)return;let i=D(t.asset_id??t.assetId),o=e;if(r.strictAssetId&&i&&i!==o)throw new Error(`Resolved assetId ${i} does not match requested assetId ${o}.`);let a=await L9(t,n.purpose,n.videoVariant,r);if(!a)return;let s=O9(t),c=await PT(r,t,"cover_url","cover_key"),d=await M9(t,r),u={durationMs:Ae(t.duration_ms),format:D(t.format),height:Ae(t.height),name:D(t.name)??i??o,size:Ae(t.size),spriteFrames:d,width:Ae(t.width)};return{encryptKey:F9(t),identity:Yn({assetId:o}),metadata:{assetId:o,downloadUrl:s,...u,poster:c},preview:{metadata:u,raw:t,type:"video",urls:{download:s??a,high:a,low:a,medium:a,poster:c,url:a}},url:a,version:`${o}:${ri(a)}`}}async function M9(e,t){let n=N9(e),r=w9(n);if(!(r!=null&&r.length))return;let i=(await Promise.all(r.map(a=>k9(a,t)))).filter(a=>!!a);if(!i.length)return;let o=P((n==null?void 0:n.common_info)??(n==null?void 0:n.commonInfo));return{frameCount:Ae((o==null?void 0:o.total_set_num)??(o==null?void 0:o.totalSetNum)),frameHeight:Ae((o==null?void 0:o.single_frame_height)??(o==null?void 0:o.singleFrameHeight)),frameWidth:Ae((o==null?void 0:o.single_frame_width)??(o==null?void 0:o.singleFrameWidth)),images:i}}function N9(e){let t=P(e.video_meta_info??e.videoMetaInfo);return P(e.sprite_frame??e.spriteFrame)??P((t==null?void 0:t.sprite_frame)??(t==null?void 0:t.spriteFrame))}function w9(e){return[e==null?void 0:e.image_list,e==null?void 0:e.imageList,e==null?void 0:e.detail_infos,e==null?void 0:e.detailInfos].find(n=>Array.isArray(n))}async function k9(e,t){let n=P(e),r=await PT(t,n,"url","encrypted_key");if(r)return{encryptKey:D((n==null?void 0:n.encrypted_key)??(n==null?void 0:n.encryptKey)),frameCount:Ae((n==null?void 0:n.frame_count)??(n==null?void 0:n.frameCount)),height:Ae(n==null?void 0:n.height),url:r,width:Ae(n==null?void 0:n.width)}}function RT(e,t){var a,s;let n=e==null?void 0:e.video;if(!n)return;let r=t.purpose==="download"?t.videoVariant?(a=n.downloadVariants)==null?void 0:a[t.videoVariant]:n.downloadUrl:t.videoVariant?(s=n.previewVariants)==null?void 0:s[t.videoVariant]:n.previewUrl;if(!r)return;let i=e.assetId??e.pippitAssetId??"video",o={durationMs:n.durationMs,fps:n.fps,height:n.height,spriteFrames:n.spriteFrames,width:n.width};return{identity:Yn({assetId:e.assetId,pippitAssetId:e.pippitAssetId}),metadata:{assetId:e.assetId,downloadUrl:n.downloadUrl,...o,pippitAssetId:e.pippitAssetId,poster:n.coverUrl},preview:{metadata:o,raw:e.raw,type:"video",urls:{download:n.downloadUrl??r,high:r,low:r,medium:r,poster:n.coverUrl,url:r}},refreshOnSourceError:!0,url:r,version:`${i}:${t.purpose}:${ri(r)}`}}function AD(e){let t=P(e.no_watermark_video_url??e.noWatermarkVideoUrl);return Zi([t==null?void 0:t.origin_cover_url,t==null?void 0:t.originCoverUrl,e.origin_cover_url,e.originCoverUrl])}function O9(e){let t=P(e.no_watermark_video_url);return Zi([e.download_url,t==null?void 0:t.download_url,e.origin_url])}function Lt(e,t){let n=P(e[`preview_video_${t}`]??e[`previewVideo${t}`]);return(n==null?void 0:n.preview_url)??(n==null?void 0:n.previewUrl)??(n==null?void 0:n.download_url)??(n==null?void 0:n.downloadUrl)}async function L9(e,t,n,r){let i=P(e.no_watermark_video_url);if(t==="download")return Zi(n==="watermark"?[e.download_url]:n==="notWatermark"?[i==null?void 0:i.download_url,e.origin_url,i==null?void 0:i.preview_url,e.download_url]:[e.download_url,i==null?void 0:i.download_url,e.preview_url,e.preview_url_720p,Lt(e,"720p"),e.preview_url_1080p,Lt(e,"1080p"),e.preview_url_480p,Lt(e,"480p"),e.preview_url_360p,Lt(e,"360p")]);if(n==="watermark")return Zi([e.preview_url_720p,Lt(e,"720p"),e.preview_url_1080p,Lt(e,"1080p"),e.preview_url_480p,Lt(e,"480p"),e.preview_url_360p,Lt(e,"360p"),e.preview_url]);if(n==="notWatermark")return Zi([i==null?void 0:i.preview_url,i==null?void 0:i.download_url,e.origin_url,e.preview_url_720p,Lt(e,"720p"),e.preview_url_1080p,Lt(e,"1080p"),e.preview_url_480p,Lt(e,"480p"),e.preview_url_360p,Lt(e,"360p"),e.preview_url]);let o=Zi([e.preview_url_720p,Lt(e,"720p"),e.preview_url_1080p,Lt(e,"1080p"),e.preview_url_480p,Lt(e,"480p"),e.preview_url_360p,Lt(e,"360p"),e.preview_url,i==null?void 0:i.preview_url]);return o||await PT(r,e.encrypt_preview_url,"url","key")}function Zi(e){for(let t of e){let n=D(t);if(n)return n}}function F9(e){let t=n=>{let r=P(e[`preview_video_${n}`]??e[`previewVideo${n}`]);return(r==null?void 0:r.preview_key)??(r==null?void 0:r.previewKey)};return D(e.preview_key_720p)??D(t("720p"))??D(e.preview_key_1080p)??D(t("1080p"))??D(e.preview_key_480p)??D(t("480p"))??D(e.preview_key_360p)??D(t("360p"))??D(e.preview_key)}async function PT(e,t,n,r){let i=P(t),o=D(i==null?void 0:i[n]);if(!o)return;let a=D(i==null?void 0:i[r]);return!a||!e.resolveEncryptedUrl?o:await e.resolveEncryptedUrl({key:a,url:o})??o}var B9=["360p","480p","720p","1080p","2048p","origin"];function OD(e,t){return FD(e,z9(t))}function LD(e,t){return FD(e,G9(t))}function G9(e){if(e!=null&&e.assetId)return{assetId:e.assetId,...e.mediaType?{mediaType:e.mediaType}:{},preferRequestedAssetId:!0}}function z9(e){if(e!=null&&e.mediaType)return{mediaType:e.mediaType,pippitAssetId:e.pippitAssetId}}function FD(e,t){let n=U9(e),r=K9(e,n,t==null?void 0:t.mediaType),i=H9(e,n,r),o=D(e.pippit_asset_id??e.pippitAssetId??e.PippitAssetID)??(t==null?void 0:t.pippitAssetId),a=$9(e,n,r,t),s=q9(e,n,r),c=V9(e,n,s);return{assetId:a,audio:n.audio?RD({...e,...n.audio}):r==="audio"?RD(i):void 0,extra:ET(e.extra??e.Extra),file:n.file?DD(n.file):r==="file"?DD(i):void 0,image:n.image?ID(n.image):r==="image"?ID(i):void 0,mediaType:r,metadata:ET(e.metadata??e.Metadata),pippitAssetId:o,playerInfoVersion:Ae(e.player_info_version??e.playerInfoVersion??e.PlayerInfoVersion),raw:e,semanticMetadata:c,text:n.text?PD(n.text):r==="text"?PD(i):void 0,video:n.video?xD(n.video):r==="video"?xD(i):void 0,version:Ae(e.version??e.Version??e.asset_version??e.assetVersion)}}function ET(e){let t=P(e);if(t)return t;if(!(typeof e!="string"||!e.trim()))try{return P(JSON.parse(e))}catch{return}}function U9(e){return{audio:P(e.Audio)??P(e.audio),file:P(e.File)??P(e.FileInfo)??P(e.file)??P(e.fileInfo),image:P(e.Image)??P(e.image),text:P(e.Text)??P(e.TextInfo)??P(e.text)??P(e.textInfo),video:P(e.Video)??P(e.video)}}function V9(e,t,n){let r;n==="image"?r=t.image:n==="video"&&(r=t.video);let i={assetDescription:tu(e.AssetDesc,e.asset_desc,e.assetDescription),displayName:tu(e.Name,e.name,r==null?void 0:r.name,r==null?void 0:r.Name),semanticCaption:tu(r==null?void 0:r.caption,r==null?void 0:r.Caption)};return Object.values(i).some(Boolean)?i:void 0}function tu(...e){for(let t of e){let n=D(t);if(n)return n}}function q9(e,t,n){var s,c,d,u,p,m,f,h;let r=GD(e.AssetType??e.assetType??(zD(e)?e.asset_type:void 0));if(r)return r;let i=BD(e,t);if(i)return i;let o=!!tu((s=t.image)==null?void 0:s.name,(c=t.image)==null?void 0:c.Name,(d=t.image)==null?void 0:d.caption,(u=t.image)==null?void 0:u.Caption),a=!!tu((p=t.video)==null?void 0:p.name,(m=t.video)==null?void 0:m.Name,(f=t.video)==null?void 0:f.caption,(h=t.video)==null?void 0:h.Caption);return o!==a?o?"image":"video":t.image&&!t.video?"image":t.video&&!t.image?"video":n}function K9(e,t,n){return n||BD(e,t)}function BD(e,t){let n=j9(e.media_type??e.mediaType??e.asset_type??e.type);if(n)return n;let r=GD(e.AssetType??e.assetType??(zD(e)?e.asset_type:void 0));if(r)return r;if(t.audio&&ND(t.audio))return"audio";if(t.video&&MD(t.video))return"video";if(t.image&&ED(t.image))return"image";if(t.text&&wD(t.text))return"text";if(t.file&&kD(t.file))return"file";if(ND(e))return"audio";if(MD(e))return"video";if(ED(e))return"image";if(wD(e))return"text";if(kD(e))return"file"}function j9(e){var n;let t=(n=D(e))==null?void 0:n.toLowerCase();if(t){if(t.includes("audio")||t.includes("music"))return"audio";if(t.includes("video"))return"video";if(t.includes("image")||t.includes("photo")||t.includes("picture"))return"image";if(t.includes("text"))return"text";if(t.includes("file")||t.includes("document"))return"file"}}function GD(e){let t=typeof e=="number"?e:Number(D(e));if(Number.isFinite(t)){if(t===1)return"image";if(t===2)return"video";if(t===3)return"audio";if(t===4)return"text";if(t===5)return"file"}}function zD(e){return!!(e.PippitAssetID||e.pippit_asset_id||e.pippitAssetId||e.AssetSourceType||e.asset_source_type)}function H9(e,t,n){return n==="audio"?t.audio?{...e,...t.audio}:e:n==="video"?t.video??e:n==="image"?t.image??e:n==="text"?t.text??e:n==="file"?t.file??e:e}function Gs(e){return D((e==null?void 0:e.asset_id)??(e==null?void 0:e.assetId)??(e==null?void 0:e.AssetID))}function $9(e,t,n,r){if(r!=null&&r.preferRequestedAssetId&&r.assetId)return r.assetId;let i=D(e.asset_id??e.assetId),o=n?Gs(t[n]):void 0,a=D(e.SourceID??e.source_id??e.sourceId);return i??o??Gs(t.image)??Gs(t.video)??Gs(t.audio)??Gs(t.text)??Gs(t.file)??((r==null?void 0:r.mediaType)==="audio"?a:void 0)??(r==null?void 0:r.assetId)}function ID(e){let t=DT(e,"default"),n={default:Y9(e),notWatermark:X9(e),watermark:W9(e)},r=D(e.url),i=UD(e);return{download:Mm(n.default,e,i),downloadVariants:{default:Mm(n.default,e,i),notWatermark:Mm(n.notWatermark,e,i),watermark:Mm(n.watermark,e,i)},provisionalPreview:r?{url:r}:void 0,previews:t,previewVariants:{default:t,notWatermark:DT(e,"notWatermark"),watermark:DT(e,"watermark")}}}function Mm(e,t,n){return e?{format:VD(void 0,void 0,n),height:qD(void 0,void 0,n,t),size:jD(void 0,void 0,n,t),url:e,width:KD(void 0,void 0,n,t)}:void 0}function DT(e,t){let n={},r=UD(e);for(let i of B9){let o=Q9(e,i,t),a=vD(Xn(o))??vD(Z9(e,i));if(a){let s=J9(o);n[i]={format:VD(o,s,r),height:qD(o,s,r,e),size:jD(o,s,r,e),url:a,width:KD(o,s,r,e)}}}return n}function vD(e){return e?Bs.SDK.pippitAsset.imagePreviewBlockedUrlPatterns.some(n=>new RegExp(n,"i").test(e))?void 0:e:void 0}function Y9(e){var t;return D(e.download_url)??D(e.url)??D(e.dowmload_url)??D(e.DownloadURL)??Xn(ru(P(e.not_watermark_preview)))??Xn(nu(P(e.not_watermark_preview)))??D((t=P(e.not_watermark_preview))==null?void 0:t.url)??Xn(ru(P(e.download_preview)))??Xn(nu(P(e.download_preview)))??D(e.downsample_url)}function X9(e){let t=P(e.not_watermark_preview),n=P(e.download_preview);return D(e.url)??D(e.dowmload_url)??D(e.DownloadURL)??Xn(ru(t))??Xn(nu(t))??D(t==null?void 0:t.url)??Xn(ru(n))??Xn(nu(n))??D(e.downsample_url)??D(e.download_url)}function W9(e){let t=P(e.watermark_preview);return D(e.download_url)??Xn(ru(t))??Xn(nu(t))??D(t==null?void 0:t.url)}function UD(e){return P(e.metadata)??P(e.Metadata)}function J9(e){return P(e==null?void 0:e.metadata)??P(e==null?void 0:e.Metadata)}function Xn(e){return D((e==null?void 0:e.preview_url)??(e==null?void 0:e.previewUrl)??(e==null?void 0:e.PreviewURL)??(e==null?void 0:e.url)??(e==null?void 0:e.URL))}function VD(e,t,n){return D((t==null?void 0:t.format)??(t==null?void 0:t.Format)??(t==null?void 0:t.fileFormat)??(t==null?void 0:t.FileFormat)??(e==null?void 0:e.format)??(e==null?void 0:e.Format)??(n==null?void 0:n.format)??(n==null?void 0:n.Format)??(n==null?void 0:n.fileFormat)??(n==null?void 0:n.FileFormat))}function qD(e,t,n,r){return Ae((t==null?void 0:t.height)??(t==null?void 0:t.Height)??(e==null?void 0:e.height)??(e==null?void 0:e.Height)??(n==null?void 0:n.height)??(n==null?void 0:n.Height)??(r==null?void 0:r.height)??(r==null?void 0:r.Height))}function KD(e,t,n,r){return Ae((t==null?void 0:t.width)??(t==null?void 0:t.Width)??(e==null?void 0:e.width)??(e==null?void 0:e.Width)??(n==null?void 0:n.width)??(n==null?void 0:n.Width)??(r==null?void 0:r.width)??(r==null?void 0:r.Width))}function jD(e,t,n,r){return Ae((t==null?void 0:t.size)??(t==null?void 0:t.Size)??(e==null?void 0:e.size)??(e==null?void 0:e.Size)??(n==null?void 0:n.size)??(n==null?void 0:n.Size)??(r==null?void 0:r.size)??(r==null?void 0:r.Size))}function Q9(e,t,n){let r=P(e.not_watermark_preview),i=P(e.watermark_preview),o=[P(e.download_preview),P(e.compliance_preview),P(e.brand_preview),P(e.dynamic_preview),P(e.fusion_preview),P(e.share_preview)];if(t==="origin"){let c=P(e.previewinfo)??P(e.preview_info)??P(e.PreviewInfo),d=o.map(u=>P(u==null?void 0:u.previewinfo)).find(Boolean);return n==="watermark"?P(i==null?void 0:i.previewinfo)??c??P(r==null?void 0:r.previewinfo)??d:P(r==null?void 0:r.previewinfo)??c??P(i==null?void 0:i.previewinfo)??d}let a=P(e[`previewinfo_${t}`])??P(e[`preview_info_${t}`])??P(e[`preview_${t}`])??P(e[`preview_video_${t}`])??P(e[HD(t)]),s=o.map(c=>ii(c,t)).find(Boolean);return n==="watermark"?ii(i,t)??a??ii(r,t)??s:ii(r,t)??a??ii(i,t)??s}function ii(e,t){return P(e==null?void 0:e[`previewinfo_${t}`])??P(e==null?void 0:e[`preview_info_${t}`])??P(e==null?void 0:e[`preview_${t}`])??P(e==null?void 0:e[HD(t)])}function nu(e){return ii(e,"2048p")??ii(e,"1080p")??ii(e,"720p")??ii(e,"480p")??P(e==null?void 0:e.previewinfo)??P(e==null?void 0:e.preview_info)??P(e==null?void 0:e.PreviewInfo)}function ru(e){return P(e==null?void 0:e.previewinfo)??P(e==null?void 0:e.preview_info)??P(e==null?void 0:e.PreviewInfo)}function HD(e){return`PreviewInfo_${e.toUpperCase()}`}function Z9(e,t){return t==="origin"?D(e.preview_url??e.previewUrl??e.PreviewURL??e.downsample_url):D(e[`preview_url_${t}`]??e[`previewUrl_${t}`]??e[`PreviewURL_${t.toUpperCase()}`]??e[`url_${t}`]??e[`URL_${t.toUpperCase()}`])}function xD(e){let t=P(e.no_watermark_video_url??e.noWatermarkVideoUrl),n=P(e.metadata),r=ET(e.extra??e.Extra),i=D(e.downloadUrl)??D(e.download_url),o=D(e.originUrl)??D(e.origin_url)??D(t==null?void 0:t.downloadUrl)??D(t==null?void 0:t.download_url),a=D(e.previewUrl)??D(e.preview_url),s=D(t==null?void 0:t.previewUrl)??D(t==null?void 0:t.preview_url)??D(e.originPreviewUrl)??D(e.origin_preview_url),c=s??D(e.previewUrl_720p)??D(e.preview_url_720p)??D(e.previewUrl_1080p)??D(e.preview_url_1080p)??D(e.previewUrl_480p)??D(e.preview_url_480p)??a??o??i;return{coverUrl:AD(e)??D(e.coverUrl)??D(e.cover_url),draftKey:D(e.draftKey??e.draft_key??e.DraftKey??(r==null?void 0:r.draftKey)??(r==null?void 0:r.draft_key)),downloadUrl:o??i,downloadVariants:{notWatermark:o,watermark:i},durationMs:Ae(e.durationMs??e.duration_ms??(n==null?void 0:n.durationMs)??(n==null?void 0:n.duration_ms)),extra:r,fps:Ae(e.fps??(n==null?void 0:n.fps)),height:Ae(e.height??(n==null?void 0:n.height)),packageId:D(e.packageID??e.packageId??e.package_id??e.PackageID??(r==null?void 0:r.packageID)??(r==null?void 0:r.packageId)??(r==null?void 0:r.package_id)),previewUrl:c,previewVariants:{notWatermark:s,watermark:a},spriteFrames:eJ(e),renderTaskId:D(e.renderTaskID??e.renderTaskId??e.render_task_id??e.RenderTaskID??(r==null?void 0:r.renderTaskID)??(r==null?void 0:r.renderTaskId)??(r==null?void 0:r.render_task_id)),width:Ae(e.width??(n==null?void 0:n.width))}}function eJ(e){let t=Qe(e.sprite_info??e.spriteInfo??e.SpriteInfo);if(!(t!=null&&t.length))return;let n=t.map(tJ);if(n.some(a=>!a))return;let r=n,[{frameHeight:i,frameWidth:o}]=r;if(!r.some(a=>a.frameHeight!==i||a.frameWidth!==o))return{frameCount:r.reduce((a,s)=>a+s.image.frameCount,0),frameHeight:i,frameWidth:o,images:r.map(a=>a.image)}}function tJ(e){let t=P(e),n=ca((t==null?void 0:t.sprite_num)??(t==null?void 0:t.spriteNum)),r=ca((t==null?void 0:t.image_height)??(t==null?void 0:t.imageHeight)),i=ca((t==null?void 0:t.image_width)??(t==null?void 0:t.imageWidth)),o=ca((t==null?void 0:t.canvas_height)??(t==null?void 0:t.canvasHeight)),a=ca((t==null?void 0:t.canvas_width)??(t==null?void 0:t.canvasWidth)),s=ca((t==null?void 0:t.image_x_num)??(t==null?void 0:t.imageXNum)),c=ca((t==null?void 0:t.image_y_num)??(t==null?void 0:t.imageYNum)),d=D((t==null?void 0:t.url)??(t==null?void 0:t.URL));if(!(!n||!r||!i||!o||!a||!s||!c||!d)&&!(n>s*c||a!==i*s||o!==r*c))return{frameHeight:r,frameWidth:i,image:{frameCount:n,height:o,url:d,width:a}}}function ca(e){let t=Ae(e);return t!==void 0&&Number.isInteger(t)&&t>0?t:void 0}function RD(e){return{downloadUrl:D(e.download_url??e.origin_url),durationMs:Ae(e.duration_ms),mimeType:D(e.mime_type??e.mimeType??e.format),name:D(e.name??e.Name),previewUrl:D(e.preview_url??e.download_url??e.origin_url),size:Ae(e.size)}}function PD(e){return{content:D(e.content??e.text),downloadUrl:D(e.download_url),mimeType:D(e.mime_type??e.mimeType),name:D(e.name),previewUrl:D(e.preview_url??e.origin_url),size:Ae(e.size)}}function DD(e){return{downloadUrl:D(e.download_url??e.origin_url??e.internal_url),extension:D(e.extension??e.ext),format:D(e.format),mimeType:D(e.mime_type??e.mimeType),name:D(e.name),previewUrl:D(e.preview_url),size:Ae(e.size)}}function ED(e){return!!(e.url||e.preview_url||e.download_url||e.dowmload_url||e.DownloadURL||e.downsample_url||e.PreviewURL||e.URL||e.previewinfo||e.PreviewInfo||e.previewinfo_720p||e.PreviewInfo_720P||e.previewinfo_1080p||e.PreviewInfo_1080P||e.previewinfo_480p||e.PreviewInfo_480P||e.previewinfo_2048p||e.PreviewInfo_2048P||e.not_watermark_preview||e.watermark_preview||e.download_preview||e.compliance_preview||e.brand_preview||e.dynamic_preview||e.fusion_preview||e.share_preview)}function MD(e){return!!(e.preview_url||e.download_url||e.origin_url||e.internal_url||e.preview_url_720p||e.preview_url_1080p||e.preview_url_480p||e.no_watermark_video_url||e.preview_key_720p||e.vid||e.render_task_id)}function ND(e){var r,i;let t=(r=D(e.mime_type??e.mimeType))==null?void 0:r.toLowerCase(),n=(i=D(e.format))==null?void 0:i.toLowerCase();return!!(t!=null&&t.startsWith("audio/")||["mp3","wav","aac","m4a","ogg"].includes(n??"")||e.audio_url||e.preview_url||e.download_url||e.origin_url||e.internal_url)}function wD(e){var n;let t=(n=D(e.mime_type??e.mimeType))==null?void 0:n.toLowerCase();return!!(t!=null&&t.startsWith("text/")||e.text||e.content||e.download_url)}function kD(e){return!!(e.download_url||e.origin_url||e.name)}function Nm(e){let t=P(e),n=P(t==null?void 0:t.data),r=Qe(t==null?void 0:t.assets)??Qe(n==null?void 0:n.assets)??Qe(t==null?void 0:t.Assets)??Qe(n==null?void 0:n.Assets)??Qe(t==null?void 0:t.AgentAsset)??Qe(n==null?void 0:n.AgentAsset)??Qe(t==null?void 0:t.agentAsset)??Qe(n==null?void 0:n.agentAsset)??Qe(t==null?void 0:t.asset_list);return $D(r)}function iu(e){let t=P(e),n=P(t==null?void 0:t.data),r=Qe(t==null?void 0:t.asset_infos)??Qe(n==null?void 0:n.asset_infos)??Qe(t==null?void 0:t.assets)??Qe(n==null?void 0:n.assets)??Qe(t==null?void 0:t.data);return $D(r)}function $D(e){return(e??[]).map(P).filter(Boolean)}var YD=new WeakMap;function XD(e){return!!(e&&typeof e=="object")}function da(e){let t=P(e);return D((t==null?void 0:t.log_id)??(t==null?void 0:t.logId))}function WD(e,t){let n=da(t);return n?new Map(e.map(r=>[r,n])):new Map}function ua(e,t){return XD(e)&&YD.set(e,t),e}function wm(e){return XD(e)?YD.get(e):void 0}function MT(e,t){var n,r;return((r=(n=wm(e))==null?void 0:n.assetLogIds)==null?void 0:r.get(t))??da(e)}function JD(e,t){var n,r;return((r=(n=wm(e))==null?void 0:n.pippitAssetLogIds)==null?void 0:r.get(t))??da(e)}var nJ=200,rJ=20;function QD(e){if((e==null?void 0:e.reason)!==void 0)return e.reason;let t=new Error("Pippit asset info caller aborted");return t.name="AbortError",t}function ZD(){let e=new Error("Pippit asset info coordinator disposed");return e.name="AbortError",e}function eE(e,t){return Number.isFinite(e)&&Number(e)>0?Math.max(1,Math.floor(Number(e))):t}function tE(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))]}function iJ(e){return[(e==null?void 0:e.cachePolicy)??"default",e!=null&&e.refresh?"refresh":"default",(e==null?void 0:e.mediaType)??"",(e==null?void 0:e.purpose)??""].join(":")}function NT(e){e.timer&&(clearTimeout(e.timer),e.timer=void 0)}function km(e,t){var n;e.settled||(e.settled=!0,(n=e.cleanupAbort)==null||n.call(e),t.status==="rejected"?e.reject(t.error):e.resolve(t.response))}function oJ(e,t){let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}function aJ(e){return D(e.asset_id??e.assetId)}function sJ(e,t){let n=new Map,r=new Set,i=0;return e.forEach(o=>{let a=aJ(o);!a||!t.includes(a)||r.has(a)||(i+=1,r.add(a),n.set(a,o))}),i===0&&e.length===t.length&&e.forEach((o,a)=>{let s=t[a];s&&n.set(s,o)}),n}function nE(e,t={}){let n=eE(t.batchDelayMs,nJ),r=eE(t.maxBatchSize,rJ),i=new Map,o=new Set,a=!1,s=async d=>{var h;let u=i.get(d);if(!u)return;i.delete(d),NT(u),o.add(u);let p=u.callers.filter(g=>!g.settled),m=tE(p.flatMap(g=>g.ids));if(!m.length){o.delete(u);return}let f={...(h=p[0])==null?void 0:h.options,signal:u.abortController.signal};try{let g=await Promise.all(oJ(m,r).map(async S=>{let T=await e({asset_ids:S},f);return{logIdsById:WD(S,T),recordsById:sJ(iu(T),S)}})),y=new Map,_=new Map;g.forEach(S=>{S.logIdsById.forEach((T,C)=>y.set(C,T)),S.recordsById.forEach((T,C)=>_.set(C,T))}),p.forEach(S=>{let T=new Map;S.ids.forEach(C=>{let I=y.get(C);I&&T.set(C,I)}),km(S,{response:ua({asset_infos:S.ids.map(C=>_.get(C)).filter(C=>!!C)},{assetLogIds:T}),status:"resolved"})})}catch(g){p.forEach(y=>km(y,{error:g,status:"rejected"}))}finally{o.delete(u)}},c=(d,u)=>new Promise((p,m)=>{let f=iJ(u),h=i.get(f),g=h??{abortController:new AbortController,callers:[]},y={ids:d,options:u,reject:m,resolve:p,settled:!1};g.callers.push(y);let _=u==null?void 0:u.signal;if(_){let T=()=>{km(y,{error:QD(_),status:"rejected"}),g.callers.every(C=>C.settled)&&(i.get(f)===g&&(i.delete(f),NT(g)),g.abortController.abort())};y.cleanupAbort=()=>_.removeEventListener("abort",T),_.addEventListener("abort",T,{once:!0}),_.aborted&&T()}if(y.settled)return;h||i.set(f,g),(u==null?void 0:u.dispatchMode)==="immediate"?s(f):h||(g.timer=setTimeout(()=>void s(f),n))});return{dispose:()=>{if(a)return;a=!0;let d=ZD(),u=new Set([...i.values(),...o]);i.clear(),u.forEach(p=>{NT(p),p.abortController.abort(),p.callers.forEach(m=>km(m,{error:d,status:"rejected"}))}),o.clear()},query:(d,u)=>{var m;if(a)return Promise.reject(ZD());if((m=u==null?void 0:u.signal)!=null&&m.aborted)return Promise.reject(QD(u.signal));let p=tE(d.asset_ids);return p.length?c(p,u):Promise.resolve({asset_infos:[]})}}}var cJ=["origin",...ks.filter(e=>e!=="origin")];function iE(e,t){var n,r,i;return((r=(n=e==null?void 0:e.image)==null?void 0:n.previewVariants)==null?void 0:r[t])??((i=e==null?void 0:e.image)==null?void 0:i.previews)}function oE(e,t){var n,r,i;return((r=(n=e==null?void 0:e.image)==null?void 0:n.downloadVariants)==null?void 0:r[t])??((i=e==null?void 0:e.image)==null?void 0:i.download)}function ou(e,t,n){let r=iE(e,n);if(r)for(let i of t){let o=r[i];if(o!=null&&o.url)return o}}function dJ(e,t,n){var s,c;let r=ou(e,dm,t),i=ou(e,um,t),o=ou(e,ks,t),a=ou(e,[n],t)??i??o??r;if(a)return{metadata:{format:a.format??(o==null?void 0:o.format)??(i==null?void 0:i.format)??(r==null?void 0:r.format),height:a.height??(o==null?void 0:o.height)??(i==null?void 0:i.height)??(r==null?void 0:r.height),imageVariant:t,size:a.size??(o==null?void 0:o.size)??(i==null?void 0:i.size)??(r==null?void 0:r.size),width:a.width??(o==null?void 0:o.width)??(i==null?void 0:i.width)??(r==null?void 0:r.width)},raw:e==null?void 0:e.raw,type:"image",urls:{download:((s=oE(e,t))==null?void 0:s.url)??((c=ou(e,["origin",...ks],t))==null?void 0:c.url)??(o==null?void 0:o.url)??a.url,high:(o==null?void 0:o.url)??(i==null?void 0:i.url)??(r==null?void 0:r.url)??a.url,low:(r==null?void 0:r.url)??(i==null?void 0:i.url)??(o==null?void 0:o.url)??a.url,medium:(i==null?void 0:i.url)??(o==null?void 0:o.url)??(r==null?void 0:r.url)??a.url,url:a.url}}}function uJ(e,t,n){let r=(e==null?void 0:e.assetId)??(e==null?void 0:e.pippitAssetId)??"image",{url:i}=n;return{identity:Yn({assetId:e==null?void 0:e.assetId,pippitAssetId:e==null?void 0:e.pippitAssetId}),isProvisional:!0,metadata:{assetId:e==null?void 0:e.assetId,format:n.format,height:n.height,imageVariant:t,pippitAssetId:e==null?void 0:e.pippitAssetId,resolution:"origin",size:n.size,width:n.width},preview:{metadata:{format:n.format,height:n.height,imageVariant:t,size:n.size,width:n.width},raw:e==null?void 0:e.raw,type:"image",urls:{url:i}},url:i,version:`${r}:origin:${t}:provisional:${ri(i)}`}}function pJ(e){var i,o,a;let t=(i=e==null?void 0:e.video)==null?void 0:i.coverUrl;if(!t)return;let n=(e==null?void 0:e.assetId)??(e==null?void 0:e.pippitAssetId)??"video-cover",r={height:(o=e==null?void 0:e.video)==null?void 0:o.height,width:(a=e==null?void 0:e.video)==null?void 0:a.width};return{identity:Yn({assetId:e==null?void 0:e.assetId,pippitAssetId:e==null?void 0:e.pippitAssetId}),metadata:{assetId:e==null?void 0:e.assetId,...r,pippitAssetId:e==null?void 0:e.pippitAssetId,resolution:"origin"},preview:{metadata:r,raw:e==null?void 0:e.raw,type:"image",urls:{download:t,high:t,low:t,medium:t,poster:t,url:t}},url:t,version:`${n}:video-cover:${ri(t)}`}}function rE(e,t,n,r,i){let o=(e==null?void 0:e.assetId)??(e==null?void 0:e.pippitAssetId)??"image";return{identity:Yn({assetId:e==null?void 0:e.assetId,pippitAssetId:e==null?void 0:e.pippitAssetId}),metadata:{assetId:e==null?void 0:e.assetId,format:r==null?void 0:r.format,height:r==null?void 0:r.height,imageVariant:t,pippitAssetId:e==null?void 0:e.pippitAssetId,resolution:n,size:r==null?void 0:r.size,width:r==null?void 0:r.width},preview:dJ(e,t,n),url:i,version:`${o}:${n}:${t}:${ri(i)}`}}function aE(e,t){var s,c;let n=t.imageVariant??"default",r=iE(e,n),i=oE(e,n);if(t.purpose==="download"&&(i!=null&&i.url))return rE(e,n,"origin",i,i.url);let o=t.purpose==="download"?cJ:wP(t);for(let d of o){let u=(s=r==null?void 0:r[d])==null?void 0:s.url;if(u)return rE(e,n,d,r==null?void 0:r[d],u)}let a=(c=e==null?void 0:e.image)==null?void 0:c.provisionalPreview;return t.purpose==="preview"&&n==="default"&&(a!=null&&a.url)?uJ(e,n,a):pJ(e)}function cE(e){return e?{createAsset:async t=>{if(e.createAsset)return e.createAsset(t);let n=await lJ(e,t),r=await wT(e,{intent:"asset.create",patches:[{baseVersion:0,op:"add",path:"",ref:n,value:yJ(t)}],signal:t.signal});return{raw:r.raw,ref:n,version:sE(r,n)}},patchAssets:async t=>e.patchAssets?e.patchAssets(t):wT(e,t),updateAsset:async(t,n)=>{let r=_e(t);if(e.updateAsset)return e.updateAsset(r,n);let i=await wT(e,{intent:n.intent??"asset.update",patches:mJ(r,n),signal:n.signal,transactionId:n.transactionId});return{raw:i.raw,ref:r,version:sE(i,r)}}}:{}}async function lJ(e,t){if(t.ref)return _e(t.ref);if(!e.batchGeneratePippitAssetIds)throw new Error("Pippit asset create requires request.ref or batchGeneratePippitAssetIds.");let n=await e.batchGeneratePippitAssetIds({count:1}),r=_J(n);if(!r)throw new Error("Pippit asset ID generation returned no usable pippitAssetId.");return _e({mediaType:t.mediaType,pippitAssetId:r})}function mJ(e,t){var n;return(n=t.patches)!=null&&n.length?t.patches.map(r=>({...r,ref:_e(r.ref)})):[{op:"replace",path:"",ref:e,value:t.content??{metadata:t.metadata}}]}async function wT(e,t){var o,a;if(!e.batchPatchAsset)throw new Error("Pippit asset batchPatchAsset transport is not configured.");let n=fJ(t),r=n.transactionId||`asset_patch_${Date.now()}`,i=await e.batchPatchAsset({batch_id:n.batchId||`batch_${r}`,client_id:n.clientId||`client_${r}`,root_pippit_asset_id:((o=n.rootRef)==null?void 0:o.pippitAssetId)??((a=n.patches[0])==null?void 0:a.ref.pippitAssetId),transactions:[{attempt:1,enqueued_at:Date.now(),intent:n.intent,patches:n.patches.map(hJ),transaction_id:r}]});return dE(i,"Pippit asset patch failed."),{raw:i,versions:TJ(i,r)}}function fJ(e){return{...e,patches:e.patches.map(t=>({...t,ref:_e(t.ref)})),rootRef:e.rootRef?_e(e.rootRef):void 0}}function hJ(e){return{asset_id:gJ(e.ref),base_asset_version:e.baseVersion,op:e.op,path:e.path,...e.op==="remove"?{}:{value:e.value}}}function gJ(e){return e.pippitAssetId??e.assetId}function yJ(e){return e.content!==void 0?e.content:{mediaType:e.mediaType,metadata:e.metadata}}function sE(e,t){var r;let n=t.pippitAssetId??t.assetId;return n?(r=e.versions)==null?void 0:r[n]:void 0}function _J(e){dE(e,"Pippit asset ID generation failed.");let t=P(e),n=P(t==null?void 0:t.data),r=Qe(n==null?void 0:n.ids)??Qe(t==null?void 0:t.ids),i=r==null?void 0:r.find(eu);return i==null?void 0:i.trim()}function dE(e,t){let n=P(e),r=Number((n==null?void 0:n.ret)??0);if(Number.isNaN(r)||r!==0)throw new Error(typeof(n==null?void 0:n.errmsg)=="string"?n.errmsg:t)}function TJ(e,t){let n=P(e),r=P(n==null?void 0:n.data),i=Qe(r==null?void 0:r.results)??Qe(n==null?void 0:n.results),o=i==null?void 0:i.find(d=>{let u=P(d);return(u==null?void 0:u.transaction_id)===t||(u==null?void 0:u.transactionId)===t}),a=P(o)??P(i==null?void 0:i[0]),s=P(a==null?void 0:a.asset_versions)??P(a==null?void 0:a.assetVersions);if(!s)return;let c={};for(let[d,u]of Object.entries(s)){let p=Ae(u);p!==void 0&&(c[d]=p)}return Object.keys(c).length?c:void 0}function uE(e){return Number.isFinite(e)&&e>0?Math.max(1,Math.floor(e)):1}function oi(e,t,n){if(e.length===0)return[];let r=uE(t),i=uE(n),o=Math.ceil(e.length/r),a=Math.min(e.length,Math.max(o,i)),s=Math.floor(e.length/a),c=e.length%a,d=[],u=0;for(let p=0;p<a;p+=1){let m=s+(p<c?1:0);d.push(e.slice(u,u+m)),u+=m}return d}var OT="PIPPIT_ASSET_QUERY_TIMEOUT",kT=class extends Error{constructor(n){super(`Pippit asset query did not finish within ${n} ms.`);this.code=OT;this.name="PippitAssetQueryTimeoutError"}},eo=e=>{if((e==null?void 0:e.reason)!==void 0)return e.reason;let t=new Error("Pippit asset query caller aborted");return t.name="AbortError",t};async function pE(e,t,n,r){if(r<=0)return e(t,n);let i=new AbortController,o=n==null?void 0:n.signal,a,s,c=new Promise((d,u)=>{s=()=>{let p=eo(o);i.abort(p),u(p)},o==null||o.addEventListener("abort",s,{once:!0}),a=setTimeout(()=>{let p=new kT(r);i.abort(p),u(p)},r)});o!=null&&o.aborted&&(s==null||s());try{return await Promise.race([Promise.resolve().then(()=>{if(i.signal.aborted)throw i.signal.reason??eo(o);return e(t,{...n,signal:i.signal})}),c])}finally{a!==void 0&&clearTimeout(a),s&&(o==null||o.removeEventListener("abort",s))}}var Om="PIPPIT_ASSET_AUTHENTICATION_ERROR",lE=1015,LT=class extends Error{constructor(n,r={}){super(n);this.code=Om;this.retryable=!1;this.serviceCode=lE;this.name="PippitAssetAuthenticationError",this.logId=r.logId}};function Lm(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code===Om}function Fm(e){let t=P(e);if(Ae(t==null?void 0:t.ret)===lE)throw new LT(D((t==null?void 0:t.errmsg)??(t==null?void 0:t.message))??"Pippit asset authentication failed.",{logId:da(e)})}async function mE(e,t,n,r,i){var a,s;let o;for(let c=1;c<=Math.max(1,i);c+=1){if((a=n==null?void 0:n.signal)!=null&&a.aborted)throw eo(n.signal);try{let d=await pE(e,t,n,r);return Fm(d),{logId:da(d),records:Nm(d)}}catch(d){if((s=n==null?void 0:n.signal)!=null&&s.aborted)throw eo(n.signal);if(Lm(d))throw d;o=d}}throw o}var SJ=200,bJ=150,CJ=20,AJ=2,IJ=500,Bm=()=>{let e=new Error("Pippit asset query coordinator disposed");return e.name="AbortError",e},FT=e=>{e.timer&&(clearTimeout(e.timer),e.timer=void 0)},au=(e,t)=>{var n;e.settled||(e.settled=!0,(n=e.cleanupAbort)==null||n.call(e),t.status==="rejected"?e.reject(t.error):e.resolve(t.records))},fE=(e,t,n,r,i,o)=>new Promise((a,s)=>{let{cacheKey:c,queueKey:d}=t,u={ids:n,options:r,reject:s,resolve:a,settled:!1},p=e.get(d),m=p??{abortController:new AbortController,cacheKey:c,callers:[]};m.callers.push(u);let f=r==null?void 0:r.signal;if(f){let h=()=>{au(u,{error:eo(f),status:"rejected"}),m.callers.every(g=>g.settled)&&(e.get(d)===m&&(FT(m),e.delete(d)),m.abortController.abort())};u.cleanupAbort=()=>f.removeEventListener("abort",h),f.addEventListener("abort",h,{once:!0}),f.aborted&&h()}if(!u.settled){if(p){(r==null?void 0:r.dispatchMode)==="immediate"&&(FT(p),o.flush(e,d,i));return}if(e.set(d,m),(r==null?void 0:r.dispatchMode)==="immediate")return void o.flush(e,d,i);m.timer=setTimeout(()=>void o.flush(e,d,i),o.batchDelayMs)}}),Gm=e=>e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(Gm).join(",")}]`:`{${Object.entries(e).filter(([,t])=>t!==void 0).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>`${JSON.stringify(t)}:${Gm(n)}`).join(",")}}`,vJ=e=>D(e.pippit_asset_id??e.pippitAssetId??e.PippitAssetID),hE=e=>{let t=new Map;return e.forEach(n=>{let r=vJ(n);r&&t.set(r,n)}),t},xJ=(e,t)=>{let n=e.map(i=>t.recordsById.get(i)).filter(i=>!!i),r=new Map;return e.forEach(i=>{let o=t.logIdsById.get(i);o&&r.set(i,o)}),ua(n,{pippitAssetLogIds:r})},RJ=(e,t)=>{e.forEach(n=>au(n,{records:xJ(n.ids,t),status:"resolved"}))},PJ=(e,t)=>ua(e,{pippitAssetLogIds:t}),gE=(e,t)=>(e==null?void 0:e.batchingStrategy)??t.batchingStrategy??"max-size",DJ=(e,t)=>Gm({batchingStrategy:t,cacheKey:e}),EJ=(e,t)=>{let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n},MJ=(e,t,n,r)=>t==="balanced"?oi(e,n,r):EJ(e,Math.max(1,n)),NJ=e=>{let t=n=>{let r={pippit_asset_ids:n};return(typeof e.bodyExtra=="function"?e.bodyExtra(r):e.bodyExtra)??{}};return{bodyExtraFor:t,cacheKeyFor:n=>Gm({bodyExtra:t(n),scopeKey:e.scopeKey})}},wJ=e=>typeof e=="number"&&Number.isFinite(e)?Math.max(0,e):0;function zm(e,t={}){let n=new Map,r=new Map,i=new Map,o=new Map,a=new Set,s=wJ(t.attemptTimeoutMs),c=t.batchDelayMs??SJ,d=t.cacheTtlMs??IJ,u=t.maxBatchSize??bJ,p=t.maxAttempts??AJ,m=t.maxConcurrentChunks??CJ,f=NJ(t),h=0,g=0,y=!1,_=[],S=async H=>{var U;if(y||(h>=m&&await new Promise(W=>_.push(W)),y))throw Bm();h+=1;try{return await H()}finally{h-=1,(U=_.shift())==null||U()}},T=(H,U)=>MJ(H,gE(U,t),u,m),C=(H,U)=>{let W=Date.now(),re=new Map,Q=[];for(let Ge of H){let Xe=`${U}:${Ge}`,Ce=i.get(Xe);if(!Ce||Ce.expiresAt<=W)return i.delete(Xe),{complete:!1,logIdsById:new Map,records:[]};Ce.logId&&re.set(Ge,Ce.logId),Ce.record&&Q.push(Ce.record)}return{complete:!0,logIdsById:re,records:Q}},I=async(H,U)=>{let W={...f.bodyExtraFor(H),pippit_asset_ids:H};return mE(e,W,U,s,p)},x=async(H,U,W)=>{let re=g,Q=Date.now(),Ge=new Map,Xe=new Map,Ce=[],ze=[];H.forEach(Re=>{let wt=`${U}:${Re}`,kt=i.get(wt);if(kt&&kt.expiresAt>Q){kt.logId&&Ge.set(Re,kt.logId),kt.record&&Xe.set(Re,kt.record);return}i.delete(wt);let on=o.get(wt);if(on){Ce.push(on.then(an=>{an.logId&&Ge.set(Re,an.logId),an.record&&Xe.set(Re,an.record)}));return}ze.push(Re)});let Nt=T(ze,W).map(async Re=>{let kt=S(()=>I(Re,W)).then(({logId:ut,records:Ot})=>({logId:ut,recordMap:hE(Ot)}));Re.forEach(ut=>{let Ot=`${U}:${ut}`,Ns=kt.then(({logId:W5,recordMap:J5})=>({logId:W5,record:J5.get(ut)??null}));o.set(Ot,Ns);let vP=()=>{o.get(Ot)===Ns&&o.delete(Ot)};Ns.then(vP,vP)});let{logId:on,recordMap:an}=await kt;Re.forEach(ut=>{let Ot=an.get(ut)??null;!y&&g===re&&i.set(`${U}:${ut}`,{expiresAt:Date.now()+d,logId:on,record:Ot}),on&&Ge.set(ut,on),Ot&&Xe.set(ut,Ot)})});return await Promise.all([...Nt,...Ce]),{logIdsById:Ge,recordsById:Xe}},R=async(H,U,W)=>{let re=g,Q=new Map,Ge=new Map;return await Promise.all(T(H,W).map(async Xe=>{let{logId:Ce,records:ze}=await S(()=>I(Xe,W)),Nt=hE(ze);Xe.forEach(Re=>{let wt=Nt.get(Re)??null;!y&&g===re&&i.set(`${U}:${Re}`,{expiresAt:Date.now()+d,logId:Ce,record:wt}),Ce&&Q.set(Re,Ce),wt&&Ge.set(Re,wt)})})),{logIdsById:Q,recordsById:Ge}},G=async(H,U,W)=>{var Ce;let re=H.get(U);if(!re)return;H.delete(U),a.add(re);let Q=re.callers.filter(ze=>!ze.settled),Ge=[...new Set(Q.flatMap(ze=>ze.ids))],Xe={...(Ce=Q[0])==null?void 0:Ce.options,signal:re.abortController.signal};try{RJ(Q,await W(Ge,re.cacheKey,Xe))}catch(ze){Q.forEach(Nt=>au(Nt,{error:ze,status:"rejected"}))}finally{a.delete(re)}},O=()=>{g+=1,i.clear(),o.clear()};return{clear:O,dispose:()=>{if(y)return;y=!0,g+=1;let H=Bm();[n,r].forEach(U=>{U.forEach(W=>{FT(W),W.abortController.abort(),W.callers.forEach(re=>au(re,{error:H,status:"rejected"}))}),U.clear()}),a.forEach(U=>{U.abortController.abort(),U.callers.forEach(W=>au(W,{error:H,status:"rejected"}))}),i.clear(),o.clear(),_.splice(0).forEach(U=>U())},invalidate:O,query:(H,U)=>{var Xe;if(y)return Promise.reject(Bm());if((Xe=U==null?void 0:U.signal)!=null&&Xe.aborted)return Promise.reject(eo(U.signal));let W=[...new Set(H.map(Ce=>Ce.trim()).filter(Boolean))];if(!W.length)return Promise.resolve([]);let re=f.cacheKeyFor(W),Q=DJ(re,gE(U,t));if((U==null?void 0:U.cachePolicy)==="refresh")return fE(r,{cacheKey:re,queueKey:Q},W,U,R,{batchDelayMs:c,flush:G});let Ge=C(W,re);return Ge.complete?Promise.resolve(PJ(Ge.records,Ge.logIdsById)):fE(n,{cacheKey:re,queueKey:Q},W,U,x,{batchDelayMs:c,flush:G})}}}function BT({assetInfo:e,assetQuery:t,mgetAssetInfo:n,mutation:r,query:i,resolveEncryptedUrl:o,shouldUseAssetQuerySource:a,subscription:s,upload:c}){let d=cE(r),u=t&&i?zm(t,i):void 0,p=u?async(g,y)=>{let _=await u.query(g.pippit_asset_ids,y);return ua({data:{Assets:_},ret:0},wm(_)??{})}:t,m=n&&e!==!1?nE(n,e):void 0,f=m?(g,y)=>m.query(g,y):n,h=s?gT(s):void 0;return{...d,allocateAssetIds:r!=null&&r.batchGeneratePippitAssetIds?async g=>{var y;return OJ(await((y=r.batchGeneratePippitAssetIds)==null?void 0:y.call(r,{count:g})),g)}:void 0,dispose:()=>{m==null||m.dispose(),u==null||u.dispose(),h==null||h.dispose()},invalidateAssets:()=>u==null?void 0:u.invalidate(),async queryAssets(g,y){let{assetsById:_}=await Um(g,{assetQuery:p},y),S=g.filter(I=>LJ(I,_)),{assetsById:T}=await TE(S,{mgetAssetInfo:f},y),C=g.map(I=>{if(I.pippitAssetId){let x=_.get(I.pippitAssetId);return x?(Vm(I,x),x):yE(I,T)}return yE(I,T)}).filter(I=>!!I);return Promise.all(C.map(I=>kJ(I,y)))},async resolveSource(g,y){if(y.mediaType==="image"){let{asset:S,logId:T}=await _E(g,{assetQuery:p,mgetAssetInfo:f},y),C=aE(S,y);if(C!=null&&C.isProvisional&&y.allowProvisionalImage===!1)throw new xt("Public image preview is not ready yet.",{logId:T});if(!C)throw new xt("No image source URL found yet.",{logId:T});return C}if(y.mediaType==="audio"){let{asset:S,logId:T}=await _E(g,{assetQuery:p,mgetAssetInfo:f},y),C=IT(S,y);if(!C)throw new xt("No audio source URL found yet.",{logId:T});return C}if(y.mediaType!=="video")throw new Error(`Source resolution for ${y.mediaType} assets is not supported.`);let _=await zJ(g,y,{assetQuery:p,mgetAssetInfo:f,resolveEncryptedUrl:o,shouldUseAssetQuerySource:a});if(!_)throw new xt("No video source URL found yet.");return _},subscribeAssetEvents:h?(g,y,_)=>h.subscribe(g,y,_):void 0,upload:c}}async function kJ(e,t){var r,i;if(e.mediaType!=="text"||(r=e.text)!=null&&r.content||!((i=e.text)!=null&&i.downloadUrl))return e;let n=await fetch(e.text.downloadUrl,{signal:t.signal});if(!n.ok)throw new Error(`Failed to download Pippit text asset: ${n.status} ${n.statusText}`);return{...e,text:{...e.text,content:await n.text()}}}function OJ(e,t){let n=e&&typeof e=="object"?e:void 0,r=Number((n==null?void 0:n.ret)??0);if(Number.isNaN(r)||r!==0)throw new Error(typeof(n==null?void 0:n.errmsg)=="string"?n.errmsg:"Pippit asset ID generation failed.");let i=n!=null&&n.data&&typeof n.data=="object"&&!Array.isArray(n.data)?n.data:void 0,a=(Array.isArray(i==null?void 0:i.ids)?i.ids:Array.isArray(n==null?void 0:n.ids)?n.ids:[]).filter(s=>typeof s=="string"&&!!s.trim());if(a.length<t)throw new Error(`Pippit asset ID generation returned ${a.length}/${t} IDs.`);return a}function LJ(e,t){return e.assetId?e.pippitAssetId?!t.has(e.pippitAssetId):!0:!1}function yE(e,t){return e.assetId?t.get(e.assetId):void 0}async function Um(e,t,n){let r=SE(e.map(a=>a.pippitAssetId).filter(eu));if(!r.length)return{assetsById:new Map,logIdsById:new Map};if(!t.assetQuery){if(e.filter(a=>a.pippitAssetId).every(a=>a.assetId))return{assetsById:new Map,logIdsById:new Map};throw new Error("assetQuery is not configured.")}let i=await t.assetQuery({pippit_asset_ids:r},n);Fm(i);let o=new Map;return r.forEach(a=>{let s=JD(i,a);s&&o.set(a,s)}),{assetsById:new Map(Nm(i).map(a=>{let s=FJ(a),c=e.find(d=>d.pippitAssetId===s);return OD(a,c)}).filter(a=>a.pippitAssetId).map(a=>[a.pippitAssetId,a])),logIdsById:o}}function FJ(e){return D(e.pippit_asset_id??e.pippitAssetId??e.PippitAssetID)}async function TE(e,t,n){let r=e.filter(d=>eu(d.assetId)),i=SE(r.map(d=>d.assetId));if(!i.length)return{assetsById:new Map,logIdsById:new Map};if(!t.mgetAssetInfo){if(r.every(d=>d.pippitAssetId))return{assetsById:new Map,logIdsById:new Map};throw new Error("mgetAssetInfo is not configured.")}let o=await t.mgetAssetInfo({asset_ids:i},n),a=iu(o),s=GJ(a,r),c=new Map;return i.forEach(d=>{let u=MT(o,d);u&&c.set(d,u)}),{assetsById:new Map(a.map((d,u)=>{let p=s[u],m=LD(d,p),f=(p==null?void 0:p.assetId)??m.assetId;return f?[f,m]:void 0}).filter(d=>!!d)),logIdsById:c}}function BJ(e){return typeof e.asset_id=="string"&&e.asset_id.trim()?e.asset_id.trim():typeof e.assetId=="string"&&e.assetId.trim()?e.assetId.trim():void 0}function GJ(e,t){let n=e.map(()=>{}),r=new Set,i=0;return e.forEach((a,s)=>{let c=BJ(a);if(!c)return;let d=t.findIndex((u,p)=>!r.has(p)&&u.assetId===c);d>=0&&(r.add(d),n[s]=t[d],i+=1)}),i===0&&e.length===t.length&&e.forEach((a,s)=>{n[s]=t[s]}),n}function SE(e){return Array.from(new Set(e))}async function zJ(e,t,n){return UJ(e)&&VJ(t,n)&&await qJ(e,t,n)?KJ(e,t,n):$J(e,t,n)}function UJ(e){return!!e.pippitAssetId}function VJ(e,t){return!e.refresh&&!!(t.assetQuery&&t.shouldUseAssetQuerySource)}async function qJ(e,t,n){var r,i;try{return!!await((r=n.shouldUseAssetQuerySource)==null?void 0:r.call(n,{options:t,ref:e}))}catch(o){if((i=t.signal)!=null&&i.aborted)throw o;return!1}}async function KJ(e,t,n){let{asset:r,logId:i}=await HJ(e,t,n),o=bE(r)?void 0:RT(r,t);if(WJ(o,t))return su(o,r);let a=jJ(e,r);if(!a){if(o)return su(o,r);throw new xt("No video source URL found yet.",{logId:i})}return CE(e,a,t,n,r??IE(e))}function bE(e){return(e==null?void 0:e.playerInfoVersion)!==1}function jJ(e,t){return bE(t)?e.assetId??(t==null?void 0:t.assetId):(t==null?void 0:t.assetId)??e.assetId}async function HJ(e,t,n){var r;try{let{assetsById:i,logIdsById:o}=await Um([e],n,t),a=i.get(e.pippitAssetId);return a&&Vm(e,a),{asset:a,logId:o.get(e.pippitAssetId)}}catch(i){if((r=t.signal)!=null&&r.aborted)throw i;return{}}}async function $J(e,t,n){if(e.assetId){let a=await AE(e.assetId,t,n);return JJ(a,IE(e))}let{asset:r,logId:i}=await XJ(e,t,n);if(r!=null&&r.assetId)return CE(e,r.assetId,t,n,r,{strictAssetId:!0});let o=t.purpose==="download"?RT(r,t):void 0;if(o)return su(o,r);throw!e.pippitAssetId||!n.assetQuery?new Error("resolveSource requires assetId or assetQuery with pippitAssetId."):t.purpose==="preview"?new xt("AssetQuery did not return an asset_id for source resolution.",{logId:i}):new Error("AssetQuery did not return an asset_id for source resolution.")}async function CE(e,t,n,r,i,o={}){let a=YJ(e,t,n);try{let s=await AE(t,n,r,o);if(!s&&a)throw sT(new xt("No video source URL found yet."),a);return s&&su(s,i)}catch(s){throw!a||!fr(s)||hm(s)?s:sT(s,a)}}function YJ(e,t,n){if(!(e.assetId||!e.pippitAssetId||n.mediaType!=="video"||n.purpose!=="preview"))return{assetId:t,mediaType:"video",pippitAssetId:e.pippitAssetId}}async function XJ(e,t,n){if(!e.pippitAssetId||!n.assetQuery)return{};let{assetsById:r,logIdsById:i}=await Um([e],n,t),o=r.get(e.pippitAssetId);return o&&Vm(e,o),{asset:o,logId:i.get(e.pippitAssetId)}}function WJ(e,t){var n,r;return e?t.purpose==="download"||!!((r=(n=e.preview)==null?void 0:n.urls)!=null&&r.poster):!1}async function AE(e,t,n,r={}){if(!n.mgetAssetInfo)throw new Error("mgetAssetInfo is not configured.");let i=await n.mgetAssetInfo({asset_ids:[e]},t),o=MT(i,e),a=iu(i)[0];if(!a)throw t.purpose==="preview"?new xt("No video asset info found yet.",{logId:o}):new Error("Pippit asset info was not found.");let s=await CD(e,a,t,{resolveEncryptedUrl:n.resolveEncryptedUrl,strictAssetId:r.strictAssetId});if(!s&&t.purpose==="preview")throw new xt("No video source URL found yet.",{logId:o});return s}async function _E(e,t,n){let r;if(e.pippitAssetId&&t.assetQuery){let{assetsById:a,logIdsById:s}=await Um([e],t,n),c=a.get(e.pippitAssetId);if(r=s.get(e.pippitAssetId),c)return Vm(e,c),{asset:c,logId:r}}if(!e.assetId)return{logId:r};let{assetsById:i,logIdsById:o}=await TE([e],t,n);return{asset:i.get(e.assetId),logId:o.get(e.assetId)??r}}function Vm(e,t){if(e.pippitAssetId&&t.pippitAssetId&&e.pippitAssetId!==t.pippitAssetId)throw new Error(`Resolved pippitAssetId ${t.pippitAssetId} does not match requested pippitAssetId ${e.pippitAssetId}.`);if(!e.pippitAssetId&&e.assetId&&t.assetId&&e.assetId!==t.assetId)throw new Error(`Resolved assetId ${t.assetId} does not match requested assetId ${e.assetId}.`)}function IE(e){return{assetId:e.assetId,mediaType:e.mediaType,pippitAssetId:e.pippitAssetId}}function JJ(e,t){return e?su(e,t):void 0}function su(e,t){var o,a,s,c,d;let n=Yn({assetId:((o=e.identity)==null?void 0:o.assetId)??(t==null?void 0:t.assetId),pippitAssetId:((a=e.identity)==null?void 0:a.pippitAssetId)??(t==null?void 0:t.pippitAssetId)}),r=((c=(s=e.preview)==null?void 0:s.urls)==null?void 0:c.poster)??((d=t==null?void 0:t.video)==null?void 0:d.coverUrl),i={...n!=null&&n.assetId?{assetId:n.assetId}:{},...n!=null&&n.pippitAssetId?{pippitAssetId:n.pippitAssetId}:{}};return{...e,identity:n,metadata:{...e.metadata,...i,...r?{poster:r}:{}},preview:e.preview?{...e.preview,raw:e.preview.raw??(t==null?void 0:t.raw),urls:{...e.preview.urls,...r?{poster:r}:{}}}:void 0}}var Mn="canvas";function Nn(e){return e.type===Mn}var RE=/^-?\d+(?:\.\d+)?$/,qm=BigInt(0),vE=BigInt(1),FUe=BigInt("2"),BUe=BigInt("5"),xE=BigInt("10");function QJ(e){if(!RE.test(e))throw new Error(`Invalid fractional index value: ${e}`);let t=e.startsWith("-"),n=t?e.slice(1):e,[r,i=""]=n.split("."),o=`${r}${i}`.replace(/^0+(?=\d)/,"")||"0",a=BigInt(o)*(t?-vE:vE);return a===qm?{coefficient:qm,scale:0}:{coefficient:a,scale:i.length}}function ZJ(e){let{coefficient:t,scale:n}=e;for(;n>0&&t%xE===qm;)t/=xE,n-=1;let r=t<qm,i=(r?-t:t).toString().padStart(n+1,"0"),o=n===0?i:`${i.slice(0,-n)}.${i.slice(-n)}`;return r?`-${o}`:o}function PE(e){return typeof e=="string"&&RE.test(e)}function Km(e){return!!(e&&typeof e=="object"&&PE(e.value)&&typeof e.sessionId=="string"&&e.sessionId.length>0)}function GT(e){return ZJ(QJ(e))}function jm(e){let t=e.assets[e.rootCanvasId];if(!t)throw new Error(`Root canvas asset ${e.rootCanvasId} is missing`);if(!Nn(t))throw new Error(`Root asset ${e.rootCanvasId} is not a canvas`);return t}function M(e){return jm(e).content}var e7={snap:{enabled:!0,threshold:8,targets:["grid","node"]},grid:{size:28,visible:!0}};function zs(e){let t={pippitAssetId:e,type:Mn,content:{metadata:{title:"Canvas",globalBounds:{minX:-4e3,minY:-3e3,maxX:4e3,maxY:3e3}},settings:e7,nodes:{},edges:{},nodeLabels:{byId:{}}},extra:{}};return{rootCanvasId:e,assets:{[e]:t}}}var zT=20,qUe=+"36",KUe=+"2";var n7=/^#[0-9A-F]{6}$/;function Hm(e){return e.trim().toUpperCase()}function UT(e){return typeof e=="string"&&n7.test(Hm(e))}var DE;function EE(e){let t=globalThis.console;if(!t||typeof t!="object")return;let n=t[e];return typeof n=="function"?n.bind(t):void 0}function VT(e,t){var n;(n=EE(e))==null||n(...t),e==="error"&&r7(t)}function r7(e){var t;if(DE)try{DE({packageName:"canvas-sdk",message:i7(e),error:o7(e),context:a7(e)})}catch(n){(t=EE("warn"))==null||t("[canvas-sdk] error reporter failed",n)}}function i7(e){return e.filter(n=>typeof n=="string"||typeof n=="number"||typeof n=="boolean").map(n=>String(n)).join(" ")||"[canvas-sdk] error"}function o7(e){for(let t of e){if(t instanceof Error)return t;if(ME(t)&&t.error instanceof Error)return t.error}}function a7(e){let t={},n=20;for(let r of e){if(n<=0)break;if(!(r instanceof Error)&&ME(r))for(let[i,o]of Object.entries(r)){if(n<=0)break;t[i]=s7(o),n-=1}}return t}function s7(e){var t;return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e.length>500?`${e.slice(0,500)}...`:e:e===null||typeof e=="number"||typeof e=="boolean"||typeof e>"u"?e:Array.isArray(e)?`[array:${e.length}]`:typeof e=="object"?`[object:${((t=e.constructor)==null?void 0:t.name)||"Object"}]`:String(e)}function ME(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}var pt={error:(...e)=>VT("error",e),info:(...e)=>VT("info",e),warn:(...e)=>VT("warn",e)};var QT=Symbol.for("immer-nothing"),cu=Symbol.for("immer-draftable"),cn=Symbol.for("immer-state");function Ft(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Us=Object.getPrototypeOf;function la(e){return!!e&&!!e[cn]}function to(e){var t;return e?FE(e)||Array.isArray(e)||!!e[cu]||!!((t=e.constructor)!=null&&t[cu])||Vs(e)||fu(e):!1}var c7=Object.prototype.constructor.toString(),NE=new WeakMap;function FE(e){if(!e||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;let n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;if(n===Object)return!0;if(typeof n!="function")return!1;let r=NE.get(n);return r===void 0&&(r=Function.toString.call(n),NE.set(n,r)),r===c7}function du(e,t,n=!0){ma(e)===0?(n?Reflect.ownKeys(e):Object.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function ma(e){let t=e[cn];return t?t.type_:Array.isArray(e)?1:Vs(e)?2:fu(e)?3:0}function uu(e,t){return ma(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function qT(e,t){return ma(e)===2?e.get(t):e[t]}function BE(e,t,n){let r=ma(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function d7(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Vs(e){return e instanceof Map}function fu(e){return e instanceof Set}function pa(e){return e.copy_||e.base_}function HT(e,t){if(Vs(e))return new Map(e);if(fu(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let n=FE(e);if(t===!0||t==="class_only"&&!n){let r=Object.getOwnPropertyDescriptors(e);delete r[cn];let i=Reflect.ownKeys(r);for(let o=0;o<i.length;o++){let a=i[o],s=r[a];s.writable===!1&&(s.writable=!0,s.configurable=!0),(s.get||s.set)&&(r[a]={configurable:!0,writable:!0,enumerable:s.enumerable,value:e[a]})}return Object.create(Us(e),r)}else{let r=Us(e);if(r!==null&&n)return{...e};let i=Object.create(r);return Object.assign(i,e)}}function ZT(e,t=!1){return Wm(e)||la(e)||!to(e)||(ma(e)>1&&Object.defineProperties(e,{set:$m,add:$m,clear:$m,delete:$m}),Object.freeze(e),t&&Object.values(e).forEach(n=>ZT(n,!0))),e}function u7(){Ft(2)}var $m={value:u7};function Wm(e){return e===null||typeof e!="object"?!0:Object.isFrozen(e)}var $T={};function fa(e){let t=$T[e];return t||Ft(0,e),t}function p7(e,t){$T[e]||($T[e]=t)}var pu;function GE(){return pu}function l7(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function wE(e,t){t&&(fa("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function YT(e){XT(e),e.drafts_.forEach(m7),e.drafts_=null}function XT(e){e===pu&&(pu=e.parent_)}function kE(e){return pu=l7(pu,e)}function m7(e){let t=e[cn];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function OE(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];return e!==void 0&&e!==n?(n[cn].modified_&&(YT(t),Ft(4)),to(e)&&(e=Ym(t,e),t.parent_||Xm(t,e)),t.patches_&&fa("Patches").generateReplacementPatches_(n[cn].base_,e,t.patches_,t.inversePatches_)):e=Ym(t,n,[]),YT(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==QT?e:void 0}function Ym(e,t,n){if(Wm(t))return t;let r=e.immer_.shouldUseStrictIteration(),i=t[cn];if(!i)return du(t,(o,a)=>LE(e,i,t,o,a,n),r),t;if(i.scope_!==e)return t;if(!i.modified_)return Xm(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;let o=i.copy_,a=o,s=!1;i.type_===3&&(a=new Set(o),o.clear(),s=!0),du(a,(c,d)=>LE(e,i,o,c,d,n,s),r),Xm(e,o,!1),n&&e.patches_&&fa("Patches").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function LE(e,t,n,r,i,o,a){if(i==null||typeof i!="object"&&!a)return;let s=Wm(i);if(!(s&&!a)){if(la(i)){let c=o&&t&&t.type_!==3&&!uu(t.assigned_,r)?o.concat(r):void 0,d=Ym(e,i,c);if(BE(n,r,d),la(d))e.canAutoFreeze_=!1;else return}else a&&n.add(i);if(to(i)&&!s){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||t&&t.base_&&t.base_[r]===i&&s)return;Ym(e,i),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&(Vs(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&Xm(e,i)}}}function Xm(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&ZT(t,n)}function f7(e,t){let n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:GE(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},i=r,o=eS;n&&(i=[r],o=lu);let{revoke:a,proxy:s}=Proxy.revocable(i,o);return r.draft_=s,r.revoke_=a,s}var eS={get(e,t){if(t===cn)return e;let n=pa(e);if(!uu(n,t))return h7(e,n,t);let r=n[t];return e.finalized_||!to(r)?r:r===KT(e.base_,t)?(jT(e),e.copy_[t]=JT(r,e)):r},has(e,t){return t in pa(e)},ownKeys(e){return Reflect.ownKeys(pa(e))},set(e,t,n){let r=zE(pa(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let i=KT(pa(e),t),o=i==null?void 0:i[cn];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(d7(n,i)&&(n!==void 0||uu(e.base_,t)))return!0;jT(e),WT(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return KT(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,jT(e),WT(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=pa(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){Ft(11)},getPrototypeOf(e){return Us(e.base_)},setPrototypeOf(){Ft(12)}},lu={};du(eS,(e,t)=>{lu[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});lu.deleteProperty=function(e,t){return lu.set.call(this,e,t,void 0)};lu.set=function(e,t,n){return eS.set.call(this,e[0],t,n,e[0])};function KT(e,t){let n=e[cn];return(n?pa(n):e)[t]}function h7(e,t,n){var i;let r=zE(t,n);return r?"value"in r?r.value:(i=r.get)==null?void 0:i.call(e.draft_):void 0}function zE(e,t){if(!(t in e))return;let n=Us(e);for(;n;){let r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Us(n)}}function WT(e){e.modified_||(e.modified_=!0,e.parent_&&WT(e.parent_))}function jT(e){e.copy_||(e.copy_=HT(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var g7=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){let o=n;n=t;let a=this;return function(c=o,...d){return a.produce(c,u=>n.call(this,u,...d))}}typeof n!="function"&&Ft(6),r!==void 0&&typeof r!="function"&&Ft(7);let i;if(to(t)){let o=kE(this),a=JT(t,void 0),s=!0;try{i=n(a),s=!1}finally{s?YT(o):XT(o)}return wE(o,r),OE(i,o)}else if(!t||typeof t!="object"){if(i=n(t),i===void 0&&(i=t),i===QT&&(i=void 0),this.autoFreeze_&&ZT(i,!0),r){let o=[],a=[];fa("Patches").generateReplacementPatches_(t,i,o,a),r(o,a)}return i}else Ft(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(a,...s)=>this.produceWithPatches(a,c=>t(c,...s));let r,i;return[this.produce(t,n,(a,s)=>{r=a,i=s}),r,i]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),typeof(e==null?void 0:e.useStrictIteration)=="boolean"&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){to(e)||Ft(8),la(e)&&(e=y7(e));let t=kE(this),n=JT(e,void 0);return n[cn].isManual_=!0,XT(t),n}finishDraft(e,t){let n=e&&e[cn];(!n||!n.isManual_)&&Ft(9);let{scope_:r}=n;return wE(r,t),OE(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){let i=t[n];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}n>-1&&(t=t.slice(n+1));let r=fa("Patches").applyPatches_;return la(e)?r(e,t):this.produce(e,i=>r(i,t))}};function JT(e,t){let n=Vs(e)?fa("MapSet").proxyMap_(e,t):fu(e)?fa("MapSet").proxySet_(e,t):f7(e,t);return(t?t.scope_:GE()).drafts_.push(n),n}function y7(e){return la(e)||Ft(10,e),UE(e)}function UE(e){if(!to(e)||Wm(e))return e;let t=e[cn],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=HT(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=HT(e,!0);return du(n,(i,o)=>{BE(n,i,UE(o))},r),t&&(t.finalized_=!1),n}function hr(){let t="replace",n="add",r="remove";function i(m,f,h,g){switch(m.type_){case 0:case 2:return a(m,f,h,g);case 1:return o(m,f,h,g);case 3:return s(m,f,h,g)}}function o(m,f,h,g){let{base_:y,assigned_:_}=m,S=m.copy_;S.length<y.length&&([y,S]=[S,y],[h,g]=[g,h]);for(let T=0;T<y.length;T++)if(_[T]&&S[T]!==y[T]){let C=f.concat([T]);h.push({op:t,path:C,value:p(S[T])}),g.push({op:t,path:C,value:p(y[T])})}for(let T=y.length;T<S.length;T++){let C=f.concat([T]);h.push({op:n,path:C,value:p(S[T])})}for(let T=S.length-1;y.length<=T;--T){let C=f.concat([T]);g.push({op:r,path:C})}}function a(m,f,h,g){let{base_:y,copy_:_}=m;du(m.assigned_,(S,T)=>{let C=qT(y,S),I=qT(_,S),x=T?uu(y,S)?t:n:r;if(C===I&&x===t)return;let R=f.concat(S);h.push(x===r?{op:x,path:R}:{op:x,path:R,value:I}),g.push(x===n?{op:r,path:R}:x===r?{op:n,path:R,value:p(C)}:{op:t,path:R,value:p(C)})})}function s(m,f,h,g){let{base_:y,copy_:_}=m,S=0;y.forEach(T=>{if(!_.has(T)){let C=f.concat([S]);h.push({op:r,path:C,value:T}),g.unshift({op:n,path:C,value:T})}S++}),S=0,_.forEach(T=>{if(!y.has(T)){let C=f.concat([S]);h.push({op:n,path:C,value:T}),g.unshift({op:r,path:C,value:T})}S++})}function c(m,f,h,g){h.push({op:t,path:[],value:f===QT?void 0:f}),g.push({op:t,path:[],value:m})}function d(m,f){return f.forEach(h=>{let{path:g,op:y}=h,_=m;for(let I=0;I<g.length-1;I++){let x=ma(_),R=g[I];typeof R!="string"&&typeof R!="number"&&(R=""+R),(x===0||x===1)&&(R==="__proto__"||R==="constructor")&&Ft(16+3),typeof _=="function"&&R==="prototype"&&Ft(16+3),_=qT(_,R),typeof _!="object"&&Ft(16+2,g.join("/"))}let S=ma(_),T=u(h.value),C=g[g.length-1];switch(y){case t:switch(S){case 2:return _.set(C,T);case 3:Ft(16);default:return _[C]=T}case n:switch(S){case 1:return C==="-"?_.push(T):_.splice(C,0,T);case 2:return _.set(C,T);case 3:return _.add(T);default:return _[C]=T}case r:switch(S){case 1:return _.splice(C,1);case 2:return _.delete(C);case 3:return _.delete(h.value);default:return delete _[C]}default:Ft(16+1,y)}}),m}function u(m){if(!to(m))return m;if(Array.isArray(m))return m.map(u);if(Vs(m))return new Map(Array.from(m.entries()).map(([h,g])=>[h,u(g)]));if(fu(m))return new Set(Array.from(m).map(u));let f=Object.create(Us(m));for(let h in m)f[h]=u(m[h]);return uu(m,cu)&&(f[cu]=m[cu]),f}function p(m){return la(m)?u(m):m}p7("Patches",{applyPatches_:d,generatePatches_:i,generateReplacementPatches_:c})}var mu=new g7,qs=mu.produce,gr=mu.produceWithPatches.bind(mu);var yr=mu.applyPatches.bind(mu);var We=class extends Error{constructor(n,r,i){super(n);this.code=r;this.cause=i;this.name="TransactionError"}};hr();function Pe(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function lt(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1)if(!lt(e[r],t[r]))return!1;return!0}if(!Pe(e)||!Pe(t))return!1;let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.hasOwn(t,r)||!lt(e[r],t[r]))return!1;return!0}function dn(e,t,n={}){var r;for(let i of Object.keys(e))i in t||delete e[i];for(let[i,o]of Object.entries(t)){let a=e[i],s=[...n.path??[],i];if(!Object.is(a,o)){if((r=n.isAtomicPath)!=null&&r.call(n,s,o)||Array.isArray(a)||Array.isArray(o)){lt(a,o)||(e[i]=o);continue}if(Pe(a)&&Pe(o)){dn(a,o,{...n,path:s});continue}e[i]=o}}}function _7(e){return!!(e&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function")}function tS(e,t){let n=t(e);if(_7(n))throw Promise.resolve(n).catch(()=>{}),new We("transact recipe must be synchronous","ASYNC_RECIPE")}function Jm(e){if(e===void 0)return;if(Array.isArray(e)){let r=!1,i=e.map(o=>{let a=Jm(o);return a===void 0?(r=!0,null):(a!==o&&(r=!0),a)});return r?i:e}if(!Pe(e))return e;let t=!1,n={};for(let[r,i]of Object.entries(e)){let o=Jm(i);if(o===void 0){t=!0;continue}o!==i&&(t=!0),n[r]=o}return t?n:e}function no(e){return Jm(e)}function hu(e){let t=Jm(e);return Pe(t)?t:{}}var Ze="group",wn="builtin/group";function _r(e){return e?e!==Ze&&e!==wn:!1}function nS(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function T7(e){return hu(e)}function Qm(e){return{pippitAssetId:e.id,type:e.type,content:T7(e.data),extra:{}}}function Wn(e){return!!(e&&e.type!==Mn&&e.content&&typeof e.content=="object"&&!Array.isArray(e.content))}function rS(e){if(e&&_r(e.type))return typeof e.id=="string"&&e.id.trim()?e.id:void 0}function S7(e){if(Wn(e))return nS(e.content)?e.content:void 0}function ro(e,t){if(!(!t||!e||!nS(e.assets)))return S7(e.assets[t])}function Zm(e,t){if(!t||!_r(t.type))return t;let n=ro(e,t.id);if(!n)return t;let r=nS(t.data)?t.data:{};return{...t,data:{...r,...n}}}var VE="unknown",qE="unknown_node";function v7(e){if(e!==Ze&&!/^(builtin|biz|plugin)\//.test(e))throw new Error(`Node type must be namespaced with builtin/, biz/ or plugin/: ${e}`)}function nf(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function iS(e){return typeof e=="string"&&e.length>0?e:void 0}function ef(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function x7(e){if(nf(e))return e}function R7(e){if(!nf(e))return;let t=Object.entries(e).filter(n=>!!n[0]&&n[1]===!0);return t.length>0?Object.fromEntries(t):void 0}function tf(e,t){if(!nf(e))return{id:t??qE,type:VE,x:0,y:0,w:1,h:1,parentId:null,data:e,status:"unknown"};let n=iS(e.type)??VE;return{...e,id:iS(e.id)??t??qE,type:n,x:ef(e.x,0),y:ef(e.y,0),w:ef(e.w,1),h:ef(e.h,1),parentId:iS(e.parentId)??null,order:typeof e.order=="number"?e.order:void 0,labelRefs:R7(e.labelRefs),data:"data"in e?e.data:e,style:x7(e.style),status:"unknown"}}function P7(e,t,n,r){let i=tf(e,r);return{id:i.id,x:i.x,y:i.y,w:i.w,h:i.h,parentId:i.parentId,order:i.order,labelRefs:i.labelRefs,style:i.style,type:t.type,data:n}}function rf(){let e=new Map;return{register(t){if(v7(t.type),e.has(t.type))throw new Error(`Node definition already registered: ${t.type}`);return e.set(t.type,t),()=>{e.delete(t.type)}},get(t){return e.get(t)},has(t){return e.has(t)},hydrate(t,n){if(!nf(t))return tf(t,n);let r=typeof t.type=="string"?t.type:"",i=e.get(r);if(!i)return tf(t,n);let{data:o}=t;return i.validate(o)?P7(t,i,o,n):tf(t,n)}}}function oS(){let e=new Map;return{register(t){if(e.has(t.type))throw new Error(`Directive handler already registered: ${t.type}`);return e.set(t.type,t),()=>{e.get(t.type)===t&&e.delete(t.type)}},resolve(t){return e.get(t)},has(t){return e.has(t)}}}var aS="directive.apply";function gu(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function D7(e){if(!(!gu(e)||!gu(e.directives)))return e.directives}function E7(e){let t=M(e.getState()),n=[],r=t.directives;if(gu(r))for(let[i,o]of Object.entries(r))n.push({carrier:{kind:"canvas"},directiveId:i,directive:o});for(let[i,o]of Object.entries(t.nodes)){let a=D7(o==null?void 0:o.data);if(a)for(let[s,c]of Object.entries(a))n.push({carrier:{kind:"node",nodeId:i},directiveId:s,directive:c})}return n}function M7(e,t,n){var o;let r=M(e);if(t.kind==="canvas"){r.directives&&(delete r.directives[n],Object.keys(r.directives).length===0&&delete r.directives);return}let i=(o=r.nodes[t.nodeId])==null?void 0:o.data;gu(i)&&gu(i.directives)&&(delete i.directives[n],Object.keys(i.directives).length===0&&delete i.directives)}function sS(e,t){let{registry:n,onError:r}=t,i=()=>{let o=E7(e);o.length!==0&&e.transact(a=>{for(let{carrier:s,directiveId:c,directive:d}of o){M7(a,s,c);let u=n.resolve(d.type);if(!u){pt.info("[canvas-sdk:directive] no handler, directive removed",{type:d.type,directiveId:c,carrier:s});continue}try{u.run({directiveId:c,carrier:s,directive:d,commands:e.commands,store:e})}catch(p){pt.error("[canvas-sdk:directive] handler threw",p,{type:d.type,directiveId:c,carrier:s}),r==null||r(p,d,s)}}},{intent:aS,source:"local",undoable:!1})};return i(),e.subscribe(({transaction:o})=>{o.intent!==aS&&i()})}var cS=(e,t)=>{t()};var Ks=["horizontal-directed-cluster","vertical-directed-cluster","dag-layered","component-packing","incremental-stress"],N7=["directed-cluster"];function ha(e){return typeof e=="string"&&[...Ks,...N7].includes(e)}function KE(e,t){let n=new Map;return{batch(r,i,o){return e.transact(()=>{i(t())},{...o,intent:r})},register(r,i){return n.set(r,i),()=>{n.delete(r)}},invoke(r,...i){let o=n.get(r);return o?o(e,...i):{status:"aborted",reason:`Unknown command: ${r}`}}}}function Jn(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Ie(e){return!!(e&&Array.isArray(e.children))}function ae(e){return M(e)}function ga(e,t,n){let r=e.nodes[t];Ie(r)&&(r.children=r.children.filter(i=>i!==n))}function jE(e,t){let n=new Set,r=i=>{if(n.has(i))return;n.add(i);let o=e.nodes[i];if(Ie(o))for(let a of o.children)r(a)};for(let i of t)r(i);return n}function _t(e,t){let n=e[t];if(!n)return{x:0,y:0};if(!n.parentId)return{x:n.x,y:n.y};let r=_t(e,n.parentId);return{x:r.x+n.x,y:r.y+n.y}}function ci(e,t){let n=e[t];if(!n)return;let r=_t(e,t);return{minX:r.x,minY:r.y,maxX:r.x+n.w,maxY:r.y+n.h}}function Rt(e){if(e.length!==0)return e.reduce((t,n)=>({minX:Math.min(t.minX,n.minX),minY:Math.min(t.minY,n.minY),maxX:Math.max(t.maxX,n.maxX),maxY:Math.max(t.maxY,n.maxY)}),e[0])}function kn(e,t){let n=new Set(t);return t.filter(r=>{var o,a;let i=(o=e[r])==null?void 0:o.parentId;for(;i;){if(n.has(i))return!1;i=(a=e[i])==null?void 0:a.parentId}return!!e[r]})}function HE(e,t){var r;if(t.length===0)return null;let n=((r=e[t[0]])==null?void 0:r.parentId)??null;return t.every(i=>{var o;return(((o=e[i])==null?void 0:o.parentId)??null)===n})?n:null}function $E(e,t,n="_"){let r=1,i=`${t}${n}${Date.now().toString(36)}`;for(;e[i];)r+=1,i=`${t}${n}${Date.now().toString(36)}${n}${r}`;return i}function YE(e,t,n,r){let i=e.nodes[t];if(!Ie(i))return;let o=new Set(n),a=i.children.findIndex(s=>o.has(s));i.children=i.children.filter(s=>!o.has(s)),i.children.splice(Math.max(a,0),0,r)}function XE(e,t){let n=Object.values(e).filter(r=>r.parentId===t);return n.length===0?0:Math.max(...n.map(r=>r.order??0))+1}function WE(e){return{createEdge(t){return e.transact(n=>{ae(n).edges[t.id]=t},{intent:"edge.create"})},deleteEdges(t){return e.transact(n=>{let{edges:r}=ae(n);for(let i of t)delete r[i]},{intent:"edge.delete"})},reconnectEdge(t,n){return e.transact(r=>{let i=ae(r).edges[t];i&&(i.source=n.source,i.target=n.target,n.sourceHandle?i.sourceHandle=n.sourceHandle:delete i.sourceHandle,n.targetHandle?i.targetHandle=n.targetHandle:delete i.targetHandle)},{intent:"edge.reconnect"})},updateEdgeData(t,n){return e.transact(r=>{let i=ae(r).edges[t];i&&(i.data={...Jn(i.data)?i.data:{},...n})},{intent:"edge.updateData"})}}}function JE(e,t={}){let n=t.centerThreshold??1048576,r=t.targetCenter??{x:0,y:0};if(!Number.isFinite(n)||n<0||!Number.isFinite(r.x)||!Number.isFinite(r.y))return;let i=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY,c=!1;for(let m of e){if(![m.x,m.y,m.w,m.h].every(Number.isFinite))return;let f=m.x+m.w,h=m.y+m.h;if(!Number.isFinite(f)||!Number.isFinite(h))return;i=Math.min(i,m.x,f),o=Math.min(o,m.y,h),a=Math.max(a,m.x,f),s=Math.max(s,m.y,h),c=!0}if(!c)return;let d=i/2+a/2,u=o/2+s/2;if(Math.abs(d-r.x)<=n&&Math.abs(u-r.y)<=n)return;let p={dx:r.x-d,dy:r.y-u};return Number.isFinite(p.dx)&&Number.isFinite(p.dy)?p:void 0}function QE(e){let t=new Set;return e.filter(n=>t.has(n)?!1:(t.add(n),!0))}function dS(e,t){return!e||!t?e?-1:t?1:0:(e.order??0)-(t.order??0)||e.y-t.y||e.x-t.x||e.id.localeCompare(t.id)}function un(e,t){return dS(e.node,t.node)||e.rect.minY-t.rect.minY||e.rect.minX-t.rect.minX}function io(e,t){e.sort((n,r)=>{let i=t.get(n),o=t.get(r);return!i||!o?n.localeCompare(r):un(i,o)})}function ya(e,t){return t.flatMap(n=>{let r=e[n],i=ci(e,n);return r&&i?[{node:r,rect:i}]:[]})}function ZE(e,t,n){switch(n){case"left":return{dx:t.minX-e.minX,dy:0};case"center":return{dx:(t.minX+t.maxX)/2-(e.minX+e.maxX)/2,dy:0};case"right":return{dx:t.maxX-e.maxX,dy:0};case"top":return{dx:0,dy:t.minY-e.minY};case"middle":return{dx:0,dy:(t.minY+t.maxY)/2-(e.minY+e.maxY)/2};case"bottom":return{dx:0,dy:t.maxY-e.maxY}}}function of(e,t){t.dx!==0&&(e.x+=t.dx),t.dy!==0&&(e.y+=t.dy)}var w7=40,k7=40;function O7(e,t){return e.x-t.x||e.y-t.y||e.id.localeCompare(t.id)}function L7(e,t){return e.y-t.y||e.x-t.x||e.id.localeCompare(t.id)}function af(e,t){var o;let n=QE(t);if(n.length===1){let a=e[n[0]];if(!Ie(a))return;let s=a.children.filter(c=>{var d;return((d=e[c])==null?void 0:d.parentId)===a.id});return s.length>=2?{ids:s,parentId:a.id}:void 0}let r=kn(e,n);if(r.length<2)return;let i=((o=e[r[0]])==null?void 0:o.parentId)??null;if(r.every(a=>{var s;return(((s=e[a])==null?void 0:s.parentId)??null)===i}))return{ids:r,parentId:i}}function sf(e,t,n,r){let i=t.map(g=>e[g]).filter(g=>!!g);if(i.length<2)return;let o=Math.min(...i.map(g=>g.x)),a=Math.min(...i.map(g=>g.y)),s=Math.max(...i.map(g=>g.w)),c=Math.max(...i.map(g=>g.h)),d=(r==null?void 0:r.horizontalGap)??w7,u=(r==null?void 0:r.verticalGap)??k7,p=[...i].sort(n==="horizontal"?O7:L7);if(n==="horizontal"){let g=o;for(let y of p)y.x=g,y.y=a,g+=y.w+d;return}if(n==="vertical"){let g=a;for(let y of p)y.x=o,y.y=g,g+=y.h+u;return}let m=Math.max(1,(r==null?void 0:r.gridColumns)??Math.ceil(Math.sqrt(i.length))),f=s+d,h=c+u;p.forEach((g,y)=>{g.x=o+y%m*f,g.y=a+Math.floor(y/m)*h})}function F7(e){return e.maxX-e.minX}function B7(e){return e.maxY-e.minY}function Tr(e){return{x:e.minX+F7(e)/2,y:e.minY+B7(e)/2}}function cf(e,t){return{id:e,minX:t.minX,minY:t.minY,maxX:t.maxX,maxY:t.maxY}}function df(e){return{...e}}function js(e,t,n){e.minX+=t,e.maxX+=t,e.minY+=n,e.maxY+=n}function Hs(e){return(e.minX+e.maxX)/2}function $s(e){return(e.minY+e.maxY)/2}function Ys(e){return e.maxX-e.minX}function Xs(e){return e.maxY-e.minY}function uS(e,t){return Rt([...e.entries()].flatMap(([n,r])=>{let i=t.get(n);return i?[{minX:r.x,minY:r.y,maxX:r.x+i.node.w,maxY:r.y+i.node.h}]:[]}))}function G7(e,t){return t.flatMap(n=>{let r=e.get(n.node.id);return r?[{id:n.node.id,minX:r.x,minY:r.y,maxX:r.x+n.node.w,maxY:r.y+n.node.h}]:[]})}function tM(e,t,n){let r=(Ys(e)+Ys(t))/2+n-Math.abs(Hs(t)-Hs(e)),i=(Xs(e)+Xs(t))/2+n-Math.abs($s(t)-$s(e));return r>0&&i>0}function z7(e,t,n){let r=Math.max(0,(Ys(e)+Ys(t))/2+n-Math.abs(Hs(t)-Hs(e))),i=Math.max(0,(Xs(e)+Xs(t))/2+n-Math.abs($s(t)-$s(e)));return r*i}function pS(e,t,n){return t.reduce((r,i)=>r+z7(e,i,n),0)}function eM(e,t,n){return e!==0?Math.sign(e):t.localeCompare(n)<=0?1:-1}function U7(e,t,n){let r=Hs(t)-Hs(e),i=$s(t)-$s(e),o=(Ys(e)+Ys(t))/2+n-Math.abs(r),a=(Xs(e)+Xs(t))/2+n-Math.abs(i);if(o<=0||a<=0)return!1;if(o<=a){let d=eM(r,e.id,t.id),u=o/2;return js(e,-d*u,0),js(t,d*u,0),!0}let s=eM(i,e.id,t.id),c=a/2;return js(e,0,-s*c),js(t,0,s*c),!0}function lS(e,t,n=Math.max(24,e.length*16)){if(!(e.length<2))for(let r=0;r<n;r+=1){let i=!1;for(let o=0;o<e.length;o+=1)for(let a=o+1;a<e.length;a+=1)i=U7(e[o],e[a],t)||i;if(!i)return}}function mS(e,t,n){let r=new Map;for(let[i,o]of e)r.set(i,{x:o.x+t,y:o.y+n});return r}function yu(e,t,n){let r=G7(e,t.items);lS(r,n);let i=new Map;for(let c of r)i.set(c.id,{x:c.minX,y:c.minY});let o=new Map(t.items.map(c=>[c.node.id,c])),a=uS(i,o);if(!a)return i;let s=Tr(a);return mS(i,t.center.x-s.x,t.center.y-s.y)}function fS(e){return new Map(e.map(t=>[t.node.id,{x:t.rect.minX,y:t.rect.minY}]))}function rM(e,t,n){var i;let r=t;for(;r;){if(n.has(r))return r;r=((i=e[r])==null?void 0:i.parentId)??null}}function K7(e,t,n){let r=new Set(n),i=new Set,o=[];for(let a of Object.values(t)){let s=rM(e,a.source,r),c=rM(e,a.target,r);if(!s||!c||s===c)continue;let d=`${s}->${c}`;i.has(d)||(i.add(d),o.push({source:s,target:c}))}return o}function j7(e,t,n){var u,p;let r=ya(e,t).sort((m,f)=>un(m,f)),i=new Map(r.map(m=>[m.node.id,m])),o=r.map(m=>m.node.id),a=K7(e,n,o),s=new Map;for(let m of o)s.set(m,new Set);for(let m of a)(u=s.get(m.source))==null||u.add(m.target),(p=s.get(m.target))==null||p.add(m.source);let c=[],d=new Set;for(let m of o){if(d.has(m))continue;let f=[],h=[m];for(d.add(m);h.length>0;){let T=h.pop();f.push(T);let C=[...s.get(T)??[]].filter(I=>!d.has(I));io(C,i);for(let I of C.reverse())d.add(I),h.push(I)}f.sort((T,C)=>un(i.get(T),i.get(C)));let g=f.flatMap(T=>{let C=i.get(T);return C?[C]:[]}),y=Rt(g.map(T=>T.rect));if(!y)continue;let _=new Set(f),S=a.filter(T=>_.has(T.source)&&_.has(T.target));c.push({ids:f,items:g,edges:S,bounds:y,center:Tr(y),isolated:S.length===0&&f.length===1})}return c}function H7(e,t,n){let r=n(e,t),i=new Map(e.items.map(a=>[a.node.id,a])),o=uS(r,i)??e.bounds;return{component:e,positions:r,bounds:o}}function hS(e,t){return mS(e.positions,t.minX-e.bounds.minX,t.minY-e.bounds.minY)}function $7(e,t,n){let r=Tr(t),i=e.map((o,a)=>{let s={x:r.x+(o.component.center.x-r.x)*.78,y:r.y+(o.component.center.y-r.y)*.78},c=Tr(o.bounds),d=s.x-c.x,u=s.y-c.y;return cf(String(a),{minX:o.bounds.minX+d,minY:o.bounds.minY+u,maxX:o.bounds.maxX+d,maxY:o.bounds.maxY+u})});return lS(i,n),i}function iM(e,t,n){return t.some(r=>tM(e,r,n))}function Y7(e,t){let n=[{x:0,y:0}],r=Math.max(0,Math.ceil(t/e));for(let i=1;i<=r;i+=1){for(let o=-i;o<=i;o+=1)n.push({x:o*e,y:-i*e}),n.push({x:o*e,y:i*e});for(let o=-i+1;o<=i-1;o+=1)n.push({x:-i*e,y:o*e}),n.push({x:i*e,y:o*e})}return n.filter(i=>Math.hypot(i.x,i.y)<=t).sort((i,o)=>Math.hypot(i.x,i.y)-Math.hypot(o.x,o.y)||i.y-o.y||i.x-o.x)}function gS(e){var t;return((t=e.component.items[0])==null?void 0:t.node.id)??e.component.ids[0]??""}function _u(e){return{w:e.bounds.maxX-e.bounds.minX,h:e.bounds.maxY-e.bounds.minY}}function X7(e,t,n,r){let i=[...e].sort((h,g)=>un(h.component.items[0],g.component.items[0])),o=Math.max(0,t.maxY-t.minY),a=Math.max(0,...i.map(h=>_u(h).h)),s=i.reduce((h,g)=>h+_u(g).h+r,0),c=o>0?Math.max(o,a):s,d=[],u=[],p=0;for(let h of i){let{h:g}=_u(h);u.length>0&&p+g+r>c&&(d.push(u),u=[],p=0),u.push(h),p+=g+r}u.length>0&&d.push(u);let m=new Map,f=t.minX-n;for(let h of d){let g=Math.max(0,...h.map(S=>_u(S).w)),y=f-g,_=t.minY;for(let S of h){let{w:T,h:C}=_u(S);m.set(gS(S),cf(gS(S),{minX:y,minY:_,maxX:y+T,maxY:_+C})),_+=C+r}f=y-n}return m}function W7(e,t,n,r,i){if(!iM(e,t,n))return df(e);let o=df(e),a=pS(o,t,n);for(let s of Y7(i,r)){let c=df(e);if(js(c,s.x,s.y),!iM(c,t,n))return c;let d=pS(c,t,n);d<a&&(a=d,o=c)}return o}function _a({nodes:e,edges:t,ids:n,options:r,resolveComponentPositions:i}){let o=j7(e,n,t),a=Rt(o.map(_=>_.bounds));if(!a)return new Map;let s=(r==null?void 0:r.componentGap)??180,c=(r==null?void 0:r.nodeGap)??40,d=(r==null?void 0:r.isolatedNodeMoveLimit)??360,u=o.map(_=>H7(_,r,i)),p=u.filter(_=>!_.component.isolated),m=u.filter(_=>_.component.isolated),f=new Map,h=[],g=$7(p,a,s);if(p.forEach((_,S)=>{let T=g[S];for(let[C,I]of hS(_,T))f.set(C,I);h.push(T)}),(r==null?void 0:r.isolatedPlacement)==="left"&&m.length>0){let _=Rt(h)??a,S=X7(m,_,s,c);for(let T of m){let C=S.get(gS(T));if(C){for(let[I,x]of hS(T,C))f.set(I,x);h.push(C)}}return f}let y=Math.max(40,c+20);return m.forEach((_,S)=>{let T=cf(`isolated-${S}`,_.bounds),C=W7(T,h,s,d,y);for(let[I,x]of hS(_,C))f.set(I,x);h.push(C)}),f}var oM=.86;function yS(e,t){if(e.items.length<2)return fS(e.items);let n=new Map;for(let i of e.items){let o=Tr(i.rect),a={x:e.center.x+(o.x-e.center.x)*oM,y:e.center.y+(o.y-e.center.y)*oM};n.set(i.node.id,{x:a.x-i.node.w/2,y:a.y-i.node.h/2})}let r=(t==null?void 0:t.nodeGap)??40;return yu(n,e,r)}function aM({nodes:e,edges:t,ids:n,options:r}){return _a({nodes:e,edges:t,ids:n,options:r,resolveComponentPositions:yS})}var J7=240,Q7=40,Z7=240,eQ=2.2;function tQ(e,t,n,r,i){let o=e.filter(s=>(n.get(s.node.id)??0)===0).map(s=>s.node.id);io(o,i);let a=[];for(;o.length>0;){let s=o.shift();a.push(s);let c=t.get(s)??[];io(c,i);for(let d of c){r.set(d,Math.max(r.get(d)??0,(r.get(s)??0)+1));let u=(n.get(d)??0)-1;n.set(d,u),u===0&&(o.push(d),io(o,i))}}return a}function nQ(e,t,n){let r=new Map;for(let i of e){let o=t.get(i);if(!o)continue;let a=n.get(i)??0,s=r.get(a)??[];s.push(o),r.set(a,s)}return r}function rQ(e,t,n){let r=[],i=e;for(let o=0;o<t.length;o+=1)r[o]=i,i+=t[o]+n;return r}function iQ({itemById:e,items:t,outgoing:n,indegree:r,layer:i,options:o}){let a=tQ(t,n,r,i,e);if(a.length!==t.length)return;let s=Rt(t.map(g=>g.rect));if(!s)return;let c=(o==null?void 0:o.horizontalGap)??J7,d=(o==null?void 0:o.verticalGap)??Q7,u=nQ(a,e,i),p=Math.max(...u.keys()),m=Array.from({length:p+1},(g,y)=>Math.max(...(u.get(y)??[]).map(_=>_.node.w),0)),f=rQ(s.minX,m,c),h=new Map;for(let g=0;g<=p;g+=1){let y=u.get(g)??[],_=s.minY;for(let S of y)h.set(S.node.id,{x:f[g],y:_}),_+=S.node.h+d}return h}function oQ(e,t,n){var c;if(t.length===0)return;let r=new Map(e.map(d=>[d.node.id,d])),i=new Map,o=new Map,a=new Map;for(let d of e)i.set(d.node.id,[]),o.set(d.node.id,0),a.set(d.node.id,0);let s=new Set;for(let d of t){let u=`${d.source}->${d.target}`;s.has(u)||(s.add(u),(c=i.get(d.source))==null||c.push(d.target),o.set(d.target,(o.get(d.target)??0)+1))}return iQ({itemById:r,items:e,outgoing:i,indegree:o,layer:a,options:n})}function aQ(e,t){let n=new Set,r=[];for(let i of t){if(i.source===i.target||!e.has(i.source)||!e.has(i.target))continue;let o=`${i.source}->${i.target}`;n.has(o)||(n.add(o),r.push(i))}return r}function sQ(e,t){var s,c;let n=new Map(e.map(d=>[d.node.id,d])),r=e.map(d=>d.node.id),i=new Map;for(let d of r)i.set(d,new Set);for(let d of t)(s=i.get(d.source))==null||s.add(d.target),(c=i.get(d.target))==null||c.add(d.source);let o=[],a=new Set;for(let d of r){if(a.has(d))continue;let u=[],p=[d];for(a.add(d);p.length>0;){let g=p.pop();u.push(g);let y=[...i.get(g)??[]].filter(_=>!a.has(_));io(y,n);for(let _ of y.reverse())a.add(_),p.push(_)}io(u,n);let m=new Set(u),f=u.flatMap(g=>{let y=n.get(g);return y?[y]:[]}),h=t.filter(g=>m.has(g.source)&&m.has(g.target));o.push({edges:h,ids:u,items:f})}return o}function cQ(e,t){let n;for(let[r,i]of e){let o=t.get(r);if(!o)continue;let a={minX:i.x,minY:i.y,maxX:i.x+o.node.w,maxY:i.y+o.node.h};n=n?{minX:Math.min(n.minX,a.minX),minY:Math.min(n.minY,a.minY),maxX:Math.max(n.maxX,a.maxX),maxY:Math.max(n.maxY,a.maxY)}:a}return n}function sM(e,t){let n=[...e].sort((h,g)=>un(h,g)),r=Rt(n.map(h=>h.rect)),i=(r==null?void 0:r.minX)??0,o=(r==null?void 0:r.minY)??0,a=(t==null?void 0:t.horizontalGap)??120,s=(t==null?void 0:t.verticalGap)??80,c=Math.max(1,(t==null?void 0:t.gridColumns)??Math.ceil(Math.sqrt(n.length))),d=Math.max(...n.map(h=>h.node.w),0),u=Math.max(...n.map(h=>h.node.h),0),p=d+a,m=u+s,f=new Map;return n.forEach((h,g)=>{f.set(h.node.id,{x:i+g%c*p,y:o+Math.floor(g/c)*m})}),f}function dQ(e,t){let n=e.edges.length>0?oQ(e.items,e.edges,t):sM(e.items,t);if(!n)return;let r=cQ(n,new Map(e.items.map(i=>[i.node.id,i])));if(r)return{bounds:r,positions:n}}function uQ(e,t,n){let r=(n==null?void 0:n.componentGap)??Z7,i=e.reduce((p,m)=>p+(m.bounds.maxX-m.bounds.minX)*(m.bounds.maxY-m.bounds.minY),0),o=Math.max(...e.map(p=>p.bounds.maxX-p.bounds.minX),0),a=Math.max(o,Math.sqrt(i)*eQ),s=new Map,c=t.minX,d=t.minY,u=0;for(let p of e){let m=p.bounds.maxX-p.bounds.minX,f=p.bounds.maxY-p.bounds.minY;c>t.minX&&c+m>t.minX+a&&(c=t.minX,d+=u+r,u=0);let h=c-p.bounds.minX,g=d-p.bounds.minY;for(let[y,_]of p.positions)s.set(y,{x:_.x+h,y:_.y+g});c+=m+r,u=Math.max(u,f)}return s}function pQ(e,t,n){let r=new Set(e.map(s=>s.node.id)),i=aQ(r,t);if(i.length===0)return;let o=[];for(let s of sQ(e,i)){let c=dQ(s,n);if(!c)return;o.push(c)}if(o.length===0)return;if(o.length===1)return o[0].positions;let a=Rt(e.map(s=>s.rect));return a?uQ(o,a,n):void 0}function cM({nodes:e,edges:t,ids:n,options:r}){let i=ya(e,n);return pQ(i,Object.values(t),r)??sM(i,r)}function Tu(e,t){let n=(e==null?void 0:e.horizontalGap)??(t==="horizontal"?240:48),r=(e==null?void 0:e.verticalGap)??(t==="horizontal"?96:480);return{horizontalGap:n,verticalGap:r,mainGap:t==="horizontal"?n:r,crossGap:t==="horizontal"?r:n}}function dM(e,t){let{horizontalGap:n,verticalGap:r}=Tu(e,t);return{...e,horizontalGap:n,verticalGap:r,nodeGap:(e==null?void 0:e.nodeGap)??80,componentGap:(e==null?void 0:e.componentGap)??240,isolatedPlacement:(e==null?void 0:e.isolatedPlacement)??"left"}}function uM(e,t){var n;return((n=e.get(t))==null?void 0:n.node.h)??0}function pM(e,t){var n;return((n=e.get(t))==null?void 0:n.node.w)??0}function Ta(e,t,n){return n==="horizontal"?uM(e,t):pM(e,t)}function lM(e,t,n){return n==="horizontal"?pM(e,t):uM(e,t)}var _Q=4;function mM(e){if(e.length===0)return-1;let t=[...e].sort((r,i)=>r-i),n=Math.floor(t.length/2);return t.length%2===1?t[n]:(t[n-1]+t[n])/2}function hM(e,t,n){var u;let r=new Map;for(let p of e)r.set(p,[]);let i=new Set;for(let p of t){if(p.source===p.target||!r.has(p.source)||!r.has(p.target))continue;let m=`${p.source}->${p.target}`;i.has(m)||(i.add(m),(u=r.get(p.source))==null||u.push(p.target))}for(let p of r.values())p.sort((m,f)=>un(n.get(m),n.get(f)));let o=new Map,a=new Map;for(let p of e)o.set(p,[]),a.set(p,[]);let s=new Map;for(let p of e)s.set(p,0);let c=[...e].sort((p,m)=>un(n.get(p),n.get(m))),d=p=>{var f,h;let m=[{id:p,index:0}];for(s.set(p,1);m.length>0;){let g=m[m.length-1],y=r.get(g.id)??[];if(g.index<y.length){let _=y[g.index];g.index+=1;let S=s.get(_);if(S===1)continue;(f=o.get(g.id))==null||f.push(_),(h=a.get(_))==null||h.push(g.id),S===0&&(s.set(_,1),m.push({id:_,index:0}))}else s.set(g.id,2),m.pop()}};for(let p of c)s.get(p)===0&&d(p);return{out:o,inn:a}}function TQ(e,t,n){var s;let r=new Map;for(let c of e)r.set(c,((s=t.inn.get(c))==null?void 0:s.length)??0);let i=new Map;for(let c of e)i.set(c,0);let o=e.filter(c=>(r.get(c)??0)===0).sort((c,d)=>un(n.get(c),n.get(d))),a=0;for(;a<o.length;){let c=o[a];a+=1;for(let d of t.out.get(c)??[]){i.set(d,Math.max(i.get(d)??0,(i.get(c)??0)+1));let u=(r.get(d)??0)-1;r.set(d,u),u===0&&o.push(d)}}return i}function SQ(e,t,n){let r=Math.max(0,...e.map(o=>t.get(o)??0)),i=Array.from({length:r+1},()=>[]);for(let o of e)i[t.get(o)??0].push(o);for(let o of i)o.sort((a,s)=>un(n.get(a),n.get(s)));return i}function fM(e,t,n){let r=new Map(e.map((o,a)=>[o,a])),i=new Map;for(let o of e){let a=t(o);i.set(o,a<0?r.get(o)??0:a)}e.sort((o,a)=>(i.get(o)??0)-(i.get(a)??0)||un(n.get(o),n.get(a)))}function bQ(e,t,n){let r=new Map,i=o=>{o.forEach((a,s)=>r.set(a,s))};e.forEach(i);for(let o=0;o<_Q;o+=1)if(o%2===0)for(let s=1;s<e.length;s+=1)fM(e[s],c=>mM((t.inn.get(c)??[]).map(d=>r.get(d)).filter(d=>d!==void 0)),n),i(e[s]);else for(let s=e.length-2;s>=0;s-=1)fM(e[s],c=>mM((t.out.get(c)??[]).map(d=>r.get(d)).filter(d=>d!==void 0)),n),i(e[s])}function gM(e,t,n){let r=TQ(e,t,n),i=SQ(e,r,n);return bQ(i,t,n),i}var CQ=6;function _S(e){return e.length===0?0:e.reduce((t,n)=>t+n,0)/e.length}function AQ(e,t,n,r,i,o,a){if(e.length===0)return;let s=e.map(p=>(t.get(p)??r.get(p)??0)-Ta(i,p,a)/2);for(let p=1;p<e.length;p+=1){let m=s[p-1]+Ta(i,e[p-1],a)+o;s[p]<m&&(s[p]=m)}let c=e.map((p,m)=>s[m]+Ta(i,p,a)/2),d=e.map(p=>t.get(p)??r.get(p)??0),u=_S(d)-_S(c);e.forEach((p,m)=>{let f=s[m]+u;n.set(p,f),r.set(p,f+Ta(i,p,a)/2)})}function IQ(e,t,n,r,i){let o=new Map,a=new Map;for(let s of e){let c=0;for(let d of s)o.set(d,c),a.set(d,c+Ta(n,d,i)/2),c+=Ta(n,d,i)+r}for(let s=0;s<CQ;s+=1){let c=s%2===0,d=c?e.map((u,p)=>p):e.map((u,p)=>p).reverse();for(let u of d){let p=e[u],m=new Map;for(let f of p){let h=c?t.inn.get(f)??[]:t.out.get(f)??[],g=[...t.inn.get(f)??[],...t.out.get(f)??[]],_=(h.length>0?h:g).map(S=>a.get(S)).filter(S=>S!==void 0);m.set(f,_.length>0?_S(_):a.get(f)??0)}AQ(p,m,o,a,n,r,i)}}return o}function vQ(e,t,n){let r=new Map,i=0;for(let o of e)r.set(o.node.id,n==="horizontal"?{x:0,y:i}:{x:i,y:0}),i+=(n==="horizontal"?o.node.h:o.node.w)+t;return r}function yM(e,t,n="horizontal"){let r=new Map(e.items.map(f=>[f.node.id,f])),i=e.items.map(f=>f.node.id),{mainGap:o,crossGap:a}=Tu(t,n);if(e.items.length<2||e.edges.length===0)return vQ(e.items,a,n);let s=hM(i,e.edges,r),c=gM(i,s,r),d=IQ(c,s,r,a,n),u=[],p=0;for(let f=0;f<c.length;f+=1){u[f]=p;let h=Math.max(0,...c[f].map(g=>lM(r,g,n)));p+=h+o}let m=new Map;for(let f=0;f<c.length;f+=1)for(let h of c[f]){let g=d.get(h)??0;m.set(h,n==="horizontal"?{x:u[f],y:g}:{x:g,y:u[f]})}return m}function _M({nodes:e,edges:t,ids:n,options:r,axis:i}){let o=dM(r,i);return _a({nodes:e,edges:t,ids:n,options:o,resolveComponentPositions:(a,s)=>yM(a,s,i)})}function TM({nodes:e,edges:t,ids:n,options:r}){return _M({nodes:e,edges:t,ids:n,options:r,axis:"horizontal"})}function SM({nodes:e,edges:t,ids:n,options:r}){return _M({nodes:e,edges:t,ids:n,options:r,axis:"vertical"})}var bM=.9;function xQ(e,t){return(e==null?void 0:e.stressIterations)!==void 0?Math.max(0,e.stressIterations):Math.max(24,Math.min(80,Math.floor(2400/Math.max(1,t))))}function RQ(e,t){let n=e.items.reduce((a,s)=>a+s.node.w,0)/e.items.length,r=e.items.reduce((a,s)=>a+s.node.h,0)/e.items.length,i=(t==null?void 0:t.horizontalGap)??120,o=(t==null?void 0:t.verticalGap)??80;return Math.max(120,Math.min(520,Math.max(n+i,r+o)))}function PQ(e,t){if(e.items.length<2||e.edges.length===0)return yS(e,t);let n=(t==null?void 0:t.nodeGap)??40,r=RQ(e,t),i=xQ(t,e.items.length),o=new Map,a=new Map,s=new Map,c=0,d=0;for(let p of e.items){let m=Tr(p.rect),f={x:e.center.x+(m.x-e.center.x)*bM,y:e.center.y+(m.y-e.center.y)*bM};o.set(p.node.id,{...m}),a.set(p.node.id,f),s.set(p.node.id,{w:p.node.w,h:p.node.h}),c+=f.x,d+=f.y}c/=e.items.length,d/=e.items.length;for(let p=0;p<i;p+=1){for(let y of e.edges){let _=o.get(y.source),S=o.get(y.target);if(!_||!S)continue;let T=S.x-_.x,C=S.y-_.y,I=Math.max(1,Math.hypot(T,C)),x=Math.max(-r*.18,Math.min(r*.18,(I-r)*.08)),R=T/I*x*.5,G=C/I*x*.5;_.x+=R,_.y+=G,S.x-=R,S.y-=G}for(let y=0;y<e.items.length;y+=1)for(let _=y+1;_<e.items.length;_+=1){let S=e.items[y],T=e.items[_],C=o.get(S.node.id),I=o.get(T.node.id),x=s.get(S.node.id),R=s.get(T.node.id);if(!C||!I||!x||!R)continue;let G=I.x-C.x,O=I.y-C.y,K=(x.w+R.w)/2+n-Math.abs(G),H=(x.h+R.h)/2+n-Math.abs(O);if(K>0&&H>0){if(K<=H){let W=G===0?S.node.id.localeCompare(T.node.id)<=0?1:-1:Math.sign(G),re=K/2;C.x-=W*re,I.x+=W*re}else{let W=O===0?S.node.id.localeCompare(T.node.id)<=0?1:-1:Math.sign(O),re=H/2;C.y-=W*re,I.y+=W*re}continue}let U=Math.max(1,Math.hypot(G,O));if(U<r*.55){let W=G===0?S.node.id.localeCompare(T.node.id)<=0?1:-1:G/U,re=O===0?0:O/U,Q=(r*.55-U)*.015;C.x-=W*Q,C.y-=re*Q,I.x+=W*Q,I.y+=re*Q}}let m=0,f=0;for(let y of e.items){let _=o.get(y.node.id),S=a.get(y.node.id);!_||!S||(_.x+=(S.x-_.x)*.035,_.y+=(S.y-_.y)*.035,m+=_.x,f+=_.y)}m/=e.items.length,f/=e.items.length;let h=(c-m)*.15,g=(d-f)*.15;for(let y of o.values())y.x+=h,y.y+=g}let u=new Map;for(let p of e.items){let m=o.get(p.node.id);m&&u.set(p.node.id,{x:m.x-p.node.w/2,y:m.y-p.node.h/2})}return yu(u,e,n)}function CM({nodes:e,edges:t,ids:n,options:r}){return _a({nodes:e,edges:t,ids:n,options:r,resolveComponentPositions:PQ})}var DQ="horizontal-directed-cluster";function AM(e,t){let n=t!=null&&t.length?kn(e,t):Object.values(e).filter(i=>i.parentId===null).map(i=>i.id),r=new Set;return n.filter(i=>{let o=e[i];return!o||o.parentId!==null||r.has(i)?!1:(r.add(i),!0)}).sort((i,o)=>dS(e[i],e[o]))}function Js(e,t,n,r){let i=(r==null?void 0:r.strategy)??DQ;return i==="component-packing"?aM({nodes:e,edges:t,ids:n,options:r}):i==="incremental-stress"?CM({nodes:e,edges:t,ids:n,options:r}):i==="dag-layered"?cM({nodes:e,edges:t,ids:n,options:r}):i==="vertical-directed-cluster"?SM({nodes:e,edges:t,ids:n,options:r}):TM({nodes:e,edges:t,ids:n,options:r})}function mf(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Qs(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function TS(e){if(!(!mf(e)||!Qs(e.w)||!Qs(e.h)))return{w:e.w,h:e.h}}function lf(e){return{w:Qs(e.w)?e.w:320,h:Qs(e.h)?e.h:180}}function ff(e){return!!(e&&(e.type===Ze||e.type===wn)&&Array.isArray(e.children))}function Sa(e){return ff(e)&&mf(e.data)&&e.data.collapsed===!0}function SS(e){return ff(e)&&mf(e.data)?TS(e.data.expandedSize):void 0}function Su(e){return Sa(e)?SS(e)??lf(e):lf(e)}function bu(e,t){if(Sa(e)){e.data.expandedSize={...t};return}e.w=t.w,e.h=t.h}function hf(e){if(!ff(e))return!1;mf(e.data)||(e.data={});let{data:t}=e,n=TS(t.expandedSize);if(t.collapsed===!0){let r=!1;return n?(!Qs(e.w)||!Qs(e.h))&&(e.w=320,e.h=180,r=!0):(t.expandedSize=lf(e),e.w=320,e.h=180,r=!0),r}return n?(e.w=n.w,e.h=n.h,delete t.expandedSize,!0):!1}function IM(e,t){if(!ff(e))return!1;let n=hf(e),{data:r}=e;if(r.collapsed===!0===t)return n;if(t)return r.expandedSize=lf(e),r.collapsed=!0,e.w=320,e.h=180,!0;let i=TS(r.expandedSize);return r.collapsed=!1,i&&(e.w=i.w,e.h=i.h),delete r.expandedSize,!0}function vM(e,t){return e.minX>=t.minX-.001&&e.minY>=t.minY-.001&&e.maxX<=t.maxX+.001&&e.maxY<=t.maxY+.001}function xM(e,t){e.x+=t.minX,e.y+=t.minY,bu(e,{w:Math.max(1,t.maxX-t.minX),h:Math.max(1,t.maxY-t.minY)})}function EQ(e,t){return Rt(t.map(n=>{let r=typeof n=="string"?e[n]:void 0;return r?{minX:r.x,minY:r.y,maxX:r.x+r.w,maxY:r.y+r.h}:void 0}).filter(n=>!!n))}function MQ(e,t){return Rt(t.children.map(n=>e[n]).filter(n=>!!(n&&n.parentId===t.id)).map(n=>({minX:n.x,minY:n.y,maxX:n.x+n.w,maxY:n.y+n.h})))}function NQ(e,t,n,r){for(let i of t){let o=typeof i=="string"?e[i]:void 0;o&&(o.x-=n,o.y-=r)}}function wQ(e,t,n,r){for(let i of t.children){let o=e[i];(o==null?void 0:o.parentId)===t.id&&(o.x-=n,o.y-=r)}}function RM(e,t,n,r){let i=e[t];if(i){if(i.x*=n,i.y*=r,Sa(i)){let o=Su(i);bu(i,{w:o.w*n,h:o.h*r})}else i.w*=n,i.h*=r;if(Ie(i))for(let o of i.children)RM(e,o,n,r)}}function PM(e,t,n){if(n.has(t))return;n.add(t);let r=e[t];if(Ie(r))for(let i of r.children)PM(e,i,n)}function kQ(e,t,n){let r=ci(e,t);if(!r)return null;let i=null,o=Number.POSITIVE_INFINITY;for(let a of Object.values(e)){if(!Ie(a)||n.has(a.id))continue;let s=ci(e,a.id);if(!s||!vM(r,s))continue;let c=a.w*a.h;c<o&&(i=a.id,o=c)}return i}function OQ(e,t){let{nodes:n}=e;for(let r of t){let i=n[r],o=i==null?void 0:i.parentId;if(!i||!o)continue;let a=ci(n,r),s=ci(n,o);if(a&&s&&vM(a,s))continue;let c=_t(n,r);ga(e,o,r),i.parentId=null,i.x=c.x,i.y=c.y}}function LQ(e,t,n){let{nodes:r}=e;for(let i of t){let o=r[i];if(!o||o.parentId)continue;let a=kQ(r,i,n),s=a?r[a]:void 0;if(!a||!Ie(s))continue;let c=_t(r,i),d=_t(r,a);o.parentId=a,o.x=c.x-d.x,o.y=c.y-d.y,s.children=[...s.children.filter(u=>u!==i),i]}}function FQ(e,t){var i,o;let n=[],r=new Set;for(let a of t){let s=((i=e[a])==null?void 0:i.parentId)??null;for(;s;)r.has(s)||(r.add(s),n.push(s)),s=((o=e[s])==null?void 0:o.parentId)??null}return n}function BQ(e,t){let n=e[t];if(!Array.isArray(n==null?void 0:n.children)||n.children.length===0)return;let r=EQ(e,n.children);if(!r)return;let i=Su(n),o={minX:Math.min(0,r.minX-40),minY:Math.min(0,r.minY-40),maxX:Math.max(i.w,r.maxX+40),maxY:Math.max(i.h,r.maxY+40)};xM(n,o),NQ(e,n.children,o.minX,o.minY)}function DM(e,t,n){if(!Ie(t)||Sa(t)||t.w===n.w&&t.h===n.h)return;let r=t.w===0?1:n.w/t.w,i=t.h===0?1:n.h/t.h;for(let o of t.children)RM(e,o,r,i)}function EM(e,t){let{nodes:n}=e,r=kn(n,t),i=new Set;for(let o of r)PM(n,o,i);OQ(e,r),LQ(e,r,i)}function gf(e,t){let n=FQ(e,t);for(let r of n)BQ(e,r)}function Zs(e,t,n=new Set){if(!t||n.has(t))return;let r=e[t];if(!Ie(r))return;n.add(t);let i=MQ(e,r);if(!i)return;let o={minX:i.minX-40,minY:i.minY-40,maxX:i.maxX+40,maxY:i.maxY+40};xM(r,o),wQ(e,r,o.minX,o.minY),Zs(e,r.parentId??null,n)}function GQ(e,t){let n=[],r=new Set,i=o=>{let a=e[o];if(!(!Ie(a)||r.has(o))){r.add(o);for(let s of a.children)i(s);n.push(o)}};for(let o of t)i(o);return n}function zQ(e,t){let n=e[t];return Ie(n)?n.children.filter(r=>{var i;return((i=e[r])==null?void 0:i.parentId)===t}):[]}function NM(e){return e==="horizontal-directed-cluster"||e==="vertical-directed-cluster"}function MM(e,t,n){var i;let r=t;for(;r;){if(n.has(r))return r;r=((i=e[r])==null?void 0:i.parentId)??null}}function UQ(e,t,n){let r=new Set(n);return Object.values(t).some(i=>{let o=MM(e,i.source,r),a=MM(e,i.target,r);return!!(o&&a&&o!==a)})}function VQ(e,t){let n=new Set(t);return Object.fromEntries(Object.entries(e).map(([r,i])=>[r,n.has(r)?{...i,parentId:null}:{...i}]))}function qQ(e,t){let n;for(let[r,i]of t)e[r]&&(n=n?{minX:Math.min(n.minX,i.x),minY:Math.min(n.minY,i.y)}:{minX:i.x,minY:i.y});return n}function KQ(e,t,n){let r=Object.fromEntries(Object.entries(e).map(([s,c])=>[s,{...c}])),i=n==="horizontal-directed-cluster"?"horizontal":"vertical",{horizontalGap:o,verticalGap:a}=Tu(void 0,i);return sf(r,t,i==="horizontal"?"vertical":"horizontal",{horizontalGap:o,verticalGap:a}),new Map(t.flatMap(s=>{let c=r[s];return c?[[s,{x:c.x,y:c.y}]]:[]}))}function jQ(e,t,n){let{nodes:r}=e,i=VQ(r,t),o=UQ(r,e.edges,t)?Js(i,e.edges,t,{strategy:n}):KQ(i,t,n),a=qQ(i,o);return a?new Map([...o.entries()].map(([s,c])=>[s,{x:c.x-a.minX+40,y:c.y-a.minY+40}])):o}function wM(e,t,n){let{nodes:r}=e,i=af(r,t);if(!i)return;let o=i.parentId?jQ(e,i.ids,n):Js(r,e.edges,i.ids,{strategy:n});if(o.size!==0){for(let[a,s]of o){let c=r[a];c&&(c.x=s.x,c.y=s.y)}Zs(r,i.parentId)}}function kM(e,t,n,r){let i=r.strategy??"horizontal-directed-cluster";if(!["directed-cluster","horizontal-directed-cluster","vertical-directed-cluster"].includes(i)||!r.sortGroupChildren)return!1;let a=!1;for(let s of GQ(e,n)){let c=zQ(e,s);if(c.length<2)continue;let d=Js(e,t,c,r);if(d.size===0)continue;let u=_t(e,s);for(let[p,m]of d){let f=e[p];!f||f.parentId!==s||(f.x=m.x-u.x,f.y=m.y-u.y,a=!0)}Zs(e,s)}return a}function HQ(e,t,n){let r=kn(e,t);if(r.length<3)return;let i=ya(e,r).sort((p,m)=>n==="horizontal"?p.rect.minX-m.rect.minX:p.rect.minY-m.rect.minY);if(i.length<3)return;let o=i[0],a=i[i.length-1],s=i.reduce((p,m)=>{let f=n==="horizontal"?m.rect.maxX-m.rect.minX:m.rect.maxY-m.rect.minY;return p+f},0),d=((n==="horizontal"?a.rect.maxX-o.rect.minX:a.rect.maxY-o.rect.minY)-s)/(i.length-1),u=n==="horizontal"?o.rect.maxX+d:o.rect.maxY+d;for(let p=1;p<i.length-1;p+=1){let m=i[p];n==="horizontal"?(of(m.node,{dx:u-m.rect.minX,dy:0}),u+=m.rect.maxX-m.rect.minX+d):(of(m.node,{dx:0,dy:u-m.rect.minY}),u+=m.rect.maxY-m.rect.minY+d)}}function OM(e,t){let n=t.flatMap(i=>{let o=e[i];return o?[o]:[]}),r=JE(n);if(r)for(let i of t){let o=e[i];o&&(o.x+=r.dx,o.y+=r.dy)}}function LM(e){return{moveNodes(t,n,r){return e.transact(i=>{if(!Number.isFinite(n==null?void 0:n.dx)||!Number.isFinite(n==null?void 0:n.dy))throw new We("moveNodes requires finite delta.dx and delta.dy","GUARD_REJECTED");let o=ae(i),{nodes:a}=o,s=kn(a,t);for(let c of s){let d=a[c];d&&(d.x+=n.dx,d.y+=n.dy)}r!=null&&r.reparentToContainingGroup?EM(o,s):gf(a,s)},{intent:"geometry.moveNodes",mergeKey:r==null?void 0:r.mergeKey})},resizeNode(t,n,r){return e.transact(i=>{let{nodes:o}=ae(i),a=o[t];a&&(DM(o,a,n),a.w=n.w,a.h=n.h),gf(o,[t])},{intent:"geometry.resizeNode",mergeKey:r==null?void 0:r.mergeKey})},setNodePosition(t,n,r){return e.transact(i=>{let{nodes:o}=ae(i),a=o[t];a&&(a.x=n.x,a.y=n.y),gf(o,[t])},{intent:"geometry.setNodePosition",mergeKey:r==null?void 0:r.mergeKey})},alignNodes(t,n){return e.transact(r=>{let{nodes:i}=ae(r),o=kn(i,t);if(o.length<2)return;let a=ya(i,o),s=Rt(a.map(c=>c.rect));if(s)for(let c of a)of(c.node,ZE(c.rect,s,n))},{intent:`geometry.alignNodes.${n}`})},distributeNodes(t,n){return e.transact(r=>{HQ(ae(r).nodes,t,n)},{intent:`geometry.distributeNodes.${n}`})},arrangeNodes(t,n,r){return e.transact(i=>{let o=ae(i);if(NM(n)){wM(o,t,n);return}let{nodes:a}=o,s=af(a,t);s&&(sf(a,s.ids,n,r),Zs(a,s.parentId))},{intent:`geometry.arrangeNodes.${n}`})},autoLayoutNodes(t){return e.transact(n=>{var d,u,p;let r=ae(n),i=AM(r.nodes,t==null?void 0:t.ids),o=(d=r.settings.autoLayout)==null?void 0:d.strategy,a=(t==null?void 0:t.strategy)??(ha(o)?o:void 0),s=a?{...t,strategy:a}:t;if(s&&kM(r.nodes,r.edges,i,s),i.length<2){(u=t==null?void 0:t.ids)!=null&&u.length||OM(r.nodes,i);return}let c=Js(r.nodes,r.edges,i,s);for(let[m,f]of c){let h=r.nodes[m];h&&(h.x=f.x,h.y=f.y)}(p=t==null?void 0:t.ids)!=null&&p.length||OM(r.nodes,i)},{intent:"geometry.autoLayoutNodes"})}}}function FM(e,t){let n=[],r=new Set,i=o=>{let a=e[o];if(!(!a||r.has(o))){if(Ie(a)){r.add(o);for(let s of a.children)i(s);return}r.add(o),n.push(o)}};for(let o of t)i(o);return n}function BM(e,t,n){var o;let r=new Set,i=a=>{let s=e[a];if(!(!Ie(s)||r.has(a))){r.add(a);for(let c of s.children)i(c)}};for(let a of t)i(a);for(let a of n){let s=((o=e[a])==null?void 0:o.parentId)??null;for(;s;){let c=e[s];Ie(c)&&r.add(s),s=(c==null?void 0:c.parentId)??null}}return[...r]}function GM(e,t,n){let{nodes:r}=e,i=r[n];if(!Ie(i))return;let o=[...i.children],a=_t(r,n),{parentId:s}=i,c=s?_t(r,s):{x:0,y:0};for(let d of o){let u=r[d];u&&(u.parentId=s,u.x=a.x+u.x-c.x,u.y=a.y+u.y-c.y)}if(s){let d=r[s];if(Ie(d)){let u=d.children.indexOf(n);d.children=d.children.filter(p=>p!==n),d.children.splice(Math.max(u,0),0,...o)}}delete r[n],delete t[n];for(let d of Object.values(e.edges))(d.source===n||d.target===n)&&delete e.edges[d.id]}function $Q(e,t){let n=e;if(!Wn(n)||!Jn(n.content))return;let r=Jn(n.content.data)?n.content.data:n.content;r.collapsed=Jn(t.data)&&t.data.collapsed===!0;let i=SS(t);i?r.expandedSize={...i}:delete r.expandedSize}function zM(e){return{group(t){return e.transact(n=>{let r=ae(n),{nodes:i}=r,o=kn(i,t);if(o.length===0)return;let a=FM(i,o);if(a.length<2)return;let s=Rt(a.map(h=>ci(i,h)).filter(h=>!!h));if(!s)return;let c=BM(i,o,a),d=$E(i,"group","$");for(let h of c)GM(r,n.assets,h);let u=HE(i,a),p=u?_t(i,u):{x:0,y:0},m={x:s.minX-40,y:s.minY-40},f={id:d,type:Ze,x:m.x-p.x,y:m.y-p.y,w:Math.max(1,s.maxX-s.minX+40*2),h:Math.max(1,s.maxY-s.minY+40*2),parentId:u,order:XE(i,u),data:{},children:[...a]};u&&YE(r,u,a,d);for(let h of a){let g=i[h],y=_t(i,h);g&&(g.parentId&&g.parentId!==u&&ga(r,g.parentId,h),g.parentId=d,g.x=y.x-m.x,g.y=y.y-m.y)}i[d]=f},{intent:"group.create"})},ungroup(t){return e.transact(n=>{let r=ae(n),{nodes:i}=r,o=i[t];if(!Ie(o))return;let a=_t(i,t),s=o.parentId?_t(i,o.parentId):{x:0,y:0},{parentId:c}=o;for(let d of o.children){let u=i[d];u&&(u.parentId=c,u.x=a.x+u.x-s.x,u.y=a.y+u.y-s.y)}if(c){let d=i[c];if(Ie(d)){let u=d.children.indexOf(t);d.children=d.children.filter(p=>p!==t),d.children.splice(Math.max(u,0),0,...o.children)}}delete i[t],delete n.assets[t];for(let d of Object.values(r.edges))(d.source===t||d.target===t)&&delete r.edges[d.id]},{intent:"group.ungroup"})},reparent(t,n,r){return e.transact(i=>{let o=ae(i),{nodes:a}=o,s=a[t];if(!s||t===n)return;let c=n?a[n]:void 0;if(n&&!Ie(c))return;let d=_t(a,t);s.parentId&&ga(o,s.parentId,t),s.parentId=n;let u=n?_t(a,n):{x:0,y:0};if(s.x=d.x-u.x,s.y=d.y-u.y,c&&Ie(c)){let p=c.children.filter(f=>f!==t),m=r===void 0?p.length:Math.max(0,Math.min(r,p.length));p.splice(m,0,t),c.children=p}},{intent:"group.reparent"})},reorderChildren(t,n){return e.transact(r=>{let{nodes:i}=ae(r),o=i[t];if(Ie(o)){let a=new Set(o.children);if(!Array.isArray(n)||n.length!==o.children.length||n.some(s=>{var c;return!a.delete(s)||((c=i[s])==null?void 0:c.parentId)!==t})||a.size!==0)throw new We("reorderChildren requires a complete permutation of the existing group children","GUARD_REJECTED");o.children=[...n]}},{intent:"group.reorderChildren"})},setGroupCollapsed(t,n){return e.transact(r=>{let i=ae(r).nodes[t];Ie(i)&&(IM(i,n),$Q(r.assets[t],i))},{intent:"group.setCollapsed"})}}}function YQ(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function XQ(e){let t=YQ(e.pippitAssetId);if(t)return{pippitAssetId:t}}function UM(e){return{setTitle(t){return e.transact(n=>{ae(n).metadata.title=t},{intent:"metadata.setTitle"})},setCover(t){return e.transact(n=>{var o;let r=XQ(t);if(!r)return;let{metadata:i}=ae(n);((o=i.cover)==null?void 0:o.pippitAssetId)!==r.pippitAssetId&&(i.cover=r)},{intent:"metadata.setCover",undoable:!1})},setGlobalBounds(t){return e.transact(n=>{ae(n).metadata.globalBounds=t},{intent:"metadata.setGlobalBounds"})}}}function WQ(e){return typeof structuredClone=="function"?no(structuredClone(e)):no(JSON.parse(JSON.stringify(e)))}function VM(e){return{createNode(t,n={}){return e.transact(r=>{let i=ae(r),o=e.registry.hydrate(t),a=n.autoCreateNodeAsset??!0,s=_r(o.type);for(let c of n.assets??[]){if(r.assets[c.pippitAssetId])throw new Error(`Asset already exists: ${c.pippitAssetId}`);s&&c.pippitAssetId===o.id&&c.type!==Mn&&!Wn(c)&&pt.error("[canvas-sdk] biz node companion asset must be NodeAsset shape (flat content: object)",{nodeId:o.id,nodeType:o.type,assetType:c.type}),r.assets[c.pippitAssetId]=WQ(c)}if(a&&s){if(r.assets[o.id])throw new Error(`Node asset already exists: ${o.id}`);r.assets[o.id]=Qm(o)}if(i.nodes[o.id]=o,o.parentId){let c=i.nodes[o.parentId];Ie(c)&&!c.children.includes(o.id)&&c.children.push(o.id)}},{intent:"node.create"})},deleteNodes(t){return e.transact(n=>{let r=ae(n),i=jE(r,t);for(let o of i){let a=r.nodes[o];a!=null&&a.parentId&&ga(r,a.parentId,o)}for(let o of i)delete r.nodes[o];for(let o of Object.values(r.edges))(i.has(o.source)||i.has(o.target))&&delete r.edges[o.id]},{intent:"node.delete"})},updateNodeData(t,n){return e.transact(r=>{let i=ae(r).nodes[t];if(!i)return;if(!_r(i.type)){if(Jn(i.data)||(i.data={}),typeof n=="function"){tS(i.data,n);return}let s=Jn(n)?hu(n):{};if(Object.keys(s).length===0)return;Object.assign(i.data,s);return}let o=r.assets[t];if(!Wn(o))throw new We(`biz node "${t}" missing NodeAsset; cannot apply updateNodeData`,"INVARIANT_VIOLATION");if(Jn(o.content)||(o.content={}),typeof n=="function"){tS(o.content,n);return}let a=Jn(n)?hu(n):{};Object.keys(a).length!==0&&Object.assign(o.content,a)},{intent:"node.updateData"})},setNodeStyle(t,n){return e.transact(r=>{let i=ae(r).nodes[t];i&&(i.style={...i.style??{},...n})},{intent:"node.setStyle"})}}}function oo(e){throw new We(e,"GUARD_REJECTED")}function jM(e){let t=e.trim();return t||oo("canvas-label-name-required"),Array.from(t).length>zT&&oo("canvas-label-name-too-long"),t}function HM(e){return Km(e)||oo("canvas-label-order-invalid"),{value:GT(e.value),sessionId:e.sessionId}}function $M(e){return UT(e)||oo("canvas-label-color-invalid"),Hm(e)}function JQ(e){return e.nodeLabels??={byId:{}},e.nodeLabels}function Cu(e,t){let n=e==null?void 0:e.byId[t];return n||oo("canvas-label-not-found"),n}function qM(e,t,n){Object.values((e==null?void 0:e.byId)??{}).some(i=>i.id!==n&&i.name.trim()===t)&&oo("canvas-label-name-duplicate")}function QQ(e){return e.id.trim()||oo("canvas-label-id-required"),{id:e.id,name:jM(e.name),color:$M(e.color),order:HM(e.order)}}function KM(e,t){Cu(e.nodeLabels,t.labelId);for(let n of new Set(t.nodeIds)){if(!Object.prototype.hasOwnProperty.call(e.nodes,n))continue;let r=e.nodes[n];if(t.assigned){r.labelRefs??={},r.labelRefs[t.labelId]=!0;continue}r.labelRefs&&delete r.labelRefs[t.labelId]}}function YM(e){return{createCanvasNodeLabel(t){return e.transact(n=>{var a;let r=ae(n),i=QQ(t),o=JQ(r);Object.prototype.hasOwnProperty.call(o.byId,i.id)&&oo("canvas-label-id-duplicate"),qM(o,i.name),o.byId[i.id]=i,(a=t.nodeIds)!=null&&a.length&&KM(r,{assigned:!0,labelId:i.id,nodeIds:t.nodeIds})},{intent:"nodeLabel.create"})},renameCanvasNodeLabel(t,n){return e.transact(r=>{let i=ae(r).nodeLabels,o=Cu(i,t),a=jM(n);qM(i,a,t),o.name=a},{intent:"nodeLabel.rename"})},setCanvasNodeLabelColor(t,n){return e.transact(r=>{let i=Cu(ae(r).nodeLabels,t);i.color=$M(n)},{intent:"nodeLabel.setColor"})},setCanvasNodeLabelOrder(t,n){return e.transact(r=>{let i=Cu(ae(r).nodeLabels,t);i.order=HM(n)},{intent:"nodeLabel.setOrder"})},setCanvasNodeLabelMembership(t){return e.transact(n=>KM(ae(n),t),{intent:t.assigned?"nodeLabel.assign":"nodeLabel.unassign"})},deleteCanvasNodeLabel(t){return e.transact(n=>{let r=ae(n),i=r.nodeLabels;Cu(i,t),delete i.byId[t];for(let o of Object.values(r.nodes))o.labelRefs&&delete o.labelRefs[t]},{intent:"nodeLabel.delete"})}}}function XM(e){return{updateSnapSettings(t){return e.transact(n=>{let{settings:r}=ae(n);r.snap={...r.snap,...t}},{intent:"settings.updateSnap"})},setSnapEnabled(t){return e.transact(n=>{ae(n).settings.snap.enabled=t},{intent:"settings.setSnapEnabled"})},setAutoLayoutStrategy(t){return e.transact(n=>{let{settings:r}=ae(n);if(!t){delete r.autoLayout;return}r.autoLayout={...r.autoLayout,strategy:t}},{intent:"settings.setAutoLayoutStrategy"})}}}function bS(e){let t={...VM(e),...YM(e),...LM(e),...zM(e),...WE(e),...UM(e),...XM(e),...KE(e,()=>t)};return t}var ZQ=[[1,0],[0,1],[-1,0],[0,-1],[1,1],[-1,1],[1,-1],[-1,-1]];function eZ(e,t){return e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y}function tZ(e,t){return{x:e.x-t,y:e.y-t,w:e.w+t*2,h:e.h+t*2}}function nZ(e){return{x:e.x,y:e.y,w:e.w,h:e.h}}function rZ({base:e,gap:t,searchRings:n,size:r}){let i=[e],o=r.w+t,a=r.h+t;for(let s=1;s<=n;s+=1)for(let[c,d]of ZQ)i.push({x:e.x+c*o*s,y:e.y+d*a*s});return i}function iZ(e,t,n){return t.some(r=>eZ(e,tZ(r,n)))}function WM({center:e,existingNodes:t={},gap:n=24,searchRings:r=8,size:i}){let o={x:e.x-i.w/2,y:e.y-i.h/2},a=Object.values(t).filter(c=>!c.parentId).map(nZ);if(a.length===0)return o;let s=rZ({base:o,gap:n,searchRings:r,size:i});return s.find(c=>!iZ({...c,...i},a,n))??s[0]}var JM;function oZ(){let e=globalThis.console;if(!e||typeof e!="object")return;let t=e.warn;return typeof t=="function"?t.bind(e):void 0}function Au(e){var t;if(JM)try{JM({...e,context:aZ(e.context),metrics:sZ(e.metrics)})}catch(n){(t=oZ())==null||t("[canvas-sdk] telemetry reporter failed",n)}}function aZ(e){if(!e)return;let t={},n=40;for(let[r,i]of Object.entries(e)){if(n<=0)break;t[r]=cZ(i),n-=1}return t}function sZ(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))Number.isFinite(r)&&(t[n]=r);return Object.keys(t).length?t:void 0}function cZ(e){var t;return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e.length>500?`${e.slice(0,500)}...`:e:e===null||typeof e=="number"||typeof e=="boolean"||typeof e>"u"?e:Array.isArray(e)?`[array:${e.length}]`:typeof e=="object"?`[object:${((t=e.constructor)==null?void 0:t.name)||"Object"}]`:String(e)}var dZ=e=>String(e).replace(/~/g,"~0").replace(/\//g,"~1"),uZ=e=>e.replace(/~1/g,"/").replace(/~0/g,"~"),pZ=e=>/^\d+$/.test(e)?Number(e):e,lZ=e=>e.length===0?"":`/${e.map(dZ).join("/")}`,CS=e=>{if(e==="")return[];if(!e.startsWith("/"))throw new Error(`Invalid JSON pointer: ${e}`);return e.slice(1).split("/").map(uZ).map(pZ)},mZ=e=>{if(e.path[0]==="revision"||e.path[0]!=="assets"||e.path[1]===void 0)return null;let t=String(e.path[1]),n=e.path.slice(2),r={assetId:t,op:e.op,path:lZ(n)};return e.op!=="remove"&&(r.value=e.value),r},ao=e=>{let t=[];for(let n of e){let r=mZ(n);r&&t.push(r)}return t},fZ=e=>{let t={op:e.op,path:["assets",e.assetId,...CS(e.path)]};return e.op!=="remove"&&(t.value=e.value),t},yf=e=>e.map(fZ);function ec(e,t,n){e.assets[t]=n}var hZ=5;function AS(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function gZ(e){let t=e;if(!(!Wn(t)||!AS(t.content)))return AS(t.content.data)?t.content.data:t.content}function Iu(e,t){let n=qs(e,r=>{for(let i of Object.values(r.assets))if(Nn(i)){for(let o of Object.keys(i.content.nodes)){let a=t.hydrate(i.content.nodes[o],o),s=r.assets[o];if(!_r(a.type)){let d=gZ(s),u=AS(a.data)?a.data:{};i.content.nodes[o]=t.hydrate({...a,data:d?{...d,...u}:a.data},o);continue}if(Wn(s)){i.content.nodes[o]=t.hydrate({...a,type:s.type},o);continue}if(!s){i.content.nodes[o]=a;continue}pt.error("[canvas-sdk:hydrate] biz node companion asset has invalid shape",{nodeId:o,nodeType:a.type,assetType:s.type}),i.content.nodes[o]=a}for(let o of Object.values(i.content.nodes))hf(o)}});return no(n)}function QM(e){return Object.keys(e).sort()}function ZM(e,t){dn(e,t,{isAtomicPath:n=>n.length===hZ&&n[0]==="content"&&n[1]==="nodeLabels"&&n[2]==="byId"&&n[4]==="order"})}function yZ(e,t){let n=QM(e),r=QM(t);return n.length===r.length&&n.every((i,o)=>i===r[o]&&(e[i]===t[i]||lt(e[i],t[i])))}function eN(e,t){let[n,r,i]=gr(e,o=>{o.rootCanvasId=t.rootCanvasId;for(let a of Object.keys(o.assets))a in t.assets||delete o.assets[a];for(let[a,s]of Object.entries(t.assets)){if(!(a in e.assets)){ec(o,a,s);continue}let c=e.assets[a];c===s||lt(c,s)||ZM(o.assets[a],s)}});return{forwardPatches:ao(r),reversePatches:ao(i),nextState:n}}function tN(e,t){return e.rootCanvasId===t.rootCanvasId&&yZ(e.assets,t.assets)}function IS(e,t,n={}){let r=e.getState();return r.rootCanvasId!==t.rootCanvasId?{status:"aborted",reason:"root-canvas-id-mismatch"}:t.assets[t.rootCanvasId]?tN(r,t)?{status:"noop",reason:"no-changes"}:e.transact(i=>{for(let o of Object.keys(i.assets))o in t.assets||delete i.assets[o];for(let[o,a]of Object.entries(t.assets)){if(!(o in r.assets)){ec(i,o,a);continue}let s=r.assets[o];s===a||lt(s,a)||ZM(i.assets[o],a)}for(let o of Object.values(i.assets))if(Nn(o))for(let a of Object.values(o.content.nodes))hf(a)},n):{status:"aborted",reason:"missing-root-canvas-asset"}}function nN(e={}){return{undoStack:[],redoStack:[],limit:e.limit??200,mergeWindow:e.mergeWindow??500}}function _Z(e,t){if(!t.historyGroupKey||t.historyGroupMode!=="append")return-1;for(let n=e.length-1;n>=0;n-=1)if(e[n].historyGroupKey===t.historyGroupKey)return n;return-1}function TZ(e,t){return{...e,forwardPatches:[...e.forwardPatches,...t.forwardPatches],reversePatches:[...t.reversePatches,...e.reversePatches],timestamp:t.timestamp}}function vS(e,t,n){if(!n||t.source!=="local")return;let r=_Z(e.undoStack,t);if(r>=0){e.undoStack[r]=TZ(e.undoStack[r],t),e.redoStack=[];return}let i=e.undoStack[e.undoStack.length-1];i&&t.mergeKey&&i.mergeKey===t.mergeKey&&t.timestamp-i.timestamp<=e.mergeWindow?e.undoStack[e.undoStack.length-1]={...i,forwardPatches:[...i.forwardPatches,...t.forwardPatches],reversePatches:[...t.reversePatches,...i.reversePatches],timestamp:t.timestamp}:(e.undoStack.push(t),e.undoStack.length>e.limit&&e.undoStack.shift()),e.redoStack=[]}function xS(e){e.undoStack=[],e.redoStack=[]}function rN(e,t){let n=new Set(t);n.size&&(e.undoStack=e.undoStack.filter(r=>!n.has(r.id)),e.redoStack=e.redoStack.filter(r=>!n.has(r.id)))}function RS(e,t,n,r){let i=-1,o=c=>{throw new We(c,"MIDDLEWARE_REJECTED")},a=c=>{throw new We(c,"GUARD_REJECTED")},s=c=>{if(c<=i)throw new We("Middleware called next() multiple times","MIDDLEWARE_REJECTED");i=c;let d=e[c];d&&d({txId:t.id,forwardPatches:t.forwardPatches,reversePatches:t.reversePatches,intent:t.intent,source:t.source,nextState:r,prevState:n,reject:o,rejectExpected:a},()=>s(c+1))};s(0)}function iN(e){let t={id:e.txId,intent:e.intent,forwardPatches:e.forwardPatches,reversePatches:e.reversePatches,timestamp:Date.now(),source:"remote"};return t.undoable=!1,t}function oN(e){return{applyRemoteSnapshot(t,n){let r=e.getState(),{forwardPatches:i,reversePatches:o,nextState:a}=eN(r,t);if(i.length===0)return{status:"noop",reason:"no-changes"};let s=iN({forwardPatches:i,intent:"remote.snapshot",reversePatches:o,txId:e.nextTransactionId()}),c=Iu(a,e.registry);return e.setState(c),e.onStateCommitted(),e.notify(s,i,r,c),e.reportCommit(s,c),n==null||n.conflicts,{status:"committed",transaction:s}},applyRemotePatches(t,n){if(t.length===0)return{status:"noop",reason:"no-changes"};let r=e.getState();try{let[i,,o]=gr(r,c=>yr(c,yf(t))),a=Iu(i,e.registry),s=iN({forwardPatches:[...t],intent:"remote.patches",reversePatches:ao(o),txId:e.nextTransactionId()});return e.setState(a),e.onStateCommitted(),e.notify(s,s.forwardPatches,r,a),e.reportCommit(s,a),n==null||n.conflicts,{status:"committed",transaction:s}}catch(i){return e.logAbort({error:i,intent:"remote.patches",source:"remote"}),{status:"aborted",reason:i instanceof Error?i.message:String(i),error:i instanceof Error?i:void 0}}}}}function aN(){let e=new Set,t=new Set;return{notify(n,r,i,o){let a={transaction:n,prevState:i,nextState:o};for(let c of Array.from(e))c(a);if(r.length===0)return;let s={transaction:n,patches:r,prevState:i,nextState:o};for(let c of Array.from(t))c(s)},subscribe(n){return e.add(n),()=>{e.delete(n)}},subscribePatches(n,r){let i=r?o=>{let a=o.patches.filter(s=>s.assetId===r.assetId);a.length!==0&&n({...o,patches:a})}:n;return t.add(i),()=>{t.delete(i)}}}}var SZ=/\b(node|edge|asset|canvas|group|tx|run|request|workflow)[_-][A-Za-z0-9_-]+\b/gi,bZ=/\b[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\b/gi;function CZ(e){return e instanceof Error?e.message:String(e)}function AZ(e){return e instanceof Error?e.name:typeof e}function sN(e){if(e instanceof We)return e.code}function IZ(e){return e.replace(SZ,"$1_<id>").replace(bZ,"<uuid>").replace(/\b\d{6,}\b/g,"<number>").replace(/\s+/g," ").trim()||"unknown"}function vZ(e,t){let n=sN(e);return n&&n!=="MIDDLEWARE_REJECTED"?n:IZ(t)}function cN(e){let t=CZ(e),n=sN(e);return{canvas_sdk_error_reason:vZ(e,t),error_name:AZ(e),reason:t,...n?{transaction_error_code:n}:{}}}hr();function vu(e){let t=e.registry??rf(),n=aN(),r=[cS,...e.middlewares??[]],i=nN({limit:e.historyLimit,mergeWindow:e.mergeWindow}),o=Iu(e.initialDocument,t),a=null,s=0,c=0,d,u=(g,y)=>{xZ(g,y,e.getTelemetryContext)},p=()=>{s+=1;let g=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;return`tx_${s}_${g}`},m=(g,y,_)=>{if(g.length===0)return{status:"noop",reason:"no-changes"};let S=o,T,C;try{T=qs(S,x=>yr(x,yf(g))),C={id:p(),intent:_.intent,forwardPatches:[...g],reversePatches:[...y],timestamp:Date.now(),mergeKey:_.mergeKey,historyGroupKey:_.historyGroupKey,historyGroupMode:_.historyGroupMode,source:_.source},C.undoable=_.undoable,_.skipMiddleware||RS(r,C,S,T)}catch(I){return uN(I)&&PS({error:I,intent:_.intent,source:_.source}),{status:"aborted",reason:I instanceof Error?I.message:String(I),error:I instanceof Error?I:void 0}}return o=T,c+=1,vS(i,C,_.undoable),n.notify(C,C.forwardPatches,S,o),u(C,o),{status:"committed",transaction:C}},f=oN({clearHistory:()=>xS(i),getState:()=>o,logAbort:PS,nextTransactionId:p,notify:n.notify,registry:t,reportCommit:u,setState:g=>{o=g},onStateCommitted:()=>{c+=1}}),h={transact(g,y={}){if(a){let C=g(a);if(dN(C))throw new We("transact recipe must be synchronous","ASYNC_RECIPE");return{status:"noop",reason:"merged-into-outer"}}let _=o,S=y.source??"local",T=y.undoable??!0;try{let[C,I,x]=gr(_,H=>{a=H;try{let U=g(H);if(dN(U))throw new We("transact recipe must be synchronous","ASYNC_RECIPE")}finally{a=null}}),R=ao(I),G=ao(x);if(R.length===0)return{status:"noop",reason:"no-changes"};let O=C,K={id:p(),intent:y.intent,forwardPatches:R,reversePatches:G,timestamp:Date.now(),mergeKey:y.mergeKey,historyGroupKey:y.historyGroupKey,historyGroupMode:y.historyGroupMode,source:S};return K.undoable=T,y.skipMiddleware||RS(r,K,_,O),o=O,c+=1,vS(i,K,T),n.notify(K,R,_,o),u(K,o),{status:"committed",transaction:K}}catch(C){return a=null,uN(C)&&PS({error:C,intent:y.intent,source:S}),{status:"aborted",reason:C instanceof Error?C.message:String(C),error:C instanceof Error?C:void 0}}},getState(){return o},getRevision(){return c},getRootCanvas(){return jm(o)},getRootCanvasContent(){return M(o)},subscribe:n.subscribe,subscribePatches:n.subscribePatches,subscribeSelector(g,y,_){let S=(_==null?void 0:_.equalityFn)??Object.is,T=g(o);return h.subscribe(({nextState:C})=>{let I=g(C);if(!S(I,T)){let x=T;T=I,y(I,x)}})},undo(){let g=i.undoStack.pop();if(!g)return{status:"noop",reason:"no-changes"};let y=m(g.reversePatches,g.forwardPatches,{intent:g.intent?`undo:${g.intent}`:"undo",source:"local",undoable:!1});return y.status==="committed"?i.redoStack.push(g):i.undoStack.push(g),y},redo(){let g=i.redoStack.pop();if(!g)return{status:"noop",reason:"no-changes"};let y=m(g.forwardPatches,g.reversePatches,{intent:g.intent?`redo:${g.intent}`:"redo",source:"local",undoable:!1});return y.status==="committed"?i.undoStack.push(g):i.redoStack.push(g),y},canUndo(){return i.undoStack.length>0},canRedo(){return i.redoStack.length>0},clearHistory(){xS(i)},discardHistoryTransactions(g){rN(i,g)},use(g){return r.push(g),()=>{let y=r.indexOf(g);y>=0&&r.splice(y,1)}},applyRemoteSnapshot:f.applyRemoteSnapshot,applyRemotePatches:f.applyRemotePatches,get commands(){return d},registry:t};return d=bS(h),h}function xZ(e,t,n){let r=new Set(e.forwardPatches.map(o=>o.assetId)),i=M(t);Au({action:"canvas_transaction_commit",category:"canvas",packageName:"canvas-sdk",status:"success",context:{...RZ(n),root_canvas_id:t.rootCanvasId,transaction_id:e.id,transaction_history_group_key:e.historyGroupKey,transaction_history_group_mode:e.historyGroupMode,transaction_intent:e.intent,transaction_merge_key:e.mergeKey,transaction_source:e.source,undoable:e.undoable??!0},metrics:{asset_count:r.size,count:1,node_count:Object.keys(i.nodes).length,patch_count:e.forwardPatches.length}})}function RZ(e){try{return e==null?void 0:e()}catch{return}}function dN(e){return!!(e&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function")}function PS({error:e,intent:t,source:n}){pt.error("[canvas-sdk] transaction aborted",{error:e,...cN(e),intent:t,source:n})}function uN(e){return!(e instanceof We&&(e.code==="READ_ONLY"||e.code==="GUARD_REJECTED"))}function MZ(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function pN(){let e,t=0;return{getCanvasClipboard(){return e},setCanvasClipboard(n){e=MZ(n),t=0},clearCanvasClipboard(){e=void 0,t=0},getCanvasClipboardPasteCount(){return t},markCanvasClipboardPasted(){t+=1}}}function On(e,t,n){let r=e.get(t)??new Set;r.add(n),e.set(t,r)}function Ln(e,t,n){let r=e.get(t);r&&(r.delete(n),r.size===0&&e.delete(t))}function Vt(e,t,n){for(let r of Array.from(e.get(t)??[]))r(n)}function Me(e,t){return()=>{e.delete(t)}}function lN(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n}]))}function mN(e,t){return(e==null?void 0:e.x)===(t==null?void 0:t.x)&&(e==null?void 0:e.y)===(t==null?void 0:t.y)}function fN(){let e={},t=new Set,n=new Map,r=i=>{let o=e;e=lN(i);for(let s of Array.from(t))s(e);let a=new Set([...Object.keys(o),...Object.keys(e)]);for(let s of a){let c=o[s],d=e[s];mN(c,d)||Vt(n,s,d)}};return{getDragPreview(){return e},getPreviewOf(i){return e[i]},setDragPreview:r,update(i,o){r({...e,[i]:{...o}})},updateMany(i){let o={...e};for(let{id:a,position:s}of i)o[a]={...s};r(o)},clear(i){if(i){let o={...e};delete o[i],r(o);return}r({})},clearDragPreview(){r({})},subscribeDragPreview(i){return t.add(i),Me(t,i)},subscribePreviewOf(i,o){return On(n,i,o),()=>Ln(n,i,o)}}}function hN(){let e,t=new Set,n=new Map,r=i=>{if(e===i)return;let o=e;e=i;for(let a of Array.from(t))a(e);o&&Vt(n,o,!1),e&&Vt(n,e,!0)};return{getHoveredEdgeId(){return e},isEdgeHovered(i){return e===i},setHoveredEdge:r,clearEdgeHover(){r(void 0)},subscribeEdgeHover(i){return t.add(i),Me(t,i)},subscribeEdgeHoverOf(i,o){return On(n,i,o),()=>Ln(n,i,o)}}}function gN(){let e,t=new Set,n=new Map,r=o=>{if(o!==e){for(let a of Array.from(t))a(e);o&&Vt(n,o,!1),e&&Vt(n,e,!0)}},i=o=>{let a=e;e=o,r(a)};return{getSelectedEdgeId(){return e},isEdgeSelected(o){return e===o},setSelectedEdge(o){i(o)},clearEdgeSelection(){i(void 0)},subscribeEdgeSelection(o){return t.add(o),Me(t,o)},subscribeEdgeSelectionOf(o,a){return On(n,o,a),()=>Ln(n,o,a)}}}function yN(){let e=null,t=new Set,n=new Map,r=i=>{if(e===i)return;let o=e;e=i;for(let a of Array.from(t))a(e);o&&Vt(n,o,!1),e&&Vt(n,e,!0)};return{getHovered(){return e},isHovered(i){return e===i},setHovered:r,clear(){r(null)},subscribeHover(i){return t.add(i),Me(t,i)},subscribeHoverOf(i,o){return On(n,i,o),()=>Ln(n,i,o)}}}function _N(e=!1){let t=e,n=new Set,r=i=>{if(t!==i){t=i;for(let o of Array.from(n))o(t)}};return{isMiniMapVisible(){return t},setMiniMapVisible:r,toggleMiniMapVisible(){r(!t)},subscribeMiniMapVisible(i){return n.add(i),Me(n,i)}}}function NZ(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function TN(){let e=new Set,t=new Set,n=new Map,r=i=>{let o=e,a=new Set(i);if(NZ(o,a))return;e=a;for(let c of Array.from(t))c(e);let s=new Set([...o,...a]);for(let c of s)o.has(c)!==a.has(c)&&Vt(n,c,a.has(c))};return{getHighlightedNodeIds(){return e},isNodeHighlighted(i){return e.has(i)},setHighlightedNodes:r,clearHighlightedNodes(){r([])},subscribeNodeHighlight(i){return t.add(i),Me(t,i)},subscribeNodeHighlightOf(i,o){return On(n,i,o),()=>Ln(n,i,o)}}}function wZ(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function SN(){let e=new Set,t=new Set,n=r=>{let i=new Set([...r].map(o=>o.trim()).filter(o=>!!o));if(!wZ(e,i)){e=i;for(let o of Array.from(t))o(e)}};return{getHighlightedNodeTypes(){return e},isNodeTypeHighlighted(r){return e.has(r)},setHighlightedNodeTypes:n,clearHighlightedNodeTypes(){n([])},subscribeNodeTypeHighlight(r){return t.add(r),Me(t,r)}}}function Qn(e){switch(e.type){case"single_node":return new Set([e.activeId]);case"multi_node_discrete":case"multi_node_region":return new Set(e.selectedIds);case"none":default:return new Set}}function _f(e){let t=new Set(e);return t.size===0?{type:"none"}:t.size===1?{type:"single_node",activeId:[...t][0]}:{type:"multi_node_discrete",selectedIds:t}}function DS(e){if(e.type==="multi_node_discrete"){let t=new Set(e.selectedIds);return{..._f(t),...t.size>1&&e.activeId&&t.has(e.activeId)?{activeId:e.activeId}:{}}}if(e.type==="multi_node_region"){let t=new Set(e.selectedIds);return t.size===0?{type:"none"}:{...e,selectedIds:t}}return e}function bN(e,t,n){let r=new Set(t),i=new Set(n==="replace"?[]:Qn(e));if(n==="replace")return r;for(let o of r)n==="add"?i.add(o):n==="subtract"||i.has(o)?i.delete(o):i.add(o);return i}function ES(e,t){let n=Qn(e),r=Qn(t);if(n.size!==r.size)return!1;for(let i of n)if(!r.has(i))return!1;return e.type===t.type}function kZ(e){switch(e.type){case"multi_node_discrete":return{...e,selectedIds:new Set(e.selectedIds)};case"multi_node_region":return{...e,selectedIds:new Set(e.selectedIds),selectionBounds:{...e.selectionBounds}};default:return{...e}}}function CN(e={type:"none"}){let t=DS(e),n=Qn(t),r=new Set,i=new Set,o=new Map,a=0,s=d=>{if(ES(d,t))return;for(let f of Array.from(r))f(t);let u=Qn(d),p=n,m=new Set([...u,...p]);for(let f of m)u.has(f)!==p.has(f)&&Vt(o,f,p.has(f))},c=(d,u)=>{let p=t;t=DS(d);let m=!ES(p,t);if(!m&&(u==null?void 0:u.cause)!=="navigation")return;m&&(n=Qn(t)),a+=1;let f=Array.from(i),h=f.length?{selection:kZ(t),revision:a,...u!=null&&u.cause?{cause:u.cause}:{}}:void 0;if(s(p),h)for(let g of f)g(h)};return{getSelection(){return t},has(d){return n.has(d)},getSelectedIds(){return n},setSelection:c,clear(){c({type:"none"})},apply(d,u){c(_f(bN(t,d,u)))},subscribeSelection(d){return r.add(d),Me(r,d)},subscribeSelectionChange(d){return i.add(d),Me(i,d)},subscribeSelectionOf(d,u){return On(o,d,u),()=>Ln(o,d,u)}}}function AN(){let e=new Set;return{emitSelectionInteraction(t){if(t.nodeIds.size===0)return;let n={...t,nodeIds:new Set(t.nodeIds)};for(let r of Array.from(e))r(n)},subscribeSelectionInteraction(t){return e.add(t),Me(e,t)}}}function xu(e){let t=new Set(e.targets);return{enabled:e.enabled,tolerance:e.threshold,snapToGrid:t.has("grid"),snapToNodes:t.has("node"),snapToGuidelines:t.has("guide")}}function MS(e,t){return e.enabled===t.enabled&&e.threshold===t.threshold&&e.targets.length===t.targets.length&&e.targets.every((n,r)=>n===t.targets[r])}function NS(e,t){let n=new Set(t),r={vertical:[],horizontal:[]};for(let[i,o]of e.entries())n.has(i)||(r.vertical.push({value:o.x,nodeId:i,type:"min"},{value:o.x+o.w/2,nodeId:i,type:"mid"},{value:o.x+o.w,nodeId:i,type:"max"}),r.horizontal.push({value:o.y,nodeId:i,type:"min"},{value:o.y+o.h/2,nodeId:i,type:"mid"},{value:o.y+o.h,nodeId:i,type:"max"}));return r}function OZ(e,t){let n=t.candidate.value-t.moved,r=Math.abs(n);return r>t.tolerance||e&&r>=e.distance?e:{offset:n,distance:r,line:{id:`${t.axis}:${t.draggingId}:${t.candidate.nodeId}:${t.candidate.value}`,type:t.axis==="x"?"v":"h",value:t.candidate.value,sourceNodeId:t.candidate.nodeId,targetNodeIds:[t.draggingId]}}}function Tf(e,t,n,r,i,o){if(!o.snapToNodes||e.length===0)return;let a;for(let s of t){let c=n.get(s);if(!c)continue;let d=i==="x"?[c.x,c.x+c.w/2,c.x+c.w]:[c.y,c.y+c.h/2,c.y+c.h];for(let u of d){let p=u+r;for(let m of e)a=OZ(a,{axis:i,candidate:m,draggingId:s,moved:p,tolerance:o.tolerance})}}return a}var LZ={enabled:!0,tolerance:6,snapToGrid:!1,snapToNodes:!0,snapToGuidelines:!0,edgeSnapping:!0,centerSnapping:!0,spacingSnapping:!1};function IN(e){let t={...LZ,...e??{}},n={activeLines:[],snapOffset:{x:0,y:0}},r={vertical:[],horizontal:[]},i=new Set,o=a=>{n={activeLines:[...a.activeLines],snapOffset:{...a.snapOffset}};for(let s of Array.from(i))s(n)};return{getSnapConfig(){return t},setSnapConfig(a){t={...t,...a}},getSnappingState(){return n},setSnappingState:o,clearSnapping(){o({activeLines:[],snapOffset:{x:0,y:0}})},buildCandidatePool(a,s){let c=new Set(a);r=s?NS(s,a):{vertical:r.vertical.filter(d=>!c.has(d.nodeId)),horizontal:r.horizontal.filter(d=>!c.has(d.nodeId))}},clearCandidatePool(){r={vertical:[],horizontal:[]}},computeSnapResult(a,s,c){if(!t.enabled){let g={adjustedDelta:s,snapOffset:{x:0,y:0},activeLines:[]};return o({activeLines:g.activeLines,snapOffset:g.snapOffset}),g}let d=new Set(a),u=Tf(r.vertical.filter(g=>!d.has(g.nodeId)),a,c,s.x,"x",t),p=Tf(r.horizontal.filter(g=>!d.has(g.nodeId)),a,c,s.y,"y",t),m={x:(u==null?void 0:u.offset)??0,y:(p==null?void 0:p.offset)??0},f=[...u?[u.line]:[],...p?[p.line]:[]],h={adjustedDelta:{x:s.x+m.x,y:s.y+m.y},snapOffset:m,activeLines:f};return o({activeLines:f,snapOffset:m}),h},subscribeSnapping(a){return i.add(a),Me(i,a)}}}function vN(e=!1){let t=e,n=new Set,r=i=>{if(t!==i){t=i;for(let o of Array.from(n))o(t)}};return{isViewportPanModeEnabled(){return t},setViewportPanModeEnabled:r,toggleViewportPanModeEnabled(){r(!t)},subscribeViewportPanModeEnabled(i){return n.add(i),Me(n,i)}}}function xN(e="trackpad"){let t=e,n=new Set;return{getViewportInputMode(){return t},setViewportInputMode:i=>{if(t!==i){t=i;for(let o of Array.from(n))o(t)}},subscribeViewportInputMode(i){return n.add(i),Me(n,i)}}}function RN(){let e=new Set;return{emitGeometryChange(t){if(t.nodeIds.size!==0)for(let n of Array.from(e))n(t)},subscribeGeometryChange(t){return e.add(t),Me(e,t)}}}function wS(e){let t=CN(e==null?void 0:e.initialSelection),n=AN(),r=gN(),i=hN(),o=yN(),a=TN(),s=SN(),c=_N(),d=vN(),u=xN(e==null?void 0:e.initialViewportInputMode),p=IN(e==null?void 0:e.initialSnapConfig),m=fN(),f=pN(),h=RN();return{...t,...n,...r,...i,...o,...a,...s,...c,...d,...u,...p,...m,...f,...h,setSelection:(_,S)=>{t.setSelection(_,S),Qn(t.getSelection()).size>0&&r.clearEdgeSelection()},apply:(_,S)=>{t.apply(_,S),t.getSelectedIds().size>0&&r.clearEdgeSelection()},setSelectedEdge(_){t.clear(),r.setSelectedEdge(_)},clearEdgeSelection:r.clearEdgeSelection,clear(_){if(_){m.clear(_);return}t.clear(),r.clearEdgeSelection(),i.clearEdgeHover(),o.clear(),a.clearHighlightedNodes()}}}var Sf=class{constructor(t){this.options=t;this.failureCountByTransactionId=new Map}reportFailure(t,n){var c,d,u;let r=(c=this.options.diagnostics)==null?void 0:c.report;if(!r)return;let i=new Set(n.acknowledgedTransactionIds),o=n.transactions.filter(p=>!i.has(p.txId)).filter(p=>{let m=(this.failureCountByTransactionId.get(p.txId)??0)+1;return this.failureCountByTransactionId.set(p.txId,m),m===6}),a=o.map(p=>p.txId).slice(0,20);if(a.length===0)return;let s={attemptCount:Math.max(...o.map(p=>p.attempt)),errorMessage:t.message,errorName:t.name||"Error",eventName:"pippit_asset_sync_commit_retry_failed",retryCount:5,...(d=this.options.diagnostics)!=null&&d.runtimeId?{runtimeId:this.options.diagnostics.runtimeId}:{},...(u=this.options.diagnostics)!=null&&u.scopeId?{scopeId:this.options.diagnostics.scopeId}:{},syncPhase:n.syncPhase,syncReason:"commit-failed",transactionIds:a,trigger:"commit-retry"};try{r(s)}catch(p){try{this.options.logger.warn(`${this.options.logPrefix} diagnostic reporter failed`,{diagnosticEventName:s.eventName,errorMessage:p instanceof Error?p.message:String(p),errorName:p instanceof Error?p.name:"Error"})}catch{}}}forget(t){t.forEach(n=>this.failureCountByTransactionId.delete(n))}clear(){this.failureCountByTransactionId.clear()}};var FZ=e=>String(e).replace(/~/g,"~0").replace(/\//g,"~1"),BZ=e=>e.replace(/~1/g,"/").replace(/~0/g,"~"),GZ=e=>/^\d+$/.test(e)?Number(e):e,PN=e=>e.length===0?"":`/${e.map(FZ).join("/")}`,tc=e=>{if(e==="")return[];if(!e.startsWith("/"))throw new Error(`Invalid JSON pointer: ${e}`);return e.slice(1).split("/").map(BZ).map(GZ)},DN=e=>{if(e.path[0]==="revision"||e.path[0]!=="assets"||e.path.length<2)return null;let t={assetId:String(e.path[1]),op:e.op,path:PN(e.path.slice(2))};return e.op!=="remove"&&(t.value=e.value),t},bf=e=>{let t=[];for(let n of e){let r=DN(n);r&&t.push(r)}return t},EN=e=>{let t={op:e.op,path:["assets",e.assetId,...tc(e.path)]};return e.op!=="remove"&&(t.value=e.value),t},ba=e=>e.map(EN),MN=e=>`${e.assetId}\0${e.path}`,NN=e=>tc(e).some(t=>typeof t=="number"),zZ=(e,t)=>e===t||e===""||t===""?!0:e.startsWith(`${t}/`)||t.startsWith(`${e}/`);function UZ(e,t){let n=r=>{let{rebaseCondition:i,...o}=r;return e.rebaseCondition?{...o,rebaseCondition:e.rebaseCondition}:o};if(e.op==="add"&&t.op==="remove")return null;if((e.op==="add"||e.op==="replace")&&t.op==="replace")return n({...t,op:e.op});if((e.op==="add"||e.op==="replace")&&t.op==="add")return n({...t,op:e.op});if(e.op==="replace"&&t.op==="remove")return n(t);if(e.op==="remove"&&t.op==="add")return n({...t,op:"replace"});if(e.op==="remove"&&t.op==="remove")return n(t)}function VZ(e){let t=new Map;for(let n=0;n<e.length;n+=1){let r=e[n];NN(r.path)||t.set(MN(r),n)}return t}var Ca=e=>{let t=[],n=new Map;for(let r of e){let i=!NN(r.path),o=MN(r),a=i?n.get(o):void 0,s=a===void 0?void 0:t[a],c=s?UZ(s,r):void 0;if(a!==void 0&&s&&c!==void 0){t.splice(a,1),c!==null&&t.push(c),n=VZ(t);continue}for(let[d,u]of Array.from(n.entries())){let p=t[u];p.assetId===r.assetId&&zZ(p.path,r.path)&&n.delete(d)}t.push(r),i&&n.set(o,t.length-1)}return t};function wN(e,t){return!Number.isFinite(e)||e===void 0?t:Math.max(1,Math.floor(e))}function Ru(e){let t=wN(e==null?void 0:e.maxBatchSize,10),n=wN(e==null?void 0:e.maxBatchPatchCount,50),r=[],i=[],o=(s,c)=>{for(let d of s.patches)d.op==="add"&&d.path===""&&c.add(d.assetId)};return{enqueue(s){let c={txId:s.id,patches:Ca(s.forwardPatches),intent:s.intent,mergeKey:s.mergeKey,attempt:0,enqueuedAt:Date.now(),status:"pending"};return r.push(c),c},takeNextBatch(){if(r.length===0||r[0].status==="in-flight")return null;let s=[r[0]],c=new Set;o(r[0],c);let d=s[0].patches.length;for(let p=1;p<r.length;p+=1){let m=r[p],f=m.patches.length,h=m.patches.some(g=>c.has(g.assetId));if(m.status!=="pending"||s.length>=t||d+f>n||h)break;s.push(m),o(m,c),d+=f}for(let p of s)p.status="in-flight",p.attempt+=1;return i=s.map(p=>p.txId),{...s[0],txIds:[...i],patches:s.flatMap(p=>p.patches),attempt:Math.max(...s.map(p=>p.attempt)),status:"in-flight",envelopes:s.map(p=>({...p,patches:[...p.patches]}))}},ack(s){let c=Array.isArray(s)?s:[s],d=new Set(c),u=r.filter(p=>d.has(p.txId)).map(p=>p.txId);return r=r.filter(p=>!d.has(p.txId)),i=i.filter(p=>!d.has(p)),Promise.resolve(u)},markRebasing(s){let c=Array.isArray(s)?s:[s],d=new Set(c);for(let u of r)d.has(u.txId)&&(u.status="rebasing");i=i.filter(u=>!d.has(u))},replaceAll(s){let c=new Set(i);return r=s.map(d=>({...d,patches:[...d.patches],status:c.has(d.txId)?"in-flight":d.status==="in-flight"?"pending":d.status})),i=r.filter(d=>d.status==="in-flight").map(d=>d.txId),Promise.resolve()},size:()=>r.length,snapshot:()=>r.map(s=>({...s,patches:[...s.patches]})),releaseInflight(){let s=new Set(i);for(let c of r)s.has(c.txId)&&(c.status="pending");i=[]}}}var Cf=class{constructor(t){this.options=t;this.flushBlockedReported=!1}reportFailure(t,n,r){this.failure||(this.failure={error:t,operation:n},this.emit("pippit_asset_sync_persistence_failed","persistence-write",r))}reportFlushBlocked(t,n){!this.failure||this.flushBlockedReported||(this.flushBlockedReported=!0,this.emit("pippit_asset_sync_flush_blocked",t,n))}emit(t,n,r){var a,s,c,d;let{failure:i}=this;if(!i)return;let o={errorMessage:i.error.message,errorName:i.error.name||"Error",eventName:t,hasPendingTransaction:r.pendingTransactionIds.length>0,pendingTransactionCount:r.pendingTransactionIds.length,pendingTransactionIds:r.pendingTransactionIds.slice(0,20),persistenceOperation:i.operation,...(a=this.options.diagnostics)!=null&&a.runtimeId?{runtimeId:this.options.diagnostics.runtimeId}:{},...(s=this.options.diagnostics)!=null&&s.scopeId?{scopeId:this.options.diagnostics.scopeId}:{},syncPhase:r.syncPhase,syncReason:"persistence-failed",trigger:n};this.options.logger.error(`${this.options.logPrefix} ${t}`,o);try{(d=(c=this.options.diagnostics)==null?void 0:c.report)==null||d.call(c,o)}catch(u){this.options.logger.warn(`${this.options.logPrefix} diagnostic reporter failed`,{diagnosticEventName:t,errorMessage:u instanceof Error?u.message:String(u),errorName:u instanceof Error?u.name:"Error"})}}};var Af=class{constructor(t){this.onFailure=t;this.pending=new Set;this.failure=null;this.tail=Promise.resolve()}track(t,n="unknown"){this.run(t,n).catch(()=>{})}run(t,n="unknown"){let r=this.tail.then(async()=>{this.throwIfFailed();try{await t()}catch(i){throw this.recordFailure(i,n)}}).finally(()=>{this.pending.delete(r)});return this.pending.add(r),this.tail=r.catch(()=>{}),r}async waitForCaptured(){for(;;){this.throwIfFailed();let t=[...this.pending];if(t.length===0)return;await Promise.all(t)}}hasFailed(){return this.failure!==null}recordFailure(t,n){let r=t instanceof Error?t:new Error(String(t));return this.failure||(this.failure=r,this.onFailure(r,n)),this.failure}throwIfFailed(){if(this.failure)throw this.failure}};var If=class{constructor(t){this.options=t;this.ready=!1;this.retryAttempt=0;this.retryTimer=null}isReady(){return this.ready}reset(){this.dispose(),this.ready=!1,this.retryAttempt=0}markReady(){this.ready=!0,this.retryAttempt=0,this.dispose()}schedule(){if(this.options.isClosed()||this.ready||this.retryTimer||!this.options.hasAttachedStore())return;let t=Math.min(this.options.retryMaxMs,this.options.retryBaseMs*2**this.retryAttempt);this.retryAttempt+=1,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.options.sync().then(n=>{n||this.schedule()},()=>{this.schedule()})},t)}dispose(){this.retryTimer&&(clearTimeout(this.retryTimer),this.retryTimer=null)}};hr();var vf=e=>`${e.assetId}\0${e.path}`;function Pu(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((a,s)=>Pu(a,t[s]));if(!e||!t||typeof e!="object"||typeof t!="object")return!1;let n=e,r=t,i=Object.keys(n),o=Object.keys(r);return i.length===o.length&&i.every(a=>Object.hasOwn(r,a)&&Pu(n[a],r[a]))}function qZ(e,t){let n=e.assets;for(let r of[t.assetId,...tc(t.path)]){if(!n||typeof n!="object"||!Object.hasOwn(n,r))return{exists:!1};n=n[r]}return{exists:!0,value:n}}function KZ(e,t){return t.op==="remove"?!e.exists:e.exists&&Pu(e.value,t.value)}function kN(e,t){let n=e;for(let r of tc(t)){if(!n||typeof n!="object"||!Object.hasOwn(n,r))return{exists:!1};n=n[r]}return{exists:!0,value:n}}function jZ(e,t){var o;let n=(o=t.rebaseCondition)==null?void 0:o.acceptExistingValueAt;if(!n||!e.exists||t.op==="remove")return!1;let r=kN(e.value,n),i=kN(t.value,n);return r.exists&&i.exists&&Pu(r.value,i.value)}function HZ(e,t){let n=[];for(let r of t.patches){let i=r.rebaseCondition;if(!i){n.push(r);continue}let o=qZ(e,r);if(o.exists===i.exists&&(!i.exists||Pu(o.value,i.value)))n.push(r);else if(!KZ(o,r)&&!jZ(o,r))throw new Error(`Asset sync rebase condition failed: ${r.assetId}${r.path}`)}return n}function $Z(e,t){let n=new Set(e.filter(r=>r.op==="add"&&r.path==="").map(vf));return n.size===0?t:t.map(r=>r.op==="replace"&&r.path===""&&n.has(vf(r))?{...r,op:"add"}:r)}function YZ(e,t){let n=new Map(e.filter(r=>r.rebaseCondition).map(r=>[vf(r),r.rebaseCondition]));return n.size===0?t:t.map(r=>{let i=n.get(vf(r));return i?{...r,rebaseCondition:i}:r})}function XZ(e,t,n){var i;if(!e.observeRebasedEnvelope)return;let r={state:t,envelope:n};try{e.observeRebasedEnvelope(r)}catch(o){try{(i=e.onObserverError)==null||i.call(e,o,r)}catch{}}}function xf(e){var i;let t=e.baseState,n=[],r=[];for(let o of e.envelopes)try{let a=HZ(t,o),[s,c]=gr(t,p=>yr(p,ba(a)));(i=e.validateRebasedEnvelope)==null||i.call(e,{envelope:o,nextState:s,previousState:t});let d=YZ(o.patches,$Z(o.patches,Ca(bf(c))));if(d.length===0){t=s;continue}let u={...o,patches:d,status:"pending"};XZ(e,t,u),t=s,n.push(u)}catch(a){r.push({txId:o.txId,intent:o.intent,reason:a instanceof Error?a.message:String(a),cause:a instanceof Error?a:void 0})}return{rebased:n,conflicts:r,resultState:t}}var Rf=class{constructor(){this.waiters=new Set}waitFor(t){return new Promise((n,r)=>{this.waiters.add({remaining:new Set(t),resolve:n,reject:r})})}capture(t){return[...this.waiters].filter(n=>[...n.remaining].some(r=>t.has(r)))}settle(t,n,r){for(let i of t)if(this.waiters.has(i)){if(r){this.waiters.delete(i),i.reject(r);continue}for(let o of n)i.remaining.delete(o);i.remaining.size===0&&(this.waiters.delete(i),i.resolve())}}dispose(t=new Error("Asset refresh was cancelled")){for(let n of this.waiters)n.reject(t);this.waiters.clear()}};hr();function di(e){return e instanceof Error?e:new Error(String(e))}async function Pf(e,t){if(e.runPersistenceMutation){await e.runPersistenceMutation(t);return}await t()}function Sr(e,t,n){var r;return!e.closed&&e.attachedStore===t&&(n===void 0||((r=e.getAttachmentEpoch)==null?void 0:r.call(e))===n)}async function WZ(e,t,n){await Pf(e,async()=>{if(e.persistence.replaceOutboundPartition){await e.persistence.replaceOutboundPartition(t,n);return}let r=new Set(n),i=new Set(t.map(s=>s.txId)),a=(await e.persistence.loadOutbound()).filter(s=>!r.has(s.txId)&&!i.has(s.txId));await e.persistence.replaceOutbound([...t,...a])})}var Df=new WeakMap;function JZ(e,t){return e===void 0?t:t===void 0?e:Math.max(e,t)}function QZ(e,t,n){let r=new Set(n.rebased.map(s=>s.txId)),i=new Set(n.conflicts.map(s=>s.txId)),o=[],a=[];for(let s of t)r.has(s.txId)||(i.has(s.txId)?a.push(s.txId):o.push(s.txId));o.length>0&&e.emit({kind:"discarded",txId:o[0],txIds:o,reason:"rebase-noop"}),a.length>0&&e.emit({kind:"discarded",txId:a[0],txIds:a,reason:"rebase-conflict"})}function OS(e){let t=Df.get(e);if(t)return t;let n={pending:new Map,refreshWaiters:new Rf,timer:null,applyQueue:Promise.resolve(),disposed:!1};return Df.set(e,n),n}function Ef(e,t){for(let n of t){let r=e.pending.get(n.assetId);e.pending.set(n.assetId,{assetId:n.assetId,minimumAssetVersion:JZ(r==null?void 0:r.minimumAssetVersion,n.minimumAssetVersion)})}}function ON(e){return e.assetVersion}function LN(e,t,n){let r=e,i=[],o=[];for(let a of t)try{let s=yr(r,ba(a.patches));if(n)try{n({envelope:a,nextState:s,previousState:r})}catch(c){throw o.push(a.txId),c}r=s}catch(s){i.push({txId:a.txId,intent:a.intent,reason:s instanceof Error?s.message:String(s),cause:s instanceof Error?s:void 0})}return{conflicts:i,guardRejectedTxIds:o,resultState:r}}function FN(e,t,n){return n.filter(r=>{var c,d;let i=(c=t.assets.find(u=>u.assetId===r.assetId))==null?void 0:c.minimumAssetVersion,o=ON(r),a=e.assetVersions.getVersion(r.assetId)??0;if(o===void 0||i!==void 0&&o<i)return e.logger.warn(`${e.logPrefix} skip scoped asset: fetched version is below event version`,{assetId:r.assetId,remoteAssetVersion:o,minimumAssetVersion:i,localAssetVersion:a}),!1;let s=r.asset!==null&&r.asset!==void 0&&((d=e.attachedStore)==null?void 0:d.getState().assets[r.assetId])===void 0;return o<a||o===a&&!s?(e.logger.info(`${e.logPrefix} skip scoped asset: remote asset version is not newer`,{assetId:r.assetId,remoteAssetVersion:o,localAssetVersion:a}),!1):!0})}function ZZ(e,t,n){return{assets:n,requests:n.map(r=>e.stateAdapter.createRemoteAssetRequest(t,r.assetId))}}function eee(e,t,n,r){let i=e.attachedStore;if(!i||e.closed||t.disposed)return null;let o=FN(e,n,r);if(o.length===0)return e.setState(e.transport.getConnectionState()==="open"?{phase:"idle"}:{phase:"offline"}),e.scheduleFlush(),null;let a=e.stateAdapter.mergeRemoteAssets(i.getState(),o);e.setState({phase:"rebasing"});let s=LN(a,e.outbound.snapshot(),e.validateRebasedEnvelope);s.conflicts.length>0&&e.logger.warn(`${e.logPrefix} scoped asset overlay conflicts`,{assetIds:o.map(d=>d.assetId),conflicts:s.conflicts});let c=()=>{i.applyRemoteSnapshot(s.resultState,{conflicts:s.conflicts})};e.withApplyingRemoteAssets?e.withApplyingRemoteAssets(o.map(d=>d.assetId),c):c();for(let d of o)e.assetVersions.remember(d.assetId,ON(d));return{acceptedAssets:o,remoteState:a,conflicts:s.conflicts,guardRejectedTxIds:s.guardRejectedTxIds}}async function tee(e,t,n,r){var o,a;await((o=e.waitForCapturedPersistenceWrites)==null?void 0:o.call(e));let i=eee(e,t,n,r);if(!(!i||!e.attachedStore||e.closed||t.disposed)){if(!e.readOnly){if(i.guardRejectedTxIds.length>0){let s=new Set(i.guardRejectedTxIds),c=e.outbound.snapshot().filter(u=>s.has(u.txId)).map(u=>u.txId);for(let u of c)await Pf(e,()=>e.persistence.removeOutbound(u));let d=await e.outbound.ack(c);d.length>0&&(e.emit({kind:"discarded",reason:"rebase-conflict",txId:d[0],txIds:d}),e.emitOutboundChange())}await Pf(e,()=>e.persistence.saveSnapshot({state:i.remoteState})),await((a=e.waitForCapturedPersistenceWrites)==null?void 0:a.call(e))}if(!(!e.attachedStore||e.closed||t.disposed)){if(e.emit({kind:"snapshot-applied"}),e.conflictPolicy==="conflict-event")for(let s of i.conflicts)e.emit({kind:"conflict",conflict:s});e.setState(e.transport.getConnectionState()==="open"?{phase:"idle"}:{phase:"offline"}),e.scheduleFlush()}}}function nee(e,t,n,r){let i=t.applyQueue.catch(()=>{}).then(()=>tee(e,t,n,r));return t.applyQueue=i.catch(()=>{}),i}async function ree(e,t){var s,c,d;let n=e.attachedStore;if(!n||e.closed||t.disposed||(s=e.hasPersistenceWriteFailure)!=null&&s.call(e)||!e.transport.fetchAssets){t.refreshWaiters.dispose(new Error("Scoped asset refresh is unavailable"));return}let r=Array.from(t.pending.values());if(t.pending.clear(),r.length===0)return;let i=ZZ(e,n.getState(),r),o=new Set(r.map(({assetId:u})=>u)),a=t.refreshWaiters.capture(o);e.setState({phase:"syncing",reason:"invalidate"});try{let u=await e.transport.fetchAssets(i.requests);if(t.disposed||e.closed||(c=e.hasPersistenceWriteFailure)!=null&&c.call(e)){t.refreshWaiters.settle(a,o,new Error("Asset refresh stopped before applying"));return}let p=FN(e,i,u.assets);if(p.length===0){e.setState(e.transport.getConnectionState()==="open"?{phase:"idle"}:{phase:"offline"}),e.scheduleFlush(),t.refreshWaiters.settle(a,o);return}await nee(e,t,i,p),t.refreshWaiters.settle(a,o)}catch(u){if(t.refreshWaiters.settle(a,o,di(u)),(d=e.hasPersistenceWriteFailure)!=null&&d.call(e)||e.closed||t.disposed)return;!t.disposed&&!e.closed&&Ef(t,r),e.logger.error(`${e.logPrefix} failed to sync scoped assets`,u),e.setState({phase:"error",error:di(u),reason:"remote-sync-failed"})}}function LS(e,t){t.timer||t.disposed||(t.timer=setTimeout(()=>{t.timer=null,ree(e,t)},e.scopedAssetFetchDebounceMs??500))}function BN(e){let t=Df.get(e);t&&(t.timer&&clearTimeout(t.timer),t.disposed=!0,t.refreshWaiters.dispose(),t.pending.clear(),Df.delete(e))}async function Du(e){var f,h,g,y,_,S,T;let t=e.attachedStore;if(!t||e.closed)return;let n=(f=e.getAttachmentEpoch)==null?void 0:f.call(e);if(await((h=e.waitForCapturedPersistenceWrites)==null?void 0:h.call(e)),!Sr(e,t,n))return;e.setState({phase:"syncing",reason:"bootstrap"});let r=await e.transport.fetchSnapshot();if(!Sr(e,t,n)||(await((g=e.waitForCapturedPersistenceWrites)==null?void 0:g.call(e)),!Sr(e,t,n)))return;e.setState({phase:"rebasing"});let i=e.outbound.snapshot(),o=xf({baseState:r.state,envelopes:i,validateRebasedEnvelope:e.validateRebasedEnvelope,observeRebasedEnvelope:e.observeOutboundEnvelope?({state:C,envelope:I})=>{var x;return(x=e.observeOutboundEnvelope)==null?void 0:x.call(e,C,I,"rebase")}:void 0,onObserverError:(C,{envelope:I})=>{e.logger.warn(`${e.logPrefix} outbound observer failed`,{error:C instanceof Error?C.message:String(C),phase:"rebase",txId:I.txId})}});o.conflicts.length>0&&e.logger.warn(`${e.logPrefix} rebase conflicts`,{conflicts:o.conflicts});let a=i.map(C=>C.txId),s=new Set(a);if(await((y=e.waitForCapturedPersistenceWrites)==null?void 0:y.call(e)),!Sr(e,t,n))return;let c=e.outbound.snapshot().filter(C=>!s.has(C.txId)),d=LN(o.resultState,c),u=[...o.conflicts,...d.conflicts];if(t.applyRemoteSnapshot(d.resultState,{conflicts:u}),!Sr(e,t,n))return;let p=e.readOnly?void 0:WZ(e,o.rebased,a),m=e.outbound.snapshot().filter(C=>!s.has(C.txId));if(await e.outbound.replaceAll(e.readOnly?[]:[...o.rebased,...m]),!!Sr(e,t,n)){if(e.emitOutboundChange(),!e.readOnly){if(await p,!Sr(e,t,n)||(await((_=e.waitForCapturedPersistenceWrites)==null?void 0:_.call(e)),!Sr(e,t,n))||(await Pf(e,()=>e.persistence.saveSnapshot({state:r.state})),!Sr(e,t,n)))return;await((S=e.waitForCapturedPersistenceWrites)==null?void 0:S.call(e))}if(Sr(e,t,n)){if((T=e.markRemoteBaselineReady)==null||T.call(e),QZ(e,i,o),e.emit({kind:"snapshot-applied"}),e.conflictPolicy==="conflict-event")for(let C of u)e.emit({kind:"conflict",conflict:C});e.setState(e.transport.getConnectionState()==="open"?{phase:"idle"}:{phase:"offline"}),e.scheduleFlush()}}}function GN(e,t){if(!e.attachedStore||e.closed||!t.scopedAssetId||!e.transport.fetchAssets)return Promise.resolve(!1);let r=OS(e);return Ef(r,[{assetId:t.scopedAssetId,minimumAssetVersion:t.assetVersion}]),LS(e,r),Promise.resolve(!0)}function zN(e,t){if(!e.attachedStore||e.closed||!e.transport.fetchAssets)return Promise.resolve(!1);let n=OS(e);return Ef(n,[{assetId:t}]),LS(e,n),Promise.resolve(!0)}function UN(e,t){var o;let n=[...new Set(t.map(a=>a.trim()).filter(Boolean))];if(n.length===0)return Promise.resolve();if(!e.attachedStore||e.closed||!e.transport.fetchAssets||(o=e.hasPersistenceWriteFailure)!=null&&o.call(e))return Promise.reject(new Error("Scoped asset refresh is unavailable"));let r=OS(e),i=r.refreshWaiters.waitFor(n);return Ef(r,n.map(a=>({assetId:a}))),LS(e,r),i}function Zn(e,t,n){return!e.closed&&e.attachedStore===t&&e.getAttachmentEpoch()===n}function iee(e,t){return e.closed&&t!==null&&typeof t=="object"&&"name"in t&&t.name==="AbortError"}function VN(e,t){if(e.hasPersistenceWriteFailure())return;let n=e.attachedStore,r=e.getAttachmentEpoch();(async()=>{try{if(!t.scopedAssetId){e.logger.info(`${e.logPrefix} skip invalidate: only scoped asset refresh is supported`);return}await GN(e,t)}catch(i){if(e.hasPersistenceWriteFailure()||e.attachedStore!==n||e.getAttachmentEpoch()!==r)return;e.logger.error(`${e.logPrefix} failed to handle invalidate`,i),e.setState({phase:"error",error:di(i),reason:"remote-sync-failed"})}})()}function qN(e,t){if(!e.hasPersistenceWriteFailure()){if(t==="closed"){e.setState({phase:"offline"});return}e.setState({phase:"idle"}),e.scheduleFlush()}}async function oee(e,t,n){if(e.isOutboundHydrated())return Zn(e,t,n);if(e.readOnly)await e.outbound.replaceAll([]);else{if(await e.waitForCapturedPersistenceWrites(),!Zn(e,t,n))return!1;let r=await e.persistence.loadOutbound();if(!Zn(e,t,n))return!1;let i=new Set(r.map(a=>a.txId)),o=e.outbound.snapshot().filter(a=>!i.has(a.txId));await e.outbound.replaceAll([...r,...o])}return Zn(e,t,n)?(e.markOutboundHydrated(),e.emitOutboundChange(),!0):!1}async function FS(e,t,n){if(!e.isClientIdentityHydrated()){let r=await e.persistence.loadClientId();if(!Zn(e,t,n)||!r&&(await e.runPersistenceMutation(()=>e.persistence.saveClientId(e.transport.clientId)),!Zn(e,t,n)))return!1;e.markClientIdentityHydrated()}if(!e.isLocalSnapshotHydrated()){let r=await e.persistence.loadSnapshot();if(!Zn(e,t,n)||r&&(t.applyRemoteSnapshot(r.state),!Zn(e,t,n)))return!1;e.markLocalSnapshotHydrated()}return oee(e,t,n)}async function KN(e,t,n){var i;let r=e.getAttachmentEpoch();try{if(!await FS(e,t,r)||!Zn(e,t,r))return;await Du(e)}catch(o){Zn(e,t,r)&&!iee(e,o)&&!e.hasPersistenceWriteFailure()&&(e.logger.error(`${e.logPrefix} bootstrap failed`,o),e.setState({phase:"error",error:di(o),reason:"bootstrap-failed"}),e.scheduleRemoteBaselineRetry())}finally{e.getAttachmentEpoch()===r&&e.markBootstrapSettled(),Zn(e,t,r)&&((i=n.onBootstrapSettled)==null||i.call(n))}}var Mf=class{constructor(t){this.options=t;this.listeners=new Set;this.ackSinceSnapshot=0;this.storeUnsubscribe=null;this.invalidateUnsubscribe=null;this.connectionUnsubscribe=null;this.flushTimer=null;this.resyncTimer=null;this.applyingRemoteAssetIds=new Set;this.attachmentEpoch=0;this.bootstrapSettled=!1;this.clientIdentityHydrated=!1;this.localSnapshotHydrated=!1;this.outboundHydrated=!1;this.remoteBaselineRetryDisabled=!1;this.attachedStore=null;this.closed=!1;this.attach=t=>{this.detachListeners(),this.attachmentEpoch+=1,this.attachedStore=t,this.bootstrapSettled=!1,this.clientIdentityHydrated=!1,this.localSnapshotHydrated=!1,this.outboundHydrated=!1,this.remoteBaselineRetryDisabled=!1,this.remoteBaselineGate.reset();let{attachmentEpoch:n}=this;return this.storeUnsubscribe=t.subscribe(({prevState:r,nextState:i,transaction:o})=>{if(this.syncTransportAssetSubscriptions(i),this.syncDiscoveredRemoteAssets(r,i,o.source),this.readOnly||o.source!=="local"||o.forwardPatches.length===0)return;let a=this.outbound.enqueue(o);this.emitOutboundChange(),this.observeOutboundEnvelope(r,a,"local"),this.persistenceWriteBarrier.track(()=>this.persistence.appendOutbound(a),"append-outbound"),this.scheduleFlush()}),this.syncTransportAssetSubscriptions(t.getState()),this.invalidateUnsubscribe=this.transport.onInvalidate(r=>VN(this,r)),this.connectionUnsubscribe=this.transport.onConnectionChange(r=>qN(this,r)),this.bootstrap(t),()=>{this.attachedStore!==t||this.attachmentEpoch!==n||(this.detachListeners(),this.attachmentEpoch+=1,this.attachedStore=null,this.clientIdentityHydrated=!1,this.localSnapshotHydrated=!1,this.outboundHydrated=!1,this.remoteBaselineGate.reset())}};this.getState=()=>this.state;this.subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t)});this.getPendingOutboundCount=()=>this.outbound.size();this.getPendingTransactionIds=()=>this.outbound.snapshot().map(t=>t.txId);this.isBootstrapSettled=()=>this.bootstrapSettled;this.refreshAssets=t=>UN(this,t);this.getAttachmentEpoch=()=>this.attachmentEpoch;this.isClientIdentityHydrated=()=>this.clientIdentityHydrated;this.isLocalSnapshotHydrated=()=>this.localSnapshotHydrated;this.isOutboundHydrated=()=>this.outboundHydrated;this.markBootstrapSettled=()=>{this.bootstrapSettled=!0};this.markClientIdentityHydrated=()=>{this.clientIdentityHydrated=!0};this.markLocalSnapshotHydrated=()=>{this.localSnapshotHydrated=!0};this.markOutboundHydrated=()=>{this.outboundHydrated=!0};this.markRemoteBaselineReady=()=>{this.persistenceWriteBarrier.hasFailed()||this.remoteBaselineGate.markReady()};this.scheduleRemoteBaselineRetry=()=>{this.state.phase==="error"&&this.state.reason==="bootstrap-failed"&&this.state.error.retryable===!1&&(this.remoteBaselineRetryDisabled=!0),!this.persistenceWriteBarrier.hasFailed()&&!this.remoteBaselineRetryDisabled&&this.remoteBaselineGate.schedule()};this.hasPersistenceWriteFailure=()=>this.persistenceWriteBarrier.hasFailed();this.waitForCapturedPersistenceWrites=()=>this.persistenceWriteBarrier.waitForCaptured();this.runPersistenceMutation=t=>this.persistenceWriteBarrier.run(t);this.flush=()=>{this.readOnly||this.scheduleFlush(0)};this.close=()=>{this.closed=!0,this.commitRetryDiagnostics.clear(),this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=null),this.resyncTimer&&(clearTimeout(this.resyncTimer),this.resyncTimer=null),this.detachListeners(),this.transport.close(),this.setState({phase:"offline"})};var n,r,i,o,a,s,c;this.transport=t.transport,this.persistence=t.persistence,this.stateAdapter=t.stateAdapter,this.assetVersions=t.transport.assetVersions??new ni,this.readOnly=!!t.readOnly,this.outbound=Ru({maxBatchSize:(n=t.flush)==null?void 0:n.maxBatchSize,maxBatchPatchCount:(r=t.flush)==null?void 0:r.maxBatchPatchCount}),this.conflictPolicy=t.conflictPolicy??"remote-wins",this.logger=ws(t.logger),this.logPrefix=t.logPrefix??"[pippit-asset-sdk:sync]",this.validateRebasedEnvelope=t.validateRebasedEnvelope,this.scopedAssetFetchDebounceMs=t.scopedAssetFetchDebounceMs??500,this.debounceMs=((i=t.flush)==null?void 0:i.debounceMs)??0,this.retryBaseMs=((o=t.flush)==null?void 0:o.retryBaseMs)??500,this.retryMaxMs=((a=t.flush)==null?void 0:a.retryMaxMs)??3e4,this.maxAttempts=((s=t.flush)==null?void 0:s.maxAttempts)??1/0,this.saveEveryNAcks=((c=t.snapshot)==null?void 0:c.saveEveryNAcks)??50,this.remoteBaselineGate=new If({hasAttachedStore:()=>!!this.attachedStore,isClosed:()=>this.closed,retryBaseMs:this.retryBaseMs,retryMaxMs:this.retryMaxMs,sync:()=>this.syncRemoteBaseline()}),this.persistenceFailureDiagnostics=new Cf({diagnostics:t.diagnostics,logger:this.logger,logPrefix:this.logPrefix}),this.commitRetryDiagnostics=new Sf({diagnostics:t.diagnostics,logger:this.logger,logPrefix:this.logPrefix}),this.persistenceWriteBarrier=new Af((d,u)=>this.handlePersistenceWriteFailure(d,u)),this.state=t.transport.getConnectionState()==="open"?{phase:"idle"}:{phase:"offline"}}emit(t){for(let n of Array.from(this.listeners))n(t)}emitOutboundChange(){this.emit({kind:"outbound-change",pendingOutboundCount:this.outbound.size()})}observeOutboundEnvelope(t,n,r){var i,o;try{(o=(i=this.options).observeOutboundEnvelope)==null||o.call(i,{state:t,envelope:n,phase:r})}catch(a){this.logger.warn(`${this.logPrefix} outbound observer failed`,{error:a instanceof Error?a.message:String(a),phase:r,txId:n.txId})}}withApplyingRemoteAssets(t,n){for(let r of t)this.applyingRemoteAssetIds.add(r);try{n()}finally{for(let r of t)this.applyingRemoteAssetIds.delete(r)}}setState(t){this.persistenceWriteBarrier.hasFailed()&&!(t.phase==="error"&&t.reason==="persistence-failed")&&!(this.closed&&t.phase==="offline")||(this.state=t,this.emit({kind:"state-change",state:t}))}scheduleFlush(t=this.debounceMs){if(!(this.closed||this.readOnly)){if(this.persistenceWriteBarrier.hasFailed()){this.reportPersistenceFlushBlocked("schedule-flush");return}this.flushTimer&&clearTimeout(this.flushTimer),this.flushTimer=setTimeout(()=>{this.flushTimer=null,this.flushNow().catch(n=>{if(this.persistenceWriteBarrier.hasFailed())return;let r=di(n);this.logger.error(`${this.logPrefix} flush failed`,r),this.setState({phase:"error",error:r,reason:"commit-failed"})})},t)}}releaseInflight(){var t,n;(n=(t=this.outbound).releaseInflight)==null||n.call(t)}handlePersistenceWriteFailure(t,n){this.remoteBaselineGate.reset(),this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=null),this.resyncTimer&&(clearTimeout(this.resyncTimer),this.resyncTimer=null),!this.closed&&(this.persistenceFailureDiagnostics.reportFailure(t,n,{pendingTransactionIds:this.getPendingTransactionIds(),syncPhase:this.state.phase}),this.setState({phase:"error",error:t,reason:"persistence-failed"}))}syncTransportAssetSubscriptions(t){!t||!this.transport.syncAssetSubscriptions||this.transport.syncAssetSubscriptions(this.stateAdapter.collectAssetIds(t))}syncDiscoveredRemoteAssets(t,n,r){if(r!=="remote"||!this.bootstrapSettled||!this.transport.fetchAssets)return;let i=new Set(this.stateAdapter.collectAssetIds(t)),o=this.stateAdapter.collectAssetIds(n).filter(a=>!i.has(a)&&!this.applyingRemoteAssetIds.has(a));for(let a of o)zN(this,a)}async flushNow(){var o;if(!this.attachedStore||this.closed||this.readOnly)return;if(this.persistenceWriteBarrier.hasFailed()){this.reportPersistenceFlushBlocked("flush-now");return}if(this.transport.getConnectionState()!=="open"){this.setState({phase:"offline"});return}if(!this.remoteBaselineGate.isReady()){this.bootstrapSettled&&this.scheduleRemoteBaselineRetry();return}try{await this.waitForCapturedPersistenceWrites()}catch{this.reportPersistenceFlushBlocked("flush-now");return}if(!this.attachedStore||this.closed||this.transport.getConnectionState()!=="open"||!this.remoteBaselineGate.isReady()||this.state.phase==="flushing"||this.state.phase==="syncing"||this.state.phase==="rebasing")return;let t=this.outbound.takeNextBatch();if(!t){this.setState({phase:"idle"});return}if(this.observeOutboundBatch(t,"commit"),t.patches.length===0){let a;try{a=await this.removeAckedOutbound(t.txIds)}catch{return}this.emit({kind:"committed",txId:t.txId,ackedTxIds:a}),this.setState({phase:"idle"}),this.scheduleFlush();return}this.setState({phase:"flushing",inflight:t.txId,inflightTxIds:t.txIds});let n=await this.transport.commit(t);if(this.closed||this.persistenceWriteBarrier.hasFailed())return;if(n.status==="ack"){try{await this.handleAck(t,n.ackedTxIds)}catch{return}return}if(n.status==="reject"){try{await this.handleCommitReject(t,n.ackedTxIds,n.error)}catch{return}return}if(n.retryable===!1){try{await this.removeAckedOutbound(t.txIds)}catch{return}this.logger.error(`${this.logPrefix} non-retryable commit failed`,n.error,{txIds:t.txIds,attempt:t.attempt}),this.setState({phase:"error",error:n.error,reason:"commit-failed"});return}let r=[];if((o=n.ackedTxIds)!=null&&o.length)try{r=await this.acknowledgeConfirmedTransactions(n.ackedTxIds)}catch{return}if(n.requiresResync?this.commitRetryDiagnostics.forget(t.txIds):this.commitRetryDiagnostics.reportFailure(n.error,{acknowledgedTransactionIds:r,syncPhase:this.state.phase,transactions:t.envelopes}),this.releaseInflight(),t.attempt>=this.maxAttempts){this.logger.error(`${this.logPrefix} commit retry attempts exhausted`,n.error,{txIds:t.txIds,attempt:t.attempt,maxAttempts:this.maxAttempts}),this.setState({phase:"error",error:n.error,reason:"commit-failed"});return}let i=Math.min(this.retryMaxMs,this.retryBaseMs*2**Math.max(0,t.attempt-1));if(n.requiresResync){this.logger.warn(`${this.logPrefix} commit requires remote resync`,{txIds:t.txIds,ackedTxIds:n.ackedTxIds,attempt:t.attempt,delay:i}),this.setState({phase:"idle"}),this.scheduleResync(i);return}this.setState({phase:"idle"}),this.scheduleFlush(i)}scheduleResync(t){this.closed||this.readOnly||this.persistenceWriteBarrier.hasFailed()||this.resyncTimer||(this.resyncTimer=setTimeout(()=>{this.resyncTimer=null,this.resyncNow()},t))}async resyncNow(){let{attachedStore:t,attachmentEpoch:n}=this;if(!(!t||this.closed||this.readOnly||this.persistenceWriteBarrier.hasFailed())){if(this.state.phase==="flushing"||this.state.phase==="syncing"||this.state.phase==="rebasing"){this.scheduleResync(this.retryBaseMs);return}try{await Du(this)}catch(r){if(this.persistenceWriteBarrier.hasFailed()||this.attachedStore!==t||this.attachmentEpoch!==n)return;this.logger.error(`${this.logPrefix} resync after blocked commit failed`,r),this.setState({phase:"error",error:di(r),reason:"remote-sync-failed"}),this.scheduleResync(this.retryMaxMs)}}}async syncRemoteBaseline(){let{attachedStore:t,attachmentEpoch:n}=this;if(!t||this.closed)return!1;if(this.persistenceWriteBarrier.hasFailed())return!0;if(this.state.phase==="flushing"||this.state.phase==="syncing"||this.state.phase==="rebasing")return!1;try{return!await FS(this,t,n)||this.attachedStore!==t||this.attachmentEpoch!==n||(await Du(this),this.attachedStore!==t||this.attachmentEpoch!==n)?!0:this.remoteBaselineGate.isReady()}catch(r){return this.closed?!1:this.persistenceWriteBarrier.hasFailed()||this.attachedStore!==t||this.attachmentEpoch!==n?!0:(this.logger.error(`${this.logPrefix} remote baseline retry failed`,r),this.setState({phase:"error",error:di(r),reason:"remote-sync-failed"}),!1)}}async handleCommitReject(t,n,r){let i=n!=null&&n.length?await this.acknowledgeConfirmedTransactions(n):[],o=new Set(i),a=t.txIds.filter(c=>!o.has(c));a.length>0&&await this.removeAckedOutbound(a);let s=r??new Error(`Asset sync commit rejected for transaction ${t.txId}`);this.logger.error(`${this.logPrefix} commit rejected`,s,{txIds:t.txIds,ackedTxIds:i,rejectedTxIds:a}),this.setState({phase:"error",error:s,reason:"commit-rejected"})}async acknowledgeConfirmedTransactions(t){let n=await this.removeAckedOutbound(t);return n.length>0&&(this.ackSinceSnapshot+=n.length,this.emit({kind:"committed",txId:n[0],ackedTxIds:n})),n}async handleAck(t,n){let r=await this.removeAckedOutbound(n!=null&&n.length?n:t.txIds);if(this.ackSinceSnapshot+=Math.max(1,r.length),this.emit({kind:"committed",txId:t.txId,ackedTxIds:r}),this.ackSinceSnapshot>=this.saveEveryNAcks&&this.attachedStore){this.ackSinceSnapshot=0;let i=this.attachedStore.getState();await this.persistenceWriteBarrier.run(()=>this.persistence.saveSnapshot({state:i}),"save-snapshot")}this.setState({phase:"idle"}),this.scheduleFlush()}async removeAckedOutbound(t){let n=new Set(Array.isArray(t)?t:[t]),r=this.outbound.snapshot().filter(o=>n.has(o.txId)).map(o=>o.txId);for(let o of r)await this.persistenceWriteBarrier.run(()=>this.persistence.removeOutbound(o),"remove-outbound");let i=await this.outbound.ack(r);return this.commitRetryDiagnostics.forget(i),this.emitOutboundChange(),i}observeOutboundBatch(t,n){var i;let r=(i=this.attachedStore)==null?void 0:i.getState();if(!(!r||!this.options.observeOutboundEnvelope))for(let o of t.envelopes)this.observeOutboundEnvelope(r,o,n)}reportPersistenceFlushBlocked(t){this.persistenceFailureDiagnostics.reportFlushBlocked(t,{pendingTransactionIds:this.getPendingTransactionIds(),syncPhase:this.state.phase})}async bootstrap(t){await KN(this,t,this.options)}detachListeners(){var t,n,r;BN(this),this.remoteBaselineGate.dispose(),(t=this.storeUnsubscribe)==null||t.call(this),(n=this.invalidateUnsubscribe)==null||n.call(this),(r=this.connectionUnsubscribe)==null||r.call(this),this.storeUnsubscribe=null,this.invalidateUnsubscribe=null,this.connectionUnsubscribe=null}};function Aa(e){return new Mf(e)}function BS(){let e=null,t=[];return{loadClientId:()=>Promise.resolve(e),saveClientId:n=>(e=n,Promise.resolve()),loadSnapshot:()=>Promise.resolve(null),saveSnapshot:()=>Promise.resolve(),loadOutbound:()=>Promise.resolve(t.slice()),appendOutbound:n=>(t=[...t.filter(r=>r.txId!==n.txId),n],Promise.resolve()),removeOutbound:n=>(t=t.filter(r=>r.txId!==n),Promise.resolve()),replaceOutbound:n=>(t=n.slice(),Promise.resolve()),replaceOutboundPartition:(n,r)=>{let i=new Set(r);return t=[...n,...t.filter(o=>!i.has(o.txId))],Promise.resolve()},clear:()=>(t=[],Promise.resolve())}}hr();function GS(e,t){return yr(e,ba(t))}var zS=e=>e==="committed"||e==="discarded"||e==="failed",see=e=>e instanceof Error?e:new Error(String(e)),US=class{constructor(t){this.snapshots=new Map;this.listeners=new Map;this.closed=!1;this.getSnapshot=t=>this.snapshots.get(t);this.subscribe=(t,n)=>{let r=this.listeners.get(t)??new Set;return r.add(n),this.listeners.set(t,r),()=>{r.delete(n),r.size===0&&this.listeners.delete(t)}};this.wait=(t,n={})=>{let r=this.snapshots.get(t);return r?r.phase==="committed"?Promise.resolve({transactionId:t}):r.phase==="discarded"||r.phase==="failed"?Promise.reject(this.toTerminalError(r)):new Promise((i,o)=>{var p,m;let a,s=()=>{},c=()=>{},d=()=>{var f;s(),(f=n.signal)==null||f.removeEventListener("abort",c),a&&clearTimeout(a)},u=()=>{let f=this.snapshots.get(t);!f||!zS(f.phase)||(d(),f.phase==="committed"?i({transactionId:t}):o(this.toTerminalError(f)))};if(c=()=>{var f;d(),o(((f=n.signal)==null?void 0:f.reason)??new DOMException("Aborted","AbortError"))},s=this.subscribe(t,u),(p=n.signal)!=null&&p.aborted){c();return}(m=n.signal)==null||m.addEventListener("abort",c,{once:!0}),(n.timeoutMs??0)>0&&(a=setTimeout(()=>{d(),o(new Error(`Asset sync transaction timed out: ${t}`))},n.timeoutMs))}):Promise.reject(new Error(`Asset sync transaction is not tracked: ${t}`))};this.registerPending=t=>{for(let n of t)this.snapshots.has(n)||this.update({transactionId:n,phase:"queued",updatedAt:Date.now()})};this.close=()=>{if(this.closed)return;this.closed=!0,this.unsubscribeStore(),this.unsubscribeEngine();let t=new Error("Asset sync transaction tracker is closed");this._updatePendingSnapshots(n=>({...n,phase:"failed",error:t,updatedAt:Date.now()})),this.listeners.clear()};this.handleSyncEvent=t=>{var n,r;if(t.kind==="committed"){((n=t.ackedTxIds)!=null&&n.length?t.ackedTxIds:[t.txId]).forEach(o=>{this.updateFromExisting(o,{phase:"committed"})});return}if(t.kind==="discarded"){t.txIds.forEach(i=>{this.updateFromExisting(i,{phase:"discarded",discardReason:t.reason})});return}if(t.kind==="state-change"){if(t.state.phase==="flushing"){((r=t.state.inflightTxIds)!=null&&r.length?t.state.inflightTxIds:[t.state.inflight]).forEach(o=>{this.updateFromExisting(o,{phase:"in-flight"})});return}if(t.state.phase==="rebasing"){this.updatePendingPhase("rebasing");return}t.state.phase==="error"&&(t.state.reason==="commit-rejected"||t.state.reason==="commit-failed")&&this.failPending(t.state.error)}};this.maxRecords=Math.max(1,t.maxRecords??1e3),this.unsubscribeStore=t.store.subscribe(({transaction:n})=>{n.source!=="local"||n.forwardPatches.length===0||this.update({transactionId:n.id,phase:"queued",intent:n.intent,mergeKey:n.mergeKey,updatedAt:Date.now()})}),this.unsubscribeEngine=t.engine.subscribe(this.handleSyncEvent)}updatePendingPhase(t){this._updatePendingSnapshots(n=>({...n,phase:t,updatedAt:Date.now()}))}failPending(t){let n=see(t);this._updatePendingSnapshots(r=>({...r,phase:"failed",error:n,updatedAt:Date.now()}))}_updatePendingSnapshots(t){let n=Array.from(this.snapshots.keys());for(let r of n){let i=this.snapshots.get(r);!i||zS(i.phase)||this.update(t(i))}}updateFromExisting(t,n){let r=this.snapshots.get(t);this.update({transactionId:t,phase:(r==null?void 0:r.phase)??"queued",...r,...n,updatedAt:Date.now()})}update(t){this.snapshots.delete(t.transactionId),this.snapshots.set(t.transactionId,t);for(let n of Array.from(this.listeners.get(t.transactionId)??[]))n();this.prune()}prune(){if(!(this.snapshots.size<=this.maxRecords)){for(let[t,n]of this.snapshots)if(zS(n.phase)&&!this.listeners.has(t)&&(this.snapshots.delete(t),this.snapshots.size<=this.maxRecords))return}}toTerminalError(t){return t.error?t.error:t.phase==="discarded"?new Error(`Asset sync transaction was discarded: ${t.transactionId} (${t.discardReason??"unknown"})`):new Error(`Asset sync transaction failed: ${t.transactionId}`)}};function Nf(e){return new US(e)}function VS(e){return rS(e)}function pee(e,t){for(let n of Object.values(e.assets))if(Nn(n)){for(let r of Object.values(n.content.nodes))if(VS(r)===t)return r.type}}function wf(e,t){let n=e.assets[t],r=pee(e,t);return{assetId:t,assetKind:n&&Nn(n)?"canvas":"node",...r?{nodeType:r}:{}}}function kf(e,t){let n={...e.assets};for(let r of t)r.asset&&(n[r.assetId]=r.asset);return{...e,assets:n}}function Of(e,t){if(typeof t!="string")return;let n=t.trim();n&&e.add(n)}function Lf(e){let t=new Set;Of(t,e.rootCanvasId);for(let[n,r]of Object.entries(e.assets))if(Of(t,n),Of(t,r==null?void 0:r.pippitAssetId),!!Nn(r))for(let i of Object.values(r.content.nodes)){let o=VS(i);o!=null&&o.includes("::")||Of(t,o)}return[...t]}var lee={collectAssetIds:Lf,createRemoteAssetRequest:wf,mergeRemoteAssets:kf};function mee(e,t){return{...e,assetVersions:e.assetVersions,fetchSnapshot:async()=>({state:(await e.fetchSnapshot({onProgress:r=>{try{r.kind==="root-ready"?t({kind:"bootstrap-root-ready",document:r.document}):r.kind==="assets-ready"?t({kind:"bootstrap-assets-ready",document:r.document,readyAssetIds:r.readyAssetIds}):t({kind:"bootstrap-assets-settled",document:r.document})}catch(i){pt.warn("[canvas-sdk:sync] bootstrap progress observer failed",{error:i instanceof Error?i.message:String(i),kind:r.kind})}}})).document})}}function fee(e){return{...e,replaceOutboundPartition:e.replaceOutboundPartition,loadSnapshot:async()=>{let t=await e.loadSnapshot();return t?{state:t.document}:null},saveSnapshot:({state:t})=>e.saveSnapshot({document:t})}}function qS(e){let t=new Set,n=o=>{for(let a of Array.from(t))a(o)},r=Aa({...e,transport:mee(e.transport,n),persistence:fee(e.persistence),stateAdapter:e.stateAdapter??lee,observeOutboundEnvelope:e.observeOutboundEnvelope?({state:o,envelope:a,phase:s})=>{var c;return(c=e.observeOutboundEnvelope)==null?void 0:c.call(e,{document:o,envelope:a,phase:s})}:void 0,validateRebasedEnvelope:e.validateRebasedEnvelope?({envelope:o,nextState:a,previousState:s})=>{var c;return(c=e.validateRebasedEnvelope)==null?void 0:c.call(e,{envelope:o,nextDocument:a,previousDocument:s})}:void 0,logger:pt,logPrefix:"[canvas-sdk:sync]"}),i=r.subscribe(o=>n(o));return{attach:o=>r.attach(o),getState:r.getState,subscribe:o=>(t.add(o),()=>t.delete(o)),getPendingOutboundCount:()=>{var o;return((o=r.getPendingOutboundCount)==null?void 0:o.call(r))??0},flush:r.flush,refreshAssets:r.refreshAssets,close:()=>{r.close(),i(),t.clear()}}}var jN=new WeakMap;function hee(e){return{txId:e.id,patches:Ca(e.forwardPatches),intent:e.intent,mergeKey:e.mergeKey,attempt:0,enqueuedAt:Date.now(),status:"pending"}}function HN(e,t,n){e.pendingEnvelopes.get(t)===n&&e.pendingEnvelopes.delete(t),e.pendingEnvelopes.size===0&&(e.captureFailure=void 0,e.failedPersistence=void 0)}function $N(e,t,n,r){e.captureFailure=r,e.failedPersistence=t,pt.error("[canvas-sdk:sync] failed to persist a transaction between sync engines",r,{txId:n})}function gee(e,t){let n,r=e.captureTail.then(async()=>{n=e.persistence,await n.appendOutbound(t),HN(e,t.txId,t)});e.captureTail=r.then(()=>{},i=>$N(e,n,t.txId,i))}function yee(e){if(e.pendingEnvelopes.size===0||e.failedPersistence===e.persistence)return;let t,n,r=e.captureTail.then(async()=>{t=e.persistence;for(let[i,o]of Array.from(e.pendingEnvelopes.entries()))n=i,await t.appendOutbound(o),HN(e,i,o)});e.captureTail=r.then(()=>{},i=>$N(e,t,n??"unknown",i))}function _ee(e,t){if(!e.captureEnabled||e.liveEngineTokens.size>0||t.source!=="local"||t.forwardPatches.length===0)return;let n=hee(t);e.pendingEnvelopes.set(n.txId,n),gee(e,n)}function Tee(e,t,n){let r={captureEnabled:n,captureTail:Promise.resolve(),liveEngineTokens:new Set,pendingEnvelopes:new Map,persistence:t};return e.subscribe(({transaction:i})=>_ee(r,i)),r}function YN(e,t,n){let r=jN.get(e)??Tee(e,t,n);jN.set(e,r),r.persistence=t,r.captureEnabled=n;let i={};return{activateEngine:()=>r.liveEngineTokens.add(i),deactivateEngine:()=>r.liveEngineTokens.delete(i),waitForCaptures:async()=>{for(;;){let o=r.captureTail;if(await o,o===r.captureTail&&(yee(r),o===r.captureTail))break}if(r.pendingEnvelopes.size>0)throw r.captureFailure??new Error("Canvas outbound journal is not durable")}}}var Ff=new WeakMap;function Bf(){return`client_${typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`}async function See(e,t,n){var d,u;let r=await e.persistence.loadClientId(),i=r??((d=e.createClientId)==null?void 0:d.call(e))??Bf();if(r||await e.persistence.saveClientId(i),n.isDisposed()||(await t.waitForCaptures(),n.isDisposed()))return;let o=e.transportFactory({canvasId:e.canvasId,clientId:i});try{await t.waitForCaptures()}catch(p){throw o.close(),p}if(n.isDisposed()){o.close();return}let a=qS({...e.sync??{},transport:o,persistence:e.persistence}),s=e.onSyncEvent?a.subscribe(e.onSyncEvent):void 0,c;try{c=a.attach(e.syncStore??e.store)}catch(p){throw s==null||s(),a.close(),p}if(n.isDisposed()){s==null||s(),c(),a.close();return}t.activateEngine();try{(u=e.onAttached)==null||u.call(e,a)}catch(p){throw t.deactivateEngine(),s==null||s(),c(),a.close(),p}n.onAttached(a,()=>{t.deactivateEngine(),s==null||s(),c()})}function bee(e){return e instanceof Error?e:new Error(String(e))}function KS(e){var c;let t=YN(e.store,e.persistence,((c=e.sync)==null?void 0:c.readOnly)!==!0),n={},r=!1,i,o,a=()=>{let d=Ff.get(e.store);(d==null?void 0:d.token)===n&&Ff.delete(e.store),r=!0,i==null||i(),o==null||o.close(),i=void 0,o=void 0},s=Ff.get(e.store);return Ff.set(e.store,{dispose:a,token:n}),s==null||s.dispose(),r||See(e,t,{isDisposed:()=>r,onAttached:(d,u)=>{o=d,i=u,r&&a()}}).catch(d=>{var u;r||(pt.error("[canvas-sdk:sync] failed to attach sync engine",d),(u=e.onError)==null||u.call(e,bee(d)))}),a}function Eu(e,t){let n=new Set,r=new Set;for(let i of e){for(let o of i.rootReferenceKeys??[])r.add(o);for(let o of t)for(let a of i.getAssetIds(o))n.add(a)}return{assetIds:n,rootReferenceKeys:r}}function XN(e,t,n){if(n.assetIds.has(e.assetId))return!0;if(e.assetId!==t||!e.path.startsWith("/extra/"))return!1;let r=e.path.slice(7);return!r.includes("/")&&n.rootReferenceKeys.has(r.replaceAll("~1","/").replaceAll("~0","~"))}function jS(e,t,n){return qs(e,r=>{var a,s;for(let c of n.assetIds)t.assets[c]?r.assets[c]=t.assets[c]:delete r.assets[c];let i=(a=t.assets[t.rootCanvasId])==null?void 0:a.extra,o=(s=r.assets[r.rootCanvasId])==null?void 0:s.extra;if(!(!Pe(i)||!Pe(o)))for(let c of n.rootReferenceKeys)Object.hasOwn(i,c)?o[c]=i[c]:delete o[c]})}function WN(e){let{store:t,stateAdapter:n}=e,r=new Map,i=new Map,o=[],a=!1,s=u=>u?[r.get(u)]:[...r.values()],c=u=>{let p=m=>{let f=t.getState(),h=Eu(s(u),[f,m]);return u?jS(f,m,h):jS(m,f,h)};return{getState:t.getState,subscribe:m=>t.subscribe(f=>{let h=Eu(s(u),[f.prevState,f.nextState]),g=_=>XN(_,f.nextState.rootCanvasId,h)===!!u,y=f.transaction.forwardPatches.filter(g);y.length&&m({...f,transaction:{...f.transaction,forwardPatches:y,reversePatches:f.transaction.reversePatches.filter(g)}})}),applyRemoteSnapshot:(m,f)=>t.applyRemoteSnapshot(p(m),f),applyRemotePatches:(m,f)=>t.applyRemoteSnapshot(p(GS(t.getState(),m)),f)}},d=u=>({...n,collectAssetIds:p=>{let m=Eu(s(u),[p]);return u?[...m.assetIds,...m.rootReferenceKeys.size?[p.rootCanvasId]:[]]:n.collectAssetIds(p).filter(f=>!m.assetIds.has(f))}});return{getChannel:u=>i.get(u),primaryStore:c(),primaryStateAdapter:d(),open(u,p,m){var G;if(a)throw new Error("Asset save manager is closed");let f=i.get(u);if(f)return f;if(!u)throw new Error("Asset save channel needs a stable key");let h=t.getState(),g=Eu([...r.values()],[h]);if(p.getAssetIds(h).some(O=>g.assetIds.has(O))||(G=p.rootReferenceKeys)!=null&&G.some(O=>g.rootReferenceKeys.has(O)))throw new Error("Canvas save asset already belongs to another channel");r.set(u,p);let y=c(u),_=new Set,S=O=>{var H;let K=O.getState();if(!(!((H=O.isBootstrapSettled)!=null&&H.call(O))&&K.phase!=="error")){for(let U of _)K.phase==="error"?U.reject(K.error):U.resolve();_.clear()}},T=Aa({...m,persistence:BS(),stateAdapter:d(u),onBootstrapSettled:()=>{var O;(O=m.onBootstrapSettled)==null||O.call(m),S(T)}}),C=Nf({engine:T,store:y}),I=T.subscribe(()=>S(T)),x=T.attach(y),R={engine:T,transactions:C,whenReady:()=>new Promise((O,K)=>{if(a){K(new Error("Asset save manager is closed"));return}_.add({resolve:O,reject:K}),S(T)})};return i.set(u,R),o.push(()=>{I(),x(),C.close(),T.close();for(let O of _)O.reject(new Error("Asset save manager is closed"));_.clear()}),R},close(){if(!a){a=!0;for(let u of o.reverse())u();i.clear(),r.clear()}}}}var Gf=new WeakMap;function Cee(e){let{store:t}=e,n=WN({store:t,stateAdapter:{collectAssetIds:Lf,createRemoteAssetRequest:wf,mergeRemoteAssets:kf}});return{primaryStore:{...t,...n.primaryStore},primaryStateAdapter:n.primaryStateAdapter,open(r,i){var d,u;let o=n.getChannel(r);if(o)return o;let a=e.transportFactory({canvasId:t.getState().rootCanvasId,clientId:Bf()}),s=async()=>{var y,_;if(!a.fetchAssets)return{state:(await a.fetchSnapshot()).document};let p=t.getState(),f=[...new Set([...i.getAssetIds(p),...(y=i.rootReferenceKeys)!=null&&y.length?[p.rootCanvasId]:[]])].map(S=>({assetId:S,assetKind:S===p.rootCanvasId?"canvas":"node"})),h=await a.fetchAssets(f),g={...p.assets};for(let S of h.assets)S.asset?g[S.assetId]=S.asset:delete g[S.assetId],(_=a.assetVersions)==null||_.remember(S.assetId,S.assetVersion);return{state:{...p,assets:g}}},{sync:c}=e;try{return n.open(r,i,{transport:{clientId:a.clientId,assetVersions:a.assetVersions,commit:p=>a.commit(p),fetchSnapshot:s,fetchAssets:(d=a.fetchAssets)==null?void 0:d.bind(a),onInvalidate:p=>a.onInvalidate(p),onConnectionChange:p=>a.onConnectionChange(p),getConnectionState:()=>a.getConnectionState(),syncAssetSubscriptions:(u=a.syncAssetSubscriptions)==null?void 0:u.bind(a),close:()=>a.close()},readOnly:c==null?void 0:c.readOnly,conflictPolicy:c==null?void 0:c.conflictPolicy,diagnostics:c==null?void 0:c.diagnostics,flush:{...c==null?void 0:c.flush,debounceMs:0},validateRebasedEnvelope:c!=null&&c.validateRebasedEnvelope?({envelope:p,previousState:m,nextState:f})=>{var h;return(h=c.validateRebasedEnvelope)==null?void 0:h.call(c,{envelope:p,previousDocument:m,nextDocument:f})}:void 0})}catch(p){throw a.close(),p}},close:n.close}}function Aee(e){var n;(n=Gf.get(e.store))==null||n.close();let t=Cee(e);return Gf.set(e.store,t),{...t,close:()=>{Gf.get(e.store)===t&&Gf.delete(e.store),t.close()}}}function HS(e){let t=Aee(e),n=KS({...e,syncStore:t.primaryStore,sync:{...e.sync,stateAdapter:t.primaryStateAdapter}});return()=>{n(),t.close()}}var Iee="__xyq_idb_success_debug__";function JN(){return globalThis}function vee(){var t;let e=JN();try{return((t=e.localStorage)==null?void 0:t.getItem(Iee))==="1"}catch{return!1}}function Ia(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}function Fn(e){var t;if(e==null)return{type:String(e)};if(typeof e=="string")return{type:"string",length:e.length};if(typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer)return{type:"ArrayBuffer",byteLength:e.byteLength};if(typeof Blob<"u"&&e instanceof Blob)return{type:"Blob",size:e.size};if(Array.isArray(e)){let n=0,r={};for(let i of e){if(!i||typeof i!="object")continue;let o=i;Array.isArray(o.patches)&&(n+=o.patches.length),o.status&&(r[o.status]=(r[o.status]??0)+1)}return{type:"Array",length:e.length,patchCount:n,statusCounts:r}}if(typeof e=="object"){let n=e;return{type:((t=e.constructor)==null?void 0:t.name)??"Object",keyCount:Object.keys(n).length,txId:n.txId,status:n.status,patchCount:Array.isArray(n.patches)?n.patches.length:void 0}}return{type:typeof e}}function so(e,t,n){if(!vee())return;let r=n===void 0?void 0:Math.round((Ia()-n)*10)/10;JN().console.info("[xyq-idb-success]",e,{...t,...r===void 0?{}:{elapsedMs:r}})}var ZN="canvas-sync",ew="outbound",xee="clientId",zf=new Map,Mu=new Map,Nu=new Map;function nc(e,t,n=!1){let i=(Mu.get(e)??Promise.resolve()).then(t,t).catch(a=>{throw n&&!Nu.has(e)&&Nu.set(e,a),a}),o=i.then(()=>{},()=>{});return Mu.set(e,o),o.then(()=>{Mu.get(e)===o&&Mu.delete(e)}),i}async function QN(e,t=!1){if(await Mu.get(e),t&&Nu.has(e))throw Nu.get(e)}function Ree(e){if(typeof indexedDB>"u")return Promise.resolve(null);let t=e.dbName??ZN,n=e.storeName??ew;return new Promise(r=>{let i=Ia(),o=indexedDB.open(t,1);o.onupgradeneeded=()=>{let a=o.result;a.objectStoreNames.contains(n)||a.createObjectStore(n)},o.onsuccess=()=>{so("canvas.open",{dbName:t,storeName:n},i),r(o.result)},o.onerror=()=>r(null),o.onblocked=()=>r(null)})}function Pee(e,t,n){return new Promise((r,i)=>{let o=Ia(),a=e.transaction(t,"readonly").objectStore(t).get(n);a.onsuccess=()=>{so("canvas.get",{dbName:e.name,storeName:t,key:n,result:Fn(a.result)},o),r(a.result)},a.onerror=()=>i(a.error)})}function Dee(e,t,n,r){return new Promise((i,o)=>{let a=Ia(),s=e.transaction(t,"readwrite"),c=s.objectStore(t),d=c.get(n),u,p;d.onsuccess=()=>{let m=d.result;try{let f=r(m);p={after:f,before:m},f===void 0?c.delete(n):c.put(f,n)}catch(f){u=f,s.abort()}},s.oncomplete=()=>{so("canvas.mutate",{dbName:e.name,storeName:t,key:n,before:Fn(p==null?void 0:p.before),after:Fn(p==null?void 0:p.after)},a),i(p??{after:void 0,before:void 0})},s.onerror=()=>o(u??s.error??new Error("IndexedDB mutation failed")),s.onabort=()=>o(u??s.error??new Error("IndexedDB mutation aborted"))})}function tw(e){return{...e,patches:e.patches.map(t=>({...t})),status:e.status==="in-flight"?"pending":e.status}}function rc(e){return e.map(tw)}function $S(e,t={}){let n=t.dbName??ZN,r=t.storeName??ew,i=Ree(t),o=`outbound:${e}`,a=t.clientIdKey??xee,s=f=>`${n}\0${r}\0${f}`,c=s(o),d=s(a),u=async f=>{let h=await i;return h?Pee(h,r,f):zf.get(s(f))},p=async(f,h)=>{let g=await i;if(!g){let y=s(f),_=zf.get(y),S=h(_);return S===void 0?zf.delete(y):zf.set(y,S),{after:S,before:_}}return Dee(g,r,f,h)};return{async loadClientId(){return await QN(d),await u(a)??null},async saveClientId(f){await nc(d,()=>p(a,()=>f).then(()=>{}))},loadSnapshot(){return Promise.resolve(null)},async saveSnapshot(){},loadOutbound:async()=>(await QN(c,!0),rc(await u(o)??[])),async appendOutbound(f){await nc(c,async()=>{let h=Ia(),g=await p(o,y=>[...rc(y??[]).filter(S=>S.txId!==f.txId),tw(f)]);so("canvas.appendOutbound.plan",{key:o,txId:f.txId,env:Fn(f),before:Fn(g.before),after:Fn(g.after)},h)},!0)},async removeOutbound(f){await nc(c,async()=>{let h=Ia(),g=await p(o,y=>rc(y??[]).filter(_=>_.txId!==f));so("canvas.removeOutbound.plan",{key:o,txId:f,before:Fn(g.before),after:Fn(g.after)},h)},!0)},async replaceOutboundPartition(f,h){await nc(c,async()=>{let g=rc(f),y=new Set(h),_=new Set(g.map(T=>T.txId)),S=await p(o,T=>{let C=rc(T??[]).filter(I=>!y.has(I.txId)&&!_.has(I.txId));return[...g,...C]});so("canvas.replaceOutboundPartition.plan",{key:o,capturedTxIds:[...h],before:Fn(S.before),after:Fn(S.after)})},!0)},async replaceOutbound(f){await nc(c,async()=>{let h=rc(f);so("canvas.replaceOutbound.plan",{key:o,value:Fn(h)}),await p(o,()=>h)},!0)},async clear(){await nc(c,()=>p(o,()=>{}).then(()=>{}),!0),Nu.delete(c)}}}function Uf(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Eee(e){if(!Uf(e))throw new Error("Mutation must be an object");return e}function Mee(e){throw new Error(`Unsupported canvas mutation kind: ${String(e)}`)}function Nee(e,t,n){if(typeof t!="number"||!Number.isSafeInteger(t)||t<0)throw new Error(`Invalid array index for op ${n.op} at ${n.path}: ${String(t)}`);if(!(n.op==="add"?t<=e.length:t<e.length))throw new Error(`Array index out of bounds for op ${n.op} at ${n.path}: ${t}`);return t}function wee(e,t,n){if(!e||typeof e!="object")throw new Error(`Cannot apply patch at ${n.path}`);if(Array.isArray(e)){let i=Nee(e,t,n);if(n.op==="remove"){e.splice(i,1);return}if(!("value"in n)||n.value===void 0)throw new Error(`Patch value is required for op ${n.op} at ${n.path}`);if(n.op==="add"){e.splice(i,0,n.value);return}e[i]=n.value;return}let r=e;if(n.op==="remove"){delete r[String(t)];return}if(!("value"in n)||n.value===void 0)throw new Error(`Patch value is required for op ${n.op} at ${n.path}`);r[String(t)]=n.value}function kee(e,t){let n=e,r=t;for(let i of Object.keys(n))i in r||delete n[i];for(let[i,o]of Object.entries(r))n[i]=o}function Oee(e,t){if(t.op!=="remove"&&(!("value"in t)||t.value===void 0))throw new Error(`Patch value is required for op ${t.op} at ${t.path}`);if(t.path===""){if(t.op==="remove"){if(t.assetId===e.rootCanvasId)throw new Error(`Cannot remove root canvas asset: ${t.assetId}`);if(!Object.prototype.hasOwnProperty.call(e.assets,t.assetId))throw new Error(`Unknown patch target asset: ${t.assetId}`);delete e.assets[t.assetId];return}let a=t.value;if(!Uf(a)||a.pippitAssetId!==t.assetId)throw new Error(`Invalid asset payload for ${t.assetId}`);let s=e.assets[t.assetId];if(!s){ec(e,t.assetId,a);return}kee(s,a);return}let n=e.assets[t.assetId];if(!n)throw new Error(`Unknown patch target asset: ${t.assetId}`);let r=CS(t.path),i=n;for(let a=0;a<r.length-1;a+=1){let s=r[a];if(!i||typeof i!="object")throw new Error(`Cannot apply patch at ${t.path}`);i=i[String(s)]}let o=r[r.length-1];if(o===void 0)throw new Error(`Invalid patch path: ${t.path}`);wee(i,o,t)}function Lee(e,t,n){return e.store.transact(r=>{let i=r.assets[t.assetId];if(!i)throw new Error(`Unknown asset: ${t.assetId}`);t.contentPatch&&Uf(i.content)?Object.assign(i.content,t.contentPatch):t.contentPatch&&(i.content=t.contentPatch),t.extraPatch&&Uf(i.extra)?Object.assign(i.extra,t.extraPatch):t.extraPatch&&(i.extra=t.extraPatch)},{intent:n})}function Fee(e,t,n){return e.store.transact(r=>{for(let i of t.patches)Oee(r,i)},{intent:n})}function Bee(e,t,n,r){var o,a;let i;switch(t.kind){case"set_title":i=e.store.commands.setTitle(t.title);break;case"set_cover":i=e.store.commands.setCover(t.cover);break;case"set_global_bounds":i=e.store.commands.setGlobalBounds(t.bounds);break;case"create_node":i=e.store.commands.createNode(t.node,{assets:t.assets,autoCreateNodeAsset:t.autoCreateNodeAsset});break;case"delete_nodes":i=e.store.commands.deleteNodes(t.ids);break;case"update_node_data":i=e.store.commands.updateNodeData(t.id,t.patch);break;case"set_node_style":i=e.store.commands.setNodeStyle(t.id,t.style);break;case"update_asset":i=Lee(e,t,n);break;case"move_nodes":i=e.store.commands.moveNodes(t.ids,t.delta);break;case"resize_node":i=e.store.commands.resizeNode(t.id,t.size);break;case"set_node_position":i=e.store.commands.setNodePosition(t.id,t.position);break;case"align_nodes":i=e.store.commands.alignNodes(t.ids,t.direction);break;case"distribute_nodes":i=e.store.commands.distributeNodes(t.ids,t.axis);break;case"arrange_nodes":i=e.store.commands.arrangeNodes(t.ids,t.layout,t.options);break;case"auto_layout_nodes":i=e.store.commands.autoLayoutNodes(t.options);break;case"group_nodes":i=e.store.commands.group(t.ids);break;case"ungroup":i=e.store.commands.ungroup(t.groupId);break;case"reparent":i=e.store.commands.reparent(t.nodeId,t.newParentId,t.index);break;case"reorder_children":i=e.store.commands.reorderChildren(t.groupId,t.orderedChildren);break;case"set_group_collapsed":i=e.store.commands.setGroupCollapsed(t.groupId,t.collapsed);break;case"create_edge":i=e.store.commands.createEdge(t.edge);break;case"delete_edges":i=e.store.commands.deleteEdges(t.ids);break;case"reconnect_edge":i=e.store.commands.reconnectEdge(t.id,t.patch);break;case"update_edge_data":i=e.store.commands.updateEdgeData(t.id,t.patch);break;case"update_snap_settings":i=e.store.commands.updateSnapSettings(t.patch);break;case"set_snap_enabled":i=e.store.commands.setSnapEnabled(t.enabled);break;case"set_auto_layout_strategy":i=e.store.commands.setAutoLayoutStrategy(t.strategy);break;case"invoke_command":i=e.store.commands.invoke(t.name,...t.args??[]);break;case"delete":(o=t.edgeIds)!=null&&o.length&&r(e.store.commands.deleteEdges(t.edgeIds)),(a=t.nodeIds)!=null&&a.length&&r(e.store.commands.deleteNodes(t.nodeIds));return;case"apply_patches":i=Fee(e,t,n);break;default:Mee(t)}r(i)}function va({atomic:e,dryRun:t,expectedRevision:n,intent:r,mutations:i,runtime:o}){if(typeof n=="number"&&o.store.getRevision()!==n)throw new Error(`Expected revision ${n}, current revision ${o.store.getRevision()}`);if(t)return{dryRun:!0,results:[]};let a=[],s=u=>{if(a.push(u),e&&u.status==="aborted")throw u.error??new Error(u.reason)},c=()=>{for(let u of i)Bee(o,Eee(u),r,s)};if(!e)return c(),{results:a};let d=o.store.commands.batch(r,c);if(d.status==="aborted")throw d.error??new Error(d.reason);return{results:[d]}}function Vf(e){return JSON.parse(JSON.stringify(e))}function Gee(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function YS(e){return Array.isArray(e)?`[${e.map(YS).join(",")}]`:Gee(e)?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${YS(e[t])}`).join(",")}}`:JSON.stringify(e)}function zee(e){let t=5381;for(let n=0;n<e.length;n+=1)t=t*33^e.charCodeAt(n);return`hash_${(t>>>0).toString(36)}`}function Uee(e){return zee(YS(e))}function Vee(){let e=new Map;return{create(t){e.set(t.checkpointId,Vf(t))},get(t){let n=e.get(t);return n?Vf(n):void 0},list(t){return Array.from(e.values()).filter(n=>n.canvasId===t).map(n=>Vf(n))}}}var nw=new WeakMap;function ic(e){if(e.checkpoints)return e.checkpoints;let t=nw.get(e);return t||(t=Vee(),nw.set(e,t)),t}async function qee(e,t){let n=typeof e.permissions=="function"?await e.permissions(t):e.permissions;return new Set(n)}function qt(e,t,n){return{code:t,message:n,ok:!1,revision:e.store.getRevision()}}function he(e){return JSON.stringify(e,null,2)}function pn(e,t){return{data:t,ok:!0,revision:e.store.getRevision()}}function br(e){return e.store.getState().rootCanvasId}function qf(e){var t;return!!((t=e.store.getRootCanvasContent().settings)!=null&&t.readOnly)}async function co(e,t,n){let r=await qee(e,t),i=n.filter(o=>!r.has(o));return i.length>0?qt(e,"PERMISSION_DENIED",`Missing canvas tool permission(s): ${i.join(", ")}`):null}function XS(e,t){var i,o;let n=Vf(e.store.getState()),r=((i=e.now)==null?void 0:i.call(e))??Date.now();return{canvasId:n.rootCanvasId,checkpointId:((o=e.createCheckpointId)==null?void 0:o.call(e))??`canvas_checkpoint_${r}`,createdAt:r,document:n,documentHash:Uee(n),reason:t,revision:e.store.getRevision()}}function rw(e,t){return IS(e.store,t.document,{intent:"opencode.checkpoint.restore"})}function v(e,t=[],n){return{type:"object",properties:e,required:t,additionalProperties:!0,...n?{description:n}:{}}}function Ee(e){return{type:"string",enum:Object.keys(e),description:Object.entries(e).map(([t,n])=>`${t}: ${n}`).join("; ")}}var A={type:"string"},E={type:"number"},Ue={type:"boolean"},ke={type:"array",items:A},Cr={description:"Any JSON value; the registered node or asset type owns the content contract."},mt=v({},[],"Open JSON object; keys are defined by the owning node or asset type and are preserved."),xa=v({x:E,y:E},["x","y"],"Canvas world coordinates in pixels."),WS=v({w:E,h:E},["w","h"],"Width and height in canvas pixels.");function st(e){return{anyOf:[e,{type:"null"}]}}var JS=v({borderRadius:E,border:A,background:A,opacity:E}),iw=v({id:A,type:{type:"string",description:"Open registered node type, e.g. group; for business nodes prefer create_biz_node."},x:E,y:E,w:E,h:E,parentId:st(A),order:{type:"number",default:0,description:"Rendering order among siblings."},labelRefs:{type:"object",additionalProperties:{const:!0},description:"Canvas label id to true; omit a key to leave that label unassigned."},data:Cr,style:JS,status:{const:"unknown",description:"Preserve unknown node types during round trips."}},["id","type","x","y","w","h","parentId","data"]),ow=v({pippitAssetId:A,type:{type:"string",description:"Open registered asset type."},protocolVersion:A,content:Cr,extra:Cr,status:{const:"unknown"}},["pippitAssetId","type","content","extra"]),QS=v({label:A,text:{type:"string",description:"Fallback label when label is empty."}},[],"Additional edge data is owned by the registered business type."),aw=v({id:A,type:{type:"string",examples:["reference"],description:"Open edge type; reference is the standard type."},source:A,target:A,sourceHandle:{type:"string",examples:["right"],description:"Registered source handle id; omitted uses the view default."},targetHandle:{type:"string",examples:["left"],description:"Registered target handle id; omitted uses the view default."},data:QS},["id","type","source","target"]),sw=v({enabled:Ue,threshold:{type:"number",description:"Snap distance in canvas world-coordinate pixels."},targets:{type:"array",items:Ee({grid:"Grid",node:"Other nodes",guide:"Guide lines"}),description:"An empty list disables all snap targets."}}),cw={...v({assetId:A,op:Ee({add:"Add a value or asset",remove:"Remove a value or asset",replace:"Replace a value"}),path:{type:"string",description:"JSON Pointer relative to the asset root; empty string addresses the complete asset.",examples:["/content/title",""]},value:Cr},["assetId","op","path"]),allOf:[{if:{properties:{op:{enum:["add","replace"]}},required:["op"]},then:{required:["value"]}}]},Kf={...mt,description:"Shallow content patch. Top-level keys are merged; nested values replace the corresponding field. Read the asset before updating a nested field."};var dw=Ee({left:"Left edges",center:"Horizontal centers",right:"Right edges",top:"Top edges",middle:"Vertical centers",bottom:"Bottom edges"}),uw=Ee({horizontal:"Horizontal spacing",vertical:"Vertical spacing"}),pw=Ee({horizontal:"Horizontal row",vertical:"Vertical column",grid:"Grid","horizontal-directed-cluster":"Left-to-right directed clusters","vertical-directed-cluster":"Top-to-bottom directed clusters"}),Kee="directed-cluster",ZS={type:"string",enum:[...Ks,Kee],description:"directed-cluster is the legacy alias of horizontal-directed-cluster."},lw=v({horizontalGap:E,verticalGap:E,gridColumns:E}),mw=v({strategy:ZS,ids:{...ke,description:"Only root-level nodes from this list; omitted means all root-level nodes."},horizontalGap:{type:"number",description:"Pixels; default depends on strategy: 240 for horizontal-directed-cluster/dag-layered, 48 for vertical-directed-cluster, otherwise 120."},verticalGap:{type:"number",description:"Pixels; default 96 for horizontal-directed-cluster, 480 for vertical-directed-cluster, 40 for dag-layered, otherwise 80."},gridColumns:{type:"number",description:"Grid fallback columns; omitted means estimated from node count."},nodeGap:{type:"number",description:"Minimum node spacing in pixels; strategy-dependent default."},componentGap:{type:"number",default:180},stressIterations:{type:"number",description:"Iteration count for incremental-stress; omitted means estimated from node count."},isolatedNodeMoveLimit:{type:"number",default:360,description:"Maximum displacement in canvas pixels."},isolatedPlacement:{...Ee({left:"Place isolated nodes to the left",preserve:"Preserve original area, avoid overlap"}),default:"left"},sortGroupChildren:{type:"boolean",default:!1}});var Pt=A,Ar=ke,wu={set_title:v({title:A},["title"]),set_cover:v({cover:v({pippitAssetId:Pt},[],"Image/video business asset id. Missing or blank pippitAssetId is a no-op; this command cannot clear the cover.")},["cover"]),set_global_bounds:v({bounds:v({minX:E,minY:E,maxX:E,maxY:E},["minX","minY","maxX","maxY"])},["bounds"]),create_node:v({node:iw,assets:{type:"array",items:ow},autoCreateNodeAsset:{type:"boolean",default:!0}},["node"]),delete_nodes:v({ids:Ar},["ids"]),update_node_data:v({id:Pt,patch:Kf},["id","patch"]),set_node_style:v({id:Pt,style:JS},["id","style"]),update_asset:v({assetId:Pt,contentPatch:Kf,extraPatch:Kf},["assetId"]),move_nodes:v({ids:Ar,delta:v({dx:E,dy:E},["dx","dy"],"Displacement in canvas pixels.")},["ids","delta"]),resize_node:v({id:Pt,size:WS},["id","size"]),set_node_position:v({id:Pt,position:xa},["id","position"]),align_nodes:v({ids:Ar,direction:dw},["ids","direction"]),distribute_nodes:v({ids:Ar,axis:uw},["ids","axis"]),arrange_nodes:v({ids:Ar,layout:pw,options:lw},["ids","layout"]),auto_layout_nodes:v({options:mw}),group_nodes:v({ids:Ar},["ids"]),ungroup:v({groupId:Pt},["groupId"]),reparent:v({nodeId:Pt,newParentId:st(Pt),index:{type:"number",description:"Optional insertion index among the new parent children."}},["nodeId","newParentId"]),reorder_children:v({groupId:Pt,orderedChildren:Ar},["groupId","orderedChildren"]),set_group_collapsed:v({groupId:Pt,collapsed:Ue},["groupId","collapsed"]),create_edge:v({edge:aw},["edge"]),delete_edges:v({ids:Ar},["ids"]),reconnect_edge:v({id:Pt,patch:v({source:Pt,target:Pt,sourceHandle:st(Pt),targetHandle:st(Pt)},["source","target"])},["id","patch"]),update_edge_data:v({id:Pt,patch:QS},["id","patch"]),update_snap_settings:v({patch:sw},["patch"]),set_snap_enabled:v({enabled:Ue},["enabled"]),set_auto_layout_strategy:v({strategy:{type:"string",examples:ZS.enum,description:"Open host-registered strategy name; omitted clears the preference. Examples enumerate built-in strategies."}}),invoke_command:v({name:{type:"string",description:"Command registered on this runtime. The XYQ CLI exposes its explicit business command catalog instead of arbitrary names."},args:{type:"array",items:Cr,default:[]}},["name"]),delete:v({nodeIds:Ar,edgeIds:Ar}),apply_patches:v({patches:{type:"array",items:cw}},["patches"])};function ku(e){return{type:"array",items:{oneOf:e.map(({kind:t,inputSchema:n})=>({...n,properties:{...n.properties,kind:{const:t,type:"string"}},required:["kind",...n.required??[]]}))}}}var Ir={get_snapshot:v({assetIds:ke,includeRootCanvas:{type:"boolean",default:!0}}),get_asset:v({assetId:A},["assetId"]),apply_mutations:v({atomic:{type:"boolean",default:!1,description:"Merge all mutations into one SDK transaction. The CLI wrapper may explicitly select atomic execution."},checkpointBefore:{type:"boolean",default:!1,description:"Create a checkpoint before applying the mutations."},dryRun:{type:"boolean",default:!1,description:"Validate tool routing without writing; this does not execute or fully validate the mutation business logic."},expectedRevision:{type:"number",description:"Reject when the current document revision differs."},intent:{type:"string",description:"Short semantic transaction intent."},mutations:ku(Object.entries(wu).map(([e,t])=>({kind:e,inputSchema:t})))},["intent","mutations"]),create_checkpoint:v({reason:A}),list_checkpoints:v({}),compare_checkpoint:v({checkpointId:A},["checkpointId"]),restore_checkpoint:v({checkpointId:A},["checkpointId"]),get_permissions:v({})};var jee="__debug_i18n__",Hee="1",$ee="0",fw=new WeakMap;function eb(e){try{return e()}catch{return}}function hw(e,t){try{e(t)}catch{}}function Yee(e,t){if(e)try{return new URL(e,"http://pippit-business-shared.local").searchParams.get(t)??void 0}catch{return}}function Xee(e){try{return decodeURIComponent(e)}catch{return}}function Wee(e,t){if(e===void 0)return;let n=`${encodeURIComponent(t)}=`,r=e.split(";").map(i=>i.trim()).find(i=>i.startsWith(n));return r?Xee(r.slice(n.length)):void 0}function gw(e,t,n,r){let i=r===void 0?"":`; Max-Age=${r}`;return`${encodeURIComponent(e)}=${encodeURIComponent(t)}; path=${n}${i}`}function Jee(){return{readHref:()=>typeof window>"u"?void 0:window.location.href,readCookie:()=>typeof document>"u"?void 0:document.cookie,writeCookie:e=>{typeof document<"u"&&(document.cookie=e)}}}function Qee(e={}){let t=e.cookieKey??jee,n=e.enabledValue??Hee,r=e.disabledValue??$ee,i=e.cookiePath??"/",o=e.environment??Jee(),a=e.refreshOnHrefChange??!1,s,c,d=p=>{c=p;let m=Yee(p,t);if(m===n)return hw(h=>o.writeCookie(h),gw(t,n,i)),s=!0,s;if(m===r)return hw(h=>o.writeCookie(h),gw(t,"",i,0)),s=!1,s;let f=eb(()=>o.readCookie());return p===void 0&&f===void 0?(s=void 0,!1):(s=Wee(f,t)===n,s)},u=()=>d(eb(()=>o.readHref()));return{isEnabled:()=>{if(s===void 0)return u();if(a){let p=eb(()=>o.readHref());if(p!==c)return d(p)}return s},refresh:u,invalidate:()=>{s=void 0,c=void 0}}}function Zee(e){return Array.isArray(e)?`${e[0]??""}`:`${e??""}`}var ete=Qee({refreshOnHrefChange:!0});function oc(){return{memoize:!0,memoizeFallback:!0,bindI18n:"languageChanged",bindI18nStore:"added removed"}}function ac(e,t={}){let n=t.runtime??ete,r=t.resolveKeyText??Zee,i=fw.get(e)??e.t.bind(e);return fw.set(e,i),e.t=(...o)=>n.isEnabled()?r(o[0]):i(...o),e}function Kt(e){"@babel/helpers - typeof";return Kt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kt(e)}function yw(e,t){if(Kt(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Kt(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function jf(e){var t=yw(e,"string");return Kt(t)=="symbol"?t:t+""}function _w(e,t,n){return(t=jf(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Dt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?Object(arguments[t]):{},r=Object.keys(n);typeof Object.getOwnPropertySymbols=="function"&&r.push.apply(r,Object.getOwnPropertySymbols(n).filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),r.forEach(function(i){_w(e,i,n[i])})}return e}function vr(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Tw(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,jf(r.key),r)}}function xr(e,t,n){return t&&Tw(e.prototype,t),n&&Tw(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function ui(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function sc(e,t){if(t&&(Kt(t)=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return ui(e)}function Ra(e){return Ra=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Ra(e)}function Hf(e,t){return Hf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},Hf(e,t)}function Ou(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Hf(e,t)}var tte={type:"logger",log:function(t){this.output("log",t)},warn:function(t){this.output("warn",t)},error:function(t){this.output("error",t)},output:function(t,n){console&&console[t]&&console[t].apply(console,n)}},nte=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};vr(this,e),this.init(t,n)}return xr(e,[{key:"init",value:function(n){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=r.prefix||"i18next:",this.logger=n||tte,this.options=r,this.debug=r.debug}},{key:"setDebug",value:function(n){this.debug=n}},{key:"log",value:function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return this.forward(r,"log","",!0)}},{key:"warn",value:function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return this.forward(r,"warn","",!0)}},{key:"error",value:function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return this.forward(r,"error","")}},{key:"deprecate",value:function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return this.forward(r,"warn","WARNING DEPRECATED: ",!0)}},{key:"forward",value:function(n,r,i,o){return o&&!this.debug?null:(typeof n[0]=="string"&&(n[0]="".concat(i).concat(this.prefix," ").concat(n[0])),this.logger[r](n))}},{key:"create",value:function(n){return new e(this.logger,Dt({},{prefix:"".concat(this.prefix,":").concat(n,":")},this.options))}}]),e}(),pi=new nte,uo=function(){function e(){vr(this,e),this.observers={}}return xr(e,[{key:"on",value:function(n,r){var i=this;return n.split(" ").forEach(function(o){i.observers[o]=i.observers[o]||[],i.observers[o].push(r)}),this}},{key:"off",value:function(n,r){if(this.observers[n]){if(!r){delete this.observers[n];return}this.observers[n]=this.observers[n].filter(function(i){return i!==r})}}},{key:"emit",value:function(n){for(var r=arguments.length,i=new Array(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];if(this.observers[n]){var a=[].concat(this.observers[n]);a.forEach(function(c){c.apply(void 0,i)})}if(this.observers["*"]){var s=[].concat(this.observers["*"]);s.forEach(function(c){c.apply(c,[n].concat(i))})}}}]),e}();function Lu(){var e,t,n=new Promise(function(r,i){e=r,t=i});return n.resolve=e,n.reject=t,n}function Sw(e){return e==null?"":""+e}function rte(e,t,n){e.forEach(function(r){t[r]&&(n[r]=t[r])})}function nb(e,t,n){function r(s){return s&&s.indexOf("###")>-1?s.replace(/###/g,"."):s}function i(){return!e||typeof e=="string"}for(var o=typeof t!="string"?[].concat(t):t.split(".");o.length>1;){if(i())return{};var a=r(o.shift());!e[a]&&n&&(e[a]=new n),Object.prototype.hasOwnProperty.call(e,a)?e=e[a]:e={}}return i()?{}:{obj:e,k:r(o.shift())}}function bw(e,t,n){var r=nb(e,t,Object),i=r.obj,o=r.k;i[o]=n}function ite(e,t,n,r){var i=nb(e,t,Object),o=i.obj,a=i.k;o[a]=o[a]||[],r&&(o[a]=o[a].concat(n)),r||o[a].push(n)}function Yf(e,t){var n=nb(e,t),r=n.obj,i=n.k;if(r)return r[i]}function Cw(e,t,n){var r=Yf(e,n);return r!==void 0?r:Yf(t,n)}function xw(e,t,n){for(var r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?typeof e[r]=="string"||e[r]instanceof String||typeof t[r]=="string"||t[r]instanceof String?n&&(e[r]=t[r]):xw(e[r],t[r],n):e[r]=t[r]);return e}function cc(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var ote={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};function ate(e){return typeof e=="string"?e.replace(/[&<>"'\/]/g,function(t){return ote[t]}):e}var Xf=typeof window<"u"&&window.navigator&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,ste=function(e){Ou(t,e);function t(n){var r,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};return vr(this,t),r=sc(this,Ra(t).call(this)),Xf&&uo.call(ui(r)),r.data=n||{},r.options=i,r.options.keySeparator===void 0&&(r.options.keySeparator="."),r}return xr(t,[{key:"addNamespaces",value:function(r){this.options.ns.indexOf(r)<0&&this.options.ns.push(r)}},{key:"removeNamespaces",value:function(r){var i=this.options.ns.indexOf(r);i>-1&&this.options.ns.splice(i,1)}},{key:"getResource",value:function(r,i,o){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},s=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator,c=[r,i];return o&&typeof o!="string"&&(c=c.concat(o)),o&&typeof o=="string"&&(c=c.concat(s?o.split(s):o)),r.indexOf(".")>-1&&(c=r.split(".")),Yf(this.data,c)}},{key:"addResource",value:function(r,i,o,a){var s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1},c=this.options.keySeparator;c===void 0&&(c=".");var d=[r,i];o&&(d=d.concat(c?o.split(c):o)),r.indexOf(".")>-1&&(d=r.split("."),a=i,i=d[1]),this.addNamespaces(i),bw(this.data,d,a),s.silent||this.emit("added",r,i,o,a)}},{key:"addResources",value:function(r,i,o){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(var s in o)(typeof o[s]=="string"||Object.prototype.toString.apply(o[s])==="[object Array]")&&this.addResource(r,i,s,o[s],{silent:!0});a.silent||this.emit("added",r,i,o)}},{key:"addResourceBundle",value:function(r,i,o,a,s){var c=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1},d=[r,i];r.indexOf(".")>-1&&(d=r.split("."),a=o,o=i,i=d[1]),this.addNamespaces(i);var u=Yf(this.data,d)||{};a?xw(u,o,s):u=Dt({},u,o),bw(this.data,d,u),c.silent||this.emit("added",r,i,o)}},{key:"removeResourceBundle",value:function(r,i){this.hasResourceBundle(r,i)&&delete this.data[r][i],this.removeNamespaces(i),this.emit("removed",r,i)}},{key:"hasResourceBundle",value:function(r,i){return this.getResource(r,i)!==void 0}},{key:"getResourceBundle",value:function(r,i){return i||(i=this.options.defaultNS),this.options.compatibilityAPI==="v1"?Dt({},{},this.getResource(r,i)):this.getResource(r,i)}},{key:"getDataByLanguage",value:function(r){return this.data[r]}},{key:"toJSON",value:function(){return this.data}}]),t}(uo),Rw={processors:{},addPostProcessor:function(t){this.processors[t.name]=t},handle:function(t,n,r,i,o){var a=this;return t.forEach(function(s){a.processors[s]&&(n=a.processors[s].process(n,r,i,o))}),n}},Aw={},Iw=function(e){Ou(t,e);function t(n){var r,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return vr(this,t),r=sc(this,Ra(t).call(this)),Xf&&uo.call(ui(r)),rte(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],n,ui(r)),r.options=i,r.options.keySeparator===void 0&&(r.options.keySeparator="."),r.logger=pi.create("translator"),r}return xr(t,[{key:"changeLanguage",value:function(r){r&&(this.language=r)}},{key:"exists",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}},o=this.resolve(r,i);return o&&o.res!==void 0}},{key:"extractFromKey",value:function(r,i){var o=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;o===void 0&&(o=":");var a=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,s=i.ns||this.options.defaultNS;if(o&&r.indexOf(o)>-1){var c=r.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:r,namespaces:s};var d=r.split(o);(o!==a||o===a&&this.options.ns.indexOf(d[0])>-1)&&(s=d.shift()),r=d.join(a)}return typeof s=="string"&&(s=[s]),{key:r,namespaces:s}}},{key:"translate",value:function(r,i,o){var a=this;if(Kt(i)!=="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),i||(i={}),r==null)return"";Array.isArray(r)||(r=[String(r)]);var s=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,c=this.extractFromKey(r[r.length-1],i),d=c.key,u=c.namespaces,p=u[u.length-1],m=i.lng||this.language,f=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(m&&m.toLowerCase()==="cimode"){if(f){var h=i.nsSeparator||this.options.nsSeparator;return p+h+d}return d}var g=this.resolve(r,i),y=g&&g.res,_=g&&g.usedKey||d,S=g&&g.exactUsedKey||d,T=Object.prototype.toString.apply(y),C=["[object Number]","[object Function]","[object RegExp]"],I=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,x=!this.i18nFormat||this.i18nFormat.handleAsObject,R=typeof y!="string"&&typeof y!="boolean"&&typeof y!="number";if(x&&y&&R&&C.indexOf(T)<0&&!(typeof I=="string"&&T==="[object Array]")){if(!i.returnObjects&&!this.options.returnObjects)return this.logger.warn("accessing an object - but returnObjects options is not enabled!"),this.options.returnedObjectHandler?this.options.returnedObjectHandler(_,y,i):"key '".concat(d," (").concat(this.language,")' returned an object instead of string.");if(s){var G=T==="[object Array]",O=G?[]:{},K=G?S:_;for(var H in y)if(Object.prototype.hasOwnProperty.call(y,H)){var U="".concat(K).concat(s).concat(H);O[H]=this.translate(U,Dt({},i,{joinArrays:!1,ns:u})),O[H]===U&&(O[H]=y[H])}y=O}}else if(x&&typeof I=="string"&&T==="[object Array]")y=y.join(I),y&&(y=this.extendTranslation(y,r,i,o));else{var W=!1,re=!1,Q=i.count!==void 0&&typeof i.count!="string",Ge=t.hasDefaultValue(i),Xe=Q?this.pluralResolver.getSuffix(m,i.count):"",Ce=i["defaultValue".concat(Xe)]||i.defaultValue;!this.isValidLookup(y)&&Ge&&(W=!0,y=Ce),this.isValidLookup(y)||(re=!0,y=d);var ze=Ge&&Ce!==y&&this.options.updateMissing;if(re||W||ze){if(this.logger.log(ze?"updateKey":"missingKey",m,p,d,ze?Ce:y),s){var Nt=this.resolve(d,Dt({},i,{keySeparator:!1}));Nt&&Nt.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}var Re=[],wt=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&wt&&wt[0])for(var kt=0;kt<wt.length;kt++)Re.push(wt[kt]);else this.options.saveMissingTo==="all"?Re=this.languageUtils.toResolveHierarchy(i.lng||this.language):Re.push(i.lng||this.language);var on=function(ut,Ot,Ns){a.options.missingKeyHandler?a.options.missingKeyHandler(ut,p,Ot,ze?Ns:y,ze,i):a.backendConnector&&a.backendConnector.saveMissing&&a.backendConnector.saveMissing(ut,p,Ot,ze?Ns:y,ze,i),a.emit("missingKey",ut,p,Ot,y)};this.options.saveMissing&&(this.options.saveMissingPlurals&&Q?Re.forEach(function(an){a.pluralResolver.getSuffixes(an).forEach(function(ut){on([an],d+ut,i["defaultValue".concat(ut)]||Ce)})}):on(Re,d,Ce))}y=this.extendTranslation(y,r,i,g,o),re&&y===d&&this.options.appendNamespaceToMissingKey&&(y="".concat(p,":").concat(d)),re&&this.options.parseMissingKeyHandler&&(y=this.options.parseMissingKeyHandler(y))}return y}},{key:"extendTranslation",value:function(r,i,o,a,s){var c=this;if(this.i18nFormat&&this.i18nFormat.parse)r=this.i18nFormat.parse(r,o,a.usedLng,a.usedNS,a.usedKey,{resolved:a});else if(!o.skipInterpolation){o.interpolation&&this.interpolator.init(Dt({},o,{interpolation:Dt({},this.options.interpolation,o.interpolation)}));var d=o.interpolation&&o.interpolation.skipOnVariables||this.options.interpolation.skipOnVariables,u;if(d){var p=r.match(this.interpolator.nestingRegexp);u=p&&p.length}var m=o.replace&&typeof o.replace!="string"?o.replace:o;if(this.options.interpolation.defaultVariables&&(m=Dt({},this.options.interpolation.defaultVariables,m)),r=this.interpolator.interpolate(r,m,o.lng||this.language,o),d){var f=r.match(this.interpolator.nestingRegexp),h=f&&f.length;u<h&&(o.nest=!1)}o.nest!==!1&&(r=this.interpolator.nest(r,function(){for(var _=arguments.length,S=new Array(_),T=0;T<_;T++)S[T]=arguments[T];return s&&s[0]===S[0]&&!o.context?(c.logger.warn("It seems you are nesting recursively key: ".concat(S[0]," in key: ").concat(i[0])),null):c.translate.apply(c,S.concat([i]))},o)),o.interpolation&&this.interpolator.reset()}var g=o.postProcess||this.options.postProcess,y=typeof g=="string"?[g]:g;return r!=null&&y&&y.length&&o.applyPostProcessor!==!1&&(r=Rw.handle(y,r,i,this.options&&this.options.postProcessPassResolved?Dt({i18nResolved:a},o):o,this)),r}},{key:"resolve",value:function(r){var i=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a,s,c,d,u;return typeof r=="string"&&(r=[r]),r.forEach(function(p){if(!i.isValidLookup(a)){var m=i.extractFromKey(p,o),f=m.key;s=f;var h=m.namespaces;i.options.fallbackNS&&(h=h.concat(i.options.fallbackNS));var g=o.count!==void 0&&typeof o.count!="string",y=o.context!==void 0&&typeof o.context=="string"&&o.context!=="",_=o.lngs?o.lngs:i.languageUtils.toResolveHierarchy(o.lng||i.language,o.fallbackLng);h.forEach(function(S){i.isValidLookup(a)||(u=S,!Aw["".concat(_[0],"-").concat(S)]&&i.utils&&i.utils.hasLoadedNamespace&&!i.utils.hasLoadedNamespace(u)&&(Aw["".concat(_[0],"-").concat(S)]=!0,i.logger.warn('key "'.concat(s,'" for languages "').concat(_.join(", "),`" won't get resolved as namespace "`).concat(u,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),_.forEach(function(T){if(!i.isValidLookup(a)){d=T;var C=f,I=[C];if(i.i18nFormat&&i.i18nFormat.addLookupKeys)i.i18nFormat.addLookupKeys(I,f,T,S,o);else{var x;g&&(x=i.pluralResolver.getSuffix(T,o.count)),g&&y&&I.push(C+x),y&&I.push(C+="".concat(i.options.contextSeparator).concat(o.context)),g&&I.push(C+=x)}for(var R;R=I.pop();)i.isValidLookup(a)||(c=R,a=i.getResource(T,S,R,o))}}))})}}),{res:a,usedKey:s,exactUsedKey:c,usedLng:d,usedNS:u}}},{key:"isValidLookup",value:function(r){return r!==void 0&&!(!this.options.returnNull&&r===null)&&!(!this.options.returnEmptyString&&r==="")}},{key:"getResource",value:function(r,i,o){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(r,i,o,a):this.resourceStore.getResource(r,i,o,a)}}],[{key:"hasDefaultValue",value:function(r){var i="defaultValue";for(var o in r)if(Object.prototype.hasOwnProperty.call(r,o)&&i===o.substring(0,i.length)&&r[o]!==void 0)return!0;return!1}}]),t}(uo);function tb(e){return e.charAt(0).toUpperCase()+e.slice(1)}var cte=function(){function e(t){vr(this,e),this.options=t,this.whitelist=this.options.supportedLngs||!1,this.supportedLngs=this.options.supportedLngs||!1,this.logger=pi.create("languageUtils")}return xr(e,[{key:"getScriptPartFromCode",value:function(n){if(!n||n.indexOf("-")<0)return null;var r=n.split("-");return r.length===2||(r.pop(),r[r.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(r.join("-"))}},{key:"getLanguagePartFromCode",value:function(n){if(!n||n.indexOf("-")<0)return n;var r=n.split("-");return this.formatLanguageCode(r[0])}},{key:"formatLanguageCode",value:function(n){if(typeof n=="string"&&n.indexOf("-")>-1){var r=["hans","hant","latn","cyrl","cans","mong","arab"],i=n.split("-");return this.options.lowerCaseLng?i=i.map(function(o){return o.toLowerCase()}):i.length===2?(i[0]=i[0].toLowerCase(),i[1]=i[1].toUpperCase(),r.indexOf(i[1].toLowerCase())>-1&&(i[1]=tb(i[1].toLowerCase()))):i.length===3&&(i[0]=i[0].toLowerCase(),i[1].length===2&&(i[1]=i[1].toUpperCase()),i[0]!=="sgn"&&i[2].length===2&&(i[2]=i[2].toUpperCase()),r.indexOf(i[1].toLowerCase())>-1&&(i[1]=tb(i[1].toLowerCase())),r.indexOf(i[2].toLowerCase())>-1&&(i[2]=tb(i[2].toLowerCase()))),i.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?n.toLowerCase():n}},{key:"isWhitelisted",value:function(n){return this.logger.deprecate("languageUtils.isWhitelisted",`function "isWhitelisted" will be renamed to "isSupportedCode" in the next major - please make sure to rename it's usage asap.`),this.isSupportedCode(n)}},{key:"isSupportedCode",value:function(n){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(n=this.getLanguagePartFromCode(n)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(n)>-1}},{key:"getBestMatchFromCodes",value:function(n){var r=this;if(!n)return null;var i;return n.forEach(function(o){if(!i){var a=r.formatLanguageCode(o);(!r.options.supportedLngs||r.isSupportedCode(a))&&(i=a)}}),!i&&this.options.supportedLngs&&n.forEach(function(o){if(!i){var a=r.getLanguagePartFromCode(o);if(r.isSupportedCode(a))return i=a;i=r.options.supportedLngs.find(function(s){if(s.indexOf(a)===0)return s})}}),i||(i=this.getFallbackCodes(this.options.fallbackLng)[0]),i}},{key:"getFallbackCodes",value:function(n,r){if(!n)return[];if(typeof n=="function"&&(n=n(r)),typeof n=="string"&&(n=[n]),Object.prototype.toString.apply(n)==="[object Array]")return n;if(!r)return n.default||[];var i=n[r];return i||(i=n[this.getScriptPartFromCode(r)]),i||(i=n[this.formatLanguageCode(r)]),i||(i=n[this.getLanguagePartFromCode(r)]),i||(i=n.default),i||[]}},{key:"toResolveHierarchy",value:function(n,r){var i=this,o=this.getFallbackCodes(r||this.options.fallbackLng||[],n),a=[],s=function(d){d&&(i.isSupportedCode(d)?a.push(d):i.logger.warn("rejecting language code not found in supportedLngs: ".concat(d)))};return typeof n=="string"&&n.indexOf("-")>-1?(this.options.load!=="languageOnly"&&s(this.formatLanguageCode(n)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&s(this.getScriptPartFromCode(n)),this.options.load!=="currentOnly"&&s(this.getLanguagePartFromCode(n))):typeof n=="string"&&s(this.formatLanguageCode(n)),o.forEach(function(c){a.indexOf(c)<0&&s(i.formatLanguageCode(c))}),a}}]),e}(),dte=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","kk","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],ute={1:function(t){return+(t>1)},2:function(t){return+(t!=1)},3:function(t){return 0},4:function(t){return t%10==1&&t%100!=11?0:t%10>=2&&t%10<=4&&(t%100<10||t%100>=20)?1:2},5:function(t){return t==0?0:t==1?1:t==2?2:t%100>=3&&t%100<=10?3:t%100>=11?4:5},6:function(t){return t==1?0:t>=2&&t<=4?1:2},7:function(t){return t==1?0:t%10>=2&&t%10<=4&&(t%100<10||t%100>=20)?1:2},8:function(t){return t==1?0:t==2?1:t!=8&&t!=11?2:3},9:function(t){return+(t>=2)},10:function(t){return t==1?0:t==2?1:t<7?2:t<11?3:4},11:function(t){return t==1||t==11?0:t==2||t==12?1:t>2&&t<20?2:3},12:function(t){return+(t%10!=1||t%100==11)},13:function(t){return+(t!==0)},14:function(t){return t==1?0:t==2?1:t==3?2:3},15:function(t){return t%10==1&&t%100!=11?0:t%10>=2&&(t%100<10||t%100>=20)?1:2},16:function(t){return t%10==1&&t%100!=11?0:t!==0?1:2},17:function(t){return t==1||t%10==1&&t%100!=11?0:1},18:function(t){return t==0?0:t==1?1:2},19:function(t){return t==1?0:t==0||t%100>1&&t%100<11?1:t%100>10&&t%100<20?2:3},20:function(t){return t==1?0:t==0||t%100>0&&t%100<20?1:2},21:function(t){return t%100==1?1:t%100==2?2:t%100==3||t%100==4?3:0},22:function(t){return t==1?0:t==2?1:(t<0||t>10)&&t%10==0?2:3}};function pte(){var e={};return dte.forEach(function(t){t.lngs.forEach(function(n){e[n]={numbers:t.nr,plurals:ute[t.fc]}})}),e}var lte=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};vr(this,e),this.languageUtils=t,this.options=n,this.logger=pi.create("pluralResolver"),this.rules=pte()}return xr(e,[{key:"addRule",value:function(n,r){this.rules[n]=r}},{key:"getRule",value:function(n){return this.rules[n]||this.rules[this.languageUtils.getLanguagePartFromCode(n)]}},{key:"needsPlural",value:function(n){var r=this.getRule(n);return r&&r.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(n,r){return this.getSuffixes(n).map(function(i){return r+i})}},{key:"getSuffixes",value:function(n){var r=this,i=this.getRule(n);return i?i.numbers.map(function(o){return r.getSuffix(n,o)}):[]}},{key:"getSuffix",value:function(n,r){var i=this,o=this.getRule(n);if(o){var a=o.noAbs?o.plurals(r):o.plurals(Math.abs(r)),s=o.numbers[a];this.options.simplifyPluralSuffix&&o.numbers.length===2&&o.numbers[0]===1&&(s===2?s="plural":s===1&&(s=""));var c=function(){return i.options.prepend&&s.toString()?i.options.prepend+s.toString():s.toString()};return this.options.compatibilityJSON==="v1"?s===1?"":typeof s=="number"?"_plural_".concat(s.toString()):c():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&o.numbers.length===2&&o.numbers[0]===1?c():this.options.prepend&&a.toString()?this.options.prepend+a.toString():a.toString()}return this.logger.warn("no plural rule found for: ".concat(n)),""}}]),e}(),mte=function(){function e(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};vr(this,e),this.logger=pi.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(n){return n},this.init(t)}return xr(e,[{key:"init",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};n.interpolation||(n.interpolation={escapeValue:!0});var r=n.interpolation;this.escape=r.escape!==void 0?r.escape:ate,this.escapeValue=r.escapeValue!==void 0?r.escapeValue:!0,this.useRawValueToEscape=r.useRawValueToEscape!==void 0?r.useRawValueToEscape:!1,this.prefix=r.prefix?cc(r.prefix):r.prefixEscaped||"{{",this.suffix=r.suffix?cc(r.suffix):r.suffixEscaped||"}}",this.formatSeparator=r.formatSeparator?r.formatSeparator:r.formatSeparator||",",this.unescapePrefix=r.unescapeSuffix?"":r.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":r.unescapeSuffix||"",this.nestingPrefix=r.nestingPrefix?cc(r.nestingPrefix):r.nestingPrefixEscaped||cc("$t("),this.nestingSuffix=r.nestingSuffix?cc(r.nestingSuffix):r.nestingSuffixEscaped||cc(")"),this.nestingOptionsSeparator=r.nestingOptionsSeparator?r.nestingOptionsSeparator:r.nestingOptionsSeparator||",",this.maxReplaces=r.maxReplaces?r.maxReplaces:1e3,this.alwaysFormat=r.alwaysFormat!==void 0?r.alwaysFormat:!1,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var n="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=new RegExp(n,"g");var r="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=new RegExp(r,"g");var i="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=new RegExp(i,"g")}},{key:"interpolate",value:function(n,r,i,o){var a=this,s,c,d,u=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function p(y){return y.replace(/\$/g,"$$$$")}var m=function(_){if(_.indexOf(a.formatSeparator)<0){var S=Cw(r,u,_);return a.alwaysFormat?a.format(S,void 0,i):S}var T=_.split(a.formatSeparator),C=T.shift().trim(),I=T.join(a.formatSeparator).trim();return a.format(Cw(r,u,C),I,i,o)};this.resetRegExp();var f=o&&o.missingInterpolationHandler||this.options.missingInterpolationHandler,h=o&&o.interpolation&&o.interpolation.skipOnVariables||this.options.interpolation.skipOnVariables,g=[{regex:this.regexpUnescape,safeValue:function(_){return p(_)}},{regex:this.regexp,safeValue:function(_){return a.escapeValue?p(a.escape(_)):p(_)}}];return g.forEach(function(y){for(d=0;s=y.regex.exec(n);){if(c=m(s[1].trim()),c===void 0)if(typeof f=="function"){var _=f(n,s,o);c=typeof _=="string"?_:""}else if(h){c=s[0];continue}else a.logger.warn("missed to pass in variable ".concat(s[1]," for interpolating ").concat(n)),c="";else typeof c!="string"&&!a.useRawValueToEscape&&(c=Sw(c));if(n=n.replace(s[0],y.safeValue(c)),y.regex.lastIndex=0,d++,d>=a.maxReplaces)break}}),n}},{key:"nest",value:function(n,r){var i=this,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a,s,c=Dt({},o);c.applyPostProcessor=!1,delete c.defaultValue;function d(f,h){var g=this.nestingOptionsSeparator;if(f.indexOf(g)<0)return f;var y=f.split(new RegExp("".concat(g,"[ ]*{"))),_="{".concat(y[1]);f=y[0],_=this.interpolate(_,c),_=_.replace(/'/g,'"');try{c=JSON.parse(_),h&&(c=Dt({},h,c))}catch(S){return this.logger.warn("failed parsing options string in nesting for key ".concat(f),S),"".concat(f).concat(g).concat(_)}return delete c.defaultValue,f}for(;a=this.nestingRegexp.exec(n);){var u=[],p=!1;if(a[0].includes(this.formatSeparator)&&!/{.*}/.test(a[1])){var m=a[1].split(this.formatSeparator).map(function(f){return f.trim()});a[1]=m.shift(),u=m,p=!0}if(s=r(d.call(this,a[1].trim(),c),c),s&&a[0]===n&&typeof s!="string")return s;typeof s!="string"&&(s=Sw(s)),s||(this.logger.warn("missed to resolve ".concat(a[1]," for nesting ").concat(n)),s=""),p&&(s=u.reduce(function(f,h){return i.format(f,h,o.lng,o)},s.trim())),n=n.replace(a[0],s),this.regexp.lastIndex=0}return n}}]),e}();function fte(e,t){for(var n=e.indexOf(t);n!==-1;)e.splice(n,1),n=e.indexOf(t)}var hte=function(e){Ou(t,e);function t(n,r,i){var o,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return vr(this,t),o=sc(this,Ra(t).call(this)),Xf&&uo.call(ui(o)),o.backend=n,o.store=r,o.services=i,o.languageUtils=i.languageUtils,o.options=a,o.logger=pi.create("backendConnector"),o.state={},o.queue=[],o.backend&&o.backend.init&&o.backend.init(i,a.backend,a),o}return xr(t,[{key:"queueLoad",value:function(r,i,o,a){var s=this,c=[],d=[],u=[],p=[];return r.forEach(function(m){var f=!0;i.forEach(function(h){var g="".concat(m,"|").concat(h);!o.reload&&s.store.hasResourceBundle(m,h)?s.state[g]=2:s.state[g]<0||(s.state[g]===1?d.indexOf(g)<0&&d.push(g):(s.state[g]=1,f=!1,d.indexOf(g)<0&&d.push(g),c.indexOf(g)<0&&c.push(g),p.indexOf(h)<0&&p.push(h)))}),f||u.push(m)}),(c.length||d.length)&&this.queue.push({pending:d,loaded:{},errors:[],callback:a}),{toLoad:c,pending:d,toLoadLanguages:u,toLoadNamespaces:p}}},{key:"loaded",value:function(r,i,o){var a=r.split("|"),s=a[0],c=a[1];i&&this.emit("failedLoading",s,c,i),o&&this.store.addResourceBundle(s,c,o),this.state[r]=i?-1:2;var d={};this.queue.forEach(function(u){ite(u.loaded,[s],c),fte(u.pending,r),i&&u.errors.push(i),u.pending.length===0&&!u.done&&(Object.keys(u.loaded).forEach(function(p){d[p]||(d[p]=[]),u.loaded[p].length&&u.loaded[p].forEach(function(m){d[p].indexOf(m)<0&&d[p].push(m)})}),u.done=!0,u.errors.length?u.callback(u.errors):u.callback())}),this.emit("loaded",d),this.queue=this.queue.filter(function(u){return!u.done})}},{key:"read",value:function(r,i,o){var a=this,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,c=arguments.length>4&&arguments[4]!==void 0?arguments[4]:350,d=arguments.length>5?arguments[5]:void 0;return r.length?this.backend[o](r,i,function(u,p){if(u&&p&&s<5){setTimeout(function(){a.read.call(a,r,i,o,s+1,c*2,d)},c);return}d(u,p)}):d(null,{})}},{key:"prepareLoading",value:function(r,i){var o=this,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();typeof r=="string"&&(r=this.languageUtils.toResolveHierarchy(r)),typeof i=="string"&&(i=[i]);var c=this.queueLoad(r,i,a,s);if(!c.toLoad.length)return c.pending.length||s(),null;c.toLoad.forEach(function(d){o.loadOne(d)})}},{key:"load",value:function(r,i,o){this.prepareLoading(r,i,{},o)}},{key:"reload",value:function(r,i,o){this.prepareLoading(r,i,{reload:!0},o)}},{key:"loadOne",value:function(r){var i=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",a=r.split("|"),s=a[0],c=a[1];this.read(s,c,"read",void 0,void 0,function(d,u){d&&i.logger.warn("".concat(o,"loading namespace ").concat(c," for language ").concat(s," failed"),d),!d&&u&&i.logger.log("".concat(o,"loaded namespace ").concat(c," for language ").concat(s),u),i.loaded(r,d,u)})}},{key:"saveMissing",value:function(r,i,o,a,s){var c=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(i)){this.logger.warn('did not save key "'.concat(o,'" as the namespace "').concat(i,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}o==null||o===""||(this.backend&&this.backend.create&&this.backend.create(r,i,o,a,null,Dt({},c,{isUpdate:s})),!(!r||!r[0])&&this.store.addResource(r[0],i,o,a))}}]),t}(uo);function gte(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,whitelist:!1,nonExplicitWhitelist:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(t){var n={};if(Kt(t[1])==="object"&&(n=t[1]),typeof t[1]=="string"&&(n.defaultValue=t[1]),typeof t[2]=="string"&&(n.tDescription=t[2]),Kt(t[2])==="object"||Kt(t[3])==="object"){var r=t[3]||t[2];Object.keys(r).forEach(function(i){n[i]=r[i]})}return n},interpolation:{escapeValue:!0,format:function(t,n,r,i){return t},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!1}}}function vw(e){return typeof e.ns=="string"&&(e.ns=[e.ns]),typeof e.fallbackLng=="string"&&(e.fallbackLng=[e.fallbackLng]),typeof e.fallbackNS=="string"&&(e.fallbackNS=[e.fallbackNS]),e.whitelist&&(e.whitelist&&e.whitelist.indexOf("cimode")<0&&(e.whitelist=e.whitelist.concat(["cimode"])),e.supportedLngs=e.whitelist),e.nonExplicitWhitelist&&(e.nonExplicitSupportedLngs=e.nonExplicitWhitelist),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e}function $f(){}var yte=function(e){Ou(t,e);function t(){var n,r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;if(vr(this,t),n=sc(this,Ra(t).call(this)),Xf&&uo.call(ui(n)),n.options=vw(r),n.services={},n.logger=pi,n.modules={external:[]},i&&!n.isInitialized&&!r.isClone){if(!n.options.initImmediate)return n.init(r,i),sc(n,ui(n));setTimeout(function(){n.init(r,i)},0)}return n}return xr(t,[{key:"init",value:function(){var r=this,i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=arguments.length>1?arguments[1]:void 0;typeof i=="function"&&(o=i,i={}),i.whitelist&&!i.supportedLngs&&this.logger.deprecate("whitelist",'option "whitelist" will be renamed to "supportedLngs" in the next major - please make sure to rename this option asap.'),i.nonExplicitWhitelist&&!i.nonExplicitSupportedLngs&&this.logger.deprecate("whitelist",'options "nonExplicitWhitelist" will be renamed to "nonExplicitSupportedLngs" in the next major - please make sure to rename this option asap.'),this.options=Dt({},gte(),this.options,vw(i)),this.format=this.options.interpolation.format,o||(o=$f);function a(h){return h?typeof h=="function"?new h:h:null}if(!this.options.isClone){this.modules.logger?pi.init(a(this.modules.logger),this.options):pi.init(null,this.options);var s=new cte(this.options);this.store=new ste(this.options.resources,this.options);var c=this.services;c.logger=pi,c.resourceStore=this.store,c.languageUtils=s,c.pluralResolver=new lte(s,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),c.interpolator=new mte(this.options),c.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},c.backendConnector=new hte(a(this.modules.backend),c.resourceStore,c,this.options),c.backendConnector.on("*",function(h){for(var g=arguments.length,y=new Array(g>1?g-1:0),_=1;_<g;_++)y[_-1]=arguments[_];r.emit.apply(r,[h].concat(y))}),this.modules.languageDetector&&(c.languageDetector=a(this.modules.languageDetector),c.languageDetector.init(c,this.options.detection,this.options)),this.modules.i18nFormat&&(c.i18nFormat=a(this.modules.i18nFormat),c.i18nFormat.init&&c.i18nFormat.init(this)),this.translator=new Iw(this.services,this.options),this.translator.on("*",function(h){for(var g=arguments.length,y=new Array(g>1?g-1:0),_=1;_<g;_++)y[_-1]=arguments[_];r.emit.apply(r,[h].concat(y))}),this.modules.external.forEach(function(h){h.init&&h.init(r)})}if(this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){var d=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);d.length>0&&d[0]!=="dev"&&(this.options.lng=d[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined");var u=["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"];u.forEach(function(h){r[h]=function(){var g;return(g=r.store)[h].apply(g,arguments)}});var p=["addResource","addResources","addResourceBundle","removeResourceBundle"];p.forEach(function(h){r[h]=function(){var g;return(g=r.store)[h].apply(g,arguments),r}});var m=Lu(),f=function(){var g=function(_,S){r.isInitialized&&r.logger.warn("init: i18next is already initialized. You should call init just once!"),r.isInitialized=!0,r.options.isClone||r.logger.log("initialized",r.options),r.emit("initialized",r.options),m.resolve(S),o(_,S)};if(r.languages&&r.options.compatibilityAPI!=="v1"&&!r.isInitialized)return g(null,r.t.bind(r));r.changeLanguage(r.options.lng,g)};return this.options.resources||!this.options.initImmediate?f():setTimeout(f,0),m}},{key:"loadResources",value:function(r){var i=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:$f,a=o,s=typeof r=="string"?r:this.language;if(typeof r=="function"&&(a=r),!this.options.resources||this.options.partialBundledLanguages){if(s&&s.toLowerCase()==="cimode")return a();var c=[],d=function(m){if(m){var f=i.services.languageUtils.toResolveHierarchy(m);f.forEach(function(h){c.indexOf(h)<0&&c.push(h)})}};if(s)d(s);else{var u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.forEach(function(p){return d(p)})}this.options.preload&&this.options.preload.forEach(function(p){return d(p)}),this.services.backendConnector.load(c,this.options.ns,a)}else a(null)}},{key:"reloadResources",value:function(r,i,o){var a=Lu();return r||(r=this.languages),i||(i=this.options.ns),o||(o=$f),this.services.backendConnector.reload(r,i,function(s){a.resolve(),o(s)}),a}},{key:"use",value:function(r){if(!r)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!r.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return r.type==="backend"&&(this.modules.backend=r),(r.type==="logger"||r.log&&r.warn&&r.error)&&(this.modules.logger=r),r.type==="languageDetector"&&(this.modules.languageDetector=r),r.type==="i18nFormat"&&(this.modules.i18nFormat=r),r.type==="postProcessor"&&Rw.addPostProcessor(r),r.type==="3rdParty"&&this.modules.external.push(r),this}},{key:"changeLanguage",value:function(r,i){var o=this;this.isLanguageChangingTo=r;var a=Lu();this.emit("languageChanging",r);var s=function(u,p){p?(o.language=p,o.languages=o.services.languageUtils.toResolveHierarchy(p),o.translator.changeLanguage(p),o.isLanguageChangingTo=void 0,o.emit("languageChanged",p),o.logger.log("languageChanged",p)):o.isLanguageChangingTo=void 0,a.resolve(function(){return o.t.apply(o,arguments)}),i&&i(u,function(){return o.t.apply(o,arguments)})},c=function(u){var p=typeof u=="string"?u:o.services.languageUtils.getBestMatchFromCodes(u);p&&(o.language||(o.language=p,o.languages=o.services.languageUtils.toResolveHierarchy(p)),o.translator.language||o.translator.changeLanguage(p),o.services.languageDetector&&o.services.languageDetector.cacheUserLanguage(p)),o.loadResources(p,function(m){s(m,p)})};return!r&&this.services.languageDetector&&!this.services.languageDetector.async?c(this.services.languageDetector.detect()):!r&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect(c):c(r),a}},{key:"getFixedT",value:function(r,i){var o=this,a=function s(c,d){var u;if(Kt(d)!=="object"){for(var p=arguments.length,m=new Array(p>2?p-2:0),f=2;f<p;f++)m[f-2]=arguments[f];u=o.options.overloadTranslationOptionHandler([c,d].concat(m))}else u=Dt({},d);return u.lng=u.lng||s.lng,u.lngs=u.lngs||s.lngs,u.ns=u.ns||s.ns,o.t(c,u)};return typeof r=="string"?a.lng=r:a.lngs=r,a.ns=i,a}},{key:"t",value:function(){var r;return this.translator&&(r=this.translator).translate.apply(r,arguments)}},{key:"exists",value:function(){var r;return this.translator&&(r=this.translator).exists.apply(r,arguments)}},{key:"setDefaultNamespace",value:function(r){this.options.defaultNS=r}},{key:"hasLoadedNamespace",value:function(r){var i=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var a=this.languages[0],s=this.options?this.options.fallbackLng:!1,c=this.languages[this.languages.length-1];if(a.toLowerCase()==="cimode")return!0;var d=function(m,f){var h=i.services.backendConnector.state["".concat(m,"|").concat(f)];return h===-1||h===2};if(o.precheck){var u=o.precheck(this,d);if(u!==void 0)return u}return!!(this.hasResourceBundle(a,r)||!this.services.backendConnector.backend||d(a,r)&&(!s||d(c,r)))}},{key:"loadNamespaces",value:function(r,i){var o=this,a=Lu();return this.options.ns?(typeof r=="string"&&(r=[r]),r.forEach(function(s){o.options.ns.indexOf(s)<0&&o.options.ns.push(s)}),this.loadResources(function(s){a.resolve(),i&&i(s)}),a):(i&&i(),Promise.resolve())}},{key:"loadLanguages",value:function(r,i){var o=Lu();typeof r=="string"&&(r=[r]);var a=this.options.preload||[],s=r.filter(function(c){return a.indexOf(c)<0});return s.length?(this.options.preload=a.concat(s),this.loadResources(function(c){o.resolve(),i&&i(c)}),o):(i&&i(),Promise.resolve())}},{key:"dir",value:function(r){if(r||(r=this.languages&&this.languages.length>0?this.languages[0]:this.language),!r)return"rtl";var i=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam"];return i.indexOf(this.services.languageUtils.getLanguagePartFromCode(r))>=0?"rtl":"ltr"}},{key:"createInstance",value:function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;return new t(r,i)}},{key:"cloneInstance",value:function(){var r=this,i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:$f,a=Dt({},this.options,i,{isClone:!0}),s=new t(a),c=["store","services","language"];return c.forEach(function(d){s[d]=r[d]}),s.services=Dt({},this.services),s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s.translator=new Iw(s.services,s.options),s.translator.on("*",function(d){for(var u=arguments.length,p=new Array(u>1?u-1:0),m=1;m<u;m++)p[m-1]=arguments[m];s.emit.apply(s,[d].concat(p))}),s.init(a,o),s.translator.options=s.options,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}}]),t}(uo),_te=new yte,Pw=_te;var rk=am(nk(),1),{__extends:Fu,__assign:ge,__rest:ik,__decorate:pXe,__param:lXe,__esDecorate:mXe,__runInitializers:fXe,__propKey:hXe,__setFunctionName:gXe,__metadata:yXe,__awaiter:_Xe,__generator:TXe,__exportStar:SXe,__createBinding:bXe,__values:CXe,__read:AXe,__spread:IXe,__spreadArrays:vXe,__spreadArray:Zf,__await:xXe,__asyncGenerator:RXe,__asyncDelegator:PXe,__asyncValues:DXe,__makeTemplateObject:EXe,__importStar:MXe,__importDefault:NXe,__classPrivateFieldGet:wXe,__classPrivateFieldSet:kXe,__classPrivateFieldIn:OXe,__addDisposableResource:LXe,__disposeResources:FXe}=rk.default;var me;(function(e){e[e.EXPECT_ARGUMENT_CLOSING_BRACE=1]="EXPECT_ARGUMENT_CLOSING_BRACE",e[e.EMPTY_ARGUMENT=2]="EMPTY_ARGUMENT",e[e.MALFORMED_ARGUMENT=3]="MALFORMED_ARGUMENT",e[e.EXPECT_ARGUMENT_TYPE=4]="EXPECT_ARGUMENT_TYPE",e[e.INVALID_ARGUMENT_TYPE=5]="INVALID_ARGUMENT_TYPE",e[e.EXPECT_ARGUMENT_STYLE=6]="EXPECT_ARGUMENT_STYLE",e[e.INVALID_NUMBER_SKELETON=7]="INVALID_NUMBER_SKELETON",e[e.INVALID_DATE_TIME_SKELETON=8]="INVALID_DATE_TIME_SKELETON",e[e.EXPECT_NUMBER_SKELETON=9]="EXPECT_NUMBER_SKELETON",e[e.EXPECT_DATE_TIME_SKELETON=10]="EXPECT_DATE_TIME_SKELETON",e[e.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE=11]="UNCLOSED_QUOTE_IN_ARGUMENT_STYLE",e[e.EXPECT_SELECT_ARGUMENT_OPTIONS=12]="EXPECT_SELECT_ARGUMENT_OPTIONS",e[e.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE=13]="EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE",e[e.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE=14]="INVALID_PLURAL_ARGUMENT_OFFSET_VALUE",e[e.EXPECT_SELECT_ARGUMENT_SELECTOR=15]="EXPECT_SELECT_ARGUMENT_SELECTOR",e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR=16]="EXPECT_PLURAL_ARGUMENT_SELECTOR",e[e.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT=17]="EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT",e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT=18]="EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT",e[e.INVALID_PLURAL_ARGUMENT_SELECTOR=19]="INVALID_PLURAL_ARGUMENT_SELECTOR",e[e.DUPLICATE_PLURAL_ARGUMENT_SELECTOR=20]="DUPLICATE_PLURAL_ARGUMENT_SELECTOR",e[e.DUPLICATE_SELECT_ARGUMENT_SELECTOR=21]="DUPLICATE_SELECT_ARGUMENT_SELECTOR",e[e.MISSING_OTHER_CLAUSE=22]="MISSING_OTHER_CLAUSE",e[e.INVALID_TAG=23]="INVALID_TAG",e[e.INVALID_TAG_NAME=25]="INVALID_TAG_NAME",e[e.UNMATCHED_CLOSING_TAG=26]="UNMATCHED_CLOSING_TAG",e[e.UNCLOSED_TAG=27]="UNCLOSED_TAG"})(me||(me={}));var Ve;(function(e){e[e.literal=0]="literal",e[e.argument=1]="argument",e[e.number=2]="number",e[e.date=3]="date",e[e.time=4]="time",e[e.select=5]="select",e[e.plural=6]="plural",e[e.pound=7]="pound",e[e.tag=8]="tag"})(Ve||(Ve={}));var Pa;(function(e){e[e.number=0]="number",e[e.dateTime=1]="dateTime"})(Pa||(Pa={}));function ib(e){return e.type===Ve.literal}function ok(e){return e.type===Ve.argument}function eh(e){return e.type===Ve.number}function th(e){return e.type===Ve.date}function nh(e){return e.type===Ve.time}function rh(e){return e.type===Ve.select}function ih(e){return e.type===Ve.plural}function ak(e){return e.type===Ve.pound}function oh(e){return e.type===Ve.tag}function ah(e){return!!(e&&typeof e=="object"&&e.type===Pa.number)}function Bu(e){return!!(e&&typeof e=="object"&&e.type===Pa.dateTime)}var ob=/[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/;var Tte=/(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;function sk(e){var t={};return e.replace(Tte,function(n){var r=n.length;switch(n[0]){case"G":t.era=r===4?"long":r===5?"narrow":"short";break;case"y":t.year=r===2?"2-digit":"numeric";break;case"Y":case"u":case"U":case"r":throw new RangeError("`Y/u/U/r` (year) patterns are not supported, use `y` instead");case"q":case"Q":throw new RangeError("`q/Q` (quarter) patterns are not supported");case"M":case"L":t.month=["numeric","2-digit","short","long","narrow"][r-1];break;case"w":case"W":throw new RangeError("`w/W` (week) patterns are not supported");case"d":t.day=["numeric","2-digit"][r-1];break;case"D":case"F":case"g":throw new RangeError("`D/F/g` (day) patterns are not supported, use `d` instead");case"E":t.weekday=r===4?"short":r===5?"narrow":"short";break;case"e":if(r<4)throw new RangeError("`e..eee` (weekday) patterns are not supported");t.weekday=["short","long","narrow","short"][r-4];break;case"c":if(r<4)throw new RangeError("`c..ccc` (weekday) patterns are not supported");t.weekday=["short","long","narrow","short"][r-4];break;case"a":t.hour12=!0;break;case"b":case"B":throw new RangeError("`b/B` (period) patterns are not supported, use `a` instead");case"h":t.hourCycle="h12",t.hour=["numeric","2-digit"][r-1];break;case"H":t.hourCycle="h23",t.hour=["numeric","2-digit"][r-1];break;case"K":t.hourCycle="h11",t.hour=["numeric","2-digit"][r-1];break;case"k":t.hourCycle="h24",t.hour=["numeric","2-digit"][r-1];break;case"j":case"J":case"C":throw new RangeError("`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead");case"m":t.minute=["numeric","2-digit"][r-1];break;case"s":t.second=["numeric","2-digit"][r-1];break;case"S":case"A":throw new RangeError("`S/A` (second) patterns are not supported, use `s` instead");case"z":t.timeZoneName=r<4?"short":"long";break;case"Z":case"O":case"v":case"V":case"X":case"x":throw new RangeError("`Z/O/v/V/X/x` (timeZone) patterns are not supported, use `z` instead")}return""}),t}var ck=/[\t-\r \x85\u200E\u200F\u2028\u2029]/i;function lk(e){if(e.length===0)throw new Error("Number skeleton cannot be empty");for(var t=e.split(ck).filter(function(m){return m.length>0}),n=[],r=0,i=t;r<i.length;r++){var o=i[r],a=o.split("/");if(a.length===0)throw new Error("Invalid number skeleton");for(var s=a[0],c=a.slice(1),d=0,u=c;d<u.length;d++){var p=u[d];if(p.length===0)throw new Error("Invalid number skeleton")}n.push({stem:s,options:c})}return n}function Ste(e){return e.replace(/^(.*?)-/,"")}var dk=/^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g,mk=/^(@+)?(\+|#+)?[rs]?$/g,bte=/(\*)(0+)|(#+)(0+)|(0+)/g,fk=/^(0+)$/;function uk(e){var t={};return e[e.length-1]==="r"?t.roundingPriority="morePrecision":e[e.length-1]==="s"&&(t.roundingPriority="lessPrecision"),e.replace(mk,function(n,r,i){return typeof i!="string"?(t.minimumSignificantDigits=r.length,t.maximumSignificantDigits=r.length):i==="+"?t.minimumSignificantDigits=r.length:r[0]==="#"?t.maximumSignificantDigits=r.length:(t.minimumSignificantDigits=r.length,t.maximumSignificantDigits=r.length+(typeof i=="string"?i.length:0)),""}),t}function hk(e){switch(e){case"sign-auto":return{signDisplay:"auto"};case"sign-accounting":case"()":return{currencySign:"accounting"};case"sign-always":case"+!":return{signDisplay:"always"};case"sign-accounting-always":case"()!":return{signDisplay:"always",currencySign:"accounting"};case"sign-except-zero":case"+?":return{signDisplay:"exceptZero"};case"sign-accounting-except-zero":case"()?":return{signDisplay:"exceptZero",currencySign:"accounting"};case"sign-never":case"+_":return{signDisplay:"never"}}}function Cte(e){var t;if(e[0]==="E"&&e[1]==="E"?(t={notation:"engineering"},e=e.slice(2)):e[0]==="E"&&(t={notation:"scientific"},e=e.slice(1)),t){var n=e.slice(0,2);if(n==="+!"?(t.signDisplay="always",e=e.slice(2)):n==="+?"&&(t.signDisplay="exceptZero",e=e.slice(2)),!fk.test(e))throw new Error("Malformed concise eng/scientific notation");t.minimumIntegerDigits=e.length}return t}function pk(e){var t={},n=hk(e);return n||t}function gk(e){for(var t={},n=0,r=e;n<r.length;n++){var i=r[n];switch(i.stem){case"percent":case"%":t.style="percent";continue;case"%x100":t.style="percent",t.scale=100;continue;case"currency":t.style="currency",t.currency=i.options[0];continue;case"group-off":case",_":t.useGrouping=!1;continue;case"precision-integer":case".":t.maximumFractionDigits=0;continue;case"measure-unit":case"unit":t.style="unit",t.unit=Ste(i.options[0]);continue;case"compact-short":case"K":t.notation="compact",t.compactDisplay="short";continue;case"compact-long":case"KK":t.notation="compact",t.compactDisplay="long";continue;case"scientific":t=ge(ge(ge({},t),{notation:"scientific"}),i.options.reduce(function(c,d){return ge(ge({},c),pk(d))},{}));continue;case"engineering":t=ge(ge(ge({},t),{notation:"engineering"}),i.options.reduce(function(c,d){return ge(ge({},c),pk(d))},{}));continue;case"notation-simple":t.notation="standard";continue;case"unit-width-narrow":t.currencyDisplay="narrowSymbol",t.unitDisplay="narrow";continue;case"unit-width-short":t.currencyDisplay="code",t.unitDisplay="short";continue;case"unit-width-full-name":t.currencyDisplay="name",t.unitDisplay="long";continue;case"unit-width-iso-code":t.currencyDisplay="symbol";continue;case"scale":t.scale=parseFloat(i.options[0]);continue;case"integer-width":if(i.options.length>1)throw new RangeError("integer-width stems only accept a single optional option");i.options[0].replace(bte,function(c,d,u,p,m,f){if(d)t.minimumIntegerDigits=u.length;else{if(p&&m)throw new Error("We currently do not support maximum integer digits");if(f)throw new Error("We currently do not support exact integer digits")}return""});continue}if(fk.test(i.stem)){t.minimumIntegerDigits=i.stem.length;continue}if(dk.test(i.stem)){if(i.options.length>1)throw new RangeError("Fraction-precision stems only accept a single optional option");i.stem.replace(dk,function(c,d,u,p,m,f){return u==="*"?t.minimumFractionDigits=d.length:p&&p[0]==="#"?t.maximumFractionDigits=p.length:m&&f?(t.minimumFractionDigits=m.length,t.maximumFractionDigits=m.length+f.length):(t.minimumFractionDigits=d.length,t.maximumFractionDigits=d.length),""});var o=i.options[0];o==="w"?t=ge(ge({},t),{trailingZeroDisplay:"stripIfInteger"}):o&&(t=ge(ge({},t),uk(o)));continue}if(mk.test(i.stem)){t=ge(ge({},t),uk(i.stem));continue}var a=hk(i.stem);a&&(t=ge(ge({},t),a));var s=Cte(i.stem);s&&(t=ge(ge({},t),s))}return t}var Gu={"001":["H","h"],AC:["H","h","hb","hB"],AD:["H","hB"],AE:["h","hB","hb","H"],AF:["H","hb","hB","h"],AG:["h","hb","H","hB"],AI:["H","h","hb","hB"],AL:["h","H","hB"],AM:["H","hB"],AO:["H","hB"],AR:["H","h","hB","hb"],AS:["h","H"],AT:["H","hB"],AU:["h","hb","H","hB"],AW:["H","hB"],AX:["H"],AZ:["H","hB","h"],BA:["H","hB","h"],BB:["h","hb","H","hB"],BD:["h","hB","H"],BE:["H","hB"],BF:["H","hB"],BG:["H","hB","h"],BH:["h","hB","hb","H"],BJ:["H","hB"],BL:["H","hB"],BM:["h","hb","H","hB"],BN:["hb","hB","h","H"],BO:["H","hB","h","hb"],BQ:["H"],BR:["H","hB"],BS:["h","hb","H","hB"],BT:["h","H"],BW:["H","h","hb","hB"],BZ:["H","h","hb","hB"],CA:["h","hb","H","hB"],CC:["H","h","hb","hB"],CD:["hB","H"],CF:["H","h","hB"],CG:["H","hB"],CH:["H","hB","h"],CI:["H","hB"],CK:["H","h","hb","hB"],CL:["H","h","hB","hb"],CM:["H","h","hB"],CN:["H","hB","hb","h"],CO:["h","H","hB","hb"],CP:["H"],CR:["H","h","hB","hb"],CU:["H","h","hB","hb"],CV:["H","hB"],CX:["H","h","hb","hB"],CY:["h","H","hb","hB"],CZ:["H"],DE:["H","hB"],DG:["H","h","hb","hB"],DJ:["h","H"],DK:["H"],DM:["h","hb","H","hB"],DO:["h","H","hB","hb"],DZ:["h","hB","hb","H"],EA:["H","h","hB","hb"],EC:["H","hB","h","hb"],EE:["H","hB"],EG:["h","hB","hb","H"],EH:["h","hB","hb","H"],ER:["h","H"],ES:["H","hB","h","hb"],ET:["hB","hb","h","H"],FI:["H"],FJ:["h","hb","H","hB"],FK:["H","h","hb","hB"],FM:["h","hb","H","hB"],FR:["H","hB"],GA:["H","hB"],GB:["H","h","hb","hB"],GD:["h","hb","H","hB"],GE:["H","hB","h"],GF:["H","hB"],GG:["H","h","hb","hB"],GH:["h","H"],GI:["H","h","hb","hB"],GM:["h","hb","H","hB"],GN:["H","hB"],GP:["H","hB"],GQ:["H","hB","h","hb"],GR:["h","H","hb","hB"],GT:["H","h","hB","hb"],GU:["h","hb","H","hB"],GW:["H","hB"],GY:["h","hb","H","hB"],HK:["h","hB","hb","H"],HN:["H","h","hB","hb"],HR:["H","hB"],IC:["H","h","hB","hb"],ID:["H"],IE:["H","h","hb","hB"],IL:["H","hB"],IM:["H","h","hb","hB"],IN:["h","H"],IO:["H","h","hb","hB"],IQ:["h","hB","hb","H"],IR:["hB","H"],IS:["H"],IT:["H","hB"],JE:["H","h","hb","hB"],JM:["h","hb","H","hB"],JO:["h","hB","hb","H"],JP:["H","h","K"],KE:["hB","hb","H","h"],KG:["H","h","hB","hb"],KH:["hB","h","H","hb"],KI:["h","hb","H","hB"],KM:["H","h","hB","hb"],KN:["h","hb","H","hB"],KP:["h","H","hB","hb"],KR:["h","H","hB","hb"],KW:["h","hB","hb","H"],KY:["h","hb","H","hB"],KZ:["H","hB"],LA:["H","hb","hB","h"],LB:["h","hB","hb","H"],LC:["h","hb","H","hB"],LI:["H","hB","h"],LK:["H","h","hB","hb"],LR:["h","hb","H","hB"],LS:["h","H"],LT:["H","h","hb","hB"],LU:["H","h","hB"],LV:["H","hB","hb","h"],LY:["h","hB","hb","H"],MA:["H","h","hB","hb"],MC:["H","hB"],MD:["H","hB"],ME:["H","hB","h"],MF:["H","hB"],MH:["h","hb","H","hB"],MK:["H","h","hb","hB"],ML:["H"],MM:["hB","hb","H","h"],MN:["H","h","hb","hB"],MO:["h","hB","hb","H"],MP:["h","hb","H","hB"],MQ:["H","hB"],MR:["h","hB","hb","H"],MS:["H","h","hb","hB"],MW:["h","hb","H","hB"],MX:["H","h","hB","hb"],MY:["hb","hB","h","H"],MZ:["H","hB"],NA:["h","H","hB","hb"],NC:["H","hB"],NE:["H"],NF:["H","h","hb","hB"],NG:["H","h","hb","hB"],NI:["H","h","hB","hb"],NL:["H","hB"],NP:["H","h","hB"],NR:["H","h","hb","hB"],NU:["H","h","hb","hB"],NZ:["h","hb","H","hB"],OM:["h","hB","hb","H"],PA:["h","H","hB","hb"],PE:["H","hB","h","hb"],PF:["H","h","hB"],PG:["h","H"],PH:["h","hB","hb","H"],PK:["h","hB","H"],PM:["H","hB"],PN:["H","h","hb","hB"],PR:["h","H","hB","hb"],PS:["h","hB","hb","H"],PT:["H","hB"],PW:["h","H"],PY:["H","h","hB","hb"],QA:["h","hB","hb","H"],RE:["H","hB"],RO:["H","hB"],RS:["H","hB","h"],RU:["H"],SA:["h","hB","hb","H"],SB:["h","hb","H","hB"],SC:["H","h","hB"],SD:["h","hB","hb","H"],SE:["H"],SG:["h","hb","H","hB"],SH:["H","h","hb","hB"],SI:["H","hB"],SJ:["H"],SK:["H"],SL:["h","hb","H","hB"],SM:["H","h","hB"],SN:["H","h","hB"],SO:["h","H"],SR:["H","hB"],SS:["h","hb","H","hB"],ST:["H","hB"],SV:["H","h","hB","hb"],SX:["H","h","hb","hB"],SY:["h","hB","hb","H"],SZ:["h","hb","H","hB"],TA:["H","h","hb","hB"],TC:["h","hb","H","hB"],TD:["h","H","hB"],TF:["H","h","hB"],TG:["H","hB"],TL:["H","hB","hb","h"],TN:["h","hB","hb","H"],TO:["h","H"],TR:["H","hB"],TT:["h","hb","H","hB"],TW:["hB","hb","h","H"],TZ:["hB","hb","H","h"],UA:["H","hB","h"],UG:["hB","hb","H","h"],UM:["h","hb","H","hB"],US:["h","hb","H","hB"],UY:["H","h","hB","hb"],UZ:["H","hB","h"],VA:["H","h","hB"],VC:["h","hb","H","hB"],VE:["h","H","hB","hb"],VG:["h","hb","H","hB"],VI:["h","hb","H","hB"],VU:["h","H"],WF:["H","hB"],WS:["h","H"],XK:["H","hB","h"],YE:["h","hB","hb","H"],YT:["H","hB"],ZA:["H","h","hb","hB"],ZM:["h","hb","H","hB"],"af-ZA":["H","h","hB","hb"],"ar-001":["h","hB","hb","H"],"ca-ES":["H","h","hB"],"en-001":["h","hb","H","hB"],"es-BO":["H","h","hB","hb"],"es-BR":["H","h","hB","hb"],"es-EC":["H","h","hB","hb"],"es-ES":["H","h","hB","hb"],"es-GQ":["H","h","hB","hb"],"es-PE":["H","h","hB","hb"],"fr-CA":["H","h","hB"],"gl-ES":["H","h","hB"],"gu-IN":["hB","hb","h","H"],"hi-IN":["hB","h","H"],"it-CH":["H","h","hB"],"it-IT":["H","h","hB"],"kn-IN":["hB","h","H"],"ml-IN":["hB","h","H"],"mr-IN":["hB","hb","h","H"],"pa-IN":["hB","hb","h","H"],"ta-IN":["hB","h","hb","H"],"te-IN":["hB","h","H"],"zu-ZA":["H","hB","hb","h"]};function yk(e,t){for(var n="",r=0;r<e.length;r++){var i=e.charAt(r);if(i==="j"){for(var o=0;r+1<e.length&&e.charAt(r+1)===i;)o++,r++;var a=1+(o&1),s=o<2?1:3+(o>>1),c="a",d=Ate(t);for((d=="H"||d=="k")&&(s=0);s-- >0;)n+=c;for(;a-- >0;)n=d+n}else i==="J"?n+="H":n+=i}return n}function Ate(e){var t=e.hourCycle;if(t===void 0&&e.hourCycles&&e.hourCycles.length&&(t=e.hourCycles[0]),t)switch(t){case"h24":return"k";case"h23":return"H";case"h12":return"h";case"h11":return"K";default:throw new Error("Invalid hourCycle")}var n=e.language,r;n!=="root"&&(r=e.maximize().region);var i=Gu[r||""]||Gu[n||""]||Gu["".concat(n,"-001")]||Gu["001"];return i[0]}var ab,Ite=new RegExp("^".concat(ob.source,"*")),vte=new RegExp("".concat(ob.source,"*$"));function ye(e,t){return{start:e,end:t}}var xte=!!String.prototype.startsWith&&"_a".startsWith("a",1),Rte=!!String.fromCodePoint,Pte=!!Object.fromEntries,Dte=!!String.prototype.codePointAt,Ete=!!String.prototype.trimStart,Mte=!!String.prototype.trimEnd,Nte=!!Number.isSafeInteger,wte=Nte?Number.isSafeInteger:function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e&&Math.abs(e)<=9007199254740991},cb=!0;try{_k=Ck("([^\\p{White_Space}\\p{Pattern_Syntax}]*)","yu"),cb=((ab=_k.exec("a"))===null||ab===void 0?void 0:ab[0])==="a"}catch{cb=!1}var _k,Tk=xte?function(t,n,r){return t.startsWith(n,r)}:function(t,n,r){return t.slice(r,r+n.length)===n},db=Rte?String.fromCodePoint:function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];for(var r="",i=t.length,o=0,a;i>o;){if(a=t[o++],a>1114111)throw RangeError(a+" is not a valid code point");r+=a<65536?String.fromCharCode(a):String.fromCharCode(((a-=65536)>>10)+55296,a%1024+56320)}return r},Sk=Pte?Object.fromEntries:function(t){for(var n={},r=0,i=t;r<i.length;r++){var o=i[r],a=o[0],s=o[1];n[a]=s}return n},bk=Dte?function(t,n){return t.codePointAt(n)}:function(t,n){var r=t.length;if(!(n<0||n>=r)){var i=t.charCodeAt(n),o;return i<55296||i>56319||n+1===r||(o=t.charCodeAt(n+1))<56320||o>57343?i:(i-55296<<10)+(o-56320)+65536}},kte=Ete?function(t){return t.trimStart()}:function(t){return t.replace(Ite,"")},Ote=Mte?function(t){return t.trimEnd()}:function(t){return t.replace(vte,"")};function Ck(e,t){return new RegExp(e,t)}var ub;cb?(sb=Ck("([^\\p{White_Space}\\p{Pattern_Syntax}]*)","yu"),ub=function(t,n){var r;sb.lastIndex=n;var i=sb.exec(t);return(r=i[1])!==null&&r!==void 0?r:""}):ub=function(t,n){for(var r=[];;){var i=bk(t,n);if(i===void 0||Ik(i)||Bte(i))break;r.push(i),n+=i>=65536?2:1}return db.apply(void 0,r)};var sb,Ak=function(){function e(t,n){n===void 0&&(n={}),this.message=t,this.position={offset:0,line:1,column:1},this.ignoreTag=!!n.ignoreTag,this.locale=n.locale,this.requiresOtherClause=!!n.requiresOtherClause,this.shouldParseSkeletons=!!n.shouldParseSkeletons}return e.prototype.parse=function(){if(this.offset()!==0)throw Error("parser can only be used once");return this.parseMessage(0,"",!1)},e.prototype.parseMessage=function(t,n,r){for(var i=[];!this.isEOF();){var o=this.char();if(o===123){var a=this.parseArgument(t,r);if(a.err)return a;i.push(a.val)}else{if(o===125&&t>0)break;if(o===35&&(n==="plural"||n==="selectordinal")){var s=this.clonePosition();this.bump(),i.push({type:Ve.pound,location:ye(s,this.clonePosition())})}else if(o===60&&!this.ignoreTag&&this.peek()===47){if(r)break;return this.error(me.UNMATCHED_CLOSING_TAG,ye(this.clonePosition(),this.clonePosition()))}else if(o===60&&!this.ignoreTag&&pb(this.peek()||0)){var a=this.parseTag(t,n);if(a.err)return a;i.push(a.val)}else{var a=this.parseLiteral(t,n);if(a.err)return a;i.push(a.val)}}}return{val:i,err:null}},e.prototype.parseTag=function(t,n){var r=this.clonePosition();this.bump();var i=this.parseTagName();if(this.bumpSpace(),this.bumpIf("/>"))return{val:{type:Ve.literal,value:"<".concat(i,"/>"),location:ye(r,this.clonePosition())},err:null};if(this.bumpIf(">")){var o=this.parseMessage(t+1,n,!0);if(o.err)return o;var a=o.val,s=this.clonePosition();if(this.bumpIf("</")){if(this.isEOF()||!pb(this.char()))return this.error(me.INVALID_TAG,ye(s,this.clonePosition()));var c=this.clonePosition(),d=this.parseTagName();return i!==d?this.error(me.UNMATCHED_CLOSING_TAG,ye(c,this.clonePosition())):(this.bumpSpace(),this.bumpIf(">")?{val:{type:Ve.tag,value:i,children:a,location:ye(r,this.clonePosition())},err:null}:this.error(me.INVALID_TAG,ye(s,this.clonePosition())))}else return this.error(me.UNCLOSED_TAG,ye(r,this.clonePosition()))}else return this.error(me.INVALID_TAG,ye(r,this.clonePosition()))},e.prototype.parseTagName=function(){var t=this.offset();for(this.bump();!this.isEOF()&&Fte(this.char());)this.bump();return this.message.slice(t,this.offset())},e.prototype.parseLiteral=function(t,n){for(var r=this.clonePosition(),i="";;){var o=this.tryParseQuote(n);if(o){i+=o;continue}var a=this.tryParseUnquoted(t,n);if(a){i+=a;continue}var s=this.tryParseLeftAngleBracket();if(s){i+=s;continue}break}var c=ye(r,this.clonePosition());return{val:{type:Ve.literal,value:i,location:c},err:null}},e.prototype.tryParseLeftAngleBracket=function(){return!this.isEOF()&&this.char()===60&&(this.ignoreTag||!Lte(this.peek()||0))?(this.bump(),"<"):null},e.prototype.tryParseQuote=function(t){if(this.isEOF()||this.char()!==39)return null;switch(this.peek()){case 39:return this.bump(),this.bump(),"'";case 123:case 60:case 62:case 125:break;case 35:if(t==="plural"||t==="selectordinal")break;return null;default:return null}this.bump();var n=[this.char()];for(this.bump();!this.isEOF();){var r=this.char();if(r===39)if(this.peek()===39)n.push(39),this.bump();else{this.bump();break}else n.push(r);this.bump()}return db.apply(void 0,n)},e.prototype.tryParseUnquoted=function(t,n){if(this.isEOF())return null;var r=this.char();return r===60||r===123||r===35&&(n==="plural"||n==="selectordinal")||r===125&&t>0?null:(this.bump(),db(r))},e.prototype.parseArgument=function(t,n){var r=this.clonePosition();if(this.bump(),this.bumpSpace(),this.isEOF())return this.error(me.EXPECT_ARGUMENT_CLOSING_BRACE,ye(r,this.clonePosition()));if(this.char()===125)return this.bump(),this.error(me.EMPTY_ARGUMENT,ye(r,this.clonePosition()));var i=this.parseIdentifierIfPossible().value;if(!i)return this.error(me.MALFORMED_ARGUMENT,ye(r,this.clonePosition()));if(this.bumpSpace(),this.isEOF())return this.error(me.EXPECT_ARGUMENT_CLOSING_BRACE,ye(r,this.clonePosition()));switch(this.char()){case 125:return this.bump(),{val:{type:Ve.argument,value:i,location:ye(r,this.clonePosition())},err:null};case 44:return this.bump(),this.bumpSpace(),this.isEOF()?this.error(me.EXPECT_ARGUMENT_CLOSING_BRACE,ye(r,this.clonePosition())):this.parseArgumentOptions(t,n,i,r);default:return this.error(me.MALFORMED_ARGUMENT,ye(r,this.clonePosition()))}},e.prototype.parseIdentifierIfPossible=function(){var t=this.clonePosition(),n=this.offset(),r=ub(this.message,n),i=n+r.length;this.bumpTo(i);var o=this.clonePosition(),a=ye(t,o);return{value:r,location:a}},e.prototype.parseArgumentOptions=function(t,n,r,i){var o,a=this.clonePosition(),s=this.parseIdentifierIfPossible().value,c=this.clonePosition();switch(s){case"":return this.error(me.EXPECT_ARGUMENT_TYPE,ye(a,c));case"number":case"date":case"time":{this.bumpSpace();var d=null;if(this.bumpIf(",")){this.bumpSpace();var u=this.clonePosition(),p=this.parseSimpleArgStyleIfPossible();if(p.err)return p;var m=Ote(p.val);if(m.length===0)return this.error(me.EXPECT_ARGUMENT_STYLE,ye(this.clonePosition(),this.clonePosition()));var f=ye(u,this.clonePosition());d={style:m,styleLocation:f}}var h=this.tryParseArgumentClose(i);if(h.err)return h;var g=ye(i,this.clonePosition());if(d&&Tk(d==null?void 0:d.style,"::",0)){var y=kte(d.style.slice(2));if(s==="number"){var p=this.parseNumberSkeletonFromString(y,d.styleLocation);return p.err?p:{val:{type:Ve.number,value:r,location:g,style:p.val},err:null}}else{if(y.length===0)return this.error(me.EXPECT_DATE_TIME_SKELETON,g);var _=y;this.locale&&(_=yk(y,this.locale));var m={type:Pa.dateTime,pattern:_,location:d.styleLocation,parsedOptions:this.shouldParseSkeletons?sk(_):{}},S=s==="date"?Ve.date:Ve.time;return{val:{type:S,value:r,location:g,style:m},err:null}}}return{val:{type:s==="number"?Ve.number:s==="date"?Ve.date:Ve.time,value:r,location:g,style:(o=d==null?void 0:d.style)!==null&&o!==void 0?o:null},err:null}}case"plural":case"selectordinal":case"select":{var T=this.clonePosition();if(this.bumpSpace(),!this.bumpIf(","))return this.error(me.EXPECT_SELECT_ARGUMENT_OPTIONS,ye(T,ge({},T)));this.bumpSpace();var C=this.parseIdentifierIfPossible(),I=0;if(s!=="select"&&C.value==="offset"){if(!this.bumpIf(":"))return this.error(me.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE,ye(this.clonePosition(),this.clonePosition()));this.bumpSpace();var p=this.tryParseDecimalInteger(me.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE,me.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);if(p.err)return p;this.bumpSpace(),C=this.parseIdentifierIfPossible(),I=p.val}var x=this.tryParsePluralOrSelectOptions(t,s,n,C);if(x.err)return x;var h=this.tryParseArgumentClose(i);if(h.err)return h;var R=ye(i,this.clonePosition());return s==="select"?{val:{type:Ve.select,value:r,options:Sk(x.val),location:R},err:null}:{val:{type:Ve.plural,value:r,options:Sk(x.val),offset:I,pluralType:s==="plural"?"cardinal":"ordinal",location:R},err:null}}default:return this.error(me.INVALID_ARGUMENT_TYPE,ye(a,c))}},e.prototype.tryParseArgumentClose=function(t){return this.isEOF()||this.char()!==125?this.error(me.EXPECT_ARGUMENT_CLOSING_BRACE,ye(t,this.clonePosition())):(this.bump(),{val:!0,err:null})},e.prototype.parseSimpleArgStyleIfPossible=function(){for(var t=0,n=this.clonePosition();!this.isEOF();){var r=this.char();switch(r){case 39:{this.bump();var i=this.clonePosition();if(!this.bumpUntil("'"))return this.error(me.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE,ye(i,this.clonePosition()));this.bump();break}case 123:{t+=1,this.bump();break}case 125:{if(t>0)t-=1;else return{val:this.message.slice(n.offset,this.offset()),err:null};break}default:this.bump();break}}return{val:this.message.slice(n.offset,this.offset()),err:null}},e.prototype.parseNumberSkeletonFromString=function(t,n){var r=[];try{r=lk(t)}catch{return this.error(me.INVALID_NUMBER_SKELETON,n)}return{val:{type:Pa.number,tokens:r,location:n,parsedOptions:this.shouldParseSkeletons?gk(r):{}},err:null}},e.prototype.tryParsePluralOrSelectOptions=function(t,n,r,i){for(var o,a=!1,s=[],c=new Set,d=i.value,u=i.location;;){if(d.length===0){var p=this.clonePosition();if(n!=="select"&&this.bumpIf("=")){var m=this.tryParseDecimalInteger(me.EXPECT_PLURAL_ARGUMENT_SELECTOR,me.INVALID_PLURAL_ARGUMENT_SELECTOR);if(m.err)return m;u=ye(p,this.clonePosition()),d=this.message.slice(p.offset,this.offset())}else break}if(c.has(d))return this.error(n==="select"?me.DUPLICATE_SELECT_ARGUMENT_SELECTOR:me.DUPLICATE_PLURAL_ARGUMENT_SELECTOR,u);d==="other"&&(a=!0),this.bumpSpace();var f=this.clonePosition();if(!this.bumpIf("{"))return this.error(n==="select"?me.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT:me.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT,ye(this.clonePosition(),this.clonePosition()));var h=this.parseMessage(t+1,n,r);if(h.err)return h;var g=this.tryParseArgumentClose(f);if(g.err)return g;s.push([d,{value:h.val,location:ye(f,this.clonePosition())}]),c.add(d),this.bumpSpace(),o=this.parseIdentifierIfPossible(),d=o.value,u=o.location}return s.length===0?this.error(n==="select"?me.EXPECT_SELECT_ARGUMENT_SELECTOR:me.EXPECT_PLURAL_ARGUMENT_SELECTOR,ye(this.clonePosition(),this.clonePosition())):this.requiresOtherClause&&!a?this.error(me.MISSING_OTHER_CLAUSE,ye(this.clonePosition(),this.clonePosition())):{val:s,err:null}},e.prototype.tryParseDecimalInteger=function(t,n){var r=1,i=this.clonePosition();this.bumpIf("+")||this.bumpIf("-")&&(r=-1);for(var o=!1,a=0;!this.isEOF();){var s=this.char();if(s>=48&&s<=57)o=!0,a=a*10+(s-48),this.bump();else break}var c=ye(i,this.clonePosition());return o?(a*=r,wte(a)?{val:a,err:null}:this.error(n,c)):this.error(t,c)},e.prototype.offset=function(){return this.position.offset},e.prototype.isEOF=function(){return this.offset()===this.message.length},e.prototype.clonePosition=function(){return{offset:this.position.offset,line:this.position.line,column:this.position.column}},e.prototype.char=function(){var t=this.position.offset;if(t>=this.message.length)throw Error("out of bound");var n=bk(this.message,t);if(n===void 0)throw Error("Offset ".concat(t," is at invalid UTF-16 code unit boundary"));return n},e.prototype.error=function(t,n){return{val:null,err:{kind:t,message:this.message,location:n}}},e.prototype.bump=function(){if(!this.isEOF()){var t=this.char();t===10?(this.position.line+=1,this.position.column=1,this.position.offset+=1):(this.position.column+=1,this.position.offset+=t<65536?1:2)}},e.prototype.bumpIf=function(t){if(Tk(this.message,t,this.offset())){for(var n=0;n<t.length;n++)this.bump();return!0}return!1},e.prototype.bumpUntil=function(t){var n=this.offset(),r=this.message.indexOf(t,n);return r>=0?(this.bumpTo(r),!0):(this.bumpTo(this.message.length),!1)},e.prototype.bumpTo=function(t){if(this.offset()>t)throw Error("targetOffset ".concat(t," must be greater than or equal to the current offset ").concat(this.offset()));for(t=Math.min(t,this.message.length);;){var n=this.offset();if(n===t)break;if(n>t)throw Error("targetOffset ".concat(t," is at invalid UTF-16 code unit boundary"));if(this.bump(),this.isEOF())break}},e.prototype.bumpSpace=function(){for(;!this.isEOF()&&Ik(this.char());)this.bump()},e.prototype.peek=function(){if(this.isEOF())return null;var t=this.char(),n=this.offset(),r=this.message.charCodeAt(n+(t>=65536?2:1));return r??null},e}();function pb(e){return e>=97&&e<=122||e>=65&&e<=90}function Lte(e){return pb(e)||e===47}function Fte(e){return e===45||e===46||e>=48&&e<=57||e===95||e>=97&&e<=122||e>=65&&e<=90||e==183||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=893||e>=895&&e<=8191||e>=8204&&e<=8205||e>=8255&&e<=8256||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}function Ik(e){return e>=9&&e<=13||e===32||e===133||e>=8206&&e<=8207||e===8232||e===8233}function Bte(e){return e>=33&&e<=35||e===36||e>=37&&e<=39||e===40||e===41||e===42||e===43||e===44||e===45||e>=46&&e<=47||e>=58&&e<=59||e>=60&&e<=62||e>=63&&e<=64||e===91||e===92||e===93||e===94||e===96||e===123||e===124||e===125||e===126||e===161||e>=162&&e<=165||e===166||e===167||e===169||e===171||e===172||e===174||e===176||e===177||e===182||e===187||e===191||e===215||e===247||e>=8208&&e<=8213||e>=8214&&e<=8215||e===8216||e===8217||e===8218||e>=8219&&e<=8220||e===8221||e===8222||e===8223||e>=8224&&e<=8231||e>=8240&&e<=8248||e===8249||e===8250||e>=8251&&e<=8254||e>=8257&&e<=8259||e===8260||e===8261||e===8262||e>=8263&&e<=8273||e===8274||e===8275||e>=8277&&e<=8286||e>=8592&&e<=8596||e>=8597&&e<=8601||e>=8602&&e<=8603||e>=8604&&e<=8607||e===8608||e>=8609&&e<=8610||e===8611||e>=8612&&e<=8613||e===8614||e>=8615&&e<=8621||e===8622||e>=8623&&e<=8653||e>=8654&&e<=8655||e>=8656&&e<=8657||e===8658||e===8659||e===8660||e>=8661&&e<=8691||e>=8692&&e<=8959||e>=8960&&e<=8967||e===8968||e===8969||e===8970||e===8971||e>=8972&&e<=8991||e>=8992&&e<=8993||e>=8994&&e<=9e3||e===9001||e===9002||e>=9003&&e<=9083||e===9084||e>=9085&&e<=9114||e>=9115&&e<=9139||e>=9140&&e<=9179||e>=9180&&e<=9185||e>=9186&&e<=9254||e>=9255&&e<=9279||e>=9280&&e<=9290||e>=9291&&e<=9311||e>=9472&&e<=9654||e===9655||e>=9656&&e<=9664||e===9665||e>=9666&&e<=9719||e>=9720&&e<=9727||e>=9728&&e<=9838||e===9839||e>=9840&&e<=10087||e===10088||e===10089||e===10090||e===10091||e===10092||e===10093||e===10094||e===10095||e===10096||e===10097||e===10098||e===10099||e===10100||e===10101||e>=10132&&e<=10175||e>=10176&&e<=10180||e===10181||e===10182||e>=10183&&e<=10213||e===10214||e===10215||e===10216||e===10217||e===10218||e===10219||e===10220||e===10221||e===10222||e===10223||e>=10224&&e<=10239||e>=10240&&e<=10495||e>=10496&&e<=10626||e===10627||e===10628||e===10629||e===10630||e===10631||e===10632||e===10633||e===10634||e===10635||e===10636||e===10637||e===10638||e===10639||e===10640||e===10641||e===10642||e===10643||e===10644||e===10645||e===10646||e===10647||e===10648||e>=10649&&e<=10711||e===10712||e===10713||e===10714||e===10715||e>=10716&&e<=10747||e===10748||e===10749||e>=10750&&e<=11007||e>=11008&&e<=11055||e>=11056&&e<=11076||e>=11077&&e<=11078||e>=11079&&e<=11084||e>=11085&&e<=11123||e>=11124&&e<=11125||e>=11126&&e<=11157||e===11158||e>=11159&&e<=11263||e>=11776&&e<=11777||e===11778||e===11779||e===11780||e===11781||e>=11782&&e<=11784||e===11785||e===11786||e===11787||e===11788||e===11789||e>=11790&&e<=11798||e===11799||e>=11800&&e<=11801||e===11802||e===11803||e===11804||e===11805||e>=11806&&e<=11807||e===11808||e===11809||e===11810||e===11811||e===11812||e===11813||e===11814||e===11815||e===11816||e===11817||e>=11818&&e<=11822||e===11823||e>=11824&&e<=11833||e>=11834&&e<=11835||e>=11836&&e<=11839||e===11840||e===11841||e===11842||e>=11843&&e<=11855||e>=11856&&e<=11857||e===11858||e>=11859&&e<=11903||e>=12289&&e<=12291||e===12296||e===12297||e===12298||e===12299||e===12300||e===12301||e===12302||e===12303||e===12304||e===12305||e>=12306&&e<=12307||e===12308||e===12309||e===12310||e===12311||e===12312||e===12313||e===12314||e===12315||e===12316||e===12317||e>=12318&&e<=12319||e===12320||e===12336||e===64830||e===64831||e>=65093&&e<=65094}function lb(e){e.forEach(function(t){if(delete t.location,rh(t)||ih(t))for(var n in t.options)delete t.options[n].location,lb(t.options[n].value);else eh(t)&&ah(t.style)||(th(t)||nh(t))&&Bu(t.style)?delete t.style.location:oh(t)&&lb(t.children)})}function vk(e,t){t===void 0&&(t={}),t=ge({shouldParseSkeletons:!0,requiresOtherClause:!0},t);var n=new Ak(e,t).parse();if(n.err){var r=SyntaxError(me[n.err.kind]);throw r.location=n.err.location,r.originalMessage=n.err.message,r}return t!=null&&t.captureLocation||lb(n.val),n.val}function sh(e,t){var n=t&&t.cache?t.cache:Kte,r=t&&t.serializer?t.serializer:qte,i=t&&t.strategy?t.strategy:zte;return i(e,{cache:n,serializer:r})}function Gte(e){return e==null||typeof e=="number"||typeof e=="boolean"}function xk(e,t,n,r){var i=Gte(r)?r:n(r),o=t.get(i);return typeof o>"u"&&(o=e.call(this,r),t.set(i,o)),o}function Rk(e,t,n){var r=Array.prototype.slice.call(arguments,3),i=n(r),o=t.get(i);return typeof o>"u"&&(o=e.apply(this,r),t.set(i,o)),o}function mb(e,t,n,r,i){return n.bind(t,e,r,i)}function zte(e,t){var n=e.length===1?xk:Rk;return mb(e,this,n,t.cache.create(),t.serializer)}function Ute(e,t){return mb(e,this,Rk,t.cache.create(),t.serializer)}function Vte(e,t){return mb(e,this,xk,t.cache.create(),t.serializer)}var qte=function(){return JSON.stringify(arguments)};function fb(){this.cache=Object.create(null)}fb.prototype.get=function(e){return this.cache[e]};fb.prototype.set=function(e,t){this.cache[e]=t};var Kte={create:function(){return new fb}},ch={variadic:Ute,monadic:Vte};var Da;(function(e){e.MISSING_VALUE="MISSING_VALUE",e.INVALID_VALUE="INVALID_VALUE",e.MISSING_INTL_API="MISSING_INTL_API"})(Da||(Da={}));var zu=function(e){Fu(t,e);function t(n,r,i){var o=e.call(this,n)||this;return o.code=r,o.originalMessage=i,o}return t.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},t}(Error);var hb=function(e){Fu(t,e);function t(n,r,i,o){return e.call(this,'Invalid values for "'.concat(n,'": "').concat(r,'". Options are "').concat(Object.keys(i).join('", "'),'"'),Da.INVALID_VALUE,o)||this}return t}(zu);var Pk=function(e){Fu(t,e);function t(n,r,i){return e.call(this,'Value for "'.concat(n,'" must be of type ').concat(r),Da.INVALID_VALUE,i)||this}return t}(zu);var Dk=function(e){Fu(t,e);function t(n,r){return e.call(this,'The intl string context variable "'.concat(n,'" was not provided to the string "').concat(r,'"'),Da.MISSING_VALUE,r)||this}return t}(zu);var Bt;(function(e){e[e.literal=0]="literal",e[e.object=1]="object"})(Bt||(Bt={}));function jte(e){return e.length<2?e:e.reduce(function(t,n){var r=t[t.length-1];return!r||r.type!==Bt.literal||n.type!==Bt.literal?t.push(n):r.value+=n.value,t},[])}function Hte(e){return typeof e=="function"}function Uu(e,t,n,r,i,o,a){if(e.length===1&&ib(e[0]))return[{type:Bt.literal,value:e[0].value}];for(var s=[],c=0,d=e;c<d.length;c++){var u=d[c];if(ib(u)){s.push({type:Bt.literal,value:u.value});continue}if(ak(u)){typeof o=="number"&&s.push({type:Bt.literal,value:n.getNumberFormat(t).format(o)});continue}var p=u.value;if(!(i&&p in i))throw new Dk(p,a);var m=i[p];if(ok(u)){(!m||typeof m=="string"||typeof m=="number")&&(m=typeof m=="string"||typeof m=="number"?String(m):""),s.push({type:typeof m=="string"?Bt.literal:Bt.object,value:m});continue}if(th(u)){var f=typeof u.style=="string"?r.date[u.style]:Bu(u.style)?u.style.parsedOptions:void 0;s.push({type:Bt.literal,value:n.getDateTimeFormat(t,f).format(m)});continue}if(nh(u)){var f=typeof u.style=="string"?r.time[u.style]:Bu(u.style)?u.style.parsedOptions:r.time.medium;s.push({type:Bt.literal,value:n.getDateTimeFormat(t,f).format(m)});continue}if(eh(u)){var f=typeof u.style=="string"?r.number[u.style]:ah(u.style)?u.style.parsedOptions:void 0;f&&f.scale&&(m=m*(f.scale||1)),s.push({type:Bt.literal,value:n.getNumberFormat(t,f).format(m)});continue}if(oh(u)){var h=u.children,g=u.value,y=i[g];if(!Hte(y))throw new Pk(g,"function",a);var _=Uu(h,t,n,r,i,o),S=y(_.map(function(I){return I.value}));Array.isArray(S)||(S=[S]),s.push.apply(s,S.map(function(I){return{type:typeof I=="string"?Bt.literal:Bt.object,value:I}}))}if(rh(u)){var T=u.options[m]||u.options.other;if(!T)throw new hb(u.value,m,Object.keys(u.options),a);s.push.apply(s,Uu(T.value,t,n,r,i));continue}if(ih(u)){var T=u.options["=".concat(m)];if(!T){if(!Intl.PluralRules)throw new zu(`Intl.PluralRules is not available in this environment.
3
3
  Try polyfilling it using "@formatjs/intl-pluralrules"
4
- `,Ur.MISSING_INTL_API,i);var b=n.getPluralRules(t,{type:u.pluralType}).select(l-(u.offset||0));S=u.options[b]||u.options.other}if(!S)throw new Bf(u.value,l,Object.keys(u.options),i);a.push.apply(a,Oi(S.value,t,n,r,o,l-(u.offset||0)));continue}}return CV(a)}function xV(e,t){return t?V(V(V({},e||{}),t||{}),Object.keys(e).reduce(function(n,r){return n[r]=V(V({},e[r]),t[r]||{}),n},{})):e}function TV(e,t){return t?Object.keys(e).reduce(function(n,r){return n[r]=xV(e[r],t[r]),n},V({},e)):e}function Gf(e){return{create:function(){return{get:function(t){return e[t]},set:function(t,n){e[t]=n}}}}}function NV(e){return e===void 0&&(e={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:kc(function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new((t=Intl.NumberFormat).bind.apply(t,Cc([void 0],n,!1)))},{cache:Gf(e.number),strategy:Mc.variadic}),getDateTimeFormat:kc(function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new((t=Intl.DateTimeFormat).bind.apply(t,Cc([void 0],n,!1)))},{cache:Gf(e.dateTime),strategy:Mc.variadic}),getPluralRules:kc(function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new((t=Intl.PluralRules).bind.apply(t,Cc([void 0],n,!1)))},{cache:Gf(e.pluralRules),strategy:Mc.variadic})}}var t_=function(){function e(t,n,r,o){n===void 0&&(n=e.defaultLocale);var s=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(c){var u=s.formatToParts(c);if(u.length===1)return u[0].value;var p=u.reduce(function(l,f){return!l.length||f.type!==Le.literal||typeof l[l.length-1]!="string"?l.push(f.value):l[l.length-1]+=f.value,l},[]);return p.length<=1?p[0]||"":p},this.formatToParts=function(c){return Oi(s.ast,s.locales,s.formatters,s.formats,c,void 0,s.message)},this.resolvedOptions=function(){var c;return{locale:((c=s.resolvedLocale)===null||c===void 0?void 0:c.toString())||Intl.NumberFormat.supportedLocalesOf(s.locales)[0]}},this.getAst=function(){return s.ast},this.locales=n,this.resolvedLocale=e.resolveLocale(n),typeof t=="string"){if(this.message=t,!e.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");var i=o||{},a=i.formatters,d=TI(i,["formatters"]);this.ast=e.__parse(t,V(V({},d),{locale:this.resolvedLocale}))}else this.ast=t;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=TV(e.formats,r),this.formatters=o&&o.formatters||NV(this.formatterCache)}return Object.defineProperty(e,"defaultLocale",{get:function(){return e.memoizedDefaultLocale||(e.memoizedDefaultLocale=new Intl.NumberFormat().resolvedOptions().locale),e.memoizedDefaultLocale},enumerable:!1,configurable:!0}),e.memoizedDefaultLocale=null,e.resolveLocale=function(t){if(!(typeof Intl.Locale>"u")){var n=Intl.NumberFormat.supportedLocalesOf(t);return n.length>0?new Intl.Locale(n[0]):new Intl.Locale(typeof t=="string"?t:t[0])}},e.__parse=WI,e.formats={number:{integer:{maximumFractionDigits:0},currency:{style:"currency"},percent:{style:"percent"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},e}();var Di=t_;var Lc=function(){return Lc=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Lc.apply(this,arguments)};function n_(e,t,n){n===void 0&&(n=null);function r(a){return a&&a.indexOf("###")>-1?a.replace(/###/g,"."):a}function o(){return!e||typeof e=="string"}for(var s=typeof t!="string"?[].concat(t):t.split(".");s.length>1;){if(o())return{};var i=r(s.shift());!e[i]&&n&&(e[i]=new n),e=e[i]}return o()?{}:{obj:e,k:r(s.shift())}}function wV(e,t,n){var r=n_(e,t,Object),o=r.obj,s=r.k;o[s]=n}function OV(e,t){var n=n_(e,t),r=n.obj,o=n.k;if(r)return r[o]}var Vo;(function(e){e.keepRaw="keepRaw",e.replaceAnyway="replaceAnyway"})(Vo||(Vo={}));var kPe=Vo.replaceAnyway,DV={memoize:!1,memoizeFallback:!1,bindI18n:!1,bindI18nStore:!1,onParseError:Vo.replaceAnyway},Uf=function(){function e(){this.mem={}}return e.staticInit=function(t){e._i18nextInstance=t},e.prototype.init=function(t,n){var r=this;t===void 0&&(t=e._i18nextInstance);var o={};if(t!=null&&t.options&&(t.options.i18nFormat&&(o=t.options.i18nFormat),o.onParseError=t.options.onParseError,o.missingInterpolationHandler=t.options.missingInterpolationHandler,o.icuConfig=t.options.icuConfig,o.ignoreWarning=!!t.options.ignoreWarning),this.options=Object.assign(DV,n,o),this.formats=this.options.formats,t){var s=this.options,i=s.bindI18n,a=s.bindI18nStore,d=s.memoize;t.IntlMessageFormat=Di,this.IntlMessageFormat=Di,t.ICU=this,d&&(i&&t.on(i,function(){return r.clearCache()}),a&&t.store.on(a,function(){return r.clearCache()}))}this.options.localeData&&(Object.prototype.toString.apply(this.options.localeData)==="[object Array]"?this.options.localeData.forEach(function(c){return r.addLocaleData(c)}):this.addLocaleData(this.options.localeData))},e.prototype.addLocaleData=function(t){var n=Object.prototype.toString.apply(t)==="[object Array]"?t:[t];n.forEach(function(r){r&&r.locale&&Di.__addLocaleData(r)})},e.prototype.addUserDefinedFormats=function(t){this.formats=this.formats?Lc(Lc({},this.formats),t):t},e.prototype.checkMissingInterpolation=function(t,n,r,o,s){if((this.options.icuConfig||{}).strict===!1)return r;for(var i={},a=0,d=t;a<d.length;a++){var c=d[a];if(c.type===1){var u=c.value;if(!(r[u]!==null&&r[u]!==void 0)){if(typeof this.options.missingInterpolationHandler=="function"){var p=this.options.missingInterpolationHandler({key:s,text:n,locale:o,interpolation:{key:u,val:r[u]}});if(typeof p=="string"){i[u]=p;continue}}switch(this.options.onParseError){case Vo.keepRaw:throw new Error;case Vo.replaceAnyway:i[u]="{"+u+"}";continue}if(typeof this.options.onParseError=="function"){console.warn("[DEPRECATED] onParseError is deprecated, please use 'missingInterpolationHandler' instead of");var l=this.options.onParseError(n,u,o,this.IntlMessageFormat);if(l===!0)throw new Error;i[u]=typeof l=="string"?l:"{"+u+"}"}else this.options.ignoreWarning||console.warn('[Starling ICU Warning] The interpolation parameter "{'+u+'}" is missing in the translation text "'+n+'" for the key "'+s+`"
5
- Suggestions: check whether the value is null or undefined. Try using empty string '' as fallback! e.g I18n.t('key', { apple: count || '' })`),i[u]="{"+u+"}"}}}return Object.assign({},r,i)},e.prototype.parse=function(t,n,r,o,s,i){var a=i&&i.resolved&&i.resolved.res,d=this.options.memoize&&r+"."+o+"."+s.replace(/\./g,"###");!a&&n.thirdParamFallback&&n.fallbackText&&(t=n.fallbackText);var c;this.options.memoize&&(c=OV(this.mem,d));try{return c||(c=new this.IntlMessageFormat(t,r,this.formats,(this.options.icuConfig||{}).formatOptions),this.options.memoize&&(this.options.memoizeFallback||!i||a)&&wV(this.mem,d,c)),c.format(this.checkMissingInterpolation(c.getAst(),t,n||{},r,s))}catch{return t}},e.prototype.addLookupKeys=function(t,n,r,o,s){return t},e.prototype.clearCache=function(){this.mem={}},e.type="i18nFormat",e._i18nextInstance=null,e}(),MPe=Uf.name;var zf=function(){return zf=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},zf.apply(this,arguments)},kV="INCONTEXT-KEY-MATCH",Bc=/^\s*\[\[__starling_(\d+)_(.*)__\]\]\s*$/,MV=function(){return document.getElementById(kV)};typeof window<"u"&&(window.__STARLING_INCONTEXT_GLOBAL__HOOK__=zf({},window.__STARLING_INCONTEXT_GLOBAL__HOOK__||{payload:{}}));var r_={name:"inContext",type:"postProcessor",process:function(e,t,n,r){if(window&&MV()&&!n.__STARLING_INCONTEXT_FLAG__){window.__STARLING_INCONTEXT_GLOBAL_I18N__||(window.__STARLING_INCONTEXT_GLOBAL_I18N__=r),delete n.keySeparator,delete n.lngs;var o=0;if(t=t.toString(),Bc.test(t)){var s=t.match(Bc);s[0];var i=s[1],a=s[2];o=i,t=a}if(Bc.test(e)){var s=e.match(Bc);s[0];var i=s[1],a=s[2];e=a}return window.__STARLING_INCONTEXT_GLOBAL__HOOK__.payload[t]?o=window.__STARLING_INCONTEXT_GLOBAL__HOOK__.payload[t].push({options:n,default:e})-1:(window.__STARLING_INCONTEXT_GLOBAL__HOOK__.payload[t]=[{options:n,default:e}],o=0),"[[__starling_"+o+"_"+t+"__]]"}else return e}};function Yf(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function LV(e){if(Array.isArray(e))return Yf(e)}function d_(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o_(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,qV(r.key),r)}}function c_(e,t,n){return t&&o_(e.prototype,t),n&&o_(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function BV(e,t){var n=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=u_(e))||t&&e&&typeof e.length=="number"){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(d){throw d},f:o}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
6
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s,i=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var d=n.next();return i=d.done,d},e:function(d){a=!0,s=d},f:function(){try{i||n.return==null||n.return()}finally{if(a)throw s}}}}function GV(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function UV(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
7
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function s_(e){return LV(e)||GV(e)||u_(e)||UV()}function zV(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function qV(e){var t=zV(e,"string");return typeof t=="symbol"?t:t+""}function u_(e,t){if(e){if(typeof e=="string")return Yf(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Yf(e,t):void 0}}var qf=["AFN","EUR","ALL","DZD","USD","AOA","XCD","ARS","AMD","AWG","AUD","AZN","BSD","BHD","BDT","BBD","BYN","BZD","XOF","BMD","INR","BTN","BOB","BOV","BAM","BWP","NOK","BRL","BND","BGN","BIF","CVE","KHR","XAF","CAD","KYD","CLP","CLF","CNY","COP","COU","KMF","CDF","NZD","CRC","HRK","CUP","CUC","ANG","CZK","DKK","DJF","DOP","EGP","SVC","ERN","ETB","FKP","FJD","XPF","GMD","GEL","GHS","GIP","GTQ","GBP","GNF","GYD","HTG","HNL","HKD","HUF","ISK","IDR","XDR","IRR","IQD","ILS","JMD","JPY","JOD","KZT","KES","KPW","KRW","KWD","KGS","LAK","LBP","LSL","ZAR","LRD","LYD","CHF","MOP","MKD","MGA","MWK","MYR","MVR","MRO","MUR","XUA","MXN","MXV","MDL","MNT","MAD","MZN","MMK","NAD","NPR","NIO","NGN","OMR","PKR","PAB","PGK","PYG","PEN","PHP","PLN","QAR","RON","RUB","RWF","SHP","WST","STD","SAR","RSD","SCR","SLL","SGD","XSU","SBD","SOS","SSP","LKR","SDG","SRD","SZL","SEK","CHE","CHW","SYP","TWD","TJS","TZS","THB","TOP","TTD","TND","TRY","TMT","UGX","UAH","AED","USN","UYU","UYI","UZS","VUV","VEF","VND","YER","ZMW","ZWL","XBA","XBB","XBC","XBD","XTS","XXX","XAU","XPD","XPT","XAG"],p_={};for(ki=0;ki<qf.length;ki++)p_[qf[ki]]={style:"currency",currency:qf[ki]};var ki,FV={number:p_},Kf={LOGGER:"logger",LAMGUAGE_DETECTOR:"languageDetector",LAMGUAGE_TRANSFORMER:"languageTransformer",BACKEND:"backend"};function Xf(e){return function(t){return t.type===e}}function $f(e,t){var n=e;return(t||[]).map(function(r){n=r.process(e)||n}),n}var jV="zh-CN",VV={lng:jV,fallbackLng:["en-US"],inContext:!0},Ff=[Uf,r_],HV=function(){function e(t,n){if(d_(this,e),this._waitingToAddResourceBundle=[],t!=null&&t.copiedI18nextInstance){this.instance=t.copiedI18nextInstance;return}this._handlePlugins(n),this._handleConfigs(t),this.instance=Zb.createInstance(),this.instance.isInitialized=!1}return c_(e,[{key:"_handlePlugins",value:function(n){var r,o;((r=this.config)===null||r===void 0||(o=r.icuConfig)===null||o===void 0?void 0:o.open)===!1&&Ff.shift(),this.plugins=Array.isArray(n)?n.concat(Ff):Ff}},{key:"_handleConfigs",value:function(n){this.userLng=(n==null?void 0:n.lng)||null,this.config=Object.assign({},VV,n||{})}},{key:"language",get:function(){return(this.instance||{}).language}},{key:"createInstance",value:function(){var n=this;return new Promise(function(r,o){typeof window<"u"&&!window.CocosEngine&&n.config.inContext&&(n.config.postProcess=[].concat(["inContext"],n.config.postProcess||[]),window.__STARLING_DEVTOOLS_I18N=n.instance),n.plugins.map(function(a){a.name==="IES_INTL_ICU_PLUGIN"&&a.staticInit(n.instance),n.instance.use(a)});var s=n.config;n.config.formats=Object.assign({},n.config.formats,FV);var i=$f(s.lng,n.plugins.filter(Xf(Kf.LAMGUAGE_TRANSFORMER)));n.instance.init(Object.assign({},s,{lng:i,i18nFormat:Object.assign({},s.i18nFormat||{},{formats:n.config.formats})}),function(a,d){try{var c=BV(n._waitingToAddResourceBundle),u;try{for(c.s();!(u=c.n()).done;){var p,l=u.value;(p=n.instance).addResourceBundle.apply(p,s_(l))}}catch(f){c.e(f)}finally{c.f()}n._waitingToAddResourceBundle=[]}catch{}a||(n._updateLanguages(),r({t:d,err:a})),n.init=!0,o({t:d,err:a})})})}},{key:"_updateLanguages",value:function(){this.languages=this.instance?Array.from(new Set([this.instance.language].concat(s_(this.instance.languages)))):null}},{key:"getLanguages",value:function(){return this.languages}},{key:"changeLanguage",value:function(n,r){var o=this;this.config.lng=n,this.instance.changeLanguage(n,function(s,i){s||o._updateLanguages(),r&&r(s,i)})}},{key:"changeLanguageWithPromise",value:function(n){var r=this;return new Promise(function(o,s){r.config.lng=n,r.instance.changeLanguage(n,function(i,a){i&&s({err:i,t:a}),r._updateLanguages(),o({err:i,t:a})})})}},{key:"getDir",value:function(n){return this.instance.dir(n)}},{key:"t",value:function(n,r,o){var s=Array.isArray(n)?Array.from(n).map(function(){return" "}).join(""):Array(n.length).fill(" "),i=Object.assign({keySeparator:s,nsSeparator:s},r);return"thirdParamFallback"in this.config&&this.config.thirdParamFallback&&(i.thirdParamFallback=!0),this.instance.t(n,o,i)}},{key:"addResourceBundle",value:function(n,r,o,s,i){return this.instance.isInitialized?this.instance.addResourceBundle(n,r,o,s,i):(this._waitingToAddResourceBundle.push([n,r,o,!!s,!!i]),this.instance)}},{key:"cloneInstance",value:function(n,r){var o=this.instance.cloneInstance(n,r),s=new e({copiedI18nextInstance:o});return s.t=this.t.bind(s),s.config=this.config,s.plugins=this.plugins,s.languages=this.languages,s.init=o.isInitialized||!!this.init,s.userLng=this.userLng,o.on("initialized",function(){s.init=!0}),s}}])}(),i_="Starling_intl:",jf={warn:function(){for(var t,n="".concat(i_," [WARNING]"),r=arguments.length,o=new Array(r),s=0;s<r;s++)o[s]=arguments[s];(t=console).warn.apply(t,[n].concat(o))},error:function(){for(var t,n="".concat(i_," [ERROR]"),r=arguments.length,o=new Array(r),s=0;s<r;s++)o[s]=arguments[s];(t=console).error.apply(t,[n].concat(o))}};function YV(e){return new Promise(function(t,n){if(Array.isArray(e)||(e=Array.from(e)),e.length<=0)return t([]);var r=[];e=e.map(function(o,s){return function(){var i=typeof o=="function"?new Promise(o):Promise.resolve(o);i.then(function(a){r[s]=a,s===e.length-1?t(r):e[s+1]()},n)}}),e[0]()})}function Vf(e,t,n){return n?t?t(e):e:((!e||!e.then)&&(e=Promise.resolve(e)),t?e.then(t):e)}function KV(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}function XV(){}function $V(e,t){if(!t)return e&&e.then?e.then(XV):Promise.resolve()}function a_(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{return Promise.resolve(e.apply(this,t))}catch(r){return Promise.reject(r)}}}var Wf;(function(e){e.intl3rdParty="intl3rdParty",e.backend="backend",e.logger="logger",e.languageDetector="languageDetector",e.postProcessor="postProcessor",e.i18nFormat="i18nFormat",e["3rdParty"]="3rdParty"})(Wf||(Wf={}));var Qf=null,Mi=function(){function e(t){var n;d_(this,e),this.plugins=[],this.i18nInstance=(n=t==null?void 0:t.i18nInstance)!==null&&n!==void 0?n:new HV}return c_(e,[{key:"use",value:function(n){return this.plugins.includes(n)?(jf.warn("Plugin: ".concat(n.name," has beeninit installed.")),this):(this.plugins.push(n),this)}},{key:"init",value:function(n,r){try{var o=this;return o.ignoreWarning=n.ignoreWarning,o.i18nInstance._handleConfigs(n),o.i18nInstance._handlePlugins(o.plugins),Vf(KV(function(){return Vf(o.i18nInstance.createInstance(),function(s){var i=s.err,a=s.t,d=o.plugins.filter(function(c){return c.type===Wf.intl3rdParty});return Vf(YV(d.map(a_(function(c){if(!(!c||typeof c.init!="function")){var u=c.init instanceof Promise?c.init:a_(function(p){return Promise.resolve(c.init(p))});return $V(u(o))}}))),function(){return typeof r=="function"&&r(i,a),{err:i,t:a}})})},function(s){return jf.error("The instance init error: ".concat(s)),{err:s,t:function(a){return a}}}))}catch(s){return Promise.reject(s)}}},{key:"language",get:function(){return(this.i18nInstance||{}).language}},{key:"setLang",value:function(n,r){var o=$f(n,this.plugins.filter(Xf(Kf.LAMGUAGE_TRANSFORMER)));this.i18nInstance.changeLanguage(o,r)}},{key:"getLanguages",value:function(){return this.i18nInstance.getLanguages()}},{key:"setLangWithPromise",value:function(n){var r=$f(n,this.plugins.filter(Xf(Kf.LAMGUAGE_TRANSFORMER)));return this.i18nInstance.changeLanguageWithPromise(r)}},{key:"dir",value:function(n){return this.i18nInstance.getDir(n)}},{key:"t",value:function(n,r,o){var s=null;return typeof this>"u"?s=Qf:s=this,!s.ignoreWarning&&(!s.i18nInstance||!s.i18nInstance.init)?(jf.error("The instance has not been initialized: i18n.t('".concat(n,"'").concat(r?","+JSON.stringify(r):"",");")),o??(Array.isArray(n)?n[0]:n)):!n||typeof n=="string"&&!n.trim()?"":s.i18nInstance.t(n,r,o)}},{key:"addResourceBundle",value:function(n,r,o,s,i){return this.i18nInstance.addResourceBundle(n,r,o,s,i)}},{key:"cloneInstance",value:function(n){var r=this.i18nInstance.cloneInstance(n),o=new e({i18nInstance:r});return o.t=this.t.bind(o),o.plugins=this.plugins,o.ignoreWarning=this.ignoreWarning,o}}])}();Qf=new Mi;var Hf=Qf;Hf.t=Hf.t.bind(Hf);var Gc=class{static create(){let t=new Mi;return t.init({lng:"en",fallbackLng:"en",resources:{},i18nFormat:gc()}),yc(t)}constructor(){}},Q=Gc.create();function te(e,t,n){return{get description(){return n()},input:t,kind:e}}var Uc=[te("set_title","{title}",()=>Q.t("Pippit_canvas_command_desc_setcanvastitle",{},"设置画布标题")),te("set_cover","{cover}",()=>Q.t("Pippit_canvas_command_desc_setcanvascover",{},"设置画布封面")),te("set_global_bounds","{bounds}",()=>Q.t("Pippit_canvas_command_desc_setcanvasglobalbounds",{},"设置画布全局边界")),te("create_node","{node, assets?, autoCreateNodeAsset?}",()=>Q.t("Pippit_canvas_command_desc_creategenericnode",{},"创建通用节点及配套资产")),te("delete_nodes","{ids}",()=>Q.t("Pippit_canvas_command_desc_deletenodes",{},"删除节点并维护关联关系")),te("update_node_data","{id, patch}",()=>Q.t("Pippit_canvas_command_desc_updatenodedata",{},"更新节点业务数据")),te("set_node_style","{id, style}",()=>Q.t("Pippit_canvas_command_desc_setnodestyle",{},"更新节点样式")),te("update_asset","{assetId, contentPatch?, extraPatch?}",()=>Q.t("Pippit_canvas_command_desc_updatecanvasasset",{},"更新画布资产内容或扩展信息")),te("move_nodes","{ids, delta}",()=>Q.t("Pippit_canvas_command_desc_movenodes",{},"移动节点")),te("resize_node","{id, size}",()=>Q.t("Pippit_canvas_command_desc_resizenode",{},"缩放节点")),te("set_node_position","{id, position}",()=>Q.t("Pippit_canvas_command_desc_setnodeposition",{},"设置节点位置")),te("align_nodes","{ids, direction}",()=>Q.t("Pippit_canvas_command_desc_alignnodes",{},"对齐节点")),te("distribute_nodes","{ids, axis}",()=>Q.t("Pippit_canvas_command_desc_distributenodes",{},"等距分布节点")),te("arrange_nodes","{ids, layout, options?}",()=>Q.t("Pippit_canvas_command_desc_arrangenodes",{},"按指定布局排列节点")),te("auto_layout_nodes","{options?}",()=>Q.t("Pippit_canvas_command_desc_autolayoutnodes",{},"执行自动布局")),te("group_nodes","{ids}",()=>Q.t("Pippit_canvas_command_desc_groupnodes",{},"创建分组")),te("ungroup","{groupId}",()=>Q.t("Pippit_canvas_command_desc_ungroupnodes",{},"解散分组")),te("reparent","{nodeId, newParentId, index?}",()=>Q.t("Pippit_canvas_command_desc_reparentnode",{},"重新设置节点归属")),te("reorder_children","{groupId, orderedChildren}",()=>Q.t("Pippit_canvas_command_desc_reordergroupchildren",{},"调整分组内节点顺序")),te("set_group_collapsed","{groupId, collapsed}",()=>Q.t("Pippit_canvas_command_desc_setgroupcollapsed",{},"设置分组折叠状态")),te("create_edge","{edge}",()=>Q.t("Pippit_canvas_command_desc_createedge",{},"创建连线")),te("delete_edges","{ids}",()=>Q.t("Pippit_canvas_command_desc_deleteedges",{},"删除连线")),te("reconnect_edge","{id, patch}",()=>Q.t("Pippit_canvas_command_desc_reconnectedge",{},"重连连线")),te("update_edge_data","{id, patch}",()=>Q.t("Pippit_canvas_command_desc_updateedgedata",{},"更新连线数据")),te("update_snap_settings","{patch}",()=>Q.t("Pippit_canvas_command_desc_updatesnapsettings",{},"更新吸附设置")),te("set_snap_enabled","{enabled}",()=>Q.t("Pippit_canvas_command_desc_setsnapenabled",{},"启用或关闭吸附")),te("set_auto_layout_strategy","{strategy?}",()=>Q.t("Pippit_canvas_command_desc_setautolayoutstrategy",{},"设置默认自动布局策略")),te("invoke_command","{name, args?}",()=>Q.t("Pippit_canvas_command_desc_invokeregisteredcommand",{},"调用 SDK 已注册的业务命令")),te("delete","{nodeIds?, edgeIds?}",()=>Q.t("Pippit_canvas_command_desc_deletenodesoredges",{},"兼容方式删除节点或连线")),te("apply_patches","{patches}",()=>Q.t("Pippit_canvas_command_desc_applypatches",{},"特权级底层 patch 操作"))];function nt(e,t){var n;return((n=e.describe)==null?void 0:n.call(e,t))??e}function zr(e){var t;return((t=e.optional)==null?void 0:t.call(e))??e}function WV(e,t,n){if(!(t!=null&&t.length))return e;let r=new Set(t);return n&&r.add(e.rootCanvasId),{...e,assets:Object.fromEntries(Object.entries(e.assets).filter(([s])=>r.has(s)))}}function QV(e){return e.map(t=>t&&typeof t=="object"&&"kind"in t?String(t.kind):"<invalid>")}function JV(e){let t=new Set(["canvas.write"]);return e.includes("apply_patches")&&t.add("canvas.patch"),(e.includes("create_node")||e.includes("create_biz_node")||e.includes("invoke_command")||e.includes("update_asset"))&&t.add("canvas.asset.write"),[...t]}async function qr(e,t,n=["canvas.read"]){return hc(e,{canvasId:zo(e),operation:t},n)}function l_(e){let{runtime:t,schema:n}=e,r=e.mutationHandler??Ei;return{get_snapshot:{args:{assetIds:zr((()=>nt(n.array(nt(n.string(),"Canvas asset id")),"Canvas asset ids"))()),includeRootCanvas:zr(nt(n.boolean(),"Whether to include the root canvas asset in the returned snapshot"))},description:"Read the current canvas snapshot as CanvasDocument JSON, optionally filtered by asset ids.",async execute(s={}){let i=await qr(t,"get_snapshot");if(i)return se(i);let a=t.store.getState();return se(bn(t,{document:WV(a,s.assetIds,s.includeRootCanvas!==!1)}))}},get_asset:{args:{assetId:nt(n.string(),"Canvas asset id to read")},description:"Read one canvas asset from the current CanvasDocument.",async execute(s){let i=await qr(t,"get_asset",["canvas.read","canvas.asset.read"]);if(i)return se(i);let a=t.store.getState().assets[s.assetId];return a?se(bn(t,{asset:a})):se(Ct(t,"INVALID_ARGUMENT",`Unknown asset: ${s.assetId}`))}},apply_mutations:{args:{atomic:zr(nt(n.boolean(),"Merge all mutations into one SDK transaction")),checkpointBefore:zr(nt(n.boolean(),"Create a checkpoint before applying mutations")),dryRun:zr(nt(n.boolean(),"Validate tool routing without writing")),expectedRevision:zr(nt(n.number(),"Reject if the current document revision differs from this value")),intent:nt(n.string(),"Short semantic intent for the canvas transaction"),mutations:nt(n.array(n.unknown()),`Canvas mutations: ${Uc.map(({kind:s})=>s).join(", ")}. Use apply_patches only for privileged patch-level changes.`)},description:"Apply semantic CanvasDocument mutations. The tool enforces canvas permissions, read-only state, revision checks, and checkpoint creation.",async execute(s){if(!Array.isArray(s.mutations))return se(Ct(t,"INVALID_ARGUMENT","mutations must be an array"));let i=QV(s.mutations),a=await hc(t,{canvasId:zo(t),mutationKinds:i,operation:"apply_mutations"},JV(i));if(a)return se(a);if(mc(t))return se(Ct(t,"READ_ONLY","Canvas is read-only"));if(typeof s.expectedRevision=="number"&&t.store.getRevision()!==s.expectedRevision)return se(Ct(t,"REVISION_CONFLICT",`Expected revision ${s.expectedRevision}, current revision ${t.store.getRevision()}`));let d;if(s.checkpointBefore){let c=await hc(t,{canvasId:zo(t),operation:"create_checkpoint"},["canvas.checkpoint.create"]);if(c)return se(c);let u=bf(t,`before:${s.intent}`);await Uo(t).create(u),d=u.checkpointId}try{let c=await r({atomic:s.atomic,dryRun:s.dryRun,expectedRevision:s.expectedRevision,intent:s.intent,mutations:s.mutations,runtime:t});return se(bn(t,{...c,checkpointId:c.checkpointId??d}))}catch(c){return se(Ct(t,"INVARIANT_FAILED",c instanceof Error?c.message:String(c)))}}},create_checkpoint:{args:{reason:zr(nt(n.string(),"Why this checkpoint is being created"))},description:"Create an opencode checkpoint from the current CanvasDocument.",async execute(s={}){let i=await qr(t,"create_checkpoint",["canvas.read","canvas.checkpoint.create"]);if(i)return se(i);let a=bf(t,s.reason);return await Uo(t).create(a),se(bn(t,{checkpointId:a.checkpointId,documentHash:a.documentHash,revision:a.revision}))}},list_checkpoints:{args:{},description:"List opencode checkpoints for the current canvas.",async execute(){let s=await qr(t,"list_checkpoints",["canvas.read"]);if(s)return se(s);let i=await Uo(t).list(zo(t));return se(bn(t,{checkpoints:i.map(({document:a,...d})=>d)}))}},restore_checkpoint:{args:{checkpointId:nt(n.string(),"Checkpoint id returned by create_checkpoint")},description:"Restore a previously created opencode checkpoint into the canvas store.",async execute(s){let i=await qr(t,"restore_checkpoint",["canvas.write","canvas.checkpoint.restore"]);if(i)return se(i);if(mc(t))return se(Ct(t,"READ_ONLY","Canvas is read-only"));let a=await Uo(t).get(s.checkpointId);if(!a)return se(Ct(t,"CHECKPOINT_NOT_FOUND",`Unknown checkpoint: ${s.checkpointId}`));let d=Gb(t,a);return d.status==="aborted"?se(Ct(t,"INVARIANT_FAILED",d.reason)):se(bn(t,{result:d}))}},compare_checkpoint:{args:{checkpointId:nt(n.string(),"Checkpoint id to compare with current canvas state")},description:"Compare a checkpoint with the current CanvasDocument at asset granularity.",async execute(s){let i=await qr(t,"compare_checkpoint");if(i)return se(i);let a=await Uo(t).get(s.checkpointId);if(!a)return se(Ct(t,"CHECKPOINT_NOT_FOUND",`Unknown checkpoint: ${s.checkpointId}`));let d=t.store.getState(),u=[...new Set([...Object.keys(d.assets),...Object.keys(a.document.assets)])].filter(p=>JSON.stringify(d.assets[p])!==JSON.stringify(a.document.assets[p]));return se(bn(t,{changedAssetIds:u,checkpointRevision:a.revision,currentRevision:t.store.getRevision()}))}},get_permissions:{args:{},description:"Read effective opencode canvas permissions for the current canvas.",async execute(){let s=await qr(t,"get_permissions",["canvas.permission.read"]);return s?se(s):se(bn(t,{canvasId:zo(t),readOnly:mc(t)}))}}}}var Jf={error(...e){typeof console.error=="function"&&console.error(...e)},info(...e){typeof console.info=="function"&&console.info(...e)},log(...e){typeof console.log=="function"&&console.log(...e)},time(e){typeof console.time=="function"&&console.time(e)},timeEnd(e){typeof console.timeEnd=="function"&&console.timeEnd(e)},timeLog(e,...t){typeof console.timeLog=="function"&&console.timeLog(e,...t)},timeStamp(e){typeof console.timeStamp=="function"&&console.timeStamp(e)},trace(...e){typeof console.trace=="function"&&console.trace(...e)},warn(...e){typeof console.warn=="function"&&console.warn(...e)},profile(e){typeof console.profile=="function"&&console.profile(e)},profileEnd(e){typeof console.profileEnd=="function"&&console.profileEnd(e)}};var Zf=null;function zc(e,t){Zf==null||Zf.branch(e,t)}var Rn=null;function Li(e){return Rn==null||Rn.trackDisposable(e),e}function Bi(e){Rn==null||Rn.markAsDisposed(e)}function qc(e,t){Rn==null||Rn.setParent(e,t)}var Gi=class e{get isDisposed(){return this._isDisposed}dispose(){if(this._isDisposed){Jf.warn(new Error("DisposableStore has disposed.").stack);return}Bi(this),this._isDisposed=!0,this.clear()}clear(){if(this._toDispose.size===0)return;for(let n of this._toDispose)zc(this.constructor.name,n.constructor.name);let t=[];for(let n of this._toDispose)try{n.dispose()}catch(r){t.push(r)}if(this._toDispose.clear(),t.length>0)throw new AggregateError(t,"find error when dispose store.")}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself.");return qc(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||Jf.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}constructor(){this._toDispose=new Set,this._isDisposed=!1,Li(this)}};Gi.DISABLE_DISPOSED_WARNING=!1;var Ui=class{dispose(){Bi(this),zc(this.constructor.name,this._store.constructor.name),this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}constructor(){this._store=new Gi,Li(this),qc(this._store,this)}};var Fc=class{get value(){return this._value}isEmpty(){return this._value===void 0}dispose(){this._value&&(this._value.dispose(),this._value=void 0,Bi(this))}constructor(t){this._value=t,Li(this)}};function zi(e){return new Fc({dispose:e})}var Sxe=Symbol.for("canvas-sdk.glassbox.host");var qi=class{constructor(t){this._items=[];this._capacity=Math.max(1,Math.floor(t))}get size(){return this._items.length}get capacity(){return this._capacity}push(t){this._items.push(t);let n=this._items.length-this._capacity;n>0&&this._items.splice(0,n)}take(t){return t===void 0||t>=this._items.length?this._items.slice():t<=0?[]:this._items.slice(this._items.length-t)}clear(){this._items=[]}};var jc={debug:10,info:20,warn:30,error:40,silent:100};function em(e){return e<10?`0${e}`:`${e}`}function sH(e){return e<10?`00${e}`:e<100?`0${e}`:`${e}`}function iH(e){let t=new Date(e);return`${em(t.getHours())}:${em(t.getMinutes())}:${em(t.getSeconds())}.${sH(t.getMilliseconds())}`}var aH={debug:"DEBUG",info:"INFO ",warn:"WARN ",error:"ERROR"},dH={debug:"debug",info:"info",warn:"warn",error:"error"};function cH(e){let t=globalThis.console;if(!t||typeof t!="object")return;let n=t[dH[e]];return typeof n=="function"?n.bind(t):void 0}var tm={write(e){var r;let t=`${iH(e.time)} ${aH[e.level]} ${e.scope}: ${e.message}`,n=[];e.fields&&Object.keys(e.fields).length>0&&n.push(e.fields),e.error!==void 0&&n.push(e.error),(r=cH(e.level))==null||r(t,...n)}};var rm="__LOG_LEVEL__",f_="LOG_LEVEL",uH="info",pH=200;function nm(e){if(typeof e!="string")return;let t=e.trim().toLowerCase();if(t==="debug"||t==="info"||t==="warn"||t==="error"||t==="silent")return t;if(t==="warning")return"warn";if(t==="off"||t==="none")return"silent"}function lH(){let e=globalThis,t=nm(e[rm]);if(t!==void 0)return t;try{let n=e.localStorage;if(n){let r=nm(n.getItem(rm));if(r!==void 0)return r}}catch{}try{if(typeof process<"u"&&process.env){let n=nm(process.env[f_]);if(n!==void 0)return n}}catch{}}var om=class e{constructor(t,n){this._hub=t,this._scope=n}debug(t,n){this._log("debug",t,void 0,n)}info(t,n){this._log("info",t,void 0,n)}warn(t,n){this._log("warn",t,void 0,n)}error(t,n,r){this._log("error",t,n,r)}scope(t){return new e(this._hub,`${this._scope}.${t}`)}isEnabled(t){return this._hub.isEnabled(t)}_log(t,n,r,o){if(!this._hub.isEnabled(t))return;let s={time:Date.now(),level:t,scope:this._scope,message:n};o&&Object.keys(o).length>0&&(s.fields=o),r!==void 0&&(s.error=r),this._hub.emit(s)}},Fi=class extends Ui{constructor(n){super();this._counters={debug:0,info:0,warn:0,error:0};this._explicitLevel=n==null?void 0:n.level,this._useRuntimeLevel=(n==null?void 0:n.useRuntimeLevel)??!0,this._rootScope=(n==null?void 0:n.rootScope)??"app",this._sinks=new Set((n==null?void 0:n.sinks)??[tm]),this._buffer=new qi((n==null?void 0:n.bufferSize)??pH)}logger(n){return new om(this,n??this._rootScope)}setLevel(n){this._explicitLevel=n}getLevel(){return this._effectiveLevel()}isEnabled(n){return jc[n]>=jc[this._effectiveLevel()]}emit(n){if(this.isEnabled(n.level)){this._counters[n.level]++,this._buffer.push(n);for(let r of this._sinks)try{r.write(n)}catch{}}}addSink(n){return this._sinks.add(n),zi(()=>this._sinks.delete(n))}removeSink(n){this._sinks.delete(n)}clearSinks(){this._sinks.clear()}recent(n){return this._buffer.take(n)}stats(){return{level:this._effectiveLevel(),counters:{...this._counters},sinks:this._sinks.size,buffered:this._buffer.size}}dispose(){this._sinks.clear(),this._buffer.clear(),super.dispose()}_effectiveLevel(){if(this._explicitLevel!==void 0)return this._explicitLevel;if(this._useRuntimeLevel){let n=lH();if(n!==void 0)return n}return uH}};var sm;function im(){return sm||(sm=new Fi),sm}function m_(e){return im().logger(e)}var fH=m_();var mH=["brightness","cameraMotion","color","count","direction","durationMs","effect","goutu","jiaoduan","jingbie","leftright","novelStyle","promptTemplate","ratio","resolution","seed","updown"],hH=["brightness","color","direction","effect","goutu","jiaoduan","jingbie","leftright","updown"],gH=["cameraMotion","count","durationMs","novelStyle","promptTemplate","ratio","resolution","seed"],yH=new Set(mH),AH=new Set(hH),NTe=new Set(gH);function vH(e){return yH.has(e)}function SH(e){return AH.has(e)}function h_(e){return e==null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e)}function g_(e){return e===void 0?!0:!e||typeof e!="object"||Array.isArray(e)?!1:Object.entries(e).every(([t,n])=>vH(t)&&h_(n))}function y_(e){return e===void 0?!0:!e||typeof e!="object"||Array.isArray(e)?!1:Object.entries(e).every(([t,n])=>SH(t)&&h_(n))}var bH=new Set(["empty","generated","tool","uploaded"]);function IH(e){return typeof e=="string"&&bH.has(e)}function Vc(e){return e===void 0||IH(e)}function P(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function De(e){return typeof e=="string"}function _(e){return e===void 0||De(e)}function Oe(e){return typeof e=="number"&&Number.isFinite(e)}function Ce(e){return e===void 0||Oe(e)}function rt(e){return e===void 0||typeof e=="boolean"}function Xt(e){return Array.isArray(e)&&e.every(De)}function Xn(e){return e===void 0||P(e)}function Ho(e,t,n,r=480){let o=Oe(e)&&e>0?e:void 0,s=Oe(t)&&t>0?t:void 0,i=n&&n.w>0?n.w:void 0,a=n&&n.h>0?n.h:void 0,d=o??i,c=s??a;if(!(!d||!c||r<=0))return{w:r,h:Math.max(1,Math.round(r*c/d))}}var _H=new Set(["audioUrl","audio_url","coverPreviewUrl","cover_preview_url","coverUrl","coverURL","cover_url","downloadUrl","download_url","playUrl","play_url","playerInfo","player_info","posterUrl","poster_url","previewUrl","preview_url","sourceUrl","source_url","src","thumbnailUrl","thumbnail_url","uri","url","urlList","url_list","waveformUrl","waveform_url"]);function ji(e){return Array.isArray(e)?e.map(ji):P(e)?Object.fromEntries(Object.entries(e).filter(([t])=>!_H.has(t)).map(([t,n])=>[t,ji(n)])):e}function RH(e){if(!P(e))return;let t=e.uploadPath==="legacy"||e.uploadPath==="optimized"?e.uploadPath:void 0;return{...typeof e.id=="string"?{id:e.id}:{},...typeof e.type=="string"?{type:e.type}:{},...typeof e.assetId=="string"?{assetId:e.assetId}:{},...Xt(e.dataReferenceSelection)?{dataReferenceSelection:e.dataReferenceSelection}:{},...typeof e.edgeId=="string"?{edgeId:e.edgeId}:{},...P(e.nodeAssetExtra)?{nodeAssetExtra:ji(e.nodeAssetExtra)}:{},...typeof e.nodeAssetId=="string"?{nodeAssetId:e.nodeAssetId}:{},...typeof e.nodeAssetType=="string"?{nodeAssetType:e.nodeAssetType}:{},...typeof e.pippitAssetId=="string"?{pippitAssetId:e.pippitAssetId}:{},...typeof e.referenceSource=="string"?{referenceSource:e.referenceSource}:{},...typeof e.sourceNodeId=="string"?{sourceNodeId:e.sourceNodeId}:{},...typeof e.sourceNodeType=="string"?{sourceNodeType:e.sourceNodeType}:{},...t?{uploadPath:t}:{},...typeof e.label=="string"?{label:e.label}:{},...P(e.metadata)?{metadata:ji(e.metadata)}:{}}}function EH(e){Array.isArray(e.references)&&(e.references=e.references.map(RH).filter(t=>!!t))}var Yo={Generated:"generated",Tool:"tool",Uploaded:"uploaded"},A_={CanvasMentionText:"canvas-mention-text"};function Hc(e,t){if(t===void 0){delete e.generation;return}let n=ji(t);if(EH(n),Ye(e.generation)&&Ye(t)){et(e.generation,n);return}e.generation=n}function v_(e){let t=e==null?void 0:e.source;if(t==="generated"||t==="tool"||t==="uploaded")return t}function CH(e){return P(e)?_(e.id)&&_(e.type)&&_(e.assetId)&&(e.dataReferenceSelection===void 0||Xt(e.dataReferenceSelection))&&_(e.edgeId)&&Xn(e.nodeAssetExtra)&&_(e.nodeAssetId)&&_(e.nodeAssetType)&&_(e.pippitAssetId)&&_(e.referenceSource)&&_(e.sourceNodeId)&&_(e.sourceNodeType)&&_(e.label)&&Xn(e.metadata):!1}function PH(e){return e===void 0||Array.isArray(e)&&e.every(CH)}var xH={submitting:!0,running:!0,succeeded:!0,failed:!0};function TH(e){return e===void 0||De(e)&&xH[e]}function NH(e){return e===void 0?!0:P(e)?_(e.threadId)&&_(e.runId)&&_(e.target)&&TH(e.status)&&_(e.submittedAt)&&_(e.updatedAt)&&_(e.errorMessage)&&Xn(e.failureContext):!1}function wH(e){return e==null?!0:P(e)?_(e.styleId)&&_(e.stylePeBefore)&&_(e.stylePeAfter)&&_(e.stylePosition)&&_(e.modelKey)&&_(e.stylePe)&&_(e.style_id)&&_(e.title)&&_(e.style_pe_before)&&_(e.style_pe_after)&&_(e.style_position)&&_(e.version)&&_(e.model_key)&&_(e.style_pe)&&_(e.category):!1}function S_(e){return P(e)?_(e.agentName)&&Xn(e.submitRunClientExtra)&&_(e.generateId)&&_(e.taskId)&&_(e.artifactId)&&_(e.threadId)&&_(e.runId)&&_(e.source)&&_(e.runSource)&&_(e.outputName)&&_(e.outputAudioType)&&_(e.prompt)&&_(e.modelKey)&&Xn(e.audioConfig)&&y_(e.args)&&_(e.cameraMotion)&&Ce(e.count)&&Ce(e.durationMs)&&_(e.novelStyle)&&_(e.promptTemplate)&&_(e.ratio)&&Ce(e.videoRatioUpdatedAt)&&Ce(e.successfulGenerationCount)&&_(e.lastSuccessfulGenerationRunId)&&_(e.resolution)&&wH(e.styleSnapshot)&&Ce(e.seed)&&g_(e.params)&&PH(e.references)&&NH(e.state)&&Xn(e.snapshot)&&Xn(e.sceneSegmentation)&&_(e.createdAt):!1}function $n(e){return P(e)?_(e.name)&&_(e.variant):!1}var am=class{static create(){let t=new Mi;return t.init({lng:"en",fallbackLng:"en",resources:{},i18nFormat:gc()}),yc(t)}constructor(){}},O=am.create();function I_(){return O.t("Pippit_xyqcanvas_legacy_label_basic_image",{},"基础形象")}function um(){return O.t("Pippit_xyqcanvas_legacy_label_unnamed_scene",{},"未命名场景")}var OH=new Set([0,1,2,3,4]),DH=new Set(["user_created","ai_generated","novel_template_clone"]),kH=new Set([1,2]),MH=new Set(["audio","image","video"]),LH=["image","Generation","Config"].join("");function BH(e){return e===void 0||Oe(e)&&OH.has(e)}function GH(e){return e===void 0||typeof e=="string"&&DH.has(e)}function __(e){return e===void 0||Oe(e)&&kH.has(e)}function R_(e){return e===void 0||typeof e=="string"&&MH.has(e)}function st(e,t){let n=e[t];return typeof n=="string"?n:void 0}function dm(e,t){let n=e[t];return Oe(n)?n:void 0}function ot(e,t,n){n!==void 0&&(e[t]=n)}function Yc(e){if(!P(e))return;let t={};ot(t,"ttsProvider",dm(e,"ttsProvider")),ot(t,"age",st(e,"age")),ot(t,"gender",st(e,"gender")),ot(t,"speaker",st(e,"speaker")),ot(t,"description",st(e,"description")),ot(t,"audioAssetId",st(e,"audioAssetId")),ot(t,"audioPippitAssetId",st(e,"audioPippitAssetId")),ot(t,"audioName",st(e,"audioName")),ot(t,"audioNodeId",st(e,"audioNodeId"));let n=st(e,"audioSource");(n===Yo.Generated||n===Yo.Uploaded)&&ot(t,"audioSource",n),ot(t,"audioDurationMs",dm(e,"audioDurationMs")),ot(t,"voiceId",st(e,"voiceId"));let r=e.voice_type??e.voiceType;return __(r)&&ot(t,"voice_type",r),Object.keys(t).length>0?t:void 0}function Pt(e){return Yc(e==null?void 0:e.voiceInfo)}function UH(e){return typeof e=="string"&&e.trim().length>0}function b_(e){return(e==null?void 0:e.trim())||void 0}function E_(e){let t=P(e)?e:void 0,n=Yc(t==null?void 0:t.voiceInfo);return(n==null?void 0:n.voice_type)!==2?!1:[n.voiceId,n.audioAssetId,n.audioPippitAssetId].some(UH)}function C_(e){var r;let t=P(e)?e:void 0,n=Yc(t==null?void 0:t.voiceInfo);if((n==null?void 0:n.voice_type)===2)return((r=n.audioAssetId)==null?void 0:r.trim())||void 0}function P_(e){let t=P(e)?e:void 0,n=Yc(t==null?void 0:t.voiceInfo);if((n==null?void 0:n.voice_type)===2)return n.audioDurationMs}function zH(e){return e===void 0?!0:P(e)?Ce(e.ttsProvider)&&_(e.age)&&_(e.gender)&&_(e.speaker)&&_(e.voiceId)&&_(e.description)&&__(e.voice_type)&&_(e.audioAssetId)&&_(e.audioPippitAssetId)&&_(e.audioName)&&_(e.audioNodeId)&&_(e.audioSource)&&Ce(e.audioDurationMs):!1}function qH(e){return e===void 0?!0:P(e)?_(e.name)&&_(e.appearanceName)&&_(e.stageTag)&&_(e.label)&&rt(e.isMainImage)&&_(e.description)&&_(e.biography)&&(e.alias===void 0||Xt(e.alias))&&_(e.referName)&&rt(e.unpromptable)&&rt(e.isMainCharacter):!1}function x_(e){if(!P(e))return{};let{[LH]:t,...n}=e;return n}function T_(e,t){let n=x_(e);delete n.assetId,delete n.pippitAssetId,delete n.uploadPath;let r=b_(t.assetId),o=b_(t.pippitAssetId);return t.imageSource!==void 0&&(n.imageSource=t.imageSource),r&&(n.assetId=r),o&&(n.pippitAssetId=o),t.uploadPath==="optimized"&&(n.uploadPath="optimized"),n}function Ko(e){let{url:t,...n}=x_(e);return n}function Kc(e){return e===void 0?!0:P(e)?BH(e.imageSource)&&_(e.assetId)&&_(e.pippitAssetId)&&(e.uploadPath===void 0||e.uploadPath==="legacy"||e.uploadPath==="optimized")&&_(e.description)&&_(e.modify):!1}function FH(e){return e===void 0||Array.isArray(e)&&e.every(t=>Kc(t))}function N_(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function Fr(e,t,n){n!==void 0&&(e[t]=n)}var jH=new Set(["audioUrl","coverPreviewUrl","coverUrl","coverURL","downloadUrl","playerInfo","posterUrl","previewUrl","sceneUrls","sourceUrl","src","thumbnailUrl","uri","url","urlList","waveformUrl"]);function cm(e){return Array.isArray(e)?e.map(cm):P(e)?Object.fromEntries(Object.entries(e).filter(([t])=>!jH.has(t)).map(([t,n])=>[t,cm(n)])):e}function VH(e){let t=st({metadata:e},"metadata");if(t)try{let n=JSON.parse(t);if(!P(n))return t;let r=cm(n);return Object.keys(r).length?JSON.stringify(r):void 0}catch{return t}}function HH(e,t){if(!P(t))return;let n=N_(e);if(!n)return;let r={pippitAssetId:n};Fr(r,"assetId",st(t,"assetId")),Fr(r,"name",st(t,"name")),Fr(r,"order",dm(t,"order"));let o=t.type??void 0;if(R_(o))return Fr(r,"type",o),t.uploadPath==="optimized"&&(r.uploadPath="optimized"),Fr(r,"isMain",typeof t.isMain=="boolean"?t.isMain:void 0),Fr(r,"isDefault",typeof t.isDefault=="boolean"?t.isDefault:void 0),Fr(r,"metadata",VH(t.metadata)),r}function Xo(e){if(!P(e))return;let t=Object.entries(e).map(([n,r])=>{let o=HH(n,r);return o!=null&&o.pippitAssetId?[o.pippitAssetId,o]:void 0}).filter(n=>!!n);return t.length?Object.fromEntries(t):void 0}function YH(e){return e===void 0?!0:P(e)?Object.entries(e).every(([t,n])=>!N_(t)||!P(n)?!1:_(n.pippitAssetId)&&_(n.assetId)&&_(n.name)&&Ce(n.order)&&R_(n.type)&&(n.uploadPath===void 0||n.uploadPath==="legacy"||n.uploadPath==="optimized")&&rt(n.isMain)&&rt(n.isDefault)&&_(n.metadata)):!1}function Xc(e){return P(e)?_(e.nodeName)&&Ce(e.order)&&qH(e.basicInfo)&&_(e.useContext)&&(e.episodes===void 0||Xt(e.episodes))&&GH(e.createType)&&Kc(e.appearanceInfo)&&FH(e.referenceAppearances)&&zH(e.voiceInfo)&&(e.generation===void 0||S_(e.generation))&&YH(e.sourceInfos):!1}var z="biz/role",pm=z,O_="role";function XH(e){return P(e)&&!("pippitAssetId"in e)&&_(e.name)&&_(e.extra)&&rt(e.isCover)}function w_(e){return Xc(e)}function $t(e){if(!P(e))return;let{content:t}=e;return P(t)&&w_(t.data)?t.data:w_(t)?t:void 0}function jr(e){if(!P(e))return;let t=$t(e);if(t)return e.type=pm,e.content=t,e}var Vr={type:z,validate:XH,getDefaultSize:e=>({w:362,h:468})};var Vi="data-reference-selection",lm="roleVoiceReference";function xt(e){return typeof e=="string"?e.trim():""}function WH(e){return e==="audio"||e==="image"||e==="video"?e:void 0}function QH(e){let t=WH(e==null?void 0:e.type);return!t||t==="image"}function $o(e){var r,o,s;let t=Xo(e==null?void 0:e.sourceInfos),n=t?Object.entries(t):[];if(!n.length){let i=xt((r=e==null?void 0:e.appearanceInfo)==null?void 0:r.pippitAssetId);i&&n.push([i,{assetId:xt((o=e==null?void 0:e.appearanceInfo)==null?void 0:o.assetId)||void 0,isMain:!0,name:xt((s=e==null?void 0:e.basicInfo)==null?void 0:s.appearanceName)||void 0,order:0,pippitAssetId:i,type:"image"}])}return n.map(([i,a])=>[i,{...a,isMain:QH(a)?a.isMain:!1,pippitAssetId:i}]).sort((i,a)=>{let d=Number.isFinite(i[1].order)?Number(i[1].order):0,c=Number.isFinite(a[1].order)?Number(a[1].order):0;return d!==c?d-c:i[0].localeCompare(a[0])})}function D_(e,t){var a,d,c;let n=xt(t.pippitAssetId),r=$o(e);if(!n)return Object.fromEntries(r);let o=((a=r.find(([,u])=>u.isMain===!0))==null?void 0:a[0])||xt((d=e==null?void 0:e.appearanceInfo)==null?void 0:d.pippitAssetId),s=(c=r.find(([u])=>u===n))==null?void 0:c[1],i=r.filter(([u])=>u!==o&&u!==n);return Object.fromEntries([[n,{...s??{},...t,isMain:!0,order:0,pippitAssetId:n,type:"image"}],...i.map(([u,p],l)=>[u,{...p,isMain:!1,order:l+1,pippitAssetId:u}])])}function k_(e,t){let n=xt(t.assetId)||void 0,r=xt(t.pippitAssetId)||void 0,o={appearanceInfo:T_(e==null?void 0:e.appearanceInfo,{assetId:n,imageSource:t.imageSource,pippitAssetId:r})};if(r){let s={pippitAssetId:r,type:"image"},i=xt(t.name);n&&(s.assetId=n),i&&(s.name=i),typeof t.metadata=="string"&&(s.metadata=t.metadata),typeof t.isMain=="boolean"&&(s.isMain=t.isMain),Number.isFinite(t.order)&&(s.order=t.order),t.uploadPath&&(s.uploadPath=t.uploadPath),o.sourceInfos=D_(e,s)}return o}function M_(e){return e.map(xt).filter(Boolean).join(",")}function fm(e){let t=xt(e);return t?t.split(",").map(xt).filter(Boolean):null}function $c(e){return e.nodeAssetType===z||e.sourceNodeType===z}var Hr=/<(pippit-asset-id|node-asset)\b(?:[^>]*?\slabel="([^"]*)")?[^>]*>([^<]*)<\/\1>/g;var Wo=/<(pippit-asset-id|node-asset)\b(?:[^>]*?\slabel="([^"]*)")?[^>]*>([^<]*)<\/\1>|<bbox\s+pippit-asset-id="([^"]*)">\s*(\[[^\]]*\])\s*<\/bbox>/g,JH=/^<(pippit-asset-id|node-asset)\b([^>]*)>/i,mm=/([A-Za-z_:][A-Za-z0-9_:.-]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/g;function ZH(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function L_(e){return e.replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")}function B_(e){return/^[A-Za-z_:][A-Za-z0-9_:.-]*$/.test(e)}function Wc(e){return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).map(([t,n])=>[t.trim(),String(n??"").trim()]).filter(([t,n])=>B_(t)&&n))}function eY(e){let t={};mm.lastIndex=0;for(let n of e.matchAll(mm)){let r=String(n[1]??"").trim(),o=String(n[2]??n[3]??"");B_(r)&&(t[r]=L_(o))}return mm.lastIndex=0,t}function Qc(e){let t=JH.exec(e[0]??"");return eY((t==null?void 0:t[2])??"")}function tY(e,t={}){let n={...Wc(e),...Wc(t)};return Object.entries(n).map(([r,o])=>` ${r}="${ZH(o)}"`).join("")}function G_(e){return String(e??"").trim()}function U_({attributes:e,tagId:t,tagName:n}){let r=G_(t);return r?`<${n}${tY(e)}>${r}</${n}>`:""}function z_(e,t){return U_({attributes:t,tagId:e,tagName:"pippit-asset-id"})}function Jc(e,t){return U_({attributes:t,tagId:e,tagName:"node-asset"})}function hm(e){return String(e??"").replace(Hr,(t,n,r,o)=>G_(o)?t:"")}function Qo(e){return P(e)&&(e.episodes===void 0||Xt(e.episodes))}function q_(e){let t=new Set,n=[];for(let r of e??[]){let o=String(r).trim();!o||t.has(o)||(t.add(o),n.push(o))}return n}function nY(e){return P(e)&&_(e.tag)}function F_(e){return e===void 0||Array.isArray(e)&&e.every(nY)}var ue="biz/audio";function Tt(e){let t=typeof e=="string"?Number(e):e;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:void 0}function j_(e){let t=e==null?void 0:e.metadata;return P(t)?t:void 0}function Hi(e){let t=Tt(e);return t===void 0?void 0:t*1e3}function V_(e){let t=j_(e);return Tt(e==null?void 0:e.durationMs)??Tt(t==null?void 0:t.durationMs)??Tt(t==null?void 0:t.durationMS)??Tt(t==null?void 0:t.duration_ms)??Hi(t==null?void 0:t.durationSec)??Hi(t==null?void 0:t.duration_sec)??Hi(t==null?void 0:t.duration)??Hi(t==null?void 0:t.originalDuration)??Hi(t==null?void 0:t.original_duration)}function H_(e){let t=e,n=j_(e);return Tt(t==null?void 0:t.sizeBytes)??Tt(t==null?void 0:t.size_bytes)??Tt(t==null?void 0:t.size)??Tt(n==null?void 0:n.sizeBytes)??Tt(n==null?void 0:n.size_bytes)??Tt(n==null?void 0:n.size)}function rY(e){return e===void 0?!0:P(e)?Ce(e.startMs)&&Ce(e.endMs)&&Ce(e.currentTimeMs)&&Ce(e.playbackRate)&&rt(e.muted)&&rt(e.loop)&&Ce(e.volume):!1}function gm(e){return!P(e)||!_(e.assetId)||!_(e.pippitAssetId)||e.securityCheckScene!==void 0&&!Xt(e.securityCheckScene)||!F_(e.tagInfos)||!$n(e)||!Qo(e)||!Ce(e.durationMs)||!rY(e.playback)||!_(e.waveformKey)||!Vc(e.source)?!1:Object.keys(e).length===0||!!(e.assetId||e.pippitAssetId||e.generation||e.episodes)}var Wn={type:ue,validate:gm,getDefaultSize:()=>({w:362,h:218})};var L="biz/image";function Yi(e){return!(!P(e)||!$n(e)||!Qo(e))}function oY(e){var r,o;let t=e.naturalWidth??((r=e.metadata)==null?void 0:r.width),n=e.naturalHeight??((o=e.metadata)==null?void 0:o.height);return Ho(t,n,{w:420,h:326})??{w:480,h:373}}var En={type:L,validate:Yi,getDefaultSize:oY};var me="biz/image-panorama",sY="equirectangular",Y_=1,ANe=Object.freeze({fov:90,pitch:0,version:Y_,yaw:0});function iY(e){return e===void 0||e===sY}function aY(e){return!P(e)||e.version!==Y_?!1:typeof e.yaw=="number"&&Number.isFinite(e.yaw)&&e.yaw>=-180&&e.yaw<180&&typeof e.pitch=="number"&&Number.isFinite(e.pitch)&&e.pitch>=-85&&e.pitch<=85&&typeof e.fov=="number"&&Number.isFinite(e.fov)&&e.fov>=45&&e.fov<=110}function ym(e){return P(e)&&Yi(e)&&iY(e.projection)&&(e.viewState===void 0||aY(e.viewState))}function dY(e){var r,o;let t=e.naturalWidth??((r=e.metadata)==null?void 0:r.width),n=e.naturalHeight??((o=e.metadata)==null?void 0:o.height);return Ho(t,n,{w:320,h:180})??{w:480,h:270}}var Zc={type:me,validate:ym,getDefaultSize:dY};function K_(e){return e===L||e===me}var cY=new Set(["manual","image-operation","panorama-capture","panorama-grid","scene3d-capture-send"]);function Nt(e,t){return!(!P(e)||!De(e.id)||!e.id.trim()||e.type!=="image"&&e.type!=="video"||t&&e.type!==t||e.status!=="capturing"&&e.status!=="uploading"&&e.status!=="failed"||!_(e.cacheId)||e.cacheId!==void 0&&!e.cacheId.trim()||!_(e.fileName)||!_(e.mimeType)||!_(e.errorMessage)||!_(e.sourceKind)||e.sourceKind!==void 0&&!cY.has(e.sourceKind)||e.uploadPath!==void 0&&e.uploadPath!=="legacy"&&e.uploadPath!=="optimized"||e.size!==void 0&&(!Oe(e.size)||e.size<0)||e.cachedAt!==void 0&&!Oe(e.cachedAt))}function eu(e,t){return Nt(e,t)?e.status==="capturing"||e.status==="uploading":!1}var he="biz/scene",Am=he;var Yr={w:420,h:372};function uY(e){return P(e)&&!("pippitAssetId"in e)&&_(e.name)&&_(e.extra)&&rt(e.isCover)}function X_(e){return Xc(e)}function tu(e){if(!P(e))return;let{content:t}=e;return P(t)&&X_(t.data)?t.data:X_(t)?t:void 0}function $_(e){if(!P(e))return;let t=tu(e);if(t)return e.type=Am,e.content=t,e}var Ki={type:he,validate:uY,getDefaultSize:()=>({...Yr})};var M="biz/video";function vm(e){return!(!P(e)||!$n(e)||!Qo(e))}function pY(e){var r,o;let t=(r=e.metadata)==null?void 0:r.width,n=(o=e.metadata)==null?void 0:o.height;return Ho(t,n,{w:420,h:236})??{w:480,h:270}}var Cn={type:M,validate:vm,getDefaultSize:pY};var lY=new Set([z,he]);function fY(){return new Set([O.t("Pippit_xyqcanvas_legacy_label_role",{},"角色"),O.t("Pippit_xyqcanvas_legacy_label_scene",{},"场景"),O.t("Pippit_xyqcanvas_legacy_label_basic_image",{},"基础形象"),O.t("Pippit_xyqcanvas_legacy_label_default_image",{},"默认形象"),O.t("Pippit_xyqcanvas_legacy_label_master_image",{},"主设定形象"),O.t("Pippit_xyqcanvas_legacy_label_no_character_name_yet",{},"暂无角色名"),O.t("Pippit_xyqcanvas_legacy_label_no_image_name_yet",{},"暂无形象名称"),O.t("Pippit_xyqcanvas_legacy_label_unnamed_role",{},"未命名角色"),O.t("Pippit_xyqcanvas_legacy_label_unnamed_image_name",{},"未命名形象名"),O.t("Pippit_xyqcanvas_legacy_label_unnamed_scene",{},"未命名场景")])}function mY(){return new Set([O.t("Pippit_xyqcanvas_legacy_label_no_image_name_yet",{},"暂无形象名称"),O.t("Pippit_xyqcanvas_legacy_label_unnamed_image_name",{},"未命名形象名"),O.t("Pippit_xyqcanvas_legacy_label_unnamed_scene",{},"未命名场景")])}function ru(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Xi(e){if(e){if(typeof e=="string")try{return Xi(JSON.parse(e))}catch{return}return ru(e)?e:void 0}}function Pn(e){let t=e==null?void 0:e.trim();return t||void 0}function $i(e){if(ru(e))return Pn(typeof e.name=="string"?e.name:void 0)}function Sm(e){let t=e==null?void 0:e.replace(/_\d+$/,"");return!!(t&&fY().has(t))}function nu(e){let t=e==null?void 0:e.replace(/_\d+$/,"");return!!(t&&mY().has(t))}function W_(e,t){let n=e==null?void 0:e[t];return typeof n=="string"?n:void 0}function Q_(e){let t=Xi(e);if(!t)return!0;let n=Xi(t.basicInfo),r=Pn(W_(n,"appearanceName"));if(r)return nu(r);let o=Pn(W_(t,"nodeName"));return!o||nu(o)}function Wi(e){if(!ru(e))return;let t=Xi(e.data);if(e.type===be)return Pn(typeof(t==null?void 0:t.title)=="string"?t.title:void 0);let n=$i(t);return typeof e.type=="string"&&lY.has(e.type)&&Sm(n)?void 0:n}function hY(e){switch(e){case L:return O.t("Pippit_xyqcanvas_legacy_label_picture",{},"图片");case me:return O.t("Pippit_xyqcanvas_legacy_label_panorama",{},"全景图");case M:return O.t("Pippit_xyqcanvas_legacy_title_video",{},"视频");default:return}}function gY(e,t){let n=Xi(t);if(n&&e===M)return Pn(typeof n.title=="string"?n.title:void 0)}function J_(e){if(ru(e))return Wi(e)??gY(e.type,e.data)??hY(e.type)}var Ie="biz/text",Z_={overflow:"wrap",padding:28,verticalAlign:"top"};var yY=new Set(["top","middle","bottom"]),AY=new Set(["clip","wrap","auto-height"]);function vY(e){if(e===void 0)return!0;if(!P(e))return!1;let{verticalAlign:t,overflow:n,padding:r}=e;return!(t!==void 0&&(!De(t)||!yY.has(t))||n!==void 0&&(!De(n)||!AY.has(n))||r!==void 0&&(!Oe(r)||r<0))}function bm(e){return!(!P(e)||"pippitAssetId"in e||!$n(e)||e.plainText!==void 0&&!De(e.plainText)||e.markdownText!==void 0&&!De(e.markdownText)||!_(e.placeholder)||!vY(e.block)||e.plainText===void 0&&e.content!==void 0||e.content!==void 0&&!P(e.content))}var Qn={type:Ie,validate:bm,getDefaultSize:e=>{var t;return{w:420,h:((t=e.block)==null?void 0:t.overflow)==="auto-height"?64:180}}};function Kr(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!=null))}function Ke(e,t){let n=e==null?void 0:e[t];return typeof n=="string"?n:void 0}function ou(e){return typeof e=="object"&&e!==null}function su(e){return ou(e==null?void 0:e.data)?e.data:{}}function Jo(e,t){var a;let n=su(t),r=t!=null&&t.id?(a=e.assets)==null?void 0:a[t.id]:void 0,o=ou(r)?r.content:void 0,s=ou(o)?o:void 0,i=ou(s==null?void 0:s.data)?s.data:s;return i||n}var SY=new Set(["audiourl","coverpreviewurl","coverurl","downloadurl","imageurl","playerinfo","posterurl","previewinfo","previewurl","sceneurls","sourceimageurl","sourceurl","src","thumbnailurl","uri","url","urls","urllist","videourl","waveformurl"]);function Em(e){return Array.isArray(e)?e.map(t=>Em(t)):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).flatMap(([t,n])=>SY.has(t.replaceAll("_","").toLowerCase())?[]:[[t,Em(n)]]))}function Jn(e){let t=e.pippitAssetId?Em(e):e;return Kr(t)}function Zo(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Im(e){let t=(Array.isArray(e)?e:e?[e]:[]).map(n=>typeof n=="string"?n.trim():"").filter(Boolean);return t.length?t:void 0}function _m(e){if(!Zo(e.localUploadTask))return;let t=Ke(e.localUploadTask,"uploadPath");if(e.uploadPath!=="optimized"&&t!=="optimized")return;let n=Ke(e.localUploadTask,"status");return n==="capturing"||n==="uploading"?"uploading":void 0}function bY(e,t){if(Nt(e,"image"))return t==="optimized"||e.uploadPath==="optimized"?"uploading":void 0}function Qi(e){if(!Zo(e))return"";if(typeof e.text=="string")return e.text;if(e.type==="hardBreak")return`
8
- `;if(e.type==="table")return Array.isArray(e.content)?e.content.map(Qi).filter(Boolean).join(`
9
- `):"";if(e.type==="tableRow")return Array.isArray(e.content)?e.content.map(Qi).join(" "):"";if(e.type==="tableCell"||e.type==="tableHeader")return Array.isArray(e.content)?e.content.map(Qi).filter(Boolean).join(`
10
- `):"";let t=Array.isArray(e.content)?e.content.map(Qi).filter(Boolean):[];return t.length===0?"":e.type==="doc"||e.type==="bulletList"||e.type==="orderedList"?t.join(`
11
- `):t.join("")}function nR(e){return(typeof e.plainText=="string"?e.plainText.trim():"")||Qi(e.content).trim()}function IY(e,t,n){return Wi(n??e)??$i(t)??Pn(Ke(t,"title"))??O.t("Pippit_xyqcanvas_legacy_title_text",{},"文本")}function eR(e,t){return Wi(t)??J_(e)??e.id}function _Y(e){var r;let t=$i(e);if(t)return t;let n=(r=e.assetId)==null?void 0:r.trim();return n||O.t("Pippit_xyqcanvas_legacy_label_audio",{},"音频")}function Rm(e){let t=Pn(e);return t&&!Sm(t)?t:void 0}function tR(e){let t=Pn(e);return t&&!nu(t)?t:void 0}function RY(e,t){if(!e)return t;if(!t||t===e)return e;let n=`${e}-`,r=t.startsWith(n)?t.slice(n.length):t;return r?`${e}-${r}`:e}function EY(e,t,n,r){let o=Rm(Wi(r??e))??Rm(Ke(n,"name"))??Rm(t.nodeName),s=tR(Ke(n,"appearanceName"))??(e.type===he?tR(t.nodeName):void 0);return{label:RY(o,s)??e.id,subjectName:o,variantName:s}}function CY(e,t,n,r,o,s){let i=Zo(t.appearanceInfo)?t.appearanceInfo:void 0,a=Zo(t.basicInfo)?t.basicInfo:void 0,d=Ke(i,"assetId"),c=Ke(i,"pippitAssetId"),u=Ke(i,"uploadPath"),p=u==="legacy"||u==="optimized"?u:void 0,{label:l,subjectName:f,variantName:h}=EY(e,t,a,r),m=e.type===z?C_(t):void 0,g=e.type===z?P_(t):void 0;return Jn({id:e.id,type:"image",assetId:d,...n,nodeAssetId:e.id,nodeAssetType:e.type,sourceNodeType:e.type,content:o,pippitAssetId:c,uploadPath:p,uploadStatus:bY(s,p),label:l,metadata:Kr({audioVoiceAssetId:m,audioVoiceDurationMs:g,hasAudioVoice:e.type===z?E_(t):void 0,name:l===e.id?void 0:l,subjectName:f,variantName:h})})}function iu(e,t,n={}){var i,a,d,c,u;if(!e)return;let r=su(e),o=Zo(r.metadata)?r.metadata:{},s=t?{edgeId:t.id,referenceSource:"canvas-edge",sourceNodeId:t.source}:void 0;if(K_(e.type))return Jn({id:e.id,type:"image",assetId:r.assetId,...s,nodeAssetId:e.id,nodeAssetType:e.type,sourceNodeType:e.type,content:n.content,mediaSource:Ke(r,"source"),pippitAssetId:r.pippitAssetId,securityCheckScene:Im(r.securityCheckScene),uploadPath:r.uploadPath,uploadStatus:_m(r),label:eR(e,n.displayNode),metadata:Kr({height:r.naturalHeight??((i=r.metadata)==null?void 0:i.height),name:$i(r)??((a=r.metadata)==null?void 0:a.name)??r.caption,sizeBytes:r.sizeBytes??o.sizeBytes??o.size,width:r.naturalWidth??((d=r.metadata)==null?void 0:d.width)})});switch(e.type){case z:case he:return CY(e,r,s,n.displayNode,n.content,n.localUploadTask);case M:return Jn({id:e.id,type:"video",assetId:r.assetId,...s,nodeAssetId:e.id,nodeAssetType:e.type,sourceNodeType:e.type,content:n.content,coverPreviewKey:r.coverPreviewKey,mediaSource:Ke(r,"source"),pippitAssetId:r.pippitAssetId,securityCheckScene:Im(r.securityCheckScene),uploadPath:r.uploadPath,uploadStatus:_m(r),label:eR(e,n.displayNode),metadata:Kr({width:o.width,height:o.height,durationMs:o.durationMs??o.durationMS,durationSec:o.durationSec??o.duration,fps:o.fps,sizeBytes:o.sizeBytes??o.size})});case ue:return Jn({id:e.id,type:"audio",assetId:r.assetId,...s,nodeAssetId:e.id,nodeAssetType:e.type,sourceNodeType:e.type,content:n.content,pippitAssetId:r.pippitAssetId,securityCheckScene:Im(r.securityCheckScene),uploadPath:r.uploadPath,uploadStatus:_m(r),label:_Y(r),metadata:Kr({durationMs:r.durationMs??((c=r.metadata)==null?void 0:c.durationMs)??((u=r.metadata)==null?void 0:u.durationMS),durationSec:r.durationSec??o.durationSec??o.duration,sizeBytes:r.sizeBytes??o.sizeBytes??o.size})});case Ie:return Jn({id:e.id,type:"text",...s,sourceNodeType:e.type,displayLabel:IY(e,r,n.displayNode),label:nR(r)});default:return}}function au(e,t){var s;if(!t)return;let n=Jo(e,t),r=(s=e.assets)==null?void 0:s[t.id],o=Zo(r)?Ke(r,"pippitAssetId"):void 0;return{...t,data:o&&!Ke(n,"pippitAssetId")?{...n,pippitAssetId:o}:n}}var rR="roleReferenceNodeId";function NY(e){return typeof e=="string"?e.trim():""}function Ji(e){return Array.from(new Set([e.nodeAssetId,e.sourceNodeId,e.pippitAssetId,e.id].map(NY).filter(Boolean)))}function oR(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function sR(e){return String(e??"").trim()}function du(e,t){let n=sR(t);return n?`${e}:${n}`:""}function cu(e){return du("node",e)}function uu(e){var t;return cu(e.sourceNodeId)||cu((t=e.metadata)==null?void 0:t[rR])||du("pippit_asset",e.pippitAssetId)||du("asset",e.assetId)||du("reference",e.id)}function wY(e){return typeof e=="string"?cu(e):oR(e)?e.kind==="node"?cu(e.nodeId):e.kind==="reference"?sR(e.referenceKey):"":""}function Zi(e){if(!(!oR(e)||!Array.isArray(e.inputOrder)))return e.inputOrder}function pu(e){if(!Array.isArray(e))return[];let t=[],n=new Set;return e.forEach(r=>{let o=wY(r);!o||n.has(o)||(n.add(o),t.push(o))}),t}function Cm(e){return e.startsWith("node:")}function OY(e){return{kind:"reference",referenceKey:e}}function iR(e,t){let n=pu(e);if(!n.length)return{changed:!1};let r=[],o=new Set;t.forEach(d=>{let c=uu(d);!c||!Cm(c)||o.has(c)||(o.add(c),r.push(c))});let s=n.some(Cm),i=n.filter(d=>!Cm(d)||o.has(d));return s&&r.forEach(d=>{i.includes(d)||i.push(d)}),{changed:i.length!==n.length||i.some((d,c)=>d!==n[c]),inputOrder:i.length?i.map(OY):void 0}}function aR(e,t){let n=pu(t);if(!n.length)return[...e];let r=new Map(n.map((i,a)=>[i,a])),o=[],s=[];return e.forEach((i,a)=>{let d=uu(i),c=d?r.get(d):void 0;if(c===void 0){s.push(i);return}o.push({index:a,rank:c,reference:i})}),o.sort((i,a)=>i.rank-a.rank||i.index-a.index),[...o.map(({reference:i})=>i),...s]}var DY="xyqLocalImageUploadTask";function dR(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function ea(e){var n,r;let t=(r=dR((n=dR(e))==null?void 0:n.extra))==null?void 0:r[DY];return Nt(t,"image")?t:void 0}function Xr(e){return typeof e=="string"?e.trim():""}function lu(e,t){if(!$c(t))return t;let n=Pt(t.content),r=Xr(n==null?void 0:n.audioNodeId);if(!r)return t;let o=x(e).nodes[r];if(!o||o.type!==ue)return t;let s=Jo(e,o),i=Xr(s==null?void 0:s.pippitAssetId);if(!i)return t;let a=v_(s==null?void 0:s.generation)??(n==null?void 0:n.audioSource),d=Xr(s==null?void 0:s.src),c=H_(s);return{...t,metadata:{...t.metadata??{},...c!==void 0?{audioVoiceSizeBytes:c}:{},[lm]:{assetId:Xr(s==null?void 0:s.assetId)||void 0,audioNodeId:r,...a?{audioSource:a}:{},durationMs:V_(s),name:Xr(s==null?void 0:s.name)||Xr(n==null?void 0:n.audioName)||Xr(s==null?void 0:s.assetId)||void 0,pippitAssetId:i,...c!==void 0?{sizeBytes:c}:{},...d?{url:d}:{}}}}}var Pm=[L,me,z,he],Vwe=new Set(Pm),Hwe=new Set([...Pm,ue]),Ywe=new Set([...Pm,M,ue]);function kY(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function MY(e,t){var r;let n=t!=null&&t.id?(r=e.assets)==null?void 0:r[t.id]:void 0;if(!(!kY(n)||!("content"in n)))return n.content??void 0}function LY(e,t){let n=pu(t);if(!n.length)return;let r=[],o=new Set;if(e.forEach(s=>{let i=uu(s);!i||o.has(i)||(o.add(i),r.push(i))}),r.length===n.length)return n.every(s=>o.has(s))?t:void 0}function fu(e,t){let n=x(e),r=n.nodes[t],o=Zi(r==null?void 0:r.data)??Zi(Jo(e,r)),s=Object.values(n.edges).filter(i=>i.target===t).map(i=>{let a=n.nodes[i.source],d=iu(au(e,a),i,{content:MY(e,a),displayNode:a,localUploadTask:ea(a!=null&&a.id?e.assets[a.id]:void 0)});return d?lu(e,d):void 0}).filter(i=>!!i);return aR(s,LY(s,o))}var mu="generation.normalizeInputOrder";function es(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function BY(e){return e===L||e===M}function cR(e,t){var o;if(!es(e)||!Zi(e))return{changed:!1,data:e};let n=iR(e.inputOrder,t);if(!n.changed)return{changed:!1,data:e};let r={...e};return(o=n.inputOrder)!=null&&o.length?r.inputOrder=n.inputOrder:delete r.inputOrder,{changed:!0,data:r}}function GY(e){let t=x(e),n=!1;return Object.values(t.nodes).forEach(r=>{if(!BY(r.type))return;let o=fu(e,r.id),s=cR(r.data,o);s.changed&&es(r.data)&&es(s.data)&&(et(r.data,s.data),n=!0);let i=e.assets[r.id];if(!es(i)||!es(i.content))return;let a=cR(i.content,o);a.changed&&es(a.data)&&(et(i.content,a.data),n=!0)}),n}function UY(e){e.transact(t=>{GY(t)},{intent:mu,undoable:!1,source:"local"})}function uR(e){return e.subscribe(({transaction:t})=>{t.intent!==mu&&UY(e)})}function xm(e){return String(e??"").trim()}function pR(e){let t=xm(e.type),n=xm(e.sourceNodeType),r=xm(e.nodeAssetType);return t==="audio"||n===ue||r===ue?"audio":t==="video"||n===M||r===M?"video":"image"}function Be(e){return String(e??"").trim()}var zY=new RegExp("^(\\u56fe\\u7247|\\u89c6\\u9891|\\u97f3\\u9891|\\u6587\\u4ef6)\\s+(\\d+)$");function $r(e){return Be(e).replace(zY,"$1$2")}var qY="camera-motion:";function FY(e){return Be(e).startsWith(qY)}function lR(e,t,n){let r=Be(e);if(!r)return"";let o=$r(t),s=Wc(n);return o&&FY(r)&&(s.label=o),z_(r,s)}function fR(e,t){let n=Be(e);return Jc(n,t)}var jY=String.fromCharCode(35270,39057),mR=/【\s*@?\s*(图片|图|视频)\s*(\d+)\s*】|@\s*(图片|图|视频)\s*(\d+)|(图片|图|视频)\s*(\d+)/g;function VY(e){return Be(e.sourceNodeId)||Be(e.nodeAssetId)||Be(e.pippitAssetId)||Be(e.id)||Be(e.name)}function HY({mentionItems:e,mentionSourceItems:t}){let n=[],r=new Set,o=s=>{s==null||s.forEach(i=>{let a=VY(i);!a||r.has(a)||(r.add(a),n.push(i))})};return o(e),Object.values(t??{}).forEach(o),n}function YY(e){return e===jY?"video":"image"}function KY(e,t){return t==="video"?e.type==="video":e.type==="image"||e.type==="character"}function XY(e,t,n){if(!Number.isInteger(n)||n<=0)return;let r=e.filter(o=>KY(o,t))[n-1];return r?{...r,label:r.name}:void 0}function $Y(e,t){let n=$r(t.replace(/[【】@]/g,"").trim());if(!n)return;let r=e.find(o=>[$r(o.name),$r(o.originalName),$r(o.displayName)].some(s=>s==null?void 0:s.includes(n)));return r?{...r,label:r.name}:void 0}function WY(e){if(!e)return"";let t=Be(e.nodeAssetId)||Be(e.sourceNodeId);if(t)return fR(t);let n=Be(e.pippitAssetId)||Be(e.id);return n?lR(n,$r(e.label)):""}function hR(e,t){return mR.lastIndex=0,e.replace(mR,(n,...r)=>{let[o,s,i,a,d,c]=r,u=Be(o||i||d),p=Be(s||a||c),l=Number.parseInt(p,10),f=XY(t,YY(u),l),h=$Y(t,n);return WY(f??h)||n})}function gR(e,t={}){let n=String(e??""),r=HY(t);if(!n||!r.length)return{changed:!1,value:n};let o=!1,s=0,i=[];Hr.lastIndex=0;for(let c of n.matchAll(Hr)){let u=c.index??0,p=c[0]||"",l=n.slice(s,u),f=hR(l,r);o||=f!==l,i.push(f,p),s=u+p.length}Hr.lastIndex=0;let a=n.slice(s),d=hR(a,r);return o||=d!==a,i.push(d),{changed:o,value:o?i.join(""):n}}var hu="generation.normalizePromptMentionContent";function Wr(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function wt(e){return String(e??"").trim()}function QY(e){return wt(e)===A_.CanvasMentionText}function JY(e){let t=wt(e);return t==="video"||t==="audio"||t==="text"?t:"image"}function ZY(e,t){let n=wt(e.label)||wt(e.sourceNodeId)||wt(e.nodeAssetId)||wt(e.pippitAssetId)||wt(e.id)||`material-${t+1}`;return{id:wt(e.id)||wt(e.sourceNodeId)||wt(e.nodeAssetId)||wt(e.pippitAssetId)||n,name:n,originalName:n,type:pR(e),nodeAssetId:e.nodeAssetId||e.sourceNodeId,nodeAssetType:e.nodeAssetType,pippitAssetId:e.pippitAssetId,sourceNodeId:e.sourceNodeId,sourceNodeType:e.sourceNodeType}}function eK(e){return(e??[]).map((t,n)=>ZY({...t,type:JY(t.type)},n))}function tK(e,t={}){if(!Wr(e)||!Wr(e.generation))return{changed:!1,data:e};let n=e.generation;if(!QY(n.promptContentFormat))return{changed:!1,data:e};let r={...n};delete r.promptContentFormat;let o=typeof n.prompt=="string"?n.prompt:void 0;if(o===void 0)return{changed:!0,data:{...e,generation:r}};let s=eK(t.mentionReferences),i=gR(o,{mentionItems:s});return r.prompt=i.value,{changed:!0,data:{...e,generation:r}}}function yR(e){return e===L||e===M}function AR(e,t,n){return tK(n,{mentionReferences:fu(e,t)})}function nK(e){let t=x(e),n=!1;return Object.values(t.nodes).forEach(r=>{if(!yR(r.type)||!Wr(r.data))return;let o=AR(e,r.id,r.data);o.changed&&Wr(o.data)&&(et(r.data,o.data),n=!0)}),Object.entries(e.assets).forEach(([r,o])=>{if(!Wr(o)||!Wr(o.content))return;let s=t.nodes[r],i=typeof o.type=="string"?o.type:s==null?void 0:s.type;if(!yR(i))return;let a=AR(e,r,o.content);a.changed&&Wr(a.data)&&(et(o.content,a.data),n=!0)}),n}function rK(e){e.transact(t=>{nK(t)},{intent:hu,undoable:!1,source:"local"})}function vR(e){return e.subscribe(({transaction:t})=>{t.intent!==hu&&rK(e)})}var ta="link",oK=new Set(["http:","https:","mailto:","tel:"]),sK=/^[a-z][a-z\d+.-]*:/i;function iK(e){return sK.test(e)}function aK(e){return e.startsWith("/")||e.startsWith("#")||e.startsWith("?")}function gu(e){if(typeof e!="string")return null;let t=e.trim();if(!t||aK(t))return null;let n=iK(t)?t:`https://${t}`;try{let r=new URL(n);return!oK.has(r.protocol)||(r.protocol==="http:"||r.protocol==="https:")&&!r.hostname?null:n}catch{return null}}function SR(e){return e.replace(/[()\s]/g,t=>encodeURIComponent(t))}function bR(e,t){let n=gu(t);return n?`[${e}](${SR(n)})`:e}function dK(e){return e.type==="paragraph"||e.type==="heading"||e.type==="listItem"||e.type==="bulletList"||e.type==="orderedList"||e.type==="blockquote"||e.type==="table"||e.type==="tableRow"}function ts(e){var t,n,r;if(!e)return"";if(typeof e.text=="string"){let o=(r=(n=(t=e.marks)==null?void 0:t.find(s=>s.type===ta))==null?void 0:n.attrs)==null?void 0:r.href;return bR(e.text,o)}return e.type==="table"?(e.content??[]).map(ts).filter(Boolean).join(`
12
- `):e.type==="tableRow"?(e.content??[]).map(ts).join(" "):e.type==="tableCell"||e.type==="tableHeader"?(e.content??[]).map(ts).filter(Boolean).join(`
13
- `):(e.content??[]).flatMap((o,s)=>{let i=ts(o);return s>0&&dK(o)?[`
14
- `,i]:[i]}).join("")}var cK="markdown",uK=/\\([\\`*_[\]{}()#+\-.!>~|])/g;function pK(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function lK(e){return typeof e=="string"&&e.trim().toLowerCase()===cK}function fK(e){if(typeof e.markdownText=="string")return e.markdownText;if(typeof e.plainText=="string")return e.plainText}function IR(e){return{type:"paragraph",...e?{content:[{type:"text",text:e}]}:{}}}function CR(e,t){let n=0;for(let r=t-1;r>=0&&e[r]==="\\";r-=1)n+=1;return n%2===1}function mK(e){let t=e.trim(),n=0,r=t.length;return t[n]==="|"&&(n+=1),r>n&&t[r-1]==="|"&&!CR(t,r-1)&&(r-=1),t.slice(n,r)}function Nm(e){let t=mK(e),n=[],r="";for(let o=0;o<t.length;o+=1){let s=t[o];if(s==="|"&&!CR(t,o)){n.push(r.trim()),r="";continue}r+=s}return n.push(r.trim()),n}function wm(e){let t=Nm(e);if(t.length<2)return null;let n=[];for(let r of t){let o=r.trim();if(!/^:?-{3,}:?$/.test(o))return null;let s=o.startsWith(":"),i=o.endsWith(":");n.push(s&&i?"center":i?"right":s?"left":null)}return n}function PR(e,t){let n=e[t]??"",r=e[t+1]??"";return n.includes("|")&&wm(r)!==null}function xR(e){return/^\s{0,3}([-*_])(\s*\1){2,}\s*$/.test(e)}function hK(e){return!!(/^\s*(```|~~~)/.test(e)||/^( {4}|\t)\S/.test(e)||/^\s{0,3}#{5,6}\s+/.test(e)||/^\s{0,3}>\s*>/.test(e)||/^\s{2,}([-+*]|\d+[.)])\s+/.test(e)||/^\s{0,3}[-+*]\s+\[[ xX]\]\s+/.test(e)||/^\s{0,3}<[A-Za-z][^>]*>/.test(e))}function gK(e){return/!\[[^\]]*]\([^)]+\)/.test(e)||/`/.test(e)}function ra(e){return hK(e)||gK(e)}function _R(e,t){return e.some(n=>n.type===t.type)?e:[...e,t]}function Tm(e,t){let n=e.replace(uK,"$1");return n?[{type:"text",text:n,...t.length?{marks:t}:{}}]:[]}function Om(e,t,n){let r=e.indexOf(t,n);for(;r>0&&e[r-1]==="\\";)r=e.indexOf(t,r+t.length);return r}function yK(e){let t=[{delimiter:"**",mark:{type:"bold"}},{delimiter:"__",mark:{type:"bold"}},{delimiter:"~~",mark:{type:"strike"}},{delimiter:"*",mark:{type:"italic"}},{delimiter:"_",mark:{type:"italic"}}],n=null;for(let r=0;r<e.length;r+=1){if(e[r]==="\\"){r+=1;continue}for(let o of t){if(!e.startsWith(o.delimiter,r))continue;let s=Om(e,o.delimiter,r+o.delimiter.length);s<=r+o.delimiter.length||(!n||r<n.open||o.delimiter.length>n.delimiter.length)&&(n={...o,close:s,open:r})}if((n==null?void 0:n.open)===r)return n}return n}function AK(e){for(let t=0;t<e.length;t+=1){if(e[t]==="\\"){t+=1;continue}if(e[t]!=="["||e[t-1]==="!")continue;let n=Om(e,"]",t+1);if(n<=t+1||e[n+1]!=="(")continue;let r=Om(e,")",n+2);if(r<=n+2)continue;let o=gu(e.slice(n+2,r).trim());if(o)return{close:r,href:o,label:e.slice(t+1,n),open:t}}return null}function na(e,t=[]){let n=AK(e),r=yK(e);if(n&&(!r||n.open<=r.open)){let d={type:ta,attrs:{href:n.href}};return[...Tm(e.slice(0,n.open),t),...na(n.label,_R(t,d)),...na(e.slice(n.close+1),t)]}if(!r)return Tm(e,t);let{close:o,delimiter:s,mark:i,open:a}=r;return[...Tm(e.slice(0,a),t),...na(e.slice(a+s.length,o),_R(t,i)),...na(e.slice(o+s.length),t)]}function yu(e,t,n){let r=na(t);return{type:e,...n?{attrs:n}:{},...r.length?{content:r}:{}}}function Dm(e){return!e.trim()}function TR(e){return e.match(/^\s{0,3}(#{1,4})\s+(.+?)\s*#*\s*$/)}function km(e){return e.match(/^\s{0,3}[-+*]\s+(.+)$/)}function Mm(e){return e.match(/^\s{0,3}\d+[.)]\s+(.+)$/)}function Lm(e){return e.match(/^\s{0,3}>\s?(.*)$/)}function vK(e){return{type:"listItem",content:[yu("paragraph",e)]}}function SK(e,t,n){return{type:e,attrs:{colspan:1,rowspan:1,colwidth:null,...n?{align:n}:{}},content:[yu("paragraph",t)]}}function RR(e,t,n,r){return{type:"tableRow",content:Array.from({length:r},(o,s)=>SK(e,t[s]??"",n[s]??null))}}function bK(e,t){let n=wm(e[t+1]??"");if(!n||!(e[t]??"").includes("|"))return null;let r=Nm(e[t]??""),o=[],s=t+2;for(;s<e.length;){let d=e[s];if(Dm(d)||ra(d)||!d.includes("|")||wm(d))break;o.push(Nm(d)),s+=1}let i=Math.max(r.length,n.length,...o.map(d=>d.length)),a=[RR("tableHeader",r,n,i),...o.map(d=>RR("tableCell",d,n,i))];return{nextIndex:s,node:{type:"table",content:a}}}function ER(e,t,n){let r=[],o=t;for(;o<e.length&&!ra(e[o]);){let s=n?Mm(e[o]):km(e[o]);if(!s)break;r.push(vK(s[1]??"")),o+=1}return{nextIndex:o,node:{type:n?"orderedList":"bulletList",content:r}}}function IK(e,t,n){let r=[],o=t;for(;o<e.length&&!ra(e[o]);){let s=Lm(e[o]);if(!s)break;r.push(s[1]??""),o+=1}return{nextIndex:o,node:{type:"blockquote",content:n(r)}}}function _K(e){return!!(xR(e)||TR(e)||Lm(e)||km(e)||Mm(e))}function RK(e,t){let n=[],r=t;for(;r<e.length&&!Dm(e[r])&&!ra(e[r])&&!_K(e[r])&&!PR(e,r);)n.push(e[r].trim()),r+=1;return{nextIndex:r,node:yu("paragraph",n.join(" "))}}function NR(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(Dm(r)){n+=1;continue}if(ra(r)){t.push(IR(r)),n+=1;continue}if(xR(r)){t.push({type:"horizontalRule"}),n+=1;continue}let o=PR(e,n)?bK(e,n):null;if(o){t.push(o.node),n=o.nextIndex;continue}let s=TR(r);if(s){t.push(yu("heading",s[2]??"",{level:s[1].length})),n+=1;continue}if(Lm(r)){let u=IK(e,n,NR);t.push(u.node),n=u.nextIndex;continue}if(km(r)){let u=ER(e,n,!1);t.push(u.node),n=u.nextIndex;continue}if(Mm(r)){let u=ER(e,n,!0);t.push(u.node),n=u.nextIndex;continue}let c=RK(e,n);t.push(c.node),n=c.nextIndex}return t.length?t:[IR("")]}function EK(e){return{type:"doc",content:NR(e.replace(/\r\n/g,`
4
+ `,Da.MISSING_INTL_API,a);var C=n.getPluralRules(t,{type:u.pluralType}).select(m-(u.offset||0));T=u.options[C]||u.options.other}if(!T)throw new hb(u.value,m,Object.keys(u.options),a);s.push.apply(s,Uu(T.value,t,n,r,i,m-(u.offset||0)));continue}}return jte(s)}function $te(e,t){return t?ge(ge(ge({},e||{}),t||{}),Object.keys(e).reduce(function(n,r){return n[r]=ge(ge({},e[r]),t[r]||{}),n},{})):e}function Yte(e,t){return t?Object.keys(e).reduce(function(n,r){return n[r]=$te(e[r],t[r]),n},ge({},e)):e}function gb(e){return{create:function(){return{get:function(t){return e[t]},set:function(t,n){e[t]=n}}}}}function Xte(e){return e===void 0&&(e={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:sh(function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new((t=Intl.NumberFormat).bind.apply(t,Zf([void 0],n,!1)))},{cache:gb(e.number),strategy:ch.variadic}),getDateTimeFormat:sh(function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new((t=Intl.DateTimeFormat).bind.apply(t,Zf([void 0],n,!1)))},{cache:gb(e.dateTime),strategy:ch.variadic}),getPluralRules:sh(function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new((t=Intl.PluralRules).bind.apply(t,Zf([void 0],n,!1)))},{cache:gb(e.pluralRules),strategy:ch.variadic})}}var Ek=function(){function e(t,n,r,i){n===void 0&&(n=e.defaultLocale);var o=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(d){var u=o.formatToParts(d);if(u.length===1)return u[0].value;var p=u.reduce(function(m,f){return!m.length||f.type!==Bt.literal||typeof m[m.length-1]!="string"?m.push(f.value):m[m.length-1]+=f.value,m},[]);return p.length<=1?p[0]||"":p},this.formatToParts=function(d){return Uu(o.ast,o.locales,o.formatters,o.formats,d,void 0,o.message)},this.resolvedOptions=function(){var d;return{locale:((d=o.resolvedLocale)===null||d===void 0?void 0:d.toString())||Intl.NumberFormat.supportedLocalesOf(o.locales)[0]}},this.getAst=function(){return o.ast},this.locales=n,this.resolvedLocale=e.resolveLocale(n),typeof t=="string"){if(this.message=t,!e.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");var a=i||{},s=a.formatters,c=ik(a,["formatters"]);this.ast=e.__parse(t,ge(ge({},c),{locale:this.resolvedLocale}))}else this.ast=t;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=Yte(e.formats,r),this.formatters=i&&i.formatters||Xte(this.formatterCache)}return Object.defineProperty(e,"defaultLocale",{get:function(){return e.memoizedDefaultLocale||(e.memoizedDefaultLocale=new Intl.NumberFormat().resolvedOptions().locale),e.memoizedDefaultLocale},enumerable:!1,configurable:!0}),e.memoizedDefaultLocale=null,e.resolveLocale=function(t){if(!(typeof Intl.Locale>"u")){var n=Intl.NumberFormat.supportedLocalesOf(t);return n.length>0?new Intl.Locale(n[0]):new Intl.Locale(typeof t=="string"?t:t[0])}},e.__parse=vk,e.formats={number:{integer:{maximumFractionDigits:0},currency:{style:"currency"},percent:{style:"percent"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},e}();var Vu=Ek;var dh=function(){return dh=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},dh.apply(this,arguments)};function Mk(e,t,n){n===void 0&&(n=null);function r(s){return s&&s.indexOf("###")>-1?s.replace(/###/g,"."):s}function i(){return!e||typeof e=="string"}for(var o=typeof t!="string"?[].concat(t):t.split(".");o.length>1;){if(i())return{};var a=r(o.shift());!e[a]&&n&&(e[a]=new n),e=e[a]}return i()?{}:{obj:e,k:r(o.shift())}}function Wte(e,t,n){var r=Mk(e,t,Object),i=r.obj,o=r.k;i[o]=n}function Jte(e,t){var n=Mk(e,t),r=n.obj,i=n.k;if(r)return r[i]}var uc;(function(e){e.keepRaw="keepRaw",e.replaceAnyway="replaceAnyway"})(uc||(uc={}));var DWe=uc.replaceAnyway,Qte={memoize:!1,memoizeFallback:!1,bindI18n:!1,bindI18nStore:!1,onParseError:uc.replaceAnyway},yb=function(){function e(){this.mem={}}return e.staticInit=function(t){e._i18nextInstance=t},e.prototype.init=function(t,n){var r=this;t===void 0&&(t=e._i18nextInstance);var i={};if(t!=null&&t.options&&(t.options.i18nFormat&&(i=t.options.i18nFormat),i.onParseError=t.options.onParseError,i.missingInterpolationHandler=t.options.missingInterpolationHandler,i.icuConfig=t.options.icuConfig,i.ignoreWarning=!!t.options.ignoreWarning),this.options=Object.assign(Qte,n,i),this.formats=this.options.formats,t){var o=this.options,a=o.bindI18n,s=o.bindI18nStore,c=o.memoize;t.IntlMessageFormat=Vu,this.IntlMessageFormat=Vu,t.ICU=this,c&&(a&&t.on(a,function(){return r.clearCache()}),s&&t.store.on(s,function(){return r.clearCache()}))}this.options.localeData&&(Object.prototype.toString.apply(this.options.localeData)==="[object Array]"?this.options.localeData.forEach(function(d){return r.addLocaleData(d)}):this.addLocaleData(this.options.localeData))},e.prototype.addLocaleData=function(t){var n=Object.prototype.toString.apply(t)==="[object Array]"?t:[t];n.forEach(function(r){r&&r.locale&&Vu.__addLocaleData(r)})},e.prototype.addUserDefinedFormats=function(t){this.formats=this.formats?dh(dh({},this.formats),t):t},e.prototype.checkMissingInterpolation=function(t,n,r,i,o){if((this.options.icuConfig||{}).strict===!1)return r;for(var a={},s=0,c=t;s<c.length;s++){var d=c[s];if(d.type===1){var u=d.value;if(!(r[u]!==null&&r[u]!==void 0)){if(typeof this.options.missingInterpolationHandler=="function"){var p=this.options.missingInterpolationHandler({key:o,text:n,locale:i,interpolation:{key:u,val:r[u]}});if(typeof p=="string"){a[u]=p;continue}}switch(this.options.onParseError){case uc.keepRaw:throw new Error;case uc.replaceAnyway:a[u]="{"+u+"}";continue}if(typeof this.options.onParseError=="function"){console.warn("[DEPRECATED] onParseError is deprecated, please use 'missingInterpolationHandler' instead of");var m=this.options.onParseError(n,u,i,this.IntlMessageFormat);if(m===!0)throw new Error;a[u]=typeof m=="string"?m:"{"+u+"}"}else this.options.ignoreWarning||console.warn('[Starling ICU Warning] The interpolation parameter "{'+u+'}" is missing in the translation text "'+n+'" for the key "'+o+`"
5
+ Suggestions: check whether the value is null or undefined. Try using empty string '' as fallback! e.g I18n.t('key', { apple: count || '' })`),a[u]="{"+u+"}"}}}return Object.assign({},r,a)},e.prototype.parse=function(t,n,r,i,o,a){var s=a&&a.resolved&&a.resolved.res,c=this.options.memoize&&r+"."+i+"."+o.replace(/\./g,"###");!s&&n.thirdParamFallback&&n.fallbackText&&(t=n.fallbackText);var d;this.options.memoize&&(d=Jte(this.mem,c));try{return d||(d=new this.IntlMessageFormat(t,r,this.formats,(this.options.icuConfig||{}).formatOptions),this.options.memoize&&(this.options.memoizeFallback||!a||s)&&Wte(this.mem,c,d)),d.format(this.checkMissingInterpolation(d.getAst(),t,n||{},r,o))}catch{return t}},e.prototype.addLookupKeys=function(t,n,r,i,o){return t},e.prototype.clearCache=function(){this.mem={}},e.type="i18nFormat",e._i18nextInstance=null,e}(),EWe=yb.name;var _b=function(){return _b=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},_b.apply(this,arguments)},Zte="INCONTEXT-KEY-MATCH",uh=/^\s*\[\[__starling_(\d+)_(.*)__\]\]\s*$/,ene=function(){return document.getElementById(Zte)};typeof window<"u"&&(window.__STARLING_INCONTEXT_GLOBAL__HOOK__=_b({},window.__STARLING_INCONTEXT_GLOBAL__HOOK__||{payload:{}}));var Nk={name:"inContext",type:"postProcessor",process:function(e,t,n,r){if(window&&ene()&&!n.__STARLING_INCONTEXT_FLAG__){window.__STARLING_INCONTEXT_GLOBAL_I18N__||(window.__STARLING_INCONTEXT_GLOBAL_I18N__=r),delete n.keySeparator,delete n.lngs;var i=0;if(t=t.toString(),uh.test(t)){var o=t.match(uh);o[0];var a=o[1],s=o[2];i=a,t=s}if(uh.test(e)){var o=e.match(uh);o[0];var a=o[1],s=o[2];e=s}return window.__STARLING_INCONTEXT_GLOBAL__HOOK__.payload[t]?i=window.__STARLING_INCONTEXT_GLOBAL__HOOK__.payload[t].push({options:n,default:e})-1:(window.__STARLING_INCONTEXT_GLOBAL__HOOK__.payload[t]=[{options:n,default:e}],i=0),"[[__starling_"+i+"_"+t+"__]]"}else return e}};function Ab(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function tne(e){if(Array.isArray(e))return Ab(e)}function Fk(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function wk(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,ane(r.key),r)}}function Bk(e,t,n){return t&&wk(e.prototype,t),n&&wk(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function nne(e,t){var n=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=Gk(e))||t&&e&&typeof e.length=="number"){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
6
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var c=n.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{a||n.return==null||n.return()}finally{if(s)throw o}}}}function rne(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function ine(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
7
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function kk(e){return tne(e)||rne(e)||Gk(e)||ine()}function one(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function ane(e){var t=one(e,"string");return typeof t=="symbol"?t:t+""}function Gk(e,t){if(e){if(typeof e=="string")return Ab(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ab(e,t):void 0}}var Tb=["AFN","EUR","ALL","DZD","USD","AOA","XCD","ARS","AMD","AWG","AUD","AZN","BSD","BHD","BDT","BBD","BYN","BZD","XOF","BMD","INR","BTN","BOB","BOV","BAM","BWP","NOK","BRL","BND","BGN","BIF","CVE","KHR","XAF","CAD","KYD","CLP","CLF","CNY","COP","COU","KMF","CDF","NZD","CRC","HRK","CUP","CUC","ANG","CZK","DKK","DJF","DOP","EGP","SVC","ERN","ETB","FKP","FJD","XPF","GMD","GEL","GHS","GIP","GTQ","GBP","GNF","GYD","HTG","HNL","HKD","HUF","ISK","IDR","XDR","IRR","IQD","ILS","JMD","JPY","JOD","KZT","KES","KPW","KRW","KWD","KGS","LAK","LBP","LSL","ZAR","LRD","LYD","CHF","MOP","MKD","MGA","MWK","MYR","MVR","MRO","MUR","XUA","MXN","MXV","MDL","MNT","MAD","MZN","MMK","NAD","NPR","NIO","NGN","OMR","PKR","PAB","PGK","PYG","PEN","PHP","PLN","QAR","RON","RUB","RWF","SHP","WST","STD","SAR","RSD","SCR","SLL","SGD","XSU","SBD","SOS","SSP","LKR","SDG","SRD","SZL","SEK","CHE","CHW","SYP","TWD","TJS","TZS","THB","TOP","TTD","TND","TRY","TMT","UGX","UAH","AED","USN","UYU","UYI","UZS","VUV","VEF","VND","YER","ZMW","ZWL","XBA","XBB","XBC","XBD","XTS","XXX","XAU","XPD","XPT","XAG"],zk={};for(qu=0;qu<Tb.length;qu++)zk[Tb[qu]]={style:"currency",currency:Tb[qu]};var qu,sne={number:zk},Ib={LOGGER:"logger",LAMGUAGE_DETECTOR:"languageDetector",LAMGUAGE_TRANSFORMER:"languageTransformer",BACKEND:"backend"};function vb(e){return function(t){return t.type===e}}function xb(e,t){var n=e;return(t||[]).map(function(r){n=r.process(e)||n}),n}var cne="zh-CN",dne={lng:cne,fallbackLng:["en-US"],inContext:!0},Sb=[yb,Nk],une=function(){function e(t,n){if(Fk(this,e),this._waitingToAddResourceBundle=[],t!=null&&t.copiedI18nextInstance){this.instance=t.copiedI18nextInstance;return}this._handlePlugins(n),this._handleConfigs(t),this.instance=Pw.createInstance(),this.instance.isInitialized=!1}return Bk(e,[{key:"_handlePlugins",value:function(n){var r,i;((r=this.config)===null||r===void 0||(i=r.icuConfig)===null||i===void 0?void 0:i.open)===!1&&Sb.shift(),this.plugins=Array.isArray(n)?n.concat(Sb):Sb}},{key:"_handleConfigs",value:function(n){this.userLng=(n==null?void 0:n.lng)||null,this.config=Object.assign({},dne,n||{})}},{key:"language",get:function(){return(this.instance||{}).language}},{key:"createInstance",value:function(){var n=this;return new Promise(function(r,i){typeof window<"u"&&!window.CocosEngine&&n.config.inContext&&(n.config.postProcess=[].concat(["inContext"],n.config.postProcess||[]),window.__STARLING_DEVTOOLS_I18N=n.instance),n.plugins.map(function(s){s.name==="IES_INTL_ICU_PLUGIN"&&s.staticInit(n.instance),n.instance.use(s)});var o=n.config;n.config.formats=Object.assign({},n.config.formats,sne);var a=xb(o.lng,n.plugins.filter(vb(Ib.LAMGUAGE_TRANSFORMER)));n.instance.init(Object.assign({},o,{lng:a,i18nFormat:Object.assign({},o.i18nFormat||{},{formats:n.config.formats})}),function(s,c){try{var d=nne(n._waitingToAddResourceBundle),u;try{for(d.s();!(u=d.n()).done;){var p,m=u.value;(p=n.instance).addResourceBundle.apply(p,kk(m))}}catch(f){d.e(f)}finally{d.f()}n._waitingToAddResourceBundle=[]}catch{}s||(n._updateLanguages(),r({t:c,err:s})),n.init=!0,i({t:c,err:s})})})}},{key:"_updateLanguages",value:function(){this.languages=this.instance?Array.from(new Set([this.instance.language].concat(kk(this.instance.languages)))):null}},{key:"getLanguages",value:function(){return this.languages}},{key:"changeLanguage",value:function(n,r){var i=this;this.config.lng=n,this.instance.changeLanguage(n,function(o,a){o||i._updateLanguages(),r&&r(o,a)})}},{key:"changeLanguageWithPromise",value:function(n){var r=this;return new Promise(function(i,o){r.config.lng=n,r.instance.changeLanguage(n,function(a,s){a&&o({err:a,t:s}),r._updateLanguages(),i({err:a,t:s})})})}},{key:"getDir",value:function(n){return this.instance.dir(n)}},{key:"t",value:function(n,r,i){var o=Array.isArray(n)?Array.from(n).map(function(){return" "}).join(""):Array(n.length).fill(" "),a=Object.assign({keySeparator:o,nsSeparator:o},r);return"thirdParamFallback"in this.config&&this.config.thirdParamFallback&&(a.thirdParamFallback=!0),this.instance.t(n,i,a)}},{key:"addResourceBundle",value:function(n,r,i,o,a){return this.instance.isInitialized?this.instance.addResourceBundle(n,r,i,o,a):(this._waitingToAddResourceBundle.push([n,r,i,!!o,!!a]),this.instance)}},{key:"cloneInstance",value:function(n,r){var i=this.instance.cloneInstance(n,r),o=new e({copiedI18nextInstance:i});return o.t=this.t.bind(o),o.config=this.config,o.plugins=this.plugins,o.languages=this.languages,o.init=i.isInitialized||!!this.init,o.userLng=this.userLng,i.on("initialized",function(){o.init=!0}),o}}])}(),Ok="Starling_intl:",bb={warn:function(){for(var t,n="".concat(Ok," [WARNING]"),r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];(t=console).warn.apply(t,[n].concat(i))},error:function(){for(var t,n="".concat(Ok," [ERROR]"),r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];(t=console).error.apply(t,[n].concat(i))}};function pne(e){return new Promise(function(t,n){if(Array.isArray(e)||(e=Array.from(e)),e.length<=0)return t([]);var r=[];e=e.map(function(i,o){return function(){var a=typeof i=="function"?new Promise(i):Promise.resolve(i);a.then(function(s){r[o]=s,o===e.length-1?t(r):e[o+1]()},n)}}),e[0]()})}function Cb(e,t,n){return n?t?t(e):e:((!e||!e.then)&&(e=Promise.resolve(e)),t?e.then(t):e)}function lne(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}function mne(){}function fne(e,t){if(!t)return e&&e.then?e.then(mne):Promise.resolve()}function Lk(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{return Promise.resolve(e.apply(this,t))}catch(r){return Promise.reject(r)}}}var Rb;(function(e){e.intl3rdParty="intl3rdParty",e.backend="backend",e.logger="logger",e.languageDetector="languageDetector",e.postProcessor="postProcessor",e.i18nFormat="i18nFormat",e["3rdParty"]="3rdParty"})(Rb||(Rb={}));var Pb=null,Ea=function(){function e(t){var n;Fk(this,e),this.plugins=[],this.i18nInstance=(n=t==null?void 0:t.i18nInstance)!==null&&n!==void 0?n:new une}return Bk(e,[{key:"use",value:function(n){return this.plugins.includes(n)?(bb.warn("Plugin: ".concat(n.name," has beeninit installed.")),this):(this.plugins.push(n),this)}},{key:"init",value:function(n,r){try{var i=this;return i.ignoreWarning=n.ignoreWarning,i.i18nInstance._handleConfigs(n),i.i18nInstance._handlePlugins(i.plugins),Cb(lne(function(){return Cb(i.i18nInstance.createInstance(),function(o){var a=o.err,s=o.t,c=i.plugins.filter(function(d){return d.type===Rb.intl3rdParty});return Cb(pne(c.map(Lk(function(d){if(!(!d||typeof d.init!="function")){var u=d.init instanceof Promise?d.init:Lk(function(p){return Promise.resolve(d.init(p))});return fne(u(i))}}))),function(){return typeof r=="function"&&r(a,s),{err:a,t:s}})})},function(o){return bb.error("The instance init error: ".concat(o)),{err:o,t:function(s){return s}}}))}catch(o){return Promise.reject(o)}}},{key:"language",get:function(){return(this.i18nInstance||{}).language}},{key:"setLang",value:function(n,r){var i=xb(n,this.plugins.filter(vb(Ib.LAMGUAGE_TRANSFORMER)));this.i18nInstance.changeLanguage(i,r)}},{key:"getLanguages",value:function(){return this.i18nInstance.getLanguages()}},{key:"setLangWithPromise",value:function(n){var r=xb(n,this.plugins.filter(vb(Ib.LAMGUAGE_TRANSFORMER)));return this.i18nInstance.changeLanguageWithPromise(r)}},{key:"dir",value:function(n){return this.i18nInstance.getDir(n)}},{key:"t",value:function(n,r,i){var o=null;return typeof this>"u"?o=Pb:o=this,!o.ignoreWarning&&(!o.i18nInstance||!o.i18nInstance.init)?(bb.error("The instance has not been initialized: i18n.t('".concat(n,"'").concat(r?","+JSON.stringify(r):"",");")),i??(Array.isArray(n)?n[0]:n)):!n||typeof n=="string"&&!n.trim()?"":o.i18nInstance.t(n,r,i)}},{key:"addResourceBundle",value:function(n,r,i,o,a){return this.i18nInstance.addResourceBundle(n,r,i,o,a)}},{key:"cloneInstance",value:function(n){var r=this.i18nInstance.cloneInstance(n),i=new e({i18nInstance:r});return i.t=this.t.bind(i),i.plugins=this.plugins,i.ignoreWarning=this.ignoreWarning,i}}])}();Pb=new Ea;var ph=Pb;ph.t=ph.t.bind(ph);var Uk=ph;var lh=class{static create(){let t=new Ea;return t.init({lng:"en",fallbackLng:"en",resources:{},i18nFormat:oc()}),ac(t)}constructor(){}},Se=lh.create();function ve(e,t,n){return{get description(){return n()},input:t,inputSchema:wu[e],kind:e}}var mh=[ve("set_title","{title}",()=>Se.t("Pippit_canvas_command_desc_setcanvastitle",{},"设置画布标题")),ve("set_cover","{cover}",()=>Se.t("Pippit_canvas_command_desc_setcanvascover",{},"设置画布封面")),ve("set_global_bounds","{bounds}",()=>Se.t("Pippit_canvas_command_desc_setcanvasglobalbounds",{},"设置画布全局边界")),ve("create_node","{node, assets?, autoCreateNodeAsset?}",()=>Se.t("Pippit_canvas_command_desc_creategenericnode",{},"创建通用节点及配套资产")),ve("delete_nodes","{ids}",()=>Se.t("Pippit_canvas_command_desc_deletenodes",{},"删除节点并维护关联关系")),ve("update_node_data","{id, patch}",()=>Se.t("Pippit_canvas_command_desc_updatenodedata",{},"更新节点业务数据")),ve("set_node_style","{id, style}",()=>Se.t("Pippit_canvas_command_desc_setnodestyle",{},"更新节点样式")),ve("update_asset","{assetId, contentPatch?, extraPatch?}",()=>Se.t("Pippit_canvas_command_desc_updatecanvasasset",{},"更新画布资产内容或扩展信息")),ve("move_nodes","{ids, delta}",()=>Se.t("Pippit_canvas_command_desc_movenodes",{},"移动节点")),ve("resize_node","{id, size}",()=>Se.t("Pippit_canvas_command_desc_resizenode",{},"缩放节点")),ve("set_node_position","{id, position}",()=>Se.t("Pippit_canvas_command_desc_setnodeposition",{},"设置节点位置")),ve("align_nodes","{ids, direction}",()=>Se.t("Pippit_canvas_command_desc_alignnodes",{},"对齐节点")),ve("distribute_nodes","{ids, axis}",()=>Se.t("Pippit_canvas_command_desc_distributenodes",{},"等距分布节点")),ve("arrange_nodes","{ids, layout, options?}",()=>Se.t("Pippit_canvas_command_desc_arrangenodes",{},"按指定布局排列节点")),ve("auto_layout_nodes","{options?}",()=>Se.t("Pippit_canvas_command_desc_autolayoutnodes",{},"执行自动布局")),ve("group_nodes","{ids}",()=>Se.t("Pippit_canvas_command_desc_groupnodes",{},"创建分组")),ve("ungroup","{groupId}",()=>Se.t("Pippit_canvas_command_desc_ungroupnodes",{},"解散分组")),ve("reparent","{nodeId, newParentId, index?}",()=>Se.t("Pippit_canvas_command_desc_reparentnode",{},"重新设置节点归属")),ve("reorder_children","{groupId, orderedChildren}",()=>Se.t("Pippit_canvas_command_desc_reordergroupchildren",{},"调整分组内节点顺序")),ve("set_group_collapsed","{groupId, collapsed}",()=>Se.t("Pippit_canvas_command_desc_setgroupcollapsed",{},"设置分组折叠状态")),ve("create_edge","{edge}",()=>Se.t("Pippit_canvas_command_desc_createedge",{},"创建连线")),ve("delete_edges","{ids}",()=>Se.t("Pippit_canvas_command_desc_deleteedges",{},"删除连线")),ve("reconnect_edge","{id, patch}",()=>Se.t("Pippit_canvas_command_desc_reconnectedge",{},"重连连线")),ve("update_edge_data","{id, patch}",()=>Se.t("Pippit_canvas_command_desc_updateedgedata",{},"更新连线数据")),ve("update_snap_settings","{patch}",()=>Se.t("Pippit_canvas_command_desc_updatesnapsettings",{},"更新吸附设置")),ve("set_snap_enabled","{enabled}",()=>Se.t("Pippit_canvas_command_desc_setsnapenabled",{},"启用或关闭吸附")),ve("set_auto_layout_strategy","{strategy?}",()=>Se.t("Pippit_canvas_command_desc_setautolayoutstrategy",{},"设置默认自动布局策略")),ve("invoke_command","{name, args?}",()=>Se.t("Pippit_canvas_command_desc_invokeregisteredcommand",{},"调用 SDK 已注册的业务命令")),ve("delete","{nodeIds?, edgeIds?}",()=>Se.t("Pippit_canvas_command_desc_deletenodesoredges",{},"兼容方式删除节点或连线")),ve("apply_patches","{patches}",()=>Se.t("Pippit_canvas_command_desc_applypatches",{},"特权级底层 patch 操作"))];function ln(e,t){var n;return((n=e.describe)==null?void 0:n.call(e,t))??e}function Ma(e){var t;return((t=e.optional)==null?void 0:t.call(e))??e}function hne(e,t,n){if(!(t!=null&&t.length))return e;let r=new Set(t);return n&&r.add(e.rootCanvasId),{...e,assets:Object.fromEntries(Object.entries(e.assets).filter(([o])=>r.has(o)))}}function gne(e){return e.map(t=>t&&typeof t=="object"&&"kind"in t?String(t.kind):"<invalid>")}function yne(e){let t=new Set(["canvas.write"]);return e.includes("apply_patches")&&t.add("canvas.patch"),(e.includes("create_node")||e.includes("create_biz_node")||e.includes("invoke_command")||e.includes("update_asset"))&&t.add("canvas.asset.write"),[...t]}async function Na(e,t,n=["canvas.read"]){return co(e,{canvasId:br(e),operation:t},n)}function Vk(e){let{runtime:t,schema:n}=e,r=e.mutationHandler??va,i=()=>ln(n.array(ln(n.string(),"Canvas asset id")),"Canvas asset ids");return{get_snapshot:{inputSchema:Ir.get_snapshot,args:{assetIds:Ma(i()),includeRootCanvas:Ma(ln(n.boolean(),"Whether to include the root canvas asset in the returned snapshot"))},description:"Read the current canvas snapshot as CanvasDocument JSON, optionally filtered by asset ids.",async execute(o={}){let a=await Na(t,"get_snapshot");if(a)return he(a);let s=t.store.getState();return he(pn(t,{document:hne(s,o.assetIds,o.includeRootCanvas!==!1)}))}},get_asset:{inputSchema:Ir.get_asset,args:{assetId:ln(n.string(),"Canvas asset id to read")},description:"Read one canvas asset from the current CanvasDocument.",async execute(o){let a=await Na(t,"get_asset",["canvas.read","canvas.asset.read"]);if(a)return he(a);let s=t.store.getState().assets[o.assetId];return s?he(pn(t,{asset:s})):he(qt(t,"INVALID_ARGUMENT",`Unknown asset: ${o.assetId}`))}},apply_mutations:{inputSchema:Ir.apply_mutations,args:{atomic:Ma(ln(n.boolean(),"Merge all mutations into one SDK transaction")),checkpointBefore:Ma(ln(n.boolean(),"Create a checkpoint before applying mutations")),dryRun:Ma(ln(n.boolean(),"Validate tool routing without writing")),expectedRevision:Ma(ln(n.number(),"Reject if the current document revision differs from this value")),intent:ln(n.string(),"Short semantic intent for the canvas transaction"),mutations:ln(n.array(n.unknown()),`Canvas mutations: ${mh.map(({kind:o})=>o).join(", ")}. Use apply_patches only for privileged patch-level changes.`)},description:"Apply semantic CanvasDocument mutations. The tool enforces canvas permissions, read-only state, revision checks, and checkpoint creation.",async execute(o){if(!Array.isArray(o.mutations))return he(qt(t,"INVALID_ARGUMENT","mutations must be an array"));let a=gne(o.mutations),s=await co(t,{canvasId:br(t),mutationKinds:a,operation:"apply_mutations"},yne(a));if(s)return he(s);if(qf(t))return he(qt(t,"READ_ONLY","Canvas is read-only"));if(typeof o.expectedRevision=="number"&&t.store.getRevision()!==o.expectedRevision)return he(qt(t,"REVISION_CONFLICT",`Expected revision ${o.expectedRevision}, current revision ${t.store.getRevision()}`));let c;if(o.checkpointBefore){let d=await co(t,{canvasId:br(t),operation:"create_checkpoint"},["canvas.checkpoint.create"]);if(d)return he(d);let u=XS(t,`before:${o.intent}`);await ic(t).create(u),c=u.checkpointId}try{let d=await r({atomic:o.atomic,dryRun:o.dryRun,expectedRevision:o.expectedRevision,intent:o.intent,mutations:o.mutations,runtime:t});return he(pn(t,{...d,checkpointId:d.checkpointId??c}))}catch(d){return he(qt(t,"INVARIANT_FAILED",d instanceof Error?d.message:String(d)))}}},create_checkpoint:{inputSchema:Ir.create_checkpoint,args:{reason:Ma(ln(n.string(),"Why this checkpoint is being created"))},description:"Create an opencode checkpoint from the current CanvasDocument.",async execute(o={}){let a=await Na(t,"create_checkpoint",["canvas.read","canvas.checkpoint.create"]);if(a)return he(a);let s=XS(t,o.reason);return await ic(t).create(s),he(pn(t,{checkpointId:s.checkpointId,documentHash:s.documentHash,revision:s.revision}))}},list_checkpoints:{inputSchema:Ir.list_checkpoints,args:{},description:"List opencode checkpoints for the current canvas.",async execute(){let o=await Na(t,"list_checkpoints",["canvas.read"]);if(o)return he(o);let a=await ic(t).list(br(t));return he(pn(t,{checkpoints:a.map(({document:s,...c})=>c)}))}},restore_checkpoint:{inputSchema:Ir.restore_checkpoint,args:{checkpointId:ln(n.string(),"Checkpoint id returned by create_checkpoint")},description:"Restore a previously created opencode checkpoint into the canvas store.",async execute(o){let a=await Na(t,"restore_checkpoint",["canvas.write","canvas.checkpoint.restore"]);if(a)return he(a);if(qf(t))return he(qt(t,"READ_ONLY","Canvas is read-only"));let s=await ic(t).get(o.checkpointId);if(!s)return he(qt(t,"CHECKPOINT_NOT_FOUND",`Unknown checkpoint: ${o.checkpointId}`));let c=rw(t,s);return c.status==="aborted"?he(qt(t,"INVARIANT_FAILED",c.reason)):he(pn(t,{result:c}))}},compare_checkpoint:{inputSchema:Ir.compare_checkpoint,args:{checkpointId:ln(n.string(),"Checkpoint id to compare with current canvas state")},description:"Compare a checkpoint with the current CanvasDocument at asset granularity.",async execute(o){let a=await Na(t,"compare_checkpoint");if(a)return he(a);let s=await ic(t).get(o.checkpointId);if(!s)return he(qt(t,"CHECKPOINT_NOT_FOUND",`Unknown checkpoint: ${o.checkpointId}`));let c=t.store.getState(),u=[...new Set([...Object.keys(c.assets),...Object.keys(s.document.assets)])].filter(p=>!lt(no(c.assets[p]),no(s.document.assets[p])));return he(pn(t,{changedAssetIds:u,checkpointRevision:s.revision,currentRevision:t.store.getRevision()}))}},get_permissions:{inputSchema:Ir.get_permissions,args:{},description:"Read effective opencode canvas permissions for the current canvas.",async execute(){let o=await Na(t,"get_permissions",["canvas.permission.read"]);return o?he(o):he(pn(t,{canvasId:br(t),readOnly:qf(t)}))}}}}var Db={error(...e){typeof console.error=="function"&&console.error(...e)},info(...e){typeof console.info=="function"&&console.info(...e)},log(...e){typeof console.log=="function"&&console.log(...e)},time(e){typeof console.time=="function"&&console.time(e)},timeEnd(e){typeof console.timeEnd=="function"&&console.timeEnd(e)},timeLog(e,...t){typeof console.timeLog=="function"&&console.timeLog(e,...t)},timeStamp(e){typeof console.timeStamp=="function"&&console.timeStamp(e)},trace(...e){typeof console.trace=="function"&&console.trace(...e)},warn(...e){typeof console.warn=="function"&&console.warn(...e)},profile(e){typeof console.profile=="function"&&console.profile(e)},profileEnd(e){typeof console.profileEnd=="function"&&console.profileEnd(e)}};var Eb=null;function fh(e,t){Eb==null||Eb.branch(e,t)}var li=null;function Ku(e){return li==null||li.trackDisposable(e),e}function ju(e){li==null||li.markAsDisposed(e)}function hh(e,t){li==null||li.setParent(e,t)}var Hu=class e{get isDisposed(){return this._isDisposed}dispose(){if(this._isDisposed){Db.warn(new Error("DisposableStore has disposed.").stack);return}ju(this),this._isDisposed=!0,this.clear()}clear(){if(this._toDispose.size===0)return;for(let n of this._toDispose)fh(this.constructor.name,n.constructor.name);let t=[];for(let n of this._toDispose)try{n.dispose()}catch(r){t.push(r)}if(this._toDispose.clear(),t.length>0)throw new AggregateError(t,"find error when dispose store.")}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself.");return hh(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||Db.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}constructor(){this._toDispose=new Set,this._isDisposed=!1,Ku(this)}};Hu.DISABLE_DISPOSED_WARNING=!1;var $u=class{dispose(){ju(this),fh(this.constructor.name,this._store.constructor.name),this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}constructor(){this._store=new Hu,Ku(this),hh(this._store,this)}};var gh=class{get value(){return this._value}isEmpty(){return this._value===void 0}dispose(){this._value&&(this._value.dispose(),this._value=void 0,ju(this))}constructor(t){this._value=t,Ku(this)}};function Yu(e){return new gh({dispose:e})}var b8e=Symbol.for("canvas-sdk.glassbox.host");var Xu=class{constructor(t){this._items=[];this._capacity=Math.max(1,Math.floor(t))}get size(){return this._items.length}get capacity(){return this._capacity}push(t){this._items.push(t);let n=this._items.length-this._capacity;n>0&&this._items.splice(0,n)}take(t){return t===void 0||t>=this._items.length?this._items.slice():t<=0?[]:this._items.slice(this._items.length-t)}clear(){this._items=[]}};var yh={debug:10,info:20,warn:30,error:40,silent:100};function Mb(e){return e<10?`0${e}`:`${e}`}function Ine(e){return e<10?`00${e}`:e<100?`0${e}`:`${e}`}function vne(e){let t=new Date(e);return`${Mb(t.getHours())}:${Mb(t.getMinutes())}:${Mb(t.getSeconds())}.${Ine(t.getMilliseconds())}`}var xne={debug:"DEBUG",info:"INFO ",warn:"WARN ",error:"ERROR"},Rne={debug:"debug",info:"info",warn:"warn",error:"error"};function Pne(e){let t=globalThis.console;if(!t||typeof t!="object")return;let n=t[Rne[e]];return typeof n=="function"?n.bind(t):void 0}var Nb={write(e){var r;let t=`${vne(e.time)} ${xne[e.level]} ${e.scope}: ${e.message}`,n=[];e.fields&&Object.keys(e.fields).length>0&&n.push(e.fields),e.error!==void 0&&n.push(e.error),(r=Pne(e.level))==null||r(t,...n)}};var kb="__LOG_LEVEL__",qk="LOG_LEVEL",Dne="info",Ene=200;function wb(e){if(typeof e!="string")return;let t=e.trim().toLowerCase();if(t==="debug"||t==="info"||t==="warn"||t==="error"||t==="silent")return t;if(t==="warning")return"warn";if(t==="off"||t==="none")return"silent"}function Mne(){let e=globalThis,t=wb(e[kb]);if(t!==void 0)return t;try{let n=e.localStorage;if(n){let r=wb(n.getItem(kb));if(r!==void 0)return r}}catch{}try{if(typeof process<"u"&&process.env){let n=wb(process.env[qk]);if(n!==void 0)return n}}catch{}}var Ob=class e{constructor(t,n){this._hub=t,this._scope=n}debug(t,n){this._log("debug",t,void 0,n)}info(t,n){this._log("info",t,void 0,n)}warn(t,n){this._log("warn",t,void 0,n)}error(t,n,r){this._log("error",t,n,r)}scope(t){return new e(this._hub,`${this._scope}.${t}`)}isEnabled(t){return this._hub.isEnabled(t)}_log(t,n,r,i){if(!this._hub.isEnabled(t))return;let o={time:Date.now(),level:t,scope:this._scope,message:n};i&&Object.keys(i).length>0&&(o.fields=i),r!==void 0&&(o.error=r),this._hub.emit(o)}},Wu=class extends $u{constructor(n){super();this._counters={debug:0,info:0,warn:0,error:0};this._explicitLevel=n==null?void 0:n.level,this._useRuntimeLevel=(n==null?void 0:n.useRuntimeLevel)??!0,this._rootScope=(n==null?void 0:n.rootScope)??"app",this._sinks=new Set((n==null?void 0:n.sinks)??[Nb]),this._buffer=new Xu((n==null?void 0:n.bufferSize)??Ene)}logger(n){return new Ob(this,n??this._rootScope)}setLevel(n){this._explicitLevel=n}getLevel(){return this._effectiveLevel()}isEnabled(n){return yh[n]>=yh[this._effectiveLevel()]}emit(n){if(this.isEnabled(n.level)){this._counters[n.level]++,this._buffer.push(n);for(let r of this._sinks)try{r.write(n)}catch{}}}addSink(n){return this._sinks.add(n),Yu(()=>this._sinks.delete(n))}removeSink(n){this._sinks.delete(n)}clearSinks(){this._sinks.clear()}recent(n){return this._buffer.take(n)}stats(){return{level:this._effectiveLevel(),counters:{...this._counters},sinks:this._sinks.size,buffered:this._buffer.size}}dispose(){this._sinks.clear(),this._buffer.clear(),super.dispose()}_effectiveLevel(){if(this._explicitLevel!==void 0)return this._explicitLevel;if(this._useRuntimeLevel){let n=Mne();if(n!==void 0)return n}return Dne}};var Lb;function Fb(){return Lb||(Lb=new Wu),Lb}function Kk(e){return Fb().logger(e)}var Nne=Kk();var Bb=["brightness","cameraMotion","color","count","direction","durationMs","effect","goutu","jiaoduan","jingbie","leftright","novelStyle","promptTemplate","ratio","resolution","seed","updown"],Gb=["brightness","color","direction","effect","goutu","jiaoduan","jingbie","leftright","updown"],wne=["cameraMotion","count","durationMs","novelStyle","promptTemplate","ratio","resolution","seed"],M4e=new Set(Bb),kne=new Set(Gb),One=new Set(wne);function Lne(e){return kne.has(e)}function Fne(e){return One.has(e)}function jk(e){return e==null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e)}function Bne(e){let t=Object.fromEntries(Object.entries(e).filter(([n,r])=>Lne(n)&&r!==void 0&&r!==null&&jk(r)));return Object.keys(t).length?t:void 0}function zb(e){let t=Object.fromEntries(Object.entries(e).filter(([r,i])=>Fne(r)&&i!==void 0&&i!==null&&jk(i))),n=Bne(e);return n?{...t,args:n}:t}var Ju=(i=>(i.Empty="empty",i.Generated="generated",i.Tool="tool",i.Uploaded="uploaded",i))(Ju||{}),Gne=new Set(["empty","generated","tool","uploaded"]);function zne(e){return typeof e=="string"&&Gne.has(e)}function _h(e){return e===void 0||zne(e)}function L(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ne(e){return typeof e=="string"}function B(e){return e===void 0||Ne(e)}function Je(e){return typeof e=="number"&&Number.isFinite(e)}function mn(e){return e===void 0||Je(e)}function ft(e){return e===void 0||typeof e=="boolean"}function mi(e){return Array.isArray(e)&&e.every(Ne)}function pc(e,t,n,r=480){let i=Je(e)&&e>0?e:void 0,o=Je(t)&&t>0?t:void 0,a=n&&n.w>0?n.w:void 0,s=n&&n.h>0?n.h:void 0,c=i??a,d=o??s;if(!(!c||!d||r<=0))return{w:r,h:Math.max(1,Math.round(r*d/c))}}var Une=new Set(["audioUrl","audio_url","coverPreviewUrl","cover_preview_url","coverUrl","coverURL","cover_url","downloadUrl","download_url","playUrl","play_url","playerInfo","player_info","posterUrl","poster_url","previewUrl","preview_url","sourceUrl","source_url","src","thumbnailUrl","thumbnail_url","uri","url","urlList","url_list","waveformUrl","waveform_url"]);function Qu(e){return Array.isArray(e)?e.map(Qu):L(e)?Object.fromEntries(Object.entries(e).filter(([t])=>!Une.has(t)).map(([t,n])=>[t,Qu(n)])):e}function Vne(e){if(!L(e))return;let t=e.uploadPath==="legacy"||e.uploadPath==="optimized"?e.uploadPath:void 0;return{...typeof e.id=="string"?{id:e.id}:{},...typeof e.type=="string"?{type:e.type}:{},...typeof e.assetId=="string"?{assetId:e.assetId}:{},...mi(e.dataReferenceSelection)?{dataReferenceSelection:e.dataReferenceSelection}:{},...typeof e.edgeId=="string"?{edgeId:e.edgeId}:{},...L(e.nodeAssetExtra)?{nodeAssetExtra:Qu(e.nodeAssetExtra)}:{},...typeof e.nodeAssetId=="string"?{nodeAssetId:e.nodeAssetId}:{},...typeof e.nodeAssetType=="string"?{nodeAssetType:e.nodeAssetType}:{},...typeof e.pippitAssetId=="string"?{pippitAssetId:e.pippitAssetId}:{},...typeof e.referenceSource=="string"?{referenceSource:e.referenceSource}:{},...typeof e.sourceNodeId=="string"?{sourceNodeId:e.sourceNodeId}:{},...typeof e.sourceNodeType=="string"?{sourceNodeType:e.sourceNodeType}:{},...t?{uploadPath:t}:{},...typeof e.label=="string"?{label:e.label}:{},...L(e.metadata)?{metadata:Qu(e.metadata)}:{}}}function qne(e){Array.isArray(e.references)&&(e.references=e.references.map(Vne).filter(t=>!!t))}var fn={Generated:"generated",Tool:"tool",Uploaded:"uploaded"},Th={CanvasMentionText:"canvas-mention-text"};function Zu(e,t){if(t===void 0){delete e.generation;return}let n=Qu(t);if(qne(n),Pe(e.generation)&&Pe(t)){dn(e.generation,n);return}e.generation=n}function Sh(e,t,n){let{generation:r,...i}=n;return r===void 0?e.updateNodeData(t,n):e.updateNodeData(t,o=>{Object.assign(o,i),Zu(o,r)})}function Ub(e){return e==="submitting"||e==="running"||e==="generating"||e==="processing"}function Hk(e){let t=e==null?void 0:e.source;if(t==="generated"||t==="tool"||t==="uploaded")return t}function Bn(e){return L(e)?B(e.name)&&B(e.variant):!1}var Vb=class{static create(){let t=new Ea;return t.init({lng:"en",fallbackLng:"en",resources:{},i18nFormat:oc()}),ac(t)}constructor(){}},X=Vb.create();function ep(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function qb(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function $k(e){return ep(e.appearanceInfo)?e.appearanceInfo:void 0}function bh(e){return e===void 0||ep(e)&&Object.entries(e).every(([t,n])=>!!t.trim()&&typeof n=="boolean")}function Kne(e){if(!ep(e))return;let t=$k(e),n=(t==null?void 0:t.candidatePippitAssetIds)??e.candidatePippitAssetIds;if(!ep(n))return;let r={};return Object.entries(n).forEach(([i,o])=>{let a=qb(i);a&&typeof o=="boolean"&&(r[a]=o)}),Object.keys(r).length?r:void 0}function Yk(e){var s;if(!ep(e))return{candidateIds:[]};let t=$k(e),n=qb(e.pippitAssetId)??qb(t==null?void 0:t.pippitAssetId),r=Kne(e),i=r?(s=Object.entries(r).find(([,c])=>c))==null?void 0:s[0]:void 0,o=n??i,a=[];return r?a=Object.keys(r):o&&(a=[o]),{candidateIds:a,candidateMap:r,selectedId:o}}function Xk(e){return Yk(e).selectedId}var lc=(o=>(o[o.ModelGenerated=0]="ModelGenerated",o[o.ModelGeneratedI2I=1]="ModelGeneratedI2I",o[o.Upload=2]="Upload",o[o.UploadedImageI2I=3]="UploadedImageI2I",o[o.ReframeFromVideo=4]="ReframeFromVideo",o))(lc||{}),Hb=(r=>(r.UserCreated="user_created",r.AIGenerated="ai_generated",r.NovelTemplateClone="novel_template_clone",r))(Hb||{}),mc=(n=>(n[n.UseDescription=1]="UseDescription",n[n.UseVoiceID=2]="UseVoiceID",n))(mc||{});function Jk(){return X.t("Pippit_xyqcanvas_legacy_label_basic_image",{},"基础形象")}function $b(){return X.t("Pippit_xyqcanvas_legacy_label_unnamed_scene",{},"未命名场景")}var jne=new Set([0,1,2,3,4]),Hne=new Set(["user_created","ai_generated","novel_template_clone"]),$ne=new Set([1,2]),Yne=new Set(["audio","image","video"]),Xne=["image","Generation","Config"].join("");function Wne(e){return e===void 0||Je(e)&&jne.has(e)}function Jne(e){return e===void 0||typeof e=="string"&&Hne.has(e)}function Qk(e){return e===void 0||Je(e)&&$ne.has(e)}function Zk(e){return e===void 0||typeof e=="string"&&Yne.has(e)}function gn(e,t){let n=e[t];return typeof n=="string"?n:void 0}function Kb(e,t){let n=e[t];return Je(n)?n:void 0}function hn(e,t,n){n!==void 0&&(e[t]=n)}function Ch(e){if(!L(e))return;let t={};hn(t,"ttsProvider",Kb(e,"ttsProvider")),hn(t,"age",gn(e,"age")),hn(t,"gender",gn(e,"gender")),hn(t,"speaker",gn(e,"speaker")),hn(t,"description",gn(e,"description")),hn(t,"audioAssetId",gn(e,"audioAssetId")),hn(t,"audioPippitAssetId",gn(e,"audioPippitAssetId")),hn(t,"audioName",gn(e,"audioName")),hn(t,"audioNodeId",gn(e,"audioNodeId"));let n=gn(e,"audioSource");(n===fn.Generated||n===fn.Uploaded)&&hn(t,"audioSource",n),hn(t,"audioDurationMs",Kb(e,"audioDurationMs")),hn(t,"voiceId",gn(e,"voiceId"));let r=e.voice_type??e.voiceType;return Qk(r)&&hn(t,"voice_type",r),Object.keys(t).length>0?t:void 0}function yn(e){return Ch(e==null?void 0:e.voiceInfo)}function Qne(e){return typeof e=="string"&&e.trim().length>0}function Wk(e){return(e==null?void 0:e.trim())||void 0}function Ah(e){let t=L(e)?e:void 0,n=Ch(t==null?void 0:t.voiceInfo);return(n==null?void 0:n.voice_type)!==2?!1:[n.voiceId,n.audioAssetId,n.audioPippitAssetId].some(Qne)}function Ih(e){var r;let t=L(e)?e:void 0,n=Ch(t==null?void 0:t.voiceInfo);if((n==null?void 0:n.voice_type)===2)return((r=n.audioAssetId)==null?void 0:r.trim())||void 0}function vh(e){let t=L(e)?e:void 0,n=Ch(t==null?void 0:t.voiceInfo);if((n==null?void 0:n.voice_type)===2)return n.audioDurationMs}function Zne(e){return e===void 0?!0:L(e)?mn(e.ttsProvider)&&B(e.age)&&B(e.gender)&&B(e.speaker)&&B(e.voiceId)&&B(e.description)&&Qk(e.voice_type)&&B(e.audioAssetId)&&B(e.audioPippitAssetId)&&B(e.audioName)&&B(e.audioNodeId)&&B(e.audioSource)&&mn(e.audioDurationMs):!1}function ere(e){return e===void 0?!0:L(e)?B(e.name)&&B(e.appearanceName)&&B(e.stageTag)&&B(e.label)&&ft(e.isMainImage)&&B(e.description)&&B(e.biography)&&(e.alias===void 0||mi(e.alias))&&B(e.referName)&&ft(e.unpromptable)&&ft(e.isMainCharacter):!1}function tre(e){if(!L(e))return{};let{[Xne]:t,...n}=e;return n}function ka(e){let{url:t,...n}=tre(e);return n}function eO(e,t){let n=ka(e);delete n.assetId,delete n.pippitAssetId,delete n.uploadPath;let r=Wk(t.assetId),i=Wk(t.pippitAssetId);return t.imageSource!==void 0&&(n.imageSource=t.imageSource),r&&(n.assetId=r),i&&(n.pippitAssetId=i),t.uploadPath==="optimized"&&(n.uploadPath="optimized"),n}function xh(e){return e===void 0?!0:L(e)?Wne(e.imageSource)&&B(e.assetId)&&B(e.pippitAssetId)&&bh(e.candidatePippitAssetIds)&&(e.uploadPath===void 0||e.uploadPath==="legacy"||e.uploadPath==="optimized")&&B(e.description)&&B(e.modify):!1}function nre(e){return e===void 0||Array.isArray(e)&&e.every(t=>xh(t))}function tO(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function wa(e,t,n){n!==void 0&&(e[t]=n)}var rre=new Set(["audioUrl","coverPreviewUrl","coverUrl","coverURL","downloadUrl","playerInfo","posterUrl","previewUrl","sceneUrls","sourceUrl","src","thumbnailUrl","uri","url","urlList","waveformUrl"]);function jb(e){return Array.isArray(e)?e.map(jb):L(e)?Object.fromEntries(Object.entries(e).filter(([t])=>!rre.has(t)).map(([t,n])=>[t,jb(n)])):e}function ire(e){let t=gn({metadata:e},"metadata");if(t)try{let n=JSON.parse(t);if(!L(n))return t;let r=jb(n);return Object.keys(r).length?JSON.stringify(r):void 0}catch{return t}}function ore(e,t){if(!L(t))return;let n=tO(e);if(!n)return;let r={pippitAssetId:n};wa(r,"assetId",gn(t,"assetId")),wa(r,"name",gn(t,"name")),wa(r,"order",Kb(t,"order"));let i=t.type??void 0;if(Zk(i))return wa(r,"type",i),t.uploadPath==="optimized"&&(r.uploadPath="optimized"),wa(r,"isMain",typeof t.isMain=="boolean"?t.isMain:void 0),wa(r,"isDefault",typeof t.isDefault=="boolean"?t.isDefault:void 0),wa(r,"metadata",ire(t.metadata)),r}function fc(e){if(!L(e))return;let t=Object.entries(e).map(([n,r])=>{let i=ore(n,r);return i!=null&&i.pippitAssetId?[i.pippitAssetId,i]:void 0}).filter(n=>!!n);return t.length?Object.fromEntries(t):void 0}function are(e){return e===void 0?!0:L(e)?Object.entries(e).every(([t,n])=>!tO(t)||!L(n)?!1:B(n.pippitAssetId)&&B(n.assetId)&&B(n.name)&&mn(n.order)&&Zk(n.type)&&(n.uploadPath===void 0||n.uploadPath==="legacy"||n.uploadPath==="optimized")&&ft(n.isMain)&&ft(n.isDefault)&&B(n.metadata)):!1}function Rh(e){return L(e)?B(e.nodeName)&&mn(e.order)&&ere(e.basicInfo)&&B(e.useContext)&&(e.episodes===void 0||mi(e.episodes))&&Jne(e.createType)&&xh(e.appearanceInfo)&&nre(e.referenceAppearances)&&Zne(e.voiceInfo)&&are(e.sourceInfos):!1}var Z="biz/role",Yb=Z,Ph="role";function sre(e){return L(e)&&!("pippitAssetId"in e)&&B(e.name)&&B(e.extra)&&ft(e.isCover)}function nO(e){return Rh(e)}function Zt(e){if(!L(e))return;let{content:t}=e;return L(t)&&nO(t.data)?t.data:nO(t)?t:void 0}function Oa(e){if(!L(e))return;let t=Zt(e);if(t)return e.type=Yb,e.content=t,e}var La={type:Z,validate:sre,getDefaultSize:e=>({w:362,h:468})};var tp="data-reference-selection",hc="roleVoiceReference";function rt(e){return typeof e=="string"?e.trim():""}function Xb(e){return e==="audio"||e==="image"||e==="video"?e:void 0}function cre(e){if(e===fn.Generated||e===fn.Tool||e===fn.Uploaded)return e}function Wb(e,t){let n=yn(e),r=t==null?void 0:t[hc],i=!!(r&&typeof r=="object"&&!Array.isArray(r));if((n==null?void 0:n.voice_type)!==void 0&&n.voice_type!==2||!i&&(n==null?void 0:n.voice_type)!==2)return;let o=i?r:{},a=rt(o.pippitAssetId)||rt(n==null?void 0:n.audioPippitAssetId);if(!a)return;let s=Number(o.durationMs??(n==null?void 0:n.audioDurationMs)),c=Number(o.sizeBytes??o.size_bytes??o.size);return{assetId:rt(o.assetId)||rt(n==null?void 0:n.audioAssetId)||rt(n==null?void 0:n.voiceId)||void 0,audioNodeId:rt(o.audioNodeId)||rt(n==null?void 0:n.audioNodeId)||void 0,audioSource:cre(o.audioSource)??(n==null?void 0:n.audioSource),durationMs:Number.isFinite(s)&&s>0?s:void 0,id:a,kind:"roleVoice",name:rt(o.name)||rt(n==null?void 0:n.audioName)||rt(o.assetId)||void 0,pippitAssetId:a,selectable:!0,sizeBytes:Number.isFinite(c)&&c>0?c:void 0,type:"audio"}}function rO(e){let t=Xb(e==null?void 0:e.type);return!t||t==="image"}function dre(e){return Xb(e==null?void 0:e.type)==="video"}function ure(e){return Xb(e==null?void 0:e.type)==="audio"}function Jb(e){if(ure(e))return"audio";if(dre(e))return"video";if(rO(e))return"image"}function Fa(e){var r,i,o;let t=fc(e==null?void 0:e.sourceInfos),n=t?Object.entries(t):[];if(!n.length){let a=rt((r=e==null?void 0:e.appearanceInfo)==null?void 0:r.pippitAssetId);a&&n.push([a,{assetId:rt((i=e==null?void 0:e.appearanceInfo)==null?void 0:i.assetId)||void 0,isMain:!0,name:rt((o=e==null?void 0:e.basicInfo)==null?void 0:o.appearanceName)||void 0,order:0,pippitAssetId:a,type:"image"}])}return n.map(([a,s])=>[a,{...s,isMain:rO(s)?s.isMain:!1,pippitAssetId:a}]).sort((a,s)=>{let c=Number.isFinite(a[1].order)?Number(a[1].order):0,d=Number.isFinite(s[1].order)?Number(s[1].order):0;return c!==d?c-d:a[0].localeCompare(s[0])})}function iO(e,t){var s,c,d;let n=rt(t.pippitAssetId),r=Fa(e);if(!n)return Object.fromEntries(r);let i=((s=r.find(([,u])=>u.isMain===!0))==null?void 0:s[0])||rt((c=e==null?void 0:e.appearanceInfo)==null?void 0:c.pippitAssetId),o=(d=r.find(([u])=>u===n))==null?void 0:d[1],a=r.filter(([u])=>u!==i&&u!==n);return Object.fromEntries([[n,{...o??{},...t,isMain:!0,order:0,pippitAssetId:n,type:"image"}],...a.map(([u,p],m)=>[u,{...p,isMain:!1,order:m+1,pippitAssetId:u}])])}function oO(e,t){let n=rt(t.assetId)||void 0,r=rt(t.pippitAssetId)||void 0,i={appearanceInfo:eO(e==null?void 0:e.appearanceInfo,{assetId:n,imageSource:t.imageSource,pippitAssetId:r})};if(r){let o={pippitAssetId:r,type:"image"},a=rt(t.name);n&&(o.assetId=n),a&&(o.name=a),typeof t.metadata=="string"&&(o.metadata=t.metadata),typeof t.isMain=="boolean"&&(o.isMain=t.isMain),Number.isFinite(t.order)&&(o.order=t.order),t.uploadPath&&(o.uploadPath=t.uploadPath),i.sourceInfos=iO(e,o)}return i}function aO(e){return e.map(rt).filter(Boolean).join(",")}function Qb(e){let t=rt(e);return t?t.split(",").map(rt).filter(Boolean):null}function np(e){return e.nodeAssetType===Z||e.sourceNodeType===Z}var eC=/<pippit-asset-id\b(?:[^>]*?\slabel="([^"]*)")?[^>]*>([^<]*)<\/pippit-asset-id>/g;var Ba=/<(pippit-asset-id|node-asset)\b(?:[^>]*?\slabel="([^"]*)")?[^>]*>([^<]*)<\/\1>/g;var er=/<(pippit-asset-id|node-asset)\b(?:[^>]*?\slabel="([^"]*)")?[^>]*>([^<]*)<\/\1>|<bbox\s+pippit-asset-id="([^"]*)">\s*(\[[^\]]*\])\s*<\/bbox>/g,pre=/^<(pippit-asset-id|node-asset)\b([^>]*)>/i,Zb=/([A-Za-z_:][A-Za-z0-9_:.-]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/g;function lre(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function sO(e){return e.replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")}function cO(e){return/^[A-Za-z_:][A-Za-z0-9_:.-]*$/.test(e)}function Dh(e){return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).map(([t,n])=>[t.trim(),String(n??"").trim()]).filter(([t,n])=>cO(t)&&n))}function mre(e){let t={};Zb.lastIndex=0;for(let n of e.matchAll(Zb)){let r=String(n[1]??"").trim(),i=String(n[2]??n[3]??"");cO(r)&&(t[r]=sO(i))}return Zb.lastIndex=0,t}function gc(e){let t=pre.exec(e[0]??"");return mre((t==null?void 0:t[2])??"")}function fre(e,t={}){let n={...Dh(e),...Dh(t)};return Object.entries(n).map(([r,i])=>` ${r}="${lre(i)}"`).join("")}function dO(e){return String(e??"").trim()}function uO({attributes:e,tagId:t,tagName:n}){let r=dO(t);return r?`<${n}${fre(e)}>${r}</${n}>`:""}function pO(e,t){return uO({attributes:t,tagId:e,tagName:"pippit-asset-id"})}function Eh(e,t){return uO({attributes:t,tagId:e,tagName:"node-asset"})}function tC(e){return String(e??"").replace(Ba,(t,n,r,i)=>dO(i)?t:"")}function po(e){return L(e)&&(e.episodes===void 0||mi(e.episodes))}function Mh(e){let t=new Set,n=[];for(let r of e??[]){let i=String(r).trim();!i||t.has(i)||(t.add(i),n.push(i))}return n}var hre=new Set(["failed","uploaded"]),gre=new Set(["manual","image-operation","panorama-capture","panorama-grid","scene3d-capture-send","video-trim"]);function lO(e,t){return!(!L(e)||!Ne(e.id)||!e.id.trim()||e.type!=="image"&&e.type!=="video"||t&&e.type!==t||typeof e.status!="string"||!hre.has(e.status)||!B(e.fileName)||!B(e.mimeType)||!B(e.errorMessage)||e.uploadPath!==void 0&&e.uploadPath!=="legacy"&&e.uploadPath!=="optimized"||e.status==="uploaded"&&e.uploadPath!=="optimized"&&!(e.type==="image"&&e.uploadPath==="legacy")||e.size!==void 0&&(!Je(e.size)||e.size<0)||e.cachedAt!==void 0&&!Je(e.cachedAt))}function mO(e,t){return lO(e,t)?e:void 0}function en(e,t){return!(!L(e)||!Ne(e.id)||!e.id.trim()||e.type!=="audio"&&e.type!=="image"&&e.type!=="video"||t&&e.type!==t||e.status!=="capturing"&&e.status!=="uploading"&&e.status!=="failed"||!B(e.cacheId)||e.cacheId!==void 0&&!e.cacheId.trim()||!B(e.fileName)||!B(e.mimeType)||!B(e.errorMessage)||!B(e.sourceKind)||e.sourceKind!==void 0&&!gre.has(e.sourceKind)||e.uploadPath!==void 0&&e.uploadPath!=="legacy"&&e.uploadPath!=="optimized"||e.size!==void 0&&(!Je(e.size)||e.size<0)||e.cachedAt!==void 0&&!Je(e.cachedAt))}function fO(e,t){return e==null||en(e,t)}function nC(e,t){return en(e,t)?e.status==="capturing"||e.status==="uploading":!1}var hO={Material:"material",Prop:"prop"};function yre(e){return L(e)&&B(e.tag)}function gO(e){return e===void 0||Array.isArray(e)&&e.every(yre)}var fe="biz/audio";function tr(e){let t=typeof e=="string"?Number(e):e;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:void 0}function yO(e){let t=e==null?void 0:e.metadata;return L(t)?t:void 0}function rp(e){let t=tr(e);return t===void 0?void 0:t*1e3}function ip(e){let t=yO(e);return tr(e==null?void 0:e.durationMs)??tr(t==null?void 0:t.durationMs)??tr(t==null?void 0:t.durationMS)??tr(t==null?void 0:t.duration_ms)??rp(t==null?void 0:t.durationSec)??rp(t==null?void 0:t.duration_sec)??rp(t==null?void 0:t.duration)??rp(t==null?void 0:t.originalDuration)??rp(t==null?void 0:t.original_duration)}function _O(e){let t=e,n=yO(e);return tr(t==null?void 0:t.sizeBytes)??tr(t==null?void 0:t.size_bytes)??tr(t==null?void 0:t.size)??tr(n==null?void 0:n.sizeBytes)??tr(n==null?void 0:n.size_bytes)??tr(n==null?void 0:n.size)}function _re(e){return e===void 0?!0:L(e)?mn(e.startMs)&&mn(e.endMs)&&mn(e.currentTimeMs)&&mn(e.playbackRate)&&ft(e.muted)&&ft(e.loop)&&mn(e.volume):!1}function rC(e){return!L(e)||!B(e.assetId)||!B(e.pippitAssetId)||!fO(e.localUploadTask,"audio")||e.securityCheckScene!==void 0&&!mi(e.securityCheckScene)||!gO(e.tagInfos)||!Bn(e)||!po(e)||!mn(e.durationMs)||!_re(e.playback)||!B(e.waveformKey)||!_h(e.source)?!1:Object.keys(e).length===0||!!(e.assetId||e.pippitAssetId||e.generation||e.episodes)}var lo={type:fe,validate:rC,getDefaultSize:()=>({w:362,h:218})};var ee="biz/image",op=(i=>(i[i.URL=1]="URL",i[i.URI=2]="URI",i[i.Binary=3]="Binary",i[i.Everphoto=4]="Everphoto",i))(op||{});function ap(e){return!(!L(e)||!Bn(e)||!po(e)||!bh(e.candidatePippitAssetIds))}function Tre(e){var r,i;let t=e.naturalWidth??((r=e.metadata)==null?void 0:r.width),n=e.naturalHeight??((i=e.metadata)==null?void 0:i.height);return pc(t,n,{w:420,h:326})??{w:480,h:373}}var fi={type:ee,validate:ap,getDefaultSize:Tre};var qe="biz/image-panorama",Sre="equirectangular",TO=1,R5e=Object.freeze({fov:90,pitch:0,version:TO,yaw:0});function bre(e){return e===void 0||e===Sre}function Cre(e){return!L(e)||e.version!==TO?!1:typeof e.yaw=="number"&&Number.isFinite(e.yaw)&&e.yaw>=-180&&e.yaw<180&&typeof e.pitch=="number"&&Number.isFinite(e.pitch)&&e.pitch>=-85&&e.pitch<=85&&typeof e.fov=="number"&&Number.isFinite(e.fov)&&e.fov>=45&&e.fov<=110}function iC(e){return L(e)&&ap(e)&&bre(e.projection)&&(e.viewState===void 0||Cre(e.viewState))}function Are(e){var r,i;let t=e.naturalWidth??((r=e.metadata)==null?void 0:r.width),n=e.naturalHeight??((i=e.metadata)==null?void 0:i.height);return pc(t,n,{w:320,h:180})??{w:480,h:270}}var Nh={type:qe,validate:iC,getDefaultSize:Are};function SO(e){return e===ee||e===qe}var Oe="biz/scene",oC=Oe,CO="scene",Ga={w:420,h:372};function Ire(e){return L(e)&&!("pippitAssetId"in e)&&B(e.name)&&B(e.extra)&&ft(e.isCover)}function bO(e){return Rh(e)}function yc(e){if(!L(e))return;let{content:t}=e;return L(t)&&bO(t.data)?t.data:bO(t)?t:void 0}function AO(e){if(!L(e))return;let t=yc(e);if(t)return e.type=oC,e.content=t,e}var sp={type:Oe,validate:Ire,getDefaultSize:()=>({...Ga})};var et="biz/text",IO={overflow:"wrap",padding:28,verticalAlign:"top"};var vre=new Set(["top","middle","bottom"]),xre=new Set(["clip","wrap","auto-height"]);function Rre(e){if(e===void 0)return!0;if(!L(e))return!1;let{verticalAlign:t,overflow:n,padding:r}=e;return!(t!==void 0&&(!Ne(t)||!vre.has(t))||n!==void 0&&(!Ne(n)||!xre.has(n))||r!==void 0&&(!Je(r)||r<0))}function aC(e){return!(!L(e)||"pippitAssetId"in e||!Bn(e)||e.plainText!==void 0&&!Ne(e.plainText)||e.markdownText!==void 0&&!Ne(e.markdownText)||!B(e.placeholder)||!Rre(e.block)||e.plainText===void 0&&e.content!==void 0||e.content!==void 0&&!L(e.content))}var mo={type:et,validate:aC,getDefaultSize:e=>{var t;return{w:420,h:((t=e.block)==null?void 0:t.overflow)==="auto-height"?64:180}}};var J="biz/video";var sC="smart-edit",cC="video-smart-edit";function dC(e){return!(!L(e)||!Bn(e)||!po(e))}function Pre(e){var r,i;let t=(r=e.metadata)==null?void 0:r.width,n=(i=e.metadata)==null?void 0:i.height;return pc(t,n,{w:420,h:236})??{w:480,h:270}}var hi={type:J,validate:dC,getDefaultSize:Pre};var Dre=new Set([Z,Oe]);function Ere(){return new Set([X.t("Pippit_xyqcanvas_legacy_label_role",{},"角色"),X.t("Pippit_xyqcanvas_legacy_label_scene",{},"场景"),X.t("Pippit_xyqcanvas_legacy_label_basic_image",{},"基础形象"),X.t("Pippit_xyqcanvas_legacy_label_default_image",{},"默认形象"),X.t("Pippit_xyqcanvas_legacy_label_master_image",{},"主设定形象"),X.t("Pippit_xyqcanvas_legacy_label_no_character_name_yet",{},"暂无角色名"),X.t("Pippit_xyqcanvas_legacy_label_no_image_name_yet",{},"暂无形象名称"),X.t("Pippit_xyqcanvas_legacy_label_unnamed_role",{},"未命名角色"),X.t("Pippit_xyqcanvas_legacy_label_unnamed_image_name",{},"未命名形象名"),X.t("Pippit_xyqcanvas_legacy_label_unnamed_scene",{},"未命名场景")])}function Mre(){return new Set([X.t("Pippit_xyqcanvas_legacy_label_no_image_name_yet",{},"暂无形象名称"),X.t("Pippit_xyqcanvas_legacy_label_unnamed_image_name",{},"未命名形象名"),X.t("Pippit_xyqcanvas_legacy_label_unnamed_scene",{},"未命名场景")])}function kh(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function cp(e){if(e){if(typeof e=="string")try{return cp(JSON.parse(e))}catch{return}return kh(e)?e:void 0}}function gi(e){let t=e==null?void 0:e.trim();return t||void 0}function dp(e){if(kh(e))return gi(typeof e.name=="string"?e.name:void 0)}function uC(e){let t=e==null?void 0:e.replace(/_\d+$/,"");return!!(t&&Ere().has(t))}function wh(e){let t=e==null?void 0:e.replace(/_\d+$/,"");return!!(t&&Mre().has(t))}function vO(e,t){let n=e==null?void 0:e[t];return typeof n=="string"?n:void 0}function xO(e){let t=cp(e);if(!t)return!0;let n=cp(t.basicInfo),r=gi(vO(n,"appearanceName"));if(r)return wh(r);let i=gi(vO(t,"nodeName"));return!i||wh(i)}function up(e){if(!kh(e))return;let t=cp(e.data);if(e.type===Ze)return gi(typeof(t==null?void 0:t.title)=="string"?t.title:void 0);let n=dp(t);return typeof e.type=="string"&&Dre.has(e.type)&&uC(n)?void 0:n}function Nre(e){switch(e){case et:return X.t("Pippit_xyqcanvas_legacy_title_text",{},"文本");case ee:return X.t("Pippit_xyqcanvas_legacy_label_picture",{},"图片");case qe:return X.t("Pippit_xyqcanvas_legacy_label_panorama",{},"全景图");case J:return X.t("Pippit_xyqcanvas_legacy_title_video",{},"视频");default:return}}function wre(e,t){let n=cp(t);if(n&&e===J)return gi(typeof n.title=="string"?n.title:void 0)}function pC(e){if(kh(e))return up(e)??wre(e.type,e.data)??Nre(e.type)}var Oh="pippit-role",lC="base-model",mC="base",fC=Bs.ASSETS.entries[Oh].path;function kre(e){return L(e)?Ne(e.captureId)&&!!e.captureId.trim()&&Je(e.createdAt)&&en(e):!1}function RO(e){return e===void 0?!0:L(e)?Object.entries(e).every(([t,n])=>kre(n)&&n.captureId===t):!1}var _n="biz/scene3d-director",Ore=_n,_c="biz/scene3d-director-document",yi="biz/scene3d-director-fcurves";function gC(){return X.t("Pippit_xyqcanvas_legacy_title_3d_director_s_desk",{},"3D 导演台")}var p6e=gC();function PO(){return X.t("Pippit_xyqcanvas_scene3ddirector_defaultname_democharacter",{},"角色1")}var Lre={baseAction:"idle",additiveWeights:{},boneRotations:{},controlValues:{bodyBend:0,bodyTilt:0,bodyTurn:0,headNod:0,headTilt:0,headTurn:0,lArmRaise:0,lArmStraddle:0,lArmTurn:0,lElbowBend:0,lKneeBend:0,lLegRaise:0,lLegStraddle:0,lLegTurn:0,rArmRaise:0,rArmStraddle:0,rArmTurn:0,rElbowBend:0,rKneeBend:0,rLegRaise:0,rLegStraddle:0,rLegTurn:0,torsoBend:0,torsoTilt:0,torsoTurn:0},posePresetId:"tpose",rootPositionOffset:{x:0,y:0,z:0},speed:1};function yC(){return{version:1,nodes:[{id:"character_1",type:"character",name:PO(),visible:!0,locked:!1,transform:{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}},metadata:{assetCategory:lC,assetId:Oh,assetSource:mC,defaultCharacterIndex:1,modelUrl:fC},character:{gender:"female",placeholder:!0,appearance:{color:"#d7b5ee"},label:{scale:1,yOffset:1.1},animation:Lre}}],aspectRatio:"21:9",settings:{gridVisible:!0,helpersVisible:!0,compositionGuide:"none",transformMode:"translate",viewMode:"director"},environment:{transform:{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}},background:{skyColor:"#060608"},sphere:{orientationVersion:1,rotationX:0,rotationY:90,radius:180},display:{characterLabelsVisible:!0,gridSnapEnabled:!1,groundVisible:!1,groundOpacity:1}}}}var Fre=["assetId","pippitAssetId","previewUrl","url","naturalWidth","naturalHeight","latestCaptureAt","directorDocument","metadata"];function Bre(e){return Fre.some(t=>t in e)}function Gre(e){return L(e)?Ne(e.requestId)&&Ne(e.runId)&&Ne(e.sceneId)&&Array.isArray(e.sourceShotAssetIds)&&e.sourceShotAssetIds.every(Ne):!1}function zre(e){return L(e)?!Bre(e)&&Bn(e)&&B(e.title)&&B(e.name)&&B(e.caption)&&B(e.subType)&&_h(e.source)&&RO(e.captureUploadTasks)&&(e.storyboardOrigin===void 0||Gre(e.storyboardOrigin)):!1}function Ure(e){return e===void 0?!0:L(e)?Je(e.width)&&Je(e.height):!1}function hC(e){return L(e)?e.kind==="pippit-asset"&&Ne(e.pippitAssetId)&&e.schemaVersion===1:!1}function DO(e){return L(e)?e.kind==="pippit-asset"&&Ne(e.pippitAssetId)&&e.schemaVersion===1:!1}function Vre(e){return{kind:"pippit-asset",pippitAssetId:e,schemaVersion:1}}function EO(e){return{kind:"pippit-asset",pippitAssetId:e,schemaVersion:1}}function qre(e){return{version:2,documentRef:e}}function Kre(e){return`${e}_document`}function jre({document:e,documentAssetId:t,nodeId:n}){return{pippitAssetId:t,type:_c,content:e,extra:{sourceNodeId:n}}}function MO({document:e=yC(),documentAssetId:t,nodeId:n}){let r=t??Kre(n),i=Vre(r);return[{pippitAssetId:n,type:Ore,content:qre(i),extra:{}},jre({document:e,documentAssetId:r,nodeId:n})]}function Lh(e){if(!L(e))return!1;let t=e.cover===void 0||L(e.cover)&&Ne(e.cover.pippitAssetId)&&!!e.cover.pippitAssetId.trim();return e.version===2&&hC(e.documentRef)&&t}function _i(e){return L(e)?e.version===1&&Array.isArray(e.nodes)&&B(e.generate)&&B(e.generate_run_id)&&B(e.applied_generate_run_id)&&(B(e.activeCameraId)||B(e.activeShotCameraNodeId))&&Ne(e.aspectRatio)&&Ure(e.customAspectRatio)&&L(e.settings)&&L(e.environment)&&(e.captures===void 0||Array.isArray(e.captures)):!1}function Tc(e){if(!L(e))return;let{content:t}=e;if(Lh(t))return t.documentRef;if(!L(t))return;let{documentRef:n}=t;if(hC(n))return n;let r=t.data;if(L(r)&&hC(r.documentRef))return r.documentRef}function NO(e){var t;if(!(!L(e)||!Lh(e.content)))return((t=e.content.cover)==null?void 0:t.pippitAssetId.trim())||void 0}var pp={type:_n,validate:zre,getDefaultSize:()=>({w:420,h:236})};function Ti(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!=null))}function jt(e,t){let n=e==null?void 0:e[t];return typeof n=="string"?n:void 0}function Fh(e){return typeof e=="object"&&e!==null}function Bh(e){return Fh(e==null?void 0:e.data)?e.data:{}}function Rr(e,t){var s;let n=Bh(t),r=t!=null&&t.id?(s=e.assets)==null?void 0:s[t.id]:void 0,i=Fh(r)?r.content:void 0,o=Fh(i)?i:void 0,a=Fh(o==null?void 0:o.data)?o.data:o;return a||n}var Hre=new Set(["audiourl","coverpreviewurl","coverurl","downloadurl","imageurl","playerinfo","posterurl","previewinfo","previewurl","sceneurls","sourceimageurl","sourceurl","src","thumbnailurl","uri","url","urls","urllist","videourl","waveformurl"]);function bC(e){return Array.isArray(e)?e.map(t=>bC(t)):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).flatMap(([t,n])=>Hre.has(t.replaceAll("_","").toLowerCase())?[]:[[t,bC(n)]]))}function Gn(e){let t=e.pippitAssetId?bC(e):e;return Ti(t)}function Sc(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function _C(e){let t=(Array.isArray(e)?e:e?[e]:[]).map(n=>typeof n=="string"?n.trim():"").filter(Boolean);return t.length?t:void 0}function TC(e){if(!Sc(e.localUploadTask))return;let t=jt(e.localUploadTask,"uploadPath");if(e.uploadPath!=="optimized"&&t!=="optimized")return;let n=jt(e.localUploadTask,"status");return n==="capturing"||n==="uploading"?"uploading":void 0}function $re(e,t){if(en(e,"image"))return t==="optimized"||e.uploadPath==="optimized"?"uploading":void 0}function lp(e){if(!Sc(e))return"";if(typeof e.text=="string")return e.text;if(e.type==="hardBreak")return`
8
+ `;if(e.type==="table")return Array.isArray(e.content)?e.content.map(lp).filter(Boolean).join(`
9
+ `):"";if(e.type==="tableRow")return Array.isArray(e.content)?e.content.map(lp).join(" "):"";if(e.type==="tableCell"||e.type==="tableHeader")return Array.isArray(e.content)?e.content.map(lp).filter(Boolean).join(`
10
+ `):"";let t=Array.isArray(e.content)?e.content.map(lp).filter(Boolean):[];return t.length===0?"":e.type==="doc"||e.type==="bulletList"||e.type==="orderedList"?t.join(`
11
+ `):t.join("")}function OO(e){return(typeof e.plainText=="string"?e.plainText.trim():"")||lp(e.content).trim()}function Yre(e,t,n){return up(n??e)??dp(t)??gi(jt(t,"title"))??X.t("Pippit_xyqcanvas_legacy_title_text",{},"文本")}function wO(e,t){return up(t)??pC(e)??e.id}function Xre(e){var r;let t=dp(e);if(t)return t;let n=(r=e.assetId)==null?void 0:r.trim();return n||X.t("Pippit_xyqcanvas_legacy_label_audio",{},"音频")}function SC(e){let t=gi(e);return t&&!uC(t)?t:void 0}function kO(e){let t=gi(e);return t&&!wh(t)?t:void 0}function Wre(e,t){if(!e)return t;if(!t||t===e)return e;let n=`${e}-`,r=t.startsWith(n)?t.slice(n.length):t;return r?`${e}-${r}`:e}function Jre(e,t,n,r){let i=SC(up(r??e))??SC(jt(n,"name"))??SC(t.nodeName),o=kO(jt(n,"appearanceName"))??(e.type===Oe?kO(t.nodeName):void 0);return{label:Wre(i,o)??e.id,subjectName:i,variantName:o}}function Qre(e,t,n,r,i,o){let a=Sc(t.appearanceInfo)?t.appearanceInfo:void 0,s=Sc(t.basicInfo)?t.basicInfo:void 0,c=jt(a,"assetId"),d=jt(a,"pippitAssetId"),u=jt(a,"uploadPath"),p=u==="legacy"||u==="optimized"?u:void 0,{label:m,subjectName:f,variantName:h}=Jre(e,t,s,r),g=e.type===Z?Ih(t):void 0,y=e.type===Z?vh(t):void 0;return Gn({id:e.id,type:"image",assetId:c,...n,nodeAssetId:e.id,nodeAssetType:e.type,sourceNodeType:e.type,content:i,pippitAssetId:d,uploadPath:p,uploadStatus:$re(o,p),label:m,metadata:Ti({audioVoiceAssetId:g,audioVoiceDurationMs:y,hasAudioVoice:e.type===Z?Ah(t):void 0,name:m===e.id?void 0:m,subjectName:f,variantName:h})})}function bc(e,t,n={}){var a,s,c,d,u;if(!e)return;let r=Bh(e),i=Sc(r.metadata)?r.metadata:{},o=t?{edgeId:t.id,referenceSource:"canvas-edge",sourceNodeId:t.source}:void 0;if(SO(e.type))return Gn({id:e.id,type:"image",assetId:r.assetId,...o,nodeAssetId:e.id,nodeAssetType:e.type,sourceNodeType:e.type,content:n.content,mediaSource:jt(r,"source"),pippitAssetId:r.pippitAssetId,securityCheckScene:_C(r.securityCheckScene),uploadPath:r.uploadPath,uploadStatus:TC(r),label:wO(e,n.displayNode),metadata:Ti({height:r.naturalHeight??((a=r.metadata)==null?void 0:a.height),name:dp(r)??((s=r.metadata)==null?void 0:s.name)??r.caption,sizeBytes:r.sizeBytes??i.sizeBytes??i.size,width:r.naturalWidth??((c=r.metadata)==null?void 0:c.width)})});switch(e.type){case Z:case Oe:return Qre(e,r,o,n.displayNode,n.content,n.localUploadTask);case J:return Gn({id:e.id,type:"video",assetId:r.assetId,...o,nodeAssetId:e.id,nodeAssetType:e.type,sourceNodeType:e.type,content:n.content,coverPreviewKey:r.coverPreviewKey,mediaSource:jt(r,"source"),pippitAssetId:r.pippitAssetId,securityCheckScene:_C(r.securityCheckScene),uploadPath:r.uploadPath,uploadStatus:TC(r),label:wO(e,n.displayNode),metadata:Ti({width:i.width,height:i.height,durationMs:i.durationMs??i.durationMS,durationSec:i.durationSec??i.duration,fps:i.fps,shotId:jt(r,"shotId"),sizeBytes:i.sizeBytes??i.size})});case fe:return Gn({id:e.id,type:"audio",assetId:r.assetId,...o,nodeAssetId:e.id,nodeAssetType:e.type,sourceNodeType:e.type,content:n.content,pippitAssetId:r.pippitAssetId,securityCheckScene:_C(r.securityCheckScene),uploadPath:r.uploadPath,uploadStatus:TC(r),label:Xre(r),metadata:Ti({durationMs:r.durationMs??((d=r.metadata)==null?void 0:d.durationMs)??((u=r.metadata)==null?void 0:u.durationMS),durationSec:r.durationSec??i.durationSec??i.duration,sizeBytes:r.sizeBytes??i.sizeBytes??i.size})});case et:return Gn({id:e.id,type:"text",...o,nodeAssetId:n.allowGenericNodeAsset?e.id:void 0,nodeAssetType:n.allowGenericNodeAsset?e.type:void 0,sourceNodeType:e.type,content:n.allowGenericNodeAsset?n.content:void 0,displayLabel:Yre(e,r,n.displayNode),label:OO(r)});case _n:return n.allowGenericNodeAsset?Gn({id:e.id,type:"node-asset",...o,nodeAssetId:e.id,nodeAssetType:e.type,sourceNodeType:e.type,content:n.content,label:pC(n.displayNode??e)??e.id}):void 0;default:return}}function Cc(e,t){var o;if(!t)return;let n=Rr(e,t),r=(o=e.assets)==null?void 0:o[t.id],i=Sc(r)?jt(r,"pippitAssetId"):void 0;return{...t,data:i&&!jt(n,"pippitAssetId")?{...n,pippitAssetId:i}:n}}function mp(e){let t=Object.fromEntries(Object.entries(e.metadata??{}).filter(([n])=>n!==hc&&n!=="audioVoiceAssetId"&&n!=="audioVoicePippitAssetId"&&n!=="audioVoiceDurationMs"&&n!=="audioVoiceSizeBytes"&&n!=="hasAudioVoice"));return{...e,metadata:Object.keys(t).length?t:void 0}}var CC="roleReferenceNodeId";function Ac(e){return typeof e=="string"?e.trim():""}function eie(e){return Array.isArray(e)?Array.from(new Set(e.map(Ac).filter(Boolean))):[]}function Ic(e){return Array.from(new Set([e.nodeAssetId,e.sourceNodeId,e.pippitAssetId,e.id].map(Ac).filter(Boolean)))}function tie(e,t){return t==="image"?!0:e==="video"&&(t==="audio"||t==="video")}function LO(e){var t;return Ac((t=e.metadata)==null?void 0:t[CC])||Ac(e.sourceNodeId)||Ac(e.nodeAssetId)||Ac(e.id)}function FO(e,t){let n=LO(t);return!!(n&&LO(e)===n)}function BO(e,t){return(e??[]).filter(n=>!FO(n,t))}function AC(e,t,n){let r=n===void 0?void 0:eie(n),i=[],o=!1;if((e??[]).forEach(s=>{if(!FO(s,t)){i.push(s);return}if(o)return;let c={...mp(s)};r===void 0?delete c.dataReferenceSelection:c.dataReferenceSelection=r,i.push(c),o=!0}),o)return i;let a={...mp(t),content:void 0};return r===void 0?delete a.dataReferenceSelection:a.dataReferenceSelection=r,i.push(a),i}function nie(e,t){if(t==="video")return Wb(e.content,e.metadata)}function GO(e,t){let n=e.content,r=Fa(n).filter(([,o])=>tie(t,Jb(o))).map(([o])=>o),i=nie(e,t);return[...r,...i?[i.pippitAssetId]:[]]}function zO(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function UO(e){return String(e??"").trim()}function Gh(e,t){let n=UO(t);return n?`${e}:${n}`:""}function zh(e){return Gh("node",e)}function Uh(e){var t;return zh(e.sourceNodeId)||zh((t=e.metadata)==null?void 0:t[CC])||Gh("pippit_asset",e.pippitAssetId)||Gh("asset",e.assetId)||Gh("reference",e.id)}function rie(e){return typeof e=="string"?zh(e):zO(e)?e.kind==="node"?zh(e.nodeId):e.kind==="reference"?UO(e.referenceKey):"":""}function za(e){if(!(!zO(e)||!Array.isArray(e.inputOrder)))return e.inputOrder}function Vh(e){if(!Array.isArray(e))return[];let t=[],n=new Set;return e.forEach(r=>{let i=rie(r);!i||n.has(i)||(n.add(i),t.push(i))}),t}function IC(e){return e.startsWith("node:")}function iie(e){return{kind:"reference",referenceKey:e}}function VO(e,t){let n=Vh(e);if(!n.length)return{changed:!1};let r=[],i=new Set;t.forEach(c=>{let d=Uh(c);!d||!IC(d)||i.has(d)||(i.add(d),r.push(d))});let o=n.some(IC),a=n.filter(c=>!IC(c)||i.has(c));return o&&r.forEach(c=>{a.includes(c)||a.push(c)}),{changed:a.length!==n.length||a.some((c,d)=>c!==n[d]),inputOrder:a.length?a.map(iie):void 0}}function qO(e,t){let n=Vh(t);if(!n.length)return[...e];let r=new Map(n.map((a,s)=>[a,s])),i=[],o=[];return e.forEach((a,s)=>{let c=Uh(a),d=c?r.get(c):void 0;if(d===void 0){o.push(a);return}i.push({index:s,rank:d,reference:a})}),i.sort((a,s)=>a.rank-s.rank||a.index-s.index),[...i.map(({reference:a})=>a),...o]}var oie="xyqLocalImageUploadTask";function KO(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function vc(e){var n,r;let t=(r=KO((n=KO(e))==null?void 0:n.extra))==null?void 0:r[oie];return en(t,"image")?t:void 0}function fo(e){return typeof e=="string"?e.trim():""}function aie({reference:e,audioContent:t}){if(!np(e))return e;let n=e.content,r=yn(n),i=fo(r==null?void 0:r.audioNodeId),o=mp(e);if(!i)return o;let a={...n==null?void 0:n.voiceInfo},s={...o,content:{...n,voiceInfo:a}},c=fo(t==null?void 0:t.pippitAssetId);if(!t||!c)return delete a.audioPippitAssetId,delete a.audioAssetId,delete a.audioDurationMs,delete a.audioSource,s;let d=fo(t.assetId)||void 0,u=Hk(t.generation),p=ip(t);a.audioPippitAssetId=c,d?a.audioAssetId=d:delete a.audioAssetId,u?a.audioSource=u:delete a.audioSource,p!==void 0?a.audioDurationMs=p:delete a.audioDurationMs;let m=fo(t.src),f=_O(t);return{...s,metadata:{...s.metadata??{},...f!==void 0?{audioVoiceSizeBytes:f}:{},[hc]:{assetId:d,audioNodeId:i,...u?{audioSource:u}:{},durationMs:p,name:fo(t.name)||fo(r==null?void 0:r.audioName)||fo(t.assetId)||void 0,pippitAssetId:c,...f!==void 0?{sizeBytes:f}:{},...m?{url:m}:{}}}}}function xc(e,t){if(!np(t))return t;let n=t.nodeAssetId||t.sourceNodeId||t.id,r=n?Zt(e.assets[n]):void 0,i=r?Gn({...t,content:r}):t,o=yn(i.content),a=fo(o==null?void 0:o.audioNodeId),s=a?e.assets[a]:void 0,c=(s==null?void 0:s.type)===fe?Rr(e,{id:a}):void 0,d=aie({reference:i,audioContent:c});return{...d,metadata:{...d.metadata,...Ti({audioVoiceAssetId:Ih(d.content),audioVoiceDurationMs:vh(d.content),hasAudioVoice:Ah(d.content)})}}}var qh=[ee,qe,Z,Oe],sie=new Set(qh),cie=new Set([...qh,fe]),die=new Set([...qh,J,fe]),uie=new Set([...qh,J,fe]);function pie(e){return e==="video"?die:e==="audio"?cie:e==="text"?uie:sie}function lie(e,t){return t.type==="image"||(e==="audio"||e==="text")&&t.type==="audio"||(e==="video"||e==="text")&&t.type==="video"}function mie(e,t){let n=e.assets[t];return typeof n=="object"&&n!==null&&"content"in n?n.content:void 0}function fie(e,t,n){if(!pie(n.target).has(t.type))return;let i=bc(Cc(e,t),void 0,{content:mie(e,t.id),displayNode:t,localUploadTask:vc(e.assets[t.id])});if(!i||!lie(n.target,i)||!String(i.nodeAssetId??i.pippitAssetId??"").trim())return;let o=Gn({...i,referenceSource:i.referenceSource??"canvas-node",sourceNodeId:i.sourceNodeId??t.id,sourceNodeType:i.sourceNodeType??t.type});return n.target==="video"?xc(e,o):o}function vC(e,t,n){let r=M(e);return Object.values(r.nodes).filter(i=>i.id!==t).map(i=>fie(e,i,n)).filter(i=>!!i)}function hie(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function gie(e,t){var r;let n=t!=null&&t.id?(r=e.assets)==null?void 0:r[t.id]:void 0;if(!(!hie(n)||!("content"in n)))return n.content??void 0}function yie(e,t){let n=Vh(t);if(!n.length)return;let r=[],i=new Set;if(e.forEach(o=>{let a=Uh(o);!a||i.has(a)||(i.add(a),r.push(a))}),r.length===n.length)return n.every(o=>i.has(o))?t:void 0}function Kh(e,t,n={}){let r=M(e),i=r.nodes[t],o=za(i==null?void 0:i.data)??za(Rr(e,i)),a=Object.values(r.edges).filter(s=>s.target===t).map(s=>{let c=r.nodes[s.source],d=bc(Cc(e,c),s,{allowGenericNodeAsset:n.allowGenericNodeAssets,content:gie(e,c),displayNode:c,localUploadTask:vc(c!=null&&c.id?e.assets[c.id]:void 0)});return d?xc(e,d):void 0}).filter(s=>!!s);return qO(a,yie(a,o))}var jh="generation.normalizeInputOrder";function Ua(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function HO(e){return e===ee||e===J}function jO(e,t){var i;if(!Ua(e)||!za(e))return{changed:!1,data:e};let n=VO(e.inputOrder,t);if(!n.changed)return{changed:!1,data:e};let r={...e};return(i=n.inputOrder)!=null&&i.length?r.inputOrder=n.inputOrder:delete r.inputOrder,{changed:!0,data:r}}function _ie(e){let t=M(e),n=!1;return Object.values(t.nodes).forEach(r=>{if(!HO(r.type))return;let i=Kh(e,r.id),o=jO(r.data,i);o.changed&&Ua(r.data)&&Ua(o.data)&&(dn(r.data,o.data),n=!0);let a=e.assets[r.id];if(!Ua(a)||!Ua(a.content))return;let s=jO(a.content,i);s.changed&&Ua(s.data)&&(dn(a.content,s.data),n=!0)}),n}function Tie(e){let t=M(e);return Object.values(t.nodes).some(n=>{if(!HO(n.type))return!1;if(za(n.data))return!0;let r=e.assets[n.id];return Ua(r)&&za(r.content)!==void 0})}function Sie(e){Tie(e.getState())&&e.transact(t=>{_ie(t)},{intent:jh,undoable:!1,source:"local"})}function $O(e){return e.subscribe(({transaction:t})=>{t.intent!==jh&&Sie(e)})}var YO=new Map([[Z,"generationRole"],[Oe,"generationScene"],[ee,"generationImage"],[qe,"generationPanorama"],[J,"generationVideo"],[fe,"generationAudio"]]);function Ht(e){return String(e??"").trim()}function xC(e){let t=Ht(e.sourceNodeId);return t?`source:${t}`:[e.type,e.nodeAssetId||e.pippitAssetId||e.assetId||e.url||e.label||e.id].map(Ht).filter(Boolean).join("|")}function bie(e){return!!Ht(e.sourceNodeId)}function Cie(e,t){let n=Ht(t.assetId),r=Ht(t.pippitAssetId);if(!n&&!r)return!1;let i=Ht(e.assetId),o=Ht(e.pippitAssetId);return r&&o?r!==o:n&&i?n!==i:!1}function XO(e,t,n){return e&&t?n?{...e,...t}:{...t,...e}:n?t??e:e??t}function WO(...e){let t=[],n=new Map;return e.forEach(r=>{r==null||r.forEach(i=>{let o=xC(i);if(!o)return;let a=n.get(o);if(a!==void 0){let s=t[a],c=bie(i),d=c&&Cie(s,i),u=(m,f,h=!1)=>c?f??(h?void 0:m):m??f,p=(m,f)=>c&&d?f:m??f;t[a]={...i,...s,assetId:u(s.assetId,i.assetId,d),content:u(s.content,i.content),dataReferenceSelection:u(s.dataReferenceSelection,i.dataReferenceSelection),edgeId:s.edgeId||i.edgeId,label:u(s.label,i.label),mediaSource:u(s.mediaSource,i.mediaSource,d),metadata:XO(s.metadata,i.metadata,c),nodeAssetExtra:XO(s.nodeAssetExtra,i.nodeAssetExtra,c),nodeAssetId:u(s.nodeAssetId,i.nodeAssetId),nodeAssetType:u(s.nodeAssetType,i.nodeAssetType),pippitAssetId:u(s.pippitAssetId,i.pippitAssetId,d),placeholderUrl:p(s.placeholderUrl,i.placeholderUrl),referenceSource:s.referenceSource||i.referenceSource,sourceNodeId:s.sourceNodeId||i.sourceNodeId,sourceNodeType:u(s.sourceNodeType,i.sourceNodeType),thumbnailUrl:p(s.thumbnailUrl,i.thumbnailUrl),uploadPath:u(s.uploadPath,i.uploadPath,d),url:p(s.url,i.url)};return}n.set(o,t.length),t.push(i)})}),t}function JO(e){let t=Ht(e.type),n=Ht(e.sourceNodeType),r=Ht(e.nodeAssetType);return t==="audio"||n===fe||r===fe?"audio":t==="video"||n===J||r===J?"video":"image"}function Aie(e){let t=Ht(e.sourceNodeType),n=Ht(e.nodeAssetType),r=YO.get(t)??YO.get(n);if(r)return r;let i=Ht(e.type);return i==="audio"?"generationAudio":i==="video"?"generationVideo":"generationImage"}function QO(e){if(Aie(e)!=="generationRole")return{};let{subjectName:t,variantName:n}=e.metadata??{},r=Ht(n),i=Ht(t);return{...r?{appearanceName:r}:{},...i?{roleName:i}:{}}}var Iie=/<([a-z][\w-]*)(?:\s[^>]*)?>[\s\S]*?<\/\1>/i;function ZO(e){return(e==null?void 0:e.trim())||void 0}function vie(e){return e===" "||e===" "||e===" "}function xie(e){let t=new Map,n=new Map;e.forEach(i=>{let o=ZO(i.appearanceName);o&&!t.has(o)&&t.set(o,i);let a=ZO(i.roleName);if(!a)return;let s=n.get(a)??new Map;s.set(i.id,i),n.set(a,s)});let r=[...t].map(([i,o])=>({name:i,priority:0,replacement:o.replacement}));return n.forEach((i,o)=>{if(t.has(o)||i.size!==1)return;let a=i.values().next().value;a&&r.push({name:o,priority:1,replacement:a.replacement})}),r.sort((i,o)=>o.name.length-i.name.length||i.priority-o.priority)}function Rie(e,t){let n="",r=0;for(;r<e.length;){if(e[r]!=="@"&&e[r]!=="@"){n+=e[r],r+=1;continue}let i=r+1;for(;vie(e[i]);)i+=1;let o=t.find(a=>e.startsWith(a.name,i));if(!o){n+=e[r],r+=1;continue}n+=o.replacement,r=i+o.name.length}return n}function e0(e,t){let n=xie(t);return!e||n.length===0||Iie.test(e)?e:Rie(e,n)}var RC="<duration-ms>[^<]*<\\/duration-ms>|<camera-motion>[^<]*<\\/camera-motion>|<(?:extend|tail_frame|reference_last_frame)>[^<]+<\\/(?:extend|tail_frame|reference_last_frame)>";var pJe=new RegExp(`${er.source}|${RC}`,"gi");var t0=new Set(["image"]),n0=new Set(["audio","image","video"]);function nr(e){return String(e??"").trim()}function DC(e){let t=[];er.lastIndex=0;for(let n of String(e??"").matchAll(er)){let r=!!n[4],i=nr(r?n[4]:n[3]);i&&t.push({tagId:i,tagType:n[1]==="node-asset"?"node-asset":"pippit-asset-id"})}return er.lastIndex=0,t}function PC(e){return nr(e.sourceNodeId)||nr(e.nodeAssetId)}function Eie(e,t){let n=nr(e.tagId);return n?e.tagType==="node-asset"?[nr(t.sourceNodeId),nr(t.nodeAssetId),nr(t.id)].includes(n):nr(t.pippitAssetId)===n:!1}function r0(e,t){let n=nr(e.materialPippitAssetId);return!!(e.tagType==="node-asset"&&n&&nr(t.pippitAssetId)===n)}function Mie(e,t){return e.tagType==="pippit-asset-id"||r0(e,t)}function Nie(e,t,n){let r=t.filter(o=>n.has(nr(o.type))),i=r.filter(o=>Eie(e,o));return i.length?i:r.filter(o=>r0(e,o))}function EC({acceptedTypes:e,references:t,tags:n}){let r=[],i=[],o=new Set,a=new Set;return n.forEach(s=>{let c=Nie(s,t,e),d=c.find(m=>PC(m))??c[0];if(!d)return;let u=PC(d);if(u){a.has(u)||(a.add(u),i.push(d));return}if(!Mie(s,d))return;let p=xC(d);p&&!o.has(p)&&(o.add(p),r.push(d))}),{assetReferences:r,edgeReferences:i}}function i0({connectReference:e,...t}){let n=EC(t);for(let r of n.edgeReferences)e(PC(r));return n}function Tt(e){return String(e??"").trim()}var wie=new RegExp("^(\\u56fe\\u7247|\\u89c6\\u9891|\\u97f3\\u9891|\\u6587\\u4ef6)\\s+(\\d+)$");function Va(e){return Tt(e).replace(wie,"$1$2")}var kie="camera-motion:";function Oie(e){return Tt(e).startsWith(kie)}function o0(e,t,n){let r=Tt(e);if(!r)return"";let i=Va(t),o=Dh(n);return i&&Oie(r)&&(o.label=i),pO(r,o)}function a0(e,t){let n=Tt(e);return Eh(n,t)}var Lie=String.fromCharCode(35270,39057),s0=/【\s*@?\s*(图片|图|视频)\s*(\d+)\s*】|@\s*(图片|图|视频)\s*(\d+)|(图片|图|视频)\s*(\d+)/g;function d0(e){return Tt(e.sourceNodeId)||Tt(e.nodeAssetId)||Tt(e.pippitAssetId)||Tt(e.id)||Tt(e.name)}function Fie({mentionItems:e,mentionSourceItems:t}){let n=[],r=new Set,i=o=>{o==null||o.forEach(a=>{let s=d0(a);!s||r.has(s)||(r.add(s),n.push(a))})};return i(e),Object.values(t??{}).forEach(i),n}function Bie(e){return e===Lie?"video":"image"}function Gie(e,t){return t==="video"?e.type==="video":e.type==="image"||e.type==="character"}function zie(e,t,n){if(!Number.isInteger(n)||n<=0)return;let r=e.filter(i=>Gie(i,t))[n-1];return r?{...r,label:r.name}:void 0}function Uie(e,t){let n=Va(t.replace(/[【】@]/g,"").trim());if(!n)return;let r=e.find(i=>[Va(i.name),Va(i.originalName),Va(i.displayName)].some(o=>o==null?void 0:o.includes(n)));return r?{...r,label:r.name}:void 0}function u0(e){if(!e)return"";let t=Tt(e.nodeAssetId)||Tt(e.sourceNodeId);if(t)return a0(t);let n=Tt(e.pippitAssetId)||Tt(e.id);return n?o0(n,Va(e.label)):""}function Vie(e){return e.sourceType==="generationRole"||e.nodeAssetType===Z||e.sourceNodeType===Z||e.type==="character"}function qie(e){return e.filter(Vie).flatMap(t=>{let n=u0({...t,label:t.name}),r=d0(t);return!r||!n?[]:[{appearanceName:Tt(t.appearanceName),id:r,replacement:n,roleName:Tt(t.roleName)}]})}function Kie(e,t){return s0.lastIndex=0,e.replace(s0,(n,...r)=>{let[i,o,a,s,c,d]=r,u=Tt(i||a||c),p=Tt(o||s||d),m=Number.parseInt(p,10),f=zie(t,Bie(u),m),h=Uie(t,n);return u0(f??h)||n})}function c0(e,t,n){return e0(Kie(e,t),n)}function p0(e,t={}){let n=String(e??""),r=Fie(t);if(!n||!r.length)return{changed:!1,value:n};let i=!1,o=t.enableRoleMentionResolution?qie(r):[],a=0,s=[];Ba.lastIndex=0;for(let u of n.matchAll(Ba)){let p=u.index??0,m=u[0]||"",f=n.slice(a,p),h=c0(f,r,o);i||=h!==f,s.push(h,m),a=p+m.length}Ba.lastIndex=0;let c=n.slice(a),d=c0(c,r,o);return i||=d!==c,s.push(d),{changed:i,value:i?s.join(""):n}}var $h="generation.normalizePromptMentionContent";function zn(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function rr(e){return String(e??"").trim()}function MC(e){return rr(e)===Th.CanvasMentionText}function jie(e){let t=rr(e);return t==="video"||t==="audio"||t==="text"?t:"image"}function Hie(e,t){let n=rr(e.label)||rr(e.sourceNodeId)||rr(e.nodeAssetId)||rr(e.pippitAssetId)||rr(e.id)||`material-${t+1}`,r=rr(e.id)||rr(e.sourceNodeId)||rr(e.nodeAssetId)||rr(e.pippitAssetId)||n;return{...QO(e),id:r,name:n,originalName:n,type:JO(e),nodeAssetId:e.nodeAssetId||e.sourceNodeId,nodeAssetType:e.nodeAssetType,pippitAssetId:e.pippitAssetId,sourceNodeId:e.sourceNodeId,sourceNodeType:e.sourceNodeType}}function $ie(e){return(e??[]).map((t,n)=>Hie({...t,type:jie(t.type)},n))}function Yie(e,t={}){if(!zn(e)||!zn(e.generation))return{changed:!1,data:e};let n=e.generation;if(!MC(n.promptContentFormat))return{changed:!1,data:e};let r={...n};delete r.promptContentFormat;let i=typeof n.prompt=="string"?n.prompt:void 0;if(i===void 0)return{changed:!0,data:{...e,generation:r}};let o=$ie(t.mentionReferences),a=p0(i,{mentionItems:o});return r.prompt=a.value,{changed:!0,data:{...e,generation:r}}}function Hh(e){return e===ee||e===J}function m0(e,t,n){if(typeof n=="string")return n;if(t in e.nodes)return e.nodes[t].type}function l0(e,t,n){return Yie(n,{mentionReferences:Kh(e,t)})}function Xie(e){let t=M(e),n=!1;return Object.values(t.nodes).forEach(r=>{if(!Hh(r.type)||!zn(r.data))return;let i=l0(e,r.id,r.data);i.changed&&zn(i.data)&&(dn(r.data,i.data),n=!0)}),Object.entries(e.assets).forEach(([r,i])=>{if(!zn(i)||!zn(i.content))return;let o=m0(t,r,i.type);if(!Hh(o))return;let a=l0(e,r,i.content);a.changed&&zn(a.data)&&(dn(i.content,a.data),n=!0)}),n}function Wie(e){let t=M(e);return Object.values(t.nodes).some(r=>Hh(r.type)&&zn(r.data)&&zn(r.data.generation)&&MC(r.data.generation.promptContentFormat))?!0:Object.entries(e.assets).some(([r,i])=>{if(!zn(i)||!zn(i.content)||!zn(i.content.generation))return!1;let o=m0(t,r,i.type);return Hh(o)&&MC(i.content.generation.promptContentFormat)})}function Jie(e){Wie(e.getState())&&e.transact(t=>{Xie(t)},{intent:$h,undoable:!1,source:"local"})}function f0(e){return e.subscribe(({transaction:t})=>{t.intent!==$h&&Jie(e)})}var fp="link",Qie=new Set(["http:","https:","mailto:","tel:"]),Zie=/^[a-z][a-z\d+.-]*:/i;function eoe(e){return Zie.test(e)}function toe(e){return e.startsWith("/")||e.startsWith("#")||e.startsWith("?")}function Yh(e){if(typeof e!="string")return null;let t=e.trim();if(!t||toe(t))return null;let n=eoe(t)?t:`https://${t}`;try{let r=new URL(n);return!Qie.has(r.protocol)||(r.protocol==="http:"||r.protocol==="https:")&&!r.hostname?null:n}catch{return null}}function h0(e){return e.replace(/[()\s]/g,t=>encodeURIComponent(t))}function g0(e,t){let n=Yh(t);return n?`[${e}](${h0(n)})`:e}function noe(e){return e.type==="paragraph"||e.type==="heading"||e.type==="listItem"||e.type==="bulletList"||e.type==="orderedList"||e.type==="blockquote"||e.type==="table"||e.type==="tableRow"}function Rc(e){var t,n,r;if(!e)return"";if(typeof e.text=="string"){let i=(r=(n=(t=e.marks)==null?void 0:t.find(o=>o.type===fp))==null?void 0:n.attrs)==null?void 0:r.href;return g0(e.text,i)}return e.type==="table"?(e.content??[]).map(Rc).filter(Boolean).join(`
12
+ `):e.type==="tableRow"?(e.content??[]).map(Rc).join(" "):e.type==="tableCell"||e.type==="tableHeader"?(e.content??[]).map(Rc).filter(Boolean).join(`
13
+ `):(e.content??[]).flatMap((i,o)=>{let a=Rc(i);return o>0&&noe(i)?[`
14
+ `,a]:[a]}).join("")}var roe=/\\([\\`*_[\]{}()#+\-.!>~|])/g,ioe=/!\[[^\]]*]\([^)]+\)/,ooe=2,aoe=2;function _0(e,t){let n=0;for(let r=t-1;r>=0&&e[r]==="\\";r-=1)n+=1;return n%ooe===1}function y0(e,t){return e.some(n=>n.type===t.type)?e:[...e,t]}function Xh(e,t){let n=e.replace(roe,"$1");return n?[{type:"text",text:n,...t.length?{marks:t}:{}}]:[]}function soe(e){let t=e.replace(/[\r\n]/g," "),r=t.startsWith(" ")&&t.endsWith(" ")&&/[^ ]/.test(t)?t.slice(1,-1):t;return r?[{type:"text",text:r,marks:[{type:"code"}]}]:[]}function T0(e,t){let n=0;for(;e[t+n]==="`";)n+=1;return n}function coe(e,t,n){let r=t;for(;r<e.length;){let i=e.indexOf("`",r);if(i<0)return-1;let o=T0(e,i);if(o===n)return i;r=i+o}return-1}function S0(e){for(let t=0;t<e.length;t+=1){if(e[t]!=="`"||_0(e,t))continue;let n=T0(e,t),r=coe(e,t+n,n);if(r>=0)return{close:r,delimiterLength:n,open:t};t+=n-1}return null}function b0(e){let t=e;for(;t;){let n=S0(t),r=n?t.slice(0,n.open):t;if(ioe.test(r))return!0;if(!n)return!1;t=t.slice(n.close+n.delimiterLength)}return!1}function NC(e,t,n){let r=e.indexOf(t,n);for(;r>=0&&_0(e,r);)r=e.indexOf(t,r+t.length);return r}function doe(e){let t=[{delimiter:"**",mark:{type:"bold"}},{delimiter:"__",mark:{type:"bold"}},{delimiter:"~~",mark:{type:"strike"}},{delimiter:"*",mark:{type:"italic"}},{delimiter:"_",mark:{type:"italic"}}],n=null;for(let r=0;r<e.length;r+=1){if(e[r]==="\\"){r+=1;continue}for(let i of t){if(!e.startsWith(i.delimiter,r))continue;let o=NC(e,i.delimiter,r+i.delimiter.length);o<=r+i.delimiter.length||(!n||r<n.open||i.delimiter.length>n.delimiter.length)&&(n={...i,close:o,open:r})}if((n==null?void 0:n.open)===r)return n}return n}function uoe(e){for(let t=0;t<e.length;t+=1){if(e[t]==="\\"){t+=1;continue}if(e[t]!=="["||e[t-1]==="!")continue;let n=NC(e,"]",t+1);if(n<=t+1||e[n+1]!=="(")continue;let r=n+aoe,i=NC(e,")",r);if(i<=r)continue;let o=Yh(e.slice(r,i).trim());if(o)return{close:i,href:o,label:e.slice(t+1,n),open:t}}return null}function qa(e,t=[]){let n=S0(e),r=uoe(e),i=doe(e);if(n&&(!r||n.open<=r.open)&&(!i||n.open<=i.open))return[...Xh(e.slice(0,n.open),t),...soe(e.slice(n.open+n.delimiterLength,n.close)),...qa(e.slice(n.close+n.delimiterLength),t)];if(r&&(!i||r.open<=i.open)){let d={type:fp,attrs:{href:r.href}};return[...Xh(e.slice(0,r.open),t),...qa(r.label,y0(t,d)),...qa(e.slice(r.close+1),t)]}if(!i)return Xh(e,t);let{close:o,delimiter:a,mark:s,open:c}=i;return[...Xh(e.slice(0,c),t),...qa(e.slice(c+a.length,o),y0(t,s)),...qa(e.slice(o+a.length),t)]}var poe="markdown";function loe(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function moe(e){return typeof e=="string"&&e.trim().toLowerCase()===poe}function foe(e){if(typeof e.markdownText=="string")return e.markdownText;if(typeof e.plainText=="string")return e.plainText}function C0(e){return{type:"paragraph",...e?{content:[{type:"text",text:e}]}:{}}}function wC(e,t){let n=0;for(let r=t-1;r>=0&&e[r]==="\\";r-=1)n+=1;return n%2===1}function hoe(e){let t=e.trim(),n=0,r=t.length;return t[n]==="|"&&(n+=1),r>n&&t[r-1]==="|"&&!wC(t,r-1)&&(r-=1),t.slice(n,r)}function kC(e){let t=hoe(e),n=[],r="";for(let i=0;i<t.length;i+=1){let o=t[i];if(o==="\\"&&t[i+1]==="|"&&!wC(t,i)){r+="|",i+=1;continue}if(o==="|"&&!wC(t,i)){n.push(r.trim()),r="";continue}r+=o}return n.push(r.trim()),n}function OC(e){let t=kC(e);if(t.length<2)return null;let n=[];for(let r of t){let i=r.trim();if(!/^:?-{3,}:?$/.test(i))return null;let o=i.startsWith(":"),a=i.endsWith(":");n.push(o&&a?"center":a?"right":o?"left":null)}return n}function v0(e,t){let n=e[t]??"",r=e[t+1]??"";return n.includes("|")&&OC(r)!==null}function x0(e){return/^\s{0,3}([-*_])(\s*\1){2,}\s*$/.test(e)}function goe(e){let t=e.match(/^\s*(`{3,}|~{3,})(.*)$/);if(!t)return!1;let n=t[1],r=t[2];return n.startsWith("~")||!r.includes("`")}function yoe(e){return!!(goe(e)||/^( {4}|\t)\S/.test(e)||/^\s{0,3}#{5,6}\s+/.test(e)||/^\s{0,3}>\s*>/.test(e)||/^\s{2,}([-+*]|\d+[.)])\s+/.test(e)||/^\s{0,3}[-+*]\s+\[[ xX]\]\s+/.test(e)||/^\s{0,3}<[A-Za-z][^>]*>/.test(e))}function hp(e){return yoe(e)||b0(e)}function Wh(e,t,n){let r=qa(t);return{type:e,...n?{attrs:n}:{},...r.length?{content:r}:{}}}function LC(e){return!e.trim()}function R0(e){return e.match(/^\s{0,3}(#{1,4})\s+(.+?)\s*#*\s*$/)}function FC(e){return e.match(/^\s{0,3}[-+*]\s+(.+)$/)}function BC(e){return e.match(/^\s{0,3}\d+[.)]\s+(.+)$/)}function GC(e){return e.match(/^\s{0,3}>\s?(.*)$/)}function _oe(e){return{type:"listItem",content:[Wh("paragraph",e)]}}function Toe(e,t,n){return{type:e,attrs:{colspan:1,rowspan:1,colwidth:null,...n?{align:n}:{}},content:[Wh("paragraph",t)]}}function A0(e,t,n,r){return{type:"tableRow",content:Array.from({length:r},(i,o)=>Toe(e,t[o]??"",n[o]??null))}}function Soe(e,t){let n=OC(e[t+1]??"");if(!n||!(e[t]??"").includes("|"))return null;let r=kC(e[t]??""),i=[],o=t+2;for(;o<e.length;){let c=e[o];if(LC(c)||hp(c)||!c.includes("|")||OC(c))break;i.push(kC(c)),o+=1}let a=Math.max(r.length,n.length,...i.map(c=>c.length)),s=[A0("tableHeader",r,n,a),...i.map(c=>A0("tableCell",c,n,a))];return{nextIndex:o,node:{type:"table",content:s}}}function I0(e,t,n){let r=[],i=t;for(;i<e.length&&!hp(e[i]);){let o=n?BC(e[i]):FC(e[i]);if(!o)break;r.push(_oe(o[1]??"")),i+=1}return{nextIndex:i,node:{type:n?"orderedList":"bulletList",content:r}}}function boe(e,t,n){let r=[],i=t;for(;i<e.length&&!hp(e[i]);){let o=GC(e[i]);if(!o)break;r.push(o[1]??""),i+=1}return{nextIndex:i,node:{type:"blockquote",content:n(r)}}}function Coe(e){return!!(x0(e)||R0(e)||GC(e)||FC(e)||BC(e))}function Aoe(e,t){let n=[],r=t;for(;r<e.length&&!LC(e[r])&&!hp(e[r])&&!Coe(e[r])&&!v0(e,r);)n.push(e[r].trim()),r+=1;return{nextIndex:r,node:Wh("paragraph",n.join(" "))}}function P0(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(LC(r)){n+=1;continue}if(hp(r)){t.push(C0(r)),n+=1;continue}if(x0(r)){t.push({type:"horizontalRule"}),n+=1;continue}let i=v0(e,n)?Soe(e,n):null;if(i){t.push(i.node),n=i.nextIndex;continue}let o=R0(r);if(o){t.push(Wh("heading",o[2]??"",{level:o[1].length})),n+=1;continue}if(GC(r)){let u=boe(e,n,P0);t.push(u.node),n=u.nextIndex;continue}if(FC(r)){let u=I0(e,n,!1);t.push(u.node),n=u.nextIndex;continue}if(BC(r)){let u=I0(e,n,!0);t.push(u.node),n=u.nextIndex;continue}let d=Aoe(e,n);t.push(d.node),n=d.nextIndex}return t.length?t:[C0("")]}function Ioe(e){return{type:"doc",content:P0(e.replace(/\r\n/g,`
15
15
  `).split(`
16
- `))}}function Zn(e){if(!pK(e)||!lK(e.contentFormat))return{changed:!1,data:e};let t=fK(e),n={...e};if(delete n.contentFormat,t===void 0)return{changed:!0,data:n};let r=EK(t),o=ts(r);return{changed:!0,data:{...n,content:r,markdownText:typeof n.markdownText=="string"?n.markdownText:t,plainText:o}}}var Au="text.normalizeMarkdownContent";function Bm(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function CK(e){let t=x(e),n=!1;return Object.entries(t.nodes).forEach(([r,o])=>{if(o.type!==Ie||!Bm(o.data))return;let s=Zn(o.data);s.changed&&(o.data=s.data,n=!0)}),Object.entries(e.assets).forEach(([r,o])=>{var a;if(!Bm(o)||!Bm(o.content)||(typeof o.type=="string"?o.type:(a=t.nodes[r])==null?void 0:a.type)!==Ie)return;let i=Zn(o.content);i.changed&&(o.content=i.data,n=!0)}),n}function PK(e){e.transact(t=>{CK(t)},{intent:Au,undoable:!1,source:"local"})}function wR(e){return e.subscribe(({transaction:t})=>{t.intent!==Au&&PK(e)})}function xK(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function OR(e,t,n="media.localUploadTask.clear",r={}){return e.transact(o=>{let s=o.assets[t],i=xK(s==null?void 0:s.content)?s.content:void 0;!i||!Object.prototype.hasOwnProperty.call(i,"localUploadTask")||delete i.localUploadTask},{intent:n,mergeKey:`local-upload-task:${t}`,...r.system?{source:"system",undoable:!1}:{}})}var DR="role-scene",bDe=[DR,...Fd];function TK(e){return e===DR||Tr(e)}function kR(e){var n;let t=(n=x(e).settings.autoLayout)==null?void 0:n.strategy;return typeof t=="string"&&t.trim()||void 0}function MR({configuredStrategies:e,storedStrategy:t}){if(e!=null&&e.length)return TK(t)&&e.includes(t)?t:e[0]}var NK="canvas is read-only";function LR(e){return(t,n)=>{if(t.source==="remote"||t.intent===Au||t.intent===mu||t.intent===hu){n();return}throw t.source==="local"&&(e==null||e()),new Te(NK,"READ_ONLY")}}function BR(e,t){let n=kR(e.getState()),r=MR({configuredStrategies:t,storedStrategy:n});!r||n===r||e.transact(o=>{let{settings:s}=x(o);s.autoLayout={...s.autoLayout,strategy:r}},{intent:"settings.normalizeAutoLayoutStrategy",undoable:!1})}function GR(e,t=!1){return Object.values(x(e).nodes).some(n=>{var s,i;if(!t){if(n.type!==L)return!1;let a=(s=ui(e,n))==null?void 0:s.data;return eu(a==null?void 0:a.localUploadTask,"image")}if(n.type===z||n.type===he)return eu(ea(e.assets[n.id]),"image");let r;if(n.type===L?r="image":n.type===M&&(r="video"),!r)return!1;let o=(i=ui(e,n))==null?void 0:i.data;return eu(o==null?void 0:o.localUploadTask,r)})}function UR(e,t){var n,r;for(let o of Object.values(x(e).nodes)){if(o.type!==L)continue;let s=(r=(n=ui(e,o))==null?void 0:n.data)==null?void 0:r.localUploadTask;Nt(s,"image")&&s.status==="capturing"&&!s.cacheId&&OR(t,o.id,"image.upload.clearRestoredCapturingTask")}}var qR="biz/auto-layout";function zR(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:void 0}function wK(e){let t={};if(!e)return t;Tr(e.strategy)&&(t.strategy=e.strategy);let n=zR(e.horizontalGap);n!==void 0&&(t.horizontalGap=n);let r=zR(e.verticalGap);return r!==void 0&&(t.verticalGap=r),t}var Gm={type:qR,run:e=>{e.commands.autoLayoutNodes(wK(e.directive.params))}};var FR="biz/layout-group",OK="horizontal-directed-cluster",DK=["horizontal","vertical","grid","horizontal-directed-cluster","vertical-directed-cluster"];function kK(e){return DK.includes(e)?e:void 0}function MK(e){return e==="vertical-directed-cluster"||e==="horizontal-directed-cluster"?e:OK}var Um={type:FR,run:e=>{var r,o;if(e.carrier.kind!=="node")return;let t=e.store.getRootCanvasContent().nodes[e.carrier.nodeId];if((t==null?void 0:t.type)!==be)return;let n=kK((r=e.directive.params)==null?void 0:r.strategy)??MK((o=e.store.getRootCanvasContent().settings.autoLayout)==null?void 0:o.strategy);e.commands.arrangeNodes([e.carrier.nodeId],n)}};var VR="biz/resize-node";function jR(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:void 0}var zm={type:VR,run:e=>{if(e.carrier.kind!=="node")return;let t=e.directive.params??{},n=jR(t.w),r=jR(t.h);n===void 0||r===void 0||e.commands.resizeNode(e.carrier.nodeId,{w:n,h:r})}};var HR=Ml(),LK=[Gm,zm,Um];for(let e of LK)HR.register(e);function qm(){return HR}function ns(e){return String(e??"").trim()}function Fm(e){return Array.from(new Set(e.map(ns).filter(Boolean)))}function YR(e,t){let n=hm(e),r=new Set(t.map(ns).filter(Boolean));return r.size===0?n:n.replace(Hr,(o,s,i,a)=>s==="node-asset"&&r.has(ns(a))?"":o)}function KR({nextSelectableSelection:e,previousDefaultSelection:t,prompt:n,reference:r,selectionReplacements:o}){let s=new Set(Ji(r));if(!s.size)return{explicitSelection:[],hasRoleMention:!1,prompt:n};let i=Object.fromEntries(Object.entries(o??{}).map(([p,l])=>[ns(p),ns(l)]).filter(([p,l])=>p&&p!==l)),a=[],d=!1,c=0,u=[];Wo.lastIndex=0;for(let p of String(n??"").matchAll(Wo)){let l=p.index??0;u.push(n.slice(c,l)),c=l+p[0].length;let f=ns(p[3]);if(p[1]!=="node-asset"||!s.has(f)){u.push(p[0]);continue}d=!0;let h=Qc(p);if(!(Vi in h)){u.push(p[0]);continue}let m=Fm(fm(h[Vi])??[]),g=Fm(m.map(y=>i[y]??y));a.push(...g),g.length&&u.push(Jc(f,{...h,[Vi]:M_(g)}))}return Wo.lastIndex=0,u.push(n.slice(c)),{explicitSelection:Fm(a),hasRoleMention:d,prompt:u.join("")}}function BK(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function GK(e){return e===L||e===M||e===ue}function UK(e,t){let{nodes:n}=x(e),r=new Set,o=s=>{if(r.has(s))return;let i=n[s];if(!i)return;r.add(s);let{children:a}=i;Array.isArray(a)&&a.forEach(o)};return t.forEach(o),r}function zK(e,t){let n=x(e),r=UK(e,t);return r.size===0?[]:Object.values(n.nodes).flatMap(o=>{if(r.has(o.id)||!GK(o.type))return[];let s=ci(e,o.id),i=BK(s==null?void 0:s.generation)?s.generation:void 0,a=typeof(i==null?void 0:i.prompt)=="string"?i.prompt:void 0;if(a===void 0)return[];let d=YR(a,[...r]);return d===a?[]:[{generation:{...i,prompt:d},nodeId:o.id}]})}function XR(e){let{deleteNodes:t}=e.commands,n=r=>{let o=zK(e.getState(),r);return o.length===0?t(r):e.commands.batch("node.delete",s=>{t(r),o.forEach(({generation:i,nodeId:a})=>{s.updateNodeData(a,{generation:i})})})};return e.commands.deleteNodes=n,()=>{e.commands.deleteNodes===n&&(e.commands.deleteNodes=t)}}function qK(...e){let[t="",...n]=e,r=n.map(o=>o.replace(/^\/+|\/+$/g,"")).filter(Boolean).join("/");return r?`${t.replace(/\/+$/g,"")}/${r}`:t}function jm(e=""){return qK(vo.TOS.cmsStaticAssetBaseUrl,e)}function X(e){return{coverImageUrl:jm(`${e}.webp`),previewVideoUrl:jm(`${e}.mp4`)}}var FK={static_shot:X("01_%E5%9B%BA%E5%AE%9A%E9%95%9C%E5%A4%B4"),tilt_up:X("02_%E9%95%9C%E5%A4%B4%E4%B8%8A%E6%91%87"),tilt_down:X("03_%E9%95%9C%E5%A4%B4%E4%B8%8B%E6%91%87"),pan_left:X("04_%E9%95%9C%E5%A4%B4%E5%B7%A6%E6%91%87"),pan_right:X("05_%E9%95%9C%E5%A4%B4%E5%8F%B3%E6%91%87"),crane_up:X("06_%E9%95%9C%E5%A4%B4%E4%B8%8A%E5%8D%87"),crane_down:X("07_%E9%95%9C%E5%A4%B4%E4%B8%8B%E9%99%8D"),truck_left:X("08_%E9%95%9C%E5%A4%B4%E5%B7%A6%E7%A7%BB"),truck_right:X("09_%E9%95%9C%E5%A4%B4%E5%8F%B3%E7%A7%BB"),dolly_in:X("10_%E9%95%9C%E5%A4%B4%E5%89%8D%E6%8E%A8"),dolly_out:X("11_%E9%95%9C%E5%A4%B4%E5%90%8E%E7%A7%BB"),zoom_in:X("12_%E5%8F%98%E7%84%A6%E6%8E%A8%E8%BF%9B"),zoom_out:X("13_%E5%8F%98%E7%84%A6%E6%8B%89%E8%BF%9C"),follow_tracking:X("14_%E8%B7%9F%E9%9A%8F%E6%8B%8D%E6%91%84"),leading_tracking:X("15_%E8%BF%8E%E9%9D%A2%E8%B7%9F%E6%8B%8D"),profile_tracking:X("16_%E4%BE%A7%E9%9D%A2%E8%B7%9F%E6%8B%8D"),handheld_shot:X("17_%E6%89%8B%E6%8C%81%E6%8B%8D%E6%91%84"),pov_shot:X("18_%E7%AC%AC%E4%B8%80%E8%A7%86%E8%A7%92"),steadicam_walkthrough:X("19_%E7%A8%B3%E5%AE%9A%E5%99%A8%E8%A1%8C%E8%BF%9B"),slider_reveal:X("20_%E6%A8%AA%E6%BB%91%E6%8F%AD%E7%A4%BA"),foreground_wipe:X("21_%E5%89%8D%E6%99%AF%E6%93%A6%E8%BF%87"),push_through:X("22_%E7%A9%BF%E8%B6%8A%E9%95%9C%E5%A4%B4"),whip_pan:X("23_%E7%94%A9%E6%91%87"),rack_focus:X("24_%E7%84%A6%E7%82%B9%E8%BD%AC%E7%A7%BB"),crash_zoom:X("25_%E6%80%A5%E9%80%9F%E5%8F%98%E7%84%A6"),dolly_zoom:X("26_%E6%9F%AF%E5%85%8B%E5%8F%98%E7%84%A6"),orbit_180:X("27_%E7%8E%AF%E7%BB%95%E6%8B%8D%E6%91%84"),ascending_orbit:X("28_%E7%9B%98%E6%97%8B%E6%8A%AC%E5%8D%87"),descending_orbit:X("29_%E7%9B%98%E6%97%8B%E4%B8%8B%E9%99%8D"),aerial_establishing:X("30_%E9%AB%98%E7%A9%BA%E8%88%AA%E6%8B%8D"),fpv_flythrough:X("31_%E7%A9%BF%E8%B6%8A%E6%9C%BA%E8%BF%90%E9%95%9C"),drone_dive:X("32_%E4%BF%AF%E5%86%B2%E4%B8%8B%E9%99%8D"),pull_away:X("33_%E6%8B%89%E5%8D%87%E7%A6%BB%E5%9C%BA")};function $R(e){let t=FK[e.id];return t?{...e,url:t.coverImageUrl,previewVideoUrl:t.previewVideoUrl}:e}var eE=["AnyDream_2.0","anycook_1_standard","anycook_1_creative","seedream_5.0_pro","NanoPro","Nano2"],tE=[{value:"auto"},{value:"21:9"},{value:"16:9"},{value:"9:16"},{value:"3:4"},{value:"4:3"},{value:"3:2"},{value:"2:3"},{value:"1:1"}],nE=[{value:"1K"},{value:"2K"},{value:"3K"},{value:"4K"}],VK=[{value:"3K"},{value:"4K"}],HK=[{value:"1K"},{value:"2K"},{value:"4K"}],YK=[{value:"1K"},{value:"2K"},{value:"4K"}],Hm={aspectRatio:tE,resolution:nE},WR={...Hm,resolution:VK},QR={...Hm,resolution:HK},KK={...Hm,resolution:YK},vu={aspectRatio:"9:16",resolution:"3K"},JR={...vu,resolution:"2K"},XK={...vu,resolution:"1K"},$K={maxImageReferences:10},oa=["text_to_image","image_to_image"],WK=["image_to_image"],rE=[{modelId:"AnyDream_2.0",modelKind:"image",modes:oa,defaultMode:"text_to_image",settingOptions:WR,defaultSettings:vu},{modelId:"anycook_1_standard",modelKind:"image",modes:oa,defaultMode:"text_to_image",settingOptions:WR,defaultSettings:vu},{modelId:"anycook_1_creative",modelKind:"image",modes:WK,defaultMode:"image_to_image",referenceLimits:{minImageReferences:1}},{modelId:"seedream_5.0_pro",modelKind:"image",modes:oa,defaultMode:"text_to_image",referenceLimits:$K,settingOptions:KK,defaultSettings:XK},{modelId:"NanoPro",modelKind:"image",modes:oa,defaultMode:"text_to_image",settingOptions:QR,defaultSettings:JR},{modelId:"Nano2",modelKind:"image",modes:oa,defaultMode:"text_to_image",settingOptions:QR,defaultSettings:JR}];var ZK=[{value:"480p"},{value:"720p"},{value:"1080p"}],eX=[{value:"auto"},{value:"16:9"},{value:"4:3"},{value:"1:1"},{value:"3:4"},{value:"9:16"}];function tX(e,t){return{...e,aspectRatio:eX,resolution:ZK,durationSec:t}}function nX(e){return{...e,aspectRatio:"auto",resolution:"720p",durationSec:10}}function oE({durationOptions:e,modes:t,standardVideoDefaultSettings:n,standardVideoSettings:r}){return{modelId:"wan3.0",modelKind:"video",modes:t,defaultMode:"text_to_video",referenceLimits:{maxImageReferences:10},settingOptions:tX(r,e),defaultSettings:nX(n)}}var iX={auto:void 0,"16:9":2,"21:9":8,"9:16":3,"3:4":5,"4:3":4,"3:2":void 0,"2:3":void 0,"1:1":6},aX={2:"16:9",8:"21:9",3:"9:16",4:"4:3",5:"3:4",6:"1:1"},dX=["seedance_1.0","seedance1.5_direct","Seedance_2.0_mini_lite","Seedance_2.0_lite","seedance2.0_direct","seedance2.0_fast_direct","seedance2.0_vision","seedance2.0_fast_vision","Seedance_2.5","MiniMax-H3","wan3.0","happyhorse-1.1"],cX=[{value:"auto"},{value:"16:9"},{value:"21:9"},{value:"9:16"},{value:"4:3"},{value:"3:4"},{value:"1:1"}],uX=[{value:"480p"},{value:"720p_lite"},{value:"720p"}],pX=[{value:"720p"},{value:"1080p"},{value:"4k"}],lX=[{value:"480p"},{value:"720p"},{value:"1080p"},{value:"4k"}],fX=[{value:"768p"},{value:"2k"}],mX=[{value:"720p"},{value:"1080p"}],Km=[{value:4},{value:5},{value:6},{value:7},{value:8},{value:9},{value:10},{value:11},{value:12},{value:13},{value:14},{value:15}],hX=[{value:3},...Km],iE=[...Km,{value:16},{value:17},{value:18},{value:19},{value:20},{value:21},{value:22},{value:23},{value:24},{value:25},{value:26},{value:27},{value:28},{value:29},{value:30}],gX=[{value:!1},{value:!0}];var yX=[{id:"static_shot",label:"固定镜头",promptValue:"固定镜头",tag:"基础控制",desc:"建立冷静秩序",submitPromptText:"运镜:固定机位,镜头位置和拍摄方向都保持不变,画面构图稳定,由主体动作或画面内部变化形成运动感。"},{id:"tilt_up",label:"镜头上摇",promptValue:"镜头上摇",tag:"基础控制",desc:"展示高度威压",submitPromptText:"运镜:固定机位上摇,镜头位置不移动,只沿垂直方向缓慢向上转动,画面重心从下方逐步移向上方。"},{id:"tilt_down",label:"镜头下摇",promptValue:"镜头下摇",tag:"基础控制",desc:"从环境落到人",submitPromptText:"运镜:固定机位下摇,镜头位置不移动,只沿垂直方向缓慢向下转动,画面重心从上方逐步移向下方。"},{id:"pan_left",label:"镜头左摇",promptValue:"镜头左摇",tag:"基础控制",desc:"横向展示空间",submitPromptText:"运镜:固定机位左摇,镜头位置不移动,只沿水平方向缓慢向左转动,让画面内容从右向左连续变化。"},{id:"pan_right",label:"镜头右摇",promptValue:"镜头右摇",tag:"基础控制",desc:"引出画外信息",submitPromptText:"运镜:固定机位右摇,镜头位置不移动,只沿水平方向缓慢向右转动,让画面内容从左向右连续变化。"},{id:"crane_up",label:"镜头上升",promptValue:"镜头上升",tag:"基础控制",desc:"展开场景规模",submitPromptText:"运镜:镜头垂直上升,拍摄方向基本保持稳定,机位高度从低到高变化,画面视角随高度产生变化。"},{id:"crane_down",label:"镜头下降",promptValue:"镜头下降",tag:"基础控制",desc:"从全局聚焦",submitPromptText:"运镜:镜头垂直下降,拍摄方向基本保持稳定,机位高度从高到低变化,画面视角随高度产生变化。"},{id:"truck_left",label:"镜头左移",promptValue:"镜头左移",tag:"基础控制",desc:"制造空间视差",submitPromptText:"运镜:镜头左移,机位整体向左横向平移,拍摄方向基本不变,前景与背景形成自然视差。"},{id:"truck_right",label:"镜头右移",promptValue:"镜头右移",tag:"基础控制",desc:"制造空间视差",submitPromptText:"运镜:镜头右移,机位整体向右横向平移,拍摄方向基本不变,前景与背景形成自然视差。"},{id:"dolly_in",label:"镜头前推",promptValue:"镜头前推",tag:"基础控制",desc:"强调情绪靠近",submitPromptText:"运镜:镜头缓慢前推,机位沿镜头朝向向前移动,主体在画面中逐渐变大,空间层次产生自然视差。"},{id:"dolly_out",label:"镜头后移",promptValue:"镜头后移",tag:"基础控制",desc:"展示人物孤独",submitPromptText:"运镜:镜头缓慢后拉,机位沿镜头朝向向后移动,主体在画面中逐渐变小,画面范围逐步变宽。"},{id:"zoom_in",label:"变焦推进",promptValue:"变焦推进",tag:"基础控制",desc:"突出表情反应",submitPromptText:"运镜:缓慢变焦推进,机位保持不动,只通过焦距变化让画面范围逐渐收紧。"},{id:"zoom_out",label:"变焦拉远",promptValue:"变焦拉远",tag:"基础控制",desc:"从局部到全貌",submitPromptText:"运镜:缓慢变焦拉远,机位保持不动,只通过焦距变化让画面范围逐渐放宽。"},{id:"follow_tracking",label:"跟随拍摄",promptValue:"跟随拍摄",tag:"人物跟拍",desc:"跟住人物行动",submitPromptText:"运镜:跟随拍摄,镜头跟随主体运动方向移动,与主体保持相对稳定的距离和构图。"},{id:"leading_tracking",label:"迎面跟拍",promptValue:"迎面跟拍",tag:"人物跟拍",desc:"保留人物表情",submitPromptText:"运镜:迎面跟拍,镜头位于主体前方并随主体运动同步后退,保持主体正面信息稳定可见。"},{id:"profile_tracking",label:"侧面跟拍",promptValue:"侧面跟拍",tag:"人物跟拍",desc:"强化行进节奏",submitPromptText:"运镜:侧面跟拍,镜头在主体侧方与其平行移动,保持侧向构图稳定,并形成横向空间视差。"},{id:"handheld_shot",label:"手持拍摄",promptValue:"手持拍摄",tag:"人物跟拍",desc:"增加真实紧张",submitPromptText:"运镜:手持拍摄,镜头带轻微自然晃动和近距离临场感,可随主体动作产生小幅调整。"},{id:"pov_shot",label:"第一视角",promptValue:"第一视角",tag:"人物跟拍",desc:"进入角色视角",submitPromptText:"运镜:第一视角,镜头模拟角色视线和身体移动,带轻微头部晃动和主观视角的运动反馈。"},{id:"fpv_flythrough",label:"穿越机运镜",promptValue:"穿越机运镜",tag:"空间航拍",desc:"高速掠过空间",submitPromptText:"运镜:穿越机运镜,fpv 镜头以第一视角高速穿行空间,贴近场景边界和主体灵活飞行,带明显速度感与滚转俯仰变化。"},{id:"steadicam_walkthrough",label:"稳定器行进",promptValue:"稳定器行进",tag:"人物跟拍",desc:"平稳进入现场",submitPromptText:"运镜:稳定器行进,镜头以稳定、连续的方式向前或跟随移动,运动平滑,晃动幅度低。"},{id:"slider_reveal",label:"横滑揭示",promptValue:"横滑揭示",tag:"揭示转场",desc:"从遮挡露主体",submitPromptText:"运镜:横滑揭示,镜头从遮挡关系中横向滑出,逐步露出被遮挡的主体或关键信息。"},{id:"foreground_wipe",label:"前景擦过",promptValue:"前景擦过",tag:"揭示转场",desc:"用遮挡完成切换",submitPromptText:"运镜:前景擦过,近处遮挡物从镜头前掠过并短暂覆盖画面,随后露出新的画面内容。"},{id:"push_through",label:"穿越镜头",promptValue:"穿越镜头",tag:"揭示转场",desc:"穿过边界入场",submitPromptText:"运镜:穿越镜头,镜头持续快速向前推进,并产生短暂运动模糊,穿过明确的前景边界或空间层次,进入后方画面,最后落到新的构图或目标上。"},{id:"whip_pan",label:"甩摇",promptValue:"甩摇",tag:"揭示转场",desc:"快速切换信息",submitPromptText:"运镜:甩摇,镜头快速水平转动并产生短暂运动模糊,最后落到新的构图或目标上。"},{id:"rack_focus",label:"焦点转移",promptValue:"焦点转移",tag:"揭示转场",desc:"注意力换目标",submitPromptText:"运镜:焦点转移,镜头位置可以不变,焦点从一个画面层次平滑切换到另一个画面层次。"},{id:"crash_zoom",label:"急速变焦",promptValue:"急速变焦",tag:"情绪强化",desc:"放大狗血反应",submitPromptText:"运镜:急速变焦推进,机位保持不动,画面范围快速收紧到目标区域,形成突然强调。"},{id:"dolly_zoom",label:"希区柯克",promptValue:"希区柯克",tag:"情绪强化",desc:"现实崩塌瞬间",submitPromptText:"运镜:希区柯克式变焦,机位移动与反向变焦同时发生,主体大小基本保持稳定,背景透视发生明显变化。"},{id:"orbit_180",label:"环绕拍摄",promptValue:"环绕拍摄",tag:"情绪强化",desc:"强化人物气场",submitPromptText:"运镜:环绕拍摄,镜头围绕主体平稳旋转约180度,主体保持在画面核心位置,背景产生连续旋转视差。"},{id:"ascending_orbit",label:"盘旋抬升",promptValue:"盘旋抬升",tag:"情绪强化",desc:"高光登场时刻",submitPromptText:"运镜:盘旋抬升,镜头围绕主体旋转的同时逐渐升高,主体保持锁定,机位高度持续变化。"},{id:"descending_orbit",label:"盘旋下降",promptValue:"盘旋下降",tag:"情绪强化",desc:"巨物压迫登场",submitPromptText:"运镜:盘旋下降,镜头围绕主体旋转的同时逐渐降低,主体保持锁定,机位高度持续变化。"},{id:"aerial_establishing",label:"高空航拍",promptValue:"高空航拍",tag:"空间航拍",desc:"建立宏大世界",submitPromptText:"运镜:高空航拍,镜头以高角度俯视画面,并保持稳定滑行,用于呈现空间关系和整体布局。"},{id:"drone_dive",label:"俯冲下降",promptValue:"俯冲下降",tag:"空间航拍",desc:"从高空压向目标",submitPromptText:"运镜:俯冲下降,镜头从高处向目标方向快速下降并靠近,形成明显速度感和压迫感。"},{id:"pull_away",label:"拉升离场",promptValue:"拉升离场",tag:"空间航拍",desc:"人变小世界变大",submitPromptText:"运镜:拉升离场,镜头从主体附近向后并向上移动,主体在画面中逐渐变小,画面范围逐步扩大。"}],AX=yX.map($R),vX=new Map(AX.map(e=>[e.id,e])),Wt={aspectRatio:cX,resolution:uX,durationSec:Km,soundEffectEnabled:gX},aE={...Wt,resolution:pX},SX={...aE,resolution:lX,durationSec:iE},bX={...Wt,resolution:fX},IX={...Wt,resolution:mX,durationSec:hX},_X={...Wt,resolution:[{value:"480p"},{value:"720p"}]},Qt={aspectRatio:"9:16",resolution:"720p_lite",durationSec:10,soundEffectEnabled:!1},RX=["text_to_video","omni_reference","image_to_video","image_reference"],bke={modelId:"seedance_1.0",modelKind:"video",modes:RX,defaultMode:"text_to_video",referenceLimits:{maxImageReferences:9},settingOptions:Wt,defaultSettings:Qt},sE={...Qt,resolution:"720p"},EX={...Qt,resolution:"720p"},CX={...Qt,aspectRatio:"16:9",resolution:"768p"},PX={...Qt,aspectRatio:"16:9",resolution:"720p",durationSec:5},xX=["text_to_video","omni_reference","image_to_video","image_reference"],TX=["text_to_video","image_to_video","first_last_frame"],er=["text_to_video","omni_reference","image_to_video","first_last_frame","image_reference"],NX=[...er,"video_edit","video_extend"],Ike=[{modelId:"seedance1.5_direct",modelKind:"video",modes:TX,defaultMode:"text_to_video",settingOptions:Wt,defaultSettings:Qt},...["Seedance_2.0_mini_lite","Seedance_2.0_lite"].map(e=>({modelId:e,modelKind:"video",modes:er,defaultMode:"text_to_video",settingOptions:_X,defaultSettings:EX})),{modelId:"seedance2.0_direct",modelKind:"video",modes:er,defaultMode:"text_to_video",settingOptions:Wt,defaultSettings:Qt},{modelId:"seedance2.0_fast_direct",modelKind:"video",modes:er,defaultMode:"text_to_video",settingOptions:Wt,defaultSettings:Qt},{modelId:"seedance2.0_vision",modelKind:"video",modes:er,defaultMode:"text_to_video",settingOptions:aE,defaultSettings:sE},{modelId:"seedance2.0_fast_vision",modelKind:"video",modes:er,defaultMode:"text_to_video",settingOptions:Wt,defaultSettings:Qt},{modelId:"Seedance_2.5",modelKind:"video",modes:NX,defaultMode:"text_to_video",settingOptions:SX,defaultSettings:sE},{modelId:"MiniMax-H3",modelKind:"video",modes:er,defaultMode:"text_to_video",referenceLimits:{maxImageReferences:5},settingOptions:bX,defaultSettings:CX},oE({durationOptions:iE,modes:er,standardVideoDefaultSettings:Qt,standardVideoSettings:Wt}),{modelId:"happyhorse-1.1",modelKind:"video",modes:xX,defaultMode:"text_to_video",referenceLimits:{maxImageReferences:9},settingOptions:IX,defaultSettings:PX},...rE];var Gke={"seedance1.0":"seedance_1.0",seedance_1_5:"seedance1.5_direct","seedance_1.5":"seedance1.5_direct","seedance1.5":"seedance1.5_direct",seedance_2_0_lite:"Seedance_2.0_lite","seedance_2.0_lite":"Seedance_2.0_lite","seedance2.0_lite":"Seedance_2.0_lite","seedance2.0lite":"Seedance_2.0_lite",seedance_2_0_mini:"Seedance_2.0_lite","seedance_2.0_mini":"Seedance_2.0_lite","seedance2.0_mini":"Seedance_2.0_lite","seedance2.0mini":"Seedance_2.0_lite",seedance_2_0_mini_lite:"Seedance_2.0_mini_lite","seedance_2.0_mini_lite":"Seedance_2.0_mini_lite","seedance2.0_mini_lite":"Seedance_2.0_mini_lite","seedance2.0minilite":"Seedance_2.0_mini_lite",seedance_2_0:"seedance2.0_direct","seedance_2.0":"seedance2.0_direct","seedance2.0":"seedance2.0_direct",seedance_2_0_fast:"seedance2.0_fast_direct","seedance_2.0_fast":"seedance2.0_fast_direct","seedance2.0_fast":"seedance2.0_fast_direct",seedance_2_0_vision:"seedance2.0_vision","seedance_2.0_vision":"seedance2.0_vision",seedance_2_0_fast_vision:"seedance2.0_fast_vision","seedance_2.0_fast_vision":"seedance2.0_fast_vision",seedance_2_5:"Seedance_2.5","seedance_2.5":"Seedance_2.5","seedance2.5":"Seedance_2.5",seedance_25:"Seedance_2.5",seedance25:"Seedance_2.5",seedance_2_5_vision:"Seedance_2.5","seedance2.5_direct":"Seedance_2.5","seedance_2.5_direct":"Seedance_2.5","seedance2.5direct":"Seedance_2.5","seedance_2.5_fast":"Seedance_2.5","seedance2.5_fast":"Seedance_2.5","seedance_2.5_fast_direct":"Seedance_2.5","seedance2.5fast":"Seedance_2.5","seedance2.5fastdirect":"Seedance_2.5","seedance_2.5_vision":"Seedance_2.5","seedance2.5_vision":"Seedance_2.5","seedance2.5vision":"Seedance_2.5","seedance_2.5_fast_vision":"Seedance_2.5","seedance2.5_fast_vision":"Seedance_2.5","seedance2.5_fastvision":"Seedance_2.5","seedance2.5fastvision":"Seedance_2.5","seedance_2.5_lite":"Seedance_2.5","seedance2.5_lite":"Seedance_2.5","seedance2.5lite":"Seedance_2.5",seedance_2_5_lite:"Seedance_2.5","seedance_2.5_pro":"Seedance_2.5","seedance2.5_pro":"Seedance_2.5","seedance2.5pro":"Seedance_2.5","minimax-h3":"MiniMax-H3",minimax_h3:"MiniMax-H3",minimaxh3:"MiniMax-H3","happyhorse-1.1":"happyhorse-1.1","happyhorse_1.1":"happyhorse-1.1",happyhorse_1_1:"happyhorse-1.1",happyhorse11:"happyhorse-1.1"},Uke={nano:"AnyDream_2.0",gpt_image_2:"Nano2",nano2:"Nano2",nanopro:"NanoPro","seedream_5.0_pro":"seedream_5.0_pro",anydream_2:"AnyDream_2.0",anydream2:"AnyDream_2.0","anydream2.0":"AnyDream_2.0",anydream_2_0:"AnyDream_2.0","anydream_2.0":"AnyDream_2.0",anycook_1_standard:"anycook_1_standard",anycook_1_creative:"anycook_1_creative",seedream_4:"AnyDream_2.0","seedream_4.1":"AnyDream_2.0","seedream_4.3":"AnyDream_2.0","seedream_4.5":"AnyDream_2.0","seedream_5.0":"AnyDream_2.0"};var zke={around:"orbit_180",push_in:"dolly_in",pull_back:"dolly_out",left_tracking:"truck_left",right_tracking:"truck_right"};function cE(e){if(e===L)return"image";if(e===M)return"video"}function Xm(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function sa(e){return typeof e=="string"?e.trim():""}function wX(e){return Array.from(new Set(e.map(sa).filter(Boolean)))}function OX(e){return Array.isArray(e==null?void 0:e.references)?e.references:[]}function uE(e,t){return Ji(e).includes(t)}function DX(e,t){return wX(e.map(n=>t[n]??n))}function kX(e,t,n){let r=e.assets[t];r&&Xm(r.content)&&Object.assign(r.content,{generation:n});let o=x(e).nodes[t];o&&Xm(o.data)&&Object.assign(o.data,{generation:n})}function ia({document:e,nextRoleContent:t,previousRoleContent:n,roleNodeId:r,selectionReplacements:o}){let s=Object.fromEntries(Object.entries(o??{}).map(([a,d])=>[sa(a),sa(d)]).filter(([a,d])=>a&&a!==d));if(!Object.keys(s).length)return;let i=x(e);Object.values(i.nodes).forEach(a=>{if(!cE(a.type))return;let d=e.assets[a.id];if(!d||!Xm(d.content))return;let{generation:c}=d.content;if(!c)return;let u=OX(c),l=u.find(y=>uE(y,r))??{nodeAssetId:r,type:"image"},f=typeof c.prompt=="string"?c.prompt:"",h=KR({nextSelectableSelection:[],previousDefaultSelection:[],prompt:f,reference:l,selectionReplacements:s}),m=u.map(y=>!uE(y,r)||!Array.isArray(y.dataReferenceSelection)?y:{...y,dataReferenceSelection:DX(y.dataReferenceSelection,s)});!m.some((y,v)=>y!==u[v])&&h.prompt===f||kX(e,a.id,{...c,prompt:h.prompt,references:m})})}function pE({document:e,nextPippitAssetId:t,previousPippitAssetId:n,roleContent:r,roleNodeId:o}){let s=sa(n),i=sa(t);!s||s===i||ia({document:e,nextRoleContent:r,previousRoleContent:r,roleNodeId:o,selectionReplacements:{[s]:i}})}var MX=["assetId","caption","generation","metadata","naturalHeight","naturalWidth","pippitAssetId","source","sourceType"];function tr(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function lE(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function $m(e){return tr(e)&&tr(e.appearanceInfo)?e.appearanceInfo:void 0}function fE(e){var t;if(tr(e))return lE(e.pippitAssetId)??lE((t=$m(e))==null?void 0:t.pippitAssetId)}function LX(e){var n;if(!tr(e))return;let t=e.uploadPath??((n=$m(e))==null?void 0:n.uploadPath);return t==="legacy"||t==="optimized"?t:void 0}function BX(e){if(!tr(e)||!fE(e))return;let n=$m(e);if(n){let o=tr(e.generation)?{...e.generation}:void 0;return{appearanceInfo:Ko(n),...o?{generation:o}:{}}}let r={};return MX.forEach(o=>{e[o]!==void 0&&(r[o]=e[o])}),LX(e)==="optimized"&&(r.uploadPath="optimized",e.localUploadCache!==void 0&&(r.localUploadCache=e.localUploadCache),e.securityCheckScene!==void 0&&(r.securityCheckScene=e.securityCheckScene)),Object.keys(r).length?r:void 0}function os(e,t,n){var a;let r=(a=e.assets)==null?void 0:a[t];if(!r||!tr(r))return;let o=BX(n??r.content),s=fE(o);if(!o||!s)return;let i=tr(r.history)?r.history:void 0;r.history={...i??{},[s]:o}}var aa="xyq.role.updateAppearance";function Pe(e){return(e==null?void 0:e.trim())||void 0}function Wm(e){let t=new Set;return e.flatMap(n=>{let r=n.trim();return!r||t.has(r)?[]:(t.add(r),[r])})}function mE(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function nr(e,t){return Pe(e)===Pe(t)}function GX(e,t){var n,r;return t?nr((n=e.appearanceInfo)==null?void 0:n.assetId,t.assetId)&&nr((r=e.appearanceInfo)==null?void 0:r.pippitAssetId,t.pippitAssetId):!0}function UX(e){var t,n;return{runId:Pe((t=e==null?void 0:e.state)==null?void 0:t.runId)??Pe(e==null?void 0:e.runId),threadId:Pe((n=e==null?void 0:e.state)==null?void 0:n.threadId)??Pe(e==null?void 0:e.threadId)}}function zX(e,t){if(!t)return!0;let n=UX(e);return nr(n.runId??void 0,t.runId)&&nr(n.threadId??void 0,t.threadId)}function qX(e,t){return nr(e==null?void 0:e.prompt,t)}function FX(e,t){if(t===null){e.content.generation&&delete e.content.generation.prompt;return}e.content.generation??={},e.content.generation.prompt=t}function jX(e,t){let n=t.state.runId.trim(),r=t.state.threadId.trim();if(!n||!r)return;let{generation:o}=e.content;o||(o={},e.content.generation=o),o.runId=n,o.threadId=r,o.state={...structuredClone(t.state),runId:n,threadId:r}}function xn(e,t,n){if(!t||!Object.prototype.hasOwnProperty.call(t,n))return!0;let r=t[n];if(n==="voiceType")return e.voice_type===r;if(n==="description")return(e.description??"")===(r??"");if(n==="audioDurationMs")return(e.audioDurationMs??null)===(r??null);let o={audioAssetId:e.audioAssetId,audioName:e.audioName,audioNodeId:e.audioNodeId,audioPippitAssetId:e.audioPippitAssetId,audioSource:e.audioSource,voiceId:e.voiceId}[n];return nr(typeof o=="string"?o:void 0,typeof r=="string"?r:void 0)}function VX(e,t){let n=e.getState(),r=x(n).nodes[t.nodeId];if((r==null?void 0:r.type)!==z||r.id!==t.assetId)return;let o=n.assets[t.assetId];return o&&$t(o)?o:void 0}function HX(e,t,n){let r={...e.content.voiceInfo??{}};t.description!==void 0&&xn(r,n,"description")&&(r.description=t.description),t.voiceType!==void 0&&xn(r,n,"voiceType")&&(r.voice_type=t.voiceType),t.audioAssetId!==void 0&&xn(r,n,"audioAssetId")&&(r.audioAssetId=Pe(t.audioAssetId)),t.audioName!==void 0&&xn(r,n,"audioName")&&(r.audioName=Pe(t.audioName)),t.audioNodeId!==void 0&&xn(r,n,"audioNodeId")&&(r.audioNodeId=Pe(t.audioNodeId)),t.audioPippitAssetId!==void 0&&xn(r,n,"audioPippitAssetId")&&(r.audioPippitAssetId=Pe(t.audioPippitAssetId)),t.audioSource!==void 0&&xn(r,n,"audioSource")&&(r.audioSource=t.audioSource??void 0),t.voiceId!==void 0&&xn(r,n,"voiceId")&&(r.voiceId=Pe(t.voiceId)),t.audioDurationMs!==void 0&&xn(r,n,"audioDurationMs")&&(t.audioDurationMs===null||!Number.isFinite(t.audioDurationMs)||t.audioDurationMs<=0?delete r.audioDurationMs:r.audioDurationMs=t.audioDurationMs),e.content.voiceInfo=r,delete e.content.voice_info}function YX(e,t,n){var a,d;let r=Pe((a=e.content.appearanceInfo)==null?void 0:a.pippitAssetId),o=Pe(t.pippitAssetId),i=!!(o&&(o!==r||Pe(t.assetId)!==Pe((d=e.content.appearanceInfo)==null?void 0:d.assetId)))?k_(e.content,{assetId:Pe(t.assetId),imageSource:t.imageSource,isMain:!0,name:n,pippitAssetId:o,type:"image",uploadPath:t.uploadPath}):void 0;e.content.appearanceInfo={...(i==null?void 0:i.appearanceInfo)??e.content.appearanceInfo??{},...t.assetId!==void 0?{assetId:Pe(t.assetId)}:{},...t.pippitAssetId!==void 0?{pippitAssetId:Pe(t.pippitAssetId)}:{},...t.imageSource!==void 0?{imageSource:t.imageSource}:{},...t.uploadPath!==void 0?{uploadPath:t.uploadPath}:{}},i!=null&&i.sourceInfos&&(e.content.sourceInfos=i.sourceInfos)}function Qm(e,t){let n=VX(e,t);if(!n)return{status:"aborted",reason:"role asset not found"};let r=structuredClone(n.content);return e.transact(o=>{var h,m,g,y,v,S;let s=x(o).nodes[t.nodeId];if((s==null?void 0:s.type)!==z||s.id!==t.assetId)return;let i=jr(o.assets[t.assetId]);if(!(i!=null&&i.content))return;let{expected:a,patch:d}=t;d.characterName!==void 0&&(!a||!Object.prototype.hasOwnProperty.call(a,"characterName")||nr(s.data.name,a.characterName))&&(s.data.name=d.characterName,i.content.basicInfo={...i.content.basicInfo??{},name:d.characterName}),d.appearanceName!==void 0&&(!a||!Object.prototype.hasOwnProperty.call(a,"appearanceName")||nr((h=r.basicInfo)==null?void 0:h.appearanceName,a.appearanceName))&&(i.content.basicInfo={...i.content.basicInfo??{},appearanceName:d.appearanceName}),d.episodes!==void 0&&(!a||!Object.prototype.hasOwnProperty.call(a,"episodes")||mE(Wm(r.episodes??[]),Wm(a.episodes??[])))&&(i.content.episodes=Wm(d.episodes)),d.appearanceDescription!==void 0&&(i.content.appearanceInfo={...i.content.appearanceInfo??{},description:d.appearanceDescription});let c=!d.mainImage||GX(r,a==null?void 0:a.mainImage),u=d.generation===void 0||!a||!Object.prototype.hasOwnProperty.call(a,"generation")||mE(r.generation,a.generation),p=!!(d.mainImage&&d.generation!==void 0),l=c&&u;d.mainImage&&(p?l:c)&&YX(i,d.mainImage,d.appearanceName??((m=i.content.basicInfo)==null?void 0:m.appearanceName)),d.voice&&HX(i,d.voice,a==null?void 0:a.voice),d.generation!==void 0&&(p?l:u)&&(d.generation===null?delete i.content.generation:i.content.generation=structuredClone(d.generation)),d.generationPrompt!==void 0&&(!a||!Object.prototype.hasOwnProperty.call(a,"generationPrompt")||qX(r.generation,a.generationPrompt))&&FX(i,d.generationPrompt),d.generationRun&&(!a||!Object.prototype.hasOwnProperty.call(a,"generationRun")||zX(r.generation,a.generationRun))&&jX(i,d.generationRun),(((g=r.appearanceInfo)==null?void 0:g.pippitAssetId)!==((y=i.content.appearanceInfo)==null?void 0:y.pippitAssetId)||((v=r.appearanceInfo)==null?void 0:v.assetId)!==((S=i.content.appearanceInfo)==null?void 0:S.assetId))&&(os(o,t.assetId,r),os(o,t.assetId,i.content)),ia({document:o,nextRoleContent:i.content,previousRoleContent:r,roleNodeId:t.nodeId})},{intent:"role.updateAppearance",mergeKey:`role-appearance:${t.nodeId}`})}var da="xyq.role.updateSourceInfos";function ss(e){return typeof e=="string"?e.trim():""}function Jt(e){return e!==void 0&&(!e.type||e.type==="image")}function Jm(e){return[...e].sort((t,n)=>{let r=typeof t[1].order=="number"&&Number.isFinite(t[1].order)?t[1].order:0,o=typeof n[1].order=="number"&&Number.isFinite(n[1].order)?n[1].order:0;return r!==o?r-o:t[0].localeCompare(n[0])})}function KX(e){return Object.fromEntries($o(e.content))}function hE(e){let t=Object.fromEntries(Jm(Object.entries(e)).map(([n,r],o)=>[n,{...r,pippitAssetId:n,order:o}]));return Xo(t)??{}}function XX(e,t){!t||!Jt(t)||(e.content.appearanceInfo={...e.content.appearanceInfo??{},assetId:t.assetId,pippitAssetId:t.pippitAssetId,imageSource:2},t.uploadPath==="optimized"?e.content.appearanceInfo.uploadPath="optimized":delete e.content.appearanceInfo.uploadPath,Hc(e.content,{source:Yo.Uploaded}))}function $X(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,{...r,isMain:n===t,pippitAssetId:n}]))}function WX(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n,isMain:!1,pippitAssetId:t}]))}function gE(e){var t;return(t=Jm(Object.entries(e)).find(([,n])=>Jt(n)))==null?void 0:t[0]}function QX(e){var t;return(t=Object.entries(e).find(([,n])=>n.isMain===!0&&Jt(n)))==null?void 0:t[0]}function yE(e,t){let n=e[t];if(!n)return e;let r=Math.min(0,...Object.values(e).map(o=>typeof o.order=="number"&&Number.isFinite(o.order)?o.order:0));return{...e,[t]:{...n,order:r-1,pippitAssetId:t}}}function JX(e,t,n){let r=!1;return Object.values(x(e).nodes).forEach(o=>{if(o.type!==z)return;let s=jr(e.assets[o.id]);if(!(s!=null&&s.content))return;let i=Object.fromEntries($o(s.content)),a=i[t];!a||a.name===n||(s.content.sourceInfos={...i,[t]:{...a,name:n,pippitAssetId:t}},r=!0)}),r}function ZX(e,t,n,r){if(r.type==="setDefault")return!1;if(r.type==="setName"){let l=ss(r.pippitAssetId),f=r.name.trim();return!l||!f?!1:JX(e,l,f)}let o=KX(n),s={...n.content,appearanceInfo:{...n.content.appearanceInfo??{}},sourceInfos:hE(o)},i={...o},a,d=!1,c=QX(o);if(r.type==="upsert"){let l=ss(r.sourceInfo.pippitAssetId);if(!l)return!1;let f=Object.keys(i).length>0,h=Object.values(i).some(Jt),m=Math.max(-1,...Object.values(i).map(v=>typeof v.order=="number"&&Number.isFinite(v.order)?v.order:-1)),g=i[l],y={...g??{},...r.sourceInfo,isMain:r.sourceInfo.isMain??(g==null?void 0:g.isMain)??!f,order:r.sourceInfo.order??(g==null?void 0:g.order)??m+1,pippitAssetId:l,type:r.sourceInfo.type??(g==null?void 0:g.type)??"image"};i[l]={...y,isMain:Jt(y)&&(!h||y.isMain===!0)},i[l].isMain&&(i=yE(i,l),a=l)}if(r.type==="setMain"){let l=ss(r.pippitAssetId);if(!Jt(i[l]))return!1;i=yE(i,l),a=l}if(r.type==="delete"){let l=ss(r.pippitAssetId),f=i[l];if(!f||Object.keys(i).length<=1&&Jt(f))return!1;let h=f.isMain===!0?gE(Object.fromEntries(Object.entries(i).filter(([m])=>m!==l))):void 0;if(f.isMain===!0&&!h)return!1;delete i[l],h&&(a=h)}if(r.type==="reorder"){let l=ss(r.activePippitAssetId),f=ss(r.overPippitAssetId),h=i[l],m=i[f];if(!h||!m||l===f)return!1;i[l]={...h,order:m.order,pippitAssetId:l},i[f]={...m,order:h.order,pippitAssetId:f};let g=Jm(Object.entries(i))[0];if(!g)return!1;if(Jt(g[1]))a=g[0];else if(Object.values(i).some(Jt))return!1}i=hE(i);let u=Jt(i[c??""])?c:void 0,p=a??u??gE(i);return p?(i=$X(i,p),c!==p&&(a=p,d=!0)):i=WX(i),n.content.sourceInfos=i,a&&XX(n,i[a]),d&&(os(e,t,s),os(e,t,n.content)),ia({document:e,nextRoleContent:n.content,previousRoleContent:s,roleNodeId:t}),!0}function e3(e,t){let n=e.getState(),r=x(n).nodes[t.nodeId];if((r==null?void 0:r.type)!==z||r.id!==t.assetId)return;let o=n.assets[t.assetId];return o&&$t(o)?o:void 0}function Zm(e,t){return e3(e,t)?e.transact(n=>{let r=x(n).nodes[t.nodeId];if((r==null?void 0:r.type)!==z||r.id!==t.assetId)return;let o=jr(n.assets[t.assetId]);o!=null&&o.content&&ZX(n,t.assetId,o,t.operation)},{intent:"role.updateSourceInfos",mergeKey:`role-source-infos:${t.nodeId}:${t.operation.type}`,undoable:t.operation.type!=="setName"}):{status:"aborted",reason:"role asset not found"}}var t3=2e3,n3=5e3;function r3(e){return e!==void 0&&e>t3&&e<=n3}function eh(e){return e!==void 0&&!r3(e)}var nh="xyq.role.updateDescription";function AE(e){var a,d,c,u,p;let t=((a=e==null?void 0:e.audioAssetId)==null?void 0:a.trim())||((d=e==null?void 0:e.voiceId)==null?void 0:d.trim()),n=(c=e==null?void 0:e.audioPippitAssetId)==null?void 0:c.trim(),r=(u=e==null?void 0:e.audioName)==null?void 0:u.trim(),o=e==null?void 0:e.audioDurationMs,s=e==null?void 0:e.audioSource,i=(p=e==null?void 0:e.audioNodeId)==null?void 0:p.trim();if(!(!t&&!i&&!n&&!r&&(typeof o!="number"||!Number.isFinite(o)||o<=0)))return{assetId:t,audioNodeId:i,durationMs:o,name:r,pippitAssetId:n,audioSource:s}}function o3(e,t){var o;let n=t?(o=e.assets[t])==null?void 0:o.content:void 0;if(!n||typeof n!="object"||Array.isArray(n))return;let{pippitAssetId:r}=n;return typeof r=="string"&&r.trim()||void 0}function vE(e){let t=typeof e=="string"?e.split(/[、,,\s]+/):e??[],n=new Set,r=[];for(let o of t){let s=String(o).trim();!s||n.has(s)||(n.add(s),r.push(s))}return r}function s3(e,t){var r,o,s,i,a,d;let n=$t(e);return n?t==="voice"?((r=Pt(n))==null?void 0:r.description)??"":t==="characterName"?((o=n.basicInfo)==null?void 0:o.name)??"":t==="appearanceName"?((s=n.basicInfo)==null?void 0:s.appearanceName)??"":t==="episodes"?vE(n.episodes).join("、"):t==="voiceAudio"?AE(Pt(n)):t==="voiceType"?(i=Pt(n))==null?void 0:i.voice_type:((a=n.appearanceInfo)==null?void 0:a.description)??((d=n.basicInfo)==null?void 0:d.description)??"":""}function bu(e){var d,c,u,p,l;if(!e||typeof e!="object")return;let t=(d=e.assetId)==null?void 0:d.trim(),n=(c=e.name)==null?void 0:c.trim(),r=typeof e.durationMs=="number"&&Number.isFinite(e.durationMs)&&e.durationMs>0?e.durationMs:void 0,{audioSource:o}=e,s=(u=e.audioNodeId)==null?void 0:u.trim(),i=(p=e.pippitAssetId)==null?void 0:p.trim(),a=(l=e.previousPippitAssetId)==null?void 0:l.trim();if(!(!t&&!s&&!i&&!n&&r===void 0))return{...t?{assetId:t}:{},...s?{audioNodeId:s}:{},...r!==void 0?{durationMs:r}:{},...n?{name:n}:{},...o?{audioSource:o}:{},...i?{pippitAssetId:i}:{},...a?{previousPippitAssetId:a}:{}}}function i3(e){if(e===2)return 2;if(e===1)return 1;let t=bu(e);return(t!=null&&t.assetId||t!=null&&t.audioNodeId)&&!eh(t.durationMs)?2:1}function a3(e,t){let n=bu(e),r=bu(t);return((n==null?void 0:n.assetId)??"")===((r==null?void 0:r.assetId)??"")&&((n==null?void 0:n.audioNodeId)??"")===((r==null?void 0:r.audioNodeId)??"")&&((n==null?void 0:n.durationMs)??0)===((r==null?void 0:r.durationMs)??0)&&((n==null?void 0:n.name)??"")===((r==null?void 0:r.name)??"")&&((n==null?void 0:n.pippitAssetId)??"")===((r==null?void 0:r.pippitAssetId)??"")&&((n==null?void 0:n.audioSource)??"")===((r==null?void 0:r.audioSource)??"")}function th(e,t){e.content.voiceInfo={...Pt(e.content)??{},...t},delete e.content.voice_info}function d3(e,t){let n=e.getState(),r=x(n).nodes[t.nodeId];if((r==null?void 0:r.type)!==z||r.id!==t.assetId)return;let o=n.assets[t.assetId];if(!(!o||!$t(o)))return{asset:o,node:r}}function c3(e,t,n){var r,o,s;if(t.field==="characterName"){let i=typeof t.value=="string"?t.value:"";return n===t.value&&e.node.data.name===i}return t.field==="voiceAudio"?a3(n,t.value)&&!(typeof t.value=="object"&&((o=(r=t.value)==null?void 0:r.pippitAssetId)!=null&&o.trim())&&((s=t.value.previousPippitAssetId)!=null&&s.trim())&&t.value.pippitAssetId.trim()!==t.value.previousPippitAssetId.trim()):n===t.value}function u3(e,t){let n=d3(e,t);if(!n)return{status:"aborted",reason:"role asset not found"};let r=s3(n.asset,t.field);return c3(n,t,r)?{status:"noop",reason:"no-changes"}:e.transact(o=>{let s=x(o).nodes[t.nodeId];if((s==null?void 0:s.type)!==z||s.id!==t.assetId)return;let i=jr(o.assets[t.assetId]);if(!(i!=null&&i.content))return;if(t.field==="characterName"){let d=typeof t.value=="string"?t.value:"";s.data.name=d,i.content.basicInfo={...i.content.basicInfo??{},name:d};return}if(t.field==="appearanceName"){let d=typeof t.value=="string"?t.value:"";i.content.basicInfo={...i.content.basicInfo??{},appearanceName:d};return}if(t.field==="voice"){let d=typeof t.value=="string"?t.value:"";th(i,{description:d});return}if(t.field==="voiceAudio"){let d=AE(Pt(i.content)),c=bu(t.value);if(eh(c==null?void 0:c.durationMs))return;th(i,{audioAssetId:c==null?void 0:c.assetId,audioDurationMs:c==null?void 0:c.durationMs,audioName:c==null?void 0:c.name,audioNodeId:c==null?void 0:c.audioNodeId,audioPippitAssetId:c==null?void 0:c.pippitAssetId,audioSource:c==null?void 0:c.audioSource,voiceId:c==null?void 0:c.assetId});let u=(c==null?void 0:c.previousPippitAssetId)??(d==null?void 0:d.pippitAssetId)??o3(o,d==null?void 0:d.audioNodeId);u&&u!==(c==null?void 0:c.pippitAssetId)&&pE({document:o,nextPippitAssetId:c==null?void 0:c.pippitAssetId,previousPippitAssetId:u,roleContent:i.content,roleNodeId:t.nodeId});return}if(t.field==="voiceType"){let d=i3(t.value);th(i,{voice_type:d});return}if(t.field==="episodes"){i.content.episodes=vE(typeof t.value=="string"?t.value:void 0);return}let a=typeof t.value=="string"?t.value:"";i.content.appearanceInfo={...Ko(i.content.appearanceInfo),description:a}},{intent:"role.updateDescription",mergeKey:`role-description:${t.nodeId}:${t.field}`})}function SE(e){let t=e.commands.register(aa,Qm),n=e.commands.register(nh,u3),r=e.commands.register(da,Zm);return()=>{t(),n(),r()}}var rh="pippit-role",bE="base-model",IE="base",_E=vo.ASSETS.entries[rh].path;function p3(e){return P(e)?De(e.captureId)&&!!e.captureId.trim()&&Oe(e.createdAt)&&Nt(e):!1}function RE(e){return e===void 0?!0:P(e)?Object.entries(e).every(([t,n])=>p3(n)&&n.captureId===t):!1}var Qr="biz/scene3d-director",l3=Qr,f3="biz/scene3d-director-document";function oh(){return O.t("Pippit_xyqcanvas_legacy_title_3d_director_s_desk",{},"3D 导演台")}var CMe=oh();function m3(){return O.t("Pippit_xyqcanvas_scene3ddirector_defaultname_democharacter",{},"角色1")}var h3={baseAction:"idle",additiveWeights:{},boneRotations:{},controlValues:{bodyBend:0,bodyTilt:0,bodyTurn:0,headNod:0,headTilt:0,headTurn:0,lArmRaise:0,lArmStraddle:0,lArmTurn:0,lElbowBend:0,lKneeBend:0,lLegRaise:0,lLegStraddle:0,lLegTurn:0,rArmRaise:0,rArmStraddle:0,rArmTurn:0,rElbowBend:0,rKneeBend:0,rLegRaise:0,rLegStraddle:0,rLegTurn:0,torsoBend:0,torsoTilt:0,torsoTurn:0},posePresetId:"tpose",rootPositionOffset:{x:0,y:0,z:0},speed:1};function sh(){return{version:1,nodes:[{id:"character_1",type:"character",name:m3(),visible:!0,locked:!1,transform:{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}},metadata:{assetCategory:bE,assetId:rh,assetSource:IE,defaultCharacterIndex:1,modelUrl:_E},character:{gender:"female",placeholder:!0,appearance:{color:"#d7b5ee"},label:{scale:1,yOffset:1.1},animation:h3}}],aspectRatio:"21:9",settings:{gridVisible:!0,helpersVisible:!0,compositionGuide:"none",transformMode:"translate",viewMode:"director"},environment:{transform:{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}},background:{skyColor:"#060608"},sphere:{orientationVersion:1,rotationX:0,rotationY:90,radius:180},display:{characterLabelsVisible:!0,gridSnapEnabled:!1,groundVisible:!1,groundOpacity:1}}}}var g3=["assetId","pippitAssetId","previewUrl","url","naturalWidth","naturalHeight","latestCaptureAt","directorDocument","metadata"];function y3(e){return g3.some(t=>t in e)}function A3(e){return P(e)?!y3(e)&&_(e.title)&&_(e.name)&&_(e.caption)&&_(e.subType)&&Vc(e.source)&&RE(e.captureUploadTasks):!1}function v3(e){return e===void 0?!0:P(e)?Oe(e.width)&&Oe(e.height):!1}function S3(e){return P(e)?e.kind==="pippit-asset"&&De(e.pippitAssetId)&&e.schemaVersion===1:!1}function b3(e){return{kind:"pippit-asset",pippitAssetId:e,schemaVersion:1}}function I3(e){return{version:2,documentRef:e}}function _3(e){return`${e}_document`}function R3({document:e,documentAssetId:t,nodeId:n}){return{pippitAssetId:t,type:f3,content:e,extra:{sourceNodeId:n}}}function EE({document:e=sh(),documentAssetId:t,nodeId:n}){let r=t??_3(n),o=b3(r);return[{pippitAssetId:n,type:l3,content:I3(o),extra:{}},R3({document:e,documentAssetId:r,nodeId:n})]}function ih(e){if(!P(e))return!1;let t=e.cover===void 0||P(e.cover)&&De(e.cover.pippitAssetId)&&!!e.cover.pippitAssetId.trim();return e.version===2&&S3(e.documentRef)&&t}function is(e){return P(e)?e.version===1&&Array.isArray(e.nodes)&&(_(e.activeCameraId)||_(e.activeShotCameraNodeId))&&De(e.aspectRatio)&&v3(e.customAspectRatio)&&P(e.settings)&&P(e.environment)&&(e.captures===void 0||Array.isArray(e.captures)):!1}function CE(e){var t;if(!(!P(e)||!ih(e.content)))return((t=e.content.cover)==null?void 0:t.pippitAssetId.trim())||void 0}var ca={type:Qr,validate:A3,getDefaultSize:()=>({w:420,h:236})};var E3=["/content/generation","/content/data/generation"],C3=["","/content","/content/data"],P3="generation requires field-level updates",x3=2e3,ua=new Set;function PE(e){if(!Ye(e))return!1;let t=Ye(e.content)?e.content:e,n=Ye(t==null?void 0:t.data)?t.data:void 0;return(t==null?void 0:t.generation)!==void 0||(n==null?void 0:n.generation)!==void 0}function T3(e,t){return t.op!=="replace"||!Ye(t.value)?!1:E3.some(n=>t.path===n||t.path.startsWith(`${n}/`))?!0:C3.includes(t.path)&&(PE(e.assets[t.assetId])||PE(t.value))}function xE(e,t,n,r){if(t.txId){let o=[e,t.txId,n.assetId,n.path,n.op].join("\0");if(ua.has(o))return;if(ua.add(o),ua.size>x3){let s=ua.values().next().value;s!==void 0&&ua.delete(s)}}yi({action:e,category:"canvas_sync",context:{txId:t.txId,intent:t.intent,assetId:n.assetId,path:n.path,op:n.op,reason:r},packageName:"xyq-canvas-sdk",status:e==="canvas_generation_replace_report_only"?"failure":"log"})}function N3(e){for(let t of e.patches){if(T3(e.document,t)){xE("canvas_generation_replace_report_only",e,t,P3);continue}t.op==="replace"&&Ye(t.value)&&e.phase==="local"&&e.txId!==void 0&&xE("canvas_object_replace_report_only",e,t,"broad object replace")}}function w3(e){try{N3(e)}catch{}}var TE=(e,t)=>{if(e.source==="remote"){t();return}w3({document:e.prevState,patches:e.forwardPatches,txId:e.txId,intent:e.intent,phase:"local"}),t()};function O3(e){let t=[XR(e),wR(e),uR(e),vR(e),Bl(e,{registry:qm()})];return()=>{for(let n of t.splice(0))n()}}function D3(e="canvas_1",t){let n=qd();n.register(Qn),n.register(En),n.register(Zc),n.register(Wn),n.register(Cn),n.register(Vr),n.register(Ki),n.register(ca);let r=sf({getTelemetryContext:t,initialDocument:bo(e),middlewares:[TE],registry:n});return SE(r),{dispose:O3(r),store:r}}function NE({canvasId:e,telemetryContext:t}){let n=t,{dispose:r,store:o}=D3(e,()=>n),s=pf({initialSnapConfig:vi(o.getRootCanvasContent().settings.snap)});return{store:o,runtime:s,dispose:r,setTelemetryContext:i=>{n=i}}}function wE({hasPendingLocalChanges:e,hasPendingLocalMediaUploads:t,isReady:n,syncState:r}){return r.phase==="error"?"error":r.phase==="offline"?"offline":n?e||t||r.phase==="flushing"?"saving":r.phase==="connecting"||r.phase==="syncing"||r.phase==="rebasing"?"syncing":"saved":"loading"}var k3="xyq-canvas-sync",M3=3e4,ah=new Set,dh=class{constructor(t,n){this._listeners=new Set;this._disposers=[];this._disposed=!1;this._uploadCleanupAttached=!1;this._pendingFlush=!1;this._started=!1;this.updateRuntimeConfig=t=>{this._disposed||(this._runtimeConfig=t,this._options.session.setTelemetryContext(t.telemetryContext),this._runReadyEffectsIfSyncAttached())};this.start=()=>{var t,n,r;if(this._disposed)throw new Error(((t=this._effects.disposedErrorMessages)==null?void 0:t.cannotStart)??"Cannot start a disposed canvas runtime");return this._started?this:(this._started=!0,this._options.session.setTelemetryContext(this._runtimeConfig.telemetryContext),this._attachStoreLifecycle(),this._attachSyncLifecycle(),this._attachUploadCleanup(),(r=(n=this._effects).configureGenerationRuntime)==null||r.call(n,this._options),this._runReadyEffectsIfSyncAttached(),this._syncGenerationRunsIfNeeded(),this)};this.getSnapshot=()=>this._snapshot;this.subscribe=t=>(this._listeners.add(t),()=>this._listeners.delete(t));this.flush=()=>{if(this._syncEngine){this._syncEngine.flush();return}this._pendingFlush=!0};this.whenReady=(t={})=>{var n;return this._disposed?Promise.reject(new Error(((n=this._effects.disposedErrorMessages)==null?void 0:n.wait)??"Canvas runtime was disposed")):(this.start(),this._waitFor(r=>r.isReady,t.timeoutMs))};this.waitUntilSaved=(t={})=>{var r;if(this._disposed)return Promise.reject(new Error(((r=this._effects.disposedErrorMessages)==null?void 0:r.wait)??"Canvas runtime was disposed"));this.start();let n=t.includeMediaUploads??!0;return this._waitFor(o=>o.isReady&&o.syncState.phase==="idle"&&!o.hasPendingLocalChanges&&(!n||!o.hasPendingLocalMediaUploads),t.timeoutMs)};this.dispose=()=>{if(!this._disposed){this._disposed=!0;for(let t of this._disposers.splice(0).reverse())t();this._syncEngine=void 0;for(let t of Array.from(this._listeners))t(this._snapshot);this._listeners.clear(),this._options.ownsSession&&this._options.session.dispose()}};this._handleSyncEvent=t=>{var n,r,o,s,i,a;if(!this._disposed){if(t.kind==="bootstrap-root-ready"){this._isRootReady=!0,this._lifecycle={phase:"root-ready",settled:!1},this._rootPreviewDocument=t.document,this._rootPreviewReadyNodeAssetIds=new Set,this._publish(),(r=(n=this._options).onSyncEvent)==null||r.call(n,t);return}if(t.kind==="bootstrap-assets-ready"){this._lifecycle={phase:"hydrating",settled:!1},this._rootPreviewDocument=t.document;let d=this._rootPreviewReadyNodeAssetIds??new Set;t.readyAssetIds.forEach(c=>d.add(c)),this._rootPreviewReadyNodeAssetIds=d,this._publish(),(s=(o=this._options).onSyncEvent)==null||s.call(o,t);return}if((a=(i=this._options).onSyncEvent)==null||a.call(i,t),t.kind==="state-change"){t.state.phase==="error"&&t.state.reason==="bootstrap-failed"&&(this._lifecycle={error:t.state.error,phase:"error",settled:!0},this._snapshot=this._createSnapshot(!1,t.state)),this._publish(t.state);return}if(t.kind==="outbound-change"||t.kind==="committed"||t.kind==="discarded"){this._publish();return}t.kind==="snapshot-applied"&&(this._isRootReady=!0,this._lifecycle={phase:"ready",settled:!0},ah.add(this._sessionKey),this._snapshot=this._createSnapshot(!0,this._snapshot.syncState),this._runReadyEffectsIfSyncAttached(),this._publish())}};this._options=t,this._effects=n,this._runtimeConfig={autoLayoutStrategies:t.autoLayoutStrategies,telemetryContext:t.telemetryContext},this.store=t.session.store,this.runtime=t.session.runtime;let r=!t.ownsSession&&ah.has(this._sessionKey);this._isRootReady=r,this._lifecycle={phase:r?"ready":"bootstrap-loading",settled:r},this._snapshot=this._createSnapshot(r,r?{phase:"idle"}:{phase:"connecting"})}get _readOnly(){return this._options.editable===!1}get _sessionKey(){return this._options.sessionKey??this._options.canvasId}_attachStoreLifecycle(){let t=n=>{this.runtime.setSnapConfig(vi(n)),n.enabled||this.runtime.clearSnapping()};t(this.store.getRootCanvasContent().settings.snap),this._disposers.push(this.store.subscribeSelector(n=>x(n).settings.snap,t,{equalityFn:cf})),this._readOnly?this._disposers.push(this.store.use(LR(this._options.onReadOnlyEditAttempt))):this._disposers.push(this.store.subscribe(()=>{this._publish(),this._syncGenerationRunsIfNeeded()}));for(let n of this._options.middlewares??[])this._disposers.push(this.store.use(n));this._readOnly&&this._disposers.push(this.store.subscribe(()=>{this._publish(),this._syncGenerationRunsIfNeeded()}))}_attachSyncLifecycle(){var n;let t=Af({canvasId:this._options.canvasId,createClientId:this._options.createClientId,persistence:this._options.persistence??vf(this._options.canvasId,{dbName:k3}),store:this.store,transportFactory:this._options.transportFactory,onAttached:r=>{this._disposed||(this._syncEngine=r,this._runReadyEffectsIfSyncAttached(),this._pendingFlush&&(this._pendingFlush=!1,r.flush()))},onError:r=>{this._disposed||(this._lifecycle={error:r,phase:"error",settled:!0},this._snapshot=this._createSnapshot(!1,{phase:"error",error:r,reason:"bootstrap-failed"}),this._publish({phase:"error",error:r,reason:"bootstrap-failed"}))},onSyncEvent:this._handleSyncEvent,sync:{...this._options.sync,flush:{debounceMs:1e3,maxBatchPatchCount:50,...(n=this._options.sync)==null?void 0:n.flush},readOnly:this._readOnly,onBootstrapSettled:()=>{if(!this._disposed){if(this._snapshot.syncState.phase==="error"){this._lifecycle={error:this._snapshot.syncState.error,phase:"error",settled:!0},this._publish();return}this._snapshot.isReady&&(ah.add(this._sessionKey),this._lifecycle={phase:"ready",settled:!0},this._runReadyEffectsIfSyncAttached(),this._publish())}}}});this._disposers.push(()=>{t(),this._syncEngine=void 0})}_attachUploadCleanup(){var n,r;if(this._readOnly||this._options.optimizedUploadEnabled||this._uploadCleanupAttached)return;let t=(r=(n=this._effects).attachDeletedLocalUploadCleanup)==null?void 0:r.call(n,this._options,this.store);t&&(this._uploadCleanupAttached=!0,this._disposers.push(t))}_runReadyEffectsIfSyncAttached(){var n,r,o,s;if(!this._syncEngine||!this._snapshot.isReady)return;let{autoLayoutStrategies:t}=this._runtimeConfig;if(!this._readOnly&&(t!=null&&t.length)&&BR(this.store,t),this._readOnly||(r=(n=this._effects).clearNonRecoverableLocalUploadTasks)==null||r.call(n,this._options,this.store),!this._readOnly&&this._options.optimizedUploadEnabled&&!this._uploadCleanupAttached){let i=(s=(o=this._effects).attachDeletedLocalUploadCleanup)==null?void 0:s.call(o,this._options,this.store);i&&(this._uploadCleanupAttached=!0,this._disposers.push(i))}}_syncGenerationRunsIfNeeded(){var t,n;this._readOnly||(this._generationSyncSignature=(n=(t=this._effects).syncGenerationRunsIfNeeded)==null?void 0:n.call(t,{options:this._options,previousSignature:this._generationSyncSignature,store:this.store}))}_createSnapshot(t,n){var i;let r=this.store.getState(),o=GR(r,this._options.optimizedUploadEnabled),s=!this._readOnly&&(((i=this._syncEngine)==null?void 0:i.getPendingOutboundCount())??0)>0;return{document:r,hasPendingLocalChanges:s,hasPendingLocalMediaUploads:o,isReady:t,isRootReady:this._isRootReady,lifecycle:this._lifecycle,nodeCount:Object.keys(x(r).nodes).length,...this._rootPreviewDocument?{rootPreviewDocument:this._rootPreviewDocument}:{},...this._rootPreviewReadyNodeAssetIds?{rootPreviewReadyNodeAssetIds:[...this._rootPreviewReadyNodeAssetIds].sort()}:{},saveState:wE({hasPendingLocalChanges:s,hasPendingLocalMediaUploads:o,isReady:t,syncState:n}),syncState:n}}_publish(t=this._snapshot.syncState){this._snapshot=this._createSnapshot(this._snapshot.isReady,t);for(let n of Array.from(this._listeners))n(this._snapshot)}_waitFor(t,n=M3){return new Promise((r,o)=>{let s={unsubscribe:()=>{}},i=d=>{s.unsubscribe(),s.timeout&&clearTimeout(s.timeout),d()},a=d=>{let{syncState:c}=d;this._disposed?i(()=>{var u;return o(new Error(((u=this._effects.disposedErrorMessages)==null?void 0:u.wait)??"Canvas runtime was disposed"))}):c.phase==="error"?i(()=>o(c.error)):t(d)&&i(()=>r(d))};s.unsubscribe=this.subscribe(a),s.timeout=setTimeout(()=>i(()=>o(new Error(`Timed out after ${n}ms waiting for canvas state`))),n),a(this._snapshot)})}};function OE(e,t={}){let n=NE({canvasId:e.canvasId,telemetryContext:e.telemetryContext});return new dh({...e,ownsSession:!0,session:n},t)}var ch="xyq.scene.updateDescription";function L3(e,t){var r,o,s,i;let n=tu(e);return n?t==="sceneName"?((r=n.basicInfo)==null?void 0:r.name)??"":t==="sceneViewName"?((o=n.basicInfo)==null?void 0:o.appearanceName)??"":t==="episodes"?n.episodes??[]:((s=n.appearanceInfo)==null?void 0:s.description)??((i=n.basicInfo)==null?void 0:i.description)??"":""}function B3(e,t){return Array.isArray(e)||Array.isArray(t)?!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((n,r)=>n===t[r]):e===t}function G3(e,t){let n=e.getState(),r=x(n).nodes[t.nodeId];if((r==null?void 0:r.type)!==he||r.id!==t.assetId)return;let o=n.assets[t.assetId];if(!(!o||!tu(o)))return{asset:o,node:r}}function U3(e,t){let n=t.value;return B3(L3(e.asset,t.field),n)?t.field!=="sceneName"||e.node.data.name===String(n):!1}function z3(e,t){let n=G3(e,t);return n?U3(n,t)?{status:"noop",reason:"no-changes"}:e.transact(r=>{let o=x(r).nodes[t.nodeId];if((o==null?void 0:o.type)!==he||o.id!==t.assetId)return;let s=$_(r.assets[t.assetId]);if(!(s!=null&&s.content))return;if(t.field==="sceneName"){let a=String(t.value),d=Q_(s.content);o.data.name=a,s.content.basicInfo={...s.content.basicInfo??{},name:a,...d?{appearanceName:a}:{}},d&&(s.content.nodeName=a);return}if(t.field==="sceneViewName"){let a=String(t.value);s.content.nodeName=a,s.content.basicInfo={...s.content.basicInfo??{},appearanceName:a};return}if(t.field==="episodes"){s.content.episodes=Array.isArray(t.value)?[...t.value]:[];return}let i=String(t.value);s.content.basicInfo={...s.content.basicInfo??{},description:i},s.content.appearanceInfo={...Ko(s.content.appearanceInfo),description:i}},{intent:"scene.updateDescription",mergeKey:`scene-description:${t.nodeId}:${t.field}`}):{status:"aborted",reason:"scene asset not found"}}function DE(e){return e.commands.register(ch,z3)}var q3={clearNonRecoverableLocalUploadTasks:(e,t)=>{UR(t.getState(),t)}};function kE(e){let t=OE({...e,generationAgUi:null,legacyGlobalContextBridge:!1},q3),n=DE(t.store),r=t.dispose,o=!1;return t.dispose=()=>{if(!o){o=!0;try{n()}finally{r()}}},{canvas:t,commands:t.store.commands,runtime:t.runtime,store:t.store}}var ME;function LE(e){let t=globalThis.console;if(!t||typeof t!="object")return;let n=t[e];return typeof n=="function"?n.bind(t):void 0}function uh(e,t){var n;(n=LE(e))==null||n(...t),e==="error"&&F3(t)}function F3(e){var t;if(ME)try{ME({packageName:"xyq-canvas-sdk",message:j3(e),error:V3(e),context:H3(e)})}catch(n){(t=LE("warn"))==null||t("[xyq-canvas-sdk] error reporter failed",n)}}function j3(e){return e.filter(n=>typeof n=="string"||typeof n=="number"||typeof n=="boolean").map(n=>String(n)).join(" ")||"[xyq-canvas-sdk] error"}function V3(e){for(let t of e){if(t instanceof Error)return t;if(BE(t)&&t.error instanceof Error)return t.error}}function H3(e){let t={},n=20;for(let r of e){if(n<=0)break;if(!(r instanceof Error)&&BE(r))for(let[o,s]of Object.entries(r)){if(n<=0)break;t[o]=Y3(s),n-=1}}return t}function Y3(e){var t;return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e.length>500?`${e.slice(0,500)}...`:e:e===null||typeof e=="number"||typeof e=="boolean"||typeof e>"u"?e:Array.isArray(e)?`[array:${e.length}]`:typeof e=="object"?`[object:${((t=e.constructor)==null?void 0:t.name)||"Object"}]`:String(e)}function BE(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}var Xe={error:(...e)=>uh("error",e),info:(...e)=>uh("info",e),warn:(...e)=>uh("warn",e)};var Iu=class{constructor(t,n=null,r=null){this.value=t,this.next=n,this.prev=r}},_u=class{get size(){return this._count}get firstNode(){return this._head}isEmpty(){return this._head===null}clear(){let t=this._head;for(;t!==null;){let n=t.next;t.prev=null,t.next=null,t=n}this._head=null,this._tail=null,this._count=0}unshift(t){let n=new Iu(t);if(this.isEmpty())this._head=n,this._tail=n;else{let r=this._head;this._head=n,n.next=r,r.prev=n}return this._count++,this}push(t){let n=new Iu(t);if(this.isEmpty())this._head=n,this._tail=n;else{let r=this._tail;this._tail=n,n.prev=r,r.next=n}return this._count++,this}shift(){if(this.isEmpty())return null;let t=this._head,n=t.value;return this._remove(t),n}pop(){if(this.isEmpty())return null;let t=this._tail,n=t.value;return this._remove(t),n}toArray(){let t=[];for(let n of this)t.push(n);return t}*[Symbol.iterator](){let t=this._head;for(;t!==null;)yield t.value,t=t.next}_remove(t){t.prev===null&&t.next===null&&t!==this._head&&t!==this._tail||(t===this._head&&(this._head=t.next,this._head&&(this._head.prev=null)),t===this._tail&&(this._tail=t.prev,this._tail&&(this._tail.next=null)),t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),t.prev=null,t.next=null,this._count--)}constructor(){this._head=null,this._tail=null,this._count=0}};var as=class extends _u{unshiftAndGetDisposableNode(t){this.unshift(t);let n=this._head,r=!1;return()=>{r||(r=!0,super._remove(n))}}pushAndGetDisposableNode(t){this.push(t);let n=this._tail,r=!1;return()=>{r||(r=!0,super._remove(n))}}};function ph(e){setTimeout(()=>{throw e},0)}var lh=class{invoke(...t){this._callback.call(this._callbackThis,...t)}constructor(t,n){this._callback=t,this._callbackThis=n}},fh=class{constructor(t,n,r){this.emitter=t,this.listener=n,this.event=r}},mh=class{get size(){return this._queue.size}push(t,n,r){this._queue.push(new fh(t,n,r))}clear(t){let n=new as;for(let r of this._queue)r.emitter!==t&&n.push(r);this._queue=n}deliver(){for(;this._queue.size>0;){let t=this._queue.shift();try{t.listener.invoke(...t.event)}catch(n){this._onListenerError(n)}}}constructor(t=ph){this._onListenerError=t,this._queue=new as}},pa=class{get event(){return this._event?this._event:(this._event=(t,n)=>{var r;let o=new lh(t,n);this._listeners||(this._listeners=new as);let s=this._listeners.pushAndGetDisposableNode(o);return!((r=this._options)===null||r===void 0)&&r.onAddListener&&this._options.onAddListener(this,t,n),zi(()=>{if(!this._disposed){var a;s(),!((a=this._options)===null||a===void 0)&&a.onRemoveListener&&this._options.onRemoveListener(this,t,n)}})},this._event)}dispose(){var t,n;this._disposed||(this._disposed=!0,(t=this._listeners)===null||t===void 0||t.clear(),(n=this._deliveryQueue)===null||n===void 0||n.clear(this))}fire(...t){var n;if(!(!this._listeners||this._listeners.size===0)){if(this._listeners.size===1){let s=this._listeners.firstNode;try{s.value.invoke(...t)}catch(i){var r;!((r=this._options)===null||r===void 0)&&r.onListenerError?this._options.onListenerError(i):ph(i)}return}var o;(o=this._deliveryQueue)!==null&&o!==void 0||(this._deliveryQueue=new mh((n=this._options)===null||n===void 0?void 0:n.onListenerError));for(let s of this._listeners)this._deliveryQueue.push(this,s,t);this._deliveryQueue.deliver()}}constructor(t){this._disposed=!1,this._options=t}};var K3=.2,je=Math.ceil((16+4)/K3);function C(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function q(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function la(e,t=300){let n=e.replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,t)}...`:n}function GE(e,...t){if(e)for(let n of t){let r=e[n];if(C(r))return r}}var fa=Vr.getDefaultSize({}),zE=96,gh=48,yh=72,Ah=120,qE=2,ds=48,FE=400,jE=3,vh=3,VE=Number.MAX_SAFE_INTEGER;function UE(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function X3(e){return q(e.id)}function Sh(e,t){let n=X3(t);if(!n)return;let r=e.assets[n];if(!(!C(r)||!C(r.content)))return r.content}function hh(e,t){var r;if(typeof t.order=="number"&&Number.isFinite(t.order))return t.order;let n=(r=Sh(e,t))==null?void 0:r.order;return typeof n=="number"&&Number.isFinite(n)?n:VE}function HE(e,t){var r;if(typeof t.order=="number"&&Number.isFinite(t.order))return;let n=(r=Sh(e,t))==null?void 0:r.order;return typeof n=="number"&&Number.isFinite(n)?n:void 0}function Jr(e,t){return[...t].sort((n,r)=>{let o=hh(e,n),s=hh(e,r);return o!==s?o-s:String(n.id).localeCompare(String(r.id))})}function YE(e,t){let n=Sh(e,t),r=C(n==null?void 0:n.basicInfo)?n.basicInfo:void 0,o=C(t.data)?t.data:void 0;return q(r==null?void 0:r.name)||q(o==null?void 0:o.name)||q(n==null?void 0:n.name)||q(n==null?void 0:n.nodeName)||q(r==null?void 0:r.appearanceName)||q(r==null?void 0:r.stageTag)||q(r==null?void 0:r.label)||String(t.id)}function cs(e,t){return{w:UE(e.w)?e.w:t.w,h:UE(e.h)?e.h:t.h}}function KE(e,t){let n=cs(e,t);return{...n,h:n.h+je}}function us(e,t){return Math.min(...t.map(n=>hh(e,n)))}function ps(e,t){return e.order-t.order}function Ru(e){return e.stackHeight??e.height}function Zt(e){return(e==null?void 0:e.type)===z}function en(e){return(e==null?void 0:e.type)===he}function Zr(e){return(e==null?void 0:e.type)===be&&Array.isArray(e.children)}function XE(e,t){let n=new Set;return e.children.map(r=>t[r]).filter(r=>!r||r.parentId!==e.id||n.has(r.id)?!1:(n.add(r.id),!0))}function $E(e){if(e.length!==0){if(e.filter(Zt).length===e.length)return"role";if(e.filter(en).length===e.length)return"scene"}}function ls(e,t,n){let r=cs(t,n);return{order:us(e,[t]),width:r.w,height:r.h,stackHeight:r.h+je,apply:(o,s)=>{s.set(t.id,{x:o.x,y:o.y,width:r.w,height:r.h})}}}function ma(e,t,n){var u;let r=[...e].sort(ps),o=Math.max(1,Math.min(n,Math.ceil(Math.sqrt(r.length)))),s=Math.ceil(r.length/o),i=new Map,a=0,d=0,c=0;return Array.from({length:s}).forEach((p,l)=>{let f=r.slice(l*o,(l+1)*o),h=0,m=Math.max(...f.map(y=>y.height),0),g=Math.max(...f.map(Ru),0);f.forEach(y=>{i.set(y,{x:h,y:c+(m-y.height)/2}),h+=y.width+t}),a=Math.max(a,Math.max(0,h-t)),d=Math.max(d,c+m),c+=g+(l<s-1?t:0)}),{order:((u=r[0])==null?void 0:u.order)??VE,width:a,height:d,stackHeight:c,apply:(p,l)=>{r.forEach(f=>{let h=i.get(f)??{x:0,y:0};f.apply({x:p.x+h.x,y:p.y+h.y},l)})}}}var Xg=ed(np());function rp(e,t){let n=new Set;return e.children.map(r=>t[r]).filter(r=>!r||r.parentId!==e.id||n.has(r.id)?!1:(n.add(r.id),!0))}function YM(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>{let r={...n};return Array.isArray(n.children)&&(r.children=[...n.children??[]]),[t,r]}))}function op(e,t,n,r){let o=r[e.rootCanvasId],s=x(e);return{...e,assets:{...r,[e.rootCanvasId]:{...o,content:{...s,edges:n,nodes:t}}}}}function Cs(e){return{maxX:e.x+e.w,maxY:e.y+e.h+je,minX:e.x,minY:e.y}}function Dt(e){let t=e.filter(n=>!!n);if(t.length!==0)return t.reduce((n,r)=>({maxX:Math.max(n.maxX,r.maxX),maxY:Math.max(n.maxY,r.maxY),minX:Math.min(n.minX,r.minX),minY:Math.min(n.minY,r.minY)}),{...t[0]})}function sn(e,t){return!e||!t?e?-1:t?1:0:(e.order??0)-(t.order??0)||e.y-t.y||e.x-t.x||e.id.localeCompare(t.id)}function dde(e){let t=[...e].sort(sn),n=Math.max(1,Math.min(3,Math.ceil(Math.sqrt(t.length)))),r=Math.max(...t.map(i=>i.w),0),o=Math.max(...t.map(i=>i.h),0),s=new Map;return t.forEach((i,a)=>{s.set(i.id,{x:a%n*(r+80),y:Math.floor(a/n)*(o+je+64)})}),s}function XM(e,t,n,r=new Set){if(t===n)return!0;if(r.has(t))return!1;r.add(t);let o=e.get(t);if(!o)return!1;for(let s of o)if(XM(e,s,n,r))return!0;return!1}function cde(e,t){let n=new Set(e.map(i=>i.id)),r=new Map,o=[],s=new Set;return[...t].sort((i,a)=>String(i.id).localeCompare(String(a.id))).forEach(i=>{if(!n.has(i.source)||!n.has(i.target)||i.source===i.target)return;let a=`${i.source}->${i.target}`;if(s.has(a)||XM(r,i.target,i.source))return;s.add(a);let d=r.get(i.source)??new Set;d.add(i.target),r.set(i.source,d),o.push(i)}),o}function KM(e,t,n,r){if(r.has(e))return r.get(e);let o=[],s=e,i;for(;s;){if(t.has(s)){i=s;break}if(o.includes(s))break;o.push(s);let a=n.get(s);s=typeof(a==null?void 0:a.parentId)=="string"?a.parentId:null}return r.set(e,i),o.forEach(a=>r.set(a,i)),i}function ude(e,t,n){let r=new Set(e.map(a=>a.id)),o=new Map,s=new Set,i=[];return[...t].sort((a,d)=>String(a.id).localeCompare(String(d.id))).forEach(a=>{let d=KM(a.source,r,n,o),c=KM(a.target,r,n,o);if(!d||!c||d===c)return;let u=`${d}->${c}`;s.has(u)||(s.add(u),i.push({...a,id:`${String(a.id)}:layout:${u}`,source:d,target:c}))}),i}function pde(e,t){if(t.length===0)return;let n=cde(e,t);if(n.length===0)return;let r=new Xg.default.graphlib.Graph;r.setDefaultEdgeLabel(()=>({})),r.setGraph({marginx:0,marginy:0,nodesep:64,rankdir:"LR",ranker:"tight-tree",ranksep:80});let o=[...e].sort(sn),s=new Map;o.forEach(c=>{let u=c.h+je;s.set(c.id,u),r.setNode(c.id,{width:c.w,height:u})}),n.forEach(c=>r.setEdge(c.source,c.target)),Xg.default.layout(r);let i=new Map,a=[];return o.forEach(c=>{let u=s.get(c.id)??c.h+je,p=r.node(c.id),l=(p==null?void 0:p.x)??c.w/2;a.push(l.toFixed(3)),i.set(c.id,{x:l-c.w/2,y:((p==null?void 0:p.y)??u/2)-u/2})}),new Set(a).size===i.size&&i.forEach((c,u)=>{i.set(u,{x:c.x,y:0})}),i}function lde(e,t){let n=new Set(e.map(i=>i.id)),r=t.filter(i=>n.has(i.source)&&n.has(i.target)),o=pde(e,r)??dde(e),s=Dt(e.map(i=>{let a=o.get(i.id)??{x:0,y:0};return{maxX:a.x+i.w,maxY:a.y+i.h+je,minX:a.x,minY:a.y}}))??{minX:0,minY:0,maxX:1,maxY:1};return(s.minX!==0||s.minY!==0)&&o.forEach((i,a)=>{o.set(a,{x:i.x-s.minX,y:i.y-s.minY})}),{edges:r,height:Math.max(1,s.maxY-s.minY),nodes:e,relativePositions:o,width:Math.max(1,s.maxX-s.minX)}}function $M(e,t,n=e){let r=new Map(e.map(c=>[c.id,c])),o=new Map(n.map(c=>[c.id,c])),s=ude(e,t,o),i=new Map;r.forEach((c,u)=>i.set(u,new Set)),s.forEach(c=>{var u,p;(u=i.get(c.source))==null||u.add(c.target),(p=i.get(c.target))==null||p.add(c.source)});let a=new Set,d=[];return e.sort(sn).forEach(c=>{var f;if(a.has(c.id))return;let u=[],p=[c.id];for(a.add(c.id);p.length>0;){let h=p.shift();u.push(h),(f=i.get(h))==null||f.forEach(m=>{a.has(m)||(a.add(m),p.push(m))})}let l=u.map(h=>r.get(h)).filter(h=>!!h);d.push(lde(l,s))}),d.sort((c,u)=>sn(c.nodes[0],u.nodes[0]))}function fde(e){return Math.max(1,Math.min(3,Math.ceil(Math.sqrt(e.length))))}function $g(e,t,n=fde(e)){let r=[...e].sort((a,d)=>sn(a.nodes[0],d.nodes[0])),o=Math.max(1,Math.min(n,r.length)),s=[],{y:i}=t;for(let a=0;a<r.length;a+=o){let d=r.slice(a,a+o),{x:c}=t,u=Math.max(...d.map(p=>p.height),0);for(let p of d)s.push({component:p,x:c,y:i+(u-p.height)/2}),c+=p.width+72;i+=u+72}return s}function JM(e,t,n){let r=Dt([n,...e.map(({component:a,x:d,y:c})=>({maxX:d+a.width,maxY:c+a.height,minX:d,minY:c}))]);if(!r)return{aspectError:Number.POSITIVE_INFINITY,area:Number.POSITIVE_INFINITY};let o=r.maxX-r.minX,s=r.maxY-r.minY,i=o/Math.max(1,s);return{area:o*s,aspectError:Math.abs(Math.log(i/t))}}function ZM(e,t,n,r){if(!n||e.length<=1)return $g(e,t);let o=e.length,s=$g(e,t,1),i=JM(s,n,r);for(let a=2;a<=o;a+=1){let d=$g(e,t,a),c=JM(d,n,r);(c.aspectError<i.aspectError||c.aspectError===i.aspectError&&c.area<i.area)&&(s=d,i=c)}return s}function mde(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:void 0}function hde(e){return Dt([e.roleBounds,e.sceneBounds,...e.mixedBounds])}function gde(e,t){let{roleBounds:n,sceneBounds:r}=e;return n&&r?{x:r.maxX+96,y:t.minY}:{x:t.maxX+96,y:t.minY}}function eL(e,t,n,r){let o=n?{x:n.minX,y:n.minY}:{x:0,y:0},s=mde(r),i=hde(t);return i?ZM(e,gde(t,i),s,i):ZM(e,o,s)}function yde(e,t){if(Zt(e))return"role";if(en(e))return"scene";if(!Zr(e))return;let n=rp(e,t);if(n.length===0)return;if(n.filter(Zt).length===n.length)return"role";if(n.filter(en).length===n.length)return"scene"}function oL(e,t){if(Zt(e)||en(e))return!0;if(!Zr(e))return!1;let n=rp(e,t);return n.length>0&&n.every(r=>Zt(r)||en(r))}function Wg(e,t){return oL(e,t)?!1:e.type===Ie||e.type===L||e.type===me||e.type===ue||e.type===M||Zr(e)}function pr(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function an(e){return typeof e=="number"&&Number.isFinite(e)}function kn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Qg(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function Ade(e){return(e==null?void 0:e.type)===Ie||(e==null?void 0:e.type)===L||(e==null?void 0:e.type)===me||(e==null?void 0:e.type)===ue||(e==null?void 0:e.type)===M}function tL(e){if(!(!kn(e)||!kn(e.content)))return e.content}function vde(e,t){if(!t)return;let n=tL(e[t]);if(n)return n;for(let r of Object.values(e)){if(!kn(r)||Qg(r.pippitAssetId)!==t)continue;let o=tL(r);if(o)return o}}function sL(e){let{data:t}=e;return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function Sde(e,t){let n=kn(e)?e:void 0,r=Qg(n==null?void 0:n.pippitAssetId)||Qg(e.id);return vde(t,r)}function nL(e,t){let n=sL(e),r=Sde(e,t);if(!r)return n;let o=kn(r.data)?r.data:r,s={...n,...o};return(kn(n.metadata)||kn(o.metadata))&&(s.metadata={...kn(n.metadata)?n.metadata:{},...kn(o.metadata)?o.metadata:{}}),s}function rL({defaultSize:e,mediaSize:t}){let n=t.w>0&&t.h>0?t.w/t.h:void 0;if(!n)return e;let r=Math.max(1,e.w*e.h);return{w:Math.round(Math.sqrt(r*n)),h:Math.round(Math.sqrt(r/n))}}function bde(e,t){var r,o,s,i,a,d,c,u,p,l,f,h,m,g;let n=sL(e);switch(e.type){case Ie:return((o=(r=Qn).getDefaultSize)==null?void 0:o.call(r,n))??{w:420,h:180};case L:{let y=nL(e,t),v=((i=(s=En).getDefaultSize)==null?void 0:i.call(s,{}))??{w:480,h:373},S=((d=(a=En).getDefaultSize)==null?void 0:d.call(a,y))??v;return rL({defaultSize:v,mediaSize:S})}case me:return((u=(c=Zc).getDefaultSize)==null?void 0:u.call(c,n))??{w:320,h:180};case ue:return((l=(p=Wn).getDefaultSize)==null?void 0:l.call(p,n))??{w:362,h:218};case M:{let y=nL(e,t),v=((h=(f=Cn).getDefaultSize)==null?void 0:h.call(f,{}))??{w:480,h:270},S=((g=(m=Cn).getDefaultSize)==null?void 0:g.call(m,y))??v;return rL({defaultSize:v,mediaSize:S})}default:return}}function lr(e){return an(e.x)&&an(e.y)&&pr(e.w)&&pr(e.h)}function Jg(e,t){let n=!1;if(an(e.x)||(e.x=0,n=!0),an(e.y)||(e.y=0,n=!0),pr(e.w)&&pr(e.h))return n;let r=bde(e,t);return r&&(pr(e.w)||(e.w=r.w,n=!0),pr(e.h)||(e.h=r.h,n=!0)),n}function Zg(e){return!an(e.x)||!an(e.y)||e.x===0&&e.y===0}function iL(e,t){let n=Dt(t.filter(lr).map(Cs));if(!n)return!1;let r=!1,o=n.maxX+80,s=n.minY;return[...e].sort(sn).forEach(i=>{lr(i)&&(i.x!==o&&(i.x=o,r=!0),i.y!==s&&(i.y=s,r=!0),o+=i.w+80)}),r}function aL(e,t,n){let r=kr(e)?hi(e):{w:e.w,h:e.h},o=pr(r.w)?Math.max(r.w,t):t,s=pr(r.h)?Math.max(r.h,n):n;return o===r.w&&s===r.h?!1:(gi(e,{w:o,h:s}),!0)}function Ide(e,t){let n=Dt(t.filter(lr).map(i=>({maxX:i.x+i.w,maxY:i.y+i.h+je,minX:i.x,minY:i.y})));if(!n)return!1;let r=!1;an(e.x)||(e.x=0,r=!0),an(e.y)||(e.y=0,r=!0);let o=Math.max(40*2,n.maxX+40),s=Math.max(40*2,n.maxY+40);return aL(e,o,s)||r}function _de(e,t,n,r){let o=rp(e,t).filter(Ade),s=o.filter(m=>!lr(m));if(o.length===0||s.length===0)return!1;let i=new Set(s.filter(Zg).map(m=>m.id)),a=!1;if(s.forEach(m=>{a=Jg(m,n)||a}),r&&s.length<o.length){let m=o.filter(y=>i.has(y.id)),g=o.filter(y=>!i.has(y.id)&&lr(y));return a=iL(m,g)||a,Ide(e,o)||a}let d=[...o].sort(sn),c=Math.max(1,Math.min(3,Math.ceil(Math.sqrt(d.length)))),u=Math.ceil(d.length/c),p=Math.max(...d.map(m=>m.w),1),l=Math.max(...d.map(m=>m.h+je),1);d.forEach((m,g)=>{let y=40+g%c*(p+80),v=40+Math.floor(g/c)*(l+64);m.x!==y&&(m.x=y,a=!0),m.y!==v&&(m.y=v,a=!0)});let f=40*2+c*p+Math.max(0,c-1)*80,h=40*2+u*l+Math.max(0,u-1)*64;return an(e.x)||(e.x=0,a=!0),an(e.y)||(e.y=0,a=!0),aL(e,f,h)||a}function Rde(e,t,n,r){let o=!1;return e.forEach(s=>{!Zr(s)||!Wg(s,t)||(o=_de(s,t,n,r)||o)}),o}function Ede(e,t){let n=[],r=[],o=[];return e.forEach(s=>{let i=yde(s,t);if(i==="role"){n.push(Cs(s));return}if(i==="scene"){r.push(Cs(s));return}oL(s,t)&&o.push(Cs(s))}),{mixedBounds:o,roleBounds:Dt(n),sceneBounds:Dt(r)}}function dL(e,t){let n=x(e),r=YM(n.nodes),o=Object.values(r).filter(g=>(g.parentId??null)===null),s=t.repairInvalidOnly===!0,i=s?new Set(o.filter(g=>Wg(g,r)).filter(g=>!lr(g)&&Zg(g)).map(g=>g.id)):new Set,a=Rde(o,r,e.assets,s),d=Ede(o,r),c=o.filter(g=>Wg(g,r));if(c.length===0)return a?op(e,r,n.edges,e.assets):e;let u=c.filter(g=>!lr(g)),p=new Set([...i,...u.filter(Zg).map(g=>g.id)]),l=!1;if(u.forEach(g=>{l=Jg(g,e.assets)||l}),s&&u.length<c.length){let g=c.filter(v=>p.has(v.id)),y=c.filter(v=>!p.has(v.id)&&lr(v));if(g.length===0||y.length>0)return l=iL(g,y)||l,a||l?op(e,r,n.edges,e.assets):e}s||c.forEach(g=>{l=Jg(g,e.assets)||l});let f=$M(c,Object.values(n.edges),Object.values(r));if(f.length===0)return e;let h=Dt(c.map(g=>Cs(g)));return eL(f,d,h,t.aspectRatio).forEach(({component:g,x:y,y:v})=>{g.relativePositions.forEach((S,b)=>{let I=r[b];I&&(I.x=y+S.x,I.y=v+S.y)})}),op(e,r,n.edges,e.assets)}var Ha=class extends Error{constructor(n){super(n);this.restoreFailureReason="empty-text-asset";this.name="CanvasAssetNotFoundError"}};function ey(e,t){return!!(t!=null&&t.aborted||e instanceof Error&&e.name==="AbortError"||typeof DOMException<"u"&&e instanceof DOMException&&e.name==="AbortError")}function ty(e){return e instanceof Ha?e.restoreFailureReason:void 0}function cL(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown canvas restore failure")}var sy=ed(np());var ny=ed(np());function Cde(e,t){let n=[],r=new Map;return Jr(e,t).forEach(o=>{let s=YE(e,o),i=r.get(s);i||(i=[],r.set(s,i),n.push(i)),i.push(o)}),n}function Pde(e,t,n){let r=t;for(;r;){if(r===n)return!0;r=e.get(r)}return!1}function xde(e,t){let n=new Set(e.map(s=>s.id)),r=new Map,o=[];return[...t].sort((s,i)=>String(s.id).localeCompare(String(i.id))).forEach(s=>{!n.has(s.source)||!n.has(s.target)||s.source===s.target||r.has(s.target)||Pde(r,s.source,s.target)||(r.set(s.target,s.source),o.push(s))}),o}function Tde(e,t,n){if(t.length===1)return ls(e,t[0],fa);let r=new ny.default.graphlib.Graph;r.setDefaultEdgeLabel(()=>({})),r.setGraph({rankdir:"LR",nodesep:gh,ranksep:zE,ranker:"tight-tree",marginx:0,marginy:0});let o=Jr(e,t),s=new Map,i=new Map;o.forEach(l=>{let f=cs(l,fa),h=KE(l,fa);s.set(l.id,f),i.set(l.id,h),r.setNode(l.id,{width:h.w,height:h.h})}),xde(o,n).forEach(l=>r.setEdge(l.source,l.target)),ny.default.layout(r);let a=new Map,d=Number.POSITIVE_INFINITY,c=Number.POSITIVE_INFINITY,u=Number.NEGATIVE_INFINITY,p=Number.NEGATIVE_INFINITY;return o.forEach(l=>{let f=s.get(l.id)??fa,h=i.get(l.id)??f,m=r.node(l.id),g=((m==null?void 0:m.x)??h.w/2)-h.w/2,y=((m==null?void 0:m.y)??h.h/2)-h.h/2;a.set(l.id,{x:g,y,width:f.w,height:f.h}),d=Math.min(d,g),c=Math.min(c,y),u=Math.max(u,g+h.w),p=Math.max(p,y+h.h)}),{order:us(e,o),width:Math.max(1,u-d),height:Math.max(1,p-c),apply:(l,f)=>{a.forEach((h,m)=>{f.set(m,{x:l.x+h.x-d,y:l.y+h.y-c,width:h.width,height:h.height})})}}}function Nde(e,t){return ps(e.block,t.block)}function ry(e,t,n){return Cde(e,t).map(r=>({kind:r.length===1?"single":"group",block:Tde(e,r,n)}))}function oy(e){let t=[],n=[],r=()=>{n.length!==0&&(t.push(ma(n,gh,jE)),n=[])};return[...e].sort(Nde).forEach(o=>{if(o.kind==="single"){n.push(o.block);return}r(),t.push(o.block)}),r(),t}function uL(e,t,n){return oy(ry(e,t,n))}function pL(e,t,n,r=new Set){if(t===n)return!0;if(r.has(t))return!1;r.add(t);let o=e.get(t);if(!o)return!1;for(let s of o)if(pL(e,s,n,r))return!0;return!1}function wde(e,t){let n=new Set(e.map(s=>s.id)),r=new Map,o=[];return[...t].sort((s,i)=>String(s.id).localeCompare(String(i.id))).forEach(s=>{if(!n.has(s.source)||!n.has(s.target)||s.source===s.target||pL(r,s.target,s.source))return;let i=r.get(s.source)??new Set;i.add(s.target),r.set(s.source,i),o.push(s)}),o}function Ode(e,t,n,r,o,s){if(t.length===0)return;if(t.length===1)return ls(e,t[0],r);let i=wde(t,n);if(i.length===0)return;let a=new sy.default.graphlib.Graph;a.setDefaultEdgeLabel(()=>({})),a.setGraph({rankdir:"LR",nodesep:o,ranksep:s,ranker:"tight-tree",marginx:0,marginy:0});let d=Jr(e,t),c=new Map;d.forEach(m=>{let g=cs(m,r);c.set(m.id,g),a.setNode(m.id,{width:g.w,height:g.h})}),i.forEach(m=>a.setEdge(m.source,m.target)),sy.default.layout(a);let u=new Map,p=Number.POSITIVE_INFINITY,l=Number.POSITIVE_INFINITY,f=Number.NEGATIVE_INFINITY,h=Number.NEGATIVE_INFINITY;return d.forEach(m=>{let g=c.get(m.id)??r,y=a.node(m.id),v=((y==null?void 0:y.x)??g.w/2)-g.w/2,S=((y==null?void 0:y.y)??g.h/2)-g.h/2;u.set(m.id,{x:v,y:S,width:g.w,height:g.h}),p=Math.min(p,v),l=Math.min(l,S),f=Math.max(f,v+g.w),h=Math.max(h,S+g.h)}),{order:us(e,d),width:Math.max(1,f-p),height:Math.max(1,h-l),apply:(m,g)=>{u.forEach((y,v)=>{g.set(v,{x:m.x+y.x-p,y:m.y+y.y-l,width:y.width,height:y.height})})}}}function lL(e,t,n,r){let{y:o}=t,s=0,i=0;return[...e].sort(ps).forEach((a,d)=>{d>0&&(o+=n),a.apply({x:t.x,y:o},r),o+=Ru(a),s=Math.max(s,a.width),i=o-t.y}),{width:s,height:i}}function Dde(e,t,n){let r=[...e].sort(ps);if(r.length===0)return{width:0,height:0};let o=Math.max(1,Math.min(qE,Math.ceil(Math.sqrt(r.length)))),s=Array.from({length:o},()=>({items:[],width:0,height:0}));r.forEach(a=>{let d=s.reduce((u,p)=>p.height<u.height||p.height===u.height&&p.items.length<u.items.length?p:u),c=d.height>0?d.height+yh:0;d.items.push({block:a,y:c}),d.width=Math.max(d.width,a.width),d.height=c+Ru(a)});let i=s.map((a,d)=>s.slice(0,d).reduce((c,u)=>c+u.width+Ah,0));return s.forEach((a,d)=>{a.items.forEach(({block:c,y:u})=>{c.apply({x:t.x+i[d],y:t.y+u},n)})}),{width:s.reduce((a,d)=>a+d.width,0)+Ah*(s.length-1),height:Math.max(...s.map(a=>a.height))}}function kde(e,t,n=[]){let r=Ode(e,t,n,Yr,ds,ds);if(r)return r;let o=Jr(e,t).map(s=>ls(e,s,Yr));return o.length>0?ma(o,ds,vh):void 0}function Mde(e){let t;for(let n of e){let r={minX:n.x,minY:n.y,maxX:n.x+n.width,maxY:n.y+n.height};t=t?{minX:Math.min(t.minX,r.minX),minY:Math.min(t.minY,r.minY),maxX:Math.max(t.maxX,r.maxX),maxY:Math.max(t.maxY,r.maxY)}:r}return t}function Lde(e,t,n,r,o){let s=o==="role"?uL(e,n.filter(Zt),r):[kde(e,n.filter(en),r)].filter(u=>!!u);if(s.length===0)return;let i=new Map;lL(s,{x:0,y:0},yh,i);let a=Mde(i.values())??{minX:0,minY:0,maxX:1,maxY:1},d=Math.max(1,a.maxX-a.minX+40*2),c=Math.max(1,a.maxY-a.minY+40*2);return{order:us(e,n),width:d,height:c,stackHeight:c+je,apply:(u,p)=>{p.set(t.id,{x:u.x,y:u.y,width:d,height:c}),i.forEach((l,f)=>{p.set(f,{...l,x:l.x-a.minX+40,y:l.y-a.minY+40})})}}}function fL(e,t,n){let r=new Map,s=Jr(e,Object.values(t)).filter(f=>!f.parentId),i=ry(e,s.filter(Zt),n),d=s.filter(en).map(f=>ls(e,f,Yr));s.filter(Zr).forEach(f=>{let h=XE(f,t),m=$E(h);if(!m)return;let g=Lde(e,f,h,n,m);if(g){if(m==="role"){i.push({kind:"group",block:g});return}m==="scene"&&d.push(g)}});let c=oy(i),u=d.length>0?ma(d,ds,vh):void 0,p=Dde(c,{x:0,y:0},r),l=c.length>0?p.width+FE:0;return lL(u?[u]:[],{x:l,y:0},ds,r),r}var sp={name:"role-tree-scene-columns",layout(e){let t=x(e),n=fL(e,t.nodes,Object.values(t.edges)),r={},o=!1;if(Object.values(t.nodes).forEach(i=>{let a=n.get(i.id),d=HE(e,i),c=a||d!==void 0?{...i,...d!==void 0?{order:d}:{},...a?{x:a.x,y:a.y,w:a.width,h:a.height}:{}}:i;r[i.id]=c,c!==i&&(c.x!==i.x||c.y!==i.y||c.w!==i.w||c.h!==i.h||c.order!==i.order)&&(o=!0)}),!o)return e;let s=e.assets[e.rootCanvasId];return{...e,assets:{...e.assets,[e.rootCanvasId]:{...s,content:{...t,nodes:r}}}}}};var iy="[novel-detail-canvas]";function Bde(){var t,n;let e=globalThis.process;return((t=e==null?void 0:e.env)==null?void 0:t.JEST_WORKER_ID)==null&&((n=e==null?void 0:e.env)==null?void 0:n.VITEST)==null}function Gde(e){let{error:t,...n}=e.payload??{},r=C(t)?t:void 0,o=typeof(r==null?void 0:r.name)=="string"?r.name:void 0,s=typeof(r==null?void 0:r.message)=="string"?r.message:void 0;return{canvasAssetId:e.canvasAssetId,...n,...o?{canvas_restore_error_name:la(o,128)}:{},...s?{canvas_restore_error_message:la(s,256)}:{}}}function mL(e,t={},n){var s;if((s=t.logger)==null||s.call(t,e),!Bde()||t.debugLog===!1&&e.level==="info")return;let r=Gde(e),o=n===void 0?void 0:cL(n);if(e.level==="error"){Xe.error(iy,e.type,...o?[o,r]:[r]);return}if(e.level==="warn"){Xe.warn(iy,e.type,...o?[o,r]:[r]);return}Xe.info(iy,e.type,...o?[o,r]:[r])}function Ya(e){let t=C(e.assets)?e.assets:{},n=t[e.rootCanvasId],r=C(n)&&C(n.content)?n.content:null,o=r&&C(r.nodes)?r.nodes:null,s=r&&C(r.edges)?r.edges:null;return{rootCanvasId:e.rootCanvasId,assetKeys:Object.keys(t).slice(0,20),rootAssetKeys:C(n)?Object.keys(n).slice(0,30):[],nodeCount:o?Object.keys(o).length:void 0,edgeCount:s?Object.keys(s).length:void 0}}function ip(e){if(e==null)return{type:String(e)};if(typeof e=="string")return{type:"string",length:e.length,preview:la(e)};if(Array.isArray(e))return{type:"array",length:e.length,first:ip(e[0])};if(typeof e=="object"){let t=e;return{type:"object",keys:Object.keys(t).slice(0,50),rootCanvasId:t.rootCanvasId,root_canvas_id:t.root_canvas_id,typeField:t.type,hasAssets:C(t.assets),hasContent:t.content!=null,hasData:t.data!=null,hasDocument:t.document!=null,hasCanvasDocument:t.canvasDocument!=null,hasSnapshot:t.snapshot!=null}}return{type:typeof e,value:e}}function Ps(e){return{pippitAssetId:e.pippitAssetId,value:ip(e.value),extra:ip(e.extra)}}function dn(e){return e instanceof Error?{name:e.name,message:e.message,stack:la(e.stack??"",500)}:ip(e)}function xs(e){let t=C(e)?e:void 0;return q(t==null?void 0:t.pippitAssetId)||q(t==null?void 0:t.id)}var Ude=new Set([L,me,M]),zde=new Set([z,he]);function gL(e,t){let n=xs(t);return n?e.assets[n]:void 0}function qde(e,t){let n=C(t.data)?t.data:{},r=gL(e,t),o=C(r)&&C(r.content)?r.content:{};return{...n,...o}}function hL(e){let t=C(e.appearanceInfo)?e.appearanceInfo:void 0;return q(t==null?void 0:t.pippitAssetId)||q(t==null?void 0:t.PippitAssetID)}function Fde(e,t){if(t.type===Qr)return CE(gL(e,t));let n=qde(e,t);if(zde.has(t.type))return hL(n);if(Ude.has(t.type))return q(n.pippitAssetId)||hL(n)}function ay(e,t){let n=new Set;return Object.values(x(e).nodes).forEach(r=>{let o=xs(r);if(t&&(!o||!t.has(o)))return;let s=Fde(e,r);s&&n.add(s)}),[...n].sort()}var yL=150,jde=10;function Vde(e,t){return!!(t!=null&&t.aborted||e instanceof Error&&e.name==="AbortError"||typeof DOMException<"u"&&e instanceof DOMException&&e.name==="AbortError")}function AL(e){let t=[],n=new Set,r=new Set,o=0,s=()=>{o||t.length||(r.forEach(a=>a()),r.clear())},i=()=>{var u;if((u=e.signal)!=null&&u.aborted){t.splice(0),s();return}let a=jde-o;if(a<=0||t.length===0){s();return}let d=t.splice(0,a*yL);gn(d,yL,a).forEach(p=>{o+=1,e.emit({type:"cover-assets-query:start",level:"info",canvasAssetId:e.canvasAssetId,payload:{assetIds:p}}),e.prefetchCoverAssets({pippitAssetIds:p,signal:e.signal}).then(()=>{e.emit({type:"cover-assets-query:success",level:"info",canvasAssetId:e.canvasAssetId,payload:{assetIds:p}})}).catch(l=>{Vde(l,e.signal)||(e.emit({type:"cover-assets-query:error",level:"warn",canvasAssetId:e.canvasAssetId,payload:{assetIds:p,error:dn(l)}}),Xe.warn("[xyq-canvas] Failed to prefetch canvas cover assets",{canvasAssetId:e.canvasAssetId,assetIds:p,error:dn(l)}))}).finally(()=>{o-=1,i()})})};return{enqueue(a){a.forEach(d=>{let c=q(d);!c||n.has(c)||(n.add(c),t.push(c))}),i()},waitForIdle(){return!o&&t.length===0?Promise.resolve():new Promise(a=>r.add(a))}}}var bL=150,fr=10;function Hde(e,t){let n={pippitAssetIds:e,isCamelCase:!0};return t&&(n.signal=t),n}function IL(e){let t=0,n=[],r=()=>t<e?(t+=1,Promise.resolve()):new Promise(s=>{n.push(()=>{t+=1,s()})}),o=()=>{var s;t-=1,(s=n.shift())==null||s()};return{async run(s){await r();try{return await s()}finally{o()}}}}function vL(e){if(e.reason instanceof Error)return e.reason;let t=new Error("Canvas node asset query aborted");return t.name="AbortError",t}function _L(e,t){return!!(t!=null&&t.aborted||e instanceof Error&&e.name==="AbortError"||typeof DOMException<"u"&&e instanceof DOMException&&e.name==="AbortError")}function RL(e,t){let n=async()=>{var s,i;if((s=t.signal)!=null&&s.aborted)throw vL(t.signal);let r=Hde(e,t.signal),o=await(t.queryTextAssetContent.queryImmediately?t.queryTextAssetContent.queryImmediately(r):t.queryTextAssetContent(r));if((i=t.signal)!=null&&i.aborted)throw vL(t.signal);return o};return t.queryLimiter?t.queryLimiter.run(n):n()}async function dy(e,t,n){let r=new Array(e.length),o=0,s=async()=>{for(;o<e.length;){let a=o;o+=1;let d=e[a];if(d===void 0)return;r[a]=await n(d)}},i=Math.min(t,e.length);return await Promise.all(Array.from({length:i},()=>s())),r}async function Yde(e,t){return(await dy(e,fr,async r=>{try{let o=await RL([r],t);return Array.isArray(o)?o:[]}catch(o){if(_L(o,t.signal))throw o;return[]}})).flat()}function SL(e,t,n,r,o){let s=n.filter(i=>i.value!==null&&i.value!==void 0).map(i=>i.pippitAssetId);r.emit({type:"node-assets-query:success",level:o?"warn":"info",canvasAssetId:e,payload:{requestedAssetIds:t,returnedAssetIds:s,missingAssetIds:t.filter(i=>!s.includes(i)),assets:n.map(Ps),...o?{fallback:"individual",batchError:dn(o)}:{}}})}async function EL(e,t,n){n.emit({type:"node-assets-query:start",level:"info",canvasAssetId:t,payload:{assetIds:e}});try{let r=await RL(e,n);return SL(t,e,r,n),{assetIds:e,assets:r}}catch(r){if(_L(r,n.signal))throw r;let o=await Yde(e,n);if(o.length)return SL(t,e,o,n,r),{assetIds:e,assets:o};let s=dn(r);return n.emit({type:"node-assets-query:error",level:"error",canvasAssetId:t,payload:{assetIds:e,error:s}}),Xe.error("[xyq-canvas] Failed to query canvas node assets during restore",{canvasAssetId:t,nodeAssetIds:e,error:s}),{assetIds:e,assets:[]}}}function Kde(e,t){let n=new Set;return t().filter(r=>!e.has(r)||n.has(r)?!1:(n.add(r),!0))}function Xde(e){return gn(e,bL,fr).slice(0,fr)}async function $de(e,t,n,r){let o=new Set(e),s={...n,queryLimiter:IL(fr)};for(;o.size>0;){let i=Kde(o,n.getPriorityNodeAssetIds),a=i.length?i:[...o],d=Xde(a);d.flat().forEach(c=>o.delete(c)),await dy(d,fr,async c=>{let u=await EL(c,t,s);r(u)})}}async function CL(e,t,n,r){if(n.getPriorityNodeAssetIds){await $de(e,t,n,r);return}let o=gn(e,bL,fr),s={...n,queryLimiter:IL(fr)};await dy(o,fr,async i=>{let a=await EL(i,t,s);r(a)})}var PL=["assetId","pippitAssetId","tagInfos","subType","source","sourceType","src","url","metadata","naturalWidth","naturalHeight","caption","display","generation","variant","episodes","localUploadCache","localUploadTask"],Wde={[L]:PL,[me]:[...PL,"projection"],[M]:["assetId","pippitAssetId","tagInfos","subType","source","src","url","downloadUrl","previewUrl","coverUrl","coverURL","metadata","frameWidth","frameHeight","durationMs","caption","title","playback","generation","variant","episodes"],[Ie]:["plainText","content","contentFormat","markdownText","placeholder","block","generation","variant"],[ue]:["assetId","tagInfos","source","src","durationMs","waveformUrl","waveformKey","playback","generation","variant","episodes"]};function ct(e){if(typeof e=="string"){let t=e.trim();if(!t)return null;try{return ct(JSON.parse(t))}catch{return null}}return C(e)?e:null}function Ka(e){let t=ct(e),n=ct(t==null?void 0:t.content);return n&&((t==null?void 0:t.protocolVersion)!==void 0||(t==null?void 0:t.protocol_version)!==void 0)?n:e}function Qde(e){return C(e)?e.nodeName!==void 0||e.order!==void 0||e.basicInfo!==void 0||e.useContext!==void 0||e.episodes!==void 0||e.createType!==void 0||e.appearanceInfo!==void 0||e.referenceAppearances!==void 0||e.voiceInfo!==void 0||e.generation!==void 0||e.sourceInfos!==void 0:!1}function Jde(e){let t=Pt(e);return{...e.nodeName!==void 0?{nodeName:e.nodeName}:{},...e.order!==void 0?{order:e.order}:{},...e.basicInfo!==void 0?{basicInfo:e.basicInfo}:{},...e.useContext!==void 0?{useContext:e.useContext}:{},...e.episodes!==void 0?{episodes:e.episodes}:{},...e.createType!==void 0?{createType:e.createType}:{},...e.appearanceInfo!==void 0?{appearanceInfo:e.appearanceInfo}:{},...e.referenceAppearances!==void 0?{referenceAppearances:e.referenceAppearances}:{},...t!==void 0?{voiceInfo:t}:{},...e.generation!==void 0?{generation:e.generation}:{},...e.sourceInfos!==void 0?{sourceInfos:e.sourceInfos}:{}}}function Zde(e){if(e!==void 0)return Array.isArray(e)?e.reduce((t,n)=>{let r=ct(n);return Kc(r)&&t.push(r),t},[]):[]}function ece(e){let t=Xo(e.sourceInfos),n=Zde(e.referenceAppearances),{referenceAppearances:r,sourceInfos:o,...s}=e,i={...s,...n!==void 0?{referenceAppearances:n}:{},...t?{sourceInfos:t}:{}},a=ct(e.appearanceInfo);return a?{...i,appearanceInfo:a}:i}function tce(e){let t=ct(Ka(e));return Qde(t)?ece(Jde(t)):null}function xL(e,t){let n=q(e),r=q(t);if(n===L||r===L)return L;if(n===me||r===me)return me;if(n===M||r===M)return M;if(n===Ie||r===Ie)return Ie;if(n===ue||r===ue)return ue}function nce(e,t){let n=q(e),r=q(t);return n===Qr||r===Qr}function rce(e,t){if(!nce(e.type,t))return null;let n=ct(Ka(e.content));if(ih(n)||is(n))return n;let r=ct(n==null?void 0:n.directorDocument);if(is(r))return r;let o=ct(n==null?void 0:n.data);if(is(o))return o;let s=ct(Ka(e.data));if(is(s))return s;let i=ct(s==null?void 0:s.directorDocument);return is(i)?i:null}function oce(e,t){return C(e)?Object.keys(e).length===0||Wde[t].some(r=>r in e):!1}function sce(e,t){if(!C(e))return e;if(t===Ie)return Zn(e).data;if(t!==L&&t!==M)return e;let n={...e},r=!1;(e.localUploadCache===""||e.localUploadCache===null)&&(delete n.localUploadCache,r=!0);let o=C(e.localUploadTask)?e.localUploadTask:void 0;if((t===L||t===M&&(e.uploadPath==="optimized"||(o==null?void 0:o.uploadPath)==="optimized"))&&e.localUploadTask!==void 0){let i=t===L?"image":"video";(e.localUploadTask===""||e.localUploadTask===null||!Nt(e.localUploadTask,i)||e.localUploadTask.status==="capturing"&&!e.localUploadTask.cacheId)&&(delete n.localUploadTask,r=!0)}return r?n:e}function cy(e,t){if(!oce(e,t))return null;let n=sce(e,t);return t===L&&Yi(n)?{...n}:t===me&&ym(n)?{...n}:t===M&&vm(n)?{...n}:t===Ie&&bm(n)?{...n}:t===ue&&gm(n)?{...n}:null}function ice(e,t){let n=xL(e.type,t);if(!n)return null;let r=cy(Ka(e.content),n),o=cy(Ka(e.data),n);return r||o||"content"in e||"data"in e?r??o:cy(e,n)}function ace(e){let t=C(e.extra)?{...e.extra}:{},n=e.create_type??e.createType??e.CreateType;return n!==void 0&&t.create_type===void 0&&(t.create_type=n),t}function dce(e){let t=ct(e.history??e.History);return t?{...t}:void 0}function cce(e,t){let n=ct(e);if(!n)return null;let r=n,o=!!xL(r.type,t.nodeType),s=rce(r,t.nodeType)??(o?ice(r,t.nodeType):tce(r.content));if(!s)return null;let i=q(r.protocolVersion),a=q(r.dataVersion),d=dce(r);return{pippitAssetId:q(r.pippitAssetId)||t.nodeAssetId,type:q(r.type)||"unknown",...i?{protocolVersion:i}:{},...a?{dataVersion:a}:{},content:s,...d?{history:d}:{},extra:ace(r)}}function ap(e,t){return cce(e,t)}function uce(e){let t=C(e)?e:void 0;return q(t==null?void 0:t.type)}function wL(e){let t=q(e);return t===be||t===Ft}function pce(e){let t=x(e),n=new Map;return Object.values(t.nodes).forEach(r=>{let o=uce(r);if(wL(o))return;let s=xs(r);s&&s!==e.rootCanvasId&&n.set(s,{assetId:s,nodeType:o})}),[...n.values()].sort((r,o)=>r.assetId.localeCompare(o.assetId))}function TL(e){return e.includes("::")}function lce(e,t){let n=e.assets[t];return C(n)&&C(n.content)}function fce(e){let t=q(e);return t===z||t===O_}function mce(e,t){var r,o;if(!fce(t.type))return!1;let n=e.assets[xs(t)??""];return((o=(r=$t(n))==null?void 0:r.basicInfo)==null?void 0:o.unpromptable)===!0}function uy(e){let t=x(e),n=new Set(Object.values(t.nodes).filter(i=>mce(e,i)).map(i=>i.id));if(!n.size)return e;let r=Object.fromEntries(Object.entries(t.nodes).filter(([i])=>!n.has(i)).map(([i,a])=>{let{children:d}=a;return!wL(a.type)||!Array.isArray(d)?[i,a]:[i,{...a,children:d.filter(c=>!n.has(c))}]})),o=Object.fromEntries(Object.entries(t.edges).filter(([,i])=>!n.has(i.source)&&!n.has(i.target))),s=e.assets[e.rootCanvasId];return{...e,assets:{...e.assets,[e.rootCanvasId]:{...s,content:{...t,nodes:r,edges:o}}}}}function dp(e){if(e==null)return null;if(typeof e=="string"){let t=e.trim();if(!t)return e;try{return dp(JSON.parse(t))}catch{return e}}return Array.isArray(e)?e.map(dp):C(e)?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,dp(n)])):e}function hce(e,t){let n=new Map(e.assets.map(i=>[i.pippitAssetId,i])),r={},o=[],s=[];return e.assetIds.forEach(i=>{let a=n.get(i);if((a==null?void 0:a.value)==null)return;let d=ap(a.value,{nodeAssetId:i,nodeType:t.get(i)});if(!d){s.push(i);return}r[i]={...d,assetExtra:dp(a.extra)},o.push(i)}),{assets:r,loadedAssetIds:o,unparsedAssetIds:s}}function NL(e,t,n){if(n)try{n({document:uy(e),readyNodeAssetIds:[...t].sort()})}catch(r){Xe.warn("[xyq-canvas] Node asset ready observer failed during restore",r)}}async function OL(e,t,n){let r=pce(e),o=r.map(y=>y.assetId),s=new Map(r.map(y=>[y.assetId,y.nodeType])),i=n.prefetchCoverAssets?AL({canvasAssetId:t,emit:n.emit,prefetchCoverAssets:n.prefetchCoverAssets,signal:n.signal}):void 0;i==null||i.enqueue(ay(e));let a=o.filter(y=>!lce(e,y)),d=o.filter(y=>!a.includes(y)),c=a.filter(y=>!TL(y)),u=a.filter(TL);n.emit({type:"node-assets:collect",level:"info",canvasAssetId:t,payload:{nodeAssetIds:o,missingNodeAssetIds:a,existingNodeAssetIds:d,skippedSyntheticNodeAssetIds:u}}),u.length&&Xe.error("[xyq-canvas] Skip synthetic node asset ids during canvas restore",{canvasAssetId:t,skippedSyntheticNodeAssetIds:u});let p=new Set(d);if(d.length&&NL(e,p,n.onNodeAssetsReady),!a.length)return{document:uy(e),canvasAssetId:t,nodeAssetIds:o,loadedNodeAssetIds:[],missingNodeAssetIds:[]};let l=[],f=[],h=e;c.length&&await CL(c,t,{...n,getPriorityNodeAssetIds:n.resolvePriorityNodeAssetIds?()=>{var y;return((y=n.resolvePriorityNodeAssetIds)==null?void 0:y.call(n,h))??[]}:void 0},y=>{let v=hce(y,s);f.push(...v.unparsedAssetIds),v.loadedAssetIds.length&&(l.push(...v.loadedAssetIds),v.loadedAssetIds.forEach(S=>p.add(S)),h={...h,assets:{...h.assets,...v.assets}},i==null||i.enqueue(ay(h,new Set(v.loadedAssetIds))),NL(h,p,n.onNodeAssetsReady))}),l.sort(),f.sort();let m=uy(h),g=a.filter(y=>!l.includes(y));return n.emit({type:"node-assets:merge",level:g.length?"warn":"info",canvasAssetId:t,payload:{loadedNodeAssetIds:l,missingNodeAssetIds:g,unparsedNodeAssetIds:f,document:Ya(m)}}),{document:m,canvasAssetId:t,nodeAssetIds:o,loadedNodeAssetIds:l,missingNodeAssetIds:g}}function ML(e){return e===be||e===Ft}function DL(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function LL(e){if(!e.startsWith("group"))return e;let t=e.slice(5);if(!t)return e;let n=t.replace(/^[-_$]+/,"");if(!n)return e;let r=n.replace(/[-_]/g,"$").replace(/([a-z0-9])([A-Z])/g,"$1$$$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1$$$2").replace(/\$+/g,"$").replace(/^\$|\$$/g,"").toLowerCase();return r?`group$${r}`:e}function gce(e,t){let n=e,r=2;for(;t.has(n);)n=`${e}$${r}`,r+=1;return n}function yce(e){let t=new Set(Object.keys(e)),n=new Map;return Object.values(e).forEach(r=>{if(!ML(r.type))return;let o=LL(r.id);if(o===r.id)return;t.delete(r.id);let s=gce(o,t);t.add(s),n.set(r.id,s)}),n}function kL(e,t,n){let r=t.get(e);if(r)return r;let o=LL(e);return o!==e&&n.has(o)?o:e}function BL(e,t,n,r){t.has(n)||(e[n]={...e[n]},t.add(n)),r(e[n])}function GL(e){let t=yce(e),n=new Set(Object.keys(e).map(s=>t.get(s)??s)),r={},o=t.size>0;return Object.entries(e).forEach(([s,i])=>{let a=t.get(s)??s,d=i;if(i.id!==a&&(d={...d,id:a},o=!0),typeof d.parentId=="string"){let u=kL(d.parentId,t,n);u!==d.parentId&&(d={...d,parentId:u},o=!0)}let c=d.children;if(Array.isArray(c)){let u=c.map(p=>typeof p=="string"?kL(p,t,n):p);u.some((p,l)=>p!==c[l])&&(d={...d,children:u},o=!0)}a!==s&&(o=!0),r[a]=d}),{nodes:o?r:e,changed:o,nodeIdAliases:t}}function UL(e,t,n,r){let o={...e};return t.forEach((s,i)=>{if(i===n||!DL(o,i))return;let a=o[i];DL(o,s)||(o[s]=C(a)?{...a,pippitAssetId:s}:a),delete o[i]}),o[n]=r,o}function py(e){let t={...e},n=new Set,r=new Map,o=!1,s=(i,a)=>{BL(t,n,i,a),o=!0};return Object.values(e).forEach(i=>{if(!ML(i.type)){"children"in i&&s(i.id,u=>{delete u.children});return}let a=i.children;if(a==null)return;if(!Array.isArray(a)){s(i.id,u=>{u.children=[]});return}let d=new Set,c=a.filter(u=>{if(typeof u!="string"||d.has(u))return!1;d.add(u);let p=e[u];return!p||p.parentId!==i.id||r.has(u)?!1:(r.set(u,i.id),!0)});(c.length!==a.length||c.some((u,p)=>u!==a[p]))&&s(i.id,u=>{u.children=c})}),Object.values(t).forEach(i=>{if(!i.parentId)return;let a=t[i.parentId];if(a&&"children"in a&&a.children===null)return;let d=Array.isArray(a==null?void 0:a.children)?a.children:[];(!a||!d.includes(i.id))&&s(i.id,c=>{delete c.parentId})}),{nodes:o?t:e,changed:o}}function zL(e){let t=new Set;if(Object.values(e).forEach(o=>{let s=[],i=new Map,a=o;for(;a!=null&&a.parentId;){let d=i.get(a.id);if(d!==void 0){s.slice(d).forEach(c=>t.add(c));break}i.set(a.id,s.length),s.push(a.id),a=e[a.parentId]}}),!t.size)return{nodes:e,changed:!1};let n={...e},r=new Set;return t.forEach(o=>{BL(n,r,o,s=>{delete s.parentId})}),{nodes:n,changed:!0}}function mr(e){return typeof e=="string"?e.trim()||void 0:typeof e=="number"&&Number.isFinite(e)?String(e):void 0}function Ts(e,t){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e!="string"||!e.trim())return t;let n=Number(e);return Number.isFinite(n)?n:t}function qL(e,t){let n=Ts(e,t);return n>0?n:t}function FL(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jL(e){if(typeof e!="string")return;let t=e.trim();if(!(!t||t==="null"||t==="undefined"))return t}function Ace(e){return{...e,snap:{...e.snap,targets:[...e.snap.targets]},grid:{...e.grid},...e.autoLayout?{autoLayout:{...e.autoLayout}}:{}}}function VL(e,t){if(!C(e))return{settings:Ace(t),changed:!0};let n=C(e.snap)?e.snap:void 0,r=C(e.grid)?e.grid:void 0,o=C(e.autoLayout)?e.autoLayout:void 0,s=o==null?void 0:o.strategy,i=Object.prototype.hasOwnProperty.call(e,"autoLayout"),a=typeof s=="string"?s.trim():void 0,d=!!a,c=Array.isArray(n==null?void 0:n.targets)?n.targets.filter(p=>typeof p=="string"):void 0,u={...e,snap:{enabled:typeof(n==null?void 0:n.enabled)=="boolean"?n.enabled:t.snap.enabled,threshold:qL(n==null?void 0:n.threshold,t.snap.threshold),targets:c&&c.length>0?c:[...t.snap.targets]},grid:{size:Ts(r==null?void 0:r.size,t.grid.size),visible:typeof(r==null?void 0:r.visible)=="boolean"?r.visible:t.grid.visible}};return d?u.autoLayout={...o,strategy:a}:delete u.autoLayout,{settings:u,changed:!n||!r||typeof n.enabled!="boolean"||typeof r.visible!="boolean"||!Number.isFinite(n.threshold)||qL(n.threshold,t.snap.threshold)!==n.threshold||!Number.isFinite(r.size)||!Array.isArray(n.targets)||((c==null?void 0:c.length)??0)!==n.targets.length||i&&(!d||a!==s)}}function HL(e){if(!C(e))return{nodes:{},changed:e!==void 0};let t={},n=!1;return Object.entries(e).forEach(([r,o])=>{if(!C(o)){n=!0;return}let s={...o},i=mr(s.id)||r;s.id!==i&&(s.id=i,n=!0),i!==r&&(n=!0);let a=mr(s.parentId)||mr(s.parent_id);a&&s.parentId!==a?(s.parentId=a,n=!0):!a&&s.parentId!=null&&typeof s.parentId!="string"&&(delete s.parentId,n=!0);let d=Ts(s.x,0),c=Ts(s.y,0),u=Ts(s.w,0),p=Ts(s.h,0);(s.x!==d||s.y!==c||s.w!==u||s.h!==p)&&(Object.assign(s,{x:d,y:c,w:u,h:p}),n=!0),t[i]=s}),{nodes:t,changed:n}}function YL(e,t,n=new Map){if(!C(e))return{edges:{},changed:e!==void 0};let r={},o=!1;return Object.entries(e).forEach(([s,i])=>{if(!C(i)){o=!0;return}let a=mr(i.id)||s,d=mr(i.source),c=mr(i.target),u=d?n.get(d)??d:void 0,p=c?n.get(c)??c:void 0;if(!u||!p||!t[u]||!t[p]){o=!0;return}r[a]&&(o=!0);let l=jL(i.sourceHandle),f=jL(i.targetHandle),h={...i,id:a,source:u,target:p},m=a!==s||i.id!==a||i.source!==u||i.target!==p||d!==u||c!==p;l?(h.sourceHandle=l,m||=i.sourceHandle!==l):FL(i,"sourceHandle")&&(delete h.sourceHandle,m=!0),f?(h.targetHandle=f,m||=i.targetHandle!==f):FL(i,"targetHandle")&&(delete h.targetHandle,m=!0),r[a]=m?h:i,o||=m}),{edges:r,changed:o}}function Xa(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function KL(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function vce(e,t){return JSON.stringify(e)===JSON.stringify(t)}function po(e,t,n,r,o,s){let i=Xa(n,r);i&&vce(n[r],s)||e.push({assetId:t,op:i?"replace":"add",path:o,value:s})}function XL(e,t,n,r,o){Object.keys(n).forEach(s=>{Xa(r,s)||e.push({assetId:t,op:"remove",path:`${o}/${KL(s)}`})}),Object.entries(r).forEach(([s,i])=>{po(e,t,n,s,`${o}/${KL(s)}`,i)})}function Sce(e,t,n,r){if(!C(t.content))return[{assetId:e,op:Xa(t,"content")?"replace":"add",path:"/content",value:r}];let o=[];return po(o,e,n,"metadata","/content/metadata",r.metadata),C(n.settings)?(po(o,e,n.settings,"snap","/content/settings/snap",r.settings.snap),po(o,e,n.settings,"grid","/content/settings/grid",r.settings.grid)):po(o,e,n,"settings","/content/settings",r.settings),C(n.nodes)?XL(o,e,n.nodes,r.nodes,"/content/nodes"):po(o,e,n,"nodes","/content/nodes",r.nodes),C(n.edges)?XL(o,e,n.edges,r.edges,"/content/edges"):po(o,e,n,"edges","/content/edges",r.edges),o}function bce(e){let t={...e},n=!1;return Object.entries(e).forEach(([r,o])=>{if(o.type!==Ie||!C(o.data))return;let s=Zn(o.data);s.changed&&(t[r]={...o,data:s.data},n=!0)}),{nodes:n?t:e,changed:n}}function Ice(e,t,n){let r={...e},o=[],s=!1;return Object.entries(e).forEach(([i,a])=>{var u;if(i===n||!C(a)||!C(a.content)||(typeof a.type=="string"?a.type:(u=t[i])==null?void 0:u.type)!==Ie)return;let c=Zn(a.content);c.changed&&(r[i]={...a,content:c.data},o.push({assetId:i,op:"replace",path:"/content",value:c.data}),s=!0)}),{assets:s?r:e,changed:s,repairPatches:o}}function ly(e){let t=e.assets[e.rootCanvasId];if(!t||!C(t))return{document:e,repairPatches:[]};let n=bo(e.rootCanvasId).assets[e.rootCanvasId].content,r=C(t.content)?t.content:{},o=HL(r.nodes),s=bce(o.nodes),i=GL(s.nodes),a=py(i.nodes),d=zL(a.nodes),c=d.changed?py(d.nodes):d,u=Ice(e.assets,c.nodes,e.rootCanvasId),p=YL(r.edges,c.nodes,i.nodeIdAliases),l=VL(r.settings,n.settings),f=C(r.metadata)?r.metadata:n.metadata,m=mr(t.pippitAssetId)!==e.rootCanvasId,g=t.type!==lt,y=!C(t.content)||!C(r.metadata)||!C(r.nodes)||!C(r.edges)||o.changed||s.changed||i.changed||a.changed||d.changed||c.changed||p.changed||l.changed;if(!(g||m||y||u.changed))return{document:e,repairPatches:[]};let S={...n,...r,metadata:f,settings:l.settings,nodes:c.nodes,edges:p.edges},b={...t,pippitAssetId:e.rootCanvasId,type:lt,content:S},I=[];return m&&I.push({assetId:e.rootCanvasId,op:Xa(t,"pippitAssetId")?"replace":"add",path:"/pippitAssetId",value:e.rootCanvasId}),g&&I.push({assetId:e.rootCanvasId,op:Xa(t,"type")?"replace":"add",path:"/type",value:lt}),y&&I.push(...Sce(e.rootCanvasId,t,r,S)),I.push(...u.repairPatches),{document:{...e,assets:UL(u.assets,i.nodeIdAliases,e.rootCanvasId,b)},repairPatches:I}}function $L(e){return C(e.nodes)?Object.keys(e.nodes).length:0}function _ce(e,t){let n=$L(e),r=$L(t);if(r<=0)return!1;let o=C(e.edges),s=C(t.edges);return!o&&s&&r>n?!0:n===0&&r>0}function Rce(e){let t=C(e.content)?e.content:null,n=C(e.data)?e.data:null;return t?n&&_ce(t,n)?n:t:n}function Ece(e){let t={...e};return delete t.data,t}function Cce(e,t){let n=q(e.rootCanvasId)||q(e.root_canvas_id)||t,r=C(e.assets)?e.assets:null;return!n||!r||!C(r[n])?null:{rootCanvasId:n,assets:r}}function Pce(e,t){let n=q(e.pippitAssetId)||q(e.pippit_asset_id)||t,r=Rce(e);return!n||e.type!=="canvas"||!r?null:{rootCanvasId:n,assets:{[n]:{...Ece(e),pippitAssetId:n,content:r,extra:C(e.extra)?e.extra:C(e.Extra)?e.Extra:{}}}}}function hy(e,t,n){if(e==null)return null;if(typeof e=="string"){let s=e.trim();if(!s)return null;try{return hy(JSON.parse(s),t,n)}catch{return null}}if(!C(e)||n.has(e))return null;n.add(e);let r=Cce(e,t);if(r){let s=ly(r);return{document:s.document,repairPatches:s.repairPatches}}let o=Pce(e,t);if(o){let s=ly(o);return{document:s.document,repairPatches:s.repairPatches}}for(let s of["document","canvasDocument","canvas_document","snapshot","data","content","value"]){let i=hy(e[s],t,n);if(i)return i}return null}function fy(e,t){return hy(e,t,new Set)}function my(e,t){var n;return e?(e.repairPatches.length>0&&((n=t.onRepairPatches)==null||n.call(t,e.repairPatches)),e.document):null}function cp(e,t={}){let n=fy(e,t.canvasAssetId);if(n)return Promise.resolve(my(n,t));let r=C(e)?e:void 0,o=GE(r,"TextInfo","textInfo"),s=fy(o==null?void 0:o.content,t.canvasAssetId);if(s)return Promise.resolve(my(s,t));let i=fy((r==null?void 0:r.Extra)??(r==null?void 0:r.extra),t.canvasAssetId);return i?Promise.resolve(my(i,t)):Promise.resolve(null)}var xce=new Set([z,he]),Tce=new Set([L,M]);function Nce(e){return typeof e.x=="number"&&Number.isFinite(e.x)&&typeof e.y=="number"&&Number.isFinite(e.y)&&typeof e.w=="number"&&Number.isFinite(e.w)&&e.w>0&&typeof e.h=="number"&&Number.isFinite(e.h)&&e.h>0}function wce(e){return{name:e?`${sp.name}-media`:"media-node-geometry-repair",layout(t){let n=e?sp.layout(t):t;return dL(n,{repairInvalidOnly:!0})}}}function Oce(e){let t=!1,n=!1;if(Object.values(x(e).nodes).forEach(r=>{if(!Nce(r)){if(Tce.has(r.type)){n=!0;return}xce.has(r.type)&&(t=!0)}}),n)return wce(t);if(t)return sp}var Dce=["x","y","w","h","order"];function kce(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Mce(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Lce(e,t){let n=x(e).nodes,r=x(t).nodes,o=[];return Object.values(r).forEach(s=>{let i=n[s.id];i&&Dce.forEach(a=>{let d=s[a];i[a]!==d&&o.push({assetId:t.rootCanvasId,op:Mce(i,a)?"replace":"add",path:`/content/nodes/${kce(s.id)}/${a}`,value:d})})}),o}function Bce(e,t){let n={pippitAssetIds:e,isCamelCase:!0};return t&&(n.signal=t),n}var gy=class{constructor(t){this._options=t;this._eventEmitter=new pa;this.onEvent=this._eventEmitter.event}async loadDocument(t){return(await this.restore(t)).document}async restore(t){var o,s;let n=t.trim();if(!n)throw new Error("missing canvasAssetId");let r="canvas-asset-query";try{this._emit({type:"restore:start",level:"info",canvasAssetId:n});let{selectedAsset:i}=await this._queryCanvasAsset(n),a=[];r="canvas-document-normalize",this._emit({type:"canvas-document-normalize:start",level:"info",canvasAssetId:n,payload:{textAsset:Ps(i)}});let d=await cp(i.value,{canvasAssetId:n,signal:this._options.signal,onRepairPatches:h=>a.push(...h)});if(!d){let h=new Error(O.t("Pippit_xyqcanvas_restore_error_invalidcanvasasset",{},"画布资产内容为空或格式不正确"));throw this._emit({type:"canvas-document-normalize:error",level:"warn",canvasAssetId:n,payload:{error:dn(h),textAsset:Ps(i)}},h),h}this._emit({type:"canvas-document-normalize:success",level:"info",canvasAssetId:n,payload:{document:Ya(d)}}),r="root-document-ready",(s=(o=this._options).onRootDocumentReady)==null||s.call(o,d),r="node-assets-hydrate";let c=await OL(d,n,{signal:this._options.signal,queryTextAssetContent:this._options.queryTextAssetContent,prefetchCoverAssets:this._options.prefetchCoverAssets,emit:h=>this._emit(h),onNodeAssetsReady:this._options.onNodeAssetsReady,resolvePriorityNodeAssetIds:this._options.resolvePriorityNodeAssetIds});r="canvas-layout";let u=this._options.layoutStrategy===void 0?Oce(c.document):this._options.layoutStrategy,p=u?u.layout(c.document):c.document,l=u?Lce(c.document,p):[],f=p===c.document?c:{...c,document:p};return u&&(f.layoutApplied=!0,f.layoutPatches=l,f.layoutStrategy=u.name),a.length>0&&(f.repairApplied=!0,f.repairPatches=a),r="restore-finalize",this._emit({type:"restore:success",level:"info",canvasAssetId:n,payload:{document:Ya(f.document),nodeAssetIds:f.nodeAssetIds,loadedNodeAssetIds:f.loadedNodeAssetIds,missingNodeAssetIds:f.missingNodeAssetIds,repairApplied:a.length>0,repairPatchCount:a.length,layoutApplied:!!u,layoutPatchCount:l.length,layoutStrategy:u?u.name:void 0}}),f}catch(i){let a=ey(i,this._options.signal),d=a?"aborted":ty(i);throw this._emit({type:a?"restore:cancel":"restore:error",level:a?"info":"error",canvasAssetId:n,payload:{error:dn(i),failure_stage:r,...d?{reason:d}:{}}},i),i}}dispose(){this._eventEmitter.dispose()}async _queryCanvasAsset(t){this._emit({type:"canvas-asset-query:start",level:"info",canvasAssetId:t,payload:{assetIds:[t]}});try{let n=await this._options.queryTextAssetContent(Bce([t],this._options.signal)),r=n.find(o=>o.pippitAssetId===t)??n[0];if((r==null?void 0:r.value)===null||(r==null?void 0:r.value)===void 0)throw new Ha(O.t("Pippit_xyqcanvas_restore_error_canvasassetnotfound",{},"画布资产不存在"));return this._emit({type:"canvas-asset-query:success",level:"info",canvasAssetId:t,payload:{assetCount:n.length,resolvedAssetIds:n.filter(o=>o.value!==null&&o.value!==void 0).map(o=>o.pippitAssetId),assets:n.map(Ps)}}),{selectedAsset:r,assets:n}}catch(n){let r=ey(n,this._options.signal),o=r?"aborted":ty(n);throw this._emit({type:r?"canvas-asset-query:cancel":"canvas-asset-query:error",level:r?"info":"warn",canvasAssetId:t,payload:{error:dn(n),...o?{reason:o}:{}}},n),n}}_emit(t,n){this._eventEmitter.fire(t),mL(t,this._options,n)}};async function WL(e,t){let n=new gy(t),r=t.onEvent?n.onEvent(t.onEvent):void 0;try{return await n.restore(e)}finally{r==null||r.dispose(),n.dispose()}}function Gce(){this.__data__=[],this.size=0}var QL=Gce;function Uce(e,t){return e===t||e!==e&&t!==t}var up=Uce;function zce(e,t){for(var n=e.length;n--;)if(up(e[n][0],t))return n;return-1}var hr=zce;var qce=Array.prototype,Fce=qce.splice;function jce(e){var t=this.__data__,n=hr(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():Fce.call(t,n,1),--this.size,!0}var JL=jce;function Vce(e){var t=this.__data__,n=hr(t,e);return n<0?void 0:t[n][1]}var ZL=Vce;function Hce(e){return hr(this.__data__,e)>-1}var eB=Hce;function Yce(e,t){var n=this.__data__,r=hr(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}var tB=Yce;function Ns(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Ns.prototype.clear=QL;Ns.prototype.delete=JL;Ns.prototype.get=ZL;Ns.prototype.has=eB;Ns.prototype.set=tB;var gr=Ns;function Kce(){this.__data__=new gr,this.size=0}var nB=Kce;function Xce(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}var rB=Xce;function $ce(e){return this.__data__.get(e)}var oB=$ce;function Wce(e){return this.__data__.has(e)}var sB=Wce;var Qce=typeof global=="object"&&global&&global.Object===Object&&global,pp=Qce;var Jce=typeof self=="object"&&self&&self.Object===Object&&self,Zce=pp||Jce||Function("return this")(),_e=Zce;var eue=_e.Symbol,Mn=eue;var iB=Object.prototype,tue=iB.hasOwnProperty,nue=iB.toString,$a=Mn?Mn.toStringTag:void 0;function rue(e){var t=tue.call(e,$a),n=e[$a];try{e[$a]=void 0;var r=!0}catch{}var o=nue.call(e);return r&&(t?e[$a]=n:delete e[$a]),o}var aB=rue;var oue=Object.prototype,sue=oue.toString;function iue(e){return sue.call(e)}var dB=iue;var aue="[object Null]",due="[object Undefined]",cB=Mn?Mn.toStringTag:void 0;function cue(e){return e==null?e===void 0?due:aue:cB&&cB in Object(e)?aB(e):dB(e)}var Ln=cue;function uue(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var cn=uue;var pue="[object AsyncFunction]",lue="[object Function]",fue="[object GeneratorFunction]",mue="[object Proxy]";function hue(e){if(!cn(e))return!1;var t=Ln(e);return t==lue||t==fue||t==pue||t==mue}var lp=hue;var gue=_e["__core-js_shared__"],fp=gue;var uB=function(){var e=/[^.]+$/.exec(fp&&fp.keys&&fp.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function yue(e){return!!uB&&uB in e}var pB=yue;var Aue=Function.prototype,vue=Aue.toString;function Sue(e){if(e!=null){try{return vue.call(e)}catch{}try{return e+""}catch{}}return""}var Bn=Sue;var bue=/[\\^$.*+?()[\]{}|]/g,Iue=/^\[object .+?Constructor\]$/,_ue=Function.prototype,Rue=Object.prototype,Eue=_ue.toString,Cue=Rue.hasOwnProperty,Pue=RegExp("^"+Eue.call(Cue).replace(bue,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function xue(e){if(!cn(e)||pB(e))return!1;var t=lp(e)?Pue:Iue;return t.test(Bn(e))}var lB=xue;function Tue(e,t){return e==null?void 0:e[t]}var fB=Tue;function Nue(e,t){var n=fB(e,t);return lB(n)?n:void 0}var $e=Nue;var wue=$e(_e,"Map"),yr=wue;var Oue=$e(Object,"create"),Gn=Oue;function Due(){this.__data__=Gn?Gn(null):{},this.size=0}var mB=Due;function kue(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var hB=kue;var Mue="__lodash_hash_undefined__",Lue=Object.prototype,Bue=Lue.hasOwnProperty;function Gue(e){var t=this.__data__;if(Gn){var n=t[e];return n===Mue?void 0:n}return Bue.call(t,e)?t[e]:void 0}var gB=Gue;var Uue=Object.prototype,zue=Uue.hasOwnProperty;function que(e){var t=this.__data__;return Gn?t[e]!==void 0:zue.call(t,e)}var yB=que;var Fue="__lodash_hash_undefined__";function jue(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Gn&&t===void 0?Fue:t,this}var AB=jue;function ws(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}ws.prototype.clear=mB;ws.prototype.delete=hB;ws.prototype.get=gB;ws.prototype.has=yB;ws.prototype.set=AB;var yy=ws;function Vue(){this.size=0,this.__data__={hash:new yy,map:new(yr||gr),string:new yy}}var vB=Vue;function Hue(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var SB=Hue;function Yue(e,t){var n=e.__data__;return SB(t)?n[typeof t=="string"?"string":"hash"]:n.map}var Ar=Yue;function Kue(e){var t=Ar(this,e).delete(e);return this.size-=t?1:0,t}var bB=Kue;function Xue(e){return Ar(this,e).get(e)}var IB=Xue;function $ue(e){return Ar(this,e).has(e)}var _B=$ue;function Wue(e,t){var n=Ar(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}var RB=Wue;function Os(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Os.prototype.clear=vB;Os.prototype.delete=bB;Os.prototype.get=IB;Os.prototype.has=_B;Os.prototype.set=RB;var EB=Os;var Que=200;function Jue(e,t){var n=this.__data__;if(n instanceof gr){var r=n.__data__;if(!yr||r.length<Que-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new EB(r)}return n.set(e,t),this.size=n.size,this}var CB=Jue;function Ds(e){var t=this.__data__=new gr(e);this.size=t.size}Ds.prototype.clear=nB;Ds.prototype.delete=rB;Ds.prototype.get=oB;Ds.prototype.has=sB;Ds.prototype.set=CB;var PB=Ds;var Zue=_e.Uint8Array,Ay=Zue;function epe(e,t){for(var n=-1,r=t.length,o=e.length;++n<r;)e[o+n]=t[n];return e}var mp=epe;var tpe=Array.isArray,ks=tpe;function npe(e,t,n){var r=t(e);return ks(e)?r:mp(r,n(e))}var hp=npe;function rpe(e,t){for(var n=-1,r=e==null?0:e.length,o=0,s=[];++n<r;){var i=e[n];t(i,n,e)&&(s[o++]=i)}return s}var xB=rpe;function ope(){return[]}var gp=ope;var spe=Object.prototype,ipe=spe.propertyIsEnumerable,TB=Object.getOwnPropertySymbols,ape=TB?function(e){return e==null?[]:(e=Object(e),xB(TB(e),function(t){return ipe.call(e,t)}))}:gp,Ms=ape;function dpe(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var NB=dpe;function cpe(e){return e!=null&&typeof e=="object"}var un=cpe;var upe="[object Arguments]";function ppe(e){return un(e)&&Ln(e)==upe}var vy=ppe;var wB=Object.prototype,lpe=wB.hasOwnProperty,fpe=wB.propertyIsEnumerable,mpe=vy(function(){return arguments}())?vy:function(e){return un(e)&&lpe.call(e,"callee")&&!fpe.call(e,"callee")},OB=mpe;function hpe(){return!1}var DB=hpe;var LB=typeof exports=="object"&&exports&&!exports.nodeType&&exports,kB=LB&&typeof module=="object"&&module&&!module.nodeType&&module,gpe=kB&&kB.exports===LB,MB=gpe?_e.Buffer:void 0,ype=MB?MB.isBuffer:void 0,Ape=ype||DB,yp=Ape;var vpe=9007199254740991,Spe=/^(?:0|[1-9]\d*)$/;function bpe(e,t){var n=typeof e;return t=t??vpe,!!t&&(n=="number"||n!="symbol"&&Spe.test(e))&&e>-1&&e%1==0&&e<t}var BB=bpe;var Ipe=9007199254740991;function _pe(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Ipe}var Ap=_pe;var Rpe="[object Arguments]",Epe="[object Array]",Cpe="[object Boolean]",Ppe="[object Date]",xpe="[object Error]",Tpe="[object Function]",Npe="[object Map]",wpe="[object Number]",Ope="[object Object]",Dpe="[object RegExp]",kpe="[object Set]",Mpe="[object String]",Lpe="[object WeakMap]",Bpe="[object ArrayBuffer]",Gpe="[object DataView]",Upe="[object Float32Array]",zpe="[object Float64Array]",qpe="[object Int8Array]",Fpe="[object Int16Array]",jpe="[object Int32Array]",Vpe="[object Uint8Array]",Hpe="[object Uint8ClampedArray]",Ype="[object Uint16Array]",Kpe="[object Uint32Array]",fe={};fe[Upe]=fe[zpe]=fe[qpe]=fe[Fpe]=fe[jpe]=fe[Vpe]=fe[Hpe]=fe[Ype]=fe[Kpe]=!0;fe[Rpe]=fe[Epe]=fe[Bpe]=fe[Cpe]=fe[Gpe]=fe[Ppe]=fe[xpe]=fe[Tpe]=fe[Npe]=fe[wpe]=fe[Ope]=fe[Dpe]=fe[kpe]=fe[Mpe]=fe[Lpe]=!1;function Xpe(e){return un(e)&&Ap(e.length)&&!!fe[Ln(e)]}var GB=Xpe;function $pe(e){return function(t){return e(t)}}var Ls=$pe;var UB=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Wa=UB&&typeof module=="object"&&module&&!module.nodeType&&module,Wpe=Wa&&Wa.exports===UB,Sy=Wpe&&pp.process,Qpe=function(){try{var e=Wa&&Wa.require&&Wa.require("util").types;return e||Sy&&Sy.binding&&Sy.binding("util")}catch{}}(),Un=Qpe;var zB=Un&&Un.isTypedArray,Jpe=zB?Ls(zB):GB,qB=Jpe;var Zpe=Object.prototype,ele=Zpe.hasOwnProperty;function tle(e,t){var n=ks(e),r=!n&&OB(e),o=!n&&!r&&yp(e),s=!n&&!r&&!o&&qB(e),i=n||r||o||s,a=i?NB(e.length,String):[],d=a.length;for(var c in e)(t||ele.call(e,c))&&!(i&&(c=="length"||o&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||BB(c,d)))&&a.push(c);return a}var vp=tle;var nle=Object.prototype;function rle(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||nle;return e===n}var Bs=rle;function ole(e,t){return function(n){return e(t(n))}}var Sp=ole;var sle=Sp(Object.keys,Object),FB=sle;var ile=Object.prototype,ale=ile.hasOwnProperty;function dle(e){if(!Bs(e))return FB(e);var t=[];for(var n in Object(e))ale.call(e,n)&&n!="constructor"&&t.push(n);return t}var jB=dle;function cle(e){return e!=null&&Ap(e.length)&&!lp(e)}var bp=cle;function ule(e){return bp(e)?vp(e):jB(e)}var Gs=ule;function ple(e){return hp(e,Gs,Ms)}var VB=ple;var lle=$e(_e,"DataView"),Ip=lle;var fle=$e(_e,"Promise"),_p=fle;var mle=$e(_e,"Set"),Rp=mle;var hle=$e(_e,"WeakMap"),Ep=hle;var HB="[object Map]",gle="[object Object]",YB="[object Promise]",KB="[object Set]",XB="[object WeakMap]",$B="[object DataView]",yle=Bn(Ip),Ale=Bn(yr),vle=Bn(_p),Sle=Bn(Rp),ble=Bn(Ep),lo=Ln;(Ip&&lo(new Ip(new ArrayBuffer(1)))!=$B||yr&&lo(new yr)!=HB||_p&&lo(_p.resolve())!=YB||Rp&&lo(new Rp)!=KB||Ep&&lo(new Ep)!=XB)&&(lo=function(e){var t=Ln(e),n=t==gle?e.constructor:void 0,r=n?Bn(n):"";if(r)switch(r){case yle:return $B;case Ale:return HB;case vle:return YB;case Sle:return KB;case ble:return XB}return t});var Us=lo;function Ile(e,t){for(var n=-1,r=e==null?0:e.length;++n<r&&t(e[n],n,e)!==!1;);return e}var WB=Ile;var _le=function(){try{var e=$e(Object,"defineProperty");return e({},"",{}),e}catch{}}(),by=_le;function Rle(e,t,n){t=="__proto__"&&by?by(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}var Cp=Rle;var Ele=Object.prototype,Cle=Ele.hasOwnProperty;function Ple(e,t,n){var r=e[t];(!(Cle.call(e,t)&&up(r,n))||n===void 0&&!(t in e))&&Cp(e,t,n)}var Pp=Ple;function xle(e,t,n,r){var o=!n;n||(n={});for(var s=-1,i=t.length;++s<i;){var a=t[s],d=r?r(n[a],e[a],a,n,e):void 0;d===void 0&&(d=e[a]),o?Cp(n,a,d):Pp(n,a,d)}return n}var vr=xle;function Tle(e,t){return e&&vr(t,Gs(t),e)}var QB=Tle;function Nle(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}var JB=Nle;var wle=Object.prototype,Ole=wle.hasOwnProperty;function Dle(e){if(!cn(e))return JB(e);var t=Bs(e),n=[];for(var r in e)r=="constructor"&&(t||!Ole.call(e,r))||n.push(r);return n}var ZB=Dle;function kle(e){return bp(e)?vp(e,!0):ZB(e)}var zs=kle;function Mle(e,t){return e&&vr(t,zs(t),e)}var eG=Mle;var oG=typeof exports=="object"&&exports&&!exports.nodeType&&exports,tG=oG&&typeof module=="object"&&module&&!module.nodeType&&module,Lle=tG&&tG.exports===oG,nG=Lle?_e.Buffer:void 0,rG=nG?nG.allocUnsafe:void 0;function Ble(e,t){if(t)return e.slice();var n=e.length,r=rG?rG(n):new e.constructor(n);return e.copy(r),r}var sG=Ble;function Gle(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}var iG=Gle;function Ule(e,t){return vr(e,Ms(e),t)}var aG=Ule;var zle=Sp(Object.getPrototypeOf,Object),xp=zle;var qle=Object.getOwnPropertySymbols,Fle=qle?function(e){for(var t=[];e;)mp(t,Ms(e)),e=xp(e);return t}:gp,Tp=Fle;function jle(e,t){return vr(e,Tp(e),t)}var dG=jle;function Vle(e){return hp(e,zs,Tp)}var cG=Vle;var Hle=Object.prototype,Yle=Hle.hasOwnProperty;function Kle(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]=="string"&&Yle.call(e,"index")&&(n.index=e.index,n.input=e.input),n}var uG=Kle;function Xle(e){var t=new e.constructor(e.byteLength);return new Ay(t).set(new Ay(e)),t}var qs=Xle;function $le(e,t){var n=t?qs(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}var pG=$le;var Wle=/\w*$/;function Qle(e){var t=new e.constructor(e.source,Wle.exec(e));return t.lastIndex=e.lastIndex,t}var lG=Qle;var fG=Mn?Mn.prototype:void 0,mG=fG?fG.valueOf:void 0;function Jle(e){return mG?Object(mG.call(e)):{}}var hG=Jle;function Zle(e,t){var n=t?qs(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}var gG=Zle;var efe="[object Boolean]",tfe="[object Date]",nfe="[object Map]",rfe="[object Number]",ofe="[object RegExp]",sfe="[object Set]",ife="[object String]",afe="[object Symbol]",dfe="[object ArrayBuffer]",cfe="[object DataView]",ufe="[object Float32Array]",pfe="[object Float64Array]",lfe="[object Int8Array]",ffe="[object Int16Array]",mfe="[object Int32Array]",hfe="[object Uint8Array]",gfe="[object Uint8ClampedArray]",yfe="[object Uint16Array]",Afe="[object Uint32Array]";function vfe(e,t,n){var r=e.constructor;switch(t){case dfe:return qs(e);case efe:case tfe:return new r(+e);case cfe:return pG(e,n);case ufe:case pfe:case lfe:case ffe:case mfe:case hfe:case gfe:case yfe:case Afe:return gG(e,n);case nfe:return new r;case rfe:case ife:return new r(e);case ofe:return lG(e);case sfe:return new r;case afe:return hG(e)}}var yG=vfe;var AG=Object.create,Sfe=function(){function e(){}return function(t){if(!cn(t))return{};if(AG)return AG(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}(),vG=Sfe;function bfe(e){return typeof e.constructor=="function"&&!Bs(e)?vG(xp(e)):{}}var SG=bfe;var Ife="[object Map]";function _fe(e){return un(e)&&Us(e)==Ife}var bG=_fe;var IG=Un&&Un.isMap,Rfe=IG?Ls(IG):bG,_G=Rfe;var Efe="[object Set]";function Cfe(e){return un(e)&&Us(e)==Efe}var RG=Cfe;var EG=Un&&Un.isSet,Pfe=EG?Ls(EG):RG,CG=Pfe;var xfe=1,Tfe=2,Nfe=4,PG="[object Arguments]",wfe="[object Array]",Ofe="[object Boolean]",Dfe="[object Date]",kfe="[object Error]",xG="[object Function]",Mfe="[object GeneratorFunction]",Lfe="[object Map]",Bfe="[object Number]",TG="[object Object]",Gfe="[object RegExp]",Ufe="[object Set]",zfe="[object String]",qfe="[object Symbol]",Ffe="[object WeakMap]",jfe="[object ArrayBuffer]",Vfe="[object DataView]",Hfe="[object Float32Array]",Yfe="[object Float64Array]",Kfe="[object Int8Array]",Xfe="[object Int16Array]",$fe="[object Int32Array]",Wfe="[object Uint8Array]",Qfe="[object Uint8ClampedArray]",Jfe="[object Uint16Array]",Zfe="[object Uint32Array]",de={};de[PG]=de[wfe]=de[jfe]=de[Vfe]=de[Ofe]=de[Dfe]=de[Hfe]=de[Yfe]=de[Kfe]=de[Xfe]=de[$fe]=de[Lfe]=de[Bfe]=de[TG]=de[Gfe]=de[Ufe]=de[zfe]=de[qfe]=de[Wfe]=de[Qfe]=de[Jfe]=de[Zfe]=!0;de[kfe]=de[xG]=de[Ffe]=!1;function Np(e,t,n,r,o,s){var i,a=t&xfe,d=t&Tfe,c=t&Nfe;if(n&&(i=o?n(e,r,o,s):n(e)),i!==void 0)return i;if(!cn(e))return e;var u=ks(e);if(u){if(i=uG(e),!a)return iG(e,i)}else{var p=Us(e),l=p==xG||p==Mfe;if(yp(e))return sG(e,a);if(p==TG||p==PG||l&&!o){if(i=d||l?{}:SG(e),!a)return d?dG(e,eG(i,e)):aG(e,QB(i,e))}else{if(!de[p])return o?e:{};i=yG(e,p,a)}}s||(s=new PB);var f=s.get(e);if(f)return f;s.set(e,i),CG(e)?e.forEach(function(g){i.add(Np(g,t,n,g,e,s))}):_G(e)&&e.forEach(function(g,y){i.set(y,Np(g,t,n,y,e,s))});var h=c?d?cG:VB:d?zs:Gs,m=u?void 0:h(e);return WB(m||e,function(g,y){m&&(y=g,g=e[y]),Pp(i,y,Np(g,t,n,y,e,s))}),i}var NG=Np;var eme=1,tme=4;function nme(e){return NG(e,eme|tme)}var wG=nme;function OG(e,t,n=!1){if(e&&typeof e=="object")for(let r of Object.keys(e)){let o=t(r),s=e[r];o!==r&&(e[o]=s,delete e[r]),s===null&&n&&(e[o]=void 0),OG(e[o],t,n)}return e}var DG=(e,t,n=!0)=>OG(n?wG(e):e,t??rme,!0);function rme(e){return e.replace(/_([a-z])/g,(t,n)=>n.toUpperCase())}function kt(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function fo(e){return typeof e=="string"&&e.trim()?e:void 0}function ome(e){var r;let t=e.replace(/_([a-zA-Z0-9])/g,(o,s)=>s.toUpperCase()),n=t&&`${(r=t[0])==null?void 0:r.toLowerCase()}${t.slice(1)}`;return Array.from(new Set([e,t,n]))}function MG(e,t){for(let n of ome(t))if(n in e)return e[n]}function sme(e){if(kt(e))return fo(e.id)??fo(e.pippitAssetId)??fo(e.pippit_asset_id)??fo(e.PippitAssetID)}function ime(e,t){return(fo(e.type)??fo(t.type)??fo(t.Type))==="canvas"&&(t.content!==void 0||t.Content!==void 0)}function kG(e,t,n,r){let o=kt(e[n])?e[n]:kt(e[r])?e[r]:null,s=kt(t[r])?t[r]:kt(t[n])?t[n]:null;if(!o||!s)return;let i={};for(let a of Object.keys(s))i[a]=MG(o,a)??s[a];e[n]=i}function Iy(e,t,n,r){let o=kt(e[n])?e[n]:null,s=kt(t[n])?t[n]:null;if(!o||!s)return;let i=new Map;for(let d of Object.values(o)){let c=sme(d);c&&i.set(c,d)}let a={};for(let d of Object.keys(s)){let c=MG(o,d)??i.get(d)??s[d];r(c,s[d]),a[d]=c}e[n]=a}function ame(e,t,n){for(let r of["document","canvasDocument","canvas_document","snapshot","data","content","payload","value"]){let o=e[r],s=t[r];kt(o)&&kt(s)&&n(o,s)}}function Qa(e,t){if(!(!kt(e)||!kt(t))){if(ime(e,t)){let n=t.content??t.Content;n!==void 0&&(e.content=n);return}Iy(e,t,"assets",Qa),Iy(e,t,"nodes",Qa),Iy(e,t,"edges",Qa),kG(e,t,"assetVersions","asset_versions"),kG(e,t,"currentAssetVersions","current_asset_versions"),ame(e,t,Qa)}}function LG(e){let t=DG(e);return Qa(t,e),t}function BG(e){return LG(e)}var GG=(e,t=!0)=>{if(!e)return null;try{let n=JSON.parse(e);return t?BG(n):n}catch{return e}},Ja=e=>({mediaType:"text",pippitAssetId:e}),Ry=e=>e==null?void 0:e.version,dme=e=>Object.fromEntries(e),cme=e=>[...e.repairPatches??[],...e.layoutPatches??[]],_y=(e,t)=>e.op==="add"&&e.path===""?0:t.get(e.assetId),ume=async(e,t,n,r)=>{let o=[...new Set(t.filter(i=>_y(i,n)===void 0).map(i=>i.assetId))];if(!o.length)return;let s=new Set(o);try{(await e.assets.queryAssets(o.map(Ja),{cachePolicy:"refresh",dispatchMode:"immediate",signal:r})).forEach(({asset:a,ref:d})=>{let c=Ry(a),u=d.pippitAssetId;u&&s.has(u)&&c!==void 0&&n.set(u,c)})}catch(i){Xe.error("[xyq-canvas-sdk:restore] failed to refresh restore patch asset versions",i,{assetIds:o})}},pme=async(e,t,n,r)=>{var d;let o=cme(t);if(!o.length)return;await ume(e,o,n,r);let s=o.filter(c=>_y(c,n)===void 0);s.length&&Xe.error("[xyq-canvas-sdk:restore] skipped restore patches without base asset versions",{assetIds:[...new Set(s.map(c=>c.assetId))],canvasAssetId:t.canvasAssetId,patchCount:s.length});let i=o.flatMap(c=>{let u=_y(c,n);return u===void 0?[]:[{baseVersion:u,op:c.op,path:c.path,ref:Ja(c.assetId),...c.op==="remove"?{}:{value:c.value}}]});if(!i.length)return;let a=await e.assets.patchAssets({intent:(d=t.repairPatches)!=null&&d.length?"restore.repairDocument":"restore.repairLayout",patches:i,refresh:!1,rootRef:Ja(t.canvasAssetId),transactionId:`restore_${t.canvasAssetId}_${Date.now()}`});Object.entries(a.versions??{}).forEach(([c,u])=>n.set(c,u))},lme=({client:e,onAssetVersion:t,preloadedAssets:n})=>{let r=async({pippitAssetIds:s,isCamelCase:i=!0,signal:a},d)=>{let c=s.filter(f=>!(n!=null&&n.has(f))),[u,p]=await Promise.all([c.length>0?e.assets.queryAssets(c.map(Ja),d?{dispatchMode:d,signal:a}:{signal:a}):Promise.resolve([]),Promise.all(s.filter(f=>n==null?void 0:n.has(f)).map(async f=>[f,await(n==null?void 0:n.get(f))]))]),l=new Map;return u.forEach(({asset:f,ref:h})=>{l.set(h.pippitAssetId,f)}),p.forEach(([f,h])=>{l.set(f,h??null)}),s.map(f=>{var g;let h=l.get(f)??null,m=Ry(h);return m!==void 0&&(t==null||t(f,m)),{extra:(h==null?void 0:h.extra)??null,pippitAssetId:f,value:GG((g=h==null?void 0:h.text)==null?void 0:g.content,i)}})},o=s=>r(s);return o.queryImmediately=s=>r(s,"immediate"),o},fme=async(e,t)=>{var i;let n=Ry(t),r=GG((i=t==null?void 0:t.text)==null?void 0:i.content);if(r===null)return{asset:null,assetId:e.assetId,...n===void 0?{}:{assetVersion:n}};if(e.assetKind==="canvas"){let a=await cp(r,{canvasAssetId:e.assetId});return{asset:(a==null?void 0:a.assets[e.assetId])??null,assetId:e.assetId,...n===void 0?{}:{assetVersion:n}}}let o=ap(r,{nodeAssetId:e.assetId,nodeType:e.nodeType});return{asset:o?{...o,assetExtra:(t==null?void 0:t.extra)??null}:null,assetId:e.assetId,...n===void 0?{}:{assetVersion:n}}};function UG({client:e,enableCoverAssetPrefetch:t=!1,initialRootAsset:n,onRestoreEvent:r,onRestoreResult:o,resolvePriorityNodeAssetIds:s}){let i=n,a=t?async({pippitAssetIds:d,signal:c})=>{await e.assets.queryAssets(d.map(u=>({pippitAssetId:u})),{batchingStrategy:"max-size",dispatchMode:"immediate",signal:c})}:void 0;return{async fetchSnapshot({scopeAssetId:d,signal:c,onProgress:u}){let p=i;i=void 0;let l=new Map,f=await WL(d,{debugLog:!1,onEvent:r,prefetchCoverAssets:a,onRootDocumentReady:h=>{u==null||u({kind:"root-ready",document:h})},onNodeAssetsReady:({document:h,readyNodeAssetIds:m})=>{u==null||u({kind:"assets-ready",document:h,readyAssetIds:m})},queryTextAssetContent:lme({client:e,onAssetVersion:(h,m)=>l.set(h,m),preloadedAssets:p?new Map([[d,p]]):void 0}),resolvePriorityNodeAssetIds:s,signal:c});return await pme(e,f,l,c),o==null||o(f),{assetVersions:dme(l),state:f.document}},async fetchAssets({requests:d,signal:c}){let u=await e.assets.queryAssets(d.map(({assetId:f})=>Ja(f)),{signal:c}),p=await Promise.all(d.map((f,h)=>{var m;return fme(f,((m=u[h])==null?void 0:m.asset)??null)})),l={};return u.forEach(({asset:f},h)=>{(f==null?void 0:f.version)!==void 0&&(l[d[h].assetId]=f.version)}),{assets:p,assetVersions:l}}}}var mme=["9:16","16:9","21:9","3:4","4:3","1:1"],hme={"9:16":{w:236,h:420},"16:9":{w:420,h:236},"21:9":{w:420,h:180},"3:4":{w:315,h:420},"4:3":{w:420,h:315},"1:1":{w:360,h:360}},gme={"9:16":"9:16","16:9":"16:9","21:9":"21:9","3:4":"3:4","4:3":"4:3","1:1":"1:1"},yme={"9:16":{width:9,height:16},"16:9":{width:16,height:9},"21:9":{width:21,height:9},"3:4":{width:3,height:4},"4:3":{width:4,height:3},"1:1":{width:1,height:1}};function qG(e){return mme.includes(e)}function Ame(e){return gme[e]}function FG(e){return hme[e]}function jG(e){return(e==null?void 0:e.type)===he||(e==null?void 0:e.type)===L||(e==null?void 0:e.type)===me||(e==null?void 0:e.type)===M}function VG(e){return(e==null?void 0:e.type)===L||(e==null?void 0:e.type)===me||(e==null?void 0:e.type)===M}function zG(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function vme(e){return"metadata"in e||"naturalWidth"in e||"caption"in e}function Sme(e){return"playback"in e||"frameWidth"in e||"durationMs"in e||"title"in e}function HG(e,t){let n=e,r=Ame(t),o=yme[t],s={...n,generation:{...zG(n.generation)?n.generation:{},ratio:r}},i=Sme(n);return!i&&vme(n)&&(s.metadata={...zG(n.metadata)?n.metadata:{},ratio:r}),i&&(s.ratio=o),s}function YG(){return O.t("Pippit_xyqcanvas_legacy_label_unnamed_role",{},"未命名角色")}function Op(e,t){let n=q_(t);return n.length>0?{...e,episodes:n}:e}function KG(e,t,n={}){return Op({nodeName:e,order:t,basicInfo:{name:e,...n.defaultAppearanceName?{appearanceName:n.defaultAppearanceName}:{}}},n.defaultEpisodeIds)}var bme={text:{type:Qn.type,createNodeData:()=>({}),createAsset:e=>wp(e,Qn.type,{plainText:"",placeholder:O.t("Pippit_xyqcanvas_legacy_label_text",{},"文本"),block:{verticalAlign:"top",overflow:"wrap",padding:Z_.padding}}),getDefaultSize:e=>{var t,n;return((n=(t=Qn).getDefaultSize)==null?void 0:n.call(t,e))??{w:420,h:180}}},image:{type:En.type,createNodeData:()=>({}),createAsset:(e,t,n)=>wp(e,En.type,Op(Ey({caption:O.t("Pippit_xyqcanvas_legacy_label_picture",{},"图片")},n==null?void 0:n.defaultVideoRatio),n==null?void 0:n.defaultEpisodeIds)),getDefaultSize:e=>{var t,n;return((n=(t=En).getDefaultSize)==null?void 0:n.call(t,e))??{w:480,h:373}}},video:{type:Cn.type,createNodeData:()=>({}),createAsset:(e,t,n)=>wp(e,Cn.type,Op(Ey({title:O.t("Pippit_xyqcanvas_legacy_title_video",{},"视频"),caption:O.t("Pippit_xyqcanvas_legacy_title_video",{},"视频"),playback:{muted:!0}},n==null?void 0:n.defaultVideoRatio),n==null?void 0:n.defaultEpisodeIds)),getDefaultSize:e=>{var t,n;return((n=(t=Cn).getDefaultSize)==null?void 0:n.call(t,e))??{w:480,h:270}}},audio:{type:Wn.type,createNodeData:()=>({}),createAsset:(e,t,n)=>wp(e,Wn.type,Op({},n==null?void 0:n.defaultEpisodeIds)),getDefaultSize:e=>{var t,n;return((n=(t=Wn).getDefaultSize)==null?void 0:n.call(t,e))??{w:362,h:218}}},role:{type:Vr.type,createNodeData:()=>({name:YG()}),createAsset:(e,t,n)=>({pippitAssetId:e,type:pm,content:KG(YG(),t,{defaultAppearanceName:I_(),defaultEpisodeIds:n==null?void 0:n.defaultEpisodeIds}),extra:{}}),getDefaultSize:e=>Vr.getDefaultSize(e)},scene:{type:Ki.type,createNodeData:()=>({name:um()}),createAsset:(e,t,n)=>({pippitAssetId:e,type:Am,content:Ey(KG(um(),t,{defaultEpisodeIds:n==null?void 0:n.defaultEpisodeIds}),n==null?void 0:n.defaultVideoRatio),extra:{}}),getDefaultSize:e=>{var t,n;return((n=(t=Ki).getDefaultSize)==null?void 0:n.call(t,e))??{...Yr}}},scene3d:{type:ca.type,createNodeData:()=>({title:oh()}),createAsset:(e,t,n)=>{let r=sh(),o=n==null?void 0:n.initialData;return EE({document:o&&Object.keys(o).length>0?{...r,...o}:r,documentAssetId:n==null?void 0:n.scene3DDocumentAssetId,nodeId:e})},getDefaultSize:e=>{var t,n;return((n=(t=ca).getDefaultSize)==null?void 0:n.call(t,e))??{w:420,h:236}}}};function wp(e,t,n){return{pippitAssetId:e,type:t,content:n,extra:{}}}function Ey(e,t){return t?HG(e,t):e}function XG(e,t){if(!t||Object.keys(t).length===0)return e;let n=e.content&&typeof e.content=="object"&&!Array.isArray(e.content)?e.content:{};return{...e,content:{...n,...t}}}function Ime(e){return Array.isArray(e)?e:[e]}function _me({defaultSize:e,initialSize:t}){let n=t.w>0&&t.h>0?t.w/t.h:void 0;if(!n)return e;let r=Math.max(1,e.w*e.h);return{w:Math.round(Math.sqrt(r*n)),h:Math.round(Math.sqrt(r/n))}}function $G({kind:e,id:t,center:n,topLeft:r,initialData:o,initialAssetContent:s,initialNodeData:i,order:a=0,existingNodes:d,defaultEpisodeIds:c,defaultEpisodes:u,defaultVideoRatio:p,scene3DDocumentAssetId:l}){let f=bme[e],h=f.createNodeData(t),m=i?{...h,...i}:h,g=!!(o&&Object.keys(o).length>0),y=g?{...m,...o}:m,v=p&&!g&&VG({type:f.type}),S=p&&jG({type:f.type}),b=v?FG(p):g&&(e==="image"||e==="video")?_me({defaultSize:f.getDefaultSize(m),initialSize:f.getDefaultSize(y)}):f.getDefaultSize(y),I=r??wS({center:n??{x:0,y:0},size:b,existingNodes:d}),N=Ime(f.createAsset(t,a,{defaultEpisodeIds:c??u,defaultVideoRatio:S?p:void 0,initialData:o,scene3DDocumentAssetId:l})),w=N[0],ne=e==="scene3d"||!w?N:[XG(XG(w,o),s),...N.slice(1)];return{node:{id:t,type:f.type,x:I.x,y:I.y,w:b.w,h:b.h,parentId:null,order:a,data:m},assets:ne}}var Cy=[...Uc.filter(({kind:e})=>e!=="invoke_command"),{get description(){return O.t("Pippit_xyqcanvas_command_desc_createbusinessnode",{},"使用小云雀现有业务工厂创建文字、图片、视频、音频、角色、场景或 3D 导演台节点")},input:"{nodeKind, id?, topLeft?, center?, order?, initialData?, defaultEpisodeIds?, defaultVideoRatio?}",kind:"create_biz_node"}],Py=[{get description(){return O.t("Pippit_xyqcanvas_command_desc_updaterolefields",{},"更新角色名称、描述、集数、音色或配音字段")},input:"{nodeId, assetId, field, value}",name:nh},{get description(){return O.t("Pippit_xyqcanvas_command_desc_updateroleappearance",{},"更新角色外观主图、描述和音色信息")},input:"{nodeId, assetId, patch}",name:aa},{get description(){return O.t("Pippit_xyqcanvas_command_desc_updaterolereferenceimages",{},"更新角色参考图来源列表")},input:"{nodeId, assetId, operation}",name:da},{get description(){return O.t("Pippit_xyqcanvas_command_desc_updatescenefields",{},"更新场景名称、场景视图、描述或集数字段")},input:"{nodeId, assetId, field, value}",name:ch}],Rme=new Set(Py.map(({name:e})=>e));function Eme(e){return!!(e&&typeof e=="object"&&"kind"in e&&e.kind==="invoke_command")}function Cme(e){let t=e.filter(Eme);if(t.length===0)return;if(e.length!==1||t.length!==1)throw new Error("Registered business commands must run as a single mutation");let[{name:n}]=t;if(!Rme.has(n))throw new Error(`Unsupported registered business command: ${n}`)}function Pme(e){return e.kind==="create_biz_node"}async function xme(e,t){let n=[];for(let r of e.mutations){if(!Pme(r)){n.push(r);continue}let o=r.id??(t?await t(r):void 0);if(!o)throw new Error("create_biz_node requires id when allocateNodeId is not configured");let s=r.defaultVideoRatio===void 0?void 0:qG(r.defaultVideoRatio)?r.defaultVideoRatio:void 0;if(r.defaultVideoRatio!==void 0&&s===void 0)throw new Error(`Invalid defaultVideoRatio: ${String(r.defaultVideoRatio)}`);let{assets:i,node:a}=$G({defaultEpisodeIds:r.defaultEpisodeIds??r.defaultEpisodes,defaultVideoRatio:s,existingNodes:e.runtime.store.getRootCanvasContent().nodes,id:o,initialData:r.initialData,kind:r.nodeKind,order:r.order,topLeft:r.topLeft,center:r.center});n.push({assets:i,autoCreateNodeAsset:!1,kind:"create_node",node:a})}return n}function WG(e){var s;let t=l_({...e,mutationHandler:async i=>(Cme(i.mutations),Ei({...i,mutations:await xme(i,e.allocateNodeId)}))}),n=Cy.map(({kind:i})=>i).join(", "),r=`Canvas mutations: ${n}. Use apply_patches only for privileged patch-level changes.`,o=t.apply_mutations.args.mutations;return{...t,apply_mutations:{...t.apply_mutations,args:{...t.apply_mutations.args,mutations:((s=o.describe)==null?void 0:s.call(o,r))??o},description:`${t.apply_mutations.description} Supported mutation kinds: ${n}.`}}}0&&(module.exports={XYQ_CANVAS_OPENCODE_MUTATION_DEFINITIONS,XYQ_CANVAS_REGISTERED_COMMAND_DEFINITIONS,createPippitAssetRuntime,createPippitAssetSdkCanvasLoader,createPippitAssetServiceTransport,createXyqCanvasCommandRuntime,createXyqCanvasOpencodeToolDefinitions});
16
+ `))}}function ho(e){if(!loe(e)||!moe(e.contentFormat))return{changed:!1,data:e};let t=foe(e),n={...e};if(delete n.contentFormat,t===void 0)return{changed:!0,data:n};let r=Ioe(t),i=Rc(r);return{changed:!0,data:{...n,content:r,markdownText:typeof n.markdownText=="string"?n.markdownText:t,plainText:i}}}var Jh="text.normalizeMarkdownContent";function zC(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function voe(e){let t=M(e),n=!1;return Object.entries(t.nodes).forEach(([r,i])=>{if(i.type!==et||!zC(i.data))return;let o=ho(i.data);o.changed&&(i.data=o.data,n=!0)}),Object.entries(e.assets).forEach(([r,i])=>{var s;if(!zC(i)||!zC(i.content)||(typeof i.type=="string"?i.type:(s=t.nodes[r])==null?void 0:s.type)!==et)return;let a=ho(i.content);a.changed&&(i.content=a.data,n=!0)}),n}function xoe(e){e.transact(t=>{voe(t)},{intent:Jh,undoable:!1,source:"local"})}function D0(e){return e.subscribe(({transaction:t})=>{t.intent!==Jh&&xoe(e)})}function Roe(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function E0(e,t,n="media.localUploadTask.clear",r={}){return e.transact(i=>{let o=i.assets[t],a=Roe(o==null?void 0:o.content)?o.content:void 0;!a||!Object.prototype.hasOwnProperty.call(a,"localUploadTask")||delete a.localUploadTask},{intent:n,mergeKey:`local-upload-task:${t}`,...r.system?{source:"system",undoable:!1}:{}})}var M0="role-scene",a7e=[M0,...Ks];function Poe(e){return e===M0||ha(e)}function N0(e){var n;let t=(n=M(e).settings.autoLayout)==null?void 0:n.strategy;return typeof t=="string"&&t.trim()||void 0}function w0({configuredStrategies:e,storedStrategy:t}){if(e!=null&&e.length)return Poe(t)&&e.includes(t)?t:e[0]}var Doe="canvas is read-only";function k0(e){return(t,n)=>{if(t.source==="remote"||t.intent===Jh||t.intent===jh||t.intent===$h){n();return}throw t.source==="local"&&(e==null||e()),new We(Doe,"READ_ONLY")}}function O0(e,t){let n=N0(e.getState()),r=w0({configuredStrategies:t,storedStrategy:n});!r||n===r||e.transact(i=>{let{settings:o}=M(i);o.autoLayout={...o.autoLayout,strategy:r}},{intent:"settings.normalizeAutoLayoutStrategy",undoable:!1})}function L0(e,t=!1){return Object.values(M(e).nodes).some(n=>{var o;if(n.type===Z||n.type===Oe)return t&&nC(vc(e.assets[n.id]),"image");let r;if(n.type===ee?r="image":n.type===J?r="video":n.type===fe&&(r="audio"),!r)return!1;let i=(o=Zm(e,n))==null?void 0:o.data;return nC(i==null?void 0:i.localUploadTask,r)})}function F0(e,t){var n,r;for(let i of Object.values(M(e).nodes)){if(i.type!==ee)continue;let o=(r=(n=Zm(e,i))==null?void 0:n.data)==null?void 0:r.localUploadTask;en(o,"image")&&o.status==="capturing"&&!o.cacheId&&E0(t,i.id,"image.upload.clearRestoredCapturingTask")}}var G0="biz/auto-layout";function B0(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:void 0}function Eoe(e){let t={};if(!e)return t;ha(e.strategy)&&(t.strategy=e.strategy);let n=B0(e.horizontalGap);n!==void 0&&(t.horizontalGap=n);let r=B0(e.verticalGap);return r!==void 0&&(t.verticalGap=r),t}var UC={type:G0,run:e=>{e.commands.autoLayoutNodes(Eoe(e.directive.params))}};var z0="biz/layout-group",Moe="horizontal-directed-cluster",Noe=["horizontal","vertical","grid","horizontal-directed-cluster","vertical-directed-cluster"];function woe(e){return Noe.includes(e)?e:void 0}function koe(e){return e==="vertical-directed-cluster"||e==="horizontal-directed-cluster"?e:Moe}var VC={type:z0,run:e=>{var r,i;if(e.carrier.kind!=="node")return;let t=e.store.getRootCanvasContent().nodes[e.carrier.nodeId];if((t==null?void 0:t.type)!==Ze)return;let n=woe((r=e.directive.params)==null?void 0:r.strategy)??koe((i=e.store.getRootCanvasContent().settings.autoLayout)==null?void 0:i.strategy);e.commands.arrangeNodes([e.carrier.nodeId],n)}};var V0="biz/resize-node";function U0(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:void 0}var qC={type:V0,run:e=>{if(e.carrier.kind!=="node")return;let t=e.directive.params??{},n=U0(t.w),r=U0(t.h);n===void 0||r===void 0||e.commands.resizeNode(e.carrier.nodeId,{w:n,h:r})}};var q0=oS(),Ooe=[UC,qC,VC];for(let e of Ooe)q0.register(e);function KC(){return q0}function Pc(e){return String(e??"").trim()}function jC(e){return Array.from(new Set(e.map(Pc).filter(Boolean)))}function K0(e,t){let n=tC(e),r=new Set(t.map(Pc).filter(Boolean));return r.size===0?n:n.replace(Ba,(i,o,a,s)=>o==="node-asset"&&r.has(Pc(s))?"":i)}function j0({nextSelectableSelection:e,previousDefaultSelection:t,prompt:n,reference:r,selectionReplacements:i}){let o=new Set(Ic(r));if(!o.size)return{explicitSelection:[],hasRoleMention:!1,prompt:n};let a=Object.fromEntries(Object.entries(i??{}).map(([p,m])=>[Pc(p),Pc(m)]).filter(([p,m])=>p&&p!==m)),s=[],c=!1,d=0,u=[];er.lastIndex=0;for(let p of String(n??"").matchAll(er)){let m=p.index??0;u.push(n.slice(d,m)),d=m+p[0].length;let f=Pc(p[3]);if(p[1]!=="node-asset"||!o.has(f)){u.push(p[0]);continue}c=!0;let h=gc(p);if(!(tp in h)){u.push(p[0]);continue}let g=jC(Qb(h[tp])??[]),y=jC(g.map(_=>a[_]??_));s.push(...y),y.length&&u.push(Eh(f,{...h,[tp]:aO(y)}))}return er.lastIndex=0,u.push(n.slice(d)),{explicitSelection:jC(s),hasRoleMention:c,prompt:u.join("")}}function Loe(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Foe(e){return e===ee||e===J||e===fe}function Boe(e,t){let{nodes:n}=M(e),r=new Set,i=o=>{if(r.has(o))return;let a=n[o];if(!a)return;r.add(o);let{children:s}=a;Array.isArray(s)&&s.forEach(i)};return t.forEach(i),r}function Goe(e,t){let n=M(e),r=Boe(e,t);return r.size===0?[]:Object.values(n.nodes).flatMap(i=>{if(r.has(i.id)||!Foe(i.type))return[];let o=ro(e,i.id),a=Loe(o==null?void 0:o.generation)?o.generation:void 0,s=typeof(a==null?void 0:a.prompt)=="string"?a.prompt:void 0;if(s===void 0)return[];let c=K0(s,[...r]);return c===s?[]:[{generation:{...a,prompt:c},nodeId:i.id}]})}function H0(e){let{deleteNodes:t}=e.commands,n=r=>{let i=Goe(e.getState(),r);return i.length===0?t(r):e.commands.batch("node.delete",o=>{t(r),i.forEach(({generation:a,nodeId:s})=>{o.updateNodeData(s,{generation:a})})})};return e.commands.deleteNodes=n,()=>{e.commands.deleteNodes===n&&(e.commands.deleteNodes=t)}}var Pr=(d=>(d.Auto="auto",d.Landscape16x9="16:9",d.Cinematic21x9="21:9",d.Portrait9x16="9:16",d.Portrait3x4="3:4",d.Landscape4x3="4:3",d.Landscape3x2="3:2",d.Portrait2x3="2:3",d.Square1x1="1:1",d))(Pr||{}),Qh=(a=>(a[a.Landscape16x9=2]="Landscape16x9",a[a.Portrait9x16=3]="Portrait9x16",a[a.Landscape4x3=4]="Landscape4x3",a[a.Portrait3x4=5]="Portrait3x4",a[a.Square1x1=6]="Square1x1",a[a.Cinematic21x9=8]="Cinematic21x9",a))(Qh||{});var zoe="https";var Uoe=["lf-xiaoyunque","jianying","com"],Voe="/obj/pippit-app-buz/pippit_cms";function qoe(...e){return e.filter(Boolean).map(t=>t.replace(/^\/+|\/+$/g,"")).filter(Boolean).join("/")}function Koe(e,t="/"){let n=t.startsWith("/")?t:`/${t}`;return`${zoe}://${e.join(".")}${n}`}function HC(e=""){return Koe(Uoe,qoe(Voe,e))}function Te(e){return{coverImageUrl:HC(`${e}.webp`),previewVideoUrl:HC(`${e}.mp4`)}}var joe={static_shot:Te("01_%E5%9B%BA%E5%AE%9A%E9%95%9C%E5%A4%B4"),tilt_up:Te("02_%E9%95%9C%E5%A4%B4%E4%B8%8A%E6%91%87"),tilt_down:Te("03_%E9%95%9C%E5%A4%B4%E4%B8%8B%E6%91%87"),pan_left:Te("04_%E9%95%9C%E5%A4%B4%E5%B7%A6%E6%91%87"),pan_right:Te("05_%E9%95%9C%E5%A4%B4%E5%8F%B3%E6%91%87"),crane_up:Te("06_%E9%95%9C%E5%A4%B4%E4%B8%8A%E5%8D%87"),crane_down:Te("07_%E9%95%9C%E5%A4%B4%E4%B8%8B%E9%99%8D"),truck_left:Te("08_%E9%95%9C%E5%A4%B4%E5%B7%A6%E7%A7%BB"),truck_right:Te("09_%E9%95%9C%E5%A4%B4%E5%8F%B3%E7%A7%BB"),dolly_in:Te("10_%E9%95%9C%E5%A4%B4%E5%89%8D%E6%8E%A8"),dolly_out:Te("11_%E9%95%9C%E5%A4%B4%E5%90%8E%E7%A7%BB"),zoom_in:Te("12_%E5%8F%98%E7%84%A6%E6%8E%A8%E8%BF%9B"),zoom_out:Te("13_%E5%8F%98%E7%84%A6%E6%8B%89%E8%BF%9C"),follow_tracking:Te("14_%E8%B7%9F%E9%9A%8F%E6%8B%8D%E6%91%84"),leading_tracking:Te("15_%E8%BF%8E%E9%9D%A2%E8%B7%9F%E6%8B%8D"),profile_tracking:Te("16_%E4%BE%A7%E9%9D%A2%E8%B7%9F%E6%8B%8D"),handheld_shot:Te("17_%E6%89%8B%E6%8C%81%E6%8B%8D%E6%91%84"),pov_shot:Te("18_%E7%AC%AC%E4%B8%80%E8%A7%86%E8%A7%92"),steadicam_walkthrough:Te("19_%E7%A8%B3%E5%AE%9A%E5%99%A8%E8%A1%8C%E8%BF%9B"),slider_reveal:Te("20_%E6%A8%AA%E6%BB%91%E6%8F%AD%E7%A4%BA"),foreground_wipe:Te("21_%E5%89%8D%E6%99%AF%E6%93%A6%E8%BF%87"),push_through:Te("22_%E7%A9%BF%E8%B6%8A%E9%95%9C%E5%A4%B4"),whip_pan:Te("23_%E7%94%A9%E6%91%87"),rack_focus:Te("24_%E7%84%A6%E7%82%B9%E8%BD%AC%E7%A7%BB"),crash_zoom:Te("25_%E6%80%A5%E9%80%9F%E5%8F%98%E7%84%A6"),dolly_zoom:Te("26_%E6%9F%AF%E5%85%8B%E5%8F%98%E7%84%A6"),orbit_180:Te("27_%E7%8E%AF%E7%BB%95%E6%8B%8D%E6%91%84"),ascending_orbit:Te("28_%E7%9B%98%E6%97%8B%E6%8A%AC%E5%8D%87"),descending_orbit:Te("29_%E7%9B%98%E6%97%8B%E4%B8%8B%E9%99%8D"),aerial_establishing:Te("30_%E9%AB%98%E7%A9%BA%E8%88%AA%E6%8B%8D"),fpv_flythrough:Te("31_%E7%A9%BF%E8%B6%8A%E6%9C%BA%E8%BF%90%E9%95%9C"),drone_dive:Te("32_%E4%BF%AF%E5%86%B2%E4%B8%8B%E9%99%8D"),pull_away:Te("33_%E6%8B%89%E5%8D%87%E7%A6%BB%E5%9C%BA")};function $0(e){let t=joe[e.id];return t?{...e,url:t.coverImageUrl,previewVideoUrl:t.previewVideoUrl}:e}var J0=["gpt_image_2","AnyDream_2.0","anycook_1_standard","anycook_1_creative","seedream_5.0_pro","ali_midjourney_8_2","NanoPro","Nano2"],Q0=[{value:"auto"},{value:"21:9"},{value:"16:9"},{value:"9:16"},{value:"3:4"},{value:"4:3"},{value:"3:2"},{value:"2:3"},{value:"1:1"}],Z0=[{value:"1K"},{value:"2K"},{value:"3K"},{value:"4K"}],eL=[{value:"3K"},{value:"4K"}],tL=[{value:"1K"},{value:"2K"},{value:"4K"}],Yoe=[{value:"low"},{value:"medium"},{value:"high"}];function Xoe(e=typeof IS_US<"u"&&IS_US){return[{value:"1K"},...e?[]:[{value:"1.5K"}],{value:"2K"},{value:"4K"}]}function Woe(e=typeof IS_US<"u"&&IS_US){return e?"1K":"1.5K"}var Joe=Xoe(),Qoe=[{value:"1K"},{value:"2K"}],yp={aspectRatio:Q0,resolution:Z0},Y0={...yp,resolution:eL},Zoe={resolution:eL},X0={...yp,resolution:tL},eae={...yp,resolution:tL,effort:Yoe},tae={...yp,resolution:Joe},nae={...yp,resolution:Qoe},Dc={aspectRatio:"9:16",resolution:"3K"},rae={resolution:"3K"},W0={...Dc,resolution:"2K"},iae={...Dc,resolution:"1K",effort:"low"},oae={...Dc,resolution:Woe()},aae={...Dc,resolution:"1K"},sae={maxImageReferences:10},Ka=["text_to_image","image_to_image"],cae=["image_to_image"],nL=[{modelId:"AnyDream_2.0",modelKind:"image",modes:Ka,defaultMode:"text_to_image",settingOptions:Y0,defaultSettings:Dc},{modelId:"gpt_image_2",modelKind:"image",modes:Ka,defaultMode:"text_to_image",settingOptions:eae,defaultSettings:iae},{modelId:"anycook_1_standard",modelKind:"image",modes:Ka,defaultMode:"text_to_image",settingOptions:Y0,defaultSettings:Dc},{modelId:"anycook_1_creative",modelKind:"image",modes:cae,defaultMode:"image_to_image",settingOptions:Zoe,defaultSettings:rae,referenceLimits:{minImageReferences:1}},{modelId:"seedream_5.0_pro",modelKind:"image",modes:Ka,defaultMode:"text_to_image",referenceLimits:sae,settingOptions:tae,defaultSettings:oae},{modelId:"ali_midjourney_8_2",modelKind:"image",modes:Ka,defaultMode:"text_to_image",settingOptions:nae,defaultSettings:aae},{modelId:"NanoPro",modelKind:"image",modes:Ka,defaultMode:"text_to_image",settingOptions:X0,defaultSettings:W0},{modelId:"Nano2",modelKind:"image",modes:Ka,defaultMode:"text_to_image",settingOptions:X0,defaultSettings:W0}];var dae=[{value:"480p"},{value:"720p"},{value:"1080p"}],uae=[{value:"auto"},{value:"16:9"},{value:"4:3"},{value:"1:1"},{value:"3:4"},{value:"9:16"}];function pae(e,t){return{...e,aspectRatio:uae,resolution:dae,durationSec:t}}function lae(e){return{...e,aspectRatio:"auto",resolution:"720p",durationSec:10}}function oL({durationOptions:e,modes:t,standardVideoDefaultSettings:n,standardVideoSettings:r}){return{modelId:"wan3.0",modelKind:"video",modes:t,defaultMode:"text_to_video",referenceLimits:{maxImageReferences:10},settingOptions:pae(r,e),defaultSettings:lae(n)}}var fae=[{value:"auto"},{value:"16:9"},{value:"9:16"},{value:"4:3"},{value:"3:4"},{value:"1:1"}],hae=[{value:"480p"},{value:"768p"}],gae=[{value:5},{value:6},{value:7},{value:8},{value:9},{value:10},{value:11},{value:12},{value:13},{value:14},{value:15}],yae={aspectRatio:fae,resolution:hae,durationSec:gae,soundEffectEnabled:[{value:!1},{value:!0}]},_ae={aspectRatio:"auto",resolution:"768p",durationSec:10,soundEffectEnabled:!1},aL={modelId:"MiniMax-H3-Max",modelKind:"video",modes:["text_to_video","first_last_frame"],defaultMode:"text_to_video",controlsByMode:{text_to_video:[],first_last_frame:[]},referenceLimits:{maxImageReferences:2,minImageReferences:2},settingOptions:yae,defaultSettings:_ae};var Sae={auto:void 0,"16:9":2,"21:9":8,"9:16":3,"3:4":5,"4:3":4,"3:2":void 0,"2:3":void 0,"1:1":6},YC={2:"16:9",8:"21:9",3:"9:16",4:"4:3",5:"3:4",6:"1:1"},bae=["seedance_1.0","seedance1.5_direct","Seedance_2.0_mini_lite","Seedance_2.0_lite","seedance2.0_direct","seedance2.0_fast_direct","seedance2.0_vision","seedance2.0_fast_vision","Seedance_2.5","MiniMax-H3","MiniMax-H3-Max","wan3.0","happyhorse-1.1"],Cae=[{value:"auto"},{value:"16:9"},{value:"21:9"},{value:"9:16"},{value:"4:3"},{value:"3:4"},{value:"1:1"}],Aae=[{value:"480p"},{value:"720p_lite"},{value:"720p"}],Iae=[{value:"480p"},{value:"720p"},{value:"1080p"},{value:"4k"}],vae=[{value:"480p"},{value:"720p"},{value:"1080p"},{value:"4k"}],xae=[{value:"768p"},{value:"2k"}],Rae=[{value:"720p"},{value:"1080p"}],XC=[{value:4},{value:5},{value:6},{value:7},{value:8},{value:9},{value:10},{value:11},{value:12},{value:13},{value:14},{value:15}],Pae=[{value:3},...XC],cL=[...XC,{value:16},{value:17},{value:18},{value:19},{value:20},{value:21},{value:22},{value:23},{value:24},{value:25},{value:26},{value:27},{value:28},{value:29},{value:30}],Dae=[{value:!1},{value:!0}];var Eae=[{id:"static_shot",label:"固定镜头",promptValue:"固定镜头",tag:"基础控制",desc:"建立冷静秩序",submitPromptText:"运镜:固定机位,镜头位置和拍摄方向都保持不变,画面构图稳定,由主体动作或画面内部变化形成运动感。"},{id:"tilt_up",label:"镜头上摇",promptValue:"镜头上摇",tag:"基础控制",desc:"展示高度威压",submitPromptText:"运镜:固定机位上摇,镜头位置不移动,只沿垂直方向缓慢向上转动,画面重心从下方逐步移向上方。"},{id:"tilt_down",label:"镜头下摇",promptValue:"镜头下摇",tag:"基础控制",desc:"从环境落到人",submitPromptText:"运镜:固定机位下摇,镜头位置不移动,只沿垂直方向缓慢向下转动,画面重心从上方逐步移向下方。"},{id:"pan_left",label:"镜头左摇",promptValue:"镜头左摇",tag:"基础控制",desc:"横向展示空间",submitPromptText:"运镜:固定机位左摇,镜头位置不移动,只沿水平方向缓慢向左转动,让画面内容从右向左连续变化。"},{id:"pan_right",label:"镜头右摇",promptValue:"镜头右摇",tag:"基础控制",desc:"引出画外信息",submitPromptText:"运镜:固定机位右摇,镜头位置不移动,只沿水平方向缓慢向右转动,让画面内容从左向右连续变化。"},{id:"crane_up",label:"镜头上升",promptValue:"镜头上升",tag:"基础控制",desc:"展开场景规模",submitPromptText:"运镜:镜头垂直上升,拍摄方向基本保持稳定,机位高度从低到高变化,画面视角随高度产生变化。"},{id:"crane_down",label:"镜头下降",promptValue:"镜头下降",tag:"基础控制",desc:"从全局聚焦",submitPromptText:"运镜:镜头垂直下降,拍摄方向基本保持稳定,机位高度从高到低变化,画面视角随高度产生变化。"},{id:"truck_left",label:"镜头左移",promptValue:"镜头左移",tag:"基础控制",desc:"制造空间视差",submitPromptText:"运镜:镜头左移,机位整体向左横向平移,拍摄方向基本不变,前景与背景形成自然视差。"},{id:"truck_right",label:"镜头右移",promptValue:"镜头右移",tag:"基础控制",desc:"制造空间视差",submitPromptText:"运镜:镜头右移,机位整体向右横向平移,拍摄方向基本不变,前景与背景形成自然视差。"},{id:"dolly_in",label:"镜头前推",promptValue:"镜头前推",tag:"基础控制",desc:"强调情绪靠近",submitPromptText:"运镜:镜头缓慢前推,机位沿镜头朝向向前移动,主体在画面中逐渐变大,空间层次产生自然视差。"},{id:"dolly_out",label:"镜头后移",promptValue:"镜头后移",tag:"基础控制",desc:"展示人物孤独",submitPromptText:"运镜:镜头缓慢后拉,机位沿镜头朝向向后移动,主体在画面中逐渐变小,画面范围逐步变宽。"},{id:"zoom_in",label:"变焦推进",promptValue:"变焦推进",tag:"基础控制",desc:"突出表情反应",submitPromptText:"运镜:缓慢变焦推进,机位保持不动,只通过焦距变化让画面范围逐渐收紧。"},{id:"zoom_out",label:"变焦拉远",promptValue:"变焦拉远",tag:"基础控制",desc:"从局部到全貌",submitPromptText:"运镜:缓慢变焦拉远,机位保持不动,只通过焦距变化让画面范围逐渐放宽。"},{id:"follow_tracking",label:"跟随拍摄",promptValue:"跟随拍摄",tag:"人物跟拍",desc:"跟住人物行动",submitPromptText:"运镜:跟随拍摄,镜头跟随主体运动方向移动,与主体保持相对稳定的距离和构图。"},{id:"leading_tracking",label:"迎面跟拍",promptValue:"迎面跟拍",tag:"人物跟拍",desc:"保留人物表情",submitPromptText:"运镜:迎面跟拍,镜头位于主体前方并随主体运动同步后退,保持主体正面信息稳定可见。"},{id:"profile_tracking",label:"侧面跟拍",promptValue:"侧面跟拍",tag:"人物跟拍",desc:"强化行进节奏",submitPromptText:"运镜:侧面跟拍,镜头在主体侧方与其平行移动,保持侧向构图稳定,并形成横向空间视差。"},{id:"handheld_shot",label:"手持拍摄",promptValue:"手持拍摄",tag:"人物跟拍",desc:"增加真实紧张",submitPromptText:"运镜:手持拍摄,镜头带轻微自然晃动和近距离临场感,可随主体动作产生小幅调整。"},{id:"pov_shot",label:"第一视角",promptValue:"第一视角",tag:"人物跟拍",desc:"进入角色视角",submitPromptText:"运镜:第一视角,镜头模拟角色视线和身体移动,带轻微头部晃动和主观视角的运动反馈。"},{id:"fpv_flythrough",label:"穿越机运镜",promptValue:"穿越机运镜",tag:"空间航拍",desc:"高速掠过空间",submitPromptText:"运镜:穿越机运镜,fpv 镜头以第一视角高速穿行空间,贴近场景边界和主体灵活飞行,带明显速度感与滚转俯仰变化。"},{id:"steadicam_walkthrough",label:"稳定器行进",promptValue:"稳定器行进",tag:"人物跟拍",desc:"平稳进入现场",submitPromptText:"运镜:稳定器行进,镜头以稳定、连续的方式向前或跟随移动,运动平滑,晃动幅度低。"},{id:"slider_reveal",label:"横滑揭示",promptValue:"横滑揭示",tag:"揭示转场",desc:"从遮挡露主体",submitPromptText:"运镜:横滑揭示,镜头从遮挡关系中横向滑出,逐步露出被遮挡的主体或关键信息。"},{id:"foreground_wipe",label:"前景擦过",promptValue:"前景擦过",tag:"揭示转场",desc:"用遮挡完成切换",submitPromptText:"运镜:前景擦过,近处遮挡物从镜头前掠过并短暂覆盖画面,随后露出新的画面内容。"},{id:"push_through",label:"穿越镜头",promptValue:"穿越镜头",tag:"揭示转场",desc:"穿过边界入场",submitPromptText:"运镜:穿越镜头,镜头持续快速向前推进,并产生短暂运动模糊,穿过明确的前景边界或空间层次,进入后方画面,最后落到新的构图或目标上。"},{id:"whip_pan",label:"甩摇",promptValue:"甩摇",tag:"揭示转场",desc:"快速切换信息",submitPromptText:"运镜:甩摇,镜头快速水平转动并产生短暂运动模糊,最后落到新的构图或目标上。"},{id:"rack_focus",label:"焦点转移",promptValue:"焦点转移",tag:"揭示转场",desc:"注意力换目标",submitPromptText:"运镜:焦点转移,镜头位置可以不变,焦点从一个画面层次平滑切换到另一个画面层次。"},{id:"crash_zoom",label:"急速变焦",promptValue:"急速变焦",tag:"情绪强化",desc:"放大狗血反应",submitPromptText:"运镜:急速变焦推进,机位保持不动,画面范围快速收紧到目标区域,形成突然强调。"},{id:"dolly_zoom",label:"希区柯克",promptValue:"希区柯克",tag:"情绪强化",desc:"现实崩塌瞬间",submitPromptText:"运镜:希区柯克式变焦,机位移动与反向变焦同时发生,主体大小基本保持稳定,背景透视发生明显变化。"},{id:"orbit_180",label:"环绕拍摄",promptValue:"环绕拍摄",tag:"情绪强化",desc:"强化人物气场",submitPromptText:"运镜:环绕拍摄,镜头围绕主体平稳旋转约180度,主体保持在画面核心位置,背景产生连续旋转视差。"},{id:"ascending_orbit",label:"盘旋抬升",promptValue:"盘旋抬升",tag:"情绪强化",desc:"高光登场时刻",submitPromptText:"运镜:盘旋抬升,镜头围绕主体旋转的同时逐渐升高,主体保持锁定,机位高度持续变化。"},{id:"descending_orbit",label:"盘旋下降",promptValue:"盘旋下降",tag:"情绪强化",desc:"巨物压迫登场",submitPromptText:"运镜:盘旋下降,镜头围绕主体旋转的同时逐渐降低,主体保持锁定,机位高度持续变化。"},{id:"aerial_establishing",label:"高空航拍",promptValue:"高空航拍",tag:"空间航拍",desc:"建立宏大世界",submitPromptText:"运镜:高空航拍,镜头以高角度俯视画面,并保持稳定滑行,用于呈现空间关系和整体布局。"},{id:"drone_dive",label:"俯冲下降",promptValue:"俯冲下降",tag:"空间航拍",desc:"从高空压向目标",submitPromptText:"运镜:俯冲下降,镜头从高处向目标方向快速下降并靠近,形成明显速度感和压迫感。"},{id:"pull_away",label:"拉升离场",promptValue:"拉升离场",tag:"空间航拍",desc:"人变小世界变大",submitPromptText:"运镜:拉升离场,镜头从主体附近向后并向上移动,主体在画面中逐渐变小,画面范围逐步扩大。"}],Mae=Eae.map($0),Nae=new Map(Mae.map(e=>[e.id,e])),Dr={aspectRatio:Cae,resolution:Aae,durationSec:XC,soundEffectEnabled:Dae},dL={...Dr,resolution:Iae},wae={...dL,resolution:vae,durationSec:cL},kae={...Dr,resolution:xae},Oae={...Dr,resolution:Rae,durationSec:Pae},Lae={...Dr,resolution:[{value:"480p"},{value:"720p"}]},Er={aspectRatio:"9:16",resolution:"720p_lite",durationSec:10,soundEffectEnabled:!1},Fae=["text_to_video","omni_reference","image_to_video","image_reference"],dQe={modelId:"seedance_1.0",modelKind:"video",modes:Fae,defaultMode:"text_to_video",referenceLimits:{maxImageReferences:9},settingOptions:Dr,defaultSettings:Er},sL={...Er,resolution:"720p"},Bae={...Er,resolution:"720p"},Gae={...Er,aspectRatio:"16:9",resolution:"768p"},zae={...Er,aspectRatio:"16:9",resolution:"720p",durationSec:5},Uae=["text_to_video","omni_reference","image_to_video","image_reference"],Vae=["text_to_video","image_to_video","first_last_frame"],go=["text_to_video","omni_reference","image_to_video","first_last_frame","image_reference"],qae=[...go,"video_edit","video_extend"],uQe=[{modelId:"seedance1.5_direct",modelKind:"video",modes:Vae,defaultMode:"text_to_video",settingOptions:Dr,defaultSettings:Er},...["Seedance_2.0_mini_lite","Seedance_2.0_lite"].map(e=>({modelId:e,modelKind:"video",modes:go,defaultMode:"text_to_video",settingOptions:Lae,defaultSettings:Bae})),{modelId:"seedance2.0_direct",modelKind:"video",modes:go,defaultMode:"text_to_video",settingOptions:Dr,defaultSettings:Er},{modelId:"seedance2.0_fast_direct",modelKind:"video",modes:go,defaultMode:"text_to_video",settingOptions:Dr,defaultSettings:Er},{modelId:"seedance2.0_vision",modelKind:"video",modes:go,defaultMode:"text_to_video",settingOptions:dL,defaultSettings:sL},{modelId:"seedance2.0_fast_vision",modelKind:"video",modes:go,defaultMode:"text_to_video",settingOptions:Dr,defaultSettings:Er},{modelId:"Seedance_2.5",modelKind:"video",modes:qae,defaultMode:"text_to_video",settingOptions:wae,defaultSettings:sL},{modelId:"MiniMax-H3",modelKind:"video",modes:go,defaultMode:"text_to_video",referenceLimits:{maxImageReferences:5},settingOptions:kae,defaultSettings:Gae},aL,oL({durationOptions:cL,modes:go,standardVideoDefaultSettings:Er,standardVideoSettings:Dr}),{modelId:"happyhorse-1.1",modelKind:"video",modes:Uae,defaultMode:"text_to_video",referenceLimits:{maxImageReferences:9},settingOptions:Oae,defaultSettings:zae},...nL];var xQe={"seedance1.0":"seedance_1.0",seedance_1_5:"seedance1.5_direct","seedance_1.5":"seedance1.5_direct","seedance1.5":"seedance1.5_direct",seedance_2_0_lite:"Seedance_2.0_lite","seedance_2.0_lite":"Seedance_2.0_lite","seedance2.0_lite":"Seedance_2.0_lite","seedance2.0lite":"Seedance_2.0_lite",seedance_2_0_mini:"Seedance_2.0_lite","seedance_2.0_mini":"Seedance_2.0_lite","seedance2.0_mini":"Seedance_2.0_lite","seedance2.0mini":"Seedance_2.0_lite",seedance_2_0_mini_lite:"Seedance_2.0_mini_lite","seedance_2.0_mini_lite":"Seedance_2.0_mini_lite","seedance2.0_mini_lite":"Seedance_2.0_mini_lite","seedance2.0minilite":"Seedance_2.0_mini_lite",seedance_2_0:"seedance2.0_direct","seedance_2.0":"seedance2.0_direct","seedance2.0":"seedance2.0_direct",seedance_2_0_fast:"seedance2.0_fast_direct","seedance_2.0_fast":"seedance2.0_fast_direct","seedance2.0_fast":"seedance2.0_fast_direct",seedance_2_0_vision:"seedance2.0_vision","seedance_2.0_vision":"seedance2.0_vision",seedance_2_0_fast_vision:"seedance2.0_fast_vision","seedance_2.0_fast_vision":"seedance2.0_fast_vision",seedance_2_5:"Seedance_2.5","seedance_2.5":"Seedance_2.5","seedance2.5":"Seedance_2.5",seedance_25:"Seedance_2.5",seedance25:"Seedance_2.5",seedance_2_5_vision:"Seedance_2.5","seedance2.5_direct":"Seedance_2.5","seedance_2.5_direct":"Seedance_2.5","seedance2.5direct":"Seedance_2.5","seedance_2.5_fast":"Seedance_2.5","seedance2.5_fast":"Seedance_2.5","seedance_2.5_fast_direct":"Seedance_2.5","seedance2.5fast":"Seedance_2.5","seedance2.5fastdirect":"Seedance_2.5","seedance_2.5_vision":"Seedance_2.5","seedance2.5_vision":"Seedance_2.5","seedance2.5vision":"Seedance_2.5","seedance_2.5_fast_vision":"Seedance_2.5","seedance2.5_fast_vision":"Seedance_2.5","seedance2.5_fastvision":"Seedance_2.5","seedance2.5fastvision":"Seedance_2.5","seedance_2.5_lite":"Seedance_2.5","seedance2.5_lite":"Seedance_2.5","seedance2.5lite":"Seedance_2.5",seedance_2_5_lite:"Seedance_2.5","seedance_2.5_pro":"Seedance_2.5","seedance2.5_pro":"Seedance_2.5","seedance2.5pro":"Seedance_2.5","minimax-h3":"MiniMax-H3",minimax_h3:"MiniMax-H3",minimaxh3:"MiniMax-H3","minimax-h3-max":"MiniMax-H3-Max",minimax_h3_max:"MiniMax-H3-Max",minimaxh3max:"MiniMax-H3-Max","happyhorse-1.1":"happyhorse-1.1","happyhorse_1.1":"happyhorse-1.1",happyhorse_1_1:"happyhorse-1.1",happyhorse11:"happyhorse-1.1"},RQe={nano:"AnyDream_2.0",gpt_image_2:"gpt_image_2",nano2:"Nano2",nanopro:"NanoPro",nova2:"Nano2",nova_pro:"NanoPro","seedream_5.0_pro":"seedream_5.0_pro",anydream_2:"AnyDream_2.0",anydream2:"AnyDream_2.0","anydream2.0":"AnyDream_2.0",anydream_2_0:"AnyDream_2.0","anydream_2.0":"AnyDream_2.0",anycook_1_standard:"anycook_1_standard",anycook_1_creative:"anycook_1_creative",seedream_4:"AnyDream_2.0","seedream_4.1":"AnyDream_2.0","seedream_4.3":"AnyDream_2.0","seedream_4.5":"AnyDream_2.0","seedream_5.0":"AnyDream_2.0"};function Kae(e){return Object.values(Pr).includes(e)}function uL(e){return typeof e=="number"&&Object.values(Qh).filter(t=>typeof t=="number").includes(e)}var PQe={around:"orbit_180",push_in:"dolly_in",pull_back:"dolly_out",left_tracking:"truck_left",right_tracking:"truck_right"};function Ec(e){if(e==null||e==="")return"auto";if(Kae(e))return e;if(typeof e=="number"&&uL(e))return YC[e];let t=String(e).trim().toLowerCase();if(!t)return"auto";let n=Number(t);if(uL(n))return YC[n];switch(t){case"auto":return"auto";case"16:9":case"landscape_16_9":return"16:9";case"21:9":case"cinematic_21_9":return"21:9";case"9:16":case"portrait_9_16":return"9:16";case"3:4":case"portrait_3_4":return"3:4";case"4:3":case"landscape_4_3":return"4:3";case"3:2":return"3:2";case"2:3":return"2:3";case"1:1":case"square_1_1":return"1:1";default:return}}function pL(e){return typeof e=="string"&&e.trim()||void 0}function jae(e,t,n){return pL(e==null?void 0:e[t])??pL(n?e==null?void 0:e[n]:void 0)}function lL(e){let t={};return[["styleId","style_id"],["title"],["stylePeBefore","style_pe_before"],["stylePeAfter","style_pe_after"],["stylePosition","style_position"],["version"],["modelKey","model_key"],["stylePe","style_pe"],["category"]].forEach(([n,r])=>{let i=jae(e,n,r);i&&(t[n]=i)}),Object.keys(t).length>0?t:void 0}function mL(e,t){if(e===t)return!0;if(e==null||t==null)return!1;let n=lL(e),r=lL(t);return!n&&!r?!0:!n||!r?!1:lt(n,r)}function WC(){return Date.now()}function JC(e){return e==null||e===""?void 0:Ec(e)}function Hae(e){var t;return JC((e==null?void 0:e.ratio)??((t=e==null?void 0:e.params)==null?void 0:t.ratio))}function $ae(e,t,n){let r=n??0,i=(e==null?void 0:e.videoRatioUpdatedAt)??0;return i>0?i>r:r===0&&!!(t&&t!=="auto")}function fL({generation:e,runtimeVideoRatio:t,runtimeVideoRatioUpdatedAt:n,selectionVideoRatio:r}){let i=JC(r),o=JC(t);if(!(!i||!o||i!==o)&&!$ae(e,Hae(e),n))return n??null}var Yae=1;function Xae(e){if(!(typeof e!="string"||!e.trim()))try{let t=new URL(e.trim());return t.protocol==="http:"||t.protocol==="https:"?t.toString():void 0}catch{return}}function QC(e){if(!Array.isArray(e))return[];let t=new Set;for(let n of e){let r=Xae(n);if(r&&t.add(r),t.size>=Yae)break}return[...t]}function Wae(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function Jae(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!=null&&t!==""))}function ZC(e){return{...Jae({id:e.id,assetId:e.assetId,dataReferenceSelection:e.dataReferenceSelection,edgeId:e.edgeId,nodeAssetExtra:e.nodeAssetExtra,nodeAssetId:e.nodeAssetId,nodeAssetType:e.nodeAssetType,pippitAssetId:e.pippitAssetId,referenceSource:e.referenceSource,sourceNodeId:e.sourceNodeId,sourceNodeType:e.sourceNodeType,label:e.label,metadata:e.metadata,uploadPath:e.uploadPath,uploadStatus:"uploadStatus"in e&&e.uploadStatus==="uploading"?e.uploadStatus:void 0}),type:e.type}}function Qae(e){let t=(e==null?void 0:e.settings)??{},n=t.durationSec;return{...zb({cameraMotion:e==null?void 0:e.cameraMotion,durationMs:typeof n=="number"&&Number.isFinite(n)?Number(n)*1e3:void 0,ratio:t.aspectRatio,resolution:t.resolution,seed:e==null?void 0:e.seed}),...t.effort!==void 0?{effort:t.effort}:{},...e!=null&&e.mode?{mode:e.mode}:{}}}function Zae(e,t){let n=zb((e==null?void 0:e.params)??{});return{...(e==null?void 0:e.prompt)!==void 0?{prompt:e.prompt}:{},...(e==null?void 0:e.modelKey)!==void 0?{modelKey:e.modelKey}:{},...t&&(e==null?void 0:e.mode)!==void 0?{mode:e.mode}:{},...n.args!==void 0?{args:n.args}:{},...n.count!==void 0?{count:n.count}:{},...n.novelStyle!==void 0?{novelStyle:n.novelStyle}:{},...n.promptTemplate!==void 0?{promptTemplate:n.promptTemplate}:{},...t&&n.cameraMotion!==void 0?{cameraMotion:n.cameraMotion}:{},...t&&n.durationMs!==void 0?{durationMs:n.durationMs}:{},...t&&n.ratio!==void 0?{ratio:n.ratio}:{},...t&&n.resolution!==void 0?{resolution:n.resolution}:{},...t&&n.seed!==void 0?{seed:n.seed}:{},...(e==null?void 0:e.args)!==void 0?{args:e.args}:{},...(e==null?void 0:e.count)!==void 0?{count:e.count}:{},...(e==null?void 0:e.novelStyle)!==void 0?{novelStyle:e.novelStyle}:{},...(e==null?void 0:e.promptTemplate)!==void 0?{promptTemplate:e.promptTemplate}:{},...t&&(e==null?void 0:e.cameraMotion)!==void 0?{cameraMotion:e.cameraMotion}:{},...t&&(e==null?void 0:e.durationMs)!==void 0?{durationMs:e.durationMs}:{},...t&&(e==null?void 0:e.ratio)!==void 0?{ratio:e.ratio}:{},...t&&(e==null?void 0:e.resolution)!==void 0?{resolution:e.resolution}:{},...t&&(e==null?void 0:e.effort)!==void 0?{effort:e.effort}:{},...t&&(e==null?void 0:e.seed)!==void 0?{seed:e.seed}:{},...(e==null?void 0:e.references)!==void 0?{references:e.references.map(ZC)}:{}}}function ese({previous:e,styleSnapshot:t,novelStyle:n}){if(t!==void 0)return t;if(n===void 0)return e==null?void 0:e.styleSnapshot}function tse({previous:e,styleSnapshot:t,styleSnapshotPinnedAt:n,nextStyleSnapshot:r}){return n!==void 0?n??void 0:t===null?WC():t===void 0||mL(e==null?void 0:e.styleSnapshot,r)?e==null?void 0:e.styleSnapshotPinnedAt:WC()}function nse({previous:e,runtimeVideoRatio:t,runtimeVideoRatioUpdatedAt:n,selectionConfig:r,videoRatioUpdatedAt:i,videoRatioTouched:o}){var d;if(i!==void 0)return i??void 0;if(r.ratio===void 0)return e==null?void 0:e.videoRatioUpdatedAt;if(o)return Date.now();let a=fL({generation:e,runtimeVideoRatio:t,runtimeVideoRatioUpdatedAt:n,selectionVideoRatio:r.ratio});if(a!==void 0)return a??void 0;let s=Ec((e==null?void 0:e.ratio)??((d=e==null?void 0:e.params)==null?void 0:d.ratio)),c=Ec(r.ratio);return s!==void 0&&c!==void 0&&s===c?e==null?void 0:e.videoRatioUpdatedAt:Date.now()}function eA({previous:e,prompt:t,references:n,webLinks:r,selection:i,count:o,novelStyle:a,styleSnapshot:s,styleSnapshotPinnedAt:c,videoRatioUpdatedAt:d,videoRatioTouched:u,runtimeVideoRatio:p,runtimeVideoRatioUpdatedAt:m,target:f}){var Ot;let{args:h,cameraMotion:g,count:y,durationMs:_,mode:S,modelKey:T,novelStyle:C,params:I,promptTemplate:x,ratio:R,resolution:G,effort:O,seed:K,references:H,webLinks:U,prompt:W,styleSnapshot:re,styleSnapshotPinnedAt:Q,videoRatioUpdatedAt:Ge,...Xe}=e??{},{model:Ce,...ze}=Xe,Nt=Wae(i==null?void 0:i.modelId),Re=n!==void 0?n.map(ZC):(Ot=e==null?void 0:e.references)==null?void 0:Ot.map(ZC),wt=r!==void 0?QC(r):QC(e==null?void 0:e.webLinks),kt=i!==void 0?Qae(i):{},on=ese({previous:e,styleSnapshot:s,novelStyle:a}),an=tse({previous:e,styleSnapshot:s,styleSnapshotPinnedAt:c,nextStyleSnapshot:on}),ut=nse({previous:e,runtimeVideoRatio:p,runtimeVideoRatioUpdatedAt:m,selectionConfig:kt,videoRatioUpdatedAt:d,videoRatioTouched:u});return{generation:{...ze,...Zae(e,i===void 0),...t!==void 0?{prompt:t}:{},...Nt?{modelKey:Nt}:{},...kt,...o!==void 0?{count:o}:{},...a!==void 0?{novelStyle:a}:{},...on!==void 0?{styleSnapshot:on}:{},...an!==void 0?{styleSnapshotPinnedAt:an}:{},...ut!==void 0?{videoRatioUpdatedAt:ut}:{},...Re!==void 0?{references:Re}:{},...wt.length?{webLinks:wt}:{}}}}function hL(e){return String(e??"").trim()}function rse(e,t,n){let r=`edge-${e}-${t}`,i=r,o=1;for(;n[i];)o+=1,i=`${r}-${o}`;return i}function Si(e,t,n){let r=hL(t);return Object.values(e).find(i=>i.type==="reference"&&i.source===r&&i.target===n)}function tg({createEdge:e,sourceNodeId:t,store:n,targetNodeId:r}){let i=hL(t);if(!i||i===r)return{status:"noop"};let o=n.getRootCanvasContent();if(!o.nodes[i]||!o.nodes[r])return{status:"aborted"};let a=Si(o.edges,i,r);if(a)return{edgeId:a.id,status:"noop"};let s=rse(i,r,o.edges),c={id:s,type:"reference",source:i,target:r,sourceHandle:"right",targetHandle:"left"};if(e){let u=e(c);return u?u.status==="aborted"?{status:"aborted"}:u.status==="noop"?{edgeId:s,status:"noop"}:{edgeId:s,status:"committed"}:{edgeId:s,status:"committed"}}return n.commands.createEdge(c).status==="committed"?{edgeId:s,status:"committed"}:{status:"aborted"}}function ng(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function yo(e){if(e===ee)return"image";if(e===J)return"video"}function gL({document:e,edge:t,target:n}){let r=M(e).nodes[t.source];if(!r||r.type!==Z)return;let i=e.assets[r.id],o=ng(i)&&"content"in i?i.content:void 0,a=bc(Cc(e,r),t,{content:o,displayNode:r});if(!a)return;let s=n==="video"?xc(e,a):a;return GO(s,n).length?s:void 0}function ise({document:e,edge:t,previous:n,target:r}){let i=gL({document:e,edge:t,target:r});if(i)return eA({previous:n,references:AC(n==null?void 0:n.references,i,void 0),target:r})}function yL(e){return t=>{let n=e.getRootCanvasContent(),r=n.nodes[t.source],i=n.nodes[t.target],o=i?yo(i.type):void 0;if((r==null?void 0:r.type)!==Z||!o)return e.commands.createEdge(t);if(Si(n.edges,t.source,t.target))return{status:"noop",reason:"no-changes"};let a=e.getState(),s=ro(a,t.target),c=ise({document:a,edge:t,previous:s==null?void 0:s.generation,target:o});return c?e.commands.batch("edge.createWithRoleReferenceSelection",d=>{d.createEdge(t),Sh(d,t.target,c)}):e.commands.createEdge(t)}}function ose(e,t,n,r){if(!Array.isArray(e))return e;let i=`node:${t}`,o=`node:${n}`,a=new Set,s=!1,c=e.flatMap(d=>{if(typeof d=="string"){if(d===t)return s=!0,(r?[n]:[t,n]).filter(m=>{let f=`node:${m}`;return a.has(f)?!1:(a.add(f),!0)});let u=`node:${d}`;return a.has(u)?[]:(a.add(u),[d])}if(!ng(d))return[d];if(d.kind==="node"){if(d.nodeId===t)return s=!0,(r?[n]:[t,n]).flatMap(m=>{let f=`node:${m}`;return a.has(f)?[]:(a.add(f),[{...d,nodeId:m}])});let u=`node:${String(d.nodeId??"")}`;return a.has(u)?[]:(a.add(u),[d])}if(d.kind==="reference"){if(d.referenceKey===i)return s=!0,(r?[o]:[i,o]).flatMap(m=>a.has(m)?[]:(a.add(m),[{...d,referenceKey:m}]));let u=String(d.referenceKey??"");return a.has(u)?[]:(a.add(u),[d])}return[d]});return!s&&!a.has(o)&&c.push(n),c}function _L({nextRoleNodeId:e,previousRoleNodeId:t,removePreviousReference:n,selection:r,store:i,targetNodeId:o}){let a=i.getState(),s=M(a),c=s.nodes[o],d=c?yo(c.type):void 0,u=s.nodes[e];if(!d||(u==null?void 0:u.type)!==Z)return{status:"aborted",reason:"role reference switch target not found"};let m=Si(s.edges,e,o)??{id:`edge-${e}-${o}`,source:e,sourceHandle:"right",target:o,targetHandle:"left",type:"reference"},f=gL({document:a,edge:m,target:d});return f?i.transact(h=>{let g=M(h);if(!Si(g.edges,e,o)){let G=m.id,O=1;for(;g.edges[G];)O+=1,G=`${m.id}-${O}`;g.edges[G]={...m,id:G}}let y=h.assets[o],_=ng(y==null?void 0:y.content)?y.content:void 0,S=g.nodes[o],T=ng(S==null?void 0:S.data)?S.data:void 0,C=_??T,I=C==null?void 0:C.generation,x=AC(I==null?void 0:I.references,f,r);if(n&&t!==e){let G=x.find(O=>Ic(O).includes(t));G&&(x=BO(x,G)),Object.entries(g.edges).forEach(([O,K])=>{K.source===t&&K.target===o&&delete g.edges[O]})}let R=eA({previous:I,references:x,target:d});if(_&&Object.assign(_,R),T&&Object.assign(T,R),t!==e){let G=(_==null?void 0:_.inputOrder)??(T==null?void 0:T.inputOrder),O=ose(G,t,e,n);_&&O!==void 0&&(_.inputOrder=O),T&&O!==void 0&&(T.inputOrder=O)}},{intent:"generation.roleReference.replace"}):{status:"aborted",reason:"role reference has no compatible source"}}function tA(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function _p(e){return typeof e=="string"?e.trim():""}function ase(e){return Array.from(new Set(e.map(_p).filter(Boolean)))}function sse(e){return Array.isArray(e==null?void 0:e.references)?e.references:[]}function TL(e,t){return Ic(e).includes(t)}function cse(e,t){return ase(e.map(n=>t[n]??n))}function dse(e,t,n){let r=e.assets[t];r&&tA(r.content)&&Object.assign(r.content,{generation:n});let i=M(e).nodes[t];i&&tA(i.data)&&Object.assign(i.data,{generation:n})}function Tp({document:e,nextRoleContent:t,previousRoleContent:n,roleNodeId:r,selectionReplacements:i}){let o=Object.fromEntries(Object.entries(i??{}).map(([s,c])=>[_p(s),_p(c)]).filter(([s,c])=>s&&s!==c));if(!Object.keys(o).length)return;let a=M(e);Object.values(a.nodes).forEach(s=>{if(!yo(s.type))return;let c=e.assets[s.id];if(!c||!tA(c.content))return;let{generation:d}=c.content;if(!d)return;let u=sse(d),m=u.find(_=>TL(_,r))??{nodeAssetId:r,type:"image"},f=typeof d.prompt=="string"?d.prompt:"",h=j0({nextSelectableSelection:[],previousDefaultSelection:[],prompt:f,reference:m,selectionReplacements:o}),g=u.map(_=>!TL(_,r)||!Array.isArray(_.dataReferenceSelection)?_:{..._,dataReferenceSelection:cse(_.dataReferenceSelection,o)});!g.some((_,S)=>_!==u[S])&&h.prompt===f||dse(e,s.id,{...d,prompt:h.prompt,references:g})})}function SL({document:e,nextPippitAssetId:t,previousPippitAssetId:n,roleContent:r,roleNodeId:i}){let o=_p(n),a=_p(t);!o||o===a||Tp({document:e,nextRoleContent:r,previousRoleContent:r,roleNodeId:i,selectionReplacements:{[o]:a}})}function nA(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function use(e){return e?Object.entries(e).filter(t=>!!t[0].trim()&&nA(t[1])):[]}function bL(e,t,n){var o;let r=(o=e.assets)==null?void 0:o[t];if(!r||!nA(r))return;let i=use(n);if(i.length){if(!nA(r.history)){r.history=Object.fromEntries(i);return}for(let[a,s]of i)r.history[a]=s}}var pse=["assetId","caption","candidatePippitAssetIds","generation","metadata","naturalHeight","naturalWidth","pippitAssetId","source","sourceType","durationMs","waveformKey","playback","viewState"];function Mc(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function CL(e){return Mc(e)&&Mc(e.appearanceInfo)?e.appearanceInfo:void 0}function AL(e){return Xk(e)}function lse(e){var n;if(!Mc(e))return;let t=e.uploadPath??((n=CL(e))==null?void 0:n.uploadPath);return t==="legacy"||t==="optimized"?t:void 0}function mse(e){if(!Mc(e)||!AL(e))return;let n=CL(e);if(n){let i=Mc(e.generation)?{...e.generation}:void 0;return{appearanceInfo:ka(n),...i?{generation:i}:{}}}let r={};return pse.forEach(i=>{e[i]!==void 0&&(r[i]=e[i])}),lse(e)==="optimized"&&(r.uploadPath="optimized",e.localUploadCache!==void 0&&(r.localUploadCache=e.localUploadCache),e.securityCheckScene!==void 0&&(r.securityCheckScene=e.securityCheckScene)),Object.keys(r).length?r:void 0}function Nc(e,t,n){var a;let r=(a=e.assets)==null?void 0:a[t];if(!r||!Mc(r))return;let i=mse(n??r.content),o=AL(i);!i||!o||bL(e,t,{[o]:i})}var To="xyq.role.updateAppearance";function St(e){return(e==null?void 0:e.trim())||void 0}function rA(e){let t=new Set;return e.flatMap(n=>{let r=n.trim();return!r||t.has(r)?[]:(t.add(r),[r])})}function IL(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function _o(e,t){return St(e)===St(t)}function fse(e,t){var n,r;return t?_o((n=e.appearanceInfo)==null?void 0:n.assetId,t.assetId)&&_o((r=e.appearanceInfo)==null?void 0:r.pippitAssetId,t.pippitAssetId):!0}function hse(e){var t,n;return{runId:St((t=e==null?void 0:e.state)==null?void 0:t.runId)??St(e==null?void 0:e.runId),threadId:St((n=e==null?void 0:e.state)==null?void 0:n.threadId)??St(e==null?void 0:e.threadId)}}function gse(e,t){if(!t)return!0;let n=hse(e);return _o(n.runId??void 0,t.runId)&&_o(n.threadId??void 0,t.threadId)}function yse(e,t){return _o(e==null?void 0:e.prompt,t)}function _se(e,t){if(t===null){e.content.generation&&delete e.content.generation.prompt;return}e.content.generation??={},e.content.generation.prompt=t}function Tse(e,t){let n=t.state.runId.trim(),r=t.state.threadId.trim();if(!n||!r)return;let{generation:i}=e.content;i||(i={},e.content.generation=i),i.runId=n,i.threadId=r,i.state={...structuredClone(t.state),runId:n,threadId:r}}function bi(e,t,n){if(!t||!Object.prototype.hasOwnProperty.call(t,n))return!0;let r=t[n];if(n==="voiceType")return e.voice_type===r;if(n==="description")return(e.description??"")===(r??"");if(n==="audioDurationMs")return(e.audioDurationMs??null)===(r??null);let i={audioAssetId:e.audioAssetId,audioName:e.audioName,audioNodeId:e.audioNodeId,audioPippitAssetId:e.audioPippitAssetId,audioSource:e.audioSource,voiceId:e.voiceId}[n];return _o(typeof i=="string"?i:void 0,typeof r=="string"?r:void 0)}function Sse(e,t){let n=e.getState(),r=M(n).nodes[t.nodeId];if((r==null?void 0:r.type)!==Z||r.id!==t.assetId)return;let i=n.assets[t.assetId];return i&&Zt(i)?i:void 0}function bse(e,t,n){let r={...e.content.voiceInfo??{}};t.description!==void 0&&bi(r,n,"description")&&(r.description=t.description),t.voiceType!==void 0&&bi(r,n,"voiceType")&&(r.voice_type=t.voiceType),t.audioAssetId!==void 0&&bi(r,n,"audioAssetId")&&(r.audioAssetId=St(t.audioAssetId)),t.audioName!==void 0&&bi(r,n,"audioName")&&(r.audioName=St(t.audioName)),t.audioNodeId!==void 0&&bi(r,n,"audioNodeId")&&(r.audioNodeId=St(t.audioNodeId)),t.audioPippitAssetId!==void 0&&bi(r,n,"audioPippitAssetId")&&(r.audioPippitAssetId=St(t.audioPippitAssetId)),t.audioSource!==void 0&&bi(r,n,"audioSource")&&(r.audioSource=t.audioSource??void 0),t.voiceId!==void 0&&bi(r,n,"voiceId")&&(r.voiceId=St(t.voiceId)),t.audioDurationMs!==void 0&&bi(r,n,"audioDurationMs")&&(t.audioDurationMs===null||!Number.isFinite(t.audioDurationMs)||t.audioDurationMs<=0?delete r.audioDurationMs:r.audioDurationMs=t.audioDurationMs),e.content.voiceInfo=r,delete e.content.voice_info}function Cse(e,t,n){var s,c;let r=St((s=e.content.appearanceInfo)==null?void 0:s.pippitAssetId),i=St(t.pippitAssetId),a=!!(i&&(i!==r||St(t.assetId)!==St((c=e.content.appearanceInfo)==null?void 0:c.assetId)))?oO(e.content,{assetId:St(t.assetId),imageSource:t.imageSource,isMain:!0,name:n,pippitAssetId:i,type:"image",uploadPath:t.uploadPath}):void 0;e.content.appearanceInfo={...(a==null?void 0:a.appearanceInfo)??e.content.appearanceInfo??{},...t.assetId!==void 0?{assetId:St(t.assetId)}:{},...t.pippitAssetId!==void 0?{pippitAssetId:St(t.pippitAssetId)}:{},...t.imageSource!==void 0?{imageSource:t.imageSource}:{},...t.uploadPath!==void 0?{uploadPath:t.uploadPath}:{}},a!=null&&a.sourceInfos&&(e.content.sourceInfos=a.sourceInfos)}function iA(e,t){let n=Sse(e,t);if(!n)return{status:"aborted",reason:"role asset not found"};let r=structuredClone(n.content);return e.transact(i=>{var h,g,y,_,S,T;let o=M(i).nodes[t.nodeId];if((o==null?void 0:o.type)!==Z||o.id!==t.assetId)return;let a=Oa(i.assets[t.assetId]);if(!(a!=null&&a.content))return;let{expected:s,patch:c}=t;c.characterName!==void 0&&(!s||!Object.prototype.hasOwnProperty.call(s,"characterName")||_o(o.data.name,s.characterName))&&(o.data.name=c.characterName,a.content.basicInfo={...a.content.basicInfo??{},name:c.characterName}),c.appearanceName!==void 0&&(!s||!Object.prototype.hasOwnProperty.call(s,"appearanceName")||_o((h=r.basicInfo)==null?void 0:h.appearanceName,s.appearanceName))&&(a.content.basicInfo={...a.content.basicInfo??{},appearanceName:c.appearanceName}),c.episodes!==void 0&&(!s||!Object.prototype.hasOwnProperty.call(s,"episodes")||IL(rA(r.episodes??[]),rA(s.episodes??[])))&&(a.content.episodes=rA(c.episodes)),c.appearanceDescription!==void 0&&(a.content.appearanceInfo={...a.content.appearanceInfo??{},description:c.appearanceDescription});let d=!c.mainImage||fse(r,s==null?void 0:s.mainImage),u=c.generation===void 0||!s||!Object.prototype.hasOwnProperty.call(s,"generation")||IL(r.generation,s.generation),p=!!(c.mainImage&&c.generation!==void 0),m=d&&u;c.mainImage&&(p?m:d)&&Cse(a,c.mainImage,c.appearanceName??((g=a.content.basicInfo)==null?void 0:g.appearanceName)),c.voice&&bse(a,c.voice,s==null?void 0:s.voice),c.generation!==void 0&&(p?m:u)&&(c.generation===null?delete a.content.generation:a.content.generation=structuredClone(c.generation)),c.generationPrompt!==void 0&&(!s||!Object.prototype.hasOwnProperty.call(s,"generationPrompt")||yse(r.generation,s.generationPrompt))&&_se(a,c.generationPrompt),c.generationRun&&(!s||!Object.prototype.hasOwnProperty.call(s,"generationRun")||gse(r.generation,s.generationRun))&&Tse(a,c.generationRun),(((y=r.appearanceInfo)==null?void 0:y.pippitAssetId)!==((_=a.content.appearanceInfo)==null?void 0:_.pippitAssetId)||((S=r.appearanceInfo)==null?void 0:S.assetId)!==((T=a.content.appearanceInfo)==null?void 0:T.assetId))&&(Nc(i,t.assetId,r),Nc(i,t.assetId,a.content)),Tp({document:i,nextRoleContent:a.content,previousRoleContent:r,roleNodeId:t.nodeId})},{intent:"role.updateAppearance",mergeKey:`role-appearance:${t.nodeId}`})}var So="xyq.role.updateSourceInfos";function wc(e){return typeof e=="string"?e.trim():""}function Mr(e){return e!==void 0&&(!e.type||e.type==="image")}function oA(e){return[...e].sort((t,n)=>{let r=typeof t[1].order=="number"&&Number.isFinite(t[1].order)?t[1].order:0,i=typeof n[1].order=="number"&&Number.isFinite(n[1].order)?n[1].order:0;return r!==i?r-i:t[0].localeCompare(n[0])})}function Ase(e){return Object.fromEntries(Fa(e.content))}function vL(e){let t=Object.fromEntries(oA(Object.entries(e)).map(([n,r],i)=>[n,{...r,pippitAssetId:n,order:i}]));return fc(t)??{}}function Ise(e,t){!t||!Mr(t)||(e.content.appearanceInfo={...e.content.appearanceInfo??{},assetId:t.assetId,pippitAssetId:t.pippitAssetId,imageSource:2},t.uploadPath==="optimized"?e.content.appearanceInfo.uploadPath="optimized":delete e.content.appearanceInfo.uploadPath,Zu(e.content,{source:fn.Uploaded}))}function vse(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,{...r,isMain:n===t,pippitAssetId:n}]))}function xse(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n,isMain:!1,pippitAssetId:t}]))}function xL(e){var t;return(t=oA(Object.entries(e)).find(([,n])=>Mr(n)))==null?void 0:t[0]}function Rse(e){var t;return(t=Object.entries(e).find(([,n])=>n.isMain===!0&&Mr(n)))==null?void 0:t[0]}function RL(e,t){let n=e[t];if(!n)return e;let r=Math.min(0,...Object.values(e).map(i=>typeof i.order=="number"&&Number.isFinite(i.order)?i.order:0));return{...e,[t]:{...n,order:r-1,pippitAssetId:t}}}function Pse(e,t,n){let r=!1;return Object.values(M(e).nodes).forEach(i=>{if(i.type!==Z)return;let o=Oa(e.assets[i.id]);if(!(o!=null&&o.content))return;let a=Object.fromEntries(Fa(o.content)),s=a[t];!s||s.name===n||(o.content.sourceInfos={...a,[t]:{...s,name:n,pippitAssetId:t}},r=!0)}),r}function Dse(e,t,n,r){if(r.type==="setDefault")return!1;if(r.type==="setName"){let m=wc(r.pippitAssetId),f=r.name.trim();return!m||!f?!1:Pse(e,m,f)}let i=Ase(n),o={...n.content,appearanceInfo:{...n.content.appearanceInfo??{}},sourceInfos:vL(i)},a={...i},s,c=!1,d=Rse(i);if(r.type==="upsert"){let m=wc(r.sourceInfo.pippitAssetId);if(!m)return!1;let f=Object.keys(a).length>0,h=Object.values(a).some(Mr),g=Math.max(-1,...Object.values(a).map(S=>typeof S.order=="number"&&Number.isFinite(S.order)?S.order:-1)),y=a[m],_={...y??{},...r.sourceInfo,isMain:r.sourceInfo.isMain??(y==null?void 0:y.isMain)??!f,order:r.sourceInfo.order??(y==null?void 0:y.order)??g+1,pippitAssetId:m,type:r.sourceInfo.type??(y==null?void 0:y.type)??"image"};a[m]={..._,isMain:Mr(_)&&(!h||_.isMain===!0)},a[m].isMain&&(a=RL(a,m),s=m)}if(r.type==="setMain"){let m=wc(r.pippitAssetId);if(!Mr(a[m]))return!1;a=RL(a,m),s=m}if(r.type==="delete"){let m=wc(r.pippitAssetId),f=a[m];if(!f||Object.keys(a).length<=1&&Mr(f))return!1;let h=f.isMain===!0?xL(Object.fromEntries(Object.entries(a).filter(([g])=>g!==m))):void 0;if(f.isMain===!0&&!h)return!1;delete a[m],h&&(s=h)}if(r.type==="reorder"){let m=wc(r.activePippitAssetId),f=wc(r.overPippitAssetId),h=a[m],g=a[f];if(!h||!g||m===f)return!1;a[m]={...h,order:g.order,pippitAssetId:m},a[f]={...g,order:h.order,pippitAssetId:f};let y=oA(Object.entries(a))[0];if(!y)return!1;if(Mr(y[1]))s=y[0];else if(Object.values(a).some(Mr))return!1}a=vL(a);let u=Mr(a[d??""])?d:void 0,p=s??u??xL(a);return p?(a=vse(a,p),d!==p&&(s=p,c=!0)):a=xse(a),n.content.sourceInfos=a,s&&Ise(n,a[s]),c&&(Nc(e,t,o),Nc(e,t,n.content)),Tp({document:e,nextRoleContent:n.content,previousRoleContent:o,roleNodeId:t}),!0}function Ese(e,t){let n=e.getState(),r=M(n).nodes[t.nodeId];if((r==null?void 0:r.type)!==Z||r.id!==t.assetId)return;let i=n.assets[t.assetId];return i&&Zt(i)?i:void 0}function aA(e,t){return Ese(e,t)?e.transact(n=>{let r=M(n).nodes[t.nodeId];if((r==null?void 0:r.type)!==Z||r.id!==t.assetId)return;let i=Oa(n.assets[t.assetId]);i!=null&&i.content&&Dse(n,t.assetId,i,t.operation)},{intent:"role.updateSourceInfos",mergeKey:`role-source-infos:${t.nodeId}:${t.operation.type}`,undoable:t.operation.type!=="setName"}):{status:"aborted",reason:"role asset not found"}}var Mse=2e3,Nse=5e3;function wse(e){return e!==void 0&&e>Mse&&e<=Nse}function sA(e){return e!==void 0&&!wse(e)}var kc="xyq.role.updateDescription";function PL(e){var s,c,d,u,p;let t=((s=e==null?void 0:e.audioAssetId)==null?void 0:s.trim())||((c=e==null?void 0:e.voiceId)==null?void 0:c.trim()),n=(d=e==null?void 0:e.audioPippitAssetId)==null?void 0:d.trim(),r=(u=e==null?void 0:e.audioName)==null?void 0:u.trim(),i=e==null?void 0:e.audioDurationMs,o=e==null?void 0:e.audioSource,a=(p=e==null?void 0:e.audioNodeId)==null?void 0:p.trim();if(!(!t&&!a&&!n&&!r&&(typeof i!="number"||!Number.isFinite(i)||i<=0)))return{assetId:t,audioNodeId:a,durationMs:i,name:r,pippitAssetId:n,audioSource:o}}function kse(e,t){var i;let n=t?(i=e.assets[t])==null?void 0:i.content:void 0;if(!n||typeof n!="object"||Array.isArray(n))return;let{pippitAssetId:r}=n;return typeof r=="string"&&r.trim()||void 0}function DL(e){let t=typeof e=="string"?e.split(/[、,,\s]+/):e??[],n=new Set,r=[];for(let i of t){let o=String(i).trim();!o||n.has(o)||(n.add(o),r.push(o))}return r}function Ose(e,t){var r,i,o,a,s,c;let n=Zt(e);return n?t==="voice"?((r=yn(n))==null?void 0:r.description)??"":t==="characterName"?((i=n.basicInfo)==null?void 0:i.name)??"":t==="appearanceName"?((o=n.basicInfo)==null?void 0:o.appearanceName)??"":t==="episodes"?DL(n.episodes).join("、"):t==="voiceAudio"?PL(yn(n)):t==="voiceType"?(a=yn(n))==null?void 0:a.voice_type:((s=n.appearanceInfo)==null?void 0:s.description)??((c=n.basicInfo)==null?void 0:c.description)??"":""}function rg(e){var c,d,u,p,m;if(!e||typeof e!="object")return;let t=(c=e.assetId)==null?void 0:c.trim(),n=(d=e.name)==null?void 0:d.trim(),r=typeof e.durationMs=="number"&&Number.isFinite(e.durationMs)&&e.durationMs>0?Math.round(e.durationMs):void 0,{audioSource:i}=e,o=(u=e.audioNodeId)==null?void 0:u.trim(),a=(p=e.pippitAssetId)==null?void 0:p.trim(),s=(m=e.previousPippitAssetId)==null?void 0:m.trim();if(!(!t&&!o&&!a&&!n&&r===void 0))return{...t?{assetId:t}:{},...o?{audioNodeId:o}:{},...r!==void 0?{durationMs:r}:{},...n?{name:n}:{},...i?{audioSource:i}:{},...a?{pippitAssetId:a}:{},...s?{previousPippitAssetId:s}:{}}}function Lse(e){if(e===2)return 2;if(e===1)return 1;let t=rg(e);return(t!=null&&t.assetId||t!=null&&t.audioNodeId)&&!sA(t.durationMs)?2:1}function Fse(e,t){let n=rg(e),r=rg(t);return((n==null?void 0:n.assetId)??"")===((r==null?void 0:r.assetId)??"")&&((n==null?void 0:n.audioNodeId)??"")===((r==null?void 0:r.audioNodeId)??"")&&((n==null?void 0:n.durationMs)??0)===((r==null?void 0:r.durationMs)??0)&&((n==null?void 0:n.name)??"")===((r==null?void 0:r.name)??"")&&((n==null?void 0:n.pippitAssetId)??"")===((r==null?void 0:r.pippitAssetId)??"")&&((n==null?void 0:n.audioSource)??"")===((r==null?void 0:r.audioSource)??"")}function cA(e,t){e.content.voiceInfo={...yn(e.content)??{},...t},delete e.content.voice_info}function Bse(e,t){let n=e.getState(),r=M(n).nodes[t.nodeId];if((r==null?void 0:r.type)!==Z||r.id!==t.assetId)return;let i=n.assets[t.assetId];if(!(!i||!Zt(i)))return{asset:i,node:r}}function Gse(e,t,n){var r,i,o;if(t.field==="characterName"){let a=typeof t.value=="string"?t.value:"";return n===t.value&&e.node.data.name===a}return t.field==="voiceAudio"?Fse(n,t.value)&&!(typeof t.value=="object"&&((i=(r=t.value)==null?void 0:r.pippitAssetId)!=null&&i.trim())&&((o=t.value.previousPippitAssetId)!=null&&o.trim())&&t.value.pippitAssetId.trim()!==t.value.previousPippitAssetId.trim()):n===t.value}function zse(e,t){let n=Bse(e,t);if(!n)return{status:"aborted",reason:"role asset not found"};let r=Ose(n.asset,t.field);return Gse(n,t,r)?{status:"noop",reason:"no-changes"}:e.transact(i=>{let o=M(i).nodes[t.nodeId];if((o==null?void 0:o.type)!==Z||o.id!==t.assetId)return;let a=Oa(i.assets[t.assetId]);if(!(a!=null&&a.content))return;if(t.field==="characterName"){let c=typeof t.value=="string"?t.value:"";o.data.name=c,a.content.basicInfo={...a.content.basicInfo??{},name:c};return}if(t.field==="appearanceName"){let c=typeof t.value=="string"?t.value:"";a.content.basicInfo={...a.content.basicInfo??{},appearanceName:c};return}if(t.field==="voice"){let c=typeof t.value=="string"?t.value:"";cA(a,{description:c});return}if(t.field==="voiceAudio"){let c=PL(yn(a.content)),d=rg(t.value);if(sA(d==null?void 0:d.durationMs))return;cA(a,{audioAssetId:d==null?void 0:d.assetId,audioDurationMs:d==null?void 0:d.durationMs,audioName:d==null?void 0:d.name,audioNodeId:d==null?void 0:d.audioNodeId,audioPippitAssetId:d==null?void 0:d.pippitAssetId,audioSource:d==null?void 0:d.audioSource,voiceId:d==null?void 0:d.assetId});let u=(d==null?void 0:d.previousPippitAssetId)??(c==null?void 0:c.pippitAssetId)??kse(i,c==null?void 0:c.audioNodeId);u&&u!==(d==null?void 0:d.pippitAssetId)&&SL({document:i,nextPippitAssetId:d==null?void 0:d.pippitAssetId,previousPippitAssetId:u,roleContent:a.content,roleNodeId:t.nodeId});return}if(t.field==="voiceType"){let c=Lse(t.value);cA(a,{voice_type:c});return}if(t.field==="episodes"){a.content.episodes=DL(typeof t.value=="string"?t.value:void 0);return}let s=typeof t.value=="string"?t.value:"";a.content.appearanceInfo={...ka(a.content.appearanceInfo),description:s}},{intent:"role.updateDescription",mergeKey:`role-description:${t.nodeId}:${t.field}`})}function EL(e){let t=e.commands.register(To,iA),n=e.commands.register(kc,zse),r=e.commands.register(So,aA);return()=>{t(),n(),r()}}var ir="5.0";var Tn=(e,t)=>e===t?0:e<t?-1:1,dA=e=>Array.isArray(e)?e.map(dA):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0).sort(([t],[n])=>Tn(t,n)).map(([t,n])=>[t,dA(n)])):e,ig=e=>JSON.stringify(dA(e)),Sp=(e,t)=>ig(e)===ig(t);var ct=e=>Number.isSafeInteger(e);var tt=e=>e.start+e.duration,uA=(e,t)=>e.start<tt(t)&&t.start<tt(e),pA=e=>e.numerator/e.denominator,ML=(e,t)=>{let n=e<0n!=t<0n,r=e<0n?-e:e,i=t<0n?-t:t,o=r/i,s=r%i*2n>=i?o+1n:o;return Number(n?-s:s)},NL=(...e)=>e.every(t=>Number.isSafeInteger(t))&&e.at(-1)!==0,ja=(e,t)=>NL(e,t.denominator,t.numerator)?ML(BigInt(e)*BigInt(t.denominator),BigInt(t.numerator)):Number.NaN,wL=(e,t)=>NL(e,t.numerator,t.denominator)?ML(BigInt(e)*BigInt(t.numerator),BigInt(t.denominator)):Number.NaN;var kL={video:0,text:1,audio:2},we=e=>e.kind==="media",OL=e=>e.kind==="text",Ci=e=>Object.values(e.tracksById).sort((t,n)=>kL[t.kind]-kL[n.kind]||t.order-n.order||Tn(t.trackId,n.trackId)),ht=(e,t)=>hA(Object.values(e.clipsById).filter(n=>n.trackId===t)),lA=e=>Ci(e).filter(t=>t.kind==="video").sort((t,n)=>t.order-n.order||Tn(t.trackId,n.trackId)),mA=e=>{let t=e.tracksById[e.primaryVideoTrackId];return(t==null?void 0:t.kind)==="video"?t:void 0};var fA=e=>Ci(e).filter(t=>t.kind==="audio").sort((t,n)=>t.order-n.order||Tn(t.trackId,n.trackId)),LL=e=>Ci(e).filter(t=>t.kind==="text").sort((t,n)=>t.order-n.order||Tn(t.trackId,n.trackId));var Ai=(e,t)=>e.tracksById[t],Ha=(e,t)=>{let n=e.clipsById[t],r=n?e.tracksById[n.trackId]:void 0;return n&&r?{clip:n,track:r}:void 0},bp=(e,t)=>{let n=Ha(e,t);return n&&we(n.clip)?{clip:n.clip,track:n.track}:void 0},FL=bp,BL=(e,t)=>{let n=Ha(e,t);return n&&OL(n.clip)?{clip:n.clip,track:n.track}:void 0},Nr=(e,t)=>Object.values(e.clipsById).filter(n=>OL(n)&&(t===void 0||n.trackId===t)).sort((n,r)=>n.timelineRange.start-r.timelineRange.start||Tn(n.clipId,r.clipId));var hA=e=>[...e].sort((t,n)=>t.timelineRange.start-n.timelineRange.start||Tn(t.clipId,n.clipId)),gA=e=>{let t=0;for(let n of Ci(e))if(!(!n.enabled||n.kind==="text"))for(let r of ht(e,n.trackId))we(r)&&r.enabled&&(t=Math.max(t,tt(r.timelineRange)));return t},yA=e=>Object.values(e.clipsById).reduce((t,n)=>we(n)?Math.max(t,tt(n.timelineRange)):t,0);function N(e){return e==null||typeof e!="object"?e:typeof globalThis.structuredClone=="function"?globalThis.structuredClone(e):JSON.parse(JSON.stringify(e))}var Cp=e=>N(e);var Use={fadeInDuration:0,fadeOutDuration:0,gain:1,muted:!1};var Vse={audio:{channels:2,sampleRate:48e3},backgroundColor:"#000000",frameRate:{denominator:1,numerator:30},height:1920,width:1080};var TA=()=>({...Use});var UL=({draftId:e,nowMs:t=0,output:n=Vse,revision:r=1,primaryVideoTrackId:i="video_primary"})=>{let o={enabled:!0,kind:"video",locked:!1,order:0,trackId:i};return{clipsById:{},createdAtMs:t,draftId:e,output:{...n,audio:{...n.audio},frameRate:{...n.frameRate}},primaryVideoTrackId:i,revision:r,schemaVersion:ir,sources:{},timebase:{rounding:"half_away_from_zero",ticksPerSecond:1e6},tracksById:{[o.trackId]:o},updatedAtMs:t}};var VL=()=>({changedEntityIds:[],dirtyRanges:[],entityEvents:[]}),Ap=(e,t)=>(e.changedEntityIds.push(...t.changedEntityIds),e.dirtyRanges.push(...t.dirtyRanges),e.entityEvents.push(...t.entityEvents),e),qL=e=>({changedEntityIds:[...new Set(e.changedEntityIds)],dirtyRanges:e.dirtyRanges,entityEvents:e.entityEvents});var qse="3.0",Kse="4.0",Oc=e=>!!(e&&typeof e=="object"&&!Array.isArray(e)),KL=e=>Object.values(e).some(t=>Oc(t)&&t.kind==="text");function jL(e){return Oc(e)?Object.fromEntries(Object.entries(e).map(([t,n])=>{if(!Oc(n))return[t,n];let{version:r,...i}=n;return[t,i]})):e}function HL(e){return!Oc(e)||e.schemaVersion===ir?e:e.schemaVersion===Kse?{...e,schemaVersion:ir,sources:jL(e.sources)}:e.schemaVersion!==qse||!Oc(e.tracksById)||!Oc(e.clipsById)||KL(e.tracksById)||KL(e.clipsById)?e:{...e,schemaVersion:ir,sources:jL(e.sources)}}var j=(e,t,n,r)=>e.push({code:t,message:r,path:n}),Sn=e=>typeof e=="string"&&e.trim().length>0,De=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Ip=e=>typeof e=="number"&&ct(e),bo=(e,t)=>{let n=new Set(t);return Object.keys(e).every(r=>n.has(r))},Rp=(e,t)=>t.every(n=>Object.prototype.hasOwnProperty.call(e,n));function og(e,t,n,r){return!De(e)||!Ip(e.start)||e.start<0||!Ip(e.duration)||e.duration<=0?(j(r,n,t,"Range must use non-negative integer start and positive integer duration"),!1):Number.isSafeInteger(tt(e))?!0:(j(r,n,t,"Range end exceeds the safe integer domain"),!1)}function jse(e,t,n){if(!De(e))return j(n,"INVALID_RATE",t,"Playback rate must be a 0.25x-4x positive rational"),!1;let r=e.rate;return e.direction!=="forward"||e.pitchMode!=="preserve"||!De(r)||!Ip(r.numerator)||!Ip(r.denominator)||r.numerator<=0||r.denominator<=0||pA(r)<.25||pA(r)>4?(j(n,"INVALID_RATE",t,"Playback rate must be a 0.25x-4x positive rational"),!1):!0}function $L(e,t,n){if(!De(e)||!["contain","cover","fill"].includes(e.fit)||!De(e.transform)){j(n,"INVALID_DRAFT",t,"Video-track clips require a supported fit and transform");return}let{transform:r}=e;if(!De(r.translation)||!De(r.scale)){j(n,"INVALID_DRAFT",`${t}.transform`,"Transform scale and translation are required");return}[r.translation.x,r.translation.y,r.scale.x,r.scale.y,r.rotationDeg].some(o=>!Number.isFinite(o))&&j(n,"INVALID_DRAFT",`${t}.transform`,"Transform values must be finite"),(typeof r.flipX!="boolean"||typeof r.flipY!="boolean")&&j(n,"INVALID_DRAFT",`${t}.transform`,"Transform flip values must be boolean")}function YL(e,t,n,r){if(!De(e)){j(r,"INVALID_GAIN",n,"Audio gain must be in the inclusive range 0..1");return}let i=e;if(!Number.isFinite(i.gain)||i.gain<0||i.gain>1){j(r,"INVALID_GAIN",n,"Audio gain must be in the inclusive range 0..1");return}typeof i.muted!="boolean"&&j(r,"INVALID_DRAFT",`${n}.muted`,"Audio muted must be boolean");for(let[o,a]of[["fadeInDuration",i.fadeInDuration],["fadeOutDuration",i.fadeOutDuration]])(!ct(a)||a<0||a>t)&&j(r,"INVALID_FADE",`${n}.${o}`,"Fade duration must be an integer within clip duration")}var XL=["background","bold","fill","font","fontSizePx","italic","letterSpacing","lineSpacing","stroke"],WL=["align","centerX","centerY","maxWidth"],QL=/^#[0-9A-F]{6}$/;function JL(e,t,n){return!De(e)||!bo(e,["alpha","color"])||!Rp(e,["alpha","color"])||!QL.test(e.color)||typeof e.alpha!="number"||!Number.isFinite(e.alpha)||e.alpha<0||e.alpha>1?(j(n,"INVALID_DRAFT",t,"Text paint requires #RRGGBB color and alpha in 0..1"),!1):!0}function Hse(e,t,n){if(!De(e)||!bo(e,["effectId","family","resourceId","resourceType","version"])||!Rp(e,["family"])||!Sn(e.family))return j(n,"INVALID_DRAFT",t,"Text font requires a non-empty family"),!1;let r=[e.effectId,e.resourceId,e.resourceType,e.version];return r.some(o=>o!==void 0)&&!r.every(Sn)?(j(n,"INVALID_DRAFT",t,"Text resource font requires effectId, resourceId, resourceType and version together"),!1):!0}function $se(e,t,n){return!De(e)||!bo(e,["alpha","color","widthPx"])||!Rp(e,["alpha","color","widthPx"])||!QL.test(e.color)||typeof e.widthPx!="number"||!Number.isFinite(e.widthPx)||e.widthPx<0||typeof e.alpha!="number"||!Number.isFinite(e.alpha)||e.alpha<0||e.alpha>1?(j(n,"INVALID_DRAFT",t,"Text stroke requires #RRGGBB color, non-negative width and alpha in 0..1"),!1):!0}function ZL(e,t,n,r){if(!De(e)||!bo(e,XL)||!r&&!Rp(e,XL))return j(n,"INVALID_DRAFT",t,"Text style contains unsupported or missing fields"),!1;let i=e,o=!0,a=(s,c)=>{j(n,"INVALID_DRAFT",`${t}.${s}`,c),o=!1};return"font"in e&&!Hse(i.font,`${t}.font`,n)&&(o=!1),"fontSizePx"in e&&(!Number.isFinite(i.fontSizePx)||i.fontSizePx<=0)&&a("fontSizePx","Text fontSizePx must be positive and finite"),"bold"in e&&typeof i.bold!="boolean"&&a("bold","Text bold must be boolean"),"italic"in e&&typeof i.italic!="boolean"&&a("italic","Text italic must be boolean"),"fill"in e&&!JL(i.fill,`${t}.fill`,n)&&(o=!1),"background"in e&&!JL(i.background,`${t}.background`,n)&&(o=!1),"letterSpacing"in e&&!Number.isFinite(i.letterSpacing)&&a("letterSpacing","Text letterSpacing must be finite"),"lineSpacing"in e&&(!Number.isFinite(i.lineSpacing)||i.lineSpacing<=-1)&&a("lineSpacing","Text lineSpacing must be finite and greater than -1"),"stroke"in e&&!$se(i.stroke,`${t}.stroke`,n)&&(o=!1),o}function e1(e,t,n,r){if(!De(e)||!bo(e,WL)||!r&&!Rp(e,WL))return j(n,"INVALID_DRAFT",t,"Text layout contains unsupported or missing fields"),!1;let i=e,o=!0;for(let a of["centerX","centerY","maxWidth"])a in e&&(!Number.isFinite(i[a])||i[a]<0||i[a]>1)&&(j(n,"INVALID_DRAFT",`${t}.${a}`,`Text ${a} must be finite in 0..1`),o=!1);return"align"in e&&!["center","end","start"].includes(i.align)&&(j(n,"INVALID_DRAFT",`${t}.align`,"Text align must be start, center or end"),o=!1),o}function Yse(e,t,n){(!bo(e,["defaultLayout","defaultStyle","enabled","extensions","kind","locked","order","role","trackId"])||e.role!=="subtitle")&&j(n,"INVALID_DRAFT",t,"Text track contains unsupported fields or role"),ZL(e.defaultStyle,`${t}.defaultStyle`,n,!1),e1(e.defaultLayout,`${t}.defaultLayout`,n,!1)}function Xse(e,t,n,r){(!bo(t,["clipId","enabled","extensions","kind","layout","style","text","timelineRange","trackId"])||e.kind!=="text")&&j(r,"MEDIA_TYPE_MISMATCH",n,"Text clips require a text track and text-only fields"),(typeof t.enabled!="boolean"||typeof t.text!="string")&&j(r,"INVALID_DRAFT",n,"Text clip enabled state and text are required"),t.enabled&&typeof t.text=="string"&&!t.text.trim()&&j(r,"INVALID_DRAFT",`${n}.text`,"Enabled text clips require non-empty text"),og(t.timelineRange,`${n}.timelineRange`,"TIME_RANGE_INVALID",r),t.style!==void 0&&ZL(t.style,`${n}.style`,r,!0),t.layout!==void 0&&e1(t.layout,`${n}.layout`,r,!0)}function Wse(e,t,n,r,i,o){var p;if(t.kind==="text"){j(o,"MEDIA_TYPE_MISMATCH",r,"Text tracks accept only text clips");return}let a=og(n.timelineRange,`${r}.timelineRange`,"TIME_RANGE_INVALID",o);if(!Sn(n.sourceRef)){j(o,"SOURCE_NOT_FOUND",`${r}.sourceRef`,"Media clip sourceRef must be non-empty");return}let s=e[n.sourceRef];if(!De(s)){j(o,"SOURCE_NOT_FOUND",`${r}.sourceRef`,"Media clip sourceRef must resolve to a source");return}if(t.kind==="video"&&s.mediaType==="audio"&&j(o,"MEDIA_TYPE_MISMATCH",r,"Video tracks accept only video or image sources"),t.kind==="audio"&&s.mediaType!=="audio"&&j(o,"MEDIA_TYPE_MISMATCH",r,"Audio tracks accept only audio sources"),s.mediaType==="image"){(n.sourceRange!==void 0||n.playback!==void 0||n.audio!==void 0)&&j(o,"IMAGE_PLAYBACK_UNSUPPORTED",r,"Image clips cannot contain playback fields"),$L(n.frame,`${r}.frame`,o);return}let c=og(n.sourceRange,`${r}.sourceRange`,"SOURCE_RANGE_INVALID",o),d=jse(n.playback,`${r}.playback`,o);if(c&&d&&a){ja(n.sourceRange.duration,n.playback.rate)!==n.timelineRange.duration&&j(o,"DURATION_RATE_MISMATCH",r,"Timeline duration must match source range and rate");let f=(p=i.sourceDurations)==null?void 0:p[n.sourceRef];f!==void 0&&tt(n.sourceRange)>f&&j(o,"SOURCE_RANGE_INVALID",`${r}.sourceRange`,"Source range exceeds media duration")}t.kind==="video"&&$L(n.frame,`${r}.frame`,o);let u=a?n.timelineRange.duration:0;t.kind==="audio"&&YL(n.audio,u,`${r}.audio`,o),t.kind==="video"&&s.mediaType==="video"&&n.audio!==void 0&&YL(n.audio,u,`${r}.audio`,o),t.kind==="audio"&&n.frame!==void 0&&j(o,"MEDIA_TYPE_MISMATCH",`${r}.frame`,"Audio clips cannot contain frame settings")}function Jse(e,t,n){let r=t.filter(i=>(e.kind==="text"||i.enabled)&&og(i.timelineRange,"","TIME_RANGE_INVALID",[])).sort((i,o)=>i.timelineRange.start-o.timelineRange.start||Tn(i.clipId,o.clipId));for(let i=1;i<r.length;i+=1){if(!uA(r[i-1].timelineRange,r[i].timelineRange))continue;let o=r[i];j(n,e.kind==="text"?"TEXT_CLIP_OVERLAP":e.kind==="video"?"VIDEO_OVERLAP":"AUDIO_OVERLAP",`clipsById.${o.clipId}.timelineRange`,e.kind==="text"?"Text clips in the same track cannot overlap, including disabled clips":"Enabled media clips in the same track cannot overlap");return}}function Ya(e,t={}){var u,p,m,f,h,g,y,_,S,T,C,I,x;let n=[];if(!De(e))return j(n,"INVALID_DRAFT","draft","TimelineDraft must be an object"),n;let r=e;r.schemaVersion!==ir&&j(n,"SCHEMA_UNSUPPORTED","schemaVersion","Only TimelineDraft schema 5.0 is supported"),(((u=r.timebase)==null?void 0:u.ticksPerSecond)!==1e6||((p=r.timebase)==null?void 0:p.rounding)!=="half_away_from_zero")&&j(n,"TIMEBASE_UNSUPPORTED","timebase","TimelineDraft requires integer microseconds"),(!Sn(r.draftId)||!ct(r.revision)||r.revision<0)&&j(n,"INVALID_DRAFT","draftId","Draft identity and revision are required"),(!ct(r.createdAtMs)||r.createdAtMs<0||!ct(r.updatedAtMs)||r.updatedAtMs<0)&&j(n,"INVALID_DRAFT","updatedAtMs","Draft timestamps must be non-negative integers"),([(m=r.output)==null?void 0:m.width,(f=r.output)==null?void 0:f.height,(g=(h=r.output)==null?void 0:h.frameRate)==null?void 0:g.numerator,(_=(y=r.output)==null?void 0:y.frameRate)==null?void 0:_.denominator,(T=(S=r.output)==null?void 0:S.audio)==null?void 0:T.sampleRate,(I=(C=r.output)==null?void 0:C.audio)==null?void 0:I.channels].some(R=>!ct(R)||R<=0)||!Sn((x=r.output)==null?void 0:x.backgroundColor))&&j(n,"INVALID_DRAFT","output","Output dimensions and formats are required");let o=De(r.sources)?r.sources:{};if(De(r.sources)||j(n,"INVALID_DRAFT","sources","Sources must be an object"),Object.entries(o).forEach(([R,G])=>{if(!De(G)||!Sn(R)||!Sn(G.resourceId)||!Sn(G.resourceType)||!["audio","image","video"].includes(G.mediaType)){j(n,"INVALID_DRAFT",`sources.${R}`,"Source identity and media type are required");return}bo(G,["mediaType","resourceId","resourceType"])||j(n,"INVALID_DRAFT",`sources.${R}`,"Source contains unsupported fields")}),!De(r.tracksById))return j(n,"VIDEO_TRACK_REQUIRED","tracksById","TimelineDraft requires tracksById"),n;if(!De(r.clipsById))return j(n,"INVALID_DRAFT","clipsById","TimelineDraft requires clipsById"),n;let a=Object.entries(r.tracksById),s=Object.entries(r.clipsById),c={video:a.filter(([,R])=>De(R)&&R.kind==="video"),audio:a.filter(([,R])=>De(R)&&R.kind==="audio"),text:a.filter(([,R])=>De(R)&&R.kind==="text")};c.video.length<1&&j(n,"VIDEO_TRACK_REQUIRED","tracksById","At least one video track is required"),c.video.length>4&&j(n,"VIDEO_TRACK_FULL","tracksById","At most four video tracks are supported"),c.audio.length>6&&j(n,"AUDIO_LANE_FULL","tracksById","At most six audio tracks are supported"),c.text.length>1&&j(n,"INVALID_DRAFT","tracksById","At most one text track is supported"),a.forEach(([R,G])=>{let O=`tracksById.${R}`;if(!De(G)){j(n,"INVALID_DRAFT",O,"Track must be an object");return}let K=G;(!Sn(K.trackId)||K.trackId!==R)&&j(n,"DUPLICATE_ID",`${O}.trackId`,"Track ID must match its tracksById key"),(!["audio","text","video"].includes(K.kind)||!ct(K.order)||K.order<0||typeof K.enabled!="boolean"||typeof K.locked!="boolean"||K.kind==="audio"&&!Sn(K.role))&&j(n,"INVALID_DRAFT",O,"Track kind, order and state are invalid"),K.kind==="text"&&Yse(K,O,n);let H=s.flatMap(([,U])=>De(U)&&U.trackId===R?[U]:[]);Jse(K,H,n)});for(let R of["video","audio","text"]){let G=c[R].flatMap(([,O])=>De(O)&&Ip(O.order)?[O.order]:[]);new Set(G).size!==G.length&&j(n,"TRACK_ORDER_DUPLICATE","tracksById",`Order must be unique within ${R} tracks`)}let d=Sn(r.primaryVideoTrackId)?r.tracksById[r.primaryVideoTrackId]:void 0;return!d||!De(d)||d.kind!=="video"?j(n,"PRIMARY_VIDEO_TRACK_REQUIRED","primaryVideoTrackId","Primary video track is required"):d.order!==0&&j(n,"PRIMARY_VIDEO_TRACK_REQUIRED","primaryVideoTrackId","Primary video track order must be zero"),s.forEach(([R,G])=>{let O=`clipsById.${R}`;if(!De(G)){j(n,"INVALID_DRAFT",O,"Clip must be an object");return}let K=G;(!Sn(K.clipId)||K.clipId!==R)&&j(n,"DUPLICATE_ID",`${O}.clipId`,"Clip ID must match its clipsById key"),typeof K.enabled!="boolean"&&j(n,"INVALID_DRAFT",`${O}.enabled`,"Clip enabled must be boolean");let H=Sn(K.trackId)?r.tracksById[K.trackId]:void 0;if(!H||!De(H)){j(n,"TRACK_NOT_FOUND",`${O}.trackId`,"Clip trackId must resolve to a track");return}K.kind==="text"?Xse(H,K,O,n):K.kind==="media"?Wse(o,H,K,O,t,n):j(n,"INVALID_DRAFT",`${O}.kind`,"Clip kind must be media or text")}),n}var Pp=class extends Error{constructor(n,r,i="command"){super(r);this.name="TimelineCommandRejectedError",this.code=n,this.path=i}};function F(e,t,n){throw new Pp(e,t,n)}var Co=(e,t)=>{let n=Ha(e,t);return n||F("TARGET_NOT_FOUND",`Clip ${t} does not exist`,"payload.clipId"),n.track.locked&&F("TRACK_LOCKED",`Track ${n.track.trackId} is locked`,"payload.clipId"),n},Ao=(e,t)=>{let n=Ai(e,t);return n||F("TRACK_NOT_FOUND",`Track ${t} does not exist`,"payload.trackId"),n},Xa=(e,t)=>{let n=FL(e,t);return n||F("TARGET_NOT_FOUND",`Media clip ${t} does not exist`,"payload.clipId"),n.track.locked&&F("TRACK_LOCKED",`Track ${n.track.trackId} is locked`,"payload.clipId"),n},wr=(e,t,n=!1)=>{let r=e.tracksById[t];return(!r||r.kind!=="text")&&F("TRACK_NOT_FOUND",`Text track ${t} does not exist`,"payload.trackId"),r.locked&&!n&&F("TRACK_LOCKED",`Text track ${t} is locked`,"payload.trackId"),r},Dp=(e,t)=>{let n=BL(e,t);(!n||n.track.kind!=="text")&&F("TARGET_NOT_FOUND",`Text clip ${t} does not exist`,"payload.clipId");let r=wr(e,n.track.trackId);return{clip:n.clip,track:r}},SA=(e,t,n)=>{let r=e.sources[t];return r&&n&&!Sp(r,n)&&F("DUPLICATE_ID",`Source ${t} already has a different identity`,"payload.source"),!r&&!n&&F("SOURCE_NOT_FOUND",`Source ${t} does not exist`,"payload.sourceRef"),!r&&n&&(e.sources[t]=n),r??n},ie=(e,t)=>({...t,trackId:e}),$=(e,t)=>N({...e,commandId:t,commandSchemaVersion:1}),Zse=(e,t)=>e.start===t.start&&e.duration===t.duration,ece=e=>{if("clipId"in e.payload)return e.payload.clipId},t1=(e,t)=>Ai(e,t),n1=e=>{(!e||typeof e.commandId!="string"||e.commandId.trim().length===0)&&F("INVALID_COMMAND","commandId must be a non-empty string","commandId"),e.commandSchemaVersion!==1&&F("COMMAND_SCHEMA_UNSUPPORTED","Only command schema version 1 is supported","commandSchemaVersion"),(!e.payload||typeof e.payload!="object")&&F("INVALID_COMMAND","Command payload must be an object","payload")},r1=(e,t)=>{let n=t.preconditions;if(!n)return;let r=ece(t),i=r?Ha(e,r):void 0,o="trackId"in t.payload?t.payload.trackId:void 0,a=(i==null?void 0:i.track.trackId)??o;if(n.expectedDraftExtensions!==void 0&&!Sp(n.expectedDraftExtensions,e.extensions)&&F("PRECONDITION_FAILED","The draft extensions changed since the command was created","preconditions.expectedDraftExtensions"),n.expectedTrackId!==void 0&&n.expectedTrackId!==a&&F("PRECONDITION_FAILED","The target track changed since the command was created","preconditions.expectedTrackId"),n.expectedClip!==void 0&&(!i||!Sp(n.expectedClip,i.clip))&&F("PRECONDITION_FAILED","The target clip changed since the command was created","preconditions.expectedClip"),n.expectedTextTrack!==void 0&&(!a||!Sp(n.expectedTextTrack,e.tracksById[a]))&&F("PRECONDITION_FAILED","The text track changed since the command was created","preconditions.expectedTextTrack"),n.expectedSourceRef!==void 0&&n.expectedSourceRef!==(i&&we(i.clip)?i.clip.sourceRef:void 0)&&F("PRECONDITION_FAILED","The clip source changed since the command was created","preconditions.expectedSourceRef"),n.expectedTimelineRange!==void 0&&(!i||!Zse(n.expectedTimelineRange,i.clip.timelineRange))&&F("PRECONDITION_FAILED","The clip range changed since the command was created","preconditions.expectedTimelineRange"),n.expectedTrackEnabled!==void 0){let s=a?t1(e,a):void 0;(!s||s.enabled!==n.expectedTrackEnabled)&&F("PRECONDITION_FAILED","The target track changed since the command was created","preconditions.expectedTrackEnabled")}if(n.expectedTrackLocked!==void 0){let s=a?t1(e,a):void 0;(!s||s.locked!==n.expectedTrackLocked)&&F("PRECONDITION_FAILED","The target track lock state changed since the command was created","preconditions.expectedTrackLocked")}},i1=(e,t,n)=>{if(t.kind==="text"){e.kind!=="text"&&F("MEDIA_TYPE_MISMATCH","Text clips require a text track","payload.clip");return}e.kind==="text"&&F("MEDIA_TYPE_MISMATCH","Text tracks accept only text clips","payload.clip"),n||F("SOURCE_NOT_FOUND","Media clips require a source","payload.source"),e.kind==="video"&&n.mediaType!=="video"&&n.mediaType!=="image"&&F("MEDIA_TYPE_MISMATCH","Video tracks accept only image and video clips","payload.clip"),e.kind==="audio"&&n.mediaType!=="audio"&&F("MEDIA_TYPE_MISMATCH","Audio tracks accept only audio clips","payload.clip"),t.sourceRef.trim().length===0&&F("SOURCE_NOT_FOUND","Clip sourceRef must be non-empty","payload.clip.sourceRef")};function o1(e,t){let{height:n,width:r}=t.payload;(!ct(r)||r<=0)&&F("INVALID_COMMAND","Output width must be a positive integer","payload.width"),(!ct(n)||n<=0)&&F("INVALID_COMMAND","Output height must be a positive integer","payload.height");let i={height:e.output.height,width:e.output.width};return e.output.height=n,e.output.width=r,{effects:{changedEntityIds:[e.draftId],dirtyRanges:Ci(e).flatMap(o=>ht(e,o.trackId).map(a=>ie(o.trackId,a.timelineRange))),entityEvents:[]},inverseCommands:[$({payload:i,type:"set_output_size"},`inverse:${t.commandId}:output-size`)]}}var a1=(e,t)=>{let n=Co(e,t);return{effects:{changedEntityIds:[t],dirtyRanges:[ie(n.track.trackId,n.clip.timelineRange)],entityEvents:[{clipId:t,type:"clipUpdated"}]},location:n}},ag=(e,t)=>{let n=Xa(e,t);return{effects:{changedEntityIds:[t],dirtyRanges:[ie(n.track.trackId,n.clip.timelineRange)],entityEvents:[{clipId:t,type:"clipUpdated"}]},location:n}};function s1(e,t){let{clipId:n,extensions:r}=t.payload,{effects:i,location:o}=a1(e,n),a=N(o.clip.extensions);return r===void 0?delete o.clip.extensions:o.clip.extensions=N(r),{effects:i,inverseCommands:[$({payload:{clipId:n,extensions:a},preconditions:{expectedClip:N(o.clip),expectedTimelineRange:o.clip.timelineRange,expectedTrackId:o.track.trackId},type:"set_clip_extensions"},`inverse:${t.commandId}:extensions`)]}}function c1(e,t){let{extensions:n}=t.payload,r=N(e.extensions);return n===void 0?delete e.extensions:e.extensions=N(n),{effects:{changedEntityIds:[e.draftId],dirtyRanges:[],entityEvents:[]},inverseCommands:[$({payload:{extensions:r},preconditions:{expectedDraftExtensions:N(e.extensions)},type:"set_draft_extensions"},`inverse:${t.commandId}:draft-extensions`)]}}function d1(e,t){let{clipId:n,enabled:r}=t.payload,{effects:i,location:o}=a1(e,n),a=o.clip.enabled;return o.clip.enabled=r,{effects:i,inverseCommands:[$({payload:{clipId:n,enabled:a},preconditions:{expectedClip:N(o.clip),expectedTimelineRange:o.clip.timelineRange,expectedTrackId:o.track.trackId},type:"set_clip_enabled"},`inverse:${t.commandId}:enabled`)]}}function u1(e,t){let{clipId:n,transform:r}=t.payload,{effects:i,location:o}=ag(e,n);(o.track.kind!=="video"||!o.clip.frame)&&F("MEDIA_TYPE_MISMATCH","Only video-track clips have transforms","payload.clipId");let a=N(o.clip.frame.transform);return o.clip.frame.transform=N(r),{effects:i,inverseCommands:[$({payload:{clipId:n,transform:a},preconditions:{expectedClip:N(o.clip),expectedSourceRef:o.clip.sourceRef,expectedTimelineRange:o.clip.timelineRange,expectedTrackId:o.track.trackId},type:"set_clip_transform"},`inverse:${t.commandId}:transform`)]}}function p1(e,t){let{clipId:n,fit:r}=t.payload,{effects:i,location:o}=ag(e,n);(o.track.kind!=="video"||!o.clip.frame)&&F("MEDIA_TYPE_MISMATCH","Only video-track clips have fit settings","payload.clipId");let a=o.clip.frame.fit;return o.clip.frame.fit=r,{effects:i,inverseCommands:[$({payload:{clipId:n,fit:a},preconditions:{expectedClip:N(o.clip),expectedSourceRef:o.clip.sourceRef,expectedTimelineRange:o.clip.timelineRange,expectedTrackId:o.track.trackId},type:"set_clip_fit"},`inverse:${t.commandId}:fit`)]}}function l1(e,t){let{audio:n,clipId:r}=t.payload,{effects:i,location:o}=ag(e,r),a=e.sources[o.clip.sourceRef];(o.track.kind!=="video"||(a==null?void 0:a.mediaType)!=="video")&&F("MEDIA_TYPE_MISMATCH","Original audio belongs only to video clips on video tracks","payload.clipId");let s=N(o.clip.audio);return n===void 0?delete o.clip.audio:o.clip.audio=N(n),{effects:i,inverseCommands:[$({payload:{audio:s,clipId:r},preconditions:{expectedClip:N(o.clip),expectedSourceRef:o.clip.sourceRef,expectedTimelineRange:o.clip.timelineRange,expectedTrackId:o.track.trackId},type:"set_original_audio"},`inverse:${t.commandId}:original-audio`)]}}var bA=(e,t)=>{let{effects:n,location:r}=ag(e,t);if(!r.clip.audio){let i=e.sources[r.clip.sourceRef];return(r.track.kind!=="video"||(i==null?void 0:i.mediaType)!=="video")&&F("MEDIA_TYPE_MISMATCH","The target clip does not have an audio channel","payload.clipId"),r.clip.audio=TA(),{audio:r.clip.audio,effects:n,implicit:!0,location:r}}return{audio:r.clip.audio,effects:n,implicit:!1,location:r}},CA=(e,t,n)=>$({payload:{clipId:t},preconditions:{expectedClip:N(n.clip)},type:"set_original_audio"},e);function m1(e,t){let{clipId:n,gain:r}=t.payload,{audio:i,effects:o,implicit:a,location:s}=bA(e,n),c=i.gain;return i.gain=r,{effects:o,inverseCommands:[a?CA(`inverse:${t.commandId}:volume`,n,s):$({payload:{clipId:n,gain:c},preconditions:{expectedClip:N(s.clip)},type:"set_audio_volume"},`inverse:${t.commandId}:volume`)]}}function f1(e,t){let{clipId:n,muted:r}=t.payload,{audio:i,effects:o,implicit:a,location:s}=bA(e,n),c=i.muted;return i.muted=r,{effects:o,inverseCommands:[a?CA(`inverse:${t.commandId}:mute`,n,s):$({payload:{clipId:n,muted:c},preconditions:{expectedClip:N(s.clip)},type:"set_audio_mute"},`inverse:${t.commandId}:mute`)]}}function h1(e,t){let{clipId:n,fadeInDuration:r,fadeOutDuration:i}=t.payload,{audio:o,effects:a,implicit:s,location:c}=bA(e,n),d={fadeInDuration:o.fadeInDuration,fadeOutDuration:o.fadeOutDuration};return o.fadeInDuration=r,o.fadeOutDuration=i,{effects:a,inverseCommands:[s?CA(`inverse:${t.commandId}:fade`,n,c):$({payload:{clipId:n,...d},preconditions:{expectedClip:N(c.clip)},type:"set_audio_fade"},`inverse:${t.commandId}:fade`)]}}function g1(e,t){let{enabled:n,trackId:r}=t.payload,i=Ao(e,r),o=ht(e,r),a=i.enabled;return i.enabled=n,{effects:{changedEntityIds:[r,...o.map(s=>s.clipId)],dirtyRanges:o.map(s=>ie(r,s.timelineRange)),entityEvents:[{enabled:n,trackId:r,type:"trackUpdated"}]},inverseCommands:[$({payload:{enabled:a,trackId:r},preconditions:{expectedTrackEnabled:n,expectedTrackId:r},type:"set_track_enabled"},`inverse:${t.commandId}:track-enabled`)]}}function y1(e,t){let{locked:n,trackId:r}=t.payload,i=Ao(e,r),o=i.locked;return i.locked=n,{effects:{changedEntityIds:[r],dirtyRanges:[],entityEvents:[{locked:n,trackId:r,type:"trackUpdated"}]},inverseCommands:[$({payload:{locked:o,trackId:r},preconditions:{expectedTrackId:r,expectedTrackLocked:n},type:"set_track_locked"},`inverse:${t.commandId}:track-locked`)]}}var AA=(e,t)=>t.map(n=>ie(e,n.timelineRange));function _1(e,t){let{style:n,trackId:r}=t.payload,i=wr(e,r),o=N(i.defaultStyle);i.defaultStyle=N(n);let a=Nr(e,r);return{effects:{changedEntityIds:[r,...a.map(s=>s.clipId)],dirtyRanges:AA(r,a),entityEvents:[{enabled:i.enabled,trackId:r,type:"trackUpdated"}]},inverseCommands:[$({payload:{style:o,trackId:r},preconditions:{expectedTextTrack:N(i)},type:"set_text_track_default_style"},`inverse:${t.commandId}:text-default-style`)]}}function T1(e,t){let{layout:n,trackId:r}=t.payload,i=wr(e,r),o=N(i.defaultLayout);i.defaultLayout=N(n);let a=Nr(e,r);return{effects:{changedEntityIds:[r,...a.map(s=>s.clipId)],dirtyRanges:AA(r,a),entityEvents:[{enabled:i.enabled,trackId:r,type:"trackUpdated"}]},inverseCommands:[$({payload:{layout:o,trackId:r},preconditions:{expectedTextTrack:N(i)},type:"set_text_track_default_layout"},`inverse:${t.commandId}:text-default-layout`)]}}function S1(e,t){let{clipId:n,text:r}=t.payload,{clip:i,track:o}=Dp(e,n),a=i.text;return i.text=r,{effects:{changedEntityIds:[o.trackId,n],dirtyRanges:[ie(o.trackId,i.timelineRange)],entityEvents:[{clipId:n,type:"clipUpdated"}]},inverseCommands:[$({payload:{clipId:n,text:a},preconditions:{expectedClip:N(i),expectedTrackId:o.trackId},type:"set_text_clip_text"},`inverse:${t.commandId}:text-clip-text`)]}}function b1(e,t){let{clipId:n,enabled:r}=t.payload,{clip:i,track:o}=Dp(e,n),a=i.enabled;return i.enabled=r,{effects:{changedEntityIds:[o.trackId,n],dirtyRanges:[ie(o.trackId,i.timelineRange)],entityEvents:[{clipId:n,type:"clipUpdated"}]},inverseCommands:[$({payload:{clipId:n,enabled:a},preconditions:{expectedClip:N(i),expectedTrackId:o.trackId},type:"set_text_clip_enabled"},`inverse:${t.commandId}:text-clip-enabled`)]}}function C1(e,t){let{clipId:n,style:r}=t.payload,{clip:i,track:o}=Dp(e,n),a=N(i.style);return r===void 0?delete i.style:i.style=N(r),{effects:{changedEntityIds:[o.trackId,n],dirtyRanges:[ie(o.trackId,i.timelineRange)],entityEvents:[{clipId:n,type:"clipUpdated"}]},inverseCommands:[$({payload:{clipId:n,style:a},preconditions:{expectedClip:N(i),expectedTrackId:o.trackId},type:"set_text_clip_style"},`inverse:${t.commandId}:text-clip-style`)]}}function A1(e,t){let{clipId:n,layout:r}=t.payload,{clip:i,track:o}=Dp(e,n),a=N(i.layout);return r===void 0?delete i.layout:i.layout=N(r),{effects:{changedEntityIds:[o.trackId,n],dirtyRanges:[ie(o.trackId,i.timelineRange)],entityEvents:[{clipId:n,type:"clipUpdated"}]},inverseCommands:[$({payload:{clipId:n,layout:a},preconditions:{expectedClip:N(i),expectedTrackId:o.trackId},type:"set_text_clip_layout"},`inverse:${t.commandId}:text-clip-layout`)]}}function I1(e,t){let{style:n,trackId:r}=t.payload;wr(e,r);let i=Nr(e,r),o=Object.fromEntries(i.map(a=>[a.clipId,N(a.style)]));return i.forEach(a=>{a.style=tce(a.style,n)}),{effects:{changedEntityIds:[r,...i.map(a=>a.clipId)],dirtyRanges:AA(r,i),entityEvents:i.map(a=>({clipId:a.clipId,type:"clipUpdated"}))},inverseCommands:i.map(a=>$({payload:{clipId:a.clipId,style:o[a.clipId]},type:"set_text_clip_style"},`inverse:${t.commandId}:restore-text-style:${a.clipId}`))}}var tce=(e,t)=>({...e,...t,...t.stroke===void 0?{}:{stroke:{...e==null?void 0:e.stroke,...t.stroke}}});var sg=e=>({changedEntityIds:e.changedEntityIds??[],dirtyRanges:e.dirtyRanges??[],entityEvents:e.entityEvents??[]}),IA=(e,t)=>t.map(n=>ie(e,n.timelineRange));function v1(e,t){let n=N(t.payload.track);return Ai(e,n.trackId)&&F("DUPLICATE_ID",`Track ${n.trackId} already exists`,"payload.track.trackId"),n.kind!=="text"&&F("INVALID_COMMAND","Inserted tracks must be text tracks","payload.track"),LL(e).length>=1&&F("INVALID_COMMAND","The maximum number of text tracks has been reached","payload.track"),e.tracksById[n.trackId]=n,{effects:sg({changedEntityIds:[n.trackId],entityEvents:[{trackId:n.trackId,type:"trackCreated"}]}),inverseCommands:[$({payload:{trackId:n.trackId},type:"remove_text_track"},`inverse:${t.commandId}:remove-text-track`)]}}function x1(e,t){let n=N(wr(e,t.payload.trackId,!0)),r=Nr(e,n.trackId).map(N);return r.forEach(i=>delete e.clipsById[i.clipId]),delete e.tracksById[n.trackId],{effects:sg({changedEntityIds:[n.trackId,...r.map(i=>i.clipId)],dirtyRanges:IA(n.trackId,r),entityEvents:[...r.map(i=>({clipId:i.clipId,trackId:n.trackId,type:"clipDeleted"})),{trackId:n.trackId,type:"trackDeleted"}]}),inverseCommands:[$({payload:{track:n},type:"insert_text_track"},`inverse:${t.commandId}:restore-text-track`),...r.map(i=>$({payload:{clip:i,trackId:n.trackId},type:"insert_clip"},`inverse:${t.commandId}:restore-text-clip:${i.clipId}`))]}}function R1(e,t){let{clipsById:n,trackId:r}=t.payload;wr(e,r);let i=Object.fromEntries(Nr(e,r).map(d=>[d.clipId,N(d)]));Object.keys(n).forEach(d=>{let u=e.clipsById[d];u&&(u.kind!=="text"||u.trackId!==r)&&F("DUPLICATE_ID",`Clip ${d} already exists`,"payload.clipsById")}),Object.keys(i).forEach(d=>delete e.clipsById[d]),Object.entries(n).forEach(([d,u])=>{e.clipsById[d]=N({...u,clipId:d,kind:"text",trackId:r})});let o=Nr(e,r),a=[...new Set([...Object.keys(i),...o.map(d=>d.clipId)])],s=new Set(Object.keys(i)),c=new Set(o.map(d=>d.clipId));return{effects:sg({changedEntityIds:[r,...a],dirtyRanges:[...IA(r,Object.values(i)),...IA(r,o)],entityEvents:a.map(d=>s.has(d)?c.has(d)?{clipId:d,type:"clipUpdated"}:{clipId:d,trackId:r,type:"clipDeleted"}:{clipId:d,trackId:r,type:"clipCreated"})}),inverseCommands:[$({payload:{clipsById:i,trackId:r},preconditions:{expectedTextTrack:N(wr(e,r,!0))},type:"replace_text_clips"},`inverse:${t.commandId}:restore-text-clips`)]}}function cg(e,t){let{rangesByClipId:n,trackId:r}=t.payload;wr(e,r);let i={};return Object.entries(n).forEach(([o,a])=>{let s=e.clipsById[o];(!s||s.kind!=="text"||s.trackId!==r)&&F("TARGET_NOT_FOUND",`Text clip ${o} does not exist in track ${r}`,"payload.rangesByClipId"),i[o]=N(s.timelineRange),s.timelineRange=N(a)}),{effects:sg({changedEntityIds:[r,...Object.keys(n)],dirtyRanges:Object.keys(n).flatMap(o=>[ie(r,i[o]),ie(r,n[o])]),entityEvents:Object.keys(n).map(o=>({clipId:o,type:"clipUpdated"}))}),inverseCommands:[$({payload:{rangesByClipId:i,trackId:r},type:"reflow_text_clips"},`inverse:${t.commandId}:reflow-text-clips`)]}}var Lc=e=>({changedEntityIds:e.changedEntityIds??[],dirtyRanges:e.dirtyRanges??[],entityEvents:e.entityEvents??[]});function P1(e,t){let n=N(t.payload.track);return Ai(e,n.trackId)&&F("DUPLICATE_ID",`Track ${n.trackId} already exists`,"payload.track.trackId"),n.kind!=="audio"&&F("AUDIO_TRACK_REQUIRED","Inserted tracks must be audio tracks","payload.track"),fA(e).length>=6&&F("AUDIO_LANE_FULL","The maximum number of audio tracks has been reached","payload.track"),e.tracksById[n.trackId]=n,{effects:Lc({changedEntityIds:[n.trackId],entityEvents:[{trackId:n.trackId,type:"trackCreated"}]}),inverseCommands:[$({payload:{trackId:n.trackId},type:"remove_audio_track"},`inverse:${t.commandId}:remove-track`)]}}function D1(e,t){let n=e.tracksById[t.payload.trackId];return(!n||n.kind!=="audio")&&F("AUDIO_TRACK_REQUIRED","Only audio tracks can be removed","payload.trackId"),ht(e,n.trackId).length>0&&F("INVALID_COMMAND","Only empty audio tracks can be removed","payload.trackId"),delete e.tracksById[n.trackId],{effects:Lc({changedEntityIds:[n.trackId],entityEvents:[{trackId:n.trackId,type:"trackDeleted"}]}),inverseCommands:[$({payload:{track:N(n)},type:"insert_audio_track"},`inverse:${t.commandId}:restore-track`)]}}function E1(e,t){let{clip:n,source:r,trackId:i}=t.payload;bp(e,n.clipId)&&F("DUPLICATE_ID",`Clip ${n.clipId} already exists`,"payload.clip.clipId");let o=Ao(e,i);o.locked&&F("TRACK_LOCKED",`Track ${o.trackId} is locked`,"payload.trackId");let a=N(n);a.trackId=i;let s=a.kind==="media"?SA(e,a.sourceRef,r?N(r):void 0):void 0;return i1(o,a,s),e.clipsById[a.clipId]=a,{effects:Lc({changedEntityIds:[a.clipId,i,...a.kind==="media"?[a.sourceRef]:[]],dirtyRanges:[ie(i,a.timelineRange)],entityEvents:[{clipId:a.clipId,trackId:i,type:"clipCreated"}]}),inverseCommands:[$({payload:{clipId:a.clipId},preconditions:{expectedClip:N(a),expectedTimelineRange:a.timelineRange,expectedTrackId:i},type:"remove_clip"},`inverse:${t.commandId}:remove`)]}}function M1(e,t){let n=Co(e,t.payload.clipId),r=N(n.clip),i=n.track.trackId,o=we(r)?e.sources[r.sourceRef]:void 0,a=o?N(o):void 0;delete e.clipsById[r.clipId];let s=we(r)&&!Object.values(e.clipsById).some(c=>we(c)&&c.sourceRef===r.sourceRef)?r.sourceRef:void 0;return s&&delete e.sources[s],{effects:Lc({changedEntityIds:[r.clipId,i,...s?[s]:[]],dirtyRanges:[ie(i,r.timelineRange)],entityEvents:[{clipId:r.clipId,trackId:i,type:"clipDeleted"}]}),inverseCommands:[$({payload:{clip:r,...s&&a?{source:a}:{},trackId:i},type:"insert_clip"},`inverse:${t.commandId}:insert`)]}}var nce=(e,t,n,r)=>{let i=wL(t,r);for(let o=-2;o<=2;o+=1){let a=i+o,s=e-a;if(a>0&&s>0&&ja(a,r)===t&&ja(s,r)===n)return a}},rce=(e,t,n)=>{(!e.sourceRange||!e.playback)&&F("INVALID_DRAFT","Timed clips require sourceRange and playback","payload.clipId");let r=nce(e.sourceRange.duration,t,n,e.playback.rate);return r===void 0&&F("TIME_RANGE_INVALID","The split point cannot be represented exactly at this playback rate","payload.atTimelineUs"),{left:{duration:r,start:e.sourceRange.start},right:{duration:e.sourceRange.duration-r,start:e.sourceRange.start+r}}};function N1(e,t){let{atTimelineUs:n,clipId:r,rightClipId:i}=t.payload,o=Co(e,r),a=N(o.clip),s=tt(a.timelineRange);(!ct(n)||n<=a.timelineRange.start||n>=s)&&F("TIME_RANGE_INVALID","Split point must be an integer strictly inside the clip","payload.atTimelineUs"),Ha(e,i)&&F("DUPLICATE_ID",`Clip ${i} already exists`,"payload.rightClipId");let c=n-a.timelineRange.start,d=s-n,u=N(a);if(o.clip.timelineRange.duration=c,u.clipId=i,u.timelineRange={duration:d,start:n},we(a)&&we(o.clip)&&we(u)&&a.sourceRange&&a.playback){let f=rce(a,c,d);o.clip.sourceRange=f.left,u.sourceRange=f.right}we(a)&&we(o.clip)&&we(u)&&a.audio&&(o.clip.audio.fadeInDuration=Math.min(a.audio.fadeInDuration,c),o.clip.audio.fadeOutDuration=0,u.audio.fadeInDuration=0,u.audio.fadeOutDuration=Math.min(a.audio.fadeOutDuration,d)),e.clipsById[u.clipId]=u;let p=o.track.trackId,m=[$({payload:{clipId:i},preconditions:{expectedSourceRef:we(u)?u.sourceRef:void 0,expectedTimelineRange:u.timelineRange,expectedTrackId:p},type:"remove_clip"},`inverse:${t.commandId}:remove-right`)];return we(a)&&a.audio&&m.push($({payload:{clipId:r,fadeInDuration:a.audio.fadeInDuration,fadeOutDuration:a.audio.fadeOutDuration},preconditions:{expectedClip:N(o.clip)},type:"set_audio_fade"},`inverse:${t.commandId}:restore-fades`)),m.push(we(a)?$({payload:{clipId:r,sourceRange:a.sourceRange,timelineRange:a.timelineRange},preconditions:{expectedSourceRef:we(o.clip)?o.clip.sourceRef:void 0,expectedTimelineRange:o.clip.timelineRange,expectedTrackId:p},type:"trim_clip"},`inverse:${t.commandId}:restore-left`):$({payload:{rangesByClipId:{[r]:a.timelineRange},trackId:p},preconditions:{expectedTrackId:p},type:"reflow_text_clips"},`inverse:${t.commandId}:restore-left`)),{effects:Lc({changedEntityIds:[r,i,p],dirtyRanges:[ie(p,a.timelineRange)],entityEvents:[{leftClipId:r,rightClipId:i,trackId:p,type:"clipSplit"},{fromClipId:r,reason:"split",toClipId:i,type:"clipIdRemap"}]}),inverseCommands:m}}function w1(e,t){let{clipId:n,replaceExistingSource:r=!1,source:i,sourceRange:o,sourceRef:a}=t.payload,s=Xa(e,n),c=s.clip.sourceRef,d=N(s.clip.sourceRange),u=e.sources[c],p=r&&a===c&&i!==void 0,m=p?N(i):SA(e,a,i?N(i):void 0);return u.mediaType!==m.mediaType&&F("MEDIA_TYPE_MISMATCH","Replacement source must use the same media type","payload.sourceRef"),p&&(e.sources[a]=m),s.clip.sourceRef=a,o!==void 0&&(s.clip.sourceRange=N(o)),{effects:Lc({changedEntityIds:[n,c,a],dirtyRanges:[ie(s.track.trackId,s.clip.timelineRange)],entityEvents:[{clipId:n,fromSourceRef:c,toSourceRef:a,type:"sourceReplaced"}]}),inverseCommands:[$({payload:{clipId:n,replaceExistingSource:p||void 0,source:p?N(u):void 0,sourceRange:d,sourceRef:c},preconditions:{expectedSourceRef:a,expectedTimelineRange:s.clip.timelineRange,expectedTrackId:s.track.trackId},type:"replace_source"},`inverse:${t.commandId}:replace`)]}}var dg=e=>({changedEntityIds:e.changedEntityIds??[],dirtyRanges:e.dirtyRanges??[],entityEvents:e.entityEvents??[]});function k1(e,t){let n=N(t.payload.track);return Ai(e,n.trackId)&&F("DUPLICATE_ID",`Track ${n.trackId} already exists`,"payload.track.trackId"),n.kind!=="video"&&F("VIDEO_TRACK_REQUIRED","Inserted tracks must be video tracks","payload.track"),lA(e).length>=4&&F("VIDEO_TRACK_FULL","The maximum number of video tracks has been reached","payload.track"),e.tracksById[n.trackId]=n,{effects:dg({changedEntityIds:[n.trackId],entityEvents:[{trackId:n.trackId,type:"trackCreated"}]}),inverseCommands:[$({payload:{trackId:n.trackId},type:"remove_video_track"},`inverse:${t.commandId}:remove-track`)]}}function O1(e,t){let n=e.tracksById[t.payload.trackId];return(!n||n.kind!=="video")&&F("VIDEO_TRACK_REQUIRED","Only video tracks can be removed","payload.trackId"),n.trackId===e.primaryVideoTrackId&&F("INVALID_COMMAND","The primary video track cannot be removed","payload.trackId"),ht(e,n.trackId).length>0&&F("INVALID_COMMAND","Only empty video tracks can be removed","payload.trackId"),delete e.tracksById[n.trackId],{effects:dg({changedEntityIds:[n.trackId],entityEvents:[{trackId:n.trackId,type:"trackDeleted"}]}),inverseCommands:[$({payload:{track:N(n)},type:"insert_video_track"},`inverse:${t.commandId}:restore-track`)]}}var ice=(e,t)=>{if(e.length!==t.length||new Set(e).size!==e.length)return!1;let n=new Set(t);return e.every(r=>n.has(r))};function L1(e,t){let n=lA(e),{orderedTrackIds:r}=t.payload;ice(r,n.map(o=>o.trackId))||F("INVALID_COMMAND","orderedTrackIds must contain every video track exactly once","payload.orderedTrackIds"),r[0]!==e.primaryVideoTrackId&&F("INVALID_COMMAND","The primary video track must remain at order zero","payload.orderedTrackIds");let i=n.map(o=>o.trackId);return r.forEach((o,a)=>{e.tracksById[o].order=a}),{effects:dg({changedEntityIds:r,entityEvents:r.map((o,a)=>({order:a,trackId:o,type:"trackUpdated"}))}),inverseCommands:[$({payload:{orderedTrackIds:i},type:"reorder_video_tracks"},`inverse:${t.commandId}:reorder-tracks`)]}}function F1(e,t){let n=e.tracksById[t.payload.trackId];(!n||n.kind!=="video")&&F("VIDEO_TRACK_REQUIRED","Primary track must be a video track","payload.trackId");let r=e.tracksById[e.primaryVideoTrackId];(!r||r.kind!=="video")&&F("PRIMARY_VIDEO_TRACK_REQUIRED","The draft primaryVideoTrackId must resolve to a video track","primaryVideoTrackId");let i=r.trackId,o=r.order;return r.order=n.order,n.order=o,e.primaryVideoTrackId=n.trackId,{effects:dg({changedEntityIds:[i,n.trackId],entityEvents:[{primary:!1,trackId:i,type:"trackUpdated"},{primary:!0,trackId:n.trackId,type:"trackUpdated"}]}),inverseCommands:[$({payload:{trackId:i},type:"set_primary_video_track"},`inverse:${t.commandId}:primary-track`)]}}function Ep(e,t,n,r){let i=ht(e,t.trackId),o=i.find(c=>c.clipId===n);if(!o)return;let a=tt(o.timelineRange),s=tt(r)-a;return{endDelta:s,followingClips:s===0?[]:i.filter(c=>c.clipId!==n&&c.timelineRange.start>=a),targetClip:o}}var Mp=e=>({changedEntityIds:e.changedEntityIds??[],dirtyRanges:e.dirtyRanges??[],entityEvents:e.entityEvents??[]}),vA=(e,t)=>{(!ct(e)||e<0)&&F("TIME_RANGE_INVALID","Timeline start must be a non-negative integer",t)};function B1(e,t){let{clipId:n,start:r}=t.payload;vA(r,"payload.start");let i=Co(e,n),o=N(i.clip.timelineRange);i.clip.timelineRange.start=r;let a=N(i.clip);return{effects:Mp({changedEntityIds:[n,i.track.trackId],dirtyRanges:[ie(i.track.trackId,o),ie(i.track.trackId,i.clip.timelineRange)],entityEvents:[{clipId:n,fromTrackId:i.track.trackId,toTrackId:i.track.trackId,type:"clipMoved"}]}),inverseCommands:[$({payload:{clipId:n,start:o.start},preconditions:{expectedClip:a,expectedTimelineRange:i.clip.timelineRange,expectedTrackId:i.track.trackId},type:"move_clip"},`inverse:${t.commandId}:move`)]}}function G1(e,t){let{clipId:n,sourceRange:r,timelineRange:i}=t.payload,o=Co(e,n),a=N(o.clip.timelineRange);if((!ct(i.start)||i.start<0||!ct(i.duration)||i.duration<=0||!Number.isSafeInteger(tt(i)))&&F("TIME_RANGE_INVALID","Clip range must use safe integer microseconds","payload.timelineRange"),!we(o.clip)){r!==void 0&&F("SOURCE_RANGE_INVALID","Text clips cannot have a source range","payload.sourceRange");let f=Ep(e,o.track,n,i),h={[n]:i};for(let g of(f==null?void 0:f.followingClips)??[])h[g.clipId]={...g.timelineRange,start:g.timelineRange.start+((f==null?void 0:f.endDelta)??0)};return cg(e,{...t,payload:{rangesByClipId:h,trackId:o.track.trackId},type:"reflow_text_clips"})}let s=e.sources[o.clip.sourceRef],c=N(o.clip.sourceRange);s.mediaType==="image"&&r!==void 0&&F("IMAGE_PLAYBACK_UNSUPPORTED","Image clips cannot be source-trimmed","payload.sourceRange"),s.mediaType!=="image"&&r===void 0&&F("SOURCE_RANGE_INVALID","Timed clips must provide the absolute source range","payload.sourceRange");let u=o.track.trackId===e.primaryVideoTrackId&&s.mediaType==="video"&&c!==void 0&&r!==void 0&&r.start!==c.start&&tt(r)===tt(c)?{...i,start:a.start}:i,p=o.track.trackId===e.primaryVideoTrackId||o.track.kind==="audio"?Ep(e,o.track,n,u):void 0;o.clip.timelineRange=N(u),s.mediaType==="image"?delete o.clip.sourceRange:o.clip.sourceRange=N(r);let m=((p==null?void 0:p.followingClips)??[]).map(f=>{let h=N(f.timelineRange);return f.timelineRange.start+=(p==null?void 0:p.endDelta)??0,{clip:f,previousRange:h}});return{effects:Mp({changedEntityIds:[n,...m.map(({clip:f})=>f.clipId),o.track.trackId],dirtyRanges:[ie(o.track.trackId,a),ie(o.track.trackId,u),...m.flatMap(({clip:f,previousRange:h})=>[ie(o.track.trackId,h),ie(o.track.trackId,f.timelineRange)])],entityEvents:[{clipId:n,type:"clipUpdated"},...m.map(({clip:f})=>({clipId:f.clipId,type:"clipUpdated"}))]}),inverseCommands:[$({payload:{clipId:n,sourceRange:c,timelineRange:a},preconditions:{expectedSourceRef:o.clip.sourceRef,expectedTimelineRange:o.clip.timelineRange,expectedTrackId:o.track.trackId},type:"trim_clip"},`inverse:${t.commandId}:trim`)]}}function z1(e,t){let{clipId:n,rate:r}=t.payload,i=Xa(e,n);(!i.clip.sourceRange||!i.clip.playback)&&F("IMAGE_PLAYBACK_UNSUPPORTED","Images do not support playback speed","payload.clipId");let o=N(i.clip.timelineRange),a=N(i.clip.playback.rate),s={...i.clip.timelineRange,duration:ja(i.clip.sourceRange.duration,r)},c=Ep(e,i.track,n,s);i.clip.playback.rate=N(r),i.clip.timelineRange=s;let d=((c==null?void 0:c.followingClips)??[]).map(u=>{let p=N(u.timelineRange);return u.timelineRange.start+=(c==null?void 0:c.endDelta)??0,{clip:u,previousTimelineRange:p}});return{effects:Mp({changedEntityIds:[n,...d.map(({clip:u})=>u.clipId),i.track.trackId],dirtyRanges:[ie(i.track.trackId,o),ie(i.track.trackId,i.clip.timelineRange),...d.flatMap(({clip:u,previousTimelineRange:p})=>[ie(i.track.trackId,p),ie(i.track.trackId,u.timelineRange)])],entityEvents:[{clipId:n,type:"clipUpdated"},...d.map(({clip:u})=>({clipId:u.clipId,type:"clipUpdated"}))]}),inverseCommands:[$({payload:{clipId:n,rate:a},preconditions:{expectedSourceRef:i.clip.sourceRef,expectedTimelineRange:i.clip.timelineRange,expectedTrackId:i.track.trackId},type:"set_clip_speed"},`inverse:${t.commandId}:speed`)]}}var oce=(e,t)=>{if(e.length!==t.length||new Set(e).size!==e.length)return!1;let n=new Set(t);return e.every(r=>n.has(r))};function U1(e,t){let{orderedClipIds:n,start:r,trackId:i}=t.payload,o=Ao(e,i);o.kind!=="video"&&F("VIDEO_TRACK_REQUIRED","Clip reordering requires a video track","payload.trackId"),o.locked&&F("TRACK_LOCKED",`Track ${o.trackId} is locked`,"payload.trackId");let a=ht(e,o.trackId);oce(n,a.map(p=>p.clipId))||F("INVALID_COMMAND","orderedClipIds must contain every clip in the video track exactly once","payload.orderedClipIds");let s=r??(a.length>0?Math.min(...a.map(p=>p.timelineRange.start)):0);vA(s,"payload.start");let c=new Map;a.forEach(p=>c.set(p.clipId,N(p.timelineRange)));let d=new Map(a.map(p=>[p.clipId,p])),u=s;return n.forEach(p=>{let m=d.get(p);m.timelineRange.start=u,u+=m.timelineRange.duration}),{effects:Mp({changedEntityIds:[o.trackId,...n],dirtyRanges:n.flatMap(p=>[ie(o.trackId,c.get(p)),ie(o.trackId,d.get(p).timelineRange)]),entityEvents:n.map(p=>({clipId:p,type:"clipUpdated"}))}),inverseCommands:n.map((p,m)=>$({payload:{clipId:p,start:c.get(p).start},preconditions:{expectedSourceRef:d.get(p).sourceRef,expectedTimelineRange:d.get(p).timelineRange,expectedTrackId:o.trackId},type:"move_clip"},`inverse:${t.commandId}:move:${m}`))}}function V1(e,t){let{clipId:n,start:r,targetTrackId:i}=t.payload;vA(r,"payload.start");let o=Xa(e,n),a=Ao(e,i);o.track.kind!==a.kind&&F("MEDIA_TYPE_MISMATCH","A clip can move only between tracks of the same kind","payload.targetTrackId"),a.locked&&F("TRACK_LOCKED",`Track ${a.trackId} is locked`,"payload.targetTrackId");let s=o.track.trackId,c=N(o.clip.timelineRange),d=o.clip;return d.trackId=i,d.timelineRange.start=r,{effects:Mp({changedEntityIds:[n,s,i],dirtyRanges:[ie(s,c),ie(i,d.timelineRange)],entityEvents:[{clipId:n,fromTrackId:s,toTrackId:i,type:"clipMoved"}]}),inverseCommands:[$({payload:{clipId:n,start:c.start,targetTrackId:s},preconditions:{expectedSourceRef:d.sourceRef,expectedTimelineRange:d.timelineRange,expectedTrackId:i},type:"move_clip_to_track"},`inverse:${t.commandId}:track`)]}}var de=e=>(t,n)=>e(t,n),ace={apply_text_style_to_all:de(I1),insert_audio_track:de(P1),insert_clip:de(E1),insert_text_track:de(v1),insert_video_track:de(k1),move_clip:de(B1),move_clip_to_track:de(V1),remove_clip:de(M1),remove_text_track:de(x1),remove_audio_track:de(D1),remove_video_track:de(O1),reorder_video_clips:de(U1),reorder_video_tracks:de(L1),replace_source:de(w1),replace_text_clips:de(R1),reflow_text_clips:de(cg),set_audio_fade:de(h1),set_audio_mute:de(f1),set_audio_volume:de(m1),set_clip_enabled:de(d1),set_clip_extensions:de(s1),set_draft_extensions:de(c1),set_clip_fit:de(p1),set_clip_speed:de(z1),set_clip_transform:de(u1),set_original_audio:de(l1),set_output_size:de(o1),set_primary_video_track:de(F1),set_text_clip_enabled:de(b1),set_text_clip_layout:de(A1),set_text_clip_style:de(C1),set_text_clip_text:de(S1),set_text_track_default_layout:de(T1),set_text_track_default_style:de(_1),set_track_enabled:de(g1),set_track_locked:de(y1),split_clip:de(N1),trim_clip:de(G1)};function xA(e,t){n1(t),r1(e,t);let n=ace[t.type];return n||F("COMMAND_TYPE_UNSUPPORTED","The command type is not supported","type"),n(e,t)}function q1(e){let t=mA(e);if(!t||t.locked)return[];let n=hA(ht(e,t.trackId));if(n.length===0)return[];let r=[],i=0,o=0;return n.forEach(a=>{let s=N(a.timelineRange),c=a.timelineRange.start+i;c>o&&(i-=c-o,c=o),c!==a.timelineRange.start&&(a.timelineRange.start=c,r.push({clipId:a.clipId,correctedRange:N(a.timelineRange),previousRange:s,sourceRef:a.sourceRef,trackId:t.trackId})),o=Math.max(o,tt(a.timelineRange))}),r}function K1(e){return e.length===0?{changedEntityIds:[],dirtyRanges:[],entityEvents:[]}:{changedEntityIds:[...new Set(e.flatMap(t=>[t.trackId,t.clipId]))],dirtyRanges:e.flatMap(t=>[ie(t.trackId,t.previousRange),ie(t.trackId,t.correctedRange)]),entityEvents:e.map(t=>({clipId:t.clipId,type:"clipUpdated"}))}}function j1(e,t){return e.map((n,r)=>$({payload:{clipId:n.clipId,start:n.previousRange.start},preconditions:{expectedSourceRef:n.sourceRef,expectedTimelineRange:n.correctedRange,expectedTrackId:n.trackId},type:"move_clip"},`inverse:${t}:primary-video-continuity:${r}`))}function H1(e,t){let n=[];for(let r of Nr(e)){let i=e.tracksById[r.trackId];if(!i||i.kind!=="text"||i.locked||!r.enabled||tt(r.timelineRange)<=t)continue;let o=N(r);r.timelineRange.start>=t?r.enabled=!1:r.timelineRange.duration=t-r.timelineRange.start,n.push({correctedClip:N(r),previousClip:o,trackId:i.trackId})}return n}function $1(e){return{changedEntityIds:[...new Set(e.flatMap(({correctedClip:t,trackId:n})=>[n,t.clipId]))],dirtyRanges:e.flatMap(({correctedClip:t,previousClip:n,trackId:r})=>[ie(r,n.timelineRange),ie(r,t.timelineRange)]),entityEvents:e.map(({correctedClip:t})=>({clipId:t.clipId,type:"clipUpdated"}))}}function Y1(e,t){return e.map(({correctedClip:n,previousClip:r,trackId:i},o)=>n.enabled!==r.enabled?$({payload:{clipId:n.clipId,enabled:r.enabled},preconditions:{expectedClip:n,expectedTrackId:i},type:"set_text_clip_enabled"},`inverse:${t}:text-media-bound:${o}`):$({payload:{rangesByClipId:{[n.clipId]:r.timelineRange},trackId:i},preconditions:{expectedTrackId:i},type:"reflow_text_clips"},`inverse:${t}:text-media-bound:${o}`))}var Np=(e,t,n,r,i)=>({changedEntityIds:[],dirtyRanges:[],draft:e,entityEvents:[],failedCommandId:i,inverseCommands:[],issues:r,newRevision:e.revision,ok:!1,rejectionCode:n,transactionId:t}),Wa=(e,t,n)=>({code:e,message:n,path:t}),sce=new Set(["insert_clip","move_clip","move_clip_to_track","remove_clip","reorder_video_clips","set_clip_speed","set_primary_video_track","split_clip","trim_clip"]),cce=(e,t,n)=>t.some(r=>r.type==="set_primary_video_track")?!0:t.some(r=>sce.has(r.type))?n.dirtyRanges.some(r=>r.trackId===e.primaryVideoTrackId):!1,dce=(e,t,n)=>{let r=new Set;for(let o of t.entityEvents)o.type==="clipDeleted"?r.add(o.trackId):(o.type==="trackCreated"||o.type==="trackDeleted")&&r.delete(o.trackId);let i=[];return r.forEach(o=>{let a=e.tracksById[o];if(!a||o===e.primaryVideoTrackId||ht(e,o).length>0)return;let s=a.kind==="video"?"remove_video_track":a.kind==="audio"?"remove_audio_track":"remove_text_track",c=xA(e,{commandId:`system:${n}:remove-empty-track:${o}`,commandSchemaVersion:1,payload:{trackId:o},type:s});Ap(t,c.effects),i.push(...c.inverseCommands)}),i},uce=(e,t)=>{if(t.draftId!==e.draftId)return Wa("DRAFT_ID_MISMATCH","draftId","Transaction draftId does not match the current draft");if(t.baseRevision!==e.revision)return Wa("STALE_REVISION","baseRevision","Transaction is based on a stale draft revision");if(!t.commands.length)return Wa("EMPTY_TRANSACTION","commands","A transaction must contain at least one command");if(t.committedAtMs!==void 0&&(!ct(t.committedAtMs)||t.committedAtMs<0))return Wa("INVALID_COMMAND","committedAtMs","committedAtMs must be a non-negative integer");let n=t.commands.map(r=>r.commandId);if(new Set(n).size!==n.length)return Wa("DUPLICATE_COMMAND_ID","commands","Command IDs must be unique within a transaction")};function RA(e,t,n={},r=n){let i=Ya(e,n);if(i.length>0)return Np(e,t.transactionId,i[0].code,i);let o=uce(e,t);if(o)return Np(e,t.transactionId,o.code,[o]);let a=Cp(e),s=yA(a);a.schemaVersion=ir;let c=VL(),d=[];for(let y of t.commands)try{let _=xA(a,N(y));Ap(c,_.effects),d=[..._.inverseCommands,...d]}catch(_){if(_ instanceof Pp){let T=Wa(_.code,_.path,_.message);return Np(e,t.transactionId,_.code,[T],y.commandId)}let S=Wa("INVALID_COMMAND","commands","Command payload could not be applied");return Np(e,t.transactionId,S.code,[S],y.commandId)}d=[...dce(a,c,t.transactionId),...d];let u=cce(a,t.commands,c)?q1(a):[];Ap(c,K1(u));let p=yA(a),m=t.commands.some(y=>y.type==="set_clip_speed"),f=p<s&&!m?H1(a,p):[];Ap(c,$1(f)),d=[...Y1(f,t.transactionId),...j1(u,t.transactionId),...d],a.revision=e.revision+1,a.updatedAtMs=t.committedAtMs??e.updatedAtMs;let h=Ya(a,r);return h.length>0?Np(e,t.transactionId,h[0].code,h):{...qL(c),draft:a,inverseCommands:d,newRevision:a.revision,ok:!0,rejectionCode:null,transactionId:t.transactionId}}var Ja="timeline-editor-sdk ",Int=`${Ja}performance`,vnt=`${Ja}clip-load`,xnt=`${Ja}error`,Rnt=`${Ja}media-diagnostic`;var Pnt=`${Ja}export`,Dnt=`${Ja}open`,Ent=`${Ja}preview-transform`;var Io="biz/timeline-composition",PA=Io,kr="biz/timeline-composition-draft";function DA(){return X.t("Pippit_xyqcanvas_timelinecomposition_node_title_videocomposition",{},"多轨道剪辑")}function gce(e){return{kind:"pippit-asset",pippitAssetId:e,schemaVersion:1}}function yce(e){return L(e)&&e.kind==="pippit-asset"&&Ne(e.pippitAssetId)&&e.pippitAssetId.length>0&&e.schemaVersion===1}function _ce(e){return L(e)&&B(e.title)}function vo(e){return L(e)&&e.version===1&&yce(e.draftRef)&&B(e.title)&&po(e)}function Fc(e){let t=HL(e);return Ya(t).length===0?t:void 0}function X1({draftAssetId:e,episodeIds:t,nodeId:n}){let r=DA(),i=Mh(t);return[{pippitAssetId:n,type:PA,content:{draftRef:gce(e),...i.length>0?{episodes:i}:{},title:r,version:1},extra:{}},{pippitAssetId:e,type:kr,content:UL({draftId:e}),extra:{sourceNodeId:n}}]}var wp={type:Io,validate:_ce,getDefaultSize:()=>({w:1200,h:232})};var Tce=["/content/generation","/content/data/generation"],Sce=["","/content","/content/data"],bce="generation requires field-level updates",Cce=2e3,kp=new Set;function W1(e){if(!Pe(e))return!1;let t=Pe(e.content)?e.content:e,n=Pe(t==null?void 0:t.data)?t.data:void 0;return(t==null?void 0:t.generation)!==void 0||(n==null?void 0:n.generation)!==void 0}function Ace(e,t){return t.op!=="replace"||!Pe(t.value)?!1:Tce.some(n=>t.path===n||t.path.startsWith(`${n}/`))?!0:Sce.includes(t.path)&&(W1(e.assets[t.assetId])||W1(t.value))}function J1(e,t,n,r){if(t.txId){let i=[e,t.txId,n.assetId,n.path,n.op].join("\0");if(kp.has(i))return;if(kp.add(i),kp.size>Cce){let o=kp.values().next().value;o!==void 0&&kp.delete(o)}}Au({action:e,category:"canvas_sync",context:{txId:t.txId,intent:t.intent,assetId:n.assetId,path:n.path,op:n.op,reason:r},packageName:"xyq-canvas-sdk",status:e==="canvas_generation_replace_report_only"?"failure":"log"})}function Ice(e){for(let t of e.patches){if(Ace(e.document,t)){J1("canvas_generation_replace_report_only",e,t,bce);continue}t.op==="replace"&&Pe(t.value)&&e.phase==="local"&&e.txId!==void 0&&J1("canvas_object_replace_report_only",e,t,"broad object replace")}}function vce(e){try{Ice(e)}catch{}}var Q1=(e,t)=>{if(e.source==="remote"){t();return}vce({document:e.prevState,patches:e.forwardPatches,txId:e.txId,intent:e.intent,phase:"local"}),t()};var xce="pippit:canvas:viewport-input-mode:v1";function Rce(){try{return Reflect.get(globalThis,"localStorage")??null}catch{return null}}function Z1(){var e;try{return((e=Rce())==null?void 0:e.getItem(xce))==="mouse"?"mouse":"trackpad"}catch{return"trackpad"}}function Pce(e){let t=[H0(e),D0(e),$O(e),f0(e),sS(e,{registry:KC()})];return()=>{for(let n of t.splice(0))n()}}function Dce(e="canvas_1",t){let n=rf();n.register(mo),n.register(fi),n.register(Nh),n.register(lo),n.register(hi),n.register(La),n.register(sp),n.register(pp),n.register(wp);let r=vu({getTelemetryContext:t,initialDocument:zs(e),middlewares:[Q1],registry:n});return EL(r),{dispose:Pce(r),store:r}}function eF({canvasId:e,telemetryContext:t}){let n=t,{dispose:r,store:i}=Dce(e,()=>n),o=wS({initialSnapConfig:xu(i.getRootCanvasContent().settings.snap),initialViewportInputMode:Z1()});return{store:i,runtime:o,dispose:r,setTelemetryContext:a=>{n=a}}}function tF({hasPendingLocalChanges:e,hasPendingLocalMediaUploads:t,isReady:n,syncState:r}){return r.phase==="error"?"error":r.phase==="offline"?"offline":n?e||t||r.phase==="flushing"?"saving":r.phase==="connecting"||r.phase==="syncing"||r.phase==="rebasing"?"syncing":"saved":"loading"}var ug=class{constructor(){this._outcomes=new Map;this._waiters=new Map}failPending(t){this._waiters.forEach(n=>{n.forEach(r=>{clearTimeout(r.timeout),r.reject(t)})}),this._waiters.clear()}record(t){for(this._outcomes.delete(t.transactionId),this._outcomes.set(t.transactionId,t),this._resolveWaiters(t);this._outcomes.size>1e3;){let n=this._outcomes.keys().next().value;if(typeof n!="string")break;this._outcomes.delete(n)}}wait(t,n=3e4){let r=this._outcomes.get(t);return r?Promise.resolve(r):new Promise((i,o)=>{let a={reject:o,resolve:i,timeout:setTimeout(()=>{this._deleteWaiter(t,a),o(new Error(`Timed out after ${n}ms waiting for canvas transaction ${t}`))},n)},s=this._waiters.get(t)??new Set;s.add(a),this._waiters.set(t,s)})}_deleteWaiter(t,n){let r=this._waiters.get(t);r==null||r.delete(n),(r==null?void 0:r.size)===0&&this._waiters.delete(t)}_resolveWaiters(t){let n=this._waiters.get(t.transactionId);n&&(this._waiters.delete(t.transactionId),n.forEach(r=>{clearTimeout(r.timeout),r.resolve(t)}))}};async function nF(e,t,n){e.start();let r=e.getSnapshot();(!n()||!r.isReady||!r.lifecycle.settled)&&await e.whenReady();let i=n();if(!i)throw new Error("Canvas runtime was disposed");await i.refreshAssets(t)}var Ece="xyq-canvas-sync",Mce=3e4,EA=new Set,MA=class{constructor(t,n){this._listeners=new Set;this._disposers=[];this._disposed=!1;this._uploadCleanupAttached=!1;this._pendingFlush=!1;this._rootPreviewAssetsSettled=!1;this._started=!1;this._transactionOutcomes=new ug;this.updateRuntimeConfig=t=>{this._disposed||(this._runtimeConfig=t,this._options.session.setTelemetryContext(t.telemetryContext),this._runReadyEffectsIfSyncAttached())};this.start=()=>{var t,n,r;if(this._disposed)throw new Error(((t=this._effects.disposedErrorMessages)==null?void 0:t.cannotStart)??"Cannot start a disposed canvas runtime");return this._started?this:(this._started=!0,this._options.session.setTelemetryContext(this._runtimeConfig.telemetryContext),this._attachStoreLifecycle(),this._attachSyncLifecycle(),this._attachUploadCleanup(),(r=(n=this._effects).configureGenerationRuntime)==null||r.call(n,this._options),this._runReadyEffectsIfSyncAttached(),this._syncGenerationRunsIfNeeded(),this)};this.getSnapshot=()=>this._snapshot;this.subscribe=t=>(this._listeners.add(t),()=>this._listeners.delete(t));this.flush=()=>{if(this._syncEngine){this._syncEngine.flush();return}this._pendingFlush=!0};this.whenReady=(t={})=>{var n;return this._disposed?Promise.reject(new Error(((n=this._effects.disposedErrorMessages)==null?void 0:n.wait)??"Canvas runtime was disposed")):(this.start(),this._waitFor(r=>r.isReady&&r.lifecycle.settled&&r.syncState.phase==="idle",t.timeoutMs))};this.refreshAssets=t=>nF(this,t,()=>this._syncEngine);this.waitUntilSaved=(t={})=>{var r;if(this._disposed)return Promise.reject(new Error(((r=this._effects.disposedErrorMessages)==null?void 0:r.wait)??"Canvas runtime was disposed"));this.start();let n=t.includeMediaUploads??!0;return this._waitFor(i=>i.isReady&&i.syncState.phase==="idle"&&!i.hasPendingLocalChanges&&(!n||!i.hasPendingLocalMediaUploads),t.timeoutMs)};this.waitForTransaction=(t,n={})=>{var r;return this._disposed?Promise.reject(new Error(((r=this._effects.disposedErrorMessages)==null?void 0:r.wait)??"Canvas runtime was disposed")):(this.start(),this._snapshot.syncState.phase==="error"?Promise.reject(this._snapshot.syncState.error):this._transactionOutcomes.wait(t,n.timeoutMs))};this.dispose=()=>{var t;if(!this._disposed){this._disposed=!0;for(let n of this._disposers.splice(0).reverse())n();this._syncEngine=void 0,this._transactionOutcomes.failPending(new Error(((t=this._effects.disposedErrorMessages)==null?void 0:t.wait)??"Canvas runtime was disposed"));for(let n of Array.from(this._listeners))n(this._snapshot);this._listeners.clear(),this._options.ownsSession&&this._options.session.dispose()}};this._handleSyncEvent=t=>{var n,r,i,o,a,s;if(!this._disposed){if(t.kind==="bootstrap-root-ready"){this._isRootReady=!0,this._lifecycle={phase:"root-ready",settled:!1},this._rootPreviewDocument=t.document,this._rootPreviewReadyNodeAssetIds=new Set,this._rootPreviewAssetsSettled=!1,this._publish(),(r=(n=this._options).onSyncEvent)==null||r.call(n,t);return}if(t.kind==="bootstrap-assets-ready"||t.kind==="bootstrap-assets-settled"){if(this._rootPreviewDocument=t.document,this._rootPreviewAssetsSettled=t.kind==="bootstrap-assets-settled",t.kind==="bootstrap-assets-ready"){this._lifecycle={phase:"hydrating",settled:!1};let c=this._rootPreviewReadyNodeAssetIds??new Set;t.readyAssetIds.forEach(d=>c.add(d)),this._rootPreviewReadyNodeAssetIds=c}this._publish(),(o=(i=this._options).onSyncEvent)==null||o.call(i,t);return}if((s=(a=this._options).onSyncEvent)==null||s.call(a,t),t.kind==="committed"?new Set([t.txId,...t.ackedTxIds??[]]).forEach(d=>{this._transactionOutcomes.record({status:"committed",transactionId:d})}):t.kind==="discarded"&&new Set([t.txId,...t.txIds]).forEach(d=>{this._transactionOutcomes.record({status:"discarded",transactionId:d,reason:t.reason})}),t.kind==="state-change"){t.state.phase==="error"&&this._transactionOutcomes.failPending(t.state.error),t.state.phase==="error"&&t.state.reason==="bootstrap-failed"&&(this._lifecycle={error:t.state.error,phase:"error",settled:!0},this._snapshot=this._createSnapshot(!1,t.state)),this._publish(t.state);return}if(t.kind==="outbound-change"||t.kind==="committed"||t.kind==="discarded"){this._publish();return}t.kind==="snapshot-applied"&&(this._isRootReady=!0,this._lifecycle={phase:"ready",settled:!0},EA.add(this._sessionKey),this._snapshot=this._createSnapshot(!0,this._snapshot.syncState),this._runReadyEffectsIfSyncAttached(),this._publish())}};this._options=t,this._effects=n,this._runtimeConfig={autoLayoutStrategies:t.autoLayoutStrategies,telemetryContext:t.telemetryContext},this.store=t.session.store,this.runtime=t.session.runtime;let r=!t.ownsSession&&EA.has(this._sessionKey);this._isRootReady=r,this._lifecycle={phase:r?"ready":"bootstrap-loading",settled:r},this._snapshot=this._createSnapshot(r,r?{phase:"idle"}:{phase:"connecting"})}get _readOnly(){return this._options.editable===!1}get _sessionKey(){return this._options.sessionKey??this._options.canvasId}_attachStoreLifecycle(){let t=n=>{this.runtime.setSnapConfig(xu(n)),n.enabled||this.runtime.clearSnapping()};t(this.store.getRootCanvasContent().settings.snap),this._disposers.push(this.store.subscribeSelector(n=>M(n).settings.snap,t,{equalityFn:MS})),this._readOnly?this._disposers.push(this.store.use(k0(this._options.onReadOnlyEditAttempt))):this._disposers.push(this.store.subscribe(()=>{this._publish(),this._syncGenerationRunsIfNeeded()}));for(let n of this._options.middlewares??[])this._disposers.push(this.store.use(n));this._readOnly&&this._disposers.push(this.store.subscribe(()=>{this._publish(),this._syncGenerationRunsIfNeeded()}))}_attachSyncLifecycle(){var n;let t=HS({canvasId:this._options.canvasId,createClientId:this._options.createClientId,persistence:this._options.persistence??$S(this._options.canvasId,{dbName:Ece}),store:this.store,transportFactory:this._options.transportFactory,onAttached:r=>{this._disposed||(this._syncEngine=r,this._runReadyEffectsIfSyncAttached(),this._pendingFlush&&(this._pendingFlush=!1,r.flush()))},onError:r=>{this._disposed||(this._lifecycle={error:r,phase:"error",settled:!0},this._snapshot=this._createSnapshot(!1,{phase:"error",error:r,reason:"bootstrap-failed"}),this._publish({phase:"error",error:r,reason:"bootstrap-failed"}))},onSyncEvent:this._handleSyncEvent,sync:{...this._options.sync,flush:{debounceMs:1e3,maxBatchPatchCount:50,...(n=this._options.sync)==null?void 0:n.flush},readOnly:this._readOnly,onBootstrapSettled:()=>{if(!this._disposed){if(this._snapshot.syncState.phase==="error"){this._lifecycle={error:this._snapshot.syncState.error,phase:"error",settled:!0},this._publish();return}this._snapshot.isReady&&(EA.add(this._sessionKey),this._lifecycle={phase:"ready",settled:!0},this._runReadyEffectsIfSyncAttached(),this._publish())}}}});this._disposers.push(()=>{t(),this._syncEngine=void 0})}_attachUploadCleanup(){var n,r;if(this._readOnly||this._options.optimizedUploadEnabled||this._uploadCleanupAttached)return;let t=(r=(n=this._effects).attachDeletedLocalUploadCleanup)==null?void 0:r.call(n,this._options,this.store);t&&(this._uploadCleanupAttached=!0,this._disposers.push(t))}_runReadyEffectsIfSyncAttached(){var n,r,i,o;if(!this._syncEngine||!this._snapshot.isReady)return;let{autoLayoutStrategies:t}=this._runtimeConfig;if(!this._readOnly&&(t!=null&&t.length)&&O0(this.store,t),this._readOnly||(r=(n=this._effects).clearNonRecoverableLocalUploadTasks)==null||r.call(n,this._options,this.store),!this._readOnly&&this._options.optimizedUploadEnabled&&!this._uploadCleanupAttached){let a=(o=(i=this._effects).attachDeletedLocalUploadCleanup)==null?void 0:o.call(i,this._options,this.store);a&&(this._uploadCleanupAttached=!0,this._disposers.push(a))}}_syncGenerationRunsIfNeeded(){var t,n;this._readOnly||(this._generationSyncSignature=(n=(t=this._effects).syncGenerationRunsIfNeeded)==null?void 0:n.call(t,{options:this._options,previousSignature:this._generationSyncSignature,store:this.store}))}_createSnapshot(t,n){var a;let r=this.store.getState(),i=L0(r,this._options.optimizedUploadEnabled),o=!this._readOnly&&(((a=this._syncEngine)==null?void 0:a.getPendingOutboundCount())??0)>0;return{document:r,hasPendingLocalChanges:o,hasPendingLocalMediaUploads:i,isReady:t,isRootReady:this._isRootReady,lifecycle:this._lifecycle,nodeCount:Object.keys(M(r).nodes).length,...this._rootPreviewDocument?{rootPreviewDocument:this._rootPreviewDocument}:{},...this._rootPreviewReadyNodeAssetIds?{rootPreviewReadyNodeAssetIds:[...this._rootPreviewReadyNodeAssetIds].sort()}:{},rootPreviewAssetsSettled:this._rootPreviewAssetsSettled,saveState:tF({hasPendingLocalChanges:o,hasPendingLocalMediaUploads:i,isReady:t,syncState:n}),syncState:n}}_publish(t=this._snapshot.syncState){this._snapshot=this._createSnapshot(this._snapshot.isReady,t);for(let n of Array.from(this._listeners))n(this._snapshot)}_waitFor(t,n=Mce){return new Promise((r,i)=>{let o={unsubscribe:()=>{}},a=c=>{o.unsubscribe(),o.timeout&&clearTimeout(o.timeout),c()},s=c=>{let{syncState:d}=c;this._disposed?a(()=>{var u;return i(new Error(((u=this._effects.disposedErrorMessages)==null?void 0:u.wait)??"Canvas runtime was disposed"))}):d.phase==="error"?a(()=>i(d.error)):t(c)&&a(()=>r(c))};o.unsubscribe=this.subscribe(s),o.timeout=setTimeout(()=>a(()=>i(new Error(`Timed out after ${n}ms waiting for canvas state`))),n),s(this._snapshot)})}};function rF(e,t={}){let n=eF({canvasId:e.canvasId,telemetryContext:e.telemetryContext});return new MA({...e,ownsSession:!0,session:n},t)}var Bc="xyq.scene.updateDescription";function Nce(e,t){var r,i,o,a;let n=yc(e);return n?t==="sceneName"?((r=n.basicInfo)==null?void 0:r.name)??"":t==="sceneViewName"?((i=n.basicInfo)==null?void 0:i.appearanceName)??"":t==="episodes"?n.episodes??[]:((o=n.appearanceInfo)==null?void 0:o.description)??((a=n.basicInfo)==null?void 0:a.description)??"":""}function wce(e,t){return Array.isArray(e)||Array.isArray(t)?!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((n,r)=>n===t[r]):e===t}function kce(e,t){let n=e.getState(),r=M(n).nodes[t.nodeId];if((r==null?void 0:r.type)!==Oe||r.id!==t.assetId)return;let i=n.assets[t.assetId];if(!(!i||!yc(i)))return{asset:i,node:r}}function Oce(e,t){let n=t.value;return wce(Nce(e.asset,t.field),n)?t.field!=="sceneName"||e.node.data.name===String(n):!1}function Lce(e,t){let n=kce(e,t);return n?Oce(n,t)?{status:"noop",reason:"no-changes"}:e.transact(r=>{let i=M(r).nodes[t.nodeId];if((i==null?void 0:i.type)!==Oe||i.id!==t.assetId)return;let o=AO(r.assets[t.assetId]);if(!(o!=null&&o.content))return;if(t.field==="sceneName"){let s=String(t.value),c=xO(o.content);i.data.name=s,o.content.basicInfo={...o.content.basicInfo??{},name:s,...c?{appearanceName:s}:{}},c&&(o.content.nodeName=s);return}if(t.field==="sceneViewName"){let s=String(t.value);o.content.nodeName=s,o.content.basicInfo={...o.content.basicInfo??{},appearanceName:s};return}if(t.field==="episodes"){o.content.episodes=Array.isArray(t.value)?[...t.value]:[];return}let a=String(t.value);o.content.basicInfo={...o.content.basicInfo??{},description:a},o.content.appearanceInfo={...ka(o.content.appearanceInfo),description:a}},{intent:"scene.updateDescription",mergeKey:`scene-description:${t.nodeId}:${t.field}`}):{status:"aborted",reason:"scene asset not found"}}function iF(e){return e.commands.register(Bc,Lce)}function Op(e){let t=e.pippitAssetId;return typeof t=="string"&&t.trim()?t.trim():void 0}function oF(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function sF(e,t){for(let n of Object.keys(e))n in t||delete e[n];for(let[n,r]of Object.entries(t)){let i=e[n];JSON.stringify(i)!==JSON.stringify(r)&&(oF(i)&&oF(r)?sF(i,r):e[n]=r)}}function Fce(e,t,n){var a;let r=M(e),i=n.startsWith("canvas-node:")?n.slice(12):"";if(i&&r.nodes[i])return i;let o=t.sources[n];if(o)return o.resourceType==="canvas-node"&&r.nodes[o.resourceId]||(o.resourceType===void 0||o.resourceType==="legacy")&&r.nodes[o.resourceId]?o.resourceId:(a=Object.values(r.nodes).find(s=>{let c=Rr(e,s);return Op(c)===o.resourceId}))==null?void 0:a.id}function aF(e,t){let n=new Set(Object.values(t.clipsById).filter(we).map(r=>r.sourceRef));return new Set([...n].flatMap(r=>{let i=Fce(e,t,r);return i?[i]:[]}))}function Bce({currentDraft:e,nextDraft:t,nodeId:n,store:r}){let i=r.getState(),o=aF(i,e),a=aF(i,t),s=new Set([...o].filter(p=>!a.has(p))),c=[...a].filter(p=>!o.has(p)),d=[],u=Object.values(r.getRootCanvasContent().edges).filter(p=>p.type==="reference"&&p.target===n&&s.has(p.source)).map(p=>p.id);return c.forEach(p=>{tg({createEdge:m=>{d.push(m)},sourceNodeId:p,store:r,targetNodeId:n})}),{edgesToCreate:d,edgeIdsToDelete:u}}function cF(e,t,n,r,i="edit",o={}){let a=e.getState().assets[t],s=(a==null?void 0:a.type)===kr?Bce({currentDraft:a.content,nextDraft:n,nodeId:r,store:e}):{edgesToCreate:[],edgeIdsToDelete:[]};return e.transact(c=>{let d=c.assets[t];(d==null?void 0:d.type)===kr&&sF(d.content,n);let u=M(c);s.edgeIdsToDelete.forEach(p=>{delete u.edges[p]}),s.edgesToCreate.forEach(p=>{u.edges[p.id]=p})},{intent:"timelineComposition.updateDraft",mergeKey:`timeline-composition:${i}:${r}`,undoable:o.undoable??!0})}var q=(e,t=Object.keys(e))=>({type:"object",properties:e,required:t,additionalProperties:!1}),Y={type:"string",minLength:1},Ii={type:"number"},Et={type:"boolean"},Fp={type:"integer",minimum:0,maximum:Number.MAX_SAFE_INTEGER},Lp={...Fp,minimum:1},or={...Fp,description:"Integer microseconds (1 second = 1000000 ticks)."},Gc={type:"object",additionalProperties:!0,description:"SDK extension namespace. Preserve unrelated extension keys when replacing this value."},NA={type:"array",items:Y,uniqueItems:!0},xo=q({start:or,duration:{...or,minimum:1}}),wA=q({numerator:Lp,denominator:Lp}),kA={type:"string",enum:["contain","cover","fill"]},OA=q({flipX:Et,flipY:Et,rotationDeg:Ii,scale:q({x:Ii,y:Ii}),translation:{...q({x:Ii,y:Ii}),description:"Normalized output-width/height offsets. Positive x moves right; positive y moves up."}}),LA=q({fadeInDuration:or,fadeOutDuration:or,gain:{type:"number",minimum:0,maximum:1},muted:Et}),FA=q({mediaType:{type:"string",enum:["audio","image","video"]},resourceId:{...Y,description:"For a new or replaced source, use the exact source identity from xyq.timeline.query.availableCanvasSources."},resourceType:{...Y,description:"Stable resource namespace; extensible by the host. Runtime URLs, blobs and player objects are forbidden.",examples:["pippit-asset","canvas-node","legacy"]}}),dF=q({alpha:{type:"number",minimum:0,maximum:1},color:{type:"string",pattern:"^#[0-9a-fA-F]{6}$"}}),uF={background:dF,bold:Et,fill:dF,font:q({family:Y,effectId:Y,resourceId:Y,resourceType:Y,version:Y},["family"]),fontSizePx:{type:"number",exclusiveMinimum:0},italic:Et,letterSpacing:{...Ii,description:"CC spacing units; CSS px = letterSpacing * fontSizePx * 20."},lineSpacing:{...Ii,description:"Additional spacing; CSS line-height = 1 + lineSpacing."},stroke:q({alpha:{type:"number",minimum:0,maximum:1},color:{type:"string",pattern:"^#[0-9a-fA-F]{6}$"},widthPx:{type:"number",minimum:0}})},BA=q(uF),pg=q(uF,[]),pF={align:{type:"string",enum:["center","end","start"]},centerX:{...Ii,description:"Text center as a fraction of output width."},centerY:{...Ii,description:"Text center as a fraction of output height."},maxWidth:{type:"number",exclusiveMinimum:0,description:"Maximum line width as a fraction of output width."}},GA=q(pF),zA=q(pF,[]),UA={trackId:Y,enabled:Et,locked:Et,order:Fp,extensions:Gc},VA=["trackId","enabled","locked","order","kind"],lF=q({...UA,kind:{const:"video"}},VA),mF=q({...UA,kind:{const:"audio"},role:{...Y,description:"Extensible audio role.",examples:["bgm","dialogue","music","sfx","voiceover"]}},[...VA,"role"]),qA=q({...UA,kind:{const:"text"},role:{const:"subtitle"},defaultLayout:GA,defaultStyle:BA},[...VA,"role","defaultLayout","defaultStyle"]),fF={clipId:Y,trackId:Y,enabled:Et,extensions:Gc,timelineRange:xo},hF=["clipId","trackId","enabled","timelineRange","kind"],KA=q({...fF,kind:{const:"text"},layout:zA,style:pg,text:{type:"string"}},[...hF,"text"]),Gce=q({...fF,kind:{const:"media"},audio:LA,playback:q({direction:{const:"forward"},pitchMode:{const:"preserve"},rate:wA}),sourceRange:xo,sourceRef:{...Y,description:"Reuse a sourceRef from xyq.timeline.query. New or replaced sources must use canvas-node:<nodeId> from availableCanvasSources with its exact media type and resource identity. Standalone media-library import requires its owning workflow."},frame:q({fit:kA,transform:OA})},[...hF,"sourceRef"]),jA={oneOf:[Gce,KA],description:"Existing Timeline SDK clip. Audio clips require audio/playback/sourceRange and forbid frame. Video clips require playback/sourceRange/frame. Image clips require frame and forbid playback/sourceRange/audio. IDs are stable within this draft."},gF=q({expectedClip:jA,expectedDraftExtensions:Gc,expectedSourceRef:Y,expectedTextTrack:qA,expectedTimelineRange:xo,expectedTrackId:Y,expectedTrackEnabled:Et,expectedTrackLocked:Et},[]);var HA="xyq.timeline.apply",lg="xyq.timeline.query",zce={insert_clip:q({clip:jA,source:FA,trackId:Y},["clip","trackId"]),remove_clip:q({clipId:Y}),split_clip:q({atTimelineUs:or,clipId:Y,rightClipId:Y}),replace_source:q({clipId:Y,replaceExistingSource:Et,source:FA,sourceRange:xo,sourceRef:Y},["clipId","sourceRef"]),move_clip:q({clipId:Y,start:or}),trim_clip:q({clipId:Y,sourceRange:xo,timelineRange:xo},["clipId","timelineRange"]),set_clip_speed:q({clipId:Y,rate:wA}),reorder_video_clips:q({orderedClipIds:NA,start:or,trackId:Y},["orderedClipIds","trackId"]),set_clip_transform:q({clipId:Y,transform:OA}),set_clip_fit:q({clipId:Y,fit:kA}),set_clip_extensions:q({clipId:Y,extensions:Gc},["clipId"]),set_draft_extensions:q({extensions:Gc},[]),set_clip_enabled:q({clipId:Y,enabled:Et}),set_original_audio:q({clipId:Y,audio:LA},["clipId"]),move_clip_to_track:q({clipId:Y,start:or,targetTrackId:Y}),set_audio_volume:q({clipId:Y,gain:{type:"number",minimum:0,maximum:1}}),set_audio_mute:q({clipId:Y,muted:Et}),set_audio_fade:q({clipId:Y,fadeInDuration:or,fadeOutDuration:or}),set_track_enabled:q({enabled:Et,trackId:Y}),set_track_locked:q({locked:Et,trackId:Y}),set_output_size:q({height:Lp,width:Lp}),insert_audio_track:q({track:mF}),insert_video_track:q({track:lF}),remove_audio_track:q({trackId:Y}),remove_video_track:q({trackId:Y}),reorder_video_tracks:q({orderedTrackIds:NA}),set_primary_video_track:q({trackId:Y}),insert_text_track:q({track:qA}),remove_text_track:q({trackId:Y}),set_text_track_default_style:q({style:BA,trackId:Y}),set_text_track_default_layout:q({layout:GA,trackId:Y}),set_text_clip_text:q({clipId:Y,text:{type:"string"}}),set_text_clip_enabled:q({clipId:Y,enabled:Et}),set_text_clip_style:q({clipId:Y,style:pg},["clipId"]),set_text_clip_layout:q({clipId:Y,layout:zA},["clipId"]),apply_text_style_to_all:q({style:pg,trackId:Y}),replace_text_clips:q({clipsById:{type:"object",additionalProperties:KA},trackId:Y}),reflow_text_clips:q({rangesByClipId:{type:"object",additionalProperties:xo},trackId:Y})},Uce={oneOf:Object.entries(zce).map(([e,t])=>q({type:{type:"string",const:e},payload:t,commandId:{...Y,description:"Optional ID; must be unique within this batch. An omitted ID is generated deterministically."},preconditions:gF},["type","payload"]))},$A={...q({nodeId:{...Y,description:"Canvas node with type biz/timeline-composition; create it with create_biz_node(nodeKind=timeline-composition)."},expectedRevision:{...Fp,description:"Timeline draft revision returned by xyq.timeline.query. A mismatch aborts without writing."},commands:{type:"array",minItems:1,items:Uce,description:"An atomic batch of existing Timeline SDK commands. All commands validate before Canvas persistence. Primary video gaps close and empty secondary tracks are removed according to the existing editor rules. Duration is derived from clips; frame rate is read-only because the SDK has no frame-rate command."},dryRun:{type:"boolean",default:!1,description:"Execute full Timeline SDK validation and atomic preview without saving any Canvas state. This is the domain dryRun parameter, separate from routing-only apply_mutations.dryRun."}},["nodeId","expectedRevision","commands"]),examples:[{nodeId:"timeline-node",expectedRevision:0,commands:[{type:"set_output_size",payload:{width:1920,height:1080}}]}]},YA=q({nodeId:Y});var Vce=new Set(["type","description","title","properties","required","items","additionalProperties","enum","const","default","examples","oneOf","anyOf","allOf","if","then","deprecated","minimum","maximum","exclusiveMinimum","exclusiveMaximum","minLength","pattern","uniqueItems","minItems","maxItems"]),Bp=(e,t)=>`${e}/${String(t).replace(/~/g,"~0").replace(/\//g,"~1")}`,it=(e,t)=>({path:e||"/",message:t}),yF=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);function _F(e,t,n){if(!(e===null||typeof e=="string"||typeof e=="boolean")){if(typeof e=="number")return Number.isFinite(e)?void 0:it(t,"Expected a finite JSON number");if(typeof e!="object")return it(t,"Expected a JSON value");if(n.has(e))return it(t,"Circular JSON value");if(!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)return it(t,"Expected a plain JSON object");n.add(e);for(let[r,i]of Object.entries(e)){let o=_F(i,Bp(t,r),n);if(o)return o}n.delete(e)}}function TF(e,t){for(let r of Object.keys(e))if(!Vce.has(r))return it(t,`Unsupported command schema keyword: ${r}`);let n=[...Object.values(e.properties??{}),...[e.items,e.if,e.then].filter(r=>!!r),...typeof e.additionalProperties=="object"?[e.additionalProperties]:[],...e.oneOf??[],...e.anyOf??[],...e.allOf??[]];for(let r of n){let i=TF(r,t);if(i)return i}}function qce(e,t){switch(t){case"null":return e===null;case"array":return Array.isArray(e);case"object":return yF(e);case"integer":return typeof e=="number"&&Number.isInteger(e);case"number":return typeof e=="number"&&Number.isFinite(e);case"string":return typeof e=="string";case"boolean":return typeof e=="boolean";default:return!1}}function Kce(e,t,n,r){for(let i of t.allOf??[]){let o=r(e,i,n);if(o)return o}if(t.if&&!r(e,t.if,n)&&t.then){let i=r(e,t.then,n);if(i)return i}for(let i of["oneOf","anyOf"]){let o=t[i];if(!o)continue;let a=o.map(c=>r(e,c,n)),s=a.filter(c=>!c).length;if(s===0)return a.filter(c=>!!c).sort((c,d)=>d.path.length-c.path.length)[0]??it(n,`Value does not match ${i}`);if(i==="oneOf"&&s!==1)return it(n,"Value matches multiple oneOf alternatives")}}function jce(e,t,n,r){var i;for(let o of t.required??[])if(!Object.hasOwn(e,o))return it(Bp(n,o),"Required property is missing");for(let[o,a]of Object.entries(e)){let s=Object.hasOwn(t.properties??{},o)?(i=t.properties)==null?void 0:i[o]:void 0;if(!s&&t.additionalProperties===!1)return it(Bp(n,o),"Unknown property");let c=s??(typeof t.additionalProperties=="object"?t.additionalProperties:void 0);if(c){let d=r(a,c,Bp(n,o));if(d)return d}}}function mg(e,t,n){if(t.type){let i=typeof t.type=="string"?[t.type]:t.type;if(!i.some(o=>qce(e,o)))return it(n,`Expected ${i.join(" or ")}`)}if(Object.hasOwn(t,"const")&&!lt(e,t.const))return it(n,`Expected constant ${JSON.stringify(t.const)}`);if(t.enum&&!t.enum.some(i=>lt(i,e)))return it(n,`Expected one of ${JSON.stringify(t.enum)}`);let r=Kce(e,t,n,mg);if(r)return r;if(typeof e=="number"){if(t.minimum!==void 0&&e<t.minimum)return it(n,`Minimum is ${t.minimum}`);if(t.maximum!==void 0&&e>t.maximum)return it(n,`Maximum is ${t.maximum}`);if(t.exclusiveMinimum!==void 0&&e<=t.exclusiveMinimum)return it(n,`Must exceed ${t.exclusiveMinimum}`);if(t.exclusiveMaximum!==void 0&&e>=t.exclusiveMaximum)return it(n,`Must be below ${t.exclusiveMaximum}`)}if(typeof e=="string"){if(t.minLength!==void 0&&[...e].length<t.minLength)return it(n,`Minimum string length is ${t.minLength}`);if(t.pattern&&!new RegExp(t.pattern,"u").test(e))return it(n,`Expected pattern ${t.pattern}`)}if(Array.isArray(e)){if(t.minItems!==void 0&&e.length<t.minItems)return it(n,`Minimum item count is ${t.minItems}`);if(t.maxItems!==void 0&&e.length>t.maxItems)return it(n,`Maximum item count is ${t.maxItems}`);if(t.uniqueItems&&e.some((i,o)=>e.slice(0,o).some(a=>lt(a,i))))return it(n,"Array items must be unique");if(!t.items)return;for(let i=0;i<e.length;i+=1){let o=mg(e[i],t.items,Bp(n,i));if(o)return o}}else if(yF(e))return jce(e,t,n,mg)}function Ro(e,t){return TF(t,"")??_F(e,"",new Set)??mg(e,t,"")}function Hce(e,t){let n=e==null?void 0:e.trim();if(!n)return 0;let r=Math.ceil(n.length/26);return Math.min(t,Math.max(1,r))}function $ce(e){return Hce(e,3)}function XA(e){var a;let t=(a=e.transType)==null?void 0:a.trim().toUpperCase(),n=$ce(e.displayContent),r=t==="SELECTION",i=Math.max(0,e.selectionOptionsCount??0),o=2+36+4+40+20;return n>0&&(o+=6+n*18),e.scriptReady!==!0&&(o+=16+32),r&&(o+=16),r&&i>0&&(o+=i*36+Math.max(0,i-1)*8),24+o}var WA="biz/interactive-episode",JA="biz/interactive-episode-video";var Gp=372,QA=XA({}),Yce=372,SF=16,Xce=36,Wce=8,Jce=20,Qce=26,Zce=3;function ede(e){var i,o;let t=(i=e.transType)==null?void 0:i.trim().toUpperCase(),n=Yce;if(t==="SELECTION"){let a=Math.max(0,e.selectionOptionsCount??0);n+=SF,a>0&&(n+=a*Xce+Math.max(0,a-1)*Wce)}let r=(o=e.endingLabel)==null?void 0:o.trim();if(r){let a=Math.min(Zce,Math.max(1,Math.ceil(r.length/Qce)));n+=SF+a*Jce}return n}function tde(e){return e===void 0||e==="HE"||e==="BE"||e==="OE"}function nde(e){return L(e)&&Je(e.x)&&Je(e.y)}function rde(e){return!(!L(e)||!Ne(e.optionText)||!B(e.nextEpisodeId)||!B(e.targetDisplayCode)||!Je(e.selectionIdx))}function ide(e){return e===void 0||Array.isArray(e)&&e.every(rde)}function ode(e){return!(!L(e)||!Bn(e)||e.canvasPosition!==void 0&&!nde(e.canvasPosition)||e.title!==void 0&&!Ne(e.title)||!B(e.displayContent)||!B(e.summary)||!B(e.transType)||!B(e.endingLabel)||!tde(e.endingType)||!B(e.episodeId)||!B(e.groupName)||!B(e.displayCode)||!ft(e.isRoot)||!ft(e.scriptReady)||!ide(e.selectionOptions)||!ft(e.storyboardReady)||!ft(e.videoReady))}var fg={type:WA,validate:ode,getDefaultSize:e=>{var t;return{w:Gp,h:XA({displayContent:e==null?void 0:e.displayContent,scriptReady:e.scriptReady,selectionOptionsCount:(t=e==null?void 0:e.selectionOptions)==null?void 0:t.length,transType:e==null?void 0:e.transType})}}},ZA={...fg,type:JA,getDefaultSize:e=>{var t;return{w:Gp,h:ede({endingLabel:e==null?void 0:e.endingLabel,selectionOptionsCount:(t=e==null?void 0:e.selectionOptions)==null?void 0:t.length,transType:e==null?void 0:e.transType})}}};var ade=new Map;function eI(e){return ade.get(e)}var sde=new Map;function cde(e,t){return`${e}::${t}`}function bF(e,t){var n;return!!((n=sde.get(cde(e,t)))!=null&&n.size)}function CF(e){return!e.cacheId&&(e.sourceKind==="manual"||e.sourceKind===void 0&&e.id.startsWith("media_upload_"))}var tI=3e6,rI=5e6;function iI(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>0?Math.max(1,Math.round(e*1e3)):t}function hg(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:void 0}function dde(e,t){var n,r,i,o;if(e==="image"){let a=t,s=hg(a.naturalHeight??((n=a.metadata)==null?void 0:n.height)),c=hg(a.naturalWidth??((r=a.metadata)==null?void 0:r.width));return{...s?{height:s}:{},...c?{width:c}:{}}}if(e==="video"){let a=t,s=hg(((i=a.metadata)==null?void 0:i.height)??a.height??a.frameHeight),c=hg(((o=a.metadata)==null?void 0:o.width)??a.width??a.frameWidth);return{...s?{height:s}:{},...c?{width:c}:{}}}return{}}function AF(e,t){var i,o;let n=e.generation;return(o=[t,(i=n==null?void 0:n.state)==null?void 0:i.runId,n==null?void 0:n.runId,n==null?void 0:n.taskId].find(a=>!!(a!=null&&a.trim())))==null?void 0:o.trim()}function ude(e,t){var n,r;if(t.type===Z||t.type===Ph)return(n=Zt(e.assets[t.id]))==null?void 0:n.appearanceInfo;if(t.type===Oe||t.type===CO)return(r=yc(e.assets[t.id]))==null?void 0:r.appearanceInfo}function pde(e){var r,i,o;if(!(e.variant===cC||((r=e.generation)==null?void 0:r.runSource)===sC))return;let n=(o=(i=e.generation)==null?void 0:i.state)==null?void 0:o.status;if(Ub(n))return"generating";if(n==="failed"||n==="succeeded")return n}function nI(e){var n,r;let t=e.durationMs??((n=e.metadata)==null?void 0:n.durationMs)??((r=e.metadata)==null?void 0:r.durationMS)??(typeof e.duration=="number"?e.duration*1e3:void 0);return iI(t,rI)}function lde(e,t,n,r){return t.serverProcessing?!!eI(e)||bF(r,n)||!!mO(t.localUploadCache,"video")?void 0:"processing":void 0}function mde(e){switch(e){case ee:return"image";case J:return"video";case fe:return"audio";default:return}}function IF(e,t){switch(e){case"image":return tI;case"video":return nI(t);case"audio":return iI(ip(t),rI)}}function fde(e){var n,r,i;let t=(r=(n=e.generation)==null?void 0:n.state)==null?void 0:r.status;if(Ub(t)||t==="succeeded"&&!((i=e.pippitAssetId)!=null&&i.trim()))return"generating";if(t==="failed")return"failed"}function vF(e,t,n={}){var f,h,g,y,_,S,T,C,I;let r=Rr(e,t),i=`canvas-node:${t.id}`,o=ude(e,t),a=(f=o==null?void 0:o.pippitAssetId)==null?void 0:f.trim();if(o&&a)return{durationUs:tI,mediaType:"image",nodeId:t.id,resourceId:a,resourceType:"pippit-asset",sourceRef:i};let s=mde(t.type),c=s?dde(s,r):{},d=Op(r);if(t.type===J){let x=r;if(x.variant===cC||((h=x.generation)==null?void 0:h.runSource)===sC){let G=pde(x);if(!G&&n.generationStatus!=="preparing")return;if(G&&n.generationStatus!=="preparing"){let O=G==="succeeded"&&!d?"generating":G,K=O==="succeeded"?d:AF(x,n.pendingGenerationResourceId);return K?{durationUs:nI(x),errorMessage:((_=(y=(g=x.generation)==null?void 0:g.state)==null?void 0:y.errorMessage)==null?void 0:_.trim())||void 0,...c,mediaType:"video",nodeId:t.id,resourceId:K,resourceType:O==="succeeded"?"pippit-asset":"pending-generation",smartEditGenerationStatus:O,sourceRef:i}:void 0}}}let u=n.generationStatus??(s?fde(r):void 0);if(s&&u){let x=AF(r,n.pendingGenerationResourceId);return x?{durationUs:IF(s,r),errorMessage:((C=(T=(S=r.generation)==null?void 0:S.state)==null?void 0:T.errorMessage)==null?void 0:C.trim())||void 0,generationStatus:u,...c,mediaType:s,nodeId:t.id,resourceId:x,resourceType:"pending-generation",sourceRef:i}:void 0}let p=s&&en(r.localUploadTask,s)?r.localUploadTask:void 0;if(s&&p){let x=s==="video"&&!!eI(t.id),R;return p.status==="failed"?R="failed":x||(R="uploading"),{durationUs:IF(s,r),errorMessage:((I=p.errorMessage)==null?void 0:I.trim())||void 0,...c,mediaType:s,nodeId:t.id,resourceId:p.id,resourceType:"pending-upload",sourceRef:i,uploadStatus:R,uploadRetryable:CF(p)}}if(!d)return;let m={resourceId:d,resourceType:"pippit-asset"};if(t.type===ee)return{durationUs:tI,...c,mediaType:"image",nodeId:t.id,...m,sourceRef:i};if(t.type===J){let x=r;return{durationUs:nI(x),...c,mediaType:"video",nodeId:t.id,processingStatus:lde(t.id,x,m.resourceId,i),...m,sourceRef:i}}if(t.type===fe)return{durationUs:iI(ip(r),rI),mediaType:"audio",nodeId:t.id,...m,sourceRef:i}}function xF(e,t){let{nodes:n}=M(e);if(!Object.hasOwn(n,t))return;let r=vF(e,n[t]);if((r==null?void 0:r.resourceType)==="pippit-asset")return{nodeId:t,sourceRef:r.sourceRef,source:{mediaType:r.mediaType,resourceId:r.resourceId,resourceType:r.resourceType},durationUs:r.durationUs,...r.width?{width:r.width}:{},...r.height?{height:r.height}:{}}}function RF(e){return Object.keys(M(e).nodes).flatMap(t=>{let n=xF(e,t);return n?[n]:[]})}function PF(e,t,n){let r=new Set;for(let i of Object.values(n.clipsById)){if(!we(i)||r.has(i.sourceRef))continue;r.add(i.sourceRef);let o=n.sources[i.sourceRef];if(Object.hasOwn(t.sources,i.sourceRef)&&lt(o,t.sources[i.sourceRef]))continue;let a=i.sourceRef.startsWith("canvas-node:")?i.sourceRef.slice(12):"",s=a?xF(e,a):void 0;if(!s||s.sourceRef!==i.sourceRef||!lt(s.source,o))return{clipId:i.clipId,sourceRef:i.sourceRef}}}function hde(e,t){return e!==null&&typeof e=="object"&&"sourceNodeId"in e&&e.sourceNodeId===t}function DF(e,t){let n=e.getState(),{nodes:r}=M(n);if(!Object.hasOwn(r,t)||!Object.hasOwn(n.assets,t))return{ok:!1,reason:"TIMELINE_NODE_NOT_FOUND"};let i=r[t],o=n.assets[t];if(i.type!==Io||o.type!==PA||!vo(o.content))return{ok:!1,reason:"TIMELINE_NODE_NOT_FOUND"};let a=o.content.draftRef.pippitAssetId,s=n.assets[a];if((s==null?void 0:s.type)!==kr)return{ok:!1,reason:"TIMELINE_DRAFT_NOT_FOUND"};if(!hde(s.extra,t))return{ok:!1,reason:"TIMELINE_DRAFT_NOT_OWNED"};let c=Fc(s.content);return!c||c.draftId!==a?{ok:!1,reason:"TIMELINE_DRAFT_INVALID"}:{ok:!0,target:{draft:c,draftAssetId:a,nodeId:t}}}function gde(e,t){let n=Ro(t,YA);if(n)return{ok:!1,reason:JSON.stringify({code:"INVALID_ARGUMENT",...n})};let r=DF(e,t.nodeId);if(!r.ok)return r;let{draftAssetId:i,nodeId:o}=r.target,a=Cp(r.target.draft);return{ok:!0,data:{nodeId:o,draftAssetId:i,draft:a,durationUs:gA(a),availableCanvasSources:RF(e.getState()),trackOrder:Ci(a).map(s=>s.trackId),limits:{audioTracks:6,textTracks:1,videoTracks:4}}}}function yde(e,t){let n=Ro(t,$A);if(n)return{ok:!1,reason:JSON.stringify({code:"INVALID_TIMELINE_COMMAND",...n})};let r=DF(e,t.nodeId);if(!r.ok)return r;let{draft:i,draftAssetId:o}=r.target,a=`canvas-agent:${o}:${t.expectedRevision}`,s=RA(i,{baseRevision:t.expectedRevision,commands:t.commands.map((c,d)=>({...c,commandSchemaVersion:1,commandId:c.commandId??`${a}:${d}`})),draftId:o,initiator:"agent",origin:"local",transactionId:a});if(s.ok){let c=PF(e.getState(),i,s.draft);if(c)return{ok:!1,reason:JSON.stringify({code:"TIMELINE_SOURCE_NOT_BOUND",clipId:c.clipId,sourceRef:c.sourceRef,message:"New or replaced sources must match a completed Canvas media source returned in xyq.timeline.query.availableCanvasSources; otherwise Web reconciliation cannot retain the requested identity."})}}return{ok:!0,target:r.target,execution:s}}function _de(e,t){let n=yde(e,t);return n.ok?n.execution.ok?t.dryRun?{status:"noop",reason:"no-changes"}:cF(e,n.target.draftAssetId,n.execution.draft,n.target.nodeId,`agent:${t.expectedRevision}`):{status:"aborted",reason:JSON.stringify({code:n.execution.rejectionCode,failedCommandId:n.execution.failedCommandId,issues:n.execution.issues})}:{status:"aborted",reason:n.reason}}function EF(e){return e.commands.register(HA,_de)}var MF={name:HA,description:"Atomically edit a timeline-composition node through the existing Timeline SDK commands. Query the node first for revision and stable track/clip IDs; all times are integer microseconds.",input:"{nodeId, expectedRevision, commands, dryRun?}",inputSchema:$A};function NF({runtime:e,schema:t}){return{args:{nodeId:t.string()},inputSchema:YA,description:"Read a timeline-composition node and its owned draft, tracks, clips, sources, output, revision, derived duration and availableCanvasSources. Does not prepare, reconcile or save the draft.",async execute(n){let r=await co(e,{canvasId:br(e),operation:lg},["canvas.read","canvas.asset.read"]);if(r)return he(r);let i=gde(e.store,n);return he(i.ok?pn(e,i.data):qt(e,"INVALID_ARGUMENT",i.reason))}}}var Tde="camera-motion:",Sde=new Set(["data-end-time-us","data-source-pippit-asset-id","data-start-time-us","data-timestamp-us"]);function bde(e){return typeof e=="string"?e.trim():""}function Cde(e,t){if(t.startsWith(Tde))return!1;let n=gc(e);return!Object.keys(n).some(r=>Sde.has(r))}function wF(e){let t=[],n=new Set,r=new RegExp(eC.source,"g");for(let i of e.matchAll(r)){let o=bde(i[2]);!o||n.has(o)||!Cde(i,o)||(n.add(o),t.push(o))}return t}function oI(e){return String(e??"").trim()}function Ade({nextSourceNodeId:e,previousSourceNodeId:t,removePreviousReference:n,store:r,targetNodeId:i}){let o=r.getRootCanvasContent();return!o.nodes[e]||!o.nodes[i]?!1:r.transact(s=>{let c=M(s);if(!Si(c.edges,e,i)){let d=`edge-${e}-${i}`,u=d,p=1;for(;c.edges[u];)p+=1,u=`${d}-${p}`;c.edges[u]={id:u,source:e,sourceHandle:"right",target:i,targetHandle:"left",type:"reference"}}n&&t!==e&&Object.entries(c.edges).forEach(([d,u])=>{u.type==="reference"&&u.source===t&&u.target===i&&delete c.edges[d]})},{intent:"generation.promptReference.replace"}).status!=="aborted"}function kF({enableRoleReferenceSelection:e,store:t,targetNodeId:n}){let r=e?yL(t):void 0;return{connectReference:i=>tg({createEdge:r,sourceNodeId:i,store:t,targetNodeId:n}).status!=="aborted",disconnectReference:i=>{let o=oI(i);return o?t.transact(s=>{let c=M(s);Object.entries(c.edges).forEach(([d,u])=>{u.type==="reference"&&u.source===o&&u.target===n&&delete c.edges[d]})},{intent:"generation.promptReference.remove"}).status!=="aborted":!1},replaceReference:({nextSourceNodeId:i,previousSourceNodeId:o,removePreviousReference:a,selectedIds:s})=>{let c=oI(i),d=oI(o);if(!c||!d)return!1;let u=t.getRootCanvasContent().nodes[n];return u&&yo(u.type)?_L({nextRoleNodeId:c,previousRoleNodeId:d,removePreviousReference:a,selection:s,store:t,targetNodeId:n}).status!=="aborted":Ade({nextSourceNodeId:c,previousSourceNodeId:d,removePreviousReference:a,store:t,targetNodeId:n})}}}var gg="xyq.generation.update_prompt",aI={type:"object",properties:{nodeId:{type:"string",minLength:1,description:"Existing image or video target node ID. Inspect its generation draft with get_asset."},prompt:{type:"string",description:"Prompt text using the existing Web node-asset and pippit-asset-id tags. Tags are parsed and imported by the same SDK functions as Web paste. Reference candidates must already exist in the Canvas or target generation.references; unknown ordinary references are reported before writing. Text and tag attributes are preserved. An empty string clears the prompt while retaining references and connections.",examples:['Use <node-asset label="Character">SOURCE_NODE_ID</node-asset> in a rainy street.','Use <pippit-asset-id label="Reference image">PIPPIT_ASSET_ID_IN_DRAFT</pippit-asset-id>.']},dryRun:{type:"boolean",default:!1,description:"Execute the same SDK operations on an isolated document to validate the edit without changing the current document, revision or undo history."}},required:["nodeId","prompt"],additionalProperties:!1,description:"CLI adapter for the existing SDK tag parser, reference controller and generation draft writer. Keeps other generation fields and caption/title/name. Reuses Web node-first reference matching and role connection defaults. Uploading, querying unknown media and starting generation remain separate operations."},OF={name:gg,input:"{nodeId, prompt: string, dryRun?}",inputSchema:aI,description:"Pass existing Web prompt tags through shared SDK reference handling and Canvas commands. Use get_asset for nodes and saved reference identities; unknown standalone media is not fetched automatically."};function LF(e,t){let n=ro(e.getState(),t);if(!Pe(n))throw new Error("PROMPT_TARGET_MUST_HAVE_NODE_ASSET");let{generation:r}=n;if(r!==void 0&&!Pe(r))throw new Error("INVALID_GENERATION_DRAFT");if((r==null?void 0:r.references)!==void 0&&(!Array.isArray(r.references)||!r.references.every(Pe)))throw new Error("INVALID_GENERATION_REFERENCES");return r}function Ide(e,t){let{nodes:n}=e.getRootCanvasContent(),r=Object.hasOwn(n,t.nodeId)?n[t.nodeId]:void 0,i=r&&yo(r.type);if(!i)throw new Error("PROMPT_TARGET_MUST_BE_IMAGE_OR_VIDEO");let o=LF(e,t.nodeId),a=WO(o==null?void 0:o.references,vC(e.getState(),t.nodeId,{target:i})),s=i==="image"?t0:n0,c=DC(t.prompt),d=new Set(wF(t.prompt));for(let p of c){if(p.tagType!=="node-asset"&&!d.has(p.tagId))continue;let m=EC({acceptedTypes:s,references:a,tags:[p]});if(!m.assetReferences.length&&!m.edgeReferences.length)throw new Error(`UNRESOLVED_PROMPT_REFERENCE: ${p.tagId}`)}let u=kF({enableRoleReferenceSelection:!0,store:e,targetNodeId:t.nodeId});return i0({acceptedTypes:s,references:a,tags:c,connectReference:p=>{if(u.connectReference(p),!Si(e.getRootCanvasContent().edges,p,t.nodeId))throw new Error(`PROMPT_REFERENCE_CONNECTION_FAILED: ${p}`)}}),Sh(e.commands,t.nodeId,{generation:{...LF(e,t.nodeId),prompt:t.prompt}})}function vde(e,t){let n=Ro(t,aI);if(n)return{status:"aborted",reason:JSON.stringify({code:"INVALID_ARGUMENT",...n})};try{let r=vu({initialDocument:e.getState(),registry:e.registry}),i=[],o=r.subscribePatches(c=>i.push(...c.patches));try{let c=Ide(r,t);if(c.status==="aborted")return c}finally{o()}if(t.dryRun||!i.length)return{status:"noop",reason:"no-changes"};let a=JSON.parse(JSON.stringify(i));return va({atomic:!0,intent:gg,mutations:[{kind:"apply_patches",patches:a}],runtime:{store:e,permissions:[]}}).results[0]}catch(r){return{status:"aborted",reason:r instanceof Error?r.message:"INVALID_GENERATION_PROMPT"}}}function FF(e){return e.commands.register(gg,vde)}function BF(e){function t(r){return e(r)}function n(r){let i={};return Object.entries(r).forEach(([o,a])=>{o!=="timeline"&&(i[o]=e(a))}),r.timeline!==void 0&&(i.timeline=r.timeline),i}return{cloneDirectorValue:e,cloneDirectorSceneNode:t,cloneDirectorSceneDocumentWithoutTimeline:n}}var{cloneDirectorValue:ue,cloneDirectorSceneNode:xde,cloneDirectorSceneDocumentWithoutTimeline:Rde}=BF(e=>structuredClone(e));var GF={wrapDocument:e=>e,initializeStore:()=>{},loadHierarchyCollapsedSections:()=>[],persistHierarchyCollapsedSections:()=>{},createHierarchyGroups:()=>{throw new Error("Document commands do not expose the editor hierarchy view.")}};var Pde={hips:["hips","pelvis","hip"],spine:["spine","waist","lowerback"],chest:["chest","spine1","spine01","spine2","spine02","upperbody"],neck:["neck"],head:["head"],leftShoulder:["leftshoulder","leftclavicle","lshoulder","lclavicle"],leftUpperArm:["leftupperarm","leftarm","lupperarm","luparm","larm"],leftLowerArm:["leftlowerarm","leftforearm","llowerarm","lforearm","leftelbow"],leftHand:["lefthand","leftwrist","lhand"],rightShoulder:["rightshoulder","rightclavicle","rshoulder","rclavicle"],rightUpperArm:["rightupperarm","rightarm","rupperarm","ruparm","rarm"],rightLowerArm:["rightlowerarm","rightforearm","rlowerarm","rforearm","rightelbow"],rightHand:["righthand","rightwrist","rhand"],leftUpperLeg:["leftupperleg","leftupleg","leftthigh","lupperleg","lupleg","lthigh"],leftLowerLeg:["leftlowerleg","leftleg","leftcalf","llowerleg","lleg","lcalf"],leftFoot:["leftfoot","leftankle","lfoot"],rightUpperLeg:["rightupperleg","rightupleg","rightthigh","rupperleg","rupleg","rthigh"],rightLowerLeg:["rightlowerleg","rightleg","rightcalf","rlowerleg","rleg","rcalf"],rightFoot:["rightfoot","rightankle","rfoot"]},Dde={hips:["mixamorighips"],spine:["mixamorigspine"],chest:["mixamorigspine1","mixamorigspine2"],neck:["mixamorigneck"],head:["mixamorighead"],leftShoulder:["mixamorigleftshoulder"],leftUpperArm:["mixamorigleftarm"],leftLowerArm:["mixamorigleftforearm"],leftHand:["mixamoriglefthand"],rightShoulder:["mixamorigrightshoulder"],rightUpperArm:["mixamorigrightarm"],rightLowerArm:["mixamorigrightforearm"],rightHand:["mixamorigrighthand"],leftUpperLeg:["mixamorigleftupleg"],leftLowerLeg:["mixamorigleftleg"],leftFoot:["mixamorigleftfoot"],rightUpperLeg:["mixamorigrightupleg"],rightLowerLeg:["mixamorigrightleg"],rightFoot:["mixamorigrightfoot"]},Ede={hips:["ccbasehip"],spine:["ccbasewaist"],chest:["ccbasespine01","ccbasespine02"],neck:["ccbasenecktwist01"],head:["ccbasehead"],leftShoulder:["ccbaselclavicle"],leftUpperArm:["ccbaselupperarm"],leftLowerArm:["ccbaselforearm"],leftHand:["ccbaselhand"],rightShoulder:["ccbaserclavicle"],rightUpperArm:["ccbaserupperarm"],rightLowerArm:["ccbaserforearm"],rightHand:["ccbaserhand"],leftUpperLeg:["ccbaselthigh"],leftLowerLeg:["ccbaselcalf"],leftFoot:["ccbaselfoot"],rightUpperLeg:["ccbaserthigh"],rightLowerLeg:["ccbasercalf"],rightFoot:["ccbaserfoot"]};function zF(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"")}function gt(e){let t=[...Pde[e],...Dde[e],...Ede[e]];return Array.from(new Set(t))}var Mde={hips:gt("hips"),spine:gt("spine"),chest:gt("chest"),neck:gt("neck"),head:gt("head"),leftShoulder:gt("leftShoulder"),leftUpperArm:gt("leftUpperArm"),leftLowerArm:gt("leftLowerArm"),leftHand:gt("leftHand"),rightShoulder:gt("rightShoulder"),rightUpperArm:gt("rightUpperArm"),rightLowerArm:gt("rightLowerArm"),rightHand:gt("rightHand"),leftUpperLeg:gt("leftUpperLeg"),leftLowerLeg:gt("leftLowerLeg"),leftFoot:gt("leftFoot"),rightUpperLeg:gt("rightUpperLeg"),rightLowerLeg:gt("rightLowerLeg"),rightFoot:gt("rightFoot")},Nde=new Map(Object.entries(Mde).flatMap(([e,t])=>[e,...t].map(n=>[zF(n),e])));function sI(e){if(e)return Nde.get(zF(e))}var cI=class{static create(){let t=Ea,n=typeof t=="function"?new t:Uk;return n.init({lng:"zh",fallbackLng:"zh",resources:{},i18nFormat:oc()}),ac(n)}constructor(){}},l=cI.create();function wde(){return l.t("Pippit_scene3d_image_replicate_btn_start",{},"AI识图")}function kde(e,t=e){switch(e){case"static_shot":return l.t("Pippit_scene3d_camera_motion_static_shot_label",{},"固定镜头");case"tilt_up":return l.t("Pippit_scene3d_camera_motion_tilt_up_label",{},"镜头上摇");case"tilt_down":return l.t("Pippit_scene3d_camera_motion_tilt_down_label",{},"镜头下摇");case"pan_left":return l.t("Pippit_scene3d_camera_motion_pan_left_label",{},"镜头左摇");case"pan_right":return l.t("Pippit_scene3d_camera_motion_pan_right_label",{},"镜头右摇");case"crane_up":return l.t("Pippit_scene3d_camera_motion_crane_up_label",{},"镜头上升");case"crane_down":return l.t("Pippit_scene3d_camera_motion_crane_down_label",{},"镜头下降");case"truck_left":return l.t("Pippit_scene3d_camera_motion_truck_left_label",{},"镜头左移");case"truck_right":return l.t("Pippit_scene3d_camera_motion_truck_right_label",{},"镜头右移");case"dolly_in":return l.t("Pippit_scene3d_camera_motion_dolly_in_label",{},"镜头前推");case"dolly_out":return l.t("Pippit_scene3d_camera_motion_dolly_out_label",{},"镜头后移");case"zoom_in":return l.t("Pippit_scene3d_camera_motion_zoom_in_label",{},"变焦推进");case"zoom_out":return l.t("Pippit_scene3d_camera_motion_zoom_out_label",{},"变焦拉远");case"follow_tracking":return l.t("Pippit_scene3d_camera_motion_follow_tracking_label",{},"跟随拍摄");case"leading_tracking":return l.t("Pippit_scene3d_camera_motion_leading_tracking_label",{},"迎面跟拍");case"profile_tracking":return l.t("Pippit_scene3d_camera_motion_profile_tracking_label",{},"侧面跟拍");case"handheld_shot":return l.t("Pippit_scene3d_camera_motion_handheld_shot_label",{},"手持拍摄");case"slider_reveal":return l.t("Pippit_scene3d_camera_motion_slider_reveal_label",{},"横滑揭示");case"foreground_wipe":return l.t("Pippit_scene3d_camera_motion_foreground_wipe_label",{},"前景擦过");case"push_through":return l.t("Pippit_scene3d_camera_motion_push_through_label",{},"穿越镜头");case"whip_pan":return l.t("Pippit_scene3d_camera_motion_whip_pan_label",{},"甩摇");case"rack_focus":return l.t("Pippit_scene3d_camera_motion_rack_focus_label",{},"焦点转移");case"crash_zoom":return l.t("Pippit_scene3d_camera_motion_crash_zoom_label",{},"急速变焦");case"orbit_180":return l.t("Pippit_scene3d_camera_motion_orbit_180_label",{},"环绕拍摄");case"ascending_orbit":return l.t("Pippit_scene3d_camera_motion_ascending_orbit_label",{},"盘旋抬升");case"descending_orbit":return l.t("Pippit_scene3d_camera_motion_descending_orbit_label",{},"盘旋下降");case"aerial_establishing":return l.t("Pippit_scene3d_camera_motion_aerial_establishing_label",{},"高空航拍");case"fpv_flythrough":return l.t("Pippit_scene3d_camera_motion_fpv_flythrough_label",{},"穿越机运镜");case"drone_dive":return l.t("Pippit_scene3d_camera_motion_drone_dive_label",{},"俯冲下降");case"pull_away":return l.t("Pippit_scene3d_camera_motion_pull_away_label",{},"拉升离场");default:return t}}function Ode(){return{common:{cancel:()=>l.t("Pippit_scene3d_common_btn_cancel",{},"取消"),confirm:()=>l.t("Pippit_scene3d_common_btn_confirm",{},"确定"),add:()=>l.t("Pippit_scene3d_common_btn_add",{},"添加"),close:()=>l.t("Pippit_scene3d_common_btn_close",{},"关闭"),delete:()=>l.t("Pippit_scene3d_common_btn_delete",{},"删除"),fullscreen:()=>l.t("Pippit_scene3d_common_btn_fullscreen",{},"全屏"),replace:()=>l.t("Pippit_scene3d_common_btn_replace",{},"替换"),upload:()=>l.t("Pippit_scene3d_common_btn_upload",{},"上传"),save:()=>l.t("Pippit_scene3d_common_btn_save",{},"保存"),saving:()=>l.t("Pippit_scene3d_common_btn_saving",{},"保存中"),uploading:()=>l.t("Pippit_scene3d_common_status_uploading",{},"上传中")},contextMenu:{adjustPose:()=>l.t("Pippit_scene3d_contextmenu_btn_adjustpose",{},"姿势调节"),duplicate:()=>l.t("Pippit_scene3d_contextmenu_btn_duplicate",{},"创建副本"),pasteHere:()=>l.t("Pippit_scene3d_contextmenu_btn_pastehere",{},"粘贴到此处"),focusSelection:()=>l.t("Pippit_scene3d_contextmenu_btn_focusselection",{},"聚焦选区"),clearSelection:()=>l.t("Pippit_scene3d_contextmenu_btn_clearselection",{},"清空选择"),addCharacter:()=>l.t("Pippit_scene3d_contextmenu_btn_addcharacter",{},"新增角色")},toolbar:{addCharacter:()=>l.t("Pippit_scene3d_toolbar_btn_addmodel",{},"添加模型"),localUpload:()=>l.t("Pippit_scene3d_toolbar_btn_localupload",{},"本地上传"),character:()=>l.t("Pippit_scene3d_toolbar_btn_character",{},"单人物"),prop:()=>l.t("Pippit_scene3d_toolbar_btn_prop",{},"道具"),crowd:()=>l.t("Pippit_scene3d_toolbar_btn_crowd",{},"群众"),crowdPreset:()=>l.t("Pippit_scene3d_toolbar_btn_crowdpreset",{},"群众(3x3)"),geometry:()=>l.t("Pippit_scene3d_toolbar_btn_geometry",{},"几何模型"),addCrowdArray:()=>l.t("Pippit_scene3d_toolbar_title_addcrowdarray",{},"添加群众阵列"),rowCount:()=>l.t("Pippit_scene3d_toolbar_label_rows",{},"行数"),columnCount:()=>l.t("Pippit_scene3d_toolbar_label_columns",{},"列数"),spacing:()=>l.t("Pippit_scene3d_toolbar_label_spacing",{},"间距"),addCamera:()=>l.t("Pippit_scene3d_toolbar_btn_addcamera",{},"添加机位"),selectCameraView:()=>l.t("Pippit_scene3d_toolbar_title_selectcameraview",{},"选择机位视角"),aspectRatio:()=>l.t("Pippit_scene3d_toolbar_btn_aspectratio",{},"画幅比例"),ratio:()=>l.t("Pippit_scene3d_toolbar_title_ratio",{},"比例"),exportMenu:()=>l.t("Pippit_scene3d_toolbar_title_export",{},"导出"),snapshot:()=>l.t("Pippit_scene3d_toolbar_btn_snapshot",{},"截图"),render:()=>l.t("Pippit_scene3d_toolbar_btn_render",{},"渲染"),renderVideo:()=>l.t("Pippit_scene3d_toolbar_btn_rendervideo",{},"导出素材"),cancelRenderVideo:()=>l.t("Pippit_scene3d_toolbar_btn_cancelrendervideo",{},"取消渲染"),screenRecord:()=>l.t("Pippit_scene3d_toolbar_btn_screenrecord",{},"录屏"),stopScreenRecord:()=>l.t("Pippit_scene3d_toolbar_btn_stopscreenrecord",{},"停止录屏"),addProp:()=>l.t("Pippit_scene3d_toolbar_btn_addprop",{},"添加道具"),addPropsWithCount:e=>l.t("Pippit_scene3d_toolbar_btn_addpropswithcount",{num:e,number:e},"添加{number}个道具")},renderPreview:{title:()=>l.t("Pippit_scene3d_render_preview_title",{},"渲染预览"),description:()=>l.t("Pippit_scene3d_render_preview_desc_confirmbeforestart",{},"确认机位、帧和输出类型后开始渲染"),outputType:()=>l.t("Pippit_scene3d_render_preview_label_outputtype",{},"输出类型"),image:()=>l.t("Pippit_scene3d_render_preview_tab_image",{},"图片"),video:()=>l.t("Pippit_scene3d_render_preview_tab_video",{},"视频"),camera:()=>l.t("Pippit_scene3d_render_preview_label_camera",{},"机位"),frame:()=>l.t("Pippit_scene3d_render_preview_label_frame",{},"帧"),range:()=>l.t("Pippit_scene3d_render_preview_label_range",{},"范围"),aspectRatio:()=>l.t("Pippit_scene3d_render_preview_label_aspectratio",{},"画幅"),resolution:()=>l.t("Pippit_scene3d_render_preview_label_resolution",{},"分辨率"),resolution720p:()=>l.t("Pippit_scene3d_render_preview_option_resolution720p",{},"720p"),resolution1080p:()=>l.t("Pippit_scene3d_render_preview_option_resolution1080p",{},"1080p"),currentView:()=>l.t("Pippit_scene3d_render_preview_label_currentview",{},"当前视角"),currentFrame:()=>l.t("Pippit_scene3d_render_preview_label_currentframe",{},"当前帧"),startFrame:()=>l.t("Pippit_scene3d_render_preview_label_startframe",{},"起始帧"),endFrame:()=>l.t("Pippit_scene3d_render_preview_label_endframe",{},"结束帧"),frameWithNumber:e=>l.t("Pippit_scene3d_render_preview_label_framewithnumber",{number:e},"第 {number} 帧"),framesRange:(e,t)=>l.t("Pippit_scene3d_render_preview_label_framesrange",{number1:e,number2:t},"{number1}-{number2} 帧"),imageHint:()=>l.t("Pippit_scene3d_render_preview_desc_imagerange",{},"渲染当前机位的当前帧"),videoHint:()=>l.t("Pippit_scene3d_render_preview_desc_videorange",{},"预览显示当前帧,视频会渲染当前机位的时间轴范围"),refreshPreview:()=>l.t("Pippit_scene3d_render_preview_btn_refreshpreview",{},"刷新预览"),noPreview:()=>l.t("Pippit_scene3d_render_preview_empty_nopreview",{},"暂无预览"),previewAlt:(e,t)=>l.t("Pippit_scene3d_render_preview_alt_imagepreview",{text:e,number:t},"{text} 第 {number} 帧预览"),renderImage:()=>l.t("Pippit_scene3d_render_preview_btn_renderimage",{},"渲染图片"),renderVideo:()=>l.t("Pippit_scene3d_render_preview_btn_rendervideo",{},"渲染视频")},imageReplicate:{title:()=>l.t("Pippit_scene3d_image_replicate_title_import",{},"AI 识图导入"),toolbar:()=>l.t("Pippit_scene3d_image_replicate_toolbar_entry",{},"AI识图"),panelDescription:()=>l.t("Pippit_scene3d_image_replicate_desc_panel",{},"选择一张图片生成 3D 场景元素"),exampleSectionTitle:()=>l.t("Pippit_scene3d_image_replicate_example_section_title",{},"效果示例"),exampleReferenceLabel:()=>l.t("Pippit_scene3d_image_replicate_example_reference_label",{},"参考图"),exampleTitle:()=>l.t("Pippit_scene3d_image_replicate_example_title_generate_editable_scene",{},"一张图生成 3D 场景"),exampleDescription:()=>l.t("Pippit_scene3d_image_replicate_example_desc_restore_composition",{},"自动还原人物站位、机位与场景布局,生成可继续编辑的 3D 场景。"),exampleResultLabel:()=>l.t("Pippit_scene3d_image_replicate_example_result_label",{},"3D 场景"),sourceSectionTitle:()=>l.t("Pippit_scene3d_image_replicate_source_section",{},"选择图片来源"),sourceLocalUpload:()=>l.t("Pippit_scene3d_image_replicate_source_local_upload",{},"本地上传"),sourceAssetLibrary:()=>l.t("Pippit_scene3d_image_replicate_source_asset_library",{},"资产库"),sourceCanvasImage:()=>l.t("Pippit_scene3d_image_replicate_source_canvas_image",{},"画布图片"),sourceHistory:()=>l.t("Pippit_scene3d_image_replicate_source_history",{},"历史结果"),selectedSourceTitle:()=>l.t("Pippit_scene3d_image_replicate_selected_source_title",{},"已选择图片"),emptySource:()=>l.t("Pippit_scene3d_image_replicate_empty_source",{},"先选择一张图片作为识图来源"),failureTitle:()=>l.t("Pippit_scene3d_image_replicate_failure_title",{},"识图失败"),changeImage:()=>l.t("Pippit_scene3d_image_replicate_btn_change_image",{},"更换图片"),retry:()=>l.t("Pippit_scene3d_image_replicate_btn_retry",{},"重试"),reset:()=>l.t("Pippit_scene3d_image_replicate_btn_reset",{},"重置"),start:wde,historySectionTitle:()=>l.t("Pippit_scene3d_image_replicate_history_section_title",{},"最近识图"),historyViewAll:()=>l.t("Pippit_scene3d_image_replicate_history_btn_view_all",{},"查看全部"),historyLoading:()=>l.t("Pippit_scene3d_image_replicate_history_loading",{},"正在加载识图记录"),historyUnnamedItem:()=>l.t("Pippit_scene3d_image_replicate_history_unnamed_item",{},"未命名记录"),historyUse:()=>l.t("Pippit_scene3d_image_replicate_history_btn_use",{},"使用"),historyStatus:e=>e==="failed"?l.t("Pippit_scene3d_image_replicate_history_status_failed",{},"失败"):e==="running"?l.t("Pippit_scene3d_image_replicate_history_status_running",{},"识图中"):l.t("Pippit_scene3d_image_replicate_history_status_succeeded",{},"已完成"),localTab:()=>l.t("Pippit_scene3d_image_replicate_tab_local",{},"本地上传"),historyTab:()=>l.t("Pippit_scene3d_image_replicate_tab_history",{},"历史记录"),jsonTab:()=>l.t("Pippit_scene3d_image_replicate_tab_json",{},"粘贴 JSON"),localUploadTitle:()=>l.t("Pippit_scene3d_image_replicate_upload_title",{},"点击上传图片 或 拖拽图片至此上传"),localUploadHint:()=>l.t("Pippit_scene3d_image_replicate_upload_hint",{},"上传后将先转为小云雀资产,再用于识图导入"),historyPickTitle:()=>l.t("Pippit_scene3d_image_replicate_history_title",{},"选择画布历史图片"),historyPickHint:()=>l.t("Pippit_scene3d_image_replicate_history_hint",{},"从当前画布已有图片节点中选择一张作为识图来源"),jsonPlaceholder:()=>l.t("Pippit_scene3d_image_replicate_json_placeholder",{},"粘贴 prompt 输出或识图返回的 JSON 文本"),modeTitle:()=>l.t("Pippit_scene3d_image_replicate_mode_title",{},"选择是否覆盖当前场景"),modeLabel:e=>e==="overwrite"?l.t("Pippit_scene3d_image_replicate_mode_overwrite",{},"覆盖当前导演台"):l.t("Pippit_scene3d_image_replicate_mode_insert",{},"插入当前导演台"),modeDescription:e=>e==="overwrite"?l.t("Pippit_scene3d_image_replicate_mode_overwrite_desc",{},"作为站位参考后插入,覆盖当前全景、角色和机位"):l.t("Pippit_scene3d_image_replicate_mode_insert_desc",{},"作为站位参考后插入,不覆盖当前全景、角色和机位"),sourceReady:()=>l.t("Pippit_scene3d_image_replicate_status_source_ready",{},"图片已准备好"),resultTitle:()=>l.t("Pippit_scene3d_image_replicate_result_title",{},"已获取 JSON 结果"),resultPending:()=>l.t("Pippit_scene3d_image_replicate_result_pending",{},"任务已提交,结果生成成功后会返回 JSON 文本"),submit:()=>l.t("Pippit_scene3d_image_replicate_btn_submit",{},"识图导入场景"),jsonSubmit:()=>l.t("Pippit_scene3d_image_replicate_btn_json_submit",{},"粘贴导入"),loadingScene:()=>l.t("Pippit_scene3d_image_replicate_status_loadingscene",{},"正在加载场景..."),errorUploadUnavailable:()=>l.t("Pippit_scene3d_image_replicate_error_upload_unavailable",{},"上传服务未就绪,请稍后重试"),errorUploadNoAsset:()=>l.t("Pippit_scene3d_image_replicate_error_upload_no_asset",{},"上传结果缺少可用于识图的资产 ID"),errorUploadFailed:()=>l.t("Pippit_scene3d_image_replicate_error_upload_failed",{},"图片上传失败,请重试"),errorHistoryUnavailable:()=>l.t("Pippit_scene3d_image_replicate_error_history_unavailable",{},"历史记录服务未就绪,请稍后重试"),errorHistoryNoAsset:()=>l.t("Pippit_scene3d_image_replicate_error_history_no_asset",{},"所选图片缺少可用于识图的资产信息"),errorHistoryFailed:()=>l.t("Pippit_scene3d_image_replicate_error_history_failed",{},"历史图片选择失败,请重试"),errorJsonUnavailable:()=>l.t("Pippit_scene3d_image_replicate_error_json_unavailable",{},"JSON 导入服务未就绪,请稍后重试"),errorJsonInvalid:()=>l.t("Pippit_scene3d_image_replicate_error_json_invalid",{},"JSON 格式不正确,请检查后重试"),errorJsonFailed:()=>l.t("Pippit_scene3d_image_replicate_error_json_failed",{},"JSON 导入失败,请重试"),errorMissingSource:()=>l.t("Pippit_scene3d_image_replicate_error_missing_source",{},"请先上传或选择一张图片"),errorSourceNoAsset:()=>l.t("Pippit_scene3d_image_replicate_error_source_no_asset",{},"所选图片缺少可用于识图的资产信息"),errorAssetLibraryUnavailable:()=>l.t("Pippit_scene3d_image_replicate_error_asset_library_unavailable",{},"资产库暂不可用,请稍后重试"),errorAssetLibraryFailed:()=>l.t("Pippit_scene3d_image_replicate_error_asset_library_failed",{},"资产库图片选择失败,请重试"),errorSubmitFailed:()=>l.t("Pippit_scene3d_image_replicate_error_submit_failed",{},"识图导入失败,请重试"),errorSceneLoadFailed:()=>l.t("Pippit_scene3d_image_replicate_error_sceneload_failed",{},"场景解析或加载失败,请重试"),errorSceneLoadFailedWithReason:e=>l.t("Pippit_scene3d_image_replicate_error_sceneload_failed_withreason",{text:e},"场景解析或加载失败:{text}")},cameraPreset:{currentView:()=>l.t("Pippit_scene3d_camera_preset_currentview",{},"当前视角"),frontMedium:()=>l.t("Pippit_scene3d_camera_preset_frontmedium",{},"正面中景"),frontClose:()=>l.t("Pippit_scene3d_camera_preset_frontclose",{},"正面特写"),frontWide:()=>l.t("Pippit_scene3d_camera_preset_frontwide",{},"正面全景"),sideFollow:()=>l.t("Pippit_scene3d_camera_preset_sidefollow",{},"侧面跟拍"),sideClose:()=>l.t("Pippit_scene3d_camera_preset_sideclose",{},"侧面近景"),backMedium:()=>l.t("Pippit_scene3d_camera_preset_backmedium",{},"背面中景"),topWide:()=>l.t("Pippit_scene3d_camera_preset_topwide",{},"俯拍全景"),fortyFiveTop:()=>l.t("Pippit_scene3d_camera_preset_fortyfivetop",{},"45° 俯拍"),lowAngle:()=>l.t("Pippit_scene3d_camera_preset_lowangle",{},"低角度仰拍"),lowWide:()=>l.t("Pippit_scene3d_camera_preset_lowwide",{},"低角度广角"),overShoulder:()=>l.t("Pippit_scene3d_camera_preset_overshoulder",{},"过肩镜头"),overShoulderRight:()=>l.t("Pippit_scene3d_camera_preset_overshoulderright",{},"过肩镜头(右)"),birdEye:()=>l.t("Pippit_scene3d_camera_preset_birdeye",{},"鸟瞰"),dutch:()=>l.t("Pippit_scene3d_camera_preset_dutch",{},"荷兰角")},hierarchy:{scene:()=>l.t("Pippit_scene3d_hierarchy_title_scene",{},"对象"),addCamera:()=>l.t("Pippit_scene3d_hierarchy_btn_addcamera",{},"新增机位"),searchPlaceholder:()=>l.t("Pippit_scene3d_hierarchy_placeholder_search",{},"搜索对象"),scene3d:()=>l.t("Pippit_scene3d_hierarchy_item_3dscene",{},"3D场景"),hide:()=>l.t("Pippit_scene3d_hierarchy_btn_hide",{},"隐藏"),show:()=>l.t("Pippit_scene3d_hierarchy_btn_show",{},"显示"),unlock:()=>l.t("Pippit_scene3d_hierarchy_btn_unlock",{},"解锁"),lock:()=>l.t("Pippit_scene3d_hierarchy_btn_lock",{},"锁定"),copy:()=>l.t("Pippit_scene3d_hierarchy_menu_copy",{},"复制"),paste:()=>l.t("Pippit_scene3d_hierarchy_menu_paste",{},"粘贴"),rename:()=>l.t("Pippit_scene3d_hierarchy_menu_rename",{},"重命名"),group:()=>l.t("Pippit_scene3d_hierarchy_menu_group",{},"打组"),ungroup:()=>l.t("Pippit_scene3d_hierarchy_menu_ungroup",{},"解组")},leftPanel:{navigation:()=>l.t("Pippit_scene3d_leftpanel_arialabel_navigation",{},"左侧导航"),collapsePanel:()=>l.t("Pippit_scene3d_leftpanel_arialabel_collapsepanel",{},"收起左侧面板"),expandPanel:()=>l.t("Pippit_scene3d_leftpanel_arialabel_expandpanel",{},"展开左侧面板")},rightPanel:{properties:()=>l.t("Pippit_scene3d_rightpanel_tab_properties",{},"属性"),assets:()=>l.t("Pippit_scene3d_rightpanel_tab_assets",{},"资源"),collapseInspector:()=>l.t("Pippit_scene3d_rightpanel_arialabel_collapseinspector",{},"收起属性面板"),expandInspector:()=>l.t("Pippit_scene3d_rightpanel_arialabel_expandinspector",{},"展开属性面板"),collapseCameraPreview:()=>l.t("Pippit_scene3d_rightpanel_tooltip_collapsecamerapreview",{},"收起机位预览"),expandCameraPreview:()=>l.t("Pippit_scene3d_rightpanel_tooltip_expandcamerapreview",{},"展开机位预览"),resizeHierarchy:()=>l.t("Pippit_scene3d_layout_arialabel_resizehierarchy",{},"拖拽调整层级栏宽度"),resizeInspector:()=>l.t("Pippit_scene3d_layout_arialabel_resizeinspector",{},"拖拽调整检查器宽度")},assets:{official:()=>l.t("Pippit_scene3d_asset_tab_official",{},"官方资源"),mine:()=>l.t("Pippit_scene3d_asset_tab_mine",{},"我的资源"),library:()=>l.t("Pippit_scene3d_asset_title_library",{},"资源库"),propLibrary:()=>l.t("Pippit_scene3d_asset_tab_proplibrary",{},"道具"),motionLibrary:()=>l.t("Pippit_scene3d_asset_tab_motionlibrary",{},"动作"),myLibrary:()=>l.t("Pippit_scene3d_asset_tab_mylibrary",{},"我的"),entityGroup:()=>l.t("Pippit_scene3d_asset_group_entity",{},"实体"),behaviorGroup:()=>l.t("Pippit_scene3d_asset_group_behavior",{},"行为"),characterLibrary:()=>l.t("Pippit_scene3d_asset_tab_characterlibrary",{},"角色"),cameraLibrary:()=>l.t("Pippit_scene3d_asset_tab_cameralibrary",{},"机位"),characterSingleCategory:()=>l.t("Pippit_scene3d_asset_filter_singlecharacter",{},"单人"),characterCrowdCategory:()=>l.t("Pippit_scene3d_asset_filter_crowd",{},"群众"),basicShapes:()=>l.t("Pippit_scene3d_asset_category_basicshapes",{},"基础形状"),characterKind:()=>l.t("Pippit_scene3d_asset_kind_character",{},"角色"),uploadKind:()=>l.t("Pippit_scene3d_asset_kind_upload",{},"上传"),propKind:()=>l.t("Pippit_scene3d_asset_kind_prop",{},"道具"),motionKind:()=>l.t("Pippit_scene3d_asset_kind_motion",{},"动作"),cameraKind:()=>l.t("Pippit_scene3d_asset_kind_camera",{},"机位"),addedBadge:()=>l.t("Pippit_scene3d_asset_badge_added",{},"已添加"),all:()=>l.t("Pippit_scene3d_asset_filter_all",{},"全部"),searchProps:()=>l.t("Pippit_scene3d_asset_placeholder_searchprops",{},"搜索道具"),searchMotions:()=>l.t("Pippit_scene3d_asset_placeholder_searchmotions",{},"搜索动作"),motionTargetSelected:(e,t)=>l.t("Pippit_scene3d_asset_desc_motiontargetselected",{number:t,text:e},"已选中{text},点击动作从第 {number} 帧开始添加"),motionTargetNewCharacter:e=>l.t("Pippit_scene3d_asset_desc_motiontargetnewcharacter",{number:e},"未选中角色,点击动作将新建角色并从第 {number} 帧开始添加"),motionTargetLocked:e=>l.t("Pippit_scene3d_asset_desc_motiontargetlocked",{text:e},"{text}已锁定,解锁后可添加动作"),motionCardApplyToFrame:(e,t)=>l.t("Pippit_scene3d_asset_label_motioncardapplytoframe",{number:t,text:e},"为{text} 从第 {number} 帧添加动作"),motionCardCreateCharacterAtFrame:e=>l.t("Pippit_scene3d_asset_label_motioncardcreatecharacteratframe",{number:e},"点击新建角色 · 第 {number} 帧"),motionCardLocked:()=>l.t("Pippit_scene3d_asset_label_motioncardlocked",{},"角色已锁定"),motionAppliedToCharacter:(e,t,n)=>l.t("Pippit_scene3d_asset_toast_motionappliedtocharacter",{number:n,text1:t,text2:e},"已在第 {number} 帧为{text1}添加「{text2}」"),motionAppliedToNewCharacter:(e,t,n)=>l.t("Pippit_scene3d_asset_toast_motionappliedtonewcharacter",{number:n,text1:t,text2:e},"已新建{text1}并在第 {number} 帧添加「{text2}」"),collapseLibrary:()=>l.t("Pippit_scene3d_asset_arialabel_collapselibrary",{},"收起资源库"),expandLibrary:()=>l.t("Pippit_scene3d_asset_arialabel_expandlibrary",{},"展开资源库"),resizeLibrary:()=>l.t("Pippit_scene3d_layout_arialabel_resizeassetlibrary",{},"拖拽调整资源库高度"),emptyMine:()=>l.t("Pippit_scene3d_asset_empty_mine",{},"暂无我的资源"),emptyOfficial:()=>l.t("Pippit_scene3d_asset_empty_official",{},"暂无官方资源"),emptyProps:()=>l.t("Pippit_scene3d_asset_empty_props",{},"暂无道具"),emptyMotions:()=>l.t("Pippit_scene3d_asset_empty_motions",{},"暂无动作"),emptySearch:()=>l.t("Pippit_scene3d_asset_empty_searchresults",{},"未找到匹配资源"),selectResource:()=>l.t("Pippit_scene3d_asset_dialog_title_selectresource",{},"选择资源"),poseableModels:()=>l.t("Pippit_scene3d_asset_category_poseablemodels",{},"可调姿势模型"),cube:()=>l.t("Pippit_scene3d_asset_name_cube",{},"正方体"),cone:()=>l.t("Pippit_scene3d_asset_name_cone",{},"圆锥"),cylinder:()=>l.t("Pippit_scene3d_asset_name_cylinder",{},"圆柱体"),frustum:()=>l.t("Pippit_scene3d_asset_name_frustum",{},"截锥"),roundedBox:()=>l.t("Pippit_scene3d_asset_name_roundedbox",{},"圆角方块"),capsule:()=>l.t("Pippit_scene3d_asset_name_capsule",{},"胶囊体"),sphere:()=>l.t("Pippit_scene3d_asset_name_sphere",{},"球体")},myAssets:{characterType:()=>l.t("Pippit_scene3d_myassets_filter_character",{},"角色"),propType:()=>l.t("Pippit_scene3d_myassets_filter_prop",{},"道具"),motionType:()=>l.t("Pippit_scene3d_myassets_filter_motion",{},"动作"),upload:()=>l.t("Pippit_scene3d_myassets_btn_upload",{},"上传"),apply:()=>l.t("Pippit_scene3d_myassets_btn_apply",{},"应用"),download:()=>l.t("Pippit_scene3d_myassets_btn_download",{},"下载"),retry:()=>l.t("Pippit_scene3d_myassets_btn_retry",{},"重试"),uploadCharacter:()=>l.t("Pippit_scene3d_myassets_menu_uploadcharacter",{},"上传角色"),uploadProp:()=>l.t("Pippit_scene3d_myassets_menu_uploadprop",{},"上传道具"),uploadMotion:()=>l.t("Pippit_scene3d_myassets_menu_uploadmotion",{},"上传动作"),search:()=>l.t("Pippit_scene3d_myassets_placeholder_search",{},"搜索我的素材"),history:()=>l.t("Pippit_scene3d_myassets_title_history",{},"历史记录"),empty:()=>l.t("Pippit_scene3d_myassets_empty_noassets",{},"暂无我的素材"),loading:()=>l.t("Pippit_scene3d_myassets_loading_assets",{},"正在加载我的素材"),loadFailed:()=>l.t("Pippit_scene3d_myassets_error_loadfailed",{},"无法加载我的素材,请重试"),uploading:()=>l.t("Pippit_scene3d_myassets_status_uploading",{},"上传中"),checking:()=>l.t("Pippit_scene3d_myassets_status_checking",{},"检查中"),ready:()=>l.t("Pippit_scene3d_myassets_status_ready",{},"可使用"),failed:()=>l.t("Pippit_scene3d_myassets_status_failed",{},"上传失败"),unsupportedFormat:()=>l.t("Pippit_scene3d_myassets_error_unsupportedformat",{},"当前文件格式不支持"),fileTooLarge:()=>l.t("Pippit_scene3d_myassets_error_filetoolarge",{},"文件超过大小限制"),motionNotDetected:()=>l.t("Pippit_scene3d_myassets_error_motionnotdetected",{},"未检测到动作"),motionRigIncompatible:()=>l.t("Pippit_scene3d_myassets_error_motionrigincompatible",{},"动作骨架暂不兼容"),uploadFailed:()=>l.t("Pippit_scene3d_myassets_error_uploadfailed",{},"无法上传素材,请重试"),uploadedToast:e=>l.t("Pippit_scene3d_myassets_toast_uploaded",{text:e},"已上传{text}素材"),textMotionEntry:()=>l.t("Pippit_scene3d_myassets_btn_generate_motion",{},"AI 生成动作"),textMotionTitle:()=>l.t("Pippit_scene3d_myassets_card_title_aigeneratemotion",{},"AI 生成动作"),textMotionLimitedFree:()=>l.t("Pippit_scene3d_myassets_card_badge_limitedfree",{},"限免"),textMotionPromptLabel:()=>l.t("Pippit_scene3d_myassets_text_motion_prompt_label",{},"描述想要的动作"),textMotionPromptPlaceholder:()=>l.t("Pippit_scene3d_myassets_text_motion_prompt_placeholder",{},"描述动作,例如:向前挥手并自然放下"),textMotionGenerate:()=>l.t("Pippit_scene3d_myassets_btn_text_motion_generate",{},"生成"),textMotionGenerating:()=>l.t("Pippit_scene3d_myassets_status_text_motion_generating",{},"正在生成"),textMotionGenerated:()=>l.t("Pippit_scene3d_myassets_toast_text_motion_generated",{},"动作已生成"),textMotionDownload:()=>l.t("Pippit_scene3d_myassets_btn_text_motion_download",{},"下载 .pt"),textMotionFailed:()=>l.t("Pippit_scene3d_myassets_error_text_motion_failed",{},"生成失败,请重试")},uploadedMotion:{title:()=>l.t("Pippit_scene3d_uploadedmotion_dialog_title_detected",{},"检测到模型自带动作"),description:()=>l.t("Pippit_scene3d_uploadedmotion_dialog_desc_chooseaction",{},"这个模型包含可播放的动作。你可以直接添加到时间轴,也可以导入为关键帧。"),motionLabel:()=>l.t("Pippit_scene3d_uploadedmotion_label_motion",{},"动作"),durationLabel:()=>l.t("Pippit_scene3d_uploadedmotion_label_duration",{},"时长"),durationValue:e=>l.t("Pippit_scene3d_uploadedmotion_label_durationvalue",{number:e},"约 {number} 秒"),directTitle:()=>l.t("Pippit_scene3d_uploadedmotion_option_title_directplay",{},"直接播放动作"),recommended:()=>l.t("Pippit_scene3d_uploadedmotion_badge_recommended",{},"推荐"),directDescription:()=>l.t("Pippit_scene3d_uploadedmotion_option_desc_directplay",{},"适合播放、裁剪、调速,性能更好。"),keyframesTitle:()=>l.t("Pippit_scene3d_uploadedmotion_option_title_importkeyframes",{},"导入为关键帧"),keyframesDescription:()=>l.t("Pippit_scene3d_uploadedmotion_option_desc_importkeyframes",{},"可以逐帧编辑骨骼动作。"),keyframesHint:()=>l.t("Pippit_scene3d_uploadedmotion_option_hint_importkeyframes",{},"转换后可编辑,但导入时间会更长。"),skip:()=>l.t("Pippit_scene3d_uploadedmotion_btn_skip",{},"暂不使用动作"),addToTimeline:()=>l.t("Pippit_scene3d_uploadedmotion_btn_addtotimeline",{},"添加到时间轴"),importKeyframes:()=>l.t("Pippit_scene3d_uploadedmotion_btn_importkeyframes",{},"导入关键帧")},cameraMotion:{library:()=>l.t("Pippit_scene3d_camera_motion_tab_library",{},"运镜"),kind:()=>l.t("Pippit_scene3d_camera_motion_kind_camera_motion",{},"运镜"),apply:()=>l.t("Pippit_scene3d_camera_motion_btn_previewmotion",{},"应用"),add:()=>l.t("Pippit_scene3d_camera_motion_btn_addmotion",{},"添加"),targetCurrentView:e=>l.t("Pippit_scene3d_camera_motion_desc_targetcurrentview",{number:e},"未选中机位,点击运镜将在第 {number} 帧添加当前视角机位"),targetSelected:(e,t)=>l.t("Pippit_scene3d_camera_motion_desc_targetselected",{number:t,text:e},"已选中{text},点击运镜从第 {number} 帧开始应用"),cardApplyToFrame:e=>l.t("Pippit_scene3d_camera_motion_label_cardapplytoframe",{number:e},"点击应用到第 {number} 帧"),cardAddToFrame:e=>l.t("Pippit_scene3d_camera_motion_label_cardaddtoframe",{number:e},"点击添加到第 {number} 帧"),lookAtTarget:()=>l.t("Pippit_scene3d_camera_motion_label_lookattarget",{},"注视目标"),stopPreview:()=>l.t("Pippit_scene3d_camera_motion_btn_stoppreview",{},"停止预览"),applyToCamera:()=>l.t("Pippit_scene3d_camera_motion_btn_applytocamera",{},"应用到机位"),previewing:e=>l.t("Pippit_scene3d_camera_motion_status_previewing",{text:e},"正在预览:{text}"),previewReady:e=>l.t("Pippit_scene3d_camera_motion_status_previewready",{text:e},"预览结束:{text}"),appliedToFrame:(e,t)=>l.t("Pippit_scene3d_camera_motion_toast_appliedtoframe",{number:t,text:e},"已从第 {number} 帧添加「{text}」"),disabledRequiresCharacter:()=>l.t("Pippit_scene3d_camera_motion_disabled_requirescharacter",{},"需要先选择角色"),disabledRequiresOccluder:()=>l.t("Pippit_scene3d_camera_motion_disabled_requiresoccluder",{},"需要先选择遮挡物"),disabledRequiresPath:()=>l.t("Pippit_scene3d_camera_motion_disabled_requirespath",{},"需要先绘制路径"),disabledRequiresFocusTarget:()=>l.t("Pippit_scene3d_camera_motion_disabled_requiresfocustarget",{},"需要先选择焦点目标"),disabledV2:()=>l.t("Pippit_scene3d_camera_motion_disabled_v2",{},"暂未支持预览"),errorNoCamera:()=>l.t("Pippit_scene3d_camera_motion_error_nocamera",{},"请先添加一个机位"),errorMissingTarget:()=>l.t("Pippit_scene3d_camera_motion_error_missingtarget",{},"需要先选择一个目标"),errorUnsupported:()=>l.t("Pippit_scene3d_camera_motion_error_unsupported",{},"当前版本暂不支持这个运镜"),errorPreviewFailed:()=>l.t("Pippit_scene3d_camera_motion_error_previewfailed",{},"无法预览这个运镜,请换一个再试"),presetLabel:kde,dollyIn:()=>l.t("Pippit_scene3d_camera_motion_name_dollyin",{},"推镜 Push"),dollyOut:()=>l.t("Pippit_scene3d_camera_motion_name_dollyout",{},"拉镜 Pull"),orbit:()=>l.t("Pippit_scene3d_camera_motion_name_orbit",{},"环绕 Orbit"),tilt:()=>l.t("Pippit_scene3d_camera_motion_name_tilt",{},"摇镜 Tilt")},pathDrawing:{toolbar:()=>l.t("Pippit_scene3d_path_toolbar_btn_path",{},"轨迹"),clickMode:()=>l.t("Pippit_scene3d_path_toolbar_option_clickpoints",{},"点击加点"),drawMode:()=>l.t("Pippit_scene3d_path_toolbar_option_drawpath",{},"拖拽绘制"),editingStatus:()=>l.t("Pippit_scene3d_path_viewport_status_editingpath",{},"轨迹编辑中"),editPath:()=>l.t("Pippit_scene3d_path_contextmenu_btn_editpath",{},"编辑轨迹"),clickHint:()=>l.t("Pippit_scene3d_path_viewport_hint_clickpoints",{},"点击添加轨迹点,拖拽轨迹点编辑,空白处拖拽旋转视角,双击或保存完成"),drawHint:()=>l.t("Pippit_scene3d_path_viewport_hint_drawpath",{},"空白处第一次拖拽绘制新轨迹,之后拖拽空白处旋转视角,双击或保存完成"),applyCurrentActionToCharacter:()=>l.t("Pippit_scene3d_path_inspector_btn_applycurrentactiontocharacter",{},"沿轨迹播放动作"),applySection:()=>l.t("Pippit_scene3d_path_inspector_title_applypath",{},"应用轨迹"),pointCount:e=>l.t("Pippit_scene3d_path_inspector_label_pointcount",{num:e,number:e},"{number} 个轨迹点"),noPathSelected:()=>l.t("Pippit_scene3d_path_inspector_status_nopathselected",{},"未选择轨迹"),durationFrames:()=>l.t("Pippit_scene3d_path_inspector_label_durationframes",{},"持续帧数"),characterTarget:()=>l.t("Pippit_scene3d_path_inspector_label_charactertarget",{},"目标角色"),cameraTarget:()=>l.t("Pippit_scene3d_path_inspector_label_cameratarget",{},"目标机位"),cameraLookAt:()=>l.t("Pippit_scene3d_path_inspector_label_cameralookat",{},"机位朝向"),lookAtTarget:()=>l.t("Pippit_scene3d_path_inspector_option_lookattarget",{},"看向目标"),lookAtTangent:()=>l.t("Pippit_scene3d_path_inspector_option_lookattangent",{},"沿轨迹方向"),lookAtCurrent:()=>l.t("Pippit_scene3d_path_inspector_option_lookatcurrent",{},"保持当前注视点"),lookAtObject:()=>l.t("Pippit_scene3d_path_inspector_label_lookatobject",{},"注视对象"),applyToCharacter:()=>l.t("Pippit_scene3d_path_inspector_btn_applytocharacter",{},"应用到角色"),applyToCamera:()=>l.t("Pippit_scene3d_path_inspector_btn_applytocamera",{},"应用到机位"),timelineRequired:()=>l.t("Pippit_scene3d_path_inspector_hint_timeline_required",{},"开启时间轴后可应用轨迹")},performanceOverlay:{fps:()=>l.t("Pippit_scene3d_performance_overlay_label_fps",{},"FPS"),frame:()=>l.t("Pippit_scene3d_performance_overlay_label_frame",{},"Frame"),cpuBusy:()=>l.t("Pippit_scene3d_performance_overlay_label_cpubusy",{},"CPU busy"),longTask:()=>l.t("Pippit_scene3d_performance_overlay_label_longtask",{},"Long task"),jsHeap:()=>l.t("Pippit_scene3d_performance_overlay_label_jsheap",{},"JS heap"),drawCalls:()=>l.t("Pippit_scene3d_performance_overlay_label_drawcalls",{},"Draw calls"),triangles:()=>l.t("Pippit_scene3d_performance_overlay_label_triangles",{},"Triangles"),geometryObjects:()=>l.t("Pippit_scene3d_performance_overlay_label_geometryobjects",{},"Geometry objects"),gpuGeometries:()=>l.t("Pippit_scene3d_performance_overlay_label_gpugeometries",{},"GPU geometries"),textures:()=>l.t("Pippit_scene3d_performance_overlay_label_textures",{},"Textures"),programs:()=>l.t("Pippit_scene3d_performance_overlay_label_programs",{},"Programs"),gpuFrame:()=>l.t("Pippit_scene3d_performance_overlay_label_gpuframe",{},"GPU frame"),linesPoints:()=>l.t("Pippit_scene3d_performance_overlay_label_linespoints",{},"Lines / Points"),sceneObjects:()=>l.t("Pippit_scene3d_performance_overlay_label_sceneobjects",{},"Scene objects"),meshesSkinned:()=>l.t("Pippit_scene3d_performance_overlay_label_meshesskinned",{},"Meshes / Skinned"),materials:()=>l.t("Pippit_scene3d_performance_overlay_label_materials",{},"Materials"),runtimeObjects:()=>l.t("Pippit_scene3d_performance_overlay_label_runtimeobjects",{},"Runtime objects"),labelsHelpers:()=>l.t("Pippit_scene3d_performance_overlay_label_labelshelpers",{},"Labels / Helpers"),trajectories:()=>l.t("Pippit_scene3d_performance_overlay_label_trajectories",{},"Trajectories"),controllers:()=>l.t("Pippit_scene3d_performance_overlay_label_controllers",{},"Controllers"),assetLoads:()=>l.t("Pippit_scene3d_performance_overlay_label_assetloads",{},"Asset loads"),canvas:()=>l.t("Pippit_scene3d_performance_overlay_label_canvas",{},"Canvas"),priority1:()=>l.t("Pippit_scene3d_performance_overlay_tab_priority1",{},"Priority 1"),priority2:()=>l.t("Pippit_scene3d_performance_overlay_tab_priority2",{},"Priority 2"),openMetrics:()=>l.t("Pippit_scene3d_performance_overlay_arialabel_openmetrics",{},"Open performance metrics"),collapseMetrics:()=>l.t("Pippit_scene3d_performance_overlay_arialabel_closemetrics",{},"Collapse performance metrics"),unavailable:()=>l.t("Pippit_scene3d_performance_overlay_value_unavailable",{},"n/a"),frameValue:(e,t)=>l.t("Pippit_scene3d_performance_overlay_value_frame",{text1:e,text2:t},"{text1} ms avg / {text2} ms max"),longTaskValue:(e,t,n)=>l.t("Pippit_scene3d_performance_overlay_value_longtask",{number:e,text1:t,text2:n},"{number} / {text1} ms / {text2} ms max"),visibleObjectsValue:(e,t)=>l.t("Pippit_scene3d_performance_overlay_value_visibleobjects",{number1:e,number2:t},"{number1} ({number2} visible)"),trajectoriesValue:(e,t)=>l.t("Pippit_scene3d_performance_overlay_value_trajectories",{number1:e,number2:t},"{number1} camera / {number2} path"),controllersValue:(e,t)=>l.t("Pippit_scene3d_performance_overlay_value_controllers",{number1:e,number2:t},"{number1} pose / {number2} motion"),canvasValue:(e,t,n)=>l.t("Pippit_scene3d_performance_overlay_value_canvas",{text1:e,text2:t,text3:n},"{text1} px / {text2} css / DPR {text3}"),megabytes:e=>l.t("Pippit_scene3d_performance_overlay_value_megabytes",{number:e},"{number} MB")},topbar:{director:()=>l.t("Pippit_scene3d_topbar_title_director",{},"3D导演台"),help:()=>l.t("Pippit_scene3d_topbar_btn_help",{},"帮助"),shortcuts:()=>l.t("Pippit_scene3d_topbar_btn_shortcuts",{},"快捷键"),basicOperations:()=>l.t("Pippit_scene3d_topbar_label_basicoperations",{},"基础操作"),basicOperationRotate:()=>l.t("Pippit_scene3d_topbar_label_basicoperationrotate",{},"旋转"),basicOperationPan:()=>l.t("Pippit_scene3d_topbar_label_basicoperationpan",{},"平移"),basicOperationZoom:()=>l.t("Pippit_scene3d_topbar_label_basicoperationzoom",{},"缩放"),basicOperationLeftButton:()=>l.t("Pippit_scene3d_topbar_label_basicoperationleftbutton",{},"左键"),basicOperationRightButton:()=>l.t("Pippit_scene3d_topbar_label_basicoperationrightbutton",{},"中键"),basicOperationWheel:()=>l.t("Pippit_scene3d_topbar_label_basicoperationwheel",{},"滚轮"),tutorial:()=>l.t("Pippit_scene3d_topbar_btn_tutorial",{},"使用教程"),exit:()=>l.t("Pippit_scene3d_topbar_btn_exit",{},"退出")},timeline:{tab:()=>l.t("Pippit_scene3d_timeline_tab_timeline",{},"时间轴"),panel:()=>l.t("Pippit_scene3d_timeline_panel_label",{},"时间轴"),expandPanel:()=>l.t("Pippit_scene3d_timeline_btn_expandtimeline",{},"展开时间轴"),collapsePanel:()=>l.t("Pippit_scene3d_timeline_btn_collapsetimeline",{},"收起时间轴"),playPreview:()=>l.t("Pippit_scene3d_timeline_btn_playpreview",{},"播放预览"),pausePreview:()=>l.t("Pippit_scene3d_timeline_btn_pausepreview",{},"暂停预览"),defaultRange:()=>l.t("Pippit_scene3d_timeline_label_defaultrange",{},"起始 1 · 结束 90"),emptyKeyframes:()=>l.t("Pippit_scene3d_timeline_empty_keyframes",{},"暂无关键帧 - 在动作库或运镜库应用一个行为来试试"),shotTrack:()=>l.t("Pippit_scene3d_timeline_track_shot",{},"机位轨道"),sceneTrack:()=>l.t("Pippit_scene3d_timeline_track_scene",{},"3D场景"),actionTrack:()=>l.t("Pippit_scene3d_timeline_track_action",{},"动作"),cameraMotionTrack:()=>l.t("Pippit_scene3d_timeline_track_cameramotion",{},"运镜"),pathMotionTrack:()=>l.t("Pippit_scene3d_timeline_track_pathmotion",{},"运动轨迹"),position:()=>l.t("Pippit_scene3d_timeline_track_position",{},"位置"),rotation:()=>l.t("Pippit_scene3d_timeline_track_rotation",{},"旋转"),scale:()=>l.t("Pippit_scene3d_timeline_track_scale",{},"缩放"),xPosition:()=>l.t("Pippit_scene3d_timeline_track_xposition",{},"X 位置"),yPosition:()=>l.t("Pippit_scene3d_timeline_track_yposition",{},"Y 位置"),zPosition:()=>l.t("Pippit_scene3d_timeline_track_zposition",{},"Z 位置"),xEulerRotation:()=>l.t("Pippit_scene3d_timeline_track_xeulerrotation",{},"X 欧拉旋转"),yEulerRotation:()=>l.t("Pippit_scene3d_timeline_track_yeulerrotation",{},"Y 欧拉旋转"),zEulerRotation:()=>l.t("Pippit_scene3d_timeline_track_zeulerrotation",{},"Z 欧拉旋转"),xRotation:()=>l.t("Pippit_scene3d_timeline_track_xrotation",{},"X 旋转"),yRotation:()=>l.t("Pippit_scene3d_timeline_track_yrotation",{},"Y 旋转"),zRotation:()=>l.t("Pippit_scene3d_timeline_track_zrotation",{},"Z 旋转"),wRotation:()=>l.t("Pippit_scene3d_timeline_track_wrotation",{},"W 旋转"),xScale:()=>l.t("Pippit_scene3d_timeline_track_xscale",{},"X 缩放"),yScale:()=>l.t("Pippit_scene3d_timeline_track_yscale",{},"Y 缩放"),zScale:()=>l.t("Pippit_scene3d_timeline_track_zscale",{},"Z 缩放"),cameraFov:()=>l.t("Pippit_scene3d_timeline_track_camerafov",{},"视角"),cameraLookAt:()=>l.t("Pippit_scene3d_timeline_track_cameralookat",{},"看向"),scenePosition:()=>l.t("Pippit_scene3d_timeline_track_sceneposition",{},"场景平移"),sceneRotation:()=>l.t("Pippit_scene3d_timeline_track_scenerotation",{},"场景旋转"),sceneScale:()=>l.t("Pippit_scene3d_timeline_track_scenescale",{},"场景缩放"),panoramaRotation:()=>l.t("Pippit_scene3d_timeline_track_panoramarotation",{},"全景旋转"),groundOpacity:()=>l.t("Pippit_scene3d_timeline_track_groundopacity",{},"地面透明度"),groundHeight:()=>l.t("Pippit_scene3d_timeline_track_groundheight",{},"地面高度"),play:()=>l.t("Pippit_scene3d_timeline_btn_play",{},"播放"),pause:()=>l.t("Pippit_scene3d_timeline_btn_pause",{},"暂停"),playReverse:()=>l.t("Pippit_scene3d_timeline_btn_playreverse",{},"反向播放"),playForward:()=>l.t("Pippit_scene3d_timeline_btn_playforward",{},"正向播放"),jumpToStartFrame:()=>l.t("Pippit_scene3d_timeline_btn_jumptostartframe",{},"跳到起始帧"),jumpToEndFrame:()=>l.t("Pippit_scene3d_timeline_btn_jumptoendframe",{},"跳到结束帧"),previousKeyframe:()=>l.t("Pippit_scene3d_timeline_btn_previouskeyframe",{},"上一关键帧"),nextKeyframe:()=>l.t("Pippit_scene3d_timeline_btn_nextkeyframe",{},"下一关键帧"),previousFrame:()=>l.t("Pippit_scene3d_timeline_btn_previousframe",{},"上一帧"),nextFrame:()=>l.t("Pippit_scene3d_timeline_btn_nextframe",{},"下一帧"),viewMode:()=>l.t("Pippit_scene3d_timeline_btn_viewmode",{},"视图"),playbackOptions:()=>l.t("Pippit_scene3d_timeline_btn_playbackoptions",{},"播放设置"),onlyShowSelected:()=>l.t("Pippit_scene3d_timeline_option_onlyshowselected",{},"仅显示已选中"),useTimecode:()=>l.t("Pippit_scene3d_timeline_option_usetimecode",{},"使用时间码"),loopPlayback:()=>l.t("Pippit_scene3d_timeline_option_loopplayback",{},"循环播放"),enableKeyframeSnap:()=>l.t("Pippit_scene3d_timeline_btn_enablekeyframesnap",{},"开启关键帧吸附"),disableKeyframeSnap:()=>l.t("Pippit_scene3d_timeline_btn_disablekeyframesnap",{},"关闭关键帧吸附"),snappedToFrame:e=>l.t("Pippit_scene3d_timeline_status_snappedtoframe",{number:e},"已吸附到第 {number} 帧"),emptySelectedOnly:()=>l.t("Pippit_scene3d_timeline_empty_selectedonly",{},"选择对象后查看时间轴轨道"),loading:()=>l.t("Pippit_scene3d_timeline_status_loadingfcurves",{},"正在加载时间轴数据"),currentFrame:()=>l.t("Pippit_scene3d_timeline_label_currentframe",{},"当前帧"),frameRange:()=>l.t("Pippit_scene3d_timeline_label_framerange",{},"帧范围"),collapseTrackList:()=>l.t("Pippit_scene3d_timeline_btn_collapsetracklist",{},"收起轨道列表"),expandTrackList:()=>l.t("Pippit_scene3d_timeline_btn_expandtracklist",{},"展开轨道列表"),startFrame:()=>l.t("Pippit_scene3d_timeline_label_startframe",{},"起始"),startFrameAriaLabel:()=>l.t("Pippit_scene3d_timeline_arialabel_startframe",{},"起始帧"),endFrame:()=>l.t("Pippit_scene3d_timeline_label_endframe",{},"结束"),endFrameAriaLabel:()=>l.t("Pippit_scene3d_timeline_arialabel_endframe",{},"结束帧"),fps:e=>l.t("Pippit_scene3d_timeline_label_fps",{number:e},"{number} fps"),interpolation:()=>l.t("Pippit_scene3d_timeline_label_interpolation",{},"插值"),interpolationBezier:()=>l.t("Pippit_scene3d_timeline_option_interpolationbezier",{},"平滑变速"),interpolationLinear:()=>l.t("Pippit_scene3d_timeline_option_interpolationlinear",{},"匀速运动"),interpolationHold:()=>l.t("Pippit_scene3d_timeline_option_interpolationhold",{},"定格跳转"),deleteKeyframe:()=>l.t("Pippit_scene3d_timeline_btn_deletekeyframe",{},"删除关键帧"),addKeyframe:()=>l.t("Pippit_scene3d_timeline_btn_addkeyframe",{},"添加关键帧"),addAllChannelKeyframes:()=>l.t("Pippit_scene3d_timeline_btn_addallchannelkeyframes",{},"添加全部通道关键帧"),expandTrack:e=>l.t("Pippit_scene3d_timeline_arialabel_expandtrack",{text:e},"展开{text}轨道"),collapseTrack:e=>l.t("Pippit_scene3d_timeline_arialabel_collapsetrack",{text:e},"收起{text}轨道"),pinTrack:e=>l.t("Pippit_scene3d_timeline_arialabel_pintrack",{text:e},"将{text}固定到时间轴顶部"),unpinTrack:e=>l.t("Pippit_scene3d_timeline_arialabel_unpintrack",{text:e},"取消固定{text}"),lockTrack:e=>l.t("Pippit_scene3d_timeline_arialabel_locktrack",{text:e},"锁定{text}关键帧通道"),unlockTrack:e=>l.t("Pippit_scene3d_timeline_arialabel_unlocktrack",{text:e},"解锁{text}关键帧通道"),insertKeyframe:()=>l.t("Pippit_scene3d_timeline_menu_insertkeyframe",{},"插入关键帧"),allChannels:()=>l.t("Pippit_scene3d_timeline_menu_allchannels",{},"全部通道"),selectedChannelOnly:()=>l.t("Pippit_scene3d_timeline_menu_selectedchannelonly",{},"仅选择通道"),deleteKeyframeFromMenu:()=>l.t("Pippit_scene3d_timeline_menu_deletekeyframe",{},"删除关键帧"),deleteKeyframeAtFrameFromMenu:e=>l.t("Pippit_scene3d_timeline_menu_deletekeyframeatframe",{number:e},"删除第 {number} 帧"),addMotionTransition:()=>l.t("Pippit_scene3d_timeline_menu_addmotiontransition",{},"添加过渡"),addCameraMotionTransition:()=>l.t("Pippit_scene3d_timeline_menu_addcameramotiontransition",{},"添加运镜过渡"),addPathMotionTransition:()=>l.t("Pippit_scene3d_timeline_menu_addpathmotiontransition",{},"添加运动轨迹过渡"),deleteMotionClip:()=>l.t("Pippit_scene3d_timeline_menu_deletemotionclip",{},"删除动作"),deleteCameraMotionClip:()=>l.t("Pippit_scene3d_timeline_menu_deletecameramotionclip",{},"删除运镜"),deletePathMotionClip:()=>l.t("Pippit_scene3d_timeline_menu_deletepathmotionclip",{},"删除运动轨迹"),deleteMotionTransition:()=>l.t("Pippit_scene3d_timeline_menu_deletemotiontransition",{},"删除过渡"),deleteCameraMotionTransition:()=>l.t("Pippit_scene3d_timeline_menu_deletecameramotiontransition",{},"移除运镜过渡"),deletePathMotionTransition:()=>l.t("Pippit_scene3d_timeline_menu_deletepathmotiontransition",{},"移除运动轨迹过渡"),duplicateMotionClip:()=>l.t("Pippit_scene3d_timeline_menu_duplicatemotionclip",{},"复制动作"),duplicateCameraMotionClip:()=>l.t("Pippit_scene3d_timeline_menu_duplicatecameramotionclip",{},"复制运镜"),duplicatePathMotionClip:()=>l.t("Pippit_scene3d_timeline_menu_duplicatepathmotionclip",{},"复制运动轨迹"),splitMotionClip:()=>l.t("Pippit_scene3d_timeline_menu_splitmotionclip",{},"分割动作"),splitPathMotionClip:()=>l.t("Pippit_scene3d_timeline_menu_splitpathmotionclip",{},"分割运动轨迹"),bakeMotionClip:()=>l.t("Pippit_scene3d_timeline_menu_bakemotionclip",{},"转换为关键帧"),bakeCameraMotionClip:()=>l.t("Pippit_scene3d_timeline_menu_bakecameramotionclip",{},"转换为关键帧"),bakePathMotionClip:()=>l.t("Pippit_scene3d_timeline_menu_bakepathmotionclip",{},"转换为关键帧"),bakeMotionTransition:()=>l.t("Pippit_scene3d_timeline_menu_bakemotiontransition",{},"转换过渡为关键帧"),bakeCameraMotionTransition:()=>l.t("Pippit_scene3d_timeline_menu_bakecameramotiontransition",{},"转换过渡为关键帧"),bakePathMotionTransition:()=>l.t("Pippit_scene3d_timeline_menu_bakepathmotiontransition",{},"转换过渡为关键帧"),cameraMotionTransitionTweenLinear:()=>l.t("Pippit_scene3d_timeline_menu_cameramotiontransitiontweenlinear",{},"直线"),cameraMotionTransitionTweenBezier:()=>l.t("Pippit_scene3d_timeline_menu_cameramotiontransitiontweenbezier",{},"贝塞尔"),cameraMotionTransitionTweenEaseIn:()=>l.t("Pippit_scene3d_timeline_menu_cameramotiontransitiontweeneasein",{},"渐入"),cameraMotionTransitionTweenEaseOut:()=>l.t("Pippit_scene3d_timeline_menu_cameramotiontransitiontweeneaseout",{},"渐出"),cameraMotionTransitionTweenEaseInOut:()=>l.t("Pippit_scene3d_timeline_menu_cameramotiontransitiontweeneaseinout",{},"渐入渐出"),bakeMotionClipFailed:()=>l.t("Pippit_scene3d_timeline_toast_bakemotionclipfailed",{},"动作转换失败,请重试"),cameraMotionKeyframeBlocked:()=>l.t("Pippit_scene3d_timeline_toast_cameramotionkeyframeblocked",{},"当前时间轴由于有预设运镜片段,不支持 K 帧。如有 K 帧需求,可以移到空白帧 K 帧,或将当前时间帧 Bake 成关键帧后再 K 帧。"),motionClipStartFrame:()=>l.t("Pippit_scene3d_timeline_label_motionclipstartframe",{},"开始"),motionClipEndFrame:()=>l.t("Pippit_scene3d_timeline_label_motionclipendframe",{},"结束"),motionClipSpeed:()=>l.t("Pippit_scene3d_timeline_label_motionclipspeed",{},"速度"),motionClipLoop:()=>l.t("Pippit_scene3d_timeline_btn_motioncliploop",{},"循环"),motionClipInPlace:()=>l.t("Pippit_scene3d_timeline_btn_motionclipinplace",{},"原地"),motionClipTrimmed:()=>l.t("Pippit_scene3d_timeline_badge_motioncliptrimmed",{},"裁剪"),clipPlaybackPingPongBadge:()=>l.t("Pippit_scene3d_timeline_badge_clipplaybackpingpong",{},"往返"),motionTransitionBadge:()=>l.t("Pippit_scene3d_timeline_badge_motiontransition",{},"过渡"),cameraMotionTransitionBadge:()=>l.t("Pippit_scene3d_timeline_badge_cameramotiontransition",{},"运镜过渡"),pathMotionTransitionBadge:()=>l.t("Pippit_scene3d_timeline_badge_pathmotiontransition",{},"轨迹过渡"),pathMotionReverseBadge:()=>l.t("Pippit_scene3d_timeline_badge_pathmotionreverse",{},"反向"),pathMotionMissingBadge:()=>l.t("Pippit_scene3d_timeline_badge_pathmotionmissing",{},"轨迹丢失"),derivedPathMotionFromKeyframes:()=>l.t("Pippit_scene3d_timeline_label_derivedpathmotionfromkeyframes",{},"关键帧生成"),motionClipHoldLastFrame:()=>l.t("Pippit_scene3d_timeline_label_motionclipholdlastframe",{},"末帧保持"),motionClipSourceRange:(e,t)=>l.t("Pippit_scene3d_timeline_label_motionclipsourcerange",{text1:e,text2:t},"源片段 {text1}s-{text2}s"),motionClipLoopSummary:e=>l.t("Pippit_scene3d_timeline_label_motioncliploopsummary",{number:e},"循环 {number} 次"),motionClipLoopSummaryWithRemainder:(e,t)=>l.t("Pippit_scene3d_timeline_label_motioncliploopsummarywithremainder",{number1:e,number2:t},"循环 {number1} 次 + {number2} 帧"),zoom:()=>l.t("Pippit_scene3d_timeline_label_zoom",{},"缩放"),keyframeAtFrame:e=>l.t("Pippit_scene3d_timeline_arialabel_keyframeatframe",{number:e},"第 {number} 帧关键帧"),motionClipAriaLabel:(e,t,n)=>l.t("Pippit_scene3d_timeline_arialabel_motionclip",{number1:t,number2:n,text:e},"{text},第 {number1} 到 {number2} 帧"),motionTransitionAriaLabel:(e,t)=>l.t("Pippit_scene3d_timeline_arialabel_motiontransition",{number1:e,number2:t},"过渡,第 {number1} 到 {number2} 帧"),cameraMotionClipAriaLabel:(e,t,n)=>l.t("Pippit_scene3d_timeline_arialabel_cameramotionclip",{number1:t,number2:n,text:e},"{text} 运镜,第 {number1} 到 {number2} 帧"),cameraMotionTransitionAriaLabel:(e,t)=>l.t("Pippit_scene3d_timeline_arialabel_cameramotiontransition",{number1:e,number2:t},"运镜过渡,第 {number1} 到 {number2} 帧"),pathMotionClipAriaLabel:(e,t,n)=>l.t("Pippit_scene3d_timeline_arialabel_pathmotionclip",{number1:t,number2:n,text:e},"{text},第 {number1} 到 {number2} 帧"),pathMotionTransitionAriaLabel:(e,t)=>l.t("Pippit_scene3d_timeline_arialabel_pathmotiontransition",{number1:e,number2:t},"运动轨迹过渡,第 {number1} 到 {number2} 帧")},shortcuts:{platformTabsAriaLabel:()=>l.t("Pippit_scene3d_shortcut_tabs_arialabel_platform",{},"快捷键平台"),windowsPlatform:()=>l.t("Pippit_scene3d_shortcut_tab_windows",{},"Windows"),macosPlatform:()=>l.t("Pippit_scene3d_shortcut_tab_macos",{},"macOS"),viewToolsGroup:()=>l.t("Pippit_scene3d_shortcut_group_viewtools",{},"视图与工具"),objectActionsGroup:()=>l.t("Pippit_scene3d_shortcut_group_objectactions",{},"对象操作"),hierarchyGroup:()=>l.t("Pippit_scene3d_shortcut_group_hierarchy",{},"层级"),timelineHistoryGroup:()=>l.t("Pippit_scene3d_shortcut_group_timelinehistory",{},"时间轴与历史"),boxSelect:()=>l.t("Pippit_scene3d_shortcut_label_boxselect",{},"框选"),leftButtonDrag:()=>l.t("Pippit_scene3d_shortcut_label_leftbuttondrag",{},"左键拖拽"),middleButtonDrag:()=>l.t("Pippit_scene3d_shortcut_label_middlebuttondrag",{},"中键拖拽"),wheel:()=>l.t("Pippit_scene3d_shortcut_label_wheel",{},"滚轮"),twoFingerSwipe:()=>l.t("Pippit_scene3d_shortcut_label_twofingerswipe",{},"双指滑动"),pinch:()=>l.t("Pippit_scene3d_shortcut_label_pinch",{},"双指捏合"),rotateView:()=>l.t("Pippit_scene3d_shortcut_label_rotateview",{},"旋转视图"),panView:()=>l.t("Pippit_scene3d_shortcut_label_panview",{},"平移视图"),trackpadPan:()=>l.t("Pippit_scene3d_shortcut_label_trackpadpan",{},"触摸板平移"),zoomView:()=>l.t("Pippit_scene3d_shortcut_label_zoomview",{},"缩放视图"),trackpadZoom:()=>l.t("Pippit_scene3d_shortcut_label_trackpadzoom",{},"触摸板缩放"),move:()=>l.t("Pippit_scene3d_shortcut_label_move",{},"移动工具"),rotate:()=>l.t("Pippit_scene3d_shortcut_label_rotate",{},"旋转工具"),scale:()=>l.t("Pippit_scene3d_shortcut_label_scale",{},"缩放工具"),deleteSelected:()=>l.t("Pippit_scene3d_shortcut_label_deleteselected",{},"删除选中对象"),toggleVisibility:()=>l.t("Pippit_scene3d_shortcut_label_togglevisibility",{},"显示/隐藏"),toggleLock:()=>l.t("Pippit_scene3d_shortcut_label_togglelock",{},"锁定/解锁"),playPause:()=>l.t("Pippit_scene3d_shortcut_label_playpause",{},"播放/暂停"),undo:()=>l.t("Pippit_scene3d_shortcut_label_undo",{},"撤销"),redo:()=>l.t("Pippit_scene3d_shortcut_label_redo",{},"重做"),cancelSelection:()=>l.t("Pippit_scene3d_shortcut_label_cancelorexit",{},"取消选择"),copy:()=>l.t("Pippit_scene3d_shortcut_label_copy",{},"复制"),paste:()=>l.t("Pippit_scene3d_shortcut_label_paste",{},"粘贴")},viewport:{openHierarchy:()=>l.t("Pippit_scene3d_viewport_arialabel_openhierarchy",{},"打开层级"),settings:()=>l.t("Pippit_scene3d_viewport_arialabel_settings",{},"设置"),viewMode:()=>l.t("Pippit_scene3d_viewport_arialabel_viewmode",{},"视角模式"),directorView:()=>l.t("Pippit_scene3d_viewport_tab_directorview",{},"导演视角"),cameraView:()=>l.t("Pippit_scene3d_viewport_tab_cameraview",{},"机位视角"),resetView:()=>l.t("Pippit_scene3d_viewport_btn_resetview",{},"重置视角"),panoramaAdjustHint:()=>l.t("Pippit_scene3d_viewport_hint_adjustpanoramascene",{},"拖动画面调整上下左右视角,双指上下滑动或滚轮调整远近"),panoramaAdjustSurface:()=>l.t("Pippit_scene3d_viewport_arialabel_panoramaadjustsurface",{},"全景场景调整区域"),resetPanoramaScene:()=>l.t("Pippit_scene3d_viewport_btn_resetpanoramascene",{},"重置场景"),resetCameraView:()=>l.t("Pippit_scene3d_viewport_btn_resetcameraview",{},"重置机位视角"),lockCameraView:()=>l.t("Pippit_scene3d_viewport_btn_lockcameraview",{},"视角锁定"),setActiveCamera:()=>l.t("Pippit_scene3d_viewport_tooltip_setactivecamera",{},"定位视角"),switchToCameraView:()=>l.t("Pippit_scene3d_viewport_btn_switchtocameraview",{},"进入机位视角"),exitCameraView:()=>l.t("Pippit_scene3d_viewport_btn_exitcameraview",{},"退出机位视角"),completePoseEditing:()=>l.t("Pippit_scene3d_viewport_btn_completeposeediting",{},"完成"),models:()=>l.t("Pippit_scene3d_viewport_btn_models",{},"模型"),loading:()=>l.t("Pippit_scene3d_viewport_status_loading",{},"加载中..."),screenRecording:()=>l.t("Pippit_scene3d_viewport_status_screenrecording",{},"录制中"),screenRecordMp4Unsupported:()=>l.t("Pippit_scene3d_viewport_error_screenrecordmp4unsupported",{},"当前浏览器不支持 MP4 录屏"),screenRecordFailed:()=>l.t("Pippit_scene3d_viewport_error_screenrecordfailed",{},"录屏失败,请重试"),prepareRenderVideo:()=>l.t("Pippit_scene3d_viewport_status_preparerendervideo",{},"准备渲染视频"),prepareRenderVideoEncoder:()=>l.t("Pippit_scene3d_viewport_status_preparevideoencoder",{},"正在检查视频渲染支持..."),renderVideoProgress:e=>l.t("Pippit_scene3d_viewport_status_rendervideoprogress",{number:e},"正在渲染视频 {number}%"),renderVideoFrameRange:(e,t)=>l.t("Pippit_scene3d_viewport_label_renderframerange",{number1:e,number2:t},"{number1}-{number2} 帧"),renderVideoMp4Unsupported:()=>l.t("Pippit_scene3d_viewport_error_rendervideomp4unsupported",{},"当前浏览器不支持视频渲染"),renderVideoInvalidRange:()=>l.t("Pippit_scene3d_viewport_error_rendervideoinvalidrange",{},"时间轴范围为空,无法渲染视频"),renderVideoFailed:()=>l.t("Pippit_scene3d_viewport_error_rendervideofailed",{},"渲染视频失败,请重试")},inspector:{empty:()=>l.t("Pippit_scene3d_inspector_empty_noobjectselected",{},"未选择对象"),properties:()=>l.t("Pippit_scene3d_inspector_tab_properties",{},"属性"),cameraCaptures:()=>l.t("Pippit_scene3d_inspector_tab_cameracaptures",{},"摄像机素材"),cameraCapturesHistoryTooltip:()=>l.t("Pippit_scene3d_inspector_tooltip_cameracaptureshistory",{},"摄像机素材历史记录"),cameraMotionEffect:()=>l.t("Pippit_scene3d_inspector_tab_cameramotioneffect",{},"运镜效果"),cameraMotionEffectEmpty:()=>l.t("Pippit_scene3d_inspector_empty_cameramotioneffect",{},"当前摄像机暂无运镜效果。"),cameraCapturesEmptyTitle:()=>l.t("Pippit_scene3d_inspector_empty_cameracaptures_title",{},"暂无摄像机素材"),cameraCapturesEmptyDescription:()=>l.t("Pippit_scene3d_inspector_empty_cameracaptures_desc",{},"录屏或导出素材后,会显示在这里。"),cameraCaptureUploading:()=>l.t("Pippit_scene3d_inspector_status_cameracaptureuploading",{},"正在上传素材…"),cameraCaptureUploadFailedTitle:()=>l.t("Pippit_scene3d_inspector_title_cameracaptureuploadfailed",{},"素材保存失败"),cameraCaptureUploadFailedDescription:()=>l.t("Pippit_scene3d_inspector_desc_cameracaptureuploadfailed",{},"自动重试仍未成功,请重新生成素材。"),pose:()=>l.t("Pippit_scene3d_inspector_tab_pose",{},"姿势"),poseGuide:{title:()=>l.t("Pippit_scene3d_poseguide_title_adjustpose",{},"姿势调节"),newBadge:()=>l.t("Pippit_scene3d_poseguide_badge_new",{},"新功能"),description:()=>l.t("Pippit_scene3d_poseguide_desc_enteranddragcontrols",{},"双击角色或右键选择“姿势调节”,也可以在这里开启。进入后拖动控制点即可调整姿势。"),closeLabel:()=>l.t("Pippit_scene3d_poseguide_arialabel_close",{},"关闭姿势调节引导")},lockedReadonly:()=>l.t("Pippit_scene3d_inspector_status_lockedreadonly",{},"对象已锁定,属性为只读"),unlockObject:()=>l.t("Pippit_scene3d_inspector_btn_unlockobject",{},"解锁对象"),lockObject:()=>l.t("Pippit_scene3d_inspector_btn_lockobject",{},"锁定对象"),unlockTransformChannel:e=>l.t("Pippit_scene3d_inspector_arialabel_unlocktransformchannel",{text:e},"解锁{text}"),lockTransformChannel:e=>l.t("Pippit_scene3d_inspector_arialabel_locktransformchannel",{text:e},"锁定{text}"),scene3d:()=>l.t("Pippit_scene3d_inspector_title_3dscene",{},"3D场景"),sceneScale:()=>l.t("Pippit_scene3d_inspector_label_scenescale",{},"缩放"),sceneMove:()=>l.t("Pippit_scene3d_inspector_label_scenemove",{},"平移"),sceneRotate:()=>l.t("Pippit_scene3d_inspector_label_scenerotate",{},"旋转"),panoramaBackground:()=>l.t("Pippit_scene3d_inspector_title_panoramabackground",{},"全景背景"),background:()=>l.t("Pippit_scene3d_inspector_title_background",{},"背景"),backgroundMode:()=>l.t("Pippit_scene3d_inspector_label_backgroundmode",{},"模式"),backgroundModeTexture:()=>l.t("Pippit_scene3d_inspector_option_backgroundmodetexture",{},"贴图"),backgroundModeColor:()=>l.t("Pippit_scene3d_inspector_option_backgroundmodecolor",{},"颜色"),backgroundColor:()=>l.t("Pippit_scene3d_inspector_label_backgroundcolor",{},"背景颜色"),panoramaImage:()=>l.t("Pippit_scene3d_inspector_label_panoramaimage",{},"全景图"),adjustPanoramaScene:()=>l.t("Pippit_scene3d_inspector_btn_adjustpanoramascene",{},"调整场景"),finishPanoramaSceneAdjust:()=>l.t("Pippit_scene3d_inspector_btn_finishpanoramasceneadjust",{},"完成调整"),previousPanoramas:()=>l.t("Pippit_scene3d_inspector_aria_previouspanoramas",{},"向左查看更多全景图"),nextPanoramas:()=>l.t("Pippit_scene3d_inspector_aria_nextpanoramas",{},"向右查看更多全景图"),panoramaEmpty:()=>l.t("Pippit_scene3d_inspector_status_panoramaempty",{},"未选择"),panoramaNone:()=>l.t("Pippit_scene3d_inspector_option_panoramanone",{},"None"),currentPanorama:()=>l.t("Pippit_scene3d_inspector_label_currentpanorama",{},"当前全景图"),panoramaListItem:e=>l.t("Pippit_scene3d_inspector_label_panoramalistitem",{number:e},"全景图 {number}"),panoramaConnected:()=>l.t("Pippit_scene3d_inspector_status_panoramaconnected",{},"已连接全景图"),panoramaDropHint:()=>l.t("Pippit_scene3d_inspector_hint_connectimageinput",{},"请将图片节点连接到导演台左侧输入口"),skyColor:()=>l.t("Pippit_scene3d_inspector_label_skycolor",{},"天空颜色"),panoramaSphere:()=>l.t("Pippit_scene3d_inspector_title_panoramasphere",{},"全景球"),horizontalRotation:()=>l.t("Pippit_scene3d_inspector_label_horizontalrotation",{},"水平旋转"),verticalView:()=>l.t("Pippit_scene3d_inspector_label_verticalview",{},"上下视角"),sphereRadius:()=>l.t("Pippit_scene3d_inspector_label_sphereradius",{},"球形半径"),characterLabels:()=>l.t("Pippit_scene3d_inspector_label_characterlabels",{},"角色标签"),gridSnap:()=>l.t("Pippit_scene3d_inspector_label_gridsnap",{},"网格吸附"),groundSnap:()=>l.t("Pippit_scene3d_inspector_label_groundsnap",{},"地面吸附"),ground:()=>l.t("Pippit_scene3d_inspector_label_ground",{},"地面"),groundHeight:()=>l.t("Pippit_scene3d_inspector_label_groundheight",{},"地面高度"),opacity:()=>l.t("Pippit_scene3d_inspector_label_opacity",{},"透明度"),editInCanvas:()=>l.t("Pippit_scene3d_inspector_btn_editincanvas",{},"去画布编辑"),editingInCanvas:()=>l.t("Pippit_scene3d_inspector_btn_editingincanvas",{},"跳转中"),sendToCanvas:()=>l.t("Pippit_scene3d_inspector_btn_sendtocanvas",{},"发送到画布"),sendingToCanvas:()=>l.t("Pippit_scene3d_inspector_btn_sendingtocanvas",{},"发送中"),name:()=>l.t("Pippit_scene3d_inspector_label_name",{},"名称"),switchCamera:()=>l.t("Pippit_scene3d_inspector_label_switchcamera",{},"切换机位"),position:()=>l.t("Pippit_scene3d_inspector_label_position",{},"位置"),positionCm:()=>l.t("Pippit_scene3d_inspector_label_positioncm",{},"位置 (cm)"),lookAtTarget:()=>l.t("Pippit_scene3d_inspector_label_lookattarget",{},"注视目标"),manualCoordinates:()=>l.t("Pippit_scene3d_inspector_option_manualcoordinates",{},"手动坐标"),lookAtCoordinates:()=>l.t("Pippit_scene3d_inspector_label_lookatcoordinates",{},"注视坐标"),lookAtTargetCharacter:()=>l.t("Pippit_scene3d_inspector_group_lookattarget_character",{},"角色"),lookAtTargetCharacterGroup:()=>l.t("Pippit_scene3d_inspector_group_lookattarget_character_group",{},"角色组"),lookAtTargetPropGroup:()=>l.t("Pippit_scene3d_inspector_group_lookattarget_prop_group",{},"道具组"),targetDistance:()=>l.t("Pippit_scene3d_inspector_label_targetdistance",{},"目标距离"),fov:()=>l.t("Pippit_scene3d_inspector_label_fov",{},"视野角度 (FOV)"),cameraCapture:()=>l.t("Pippit_scene3d_inspector_title_cameracapture",{},"摄像机素材"),poseUnavailable:()=>l.t("Pippit_scene3d_inspector_status_poseunavailable",{},"当前角色没有可用骨骼模型,暂不支持姿势编辑"),viewportPoseControls:()=>l.t("Pippit_scene3d_inspector_label_viewportposecontrols",{},"手动调整姿势"),viewportPosingMotionBlocked:()=>l.t("Pippit_scene3d_inspector_status_viewportposingmotionblocked",{},"当前帧的动作正在覆盖姿势。请在时间轴右键动作并转换为关键帧,或移除动作后再调整"),viewportPosingUnavailable:()=>l.t("Pippit_scene3d_inspector_status_viewportposingunavailable",{},"当前状态无法开始视口调姿"),poseControlledByKeyframes:()=>l.t("Pippit_scene3d_inspector_hint_posecontrolledbykeyframes",{},"当前姿势由关键帧控制。请在关键帧面板编辑动作数据;姿势参数和预设只影响未被关键帧覆盖的默认姿势。"),posePresets:()=>l.t("Pippit_scene3d_inspector_title_posepresets",{},"姿势预设"),poseControls:()=>l.t("Pippit_scene3d_inspector_title_posecontrols",{},"姿势调节"),poseAdjustment:()=>l.t("Pippit_scene3d_inspector_title_poseadjustment",{},"姿势调整"),posePresetEdited:e=>l.t("Pippit_scene3d_inspector_arialabel_posepresetedited",{text:e},"{text},已调整"),poseEditor:()=>l.t("Pippit_scene3d_inspector_title_poseeditor",{},"姿势编辑"),showSkeleton:()=>l.t("Pippit_scene3d_inspector_label_showskeleton",{},"显示骨骼"),boneProperties:()=>l.t("Pippit_scene3d_inspector_tab_boneproperties",{},"骨骼属性"),poseEditorStatusTemporary:e=>l.t("Pippit_scene3d_inspector_status_poseeditortemporary",{number:e},"第 {number} 帧 · 临时姿态"),poseEditorStatusSelectedValues:(e,t)=>l.t("Pippit_scene3d_inspector_status_poseeditorselectedvalues",{num:t,number1:e,number2:t},"第 {number1} 帧 · 已选 {number2} 个关键值"),poseEditorStatusCurrentFrameValues:e=>l.t("Pippit_scene3d_inspector_status_poseeditorcurrentframevalues",{number:e},"第 {number} 帧 · 当前帧已有关键值"),poseBonePropertiesEmpty:()=>l.t("Pippit_scene3d_inspector_empty_boneproperties",{},"当前角色暂无可编辑骨骼属性。"),boneSearchPlaceholder:()=>l.t("Pippit_scene3d_inspector_placeholder_searchbones",{},"搜索骨骼"),poseBoneSearchEmpty:()=>l.t("Pippit_scene3d_inspector_empty_bonesearch",{},"未找到匹配的骨骼。"),boneGroupTorso:()=>l.t("Pippit_scene3d_inspector_group_bone_torso",{},"躯干"),boneGroupHeadNeck:()=>l.t("Pippit_scene3d_inspector_group_bone_headneck",{},"头颈"),boneGroupArms:()=>l.t("Pippit_scene3d_inspector_group_bone_arms",{},"手臂"),boneGroupHands:()=>l.t("Pippit_scene3d_inspector_group_bone_hands",{},"手部"),boneGroupLegsFeet:()=>l.t("Pippit_scene3d_inspector_group_bone_legsfeet",{},"腿脚"),boneGroupOther:()=>l.t("Pippit_scene3d_inspector_group_bone_other",{},"其他"),action:()=>l.t("Pippit_scene3d_inspector_label_action",{},"动作"),cameraMotion:()=>l.t("Pippit_scene3d_inspector_label_cameramotion",{},"运镜"),pathMotion:()=>l.t("Pippit_scene3d_inspector_label_pathmotion",{},"运动轨迹"),pathMotionEffect:()=>l.t("Pippit_scene3d_inspector_tab_pathmotioneffect",{},"运动轨迹"),pathMotionEffectEmpty:()=>l.t("Pippit_scene3d_inspector_empty_pathmotioneffect",{},"选择运动轨迹片段后编辑属性。"),cameraMotionCenterTarget:()=>l.t("Pippit_scene3d_inspector_option_cameramotioncentertarget",{},"中心点"),cameraMotionFocusTarget:()=>l.t("Pippit_scene3d_inspector_label_cameramotionfocustarget",{},"注视目标"),cameraMotionFollowTarget:()=>l.t("Pippit_scene3d_inspector_label_cameramotionfollowtarget",{},"跟随目标"),cameraMotionOwner:()=>l.t("Pippit_scene3d_inspector_label_cameramotionowner",{},"摄像机"),cameraMotionOrbitAngle:()=>l.t("Pippit_scene3d_inspector_label_cameramotionorbitangle",{},"环绕角度"),cameraMotionPreset:()=>l.t("Pippit_scene3d_inspector_label_cameramotionpreset",{},"运镜"),cameraMotionProperties:()=>l.t("Pippit_scene3d_inspector_title_cameramotionproperties",{},"运镜属性"),cameraMotionShowTrajectory:()=>l.t("Pippit_scene3d_inspector_label_cameramotionshowtrajectory",{},"显示轨迹"),cameraMotionTrajectoryVisibility:()=>l.t("Pippit_scene3d_inspector_label_cameramotiontrajectoryvisibility",{},"轨迹显示"),cameraMotionTrajectoryVisibilityAll:()=>l.t("Pippit_scene3d_inspector_option_cameramotiontrajectoryall",{},"全部"),cameraMotionTrajectoryVisibilitySelected:()=>l.t("Pippit_scene3d_inspector_option_cameramotiontrajectoryselected",{},"选中片段"),cameraMotionTrajectoryVisibilityHidden:()=>l.t("Pippit_scene3d_inspector_option_cameramotiontrajectoryhidden",{},"隐藏"),pathMotionTrajectoryVisibility:()=>l.t("Pippit_scene3d_inspector_label_pathmotiontrajectoryvisibility",{},"运动轨迹"),pathMotionTrajectoryVisibilityAll:()=>l.t("Pippit_scene3d_inspector_option_pathmotiontrajectoryall",{},"全部"),pathMotionTrajectoryVisibilitySelected:()=>l.t("Pippit_scene3d_inspector_option_pathmotiontrajectoryselected",{},"选中片段"),pathMotionTrajectoryVisibilityHidden:()=>l.t("Pippit_scene3d_inspector_option_pathmotiontrajectoryhidden",{},"隐藏"),cameraMotionTransitionProperties:()=>l.t("Pippit_scene3d_inspector_title_cameramotiontransitionproperties",{},"运镜过渡属性"),cameraMotionTransitionTween:()=>l.t("Pippit_scene3d_inspector_label_cameramotiontransitiontween",{},"过渡方式"),pathMotionPathGroup:()=>l.t("Pippit_scene3d_inspector_group_pathmotionpath",{},"轨迹"),pathMotionMotionGroup:()=>l.t("Pippit_scene3d_inspector_group_pathmotionmotion",{},"运动"),pathMotionTimeGroup:()=>l.t("Pippit_scene3d_inspector_group_pathmotiontime",{},"时间"),pathMotionTrajectoryName:()=>l.t("Pippit_scene3d_inspector_label_pathmotiontrajectoryname",{},"轨迹名称"),pathMotionPathLength:()=>l.t("Pippit_scene3d_inspector_label_pathmotionpathlength",{},"路径长度"),pathMotionPathRange:()=>l.t("Pippit_scene3d_inspector_label_pathmotionpathrange",{},"起止百分比"),pathMotionStartPercent:()=>l.t("Pippit_scene3d_inspector_label_pathmotionstartpercent",{},"起始百分比"),pathMotionEndPercent:()=>l.t("Pippit_scene3d_inspector_label_pathmotionendpercent",{},"结束百分比"),pathMotionStatus:()=>l.t("Pippit_scene3d_inspector_label_pathmotionstatus",{},"轨迹状态"),pathMotionStatusActive:()=>l.t("Pippit_scene3d_inspector_option_pathmotionstatusactive",{},"正常"),pathMotionStatusMissing:()=>l.t("Pippit_scene3d_inspector_option_pathmotionstatusmissing",{},"轨迹丢失"),pathMotionDirection:()=>l.t("Pippit_scene3d_inspector_label_pathmotiondirection",{},"方向"),pathMotionDirectionForward:()=>l.t("Pippit_scene3d_inspector_option_pathmotiondirectionforward",{},"正向"),pathMotionDirectionReverse:()=>l.t("Pippit_scene3d_inspector_option_pathmotiondirectionreverse",{},"反向"),pathMotionSpeed:()=>l.t("Pippit_scene3d_inspector_label_pathmotionspeed",{},"速度"),pathMotionFacing:()=>l.t("Pippit_scene3d_inspector_label_pathmotionfacing",{},"朝向策略"),pathMotionFacingPathTangent:()=>l.t("Pippit_scene3d_inspector_option_pathmotionfacingpathtangent",{},"跟随路径"),pathMotionFacingFixed:()=>l.t("Pippit_scene3d_inspector_option_pathmotionfacingfixed",{},"保持当前"),pathMotionTransitionTween:()=>l.t("Pippit_scene3d_inspector_label_pathmotiontransitiontween",{},"过渡方式"),motionClipProperties:()=>l.t("Pippit_scene3d_inspector_title_motionclipproperties",{},"动作属性"),motionTransitionProperties:()=>l.t("Pippit_scene3d_inspector_title_motiontransitionproperties",{},"过渡属性"),motionClipOwner:()=>l.t("Pippit_scene3d_inspector_label_motionclipowner",{},"所属角色"),motionClipDuration:()=>l.t("Pippit_scene3d_inspector_label_motionclipduration",{},"持续帧数"),motionClipDurationFrames:e=>l.t("Pippit_scene3d_inspector_label_motionclipdurationframes",{number:e},"{number} 帧"),motionClipDurationFramesSeconds:(e,t)=>l.t("Pippit_scene3d_inspector_label_motionclipdurationframeseconds",{number:e,text:t},"{number} 帧 / {text}s"),motionClipOriginalDuration:()=>l.t("Pippit_scene3d_inspector_label_motioncliporiginalduration",{},"原始时长"),motionClipTrimmedDuration:()=>l.t("Pippit_scene3d_inspector_label_motioncliptrimmedduration",{},"裁剪后时长"),motionClipSource:()=>l.t("Pippit_scene3d_inspector_label_motionclipsource",{},"源片段"),motionClipSourceStart:()=>l.t("Pippit_scene3d_inspector_label_motionclipsourcestart",{},"源起始"),motionClipSourceEnd:()=>l.t("Pippit_scene3d_inspector_label_motionclipsourceend",{},"源结束"),motionClipFrameUnit:()=>l.t("Pippit_scene3d_inspector_unit_motionclipframe",{},"帧"),motionClipSpeedUnit:()=>l.t("Pippit_scene3d_inspector_unit_motionclipspeed",{},"倍"),motionClipTiming:()=>l.t("Pippit_scene3d_inspector_group_motioncliptiming",{},"时间范围(帧)"),motionClipTimingHint:()=>l.t("Pippit_scene3d_inspector_hint_motioncliptiming",{},"按时间轴帧数填写,结束帧需大于开始帧。"),motionClipSourceTrim:()=>l.t("Pippit_scene3d_inspector_group_motionclipsourcetrim",{},"动作裁剪"),motionClipSourceTrimHint:()=>l.t("Pippit_scene3d_inspector_hint_motionclipsourcetrim",{},"裁剪原动作内容,不改变动作在时间线中的开始位置。"),motionClipSourceTrimReset:()=>l.t("Pippit_scene3d_inspector_btn_motionclipsourcetrimreset",{},"重置完整动作"),motionClipPlayback:()=>l.t("Pippit_scene3d_inspector_group_motionclipplayback",{},"播放"),clipPlaybackLoopMode:()=>l.t("Pippit_scene3d_inspector_label_clipplaybackloopmode",{},"循环方式"),clipPlaybackRepeat:()=>l.t("Pippit_scene3d_inspector_option_clipplaybackrepeat",{},"重复"),clipPlaybackPingPong:()=>l.t("Pippit_scene3d_inspector_option_clipplaybackpingpong",{},"往返"),clipPlaybackSpeedHint:()=>l.t("Pippit_scene3d_inspector_hint_clipplaybackspeed",{},"1 倍为原速,数值越大播放越快。"),motionClipSpeedHint:()=>l.t("Pippit_scene3d_inspector_hint_motionclipspeed",{},"1 倍为原速,数值越大动作越快。"),motionClipLoopHint:()=>l.t("Pippit_scene3d_inspector_hint_motioncliploop",{},"开启后,动作播完会从头重复,直到动作条结束。"),cameraMotionClipLoopHint:()=>l.t("Pippit_scene3d_inspector_hint_cameramotioncliploop",{},"开启后,运镜会在片头和片尾之间往返播放。"),pathMotionClipLoopHint:()=>l.t("Pippit_scene3d_inspector_hint_pathmotioncliploop",{},"开启后,角色会沿轨迹往返移动。"),motionClipInPlaceAnimation:()=>l.t("Pippit_scene3d_inspector_label_motionclipinplaceanimation",{},"原地动画"),motionClipInPlaceHint:()=>l.t("Pippit_scene3d_inspector_hint_motionclipinplace",{},"开启后,角色保持当前位置,不跟随动作里的前进位移。"),animation:()=>l.t("Pippit_scene3d_inspector_title_animation",{},"动画"),animationNone:()=>l.t("Pippit_scene3d_inspector_option_animationnone",{},"无"),playAnimation:()=>l.t("Pippit_scene3d_inspector_arialabel_playanimation",{},"播放动画"),pauseAnimation:()=>l.t("Pippit_scene3d_inspector_arialabel_pauseanimation",{},"暂停动画"),posePanel:{controlRange:(e,t,n)=>l.t("Pippit_scene3d_inspector_arialabel_posecontrolrange",{text1:e,text2:t,text3:n},"{text1}:{text2}至{text3}"),bodyOverall:()=>l.t("Pippit_scene3d_inspector_posepanel_title_bodyoverall",{},"身体整体"),chestWaist:()=>l.t("Pippit_scene3d_inspector_posepanel_title_chestwaist",{},"胸腰"),arms:()=>l.t("Pippit_scene3d_inspector_posepanel_title_arms",{},"手臂"),legs:()=>l.t("Pippit_scene3d_inspector_posepanel_title_legs",{},"腿部"),body:()=>l.t("Pippit_scene3d_inspector_posepanel_title_body",{},"身体"),torso:()=>l.t("Pippit_scene3d_inspector_posepanel_title_torso",{},"躯干"),head:()=>l.t("Pippit_scene3d_inspector_posepanel_title_head",{},"头部"),armShoulder:()=>l.t("Pippit_scene3d_inspector_posepanel_title_armshoulder",{},"手臂 - 肩"),elbow:()=>l.t("Pippit_scene3d_inspector_posepanel_title_elbow",{},"肘部"),legHip:()=>l.t("Pippit_scene3d_inspector_posepanel_title_leghip",{},"腿部 - 髋"),knee:()=>l.t("Pippit_scene3d_inspector_posepanel_title_knee",{},"膝部"),left:()=>l.t("Pippit_scene3d_inspector_posepanel_side_left",{},"左"),right:()=>l.t("Pippit_scene3d_inspector_posepanel_side_right",{},"右"),bilateralLink:()=>l.t("Pippit_scene3d_inspector_posepanel_label_bilaterallink",{},"双侧联动"),restorePreset:()=>l.t("Pippit_scene3d_inspector_posepanel_btn_restorepreset",{},"恢复预设"),backwardLean:()=>l.t("Pippit_scene3d_inspector_posepanel_label_backwardlean",{},"后仰"),forwardLean:()=>l.t("Pippit_scene3d_inspector_posepanel_label_forwardlean",{},"前倾"),turnLeft:()=>l.t("Pippit_scene3d_inspector_posepanel_label_turnleft",{},"左转"),turnRight:()=>l.t("Pippit_scene3d_inspector_posepanel_label_turnright",{},"右转"),leanLeft:()=>l.t("Pippit_scene3d_inspector_posepanel_label_leanleft",{},"左倾"),leanRight:()=>l.t("Pippit_scene3d_inspector_posepanel_label_leanright",{},"右倾"),lookUp:()=>l.t("Pippit_scene3d_inspector_posepanel_label_lookup",{},"抬头"),lookDown:()=>l.t("Pippit_scene3d_inspector_posepanel_label_lookdown",{},"低头"),lookLeft:()=>l.t("Pippit_scene3d_inspector_posepanel_label_lookleft",{},"左看"),lookRight:()=>l.t("Pippit_scene3d_inspector_posepanel_label_lookright",{},"右看"),tiltLeft:()=>l.t("Pippit_scene3d_inspector_posepanel_label_tiltleft",{},"左歪"),tiltRight:()=>l.t("Pippit_scene3d_inspector_posepanel_label_tiltright",{},"右歪"),backwardSwing:()=>l.t("Pippit_scene3d_inspector_posepanel_label_backwardswing",{},"后摆"),forwardRaise:()=>l.t("Pippit_scene3d_inspector_posepanel_label_forwardraise",{},"前举"),adduct:()=>l.t("Pippit_scene3d_inspector_posepanel_label_adduct",{},"内收"),rotateIn:()=>l.t("Pippit_scene3d_inspector_posepanel_label_rotatein",{},"内旋"),rotateOut:()=>l.t("Pippit_scene3d_inspector_posepanel_label_rotateout",{},"外旋"),straight:()=>l.t("Pippit_scene3d_inspector_posepanel_label_straight",{},"伸直"),backwardExtend:()=>l.t("Pippit_scene3d_inspector_posepanel_label_backwardextend",{},"后伸"),lean:()=>l.t("Pippit_scene3d_inspector_posepanel_label_lean",{},"前倾"),turn:()=>l.t("Pippit_scene3d_inspector_posepanel_label_turn",{},"转身"),sideLean:()=>l.t("Pippit_scene3d_inspector_posepanel_label_sidelean",{},"侧倾"),twist:()=>l.t("Pippit_scene3d_inspector_posepanel_label_twist",{},"扭转"),nod:()=>l.t("Pippit_scene3d_inspector_posepanel_label_nod",{},"点头"),headTurn:()=>l.t("Pippit_scene3d_inspector_posepanel_label_headturn",{},"转头"),tiltHead:()=>l.t("Pippit_scene3d_inspector_posepanel_label_tilthead",{},"歪头"),raise:()=>l.t("Pippit_scene3d_inspector_posepanel_label_raise",{},"前举"),abduct:()=>l.t("Pippit_scene3d_inspector_posepanel_label_abduct",{},"外展"),bend:()=>l.t("Pippit_scene3d_inspector_posepanel_label_bend",{},"弯曲"),legRaise:()=>l.t("Pippit_scene3d_inspector_posepanel_label_legraise",{},"前抬"),checkingPoseCompatibility:()=>l.t("Pippit_scene3d_inspector_status_checkingposecompatibility",{},"正在检测骨骼兼容性,请稍候")},cameraBadge:()=>l.t("Pippit_scene3d_inspector_badge_camera",{},"机位"),objectBadge:()=>l.t("Pippit_scene3d_inspector_badge_object",{},"物"),rotation:()=>l.t("Pippit_scene3d_inspector_label_rotation",{},"旋转"),scale:()=>l.t("Pippit_scene3d_inspector_label_scale",{},"缩放"),showLabel:()=>l.t("Pippit_scene3d_inspector_label_showlabel",{},"显示标签"),linkedScale:()=>l.t("Pippit_scene3d_inspector_arialabel_linkedscale",{},"联动缩放"),keyframeEditor:()=>l.t("Pippit_scene3d_inspector_keyframe_title_editor",{},"关键帧"),keyframeEditorFrame:e=>l.t("Pippit_scene3d_inspector_keyframe_label_frame",{number:e},"第 {number} 帧"),keyframeEditorMultipleFrames:()=>l.t("Pippit_scene3d_inspector_keyframe_label_multipleframes",{},"多帧"),keyframeEditorSelectedCount:e=>l.t("Pippit_scene3d_inspector_keyframe_label_selectedcount",{num:e,number:e},"{number} 个已选"),keyframeEditorEulerRotation:()=>l.t("Pippit_scene3d_inspector_keyframe_label_eulerrotation",{},"欧拉旋转"),keyframeEditorValue:()=>l.t("Pippit_scene3d_inspector_keyframe_label_value",{},"数值"),addTransformKeyframe:(e,t)=>l.t("Pippit_scene3d_inspector_arialabel_addtransformkeyframe",{number:t,text:e},"第 {number} 帧为{text}添加关键帧"),deleteTransformKeyframe:(e,t)=>l.t("Pippit_scene3d_inspector_arialabel_deletetransformkeyframe",{number:t,text:e},"删除第 {number} 帧{text}关键帧"),customColor:()=>l.t("Pippit_scene3d_inspector_arialabel_customcolor",{},"自定义颜色"),groupApplyHint:()=>l.t("Pippit_scene3d_inspector_hint_groupapplymembers",{},"修改后应用到组内全部成员"),groupBadge:()=>l.t("Pippit_scene3d_inspector_badge_group",{},"组"),sceneTransform:()=>l.t("Pippit_scene3d_inspector_group_scenetransform",{},"场景变换"),display:()=>l.t("Pippit_scene3d_inspector_group_display",{},"显示")},inspectorGroup:{transform:()=>l.t("Pippit_scene3d_inspector_group_transform",{},"变换"),lens:()=>l.t("Pippit_scene3d_inspector_group_lens",{},"镜头"),cameraRig:()=>l.t("Pippit_scene3d_inspector_group_camerarig",{},"机位"),projection:()=>l.t("Pippit_scene3d_inspector_group_projection",{},"投影"),type:()=>l.t("Pippit_scene3d_inspector_label_type",{},"类型"),perspective:()=>l.t("Pippit_scene3d_inspector_option_perspective",{},"透视"),orthographic:()=>l.t("Pippit_scene3d_inspector_option_orthographic",{},"正交"),fovAxis:()=>l.t("Pippit_scene3d_inspector_label_fovaxis",{},"FOV 轴"),vertical:()=>l.t("Pippit_scene3d_inspector_option_vertical",{},"垂直"),horizontal:()=>l.t("Pippit_scene3d_inspector_option_horizontal",{},"水平"),clipping:()=>l.t("Pippit_scene3d_inspector_group_clipping",{},"裁剪面"),near:()=>l.t("Pippit_scene3d_inspector_label_near",{},"近"),far:()=>l.t("Pippit_scene3d_inspector_label_far",{},"远"),material:()=>l.t("Pippit_scene3d_inspector_group_material",{},"材质"),color:()=>l.t("Pippit_scene3d_inspector_label_color",{},"颜色"),action:()=>l.t("Pippit_scene3d_inspector_group_action",{},"动作"),marker:()=>l.t("Pippit_scene3d_inspector_group_marker",{},"标号"),yOffset:()=>l.t("Pippit_scene3d_inspector_label_yoffset",{},"Y 偏移"),asset:()=>l.t("Pippit_scene3d_inspector_group_asset",{},"资源"),category:()=>l.t("Pippit_scene3d_inspector_label_category",{},"分类"),layout:()=>l.t("Pippit_scene3d_inspector_group_layout",{},"布局"),perRow:()=>l.t("Pippit_scene3d_inspector_label_perrow",{},"每排几人"),perColumn:()=>l.t("Pippit_scene3d_inspector_label_percolumn",{},"每列几人"),spacingDepth:()=>l.t("Pippit_scene3d_inspector_label_spacingdepth",{},"前后间距"),spacingWidth:()=>l.t("Pippit_scene3d_inspector_label_spacingwidth",{},"左右间距"),label:()=>l.t("Pippit_scene3d_inspector_group_label",{},"标签")},hierarchyGroup:{scene:()=>l.t("Pippit_scene3d_hierarchy_group_scene",{},"场景"),cameras:()=>l.t("Pippit_scene3d_hierarchy_group_cameras",{},"机位"),characters:()=>l.t("Pippit_scene3d_hierarchy_group_characters",{},"角色"),props:()=>l.t("Pippit_scene3d_hierarchy_group_props",{},"道具"),primitives:()=>l.t("Pippit_scene3d_hierarchy_group_primitives",{},"基础形体"),lights:()=>l.t("Pippit_scene3d_hierarchy_group_lights",{},"灯光"),paths:()=>l.t("Pippit_scene3d_hierarchy_group_paths",{},"轨迹"),groups:()=>l.t("Pippit_scene3d_hierarchy_group_groups",{},"分组"),mixed:()=>l.t("Pippit_scene3d_hierarchy_group_mixed",{},"角色道具组"),unknown:()=>l.t("Pippit_scene3d_hierarchy_group_unknown",{},"未知对象")},poseControl:{bodyLean:()=>l.t("Pippit_scene3d_pose_control_bodylean",{},"身体 前倾"),bodyTurn:()=>l.t("Pippit_scene3d_pose_control_bodyturn",{},"身体 转身"),bodySideLean:()=>l.t("Pippit_scene3d_pose_control_bodysidelean",{},"身体 侧倾"),torsoLean:()=>l.t("Pippit_scene3d_pose_control_torsolean",{},"躯干 前倾"),torsoTwist:()=>l.t("Pippit_scene3d_pose_control_torsotwist",{},"躯干 扭转"),torsoSideLean:()=>l.t("Pippit_scene3d_pose_control_torsosidelean",{},"躯干 侧倾"),headNod:()=>l.t("Pippit_scene3d_pose_control_headnod",{},"头部 点头"),headTurn:()=>l.t("Pippit_scene3d_pose_control_headturn",{},"头部 转头"),headTilt:()=>l.t("Pippit_scene3d_pose_control_headtilt",{},"头部 歪头"),leftArmRaise:()=>l.t("Pippit_scene3d_pose_control_leftarmraise",{},"左臂 前举"),leftArmAbduct:()=>l.t("Pippit_scene3d_pose_control_leftarmabduct",{},"左臂 外展"),leftArmTwist:()=>l.t("Pippit_scene3d_pose_control_leftarmtwist",{},"左臂 扭转"),rightArmRaise:()=>l.t("Pippit_scene3d_pose_control_rightarmraise",{},"右臂 前举"),rightArmAbduct:()=>l.t("Pippit_scene3d_pose_control_rightarmabduct",{},"右臂 外展"),rightArmTwist:()=>l.t("Pippit_scene3d_pose_control_rightarmtwist",{},"右臂 扭转"),leftElbowBend:()=>l.t("Pippit_scene3d_pose_control_leftelbowbend",{},"左肘 弯曲"),rightElbowBend:()=>l.t("Pippit_scene3d_pose_control_rightelbowbend",{},"右肘 弯曲"),leftLegRaise:()=>l.t("Pippit_scene3d_pose_control_leftlegraise",{},"左腿 前抬"),leftLegAbduct:()=>l.t("Pippit_scene3d_pose_control_leftlegabduct",{},"左腿 外展"),leftLegTwist:()=>l.t("Pippit_scene3d_pose_control_leftlegtwist",{},"左腿 扭转"),rightLegRaise:()=>l.t("Pippit_scene3d_pose_control_rightlegraise",{},"右腿 前抬"),rightLegAbduct:()=>l.t("Pippit_scene3d_pose_control_rightlegabduct",{},"右腿 外展"),rightLegTwist:()=>l.t("Pippit_scene3d_pose_control_rightlegtwist",{},"右腿 扭转"),leftKneeBend:()=>l.t("Pippit_scene3d_pose_control_leftkneebend",{},"左膝 弯曲"),rightKneeBend:()=>l.t("Pippit_scene3d_pose_control_rightkneebend",{},"右膝 弯曲")},posePreset:{standing:()=>l.t("Pippit_scene3d_pose_preset_standing",{},"站立"),tPose:()=>l.t("Pippit_scene3d_pose_preset_tpose",{},"T型"),walk:()=>l.t("Pippit_scene3d_pose_preset_walk",{},"行走"),run:()=>l.t("Pippit_scene3d_pose_preset_run",{},"跑步"),sit:()=>l.t("Pippit_scene3d_pose_preset_sit",{},"坐姿"),crouch:()=>l.t("Pippit_scene3d_pose_preset_crouch",{},"蹲下"),singleKneeKneel:()=>l.t("Pippit_scene3d_pose_preset_singlekneekneel",{},"单膝跪"),doubleKneeKneel:()=>l.t("Pippit_scene3d_pose_preset_doublekneekneel",{},"双膝跪"),handsOnHips:()=>l.t("Pippit_scene3d_pose_preset_handsonhips",{},"叉腰"),leaning:()=>l.t("Pippit_scene3d_pose_preset_leaning",{},"倚靠"),bow:()=>l.t("Pippit_scene3d_pose_preset_bow",{},"鞠躬"),thinking:()=>l.t("Pippit_scene3d_pose_preset_thinking",{},"思考"),fighting:()=>l.t("Pippit_scene3d_pose_preset_fighting",{},"格斗"),kickBall:()=>l.t("Pippit_scene3d_pose_preset_kickball",{},"踢球"),throwing:()=>l.t("Pippit_scene3d_pose_preset_throwing",{},"投掷"),pushing:()=>l.t("Pippit_scene3d_pose_preset_pushing",{},"推进"),wave:()=>l.t("Pippit_scene3d_pose_preset_wave",{},"招手"),reachOut:()=>l.t("Pippit_scene3d_pose_preset_reachout",{},"伸手"),armsCrossed:()=>l.t("Pippit_scene3d_pose_preset_armscrossed",{},"抱臂"),phone:()=>l.t("Pippit_scene3d_pose_preset_phone",{},"看手机")},command:{addObject:()=>l.t("Pippit_scene3d_command_addobject",{},"添加对象"),deleteObject:()=>l.t("Pippit_scene3d_command_deleteobject",{},"删除对象"),duplicateObject:()=>l.t("Pippit_scene3d_command_duplicateobject",{},"复制对象"),pasteObject:()=>l.t("Pippit_scene3d_command_pasteobject",{},"粘贴对象"),selectObject:()=>l.t("Pippit_scene3d_command_selectobject",{},"选择对象"),selectObjects:()=>l.t("Pippit_scene3d_command_selectobjects",{},"框选对象"),selectScene:()=>l.t("Pippit_scene3d_command_selectscene",{},"选择场景"),updateTransform:()=>l.t("Pippit_scene3d_command_updatetransform",{},"更新变换"),updateKeyframe:()=>l.t("Pippit_scene3d_command_updatekeyframe",{},"更新关键帧"),updateFrameRange:()=>l.t("Pippit_scene3d_command_updateframerange",{},"更新帧范围"),deleteKeyframe:()=>l.t("Pippit_scene3d_command_deletekeyframe",{},"删除关键帧"),updateCamera:()=>l.t("Pippit_scene3d_command_updatecamera",{},"更新机位"),applyCameraMotion:()=>l.t("Pippit_scene3d_command_applycameramotion",{},"应用运镜"),applyPathMotion:()=>l.t("Pippit_scene3d_command_applypathmotion",{},"应用轨迹"),applyPathCharacterMotion:()=>l.t("Pippit_scene3d_command_applypathcharactermotion",{},"沿轨迹播放动作"),addCameraCapture:()=>l.t("Pippit_scene3d_command_addcameracapture",{},"添加摄像机截图"),deleteCameraCapture:()=>l.t("Pippit_scene3d_command_deletecameracapture",{},"删除摄像机截图"),updateCameraCaptureAsset:()=>l.t("Pippit_scene3d_command_updatecameracaptureasset",{},"更新摄像机截图资产"),markCameraCaptureSent:()=>l.t("Pippit_scene3d_command_markcameracapturesent",{},"标记摄像机截图已发送"),updateScene:()=>l.t("Pippit_scene3d_command_updatescene",{},"更新场景"),switchCamera:()=>l.t("Pippit_scene3d_command_switchcamera",{},"切换机位"),updateCharacter:()=>l.t("Pippit_scene3d_command_updatecharacter",{},"更新角色"),updateProp:()=>l.t("Pippit_scene3d_command_updateprop",{},"更新道具"),applyCharacterMotion:()=>l.t("Pippit_scene3d_command_applycharactermotion",{},"应用角色动作"),bakeCharacterMotion:()=>l.t("Pippit_scene3d_command_bakecharactermotion",{},"转换角色动作关键帧"),deleteCharacterMotionClip:()=>l.t("Pippit_scene3d_command_deletecharactermotionclip",{},"删除角色动作块"),duplicateCharacterMotionClip:()=>l.t("Pippit_scene3d_command_duplicatecharactermotionclip",{},"复制角色动作块"),splitCharacterMotionClip:()=>l.t("Pippit_scene3d_command_splitcharactermotionclip",{},"分割角色动作块"),updateCharacterMotion:()=>l.t("Pippit_scene3d_command_updatecharactermotion",{},"更新角色动作"),clearCharacterMotion:()=>l.t("Pippit_scene3d_command_clearcharactermotion",{},"清除角色动作"),renameObject:()=>l.t("Pippit_scene3d_command_renameobject",{},"重命名对象"),updateFrame:()=>l.t("Pippit_scene3d_command_updateframe",{},"更新画幅"),toggleVisible:()=>l.t("Pippit_scene3d_command_togglevisible",{},"切换显隐"),toggleLock:()=>l.t("Pippit_scene3d_command_togglelock",{},"切换锁定"),switchTool:()=>l.t("Pippit_scene3d_command_switchtool",{},"切换工具"),switchView:()=>l.t("Pippit_scene3d_command_switchview",{},"切换视角"),groupObjects:()=>l.t("Pippit_scene3d_command_groupobjects",{},"打组"),ungroupObjects:()=>l.t("Pippit_scene3d_command_ungroupobjects",{},"解组")},defaults:{aiCamera:()=>l.t("Pippit_scene3d_default_name_aicamera",{},"AI 机位"),camera:()=>l.t("Pippit_scene3d_default_name_camera",{},"机位1"),cameraType:()=>l.t("Pippit_scene3d_default_type_camera",{},"机位"),character:()=>l.t("Pippit_scene3d_default_name_character",{},"人物"),defaultCharacter:e=>l.t("Pippit_scene3d_default_name_defaultcharacter",{index:e},"角色{index}"),prop:()=>l.t("Pippit_scene3d_default_name_prop",{},"道具"),primitive:()=>l.t("Pippit_scene3d_default_name_primitive",{},"基础形体"),light:()=>l.t("Pippit_scene3d_default_name_light",{},"灯光"),path:()=>l.t("Pippit_scene3d_default_name_path",{},"轨迹"),group:()=>l.t("Pippit_scene3d_default_name_group",{},"分组"),characterGroup:e=>l.t("Pippit_scene3d_default_name_charactergroup",{number:e},"角色组{number}"),propGroup:e=>l.t("Pippit_scene3d_default_name_propgroup",{number:e},"道具组{number}"),mixedGroup:e=>l.t("Pippit_scene3d_default_name_mixedgroup",{number:e},"角色道具组{number}"),demoCharacter:()=>l.t("Pippit_scene3d_default_name_defaultcharacter",{index:1},"角色1"),unknownObject:()=>l.t("Pippit_scene3d_default_name_unknownobject",{},"未知对象"),cameraCapture:()=>l.t("Pippit_scene3d_default_name_cameracapture",{},"摄像机截图"),cameraRecording:()=>l.t("Pippit_scene3d_default_name_camerarecording",{},"摄像机录屏"),cameraRenderedVideo:()=>l.t("Pippit_scene3d_default_name_camerarenderedvideo",{},"摄像机渲染视频"),uploadedModel:()=>l.t("Pippit_scene3d_default_name_uploadedmodel",{},"上传模型")},error:{loadManifestUnsupported:()=>l.t("Pippit_scene3d_error_loadmanifestunsupported",{},"当前环境不支持加载小云雀 3D 资源"),loadModelFailed:()=>l.t("Pippit_scene3d_error_loadmodelfailed",{},"模型加载失败,请重试"),uploadModelFailedLocalPreview:()=>l.t("Pippit_scene3d_error_uploadmodelfailed_localpreview",{},"模型上传失败,已使用本地模型预览")}}}var w=Ode();var yg="stand",Lde={body:{bend:0,turn:0,tilt:0},torso:{bend:0,turn:0,tilt:0},head:{nod:0,turn:0,tilt:0},l_arm:{raise:0,straddle:0,turn:0},r_arm:{raise:0,straddle:0,turn:0},l_elbow:{bend:0},r_elbow:{bend:0},l_leg:{raise:0,straddle:0,turn:0},r_leg:{raise:0,straddle:0,turn:0},l_knee:{bend:0},r_knee:{bend:0}},Fde={crouch:{rootPositionOffset:{y:-.58}},one_knee:{rootPositionOffset:{y:-.54}},sit:{rootPositionOffset:{y:-.28}},two_knees:{rootPositionOffset:{y:-.26}}},Bde={"arms-crossed":"arms_crossed","double-knee-kneel":"two_knees","hands-on-hips":"hands_hips",fighting:"fight","kick-ball":"kick",leaning:"lean","reach-out":"stretch","single-knee-kneel":"one_knee",standing:"stand","t-pose":"tpose",thinking:"think",throwing:"throw",pushing:"push"};function Gde(e){switch(e){case"arms":return l.t("Pippit_scene3d_pose_group_arms",{},"手臂");case"body":return l.t("Pippit_scene3d_pose_group_body",{},"躯干与头部");case"legs":return l.t("Pippit_scene3d_pose_group_legs",{},"腿部");default:return e}}var zde=[{id:"bodyBend",axis:"bend",group:"body",joint:"body",label:w.poseControl.bodyLean(),min:-90,max:90,step:.1},{id:"bodyTurn",axis:"turn",group:"body",joint:"body",label:w.poseControl.bodyTurn(),min:-90,max:90,step:.1},{id:"bodyTilt",axis:"tilt",group:"body",joint:"body",label:w.poseControl.bodySideLean(),min:-45,max:45,step:.1},{id:"torsoBend",axis:"bend",group:"body",joint:"torso",label:w.poseControl.torsoLean(),min:-45,max:45,step:.1},{id:"torsoTurn",axis:"turn",group:"body",joint:"torso",label:w.poseControl.torsoTwist(),min:-45,max:45,step:.1},{id:"torsoTilt",axis:"tilt",group:"body",joint:"torso",label:w.poseControl.torsoSideLean(),min:-30,max:30,step:.1},{id:"headNod",axis:"nod",group:"body",joint:"head",label:w.poseControl.headNod(),min:-60,max:60,step:.1},{id:"headTurn",axis:"turn",group:"body",joint:"head",label:w.poseControl.headTurn(),min:-90,max:90,step:.1},{id:"headTilt",axis:"tilt",group:"body",joint:"head",label:w.poseControl.headTilt(),min:-30,max:30,step:.1},{id:"lArmRaise",axis:"raise",group:"arms",joint:"l_arm",label:w.poseControl.leftArmRaise(),min:-90,max:180,step:.1},{id:"lArmStraddle",axis:"straddle",group:"arms",joint:"l_arm",label:w.poseControl.leftArmAbduct(),min:-10,max:90,step:.1},{id:"lArmTurn",axis:"turn",group:"arms",joint:"l_arm",label:w.poseControl.leftArmTwist(),min:-90,max:90,step:.1},{id:"rArmRaise",axis:"raise",group:"arms",joint:"r_arm",label:w.poseControl.rightArmRaise(),min:-90,max:180,step:.1},{id:"rArmStraddle",axis:"straddle",group:"arms",joint:"r_arm",label:w.poseControl.rightArmAbduct(),min:-10,max:90,step:.1},{id:"rArmTurn",axis:"turn",group:"arms",joint:"r_arm",label:w.poseControl.rightArmTwist(),min:-90,max:90,step:.1},{id:"lElbowBend",axis:"bend",group:"arms",joint:"l_elbow",label:w.poseControl.leftElbowBend(),min:0,max:150,step:.1},{id:"rElbowBend",axis:"bend",group:"arms",joint:"r_elbow",label:w.poseControl.rightElbowBend(),min:0,max:150,step:.1},{id:"lLegRaise",axis:"raise",group:"legs",joint:"l_leg",label:w.poseControl.leftLegRaise(),min:-90,max:90,step:.1},{id:"lLegStraddle",axis:"straddle",group:"legs",joint:"l_leg",label:w.poseControl.leftLegAbduct(),min:-30,max:60,step:.1},{id:"lLegTurn",axis:"turn",group:"legs",joint:"l_leg",label:w.poseControl.leftLegTwist(),min:-45,max:45,step:.1},{id:"rLegRaise",axis:"raise",group:"legs",joint:"r_leg",label:w.poseControl.rightLegRaise(),min:-90,max:90,step:.1},{id:"rLegStraddle",axis:"straddle",group:"legs",joint:"r_leg",label:w.poseControl.rightLegAbduct(),min:-30,max:60,step:.1},{id:"rLegTurn",axis:"turn",group:"legs",joint:"r_leg",label:w.poseControl.rightLegTwist(),min:-45,max:45,step:.1},{id:"lKneeBend",axis:"bend",group:"legs",joint:"l_knee",label:w.poseControl.leftKneeBend(),min:0,max:150,step:.1},{id:"rKneeBend",axis:"bend",group:"legs",joint:"r_knee",label:w.poseControl.rightKneeBend(),min:0,max:150,step:.1}],Ude={bodyLean:"bodyBend",bodySideLean:"bodyTilt",bodyTurn:"bodyTurn",headNod:"headNod",headTilt:"headTilt",headTurn:"headTurn",leftArmAbduct:"lArmStraddle",leftArmRaise:"lArmRaise",leftArmTwist:"lArmTurn",leftElbowBend:"lElbowBend",leftKneeBend:"lKneeBend",leftLegAbduct:"lLegStraddle",leftLegRaise:"lLegRaise",leftLegTwist:"lLegTurn",rightArmAbduct:"rArmStraddle",rightArmRaise:"rArmRaise",rightArmTwist:"rArmTurn",rightElbowBend:"rElbowBend",rightKneeBend:"rKneeBend",rightLegAbduct:"rLegStraddle",rightLegRaise:"rLegRaise",rightLegTwist:"rLegTurn",torsoLean:"torsoBend",torsoSideLean:"torsoTilt",torsoTwist:"torsoTurn","body.bend":"bodyBend","body.tilt":"bodyTilt","body.turn":"bodyTurn","head.nod":"headNod","head.tilt":"headTilt","head.turn":"headTurn","l_arm.raise":"lArmRaise","l_arm.straddle":"lArmStraddle","l_arm.turn":"lArmTurn","l_elbow.bend":"lElbowBend","l_knee.bend":"lKneeBend","l_leg.raise":"lLegRaise","l_leg.straddle":"lLegStraddle","l_leg.turn":"lLegTurn","r_arm.raise":"rArmRaise","r_arm.straddle":"rArmStraddle","r_arm.turn":"rArmTurn","r_elbow.bend":"rElbowBend","r_knee.bend":"rKneeBend","r_leg.raise":"rLegRaise","r_leg.straddle":"rLegStraddle","r_leg.turn":"rLegTurn","torso.bend":"torsoBend","torso.tilt":"torsoTilt","torso.turn":"torsoTurn"},Vde=[{id:"stand",label:w.posePreset.standing(),jointAngles:{body:{bend:0,turn:0,tilt:0},torso:{bend:2,turn:0,tilt:0},head:{nod:-10,turn:0,tilt:0},l_arm:{raise:-5,straddle:12,turn:0},r_arm:{raise:-5,straddle:14,turn:0},l_elbow:{bend:15},r_elbow:{bend:15},l_leg:{raise:0,straddle:0,turn:0},r_leg:{raise:0,straddle:0,turn:0},l_knee:{bend:0},r_knee:{bend:0}}},{id:"tpose",label:w.posePreset.tPose(),jointAngles:Lde},{id:"walk",label:w.posePreset.walk(),jointAngles:{body:{bend:0,turn:0,tilt:0},torso:{bend:3,turn:5,tilt:0},head:{nod:-5,turn:0,tilt:0},l_arm:{raise:40,straddle:9,turn:0},r_arm:{raise:-8,straddle:27,turn:-4},l_elbow:{bend:37},r_elbow:{bend:26},l_leg:{raise:-10,straddle:0,turn:0},r_leg:{raise:36,straddle:-2,turn:0},l_knee:{bend:22},r_knee:{bend:41}}},{id:"run",label:w.posePreset.run(),jointAngles:{body:{bend:-2,turn:0,tilt:0},torso:{bend:3,turn:5,tilt:0},head:{nod:-10,turn:0,tilt:0},l_arm:{raise:-26,straddle:23,turn:14},r_arm:{raise:23,straddle:14,turn:19},l_elbow:{bend:60},r_elbow:{bend:89},l_leg:{raise:50,straddle:0,turn:0},r_leg:{raise:-20,straddle:0,turn:0},l_knee:{bend:18},r_knee:{bend:36}}},{id:"sit",label:w.posePreset.sit(),jointAngles:{body:{bend:-5,turn:0,tilt:0},torso:{bend:5,turn:0,tilt:0},head:{nod:-5,turn:0,tilt:0},l_arm:{raise:0,straddle:8,turn:6},r_arm:{raise:0,straddle:15,turn:16},l_elbow:{bend:80},r_elbow:{bend:80},l_leg:{raise:90,straddle:5,turn:0},r_leg:{raise:90,straddle:5,turn:0},l_knee:{bend:90},r_knee:{bend:90}}},{id:"crouch",label:w.posePreset.crouch(),jointAngles:{body:{bend:20,turn:4,tilt:1},torso:{bend:32,turn:0,tilt:-3},head:{nod:-24,turn:-6,tilt:1},l_arm:{raise:34,straddle:18,turn:18},r_arm:{raise:34,straddle:18,turn:-18},l_elbow:{bend:86},r_elbow:{bend:86},l_leg:{raise:88,straddle:12,turn:-3},r_leg:{raise:88,straddle:8,turn:2},l_knee:{bend:146},r_knee:{bend:146}}},{id:"one_knee",label:w.posePreset.singleKneeKneel(),jointAngles:{body:{bend:-4,turn:-2,tilt:6},torso:{bend:24,turn:-6,tilt:-3},head:{nod:-10,turn:3,tilt:-2},l_arm:{raise:14,straddle:18,turn:6},r_arm:{raise:8,straddle:18,turn:-4},l_elbow:{bend:70},r_elbow:{bend:42},l_leg:{raise:82,straddle:6,turn:4},r_leg:{raise:-5,straddle:6,turn:-8},l_knee:{bend:86},r_knee:{bend:130}}},{id:"two_knees",label:w.posePreset.doubleKneeKneel(),jointAngles:{body:{bend:8,turn:0,tilt:0},torso:{bend:6,turn:0,tilt:0},head:{nod:-5,turn:0,tilt:0},l_arm:{raise:-5,straddle:7,turn:0},r_arm:{raise:-5,straddle:10,turn:0},l_elbow:{bend:15},r_elbow:{bend:15},l_leg:{raise:-10,straddle:0,turn:0},r_leg:{raise:-9,straddle:0,turn:0},l_knee:{bend:108},r_knee:{bend:104}}},{id:"lean",label:w.posePreset.leaning(),jointAngles:{body:{bend:0,turn:0,tilt:-5},torso:{bend:-3,turn:5,tilt:-5},head:{nod:-10,turn:10,tilt:-5},l_arm:{raise:-5,straddle:13,turn:0},r_arm:{raise:-10,straddle:16,turn:0},l_elbow:{bend:15},r_elbow:{bend:20},l_leg:{raise:0,straddle:5,turn:0},r_leg:{raise:20,straddle:0,turn:10},l_knee:{bend:0},r_knee:{bend:40}}},{id:"bow",label:w.posePreset.bow(),jointAngles:{body:{bend:24,turn:1,tilt:0},torso:{bend:30,turn:0,tilt:-1},head:{nod:18,turn:-3,tilt:1},l_arm:{raise:-8,straddle:8,turn:0},r_arm:{raise:-8,straddle:8,turn:0},l_elbow:{bend:4},r_elbow:{bend:4},l_leg:{raise:0,straddle:0,turn:0},r_leg:{raise:0,straddle:0,turn:0},l_knee:{bend:4},r_knee:{bend:4}}},{id:"think",label:w.posePreset.thinking(),jointAngles:{body:{bend:-2,turn:2,tilt:1},torso:{bend:7,turn:2,tilt:1},head:{nod:14,turn:8,tilt:-3},l_arm:{raise:42,straddle:-8,turn:-10},r_arm:{raise:8,straddle:22,turn:39},l_elbow:{bend:98},r_elbow:{bend:107},l_leg:{raise:0,straddle:4,turn:0},r_leg:{raise:0,straddle:4,turn:0},l_knee:{bend:0},r_knee:{bend:0}}},{id:"fight",label:w.posePreset.fighting(),jointAngles:{body:{bend:10,turn:-24,tilt:8},torso:{bend:18,turn:0,tilt:-4},head:{nod:-7,turn:24,tilt:-10},l_arm:{raise:78,straddle:24,turn:8},r_arm:{raise:82,straddle:48,turn:45},l_elbow:{bend:84},r_elbow:{bend:124},l_leg:{raise:46,straddle:18,turn:8},r_leg:{raise:34,straddle:14,turn:-2},l_knee:{bend:55},r_knee:{bend:78}}},{id:"kick",label:w.posePreset.kickBall(),jointAngles:{body:{bend:-8,turn:-12,tilt:-5},torso:{bend:-10,turn:-16,tilt:8},head:{nod:8,turn:-12,tilt:2},l_arm:{raise:-34,straddle:34,turn:-8},r_arm:{raise:42,straddle:28,turn:12},l_elbow:{bend:34},r_elbow:{bend:44},l_leg:{raise:-8,straddle:3,turn:-4},r_leg:{raise:104,straddle:3,turn:0},l_knee:{bend:16},r_knee:{bend:10}}},{id:"throw",label:w.posePreset.throwing(),jointAngles:{body:{bend:5,turn:-2,tilt:0},torso:{bend:4,turn:15,tilt:-5},head:{nod:-5,turn:-15,tilt:0},l_arm:{raise:7,straddle:17,turn:0},r_arm:{raise:77,straddle:0,turn:90},l_elbow:{bend:88},r_elbow:{bend:96},l_leg:{raise:15,straddle:5,turn:0},r_leg:{raise:-10,straddle:5,turn:0},l_knee:{bend:26},r_knee:{bend:36}}},{id:"push",label:w.posePreset.pushing(),jointAngles:{body:{bend:-1,turn:0,tilt:0},torso:{bend:19,turn:0,tilt:0},head:{nod:-5,turn:0,tilt:0},l_arm:{raise:100,straddle:6,turn:5},r_arm:{raise:101,straddle:11,turn:0},l_elbow:{bend:14},r_elbow:{bend:0},l_leg:{raise:41,straddle:0,turn:0},r_leg:{raise:-15,straddle:0,turn:0},l_knee:{bend:35},r_knee:{bend:10}}},{id:"wave",label:w.posePreset.wave(),jointAngles:{body:{bend:0,turn:0,tilt:0},torso:{bend:2,turn:-10,tilt:0},head:{nod:-5,turn:15,tilt:5},l_arm:{raise:0,straddle:6,turn:0},r_arm:{raise:62,straddle:-10,turn:90},l_elbow:{bend:62},r_elbow:{bend:94},l_leg:{raise:0,straddle:0,turn:0},r_leg:{raise:0,straddle:0,turn:0},l_knee:{bend:0},r_knee:{bend:0}}},{id:"stretch",label:w.posePreset.reachOut(),jointAngles:{body:{bend:-5,turn:0,tilt:0},torso:{bend:-16,turn:0,tilt:3},head:{nod:-25,turn:0,tilt:0},l_arm:{raise:115,straddle:-10,turn:10},r_arm:{raise:133,straddle:-10,turn:-10},l_elbow:{bend:59},r_elbow:{bend:53},l_leg:{raise:0,straddle:10,turn:0},r_leg:{raise:0,straddle:10,turn:0},l_knee:{bend:0},r_knee:{bend:0}}},{id:"arms_crossed",label:w.posePreset.armsCrossed(),jointAngles:{body:{bend:0,turn:0,tilt:0},torso:{bend:0,turn:2,tilt:0},head:{nod:-8,turn:0,tilt:0},l_arm:{raise:7,straddle:22,turn:17},r_arm:{raise:8,straddle:22,turn:39},l_elbow:{bend:107},r_elbow:{bend:107},l_leg:{raise:0,straddle:5,turn:0},r_leg:{raise:0,straddle:5,turn:0},l_knee:{bend:0},r_knee:{bend:0}}},{id:"phone",label:w.posePreset.phone(),jointAngles:{body:{bend:0,turn:0,tilt:0},torso:{bend:5,turn:0,tilt:0},head:{nod:17,turn:0,tilt:0},l_arm:{raise:55,straddle:-10,turn:-4},r_arm:{raise:24,straddle:-10,turn:-13},l_elbow:{bend:89},r_elbow:{bend:43},l_leg:{raise:0,straddle:5,turn:0},r_leg:{raise:0,straddle:5,turn:0},l_knee:{bend:0},r_knee:{bend:0}}}].map(e=>({...e,...Fde[e.id]})),_g=Object.freeze(zde),jat=["arms","body","legs"].map(e=>({id:e,get label(){return Gde(e)},controls:_g.filter(t=>t.group===e)})),dI=new Map(Vde.map(e=>[e.id,e])),uI=new Map(_g.map(e=>[e.id,e]));function qde(e){let t=zc(e)??yg;return dI.get(t)??dI.get(yg)}function Kde(e){let t=uI.has(e)?e:Ude[e];return t?uI.get(t):void 0}function zc(e){if(typeof e!="string")return;let t=Bde[e]??e;return dI.has(t)?t:void 0}function pI(e){return e?Object.fromEntries(Object.entries(e).flatMap(([t,n])=>{var i;return Number.isFinite(n)?[[((i=Kde(t))==null?void 0:i.id)??t,n]]:[]})):{}}function jde(e){let t=pI(e);return _g.some(n=>n.id in t)}function lI(){return UF(yg)}function UF(e){let t=qde(e);return Hde(t.jointAngles,{boneRotations:t.boneRotations,posePresetId:t.id,sourcePosePresetId:t.id,rootPositionOffset:t.rootPositionOffset})}function Tg(e){let t=typeof(e==null?void 0:e.posePresetId)=="string",n=zc(e==null?void 0:e.posePresetId),r=zc(e==null?void 0:e.sourcePosePresetId),i=pI(e==null?void 0:e.controlValues),o=UF(n??r??yg),a=jde(i),s=!!(e!=null&&e.bonePositions&&Object.keys(e.bonePositions).length>0)||!!(e!=null&&e.boneQuaternions&&Object.keys(e.boneQuaternions).length>0)||!!(e!=null&&e.boneScales&&Object.keys(e.boneScales).length>0),c=$de(e==null?void 0:e.motion),d=(e==null?void 0:e.mode)==="motion"&&c?"motion":"pose",u=t?n??(e==null?void 0:e.posePresetId):s?void 0:o.posePresetId,p=r??n??o.sourcePosePresetId??o.posePresetId;return{...o,baseAction:typeof(e==null?void 0:e.baseAction)=="string"?e.baseAction:o.baseAction,additiveWeights:(e==null?void 0:e.additiveWeights)??o.additiveWeights,boneRotations:e!=null&&e.boneRotations&&Object.keys(e.boneRotations).length>0?e.boneRotations:o.boneRotations,bonePositions:e!=null&&e.bonePositions&&Object.keys(e.bonePositions).length>0?VF(e.bonePositions):o.bonePositions,boneQuaternions:e!=null&&e.boneQuaternions&&Object.keys(e.boneQuaternions).length>0?KF(e.boneQuaternions):o.boneQuaternions,boneScales:e!=null&&e.boneScales&&Object.keys(e.boneScales).length>0?qF(e.boneScales):o.boneScales,controlValues:a?{...o.controlValues,...i}:o.controlValues,mode:d,motion:d==="motion"?c:void 0,posePresetId:u,sourcePosePresetId:p,rootPositionOffset:e!=null&&e.rootPositionOffset&&Object.keys(e.rootPositionOffset).length>0?{x:e.rootPositionOffset.x??0,y:e.rootPositionOffset.y??0,z:e.rootPositionOffset.z??0}:o.rootPositionOffset,speed:typeof(e==null?void 0:e.speed)=="number"&&Number.isFinite(e.speed)?e.speed:o.speed}}function Hde(e,t={}){let n=zc(t.posePresetId)??t.posePresetId,r=zc(t.sourcePosePresetId)??zc(n)??t.sourcePosePresetId;return{additiveWeights:{...t.additiveWeights??{}},baseAction:t.baseAction??"idle",...t.bonePositions&&Object.keys(t.bonePositions).length>0?{bonePositions:VF(t.bonePositions)}:{},...t.boneQuaternions&&Object.keys(t.boneQuaternions).length>0?{boneQuaternions:KF(t.boneQuaternions)}:{},...t.boneScales&&Object.keys(t.boneScales).length>0?{boneScales:qF(t.boneScales)}:{},boneRotations:Qde(t.boneRotations??{}),controlValues:{...Jde(t.controlValues),...Xde(e)},...n?{posePresetId:n}:{},...r?{sourcePosePresetId:r}:{},rootPositionOffset:Zde(t.rootPositionOffset),speed:t.speed??1,mode:"pose"}}function $de(e){if(!e||typeof e!="object")return;let t=typeof e.assetId=="string"?e.assetId.trim():"",n=typeof e.name=="string"?e.name.trim():"",r=typeof e.url=="string"?e.url.trim():"";if(!t||!n||!r)return;let i=e.source==="user"?"user":e.source==="official"?"official":void 0;if(!i)return;let o=e.sourceRig==="mixamorig"||e.sourceRig==="ccBase"||e.sourceRig==="generic"?e.sourceRig:void 0,a=typeof e.speed=="number"&&Number.isFinite(e.speed)&&e.speed>0?e.speed:1,s=typeof e.time=="number"&&Number.isFinite(e.time)&&e.time>=0?e.time:0,c=typeof e.clipName=="string"&&e.clipName.trim()?e.clipName.trim():void 0,d=Yde(e.locomotion);return{assetId:t,name:n,url:r,clipName:c,source:i,sourceRig:o,loop:e.loop!==!1,inPlace:e.inPlace===!0,...d?{locomotion:d}:{},speed:a,time:s}}function Yde(e){if(!e||typeof e!="object")return;let t={};return(e.forwardAxis==="+z"||e.forwardAxis==="-z")&&(t.forwardAxis=e.forwardAxis),typeof e.nominalSpeed=="number"&&Number.isFinite(e.nominalSpeed)&&e.nominalSpeed>0&&(t.nominalSpeed=e.nominalSpeed),(e.rootMotionPolicy==="source"||e.rootMotionPolicy==="force-in-place"||e.rootMotionPolicy==="warp-root-motion")&&(t.rootMotionPolicy=e.rootMotionPolicy),(e.syncMode==="manual"||e.syncMode==="path-speed"||e.syncMode==="fit-duration")&&(t.syncMode=e.syncMode),Object.keys(t).length?t:void 0}function Xde(e){return Object.fromEntries(_g.map(t=>[t.id,Wde(e,t)]))}function Wde(e,t){let n=e[t.joint],r=n==null?void 0:n[t.axis];return Number.isFinite(r)?r??0:0}function Jde(e){let t=pI(e);return Object.fromEntries(Object.entries(t).filter(([n])=>!uI.has(n)))}function Qde(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[sI(t)??t,{x:n.x??0,y:n.y??0,z:n.z??0}]))}function VF(e){return Object.fromEntries(Object.entries(e).flatMap(([t,n])=>{let r=t.trim();return r?[[r,{x:n.x??0,y:n.y??0,z:n.z??0}]]:[]}))}function qF(e){return Object.fromEntries(Object.entries(e).flatMap(([t,n])=>{let r=t.trim();return r?[[r,{x:n.x??1,y:n.y??1,z:n.z??1}]]:[]}))}function KF(e){return Object.fromEntries(Object.entries(e).flatMap(([t,n])=>{let r=t.trim();return r?[[r,{x:n.x??0,y:n.y??0,z:n.z??0,w:n.w??1}]]:[]}))}function Zde(e){return{x:(e==null?void 0:e.x)??0,y:(e==null?void 0:e.y)??0,z:(e==null?void 0:e.z)??0}}var eue={full:{width:21,height:9,label:"Auto"},"16:9":{width:16,height:9,label:"16:9"},"9:16":{width:9,height:16,label:"9:16"},"21:9":{width:21,height:9,label:"21:9"},"4:3":{width:4,height:3,label:"4:3"},"3:4":{width:3,height:4,label:"3:4"},"3:2":{width:3,height:2,label:"3:2"},"2:3":{width:2,height:3,label:"2:3"},"1:1":{width:1,height:1,label:"1:1"}};function tue(e,t){if(e==="custom"){let n=Math.max(1,(t==null?void 0:t.width)??1),r=Math.max(1,(t==null?void 0:t.height)??1);return{width:n,height:r,label:`${n}:${r}`}}return eue[e]}function jF(e){let t=tue(e.aspectRatio,e.customAspectRatio),n=1,r=1,i=t.width/t.height,o=i>=1?n:r*i,a=i>=1?n/i:r;return{aspectRatio:e.aspectRatio,label:t.label,width:o,height:a}}function HF(e={}){let t=e.skyColor??"#323438",n=e.panoramaUrl,r=e.mode??(n!=null&&n.trim()?"panorama":"color");return{...e,skyColor:t,panoramaUrl:n,mode:r}}var Po=["BoxGeometry","SphereGeometry","CapsuleGeometry","ConeGeometry","CylinderGeometry","TorusGeometry","PlaneGeometry","CircleGeometry","RingGeometry","LatheGeometry","TubeGeometry","ExtrudeGeometry"];var Do=(n=>(n.ArcLength="arc-length",n.TimeRatio="time-ratio",n))(Do||{});var nue=30,rue=0,iue=150;function oue(e={}){var n,r,i,o,a,s,c,d,u,p,m,f;let t={fcurves:e.fcurves??[],motionClips:(n=e.motionClips)!=null&&n.length?e.motionClips:void 0,motionTransitions:(r=e.motionTransitions)!=null&&r.length?e.motionTransitions:void 0,cameraMotionClips:(i=e.cameraMotionClips)!=null&&i.length?e.cameraMotionClips:void 0,cameraMotionTransitions:(o=e.cameraMotionTransitions)!=null&&o.length?e.cameraMotionTransitions:void 0,pathMotionClips:(a=e.pathMotionClips)!=null&&a.length?e.pathMotionClips:void 0,pathMotionTransitions:(s=e.pathMotionTransitions)!=null&&s.length?e.pathMotionTransitions:void 0};return(c=e.motionClips)!=null&&c.length&&(t.motionClips=e.motionClips),(d=e.motionTransitions)!=null&&d.length&&(t.motionTransitions=e.motionTransitions),(u=e.cameraMotionClips)!=null&&u.length&&(t.cameraMotionClips=e.cameraMotionClips),(p=e.cameraMotionTransitions)!=null&&p.length&&(t.cameraMotionTransitions=e.cameraMotionTransitions),(m=e.pathMotionClips)!=null&&m.length&&(t.pathMotionClips=e.pathMotionClips),(f=e.pathMotionTransitions)!=null&&f.length&&(t.pathMotionTransitions=e.pathMotionTransitions),t}function V(e={}){var t;return{version:1,fps:e.fps??nue,frameStart:e.frameStart??rue,frameEnd:e.frameEnd??iue,usePreviewRange:e.usePreviewRange??!1,previewFrameStart:e.previewFrameStart,previewFrameEnd:e.previewFrameEnd,lockedChannels:(t=e.lockedChannels)!=null&&t.length?e.lockedChannels:void 0,animation:oue(e.animation)}}var aue="pippit-role.glb";var Zat=`character/${aue}`,Sg=Bs.ASSETS.entries["pippit-role"].path,est=Sg.replace(/\/[^/]+$/,"");var bg="pippit-role",Cg="base-model",Ag="base",Eo="#4F8EF7",YF=Object.freeze(["#4F8EF7","#F26B6B","#58C27D","#F9A84B","#A78BFA","#FB8DC0","#55C1D6","#F2C94C"]),XF=/^character_\d+$/,WF=/^角色(\d+)$/,JF="角色A",mI="defaultCharacterIndex",Qa=.04,Za=.8;var Ig=Object.freeze({x:0,y:0,z:0}),fI=Object.freeze({x:1,y:1,z:1}),hI=Object.freeze({x:0,y:1.6246041243470328,z:4.246041243470324}),vg=Object.freeze({x:0,y:1.2,z:0}),xg=50,gI=.1,yI=1e5,_I="#323438";var TI=1,SI=0,bI=90,CI=180,AI="21:9";var Rg=1;function Mo(e="node"){let t=`${e}_${Rg}`;return Rg+=1,t}function cue(e){if(!(!Number.isInteger(e)||e<=0))return e}function QF(e){return cue(e==null?void 0:e[mI])}function due(e){let t=e.trim();if(!t)return;if(t===JF)return 1;let n=WF.exec(t);if(!n)return;let r=Number.parseInt(n[1],10);return Number.isFinite(r)&&r>0?r:void 0}function uue(e){var t,n,r;return XF.test(e.id)&&e.name.trim()!==""&&e.name!==w.defaults.character()&&((t=e.metadata)==null?void 0:t.assetId)===bg&&((n=e.metadata)==null?void 0:n.assetCategory)===Cg&&((r=e.metadata)==null?void 0:r.assetSource)===Ag}function pue(e,t=!0){let n=new Map,r=[],i=new Set;return e.forEach(o=>{if(o.type!=="character")return;let a=QF(o.metadata);if(a!==void 0){n.set(o.id,a),i.add(a);return}if(!t)return;let s=due(o.name);if(s!==void 0){n.set(o.id,s),i.add(s);return}uue(o)&&r.push(o)}),r.forEach(o=>{let a=1;for(;i.has(a);)a+=1;n.set(o.id,a),i.add(a)}),n}function ZF(e,t){return{...e??{},[mI]:t}}function lue(e,t=!0){let n=pue(e,t);return n.size===0?[...e]:e.map(r=>{if(r.type!=="character")return r;let i=n.get(r.id);return i===void 0||QF(r.metadata)===i?r:{...r,metadata:ZF(r.metadata,i)}})}function mue(){return w.defaults.defaultCharacter(1)}function Or(e={}){return{position:{...Ig,...e.position},rotation:{...Ig,...e.rotation},scale:{...fI,...e.scale}}}function eB(e={}){return{gridVisible:!0,helpersVisible:!0,compositionGuide:"none",transformMode:"translate",viewMode:"director",selectionMode:"pointer",...e}}function tB(e={}){return{transform:Or(e.transform),background:HF({skyColor:_I,...e.background}),sphere:{orientationVersion:TI,rotationX:SI,rotationY:bI,radius:CI,...e.sphere},display:{characterLabelsVisible:!0,gridSnapEnabled:!1,groundSnapEnabled:!1,groundVisible:!1,groundOpacity:1,groundHeight:0,...e.display}}}function fue(e={}){return{projection:"perspective",fovAxis:"vertical",fov:xg,near:gI,far:yI,isPrimary:!1,lookAt:{...vg},...e}}function Pg(e={}){return{id:e.id??Mo("camera"),type:"camera",name:e.name??w.defaults.camera(),visible:!0,locked:!1,transform:Or({position:{...hI},rotation:{x:0,y:0,z:0},...e.transform}),metadata:e.metadata,camera:fue({isPrimary:!0,fov:xg,...e.camera})}}function Up(e={}){return{id:e.id??Mo("character"),type:"character",name:e.name??w.defaults.character(),visible:!0,locked:!1,transform:Or(e.transform),metadata:{assetCategory:Cg,assetId:bg,assetSource:Ag,modelUrl:Sg,...e.metadata},character:{gender:e.gender??"unknown",motionId:e.motionId,placeholder:e.placeholder??!0,appearance:{color:e.color??Eo},label:{scale:Za,yOffset:Qa,showLabel:!0},animation:lI()}}}function Dg(e={}){return{id:e.id??Mo("prop"),type:"prop",name:e.name??w.defaults.prop(),visible:!0,locked:!1,transform:Or(e.transform),metadata:e.metadata,prop:{appearance:e.color?{color:e.color}:void 0,category:e.category}}}function Eg(e){return{id:e.id??Mo(e.kind),type:"primitive",name:e.name??w.defaults.primitive(),visible:!0,locked:!1,transform:Or(e.transform),metadata:e.metadata,primitive:{kind:e.kind,...e.parameters?{parameters:e.parameters}:{}}}}function Mg(e={}){return{id:e.id??Mo("light"),type:"light",name:e.name??w.defaults.light(),visible:!0,locked:!1,transform:Or(e.transform),metadata:e.metadata,light:{kind:e.kind??"directional",intensity:e.intensity??1,color:e.color??"#ffffff"}}}function hue(e,t={}){return{id:t.id??Mo("path_point"),position:{...e},...t.tangentIn?{tangentIn:{...t.tangentIn}}:{},...t.tangentOut?{tangentOut:{...t.tangentOut}}:{},...typeof t.timeRatio=="number"?{timeRatio:t.timeRatio}:{}}}function gue(e={}){return{source:e.source??"click",parameterization:e.parameterization??"arc-length",curve:e.curve??"catmullRom",points:(e.points??[]).map(t=>hue(t.position,t)),closed:e.closed===!0,groundSnap:e.groundSnap!==!1,smoothing:typeof e.smoothing=="number"?e.smoothing:.5}}function Ng(e={}){return{id:e.id??Mo("path"),type:"path",name:e.name??w.defaults.path(),visible:e.visible??!0,locked:e.locked??!1,transform:Or(e.transform),metadata:e.metadata,path:gue(e.path)}}function nB(e={}){let t=e.kind??"character";return{id:e.id??Mo("group"),type:"group",name:e.name??w.defaults.group(),visible:!0,locked:!1,transform:Or(e.transform),metadata:e.metadata,children:[],group:{kind:t,layout:{...xI},appearance:{color:Eo},label:{scale:Za,yOffset:Qa,showLabel:!0}}}}function vI(e={}){var r,i,o;let t=lue(e.nodes??[Up({name:mue(),gender:"female",transform:{position:{x:0,y:0,z:0}},metadata:ZF(void 0,1)})],!e.scenePlan);yue(t);let n=e.activeShotCameraNodeId??e.activeCameraId;return{version:1,nodes:t,generate:e.generate,generate_run_id:e.generate_run_id,applied_generate_run_id:e.applied_generate_run_id,activeShotCameraNodeId:n,aspectRatio:e.aspectRatio??AI,customAspectRatio:e.customAspectRatio,settings:eB(e.settings),environment:tB(e.environment),asset:e.asset,captures:e.captures,timeline:V(e.timeline),scenePlan:e.scenePlan?{revision:e.scenePlan.revision,appliedExecutionKeys:[...e.scenePlan.appliedExecutionKeys]}:void 0,generatedMeshes:(r=e.generatedMeshes)==null?void 0:r.map(a=>({meshId:a.meshId,name:a.name,generateRef:a.generateRef,parts:a.parts.map(s=>({...s,parameters:{...s.parameters},position:{...s.position},rotation:{...s.rotation},scale:{...s.scale}})),anchors:a.anchors.map(s=>({...s,capabilities:[...s.capabilities],position:{...s.position},rotation:{...s.rotation}}))})),physicalConstraints:(i=e.physicalConstraints)==null?void 0:i.map(a=>({...a,supported_anchor:a.supported_anchor?{...a.supported_anchor}:void 0,supporting_anchor:a.supporting_anchor?{...a.supporting_anchor}:void 0,attached_anchor:a.attached_anchor?{...a.attached_anchor}:void 0,target_anchor:a.target_anchor?{...a.target_anchor}:void 0,anchor_a:a.anchor_a?{...a.anchor_a}:void 0,anchor_b:a.anchor_b?{...a.anchor_b}:void 0})),characterGroups:(o=e.characterGroups)==null?void 0:o.map(a=>({...a,member_ids:[...a.member_ids]}))}}function yue(e){let t=0;e.forEach(n=>{let r=_ue(n.id);r!==void 0&&r>t&&(t=r)}),t>0&&Rg<=t&&(Rg=t+1)}function _ue(e){if(!e)return;let t=/_(\d+)$/.exec(e);if(!t)return;let n=Number.parseInt(t[1],10);return Number.isFinite(n)?n:void 0}var RI=new Set(["character","prop"]),xI={perRow:2,perColumn:2,spacingDepth:120,spacingWidth:120};function Un(e){return(e==null?void 0:e.type)==="group"}function Tue(e){let t=e.includes("character"),n=e.includes("prop");return t&&n?"mixed":t?"character":"prop"}function wg(e){return e.length<2||e.some(t=>t.locked||t.parentId)?!1:e.every(t=>RI.has(t.type))}function PI(e,t){return t.children.map(n=>e.nodes.find(r=>r.id===n)).filter(n=>!!n)}function Sue(e,t){let n=e.find(r=>r.type==="character");return{kind:t,layout:{...xI},appearance:{color:(n==null?void 0:n.type)==="character"?n.character.appearance.color:Eo},label:{scale:(n==null?void 0:n.type)==="character"?n.character.label.scale:Za,yOffset:(n==null?void 0:n.type)==="character"?n.character.label.yOffset:Qa,showLabel:(n==null?void 0:n.type)==="character"?n.character.label.showLabel:!0}}}function iB(e,t,n){let r=Tue(t.map(i=>i.type));return{...nB({name:n}),children:t.map(i=>i.id),group:Sue(t,r)}}function rB(e){return e/100}function bue(e,t){if(e<=0)return[];let n=Math.max(1,Math.round(t.perRow)),r=Math.max(1,Math.ceil(e/n)),i=rB(t.spacingWidth),o=rB(t.spacingDepth),a=(n-1)*i,s=(r-1)*o;return Array.from({length:e},(c,d)=>{let u=Math.floor(d/n);return{x:d%n*i-a/2,y:0,z:u*o-s/2}})}function oB(e,t){let n=bue(e.length,t);return e.map((r,i)=>({...r,position:n[i]??r.position}))}var Vn={};X_(Vn,{DEG2RAD:()=>GI,MathUtils:()=>Cue,RAD2DEG:()=>zI,ceilPowerOfTwo:()=>SB,clamp:()=>xe,damp:()=>uB,degToRad:()=>Uc,denormalize:()=>AB,euclideanModulo:()=>UI,floorPowerOfTwo:()=>bB,generateUUID:()=>Og,inverseLerp:()=>dB,isPowerOfTwo:()=>TB,lerp:()=>VI,mapLinear:()=>cB,normalize:()=>IB,pingpong:()=>pB,radToDeg:()=>_B,randFloat:()=>hB,randFloatSpread:()=>gB,randInt:()=>fB,seededRandom:()=>yB,setQuaternionFromProperEuler:()=>CB,smootherstep:()=>mB,smoothstep:()=>lB});var DI=0,EI=1,MI=2,NI=3,wI=4,kI=5,OI=6,LI=7;var Vp=2e3,FI=2001;var kg=null;function aB(e){let t=e[0];if(typeof t=="string"&&t.startsWith("TSL:")){let n=e[1];n&&n.isStackTrace?e[0]+=" "+n.getLocation():e[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return e}function No(...e){e=aB(e);let t="THREE."+e.shift();if(kg)kg("warn",t,...e);else{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function BI(...e){e=aB(e);let t="THREE."+e.shift();if(kg)kg("error",t,...e);else{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}var Ist={[DI]:EI,[MI]:OI,[wI]:LI,[NI]:kI,[EI]:DI,[OI]:MI,[LI]:wI,[kI]:NI};var Gt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],sB=1234567,GI=Math.PI/180,zI=180/Math.PI;function Og(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Gt[e&255]+Gt[e>>8&255]+Gt[e>>16&255]+Gt[e>>24&255]+"-"+Gt[t&255]+Gt[t>>8&255]+"-"+Gt[t>>16&15|64]+Gt[t>>24&255]+"-"+Gt[n&63|128]+Gt[n>>8&255]+"-"+Gt[n>>16&255]+Gt[n>>24&255]+Gt[r&255]+Gt[r>>8&255]+Gt[r>>16&255]+Gt[r>>24&255]).toLowerCase()}function xe(e,t,n){return Math.max(t,Math.min(n,e))}function UI(e,t){return(e%t+t)%t}function cB(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function dB(e,t,n){return e!==t?(n-e)/(t-e):0}function VI(e,t,n){return(1-n)*e+n*t}function uB(e,t,n,r){return VI(e,t,1-Math.exp(-n*r))}function pB(e,t=1){return t-Math.abs(UI(e,t*2)-t)}function lB(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function mB(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function fB(e,t){return e+Math.floor(Math.random()*(t-e+1))}function hB(e,t){return e+Math.random()*(t-e)}function gB(e){return e*(.5-Math.random())}function yB(e){e!==void 0&&(sB=e);let t=sB+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Uc(e){return e*GI}function _B(e){return e*zI}function TB(e){return(e&e-1)===0&&e!==0}function SB(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function bB(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function CB(e,t,n,r,i){let o=Math.cos,a=Math.sin,s=o(n/2),c=a(n/2),d=o((t+r)/2),u=a((t+r)/2),p=o((t-r)/2),m=a((t-r)/2),f=o((r-t)/2),h=a((r-t)/2);switch(i){case"XYX":e.set(s*u,c*p,c*m,s*d);break;case"YZY":e.set(c*m,s*u,c*p,s*d);break;case"ZXZ":e.set(c*p,c*m,s*u,s*d);break;case"XZX":e.set(s*u,c*h,c*f,s*d);break;case"YXY":e.set(c*f,s*u,c*h,s*d);break;case"ZYZ":e.set(c*h,c*f,s*u,s*d);break;default:No("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function AB(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function IB(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw new Error("Invalid component type.")}}var Cue={DEG2RAD:GI,RAD2DEG:zI,generateUUID:Og,clamp:xe,euclideanModulo:UI,mapLinear:cB,inverseLerp:dB,lerp:VI,damp:uB,pingpong:pB,smoothstep:lB,smootherstep:mB,randInt:fB,randFloat:hB,randFloatSpread:gB,seededRandom:yB,degToRad:Uc,radToDeg:_B,isPowerOfTwo:TB,ceilPowerOfTwo:SB,floorPowerOfTwo:bB,setQuaternionFromProperEuler:CB,normalize:IB,denormalize:AB};var tn=class{constructor(t=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=t,this._y=n,this._z=r,this._w=i}static slerpFlat(t,n,r,i,o,a,s){let c=r[i+0],d=r[i+1],u=r[i+2],p=r[i+3],m=o[a+0],f=o[a+1],h=o[a+2],g=o[a+3];if(p!==g||c!==m||d!==f||u!==h){let y=c*m+d*f+u*h+p*g;y<0&&(m=-m,f=-f,h=-h,g=-g,y=-y);let _=1-s;if(y<.9995){let S=Math.acos(y),T=Math.sin(S);_=Math.sin(_*S)/T,s=Math.sin(s*S)/T,c=c*_+m*s,d=d*_+f*s,u=u*_+h*s,p=p*_+g*s}else{c=c*_+m*s,d=d*_+f*s,u=u*_+h*s,p=p*_+g*s;let S=1/Math.sqrt(c*c+d*d+u*u+p*p);c*=S,d*=S,u*=S,p*=S}}t[n]=c,t[n+1]=d,t[n+2]=u,t[n+3]=p}static multiplyQuaternionsFlat(t,n,r,i,o,a){let s=r[i],c=r[i+1],d=r[i+2],u=r[i+3],p=o[a],m=o[a+1],f=o[a+2],h=o[a+3];return t[n]=s*h+u*p+c*f-d*m,t[n+1]=c*h+u*m+d*p-s*f,t[n+2]=d*h+u*f+s*m-c*p,t[n+3]=u*h-s*p-c*m-d*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,n,r,i){return this._x=t,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,n=!0){let r=t._x,i=t._y,o=t._z,a=t._order,s=Math.cos,c=Math.sin,d=s(r/2),u=s(i/2),p=s(o/2),m=c(r/2),f=c(i/2),h=c(o/2);switch(a){case"XYZ":this._x=m*u*p+d*f*h,this._y=d*f*p-m*u*h,this._z=d*u*h+m*f*p,this._w=d*u*p-m*f*h;break;case"YXZ":this._x=m*u*p+d*f*h,this._y=d*f*p-m*u*h,this._z=d*u*h-m*f*p,this._w=d*u*p+m*f*h;break;case"ZXY":this._x=m*u*p-d*f*h,this._y=d*f*p+m*u*h,this._z=d*u*h+m*f*p,this._w=d*u*p-m*f*h;break;case"ZYX":this._x=m*u*p-d*f*h,this._y=d*f*p+m*u*h,this._z=d*u*h-m*f*p,this._w=d*u*p+m*f*h;break;case"YZX":this._x=m*u*p+d*f*h,this._y=d*f*p+m*u*h,this._z=d*u*h-m*f*p,this._w=d*u*p-m*f*h;break;case"XZY":this._x=m*u*p-d*f*h,this._y=d*f*p-m*u*h,this._z=d*u*h+m*f*p,this._w=d*u*p+m*f*h;break;default:No("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,n){let r=n/2,i=Math.sin(r);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(t){let n=t.elements,r=n[0],i=n[4],o=n[8],a=n[1],s=n[5],c=n[9],d=n[2],u=n[6],p=n[10],m=r+s+p;if(m>0){let f=.5/Math.sqrt(m+1);this._w=.25/f,this._x=(u-c)*f,this._y=(o-d)*f,this._z=(a-i)*f}else if(r>s&&r>p){let f=2*Math.sqrt(1+r-s-p);this._w=(u-c)/f,this._x=.25*f,this._y=(i+a)/f,this._z=(o+d)/f}else if(s>p){let f=2*Math.sqrt(1+s-r-p);this._w=(o-d)/f,this._x=(i+a)/f,this._y=.25*f,this._z=(c+u)/f}else{let f=2*Math.sqrt(1+p-r-s);this._w=(a-i)/f,this._x=(o+d)/f,this._y=(c+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,n){let r=t.dot(n)+1;return r<1e-8?(r=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=r):(this._x=0,this._y=-t.z,this._z=t.y,this._w=r)):(this._x=t.y*n.z-t.z*n.y,this._y=t.z*n.x-t.x*n.z,this._z=t.x*n.y-t.y*n.x,this._w=r),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(xe(this.dot(t),-1,1)))}rotateTowards(t,n){let r=this.angleTo(t);if(r===0)return this;let i=Math.min(1,n/r);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,n){let r=t._x,i=t._y,o=t._z,a=t._w,s=n._x,c=n._y,d=n._z,u=n._w;return this._x=r*u+a*s+i*d-o*c,this._y=i*u+a*c+o*s-r*d,this._z=o*u+a*d+r*c-i*s,this._w=a*u-r*s-i*c-o*d,this._onChangeCallback(),this}slerp(t,n){let r=t._x,i=t._y,o=t._z,a=t._w,s=this.dot(t);s<0&&(r=-r,i=-i,o=-o,a=-a,s=-s);let c=1-n;if(s<.9995){let d=Math.acos(s),u=Math.sin(d);c=Math.sin(c*d)/u,n=Math.sin(n*d)/u,this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+o*n,this._w=this._w*c+a*n,this._onChangeCallback()}else this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+o*n,this._w=this._w*c+a*n,this.normalize();return this}slerpQuaternions(t,n,r){return this.copy(t).slerp(n,r)}random(){let t=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),o=Math.sqrt(r);return this.set(i*Math.sin(t),i*Math.cos(t),o*Math.sin(n),o*Math.cos(n))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,n=0){return this._x=t[n],this._y=t[n+1],this._z=t[n+2],this._w=t[n+3],this._onChangeCallback(),this}toArray(t=[],n=0){return t[n]=this._x,t[n+1]=this._y,t[n+2]=this._z,t[n+3]=this._w,t}fromBufferAttribute(t,n){return this._x=t.getX(n),this._y=t.getY(n),this._z=t.getZ(n),this._w=t.getW(n),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}};var KI=class KI{constructor(t=0,n=0,r=0){this.x=t,this.y=n,this.z=r}set(t,n,r){return r===void 0&&(r=this.z),this.x=t,this.y=n,this.z=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,n){switch(t){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,n){return this.x=t.x+n.x,this.y=t.y+n.y,this.z=t.z+n.z,this}addScaledVector(t,n){return this.x+=t.x*n,this.y+=t.y*n,this.z+=t.z*n,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,n){return this.x=t.x-n.x,this.y=t.y-n.y,this.z=t.z-n.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,n){return this.x=t.x*n.x,this.y=t.y*n.y,this.z=t.z*n.z,this}applyEuler(t){return this.applyQuaternion(vB.setFromEuler(t))}applyAxisAngle(t,n){return this.applyQuaternion(vB.setFromAxisAngle(t,n))}applyMatrix3(t){let n=this.x,r=this.y,i=this.z,o=t.elements;return this.x=o[0]*n+o[3]*r+o[6]*i,this.y=o[1]*n+o[4]*r+o[7]*i,this.z=o[2]*n+o[5]*r+o[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let n=this.x,r=this.y,i=this.z,o=t.elements,a=1/(o[3]*n+o[7]*r+o[11]*i+o[15]);return this.x=(o[0]*n+o[4]*r+o[8]*i+o[12])*a,this.y=(o[1]*n+o[5]*r+o[9]*i+o[13])*a,this.z=(o[2]*n+o[6]*r+o[10]*i+o[14])*a,this}applyQuaternion(t){let n=this.x,r=this.y,i=this.z,o=t.x,a=t.y,s=t.z,c=t.w,d=2*(a*i-s*r),u=2*(s*n-o*i),p=2*(o*r-a*n);return this.x=n+c*d+a*p-s*u,this.y=r+c*u+s*d-o*p,this.z=i+c*p+o*u-a*d,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let n=this.x,r=this.y,i=this.z,o=t.elements;return this.x=o[0]*n+o[4]*r+o[8]*i,this.y=o[1]*n+o[5]*r+o[9]*i,this.z=o[2]*n+o[6]*r+o[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,n){return this.x=xe(this.x,t.x,n.x),this.y=xe(this.y,t.y,n.y),this.z=xe(this.z,t.z,n.z),this}clampScalar(t,n){return this.x=xe(this.x,t,n),this.y=xe(this.y,t,n),this.z=xe(this.z,t,n),this}clampLength(t,n){let r=this.length();return this.divideScalar(r||1).multiplyScalar(xe(r,t,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,n){return this.x+=(t.x-this.x)*n,this.y+=(t.y-this.y)*n,this.z+=(t.z-this.z)*n,this}lerpVectors(t,n,r){return this.x=t.x+(n.x-t.x)*r,this.y=t.y+(n.y-t.y)*r,this.z=t.z+(n.z-t.z)*r,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,n){let r=t.x,i=t.y,o=t.z,a=n.x,s=n.y,c=n.z;return this.x=i*c-o*s,this.y=o*a-r*c,this.z=r*s-i*a,this}projectOnVector(t){let n=t.lengthSq();if(n===0)return this.set(0,0,0);let r=t.dot(this)/n;return this.copy(t).multiplyScalar(r)}projectOnPlane(t){return qI.copy(this).projectOnVector(t),this.sub(qI)}reflect(t){return this.sub(qI.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let n=Math.sqrt(this.lengthSq()*t.lengthSq());if(n===0)return Math.PI/2;let r=this.dot(t)/n;return Math.acos(xe(r,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let n=this.x-t.x,r=this.y-t.y,i=this.z-t.z;return n*n+r*r+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,n,r){let i=Math.sin(n)*t;return this.x=i*Math.sin(r),this.y=Math.cos(n)*t,this.z=i*Math.cos(r),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,n,r){return this.x=t*Math.sin(n),this.y=r,this.z=t*Math.cos(n),this}setFromMatrixPosition(t){let n=t.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(t){let n=this.setFromMatrixColumn(t,0).length(),r=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=n,this.y=r,this.z=i,this}setFromMatrixColumn(t,n){return this.fromArray(t.elements,n*4)}setFromMatrix3Column(t,n){return this.fromArray(t.elements,n*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,n=0){return this.x=t[n],this.y=t[n+1],this.z=t[n+2],this}toArray(t=[],n=0){return t[n]=this.x,t[n+1]=this.y,t[n+2]=this.z,t}fromBufferAttribute(t,n){return this.x=t.getX(n),this.y=t.getY(n),this.z=t.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=Math.random()*Math.PI*2,n=Math.random()*2-1,r=Math.sqrt(1-n*n);return this.x=r*Math.cos(t),this.y=n,this.z=r*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};KI.prototype.isVector3=!0;var k=KI,qI=new k,vB=new tn;var Fg=class Fg{constructor(t,n,r,i,o,a,s,c,d,u,p,m,f,h,g,y){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,r,i,o,a,s,c,d,u,p,m,f,h,g,y)}set(t,n,r,i,o,a,s,c,d,u,p,m,f,h,g,y){let _=this.elements;return _[0]=t,_[4]=n,_[8]=r,_[12]=i,_[1]=o,_[5]=a,_[9]=s,_[13]=c,_[2]=d,_[6]=u,_[10]=p,_[14]=m,_[3]=f,_[7]=h,_[11]=g,_[15]=y,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Fg().fromArray(this.elements)}copy(t){let n=this.elements,r=t.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],n[9]=r[9],n[10]=r[10],n[11]=r[11],n[12]=r[12],n[13]=r[13],n[14]=r[14],n[15]=r[15],this}copyPosition(t){let n=this.elements,r=t.elements;return n[12]=r[12],n[13]=r[13],n[14]=r[14],this}setFromMatrix3(t){let n=t.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}extractBasis(t,n,r){return this.determinant()===0?(t.set(1,0,0),n.set(0,1,0),r.set(0,0,1),this):(t.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this)}makeBasis(t,n,r){return this.set(t.x,n.x,r.x,0,t.y,n.y,r.y,0,t.z,n.z,r.z,0,0,0,0,1),this}extractRotation(t){if(t.determinant()===0)return this.identity();let n=this.elements,r=t.elements,i=1/Vc.setFromMatrixColumn(t,0).length(),o=1/Vc.setFromMatrixColumn(t,1).length(),a=1/Vc.setFromMatrixColumn(t,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*o,n[5]=r[5]*o,n[6]=r[6]*o,n[7]=0,n[8]=r[8]*a,n[9]=r[9]*a,n[10]=r[10]*a,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(t){let n=this.elements,r=t.x,i=t.y,o=t.z,a=Math.cos(r),s=Math.sin(r),c=Math.cos(i),d=Math.sin(i),u=Math.cos(o),p=Math.sin(o);if(t.order==="XYZ"){let m=a*u,f=a*p,h=s*u,g=s*p;n[0]=c*u,n[4]=-c*p,n[8]=d,n[1]=f+h*d,n[5]=m-g*d,n[9]=-s*c,n[2]=g-m*d,n[6]=h+f*d,n[10]=a*c}else if(t.order==="YXZ"){let m=c*u,f=c*p,h=d*u,g=d*p;n[0]=m+g*s,n[4]=h*s-f,n[8]=a*d,n[1]=a*p,n[5]=a*u,n[9]=-s,n[2]=f*s-h,n[6]=g+m*s,n[10]=a*c}else if(t.order==="ZXY"){let m=c*u,f=c*p,h=d*u,g=d*p;n[0]=m-g*s,n[4]=-a*p,n[8]=h+f*s,n[1]=f+h*s,n[5]=a*u,n[9]=g-m*s,n[2]=-a*d,n[6]=s,n[10]=a*c}else if(t.order==="ZYX"){let m=a*u,f=a*p,h=s*u,g=s*p;n[0]=c*u,n[4]=h*d-f,n[8]=m*d+g,n[1]=c*p,n[5]=g*d+m,n[9]=f*d-h,n[2]=-d,n[6]=s*c,n[10]=a*c}else if(t.order==="YZX"){let m=a*c,f=a*d,h=s*c,g=s*d;n[0]=c*u,n[4]=g-m*p,n[8]=h*p+f,n[1]=p,n[5]=a*u,n[9]=-s*u,n[2]=-d*u,n[6]=f*p+h,n[10]=m-g*p}else if(t.order==="XZY"){let m=a*c,f=a*d,h=s*c,g=s*d;n[0]=c*u,n[4]=-p,n[8]=d*u,n[1]=m*p+g,n[5]=a*u,n[9]=f*p-h,n[2]=h*p-f,n[6]=s*u,n[10]=g*p+m}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Aue,t,Iue)}lookAt(t,n,r){let i=this.elements;return bn.subVectors(t,n),bn.lengthSq()===0&&(bn.z=1),bn.normalize(),wo.crossVectors(r,bn),wo.lengthSq()===0&&(Math.abs(r.z)===1?bn.x+=1e-4:bn.z+=1e-4,bn.normalize(),wo.crossVectors(r,bn)),wo.normalize(),Lg.crossVectors(bn,wo),i[0]=wo.x,i[4]=Lg.x,i[8]=bn.x,i[1]=wo.y,i[5]=Lg.y,i[9]=bn.y,i[2]=wo.z,i[6]=Lg.z,i[10]=bn.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,n){let r=t.elements,i=n.elements,o=this.elements,a=r[0],s=r[4],c=r[8],d=r[12],u=r[1],p=r[5],m=r[9],f=r[13],h=r[2],g=r[6],y=r[10],_=r[14],S=r[3],T=r[7],C=r[11],I=r[15],x=i[0],R=i[4],G=i[8],O=i[12],K=i[1],H=i[5],U=i[9],W=i[13],re=i[2],Q=i[6],Ge=i[10],Xe=i[14],Ce=i[3],ze=i[7],Nt=i[11],Re=i[15];return o[0]=a*x+s*K+c*re+d*Ce,o[4]=a*R+s*H+c*Q+d*ze,o[8]=a*G+s*U+c*Ge+d*Nt,o[12]=a*O+s*W+c*Xe+d*Re,o[1]=u*x+p*K+m*re+f*Ce,o[5]=u*R+p*H+m*Q+f*ze,o[9]=u*G+p*U+m*Ge+f*Nt,o[13]=u*O+p*W+m*Xe+f*Re,o[2]=h*x+g*K+y*re+_*Ce,o[6]=h*R+g*H+y*Q+_*ze,o[10]=h*G+g*U+y*Ge+_*Nt,o[14]=h*O+g*W+y*Xe+_*Re,o[3]=S*x+T*K+C*re+I*Ce,o[7]=S*R+T*H+C*Q+I*ze,o[11]=S*G+T*U+C*Ge+I*Nt,o[15]=S*O+T*W+C*Xe+I*Re,this}multiplyScalar(t){let n=this.elements;return n[0]*=t,n[4]*=t,n[8]*=t,n[12]*=t,n[1]*=t,n[5]*=t,n[9]*=t,n[13]*=t,n[2]*=t,n[6]*=t,n[10]*=t,n[14]*=t,n[3]*=t,n[7]*=t,n[11]*=t,n[15]*=t,this}determinant(){let t=this.elements,n=t[0],r=t[4],i=t[8],o=t[12],a=t[1],s=t[5],c=t[9],d=t[13],u=t[2],p=t[6],m=t[10],f=t[14],h=t[3],g=t[7],y=t[11],_=t[15],S=c*f-d*m,T=s*f-d*p,C=s*m-c*p,I=a*f-d*u,x=a*m-c*u,R=a*p-s*u;return n*(g*S-y*T+_*C)-r*(h*S-y*I+_*x)+i*(h*T-g*I+_*R)-o*(h*C-g*x+y*R)}transpose(){let t=this.elements,n;return n=t[1],t[1]=t[4],t[4]=n,n=t[2],t[2]=t[8],t[8]=n,n=t[6],t[6]=t[9],t[9]=n,n=t[3],t[3]=t[12],t[12]=n,n=t[7],t[7]=t[13],t[13]=n,n=t[11],t[11]=t[14],t[14]=n,this}setPosition(t,n,r){let i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=n,i[14]=r),this}invert(){let t=this.elements,n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],c=t[6],d=t[7],u=t[8],p=t[9],m=t[10],f=t[11],h=t[12],g=t[13],y=t[14],_=t[15],S=n*s-r*a,T=n*c-i*a,C=n*d-o*a,I=r*c-i*s,x=r*d-o*s,R=i*d-o*c,G=u*g-p*h,O=u*y-m*h,K=u*_-f*h,H=p*y-m*g,U=p*_-f*g,W=m*_-f*y,re=S*W-T*U+C*H+I*K-x*O+R*G;if(re===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let Q=1/re;return t[0]=(s*W-c*U+d*H)*Q,t[1]=(i*U-r*W-o*H)*Q,t[2]=(g*R-y*x+_*I)*Q,t[3]=(m*x-p*R-f*I)*Q,t[4]=(c*K-a*W-d*O)*Q,t[5]=(n*W-i*K+o*O)*Q,t[6]=(y*C-h*R-_*T)*Q,t[7]=(u*R-m*C+f*T)*Q,t[8]=(a*U-s*K+d*G)*Q,t[9]=(r*K-n*U-o*G)*Q,t[10]=(h*x-g*C+_*S)*Q,t[11]=(p*C-u*x-f*S)*Q,t[12]=(s*O-a*H-c*G)*Q,t[13]=(n*H-r*O+i*G)*Q,t[14]=(g*T-h*I-y*S)*Q,t[15]=(u*I-p*T+m*S)*Q,this}scale(t){let n=this.elements,r=t.x,i=t.y,o=t.z;return n[0]*=r,n[4]*=i,n[8]*=o,n[1]*=r,n[5]*=i,n[9]*=o,n[2]*=r,n[6]*=i,n[10]*=o,n[3]*=r,n[7]*=i,n[11]*=o,this}getMaxScaleOnAxis(){let t=this.elements,n=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],r=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(t,n,r){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(t){let n=Math.cos(t),r=Math.sin(t);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(t){let n=Math.cos(t),r=Math.sin(t);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(t){let n=Math.cos(t),r=Math.sin(t);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,n){let r=Math.cos(n),i=Math.sin(n),o=1-r,a=t.x,s=t.y,c=t.z,d=o*a,u=o*s;return this.set(d*a+r,d*s-i*c,d*c+i*s,0,d*s+i*c,u*s+r,u*c-i*a,0,d*c-i*s,u*c+i*a,o*c*c+r,0,0,0,0,1),this}makeScale(t,n,r){return this.set(t,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(t,n,r,i,o,a){return this.set(1,r,o,0,t,1,a,0,n,i,1,0,0,0,0,1),this}compose(t,n,r){let i=this.elements,o=n._x,a=n._y,s=n._z,c=n._w,d=o+o,u=a+a,p=s+s,m=o*d,f=o*u,h=o*p,g=a*u,y=a*p,_=s*p,S=c*d,T=c*u,C=c*p,I=r.x,x=r.y,R=r.z;return i[0]=(1-(g+_))*I,i[1]=(f+C)*I,i[2]=(h-T)*I,i[3]=0,i[4]=(f-C)*x,i[5]=(1-(m+_))*x,i[6]=(y+S)*x,i[7]=0,i[8]=(h+T)*R,i[9]=(y-S)*R,i[10]=(1-(m+g))*R,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,n,r){let i=this.elements;t.x=i[12],t.y=i[13],t.z=i[14];let o=this.determinant();if(o===0)return r.set(1,1,1),n.identity(),this;let a=Vc.set(i[0],i[1],i[2]).length(),s=Vc.set(i[4],i[5],i[6]).length(),c=Vc.set(i[8],i[9],i[10]).length();o<0&&(a=-a),ar.copy(this);let d=1/a,u=1/s,p=1/c;return ar.elements[0]*=d,ar.elements[1]*=d,ar.elements[2]*=d,ar.elements[4]*=u,ar.elements[5]*=u,ar.elements[6]*=u,ar.elements[8]*=p,ar.elements[9]*=p,ar.elements[10]*=p,n.setFromRotationMatrix(ar),r.x=a,r.y=s,r.z=c,this}makePerspective(t,n,r,i,o,a,s=Vp,c=!1){let d=this.elements,u=2*o/(n-t),p=2*o/(r-i),m=(n+t)/(n-t),f=(r+i)/(r-i),h,g;if(c)h=o/(a-o),g=a*o/(a-o);else if(s===Vp)h=-(a+o)/(a-o),g=-2*a*o/(a-o);else if(s===FI)h=-a/(a-o),g=-a*o/(a-o);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+s);return d[0]=u,d[4]=0,d[8]=m,d[12]=0,d[1]=0,d[5]=p,d[9]=f,d[13]=0,d[2]=0,d[6]=0,d[10]=h,d[14]=g,d[3]=0,d[7]=0,d[11]=-1,d[15]=0,this}makeOrthographic(t,n,r,i,o,a,s=Vp,c=!1){let d=this.elements,u=2/(n-t),p=2/(r-i),m=-(n+t)/(n-t),f=-(r+i)/(r-i),h,g;if(c)h=1/(a-o),g=a/(a-o);else if(s===Vp)h=-2/(a-o),g=-(a+o)/(a-o);else if(s===FI)h=-1/(a-o),g=-o/(a-o);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+s);return d[0]=u,d[4]=0,d[8]=0,d[12]=m,d[1]=0,d[5]=p,d[9]=0,d[13]=f,d[2]=0,d[6]=0,d[10]=h,d[14]=g,d[3]=0,d[7]=0,d[11]=0,d[15]=1,this}equals(t){let n=this.elements,r=t.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(t,n=0){for(let r=0;r<16;r++)this.elements[r]=t[r+n];return this}toArray(t=[],n=0){let r=this.elements;return t[n]=r[0],t[n+1]=r[1],t[n+2]=r[2],t[n+3]=r[3],t[n+4]=r[4],t[n+5]=r[5],t[n+6]=r[6],t[n+7]=r[7],t[n+8]=r[8],t[n+9]=r[9],t[n+10]=r[10],t[n+11]=r[11],t[n+12]=r[12],t[n+13]=r[13],t[n+14]=r[14],t[n+15]=r[15],t}};Fg.prototype.isMatrix4=!0;var $t=Fg,Vc=new k,ar=new $t,Aue=new k(0,0,0),Iue=new k(1,1,1),wo=new k,Lg=new k,bn=new k;var xB=new $t,RB=new tn,vi=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,n,r,i=this._order){return this._x=t,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,n=this._order,r=!0){let i=t.elements,o=i[0],a=i[4],s=i[8],c=i[1],d=i[5],u=i[9],p=i[2],m=i[6],f=i[10];switch(n){case"XYZ":this._y=Math.asin(xe(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(m,d),this._z=0);break;case"YXZ":this._x=Math.asin(-xe(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(s,f),this._z=Math.atan2(c,d)):(this._y=Math.atan2(-p,o),this._z=0);break;case"ZXY":this._x=Math.asin(xe(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-p,f),this._z=Math.atan2(-a,d)):(this._y=0,this._z=Math.atan2(c,o));break;case"ZYX":this._y=Math.asin(-xe(p,-1,1)),Math.abs(p)<.9999999?(this._x=Math.atan2(m,f),this._z=Math.atan2(c,o)):(this._x=0,this._z=Math.atan2(-a,d));break;case"YZX":this._z=Math.asin(xe(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,d),this._y=Math.atan2(-p,o)):(this._x=0,this._y=Math.atan2(s,f));break;case"XZY":this._z=Math.asin(-xe(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(m,d),this._y=Math.atan2(s,o)):(this._x=Math.atan2(-u,f),this._y=0);break;default:No("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(t,n,r){return xB.makeRotationFromQuaternion(t),this.setFromRotationMatrix(xB,n,r)}setFromVector3(t,n=this._order){return this.set(t.x,t.y,t.z,n)}reorder(t){return RB.setFromEuler(this),this.setFromQuaternion(RB,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],n=0){return t[n]=this._x,t[n+1]=this._y,t[n+2]=this._z,t[n+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};vi.DEFAULT_ORDER="XYZ";var Bg=class{addEventListener(t,n){this._listeners===void 0&&(this._listeners={});let r=this._listeners;r[t]===void 0&&(r[t]=[]),r[t].indexOf(n)===-1&&r[t].push(n)}hasEventListener(t,n){let r=this._listeners;return r===void 0?!1:r[t]!==void 0&&r[t].indexOf(n)!==-1}removeEventListener(t,n){let r=this._listeners;if(r===void 0)return;let i=r[t];if(i!==void 0){let o=i.indexOf(n);o!==-1&&i.splice(o,1)}}dispatchEvent(t){let n=this._listeners;if(n===void 0)return;let r=n[t.type];if(r!==void 0){t.target=this;let i=r.slice(0);for(let o=0,a=i.length;o<a;o++)i[o].call(this,t);t.target=null}}};var Gg=class{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}};var HI=class HI{constructor(t,n,r,i,o,a,s,c,d){this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,o,a,s,c,d)}set(t,n,r,i,o,a,s,c,d){let u=this.elements;return u[0]=t,u[1]=i,u[2]=s,u[3]=n,u[4]=o,u[5]=c,u[6]=r,u[7]=a,u[8]=d,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let n=this.elements,r=t.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(t,n,r){return t.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let n=t.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,n){let r=t.elements,i=n.elements,o=this.elements,a=r[0],s=r[3],c=r[6],d=r[1],u=r[4],p=r[7],m=r[2],f=r[5],h=r[8],g=i[0],y=i[3],_=i[6],S=i[1],T=i[4],C=i[7],I=i[2],x=i[5],R=i[8];return o[0]=a*g+s*S+c*I,o[3]=a*y+s*T+c*x,o[6]=a*_+s*C+c*R,o[1]=d*g+u*S+p*I,o[4]=d*y+u*T+p*x,o[7]=d*_+u*C+p*R,o[2]=m*g+f*S+h*I,o[5]=m*y+f*T+h*x,o[8]=m*_+f*C+h*R,this}multiplyScalar(t){let n=this.elements;return n[0]*=t,n[3]*=t,n[6]*=t,n[1]*=t,n[4]*=t,n[7]*=t,n[2]*=t,n[5]*=t,n[8]*=t,this}determinant(){let t=this.elements,n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],c=t[6],d=t[7],u=t[8];return n*a*u-n*s*d-r*o*u+r*s*c+i*o*d-i*a*c}invert(){let t=this.elements,n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],c=t[6],d=t[7],u=t[8],p=u*a-s*d,m=s*c-u*o,f=d*o-a*c,h=n*p+r*m+i*f;if(h===0)return this.set(0,0,0,0,0,0,0,0,0);let g=1/h;return t[0]=p*g,t[1]=(i*d-u*r)*g,t[2]=(s*r-i*a)*g,t[3]=m*g,t[4]=(u*n-i*c)*g,t[5]=(i*o-s*n)*g,t[6]=f*g,t[7]=(r*c-d*n)*g,t[8]=(a*n-r*o)*g,this}transpose(){let t,n=this.elements;return t=n[1],n[1]=n[3],n[3]=t,t=n[2],n[2]=n[6],n[6]=t,t=n[5],n[5]=n[7],n[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let n=this.elements;return t[0]=n[0],t[1]=n[3],t[2]=n[6],t[3]=n[1],t[4]=n[4],t[5]=n[7],t[6]=n[2],t[7]=n[5],t[8]=n[8],this}setUvTransform(t,n,r,i,o,a,s){let c=Math.cos(o),d=Math.sin(o);return this.set(r*c,r*d,-r*(c*a+d*s)+a+t,-i*d,i*c,-i*(-d*a+c*s)+s+n,0,0,1),this}scale(t,n){return this.premultiply(jI.makeScale(t,n)),this}rotate(t){return this.premultiply(jI.makeRotation(-t)),this}translate(t,n){return this.premultiply(jI.makeTranslation(t,n)),this}makeTranslation(t,n){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,n,0,0,1),this}makeRotation(t){let n=Math.cos(t),r=Math.sin(t);return this.set(n,-r,0,r,n,0,0,0,1),this}makeScale(t,n){return this.set(t,0,0,0,n,0,0,0,1),this}equals(t){let n=this.elements,r=t.elements;for(let i=0;i<9;i++)if(n[i]!==r[i])return!1;return!0}fromArray(t,n=0){for(let r=0;r<9;r++)this.elements[r]=t[r+n];return this}toArray(t=[],n=0){let r=this.elements;return t[n]=r[0],t[n+1]=r[1],t[n+2]=r[2],t[n+3]=r[3],t[n+4]=r[4],t[n+5]=r[5],t[n+6]=r[6],t[n+7]=r[7],t[n+8]=r[8],t}clone(){return new this.constructor().fromArray(this.elements)}};HI.prototype.isMatrix3=!0;var qp=HI,jI=new qp;var vue=0,PB=new k,qc=new tn,xi=new $t,zg=new k,Kp=new k,xue=new k,Rue=new tn,DB=new k(1,0,0),EB=new k(0,1,0),MB=new k(0,0,1),NB={type:"added"},Pue={type:"removed"},Kc={type:"childadded",child:null},$I={type:"childremoved",child:null},Lr=class e extends Bg{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:vue++}),this.uuid=Og(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new k,n=new vi,r=new tn,i=new k(1,1,1);function o(){r.setFromEuler(n,!1)}function a(){n.setFromQuaternion(r,void 0,!1)}n._onChange(o),r._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new $t},normalMatrix:{value:new qp}}),this.matrix=new $t,this.matrixWorld=new $t,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Gg,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,n){this.quaternion.setFromAxisAngle(t,n)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,n){return qc.setFromAxisAngle(t,n),this.quaternion.multiply(qc),this}rotateOnWorldAxis(t,n){return qc.setFromAxisAngle(t,n),this.quaternion.premultiply(qc),this}rotateX(t){return this.rotateOnAxis(DB,t)}rotateY(t){return this.rotateOnAxis(EB,t)}rotateZ(t){return this.rotateOnAxis(MB,t)}translateOnAxis(t,n){return PB.copy(t).applyQuaternion(this.quaternion),this.position.add(PB.multiplyScalar(n)),this}translateX(t){return this.translateOnAxis(DB,t)}translateY(t){return this.translateOnAxis(EB,t)}translateZ(t){return this.translateOnAxis(MB,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(xi.copy(this.matrixWorld).invert())}lookAt(t,n,r){t.isVector3?zg.copy(t):zg.set(t,n,r);let i=this.parent;this.updateWorldMatrix(!0,!1),Kp.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?xi.lookAt(Kp,zg,this.up):xi.lookAt(zg,Kp,this.up),this.quaternion.setFromRotationMatrix(xi),i&&(xi.extractRotation(i.matrixWorld),qc.setFromRotationMatrix(xi),this.quaternion.premultiply(qc.invert()))}add(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return t===this?(BI("Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(NB),Kc.child=t,this.dispatchEvent(Kc),Kc.child=null):BI("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.remove(arguments[r]);return this}let n=this.children.indexOf(t);return n!==-1&&(t.parent=null,this.children.splice(n,1),t.dispatchEvent(Pue),$I.child=t,this.dispatchEvent($I),$I.child=null),this}removeFromParent(){let t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),xi.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),xi.multiply(t.parent.matrixWorld)),t.applyMatrix4(xi),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(NB),Kc.child=t,this.dispatchEvent(Kc),Kc.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,n){if(this[t]===n)return this;for(let r=0,i=this.children.length;r<i;r++){let a=this.children[r].getObjectByProperty(t,n);if(a!==void 0)return a}}getObjectsByProperty(t,n,r=[]){this[t]===n&&r.push(this);let i=this.children;for(let o=0,a=i.length;o<a;o++)i[o].getObjectsByProperty(t,n,r);return r}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Kp,t,xue),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Kp,Rue,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let n=this.matrixWorld.elements;return t.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(t){t(this);let n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);let n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(t)}traverseAncestors(t){let n=this.parent;n!==null&&(t(n),n.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let t=this.pivot;if(t!==null){let n=t.x,r=t.y,i=t.z,o=this.matrix.elements;o[12]+=n-o[0]*n-o[4]*r-o[8]*i,o[13]+=r-o[1]*n-o[5]*r-o[9]*i,o[14]+=i-o[2]*n-o[6]*r-o[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);let n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].updateMatrixWorld(t)}updateWorldMatrix(t,n){let r=this.parent;if(t===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),n===!0){let i=this.children;for(let o=0,a=i.length;o<a;o++)i[o].updateWorldMatrix(!1,!0)}}toJSON(t){let n=t===void 0||typeof t=="string",r={};n&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),this.static!==!1&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null&&(i.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(s=>({...s,boundingBox:s.boundingBox?s.boundingBox.toJSON():void 0,boundingSphere:s.boundingSphere?s.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(s=>({...s})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function o(s,c){return s[c.uuid]===void 0&&(s[c.uuid]=c.toJSON(t)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=o(t.geometries,this.geometry);let s=this.geometry.parameters;if(s!==void 0&&s.shapes!==void 0){let c=s.shapes;if(Array.isArray(c))for(let d=0,u=c.length;d<u;d++){let p=c[d];o(t.shapes,p)}else o(t.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(o(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let s=[];for(let c=0,d=this.material.length;c<d;c++)s.push(o(t.materials,this.material[c]));i.material=s}else i.material=o(t.materials,this.material);if(this.children.length>0){i.children=[];for(let s=0;s<this.children.length;s++)i.children.push(this.children[s].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let s=0;s<this.animations.length;s++){let c=this.animations[s];i.animations.push(o(t.animations,c))}}if(n){let s=a(t.geometries),c=a(t.materials),d=a(t.textures),u=a(t.images),p=a(t.shapes),m=a(t.skeletons),f=a(t.animations),h=a(t.nodes);s.length>0&&(r.geometries=s),c.length>0&&(r.materials=c),d.length>0&&(r.textures=d),u.length>0&&(r.images=u),p.length>0&&(r.shapes=p),m.length>0&&(r.skeletons=m),f.length>0&&(r.animations=f),h.length>0&&(r.nodes=h)}return r.object=i,r;function a(s){let c=[];for(let d in s){let u=s[d];delete u.metadata,c.push(u)}return c}}clone(t){return new this.constructor().copy(this,t)}copy(t,n=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.pivot=t.pivot!==null?t.pivot.clone():null,this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),n===!0)for(let r=0;r<t.children.length;r++){let i=t.children[r];this.add(i.clone())}return this}};Lr.DEFAULT_UP=new k(0,1,0);Lr.DEFAULT_MATRIX_AUTO_UPDATE=!0;Lr.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Yc=class{constructor(t=new k(1/0,1/0,1/0),n=new k(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=n}set(t,n){return this.min.copy(t),this.max.copy(n),this}setFromArray(t){this.makeEmpty();for(let n=0,r=t.length;n<r;n+=3)this.expandByPoint(sr.fromArray(t,n));return this}setFromBufferAttribute(t){this.makeEmpty();for(let n=0,r=t.count;n<r;n++)this.expandByPoint(sr.fromBufferAttribute(t,n));return this}setFromPoints(t){this.makeEmpty();for(let n=0,r=t.length;n<r;n++)this.expandByPoint(t[n]);return this}setFromCenterAndSize(t,n){let r=sr.copy(n).multiplyScalar(.5);return this.min.copy(t).sub(r),this.max.copy(t).add(r),this}setFromObject(t,n=!1){return this.makeEmpty(),this.expandByObject(t,n)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,n=!1){t.updateWorldMatrix(!1,!1);let r=t.geometry;if(r!==void 0){let o=r.getAttribute("position");if(n===!0&&o!==void 0&&t.isInstancedMesh!==!0)for(let a=0,s=o.count;a<s;a++)t.isMesh===!0?t.getVertexPosition(a,sr):sr.fromBufferAttribute(o,a),sr.applyMatrix4(t.matrixWorld),this.expandByPoint(sr);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Ug.copy(t.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),Ug.copy(r.boundingBox)),Ug.applyMatrix4(t.matrixWorld),this.union(Ug)}let i=t.children;for(let o=0,a=i.length;o<a;o++)this.expandByObject(i[o],n);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,n){return n.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,sr),sr.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let n,r;return t.normal.x>0?(n=t.normal.x*this.min.x,r=t.normal.x*this.max.x):(n=t.normal.x*this.max.x,r=t.normal.x*this.min.x),t.normal.y>0?(n+=t.normal.y*this.min.y,r+=t.normal.y*this.max.y):(n+=t.normal.y*this.max.y,r+=t.normal.y*this.min.y),t.normal.z>0?(n+=t.normal.z*this.min.z,r+=t.normal.z*this.max.z):(n+=t.normal.z*this.max.z,r+=t.normal.z*this.min.z),n<=-t.constant&&r>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(jp),Vg.subVectors(this.max,jp),jc.subVectors(t.a,jp),Hc.subVectors(t.b,jp),$c.subVectors(t.c,jp),ko.subVectors(Hc,jc),Oo.subVectors($c,Hc),es.subVectors(jc,$c);let n=[0,-ko.z,ko.y,0,-Oo.z,Oo.y,0,-es.z,es.y,ko.z,0,-ko.x,Oo.z,0,-Oo.x,es.z,0,-es.x,-ko.y,ko.x,0,-Oo.y,Oo.x,0,-es.y,es.x,0];return!YI(n,jc,Hc,$c,Vg)||(n=[1,0,0,0,1,0,0,0,1],!YI(n,jc,Hc,$c,Vg))?!1:(qg.crossVectors(ko,Oo),n=[qg.x,qg.y,qg.z],YI(n,jc,Hc,$c,Vg))}clampPoint(t,n){return n.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,sr).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(sr).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Ri[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Ri[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Ri[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Ri[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Ri[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Ri[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Ri[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Ri[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Ri),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}},Ri=[new k,new k,new k,new k,new k,new k,new k,new k],sr=new k,Ug=new Yc,jc=new k,Hc=new k,$c=new k,ko=new k,Oo=new k,es=new k,jp=new k,Vg=new k,qg=new k,ts=new k;function YI(e,t,n,r,i){for(let o=0,a=e.length-3;o<=a;o+=3){ts.fromArray(e,o);let s=i.x*Math.abs(ts.x)+i.y*Math.abs(ts.y)+i.z*Math.abs(ts.z),c=t.dot(ts),d=n.dot(ts),u=r.dot(ts);if(Math.max(-Math.max(c,d,u),Math.min(c,d,u))>s)return!1}return!0}var XI=class XI{constructor(t=0,n=0){this.x=t,this.y=n}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,n){return this.x=t,this.y=n,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,n){switch(t){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,n){return this.x=t.x+n.x,this.y=t.y+n.y,this}addScaledVector(t,n){return this.x+=t.x*n,this.y+=t.y*n,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,n){return this.x=t.x-n.x,this.y=t.y-n.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let n=this.x,r=this.y,i=t.elements;return this.x=i[0]*n+i[3]*r+i[6],this.y=i[1]*n+i[4]*r+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,n){return this.x=xe(this.x,t.x,n.x),this.y=xe(this.y,t.y,n.y),this}clampScalar(t,n){return this.x=xe(this.x,t,n),this.y=xe(this.y,t,n),this}clampLength(t,n){let r=this.length();return this.divideScalar(r||1).multiplyScalar(xe(r,t,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){let n=Math.sqrt(this.lengthSq()*t.lengthSq());if(n===0)return Math.PI/2;let r=this.dot(t)/n;return Math.acos(xe(r,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let n=this.x-t.x,r=this.y-t.y;return n*n+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,n){return this.x+=(t.x-this.x)*n,this.y+=(t.y-this.y)*n,this}lerpVectors(t,n,r){return this.x=t.x+(n.x-t.x)*r,this.y=t.y+(n.y-t.y)*r,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,n=0){return this.x=t[n],this.y=t[n+1],this}toArray(t=[],n=0){return t[n]=this.x,t[n+1]=this.y,t}fromBufferAttribute(t,n){return this.x=t.getX(n),this.y=t.getY(n),this}rotateAround(t,n){let r=Math.cos(n),i=Math.sin(n),o=this.x-t.x,a=this.y-t.y;return this.x=o*r-a*i+t.x,this.y=o*i+a*r+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};XI.prototype.isVector2=!0;var Ke=XI;var nt=class{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){No("Curve: .getPoint() not implemented.")}getPointAt(t,n){let r=this.getUtoTmapping(t);return this.getPoint(r,n)}getPoints(t=5){let n=[];for(let r=0;r<=t;r++)n.push(this.getPoint(r/t));return n}getSpacedPoints(t=5){let n=[];for(let r=0;r<=t;r++)n.push(this.getPointAt(r/t));return n}getLength(){let t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let n=[],r,i=this.getPoint(0),o=0;n.push(0);for(let a=1;a<=t;a++)r=this.getPoint(a/t),o+=r.distanceTo(i),n.push(o),i=r;return this.cacheArcLengths=n,n}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,n=null){let r=this.getLengths(),i=0,o=r.length,a;n?a=n:a=t*r[o-1];let s=0,c=o-1,d;for(;s<=c;)if(i=Math.floor(s+(c-s)/2),d=r[i]-a,d<0)s=i+1;else if(d>0)c=i-1;else{c=i;break}if(i=c,r[i]===a)return i/(o-1);let u=r[i],m=r[i+1]-u,f=(a-u)/m;return(i+f)/(o-1)}getTangent(t,n){let i=t-1e-4,o=t+1e-4;i<0&&(i=0),o>1&&(o=1);let a=this.getPoint(i),s=this.getPoint(o),c=n||(a.isVector2?new Ke:new k);return c.copy(s).sub(a).normalize(),c}getTangentAt(t,n){let r=this.getUtoTmapping(t);return this.getTangent(r,n)}computeFrenetFrames(t,n=!1){let r=new k,i=[],o=[],a=[],s=new k,c=new $t;for(let f=0;f<=t;f++){let h=f/t;i[f]=this.getTangentAt(h,new k)}o[0]=new k,a[0]=new k;let d=Number.MAX_VALUE,u=Math.abs(i[0].x),p=Math.abs(i[0].y),m=Math.abs(i[0].z);u<=d&&(d=u,r.set(1,0,0)),p<=d&&(d=p,r.set(0,1,0)),m<=d&&r.set(0,0,1),s.crossVectors(i[0],r).normalize(),o[0].crossVectors(i[0],s),a[0].crossVectors(i[0],o[0]);for(let f=1;f<=t;f++){if(o[f]=o[f-1].clone(),a[f]=a[f-1].clone(),s.crossVectors(i[f-1],i[f]),s.length()>Number.EPSILON){s.normalize();let h=Math.acos(xe(i[f-1].dot(i[f]),-1,1));o[f].applyMatrix4(c.makeRotationAxis(s,h))}a[f].crossVectors(i[f],o[f])}if(n===!0){let f=Math.acos(xe(o[0].dot(o[t]),-1,1));f/=t,i[0].dot(s.crossVectors(o[0],o[t]))>0&&(f=-f);for(let h=1;h<=t;h++)o[h].applyMatrix4(c.makeRotationAxis(i[h],f*h)),a[h].crossVectors(i[h],o[h])}return{tangents:i,normals:o,binormals:a}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){let t={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}};var Jg={};X_(Jg,{ArcCurve:()=>Kg,CatmullRomCurve3:()=>Lo,CubicBezierCurve:()=>jg,CubicBezierCurve3:()=>Hg,EllipseCurve:()=>Xc,LineCurve:()=>$g,LineCurve3:()=>Pi,QuadraticBezierCurve:()=>Yg,QuadraticBezierCurve3:()=>Xg,SplineCurve:()=>Wg});var Xc=class extends nt{constructor(t=0,n=0,r=1,i=1,o=0,a=Math.PI*2,s=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=n,this.xRadius=r,this.yRadius=i,this.aStartAngle=o,this.aEndAngle=a,this.aClockwise=s,this.aRotation=c}getPoint(t,n=new Ke){let r=n,i=Math.PI*2,o=this.aEndAngle-this.aStartAngle,a=Math.abs(o)<Number.EPSILON;for(;o<0;)o+=i;for(;o>i;)o-=i;o<Number.EPSILON&&(a?o=0:o=i),this.aClockwise===!0&&!a&&(o===i?o=-i:o=o-i);let s=this.aStartAngle+t*o,c=this.aX+this.xRadius*Math.cos(s),d=this.aY+this.yRadius*Math.sin(s);if(this.aRotation!==0){let u=Math.cos(this.aRotation),p=Math.sin(this.aRotation),m=c-this.aX,f=d-this.aY;c=m*u-f*p+this.aX,d=m*p+f*u+this.aY}return r.set(c,d)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){let t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}};var Kg=class extends Xc{constructor(t,n,r,i,o,a){super(t,n,r,r,i,o,a),this.isArcCurve=!0,this.type="ArcCurve"}};function ZI(){let e=0,t=0,n=0,r=0;function i(o,a,s,c){e=o,t=s,n=-3*o+3*a-2*s-c,r=2*o-2*a+s+c}return{initCatmullRom:function(o,a,s,c,d){i(a,s,d*(s-o),d*(c-a))},initNonuniformCatmullRom:function(o,a,s,c,d,u,p){let m=(a-o)/d-(s-o)/(d+u)+(s-a)/u,f=(s-a)/u-(c-a)/(u+p)+(c-s)/p;m*=u,f*=u,i(a,s,m,f)},calc:function(o){let a=o*o,s=a*o;return e+t*o+n*a+r*s}}}var wB=new k,kB=new k,WI=new ZI,JI=new ZI,QI=new ZI,Lo=class extends nt{constructor(t=[],n=!1,r="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=n,this.curveType=r,this.tension=i}getPoint(t,n=new k){let r=n,i=this.points,o=i.length,a=(o-(this.closed?0:1))*t,s=Math.floor(a),c=a-s;this.closed?s+=s>0?0:(Math.floor(Math.abs(s)/o)+1)*o:c===0&&s===o-1&&(s=o-2,c=1);let d,u;this.closed||s>0?d=i[(s-1)%o]:(kB.subVectors(i[0],i[1]).add(i[0]),d=kB);let p=i[s%o],m=i[(s+1)%o];if(this.closed||s+2<o?u=i[(s+2)%o]:(wB.subVectors(i[o-1],i[o-2]).add(i[o-1]),u=wB),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,h=Math.pow(d.distanceToSquared(p),f),g=Math.pow(p.distanceToSquared(m),f),y=Math.pow(m.distanceToSquared(u),f);g<1e-4&&(g=1),h<1e-4&&(h=g),y<1e-4&&(y=g),WI.initNonuniformCatmullRom(d.x,p.x,m.x,u.x,h,g,y),JI.initNonuniformCatmullRom(d.y,p.y,m.y,u.y,h,g,y),QI.initNonuniformCatmullRom(d.z,p.z,m.z,u.z,h,g,y)}else this.curveType==="catmullrom"&&(WI.initCatmullRom(d.x,p.x,m.x,u.x,this.tension),JI.initCatmullRom(d.y,p.y,m.y,u.y,this.tension),QI.initCatmullRom(d.z,p.z,m.z,u.z,this.tension));return r.set(WI.calc(c),JI.calc(c),QI.calc(c)),r}copy(t){super.copy(t),this.points=[];for(let n=0,r=t.points.length;n<r;n++){let i=t.points[n];this.points.push(i.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){let t=super.toJSON();t.points=[];for(let n=0,r=this.points.length;n<r;n++){let i=this.points[n];t.points.push(i.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let n=0,r=t.points.length;n<r;n++){let i=t.points[n];this.points.push(new k().fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}};function ev(e,t,n,r,i){let o=(r-t)*.5,a=(i-n)*.5,s=e*e,c=e*s;return(2*n-2*r+o+a)*c+(-3*n+3*r-2*o-a)*s+o*e+n}function Due(e,t){let n=1-e;return n*n*t}function Eue(e,t){return 2*(1-e)*e*t}function Mue(e,t){return e*e*t}function ns(e,t,n,r){return Due(e,t)+Eue(e,n)+Mue(e,r)}function Nue(e,t){let n=1-e;return n*n*n*t}function wue(e,t){let n=1-e;return 3*n*n*e*t}function kue(e,t){return 3*(1-e)*e*e*t}function Oue(e,t){return e*e*e*t}function rs(e,t,n,r,i){return Nue(e,t)+wue(e,n)+kue(e,r)+Oue(e,i)}var jg=class extends nt{constructor(t=new Ke,n=new Ke,r=new Ke,i=new Ke){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=n,this.v2=r,this.v3=i}getPoint(t,n=new Ke){let r=n,i=this.v0,o=this.v1,a=this.v2,s=this.v3;return r.set(rs(t,i.x,o.x,a.x,s.x),rs(t,i.y,o.y,a.y,s.y)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}};var Hg=class extends nt{constructor(t=new k,n=new k,r=new k,i=new k){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=n,this.v2=r,this.v3=i}getPoint(t,n=new k){let r=n,i=this.v0,o=this.v1,a=this.v2,s=this.v3;return r.set(rs(t,i.x,o.x,a.x,s.x),rs(t,i.y,o.y,a.y,s.y),rs(t,i.z,o.z,a.z,s.z)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}};var $g=class extends nt{constructor(t=new Ke,n=new Ke){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=n}getPoint(t,n=new Ke){let r=n;return t===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(t).add(this.v1)),r}getPointAt(t,n){return this.getPoint(t,n)}getTangent(t,n=new Ke){return n.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,n){return this.getTangent(t,n)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}};var Pi=class extends nt{constructor(t=new k,n=new k){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=n}getPoint(t,n=new k){let r=n;return t===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(t).add(this.v1)),r}getPointAt(t,n){return this.getPoint(t,n)}getTangent(t,n=new k){return n.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,n){return this.getTangent(t,n)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}};var Yg=class extends nt{constructor(t=new Ke,n=new Ke,r=new Ke){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=n,this.v2=r}getPoint(t,n=new Ke){let r=n,i=this.v0,o=this.v1,a=this.v2;return r.set(ns(t,i.x,o.x,a.x),ns(t,i.y,o.y,a.y)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}};var Xg=class extends nt{constructor(t=new k,n=new k,r=new k){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=n,this.v2=r}getPoint(t,n=new k){let r=n,i=this.v0,o=this.v1,a=this.v2;return r.set(ns(t,i.x,o.x,a.x),ns(t,i.y,o.y,a.y),ns(t,i.z,o.z,a.z)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}};var Wg=class extends nt{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,n=new Ke){let r=n,i=this.points,o=(i.length-1)*t,a=Math.floor(o),s=o-a,c=i[a===0?a:a-1],d=i[a],u=i[a>i.length-2?i.length-1:a+1],p=i[a>i.length-3?i.length-1:a+2];return r.set(ev(s,c.x,d.x,u.x,p.x),ev(s,c.y,d.y,u.y,p.y)),r}copy(t){super.copy(t),this.points=[];for(let n=0,r=t.points.length;n<r;n++){let i=t.points[n];this.points.push(i.clone())}return this}toJSON(){let t=super.toJSON();t.points=[];for(let n=0,r=this.points.length;n<r;n++){let i=this.points[n];t.points.push(i.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let n=0,r=t.points.length;n<r;n++){let i=t.points[n];this.points.push(new Ke().fromArray(i))}return this}};var Wc=class extends nt{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){let t=this.curves[0].getPoint(0),n=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(n)){let r=t.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Jg[r](n,t))}return this}getPoint(t,n){let r=t*this.getLength(),i=this.getCurveLengths(),o=0;for(;o<i.length;){if(i[o]>=r){let a=i[o]-r,s=this.curves[o],c=s.getLength(),d=c===0?0:1-a/c;return s.getPointAt(d,n)}o++}return null}getLength(){let t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let t=[],n=0;for(let r=0,i=this.curves.length;r<i;r++)n+=this.curves[r].getLength(),t.push(n);return this.cacheLengths=t,t}getSpacedPoints(t=40){let n=[];for(let r=0;r<=t;r++)n.push(this.getPoint(r/t));return this.autoClose&&n.push(n[0]),n}getPoints(t=12){let n=[],r;for(let i=0,o=this.curves;i<o.length;i++){let a=o[i],s=a.isEllipseCurve?t*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?t*a.points.length:t,c=a.getPoints(s);for(let d=0;d<c.length;d++){let u=c[d];r&&r.equals(u)||(n.push(u),r=u)}}return this.autoClose&&n.length>1&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n}copy(t){super.copy(t),this.curves=[];for(let n=0,r=t.curves.length;n<r;n++){let i=t.curves[n];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this}toJSON(){let t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let n=0,r=this.curves.length;n<r;n++){let i=this.curves[n];t.curves.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let n=0,r=t.curves.length;n<r;n++){let i=t.curves[n];this.curves.push(new Jg[i.type]().fromJSON(i))}return this}};function OB(e,t){e.position.set(t.position.x,t.position.y,t.position.z),e.rotation.set(Uc(t.rotation.x),Uc(t.rotation.y),Uc(t.rotation.z)),e.scale.set(t.scale.x,t.scale.y,t.scale.z)}function Yt(e){return Math.round(e*1e3)/1e3}function LB(e){return{position:{x:Yt(e.position.x),y:Yt(e.position.y),z:Yt(e.position.z)},rotation:{x:Yt(Vn.radToDeg(e.rotation.x)),y:Yt(Vn.radToDeg(e.rotation.y)),z:Yt(Vn.radToDeg(e.rotation.z))},scale:{x:Yt(e.scale.x),y:Yt(e.scale.y),z:Yt(e.scale.z)}}}function $p(e){let t=new Lr;return OB(t,e),t}function FB(e){if(!e.length)return{x:0,y:0,z:0};let t=new Yc;if(e.forEach(r=>{let i=$p(r);t.expandByObject(i)}),t.isEmpty()){let r=e.reduce((o,a)=>({x:o.x+a.position.x,y:o.y+a.position.y,z:o.z+a.position.z}),{x:0,y:0,z:0}),i=e.length;return{x:Yt(r.x/i),y:Yt(r.y/i),z:Yt(r.z/i)}}let n=t.getCenter(new k);return{x:Yt(n.x),y:Yt(n.y),z:Yt(n.z)}}function tv(e,t){let n=$p(t);n.updateMatrixWorld(!0);let r=n.matrixWorld.clone().invert();return e.map(i=>{let o=$p(i);o.updateMatrixWorld(!0);let a=r.clone().multiply(o.matrixWorld),s=new Lr;return s.applyMatrix4(a),LB(s)})}function nv(e,t){let n=$p(t);return n.updateMatrixWorld(!0),e.map(r=>{let i=$p(r);i.updateMatrixWorld(!0);let o=n.matrixWorld.clone().multiply(i.matrixWorld),a=new Lr;return a.applyMatrix4(o),LB(a)})}var BB=["position","rotation","scale"],GB=["x","y","z"];function rv(e,t,n){var r,i;return((i=(r=e==null?void 0:e.transformLocks)==null?void 0:r[t])==null?void 0:i[n])===!0}function Qg(e){let t={};for(let n of BB){let r=e==null?void 0:e[n];if(!r)continue;let i={};for(let o of GB)r[o]===!0&&(i[o]=!0);Object.keys(i).length>0&&(t[n]=i)}return Object.keys(t).length>0?t:void 0}function zB(e,t,n){var i;let r={...e,[t]:{...e==null?void 0:e[t],[n]:((i=e==null?void 0:e[t])==null?void 0:i[n])===!0?void 0:!0}};return Qg(r)}function Yp(e,t){let n={};for(let r of BB){let i=t[r];if(!i)continue;let o={};for(let a of GB)i[a]===void 0||rv(e,r,a)||(o[a]=i[a]);Object.keys(o).length>0&&(n[r]=o)}return Object.keys(n).length>0?n:void 0}function Zg(e,t,n){let r=0,i=e.length;for(;r<i;){let o=Math.floor((r+i)/2);n(e[o])<t?r=o+1:i=o}return r}function Xp(e){let t=V(e);return{...t,animation:{...t.animation,fcurves:t.animation.fcurves,motionClips:t.animation.motionClips,motionTransitions:t.animation.motionTransitions}}}function ey(e){return e.type==="node"?`node:${e.nodeId}`:"environment"}function Jc(e,t){return e.type!==t.type?!1:e.type==="node"?e.nodeId===t.nodeId:!0}function Cn(e){return`${ey(e.target)}:${e.dataPath}:${e.arrayIndex}`}function UB(e){return{target:e.target,dataPath:e.dataPath,arrayIndex:KB(e.arrayIndex)}}function Lue(e){let t=UB(e);return{target:t.target,dataPath:t.dataPath,arrayIndex:t.arrayIndex}}function VB(e){let t=new Set;for(let n of(e==null?void 0:e.lockedChannels)??[])t.add(Cn(Lue(n)));return t}function is(e,t){return VB(e).has(Cn(UB(t)))}function cr(e,t){if(!t.length)return[];let n=VB(e);if(!n.size)return[...t];let r=new Set(t),i=new Set;for(let o of An(e))if(n.has(Cn(o)))for(let a of o.keyframes)r.has(a.id)&&i.add(a.id);return t.filter(o=>!i.has(o))}function Fue(e,t){return Jc(e.target,t.target)&&e.dataPath===t.dataPath&&e.arrayIndex===t.arrayIndex}function An(e){return(e==null?void 0:e.animation.fcurves)??[]}function ty(e,t){return An(e).find(n=>Fue(n,t))}function Bue(){return`kf_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function Gue(e){return{id:`fc_${Cn(e).replace(/[^a-zA-Z0-9]+/g,"_")}`,target:e.target,dataPath:e.dataPath,arrayIndex:e.arrayIndex,keyframes:[],extrapolationBefore:{type:"constant"},extrapolationAfter:{type:"constant"},enabled:!0}}function qB(e){return Number.isFinite(e)?Math.max(0,Math.round(e)):0}function zue(e){return Number.isFinite(e)?e:0}function KB(e){return Number.isFinite(e)?Math.max(0,Math.round(e)):0}function Uue(e,t){var r;let n=Zg(e,t,i=>i.frame);return((r=e[n])==null?void 0:r.frame)===t?n:-1}function Vue(e,t){var r;let n=Zg(e,t.frame,i=>i.frame);if(((r=e[n])==null?void 0:r.frame)===t.frame){e[n]=t;return}e.splice(n,0,t)}function que(e){let t=[...e];for(let n=1;n<t.length;n+=1)if(t[n].frame<t[n-1].frame)return t.sort((r,i)=>r.frame-i.frame);return t}function iv(e,t){let n=Xp(e);return n.animation.fcurves=n.animation.fcurves.filter(r=>!t(r)),n}function Qc(e,t){let n=Xp(e),r={target:t.target,dataPath:t.dataPath,arrayIndex:KB(t.arrayIndex)};if(is(n,r))return n;let i=qB(t.frame),o=ty(n,r),a=o??Gue(r),s=t.interpolation??"bezier",c=que(a.keyframes),d=Uue(c,i),u=d>=0?c[d]:void 0;Vue(c,{id:(u==null?void 0:u.id)??t.id??Bue(),frame:i,handleLeft:t.handleLeft,handleRight:t.handleRight,value:zue(t.value),interpolation:s});let p={...a,enabled:!0,keyframes:c};return n.animation.fcurves=o?n.animation.fcurves.map(m=>m.id===a.id?p:m):[...n.animation.fcurves,p],n}function jB(e,t){let n=Xp(e),r=new Set(cr(n,t));return r.size&&(n.animation.fcurves=n.animation.fcurves.map(i=>{let o=i.keyframes.filter(a=>!r.has(a.id));return o.length===i.keyframes.length?i:{...i,keyframes:o}}).filter(i=>i.keyframes.length>0)),n}function Wp(e,t,n){let r=Math.round(n);if(!e||!t.length||!r)return r;let i=new Set(cr(e,t));if(!i.size)return 0;let o=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY;for(let d of An(e))for(let u of d.keyframes)i.has(u.id)&&(o=Math.min(o,u.frame),a=Math.max(a,u.frame));if(!Number.isFinite(o)||!Number.isFinite(a))return r;let s=e.frameStart-o,c=e.frameEnd-a;return Math.min(Math.max(r,s),c)}function HB(e,t,n){let r=Xp(e),i=cr(r,t),o=Wp(r,i,n);if(!o)return r;let a=new Set(i);return r.animation.fcurves=r.animation.fcurves.map(s=>s.keyframes.some(c=>a.has(c.id))?{...s,enabled:!0,keyframes:Kue(s.keyframes.map(c=>a.has(c.id)?{...c,frame:c.frame+o}:c),a).sort((c,d)=>c.frame-d.frame)}:s),r}function Kue(e,t){let n=new Map;for(let i of e){let o=qB(i.frame),a=n.get(o)??[];a.push(i),n.set(o,a)}let r=[];for(let i of n.values()){if(i.length<=1){r.push(...i);continue}let o=i.filter(a=>t.has(a.id));r.push(...o.length?o:i)}return r}function $B(e,t,n){let r=Xp(e),i=new Set(cr(r,t));return i.size&&(r.animation.fcurves=r.animation.fcurves.map(o=>o.keyframes.some(a=>i.has(a.id))?{...o,keyframes:o.keyframes.map(a=>i.has(a.id)?{...a,interpolation:n}:a)}:o)),r}var jue=Object.freeze({x:0,y:1,z:0}),bdt=Object.freeze({x:1,y:0,z:0});var Ndt=Object.freeze({x:0,y:0,z:-1});var Xue=.1,Wue=4,Jue=1e-6;function YB(e,t){return(e%t+t)%t}function XB(e){return Number.isFinite(e)?Math.min(Math.max(e,Xue),Wue):1}function Jp(e,t={}){let n=Number.isFinite(e==null?void 0:e.baseDurationFrames)&&((e==null?void 0:e.baseDurationFrames)??0)>0?e==null?void 0:e.baseDurationFrames:t.baseDurationFrames,r=Number.isFinite(e==null?void 0:e.phaseOffset)&&((e==null?void 0:e.phaseOffset)??0)>0?e==null?void 0:e.phaseOffset:void 0;return{version:1,speed:XB((e==null?void 0:e.speed)??t.legacySpeed),loop:(e==null?void 0:e.loop)??t.legacyLoop??!1,loopMode:(e==null?void 0:e.loopMode)==="repeat"||(e==null?void 0:e.loopMode)==="ping-pong"?e.loopMode:t.defaultLoopMode??"repeat",...r!==void 0?{phaseOffset:r}:{},...Number.isFinite(n)&&(n??0)>0?{baseDurationFrames:n}:{}}}function Qp(e){let t=Number.isFinite(e.elapsedFrames)?Math.max(0,e.elapsedFrames):0,n=Number.isFinite(e.onePassFrames)&&e.onePassFrames>0?e.onePassFrames:Jue,r=XB(e.speed),o=(Number.isFinite(e.phaseOffset)&&(e.phaseOffset??0)>0?e.phaseOffset:0)+t*r/n;if(e.loopMode==="repeat")return{cycleIndex:Math.max(0,Math.floor(o)),direction:1,holding:!1,pass:o,progress:YB(o,1)};if(e.loopMode==="ping-pong"){let a=YB(o,2),s=a>1?-1:1;return{cycleIndex:Math.max(0,Math.floor(o)),direction:s,holding:!1,pass:o,progress:s===1?a:2-a}}return{cycleIndex:0,direction:1,holding:o>=1,pass:o,progress:Math.min(Math.max(o,0),1)}}function bt(e,t=0){return Number.isFinite(e)?Math.max(0,Math.round(e)):t}function av(e){return Math.max(1,Math.round(e.frameEnd-e.frameStart))}function Que(e,t){return e.frameStart===t.frameStart&&e.frameEnd===t.frameEnd}function WB(e,t){return e.frameStart<t.frameEnd&&t.frameStart<e.frameEnd}function Mt(e,t){var n;return((n=e.isAnchor)==null?void 0:n.call(e,t))===!0}function dr(e,t,n){let r=e,i=!0,o=t.slice().sort((a,s)=>a.frameStart!==s.frameStart?a.frameStart-s.frameStart:a.frameEnd-s.frameEnd);for(;i;){i=!1;for(let a of o)if(WB(r,a)){if(n==="clamp"){if(r.frameStart<a.frameStart)r={frameEnd:Math.max(r.frameStart+1,a.frameStart),frameStart:r.frameStart};else{let s=Math.min(Math.max(a.frameEnd,r.frameStart),r.frameEnd-1);r={frameEnd:r.frameEnd,frameStart:s}}if(i=WB(r,a),!i)continue}r=Fr(r,a.frameEnd),i=!0;break}}return r}function Zue(e,t,n){let r=Math.max(bt(n),bt(e.frameStart,n));return{frameEnd:r+Math.max(1,bt(t,1)),frameStart:r}}function Fr(e,t){let n=av(e);return{frameEnd:t+n,frameStart:t}}function sv(e,t){let n=Number.isFinite(t)?Math.round(t):0;return{frameEnd:e.frameEnd+n,frameStart:e.frameStart+n}}function qn(e,t){return e.slice().sort((n,r)=>{let i=t.getFrameRange(n),o=t.getFrameRange(r);return i.frameStart!==o.frameStart?i.frameStart-o.frameStart:i.frameEnd!==o.frameEnd?i.frameEnd-o.frameEnd:t.getId(n).localeCompare(t.getId(r))})}function In(e,t,n){return e.map(r=>{var o;let i=t.getFrameRange(r);return{currentRange:i,id:t.getId(r),item:r,range:Zue(i,((o=t.getDuration)==null?void 0:o.call(t,r))??av(i),n)}})}function Ct(e){var c;let t=!!((c=e.removedItemIds)!=null&&c.length),n=Object.fromEntries(e.entries.flatMap(d=>{let u=e.frameRangesByItemId[d.id];return u?[[d.id,Mt(e.adapter,d.item)?d.currentRange:u]]:[]})),i=e.entries.flatMap(d=>{let u=n[d.id];return u?[{item:e.adapter.withFrameRange(d.item,u),range:u}]:[]}).sort((d,u)=>d.range.frameStart!==u.range.frameStart?d.range.frameStart-u.range.frameStart:d.range.frameEnd!==u.range.frameEnd?d.range.frameEnd-u.range.frameEnd:e.adapter.getId(d.item).localeCompare(e.adapter.getId(u.item))).map(d=>d.item),o=e.entries.map(d=>d.id),a=i.map(d=>e.adapter.getId(d)),s=o.length!==a.length||o.some((d,u)=>d!==a[u]);return e.entries.forEach(d=>{let u=n[d.id];u&&!Que(d.currentRange,u)&&(t=!0)}),{changed:t||s,frameRangesByItemId:n,insertIndex:e.insertIndex??0,orderChanged:s,orderedItems:i,removedItemIds:[...e.removedItemIds??[]]}}function Di({adapter:e,orderedItems:t,timelineFrameStart:n}){let r=In(t,e,n),i=Object.fromEntries(r.map(o=>[o.id,o.range]));return Ct({adapter:e,entries:r,frameRangesByItemId:i})}function ny({adapter:e,items:t,referenceFrame:n,timelineFrameStart:r}){let i=Math.max(bt(r),bt(n,r)),o=qn(t,e).map(a=>e.getFrameRange(a)).filter(a=>i>=a.frameStart&&i<a.frameEnd);return o.length?Math.max(bt(r),...o.map(a=>bt(a.frameEnd,i))):i}function Zp({adapter:e,insertedItemId:t,insertIndex:n,orderedItems:r,timelineFrameStart:i}){let o=In(r,e,i),a=o.find(h=>h.id===t);if(!a)return Di({adapter:e,orderedItems:r,timelineFrameStart:i});let s=o.filter(h=>h.id!==t),c=s.findIndex(h=>h.range.frameStart>=a.range.frameStart),d=n!==void 0?Math.min(Math.max(Math.round(n),0),s.length):c<0?s.length:c,u=[...s.slice(0,d),a,...s.slice(d)];if(o.some(h=>Mt(e,h.item))){let h=o.filter(T=>Mt(e,T.item)).map(T=>T.currentRange),g=[],y={},_=bt(i),S=!1;return u.forEach(T=>{if(Mt(e,T.item)){y[T.id]=T.currentRange,_=Math.max(_,T.currentRange.frameEnd);return}let{range:C}=T;(S||T.id===t)&&(C=Fr(C,Math.max(C.frameStart,_)),C=dr(C,[...h,...g],"push"),S=!0),y[T.id]=C,g.push(C),_=Math.max(_,C.frameEnd)}),Ct({adapter:e,entries:u,frameRangesByItemId:y,insertIndex:d})}let p={},m=bt(i),f=!1;return u.forEach(h=>{let{range:g}=h;if(f||h.id===t){let y=Math.max(g.frameStart,m);g=y===g.frameStart?g:Fr(g,y),f=!0}p[h.id]=g,m=Math.max(m,g.frameEnd)}),Ct({adapter:e,entries:u,frameRangesByItemId:p,insertIndex:d})}function os({adapter:e,collisionMode:t="push",insertIndex:n,orderedItems:r,placedItemIds:i,timelineFrameStart:o}){let a=In(r,e,o),s=new Set(i),c=a.filter(f=>!s.has(f.id)),d=c.map(f=>f.range),u=a.filter(f=>s.has(f.id)).sort((f,h)=>f.range.frameStart!==h.range.frameStart?f.range.frameStart-h.range.frameStart:f.range.frameEnd-h.range.frameEnd),p=[],m={};return c.forEach(f=>{m[f.id]=f.range}),u.forEach(f=>{let h=dr(f.range,[...d,...p],t);m[f.id]=h,p.push(h)}),Ct({adapter:e,entries:a,frameRangesByItemId:m,insertIndex:n})}function ry({trimmedItemId:e,...t}){return os({...t,collisionMode:"clamp",placedItemIds:[e]})}function epe(e,t,n){let r=Math.max(bt(n),bt(e.frameStart,t.frameStart));return{frameEnd:Math.max(r+1,bt(e.frameEnd,t.frameEnd)),frameStart:r}}function iy({adapter:e,currentFrameRangesByItemId:t,orderedItems:n,resizedItemId:r,resizedRange:i,timelineFrameStart:o}){let a=In(n,e,o),s=a.find(f=>f.id===r);if(!s){let f=Object.fromEntries(a.map(h=>[h.id,h.range]));return Ct({adapter:e,entries:a,frameRangesByItemId:f})}let c=(t==null?void 0:t[r])??s.currentRange,d=epe(i,c,o);if(a.some(f=>Mt(e,f.item))){let f=a.filter(T=>Mt(e,T.item)).map(T=>T.currentRange),h=dr(d,f,"clamp"),g=h.frameEnd-c.frameEnd,y=a.findIndex(T=>T.id===r),_=[],S={};return a.forEach((T,C)=>{if(Mt(e,T.item)){S[T.id]=T.currentRange;return}let I=T.id===r?h:T.range;C>y&&(I=sv(I,g),I=dr(I,[...f,..._],"push")),S[T.id]=I,_.push(I)}),Ct({adapter:e,entries:a,frameRangesByItemId:S,insertIndex:Math.max(0,y)})}let u=d.frameEnd-c.frameEnd,p=a.findIndex(f=>f.id===r),m={};return a.forEach((f,h)=>{if(f.id===r){m[f.id]=d;return}m[f.id]=h>p?sv(f.range,u):f.range}),Ct({adapter:e,entries:a,frameRangesByItemId:m,insertIndex:Math.max(0,p)})}function JB(e,t){let n=bt(t);return e.length?Math.max(n,Math.min(...e.map(r=>r.currentRange.frameStart))):n}function tpe({adapter:e,insertIndex:t,itemId:n,items:r,timelineFrameStart:i}){let o=qn(r,e),a=In(o,e,i),s=a.find(f=>f.id===n);if(!s)return;let c=a.filter(f=>f.id!==n),d=Math.min(Math.max(Math.round(t),0),c.length),u=[...c.slice(0,d),s,...c.slice(d)];if(a.some(f=>Mt(e,f.item))){let f=a.filter(_=>Mt(e,_.item)).map(_=>_.currentRange),h=[],g={},y=JB(a,i);return u.forEach(_=>{if(Mt(e,_.item)){g[_.id]=_.currentRange,y=Math.max(y,_.currentRange.frameEnd);return}let S=dr(Fr(_.range,y),[...f,...h],"push");g[_.id]=S,h.push(S),y=S.frameEnd}),Ct({adapter:e,entries:a,frameRangesByItemId:g,insertIndex:d})}let p={},m=JB(a,i);return u.forEach(f=>{let h=Fr(f.range,m);p[f.id]=h,m=h.frameEnd}),Ct({adapter:e,entries:a,frameRangesByItemId:p,insertIndex:d})}var oy=tpe;function QB({adapter:e,orderedItems:t,timelineFrameStart:n}){let r=qn(t,e),i=In(r,e,n);if(i.some(s=>Mt(e,s.item))){let s=i.filter(u=>Mt(e,u.item)).map(u=>u.currentRange),c=[],d={};return i.forEach(u=>{if(Mt(e,u.item)){d[u.id]=u.currentRange;return}let p=dr(u.range,[...s,...c],"push");d[u.id]=p,c.push(p)}),Ct({adapter:e,entries:i,frameRangesByItemId:d})}let o={},a=bt(n);return i.forEach(s=>{let c=Math.max(s.range.frameStart,a),d=c===s.range.frameStart?s.range:Fr(s.range,c);o[s.id]=d,a=Math.max(a,d.frameEnd)}),Ct({adapter:e,entries:i,frameRangesByItemId:o})}function nG(e,t=0){return Number.isFinite(e)?Math.max(0,Math.round(e)):t}function cv(e,t){return e.type!==t.type?!1:e.type==="node"&&t.type==="node"?e.nodeId===t.nodeId:!0}function el(e){return e.type==="node"?`node:${e.nodeId}`:e.type}function rG(e){return Math.max(1,Math.round(e.frameEnd-e.frameStart))}function npe(e){return rG(e)}function rpe(e){return rG(e)}function iG(e){let t=e.kind==="camera-motion-clip"?e.cameraMotionClip:e.cameraMotionTransition;return{frameEnd:t.frameEnd,frameStart:t.frameStart}}function ipe(e){return e.kind==="camera-motion-clip"?npe(e.cameraMotionClip):rpe(e.cameraMotionTransition)}function ope(e,t){let n=nG(t);return n>=e.frameStart&&n<e.frameEnd}var oG={getDuration:ipe,getFrameRange:iG,getId:e=>e.id,withFrameRange:(e,t)=>e.kind==="camera-motion-clip"?{id:e.id,kind:"camera-motion-clip",cameraMotionClip:{...e.cameraMotionClip,...t}}:{id:e.id,kind:"camera-motion-transition",cameraMotionTransition:{...e.cameraMotionTransition,...t}}};function Ei(e){return V(e).animation.cameraMotionClips??[]}function Fo(e){return V(e).animation.cameraMotionTransitions??[]}function ape(e,t,n){let i=aG(e,typeof t=="string"?{type:"node",nodeId:t}:t).find(o=>ope(iG(o),n));if(i)return i.kind==="camera-motion-clip"?{cameraMotionClip:i.cameraMotionClip,id:i.id,kind:i.kind}:{cameraMotionTransition:i.cameraMotionTransition,id:i.id,kind:i.kind}}function ed(e,t){return t.target.type!=="node"?!1:!!ape(e,t.target,t.frame)}function aG(e,t){return qn([...Ei(e).filter(n=>cv(n.target,t)).map(n=>({cameraMotionClip:n,id:n.id,kind:"camera-motion-clip"})),...Fo(e).filter(n=>cv(n.target,t)).map(n=>({cameraMotionTransition:n,id:n.id,kind:"camera-motion-transition"}))],oG)}function spe(e){return{changed:e.changed,frameRangesByItemId:e.frameRangesByItemId,insertIndex:e.insertIndex,orderChanged:e.orderChanged,orderedItems:e.orderedItems,removedCameraMotionTransitionIds:e.removedItemIds}}function cpe(e,t){let n=V(e);return spe(Di({adapter:oG,orderedItems:t,timelineFrameStart:n.frameStart}))}function dpe(e,t,n){let r=V(e),i=el(t),o=n.orderedItems.filter(c=>c.kind==="camera-motion-clip").map(c=>c.cameraMotionClip),a=n.orderedItems.filter(c=>c.kind==="camera-motion-transition").map(c=>c.cameraMotionTransition),s=[...o,...a].reduce((c,d)=>Math.max(c,nG(d.frameEnd)),r.frameEnd);return{...r,frameEnd:s,animation:{...r.animation,cameraMotionClips:[...Ei(r).filter(c=>el(c.target)!==i),...o].sort((c,d)=>c.frameStart-d.frameStart||c.frameEnd-d.frameEnd),cameraMotionTransitions:[...Fo(r).filter(c=>el(c.target)!==i),...a].sort((c,d)=>c.frameStart-d.frameStart||c.frameEnd-d.frameEnd)}}}function sG(e,t){let n=V(e);if(!t.length)return n;let r=new Set(t),i=new Set(Ei(n).filter(p=>r.has(p.id)).map(p=>el(p.target))),o=Ei(n),a=o.filter(p=>!r.has(p.id)),s=(p,m)=>{var g,y;if(!r.has(p))return p;let f=o.find(_=>_.id===p);if(!f)return;let h=a.filter(_=>cv(_.target,f.target)).sort((_,S)=>_.frameStart-S.frameStart||_.frameEnd-S.frameEnd);return m==="from"?(g=h.filter(_=>_.frameEnd<=f.frameStart).at(-1))==null?void 0:g.id:(y=h.find(_=>_.frameStart>=f.frameEnd))==null?void 0:y.id},c=Fo(n).flatMap(p=>{let m=s(p.fromClipId,"from"),f=s(p.toClipId,"to");return!m||!f||m===f?[]:[{...p,fromClipId:m,toClipId:f}]}),d={...n.animation,cameraMotionClips:a,cameraMotionTransitions:c},u=V({...n,animation:d});for(let p of i){let m=Ei(n).find(f=>el(f.target)===p);if(m){let f=cpe(u,aG(u,m.target));u=dpe(u,m.target,f)}}return u}function cG(e,t){let n=V(e);if(!t.length)return n;let r=new Set(t);return{...n,animation:{...n.animation,cameraMotionTransitions:Fo(n).filter(i=>!r.has(i.id))}}}var Bo=1e-4,upe=200;function td(e,t,n){return Math.min(Math.max(e,t),n)}function dv(e){return new k(e.x,e.y,e.z)}function ay(e){return{x:e.x,y:e.y,z:e.z}}function uv(e){let t=new k(e.position.x,e.position.y,e.position.z),n=new vi(Vn.degToRad(e.rotation.x),Vn.degToRad(e.rotation.y),Vn.degToRad(e.rotation.z),"XYZ"),r=new k(e.scale.x,e.scale.y,e.scale.z);return new $t().compose(t,new tn().setFromEuler(n),r)}function dG(e){return e.lengthSq()>Bo*Bo?e.normalize():new k(0,0,1)}function ppe(e,t){let n=new Wc;for(let r=0;r<e.length-1;r+=1)n.add(new Pi(e[r].clone(),e[r+1].clone()));return t&&e.length>1&&n.add(new Pi(e[e.length-1].clone(),e[0].clone())),n}function lpe(e){let t=e.points.map(dv).filter(r=>Number.isFinite(r.x)&&Number.isFinite(r.y)&&Number.isFinite(r.z));if(t.length<2)return;if(e.transform){let r=uv(e.transform);t.forEach(i=>i.applyMatrix4(r))}let n=e.closed===!0;return e.curve!=="catmullRom"||t.length<3?ppe(t,n):new Lo(t,n,"centripetal",e.smoothing??.5)}var Br=class e{constructor(t,n){this.curve=t;var r;if(this.curve.arcLengthDivisions=upe,this.curve.updateArcLengths(),this.length=this.curve.getLength(),(n==null?void 0:n.parameterization)==="time-ratio"&&((r=n.timeRatios)==null?void 0:r.length)===n.points.length){let i=n.points.map(dv);if(n.transform){let c=uv(n.transform);i.forEach(d=>d.applyMatrix4(c))}let o=0,a=i.map((c,d)=>{var u;return d>0&&(o+=c.distanceTo(i[d-1])),{distance:o,point:c,timeRatio:td(((u=n.timeRatios)==null?void 0:u[d])??d/Math.max(1,i.length-1),0,1)}});a.every((c,d)=>d===0||c.timeRatio>=a[d-1].timeRatio)&&a.length>=2&&(this.timeSamples=a)}}static fromDescriptor(t){let n=lpe(t);return n?new e(n,t):void 0}static fromPathNode(t,n={}){return e.fromDescriptor({closed:t.path.closed,curve:t.path.curve,parameterization:t.path.parameterization,points:t.path.points.map(r=>r.position),smoothing:t.path.smoothing,transform:n.space==="world"?t.transform:void 0,timeRatios:t.path.points.map(r=>r.timeRatio)})}static getPathNodePoints(t,n={}){let r=t.path.points.map(o=>dv(o.position));if(n.space!=="world")return r;let i=uv(t.transform);return r.map(o=>o.applyMatrix4(i))}getLength(){return this.length}getPointAt(t){return this.curve.getPointAt(td(t,0,1)).clone()}getSpacedPoints(t){let n=Math.max(0,Math.round(t));return n<=0?[]:n===1?[this.getPointAt(0)]:this.curve.getSpacedPoints(n-1).map(r=>r.clone())}getTangentAt(t){return dG(this.curve.getTangentAt(td(t,0,1)).clone())}sampleAtDistance(t,n={}){if(this.length<=Bo)return;let r=n.loop===!0?(t%this.length+this.length)%this.length:td(t,0,this.length);return this.sampleAtProgress(r/this.length)}sampleAtProgress(t){if(this.length<=Bo)return;let n=td(t,0,1);if(this.timeSamples){let o=this.timeSamples,a=0,s=o.length-1;for(;a<s;){let g=Math.floor((a+s)/2);o[g].timeRatio<n?a=g+1:s=g}s===0&&(s=1);let c=o[s-1],d=o[s],u=d.timeRatio-c.timeRatio,p=u>1e-8?td((n-c.timeRatio)/u,0,1):1,m=c.point.clone().lerp(d.point,p),f=d.point.clone().sub(c.point);if(f.lengthSq()<=Bo*Bo)for(let g=1;g<o.length;g+=1){let y=o[Math.max(0,s-g)];if(f=o[Math.min(o.length-1,s+g)].point.clone().sub(y.point),f.lengthSq()>Bo*Bo)break}return{distance:c.distance+(d.distance-c.distance)*p,length:this.length,position:ay(m),progress:n,tangent:ay(dG(f))}}let r=this.getPointAt(n),i=this.getTangentAt(n);return{distance:n*this.length,length:this.length,position:ay(r),progress:n,tangent:ay(i)}}};var mpe=90,fpe=18,hpe=2,gpe=72,ype={"+z":0,"-z":180,"+x":-90,"-x":90};function pG(e,t,n){return Math.min(Math.max(e,t),n)}function uG(e,t=0){return Number.isFinite(e)?Math.max(0,Math.round(e)):t}function _pe(e){return Math.max(1,Math.round(e??mpe))}function Tpe(e){return pG(Math.round(e??fpe),hpe,gpe)}function Spe(e){return Math.atan2(e.x,e.z)*180/Math.PI}function bpe(e){let t=e;for(;t>180;)t-=360;for(;t<=-180;)t+=360;return t}function Cpe(e,t){return t===void 0?e:t+bpe(e-t)}function Ape(e){return{x:0,y:e,z:0}}var sy=class e{constructor(t){this.durationFrames=_pe(t.durationFrames),this.facing=t.facing??"path-tangent",this.fixedYawDegrees=Number.isFinite(t.fixedYawDegrees)?t.fixedYawDegrees??0:0,this.frameStart=uG(t.frameStart??0),this.modelForwardAxis=t.modelForwardAxis??"+z",this.path=t.path,this.yawOffsetDegrees=Number.isFinite(t.yawOffsetDegrees)?t.yawOffsetDegrees??0:0}static fromPathNode(t,n={}){let r=Br.fromPathNode(t,{space:"world"});return r?new e({...n,path:r}):void 0}getDurationFrames(){return this.durationFrames}getFrameRange(){return{frameStart:this.frameStart,frameEnd:this.frameStart+this.durationFrames}}sampleFrame(t){let n=uG(t,this.frameStart),r=pG((n-this.frameStart)/this.durationFrames,0,1);return this.createSample(n,r)}sampleRange(t={}){let n=Tpe(t.sampleCount),r=t.unwrapYaw!==!1,i;return Array.from({length:n},(o,a)=>{let s=n<=1?0:a/(n-1),c=this.frameStart+Math.round(this.durationFrames*s),d=this.createSample(c,s,r?i:void 0);return d&&(i=d.yawDegrees),d}).filter(o=>!!o)}createSample(t,n,r){let i=this.path.sampleAtProgress(n);if(!i)return;let o=this.facing==="path-tangent"?Spe(i.tangent):this.fixedYawDegrees,a=Cpe(o+ype[this.modelForwardAxis]+this.yawOffsetDegrees,r);return{...i,frame:t,rotation:Ape(a),yawDegrees:a}}};var Ipe=30,lG=new WeakMap;function cy(e,t){let n=Number.isFinite(e)?e:t;return Math.min(Math.max(n,0),100)}function as(e){return`${e.x},${e.y},${e.z}`}function vpe(e){var i;let t=(i=e.metadata)==null?void 0:i.derivedPathMotionSourceSignature;if(e.path.source!=="transform-keyframes"||typeof t!="string"||!t)return;let{path:n,transform:r}=e;return["derived",t,n.curve,n.parameterization??"",n.closed?"closed":"open",n.smoothing??"",n.points.length,as(r.position),as(r.rotation),as(r.scale)].join("|")}function xpe(e){let{path:t,transform:n}=e;return[t.source,t.curve,t.parameterization??"",t.closed?"closed":"open",t.smoothing??"",as(n.position),as(n.rotation),as(n.scale),t.points.map(r=>`${as(r.position)}@${r.timeRatio??""}`).join(";")].join("|")}function Rpe(e){let t=vpe(e)??xpe(e),n=lG.get(e);if((n==null?void 0:n.key)===t)return n.path;let r=Br.fromPathNode(e,{space:"world"});return lG.set(e,{key:t,path:r}),r}function Ppe(e){let t=e;for(;t>180;)t-=360;for(;t<=-180;)t+=360;return t}function Dpe(e){return Math.atan2(e.x,e.z)*180/Math.PI}function Epe(e,t,n,r){let i=Math.min(Math.max(Math.ceil(n*Math.max(1,t.frameEnd-t.frameStart))+1,2),72),o;for(let a=0;a<i;a+=1){let s=a===i-1?n:n*a/Math.max(1,i-1),c=e.sampleAtProgress(tl(t,s));if(!c)continue;let d=Dpe(yG(c.tangent,t.direction,r));o=o===void 0?d:o+Ppe(d-o)}return o}function mv(e,t){let n=nl(e),r=fG(e),i=Math.max(1e-6,(n.baseDurationFrames??Math.max(1,e.frameEnd-e.frameStart))*r);return Qp({elapsedFrames:Math.max(0,t-e.frameStart),loopMode:n.loop?n.loopMode:"none",onePassFrames:i,phaseOffset:n.phaseOffset,speed:n.speed})}function tl(e,t){let n=cy(e.pathStartPercent,0)/100,r=cy(e.pathEndPercent,100)/100,i=(e.direction??"forward")==="reverse"?r+(n-r)*t:n+(r-n)*t;return Math.min(Math.max(i,0),1)}function fG(e){let t=cy(e.pathStartPercent,0)/100,n=cy(e.pathEndPercent,100)/100;return Math.max(1e-6,Math.abs(n-t))}function nl(e){let t=fG(e);return Jp(e.playback,{baseDurationFrames:Math.max(1,e.frameEnd-e.frameStart)/t,defaultLoopMode:"ping-pong"})}function hG(e,t,n){return e.sampleAtProgress(tl(t,n.progress))}function pv(e){let{endSample:t,pathSample:n,playback:r,playbackSample:i,startSample:o}=e,a=Math.abs(t.distance-o.distance);if(!r.loop)return Math.abs(n.distance-o.distance);let s=Math.max(0,i.pass),c=Math.floor(s),d=r.loopMode==="ping-pong"&&c%2===1,u=Math.abs(d?t.distance-n.distance:n.distance-o.distance);return c*a+u}function Mpe(e){let t=mv(e.clip,e.frame),n=hG(e.path,e.clip,t);if(n)return Math.max(0,pv({endSample:e.endSample,pathSample:n,playback:e.playback,playbackSample:t,startSample:e.startSample})-e.baselineDistance)}function gG(e){let{clip:t,currentPathSample:n,currentPlaybackSample:r,frame:i,path:o}=e,a=Number.isFinite(e.fps)&&e.fps&&e.fps>0?e.fps:Ipe,s=nl(t),c=mv(t,t.frameStart),d=o.sampleAtProgress(tl(t,0))??n,u=o.sampleAtProgress(tl(t,1))??n,p=hG(o,t,c)??d,m=pv({endSample:u,pathSample:p,playback:s,playbackSample:c,startSample:d}),f=Math.max(0,pv({endSample:u,pathSample:n,playback:s,playbackSample:r,startSample:d})-m),h=i>t.frameStart?i-1:Math.min(i+1,t.frameEnd),g=Mpe({baselineDistance:m,clip:t,endSample:u,frame:h,path:o,playback:s,startSample:d}),y=Math.abs(i-h)/a,_=g===void 0||y<=0?0:Math.abs(f-g)/y;return{distanceFromClipStart:f,speed:_}}function yG(e,t,n=1){return t==="reverse"!=(n===-1)?{x:-e.x,y:-e.y,z:-e.z}:e}function fv(e,t,n,r={}){if(!e||t.status==="path-missing")return;let i=Rpe(e);if(!i)return;let o=nl(t),a=mv(t,n),s=a.progress,c=tl(t,s),d=i.sampleAtProgress(c);if(!d)return;let u=gG({clip:t,currentPathSample:d,currentPlaybackSample:a,fps:r.fps,frame:n,path:i}),p=yG(d.tangent,t.direction,a.direction);return{clipId:t.id,distanceFromClipStart:u.distanceFromClipStart,frameEnd:t.frameEnd,frameStart:t.frameStart,pathDistance:d.distance,pathLength:d.length,position:d.position,progress:c,rotation:(t.facing??"path-tangent")==="path-tangent"?{x:0,y:Epe(i,t,s,a.direction)??0,z:0}:void 0,speed:u.speed,tangent:p}}var kpe=90,_G=new WeakMap;function Ope(e,t=0){return Number.isFinite(e)?Math.max(0,Math.round(e)):t}function dy(e){return`${e.x},${e.y},${e.z}`}function Lpe(e){let{path:t,transform:n}=e;return[t.curve,t.closed?"closed":"open",t.smoothing??"",dy(n.position),dy(n.rotation),dy(n.scale),t.points.map(r=>dy(r.position)).join(";")].join("|")}function Fpe(e){let t=Lpe(e),n=_G.get(e);if((n==null?void 0:n.key)===t)return n.path;let r=Br.fromPathNode(e,{space:"world"});return _G.set(e,{key:t,path:r}),r}function TG(e,t){return e.type!==t.type?!1:e.type==="node"&&t.type==="node"?e.nodeId===t.nodeId:!0}function Mi(e){return e.type==="node"?`node:${e.nodeId}`:e.type}function Bpe(e){return Math.max(1,Math.round(e.frameEnd-e.frameStart))}function hv(e){let t=e.kind==="path-motion-clip"?e.pathMotionClip:e.pathMotionTransition;return{frameEnd:t.frameEnd,frameStart:t.frameStart}}function Gpe(e){return Bpe(hv(e))}function rl(e,t){return qn([...nn(e).filter(n=>TG(n.target,t)).map(n=>({id:n.id,kind:"path-motion-clip",pathMotionClip:n})),...Ni(e).filter(n=>TG(n.target,t)).map(n=>({id:n.id,kind:"path-motion-transition",pathMotionTransition:n}))],rd)}var rd={getDuration:Gpe,getFrameRange:hv,getId:e=>e.id,isAnchor:e=>e.kind==="path-motion-clip"&&nd(e.pathMotionClip),withFrameRange:(e,t)=>e.kind==="path-motion-clip"?nd(e.pathMotionClip)?e:{id:e.id,kind:"path-motion-clip",pathMotionClip:{...e.pathMotionClip,...t}}:{id:e.id,kind:"path-motion-transition",pathMotionTransition:{...e.pathMotionTransition,...t}}};function zpe(){return`path_motion_clip_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function nn(e){return V(e).animation.pathMotionClips??[]}function nd(e){return e.source==="transform-keyframes"}function Ni(e){return V(e).animation.pathMotionTransitions??[]}function SG(e,t){return nn(e).find(n=>n.id===t)}function gv(e,t,n=0){let r=V(e);return ny({adapter:rd,items:rl(r,t),referenceFrame:n,timelineFrameStart:r.frameStart})}function uy(e){return{changed:e.changed,frameRangesByItemId:e.frameRangesByItemId,insertIndex:e.insertIndex,orderChanged:e.orderChanged,orderedItems:e.orderedItems,removedPathMotionTransitionIds:e.removedItemIds}}function bG(e,t){let n=V(e);return uy(Di({adapter:rd,orderedItems:t,timelineFrameStart:n.frameStart}))}function Upe(e,t){let n=V(e);return uy(QB({adapter:rd,orderedItems:t,timelineFrameStart:n.frameStart}))}function Vpe(e,t,n){let r=V(e);return uy(os({adapter:rd,collisionMode:n.collisionMode,insertIndex:n.insertIndex,orderedItems:t,placedItemIds:n.placedItemIds,timelineFrameStart:r.frameStart}))}function qpe(e,t,n){let r=V(e);return uy(Zp({adapter:rd,insertedItemId:n,orderedItems:t,timelineFrameStart:r.frameStart}))}function py(e,t,n){let r=V(e),i=Mi(t),o=n.orderedItems.filter(c=>c.kind==="path-motion-clip").map(c=>c.pathMotionClip),a=n.orderedItems.filter(c=>c.kind==="path-motion-transition").map(c=>c.pathMotionTransition),s=[...o,...a].reduce((c,d)=>Math.max(c,Ope(d.frameEnd)),r.frameEnd);return{...r,frameEnd:s,animation:{...r.animation,pathMotionClips:[...nn(r).filter(c=>Mi(c.target)!==i),...o].sort((c,d)=>c.frameStart-d.frameStart||c.frameEnd-d.frameEnd),pathMotionTransitions:[...Ni(r).filter(c=>Mi(c.target)!==i),...a].sort((c,d)=>c.frameStart-d.frameStart||c.frameEnd-d.frameEnd)}}}function ly(e){let t=V(e),n=!1,r=new Map;return nn(t).forEach(i=>{r.set(Mi(i.target),i.target)}),Ni(t).forEach(i=>{r.set(Mi(i.target),i.target)}),r.forEach(i=>{let o=bG(t,rl(t,i));o.changed&&(t=py(t,i,o),n=!0)}),n||!e?t:e}function CG(e){let t=new Map,n=V(e);return nn(n).forEach(r=>{t.set(Mi(r.target),r.target)}),Ni(n).forEach(r=>{t.set(Mi(r.target),r.target)}),yv(e,Array.from(t.values()))}function yv(e,t){let n=V(e),r=!1;return new Map(t.map(o=>[Mi(o),o])).forEach(o=>{let a=Upe(n,rl(n,o));a.changed&&(n=py(n,o,a),r=!0)}),r||!e?n:e}function _v(e,t){let n=V(e);if(nd(t))return n;let r=!!SG(n,t.id),i=rl(n,t.target).filter(s=>!(s.kind==="path-motion-clip"&&s.id===t.id)),o=i.findIndex(s=>hv(s).frameStart>=t.frameStart),a=[...i.slice(0,o<0?i.length:o),{id:t.id,kind:"path-motion-clip",pathMotionClip:t},...i.slice(o<0?i.length:o)];return py(n,t.target,r?Vpe(n,a,{placedItemIds:[t.id]}):qpe(n,a,t.id))}function AG(e,t,n={}){let r=V(e),i=typeof t=="function"?t:c=>t.includes(c.id),o=new Set(nn(r).filter(c=>(n.includeDerived||!nd(c))&&i(c)).map(c=>c.id));if(!o.size)return r;let a=new Map;nn(r).filter(c=>o.has(c.id)).forEach(c=>a.set(Mi(c.target),c.target));let s=V({...r,animation:{...r.animation,pathMotionClips:nn(r).filter(c=>!o.has(c.id)),pathMotionTransitions:Ni(r).filter(c=>!o.has(c.fromClipId)&&!o.has(c.toClipId))}});return a.forEach(c=>{let d=bG(s,rl(s,c));d.changed&&(s=py(s,c,d))}),s}function IG(e,t){let n=V(e),r=typeof t=="function"?t:i=>t.includes(i.id);return{...n,animation:{...n.animation,pathMotionTransitions:Ni(n).filter(i=>!r(i))}}}function il(e){var n;let t=Math.max(1,Math.round(e.durationFrames??kpe));return{id:zpe(),target:{type:"node",nodeId:e.targetNodeId},pathNodeId:e.pathNode.id,pathName:e.pathNode.name||e.pathNode.id,frameStart:e.frameStart,frameEnd:e.frameStart+t,pathStartPercent:0,pathEndPercent:100,direction:"forward",facing:"path-tangent",playback:{version:1,speed:1,loop:!1,loopMode:"ping-pong",baseDurationFrames:t},speed:e.speed,pathLength:(n=Fpe(e.pathNode))==null?void 0:n.getLength(),status:"active",source:"semantic"}}var Cv=["X","Y","Z"];var Kpe="character.animation.bonePositions.",jpe="character.animation.boneQuaternions.",Hpe="character.animation.boneScales.";function ol(e,t){if(e){if(t===0)return e.x;if(t===1)return e.y;if(t===2)return e.z}}function Av(e,t,n){if(t===0){e.x=n;return}if(t===1){e.y=n;return}t===2&&(e.z=n)}function $pe(e,t){if(e){if(t===0)return e.x;if(t===1)return e.y;if(t===2)return e.z;if(t===3)return e.w}}function wi(e,t){return t.type==="node"?e.nodes.find(n=>n.id===t.nodeId):void 0}function Tv(e,t){let n=e.startsWith(t)?e.slice(t.length):void 0;return n!=null&&n.trim()?n:void 0}function Ype(e,t,n,r){var c,d,u;let i=wi(e,t);if((i==null?void 0:i.type)!=="character")return;let o=Tv(n,Kpe);if(o)return ol(((c=i.character.animation.bonePositions)==null?void 0:c[o])??{x:0,y:0,z:0},r);let a=Tv(n,jpe);if(a)return $pe(((d=i.character.animation.boneQuaternions)==null?void 0:d[a])??{x:0,y:0,z:0,w:1},r);let s=Tv(n,Hpe);if(s)return ol(((u=i.character.animation.boneScales)==null?void 0:u[s])??{x:1,y:1,z:1},r)}function Xpe(e,t){return!!wi(e,t)}function vG(e,t){var n;return((n=wi(e,t))==null?void 0:n.type)==="camera"}function Kn(e,t){return t.type==="environment"}function xG(e,t){return[{id:"transform",label:w.inspectorGroup.transform()},{id:e,label:t}]}function Sv(e,t){let n=e.replace("transform.","");return{dataPath:e,group:"Transform",label:t,channelLabels:Cv,arrayIndexes:[0,1,2],timelinePath:xG(e,t),supportsTarget:Xpe,getValue:(r,i,o)=>{var a;return ol((a=wi(r,i))==null?void 0:a.transform[n],o)},setValue:(r,i,o,a)=>{let s=wi(r,i);s&&Av(s.transform[n],o,a)}}}function bv(e,t){let n=e.replace("transform.","");return{dataPath:e,group:"Environment",label:t,channelLabels:Cv,arrayIndexes:[0,1,2],timelinePath:xG(e,t),supportsTarget:Kn,getValue:(r,i,o)=>Kn(r,i)?ol(r.environment.transform[n],o):void 0,setValue:(r,i,o,a)=>{Kn(r,i)&&Av(r.environment.transform[n],o,a)}}}var RG=[Sv("transform.position",w.timeline.position()),Sv("transform.rotation",w.timeline.rotation()),Sv("transform.scale",w.timeline.scale()),{dataPath:"camera.fov",group:"Camera",label:"FOV",channelLabels:["FOV"],arrayIndexes:[0],timelinePath:[{id:"camera",label:w.inspectorGroup.cameraRig()}],supportsTarget:vG,getValue:(e,t)=>{let n=wi(e,t);return(n==null?void 0:n.type)==="camera"?n.camera.fov:void 0},setValue:(e,t,n,r)=>{let i=wi(e,t);(i==null?void 0:i.type)==="camera"&&(i.camera.fov=r)}},{dataPath:"camera.lookAt",group:"Camera",label:"Look at",channelLabels:Cv,arrayIndexes:[0,1,2],timelinePath:[{id:"camera",label:w.inspectorGroup.cameraRig()}],supportsTarget:vG,getValue:(e,t,n)=>{let r=wi(e,t);return(r==null?void 0:r.type)==="camera"?ol(r.camera.lookAt,n):void 0},setValue:(e,t,n,r)=>{let i=wi(e,t);(i==null?void 0:i.type)==="camera"&&Av(i.camera.lookAt,n,r)}}],PG=[bv("transform.position",w.timeline.scenePosition()),bv("transform.rotation",w.timeline.sceneRotation()),bv("transform.scale",w.timeline.sceneScale()),{dataPath:"sphere.rotationY",group:"Environment",label:"Panorama rotation",channelLabels:["Y"],arrayIndexes:[0],supportsTarget:Kn,getValue:(e,t)=>Kn(e,t)?e.environment.sphere.rotationY:void 0,setValue:(e,t,n,r)=>{Kn(e,t)&&(e.environment.sphere.rotationY=r)}},{dataPath:"display.groundOpacity",group:"Environment",label:"Ground opacity",channelLabels:["Opacity"],arrayIndexes:[0],supportsTarget:Kn,getValue:(e,t)=>Kn(e,t)?e.environment.display.groundOpacity:void 0,setValue:(e,t,n,r)=>{Kn(e,t)&&(e.environment.display.groundOpacity=r)}},{dataPath:"display.groundHeight",group:"Environment",label:"Ground height",channelLabels:["Height"],arrayIndexes:[0],supportsTarget:Kn,getValue:(e,t)=>Kn(e,t)?e.environment.display.groundHeight:void 0,setValue:(e,t,n,r)=>{Kn(e,t)&&(e.environment.display.groundHeight=r)}}],Iv=[...RG,...PG];function my(e,t){return(t.type==="environment"?PG:RG).filter(r=>r.supportsTarget(e,t))}function Wpe(e,t,n){return my(e,t).find(r=>r.dataPath===n)}function id(e,t,n,r){var i;return Ype(e,t,n,r)??((i=Wpe(e,t,n))==null?void 0:i.getValue(e,t,r))}function vv(e,t,n){return e+(t-e)*n}function DG(e,t){let n=t.frame-e.frame;return n===0?0:(t.value-e.value)/n}function Jpe(e,t){let n=0,r=e.length;for(;n<r;){let i=Math.floor((n+r)/2);e[i].frame<t?n=i+1:r=i}return n}function EG(e,t,n,r,i){let o=1-i;return o*o*o*e+3*o*o*i*t+3*o*i*i*n+i*i*i*r}function Qpe(e,t,n){let r=e.handleRight??{x:vv(e.frame,t.frame,.3333333333333333),y:e.value},i=t.handleLeft??{x:vv(e.frame,t.frame,2/3),y:t.value},o=0,a=1,s=0;for(let c=0;c<16;c+=1)s=(o+a)/2,EG(e.frame,r.x,i.x,t.frame,s)<n?o=s:a=s;return EG(e.value,r.y,i.y,t.value,s)}function Zpe(e,t,n){if(t.frame===e.frame)return t.value;if(n<=e.frame)return e.value;if(n>=t.frame)return t.value;if(e.interpolation==="hold")return e.value;let r=(n-e.frame)/(t.frame-e.frame);return e.interpolation==="linear"?vv(e.value,t.value,r):Qpe(e,t,n)}function ele(e,t,n){let r=e.keyframes[0],i=e.keyframes[e.keyframes.length-1],o=i.frame-r.frame;if(o<=0)return t;let a=t<r.frame,s=a?e.extrapolationBefore:e.extrapolationAfter;if(s.type!=="cycle")return t;let{repeat:c}=s,d=a?r.frame-t:t-i.frame,u=Math.ceil(d/o);if(c!==void 0&&u>c)return a?n.frameStart:n.frameEnd;let p=((t-r.frame)%o+o)%o;return r.frame+p}function od(e,t,n){let{keyframes:r}=e;if(!r.length)return;if(r.length===1)return r[0].value;let i=ele(e,t,n),o=r[0],a=r[r.length-1];if(i<=o.frame)return i===o.frame||e.extrapolationBefore.type==="constant"?o.value:e.extrapolationBefore.type==="linear"?o.value+DG(o,r[1])*(i-o.frame):void 0;if(i>=a.frame)return i===a.frame||e.extrapolationAfter.type==="constant"?a.value:e.extrapolationAfter.type==="linear"?a.value+DG(r[r.length-2],a)*(i-a.frame):void 0;let s=Jpe(r,i),c=r[s-1],d=r[s];if(!(!c||!d))return Zpe(c,d,i)}var tle=1.2,nle=.05;function NG(e,t){return`motion_clip_${e}_${t}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`.replace(/[^a-zA-Z0-9_-]/g,"_")}function ss(e,t=0){return Number.isFinite(e)?Math.max(0,Math.round(e)):t}function Go(e){return(e==null?void 0:e.animation.motionClips)??[]}function Gr(e,t){return Go(e).find(n=>n.id===t)}function ki(e){return(e==null?void 0:e.animation.motionTransitions)??[]}function Rv(e,t){return ki(e).find(n=>n.id===t)}function Pv(e,t){let n=V(e);return cl({...n,animation:{...n.animation,motionTransitions:ki(n).filter(r=>!t(r))}})}function MG(e,t,n,r={}){var S,T;let i=Number.isFinite(n)&&n>0?n:30,o=fy(e),a=o.speed,{pathMotionSample:s}=r,c=rle(e,s),d=(c==null?void 0:c.effectiveSpeed)??a,u=typeof e.trimStart=="number"&&Number.isFinite(e.trimStart)?e.trimStart:0,p=ss(t),m=Math.max(0,p-e.frameStart),f=(s==null?void 0:s.frameStart)===e.frameStart||(S=r.resolvePathMotionSample)==null?void 0:S.call(r,e.frameStart),h=s&&f&&f.clipId===s.clipId?Math.max(0,s.distanceFromClipStart-f.distanceFromClipStart):void 0,g=c&&s?s.frameStart===e.frameStart?s.distanceFromClipStart:h??((T=r.resolvePathMotionTravelDistance)==null?void 0:T.call(r,e.frameStart,p)):void 0,y=g!==void 0&&Number.isFinite(g)?u+Math.max(0,g)/wG(e.motion)*a:u+m/i*d,_=typeof e.trimEnd=="number"&&Number.isFinite(e.trimEnd)?e.trimEnd:e.sourceDuration;if(typeof _=="number"&&Number.isFinite(_)&&_>u){let C=_-u,I=Qp({elapsedFrames:Math.max(0,y-u)*i,loopMode:o.loop?o.loopMode:"none",onePassFrames:C*i,phaseOffset:o.phaseOffset,speed:1});return u+C*I.progress}return y}function fy(e){return Jp(e.playback,{defaultLoopMode:"repeat",legacyLoop:e.motion.loop,legacySpeed:e.motion.speed})}function wG(e){var r;let t=(r=e.locomotion)==null?void 0:r.nominalSpeed;if(typeof t=="number"&&Number.isFinite(t)&&t>nle)return t;let n=`${e.name} ${e.assetId} ${e.clipName??""}`.toLowerCase();return/\b(sprint|run|running|jog|jogging|dash)\b/.test(n)?3.2:/\b(jump|leap|hop)\b/.test(n)?2:/\b(walk|walking|catwalk|stroll)\b/.test(n)?1.2:tle}function rle(e,t){var c,d;if(!t||(((c=e.motion.locomotion)==null?void 0:c.syncMode)??"path-speed")!=="path-speed")return;let r=wG(e.motion),i=fy(e).speed,o=t.speed/r,a=Number.isFinite(o)&&o>=0?o*i:i,s=((d=e.motion.locomotion)==null?void 0:d.rootMotionPolicy)??"force-in-place";return{effectiveSpeed:a,forceInPlace:s==="force-in-place"}}function ad(e,t){let n=V(e),r=!!Gr(n,t.id),i=hy(n,t.target).filter(s=>!(s.kind==="motion-clip"&&s.id===t.id)),o=i.findIndex(s=>Dv(s).frameStart>=t.frameStart),a=[...i.slice(0,o<0?i.length:o),{id:t.id,kind:"motion-clip",motionClip:t},...i.slice(o<0?i.length:o)];return gy(n,t.target,r?dle(n,a,{placedItemIds:[t.id]}):mle(n,a,t.id))}function xv(e,t){return e.type!==t.type?!1:e.type==="node"&&t.type==="node"?e.nodeId===t.nodeId:!0}function al(e){return e.type==="node"?`node:${e.nodeId}`:e.type}function ile(e){return Math.max(1,Math.round(e.frameEnd-e.frameStart))}function ole(e){return Math.max(1,Math.round(e.frameEnd-e.frameStart))}function kG(e){return e.kind==="motion-clip"?e.motionClip.target:e.motionTransition.target}function Dv(e){let t=e.kind==="motion-clip"?e.motionClip:e.motionTransition;return{frameEnd:t.frameEnd,frameStart:t.frameStart}}function ale(e){return e.kind==="motion-clip"?ile(e.motionClip):ole(e.motionTransition)}function sle(e){return qn(e,cs)}var cs={getDuration:ale,getFrameRange:Dv,getId:e=>e.id,withFrameRange:(e,t)=>e.kind==="motion-clip"?{id:e.id,kind:"motion-clip",motionClip:{...e.motionClip,...t}}:{id:e.id,kind:"motion-transition",motionTransition:{...e.motionTransition,...t}}};function hy(e,t){return sle([...Go(e).filter(n=>xv(n.target,t)).map(n=>({id:n.id,kind:"motion-clip",motionClip:n})),...ki(e).filter(n=>xv(n.target,t)).map(n=>({id:n.id,kind:"motion-transition",motionTransition:n}))])}function OG(e,t,n){if(t==="motion-clip"){let i=Gr(e,n);return i?{id:i.id,kind:"motion-clip",motionClip:i}:void 0}let r=Rv(e,n);return r?{id:r.id,kind:"motion-transition",motionTransition:r}:void 0}function sl(e){return{changed:e.changed,frameRangesByItemId:e.frameRangesByItemId,insertIndex:e.insertIndex,orderChanged:e.orderChanged,orderedItems:e.orderedItems,removedMotionTransitionIds:e.removedItemIds}}function cle(e,t){let n=V(e);return sl(Di({adapter:cs,orderedItems:t,timelineFrameStart:n.frameStart}))}function dle(e,t,n){let r=V(e);return sl(os({adapter:cs,collisionMode:n.collisionMode,insertIndex:n.insertIndex,orderedItems:t,placedItemIds:n.placedItemIds,timelineFrameStart:r.frameStart}))}function ule(e,t,n){let r=V(e);return sl(ry({adapter:cs,insertIndex:n.insertIndex,orderedItems:t,timelineFrameStart:r.frameStart,trimmedItemId:n.trimmedItemId}))}function ple(e){return Object.fromEntries(e.map(t=>[t.id,Dv(t)]))}function lle(e,t,n){let r=V(e);return sl(iy({adapter:cs,currentFrameRangesByItemId:n.currentFrameRangesByItemId,orderedItems:t,resizedItemId:n.resizedItemId,resizedRange:n.resizedRange,timelineFrameStart:r.frameStart}))}function mle(e,t,n){let r=V(e);return sl(Zp({adapter:cs,insertedItemId:n,orderedItems:t,timelineFrameStart:r.frameStart}))}function gy(e,t,n){let r=V(e),i=al(t),o=n.orderedItems.filter(c=>c.kind==="motion-clip").map(c=>c.motionClip),a=n.orderedItems.filter(c=>c.kind==="motion-transition").map(c=>c.motionTransition),s=[...o,...a].reduce((c,d)=>Math.max(c,ss(d.frameEnd)),r.frameEnd);return{...r,frameEnd:s,animation:{...r.animation,motionClips:[...Go(r).filter(c=>al(c.target)!==i),...o].sort((c,d)=>c.frameStart!==d.frameStart?c.frameStart-d.frameStart:c.frameEnd-d.frameEnd),motionTransitions:[...ki(r).filter(c=>al(c.target)!==i),...a].sort((c,d)=>c.frameStart!==d.frameStart?c.frameStart-d.frameStart:c.frameEnd-d.frameEnd)}}}function cl(e){let t=e?V(e):V(),n=!1,r=new Map;return Go(t).forEach(i=>{r.set(al(i.target),i.target)}),ki(t).forEach(i=>{r.set(al(i.target),i.target)}),r.forEach(i=>{let o=cle(t,hy(t,i));o.changed&&(t=gy(t,i,o),n=!0)}),n||!e?t:e}function fle(e,t,n,r){let i=V(e),o=OG(i,n,t);if(!o)return;let a=kG(o),s=hy(i,a),c=oy({adapter:cs,insertIndex:r,itemId:t,items:s,timelineFrameStart:i.frameStart});return c?{changed:c.changed,frameRangesByItemId:c.frameRangesByItemId,insertIndex:c.insertIndex,orderChanged:c.orderChanged,orderedItems:c.orderedItems,removedMotionTransitionIds:c.removedItemIds}:void 0}function LG(e,t,n,r){let i=V(e),o=OG(i,n,t);if(!o)return i;let a=fle(i,t,n,r);return a!=null&&a.changed?gy(i,kG(o),a):i}function hle(e,t,n,r={}){let i=V(e),o=Gr(i,t);if(!o)return;let{target:a}=o,s=r.frameStart!==void 0?ss(n.frameStart,o.frameStart):o.frameStart,c=r.frameEnd!==void 0?ss(n.frameEnd,o.frameEnd):o.frameEnd,d=Math.max(1,c-s),u=hy(i,a),p=ple(u),m=u.map(C=>C.kind!=="motion-clip"||C.id!==t?C:{id:C.id,kind:"motion-clip",motionClip:{...C.motionClip,...r,motion:r.motion?{...C.motionClip.motion,...r.motion}:C.motionClip.motion,frameEnd:s+d,frameStart:s}}),f=m.findIndex(C=>C.kind==="motion-clip"&&C.id===t),g=s===o.frameStart&&c!==o.frameEnd?lle(i,m,{currentFrameRangesByItemId:p,resizedItemId:t,resizedRange:{frameEnd:s+d,frameStart:s}}):ule(i,m,{insertIndex:Math.max(0,f),trimmedItemId:t}),y=o.motion,_=r.source!==void 0&&r.source!==o.source||r.playback!==void 0&&r.playback!==o.playback||r.sourceDuration!==void 0&&r.sourceDuration!==o.sourceDuration||r.trimEnd!==void 0&&r.trimEnd!==o.trimEnd||r.trimStart!==void 0&&r.trimStart!==o.trimStart||r.motion!==void 0&&Object.entries(r.motion).some(([C,I])=>y[C]!==I),S=g.frameRangesByItemId[t],T=!!(S&&(S.frameStart!==o.frameStart||S.frameEnd!==o.frameEnd));return _||T?{...g,changed:!0}:g}function gle(e,t,n,r={}){let i=V(e),o=Gr(i,t);if(!o)return i;let a=hle(i,t,n,r);return a!=null&&a.changed?gy(i,o.target,a):i}function yle(e,t){return Go(e).filter(n=>n.id!==t.id&&xv(n.target,t.target)).sort((n,r)=>n.frameStart!==r.frameStart?n.frameStart-r.frameStart:n.frameEnd-r.frameEnd)}function _le(e,t){let n=V(e),r=yle(n,t),i,o;for(let a of r){if(a.frameEnd<=t.frameStart){i=a;continue}if(a.frameStart>=t.frameEnd){o=a;break}}return{frameStart:Math.max(n.frameStart,(i==null?void 0:i.frameEnd)??n.frameStart),frameEnd:Math.min(n.frameEnd,(o==null?void 0:o.frameStart)??n.frameEnd),previousClip:i,nextClip:o}}function Tle(e,t,n){let r=_le(e,t),i=Math.min(Math.max(ss(n.frameStart),r.frameStart),r.frameEnd-1),o=Math.max(Math.min(ss(n.frameEnd),r.frameEnd),i+1);return{frameStart:i,frameEnd:o}}function FG(e,t,n){let r=V(e),i=Gr(r,t);if(!i)return r;let o={...i,...n,motion:n.motion?{...i.motion,...n.motion}:i.motion},a=n.frameStart!==void 0||n.frameEnd!==void 0?{frameEnd:o.frameEnd,frameStart:o.frameStart}:{frameEnd:i.frameEnd,frameStart:i.frameStart};if(n.frameStart!==void 0||n.frameEnd!==void 0){if(a.frameStart===i.frameStart&&a.frameEnd!==i.frameEnd)return gle(r,t,a,n);if(a.frameStart!==i.frameStart&&a.frameEnd-a.frameStart===i.frameEnd-i.frameStart)return ad(r,o);let d=Tle(r,i,a),u=ad(r,{...o,...d});return cl(u)}return ad(r,o)}function BG(e,t,n,r){let i=V(e),o=Sle(i,t,n,r);return o?ad(ad(dl(i,a=>a.id===t),o.leftClip),o.rightClip):i}function Sle(e,t,n,r){let i=Gr(e,t),o=ss(n);if(!i||o<=i.frameStart||o>=i.frameEnd)return;let a=Number.isFinite(r)&&r>0?r:30,s=fy(i),{speed:c}=s,d=typeof i.trimStart=="number"&&Number.isFinite(i.trimStart)?i.trimStart:0,u=typeof i.trimEnd=="number"&&Number.isFinite(i.trimEnd)?i.trimEnd:i.sourceDuration,p=typeof u=="number"&&Number.isFinite(u)&&u>d?u-d:void 0,m=p!==void 0?(s.phaseOffset??0)+(o-i.frameStart)*c/(p*a):s.phaseOffset,f=MG(i,i.frameStart,a),h=MG(i,o,a),g={...s};delete g.phaseOffset;let y=!s.loop&&typeof u=="number"&&Number.isFinite(u)&&h>=u,_=!s.loop&&f>=h,S={...g,phaseOffset:1},T=i.target.type==="node"?i.target.nodeId:i.target.type;return{leftClip:{...i,frameEnd:o,playback:s.loop?s:_?S:g,trimStart:s.loop||_?i.trimStart:f,trimEnd:s.loop||_?i.trimEnd:h},rightClip:{...i,id:NG(T,i.motion.assetId),frameStart:o,playback:s.loop?{...s,...m!==void 0?{phaseOffset:m}:{}}:y?S:g,trimStart:s.loop||y?i.trimStart:h}}}function dl(e,t){let n=V(e),r=new Set(Go(n).filter(t).map(i=>i.id));return cl({...n,animation:{...n.animation,motionClips:Go(n).filter(i=>!r.has(i.id)),motionTransitions:ki(n)}})}var Ev=[{kind:"position",dataPathPrefix:"character.animation.bonePositions.",defaultValues:[0,0,0],order:0,stride:3},{kind:"quaternion",dataPathPrefix:"character.animation.boneQuaternions.",defaultValues:[0,0,0,1],order:1,stride:4},{kind:"scale",dataPathPrefix:"character.animation.boneScales.",defaultValues:[1,1,1],order:2,stride:3}];function Mv(e){return e.type==="node"?`node:${e.nodeId}`:"environment"}function Cle(e){for(let t of Ev)if(e.startsWith(t.dataPathPrefix))return e.slice(t.dataPathPrefix.length)||void 0}function Ale(e,t){return`${e.dataPathPrefix}${t}`}function GG(e,t,n){return`${Mv(e)}:${t}:${n}`}function zG(e){return e.replace(/[^a-zA-Z0-9_-]/g,"_")||"bone"}function Ile(e){let t=e.target.type==="node"?zG(e.target.nodeId):"environment",n=zG(e.boneName);return{id:`fcurve_${t}_${n}_${e.kind}_${e.arrayIndex}`,target:e.target,dataPath:e.dataPath,arrayIndex:e.arrayIndex,keyframes:e.frames.map(r=>({id:`key_${t}_${n}_${e.kind}_${e.arrayIndex}_${r}`,frame:r,value:e.value,interpolation:"linear"})),enabled:!1,extrapolationBefore:{type:"constant"},extrapolationAfter:{type:"constant"},group:"Character"}}function Nv(e){let t=e==null?void 0:e.animation.fcurves;if(!e||!(t!=null&&t.length))return e;let n=new Map,r=new Map,i=new Map;if(t.forEach(s=>{if(i.set(GG(s.target,s.dataPath,s.arrayIndex),s),s.target.type!=="node")return;let c=Ev.find(m=>s.dataPath.startsWith(m.dataPathPrefix)),d=Cle(s.dataPath);if(!d)return;let u=`${Mv(s.target)}:${d}`,p=n.get(u)??{boneName:d,frames:new Set,target:s.target};if(s.keyframes.forEach(m=>p.frames.add(Math.round(m.frame))),n.set(u,p),c){let m=`${u}:${c.order}`,f=r.get(m)??new Set;s.keyframes.forEach(h=>f.add(Math.round(h.frame))),r.set(m,f)}}),!n.size)return e;let o=!1,a=[...t];return n.forEach(s=>{let c=`${Mv(s.target)}:${s.boneName}`;Ev.forEach(d=>{let u=Ale(d,s.boneName),p=Array.from(r.get(`${c}:${d.order}`)??s.frames).sort((m,f)=>m-f);if(p.length)for(let m=0;m<d.stride;m+=1){let f=GG(s.target,u,m);if(i.get(f))continue;let g=Ile({arrayIndex:m,boneName:s.boneName,dataPath:u,frames:p,kind:d.kind,target:s.target,value:d.defaultValues[m]});o=!0,i.set(f,g),a.push(g)}})}),o?{...e,animation:{...e.animation,fcurves:a}}:e}var vle=90,xle=18;var Rle=2,Ple=72;function UG(e){return V(e?ue(e):void 0)}function Dle(e,t,n){return Math.min(Math.max(e,t),n)}function Ele(e,t){return{x:e.x+t.x,y:e.y+t.y,z:e.z+t.z}}function VG(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}function Mle(e){return Math.hypot(e.x,e.y,e.z)}function Nle(e,t={x:0,y:0,z:1}){let n=Mle(e);return n>1e-4?VG(e,1/n):t}function wle(e){let t=Br.fromPathNode(e.pathNode,{space:"world"});if(!t||t.getLength()<=1e-4)return[];let n=Dle(Math.round(e.sampleCount??xle),Rle,Ple),r=e.startFrame??0,i=Math.max(1,Math.round(e.durationFrames??vle));return Array.from({length:n},(o,a)=>{let s=n<=1?0:a/(n-1),c=t.sampleAtProgress(s);if(c)return{frame:r+Math.round(i*s),position:c.position,tangent:c.tangent}}).filter(o=>!!o)}function yy(e,t,n,r){return[{target:e,dataPath:t,arrayIndex:0,frame:n,value:r.x,interpolation:"linear"},{target:e,dataPath:t,arrayIndex:1,frame:n,value:r.y,interpolation:"linear"},{target:e,dataPath:t,arrayIndex:2,frame:n,value:r.z,interpolation:"linear"}]}function _y(e){return Number.isFinite(e)?Math.max(0,Math.round(e)):0}function wv(e){return e.sort((t,n)=>t.frame-n.frame)}function kle(e,t,n,r){var s;if(r<=0)return n;let i=r-1,o=od(t,i,e)??((s=n.at(-1))==null?void 0:s.value);if(o===void 0)return n;let a=n.findIndex(c=>c.frame===i);return a>=0?(n[a]={...n[a],value:o,interpolation:"hold"},wv(n)):(n.push({id:`kf_${t.id}_path_motion_cut_${i}`,frame:i,value:o,interpolation:"hold"}),wv(n))}function Ole(e,t,n,r){let i=UG(e),o=_y(t),a=Math.max(o,_y(n));return i.animation.fcurves=i.animation.fcurves.flatMap(s=>{if(!r.has(Cn(s)))return[s];if(is(i,s))return[s];let c=s.keyframes.filter(u=>_y(u.frame)<o).map(u=>({...u})),d=[...c];return s.keyframes.forEach(u=>{_y(u.frame)>a&&d.push({...u})}),d.length?[{...s,keyframes:c.length>0?kle(e,s,d,o):wv(d)}]:[]}),i}function Lle(e){if(e)return e.type==="camera"?e.camera.lookAt:{x:e.transform.position.x,y:e.transform.position.y+(e.type==="character"?1.2:.5),z:e.transform.position.z}}function Fle(e,t,n,r){if(n==="current-look-at"&&t.type==="camera")return t.camera.lookAt;if(n==="target-node"){let i=Lle(r);if(i)return i}return Ele(e.position,VG(Nle(e.tangent),1.5))}function qG(e){let t=UG(e.timeline),n={type:"node",nodeId:e.targetNode.id},r=[],i=e.startFrame??t.frameStart,o=i,a=i;if(e.targetNode.type==="camera"){let d=wle({durationFrames:e.durationFrames,pathNode:e.pathNode,sampleCount:e.sampleCount,startFrame:i});if(!d.length)return t;o=d[0].frame,a=d[d.length-1].frame,d.forEach(u=>{r.push(...yy(n,"transform.position",u.frame,u.position));let p=Fle(u,e.targetNode,e.lookAtStrategy??"target-node",e.lookAtTargetNode);r.push(...yy(n,"camera.lookAt",u.frame,p))})}else{let d=sy.fromPathNode(e.pathNode,{durationFrames:e.durationFrames,frameStart:i}),u=(d==null?void 0:d.sampleRange({sampleCount:e.sampleCount,unwrapYaw:!0}))??[];if(!u.length)return t;o=u[0].frame,a=u[u.length-1].frame,u.forEach(p=>{r.push(...yy(n,"transform.position",p.frame,p.position),...yy(n,"transform.rotation",p.frame,p.rotation))})}let s=new Set(r.map(d=>Cn({target:d.target,dataPath:d.dataPath,arrayIndex:d.arrayIndex}))),c=Ole(t,o,a,s);for(let d of r)c=Qc(c,d);return c.frameStart=Math.min(c.frameStart,o),c.frameEnd=Math.max(c.frameEnd,a),c}var Gle=1e-4,KG="Transform keyframes",Ty=class{constructor(){this.kind="explicit-path-motion-clip";this.supportedSources=new Set(["semantic","baked"])}supports(t){return this.supportedSources.has(t.source??"semantic")}createClip(t){return{...il(t),source:"semantic"}}createPathFromPositionKeyframes(t){let n=Math.round(t.startKeyframe.frame),r=Math.round(t.endKeyframe.frame);if(r<=n)throw new RangeError("Position keyframe Path requires frameEnd > frameStart.");let i=r-n;return{source:t.source,parameterization:"time-ratio",curve:"polyline",points:Array.from({length:i+1},(o,a)=>{let s=n+a,c=a/i,d=a===0?t.startKeyframe.position:a===i?t.endKeyframe.position:t.interpolatePosition(s,c);return{id:`path_point_${Ov(`${t.pointIdSeed}:${s}`)}`,position:d,timeRatio:c}}),closed:!1,groundSnap:!1,smoothing:0}}sampleAtFrame(t){return fv(t.pathNode,t.clip,t.frame,{fps:t.fps})}getInteractionState(t){return{interactionLocked:t.locked===!0,runtimeEnabled:!0}}};function $G(e){return e.type==="node"?`node:${e.nodeId}`:"environment"}function Ov(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function zle(e,t,n){let r=Ov(`${$G(e)}:${t}:${n}`);return{clipId:`path_motion_clip_derived_${r}`,pathNodeId:`path_derived_${r}`}}function Ule(e,t){return e.animation.fcurves.filter(n=>n.enabled!==!1&&n.dataPath==="transform.position"&&n.arrayIndex>=0&&n.arrayIndex<=2&&Jc(n.target,t)).sort((n,r)=>n.arrayIndex-r.arrayIndex)}function Vle(e,t,n){let r=e.keyframes.filter(o=>o.frame<=t).at(-1),i=e.keyframes.find(o=>o.frame>=n);return[r,i].filter(o=>!!o)}function qle(e,t){return Math.hypot(t.x-e.x,t.y-e.y,t.z-e.z)}function jG(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function HG(e,t){if(e.length!==t.length)return!1;let n=new Set(t);return e.every(r=>n.has(r))}function Kle(e,t,n){var r,i;return!!(e&&n&&e.source==="transform-keyframes"&&e.locked===!0&&e.lockedReason==="derived-from-keyframes"&&e.pathNodeId===n.id&&((r=e.derivedSource)==null?void 0:r.sourceSignature)===t.sourceSignature&&!n.visible&&n.locked&&n.path.parameterization==="time-ratio"&&((i=n.metadata)==null?void 0:i.derivedPathMotionSourceSignature)===t.sourceSignature)}var kv=class extends Ty{constructor(){super(...arguments);this.kind="derived-path-motion-clip";this.supportedSources=new Set(["transform-keyframes"])}supports(n){return n.source==="transform-keyframes"}createFromKeyframes(n,r){let i=V(n.timeline),o=n.nodes.find(u=>u.id===r.nodeId);if(!o||o.type!=="character")return[];let a=Ule(i,r);if(!a.length)return[];let s=Array.from(new Set(a.flatMap(u=>u.keyframes.map(p=>p.frame)))).sort((u,p)=>u-p);if(s.length<2)return[];let c=new Map((i.animation.pathMotionClips??[]).filter(u=>u.source==="transform-keyframes").map(u=>[u.id,u])),d=new Map(n.nodes.filter(u=>u.type==="path"&&u.path.source==="transform-keyframes").map(u=>[u.id,u]));return s.slice(0,-1).flatMap((u,p)=>{let m=s[p+1],f=this.createSegmentDescriptor(r,a,u,m,o.transform.position),{clipId:h,pathNodeId:g}=zle(r,u,m),y=this.createSource(f),_=c.get(h),S=d.get(g);if(S&&Kle(_,y,S))return[{clip:_,pathNode:S}];let T=this.createSegment(f,i,a,o.transform.position);if(!T)return[];let C=Ng({id:g,locked:!0,metadata:{derivedPathMotionSourceSignature:y.sourceSignature,sourceType:"transform-keyframes"},name:KG,path:this.createPathData(T),visible:!1});return[{clip:{...super.createClip({durationFrames:m-u,frameStart:u,pathNode:C,targetNodeId:r.nodeId,timeline:i}),id:h,pathName:KG,source:"transform-keyframes",locked:!0,lockedReason:"derived-from-keyframes",derivedSource:y},pathNode:C}]})}createRebuildPlan(n){let r=V(n.timeline),o=n.nodes.filter(_=>_.type==="character").map(_=>({type:"node",nodeId:_.id})).flatMap(_=>this.createFromKeyframes({...n,timeline:r},_)),a=(r.animation.pathMotionClips??[]).filter(_=>_.source!=="transform-keyframes"),s=o.map(_=>_.clip),c=n.nodes.filter(_=>_.type!=="path"||_.path.source!=="transform-keyframes"),d=o.map(_=>_.pathNode),u=(r.animation.pathMotionClips??[]).filter(_=>_.source==="transform-keyframes"),p=n.nodes.filter(_=>_.type==="path"&&_.path.source==="transform-keyframes"),m=!jG(u,s),f=!jG(p,d),h=m?{...r,animation:{...r.animation,pathMotionClips:[...a,...s].sort((_,S)=>_.frameStart-S.frameStart||_.frameEnd-S.frameEnd)}}:r,g=CG(h);return{changed:m||f||g!==h,nodes:f?[...c,...d]:n.nodes,timeline:g}}createRebuildPlanForTargets(n,r){let i=V(n.timeline),o=new Set(r);if(!o.size)return{changed:!1,nodes:n.nodes,timeline:i};let a=Array.from(o,T=>({type:"node",nodeId:T})),s=a.flatMap(T=>this.createFromKeyframes({...n,timeline:i},T)),c=(i.animation.pathMotionClips??[]).filter(T=>T.source==="transform-keyframes"&&T.target.type==="node"&&o.has(T.target.nodeId)),d=new Set(c.map(T=>T.pathNodeId)),u=n.nodes.filter(T=>T.type==="path"&&d.has(T.id)),p=s.map(T=>T.clip),m=s.map(T=>T.pathNode),f=!HG(c,p),h=!HG(u,m),g=(i.animation.pathMotionClips??[]).filter(T=>!c.includes(T)),y=f?{...i,animation:{...i.animation,pathMotionClips:[...g,...p].sort((T,C)=>T.frameStart-C.frameStart||T.frameEnd-C.frameEnd)}}:i,_=yv(y,a);return{changed:f||h||_!==y,nodes:h?[...n.nodes.filter(T=>!d.has(T.id)),...m]:n.nodes,timeline:_}}getInteractionState(){return{interactionLocked:!0,runtimeEnabled:!0}}createPathData(n){let r=new Map(n.points.map(({frame:a,position:s})=>[a,s])),i=r.get(n.frameStart),o=r.get(n.frameEnd);if(!i||!o)throw new Error("Derived Path segment is missing an endpoint sample.");return this.createPathFromPositionKeyframes({endKeyframe:{frame:n.frameEnd,position:o},interpolatePosition:a=>r.get(a)??i,pointIdSeed:`${$G(n.target)}:${n.frameStart}:${n.frameEnd}`,source:"transform-keyframes",startKeyframe:{frame:n.frameStart,position:i}})}createSource(n){return{curveIds:n.curveIds,keyframeIds:n.keyframeIds,keyframeFrames:[n.frameStart,n.frameEnd],sourceSignature:n.sourceSignature}}createSegmentDescriptor(n,r,i,o,a){let s=r.map(p=>({curve:p,keyframes:Vle(p,i,o)})),c=s.flatMap(({keyframes:p})=>p),d=Array.from(new Set(c.map(p=>p.id))).sort(),u={fallback:a,curves:s.map(({curve:p,keyframes:m})=>({arrayIndex:p.arrayIndex,id:p.id,keyframes:m.map(f=>({frame:f.frame,handleLeft:f.handleLeft,handleRight:f.handleRight,id:f.id,interpolation:f.interpolation,value:f.value}))}))};return{curveIds:r.map(p=>p.id),frameEnd:o,frameStart:i,keyframeIds:d,sourceSignature:Ov(JSON.stringify(u)),target:n}}createSegment(n,r,i,o){let a=p=>{let m=[o.x,o.y,o.z];return i.forEach(f=>{let h=od(f,p,r);h!==void 0&&(m[f.arrayIndex]=h)}),{x:m[0],y:m[1],z:m[2]}},s=a(n.frameStart),c=a(n.frameEnd),d=Array.from({length:n.frameEnd-n.frameStart+1},(p,m)=>({frame:n.frameStart+m,position:a(n.frameStart+m)}));if(!(d.slice(1).reduce((p,m,f)=>p+qle(d[f].position,m.position),0)<=Gle))return{...n,points:d}}},YG=new kv,plt=new Ty;function Lv(e){return YG.createRebuildPlan(e)}function XG(e,t){return YG.createRebuildPlanForTargets(e,t)}function zr(e,t,n){return e.map(r=>r.id===t?n(r):r)}function $le(e,t){return e.target.type==="node"&&t.has(e.target.nodeId)}function zt(e){return[...new Set(e.filter(Boolean))]}function WG(e,t){return e&&t.includes(e)?e:void 0}function JG(e,t,n,r,i,o,a,s){return!e||!t?!1:e==="motion-clip"?i.includes(t):e==="motion-transition"?o.includes(t):e==="camera-motion-clip"?n.includes(t):e==="camera-motion-transition"?r.includes(t):e==="path-motion-clip"?a.includes(t):s.includes(t)}function Yle(e,t,n,r,i,o){if(n.length)return{id:n[0],kind:"motion-clip"};if(r.length)return{id:r[0],kind:"motion-transition"};if(i.length)return{id:i[0],kind:"path-motion-clip"};if(o.length)return{id:o[0],kind:"path-motion-transition"};if(e.length)return{id:e[0],kind:"camera-motion-clip"};if(t.length)return{id:t[0],kind:"camera-motion-transition"}}function Fv(e){if(e.type==="keyframes"){let t=zt(e.keyframeIds);return t.length?{type:"keyframes",keyframeIds:t,primaryKeyframeId:WG(e.primaryKeyframeId,t),anchorKeyframeId:WG(e.anchorKeyframeId,t)}:{type:"none"}}if(e.type==="motionClips"){let t=zt(e.motionClipIds);return Fv({type:"motionRanges",motionClipIds:t,motionTransitionIds:[],primaryMotionRangeId:e.primaryMotionClipId,primaryMotionRangeKind:"motion-clip",anchorMotionRangeId:e.anchorMotionClipId,anchorMotionRangeKind:"motion-clip"})}if(e.type==="motionTransitions"){let t=zt(e.motionTransitionIds);return Fv({type:"motionRanges",motionClipIds:[],motionTransitionIds:t,primaryMotionRangeId:e.primaryMotionTransitionId,primaryMotionRangeKind:"motion-transition",anchorMotionRangeId:e.anchorMotionTransitionId,anchorMotionRangeKind:"motion-transition"})}if(e.type==="motionRanges"){let t=zt(e.cameraMotionClipIds??[]),n=zt(e.cameraMotionTransitionIds??[]),r=zt(e.motionClipIds),i=zt(e.motionTransitionIds),o=zt(e.pathMotionClipIds??[]),a=zt(e.pathMotionTransitionIds??[]),s=Yle(t,n,r,i,o,a),c=JG(e.primaryMotionRangeKind,e.primaryMotionRangeId,t,n,r,i,o,a)?{id:e.primaryMotionRangeId,kind:e.primaryMotionRangeKind}:s,d=JG(e.anchorMotionRangeKind,e.anchorMotionRangeId,t,n,r,i,o,a)?{id:e.anchorMotionRangeId,kind:e.anchorMotionRangeKind}:void 0;return s?{type:"motionRanges",...t.length>0?{cameraMotionClipIds:t}:{},...n.length>0?{cameraMotionTransitionIds:n}:{},motionClipIds:r,motionTransitionIds:i,...o.length>0?{pathMotionClipIds:o}:{},...a.length>0?{pathMotionTransitionIds:a}:{},primaryMotionRangeId:c==null?void 0:c.id,primaryMotionRangeKind:c==null?void 0:c.kind,anchorMotionRangeId:d==null?void 0:d.id,anchorMotionRangeKind:d==null?void 0:d.kind}:{type:"none"}}return{type:"none"}}function Oi(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function Xle(e,t){return e.type!==t.type?!1:e.type==="none"?!0:e.type==="keyframes"&&t.type==="keyframes"?Oi(e.keyframeIds,t.keyframeIds)&&e.primaryKeyframeId===t.primaryKeyframeId&&e.anchorKeyframeId===t.anchorKeyframeId:e.type==="motionClips"&&t.type==="motionClips"?Oi(e.motionClipIds,t.motionClipIds)&&e.primaryMotionClipId===t.primaryMotionClipId&&e.anchorMotionClipId===t.anchorMotionClipId:e.type==="motionTransitions"&&t.type==="motionTransitions"?Oi(e.motionTransitionIds,t.motionTransitionIds)&&e.primaryMotionTransitionId===t.primaryMotionTransitionId&&e.anchorMotionTransitionId===t.anchorMotionTransitionId:e.type==="motionRanges"&&t.type==="motionRanges"?Oi(e.cameraMotionClipIds??[],t.cameraMotionClipIds??[])&&Oi(e.cameraMotionTransitionIds??[],t.cameraMotionTransitionIds??[])&&Oi(e.motionClipIds,t.motionClipIds)&&Oi(e.motionTransitionIds,t.motionTransitionIds)&&Oi(e.pathMotionClipIds??[],t.pathMotionClipIds??[])&&Oi(e.pathMotionTransitionIds??[],t.pathMotionTransitionIds??[])&&e.primaryMotionRangeId===t.primaryMotionRangeId&&e.primaryMotionRangeKind===t.primaryMotionRangeKind&&e.anchorMotionRangeId===t.anchorMotionRangeId&&e.anchorMotionRangeKind===t.anchorMotionRangeKind:!1}var Sy=class{constructor(t,n={}){this.environment=t;this.selectedNodeIds=[];this.selectedTarget={type:"scene"};this.timelineSelection={type:"none"};this.timelineFrame=0;this.timelinePlaying=!1;this.timelinePlaybackDirection=1;this.revision=0;this.changeListeners=new Set;this.hierarchyCollapsedSections=t.loadHierarchyCollapsedSections(),this.derivedPathMotionFromTransformKeyframes=n.derivedPathMotionFromTransformKeyframes??!0;let r=QG(n.document??vI()),i=this.derivedPathMotionFromTransformKeyframes?Lv(r):void 0;this.document=this.environment.wrapDocument(i!=null&&i.changed?{...r,nodes:i.nodes,timeline:i.timeline}:r),this.environment.initializeStore(this)}subscribe(t){return this.changeListeners.add(t),()=>{this.changeListeners.delete(t)}}emitChange(t){if(!this.changeListeners.size)return;let n={revision:this.revision,scopes:new Set(t)};this.changeListeners.forEach(r=>r(n))}isHierarchySectionExpanded(t){return!this.hierarchyCollapsedSections.includes(t)}setHierarchySectionExpanded(t,n){let r=this.hierarchyCollapsedSections.includes(t);if(n&&r){this.hierarchyCollapsedSections=this.hierarchyCollapsedSections.filter(i=>i!==t),this.environment.persistHierarchyCollapsedSections(this.hierarchyCollapsedSections),this.emitChange(["hierarchy"]);return}!n&&!r&&(this.hierarchyCollapsedSections=[...this.hierarchyCollapsedSections,t],this.environment.persistHierarchyCollapsedSections(this.hierarchyCollapsedSections),this.emitChange(["hierarchy"]))}get selectedNode(){let t=this.selectedNodeIds[0];return t?this.getNode(t):void 0}get activeShotCamera(){let{activeShotCameraNodeId:t}=this.document,n=t?this.getNode(t):void 0;return(n==null?void 0:n.type)==="camera"?n:void 0}get cameraNodes(){return this.document.nodes.filter(t=>t.type==="camera")}get hierarchyGroups(){return this.environment.createHierarchyGroups(this.document)}get cameraFrame(){return jF(this.document)}get toolbarState(){let{selectedNode:t}=this;return{hasSelection:!!t,canDelete:!!(t&&!t.locked),canTransform:!!(t&&!t.locked)}}get selectedTimelineKeyframeIds(){return this.timelineSelection.type==="keyframes"?this.timelineSelection.keyframeIds:[]}get selectedTimelineMotionClipIds(){return this.timelineSelection.type==="motionRanges"||this.timelineSelection.type==="motionClips"?this.timelineSelection.motionClipIds:[]}get primarySelectedTimelineMotionClipId(){return this.timelineSelection.type==="motionRanges"?this.timelineSelection.primaryMotionRangeKind==="motion-clip"?this.timelineSelection.primaryMotionRangeId:void 0:this.timelineSelection.type==="motionClips"?this.timelineSelection.primaryMotionClipId:void 0}get selectedTimelineMotionTransitionIds(){return this.timelineSelection.type==="motionRanges"||this.timelineSelection.type==="motionTransitions"?this.timelineSelection.motionTransitionIds:[]}get primarySelectedTimelineMotionTransitionId(){return this.timelineSelection.type==="motionRanges"?this.timelineSelection.primaryMotionRangeKind==="motion-transition"?this.timelineSelection.primaryMotionRangeId:void 0:this.timelineSelection.type==="motionTransitions"?this.timelineSelection.primaryMotionTransitionId:void 0}get selectedTimelineCameraMotionClipIds(){return this.timelineSelection.type==="motionRanges"?this.timelineSelection.cameraMotionClipIds??[]:[]}get primarySelectedTimelineCameraMotionClipId(){if(this.timelineSelection.type==="motionRanges")return this.timelineSelection.primaryMotionRangeKind==="camera-motion-clip"?this.timelineSelection.primaryMotionRangeId:void 0}get selectedTimelineCameraMotionTransitionIds(){return this.timelineSelection.type==="motionRanges"?this.timelineSelection.cameraMotionTransitionIds??[]:[]}get primarySelectedTimelineCameraMotionTransitionId(){if(this.timelineSelection.type==="motionRanges")return this.timelineSelection.primaryMotionRangeKind==="camera-motion-transition"?this.timelineSelection.primaryMotionRangeId:void 0}get selectedTimelinePathMotionClipIds(){return this.timelineSelection.type==="motionRanges"?this.timelineSelection.pathMotionClipIds??[]:[]}get primarySelectedTimelinePathMotionClipId(){if(this.timelineSelection.type==="motionRanges")return this.timelineSelection.primaryMotionRangeKind==="path-motion-clip"?this.timelineSelection.primaryMotionRangeId:void 0}get selectedTimelinePathMotionTransitionIds(){return this.timelineSelection.type==="motionRanges"?this.timelineSelection.pathMotionTransitionIds??[]:[]}get primarySelectedTimelinePathMotionTransitionId(){if(this.timelineSelection.type==="motionRanges")return this.timelineSelection.primaryMotionRangeKind==="path-motion-transition"?this.timelineSelection.primaryMotionRangeId:void 0}get canUndo(){return!1}get canRedo(){return!1}getNode(t){return this.document.nodes.find(n=>n.id===t)}setDocument(t){let n=QG(t),r=this.derivedPathMotionFromTransformKeyframes?Lv(n):void 0;this.document=this.environment.wrapDocument(r!=null&&r.changed?{...n,nodes:r.nodes,timeline:r.timeline}:n),this.clearTimelineSelection(),this.selectScene(),this.markDirty(["document","selection","timeline","timeline-selection"])}selectNode(t){this.clearTimelineSelection(),this.selectedNodeIds=t?[t]:[],this.selectedTarget=t?{type:"node",nodeId:t}:{type:"scene"},this.emitChange(["selection"])}selectNodes(t){this.clearTimelineSelection();let n=[...new Set(t.filter(Boolean))];this.selectedNodeIds=n;let r=n[0];this.selectedTarget=r?{type:"node",nodeId:r}:{type:"scene"},this.emitChange(["selection"])}toggleNodeSelection(t){if(this.selectedNodeIds.includes(t)){let n=this.selectedNodeIds.filter(r=>r!==t);this.selectNodes(n);return}this.selectNodes([...this.selectedNodeIds,t])}selectScene(){this.clearTimelineSelection(),this.selectedNodeIds=[],this.selectedTarget={type:"scene"},this.emitChange(["selection"])}markDirty(t=["document"]){this.revision+=1,this.emitChange(t)}setTimelineSelection(t){let n=Fv(t);Xle(this.timelineSelection,n)||(this.timelineSelection=n,this.emitChange(["timeline-selection"]))}setSelectedTimelineKeyframeIds(t,n={}){let r=zt(t);this.setTimelineSelection({type:"keyframes",keyframeIds:r,primaryKeyframeId:n.primaryKeyframeId??r[0],anchorKeyframeId:n.anchorKeyframeId})}clearTimelineKeyframeSelection(){this.timelineSelection.type==="keyframes"&&this.setTimelineSelection({type:"none"})}clearTimelineSelection(){this.setTimelineSelection({type:"none"})}setSelectedTimelineMotionClipIds(t,n={}){let r=zt(t);this.setSelectedTimelineMotionRangeIds({motionClipIds:r,motionTransitionIds:[],primaryMotionRangeId:n.primaryMotionClipId??r[0],primaryMotionRangeKind:"motion-clip",anchorMotionRangeId:n.anchorMotionClipId,anchorMotionRangeKind:"motion-clip"})}setSelectedTimelineMotionClipId(t){this.setSelectedTimelineMotionClipIds(t?[t]:[])}clearTimelineMotionClipSelection(){this.selectedTimelineMotionClipIds.length&&this.setSelectedTimelineMotionRangeIds({cameraMotionClipIds:this.selectedTimelineCameraMotionClipIds,cameraMotionTransitionIds:this.selectedTimelineCameraMotionTransitionIds,motionClipIds:[],motionTransitionIds:this.selectedTimelineMotionTransitionIds,pathMotionClipIds:this.selectedTimelinePathMotionClipIds,pathMotionTransitionIds:this.selectedTimelinePathMotionTransitionIds})}setSelectedTimelineMotionRangeIds(t){this.setTimelineSelection({type:"motionRanges",cameraMotionClipIds:t.cameraMotionClipIds,cameraMotionTransitionIds:t.cameraMotionTransitionIds,motionClipIds:t.motionClipIds,motionTransitionIds:t.motionTransitionIds,pathMotionClipIds:t.pathMotionClipIds,pathMotionTransitionIds:t.pathMotionTransitionIds,primaryMotionRangeId:t.primaryMotionRangeId,primaryMotionRangeKind:t.primaryMotionRangeKind,anchorMotionRangeId:t.anchorMotionRangeId,anchorMotionRangeKind:t.anchorMotionRangeKind})}setSelectedTimelineMotionTransitionIds(t,n={}){let r=zt(t);this.setSelectedTimelineMotionRangeIds({motionClipIds:[],motionTransitionIds:r,primaryMotionRangeId:n.primaryMotionTransitionId??r[0],primaryMotionRangeKind:"motion-transition",anchorMotionRangeId:n.anchorMotionTransitionId,anchorMotionRangeKind:"motion-transition"})}setSelectedTimelineMotionTransitionId(t){this.setSelectedTimelineMotionTransitionIds(t?[t]:[])}clearTimelineMotionTransitionSelection(){this.selectedTimelineMotionTransitionIds.length&&this.setSelectedTimelineMotionRangeIds({cameraMotionClipIds:this.selectedTimelineCameraMotionClipIds,cameraMotionTransitionIds:this.selectedTimelineCameraMotionTransitionIds,motionClipIds:this.selectedTimelineMotionClipIds,motionTransitionIds:[],pathMotionClipIds:this.selectedTimelinePathMotionClipIds,pathMotionTransitionIds:this.selectedTimelinePathMotionTransitionIds})}setSelectedTimelineCameraMotionClipIds(t,n={}){let r=zt(t);this.setSelectedTimelineMotionRangeIds({cameraMotionClipIds:r,cameraMotionTransitionIds:[],motionClipIds:[],motionTransitionIds:[],primaryMotionRangeId:n.primaryCameraMotionClipId??r[0],primaryMotionRangeKind:"camera-motion-clip",anchorMotionRangeId:n.anchorCameraMotionClipId,anchorMotionRangeKind:"camera-motion-clip"})}setSelectedTimelineCameraMotionClipId(t){this.setSelectedTimelineCameraMotionClipIds(t?[t]:[])}setSelectedTimelineCameraMotionTransitionIds(t,n={}){let r=zt(t);this.setSelectedTimelineMotionRangeIds({cameraMotionClipIds:[],cameraMotionTransitionIds:r,motionClipIds:[],motionTransitionIds:[],primaryMotionRangeId:n.primaryCameraMotionTransitionId??r[0],primaryMotionRangeKind:"camera-motion-transition",anchorMotionRangeId:n.anchorCameraMotionTransitionId,anchorMotionRangeKind:"camera-motion-transition"})}setSelectedTimelineCameraMotionTransitionId(t){this.setSelectedTimelineCameraMotionTransitionIds(t?[t]:[])}setSelectedTimelinePathMotionClipIds(t,n={}){let r=new Set(nn(this.document.timeline).filter(o=>o.locked!==!0).map(o=>o.id)),i=zt(t).filter(o=>r.has(o));this.setSelectedTimelineMotionRangeIds({cameraMotionClipIds:[],cameraMotionTransitionIds:[],motionClipIds:[],motionTransitionIds:[],pathMotionClipIds:i,pathMotionTransitionIds:[],primaryMotionRangeId:n.primaryPathMotionClipId&&i.includes(n.primaryPathMotionClipId)?n.primaryPathMotionClipId:i[0],primaryMotionRangeKind:"path-motion-clip",anchorMotionRangeId:n.anchorPathMotionClipId&&i.includes(n.anchorPathMotionClipId)?n.anchorPathMotionClipId:void 0,anchorMotionRangeKind:"path-motion-clip"})}setSelectedTimelinePathMotionClipId(t){this.setSelectedTimelinePathMotionClipIds(t?[t]:[])}setSelectedTimelinePathMotionTransitionIds(t,n={}){let r=zt(t);this.setSelectedTimelineMotionRangeIds({cameraMotionClipIds:[],cameraMotionTransitionIds:[],motionClipIds:[],motionTransitionIds:[],pathMotionClipIds:[],pathMotionTransitionIds:r,primaryMotionRangeId:n.primaryPathMotionTransitionId??r[0],primaryMotionRangeKind:"path-motion-transition",anchorMotionRangeId:n.anchorPathMotionTransitionId,anchorMotionRangeKind:"path-motion-transition"})}setSelectedTimelinePathMotionTransitionId(t){this.setSelectedTimelinePathMotionTransitionIds(t?[t]:[])}setTimelineFrame(t){let n=Math.round(Number.isFinite(t)?t:0);this.timelineFrame!==n&&(this.timelineFrame=n,this.emitChange(["timeline-frame"]))}setTimelinePlaying(t){this.timelinePlaying!==t&&(this.timelinePlaying=t,this.emitChange(["timeline-playback"]))}setTimelinePlaybackDirection(t){this.timelinePlaybackDirection!==t&&(this.timelinePlaybackDirection=t,this.emitChange(["timeline-playback"]))}updateTimeline(t,n={}){var i;let r=Nv(t)??t;this.document.timeline=r,this.reconcileDerivedPathMotionForTargets(((i=n.derivedPathInvalidation)==null?void 0:i.targetNodeIds)??[]),this.markDirty(["document","timeline"])}reconcileDerivedPathMotionForTargets(t){if(!this.derivedPathMotionFromTransformKeyframes||!t.length)return!1;let n=XG(this.document,t);return n.changed?(this.document.nodes=n.nodes,this.document.timeline=n.timeline,!0):!1}updateAsset(t){this.document.asset=t,this.markDirty()}addNode(t){this.document.nodes.push(t),t.type==="camera"&&(this.document.activeShotCameraNodeId=t.id,this.document.nodes=this.document.nodes.map(n=>n.type==="camera"?{...n,camera:{...n.camera,isPrimary:n.id===t.id}}:n)),this.selectNode(t.id),this.markDirty()}createCamera(t={}){let n=Pg(t);return this.addNode(n),n}createCharacter(t={}){let n=Up(t);return this.addNode(n),n}createProp(t={}){let n=Dg(t);return this.addNode(n),n}createPrimitive(t){let n=Eg(t);return this.addNode(n),n}createLight(t={}){let n=Mg(t);return this.addNode(n),n}removeNode(t){let n=this.getNode(t),r=new Set([t]);Un(n)&&n.children.forEach(s=>r.add(s)),nn(this.document.timeline).filter(s=>nd(s)&&s.target.type==="node"&&r.has(s.target.nodeId)).forEach(s=>r.add(s.pathNodeId)),this.document.nodes=this.document.nodes.filter(s=>!r.has(s.id));let i=new Set;this.document.timeline=iv(this.document.timeline,s=>{let c=$le(s,r);return c&&s.keyframes.forEach(d=>i.add(d.id)),c}),this.document.timeline=dl(this.document.timeline,s=>s.target.type==="node"&&r.has(s.target.nodeId)),this.document.timeline=Pv(this.document.timeline,s=>s.target.type==="node"&&r.has(s.target.nodeId));let o=nn(this.document.timeline).filter(s=>s.target.type==="node"&&r.has(s.target.nodeId)||r.has(s.pathNodeId)).map(s=>s.id);if(o.length){this.document.timeline=AG(this.document.timeline,o,{includeDerived:!0}),this.document.timeline=IG(this.document.timeline,d=>d.target.type==="node"&&r.has(d.target.nodeId)||o.includes(d.fromClipId)||o.includes(d.toClipId));let s=new Set(nn(this.document.timeline).map(d=>d.id)),c=new Set(Ni(this.document.timeline).map(d=>d.id));this.timelineSelection.type==="motionRanges"&&this.setSelectedTimelineMotionRangeIds({cameraMotionClipIds:this.selectedTimelineCameraMotionClipIds,cameraMotionTransitionIds:this.selectedTimelineCameraMotionTransitionIds,motionClipIds:this.selectedTimelineMotionClipIds,motionTransitionIds:this.selectedTimelineMotionTransitionIds,pathMotionClipIds:this.selectedTimelinePathMotionClipIds.filter(d=>s.has(d)),pathMotionTransitionIds:this.selectedTimelinePathMotionTransitionIds.filter(d=>c.has(d))})}let a=Ei(this.document.timeline).filter(s=>s.target.type==="node"&&r.has(s.target.nodeId)).map(s=>s.id);if(a.length){this.document.timeline=sG(this.document.timeline,a),this.document.timeline=cG(this.document.timeline,Fo(this.document.timeline).filter(d=>d.target.type==="node"&&r.has(d.target.nodeId)||a.includes(d.fromClipId)||a.includes(d.toClipId)).map(d=>d.id));let s=new Set(Ei(this.document.timeline).map(d=>d.id)),c=new Set(Fo(this.document.timeline).map(d=>d.id));this.timelineSelection.type==="motionRanges"&&this.setSelectedTimelineMotionRangeIds({cameraMotionClipIds:this.selectedTimelineCameraMotionClipIds.filter(d=>s.has(d)),cameraMotionTransitionIds:this.selectedTimelineCameraMotionTransitionIds.filter(d=>c.has(d)),motionClipIds:this.selectedTimelineMotionClipIds,motionTransitionIds:this.selectedTimelineMotionTransitionIds,pathMotionClipIds:this.selectedTimelinePathMotionClipIds,pathMotionTransitionIds:this.selectedTimelinePathMotionTransitionIds})}this.document.activeShotCameraNodeId&&r.has(this.document.activeShotCameraNodeId)&&(this.document.activeShotCameraNodeId=void 0),this.selectedNodeIds.some(s=>r.has(s))?this.selectNode(this.document.activeShotCameraNodeId):i.size&&this.timelineSelection.type==="keyframes"&&this.setSelectedTimelineKeyframeIds(this.selectedTimelineKeyframeIds.filter(s=>!i.has(s))),this.markDirty(["document","timeline"])}updateTransform(t,n){let r=this.getNode(t),i=Yp(r,n);!r||!i||(this.document.nodes=zr(this.document.nodes,t,o=>({...o,transform:{position:{...o.transform.position,...i.position},rotation:{...o.transform.rotation,...i.rotation},scale:{...o.transform.scale,...i.scale}}})),this.derivedPathMotionFromTransformKeyframes&&i.position&&this.reconcileDerivedPathMotionForTargets([t]),this.markDirty(this.derivedPathMotionFromTransformKeyframes&&i.position?["document","timeline"]:["document"]))}setTransformLocks(t,n){let r=Qg(n);this.document.nodes=zr(this.document.nodes,t,i=>{let o={...i,transformLocks:r};return r||delete o.transformLocks,o}),this.markDirty()}toggleTransformLock(t,n,r){let i=this.getNode(t);if(!i)return;let o=zB(i.transformLocks,n,r);this.document.nodes=zr(this.document.nodes,t,a=>{let s={...a};return o?s.transformLocks=o:delete s.transformLocks,s}),this.markDirty()}updateCamera(t,n){this.document.nodes=zr(this.document.nodes,t,r=>r.type==="camera"?{...r,camera:{...r.camera,...n}}:r),this.markDirty()}addCameraCapture(t){let n=this.document.captures??[];this.document.captures=[...n.filter(r=>r.id!==t.id),t],this.markDirty()}removeCameraCapture(t){let n=this.document.captures??[];this.document.captures=n.filter(r=>r.id!==t),this.markDirty()}updateCameraCaptureAsset(t,n){this.document.captures=(this.document.captures??[]).map(r=>r.id===t?{...r,asset:{...r.asset,...n}}:r),this.markDirty()}addCameraCaptureDelivery(t,n){this.document.captures=(this.document.captures??[]).map(r=>{if(r.id!==t)return r;let i=r.deliveries??[];return{...r,deliveries:[...i.filter(o=>o.id!==n.id),n]}}),this.markDirty()}updateCharacter(t,n){this.document.nodes=zr(this.document.nodes,t,r=>r.type==="character"?{...r,character:{...r.character,...n,appearance:{...r.character.appearance,...n.appearance},label:{...r.character.label,...n.label},animation:Tg({...r.character.animation,...n.animation})}}:r),this.markDirty()}updateProp(t,n){let r=Object.prototype.hasOwnProperty.call(n,"appearance");this.document.nodes=zr(this.document.nodes,t,i=>i.type==="prop"?{...i,prop:{...i.prop,...n,appearance:r?n.appearance?{...i.prop.appearance,...n.appearance}:void 0:i.prop.appearance}}:i),this.markDirty()}updateNodeMetadata(t,n){this.document.nodes=zr(this.document.nodes,t,r=>{let i={...r.metadata??{}};return Object.entries(n).forEach(([o,a])=>{if(typeof a>"u"){delete i[o];return}i[o]=a}),{...r,metadata:Object.keys(i).length?i:void 0}}),this.markDirty()}renameNode(t,n,r={}){let i=n.trim();i&&(this.document.nodes=zr(this.document.nodes,t,o=>{let a={...o.metadata??{}};return r.displayNameKey?a.displayNameKey=r.displayNameKey:delete a.displayNameKey,{...o,name:i,metadata:Object.keys(a).length?a:void 0}}),this.markDirty())}updateSceneEnvironment(t,n){var r,i,o;this.document.environment={...this.document.environment,...t,transform:{...this.document.environment.transform,...t.transform,position:{...this.document.environment.transform.position,...(r=t.transform)==null?void 0:r.position},rotation:{...this.document.environment.transform.rotation,...(i=t.transform)==null?void 0:i.rotation},scale:{...this.document.environment.transform.scale,...(o=t.transform)==null?void 0:o.scale}},background:{...this.document.environment.background,...t.background},sphere:{...this.document.environment.sphere,...t.sphere},display:{...this.document.environment.display,...t.display}},n&&(this.document.settings={...this.document.settings,...n}),this.markDirty()}setActiveCamera(t){let n=this.getNode(t);(n==null?void 0:n.type)==="camera"&&(this.document.activeShotCameraNodeId=t,this.document.nodes=this.document.nodes.map(r=>r.type==="camera"?{...r,camera:{...r.camera,isPrimary:r.id===t}}:r),this.markDirty())}setAspectRatio(t,n){this.document.aspectRatio=t,this.document.customAspectRatio=t==="custom"?n:void 0,this.markDirty()}setTransformMode(t){this.document.settings.transformMode=t,this.markDirty()}setSelectionMode(t){this.document.settings.selectionMode=t,this.markDirty()}toggleVisible(t){this.document.nodes=zr(this.document.nodes,t,n=>({...n,visible:!n.visible})),this.markDirty()}toggleLock(t){this.document.nodes=zr(this.document.nodes,t,n=>({...n,locked:!n.locked})),this.markDirty()}groupNodes(t,n){let r=t.map(c=>this.getNode(c)).filter(c=>!!c);if(!wg(r))return;let i=iB(this.document,r,n),o=FB(r.map(c=>c.transform));i.transform={...i.transform,position:o};let a=tv(r.map(c=>c.transform),i.transform),s=new Map(r.map((c,d)=>[c.id,a[d]]));return this.document.nodes=this.document.nodes.map(c=>{let d=s.get(c.id);return d?{...c,parentId:i.id,transform:d}:c}),this.document.nodes.push(i),this.selectNode(i.id),this.markDirty(),i}ungroupNode(t){let n=this.getNode(t);if(!Un(n))return[];let r=PI(this.document,n),i=nv(r.map(s=>s.transform),n.transform),o=r.map(s=>s.id),a=new Map(o.map((s,c)=>[s,i[c]]));return this.document.nodes=this.document.nodes.filter(s=>s.id!==t).map(s=>{let c=a.get(s.id);if(!c)return s;let{parentId:d,...u}=s;return{...u,transform:c}}),this.selectNodes(o),this.markDirty(),o}updateGroupLayout(t,n){let r=this.getNode(t);if(!Un(r)||r.group.kind!=="character")return;let i={...r.group.layout,...n},o=PI(this.document,r),a=oB(o.map(c=>c.transform),i),s=new Map(o.map((c,d)=>[c.id,a[d]]));this.document.nodes=this.document.nodes.map(c=>{if(c.id===t&&c.type==="group")return{...c,group:{...c.group,layout:i}};let d=s.get(c.id);return d?{...c,transform:d}:c}),this.markDirty()}updateGroupAppearance(t,n){let r=this.getNode(t);Un(r)&&(this.document.nodes=this.document.nodes.map(i=>i.id===t&&i.type==="group"?{...i,group:{...i.group,appearance:{...i.group.appearance,color:n}}}:i.parentId!==t||i.type!=="character"?i:{...i,character:{...i.character,appearance:{...i.character.appearance,color:n}}}),this.markDirty())}updateGroupLabel(t,n){let r=this.getNode(t);if(!Un(r)||r.group.kind!=="character")return;let i={...r.group.label,...n};this.document.nodes=this.document.nodes.map(o=>o.id===t&&o.type==="group"?{...o,group:{...o.group,label:i}}:o.parentId!==t||o.type!=="character"?o:{...o,character:{...o.character,label:{...o.character.label,...i}}}),this.markDirty()}addNodeToGroup(t,n){let r=this.getNode(t),i=this.getNode(n);if(!r||!Un(i)||!RI.has(r.type)||r.locked||t===n||r.parentId===n)return!1;r.parentId&&this.removeNodeFromGroup(t);let[o]=tv([r.transform],i.transform);return this.document.nodes=this.document.nodes.map(a=>a.id===t?{...a,parentId:n,transform:o}:a.id===n&&Un(a)?{...a,children:[...a.children,t]}:a),this.markDirty(),!0}removeNodeFromGroup(t){let n=this.getNode(t);if(!(n!=null&&n.parentId))return!1;let r=this.getNode(n.parentId);if(!Un(r))return!1;let[i]=nv([n.transform],r.transform);this.document.nodes=this.document.nodes.map(a=>{if(a.id===t){let{parentId:s,...c}=a;return{...c,transform:i}}return a.id===n.parentId&&Un(a)?{...a,children:a.children.filter(s=>s!==t)}:a});let o=this.getNode(n.parentId);return Un(o)&&o.children.length===0&&(this.document.nodes=this.document.nodes.filter(a=>a.id!==o.id),this.selectNode(void 0)),this.markDirty(),!0}};function QG(e){let t=V(e.timeline);return{...e,timeline:Nv(t)??t,nodes:e.nodes.map(n=>n.type==="character"?{...n,character:{...n.character,animation:Tg(n.character.animation)}}:n)}}var Wle=new Set(["support","attach","contact"]),Jle=new Set(["camera","character","prop","primitive","light","group","path","unknown"]);var Omt=new Set(Po);function Bv(e){var n,r;if(e.version!==1)return{ok:!1,error:`Unsupported document version: ${e.version}`};if(!Array.isArray(e.nodes))return{ok:!1,error:"Director scene document nodes must be an array"};let t=new Set;for(let i of e.nodes){if(!i.id)return{ok:!1,error:"Director scene node id is required"};if(t.has(i.id))return{ok:!1,error:`Duplicate director scene node id: ${i.id}`};if(t.add(i.id),!Jle.has(i.type))return{ok:!1,error:`Unsupported director scene node type: ${i.type}`}}if(e.activeShotCameraNodeId&&!t.has(e.activeShotCameraNodeId))return{ok:!1,error:`Active camera not found: ${e.activeShotCameraNodeId}`};for(let i of e.physicalConstraints??[]){if(!i.constraint_id||!Wle.has(i.type))return{ok:!1,error:"Director physical constraint id and type are required"};let o=Qle(i);if(o.length!==2||((n=o[0])==null?void 0:n.scene_object_id)===((r=o[1])==null?void 0:r.scene_object_id)||o.some(a=>!t.has(a.scene_object_id)||!a.anchor_id.trim()))return{ok:!1,error:`Director physical constraint is invalid: ${i.constraint_id}`}}for(let i of e.characterGroups??[])if(!i.group_id||i.member_ids.some(o=>!t.has(o)))return{ok:!1,error:`Director character group is invalid: ${i.group_id}`};return{ok:!0}}function Qle(e){return e.type==="support"?[e.supported_anchor,e.supporting_anchor].filter(t=>!!t):e.type==="attach"?[e.attached_anchor,e.target_anchor].filter(t=>!!t):e.type==="contact"?[e.anchor_a,e.anchor_b].filter(t=>!!t):[]}var Zle=new Set(["duplicate","lock","visibility"]);function At(e,t,n){if(!t)return!1;let r=e.getNode(t);return r?Zle.has(n)?!0:r.locked!==!0:!1}function by(e,t){e.updateTimeline(V(t))}function eme(e,t){let n=e.getNode(t);return(n==null?void 0:n.type)==="character"&&At(e,t,"motion")}function zo(e,t){let n=Gr(e.document.timeline,t);if((n==null?void 0:n.target.type)==="node")return eme(e,n.target.nodeId)?n.target.nodeId:void 0}function ZG(e,t){let n;return{id:`character-motion-clip:update:${e}`,label:w.command.updateCharacterMotion(),canExecute:r=>!!zo(r,e),execute:r=>{zo(r,e)&&(n=ue(r.document.timeline),r.updateTimeline(FG(r.document.timeline,e,t)))},undo:r=>by(r,n)}}function ez(e,t){let n;return{id:`character-motion-clip:reorder:${e}:${Math.round(t)}`,label:w.command.updateCharacterMotion(),canExecute:r=>!!zo(r,e),execute:r=>{zo(r,e)&&(n=ue(r.document.timeline),r.updateTimeline(LG(r.document.timeline,e,"motion-clip",t)))},undo:r=>by(r,n)}}function tz(e){let t,n={type:"none"};return{id:`character-motion-clip:remove:${e}`,label:w.command.deleteCharacterMotionClip(),canExecute:r=>!!zo(r,e),execute:r=>{if(!zo(r,e))return;t=ue(r.document.timeline),n=ue(r.timelineSelection);let i=dl(r.document.timeline,o=>o.id===e);if(r.updateTimeline(i),r.selectedTimelineMotionClipIds.includes(e)&&r.setSelectedTimelineMotionRangeIds({motionClipIds:r.selectedTimelineMotionClipIds.filter(o=>o!==e),motionTransitionIds:r.selectedTimelineMotionTransitionIds}),r.selectedTimelineMotionTransitionIds.length){let o=new Set(ki(i).map(a=>a.id));r.setSelectedTimelineMotionRangeIds({motionClipIds:r.selectedTimelineMotionClipIds,motionTransitionIds:r.selectedTimelineMotionTransitionIds.filter(a=>o.has(a))})}},undo:r=>{by(r,t),r.setTimelineSelection(n)}}}function nz(e,t){let n;return{id:`character-motion-clip:split:${e}:${Math.round(t)}`,label:w.command.splitCharacterMotionClip(),canExecute:r=>{if(!zo(r,e))return!1;let i=Gr(r.document.timeline,e),o=Math.round(t);return!!(i&&o>i.frameStart&&o<i.frameEnd)},execute:r=>{if(!zo(r,e))return;n=ue(r.document.timeline);let i=V(r.document.timeline);r.updateTimeline(BG(i,e,t,i.fps))},undo:r=>by(r,n)}}function Cy(e,t,n=e.selectedNodeIds,r=e.selectedTarget){e.document.nodes=t.map(i=>ue(i)),e.selectedNodeIds=[...n],e.selectedTarget=ue(r)}function rz(e,t){let n=Math.max(0,Math.round(e)),r=Math.max(0,Math.round(t));return n<=r?{frameStart:n,frameEnd:r}:{frameStart:r,frameEnd:n}}function oz(e){return{id:`add:${e.id}`,label:w.command.addObject(),execute:t=>t.addNode(ue(e)),undo:t=>t.removeNode(e.id)}}function az(e){let t=[],n=[],r={type:"scene"},i,o;return{id:`remove:${e}`,label:w.command.deleteObject(),canExecute:a=>At(a,e,"delete"),execute:a=>{t=ue(a.document.nodes),n=[...a.selectedNodeIds],r=ue(a.selectedTarget),i=a.document.activeShotCameraNodeId,o=ue(a.document.timeline),a.removeNode(e)},undo:a=>{Cy(a,t,n,r),a.document.activeShotCameraNodeId=i,ds(a,o)}}}function sz(e,t){let n;return{id:`transform:${e}`,label:w.command.updateTransform(),canExecute:r=>{let i=r.getNode(e);return!!(i&&At(r,e,"transform")&&Yp(i,t))},execute:r=>{let i=r.getNode(e),o=Yp(i,t);!i||!o||(n=ue(i.transform),r.updateTransform(e,o))},undo:r=>{n&&r.updateTransform(e,n)}}}function ul(e,t,n){e.updateTimeline(t,n.length?{derivedPathInvalidation:{targetNodeIds:n}}:void 0)}function ds(e,t,n=[]){if(t){ul(e,ue(t),n);return}delete e.document.timeline,e.reconcileDerivedPathMotionForTargets(n),e.markDirty(["document","timeline"])}function cz(e){return[...new Set(e.flatMap(t=>t.dataPath==="transform.position"&&t.target.type==="node"?[t.target.nodeId]:[]))]}function Gv(e,t){let n=new Set(t);return cz(An(e).filter(r=>r.dataPath==="transform.position"&&r.keyframes.some(i=>n.has(i.id))))}function iz(e,t,n){let{timeline:r}=e.document,i=cr(r,t),o=Wp(r,i,n);if(!o)return[];let a=new Set(i),s=[];for(let c of An(r))for(let d of c.keyframes)a.has(d.id)&&(ed(r,{target:c.target,frame:d.frame+o})||s.push(d.id));return s}function Ay(e){let t,n=cz([e]);return{id:`timeline:keyframe:upsert:${e.frame}:${e.dataPath}:${e.arrayIndex}`,label:w.command.updateKeyframe(),canExecute:r=>!is(r.document.timeline,e)&&!ed(r.document.timeline,e),execute:r=>{if(ed(r.document.timeline,e))return;let i=e.value??id(r.document,e.target,e.dataPath,e.arrayIndex);i!==void 0&&(t=ue(r.document.timeline),ul(r,Qc(r.document.timeline,{target:e.target,dataPath:e.dataPath,arrayIndex:e.arrayIndex,frame:e.frame,handleLeft:e.handleLeft,handleRight:e.handleRight,id:e.id,value:i,interpolation:e.interpolation}),n))},undo:r=>ds(r,t,n)}}function dz(e){let t,n=[],r=[];return{id:`timeline:keyframe:remove:${e.join(",")}`,label:w.command.deleteKeyframe(),canExecute:i=>cr(i.document.timeline,e).length>0,execute:i=>{t=ue(i.document.timeline),n=[...i.selectedTimelineKeyframeIds],r=Gv(i.document.timeline,e),ul(i,jB(i.document.timeline,e),r);let o=new Set(e);i.setSelectedTimelineKeyframeIds(i.selectedTimelineKeyframeIds.filter(a=>!o.has(a)))},undo:i=>{ds(i,t,r),i.setSelectedTimelineKeyframeIds(n)}}}function uz(e,t){let n,r=[];return{id:`timeline:keyframe:move:${e.join(",")}`,label:w.command.updateKeyframe(),canExecute:i=>!!t&&iz(i,e,t).length>0,execute:i=>{let o=iz(i,e,t);o.length&&(n=ue(i.document.timeline),r=Gv(i.document.timeline,o),ul(i,HB(i.document.timeline,o,t),r))},undo:i=>{ds(i,n,r)}}}function pz(e){let t;return{id:"timeline:frame-range:update",label:w.command.updateFrameRange(),canExecute:n=>{let r=V(n.document.timeline),i=rz(e.frameStart,e.frameEnd);return r.frameStart!==i.frameStart||r.frameEnd!==i.frameEnd},execute:n=>{let r=V(n.document.timeline),i=rz(e.frameStart,e.frameEnd);t=ue(n.document.timeline),n.updateTimeline({...r,...i})},undo:n=>ds(n,t)}}function lz(e,t){let n,r=[];return{id:`timeline:keyframe:interpolation:${e.join(",")}`,label:w.command.updateKeyframe(),canExecute:i=>cr(i.document.timeline,e).length>0,execute:i=>{n=ue(i.document.timeline),r=Gv(i.document.timeline,e),ul(i,$B(i.document.timeline,e,t),r)},undo:i=>ds(i,n,r)}}function mz(e,t){let n;return{id:`camera:${e}`,label:w.command.updateCamera(),canExecute:r=>At(r,e,"camera"),execute:r=>{let i=r.getNode(e);n=(i==null?void 0:i.type)==="camera"?ue(i.camera):void 0,n&&r.updateCamera(e,t)},undo:r=>{n&&r.updateCamera(e,n)}}}function fz(e,t,n={}){let r,i=[],o={type:"scene"};return{id:`path-motion:timeline:${e}:${t}`,label:w.command.applyPathMotion(),canExecute:a=>{let s=a.getNode(e),c=a.getNode(t);return(s==null?void 0:s.type)!=="path"||s.path.points.length<2||!c||c.type!=="character"&&c.type!=="camera"||!At(a,t,"transform")?!1:c.type!=="camera"||At(a,t,"camera")},execute:a=>{let s=a.getNode(e),c=a.getNode(t);if((s==null?void 0:s.type)!=="path"||!c)return;r=ue(a.document.timeline),i=[...a.selectedNodeIds],o=ue(a.selectedTarget);let d=n.lookAtTargetNodeId?a.getNode(n.lookAtTargetNodeId):void 0;if(c.type==="character"){let u=V(a.document.timeline),m=gv(u,{type:"node",nodeId:t},n.startFrame??u.frameStart),f=il({durationFrames:n.durationFrames,frameStart:m,pathNode:s,targetNodeId:t,timeline:u});a.updateTimeline(ly(_v(a.document.timeline,f))),a.selectNode(t),a.setSelectedTimelinePathMotionClipId(f.id)}else a.updateTimeline(qG({durationFrames:n.durationFrames,lookAtStrategy:n.lookAtStrategy,lookAtTargetNode:d,pathNode:s,startFrame:n.startFrame,targetNode:c,timeline:a.document.timeline})),a.selectNode(t)},undo:a=>{ds(a,r),a.selectedNodeIds=i,a.selectedTarget=o}}}function hz(e){let t;return{id:`active-camera:${e}`,label:w.command.switchCamera(),canExecute:n=>At(n,e,"camera"),execute:n=>{t=n.document.activeShotCameraNodeId,n.setActiveCamera(e)},undo:n=>{t&&n.setActiveCamera(t)}}}function gz(e,t){let n="",r;return{id:`rename:${e}`,label:w.command.renameObject(),canExecute:i=>At(i,e,"rename"),execute:i=>{var a;let o=i.getNode(e);n=(o==null?void 0:o.name)??"",r=(a=o==null?void 0:o.metadata)==null?void 0:a.displayNameKey,i.renameNode(e,t)},undo:i=>{n&&i.renameNode(e,n,{displayNameKey:r})}}}function yz(e){return{id:`visible:${e}`,label:w.command.toggleVisible(),canExecute:t=>At(t,e,"visibility"),execute:t=>t.toggleVisible(e),undo:t=>t.toggleVisible(e)}}function _z(e){return{id:`lock:${e}`,label:w.command.toggleLock(),canExecute:t=>At(t,e,"lock"),execute:t=>t.toggleLock(e),undo:t=>t.toggleLock(e)}}function Tz(e,t){let n=[],r=[],i={type:"scene"},o;return{id:`group:${e.join(",")}`,label:w.command.groupObjects(),execute:a=>{n=ue(a.document.nodes),r=[...a.selectedNodeIds],i=ue(a.selectedTarget);let s=a.groupNodes(e,t);o=s==null?void 0:s.id},undo:a=>{Cy(a,n,r,i)}}}function Sz(e){let t=[],n=[],r={type:"scene"};return{id:`ungroup:${e}`,label:w.command.ungroupObjects(),execute:i=>{t=ue(i.document.nodes),n=[...i.selectedNodeIds],r=ue(i.selectedTarget),i.ungroupNode(e)},undo:i=>{Cy(i,t,n,r)}}}function bz(e,t){let n=[];return{id:`group-layout:${e}`,label:w.command.updateTransform(),execute:r=>{n=ue(r.document.nodes),r.updateGroupLayout(e,t)},undo:r=>{Cy(r,n)}}}var Le=class extends Error{constructor(){super(...arguments);this.code="SCENE3D_COMMAND_REJECTED"}};function zv(e,t,n,r,i,o){var c;let a={type:"node",nodeId:t},s=(c=ty(e.document.timeline,{target:a,dataPath:n,arrayIndex:r}))==null?void 0:c.keyframes.find(d=>d.frame===i);return s?Ay({...s,target:a,dataPath:n,arrayIndex:r,value:o}):void 0}function Cz(e,t,n,r=0){let i=e.getNode(t);if(!i||!At(e,t,"transform"))throw new Le("Object is missing or locked.");let o=[],a={};for(let s of["position","rotation","scale"]){let c=n[s];if(!c)continue;let d={...i.transform[s]},u=!1;for(let[p,m]of["x","y","z"].entries()){if(rv(i,s,m))throw new Le(`Transform channel ${s}.${m} is locked.`);let f=zv(e,t,`transform.${s}`,p,r,c[m]);f?o.push(f):(d[m]=c[m],u=!0)}u&&(a[s]=d)}return Object.keys(a).length&&o.push(sz(t,a)),o}function Az(e,t,n,r=0){let i=e.getNode(t);if((i==null?void 0:i.type)!=="camera"||!At(e,t,"camera"))throw new Le("Camera is missing or locked.");let o=[],a={...n};if(n.fov!==void 0){let s=zv(e,t,"camera.fov",0,r,n.fov);s&&(o.push(s),delete a.fov)}if(n.lookAt){let s={...i.camera.lookAt},c=!1;for(let[d,u]of["x","y","z"].entries()){let p=zv(e,t,"camera.lookAt",d,r,n.lookAt[u]);p?o.push(p):(s[u]=n.lookAt[u],c=!0)}c?a.lookAt=s:delete a.lookAt}return Object.keys(a).length&&o.push(mz(t,a)),o}function tme(e){switch(e.kind){case"camera":return Pg(e);case"character":return Up(e);case"prop":return Dg(e);case"primitive":return Eg({...e,kind:e.primitiveKind});case"light":return Mg({...e,kind:e.lightKind});case"path":return Ng(e)}}function nme(e,t,n){let r=new Set(An(e.document.timeline).flatMap(s=>s.keyframes.map(c=>c.id))),i=new Set(cr(e.document.timeline,t));if(t.some(s=>!r.has(s)||!i.has(s)))throw new Le("Every requested keyframe must exist and be unlocked.");let o=new Set(t),a=n===void 0?void 0:Wp(e.document.timeline,t,n);for(let s of An(e.document.timeline))for(let c of s.keyframes)if(o.has(c.id)&&(s.target.type==="node"&&!At(e,s.target.nodeId,"transform")||a!==void 0&&ed(e.document.timeline,{target:s.target,frame:c.frame+a})))throw new Le("A requested keyframe target is locked or reserved by camera motion.")}function Iz(e,t){var r;let{args:n}=t;if("nodeId"in n&&!e.getNode(n.nodeId))throw new Le(`Object ${n.nodeId} was not found.`);switch("keyframeIds"in n&&nme(e,n.keyframeIds,t.command==="move_keyframes"?t.args.deltaFrames:void 0),t.command){case"create_node":{if(e.getNode(t.args.id))throw new Le("Object ID already exists.");return[oz(tme(t.args))]}case"remove_node":return[az(t.args.nodeId)];case"rename_node":return[gz(t.args.nodeId,t.args.name)];case"update_transform":return Cz(e,t.args.nodeId,t.args.transform,t.args.frame);case"update_camera":return Az(e,t.args.nodeId,t.args.camera,t.args.frame);case"set_active_camera":{if(((r=e.getNode(t.args.nodeId))==null?void 0:r.type)!=="camera")throw new Le("Target is not a camera.");return[hz(t.args.nodeId)]}case"toggle_visible":return[yz(t.args.nodeId)];case"toggle_lock":return[_z(t.args.nodeId)];case"group_nodes":{let i=t.args.nodeIds.map(o=>e.getNode(o));if(i.some(o=>!o)||!wg(i.filter(o=>o!==void 0)))throw new Le("Objects cannot be grouped.");return[Tz(t.args.nodeIds,t.args.name)]}case"ungroup_node":case"update_group_layout":{let i=e.getNode(t.args.nodeId);if((i==null?void 0:i.type)!=="group"||i.locked||t.command==="update_group_layout"&&i.group.kind!=="character")throw new Le("Group is missing, locked, or does not support this operation.");return[t.command==="ungroup_node"?Sz(i.id):bz(i.id,t.args.layout)]}case"upsert_keyframe":{let{target:i,dataPath:o,arrayIndex:a}=t.args;if(id(e.document,i,o,a)===void 0||i.type==="node"&&!At(e,i.nodeId,"transform"))throw new Le("Keyframe target or property channel is unavailable.");return[Ay(t.args)]}case"remove_keyframes":return[dz(t.args.keyframeIds)];case"move_keyframes":return[uz(t.args.keyframeIds,t.args.deltaFrames)];case"set_keyframe_interpolation":return[lz(t.args.keyframeIds,t.args.interpolation)];case"set_frame_range":return[pz(t.args)];case"apply_path_motion":{if(t.args.lookAtStrategy==="target-node"&&!e.getNode(t.args.lookAtTargetNodeId??""))throw new Le("lookAtTargetNodeId must identify an existing object.");return[fz(t.args.pathNodeId,t.args.targetNodeId,t.args)]}case"update_motion_clip":return[ZG(t.args.clipId,t.args.patch)];case"remove_motion_clip":return[tz(t.args.clipId)];case"split_motion_clip":return[nz(t.args.clipId,t.args.frame)];case"reorder_motion_clip":return[ez(t.args.clipId,t.args.insertIndex)];default:throw new Le("Unknown document command.")}}var Xt={type:"number",exclusiveMinimum:0,unit:"metres"},Uv={type:"number",minimum:0,unit:"metres"},It={type:"integer",minimum:1},ps={type:"number",unit:"radians"},us={...ps,exclusiveMinimum:0},rme=2,sd=Math.PI*rme,Vv={BoxGeometry:{width:{...Xt,default:1},height:{...Xt,default:1},depth:{...Xt,default:1},widthSegments:{...It,default:1},heightSegments:{...It,default:1},depthSegments:{...It,default:1}},SphereGeometry:{radius:{...Xt,default:.55},widthSegments:{...It,default:32},heightSegments:{...It,default:16},phiStart:{...ps,default:0},phiLength:{...us,default:sd},thetaStart:{...ps,default:0},thetaLength:{...us,default:Math.PI}},CapsuleGeometry:{radius:{...Xt,default:.35},length:{...Xt,default:.8},capSegments:{...It,default:8},radialSegments:{...It,default:20}},ConeGeometry:{radius:{...Uv,default:.55},height:{...Xt,default:1.1},radialSegments:{...It,default:32},heightSegments:{...It,default:1},openEnded:{type:"boolean",default:!1},thetaStart:{...ps,default:0},thetaLength:{...us,default:sd}},CylinderGeometry:{radiusTop:{...Uv,default:.55},radiusBottom:{...Uv,default:.55},height:{...Xt,default:1},radialSegments:{...It,default:32},heightSegments:{...It,default:1},openEnded:{type:"boolean",default:!1},thetaStart:{...ps,default:0},thetaLength:{...us,default:sd}},TorusGeometry:{radius:{...Xt,default:.35},tube:{...Xt,default:.1},radialSegments:{...It,default:16},tubularSegments:{...It,default:48},arc:{...us,default:sd}},PlaneGeometry:{width:{...Xt,default:1},height:{...Xt,default:1},widthSegments:{...It,default:1},heightSegments:{...It,default:1}},CircleGeometry:{radius:{...Xt,default:.55},segments:{...It,default:48},thetaStart:{...ps,default:0},thetaLength:{...us,default:sd}},RingGeometry:{innerRadius:{...Xt,default:.32},outerRadius:{...Xt,default:.55},thetaSegments:{...It,default:48},phiSegments:{...It,default:1},thetaStart:{...ps,default:0},thetaLength:{...us,default:sd}},LatheGeometry:{},TubeGeometry:{},ExtrudeGeometry:{}};function vz(e,t){let n=t?{type:"node",nodeId:t}:{type:"environment"},r=t?e.nodes.find(i=>i.id===t):void 0;if(t&&!r)throw new Le("Object was not found.");return ue({document:t?void 0:e,node:r,timeline:e.timeline,properties:my(e,n).map(i=>({dataPath:i.dataPath,arrayIndexes:i.arrayIndexes,channels:i.channelLabels}))})}function xz(e,t){if(!t.length)throw new Le("At least one operation is required.");let n=Bv(e);if(!n.ok)throw new Le(n.error);let r=new Sy(GF,{document:ue(e)});for(let a of t){let s=Iz(r,a);if(!s.length)throw new Le(`Command ${a.command} has no executable changes.`);for(let c of s){if(c.canExecute&&!c.canExecute(r))throw new Le(`Command ${a.command} cannot execute for the current document.`);let{revision:d}=r;if(c.execute(r),r.revision===d)throw new Le(`Command ${a.command} did not apply.`)}}let i=ue(r.document);e.timeline&&i.timeline&&(i.timeline={...e.timeline,...i.timeline,animation:{...e.timeline.animation,...i.timeline.animation}});let o=Bv(i);if(!o.ok)throw new Le(o.error);return i}function Iy(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function qv(e){return Array.isArray(e)?e.map(t=>qv(t)):Iy(e)?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,qv(n)])):e}function Rz(e){if(!Iy(e))return;let t=qv(e);return Array.isArray(t.captures)&&(t.captures=t.captures.map(n=>{if(!Iy(n)||!Iy(n.asset))return n;let{previewUrl:r,url:i,...o}=n.asset;if(r===void 0&&i===void 0)return n;let a=Object.keys(o).length>0?o:void 0;return a?{...n,asset:a}:{...n,asset:void 0}})),t}var ime=4;function Pz(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function vy(e){if(typeof e!="string")return e;let t=e.trim();if(!t)return e;try{return JSON.parse(t)}catch{return e}}function pl(e,...t){for(let n of t)if(n in e)return e[n]}function xy(e){return e==null?!1:typeof e!="string"||!!e.trim()}function ome(e){let t=pl(e,"text","TextInfo","textInfo","text_info");if(Pz(t))return pl(t,"content","Content","value","Value","text","Text")}function Dz(e,t=0){let n=vy(e);if(!Pz(n))return n;let r=ome(n);if(xy(r)&&t<ime)return Dz(r,t+1);let i=pl(n,"content","Content","AssetContent","asset_content");if(xy(i))return vy(i);let o=pl(n,"data","Data");if(xy(o))return vy(o);let a=pl(n,"value","Value");return xy(a)?vy(a):n}function ls(e){let t=Rz(Dz(e));return _i(t)?t:void 0}var Ez=1,Mz="compact-v1",Dy={type:"constant"};function ot(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function vn(e){return Array.isArray(e)?e.map(t=>vn(t)):ot(e)?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,vn(n)])):e}function Ry(e){if(typeof e!="string")return e;let t=e.trim();if(!t)return e;try{return JSON.parse(t)}catch{return e}}function ll(e,...t){for(let n of t)if(n in e)return e[n]}function Py(e){return!(e==null||typeof e=="string"&&!e.trim())}function ame(e){let t=ll(e,"text","TextInfo","textInfo","text_info");if(ot(t))return ll(t,"content","Content","value","Value","text","Text")}function Nz(e,t=0){let n=Ry(e);if(!ot(n))return n;let r=ame(n);if(Py(r)&&t<4)return Nz(r,t+1);let i=ll(n,"content","Content","AssetContent","asset_content");if(Py(i))return Ry(i);let o=ll(n,"data","Data");if(Py(o))return Ry(o);let a=ll(n,"value","Value");return Py(a)?Ry(a):n}function wz(e){if(!(!ot(e)||!ot(e.timeline)||!ot(e.timeline.animation)))return e.timeline.animation}function kz(e){var n;let t=(n=wz(e))==null?void 0:n.fcurves;return Array.isArray(t)?t.filter(ot):[]}function ms(e){let t=wz(e);if(!t)return;let n=t.fcurvesRef??t.fcurveAssetRef;return DO(n)?n:void 0}function sme(e){return kz(e).length>0}function Oz(e){return sme(e)&&!ms(e)}function cme(e){return ot(e)&&e.type==="node"&&typeof e.nodeId=="string"&&e.nodeId.trim()?["node",e.nodeId]:["environment"]}function dme(e){return Array.isArray(e)&&e[0]==="node"&&typeof e[1]=="string"&&e[1].trim()?{type:"node",nodeId:e[1]}:{type:"environment"}}function ume(e){let t=[typeof e.frame=="number"?e.frame:0,typeof e.value=="number"?e.value:0,typeof e.interpolation=="string"?e.interpolation:"linear",typeof e.id=="string"&&e.id.trim()?e.id:""];return e.handleLeft!==void 0&&(t[4]=vn(e.handleLeft)),e.handleRight!==void 0&&(t[5]=vn(e.handleRight)),t}function pme(e,t,n){if(!Array.isArray(e))return;let r=typeof e[0]=="number"?e[0]:0,i=typeof e[1]=="number"?e[1]:0,o=typeof e[2]=="string"&&e[2].trim()?e[2]:"linear";return{id:typeof e[3]=="string"&&e[3].trim()?e[3]:`${t}_kf_${n}`,frame:r,value:i,interpolation:o,...e[4]!==void 0?{handleLeft:vn(e[4])}:{},...e[5]!==void 0?{handleRight:vn(e[5])}:{}}}function Kv(e){return{version:Ez,encoding:Mz,fcurves:e.map(t=>({id:typeof t.id=="string"&&t.id.trim()?t.id:"",t:cme(t.target),p:typeof t.dataPath=="string"?t.dataPath:"",i:typeof t.arrayIndex=="number"?t.arrayIndex:0,k:Array.isArray(t.keyframes)?t.keyframes.filter(ot).map(ume):[],...t.enabled===!1?{e:!1}:{},...typeof t.group=="string"&&t.group.trim()?{g:t.group}:{},...ot(t.extrapolationBefore)&&t.extrapolationBefore.type!==Dy.type?{eb:vn(t.extrapolationBefore)}:{},...ot(t.extrapolationAfter)&&t.extrapolationAfter.type!==Dy.type?{ea:vn(t.extrapolationAfter)}:{}}))}}function lme(e){if(ot(e)&&e.version===Ez&&e.encoding===Mz&&Array.isArray(e.fcurves))return e.fcurves.filter(ot).map((t,n)=>{let r=typeof t.id=="string"&&t.id.trim()?t.id:`fc_${n}_${typeof t.p=="string"?t.p.replace(/[^a-zA-Z0-9]+/g,"_"):"curve"}`;return{id:r,target:dme(t.t),dataPath:typeof t.p=="string"?t.p:"",arrayIndex:typeof t.i=="number"?t.i:0,keyframes:Array.isArray(t.k)?t.k.map((i,o)=>pme(i,r,o)).filter(ot):[],extrapolationBefore:ot(t.eb)?vn(t.eb):{...Dy},extrapolationAfter:ot(t.ea)?vn(t.ea):{...Dy},enabled:t.e!==!1,...typeof t.g=="string"&&t.g.trim()?{group:t.g}:{}}})}function cd(e){return lme(Nz(e))}function mme({fcurves:e,fcurvesAssetId:t,sourceDocumentAssetId:n}){return{pippitAssetId:t,type:yi,content:Kv(e),extra:{...n?{sourceDocumentAssetId:n}:{}}}}function Lz(e,t){if(!ot(e))return;let n=vn(e),r=ot(n.timeline)?n.timeline:{},i=ot(r.animation)?r.animation:{};return n.timeline={...r,animation:{...i,fcurves:vn(t)}},n}function Fz({document:e,fcurvesAssetId:t,sourceDocumentAssetId:n}){let r=kz(e),i=ms(e);if(!r.length&&!i)return{document:e};if(!i&&!t)throw new Error("scene3d director fcurves asset id is required");let o=i??EO(t),a=vn(e),s=ot(a.timeline)?a.timeline:{},c=ot(s.animation)?s.animation:{};return a.timeline={...s,animation:{...c,fcurves:[],fcurvesRef:o}},{document:a,fcurvesAsset:o.pippitAssetId?mme({fcurves:r,fcurvesAssetId:o.pippitAssetId,sourceDocumentAssetId:n}):void 0,fcurvesRef:o}}var fme=Object.fromEntries(Po.map(e=>{let t=Object.fromEntries(Object.entries(Vv[e]).map(([n,r])=>{let{unit:i,...o}={unit:void 0,...r};return[n,{...o,...i?{description:`Measured in ${i}.`}:{}}]}));return[e,{type:"object",properties:t,additionalProperties:!1,description:Object.keys(t).length?"Optional geometry parameters. Omitted values use the documented renderer defaults.":"Fixed SDK geometry preset with no configurable parameters. Omit parameters or pass {}."}]})),Bz=Po.map(e=>({if:{properties:{primitiveKind:{const:e}},required:["primitiveKind"]},then:{properties:{parameters:fme[e]}}}));var je={type:"string",minLength:1},Ur={type:"number"},Li={type:"integer",minimum:0,description:"Timeline frame index (not milliseconds); timeline.fps defines frame duration."},Ey={type:"number",exclusiveMinimum:0},fs={type:"boolean"},Gz={type:"number",minimum:0,description:"Offset within the source motion in seconds; fractional seconds are supported."},Vz=e=>({type:"array",items:e,minItems:1,uniqueItems:!0}),oe=(e,t=[])=>({type:"object",properties:e,required:t,additionalProperties:!1}),hs=oe({x:Ur,y:Ur,z:Ur},["x","y","z"]),qz={...oe({position:hs,rotation:hs,scale:hs}),description:"Position is metres; rotation is XYZ Euler degrees; scale is a dimensionless XYZ multiplier."},Kz=oe({projection:{enum:["perspective","orthographic"]},fovAxis:{enum:["vertical","horizontal"]},fov:{type:"number",exclusiveMinimum:0,exclusiveMaximum:180,description:"Field of view in degrees."},near:Ey,far:Ey,isPrimary:fs,lookAt:hs}),hme=oe({source:{enum:["click","draw"],description:"Authored paths only. Keyframe-derived paths are maintained by the SDK."},parameterization:{enum:Object.values(Do)},curve:{enum:["polyline","catmullRom"]},points:{type:"array",minItems:2,items:oe({id:je,position:hs,tangentIn:hs,tangentOut:hs,timeRatio:{type:"number",minimum:0,maximum:1}},["id","position"])},closed:fs,groundSnap:fs,smoothing:Ur},["source","curve","points"]),dd={id:je,name:je,transform:qz},gme={oneOf:[oe({...dd,kind:{const:"camera"},camera:Kz},["id","kind"]),oe({...dd,kind:{const:"character"},gender:{enum:["male","female","unknown"]},motionId:je,placeholder:fs,color:je},["id","kind"]),oe({...dd,kind:{const:"prop"},color:je,category:je},["id","kind"]),{...oe({...dd,kind:{const:"primitive"},primitiveKind:{enum:Po},parameters:{type:"object",description:"Effective parameters are defined per primitiveKind below."}},["id","kind","primitiveKind"]),allOf:Bz},oe({...dd,kind:{const:"light"},lightKind:{enum:["ambient","directional","point"]},intensity:{type:"number",minimum:0},color:je},["id","kind"]),oe({...dd,kind:{const:"path"},path:hme,visible:fs,locked:fs},["id","kind","path"])]},Fi={nodeId:je},jv={keyframeIds:Vz(je)},zz={enum:["hold","linear","bezier"],description:"hold keeps a value; linear interpolates; bezier uses handles."},yme={oneOf:[oe({type:{const:"node"},nodeId:je},["type","nodeId"]),oe({type:{const:"environment"}},["type"])]},Uz=oe({x:Ur,y:Ur},["x","y"]),_me={create_node:gme,remove_node:oe(Fi,["nodeId"]),rename_node:oe({...Fi,name:je},["nodeId","name"]),update_transform:oe({...Fi,transform:qz,frame:Li},["nodeId","transform"]),update_camera:oe({...Fi,camera:Kz,frame:Li},["nodeId","camera"]),set_active_camera:oe(Fi,["nodeId"]),toggle_visible:oe(Fi,["nodeId"]),toggle_lock:oe(Fi,["nodeId"]),group_nodes:oe({nodeIds:{...Vz(je),minItems:2},name:je},["nodeIds","name"]),ungroup_node:oe(Fi,["nodeId"]),update_group_layout:oe({...Fi,layout:oe({perRow:{type:"integer",minimum:1},perColumn:{type:"integer",minimum:1},spacingDepth:Ur,spacingWidth:Ur})},["nodeId","layout"]),upsert_keyframe:oe({target:yme,dataPath:{type:"string",enum:[...new Set(Iv.map(e=>e.dataPath))],description:"Use query with objectId for supported paths and arrayIndexes for this object."},arrayIndex:{type:"integer",minimum:0,maximum:2},frame:Li,value:Ur,id:je,interpolation:zz,handleLeft:Uz,handleRight:Uz},["target","dataPath","arrayIndex","frame"]),remove_keyframes:oe(jv,["keyframeIds"]),move_keyframes:oe({...jv,deltaFrames:{type:"integer"}},["keyframeIds","deltaFrames"]),set_keyframe_interpolation:oe({...jv,interpolation:zz},["keyframeIds","interpolation"]),set_frame_range:oe({frameStart:Li,frameEnd:Li},["frameStart","frameEnd"]),apply_path_motion:oe({pathNodeId:je,targetNodeId:je,durationFrames:{type:"integer",minimum:1},startFrame:Li,lookAtStrategy:{enum:["path-tangent","target-node","current-look-at"]},lookAtTargetNodeId:je},["pathNodeId","targetNodeId"]),update_motion_clip:oe({clipId:je,patch:oe({frameStart:Li,frameEnd:Li,trimStart:Gz,trimEnd:Gz,playback:oe({version:{const:1},speed:Ey,loop:fs,loopMode:{enum:["repeat","ping-pong","none"]},phaseOffset:Ur,baseDurationFrames:Ey},["version","speed","loop"])})},["clipId","patch"]),remove_motion_clip:oe({clipId:je},["clipId"]),split_motion_clip:oe({clipId:je,frame:Li},["clipId","frame"]),reorder_motion_clip:oe({clipId:je,insertIndex:{type:"integer",minimum:0,description:"Zero-based position in the motion clip sequence."}},["clipId","insertIndex"])},My={...oe({nodeId:{...je,description:"ID of the outer biz/scene3d-director Canvas node."},dryRun:{type:"boolean",default:!1,description:"Validate and execute on a disposable document without allocating IDs or changing assets."},operations:{type:"array",minItems:1,maxItems:100,items:{oneOf:Object.entries(_me).map(([e,t])=>oe({command:{const:e},args:t},["command","args"]))}}},["nodeId","operations"]),description:"Edit a director document atomically using existing SDK commands. IDs inside operations identify 3D objects. Ordinary edits update base fields unless a keyframe already exists at frame (default 0); explicit keyframe/path/motion operations edit timeline data. No rendering, capture, upload or generation is performed.",examples:[{nodeId:"director-node",operations:[{command:"create_node",args:{kind:"camera",id:"camera-2",name:"Close-up"}},{command:"set_active_camera",args:{nodeId:"camera-2"}}]}]},ml=oe({nodeId:je,objectId:{...je,description:"Optional 3D object ID. Omit to read the whole document and environment property channels."}},["nodeId"]);var gs="xyq.scene3d.apply",fl="xyq.scene3d.query",jz={name:gs,inputSchema:My,input:"{nodeId, operations, dryRun?}",description:"Apply an atomic sequence of 3D director object, camera, group, keyframe and motion commands."};function Tme(e){let t=Ro(e,My);if(t)throw new Error(`${t.path}: ${t.message}`);return e}function Hz(e,t){var s;if(((s=M(e).nodes[t])==null?void 0:s.type)!==_n)throw new Error("scene3d Canvas node was not found");let n=Tc(e.assets[t]),r=(n==null?void 0:n.pippitAssetId)??t,i=ls(e.assets[r]);if(!i)throw new Error("scene3d document asset has not been loaded");let o=ms(i),a=i;if(o){let c=cd(e.assets[o.pippitAssetId]);if(!c)throw new Error("scene3d referenced fcurves asset has not been loaded");a=Lz(i,c)}return{document:a,documentAssetId:r}}function $z(e,t){let n=Ro(t,ml);if(n)throw new Error(`${n.path}: ${n.message}`);let{nodeId:r,objectId:i}=t,o=Hz(e.getState(),r);return{nodeId:r,documentAssetId:o.documentAssetId,...vz(o.document,i)}}function Yz(e,t={}){let n=new Map;function r(o){let a=Tme(o),s=Hz(e.getState(),a.nodeId);return{input:a,documentAssetId:s.documentAssetId,document:xz(s.document,a.operations)}}let i=e.commands.register(gs,(o,a)=>{try{let s=r(a);if(s.input.dryRun)return{status:"noop",reason:"no-changes"};let c=n.get(s.input.nodeId),d=Fz({document:s.document,fcurvesAssetId:c,sourceDocumentAssetId:s.documentAssetId}),u=e.transact(p=>{let m=p.assets[s.documentAssetId];if(!Object.hasOwn(p.assets,s.documentAssetId))throw new Error("scene3d document asset disappeared");if(m.content=d.document,d.fcurvesAsset){let f=d.fcurvesAsset.pippitAssetId,h=p.assets[f];Object.hasOwn(p.assets,f)?h.content=d.fcurvesAsset.content:p.assets[f]=d.fcurvesAsset}},{intent:gs});return u.status!=="aborted"&&n.delete(s.input.nodeId),u}catch(s){return{status:"aborted",reason:s instanceof Error?s.message:"scene3d command failed"}}});return{async prepare(o){let a=r(o);if(a.input.dryRun||!Oz(a.document)||n.has(a.input.nodeId))return;if(!t.allocateAssetId)throw new Error("scene3d keyframes require an asset ID allocator");let s=await t.allocateAssetId();if(!s||Object.hasOwn(e.getState().assets,s))throw new Error("scene3d allocator returned an invalid or existing asset ID");n.set(a.input.nodeId,s)},dispose(){n.clear(),i()}}}function Hv(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Sme(e,t,n){let r=t===yi?(()=>{let i=cd(n);if(!i)throw new Error(`scene3d fcurves asset ${e} has invalid content`);return Kv(i)})():ls(n);if(!r)throw new Error(`scene3d document asset ${e} has invalid content`);return{pippitAssetId:e,type:t,content:r,extra:Hv(n)&&Hv(n.extra)?n.extra:{}}}function bme(e,t){function n(r){return r.map(i=>{var c;let o=i.path===""&&Hv(i.value)?i.value:void 0;if(((o==null?void 0:o.type)??((c=t.assets[i.assetId])==null?void 0:c.type))!==yi||i.op==="remove"&&i.path==="")return i;if(i.path!==""&&i.path!=="/content")throw new Error("scene3d fcurves persistence requires an atomic compact-content patch");let s=i.path===""?o==null?void 0:o.content:i.value;if(!cd(s))throw new Error("scene3d fcurves patch has invalid compact content");return{...i,path:"",value:JSON.stringify(s)}})}return{...e,patches:n(e.patches),..."envelopes"in e?{envelopes:e.envelopes.map(r=>({...r,patches:n(r.patches)}))}:{}}}function Xz({transport:e,nodeIds:t,getDocument:n,queryAsset:r}){var c;let i=new Map,o=new Set(t);async function a(d,u){var f;i.set(d,u);let{asset:p,version:m}=await r(d);if(m===void 0||!Number.isSafeInteger(m)||m<0)throw new Error(`scene3d asset ${d} has no valid version`);return(f=e.assetVersions)==null||f.remember(d,m),{assetId:d,asset:Sme(d,u,p),assetVersion:m}}async function s(d){let u={...d.assets};return await Promise.all(Object.values(M(d).nodes).filter(p=>o.has(p.id)&&p.type===_n).map(async p=>{var y,_;let m=Tc(u[p.id]),f=(m==null?void 0:m.pippitAssetId)??p.id;if(m&&(i.set(f,_c),!ls(u[f])||((y=e.assetVersions)==null?void 0:y.getVersion(f))===void 0)){let S=await a(f,_c);u[f]=S.asset}let h=ls(u[f]),g=ms(h);if(g&&(i.set(g.pippitAssetId,yi),!cd(u[g.pippitAssetId])||((_=e.assetVersions)==null?void 0:_.getVersion(g.pippitAssetId))===void 0)){let S=await a(g.pippitAssetId,yi);u[S.assetId]=S.asset}})),{...d,assets:u}}return{...e,clientId:e.clientId,assetVersions:e.assetVersions,commit:d=>{let u=n();if(!u)throw new Error("scene3d command document is unavailable during commit");return e.commit(bme(d,u))},fetchSnapshot:async d=>{let u=await e.fetchSnapshot(d);return{...u,document:await s(u.document)}},fetchAssets:async d=>{var y,_;let u=n();for(let S of d){let T=(y=u==null?void 0:u.assets[S.assetId])==null?void 0:y.type;(T===_c||T===yi)&&i.set(S.assetId,T)}let p=d.filter(S=>i.has(S.assetId)),m=d.filter(S=>!i.has(S.assetId)),f=m.length?await((_=e.fetchAssets)==null?void 0:_.call(e,m)):{assets:[]};if(!f)throw new Error("scene3d command transport requires scoped asset loading");let h=await Promise.all(p.map(S=>a(S.assetId,i.get(S.assetId)))),g=[...f.assets,...h];for(let S of[...g].filter(T=>o.has(T.assetId))){let T=Tc(S.asset);T&&g.push(await a(T.pippitAssetId,_c))}for(let S of[...g].filter(T=>o.has(T.assetId)||i.has(T.assetId))){let T=ms(ls(S.asset));T&&!g.some(C=>C.assetId===T.pippitAssetId)&&g.push(await a(T.pippitAssetId,yi))}return{assets:g}},onInvalidate:e.onInvalidate.bind(e),onConnectionChange:e.onConnectionChange.bind(e),getConnectionState:e.getConnectionState.bind(e),syncAssetSubscriptions:(c=e.syncAssetSubscriptions)==null?void 0:c.bind(e),close:e.close.bind(e)}}function $v(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Wz(e){if(!e||!$v(e.input))return[];let{name:t,input:n}=e;if(t==="apply_mutations"){if(n.dryRun||!Array.isArray(n.mutations)||n.mutations.length!==1)return[];let[r]=n.mutations;if(!$v(r)||r.kind!=="invoke_command"||!Array.isArray(r.args))return[];t=String(r.name),n=r.args[0]}return t!==gs&&t!==fl?[]:$v(n)&&typeof n.nodeId=="string"&&n.nodeId?[n.nodeId]:[]}var Cme={clearNonRecoverableLocalUploadTasks:(e,t)=>{F0(t.getState(),t)}};function Jz(e){let t=Wz(e.command),n=rF({...e,generationAgUi:null,legacyGlobalContextBridge:!1,transportFactory:d=>{let u=e.transportFactory(d);return e.queryAsset&&t.length?Xz({transport:u,nodeIds:t,getDocument:()=>n.store.getState(),queryAsset:e.queryAsset}):u}},Cme),r=iF(n.store),i=EF(n.store),o=FF(n.store),a=Yz(n.store,{allocateAssetId:e.allocateAssetId}),s=n.dispose,c=!1;return n.dispose=()=>{if(!c){c=!0;try{r(),i(),o(),a.dispose()}finally{s()}}},{canvas:n,commands:n.store.commands,runtime:n.runtime,store:n.store,async prepareCommand(d,u){d===gs&&await a.prepare(u)}}}var Qz;function Zz(e){let t=globalThis.console;if(!t||typeof t!="object")return;let n=t[e];return typeof n=="function"?n.bind(t):void 0}function Yv(e,t){var n;(n=Zz(e))==null||n(...t),e==="error"&&Ame(t)}function Ame(e){var t;if(Qz)try{Qz({packageName:"xyq-canvas-sdk",message:Ime(e),error:vme(e),context:xme(e)})}catch(n){(t=Zz("warn"))==null||t("[xyq-canvas-sdk] error reporter failed",n)}}function Ime(e){return e.filter(n=>typeof n=="string"||typeof n=="number"||typeof n=="boolean").map(n=>String(n)).join(" ")||"[xyq-canvas-sdk] error"}function vme(e){for(let t of e){if(t instanceof Error)return t;if(eU(t)&&t.error instanceof Error)return t.error}}function xme(e){let t={},n=20;for(let r of e){if(n<=0)break;if(!(r instanceof Error)&&eU(r))for(let[i,o]of Object.entries(r)){if(n<=0)break;t[i]=Rme(o),n-=1}}return t}function Rme(e){var t;return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e.length>500?`${e.slice(0,500)}...`:e:e===null||typeof e=="number"||typeof e=="boolean"||typeof e>"u"?e:Array.isArray(e)?`[array:${e.length}]`:typeof e=="object"?`[object:${((t=e.constructor)==null?void 0:t.name)||"Object"}]`:String(e)}function eU(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}var Wt={error:(...e)=>Yv("error",e),info:(...e)=>Yv("info",e),warn:(...e)=>Yv("warn",e)};var Bi="biz/canvas-generation-history";function Xv(e){return Pe(e)&&e.type===Bi&&typeof e.pippitAssetId=="string"&&Pe(e.content)&&typeof e.content.ownerCanvasId=="string"&&typeof e.content.enabledAt=="string"&&Pe(e.content.recordsById)&&Pe(e.content.pendingRuns)}function hl(e){var i;let t=(i=e.assets[e.rootCanvasId])==null?void 0:i.extra;if(!Pe(t)||t.generationHistoryOwnerCanvasId!==e.rootCanvasId)return;let n=t.generationHistoryAssetId;if(typeof n!="string"||!n.trim())return;let r=e.assets[n];if(!(Xv(r)&&r.content.ownerCanvasId!==e.rootCanvasId))return n}var Ny=class{constructor(t,n=null,r=null){this.value=t,this.next=n,this.prev=r}},wy=class{get size(){return this._count}get firstNode(){return this._head}isEmpty(){return this._head===null}clear(){let t=this._head;for(;t!==null;){let n=t.next;t.prev=null,t.next=null,t=n}this._head=null,this._tail=null,this._count=0}unshift(t){let n=new Ny(t);if(this.isEmpty())this._head=n,this._tail=n;else{let r=this._head;this._head=n,n.next=r,r.prev=n}return this._count++,this}push(t){let n=new Ny(t);if(this.isEmpty())this._head=n,this._tail=n;else{let r=this._tail;this._tail=n,n.prev=r,r.next=n}return this._count++,this}shift(){if(this.isEmpty())return null;let t=this._head,n=t.value;return this._remove(t),n}pop(){if(this.isEmpty())return null;let t=this._tail,n=t.value;return this._remove(t),n}toArray(){let t=[];for(let n of this)t.push(n);return t}*[Symbol.iterator](){let t=this._head;for(;t!==null;)yield t.value,t=t.next}_remove(t){t.prev===null&&t.next===null&&t!==this._head&&t!==this._tail||(t===this._head&&(this._head=t.next,this._head&&(this._head.prev=null)),t===this._tail&&(this._tail=t.prev,this._tail&&(this._tail.next=null)),t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),t.prev=null,t.next=null,this._count--)}constructor(){this._head=null,this._tail=null,this._count=0}};var ud=class extends wy{unshiftAndGetDisposableNode(t){this.unshift(t);let n=this._head,r=!1;return()=>{r||(r=!0,super._remove(n))}}pushAndGetDisposableNode(t){this.push(t);let n=this._tail,r=!1;return()=>{r||(r=!0,super._remove(n))}}};function Wv(e){setTimeout(()=>{throw e},0)}var Jv=class{invoke(...t){this._callback.call(this._callbackThis,...t)}constructor(t,n){this._callback=t,this._callbackThis=n}},Qv=class{constructor(t,n,r){this.emitter=t,this.listener=n,this.event=r}},Zv=class{get size(){return this._queue.size}push(t,n,r){this._queue.push(new Qv(t,n,r))}clear(t){let n=new ud;for(let r of this._queue)r.emitter!==t&&n.push(r);this._queue=n}deliver(){for(;this._queue.size>0;){let t=this._queue.shift();try{t.listener.invoke(...t.event)}catch(n){this._onListenerError(n)}}}constructor(t=Wv){this._onListenerError=t,this._queue=new ud}},gl=class{get event(){return this._event?this._event:(this._event=(t,n)=>{var r;let i=new Jv(t,n);this._listeners||(this._listeners=new ud);let o=this._listeners.pushAndGetDisposableNode(i);return!((r=this._options)===null||r===void 0)&&r.onAddListener&&this._options.onAddListener(this,t,n),Yu(()=>{if(!this._disposed){var s;o(),!((s=this._options)===null||s===void 0)&&s.onRemoveListener&&this._options.onRemoveListener(this,t,n)}})},this._event)}dispose(){var t,n;this._disposed||(this._disposed=!0,(t=this._listeners)===null||t===void 0||t.clear(),(n=this._deliveryQueue)===null||n===void 0||n.clear(this))}fire(...t){var n;if(!(!this._listeners||this._listeners.size===0)){if(this._listeners.size===1){let o=this._listeners.firstNode;try{o.value.invoke(...t)}catch(a){var r;!((r=this._options)===null||r===void 0)&&r.onListenerError?this._options.onListenerError(a):Wv(a)}return}var i;(i=this._deliveryQueue)!==null&&i!==void 0||(this._deliveryQueue=new Zv((n=this._options)===null||n===void 0?void 0:n.onListenerError));for(let o of this._listeners)this._deliveryQueue.push(this,o,t);this._deliveryQueue.deliver()}}constructor(t){this._disposed=!1,this._options=t}};var Pme=.2,Jt=Math.ceil((16+4)/Pme);function z(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function se(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function yl(e,t=300){let n=e.replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,t)}...`:n}function tU(e,...t){if(e)for(let n of t){let r=e[n];if(z(r))return r}}var _l=La.getDefaultSize({}),rU=96,tx=48,nx=72,rx=120,iU=2,pd=48,oU=400,aU=3,ix=3,sU=Number.MAX_SAFE_INTEGER;function nU(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Dme(e){return se(e.id)}function ox(e,t){let n=Dme(t);if(!n)return;let r=e.assets[n];if(!(!z(r)||!z(r.content)))return r.content}function ex(e,t){var r;if(typeof t.order=="number"&&Number.isFinite(t.order))return t.order;let n=(r=ox(e,t))==null?void 0:r.order;return typeof n=="number"&&Number.isFinite(n)?n:sU}function cU(e,t){var r;if(typeof t.order=="number"&&Number.isFinite(t.order))return;let n=(r=ox(e,t))==null?void 0:r.order;return typeof n=="number"&&Number.isFinite(n)?n:void 0}function ys(e,t){return[...t].sort((n,r)=>{let i=ex(e,n),o=ex(e,r);return i!==o?i-o:String(n.id).localeCompare(String(r.id))})}function dU(e,t){let n=ox(e,t),r=z(n==null?void 0:n.basicInfo)?n.basicInfo:void 0,i=z(t.data)?t.data:void 0;return se(r==null?void 0:r.name)||se(i==null?void 0:i.name)||se(n==null?void 0:n.name)||se(n==null?void 0:n.nodeName)||se(r==null?void 0:r.appearanceName)||se(r==null?void 0:r.stageTag)||se(r==null?void 0:r.label)||String(t.id)}function ld(e,t){return{w:nU(e.w)?e.w:t.w,h:nU(e.h)?e.h:t.h}}function uU(e,t){let n=ld(e,t);return{...n,h:n.h+Jt}}function md(e,t){return Math.min(...t.map(n=>ex(e,n)))}function fd(e,t){return e.order-t.order}function ky(e){return e.stackHeight??e.height}function Vr(e){return(e==null?void 0:e.type)===Z}function qr(e){return(e==null?void 0:e.type)===Oe}function _s(e){return(e==null?void 0:e.type)===Ze&&Array.isArray(e.children)}function pU(e,t){let n=new Set;return e.children.map(r=>t[r]).filter(r=>!r||r.parentId!==e.id||n.has(r.id)?!1:(n.add(r.id),!0))}function lU(e){if(e.length!==0){if(e.filter(Vr).length===e.length)return"role";if(e.filter(qr).length===e.length)return"scene"}}function hd(e,t,n){let r=ld(t,n);return{order:md(e,[t]),width:r.w,height:r.h,stackHeight:r.h+Jt,apply:(i,o)=>{o.set(t.id,{x:i.x,y:i.y,width:r.w,height:r.h})}}}function Tl(e,t,n){var u;let r=[...e].sort(fd),i=Math.max(1,Math.min(n,Math.ceil(Math.sqrt(r.length)))),o=Math.ceil(r.length/i),a=new Map,s=0,c=0,d=0;return Array.from({length:o}).forEach((p,m)=>{let f=r.slice(m*i,(m+1)*i),h=0,g=Math.max(...f.map(_=>_.height),0),y=Math.max(...f.map(ky),0);f.forEach(_=>{a.set(_,{x:h,y:d+(g-_.height)/2}),h+=_.width+t}),s=Math.max(s,Math.max(0,h-t)),c=Math.max(c,d+g),d+=y+(m<o-1?t:0)}),{order:((u=r[0])==null?void 0:u.order)??sU,width:s,height:c,stackHeight:d,apply:(p,m)=>{r.forEach(f=>{let h=a.get(f)??{x:0,y:0};f.apply({x:p.x+h.x,y:p.y+h.y},m)})}}}var wR=am(l_());function m_(e,t){let n=new Set;return e.children.map(r=>t[r]).filter(r=>!r||r.parentId!==e.id||n.has(r.id)?!1:(n.add(r.id),!0))}function dW(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>{let r={...n};return Array.isArray(n.children)&&(r.children=[...n.children??[]]),[t,r]}))}function f_(e,t,n,r){let i=r[e.rootCanvasId],o=M(e);return{...e,assets:{...r,[e.rootCanvasId]:{...i,content:{...o,edges:n,nodes:t}}}}}function Dd(e){return{maxX:e.x+e.w,maxY:e.y+e.h+Jt,minX:e.x,minY:e.y}}function pr(e){let t=e.filter(n=>!!n);if(t.length!==0)return t.reduce((n,r)=>({maxX:Math.max(n.maxX,r.maxX),maxY:Math.max(n.maxY,r.maxY),minX:Math.min(n.minX,r.minX),minY:Math.min(n.minY,r.minY)}),{...t[0]})}function Yr(e,t){return!e||!t?e?-1:t?1:0:(e.order??0)-(t.order??0)||e.y-t.y||e.x-t.x||e.id.localeCompare(t.id)}function qNe(e){let t=[...e].sort(Yr),n=Math.max(1,Math.min(3,Math.ceil(Math.sqrt(t.length)))),r=Math.max(...t.map(a=>a.w),0),i=Math.max(...t.map(a=>a.h),0),o=new Map;return t.forEach((a,s)=>{o.set(a.id,{x:s%n*(r+80),y:Math.floor(s/n)*(i+Jt+64)})}),o}function pW(e,t,n,r=new Set){if(t===n)return!0;if(r.has(t))return!1;r.add(t);let i=e.get(t);if(!i)return!1;for(let o of i)if(pW(e,o,n,r))return!0;return!1}function KNe(e,t){let n=new Set(e.map(a=>a.id)),r=new Map,i=[],o=new Set;return[...t].sort((a,s)=>String(a.id).localeCompare(String(s.id))).forEach(a=>{if(!n.has(a.source)||!n.has(a.target)||a.source===a.target)return;let s=`${a.source}->${a.target}`;if(o.has(s)||pW(r,a.target,a.source))return;o.add(s);let c=r.get(a.source)??new Set;c.add(a.target),r.set(a.source,c),i.push(a)}),i}function uW(e,t,n,r){if(r.has(e))return r.get(e);let i=[],o=e,a;for(;o;){if(t.has(o)){a=o;break}if(i.includes(o))break;i.push(o);let s=n.get(o);o=typeof(s==null?void 0:s.parentId)=="string"?s.parentId:null}return r.set(e,a),i.forEach(s=>r.set(s,a)),a}function jNe(e,t,n){let r=new Set(e.map(s=>s.id)),i=new Map,o=new Set,a=[];return[...t].sort((s,c)=>String(s.id).localeCompare(String(c.id))).forEach(s=>{let c=uW(s.source,r,n,i),d=uW(s.target,r,n,i);if(!c||!d||c===d)return;let u=`${c}->${d}`;o.has(u)||(o.add(u),a.push({...s,id:`${String(s.id)}:layout:${u}`,source:c,target:d}))}),a}function HNe(e,t){if(t.length===0)return;let n=KNe(e,t);if(n.length===0)return;let r=new wR.default.graphlib.Graph;r.setDefaultEdgeLabel(()=>({})),r.setGraph({marginx:0,marginy:0,nodesep:64,rankdir:"LR",ranker:"tight-tree",ranksep:80});let i=[...e].sort(Yr),o=new Map;i.forEach(d=>{let u=d.h+Jt;o.set(d.id,u),r.setNode(d.id,{width:d.w,height:u})}),n.forEach(d=>r.setEdge(d.source,d.target)),wR.default.layout(r);let a=new Map,s=[];return i.forEach(d=>{let u=o.get(d.id)??d.h+Jt,p=r.node(d.id),m=(p==null?void 0:p.x)??d.w/2;s.push(m.toFixed(3)),a.set(d.id,{x:m-d.w/2,y:((p==null?void 0:p.y)??u/2)-u/2})}),new Set(s).size===a.size&&a.forEach((d,u)=>{a.set(u,{x:d.x,y:0})}),a}function $Ne(e,t){let n=new Set(e.map(a=>a.id)),r=t.filter(a=>n.has(a.source)&&n.has(a.target)),i=HNe(e,r)??qNe(e),o=pr(e.map(a=>{let s=i.get(a.id)??{x:0,y:0};return{maxX:s.x+a.w,maxY:s.y+a.h+Jt,minX:s.x,minY:s.y}}))??{minX:0,minY:0,maxX:1,maxY:1};return(o.minX!==0||o.minY!==0)&&i.forEach((a,s)=>{i.set(s,{x:a.x-o.minX,y:a.y-o.minY})}),{edges:r,height:Math.max(1,o.maxY-o.minY),nodes:e,relativePositions:i,width:Math.max(1,o.maxX-o.minX)}}function lW(e,t,n=e){let r=new Map(e.map(d=>[d.id,d])),i=new Map(n.map(d=>[d.id,d])),o=jNe(e,t,i),a=new Map;r.forEach((d,u)=>a.set(u,new Set)),o.forEach(d=>{var u,p;(u=a.get(d.source))==null||u.add(d.target),(p=a.get(d.target))==null||p.add(d.source)});let s=new Set,c=[];return e.sort(Yr).forEach(d=>{var f;if(s.has(d.id))return;let u=[],p=[d.id];for(s.add(d.id);p.length>0;){let h=p.shift();u.push(h),(f=a.get(h))==null||f.forEach(g=>{s.has(g)||(s.add(g),p.push(g))})}let m=u.map(h=>r.get(h)).filter(h=>!!h);c.push($Ne(m,o))}),c.sort((d,u)=>Yr(d.nodes[0],u.nodes[0]))}function YNe(e){return Math.max(1,Math.min(3,Math.ceil(Math.sqrt(e.length))))}function kR(e,t,n=YNe(e)){let r=[...e].sort((s,c)=>Yr(s.nodes[0],c.nodes[0])),i=Math.max(1,Math.min(n,r.length)),o=[],{y:a}=t;for(let s=0;s<r.length;s+=i){let c=r.slice(s,s+i),{x:d}=t,u=Math.max(...c.map(p=>p.height),0);for(let p of c)o.push({component:p,x:d,y:a+(u-p.height)/2}),d+=p.width+72;a+=u+72}return o}function hW(e,t,n){let r=pr([n,...e.map(({component:s,x:c,y:d})=>({maxX:c+s.width,maxY:d+s.height,minX:c,minY:d}))]);if(!r)return{aspectError:Number.POSITIVE_INFINITY,area:Number.POSITIVE_INFINITY};let i=r.maxX-r.minX,o=r.maxY-r.minY,a=i/Math.max(1,o);return{area:i*o,aspectError:Math.abs(Math.log(a/t))}}function gW(e,t,n,r){if(!n||e.length<=1)return kR(e,t);let i=e.length,o=kR(e,t,1),a=hW(o,n,r);for(let s=2;s<=i;s+=1){let c=kR(e,t,s),d=hW(c,n,r);(d.aspectError<a.aspectError||d.aspectError===a.aspectError&&d.area<a.area)&&(o=c,a=d)}return o}function XNe(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:void 0}function WNe(e){return pr([e.roleBounds,e.sceneBounds,...e.mixedBounds])}function JNe(e,t){let{roleBounds:n,sceneBounds:r}=e;return n&&r?{x:r.maxX+96,y:t.minY}:{x:t.maxX+96,y:t.minY}}function yW(e,t,n,r){let i=n?{x:n.minX,y:n.minY}:{x:0,y:0},o=XNe(r),a=WNe(t);return a?gW(e,JNe(t,a),o,a):gW(e,i,o)}function QNe(e,t){if(Vr(e))return"role";if(qr(e))return"scene";if(!_s(e))return;let n=m_(e,t);if(n.length===0)return;if(n.filter(Vr).length===n.length)return"role";if(n.filter(qr).length===n.length)return"scene"}function bW(e,t){if(Vr(e)||qr(e))return!0;if(!_s(e))return!1;let n=m_(e,t);return n.length>0&&n.every(r=>Vr(r)||qr(r))}function OR(e,t){return bW(e,t)?!1:e.type===et||e.type===ee||e.type===qe||e.type===fe||e.type===J||_s(e)}function Xo(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Xr(e){return typeof e=="number"&&Number.isFinite(e)}function Ki(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function LR(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function ZNe(e){return(e==null?void 0:e.type)===et||(e==null?void 0:e.type)===ee||(e==null?void 0:e.type)===qe||(e==null?void 0:e.type)===fe||(e==null?void 0:e.type)===J}function _W(e){if(!(!Ki(e)||!Ki(e.content)))return e.content}function ewe(e,t){if(!t)return;let n=_W(e[t]);if(n)return n;for(let r of Object.values(e)){if(!Ki(r)||LR(r.pippitAssetId)!==t)continue;let i=_W(r);if(i)return i}}function CW(e){let{data:t}=e;return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function twe(e,t){let n=Ki(e)?e:void 0,r=LR(n==null?void 0:n.pippitAssetId)||LR(e.id);return ewe(t,r)}function TW(e,t){let n=CW(e),r=twe(e,t);if(!r)return n;let i=Ki(r.data)?r.data:r,o={...n,...i};return(Ki(n.metadata)||Ki(i.metadata))&&(o.metadata={...Ki(n.metadata)?n.metadata:{},...Ki(i.metadata)?i.metadata:{}}),o}function SW({defaultSize:e,mediaSize:t}){let n=t.w>0&&t.h>0?t.w/t.h:void 0;if(!n)return e;let r=Math.max(1,e.w*e.h);return{w:Math.round(Math.sqrt(r*n)),h:Math.round(Math.sqrt(r/n))}}function nwe(e,t){var r,i,o,a,s,c,d,u,p,m,f,h,g,y;let n=CW(e);switch(e.type){case et:return((i=(r=mo).getDefaultSize)==null?void 0:i.call(r,n))??{w:420,h:180};case ee:{let _=TW(e,t),S=((a=(o=fi).getDefaultSize)==null?void 0:a.call(o,{}))??{w:480,h:373},T=((c=(s=fi).getDefaultSize)==null?void 0:c.call(s,_))??S;return SW({defaultSize:S,mediaSize:T})}case qe:return((u=(d=Nh).getDefaultSize)==null?void 0:u.call(d,n))??{w:320,h:180};case fe:return((m=(p=lo).getDefaultSize)==null?void 0:m.call(p,n))??{w:362,h:218};case J:{let _=TW(e,t),S=((h=(f=hi).getDefaultSize)==null?void 0:h.call(f,{}))??{w:480,h:270},T=((y=(g=hi).getDefaultSize)==null?void 0:y.call(g,_))??S;return SW({defaultSize:S,mediaSize:T})}default:return}}function Wo(e){return Xr(e.x)&&Xr(e.y)&&Xo(e.w)&&Xo(e.h)}function FR(e,t){let n=!1;if(Xr(e.x)||(e.x=0,n=!0),Xr(e.y)||(e.y=0,n=!0),Xo(e.w)&&Xo(e.h))return n;let r=nwe(e,t);return r&&(Xo(e.w)||(e.w=r.w,n=!0),Xo(e.h)||(e.h=r.h,n=!0)),n}function BR(e){return!Xr(e.x)||!Xr(e.y)||e.x===0&&e.y===0}function AW(e,t){let n=pr(t.filter(Wo).map(Dd));if(!n)return!1;let r=!1,i=n.maxX+80,o=n.minY;return[...e].sort(Yr).forEach(a=>{Wo(a)&&(a.x!==i&&(a.x=i,r=!0),a.y!==o&&(a.y=o,r=!0),i+=a.w+80)}),r}function IW(e,t,n){let r=Sa(e)?Su(e):{w:e.w,h:e.h},i=Xo(r.w)?Math.max(r.w,t):t,o=Xo(r.h)?Math.max(r.h,n):n;return i===r.w&&o===r.h?!1:(bu(e,{w:i,h:o}),!0)}function rwe(e,t){let n=pr(t.filter(Wo).map(a=>({maxX:a.x+a.w,maxY:a.y+a.h+Jt,minX:a.x,minY:a.y})));if(!n)return!1;let r=!1;Xr(e.x)||(e.x=0,r=!0),Xr(e.y)||(e.y=0,r=!0);let i=Math.max(40*2,n.maxX+40),o=Math.max(40*2,n.maxY+40);return IW(e,i,o)||r}function iwe(e,t,n,r){let i=m_(e,t).filter(ZNe),o=i.filter(g=>!Wo(g));if(i.length===0||o.length===0)return!1;let a=new Set(o.filter(BR).map(g=>g.id)),s=!1;if(o.forEach(g=>{s=FR(g,n)||s}),r&&o.length<i.length){let g=i.filter(_=>a.has(_.id)),y=i.filter(_=>!a.has(_.id)&&Wo(_));return s=AW(g,y)||s,rwe(e,i)||s}let c=[...i].sort(Yr),d=Math.max(1,Math.min(3,Math.ceil(Math.sqrt(c.length)))),u=Math.ceil(c.length/d),p=Math.max(...c.map(g=>g.w),1),m=Math.max(...c.map(g=>g.h+Jt),1);c.forEach((g,y)=>{let _=40+y%d*(p+80),S=40+Math.floor(y/d)*(m+64);g.x!==_&&(g.x=_,s=!0),g.y!==S&&(g.y=S,s=!0)});let f=40*2+d*p+Math.max(0,d-1)*80,h=40*2+u*m+Math.max(0,u-1)*64;return Xr(e.x)||(e.x=0,s=!0),Xr(e.y)||(e.y=0,s=!0),IW(e,f,h)||s}function owe(e,t,n,r){let i=!1;return e.forEach(o=>{!_s(o)||!OR(o,t)||(i=iwe(o,t,n,r)||i)}),i}function awe(e,t){let n=[],r=[],i=[];return e.forEach(o=>{let a=QNe(o,t);if(a==="role"){n.push(Dd(o));return}if(a==="scene"){r.push(Dd(o));return}bW(o,t)&&i.push(Dd(o))}),{mixedBounds:i,roleBounds:pr(n),sceneBounds:pr(r)}}function vW(e,t){let n=M(e),r=dW(n.nodes),i=Object.values(r).filter(y=>(y.parentId??null)===null),o=t.repairInvalidOnly===!0,a=o?new Set(i.filter(y=>OR(y,r)).filter(y=>!Wo(y)&&BR(y)).map(y=>y.id)):new Set,s=owe(i,r,e.assets,o),c=awe(i,r),d=i.filter(y=>OR(y,r));if(d.length===0)return s?f_(e,r,n.edges,e.assets):e;let u=d.filter(y=>!Wo(y)),p=new Set([...a,...u.filter(BR).map(y=>y.id)]),m=!1;if(u.forEach(y=>{m=FR(y,e.assets)||m}),o&&u.length<d.length){let y=d.filter(S=>p.has(S.id)),_=d.filter(S=>!p.has(S.id)&&Wo(S));if(y.length===0||_.length>0)return m=AW(y,_)||m,s||m?f_(e,r,n.edges,e.assets):e}o||d.forEach(y=>{m=FR(y,e.assets)||m});let f=lW(d,Object.values(n.edges),Object.values(r));if(f.length===0)return e;let h=pr(d.map(y=>Dd(y)));return yW(f,c,h,t.aspectRatio).forEach(({component:y,x:_,y:S})=>{y.relativePositions.forEach((T,C)=>{let I=r[C];I&&(I.x=_+T.x,I.y=S+T.y)})}),f_(e,r,n.edges,e.assets)}var Wl=class extends Error{constructor(n){super(n);this.restoreFailureReason="empty-text-asset";this.name="CanvasAssetNotFoundError"}},GR=class extends Error{constructor(n,r=n.length){super("Canvas restore is missing required companion node assets");this.retryable=!1;this.restoreFailureReason="missing-node-assets";this.name="CanvasMissingNodeAssetsError",this.missingNodeAssetCount=Math.max(r,n.length),this.missingNodeAssetIdsPreview=n.slice(0,10)}};function xW(e){return e instanceof GR||e instanceof Error&&e.restoreFailureReason==="missing-node-assets"}function zR(e,t){return!!(t!=null&&t.aborted||e instanceof Error&&e.name==="AbortError"||typeof DOMException<"u"&&e instanceof DOMException&&e.name==="AbortError")}function UR(e){if(e instanceof Wl||xW(e))return e.restoreFailureReason}function RW(e){return xW(e)?{missing_node_asset_count:e.missingNodeAssetCount,missing_node_asset_ids_preview:e.missingNodeAssetIdsPreview}:{}}function PW(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown canvas restore failure")}var jR=am(l_());var VR=am(l_());function swe(e,t){let n=[],r=new Map;return ys(e,t).forEach(i=>{let o=dU(e,i),a=r.get(o);a||(a=[],r.set(o,a),n.push(a)),a.push(i)}),n}function cwe(e,t,n){let r=t;for(;r;){if(r===n)return!0;r=e.get(r)}return!1}function dwe(e,t){let n=new Set(e.map(o=>o.id)),r=new Map,i=[];return[...t].sort((o,a)=>String(o.id).localeCompare(String(a.id))).forEach(o=>{!n.has(o.source)||!n.has(o.target)||o.source===o.target||r.has(o.target)||cwe(r,o.source,o.target)||(r.set(o.target,o.source),i.push(o))}),i}function uwe(e,t,n){if(t.length===1)return hd(e,t[0],_l);let r=new VR.default.graphlib.Graph;r.setDefaultEdgeLabel(()=>({})),r.setGraph({rankdir:"LR",nodesep:tx,ranksep:rU,ranker:"tight-tree",marginx:0,marginy:0});let i=ys(e,t),o=new Map,a=new Map;i.forEach(m=>{let f=ld(m,_l),h=uU(m,_l);o.set(m.id,f),a.set(m.id,h),r.setNode(m.id,{width:h.w,height:h.h})}),dwe(i,n).forEach(m=>r.setEdge(m.source,m.target)),VR.default.layout(r);let s=new Map,c=Number.POSITIVE_INFINITY,d=Number.POSITIVE_INFINITY,u=Number.NEGATIVE_INFINITY,p=Number.NEGATIVE_INFINITY;return i.forEach(m=>{let f=o.get(m.id)??_l,h=a.get(m.id)??f,g=r.node(m.id),y=((g==null?void 0:g.x)??h.w/2)-h.w/2,_=((g==null?void 0:g.y)??h.h/2)-h.h/2;s.set(m.id,{x:y,y:_,width:f.w,height:f.h}),c=Math.min(c,y),d=Math.min(d,_),u=Math.max(u,y+h.w),p=Math.max(p,_+h.h)}),{order:md(e,i),width:Math.max(1,u-c),height:Math.max(1,p-d),apply:(m,f)=>{s.forEach((h,g)=>{f.set(g,{x:m.x+h.x-c,y:m.y+h.y-d,width:h.width,height:h.height})})}}}function pwe(e,t){return fd(e.block,t.block)}function qR(e,t,n){return swe(e,t).map(r=>({kind:r.length===1?"single":"group",block:uwe(e,r,n)}))}function KR(e){let t=[],n=[],r=()=>{n.length!==0&&(t.push(Tl(n,tx,aU)),n=[])};return[...e].sort(pwe).forEach(i=>{if(i.kind==="single"){n.push(i.block);return}r(),t.push(i.block)}),r(),t}function DW(e,t,n){return KR(qR(e,t,n))}function EW(e,t,n,r=new Set){if(t===n)return!0;if(r.has(t))return!1;r.add(t);let i=e.get(t);if(!i)return!1;for(let o of i)if(EW(e,o,n,r))return!0;return!1}function lwe(e,t){let n=new Set(e.map(o=>o.id)),r=new Map,i=[];return[...t].sort((o,a)=>String(o.id).localeCompare(String(a.id))).forEach(o=>{if(!n.has(o.source)||!n.has(o.target)||o.source===o.target||EW(r,o.target,o.source))return;let a=r.get(o.source)??new Set;a.add(o.target),r.set(o.source,a),i.push(o)}),i}function mwe(e,t,n,r,i,o){if(t.length===0)return;if(t.length===1)return hd(e,t[0],r);let a=lwe(t,n);if(a.length===0)return;let s=new jR.default.graphlib.Graph;s.setDefaultEdgeLabel(()=>({})),s.setGraph({rankdir:"LR",nodesep:i,ranksep:o,ranker:"tight-tree",marginx:0,marginy:0});let c=ys(e,t),d=new Map;c.forEach(g=>{let y=ld(g,r);d.set(g.id,y),s.setNode(g.id,{width:y.w,height:y.h})}),a.forEach(g=>s.setEdge(g.source,g.target)),jR.default.layout(s);let u=new Map,p=Number.POSITIVE_INFINITY,m=Number.POSITIVE_INFINITY,f=Number.NEGATIVE_INFINITY,h=Number.NEGATIVE_INFINITY;return c.forEach(g=>{let y=d.get(g.id)??r,_=s.node(g.id),S=((_==null?void 0:_.x)??y.w/2)-y.w/2,T=((_==null?void 0:_.y)??y.h/2)-y.h/2;u.set(g.id,{x:S,y:T,width:y.w,height:y.h}),p=Math.min(p,S),m=Math.min(m,T),f=Math.max(f,S+y.w),h=Math.max(h,T+y.h)}),{order:md(e,c),width:Math.max(1,f-p),height:Math.max(1,h-m),apply:(g,y)=>{u.forEach((_,S)=>{y.set(S,{x:g.x+_.x-p,y:g.y+_.y-m,width:_.width,height:_.height})})}}}function MW(e,t,n,r){let{y:i}=t,o=0,a=0;return[...e].sort(fd).forEach((s,c)=>{c>0&&(i+=n),s.apply({x:t.x,y:i},r),i+=ky(s),o=Math.max(o,s.width),a=i-t.y}),{width:o,height:a}}function fwe(e,t,n){let r=[...e].sort(fd);if(r.length===0)return{width:0,height:0};let i=Math.max(1,Math.min(iU,Math.ceil(Math.sqrt(r.length)))),o=Array.from({length:i},()=>({items:[],width:0,height:0}));r.forEach(s=>{let c=o.reduce((u,p)=>p.height<u.height||p.height===u.height&&p.items.length<u.items.length?p:u),d=c.height>0?c.height+nx:0;c.items.push({block:s,y:d}),c.width=Math.max(c.width,s.width),c.height=d+ky(s)});let a=o.map((s,c)=>o.slice(0,c).reduce((d,u)=>d+u.width+rx,0));return o.forEach((s,c)=>{s.items.forEach(({block:d,y:u})=>{d.apply({x:t.x+a[c],y:t.y+u},n)})}),{width:o.reduce((s,c)=>s+c.width,0)+rx*(o.length-1),height:Math.max(...o.map(s=>s.height))}}function hwe(e,t,n=[]){let r=mwe(e,t,n,Ga,pd,pd);if(r)return r;let i=ys(e,t).map(o=>hd(e,o,Ga));return i.length>0?Tl(i,pd,ix):void 0}function gwe(e){let t;for(let n of e){let r={minX:n.x,minY:n.y,maxX:n.x+n.width,maxY:n.y+n.height};t=t?{minX:Math.min(t.minX,r.minX),minY:Math.min(t.minY,r.minY),maxX:Math.max(t.maxX,r.maxX),maxY:Math.max(t.maxY,r.maxY)}:r}return t}function ywe(e,t,n,r,i){let o=i==="role"?DW(e,n.filter(Vr),r):[hwe(e,n.filter(qr),r)].filter(u=>!!u);if(o.length===0)return;let a=new Map;MW(o,{x:0,y:0},nx,a);let s=gwe(a.values())??{minX:0,minY:0,maxX:1,maxY:1},c=Math.max(1,s.maxX-s.minX+40*2),d=Math.max(1,s.maxY-s.minY+40*2);return{order:md(e,n),width:c,height:d,stackHeight:d+Jt,apply:(u,p)=>{p.set(t.id,{x:u.x,y:u.y,width:c,height:d}),a.forEach((m,f)=>{p.set(f,{...m,x:m.x-s.minX+40,y:m.y-s.minY+40})})}}}function NW(e,t,n){let r=new Map,o=ys(e,Object.values(t)).filter(f=>!f.parentId),a=qR(e,o.filter(Vr),n),c=o.filter(qr).map(f=>hd(e,f,Ga));o.filter(_s).forEach(f=>{let h=pU(f,t),g=lU(h);if(!g)return;let y=ywe(e,f,h,n,g);if(y){if(g==="role"){a.push({kind:"group",block:y});return}g==="scene"&&c.push(y)}});let d=KR(a),u=c.length>0?Tl(c,pd,ix):void 0,p=fwe(d,{x:0,y:0},r),m=d.length>0?p.width+oU:0;return MW(u?[u]:[],{x:m,y:0},pd,r),r}var h_={name:"role-tree-scene-columns",layout(e){let t=M(e),n=NW(e,t.nodes,Object.values(t.edges)),r={},i=!1;if(Object.values(t.nodes).forEach(a=>{let s=n.get(a.id),c=cU(e,a),d=s||c!==void 0?{...a,...c!==void 0?{order:c}:{},...s?{x:s.x,y:s.y,w:s.width,h:s.height}:{}}:a;r[a.id]=d,d!==a&&(d.x!==a.x||d.y!==a.y||d.w!==a.w||d.h!==a.h||d.order!==a.order)&&(i=!0)}),!i)return e;let o=e.assets[e.rootCanvasId];return{...e,assets:{...e.assets,[e.rootCanvasId]:{...o,content:{...t,nodes:r}}}}}};var HR="[novel-detail-canvas]";function _we(){var t,n;let e=globalThis.process;return((t=e==null?void 0:e.env)==null?void 0:t.JEST_WORKER_ID)==null&&((n=e==null?void 0:e.env)==null?void 0:n.VITEST)==null}function Twe(e){let{error:t,...n}=e.payload??{},r=z(t)?t:void 0,i=typeof(r==null?void 0:r.name)=="string"?r.name:void 0,o=typeof(r==null?void 0:r.message)=="string"?r.message:void 0;return{canvasAssetId:e.canvasAssetId,...n,...i?{canvas_restore_error_name:yl(i,128)}:{},...o?{canvas_restore_error_message:yl(o,256)}:{}}}function wW(e,t={},n){var o;if((o=t.logger)==null||o.call(t,e),!_we()||t.debugLog===!1&&e.level==="info")return;let r=Twe(e),i=n===void 0?void 0:PW(n);if(e.level==="error"){Wt.error(HR,e.type,...i?[i,r]:[r]);return}if(e.level==="warn"){Wt.warn(HR,e.type,...i?[i,r]:[r]);return}Wt.info(HR,e.type,...i?[i,r]:[r])}function Jl(e){let t=z(e.assets)?e.assets:{},n=t[e.rootCanvasId],r=z(n)&&z(n.content)?n.content:null,i=r&&z(r.nodes)?r.nodes:null,o=r&&z(r.edges)?r.edges:null;return{rootCanvasId:e.rootCanvasId,assetKeys:Object.keys(t).slice(0,20),rootAssetKeys:z(n)?Object.keys(n).slice(0,30):[],nodeCount:i?Object.keys(i).length:void 0,edgeCount:o?Object.keys(o).length:void 0}}function g_(e){if(e==null)return{type:String(e)};if(typeof e=="string")return{type:"string",length:e.length,preview:yl(e)};if(Array.isArray(e))return{type:"array",length:e.length,first:g_(e[0])};if(typeof e=="object"){let t=e;return{type:"object",keys:Object.keys(t).slice(0,50),rootCanvasId:t.rootCanvasId,root_canvas_id:t.root_canvas_id,typeField:t.type,hasAssets:z(t.assets),hasContent:t.content!=null,hasData:t.data!=null,hasDocument:t.document!=null,hasCanvasDocument:t.canvasDocument!=null,hasSnapshot:t.snapshot!=null}}return{type:typeof e,value:e}}function Ed(e){return{pippitAssetId:e.pippitAssetId,value:g_(e.value),extra:g_(e.extra)}}function Wr(e){return e instanceof Error?{name:e.name,message:e.message,stack:yl(e.stack??"",500)}:g_(e)}function Md(e){let t=z(e)?e:void 0;return se(t==null?void 0:t.pippitAssetId)||se(t==null?void 0:t.id)}var Swe=new Set([ee,qe,J]),bwe=new Set([Z,Oe]);function OW(e,t){let n=Md(t);return n?e.assets[n]:void 0}function Cwe(e,t){let n=z(t.data)?t.data:{},r=OW(e,t),i=z(r)&&z(r.content)?r.content:{};return{...n,...i}}function kW(e){let t=z(e.appearanceInfo)?e.appearanceInfo:void 0;return se(t==null?void 0:t.pippitAssetId)||se(t==null?void 0:t.PippitAssetID)}function Awe(e,t){if(t.type===_n)return NO(OW(e,t));let n=Cwe(e,t);if(bwe.has(t.type))return kW(n);if(Swe.has(t.type))return se(n.pippitAssetId)||kW(n)}function $R(e,t){let n=new Set;return Object.values(M(e).nodes).forEach(r=>{let i=Md(r);if(t&&(!i||!t.has(i)))return;let o=Awe(e,r);o&&n.add(o)}),[...n].sort()}var LW=150,Iwe=10;function vwe(e,t){return!!(t!=null&&t.aborted||e instanceof Error&&e.name==="AbortError"||typeof DOMException<"u"&&e instanceof DOMException&&e.name==="AbortError")}function FW(e){let t=[],n=new Set,r=new Set,i=0,o=()=>{i||t.length||(r.forEach(s=>s()),r.clear())},a=()=>{var u;if((u=e.signal)!=null&&u.aborted){t.splice(0),o();return}let s=Iwe-i;if(s<=0||t.length===0){o();return}let c=t.splice(0,s*LW);oi(c,LW,s).forEach(p=>{i+=1,e.emit({type:"cover-assets-query:start",level:"info",canvasAssetId:e.canvasAssetId,payload:{assetIds:p}}),e.prefetchCoverAssets({pippitAssetIds:p,signal:e.signal}).then(()=>{e.emit({type:"cover-assets-query:success",level:"info",canvasAssetId:e.canvasAssetId,payload:{assetIds:p}})}).catch(m=>{vwe(m,e.signal)||(e.emit({type:"cover-assets-query:error",level:"warn",canvasAssetId:e.canvasAssetId,payload:{assetIds:p,error:Wr(m)}}),Wt.warn("[xyq-canvas] Failed to prefetch canvas cover assets",{canvasAssetId:e.canvasAssetId,assetIds:p,error:Wr(m)}))}).finally(()=>{i-=1,a()})})};return{enqueue(s){s.forEach(c=>{let d=se(c);!d||n.has(d)||(n.add(d),t.push(d))}),a()},waitForIdle(){return!i&&t.length===0?Promise.resolve():new Promise(s=>r.add(s))}}}var zW=150,Jo=10;function xwe(e,t){let n={pippitAssetIds:e,isCamelCase:!0};return t&&(n.signal=t),n}function UW(e){let t=0,n=[],r=()=>t<e?(t+=1,Promise.resolve()):new Promise(o=>{n.push(()=>{t+=1,o()})}),i=()=>{var o;t-=1,(o=n.shift())==null||o()};return{async run(o){await r();try{return await o()}finally{i()}}}}function BW(e){if(e.reason instanceof Error)return e.reason;let t=new Error("Canvas node asset query aborted");return t.name="AbortError",t}function VW(e,t){return!!(t!=null&&t.aborted||e instanceof Error&&e.name==="AbortError"||typeof DOMException<"u"&&e instanceof DOMException&&e.name==="AbortError")}function qW(e,t){let n=async()=>{var o,a;if((o=t.signal)!=null&&o.aborted)throw BW(t.signal);let r=xwe(e,t.signal),i=await(t.queryTextAssetContent.queryImmediately?t.queryTextAssetContent.queryImmediately(r):t.queryTextAssetContent(r));if((a=t.signal)!=null&&a.aborted)throw BW(t.signal);return i};return t.queryLimiter?t.queryLimiter.run(n):n()}async function YR(e,t,n){let r=new Array(e.length),i=0,o=async()=>{for(;i<e.length;){let s=i;i+=1;let c=e[s];if(c===void 0)return;r[s]=await n(c)}},a=Math.min(t,e.length);return await Promise.all(Array.from({length:a},()=>o())),r}async function Rwe(e,t){return(await YR(e,Jo,async r=>{try{let i=await qW([r],t);return Array.isArray(i)?i:[]}catch(i){if(VW(i,t.signal))throw i;return[]}})).flat()}function GW(e,t,n,r,i){let o=n.filter(a=>a.value!==null&&a.value!==void 0).map(a=>a.pippitAssetId);r.emit({type:"node-assets-query:success",level:i?"warn":"info",canvasAssetId:e,payload:{requestedAssetIds:t,returnedAssetIds:o,missingAssetIds:t.filter(a=>!o.includes(a)),assets:n.map(Ed),...i?{fallback:"individual",batchError:Wr(i)}:{}}})}async function KW(e,t,n){n.emit({type:"node-assets-query:start",level:"info",canvasAssetId:t,payload:{assetIds:e}});try{let r=await qW(e,n);return GW(t,e,r,n),{assetIds:e,assets:r}}catch(r){if(VW(r,n.signal))throw r;let i=await Rwe(e,n);if(i.length)return GW(t,e,i,n,r),{assetIds:e,assets:i};let o=Wr(r);return n.emit({type:"node-assets-query:error",level:"error",canvasAssetId:t,payload:{assetIds:e,error:o}}),Wt.error("[xyq-canvas] Failed to query canvas node assets during restore",{canvasAssetId:t,nodeAssetIds:e,error:o}),{assetIds:e,assets:[]}}}function Pwe(e,t){let n=new Set;return t().filter(r=>!e.has(r)||n.has(r)?!1:(n.add(r),!0))}function Dwe(e){return oi(e,zW,Jo).slice(0,Jo)}async function Ewe(e,t,n,r){let i=new Set(e),o={...n,queryLimiter:UW(Jo)};for(;i.size>0;){let a=Pwe(i,n.getPriorityNodeAssetIds),s=a.length?a:[...i],c=Dwe(s);c.flat().forEach(d=>i.delete(d)),await YR(c,Jo,async d=>{let u=await KW(d,t,o);r(u)})}}async function XR(e,t,n,r){if(n.getPriorityNodeAssetIds){await Ewe(e,t,n,r);return}let i=oi(e,zW,Jo),o={...n,queryLimiter:UW(Jo)};await YR(i,Jo,async a=>{let s=await KW(a,t,o);r(s)})}var jW=["assetId","pippitAssetId","tagInfos","subType","source","sourceType","src","url","metadata","naturalWidth","naturalHeight","caption","display","generation","variant","episodes","localUploadCache","localUploadTask"],Mwe={[ee]:jW,[qe]:[...jW,"projection"],[J]:["assetId","pippitAssetId","tagInfos","subType","source","src","url","downloadUrl","previewUrl","coverUrl","coverURL","metadata","frameWidth","frameHeight","durationMs","caption","title","playback","generation","variant","episodes"],[et]:["plainText","content","contentFormat","markdownText","placeholder","block","generation","variant"],[fe]:["assetId","tagInfos","source","src","durationMs","waveformUrl","waveformKey","playback","generation","variant","episodes"]};function Ut(e){if(typeof e=="string"){let t=e.trim();if(!t)return null;try{return Ut(JSON.parse(t))}catch{return null}}return z(e)?e:null}function Ql(e){let t=Ut(e),n=Ut(t==null?void 0:t.content);return n&&((t==null?void 0:t.protocolVersion)!==void 0||(t==null?void 0:t.protocol_version)!==void 0)?n:e}function Nwe(e){return z(e)?e.nodeName!==void 0||e.order!==void 0||e.basicInfo!==void 0||e.useContext!==void 0||e.episodes!==void 0||e.createType!==void 0||e.appearanceInfo!==void 0||e.referenceAppearances!==void 0||e.voiceInfo!==void 0||e.generation!==void 0||e.sourceInfos!==void 0:!1}function wwe(e){let t=yn(e);return{...e.nodeName!==void 0?{nodeName:e.nodeName}:{},...e.order!==void 0?{order:e.order}:{},...e.basicInfo!==void 0?{basicInfo:e.basicInfo}:{},...e.useContext!==void 0?{useContext:e.useContext}:{},...e.episodes!==void 0?{episodes:e.episodes}:{},...e.createType!==void 0?{createType:e.createType}:{},...e.appearanceInfo!==void 0?{appearanceInfo:e.appearanceInfo}:{},...e.referenceAppearances!==void 0?{referenceAppearances:e.referenceAppearances}:{},...t!==void 0?{voiceInfo:t}:{},...e.generation!==void 0?{generation:e.generation}:{},...e.sourceInfos!==void 0?{sourceInfos:e.sourceInfos}:{}}}function kwe(e){if(e!==void 0)return Array.isArray(e)?e.reduce((t,n)=>{let r=Ut(n);return xh(r)&&t.push(r),t},[]):[]}function Owe(e){let t=fc(e.sourceInfos),n=kwe(e.referenceAppearances),{referenceAppearances:r,sourceInfos:i,...o}=e,a={...o,...n!==void 0?{referenceAppearances:n}:{},...t?{sourceInfos:t}:{}},s=Ut(e.appearanceInfo);return s?{...a,appearanceInfo:s}:a}function Lwe(e){let t=Ut(Ql(e));return Nwe(t)?Owe(wwe(t)):null}function HW(e,t){let n=se(e),r=se(t);if(n===ee||r===ee)return ee;if(n===qe||r===qe)return qe;if(n===J||r===J)return J;if(n===et||r===et)return et;if(n===fe||r===fe)return fe}function Fwe(e,t){let n=se(e),r=se(t);return n===_n||r===_n}function Bwe(e,t){if(!Fwe(e.type,t))return null;let n=Ut(Ql(e.content));if(Lh(n)||_i(n))return n;let r=Ut(n==null?void 0:n.directorDocument);if(_i(r))return r;let i=Ut(n==null?void 0:n.data);if(_i(i))return i;let o=Ut(Ql(e.data));if(_i(o))return o;let a=Ut(o==null?void 0:o.directorDocument);return _i(a)?a:null}function Gwe(e,t){let n=se(e.type)||se(t),r=Ut(e),i=Ut(e.content),o=Ut(e.data);if(n===Io)return vo(i)?i:vo(o)?o:vo(r)?r:null;if(n===kr){let a=Fc(i)??Fc(o)??Fc(r);if(a)return a}return null}function zwe(e,t){return z(e)?Object.keys(e).length===0||Mwe[t].some(r=>r in e):!1}function Uwe(e,t){if(!z(e))return e;if(t===et)return ho(e).data;if(t!==ee&&t!==J&&t!==fe)return e;let n={...e},r=!1;(e.localUploadCache===""||e.localUploadCache===null)&&(delete n.localUploadCache,r=!0);let i=z(e.localUploadTask)?e.localUploadTask:void 0;if((t===ee||(t===J||t===fe)&&(e.uploadPath==="optimized"||(i==null?void 0:i.uploadPath)==="optimized"))&&e.localUploadTask!==void 0){let a="audio";t===ee&&(a="image"),t===J&&(a="video"),(e.localUploadTask===""||e.localUploadTask===null||!en(e.localUploadTask,a)||e.localUploadTask.status==="capturing"&&!e.localUploadTask.cacheId)&&(delete n.localUploadTask,r=!0)}return r?n:e}function WR(e,t){if(!zwe(e,t))return null;let n=Uwe(e,t);return t===ee&&ap(n)?{...n}:t===qe&&iC(n)?{...n}:t===J&&dC(n)?{...n}:t===et&&aC(n)?{...n}:t===fe&&rC(n)?{...n}:null}function Vwe(e,t){let n=HW(e.type,t);if(!n)return null;let r=WR(Ql(e.content),n),i=WR(Ql(e.data),n);return r||i||"content"in e||"data"in e?r??i:WR(e,n)}function qwe(e){let t=z(e.extra)?{...e.extra}:{},n=e.create_type??e.createType??e.CreateType;return n!==void 0&&t.create_type===void 0&&(t.create_type=n),t}function Kwe(e){let t=Ut(e.history??e.History);return t?{...t}:void 0}function jwe(e,t){let n=Ut(e);if(!n)return null;if(n.type===Bi)return Xv(n)?n:null;let r=n,i=!!HW(r.type,t.nodeType),o=Gwe(r,t.nodeType)??Bwe(r,t.nodeType)??(i?Vwe(r,t.nodeType):Lwe(r.content));if(!o)return null;let a=se(r.protocolVersion),s=se(r.dataVersion),c=Kwe(r);return{pippitAssetId:se(r.pippitAssetId)||t.nodeAssetId,type:se(r.type)||se(t.nodeType)||"unknown",...a?{protocolVersion:a}:{},...s?{dataVersion:s}:{},content:o,...c?{history:c}:{},extra:qwe(r)}}function y_(e,t){return jwe(e,t)}function Hwe(e){let t=z(e)?e:void 0;return se(t==null?void 0:t.type)}function JW(e){let t=se(e);return t===Ze||t===wn}function $we(e,t){let n=M(e),r=new Map;Object.values(n.nodes).forEach(o=>{let a=Hwe(o);if(!a||JW(a))return;let s=Md(o);s&&s!==e.rootCanvasId&&r.set(s,{assetId:s,nodeType:a})});let i=t?hl(e):void 0;return i&&i!==e.rootCanvasId&&r.set(i,{assetId:i,nodeType:Bi}),[...r.values()].sort((o,a)=>o.assetId.localeCompare(a.assetId))}function $W(e){return e.includes("::")}function QW(e,t){let n=e.assets[t];return z(n)&&z(n.content)}function Ywe(e){let t=se(e);return t===Z||t===Ph}function Xwe(e,t){var r,i;if(!Ywe(t.type))return!1;let n=e.assets[Md(t)??""];return((i=(r=Zt(n))==null?void 0:r.basicInfo)==null?void 0:i.unpromptable)===!0}function JR(e){let t=M(e),n=new Set(Object.values(t.nodes).filter(a=>Xwe(e,a)).map(a=>a.id));if(!n.size)return e;let r=Object.fromEntries(Object.entries(t.nodes).filter(([a])=>!n.has(a)).map(([a,s])=>{let{children:c}=s;return!JW(s.type)||!Array.isArray(c)?[a,s]:[a,{...s,children:c.filter(d=>!n.has(d))}]})),i=Object.fromEntries(Object.entries(t.edges).filter(([,a])=>!n.has(a.source)&&!n.has(a.target))),o=e.assets[e.rootCanvasId];return{...e,assets:{...e.assets,[e.rootCanvasId]:{...o,content:{...t,nodes:r,edges:i}}}}}function __(e){if(e==null)return null;if(typeof e=="string"){let t=e.trim();if(!t)return e;try{return __(JSON.parse(t))}catch{return e}}return Array.isArray(e)?e.map(__):z(e)?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,__(n)])):e}function ZW(e,t){let n=new Map(e.assets.map(a=>[a.pippitAssetId,a])),r={},i=[],o=[];return e.assetIds.forEach(a=>{let s=n.get(a);if((s==null?void 0:s.value)==null)return;let c=y_(s.value,{nodeAssetId:a,nodeType:t.get(a)});if(!c){o.push(a);return}r[a]={...c,assetExtra:__(s.extra)},i.push(a)}),{assets:r,loadedAssetIds:i,unparsedAssetIds:o}}function YW(e,t,n){if(n)try{n({document:JR(e),readyNodeAssetIds:[...t].sort()})}catch(r){Wt.warn("[xyq-canvas] Node asset ready observer failed during restore",r)}}function XW(e,t){if(t)try{t(e)}catch(n){Wt.warn("[xyq-canvas] Node asset settled observer failed during restore",n)}}function QR(e){return Object.values(e.assets).filter(t=>z(t)&&t.type===Io).flatMap(t=>{let n=vo(t.content)?t.content:void 0;return n?[n.draftRef.pippitAssetId]:[]}).filter((t,n,r)=>r.indexOf(t)===n).sort()}async function WW(e,t,n){let i=QR(e).filter(c=>!QW(e,c));if(i.length===0)return{document:e,loadedIds:[],missingIds:[]};let o={},a=[],s=new Map(i.map(c=>[c,kr]));return await XR(i,t,n,c=>{let d=ZW(c,s);Object.assign(o,d.assets),a.push(...d.loadedAssetIds)}),a.sort(),{document:a.length?{...e,assets:{...e.assets,...o}}:e,loadedIds:a,missingIds:i.filter(c=>!a.includes(c))}}async function e8(e,t,n){let r=$we(e,n.includeGenerationHistory!==!1),i=r.map(T=>T.assetId),o=new Map(r.map(T=>[T.assetId,T.nodeType])),a=n.prefetchCoverAssets?FW({canvasAssetId:t,emit:n.emit,prefetchCoverAssets:n.prefetchCoverAssets,signal:n.signal}):void 0;a==null||a.enqueue($R(e));let s=i.filter(T=>!QW(e,T)),c=i.filter(T=>!s.includes(T)),d=s.filter(T=>!$W(T)),u=s.filter($W);n.emit({type:"node-assets:collect",level:"info",canvasAssetId:t,payload:{nodeAssetIds:i,missingNodeAssetIds:s,existingNodeAssetIds:c,skippedSyntheticNodeAssetIds:u}}),u.length&&Wt.error("[xyq-canvas] Skip synthetic node asset ids during canvas restore",{canvasAssetId:t,skippedSyntheticNodeAssetIds:u});let p=new Set(c);if(c.length&&YW(e,p,n.onNodeAssetsReady),!s.length){let T=JR(e);XW(T,n.onNodeAssetsSettled);let C=await WW(T,t,n);return{document:C.document,canvasAssetId:t,nodeAssetIds:[...i,...QR(C.document)],loadedNodeAssetIds:C.loadedIds,missingNodeAssetIds:C.missingIds}}let m=[],f=[],h=e;d.length&&await XR(d,t,{...n,getPriorityNodeAssetIds:n.resolvePriorityNodeAssetIds?()=>{var T;return((T=n.resolvePriorityNodeAssetIds)==null?void 0:T.call(n,h))??[]}:void 0},T=>{let C=ZW(T,o);f.push(...C.unparsedAssetIds),C.loadedAssetIds.length&&(m.push(...C.loadedAssetIds),C.loadedAssetIds.forEach(I=>p.add(I)),h={...h,assets:{...h.assets,...C.assets}},a==null||a.enqueue($R(h,new Set(C.loadedAssetIds))),YW(h,p,n.onNodeAssetsReady))}),m.sort(),f.sort();let g=JR(h);XW(g,n.onNodeAssetsSettled);let y=await WW(g,t,n),_=y.document,S=s.filter(T=>!m.includes(T));return n.emit({type:"node-assets:merge",level:S.length?"warn":"info",canvasAssetId:t,payload:{loadedNodeAssetIds:[...m,...y.loadedIds],missingNodeAssetIds:[...S,...y.missingIds],unparsedNodeAssetIds:f,document:Jl(_)}}),{document:_,canvasAssetId:t,nodeAssetIds:[...i,...QR(y.document)],loadedNodeAssetIds:[...m,...y.loadedIds],missingNodeAssetIds:[...S,...y.missingIds]}}var Wwe=["x","y","w","h","children","data"];function Zl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ZR(e){return(e==null?void 0:e.type)===Ze||(e==null?void 0:e.type)===wn}function Nd(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Jr(e){return typeof e=="number"&&Number.isFinite(e)}function Jwe(e){return Jr(e.x)&&Jr(e.y)&&Nd(e.w)&&Nd(e.h)}function eP(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function T_(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Qwe(e,t){return JSON.stringify(e)===JSON.stringify(t)}function t8(e,t){return t==="children"?e.children:e[t]}function Zwe(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>{let r={...n};return Array.isArray(r.children)&&(r.children=[...r.children]),Zl(r.data)&&(r.data={...r.data}),[t,r]}))}function r8(e,t){return Array.isArray(e.children)?e.children.filter(n=>{var r;return typeof n=="string"&&((r=t[n])==null?void 0:r.parentId)===e.id}):[]}function eke(e,t,n,r){let i=new Set,o=new Set,a=()=>Object.values(e).filter(ZR).filter(c=>r8(c,e).length===0).map(c=>c.id),s=a();for(;s.length>0;)s.forEach(c=>{let d=e[c],u=d.parentId?e[d.parentId]:void 0;ZR(u)&&Array.isArray(u.children)&&(u.children=u.children.filter(p=>p!==c)),delete e[c],i.add(c),c!==r&&T_(n,c)&&(delete n[c],o.add(c))}),s=a();return i.size===0?{edges:t,removedAssetIds:o}:{edges:Object.fromEntries(Object.entries(t).filter(([,c])=>!i.has(c.source)&&!i.has(c.target))),removedAssetIds:o}}function n8(e,t){var o;let n=0,r=e.parentId??null,i=new Set([e.id]);for(;r&&!i.has(r);)i.add(r),n+=1,r=((o=t[r])==null?void 0:o.parentId)??null;return n}function tke(e,t){return e.reduce((n,r)=>{let i=t[r],o=Jr(i.x)?i.x:0,a=Jr(i.y)?i.y:0,s=Nd(i.w)?i.w:0,c=Nd(i.h)?i.h:0,d={minX:o,minY:a,maxX:o+s,maxY:a+c};return n?{minX:Math.min(n.minX,d.minX),minY:Math.min(n.minY,d.minY),maxX:Math.max(n.maxX,d.maxX),maxY:Math.max(n.maxY,d.maxY)}:d},void 0)}function nke(e){if(!Zl(e.data)||!Zl(e.data.expandedSize))return;let{w:t,h:n}=e.data.expandedSize;return Nd(t)&&Nd(n)?{w:t,h:n}:void 0}function rke(e,t){let n=r8(e,t),r=tke(n,t);if(!r)return;let i={minX:r.minX-40,minY:r.minY-40,maxX:r.maxX+40,maxY:r.maxY+40};e.x=(Jr(e.x)?e.x:0)+i.minX,e.y=(Jr(e.y)?e.y:0)+i.minY,n.forEach(a=>{let s=t[a];s.x=(Jr(s.x)?s.x:0)-i.minX,s.y=(Jr(s.y)?s.y:0)-i.minY});let o={w:Math.max(1,i.maxX-i.minX),h:Math.max(1,i.maxY-i.minY)};if(Zl(e.data)&&e.data.collapsed===!0){e.data.expandedSize=o,e.w=320,e.h=180;return}e.w=o.w,e.h=o.h}function ike(e){Object.values(e).filter(ZR).sort((t,n)=>n8(n,e)-n8(t,e)).forEach(t=>{if(!Jwe(t)){if(Jr(t.x)&&Jr(t.y)&&Zl(t.data)&&t.data.collapsed===!0&&nke(t)){t.w=320,t.h=180;return}rke(t,e)}})}function oke(e,t,n,r,i,o){let a=t8(r,o),s=t8(i,o);Qwe(a,s)||e.push({assetId:t,op:T_(r,o)?"replace":"add",path:`/content/nodes/${eP(n)}/${o}`,value:s})}function ake(e){let t=[],{afterEdges:n,afterNodes:r,beforeAssets:i,beforeEdges:o,beforeNodes:a,removedAssetIds:s,rootCanvasId:c}=e;return Object.entries(a).forEach(([d,u])=>{if(!T_(r,d)){t.push({assetId:c,op:"remove",path:`/content/nodes/${eP(d)}`});return}let p=r[d];Wwe.forEach(m=>oke(t,c,d,u,p,m))}),Object.keys(o).forEach(d=>{T_(n,d)||t.push({assetId:c,op:"remove",path:`/content/edges/${eP(d)}`})}),s.forEach(d=>{let u=i[d],p=typeof(u==null?void 0:u.pippitAssetId)=="string"?u.pippitAssetId:d;t.push({assetId:p,op:"remove",path:""})}),t}function S_(e,t={}){let n=M(e),r=Zwe(n.nodes),i={...e.assets},{edges:o,removedAssetIds:a}=eke(r,n.edges,i,e.rootCanvasId);t.repairInvalidGroups!==!1&&ike(r);let s=ake({afterEdges:o,afterNodes:r,beforeAssets:e.assets,beforeEdges:n.edges,beforeNodes:n.nodes,removedAssetIds:a,rootCanvasId:e.rootCanvasId});if(s.length===0)return{document:e,repairPatches:s};let d={...i[e.rootCanvasId],content:{...n,edges:o,nodes:r}};return{document:{...e,assets:{...i,[e.rootCanvasId]:d}},repairPatches:s}}function a8(e){return e===Ze||e===wn}function i8(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function s8(e){if(!e.startsWith("group")||e.startsWith("group$"))return e;let t=e.slice(5);if(!t)return e;let n=t.replace(/^[-_$]+/,"");if(!n)return e;let r=n.replace(/[-_]/g,"$").replace(/([a-z0-9])([A-Z])/g,"$1$$$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1$$$2").replace(/\$+/g,"$").replace(/^\$|\$$/g,"").toLowerCase();return r?`group$${r}`:e}function ske(e,t){let n=e,r=2;for(;t.has(n);)n=`${e}$${r}`,r+=1;return n}function cke(e){let t=new Set(Object.keys(e)),n=new Map;return Object.values(e).forEach(r=>{if(!a8(r.type))return;let i=s8(r.id);if(i===r.id)return;t.delete(r.id);let o=ske(i,t);t.add(o),n.set(r.id,o)}),n}function o8(e,t,n){let r=t.get(e);if(r)return r;let i=s8(e);return i!==e&&n.has(i)?i:e}function c8(e,t,n,r){t.has(n)||(e[n]={...e[n]},t.add(n)),r(e[n])}function d8(e){let t=cke(e),n=new Set(Object.keys(e).map(o=>t.get(o)??o)),r={},i=t.size>0;return Object.entries(e).forEach(([o,a])=>{let s=t.get(o)??o,c=a;if(a.id!==s&&(c={...c,id:s},i=!0),typeof c.parentId=="string"){let u=o8(c.parentId,t,n);u!==c.parentId&&(c={...c,parentId:u},i=!0)}let d=c.children;if(Array.isArray(d)){let u=d.map(p=>typeof p=="string"?o8(p,t,n):p);u.some((p,m)=>p!==d[m])&&(c={...c,children:u},i=!0)}s!==o&&(i=!0),r[s]=c}),{nodes:i?r:e,changed:i,nodeIdAliases:t}}function u8(e,t,n,r){let i={...e};return t.forEach((o,a)=>{if(a===n||!i8(i,a))return;let s=i[a];i8(i,o)||(i[o]=z(s)?{...s,pippitAssetId:o}:s),delete i[a]}),i[n]=r,i}function tP(e){let t={...e},n=new Set,r=new Map,i=!1,o=(a,s)=>{c8(t,n,a,s),i=!0};return Object.values(e).forEach(a=>{if(!a8(a.type)){"children"in a&&o(a.id,u=>{delete u.children});return}let s=a.children;if(s==null)return;if(!Array.isArray(s)){o(a.id,u=>{u.children=[]});return}let c=new Set,d=s.filter(u=>{if(typeof u!="string"||c.has(u))return!1;c.add(u);let p=e[u];return!p||p.parentId!==a.id||r.has(u)?!1:(r.set(u,a.id),!0)});(d.length!==s.length||d.some((u,p)=>u!==s[p]))&&o(a.id,u=>{u.children=d})}),Object.values(t).forEach(a=>{if(!a.parentId)return;let s=t[a.parentId];if(s&&"children"in s&&s.children===null)return;let c=Array.isArray(s==null?void 0:s.children)?s.children:[];(!s||!c.includes(a.id))&&o(a.id,d=>{delete d.parentId})}),{nodes:i?t:e,changed:i}}function p8(e){let t=new Set;if(Object.values(e).forEach(i=>{let o=[],a=new Map,s=i;for(;s!=null&&s.parentId;){let c=a.get(s.id);if(c!==void 0){o.slice(c).forEach(d=>t.add(d));break}a.set(s.id,o.length),o.push(s.id),s=e[s.parentId]}}),!t.size)return{nodes:e,changed:!1};let n={...e},r=new Set;return t.forEach(i=>{c8(n,r,i,o=>{delete o.parentId})}),{nodes:n,changed:!0}}function Qo(e){return typeof e=="string"?e.trim()||void 0:typeof e=="number"&&Number.isFinite(e)?String(e):void 0}function wd(e,t){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e!="string"||!e.trim())return t;let n=Number(e);return Number.isFinite(n)?n:t}function l8(e,t){let n=wd(e,t);return n>0?n:t}function m8(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function f8(e){if(typeof e!="string")return;let t=e.trim();if(!(!t||t==="null"||t==="undefined"))return t}function dke(e){return{...e,snap:{...e.snap,targets:[...e.snap.targets]},grid:{...e.grid},...e.autoLayout?{autoLayout:{...e.autoLayout}}:{}}}function h8(e,t){if(!z(e))return{settings:dke(t),changed:!0};let n=z(e.snap)?e.snap:void 0,r=z(e.grid)?e.grid:void 0,i=z(e.autoLayout)?e.autoLayout:void 0,o=i==null?void 0:i.strategy,a=Object.prototype.hasOwnProperty.call(e,"autoLayout"),s=typeof o=="string"?o.trim():void 0,c=!!s,d=Array.isArray(n==null?void 0:n.targets)?n.targets.filter(p=>typeof p=="string"):void 0,u={...e,snap:{enabled:typeof(n==null?void 0:n.enabled)=="boolean"?n.enabled:t.snap.enabled,threshold:l8(n==null?void 0:n.threshold,t.snap.threshold),targets:d&&d.length>0?d:[...t.snap.targets]},grid:{size:wd(r==null?void 0:r.size,t.grid.size),visible:typeof(r==null?void 0:r.visible)=="boolean"?r.visible:t.grid.visible}};return c?u.autoLayout={...i,strategy:s}:delete u.autoLayout,{settings:u,changed:!n||!r||typeof n.enabled!="boolean"||typeof r.visible!="boolean"||!Number.isFinite(n.threshold)||l8(n.threshold,t.snap.threshold)!==n.threshold||!Number.isFinite(r.size)||!Array.isArray(n.targets)||((d==null?void 0:d.length)??0)!==n.targets.length||a&&(!c||s!==o)}}function g8(e){if(!z(e))return{nodes:{},changed:e!==void 0};let t={},n=!1;return Object.entries(e).forEach(([r,i])=>{if(!z(i)){n=!0;return}let o={...i},a=Qo(o.id)||r;o.id!==a&&(o.id=a,n=!0),a!==r&&(n=!0);let s=Qo(o.parentId)||Qo(o.parent_id);s&&o.parentId!==s?(o.parentId=s,n=!0):!s&&o.parentId!=null&&typeof o.parentId!="string"&&(delete o.parentId,n=!0);let c=wd(o.x,0),d=wd(o.y,0),u=wd(o.w,0),p=wd(o.h,0);(o.x!==c||o.y!==d||o.w!==u||o.h!==p)&&(Object.assign(o,{x:c,y:d,w:u,h:p}),n=!0),t[a]=o}),{nodes:t,changed:n}}function y8(e,t,n=new Map){if(!z(e))return{edges:{},changed:e!==void 0};let r={},i=!1;return Object.entries(e).forEach(([o,a])=>{if(!z(a)){i=!0;return}let s=Qo(a.id)||o,c=Qo(a.source),d=Qo(a.target),u=c?n.get(c)??c:void 0,p=d?n.get(d)??d:void 0;if(!u||!p||!t[u]||!t[p]){i=!0;return}r[s]&&(i=!0);let m=f8(a.sourceHandle),f=f8(a.targetHandle),h={...a,id:s,source:u,target:p},g=s!==o||a.id!==s||a.source!==u||a.target!==p||c!==u||d!==p;m?(h.sourceHandle=m,g||=a.sourceHandle!==m):m8(a,"sourceHandle")&&(delete h.sourceHandle,g=!0),f?(h.targetHandle=f,g||=a.targetHandle!==f):m8(a,"targetHandle")&&(delete h.targetHandle,g=!0),r[s]=g?h:a,i||=g}),{edges:r,changed:i}}function em(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function _8(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function uke(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Ds(e,t,n,r,i,o){let a=em(n,r);a&&uke(n[r],o)||e.push({assetId:t,op:a?"replace":"add",path:i,value:o})}function T8(e,t,n,r,i){Object.keys(n).forEach(o=>{em(r,o)||e.push({assetId:t,op:"remove",path:`${i}/${_8(o)}`})}),Object.entries(r).forEach(([o,a])=>{Ds(e,t,n,o,`${i}/${_8(o)}`,a)})}function pke(e,t,n,r){if(!z(t.content))return[{assetId:e,op:em(t,"content")?"replace":"add",path:"/content",value:r}];let i=[];return Ds(i,e,n,"metadata","/content/metadata",r.metadata),z(n.settings)?(Ds(i,e,n.settings,"snap","/content/settings/snap",r.settings.snap),Ds(i,e,n.settings,"grid","/content/settings/grid",r.settings.grid)):Ds(i,e,n,"settings","/content/settings",r.settings),z(n.nodes)?T8(i,e,n.nodes,r.nodes,"/content/nodes"):Ds(i,e,n,"nodes","/content/nodes",r.nodes),z(n.edges)?T8(i,e,n.edges,r.edges,"/content/edges"):Ds(i,e,n,"edges","/content/edges",r.edges),i}function lke(e){let t={...e},n=!1;return Object.entries(e).forEach(([r,i])=>{if(i.type!==et||!z(i.data))return;let o=ho(i.data);o.changed&&(t[r]={...i,data:o.data},n=!0)}),{nodes:n?t:e,changed:n}}function mke(e,t,n){let r={...e},i=[],o=!1;return Object.entries(e).forEach(([a,s])=>{var u;if(a===n||!z(s)||!z(s.content)||(typeof s.type=="string"?s.type:(u=t[a])==null?void 0:u.type)!==et)return;let d=ho(s.content);d.changed&&(r[a]={...s,content:d.data},i.push({assetId:a,op:"replace",path:"/content",value:d.data}),o=!0)}),{assets:o?r:e,changed:o,repairPatches:i}}function S8(e){let t=e.assets[e.rootCanvasId];if(!t||!z(t))return{document:e,repairPatches:[]};let n=zs(e.rootCanvasId).assets[e.rootCanvasId].content,r=z(t.content)?t.content:{},i=g8(r.nodes),o=lke(i.nodes),a=d8(o.nodes),s=tP(a.nodes),c=p8(s.nodes),d=c.changed?tP(c.nodes):c,u=mke(e.assets,d.nodes,e.rootCanvasId),p=y8(r.edges,d.nodes,a.nodeIdAliases),m=h8(r.settings,n.settings),f=z(r.metadata)?r.metadata:n.metadata,g=Qo(t.pippitAssetId)!==e.rootCanvasId,y=t.type!==Mn,_=!z(t.content)||!z(r.metadata)||!z(r.nodes)||!z(r.edges)||i.changed||o.changed||a.changed||s.changed||c.changed||d.changed||p.changed||m.changed;if(!(y||g||_||u.changed))return{document:e,repairPatches:[]};let T={...n,...r,metadata:f,settings:m.settings,nodes:d.nodes,edges:p.edges},C={...t,pippitAssetId:e.rootCanvasId,type:Mn,content:T},I=[];return g&&I.push({assetId:e.rootCanvasId,op:em(t,"pippitAssetId")?"replace":"add",path:"/pippitAssetId",value:e.rootCanvasId}),y&&I.push({assetId:e.rootCanvasId,op:em(t,"type")?"replace":"add",path:"/type",value:Mn}),_&&I.push(...pke(e.rootCanvasId,t,r,T)),I.push(...u.repairPatches),{document:{...e,assets:u8(u.assets,a.nodeIdAliases,e.rootCanvasId,C)},repairPatches:I}}function b8(e){return z(e.nodes)?Object.keys(e.nodes).length:0}function fke(e,t){let n=b8(e),r=b8(t);if(r<=0)return!1;let i=z(e.edges),o=z(t.edges);return!i&&o&&r>n?!0:n===0&&r>0}function hke(e){let t=z(e.content)?e.content:null,n=z(e.data)?e.data:null;return t?n&&fke(t,n)?n:t:n}function gke(e){let t={...e};return delete t.data,t}function yke(e,t){let n=se(e.rootCanvasId)||se(e.root_canvas_id)||t,r=z(e.assets)?e.assets:null;return!n||!r||!z(r[n])?null:{rootCanvasId:n,assets:r}}function _ke(e,t){let n=se(e.pippitAssetId)||se(e.pippit_asset_id)||t,r=hke(e);return!n||e.type!=="canvas"||!r?null:{rootCanvasId:n,assets:{[n]:{...gke(e),pippitAssetId:n,content:r,extra:z(e.extra)?e.extra:z(e.Extra)?e.Extra:{}}}}}function C8(e,t){let n=S8(e),r=S_(n.document,{repairInvalidGroups:t});return{document:r.document,repairPatches:[...n.repairPatches,...r.repairPatches]}}function iP(e,t,n,r){if(e==null)return null;if(typeof e=="string"){let a=e.trim();if(!a)return null;try{return iP(JSON.parse(a),t,n,r)}catch{return null}}if(!z(e)||r.has(e))return null;r.add(e);let i=yke(e,t);if(i)return C8(i,n);let o=_ke(e,t);if(o)return C8(o,n);for(let a of["document","canvasDocument","canvas_document","snapshot","data","content","value"]){let s=iP(e[a],t,n,r);if(s)return s}return null}function nP(e,t,n=!0){return iP(e,t,n,new Set)}function rP(e,t){var n;return e?(e.repairPatches.length>0&&((n=t.onRepairPatches)==null||n.call(t,e.repairPatches)),e.document):null}function A8(e,t,n){let r=nP(e,t.canvasAssetId,n);if(r)return Promise.resolve(rP(r,t));let i=z(e)?e:void 0,o=tU(i,"TextInfo","textInfo"),a=nP(o==null?void 0:o.content,t.canvasAssetId,n);if(a)return Promise.resolve(rP(a,t));let s=nP((i==null?void 0:i.Extra)??(i==null?void 0:i.extra),t.canvasAssetId,n);return s?Promise.resolve(rP(s,t)):Promise.resolve(null)}function I8(e,t={}){return A8(e,t,!0)}function v8(e,t={}){return A8(e,t,!1)}var Tke=new Set([Z,Oe]),Ske=new Set([ee,J]);function bke(e){return typeof e.x=="number"&&Number.isFinite(e.x)&&typeof e.y=="number"&&Number.isFinite(e.y)&&typeof e.w=="number"&&Number.isFinite(e.w)&&e.w>0&&typeof e.h=="number"&&Number.isFinite(e.h)&&e.h>0}function Cke(e){return{name:e?`${h_.name}-media`:"media-node-geometry-repair",layout(t){let n=e?h_.layout(t):t;return vW(n,{repairInvalidOnly:!0})}}}function Ake(e){let t=!1,n=!1;if(Object.values(M(e).nodes).forEach(r=>{if(!bke(r)){if(Ske.has(r.type)){n=!0;return}Tke.has(r.type)&&(t=!0)}}),n)return Cke(t);if(t)return h_}var Ike=["x","y","w","h","order"];function vke(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function xke(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rke(e,t){let n=M(e).nodes,r=M(t).nodes,i=[];return Object.values(r).forEach(o=>{let a=n[o.id];a&&Ike.forEach(s=>{let c=o[s];a[s]!==c&&i.push({assetId:t.rootCanvasId,op:xke(a,s)?"replace":"add",path:`/content/nodes/${vke(o.id)}/${s}`,value:c})})}),i}function Pke(e,t){let n={pippitAssetIds:e,isCamelCase:!0};return t&&(n.signal=t),n}var oP=class{constructor(t){this._options=t;this._eventEmitter=new gl;this.onEvent=this._eventEmitter.event}async loadDocument(t){return(await this.restore(t)).document}async restore(t){var i,o;let n=t.trim();if(!n)throw new Error("missing canvasAssetId");let r="canvas-asset-query";try{this._emit({type:"restore:start",level:"info",canvasAssetId:n});let{selectedAsset:a}=await this._queryCanvasAsset(n),s=[];r="canvas-document-normalize",this._emit({type:"canvas-document-normalize:start",level:"info",canvasAssetId:n,payload:{textAsset:Ed(a)}});let c=await v8(a.value,{canvasAssetId:n,signal:this._options.signal,onRepairPatches:y=>s.push(...y)});if(!c){let y=new Error(X.t("Pippit_xyqcanvas_restore_error_invalidcanvasasset",{},"画布资产内容为空或格式不正确"));throw this._emit({type:"canvas-document-normalize:error",level:"warn",canvasAssetId:n,payload:{error:Wr(y),textAsset:Ed(a)}},y),y}this._emit({type:"canvas-document-normalize:success",level:"info",canvasAssetId:n,payload:{document:Jl(c)}}),r="root-document-ready",(o=(i=this._options).onRootDocumentReady)==null||o.call(i,c),r="node-assets-hydrate";let d=await e8(c,n,{includeGenerationHistory:this._options.includeGenerationHistory,signal:this._options.signal,queryTextAssetContent:this._options.queryTextAssetContent,prefetchCoverAssets:this._options.prefetchCoverAssets,emit:y=>this._emit(y),onNodeAssetsReady:this._options.onNodeAssetsReady,onNodeAssetsSettled:this._options.onNodeAssetsSettled,requireCompleteNodeAssets:this._options.requireCompleteNodeAssets,resolvePriorityNodeAssetIds:this._options.resolvePriorityNodeAssetIds});r="canvas-layout";let u=this._options.layoutStrategy===void 0?Ake(d.document):this._options.layoutStrategy,p=u?u.layout(d.document):d.document,m=u?Rke(d.document,p):[],f=S_(p);s.push(...f.repairPatches);let h=f.document,g=h===d.document?d:{...d,document:h};return u&&(g.layoutApplied=!0,g.layoutPatches=m,g.layoutStrategy=u.name),s.length>0&&(g.repairApplied=!0,g.repairPatches=s),r="restore-finalize",this._emit({type:"restore:success",level:"info",canvasAssetId:n,payload:{document:Jl(g.document),nodeAssetIds:g.nodeAssetIds,loadedNodeAssetIds:g.loadedNodeAssetIds,missingNodeAssetIds:g.missingNodeAssetIds,repairApplied:s.length>0,repairPatchCount:s.length,layoutApplied:!!u,layoutPatchCount:m.length,layoutStrategy:u?u.name:void 0}}),g}catch(a){let s=zR(a,this._options.signal),c=s?"aborted":UR(a);throw this._emit({type:s?"restore:cancel":"restore:error",level:s?"info":"error",canvasAssetId:n,payload:{error:Wr(a),failure_stage:r,...c?{reason:c}:{},...RW(a)}},a),a}}dispose(){this._eventEmitter.dispose()}async _queryCanvasAsset(t){this._emit({type:"canvas-asset-query:start",level:"info",canvasAssetId:t,payload:{assetIds:[t]}});try{let n=await this._options.queryTextAssetContent(Pke([t],this._options.signal)),r=n.find(i=>i.pippitAssetId===t)??n[0];if((r==null?void 0:r.value)===null||(r==null?void 0:r.value)===void 0)throw new Wl(X.t("Pippit_xyqcanvas_restore_error_canvasassetnotfound",{},"画布资产不存在"));return this._emit({type:"canvas-asset-query:success",level:"info",canvasAssetId:t,payload:{assetCount:n.length,resolvedAssetIds:n.filter(i=>i.value!==null&&i.value!==void 0).map(i=>i.pippitAssetId),assets:n.map(Ed)}}),{selectedAsset:r,assets:n}}catch(n){let r=zR(n,this._options.signal),i=r?"aborted":UR(n);throw this._emit({type:r?"canvas-asset-query:cancel":"canvas-asset-query:error",level:r?"info":"warn",canvasAssetId:t,payload:{error:Wr(n),...i?{reason:i}:{}}},n),n}}_emit(t,n){this._eventEmitter.fire(t),wW(t,this._options,n)}};async function x8(e,t){let n=new oP(t),r=t.onEvent?n.onEvent(t.onEvent):void 0;try{return await n.restore(e)}finally{r==null||r.dispose(),n.dispose()}}function Dke(){this.__data__=[],this.size=0}var R8=Dke;function Eke(e,t){return e===t||e!==e&&t!==t}var b_=Eke;function Mke(e,t){for(var n=e.length;n--;)if(b_(e[n][0],t))return n;return-1}var Zo=Mke;var Nke=Array.prototype,wke=Nke.splice;function kke(e){var t=this.__data__,n=Zo(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():wke.call(t,n,1),--this.size,!0}var P8=kke;function Oke(e){var t=this.__data__,n=Zo(t,e);return n<0?void 0:t[n][1]}var D8=Oke;function Lke(e){return Zo(this.__data__,e)>-1}var E8=Lke;function Fke(e,t){var n=this.__data__,r=Zo(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}var M8=Fke;function kd(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}kd.prototype.clear=R8;kd.prototype.delete=P8;kd.prototype.get=D8;kd.prototype.has=E8;kd.prototype.set=M8;var ea=kd;function Bke(){this.__data__=new ea,this.size=0}var N8=Bke;function Gke(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}var w8=Gke;function zke(e){return this.__data__.get(e)}var k8=zke;function Uke(e){return this.__data__.has(e)}var O8=Uke;var Vke=typeof global=="object"&&global&&global.Object===Object&&global,C_=Vke;var qke=typeof self=="object"&&self&&self.Object===Object&&self,Kke=C_||qke||Function("return this")(),dt=Kke;var jke=dt.Symbol,ji=jke;var L8=Object.prototype,Hke=L8.hasOwnProperty,$ke=L8.toString,tm=ji?ji.toStringTag:void 0;function Yke(e){var t=Hke.call(e,tm),n=e[tm];try{e[tm]=void 0;var r=!0}catch{}var i=$ke.call(e);return r&&(t?e[tm]=n:delete e[tm]),i}var F8=Yke;var Xke=Object.prototype,Wke=Xke.toString;function Jke(e){return Wke.call(e)}var B8=Jke;var Qke="[object Null]",Zke="[object Undefined]",G8=ji?ji.toStringTag:void 0;function eOe(e){return e==null?e===void 0?Zke:Qke:G8&&G8 in Object(e)?F8(e):B8(e)}var Hi=eOe;function tOe(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Qr=tOe;var nOe="[object AsyncFunction]",rOe="[object Function]",iOe="[object GeneratorFunction]",oOe="[object Proxy]";function aOe(e){if(!Qr(e))return!1;var t=Hi(e);return t==rOe||t==iOe||t==nOe||t==oOe}var A_=aOe;var sOe=dt["__core-js_shared__"],I_=sOe;var z8=function(){var e=/[^.]+$/.exec(I_&&I_.keys&&I_.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function cOe(e){return!!z8&&z8 in e}var U8=cOe;var dOe=Function.prototype,uOe=dOe.toString;function pOe(e){if(e!=null){try{return uOe.call(e)}catch{}try{return e+""}catch{}}return""}var $i=pOe;var lOe=/[\\^$.*+?()[\]{}|]/g,mOe=/^\[object .+?Constructor\]$/,fOe=Function.prototype,hOe=Object.prototype,gOe=fOe.toString,yOe=hOe.hasOwnProperty,_Oe=RegExp("^"+gOe.call(yOe).replace(lOe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function TOe(e){if(!Qr(e)||U8(e))return!1;var t=A_(e)?_Oe:mOe;return t.test($i(e))}var V8=TOe;function SOe(e,t){return e==null?void 0:e[t]}var q8=SOe;function bOe(e,t){var n=q8(e,t);return V8(n)?n:void 0}var rn=bOe;var COe=rn(dt,"Map"),ta=COe;var AOe=rn(Object,"create"),Yi=AOe;function IOe(){this.__data__=Yi?Yi(null):{},this.size=0}var K8=IOe;function vOe(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var j8=vOe;var xOe="__lodash_hash_undefined__",ROe=Object.prototype,POe=ROe.hasOwnProperty;function DOe(e){var t=this.__data__;if(Yi){var n=t[e];return n===xOe?void 0:n}return POe.call(t,e)?t[e]:void 0}var H8=DOe;var EOe=Object.prototype,MOe=EOe.hasOwnProperty;function NOe(e){var t=this.__data__;return Yi?t[e]!==void 0:MOe.call(t,e)}var $8=NOe;var wOe="__lodash_hash_undefined__";function kOe(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Yi&&t===void 0?wOe:t,this}var Y8=kOe;function Od(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Od.prototype.clear=K8;Od.prototype.delete=j8;Od.prototype.get=H8;Od.prototype.has=$8;Od.prototype.set=Y8;var aP=Od;function OOe(){this.size=0,this.__data__={hash:new aP,map:new(ta||ea),string:new aP}}var X8=OOe;function LOe(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var W8=LOe;function FOe(e,t){var n=e.__data__;return W8(t)?n[typeof t=="string"?"string":"hash"]:n.map}var na=FOe;function BOe(e){var t=na(this,e).delete(e);return this.size-=t?1:0,t}var J8=BOe;function GOe(e){return na(this,e).get(e)}var Q8=GOe;function zOe(e){return na(this,e).has(e)}var Z8=zOe;function UOe(e,t){var n=na(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}var e4=UOe;function Ld(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Ld.prototype.clear=X8;Ld.prototype.delete=J8;Ld.prototype.get=Q8;Ld.prototype.has=Z8;Ld.prototype.set=e4;var t4=Ld;var VOe=200;function qOe(e,t){var n=this.__data__;if(n instanceof ea){var r=n.__data__;if(!ta||r.length<VOe-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new t4(r)}return n.set(e,t),this.size=n.size,this}var n4=qOe;function Fd(e){var t=this.__data__=new ea(e);this.size=t.size}Fd.prototype.clear=N8;Fd.prototype.delete=w8;Fd.prototype.get=k8;Fd.prototype.has=O8;Fd.prototype.set=n4;var r4=Fd;var KOe=dt.Uint8Array,sP=KOe;function jOe(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}var v_=jOe;var HOe=Array.isArray,Bd=HOe;function $Oe(e,t,n){var r=t(e);return Bd(e)?r:v_(r,n(e))}var x_=$Oe;function YOe(e,t){for(var n=-1,r=e==null?0:e.length,i=0,o=[];++n<r;){var a=e[n];t(a,n,e)&&(o[i++]=a)}return o}var i4=YOe;function XOe(){return[]}var R_=XOe;var WOe=Object.prototype,JOe=WOe.propertyIsEnumerable,o4=Object.getOwnPropertySymbols,QOe=o4?function(e){return e==null?[]:(e=Object(e),i4(o4(e),function(t){return JOe.call(e,t)}))}:R_,Gd=QOe;function ZOe(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var a4=ZOe;function e0e(e){return e!=null&&typeof e=="object"}var Zr=e0e;var t0e="[object Arguments]";function n0e(e){return Zr(e)&&Hi(e)==t0e}var cP=n0e;var s4=Object.prototype,r0e=s4.hasOwnProperty,i0e=s4.propertyIsEnumerable,o0e=cP(function(){return arguments}())?cP:function(e){return Zr(e)&&r0e.call(e,"callee")&&!i0e.call(e,"callee")},c4=o0e;function a0e(){return!1}var d4=a0e;var l4=typeof exports=="object"&&exports&&!exports.nodeType&&exports,u4=l4&&typeof module=="object"&&module&&!module.nodeType&&module,s0e=u4&&u4.exports===l4,p4=s0e?dt.Buffer:void 0,c0e=p4?p4.isBuffer:void 0,d0e=c0e||d4,P_=d0e;var u0e=9007199254740991,p0e=/^(?:0|[1-9]\d*)$/;function l0e(e,t){var n=typeof e;return t=t??u0e,!!t&&(n=="number"||n!="symbol"&&p0e.test(e))&&e>-1&&e%1==0&&e<t}var m4=l0e;var m0e=9007199254740991;function f0e(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=m0e}var D_=f0e;var h0e="[object Arguments]",g0e="[object Array]",y0e="[object Boolean]",_0e="[object Date]",T0e="[object Error]",S0e="[object Function]",b0e="[object Map]",C0e="[object Number]",A0e="[object Object]",I0e="[object RegExp]",v0e="[object Set]",x0e="[object String]",R0e="[object WeakMap]",P0e="[object ArrayBuffer]",D0e="[object DataView]",E0e="[object Float32Array]",M0e="[object Float64Array]",N0e="[object Int8Array]",w0e="[object Int16Array]",k0e="[object Int32Array]",O0e="[object Uint8Array]",L0e="[object Uint8ClampedArray]",F0e="[object Uint16Array]",B0e="[object Uint32Array]",Ye={};Ye[E0e]=Ye[M0e]=Ye[N0e]=Ye[w0e]=Ye[k0e]=Ye[O0e]=Ye[L0e]=Ye[F0e]=Ye[B0e]=!0;Ye[h0e]=Ye[g0e]=Ye[P0e]=Ye[y0e]=Ye[D0e]=Ye[_0e]=Ye[T0e]=Ye[S0e]=Ye[b0e]=Ye[C0e]=Ye[A0e]=Ye[I0e]=Ye[v0e]=Ye[x0e]=Ye[R0e]=!1;function G0e(e){return Zr(e)&&D_(e.length)&&!!Ye[Hi(e)]}var f4=G0e;function z0e(e){return function(t){return e(t)}}var zd=z0e;var h4=typeof exports=="object"&&exports&&!exports.nodeType&&exports,nm=h4&&typeof module=="object"&&module&&!module.nodeType&&module,U0e=nm&&nm.exports===h4,dP=U0e&&C_.process,V0e=function(){try{var e=nm&&nm.require&&nm.require("util").types;return e||dP&&dP.binding&&dP.binding("util")}catch{}}(),Xi=V0e;var g4=Xi&&Xi.isTypedArray,q0e=g4?zd(g4):f4,y4=q0e;var K0e=Object.prototype,j0e=K0e.hasOwnProperty;function H0e(e,t){var n=Bd(e),r=!n&&c4(e),i=!n&&!r&&P_(e),o=!n&&!r&&!i&&y4(e),a=n||r||i||o,s=a?a4(e.length,String):[],c=s.length;for(var d in e)(t||j0e.call(e,d))&&!(a&&(d=="length"||i&&(d=="offset"||d=="parent")||o&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||m4(d,c)))&&s.push(d);return s}var E_=H0e;var $0e=Object.prototype;function Y0e(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||$0e;return e===n}var Ud=Y0e;function X0e(e,t){return function(n){return e(t(n))}}var M_=X0e;var W0e=M_(Object.keys,Object),_4=W0e;var J0e=Object.prototype,Q0e=J0e.hasOwnProperty;function Z0e(e){if(!Ud(e))return _4(e);var t=[];for(var n in Object(e))Q0e.call(e,n)&&n!="constructor"&&t.push(n);return t}var T4=Z0e;function eLe(e){return e!=null&&D_(e.length)&&!A_(e)}var N_=eLe;function tLe(e){return N_(e)?E_(e):T4(e)}var Vd=tLe;function nLe(e){return x_(e,Vd,Gd)}var S4=nLe;var rLe=rn(dt,"DataView"),w_=rLe;var iLe=rn(dt,"Promise"),k_=iLe;var oLe=rn(dt,"Set"),O_=oLe;var aLe=rn(dt,"WeakMap"),L_=aLe;var b4="[object Map]",sLe="[object Object]",C4="[object Promise]",A4="[object Set]",I4="[object WeakMap]",v4="[object DataView]",cLe=$i(w_),dLe=$i(ta),uLe=$i(k_),pLe=$i(O_),lLe=$i(L_),Es=Hi;(w_&&Es(new w_(new ArrayBuffer(1)))!=v4||ta&&Es(new ta)!=b4||k_&&Es(k_.resolve())!=C4||O_&&Es(new O_)!=A4||L_&&Es(new L_)!=I4)&&(Es=function(e){var t=Hi(e),n=t==sLe?e.constructor:void 0,r=n?$i(n):"";if(r)switch(r){case cLe:return v4;case dLe:return b4;case uLe:return C4;case pLe:return A4;case lLe:return I4}return t});var qd=Es;function mLe(e,t){for(var n=-1,r=e==null?0:e.length;++n<r&&t(e[n],n,e)!==!1;);return e}var x4=mLe;var fLe=function(){try{var e=rn(Object,"defineProperty");return e({},"",{}),e}catch{}}(),uP=fLe;function hLe(e,t,n){t=="__proto__"&&uP?uP(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}var F_=hLe;var gLe=Object.prototype,yLe=gLe.hasOwnProperty;function _Le(e,t,n){var r=e[t];(!(yLe.call(e,t)&&b_(r,n))||n===void 0&&!(t in e))&&F_(e,t,n)}var B_=_Le;function TLe(e,t,n,r){var i=!n;n||(n={});for(var o=-1,a=t.length;++o<a;){var s=t[o],c=r?r(n[s],e[s],s,n,e):void 0;c===void 0&&(c=e[s]),i?F_(n,s,c):B_(n,s,c)}return n}var ra=TLe;function SLe(e,t){return e&&ra(t,Vd(t),e)}var R4=SLe;function bLe(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}var P4=bLe;var CLe=Object.prototype,ALe=CLe.hasOwnProperty;function ILe(e){if(!Qr(e))return P4(e);var t=Ud(e),n=[];for(var r in e)r=="constructor"&&(t||!ALe.call(e,r))||n.push(r);return n}var D4=ILe;function vLe(e){return N_(e)?E_(e,!0):D4(e)}var Kd=vLe;function xLe(e,t){return e&&ra(t,Kd(t),e)}var E4=xLe;var k4=typeof exports=="object"&&exports&&!exports.nodeType&&exports,M4=k4&&typeof module=="object"&&module&&!module.nodeType&&module,RLe=M4&&M4.exports===k4,N4=RLe?dt.Buffer:void 0,w4=N4?N4.allocUnsafe:void 0;function PLe(e,t){if(t)return e.slice();var n=e.length,r=w4?w4(n):new e.constructor(n);return e.copy(r),r}var O4=PLe;function DLe(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}var L4=DLe;function ELe(e,t){return ra(e,Gd(e),t)}var F4=ELe;var MLe=M_(Object.getPrototypeOf,Object),G_=MLe;var NLe=Object.getOwnPropertySymbols,wLe=NLe?function(e){for(var t=[];e;)v_(t,Gd(e)),e=G_(e);return t}:R_,z_=wLe;function kLe(e,t){return ra(e,z_(e),t)}var B4=kLe;function OLe(e){return x_(e,Kd,z_)}var G4=OLe;var LLe=Object.prototype,FLe=LLe.hasOwnProperty;function BLe(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]=="string"&&FLe.call(e,"index")&&(n.index=e.index,n.input=e.input),n}var z4=BLe;function GLe(e){var t=new e.constructor(e.byteLength);return new sP(t).set(new sP(e)),t}var jd=GLe;function zLe(e,t){var n=t?jd(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}var U4=zLe;var ULe=/\w*$/;function VLe(e){var t=new e.constructor(e.source,ULe.exec(e));return t.lastIndex=e.lastIndex,t}var V4=VLe;var q4=ji?ji.prototype:void 0,K4=q4?q4.valueOf:void 0;function qLe(e){return K4?Object(K4.call(e)):{}}var j4=qLe;function KLe(e,t){var n=t?jd(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}var H4=KLe;var jLe="[object Boolean]",HLe="[object Date]",$Le="[object Map]",YLe="[object Number]",XLe="[object RegExp]",WLe="[object Set]",JLe="[object String]",QLe="[object Symbol]",ZLe="[object ArrayBuffer]",e1e="[object DataView]",t1e="[object Float32Array]",n1e="[object Float64Array]",r1e="[object Int8Array]",i1e="[object Int16Array]",o1e="[object Int32Array]",a1e="[object Uint8Array]",s1e="[object Uint8ClampedArray]",c1e="[object Uint16Array]",d1e="[object Uint32Array]";function u1e(e,t,n){var r=e.constructor;switch(t){case ZLe:return jd(e);case jLe:case HLe:return new r(+e);case e1e:return U4(e,n);case t1e:case n1e:case r1e:case i1e:case o1e:case a1e:case s1e:case c1e:case d1e:return H4(e,n);case $Le:return new r;case YLe:case JLe:return new r(e);case XLe:return V4(e);case WLe:return new r;case QLe:return j4(e)}}var $4=u1e;var Y4=Object.create,p1e=function(){function e(){}return function(t){if(!Qr(t))return{};if(Y4)return Y4(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}(),X4=p1e;function l1e(e){return typeof e.constructor=="function"&&!Ud(e)?X4(G_(e)):{}}var W4=l1e;var m1e="[object Map]";function f1e(e){return Zr(e)&&qd(e)==m1e}var J4=f1e;var Q4=Xi&&Xi.isMap,h1e=Q4?zd(Q4):J4,Z4=h1e;var g1e="[object Set]";function y1e(e){return Zr(e)&&qd(e)==g1e}var e5=y1e;var t5=Xi&&Xi.isSet,_1e=t5?zd(t5):e5,n5=_1e;var T1e=1,S1e=2,b1e=4,r5="[object Arguments]",C1e="[object Array]",A1e="[object Boolean]",I1e="[object Date]",v1e="[object Error]",i5="[object Function]",x1e="[object GeneratorFunction]",R1e="[object Map]",P1e="[object Number]",o5="[object Object]",D1e="[object RegExp]",E1e="[object Set]",M1e="[object String]",N1e="[object Symbol]",w1e="[object WeakMap]",k1e="[object ArrayBuffer]",O1e="[object DataView]",L1e="[object Float32Array]",F1e="[object Float64Array]",B1e="[object Int8Array]",G1e="[object Int16Array]",z1e="[object Int32Array]",U1e="[object Uint8Array]",V1e="[object Uint8ClampedArray]",q1e="[object Uint16Array]",K1e="[object Uint32Array]",Be={};Be[r5]=Be[C1e]=Be[k1e]=Be[O1e]=Be[A1e]=Be[I1e]=Be[L1e]=Be[F1e]=Be[B1e]=Be[G1e]=Be[z1e]=Be[R1e]=Be[P1e]=Be[o5]=Be[D1e]=Be[E1e]=Be[M1e]=Be[N1e]=Be[U1e]=Be[V1e]=Be[q1e]=Be[K1e]=!0;Be[v1e]=Be[i5]=Be[w1e]=!1;function U_(e,t,n,r,i,o){var a,s=t&T1e,c=t&S1e,d=t&b1e;if(n&&(a=i?n(e,r,i,o):n(e)),a!==void 0)return a;if(!Qr(e))return e;var u=Bd(e);if(u){if(a=z4(e),!s)return L4(e,a)}else{var p=qd(e),m=p==i5||p==x1e;if(P_(e))return O4(e,s);if(p==o5||p==r5||m&&!i){if(a=c||m?{}:W4(e),!s)return c?B4(e,E4(a,e)):F4(e,R4(a,e))}else{if(!Be[p])return i?e:{};a=$4(e,p,s)}}o||(o=new r4);var f=o.get(e);if(f)return f;o.set(e,a),n5(e)?e.forEach(function(y){a.add(U_(y,t,n,y,e,o))}):Z4(e)&&e.forEach(function(y,_){a.set(_,U_(y,t,n,_,e,o))});var h=d?c?G4:S4:c?Kd:Vd,g=u?void 0:h(e);return x4(g||e,function(y,_){g&&(_=y,y=e[_]),B_(a,_,U_(y,t,n,_,e,o))}),a}var a5=U_;var j1e=1,H1e=4;function $1e(e){return a5(e,j1e|H1e)}var s5=$1e;function c5(e,t,n=!1){if(e&&typeof e=="object")for(let r of Object.keys(e)){let i=t(r),o=e[r];i!==r&&(e[i]=o,delete e[r]),o===null&&n&&(e[i]=void 0),c5(e[i],t,n)}return e}var d5=(e,t,n=!0)=>c5(n?s5(e):e,t??Y1e,!0);function Y1e(e){return e.replace(/_([a-z])/g,(t,n)=>n.toUpperCase())}var X1e="biz/timeline-composition-draft",W1e=["clipsById","sources","tracksById"];function yt(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function ei(e){return typeof e=="string"&&e.trim()?e:void 0}function J1e(e){var r;let t=e.replace(/_([a-zA-Z0-9])/g,(i,o)=>o.toUpperCase()),n=t&&`${(r=t[0])==null?void 0:r.toLowerCase()}${t.slice(1)}`;return Array.from(new Set([e,t,n]))}function V_(e,t){for(let n of J1e(t))if(n in e)return e[n]}function Q1e(e){if(yt(e))return ei(e.id)??ei(e.pippitAssetId)??ei(e.pippit_asset_id)??ei(e.PippitAssetID)}function u5(e,t){return(ei(e.type)??ei(t.type)??ei(t.Type))==="canvas"&&(t.content!==void 0||t.Content!==void 0)}function p5(e,t){return(ei(e.type)??ei(t.type)??ei(t.Type))===X1e}function lP(e,t,n,r){let i=yt(e[n])?e[n]:yt(e[r])?e[r]:null,o=yt(t[r])?t[r]:yt(t[n])?t[n]:null;if(!i||!o)return;let a={};for(let s of Object.keys(o))a[s]=V_(i,s)??o[s];e[n]=a}function pP(e,t,n,r){let i=yt(e[n])?e[n]:null,o=yt(t[n])?t[n]:null;if(!i||!o)return;let a=new Map;for(let c of Object.values(i)){let d=Q1e(c);d&&a.set(d,c)}let s={};for(let c of Object.keys(o)){let d=V_(i,c)??a.get(c)??o[c];r(d,o[c]),s[c]=d}e[n]=s}function Z1e(e,t){let n=yt(e.content)?e.content:null,r=yt(t.content)?t.content:null;if(!(!n||!r))for(let i of W1e)lP(n,r,i,i)}function l5(e,t){let n=t.extra??t.Extra;n!==void 0&&(e.extra=n)}function eFe(e,t,n){let r=e.assets,i=t.assets;if(!(!Array.isArray(r)||!Array.isArray(i)))for(let o=0;o<Math.min(r.length,i.length);o+=1){let a=r[o],s=i[o];if(!yt(a)||!yt(s))continue;let c=V_(a,"asset"),d=V_(s,"asset");yt(c)&&yt(d)&&u5(c,d)&&l5(c,d),yt(c)&&yt(d)&&(p5(c,d)||c.type===Bi)&&n(c,d)}}function tFe(e,t,n){for(let r of["document","canvasDocument","canvas_document","snapshot","data","content","payload","value"]){let i=e[r],o=t[r];yt(i)&&yt(o)&&n(i,o)}}function Hd(e,t){if(!(!yt(e)||!yt(t))){if(u5(e,t)||e.type===Bi){let n=t.content??t.Content;n!==void 0&&(e.content=n),l5(e,t);return}p5(e,t)&&Z1e(e,t),eFe(e,t,Hd),pP(e,t,"assets",Hd),pP(e,t,"nodes",Hd),pP(e,t,"edges",Hd),lP(e,t,"assetVersions","asset_versions"),lP(e,t,"currentAssetVersions","current_asset_versions"),tFe(e,t,Hd)}}function m5(e){let t=d5(e);return Hd(t,e),t}function f5(e){return m5(e)}var g5=(e,t=!0)=>{if(!e)return null;try{let n=JSON.parse(e);return t?f5(n):n}catch{return e}},$d=e=>({mediaType:"text",pippitAssetId:e}),fP=e=>e==null?void 0:e.version,nFe=e=>Object.fromEntries(e),rFe=e=>[...e.repairPatches??[],...e.layoutPatches??[]],mP=(e,t)=>e.op==="add"&&e.path===""?0:t.get(e.assetId),iFe=async(e,t,n,r)=>{let i=[...new Set(t.filter(a=>mP(a,n)===void 0).map(a=>a.assetId))];if(!i.length)return;let o=new Set(i);try{(await e.assets.queryAssets(i.map($d),{cachePolicy:"refresh",dispatchMode:"immediate",signal:r})).forEach(({asset:s,ref:c})=>{let d=fP(s),u=c.pippitAssetId;u&&o.has(u)&&d!==void 0&&n.set(u,d)})}catch(a){Wt.error("[xyq-canvas-sdk:restore] failed to refresh restore patch asset versions",a,{assetIds:i})}},oFe=async(e,t,n,r)=>{var c;let i=rFe(t);if(!i.length)return;await iFe(e,i,n,r);let o=i.filter(d=>mP(d,n)===void 0);o.length&&Wt.error("[xyq-canvas-sdk:restore] skipped restore patches without base asset versions",{assetIds:[...new Set(o.map(d=>d.assetId))],canvasAssetId:t.canvasAssetId,patchCount:o.length});let a=i.flatMap(d=>{let u=mP(d,n);return u===void 0?[]:[{baseVersion:u,op:d.op,path:d.path,ref:$d(d.assetId),...d.op==="remove"?{}:{value:d.value}}]});if(!a.length)return;let s=await e.assets.patchAssets({intent:(c=t.repairPatches)!=null&&c.length?"restore.repairDocument":"restore.repairLayout",patches:a,refresh:!1,rootRef:$d(t.canvasAssetId),transactionId:`restore_${t.canvasAssetId}_${Date.now()}`});Object.entries(s.versions??{}).forEach(([d,u])=>n.set(d,u))},aFe=({client:e,onAssetVersion:t,preloadedAssets:n})=>{let r=async({pippitAssetIds:o,isCamelCase:a=!0,signal:s},c)=>{let d=o.filter(f=>!(n!=null&&n.has(f))),[u,p]=await Promise.all([d.length>0?e.assets.queryAssets(d.map($d),c?{dispatchMode:c,signal:s}:{signal:s}):Promise.resolve([]),Promise.all(o.filter(f=>n==null?void 0:n.has(f)).map(async f=>[f,await(n==null?void 0:n.get(f))]))]),m=new Map;return u.forEach(({asset:f,ref:h})=>{m.set(h.pippitAssetId,f)}),p.forEach(([f,h])=>{m.set(f,h??null)}),o.map(f=>{var y;let h=m.get(f)??null,g=fP(h);return g!==void 0&&(t==null||t(f,g)),{extra:(h==null?void 0:h.extra)??null,pippitAssetId:f,value:g5((y=h==null?void 0:h.text)==null?void 0:y.content,a)}})},i=o=>r(o);return i.queryImmediately=o=>r(o,"immediate"),i},h5=async(e,t)=>{var a;let n=fP(t),r=g5((a=t==null?void 0:t.text)==null?void 0:a.content);if(r===null)return{asset:null,assetId:e.assetId,...n===void 0?{}:{assetVersion:n}};if(e.assetKind==="canvas"){let s=await I8(r,{canvasAssetId:e.assetId});return{asset:(s==null?void 0:s.assets[e.assetId])??null,assetId:e.assetId,...n===void 0?{}:{assetVersion:n}}}let i=y_(r,{nodeAssetId:e.assetId,nodeType:e.nodeType});return{asset:i?{...i,assetExtra:(t==null?void 0:t.extra)??null}:null,assetId:e.assetId,...n===void 0?{}:{assetVersion:n}}};function y5({client:e,includeGenerationHistory:t=!0,enableCoverAssetPrefetch:n=!1,initialRootAsset:r,onRestoreEvent:i,onRestoreResult:o,requireCompleteNodeAssets:a,resolvePriorityNodeAssetIds:s}){let c=r,d=new Set,u=n?async({pippitAssetIds:p,signal:m})=>{await e.assets.queryAssets(p.map(f=>({pippitAssetId:f})),{batchingStrategy:"max-size",dispatchMode:"immediate",signal:m})}:void 0;return{async fetchSnapshot({scopeAssetId:p,signal:m,onProgress:f}){let h=c;c=void 0;let g=new Map,y=await x8(p,{includeGenerationHistory:t,debugLog:!1,onEvent:i,prefetchCoverAssets:u,onRootDocumentReady:S=>{f==null||f({kind:"root-ready",document:S})},onNodeAssetsReady:({document:S,readyNodeAssetIds:T})=>{f==null||f({kind:"assets-ready",document:S,readyAssetIds:T})},onNodeAssetsSettled:S=>{f==null||f({kind:"assets-settled",document:S})},queryTextAssetContent:aFe({client:e,onAssetVersion:(S,T)=>g.set(S,T),preloadedAssets:h?new Map([[p,h]]):void 0}),requireCompleteNodeAssets:a,resolvePriorityNodeAssetIds:s,signal:m});await oFe(e,y,g,m);let _=hl(y.document);return d.clear(),_&&y.document.assets[_]&&d.add(_),o==null||o(y),{assetVersions:nFe(g),state:y.document}},async fetchAssets({requests:p,signal:m}){var _,S;let f=await e.assets.queryAssets(p.map(({assetId:T})=>$d(T)),{signal:m}),h=await Promise.all(p.map((T,C)=>{var I;return h5(T,((I=f[C])==null?void 0:I.asset)??null)})),g={};f.forEach(({asset:T},C)=>{(T==null?void 0:T.version)!==void 0&&(g[p[C].assetId]=T.version)});let y=new Set;for(let T of h){if(!t)break;if(((_=T.asset)==null?void 0:_.type)!=="canvas")continue;let C=hl({rootCanvasId:T.assetId,assets:{[T.assetId]:T.asset}});C&&!d.has(C)&&!h.some(I=>I.assetId===C)&&y.add(C)}if(y.size){let T=[...y],C=await e.assets.queryAssets(T.map($d),{signal:m});for(let I=0;I<T.length;I+=1){let x=((S=C[I])==null?void 0:S.asset)??null,R=await h5({assetId:T[I],assetKind:"node"},x);h.push(R),R.asset&&d.add(T[I]),(x==null?void 0:x.version)!==void 0&&(g[T[I]]=x.version)}}return{assets:h,assetVersions:g}}}}var hP=["9:16","16:9","21:9","3:4","4:3","1:1"],sFe={"9:16":{w:236,h:420},"16:9":{w:420,h:236},"21:9":{w:420,h:180},"3:4":{w:315,h:420},"4:3":{w:420,h:315},"1:1":{w:360,h:360}},cFe={"9:16":"9:16","16:9":"16:9","21:9":"21:9","3:4":"3:4","4:3":"4:3","1:1":"1:1"},dFe={"9:16":{width:9,height:16},"16:9":{width:16,height:9},"21:9":{width:21,height:9},"3:4":{width:3,height:4},"4:3":{width:4,height:3},"1:1":{width:1,height:1}};function T5(e){return hP.includes(e)}function uFe(e){return cFe[e]}function S5(e){return sFe[e]}function b5(e){return(e==null?void 0:e.type)===Oe||(e==null?void 0:e.type)===ee||(e==null?void 0:e.type)===qe||(e==null?void 0:e.type)===J}function C5(e){return(e==null?void 0:e.type)===ee||(e==null?void 0:e.type)===qe||(e==null?void 0:e.type)===J}function _5(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function pFe(e){return"metadata"in e||"naturalWidth"in e||"caption"in e}function lFe(e){return"playback"in e||"frameWidth"in e||"durationMs"in e||"title"in e}function A5(e,t){let n=e,r=uFe(t),i=dFe[t],o={...n,generation:{..._5(n.generation)?n.generation:{},ratio:r}},a=lFe(n);return!a&&pFe(n)&&(o.metadata={..._5(n.metadata)?n.metadata:{},ratio:r}),a&&(o.ratio=i),o}function I5(){return X.t("Pippit_xyqcanvas_legacy_label_unnamed_role",{},"未命名角色")}function q_(){return X.t("Pippit_xyqcanvas_interactive_episode_label_unnamedepisode",{},"未命名分集")}function K_(e,t){let n=Mh(t);return n.length>0?{...e,episodes:n}:e}function v5(e,t,n={}){return K_({nodeName:e,order:t,basicInfo:{name:e,...n.defaultAppearanceName?{appearanceName:n.defaultAppearanceName}:{}}},n.defaultEpisodeIds)}var R5={text:{type:mo.type,createNodeData:()=>({}),createAsset:e=>Yd(e,mo.type,{plainText:"",placeholder:X.t("Pippit_xyqcanvas_legacy_label_text",{},"文本"),block:{verticalAlign:"top",overflow:"wrap",padding:IO.padding}}),getDefaultSize:e=>{var t,n;return((n=(t=mo).getDefaultSize)==null?void 0:n.call(t,e))??{w:420,h:180}}},image:{type:fi.type,createNodeData:()=>({}),createAsset:(e,t,n)=>Yd(e,fi.type,K_(gP({caption:X.t("Pippit_xyqcanvas_legacy_label_picture",{},"图片")},n==null?void 0:n.defaultVideoRatio),n==null?void 0:n.defaultEpisodeIds)),getDefaultSize:e=>{var t,n;return((n=(t=fi).getDefaultSize)==null?void 0:n.call(t,e))??{w:480,h:373}}},video:{type:hi.type,createNodeData:()=>({}),createAsset:(e,t,n)=>Yd(e,hi.type,K_(gP({title:X.t("Pippit_xyqcanvas_legacy_title_video",{},"视频"),caption:X.t("Pippit_xyqcanvas_legacy_title_video",{},"视频"),playback:{muted:!0}},n==null?void 0:n.defaultVideoRatio),n==null?void 0:n.defaultEpisodeIds)),getDefaultSize:e=>{var t,n;return((n=(t=hi).getDefaultSize)==null?void 0:n.call(t,e))??{w:480,h:270}}},audio:{type:lo.type,createNodeData:()=>({}),createAsset:(e,t,n)=>Yd(e,lo.type,K_({},n==null?void 0:n.defaultEpisodeIds)),getDefaultSize:e=>{var t,n;return((n=(t=lo).getDefaultSize)==null?void 0:n.call(t,e))??{w:362,h:218}}},role:{type:La.type,createNodeData:()=>({name:I5()}),createAsset:(e,t,n)=>({pippitAssetId:e,type:Yb,content:v5(I5(),t,{defaultAppearanceName:Jk(),defaultEpisodeIds:n==null?void 0:n.defaultEpisodeIds}),extra:{}}),getDefaultSize:e=>La.getDefaultSize(e)},scene:{type:sp.type,createNodeData:()=>({name:$b()}),createAsset:(e,t,n)=>({pippitAssetId:e,type:oC,content:gP(v5($b(),t,{defaultEpisodeIds:n==null?void 0:n.defaultEpisodeIds}),n==null?void 0:n.defaultVideoRatio),extra:{}}),getDefaultSize:e=>{var t,n;return((n=(t=sp).getDefaultSize)==null?void 0:n.call(t,e))??{...Ga}}},scene3d:{type:pp.type,createNodeData:()=>({title:gC()}),createAsset:(e,t,n)=>{let r=yC(),i=n==null?void 0:n.initialData;return MO({document:i&&Object.keys(i).length>0?{...r,...i}:r,documentAssetId:n==null?void 0:n.scene3DDocumentAssetId,nodeId:e})},getDefaultSize:e=>{var t,n;return((n=(t=pp).getDefaultSize)==null?void 0:n.call(t,e))??{w:420,h:236}}},"timeline-composition":{type:wp.type,createNodeData:()=>({title:DA()}),createAsset:(e,t,n)=>X1({draftAssetId:(n==null?void 0:n.timelineDraftAssetId)??`${e}-timeline-draft`,episodeIds:n==null?void 0:n.defaultEpisodeIds,nodeId:e}),getDefaultSize:e=>{var t,n;return((n=(t=wp).getDefaultSize)==null?void 0:n.call(t,e))??{w:440,h:334}}},"interactive-episode":{type:WA,createNodeData:()=>({title:q_(),selectionOptions:[]}),createAsset:e=>Yd(e,fg.type,{title:q_(),selectionOptions:[]}),getDefaultSize:e=>{var t,n;return((n=(t=fg).getDefaultSize)==null?void 0:n.call(t,e))??{w:Gp,h:QA}}},"interactive-episode-video":{type:JA,createNodeData:()=>({title:q_(),selectionOptions:[]}),createAsset:e=>Yd(e,ZA.type,{title:q_(),selectionOptions:[]}),getDefaultSize:e=>{var t,n;return((n=(t=ZA).getDefaultSize)==null?void 0:n.call(t,e))??{w:Gp,h:QA}}}},mFe=new Set(Object.keys(R5));function P5(){return[...mFe]}function Yd(e,t,n){return{pippitAssetId:e,type:t,content:n,extra:{}}}function gP(e,t){return t?A5(e,t):e}function x5(e,t){if(!t||Object.keys(t).length===0)return e;let n=e.content&&typeof e.content=="object"&&!Array.isArray(e.content)?e.content:{};return{...e,content:{...n,...t}}}function fFe(e){return Array.isArray(e)?e:[e]}function hFe({defaultSize:e,initialSize:t}){let n=t.w>0&&t.h>0?t.w/t.h:void 0;if(!n)return e;let r=Math.max(1,e.w*e.h);return{w:Math.round(Math.sqrt(r*n)),h:Math.round(Math.sqrt(r/n))}}function D5({kind:e,id:t,center:n,topLeft:r,initialData:i,initialAssetContent:o,initialNodeData:a,order:s=0,existingNodes:c,defaultEpisodeIds:d,defaultEpisodes:u,defaultVideoRatio:p,scene3DDocumentAssetId:m,timelineDraftAssetId:f}){let h=R5[e],g=h.createNodeData(t),y=a?{...g,...a}:g,_=!!(i&&Object.keys(i).length>0),S=_?{...y,...i}:y,T=p&&!_&&C5({type:h.type}),C=p&&b5({type:h.type}),I=T?S5(p):_&&(e==="image"||e==="video")?hFe({defaultSize:h.getDefaultSize(y),initialSize:h.getDefaultSize(S)}):h.getDefaultSize(S),x=r??WM({center:n??{x:0,y:0},size:I,existingNodes:c}),R=fFe(h.createAsset(t,s,{defaultEpisodeIds:d??u,defaultVideoRatio:C?p:void 0,initialData:i,scene3DDocumentAssetId:m,timelineDraftAssetId:f})),G=R[0],O=e==="scene3d"||e==="timeline-composition"||!G?R:[x5(x5(G,i),o),...R.slice(1)];return{node:{id:t,type:h.type,x:x.x,y:x.y,w:I.w,h:I.h,parentId:null,order:s,data:y},assets:O}}var Wi=Ee({legacy:"Legacy upload",optimized:"Optimized upload"}),rm={type:"string",enum:Object.values(fn)},j_=v({threadId:A,runId:A,target:A,status:Ee({submitting:"Submitting",running:"Running",succeeded:"Succeeded",failed:"Failed"}),submittedAt:A,updatedAt:A,errorMessage:A,failureContext:{...mt,properties:{partial_edit_videos:{type:"array",items:v({asset_id:A,cover_preview_key:A,description:A,metadata:mt,pippit_asset_id:A,security_check_scene:ke,time_range:v({end_time_us:E,start_time_us:E},["end_time_us","start_time_us"],"Microseconds.")},["time_range"])}}}}),gFe=v({id:A,type:A,assetId:A,dataReferenceSelection:ke,edgeId:A,nodeAssetExtra:{type:"object",additionalProperties:A},nodeAssetId:A,nodeAssetType:A,pippitAssetId:A,referenceSource:A,sourceNodeId:A,sourceNodeType:A,uploadPath:Wi,label:A,metadata:mt}),yFe=v({styleId:A,stylePeBefore:A,stylePeAfter:A,stylePosition:A,modelKey:A,stylePe:A,style_id:A,title:A,style_pe_before:A,style_pe_after:A,style_position:A,version:A,model_key:A,style_pe:A,category:A}),_Fe=Ee({lighting:"Lighting",shot:"Shot",panorama:"Panorama",three_view:"Three views",character:"Character",scene:"Scene"}),E5={type:["string","number","boolean","null"]},M5,Ms=v({agentName:A,handleByServer:Ue,submitRunClientExtra:mt,generateId:A,taskId:A,artifactId:A,threadId:A,runId:A,source:{type:"string",examples:Object.values(fn),description:"Generation provenance source; open string for existing integrations."},runSource:A,outputContract:A,outputAppliedRunId:A,outputName:A,outputAudioType:A,prompt:{type:"string",description:"Generation prompt; independent of display caption/title/name."},submittedPrompt:A,promptContentFormat:{type:"string",examples:Object.values(Th)},webLinks:ke,modelKey:{type:"string",description:"Model key from the host model catalog; available models depend on region and account capabilities."},audioConfig:v({format:A,loudnessRate:E,pitchRate:E,sampleRate:E,speechRate:E}),mode:A,args:v(Object.fromEntries(Gb.map(e=>[e,E5]))),cameraMotion:A,count:E,durationMs:{type:"number",description:"Milliseconds."},novelStyle:A,promptTemplate:_Fe,ratio:{type:"string",examples:["9:16","16:9","1:1"],description:"Model-supported aspect ratio; available values come from the host model catalog."},videoRatioUpdatedAt:E,successfulGenerationCount:E,lastSuccessfulGenerationRunId:A,resolution:{type:"string",description:"Model-supported resolution from the host model catalog."},effort:A,styleSnapshot:st(yFe),styleSnapshotPinnedAt:E,seed:E,params:{...v(Object.fromEntries(Bb.map(e=>[e,E5]))),deprecated:!0,description:"Legacy generation parameters; prefer top-level configuration and args."},references:{type:"array",items:gFe},state:j_,snapshot:mt,sceneSegmentation:v({errorMessage:A,output:mt,runId:A,sourceKey:A,sourceVideo:v({assetId:A,durationMs:E,fileId:A,id:A,materialId:A,mediaId:A,pippitAssetId:A,range:v({endMs:E,startMs:E}),sourceAssetId:A,sourceNodeType:A,type:A,videoId:A}),status:((M5=j_.properties)==null?void 0:M5.status)??A,submittedAt:A,threadId:A,updatedAt:A}),createdAt:A});var yP={type:"number",enum:Object.values(lc).filter(e=>typeof e=="number"),description:Object.entries(lc).filter(([,e])=>typeof e=="number").map(([e,t])=>`${t}: ${e}`).join("; ")},H_={type:"number",enum:Object.values(mc).filter(e=>typeof e=="number"),description:Object.entries(mc).filter(([,e])=>typeof e=="number").map(([e,t])=>`${t}: ${e}`).join("; ")},_P={type:"object",description:"Candidate Pippit asset id to isMain selection flag.",additionalProperties:{type:"boolean"}},TP=v({pippitAssetId:A,assetId:A,name:A,order:E,type:Ee({audio:"Audio",image:"Image",video:"Video"}),uploadPath:Wi,isMain:Ue,isDefault:{type:"boolean",deprecated:!0,description:"Preserved for old documents; references are controlled through mentions."},metadata:A}),N5=v({imageSource:yP,assetId:A,pippitAssetId:A,candidatePippitAssetIds:_P,uploadPath:Wi,description:A,modify:A}),TFe=v({ttsProvider:E,age:A,gender:A,speaker:A,voiceId:A,description:A,voice_type:H_,audioAssetId:A,audioPippitAssetId:A,audioName:A,audioDurationMs:E,audioSource:rm,audioNodeId:A}),SP=v({nodeName:A,order:E,basicInfo:v({name:A,appearanceName:A,stageTag:A,label:A,isMainImage:Ue,description:A,biography:A,alias:ke,referName:A,unpromptable:Ue,isMainCharacter:Ue}),useContext:A,episodes:ke,createType:{type:"string",enum:Object.values(Hb)},appearanceInfo:N5,referenceAppearances:{type:"array",items:N5},voiceInfo:TFe,generation:Ms,sourceInfos:{type:"object",additionalProperties:TP,description:"Map keyed by canonical pippitAssetId."}});var $_={name:A,variant:{type:"string",description:"Node-type-specific variant; omitted means the default."},generation:Ms},SFe={source:{type:"string",enum:Object.values(Ju)},uploadPath:Wi},w5=v({fit:Ee({contain:"Contain",cover:"Cover",fill:"Fill",none:"No fit"}),crop:v({x:E,y:E,w:E,h:E},["x","y","w","h"],"Normalized crop coordinates relative to original media, 0..1."),rotation:E,flipX:Ue,flipY:Ue,opacity:E}),k5=v({startMs:E,endMs:E,currentTimeMs:E,playbackRate:E,muted:Ue,loop:Ue,volume:E},[],"Playback time fields use milliseconds."),O5={id:A,cachedAt:E,errorMessage:A,fileName:A,mimeType:A,size:E,uploadPath:Wi},L5=st(v({...O5,type:Ee({image:"Image",video:"Video"}),status:Ee({failed:"Failed upload",uploaded:"Upload completed"})},["id","type","status"],"Existing browser cache reference; creating metadata does not upload a file.")),bFe=st(v({...O5,cacheId:A,type:Ee({audio:"Audio",image:"Image",video:"Video"}),status:Ee({capturing:"Capturing",uploading:"Uploading",failed:"Failed"}),sourceKind:Ee({manual:"Manual upload","image-operation":"Image operation","panorama-capture":"Panorama capture","panorama-grid":"Panorama grid","scene3d-capture-send":"3D capture","video-trim":"Video trim"})},["id","type","status"],"Existing upload task reference; creating metadata does not start a task.")),F5=st(v({kind:A},[],"Server-owned processing state; other keys are server extensions.")),bP={...$_,...SFe,pippitAssetId:A,assetId:A,episodes:ke,securityCheckScene:ke,tagInfos:{type:"array",items:v({tag:{type:"string",examples:Object.values(hO),description:"Open tag name; examples list built-in tags."}})},localUploadTask:bFe},B5={type:"array",items:{anyOf:[v({kind:{const:"node"},nodeId:A},["kind","nodeId"]),v({kind:{const:"reference"},referenceKey:A},["kind","referenceKey"]),{type:"string",deprecated:!0,description:"Legacy node id."}]}},G5=v({...$_,plainText:A,markdownText:A,placeholder:A,content:v({type:A,text:A,attrs:mt,marks:{type:"array",items:v({type:A,attrs:mt})},content:{type:"array",items:{...Cr,description:"Nested Tiptap JSONContent. Its node/mark types and attrs are owned by the host Tiptap extensions."}}},[],"Tiptap JSONContent, usually type=doc; keep plainText and markdownText in sync."),block:v({verticalAlign:Ee({top:"Top",middle:"Middle",bottom:"Bottom"}),overflow:Ee({clip:"Clip",wrap:"Wrap","auto-height":"Grow height with content"}),padding:{type:"number",description:"Pixels."}})}),z5=v({...bP,naturalWidth:E,naturalHeight:E,caption:A,display:w5,isCover:Ue,candidatePippitAssetIds:_P,subType:A,sourceType:{type:"number",enum:Object.values(op).filter(e=>typeof e=="number"),description:Object.entries(op).filter(([,e])=>typeof e=="number").map(([e,t])=>`${t}: ${e}`).join("; ")},metadata:v({width:E,height:E,format:A,md5:A,frameCount:E,size:E,ratio:A,name:A}),localUploadCache:L5,serverProcessing:F5,pictureId:A,draftId:A,scene3dCameraId:A,scene3dCameraName:A,scene3dCaptureId:A,scene3dSourceNodeId:A,imagePartialEdit:v({sourceAssetId:A,sourceHeight:E,sourceNodeId:A,sourcePippitAssetId:A,sourceWidth:E,regions:{type:"array",items:v({id:A,text:A,rect:v({height:E,width:E,x:E,y:E},["height","width","x","y"])},["id","rect"])}},["sourceNodeId","sourcePippitAssetId"]),inputOrder:B5}),U5=v({...bP,frameWidth:E,frameHeight:E,durationMs:E,ratio:v({width:E,height:E},["width","height"]),caption:A,display:w5,playback:k5,subType:A,title:A,duration:{type:"number",description:"Legacy duration in seconds; prefer durationMs for new data."},width:E,height:E,metadata:v({width:E,height:E,fps:E,format:A,durationMS:E,durationMs:E,size:E,bitrate:E,definition:A,codecType:A,encodedType:A,fileHash:A,md5:A,ratio:A,name:A}),renderTaskID:A,draftKey:A,packageID:A,vid:A,extra:{type:"object",additionalProperties:A},coverPreviewKey:A,localUploadCache:L5,localProcessing:st(v({kind:{const:"video-trim"},rangeMs:v({endMs:E,startMs:E},["endMs","startMs"])},["kind"])),serverProcessing:F5,inputOrder:B5}),V5=v({...bP,durationMs:E,playback:k5,waveformKey:A});var q5=v({...$_,canvasPosition:xa,displayContent:A,displayCode:A,endingLabel:A,endingType:Ee({BE:"Bad ending",HE:"Happy ending",OE:"Open ending"}),episodeId:A,groupName:A,isRoot:Ue,scriptReady:Ue,storyboardReady:Ue,summary:A,title:A,transType:A,videoReady:Ue,selectionOptions:{type:"array",items:v({nextEpisodeId:A,optionText:A,selectionIdx:E,targetDisplayCode:A},["optionText","selectionIdx"])}}),Xd=v({scene_object_id:A,anchor_id:A},["scene_object_id","anchor_id"]),CFe=v({version:{const:1},nodes:{type:"array",items:{...mt,description:"Director scene node DTO; use the 3D domain edit command to add or edit nodes with a discoverable operation schema."}},generate:A,generate_run_id:A,applied_generate_run_id:A,activeCameraId:{type:"string",deprecated:!0,description:"Legacy active camera id; use activeShotCameraNodeId."},activeShotCameraNodeId:A,aspectRatio:A,customAspectRatio:v({width:E,height:E},["width","height"]),settings:{...mt,description:"Director settings owned by the 3D SDK; use the 3D domain edit command for supported operations."},environment:{...mt,description:"Director environment owned by the 3D SDK; use the 3D domain edit command for supported operations."},captures:{type:"array",items:{...mt,description:"Existing capture metadata; supplying it does not render or upload an image."}},scenePlan:v({revision:E,appliedExecutionKeys:ke},["revision","appliedExecutionKeys"]),physicalConstraints:{type:"array",items:v({constraint_id:A,type:A,supported_anchor:Xd,supporting_anchor:Xd,attached_anchor:Xd,target_anchor:Xd,anchor_a:Xd,anchor_b:Xd,align_rotation:Ue},["constraint_id","type"])},characterGroups:{type:"array",items:v({group_id:A,name:A,member_ids:ke},["group_id","member_ids"])}},[],"Shallow overrides of the default DirectorSceneDocument, not canvas node data. Prefer factory defaults and 3D semantic operations over replacing a complete document."),AFe={text:G5,image:z5,video:U5,audio:V5,role:SP,scene:SP,scene3d:CFe,"timeline-composition":{...mt,deprecated:!0,description:"Ignored by the timeline factory. It always creates an empty companion TimelineDraft; use timeline domain commands to add tracks/clips. defaultEpisodeIds initializes the composition episode scope."},"interactive-episode":q5,"interactive-episode-video":q5},K5={...v({nodeKind:{type:"string",enum:P5(),description:"Business node factory kind. scene3d creates a 3D director node and document asset; timeline-composition creates a multitrack node and companion timeline draft."},id:{type:"string",description:"Node/primary asset id; required unless the caller configures allocateNodeId."},topLeft:{...xa,description:"Explicit top-left position, takes precedence over center."},center:{...xa,default:{x:0,y:0},description:"Placement search center when topLeft is omitted; existing nodes are avoided."},order:{type:"number",default:0},initialData:{type:"object",additionalProperties:!0,description:"Kind-specific initial asset content; see conditional schemas. Merged shallowly except scene3d (document overrides) and timeline-composition (ignored)."},defaultEpisodeIds:ke,defaultEpisodes:{...ke,deprecated:!0,description:"Legacy alias, used only when defaultEpisodeIds is omitted."},defaultVideoRatio:{type:"string",enum:hP,description:"Canvas global aspect ratio; applies to image/video/scene defaults."}},["nodeKind"]),allOf:Object.entries(AFe).map(([e,t])=>({if:{properties:{nodeKind:{const:e}},required:["nodeKind"]},then:{properties:{initialData:t}}})),examples:[{nodeKind:"scene3d"},{nodeKind:"timeline-composition"},{nodeKind:"text",initialData:{plainText:"Scene notes"}}]};var CP={nodeId:A,assetId:{type:"string",description:"Must match nodeId and the selected node asset identity."}},IFe=v({assetId:A,audioNodeId:A,durationMs:E,name:A,audioSource:rm,playbackStartMs:E,playbackEndMs:E,pippitAssetId:A,previousPippitAssetId:A},[],"Audio time values are milliseconds. Omit value to clear voiceAudio."),vFe={appearance:A,appearanceName:A,characterName:A,episodes:{type:"string",description:"Episode IDs separated by commas, whitespace or 、; normalized to an ID array."},voice:A,voiceAudio:IFe,voiceType:H_},xFe={description:A,episodes:ke,sceneName:A,sceneViewName:A};function j5(e,t){return{...v({...CP,field:{type:"string",enum:Object.keys(e)},value:{anyOf:Object.values(e),description:"Value shape depends on field; see the conditional schemas."}},["nodeId","assetId","field",...t?["value"]:[]]),allOf:Object.entries(e).map(([n,r])=>({if:{properties:{field:{const:n}},required:["field"]},then:{properties:{value:r}}}))}}var Dn=st(A),H5=v({audioAssetId:Dn,audioDurationMs:st(E),audioName:Dn,audioNodeId:Dn,audioPippitAssetId:Dn,audioSource:st(rm),description:A,voiceId:Dn,voiceType:H_}),RFe=v({assetId:A,imageSource:yP,pippitAssetId:A,uploadPath:Wi}),PFe=v({appearanceDescription:A,appearanceName:A,characterName:A,episodes:ke,generation:{...st(Ms),description:"Complete generation provenance replacement; null clears it. Use generationPrompt to update only the prompt."},generationPrompt:Dn,generationRun:v({state:{...j_,required:["runId","threadId"]}},["state"]),mainImage:RFe,voice:H5}),DFe=v({appearanceName:Dn,characterName:Dn,episodes:ke,generation:st(Ms),generationPrompt:Dn,generationRun:v({runId:Dn,threadId:Dn}),mainImage:v({assetId:Dn,pippitAssetId:Dn}),voice:H5},[],"Snapshot when editing started; conflicting fields are skipped by the existing command, not overwritten."),EFe={delete:v({pippitAssetId:A},["pippitAssetId"]),reorder:v({activePippitAssetId:A,overPippitAssetId:A},["activePippitAssetId","overPippitAssetId"]),setDefault:{...v({isDefault:{type:"boolean"},pippitAssetId:A},["isDefault","pippitAssetId"]),deprecated:!0},setMain:v({pippitAssetId:A},["pippitAssetId"]),setName:v({name:A,pippitAssetId:A},["name","pippitAssetId"]),upsert:v({sourceInfo:TP},["sourceInfo"])},MFe={type:"object",properties:{type:Ee({delete:"Delete reference",reorder:"Reorder reference",setDefault:"Legacy default flag",setMain:"Set main image",setName:"Rename reference",upsert:"Insert or update reference"})},required:["type"],additionalProperties:!0,oneOf:Object.entries(EFe).map(([e,t])=>({...t,properties:{...t.properties,type:{const:e}},required:["type",...t.required??[]]}))},im={[kc]:j5(vFe,!1),[To]:v({...CP,expected:DFe,patch:PFe},["nodeId","assetId","patch"]),[So]:v({...CP,operation:MFe},["nodeId","assetId","operation"]),[Bc]:j5(xFe,!0)};var Y_=[...mh.filter(({kind:e})=>e!=="invoke_command"),{get description(){return X.t("Pippit_xyqcanvas_command_desc_createbusinessnode",{},"使用小云雀现有业务工厂创建文字、图片、视频、音频、角色、场景或 3D 导演台节点")},input:"{nodeKind, id?, topLeft?, center?, order?, initialData?, defaultEpisodeIds?, defaultVideoRatio?}",inputSchema:K5,kind:"create_biz_node"}],AP=[{get description(){return X.t("Pippit_xyqcanvas_command_desc_updaterolefields",{},"更新角色名称、描述、集数、音色或配音字段")},input:"{nodeId, assetId, field, value}",name:kc,inputSchema:im[kc]},{get description(){return X.t("Pippit_xyqcanvas_command_desc_updateroleappearance",{},"更新角色外观主图、描述和音色信息")},input:"{nodeId, assetId, patch}",name:To,inputSchema:im[To]},{get description(){return X.t("Pippit_xyqcanvas_command_desc_updaterolereferenceimages",{},"更新角色参考图来源列表")},input:"{nodeId, assetId, operation}",name:So,inputSchema:im[So]},{get description(){return X.t("Pippit_xyqcanvas_command_desc_updatescenefields",{},"更新场景名称、场景视图、描述或集数字段")},input:"{nodeId, assetId, field, value}",name:Bc,inputSchema:im[Bc]}];function NFe(e){return!!(e&&typeof e=="object"&&"kind"in e&&e.kind==="invoke_command")}function wFe(e,t){let n=e.filter(NFe);if(n.length===0)return;if(e.length!==1||n.length!==1)throw new Error("Registered business commands must run as a single mutation");let[{name:r}]=n;if(!t.has(r))throw new Error(`Unsupported registered business command: ${r}`)}function $5(e){return e.kind==="create_biz_node"}async function kFe(e,t,n){let r=[],i=new Set,o=new Set(e.mutations.filter($5).flatMap(a=>a.id?[a.id]:[]));for(let a of e.mutations){if(!$5(a)){r.push(a);continue}let s=a.id??(t?await t(a):void 0);if(!s)throw new Error("create_biz_node requires id when allocateNodeId is not configured");if(i.has(s))throw new Error("Allocated node ID conflicts with a companion asset");o.add(s);let c=a.defaultVideoRatio===void 0?void 0:T5(a.defaultVideoRatio)?a.defaultVideoRatio:void 0;if(a.defaultVideoRatio!==void 0&&c===void 0)throw new Error(`Invalid defaultVideoRatio: ${String(a.defaultVideoRatio)}`);let d;if(!e.dryRun&&n&&(a.nodeKind==="scene3d"||a.nodeKind==="timeline-composition")){if(d=await n(),typeof d!="string"||!d.trim()||o.has(d)||Object.hasOwn(e.runtime.store.getState().assets,d))throw new Error("Asset allocator returned an invalid or existing companion asset ID");i.add(d),o.add(d)}let{assets:u,node:p}=D5({defaultEpisodeIds:a.defaultEpisodeIds??a.defaultEpisodes,defaultVideoRatio:c,existingNodes:e.runtime.store.getRootCanvasContent().nodes,id:s,initialData:a.initialData,kind:a.nodeKind,order:a.order,topLeft:a.topLeft,center:a.center,scene3DDocumentAssetId:a.nodeKind==="scene3d"?d:void 0,timelineDraftAssetId:a.nodeKind==="timeline-composition"?d:void 0});r.push({assets:u,autoCreateNodeAsset:!1,kind:"create_node",node:p})}return r}function Y5(e){var d,u;let t=e.registeredCommandDefinitions??AP,n=new Set(t.map(({name:p})=>p)),r=Vk({...e,mutationHandler:async p=>(wFe(p.mutations,n),va({...p,mutations:await kFe(p,e.allocateNodeId,e.allocateAssetId)}))}),i=Y_.map(({kind:p})=>p).join(", "),o=`Canvas mutations: ${i}. Use apply_patches only for privileged patch-level changes.`,a=r.apply_mutations.args.mutations,s=ku(Y_),c=t.map(p=>({type:"object",properties:{kind:{const:"invoke_command",type:"string"},name:{const:p.name,type:"string"},args:p.inputSchema?{type:"array",minItems:1,maxItems:1,items:p.inputSchema}:{type:"array",items:{},default:[]}},required:p.inputSchema?["kind","name","args"]:["kind","name"],description:"Run this registered business command alone in its mutation batch."}));return{...r,apply_mutations:{...r.apply_mutations,inputSchema:{...r.apply_mutations.inputSchema,properties:{...(d=r.apply_mutations.inputSchema)==null?void 0:d.properties,mutations:c.length?{oneOf:[s,{type:"array",minItems:1,maxItems:1,items:{oneOf:c}}]}:s}},args:{...r.apply_mutations.args,mutations:((u=a.describe)==null?void 0:u.call(a,o))??a},description:`${r.apply_mutations.description} Supported mutation kinds: ${i}.`}}}var IP=[...AP,MF,jz,OF];function OFe({runtime:e,schema:t}){var r;let n=t.string();return{args:{nodeId:t.string(),objectId:((r=n.optional)==null?void 0:r.call(n))??n},inputSchema:ml,description:"Read a director document, objects, cameras, timeline and supported animated property channels. Object IDs belong to the director document; nodeId identifies its outer Canvas node.",async execute(i){let o=await co(e,{canvasId:br(e),operation:fl},["canvas.read","canvas.asset.read"]);if(o)return he(o);try{return he(pn(e,$z(e.store,i)))}catch(a){return he(qt(e,"INVALID_ARGUMENT",a instanceof Error?a.message:"Invalid scene3d query"))}}}}function X5(e){return{...Y5({...e,registeredCommandDefinitions:IP}),[lg]:NF(e),[fl]:OFe(e)}}0&&(module.exports={XYQ_CANVAS_OPENCODE_MUTATION_DEFINITIONS,XYQ_CANVAS_REGISTERED_COMMAND_DEFINITIONS,createPippitAssetRuntime,createPippitAssetSdkCanvasLoader,createPippitAssetServiceTransport,createXyqCanvasCommandRuntime,createXyqCanvasOpencodeToolDefinitions});