UNPKG

psyche-editor-render

Version:

编辑器渲染器

2 lines 588 kB
/*! For license information please see index.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("fabric"),require("axios")):"function"==typeof define&&define.amd?define(["react","fabric","axios"],t):"object"==typeof exports?exports["editor-render"]=t(require("react"),require("fabric"),require("axios")):e["editor-render"]=t(e.React,e.fabric,e.axios)}(this,((e,t,r)=>(()=>{var n={1058:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readAbr=void 0;var n=r(1875),i=r(3024),a=["off","fade","pen pressure","pen tilt","stylus wheel","initial direction","direction","initial rotation","rotation"];function o(e){return{control:a[e.bVTy],steps:e.fStp,jitter:(0,n.parsePercent)(e.jitter),minimum:(0,n.parsePercent)(e["Mnm "])}}function s(e){var t={size:(0,n.parseUnitsToNumber)(e.Dmtr,"Pixels"),angle:(0,n.parseAngle)(e.Angl),roundness:(0,n.parsePercent)(e.Rndn),spacingOn:e.Intr,spacing:(0,n.parsePercent)(e.Spcn),flipX:e.flipX,flipY:e.flipY};return e["Nm "]&&(t.name=e["Nm "]),e.Hrdn&&(t.hardness=(0,n.parsePercent)(e.Hrdn)),e.sampledData&&(t.sampledData=e.sampledData),t}t.readAbr=function(e,t){var r,a,l,c;void 0===t&&(t={});var d=(0,i.createReader)(e.buffer,e.byteOffset,e.byteLength),h=(0,i.readInt16)(d),u=[],f=[],p=[];if(1===h||2===h)throw new Error("Unsupported ABR version (".concat(h,")"));if(6!==h&&7!==h&&9!==h&&10!==h)throw new Error("Unsupported ABR version (".concat(h,")"));var g=(0,i.readInt16)(d);if(1!==g&&2!==g)throw new Error("Unsupported ABR minor version");for(;d.offset<d.view.byteLength;){(0,i.checkSignature)(d,"8BIM");var v=(0,i.readSignature)(d),m=(0,i.readUint32)(d),A=d.offset+m;switch(v){case"samp":for(;d.offset<A;){for(var b=(0,i.readUint32)(d);3&b;)b++;var y=d.offset+b,w=(0,i.readPascalString)(d,1);(0,i.skipBytes)(d,1===g?10:264);var k=(0,i.readInt32)(d),C=(0,i.readInt32)(d),S=(0,i.readInt32)(d)-k,x=(0,i.readInt32)(d)-C;if(x<=0||S<=0)throw new Error("Invalid bounds");var E=(0,i.readInt16)(d),I=(0,i.readUint8)(d),B=new Uint8Array(x*S);if(8===E)if(0===I)B.set((0,i.readBytes)(d,B.byteLength));else{if(1!==I)throw new Error("Invalid compression");(0,i.readDataRLE)(d,{width:x,height:S,data:B},x,S,1,[0],!1)}else{if(16!==E)throw new Error("Invalid depth");if(0!==I)throw 1===I?new Error("not implemented (16bit RLE)"):new Error("Invalid compression");for(var O=0;O<B.byteLength;O++)B[O]=(0,i.readUint16)(d)>>8}u.push({id:w,bounds:{x:C,y:k,w:x,h:S},alpha:B}),d.offset=y}break;case"desc":for(var M=0,U=(T=(0,n.readVersionAndDescriptor)(d)).Brsh;M<U.length;M++){var R=U[M],P={name:R["Nm "],shape:s(R.Brsh),spacing:(0,n.parsePercent)(R.Spcn),wetEdges:R.Wtdg,noise:R.Nose,useBrushSize:R.useBrushSize};null!=R.interpretation&&(P.interpretation=R.interpretation),null!=R.protectTexture&&(P.protectTexture=R.protectTexture),R.useTipDynamics&&(P.shapeDynamics={tiltScale:(0,n.parsePercent)(R.tiltScale),sizeDynamics:o(R.szVr),angleDynamics:o(R.angleDynamics),roundnessDynamics:o(R.roundnessDynamics),flipX:R.flipX,flipY:R.flipY,brushProjection:R.brushProjection,minimumDiameter:(0,n.parsePercent)(R.minimumDiameter),minimumRoundness:(0,n.parsePercent)(R.minimumRoundness)}),R.useScatter&&(P.scatter={count:R["Cnt "],bothAxes:R.bothAxes,countDynamics:o(R.countDynamics),scatterDynamics:o(R.scatterDynamics)}),R.useTexture&&R.Txtr&&(P.texture={id:R.Txtr.Idnt,name:R.Txtr["Nm "],blendMode:n.BlnM.decode(R.textureBlendMode),depth:(0,n.parsePercent)(R.textureDepth),depthMinimum:(0,n.parsePercent)(R.minimumDepth),depthDynamics:o(R.textureDepthDynamics),scale:(0,n.parsePercent)(R.textureScale),invert:R.InvT,brightness:R.textureBrightness,contrast:R.textureContrast});var D=R.dualBrush;D&&D.useDualBrush&&(P.dualBrush={flip:D.Flip,shape:s(D.Brsh),blendMode:n.BlnM.decode(D.BlnM),useScatter:D.useScatter,spacing:(0,n.parsePercent)(D.Spcn),count:D["Cnt "],bothAxes:D.bothAxes,countDynamics:o(D.countDynamics),scatterDynamics:o(D.scatterDynamics)}),R.useColorDynamics&&(P.colorDynamics={foregroundBackground:o(R.clVr),hue:(0,n.parsePercent)(R["H "]),saturation:(0,n.parsePercent)(R.Strt),brightness:(0,n.parsePercent)(R.Brgh),purity:(0,n.parsePercent)(R.purity),perTip:R.colorDynamicsPerTip}),R.usePaintDynamics&&(P.transfer={flowDynamics:o(R.prVr),opacityDynamics:o(R.opVr),wetnessDynamics:o(R.wtVr),mixDynamics:o(R.mxVr)}),R.useBrushPose&&(P.brushPose={overrideAngle:R.overridePoseAngle,overrideTiltX:R.overridePoseTiltX,overrideTiltY:R.overridePoseTiltY,overridePressure:R.overridePosePressure,pressure:(0,n.parsePercent)(R.brushPosePressure),tiltX:R.brushPoseTiltX,tiltY:R.brushPoseTiltY,angle:R.brushPoseAngle});var F=R.toolOptions;F&&(P.toolOptions={brushPreset:F.brushPreset,flow:null!==(r=F.flow)&&void 0!==r?r:100,smooth:null!==(a=F.Smoo)&&void 0!==a?a:0,mode:n.BlnM.decode(F["Md "]||"BlnM.Nrml"),opacity:null!==(l=F.Opct)&&void 0!==l?l:100,smoothing:!!F.smoothing,smoothingValue:F.smoothingValue||0,smoothingRadiusMode:!!F.smoothingRadiusMode,smoothingCatchup:!!F.smoothingCatchup,smoothingCatchupAtEnd:!!F.smoothingCatchupAtEnd,smoothingZoomCompensation:!!F.smoothingZoomCompensation,pressureSmoothing:!!F.pressureSmoothing,usePressureOverridesSize:!!F.usePressureOverridesSize,usePressureOverridesOpacity:!!F.usePressureOverridesOpacity,useLegacy:!!F.useLegacy},F.prVr&&(P.toolOptions.flowDynamics=o(F.prVr)),F.opVr&&(P.toolOptions.opacityDynamics=o(F.opVr)),F.szVr&&(P.toolOptions.sizeDynamics=o(F.szVr))),f.push(P)}break;case"patt":d.offset<A&&(p.push((0,i.readPattern)(d)),d.offset=A);break;case"phry":var T=(0,n.readVersionAndDescriptor)(d);t.logMissingFeatures&&(null===(c=T.hierarchy)||void 0===c||c.length);break;default:throw new Error("Invalid brush type: ".concat(v))}for(;m%4;)d.offset++,m++}return{samples:u,patterns:p,brushes:f}}},1825:function(e,t,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.hasMultiEffects=t.readVectorMask=t.booleanOperations=t.readBezierKnot=t.infoHandlersMap=t.infoHandlers=void 0;var i=r(6717),a=r(3759),o=r(9114),s=r(3024),l=r(3189),c=r(1875),d=r(4816),h=r(6923);function u(e,r,n,i){var a={key:e,has:r,read:n,write:i};t.infoHandlers.push(a),t.infoHandlersMap[a.key]=a}function f(e,r){t.infoHandlersMap[e]=t.infoHandlersMap[r]}function p(e){return function(t){return void 0!==t[e]}}function g(e){if((0,s.readUint32)(e))throw new Error("Resource size above 4 GB limit at ".concat(e.offset.toString(16)));return(0,s.readUint32)(e)}function v(e,t){(0,l.writeUint32)(e,0),(0,l.writeUint32)(e,t)}function m(e,t,r){var n=(0,s.readFixedPointPath32)(e)*r,i=(0,s.readFixedPointPath32)(e)*t,a=(0,s.readFixedPointPath32)(e)*r,o=(0,s.readFixedPointPath32)(e)*t,l=(0,s.readFixedPointPath32)(e)*r;return[i,n,o,a,(0,s.readFixedPointPath32)(e)*t,l]}function A(e,t,r,n){(0,l.writeFixedPointPath32)(e,t[1]/n),(0,l.writeFixedPointPath32)(e,t[0]/r),(0,l.writeFixedPointPath32)(e,t[3]/n),(0,l.writeFixedPointPath32)(e,t[2]/r),(0,l.writeFixedPointPath32)(e,t[5]/n),(0,l.writeFixedPointPath32)(e,t[4]/r)}function b(e,r,n,i,a){for(var o=e.offset+a,l=r.paths,c=void 0;o-e.offset>=26;){var d=(0,s.readUint16)(e);switch(d){case 0:case 3:(0,s.readUint16)(e);var h=(0,s.readInt16)(e);(0,s.readUint16)(e),(0,s.skipBytes)(e,18),c={open:3===d,operation:-1===h?"combine":t.booleanOperations[h],knots:[]},l.push(c);break;case 1:case 2:case 4:case 5:c.knots.push({linked:1===d||4===d,points:m(e,n,i)});break;case 6:(0,s.skipBytes)(e,24);break;case 7:var u=(0,s.readFixedPointPath32)(e),f=(0,s.readFixedPointPath32)(e),p=(0,s.readFixedPointPath32)(e),g=(0,s.readFixedPointPath32)(e),v=(0,s.readFixedPointPath32)(e);(0,s.skipBytes)(e,4),r.clipboard={top:u,left:f,bottom:p,right:g,resolution:v};break;case 8:r.fillStartsWithAllPixels=!!(0,s.readUint16)(e),(0,s.skipBytes)(e,22);break;default:throw new Error("Invalid vmsk section")}}return l}t.infoHandlers=[],t.infoHandlersMap={},u("TySh",p("text"),(function(e,t,r){if(1!==(0,s.readInt16)(e))throw new Error("Invalid TySh version");for(var i=[],a=0;a<6;a++)i.push((0,s.readFloat64)(e));if(50!==(0,s.readInt16)(e))throw new Error("Invalid TySh text version");var o=(0,c.readVersionAndDescriptor)(e);if(1!==(0,s.readInt16)(e))throw new Error("Invalid TySh warp version");var l=(0,c.readVersionAndDescriptor)(e);if(t.text={transform:i,left:(0,s.readFloat32)(e),top:(0,s.readFloat32)(e),right:(0,s.readFloat32)(e),bottom:(0,s.readFloat32)(e),text:o["Txt "].replace(/\r/g,"\n"),index:o.TextIndex||0,gridding:c.textGridding.decode(o.textGridding),antiAlias:c.Annt.decode(o.AntA),orientation:c.Ornt.decode(o.Ornt),warp:{style:c.warpStyle.decode(l.warpStyle),value:l.warpValue||0,perspective:l.warpPerspective||0,perspectiveOther:l.warpPerspectiveOther||0,rotate:c.Ornt.decode(l.warpRotate)}},o.EngineData){var u=(0,d.parseEngineData)(o.EngineData),f=(0,h.decodeEngineData)(u);t.text=n(n({},t.text),f)}(0,s.skipBytes)(e,r())}),(function(e,t){var r=t.text,n=r.warp||{},i=r.transform||[1,0,0,1,0,0],a={"Txt ":(r.text||"").replace(/\r?\n/g,"\r"),textGridding:c.textGridding.encode(r.gridding),Ornt:c.Ornt.encode(r.orientation),AntA:c.Annt.encode(r.antiAlias),TextIndex:r.index||0,EngineData:(0,d.serializeEngineData)((0,h.encodeEngineData)(r))};(0,l.writeInt16)(e,1);for(var o=0;o<6;o++)(0,l.writeFloat64)(e,i[o]);(0,l.writeInt16)(e,50),(0,c.writeVersionAndDescriptor)(e,"","TxLr",a),(0,l.writeInt16)(e,1),(0,c.writeVersionAndDescriptor)(e,"","warp",C(n)),(0,l.writeFloat32)(e,r.left),(0,l.writeFloat32)(e,r.top),(0,l.writeFloat32)(e,r.right),(0,l.writeFloat32)(e,r.bottom)})),u("SoCo",(function(e){return void 0!==e.vectorFill&&void 0===e.vectorStroke&&"color"===e.vectorFill.type}),(function(e,t){var r=(0,c.readVersionAndDescriptor)(e);t.vectorFill=(0,c.parseVectorContent)(r)}),(function(e,t){var r=(0,c.serializeVectorContent)(t.vectorFill).descriptor;(0,c.writeVersionAndDescriptor)(e,"","null",r)})),u("GdFl",(function(e){return void 0!==e.vectorFill&&void 0===e.vectorStroke&&("solid"===e.vectorFill.type||"noise"===e.vectorFill.type)}),(function(e,t,r){var n=(0,c.readVersionAndDescriptor)(e);t.vectorFill=(0,c.parseVectorContent)(n),(0,s.skipBytes)(e,r())}),(function(e,t){var r=(0,c.serializeVectorContent)(t.vectorFill).descriptor;(0,c.writeVersionAndDescriptor)(e,"","null",r)})),u("PtFl",(function(e){return void 0!==e.vectorFill&&void 0===e.vectorStroke&&"pattern"===e.vectorFill.type}),(function(e,t){var r=(0,c.readVersionAndDescriptor)(e);t.vectorFill=(0,c.parseVectorContent)(r)}),(function(e,t){var r=(0,c.serializeVectorContent)(t.vectorFill).descriptor;(0,c.writeVersionAndDescriptor)(e,"","null",r)})),u("vscg",(function(e){return void 0!==e.vectorFill&&void 0!==e.vectorStroke}),(function(e,t,r){(0,s.readSignature)(e);var n=(0,c.readVersionAndDescriptor)(e);t.vectorFill=(0,c.parseVectorContent)(n),(0,s.skipBytes)(e,r())}),(function(e,t){var r=(0,c.serializeVectorContent)(t.vectorFill),n=r.descriptor,i=r.key;(0,l.writeSignature)(e,i),(0,c.writeVersionAndDescriptor)(e,"","null",n)})),t.readBezierKnot=m,t.booleanOperations=["exclude","combine","subtract","intersect"],t.readVectorMask=b,u("vmsk",p("vectorMask"),(function(e,t,r,n){var i=n.width,a=n.height;if(3!==(0,s.readUint32)(e))throw new Error("Invalid vmsk version");t.vectorMask={paths:[]};var o=t.vectorMask,l=(0,s.readUint32)(e);o.invert=0!=(1&l),o.notLink=0!=(2&l),o.disable=0!=(4&l),b(e,o,i,a,r()),(0,s.skipBytes)(e,r())}),(function(e,r,n){var i=n.width,a=n.height,o=r.vectorMask,s=(o.invert?1:0)|(o.notLink?2:0)|(o.disable?4:0);(0,l.writeUint32)(e,3),(0,l.writeUint32)(e,s),(0,l.writeUint16)(e,6),(0,l.writeZeros)(e,24);var c=o.clipboard;c&&((0,l.writeUint16)(e,7),(0,l.writeFixedPointPath32)(e,c.top),(0,l.writeFixedPointPath32)(e,c.left),(0,l.writeFixedPointPath32)(e,c.bottom),(0,l.writeFixedPointPath32)(e,c.right),(0,l.writeFixedPointPath32)(e,c.resolution),(0,l.writeZeros)(e,4)),void 0!==o.fillStartsWithAllPixels&&((0,l.writeUint16)(e,8),(0,l.writeUint16)(e,o.fillStartsWithAllPixels?1:0),(0,l.writeZeros)(e,22));for(var d=0,h=o.paths;d<h.length;d++){var u=h[d];(0,l.writeUint16)(e,u.open?3:0),(0,l.writeUint16)(e,u.knots.length),(0,l.writeUint16)(e,Math.abs(t.booleanOperations.indexOf(u.operation))),(0,l.writeUint16)(e,1),(0,l.writeZeros)(e,18);for(var f=u.open?4:1,p=u.open?5:2,g=0,v=u.knots;g<v.length;g++){var m=v[g],b=m.linked,y=m.points;(0,l.writeUint16)(e,b?f:p),A(e,y,i,a)}}})),f("vsms","vmsk"),u("vogk",p("vectorOrigination"),(function(e,t,r){if(1!==(0,s.readInt32)(e))throw new Error("Invalid vogk version");var n=(0,c.readVersionAndDescriptor)(e);t.vectorOrigination={keyDescriptorList:[]};for(var i=0,a=n.keyDescriptorList;i<a.length;i++){var o=a[i],l={};null!=o.keyShapeInvalidated&&(l.keyShapeInvalidated=o.keyShapeInvalidated),null!=o.keyOriginType&&(l.keyOriginType=o.keyOriginType),null!=o.keyOriginResolution&&(l.keyOriginResolution=o.keyOriginResolution),o.keyOriginShapeBBox&&(l.keyOriginShapeBoundingBox={top:(0,c.parseUnits)(o.keyOriginShapeBBox["Top "]),left:(0,c.parseUnits)(o.keyOriginShapeBBox.Left),bottom:(0,c.parseUnits)(o.keyOriginShapeBBox.Btom),right:(0,c.parseUnits)(o.keyOriginShapeBBox.Rght)});var d=o.keyOriginRRectRadii;d&&(l.keyOriginRRectRadii={topRight:(0,c.parseUnits)(d.topRight),topLeft:(0,c.parseUnits)(d.topLeft),bottomLeft:(0,c.parseUnits)(d.bottomLeft),bottomRight:(0,c.parseUnits)(d.bottomRight)});var h=o.keyOriginBoxCorners;h&&(l.keyOriginBoxCorners=[{x:h.rectangleCornerA.Hrzn,y:h.rectangleCornerA.Vrtc},{x:h.rectangleCornerB.Hrzn,y:h.rectangleCornerB.Vrtc},{x:h.rectangleCornerC.Hrzn,y:h.rectangleCornerC.Vrtc},{x:h.rectangleCornerD.Hrzn,y:h.rectangleCornerD.Vrtc}]);var u=o.Trnf;u&&(l.transform=[u.xx,u.xy,u.xy,u.yy,u.tx,u.ty]),t.vectorOrigination.keyDescriptorList.push(l)}(0,s.skipBytes)(e,r())}),(function(e,t){for(var r=t.vectorOrigination,n={keyDescriptorList:[]},i=0;i<r.keyDescriptorList.length;i++){var a=r.keyDescriptorList[i];if(a.keyShapeInvalidated)n.keyDescriptorList.push({keyShapeInvalidated:!0,keyOriginIndex:i});else{n.keyDescriptorList.push({});var o=n.keyDescriptorList[n.keyDescriptorList.length-1];null!=a.keyOriginType&&(o.keyOriginType=a.keyOriginType),null!=a.keyOriginResolution&&(o.keyOriginResolution=a.keyOriginResolution);var s=a.keyOriginRRectRadii;s&&(o.keyOriginRRectRadii={unitValueQuadVersion:1,topRight:(0,c.unitsValue)(s.topRight,"topRight"),topLeft:(0,c.unitsValue)(s.topLeft,"topLeft"),bottomLeft:(0,c.unitsValue)(s.bottomLeft,"bottomLeft"),bottomRight:(0,c.unitsValue)(s.bottomRight,"bottomRight")});var d=a.keyOriginShapeBoundingBox;d&&(o.keyOriginShapeBBox={unitValueQuadVersion:1,"Top ":(0,c.unitsValue)(d.top,"top"),Left:(0,c.unitsValue)(d.left,"left"),Btom:(0,c.unitsValue)(d.bottom,"bottom"),Rght:(0,c.unitsValue)(d.right,"right")});var h=a.keyOriginBoxCorners;h&&4===h.length&&(o.keyOriginBoxCorners={rectangleCornerA:{Hrzn:h[0].x,Vrtc:h[0].y},rectangleCornerB:{Hrzn:h[1].x,Vrtc:h[1].y},rectangleCornerC:{Hrzn:h[2].x,Vrtc:h[2].y},rectangleCornerD:{Hrzn:h[3].x,Vrtc:h[3].y}});var u=a.transform;u&&6===u.length&&(o.Trnf={xx:u[0],xy:u[1],yx:u[2],yy:u[3],tx:u[4],ty:u[5]}),o.keyOriginIndex=i}}(0,l.writeInt32)(e,1),(0,c.writeVersionAndDescriptor)(e,"","null",n)})),u("lmfx",(function(e){return void 0!==e.effects&&X(e.effects)}),(function(e,t,r,n,i){if(0!==(0,s.readUint32)(e))throw new Error("Invalid lmfx version");var a=(0,c.readVersionAndDescriptor)(e);t.effects=(0,c.parseEffects)(a,!!i.logMissingFeatures),(0,s.skipBytes)(e,r())}),(function(e,t,r,n){var i=(0,c.serializeEffects)(t.effects,!!n.logMissingFeatures,!0);(0,l.writeUint32)(e,0),(0,c.writeVersionAndDescriptor)(e,"","null",i)})),u("lrFX",p("effects"),(function(e,t,r){t.effects||(t.effects=(0,a.readEffects)(e)),(0,s.skipBytes)(e,r())}),(function(e,t){(0,a.writeEffects)(e,t.effects)})),u("luni",p("name"),(function(e,t,r){t.name=(0,s.readUnicodeString)(e),(0,s.skipBytes)(e,r())}),(function(e,t){(0,l.writeUnicodeString)(e,t.name)})),u("lnsr",p("nameSource"),(function(e,t){return t.nameSource=(0,s.readSignature)(e)}),(function(e,t){return(0,l.writeSignature)(e,t.nameSource)})),u("lyid",p("id"),(function(e,t){return t.id=(0,s.readUint32)(e)}),(function(e,t,r,n){for(var i=t.id;n.layerIds.has(i);)i+=100;(0,l.writeUint32)(e,i),n.layerIds.add(i),n.layerToId.set(t,i)})),u("lsct",p("sectionDivider"),(function(e,t,r){t.sectionDivider={type:(0,s.readUint32)(e)},r()&&((0,s.checkSignature)(e,"8BIM"),t.sectionDivider.key=(0,s.readSignature)(e)),r()&&(t.sectionDivider.subType=(0,s.readUint32)(e))}),(function(e,t){(0,l.writeUint32)(e,t.sectionDivider.type),t.sectionDivider.key&&((0,l.writeSignature)(e,"8BIM"),(0,l.writeSignature)(e,t.sectionDivider.key),void 0!==t.sectionDivider.subType&&(0,l.writeUint32)(e,t.sectionDivider.subType))})),f("lsdk","lsct"),u("clbl",p("blendClippendElements"),(function(e,t){t.blendClippendElements=!!(0,s.readUint8)(e),(0,s.skipBytes)(e,3)}),(function(e,t){(0,l.writeUint8)(e,t.blendClippendElements?1:0),(0,l.writeZeros)(e,3)})),u("infx",p("blendInteriorElements"),(function(e,t){t.blendInteriorElements=!!(0,s.readUint8)(e),(0,s.skipBytes)(e,3)}),(function(e,t){(0,l.writeUint8)(e,t.blendInteriorElements?1:0),(0,l.writeZeros)(e,3)})),u("knko",p("knockout"),(function(e,t){t.knockout=!!(0,s.readUint8)(e),(0,s.skipBytes)(e,3)}),(function(e,t){(0,l.writeUint8)(e,t.knockout?1:0),(0,l.writeZeros)(e,3)})),u("lmgm",p("layerMaskAsGlobalMask"),(function(e,t){t.layerMaskAsGlobalMask=!!(0,s.readUint8)(e),(0,s.skipBytes)(e,3)}),(function(e,t){(0,l.writeUint8)(e,t.layerMaskAsGlobalMask?1:0),(0,l.writeZeros)(e,3)})),u("lspf",p("protected"),(function(e,t){var r=(0,s.readUint32)(e);t.protected={transparency:0!=(1&r),composite:0!=(2&r),position:0!=(4&r)},8&r&&(t.protected.artboards=!0)}),(function(e,t){var r=(t.protected.transparency?1:0)|(t.protected.composite?2:0)|(t.protected.position?4:0)|(t.protected.artboards?8:0);(0,l.writeUint32)(e,r)})),u("lclr",p("layerColor"),(function(e,t){var r=(0,s.readUint16)(e);(0,s.skipBytes)(e,6),t.layerColor=o.layerColors[r]}),(function(e,t){var r=o.layerColors.indexOf(t.layerColor);(0,l.writeUint16)(e,-1===r?0:r),(0,l.writeZeros)(e,6)})),u("shmd",(function(e){return void 0!==e.timestamp||void 0!==e.animationFrames||void 0!==e.animationFrameFlags||void 0!==e.timeline}),(function(e,t,r,n,i){for(var a=(0,s.readUint32)(e),o=function(r){(0,s.checkSignature)(e,"8BIM");var n=(0,s.readSignature)(e);(0,s.readUint8)(e),(0,s.skipBytes)(e,3),(0,s.readSection)(e,1,(function(r){if("cust"===n)void 0!==(a=(0,c.readVersionAndDescriptor)(e)).layerTime&&(t.timestamp=a.layerTime);else if("mlst"===n){var a=(0,c.readVersionAndDescriptor)(e);t.animationFrames=[];for(var o=0;o<a.LaSt.length;o++){var l=a.LaSt[o],d={frames:l.FrLs};void 0!==l.enab&&(d.enable=l.enab),l.Ofst&&(d.offset=(0,c.horzVrtcToXY)(l.Ofst)),l.FXRf&&(d.referencePoint=(0,c.horzVrtcToXY)(l.FXRf)),l.Lefx&&(d.effects=(0,c.parseEffects)(l.Lefx,!!i.logMissingFeatures)),l.blendOptions&&l.blendOptions.Opct&&(d.opacity=(0,c.parsePercent)(l.blendOptions.Opct)),t.animationFrames.push(d)}}else if("mdyn"===n){(0,s.readUint16)(e);var h=(0,s.readUint8)(e),u=(0,s.readUint8)(e);t.animationFrameFlags={propagateFrameOne:!h,unifyLayerPosition:0!=(1&u),unifyLayerStyle:0!=(2&u),unifyLayerVisibility:0!=(4&u)}}else if("tmln"===n){var f=(a=(0,c.readVersionAndDescriptor)(e)).timeScope,p={start:f.Strt,duration:f.duration,inTime:f.inTime,outTime:f.outTime,autoScope:a.autoScope,audioLevel:a.audioLevel};a.trackList&&(p.tracks=(0,c.parseTrackList)(a.trackList,!!i.logMissingFeatures)),t.timeline=p}else i.logDevFeatures;(0,s.skipBytes)(e,r())}))},l=0;l<a;l++)o();(0,s.skipBytes)(e,r())}),(function(e,t,r,n){var i=t.animationFrames,a=t.animationFrameFlags,o=t.timestamp,s=t.timeline,d=0;i&&d++,a&&d++,s&&d++,void 0!==o&&d++,(0,l.writeUint32)(e,d),i&&((0,l.writeSignature)(e,"8BIM"),(0,l.writeSignature)(e,"mlst"),(0,l.writeUint8)(e,0),(0,l.writeZeros)(e,3),(0,l.writeSection)(e,2,(function(){for(var r,n={LaID:null!==(r=t.id)&&void 0!==r?r:0,LaSt:[]},a=0;a<i.length;a++){var o=i[a],s={};void 0!==o.enable&&(s.enab=o.enable),s.FrLs=o.frames,o.offset&&(s.Ofst=(0,c.xyToHorzVrtc)(o.offset)),o.referencePoint&&(s.FXRf=(0,c.xyToHorzVrtc)(o.referencePoint)),o.effects&&(s.Lefx=(0,c.serializeEffects)(o.effects,!1,!1)),void 0!==o.opacity&&(s.blendOptions={Opct:(0,c.unitsPercent)(o.opacity)}),n.LaSt.push(s)}(0,c.writeVersionAndDescriptor)(e,"","null",n)}),!0)),a&&((0,l.writeSignature)(e,"8BIM"),(0,l.writeSignature)(e,"mdyn"),(0,l.writeUint8)(e,0),(0,l.writeZeros)(e,3),(0,l.writeSection)(e,2,(function(){(0,l.writeUint16)(e,0),(0,l.writeUint8)(e,a.propagateFrameOne?0:15),(0,l.writeUint8)(e,(a.unifyLayerPosition?1:0)|(a.unifyLayerStyle?2:0)|(a.unifyLayerVisibility?4:0))}))),s&&((0,l.writeSignature)(e,"8BIM"),(0,l.writeSignature)(e,"tmln"),(0,l.writeUint8)(e,0),(0,l.writeZeros)(e,3),(0,l.writeSection)(e,2,(function(){var r={Vrsn:1,timeScope:{Vrsn:1,Strt:s.start,duration:s.duration,inTime:s.inTime,outTime:s.outTime},autoScope:s.autoScope,audioLevel:s.audioLevel};s.tracks&&(r.trackList=(0,c.serializeTrackList)(s.tracks));var i=n.layerToId.get(t)||t.id||0;if(!i)throw new Error("You need to provide layer.id value whan writing document with animations");r.LyrI=i,(0,c.writeVersionAndDescriptor)(e,"","null",r,"anim")}),!0)),void 0!==o&&((0,l.writeSignature)(e,"8BIM"),(0,l.writeSignature)(e,"cust"),(0,l.writeUint8)(e,0),(0,l.writeZeros)(e,3),(0,l.writeSection)(e,2,(function(){var t={layerTime:o};(0,c.writeVersionAndDescriptor)(e,"","metadata",t)}),!0))})),u("vstk",p("vectorStroke"),(function(e,t,r){var n=(0,c.readVersionAndDescriptor)(e);t.vectorStroke={strokeEnabled:n.strokeEnabled,fillEnabled:n.fillEnabled,lineWidth:(0,c.parseUnits)(n.strokeStyleLineWidth),lineDashOffset:(0,c.parseUnits)(n.strokeStyleLineDashOffset),miterLimit:n.strokeStyleMiterLimit,lineCapType:c.strokeStyleLineCapType.decode(n.strokeStyleLineCapType),lineJoinType:c.strokeStyleLineJoinType.decode(n.strokeStyleLineJoinType),lineAlignment:c.strokeStyleLineAlignment.decode(n.strokeStyleLineAlignment),scaleLock:n.strokeStyleScaleLock,strokeAdjust:n.strokeStyleStrokeAdjust,lineDashSet:n.strokeStyleLineDashSet.map(c.parseUnits),blendMode:c.BlnM.decode(n.strokeStyleBlendMode),opacity:(0,c.parsePercent)(n.strokeStyleOpacity),content:(0,c.parseVectorContent)(n.strokeStyleContent),resolution:n.strokeStyleResolution},(0,s.skipBytes)(e,r())}),(function(e,t){var r,n,i,a=t.vectorStroke,o={strokeStyleVersion:2,strokeEnabled:!!a.strokeEnabled,fillEnabled:!!a.fillEnabled,strokeStyleLineWidth:a.lineWidth||{value:3,units:"Points"},strokeStyleLineDashOffset:a.lineDashOffset||{value:0,units:"Points"},strokeStyleMiterLimit:null!==(r=a.miterLimit)&&void 0!==r?r:100,strokeStyleLineCapType:c.strokeStyleLineCapType.encode(a.lineCapType),strokeStyleLineJoinType:c.strokeStyleLineJoinType.encode(a.lineJoinType),strokeStyleLineAlignment:c.strokeStyleLineAlignment.encode(a.lineAlignment),strokeStyleScaleLock:!!a.scaleLock,strokeStyleStrokeAdjust:!!a.strokeAdjust,strokeStyleLineDashSet:a.lineDashSet||[],strokeStyleBlendMode:c.BlnM.encode(a.blendMode),strokeStyleOpacity:(0,c.unitsPercent)(null!==(n=a.opacity)&&void 0!==n?n:1),strokeStyleContent:(0,c.serializeVectorContent)(a.content||{type:"color",color:{r:0,g:0,b:0}}).descriptor,strokeStyleResolution:null!==(i=a.resolution)&&void 0!==i?i:72};(0,c.writeVersionAndDescriptor)(e,"","strokeStyle",o)})),u("artb",p("artboard"),(function(e,t,r){var n=(0,c.readVersionAndDescriptor)(e),i=n.artboardRect;t.artboard={rect:{top:i["Top "],left:i.Left,bottom:i.Btom,right:i.Rght},guideIndices:n.guideIndeces,presetName:n.artboardPresetName,color:(0,c.parseColor)(n["Clr "]),backgroundType:n.artboardBackgroundType},(0,s.skipBytes)(e,r())}),(function(e,t){var r,n=t.artboard,i=n.rect,a={artboardRect:{"Top ":i.top,Left:i.left,Btom:i.bottom,Rght:i.right},guideIndeces:n.guideIndices||[],artboardPresetName:n.presetName||"","Clr ":(0,c.serializeColor)(n.color),artboardBackgroundType:null!==(r=n.backgroundType)&&void 0!==r?r:1};(0,c.writeVersionAndDescriptor)(e,"","artboard",a)})),u("sn2P",p("usingAlignedRendering"),(function(e,t){return t.usingAlignedRendering=!!(0,s.readUint32)(e)}),(function(e,t){return(0,l.writeUint32)(e,t.usingAlignedRendering?1:0)}));var y=["unknown","vector","raster","image stack"];function w(e){var t,r,i,a,o,s,l=n(n({style:c.warpStyle.decode(e.warpStyle)},e.warpValues?{values:e.warpValues}:{value:e.warpValue||0}),{perspective:e.warpPerspective||0,perspectiveOther:e.warpPerspectiveOther||0,rotate:c.Ornt.decode(e.warpRotate),bounds:e.bounds&&{top:(0,c.parseUnitsOrNumber)(e.bounds["Top "]),left:(0,c.parseUnitsOrNumber)(e.bounds.Left),bottom:(0,c.parseUnitsOrNumber)(e.bounds.Btom),right:(0,c.parseUnitsOrNumber)(e.bounds.Rght)},uOrder:e.uOrder,vOrder:e.vOrder});null==e.deformNumRows&&null==e.deformNumCols||(l.deformNumRows=e.deformNumRows,l.deformNumCols=e.deformNumCols);var d=e.customEnvelopeWarp;if(d){l.customEnvelopeWarp={meshPoints:[]};for(var h=(null===(t=d.meshPoints.find((function(e){return"Hrzn"===e.type})))||void 0===t?void 0:t.values)||[],u=(null===(r=d.meshPoints.find((function(e){return"Vrtc"===e.type})))||void 0===r?void 0:r.values)||[],f=0;f<h.length;f++)l.customEnvelopeWarp.meshPoints.push({x:h[f],y:u[f]});(d.quiltSliceX||d.quiltSliceY)&&(l.customEnvelopeWarp.quiltSliceX=(null===(a=null===(i=d.quiltSliceX)||void 0===i?void 0:i[0])||void 0===a?void 0:a.values)||[],l.customEnvelopeWarp.quiltSliceY=(null===(s=null===(o=d.quiltSliceY)||void 0===o?void 0:o[0])||void 0===s?void 0:s.values)||[])}return l}function k(e){var t,r;return null!=e.deformNumCols||null!=e.deformNumRows||(null===(t=e.customEnvelopeWarp)||void 0===t?void 0:t.quiltSliceX)||(null===(r=e.customEnvelopeWarp)||void 0===r?void 0:r.quiltSliceY)}function C(e){var t=e.bounds,r=n(n({warpStyle:c.warpStyle.encode(e.style)},e.values?{warpValues:e.values}:{warpValue:e.value}),{warpPerspective:e.perspective||0,warpPerspectiveOther:e.perspectiveOther||0,warpRotate:c.Ornt.encode(e.rotate),bounds:{"Top ":(0,c.unitsValue)(t&&t.top||{units:"Pixels",value:0},"bounds.top"),Left:(0,c.unitsValue)(t&&t.left||{units:"Pixels",value:0},"bounds.left"),Btom:(0,c.unitsValue)(t&&t.bottom||{units:"Pixels",value:0},"bounds.bottom"),Rght:(0,c.unitsValue)(t&&t.right||{units:"Pixels",value:0},"bounds.right")},uOrder:e.uOrder||0,vOrder:e.vOrder||0}),i=k(e);i&&((o=r).deformNumRows=e.deformNumRows||0,o.deformNumCols=e.deformNumCols||0);var a=e.customEnvelopeWarp;if(a){var o,s=a.meshPoints||[];if(i)(o=r).customEnvelopeWarp={quiltSliceX:[{type:"quiltSliceX",values:a.quiltSliceX||[]}],quiltSliceY:[{type:"quiltSliceY",values:a.quiltSliceY||[]}],meshPoints:[{type:"Hrzn",values:s.map((function(e){return e.x}))},{type:"Vrtc",values:s.map((function(e){return e.y}))}]};else r.customEnvelopeWarp={meshPoints:[{type:"Hrzn",values:s.map((function(e){return e.x}))},{type:"Vrtc",values:s.map((function(e){return e.y}))}]}}return r}function S(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function x(e){for(var t=[],r=0;r<e.length;r+=2)t.push({x:e[r],y:e[r+1]});return t}function E(e){for(var t=[],r=0;r<e.length;r++)t.push(e[r].x,e[r].y);return t}function I(e){return x(function(e){return new Float32Array(e.buffer.slice(e.byteOffset),0,e.byteLength/4)}(e))}function B(e){return{x:(0,c.parseUnits)(e.Hrzn),y:(0,c.parseUnits)(e.Vrtc)}}function O(e){return{Hrzn:(0,c.unitsValue)(e.x,"x"),Vrtc:(0,c.unitsValue)(e.y,"y")}}function M(e){return{top:(0,s.readInt32)(e),left:(0,s.readInt32)(e),bottom:(0,s.readInt32)(e),right:(0,s.readInt32)(e)}}function U(e,t){(0,l.writeInt32)(e,t.top),(0,l.writeInt32)(e,t.left),(0,l.writeInt32)(e,t.bottom),(0,l.writeInt32)(e,t.right)}function R(e){return function(t){return!!t.adjustment&&t.adjustment.type===e}}function P(e){return{shadowInput:(0,s.readInt16)(e),highlightInput:(0,s.readInt16)(e),shadowOutput:(0,s.readInt16)(e),highlightOutput:(0,s.readInt16)(e),midtoneInput:(0,s.readInt16)(e)/100}}function D(e,t){(0,l.writeInt16)(e,t.shadowInput),(0,l.writeInt16)(e,t.highlightInput),(0,l.writeInt16)(e,t.shadowOutput),(0,l.writeInt16)(e,t.highlightOutput),(0,l.writeInt16)(e,Math.round(100*t.midtoneInput))}function F(e){for(var t=(0,s.readUint16)(e),r=[],n=0;n<t;n++){var i=(0,s.readInt16)(e),a=(0,s.readInt16)(e);r.push({input:a,output:i})}return r}function T(e,t){(0,l.writeUint16)(e,t.length);for(var r=0,n=t;r<n.length;r++){var i=n[r];(0,l.writeUint16)(e,i.output),(0,l.writeUint16)(e,i.input)}}function _(e){return{a:(0,s.readInt16)(e),b:(0,s.readInt16)(e),c:(0,s.readInt16)(e),d:(0,s.readInt16)(e),hue:(0,s.readInt16)(e),saturation:(0,s.readInt16)(e),lightness:(0,s.readInt16)(e)}}function L(e,t){var r=t||{};(0,l.writeInt16)(e,r.a||0),(0,l.writeInt16)(e,r.b||0),(0,l.writeInt16)(e,r.c||0),(0,l.writeInt16)(e,r.d||0),(0,l.writeInt16)(e,r.hue||0),(0,l.writeInt16)(e,r.saturation||0),(0,l.writeInt16)(e,r.lightness||0)}function z(e){return{cyanRed:(0,s.readInt16)(e),magentaGreen:(0,s.readInt16)(e),yellowBlue:(0,s.readInt16)(e)}}function j(e,t){(0,l.writeInt16)(e,t.cyanRed||0),(0,l.writeInt16)(e,t.magentaGreen||0),(0,l.writeInt16)(e,t.yellowBlue||0)}function H(e){var t=(0,s.readInt16)(e),r=(0,s.readInt16)(e),n=(0,s.readInt16)(e);return(0,s.skipBytes)(e,2),{red:t,green:r,blue:n,constant:(0,s.readInt16)(e)}}function N(e,t){var r=t||{};(0,l.writeInt16)(e,r.red),(0,l.writeInt16)(e,r.green),(0,l.writeInt16)(e,r.blue),(0,l.writeZeros)(e,2),(0,l.writeInt16)(e,r.constant)}u("PlLd",p("placedLayer"),(function(e,t,r){if("plcL"!==(0,s.readSignature)(e))throw new Error("Invalid PlLd signature");if(3!==(0,s.readInt32)(e))throw new Error("Invalid PlLd version");var n=(0,s.readPascalString)(e,1),i=(0,s.readInt32)(e),a=(0,s.readInt32)(e);(0,s.readInt32)(e);var o=(0,s.readInt32)(e);if(!y[o])throw new Error("Invalid PlLd type");for(var l=[],d=0;d<8;d++)l.push((0,s.readFloat64)(e));var h=(0,s.readInt32)(e);if(0!==h)throw new Error("Invalid Warp version ".concat(h));var u=(0,c.readVersionAndDescriptor)(e);t.placedLayer=t.placedLayer||{id:n,type:y[o],pageNumber:i,totalPages:a,transform:l,warp:w(u)},(0,s.skipBytes)(e,r())}),(function(e,t){var r=t.placedLayer;if((0,l.writeSignature)(e,"plcL"),(0,l.writeInt32)(e,3),(0,l.writePascalString)(e,r.id,1),(0,l.writeInt32)(e,1),(0,l.writeInt32)(e,1),(0,l.writeInt32)(e,16),-1===y.indexOf(r.type))throw new Error("Invalid placedLayer type");(0,l.writeInt32)(e,y.indexOf(r.type));for(var n=0;n<8;n++)(0,l.writeFloat64)(e,r.transform[n]);(0,l.writeInt32)(e,0);var i=r.warp&&k(r.warp)?"quiltWarp":"warp";(0,c.writeVersionAndDescriptor)(e,"",i,C(r.warp||{}),i)})),u("SoLd",p("placedLayer"),(function(e,t,r){if("soLD"!==(0,s.readSignature)(e))throw new Error("Invalid SoLd type");var n=(0,s.readInt32)(e);if(4!==n&&5!==n)throw new Error("Invalid SoLd version");var i=(0,c.readVersionAndDescriptor)(e);t.placedLayer={id:i.Idnt,placed:i.placed,type:y[i.Type],pageNumber:i.PgNm,totalPages:i.totalPages,frameStep:i.frameStep,duration:i.duration,frameCount:i.frameCount,transform:i.Trnf,width:i["Sz "].Wdth,height:i["Sz "].Hght,resolution:(0,c.parseUnits)(i.Rslt),warp:w(i.quiltWarp||i.warp)},i.nonAffineTransform&&i.nonAffineTransform.some((function(e,t){return e!==i.Trnf[t]}))&&(t.placedLayer.nonAffineTransform=i.nonAffineTransform),i.Crop&&(t.placedLayer.crop=i.Crop),i.comp&&(t.placedLayer.comp=i.comp),i.compInfo&&(t.placedLayer.compInfo=i.compInfo),i.filterFX&&(t.placedLayer.filter=function(e){return{enabled:e.enab,validAtPosition:e.validAtPosition,maskEnabled:e.filterMaskEnable,maskLinked:e.filterMaskLinked,maskExtendWithWhite:e.filterMaskExtendWithWhite,list:e.filterFXList.map((function(e){return{id:e.filterID,name:e["Nm "],opacity:(0,c.parsePercent)(e.blendOptions.Opct),blendMode:c.BlnM.decode(e.blendOptions["Md "]),enabled:e.enab,hasOptions:e.hasoptions,foregroundColor:(0,c.parseColor)(e.FrgC),backgroundColor:(0,c.parseColor)(e.BckC),filter:{rigidType:e.Fltr.rigidType,bounds:[{x:e.Fltr.PuX0,y:e.Fltr.PuY0},{x:e.Fltr.PuX1,y:e.Fltr.PuY1},{x:e.Fltr.PuX2,y:e.Fltr.PuY2},{x:e.Fltr.PuX3,y:e.Fltr.PuY3}],puppetShapeList:e.Fltr.puppetShapeList.map((function(e){return{rigidType:e.rigidType,originalVertexArray:I(e.originalVertexArray),deformedVertexArray:I(e.deformedVertexArray),indexArray:Array.from((t=e.indexArray,new Uint32Array(t.buffer.slice(t.byteOffset),0,t.byteLength/4))),pinOffsets:x(e.pinOffsets),posFinalPins:x(e.posFinalPins),pinVertexIndices:e.pinVertexIndices,selectedPin:e.selectedPin,pinPosition:x(e.PinP),pinRotation:e.PnRt,pinOverlay:e.PnOv,pinDepth:e.PnDp,meshQuality:e.meshQuality,meshExpansion:e.meshExpansion,meshRigidity:e.meshRigidity,imageResolution:e.imageResolution,meshBoundaryPath:{pathComponents:e.meshBoundaryPath.pathComponents.map((function(e){return{shapeOperation:e.shapeOperation.split(".")[1],paths:e.SbpL.map((function(e){return{closed:e.Clsp,points:e["Pts "].map((function(e){return{anchor:B(e.Anch),forward:B(e["Fwd "]),backward:B(e["Bwd "]),smooth:e.Smoo}}))}}))}}))}};var t}))}}}))}}(i.filterFX)),(0,s.skipBytes)(e,r())}),(function(e,t){var r,i;(0,l.writeSignature)(e,"soLD"),(0,l.writeInt32)(e,4);var a,o=t.placedLayer,s=n(n({Idnt:o.id,placed:null!==(r=o.placed)&&void 0!==r?r:o.id,PgNm:o.pageNumber||1,totalPages:o.totalPages||1},o.crop?{Crop:o.crop}:{}),{frameStep:o.frameStep||{numerator:0,denominator:600},duration:o.duration||{numerator:0,denominator:600},frameCount:o.frameCount||0,Annt:16,Type:y.indexOf(o.type),Trnf:o.transform,nonAffineTransform:null!==(i=o.nonAffineTransform)&&void 0!==i?i:o.transform,quiltWarp:{},warp:C(o.warp||{}),"Sz ":{Wdth:o.width||0,Hght:o.height||0},Rslt:o.resolution?(0,c.unitsValue)(o.resolution,"resolution"):{units:"Density",value:72}});if(o.filter&&(s.filterFX={enab:(a=o.filter).enabled,validAtPosition:a.validAtPosition,filterMaskEnable:a.maskEnabled,filterMaskLinked:a.maskLinked,filterMaskExtendWithWhite:a.maskExtendWithWhite,filterFXList:(a.list||[]).map((function(e){return{"Nm ":e.name,blendOptions:{Opct:(0,c.unitsPercent)(e.opacity),"Md ":c.BlnM.encode(e.blendMode)},enab:e.enabled,hasoptions:e.hasOptions,FrgC:(0,c.serializeColor)(e.foregroundColor),BckC:(0,c.serializeColor)(e.backgroundColor),Fltr:{null:["Ordn.Trgt"],rigidType:e.filter.rigidType,puppetShapeList:(e.filter.puppetShapeList||[]).map((function(e){return{rigidType:e.rigidType,VrsM:1,VrsN:0,originalVertexArray:S(new Float32Array(E(e.originalVertexArray))),deformedVertexArray:S(new Float32Array(E(e.deformedVertexArray))),indexArray:S(new Uint32Array(e.indexArray)),pinOffsets:E(e.pinOffsets),posFinalPins:E(e.posFinalPins),selectedPin:e.selectedPin,pinVertexIndices:e.pinVertexIndices,PinP:E(e.pinPosition),PnRt:e.pinRotation,PnOv:e.pinOverlay,PnDp:e.pinDepth,meshQuality:e.meshQuality,meshExpansion:e.meshExpansion,meshRigidity:e.meshRigidity,imageResolution:e.imageResolution,meshBoundaryPath:{pathComponents:(e.meshBoundaryPath.pathComponents||[]).map((function(e){return{shapeOperation:"shapeOperation.".concat(e.shapeOperation),SbpL:(e.paths||[]).map((function(e){return{Clsp:e.closed,"Pts ":(e.points||[]).map((function(e){return{Anch:O(e.anchor),"Fwd ":O(e.forward),"Bwd ":O(e.backward),Smoo:e.smooth}}))}}))}}))}}})),PuX0:e.filter.bounds[0].x,PuX1:e.filter.bounds[1].x,PuX2:e.filter.bounds[2].x,PuX3:e.filter.bounds[3].x,PuY0:e.filter.bounds[0].y,PuY1:e.filter.bounds[1].y,PuY2:e.filter.bounds[2].y,PuY3:e.filter.bounds[3].y},filterID:e.id}}))}),o.warp&&k(o.warp)){var d=C(o.warp);s.quiltWarp=d,s.warp={warpStyle:"warpStyle.warpNone",warpValue:d.warpValue,warpPerspective:d.warpPerspective,warpPerspectiveOther:d.warpPerspectiveOther,warpRotate:d.warpRotate,bounds:d.bounds,uOrder:d.uOrder,vOrder:d.vOrder}}else delete s.quiltWarp;o.comp&&(s.comp=o.comp),o.compInfo&&(s.compInfo=o.compInfo),(0,c.writeVersionAndDescriptor)(e,"","null",s,s.quiltWarp?"quiltWarp":"warp")})),f("SoLE","SoLd"),u("fxrp",p("referencePoint"),(function(e,t){t.referencePoint={x:(0,s.readFloat64)(e),y:(0,s.readFloat64)(e)}}),(function(e,t){(0,l.writeFloat64)(e,t.referencePoint.x),(0,l.writeFloat64)(e,t.referencePoint.y)})),o.MOCK_HANDLERS?u("Patt",(function(e){return void 0!==e._Patt}),(function(e,t,r){t._Patt=(0,s.readBytes)(e,r())}),(function(e,t){return!1})):u("Patt",(function(e){return!e}),(function(e,t,r){r()&&(0,s.skipBytes)(e,r())}),(function(e,t){})),u("Anno",(function(e){return void 0!==e.annotations}),(function(e,t,r){var n=(0,s.readUint16)(e),i=(0,s.readUint16)(e);if(2!==n||1!==i)throw new Error("Invalid Anno version");for(var a=(0,s.readUint32)(e),o=[],l=0;l<a;l++){(0,s.readUint32)(e);var c=(0,s.readSignature)(e),d=!!(0,s.readUint8)(e);(0,s.readUint8)(e),(0,s.readUint16)(e);var h=M(e),u=M(e),f=(0,s.readColor)(e),p=(0,s.readPascalString)(e,2),g=(0,s.readPascalString)(e,2),v=(0,s.readPascalString)(e,2);(0,s.readUint32)(e),(0,s.readSignature)(e);var m=(0,s.readUint32)(e),A=void 0;if("txtA"===c)m>=2&&65279===(0,s.readUint16)(e)?A=(0,s.readUnicodeStringWithLength)(e,(m-2)/2):(e.offset-=2,A=(0,s.readAsciiString)(e,m)),A=A.replace(/\r/g,"\n");else{if("sndA"!==c)throw new Error("Unknown annotation type");A=(0,s.readBytes)(e,m)}o.push({type:"txtA"===c?"text":"sound",open:d,iconLocation:h,popupLocation:u,color:f,author:p,name:g,date:v,data:A})}t.annotations=o,(0,s.skipBytes)(e,r())}),(function(e,t){var r=t.annotations;(0,l.writeUint16)(e,2),(0,l.writeUint16)(e,1),(0,l.writeUint32)(e,r.length);for(var n=0,i=r;n<i.length;n++){var a=i[n],o="sound"===a.type;if(o&&!(a.data instanceof Uint8Array))throw new Error("Sound annotation data should be Uint8Array");if(!o&&"string"!=typeof a.data)throw new Error("Text annotation data should be string");var s=e.offset;(0,l.writeUint32)(e,0),(0,l.writeSignature)(e,o?"sndA":"txtA"),(0,l.writeUint8)(e,a.open?1:0),(0,l.writeUint8)(e,28),(0,l.writeUint16)(e,1),U(e,a.iconLocation),U(e,a.popupLocation),(0,l.writeColor)(e,a.color),(0,l.writePascalString)(e,a.author||"",2),(0,l.writePascalString)(e,a.name||"",2),(0,l.writePascalString)(e,a.date||"",2);var c=e.offset;(0,l.writeUint32)(e,0),(0,l.writeSignature)(e,o?"sndM":"txtC"),(0,l.writeUint32)(e,0);var d=e.offset;if(o)(0,l.writeBytes)(e,a.data);else{(0,l.writeUint16)(e,65279);for(var h=a.data.replace(/\n/g,"\r"),u=0;u<h.length;u++)(0,l.writeUint16)(e,h.charCodeAt(u))}e.view.setUint32(s,e.offset-s,!1),e.view.setUint32(c,e.offset-c,!1),e.view.setUint32(d-4,e.offset-d,!1)}})),u("lnk2",(function(e){return!!e.linkedFiles&&e.linkedFiles.length>0}),(function(e,t,r,n,i){var a=t;for(a.linkedFiles=a.linkedFiles||[];r()>8;){var o=g(e),l=e.offset,d=(0,s.readSignature)(e),h=(0,s.readInt32)(e),u=(0,s.readPascalString)(e,1),f=(0,s.readUnicodeString)(e),p=(0,s.readSignature)(e).trim(),v=(0,s.readSignature)(e).trim(),m=g(e),A=(0,s.readUint8)(e)?(0,c.readVersionAndDescriptor)(e):void 0,b=("liFE"===d&&(0,c.readVersionAndDescriptor)(e),{id:u,name:f,data:void 0});if(p&&(b.type=p),v&&(b.creator=v),A&&(b.descriptor=A),"liFE"===d&&h>3){var y=(0,s.readInt32)(e),w=(0,s.readUint8)(e),k=(0,s.readUint8)(e),C=(0,s.readUint8)(e),S=(0,s.readUint8)(e),x=(0,s.readFloat64)(e),E=Math.floor(x),I=1e3*(x-E);b.time=new Date(y,w,k,C,S,E,I).toISOString()}var B="liFE"===d?g(e):0;for("liFA"===d&&(0,s.skipBytes)(e,8),"liFD"===d&&(b.data=(0,s.readBytes)(e,m)),h>=5&&(b.childDocumentID=(0,s.readUnicodeString)(e)),h>=6&&(b.assetModTime=(0,s.readFloat64)(e)),h>=7&&(b.assetLockedState=(0,s.readUint8)(e)),"liFE"===d&&(b.data=(0,s.readBytes)(e,B)),i.skipLinkedFilesData&&(b.data=void 0),a.linkedFiles.push(b);o%4;)o++;e.offset=l+o}(0,s.skipBytes)(e,r())}),(function(e,t){for(var r=0,n=t.linkedFiles;r<n.length;r++){var i=n[r],a=2;null!=i.assetLockedState?a=7:null!=i.assetModTime?a=6:null!=i.childDocumentID&&(a=5),(0,l.writeUint32)(e,0),(0,l.writeUint32)(e,0);var o=e.offset;if((0,l.writeSignature)(e,i.data?"liFD":"liFA"),(0,l.writeInt32)(e,a),(0,l.writePascalString)(e,i.id||"",1),(0,l.writeUnicodeStringWithPadding)(e,i.name||""),(0,l.writeSignature)(e,i.type?"".concat(i.type," ").substring(0,4):" "),(0,l.writeSignature)(e,i.creator?"".concat(i.creator," ").substring(0,4):"\0\0\0\0"),v(e,i.data?i.data.byteLength:0),i.descriptor&&i.descriptor.compInfo){var s={compInfo:i.descriptor.compInfo};(0,l.writeUint8)(e,1),(0,c.writeVersionAndDescriptor)(e,"","null",s)}else(0,l.writeUint8)(e,0);i.data?(0,l.writeBytes)(e,i.data):v(e,0),a>=5&&(0,l.writeUnicodeStringWithPadding)(e,i.childDocumentID||""),a>=6&&(0,l.writeFloat64)(e,i.assetModTime||0),a>=7&&(0,l.writeUint8)(e,i.assetLockedState||0);var d=e.offset-o;for(e.view.setUint32(o-4,d,!1);d%4;)d++,(0,l.writeUint8)(e,0)}})),f("lnkD","lnk2"),f("lnk3","lnk2"),f("lnkE","lnk2"),u("pths",p("pathList"),(function(e,t){(0,c.readVersionAndDescriptor)(e);t.pathList=[]}),(function(e,t){(0,c.writeVersionAndDescriptor)(e,"","pathsDataClass",{pathList:[]})})),u("lyvr",p("version"),(function(e,t){return t.version=(0,s.readUint32)(e)}),(function(e,t){return(0,l.writeUint32)(e,t.version)})),u("brit",R("brightness/contrast"),(function(e,t,r){t.adjustment||(t.adjustment={type:"brightness/contrast",brightness:(0,s.readInt16)(e),contrast:(0,s.readInt16)(e),meanValue:(0,s.readInt16)(e),labColorOnly:!!(0,s.readUint8)(e),useLegacy:!0}),(0,s.skipBytes)(e,r())}),(function(e,t){var r,n=t.adjustment;(0,l.writeInt16)(e,n.brightness||0),(0,l.writeInt16)(e,n.contrast||0),(0,l.writeInt16)(e,null!==(r=n.meanValue)&&void 0!==r?r:127),(0,l.writeUint8)(e,n.labColorOnly?1:0),(0,l.writeZeros)(e,1)})),u("levl",R("levels"),(function(e,t,r){if(2!==(0,s.readUint16)(e))throw new Error("Invalid levl version");t.adjustment=n(n({},t.adjustment),{type:"levels",rgb:P(e),red:P(e),green:P(e),blue:P(e)}),(0,s.skipBytes)(e,r())}),(function(e,t){var r=t.adjustment,n={shadowInput:0,highlightInput:255,shadowOutput:0,highlightOutput:255,midtoneInput:1};(0,l.writeUint16)(e,2),D(e,r.rgb||n),D(e,r.red||n),D(e,r.blue||n),D(e,r.green||n);for(var i=0;i<59;i++)D(e,n)})),u("curv",R("curves"),(function(e,t,r){if((0,s.readUint8)(e),1!==(0,s.readUint16)(e))throw new Error("Invalid curv version");(0,s.readUint16)(e);var i=(0,s.readUint16)(e),a={type:"curves"};1&i&&(a.rgb=F(e)),2&i&&(a.red=F(e)),4&i&&(a.green=F(e)),8&i&&(a.blue=F(e)),t.adjustment=n(n({},t.adjustment),a),(0,s.skipBytes)(e,r())}),(function(e,t){var r=t.adjustment,n=r.rgb,i=r.red,a=r.green,o=r.blue,s=0,c=0;n&&n.length&&(s|=1,c++),i&&i.length&&(s|=2,c++),a&&a.length&&(s|=4,c++),o&&o.length&&(s|=8,c++),(0,l.writeUint8)(e,0),(0,l.writeUint16)(e,1),(0,l.writeUint16)(e,0),(0,l.writeUint16)(e,s),n&&n.length&&T(e,n),i&&i.length&&T(e,i),a&&a.length&&T(e,a),o&&o.length&&T(e,o),(0,l.writeSignature)(e,"Crv "),(0,l.writeUint16)(e,4),(0,l.writeUint16)(e,0),(0,l.writeUint16)(e,c),n&&n.length&&((0,l.writeUint16)(e,0),T(e,n)),i&&i.length&&((0,l.writeUint16)(e,1),T(e,i)),a&&a.length&&((0,l.writeUint16)(e,2),T(e,a)),o&&o.length&&((0,l.writeUint16)(e,3),T(e,o)),(0,l.writeZeros)(e,2)})),u("expA",R("exposure"),(function(e,t,r){if(1!==(0,s.readUint16)(e))throw new Error("Invalid expA version");t.adjustment=n(n({},t.adjustment),{type:"exposure",exposure:(0,s.readFloat32)(e),offset:(0,s.readFloat32)(e),gamma:(0,s.readFloat32)(e)}),(0,s.skipBytes)(e,r())}),(function(e,t){var r=t.adjustment;(0,l.writeUint16)(e,1),(0,l.writeFloat32)(e,r.exposure),(0,l.writeFloat32)(e,r.offset),(0,l.writeFloat32)(e,r.gamma),(0,l.writeZeros)(e,2)})),u("vibA",R("vibrance"),(function(e,t,r){var n=(0,c.readVersionAndDescriptor)(e);t.adjustment={type:"vibrance"},void 0!==n.vibrance&&(t.adjustment.vibrance=n.vibrance),void 0!==n.Strt&&(t.adjustment.saturation=n.Strt),(0,s.skipBytes)(e,r())}),(function(e,t){var r=t.adjustment,n={};void 0!==r.vibrance&&(n.vibrance=r.vibrance),void 0!==r.saturation&&(n.Strt=r.saturation),(0,c.writeVersionAndDescriptor)(e,"","null",n)})),u("hue2",R("hue/saturation"),(function(e,t,r){if(2!==(0,s.readUint16)(e))throw new Error("Invalid hue2 version");t.adjustment=n(n({},t.adjustment),{type:"hue/saturation",master:_(e),reds:_(e),yellows:_(e),greens:_(e),cyans:_(e),blues:_(e),magentas:_(e)}),(0,s.skipBytes)(e,r())}),(function(e,t){var r=t.adjustment;(0,l.writeUint16)(e,2),L(e,r.master),L(e,r.reds),L(e,r.yellows),L(e,r.greens),L(e,r.cyans),L(e,r.blues),L(e,r.magentas)})),u("blnc",R("color balance"),(function(e,t,r){t.adjustment={type:"color balance",shadows:z(e),midtones:z(e),highlights:z(e),preserveLuminosity:!!(0,s.readUint8)(e)},(0,s.skipBytes)(e,r())}),(function(e,t){var r=t.adjustment;j(e,r.shadows||{}),j(e,r.midtones||{}),j(e,r.highlights||{}),(0,l.writeUint8)(e,r.preserveLuminosity?1:0),(0,l.writeZeros)(e,1)})),u("blwh",R("black & white"),(function(e,t,r){var n=(0,c.readVersionAndDescriptor)(e);t.adjustment={type:"black & white",reds:n["Rd "],yellows:n.Yllw,greens:n["Grn "],cyans:n["Cyn "],blues:n["Bl "],magentas:n.Mgnt,useTint:!!n.useTint,presetKind:n.bwPresetKind,presetFileName:n.blackAndWhitePresetFileName},void 0!==n.tintColor&&(t.adjustment.tintColor=(0,c.parseColor)(n.tintColor)),(0,s.skipBytes)(e,r())}),(function(e,t){var r=t.adjustment,n={"Rd ":r.reds||0,Yllw:r.yellows||0,"Grn ":r.greens||0,"Cyn ":r.cyans||0,"Bl ":r.blues||0,Mgnt:r.magentas||0,useTint:!!r.useTint,tintColor:(0,c.serializeColor)(r.tintColor),bwPresetKind:r.presetKind||0,blackAndWhitePresetFileName:r.presetFileName||""};(0,c.writeVersionAndDescriptor)(e,"","null",n)})),u("phfl",R("photo filter"),(function(e,t,r){var n,i=(0,s.readUint16)(e);if(2!==i&&3!==i)throw new Error("Invalid phfl version");n=2===i?(0,s.readColor)(e):{l:(0,s.readInt32)(e)/100,a:(0,s.readInt32)(e)/100,b:(0,s.readInt32)(e)/100},t.adjustment={type:"photo filter",color:n,density:(0,s.readUint32)(e)/100,preserveLuminosity:!!(0,s.readUint8)(e)},(0,s.skipBytes)(e,r())}),(function(e,t){var r=t.adjustment;(0,l.writeUint16)(e,2),(0,l.writeColor)(e,r.color||{l:0,a:0,b:0}),(0,l.writeUint32)(e,100*(r.density||0)),(0,l.writeUint8)(e,r.preserveLuminosity?1:0),(0,l.writeZeros)(e,3)})),u("mixr",R("channel mixer"),(function(e,t,r){if(1!==(0,s.readUint16)(e))throw new Error("Invalid mixr version");var i=t.adjustment=n(n({},t.adjustment),{type:"channel mixer",monochrome:!!(0,s.readUint16)(e)});i.monochrome||(i.red=H(e),i.green=H(e),i.blue=H(e)),i.gray=H(e),(0,s.skipBytes)(e,r())}),(function(e,t){var r=t.adjustment;(0,l.writeUint16)(e,1),(0,l.writeUint16)(e,r.monochrome?1:0),r.monochrome?(N(e,r.gray),(0,l.writeZeros)(e,30)):(N(e,r.red),N(e,r.green),N(e,r.blue),N(e,r.gray))}));var V=(0,o.createEnum)("colorLookupType","3DLUT",{"3dlut":"3DLUT",abstractProfile:"abstractProfile",deviceLinkProfile:"deviceLinkProfile"}),G=(0,o.createEnum)("LUTFormatType","look",{look:"LUTFormatLOOK",cube:"LUTFormatCUBE","3dl":"LUTFormat3DL"}),K=(0,o.createEnum)("colorLookupOrder","rgb",{rgb:"rgbOrder",bgr:"bgrOrder"});u("clrL",R("color lookup"),(function(e,t,r){if(1!==(0,s.readUint16)(e))throw new Error("Invalid clrL version");var n=(0,c.readVersionAndDescriptor)(e);t.adjustment={type:"color lookup"};var i=t.adjustment;void 0!==n.lookupType&&(i.lookupType=V.decode(n.lookupType)),void 0!==n["Nm "]&&(i.name=n["Nm "]),void 0!==n.Dthr&&(i.dither=n.Dthr),void 0!==n.profile&&(i.profile=n.profile),void 0!==n.LUTFormat&&(i.lutFormat=G.decode(n.LUTFormat)),void 0!==n.dataOrder&&(i.dataOrder=K.decode(n.dataOrder)),void 0!==n.tableOrder&&(i.tableOrder=K.decode(n.tableOrder)),void 0!==n.LUT3DFileData&&(i.lut3DFileData=n.LUT3DFileData),void 0!==n.LUT3DFileName&&(i.lut3DFileName=n.LUT3DFileName),(0,s.skipBytes)(e,r())}),(function(e,t){var r=t.adjustment,n={};void 0!==r.lookupType&&(n.lookupType=V.encode(r.lookupType)),void 0!==r.name&&(n["Nm "]=r.name),void 0!==r.dither&&(n.Dthr=r.dither),void 0!==r.profile&&(n.profile=r.profile),void 0!==r.lutFormat&&(n.LUTFormat=G.encode(r.lutFormat)),void 0!==r.dataOrder&&(n.dataOrder=K.encode(r.dataOrder)),void 0!==r.tableOrder&&(n.tableOrder=K.encode(r.tableOrder)),void 0!==r.lut3DFileData&&(n.LUT3DFileData=r.lut3DFileData),void 0!==r.lut3DFileName&&(n.LUT3DFileName=r.lut3DFileName),(0,l.writeUint16)(e,1),(0,c.writeVersionAndDescriptor)(e,"","null",n)})),u("nvrt",R("invert"),(function(e,t,r){t.adjustment={type:"invert"},(0,s.skipBytes)(e,r())}),(function(){})),u("post",R("posterize"),(function(e,t,r){t.adjustment={type:"posterize",levels:(0,s.readUint16)(e)},(0,s.skipBytes)(e,r())}),(function(e,t){var r,n=t.adjustment;(0,l.writeUint16)(e,null!==(r=n.levels)&&void 0!==r?r:4),(0,l.writeZeros)(e,2)})),u("thrs",R("threshold"),(function(e,t,r){t.adjustment={type:"threshold",level:(0,s.readUint16)(e)},(0,s.skipBytes)(e,r())}),(function(e,t){var r,n=t.adjustment;(0,l.writeUint16)(e,null!==(r=n.level)&&void 0!==r?r:128),(0,l.writeZeros)(e,2)}));var Y=["","","","rgb","hsb","","lab"];function W(e){return{c:(0,s.readInt16)(e),m:(0,s.readInt16)(e),y:(0,s.readInt16)(e),k:(0,s.readInt16)(e)}}function Z(e,t){var r=t||{};(0,l.writeInt16)(e,r.c),(0,l.writeInt16)(e,r.m),(0,l.writeInt16)(e,r.y),(0,l.writeInt16)(e,r.k)}function X(e){return Object.keys(e).map((function(t){return e[t]})).some((function(e){return Array.isArray(e)&&e.length>1}))}u("grdm",R("gradient map"),(function(e,t,r){if(1!==(0,s.readUint16)(e))throw new Error("Invalid grdm version");var n={type:"gradient map",gradientType:"solid"};n.reverse=!!(0,s.readUint8)(e),n.dither=!!(0,s.readUint8)(e),n.name=(0,s.readUnicodeString)(e),n.colorStops=[],n.opacityStops=[];for(var i=(0,s.readUint16)(e),a=0;a<i;a++)n.colorStops.push({location:(0,s.readUint32)(e),midpoint:(0,s.readUint32)(e)/100,color:(0,s.readColor)(e)}),(0,s.skipBytes)(e,2);var o=(0,s.readUint16)(e);for(a=0;a<o;a++)n.opacityStops.push({location:(0,s.readUint32)(e),midpoint:(0,s.readUint32)(e)/100,opacity:(0,s.readUint16)(e)/255});if(2!==(0,s.readUint16)(e))throw new Error("Invalid grdm expansion count");var l=(0,s.readUint16)(e);if(n.smoothness=l/4096,32!==(0,s.readUint16)(e))throw new Error("Invalid grdm length");n.gradientType=(0,s.readUint16)(e)?"noise":"solid",n.randomSeed=(0,s.readUint32)(e),n.addTransparency=!!(0,s.readUint16)(e),n.restrictColors=!!(0,s.readUint16)(e),n.roughness=(0,s.readUint32)(e)/4096,n.colorModel=Y[(0,s.readUint16)(e)]||"rgb",n.min=[(0,s.readUint16)(e)/32768,(0,s.readUint16)(e)/32768,(0,s.readUint16)(e)/32768,(0,s.readUint16)(e)/32768],n.max=[(0,s.re