0&&s.filters.forEach((e=>{if("brightness"===e.type)c.push({type:"color matrix",value:[e.value,0,0,0,0,0,e.value,0,0,0,0,0,e.value,0,0,0,0,0,1,0]});else if("contrast"===e.type){const t=.5*(1-e.value);c.push({type:"color matrix",value:[e.value,0,0,0,t,0,e.value,0,0,t,0,0,e.value,0,t,0,0,0,1,0]})}else if("hue-rotate"===e.type){const t=(0,p.angleToRadian)(e.value),n=Math.cos(t),r=Math.sin(t),o=.213,i=.715,a=.072;c.push({type:"color matrix",value:[o+n*(1-o)+r*-o,i+n*-i+r*-i,a+n*-a+r*(1-a),0,0,o+n*-o+.143*r,i+n*(1-i)+.14*r,a+n*-a+-.283*r,0,0,o+n*-o+r*-(1-o),i+n*-i+r*i,a+n*(1-a)+r*a,0,0,0,0,0,1,0]})}else if("saturate"===e.type){const t=2*(e.value-1)/3+1,n=-.5*(t-1);c.push({type:"color matrix",value:[t,n,n,0,0,n,t,n,0,0,n,n,t,0,0,0,0,0,1,0]})}else if("grayscale"===e.type){const t=1-e.value;c.push({type:"color matrix",value:[.2126+.7874*t,.7152-.7152*t,.0722-.0722*t,0,0,.2126-.2126*t,.7152+.2848*t,.0722-.0722*t,0,0,.2126-.2126*t,.7152-.7152*t,.0722+.9278*t,0,0,0,0,0,1,0]})}else if("sepia"===e.type){const t=1-e.value;c.push({type:"color matrix",value:[.393+.607*t,.769-.769*t,.189-.189*t,0,0,.349-.349*t,.686+.314*t,.168-.168*t,0,0,.272-.272*t,.534-.534*t,.131+.869*t,0,0,0,0,0,1,0]})}else if("invert"===e.type){const t=1-2*e.value;c.push({type:"color matrix",value:[t,0,0,0,e.value,0,t,0,0,e.value,0,0,t,0,e.value,0,0,0,1,0]})}else"opacity"===e.type?c.push({type:"color matrix",value:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,e.value,0]}):"blur"===e.type&&c.push({type:"blur",value:[0,3*e.value/7/o]},{type:"blur",value:[3*e.value/7/r,0]})})),{type:"texture",x:t,y:n,width:r,height:o,src:l,opacity:null==s?void 0:s.opacity,filters:c.length>0?c:void 0}}function A(e,t,n,r=1){return n&&(t||(t=l.m3.identity()),n.translate&&(t=l.m3.multiply(t,l.m3.translation(n.translate.x,n.translate.y))),n.base&&(n.angle||n.rotation)&&(t=l.m3.multiply(t,l.m3.translation(n.base.x,n.base.y)),n.angle?t=l.m3.multiply(t,l.m3.rotation(-(0,p.angleToRadian)(n.angle))):n.rotation&&(t=l.m3.multiply(t,l.m3.rotation(-n.rotation))),t=l.m3.multiply(t,l.m3.translation(-n.base.x,-n.base.y))),n.matrix&&(t=l.m3.multiply(t,n.matrix)),void 0!==n.opacity&&(r*=n.opacity)),e.map((e=>w(k({},e),{matrix:e.matrix?t?l.m3.multiply(t,e.matrix):e.matrix:t,opacity:void 0!==e.opacity?r*e.opacity:r})))}const M=new u.WeakmapCache,L=new u.WeakmapMap3Cache,O=new u.WeakmapMap3Cache,I=new u.WeakmapMapCache,F=new u.WeakmapMapCache;function D(e,t){(null==t?void 0:t.dashArray)&&(e.setLineDash(t.dashArray),t.dashOffset&&(e.lineDashOffset=t.dashOffset))}function B(e,t){const{start:n,end:r}=e,o=r.x-n.x,i=r.y-n.y,a=(0,c.twoPointLineToGeneralFormLine)(n,r),l=e.stops.slice(0).sort(((e,t)=>e.offset-t.offset)),u=[];let p=l[0].offset,d=l[l.length-1].offset;t.forEach((e=>{const t=(0,g.getPerpendicularPoint)(e,a),r=(0,c.getPointSideOfLine)(e,a);if((0,c.isZero)(r))u.push(0);else{const n=(0,c.getTwoPointsDistance)(t,e);r>0?u.push(n):r<0&&u.push(-n)}const s=(0,c.equals)(t.x,n.x)?(t.y-n.y)/i:(t.x-n.x)/o;sd&&(d=s)})),(0,c.equals)(p,l[0].offset)||l.unshift({offset:p,color:l[0].color}),(0,c.equals)(d,l[l.length-1].offset)||l.push({offset:d,color:l[l.length-1].color});const h=(0,c.getParallelLinesByDistance)(a,Math.max(...u))[1],m=(0,c.getParallelLinesByDistance)(a,Math.min(...u))[1],y=[],x=[];return l.forEach((e=>{const t={x:n.x+o*e.offset,y:n.y+i*e.offset},r=(0,f.getTwoGeneralFormLinesIntersectionPoint)(h,(0,g.getPerpendicular)(t,h)),a=(0,f.getTwoGeneralFormLinesIntersectionPoint)(m,(0,g.getPerpendicular)(t,m)),l=(0,s.colorNumberToRec)(e.color,e.opacity);r&&a&&(y.push(r.x,r.y,a.x,a.y),x.push(...l,...l))})),{type:"triangle strip",points:y,colors:x}}function z(e,t){let{start:n,end:r,stops:o}=e;if(n.r>r.r){const e=n;n=r,r=e,o=o.map((e=>({offset:1-e.offset,color:e.color})))}const i=r.x-n.x,a=r.y-n.y,l=r.r-n.r,u=o.slice(0).sort(((e,t)=>e.offset-t.offset)).map((e=>{const t={x:n.x+i*e.offset,y:n.y+a*e.offset,r:n.r+l*e.offset};return{color:(0,s.colorNumberToRec)(e.color,e.opacity),points:(0,c.arcToPolyline)({x:t.x,y:t.y,r:t.r,startAngle:0,endAngle:360},5)}})),p=Math.max(...t.map((e=>(0,c.getTwoPointsDistance)(e,r))));p>r.r&&u.push({color:u[u.length-1].color,points:(0,c.arcToPolyline)({x:r.x,y:r.y,r:p,startAngle:0,endAngle:360},5)});const d=[],f=[];if(n.r>0){const e=u[0],t=[],r=[];e.points.forEach((o=>{t.push(o.x,o.y,n.x,n.y),r.push(...e.color,...e.color)})),d.push(t),f.push(r)}for(let e=1;e{const a=n.points[i];r.unshift(e.x,e.y,a.x,a.y),o.unshift(...t.color,...n.color)})),d.push(r),f.push(o)}return{type:"triangle strip",points:(0,h.combineStripTriangles)(d),colors:(0,h.combineStripTriangleColors)(f)}}function U(e){const t=[];for(let n=0;nr&&(r=a),so&&(o=s)}return{xMax:r,xMin:t,yMin:n,yMax:o}}function j(e,t,n,r){var o,i;const{xMin:a,yMin:s,xMax:c,yMax:u}=n,p=null!=(o=e.width)?o:Number.MAX_SAFE_INTEGER,d=null!=(i=e.height)?i:Number.MAX_SAFE_INTEGER,f=Math.floor(a/p),g=Math.floor(c/p),h=Math.floor(s/d),m=Math.floor(u/d);for(let n=f;n<=g;n++)for(let o=h;o<=m;o++){const i=l.m3.multiply(t,l.m3.translation(n*p,o*d));for(const t of e.graphics)r(t,t.matrix?l.m3.multiply(i,t.matrix):i)}}function W(e,t){var n,r;const o=l.m3.multiply(e,l.m3.translation(t.x,t.y)),i=null!=(n=t.width)?n:t.src.width,a=null!=(r=t.height)?r:t.src.height;return{textureMatrix:l.m3.multiply(o,l.m3.scaling(i,a)),width:i,height:a}}function G(e,t,n,r,o){let i=l.m3.projection(e.width,e.height);return i=l.m3.multiply(i,l.m3.translation(t,n)),1!==r&&(i=l.m3.multiply(i,l.m3.translation(e.width/2,e.height/2)),i=l.m3.multiply(i,l.m3.scaling(r,r)),i=l.m3.multiply(i,l.m3.translation(-e.width/2,-e.height/2))),o&&(i=l.m3.multiply(i,l.m3.rotation(-o))),i}},9417:(e,t,n)=>{"use strict";n.r(t),n.d(t,{createUniformsBuffer:()=>p,createWebgpuRenderer:()=>u});var r=n(7459),o=n(7504),i=n(6581),a=n(863),s=n(5547),l=n(8485),c=(e,t,n)=>new Promise(((r,o)=>{var i=e=>{try{s(n.next(e))}catch(e){o(e)}},a=e=>{try{s(n.throw(e))}catch(e){o(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(i,a);s((n=n.apply(e,t)).next())}));function u(e){return c(this,null,(function*(){if(!navigator.gpu)return;const t=e.getContext("webgpu");if(!t)return;const n=yield navigator.gpu.requestAdapter();if(!n)return;const a=yield n.requestDevice(),c=navigator.gpu.getPreferredCanvasFormat();t.configure({device:a,format:c});const u={color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha"},alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha"}},d=new r.Lazy((()=>a.createShaderModule({code:"struct Uniforms {\n color: vec4f,\n matrix: mat3x3f,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n \n @vertex\n fn vertex_main(@location(0) position: vec2f) -> @builtin(position) vec4f\n {\n return vec4f((uniforms.matrix * vec3(position.xy, 1)).xy, 0, 1);\n }\n \n @fragment\n fn fragment_main() -> @location(0) vec4f\n {\n return uniforms.color;\n }"}))),f=new r.Lazy((()=>a.createShaderModule({code:"struct Uniforms {\n matrix: mat3x3f,\n color: vec4f,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n @group(0) @binding(1) var mySampler: sampler;\n @group(0) @binding(2) var myTexture: texture_2d;\n\n struct VertexOutput {\n @builtin(position) position: vec4f,\n @location(0) texcoord: vec2f,\n };\n \n @vertex\n fn vertex_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput\n {\n var pos = array(\n vec2f(0.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 1.0),\n vec2f(1.0, 0.0),\n );\n let xy = pos[vertexIndex];\n var vsOut: VertexOutput;\n vsOut.position = vec4f((uniforms.matrix * vec3(xy, 1)).xy, 0, 1);\n vsOut.texcoord = xy;\n return vsOut;\n }\n \n @fragment\n fn fragment_main(@location(0) texcoord: vec2f) -> @location(0) vec4f\n {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 || texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n var color = textureSample(myTexture, mySampler, texcoord) * uniforms.color;\n if (color.a < 0.1) {\n discard;\n }\n return color;\n }"}))),g=new r.Lazy((()=>a.createShaderModule({code:"struct Uniforms {\n matrix: mat3x3f,\n opacity: f32,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n @group(0) @binding(1) var mySampler: sampler;\n @group(0) @binding(2) var myTexture: texture_2d;\n\n struct VertexOutput {\n @builtin(position) position: vec4f,\n @location(0) texcoord: vec2f,\n };\n \n @vertex\n fn vertex_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput\n {\n var pos = array(\n vec2f(0.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 1.0),\n vec2f(1.0, 0.0),\n );\n let xy = pos[vertexIndex];\n var vsOut: VertexOutput;\n vsOut.position = vec4f((uniforms.matrix * vec3(xy, 1)).xy, 0, 1);\n vsOut.texcoord = xy;\n return vsOut;\n }\n \n @fragment\n fn fragment_main(@location(0) texcoord: vec2f) -> @location(0) vec4f\n {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 || texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n return textureSample(myTexture, mySampler, texcoord) * vec4f(1, 1, 1, uniforms.opacity);\n }"}))),h=new r.Lazy((()=>a.createShaderModule({code:"struct Uniforms {\n matrix: mat3x3f,\n opacity: f32,\n colorMatrix: array,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n @group(0) @binding(1) var mySampler: sampler;\n @group(0) @binding(2) var myTexture: texture_2d;\n\n struct VertexOutput {\n @builtin(position) position: vec4f,\n @location(0) texcoord: vec2f,\n };\n \n @vertex\n fn vertex_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput\n {\n var pos = array(\n vec2f(0.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 1.0),\n vec2f(1.0, 0.0),\n );\n let xy = pos[vertexIndex];\n var vsOut: VertexOutput;\n vsOut.position = vec4f((uniforms.matrix * vec3(xy, 1)).xy, 0, 1);\n vsOut.texcoord = xy;\n return vsOut;\n }\n \n @fragment\n fn fragment_main(@location(0) texcoord: vec2f) -> @location(0) vec4f\n {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 || texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n var c = textureSample(myTexture, mySampler, texcoord) * vec4f(1, 1, 1, uniforms.opacity);\n var r = uniforms.colorMatrix[0][0] * c.r + uniforms.colorMatrix[0][1] * c.g + uniforms.colorMatrix[0][2] * c.b + uniforms.colorMatrix[0][3] * c.a + uniforms.colorMatrix[1][0];\n var g = uniforms.colorMatrix[1][1] * c.r + uniforms.colorMatrix[1][2] * c.g + uniforms.colorMatrix[1][3] * c.b + uniforms.colorMatrix[2][0] * c.a + uniforms.colorMatrix[2][1];\n var b = uniforms.colorMatrix[2][2] * c.r + uniforms.colorMatrix[2][3] * c.g + uniforms.colorMatrix[3][0] * c.b + uniforms.colorMatrix[3][1] * c.a + uniforms.colorMatrix[3][2];\n var a = uniforms.colorMatrix[3][3] * c.r + uniforms.colorMatrix[4][0] * c.g + uniforms.colorMatrix[4][1] * c.b + uniforms.colorMatrix[4][2] * c.a + uniforms.colorMatrix[4][3];\n return vec4f(r, g, b, a);\n }"}))),m=new r.Lazy((()=>a.createShaderModule({code:"struct Uniforms {\n matrix: mat3x3f,\n opacity: f32,\n px: vec4f,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n @group(0) @binding(1) var mySampler: sampler;\n @group(0) @binding(2) var myTexture: texture_2d;\n\n struct VertexOutput {\n @builtin(position) position: vec4f,\n @location(0) texcoord: vec2f,\n };\n \n @vertex\n fn vertex_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput\n {\n var pos = array(\n vec2f(0.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 1.0),\n vec2f(1.0, 0.0),\n );\n let xy = pos[vertexIndex];\n var vsOut: VertexOutput;\n vsOut.position = vec4f((uniforms.matrix * vec3(xy, 1)).xy, 0, 1);\n vsOut.texcoord = xy;\n return vsOut;\n }\n \n @fragment\n fn fragment_main(@location(0) texcoord: vec2f) -> @location(0) vec4f\n {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 || texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n var r = vec4f(0.0);\n r += textureSample(myTexture, mySampler, texcoord + vec2(-7.0*uniforms.px.x, -7.0*uniforms.px.y))*0.0044299121055113265;\n r += textureSample(myTexture, mySampler, texcoord + vec2(-6.0*uniforms.px.x, -6.0*uniforms.px.y))*0.00895781211794;\n r += textureSample(myTexture, mySampler, texcoord + vec2(-5.0*uniforms.px.x, -5.0*uniforms.px.y))*0.0215963866053;\n r += textureSample(myTexture, mySampler, texcoord + vec2(-4.0*uniforms.px.x, -4.0*uniforms.px.y))*0.0443683338718;\n r += textureSample(myTexture, mySampler, texcoord + vec2(-3.0*uniforms.px.x, -3.0*uniforms.px.y))*0.0776744219933;\n r += textureSample(myTexture, mySampler, texcoord + vec2(-2.0*uniforms.px.x, -2.0*uniforms.px.y))*0.115876621105;\n r += textureSample(myTexture, mySampler, texcoord + vec2(-1.0*uniforms.px.x, -1.0*uniforms.px.y))*0.147308056121;\n r += textureSample(myTexture, mySampler, texcoord )*0.159576912161;\n r += textureSample(myTexture, mySampler, texcoord + vec2( 1.0*uniforms.px.x, 1.0*uniforms.px.y))*0.147308056121;\n r += textureSample(myTexture, mySampler, texcoord + vec2( 2.0*uniforms.px.x, 2.0*uniforms.px.y))*0.115876621105;\n r += textureSample(myTexture, mySampler, texcoord + vec2( 3.0*uniforms.px.x, 3.0*uniforms.px.y))*0.0776744219933;\n r += textureSample(myTexture, mySampler, texcoord + vec2( 4.0*uniforms.px.x, 4.0*uniforms.px.y))*0.0443683338718;\n r += textureSample(myTexture, mySampler, texcoord + vec2( 5.0*uniforms.px.x, 5.0*uniforms.px.y))*0.0215963866053;\n r += textureSample(myTexture, mySampler, texcoord + vec2( 6.0*uniforms.px.x, 6.0*uniforms.px.y))*0.00895781211794;\n r += textureSample(myTexture, mySampler, texcoord + vec2( 7.0*uniforms.px.x, 7.0*uniforms.px.y))*0.0044299121055113265;\n return r;\n }"}))),y=new r.Lazy((()=>a.createShaderModule({code:"struct Uniforms {\n matrix: mat3x3f,\n color: vec4f,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n @group(0) @binding(1) var mySampler: sampler;\n @group(0) @binding(2) var myTexture: texture_2d;\n\n struct VertexOutput {\n @builtin(position) position: vec4f,\n @location(0) texcoord: vec2f,\n };\n \n @vertex\n fn vertex_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput\n {\n var pos = array(\n vec2f(0.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 1.0),\n vec2f(1.0, 0.0),\n );\n let xy = pos[vertexIndex];\n var vsOut: VertexOutput;\n vsOut.position = vec4f((uniforms.matrix * vec3(xy, 1)).xy, 0, 1);\n vsOut.texcoord = xy;\n return vsOut;\n }\n \n @fragment\n fn fragment_main(@location(0) texcoord: vec2f) -> @location(0) vec4f\n {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 || texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n var color = textureSample(myTexture, mySampler, texcoord);\n var color2 = color * uniforms.color;\n if (color2.a < 0.1) {\n discard;\n }\n return color;\n }"}))),x=new r.Lazy((()=>a.createShaderModule({code:"struct Uniforms {\n color: vec4f,\n matrix: mat3x3f,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n\n struct VertexOutput {\n @builtin(position) position: vec4f,\n @location(0) color: vec4f,\n };\n \n @vertex\n fn vertex_main(@location(0) position: vec2f, @location(1) color: vec4f) -> VertexOutput\n {\n var vsOut: VertexOutput;\n vsOut.position = vec4f((uniforms.matrix * vec3(position.xy, 1)).xy, 0, 1);\n vsOut.color = color;\n return vsOut;\n }\n \n @fragment\n fn fragment_main(@location(0) color: vec4f) -> @location(0) vec4f\n {\n return color;\n }"}))),v=new r.Lazy((()=>a.createSampler({magFilter:"nearest",minFilter:"nearest"}))),b=new r.Lazy((()=>a.createTexture({size:[e.width,e.height],sampleCount:4,format:c,usage:GPUTextureUsage.RENDER_ATTACHMENT})),(e=>e.destroy())),C=new r.Lazy((()=>a.createTexture({format:"stencil8",sampleCount:4,size:[e.width,e.height],usage:GPUTextureUsage.RENDER_ATTACHMENT})),(e=>e.destroy())),E=new s.WeakmapCache,k=new s.WeakmapCache2,w=new s.WeakmapMap2Cache,S=new s.WeakmapCache,P=new s.MapCache2,R=e=>"color matrix"===e.type?{shaderModule:h.instance,input:{type:"vec4 array",count:5,value:e.value}}:{shaderModule:m.instance,input:{type:"vec2",value:e.value}},_=(e,t,n,r)=>a.createRenderPipeline({vertex:{module:e,entryPoint:"vertex_main",buffers:r?[r]:void 0},fragment:{module:e,entryPoint:"fragment_main",targets:"mask"===t?[]:[{format:c,blend:u}]},depthStencil:"mask"===t?{format:"stencil8",depthCompare:"always",depthWriteEnabled:!1,stencilFront:{passOp:"replace"}}:"masked"===t?{depthCompare:"always",depthWriteEnabled:!1,format:"stencil8",stencilFront:{compare:"equal"}}:void 0,primitive:n?{topology:"triangles"===n?"triangle-list":"line strip"===n?"line-strip":"lines"===n?"line-list":"triangle-strip"}:void 0,multisample:{count:4},layout:"auto"}),T=(e,t,n)=>{e.setPipeline(t),e.setBindGroup(0,a.createBindGroup({layout:t.getBindGroupLayout(0),entries:n.map(((e,t)=>({binding:t,resource:e})))}))},A=(e,t,n,r,o="normal")=>{const i=P.get(e,o,(()=>_(e,o)));T(t,i,[{buffer:p(a,n)},v.instance,r.createView()]),t.draw(6)},M=(e,t)=>a.createTexture({size:[e,t],format:c,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT}),L=(e,n=t.getCurrentTexture(),r)=>e.beginRenderPass({colorAttachments:[{clearValue:r,loadOp:r?"clear":"load",storeOp:"store",view:b.instance.createView(),resolveTarget:n.createView()}]}),O=(e,n=t.getCurrentTexture(),r=1)=>{const o=e.beginRenderPass({colorAttachments:[{view:b.instance.createView(),resolveTarget:n.createView(),loadOp:"load",storeOp:"store"}],depthStencilAttachment:{view:C.instance.createView(),stencilLoadOp:"load",stencilStoreOp:"store"}});return o.setStencilReference(r),o},I=(t,n,r,o,s,c)=>{let u;if(t.graphics.some((e=>e.pattern))){u=M(e.width,e.height);const o=a.createCommandEncoder();let i=O(o,u,0);(0,l.forEachPatternGraphicRepeatedGraphic)(t,n,r,((e,t)=>{i=F(e,t,i,o,!0,s,u)})),i.end(),a.queue.submit([o.finish()])}let p=O(o);return u?A(g.instance,p,[{type:"mat3x3",value:i.m3.projection(1,1)},{type:"number",value:null!=s?s:1}],u,"masked"):(0,l.forEachPatternGraphicRepeatedGraphic)(t,n,r,((e,t)=>{p=F(e,t,p,o,!0,s,c)})),p.end(),L(o,c)},F=(t,n,r,s,c=!1,u,h)=>{var m,v,b;const P=(0,o.mergeOpacities)(t.opacity,u),O=(0,o.mergeOpacityToColor)(t.pattern?l.defaultVec4Color:t.color,P);t.pattern&&(r.end(),r=(e=>{const t=e.beginRenderPass({colorAttachments:[],depthStencilAttachment:{view:C.instance.createView(),stencilClearValue:0,stencilLoadOp:"clear",stencilStoreOp:"store"}});return t.setStencilReference(1),t})(s));const F=t.pattern?"mask":c?"masked":"normal";if("texture"===t.type){const{textureMatrix:o,width:c,height:u}=(0,l.getTextureGraphicMatrix)(n,t);let p,d=S.get(t.src,(()=>{const e=M(t.src.width,t.src.height),n=t.src instanceof ImageBitmap?t.src:t.canvas;return n&&a.queue.copyExternalImageToTexture({source:n},{texture:e},{width:t.src.width,height:t.src.height}),e}));if(t.filters&&t.filters.length>1){const n=[];for(let r=0;r0){const e=R(t.filters[t.filters.length-1]);p=e.shaderModule,x.push({type:"number",value:null!=(v=t.opacity)?v:1},e.input)}else t.pattern?(p=y.instance,x.push({type:"vec4",value:null!=O?O:l.defaultVec4Color})):t.color?(p=f.instance,x.push({type:"vec4",value:null!=O?O:l.defaultVec4Color})):(p=g.instance,x.push({type:"number",value:null!=(b=t.opacity)?b:1}));A(p,r,x,d,F),t.pattern&&(r.end(),r=I(t.pattern,n,{xMin:t.x,yMin:t.y,xMax:t.x+c,yMax:t.y+u},s,P,h))}else{const e=t.colors?x.instance:d.instance,o=w.get(e,t.type,F,(()=>{const n=t.colors?{attributes:[{shaderLocation:0,offset:0,format:"float32x2"},{shaderLocation:1,offset:8,format:"float32x4"}],arrayStride:24,stepMode:"vertex"}:{attributes:[{shaderLocation:0,offset:0,format:"float32x2"}],arrayStride:8,stepMode:"vertex"};return _(e,F,t.type,n)}));if(T(r,o,[{buffer:p(a,[{type:"vec4",value:O||l.defaultVec4Color},{type:"mat3x3",value:n}])}]),t.colors){const e=t.colors;r.setVertexBuffer(0,k.get(t.points,e,(()=>{const n=function(e){const t=[],n=Math.min(...e.map((e=>e.data.length/e.num)));for(let r=0;r{const e=new Float32Array(t.points),n=a.createBuffer({size:e.byteLength,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});return a.queue.writeBuffer(n,0,e,0,e.length),n})));if(r.draw(t.points.length/2),t.pattern){r.end();const e=(0,l.getNumArrayPointsBounding)(t.points);r=I(t.pattern,n,e,s,P,h)}}return r};return(t,n,r,o,s,c)=>{!b.instanced||e.width===b.instance.width&&e.height===b.instance.height||b.reset(),!C.instanced||e.width===C.instance.width&&e.height===C.instance.height||C.reset();const u=(0,l.getWorldMatrix)(e,r,o,s,c),p=a.createCommandEncoder();let d=L(p,void 0,n);for(const e of t){const t=e.matrix?i.m3.multiply(u,e.matrix):u;d=F(e,t,d,p)}d.end(),a.queue.submit([p.finish()])}}))}function p(e,t){const n=(0,a.createMemoryLayoutArray)(...t),r=e.createBuffer({size:n.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});return e.queue.writeBuffer(r,0,n),r}},1948:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getImageFromCache:()=>o});const r=new Map;function o(e,t){var n;const o=r.get(e);return o?Array.isArray(o)?void o.push((()=>{var e;null==(e=null==t?void 0:t.rerender)||e.call(t)})):(null==(n=null==t?void 0:t.callback)||n.call(t,o),o):(r.set(e,[]),void function(e,t){return new Promise(((n,r)=>{const o=new Image;void 0!==t&&(o.crossOrigin=t),o.onload=()=>{n(o)},o.onerror=()=>{r()},o.src=e}))}(e,null==t?void 0:t.crossOrigin).then((n=>{createImageBitmap(n).then((n=>{var o,i;const a=r.get(e);r.set(e,n),Array.isArray(a)&&a.forEach((e=>{e()})),null==(o=null==t?void 0:t.callback)||o.call(t,n),null==(i=null==t?void 0:t.rerender)||i.call(t)}))})))}},7731:(e,t,n)=>{"use strict";n.r(t);var r=n(5136),o={};for(const e in r)"default"!==e&&(o[e]=()=>r[e]);n.d(t,o);var i=n(5319);o={};for(const e in i)"default"!==e&&(o[e]=()=>i[e]);n.d(t,o);var a=n(194);o={};for(const e in a)"default"!==e&&(o[e]=()=>a[e]);n.d(t,o);var s=n(9625);o={};for(const e in s)"default"!==e&&(o[e]=()=>s[e]);n.d(t,o);var l=n(7043);o={};for(const e in l)"default"!==e&&(o[e]=()=>l[e]);n.d(t,o);var c=n(6299);o={};for(const e in c)"default"!==e&&(o[e]=()=>c[e]);n.d(t,o);var u=n(8485);o={};for(const e in u)"default"!==e&&(o[e]=()=>u[e]);n.d(t,o);var p=n(9417);o={};for(const e in p)"default"!==e&&(o[e]=()=>p[e]);n.d(t,o);var d=n(1948);o={};for(const e in d)"default"!==e&&(o[e]=()=>d[e]);n.d(t,o);var f=n(8797);o={};for(const e in f)"default"!==e&&(o[e]=()=>f[e]);n.d(t,o)},194:(e,t,n)=>{"use strict";n.r(t),n.d(t,{reactCanvasRenderTarget:()=>b});var r=n(7378),o=n(6581),i=n(8485),a=n(1948),s=n(5136),l=n(7504),c=n(3516),u=n(5395),p=Object.defineProperty,d=Object.defineProperties,f=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,h=Object.prototype.hasOwnProperty,m=Object.prototype.propertyIsEnumerable,y=(e,t,n)=>t in e?p(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x=(e,t)=>{for(var n in t||(t={}))h.call(t,n)&&y(e,n,t[n]);if(g)for(var n of g(t))m.call(t,n)&&y(e,n,t[n]);return e},v=(e,t)=>d(e,f(t));const b={type:"canvas",renderResult:(e,t,n,o)=>r.createElement(S,{width:t,height:n,attributes:null==o?void 0:o.attributes,draws:e,transform:null==o?void 0:o.transform,backgroundColor:null==o?void 0:o.backgroundColor,debug:null==o?void 0:o.debug,strokeWidthScale:null==o?void 0:o.strokeWidthScale}),renderEmpty:()=>()=>{},renderGroup:(e,t)=>(n,r,i)=>{const a=n.globalAlpha;n.save(),void 0!==(null==t?void 0:t.opacity)&&(n.globalAlpha=a*t.opacity),(null==t?void 0:t.translate)&&n.translate(t.translate.x,t.translate.y),(null==t?void 0:t.angle)&&void 0!==(null==t?void 0:t.base)&&(n.translate(t.base.x,null==t?void 0:t.base.y),n.rotate((0,c.angleToRadian)(t.angle)),n.translate(-t.base.x,-t.base.y)),(null==t?void 0:t.rotation)&&void 0!==(null==t?void 0:t.base)&&(n.translate(t.base.x,null==t?void 0:t.base.y),n.rotate(t.rotation),n.translate(-t.base.x,-t.base.y)),(null==t?void 0:t.matrix)&&n.setTransform(n.getTransform().multiply(o.m3.getTransformInit(t.matrix))),e.forEach((e=>{e(n,r,i)})),n.restore()},renderRect:(e,t,n,r,o)=>(a,s,u)=>{var p,d;a.save(),a.beginPath(),(0,i.setCanvasLineDash)(a,o),(null==o?void 0:o.angle)&&(a.translate(e+n/2,t+r/2),a.rotate((0,c.angleToRadian)(o.angle)),a.translate(-(e+n/2),-(t+r/2))),(null==o?void 0:o.rotation)&&(a.translate(e+n/2,t+r/2),a.rotate(o.rotation),a.translate(-(e+n/2),-(t+r/2))),a.rect(e,t,n,r);const f=(null!=(p=null==o?void 0:o.strokeWidth)?p:1)*s;f&&(a.lineWidth=f,a.strokeStyle=(0,l.getColorString)(null!=(d=null==o?void 0:o.strokeColor)?d:0),a.strokeRect(e,t,n,r)),C(a,s,u,o),k(a,s,u,o),a.restore()},renderPolyline(e,t){const n=null!=t?t:{},{partsStyles:r}=n,o=((e,t)=>{var n={};for(var r in e)h.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&g)for(var r of g(e))t.indexOf(r)<0&&m.call(e,r)&&(n[r]=e[r]);return n})(n,["partsStyles"]);return r&&r.length>0?(0,s.renderPartStyledPolyline)(this,r,e,o):(n,r,o)=>{var a;n.save(),n.beginPath(),(0,i.setCanvasLineDash)(n,t);for(let r=0;r(o,a,s)=>{o.save(),o.beginPath(),(0,i.setCanvasLineDash)(o,r),o.arc(e,t,n,0,2*Math.PI),C(o,a,s,r),k(o,a,s,r),o.restore()},renderEllipse:(e,t,n,r,o)=>(a,s,l)=>{var u;a.save(),a.beginPath(),(0,i.setCanvasLineDash)(a,o);const p=null!=(u=null==o?void 0:o.rotation)?u:(0,c.angleToRadian)(null==o?void 0:o.angle);a.ellipse(e,t,n,r,p,0,2*Math.PI),C(a,s,l,o),k(a,s,l,o),a.restore()},renderArc:(e,t,n,r,o,a)=>(s,l,u)=>{s.save(),s.beginPath(),(0,i.setCanvasLineDash)(s,a),s.arc(e,t,n,(0,c.angleToRadian)(r),(0,c.angleToRadian)(o),null==a?void 0:a.counterclockwise),C(s,l,u,a),k(s,l,u,a),s.restore()},renderEllipseArc:(e,t,n,r,o,a,s)=>(l,u,p)=>{var d;l.save(),l.beginPath(),(0,i.setCanvasLineDash)(l,s);const f=null!=(d=null==s?void 0:s.rotation)?d:(0,c.angleToRadian)(null==s?void 0:s.angle);l.ellipse(e,t,n,r,f,(0,c.angleToRadian)(o),(0,c.angleToRadian)(a),null==s?void 0:s.counterclockwise),C(l,u,p,s),k(l,u,p,s),l.restore()},renderPathCommands:(e,t)=>(n,r,o)=>{let a;n.save(),n.beginPath(),(0,i.setCanvasLineDash)(n,t);for(const t of e){if("move"===t.type)n.moveTo(t.to.x,t.to.y);else if("line"===t.type)n.lineTo(t.to.x,t.to.y);else if("arc"===t.type)n.arcTo(t.from.x,t.from.y,t.to.x,t.to.y,t.radius);else if("ellipseArc"===t.type){if(a){const e=(0,s.getEllipseArcByStartEnd)(a,t.rx,t.ry,t.angle,t.largeArc,t.sweep,t.to);e&&n.ellipse(e.cx,e.cy,e.rx,e.ry,(0,c.angleToRadian)(e.angle),(0,c.angleToRadian)(e.startAngle),(0,c.angleToRadian)(e.endAngle),e.counterclockwise)}}else"bezierCurve"===t.type?n.bezierCurveTo(t.cp1.x,t.cp1.y,t.cp2.x,t.cp2.y,t.to.x,t.to.y):"quadraticCurve"===t.type?n.quadraticCurveTo(t.cp.x,t.cp.y,t.to.x,t.to.y):"close"===t.type&&n.closePath();"close"!==t.type&&(a=t.to)}(null==t?void 0:t.closed)&&n.closePath(),C(n,r,o,t),k(n,r,o,t),n.restore()},renderText:(e,t,n,r,o,a,s)=>(c,u,p)=>{var d,f,g,h;c.save(),c.font=`${null!=(d=null==s?void 0:s.fontWeight)?d:"normal"} ${null!=(f=null==s?void 0:s.fontStyle)?f:"normal"} ${o}px ${a}`,c.textAlign=null!=(g=null==s?void 0:s.textAlign)?g:"left",c.textBaseline=null!=(h=null==s?void 0:s.textBaseline)?h:"alphabetic",k(c,u,p,v(x({},s),{fillColor:"number"==typeof r?r:void 0,fillPattern:void 0!==r&&"number"!=typeof r?r:void 0}),(()=>c.fillText(n,e,t))),(void 0!==(null==s?void 0:s.strokeColor)||(null==s?void 0:s.strokePattern)||(null==s?void 0:s.strokeLinearGradient)||(null==s?void 0:s.strokeRadialGradient))&&(void 0!==(null==s?void 0:s.strokeColor)?c.strokeStyle=(0,l.getColorString)(s.strokeColor,s.strokeOpacity):w(c,u,p,s),void 0!==s.strokeWidth&&(c.lineWidth=s.strokeWidth),(0,i.setCanvasLineDash)(c,s),c.strokeText(n,e,t)),c.restore()},renderImage:(e,t,n,r,o,i)=>(s,l,c)=>{const u=(0,a.getImageFromCache)(e,{rerender:c,crossOrigin:null==i?void 0:i.crossOrigin});if(u){const e=s.globalAlpha;s.save(),void 0!==(null==i?void 0:i.opacity)&&(s.globalAlpha=e*i.opacity),function(e,t){if(t&&t.length>0){const n=[];t.forEach((e=>{"hue-rotate"===e.type?n.push(`hue-rotate(${e.value}deg)`):"blur"===e.type?n.push(`blur(${e.value}px)`):"brightness"!==e.type&&"contrast"!==e.type&&"saturate"!==e.type&&"grayscale"!==e.type&&"invert"!==e.type&&"opacity"!==e.type&&"sepia"!==e.type||n.push(`${e.type}(${e.value})`)})),e.filter=n.join(" ")}}(s,null==i?void 0:i.filters),s.drawImage(u,t,n,r,o),s.restore()}},renderPath:(e,t)=>(n,r,o)=>{n.save(),n.beginPath(),(0,i.setCanvasLineDash)(n,t);for(const t of e)for(let e=0;e{i.addColorStop(e.offset,(0,l.getColorString)(e.color,e.opacity))})),e.fillStyle=i}else if(void 0!==r.fillRadialGradient){const{start:t,end:n,stops:o}=r.fillRadialGradient,i=e.createRadialGradient(t.x,t.y,t.r,n.x,n.y,n.r);o.forEach((e=>{i.addColorStop(e.offset,(0,l.getColorString)(e.color,e.opacity))})),e.fillStyle=i}o?o():e.fill("evenodd")}}function w(e,t,n,r){if(null==r?void 0:r.strokePattern){const o=E(e,r.strokePattern,t,n);o&&(e.strokeStyle=o)}else if(void 0!==(null==r?void 0:r.strokeLinearGradient)){const{start:t,end:n,stops:o}=r.strokeLinearGradient,i=e.createLinearGradient(t.x,t.y,n.x,n.y);o.forEach((e=>{i.addColorStop(e.offset,(0,l.getColorString)(e.color,e.opacity))})),e.strokeStyle=i}else if(void 0!==(null==r?void 0:r.strokeRadialGradient)){const{start:t,end:n,stops:o}=r.strokeRadialGradient,i=e.createRadialGradient(t.x,t.y,t.r,n.x,n.y,n.r);o.forEach((e=>{i.addColorStop(e.offset,(0,l.getColorString)(e.color,e.opacity))})),e.strokeStyle=i}}function S(e){const t=r.useRef(null),[n,o]=r.useState(0);return r.useEffect((()=>{t.current&&(t.current.width=e.width,t.current.height=e.height)}),[e.width,e.height]),r.useEffect((()=>{var n;if(t.current){const r=t.current.getContext("2d");if(r){const t=Date.now();r.fillStyle=(0,l.getColorString)(null!=(n=e.backgroundColor)?n:16777215),r.fillRect(0,0,r.canvas.width,r.canvas.height),r.save(),e.transform&&(r.translate(e.width/2,e.height/2),r.scale(e.transform.scale,e.transform.scale),r.translate(e.transform.x/e.transform.scale-e.width/2,e.transform.y/e.transform.scale-e.height/2),e.transform.rotate&&r.rotate(e.transform.rotate));const i=e.strokeWidthScale||1,a=()=>o((e=>e+1));for(const t of e.draws)t(r,i,a);r.restore(),e.debug&&console.info(Date.now()-t)}}}),[e.draws,t.current,e.transform,e.backgroundColor,n]),r.createElement("canvas",x({ref:t,width:e.width,height:e.height},e.attributes))}},5136:(e,t,n)=>{"use strict";n.r(t),n.d(t,{geometryLineToPathCommands:()=>w,getArcControlPoint:()=>S,getEllipseArcByStartEnd:()=>_,getGeometryLinesPoints:()=>E,getPathCommandEndPoint:()=>R,getPathCommandsPoints:()=>C,getRoundedRectPoints:()=>b,pathCommandPointsToPath:()=>P,pathCommandsToGeometryLines:()=>k,renderPartStyledPolyline:()=>v});var r=n(9195),o=n(3516),i=n(9605),a=n(6003),s=n(6632),l=n(5791),c=n(4275),u=Object.defineProperty,p=Object.defineProperties,d=Object.getOwnPropertyDescriptors,f=Object.getOwnPropertySymbols,g=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable,m=(e,t,n)=>t in e?u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y=(e,t)=>{for(var n in t||(t={}))g.call(t,n)&&m(e,n,t[n]);if(f)for(var n of f(t))h.call(t,n)&&m(e,n,t[n]);return e},x=(e,t)=>p(e,d(t));function v(e,t,n,r){return e.renderGroup([e.renderPolyline(n,x(y({},r),{skippedLines:t.map((e=>e.index))})),...t.map((({index:t,color:o,opacity:i})=>e.renderPolyline([n[t],n[t+1]],x(y({},r),{strokeColor:o,strokeOpacity:i}))))])}function b(e,t,n){return[...(0,r.arcToPolyline)({x:e.x+e.width/2-t,y:e.y-e.height/2+t,r:t,startAngle:-90,endAngle:0},n),...(0,r.arcToPolyline)({x:e.x+e.width/2-t,y:e.y+e.height/2-t,r:t,startAngle:0,endAngle:90},n),...(0,r.arcToPolyline)({x:e.x-e.width/2+t,y:e.y+e.height/2-t,r:t,startAngle:90,endAngle:180},n),...(0,r.arcToPolyline)({x:e.x-e.width/2+t,y:e.y-e.height/2+t,r:t,startAngle:180,endAngle:270},n)]}function C(e){const t=[],n=k(e);for(const e of n)t.push(E(e));return t}function E(e,t=100,n=5){const o=[];for(const i of e)Array.isArray(i)?(0===o.length&&o.push(i[0]),o.push(i[1])):"arc"===i.type?o.push(...(0,r.arcToPolyline)(i.curve,n)):"ellipse arc"===i.type?o.push(...(0,r.ellipseArcToPolyline)(i.curve,n)):"quadratic curve"===i.type?o.push(...(0,s.getQuadraticCurvePoints)(i.curve.from,i.curve.cp,i.curve.to,t)):"bezier curve"===i.type&&o.push(...(0,s.getBezierCurvePoints)(i.curve.from,i.curve.cp1,i.curve.cp2,i.curve.to,t));return o}function k(e){const t=[];let n,s,l=[];for(const c of e)if("move"===c.type)l.length>0&&(l.length>1&&t.push(l),l=[],n=void 0),s=c.to,n||(n=c.to);else if("line"===c.type)s&&l.push([s,c.to]),s=c.to;else if("arc"===c.type){if(s){const e=c.from,t=c.to,n=(0,r.twoPointLineToGeneralFormLine)(s,e),u=(0,r.twoPointLineToGeneralFormLine)(e,t),p=(0,r.getPointSideOfLine)(t,n);if((0,r.isZero)(p))s&&(l.push([s,t]),s=t);else{const e=p<0?0:1,t=(0,i.getTwoGeneralFormLinesIntersectionPoint)((0,r.getParallelLinesByDistance)(n,c.radius)[e],(0,r.getParallelLinesByDistance)(u,c.radius)[e]);if(t){const e=(0,a.getPerpendicularPoint)(t,n),i=(0,a.getPerpendicularPoint)(t,u);s&&(l.push([s,{x:e.x,y:e.y}]),s=i);const d=(0,o.radianToAngle)((0,r.getTwoPointsRadian)(e,t)),f=(0,o.radianToAngle)((0,r.getTwoPointsRadian)(i,t));l.push({type:"arc",curve:{x:t.x,y:t.y,startAngle:d,endAngle:f,r:c.radius,counterclockwise:p>0}})}}}}else if("ellipseArc"===c.type){if(s){const e=_(s,c.rx,c.ry,c.angle,c.largeArc,c.sweep,c.to);e&&l.push({type:"ellipse arc",curve:e})}s=c.to}else"bezierCurve"===c.type?(s&&l.push({type:"bezier curve",curve:{from:s,cp1:c.cp1,cp2:c.cp2,to:c.to}}),s=c.to):"quadraticCurve"===c.type?(s&&l.push({type:"quadratic curve",curve:{from:s,cp:c.cp,to:c.to}}),s=c.to):"close"===c.type&&l.length>0&&(l.length>1&&(n&&s&&!(0,r.isSamePoint)(n,s)&&l.push([s,n]),t.push(l)),l=[],n=void 0);return l.length>0&&t.push(l),t}function w(e){const t=[];let n;for(const o of e){const{start:e,end:i}=(0,l.getGeometryLineStartAndEnd)(o);if(n&&(0,r.isSamePoint)(n,e)||t.push({type:"move",to:e}),Array.isArray(o))t.push({type:"line",to:i});else if("arc"===o.type){const e=S(o.curve);e&&t.push({type:"arc",from:e,to:i,radius:o.curve.r})}else if("ellipse arc"===o.type){const e=(0,r.getFormattedEndAngle)(o.curve),n=Math.abs(e-o.curve.startAngle)>180;t.push({type:"ellipseArc",to:i,rx:o.curve.rx,ry:o.curve.ry,angle:o.curve.angle||0,sweep:!o.curve.counterclockwise,largeArc:n})}else"quadratic curve"===o.type?t.push({type:"quadraticCurve",cp:o.curve.cp,to:o.curve.to}):"bezier curve"===o.type&&t.push({type:"bezierCurve",cp1:o.curve.cp1,cp2:o.curve.cp2,to:o.curve.to});n=i}return t}function S(e){const t=(0,r.getCirclePointAtRadian)(e,(0,o.angleToRadian)(e.startAngle)),n=(0,r.getCirclePointAtRadian)(e,(0,o.angleToRadian)(e.endAngle)),s=(0,a.getPerpendicular)(t,(0,r.twoPointLineToGeneralFormLine)(e,t)),l=(0,a.getPerpendicular)(n,(0,r.twoPointLineToGeneralFormLine)(e,n));return(0,i.getTwoGeneralFormLinesIntersectionPoint)(s,l)}function P(e){const t=[];let n;for(const o of e)n?(0,r.pointInPolygon)(o[0],n.polygon)?n.holes.push(o):(n&&t.push([n.polygon,...n.holes]),n={polygon:o,holes:[]}):n={polygon:o,holes:[]};return n&&t.push([n.polygon,...n.holes]),t}function R(e,t){if(t>=0){const n=e[t];if("close"!==n.type){if("arc"!==n.type)return n.to;const o=R(e,t-1);if(o){const e=n.from,t=n.to,s=(0,r.twoPointLineToGeneralFormLine)(o,e),l=(0,r.twoPointLineToGeneralFormLine)(e,t),c=(0,r.getPointSideOfLine)(t,s);if((0,r.isZero)(c))return n.to;const u=c<0?0:1,p=(0,i.getTwoGeneralFormLinesIntersectionPoint)((0,r.getParallelLinesByDistance)(s,n.radius)[u],(0,r.getParallelLinesByDistance)(l,n.radius)[u]);if(p){const e=(0,a.getPerpendicularPoint)(p,l),t=(0,r.getTwoPointsRadian)(e,p);return{x:p.x+n.radius*Math.cos(t),y:p.y+n.radius*Math.sin(t)}}}}}}function _(e,t,n,i,a,s,l){const u=(0,o.angleToRadian)(i),p=Math.sin(u),d=Math.cos(u),f=1/t/t,g=1/n/n,h=e.x,m=e.y,v=l.x,b=l.y,C=v-h,E=b-m,k=d*d*f+p*p*g,w=p*p*f+d*d*g,S=f-g,P=2*(S*p*d*C+w*E),R=2*(k*C+S*p*d*E)/P,_=(k*C*C+2*p*d*S*C*E+w*E*E)/P,T=(0,c.calculateEquation2)(k-2*p*d*S*R+w*R*R,-2*p*d*S*_+2*w*R*_,w*_*_-1);if(0===T.length)return;const A=T.map((e=>({x:h-e,y:m+R*e+_})));let M;M=1===A.length?0:(0,r.getPointSideOfLine)(A[0],(0,r.twoPointLineToGeneralFormLine)(e,l))>0?a===s?0:1:a!==s?0:1;const L=A[M],O={cx:L.x,cy:L.y,rx:t,ry:n,angle:i};return x(y({},O),{startAngle:(0,r.getEllipseAngle)(e,O),endAngle:(0,r.getEllipseAngle)(l,O),counterclockwise:!s})}},5319:(e,t,n)=>{"use strict";n.r(t),n.d(t,{ellipsePolarToCartesian:()=>T,getRotateTransform:()=>A,polarToCartesian:()=>_,reactSvgRenderTarget:()=>E});var r=n(7378),o=n(7504),i=n(9195),a=n(6581),s=n(5547),l=n(5136),c=n(3516),u=n(9605),p=n(6003),d=n(5395),f=Object.defineProperty,g=Object.defineProperties,h=Object.getOwnPropertyDescriptors,m=Object.getOwnPropertySymbols,y=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable,v=(e,t,n)=>t in e?f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t)=>{for(var n in t||(t={}))y.call(t,n)&&v(e,n,t[n]);if(m)for(var n of m(t))x.call(t,n)&&v(e,n,t[n]);return e},C=(e,t)=>g(e,h(t));const E={type:"svg",renderResult(e,t,n,i){var a,s,l,c,u,p,d,f,g;const h=null!=(s=null==(a=null==i?void 0:i.transform)?void 0:a.x)?s:0,m=null!=(c=null==(l=null==i?void 0:i.transform)?void 0:l.y)?c:0,y=null!=(p=null==(u=null==i?void 0:i.transform)?void 0:u.scale)?p:1,x=t/y,v=n/y,E=(t-x)/2-h/y,k=(n-v)/2-m/y,w=(null==i?void 0:i.strokeWidthScale)||1,S=null!=(f=null==(d=null==i?void 0:i.transform)?void 0:d.rotate)?f:0;return r.createElement("svg",C(b({version:"1.1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:`${E} ${k} ${x} ${v}`,width:t,height:n,colorInterpolationFilters:"sRGB"},null==i?void 0:i.attributes),{style:C(b({},null==(g=null==i?void 0:i.attributes)?void 0:g.style),{backgroundColor:void 0!==(null==i?void 0:i.backgroundColor)?(0,o.getColorString)(i.backgroundColor):void 0})}),r.createElement("g",{style:{rotate:`${S}rad`}},e.map(((e,t)=>e(t,y,w)))))},renderEmpty:()=>()=>r.createElement(r.Fragment,null),renderGroup(e,t){const n=[];if((null==t?void 0:t.translate)&&n.push(`translate(${t.translate.x}, ${t.translate.y})`),null==t?void 0:t.base){const e=A(t.base.x,t.base.y,t);e&&n.push(e)}return(null==t?void 0:t.matrix)&&n.push(`matrix(${a.m3.getTransform(t.matrix).join(" ")})`),(o,i,a)=>r.createElement("g",{transform:n.join(" "),key:o,opacity:null==t?void 0:t.opacity},e.map(((e,t)=>e(t,i,a))))},renderRect:(e,t,n,o,i)=>k(((a,s,l,c)=>r.createElement("rect",C(b({x:e,y:t,width:n,height:o},P(l,c,i)),{fill:a,stroke:s,transform:A(e+n/2,t+o/2,i)}))),i),renderPolyline(e,t){const n=null!=t?t:{},{partsStyles:o}=n,i=((e,t)=>{var n={};for(var r in e)y.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&m)for(var r of m(e))t.indexOf(r)<0&&x.call(e,r)&&(n[r]=e[r]);return n})(n,["partsStyles"]);if(o&&o.length>0)return(0,l.renderPartStyledPolyline)(this,o,e,i);const a=null==t?void 0:t.skippedLines;if(a&&a.length>0){const n=e.map(((e,t)=>0===t||a.includes(t-1)?`M ${e.x} ${e.y}`:`L ${e.x} ${e.y}`)).join(" ");return k(((e,o,i,a)=>r.createElement("path",C(b({d:n},P(i,a,t)),{fill:e,stroke:o}))),t)}const s=e.map((e=>`${e.x},${e.y}`)).join(" ");return k(((e,n,o,i)=>r.createElement((null==t?void 0:t.closed)?"polygon":"polyline",C(b({points:s},P(o,i,t)),{fill:e,stroke:n}))),t)},renderPolygon(e,t){return this.renderPolyline(e,C(b({},t),{closed:!0}))},renderCircle:(e,t,n,o)=>k(((i,a,s,l)=>r.createElement("circle",C(b({cx:e,cy:t,r:n},P(s,l,o)),{fill:i,stroke:a}))),o),renderEllipse:(e,t,n,o,i)=>k(((a,s,l,c)=>r.createElement("ellipse",C(b({cx:e,cy:t,rx:n,ry:o},P(l,c,i)),{fill:a,stroke:s,transform:A(e,t,i)}))),i),renderArc(e,t,n,o,i,a){const s=_(e,t,n,i),l=_(e,t,n,o),c=i-o<=180,u=((null==a?void 0:a.counterclockwise)?!c:c)?"0":"1",p=(null==a?void 0:a.counterclockwise)?"1":"0";return k(((e,t,o,i)=>r.createElement("path",C(b({d:`M ${s.x} ${s.y} A ${n} ${n} 0 ${u} ${p} ${l.x} ${l.y}`},P(o,i,a)),{fill:e,stroke:t}))),a)},renderEllipseArc(e,t,n,o,i,a,s){const l=T(e,t,n,o,a),c=T(e,t,n,o,i),u=a-i<=180,p=((null==s?void 0:s.counterclockwise)?!u:u)?"0":"1",d=(null==s?void 0:s.counterclockwise)?"1":"0";return k(((i,a,u,f)=>r.createElement("path",C(b({d:`M ${l.x} ${l.y} A ${n} ${o} 0 ${p} ${d} ${c.x} ${c.y}`},P(u,f,s)),{fill:i,stroke:a,transform:A(e,t,s)}))),s)},renderPathCommands(e,t){let n,o="";for(const t of e)if("move"===t.type)o+=` M ${t.to.x} ${t.to.y}`,n=t.to;else if("line"===t.type)o+=` L ${t.to.x} ${t.to.y}`,n=t.to;else if("arc"===t.type){if(n){const e=t.from,r=t.to,a=(0,i.twoPointLineToGeneralFormLine)(n,e),s=(0,i.twoPointLineToGeneralFormLine)(e,r),l=(0,i.getPointSideOfLine)(r,a);if((0,i.isZero)(l))o+=` L ${r.x} ${r.y}`,n=r;else{const e=l<0?0:1,r=(0,u.getTwoGeneralFormLinesIntersectionPoint)((0,i.getParallelLinesByDistance)(a,t.radius)[e],(0,i.getParallelLinesByDistance)(s,t.radius)[e]);if(r){const e=(0,p.getPerpendicularPoint)(r,a),i=(0,p.getPerpendicularPoint)(r,s);o+=` L ${e.x} ${e.y} A ${t.radius} ${t.radius} 0 0 ${l<0?1:0} ${i.x} ${i.y}`,n=i}}}}else"ellipseArc"===t.type?(o+=` A ${t.rx} ${t.ry} ${t.angle} ${t.largeArc?1:0} ${t.sweep?1:0} ${t.to.x} ${t.to.y}`,n=t.to):"bezierCurve"===t.type?(o+=` C ${t.cp1.x} ${t.cp1.y}, ${t.cp2.x} ${t.cp2.y}, ${t.to.x} ${t.to.y}`,n=t.to):"quadraticCurve"===t.type?(o+=` Q ${t.cp.x} ${t.cp.y}, ${t.to.x} ${t.to.y}`,n=t.to):"close"===t.type&&(o+=" Z");return k(((e,n,i,a)=>r.createElement("path",C(b({d:o},P(i,a,t)),{fill:e,stroke:n}))),t)},renderText:(e,t,n,o,i,a,s)=>k(((o,l,c,u)=>{var p;return r.createElement("text",{x:e,y:t,textAnchor:"center"===(null==s?void 0:s.textAlign)?"middle":"right"===(null==s?void 0:s.textAlign)?"end":"start",alignmentBaseline:"top"===(null==s?void 0:s.textBaseline)?"before-edge":"bottom"===(null==s?void 0:s.textBaseline)?"after-edge":null!=(p=null==s?void 0:s.textBaseline)?p:"alphabetic",style:{fill:o,fontWeight:null==s?void 0:s.fontWeight,fontSize:`${i}px`,fontStyle:null==s?void 0:s.fontStyle,fontFamily:a,strokeWidth:null==s?void 0:s.strokeWidth,stroke:l,strokeDasharray:R(c,u,s),strokeDashoffset:null==s?void 0:s.dashOffset,fillOpacity:null==s?void 0:s.fillOpacity,strokeOpacity:null==s?void 0:s.strokeOpacity}},n)}),C(b({},s),{fillColor:"number"==typeof o?o:void 0,fillPattern:void 0!==o&&"number"!=typeof o?o:void 0}),!0),renderImage(e,t,n,o,i,a){return s=s=>r.createElement("image",{filter:s,href:e,x:t,y:n,width:o,height:i,preserveAspectRatio:"none",crossOrigin:null==a?void 0:a.crossOrigin,opacity:null==a?void 0:a.opacity}),l=null==a?void 0:a.filters,e=>{let t,n;if(l&&l.length>0){const e=S(l),o=[];l.forEach(((e,t)=>{if("brightness"===e.type)o.push(r.createElement("feComponentTransfer",{key:t},r.createElement("feFuncR",{type:"linear",slope:e.value}),r.createElement("feFuncG",{type:"linear",slope:e.value}),r.createElement("feFuncB",{type:"linear",slope:e.value})));else if("contrast"===e.type){const n=.5*(1-e.value);o.push(r.createElement("feComponentTransfer",{key:t},r.createElement("feFuncR",{type:"linear",slope:e.value,intercept:n}),r.createElement("feFuncG",{type:"linear",slope:e.value,intercept:n}),r.createElement("feFuncB",{type:"linear",slope:e.value,intercept:n})))}else if("hue-rotate"===e.type)o.push(r.createElement("feColorMatrix",{key:t,type:"hueRotate",values:e.value.toString()}));else if("saturate"===e.type)o.push(r.createElement("feColorMatrix",{key:t,type:"saturate",values:e.value.toString()}));else if("grayscale"===e.type){const n=1-e.value;o.push(r.createElement("feColorMatrix",{key:t,type:"matrix",values:`\n ${.2126+.7874*n} ${.7152-.7152*n} ${.0722-.0722*n} 0 0\n ${.2126-.2126*n} ${.7152+.2848*n} ${.0722-.0722*n} 0 0\n ${.2126-.2126*n} ${.7152-.7152*n} ${.0722+.9278*n} 0 0\n 0 0 0 1 0`}))}else if("invert"===e.type){const n=`${e.value} ${1-e.value}`;o.push(r.createElement("feComponentTransfer",{key:t},r.createElement("feFuncR",{type:"table",tableValues:n}),r.createElement("feFuncG",{type:"table",tableValues:n}),r.createElement("feFuncB",{type:"table",tableValues:n})))}else if("sepia"===e.type){const n=1-e.value;o.push(r.createElement("feColorMatrix",{key:t,type:"matrix",values:`\n ${.393+.607*n} ${.769-.769*n} ${.189-.189*n} 0 0\n ${.349-.349*n} ${.686+.314*n} ${.168-.168*n} 0 0\n ${.272-.272*n} ${.534-.534*n} ${.131+.869*n} 0 0\n 0 0 0 1 0`}))}else"opacity"===e.type?o.push(r.createElement("feComponentTransfer",{key:t},r.createElement("feFuncA",{type:"table",tableValues:`0 ${e.value}`}))):"blur"===e.type&&o.push(r.createElement("feGaussianBlur",{key:t,in:"SourceGraphic",stdDeviation:e.value}))})),t=r.createElement("filter",{id:e},o),n=`url(#${e})`}return r.createElement(r.Fragment,{key:e},t,s(n))};var s,l},renderPath(e,t){const n=e.map((e=>e.map(((e,t)=>0===t?`M ${e.x} ${e.y}`:`L ${e.x} ${e.y}`)).join(" "))),o=(null==t?void 0:t.clip)&&n.length>1,i=o?n.slice(1).map(((e,t)=>r.createElement("path",{key:t,d:e,fill:"black"}))):void 0;return k(((e,i,a,s)=>{let l;return o?l=n[0]:(l=n.join(" "),(null==t?void 0:t.closed)&&(l+=" Z")),r.createElement("path",C(b({d:l},P(a,s,t)),{fill:e,stroke:i,fillRule:"evenodd"}))}),t,void 0,i)}};function k(e,t,n,i){return(a,s,l)=>{let c,u,p,d=void 0!==(null==t?void 0:t.fillColor)?(0,o.getColorString)(t.fillColor):"none",f=void 0!==(null==t?void 0:t.strokeColor)?(0,o.getColorString)(t.strokeColor):n?void 0:(0,o.getColorString)(0);if(null==t?void 0:t.strokePattern){const e=S(t.strokePattern);u=r.createElement("pattern",{id:e,patternUnits:"userSpaceOnUse",width:t.strokePattern.width,height:t.strokePattern.height},t.strokePattern.pattern()(e,s,l)),f=`url(#${e})`}else if(null==t?void 0:t.strokeLinearGradient){const e=S(t.strokeLinearGradient);u=r.createElement("linearGradient",{id:e,gradientUnits:"userSpaceOnUse",x1:t.strokeLinearGradient.start.x,y1:t.strokeLinearGradient.start.y,x2:t.strokeLinearGradient.end.x,y2:t.strokeLinearGradient.end.y},t.strokeLinearGradient.stops.map((e=>r.createElement("stop",{key:e.offset,offset:e.offset,stopColor:(0,o.getColorString)(e.color,e.opacity)})))),f=`url(#${e})`}else if(null==t?void 0:t.strokeRadialGradient){const e=S(t.strokeRadialGradient);u=r.createElement("radialGradient",{id:e,gradientUnits:"userSpaceOnUse",fx:t.strokeRadialGradient.start.x,fy:t.strokeRadialGradient.start.y,fr:t.strokeRadialGradient.start.r,cx:t.strokeRadialGradient.end.x,cy:t.strokeRadialGradient.end.y,r:t.strokeRadialGradient.end.r},t.strokeRadialGradient.stops.map((e=>r.createElement("stop",{key:e.offset,offset:e.offset,stopColor:(0,o.getColorString)(e.color,e.opacity)})))),f=`url(#${e})`}if(null==t?void 0:t.fillPattern){const e=S(t.fillPattern);c=r.createElement("pattern",{id:e,patternUnits:"userSpaceOnUse",width:t.fillPattern.width,height:t.fillPattern.height},t.fillPattern.pattern()(e,s,l)),d=`url(#${e})`}else if(null==t?void 0:t.fillLinearGradient){const e=S(t.fillLinearGradient);c=r.createElement("linearGradient",{id:e,gradientUnits:"userSpaceOnUse",x1:t.fillLinearGradient.start.x,y1:t.fillLinearGradient.start.y,x2:t.fillLinearGradient.end.x,y2:t.fillLinearGradient.end.y},t.fillLinearGradient.stops.map((e=>r.createElement("stop",{key:e.offset,offset:e.offset,stopColor:(0,o.getColorString)(e.color,e.opacity)})))),d=`url(#${e})`}else if(null==t?void 0:t.fillRadialGradient){const e=S(t.fillRadialGradient);c=r.createElement("radialGradient",{id:e,gradientUnits:"userSpaceOnUse",fx:t.fillRadialGradient.start.x,fy:t.fillRadialGradient.start.y,fr:t.fillRadialGradient.start.r,cx:t.fillRadialGradient.end.x,cy:t.fillRadialGradient.end.y,r:t.fillRadialGradient.end.r},t.fillRadialGradient.stops.map((e=>r.createElement("stop",{key:e.offset,offset:e.offset,stopColor:(0,o.getColorString)(e.color,e.opacity)})))),d=`url(#${e})`}const g=e(d,f,s,l);if(null==t?void 0:t.clip){const n=S(t.clip),o=t.clip()(n,s,l);i?(c=r.createElement(r.Fragment,null,r.createElement("mask",{id:n},e("white",f,s,l),i),g),p=r.createElement("g",{mask:`url(#${n})`},o)):(c=r.createElement(r.Fragment,null,r.createElement("clipPath",{id:n},g),g),p=r.createElement("g",{clipPath:`url(#${n})`},o))}else p=g;return r.createElement(r.Fragment,{key:a},c,u,p)}}const w=new s.WeakmapCache;function S(e){return w.get(e,(()=>Math.random().toString()))}function P(e,t,n){var r,o,i,a;return{strokeWidth:null!=(r=null==n?void 0:n.strokeWidth)?r:1,vectorEffect:1===t?void 0:"non-scaling-stroke",strokeDasharray:R(e,t,n),strokeDashoffset:null==n?void 0:n.dashOffset,strokeMiterlimit:null!=(o=null==n?void 0:n.miterLimit)?o:d.defaultMiterLimit,strokeLinejoin:null!=(i=null==n?void 0:n.lineJoin)?i:"miter",strokeLinecap:null!=(a=null==n?void 0:n.lineCap)?a:"butt",fillOpacity:null==n?void 0:n.fillOpacity,strokeOpacity:null==n?void 0:n.strokeOpacity}}function R(e,t,n){if((null==n?void 0:n.dashArray)&&n.dashArray.length>0)return n.dashArray.map((n=>n*(1===t?1:e))).join(" ")}function _(e,t,n,r){return T(e,t,n,n,r)}function T(e,t,n,r,o){const i=(0,c.angleToRadian)(o);return{x:e+n*Math.cos(i),y:t+r*Math.sin(i)}}function A(e,t,n){return(null==n?void 0:n.angle)?`rotate(${n.angle},${e},${t})`:(null==n?void 0:n.rotation)?`rotate(${(0,c.radianToAngle)(n.rotation)},${e},${t})`:void 0}},9625:(e,t,n)=>{"use strict";n.r(t),n.d(t,{reactWebglRenderTarget:()=>v});var r=n(7378),o=n(9195),i=n(5136),a=n(8485),s=n(7504),l=n(3516),c=Object.defineProperty,u=Object.defineProperties,p=Object.getOwnPropertyDescriptors,d=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable,h=(e,t,n)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,m=(e,t)=>{for(var n in t||(t={}))f.call(t,n)&&h(e,n,t[n]);if(d)for(var n of d(t))g.call(t,n)&&h(e,n,t[n]);return e},y=(e,t)=>u(e,p(t)),x=(e,t)=>{var n={};for(var r in e)f.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&d)for(var r of d(e))t.indexOf(r)<0&&g.call(e,r)&&(n[r]=e[r]);return n};const v={type:"webgl",renderResult:(e,t,n,o)=>r.createElement(b,{width:t,height:n,attributes:null==o?void 0:o.attributes,graphics:e,transform:null==o?void 0:o.transform,backgroundColor:null==o?void 0:o.backgroundColor,debug:null==o?void 0:o.debug,strokeWidthScale:null==o?void 0:o.strokeWidthScale}),renderEmpty:()=>()=>[],renderGroup:(e,t)=>(n,r,o,i)=>(0,a.getGroupGraphics)(e.map((e=>e(n,r))).flat(),o,t,i),renderRect(e,t,n,r,i){let a=[{x:e,y:t},{x:e+n,y:t},{x:e+n,y:t+r},{x:e,y:t+r}],s=0;if((null==i?void 0:i.angle)?s=(0,l.angleToRadian)(i.angle):(null==i?void 0:i.rotation)&&(s=i.rotation),s){const i={x:e+n/2,y:t+r/2};a=a.map((e=>(0,o.rotatePosition)(e,i,s)))}return this.renderPolygon(a,i)},renderPolyline(e,t){const n=null!=t?t:{},{partsStyles:r}=n,a=x(n,["partsStyles"]);if(r&&r.length>0)return(0,i.renderPartStyledPolyline)(this,r,e,a);const s=null!=t?t:{},{dashArray:l,closed:c}=s,u=x(s,["dashArray","closed"]);c&&(e=(0,o.polygonToPolyline)(e));const p=(0,o.dashedPolylineToLines)(e,l,null==t?void 0:t.skippedLines,null==t?void 0:t.dashOffset);return this.renderPath(p,u)},renderPolygon(e,t){return this.renderPolyline(e,y(m({},t),{closed:!0}))},renderCircle(e,t,n,r){const i=(0,o.arcToPolyline)({x:e,y:t,r:n,startAngle:0,endAngle:360},5);return this.renderPolyline(i,r)},renderEllipse(e,t,n,r,i){let a=0;(null==i?void 0:i.angle)?a=i.angle:(null==i?void 0:i.rotation)&&(a=(0,l.radianToAngle)(i.rotation));const s=(0,o.ellipseToPolygon)({cx:e,cy:t,rx:n,ry:r,angle:a},5);return this.renderPolygon(s,i)},renderArc(e,t,n,r,i,a){const s=(0,o.arcToPolyline)({x:e,y:t,r:n,startAngle:r,endAngle:i,counterclockwise:null==a?void 0:a.counterclockwise},5);return this.renderPolyline(s,a)},renderEllipseArc(e,t,n,r,i,a,s){let c=0;(null==s?void 0:s.angle)?c=s.angle:(null==s?void 0:s.rotation)&&(c=(0,l.radianToAngle)(s.rotation));const u=(0,o.ellipseArcToPolyline)({cx:e,cy:t,rx:n,ry:r,startAngle:i,endAngle:a,angle:c,counterclockwise:null==s?void 0:s.counterclockwise},5);return this.renderPolyline(u,s)},renderPathCommands(e,t){const n=(0,i.getPathCommandsPoints)(e),r=(0,i.pathCommandPointsToPath)(n);return this.renderGroup(r.map((e=>this.renderPath(e,t))))},renderText:(e,t,n,r,o,i,s)=>(l,c)=>{let u,p;u=void 0!==r&&"number"!=typeof r?{graphics:r.pattern()(l,c),width:r.width,height:r.height}:r,void 0!==(null==s?void 0:s.strokePattern)&&(p={graphics:s.strokePattern.pattern()(l,c),width:s.strokePattern.width,height:s.strokePattern.height});const d=(0,a.getTextGraphic)(e,t,n,u,o,i,y(m({},s),{strokePattern:p}));return d?[d]:[]},renderImage:(e,t,n,r,o,i)=>(s,l)=>{const c=(0,a.getImageGraphic)(e,t,n,r,o,l,i);return c?[c]:[]},renderPath:(e,t)=>(n,r)=>{let o,i;return void 0!==(null==t?void 0:t.clip)&&(o={graphics:t.clip()(n,r)}),void 0!==(null==t?void 0:t.fillPattern)&&(o={graphics:t.fillPattern.pattern()(n,r),width:t.fillPattern.width,height:t.fillPattern.height}),void 0!==(null==t?void 0:t.strokePattern)&&(i={graphics:t.strokePattern.pattern()(n,r),width:t.strokePattern.width,height:t.strokePattern.height}),(0,a.getPathGraphics)(e,n,y(m({},t),{fillPattern:o,strokePattern:i}))}};function b(e){const t=r.useRef(null),[n,o]=r.useState(0),i=r.useRef();return r.useEffect((()=>{t.current&&(t.current.width=e.width,t.current.height=e.height)}),[e.width,e.height]),r.useEffect((()=>{if(!t.current)return;const n=(0,a.createWebglRenderer)(t.current);if(!n)return;const r=()=>o((e=>e+1));i.current=(t,o,i,a,s,l,c)=>{const u=performance.now();n(t.map((e=>e(l,r))).flat(),o,i,a,s,c),e.debug&&console.info(Math.round(performance.now()-u))}}),[t.current,e.debug]),r.useEffect((()=>{var t,n,r,o,a,l,c,u,p;if(i.current){const d=null!=(n=null==(t=e.transform)?void 0:t.x)?n:0,f=null!=(o=null==(r=e.transform)?void 0:r.y)?o:0,g=null!=(l=null==(a=e.transform)?void 0:a.scale)?l:1,h=(0,s.colorNumberToRec)(null!=(c=e.backgroundColor)?c:16777215),m=null!=(u=e.strokeWidthScale)?u:1;i.current(e.graphics,h,d,f,g,m,null==(p=e.transform)?void 0:p.rotate)}}),[e.graphics,e.backgroundColor,i.current,e.transform,n]),r.createElement("canvas",m({ref:t,width:e.width,height:e.height},e.attributes))}},7043:(e,t,n)=>{"use strict";n.r(t),n.d(t,{reactWebgpuRenderTarget:()=>h});var r=n(7378),o=n(7504),i=n(9417),a=n(9625),s=Object.defineProperty,l=Object.defineProperties,c=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))p.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))d.call(t,n)&&f(e,n,t[n]);return e};const h=l(g({},a.reactWebglRenderTarget),c({type:"webgpu",renderResult:(e,t,n,o)=>r.createElement(m,{width:t,height:n,attributes:null==o?void 0:o.attributes,graphics:e,transform:null==o?void 0:o.transform,backgroundColor:null==o?void 0:o.backgroundColor,debug:null==o?void 0:o.debug,strokeWidthScale:null==o?void 0:o.strokeWidthScale})}));function m(e){const t=r.useRef(null),[n,a]=r.useState(0),s=r.useRef();return r.useEffect((()=>{t.current&&(t.current.width=e.width,t.current.height=e.height)}),[e.width,e.height]),r.useEffect((()=>{t.current&&(0,i.createWebgpuRenderer)(t.current).then((t=>{if(!t)return;const n=()=>a((e=>e+1));s.current=(r,o,i,a,s,l,c)=>{const u=performance.now();t(r.map((e=>e(l,n))).flat(),o,i,a,s,c),e.debug&&console.info(Math.round(performance.now()-u))},n()}))}),[t.current,e.debug]),r.useEffect((()=>{var t,n,r,i,a,l,c,u,p;if(s.current){const d=null!=(n=null==(t=e.transform)?void 0:t.x)?n:0,f=null!=(i=null==(r=e.transform)?void 0:r.y)?i:0,g=null!=(l=null==(a=e.transform)?void 0:a.scale)?l:1,h=(0,o.colorNumberToRec)(null!=(c=e.backgroundColor)?c:16777215),m=null!=(u=e.strokeWidthScale)?u:1;s.current(e.graphics,h,d,f,g,m,null==(p=e.transform)?void 0:p.rotate)}}),[e.graphics,e.backgroundColor,s.current,e.transform,n]),r.createElement("canvas",g({ref:t,width:e.width,height:e.height},e.attributes))}},6299:(e,t,n)=>{"use strict";n.r(t),n.d(t,{reverseTransformPosition:()=>o,scaleByCursorPosition:()=>l,transformPosition:()=>i,zoomToFit:()=>a,zoomToFitPoints:()=>s});var r=n(9195);function o(e,t){return t?(e={x:(e.x-t.center.x-t.x)/t.scale+t.center.x,y:(e.y-t.center.y-t.y)/t.scale+t.center.y},t.rotate&&(e=(0,r.rotatePosition)(e,{x:0,y:0},-t.rotate)),e):e}function i(e,t){return t?(t.rotate&&(e=(0,r.rotatePosition)(e,{x:0,y:0},t.rotate)),{x:(e.x-t.center.x)*t.scale+t.center.x+t.x,y:(e.y-t.center.y)*t.scale+t.center.y+t.y}):e}function a(e,{width:t,height:n},o,i=.8){if(e&&!(0,r.equals)(e.start.x,e.end.x)&&!(0,r.equals)(e.start.y,e.end.y)){const a=Math.min(t/Math.abs(e.end.x-e.start.x),n/Math.abs(e.end.y-e.start.y))*i;return{scale:a,x:(o.x-(0,r.getTwoNumberCenter)(e.start.x,e.end.x))*a,y:(o.y-(0,r.getTwoNumberCenter)(e.start.y,e.end.y))*a}}}function s(e,{width:t,height:n},o,i=.8,a){const s=(0,r.getPointsBoundingUnsafe)(e);if(s&&!(0,r.equals)(s.start.x,s.end.x)&&!(0,r.equals)(s.start.y,s.end.y)){let l,c;if(a){const t=(0,r.getPointsBoundingUnsafe)(e.map((e=>(0,r.rotatePosition)(e,{x:0,y:0},a))));l=Math.abs(t.end.x-t.start.x),c=Math.abs(t.end.y-t.start.y)}else l=Math.abs(s.end.x-s.start.x),c=Math.abs(s.end.y-s.start.y);const u=Math.min(t/l,n/c)*i;let p=(0,r.getTwoPointCenter)(s.start,s.end);return a&&(p=(0,r.rotatePosition)(p,{x:0,y:0},a)),{scale:u,x:(o.x-p.x)*u,y:(o.y-p.y)*u}}}function l({width:e,height:t},n,r){return{setX:t=>r.x-e/2-(r.x-e/2-t)*n,setY:e=>r.y-t/2-(r.y-t/2-e)*n}}},2997:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Scrollbar:()=>p});var r=n(7378),o=n(6239),i=Object.defineProperty,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,c=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,u=(e,t)=>{for(var n in t||(t={}))s.call(t,n)&&c(e,n,t[n]);if(a)for(var n of a(t))l.call(t,n)&&c(e,n,t[n]);return e};function p(e){const{type:t,containerSize:n,contentSize:i}=e,{onStart:a,mask:s}=(0,o.useDragMove)(void 0,{transformOffset:({x:r,y:o})=>{const i=Math.max(Math.min("vertical"===t?o:r,n-l),0);return i!==d&&e.onChange((i-c)*p),{x:r,y:o}}});if(n>=i)return null;const l=Math.max(12,i?n*n/i:0),c=(n/2-l/2)*("head"===e.align?0:"tail"===e.align?2:1),p=-(i-n)/(n-l),d=e.value/p+c,f=u({position:"absolute",userSelect:"none"},e.style),g={background:"rgba(0, 0, 0, 0.3)",borderRadius:"4px",position:"absolute",cursor:"grab"};return"vertical"===t?(f.width="8px",f.height=`${n}px`,f.right="0px",f.top="0px",g.width="8px",g.height=`${l}px`,g.top=`${d}px`):(f.height="8px",f.width=`${n}px`,f.left="0px",f.bottom="0px",g.height="8px",g.width=`${l}px`,g.left=`${d}px`),r.createElement("div",{style:f},r.createElement("div",{style:g,onMouseDown:e=>a({x:e.clientX,y:e.clientY},{["vertical"===t?"y":"x"]:d})}),s)}},7732:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useAttributedTextEditor:()=>E});var r=n(7378),o=n(7310),i=n(9195),a=n(1799),s=n(2997),l=n(1301),c=n(1502),u=n(2357),p=n(8533),d=n(8137),f=Object.defineProperty,g=Object.defineProperties,h=Object.getOwnPropertyDescriptors,m=Object.getOwnPropertySymbols,y=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable,v=(e,t,n)=>t in e?f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t)=>{for(var n in t||(t={}))y.call(t,n)&&v(e,n,t[n]);if(m)for(var n of m(t))x.call(t,n)&&v(e,n,t[n]);return e},C=(e,t)=>g(e,h(t));function E(e){var t,n;const[f,g]=r.useState(0),[h,m]=r.useState(),y=r.useRef(null),[x,v]=r.useState(0),[E,k]=r.useState(),w=t=>{var n,r;if(e.readOnly)return;let o,i;Q?(i=Q.min,o=P(Q)):(i=f,o=e.state),g(i+t.length);const a=[];let s=0,l=!1;const c=(null==(n=$.find((e=>f===e.min)))?void 0:n.min)===i,u=(null==(r=$.find((e=>f===e.max)))?void 0:r.max)===i;for(const e of o){const n=i-s;if(n>=0&&(u?n0&&a.push({attributes:e.attributes,insert:e.insert.slice(0,n)}),a.push({attributes:b(b({},e.attributes),E.attributes),insert:t}),n{if(e.readOnly)return;let o,i;Q?(i=Q.min,o=P(Q)):(i=f,o=e.state),void 0!==r&&(i=r),g(i+n);const a=[];let s=0,l=!1;for(const e of o){const r=i-s;r>=0&&r<=e.insert.length&&!l?(a.push({attributes:e.attributes,insert:e.insert.slice(0,r)}),a.push(...t),s+=n,a.push({attributes:e.attributes,insert:e.insert.slice(r)}),l=!0):a.push(e),s+=e.insert.length}l||a.push(...t),e.setState(a)},P=t=>{g(t.min),m(void 0);const n=[];let r=0;for(const o of e.state){const e=t.min-r,i=t.max-r;e<0?i>=o.insert.length||(i>=0?i0&&n.push({attributes:o.attributes,insert:o.insert.slice(0,e)}),i{const n=[];let r=0;for(const o of e.state){const e=t.min-r,i=t.max-r;e<0?i>=o.insert.length?n.push(o):i>=0&&i>0&&n.push({attributes:o.attributes,insert:o.insert.slice(0,i)}):e{if(void 0===Q)return;const n=R(Q);return t&&e.setState(P(Q)),n},T=e=>{const t=D(F(e)),{newSelectionStart:n,newLocation:r}=(0,d.getWordByDoubleClick)(V,t,(e=>e.insert));void 0!==n&&m(H(n,"min")),void 0!==r&&g(H(r,"max"))},A=t=>{var n;if(!t.nativeEvent.isComposing&&229!==t.keyCode&&!(null==(n=e.processInput)?void 0:n.call(e,t))&&!["CapsLock","Tab","Shift","Meta","Escape","Control"].includes(t.key)){if("Backspace"===t.key)return(()=>{if(e.readOnly)return;if(Q)return void e.setState(P(Q));if(0===f)return;const t=$.find((e=>f===e.max));if(t)return g(t.min),void e.setState(P(t));g(f-1);const n=[];let r=0,o=!1;for(const t of e.state){const e=f-r;e>=0&&e<=t.insert.length&&!o?(n.push({attributes:t.attributes,insert:t.insert.slice(0,e-1)+t.insert.slice(e)}),o=!0):n.push(t),r+=t.insert.length}e.setState(n)})();if("Delete"===t.key)return(()=>{if(e.readOnly)return;if(Q)return void e.setState(P(Q));if(f===V.length)return;const t=$.find((e=>f===e.min));if(t)return void e.setState(P(t));const n=[];let r=0,o=!1;for(const t of e.state){const e=f-r+1;e>=0&&e<=t.insert.length&&!o?(n.push({attributes:t.attributes,insert:t.insert.slice(0,e-1)+t.insert.slice(e)}),o=!0):n.push(t),r+=t.insert.length}e.setState(n)})();if("ArrowLeft"===t.key)return((e=!1)=>{if(!e&&Q)return m(void 0),void g(Q.min);0!==f&&(e&&void 0===h&&m(f),g(H(f-1,"min")))})(t.shiftKey);if("ArrowRight"===t.key)return((e=!1)=>{if(!e&&Q)return m(void 0),void g(Q.max);f!==V.length&&(e&&void 0===h&&m(f),g(H(f+1,"max")))})(t.shiftKey);if("ArrowUp"===t.key)return((e=!1)=>{if(!e&&Q)return m(void 0),void g(Q.min);e&&void 0===h&&m(f),g(te{if(!e&&Q)return m(void 0),void g(Q.max);e&&void 0===h&&m(f),ne>=X.length-1?g(V.length):g(H(D({x:ee,y:te+X[ne]+X[ne+1]/2+j},!1),"max"))})(t.shiftKey);if("Enter"===t.key)return w("\n");if((0,u.metaKeyIfMacElseCtrlKey)(t)){if("a"===t.key)return m(0),void g(V.length);if("v"===t.key)return e.readOnly||navigator.clipboard.readText().then((e=>{if(e){w(e);try{const t=JSON.parse(e);S(t,function(e){let t=0;for(const n of e)t+=n.insert.length;return t}(t))}catch(t){w(e)}}})),void t.preventDefault();if("c"===t.key||"x"===t.key){const e=_("x"===t.key);return void(e&&navigator.clipboard.writeText(JSON.stringify(e)))}}else t.preventDefault(),1===t.key.length&&w(t.key)}},M=()=>{var t,n;null==(t=e.onLocationChanged)||t.call(e,-1),null==(n=e.onBlur)||n.call(e)},L=r.useRef(),[O,I]=r.useState(),F=e=>{const t=e.target.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}},D=(t,n=!0)=>{var r,i;return null!=(i=null==(r=(0,o.getFlowLayoutLocation)(t,X,q,j,e.getWidth,n))?void 0:r.location)?i:q.length-1},B=t=>{t.preventDefault();const n=F(t),r=H(D(n),"nearest");if(t.shiftKey)(void 0===h||Math.abs(h-r){if(Q)for(let n=Q.min;nr.x&&t.y>r.y&&t.x{if(void 0===L.current)return void(void 0!==O&&I(D(F(t),!1)));const n=F(t),r=H(D(n,!1),"farthest");g(r),r===L.current?m(void 0):m(L.current),e.autoHeight||(n.y>=0&&n.y<=K?W((e=>G(e+2))):n.y<=e.height&&n.y>=e.height-Z&&W((e=>G(e-2))))},U=e=>{var t;z(e),void 0!==O&&Q&&(OQ.max&&(S(R(Q),Q.size,O-Q.size),m(O-Q.size)),I(void 0)),null==(t=y.current)||t.focus()};(0,c.useGlobalMouseUp)((0,l.useEvent)((()=>{L.current=void 0,I(void 0)})));const{ref:N,y:j,setY:W,filterY:G}=(0,p.useWheelScroll)({minY:e.autoHeight?0:x>e.height?e.height-x:0,maxY:0,disabled:e.autoHeight});r.useEffect((()=>{e.autoHeight&&W(0)}),[e.autoHeight,W]);const V=[],$=[];for(const n of e.state){const r=null==(t=e.getReadonlyType)?void 0:t.call(e,n.attributes);if(r){const e=V.length,t=V.length+n.insert.length,o=$.find((t=>t.type===r&&t.max===e));o?o.max=t:$.push({min:e,max:t,type:r})}for(const e of n.insert)V.push({insert:e,attributes:n.attributes})}const H=(e,t)=>{var n;const r=$.find((t=>e>t.min&&e(r.max+r.min)/2?r.min:r.max:"nearest"===t?e>(r.max+r.min)/2?r.max:r.min:r[t]:e},{layoutResult:q,newContentHeight:Y,lineHeights:X}=(0,o.flowLayout)({state:V,width:e.width,height:e.autoHeight?void 0:e.height,lineHeight:e.lineHeight,getWidth:e.getWidth,isNewLineContent:e=>"\n"===e.insert,isPartOfComposition:e=>(0,d.isWordCharactor)(e.insert),getComposition:t=>(0,d.getTextComposition)(t,V,e.getWidth,(e=>e.insert)),endContent:{insert:""},scrollY:j,align:e.align,verticalAlign:e.verticalAlign});x0?re-1:re];E&&!Q&&E.index===f&&(oe=C(b({},oe),{attributes:b(b({},oe.attributes),E.attributes)}));const ie=r.useRef(),ae=r.useRef();r.useEffect((()=>{if((0,i.equals)(ie.current,f)&&(0,i.equals)(ae.current,te)||e.autoHeight)return;const t=te+j;t<0?W(-te):t>e.height-Z&&W(e.height-Z-te),ie.current=f,ae.current=te}),[f,te,j,Z]),r.useEffect((()=>{var t;null==(t=e.onLocationChanged)||t.call(e,f)}),[f]),r.useEffect((()=>{E&&f!==(null==E?void 0:E.index)&&k(void 0)}),[f,E,k]);let se=e.height;return e.autoHeight&&x>e.height&&(se=x),{ref:y,range:Q,layoutResult:q,lineHeights:X,cursor:{x:ee,y:te+j,row:ne},inputText:w,inputContent:S,location:f,setLocation:g,getCopiedContents:_,isSelected:e=>Q&&e>=Q.min&&e{if(!Q)return void("function"!=typeof t&&((null==E?void 0:E.index)===f&&(t=b(b({},E.attributes),t)),k({index:f,attributes:t})));const n=e=>"function"==typeof t?t(e):b(b({},e),t),r=[];let o=0;for(const t of e.state){const e=Q.min-o,i=Q.max-o;e<0?i>=t.insert.length?r.push({insert:t.insert,attributes:n(t.attributes)}):i>=0?(i>0&&r.push({attributes:n(t.attributes),insert:t.insert.slice(0,i)}),i0&&r.push({attributes:t.attributes,insert:t.insert.slice(0,e)}),r.push({attributes:n(t.attributes),insert:t.insert.slice(e,i)}),ir.createElement("div",{style:b({position:"relative",width:e.width+"px",height:se+"px",border:"1px solid black",clipPath:"inset(0px 0px)"},e.style),onMouseLeave:U,ref:N},r.createElement(a.Cursor,{ref:y,onKeyDown:A,onCompositionEnd:e=>{w(e.data),y.current&&(y.current.value="")},onBlur:M,onFocus:e.onFocus,readOnly:e.readOnly,autoFocus:e.autoFocus,style:{left:ee+"px",top:te+j+"px",height:X[ne]+"px"}}),t,r.createElement("div",{onMouseDown:B,onMouseMove:z,onMouseUp:U,onDoubleClick:T,style:{inset:"0px",cursor:"text",position:"absolute"}}),!e.autoHeight&&r.createElement(s.Scrollbar,{value:j,type:"vertical",containerSize:e.height,contentSize:x,onChange:W,align:"head"}))}}},1138:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useAudioPlayer:()=>i});var r=n(7378),o=n.n(r);function i(e){const[t,n]=o().useState(0),[r,i]=o().useState(0),[a,s]=o().useState(!1),l=o().useRef(null);return{currentTime:t,duration:r,playing:a,play(){l.current&&(l.current.play(),s(!0))},pause(){l.current&&(l.current.pause(),s(!1))},audio:e&&o().createElement("audio",{onTimeUpdate:()=>{l.current&&n(l.current.currentTime)},onEnded:()=>{s(!1)},preload:"auto",onDurationChange:()=>{l.current&&i(l.current.duration)},ref:l,src:e})}}},3860:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useAudioRecorder:()=>a});var r=n(7378),o=n.n(r),i=(e,t,n)=>new Promise(((r,o)=>{var i=e=>{try{s(n.next(e))}catch(e){o(e)}},a=e=>{try{s(n.throw(e))}catch(e){o(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(i,a);s((n=n.apply(e,t)).next())}));function a(){const e=o().useRef(),t=o().useRef(),n=o().useRef(),[r,a]=o().useState(),[s,l]=o().useState(0),[c,u]=o().useState(),[p,d]=o().useState(!1),f=o().useRef([]);return{audioUrl:r,duration:s,volume:c,start:()=>i(this,null,(function*(){const r=yield navigator.mediaDevices.getUserMedia({audio:!0});e.current=new MediaRecorder(r),e.current.ondataavailable=e=>{f.current.push(e.data)};const o=new AudioContext,i=o.createMediaStreamSource(r);n.current=o.createAnalyser(),i.connect(n.current);const s=Date.now();t.current=setInterval((()=>{if(l(Date.now()-s),n.current){const e=new Float32Array(n.current.fftSize);n.current.getFloatTimeDomainData(e);let t=0;for(const n of e)t=Math.max(t,Math.abs(n));u(Math.min(2*t,1))}}),20),a(void 0),l(0),f.current=[],d(!0),e.current.start(100)})),stop:()=>{e.current&&(e.current.stop(),e.current.stream.getAudioTracks().forEach((e=>{e.stop()})),t.current&&(clearInterval(t.current),t.current=void 0),u(void 0),d(!1),a(window.URL.createObjectURL(new Blob(f.current,{type:"audio/ogg; codecs=opus"}))))},recording:p,chunks:f.current}}},6911:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useCircleArcClickCreate:()=>m});var r=n(7378),o=n(9254),i=n(7386),a=n(8385),s=Object.defineProperty,l=Object.defineProperties,c=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))p.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))d.call(t,n)&&f(e,n,t[n]);return e},h=(e,t)=>l(e,c(t));function m(e,t,n){const[s,l]=r.useState(),[c,u]=r.useState();let p;s&&(p=void 0===c?"specify start angle by click or input angle":"specify end angle by click or input angle");const{circle:d,onClick:f,onMove:m,input:y,setInputPosition:x,startPosition:v,middlePosition:b,cursorPosition:C,setCursorPosition:E,clearText:k}=(0,a.useCircleClickCreate)(e,(e=>l(e?h(g({},e),{startAngle:0,endAngle:0}):void 0)),h(g({},n),{message:p,onKeyDown:s?(e,n)=>{if("Enter"===e.key){let e=+n;isNaN(e)||(void 0===c?(u(e),l(h(g({},s),{startAngle:e,endAngle:e})),k()):(e{u(void 0),E(void 0),l(void 0),k()};return{circle:d,arc:s,startPosition:v,middlePosition:b,cursorPosition:C,onClick(r){if(e)if(s)if(r=(0,i.getAngleSnapPosition)(s,r,null==n?void 0:n.getAngleSnap),void 0===c){const e=(0,o.radianToAngle)((0,o.getTwoPointsRadian)(r,s));u(e),l(h(g({},s),{startAngle:e,endAngle:e}))}else{let e=(0,o.radianToAngle)((0,o.getTwoPointsRadian)(r,s));e{"use strict";n.r(t),n.d(t,{useCircleClickCreate:()=>m});var r=n(7378),o=n(9195),i=n(7386),a=n(2592),s=Object.defineProperty,l=Object.defineProperties,c=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))p.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))d.call(t,n)&&f(e,n,t[n]);return e},h=(e,t)=>l(e,c(t));function m(e,t,n){const[s,l]=r.useState(),[c,u]=r.useState(),[p,d]=r.useState();let f="";e&&(f=c?"3 points"===e?p?"specify third point by click":"specify second point by click":"2 points"===e?"specify second point by click, input position or input length":"specify circle edge point by click, input position or input length":"2 points"===e||"3 points"===e?"specify first point by click or input position":"specify circle center point by click or input position",(null==n?void 0:n.message)&&(f=n.message));const{input:m,setCursorPosition:x,clearText:v,cursorPosition:b,setInputPosition:C,resetInput:E}=(0,a.useCursorInput)(f,"center radius"===e||"center diameter"===e||"2 points"===e?(r,i,a)=>{if(null==n?void 0:n.onKeyDown)n.onKeyDown(r,i,a);else if("Enter"===r.key){const n=i.split(",");if(c){if("2 points"===e&&2===n.length){const e=+n[0],r=+n[1];if(!isNaN(e)&&!isNaN(r)){const n={x:c.x+e/2,y:c.y+r/2};t(h(g({},n),{r:(0,o.getTwoPointsDistance)(n,c)})),k()}return}const r=+i;if(!isNaN(r)&&r>0){let n=c.x,i=c.y;if("2 points"===e){const e=(0,o.getPointByLengthAndDirection)(c,r/2,a);n=e.x,i=e.y}t({x:n,y:i,r:"center diameter"===e||"2 points"===e?r/2:r}),k()}}else if(2===n.length){const t=+n[0],r=+n[1];if(!isNaN(t)&&!isNaN(r)){if(u({x:t,y:r}),e){const n=y(e,{x:t,y:r},void 0,a);n&&l(n)}v()}}}}:void 0),k=()=>{u(void 0),d(void 0),l(void 0),E()};return{circle:s,startPosition:c,middlePosition:p,cursorPosition:b,setCursorPosition:x,setInputPosition:C,clearText:v,onClick(r){if(e)if(x(r),c)if("3 points"!==e||p){const o=y(e,c,p,(0,i.getAngleSnapPosition)(c,r,null==n?void 0:n.getAngleSnap));o&&t(o),k()}else d((0,i.getAngleSnapPosition)(c,r,null==n?void 0:n.getAngleSnap));else u(r)},onMove(t,r){if(C(null!=r?r:t),e&&(t=(0,i.getAngleSnapPosition)(c,t,null==n?void 0:n.getAngleSnap),x(t),c)){const n=y(e,c,p,t);n&&l(n)}},input:m,reset:k}}function y(e,t,n,r){if("2 points"===e){const e={x:(t.x+r.x)/2,y:(t.y+r.y)/2};return h(g({},e),{r:(0,o.getTwoPointsDistance)(e,t)})}return"center radius"===e||"center diameter"===e?h(g({},t),{r:(0,o.getTwoPointsDistance)(r,t)}):n?(0,o.getThreePointsCircle)(t,n,r):void 0}},7535:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useEllipseArcClickCreate:()=>m});var r=n(7378),o=n(9300),i=n(9254),a=n(7386),s=Object.defineProperty,l=Object.defineProperties,c=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))p.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))d.call(t,n)&&f(e,n,t[n]);return e},h=(e,t)=>l(e,c(t));function m(e,t,n){const[s,l]=r.useState(),[c,u]=r.useState();let p;s&&(p=void 0===c?"specify start angle by click or input angle":"specify end angle by click or input angle");const{ellipse:d,onClick:f,onMove:m,input:y,startPosition:x,middlePosition:v,cursorPosition:b,setCursorPosition:C,clearText:E,setInputPosition:k}=(0,o.useEllipseClickCreate)(e,(e=>l(e?h(g({},e),{startAngle:0,endAngle:0}):void 0)),h(g({},n),{message:p,onKeyDown:s?(e,n)=>{if("Enter"===e.key){let e=+n;isNaN(e)||(void 0===c?(u(e),l(h(g({},s),{startAngle:e,endAngle:e})),E()):(e{l(void 0),u(void 0),C(void 0),E()};return{ellipse:d,ellipseArc:s,startPosition:x,middlePosition:v,cursorPosition:b,reset:w,onClick(r){if(e)if(s){r=(0,a.getAngleSnapPosition)({x:s.cx,y:s.cy},r,null==n?void 0:n.getAngleSnap);let e=(0,i.getEllipseAngle)(r,s);void 0===c?(u(e),l(h(g({},s),{startAngle:e,endAngle:e}))):(e{"use strict";n.r(t),n.d(t,{useEllipseClickCreate:()=>s});var r=n(7378),o=n(9300),i=n(9254),a=n(7386);function s(e,t,n){const[s,c]=r.useState(),[u,p]=r.useState(),[d,f]=r.useState();let g="";e&&(g=u?d?"specify secondary semi-axis by click, input position or input length":"specify end point by click, input position or input length":"ellipse endpoint"===e?"specify first point by click or input position":"specify ellipse center point by click or input position",(null==n?void 0:n.message)&&(g=n.message));const{input:h,setCursorPosition:m,clearText:y,cursorPosition:x,setInputPosition:v,resetInput:b}=(0,o.useCursorInput)(g,e?(r,o,a)=>{if(null==n?void 0:n.onKeyDown)n.onKeyDown(r,o,a);else if("Enter"===r.key&&e){const n=o.split(",");if(!u){if(2===n.length){const e=+n[0],t=+n[1];isNaN(e)||isNaN(t)||(p({x:e,y:t}),y())}return}if(!d){if(2===n.length){const e=+n[0],t=+n[1];isNaN(e)||isNaN(t)||(f({x:e,y:t}),y())}else{const e=+o;!isNaN(e)&&e>0&&(f((0,i.getPointByLengthAndDirection)(u,e,a)),y())}return}if(2===n.length){const r=+n[0],o=+n[1];isNaN(r)||isNaN(o)||(t(l(e,u,d,{x:r,y:o})),C())}else{const n=+o;!isNaN(n)&&n>0&&(t(l(e,u,d,n)),C())}}}:void 0),C=()=>{p(void 0),f(void 0),c(void 0),b()};return{ellipse:s,startPosition:u,middlePosition:d,cursorPosition:x,setCursorPosition:m,setInputPosition:v,clearText:y,reset:C,onClick(r){if(e)if(m(r),u)if(d){const o="ellipse center"===e?u:{x:(u.x+d.x)/2,y:(u.y+d.y)/2};r=(0,a.getAngleSnapPosition)(o,r,null==n?void 0:n.getAngleSnap),t(l(e,u,d,r)),C()}else{const e=(0,a.getAngleSnapPosition)(u,r,null==n?void 0:n.getAngleSnap);f(e)}else p(r)},onMove(t,r){if(v(r||t),!e)return;let o;if(u&&d){const r="ellipse center"===e?u:{x:(u.x+d.x)/2,y:(u.y+d.y)/2};o=(0,a.getAngleSnapPosition)(r,t,null==n?void 0:n.getAngleSnap)}else o=(0,a.getAngleSnapPosition)(u,t,null==n?void 0:n.getAngleSnap);m(o),u&&d&&c(l(e,u,d,o))},input:h}}function l(e,t,n,r){const o="ellipse center"===e?t:{x:(t.x+n.x)/2,y:(t.y+n.y)/2};return{cx:o.x,cy:o.y,rx:(0,i.getTwoPointsDistance)(o,n),ry:"number"==typeof r?r:(0,i.getTwoPointsDistance)(o,r),angle:(0,i.radianToAngle)((0,i.getTwoPointsRadian)(n,o))}}},1487:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useImageClickCreate:()=>h});var r=n(7378),o=n(9300),i=n(1948),a=Object.defineProperty,s=Object.defineProperties,l=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,d=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,f=(e,t)=>{for(var n in t||(t={}))u.call(t,n)&&d(e,n,t[n]);if(c)for(var n of c(t))p.call(t,n)&&d(e,n,t[n]);return e},g=(e,t)=>s(e,l(t));function h(e,t){const[n,a]=r.useState(),s=r.useRef(null);let l="";e&&(l=n?"specify image position":"click to select image");const{input:c,setInputPosition:u}=(0,o.useCursorInput)(l),p=()=>{a(void 0)};return r.useEffect((()=>{var t;e&&(null==(t=s.current)||t.click())}),[e]),{image:n,reset:p,onClick(r){var o;e&&(n?(u(r),t(n),p()):null==(o=s.current)||o.click())},onMove(e,t){u(t||e),n&&a(g(f({},n),{x:e.x,y:e.y}))},input:r.createElement(r.Fragment,null,r.createElement("input",{type:"file",ref:s,accept:"image/*",style:{display:"none"},onChange:e=>{var t;const n=null==(t=e.currentTarget.files)?void 0:t.item(0);if(n){const e=new FileReader;e.onloadend=()=>{const t=e.result;"string"==typeof t&&(0,i.getImageFromCache)(t,{callback(e){a({x:0,y:0,width:e.width,height:e.height,url:t})}})},e.readAsDataURL(n)}e.target.value=null}}),c)}}},5490:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useLineClickCreate:()=>s});var r=n(7378),o=n(9300),i=n(9254),a=n(7386);function s(e,t,n){const[s,u]=r.useState(),[p,d]=r.useState([]),[f,g]=r.useState([]),[h,m]=r.useState(0),[y,x]=r.useState(),[v,b]=r.useState(),C=l[h],E=(h+1)%l.length,k=void 0!==y?()=>y:null==n?void 0:n.getAngleSnap,w=void 0!==v?()=>v:null==n?void 0:n.getLengthSnap;let S="";s&&(S=1===s.length?"specify start point by click, input position":`specify next point by click, input position or input ${C}, press tab to input ${l[E]}`);const{input:P,setCursorPosition:R,clearText:_,setInputPosition:T,resetInput:A,cursorPosition:M}=(0,o.useCursorInput)(S,e?(e,r,o)=>{if("Enter"===e.key){if("angle"===C){const e=+r;if(!isNaN(e)&&(_(),s&&s.length>1)){const t=s[s.length-2],n=s[s.length-1];let r=(0,a.getAngleSnapPosition)(t,n,(()=>e));r=c(t,r,w),d([...p,r]),g([...f,void 0]),u([...p,r,{x:o.x,y:o.y}]),x(void 0),b(void 0)}return}const e=r.split(",");if(2===e.length){const r=+e[0],i=+e[1];if(!isNaN(r)&&!isNaN(r)){const e=p[p.length-1]||{x:0,y:0},a=e.x+r,s=e.y+i;if((null==n?void 0:n.once)&&p.length>0)return t([p[0],{x:a,y:s}],f),void L();d([...p,{x:a,y:s}]),g([...f,void 0]),u([...p,{x:a,y:s},{x:o.x,y:o.y}]),_(),x(void 0),b(void 0)}return}if(p.length>0){const e=+r;if(!isNaN(e)&&e>0){const r=(0,i.getPointByLengthAndDirection)(p[p.length-1],e,o);if((null==n?void 0:n.once)&&p.length>0)return t([p[0],r],f),void L();d([...p,r]),g([...f,void 0]),u([...p,r,{x:o.x,y:o.y}]),_(),x(void 0),b(void 0)}}}else if("Tab"===e.key){if(e.stopPropagation(),e.preventDefault(),r){const e=+r;isNaN(e)||("angle"===C?(x(e),b(void 0),_()):e>0&&(b(e),x(void 0),_()))}m(E)}}:void 0),L=e=>{e&&p.length>1&&t(p,f),d([]),u(void 0),A(),x(void 0),b(void 0),m(0),g([])};return{line:s,positionTargets:f,inputMode:C,lastPosition:null==s?void 0:s[s.length-2],cursorPosition:M,onClick(r,o){if(!e)return;let i=(0,a.getAngleSnapPosition)(p[p.length-1],r,k);if(i=c(p[p.length-1],i,w),R(i),x(void 0),b(void 0),(null==n?void 0:n.once)&&p.length>0)return t([p[0],i],f),void L();d([...p,i]),g([...f,o])},onMove(t,r){if(T(r||t),!e)return;let o=(0,a.getAngleSnapPosition)(p[p.length-1],t,k);o=c(p[p.length-1],o,w),R(o),(null==n?void 0:n.once)&&0===p.length||u([...p,o])},input:P,reset:L,positions:p}}const l=["length","angle"];function c(e,t,n){if(n&&e){const r=(0,i.getTwoPointsDistance)(e,t),o=n(r);void 0!==o&&o!==r&&(t=(0,i.getPointByLengthAndDirection)(e,o,t))}return t}},9328:(e,t,n)=>{"use strict";n.r(t),n.d(t,{usePathClickCreate:()=>i});var r=n(7378),o=n(9300);function i(e,t){const[n,i]=r.useState([]),[a,s]=r.useState(),[l,c]=r.useState("move"),[u,p]=r.useState(),[d,f]=r.useState(),[g,h]=r.useState();let m="";"move"===l?m="specify start point by click":"line"===l?m="specify end point by click":"quadraticCurve"===l?m=u?"specify end point by click":"specify control point by click":"bezierCurve"===l?m=u?d?"specify end point by click":"specify control point 2 by click":"specify control point 1 by click":"arc"===l&&(m=u?d?"input radius":"specify end point by click, or input radius":"specify start point by click, or input radius");const{input:y,setCursorPosition:x,cursorPosition:v,clearText:b,setInputPosition:C,resetInput:E}=(0,o.useCursorInput)(e?m:"",e?(e,t,r)=>{if("Enter"===e.key){const e=t.split(",");if(2===e.length){const t=+e[0],n=+e[1];isNaN(t)||isNaN(n)||(w({x:t,y:n}),S(r),b())}else if(1===e.length&&"arc"===l){const e=+t;!isNaN(e)&&e>0&&(u&&d?(i([...n,{type:"arc",from:u,to:d,radius:e}]),s(void 0),p(void 0),f(void 0)):h(e),b())}}}:void 0),k=e=>{e&&n.length>1&&t(n),i([]),s(void 0),E(),c("move"),b(),p(void 0),f(void 0),h(void 0)},w=e=>{x(e),"move"===l?(i([...n,{type:"move",to:e}]),c("line")):"line"===l?(i([...n,{type:"line",to:e}]),s(void 0)):"quadraticCurve"===l?u?(i([...n,{type:"quadraticCurve",cp:u,to:e}]),s(void 0),p(void 0)):p(e):"bezierCurve"===l?u?d?(i([...n,{type:"bezierCurve",cp1:u,cp2:d,to:e}]),s(void 0),p(void 0),f(void 0)):f(e):p(e):"arc"===l&&(u?g?(i([...n,{type:"arc",from:u,to:e,radius:g}]),s(void 0),p(void 0),h(void 0)):d||f(void 0):p(e))},S=e=>{"line"===l?s({type:"line",to:e}):"quadraticCurve"===l?s(u?{type:"quadraticCurve",cp:u,to:e}:void 0):"bezierCurve"===l?s(u&&d?{type:"bezierCurve",cp1:u,cp2:d,to:e}:void 0):"arc"===l&&s(u&&g?{type:"arc",from:u,radius:g,to:e}:void 0)};return{path:n,preview:a?[...n,a]:n,controlPoint:u,controlPoint2:d,onClick(t){e&&w(t)},onMove(t,n){C(n||t),e&&(x(t),S(t))},input:y,reset:k,setInputType(e){"close"===e?(t([...n,{type:"close"}]),k()):c(e)},cursorPosition:v}}},5069:(e,t,n)=>{"use strict";n.r(t),n.d(t,{usePenClickCreate:()=>a});var r=n(5188),o=n(7378),i=n(9254);function a(e,t){const[n,a]=o.useState([]),s=()=>{a([])};return{points:n,onClick(r){e&&(0!==n.length?(t(),s()):a([{x:Math.round(r.x),y:Math.round(r.y)}]))},onMove(t){if(!e||0===n.length)return;const o=n[n.length-1];if(t={x:Math.round(t.x),y:Math.round(t.y)},!(0,i.isSamePoint)(o,t)){if(n.length>1){const e=n[n.length-2];if((0,i.pointIsOnLine)(o,e,t)&&(0,i.pointIsOnLineSegment)(o,e,t))return void a((0,r.produce)(n,(e=>{e[n.length-1]=t})))}a((0,r.produce)(n,(e=>{e.push(t)})))}},reset:s}}},8313:(e,t,n)=>{"use strict";n.r(t),n.d(t,{usePolygonClickCreate:()=>s});var r=n(7378),o=n(9300),i=n(9254),a=n(7386);function s(e,t,n){const[s,l]=r.useState(),[c,u]=r.useState(),[p,d]=r.useState("radius"),[f,g]=r.useState(6);let h="";e&&(h="sides"===p?"specify sides number by input":c?(null==n?void 0:n.toEdge)?"specify edge point by click or input length":"specify end point by click or input length":"specify center point by click");const{input:m,setCursorPosition:y,clearText:x,cursorPosition:v,setInputPosition:b,resetInput:C}=(0,o.useCursorInput)(h,e?(e,r,o)=>{if("Enter"===e.key){if((null==n?void 0:n.setSidesKey)&&r.toLowerCase()===n.setSidesKey.toLowerCase())return d("sides"),void x();if((null==n?void 0:n.switchTypeKey)&&n.switchType&&r.toLowerCase()===n.switchTypeKey.toLowerCase())return n.switchType(),void x();const e=+r;if(!isNaN(e)&&e>0)if("radius"===p){if(c){const r=(0,i.getPointByLengthAndDirection)(c,e,o);t((0,i.getPolygonPoints)(r,c,f,null==n?void 0:n.toEdge)),E()}}else"sides"===p&&Number.isInteger(e)&&e>=3&&(g(e),d("radius"),x(),c&&l((0,i.getPolygonPoints)(o,c,e,null==n?void 0:n.toEdge)))}}:void 0),E=()=>{u(void 0),l(void 0),C()};return r.useEffect((()=>{c&&v&&l((0,i.getPolygonPoints)(v,c,f,null==n?void 0:n.toEdge))}),[null==n?void 0:n.toEdge]),{polygon:s,startPosition:c,cursorPosition:v,reset:E,onClick(r){if(e)if(y(r),c){const e=(0,a.getAngleSnapPosition)(c,r,null==n?void 0:n.getAngleSnap);t((0,i.getPolygonPoints)(e,c,f,null==n?void 0:n.toEdge)),E()}else u(r)},onMove(t,r){if(b(r||t),!e)return;const o=(0,a.getAngleSnapPosition)(c,t,null==n?void 0:n.getAngleSnap);y(o),c&&l((0,i.getPolygonPoints)(o,c,f,null==n?void 0:n.toEdge))},input:m,startSetSides(){d("sides")}}}},9990:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useTextClickCreate:()=>g});var r=n(7378),o=n(9300),i=Object.defineProperty,a=Object.defineProperties,s=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable,p=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d=(e,t)=>{for(var n in t||(t={}))c.call(t,n)&&p(e,n,t[n]);if(l)for(var n of l(t))u.call(t,n)&&p(e,n,t[n]);return e},f=(e,t)=>a(e,s(t));function g(e,t,n){const[i,a]=r.useState();let s="";e&&(s=i?"specify text position":"input text");const{input:l,setCursorPosition:c,clearText:u,setInputPosition:p,resetInput:g}=(0,o.useCursorInput)(s,e?(e,t,r)=>{var o;"Enter"===e.key&&(a({x:r.x,y:r.y,text:t,color:0,fontSize:16/(null!=(o=null==n?void 0:n.scale)?o:1),fontFamily:"monospace"}),u())}:void 0),h=()=>{a(void 0),g()};return{text:i,onClick(n){e&&i&&(c(n),t(i),h())},onMove(e,t){p(t||e),c(e),i&&a(f(d({},i),{x:e.x,y:e.y}))},input:l,reset:h}}},2592:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useCursorInput:()=>u});var r=n(7378),o=Object.defineProperty,i=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,l=(e,t,n)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,c=(e,t)=>{for(var n in t||(t={}))a.call(t,n)&&l(e,n,t[n]);if(i)for(var n of i(t))s.call(t,n)&&l(e,n,t[n]);return e};function u(e,t,n){const[o,i]=r.useState(""),[a,s]=r.useState(),[l,u]=r.useState(),p=r.useRef(null);return r.useLayoutEffect((()=>{var e,t;const n=null==(e=document.activeElement)?void 0:e.tagName;"INPUT"!==n&&"TEXTAREA"!==n&&(null==(t=p.current)||t.focus())})),{resetInput:()=>{s(void 0),u(void 0),i("")},cursorPosition:a,inputPosition:l,setCursorPosition:s,setInputPosition:u,clearText(){i("")},input:l&&(e||t&&a)?r.createElement("span",{style:{position:"absolute",left:`${Math.min(l.x+10,window.innerWidth-54)}px`,top:`${Math.min(l.y-5,window.innerHeight-22)}px`}},e&&r.createElement("span",null,e),t&&a&&r.createElement("input",{ref:p,value:o,autoComplete:"false",style:c({width:"50px",opacity:(null==n?void 0:n.hideIfNoInput)&&!o?0:void 0},null==n?void 0:n.inputStyle),onChange:e=>i(e.target.value),onKeyDown:e=>t(e,o,a)})):void 0}}},2293:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useDelayedAction:()=>o});var r=n(7378);function o(e,t,n){const o=r.useRef();e&&(o.current&&clearTimeout(o.current),o.current=setTimeout((()=>{n()}),t))}},6239:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useDragMove:()=>s});var r=n(7378),o=n(7386),i=n(8150),a=n(3516);function s(e,t){var n;const[s,l]=r.useState({x:0,y:0}),[c,u]=r.useState(),p=null!=(n=null==t?void 0:t.scale)?n:1,d=-(0,a.angleToRadian)(null==t?void 0:t.parentRotate),f=()=>{l({x:0,y:0}),u(void 0)};return{offset:s,resetDragMove:f,startPosition:c,onStart(e,t){var n,r;u({x:e.x-(null!=(n=null==t?void 0:t.x)?n:0),y:e.y-(null!=(r=null==t?void 0:t.y)?r:0),data:null==t?void 0:t.data})},mask:c&&r.createElement(i.DragMask,{ignoreLeavingEvent:null==t?void 0:t.ignoreLeavingEvent,onDragging:e=>{var n,r,i,a;const s={x:e.clientX,y:e.clientY};let u=null!=(r=null==(n=null==t?void 0:t.transform)?void 0:n.call(t,s))?r:s;u=(0,o.getAngleSnapPosition)(c,u,null==t?void 0:t.getAngleSnap);const f=(u.x-c.x)/p,g=(u.y-c.y)/p,h=Math.sin(d),m=Math.cos(d),y={x:m*f-h*g,y:h*f+m*g};l(null!=(a=null==(i=null==t?void 0:t.transformOffset)?void 0:i.call(t,y,e))?a:y)},onDragEnd:()=>{null==e||e(),(null==t?void 0:t.repeatedly)||f()}})}}},4558:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getResizeOffset:()=>x,useDragResize:()=>y});var r=n(7378),o=n(8626),i=n(7386),a=n(8150),s=n(3516),l=Object.defineProperty,c=Object.defineProperties,u=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,g=(e,t,n)=>t in e?l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h=(e,t)=>{for(var n in t||(t={}))d.call(t,n)&&g(e,n,t[n]);if(p)for(var n of p(t))f.call(t,n)&&g(e,n,t[n]);return e},m=(e,t)=>c(e,u(t));function y(e,t){var n,l;const[c,u]=r.useState({x:0,y:0,width:0,height:0}),[p,d]=r.useState(),f=-(0,s.angleToRadian)(null==t?void 0:t.rotate),g=-(0,s.angleToRadian)(null==t?void 0:t.parentRotate),[y,v]=r.useState(),b=()=>{u({x:0,y:0,width:0,height:0}),d(void 0)};return{offset:c,cursorPosition:y,startPosition:p,onStart(e,n){var r,o;e.stopPropagation();const i={x:e.clientX,y:e.clientY};d(m(h({},null!=(o=null==(r=null==t?void 0:t.transform)?void 0:r.call(t,i))?o:i),{direction:n}))},resetDragResize:b,mask:p&&r.createElement(a.DragMask,{onDragging:e=>{var n,r,o,a,s,l;let c={x:e.clientX,y:e.clientY};c=null!=(r=null==(n=null==t?void 0:t.transform)?void 0:n.call(t,c))?r:c,c=(0,i.getAngleSnapPosition)(p,c,null==t?void 0:t.getAngleSnap),v(c);const d="boolean"==typeof(null==t?void 0:t.centeredScaling)?t.centeredScaling:null==(o=null==t?void 0:t.centeredScaling)?void 0:o.call(t,e),h="number"==typeof(null==t?void 0:t.keepRatio)?t.keepRatio:null==(a=null==t?void 0:t.keepRatio)?void 0:a.call(t,e),m=x(p,c,p.direction,f,d,h,g);m&&u(null!=(l=null==(s=null==t?void 0:t.transformOffset)?void 0:s.call(t,m,e,p.direction))?l:m)},onDragEnd:()=>{e(),b()},style:{cursor:(0,o.getResizeCursor)((null!=(n=null==t?void 0:t.rotate)?n:0)+(null!=(l=null==t?void 0:t.parentRotate)?l:0),p.direction)}})}}function x(e,t,n,r=0,o,i,a=0){const s=t.x-e.x,l=t.y-e.y,c=Math.sin(a),u=Math.cos(a),p=u*s-c*l,d=c*s+u*l;if("center"===n)return{x:p,y:d,width:0,height:0};const f=Math.sin(r),g=Math.cos(r);let h=g*p-f*d,m=f*p+g*d;const y=n.includes("right")?1:n.includes("left")?-1:0,x=n.includes("bottom")?1:n.includes("top")?-1:0;if(i){if("left"===n||"right"===n||"top"===n||"bottom"===n)return;const e=h*y,t=m*x;h=Math.min(t*i,e)*y,m=Math.min(e/i,t)*x}const v={x:0,y:0,width:0,height:0};return v.width=h*(o?2:1)*y,v.height=m*(o?2:1)*x,o?(v.x-=h*y,v.y-=m*x):(n.includes("left")&&(v.x+=(g+1)*h/2,v.y-=f*h/2),n.includes("right")&&(v.x+=(g-1)*h/2,v.y-=f*h/2),n.includes("top")&&(v.x+=f*m/2,v.y+=(g+1)*m/2),n.includes("bottom")&&(v.x+=f*m/2,v.y+=(g-1)*m/2)),v}},3876:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useDragRotate:()=>y});var r=n(7378),o=n(9195),i=n(7386),a=n(8150),s=n(3516),l=Object.defineProperty,c=Object.defineProperties,u=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,g=(e,t,n)=>t in e?l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h=(e,t)=>{for(var n in t||(t={}))d.call(t,n)&&g(e,n,t[n]);if(p)for(var n of p(t))f.call(t,n)&&g(e,n,t[n]);return e},m=(e,t)=>c(e,u(t));function y(e,t){var n;const[l,c]=r.useState(),[u,p]=r.useState(),d=null!=(n=null==t?void 0:t.parentRotate)?n:0,f=()=>{c(void 0),p(void 0)};return{offset:l,center:u,onStart:p,resetDragRotate:f,mask:u&&r.createElement(a.DragMask,{ignoreLeavingEvent:null==t?void 0:t.ignoreLeavingEvent,onDragging:e=>{var n,r,a,l;const p={x:e.clientX,y:e.clientY};let f=null!=(r=null==(n=null==t?void 0:t.transform)?void 0:n.call(t,p))?r:p;f=(0,i.getAngleSnapPosition)(u,f,null==t?void 0:t.getAngleSnap);const g=((0,s.radianToAngle)((0,o.getTwoPointsRadian)(f,u))+450-d)%360;c(m(h({},f),{angle:null!=(l=null==(a=null==t?void 0:t.transformOffset)?void 0:a.call(t,g,e))?l:g}))},onDragEnd:()=>{null==e||e(),f()}})}}},8574:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useDragSelect:()=>i});var r=n(7378),o=n(8150);function i(e,t){const[n,i]=r.useState(),[a,s]=r.useState(),l=()=>{i(void 0),s(void 0)},c=t=>{n&&e(n,a,t),l()};return{dragSelectStartPosition:n,onStartSelect(e,t){i({x:e.clientX,y:e.clientY,data:t})},endDragSelect:c,resetDragSelect:l,dragSelectMask:n&&r.createElement(o.DragMask,{onDragging:e=>{if("boolean"==typeof t?t:t?t(e):void 0){const t=e.clientX-n.x,r=e.clientY-n.y,o=Math.min(Math.abs(t),Math.abs(r));s({x:t>0?n.x+o:n.x-o,y:r>0?n.y+o:n.y-o})}else s({x:e.clientX,y:e.clientY})},onDragEnd:c,style:{cursor:a?"crosshair":"default"}},a&&r.createElement("div",{style:{position:"absolute",border:"1px dashed black",left:Math.min(n.x,a.x)+"px",top:Math.min(n.y,a.y)+"px",width:Math.abs(n.x-a.x)+"px",height:Math.abs(n.y-a.y)+"px"}}))}}},1252:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useEdit:()=>y});var r=n(5188),o=n(7378),i=n(9254),a=n(7386),s=n(1273),l=Object.defineProperty,c=Object.defineProperties,u=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,g=(e,t,n)=>t in e?l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h=(e,t)=>{for(var n in t||(t={}))d.call(t,n)&&g(e,n,t[n]);if(p)for(var n of p(t))f.call(t,n)&&g(e,n,t[n]);return e},m=(e,t)=>c(e,u(t));function y(e,t,n){var l,c,u;const[p,d]=o.useState(),[f,g]=o.useState(),[y,x]=o.useState(),[v,b]=o.useState(),C=5/(null!=(l=null==n?void 0:n.scale)?l:1),E=null!=(c=null==n?void 0:n.readOnly)&&c,k=()=>{d(void 0),g(void 0),x(void 0),b(void 0)};return o.useEffect((()=>{!1===E&&k()}),[E]),{editPoint:p,editLastPosition:null!=(u=null==p?void 0:p.angleSnapStartPoint)?u:f,getEditAssistentContents(e,n){const r=[];if(!E){const o=null==t?void 0:t(e);o&&r.push(...o.editPoints.map((e=>n({x:e.x,y:e.y,width:C,height:C}))))}return r},updateEditPreview(){if(p&&f&&y&&p.update){const e=[],[t,o,i]=(0,r.produceWithPatches)(p.content,(t=>{var r,o;const i=null==(o=p.update)?void 0:o.call(p,t,{cursor:y,start:f,scale:null!=(r=null==n?void 0:n.scale)?r:1,target:v});(null==i?void 0:i.assistentContents)&&e.push(...i.assistentContents)})),a={content:p.content,result:t,patches:(0,s.prependPatchPath)(o,p.path),reversePatches:(0,s.prependPatchPath)(i,p.path),assistentContents:e,relatedEditPointResults:new Map};for(const t of p.relatedEditPoints){const[o,i,l]=(0,r.produceWithPatches)(t.content,(r=>{var o,i;const a=null==(i=t.update)?void 0:i.call(t,r,{cursor:y,start:f,scale:null!=(o=null==n?void 0:n.scale)?o:1});(null==a?void 0:a.assistentContents)&&e.push(...a.assistentContents)}));a.patches.push(...(0,s.prependPatchPath)(i,t.path)),a.reversePatches.push(...(0,s.prependPatchPath)(l,t.path)),a.relatedEditPointResults.set(t.content,o)}return a}},onEditMove(e,r,o){if(E)return;if((null==p?void 0:p.angleSnapStartPoint)?e=(0,a.getAngleSnapPosition)(p.angleSnapStartPoint,e,null==n?void 0:n.getAngleSnap):f&&(e=(0,a.getAngleSnapPosition)(f,e,null==n?void 0:n.getAngleSnap)),f)return x(e),void b(o);let s;for(const{content:n,path:o}of r){const r=null==t?void 0:t(n);if(r){const t=r.editPoints.find((t=>(0,i.getTwoNumbersDistance)(t.x,e.x)<=C&&(0,i.getTwoNumbersDistance)(t.y,e.y)<=C));t&&(s?s.relatedEditPoints.push(m(h({},t),{content:n,path:o})):s=m(h({},t),{content:n,path:o,angleSnapStartPoint:r.angleSnapStartPoint,relatedEditPoints:[]}))}}d(s)},onEditClick(t){if(p)if(p.execute){const[,t,n]=(0,r.produceWithPatches)(p.content,(e=>{var t;null==(t=p.execute)||t.call(p,e)}));e((0,s.prependPatchPath)(t,p.path),(0,s.prependPatchPath)(n,p.path))}else f?(e([],[]),k()):g(t)},resetEdit:k}}},447:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useCircleArcEdit:()=>s});var r=n(7378),o=n(9254),i=n(7386),a=n(5736);function s(e,t){const[n,s]=r.useState({x:0,y:0,r:0,startAngle:0,endAngle:0}),[l,c]=r.useState(),{onStart:u,mask:p,reset:d}=(0,a.useDragEdit)((()=>{s({x:0,y:0,r:0,startAngle:0,endAngle:0}),e()}),((e,n)=>{if(n=(0,i.getAngleSnapPosition)(e.data,n,null==t?void 0:t.getAngleSnap),c(n),"center"===e.data.type){const t=n.x-e.x,r=n.y-e.y;s({x:t,y:r,r:0,startAngle:0,endAngle:0,data:e.data.data})}else if("radius"===e.data.type){const t=(0,o.getTwoPointsDistance)(n,e.data)-e.data.r;s({x:0,y:0,r:t,startAngle:0,endAngle:0,data:e.data.data})}else if("start angle"===e.data.type){const t=(0,o.radianToAngle)((0,o.getTwoPointsRadian)(n,e.data))-e.data.startAngle;s({x:0,y:0,r:0,startAngle:t,endAngle:0,data:e.data.data})}else if("end angle"===e.data.type){const t=(0,o.radianToAngle)((0,o.getTwoPointsRadian)(n,e.data))-e.data.endAngle;s({x:0,y:0,r:0,startAngle:0,endAngle:t,data:e.data.data})}}),t);return{offset:n,onStart:u,mask:p,cursorPosition:l,reset(){s({x:0,y:0,r:0,startAngle:0,endAngle:0}),d()}}}},2877:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useCircleEdit:()=>s});var r=n(7378),o=n(9254),i=n(7386),a=n(5736);function s(e,t){const[n,s]=r.useState({x:0,y:0,r:0}),[l,c]=r.useState(),{onStart:u,mask:p,reset:d}=(0,a.useDragEdit)((()=>{s({x:0,y:0,r:0}),e()}),((e,n)=>{if(n=(0,i.getAngleSnapPosition)(e.data,n,null==t?void 0:t.getAngleSnap),c(n),"center"===e.data.type){const t=n.x-e.x,r=n.y-e.y;s({x:t,y:r,r:0,data:e.data.data})}else{const t=(0,o.getTwoPointsDistance)(n,e.data)-e.data.r;s({x:0,y:0,r:t,data:e.data.data})}}),t);return{cursorPosition:l,offset:n,onStart:u,mask:p,reset(){s({x:0,y:0,r:0}),d()}}}},5736:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useDragEdit:()=>g});var r=n(7378),o=n(9300),i=Object.defineProperty,a=Object.defineProperties,s=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable,p=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d=(e,t)=>{for(var n in t||(t={}))c.call(t,n)&&p(e,n,t[n]);if(l)for(var n of l(t))u.call(t,n)&&p(e,n,t[n]);return e},f=(e,t)=>a(e,s(t));function g(e,t,n){const[i,a]=r.useState();return{dragStartPosition:i,onStart(e,t){var r,o;e.stopPropagation(),a(f(d({},null!=(o=null==(r=null==n?void 0:n.transform)?void 0:r.call(n,{x:e.clientX,y:e.clientY}))?o:{x:e.clientX,y:e.clientY}),{data:t}))},reset(){a(void 0)},mask:i&&r.createElement(o.DragMask,{onDragging:e=>{var r,o;e.stopPropagation();let a={x:e.clientX,y:e.clientY};a=null!=(o=null==(r=null==n?void 0:n.transform)?void 0:r.call(n,a))?o:a,t(i,a)},onDragEnd:()=>{e(),a(void 0)},style:{cursor:i.data.cursor}})}}},2722:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useEllipseArcEdit:()=>s});var r=n(7378),o=n(9254),i=n(7386),a=n(5736);function s(e,t){const[n,s]=r.useState({cx:0,cy:0,rx:0,ry:0,startAngle:0,endAngle:0}),[l,c]=r.useState(),{onStart:u,mask:p,reset:d}=(0,a.useDragEdit)((()=>{s({cx:0,cy:0,rx:0,ry:0,startAngle:0,endAngle:0}),e()}),((e,n)=>{var r,a;if(n=(0,i.getAngleSnapPosition)({x:e.data.cx,y:e.data.cy},n,null==t?void 0:t.getAngleSnap),c(n),"center"===e.data.type){const t=n.x-e.x,r=n.y-e.y;s({cx:t,cy:r,rx:0,ry:0,startAngle:0,endAngle:0,data:e.data.data})}else if("start angle"===e.data.type){const t=(0,o.rotatePositionByCenter)(n,{x:e.data.cx,y:e.data.cy},null!=(r=e.data.angle)?r:0),i=(0,o.getEllipseAngle)(t,e.data)-e.data.startAngle;s({cx:0,cy:0,rx:0,ry:0,startAngle:i,endAngle:0,data:e.data.data})}else if("end angle"===e.data.type){const t=(0,o.rotatePositionByCenter)(n,{x:e.data.cx,y:e.data.cy},null!=(a=e.data.angle)?a:0),r=(0,o.getEllipseAngle)(t,e.data)-e.data.endAngle;s({cx:0,cy:0,rx:0,ry:0,startAngle:0,endAngle:r,data:e.data.data})}}),t);return{offset:n,onStart:u,mask:p,cursorPosition:l,reset(){s({cx:0,cy:0,rx:0,ry:0,startAngle:0,endAngle:0}),d()}}}},9988:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useEllipseEdit:()=>s});var r=n(7378),o=n(9254),i=n(7386),a=n(5736);function s(e,t){const[n,s]=r.useState({cx:0,cy:0,rx:0,ry:0}),[l,c]=r.useState(),{onStart:u,mask:p,reset:d}=(0,a.useDragEdit)((()=>{s({cx:0,cy:0,rx:0,ry:0}),e()}),((e,n)=>{if(n=(0,i.getAngleSnapPosition)({x:e.data.cx,y:e.data.cy},n,null==t?void 0:t.getAngleSnap),c(n),"center"===e.data.type){const t=n.x-e.x,r=n.y-e.y;s({cx:t,cy:r,rx:0,ry:0,data:e.data.data})}else{const t=(0,o.getTwoPointsDistance)(n,{x:e.data.cx,y:e.data.cy});"major axis"===e.data.type?s({cx:0,cy:0,rx:t-e.data.rx,ry:0,data:e.data.data}):s({cx:0,cy:0,rx:0,ry:t-e.data.ry,data:e.data.data})}}),t);return{offset:n,onStart:u,mask:p,cursorPosition:l,reset(){s({cx:0,cy:0,rx:0,ry:0}),d()}}}},4554:(e,t,n)=>{"use strict";n.r(t),n.d(t,{usePolylineEdit:()=>a});var r=n(7378),o=n(7386),i=n(5736);function a(e,t){const[n,a]=r.useState(),[s,l]=r.useState(),{onStart:c,mask:u,dragStartPosition:p,reset:d}=(0,i.useDragEdit)((()=>{a(void 0),e()}),((e,n)=>{n=(0,o.getAngleSnapPosition)(e,n,null==t?void 0:t.getAngleSnap),l(n);const r=n.x-e.x,i=n.y-e.y;a({x:r,y:i,pointIndexes:e.data.pointIndexes,data:e.data.data})}),t);return{offset:n,onStart(e,t,n){c(e,{pointIndexes:t,data:n,cursor:"move"})},mask:u,cursorPosition:s,dragStartPosition:p,reset(){a(void 0),d()}}}},1301:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useEvent:()=>o});var r=n(7378);function o(e){const t=r.useRef();return r.useLayoutEffect((()=>{t.current=e})),r.useCallback((e=>{var n;null==(n=t.current)||n.call(t,e)}),[])}},4507:(e,t,n)=>{"use strict";n.r(t),n.d(t,{compareLocations:()=>C,useFlowLayoutBlockEditor:()=>b,useFlowLayoutBlockOperation:()=>E});var r=n(5188),o=n(7378),i=n(9300),a=n(9254),s=n(1799),l=n(2997),c=n(2357),u=n(8533),p=Object.defineProperty,d=Object.defineProperties,f=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,h=Object.prototype.hasOwnProperty,m=Object.prototype.propertyIsEnumerable,y=(e,t,n)=>t in e?p(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x=(e,t)=>{for(var n in t||(t={}))h.call(t,n)&&y(e,n,t[n]);if(g)for(var n of g(t))m.call(t,n)&&y(e,n,t[n]);return e},v=(e,t)=>d(e,f(t));function b(e){var t,n,r,i,c;const{range:u,inputContent:p,inputInline:d,getCopiedContents:f,skipVoidBlock:g,scrollRef:h,scrollY:m,dragLocation:y,setY:v,selectionStart:b,setSelectionStart:k,ref:w,setLocation:S,location:P,contentHeight:R,setContentHeight:_,blockLocation:T,contentLocation:A,actualHeight:M,isSelected:L,onBlur:O,onMouseUp:I,onMouseDown:F,onMouseMove:D,onKeyDown:B}=E(e),[z,U]=o.useState(!1),N=(e=!1)=>{if(!e&&u)return k(void 0),void S(u.min);e&&void 0===b&&k(P),S(ue{if(!t&&u)return k(void 0),void S(u.max);t&&void 0===b&&k(P),pe>=Z.length-1?S([e.state.length-1,e.state[e.state.length-1].children.length]):S(V({x:ce,y:ue+Z[pe]+Z[pe+1]/2+m},!1))},W=e=>{B(e,N,j)},G=e=>{const t=e.target.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}},V=(t,n=!0,r)=>{for(let o=0;o0&&X[o][0].y>t.y)return g([o,0],r);const i=(0,a.getFlowLayoutLocation)(t,Z,X[o],m,(t=>e.getWidth(t,e.state[o])),n,e.getHeight);if(void 0!==i)return U(i.lineEnd),g([o,i.location],r)}return[e.state.length-1,e.state[e.state.length-1].children.length]},$=t=>{if(u)for(let n=0;n=0&&C(r,u.max)<0&&t.x>i.x&&t.y>i.y&&t.x{F(e,G,V,$)},q=e=>{D(e,G,(e=>V(e,!1)),0,ne,re)},Y=e=>{q(e),I()},X=[];let K=0;const Z=[];let Q=0,J=0;const ee=e.getComposition,te=e.lineHeight;if(e.state.forEach(((t,n)=>{var r,o,i,s;const l=t.listStyleType&&(null==(r=e.isSameType)?void 0:r.call(e,t,e.state[n-1]))?0:null!=(o=t.blockStart)?o:0,c=t.listStyleType&&(null==(i=e.isSameType)?void 0:i.call(e,t,e.state[n+1]))?0:null!=(s=t.blockEnd)?s:0,u=Math.max(l,J),p=(0,a.flowLayout)({state:t.children,width:e.width,height:e.autoHeight?void 0:e.height,lineHeight:"number"==typeof te?te:e=>te(e,t),getWidth:n=>e.getWidth(n,t),isNewLineContent:e.isNewLineContent,isPartOfComposition:e.isPartOfComposition,getComposition:ee?e=>ee(n,e):void 0,endContent:e.endContent,scrollX:t.inlineStart,scrollY:m+K+u,row:Q,align:e.align});X.push(p.layoutResult),t.void||(K+=p.newContentHeight),K+=u,Z.push(...p.lineHeights),Q+=p.lineHeights.length,J=c})),K+=J,e.height&&("middle"===e.verticalAlign||"bottom"===e.verticalAlign)){let t=e.height-K;t>0&&("middle"===e.verticalAlign&&(t/=2),X.forEach((e=>{e.forEach((e=>{e.y+=t}))})))}R0&&(null==ae?void 0:ae[oe-1]);se&&oe--;const le=null==ae?void 0:ae[oe],ce=(null!=(r=null==le?void 0:le.x)?r:0)+(se?e.getWidth(null==ae?void 0:ae[oe].content,e.state[ie]):0),ue=(null!=(i=null==le?void 0:le.y)?i:0)-m,pe=null!=(c=null==le?void 0:le.row)?c:0,de=o.useRef(),fe=o.useRef();return o.useEffect((()=>{var t,n;if((0,a.equals)(null==(t=de.current)?void 0:t[0],P[0])&&(0,a.equals)(null==(n=de.current)?void 0:n[1],P[1])&&(0,a.equals)(fe.current,ue)||e.autoHeight)return;const r=ue+m;r<0?v(-ue):r>e.height-re&&v(e.height-re-ue),de.current=P,fe.current=ue}),[P,ue,m,re]),{ref:w,range:u,layoutResult:X,lineHeights:Z,cursor:{x:ce,y:ue+m,row:pe},inputContent:p,inputInline:d,location:P,setLocation:S,getCopiedContents:f,isSelected:L,actualHeight:M,setSelectionStart:k,getPosition:G,positionToLocation:V,scrollY:m,renderEditor:t=>o.createElement("div",{style:x({position:"relative",width:e.width+"px",height:M+"px",border:"1px solid black",clipPath:"inset(0px 0px)"},e.style),onMouseLeave:Y,ref:h},o.createElement(s.Cursor,{ref:w,onKeyDown:W,onCompositionEnd:e.onCompositionEnd,onBlur:O,onFocus:e.onFocus,readOnly:e.readOnly,style:{left:ce+"px",top:ue+m+"px",height:Z[pe]+"px"}}),t,o.createElement("div",{onMouseDown:H,onMouseMove:q,onMouseUp:Y,onDoubleClick:e.onDoubleClick,style:{inset:"0px",cursor:"text",position:"absolute"}}),!e.autoHeight&&o.createElement(l.Scrollbar,{value:m,type:"vertical",containerSize:e.height,contentSize:R,onChange:v,align:"head"}))}}function C(e,t){return e[0]t[0]?1:e[1]t[1]?1:0}function E(e){const[t,n]=o.useState([0,0]),[a,s]=t,[l,p]=o.useState(),d=o.useRef(null),[f,g]=o.useState(0),h=void 0!==l?C(l,t)>0?{min:t,max:l}:{min:l,max:t}:void 0,m=r=>{if(!e.readOnly){if(h)return p(void 0),n([h.min[0]+r.length+1,0]),void e.setState((e=>{y(e,r)}));n([a+r.length+1,0]),e.setState((e=>{b(e,r,t)}))}},y=(t,n)=>{if(!h)return;const[o,i]=h.min,[a,s]=h.max;t[o].children.splice(i,e.state[o].children.length),a>o?(t[a].children.splice(0,s),t.splice(o+1,a-o-1,...(0,r.castDraft)(n))):t.splice(o+1,0,...(0,r.castDraft)(n),(0,r.castDraft)(v(x({},e.state[o]),{children:e.state[o].children.slice(s)})))},b=(t,n,o)=>{t[o[0]].children.splice(o[1],e.state[o[0]].children.length-o[1]),t.splice(o[0]+1,0,...(0,r.castDraft)(n),(0,r.castDraft)(v(x({},e.state[o[0]]),{children:e.state[o[0]].children.slice(o[1])})))},E=(t,n)=>{if(!h)return;const[o,i]=h.min,[a,s]=h.max,l=a>o?[...n,...e.state[a].children.slice(s)]:n,c=(o===a?s:e.state[o].children.length)-i;t[o].children.splice(i,c,...(0,r.castDraft)(l)),a>o&&t.splice(o+1,a-o)},k=(e,t,n)=>{e[n[0]].children.splice(n[1],0,...(0,r.castDraft)(t))},w=()=>{if(!e.readOnly)return h?(n(h.min),p(void 0),void e.setState((e=>{E(e,[])}))):void(0===a&&0===s||(0!==s?(n([a,s-1]),e.setState((e=>{e[a].children.splice(s-1,1)}))):(n([a-1,e.state[a-1].children.length]),e.setState((e=>{e[a-1].children.push(...e[a].children),e.splice(a,1)})))))},S=t=>{const[n,r]=t.min,[o,i]=t.max,a=n===o?i:e.state[n].children.length,s=[v(x({},e.state[n]),{children:e.state[n].children.slice(r,a)})];for(let t=n+1;tn&&s.push(v(x({},e.state[o]),{children:e.state[o].children.slice(0,i)})),s},P=([t,n],r)=>{for(;e.state[t].void;)r?(t--,n=e.state[t].children.length):(t++,n=0);return[t,n]},R=o.useRef(),[_,T]=o.useState();(0,i.useGlobalMouseUp)((0,i.useEvent)((()=>{R.current=void 0,T(void 0)})));const{ref:A,y:M,setY:L,filterY:O}=(0,u.useWheelScroll)({minY:e.autoHeight?0:f>e.height?e.height-f:0,maxY:0,disabled:e.autoHeight});o.useEffect((()=>{e.autoHeight&&L(0)}),[e.autoHeight,L]);let I=e.height;return e.autoHeight&&f>e.height&&(I=f),o.useEffect((()=>{var n;null==(n=e.onLocationChanged)||n.call(e,t)}),[t]),{range:h,inputContent:m,inputInline:r=>{if(!e.readOnly){if(h){const[t,o]=h.min;return p(void 0),n([t,o+r.length]),void e.setState((e=>{E(e,r)}))}n([a,s+r.length]),e.setState((e=>{k(e,r,t)}))}},getCopiedContents:(e=!1)=>{if(void 0!==h)return e&&w(),S(h)},skipVoidBlock:P,scrollRef:A,scrollY:M,dragLocation:_,setY:L,selectionStart:l,setSelectionStart:p,ref:d,setLocation:n,location:t,contentHeight:f,setContentHeight:g,blockLocation:a,contentLocation:s,isSelected:e=>h&&C(e,h.min)>=0&&C(e,h.max)<0,actualHeight:I,onBlur:()=>{var t,n;e.keepSelectionOnBlur||p(void 0),null==(t=e.onLocationChanged)||t.call(e),null==(n=e.onBlur)||n.call(e)},onMouseUp:()=>{var t;if(void 0!==_&&h){if(C(_,h.min)<0){const t=S(h);if(1===t.length){const r=t[0].children;e.setState((e=>{E(e,[]),k(e,r,_)})),n([_[0],_[1]+r.length]),p(_)}else e.setState((e=>{E(e,[]),b(e,t,_)})),n([_[0]+t.length+1,0]),p([_[0]+1,0])}else if(C(_,h.max)>0){const t=S(h);if(1===t.length){const r=t[0].children;e.setState((e=>{k(e,r,_),E(e,[])})),p([_[0],_[1]-r.length]),n(_)}else e.setState((e=>{b(e,t,_),E(e,[])})),n([_[0]+2,0]),p([_[0]-t.length+2,0])}T(void 0)}null==(t=d.current)||t.focus()},onMouseDown:(e,r,o,i)=>{e.preventDefault();const a=r(e),s=o(a);if(e.shiftKey)void 0===l&&p(t),n(s);else{if(i(a))return void T(s);R.current=s}},onMouseMove:(t,r,o,i,a,s)=>{if(void 0===R.current)return void(void 0!==_&&T(o(r(t))));const l=r(t),c=o(l);if(n(c),c[0]===R.current[0]&&c[1]===R.current[1]?p(void 0):p(R.current),!e.autoHeight){const t=l.y+i;t>=0&&t<=a?L((e=>O(e+2))):t<=e.height&&t>=e.height-s&&L((e=>O(e-2)))}},onKeyDown:(r,o,i,u)=>{var d;if(!r.nativeEvent.isComposing&&229!==r.keyCode&&!(null==(d=e.processInput)?void 0:d.call(e,r))){if("Enter"===r.key)return m([]),!0;if(!["CapsLock","Tab","Shift","Meta","Escape","Control"].includes(r.key)){if("Backspace"===r.key)return w();if("Delete"===r.key)return(()=>{if(!e.readOnly)return h?(n(h.min),p(void 0),void e.setState((e=>{E(e,[])}))):void(a===e.state.length-1&&s===e.state[e.state.length-1].children.length||(s!==e.state[a].children.length?e.setState((e=>{e[a].children.splice(s,1)})):e.setState((e=>{e[a].children.push(...e[a+1].children),e.splice(a+1,1)}))))})();if("ArrowLeft"===r.key)return((r=!1)=>{if(!r&&h)return p(void 0),void n(h.min);0===a&&0===s||(r&&void 0===l&&p(t),n(0!==s?[a,s-1]:P([a-1,e.state[a-1].children.length],!0)))})(r.shiftKey);if("ArrowRight"===r.key)return((r=!1)=>{if(!r&&h)return p(void 0),void n(h.max);a===e.state.length-1&&s===e.state[e.state.length-1].children.length||(r&&void 0===l&&p(t),s!==e.state[a].children.length?n([a,s+1]):n(P([a+1,0])))})(r.shiftKey);if("ArrowUp"===r.key)return o(r.shiftKey);if("ArrowDown"===r.key)return i(r.shiftKey);if((0,c.metaKeyIfMacElseCtrlKey)(r)){if("a"===r.key)return p([0,0]),void n([e.state.length-1,e.state[e.state.length-1].children.length])}else r.preventDefault();null==u||u()}}}}}},1497:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useFlowLayoutEditor:()=>x});var r=n(7378),o=n(7310),i=n(9195),a=n(1799),s=n(2997),l=n(1301),c=n(1502),u=n(2357),p=n(8533),d=Object.defineProperty,f=Object.getOwnPropertySymbols,g=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable,m=(e,t,n)=>t in e?d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y=(e,t)=>{for(var n in t||(t={}))g.call(t,n)&&m(e,n,t[n]);if(f)for(var n of f(t))h.call(t,n)&&m(e,n,t[n]);return e};function x(e){var t;const[n,d]=r.useState(0),[f,g]=r.useState(),h=r.useRef(null),[m,x]=r.useState(0),[v,b]=r.useState(!1),C=()=>{if(!e.readOnly)return j?(d(j.min),g(void 0),void e.setState((e=>{e.splice(j.min,j.size)}))):void(0!==n&&(d(n-1),e.setState((e=>{e.splice(n-1,1)}))))},E=t=>{var r;if(!t.nativeEvent.isComposing&&229!==t.keyCode&&!(null==(r=e.processInput)?void 0:r.call(e,t))&&!["CapsLock","Tab","Shift","Meta","Escape","Control"].includes(t.key)){if("Backspace"===t.key)return C();if("Delete"===t.key)return(()=>{if(!e.readOnly)return j?(d(j.min),g(void 0),void e.setState((e=>{e.splice(j.min,j.size)}))):void(n!==e.state.length&&e.setState((e=>{e.splice(n,1)})))})();if("ArrowLeft"===t.key)return((e=!1)=>{if(!e&&j)return g(void 0),void d(j.min);0!==n&&(e&&void 0===f&&g(n),d(n-1))})(t.shiftKey);if("ArrowRight"===t.key)return((t=!1)=>{if(!t&&j)return g(void 0),void d(j.max);n!==e.state.length&&(t&&void 0===f&&g(n),d(n+1))})(t.shiftKey);if("ArrowUp"===t.key)return((e=!1)=>{if(!e&&j)return g(void 0),void d(j.min);e&&void 0===f&&g(n),d(H{if(!t&&j)return g(void 0),void d(j.max);t&&void 0===f&&g(n),q>=z.length-1?d(e.state.length):d(_({x:$,y:H+z[q]+z[q+1]/2+O},!1))})(t.shiftKey);if((0,u.metaKeyIfMacElseCtrlKey)(t)){if("a"===t.key)return g(0),void d(e.state.length)}else t.preventDefault()}},k=()=>{var t,n;e.keepSelectionOnBlur||g(void 0),null==(t=e.onLocationChanged)||t.call(e,-1),null==(n=e.onBlur)||n.call(e)},w=r.useRef(),[S,P]=r.useState(),R=e=>{const t=e.target.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}},_=(t,n=!0)=>{const r=(0,o.getFlowLayoutLocation)(t,z,D,O,e.getWidth,n);return r?(b(r.lineEnd),r.location):D.length-1},T=t=>{t.preventDefault();const r=R(t),o=_(r);if(t.shiftKey)(void 0===f||Math.abs(f-o){if(j)for(let n=j.min;nr.x&&t.y>r.y&&t.x{if(void 0===w.current)return void(void 0!==S&&P(_(R(t),!1)));const n=R(t),r=_(n,!1);d(r),r===w.current?g(void 0):g(w.current),e.autoHeight||(n.y>=0&&n.y<=U?I((e=>F(e+2))):n.y<=e.height&&n.y>=e.height-N&&I((e=>F(e-2))))},M=t=>{var n;A(t),void 0!==S&&j&&(S{e.splice(S,0,...e.splice(j.min,j.size))})),d(S+j.size),g(S)):S>j.max&&(e.setState((e=>{e.splice(S-j.size,0,...e.splice(j.min,j.size))})),d(S),g(S-j.size)),P(void 0)),null==(n=h.current)||n.focus()};(0,c.useGlobalMouseUp)((0,l.useEvent)((()=>{w.current=void 0,P(void 0)})));const{ref:L,y:O,setY:I,filterY:F}=(0,p.useWheelScroll)({minY:e.autoHeight?0:m>e.height?e.height-m:0,maxY:0,disabled:e.autoHeight});r.useEffect((()=>{e.autoHeight&&I(0)}),[e.autoHeight,I]);const{layoutResult:D,newContentHeight:B,lineHeights:z}=(0,o.flowLayout)({state:e.state,width:e.width,height:e.autoHeight?void 0:e.height,lineHeight:e.lineHeight,getWidth:e.getWidth,isNewLineContent:e.isNewLineContent,isPartOfComposition:e.isPartOfComposition,getComposition:e.getComposition,endContent:e.endContent,scrollY:O,align:e.align,verticalAlign:e.verticalAlign});m