@antv/g 5.15.15 → 5.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -7035,12 +7035,7 @@
7035
7035
  * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts
7036
7036
  */PropertySyntax["LIST_OF_POINTS"]="<list-of-points>";PropertySyntax["PATH"]="<path>";/**
7037
7037
  * @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter#formal_syntax
7038
- */PropertySyntax["FILTER"]="<filter>";PropertySyntax["Z_INDEX"]="<z-index>";PropertySyntax["OFFSET_DISTANCE"]="<offset-distance>";PropertySyntax["DEFINED_PATH"]="<defined-path>";PropertySyntax["MARKER"]="<marker>";PropertySyntax["TRANSFORM"]="<transform>";PropertySyntax["TRANSFORM_ORIGIN"]="<transform-origin>";PropertySyntax["TEXT"]="<text>";PropertySyntax["TEXT_TRANSFORM"]="<text-transform>";})(exports.PropertySyntax||(exports.PropertySyntax={}));function memoize(func,resolver){if(typeof func!=='function'||resolver!=null&&typeof resolver!=='function'){throw new TypeError('Expected a function');}var memoized=function memoized(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}var key=resolver?resolver.apply(this,args):args[0];var cache=memoized.cache;if(cache.has(key)){return cache.get(key);}var result=func.apply(this,args);memoized.cache=cache.set(key,result)||cache;return result;};memoized.cache=new(memoize.Cache||Map)();return memoized;}memoize.Cache=Map;var camelCase=memoize(function(str){if(str===void 0){str='';}return str.replace(/-([a-z])/g,function(g){return g[1].toUpperCase();});});function DCHECK(bool){if(!bool){throw new Error();}}function isFunction(func){return typeof func==='function';}function isSymbol(value){// @see https://github.com/lodash/lodash/blob/master/isSymbol.js
7039
- return typeof value==='symbol';}var definedProps=function definedProps(obj){return Object.fromEntries(Object.entries(obj).filter(function(_ref){var v=_ref[1];return v!==undefined;}));};var FORMAT_ATTR_MAP={d:{alias:'path'},strokeDasharray:{alias:'lineDash'},strokeWidth:{alias:'lineWidth'},textAnchor:{alias:'textAlign'},src:{alias:'img'}};var formatAttributeName=memoize(function(name){var attributeName=camelCase(name);var map=FORMAT_ATTR_MAP[attributeName];attributeName=(map===null||map===void 0?void 0:map.alias)||attributeName;return attributeName;});var canvasMap={};var defaultCanvasIdCounter=0;/**
7040
- * destroy existed canvas with the same id
7041
- */function cleanExistedCanvas(container,canvas){if(container){var id=typeof container==='string'?container:container.id||defaultCanvasIdCounter++;if(canvasMap[id]){canvasMap[id].destroy();}canvasMap[id]=canvas;}}var isBrowser=typeof window!=='undefined'&&typeof window.document!=='undefined';function sortByZIndex(o1,o2){var zIndex1=Number(o1.style.zIndex);var zIndex2=Number(o2.style.zIndex);if(zIndex1===zIndex2){// return o1.entity.getComponent(Sortable).lastSortedIndex - o2.entity.getComponent(Sortable).lastSortedIndex;
7042
- var parent=o1.parentNode;if(parent){var children=parent.childNodes||[];return children.indexOf(o1)-children.indexOf(o2);}}return zIndex1-zIndex2;}function findClosestClipPathTarget(object){var el=object;do{var _el$style;var clipPath=(_el$style=el.style)===null||_el$style===void 0?void 0:_el$style.clipPath;if(clipPath)return el;el=el.parentElement;}while(el!==null);return null;}var PX_SUFFIX='px';function setDOMSize($el,width,height){if(isBrowser&&$el.style){$el.style.width=width+PX_SUFFIX;$el.style.height=height+PX_SUFFIX;}}function getStyle($el,property){if(isBrowser){return document.defaultView.getComputedStyle($el,null).getPropertyValue(property);}}function getWidth($el){var width=getStyle($el,'width');if(width==='auto'){return $el.offsetWidth;}return parseFloat(width);}function getHeight($el){var height=getStyle($el,'height');if(height==='auto'){return $el.offsetHeight;}return parseFloat(height);}var ERROR_MSG_METHOD_NOT_IMPLEMENTED='Method not implemented.';var ERROR_MSG_USE_DOCUMENT_ELEMENT='Use document.documentElement instead.';var ERROR_MSG_APPEND_DESTROYED_ELEMENT='Cannot append a destroyed element.';// borrow from hammer.js
7043
- var MOUSE_POINTER_ID=1;var TOUCH_TO_POINTER={touchstart:'pointerdown',touchend:'pointerup',touchendoutside:'pointerupoutside',touchmove:'pointermove',touchcancel:'pointercancel'};function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return exports;};var exports={},Op=Object.prototype,hasOwn=Op.hasOwnProperty,defineProperty=Object.defineProperty||function(obj,key,desc){obj[key]=desc.value;},$Symbol="function"==typeof Symbol?Symbol:{},iteratorSymbol=$Symbol.iterator||"@@iterator",asyncIteratorSymbol=$Symbol.asyncIterator||"@@asyncIterator",toStringTagSymbol=$Symbol.toStringTag||"@@toStringTag";function define(obj,key,value){return Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}),obj[key];}try{define({},"");}catch(err){define=function define(obj,key,value){return obj[key]=value;};}function wrap(innerFn,outerFn,self,tryLocsList){var protoGenerator=outerFn&&outerFn.prototype instanceof Generator?outerFn:Generator,generator=Object.create(protoGenerator.prototype),context=new Context(tryLocsList||[]);return defineProperty(generator,"_invoke",{value:makeInvokeMethod(innerFn,self,context)}),generator;}function tryCatch(fn,obj,arg){try{return {type:"normal",arg:fn.call(obj,arg)};}catch(err){return {type:"throw",arg:err};}}exports.wrap=wrap;var ContinueSentinel={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var IteratorPrototype={};define(IteratorPrototype,iteratorSymbol,function(){return this;});var getProto=Object.getPrototypeOf,NativeIteratorPrototype=getProto&&getProto(getProto(values([])));NativeIteratorPrototype&&NativeIteratorPrototype!==Op&&hasOwn.call(NativeIteratorPrototype,iteratorSymbol)&&(IteratorPrototype=NativeIteratorPrototype);var Gp=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(IteratorPrototype);function defineIteratorMethods(prototype){["next","throw","return"].forEach(function(method){define(prototype,method,function(arg){return this._invoke(method,arg);});});}function AsyncIterator(generator,PromiseImpl){function invoke(method,arg,resolve,reject){var record=tryCatch(generator[method],generator,arg);if("throw"!==record.type){var result=record.arg,value=result.value;return value&&"object"==typeof value&&hasOwn.call(value,"__await")?PromiseImpl.resolve(value.__await).then(function(value){invoke("next",value,resolve,reject);},function(err){invoke("throw",err,resolve,reject);}):PromiseImpl.resolve(value).then(function(unwrapped){result.value=unwrapped,resolve(result);},function(error){return invoke("throw",error,resolve,reject);});}reject(record.arg);}var previousPromise;defineProperty(this,"_invoke",{value:function value(method,arg){function callInvokeWithMethodAndArg(){return new PromiseImpl(function(resolve,reject){invoke(method,arg,resolve,reject);});}return previousPromise=previousPromise?previousPromise.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg();}});}function makeInvokeMethod(innerFn,self,context){var state="suspendedStart";return function(method,arg){if("executing"===state)throw new Error("Generator is already running");if("completed"===state){if("throw"===method)throw arg;return doneResult();}for(context.method=method,context.arg=arg;;){var delegate=context.delegate;if(delegate){var delegateResult=maybeInvokeDelegate(delegate,context);if(delegateResult){if(delegateResult===ContinueSentinel)continue;return delegateResult;}}if("next"===context.method)context.sent=context._sent=context.arg;else if("throw"===context.method){if("suspendedStart"===state)throw state="completed",context.arg;context.dispatchException(context.arg);}else "return"===context.method&&context.abrupt("return",context.arg);state="executing";var record=tryCatch(innerFn,self,context);if("normal"===record.type){if(state=context.done?"completed":"suspendedYield",record.arg===ContinueSentinel)continue;return {value:record.arg,done:context.done};}"throw"===record.type&&(state="completed",context.method="throw",context.arg=record.arg);}};}function maybeInvokeDelegate(delegate,context){var methodName=context.method,method=delegate.iterator[methodName];if(undefined===method)return context.delegate=null,"throw"===methodName&&delegate.iterator.return&&(context.method="return",context.arg=undefined,maybeInvokeDelegate(delegate,context),"throw"===context.method)||"return"!==methodName&&(context.method="throw",context.arg=new TypeError("The iterator does not provide a '"+methodName+"' method")),ContinueSentinel;var record=tryCatch(method,delegate.iterator,context.arg);if("throw"===record.type)return context.method="throw",context.arg=record.arg,context.delegate=null,ContinueSentinel;var info=record.arg;return info?info.done?(context[delegate.resultName]=info.value,context.next=delegate.nextLoc,"return"!==context.method&&(context.method="next",context.arg=undefined),context.delegate=null,ContinueSentinel):info:(context.method="throw",context.arg=new TypeError("iterator result is not an object"),context.delegate=null,ContinueSentinel);}function pushTryEntry(locs){var entry={tryLoc:locs[0]};1 in locs&&(entry.catchLoc=locs[1]),2 in locs&&(entry.finallyLoc=locs[2],entry.afterLoc=locs[3]),this.tryEntries.push(entry);}function resetTryEntry(entry){var record=entry.completion||{};record.type="normal",delete record.arg,entry.completion=record;}function Context(tryLocsList){this.tryEntries=[{tryLoc:"root"}],tryLocsList.forEach(pushTryEntry,this),this.reset(!0);}function values(iterable){if(iterable){var iteratorMethod=iterable[iteratorSymbol];if(iteratorMethod)return iteratorMethod.call(iterable);if("function"==typeof iterable.next)return iterable;if(!isNaN(iterable.length)){var i=-1,next=function next(){for(;++i<iterable.length;){if(hasOwn.call(iterable,i))return next.value=iterable[i],next.done=!1,next;}return next.value=undefined,next.done=!0,next;};return next.next=next;}}return {next:doneResult};}function doneResult(){return {value:undefined,done:!0};}return GeneratorFunction.prototype=GeneratorFunctionPrototype,defineProperty(Gp,"constructor",{value:GeneratorFunctionPrototype,configurable:!0}),defineProperty(GeneratorFunctionPrototype,"constructor",{value:GeneratorFunction,configurable:!0}),GeneratorFunction.displayName=define(GeneratorFunctionPrototype,toStringTagSymbol,"GeneratorFunction"),exports.isGeneratorFunction=function(genFun){var ctor="function"==typeof genFun&&genFun.constructor;return !!ctor&&(ctor===GeneratorFunction||"GeneratorFunction"===(ctor.displayName||ctor.name));},exports.mark=function(genFun){return Object.setPrototypeOf?Object.setPrototypeOf(genFun,GeneratorFunctionPrototype):(genFun.__proto__=GeneratorFunctionPrototype,define(genFun,toStringTagSymbol,"GeneratorFunction")),genFun.prototype=Object.create(Gp),genFun;},exports.awrap=function(arg){return {__await:arg};},defineIteratorMethods(AsyncIterator.prototype),define(AsyncIterator.prototype,asyncIteratorSymbol,function(){return this;}),exports.AsyncIterator=AsyncIterator,exports.async=function(innerFn,outerFn,self,tryLocsList,PromiseImpl){void 0===PromiseImpl&&(PromiseImpl=Promise);var iter=new AsyncIterator(wrap(innerFn,outerFn,self,tryLocsList),PromiseImpl);return exports.isGeneratorFunction(outerFn)?iter:iter.next().then(function(result){return result.done?result.value:iter.next();});},defineIteratorMethods(Gp),define(Gp,toStringTagSymbol,"Generator"),define(Gp,iteratorSymbol,function(){return this;}),define(Gp,"toString",function(){return "[object Generator]";}),exports.keys=function(val){var object=Object(val),keys=[];for(var key in object){keys.push(key);}return keys.reverse(),function next(){for(;keys.length;){var key=keys.pop();if(key in object)return next.value=key,next.done=!1,next;}return next.done=!0,next;};},exports.values=values,Context.prototype={constructor:Context,reset:function reset(skipTempReset){if(this.prev=0,this.next=0,this.sent=this._sent=undefined,this.done=!1,this.delegate=null,this.method="next",this.arg=undefined,this.tryEntries.forEach(resetTryEntry),!skipTempReset)for(var name in this){"t"===name.charAt(0)&&hasOwn.call(this,name)&&!isNaN(+name.slice(1))&&(this[name]=undefined);}},stop:function stop(){this.done=!0;var rootRecord=this.tryEntries[0].completion;if("throw"===rootRecord.type)throw rootRecord.arg;return this.rval;},dispatchException:function dispatchException(exception){if(this.done)throw exception;var context=this;function handle(loc,caught){return record.type="throw",record.arg=exception,context.next=loc,caught&&(context.method="next",context.arg=undefined),!!caught;}for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i],record=entry.completion;if("root"===entry.tryLoc)return handle("end");if(entry.tryLoc<=this.prev){var hasCatch=hasOwn.call(entry,"catchLoc"),hasFinally=hasOwn.call(entry,"finallyLoc");if(hasCatch&&hasFinally){if(this.prev<entry.catchLoc)return handle(entry.catchLoc,!0);if(this.prev<entry.finallyLoc)return handle(entry.finallyLoc);}else if(hasCatch){if(this.prev<entry.catchLoc)return handle(entry.catchLoc,!0);}else {if(!hasFinally)throw new Error("try statement without catch or finally");if(this.prev<entry.finallyLoc)return handle(entry.finallyLoc);}}}},abrupt:function abrupt(type,arg){for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i];if(entry.tryLoc<=this.prev&&hasOwn.call(entry,"finallyLoc")&&this.prev<entry.finallyLoc){var finallyEntry=entry;break;}}finallyEntry&&("break"===type||"continue"===type)&&finallyEntry.tryLoc<=arg&&arg<=finallyEntry.finallyLoc&&(finallyEntry=null);var record=finallyEntry?finallyEntry.completion:{};return record.type=type,record.arg=arg,finallyEntry?(this.method="next",this.next=finallyEntry.finallyLoc,ContinueSentinel):this.complete(record);},complete:function complete(record,afterLoc){if("throw"===record.type)throw record.arg;return "break"===record.type||"continue"===record.type?this.next=record.arg:"return"===record.type?(this.rval=this.arg=record.arg,this.method="return",this.next="end"):"normal"===record.type&&afterLoc&&(this.next=afterLoc),ContinueSentinel;},finish:function finish(finallyLoc){for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i];if(entry.finallyLoc===finallyLoc)return this.complete(entry.completion,entry.afterLoc),resetTryEntry(entry),ContinueSentinel;}},catch:function _catch(tryLoc){for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i];if(entry.tryLoc===tryLoc){var record=entry.completion;if("throw"===record.type){var thrown=record.arg;resetTryEntry(entry);}return thrown;}}throw new Error("illegal catch attempt");},delegateYield:function delegateYield(iterable,resultName,nextLoc){return this.delegate={iterator:values(iterable),resultName:resultName,nextLoc:nextLoc},"next"===this.method&&(this.arg=undefined),ContinueSentinel;}},exports;}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else {Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,_toPropertyKey(descriptor.key),descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor;}function _extends(){_extends=Object.assign?Object.assign.bind():function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _inheritsLoose(subClass,superClass){subClass.prototype=Object.create(superClass.prototype);subClass.prototype.constructor=subClass;_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return {};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _createForOfIteratorHelperLoose(o,allowArrayLike){var it=typeof Symbol!=="undefined"&&o[Symbol.iterator]||o["@@iterator"];if(it)return (it=it.call(o)).next.bind(it);if(Array.isArray(o)||(it=_unsupportedIterableToArray(o))||allowArrayLike&&o&&typeof o.length==="number"){if(it)o=it;var i=0;return function(){if(i>=o.length)return {done:true};return {done:false,value:o[i++]};};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _toPrimitive(input,hint){if(typeof input!=="object"||input===null)return input;var prim=input[Symbol.toPrimitive];if(prim!==undefined){var res=prim.call(input,hint||"default");if(typeof res!=="object")return res;throw new TypeError("@@toPrimitive must return a primitive value.");}return (hint==="string"?String:Number)(input);}function _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return typeof key==="symbol"?key:String(key);}// These units are iterated through, so be careful when adding or changing the
7038
+ */PropertySyntax["FILTER"]="<filter>";PropertySyntax["Z_INDEX"]="<z-index>";PropertySyntax["OFFSET_DISTANCE"]="<offset-distance>";PropertySyntax["DEFINED_PATH"]="<defined-path>";PropertySyntax["MARKER"]="<marker>";PropertySyntax["TRANSFORM"]="<transform>";PropertySyntax["TRANSFORM_ORIGIN"]="<transform-origin>";PropertySyntax["TEXT"]="<text>";PropertySyntax["TEXT_TRANSFORM"]="<text-transform>";})(exports.PropertySyntax||(exports.PropertySyntax={}));function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return exports;};var exports={},Op=Object.prototype,hasOwn=Op.hasOwnProperty,defineProperty=Object.defineProperty||function(obj,key,desc){obj[key]=desc.value;},$Symbol="function"==typeof Symbol?Symbol:{},iteratorSymbol=$Symbol.iterator||"@@iterator",asyncIteratorSymbol=$Symbol.asyncIterator||"@@asyncIterator",toStringTagSymbol=$Symbol.toStringTag||"@@toStringTag";function define(obj,key,value){return Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}),obj[key];}try{define({},"");}catch(err){define=function define(obj,key,value){return obj[key]=value;};}function wrap(innerFn,outerFn,self,tryLocsList){var protoGenerator=outerFn&&outerFn.prototype instanceof Generator?outerFn:Generator,generator=Object.create(protoGenerator.prototype),context=new Context(tryLocsList||[]);return defineProperty(generator,"_invoke",{value:makeInvokeMethod(innerFn,self,context)}),generator;}function tryCatch(fn,obj,arg){try{return {type:"normal",arg:fn.call(obj,arg)};}catch(err){return {type:"throw",arg:err};}}exports.wrap=wrap;var ContinueSentinel={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var IteratorPrototype={};define(IteratorPrototype,iteratorSymbol,function(){return this;});var getProto=Object.getPrototypeOf,NativeIteratorPrototype=getProto&&getProto(getProto(values([])));NativeIteratorPrototype&&NativeIteratorPrototype!==Op&&hasOwn.call(NativeIteratorPrototype,iteratorSymbol)&&(IteratorPrototype=NativeIteratorPrototype);var Gp=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(IteratorPrototype);function defineIteratorMethods(prototype){["next","throw","return"].forEach(function(method){define(prototype,method,function(arg){return this._invoke(method,arg);});});}function AsyncIterator(generator,PromiseImpl){function invoke(method,arg,resolve,reject){var record=tryCatch(generator[method],generator,arg);if("throw"!==record.type){var result=record.arg,value=result.value;return value&&"object"==typeof value&&hasOwn.call(value,"__await")?PromiseImpl.resolve(value.__await).then(function(value){invoke("next",value,resolve,reject);},function(err){invoke("throw",err,resolve,reject);}):PromiseImpl.resolve(value).then(function(unwrapped){result.value=unwrapped,resolve(result);},function(error){return invoke("throw",error,resolve,reject);});}reject(record.arg);}var previousPromise;defineProperty(this,"_invoke",{value:function value(method,arg){function callInvokeWithMethodAndArg(){return new PromiseImpl(function(resolve,reject){invoke(method,arg,resolve,reject);});}return previousPromise=previousPromise?previousPromise.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg();}});}function makeInvokeMethod(innerFn,self,context){var state="suspendedStart";return function(method,arg){if("executing"===state)throw new Error("Generator is already running");if("completed"===state){if("throw"===method)throw arg;return doneResult();}for(context.method=method,context.arg=arg;;){var delegate=context.delegate;if(delegate){var delegateResult=maybeInvokeDelegate(delegate,context);if(delegateResult){if(delegateResult===ContinueSentinel)continue;return delegateResult;}}if("next"===context.method)context.sent=context._sent=context.arg;else if("throw"===context.method){if("suspendedStart"===state)throw state="completed",context.arg;context.dispatchException(context.arg);}else "return"===context.method&&context.abrupt("return",context.arg);state="executing";var record=tryCatch(innerFn,self,context);if("normal"===record.type){if(state=context.done?"completed":"suspendedYield",record.arg===ContinueSentinel)continue;return {value:record.arg,done:context.done};}"throw"===record.type&&(state="completed",context.method="throw",context.arg=record.arg);}};}function maybeInvokeDelegate(delegate,context){var methodName=context.method,method=delegate.iterator[methodName];if(undefined===method)return context.delegate=null,"throw"===methodName&&delegate.iterator.return&&(context.method="return",context.arg=undefined,maybeInvokeDelegate(delegate,context),"throw"===context.method)||"return"!==methodName&&(context.method="throw",context.arg=new TypeError("The iterator does not provide a '"+methodName+"' method")),ContinueSentinel;var record=tryCatch(method,delegate.iterator,context.arg);if("throw"===record.type)return context.method="throw",context.arg=record.arg,context.delegate=null,ContinueSentinel;var info=record.arg;return info?info.done?(context[delegate.resultName]=info.value,context.next=delegate.nextLoc,"return"!==context.method&&(context.method="next",context.arg=undefined),context.delegate=null,ContinueSentinel):info:(context.method="throw",context.arg=new TypeError("iterator result is not an object"),context.delegate=null,ContinueSentinel);}function pushTryEntry(locs){var entry={tryLoc:locs[0]};1 in locs&&(entry.catchLoc=locs[1]),2 in locs&&(entry.finallyLoc=locs[2],entry.afterLoc=locs[3]),this.tryEntries.push(entry);}function resetTryEntry(entry){var record=entry.completion||{};record.type="normal",delete record.arg,entry.completion=record;}function Context(tryLocsList){this.tryEntries=[{tryLoc:"root"}],tryLocsList.forEach(pushTryEntry,this),this.reset(!0);}function values(iterable){if(iterable){var iteratorMethod=iterable[iteratorSymbol];if(iteratorMethod)return iteratorMethod.call(iterable);if("function"==typeof iterable.next)return iterable;if(!isNaN(iterable.length)){var i=-1,next=function next(){for(;++i<iterable.length;){if(hasOwn.call(iterable,i))return next.value=iterable[i],next.done=!1,next;}return next.value=undefined,next.done=!0,next;};return next.next=next;}}return {next:doneResult};}function doneResult(){return {value:undefined,done:!0};}return GeneratorFunction.prototype=GeneratorFunctionPrototype,defineProperty(Gp,"constructor",{value:GeneratorFunctionPrototype,configurable:!0}),defineProperty(GeneratorFunctionPrototype,"constructor",{value:GeneratorFunction,configurable:!0}),GeneratorFunction.displayName=define(GeneratorFunctionPrototype,toStringTagSymbol,"GeneratorFunction"),exports.isGeneratorFunction=function(genFun){var ctor="function"==typeof genFun&&genFun.constructor;return !!ctor&&(ctor===GeneratorFunction||"GeneratorFunction"===(ctor.displayName||ctor.name));},exports.mark=function(genFun){return Object.setPrototypeOf?Object.setPrototypeOf(genFun,GeneratorFunctionPrototype):(genFun.__proto__=GeneratorFunctionPrototype,define(genFun,toStringTagSymbol,"GeneratorFunction")),genFun.prototype=Object.create(Gp),genFun;},exports.awrap=function(arg){return {__await:arg};},defineIteratorMethods(AsyncIterator.prototype),define(AsyncIterator.prototype,asyncIteratorSymbol,function(){return this;}),exports.AsyncIterator=AsyncIterator,exports.async=function(innerFn,outerFn,self,tryLocsList,PromiseImpl){void 0===PromiseImpl&&(PromiseImpl=Promise);var iter=new AsyncIterator(wrap(innerFn,outerFn,self,tryLocsList),PromiseImpl);return exports.isGeneratorFunction(outerFn)?iter:iter.next().then(function(result){return result.done?result.value:iter.next();});},defineIteratorMethods(Gp),define(Gp,toStringTagSymbol,"Generator"),define(Gp,iteratorSymbol,function(){return this;}),define(Gp,"toString",function(){return "[object Generator]";}),exports.keys=function(val){var object=Object(val),keys=[];for(var key in object){keys.push(key);}return keys.reverse(),function next(){for(;keys.length;){var key=keys.pop();if(key in object)return next.value=key,next.done=!1,next;}return next.done=!0,next;};},exports.values=values,Context.prototype={constructor:Context,reset:function reset(skipTempReset){if(this.prev=0,this.next=0,this.sent=this._sent=undefined,this.done=!1,this.delegate=null,this.method="next",this.arg=undefined,this.tryEntries.forEach(resetTryEntry),!skipTempReset)for(var name in this){"t"===name.charAt(0)&&hasOwn.call(this,name)&&!isNaN(+name.slice(1))&&(this[name]=undefined);}},stop:function stop(){this.done=!0;var rootRecord=this.tryEntries[0].completion;if("throw"===rootRecord.type)throw rootRecord.arg;return this.rval;},dispatchException:function dispatchException(exception){if(this.done)throw exception;var context=this;function handle(loc,caught){return record.type="throw",record.arg=exception,context.next=loc,caught&&(context.method="next",context.arg=undefined),!!caught;}for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i],record=entry.completion;if("root"===entry.tryLoc)return handle("end");if(entry.tryLoc<=this.prev){var hasCatch=hasOwn.call(entry,"catchLoc"),hasFinally=hasOwn.call(entry,"finallyLoc");if(hasCatch&&hasFinally){if(this.prev<entry.catchLoc)return handle(entry.catchLoc,!0);if(this.prev<entry.finallyLoc)return handle(entry.finallyLoc);}else if(hasCatch){if(this.prev<entry.catchLoc)return handle(entry.catchLoc,!0);}else {if(!hasFinally)throw new Error("try statement without catch or finally");if(this.prev<entry.finallyLoc)return handle(entry.finallyLoc);}}}},abrupt:function abrupt(type,arg){for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i];if(entry.tryLoc<=this.prev&&hasOwn.call(entry,"finallyLoc")&&this.prev<entry.finallyLoc){var finallyEntry=entry;break;}}finallyEntry&&("break"===type||"continue"===type)&&finallyEntry.tryLoc<=arg&&arg<=finallyEntry.finallyLoc&&(finallyEntry=null);var record=finallyEntry?finallyEntry.completion:{};return record.type=type,record.arg=arg,finallyEntry?(this.method="next",this.next=finallyEntry.finallyLoc,ContinueSentinel):this.complete(record);},complete:function complete(record,afterLoc){if("throw"===record.type)throw record.arg;return "break"===record.type||"continue"===record.type?this.next=record.arg:"return"===record.type?(this.rval=this.arg=record.arg,this.method="return",this.next="end"):"normal"===record.type&&afterLoc&&(this.next=afterLoc),ContinueSentinel;},finish:function finish(finallyLoc){for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i];if(entry.finallyLoc===finallyLoc)return this.complete(entry.completion,entry.afterLoc),resetTryEntry(entry),ContinueSentinel;}},catch:function _catch(tryLoc){for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i];if(entry.tryLoc===tryLoc){var record=entry.completion;if("throw"===record.type){var thrown=record.arg;resetTryEntry(entry);}return thrown;}}throw new Error("illegal catch attempt");},delegateYield:function delegateYield(iterable,resultName,nextLoc){return this.delegate={iterator:values(iterable),resultName:resultName,nextLoc:nextLoc},"next"===this.method&&(this.arg=undefined),ContinueSentinel;}},exports;}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else {Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,_toPropertyKey(descriptor.key),descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor;}function _extends(){_extends=Object.assign?Object.assign.bind():function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _inheritsLoose(subClass,superClass){subClass.prototype=Object.create(superClass.prototype);subClass.prototype.constructor=subClass;_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return {};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _createForOfIteratorHelperLoose(o,allowArrayLike){var it=typeof Symbol!=="undefined"&&o[Symbol.iterator]||o["@@iterator"];if(it)return (it=it.call(o)).next.bind(it);if(Array.isArray(o)||(it=_unsupportedIterableToArray(o))||allowArrayLike&&o&&typeof o.length==="number"){if(it)o=it;var i=0;return function(){if(i>=o.length)return {done:true};return {done:false,value:o[i++]};};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _toPrimitive(input,hint){if(typeof input!=="object"||input===null)return input;var prim=input[Symbol.toPrimitive];if(prim!==undefined){var res=prim.call(input,hint||"default");if(typeof res!=="object")return res;throw new TypeError("@@toPrimitive must return a primitive value.");}return (hint==="string"?String:Number)(input);}function _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return typeof key==="symbol"?key:String(key);}// These units are iterated through, so be careful when adding or changing the
7044
7039
  // order.
7045
7040
  (function(UnitType){UnitType[UnitType["kUnknown"]=0]="kUnknown";UnitType[UnitType["kNumber"]=1]="kNumber";UnitType[UnitType["kPercentage"]=2]="kPercentage";// Length units
7046
7041
  UnitType[UnitType["kEms"]=3]="kEms";// kExs,
@@ -7425,7 +7420,8 @@
7425
7420
  * eg. 'initial'
7426
7421
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSKeywordValue
7427
7422
  * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_keyword_value.idl
7428
- */var CSSKeywordValue=/*#__PURE__*/function(_CSSStyleValue){_inheritsLoose(CSSKeywordValue,_CSSStyleValue);function CSSKeywordValue(value){var _this;_this=_CSSStyleValue.call(this)||this;_this.value=void 0;_this.value=value;return _this;}var _proto=CSSKeywordValue.prototype;_proto.clone=function clone(){return new CSSKeywordValue(this.value);};_proto.getType=function getType(){return CSSStyleValueType.kKeywordType;};_proto.buildCSSText=function buildCSSText(n,p,result){return result+this.value;};return CSSKeywordValue;}(CSSStyleValue);// type CSSNumericBaseType =
7423
+ */var CSSKeywordValue=/*#__PURE__*/function(_CSSStyleValue){_inheritsLoose(CSSKeywordValue,_CSSStyleValue);function CSSKeywordValue(value){var _this;_this=_CSSStyleValue.call(this)||this;_this.value=void 0;_this.value=value;return _this;}var _proto=CSSKeywordValue.prototype;_proto.clone=function clone(){return new CSSKeywordValue(this.value);};_proto.getType=function getType(){return CSSStyleValueType.kKeywordType;};_proto.buildCSSText=function buildCSSText(n,p,result){return result+this.value;};return CSSKeywordValue;}(CSSStyleValue);function memoize(func,resolver){if(typeof func!=='function'||resolver!=null&&typeof resolver!=='function'){throw new TypeError('Expected a function');}var memoized=function memoized(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}var key=resolver?resolver.apply(this,args):args[0];var cache=memoized.cache;if(cache.has(key)){return cache.get(key);}var result=func.apply(this,args);memoized.cache=cache.set(key,result)||cache;return result;};memoized.cache=new(memoize.Cache||Map)();return memoized;}memoize.Cache=Map;var camelCase=memoize(function(str){if(str===void 0){str='';}return str.replace(/-([a-z])/g,function(g){return g[1].toUpperCase();});});var kebabize=function kebabize(str){return str.split('').map(function(letter,idx){return letter.toUpperCase()===letter?""+(idx!==0?'-':'')+letter.toLowerCase():letter;}).join('');};function DCHECK(bool){if(!bool){throw new Error();}}function isFunction(func){return typeof func==='function';}function isSymbol(value){// @see https://github.com/lodash/lodash/blob/master/isSymbol.js
7424
+ return typeof value==='symbol';}var definedProps=function definedProps(obj){return Object.fromEntries(Object.entries(obj).filter(function(_ref){var v=_ref[1];return v!==undefined;}));};var FORMAT_ATTR_MAP={d:{alias:'path'},strokeDasharray:{alias:'lineDash'},strokeWidth:{alias:'lineWidth'},textAnchor:{alias:'textAlign'},src:{alias:'img'}};var formatAttributeName=memoize(function(name){var attributeName=camelCase(name);var map=FORMAT_ATTR_MAP[attributeName];attributeName=(map===null||map===void 0?void 0:map.alias)||attributeName;return attributeName;});// type CSSNumericBaseType =
7429
7425
  // | 'length'
7430
7426
  // | 'angle'
7431
7427
  // | 'time'
@@ -7472,8 +7468,7 @@
7472
7468
  // case UnitType.kUserUnits:
7473
7469
  case exports.UnitType.kDegrees:case exports.UnitType.kRadians:case exports.UnitType.kGradians:case exports.UnitType.kMilliseconds:case exports.UnitType.kSeconds:// case UnitType.kHertz:
7474
7470
  // case UnitType.kKilohertz:
7475
- case exports.UnitType.kTurns:// case UnitType.kContainerMin: // case UnitType.kContainerBlockSize: // case UnitType.kContainerInlineSize: // case UnitType.kContainerHeight: // case UnitType.kContainerWidth: // case UnitType.kDynamicViewportMax: // case UnitType.kDynamicViewportMin: // case UnitType.kDynamicViewportBlockSize: // case UnitType.kDynamicViewportInlineSize: // case UnitType.kDynamicViewportHeight: // case UnitType.kDynamicViewportWidth: // case UnitType.kLargeViewportMax: // case UnitType.kLargeViewportMin: // case UnitType.kLargeViewportBlockSize: // case UnitType.kLargeViewportInlineSize: // case UnitType.kLargeViewportHeight: // case UnitType.kLargeViewportWidth: // case UnitType.kSmallViewportMax: // case UnitType.kSmallViewportMin: // case UnitType.kSmallViewportBlockSize: // case UnitType.kSmallViewportInlineSize: // case UnitType.kSmallViewportHeight: // case UnitType.kSmallViewportWidth: // case UnitType.kViewportMax: // case UnitType.kViewportMin: // case UnitType.kViewportBlockSize: // case UnitType.kViewportInlineSize: // case UnitType.kViewportHeight: // case UnitType.kViewportWidth: // case UnitType.kFraction:
7476
- // case UnitType.kContainerMax: {
7471
+ case exports.UnitType.kTurns:// case UnitType.kContainerMax: { // case UnitType.kContainerMin: // case UnitType.kContainerBlockSize: // case UnitType.kContainerInlineSize: // case UnitType.kContainerHeight: // case UnitType.kContainerWidth: // case UnitType.kDynamicViewportMax: // case UnitType.kDynamicViewportMin: // case UnitType.kDynamicViewportBlockSize: // case UnitType.kDynamicViewportInlineSize: // case UnitType.kDynamicViewportHeight: // case UnitType.kDynamicViewportWidth: // case UnitType.kLargeViewportMax: // case UnitType.kLargeViewportMin: // case UnitType.kLargeViewportBlockSize: // case UnitType.kLargeViewportInlineSize: // case UnitType.kLargeViewportHeight: // case UnitType.kLargeViewportWidth: // case UnitType.kSmallViewportMax: // case UnitType.kSmallViewportMin: // case UnitType.kSmallViewportBlockSize: // case UnitType.kSmallViewportInlineSize: // case UnitType.kSmallViewportHeight: // case UnitType.kSmallViewportWidth: // case UnitType.kViewportMax: // case UnitType.kViewportMin: // case UnitType.kViewportBlockSize: // case UnitType.kViewportInlineSize: // case UnitType.kViewportHeight: // case UnitType.kViewportWidth: // case UnitType.kFraction:
7477
7472
  {var kMinInteger=-999999;var kMaxInteger=999999;var value=this.value;var unit=unitTypeToString(this.unit);if(value<kMinInteger||value>kMaxInteger){var _unit=unitTypeToString(this.unit);if(!Number.isFinite(value)||Number.isNaN(value)){text=formatInfinityOrNaN(value,_unit);}else {text=value+(_unit||'');}}else {text=""+value+unit;}}}result+=text;return result;};return CSSUnitValue;}(CSSStyleValue);var Opx=new CSSUnitValue(0,'px');var Lpx=new CSSUnitValue(1,'px');var Odeg=new CSSUnitValue(0,'deg');/**
7478
7473
  * The CSSRGB class represents the CSS rgb()/rgba() functions.
7479
7474
  *
@@ -7533,82 +7528,433 @@
7533
7528
  // return `${value}${unitOrName}`;
7534
7529
  // },
7535
7530
  // );
7536
- var getOrCreateUnitValue=function getOrCreateUnitValue(value,unitOrName){if(unitOrName===void 0){unitOrName=exports.UnitType.kNumber;}return new CSSUnitValue(value,unitOrName);};var regexLG=/^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;var regexRG=/^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i;var regexPR=/^p\s*\(\s*([axyn])\s*\)\s*(.*)/i;var regexColorStop=/[\d.]+:(#[^\s]+|[^\)]+\))/gi;function spaceColorStops(colorStops){var _colorStops$length;var length=colorStops.length;colorStops[length-1].length=(_colorStops$length=colorStops[length-1].length)!==null&&_colorStops$length!==void 0?_colorStops$length:{type:'%',value:'100'};if(length>1){var _colorStops$0$length;colorStops[0].length=(_colorStops$0$length=colorStops[0].length)!==null&&_colorStops$0$length!==void 0?_colorStops$0$length:{type:'%',value:'0'};}var previousIndex=0;var previousOffset=Number(colorStops[0].length.value);for(var i=1;i<length;i++){var _colorStops$i$length;// support '%' & 'px'
7537
- var offset=(_colorStops$i$length=colorStops[i].length)===null||_colorStops$i$length===void 0?void 0:_colorStops$i$length.value;if(!isNil(offset)&&!isNil(previousOffset)){for(var j=1;j<i-previousIndex;j++){colorStops[previousIndex+j].length={type:'%',value:""+(previousOffset+(Number(offset)-previousOffset)*j/(i-previousIndex))};}previousIndex=i;previousOffset=Number(offset);}}}// The position of the gradient line's starting point.
7538
- // different from CSS side(to top) @see https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient#values
7539
- var SideOrCornerToDegMap={left:270-90,top:0-90,bottom:180-90,right:90-90,'left top':315-90,'top left':315-90,'left bottom':225-90,'bottom left':225-90,'right top':45-90,'top right':45-90,'right bottom':135-90,'bottom right':135-90};var angleToDeg=memoize(function(orientation){var angle;if(orientation.type==='angular'){angle=Number(orientation.value);}else {angle=SideOrCornerToDegMap[orientation.value]||0;}return getOrCreateUnitValue(angle,'deg');});var positonToCSSUnitValue=memoize(function(position){var cx=50;var cy=50;var unitX='%';var unitY='%';if((position===null||position===void 0?void 0:position.type)==='position'){var _position$value=position.value,x=_position$value.x,y=_position$value.y;if((x===null||x===void 0?void 0:x.type)==='position-keyword'){if(x.value==='left'){cx=0;}else if(x.value==='center'){cx=50;}else if(x.value==='right'){cx=100;}else if(x.value==='top'){cy=0;}else if(x.value==='bottom'){cy=100;}}if((y===null||y===void 0?void 0:y.type)==='position-keyword'){if(y.value==='left'){cx=0;}else if(y.value==='center'){cy=50;}else if(y.value==='right'){cx=100;}else if(y.value==='top'){cy=0;}else if(y.value==='bottom'){cy=100;}}if((x===null||x===void 0?void 0:x.type)==='px'||(x===null||x===void 0?void 0:x.type)==='%'||(x===null||x===void 0?void 0:x.type)==='em'){unitX=x===null||x===void 0?void 0:x.type;cx=Number(x.value);}if((y===null||y===void 0?void 0:y.type)==='px'||(y===null||y===void 0?void 0:y.type)==='%'||(y===null||y===void 0?void 0:y.type)==='em'){unitY=y===null||y===void 0?void 0:y.type;cy=Number(y.value);}}return {cx:getOrCreateUnitValue(cx,unitX),cy:getOrCreateUnitValue(cy,unitY)};});var parseGradient=memoize(function(colorStr){if(colorStr.indexOf('linear')>-1||colorStr.indexOf('radial')>-1){var ast=parseGradient$1(colorStr);return ast.map(function(_ref){var type=_ref.type,orientation=_ref.orientation,colorStops=_ref.colorStops;spaceColorStops(colorStops);var steps=colorStops.map(function(colorStop){// TODO: only support % for now, should calc percentage of axis length when using px/em
7540
- return {offset:getOrCreateUnitValue(Number(colorStop.length.value),'%'),color:colorStopToString(colorStop)};});if(type==='linear-gradient'){return new CSSGradientValue(exports.GradientType.LinearGradient,{angle:orientation?angleToDeg(orientation):Odeg,steps:steps});}else if(type==='radial-gradient'){if(!orientation){orientation=[{type:'shape',value:'circle'}];}if(orientation[0].type==='shape'&&orientation[0].value==='circle'){var _positonToCSSUnitValu=positonToCSSUnitValue(orientation[0].at),cx=_positonToCSSUnitValu.cx,cy=_positonToCSSUnitValu.cy;var size;if(orientation[0].style){var _orientation$0$style=orientation[0].style,_type=_orientation$0$style.type,value=_orientation$0$style.value;if(_type==='extent-keyword'){size=getOrCreateKeyword(value);}else {size=getOrCreateUnitValue(value,_type);}}return new CSSGradientValue(exports.GradientType.RadialGradient,{cx:cx,cy:cy,size:size,steps:steps});}// TODO: support ellipse shape
7541
- // TODO: repeating-linear-gradient & repeating-radial-gradient
7542
- // } else if (type === 'repeating-linear-gradient') {
7543
- // } else if (type === 'repeating-radial-gradient') {
7544
- }});}// legacy format, should be deprecated later
7545
- var type=colorStr[0];if(colorStr[1]==='('||colorStr[2]==='('){if(type==='l'){var arr=regexLG.exec(colorStr);if(arr){var _arr$2$match;var steps=((_arr$2$match=arr[2].match(regexColorStop))===null||_arr$2$match===void 0?void 0:_arr$2$match.map(function(stop){return stop.split(':');}))||[];return [new CSSGradientValue(exports.GradientType.LinearGradient,{angle:getOrCreateUnitValue(parseFloat(arr[1]),'deg'),steps:steps.map(function(_ref2){var offset=_ref2[0],color=_ref2[1];return {offset:getOrCreateUnitValue(Number(offset)*100,'%'),color:color};})})];}}else if(type==='r'){var parsedRadialGradient=parseRadialGradient(colorStr);if(parsedRadialGradient){if(isString(parsedRadialGradient)){colorStr=parsedRadialGradient;}else {return [new CSSGradientValue(exports.GradientType.RadialGradient,parsedRadialGradient)];}}}else if(type==='p'){return parsePattern(colorStr);}}});function parseRadialGradient(gradientStr){var arr=regexRG.exec(gradientStr);if(arr){var _arr$4$match;var steps=((_arr$4$match=arr[4].match(regexColorStop))===null||_arr$4$match===void 0?void 0:_arr$4$match.map(function(stop){return stop.split(':');}))||[];return {cx:getOrCreateUnitValue(50,'%'),cy:getOrCreateUnitValue(50,'%'),steps:steps.map(function(_ref3){var offset=_ref3[0],color=_ref3[1];return {offset:getOrCreateUnitValue(Number(offset)*100,'%'),color:color};})};}return null;}function parsePattern(patternStr){var arr=regexPR.exec(patternStr);if(arr){var repetition=arr[1];var src=arr[2];switch(repetition){case'a':repetition='repeat';break;case'x':repetition='repeat-x';break;case'y':repetition='repeat-y';break;case'n':repetition='no-repeat';break;default:repetition='no-repeat';}return {image:src,// @ts-ignore
7546
- repetition:repetition};}return null;}function isCSSGradientValue(object){return !!object.type&&!!object.value;}function isPattern(object){return isObject(object)&&!!object.image;}function isCSSRGB(object){return isObject(object)&&!isNil(object.r)&&!isNil(object.g)&&!isNil(object.b);}/**
7547
- * @see https://github.com/WebKit/WebKit/blob/main/Source/WebCore/css/parser/CSSParser.cpp#L97
7548
- */var parseColor=memoize(function(colorStr){if(isPattern(colorStr)){return _extends({repetition:'repeat'},colorStr);}if(isNil(colorStr)){colorStr='';}if(colorStr==='transparent'){// transparent black
7549
- return transparentColor;}else if(colorStr==='currentColor'){// @see https://github.com/adobe-webplatform/Snap.svg/issues/526
7550
- colorStr='black';}// support CSS gradient syntax
7551
- var g=parseGradient(colorStr);if(g){return g;}// constants
7552
- var color$1=color(colorStr);var rgba=[0,0,0,0];if(color$1!==null){rgba[0]=color$1.r||0;rgba[1]=color$1.g||0;rgba[2]=color$1.b||0;rgba[3]=color$1.opacity;}// return new CSSRGB(...rgba);
7553
- return getOrCreateRGBA.apply(void 0,rgba);});function mergeColors(left,right){// only support constant value, exclude gradient & pattern
7554
- if(!isCSSRGB(left)||!isCSSRGB(right)){return;}return [[Number(left.r),Number(left.g),Number(left.b),Number(left.alpha)],[Number(right.r),Number(right.g),Number(right.b),Number(right.alpha)],function(color){var rgba=color.slice();if(rgba[3]){for(var i=0;i<3;i++){rgba[i]=Math.round(clamp(rgba[i],0,255));}}rgba[3]=clamp(rgba[3],0,1);return "rgba("+rgba.join(',')+")";}];}(function(Shape){Shape["GROUP"]="g";Shape["CIRCLE"]="circle";Shape["ELLIPSE"]="ellipse";Shape["IMAGE"]="image";Shape["RECT"]="rect";Shape["LINE"]="line";Shape["POLYLINE"]="polyline";Shape["POLYGON"]="polygon";Shape["TEXT"]="text";Shape["PATH"]="path";Shape["HTML"]="html";Shape["MESH"]="mesh";})(exports.Shape||(exports.Shape={}));function parseDimension(unitRegExp,string){if(isNil(string)){return getOrCreateUnitValue(0,'px');}string=(""+string).trim().toLowerCase();if(isFinite(Number(string))){if('px'.search(unitRegExp)>=0){return getOrCreateUnitValue(Number(string),'px');}else if('deg'.search(unitRegExp)>=0){return getOrCreateUnitValue(Number(string),'deg');}}var matchedUnits=[];string=string.replace(unitRegExp,function(match){matchedUnits.push(match);return 'U'+match;});var taggedUnitRegExp='U('+unitRegExp.source+')';return matchedUnits.map(function(unit){return getOrCreateUnitValue(Number(string.replace(new RegExp('U'+unit,'g'),'').replace(new RegExp(taggedUnitRegExp,'g'),'*0')),unit);})[0];}/**
7555
- * <length>
7556
- * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length
7557
- * length with only absolute unit, eg. 1px
7558
- */var parseLength=memoize(function(css){return parseDimension(new RegExp('px','g'),css);});/**
7559
- * <percentage>
7560
- * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/percentage
7561
- */var parserPercentage=memoize(function(css){return parseDimension(new RegExp('%','g'),css);});/**
7562
- * length with absolute or relative unit,
7563
- * eg. 1px, 0.7em, 50%, calc(100% - 200px);
7564
- *
7565
- * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length-percentage
7566
- */ // export const parseLengthOrPercentage = memoize((css: string): CSSUnitValue => {
7567
- // if (isNumber(css) || isFinite(Number(css))) {
7568
- // return getOrCreateUnitValue(Number(css), 'px');
7569
- // }
7570
- // return parseDimension(new RegExp('px|%|em|rem', 'g'), css) as CSSUnitValue;
7571
- // });
7572
- var parseLengthOrPercentage=function parseLengthOrPercentage(css){if(isNumber(css)||isFinite(Number(css))){return getOrCreateUnitValue(Number(css),'px');// return Number(css);
7573
- }return parseDimension(new RegExp('px|%|em|rem','g'),css);};var parseAngle=memoize(function(css){return parseDimension(new RegExp('deg|rad|grad|turn','g'),css);});/**
7574
- * merge CSSUnitValue
7575
- *
7576
- * @example
7577
- * 10px + 20px = 30px
7578
- * 10deg + 10rad
7579
- * 10% + 20% = 30%
7580
- */function mergeDimensions(left,right,target,nonNegative,index){if(index===void 0){index=0;}var unit='';var leftValue=left.value||0;var rightValue=right.value||0;var canonicalUnit=toCanonicalUnit(left.unit);var leftCanonicalUnitValue=left.convertTo(canonicalUnit);var rightCanonicalUnitValue=right.convertTo(canonicalUnit);if(leftCanonicalUnitValue&&rightCanonicalUnitValue){leftValue=leftCanonicalUnitValue.value;rightValue=rightCanonicalUnitValue.value;unit=unitTypeToString(left.unit);}else {// format '%' to 'px'
7581
- if(CSSUnitValue.isLength(left.unit)||CSSUnitValue.isLength(right.unit)){leftValue=convertPercentUnit(left,index,target);rightValue=convertPercentUnit(right,index,target);unit='px';}}// // format 'rad' 'turn' to 'deg'
7582
- // if (CSSUnitValue.isAngle(left.unit) || CSSUnitValue.isAngle(right.unit)) {
7583
- // leftValue = convertAngleUnit(left);
7584
- // rightValue = convertAngleUnit(right);
7585
- // unit = 'deg';
7531
+ var getOrCreateUnitValue=function getOrCreateUnitValue(value,unitOrName){if(unitOrName===void 0){unitOrName=exports.UnitType.kNumber;}return new CSSUnitValue(value,unitOrName);};var canvasMap={};var defaultCanvasIdCounter=0;/**
7532
+ * destroy existed canvas with the same id
7533
+ */function cleanExistedCanvas(container,canvas){if(container){var id=typeof container==='string'?container:container.id||defaultCanvasIdCounter++;if(canvasMap[id]){canvasMap[id].destroy();}canvasMap[id]=canvas;}}var isBrowser=typeof window!=='undefined'&&typeof window.document!=='undefined';function sortByZIndex(o1,o2){var zIndex1=Number(o1.style.zIndex);var zIndex2=Number(o2.style.zIndex);if(zIndex1===zIndex2){// return o1.entity.getComponent(Sortable).lastSortedIndex - o2.entity.getComponent(Sortable).lastSortedIndex;
7534
+ var parent=o1.parentNode;if(parent){var children=parent.childNodes||[];return children.indexOf(o1)-children.indexOf(o2);}}return zIndex1-zIndex2;}function findClosestClipPathTarget(object){var el=object;do{var _el$style;var clipPath=(_el$style=el.style)===null||_el$style===void 0?void 0:_el$style.clipPath;if(clipPath)return el;el=el.parentElement;}while(el!==null);return null;}var PX_SUFFIX='px';function setDOMSize($el,width,height){if(isBrowser&&$el.style){$el.style.width=width+PX_SUFFIX;$el.style.height=height+PX_SUFFIX;}}function getStyle($el,property){if(isBrowser){return document.defaultView.getComputedStyle($el,null).getPropertyValue(property);}}function getWidth($el){var width=getStyle($el,'width');if(width==='auto'){return $el.offsetWidth;}return parseFloat(width);}function getHeight($el){var height=getStyle($el,'height');if(height==='auto'){return $el.offsetHeight;}return parseFloat(height);}var ERROR_MSG_METHOD_NOT_IMPLEMENTED='Method not implemented.';var ERROR_MSG_USE_DOCUMENT_ELEMENT='Use document.documentElement instead.';var ERROR_MSG_APPEND_DESTROYED_ELEMENT='Cannot append a destroyed element.';// borrow from hammer.js
7535
+ var MOUSE_POINTER_ID=1;var TOUCH_TO_POINTER={touchstart:'pointerdown',touchend:'pointerup',touchendoutside:'pointerupoutside',touchmove:'pointermove',touchcancel:'pointercancel'};function copyVec3(a,b){a[0]=b[0];a[1]=b[1];a[2]=b[2];return a;}function subVec3(o,a,b){o[0]=a[0]-b[0];o[1]=a[1]-b[1];o[2]=a[2]-b[2];return o;}function addVec3(o,a,b){o[0]=a[0]+b[0];o[1]=a[1]+b[1];o[2]=a[2]+b[2];return o;}function scaleVec3(o,a,b){o[0]=a[0]*b;o[1]=a[1]*b;o[2]=a[2]*b;return o;}function maxVec3(o,a,b){o[0]=Math.max(a[0],b[0]);o[1]=Math.max(a[1],b[1]);o[2]=Math.max(a[2],b[2]);return o;}function minVec3(o,a,b){o[0]=Math.min(a[0],b[0]);o[1]=Math.min(a[1],b[1]);o[2]=Math.min(a[2],b[2]);return o;}function getAngle$1(angle){if(angle===undefined){return 0;}else if(angle>360||angle<-360){return angle%360;}return angle;}function createVec3(x,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}if(isNumber(x)){return fromValues$2(x,y,z);}if(Array.isArray(x)&&x.length===3){return clone$1(x);}return fromValues$2(x[0],x[1]||y,x[2]||z);}function deg2rad(deg){return deg*(Math.PI/180);}function rad2deg(rad){return rad*(180/Math.PI);}function grad2deg(grads){grads=grads%400;if(grads<0){grads+=400;}return grads/400*360;}function deg2turn(deg){return deg/360;}function turn2deg(turn){return 360*turn;}function getEulerFromQuat(out,quat){var x=quat[0];var y=quat[1];var z=quat[2];var w=quat[3];var x2=x*x;var y2=y*y;var z2=z*z;var w2=w*w;var unit=x2+y2+z2+w2;var test=x*w-y*z;if(test>0.499995*unit){// TODO: Use glmatrix.EPSILON
7536
+ // singularity at the north pole
7537
+ out[0]=Math.PI/2;out[1]=2*Math.atan2(y,x);out[2]=0;}else if(test<-0.499995*unit){//TODO: Use glmatrix.EPSILON
7538
+ // singularity at the south pole
7539
+ out[0]=-Math.PI/2;out[1]=2*Math.atan2(y,x);out[2]=0;}else {out[0]=Math.asin(2*(x*z-w*y));out[1]=Math.atan2(2*(x*w+y*z),1-2*(z2+w2));out[2]=Math.atan2(2*(x*y+z*w),1-2*(y2+z2));}// TODO: Return them as degrees and not as radians
7540
+ return out;}function getEulerFromMat4(out,m){var x;var z;var halfPi=Math.PI*0.5;var _mat4$getScaling=getScaling(create$2(),m),sx=_mat4$getScaling[0],sy=_mat4$getScaling[1],sz=_mat4$getScaling[2];var y=Math.asin(-m[2]/sx);if(y<halfPi){if(y>-halfPi){x=Math.atan2(m[6]/sy,m[10]/sz);z=Math.atan2(m[1]/sx,m[0]/sx);}else {// Not a unique solution
7541
+ z=0;x=-Math.atan2(m[4]/sy,m[5]/sy);}}else {// Not a unique solution
7542
+ z=0;x=Math.atan2(m[4]/sy,m[5]/sy);}out[0]=x;out[1]=y;out[2]=z;return out;}/**
7543
+ * @see https://github.com/toji/gl-matrix/issues/329
7544
+ * @see https://doc.babylonjs.com/divingDeeper/mesh/transforms/center_origin/rotation_conventions
7545
+ */function getEuler(out,quat){if(quat.length===16){return getEulerFromMat4(out,quat);}else {return getEulerFromQuat(out,quat);}}function fromRotationTranslationScale$1(rotation,x,y,scaleX,scaleY){var cos=Math.cos(rotation);var sin=Math.sin(rotation);return fromValues(scaleX*cos,scaleY*sin,0,-scaleX*sin,scaleY*cos,0,x,y,1);}function makePerspective(out,left,right,top,bottom,near,far){var x=2*near/(right-left);var y=2*near/(top-bottom);var a=(right+left)/(right-left);var b=(top+bottom)/(top-bottom);var c=-(far+near)/(far-near);var d=-2*far*near/(far-near);out[0]=x;out[1]=0;out[2]=0;out[3]=0;out[4]=0;out[5]=y;out[6]=0;out[7]=0;out[8]=a;out[9]=b;out[10]=c;out[11]=-1;out[12]=0;out[13]=0;out[14]=d;out[15]=0;return out;}function decompose(mat){var row0x=mat[0];var row0y=mat[1];var row1x=mat[3];var row1y=mat[4];// decompose 3x3 matrix
7546
+ // @see https://www.w3.org/TR/css-transforms-1/#decomposing-a-2d-matrix
7547
+ var scalingX=Math.sqrt(row0x*row0x+row0y*row0y);var scalingY=Math.sqrt(row1x*row1x+row1y*row1y);// If determinant is negative, one axis was flipped.
7548
+ var determinant=row0x*row1y-row0y*row1x;if(determinant<0){// Flip axis with minimum unit vector dot product.
7549
+ if(row0x<row1y){scalingX=-scalingX;}else {scalingY=-scalingY;}}// Renormalize matrix to remove scale.
7550
+ if(scalingX){row0x*=1/scalingX;row0y*=1/scalingX;}if(scalingY){row1x*=1/scalingY;row1y*=1/scalingY;}// Compute rotation and renormalize matrix.
7551
+ var rotation=Math.atan2(row0y,row0x);var angle=rad2deg(rotation);return [mat[6],mat[7],scalingX,scalingY,angle];}var tmp=create$1();var perspectiveMatrix=create$1();var tmpVec4=create$3();var row=[create$2(),create$2(),create$2()];var pdum3=create$2();/*
7552
+ Input: matrix ; a 4x4 matrix
7553
+ Output: translation ; a 3 component vector
7554
+ scale ; a 3 component vector
7555
+ skew ; skew factors XY,XZ,YZ represented as a 3 component vector
7556
+ perspective ; a 4 component vector
7557
+ quaternion ; a 4 component vector
7558
+ Returns false if the matrix cannot be decomposed, true if it can
7559
+
7560
+
7561
+ References:
7562
+ https://github.com/kamicane/matrix3d/blob/master/lib/Matrix3d.js
7563
+ https://github.com/ChromiumWebApps/chromium/blob/master/ui/gfx/transform_util.cc
7564
+ http://www.w3.org/TR/css3-transforms/#decomposing-a-3d-matrix
7565
+ */function decomposeMat4(matrix,translation,scale,skew,perspective,quaternion){//normalize, if not possible then bail out early
7566
+ if(!normalize$4(tmp,matrix))return false;// perspectiveMatrix is used to solve for perspective, but it also provides
7567
+ // an easy way to test for singularity of the upper 3x3 component.
7568
+ copy(perspectiveMatrix,tmp);perspectiveMatrix[3]=0;perspectiveMatrix[7]=0;perspectiveMatrix[11]=0;perspectiveMatrix[15]=1;// If the perspectiveMatrix is not invertible, we are also unable to
7569
+ // decompose, so we'll bail early. Constant taken from SkMatrix44::invert.
7570
+ if(Math.abs(determinant(perspectiveMatrix))<1e-8)return false;var a03=tmp[3],a13=tmp[7],a23=tmp[11],a30=tmp[12],a31=tmp[13],a32=tmp[14],a33=tmp[15];// First, isolate perspective.
7571
+ if(a03!==0||a13!==0||a23!==0){tmpVec4[0]=a03;tmpVec4[1]=a13;tmpVec4[2]=a23;tmpVec4[3]=a33;// Solve the equation by inverting perspectiveMatrix and multiplying
7572
+ // rightHandSide by the inverse.
7573
+ // resuing the perspectiveMatrix here since it's no longer needed
7574
+ var ret=invert(perspectiveMatrix,perspectiveMatrix);if(!ret)return false;transpose(perspectiveMatrix,perspectiveMatrix);//multiply by transposed inverse perspective matrix, into perspective vec4
7575
+ transformMat4$1(perspective,tmpVec4,perspectiveMatrix);}else {//no perspective
7576
+ perspective[0]=perspective[1]=perspective[2]=0;perspective[3]=1;}// Next take care of translation
7577
+ translation[0]=a30;translation[1]=a31;translation[2]=a32;// Now get scale and shear. 'row' is a 3 element array of 3 component vectors
7578
+ mat3from4(row,tmp);// Compute X scale factor and normalize first row.
7579
+ scale[0]=length(row[0]);normalize(row[0],row[0]);// Compute XY shear factor and make 2nd row orthogonal to 1st.
7580
+ skew[0]=dot(row[0],row[1]);combine(row[1],row[1],row[0],1.0,-skew[0]);// Now, compute Y scale and normalize 2nd row.
7581
+ scale[1]=length(row[1]);normalize(row[1],row[1]);skew[0]/=scale[1];// Compute XZ and YZ shears, orthogonalize 3rd row
7582
+ skew[1]=dot(row[0],row[2]);combine(row[2],row[2],row[0],1.0,-skew[1]);skew[2]=dot(row[1],row[2]);combine(row[2],row[2],row[1],1.0,-skew[2]);// Next, get Z scale and normalize 3rd row.
7583
+ scale[2]=length(row[2]);normalize(row[2],row[2]);skew[1]/=scale[2];skew[2]/=scale[2];// At this point, the matrix (in rows) is orthonormal.
7584
+ // Check for a coordinate system flip. If the determinant
7585
+ // is -1, then negate the matrix and the scaling factors.
7586
+ cross(pdum3,row[1],row[2]);if(dot(row[0],pdum3)<0){for(var i=0;i<3;i++){scale[i]*=-1;row[i][0]*=-1;row[i][1]*=-1;row[i][2]*=-1;}}// Now, get the rotations out
7587
+ quaternion[0]=0.5*Math.sqrt(Math.max(1+row[0][0]-row[1][1]-row[2][2],0));quaternion[1]=0.5*Math.sqrt(Math.max(1-row[0][0]+row[1][1]-row[2][2],0));quaternion[2]=0.5*Math.sqrt(Math.max(1-row[0][0]-row[1][1]+row[2][2],0));quaternion[3]=0.5*Math.sqrt(Math.max(1+row[0][0]+row[1][1]+row[2][2],0));if(row[2][1]>row[1][2])quaternion[0]=-quaternion[0];if(row[0][2]>row[2][0])quaternion[1]=-quaternion[1];if(row[1][0]>row[0][1])quaternion[2]=-quaternion[2];return true;}function normalize$4(out,mat){var m44=mat[15];// Cannot normalize.
7588
+ if(m44===0)return false;var scale=1/m44;for(var i=0;i<16;i++){out[i]=mat[i]*scale;}return true;}//gets upper-left of a 4x4 matrix into a 3x3 of vectors
7589
+ function mat3from4(out,mat4x4){out[0][0]=mat4x4[0];out[0][1]=mat4x4[1];out[0][2]=mat4x4[2];out[1][0]=mat4x4[4];out[1][1]=mat4x4[5];out[1][2]=mat4x4[6];out[2][0]=mat4x4[8];out[2][1]=mat4x4[9];out[2][2]=mat4x4[10];}function combine(out,a,b,scale1,scale2){out[0]=a[0]*scale1+b[0]*scale2;out[1]=a[1]*scale1+b[1]*scale2;out[2]=a[2]*scale1+b[2]*scale2;}var tmpMat4=create$1();function parsedTransformToMat4(transform,object){if(transform&&transform.length){var defX=0;var defY=0;if(object){defX=object.parsedStyle.defX||0;defY=object.parsedStyle.defY||0;// reset transform
7590
+ object.resetLocalTransform();object.setLocalPosition(defX,defY);}else {object=new DisplayObject({});}transform.forEach(function(parsed){var t=parsed.t,d=parsed.d;if(t==='scale'){// scale(1) scale(1, 1)
7591
+ var newScale=(d===null||d===void 0?void 0:d.map(function(s){return s.value;}))||[1,1];object.scaleLocal(newScale[0],newScale[1],1);}else if(t==='scalex'){var _newScale=(d===null||d===void 0?void 0:d.map(function(s){return s.value;}))||[1];object.scaleLocal(_newScale[0],1,1);}else if(t==='scaley'){var _newScale2=(d===null||d===void 0?void 0:d.map(function(s){return s.value;}))||[1];object.scaleLocal(1,_newScale2[0],1);}else if(t==='scalez'){var _newScale3=(d===null||d===void 0?void 0:d.map(function(s){return s.value;}))||[1];object.scaleLocal(1,1,_newScale3[0]);}else if(t==='scale3d'){var _newScale4=(d===null||d===void 0?void 0:d.map(function(s){return s.value;}))||[1,1,1];object.scaleLocal(_newScale4[0],_newScale4[1],_newScale4[2]);}else if(t==='translate'){var newTranslation=d||[Opx,Opx];object.translateLocal(newTranslation[0].value,newTranslation[1].value,0);}else if(t==='translatex'){var _newTranslation=d||[Opx];object.translateLocal(_newTranslation[0].value,0,0);}else if(t==='translatey'){var _newTranslation2=d||[Opx];object.translateLocal(0,_newTranslation2[0].value,0);}else if(t==='translatez'){var _newTranslation3=d||[Opx];object.translateLocal(0,0,_newTranslation3[0].value);}else if(t==='translate3d'){var _newTranslation4=d||[Opx,Opx,Opx];object.translateLocal(_newTranslation4[0].value,_newTranslation4[1].value,_newTranslation4[2].value);}else if(t==='rotate'){var newAngles=d||[Odeg];object.rotateLocal(0,0,convertAngleUnit(newAngles[0]));}else if(t==='rotatex'){var _newAngles=d||[Odeg];object.rotateLocal(convertAngleUnit(_newAngles[0]),0,0);}else if(t==='rotatey'){var _newAngles2=d||[Odeg];object.rotateLocal(0,convertAngleUnit(_newAngles2[0]),0);}else if(t==='rotatez'){var _newAngles3=d||[Odeg];object.rotateLocal(0,0,convertAngleUnit(_newAngles3[0]));}else if(t==='rotate3d');else if(t==='skew'){var newSkew=(d===null||d===void 0?void 0:d.map(function(s){return s.value;}))||[0,0];object.setLocalSkew(deg2rad(newSkew[0]),deg2rad(newSkew[1]));}else if(t==='skewx'){var _newSkew=(d===null||d===void 0?void 0:d.map(function(s){return s.value;}))||[0];object.setLocalSkew(deg2rad(_newSkew[0]),object.getLocalSkew()[1]);}else if(t==='skewy'){var _newSkew2=(d===null||d===void 0?void 0:d.map(function(s){return s.value;}))||[0];object.setLocalSkew(object.getLocalSkew()[0],deg2rad(_newSkew2[0]));}else if(t==='matrix'){var _d$map=d.map(function(s){return s.value;}),a=_d$map[0],b=_d$map[1],c=_d$map[2],dd=_d$map[3],tx=_d$map[4],ty=_d$map[5];object.setLocalTransform(set(tmpMat4,a,b,0,0,c,dd,0,0,0,0,1,0,tx+defX,ty+defY,0,1));}else if(t==='matrix3d'){// @ts-ignore
7592
+ set.apply(mat4,[tmpMat4].concat(d.map(function(s){return s.value;})));tmpMat4[12]+=defX;tmpMat4[13]+=defY;object.setLocalTransform(tmpMat4);}});}return object.getLocalTransform();}/**
7593
+ * borrow from gradient-parser, but we delete some browser compatible prefix such as `-webkit-`
7594
+ * @see https://github.com/rafaelcaricio/gradient-parser
7595
+ */function colorStopToString(colorStop){var type=colorStop.type,value=colorStop.value;if(type==='hex'){return "#"+value;}else if(type==='literal'){return value;}else if(type==='rgb'){return "rgb("+value.join(',')+")";}else {return "rgba("+value.join(',')+")";}}var parseGradient=function(){var tokens={linearGradient:/^(linear\-gradient)/i,repeatingLinearGradient:/^(repeating\-linear\-gradient)/i,radialGradient:/^(radial\-gradient)/i,repeatingRadialGradient:/^(repeating\-radial\-gradient)/i,/**
7596
+ * @see https://projects.verou.me/conic-gradient/
7597
+ */conicGradient:/^(conic\-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,percentageValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,emValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,angleValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^\#([0-9a-fA-F]+)/,literalColor:/^([a-zA-Z]+)/,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,number:/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/};var input='';function error(msg){throw new Error(input+': '+msg);}function getAST(){var ast=matchListDefinitions();if(input.length>0){error('Invalid input not EOF');}return ast;}function matchListDefinitions(){return matchListing(matchDefinition);}function matchDefinition(){return matchGradient('linear-gradient',tokens.linearGradient,matchLinearOrientation)||matchGradient('repeating-linear-gradient',tokens.repeatingLinearGradient,matchLinearOrientation)||matchGradient('radial-gradient',tokens.radialGradient,matchListRadialOrientations)||matchGradient('repeating-radial-gradient',tokens.repeatingRadialGradient,matchListRadialOrientations)||matchGradient('conic-gradient',tokens.conicGradient,matchListRadialOrientations);}function matchGradient(gradientType,pattern,orientationMatcher){return matchCall(pattern,function(captures){var orientation=orientationMatcher();if(orientation){if(!scan(tokens.comma)){error('Missing comma before color stops');}}return {type:gradientType,orientation:orientation,colorStops:matchListing(matchColorStop)};});}function matchCall(pattern,callback){var captures=scan(pattern);if(captures){if(!scan(tokens.startCall)){error('Missing (');}var result=callback(captures);if(!scan(tokens.endCall)){error('Missing )');}return result;}}function matchLinearOrientation(){return matchSideOrCorner()||matchAngle();}function matchSideOrCorner(){return match('directional',tokens.sideOrCorner,1);}function matchAngle(){return match('angular',tokens.angleValue,1);}function matchListRadialOrientations(){var radialOrientations,radialOrientation=matchRadialOrientation(),lookaheadCache;if(radialOrientation){radialOrientations=[];radialOrientations.push(radialOrientation);lookaheadCache=input;if(scan(tokens.comma)){radialOrientation=matchRadialOrientation();if(radialOrientation){radialOrientations.push(radialOrientation);}else {input=lookaheadCache;}}}return radialOrientations;}function matchRadialOrientation(){var radialType=matchCircle()||matchEllipse();if(radialType){// @ts-ignore
7598
+ radialType.at=matchAtPosition();}else {var extent=matchExtentKeyword();if(extent){radialType=extent;var positionAt=matchAtPosition();if(positionAt){// @ts-ignore
7599
+ radialType.at=positionAt;}}else {var defaultPosition=matchPositioning();if(defaultPosition){radialType={type:'default-radial',// @ts-ignore
7600
+ at:defaultPosition};}}}return radialType;}function matchCircle(){var circle=match('shape',/^(circle)/i,0);if(circle){// @ts-ignore
7601
+ circle.style=matchLength()||matchExtentKeyword();}return circle;}function matchEllipse(){var ellipse=match('shape',/^(ellipse)/i,0);if(ellipse){// @ts-ignore
7602
+ ellipse.style=matchDistance()||matchExtentKeyword();}return ellipse;}function matchExtentKeyword(){return match('extent-keyword',tokens.extentKeywords,1);}function matchAtPosition(){if(match('position',/^at/,0)){var positioning=matchPositioning();if(!positioning){error('Missing positioning value');}return positioning;}}function matchPositioning(){var location=matchCoordinates();if(location.x||location.y){return {type:'position',value:location};}}function matchCoordinates(){return {x:matchDistance(),y:matchDistance()};}function matchListing(matcher){var captures=matcher();var result=[];if(captures){result.push(captures);while(scan(tokens.comma)){captures=matcher();if(captures){result.push(captures);}else {error('One extra comma');}}}return result;}function matchColorStop(){var color=matchColor();if(!color){error('Expected color definition');}color.length=matchDistance();return color;}function matchColor(){return matchHexColor()||matchRGBAColor()||matchRGBColor()||matchLiteralColor();}function matchLiteralColor(){return match('literal',tokens.literalColor,0);}function matchHexColor(){return match('hex',tokens.hexColor,1);}function matchRGBColor(){return matchCall(tokens.rgbColor,function(){return {type:'rgb',value:matchListing(matchNumber)};});}function matchRGBAColor(){return matchCall(tokens.rgbaColor,function(){return {type:'rgba',value:matchListing(matchNumber)};});}function matchNumber(){return scan(tokens.number)[1];}function matchDistance(){return match('%',tokens.percentageValue,1)||matchPositionKeyword()||matchLength();}function matchPositionKeyword(){return match('position-keyword',tokens.positionKeywords,1);}function matchLength(){return match('px',tokens.pixelValue,1)||match('em',tokens.emValue,1);}function match(type,pattern,captureIndex){var captures=scan(pattern);if(captures){return {type:type,value:captures[captureIndex]};}}function scan(regexp){var blankCaptures=/^[\n\r\t\s]+/.exec(input);if(blankCaptures){consume(blankCaptures[0].length);}var captures=regexp.exec(input);if(captures){consume(captures[0].length);}return captures;}function consume(size){input=input.substring(size);}return function(code){input=code;return getAST();};}();function computeLinearGradient(width,height,angle){var rad=deg2rad(angle.value);var rx=0;var ry=0;var rcx=rx+width/2;var rcy=ry+height/2;// get the length of gradient line
7603
+ // @see https://observablehq.com/@danburzo/css-gradient-line
7604
+ var length=Math.abs(width*Math.cos(rad))+Math.abs(height*Math.sin(rad));var x1=rcx-Math.cos(rad)*length/2;var y1=rcy-Math.sin(rad)*length/2;var x2=rcx+Math.cos(rad)*length/2;var y2=rcy+Math.sin(rad)*length/2;return {x1:x1,y1:y1,x2:x2,y2:y2};}function computeRadialGradient(width,height,cx,cy,size){// 'px'
7605
+ var x=cx.value;var y=cy.value;// TODO: 'em'
7606
+ // '%'
7607
+ if(cx.unit===exports.UnitType.kPercentage){x=cx.value/100*width;}if(cy.unit===exports.UnitType.kPercentage){y=cy.value/100*height;}// default to farthest-side
7608
+ var r=Math.max(distanceSquareRoot([0,0],[x,y]),distanceSquareRoot([0,height],[x,y]),distanceSquareRoot([width,height],[x,y]),distanceSquareRoot([width,0],[x,y]));if(size){if(size instanceof CSSUnitValue){r=size.value;}else if(size instanceof CSSKeywordValue){// @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/CSS_Images/Using_CSS_gradients#example_closest-side_for_circles
7609
+ if(size.value==='closest-side'){r=Math.min(x,width-x,y,height-y);}else if(size.value==='farthest-side'){r=Math.max(x,width-x,y,height-y);}else if(size.value==='closest-corner'){r=Math.min(distanceSquareRoot([0,0],[x,y]),distanceSquareRoot([0,height],[x,y]),distanceSquareRoot([width,height],[x,y]),distanceSquareRoot([width,0],[x,y]));}}}return {x:x,y:y,r:r};}(function(Shape){Shape["GROUP"]="g";Shape["CIRCLE"]="circle";Shape["ELLIPSE"]="ellipse";Shape["IMAGE"]="image";Shape["RECT"]="rect";Shape["LINE"]="line";Shape["POLYLINE"]="polyline";Shape["POLYGON"]="polygon";Shape["TEXT"]="text";Shape["PATH"]="path";Shape["HTML"]="html";Shape["MESH"]="mesh";})(exports.Shape||(exports.Shape={}));function getOrCalculatePathTotalLength(path){if(path.parsedStyle.path.totalLength===0){path.parsedStyle.path.totalLength=getTotalLength(path.parsedStyle.path.absolutePath);}return path.parsedStyle.path.totalLength;}function hasArcOrBezier(path){var hasArc=false;var count=path.length;for(var i=0;i<count;i++){var params=path[i];var cmd=params[0];if(cmd==='C'||cmd==='A'||cmd==='Q'){hasArc=true;break;}}return hasArc;}function extractPolygons(pathArray){var polygons=[];var polylines=[];var points=[];// 防止第一个命令不是 'M'
7610
+ for(var i=0;i<pathArray.length;i++){var params=pathArray[i];var cmd=params[0];if(cmd==='M'){// 遇到 'M' 判定是否是新数组,新数组中没有点
7611
+ if(points.length){// 如果存在点,则说明没有遇到 'Z',开始了一个新的多边形
7612
+ polylines.push(points);points=[];// 创建新的点
7613
+ }points.push([params[1],params[2]]);}else if(cmd==='Z'){if(points.length){// 存在点
7614
+ polygons.push(points);points=[];// 开始新的点集合
7615
+ }// 如果不存在点,同时 'Z',则说明是错误,不处理
7616
+ }else {points.push([params[1],params[2]]);}}// 说明 points 未放入 polygons 或者 polyline
7617
+ // 仅当只有一个 M,没有 Z 时会发生这种情况
7618
+ if(points.length>0){polylines.push(points);}return {polygons:polygons,polylines:polylines};}function isSamePoint(point1,point2){return point1[0]===point2[0]&&point1[1]===point2[1];}function getPathBBox(segments,lineWidth){var xArr=[];var yArr=[];var segmentsWithAngle=[];for(var i=0;i<segments.length;i++){var segment=segments[i];var currentPoint=segment.currentPoint,params=segment.params,prePoint=segment.prePoint;var box=void 0;switch(segment.command){case'Q':box=quadratic.box(prePoint[0],prePoint[1],params[1],params[2],params[3],params[4]);break;case'C':box=cubic.box(prePoint[0],prePoint[1],params[1],params[2],params[3],params[4],params[5],params[6]);break;case'A':var arcParams=segment.arcParams;box=arc.box(arcParams.cx,arcParams.cy,arcParams.rx,arcParams.ry,arcParams.xRotation,arcParams.startAngle,arcParams.endAngle);break;default:xArr.push(currentPoint[0]);yArr.push(currentPoint[1]);break;}if(box){segment.box=box;xArr.push(box.x,box.x+box.width);yArr.push(box.y,box.y+box.height);}if(lineWidth&&(segment.command==='L'||segment.command==='M')&&segment.prePoint&&segment.nextPoint){segmentsWithAngle.push(segment);}}// bbox calculation should ignore NaN for path attribute
7619
+ // ref: https://github.com/antvis/g/issues/210
7620
+ // ref: https://github.com/antvis/G2/issues/3109
7621
+ xArr=xArr.filter(function(item){return !Number.isNaN(item)&&item!==Infinity&&item!==-Infinity;});yArr=yArr.filter(function(item){return !Number.isNaN(item)&&item!==Infinity&&item!==-Infinity;});var minX=min(xArr);var minY=min(yArr);var maxX=max(xArr);var maxY=max(yArr);if(segmentsWithAngle.length===0){return {x:minX,y:minY,width:maxX-minX,height:maxY-minY};}for(var _i=0;_i<segmentsWithAngle.length;_i++){var _segment=segmentsWithAngle[_i];var _currentPoint=_segment.currentPoint;var extra=void 0;if(_currentPoint[0]===minX){extra=getExtraFromSegmentWithAngle(_segment,lineWidth);minX=minX-extra.xExtra;}else if(_currentPoint[0]===maxX){extra=getExtraFromSegmentWithAngle(_segment,lineWidth);maxX=maxX+extra.xExtra;}if(_currentPoint[1]===minY){extra=getExtraFromSegmentWithAngle(_segment,lineWidth);minY=minY-extra.yExtra;}else if(_currentPoint[1]===maxY){extra=getExtraFromSegmentWithAngle(_segment,lineWidth);maxY=maxY+extra.yExtra;}}return {x:minX,y:minY,width:maxX-minX,height:maxY-minY};}function getExtraFromSegmentWithAngle(segment,lineWidth){var prePoint=segment.prePoint,currentPoint=segment.currentPoint,nextPoint=segment.nextPoint;var currentAndPre=Math.pow(currentPoint[0]-prePoint[0],2)+Math.pow(currentPoint[1]-prePoint[1],2);var currentAndNext=Math.pow(currentPoint[0]-nextPoint[0],2)+Math.pow(currentPoint[1]-nextPoint[1],2);var preAndNext=Math.pow(prePoint[0]-nextPoint[0],2)+Math.pow(prePoint[1]-nextPoint[1],2);// 以 currentPoint 为顶点的夹角
7622
+ var currentAngle=Math.acos((currentAndPre+currentAndNext-preAndNext)/(2*Math.sqrt(currentAndPre)*Math.sqrt(currentAndNext)));// 夹角为空、 0 或 PI 时,不需要计算夹角处的额外宽度
7623
+ // 注意: 由于计算精度问题,夹角为 0 的情况计算出来的角度可能是一个很小的值,还需要判断其与 0 是否近似相等
7624
+ if(!currentAngle||Math.sin(currentAngle)===0||isNumberEqual(currentAngle,0)){return {xExtra:0,yExtra:0};}var xAngle=Math.abs(Math.atan2(nextPoint[1]-currentPoint[1],nextPoint[0]-currentPoint[0]));var yAngle=Math.abs(Math.atan2(nextPoint[0]-currentPoint[0],nextPoint[1]-currentPoint[1]));// 将夹角转为锐角
7625
+ xAngle=xAngle>Math.PI/2?Math.PI-xAngle:xAngle;yAngle=yAngle>Math.PI/2?Math.PI-yAngle:yAngle;// 这里不考虑在水平和垂直方向的投影,直接使用最大差值
7626
+ // 由于上层统一加减了二分之一线宽,这里需要进行弥补
7627
+ var extra={// 水平方向投影
7628
+ xExtra:Math.cos(currentAngle/2-xAngle)*(lineWidth/2*(1/Math.sin(currentAngle/2)))-lineWidth/2||0,// 垂直方向投影
7629
+ yExtra:Math.cos(yAngle-currentAngle/2)*(lineWidth/2*(1/Math.sin(currentAngle/2)))-lineWidth/2||0};return extra;}// 点对称
7630
+ function toSymmetry(point,center){return [center[0]+(center[0]-point[0]),center[1]+(center[1]-point[1])];}var angleBetween$1=function angleBetween(v0,v1){var p=v0.x*v1.x+v0.y*v1.y;var n=Math.sqrt((Math.pow(v0.x,2)+Math.pow(v0.y,2))*(Math.pow(v1.x,2)+Math.pow(v1.y,2)));var sign=v0.x*v1.y-v0.y*v1.x<0?-1:1;var angle=sign*Math.acos(p/n);return angle;};/**
7631
+ * @see https://github.com/rveciana/svg-path-properties/blob/b6bd9a322966f6ef7a311872d80c56e3718de861/src/arc.ts#L121
7632
+ */var pointOnEllipticalArc=function pointOnEllipticalArc(p0,rx,ry,xAxisRotation,largeArcFlag,sweepFlag,p1,t){// In accordance to: http://www.w3.org/TR/SVG/implnote.html#ArcOutOfRangeParameters
7633
+ rx=Math.abs(rx);ry=Math.abs(ry);xAxisRotation=mod(xAxisRotation,360);var xAxisRotationRadians=deg2rad(xAxisRotation);// If the endpoints are identical, then this is equivalent to omitting the elliptical arc segment entirely.
7634
+ if(p0.x===p1.x&&p0.y===p1.y){return {x:p0.x,y:p0.y,ellipticalArcAngle:0};// Check if angle is correct
7635
+ }// If rx = 0 or ry = 0 then this arc is treated as a straight line segment joining the endpoints.
7636
+ if(rx===0||ry===0){//return this.pointOnLine(p0, p1, t);
7637
+ return {x:0,y:0,ellipticalArcAngle:0};// Check if angle is correct
7638
+ }// Following "Conversion from endpoint to center parameterization"
7639
+ // http://www.w3.org/TR/SVG/implnote.html#ArcConversionEndpointToCenter
7640
+ // Step #1: Compute transformedPoint
7641
+ var dx=(p0.x-p1.x)/2;var dy=(p0.y-p1.y)/2;var transformedPoint={x:Math.cos(xAxisRotationRadians)*dx+Math.sin(xAxisRotationRadians)*dy,y:-Math.sin(xAxisRotationRadians)*dx+Math.cos(xAxisRotationRadians)*dy};// Ensure radii are large enough
7642
+ var radiiCheck=Math.pow(transformedPoint.x,2)/Math.pow(rx,2)+Math.pow(transformedPoint.y,2)/Math.pow(ry,2);if(radiiCheck>1){rx=Math.sqrt(radiiCheck)*rx;ry=Math.sqrt(radiiCheck)*ry;}// Step #2: Compute transformedCenter
7643
+ var cSquareNumerator=Math.pow(rx,2)*Math.pow(ry,2)-Math.pow(rx,2)*Math.pow(transformedPoint.y,2)-Math.pow(ry,2)*Math.pow(transformedPoint.x,2);var cSquareRootDenom=Math.pow(rx,2)*Math.pow(transformedPoint.y,2)+Math.pow(ry,2)*Math.pow(transformedPoint.x,2);var cRadicand=cSquareNumerator/cSquareRootDenom;// Make sure this never drops below zero because of precision
7644
+ cRadicand=cRadicand<0?0:cRadicand;var cCoef=(largeArcFlag!==sweepFlag?1:-1)*Math.sqrt(cRadicand);var transformedCenter={x:cCoef*(rx*transformedPoint.y/ry),y:cCoef*(-(ry*transformedPoint.x)/rx)};// Step #3: Compute center
7645
+ var center={x:Math.cos(xAxisRotationRadians)*transformedCenter.x-Math.sin(xAxisRotationRadians)*transformedCenter.y+(p0.x+p1.x)/2,y:Math.sin(xAxisRotationRadians)*transformedCenter.x+Math.cos(xAxisRotationRadians)*transformedCenter.y+(p0.y+p1.y)/2};// Step #4: Compute start/sweep angles
7646
+ // Start angle of the elliptical arc prior to the stretch and rotate operations.
7647
+ // Difference between the start and end angles
7648
+ var startVector={x:(transformedPoint.x-transformedCenter.x)/rx,y:(transformedPoint.y-transformedCenter.y)/ry};var startAngle=angleBetween$1({x:1,y:0},startVector);var endVector={x:(-transformedPoint.x-transformedCenter.x)/rx,y:(-transformedPoint.y-transformedCenter.y)/ry};var sweepAngle=angleBetween$1(startVector,endVector);if(!sweepFlag&&sweepAngle>0){sweepAngle-=2*Math.PI;}else if(sweepFlag&&sweepAngle<0){sweepAngle+=2*Math.PI;}// We use % instead of `mod(..)` because we want it to be -360deg to 360deg(but actually in radians)
7649
+ sweepAngle%=2*Math.PI;// From http://www.w3.org/TR/SVG/implnote.html#ArcParameterizationAlternatives
7650
+ var angle=startAngle+sweepAngle*t;var ellipseComponentX=rx*Math.cos(angle);var ellipseComponentY=ry*Math.sin(angle);var point={x:Math.cos(xAxisRotationRadians)*ellipseComponentX-Math.sin(xAxisRotationRadians)*ellipseComponentY+center.x,y:Math.sin(xAxisRotationRadians)*ellipseComponentX+Math.cos(xAxisRotationRadians)*ellipseComponentY+center.y,ellipticalArcStartAngle:startAngle,ellipticalArcEndAngle:startAngle+sweepAngle,ellipticalArcAngle:angle,ellipticalArcCenter:center,resultantRx:rx,resultantRy:ry};return point;};function path2Segments(path){var segments=[];var currentPoint=null;// 当前图形
7651
+ var nextParams=null;// 下一节点的 path 参数
7652
+ var startMovePoint=null;// 开始 M 的点,可能会有多个
7653
+ var lastStartMovePointIndex=0;// 最近一个开始点 M 的索引
7654
+ var count=path.length;for(var i=0;i<count;i++){var params=path[i];nextParams=path[i+1];var command=params[0];// 数学定义上的参数,便于后面的计算
7655
+ var segment={command:command,prePoint:currentPoint,params:params,startTangent:null,endTangent:null,currentPoint:null,nextPoint:null,arcParams:null,box:null,cubicParams:null};switch(command){case'M':startMovePoint=[params[1],params[2]];lastStartMovePointIndex=i;break;case'A':var arcParams=getArcParams(currentPoint,params);segment.arcParams=arcParams;break;}if(command==='Z'){// 有了 Z 后,当前节点从开始 M 的点开始
7656
+ currentPoint=startMovePoint;// 如果当前点的命令为 Z,相当于当前点为最近一个 M 点,则下一个点直接指向最近一个 M 点的下一个点
7657
+ nextParams=path[lastStartMovePointIndex+1];}else {var len=params.length;currentPoint=[params[len-2],params[len-1]];}if(nextParams&&nextParams[0]==='Z'){// 如果下一个点的命令为 Z,则下一个点直接指向最近一个 M 点
7658
+ nextParams=path[lastStartMovePointIndex];if(segments[lastStartMovePointIndex]){// 如果下一个点的命令为 Z,则最近一个 M 点的前一个点为当前点
7659
+ segments[lastStartMovePointIndex].prePoint=currentPoint;}}segment.currentPoint=currentPoint;// 如果当前点与最近一个 M 点相同,则最近一个 M 点的前一个点为当前点的前一个点
7660
+ if(segments[lastStartMovePointIndex]&&isSamePoint(currentPoint,segments[lastStartMovePointIndex].currentPoint)){segments[lastStartMovePointIndex].prePoint=segment.prePoint;}var nextPoint=nextParams?[nextParams[nextParams.length-2],nextParams[nextParams.length-1]]:null;segment.nextPoint=nextPoint;// Add startTangent and endTangent
7661
+ var prePoint=segment.prePoint;if(['L','H','V'].includes(command)){segment.startTangent=[prePoint[0]-currentPoint[0],prePoint[1]-currentPoint[1]];segment.endTangent=[currentPoint[0]-prePoint[0],currentPoint[1]-prePoint[1]];}else if(command==='Q'){// 二次贝塞尔曲线只有一个控制点
7662
+ var cp=[params[1],params[2]];// 二次贝塞尔曲线的终点为 currentPoint
7663
+ segment.startTangent=[prePoint[0]-cp[0],prePoint[1]-cp[1]];segment.endTangent=[currentPoint[0]-cp[0],currentPoint[1]-cp[1]];}else if(command==='T'){var preSegment=segments[i-1];var _cp=toSymmetry(preSegment.currentPoint,prePoint);if(preSegment.command==='Q'){segment.command='Q';segment.startTangent=[prePoint[0]-_cp[0],prePoint[1]-_cp[1]];segment.endTangent=[currentPoint[0]-_cp[0],currentPoint[1]-_cp[1]];}else {// @ts-ignore
7664
+ segment.command='TL';segment.startTangent=[prePoint[0]-currentPoint[0],prePoint[1]-currentPoint[1]];segment.endTangent=[currentPoint[0]-prePoint[0],currentPoint[1]-prePoint[1]];}}else if(command==='C'){// 三次贝塞尔曲线有两个控制点
7665
+ var cp1=[params[1],params[2]];var cp2=[params[3],params[4]];segment.startTangent=[prePoint[0]-cp1[0],prePoint[1]-cp1[1]];segment.endTangent=[currentPoint[0]-cp2[0],currentPoint[1]-cp2[1]];// horizontal line, eg. ['C', 100, 100, 100, 100, 200, 200]
7666
+ if(segment.startTangent[0]===0&&segment.startTangent[1]===0){segment.startTangent=[cp1[0]-cp2[0],cp1[1]-cp2[1]];}if(segment.endTangent[0]===0&&segment.endTangent[1]===0){segment.endTangent=[cp2[0]-cp1[0],cp2[1]-cp1[1]];}}else if(command==='S'){var _preSegment=segments[i-1];var _cp2=toSymmetry(_preSegment.currentPoint,prePoint);var _cp3=[params[1],params[2]];if(_preSegment.command==='C'){segment.command='C';// 将 S 命令变换为 C 命令
7667
+ segment.startTangent=[prePoint[0]-_cp2[0],prePoint[1]-_cp2[1]];segment.endTangent=[currentPoint[0]-_cp3[0],currentPoint[1]-_cp3[1]];}else {// @ts-ignore
7668
+ segment.command='SQ';// 将 S 命令变换为 SQ 命令
7669
+ segment.startTangent=[prePoint[0]-_cp3[0],prePoint[1]-_cp3[1]];segment.endTangent=[currentPoint[0]-_cp3[0],currentPoint[1]-_cp3[1]];}}else if(command==='A'){var _getTangentAtRatio=getTangentAtRatio(segment,0),dx1=_getTangentAtRatio.x,dy1=_getTangentAtRatio.y;var _getTangentAtRatio2=getTangentAtRatio(segment,1,false),dx2=_getTangentAtRatio2.x,dy2=_getTangentAtRatio2.y;segment.startTangent=[dx1,dy1];segment.endTangent=[dx2,dy2];}segments.push(segment);}return segments;}/**
7670
+ * Use length instead of ratio
7671
+ */function getTangentAtRatio(segment,ratio,sign){if(sign===void 0){sign=true;}var _segment$arcParams=segment.arcParams,_segment$arcParams$rx=_segment$arcParams.rx,rx=_segment$arcParams$rx===void 0?0:_segment$arcParams$rx,_segment$arcParams$ry=_segment$arcParams.ry,ry=_segment$arcParams$ry===void 0?0:_segment$arcParams$ry,xRotation=_segment$arcParams.xRotation,arcFlag=_segment$arcParams.arcFlag,sweepFlag=_segment$arcParams.sweepFlag;var p1=pointOnEllipticalArc({x:segment.prePoint[0],y:segment.prePoint[1]},rx,ry,xRotation,!!arcFlag,!!sweepFlag,{x:segment.currentPoint[0],y:segment.currentPoint[1]},ratio);var p2=pointOnEllipticalArc({x:segment.prePoint[0],y:segment.prePoint[1]},rx,ry,xRotation,!!arcFlag,!!sweepFlag,{x:segment.currentPoint[0],y:segment.currentPoint[1]},sign?ratio+0.005:ratio-0.005);var xDist=p2.x-p1.x;var yDist=p2.y-p1.y;var dist=Math.sqrt(xDist*xDist+yDist*yDist);return {x:-xDist/dist,y:-yDist/dist};}// 向量长度
7672
+ function vMag(v){return Math.sqrt(v[0]*v[0]+v[1]*v[1]);}// u.v/|u||v|,计算夹角的余弦值
7673
+ function vRatio(u,v){// 当存在一个向量的长度为 0 时,夹角也为 0,即夹角的余弦值为 1
7674
+ return vMag(u)*vMag(v)?(u[0]*v[0]+u[1]*v[1])/(vMag(u)*vMag(v)):1;}// 向量角度
7675
+ function vAngle(u,v){return (u[0]*v[1]<u[1]*v[0]?-1:1)*Math.acos(vRatio(u,v));}function getArcParams(startPoint,params){var rx=params[1];var ry=params[2];var xRotation=mod(deg2rad(params[3]),Math.PI*2);var arcFlag=params[4];var sweepFlag=params[5];// 弧形起点坐标
7676
+ var x1=startPoint[0];var y1=startPoint[1];// 弧形终点坐标
7677
+ var x2=params[6];var y2=params[7];var xp=Math.cos(xRotation)*(x1-x2)/2.0+Math.sin(xRotation)*(y1-y2)/2.0;var yp=-1*Math.sin(xRotation)*(x1-x2)/2.0+Math.cos(xRotation)*(y1-y2)/2.0;var lambda=xp*xp/(rx*rx)+yp*yp/(ry*ry);if(lambda>1){rx*=Math.sqrt(lambda);ry*=Math.sqrt(lambda);}var diff=rx*rx*(yp*yp)+ry*ry*(xp*xp);var f=diff?Math.sqrt((rx*rx*(ry*ry)-diff)/diff):1;if(arcFlag===sweepFlag){f*=-1;}if(isNaN(f)){f=0;}// 旋转前的起点坐标,且当长半轴和短半轴的长度为 0 时,坐标按 (0, 0) 处理
7678
+ var cxp=ry?f*rx*yp/ry:0;var cyp=rx?f*-ry*xp/rx:0;// 椭圆圆心坐标
7679
+ var cx=(x1+x2)/2.0+Math.cos(xRotation)*cxp-Math.sin(xRotation)*cyp;var cy=(y1+y2)/2.0+Math.sin(xRotation)*cxp+Math.cos(xRotation)*cyp;// 起始点的单位向量
7680
+ var u=[(xp-cxp)/rx,(yp-cyp)/ry];// 终止点的单位向量
7681
+ var v=[(-1*xp-cxp)/rx,(-1*yp-cyp)/ry];// 计算起始点和圆心的连线,与 x 轴正方向的夹角
7682
+ var theta=vAngle([1,0],u);// 计算圆弧起始点和终止点与椭圆圆心连线的夹角
7683
+ var dTheta=vAngle(u,v);if(vRatio(u,v)<=-1){dTheta=Math.PI;}if(vRatio(u,v)>=1){dTheta=0;}if(sweepFlag===0&&dTheta>0){dTheta=dTheta-2*Math.PI;}if(sweepFlag===1&&dTheta<0){dTheta=dTheta+2*Math.PI;}return {cx:cx,cy:cy,// 弧形的起点和终点相同时,长轴和短轴的长度按 0 处理
7684
+ rx:isSamePoint(startPoint,[x2,y2])?0:rx,ry:isSamePoint(startPoint,[x2,y2])?0:ry,startAngle:theta,endAngle:theta+dTheta,xRotation:xRotation,arcFlag:arcFlag,sweepFlag:sweepFlag};}function commandsToPathString(commands,object,transform){var _object$parsedStyle=object.parsedStyle,_object$parsedStyle$d=_object$parsedStyle.defX,defX=_object$parsedStyle$d===void 0?0:_object$parsedStyle$d,_object$parsedStyle$d2=_object$parsedStyle.defY,defY=_object$parsedStyle$d2===void 0?0:_object$parsedStyle$d2;return commands.reduce(function(prev,cur){var path='';if(cur[0]==='M'||cur[0]==='L'){var p=fromValues$2(cur[1]-defX,cur[2]-defY,0);if(transform){transformMat4(p,p,transform);}path=""+cur[0]+p[0]+","+p[1];}else if(cur[0]==='Z'){path=cur[0];}else if(cur[0]==='C'){var p1=fromValues$2(cur[1]-defX,cur[2]-defY,0);var p2=fromValues$2(cur[3]-defX,cur[4]-defY,0);var p3=fromValues$2(cur[5]-defX,cur[6]-defY,0);if(transform){transformMat4(p1,p1,transform);transformMat4(p2,p2,transform);transformMat4(p3,p3,transform);}path=""+cur[0]+p1[0]+","+p1[1]+","+p2[0]+","+p2[1]+","+p3[0]+","+p3[1];}else if(cur[0]==='A'){var c=fromValues$2(cur[6]-defX,cur[7]-defY,0);if(transform){transformMat4(c,c,transform);}path=""+cur[0]+cur[1]+","+cur[2]+","+cur[3]+","+cur[4]+","+cur[5]+","+c[0]+","+c[1];}else if(cur[0]==='Q'){var _p=fromValues$2(cur[1]-defX,cur[2]-defY,0);var _p2=fromValues$2(cur[3]-defX,cur[4]-defY,0);if(transform){transformMat4(_p,_p,transform);transformMat4(_p2,_p2,transform);}path=""+cur[0]+cur[1]+","+cur[2]+","+cur[3]+","+cur[4]+"}";}return prev+=path;},'');}function lineToCommands(x1,y1,x2,y2){return [['M',x1,y1],['L',x2,y2]];}function ellipseToCommands(rx,ry,cx,cy){var factor=(-1+Math.sqrt(2))/3*4;var dx=rx*factor;var dy=ry*factor;var left=cx-rx;var right=cx+rx;var top=cy-ry;var bottom=cy+ry;return [['M',left,cy],['C',left,cy-dy,cx-dx,top,cx,top],['C',cx+dx,top,right,cy-dy,right,cy],['C',right,cy+dy,cx+dx,bottom,cx,bottom],['C',cx-dx,bottom,left,cy+dy,left,cy],['Z']];}function polygonToCommands(points,closed){var result=points.map(function(point,i){return [i===0?'M':'L',point[0],point[1]];});if(closed){result.push(['Z']);}return result;}function rectToCommands(width,height,x,y,radius){// @see https://gist.github.com/danielpquinn/dd966af424030d47e476
7685
+ if(radius){var tlr=radius[0],trr=radius[1],brr=radius[2],blr=radius[3];var signX=width>0?1:-1;var signY=height>0?1:-1;// sweep-flag @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Tutorial/Paths#arcs
7686
+ var sweepFlag=signX+signY!==0?1:0;return [['M',signX*tlr+x,y],['L',width-signX*trr+x,y],trr?['A',trr,trr,0,0,sweepFlag,width+x,signY*trr+y]:null,['L',width+x,height-signY*brr+y],brr?['A',brr,brr,0,0,sweepFlag,width+x-signX*brr,height+y]:null,['L',x+signX*blr,height+y],blr?['A',blr,blr,0,0,sweepFlag,x,height+y-signY*blr]:null,['L',x,signY*tlr+y],tlr?['A',tlr,tlr,0,0,sweepFlag,signX*tlr+x,y]:null,['Z']].filter(function(command){return command;});}return [['M',x,y],['L',x+width,y],['L',x+width,y+height],['L',x,y+height],['Z']];}/**
7687
+ * convert object to path, should account for:
7688
+ * * transform & origin
7689
+ * * anchor
7690
+ * * lineWidth
7691
+ */function convertToPath(object,transform){if(transform===void 0){transform=object.getLocalTransform();}var commands=[];switch(object.nodeName){case exports.Shape.LINE:var _object$parsedStyle2=object.parsedStyle,x1=_object$parsedStyle2.x1,y1=_object$parsedStyle2.y1,x2=_object$parsedStyle2.x2,y2=_object$parsedStyle2.y2;commands=lineToCommands(x1,y1,x2,y2);break;case exports.Shape.CIRCLE:{var _object$parsedStyle3=object.parsedStyle,r=_object$parsedStyle3.r,cx=_object$parsedStyle3.cx,cy=_object$parsedStyle3.cy;commands=ellipseToCommands(r,r,cx,cy);break;}case exports.Shape.ELLIPSE:{var _object$parsedStyle4=object.parsedStyle,rx=_object$parsedStyle4.rx,ry=_object$parsedStyle4.ry,_cx=_object$parsedStyle4.cx,_cy=_object$parsedStyle4.cy;commands=ellipseToCommands(rx,ry,_cx,_cy);break;}case exports.Shape.POLYLINE:case exports.Shape.POLYGON:var points=object.parsedStyle.points;commands=polygonToCommands(points.points,object.nodeName===exports.Shape.POLYGON);break;case exports.Shape.RECT:var _object$parsedStyle5=object.parsedStyle,width=_object$parsedStyle5.width,height=_object$parsedStyle5.height,x=_object$parsedStyle5.x,y=_object$parsedStyle5.y,radius=_object$parsedStyle5.radius;var hasRadius=radius&&radius.some(function(r){return r!==0;});commands=rectToCommands(width,height,x,y,hasRadius&&radius.map(function(r){return clamp(r,0,Math.min(Math.abs(width)/2,Math.abs(height)/2));}));break;case exports.Shape.PATH:var absolutePath=object.parsedStyle.path.absolutePath;commands=[].concat(absolutePath);break;}if(commands.length){return commandsToPathString(commands,object,transform);}}function translatePathToString(absolutePath,defX,defY,startOffsetX,startOffsetY,endOffsetX,endOffsetY){if(startOffsetX===void 0){startOffsetX=0;}if(startOffsetY===void 0){startOffsetY=0;}if(endOffsetX===void 0){endOffsetX=0;}if(endOffsetY===void 0){endOffsetY=0;}var newValue=absolutePath.map(function(params,i){var command=params[0];var nextSegment=absolutePath[i+1];var useStartOffset=i===0&&(startOffsetX!==0||startOffsetY!==0);var useEndOffset=(i===absolutePath.length-1||nextSegment&&(nextSegment[0]==='M'||nextSegment[0]==='Z'))&&endOffsetX!==0&&endOffsetY!==0;switch(command){case'M':// Use start marker offset
7692
+ if(useStartOffset){return "M "+(params[1]-defX+startOffsetX)+","+(params[2]-defY+startOffsetY)+" L "+(params[1]-defX)+","+(params[2]-defY);}else {return "M "+(params[1]-defX)+","+(params[2]-defY);}case'L':return "L "+(params[1]-defX+(useEndOffset?endOffsetX:0))+","+(params[2]-defY+(useEndOffset?endOffsetY:0));case'Q':return "Q "+(params[1]-defX)+" "+(params[2]-defY)+","+(params[3]-defX)+" "+(params[4]-defY)+(useEndOffset?" L "+(params[3]-defX+endOffsetX)+","+(params[4]-defY+endOffsetY):'');case'C':return "C "+(params[1]-defX)+" "+(params[2]-defY)+","+(params[3]-defX)+" "+(params[4]-defY)+","+(params[5]-defX)+" "+(params[6]-defY)+(useEndOffset?" L "+(params[5]-defX+endOffsetX)+","+(params[6]-defY+endOffsetY):'');case'A':return "A "+params[1]+" "+params[2]+" "+params[3]+" "+params[4]+" "+params[5]+" "+(params[6]-defX)+" "+(params[7]-defY)+(useEndOffset?" L "+(params[6]-defX+endOffsetX)+","+(params[7]-defY+endOffsetY):'');case'Z':return 'Z';}}).join(' ');if(~newValue.indexOf('NaN')){return '';}return newValue;}function isFillOrStrokeAffected(pointerEvents,fill,stroke){// account for pointerEvents
7693
+ // @see https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
7694
+ var hasFill=false;var hasStroke=false;var isFillOtherThanNone=!!fill&&!fill.isNone;var isStrokeOtherThanNone=!!stroke&&!stroke.isNone;if(pointerEvents==='visiblepainted'||pointerEvents==='painted'||pointerEvents==='auto'){hasFill=isFillOtherThanNone;hasStroke=isStrokeOtherThanNone;}else if(pointerEvents==='visiblefill'||pointerEvents==='fill'){hasFill=true;}else if(pointerEvents==='visiblestroke'||pointerEvents==='stroke'){hasStroke=true;}else if(pointerEvents==='visible'||pointerEvents==='all'){// The values of the fill and stroke do not affect event processing.
7695
+ hasFill=true;hasStroke=true;}return [hasFill,hasStroke];}// @ts-nocheck
7696
+ // interface HookInterceptor<T, R, AdditionalOptions = UnsetAdditionalOptions> {
7697
+ // name?: string;
7698
+ // tap?: (tap: FullTap & IfSet<AdditionalOptions>) => void;
7699
+ // call?: (...args: any[]) => void;
7700
+ // loop?: (...args: any[]) => void;
7701
+ // error?: (err: Error) => void;
7702
+ // result?: (result: R) => void;
7703
+ // done?: () => void;
7704
+ // register?: (tap: FullTap & IfSet<AdditionalOptions>) => FullTap & IfSet<AdditionalOptions>;
7586
7705
  // }
7587
- return [leftValue,rightValue,function(value){if(nonNegative){value=Math.max(value,0);}return value+unit;}];}function convertAngleUnit(value){var deg=0;if(value.unit===exports.UnitType.kDegrees){deg=value.value;}else if(value.unit===exports.UnitType.kRadians){deg=rad2deg(Number(value.value));}else if(value.unit===exports.UnitType.kTurns){deg=turn2deg(Number(value.value));}return deg;}function parseDimensionArray(string){if(isString(string)){// "1px 2px 3px"
7588
- return string.split(' ').map(function(segment){return parseLengthOrPercentage(segment);});}else {// [1, '2px', 3]
7589
- return string.map(function(segment){return parseLengthOrPercentage(segment.toString());});}}// export function mergeDimensionList(
7590
- // left: CSSUnitValue[],
7591
- // right: CSSUnitValue[],
7592
- // target: IElement | null,
7593
- // ): [number[], number[], (list: number[]) => string] | undefined {
7594
- // if (left.length !== right.length) {
7595
- // return;
7596
- // }
7597
- // const unit = left[0].unit;
7598
- // return [
7599
- // left.map((l) => l.value),
7600
- // right.map((l) => l.value),
7601
- // (values: number[]) => {
7602
- // return values.map((n) => new CSSUnitValue(n, unit)).join(' ');
7603
- // },
7604
- // ];
7706
+ // type ArgumentNames<T extends any[]> = FixedSizeArray<T['length'], string>;
7707
+ // export declare class AsyncHook<T, R, AdditionalOptions = UnsetAdditionalOptions> extends Hook<
7708
+ // T,
7709
+ // R,
7710
+ // AdditionalOptions
7711
+ // > {
7712
+ // tapAsync(
7713
+ // options: string | (Tap & IfSet<AdditionalOptions>),
7714
+ // fn: (...args: Append<AsArray<T>, InnerCallback<Error, R>>) => void,
7715
+ // ): void;
7716
+ // tapPromise(
7717
+ // options: string | (Tap & IfSet<AdditionalOptions>),
7718
+ // fn: (...args: AsArray<T>) => Promise<R>,
7719
+ // ): void;
7605
7720
  // }
7606
- function convertPercentUnit(valueWithUnit,vec3Index,target){if(valueWithUnit.unit===exports.UnitType.kPixels){return Number(valueWithUnit.value);}else if(valueWithUnit.unit===exports.UnitType.kPercentage&&target){var bounds=target.nodeName===exports.Shape.GROUP?target.getLocalBounds():target.getGeometryBounds();var size=0;if(!AABB.isEmpty(bounds)){size=bounds.halfExtents[vec3Index]*2;}return Number(valueWithUnit.value)/100*size;}return 0;}var parseParam=function parseParam(css){return parseDimension(/deg|rad|grad|turn|px|%/g,css);};var supportedFilters=['blur','brightness','drop-shadow','contrast','grayscale','sepia','saturate','hue-rotate','invert'];function parseFilter(filterStr){if(filterStr===void 0){filterStr='';}filterStr=filterStr.toLowerCase().trim();if(filterStr==='none'){return [];}var filterRegExp=/\s*([\w-]+)\(([^)]*)\)/g;var result=[];var match;var prevLastIndex=0;while(match=filterRegExp.exec(filterStr)){if(match.index!==prevLastIndex){return [];}prevLastIndex=match.index+match[0].length;if(supportedFilters.indexOf(match[1])>-1){result.push({name:match[1],params:match[2].split(' ').map(function(p){return parseParam(p)||parseColor(p);})});}if(filterRegExp.lastIndex===filterStr.length){return result;}}return [];}function numberToString(x){// scale(0.00000001) -> scale(0)
7607
- // return x.toFixed(6).replace(/0+$/, '').replace(/\.$/, '');
7608
- return x.toString();}/**
7609
- * parse string or number to CSSUnitValue(numeric)
7610
- *
7611
- * eg.
7721
+ var CALL_DELEGATE=function CALL_DELEGATE(){this.call=this._createCall('sync');return this.call.apply(this,arguments);};var CALL_ASYNC_DELEGATE=function CALL_ASYNC_DELEGATE(){this.callAsync=this._createCall('async');return this.callAsync.apply(this,arguments);};var PROMISE_DELEGATE=function PROMISE_DELEGATE(){this.promise=this._createCall('promise');return this.promise.apply(this,arguments);};var Hook=/*#__PURE__*/function(){function Hook(args,name){if(args===void 0){args=[];}if(name===void 0){name=undefined;}this.name=void 0;this.taps=void 0;this.promise=void 0;this._promise=void 0;this._args=args;this.name=name;this.taps=[];this.interceptors=[];this._call=CALL_DELEGATE;this.call=CALL_DELEGATE;this._callAsync=CALL_ASYNC_DELEGATE;this.callAsync=CALL_ASYNC_DELEGATE;this._promise=PROMISE_DELEGATE;this.promise=PROMISE_DELEGATE;this._x=undefined;// this.compile = this.compile;
7722
+ // this.tap = this.tap;
7723
+ // this.tapAsync = this.tapAsync;
7724
+ // this.tapPromise = this.tapPromise;
7725
+ }var _proto=Hook.prototype;_proto.compile=function compile(options){throw new Error('Abstract: should be overridden');};_proto._createCall=function _createCall(type){return this.compile({taps:this.taps,interceptors:this.interceptors,args:this._args,type:type});};_proto._tap=function _tap(type,options,fn){if(typeof options==='string'){options={name:options.trim()};}else if(typeof options!=='object'||options===null){throw new Error('Invalid tap options');}if(typeof options.name!=='string'||options.name===''){throw new Error('Missing name for tap');}// if (typeof options.context !== "undefined") {
7726
+ // deprecateContext();
7727
+ // }
7728
+ options=Object.assign({type:type,fn:fn},options);options=this._runRegisterInterceptors(options);this._insert(options);};_proto.tap=function tap(options,fn){this._tap('sync',options,fn);};_proto.tapAsync=function tapAsync(options,fn){this._tap('async',options,fn);};_proto.tapPromise=function tapPromise(options,fn){this._tap('promise',options,fn);};_proto._runRegisterInterceptors=function _runRegisterInterceptors(options){for(var _iterator=_createForOfIteratorHelperLoose(this.interceptors),_step;!(_step=_iterator()).done;){var interceptor=_step.value;if(interceptor.register){var newOptions=interceptor.register(options);if(newOptions!==undefined){options=newOptions;}}}return options;};_proto.withOptions=function withOptions(options){var _this=this;var mergeOptions=function mergeOptions(opt){return Object.assign({},options,typeof opt==='string'?{name:opt}:opt);};return {name:this.name,tap:function tap(opt,fn){return _this.tap(mergeOptions(opt),fn);},tapAsync:function tapAsync(opt,fn){return _this.tapAsync(mergeOptions(opt),fn);},tapPromise:function tapPromise(opt,fn){return _this.tapPromise(mergeOptions(opt),fn);},// intercept: (interceptor) => this.intercept(interceptor),
7729
+ isUsed:function isUsed(){return _this.isUsed();},withOptions:function withOptions(opt){return _this.withOptions(mergeOptions(opt));}};};_proto.isUsed=function isUsed(){return this.taps.length>0||this.interceptors.length>0;}// intercept(interceptor: HookInterceptor<T, R, AdditionalOptions>) {
7730
+ // this._resetCompilation();
7731
+ // this.interceptors.push(Object.assign({}, interceptor));
7732
+ // if (interceptor.register) {
7733
+ // for (let i = 0; i < this.taps.length; i++) {
7734
+ // this.taps[i] = interceptor.register(this.taps[i]);
7735
+ // }
7736
+ // }
7737
+ // }
7738
+ ;_proto._resetCompilation=function _resetCompilation(){this.call=this._call;this.callAsync=this._callAsync;this.promise=this._promise;};_proto._insert=function _insert(item){this._resetCompilation();var before;if(typeof item.before==='string'){before=new Set([item.before]);}else if(Array.isArray(item.before)){before=new Set(item.before);}var stage=0;if(typeof item.stage==='number'){stage=item.stage;}var i=this.taps.length;while(i>0){i--;var x=this.taps[i];this.taps[i+1]=x;var xStage=x.stage||0;if(before){if(before.has(x.name)){before.delete(x.name);continue;}if(before.size>0){continue;}}if(xStage>stage){continue;}i++;break;}this.taps[i]=item;};return Hook;}();// Object.setPrototypeOf(Hook.prototype, null);
7739
+ // @ts-nocheck
7740
+ var HookCodeFactory=/*#__PURE__*/function(){function HookCodeFactory(config){this.config=config;this.options=undefined;this._args=undefined;}var _proto=HookCodeFactory.prototype;_proto.create=function create(options){this.init(options);var fn;switch(this.options.type){case'sync':fn=new Function(this.args(),'"use strict";\n'+this.header()+this.contentWithInterceptors({onError:function onError(err){return "throw "+err+";\n";},onResult:function onResult(result){return "return "+result+";\n";},resultReturns:true,onDone:function onDone(){return '';},rethrowIfPossible:true}));break;case'async':fn=new Function(this.args({after:'_callback'}),'"use strict";\n'+this.header()+this.contentWithInterceptors({onError:function onError(err){return "_callback("+err+");\n";},onResult:function onResult(result){return "_callback(null, "+result+");\n";},onDone:function onDone(){return '_callback();\n';}}));break;case'promise':var errorHelperUsed=false;var content=this.contentWithInterceptors({onError:function onError(err){errorHelperUsed=true;return "_error("+err+");\n";},onResult:function onResult(result){return "_resolve("+result+");\n";},onDone:function onDone(){return '_resolve();\n';}});var code='';code+='"use strict";\n';code+=this.header();code+='return new Promise((function(_resolve, _reject) {\n';if(errorHelperUsed){code+='var _sync = true;\n';code+='function _error(_err) {\n';code+='if(_sync)\n';code+='_resolve(Promise.resolve().then((function() { throw _err; })));\n';code+='else\n';code+='_reject(_err);\n';code+='};\n';}code+=content;if(errorHelperUsed){code+='_sync = false;\n';}code+='}));\n';fn=new Function(this.args(),code);break;}this.deinit();return fn;};_proto.setup=function setup(instance,options){instance._x=options.taps.map(function(t){return t.fn;});}/**
7741
+ * @param {{ type: "sync" | "promise" | "async", taps: Array<Tap>, interceptors: Array<Interceptor> }} options
7742
+ */;_proto.init=function init(options){this.options=options;this._args=options.args.slice();};_proto.deinit=function deinit(){this.options=undefined;this._args=undefined;};_proto.contentWithInterceptors=function contentWithInterceptors(options){var _this=this;if(this.options.interceptors.length>0){var onError=options.onError;var onResult=options.onResult;var onDone=options.onDone;var code='';for(var i=0;i<this.options.interceptors.length;i++){var interceptor=this.options.interceptors[i];if(interceptor.call){code+=this.getInterceptor(i)+".call("+this.args({before:interceptor.context?'_context':undefined})+");\n";}}code+=this.content(Object.assign(options,{onError:onError&&function(err){var code='';for(var _i=0;_i<_this.options.interceptors.length;_i++){var _interceptor=_this.options.interceptors[_i];if(_interceptor.error){code+=_this.getInterceptor(_i)+".error("+err+");\n";}}code+=onError(err);return code;},onResult:onResult&&function(result){var code='';for(var _i2=0;_i2<_this.options.interceptors.length;_i2++){var _interceptor2=_this.options.interceptors[_i2];if(_interceptor2.result){code+=_this.getInterceptor(_i2)+".result("+result+");\n";}}code+=onResult(result);return code;},onDone:onDone&&function(){var code='';for(var _i3=0;_i3<_this.options.interceptors.length;_i3++){var _interceptor3=_this.options.interceptors[_i3];if(_interceptor3.done){code+=_this.getInterceptor(_i3)+".done();\n";}}code+=onDone();return code;}}));return code;}else {return this.content(options);}};_proto.header=function header(){var code='';if(this.needContext()){code+='var _context = {};\n';}else {code+='var _context;\n';}code+='var _x = this._x;\n';if(this.options.interceptors.length>0){code+='var _taps = this.taps;\n';code+='var _interceptors = this.interceptors;\n';}return code;};_proto.needContext=function needContext(){for(var _iterator=_createForOfIteratorHelperLoose(this.options.taps),_step;!(_step=_iterator()).done;){var tap=_step.value;if(tap.context)return true;}return false;};_proto.callTap=function callTap(tapIndex,_ref){var onError=_ref.onError,onResult=_ref.onResult,onDone=_ref.onDone,rethrowIfPossible=_ref.rethrowIfPossible;var code='';var hasTapCached=false;for(var i=0;i<this.options.interceptors.length;i++){var interceptor=this.options.interceptors[i];if(interceptor.tap){if(!hasTapCached){code+="var _tap"+tapIndex+" = "+this.getTap(tapIndex)+";\n";hasTapCached=true;}code+=this.getInterceptor(i)+".tap("+(interceptor.context?'_context, ':'')+"_tap"+tapIndex+");\n";}}code+="var _fn"+tapIndex+" = "+this.getTapFn(tapIndex)+";\n";var tap=this.options.taps[tapIndex];switch(tap.type){case'sync':if(!rethrowIfPossible){code+="var _hasError"+tapIndex+" = false;\n";code+='try {\n';}if(onResult){code+="var _result"+tapIndex+" = _fn"+tapIndex+"("+this.args({before:tap.context?'_context':undefined})+");\n";}else {code+="_fn"+tapIndex+"("+this.args({before:tap.context?'_context':undefined})+");\n";}if(!rethrowIfPossible){code+='} catch(_err) {\n';code+="_hasError"+tapIndex+" = true;\n";code+=onError('_err');code+='}\n';code+="if(!_hasError"+tapIndex+") {\n";}if(onResult){code+=onResult("_result"+tapIndex);}if(onDone){code+=onDone();}if(!rethrowIfPossible){code+='}\n';}break;case'async':var cbCode='';if(onResult)cbCode+="(function(_err"+tapIndex+", _result"+tapIndex+") {\n";else cbCode+="(function(_err"+tapIndex+") {\n";cbCode+="if(_err"+tapIndex+") {\n";cbCode+=onError("_err"+tapIndex);cbCode+='} else {\n';if(onResult){cbCode+=onResult("_result"+tapIndex);}if(onDone){cbCode+=onDone();}cbCode+='}\n';cbCode+='})';code+="_fn"+tapIndex+"("+this.args({before:tap.context?'_context':undefined,after:cbCode})+");\n";break;case'promise':code+="var _hasResult"+tapIndex+" = false;\n";code+="var _promise"+tapIndex+" = _fn"+tapIndex+"("+this.args({before:tap.context?'_context':undefined})+");\n";code+="if (!_promise"+tapIndex+" || !_promise"+tapIndex+".then)\n";code+=" throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise"+tapIndex+" + ')');\n";code+="_promise"+tapIndex+".then((function(_result"+tapIndex+") {\n";code+="_hasResult"+tapIndex+" = true;\n";if(onResult){code+=onResult("_result"+tapIndex);}if(onDone){code+=onDone();}code+="}), function(_err"+tapIndex+") {\n";code+="if(_hasResult"+tapIndex+") throw _err"+tapIndex+";\n";code+=onError("_err"+tapIndex);code+='});\n';break;}return code;};_proto.callTapsSeries=function callTapsSeries(_ref2){var _this2=this;var _onError=_ref2.onError,onResult=_ref2.onResult,resultReturns=_ref2.resultReturns,onDone=_ref2.onDone,doneReturns=_ref2.doneReturns,rethrowIfPossible=_ref2.rethrowIfPossible;if(this.options.taps.length===0)return onDone();var firstAsync=this.options.taps.findIndex(function(t){return t.type!=='sync';});var somethingReturns=resultReturns||doneReturns;var code='';var current=onDone;var unrollCounter=0;var _loop=function _loop(j){var i=j;var unroll=current!==onDone&&(_this2.options.taps[i].type!=='sync'||unrollCounter++>20);if(unroll){unrollCounter=0;code+="function _next"+i+"() {\n";code+=current();code+="}\n";current=function current(){return (somethingReturns?'return ':'')+"_next"+i+"();\n";};}var done=current;var doneBreak=function doneBreak(skipDone){if(skipDone)return '';return onDone();};var content=_this2.callTap(i,{onError:function onError(error){return _onError(i,error,done,doneBreak);},onResult:onResult&&function(result){return onResult(i,result,done,doneBreak);},onDone:!onResult&&done,rethrowIfPossible:rethrowIfPossible&&(firstAsync<0||i<firstAsync)});current=function current(){return content;};};for(var j=this.options.taps.length-1;j>=0;j--){_loop(j);}code+=current();return code;};_proto.callTapsLooping=function callTapsLooping(_ref3){var onError=_ref3.onError,onDone=_ref3.onDone,rethrowIfPossible=_ref3.rethrowIfPossible;if(this.options.taps.length===0)return onDone();var syncOnly=this.options.taps.every(function(t){return t.type==='sync';});var code='';if(!syncOnly){code+='var _looper = (function() {\n';code+='var _loopAsync = false;\n';}code+='var _loop;\n';code+='do {\n';code+='_loop = false;\n';for(var i=0;i<this.options.interceptors.length;i++){var interceptor=this.options.interceptors[i];if(interceptor.loop){code+=this.getInterceptor(i)+".loop("+this.args({before:interceptor.context?'_context':undefined})+");\n";}}code+=this.callTapsSeries({onError:onError,onResult:function onResult(i,result,next,doneBreak){var code='';code+="if("+result+" !== undefined) {\n";code+='_loop = true;\n';if(!syncOnly)code+='if(_loopAsync) _looper();\n';code+=doneBreak(true);code+="} else {\n";code+=next();code+="}\n";return code;},onDone:onDone&&function(){var code='';code+='if(!_loop) {\n';code+=onDone();code+='}\n';return code;},rethrowIfPossible:rethrowIfPossible&&syncOnly});code+='} while(_loop);\n';if(!syncOnly){code+='_loopAsync = true;\n';code+='});\n';code+='_looper();\n';}return code;};_proto.callTapsParallel=function callTapsParallel(_ref4){var _this3=this;var _onError2=_ref4.onError,onResult=_ref4.onResult,onDone=_ref4.onDone,rethrowIfPossible=_ref4.rethrowIfPossible,_ref4$onTap=_ref4.onTap,onTap=_ref4$onTap===void 0?function(i,run){return run();}:_ref4$onTap;if(this.options.taps.length<=1){return this.callTapsSeries({onError:_onError2,onResult:onResult,onDone:onDone,rethrowIfPossible:rethrowIfPossible});}var code='';code+='do {\n';code+="var _counter = "+this.options.taps.length+";\n";if(onDone){code+='var _done = (function() {\n';code+=onDone();code+='});\n';}var _loop2=function _loop2(i){var done=function done(){if(onDone)return 'if(--_counter === 0) _done();\n';else return '--_counter;';};var doneBreak=function doneBreak(skipDone){if(skipDone||!onDone)return '_counter = 0;\n';else return '_counter = 0;\n_done();\n';};code+='if(_counter <= 0) break;\n';code+=onTap(i,function(){return _this3.callTap(i,{onError:function onError(error){var code='';code+='if(_counter > 0) {\n';code+=_onError2(i,error,done,doneBreak);code+='}\n';return code;},onResult:onResult&&function(result){var code='';code+='if(_counter > 0) {\n';code+=onResult(i,result,done,doneBreak);code+='}\n';return code;},onDone:!onResult&&function(){return done();},rethrowIfPossible:rethrowIfPossible});},done,doneBreak);};for(var i=0;i<this.options.taps.length;i++){_loop2(i);}code+='} while(false);\n';return code;};_proto.args=function args(_temp){var _ref5=_temp===void 0?{}:_temp,before=_ref5.before,after=_ref5.after;var allArgs=this._args;if(before)allArgs=[before].concat(allArgs);if(after)allArgs=allArgs.concat(after);if(allArgs.length===0){return '';}else {return allArgs.join(', ');}};_proto.getTapFn=function getTapFn(idx){return "_x["+idx+"]";};_proto.getTap=function getTap(idx){return "_taps["+idx+"]";};_proto.getInterceptor=function getInterceptor(idx){return "_interceptors["+idx+"]";};return HookCodeFactory;}();var AsyncParallelHookCodeFactory=/*#__PURE__*/function(_HookCodeFactory){_inheritsLoose(AsyncParallelHookCodeFactory,_HookCodeFactory);function AsyncParallelHookCodeFactory(){return _HookCodeFactory.apply(this,arguments)||this;}var _proto=AsyncParallelHookCodeFactory.prototype;_proto.content=function content(_ref){var _onError=_ref.onError,onDone=_ref.onDone;return this.callTapsParallel({onError:function onError(i,err,done,doneBreak){return _onError(err)+doneBreak(true);},onDone:onDone});};return AsyncParallelHookCodeFactory;}(HookCodeFactory);var factory=new AsyncParallelHookCodeFactory();var COMPILE=function COMPILE(options){factory.setup(this,options);return factory.create(options);};var AsyncParallelHook=/*#__PURE__*/function(_Hook){_inheritsLoose(AsyncParallelHook,_Hook);function AsyncParallelHook(args,name){var _this;if(args===void 0){args=[];}if(name===void 0){name=undefined;}_this=_Hook.call(this,args,name)||this;_this.compile=COMPILE;_this._call=undefined;_this.call=undefined;return _this;}return AsyncParallelHook;}(Hook);// export function AsyncParallelHook(args = [], name = undefined) {
7743
+ // const hook = new Hook(args, name);
7744
+ // hook.constructor = AsyncParallelHook;
7745
+ // hook.compile = COMPILE;
7746
+ // hook._call = undefined;
7747
+ // hook.call = undefined;
7748
+ // return hook;
7749
+ // }
7750
+ // AsyncParallelHook.prototype = null;
7751
+ var AsyncSeriesWaterfallHookCodeFactory=/*#__PURE__*/function(_HookCodeFactory){_inheritsLoose(AsyncSeriesWaterfallHookCodeFactory,_HookCodeFactory);function AsyncSeriesWaterfallHookCodeFactory(){return _HookCodeFactory.apply(this,arguments)||this;}var _proto=AsyncSeriesWaterfallHookCodeFactory.prototype;_proto.content=function content(_ref){var _this=this;var _onError=_ref.onError,onResult=_ref.onResult,onDone=_ref.onDone;return this.callTapsSeries({onError:function onError(i,err,next,doneBreak){return _onError(err)+doneBreak(true);},onResult:function onResult(i,result,next){var code='';code+="if("+result+" !== undefined) {\n";code+=_this._args[0]+" = "+result+";\n";code+="}\n";code+=next();return code;},onDone:function onDone(){return onResult(_this._args[0]);}});};return AsyncSeriesWaterfallHookCodeFactory;}(HookCodeFactory);var factory$1=new AsyncSeriesWaterfallHookCodeFactory();var COMPILE$1=function COMPILE(options){factory$1.setup(this,options);return factory$1.create(options);};// export function AsyncSeriesWaterfallHook(args = [], name = undefined) {
7752
+ // if (args.length < 1) throw new Error('Waterfall hooks must have at least one argument');
7753
+ // const hook = new Hook(args, name);
7754
+ // hook.constructor = AsyncSeriesWaterfallHook;
7755
+ // hook.compile = COMPILE;
7756
+ // hook._call = undefined;
7757
+ // hook.call = undefined;
7758
+ // return hook;
7759
+ // }
7760
+ // AsyncSeriesWaterfallHook.prototype = null;
7761
+ var AsyncSeriesWaterfallHook=/*#__PURE__*/function(_Hook){_inheritsLoose(AsyncSeriesWaterfallHook,_Hook);function AsyncSeriesWaterfallHook(args,name){var _this2;if(args===void 0){args=[];}if(name===void 0){name=undefined;}_this2=_Hook.call(this,args,name)||this;_this2.compile=COMPILE$1;_this2._call=undefined;_this2.call=undefined;return _this2;}return AsyncSeriesWaterfallHook;}(Hook);var SyncHookCodeFactory=/*#__PURE__*/function(_HookCodeFactory){_inheritsLoose(SyncHookCodeFactory,_HookCodeFactory);function SyncHookCodeFactory(){return _HookCodeFactory.apply(this,arguments)||this;}var _proto=SyncHookCodeFactory.prototype;_proto.content=function content(_ref){var _onError=_ref.onError,onDone=_ref.onDone,rethrowIfPossible=_ref.rethrowIfPossible;return this.callTapsSeries({onError:function onError(i,err){return _onError(err);},onDone:onDone,rethrowIfPossible:rethrowIfPossible});};return SyncHookCodeFactory;}(HookCodeFactory);var factory$2=new SyncHookCodeFactory();var TAP_ASYNC=function TAP_ASYNC(){throw new Error('tapAsync is not supported on a SyncHook');};var TAP_PROMISE=function TAP_PROMISE(){throw new Error('tapPromise is not supported on a SyncHook');};var COMPILE$2=function COMPILE(options){factory$2.setup(this,options);return factory$2.create(options);};var SyncHook=/*#__PURE__*/function(_Hook){_inheritsLoose(SyncHook,_Hook);function SyncHook(args,name){var _this;if(args===void 0){args=[];}if(name===void 0){name=undefined;}_this=_Hook.call(this,args,name)||this;_this.tapAsync=TAP_ASYNC;_this.tapPromise=TAP_PROMISE;_this.compile=COMPILE$2;return _this;}return SyncHook;}(Hook);// export function SyncHook(args = [], name = undefined) {
7762
+ // const hook = new Hook(args, name);
7763
+ // hook.constructor = SyncHook;
7764
+ // hook.tapAsync = TAP_ASYNC;
7765
+ // hook.tapPromise = TAP_PROMISE;
7766
+ // hook.compile = COMPILE;
7767
+ // return hook;
7768
+ // }
7769
+ // SyncHook.prototype = null;
7770
+ var SyncWaterfallHookCodeFactory=/*#__PURE__*/function(_HookCodeFactory){_inheritsLoose(SyncWaterfallHookCodeFactory,_HookCodeFactory);function SyncWaterfallHookCodeFactory(){return _HookCodeFactory.apply(this,arguments)||this;}var _proto=SyncWaterfallHookCodeFactory.prototype;_proto.content=function content(_ref){var _this=this;var _onError=_ref.onError,onResult=_ref.onResult,resultReturns=_ref.resultReturns,rethrowIfPossible=_ref.rethrowIfPossible;return this.callTapsSeries({onError:function onError(i,err){return _onError(err);},onResult:function onResult(i,result,next){var code='';code+="if("+result+" !== undefined) {\n";code+=_this._args[0]+" = "+result+";\n";code+="}\n";code+=next();return code;},onDone:function onDone(){return onResult(_this._args[0]);},doneReturns:resultReturns,rethrowIfPossible:rethrowIfPossible});};return SyncWaterfallHookCodeFactory;}(HookCodeFactory);var factory$3=new SyncWaterfallHookCodeFactory();var TAP_ASYNC$1=function TAP_ASYNC(){throw new Error('tapAsync is not supported on a SyncWaterfallHook');};var TAP_PROMISE$1=function TAP_PROMISE(){throw new Error('tapPromise is not supported on a SyncWaterfallHook');};var COMPILE$3=function COMPILE(options){factory$3.setup(this,options);return factory$3.create(options);};var SyncWaterfallHook=/*#__PURE__*/function(_SyncHook){_inheritsLoose(SyncWaterfallHook,_SyncHook);function SyncWaterfallHook(args,name){var _this2;if(args===void 0){args=[];}if(name===void 0){name=undefined;}_this2=_SyncHook.call(this,args,name)||this;_this2.tapAsync=TAP_ASYNC$1;_this2.tapPromise=TAP_PROMISE$1;_this2.compile=COMPILE$3;return _this2;}return SyncWaterfallHook;}(SyncHook);// export function SyncWaterfallHook(args = [], name = undefined) {
7771
+ // if (args.length < 1) throw new Error('Waterfall hooks must have at least one argument');
7772
+ // const hook = new Hook(args, name);
7773
+ // hook.constructor = SyncWaterfallHook;
7774
+ // hook.tapAsync = TAP_ASYNC;
7775
+ // hook.tapPromise = TAP_PROMISE;
7776
+ // hook.compile = COMPILE;
7777
+ // return hook;
7778
+ // }
7779
+ // SyncWaterfallHook.prototype = null;
7780
+ var genericFontFamilies=['serif','sans-serif','monospace','cursive','fantasy','system-ui'];var stringRegExp=/([\"\'])[^\'\"]+\1/;function toFontString(attributes){var fontSize=attributes.fontSize,fontFamily=attributes.fontFamily,fontStyle=attributes.fontStyle,fontVariant=attributes.fontVariant,fontWeight=attributes.fontWeight;// build canvas api font setting from individual components. Convert a numeric this.fontSize to px
7781
+ // const fontSizeString: string = isNumber(fontSize) ? `${fontSize}px` : fontSize.toString();
7782
+ var fontSizeString=isNumber(fontSize)&&fontSize+"px"||'16px';// Clean-up fontFamily property by quoting each font name
7783
+ // this will support font names with spaces
7784
+ // @ts-ignore
7785
+ var fontFamilies=isString(fontFamily)?fontFamily.split(','):[fontFamily];for(var i=fontFamilies.length-1;i>=0;i--){// Trim any extra white-space
7786
+ var _fontFamily=fontFamilies[i].trim();// Check if font already contains strings
7787
+ if(!stringRegExp.test(_fontFamily)&&genericFontFamilies.indexOf(_fontFamily)<0){_fontFamily="\""+_fontFamily+"\"";}fontFamilies[i]=_fontFamily;}return fontStyle+" "+fontVariant+" "+fontWeight+" "+fontSizeString+" "+fontFamilies.join(',');}/**
7788
+ * Thanks for following contributor of codes
7789
+ * https://gist.github.com/1866474
7790
+ * http://paulirish.com/2011/requestanimationframe-for-smart-animating/
7791
+ * http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
7792
+ * https://github.com/Financial-Times/polyfill-library/blob/master/polyfills/requestAnimationFrame/polyfill.js
7793
+ **/var uId=1;var uniqueId=function uniqueId(){return uId++;};// We use `self` instead of `window` for `WebWorker` support.
7794
+ var root=typeof self==='object'&&self.self==self?self:// @ts-ignore
7795
+ typeof global==='object'&&global.global==global?// @ts-ignore
7796
+ global:{};var nowOffset=Date.now();// use performance api if exist, otherwise use Date.now.
7797
+ // Date.now polyfill required.
7798
+ var pnow=function pnow(){if(root.performance&&typeof root.performance.now==='function'){return root.performance.now();}// fallback
7799
+ return Date.now()-nowOffset;};var reservedCBs={};var lastTime=Date.now();var polyfillRaf=function polyfillRaf(callback){if(typeof callback!=='function'){throw new TypeError(callback+' is not a function');}var currentTime=Date.now();var gap=currentTime-lastTime;var delay=gap>16?0:16-gap;var id=uniqueId();reservedCBs[id]=callback;// keys(reservedCBs).length > 1 의미는 이미 setTimeout 이 걸려있는 경우.
7800
+ // 함께 callback 이 실행될 수 있게 reservedCBs 에만 추가해주고 return
7801
+ if(Object.keys(reservedCBs).length>1)return id;setTimeout(function(){lastTime=currentTime;var copied=reservedCBs;reservedCBs={};Object.keys(copied).forEach(function(key){return copied[key](pnow());});},delay);return id;};var polyfillCaf=function polyfillCaf(id){delete reservedCBs[id];};var vendorPrefixes=['','webkit','moz','ms','o'];var getRequestAnimationFrame=function getRequestAnimationFrame(vp){if(typeof vp!=='string')return polyfillRaf;if(vp==='')return root['requestAnimationFrame'];return root[vp+'RequestAnimationFrame'];};var getCancelAnimationFrame=function getCancelAnimationFrame(vp){if(typeof vp!=='string')return polyfillCaf;if(vp==='')return root['cancelAnimationFrame'];return root[vp+'CancelAnimationFrame']||root[vp+'CancelRequestAnimationFrame'];};var find=function find(arr,predicate){var i=0;while(arr[i]!==void 0){if(predicate(arr[i]))return arr[i];i=i+1;}};var vp=find(vendorPrefixes,function(vp){return !!getRequestAnimationFrame(vp);});var raf=getRequestAnimationFrame(vp);var caf=getCancelAnimationFrame(vp);root.requestAnimationFrame=raf;root.cancelAnimationFrame=caf;var regexLG=/^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;var regexRG=/^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i;var regexPR=/^p\s*\(\s*([axyn])\s*\)\s*(.*)/i;var regexColorStop=/[\d.]+:(#[^\s]+|[^\)]+\))/gi;function spaceColorStops(colorStops){var _colorStops$length;var length=colorStops.length;colorStops[length-1].length=(_colorStops$length=colorStops[length-1].length)!==null&&_colorStops$length!==void 0?_colorStops$length:{type:'%',value:'100'};if(length>1){var _colorStops$0$length;colorStops[0].length=(_colorStops$0$length=colorStops[0].length)!==null&&_colorStops$0$length!==void 0?_colorStops$0$length:{type:'%',value:'0'};}var previousIndex=0;var previousOffset=Number(colorStops[0].length.value);for(var i=1;i<length;i++){var _colorStops$i$length;// support '%' & 'px'
7802
+ var offset=(_colorStops$i$length=colorStops[i].length)===null||_colorStops$i$length===void 0?void 0:_colorStops$i$length.value;if(!isNil(offset)&&!isNil(previousOffset)){for(var j=1;j<i-previousIndex;j++){colorStops[previousIndex+j].length={type:'%',value:""+(previousOffset+(Number(offset)-previousOffset)*j/(i-previousIndex))};}previousIndex=i;previousOffset=Number(offset);}}}// The position of the gradient line's starting point.
7803
+ // different from CSS side(to top) @see https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient#values
7804
+ var SideOrCornerToDegMap={left:270-90,top:0-90,bottom:180-90,right:90-90,'left top':315-90,'top left':315-90,'left bottom':225-90,'bottom left':225-90,'right top':45-90,'top right':45-90,'right bottom':135-90,'bottom right':135-90};var angleToDeg=memoize(function(orientation){var angle;if(orientation.type==='angular'){angle=Number(orientation.value);}else {angle=SideOrCornerToDegMap[orientation.value]||0;}return getOrCreateUnitValue(angle,'deg');});var positonToCSSUnitValue=memoize(function(position){var cx=50;var cy=50;var unitX='%';var unitY='%';if((position===null||position===void 0?void 0:position.type)==='position'){var _position$value=position.value,x=_position$value.x,y=_position$value.y;if((x===null||x===void 0?void 0:x.type)==='position-keyword'){if(x.value==='left'){cx=0;}else if(x.value==='center'){cx=50;}else if(x.value==='right'){cx=100;}else if(x.value==='top'){cy=0;}else if(x.value==='bottom'){cy=100;}}if((y===null||y===void 0?void 0:y.type)==='position-keyword'){if(y.value==='left'){cx=0;}else if(y.value==='center'){cy=50;}else if(y.value==='right'){cx=100;}else if(y.value==='top'){cy=0;}else if(y.value==='bottom'){cy=100;}}if((x===null||x===void 0?void 0:x.type)==='px'||(x===null||x===void 0?void 0:x.type)==='%'||(x===null||x===void 0?void 0:x.type)==='em'){unitX=x===null||x===void 0?void 0:x.type;cx=Number(x.value);}if((y===null||y===void 0?void 0:y.type)==='px'||(y===null||y===void 0?void 0:y.type)==='%'||(y===null||y===void 0?void 0:y.type)==='em'){unitY=y===null||y===void 0?void 0:y.type;cy=Number(y.value);}}return {cx:getOrCreateUnitValue(cx,unitX),cy:getOrCreateUnitValue(cy,unitY)};});var parseGradient$1=memoize(function(colorStr){if(colorStr.indexOf('linear')>-1||colorStr.indexOf('radial')>-1){var ast=parseGradient(colorStr);return ast.map(function(_ref){var type=_ref.type,orientation=_ref.orientation,colorStops=_ref.colorStops;spaceColorStops(colorStops);var steps=colorStops.map(function(colorStop){// TODO: only support % for now, should calc percentage of axis length when using px/em
7805
+ return {offset:getOrCreateUnitValue(Number(colorStop.length.value),'%'),color:colorStopToString(colorStop)};});if(type==='linear-gradient'){return new CSSGradientValue(exports.GradientType.LinearGradient,{angle:orientation?angleToDeg(orientation):Odeg,steps:steps});}else if(type==='radial-gradient'){if(!orientation){orientation=[{type:'shape',value:'circle'}];}if(orientation[0].type==='shape'&&orientation[0].value==='circle'){var _positonToCSSUnitValu=positonToCSSUnitValue(orientation[0].at),cx=_positonToCSSUnitValu.cx,cy=_positonToCSSUnitValu.cy;var size;if(orientation[0].style){var _orientation$0$style=orientation[0].style,_type=_orientation$0$style.type,value=_orientation$0$style.value;if(_type==='extent-keyword'){size=getOrCreateKeyword(value);}else {size=getOrCreateUnitValue(value,_type);}}return new CSSGradientValue(exports.GradientType.RadialGradient,{cx:cx,cy:cy,size:size,steps:steps});}// TODO: support ellipse shape
7806
+ // TODO: repeating-linear-gradient & repeating-radial-gradient
7807
+ // } else if (type === 'repeating-linear-gradient') {
7808
+ // } else if (type === 'repeating-radial-gradient') {
7809
+ }});}// legacy format, should be deprecated later
7810
+ var type=colorStr[0];if(colorStr[1]==='('||colorStr[2]==='('){if(type==='l'){var arr=regexLG.exec(colorStr);if(arr){var _arr$2$match;var steps=((_arr$2$match=arr[2].match(regexColorStop))===null||_arr$2$match===void 0?void 0:_arr$2$match.map(function(stop){return stop.split(':');}))||[];return [new CSSGradientValue(exports.GradientType.LinearGradient,{angle:getOrCreateUnitValue(parseFloat(arr[1]),'deg'),steps:steps.map(function(_ref2){var offset=_ref2[0],color=_ref2[1];return {offset:getOrCreateUnitValue(Number(offset)*100,'%'),color:color};})})];}}else if(type==='r'){var parsedRadialGradient=parseRadialGradient(colorStr);if(parsedRadialGradient){if(isString(parsedRadialGradient)){colorStr=parsedRadialGradient;}else {return [new CSSGradientValue(exports.GradientType.RadialGradient,parsedRadialGradient)];}}}else if(type==='p'){return parsePattern(colorStr);}}});function parseRadialGradient(gradientStr){var arr=regexRG.exec(gradientStr);if(arr){var _arr$4$match;var steps=((_arr$4$match=arr[4].match(regexColorStop))===null||_arr$4$match===void 0?void 0:_arr$4$match.map(function(stop){return stop.split(':');}))||[];return {cx:getOrCreateUnitValue(50,'%'),cy:getOrCreateUnitValue(50,'%'),steps:steps.map(function(_ref3){var offset=_ref3[0],color=_ref3[1];return {offset:getOrCreateUnitValue(Number(offset)*100,'%'),color:color};})};}return null;}function parsePattern(patternStr){var arr=regexPR.exec(patternStr);if(arr){var repetition=arr[1];var src=arr[2];switch(repetition){case'a':repetition='repeat';break;case'x':repetition='repeat-x';break;case'y':repetition='repeat-y';break;case'n':repetition='no-repeat';break;default:repetition='no-repeat';}return {image:src,// @ts-ignore
7811
+ repetition:repetition};}return null;}function isCSSGradientValue(object){return !!object.type&&!!object.value;}function isPattern(object){return isObject(object)&&!!object.image;}function isCSSRGB(object){return isObject(object)&&!isNil(object.r)&&!isNil(object.g)&&!isNil(object.b);}/**
7812
+ * @see https://github.com/WebKit/WebKit/blob/main/Source/WebCore/css/parser/CSSParser.cpp#L97
7813
+ */var parseColor=memoize(function(colorStr){if(isPattern(colorStr)){return _extends({repetition:'repeat'},colorStr);}if(isNil(colorStr)){colorStr='';}if(colorStr==='transparent'){// transparent black
7814
+ return transparentColor;}else if(colorStr==='currentColor'){// @see https://github.com/adobe-webplatform/Snap.svg/issues/526
7815
+ colorStr='black';}// support CSS gradient syntax
7816
+ var g=parseGradient$1(colorStr);if(g){return g;}// constants
7817
+ var color$1=color(colorStr);var rgba=[0,0,0,0];if(color$1!==null){rgba[0]=color$1.r||0;rgba[1]=color$1.g||0;rgba[2]=color$1.b||0;rgba[3]=color$1.opacity;}// return new CSSRGB(...rgba);
7818
+ return getOrCreateRGBA.apply(void 0,rgba);});function mergeColors(left,right){// only support constant value, exclude gradient & pattern
7819
+ if(!isCSSRGB(left)||!isCSSRGB(right)){return;}return [[Number(left.r),Number(left.g),Number(left.b),Number(left.alpha)],[Number(right.r),Number(right.g),Number(right.b),Number(right.alpha)],function(color){var rgba=color.slice();if(rgba[3]){for(var i=0;i<3;i++){rgba[i]=Math.round(clamp(rgba[i],0,255));}}rgba[3]=clamp(rgba[3],0,1);return "rgba("+rgba.join(',')+")";}];}/**
7820
+ * Axis-Aligned Bounding Box
7821
+ * 为了便于后续 Frustum Culling,通过查找表定义 p-vertex 和 n-vertex
7822
+ * @see https://github.com/antvis/GWebGPUEngine/issues/3
7823
+ */var AABB=/*#__PURE__*/function(){AABB.isEmpty=function isEmpty(aabb){return !aabb||aabb.halfExtents[0]===0&&aabb.halfExtents[1]===0&&aabb.halfExtents[2]===0;};// center: vec3 = vec3.create();
7824
+ // halfExtents: vec3 = vec3.create();
7825
+ // min: vec3 = vec3.create();
7826
+ // max: vec3 = vec3.create();
7827
+ function AABB(center,halfExtents){if(center===void 0){center=[0,0,0];}if(halfExtents===void 0){halfExtents=[0,0,0];}this.center=[0,0,0];this.halfExtents=[0,0,0];this.min=[0,0,0];this.max=[0,0,0];this.update(center,halfExtents);}var _proto=AABB.prototype;_proto.update=function update(center,halfExtents){copyVec3(this.center,center);copyVec3(this.halfExtents,halfExtents);subVec3(this.min,this.center,this.halfExtents);addVec3(this.max,this.center,this.halfExtents);// vec3.copy(this.center, center);
7828
+ // vec3.copy(this.halfExtents, halfExtents);
7829
+ // vec3.sub(this.min, this.center, this.halfExtents);
7830
+ // vec3.add(this.max, this.center, this.halfExtents);
7831
+ };_proto.setMinMax=function setMinMax(min,max){// vec3.add(this.center, max, min);
7832
+ // vec3.scale(this.center, this.center, 0.5);
7833
+ // vec3.sub(this.halfExtents, max, min);
7834
+ // vec3.scale(this.halfExtents, this.halfExtents, 0.5);
7835
+ // vec3.copy(this.min, min);
7836
+ // vec3.copy(this.max, max);
7837
+ addVec3(this.center,max,min);scaleVec3(this.center,this.center,0.5);subVec3(this.halfExtents,max,min);scaleVec3(this.halfExtents,this.halfExtents,0.5);copyVec3(this.min,min);copyVec3(this.max,max);};_proto.getMin=function getMin(){return this.min;};_proto.getMax=function getMax(){return this.max;};_proto.add=function add(aabb){if(AABB.isEmpty(aabb)){return;}if(AABB.isEmpty(this)){this.setMinMax(aabb.getMin(),aabb.getMax());return;}var tc=this.center;var tcx=tc[0];var tcy=tc[1];var tcz=tc[2];var th=this.halfExtents;var thx=th[0];var thy=th[1];var thz=th[2];var tminx=tcx-thx;var tmaxx=tcx+thx;var tminy=tcy-thy;var tmaxy=tcy+thy;var tminz=tcz-thz;var tmaxz=tcz+thz;var oc=aabb.center;var ocx=oc[0];var ocy=oc[1];var ocz=oc[2];var oh=aabb.halfExtents;var ohx=oh[0];var ohy=oh[1];var ohz=oh[2];var ominx=ocx-ohx;var omaxx=ocx+ohx;var ominy=ocy-ohy;var omaxy=ocy+ohy;var ominz=ocz-ohz;var omaxz=ocz+ohz;if(ominx<tminx){tminx=ominx;}if(omaxx>tmaxx){tmaxx=omaxx;}if(ominy<tminy){tminy=ominy;}if(omaxy>tmaxy){tmaxy=omaxy;}if(ominz<tminz){tminz=ominz;}if(omaxz>tmaxz){tmaxz=omaxz;}tc[0]=(tminx+tmaxx)*0.5;tc[1]=(tminy+tmaxy)*0.5;tc[2]=(tminz+tmaxz)*0.5;th[0]=(tmaxx-tminx)*0.5;th[1]=(tmaxy-tminy)*0.5;th[2]=(tmaxz-tminz)*0.5;this.min[0]=tminx;this.min[1]=tminy;this.min[2]=tminz;this.max[0]=tmaxx;this.max[1]=tmaxy;this.max[2]=tmaxz;};_proto.setFromTransformedAABB=function setFromTransformedAABB(aabb,m){var bc=this.center;var br=this.halfExtents;var ac=aabb.center;var ar=aabb.halfExtents;var mx0=m[0];var mx1=m[4];var mx2=m[8];var my0=m[1];var my1=m[5];var my2=m[9];var mz0=m[2];var mz1=m[6];var mz2=m[10];var mx0a=Math.abs(mx0);var mx1a=Math.abs(mx1);var mx2a=Math.abs(mx2);var my0a=Math.abs(my0);var my1a=Math.abs(my1);var my2a=Math.abs(my2);var mz0a=Math.abs(mz0);var mz1a=Math.abs(mz1);var mz2a=Math.abs(mz2);bc[0]=m[12]+mx0*ac[0]+mx1*ac[1]+mx2*ac[2];bc[1]=m[13]+my0*ac[0]+my1*ac[1]+my2*ac[2];bc[2]=m[14]+mz0*ac[0]+mz1*ac[1]+mz2*ac[2];// vec3.set(
7838
+ // bc,
7839
+ // m[12] + mx0 * ac[0] + mx1 * ac[1] + mx2 * ac[2],
7840
+ // m[13] + my0 * ac[0] + my1 * ac[1] + my2 * ac[2],
7841
+ // m[14] + mz0 * ac[0] + mz1 * ac[1] + mz2 * ac[2],
7842
+ // );
7843
+ br[0]=mx0a*ar[0]+mx1a*ar[1]+mx2a*ar[2];br[1]=my0a*ar[0]+my1a*ar[1]+my2a*ar[2];br[2]=mz0a*ar[0]+mz1a*ar[1]+mz2a*ar[2];// vec3.set(
7844
+ // br,
7845
+ // mx0a * ar[0] + mx1a * ar[1] + mx2a * ar[2],
7846
+ // my0a * ar[0] + my1a * ar[1] + my2a * ar[2],
7847
+ // mz0a * ar[0] + mz1a * ar[1] + mz2a * ar[2],
7848
+ // );
7849
+ // this.min = vec3.sub(this.min, bc, br);
7850
+ // this.max = vec3.add(this.max, bc, br);
7851
+ subVec3(this.min,bc,br);addVec3(this.max,bc,br);};_proto.intersects=function intersects(aabb){var aMax=this.getMax();var aMin=this.getMin();var bMax=aabb.getMax();var bMin=aabb.getMin();return aMin[0]<=bMax[0]&&aMax[0]>=bMin[0]&&aMin[1]<=bMax[1]&&aMax[1]>=bMin[1]&&aMin[2]<=bMax[2]&&aMax[2]>=bMin[2];};_proto.intersection=function intersection(aabb){if(!this.intersects(aabb)){return null;}var intersection=new AABB();// const min = vec3.max(vec3.create(), this.getMin(), aabb.getMin());
7852
+ // const max = vec3.min(vec3.create(), this.getMax(), aabb.getMax());
7853
+ var min=maxVec3([0,0,0],this.getMin(),aabb.getMin());var max=minVec3([0,0,0],this.getMax(),aabb.getMax());intersection.setMinMax(min,max);return intersection;}// containsPoint(point: vec3) {
7854
+ // const min = this.getMin();
7855
+ // const max = this.getMax();
7856
+ // return !(
7857
+ // point[0] < min[0] ||
7858
+ // point[0] > max[0] ||
7859
+ // point[1] < min[1] ||
7860
+ // point[1] > max[1] ||
7861
+ // point[2] < min[2] ||
7862
+ // point[2] > max[2]
7863
+ // );
7864
+ // }
7865
+ /**
7866
+ * get n-vertex
7867
+ * @param plane plane of CullingVolume
7868
+ */;_proto.getNegativeFarPoint=function getNegativeFarPoint(plane){if(plane.pnVertexFlag===0x111){return copyVec3([0,0,0],this.min);// return vec3.copy(vec3.create(), this.min);
7869
+ }else if(plane.pnVertexFlag===0x110){return [this.min[0],this.min[1],this.max[2]];// return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
7870
+ }else if(plane.pnVertexFlag===0x101){return [this.min[0],this.max[1],this.min[2]];// return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
7871
+ }else if(plane.pnVertexFlag===0x100){return [this.min[0],this.max[1],this.max[2]];// return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
7872
+ }else if(plane.pnVertexFlag===0x011){return [this.max[0],this.min[1],this.min[2]];// return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
7873
+ }else if(plane.pnVertexFlag===0x010){return [this.max[0],this.min[1],this.max[2]];// return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
7874
+ }else if(plane.pnVertexFlag===0x001){return [this.max[0],this.max[1],this.min[2]];// return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
7875
+ }else {return [this.max[0],this.max[1],this.max[2]];// return vec3.fromValues(this.max[0], this.max[1], this.max[2]);
7876
+ }}/**
7877
+ * get p-vertex
7878
+ * @param plane plane of CullingVolume
7879
+ */;_proto.getPositiveFarPoint=function getPositiveFarPoint(plane){if(plane.pnVertexFlag===0x111){return copyVec3([0,0,0],this.max);// return vec3.copy(vec3.create(), this.max);
7880
+ }else if(plane.pnVertexFlag===0x110){return [this.max[0],this.max[1],this.min[2]];// return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
7881
+ }else if(plane.pnVertexFlag===0x101){return [this.max[0],this.min[1],this.max[2]];// return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
7882
+ }else if(plane.pnVertexFlag===0x100){return [this.max[0],this.min[1],this.min[2]];// return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
7883
+ }else if(plane.pnVertexFlag===0x011){return [this.min[0],this.max[1],this.max[2]];// return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
7884
+ }else if(plane.pnVertexFlag===0x010){return [this.min[0],this.max[1],this.min[2]];// return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
7885
+ }else if(plane.pnVertexFlag===0x001){return [this.min[0],this.min[1],this.max[2]];// return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
7886
+ }else {return [this.min[0],this.min[1],this.min[2]];// return vec3.fromValues(this.min[0], this.min[1], this.min[2]);
7887
+ }};return AABB;}();var Plane=/*#__PURE__*/function(){/**
7888
+ * lookup table for p-vertex & n-vertex when doing frustum culling
7889
+ */function Plane(distance,normal){this.distance=void 0;this.normal=void 0;this.pnVertexFlag=void 0;this.distance=distance||0;this.normal=normal||fromValues$2(0,1,0);this.updatePNVertexFlag();}var _proto=Plane.prototype;_proto.updatePNVertexFlag=function updatePNVertexFlag(){this.pnVertexFlag=(Number(this.normal[0]>=0)<<8)+(Number(this.normal[1]>=0)<<4)+Number(this.normal[2]>=0);};_proto.distanceToPoint=function distanceToPoint(point){return dot(point,this.normal)-this.distance;};_proto.normalize=function normalize(){var invLen=1/len(this.normal);scale$1(this.normal,this.normal,invLen);this.distance*=invLen;};_proto.intersectsLine=function intersectsLine(start,end,point){var d0=this.distanceToPoint(start);var d1=this.distanceToPoint(end);var t=d0/(d0-d1);var intersects=t>=0&&t<=1;if(intersects&&point){lerp(point,start,end,t);}return intersects;};return Plane;}();(function(Mask){Mask[Mask["OUTSIDE"]=4294967295]="OUTSIDE";Mask[Mask["INSIDE"]=0]="INSIDE";Mask[Mask["INDETERMINATE"]=2147483647]="INDETERMINATE";})(exports.Mask||(exports.Mask={}));var Frustum=/*#__PURE__*/function(){function Frustum(planes){this.planes=[];if(planes){this.planes=planes;}else {for(var i=0;i<6;i++){this.planes.push(new Plane());}}}/**
7890
+ * extract 6 planes from projectionMatrix
7891
+ * @see http://www8.cs.umu.se/kurser/5DV051/HT12/lab/plane_extraction.pdf
7892
+ */var _proto=Frustum.prototype;_proto.extractFromVPMatrix=function extractFromVPMatrix(projectionMatrix){// @ts-ignore
7893
+ var m0=projectionMatrix[0],m1=projectionMatrix[1],m2=projectionMatrix[2],m3=projectionMatrix[3],m4=projectionMatrix[4],m5=projectionMatrix[5],m6=projectionMatrix[6],m7=projectionMatrix[7],m8=projectionMatrix[8],m9=projectionMatrix[9],m10=projectionMatrix[10],m11=projectionMatrix[11],m12=projectionMatrix[12],m13=projectionMatrix[13],m14=projectionMatrix[14],m15=projectionMatrix[15];// right
7894
+ set$1(this.planes[0].normal,m3-m0,m7-m4,m11-m8);this.planes[0].distance=m15-m12;// left
7895
+ set$1(this.planes[1].normal,m3+m0,m7+m4,m11+m8);this.planes[1].distance=m15+m12;// bottom
7896
+ set$1(this.planes[2].normal,m3+m1,m7+m5,m11+m9);this.planes[2].distance=m15+m13;// top
7897
+ set$1(this.planes[3].normal,m3-m1,m7-m5,m11-m9);this.planes[3].distance=m15-m13;// far
7898
+ set$1(this.planes[4].normal,m3-m2,m7-m6,m11-m10);this.planes[4].distance=m15-m14;// near
7899
+ set$1(this.planes[5].normal,m3+m2,m7+m6,m11+m10);this.planes[5].distance=m15+m14;this.planes.forEach(function(plane){plane.normalize();plane.updatePNVertexFlag();});};return Frustum;}();var Point=/*#__PURE__*/function(){function Point(x,y){if(x===void 0){x=0;}if(y===void 0){y=0;}this.x=0;this.y=0;this.x=x;this.y=y;}var _proto=Point.prototype;_proto.clone=function clone(){return new Point(this.x,this.y);};_proto.copyFrom=function copyFrom(p){this.x=p.x;this.y=p.y;};return Point;}();var Rectangle=/*#__PURE__*/function(){function Rectangle(x,y,width,height){this.x=void 0;this.y=void 0;this.width=void 0;this.height=void 0;this.left=void 0;this.right=void 0;this.top=void 0;this.bottom=void 0;this.x=x;this.y=y;this.width=width;this.height=height;this.left=x;this.right=x+width;this.top=y;this.bottom=y+height;}var _proto=Rectangle.prototype;_proto.toJSON=function toJSON(){};return Rectangle;}();function parseDimension(unitRegExp,string){if(isNil(string)){return getOrCreateUnitValue(0,'px');}string=(""+string).trim().toLowerCase();if(isFinite(Number(string))){if('px'.search(unitRegExp)>=0){return getOrCreateUnitValue(Number(string),'px');}else if('deg'.search(unitRegExp)>=0){return getOrCreateUnitValue(Number(string),'deg');}}var matchedUnits=[];string=string.replace(unitRegExp,function(match){matchedUnits.push(match);return 'U'+match;});var taggedUnitRegExp='U('+unitRegExp.source+')';return matchedUnits.map(function(unit){return getOrCreateUnitValue(Number(string.replace(new RegExp('U'+unit,'g'),'').replace(new RegExp(taggedUnitRegExp,'g'),'*0')),unit);})[0];}/**
7900
+ * <length>
7901
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length
7902
+ * length with only absolute unit, eg. 1px
7903
+ */var parseLength=memoize(function(css){return parseDimension(new RegExp('px','g'),css);});/**
7904
+ * <percentage>
7905
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/percentage
7906
+ */var parserPercentage=memoize(function(css){return parseDimension(new RegExp('%','g'),css);});/**
7907
+ * length with absolute or relative unit,
7908
+ * eg. 1px, 0.7em, 50%, calc(100% - 200px);
7909
+ *
7910
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length-percentage
7911
+ */ // export const parseLengthOrPercentage = memoize((css: string): CSSUnitValue => {
7912
+ // if (isNumber(css) || isFinite(Number(css))) {
7913
+ // return getOrCreateUnitValue(Number(css), 'px');
7914
+ // }
7915
+ // return parseDimension(new RegExp('px|%|em|rem', 'g'), css) as CSSUnitValue;
7916
+ // });
7917
+ var parseLengthOrPercentage=function parseLengthOrPercentage(css){if(isNumber(css)||isFinite(Number(css))){return getOrCreateUnitValue(Number(css),'px');// return Number(css);
7918
+ }return parseDimension(new RegExp('px|%|em|rem','g'),css);};var parseAngle=memoize(function(css){return parseDimension(new RegExp('deg|rad|grad|turn','g'),css);});/**
7919
+ * merge CSSUnitValue
7920
+ *
7921
+ * @example
7922
+ * 10px + 20px = 30px
7923
+ * 10deg + 10rad
7924
+ * 10% + 20% = 30%
7925
+ */function mergeDimensions(left,right,target,nonNegative,index){if(index===void 0){index=0;}var unit='';var leftValue=left.value||0;var rightValue=right.value||0;var canonicalUnit=toCanonicalUnit(left.unit);var leftCanonicalUnitValue=left.convertTo(canonicalUnit);var rightCanonicalUnitValue=right.convertTo(canonicalUnit);if(leftCanonicalUnitValue&&rightCanonicalUnitValue){leftValue=leftCanonicalUnitValue.value;rightValue=rightCanonicalUnitValue.value;unit=unitTypeToString(left.unit);}else {// format '%' to 'px'
7926
+ if(CSSUnitValue.isLength(left.unit)||CSSUnitValue.isLength(right.unit)){leftValue=convertPercentUnit(left,index,target);rightValue=convertPercentUnit(right,index,target);unit='px';}}// // format 'rad' 'turn' to 'deg'
7927
+ // if (CSSUnitValue.isAngle(left.unit) || CSSUnitValue.isAngle(right.unit)) {
7928
+ // leftValue = convertAngleUnit(left);
7929
+ // rightValue = convertAngleUnit(right);
7930
+ // unit = 'deg';
7931
+ // }
7932
+ return [leftValue,rightValue,function(value){if(nonNegative){value=Math.max(value,0);}return value+unit;}];}function convertAngleUnit(value){var deg=0;if(value.unit===exports.UnitType.kDegrees){deg=value.value;}else if(value.unit===exports.UnitType.kRadians){deg=rad2deg(Number(value.value));}else if(value.unit===exports.UnitType.kTurns){deg=turn2deg(Number(value.value));}return deg;}function parseDimensionArrayFormat(string,size){var parsed;if(isString(string)){parsed=string.split(' ').map(function(segment){return Number(segment);});}else if(isNumber(string)){parsed=[string];}else {// [1, '2px', 3]
7933
+ parsed=string.map(function(segment){return Number(segment);});}if(size===2){if(parsed.length===1){return [parsed[0],parsed[0]];}else {return [parsed[0],parsed[1]];}}else {if(parsed.length===1){return [parsed[0],parsed[0],parsed[0],parsed[0]];}else if(parsed.length===2){return [parsed[0],parsed[1],parsed[0],parsed[1]];}else if(parsed.length===3){return [parsed[0],parsed[1],parsed[2],parsed[1]];}else {return [parsed[0],parsed[1],parsed[2],parsed[3]];}}}function parseDimensionArray(string){if(isString(string)){// "1px 2px 3px"
7934
+ return string.split(' ').map(function(segment){return parseLengthOrPercentage(segment);});}else {// [1, '2px', 3]
7935
+ return string.map(function(segment){return parseLengthOrPercentage(segment.toString());});}}// export function mergeDimensionList(
7936
+ // left: CSSUnitValue[],
7937
+ // right: CSSUnitValue[],
7938
+ // target: IElement | null,
7939
+ // ): [number[], number[], (list: number[]) => string] | undefined {
7940
+ // if (left.length !== right.length) {
7941
+ // return;
7942
+ // }
7943
+ // const unit = left[0].unit;
7944
+ // return [
7945
+ // left.map((l) => l.value),
7946
+ // right.map((l) => l.value),
7947
+ // (values: number[]) => {
7948
+ // return values.map((n) => new CSSUnitValue(n, unit)).join(' ');
7949
+ // },
7950
+ // ];
7951
+ // }
7952
+ function convertPercentUnit(valueWithUnit,vec3Index,target){if(valueWithUnit.unit===exports.UnitType.kPixels){return Number(valueWithUnit.value);}else if(valueWithUnit.unit===exports.UnitType.kPercentage&&target){var bounds=target.nodeName===exports.Shape.GROUP?target.getLocalBounds():target.getGeometryBounds();var size=0;if(!AABB.isEmpty(bounds)){size=bounds.halfExtents[vec3Index]*2;}return Number(valueWithUnit.value)/100*size;}return 0;}var parseParam=function parseParam(css){return parseDimension(/deg|rad|grad|turn|px|%/g,css);};var supportedFilters=['blur','brightness','drop-shadow','contrast','grayscale','sepia','saturate','hue-rotate','invert'];function parseFilter(filterStr){if(filterStr===void 0){filterStr='';}filterStr=filterStr.toLowerCase().trim();if(filterStr==='none'){return [];}var filterRegExp=/\s*([\w-]+)\(([^)]*)\)/g;var result=[];var match;var prevLastIndex=0;while(match=filterRegExp.exec(filterStr)){if(match.index!==prevLastIndex){return [];}prevLastIndex=match.index+match[0].length;if(supportedFilters.indexOf(match[1])>-1){result.push({name:match[1],params:match[2].split(' ').map(function(p){return parseParam(p)||parseColor(p);})});}if(filterRegExp.lastIndex===filterStr.length){return result;}}return [];}function numberToString(x){// scale(0.00000001) -> scale(0)
7953
+ // return x.toFixed(6).replace(/0+$/, '').replace(/\.$/, '');
7954
+ return x.toString();}/**
7955
+ * parse string or number to CSSUnitValue(numeric)
7956
+ *
7957
+ * eg.
7612
7958
  * * 0 -> CSSUnitValue(0)
7613
7959
  * * '2' -> CSSUnitValue(2)
7614
7960
  */var parseNumber=memoize(function(string){if(typeof string==='number'){return getOrCreateUnitValue(string);}if(/^\s*[-+]?(\d*\.)?\d+\s*$/.test(string)){return getOrCreateUnitValue(Number(string));}else {return getOrCreateUnitValue(0);}});/**
@@ -7683,15 +8029,15 @@
7683
8029
  */var parseTransformOrigin=memoize(function(value){if(isString(value)){if(value==='text-anchor'){return [getOrCreateUnitValue(0,'px'),getOrCreateUnitValue(0,'px')];}var values=value.split(' ');if(values.length===1){if(values[0]==='top'||values[0]==='bottom'){// 'top' -> 'center top'
7684
8030
  values[1]=values[0];values[0]='center';}else {// '50px' -> '50px center'
7685
8031
  values[1]='center';}}if(values.length!==2){return null;}// eg. center bottom
7686
- return [parseLengthOrPercentage(convertKeyword2Percent(values[0])),parseLengthOrPercentage(convertKeyword2Percent(values[1]))];}else {return [getOrCreateUnitValue(value[0]||0,'px'),getOrCreateUnitValue(value[1]||0,'px')];}});function convertKeyword2Percent(keyword){if(keyword==='center'){return '50%';}else if(keyword==='left'||keyword==='top'){return '0';}else if(keyword==='right'||keyword==='bottom'){return '100%';}return keyword;}var CSSPropertyAngle=/*#__PURE__*/function(){function CSSPropertyAngle(){this.parser=parseAngle;this.mixer=mergeNumbers;}var _proto=CSSPropertyAngle.prototype;_proto.calculator=function calculator(name,oldParsed,parsed,object){return convertAngleUnit(parsed);};return CSSPropertyAngle;}();/**
8032
+ return [parseLengthOrPercentage(convertKeyword2Percent(values[0])),parseLengthOrPercentage(convertKeyword2Percent(values[1]))];}else {return [getOrCreateUnitValue(value[0]||0,'px'),getOrCreateUnitValue(value[1]||0,'px')];}});function convertKeyword2Percent(keyword){if(keyword==='center'){return '50%';}else if(keyword==='left'||keyword==='top'){return '0';}else if(keyword==='right'||keyword==='bottom'){return '100%';}return keyword;}var CSSPropertyAngle=/*#__PURE__*/function(){function CSSPropertyAngle(){this.parser=parseAngle;this.parserWithCSSDisabled=null;this.mixer=mergeNumbers;}var _proto=CSSPropertyAngle.prototype;_proto.calculator=function calculator(name,oldParsed,parsed,object){return convertAngleUnit(parsed);};return CSSPropertyAngle;}();/**
7687
8033
  * clipPath / textPath / offsetPath
7688
8034
  */var CSSPropertyClipPath=/*#__PURE__*/function(){function CSSPropertyClipPath(){}var _proto=CSSPropertyClipPath.prototype;_proto.calculator=function calculator(name,oldPath,newPath,object){// unset
7689
8035
  if(newPath instanceof CSSKeywordValue){newPath=null;}runtime.sceneGraphService.updateDisplayObjectDependency(name,oldPath,newPath,object);if(name==='clipPath'){// should affect children
7690
- object.forEach(function(leaf){if(leaf.childNodes.length===0){runtime.sceneGraphService.dirtifyToRoot(leaf);}});}return newPath;};return CSSPropertyClipPath;}();var CSSPropertyColor=/*#__PURE__*/function(){function CSSPropertyColor(){this.parser=parseColor;this.mixer=mergeColors;}var _proto=CSSPropertyColor.prototype;_proto.calculator=function calculator(name,oldParsed,parsed,object){if(parsed instanceof CSSKeywordValue){// 'unset' 'none'
8036
+ object.forEach(function(leaf){if(leaf.childNodes.length===0){runtime.sceneGraphService.dirtifyToRoot(leaf);}});}return newPath;};return CSSPropertyClipPath;}();var CSSPropertyColor=/*#__PURE__*/function(){function CSSPropertyColor(){this.parser=parseColor;this.parserWithCSSDisabled=parseColor;this.mixer=mergeColors;}var _proto=CSSPropertyColor.prototype;_proto.calculator=function calculator(name,oldParsed,parsed,object){if(parsed instanceof CSSKeywordValue){// 'unset' 'none'
7691
8037
  return parsed.value==='none'?noneColor:transparentColor;}return parsed;};return CSSPropertyColor;}();var CSSPropertyFilter=/*#__PURE__*/function(){function CSSPropertyFilter(){this.parser=parseFilter;}var _proto=CSSPropertyFilter.prototype;_proto.calculator=function calculator(name,oldParsed,parsed){// unset or none
7692
8038
  if(parsed instanceof CSSKeywordValue){return [];}return parsed;};return CSSPropertyFilter;}();function getFontSize(object){var fontSize=object.parsedStyle.fontSize;return isNil(fontSize)?null:fontSize;}/**
7693
8039
  * <length> & <percentage>
7694
- */var CSSPropertyLengthOrPercentage=/*#__PURE__*/function(){function CSSPropertyLengthOrPercentage(){this.parser=parseLengthOrPercentage;this.mixer=mergeNumbers;}var _proto=CSSPropertyLengthOrPercentage.prototype;/**
8040
+ */var CSSPropertyLengthOrPercentage=/*#__PURE__*/function(){function CSSPropertyLengthOrPercentage(){this.parser=parseLengthOrPercentage;this.parserWithCSSDisabled=null;this.mixer=mergeNumbers;}var _proto=CSSPropertyLengthOrPercentage.prototype;/**
7695
8041
  * according to parent's bounds
7696
8042
  *
7697
8043
  * @example
@@ -7723,15 +8069,15 @@
7723
8069
  if(needResetLocalPosition&&attributes.indexOf('transform')===-1){// account for current transform if needed
7724
8070
  var transform=object.parsedStyle.transform;if(transform&&transform.length){parsedTransformToMat4(transform,object);}else {var _object$getLocalPosit=object.getLocalPosition(),ox=_object$getLocalPosit[0],oy=_object$getLocalPosit[1],oz=_object$getLocalPosit[2];object.setLocalPosition(isNil(x)?ox:x,isNil(y)?oy:y,isNil(z)?oz:z);}}};return CSSPropertyLocalPosition;}(CSSPropertyLengthOrPercentage);var CSSPropertyMarker=/*#__PURE__*/function(){function CSSPropertyMarker(){}var _proto=CSSPropertyMarker.prototype;_proto.calculator=function calculator(name,oldMarker,newMarker,object){var _newMarker;// unset
7725
8071
  if(newMarker instanceof CSSKeywordValue){newMarker=null;}var cloned=(_newMarker=newMarker)===null||_newMarker===void 0?void 0:_newMarker.cloneNode(true);if(cloned){// FIXME: SVG should not inherit parent's style, add a flag here
7726
- cloned.style.isMarker=true;}return cloned;};return CSSPropertyMarker;}();var CSSPropertyNumber=/*#__PURE__*/function(){function CSSPropertyNumber(){this.mixer=mergeNumbers;this.parser=parseNumber;}var _proto=CSSPropertyNumber.prototype;_proto.calculator=function calculator(name,oldParsed,computed){return computed.value;};return CSSPropertyNumber;}();var CSSPropertyOffsetDistance=/*#__PURE__*/function(){function CSSPropertyOffsetDistance(){this.parser=parseNumber;this.mixer=clampedMergeNumbers(0,1);}var _proto=CSSPropertyOffsetDistance.prototype;_proto.calculator=function calculator(name,oldParsed,computed){return computed.value;};_proto.postProcessor=function postProcessor(object){var _object$parsedStyle=object.parsedStyle,offsetPath=_object$parsedStyle.offsetPath,offsetDistance=_object$parsedStyle.offsetDistance;if(!offsetPath){return;}var nodeName=offsetPath.nodeName;if(nodeName===exports.Shape.LINE||nodeName===exports.Shape.PATH||nodeName===exports.Shape.POLYLINE){// set position in world space
8072
+ cloned.style.isMarker=true;}return cloned;};return CSSPropertyMarker;}();var CSSPropertyNumber=/*#__PURE__*/function(){function CSSPropertyNumber(){this.mixer=mergeNumbers;this.parser=parseNumber;this.parserWithCSSDisabled=null;}var _proto=CSSPropertyNumber.prototype;_proto.calculator=function calculator(name,oldParsed,computed){return computed.value;};return CSSPropertyNumber;}();var CSSPropertyOffsetDistance=/*#__PURE__*/function(){function CSSPropertyOffsetDistance(){this.parser=parseNumber;this.parserWithCSSDisabled=null;this.mixer=clampedMergeNumbers(0,1);}var _proto=CSSPropertyOffsetDistance.prototype;_proto.calculator=function calculator(name,oldParsed,computed){return computed.value;};_proto.postProcessor=function postProcessor(object){var _object$parsedStyle=object.parsedStyle,offsetPath=_object$parsedStyle.offsetPath,offsetDistance=_object$parsedStyle.offsetDistance;if(!offsetPath){return;}var nodeName=offsetPath.nodeName;if(nodeName===exports.Shape.LINE||nodeName===exports.Shape.PATH||nodeName===exports.Shape.POLYLINE){// set position in world space
7727
8073
  var point=offsetPath.getPoint(offsetDistance);if(point){object.parsedStyle.defX=point.x;object.parsedStyle.defY=point.y;object.setLocalPosition(point.x,point.y);}}};return CSSPropertyOffsetDistance;}();/**
7728
8074
  * opacity
7729
- */var CSSPropertyOpacity=/*#__PURE__*/function(){function CSSPropertyOpacity(){this.parser=parseNumber;this.mixer=clampedMergeNumbers(0,1);}var _proto=CSSPropertyOpacity.prototype;_proto.calculator=function calculator(name,oldParsed,computed){return computed.value;};return CSSPropertyOpacity;}();var CSSPropertyPath=/*#__PURE__*/function(){function CSSPropertyPath(){this.parser=parsePath;this.mixer=mergePaths;}var _proto=CSSPropertyPath.prototype;_proto.calculator=function calculator(name,oldParsed,parsed){// unset
8075
+ */var CSSPropertyOpacity=/*#__PURE__*/function(){function CSSPropertyOpacity(){this.parser=parseNumber;this.parserWithCSSDisabled=null;this.mixer=clampedMergeNumbers(0,1);}var _proto=CSSPropertyOpacity.prototype;_proto.calculator=function calculator(name,oldParsed,computed){return computed.value;};return CSSPropertyOpacity;}();var CSSPropertyPath=/*#__PURE__*/function(){function CSSPropertyPath(){this.parser=parsePath;this.parserWithCSSDisabled=parsePath;this.mixer=mergePaths;}var _proto=CSSPropertyPath.prototype;_proto.calculator=function calculator(name,oldParsed,parsed){// unset
7730
8076
  if(parsed instanceof CSSKeywordValue&&parsed.value==='unset'){return {absolutePath:[],hasArc:false,segments:[],polygons:[],polylines:[],curve:null,totalLength:0,rect:new Rectangle(0,0,0,0)};}return parsed;};/**
7731
8077
  * update local position
7732
- */_proto.postProcessor=function postProcessor(object){if(object.nodeName===exports.Shape.PATH){var _object$parsedStyle=object.parsedStyle,_object$parsedStyle$d=_object$parsedStyle.defX,defX=_object$parsedStyle$d===void 0?0:_object$parsedStyle$d,_object$parsedStyle$d2=_object$parsedStyle.defY,defY=_object$parsedStyle$d2===void 0?0:_object$parsedStyle$d2;object.setLocalPosition(defX,defY);}};return CSSPropertyPath;}();var CSSPropertyPoints=/*#__PURE__*/function(){function CSSPropertyPoints(){this.parser=parsePoints;}var _proto=CSSPropertyPoints.prototype;/**
8078
+ */_proto.postProcessor=function postProcessor(object,attributes){if(object.nodeName===exports.Shape.PATH&&attributes.indexOf('transform')===-1){var _object$parsedStyle=object.parsedStyle,_object$parsedStyle$d=_object$parsedStyle.defX,defX=_object$parsedStyle$d===void 0?0:_object$parsedStyle$d,_object$parsedStyle$d2=_object$parsedStyle.defY,defY=_object$parsedStyle$d2===void 0?0:_object$parsedStyle$d2;object.setLocalPosition(defX,defY);}};return CSSPropertyPath;}();var CSSPropertyPoints=/*#__PURE__*/function(){function CSSPropertyPoints(){this.parser=parsePoints;}var _proto=CSSPropertyPoints.prototype;/**
7733
8079
  * update local position
7734
- */_proto.postProcessor=function postProcessor(object){if(object.nodeName===exports.Shape.POLYGON||object.nodeName===exports.Shape.POLYLINE){var _object$parsedStyle=object.parsedStyle,defX=_object$parsedStyle.defX,defY=_object$parsedStyle.defY;object.setLocalPosition(defX,defY);}};return CSSPropertyPoints;}();var CSSPropertyShadowBlur=/*#__PURE__*/function(_CSSPropertyLengthOrP){_inheritsLoose(CSSPropertyShadowBlur,_CSSPropertyLengthOrP);function CSSPropertyShadowBlur(){var _this;for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this=_CSSPropertyLengthOrP.call.apply(_CSSPropertyLengthOrP,[this].concat(args))||this;_this.mixer=clampedMergeNumbers(0,Infinity);return _this;}return CSSPropertyShadowBlur;}(CSSPropertyLengthOrPercentage);var CSSPropertyText=/*#__PURE__*/function(){function CSSPropertyText(){}var _proto=CSSPropertyText.prototype;_proto.calculator=function calculator(name,oldParsed,parsed,object){if(parsed instanceof CSSKeywordValue){if(parsed.value==='unset'){return '';}else {return parsed.value;}}// allow number as valid text content
8080
+ */_proto.postProcessor=function postProcessor(object,attributes){if((object.nodeName===exports.Shape.POLYGON||object.nodeName===exports.Shape.POLYLINE)&&attributes.indexOf('transform')===-1){var _object$parsedStyle=object.parsedStyle,defX=_object$parsedStyle.defX,defY=_object$parsedStyle.defY;object.setLocalPosition(defX,defY);}};return CSSPropertyPoints;}();var CSSPropertyShadowBlur=/*#__PURE__*/function(_CSSPropertyLengthOrP){_inheritsLoose(CSSPropertyShadowBlur,_CSSPropertyLengthOrP);function CSSPropertyShadowBlur(){var _this;for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this=_CSSPropertyLengthOrP.call.apply(_CSSPropertyLengthOrP,[this].concat(args))||this;_this.mixer=clampedMergeNumbers(0,Infinity);return _this;}return CSSPropertyShadowBlur;}(CSSPropertyLengthOrPercentage);var CSSPropertyText=/*#__PURE__*/function(){function CSSPropertyText(){}var _proto=CSSPropertyText.prototype;_proto.calculator=function calculator(name,oldParsed,parsed,object){if(parsed instanceof CSSKeywordValue){if(parsed.value==='unset'){return '';}else {return parsed.value;}}// allow number as valid text content
7735
8081
  return ""+parsed;};_proto.postProcessor=function postProcessor(object){object.nodeValue=""+object.parsedStyle.text||'';};return CSSPropertyText;}();/**
7736
8082
  * it must transform after text get parsed
7737
8083
  * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/text-transform
@@ -7764,7 +8110,7 @@
7764
8110
  * * matrix/matrix3d()
7765
8111
  * * skew/skewX/skewY
7766
8112
  * * perspective
7767
- */var CSSPropertyTransform=/*#__PURE__*/function(){function CSSPropertyTransform(){this.parser=parseTransform;this.mixer=mergeTransforms;}var _proto=CSSPropertyTransform.prototype;_proto.calculator=function calculator(name,oldParsed,parsed,object){// 'none'
8113
+ */var CSSPropertyTransform=/*#__PURE__*/function(){function CSSPropertyTransform(){this.parser=parseTransform;this.parserWithCSSDisabled=parseTransform;this.mixer=mergeTransforms;}var _proto=CSSPropertyTransform.prototype;_proto.calculator=function calculator(name,oldParsed,parsed,object){// 'none'
7768
8114
  if(parsed instanceof CSSKeywordValue){return [];}return parsed;};_proto.postProcessor=function postProcessor(object){var transform=object.parsedStyle.transform;parsedTransformToMat4(transform,object);};return CSSPropertyTransform;}();/**
7769
8115
  * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/transform-origin
7770
8116
  * @example
@@ -7776,7 +8122,7 @@
7776
8122
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry
7777
8123
  */var CustomElementRegistry=/*#__PURE__*/function(){function CustomElementRegistry(){this.registry={};this.define(exports.Shape.CIRCLE,Circle);this.define(exports.Shape.ELLIPSE,Ellipse);this.define(exports.Shape.RECT,Rect);this.define(exports.Shape.IMAGE,Image);this.define(exports.Shape.LINE,Line);this.define(exports.Shape.GROUP,Group);this.define(exports.Shape.PATH,Path);this.define(exports.Shape.POLYGON,Polygon);this.define(exports.Shape.POLYLINE,Polyline);this.define(exports.Shape.TEXT,Text);this.define(exports.Shape.HTML,HTML);}var _proto=CustomElementRegistry.prototype;_proto.define=function define(name,constructor){this.registry[name]=constructor;}/**
7778
8124
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry/get
7779
- */;_proto.get=function get(name){return this.registry[name];};return CustomElementRegistry;}();var Point=/*#__PURE__*/function(){function Point(x,y){if(x===void 0){x=0;}if(y===void 0){y=0;}this.x=0;this.y=0;this.x=x;this.y=y;}var _proto=Point.prototype;_proto.clone=function clone(){return new Point(this.x,this.y);};_proto.copyFrom=function copyFrom(p){this.x=p.x;this.y=p.y;};return Point;}();function isFederatedEvent(value){return !!value.type;}/**
8125
+ */;_proto.get=function get(name){return this.registry[name];};return CustomElementRegistry;}();function isFederatedEvent(value){return !!value.type;}/**
7780
8126
  * An DOM-compatible synthetic event implementation that is "forwarded" on behalf of an original
7781
8127
  * FederatedEvent or native {@link https://dom.spec.whatwg.org/#event Event}.
7782
8128
  */var FederatedEvent=/*#__PURE__*/function(){/**
@@ -7918,7 +8264,7 @@
7918
8264
  * @example const circle = document.createElement('circle', { style: { r: 10 } });
7919
8265
  */_proto.createElement=function createElement(tagName,options){// @observablehq/plot will create <svg>
7920
8266
  if(tagName==='svg'){return this.documentElement;}// d3 will use <tspan>
7921
- var clazz=this.defaultView.customElements.get(tagName);if(!clazz){console.warn('Unsupported tagName: ',tagName);clazz=tagName==='tspan'?Text:Group;}var shape=new clazz(options);shape.ownerDocument=this;return shape;};_proto.createElementNS=function createElementNS(namespaceURI,tagName,options){return this.createElement(tagName,options);};_proto.cloneNode=function cloneNode(deep){throw new Error(ERROR_MSG_METHOD_NOT_IMPLEMENTED);};_proto.destroy=function destroy(){try{this.documentElement.childNodes.slice().forEach(function(child){child.forEach(function(object){object.destroy();},true);});this.timeline.destroy();}catch(e){}}/**
8267
+ var clazz=this.defaultView.customElements.get(tagName);if(!clazz){console.warn('Unsupported tagName: ',tagName);clazz=tagName==='tspan'?Text:Group;}var shape=new clazz(options);shape.ownerDocument=this;return shape;};_proto.createElementNS=function createElementNS(namespaceURI,tagName,options){return this.createElement(tagName,options);};_proto.cloneNode=function cloneNode(deep){throw new Error(ERROR_MSG_METHOD_NOT_IMPLEMENTED);};_proto.destroy=function destroy(){try{this.documentElement.destroyChildren();this.timeline.destroy();}catch(e){}}/**
7922
8268
  * Picking 2D graphics with RBush based on BBox, fast but inaccurate.
7923
8269
  */;_proto.elementsFromBBox=function elementsFromBBox(minX,minY,maxX,maxY){var rBush=this.defaultView.context.rBushRoot;var rBushNodes=rBush.search({minX:minX,minY:minY,maxX:maxX,maxY:maxY});var hitTestList=[];rBushNodes.forEach(function(_ref2){var id=_ref2.id;var displayObject=runtime.displayObjectPool.getByEntity(id);var pointerEvents=displayObject.parsedStyle.pointerEvents;// account for `visibility`
7924
8270
  // @see https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
@@ -7980,7 +8326,7 @@
7980
8326
  // scaling: vec3.fromValues(1, 1, 1),
7981
8327
  // worldTransform: mat4.create(),
7982
8328
  // origin: vec3.fromValues(0, 0, 0),
7983
- localPosition:[0,0,0],localRotation:[0,0,0,1],localScale:[1,1,1],localTransform:create$1(),localSkew:[0,0],position:[0,0,0],rotation:[0,0,0,1],scaling:[1,1,1],worldTransform:create$1(),origin:[0,0,0]};_this.sortable={dirty:false,sorted:undefined,lastSortedIndex:undefined,renderOrder:0};_this.geometry={contentBounds:undefined,renderBounds:undefined};_this.rBushNode={aabb:undefined};_this.id=void 0;_this.name=void 0;_this.namespaceURI='g';_this.scrollLeft=0;_this.scrollTop=0;_this.clientTop=0;_this.clientLeft=0;_this.destroyed=false;_this.style={};_this.computedStyle={anchor:unsetKeywordValue,opacity:unsetKeywordValue,fillOpacity:unsetKeywordValue,strokeOpacity:unsetKeywordValue,fill:unsetKeywordValue,stroke:unsetKeywordValue,transform:unsetKeywordValue,transformOrigin:unsetKeywordValue,visibility:unsetKeywordValue,pointerEvents:unsetKeywordValue,lineWidth:unsetKeywordValue,lineCap:unsetKeywordValue,lineJoin:unsetKeywordValue,increasedLineWidthForHitTesting:unsetKeywordValue,fontSize:unsetKeywordValue,fontFamily:unsetKeywordValue,fontStyle:unsetKeywordValue,fontWeight:unsetKeywordValue,fontVariant:unsetKeywordValue,textAlign:unsetKeywordValue,textBaseline:unsetKeywordValue,textTransform:unsetKeywordValue,zIndex:unsetKeywordValue,filter:unsetKeywordValue,shadowType:unsetKeywordValue};_this.parsedStyle={// opacity: '',
8329
+ localPosition:[0,0,0],localRotation:[0,0,0,1],localScale:[1,1,1],localTransform:create$1(),localSkew:[0,0],position:[0,0,0],rotation:[0,0,0,1],scaling:[1,1,1],worldTransform:create$1(),origin:[0,0,0]};_this.sortable={dirty:false,sorted:undefined,lastSortedIndex:undefined,renderOrder:0};_this.geometry={contentBounds:undefined,renderBounds:undefined};_this.rBushNode={aabb:undefined};_this.id=void 0;_this.name=void 0;_this.namespaceURI='g';_this.scrollLeft=0;_this.scrollTop=0;_this.clientTop=0;_this.clientLeft=0;_this.destroyed=false;_this.style={};_this.computedStyle=runtime.enableCSSParsing?{anchor:unsetKeywordValue,opacity:unsetKeywordValue,fillOpacity:unsetKeywordValue,strokeOpacity:unsetKeywordValue,fill:unsetKeywordValue,stroke:unsetKeywordValue,transform:unsetKeywordValue,transformOrigin:unsetKeywordValue,visibility:unsetKeywordValue,pointerEvents:unsetKeywordValue,lineWidth:unsetKeywordValue,lineCap:unsetKeywordValue,lineJoin:unsetKeywordValue,increasedLineWidthForHitTesting:unsetKeywordValue,fontSize:unsetKeywordValue,fontFamily:unsetKeywordValue,fontStyle:unsetKeywordValue,fontWeight:unsetKeywordValue,fontVariant:unsetKeywordValue,textAlign:unsetKeywordValue,textBaseline:unsetKeywordValue,textTransform:unsetKeywordValue,zIndex:unsetKeywordValue,filter:unsetKeywordValue,shadowType:unsetKeywordValue}:null;_this.parsedStyle={// opacity: '',
7984
8330
  // fillOpacity: '',
7985
8331
  // strokeOpacity: '',
7986
8332
  // transformOrigin: '',
@@ -8004,9 +8350,9 @@
8004
8350
  removedEvent.relatedNode=this;child.dispatchEvent(removedEvent);if((_child$ownerDocument=child.ownerDocument)===null||_child$ownerDocument===void 0?void 0:_child$ownerDocument.defaultView){child.ownerDocument.defaultView.unmountChildren(child);}// remove from scene graph
8005
8351
  runtime.sceneGraphService.detach(child);return child;}/**
8006
8352
  * Remove all children which can be appended to its original parent later again.
8007
- */;_proto.removeChildren=function removeChildren(){var _this2=this;this.childNodes.slice().forEach(function(child){_this2.removeChild(child);});}/**
8353
+ */;_proto.removeChildren=function removeChildren(){for(var i=this.childNodes.length-1;i>=0;i--){var child=this.childNodes[i];this.removeChild(child);}}/**
8008
8354
  * Recursively destroy all children which can not be appended to its original parent later again.
8009
- */;_proto.destroyChildren=function destroyChildren(){this.childNodes.slice().forEach(function(child){child.destroyChildren();child.destroy();});}/**
8355
+ */;_proto.destroyChildren=function destroyChildren(){for(var i=this.childNodes.length-1;i>=0;i--){var child=this.childNodes[i];if(child.childNodes.length){child.destroyChildren();}child.destroy();}}/**
8010
8356
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/matches
8011
8357
  */;_proto.matches=function matches(selector){return runtime.sceneGraphService.matches(selector,this);};_proto.getElementById=function getElementById(id){return runtime.sceneGraphService.querySelector("#"+id,this);};_proto.getElementsByName=function getElementsByName(name){return runtime.sceneGraphService.querySelectorAll("[name=\""+name+"\"]",this);};_proto.getElementsByClassName=function getElementsByClassName(className){return runtime.sceneGraphService.querySelectorAll("."+className,this);};_proto.getElementsByTagName=function getElementsByTagName(tagName){return runtime.sceneGraphService.querySelectorAll(tagName,this);};_proto.querySelector=function querySelector(selectors){return runtime.sceneGraphService.querySelector(selectors,this);};_proto.querySelectorAll=function querySelectorAll(selectors){return runtime.sceneGraphService.querySelectorAll(selectors,this);}/**
8012
8358
  * should traverses the element and its parents (heading toward the document root)
@@ -8015,17 +8361,17 @@
8015
8361
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#polyfill
8016
8362
  */;_proto.closest=function closest(selectors){var el=this;do{if(runtime.sceneGraphService.matches(selectors,el))return el;el=el.parentElement;}while(el!==null);return null;}/**
8017
8363
  * search in scene group, but should not include itself
8018
- */;_proto.find=function find(filter){var _this3=this;var target=null;this.forEach(function(object){if(object!==_this3&&filter(object)){target=object;return true;}return false;});return target;};_proto.findAll=function findAll(filter){var _this4=this;var objects=[];this.forEach(function(object){if(object!==_this4&&filter(object)){objects.push(object);}});return objects;}/**
8364
+ */;_proto.find=function find(filter){var _this2=this;var target=null;this.forEach(function(object){if(object!==_this2&&filter(object)){target=object;return true;}return false;});return target;};_proto.findAll=function findAll(filter){var _this3=this;var objects=[];this.forEach(function(object){if(object!==_this3&&filter(object)){objects.push(object);}});return objects;}/**
8019
8365
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/after
8020
- */;_proto.after=function after(){var _this5=this;if(this.parentNode){var index=this.parentNode.childNodes.indexOf(this);for(var _len2=arguments.length,nodes=new Array(_len2),_key2=0;_key2<_len2;_key2++){nodes[_key2]=arguments[_key2];}nodes.forEach(function(node,i){var _this5$parentNode;return (_this5$parentNode=_this5.parentNode)===null||_this5$parentNode===void 0?void 0:_this5$parentNode.appendChild(node,index+i+1);});}}/**
8366
+ */;_proto.after=function after(){var _this4=this;if(this.parentNode){var index=this.parentNode.childNodes.indexOf(this);for(var _len2=arguments.length,nodes=new Array(_len2),_key2=0;_key2<_len2;_key2++){nodes[_key2]=arguments[_key2];}nodes.forEach(function(node,i){var _this4$parentNode;return (_this4$parentNode=_this4.parentNode)===null||_this4$parentNode===void 0?void 0:_this4$parentNode.appendChild(node,index+i+1);});}}/**
8021
8367
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/before
8022
8368
  */;_proto.before=function before(){if(this.parentNode){var index=this.parentNode.childNodes.indexOf(this);for(var _len3=arguments.length,nodes=new Array(_len3),_key3=0;_key3<_len3;_key3++){nodes[_key3]=arguments[_key3];}var first=nodes[0],rest=nodes.slice(1);this.parentNode.appendChild(first,index);first.after.apply(first,rest);}}/**
8023
8369
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/replaceWith
8024
8370
  */;_proto.replaceWith=function replaceWith(){this.after.apply(this,arguments);this.remove();}/**
8025
8371
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/append
8026
- */;_proto.append=function append(){var _this6=this;for(var _len4=arguments.length,nodes=new Array(_len4),_key4=0;_key4<_len4;_key4++){nodes[_key4]=arguments[_key4];}nodes.forEach(function(node){return _this6.appendChild(node);});}/**
8372
+ */;_proto.append=function append(){var _this5=this;for(var _len4=arguments.length,nodes=new Array(_len4),_key4=0;_key4<_len4;_key4++){nodes[_key4]=arguments[_key4];}nodes.forEach(function(node){return _this5.appendChild(node);});}/**
8027
8373
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/prepend
8028
- */;_proto.prepend=function prepend(){var _this7=this;for(var _len5=arguments.length,nodes=new Array(_len5),_key5=0;_key5<_len5;_key5++){nodes[_key5]=arguments[_key5];}nodes.forEach(function(node,i){return _this7.appendChild(node,i);});}/**
8374
+ */;_proto.prepend=function prepend(){var _this6=this;for(var _len5=arguments.length,nodes=new Array(_len5),_key5=0;_key5<_len5;_key5++){nodes[_key5]=arguments[_key5];}nodes.forEach(function(node,i){return _this6.appendChild(node,i);});}/**
8029
8375
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/replaceChildren
8030
8376
  */;_proto.replaceChildren=function replaceChildren(){while(this.childNodes.length&&this.firstChild){this.removeChild(this.firstChild);}this.append.apply(this,arguments);}/**
8031
8377
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/remove
@@ -8099,8 +8445,8 @@
8099
8445
  * which can lead to unintended consequences if an attempt is made to cache the entire event object.
8100
8446
  *
8101
8447
  * Therefore, while keeping the above performance considerations in mind, it is possible to provide a clone method that creates a new object when the user really wants to cache it, e.g.
8102
- */;_proto.clone=function clone(){return this.manager.clonePointerEvent(this);};return FederatedPointerEvent;}(FederatedMouseEvent);var FederatedWheelEvent=/*#__PURE__*/function(_FederatedMouseEvent){_inheritsLoose(FederatedWheelEvent,_FederatedMouseEvent);function FederatedWheelEvent(){var _this;for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this=_FederatedMouseEvent.call.apply(_FederatedMouseEvent,[this].concat(args))||this;_this.deltaMode=void 0;_this.deltaX=void 0;_this.deltaY=void 0;_this.deltaZ=void 0;_this.DOM_DELTA_LINE=0;_this.DOM_DELTA_PAGE=1;_this.DOM_DELTA_PIXEL=2;return _this;}var _proto=FederatedWheelEvent.prototype;_proto.clone=function clone(){return this.manager.cloneWheelEvent(this);};return FederatedWheelEvent;}(FederatedMouseEvent);function isDisplayObject(value){return !!(value===null||value===void 0?void 0:value.nodeName);}var mutationEvent=new MutationEvent(exports.ElementEvent.ATTR_MODIFIED,null,null,null,null,MutationEvent.MODIFICATION,null,null);var DEFAULT_STYLE_PROPS={anchor:'',opacity:'',fillOpacity:'',strokeOpacity:'',fill:'',stroke:'',transform:'',transformOrigin:'',visibility:'',pointerEvents:'',lineWidth:'',lineCap:'',lineJoin:'',increasedLineWidthForHitTesting:'',fontSize:'',fontFamily:'',fontStyle:'',fontWeight:'',fontVariant:'',textAlign:'',textBaseline:'',textTransform:'',zIndex:'',filter:'',shadowType:''};var DEFAULT_PARSED_STYLE_PROPS={anchor:[0,0],fill:noneColor,stroke:noneColor,transform:[],zIndex:0,filter:[],shadowType:'outer'};var DEFAULT_PARSED_STYLE_PROPS_CSS_DISABLED=_extends({},DEFAULT_PARSED_STYLE_PROPS,{opacity:1,fillOpacity:1,strokeOpacity:1,visibility:'visible',pointerEvents:'auto',lineWidth:1,lineCap:'butt',lineJoin:'miter',increasedLineWidthForHitTesting:0,fillRule:'nonzero'// TODO: transformOrigin
8103
- });var INHERITABLE_BASE_STYLE_PROPS=['opacity','fillOpacity','strokeOpacity','transformOrigin','visibility','pointerEvents','lineWidth','lineCap','lineJoin','increasedLineWidthForHitTesting'];var INHERITABLE_STYLE_PROPS=[].concat(INHERITABLE_BASE_STYLE_PROPS,['fontSize','fontFamily','fontStyle','fontWeight','fontVariant','textAlign','textBaseline','textTransform']);/**
8448
+ */;_proto.clone=function clone(){return this.manager.clonePointerEvent(this);};return FederatedPointerEvent;}(FederatedMouseEvent);var FederatedWheelEvent=/*#__PURE__*/function(_FederatedMouseEvent){_inheritsLoose(FederatedWheelEvent,_FederatedMouseEvent);function FederatedWheelEvent(){var _this;for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this=_FederatedMouseEvent.call.apply(_FederatedMouseEvent,[this].concat(args))||this;_this.deltaMode=void 0;_this.deltaX=void 0;_this.deltaY=void 0;_this.deltaZ=void 0;_this.DOM_DELTA_LINE=0;_this.DOM_DELTA_PAGE=1;_this.DOM_DELTA_PIXEL=2;return _this;}var _proto=FederatedWheelEvent.prototype;_proto.clone=function clone(){return this.manager.cloneWheelEvent(this);};return FederatedWheelEvent;}(FederatedMouseEvent);function isDisplayObject(value){return !!(value===null||value===void 0?void 0:value.nodeName);}var mutationEvent=new MutationEvent(exports.ElementEvent.ATTR_MODIFIED,null,null,null,null,MutationEvent.MODIFICATION,null,null);var DEFAULT_STYLE_PROPS={anchor:'',opacity:'',fillOpacity:'',strokeOpacity:'',fill:'',stroke:'',transform:'',transformOrigin:'',visibility:'',pointerEvents:'',lineWidth:'',lineCap:'',lineJoin:'',increasedLineWidthForHitTesting:'',fontSize:'',fontFamily:'',fontStyle:'',fontWeight:'',fontVariant:'',textAlign:'',textBaseline:'',textTransform:'',zIndex:'',filter:'',shadowType:''};var DEFAULT_PARSED_STYLE_PROPS={anchor:[0,0],fill:noneColor,stroke:noneColor,transform:[],zIndex:0,filter:[],shadowType:'outer',miterLimit:10};var DEFAULT_PARSED_STYLE_PROPS_CSS_DISABLED=_extends({},DEFAULT_PARSED_STYLE_PROPS,{opacity:1,fillOpacity:1,strokeOpacity:1,visibility:'visible',pointerEvents:'auto',lineWidth:1,lineCap:'butt',lineJoin:'miter',increasedLineWidthForHitTesting:0,fillRule:'nonzero'// TODO: transformOrigin
8449
+ });var INHERITABLE_BASE_STYLE_PROPS=['opacity','fillOpacity','strokeOpacity','transformOrigin','visibility','pointerEvents','lineWidth','lineCap','lineJoin','increasedLineWidthForHitTesting'];var INHERITABLE_STYLE_PROPS=[].concat(INHERITABLE_BASE_STYLE_PROPS,['fontSize','fontFamily','fontStyle','fontWeight','fontVariant','textAlign','textBaseline','textTransform']);var DATASET_PREFIX='data-';/**
8104
8450
  * prototype chains: DisplayObject -> Element -> Node -> EventTarget
8105
8451
  *
8106
8452
  * mixins: Animatable, Transformable, Visible
@@ -8121,9 +8467,15 @@
8121
8467
  * contains style props in constructor's params, eg. fill, stroke...
8122
8468
  */ /**
8123
8469
  * push to active animations after calling `animate()`
8470
+ */ /**
8471
+ * Use data-* attribute.
8472
+ * @see https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes
8473
+ * @example
8474
+ * group.dataset.prop1 = 1;
8475
+ * group.getAttribute('data-prop1'); // 1
8124
8476
  */function DisplayObject(config){var _this$config$capture;var _this;_this=_Element.call(this)||this;// assign name, id to config
8125
8477
  // eg. group.get('name')
8126
- _this.config=void 0;_this.isCustomElement=false;_this.isMutationObserved=false;_this.activeAnimations=[];_this.getClip=function(){return this.style.clipPath||null;};_this.config=config;// compatible with G 3.0
8478
+ _this.config=void 0;_this.isCustomElement=false;_this.isMutationObserved=false;_this.activeAnimations=[];_this.dataset=void 0;_this.getClip=function(){return this.style.clipPath||null;};_this.config=config;// compatible with G 3.0
8127
8479
  _this.config.interactive=(_this$config$capture=_this.config.capture)!==null&&_this$config$capture!==void 0?_this$config$capture:_this.config.interactive;// init scene graph node
8128
8480
  _this.id=_this.config.id||'';_this.name=_this.config.name||'';if(_this.config.className||_this.config.class){_this.className=_this.config.className||_this.config.class;}_this.nodeName=_this.config.type||exports.Shape.GROUP;// compatible with G 3.0
8129
8481
  _this.config.style=_this.config.style||_this.config.attrs||{};Object.assign(_this.config.style,_this.config.attrs);// this.config.style = {
@@ -8133,7 +8485,7 @@
8133
8485
  // };
8134
8486
  if(_this.config.visible!=null){_this.config.style.visibility=_this.config.visible===false?'hidden':'visible';}if(_this.config.interactive!=null){_this.config.style.pointerEvents=_this.config.interactive===false?'none':'auto';}// merge parsed value
8135
8487
  Object.assign(_this.parsedStyle,runtime.enableCSSParsing?DEFAULT_PARSED_STYLE_PROPS:DEFAULT_PARSED_STYLE_PROPS_CSS_DISABLED,_this.config.initialParsedStyle);if(runtime.enableCSSParsing){Object.assign(_this.attributes,DEFAULT_STYLE_PROPS);}// start to process attributes
8136
- _this.initAttributes(_this.config.style);_this.style=new Proxy(// @ts-ignore
8488
+ _this.initAttributes(_this.config.style);_this.dataset=new Proxy({},{get:function get(target,name){var formattedName=""+DATASET_PREFIX+kebabize(name);if(target[formattedName]!==undefined){return target[formattedName];}return _this.getAttribute(formattedName);},set:function set(_,prop,value){_this.setAttribute(""+DATASET_PREFIX+kebabize(prop),value);return true;}});_this.style=new Proxy(// @ts-ignore
8137
8489
  {// ...this.attributes,
8138
8490
  setProperty:function setProperty(propertyName,value){_this.setAttribute(propertyName,value);},getPropertyValue:function getPropertyValue(propertyName){return _this.getAttribute(propertyName);},removeProperty:function removeProperty(propertyName){_this.removeAttribute(propertyName);},item:function item(){return '';}},{get:function get(target,name){if(target[name]!==undefined){// if (name in target) {
8139
8491
  return target[name];}return _this.getAttribute(name);},set:function set(_,prop,value){_this.setAttribute(prop,value);return true;}});// insert this group into pool
@@ -8279,465 +8631,119 @@
8279
8631
  * @deprecated
8280
8632
  */;_proto.moveTo=function moveTo(position,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}this.setPosition(position,y,z);return this;}/**
8281
8633
  * Use `setPosition` instead.
8282
- * @deprecated
8283
- */;_proto.move=function move(position,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}this.setPosition(position,y,z);return this;}/**
8284
- * Use `this.style.zIndex` instead.
8285
- * @deprecated
8286
- */;_proto.setZIndex=function setZIndex(zIndex){this.style.zIndex=zIndex;return this;};_createClass(DisplayObject,[{key:"interactive",get:function get(){return this.isInteractive();},set:function set(b){this.style.pointerEvents=b?'auto':'none';}}]);return DisplayObject;}(Element);var _excluded=["style"];var Circle=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Circle,_DisplayObject);function Circle(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded);return _DisplayObject.call(this,_extends({type:exports.Shape.CIRCLE,style:_extends({cx:'',cy:'',r:''},style),initialParsedStyle:{anchor:[0.5,0.5]}},rest))||this;}return Circle;}(DisplayObject);var _excluded$1=["style"];/**
8287
- * shadow root
8288
- * @see https://yuque.antfin-inc.com/antv/czqvg5/pgqipg
8289
- */var CustomElement=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(CustomElement,_DisplayObject);// static get observedAttributes(): string[] {
8290
- // return [];
8291
- // }
8292
- // private shadowNodes: DisplayObject[] = [];
8293
- function CustomElement(_temp){var _this;var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$1);_this=_DisplayObject.call(this,_extends({style:_extends({x:'',y:''},style)},rest))||this;_this.isCustomElement=true;return _this;}return CustomElement;}(DisplayObject);var pool={};var htmlPool=[];var DisplayObjectPool=/*#__PURE__*/function(){function DisplayObjectPool(){}var _proto=DisplayObjectPool.prototype;_proto.getByEntity=function getByEntity(entity){return pool[entity];};_proto.getAll=function getAll(){return Object.keys(pool).map(function(entity){return pool[entity];});};_proto.add=function add(entity,groupOrShape){pool[entity]=groupOrShape;if(groupOrShape.nodeName===exports.Shape.HTML){htmlPool.push(groupOrShape);}};_proto.remove=function remove(entity){var existed=pool[entity];if(existed){delete pool[entity];if(existed.nodeName===exports.Shape.HTML){var index=htmlPool.indexOf(existed);htmlPool.splice(index,1);}}};_proto.getHTMLs=function getHTMLs(){return htmlPool;};return DisplayObjectPool;}();var _excluded$2=["style"];var Ellipse=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Ellipse,_DisplayObject);function Ellipse(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$2);return _DisplayObject.call(this,_extends({type:exports.Shape.ELLIPSE,style:_extends({cx:'',cy:'',rx:'',ry:''},style),initialParsedStyle:{anchor:[0.5,0.5]}},rest))||this;}return Ellipse;}(DisplayObject);var _excluded$3=["style"];/**
8294
- * its attributes are inherited by its children.
8295
- * @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/g
8296
- *
8297
- * @example
8298
- * <g fill="white" stroke="green" stroke-width="5">
8299
- <circle cx="40" cy="40" r="25" />
8300
- <circle cx="60" cy="60" r="25" />
8301
- </g>
8302
- */var Group=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Group,_DisplayObject);function Group(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$3);return _DisplayObject.call(this,_extends({type:exports.Shape.GROUP,style:_extends({x:'',y:'',width:'',height:''},style)},rest))||this;}return Group;}(DisplayObject);var _excluded$4=["style"];/**
8303
- * HTML container
8304
- * @see https://github.com/pmndrs/drei#html
8305
- */var HTML=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(HTML,_DisplayObject);function HTML(_temp){var _this;var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$4);_this=_DisplayObject.call(this,_extends({type:exports.Shape.HTML,style:_extends({x:'',y:'',width:'auto',height:'auto',innerHTML:''},style)},rest))||this;_this.cullable.enable=false;return _this;}/**
8306
- * return wrapper HTMLElement
8307
- * * <div> in g-webgl/canvas
8308
- * * <foreignObject> in g-svg
8309
- */var _proto=HTML.prototype;_proto.getDomElement=function getDomElement(){return this.parsedStyle.$el;}/**
8310
- * override with $el.getBoundingClientRect
8311
- * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/getBoundingClientRect
8312
- */;_proto.getBoundingClientRect=function getBoundingClientRect(){return this.parsedStyle.$el.getBoundingClientRect();};_proto.getClientRects=function getClientRects(){return [this.getBoundingClientRect()];};_proto.getBounds=function getBounds(){var _this$ownerDocument,_this$ownerDocument$d;var clientRect=this.getBoundingClientRect();// calc context's offset
8313
- // @ts-ignore
8314
- var canvasRect=(_this$ownerDocument=this.ownerDocument)===null||_this$ownerDocument===void 0?void 0:(_this$ownerDocument$d=_this$ownerDocument.defaultView)===null||_this$ownerDocument$d===void 0?void 0:_this$ownerDocument$d.getContextService().getBoundingClientRect();if(canvasRect){var minX=clientRect.left-canvasRect.left;var minY=clientRect.top-canvasRect.top;var aabb=new AABB();// aabb.setMinMax(
8315
- // vec3.fromValues(minX, minY, 0),
8316
- // vec3.fromValues(minX + clientRect.width, minY + clientRect.height, 0),
8317
- // );
8318
- aabb.setMinMax([minX,minY,0],[minX+clientRect.width,minY+clientRect.height,0]);return aabb;}return null;};_proto.getLocalBounds=function getLocalBounds(){if(this.parentNode){var parentInvert=invert(create$1(),this.parentNode.getWorldTransform());var bounds=this.getBounds();if(!AABB.isEmpty(bounds)){var localBounds=new AABB();localBounds.setFromTransformedAABB(bounds,parentInvert);return localBounds;}}return this.getBounds();};return HTML;}(DisplayObject);var _excluded$5=["style"];var Image=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Image,_DisplayObject);function Image(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$5);return _DisplayObject.call(this,_extends({type:exports.Shape.IMAGE,style:_extends({x:'',y:'',img:'',width:'',height:''},style)},rest))||this;}return Image;}(DisplayObject);var _excluded$6=["style"];/**
8319
- * Create a line connecting two points.
8320
- * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/line
8321
- *
8322
- * Also support for using marker.
8323
- */var Line=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Line,_DisplayObject);function Line(_temp){var _this;var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$6);_this=_DisplayObject.call(this,_extends({type:exports.Shape.LINE,style:_extends({x1:0,y1:0,x2:0,y2:0,z1:0,z2:0,isBillboard:false},style)},rest))||this;_this.markerStartAngle=0;_this.markerEndAngle=0;var _this$parsedStyle=_this.parsedStyle,markerStart=_this$parsedStyle.markerStart,markerEnd=_this$parsedStyle.markerEnd;if(markerStart&&isDisplayObject(markerStart)){_this.markerStartAngle=markerStart.getLocalEulerAngles();_this.appendChild(markerStart);}if(markerEnd&&isDisplayObject(markerEnd)){_this.markerEndAngle=markerEnd.getLocalEulerAngles();_this.appendChild(markerEnd);}_this.transformMarker(true);_this.transformMarker(false);return _this;}var _proto=Line.prototype;_proto.attributeChangedCallback=function attributeChangedCallback(attrName,oldValue,newValue,prevParsedValue,newParsedValue){if(attrName==='x1'||attrName==='y1'||attrName==='x2'||attrName==='y2'||attrName==='markerStartOffset'||attrName==='markerEndOffset'){this.transformMarker(true);this.transformMarker(false);}else if(attrName==='markerStart'){if(prevParsedValue&&isDisplayObject(prevParsedValue)){this.markerStartAngle=0;prevParsedValue.remove();}// CSSKeyword 'unset'
8324
- if(newParsedValue&&isDisplayObject(newParsedValue)){this.markerStartAngle=newParsedValue.getLocalEulerAngles();this.appendChild(newParsedValue);this.transformMarker(true);}}else if(attrName==='markerEnd'){if(prevParsedValue&&isDisplayObject(prevParsedValue)){this.markerEndAngle=0;prevParsedValue.remove();}if(newParsedValue&&isDisplayObject(newParsedValue)){this.markerEndAngle=newParsedValue.getLocalEulerAngles();this.appendChild(newParsedValue);this.transformMarker(false);}}};_proto.transformMarker=function transformMarker(isStart){var _this$parsedStyle2=this.parsedStyle,markerStart=_this$parsedStyle2.markerStart,markerEnd=_this$parsedStyle2.markerEnd,markerStartOffset=_this$parsedStyle2.markerStartOffset,markerEndOffset=_this$parsedStyle2.markerEndOffset,x1=_this$parsedStyle2.x1,x2=_this$parsedStyle2.x2,y1=_this$parsedStyle2.y1,y2=_this$parsedStyle2.y2,defX=_this$parsedStyle2.defX,defY=_this$parsedStyle2.defY;var marker=isStart?markerStart:markerEnd;if(!marker||!isDisplayObject(marker)){return;}var rad=0;var x;var y;var ox;var oy;var offset;var originalAngle;if(isStart){ox=x1-defX;oy=y1-defY;x=x2-x1;y=y2-y1;offset=markerStartOffset||0;originalAngle=this.markerStartAngle;}else {ox=x2-defX;oy=y2-defY;x=x1-x2;y=y1-y2;offset=markerEndOffset||0;originalAngle=this.markerEndAngle;}rad=Math.atan2(y,x);// account for markerOffset
8325
- marker.setLocalEulerAngles(rad*180/Math.PI+originalAngle);marker.setLocalPosition(ox+Math.cos(rad)*offset,oy+Math.sin(rad)*offset);};_proto.getPoint=function getPoint(ratio,inWorldSpace){if(inWorldSpace===void 0){inWorldSpace=false;}// TODO: account for z1/z2 in 3D line
8326
- var _this$parsedStyle3=this.parsedStyle,x1=_this$parsedStyle3.x1,y1=_this$parsedStyle3.y1,x2=_this$parsedStyle3.x2,y2=_this$parsedStyle3.y2,defX=_this$parsedStyle3.defX,defY=_this$parsedStyle3.defY;var _LineUtil$pointAt=line.pointAt(x1,y1,x2,y2,ratio),x=_LineUtil$pointAt.x,y=_LineUtil$pointAt.y;var transformed=transformMat4(create$2(),fromValues$2(x-defX,y-defY,0),inWorldSpace?this.getWorldTransform():this.getLocalTransform());// apply local transformation
8327
- return new Point(transformed[0],transformed[1]);};_proto.getPointAtLength=function getPointAtLength(distance,inWorldSpace){if(inWorldSpace===void 0){inWorldSpace=false;}return this.getPoint(distance/this.getTotalLength(),inWorldSpace);};_proto.getTotalLength=function getTotalLength(){// TODO: account for z1/z2 in 3D line
8328
- var _this$parsedStyle4=this.parsedStyle,x1=_this$parsedStyle4.x1,y1=_this$parsedStyle4.y1,x2=_this$parsedStyle4.x2,y2=_this$parsedStyle4.y2;return line.length(x1,y1,x2,y2);};return Line;}(DisplayObject);var _excluded$7=["style"];var Path=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Path,_DisplayObject);/**
8329
- * markers placed at the mid
8330
- */function Path(_temp){var _this;var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$7);_this=_DisplayObject.call(this,_extends({type:exports.Shape.PATH,style:_extends({path:'',miterLimit:''},style)},rest))||this;_this.markerStartAngle=0;_this.markerEndAngle=0;_this.markerMidList=[];var _this$parsedStyle=_this.parsedStyle,markerStart=_this$parsedStyle.markerStart,markerEnd=_this$parsedStyle.markerEnd,markerMid=_this$parsedStyle.markerMid;if(markerStart&&isDisplayObject(markerStart)){_this.markerStartAngle=markerStart.getLocalEulerAngles();_this.appendChild(markerStart);}if(markerMid&&isDisplayObject(markerMid)){_this.placeMarkerMid(markerMid);}if(markerEnd&&isDisplayObject(markerEnd)){_this.markerEndAngle=markerEnd.getLocalEulerAngles();_this.appendChild(markerEnd);}_this.transformMarker(true);_this.transformMarker(false);return _this;}var _proto=Path.prototype;_proto.attributeChangedCallback=function attributeChangedCallback(attrName,oldValue,newValue,prevParsedValue,newParsedValue){if(attrName==='path'){// recalc markers
8331
- this.transformMarker(true);this.transformMarker(false);this.placeMarkerMid(this.parsedStyle.markerMid);}else if(attrName==='markerStartOffset'||attrName==='markerEndOffset'){this.transformMarker(true);this.transformMarker(false);}else if(attrName==='markerStart'){if(prevParsedValue&&isDisplayObject(prevParsedValue)){this.markerStartAngle=0;prevParsedValue.remove();}// CSSKeyword 'unset'
8332
- if(newParsedValue&&isDisplayObject(newParsedValue)){this.markerStartAngle=newParsedValue.getLocalEulerAngles();this.appendChild(newParsedValue);this.transformMarker(true);}}else if(attrName==='markerEnd'){if(prevParsedValue&&isDisplayObject(prevParsedValue)){this.markerEndAngle=0;prevParsedValue.remove();}if(newParsedValue&&isDisplayObject(newParsedValue)){this.markerEndAngle=newParsedValue.getLocalEulerAngles();this.appendChild(newParsedValue);this.transformMarker(false);}}else if(attrName==='markerMid'){this.placeMarkerMid(newParsedValue);}};_proto.transformMarker=function transformMarker(isStart){var _this$parsedStyle2=this.parsedStyle,markerStart=_this$parsedStyle2.markerStart,markerEnd=_this$parsedStyle2.markerEnd,markerStartOffset=_this$parsedStyle2.markerStartOffset,markerEndOffset=_this$parsedStyle2.markerEndOffset,defX=_this$parsedStyle2.defX,defY=_this$parsedStyle2.defY;var marker=isStart?markerStart:markerEnd;if(!marker||!isDisplayObject(marker)){return;}var rad=0;var x;var y;var ox;var oy;var offset;var originalAngle;if(isStart){var _this$getStartTangent=this.getStartTangent(),p1=_this$getStartTangent[0],p2=_this$getStartTangent[1];ox=p2[0]-defX;oy=p2[1]-defY;x=p1[0]-p2[0];y=p1[1]-p2[1];offset=markerStartOffset||0;originalAngle=this.markerStartAngle;}else {var _this$getEndTangent=this.getEndTangent(),_p=_this$getEndTangent[0],_p2=_this$getEndTangent[1];ox=_p2[0]-defX;oy=_p2[1]-defY;x=_p[0]-_p2[0];y=_p[1]-_p2[1];offset=markerEndOffset||0;originalAngle=this.markerEndAngle;}rad=Math.atan2(y,x);// account for markerOffset
8333
- marker.setLocalEulerAngles(rad*180/Math.PI+originalAngle);marker.setLocalPosition(ox+Math.cos(rad)*offset,oy+Math.sin(rad)*offset);};_proto.placeMarkerMid=function placeMarkerMid(marker){var _this$parsedStyle3=this.parsedStyle,segments=_this$parsedStyle3.path.segments,defX=_this$parsedStyle3.defX,defY=_this$parsedStyle3.defY;// clear all existed markers
8334
- this.markerMidList.forEach(function(marker){marker.remove();});if(marker&&isDisplayObject(marker)){for(var i=1;i<segments.length-1;i++){var _segments$i$currentPo=segments[i].currentPoint,ox=_segments$i$currentPo[0],oy=_segments$i$currentPo[1];var cloned=i===1?marker:marker.cloneNode(true);this.markerMidList.push(cloned);this.appendChild(cloned);cloned.setLocalPosition(ox-defX,oy-defY);// TODO: orient of marker
8335
- }}}/**
8336
- * Returns the total length of the path.
8337
- * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGGeometryElement/getTotalLength
8338
- */;_proto.getTotalLength=function getTotalLength(){return getOrCalculatePathTotalLength(this);}/**
8339
- * Returns the point at a given distance along the path.
8340
- * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGGeometryElement/getPointAtLength
8341
- */;_proto.getPointAtLength=function getPointAtLength$1(distance,inWorldSpace){if(inWorldSpace===void 0){inWorldSpace=false;}var _this$parsedStyle4=this.parsedStyle,defX=_this$parsedStyle4.defX,defY=_this$parsedStyle4.defY,absolutePath=_this$parsedStyle4.path.absolutePath;var _getPointAtLength2=getPointAtLength(absolutePath,distance),x=_getPointAtLength2.x,y=_getPointAtLength2.y;var transformed=transformMat4(create$2(),fromValues$2(x-defX,y-defY,0),inWorldSpace?this.getWorldTransform():this.getLocalTransform());// apply local transformation
8342
- return new Point(transformed[0],transformed[1]);}/**
8343
- * Returns the point at a given ratio of the total length in path.
8344
- */;_proto.getPoint=function getPoint(ratio,inWorldSpace){if(inWorldSpace===void 0){inWorldSpace=false;}return this.getPointAtLength(ratio*getOrCalculatePathTotalLength(this),inWorldSpace);}/**
8345
- * Get start tangent vector
8346
- */;_proto.getStartTangent=function getStartTangent(){var segments=this.parsedStyle.path.segments;var result=[];if(segments.length>1){var startPoint=segments[0].currentPoint;var endPoint=segments[1].currentPoint;var tangent=segments[1].startTangent;result=[];if(tangent){result.push([startPoint[0]-tangent[0],startPoint[1]-tangent[1]]);result.push([startPoint[0],startPoint[1]]);}else {result.push([endPoint[0],endPoint[1]]);result.push([startPoint[0],startPoint[1]]);}}return result;}/**
8347
- * Get end tangent vector
8348
- */;_proto.getEndTangent=function getEndTangent(){var segments=this.parsedStyle.path.segments;var length=segments.length;var result=[];if(length>1){var startPoint=segments[length-2].currentPoint;var endPoint=segments[length-1].currentPoint;var tangent=segments[length-1].endTangent;result=[];if(tangent){result.push([endPoint[0]-tangent[0],endPoint[1]-tangent[1]]);result.push([endPoint[0],endPoint[1]]);}else {result.push([startPoint[0],startPoint[1]]);result.push([endPoint[0],endPoint[1]]);}}return result;};return Path;}(DisplayObject);var _excluded$8=["style"];var Polygon=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Polygon,_DisplayObject);/**
8349
- * markers placed at the mid
8350
- */function Polygon(_temp){var _this;var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$8);_this=_DisplayObject.call(this,_extends({type:exports.Shape.POLYGON,style:_extends({points:'',miterLimit:'',isClosed:true},style)},rest))||this;_this.markerStartAngle=0;_this.markerEndAngle=0;_this.markerMidList=[];var _this$parsedStyle=_this.parsedStyle,markerStart=_this$parsedStyle.markerStart,markerEnd=_this$parsedStyle.markerEnd,markerMid=_this$parsedStyle.markerMid;if(markerStart&&isDisplayObject(markerStart)){_this.markerStartAngle=markerStart.getLocalEulerAngles();_this.appendChild(markerStart);}if(markerMid&&isDisplayObject(markerMid)){_this.placeMarkerMid(markerMid);}if(markerEnd&&isDisplayObject(markerEnd)){_this.markerEndAngle=markerEnd.getLocalEulerAngles();_this.appendChild(markerEnd);}_this.transformMarker(true);_this.transformMarker(false);return _this;}var _proto=Polygon.prototype;_proto.attributeChangedCallback=function attributeChangedCallback(attrName,oldValue,newValue,prevParsedValue,newParsedValue){if(attrName==='points'){// recalc markers
8351
- this.transformMarker(true);this.transformMarker(false);this.placeMarkerMid(this.parsedStyle.markerMid);}else if(attrName==='markerStartOffset'||attrName==='markerEndOffset'){this.transformMarker(true);this.transformMarker(false);}else if(attrName==='markerStart'){if(prevParsedValue&&isDisplayObject(prevParsedValue)){this.markerStartAngle=0;prevParsedValue.remove();}// CSSKeyword 'unset'
8352
- if(newParsedValue&&isDisplayObject(newParsedValue)){this.markerStartAngle=newParsedValue.getLocalEulerAngles();this.appendChild(newParsedValue);this.transformMarker(true);}}else if(attrName==='markerEnd'){if(prevParsedValue&&isDisplayObject(prevParsedValue)){this.markerEndAngle=0;prevParsedValue.remove();}if(newParsedValue&&isDisplayObject(newParsedValue)){this.markerEndAngle=newParsedValue.getLocalEulerAngles();this.appendChild(newParsedValue);this.transformMarker(false);}}else if(attrName==='markerMid'){this.placeMarkerMid(newParsedValue);}};_proto.transformMarker=function transformMarker(isStart){var _this$parsedStyle2=this.parsedStyle,markerStart=_this$parsedStyle2.markerStart,markerEnd=_this$parsedStyle2.markerEnd,markerStartOffset=_this$parsedStyle2.markerStartOffset,markerEndOffset=_this$parsedStyle2.markerEndOffset,points=_this$parsedStyle2.points.points,defX=_this$parsedStyle2.defX,defY=_this$parsedStyle2.defY;var marker=isStart?markerStart:markerEnd;if(!marker||!isDisplayObject(marker)){return;}var rad=0;var x;var y;var ox;var oy;var offset;var originalAngle;ox=points[0][0]-defX;oy=points[0][1]-defY;if(isStart){x=points[1][0]-points[0][0];y=points[1][1]-points[0][1];offset=markerStartOffset||0;originalAngle=this.markerStartAngle;}else {var length=points.length;if(!this.style.isClosed){ox=points[length-1][0]-defX;oy=points[length-1][1]-defY;x=points[length-2][0]-points[length-1][0];y=points[length-2][1]-points[length-1][1];}else {x=points[length-1][0]-points[0][0];y=points[length-1][1]-points[0][1];}offset=markerEndOffset||0;originalAngle=this.markerEndAngle;}rad=Math.atan2(y,x);// account for markerOffset
8353
- marker.setLocalEulerAngles(rad*180/Math.PI+originalAngle);marker.setLocalPosition(ox+Math.cos(rad)*offset,oy+Math.sin(rad)*offset);};_proto.placeMarkerMid=function placeMarkerMid(marker){var _this$parsedStyle3=this.parsedStyle,points=_this$parsedStyle3.points.points,defX=_this$parsedStyle3.defX,defY=_this$parsedStyle3.defY;// clear all existed markers
8354
- this.markerMidList.forEach(function(marker){marker.remove();});this.markerMidList=[];if(marker&&isDisplayObject(marker)){for(var i=1;i<(this.style.isClosed?points.length:points.length-1);i++){var ox=points[i][0]-defX;var oy=points[i][1]-defY;var cloned=i===1?marker:marker.cloneNode(true);this.markerMidList.push(cloned);this.appendChild(cloned);cloned.setLocalPosition(ox,oy);// TODO: orient of marker
8355
- }}};return Polygon;}(DisplayObject);var _excluded$9=["style"];/**
8356
- * Polyline inherits the marker-related capabilities of Polygon.
8357
- */var Polyline=/*#__PURE__*/function(_Polygon){_inheritsLoose(Polyline,_Polygon);function Polyline(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$9);return _Polygon.call(this,_extends({type:exports.Shape.POLYLINE,style:_extends({points:'',miterLimit:'',isClosed:false},style)},rest))||this;}var _proto=Polyline.prototype;_proto.getTotalLength=function getTotalLength(){return this.parsedStyle.points.totalLength;};_proto.getPointAtLength=function getPointAtLength(distance,inWorldSpace){if(inWorldSpace===void 0){inWorldSpace=false;}return this.getPoint(distance/this.getTotalLength(),inWorldSpace);};_proto.getPoint=function getPoint(ratio,inWorldSpace){if(inWorldSpace===void 0){inWorldSpace=false;}var _this$parsedStyle=this.parsedStyle,defX=_this$parsedStyle.defX,defY=_this$parsedStyle.defY,_this$parsedStyle$poi=_this$parsedStyle.points,points=_this$parsedStyle$poi.points,segments=_this$parsedStyle$poi.segments;var subt=0;var index=0;segments.forEach(function(v,i){if(ratio>=v[0]&&ratio<=v[1]){subt=(ratio-v[0])/(v[1]-v[0]);index=i;}});var _LineUtil$pointAt=line.pointAt(points[index][0],points[index][1],points[index+1][0],points[index+1][1],subt),x=_LineUtil$pointAt.x,y=_LineUtil$pointAt.y;var transformed=transformMat4(create$2(),fromValues$2(x-defX,y-defY,0),inWorldSpace?this.getWorldTransform():this.getLocalTransform());// apply local transformation
8358
- return new Point(transformed[0],transformed[1]);};_proto.getStartTangent=function getStartTangent(){var points=this.parsedStyle.points.points;var result=[];result.push([points[1][0],points[1][1]]);result.push([points[0][0],points[0][1]]);return result;};_proto.getEndTangent=function getEndTangent(){var points=this.parsedStyle.points.points;var l=points.length-1;var result=[];result.push([points[l-1][0],points[l-1][1]]);result.push([points[l][0],points[l][1]]);return result;};return Polyline;}(Polygon);var _excluded$a=["style"];var Rect=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Rect,_DisplayObject);function Rect(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$a);return _DisplayObject.call(this,_extends({type:exports.Shape.RECT,style:_extends({x:'',y:'',width:'',height:'',radius:''},style)},rest))||this;}return Rect;}(DisplayObject);var _excluded$b=["style"];/**
8359
- * <text> @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextElement
8360
- */var Text=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Text,_DisplayObject);/**
8361
- * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement#constants
8362
- */ // LENGTHADJUST_SPACING: number = 1;
8363
- // LENGTHADJUST_SPACINGANDGLYPHS: number = 2;
8364
- // LENGTHADJUST_UNKNOWN: number = 0;
8365
- function Text(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$b);return _DisplayObject.call(this,_extends({type:exports.Shape.TEXT,style:_extends({x:'',y:'',text:'',fontSize:'',fontFamily:'',fontStyle:'',fontWeight:'',fontVariant:'',textAlign:'',textBaseline:'',textTransform:'',fill:'black',letterSpacing:'',lineHeight:'',miterLimit:'',// whiteSpace: 'pre',
8366
- wordWrap:false,wordWrapWidth:0,leading:0,dx:'',dy:''},style)},rest))||this;}// lengthAdjust: SVGAnimatedEnumeration;
8367
- // textLength: SVGAnimatedLength;
8368
- // getCharNumAtPosition(point?: DOMPointInit): number {
8369
- // throw new Error('Method not implemented.');
8370
- // }
8371
- /**
8372
- * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement
8373
- */var _proto=Text.prototype;_proto.getComputedTextLength=function getComputedTextLength(){var _this$parsedStyle$met;return ((_this$parsedStyle$met=this.parsedStyle.metrics)===null||_this$parsedStyle$met===void 0?void 0:_this$parsedStyle$met.maxLineWidth)||0;}// getEndPositionOfChar(charnum: number): DOMPoint {
8374
- // throw new Error('Method not implemented.');
8375
- // }
8376
- // getExtentOfChar(charnum: number): DOMRect {
8377
- // throw new Error('Method not implemented.');
8378
- // }
8379
- // getNumberOfChars(): number {
8380
- // throw new Error('Method not implemented.');
8381
- // }
8382
- // getRotationOfChar(charnum: number): number {
8383
- // throw new Error('Method not implemented.');
8384
- // }
8385
- // getStartPositionOfChar(charnum: number): DOMPoint {
8386
- // throw new Error('Method not implemented.');
8387
- // }
8388
- // getSubStringLength(charnum: number, nchars: number): number {
8389
- // throw new Error('Method not implemented.');
8390
- // }
8391
- // selectSubString(charnum: number, nchars: number): void {
8392
- // throw new Error('Method not implemented.');
8393
- // }
8394
- ;_proto.getLineBoundingRects=function getLineBoundingRects(){var _this$parsedStyle$met2;return ((_this$parsedStyle$met2=this.parsedStyle.metrics)===null||_this$parsedStyle$met2===void 0?void 0:_this$parsedStyle$met2.lineMetrics)||[];};_proto.isOverflowing=function isOverflowing(){return !!this.parsedStyle.isOverflowing;};return Text;}(DisplayObject);function copyVec3(a,b){a[0]=b[0];a[1]=b[1];a[2]=b[2];return a;}function subVec3(o,a,b){o[0]=a[0]-b[0];o[1]=a[1]-b[1];o[2]=a[2]-b[2];return o;}function addVec3(o,a,b){o[0]=a[0]+b[0];o[1]=a[1]+b[1];o[2]=a[2]+b[2];return o;}function scaleVec3(o,a,b){o[0]=a[0]*b;o[1]=a[1]*b;o[2]=a[2]*b;return o;}function maxVec3(o,a,b){o[0]=Math.max(a[0],b[0]);o[1]=Math.max(a[1],b[1]);o[2]=Math.max(a[2],b[2]);return o;}function minVec3(o,a,b){o[0]=Math.min(a[0],b[0]);o[1]=Math.min(a[1],b[1]);o[2]=Math.min(a[2],b[2]);return o;}function getAngle$1(angle){if(angle===undefined){return 0;}else if(angle>360||angle<-360){return angle%360;}return angle;}function createVec3(x,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}if(isNumber(x)){return fromValues$2(x,y,z);}if(Array.isArray(x)&&x.length===3){return clone$1(x);}return fromValues$2(x[0],x[1]||y,x[2]||z);}function deg2rad(deg){return deg*(Math.PI/180);}function rad2deg(rad){return rad*(180/Math.PI);}function grad2deg(grads){grads=grads%400;if(grads<0){grads+=400;}return grads/400*360;}function deg2turn(deg){return deg/360;}function turn2deg(turn){return 360*turn;}function getEulerFromQuat(out,quat){var x=quat[0];var y=quat[1];var z=quat[2];var w=quat[3];var x2=x*x;var y2=y*y;var z2=z*z;var w2=w*w;var unit=x2+y2+z2+w2;var test=x*w-y*z;if(test>0.499995*unit){// TODO: Use glmatrix.EPSILON
8395
- // singularity at the north pole
8396
- out[0]=Math.PI/2;out[1]=2*Math.atan2(y,x);out[2]=0;}else if(test<-0.499995*unit){//TODO: Use glmatrix.EPSILON
8397
- // singularity at the south pole
8398
- out[0]=-Math.PI/2;out[1]=2*Math.atan2(y,x);out[2]=0;}else {out[0]=Math.asin(2*(x*z-w*y));out[1]=Math.atan2(2*(x*w+y*z),1-2*(z2+w2));out[2]=Math.atan2(2*(x*y+z*w),1-2*(y2+z2));}// TODO: Return them as degrees and not as radians
8399
- return out;}function getEulerFromMat4(out,m){var x;var z;var halfPi=Math.PI*0.5;var _mat4$getScaling=getScaling(create$2(),m),sx=_mat4$getScaling[0],sy=_mat4$getScaling[1],sz=_mat4$getScaling[2];var y=Math.asin(-m[2]/sx);if(y<halfPi){if(y>-halfPi){x=Math.atan2(m[6]/sy,m[10]/sz);z=Math.atan2(m[1]/sx,m[0]/sx);}else {// Not a unique solution
8400
- z=0;x=-Math.atan2(m[4]/sy,m[5]/sy);}}else {// Not a unique solution
8401
- z=0;x=Math.atan2(m[4]/sy,m[5]/sy);}out[0]=x;out[1]=y;out[2]=z;return out;}/**
8402
- * @see https://github.com/toji/gl-matrix/issues/329
8403
- * @see https://doc.babylonjs.com/divingDeeper/mesh/transforms/center_origin/rotation_conventions
8404
- */function getEuler(out,quat){if(quat.length===16){return getEulerFromMat4(out,quat);}else {return getEulerFromQuat(out,quat);}}function fromRotationTranslationScale$1(rotation,x,y,scaleX,scaleY){var cos=Math.cos(rotation);var sin=Math.sin(rotation);return fromValues(scaleX*cos,scaleY*sin,0,-scaleX*sin,scaleY*cos,0,x,y,1);}function makePerspective(out,left,right,top,bottom,near,far){var x=2*near/(right-left);var y=2*near/(top-bottom);var a=(right+left)/(right-left);var b=(top+bottom)/(top-bottom);var c=-(far+near)/(far-near);var d=-2*far*near/(far-near);out[0]=x;out[1]=0;out[2]=0;out[3]=0;out[4]=0;out[5]=y;out[6]=0;out[7]=0;out[8]=a;out[9]=b;out[10]=c;out[11]=-1;out[12]=0;out[13]=0;out[14]=d;out[15]=0;return out;}function decompose(mat){var row0x=mat[0];var row0y=mat[1];var row1x=mat[3];var row1y=mat[4];// decompose 3x3 matrix
8405
- // @see https://www.w3.org/TR/css-transforms-1/#decomposing-a-2d-matrix
8406
- var scalingX=Math.sqrt(row0x*row0x+row0y*row0y);var scalingY=Math.sqrt(row1x*row1x+row1y*row1y);// If determinant is negative, one axis was flipped.
8407
- var determinant=row0x*row1y-row0y*row1x;if(determinant<0){// Flip axis with minimum unit vector dot product.
8408
- if(row0x<row1y){scalingX=-scalingX;}else {scalingY=-scalingY;}}// Renormalize matrix to remove scale.
8409
- if(scalingX){row0x*=1/scalingX;row0y*=1/scalingX;}if(scalingY){row1x*=1/scalingY;row1y*=1/scalingY;}// Compute rotation and renormalize matrix.
8410
- var rotation=Math.atan2(row0y,row0x);var angle=rad2deg(rotation);return [mat[6],mat[7],scalingX,scalingY,angle];}var tmp=create$1();var perspectiveMatrix=create$1();var tmpVec4=create$3();var row=[create$2(),create$2(),create$2()];var pdum3=create$2();/*
8411
- Input: matrix ; a 4x4 matrix
8412
- Output: translation ; a 3 component vector
8413
- scale ; a 3 component vector
8414
- skew ; skew factors XY,XZ,YZ represented as a 3 component vector
8415
- perspective ; a 4 component vector
8416
- quaternion ; a 4 component vector
8417
- Returns false if the matrix cannot be decomposed, true if it can
8418
-
8419
-
8420
- References:
8421
- https://github.com/kamicane/matrix3d/blob/master/lib/Matrix3d.js
8422
- https://github.com/ChromiumWebApps/chromium/blob/master/ui/gfx/transform_util.cc
8423
- http://www.w3.org/TR/css3-transforms/#decomposing-a-3d-matrix
8424
- */function decomposeMat4(matrix,translation,scale,skew,perspective,quaternion){//normalize, if not possible then bail out early
8425
- if(!normalize$4(tmp,matrix))return false;// perspectiveMatrix is used to solve for perspective, but it also provides
8426
- // an easy way to test for singularity of the upper 3x3 component.
8427
- copy(perspectiveMatrix,tmp);perspectiveMatrix[3]=0;perspectiveMatrix[7]=0;perspectiveMatrix[11]=0;perspectiveMatrix[15]=1;// If the perspectiveMatrix is not invertible, we are also unable to
8428
- // decompose, so we'll bail early. Constant taken from SkMatrix44::invert.
8429
- if(Math.abs(determinant(perspectiveMatrix))<1e-8)return false;var a03=tmp[3],a13=tmp[7],a23=tmp[11],a30=tmp[12],a31=tmp[13],a32=tmp[14],a33=tmp[15];// First, isolate perspective.
8430
- if(a03!==0||a13!==0||a23!==0){tmpVec4[0]=a03;tmpVec4[1]=a13;tmpVec4[2]=a23;tmpVec4[3]=a33;// Solve the equation by inverting perspectiveMatrix and multiplying
8431
- // rightHandSide by the inverse.
8432
- // resuing the perspectiveMatrix here since it's no longer needed
8433
- var ret=invert(perspectiveMatrix,perspectiveMatrix);if(!ret)return false;transpose(perspectiveMatrix,perspectiveMatrix);//multiply by transposed inverse perspective matrix, into perspective vec4
8434
- transformMat4$1(perspective,tmpVec4,perspectiveMatrix);}else {//no perspective
8435
- perspective[0]=perspective[1]=perspective[2]=0;perspective[3]=1;}// Next take care of translation
8436
- translation[0]=a30;translation[1]=a31;translation[2]=a32;// Now get scale and shear. 'row' is a 3 element array of 3 component vectors
8437
- mat3from4(row,tmp);// Compute X scale factor and normalize first row.
8438
- scale[0]=length(row[0]);normalize(row[0],row[0]);// Compute XY shear factor and make 2nd row orthogonal to 1st.
8439
- skew[0]=dot(row[0],row[1]);combine(row[1],row[1],row[0],1.0,-skew[0]);// Now, compute Y scale and normalize 2nd row.
8440
- scale[1]=length(row[1]);normalize(row[1],row[1]);skew[0]/=scale[1];// Compute XZ and YZ shears, orthogonalize 3rd row
8441
- skew[1]=dot(row[0],row[2]);combine(row[2],row[2],row[0],1.0,-skew[1]);skew[2]=dot(row[1],row[2]);combine(row[2],row[2],row[1],1.0,-skew[2]);// Next, get Z scale and normalize 3rd row.
8442
- scale[2]=length(row[2]);normalize(row[2],row[2]);skew[1]/=scale[2];skew[2]/=scale[2];// At this point, the matrix (in rows) is orthonormal.
8443
- // Check for a coordinate system flip. If the determinant
8444
- // is -1, then negate the matrix and the scaling factors.
8445
- cross(pdum3,row[1],row[2]);if(dot(row[0],pdum3)<0){for(var i=0;i<3;i++){scale[i]*=-1;row[i][0]*=-1;row[i][1]*=-1;row[i][2]*=-1;}}// Now, get the rotations out
8446
- quaternion[0]=0.5*Math.sqrt(Math.max(1+row[0][0]-row[1][1]-row[2][2],0));quaternion[1]=0.5*Math.sqrt(Math.max(1-row[0][0]+row[1][1]-row[2][2],0));quaternion[2]=0.5*Math.sqrt(Math.max(1-row[0][0]-row[1][1]+row[2][2],0));quaternion[3]=0.5*Math.sqrt(Math.max(1+row[0][0]+row[1][1]+row[2][2],0));if(row[2][1]>row[1][2])quaternion[0]=-quaternion[0];if(row[0][2]>row[2][0])quaternion[1]=-quaternion[1];if(row[1][0]>row[0][1])quaternion[2]=-quaternion[2];return true;}function normalize$4(out,mat){var m44=mat[15];// Cannot normalize.
8447
- if(m44===0)return false;var scale=1/m44;for(var i=0;i<16;i++){out[i]=mat[i]*scale;}return true;}//gets upper-left of a 4x4 matrix into a 3x3 of vectors
8448
- function mat3from4(out,mat4x4){out[0][0]=mat4x4[0];out[0][1]=mat4x4[1];out[0][2]=mat4x4[2];out[1][0]=mat4x4[4];out[1][1]=mat4x4[5];out[1][2]=mat4x4[6];out[2][0]=mat4x4[8];out[2][1]=mat4x4[9];out[2][2]=mat4x4[10];}function combine(out,a,b,scale1,scale2){out[0]=a[0]*scale1+b[0]*scale2;out[1]=a[1]*scale1+b[1]*scale2;out[2]=a[2]*scale1+b[2]*scale2;}var tmpMat4=create$1();function parsedTransformToMat4(transform,object){if(transform&&transform.length){var defX=0;var defY=0;if(object){defX=object.parsedStyle.defX||0;defY=object.parsedStyle.defY||0;// reset transform
8449
- object.resetLocalTransform();object.setLocalPosition(defX,defY);}else {object=new DisplayObject({});}transform.forEach(function(parsed){var t=parsed.t,d=parsed.d;if(t==='scale'){// scale(1) scale(1, 1)
8450
- var newScale=(d===null||d===void 0?void 0:d.map(function(s){return s.value;}))||[1,1];object.scaleLocal(newScale[0],newScale[1],1);}else if(t==='scalex'){var _newScale=(d===null||d===void 0?void 0:d.map(function(s){return s.value;}))||[1];object.scaleLocal(_newScale[0],1,1);}else if(t==='scaley'){var _newScale2=(d===null||d===void 0?void 0:d.map(function(s){return s.value;}))||[1];object.scaleLocal(1,_newScale2[0],1);}else if(t==='scalez'){var _newScale3=(d===null||d===void 0?void 0:d.map(function(s){return s.value;}))||[1];object.scaleLocal(1,1,_newScale3[0]);}else if(t==='scale3d'){var _newScale4=(d===null||d===void 0?void 0:d.map(function(s){return s.value;}))||[1,1,1];object.scaleLocal(_newScale4[0],_newScale4[1],_newScale4[2]);}else if(t==='translate'){var newTranslation=d||[Opx,Opx];object.translateLocal(newTranslation[0].value,newTranslation[1].value,0);}else if(t==='translatex'){var _newTranslation=d||[Opx];object.translateLocal(_newTranslation[0].value,0,0);}else if(t==='translatey'){var _newTranslation2=d||[Opx];object.translateLocal(0,_newTranslation2[0].value,0);}else if(t==='translatez'){var _newTranslation3=d||[Opx];object.translateLocal(0,0,_newTranslation3[0].value);}else if(t==='translate3d'){var _newTranslation4=d||[Opx,Opx,Opx];object.translateLocal(_newTranslation4[0].value,_newTranslation4[1].value,_newTranslation4[2].value);}else if(t==='rotate'){var newAngles=d||[Odeg];object.rotateLocal(0,0,convertAngleUnit(newAngles[0]));}else if(t==='rotatex'){var _newAngles=d||[Odeg];object.rotateLocal(convertAngleUnit(_newAngles[0]),0,0);}else if(t==='rotatey'){var _newAngles2=d||[Odeg];object.rotateLocal(0,convertAngleUnit(_newAngles2[0]),0);}else if(t==='rotatez'){var _newAngles3=d||[Odeg];object.rotateLocal(0,0,convertAngleUnit(_newAngles3[0]));}else if(t==='rotate3d');else if(t==='skew'){var newSkew=(d===null||d===void 0?void 0:d.map(function(s){return s.value;}))||[0,0];object.setLocalSkew(deg2rad(newSkew[0]),deg2rad(newSkew[1]));}else if(t==='skewx'){var _newSkew=(d===null||d===void 0?void 0:d.map(function(s){return s.value;}))||[0];object.setLocalSkew(deg2rad(_newSkew[0]),object.getLocalSkew()[1]);}else if(t==='skewy'){var _newSkew2=(d===null||d===void 0?void 0:d.map(function(s){return s.value;}))||[0];object.setLocalSkew(object.getLocalSkew()[0],deg2rad(_newSkew2[0]));}else if(t==='matrix'){var _d$map=d.map(function(s){return s.value;}),a=_d$map[0],b=_d$map[1],c=_d$map[2],dd=_d$map[3],tx=_d$map[4],ty=_d$map[5];object.setLocalTransform(set(tmpMat4,a,b,0,0,c,dd,0,0,0,0,1,0,tx+defX,ty+defY,0,1));}else if(t==='matrix3d'){// @ts-ignore
8451
- set.apply(mat4,[tmpMat4].concat(d.map(function(s){return s.value;})));tmpMat4[12]+=defX;tmpMat4[13]+=defY;object.setLocalTransform(tmpMat4);}});}return object.getLocalTransform();}/**
8452
- * borrow from gradient-parser, but we delete some browser compatible prefix such as `-webkit-`
8453
- * @see https://github.com/rafaelcaricio/gradient-parser
8454
- */function colorStopToString(colorStop){var type=colorStop.type,value=colorStop.value;if(type==='hex'){return "#"+value;}else if(type==='literal'){return value;}else if(type==='rgb'){return "rgb("+value.join(',')+")";}else {return "rgba("+value.join(',')+")";}}var parseGradient$1=function(){var tokens={linearGradient:/^(linear\-gradient)/i,repeatingLinearGradient:/^(repeating\-linear\-gradient)/i,radialGradient:/^(radial\-gradient)/i,repeatingRadialGradient:/^(repeating\-radial\-gradient)/i,/**
8455
- * @see https://projects.verou.me/conic-gradient/
8456
- */conicGradient:/^(conic\-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,percentageValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,emValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,angleValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^\#([0-9a-fA-F]+)/,literalColor:/^([a-zA-Z]+)/,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,number:/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/};var input='';function error(msg){throw new Error(input+': '+msg);}function getAST(){var ast=matchListDefinitions();if(input.length>0){error('Invalid input not EOF');}return ast;}function matchListDefinitions(){return matchListing(matchDefinition);}function matchDefinition(){return matchGradient('linear-gradient',tokens.linearGradient,matchLinearOrientation)||matchGradient('repeating-linear-gradient',tokens.repeatingLinearGradient,matchLinearOrientation)||matchGradient('radial-gradient',tokens.radialGradient,matchListRadialOrientations)||matchGradient('repeating-radial-gradient',tokens.repeatingRadialGradient,matchListRadialOrientations)||matchGradient('conic-gradient',tokens.conicGradient,matchListRadialOrientations);}function matchGradient(gradientType,pattern,orientationMatcher){return matchCall(pattern,function(captures){var orientation=orientationMatcher();if(orientation){if(!scan(tokens.comma)){error('Missing comma before color stops');}}return {type:gradientType,orientation:orientation,colorStops:matchListing(matchColorStop)};});}function matchCall(pattern,callback){var captures=scan(pattern);if(captures){if(!scan(tokens.startCall)){error('Missing (');}var result=callback(captures);if(!scan(tokens.endCall)){error('Missing )');}return result;}}function matchLinearOrientation(){return matchSideOrCorner()||matchAngle();}function matchSideOrCorner(){return match('directional',tokens.sideOrCorner,1);}function matchAngle(){return match('angular',tokens.angleValue,1);}function matchListRadialOrientations(){var radialOrientations,radialOrientation=matchRadialOrientation(),lookaheadCache;if(radialOrientation){radialOrientations=[];radialOrientations.push(radialOrientation);lookaheadCache=input;if(scan(tokens.comma)){radialOrientation=matchRadialOrientation();if(radialOrientation){radialOrientations.push(radialOrientation);}else {input=lookaheadCache;}}}return radialOrientations;}function matchRadialOrientation(){var radialType=matchCircle()||matchEllipse();if(radialType){// @ts-ignore
8457
- radialType.at=matchAtPosition();}else {var extent=matchExtentKeyword();if(extent){radialType=extent;var positionAt=matchAtPosition();if(positionAt){// @ts-ignore
8458
- radialType.at=positionAt;}}else {var defaultPosition=matchPositioning();if(defaultPosition){radialType={type:'default-radial',// @ts-ignore
8459
- at:defaultPosition};}}}return radialType;}function matchCircle(){var circle=match('shape',/^(circle)/i,0);if(circle){// @ts-ignore
8460
- circle.style=matchLength()||matchExtentKeyword();}return circle;}function matchEllipse(){var ellipse=match('shape',/^(ellipse)/i,0);if(ellipse){// @ts-ignore
8461
- ellipse.style=matchDistance()||matchExtentKeyword();}return ellipse;}function matchExtentKeyword(){return match('extent-keyword',tokens.extentKeywords,1);}function matchAtPosition(){if(match('position',/^at/,0)){var positioning=matchPositioning();if(!positioning){error('Missing positioning value');}return positioning;}}function matchPositioning(){var location=matchCoordinates();if(location.x||location.y){return {type:'position',value:location};}}function matchCoordinates(){return {x:matchDistance(),y:matchDistance()};}function matchListing(matcher){var captures=matcher();var result=[];if(captures){result.push(captures);while(scan(tokens.comma)){captures=matcher();if(captures){result.push(captures);}else {error('One extra comma');}}}return result;}function matchColorStop(){var color=matchColor();if(!color){error('Expected color definition');}color.length=matchDistance();return color;}function matchColor(){return matchHexColor()||matchRGBAColor()||matchRGBColor()||matchLiteralColor();}function matchLiteralColor(){return match('literal',tokens.literalColor,0);}function matchHexColor(){return match('hex',tokens.hexColor,1);}function matchRGBColor(){return matchCall(tokens.rgbColor,function(){return {type:'rgb',value:matchListing(matchNumber)};});}function matchRGBAColor(){return matchCall(tokens.rgbaColor,function(){return {type:'rgba',value:matchListing(matchNumber)};});}function matchNumber(){return scan(tokens.number)[1];}function matchDistance(){return match('%',tokens.percentageValue,1)||matchPositionKeyword()||matchLength();}function matchPositionKeyword(){return match('position-keyword',tokens.positionKeywords,1);}function matchLength(){return match('px',tokens.pixelValue,1)||match('em',tokens.emValue,1);}function match(type,pattern,captureIndex){var captures=scan(pattern);if(captures){return {type:type,value:captures[captureIndex]};}}function scan(regexp){var blankCaptures=/^[\n\r\t\s]+/.exec(input);if(blankCaptures){consume(blankCaptures[0].length);}var captures=regexp.exec(input);if(captures){consume(captures[0].length);}return captures;}function consume(size){input=input.substring(size);}return function(code){input=code;return getAST();};}();function computeLinearGradient(width,height,angle){var rad=deg2rad(angle.value);var rx=0;var ry=0;var rcx=rx+width/2;var rcy=ry+height/2;// get the length of gradient line
8462
- // @see https://observablehq.com/@danburzo/css-gradient-line
8463
- var length=Math.abs(width*Math.cos(rad))+Math.abs(height*Math.sin(rad));var x1=rcx-Math.cos(rad)*length/2;var y1=rcy-Math.sin(rad)*length/2;var x2=rcx+Math.cos(rad)*length/2;var y2=rcy+Math.sin(rad)*length/2;return {x1:x1,y1:y1,x2:x2,y2:y2};}function computeRadialGradient(width,height,cx,cy,size){// 'px'
8464
- var x=cx.value;var y=cy.value;// TODO: 'em'
8465
- // '%'
8466
- if(cx.unit===exports.UnitType.kPercentage){x=cx.value/100*width;}if(cy.unit===exports.UnitType.kPercentage){y=cy.value/100*height;}// default to farthest-side
8467
- var r=Math.max(distanceSquareRoot([0,0],[x,y]),distanceSquareRoot([0,height],[x,y]),distanceSquareRoot([width,height],[x,y]),distanceSquareRoot([width,0],[x,y]));if(size){if(size instanceof CSSUnitValue){r=size.value;}else if(size instanceof CSSKeywordValue){// @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/CSS_Images/Using_CSS_gradients#example_closest-side_for_circles
8468
- if(size.value==='closest-side'){r=Math.min(x,width-x,y,height-y);}else if(size.value==='farthest-side'){r=Math.max(x,width-x,y,height-y);}else if(size.value==='closest-corner'){r=Math.min(distanceSquareRoot([0,0],[x,y]),distanceSquareRoot([0,height],[x,y]),distanceSquareRoot([width,height],[x,y]),distanceSquareRoot([width,0],[x,y]));}}}return {x:x,y:y,r:r};}function getOrCalculatePathTotalLength(path){if(path.parsedStyle.path.totalLength===0){path.parsedStyle.path.totalLength=getTotalLength(path.parsedStyle.path.absolutePath);}return path.parsedStyle.path.totalLength;}function hasArcOrBezier(path){var hasArc=false;var count=path.length;for(var i=0;i<count;i++){var params=path[i];var cmd=params[0];if(cmd==='C'||cmd==='A'||cmd==='Q'){hasArc=true;break;}}return hasArc;}function extractPolygons(pathArray){var polygons=[];var polylines=[];var points=[];// 防止第一个命令不是 'M'
8469
- for(var i=0;i<pathArray.length;i++){var params=pathArray[i];var cmd=params[0];if(cmd==='M'){// 遇到 'M' 判定是否是新数组,新数组中没有点
8470
- if(points.length){// 如果存在点,则说明没有遇到 'Z',开始了一个新的多边形
8471
- polylines.push(points);points=[];// 创建新的点
8472
- }points.push([params[1],params[2]]);}else if(cmd==='Z'){if(points.length){// 存在点
8473
- polygons.push(points);points=[];// 开始新的点集合
8474
- }// 如果不存在点,同时 'Z',则说明是错误,不处理
8475
- }else {points.push([params[1],params[2]]);}}// 说明 points 未放入 polygons 或者 polyline
8476
- // 仅当只有一个 M,没有 Z 时会发生这种情况
8477
- if(points.length>0){polylines.push(points);}return {polygons:polygons,polylines:polylines};}function isSamePoint(point1,point2){return point1[0]===point2[0]&&point1[1]===point2[1];}function getPathBBox(segments,lineWidth){var xArr=[];var yArr=[];var segmentsWithAngle=[];for(var i=0;i<segments.length;i++){var segment=segments[i];var currentPoint=segment.currentPoint,params=segment.params,prePoint=segment.prePoint;var box=void 0;switch(segment.command){case'Q':box=quadratic.box(prePoint[0],prePoint[1],params[1],params[2],params[3],params[4]);break;case'C':box=cubic.box(prePoint[0],prePoint[1],params[1],params[2],params[3],params[4],params[5],params[6]);break;case'A':var arcParams=segment.arcParams;box=arc.box(arcParams.cx,arcParams.cy,arcParams.rx,arcParams.ry,arcParams.xRotation,arcParams.startAngle,arcParams.endAngle);break;default:xArr.push(currentPoint[0]);yArr.push(currentPoint[1]);break;}if(box){segment.box=box;xArr.push(box.x,box.x+box.width);yArr.push(box.y,box.y+box.height);}if(lineWidth&&(segment.command==='L'||segment.command==='M')&&segment.prePoint&&segment.nextPoint){segmentsWithAngle.push(segment);}}// bbox calculation should ignore NaN for path attribute
8478
- // ref: https://github.com/antvis/g/issues/210
8479
- // ref: https://github.com/antvis/G2/issues/3109
8480
- xArr=xArr.filter(function(item){return !Number.isNaN(item)&&item!==Infinity&&item!==-Infinity;});yArr=yArr.filter(function(item){return !Number.isNaN(item)&&item!==Infinity&&item!==-Infinity;});var minX=min(xArr);var minY=min(yArr);var maxX=max(xArr);var maxY=max(yArr);if(segmentsWithAngle.length===0){return {x:minX,y:minY,width:maxX-minX,height:maxY-minY};}for(var _i=0;_i<segmentsWithAngle.length;_i++){var _segment=segmentsWithAngle[_i];var _currentPoint=_segment.currentPoint;var extra=void 0;if(_currentPoint[0]===minX){extra=getExtraFromSegmentWithAngle(_segment,lineWidth);minX=minX-extra.xExtra;}else if(_currentPoint[0]===maxX){extra=getExtraFromSegmentWithAngle(_segment,lineWidth);maxX=maxX+extra.xExtra;}if(_currentPoint[1]===minY){extra=getExtraFromSegmentWithAngle(_segment,lineWidth);minY=minY-extra.yExtra;}else if(_currentPoint[1]===maxY){extra=getExtraFromSegmentWithAngle(_segment,lineWidth);maxY=maxY+extra.yExtra;}}return {x:minX,y:minY,width:maxX-minX,height:maxY-minY};}function getExtraFromSegmentWithAngle(segment,lineWidth){var prePoint=segment.prePoint,currentPoint=segment.currentPoint,nextPoint=segment.nextPoint;var currentAndPre=Math.pow(currentPoint[0]-prePoint[0],2)+Math.pow(currentPoint[1]-prePoint[1],2);var currentAndNext=Math.pow(currentPoint[0]-nextPoint[0],2)+Math.pow(currentPoint[1]-nextPoint[1],2);var preAndNext=Math.pow(prePoint[0]-nextPoint[0],2)+Math.pow(prePoint[1]-nextPoint[1],2);// 以 currentPoint 为顶点的夹角
8481
- var currentAngle=Math.acos((currentAndPre+currentAndNext-preAndNext)/(2*Math.sqrt(currentAndPre)*Math.sqrt(currentAndNext)));// 夹角为空、 0 或 PI 时,不需要计算夹角处的额外宽度
8482
- // 注意: 由于计算精度问题,夹角为 0 的情况计算出来的角度可能是一个很小的值,还需要判断其与 0 是否近似相等
8483
- if(!currentAngle||Math.sin(currentAngle)===0||isNumberEqual(currentAngle,0)){return {xExtra:0,yExtra:0};}var xAngle=Math.abs(Math.atan2(nextPoint[1]-currentPoint[1],nextPoint[0]-currentPoint[0]));var yAngle=Math.abs(Math.atan2(nextPoint[0]-currentPoint[0],nextPoint[1]-currentPoint[1]));// 将夹角转为锐角
8484
- xAngle=xAngle>Math.PI/2?Math.PI-xAngle:xAngle;yAngle=yAngle>Math.PI/2?Math.PI-yAngle:yAngle;// 这里不考虑在水平和垂直方向的投影,直接使用最大差值
8485
- // 由于上层统一加减了二分之一线宽,这里需要进行弥补
8486
- var extra={// 水平方向投影
8487
- xExtra:Math.cos(currentAngle/2-xAngle)*(lineWidth/2*(1/Math.sin(currentAngle/2)))-lineWidth/2||0,// 垂直方向投影
8488
- yExtra:Math.cos(yAngle-currentAngle/2)*(lineWidth/2*(1/Math.sin(currentAngle/2)))-lineWidth/2||0};return extra;}// 点对称
8489
- function toSymmetry(point,center){return [center[0]+(center[0]-point[0]),center[1]+(center[1]-point[1])];}var angleBetween$1=function angleBetween(v0,v1){var p=v0.x*v1.x+v0.y*v1.y;var n=Math.sqrt((Math.pow(v0.x,2)+Math.pow(v0.y,2))*(Math.pow(v1.x,2)+Math.pow(v1.y,2)));var sign=v0.x*v1.y-v0.y*v1.x<0?-1:1;var angle=sign*Math.acos(p/n);return angle;};/**
8490
- * @see https://github.com/rveciana/svg-path-properties/blob/b6bd9a322966f6ef7a311872d80c56e3718de861/src/arc.ts#L121
8491
- */var pointOnEllipticalArc=function pointOnEllipticalArc(p0,rx,ry,xAxisRotation,largeArcFlag,sweepFlag,p1,t){// In accordance to: http://www.w3.org/TR/SVG/implnote.html#ArcOutOfRangeParameters
8492
- rx=Math.abs(rx);ry=Math.abs(ry);xAxisRotation=mod(xAxisRotation,360);var xAxisRotationRadians=deg2rad(xAxisRotation);// If the endpoints are identical, then this is equivalent to omitting the elliptical arc segment entirely.
8493
- if(p0.x===p1.x&&p0.y===p1.y){return {x:p0.x,y:p0.y,ellipticalArcAngle:0};// Check if angle is correct
8494
- }// If rx = 0 or ry = 0 then this arc is treated as a straight line segment joining the endpoints.
8495
- if(rx===0||ry===0){//return this.pointOnLine(p0, p1, t);
8496
- return {x:0,y:0,ellipticalArcAngle:0};// Check if angle is correct
8497
- }// Following "Conversion from endpoint to center parameterization"
8498
- // http://www.w3.org/TR/SVG/implnote.html#ArcConversionEndpointToCenter
8499
- // Step #1: Compute transformedPoint
8500
- var dx=(p0.x-p1.x)/2;var dy=(p0.y-p1.y)/2;var transformedPoint={x:Math.cos(xAxisRotationRadians)*dx+Math.sin(xAxisRotationRadians)*dy,y:-Math.sin(xAxisRotationRadians)*dx+Math.cos(xAxisRotationRadians)*dy};// Ensure radii are large enough
8501
- var radiiCheck=Math.pow(transformedPoint.x,2)/Math.pow(rx,2)+Math.pow(transformedPoint.y,2)/Math.pow(ry,2);if(radiiCheck>1){rx=Math.sqrt(radiiCheck)*rx;ry=Math.sqrt(radiiCheck)*ry;}// Step #2: Compute transformedCenter
8502
- var cSquareNumerator=Math.pow(rx,2)*Math.pow(ry,2)-Math.pow(rx,2)*Math.pow(transformedPoint.y,2)-Math.pow(ry,2)*Math.pow(transformedPoint.x,2);var cSquareRootDenom=Math.pow(rx,2)*Math.pow(transformedPoint.y,2)+Math.pow(ry,2)*Math.pow(transformedPoint.x,2);var cRadicand=cSquareNumerator/cSquareRootDenom;// Make sure this never drops below zero because of precision
8503
- cRadicand=cRadicand<0?0:cRadicand;var cCoef=(largeArcFlag!==sweepFlag?1:-1)*Math.sqrt(cRadicand);var transformedCenter={x:cCoef*(rx*transformedPoint.y/ry),y:cCoef*(-(ry*transformedPoint.x)/rx)};// Step #3: Compute center
8504
- var center={x:Math.cos(xAxisRotationRadians)*transformedCenter.x-Math.sin(xAxisRotationRadians)*transformedCenter.y+(p0.x+p1.x)/2,y:Math.sin(xAxisRotationRadians)*transformedCenter.x+Math.cos(xAxisRotationRadians)*transformedCenter.y+(p0.y+p1.y)/2};// Step #4: Compute start/sweep angles
8505
- // Start angle of the elliptical arc prior to the stretch and rotate operations.
8506
- // Difference between the start and end angles
8507
- var startVector={x:(transformedPoint.x-transformedCenter.x)/rx,y:(transformedPoint.y-transformedCenter.y)/ry};var startAngle=angleBetween$1({x:1,y:0},startVector);var endVector={x:(-transformedPoint.x-transformedCenter.x)/rx,y:(-transformedPoint.y-transformedCenter.y)/ry};var sweepAngle=angleBetween$1(startVector,endVector);if(!sweepFlag&&sweepAngle>0){sweepAngle-=2*Math.PI;}else if(sweepFlag&&sweepAngle<0){sweepAngle+=2*Math.PI;}// We use % instead of `mod(..)` because we want it to be -360deg to 360deg(but actually in radians)
8508
- sweepAngle%=2*Math.PI;// From http://www.w3.org/TR/SVG/implnote.html#ArcParameterizationAlternatives
8509
- var angle=startAngle+sweepAngle*t;var ellipseComponentX=rx*Math.cos(angle);var ellipseComponentY=ry*Math.sin(angle);var point={x:Math.cos(xAxisRotationRadians)*ellipseComponentX-Math.sin(xAxisRotationRadians)*ellipseComponentY+center.x,y:Math.sin(xAxisRotationRadians)*ellipseComponentX+Math.cos(xAxisRotationRadians)*ellipseComponentY+center.y,ellipticalArcStartAngle:startAngle,ellipticalArcEndAngle:startAngle+sweepAngle,ellipticalArcAngle:angle,ellipticalArcCenter:center,resultantRx:rx,resultantRy:ry};return point;};function path2Segments(path){var segments=[];var currentPoint=null;// 当前图形
8510
- var nextParams=null;// 下一节点的 path 参数
8511
- var startMovePoint=null;// 开始 M 的点,可能会有多个
8512
- var lastStartMovePointIndex=0;// 最近一个开始点 M 的索引
8513
- var count=path.length;for(var i=0;i<count;i++){var params=path[i];nextParams=path[i+1];var command=params[0];// 数学定义上的参数,便于后面的计算
8514
- var segment={command:command,prePoint:currentPoint,params:params,startTangent:null,endTangent:null,currentPoint:null,nextPoint:null,arcParams:null,box:null,cubicParams:null};switch(command){case'M':startMovePoint=[params[1],params[2]];lastStartMovePointIndex=i;break;case'A':var arcParams=getArcParams(currentPoint,params);segment.arcParams=arcParams;break;}if(command==='Z'){// 有了 Z 后,当前节点从开始 M 的点开始
8515
- currentPoint=startMovePoint;// 如果当前点的命令为 Z,相当于当前点为最近一个 M 点,则下一个点直接指向最近一个 M 点的下一个点
8516
- nextParams=path[lastStartMovePointIndex+1];}else {var len=params.length;currentPoint=[params[len-2],params[len-1]];}if(nextParams&&nextParams[0]==='Z'){// 如果下一个点的命令为 Z,则下一个点直接指向最近一个 M 点
8517
- nextParams=path[lastStartMovePointIndex];if(segments[lastStartMovePointIndex]){// 如果下一个点的命令为 Z,则最近一个 M 点的前一个点为当前点
8518
- segments[lastStartMovePointIndex].prePoint=currentPoint;}}segment.currentPoint=currentPoint;// 如果当前点与最近一个 M 点相同,则最近一个 M 点的前一个点为当前点的前一个点
8519
- if(segments[lastStartMovePointIndex]&&isSamePoint(currentPoint,segments[lastStartMovePointIndex].currentPoint)){segments[lastStartMovePointIndex].prePoint=segment.prePoint;}var nextPoint=nextParams?[nextParams[nextParams.length-2],nextParams[nextParams.length-1]]:null;segment.nextPoint=nextPoint;// Add startTangent and endTangent
8520
- var prePoint=segment.prePoint;if(['L','H','V'].includes(command)){segment.startTangent=[prePoint[0]-currentPoint[0],prePoint[1]-currentPoint[1]];segment.endTangent=[currentPoint[0]-prePoint[0],currentPoint[1]-prePoint[1]];}else if(command==='Q'){// 二次贝塞尔曲线只有一个控制点
8521
- var cp=[params[1],params[2]];// 二次贝塞尔曲线的终点为 currentPoint
8522
- segment.startTangent=[prePoint[0]-cp[0],prePoint[1]-cp[1]];segment.endTangent=[currentPoint[0]-cp[0],currentPoint[1]-cp[1]];}else if(command==='T'){var preSegment=segments[i-1];var _cp=toSymmetry(preSegment.currentPoint,prePoint);if(preSegment.command==='Q'){segment.command='Q';segment.startTangent=[prePoint[0]-_cp[0],prePoint[1]-_cp[1]];segment.endTangent=[currentPoint[0]-_cp[0],currentPoint[1]-_cp[1]];}else {// @ts-ignore
8523
- segment.command='TL';segment.startTangent=[prePoint[0]-currentPoint[0],prePoint[1]-currentPoint[1]];segment.endTangent=[currentPoint[0]-prePoint[0],currentPoint[1]-prePoint[1]];}}else if(command==='C'){// 三次贝塞尔曲线有两个控制点
8524
- var cp1=[params[1],params[2]];var cp2=[params[3],params[4]];segment.startTangent=[prePoint[0]-cp1[0],prePoint[1]-cp1[1]];segment.endTangent=[currentPoint[0]-cp2[0],currentPoint[1]-cp2[1]];// horizontal line, eg. ['C', 100, 100, 100, 100, 200, 200]
8525
- if(segment.startTangent[0]===0&&segment.startTangent[1]===0){segment.startTangent=[cp1[0]-cp2[0],cp1[1]-cp2[1]];}if(segment.endTangent[0]===0&&segment.endTangent[1]===0){segment.endTangent=[cp2[0]-cp1[0],cp2[1]-cp1[1]];}}else if(command==='S'){var _preSegment=segments[i-1];var _cp2=toSymmetry(_preSegment.currentPoint,prePoint);var _cp3=[params[1],params[2]];if(_preSegment.command==='C'){segment.command='C';// 将 S 命令变换为 C 命令
8526
- segment.startTangent=[prePoint[0]-_cp2[0],prePoint[1]-_cp2[1]];segment.endTangent=[currentPoint[0]-_cp3[0],currentPoint[1]-_cp3[1]];}else {// @ts-ignore
8527
- segment.command='SQ';// 将 S 命令变换为 SQ 命令
8528
- segment.startTangent=[prePoint[0]-_cp3[0],prePoint[1]-_cp3[1]];segment.endTangent=[currentPoint[0]-_cp3[0],currentPoint[1]-_cp3[1]];}}else if(command==='A'){var _getTangentAtRatio=getTangentAtRatio(segment,0),dx1=_getTangentAtRatio.x,dy1=_getTangentAtRatio.y;var _getTangentAtRatio2=getTangentAtRatio(segment,1,false),dx2=_getTangentAtRatio2.x,dy2=_getTangentAtRatio2.y;segment.startTangent=[dx1,dy1];segment.endTangent=[dx2,dy2];}segments.push(segment);}return segments;}/**
8529
- * Use length instead of ratio
8530
- */function getTangentAtRatio(segment,ratio,sign){if(sign===void 0){sign=true;}var _segment$arcParams=segment.arcParams,_segment$arcParams$rx=_segment$arcParams.rx,rx=_segment$arcParams$rx===void 0?0:_segment$arcParams$rx,_segment$arcParams$ry=_segment$arcParams.ry,ry=_segment$arcParams$ry===void 0?0:_segment$arcParams$ry,xRotation=_segment$arcParams.xRotation,arcFlag=_segment$arcParams.arcFlag,sweepFlag=_segment$arcParams.sweepFlag;var p1=pointOnEllipticalArc({x:segment.prePoint[0],y:segment.prePoint[1]},rx,ry,xRotation,!!arcFlag,!!sweepFlag,{x:segment.currentPoint[0],y:segment.currentPoint[1]},ratio);var p2=pointOnEllipticalArc({x:segment.prePoint[0],y:segment.prePoint[1]},rx,ry,xRotation,!!arcFlag,!!sweepFlag,{x:segment.currentPoint[0],y:segment.currentPoint[1]},sign?ratio+0.005:ratio-0.005);var xDist=p2.x-p1.x;var yDist=p2.y-p1.y;var dist=Math.sqrt(xDist*xDist+yDist*yDist);return {x:-xDist/dist,y:-yDist/dist};}// 向量长度
8531
- function vMag(v){return Math.sqrt(v[0]*v[0]+v[1]*v[1]);}// u.v/|u||v|,计算夹角的余弦值
8532
- function vRatio(u,v){// 当存在一个向量的长度为 0 时,夹角也为 0,即夹角的余弦值为 1
8533
- return vMag(u)*vMag(v)?(u[0]*v[0]+u[1]*v[1])/(vMag(u)*vMag(v)):1;}// 向量角度
8534
- function vAngle(u,v){return (u[0]*v[1]<u[1]*v[0]?-1:1)*Math.acos(vRatio(u,v));}function getArcParams(startPoint,params){var rx=params[1];var ry=params[2];var xRotation=mod(deg2rad(params[3]),Math.PI*2);var arcFlag=params[4];var sweepFlag=params[5];// 弧形起点坐标
8535
- var x1=startPoint[0];var y1=startPoint[1];// 弧形终点坐标
8536
- var x2=params[6];var y2=params[7];var xp=Math.cos(xRotation)*(x1-x2)/2.0+Math.sin(xRotation)*(y1-y2)/2.0;var yp=-1*Math.sin(xRotation)*(x1-x2)/2.0+Math.cos(xRotation)*(y1-y2)/2.0;var lambda=xp*xp/(rx*rx)+yp*yp/(ry*ry);if(lambda>1){rx*=Math.sqrt(lambda);ry*=Math.sqrt(lambda);}var diff=rx*rx*(yp*yp)+ry*ry*(xp*xp);var f=diff?Math.sqrt((rx*rx*(ry*ry)-diff)/diff):1;if(arcFlag===sweepFlag){f*=-1;}if(isNaN(f)){f=0;}// 旋转前的起点坐标,且当长半轴和短半轴的长度为 0 时,坐标按 (0, 0) 处理
8537
- var cxp=ry?f*rx*yp/ry:0;var cyp=rx?f*-ry*xp/rx:0;// 椭圆圆心坐标
8538
- var cx=(x1+x2)/2.0+Math.cos(xRotation)*cxp-Math.sin(xRotation)*cyp;var cy=(y1+y2)/2.0+Math.sin(xRotation)*cxp+Math.cos(xRotation)*cyp;// 起始点的单位向量
8539
- var u=[(xp-cxp)/rx,(yp-cyp)/ry];// 终止点的单位向量
8540
- var v=[(-1*xp-cxp)/rx,(-1*yp-cyp)/ry];// 计算起始点和圆心的连线,与 x 轴正方向的夹角
8541
- var theta=vAngle([1,0],u);// 计算圆弧起始点和终止点与椭圆圆心连线的夹角
8542
- var dTheta=vAngle(u,v);if(vRatio(u,v)<=-1){dTheta=Math.PI;}if(vRatio(u,v)>=1){dTheta=0;}if(sweepFlag===0&&dTheta>0){dTheta=dTheta-2*Math.PI;}if(sweepFlag===1&&dTheta<0){dTheta=dTheta+2*Math.PI;}return {cx:cx,cy:cy,// 弧形的起点和终点相同时,长轴和短轴的长度按 0 处理
8543
- rx:isSamePoint(startPoint,[x2,y2])?0:rx,ry:isSamePoint(startPoint,[x2,y2])?0:ry,startAngle:theta,endAngle:theta+dTheta,xRotation:xRotation,arcFlag:arcFlag,sweepFlag:sweepFlag};}function commandsToPathString(commands,object,transform){var _object$parsedStyle=object.parsedStyle,_object$parsedStyle$d=_object$parsedStyle.defX,defX=_object$parsedStyle$d===void 0?0:_object$parsedStyle$d,_object$parsedStyle$d2=_object$parsedStyle.defY,defY=_object$parsedStyle$d2===void 0?0:_object$parsedStyle$d2;return commands.reduce(function(prev,cur){var path='';if(cur[0]==='M'||cur[0]==='L'){var p=fromValues$2(cur[1]-defX,cur[2]-defY,0);if(transform){transformMat4(p,p,transform);}path=""+cur[0]+p[0]+","+p[1];}else if(cur[0]==='Z'){path=cur[0];}else if(cur[0]==='C'){var p1=fromValues$2(cur[1]-defX,cur[2]-defY,0);var p2=fromValues$2(cur[3]-defX,cur[4]-defY,0);var p3=fromValues$2(cur[5]-defX,cur[6]-defY,0);if(transform){transformMat4(p1,p1,transform);transformMat4(p2,p2,transform);transformMat4(p3,p3,transform);}path=""+cur[0]+p1[0]+","+p1[1]+","+p2[0]+","+p2[1]+","+p3[0]+","+p3[1];}else if(cur[0]==='A'){var c=fromValues$2(cur[6]-defX,cur[7]-defY,0);if(transform){transformMat4(c,c,transform);}path=""+cur[0]+cur[1]+","+cur[2]+","+cur[3]+","+cur[4]+","+cur[5]+","+c[0]+","+c[1];}else if(cur[0]==='Q'){var _p=fromValues$2(cur[1]-defX,cur[2]-defY,0);var _p2=fromValues$2(cur[3]-defX,cur[4]-defY,0);if(transform){transformMat4(_p,_p,transform);transformMat4(_p2,_p2,transform);}path=""+cur[0]+cur[1]+","+cur[2]+","+cur[3]+","+cur[4]+"}";}return prev+=path;},'');}function lineToCommands(x1,y1,x2,y2){return [['M',x1,y1],['L',x2,y2]];}function ellipseToCommands(rx,ry,cx,cy){var factor=(-1+Math.sqrt(2))/3*4;var dx=rx*factor;var dy=ry*factor;var left=cx-rx;var right=cx+rx;var top=cy-ry;var bottom=cy+ry;return [['M',left,cy],['C',left,cy-dy,cx-dx,top,cx,top],['C',cx+dx,top,right,cy-dy,right,cy],['C',right,cy+dy,cx+dx,bottom,cx,bottom],['C',cx-dx,bottom,left,cy+dy,left,cy],['Z']];}function polygonToCommands(points,closed){var result=points.map(function(point,i){return [i===0?'M':'L',point[0],point[1]];});if(closed){result.push(['Z']);}return result;}function rectToCommands(width,height,x,y,radius){// @see https://gist.github.com/danielpquinn/dd966af424030d47e476
8544
- if(radius){var tlr=radius[0],trr=radius[1],brr=radius[2],blr=radius[3];var signX=width>0?1:-1;var signY=height>0?1:-1;// sweep-flag @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Tutorial/Paths#arcs
8545
- var sweepFlag=signX+signY!==0?1:0;return [['M',signX*tlr+x,y],['L',width-signX*trr+x,y],trr?['A',trr,trr,0,0,sweepFlag,width+x,signY*trr+y]:null,['L',width+x,height-signY*brr+y],brr?['A',brr,brr,0,0,sweepFlag,width+x-signX*brr,height+y]:null,['L',x+signX*blr,height+y],blr?['A',blr,blr,0,0,sweepFlag,x,height+y-signY*blr]:null,['L',x,signY*tlr+y],tlr?['A',tlr,tlr,0,0,sweepFlag,signX*tlr+x,y]:null,['Z']].filter(function(command){return command;});}return [['M',x,y],['L',x+width,y],['L',x+width,y+height],['L',x,y+height],['Z']];}/**
8546
- * convert object to path, should account for:
8547
- * * transform & origin
8548
- * * anchor
8549
- * * lineWidth
8550
- */function convertToPath(object,transform){if(transform===void 0){transform=object.getLocalTransform();}var commands=[];switch(object.nodeName){case exports.Shape.LINE:var _object$parsedStyle2=object.parsedStyle,x1=_object$parsedStyle2.x1,y1=_object$parsedStyle2.y1,x2=_object$parsedStyle2.x2,y2=_object$parsedStyle2.y2;commands=lineToCommands(x1,y1,x2,y2);break;case exports.Shape.CIRCLE:{var _object$parsedStyle3=object.parsedStyle,r=_object$parsedStyle3.r,cx=_object$parsedStyle3.cx,cy=_object$parsedStyle3.cy;commands=ellipseToCommands(r,r,cx,cy);break;}case exports.Shape.ELLIPSE:{var _object$parsedStyle4=object.parsedStyle,rx=_object$parsedStyle4.rx,ry=_object$parsedStyle4.ry,_cx=_object$parsedStyle4.cx,_cy=_object$parsedStyle4.cy;commands=ellipseToCommands(rx,ry,_cx,_cy);break;}case exports.Shape.POLYLINE:case exports.Shape.POLYGON:var points=object.parsedStyle.points;commands=polygonToCommands(points.points,object.nodeName===exports.Shape.POLYGON);break;case exports.Shape.RECT:var _object$parsedStyle5=object.parsedStyle,width=_object$parsedStyle5.width,height=_object$parsedStyle5.height,x=_object$parsedStyle5.x,y=_object$parsedStyle5.y,radius=_object$parsedStyle5.radius;var hasRadius=radius&&radius.some(function(r){return r!==0;});commands=rectToCommands(width,height,x,y,hasRadius&&radius.map(function(r){return clamp(r,0,Math.min(Math.abs(width)/2,Math.abs(height)/2));}));break;case exports.Shape.PATH:var absolutePath=object.parsedStyle.path.absolutePath;commands=[].concat(absolutePath);break;}if(commands.length){return commandsToPathString(commands,object,transform);}}function translatePathToString(absolutePath,defX,defY,startOffsetX,startOffsetY,endOffsetX,endOffsetY){if(startOffsetX===void 0){startOffsetX=0;}if(startOffsetY===void 0){startOffsetY=0;}if(endOffsetX===void 0){endOffsetX=0;}if(endOffsetY===void 0){endOffsetY=0;}var newValue=absolutePath.map(function(params,i){var command=params[0];var nextSegment=absolutePath[i+1];var useStartOffset=i===0&&(startOffsetX!==0||startOffsetY!==0);var useEndOffset=(i===absolutePath.length-1||nextSegment&&(nextSegment[0]==='M'||nextSegment[0]==='Z'))&&endOffsetX!==0&&endOffsetY!==0;switch(command){case'M':// Use start marker offset
8551
- if(useStartOffset){return "M "+(params[1]-defX+startOffsetX)+","+(params[2]-defY+startOffsetY)+" L "+(params[1]-defX)+","+(params[2]-defY);}else {return "M "+(params[1]-defX)+","+(params[2]-defY);}case'L':return "L "+(params[1]-defX+(useEndOffset?endOffsetX:0))+","+(params[2]-defY+(useEndOffset?endOffsetY:0));case'Q':return "Q "+(params[1]-defX)+" "+(params[2]-defY)+","+(params[3]-defX)+" "+(params[4]-defY)+(useEndOffset?" L "+(params[3]-defX+endOffsetX)+","+(params[4]-defY+endOffsetY):'');case'C':return "C "+(params[1]-defX)+" "+(params[2]-defY)+","+(params[3]-defX)+" "+(params[4]-defY)+","+(params[5]-defX)+" "+(params[6]-defY)+(useEndOffset?" L "+(params[5]-defX+endOffsetX)+","+(params[6]-defY+endOffsetY):'');case'A':return "A "+params[1]+" "+params[2]+" "+params[3]+" "+params[4]+" "+params[5]+" "+(params[6]-defX)+" "+(params[7]-defY)+(useEndOffset?" L "+(params[6]-defX+endOffsetX)+","+(params[7]-defY+endOffsetY):'');case'Z':return 'Z';}}).join(' ');if(~newValue.indexOf('NaN')){return '';}return newValue;}function isFillOrStrokeAffected(pointerEvents,fill,stroke){// account for pointerEvents
8552
- // @see https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
8553
- var hasFill=false;var hasStroke=false;var isFillOtherThanNone=!!fill&&!fill.isNone;var isStrokeOtherThanNone=!!stroke&&!stroke.isNone;if(pointerEvents==='visiblepainted'||pointerEvents==='painted'||pointerEvents==='auto'){hasFill=isFillOtherThanNone;hasStroke=isStrokeOtherThanNone;}else if(pointerEvents==='visiblefill'||pointerEvents==='fill'){hasFill=true;}else if(pointerEvents==='visiblestroke'||pointerEvents==='stroke'){hasStroke=true;}else if(pointerEvents==='visible'||pointerEvents==='all'){// The values of the fill and stroke do not affect event processing.
8554
- hasFill=true;hasStroke=true;}return [hasFill,hasStroke];}// @ts-nocheck
8555
- // interface HookInterceptor<T, R, AdditionalOptions = UnsetAdditionalOptions> {
8556
- // name?: string;
8557
- // tap?: (tap: FullTap & IfSet<AdditionalOptions>) => void;
8558
- // call?: (...args: any[]) => void;
8559
- // loop?: (...args: any[]) => void;
8560
- // error?: (err: Error) => void;
8561
- // result?: (result: R) => void;
8562
- // done?: () => void;
8563
- // register?: (tap: FullTap & IfSet<AdditionalOptions>) => FullTap & IfSet<AdditionalOptions>;
8564
- // }
8565
- // type ArgumentNames<T extends any[]> = FixedSizeArray<T['length'], string>;
8566
- // export declare class AsyncHook<T, R, AdditionalOptions = UnsetAdditionalOptions> extends Hook<
8567
- // T,
8568
- // R,
8569
- // AdditionalOptions
8570
- // > {
8571
- // tapAsync(
8572
- // options: string | (Tap & IfSet<AdditionalOptions>),
8573
- // fn: (...args: Append<AsArray<T>, InnerCallback<Error, R>>) => void,
8574
- // ): void;
8575
- // tapPromise(
8576
- // options: string | (Tap & IfSet<AdditionalOptions>),
8577
- // fn: (...args: AsArray<T>) => Promise<R>,
8578
- // ): void;
8634
+ * @deprecated
8635
+ */;_proto.move=function move(position,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}this.setPosition(position,y,z);return this;}/**
8636
+ * Use `this.style.zIndex` instead.
8637
+ * @deprecated
8638
+ */;_proto.setZIndex=function setZIndex(zIndex){this.style.zIndex=zIndex;return this;};_createClass(DisplayObject,[{key:"interactive",get:function get(){return this.isInteractive();},set:function set(b){this.style.pointerEvents=b?'auto':'none';}}]);return DisplayObject;}(Element);var _excluded=["style"];var Circle=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Circle,_DisplayObject);function Circle(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded);return _DisplayObject.call(this,_extends({type:exports.Shape.CIRCLE,style:runtime.enableCSSParsing?_extends({cx:'',cy:'',r:''},style):_extends({},style),initialParsedStyle:{anchor:[0.5,0.5],transformOrigin:runtime.enableCSSParsing?null:[getOrCreateUnitValue(50,'%'),getOrCreateUnitValue(50,'%')]}},rest))||this;}return Circle;}(DisplayObject);var _excluded$1=["style"];/**
8639
+ * shadow root
8640
+ * @see https://yuque.antfin-inc.com/antv/czqvg5/pgqipg
8641
+ */var CustomElement=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(CustomElement,_DisplayObject);// static get observedAttributes(): string[] {
8642
+ // return [];
8579
8643
  // }
8580
- var CALL_DELEGATE=function CALL_DELEGATE(){this.call=this._createCall('sync');return this.call.apply(this,arguments);};var CALL_ASYNC_DELEGATE=function CALL_ASYNC_DELEGATE(){this.callAsync=this._createCall('async');return this.callAsync.apply(this,arguments);};var PROMISE_DELEGATE=function PROMISE_DELEGATE(){this.promise=this._createCall('promise');return this.promise.apply(this,arguments);};var Hook=/*#__PURE__*/function(){function Hook(args,name){if(args===void 0){args=[];}if(name===void 0){name=undefined;}this.name=void 0;this.taps=void 0;this.promise=void 0;this._promise=void 0;this._args=args;this.name=name;this.taps=[];this.interceptors=[];this._call=CALL_DELEGATE;this.call=CALL_DELEGATE;this._callAsync=CALL_ASYNC_DELEGATE;this.callAsync=CALL_ASYNC_DELEGATE;this._promise=PROMISE_DELEGATE;this.promise=PROMISE_DELEGATE;this._x=undefined;// this.compile = this.compile;
8581
- // this.tap = this.tap;
8582
- // this.tapAsync = this.tapAsync;
8583
- // this.tapPromise = this.tapPromise;
8584
- }var _proto=Hook.prototype;_proto.compile=function compile(options){throw new Error('Abstract: should be overridden');};_proto._createCall=function _createCall(type){return this.compile({taps:this.taps,interceptors:this.interceptors,args:this._args,type:type});};_proto._tap=function _tap(type,options,fn){if(typeof options==='string'){options={name:options.trim()};}else if(typeof options!=='object'||options===null){throw new Error('Invalid tap options');}if(typeof options.name!=='string'||options.name===''){throw new Error('Missing name for tap');}// if (typeof options.context !== "undefined") {
8585
- // deprecateContext();
8644
+ // private shadowNodes: DisplayObject[] = [];
8645
+ function CustomElement(_temp){var _this;var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$1);_this=_DisplayObject.call(this,runtime.enableCSSParsing?_extends({style:_extends({x:'',y:''},style)},rest):_extends({},style))||this;_this.isCustomElement=true;return _this;}return CustomElement;}(DisplayObject);var pool={};var htmlPool=[];var DisplayObjectPool=/*#__PURE__*/function(){function DisplayObjectPool(){}var _proto=DisplayObjectPool.prototype;_proto.getByEntity=function getByEntity(entity){return pool[entity];};_proto.getAll=function getAll(){return Object.keys(pool).map(function(entity){return pool[entity];});};_proto.add=function add(entity,groupOrShape){pool[entity]=groupOrShape;if(groupOrShape.nodeName===exports.Shape.HTML){htmlPool.push(groupOrShape);}};_proto.remove=function remove(entity){var existed=pool[entity];if(existed){delete pool[entity];if(existed.nodeName===exports.Shape.HTML){var index=htmlPool.indexOf(existed);htmlPool.splice(index,1);}}};_proto.getHTMLs=function getHTMLs(){return htmlPool;};return DisplayObjectPool;}();var _excluded$2=["style"];var Ellipse=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Ellipse,_DisplayObject);function Ellipse(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$2);return _DisplayObject.call(this,_extends({type:exports.Shape.ELLIPSE,style:runtime.enableCSSParsing?_extends({cx:'',cy:'',rx:'',ry:''},style):_extends({},style),initialParsedStyle:{anchor:[0.5,0.5],transformOrigin:runtime.enableCSSParsing?null:[getOrCreateUnitValue(50,'%'),getOrCreateUnitValue(50,'%')]}},rest))||this;}return Ellipse;}(DisplayObject);var _excluded$3=["style"];/**
8646
+ * its attributes are inherited by its children.
8647
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/g
8648
+ *
8649
+ * @example
8650
+ * <g fill="white" stroke="green" stroke-width="5">
8651
+ <circle cx="40" cy="40" r="25" />
8652
+ <circle cx="60" cy="60" r="25" />
8653
+ </g>
8654
+ */var Group=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Group,_DisplayObject);function Group(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$3);return _DisplayObject.call(this,_extends({type:exports.Shape.GROUP,style:runtime.enableCSSParsing?_extends({x:'',y:'',width:'',height:''},style):_extends({},style)},rest))||this;}return Group;}(DisplayObject);var _excluded$4=["style"];/**
8655
+ * HTML container
8656
+ * @see https://github.com/pmndrs/drei#html
8657
+ */var HTML=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(HTML,_DisplayObject);function HTML(_temp){var _this;var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$4);_this=_DisplayObject.call(this,_extends({type:exports.Shape.HTML,style:runtime.enableCSSParsing?_extends({x:'',y:'',width:'auto',height:'auto',innerHTML:''},style):_extends({},style)},rest))||this;_this.cullable.enable=false;return _this;}/**
8658
+ * return wrapper HTMLElement
8659
+ * * <div> in g-webgl/canvas
8660
+ * * <foreignObject> in g-svg
8661
+ */var _proto=HTML.prototype;_proto.getDomElement=function getDomElement(){return this.parsedStyle.$el;}/**
8662
+ * override with $el.getBoundingClientRect
8663
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/getBoundingClientRect
8664
+ */;_proto.getBoundingClientRect=function getBoundingClientRect(){return this.parsedStyle.$el.getBoundingClientRect();};_proto.getClientRects=function getClientRects(){return [this.getBoundingClientRect()];};_proto.getBounds=function getBounds(){var _this$ownerDocument,_this$ownerDocument$d;var clientRect=this.getBoundingClientRect();// calc context's offset
8665
+ // @ts-ignore
8666
+ var canvasRect=(_this$ownerDocument=this.ownerDocument)===null||_this$ownerDocument===void 0?void 0:(_this$ownerDocument$d=_this$ownerDocument.defaultView)===null||_this$ownerDocument$d===void 0?void 0:_this$ownerDocument$d.getContextService().getBoundingClientRect();if(canvasRect){var minX=clientRect.left-canvasRect.left;var minY=clientRect.top-canvasRect.top;var aabb=new AABB();// aabb.setMinMax(
8667
+ // vec3.fromValues(minX, minY, 0),
8668
+ // vec3.fromValues(minX + clientRect.width, minY + clientRect.height, 0),
8669
+ // );
8670
+ aabb.setMinMax([minX,minY,0],[minX+clientRect.width,minY+clientRect.height,0]);return aabb;}return null;};_proto.getLocalBounds=function getLocalBounds(){if(this.parentNode){var parentInvert=invert(create$1(),this.parentNode.getWorldTransform());var bounds=this.getBounds();if(!AABB.isEmpty(bounds)){var localBounds=new AABB();localBounds.setFromTransformedAABB(bounds,parentInvert);return localBounds;}}return this.getBounds();};return HTML;}(DisplayObject);var _excluded$5=["style"];var Image=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Image,_DisplayObject);function Image(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$5);return _DisplayObject.call(this,_extends({type:exports.Shape.IMAGE,style:_extends({x:'',y:'',img:'',width:'',height:''},style)},rest))||this;}return Image;}(DisplayObject);var _excluded$6=["style"];/**
8671
+ * Create a line connecting two points.
8672
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/line
8673
+ *
8674
+ * Also support for using marker.
8675
+ */var Line=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Line,_DisplayObject);function Line(_temp){var _this;var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$6);_this=_DisplayObject.call(this,_extends({type:exports.Shape.LINE,style:_extends({x1:0,y1:0,x2:0,y2:0,z1:0,z2:0,isBillboard:false},style)},rest))||this;_this.markerStartAngle=0;_this.markerEndAngle=0;var _this$parsedStyle=_this.parsedStyle,markerStart=_this$parsedStyle.markerStart,markerEnd=_this$parsedStyle.markerEnd;if(markerStart&&isDisplayObject(markerStart)){_this.markerStartAngle=markerStart.getLocalEulerAngles();_this.appendChild(markerStart);}if(markerEnd&&isDisplayObject(markerEnd)){_this.markerEndAngle=markerEnd.getLocalEulerAngles();_this.appendChild(markerEnd);}_this.transformMarker(true);_this.transformMarker(false);return _this;}var _proto=Line.prototype;_proto.attributeChangedCallback=function attributeChangedCallback(attrName,oldValue,newValue,prevParsedValue,newParsedValue){if(attrName==='x1'||attrName==='y1'||attrName==='x2'||attrName==='y2'||attrName==='markerStartOffset'||attrName==='markerEndOffset'){this.transformMarker(true);this.transformMarker(false);}else if(attrName==='markerStart'){if(prevParsedValue&&isDisplayObject(prevParsedValue)){this.markerStartAngle=0;prevParsedValue.remove();}// CSSKeyword 'unset'
8676
+ if(newParsedValue&&isDisplayObject(newParsedValue)){this.markerStartAngle=newParsedValue.getLocalEulerAngles();this.appendChild(newParsedValue);this.transformMarker(true);}}else if(attrName==='markerEnd'){if(prevParsedValue&&isDisplayObject(prevParsedValue)){this.markerEndAngle=0;prevParsedValue.remove();}if(newParsedValue&&isDisplayObject(newParsedValue)){this.markerEndAngle=newParsedValue.getLocalEulerAngles();this.appendChild(newParsedValue);this.transformMarker(false);}}};_proto.transformMarker=function transformMarker(isStart){var _this$parsedStyle2=this.parsedStyle,markerStart=_this$parsedStyle2.markerStart,markerEnd=_this$parsedStyle2.markerEnd,markerStartOffset=_this$parsedStyle2.markerStartOffset,markerEndOffset=_this$parsedStyle2.markerEndOffset,x1=_this$parsedStyle2.x1,x2=_this$parsedStyle2.x2,y1=_this$parsedStyle2.y1,y2=_this$parsedStyle2.y2,defX=_this$parsedStyle2.defX,defY=_this$parsedStyle2.defY;var marker=isStart?markerStart:markerEnd;if(!marker||!isDisplayObject(marker)){return;}var rad=0;var x;var y;var ox;var oy;var offset;var originalAngle;if(isStart){ox=x1-defX;oy=y1-defY;x=x2-x1;y=y2-y1;offset=markerStartOffset||0;originalAngle=this.markerStartAngle;}else {ox=x2-defX;oy=y2-defY;x=x1-x2;y=y1-y2;offset=markerEndOffset||0;originalAngle=this.markerEndAngle;}rad=Math.atan2(y,x);// account for markerOffset
8677
+ marker.setLocalEulerAngles(rad*180/Math.PI+originalAngle);marker.setLocalPosition(ox+Math.cos(rad)*offset,oy+Math.sin(rad)*offset);};_proto.getPoint=function getPoint(ratio,inWorldSpace){if(inWorldSpace===void 0){inWorldSpace=false;}// TODO: account for z1/z2 in 3D line
8678
+ var _this$parsedStyle3=this.parsedStyle,x1=_this$parsedStyle3.x1,y1=_this$parsedStyle3.y1,x2=_this$parsedStyle3.x2,y2=_this$parsedStyle3.y2,defX=_this$parsedStyle3.defX,defY=_this$parsedStyle3.defY;var _LineUtil$pointAt=line.pointAt(x1,y1,x2,y2,ratio),x=_LineUtil$pointAt.x,y=_LineUtil$pointAt.y;var transformed=transformMat4(create$2(),fromValues$2(x-defX,y-defY,0),inWorldSpace?this.getWorldTransform():this.getLocalTransform());// apply local transformation
8679
+ return new Point(transformed[0],transformed[1]);};_proto.getPointAtLength=function getPointAtLength(distance,inWorldSpace){if(inWorldSpace===void 0){inWorldSpace=false;}return this.getPoint(distance/this.getTotalLength(),inWorldSpace);};_proto.getTotalLength=function getTotalLength(){// TODO: account for z1/z2 in 3D line
8680
+ var _this$parsedStyle4=this.parsedStyle,x1=_this$parsedStyle4.x1,y1=_this$parsedStyle4.y1,x2=_this$parsedStyle4.x2,y2=_this$parsedStyle4.y2;return line.length(x1,y1,x2,y2);};return Line;}(DisplayObject);var _excluded$7=["style"];var EMPTY_PARSED_PATH={absolutePath:[],hasArc:false,segments:[],polygons:[],polylines:[],curve:null,totalLength:0,rect:new Rectangle(0,0,0,0)};var Path=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Path,_DisplayObject);/**
8681
+ * markers placed at the mid
8682
+ */function Path(_temp){var _this;var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$7);_this=_DisplayObject.call(this,_extends({type:exports.Shape.PATH,style:_extends({path:'',miterLimit:''},style),initialParsedStyle:runtime.enableCSSParsing?null:{miterLimit:4,path:_extends({},EMPTY_PARSED_PATH)}},rest))||this;_this.markerStartAngle=0;_this.markerEndAngle=0;_this.markerMidList=[];var _this$parsedStyle=_this.parsedStyle,markerStart=_this$parsedStyle.markerStart,markerEnd=_this$parsedStyle.markerEnd,markerMid=_this$parsedStyle.markerMid;if(markerStart&&isDisplayObject(markerStart)){_this.markerStartAngle=markerStart.getLocalEulerAngles();_this.appendChild(markerStart);}if(markerMid&&isDisplayObject(markerMid)){_this.placeMarkerMid(markerMid);}if(markerEnd&&isDisplayObject(markerEnd)){_this.markerEndAngle=markerEnd.getLocalEulerAngles();_this.appendChild(markerEnd);}_this.transformMarker(true);_this.transformMarker(false);return _this;}var _proto=Path.prototype;_proto.attributeChangedCallback=function attributeChangedCallback(attrName,oldValue,newValue,prevParsedValue,newParsedValue){if(attrName==='path'){// recalc markers
8683
+ this.transformMarker(true);this.transformMarker(false);this.placeMarkerMid(this.parsedStyle.markerMid);}else if(attrName==='markerStartOffset'||attrName==='markerEndOffset'){this.transformMarker(true);this.transformMarker(false);}else if(attrName==='markerStart'){if(prevParsedValue&&isDisplayObject(prevParsedValue)){this.markerStartAngle=0;prevParsedValue.remove();}// CSSKeyword 'unset'
8684
+ if(newParsedValue&&isDisplayObject(newParsedValue)){this.markerStartAngle=newParsedValue.getLocalEulerAngles();this.appendChild(newParsedValue);this.transformMarker(true);}}else if(attrName==='markerEnd'){if(prevParsedValue&&isDisplayObject(prevParsedValue)){this.markerEndAngle=0;prevParsedValue.remove();}if(newParsedValue&&isDisplayObject(newParsedValue)){this.markerEndAngle=newParsedValue.getLocalEulerAngles();this.appendChild(newParsedValue);this.transformMarker(false);}}else if(attrName==='markerMid'){this.placeMarkerMid(newParsedValue);}};_proto.transformMarker=function transformMarker(isStart){var _this$parsedStyle2=this.parsedStyle,markerStart=_this$parsedStyle2.markerStart,markerEnd=_this$parsedStyle2.markerEnd,markerStartOffset=_this$parsedStyle2.markerStartOffset,markerEndOffset=_this$parsedStyle2.markerEndOffset,defX=_this$parsedStyle2.defX,defY=_this$parsedStyle2.defY;var marker=isStart?markerStart:markerEnd;if(!marker||!isDisplayObject(marker)){return;}var rad=0;var x;var y;var ox;var oy;var offset;var originalAngle;if(isStart){var _this$getStartTangent=this.getStartTangent(),p1=_this$getStartTangent[0],p2=_this$getStartTangent[1];ox=p2[0]-defX;oy=p2[1]-defY;x=p1[0]-p2[0];y=p1[1]-p2[1];offset=markerStartOffset||0;originalAngle=this.markerStartAngle;}else {var _this$getEndTangent=this.getEndTangent(),_p=_this$getEndTangent[0],_p2=_this$getEndTangent[1];ox=_p2[0]-defX;oy=_p2[1]-defY;x=_p[0]-_p2[0];y=_p[1]-_p2[1];offset=markerEndOffset||0;originalAngle=this.markerEndAngle;}rad=Math.atan2(y,x);// account for markerOffset
8685
+ marker.setLocalEulerAngles(rad*180/Math.PI+originalAngle);marker.setLocalPosition(ox+Math.cos(rad)*offset,oy+Math.sin(rad)*offset);};_proto.placeMarkerMid=function placeMarkerMid(marker){var _this$parsedStyle3=this.parsedStyle,segments=_this$parsedStyle3.path.segments,defX=_this$parsedStyle3.defX,defY=_this$parsedStyle3.defY;// clear all existed markers
8686
+ this.markerMidList.forEach(function(marker){marker.remove();});if(marker&&isDisplayObject(marker)){for(var i=1;i<segments.length-1;i++){var _segments$i$currentPo=segments[i].currentPoint,ox=_segments$i$currentPo[0],oy=_segments$i$currentPo[1];var cloned=i===1?marker:marker.cloneNode(true);this.markerMidList.push(cloned);this.appendChild(cloned);cloned.setLocalPosition(ox-defX,oy-defY);// TODO: orient of marker
8687
+ }}}/**
8688
+ * Returns the total length of the path.
8689
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGGeometryElement/getTotalLength
8690
+ */;_proto.getTotalLength=function getTotalLength(){return getOrCalculatePathTotalLength(this);}/**
8691
+ * Returns the point at a given distance along the path.
8692
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGGeometryElement/getPointAtLength
8693
+ */;_proto.getPointAtLength=function getPointAtLength$1(distance,inWorldSpace){if(inWorldSpace===void 0){inWorldSpace=false;}var _this$parsedStyle4=this.parsedStyle,defX=_this$parsedStyle4.defX,defY=_this$parsedStyle4.defY,absolutePath=_this$parsedStyle4.path.absolutePath;var _getPointAtLength2=getPointAtLength(absolutePath,distance),x=_getPointAtLength2.x,y=_getPointAtLength2.y;var transformed=transformMat4(create$2(),fromValues$2(x-defX,y-defY,0),inWorldSpace?this.getWorldTransform():this.getLocalTransform());// apply local transformation
8694
+ return new Point(transformed[0],transformed[1]);}/**
8695
+ * Returns the point at a given ratio of the total length in path.
8696
+ */;_proto.getPoint=function getPoint(ratio,inWorldSpace){if(inWorldSpace===void 0){inWorldSpace=false;}return this.getPointAtLength(ratio*getOrCalculatePathTotalLength(this),inWorldSpace);}/**
8697
+ * Get start tangent vector
8698
+ */;_proto.getStartTangent=function getStartTangent(){var segments=this.parsedStyle.path.segments;var result=[];if(segments.length>1){var startPoint=segments[0].currentPoint;var endPoint=segments[1].currentPoint;var tangent=segments[1].startTangent;result=[];if(tangent){result.push([startPoint[0]-tangent[0],startPoint[1]-tangent[1]]);result.push([startPoint[0],startPoint[1]]);}else {result.push([endPoint[0],endPoint[1]]);result.push([startPoint[0],startPoint[1]]);}}return result;}/**
8699
+ * Get end tangent vector
8700
+ */;_proto.getEndTangent=function getEndTangent(){var segments=this.parsedStyle.path.segments;var length=segments.length;var result=[];if(length>1){var startPoint=segments[length-2].currentPoint;var endPoint=segments[length-1].currentPoint;var tangent=segments[length-1].endTangent;result=[];if(tangent){result.push([endPoint[0]-tangent[0],endPoint[1]-tangent[1]]);result.push([endPoint[0],endPoint[1]]);}else {result.push([startPoint[0],startPoint[1]]);result.push([endPoint[0],endPoint[1]]);}}return result;};return Path;}(DisplayObject);var _excluded$8=["style"];var Polygon=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Polygon,_DisplayObject);/**
8701
+ * markers placed at the mid
8702
+ */function Polygon(_temp){var _this;var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$8);_this=_DisplayObject.call(this,_extends({type:exports.Shape.POLYGON,style:_extends({points:'',miterLimit:'',isClosed:true},style),initialParsedStyle:runtime.enableCSSParsing?null:{miterLimit:4}},rest))||this;_this.markerStartAngle=0;_this.markerEndAngle=0;_this.markerMidList=[];var _this$parsedStyle=_this.parsedStyle,markerStart=_this$parsedStyle.markerStart,markerEnd=_this$parsedStyle.markerEnd,markerMid=_this$parsedStyle.markerMid;if(markerStart&&isDisplayObject(markerStart)){_this.markerStartAngle=markerStart.getLocalEulerAngles();_this.appendChild(markerStart);}if(markerMid&&isDisplayObject(markerMid)){_this.placeMarkerMid(markerMid);}if(markerEnd&&isDisplayObject(markerEnd)){_this.markerEndAngle=markerEnd.getLocalEulerAngles();_this.appendChild(markerEnd);}_this.transformMarker(true);_this.transformMarker(false);return _this;}var _proto=Polygon.prototype;_proto.attributeChangedCallback=function attributeChangedCallback(attrName,oldValue,newValue,prevParsedValue,newParsedValue){if(attrName==='points'){// recalc markers
8703
+ this.transformMarker(true);this.transformMarker(false);this.placeMarkerMid(this.parsedStyle.markerMid);}else if(attrName==='markerStartOffset'||attrName==='markerEndOffset'){this.transformMarker(true);this.transformMarker(false);}else if(attrName==='markerStart'){if(prevParsedValue&&isDisplayObject(prevParsedValue)){this.markerStartAngle=0;prevParsedValue.remove();}// CSSKeyword 'unset'
8704
+ if(newParsedValue&&isDisplayObject(newParsedValue)){this.markerStartAngle=newParsedValue.getLocalEulerAngles();this.appendChild(newParsedValue);this.transformMarker(true);}}else if(attrName==='markerEnd'){if(prevParsedValue&&isDisplayObject(prevParsedValue)){this.markerEndAngle=0;prevParsedValue.remove();}if(newParsedValue&&isDisplayObject(newParsedValue)){this.markerEndAngle=newParsedValue.getLocalEulerAngles();this.appendChild(newParsedValue);this.transformMarker(false);}}else if(attrName==='markerMid'){this.placeMarkerMid(newParsedValue);}};_proto.transformMarker=function transformMarker(isStart){var _this$parsedStyle2=this.parsedStyle,markerStart=_this$parsedStyle2.markerStart,markerEnd=_this$parsedStyle2.markerEnd,markerStartOffset=_this$parsedStyle2.markerStartOffset,markerEndOffset=_this$parsedStyle2.markerEndOffset,points=_this$parsedStyle2.points.points,defX=_this$parsedStyle2.defX,defY=_this$parsedStyle2.defY;var marker=isStart?markerStart:markerEnd;if(!marker||!isDisplayObject(marker)){return;}var rad=0;var x;var y;var ox;var oy;var offset;var originalAngle;ox=points[0][0]-defX;oy=points[0][1]-defY;if(isStart){x=points[1][0]-points[0][0];y=points[1][1]-points[0][1];offset=markerStartOffset||0;originalAngle=this.markerStartAngle;}else {var length=points.length;if(!this.style.isClosed){ox=points[length-1][0]-defX;oy=points[length-1][1]-defY;x=points[length-2][0]-points[length-1][0];y=points[length-2][1]-points[length-1][1];}else {x=points[length-1][0]-points[0][0];y=points[length-1][1]-points[0][1];}offset=markerEndOffset||0;originalAngle=this.markerEndAngle;}rad=Math.atan2(y,x);// account for markerOffset
8705
+ marker.setLocalEulerAngles(rad*180/Math.PI+originalAngle);marker.setLocalPosition(ox+Math.cos(rad)*offset,oy+Math.sin(rad)*offset);};_proto.placeMarkerMid=function placeMarkerMid(marker){var _this$parsedStyle3=this.parsedStyle,points=_this$parsedStyle3.points.points,defX=_this$parsedStyle3.defX,defY=_this$parsedStyle3.defY;// clear all existed markers
8706
+ this.markerMidList.forEach(function(marker){marker.remove();});this.markerMidList=[];if(marker&&isDisplayObject(marker)){for(var i=1;i<(this.style.isClosed?points.length:points.length-1);i++){var ox=points[i][0]-defX;var oy=points[i][1]-defY;var cloned=i===1?marker:marker.cloneNode(true);this.markerMidList.push(cloned);this.appendChild(cloned);cloned.setLocalPosition(ox,oy);// TODO: orient of marker
8707
+ }}};return Polygon;}(DisplayObject);var _excluded$9=["style"];/**
8708
+ * Polyline inherits the marker-related capabilities of Polygon.
8709
+ */var Polyline=/*#__PURE__*/function(_Polygon){_inheritsLoose(Polyline,_Polygon);function Polyline(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$9);return _Polygon.call(this,_extends({type:exports.Shape.POLYLINE,style:_extends({points:'',miterLimit:'',isClosed:false},style),initialParsedStyle:runtime.enableCSSParsing?null:{miterLimit:4}},rest))||this;}var _proto=Polyline.prototype;_proto.getTotalLength=function getTotalLength(){return this.parsedStyle.points.totalLength;};_proto.getPointAtLength=function getPointAtLength(distance,inWorldSpace){if(inWorldSpace===void 0){inWorldSpace=false;}return this.getPoint(distance/this.getTotalLength(),inWorldSpace);};_proto.getPoint=function getPoint(ratio,inWorldSpace){if(inWorldSpace===void 0){inWorldSpace=false;}var _this$parsedStyle=this.parsedStyle,defX=_this$parsedStyle.defX,defY=_this$parsedStyle.defY,_this$parsedStyle$poi=_this$parsedStyle.points,points=_this$parsedStyle$poi.points,segments=_this$parsedStyle$poi.segments;var subt=0;var index=0;segments.forEach(function(v,i){if(ratio>=v[0]&&ratio<=v[1]){subt=(ratio-v[0])/(v[1]-v[0]);index=i;}});var _LineUtil$pointAt=line.pointAt(points[index][0],points[index][1],points[index+1][0],points[index+1][1],subt),x=_LineUtil$pointAt.x,y=_LineUtil$pointAt.y;var transformed=transformMat4(create$2(),fromValues$2(x-defX,y-defY,0),inWorldSpace?this.getWorldTransform():this.getLocalTransform());// apply local transformation
8710
+ return new Point(transformed[0],transformed[1]);};_proto.getStartTangent=function getStartTangent(){var points=this.parsedStyle.points.points;var result=[];result.push([points[1][0],points[1][1]]);result.push([points[0][0],points[0][1]]);return result;};_proto.getEndTangent=function getEndTangent(){var points=this.parsedStyle.points.points;var l=points.length-1;var result=[];result.push([points[l-1][0],points[l-1][1]]);result.push([points[l][0],points[l][1]]);return result;};return Polyline;}(Polygon);var _excluded$a=["style"];var Rect=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Rect,_DisplayObject);function Rect(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$a);return _DisplayObject.call(this,_extends({type:exports.Shape.RECT,style:_extends({x:'',y:'',width:'',height:'',radius:''},style)},rest))||this;}return Rect;}(DisplayObject);var _excluded$b=["style"];/**
8711
+ * <text> @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextElement
8712
+ */var Text=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Text,_DisplayObject);/**
8713
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement#constants
8714
+ */ // LENGTHADJUST_SPACING: number = 1;
8715
+ // LENGTHADJUST_SPACINGANDGLYPHS: number = 2;
8716
+ // LENGTHADJUST_UNKNOWN: number = 0;
8717
+ function Text(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$b);return _DisplayObject.call(this,_extends({type:exports.Shape.TEXT,style:runtime.enableCSSParsing?_extends({x:'',y:'',text:'',fontSize:'',fontFamily:'',fontStyle:'',fontWeight:'',fontVariant:'',textAlign:'',textBaseline:'',textTransform:'',fill:'black',letterSpacing:'',lineHeight:'',miterLimit:'',// whiteSpace: 'pre',
8718
+ wordWrap:false,wordWrapWidth:0,leading:0,dx:'',dy:''},style):_extends({fill:'black'},style),initialParsedStyle:runtime.enableCSSParsing?{}:{x:0,y:0,fontSize:16,fontFamily:'sans-serif',fontStyle:'normal',fontWeight:'normal',fontVariant:'normal',lineHeight:0,letterSpacing:0,textBaseline:'alphabetic',textAlign:'start',wordWrap:false,wordWrapWidth:0,leading:0,dx:0,dy:0}},rest))||this;}// lengthAdjust: SVGAnimatedEnumeration;
8719
+ // textLength: SVGAnimatedLength;
8720
+ // getCharNumAtPosition(point?: DOMPointInit): number {
8721
+ // throw new Error('Method not implemented.');
8586
8722
  // }
8587
- options=Object.assign({type:type,fn:fn},options);options=this._runRegisterInterceptors(options);this._insert(options);};_proto.tap=function tap(options,fn){this._tap('sync',options,fn);};_proto.tapAsync=function tapAsync(options,fn){this._tap('async',options,fn);};_proto.tapPromise=function tapPromise(options,fn){this._tap('promise',options,fn);};_proto._runRegisterInterceptors=function _runRegisterInterceptors(options){for(var _iterator=_createForOfIteratorHelperLoose(this.interceptors),_step;!(_step=_iterator()).done;){var interceptor=_step.value;if(interceptor.register){var newOptions=interceptor.register(options);if(newOptions!==undefined){options=newOptions;}}}return options;};_proto.withOptions=function withOptions(options){var _this=this;var mergeOptions=function mergeOptions(opt){return Object.assign({},options,typeof opt==='string'?{name:opt}:opt);};return {name:this.name,tap:function tap(opt,fn){return _this.tap(mergeOptions(opt),fn);},tapAsync:function tapAsync(opt,fn){return _this.tapAsync(mergeOptions(opt),fn);},tapPromise:function tapPromise(opt,fn){return _this.tapPromise(mergeOptions(opt),fn);},// intercept: (interceptor) => this.intercept(interceptor),
8588
- isUsed:function isUsed(){return _this.isUsed();},withOptions:function withOptions(opt){return _this.withOptions(mergeOptions(opt));}};};_proto.isUsed=function isUsed(){return this.taps.length>0||this.interceptors.length>0;}// intercept(interceptor: HookInterceptor<T, R, AdditionalOptions>) {
8589
- // this._resetCompilation();
8590
- // this.interceptors.push(Object.assign({}, interceptor));
8591
- // if (interceptor.register) {
8592
- // for (let i = 0; i < this.taps.length; i++) {
8593
- // this.taps[i] = interceptor.register(this.taps[i]);
8594
- // }
8595
- // }
8723
+ /**
8724
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement
8725
+ */var _proto=Text.prototype;_proto.getComputedTextLength=function getComputedTextLength(){var _this$parsedStyle$met;return ((_this$parsedStyle$met=this.parsedStyle.metrics)===null||_this$parsedStyle$met===void 0?void 0:_this$parsedStyle$met.maxLineWidth)||0;}// getEndPositionOfChar(charnum: number): DOMPoint {
8726
+ // throw new Error('Method not implemented.');
8596
8727
  // }
8597
- ;_proto._resetCompilation=function _resetCompilation(){this.call=this._call;this.callAsync=this._callAsync;this.promise=this._promise;};_proto._insert=function _insert(item){this._resetCompilation();var before;if(typeof item.before==='string'){before=new Set([item.before]);}else if(Array.isArray(item.before)){before=new Set(item.before);}var stage=0;if(typeof item.stage==='number'){stage=item.stage;}var i=this.taps.length;while(i>0){i--;var x=this.taps[i];this.taps[i+1]=x;var xStage=x.stage||0;if(before){if(before.has(x.name)){before.delete(x.name);continue;}if(before.size>0){continue;}}if(xStage>stage){continue;}i++;break;}this.taps[i]=item;};return Hook;}();// Object.setPrototypeOf(Hook.prototype, null);
8598
- // @ts-nocheck
8599
- var HookCodeFactory=/*#__PURE__*/function(){function HookCodeFactory(config){this.config=config;this.options=undefined;this._args=undefined;}var _proto=HookCodeFactory.prototype;_proto.create=function create(options){this.init(options);var fn;switch(this.options.type){case'sync':fn=new Function(this.args(),'"use strict";\n'+this.header()+this.contentWithInterceptors({onError:function onError(err){return "throw "+err+";\n";},onResult:function onResult(result){return "return "+result+";\n";},resultReturns:true,onDone:function onDone(){return '';},rethrowIfPossible:true}));break;case'async':fn=new Function(this.args({after:'_callback'}),'"use strict";\n'+this.header()+this.contentWithInterceptors({onError:function onError(err){return "_callback("+err+");\n";},onResult:function onResult(result){return "_callback(null, "+result+");\n";},onDone:function onDone(){return '_callback();\n';}}));break;case'promise':var errorHelperUsed=false;var content=this.contentWithInterceptors({onError:function onError(err){errorHelperUsed=true;return "_error("+err+");\n";},onResult:function onResult(result){return "_resolve("+result+");\n";},onDone:function onDone(){return '_resolve();\n';}});var code='';code+='"use strict";\n';code+=this.header();code+='return new Promise((function(_resolve, _reject) {\n';if(errorHelperUsed){code+='var _sync = true;\n';code+='function _error(_err) {\n';code+='if(_sync)\n';code+='_resolve(Promise.resolve().then((function() { throw _err; })));\n';code+='else\n';code+='_reject(_err);\n';code+='};\n';}code+=content;if(errorHelperUsed){code+='_sync = false;\n';}code+='}));\n';fn=new Function(this.args(),code);break;}this.deinit();return fn;};_proto.setup=function setup(instance,options){instance._x=options.taps.map(function(t){return t.fn;});}/**
8600
- * @param {{ type: "sync" | "promise" | "async", taps: Array<Tap>, interceptors: Array<Interceptor> }} options
8601
- */;_proto.init=function init(options){this.options=options;this._args=options.args.slice();};_proto.deinit=function deinit(){this.options=undefined;this._args=undefined;};_proto.contentWithInterceptors=function contentWithInterceptors(options){var _this=this;if(this.options.interceptors.length>0){var onError=options.onError;var onResult=options.onResult;var onDone=options.onDone;var code='';for(var i=0;i<this.options.interceptors.length;i++){var interceptor=this.options.interceptors[i];if(interceptor.call){code+=this.getInterceptor(i)+".call("+this.args({before:interceptor.context?'_context':undefined})+");\n";}}code+=this.content(Object.assign(options,{onError:onError&&function(err){var code='';for(var _i=0;_i<_this.options.interceptors.length;_i++){var _interceptor=_this.options.interceptors[_i];if(_interceptor.error){code+=_this.getInterceptor(_i)+".error("+err+");\n";}}code+=onError(err);return code;},onResult:onResult&&function(result){var code='';for(var _i2=0;_i2<_this.options.interceptors.length;_i2++){var _interceptor2=_this.options.interceptors[_i2];if(_interceptor2.result){code+=_this.getInterceptor(_i2)+".result("+result+");\n";}}code+=onResult(result);return code;},onDone:onDone&&function(){var code='';for(var _i3=0;_i3<_this.options.interceptors.length;_i3++){var _interceptor3=_this.options.interceptors[_i3];if(_interceptor3.done){code+=_this.getInterceptor(_i3)+".done();\n";}}code+=onDone();return code;}}));return code;}else {return this.content(options);}};_proto.header=function header(){var code='';if(this.needContext()){code+='var _context = {};\n';}else {code+='var _context;\n';}code+='var _x = this._x;\n';if(this.options.interceptors.length>0){code+='var _taps = this.taps;\n';code+='var _interceptors = this.interceptors;\n';}return code;};_proto.needContext=function needContext(){for(var _iterator=_createForOfIteratorHelperLoose(this.options.taps),_step;!(_step=_iterator()).done;){var tap=_step.value;if(tap.context)return true;}return false;};_proto.callTap=function callTap(tapIndex,_ref){var onError=_ref.onError,onResult=_ref.onResult,onDone=_ref.onDone,rethrowIfPossible=_ref.rethrowIfPossible;var code='';var hasTapCached=false;for(var i=0;i<this.options.interceptors.length;i++){var interceptor=this.options.interceptors[i];if(interceptor.tap){if(!hasTapCached){code+="var _tap"+tapIndex+" = "+this.getTap(tapIndex)+";\n";hasTapCached=true;}code+=this.getInterceptor(i)+".tap("+(interceptor.context?'_context, ':'')+"_tap"+tapIndex+");\n";}}code+="var _fn"+tapIndex+" = "+this.getTapFn(tapIndex)+";\n";var tap=this.options.taps[tapIndex];switch(tap.type){case'sync':if(!rethrowIfPossible){code+="var _hasError"+tapIndex+" = false;\n";code+='try {\n';}if(onResult){code+="var _result"+tapIndex+" = _fn"+tapIndex+"("+this.args({before:tap.context?'_context':undefined})+");\n";}else {code+="_fn"+tapIndex+"("+this.args({before:tap.context?'_context':undefined})+");\n";}if(!rethrowIfPossible){code+='} catch(_err) {\n';code+="_hasError"+tapIndex+" = true;\n";code+=onError('_err');code+='}\n';code+="if(!_hasError"+tapIndex+") {\n";}if(onResult){code+=onResult("_result"+tapIndex);}if(onDone){code+=onDone();}if(!rethrowIfPossible){code+='}\n';}break;case'async':var cbCode='';if(onResult)cbCode+="(function(_err"+tapIndex+", _result"+tapIndex+") {\n";else cbCode+="(function(_err"+tapIndex+") {\n";cbCode+="if(_err"+tapIndex+") {\n";cbCode+=onError("_err"+tapIndex);cbCode+='} else {\n';if(onResult){cbCode+=onResult("_result"+tapIndex);}if(onDone){cbCode+=onDone();}cbCode+='}\n';cbCode+='})';code+="_fn"+tapIndex+"("+this.args({before:tap.context?'_context':undefined,after:cbCode})+");\n";break;case'promise':code+="var _hasResult"+tapIndex+" = false;\n";code+="var _promise"+tapIndex+" = _fn"+tapIndex+"("+this.args({before:tap.context?'_context':undefined})+");\n";code+="if (!_promise"+tapIndex+" || !_promise"+tapIndex+".then)\n";code+=" throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise"+tapIndex+" + ')');\n";code+="_promise"+tapIndex+".then((function(_result"+tapIndex+") {\n";code+="_hasResult"+tapIndex+" = true;\n";if(onResult){code+=onResult("_result"+tapIndex);}if(onDone){code+=onDone();}code+="}), function(_err"+tapIndex+") {\n";code+="if(_hasResult"+tapIndex+") throw _err"+tapIndex+";\n";code+=onError("_err"+tapIndex);code+='});\n';break;}return code;};_proto.callTapsSeries=function callTapsSeries(_ref2){var _this2=this;var _onError=_ref2.onError,onResult=_ref2.onResult,resultReturns=_ref2.resultReturns,onDone=_ref2.onDone,doneReturns=_ref2.doneReturns,rethrowIfPossible=_ref2.rethrowIfPossible;if(this.options.taps.length===0)return onDone();var firstAsync=this.options.taps.findIndex(function(t){return t.type!=='sync';});var somethingReturns=resultReturns||doneReturns;var code='';var current=onDone;var unrollCounter=0;var _loop=function _loop(j){var i=j;var unroll=current!==onDone&&(_this2.options.taps[i].type!=='sync'||unrollCounter++>20);if(unroll){unrollCounter=0;code+="function _next"+i+"() {\n";code+=current();code+="}\n";current=function current(){return (somethingReturns?'return ':'')+"_next"+i+"();\n";};}var done=current;var doneBreak=function doneBreak(skipDone){if(skipDone)return '';return onDone();};var content=_this2.callTap(i,{onError:function onError(error){return _onError(i,error,done,doneBreak);},onResult:onResult&&function(result){return onResult(i,result,done,doneBreak);},onDone:!onResult&&done,rethrowIfPossible:rethrowIfPossible&&(firstAsync<0||i<firstAsync)});current=function current(){return content;};};for(var j=this.options.taps.length-1;j>=0;j--){_loop(j);}code+=current();return code;};_proto.callTapsLooping=function callTapsLooping(_ref3){var onError=_ref3.onError,onDone=_ref3.onDone,rethrowIfPossible=_ref3.rethrowIfPossible;if(this.options.taps.length===0)return onDone();var syncOnly=this.options.taps.every(function(t){return t.type==='sync';});var code='';if(!syncOnly){code+='var _looper = (function() {\n';code+='var _loopAsync = false;\n';}code+='var _loop;\n';code+='do {\n';code+='_loop = false;\n';for(var i=0;i<this.options.interceptors.length;i++){var interceptor=this.options.interceptors[i];if(interceptor.loop){code+=this.getInterceptor(i)+".loop("+this.args({before:interceptor.context?'_context':undefined})+");\n";}}code+=this.callTapsSeries({onError:onError,onResult:function onResult(i,result,next,doneBreak){var code='';code+="if("+result+" !== undefined) {\n";code+='_loop = true;\n';if(!syncOnly)code+='if(_loopAsync) _looper();\n';code+=doneBreak(true);code+="} else {\n";code+=next();code+="}\n";return code;},onDone:onDone&&function(){var code='';code+='if(!_loop) {\n';code+=onDone();code+='}\n';return code;},rethrowIfPossible:rethrowIfPossible&&syncOnly});code+='} while(_loop);\n';if(!syncOnly){code+='_loopAsync = true;\n';code+='});\n';code+='_looper();\n';}return code;};_proto.callTapsParallel=function callTapsParallel(_ref4){var _this3=this;var _onError2=_ref4.onError,onResult=_ref4.onResult,onDone=_ref4.onDone,rethrowIfPossible=_ref4.rethrowIfPossible,_ref4$onTap=_ref4.onTap,onTap=_ref4$onTap===void 0?function(i,run){return run();}:_ref4$onTap;if(this.options.taps.length<=1){return this.callTapsSeries({onError:_onError2,onResult:onResult,onDone:onDone,rethrowIfPossible:rethrowIfPossible});}var code='';code+='do {\n';code+="var _counter = "+this.options.taps.length+";\n";if(onDone){code+='var _done = (function() {\n';code+=onDone();code+='});\n';}var _loop2=function _loop2(i){var done=function done(){if(onDone)return 'if(--_counter === 0) _done();\n';else return '--_counter;';};var doneBreak=function doneBreak(skipDone){if(skipDone||!onDone)return '_counter = 0;\n';else return '_counter = 0;\n_done();\n';};code+='if(_counter <= 0) break;\n';code+=onTap(i,function(){return _this3.callTap(i,{onError:function onError(error){var code='';code+='if(_counter > 0) {\n';code+=_onError2(i,error,done,doneBreak);code+='}\n';return code;},onResult:onResult&&function(result){var code='';code+='if(_counter > 0) {\n';code+=onResult(i,result,done,doneBreak);code+='}\n';return code;},onDone:!onResult&&function(){return done();},rethrowIfPossible:rethrowIfPossible});},done,doneBreak);};for(var i=0;i<this.options.taps.length;i++){_loop2(i);}code+='} while(false);\n';return code;};_proto.args=function args(_temp){var _ref5=_temp===void 0?{}:_temp,before=_ref5.before,after=_ref5.after;var allArgs=this._args;if(before)allArgs=[before].concat(allArgs);if(after)allArgs=allArgs.concat(after);if(allArgs.length===0){return '';}else {return allArgs.join(', ');}};_proto.getTapFn=function getTapFn(idx){return "_x["+idx+"]";};_proto.getTap=function getTap(idx){return "_taps["+idx+"]";};_proto.getInterceptor=function getInterceptor(idx){return "_interceptors["+idx+"]";};return HookCodeFactory;}();var AsyncParallelHookCodeFactory=/*#__PURE__*/function(_HookCodeFactory){_inheritsLoose(AsyncParallelHookCodeFactory,_HookCodeFactory);function AsyncParallelHookCodeFactory(){return _HookCodeFactory.apply(this,arguments)||this;}var _proto=AsyncParallelHookCodeFactory.prototype;_proto.content=function content(_ref){var _onError=_ref.onError,onDone=_ref.onDone;return this.callTapsParallel({onError:function onError(i,err,done,doneBreak){return _onError(err)+doneBreak(true);},onDone:onDone});};return AsyncParallelHookCodeFactory;}(HookCodeFactory);var factory=new AsyncParallelHookCodeFactory();var COMPILE=function COMPILE(options){factory.setup(this,options);return factory.create(options);};var AsyncParallelHook=/*#__PURE__*/function(_Hook){_inheritsLoose(AsyncParallelHook,_Hook);function AsyncParallelHook(args,name){var _this;if(args===void 0){args=[];}if(name===void 0){name=undefined;}_this=_Hook.call(this,args,name)||this;_this.compile=COMPILE;_this._call=undefined;_this.call=undefined;return _this;}return AsyncParallelHook;}(Hook);// export function AsyncParallelHook(args = [], name = undefined) {
8602
- // const hook = new Hook(args, name);
8603
- // hook.constructor = AsyncParallelHook;
8604
- // hook.compile = COMPILE;
8605
- // hook._call = undefined;
8606
- // hook.call = undefined;
8607
- // return hook;
8728
+ // getExtentOfChar(charnum: number): DOMRect {
8729
+ // throw new Error('Method not implemented.');
8608
8730
  // }
8609
- // AsyncParallelHook.prototype = null;
8610
- var AsyncSeriesWaterfallHookCodeFactory=/*#__PURE__*/function(_HookCodeFactory){_inheritsLoose(AsyncSeriesWaterfallHookCodeFactory,_HookCodeFactory);function AsyncSeriesWaterfallHookCodeFactory(){return _HookCodeFactory.apply(this,arguments)||this;}var _proto=AsyncSeriesWaterfallHookCodeFactory.prototype;_proto.content=function content(_ref){var _this=this;var _onError=_ref.onError,onResult=_ref.onResult,onDone=_ref.onDone;return this.callTapsSeries({onError:function onError(i,err,next,doneBreak){return _onError(err)+doneBreak(true);},onResult:function onResult(i,result,next){var code='';code+="if("+result+" !== undefined) {\n";code+=_this._args[0]+" = "+result+";\n";code+="}\n";code+=next();return code;},onDone:function onDone(){return onResult(_this._args[0]);}});};return AsyncSeriesWaterfallHookCodeFactory;}(HookCodeFactory);var factory$1=new AsyncSeriesWaterfallHookCodeFactory();var COMPILE$1=function COMPILE(options){factory$1.setup(this,options);return factory$1.create(options);};// export function AsyncSeriesWaterfallHook(args = [], name = undefined) {
8611
- // if (args.length < 1) throw new Error('Waterfall hooks must have at least one argument');
8612
- // const hook = new Hook(args, name);
8613
- // hook.constructor = AsyncSeriesWaterfallHook;
8614
- // hook.compile = COMPILE;
8615
- // hook._call = undefined;
8616
- // hook.call = undefined;
8617
- // return hook;
8731
+ // getNumberOfChars(): number {
8732
+ // throw new Error('Method not implemented.');
8618
8733
  // }
8619
- // AsyncSeriesWaterfallHook.prototype = null;
8620
- var AsyncSeriesWaterfallHook=/*#__PURE__*/function(_Hook){_inheritsLoose(AsyncSeriesWaterfallHook,_Hook);function AsyncSeriesWaterfallHook(args,name){var _this2;if(args===void 0){args=[];}if(name===void 0){name=undefined;}_this2=_Hook.call(this,args,name)||this;_this2.compile=COMPILE$1;_this2._call=undefined;_this2.call=undefined;return _this2;}return AsyncSeriesWaterfallHook;}(Hook);var SyncHookCodeFactory=/*#__PURE__*/function(_HookCodeFactory){_inheritsLoose(SyncHookCodeFactory,_HookCodeFactory);function SyncHookCodeFactory(){return _HookCodeFactory.apply(this,arguments)||this;}var _proto=SyncHookCodeFactory.prototype;_proto.content=function content(_ref){var _onError=_ref.onError,onDone=_ref.onDone,rethrowIfPossible=_ref.rethrowIfPossible;return this.callTapsSeries({onError:function onError(i,err){return _onError(err);},onDone:onDone,rethrowIfPossible:rethrowIfPossible});};return SyncHookCodeFactory;}(HookCodeFactory);var factory$2=new SyncHookCodeFactory();var TAP_ASYNC=function TAP_ASYNC(){throw new Error('tapAsync is not supported on a SyncHook');};var TAP_PROMISE=function TAP_PROMISE(){throw new Error('tapPromise is not supported on a SyncHook');};var COMPILE$2=function COMPILE(options){factory$2.setup(this,options);return factory$2.create(options);};var SyncHook=/*#__PURE__*/function(_Hook){_inheritsLoose(SyncHook,_Hook);function SyncHook(args,name){var _this;if(args===void 0){args=[];}if(name===void 0){name=undefined;}_this=_Hook.call(this,args,name)||this;_this.tapAsync=TAP_ASYNC;_this.tapPromise=TAP_PROMISE;_this.compile=COMPILE$2;return _this;}return SyncHook;}(Hook);// export function SyncHook(args = [], name = undefined) {
8621
- // const hook = new Hook(args, name);
8622
- // hook.constructor = SyncHook;
8623
- // hook.tapAsync = TAP_ASYNC;
8624
- // hook.tapPromise = TAP_PROMISE;
8625
- // hook.compile = COMPILE;
8626
- // return hook;
8734
+ // getRotationOfChar(charnum: number): number {
8735
+ // throw new Error('Method not implemented.');
8627
8736
  // }
8628
- // SyncHook.prototype = null;
8629
- var SyncWaterfallHookCodeFactory=/*#__PURE__*/function(_HookCodeFactory){_inheritsLoose(SyncWaterfallHookCodeFactory,_HookCodeFactory);function SyncWaterfallHookCodeFactory(){return _HookCodeFactory.apply(this,arguments)||this;}var _proto=SyncWaterfallHookCodeFactory.prototype;_proto.content=function content(_ref){var _this=this;var _onError=_ref.onError,onResult=_ref.onResult,resultReturns=_ref.resultReturns,rethrowIfPossible=_ref.rethrowIfPossible;return this.callTapsSeries({onError:function onError(i,err){return _onError(err);},onResult:function onResult(i,result,next){var code='';code+="if("+result+" !== undefined) {\n";code+=_this._args[0]+" = "+result+";\n";code+="}\n";code+=next();return code;},onDone:function onDone(){return onResult(_this._args[0]);},doneReturns:resultReturns,rethrowIfPossible:rethrowIfPossible});};return SyncWaterfallHookCodeFactory;}(HookCodeFactory);var factory$3=new SyncWaterfallHookCodeFactory();var TAP_ASYNC$1=function TAP_ASYNC(){throw new Error('tapAsync is not supported on a SyncWaterfallHook');};var TAP_PROMISE$1=function TAP_PROMISE(){throw new Error('tapPromise is not supported on a SyncWaterfallHook');};var COMPILE$3=function COMPILE(options){factory$3.setup(this,options);return factory$3.create(options);};var SyncWaterfallHook=/*#__PURE__*/function(_SyncHook){_inheritsLoose(SyncWaterfallHook,_SyncHook);function SyncWaterfallHook(args,name){var _this2;if(args===void 0){args=[];}if(name===void 0){name=undefined;}_this2=_SyncHook.call(this,args,name)||this;_this2.tapAsync=TAP_ASYNC$1;_this2.tapPromise=TAP_PROMISE$1;_this2.compile=COMPILE$3;return _this2;}return SyncWaterfallHook;}(SyncHook);// export function SyncWaterfallHook(args = [], name = undefined) {
8630
- // if (args.length < 1) throw new Error('Waterfall hooks must have at least one argument');
8631
- // const hook = new Hook(args, name);
8632
- // hook.constructor = SyncWaterfallHook;
8633
- // hook.tapAsync = TAP_ASYNC;
8634
- // hook.tapPromise = TAP_PROMISE;
8635
- // hook.compile = COMPILE;
8636
- // return hook;
8737
+ // getStartPositionOfChar(charnum: number): DOMPoint {
8738
+ // throw new Error('Method not implemented.');
8637
8739
  // }
8638
- // SyncWaterfallHook.prototype = null;
8639
- var genericFontFamilies=['serif','sans-serif','monospace','cursive','fantasy','system-ui'];var stringRegExp=/([\"\'])[^\'\"]+\1/;function toFontString(attributes){var fontSize=attributes.fontSize,fontFamily=attributes.fontFamily,fontStyle=attributes.fontStyle,fontVariant=attributes.fontVariant,fontWeight=attributes.fontWeight;// build canvas api font setting from individual components. Convert a numeric this.fontSize to px
8640
- // const fontSizeString: string = isNumber(fontSize) ? `${fontSize}px` : fontSize.toString();
8641
- var fontSizeString=isNumber(fontSize)&&fontSize+"px"||'16px';// Clean-up fontFamily property by quoting each font name
8642
- // this will support font names with spaces
8643
- // @ts-ignore
8644
- var fontFamilies=isString(fontFamily)?fontFamily.split(','):[fontFamily];for(var i=fontFamilies.length-1;i>=0;i--){// Trim any extra white-space
8645
- var _fontFamily=fontFamilies[i].trim();// Check if font already contains strings
8646
- if(!stringRegExp.test(_fontFamily)&&genericFontFamilies.indexOf(_fontFamily)<0){_fontFamily="\""+_fontFamily+"\"";}fontFamilies[i]=_fontFamily;}return fontStyle+" "+fontVariant+" "+fontWeight+" "+fontSizeString+" "+fontFamilies.join(',');}/**
8647
- * Thanks for following contributor of codes
8648
- * https://gist.github.com/1866474
8649
- * http://paulirish.com/2011/requestanimationframe-for-smart-animating/
8650
- * http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
8651
- * https://github.com/Financial-Times/polyfill-library/blob/master/polyfills/requestAnimationFrame/polyfill.js
8652
- **/var uId=1;var uniqueId=function uniqueId(){return uId++;};// We use `self` instead of `window` for `WebWorker` support.
8653
- var root=typeof self==='object'&&self.self==self?self:// @ts-ignore
8654
- typeof global==='object'&&global.global==global?// @ts-ignore
8655
- global:{};var nowOffset=Date.now();// use performance api if exist, otherwise use Date.now.
8656
- // Date.now polyfill required.
8657
- var pnow=function pnow(){if(root.performance&&typeof root.performance.now==='function'){return root.performance.now();}// fallback
8658
- return Date.now()-nowOffset;};var reservedCBs={};var lastTime=Date.now();var polyfillRaf=function polyfillRaf(callback){if(typeof callback!=='function'){throw new TypeError(callback+' is not a function');}var currentTime=Date.now();var gap=currentTime-lastTime;var delay=gap>16?0:16-gap;var id=uniqueId();reservedCBs[id]=callback;// keys(reservedCBs).length > 1 의미는 이미 setTimeout 이 걸려있는 경우.
8659
- // 함께 callback 이 실행될 수 있게 reservedCBs 에만 추가해주고 return
8660
- if(Object.keys(reservedCBs).length>1)return id;setTimeout(function(){lastTime=currentTime;var copied=reservedCBs;reservedCBs={};Object.keys(copied).forEach(function(key){return copied[key](pnow());});},delay);return id;};var polyfillCaf=function polyfillCaf(id){delete reservedCBs[id];};var vendorPrefixes=['','webkit','moz','ms','o'];var getRequestAnimationFrame=function getRequestAnimationFrame(vp){if(typeof vp!=='string')return polyfillRaf;if(vp==='')return root['requestAnimationFrame'];return root[vp+'RequestAnimationFrame'];};var getCancelAnimationFrame=function getCancelAnimationFrame(vp){if(typeof vp!=='string')return polyfillCaf;if(vp==='')return root['cancelAnimationFrame'];return root[vp+'CancelAnimationFrame']||root[vp+'CancelRequestAnimationFrame'];};var find=function find(arr,predicate){var i=0;while(arr[i]!==void 0){if(predicate(arr[i]))return arr[i];i=i+1;}};var vp=find(vendorPrefixes,function(vp){return !!getRequestAnimationFrame(vp);});var raf=getRequestAnimationFrame(vp);var caf=getCancelAnimationFrame(vp);root.requestAnimationFrame=raf;root.cancelAnimationFrame=caf;/**
8661
- * Axis-Aligned Bounding Box
8662
- * 为了便于后续 Frustum Culling,通过查找表定义 p-vertex 和 n-vertex
8663
- * @see https://github.com/antvis/GWebGPUEngine/issues/3
8664
- */var AABB=/*#__PURE__*/function(){AABB.isEmpty=function isEmpty(aabb){return !aabb||aabb.halfExtents[0]===0&&aabb.halfExtents[1]===0&&aabb.halfExtents[2]===0;};// center: vec3 = vec3.create();
8665
- // halfExtents: vec3 = vec3.create();
8666
- // min: vec3 = vec3.create();
8667
- // max: vec3 = vec3.create();
8668
- function AABB(center,halfExtents){if(center===void 0){center=[0,0,0];}if(halfExtents===void 0){halfExtents=[0,0,0];}this.center=[0,0,0];this.halfExtents=[0,0,0];this.min=[0,0,0];this.max=[0,0,0];this.update(center,halfExtents);}var _proto=AABB.prototype;_proto.update=function update(center,halfExtents){copyVec3(this.center,center);copyVec3(this.halfExtents,halfExtents);subVec3(this.min,this.center,this.halfExtents);addVec3(this.max,this.center,this.halfExtents);// vec3.copy(this.center, center);
8669
- // vec3.copy(this.halfExtents, halfExtents);
8670
- // vec3.sub(this.min, this.center, this.halfExtents);
8671
- // vec3.add(this.max, this.center, this.halfExtents);
8672
- };_proto.setMinMax=function setMinMax(min,max){// vec3.add(this.center, max, min);
8673
- // vec3.scale(this.center, this.center, 0.5);
8674
- // vec3.sub(this.halfExtents, max, min);
8675
- // vec3.scale(this.halfExtents, this.halfExtents, 0.5);
8676
- // vec3.copy(this.min, min);
8677
- // vec3.copy(this.max, max);
8678
- addVec3(this.center,max,min);scaleVec3(this.center,this.center,0.5);subVec3(this.halfExtents,max,min);scaleVec3(this.halfExtents,this.halfExtents,0.5);copyVec3(this.min,min);copyVec3(this.max,max);};_proto.getMin=function getMin(){return this.min;};_proto.getMax=function getMax(){return this.max;};_proto.add=function add(aabb){if(AABB.isEmpty(aabb)){return;}if(AABB.isEmpty(this)){this.setMinMax(aabb.getMin(),aabb.getMax());return;}var tc=this.center;var tcx=tc[0];var tcy=tc[1];var tcz=tc[2];var th=this.halfExtents;var thx=th[0];var thy=th[1];var thz=th[2];var tminx=tcx-thx;var tmaxx=tcx+thx;var tminy=tcy-thy;var tmaxy=tcy+thy;var tminz=tcz-thz;var tmaxz=tcz+thz;var oc=aabb.center;var ocx=oc[0];var ocy=oc[1];var ocz=oc[2];var oh=aabb.halfExtents;var ohx=oh[0];var ohy=oh[1];var ohz=oh[2];var ominx=ocx-ohx;var omaxx=ocx+ohx;var ominy=ocy-ohy;var omaxy=ocy+ohy;var ominz=ocz-ohz;var omaxz=ocz+ohz;if(ominx<tminx){tminx=ominx;}if(omaxx>tmaxx){tmaxx=omaxx;}if(ominy<tminy){tminy=ominy;}if(omaxy>tmaxy){tmaxy=omaxy;}if(ominz<tminz){tminz=ominz;}if(omaxz>tmaxz){tmaxz=omaxz;}tc[0]=(tminx+tmaxx)*0.5;tc[1]=(tminy+tmaxy)*0.5;tc[2]=(tminz+tmaxz)*0.5;th[0]=(tmaxx-tminx)*0.5;th[1]=(tmaxy-tminy)*0.5;th[2]=(tmaxz-tminz)*0.5;this.min[0]=tminx;this.min[1]=tminy;this.min[2]=tminz;this.max[0]=tmaxx;this.max[1]=tmaxy;this.max[2]=tmaxz;};_proto.setFromTransformedAABB=function setFromTransformedAABB(aabb,m){var bc=this.center;var br=this.halfExtents;var ac=aabb.center;var ar=aabb.halfExtents;var mx0=m[0];var mx1=m[4];var mx2=m[8];var my0=m[1];var my1=m[5];var my2=m[9];var mz0=m[2];var mz1=m[6];var mz2=m[10];var mx0a=Math.abs(mx0);var mx1a=Math.abs(mx1);var mx2a=Math.abs(mx2);var my0a=Math.abs(my0);var my1a=Math.abs(my1);var my2a=Math.abs(my2);var mz0a=Math.abs(mz0);var mz1a=Math.abs(mz1);var mz2a=Math.abs(mz2);bc[0]=m[12]+mx0*ac[0]+mx1*ac[1]+mx2*ac[2];bc[1]=m[13]+my0*ac[0]+my1*ac[1]+my2*ac[2];bc[2]=m[14]+mz0*ac[0]+mz1*ac[1]+mz2*ac[2];// vec3.set(
8679
- // bc,
8680
- // m[12] + mx0 * ac[0] + mx1 * ac[1] + mx2 * ac[2],
8681
- // m[13] + my0 * ac[0] + my1 * ac[1] + my2 * ac[2],
8682
- // m[14] + mz0 * ac[0] + mz1 * ac[1] + mz2 * ac[2],
8683
- // );
8684
- br[0]=mx0a*ar[0]+mx1a*ar[1]+mx2a*ar[2];br[1]=my0a*ar[0]+my1a*ar[1]+my2a*ar[2];br[2]=mz0a*ar[0]+mz1a*ar[1]+mz2a*ar[2];// vec3.set(
8685
- // br,
8686
- // mx0a * ar[0] + mx1a * ar[1] + mx2a * ar[2],
8687
- // my0a * ar[0] + my1a * ar[1] + my2a * ar[2],
8688
- // mz0a * ar[0] + mz1a * ar[1] + mz2a * ar[2],
8689
- // );
8690
- // this.min = vec3.sub(this.min, bc, br);
8691
- // this.max = vec3.add(this.max, bc, br);
8692
- subVec3(this.min,bc,br);addVec3(this.max,bc,br);};_proto.intersects=function intersects(aabb){var aMax=this.getMax();var aMin=this.getMin();var bMax=aabb.getMax();var bMin=aabb.getMin();return aMin[0]<=bMax[0]&&aMax[0]>=bMin[0]&&aMin[1]<=bMax[1]&&aMax[1]>=bMin[1]&&aMin[2]<=bMax[2]&&aMax[2]>=bMin[2];};_proto.intersection=function intersection(aabb){if(!this.intersects(aabb)){return null;}var intersection=new AABB();// const min = vec3.max(vec3.create(), this.getMin(), aabb.getMin());
8693
- // const max = vec3.min(vec3.create(), this.getMax(), aabb.getMax());
8694
- var min=maxVec3([0,0,0],this.getMin(),aabb.getMin());var max=minVec3([0,0,0],this.getMax(),aabb.getMax());intersection.setMinMax(min,max);return intersection;}// containsPoint(point: vec3) {
8695
- // const min = this.getMin();
8696
- // const max = this.getMax();
8697
- // return !(
8698
- // point[0] < min[0] ||
8699
- // point[0] > max[0] ||
8700
- // point[1] < min[1] ||
8701
- // point[1] > max[1] ||
8702
- // point[2] < min[2] ||
8703
- // point[2] > max[2]
8704
- // );
8740
+ // getSubStringLength(charnum: number, nchars: number): number {
8741
+ // throw new Error('Method not implemented.');
8705
8742
  // }
8706
- /**
8707
- * get n-vertex
8708
- * @param plane plane of CullingVolume
8709
- */;_proto.getNegativeFarPoint=function getNegativeFarPoint(plane){if(plane.pnVertexFlag===0x111){return copyVec3([0,0,0],this.min);// return vec3.copy(vec3.create(), this.min);
8710
- }else if(plane.pnVertexFlag===0x110){return [this.min[0],this.min[1],this.max[2]];// return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
8711
- }else if(plane.pnVertexFlag===0x101){return [this.min[0],this.max[1],this.min[2]];// return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
8712
- }else if(plane.pnVertexFlag===0x100){return [this.min[0],this.max[1],this.max[2]];// return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
8713
- }else if(plane.pnVertexFlag===0x011){return [this.max[0],this.min[1],this.min[2]];// return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
8714
- }else if(plane.pnVertexFlag===0x010){return [this.max[0],this.min[1],this.max[2]];// return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
8715
- }else if(plane.pnVertexFlag===0x001){return [this.max[0],this.max[1],this.min[2]];// return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
8716
- }else {return [this.max[0],this.max[1],this.max[2]];// return vec3.fromValues(this.max[0], this.max[1], this.max[2]);
8717
- }}/**
8718
- * get p-vertex
8719
- * @param plane plane of CullingVolume
8720
- */;_proto.getPositiveFarPoint=function getPositiveFarPoint(plane){if(plane.pnVertexFlag===0x111){return copyVec3([0,0,0],this.max);// return vec3.copy(vec3.create(), this.max);
8721
- }else if(plane.pnVertexFlag===0x110){return [this.max[0],this.max[1],this.min[2]];// return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
8722
- }else if(plane.pnVertexFlag===0x101){return [this.max[0],this.min[1],this.max[2]];// return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
8723
- }else if(plane.pnVertexFlag===0x100){return [this.max[0],this.min[1],this.min[2]];// return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
8724
- }else if(plane.pnVertexFlag===0x011){return [this.min[0],this.max[1],this.max[2]];// return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
8725
- }else if(plane.pnVertexFlag===0x010){return [this.min[0],this.max[1],this.min[2]];// return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
8726
- }else if(plane.pnVertexFlag===0x001){return [this.min[0],this.min[1],this.max[2]];// return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
8727
- }else {return [this.min[0],this.min[1],this.min[2]];// return vec3.fromValues(this.min[0], this.min[1], this.min[2]);
8728
- }};return AABB;}();var Plane=/*#__PURE__*/function(){/**
8729
- * lookup table for p-vertex & n-vertex when doing frustum culling
8730
- */function Plane(distance,normal){this.distance=void 0;this.normal=void 0;this.pnVertexFlag=void 0;this.distance=distance||0;this.normal=normal||fromValues$2(0,1,0);this.updatePNVertexFlag();}var _proto=Plane.prototype;_proto.updatePNVertexFlag=function updatePNVertexFlag(){this.pnVertexFlag=(Number(this.normal[0]>=0)<<8)+(Number(this.normal[1]>=0)<<4)+Number(this.normal[2]>=0);};_proto.distanceToPoint=function distanceToPoint(point){return dot(point,this.normal)-this.distance;};_proto.normalize=function normalize(){var invLen=1/len(this.normal);scale$1(this.normal,this.normal,invLen);this.distance*=invLen;};_proto.intersectsLine=function intersectsLine(start,end,point){var d0=this.distanceToPoint(start);var d1=this.distanceToPoint(end);var t=d0/(d0-d1);var intersects=t>=0&&t<=1;if(intersects&&point){lerp(point,start,end,t);}return intersects;};return Plane;}();(function(Mask){Mask[Mask["OUTSIDE"]=4294967295]="OUTSIDE";Mask[Mask["INSIDE"]=0]="INSIDE";Mask[Mask["INDETERMINATE"]=2147483647]="INDETERMINATE";})(exports.Mask||(exports.Mask={}));var Frustum=/*#__PURE__*/function(){function Frustum(planes){this.planes=[];if(planes){this.planes=planes;}else {for(var i=0;i<6;i++){this.planes.push(new Plane());}}}/**
8731
- * extract 6 planes from projectionMatrix
8732
- * @see http://www8.cs.umu.se/kurser/5DV051/HT12/lab/plane_extraction.pdf
8733
- */var _proto=Frustum.prototype;_proto.extractFromVPMatrix=function extractFromVPMatrix(projectionMatrix){// @ts-ignore
8734
- var m0=projectionMatrix[0],m1=projectionMatrix[1],m2=projectionMatrix[2],m3=projectionMatrix[3],m4=projectionMatrix[4],m5=projectionMatrix[5],m6=projectionMatrix[6],m7=projectionMatrix[7],m8=projectionMatrix[8],m9=projectionMatrix[9],m10=projectionMatrix[10],m11=projectionMatrix[11],m12=projectionMatrix[12],m13=projectionMatrix[13],m14=projectionMatrix[14],m15=projectionMatrix[15];// right
8735
- set$1(this.planes[0].normal,m3-m0,m7-m4,m11-m8);this.planes[0].distance=m15-m12;// left
8736
- set$1(this.planes[1].normal,m3+m0,m7+m4,m11+m8);this.planes[1].distance=m15+m12;// bottom
8737
- set$1(this.planes[2].normal,m3+m1,m7+m5,m11+m9);this.planes[2].distance=m15+m13;// top
8738
- set$1(this.planes[3].normal,m3-m1,m7-m5,m11-m9);this.planes[3].distance=m15-m13;// far
8739
- set$1(this.planes[4].normal,m3-m2,m7-m6,m11-m10);this.planes[4].distance=m15-m14;// near
8740
- set$1(this.planes[5].normal,m3+m2,m7+m6,m11+m10);this.planes[5].distance=m15+m14;this.planes.forEach(function(plane){plane.normalize();plane.updatePNVertexFlag();});};return Frustum;}();var Rectangle=/*#__PURE__*/function(){function Rectangle(x,y,width,height){this.x=void 0;this.y=void 0;this.width=void 0;this.height=void 0;this.left=void 0;this.right=void 0;this.top=void 0;this.bottom=void 0;this.x=x;this.y=y;this.width=width;this.height=height;this.left=x;this.right=x+width;this.top=y;this.bottom=y+height;}var _proto=Rectangle.prototype;_proto.toJSON=function toJSON(){};return Rectangle;}();/**
8743
+ // selectSubString(charnum: number, nchars: number): void {
8744
+ // throw new Error('Method not implemented.');
8745
+ // }
8746
+ ;_proto.getLineBoundingRects=function getLineBoundingRects(){var _this$parsedStyle$met2;return ((_this$parsedStyle$met2=this.parsedStyle.metrics)===null||_this$parsedStyle$met2===void 0?void 0:_this$parsedStyle$met2.lineMetrics)||[];};_proto.isOverflowing=function isOverflowing(){return !!this.parsedStyle.isOverflowing;};return Text;}(DisplayObject);/**
8741
8747
  * Blink used them in code generation(css_properties.json5)
8742
8748
  */var BUILT_IN_PROPERTIES=[{/**
8743
8749
  * used in CSS Layout API
@@ -8801,11 +8807,56 @@
8801
8807
  *
8802
8808
  * * calculate used value
8803
8809
  * * post process
8804
- */;_proto.processProperties=function processProperties(object,attributes,options){var _this2=this;if(options===void 0){options={skipUpdateAttribute:false,skipParse:false,forceUpdateGeometry:false,usedAttributes:[]};}if(!runtime.enableCSSParsing){Object.assign(object.attributes,attributes);object.parsedStyle=Object.assign(object.parsedStyle,attributes);if(attributes.fill){object.parsedStyle.fill=parseColor(attributes.fill);}if(attributes.stroke){object.parsedStyle.stroke=parseColor(attributes.stroke);}// @ts-ignore
8805
- if(attributes.cx||attributes.cy){// @ts-ignore
8806
- runtime.CSSPropertySyntaxFactory['<coordinate>'].postProcessor(object);}// console.log(object.parsedStyle);
8807
- // console.log(attributes);
8808
- this.updateGeometry(object);return;}var _options=options,skipUpdateAttribute=_options.skipUpdateAttribute,skipParse=_options.skipParse,forceUpdateGeometry=_options.forceUpdateGeometry,usedAttributes=_options.usedAttributes;var needUpdateGeometry=forceUpdateGeometry;var attributeNames=Object.keys(attributes);attributeNames.forEach(function(attributeName){var _propertyMetadataCach;var name=formatAttributeName(attributeName);if(!skipUpdateAttribute){object.attributes[name]=attributes[attributeName];}if(!needUpdateGeometry&&((_propertyMetadataCach=propertyMetadataCache[name])===null||_propertyMetadataCach===void 0?void 0:_propertyMetadataCach.l)){needUpdateGeometry=true;}});if(!skipParse){attributeNames.forEach(function(name){object.computedStyle[name]=_this2.parseProperty(name,object.attributes[name],object);});}// let hasUnresolvedProperties = false;
8810
+ */;_proto.processProperties=function processProperties(object,attributes,options){var _this2=this;if(options===void 0){options={skipUpdateAttribute:false,skipParse:false,forceUpdateGeometry:false,usedAttributes:[]};}if(!runtime.enableCSSParsing){// alias
8811
+ // @ts-ignore
8812
+ if(attributes.src){// @ts-ignore
8813
+ attributes.img=attributes.src;}// @ts-ignore
8814
+ if(attributes.d){// @ts-ignore
8815
+ attributes.path=attributes.d;}if(attributes.strokeDasharray){attributes.lineDash=attributes.strokeDasharray;}if(attributes.strokeWidth){attributes.lineWidth=attributes.strokeWidth;}// @ts-ignore
8816
+ if(attributes.textAnchor){// @ts-ignore
8817
+ attributes.textAlign=attributes.textAnchor;}Object.assign(object.attributes,attributes);var _attributeNames=Object.keys(attributes);// clipPath
8818
+ var oldClipPath=object.parsedStyle.clipPath;var oldOffsetPath=object.parsedStyle.offsetPath;object.parsedStyle=Object.assign(object.parsedStyle,attributes);if(attributes.fill){object.parsedStyle.fill=parseColor(attributes.fill);}if(attributes.stroke){object.parsedStyle.stroke=parseColor(attributes.stroke);}if(attributes.shadowColor){object.parsedStyle.shadowColor=parseColor(attributes.shadowColor);}if(attributes.filter){object.parsedStyle.filter=parseFilter(attributes.filter);}// Rect
8819
+ // @ts-ignore
8820
+ if(!isNil(attributes.radius)){// @ts-ignore
8821
+ object.parsedStyle.radius=parseDimensionArrayFormat(// @ts-ignore
8822
+ attributes.radius,4);}// Polyline
8823
+ if(!isNil(attributes.lineDash)){object.parsedStyle.lineDash=parseDimensionArrayFormat(attributes.lineDash,2);}// @ts-ignore
8824
+ if(attributes.points){// @ts-ignore
8825
+ object.parsedStyle.points=parsePoints(attributes.points,object);}// Path
8826
+ // @ts-ignore
8827
+ if(attributes.path===''){object.parsedStyle.path=_extends({},EMPTY_PARSED_PATH);}// @ts-ignore
8828
+ if(attributes.path){object.parsedStyle.path=parsePath(// @ts-ignore
8829
+ attributes.path,object);}// Text
8830
+ if(attributes.textTransform){runtime.CSSPropertySyntaxFactory['<text-transform>'].calculator(null,null,{value:attributes.textTransform},object,null);}if(attributes.clipPath){runtime.CSSPropertySyntaxFactory['<defined-path>'].calculator('clipPath',oldClipPath,attributes.clipPath,object,this);}if(attributes.offsetPath){runtime.CSSPropertySyntaxFactory['<defined-path>'].calculator('offsetPath',oldOffsetPath,attributes.offsetPath,object,this);}if(attributes.anchor){object.parsedStyle.anchor=parseDimensionArrayFormat(// @ts-ignorex
8831
+ attributes.anchor,2);}if(attributes.transform){object.parsedStyle.transform=parseTransform(attributes.transform);}if(attributes.transformOrigin){object.parsedStyle.transformOrigin=parseTransformOrigin(attributes.transformOrigin);}// Marker
8832
+ // @ts-ignore
8833
+ if(attributes.markerStart){// @ts-ignore
8834
+ object.parsedStyle.markerStart=runtime.CSSPropertySyntaxFactory['<marker>'].calculator(null,// @ts-ignore
8835
+ attributes.markerStart,// @ts-ignore
8836
+ attributes.markerStart,null,null);}// @ts-ignore
8837
+ if(attributes.markerEnd){// @ts-ignore
8838
+ object.parsedStyle.markerEnd=runtime.CSSPropertySyntaxFactory['<marker>'].calculator(null,// @ts-ignore
8839
+ attributes.markerEnd,// @ts-ignore
8840
+ attributes.markerEnd,null,null);}// @ts-ignore
8841
+ if(attributes.markerMid){// @ts-ignore
8842
+ object.parsedStyle.markerMid=runtime.CSSPropertySyntaxFactory['<marker>'].calculator('',// @ts-ignore
8843
+ attributes.markerMid,// @ts-ignore
8844
+ attributes.markerMid,null,null);}if(// Circle & Ellipse
8845
+ (object.nodeName===exports.Shape.CIRCLE||object.nodeName===exports.Shape.ELLIPSE)&&(// @ts-ignore
8846
+ !isNil(attributes.cx)||// @ts-ignore
8847
+ !isNil(attributes.cy))||(object.nodeName===exports.Shape.RECT||object.nodeName===exports.Shape.IMAGE||object.nodeName===exports.Shape.GROUP||object.nodeName===exports.Shape.HTML||object.nodeName===exports.Shape.TEXT||object.nodeName===exports.Shape.MESH)&&(// @ts-ignore
8848
+ !isNil(attributes.x)||// @ts-ignore
8849
+ !isNil(attributes.y)||// @ts-ignore
8850
+ !isNil(attributes.z))||// Line
8851
+ object.nodeName===exports.Shape.LINE&&(// @ts-ignore
8852
+ !isNil(attributes.x1)||// @ts-ignore
8853
+ !isNil(attributes.y1)||// @ts-ignore
8854
+ !isNil(attributes.z1)||// @ts-ignore
8855
+ !isNil(attributes.x2)||// @ts-ignore
8856
+ !isNil(attributes.y2)||// @ts-ignore
8857
+ !isNil(attributes.z2))){runtime.CSSPropertySyntaxFactory['<coordinate>'].postProcessor(object,_attributeNames);}if(!isNil(attributes.zIndex)){runtime.CSSPropertySyntaxFactory['<z-index>'].postProcessor(object,_attributeNames);}// @ts-ignore
8858
+ if(attributes.path){runtime.CSSPropertySyntaxFactory['<path>'].postProcessor(object,_attributeNames);}// @ts-ignore
8859
+ if(attributes.points){runtime.CSSPropertySyntaxFactory['<list-of-points>'].postProcessor(object,_attributeNames);}if(!isNil(attributes.offsetDistance)){runtime.CSSPropertySyntaxFactory['<offset-distance>'].postProcessor(object,_attributeNames);}if(attributes.transform){runtime.CSSPropertySyntaxFactory['<transform>'].postProcessor(object,_attributeNames);}this.updateGeometry(object);return;}var _options=options,skipUpdateAttribute=_options.skipUpdateAttribute,skipParse=_options.skipParse,forceUpdateGeometry=_options.forceUpdateGeometry,usedAttributes=_options.usedAttributes;var needUpdateGeometry=forceUpdateGeometry;var attributeNames=Object.keys(attributes);attributeNames.forEach(function(attributeName){var _propertyMetadataCach;var name=formatAttributeName(attributeName);if(!skipUpdateAttribute){object.attributes[name]=attributes[attributeName];}if(!needUpdateGeometry&&((_propertyMetadataCach=propertyMetadataCache[name])===null||_propertyMetadataCach===void 0?void 0:_propertyMetadataCach.l)){needUpdateGeometry=true;}});if(!skipParse){attributeNames.forEach(function(name){object.computedStyle[name]=_this2.parseProperty(name,object.attributes[name],object);});}// let hasUnresolvedProperties = false;
8809
8860
  // parse according to priority
8810
8861
  // path 50
8811
8862
  // points 50
@@ -8815,7 +8866,22 @@
8815
8866
  // transform 100
8816
8867
  // transformOrigin 100
8817
8868
  if(usedAttributes===null||usedAttributes===void 0?void 0:usedAttributes.length){// uniqueAttributeSet.clear();
8818
- attributeNames=Array.from(new Set(attributeNames.concat(usedAttributes)));}['path','points','text','textTransform','anchor','transform','transformOrigin'].forEach(function(name){var index=attributeNames.indexOf(name);if(index>-1){attributeNames.splice(index,1);attributeNames.push(name);}});attributeNames.forEach(function(name){// some style props maybe deleted after parsing such as `anchor` in Text
8869
+ attributeNames=Array.from(new Set(attributeNames.concat(usedAttributes)));}// [
8870
+ // 'path',
8871
+ // 'points',
8872
+ // 'text',
8873
+ // 'textTransform',
8874
+ // 'anchor',
8875
+ // 'transform',
8876
+ // 'transformOrigin',
8877
+ // ].forEach((name) => {
8878
+ // const index = attributeNames.indexOf(name);
8879
+ // if (index > -1) {
8880
+ // attributeNames.splice(index, 1);
8881
+ // attributeNames.push(name);
8882
+ // }
8883
+ // });
8884
+ attributeNames.forEach(function(name){// some style props maybe deleted after parsing such as `anchor` in Text
8819
8885
  if(name in object.computedStyle){object.parsedStyle[name]=_this2.computeProperty(name,object.computedStyle[name],object);}});// if (hasUnresolvedProperties) {
8820
8886
  // this.dirty = true;
8821
8887
  // return;
@@ -9441,14 +9507,13 @@
9441
9507
  // getComputedStyle(node: DisplayObject) {
9442
9508
  // return node.computedStyle;
9443
9509
  // }
9444
- ;_proto.destroy=function destroy(destroyScenegraph,skipTriggerEvent){if(destroyScenegraph===void 0){destroyScenegraph=true;}if(skipTriggerEvent===void 0){skipTriggerEvent=false;}if(!skipTriggerEvent){this.dispatchEvent(new CustomEvent(exports.CanvasEvent.BEFORE_DESTROY));}if(this.frameId){var cancelRAF=this.getConfig().cancelAnimationFrame||cancelAnimationFrame;cancelRAF(this.frameId);}// unmount all children
9445
- var root=this.getRoot();this.unmountChildren(root);// root.children.forEach((child: DisplayObject) => {
9446
- // this.unmountChildren(child);
9447
- // });
9448
- if(destroyScenegraph){// destroy Document
9510
+ ;/**
9511
+ * `cleanUp` means clean all the internal services of Canvas which happens when calling `canvas.destroy()`.
9512
+ */_proto.destroy=function destroy(cleanUp,skipTriggerEvent){if(cleanUp===void 0){cleanUp=true;}if(skipTriggerEvent===void 0){skipTriggerEvent=false;}if(!skipTriggerEvent){this.dispatchEvent(new CustomEvent(exports.CanvasEvent.BEFORE_DESTROY));}if(this.frameId){var cancelRAF=this.getConfig().cancelAnimationFrame||cancelAnimationFrame;cancelRAF(this.frameId);}// unmount all children
9513
+ var root=this.getRoot();this.unmountChildren(root);if(cleanUp){// destroy Document
9449
9514
  this.document.destroy();this.getEventService().destroy();}// destroy services
9450
9515
  this.getRenderingService().destroy();this.getContextService().destroy();// clear root after renderservice destroyed
9451
- if(destroyScenegraph&&this.context.rBushRoot){// clear rbush
9516
+ if(cleanUp&&this.context.rBushRoot){// clear rbush
9452
9517
  this.context.rBushRoot.clear();this.context.rBushRoot=null;this.context.renderingContext.root=null;}if(!skipTriggerEvent){this.dispatchEvent(new CustomEvent(exports.CanvasEvent.AFTER_DESTROY));}}/**
9453
9518
  * compatible with G 3.0
9454
9519
  * @deprecated
@@ -9461,6 +9526,7 @@
9461
9526
  * Remove all children which can be appended to its original parent later again.
9462
9527
  */;_proto.removeChildren=function removeChildren(){this.document.documentElement.removeChildren();}/**
9463
9528
  * Recursively destroy all children which can not be appended to its original parent later again.
9529
+ * But the canvas remains running which means display objects can be appended later.
9464
9530
  */;_proto.destroyChildren=function destroyChildren(){this.document.documentElement.destroyChildren();};_proto.render=function render(){var _this3=this;this.dispatchEvent(beforeRenderEvent);var renderingService=this.getRenderingService();renderingService.render(this.getConfig(),function(){// trigger actual rerender event
9465
9531
  // @see https://github.com/antvis/G/issues/1268
9466
9532
  _this3.dispatchEvent(rerenderEvent);});this.dispatchEvent(afterRenderEvent);};_proto.run=function run(){var _this4=this;var tick=function tick(){_this4.render();_this4.frameId=requestAnimationFrame(tick);};tick();};_proto.initRenderer=/*#__PURE__*/function(){var _initRenderer=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(renderer){return _regeneratorRuntime().wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:if(renderer){_context2.next=2;break;}throw new Error('Renderer is required.');case 2:// reset
@@ -12471,7 +12537,8 @@
12471
12537
  // eslint-disable-next-line @typescript-eslint/ban-types
12472
12538
  convertToString) {
12473
12539
  return function (f) {
12474
- return convertToString(interpolate(from, to, f));
12540
+ var interpolated = interpolate(from, to, f);
12541
+ return !runtime.enableCSSParsing && isNumber(interpolated) ? interpolated : convertToString(interpolated);
12475
12542
  };
12476
12543
  };
12477
12544
  function propertyInterpolation(property, left, right, target) {
@@ -12488,39 +12555,21 @@
12488
12555
  if (metadata && metadata.syntax && metadata.int) {
12489
12556
  var propertyHandler = runtime.styleValueRegistry.getPropertySyntax(metadata.syntax);
12490
12557
  if (propertyHandler) {
12491
- var computedLeft = runtime.styleValueRegistry.parseProperty(property, left, target);
12492
- var computedRight = runtime.styleValueRegistry.parseProperty(property, right, target);
12493
- var usedLeft = runtime.styleValueRegistry.computeProperty(property, computedLeft, target);
12494
- var usedRight = runtime.styleValueRegistry.computeProperty(property, computedRight, target);
12495
- // use defaultValue
12496
- // const parsedDefaultLeft = parseDefaultValue(metadata, target, property, left);
12497
- // const parsedDefaultRight = parseDefaultValue(metadata, target, property, right);
12498
- // if (!isNil(parsedDefaultLeft)) {
12499
- // // @ts-ignore
12500
- // parsedLeft = parsedDefaultLeft;
12501
- // } else if (propertyHandler.parser) {
12502
- // parsedLeft = propertyHandler.parser(left, target as DisplayObject);
12503
- // }
12504
- // if (!isNil(parsedDefaultRight)) {
12505
- // // @ts-ignore
12506
- // parsedRight = parsedDefaultRight;
12507
- // } else if (propertyHandler.parser) {
12508
- // parsedRight = propertyHandler.parser(right, target as DisplayObject);
12509
- // }
12510
- // if (propertyHandler.parser) {
12511
- // parsedLeft = propertyHandler.parser(left, target as DisplayObject);
12512
- // parsedRight = propertyHandler.parser(right, target as DisplayObject);
12513
- // }
12514
- // // no need to calculate
12515
- // if (propertyHandler.calculator) {
12516
- // parsedLeft = propertyHandler.calculator(parsedLeft);
12517
- // parsedRight = propertyHandler.calculator(parsedRight);
12518
- // // parsedLeft = handler.calculator
12519
- // }
12558
+ var usedLeft;
12559
+ var usedRight;
12560
+ if (runtime.enableCSSParsing) {
12561
+ var computedLeft = runtime.styleValueRegistry.parseProperty(property, left, target);
12562
+ var computedRight = runtime.styleValueRegistry.parseProperty(property, right, target);
12563
+ usedLeft = runtime.styleValueRegistry.computeProperty(property, computedLeft, target);
12564
+ usedRight = runtime.styleValueRegistry.computeProperty(property, computedRight, target);
12565
+ } else {
12566
+ var parser = propertyHandler.parserWithCSSDisabled;
12567
+ usedLeft = parser ? parser(left, target) : left;
12568
+ usedRight = parser ? parser(right, target) : right;
12569
+ }
12520
12570
  // merger [left, right, n2string()]
12521
12571
  var interpolationArgs = propertyHandler.mixer(usedLeft, usedRight, target);
12522
12572
  if (interpolationArgs) {
12523
- // @ts-ignore
12524
12573
  var interp = InterpolationFactory.apply(void 0, interpolationArgs);
12525
12574
  return function (t) {
12526
12575
  if (t === 0) return left;
@@ -13098,6 +13147,7 @@
13098
13147
  exports.DisplayObject = DisplayObject;
13099
13148
  exports.DisplayObjectPool = DisplayObjectPool;
13100
13149
  exports.Document = Document;
13150
+ exports.EMPTY_PARSED_PATH = EMPTY_PARSED_PATH;
13101
13151
  exports.ERROR_MSG_METHOD_NOT_IMPLEMENTED = ERROR_MSG_METHOD_NOT_IMPLEMENTED;
13102
13152
  exports.Element = Element;
13103
13153
  exports.Ellipse = Ellipse;