@univerjs/preset-docs-drawing 0.7.0-beta.1 → 0.7.0-nightly.202505071607
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.css +1 -1
- package/lib/umd/index.js +7 -7
- package/package.json +8 -9
package/lib/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.univer-h-9{height:36px}.univer-w-1\/2{width:50%}.univer-justify-center{justify-content:center}.univer-justify-between{justify-content:space-between}.univer-gap-2{gap:8px}.univer-rounded{border-radius:4px}.univer-border{border-width:1px}.univer-border-b-0{border-bottom-width:0px}.univer-border-l-0{border-left-width:0px}.univer-border-r-0{border-right-width:0px}.univer-border-t-gray-200{border-top-color:var(--univer-gray-200)}.univer-bg-gray-100{background-color:var(--univer-gray-100)}.univer-bg-white{background-color:var(--univer-white)}.univer-fill-primary-600{fill:var(--univer-primary-600)}.univer-p-1{padding:4px}.univer-text-left{text-align:left}.univer-text-gray-900{color:var(--univer-gray-900)}.hover\:univer-bg-gray-100:hover{background-color:var(--univer-gray-100)}.univer-relative{position:relative}.univer-mt-2\.5{margin-top:10px}.univer-mt-5{margin-top:20px}.univer-flex{display:flex}.univer-h-full{height:100%}.univer-w-full{width:100%}.univer-items-start{align-items:flex-start}.univer-items-center{align-items:center}.univer-justify-start{justify-content:flex-start}.univer-gap-1{gap:4px}.univer-border-t{border-top-width:1px}.univer-border-solid{border-style:solid}.univer-border-gray-200{border-color:var(--univer-gray-200)}.univer-p-2{padding:8px}.univer-text-center{text-align:center}.univer-text-sm{font-size:14px;line-height:20px}.univer-text-black{color:var(--univer-black)}.univer-text-gray-400{color:var(--univer-gray-400)}.univer-text-gray-600{color:var(--univer-gray-600)}
|
|
1
|
+
.univer-block{display:block}.univer-size-full{width:100%;height:100%}.univer-h-9{height:36px}.univer-w-1\/2{width:50%}.univer-justify-center{justify-content:center}.univer-justify-between{justify-content:space-between}.univer-gap-2{gap:8px}.univer-rounded{border-radius:4px}.univer-border{border-width:1px}.univer-border-b-0{border-bottom-width:0px}.univer-border-l-0{border-left-width:0px}.univer-border-r-0{border-right-width:0px}.univer-border-t-gray-200{border-top-color:var(--univer-gray-200)}.univer-bg-gray-100{background-color:var(--univer-gray-100)}.univer-bg-white{background-color:var(--univer-white)}.univer-fill-primary-600{fill:var(--univer-primary-600)}.univer-p-1{padding:4px}.univer-py-2{padding-top:8px;padding-bottom:8px}.univer-text-left{text-align:left}.univer-text-\[10px\]{font-size:10px}.univer-text-gray-900{color:var(--univer-gray-900)}.hover\:univer-bg-gray-100:hover{background-color:var(--univer-gray-100)}.univer-relative{position:relative}.univer-mt-2\.5{margin-top:10px}.univer-mt-5{margin-top:20px}.univer-flex{display:flex}.univer-h-full{height:100%}.univer-w-full{width:100%}.univer-items-start{align-items:flex-start}.univer-items-center{align-items:center}.univer-justify-start{justify-content:flex-start}.univer-gap-1{gap:4px}.univer-border-t{border-top-width:1px}.univer-border-solid{border-style:solid}.univer-border-gray-200{border-color:var(--univer-gray-200)}.univer-p-2{padding:8px}.univer-text-center{text-align:center}.univer-text-sm{font-size:14px;line-height:20px}.univer-text-black{color:var(--univer-black)}.univer-text-gray-400{color:var(--univer-gray-400)}.univer-text-gray-600{color:var(--univer-gray-600)}
|
package/lib/umd/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
// @univerjs/drawing-ui/index
|
|
2
|
-
(function(I,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("@univerjs/core"),require("@univerjs/drawing"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("react/jsx-runtime"),require("react"),require("@univerjs/design"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing","@univerjs/engine-render","@univerjs/ui","react/jsx-runtime","react","@univerjs/design","rxjs"],h):(I=typeof globalThis<"u"?globalThis:I||self,h(I.UniverDrawingUi={},I.UniverCore,I.UniverDrawing,I.UniverEngineRender,I.UniverUi,I.React,I.React,I.UniverDesign,I.rxjs))})(this,function(I,h,D,y,
|
|
2
|
+
(function(I,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("@univerjs/core"),require("@univerjs/drawing"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("react/jsx-runtime"),require("react"),require("@univerjs/design"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing","@univerjs/engine-render","@univerjs/ui","react/jsx-runtime","react","@univerjs/design","rxjs"],h):(I=typeof globalThis<"u"?globalThis:I||self,h(I.UniverDrawingUi={},I.UniverCore,I.UniverDrawing,I.UniverEngineRender,I.UniverUi,I.React,I.React,I.UniverDesign,I.rxjs))})(this,function(I,h,D,y,W,l,_,P,Ee){"use strict";var xt=Object.defineProperty;var Ht=(I,h,D)=>h in I?xt(I,h,{enumerable:!0,configurable:!0,writable:!0,value:D}):I[h]=D;var te=(I,h,D)=>Ht(I,typeof h!="symbol"?h+"":h,D);var Oe;function Te(i,r,t,e){const n=e.getDrawingByParam(i);if(n==null)return;const s=D.getDrawingShapeKeyByDrawingSearch(i),a=t.getObject(s);if(a&&!(a instanceof y.Group))return;if(a!=null){a.addObject(r);return}const o=new y.Group(s);t.addObject(o,y.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(o),o.addObject(r);const{transform:c}=n;c&&o.transformByState({left:c.left,top:c.top,angle:c.angle})}function Pe(i,r){var s;const t=r?i.getUnit(r):i.getFocusedUnit();if(t==null)return;const e=t.getUnitId();let n;return t.type===h.UniverInstanceType.UNIVER_SHEET?n=(s=t.getActiveSheet())==null?void 0:s.getSheetId():(t.type===h.UniverInstanceType.UNIVER_DOC||t.type===h.UniverInstanceType.UNIVER_SLIDE)&&(n=e),{unitId:e,subUnitId:n,current:t}}const Be="COMPONENT_IMAGE_VIEWER";var Xe=Object.getOwnPropertyDescriptor,qe=(i,r,t,e)=>{for(var n=e>1?void 0:e?Xe(r,t):r,s=i.length-1,a;s>=0;s--)(a=i[s])&&(n=a(n)||n);return n},De=(i,r)=>(t,e)=>r(t,e,i);const Ue=50;I.DrawingRenderService=class{constructor(r,t,e){this._drawingManagerService=r,this._imageIoService=t,this._dialogService=e}async renderImages(r,t){const{transform:e,drawingType:n,source:s,imageSourceType:a,srcRect:o,prstGeom:c,groupId:d,unitId:u,subUnitId:g,drawingId:f,isMultiTransform:p,transforms:S}=r;if(n!==h.DrawingTypeEnum.DRAWING_IMAGE||!this._drawingManagerService.getDrawingVisible()||e==null)return;const w=p&&S?S:[e],m=[];for(const b of w){const{left:C,top:B,width:M,height:A,angle:E,flipX:O,flipY:N,skewX:T,skewY:U}=b,V=w.indexOf(b),x=D.getDrawingShapeKeyByDrawingSearch({unitId:u,subUnitId:g,drawingId:f},p?V:void 0),Y=t.getObject(x);if(Y!=null){Y.transformByState({left:C,top:B,width:M,height:A,angle:E,flipX:O,flipY:N,skewX:T,skewY:U});continue}const K=this._drawingManagerService.getDrawingOrder(u,g),de=K.indexOf(f),se={...b,zIndex:de===-1?K.length-1:de},oe=this._imageIoService.getImageSourceCache(s,a);let ue=!1;if(oe!=null)se.image=oe;else{if(a===D.ImageSourceType.UUID)try{se.url=await this._imageIoService.getImage(s)}catch(Ne){console.error(Ne);continue}else se.url=s;ue=!0}if(t.getObject(x))continue;se.printable=!0;const Q=new y.Image(x,se);ue&&this._imageIoService.addImageSourceCache(s,a,Q.getNative()),this._drawingManagerService.getDrawingVisible()&&(t.addObject(Q,y.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&t.attachTransformerTo(Q),d&&Te({drawingId:d,unitId:u,subUnitId:g},Q,t,this._drawingManagerService),c!=null&&Q.setPrstGeom(c),o!=null&&Q.setSrcRect(o),m.push(Q))}return m}renderFloatDom(r,t){const{transform:e,drawingType:n,groupId:s,unitId:a,subUnitId:o,drawingId:c,isMultiTransform:d,transforms:u}=r;if(n!==h.DrawingTypeEnum.DRAWING_DOM||!this._drawingManagerService.getDrawingVisible()||e==null)return;const g=d&&u?u:[e],f=[];for(const p of g){const{left:S,top:w,width:m,height:b,angle:C,flipX:B,flipY:M,skewX:A,skewY:E}=p,O=g.indexOf(p),N=D.getDrawingShapeKeyByDrawingSearch({unitId:a,subUnitId:o,drawingId:c},d?O:void 0),T=t.getObject(N);if(T!=null){T.transformByState({left:S,top:w,width:m,height:b,angle:C,flipX:B,flipY:M,skewX:A,skewY:E});continue}const U=this._drawingManagerService.getDrawingOrder(a,o),V=U.indexOf(c),x={...p,zIndex:V===-1?U.length-1:V};if(t.getObject(N))continue;x.printable=!1;const Y=new y.Rect(N,x);this._drawingManagerService.getDrawingVisible()&&(t.addObject(Y,y.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&r.allowTransform!==!1&&t.attachTransformerTo(Y),s&&Te({drawingId:s,unitId:a,subUnitId:o},Y,t,this._drawingManagerService),f.push(Y))}return f}renderDrawing(r,t){const e=this._drawingManagerService.getDrawingByParam(r);if(e!=null)switch(e.drawingType){case h.DrawingTypeEnum.DRAWING_IMAGE:return this.renderImages(e,t)}}previewImage(r,t,e,n){const s=`${r}-viewer-dialog`,a=window.innerWidth-Ue,o=window.innerHeight-Ue,c=this._adjustImageSize(e,n,a,o),d=this._dialogService.open({width:Math.max(c.width,200),id:s,children:{label:{name:Be,props:{src:t,width:c.width,height:c.height}}},destroyOnClose:!0,closable:!1,onClose:()=>{this._dialogService.close(s),d.dispose()}})}_adjustImageSize(r,t,e,n){if(r<=e&&t<=n)return{width:r,height:t};const s=e/r,a=n/t,o=Math.min(s,a);return{width:Math.floor(r*o),height:Math.floor(t*o)}}},I.DrawingRenderService=qe([De(0,D.IDrawingManagerService),De(1,D.IImageIoService),De(2,W.IDialogService)],I.DrawingRenderService);function ge(i,r){const t=[];return i.forEach(e=>{const{oKey:n,left:s,top:a,height:o,width:c,angle:d}=e,u=r.getDrawingOKey(n);if(u==null)return t.push(null),!0;const{unitId:g,subUnitId:f,drawingId:p,drawingType:S}=u,w={unitId:g,subUnitId:f,drawingId:p,drawingType:S,transform:{left:s,top:a,height:o,width:c,angle:d}};S===h.DrawingTypeEnum.DRAWING_IMAGE&&(w.srcRect=e.srcRect),t.push(w)}),t}var j=(i=>(i.default="0",i.left="1",i.center="2",i.right="3",i.top="4",i.middle="5",i.bottom="6",i.horizon="7",i.vertical="8",i))(j||{});const ve={id:"sheet.operation.set-image-align",type:h.CommandType.OPERATION,handler:(i,r)=>!0},Je=i=>{const r=W.useDependency(h.ICommandService),t=W.useDependency(h.LocaleService),{alignShow:e}=i,[n,s]=_.useState(j.default),a=[{label:t.t("image-panel.align.default"),value:j.default},{options:[{label:t.t("image-panel.align.left"),value:j.left},{label:t.t("image-panel.align.center"),value:j.center},{label:t.t("image-panel.align.right"),value:j.right}]},{options:[{label:t.t("image-panel.align.top"),value:j.top},{label:t.t("image-panel.align.middle"),value:j.middle},{label:t.t("image-panel.align.bottom"),value:j.bottom}]},{options:[{label:t.t("image-panel.align.horizon"),value:j.horizon},{label:t.t("image-panel.align.vertical"),value:j.vertical}]}];function o(d){s(d),r.executeCommand(ve.id,{alignType:d})}const c=d=>d?"block":"none";return l.jsxs("div",{className:`
|
|
3
3
|
univer-relative univer-w-full univer-border-l-0 univer-border-r-0 univer-border-t univer-border-solid
|
|
4
4
|
univer-border-gray-200
|
|
5
|
-
`,style:{display:
|
|
5
|
+
`,style:{display:c(e)},children:[l.jsx("div",{className:`
|
|
6
6
|
univer-relative univer-mt-2.5 univer-flex univer-h-full univer-items-start univer-justify-start
|
|
7
|
-
`,children:
|
|
7
|
+
`,children:l.jsx("div",{className:"univer-w-full univer-text-gray-900",children:l.jsx("div",{children:t.t("image-panel.align.title")})})}),l.jsx("div",{className:`
|
|
8
8
|
univer-relative univer-mt-2.5 univer-flex univer-h-full univer-items-start univer-justify-start
|
|
9
|
-
`,children:c.jsx("div",{className:"univer-w-full univer-text-gray-900",children:c.jsx(P.Select,{value:n,options:a,onChange:o})})})]})};var F=function(){return F=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},F.apply(this,arguments)},qe=function(i,r){var t={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&r.indexOf(e)<0&&(t[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,e=Object.getOwnPropertySymbols(i);n<e.length;n++)r.indexOf(e[n])<0&&Object.prototype.propertyIsEnumerable.call(i,e[n])&&(t[e[n]]=i[e[n]]);return t},q=_.forwardRef(function(i,r){var t=i.icon,e=i.id,n=i.className,s=i.extend,a=qe(i,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(e," ").concat(n||"").trim(),l=_.useRef("_".concat(et()));return Be(t,"".concat(e),{defIds:t.defIds,idSuffix:l.current},F({ref:r,className:o},a),s)});function Be(i,r,t,e,n){return _.createElement(i.tag,F(F({key:r},Je(i,t,n)),e),(Qe(i,t).children||[]).map(function(s,a){return Be(s,"".concat(r,"-").concat(i.tag,"-").concat(a),t,void 0,n)}))}function Je(i,r,t){var e=F({},i.attrs);t!=null&&t.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=t.colorChannel1),i.tag==="mask"&&e.id&&(e.id=e.id+r.idSuffix),Object.entries(e).forEach(function(s){var a=s[0],o=s[1];a==="mask"&&typeof o=="string"&&(e[a]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))});var n=r.defIds;return!n||n.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+r.idSuffix),Object.entries(e).forEach(function(s){var a=s[0],o=s[1];typeof o=="string"&&(e[a]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))})),e}function Qe(i,r){var t,e=r.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?F(F({},i),{children:i.children.map(function(n){return typeof n.attrs.id=="string"&&e&&e.indexOf(n.attrs.id)>-1?F(F({},n),{attrs:F(F({},n.attrs),{id:n.attrs.id+r.idSuffix})}):n})}):i}function et(){return Math.random().toString(36).substring(2,8)}q.displayName="UniverIcon";var tt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M11.0363 12.2367V14.0367C11.0363 14.3681 11.3049 14.6367 11.6363 14.6367C11.9676 14.6367 12.2363 14.3681 12.2363 14.0367V12.2367H14.0364C14.3677 12.2367 14.6364 11.9681 14.6364 11.6367C14.6364 11.3054 14.3677 11.0367 14.0364 11.0367H12.2363V9.23672C12.2363 8.90535 11.9676 8.63672 11.6363 8.63672C11.3049 8.63672 11.0363 8.90535 11.0363 9.23672V11.0367H9.23635C8.90498 11.0367 8.63635 11.3054 8.63635 11.6367C8.63635 11.9681 8.90498 12.2367 9.23635 12.2367H11.0363Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.56365 1.36377C1.90091 1.36377 1.36365 1.90103 1.36365 2.56377V6.16377C1.36365 6.82651 1.90091 7.36377 2.56365 7.36377H6.16365C6.82639 7.36377 7.36365 6.82651 7.36365 6.16377V2.56377C7.36365 1.90103 6.82639 1.36377 6.16365 1.36377H2.56365zM6.16365 2.56377H2.56365L2.56365 6.16377H6.16365V2.56377zM2.56365 8.63647C1.90091 8.63647 1.36365 9.17373 1.36365 9.83647V13.4365C1.36365 14.0992 1.90091 14.6365 2.56365 14.6365H6.16365C6.82639 14.6365 7.36365 14.0992 7.36365 13.4365V9.83647C7.36365 9.17373 6.82639 8.63647 6.16365 8.63647H2.56365zM6.16365 9.83647H2.56365L2.56365 13.4365H6.16365V9.83647zM9.83635 7.36377C9.17361 7.36377 8.63635 6.82651 8.63635 6.16377V2.56377C8.63635 1.90103 9.17361 1.36377 9.83635 1.36377H13.4364C14.0991 1.36377 14.6364 1.90103 14.6364 2.56377V6.16377C14.6364 6.82651 14.0991 7.36377 13.4364 7.36377H9.83635zM9.83635 6.16377V2.56377L13.4364 2.56377V6.16377H9.83635z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ue=_.forwardRef(function(i,r){return _.createElement(q,Object.assign({},i,{id:"autofill",ref:r,icon:tt}))});Ue.displayName="Autofill";var rt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.0045 4.4334C14.8881 4.4334 15.6045 3.71705 15.6045 2.8334 15.6045 1.94974 14.8881 1.2334 14.0045 1.2334H3.70449C2.82084 1.2334 2.10449 1.94974 2.10449 2.8334 2.10449 3.71705 2.82084 4.4334 3.70449 4.4334H14.0045zM14.4045 2.8334C14.4045 3.05431 14.2254 3.2334 14.0045 3.2334H3.70449C3.48358 3.2334 3.30449 3.05431 3.30449 2.8334 3.30449 2.61248 3.48358 2.4334 3.70449 2.4334H14.0045C14.2254 2.4334 14.4045 2.61249 14.4045 2.8334zM14.1544 8.5999C15.038 8.5999 15.7544 7.88356 15.7544 6.9999 15.7544 6.11625 15.038 5.3999 14.1544 5.3999H3.85439C2.97074 5.3999 2.25439 6.11625 2.25439 6.9999 2.25439 7.88356 2.97074 8.5999 3.85439 8.5999H14.1544zM14.5544 6.9999C14.5544 7.22082 14.3753 7.3999 14.1544 7.3999H3.85439C3.63348 7.3999 3.45439 7.22082 3.45439 6.9999 3.45439 6.77899 3.63348 6.5999 3.85439 6.5999H14.1544C14.3753 6.5999 14.5544 6.77899 14.5544 6.9999z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.57975 14.5902L6.58023 12.5907C6.34591 12.3564 6.34591 11.9765 6.58023 11.7421 6.81454 11.5078 7.19444 11.5078 7.42876 11.7421L8.40449 12.7179V10.1664C8.40449 9.83504 8.67312 9.56641 9.00449 9.56641 9.33586 9.56641 9.60449 9.83504 9.60449 10.1664V12.7179L10.5802 11.7421C10.8145 11.5078 11.1944 11.5078 11.4288 11.7421 11.6631 11.9765 11.6631 12.3564 11.4288 12.5907L9.42923 14.5902M8.57975 14.5902C8.58121 14.5917 8.58268 14.5931 8.58416 14.5946 8.64077 14.6502 8.70566 14.6923 8.77482 14.7209 8.84557 14.7502 8.92314 14.7664 9.00449 14.7664 9.08585 14.7664 9.16342 14.7502 9.23416 14.7209 9.30332 14.6923 9.36821 14.6502 9.42482 14.5946"}}]},je=_.forwardRef(function(i,r){return _.createElement(q,Object.assign({},i,{id:"bottom-single",ref:r,icon:rt}))});je.displayName="BottomSingle";var nt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.97705 7.51296C5.97705 7.18159 6.24568 6.91296 6.57705 6.91296H8.48632C8.81769 6.91296 9.08632 7.18159 9.08632 7.51296 9.08632 7.84433 8.81769 8.11296 8.48632 8.11296H6.57705C6.24568 8.11296 5.97705 7.84433 5.97705 7.51296zM6.57705 9.41028C6.24568 9.41028 5.97705 9.67891 5.97705 10.0103 5.97705 10.3416 6.24568 10.6103 6.57705 10.6103H10.8199C11.1512 10.6103 11.4199 10.3416 11.4199 10.0103 11.4199 9.67891 11.1512 9.41028 10.8199 9.41028H6.57705z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.51074 2.37063C3.51074 1.48697 4.22709 0.77063 5.11074 0.77063H9.80318L9.81294 0.770708C9.97168 0.768161 10.1311 0.82824 10.2511 0.95055L14.4317 5.21408C14.5165 5.30049 14.5697 5.406 14.5917 5.51645C14.6041 5.5644 14.6106 5.61467 14.6106 5.66648V11.6406C14.6106 12.5243 13.8943 13.2406 13.0106 13.2406H5.11074C4.22709 13.2406 3.51074 12.5243 3.51074 11.6406V2.37063ZM10.4032 4.66648V2.81964L12.6063 5.06648H10.8032C10.5823 5.06648 10.4032 4.88739 10.4032 4.66648ZM5.11074 1.97063C4.88983 1.97063 4.71074 2.14972 4.71074 2.37063V11.6406C4.71074 11.8615 4.88983 12.0406 5.11074 12.0406H13.0106C13.2316 12.0406 13.4106 11.8615 13.4106 11.6406V6.26648H10.8032C9.91953 6.26648 9.20318 5.55013 9.20318 4.66648V1.97063H5.11074Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.58916 6.6741C2.58916 6.34273 2.32053 6.0741 1.98916 6.0741C1.65779 6.0741 1.38916 6.34273 1.38916 6.6741V12.6294C1.38916 14.0653 2.55322 15.2294 3.98916 15.2294H9.41408C9.74545 15.2294 10.0141 14.9607 10.0141 14.6294C10.0141 14.298 9.74545 14.0294 9.41408 14.0294H3.98916C3.21596 14.0294 2.58916 13.4026 2.58916 12.6294V6.6741Z"}}]},Ae=_.forwardRef(function(i,r){return _.createElement(q,Object.assign({},i,{id:"create-copy-single",ref:r,icon:nt}))});Ae.displayName="CreateCopySingle";var it={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.38125 1.16211C6.49759 1.16211 5.78125 1.87845 5.78125 2.76211V5.6377H2.87783C1.99418 5.6377 1.27783 6.35404 1.27783 7.2377V13.2377C1.27783 14.1214 1.99418 14.8377 2.87783 14.8377H8.87783C9.76149 14.8377 10.4778 14.1214 10.4778 13.2377V10.3621H13.3813C14.2649 10.3621 14.9813 9.64577 14.9813 8.76211V2.76211C14.9813 1.87845 14.2649 1.16211 13.3813 1.16211H7.38125ZM10.4778 9.16211H13.3813C13.6022 9.16211 13.7812 8.98302 13.7812 8.76211V2.76211C13.7812 2.5412 13.6022 2.36211 13.3813 2.36211H7.38125C7.16034 2.36211 6.98125 2.5412 6.98125 2.76211V5.6377H8.87783C9.76149 5.6377 10.4778 6.35404 10.4778 7.2377V9.16211ZM6.98125 6.8377H8.87783C9.09875 6.8377 9.27783 7.01678 9.27783 7.2377V9.16211H7.38125C7.16034 9.16211 6.98125 8.98302 6.98125 8.76211V6.8377ZM5.78125 6.8377V8.76211C5.78125 9.64577 6.49759 10.3621 7.38125 10.3621H9.27783V13.2377C9.27783 13.4586 9.09875 13.6377 8.87783 13.6377H2.87783C2.65692 13.6377 2.47783 13.4586 2.47783 13.2377V7.2377C2.47783 7.01678 2.65692 6.8377 2.87783 6.8377H5.78125Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Le=_.forwardRef(function(i,r){return _.createElement(q,Object.assign({},i,{id:"group-single",ref:r,icon:it}))});Le.displayName="GroupSingle";var at={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},xe=_.forwardRef(function(i,r){return _.createElement(q,Object.assign({},i,{id:"more-down-single",ref:r,icon:at}))});xe.displayName="MoreDownSingle";var st={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.25 2.96401C1.25 3.84767 1.96634 4.56401 2.85 4.56401H13.15C14.0337 4.56401 14.75 3.84767 14.75 2.96401C14.75 2.08036 14.0337 1.36401 13.15 1.36401H2.85C1.96635 1.36401 1.25 2.08036 1.25 2.96401ZM2.85 3.36401C2.62909 3.36401 2.45 3.18493 2.45 2.96401C2.45 2.7431 2.62909 2.56401 2.85 2.56401H13.15C13.3709 2.56401 13.55 2.7431 13.55 2.96401C13.55 3.18493 13.3709 3.36401 13.15 3.36401H2.85Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.57564 11.6118C5.80995 11.3774 6.18985 11.3774 6.42417 11.6118L7.3999 12.5875V6.36951C7.3999 6.03814 7.66853 5.76951 7.9999 5.76951C8.33127 5.76951 8.5999 6.03814 8.5999 6.36951V12.5875L9.57564 11.6118C9.80995 11.3774 10.1899 11.3774 10.4242 11.6118C10.6585 11.8461 10.6585 12.226 10.4242 12.4603L8.4324 14.452C8.32324 14.5655 8.16982 14.6362 7.9999 14.6362C7.82998 14.6362 7.67655 14.5655 7.56739 14.452L5.57564 12.4603C5.34132 12.226 5.34132 11.8461 5.57564 11.6118Z"}}]},He=_.forwardRef(function(i,r){return _.createElement(q,Object.assign({},i,{id:"move-down-single",ref:r,icon:st}))});He.displayName="MoveDownSingle";var ot={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.25 13.036C1.25 12.1523 1.96634 11.436 2.85 11.436H13.15C14.0337 11.436 14.75 12.1523 14.75 13.036C14.75 13.9196 14.0337 14.636 13.15 14.636H2.85C1.96635 14.636 1.25 13.9196 1.25 13.036ZM2.85 12.636C2.62909 12.636 2.45 12.8151 2.45 13.036C2.45 13.2569 2.62909 13.436 2.85 13.436H13.15C13.3709 13.436 13.55 13.2569 13.55 13.036C13.55 12.8151 13.3709 12.636 13.15 12.636H2.85Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.57564 4.38825C5.80995 4.62256 6.18985 4.62256 6.42417 4.38825L7.3999 3.41251V9.63049C7.3999 9.96186 7.66853 10.2305 7.9999 10.2305C8.33127 10.2305 8.5999 9.96186 8.5999 9.63049V3.41251L9.57564 4.38825C9.80995 4.62256 10.1899 4.62256 10.4242 4.38825C10.6585 4.15393 10.6585 3.77403 10.4242 3.53972L8.4324 1.54796C8.32324 1.43445 8.16982 1.36382 7.9999 1.36382C7.82998 1.36382 7.67655 1.43446 7.56739 1.54797L5.57564 3.53972C5.34132 3.77403 5.34132 4.15393 5.57564 4.38825Z"}}]},ke=_.forwardRef(function(i,r){return _.createElement(q,Object.assign({},i,{id:"move-up-single",ref:r,icon:ot}))});ke.displayName="MoveUpSingle";var ct={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.82994 1.40913C7.88746 1.35161 7.95376 1.30821 8.02453 1.27893C8.09527 1.24959 8.17285 1.2334 8.2542 1.2334C8.33555 1.2334 8.41313 1.24959 8.48387 1.27893C8.55464 1.30821 8.62094 1.35161 8.67846 1.40913L10.6785 3.40913C10.9128 3.64345 10.9128 4.02335 10.6785 4.25766C10.4441 4.49198 10.0642 4.49198 9.82994 4.25766L8.8542 3.28193V5.8334C8.8542 6.16477 8.58557 6.4334 8.2542 6.4334C7.92283 6.4334 7.6542 6.16477 7.6542 5.8334V3.28193L6.67846 4.25766C6.44415 4.49198 6.06425 4.49198 5.82994 4.25766C5.59562 4.02335 5.59562 3.64345 5.82994 3.40913L7.82994 1.40913Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.50439 9C1.50439 8.11634 2.22074 7.4 3.10439 7.4H13.4044C14.288 7.4 15.0044 8.11634 15.0044 9 15.0044 9.88366 14.2881 10.6 13.4044 10.6H3.1044C2.22074 10.6 1.50439 9.88366 1.50439 9zM3.10439 8.6C2.88348 8.6 2.70439 8.77909 2.70439 9 2.70439 9.22091 2.88348 9.4 3.1044 9.4H13.4044C13.6253 9.4 13.8044 9.22091 13.8044 9 13.8044 8.77909 13.6253 8.6 13.4044 8.6H3.10439zM1.6543 13.1665C1.6543 12.2828 2.37064 11.5665 3.2543 11.5665H13.5543C14.438 11.5665 15.1543 12.2828 15.1543 13.1665 15.1543 14.0502 14.438 14.7665 13.5543 14.7665H3.2543C2.37064 14.7665 1.6543 14.0502 1.6543 13.1665zM3.2543 12.7665C3.03338 12.7665 2.8543 12.9456 2.8543 13.1665 2.8543 13.3874 3.03338 13.5665 3.2543 13.5665H13.5543C13.7752 13.5665 13.9543 13.3874 13.9543 13.1665 13.9543 12.9456 13.7752 12.7665 13.5543 12.7665H3.2543z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ge=_.forwardRef(function(i,r){return _.createElement(q,Object.assign({},i,{id:"topmost-single",ref:r,icon:ct}))});Ge.displayName="TopmostSingle";var lt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.46855 2.83731C7.46855 2.61639 7.64764 2.4373 7.86855 2.4373H13.8603C14.0812 2.4373 14.2603 2.61639 14.2603 2.8373V9.5049C14.2603 9.72581 14.0812 9.90489 13.8603 9.90489H12.866C12.5346 9.90489 12.266 10.1735 12.266 10.5049C12.266 10.8363 12.5346 11.1049 12.866 11.1049H13.8603C14.7439 11.1049 15.4603 10.3886 15.4603 9.5049V2.8373C15.4603 1.95365 14.7439 1.2373 13.8603 1.2373H7.86855C6.9849 1.2373 6.26855 1.95365 6.26855 2.83731V3.48688C6.26855 3.81825 6.53718 4.08688 6.86855 4.08688C7.19993 4.08688 7.46855 3.81825 7.46855 3.48688V2.83731Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.19888 5.56299C2.31522 5.56299 1.59888 6.27933 1.59888 7.16299V13.163C1.59888 14.0466 2.31522 14.763 3.19888 14.763H9.19888C10.0825 14.763 10.7989 14.0466 10.7989 13.163V7.16299C10.7989 6.27933 10.0825 5.56299 9.19888 5.56299H3.19888ZM2.79888 7.16299C2.79888 6.94207 2.97796 6.76299 3.19888 6.76299H9.19888C9.41979 6.76299 9.59888 6.94207 9.59888 7.16299V13.163C9.59888 13.3839 9.41979 13.563 9.19888 13.563H3.19888C2.97796 13.563 2.79888 13.3839 2.79888 13.163V7.16299Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Re=_.forwardRef(function(i,r){return _.createElement(q,Object.assign({},i,{id:"ungroup-single",ref:r,icon:lt}))});Re.displayName="UngroupSingle";const H="univer-relative univer-mt-2.5 univer-flex univer-h-full univer-items-start univer-justify-between univer-gap-2 univer-flex-no-wrap",k="univer-w-full univer-text-left univer-text-gray-400",re="univer-flex univer-items-center univer-gap-1",dt=i=>{const{arrangeShow:r,drawings:t}=i,e=V.useDependency(h.LocaleService),n=V.useDependency(D.IDrawingManagerService),s=d=>d?"block":"none",[a,o]=_.useState(t);_.useEffect(()=>{const d=n.focus$.subscribe(u=>{o(u)});return()=>{d.unsubscribe()}},[]);const l=d=>{const u=a[0].unitId,g=a[0].subUnitId,f=a.map(p=>p.drawingId);n.featurePluginOrderUpdateNotification({unitId:u,subUnitId:g,drawingIds:f,arrangeType:d})};return c.jsxs("div",{className:"univer-relative univer-mt-5 univer-w-full",style:{display:s(r)},children:[c.jsx("div",{className:H,children:c.jsx("div",{className:k,children:c.jsx("div",{children:e.t("image-panel.arrange.title")})})}),c.jsxs("div",{className:H,children:[c.jsx("div",{className:"univer-w-1/2",children:c.jsx(P.Button,{onClick:()=>{l(h.ArrangeTypeEnum.forward)},children:c.jsxs("span",{className:re,children:[c.jsx(ke,{}),e.t("image-panel.arrange.forward")]})})}),c.jsx("div",{className:"univer-w-1/2",children:c.jsx(P.Button,{onClick:()=>{l(h.ArrangeTypeEnum.backward)},children:c.jsxs("span",{className:re,children:[c.jsx(He,{}),e.t("image-panel.arrange.backward")]})})})]}),c.jsxs("div",{className:H,children:[c.jsx("div",{className:"univer-w-1/2",children:c.jsx(P.Button,{onClick:()=>{l(h.ArrangeTypeEnum.front)},children:c.jsxs("span",{className:re,children:[c.jsx(Ge,{}),e.t("image-panel.arrange.front")]})})}),c.jsx("div",{className:"univer-w-1/2",children:c.jsx(P.Button,{onClick:()=>{l(h.ArrangeTypeEnum.back)},children:c.jsxs("span",{className:re,children:[c.jsx(je,{}),e.t("image-panel.arrange.back")]})})})]})]})},ut=i=>{const r=V.useDependency(h.LocaleService),t=V.useDependency(y.IRenderManagerService),e=V.useDependency(D.IDrawingManagerService),{hasGroup:n,drawings:s}=i,[a,o]=_.useState(!1),[l,d]=_.useState(!0),[u,g]=_.useState(!0),f=m=>m?"block":"none",p=()=>{const m=e.getFocusDrawings(),{unitId:b,subUnitId:C}=m[0],B=h.Tools.generateRandomId(10),M=y.getGroupState(0,0,m.map(O=>O.transform||{})),A={unitId:b,subUnitId:C,drawingId:B,drawingType:h.DrawingTypeEnum.DRAWING_GROUP,transform:M},E=m.map(O=>{const N=O.transform||{left:0,top:0},{unitId:T,subUnitId:U,drawingId:R}=O;return{unitId:T,subUnitId:U,drawingId:R,transform:{...N,left:N.left-M.left,top:N.top-M.top},groupId:B}});e.featurePluginGroupUpdateNotification([{parent:A,children:E}])},S=m=>{if(m.drawingType!==h.DrawingTypeEnum.DRAWING_GROUP)return;const{unitId:b,subUnitId:C,drawingId:B,transform:M={width:0,height:0}}=m;if(M==null)return;const A=e.getDrawingsByGroup({unitId:b,subUnitId:C,drawingId:B});if(A.length===0)return;const E=A.map(O=>{const{transform:N}=O,{unitId:T,subUnitId:U,drawingId:R}=O,x=y.transformObjectOutOfGroup(N||{},M,M.width||0,M.height||0);return{unitId:T,subUnitId:U,drawingId:R,transform:{...N,...x},groupId:void 0}});return{parent:m,children:E}},w=()=>{const b=e.getFocusDrawings().map(C=>S(C)).filter(C=>C!=null);b.length!==0&&e.featurePluginUngroupUpdateNotification(b)};return _.useEffect(()=>{const m=s[0];if(m==null)return;const{unitId:b}=m,C=t.getRenderById(b),B=C==null?void 0:C.scene;if(B==null)return;const M=B.getTransformerByCreate(),A=M.clearControl$.subscribe(O=>{O===!0&&o(!1)}),E=M.changeStart$.subscribe(O=>{const{objects:N}=O,T=ge(N,e),U=T.filter(K=>(K==null?void 0:K.drawingType)===h.DrawingTypeEnum.DRAWING_GROUP);let R=!1,x=!1;T.length>1&&(R=!0),U.length>0&&(x=!0),o(R||x),d(R),g(x)});return()=>{E.unsubscribe(),A.unsubscribe()}},[]),c.jsxs("div",{className:"univer-relative univer-mt-5 univer-w-full",style:{display:f(n===!0?a:!1)},children:[c.jsx("div",{className:H,children:c.jsx("div",{className:k,children:c.jsx("div",{children:r.t("image-panel.group.title")})})}),c.jsxs("div",{className:H,children:[c.jsx("div",{className:P.clsx(re,"univer-justify-center"),children:c.jsx(P.Button,{style:{display:f(l)},onClick:p,children:c.jsxs("span",{className:"univer-flex univer-items-center univer-gap-1",children:[c.jsx(Le,{}),r.t("image-panel.group.group")]})})}),c.jsx("div",{className:P.clsx(re,"univer-justify-center"),children:c.jsx(P.Button,{style:{display:f(u)},onClick:w,children:c.jsxs("span",{className:"univer-flex univer-items-center univer-gap-1",children:[c.jsx(Re,{}),r.t("image-panel.group.unGroup")]})})})]})]})},ie=20,gt=20,ht=[-3600,3600],we=300,ft=i=>{var Fe;const r=V.useDependency(h.LocaleService),t=V.useDependency(D.IDrawingManagerService),e=V.useDependency(y.IRenderManagerService),{drawings:n,transformShow:s}=i,a=n[0];if(a==null)return;const o=a.transform;if(o==null)return;const{unitId:l,subUnitId:d,drawingId:u,drawingType:g}=a,f=e.getRenderById(l),p=f==null?void 0:f.scene;if(p==null)return;const S=(Fe=p.getEngine())==null?void 0:Fe.activeScene;if(S==null)return;const w=p.getTransformerByCreate(),{width:m=0,height:b=0,left:C=0,top:B=0,angle:M=0}=o,[A,E]=_.useState(m),[O,N]=_.useState(b),[T,U]=_.useState(C),[R,x]=_.useState(B),[Y,K]=_.useState(M),[de,se]=_.useState(w.keepRatio),oe=(v,L,$,z)=>{const{width:W,height:ee}=S,{ancestorLeft:Z,ancestorTop:X}=p;let J=v,ce=L,pe=$,me=z;return v+Z<0&&(J=-Z),L+X<0&&(ce=-X),pe=W-J-Z,pe<ie&&(pe=ie),me=ee-ce-X,me<ie&&(me=ie),v+pe+Z>W&&(J=W-$-Z),L+me+X>ee&&(ce=ee-z-X),{limitLeft:J,limitTop:ce,limitWidth:pe,limitHeight:me}},ue=v=>{const{objects:L}=v,$=ge(L,t);if($.length!==1)return;const z=$[0];if(z==null)return;const{transform:W}=z;if(W==null)return;const{width:ee,height:Z,left:X,top:J,angle:ce}=W;ee!=null&&E(ee),Z!=null&&N(Z),X!=null&&U(X),J!=null&&x(J),ce!=null&&K(ce)};_.useEffect(()=>{const v=[w.changeStart$.subscribe(L=>{ue(L)}),w.changing$.subscribe(L=>{ue(L)}),w.changeEnd$.subscribe(L=>{ue(L)}),t.focus$.subscribe(L=>{if(L.length!==1)return;const $=t.getDrawingByParam(L[0]);if($==null)return;const z=$.transform;if(z==null)return;const{width:W,height:ee,left:Z,top:X,angle:J}=z;W!=null&&E(W),ee!=null&&N(ee),Z!=null&&U(Z),X!=null&&x(X),J!=null&&K(J)})];return()=>{v.forEach(L=>L.unsubscribe())}},[]);const Q=h.debounce(v=>{if(v==null)return;v=Math.max(v,ie);const{limitWidth:L,limitHeight:$}=oe(T,R,v,O);v=Math.min(v,L);const z={unitId:l,subUnitId:d,drawingId:u,drawingType:g,transform:{width:v}};if(de){let W=v/A*O;if(W=Math.max(W,gt),W>$)return;N(W),z.transform.height=W}E(v),t.featurePluginUpdateNotification([z]),w.refreshControls().changeNotification()},we),Ne=h.debounce(v=>{if(v==null)return;v=Math.max(v,ie);const{limitHeight:L,limitWidth:$}=oe(T,R,A,v);v=Math.min(v,L);const z={unitId:l,subUnitId:d,drawingId:u,drawingType:g,transform:{height:v}};if(de){let W=v/O*A;if(W=Math.max(W,ie),W>$)return;E(W),z.transform.width=W}N(v),t.featurePluginUpdateNotification([z]),w.refreshControls().changeNotification()},we),Et=h.debounce(v=>{if(v==null)return;const{limitLeft:L}=oe(v,R,A,O);v=L;const $={unitId:l,subUnitId:d,drawingId:u,drawingType:g,transform:{left:v}};U(v),t.featurePluginUpdateNotification([$]),w.refreshControls().changeNotification()},we),Tt=h.debounce(v=>{if(v==null)return;const{limitTop:L}=oe(T,v,A,O);v=L;const $={unitId:l,subUnitId:d,drawingId:u,drawingType:g,transform:{top:v}};x(v),t.featurePluginUpdateNotification([$]),w.refreshControls().changeNotification()},we),Pt=v=>{if(v==null)return;const[L,$]=ht;v<L&&(v=L),v>$&&(v=$);const z={unitId:l,subUnitId:d,drawingId:u,drawingType:g,transform:{angle:v}};K(v),t.featurePluginUpdateNotification([z]),w.refreshControls().changeNotification()},Bt=v=>{se(v),w.keepRatio=v},Ut=v=>v?"block":"none";return c.jsxs("div",{className:`
|
|
9
|
+
`,children:l.jsx("div",{className:"univer-w-full univer-text-gray-900",children:l.jsx(P.Select,{value:n,options:a,onChange:o})})})]})};var F=function(){return F=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},F.apply(this,arguments)},Qe=function(i,r){var t={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&r.indexOf(e)<0&&(t[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,e=Object.getOwnPropertySymbols(i);n<e.length;n++)r.indexOf(e[n])<0&&Object.prototype.propertyIsEnumerable.call(i,e[n])&&(t[e[n]]=i[e[n]]);return t},q=_.forwardRef(function(i,r){var t=i.icon,e=i.id,n=i.className,s=i.extend,a=Qe(i,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(e," ").concat(n||"").trim(),c=_.useRef("_".concat(rt()));return je(t,"".concat(e),{defIds:t.defIds,idSuffix:c.current},F({ref:r,className:o},a),s)});function je(i,r,t,e,n){return _.createElement(i.tag,F(F({key:r},et(i,t,n)),e),(tt(i,t).children||[]).map(function(s,a){return je(s,"".concat(r,"-").concat(i.tag,"-").concat(a),t,void 0,n)}))}function et(i,r,t){var e=F({},i.attrs);t!=null&&t.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=t.colorChannel1),i.tag==="mask"&&e.id&&(e.id=e.id+r.idSuffix),Object.entries(e).forEach(function(s){var a=s[0],o=s[1];a==="mask"&&typeof o=="string"&&(e[a]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))});var n=r.defIds;return!n||n.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+r.idSuffix),Object.entries(e).forEach(function(s){var a=s[0],o=s[1];typeof o=="string"&&(e[a]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))})),e}function tt(i,r){var t,e=r.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?F(F({},i),{children:i.children.map(function(n){return typeof n.attrs.id=="string"&&e&&e.indexOf(n.attrs.id)>-1?F(F({},n),{attrs:F(F({},n.attrs),{id:n.attrs.id+r.idSuffix})}):n})}):i}function rt(){return Math.random().toString(36).substring(2,8)}q.displayName="UniverIcon";var nt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M11.0363 12.2367V14.0367C11.0363 14.3681 11.3049 14.6367 11.6363 14.6367C11.9676 14.6367 12.2363 14.3681 12.2363 14.0367V12.2367H14.0364C14.3677 12.2367 14.6364 11.9681 14.6364 11.6367C14.6364 11.3054 14.3677 11.0367 14.0364 11.0367H12.2363V9.23672C12.2363 8.90535 11.9676 8.63672 11.6363 8.63672C11.3049 8.63672 11.0363 8.90535 11.0363 9.23672V11.0367H9.23635C8.90498 11.0367 8.63635 11.3054 8.63635 11.6367C8.63635 11.9681 8.90498 12.2367 9.23635 12.2367H11.0363Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.56365 1.36377C1.90091 1.36377 1.36365 1.90103 1.36365 2.56377V6.16377C1.36365 6.82651 1.90091 7.36377 2.56365 7.36377H6.16365C6.82639 7.36377 7.36365 6.82651 7.36365 6.16377V2.56377C7.36365 1.90103 6.82639 1.36377 6.16365 1.36377H2.56365zM6.16365 2.56377H2.56365L2.56365 6.16377H6.16365V2.56377zM2.56365 8.63647C1.90091 8.63647 1.36365 9.17373 1.36365 9.83647V13.4365C1.36365 14.0992 1.90091 14.6365 2.56365 14.6365H6.16365C6.82639 14.6365 7.36365 14.0992 7.36365 13.4365V9.83647C7.36365 9.17373 6.82639 8.63647 6.16365 8.63647H2.56365zM6.16365 9.83647H2.56365L2.56365 13.4365H6.16365V9.83647zM9.83635 7.36377C9.17361 7.36377 8.63635 6.82651 8.63635 6.16377V2.56377C8.63635 1.90103 9.17361 1.36377 9.83635 1.36377H13.4364C14.0991 1.36377 14.6364 1.90103 14.6364 2.56377V6.16377C14.6364 6.82651 14.0991 7.36377 13.4364 7.36377H9.83635zM9.83635 6.16377V2.56377L13.4364 2.56377V6.16377H9.83635z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ae=_.forwardRef(function(i,r){return _.createElement(q,Object.assign({},i,{id:"autofill",ref:r,icon:nt}))});Ae.displayName="Autofill";var it={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.0045 4.4334C14.8881 4.4334 15.6045 3.71705 15.6045 2.8334 15.6045 1.94974 14.8881 1.2334 14.0045 1.2334H3.70449C2.82084 1.2334 2.10449 1.94974 2.10449 2.8334 2.10449 3.71705 2.82084 4.4334 3.70449 4.4334H14.0045zM14.4045 2.8334C14.4045 3.05431 14.2254 3.2334 14.0045 3.2334H3.70449C3.48358 3.2334 3.30449 3.05431 3.30449 2.8334 3.30449 2.61248 3.48358 2.4334 3.70449 2.4334H14.0045C14.2254 2.4334 14.4045 2.61249 14.4045 2.8334zM14.1544 8.5999C15.038 8.5999 15.7544 7.88356 15.7544 6.9999 15.7544 6.11625 15.038 5.3999 14.1544 5.3999H3.85439C2.97074 5.3999 2.25439 6.11625 2.25439 6.9999 2.25439 7.88356 2.97074 8.5999 3.85439 8.5999H14.1544zM14.5544 6.9999C14.5544 7.22082 14.3753 7.3999 14.1544 7.3999H3.85439C3.63348 7.3999 3.45439 7.22082 3.45439 6.9999 3.45439 6.77899 3.63348 6.5999 3.85439 6.5999H14.1544C14.3753 6.5999 14.5544 6.77899 14.5544 6.9999z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.57975 14.5902L6.58023 12.5907C6.34591 12.3564 6.34591 11.9765 6.58023 11.7421 6.81454 11.5078 7.19444 11.5078 7.42876 11.7421L8.40449 12.7179V10.1664C8.40449 9.83504 8.67312 9.56641 9.00449 9.56641 9.33586 9.56641 9.60449 9.83504 9.60449 10.1664V12.7179L10.5802 11.7421C10.8145 11.5078 11.1944 11.5078 11.4288 11.7421 11.6631 11.9765 11.6631 12.3564 11.4288 12.5907L9.42923 14.5902M8.57975 14.5902C8.58121 14.5917 8.58268 14.5931 8.58416 14.5946 8.64077 14.6502 8.70566 14.6923 8.77482 14.7209 8.84557 14.7502 8.92314 14.7664 9.00449 14.7664 9.08585 14.7664 9.16342 14.7502 9.23416 14.7209 9.30332 14.6923 9.36821 14.6502 9.42482 14.5946"}}]},Le=_.forwardRef(function(i,r){return _.createElement(q,Object.assign({},i,{id:"bottom-single",ref:r,icon:it}))});Le.displayName="BottomSingle";var at={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.97705 7.51296C5.97705 7.18159 6.24568 6.91296 6.57705 6.91296H8.48632C8.81769 6.91296 9.08632 7.18159 9.08632 7.51296 9.08632 7.84433 8.81769 8.11296 8.48632 8.11296H6.57705C6.24568 8.11296 5.97705 7.84433 5.97705 7.51296zM6.57705 9.41028C6.24568 9.41028 5.97705 9.67891 5.97705 10.0103 5.97705 10.3416 6.24568 10.6103 6.57705 10.6103H10.8199C11.1512 10.6103 11.4199 10.3416 11.4199 10.0103 11.4199 9.67891 11.1512 9.41028 10.8199 9.41028H6.57705z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.51074 2.37063C3.51074 1.48697 4.22709 0.77063 5.11074 0.77063H9.80318L9.81294 0.770708C9.97168 0.768161 10.1311 0.82824 10.2511 0.95055L14.4317 5.21408C14.5165 5.30049 14.5697 5.406 14.5917 5.51645C14.6041 5.5644 14.6106 5.61467 14.6106 5.66648V11.6406C14.6106 12.5243 13.8943 13.2406 13.0106 13.2406H5.11074C4.22709 13.2406 3.51074 12.5243 3.51074 11.6406V2.37063ZM10.4032 4.66648V2.81964L12.6063 5.06648H10.8032C10.5823 5.06648 10.4032 4.88739 10.4032 4.66648ZM5.11074 1.97063C4.88983 1.97063 4.71074 2.14972 4.71074 2.37063V11.6406C4.71074 11.8615 4.88983 12.0406 5.11074 12.0406H13.0106C13.2316 12.0406 13.4106 11.8615 13.4106 11.6406V6.26648H10.8032C9.91953 6.26648 9.20318 5.55013 9.20318 4.66648V1.97063H5.11074Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.58916 6.6741C2.58916 6.34273 2.32053 6.0741 1.98916 6.0741C1.65779 6.0741 1.38916 6.34273 1.38916 6.6741V12.6294C1.38916 14.0653 2.55322 15.2294 3.98916 15.2294H9.41408C9.74545 15.2294 10.0141 14.9607 10.0141 14.6294C10.0141 14.298 9.74545 14.0294 9.41408 14.0294H3.98916C3.21596 14.0294 2.58916 13.4026 2.58916 12.6294V6.6741Z"}}]},xe=_.forwardRef(function(i,r){return _.createElement(q,Object.assign({},i,{id:"create-copy-single",ref:r,icon:at}))});xe.displayName="CreateCopySingle";var st={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.38125 1.16211C6.49759 1.16211 5.78125 1.87845 5.78125 2.76211V5.6377H2.87783C1.99418 5.6377 1.27783 6.35404 1.27783 7.2377V13.2377C1.27783 14.1214 1.99418 14.8377 2.87783 14.8377H8.87783C9.76149 14.8377 10.4778 14.1214 10.4778 13.2377V10.3621H13.3813C14.2649 10.3621 14.9813 9.64577 14.9813 8.76211V2.76211C14.9813 1.87845 14.2649 1.16211 13.3813 1.16211H7.38125ZM10.4778 9.16211H13.3813C13.6022 9.16211 13.7812 8.98302 13.7812 8.76211V2.76211C13.7812 2.5412 13.6022 2.36211 13.3813 2.36211H7.38125C7.16034 2.36211 6.98125 2.5412 6.98125 2.76211V5.6377H8.87783C9.76149 5.6377 10.4778 6.35404 10.4778 7.2377V9.16211ZM6.98125 6.8377H8.87783C9.09875 6.8377 9.27783 7.01678 9.27783 7.2377V9.16211H7.38125C7.16034 9.16211 6.98125 8.98302 6.98125 8.76211V6.8377ZM5.78125 6.8377V8.76211C5.78125 9.64577 6.49759 10.3621 7.38125 10.3621H9.27783V13.2377C9.27783 13.4586 9.09875 13.6377 8.87783 13.6377H2.87783C2.65692 13.6377 2.47783 13.4586 2.47783 13.2377V7.2377C2.47783 7.01678 2.65692 6.8377 2.87783 6.8377H5.78125Z",fillRule:"evenodd",clipRule:"evenodd"}}]},He=_.forwardRef(function(i,r){return _.createElement(q,Object.assign({},i,{id:"group-single",ref:r,icon:st}))});He.displayName="GroupSingle";var ot={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ke=_.forwardRef(function(i,r){return _.createElement(q,Object.assign({},i,{id:"more-down-single",ref:r,icon:ot}))});ke.displayName="MoreDownSingle";var ct={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.25 2.96401C1.25 3.84767 1.96634 4.56401 2.85 4.56401H13.15C14.0337 4.56401 14.75 3.84767 14.75 2.96401C14.75 2.08036 14.0337 1.36401 13.15 1.36401H2.85C1.96635 1.36401 1.25 2.08036 1.25 2.96401ZM2.85 3.36401C2.62909 3.36401 2.45 3.18493 2.45 2.96401C2.45 2.7431 2.62909 2.56401 2.85 2.56401H13.15C13.3709 2.56401 13.55 2.7431 13.55 2.96401C13.55 3.18493 13.3709 3.36401 13.15 3.36401H2.85Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.57564 11.6118C5.80995 11.3774 6.18985 11.3774 6.42417 11.6118L7.3999 12.5875V6.36951C7.3999 6.03814 7.66853 5.76951 7.9999 5.76951C8.33127 5.76951 8.5999 6.03814 8.5999 6.36951V12.5875L9.57564 11.6118C9.80995 11.3774 10.1899 11.3774 10.4242 11.6118C10.6585 11.8461 10.6585 12.226 10.4242 12.4603L8.4324 14.452C8.32324 14.5655 8.16982 14.6362 7.9999 14.6362C7.82998 14.6362 7.67655 14.5655 7.56739 14.452L5.57564 12.4603C5.34132 12.226 5.34132 11.8461 5.57564 11.6118Z"}}]},Ge=_.forwardRef(function(i,r){return _.createElement(q,Object.assign({},i,{id:"move-down-single",ref:r,icon:ct}))});Ge.displayName="MoveDownSingle";var lt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.25 13.036C1.25 12.1523 1.96634 11.436 2.85 11.436H13.15C14.0337 11.436 14.75 12.1523 14.75 13.036C14.75 13.9196 14.0337 14.636 13.15 14.636H2.85C1.96635 14.636 1.25 13.9196 1.25 13.036ZM2.85 12.636C2.62909 12.636 2.45 12.8151 2.45 13.036C2.45 13.2569 2.62909 13.436 2.85 13.436H13.15C13.3709 13.436 13.55 13.2569 13.55 13.036C13.55 12.8151 13.3709 12.636 13.15 12.636H2.85Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.57564 4.38825C5.80995 4.62256 6.18985 4.62256 6.42417 4.38825L7.3999 3.41251V9.63049C7.3999 9.96186 7.66853 10.2305 7.9999 10.2305C8.33127 10.2305 8.5999 9.96186 8.5999 9.63049V3.41251L9.57564 4.38825C9.80995 4.62256 10.1899 4.62256 10.4242 4.38825C10.6585 4.15393 10.6585 3.77403 10.4242 3.53972L8.4324 1.54796C8.32324 1.43445 8.16982 1.36382 7.9999 1.36382C7.82998 1.36382 7.67655 1.43446 7.56739 1.54797L5.57564 3.53972C5.34132 3.77403 5.34132 4.15393 5.57564 4.38825Z"}}]},Ve=_.forwardRef(function(i,r){return _.createElement(q,Object.assign({},i,{id:"move-up-single",ref:r,icon:lt}))});Ve.displayName="MoveUpSingle";var dt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.82994 1.40913C7.88746 1.35161 7.95376 1.30821 8.02453 1.27893C8.09527 1.24959 8.17285 1.2334 8.2542 1.2334C8.33555 1.2334 8.41313 1.24959 8.48387 1.27893C8.55464 1.30821 8.62094 1.35161 8.67846 1.40913L10.6785 3.40913C10.9128 3.64345 10.9128 4.02335 10.6785 4.25766C10.4441 4.49198 10.0642 4.49198 9.82994 4.25766L8.8542 3.28193V5.8334C8.8542 6.16477 8.58557 6.4334 8.2542 6.4334C7.92283 6.4334 7.6542 6.16477 7.6542 5.8334V3.28193L6.67846 4.25766C6.44415 4.49198 6.06425 4.49198 5.82994 4.25766C5.59562 4.02335 5.59562 3.64345 5.82994 3.40913L7.82994 1.40913Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.50439 9C1.50439 8.11634 2.22074 7.4 3.10439 7.4H13.4044C14.288 7.4 15.0044 8.11634 15.0044 9 15.0044 9.88366 14.2881 10.6 13.4044 10.6H3.1044C2.22074 10.6 1.50439 9.88366 1.50439 9zM3.10439 8.6C2.88348 8.6 2.70439 8.77909 2.70439 9 2.70439 9.22091 2.88348 9.4 3.1044 9.4H13.4044C13.6253 9.4 13.8044 9.22091 13.8044 9 13.8044 8.77909 13.6253 8.6 13.4044 8.6H3.10439zM1.6543 13.1665C1.6543 12.2828 2.37064 11.5665 3.2543 11.5665H13.5543C14.438 11.5665 15.1543 12.2828 15.1543 13.1665 15.1543 14.0502 14.438 14.7665 13.5543 14.7665H3.2543C2.37064 14.7665 1.6543 14.0502 1.6543 13.1665zM3.2543 12.7665C3.03338 12.7665 2.8543 12.9456 2.8543 13.1665 2.8543 13.3874 3.03338 13.5665 3.2543 13.5665H13.5543C13.7752 13.5665 13.9543 13.3874 13.9543 13.1665 13.9543 12.9456 13.7752 12.7665 13.5543 12.7665H3.2543z",fillRule:"evenodd",clipRule:"evenodd"}}]},We=_.forwardRef(function(i,r){return _.createElement(q,Object.assign({},i,{id:"topmost-single",ref:r,icon:dt}))});We.displayName="TopmostSingle";var ut={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.46855 2.83731C7.46855 2.61639 7.64764 2.4373 7.86855 2.4373H13.8603C14.0812 2.4373 14.2603 2.61639 14.2603 2.8373V9.5049C14.2603 9.72581 14.0812 9.90489 13.8603 9.90489H12.866C12.5346 9.90489 12.266 10.1735 12.266 10.5049C12.266 10.8363 12.5346 11.1049 12.866 11.1049H13.8603C14.7439 11.1049 15.4603 10.3886 15.4603 9.5049V2.8373C15.4603 1.95365 14.7439 1.2373 13.8603 1.2373H7.86855C6.9849 1.2373 6.26855 1.95365 6.26855 2.83731V3.48688C6.26855 3.81825 6.53718 4.08688 6.86855 4.08688C7.19993 4.08688 7.46855 3.81825 7.46855 3.48688V2.83731Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.19888 5.56299C2.31522 5.56299 1.59888 6.27933 1.59888 7.16299V13.163C1.59888 14.0466 2.31522 14.763 3.19888 14.763H9.19888C10.0825 14.763 10.7989 14.0466 10.7989 13.163V7.16299C10.7989 6.27933 10.0825 5.56299 9.19888 5.56299H3.19888ZM2.79888 7.16299C2.79888 6.94207 2.97796 6.76299 3.19888 6.76299H9.19888C9.41979 6.76299 9.59888 6.94207 9.59888 7.16299V13.163C9.59888 13.3839 9.41979 13.563 9.19888 13.563H3.19888C2.97796 13.563 2.79888 13.3839 2.79888 13.163V7.16299Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Re=_.forwardRef(function(i,r){return _.createElement(q,Object.assign({},i,{id:"ungroup-single",ref:r,icon:ut}))});Re.displayName="UngroupSingle";const H="univer-relative univer-mt-2.5 univer-flex univer-h-full univer-items-start univer-justify-between univer-gap-2 univer-flex-no-wrap",k="univer-w-full univer-text-left univer-text-gray-400",re="univer-flex univer-items-center univer-gap-1",gt=i=>{const{arrangeShow:r,drawings:t}=i,e=W.useDependency(h.LocaleService),n=W.useDependency(D.IDrawingManagerService),s=d=>d?"block":"none",[a,o]=_.useState(t);_.useEffect(()=>{const d=n.focus$.subscribe(u=>{o(u)});return()=>{d.unsubscribe()}},[]);const c=d=>{const u=a[0].unitId,g=a[0].subUnitId,f=a.map(p=>p.drawingId);n.featurePluginOrderUpdateNotification({unitId:u,subUnitId:g,drawingIds:f,arrangeType:d})};return l.jsxs("div",{className:"univer-relative univer-mt-5 univer-w-full",style:{display:s(r)},children:[l.jsx("div",{className:H,children:l.jsx("div",{className:k,children:l.jsx("div",{children:e.t("image-panel.arrange.title")})})}),l.jsxs("div",{className:H,children:[l.jsx("div",{className:"univer-w-1/2",children:l.jsx(P.Button,{onClick:()=>{c(h.ArrangeTypeEnum.forward)},children:l.jsxs("span",{className:re,children:[l.jsx(Ve,{}),e.t("image-panel.arrange.forward")]})})}),l.jsx("div",{className:"univer-w-1/2",children:l.jsx(P.Button,{onClick:()=>{c(h.ArrangeTypeEnum.backward)},children:l.jsxs("span",{className:re,children:[l.jsx(Ge,{}),e.t("image-panel.arrange.backward")]})})})]}),l.jsxs("div",{className:H,children:[l.jsx("div",{className:"univer-w-1/2",children:l.jsx(P.Button,{onClick:()=>{c(h.ArrangeTypeEnum.front)},children:l.jsxs("span",{className:re,children:[l.jsx(We,{}),e.t("image-panel.arrange.front")]})})}),l.jsx("div",{className:"univer-w-1/2",children:l.jsx(P.Button,{onClick:()=>{c(h.ArrangeTypeEnum.back)},children:l.jsxs("span",{className:re,children:[l.jsx(Le,{}),e.t("image-panel.arrange.back")]})})})]})]})},ht=i=>{const r=W.useDependency(h.LocaleService),t=W.useDependency(y.IRenderManagerService),e=W.useDependency(D.IDrawingManagerService),{hasGroup:n,drawings:s}=i,[a,o]=_.useState(!1),[c,d]=_.useState(!0),[u,g]=_.useState(!0),f=m=>m?"block":"none",p=()=>{const m=e.getFocusDrawings(),{unitId:b,subUnitId:C}=m[0],B=h.Tools.generateRandomId(10),M=y.getGroupState(0,0,m.map(O=>O.transform||{})),A={unitId:b,subUnitId:C,drawingId:B,drawingType:h.DrawingTypeEnum.DRAWING_GROUP,transform:M},E=m.map(O=>{const N=O.transform||{left:0,top:0},{unitId:T,subUnitId:U,drawingId:V}=O;return{unitId:T,subUnitId:U,drawingId:V,transform:{...N,left:N.left-M.left,top:N.top-M.top},groupId:B}});e.featurePluginGroupUpdateNotification([{parent:A,children:E}])},S=m=>{if(m.drawingType!==h.DrawingTypeEnum.DRAWING_GROUP)return;const{unitId:b,subUnitId:C,drawingId:B,transform:M={width:0,height:0}}=m;if(M==null)return;const A=e.getDrawingsByGroup({unitId:b,subUnitId:C,drawingId:B});if(A.length===0)return;const E=A.map(O=>{const{transform:N}=O,{unitId:T,subUnitId:U,drawingId:V}=O,x=y.transformObjectOutOfGroup(N||{},M,M.width||0,M.height||0);return{unitId:T,subUnitId:U,drawingId:V,transform:{...N,...x},groupId:void 0}});return{parent:m,children:E}},w=()=>{const b=e.getFocusDrawings().map(C=>S(C)).filter(C=>C!=null);b.length!==0&&e.featurePluginUngroupUpdateNotification(b)};return _.useEffect(()=>{const m=s[0];if(m==null)return;const{unitId:b}=m,C=t.getRenderById(b),B=C==null?void 0:C.scene;if(B==null)return;const M=B.getTransformerByCreate(),A=M.clearControl$.subscribe(O=>{O===!0&&o(!1)}),E=M.changeStart$.subscribe(O=>{const{objects:N}=O,T=ge(N,e),U=T.filter(K=>(K==null?void 0:K.drawingType)===h.DrawingTypeEnum.DRAWING_GROUP);let V=!1,x=!1;T.length>1&&(V=!0),U.length>0&&(x=!0),o(V||x),d(V),g(x)});return()=>{E.unsubscribe(),A.unsubscribe()}},[]),l.jsxs("div",{className:"univer-relative univer-mt-5 univer-w-full",style:{display:f(n===!0?a:!1)},children:[l.jsx("div",{className:H,children:l.jsx("div",{className:k,children:l.jsx("div",{children:r.t("image-panel.group.title")})})}),l.jsxs("div",{className:H,children:[l.jsx("div",{className:P.clsx(re,"univer-justify-center"),children:l.jsx(P.Button,{style:{display:f(c)},onClick:p,children:l.jsxs("span",{className:"univer-flex univer-items-center univer-gap-1",children:[l.jsx(He,{}),r.t("image-panel.group.group")]})})}),l.jsx("div",{className:P.clsx(re,"univer-justify-center"),children:l.jsx(P.Button,{style:{display:f(u)},onClick:w,children:l.jsxs("span",{className:"univer-flex univer-items-center univer-gap-1",children:[l.jsx(Re,{}),r.t("image-panel.group.unGroup")]})})})]})]})},ie=20,ft=20,pt=[-3600,3600],we=300,mt=i=>{var Ze;const r=W.useDependency(h.LocaleService),t=W.useDependency(D.IDrawingManagerService),e=W.useDependency(y.IRenderManagerService),{drawings:n,transformShow:s}=i,a=n[0];if(a==null)return;const o=a.transform;if(o==null)return;const{unitId:c,subUnitId:d,drawingId:u,drawingType:g}=a,f=e.getRenderById(c),p=f==null?void 0:f.scene;if(p==null)return;const S=(Ze=p.getEngine())==null?void 0:Ze.activeScene;if(S==null)return;const w=p.getTransformerByCreate(),{width:m=0,height:b=0,left:C=0,top:B=0,angle:M=0}=o,[A,E]=_.useState(m),[O,N]=_.useState(b),[T,U]=_.useState(C),[V,x]=_.useState(B),[Y,K]=_.useState(M),[de,se]=_.useState(w.keepRatio),oe=(v,L,$,z)=>{const{width:R,height:ee}=S,{ancestorLeft:Z,ancestorTop:X}=p;let J=v,ce=L,pe=$,me=z;return v+Z<0&&(J=-Z),L+X<0&&(ce=-X),pe=R-J-Z,pe<ie&&(pe=ie),me=ee-ce-X,me<ie&&(me=ie),v+pe+Z>R&&(J=R-$-Z),L+me+X>ee&&(ce=ee-z-X),{limitLeft:J,limitTop:ce,limitWidth:pe,limitHeight:me}},ue=v=>{const{objects:L}=v,$=ge(L,t);if($.length!==1)return;const z=$[0];if(z==null)return;const{transform:R}=z;if(R==null)return;const{width:ee,height:Z,left:X,top:J,angle:ce}=R;ee!=null&&E(ee),Z!=null&&N(Z),X!=null&&U(X),J!=null&&x(J),ce!=null&&K(ce)};_.useEffect(()=>{const v=[w.changeStart$.subscribe(L=>{ue(L)}),w.changing$.subscribe(L=>{ue(L)}),w.changeEnd$.subscribe(L=>{ue(L)}),t.focus$.subscribe(L=>{if(L.length!==1)return;const $=t.getDrawingByParam(L[0]);if($==null)return;const z=$.transform;if(z==null)return;const{width:R,height:ee,left:Z,top:X,angle:J}=z;R!=null&&E(R),ee!=null&&N(ee),Z!=null&&U(Z),X!=null&&x(X),J!=null&&K(J)})];return()=>{v.forEach(L=>L.unsubscribe())}},[]);const Q=h.debounce(v=>{if(v==null)return;v=Math.max(v,ie);const{limitWidth:L,limitHeight:$}=oe(T,V,v,O);v=Math.min(v,L);const z={unitId:c,subUnitId:d,drawingId:u,drawingType:g,transform:{width:v}};if(de){let R=v/A*O;if(R=Math.max(R,ft),R>$)return;N(R),z.transform.height=R}E(v),t.featurePluginUpdateNotification([z]),w.refreshControls().changeNotification()},we),Ne=h.debounce(v=>{if(v==null)return;v=Math.max(v,ie);const{limitHeight:L,limitWidth:$}=oe(T,V,A,v);v=Math.min(v,L);const z={unitId:c,subUnitId:d,drawingId:u,drawingType:g,transform:{height:v}};if(de){let R=v/O*A;if(R=Math.max(R,ie),R>$)return;E(R),z.transform.width=R}N(v),t.featurePluginUpdateNotification([z]),w.refreshControls().changeNotification()},we),Bt=h.debounce(v=>{if(v==null)return;const{limitLeft:L}=oe(v,V,A,O);v=L;const $={unitId:c,subUnitId:d,drawingId:u,drawingType:g,transform:{left:v}};U(v),t.featurePluginUpdateNotification([$]),w.refreshControls().changeNotification()},we),Ut=h.debounce(v=>{if(v==null)return;const{limitTop:L}=oe(T,v,A,O);v=L;const $={unitId:c,subUnitId:d,drawingId:u,drawingType:g,transform:{top:v}};x(v),t.featurePluginUpdateNotification([$]),w.refreshControls().changeNotification()},we),jt=v=>{if(v==null)return;const[L,$]=pt;v<L&&(v=L),v>$&&(v=$);const z={unitId:c,subUnitId:d,drawingId:u,drawingType:g,transform:{angle:v}};K(v),t.featurePluginUpdateNotification([z]),w.refreshControls().changeNotification()},At=v=>{se(v),w.keepRatio=v},Lt=v=>v?"block":"none";return l.jsxs("div",{className:`
|
|
10
10
|
univer-relative univer-mt-5 univer-w-full univer-border-b-0 univer-border-l-0 univer-border-r-0
|
|
11
11
|
univer-border-t univer-border-solid univer-border-t-gray-200
|
|
12
|
-
`,style:{display:
|
|
12
|
+
`,style:{display:Lt(s)},children:[l.jsx("div",{className:H,children:l.jsx("div",{className:P.clsx(k),children:l.jsx("div",{children:r.t("image-panel.transform.title")})})}),l.jsxs("div",{className:H,children:[l.jsx("div",{className:P.clsx(k),children:l.jsxs("label",{children:[l.jsx("div",{className:H,children:l.jsx("div",{className:k,children:r.t("image-panel.transform.width")})}),l.jsx("div",{className:H,children:l.jsx("div",{className:k,children:l.jsx(P.InputNumber,{precision:1,value:A,onChange:v=>{Q(v)}})})})]})}),l.jsx("div",{className:P.clsx(k),children:l.jsxs("label",{children:[l.jsx("div",{className:H,children:l.jsx("div",{className:k,children:r.t("image-panel.transform.height")})}),l.jsx("div",{className:H,children:l.jsx("div",{className:k,children:l.jsx(P.InputNumber,{precision:1,value:O,onChange:v=>{Ne(v)}})})})]})}),l.jsx("div",{className:P.clsx(k),children:l.jsxs("label",{children:[l.jsx("div",{className:H,children:l.jsx("div",{className:k,children:r.t("image-panel.transform.lock")})}),l.jsx("div",{className:P.clsx(H,"univer-h-9 univer-items-center univer-justify-center"),children:l.jsx("div",{className:k,children:l.jsx(P.Checkbox,{checked:de,onChange:At})})})]})})]}),l.jsxs("div",{className:H,children:[l.jsx("div",{className:P.clsx(k),children:l.jsxs("label",{children:[l.jsx("div",{className:H,children:l.jsx("div",{className:k,children:r.t("image-panel.transform.x")})}),l.jsx("div",{className:H,children:l.jsx("div",{className:k,children:l.jsx(P.InputNumber,{precision:1,value:T,onChange:v=>{Bt(v)}})})})]})}),l.jsx("div",{className:P.clsx(k),children:l.jsxs("label",{children:[l.jsx("div",{className:H,children:l.jsx("div",{className:k,children:r.t("image-panel.transform.y")})}),l.jsx("div",{className:H,children:l.jsx("div",{className:k,children:l.jsx(P.InputNumber,{precision:1,value:V,onChange:v=>{Ut(v)}})})})]})}),l.jsx("div",{className:P.clsx(k),children:l.jsxs("label",{children:[l.jsx("div",{className:H,children:l.jsx("div",{className:k,children:r.t("image-panel.transform.rotate")})}),l.jsx("div",{className:H,children:l.jsx("div",{className:k,children:l.jsx(P.InputNumber,{precision:1,value:Y,onChange:jt})})})]})})]})]})},Se={id:"sheet.operation.open-image-crop",type:h.CommandType.OPERATION,handler:(i,r)=>!0},ne={id:"sheet.operation.close-image-crop",type:h.CommandType.OPERATION,handler:(i,r)=>!0};var G=(i=>(i.FREE="0",i.R1_1="1",i.R16_9="2",i.R9_16="3",i.R5_4="4",i.R4_5="5",i.R4_3="6",i.R3_4="7",i.R3_2="8",i.R2_3="9",i))(G||{});const he={id:"sheet.operation.Auto-image-crop",type:h.CommandType.OPERATION,handler:(i,r)=>!0},vt=i=>{const r=W.useDependency(h.ICommandService),t=W.useDependency(h.LocaleService),{drawings:e,cropperShow:n}=i;if(e[0]==null)return;const[a,o]=_.useState(G.FREE),c=_.useRef(!1),d=[{label:t.t("image-panel.crop.mode"),value:G.FREE},{label:"1:1",value:G.R1_1},{label:"16:9",value:G.R16_9},{label:"9:16",value:G.R9_16},{label:"5:4",value:G.R5_4},{label:"4:5",value:G.R4_5},{label:"4:3",value:G.R4_3},{label:"3:4",value:G.R3_4},{label:"3:2",value:G.R3_2},{label:"2:3",value:G.R2_3}];_.useEffect(()=>{const p=r.onCommandExecuted(S=>{if(S.id===ne.id){const w=S.params;w!=null&&w.isAuto||(c.current=!1)}});return()=>{p==null||p.dispose()}},[]);function u(p){o(p),c.current&&r.executeCommand(he.id,{cropType:p})}const g=p=>p?"block":"none",f=p=>{r.executeCommand(he.id,{cropType:p}),c.current=!0};return l.jsxs("div",{className:`
|
|
13
13
|
univer-relative univer-mt-5 univer-w-full univer-border-b-0 univer-border-l-0 univer-border-r-0
|
|
14
14
|
univer-border-t univer-border-solid univer-border-t-gray-200
|
|
15
|
-
`,style:{display:g(n)},children:[
|
|
15
|
+
`,style:{display:g(n)},children:[l.jsx("div",{className:H,children:l.jsx("div",{className:k,children:l.jsx("div",{children:t.t("image-panel.crop.title")})})}),l.jsxs("div",{className:H,children:[l.jsx("div",{className:re,children:l.jsx(P.Button,{onClick:()=>{f(a)},children:l.jsxs("span",{className:"univer-flex univer-items-center univer-gap-1",children:[l.jsx(xe,{}),t.t("image-panel.crop.start")]})})}),l.jsx("div",{className:re,children:l.jsx(P.Select,{value:a,options:d,onChange:u})})]})]})},wt=i=>{const r=W.useDependency(D.IDrawingManagerService),t=W.useDependency(y.IRenderManagerService),e=W.useDependency(h.LocaleService),{drawings:n,hasArrange:s=!0,hasTransform:a=!0,hasAlign:o=!0,hasCropper:c=!0,hasGroup:d=!0}=i,u=n[0];if(u==null)return;const{unitId:g}=u,f=t.getRenderById(g),p=f==null?void 0:f.scene;if(p==null)return;const S=p.getTransformerByCreate(),[w,m]=_.useState(!0),[b,C]=_.useState(!0),[B,M]=_.useState(!1),[A,E]=_.useState(!0),[O,N]=_.useState(!1);return _.useEffect(()=>{const T=S.clearControl$.subscribe(x=>{x===!0&&(m(!1),C(!1),M(!1),E(!1),N(!0))}),U=S.changeStart$.subscribe(x=>{const{objects:Y}=x,K=ge(Y,r);K.length===0?(m(!1),C(!1),M(!1),E(!1),N(!0)):K.length===1?(m(!0),C(!0),M(!1),E(!0),N(!1)):(m(!0),C(!1),M(!0),E(!1),N(!1))}),V=r.focus$.subscribe(x=>{x.length===0?(m(!1),C(!1),M(!1),E(!1),N(!0)):x.length===1?(m(!0),C(!0),M(!1),E(!0),N(!1)):(m(!0),C(!1),M(!0),E(!1),N(!1))});return()=>{U.unsubscribe(),T.unsubscribe(),V.unsubscribe()}},[]),l.jsxs(l.Fragment,{children:[l.jsx("div",{style:{display:O===!0?"block":"none",height:"100%"},children:l.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",top:"50%",marginTop:"-100px"},children:l.jsx("span",{children:e.t("image-panel.null")})})}),l.jsx(gt,{arrangeShow:s===!0?w:!1,drawings:n}),l.jsx(mt,{transformShow:a===!0?b:!1,drawings:n}),l.jsx(Je,{alignShow:o===!0?B:!1,drawings:n}),l.jsx(vt,{cropperShow:c===!0?A:!1,drawings:n}),l.jsx(ht,{hasGroup:d,drawings:n})]})},$e=i=>{var w;const{popup:r}=i,t=(w=r==null?void 0:r.extraProps)==null?void 0:w.menuItems;if(!t)return null;const e=W.useDependency(h.ICommandService),n=W.useDependency(h.LocaleService),[s,a]=_.useState(!1),[o,c]=_.useState(!1),d=()=>{c(!0)},u=()=>{c(!1)},g=m=>{a(m)},f=m=>{e.executeCommand(m.commandId,m.commandParams),a(!1)},p=s||o,S=t.filter(m=>!m.disable);return l.jsx("div",{onMouseEnter:d,onMouseLeave:u,children:l.jsx(P.DropdownMenu,{align:"start",items:S.map(m=>({type:"item",children:n.t(m.label),onSelect:()=>f(m)})),open:s,onOpenChange:g,children:l.jsxs("div",{className:P.clsx(`
|
|
16
16
|
univer-flex univer-items-center univer-gap-2 univer-rounded univer-border univer-border-solid
|
|
17
17
|
univer-border-gray-200 univer-p-1
|
|
18
18
|
hover:univer-bg-gray-100
|
|
19
|
-
`,{"univer-bg-gray-100":s,"univer-bg-white":!s}),children:[c.jsx(Ue,{className:"univer-fill-primary-600 univer-text-gray-900"}),p&&c.jsx(xe,{})]})})})},We="COMPONENT_IMAGE_POPUP_MENU",vt="drawing-ui.config",$e={},Me={id:"sheet.operation.image-reset-size",type:h.CommandType.OPERATION,handler:(i,r)=>!0};var wt=Object.getOwnPropertyDescriptor,St=(i,r,t,e)=>{for(var n=e>1?void 0:e?wt(r,t):r,s=i.length-1,a;s>=0;s--)(a=i[s])&&(n=a(n)||n);return n},ze=(i,r)=>(t,e)=>r(t,e,i);let _e=class extends h.Disposable{constructor(i,r){super(),this._componentManager=i,this._commandService=r,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(We,Ve))}_initCommands(){[Se,ne,Me,ve,he].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_init(){this._initCommands(),this._initCustomComponents()}};_e=St([ze(0,h.Inject(V.ComponentManager)),ze(1,h.ICommandService)],_e);var _t=Object.getOwnPropertyDescriptor,Ct=(i,r,t,e)=>{for(var n=e>1?void 0:e?_t(r,t):r,s=i.length-1,a;s>=0;s--)(a=i[s])&&(n=a(n)||n);return n},Ce=(i,r)=>(t,e)=>r(t,e,i);let ye=class extends h.Disposable{constructor(r,t,e,n){super();te(this,"_sceneListenerOnDrawingMap",new WeakSet);this._currentUniverService=r,this._commandService=t,this._renderManagerService=e,this._drawingManagerService=n,this._initialize()}dispose(){super.dispose()}_initialize(){this._recoveryImages(),this._drawingAddListener(),this._drawingRemoveListener(),this._drawingUpdateListener(),this._commandExecutedListener(),this._drawingArrangeListener(),this._drawingGroupListener(),this._drawingRefreshListener(),this._drawingVisibleListener()}_recoveryImages(){const r=this._drawingManagerService.drawingManagerData,t=Pe(this._currentUniverService);if(t==null)return;const{unitId:e,subUnitId:n}=t;Object.keys(r).forEach(s=>{Object.keys(r[s]).forEach(a=>{const o=r[s][a].data;o==null||s!==e||a!==n||Object.keys(o).forEach(l=>{o[l]&&this._insertDrawing([{unitId:s,subUnitId:a,drawingId:l}])})})})}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id===ve.id){const t=r.params;if(t==null)return;this._drawingAlign(t)}}))}_drawingGroupListener(){this.disposeWithMe(this._drawingManagerService.group$.subscribe(r=>{this._groupDrawings(r)})),this.disposeWithMe(this._drawingManagerService.ungroup$.subscribe(r=>{this._ungroupDrawings(r)}))}_getSceneAndTransformerByDrawingSearch(r){if(r==null)return;const t=this._renderManagerService.getRenderById(r),e=t==null?void 0:t.scene;if(e==null)return null;const n=e.getTransformerByCreate();return{scene:e,transformer:n}}_groupDrawings(r){r.forEach(t=>{this._groupDrawing(t)})}_groupDrawing(r){const{parent:t,children:e}=r,{unitId:n,subUnitId:s,drawingId:a}=t,o=this._getSceneAndTransformerByDrawingSearch(t.unitId);if(o==null)return;const{scene:l,transformer:d}=o;this._commandService.syncExecuteCommand(ne.id);const u=[];if(e.forEach(p=>{const S=D.getDrawingShapeKeyByDrawingSearch(p),w=l.getObjectIncludeInGroup(S);if(w==null||u.includes(w))return;u.push(w);const{transform:m}=p;m!=null&&(w.classType===y.RENDER_CLASS_TYPE.GROUP?w.transformByState({left:m.left,top:m.top}):w.transformByState(m))}),u.length===0)return;const g=D.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:s,drawingId:a}),f=new y.Group(g);l.addObject(f,y.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(f),f.addObjects(...u),t.transform&&f.transformByState({left:t.transform.left,top:t.transform.top}),d.clearSelectedObjects(),d.setSelectedControl(f)}_ungroupDrawings(r){r.forEach(t=>{this._ungroupDrawing(t)})}_ungroupDrawing(r){const{parent:t,children:e}=r,n=this._getSceneAndTransformerByDrawingSearch(t.unitId);if(n==null)return;const{scene:s,transformer:a}=n;e.forEach(g=>{const f=D.getDrawingShapeKeyByDrawingSearch(g),p=s.getObjectIncludeInGroup(f);if(p==null)return!0;if(p==null)return;const{transform:S}=g;S!=null&&(p.classType===y.RENDER_CLASS_TYPE.GROUP?p.transformByState({left:S.left,top:S.top}):p.transformByState(S))});const o=D.getDrawingShapeKeyByDrawingSearch(t),l=s.getObject(o),{width:d,height:u}=l;l.getObjects().forEach(g=>{l.removeSelfObjectAndTransform(g.oKey,d,u)}),l.dispose(),a.clearSelectedObjects()}_drawingAlign(r){const{alignType:t}=r,e=this._drawingManagerService.getFocusDrawings();if(t===j.default)return;const n=[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY,d=0;e.forEach(u=>{const{unitId:g,subUnitId:f,drawingId:p,drawingType:S}=u,w=this._drawingManagerService.getDrawingByParam({unitId:g,subUnitId:f,drawingId:p});if(w==null||w.transform==null)return;n.push({unitId:g,subUnitId:f,drawingId:p,drawingType:S,transform:w.transform});const{left:m=0,top:b=0,width:C=0,height:B=0}=w.transform;s=Math.min(s,m),a=Math.min(a,b),o=Math.max(o,m+C),l=Math.max(l,b+B),d++}),d!==0&&(this._sortDrawingTransform(n,t),this._applyAlignType(n,t,s,a,o,l,d))}_applyAlignType(r,t,e,n,s,a,o){const l=Math.round((s-e)/o*10)/10,d=Math.round((a-n)/o*10)/10,u=[],g=this._getSceneAndTransformerByDrawingSearch(r[0].unitId);if(g==null)return;const{scene:f,transformer:p}=g;r.forEach((S,w)=>{const{unitId:m,subUnitId:b,drawingId:C,transform:B,drawingType:M}=S,{left:A=0,top:E=0,width:O=0,height:N=0}=B;let T=A,U=E;switch(t){case j.left:T=e;break;case j.center:T=e+(s-e)/2-O/2;break;case j.right:T=s-O;break;case j.top:U=n;break;case j.middle:U=n+(a-n)/2-N/2;break;case j.bottom:U=a-N;break;case j.horizon:T=e+l*w;break;case j.vertical:U=n+d*w;break}(T!==A||U!==E)&&u.push({unitId:m,subUnitId:b,drawingId:C,drawingType:M,transform:{left:T,top:U}})}),this._drawingManagerService.featurePluginUpdateNotification(u),p.refreshControls().changeNotification()}_sortDrawingTransform(r,t){r.sort((e,n)=>{const s=e.transform,a=n.transform,{left:o=0,top:l=0,width:d=0,height:u=0}=s,{left:g=0,top:f=0,width:p=0,height:S=0}=a;switch(t){case j.left:return o-g;case j.center:return o+d/2-(g+p/2);case j.right:return o+d-(g+p);case j.top:return l-f;case j.middle:return l+u/2-(f+S/2);case j.bottom:return l+u-(f+S);case j.horizon:return o+d/2-(g+p/2);case j.vertical:return l+u/2-(f+S/2);default:return 0}})}_drawingArrangeListener(){this.disposeWithMe(this._drawingManagerService.order$.subscribe(r=>{this._drawingArrange(r)}))}_drawingArrange(r){const{unitId:t,subUnitId:e,drawingIds:n}=r,s=this._getSceneAndTransformerByDrawingSearch(t);if(s==null)return;const{scene:a}=s;n.forEach(o=>{const l=D.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:e,drawingId:o}),d=a.fuzzyMathObjects(l,!0);if(d==null||d.length===0)return;const u=this._drawingManagerService.getDrawingOrder(t,e).indexOf(o);for(const g of d)g.setProps({zIndex:u}),g.makeDirty()})}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(r=>{this._insertDrawing(r)}))}_insertDrawing(r){const t=[];r.forEach(e=>{const{unitId:n}=e;if(this._drawingManagerService.getDrawingByParam(e)==null)return;const a=this._getSceneAndTransformerByDrawingSearch(n);if(a==null)return;const{scene:o}=a;t.includes(o)||t.push(o)}),t.forEach(e=>{this._sceneListenerOnDrawingMap.has(e)||(this._addListenerOnDrawing(e),this._sceneListenerOnDrawingMap.add(e))})}_drawingRemoveListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(r=>{r.forEach(t=>{var u;const{unitId:e,subUnitId:n,drawingId:s}=t,a=this._getSceneAndTransformerByDrawingSearch(e);if(a==null)return;const{scene:o}=a,l=D.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:s}),d=o.fuzzyMathObjects(l,!0);if(d.length>0){for(const g of d)g.dispose();(u=o.getTransformer())==null||u.clearSelectedObjects()}})}))}_drawingUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(r=>{r.forEach(t=>{var O;const{unitId:e,subUnitId:n,drawingId:s}=t,a=this._drawingManagerService.getDrawingByParam(t);if(a==null)return;const{transform:o,drawingType:l}=a,d=this._getSceneAndTransformerByDrawingSearch(e);if(d==null)return;const{scene:u,transformer:g}=d;if(o==null)return!0;const{left:f=0,top:p=0,width:S=0,height:w=0,angle:m=0,flipX:b=!1,flipY:C=!1,skewX:B=0,skewY:M=0}=o,A=D.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:s}),E=u.getObject(A);if(E==null)return!0;E.transformByState({left:f,top:p,width:S,height:w,angle:m,flipX:b,flipY:C,skewX:B,skewY:M}),(O=u.getTransformer())==null||O.debounceRefreshControls()})}))}_drawingRefreshListener(){this.disposeWithMe(this._drawingManagerService.refreshTransform$.subscribe(r=>{r.forEach(t=>{const{unitId:e,subUnitId:n,drawingId:s}=t,a=this._getSceneAndTransformerByDrawingSearch(e);if(a==null)return;const o=this._drawingManagerService.getDrawingByParam(t);if(o==null)return;const{transform:l}=o,{scene:d}=a,u=D.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:s}),g=d.getObject(u);if(g==null||l==null)return!0;const{left:f=0,top:p=0,width:S=0,height:w=0,angle:m=0,flipX:b=!1,flipY:C=!1,skewX:B=0,skewY:M=0}=l;g.transformByState({left:f,top:p,width:S,height:w,angle:m,flipX:b,flipY:C,skewX:B,skewY:M})})}))}_drawingVisibleListener(){this.disposeWithMe(this._drawingManagerService.visible$.subscribe(r=>{r.forEach(t=>{const{unitId:e,subUnitId:n,drawingId:s,visible:a}=t,o=this._getSceneAndTransformerByDrawingSearch(e);if(o==null)return;const{scene:l}=o,d=D.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:s}),u=l.getObject(d);if(u==null)return!0;a?u.show():u.hide()})}))}_filterUpdateParams(r,t){return r.filter((e,n)=>{if(e==null)return!1;const{transform:s}=e;return h.checkIfMove(s,t==null?void 0:t[n])})}_addListenerOnDrawing(r){const t=r.getTransformerByCreate();let e=null;this.disposeWithMe(h.toDisposable(t.changeStart$.subscribe(n=>{const{objects:s}=n,a=Array.from(s.values()),o=[];e=a.map(l=>{const{left:d,top:u,height:g,width:f,angle:p,oKey:S,isInGroup:w}=l,m=this._drawingManagerService.getDrawingOKey(S);if(w||l instanceof y.Group){let b=l.ancestorGroup;if(b==null&&l instanceof y.Group&&(b=l),b==null)return null;const C=this._drawingManagerService.getDrawingOKey(b.oKey);if(C){const{unitId:B,subUnitId:M,drawingId:A}=C;o.push({unitId:B,subUnitId:M,drawingId:A});const{left:E,top:O,height:N,width:T,angle:U}=b;return{left:E,top:O,height:N,width:T,angle:U}}}else if(m!=null){const{unitId:b,subUnitId:C,drawingId:B}=m;return o.push({unitId:b,subUnitId:C,drawingId:B}),{left:d,top:u,height:g,width:f,angle:p}}return null}).filter(l=>l!=null),o.length>0?this._commandService.syncExecuteCommand(D.SetDrawingSelectedOperation.id,o):this._commandService.syncExecuteCommand(D.SetDrawingSelectedOperation.id,[])}))),this.disposeWithMe(h.toDisposable(t.changeEnd$.subscribe(n=>{const{objects:s}=n,a=this._filterUpdateParams(ge(s,this._drawingManagerService),e);a.length>0&&this._drawingManagerService.featurePluginUpdateNotification(a)})))}};ye=Ct([Ce(0,h.IUniverInstanceService),Ce(1,h.ICommandService),Ce(2,y.IRenderManagerService),Ce(3,D.IDrawingManagerService)],ye);class fe extends y.Shape{constructor(t,e){e==null&&(e={}),e.transformerConfig={keepRatio:!1,isCropper:!0,anchorFill:"rgb(0, 0, 0)",anchorStroke:"rgb(255, 255, 255)",anchorSize:24};super(t,e);te(this,"_srcRect");te(this,"_prstGeom");te(this,"_applyTransform");te(this,"_dragPadding",8);te(this,"_cacheCanvas");e!=null&&e.srcRect&&(this._srcRect=e.srcRect),e!=null&&e.prstGeom&&(this._prstGeom=e.prstGeom),e!=null&&e.applyTransform&&(this._applyTransform=e.applyTransform),e!=null&&e.dragPadding&&(this._dragPadding=e.dragPadding),this._applyProps()}refreshSrcRect(t,e){this._srcRect=t,this._applyTransform=e,this._applyProps()}get srcRect(){return this._srcRect}dispose(){var t;super.dispose(),(t=this._cacheCanvas)==null||t.dispose(),this._srcRect=null}isHit(t){const e=this.getInverseCoord(t);return e.x>=-this.strokeWidth/2&&e.x<=this.width+this.strokeWidth/2&&e.y>=-this.strokeWidth/2&&e.y<=this.height+this.strokeWidth/2&&!this._inSurround(e)}_inSurround(t){const e=this._dragPadding;return t.x>=e-this.strokeWidth/2&&t.x<=this.width+this.strokeWidth/2-e&&t.y>=e-this.strokeWidth/2&&t.y<=this.height+this.strokeWidth/2-e}render(t,e){return this.visible?(t.save(),this._draw(t),t.restore(),this.makeDirty(!1),this):(this.makeDirty(!1),this)}_draw(t){var l,d;const n=this.getScene().getEngine(),{width:s,height:a}=n;this._initialCacheCanvas(),(l=this._cacheCanvas)==null||l.clear();const o=(d=this._cacheCanvas)==null?void 0:d.getContext();o!=null&&(o.save(),y.Rect.drawWith(o,{left:0,top:0,width:s,height:a,fill:"rgba(0, 0, 0, 0.5)"}),o.setTransform(t.getTransform()),this._clipForApplyObject(o),this._applyCache(t),o.restore())}_clipForApplyObject(t){let e=0;if(this._prstGeom!=null&&(e=1),t.globalCompositeOperation="destination-out",t.beginPath(),e===0){const n=this.transform.getMatrix();t.transform(n[0],n[1],n[2],n[3],n[4],n[5]),t.rect(0,0,this.width,this.height),t.fill()}}_applyProps(){if(this._applyTransform==null)return;let t=0,e=0,n=0,s=0;const{left:a=0,top:o=0,width:l=0,height:d=0,angle:u}=this._applyTransform;if(this._srcRect!=null){const{left:p=0,top:S=0,right:w=0,bottom:m=0}=this._srcRect;t=p,e=S,n=w,s=m}const g=a+t,f=o+e;this.transformByState({left:g,top:f,width:a+l-n-g,height:o+d-s-f,angle:u})}_applyCache(t){if(!t||this._cacheCanvas==null)return;const e=this._cacheCanvas.getContext();e.save(),t.save(),t.setTransform(1,0,0,1,0,0),e.setTransform(1,0,0,1,0,0),t.drawImage(this._cacheCanvas.getCanvasEle(),0,0),t.restore(),e.restore()}_initialCacheCanvas(){if(this._cacheCanvas!=null)return;const t=this.getScene();if(t==null)return;this._cacheCanvas=new y.Canvas;const e=t.getEngine();this._cacheCanvas.setSize(e.width,e.height),e.onTransformChange$.subscribeEvent(()=>{var n;(n=this._cacheCanvas)==null||n.setSize(e.width,e.height),this.makeDirty(!0)})}}var yt=Object.getOwnPropertyDescriptor,bt=(i,r,t,e)=>{for(var n=e>1?void 0:e?yt(r,t):r,s=i.length-1,a;s>=0;s--)(a=i[s])&&(n=a(n)||n);return n},le=(i,r)=>(t,e)=>r(t,e,i);let be=class extends h.Disposable{constructor(r,t,e,n,s,a){super();te(this,"_sceneListenerOnImageMap",new WeakSet);this._commandService=r,this._drawingManagerService=t,this._renderManagerService=e,this._univerInstanceService=n,this._messageService=s,this._localeService=a,this._init()}_init(){this._initOpenCrop(),this._initCloseCrop(),this._initAutoCrop()}_initAutoCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id!==he.id)return;const t=r.params;if(t==null)return;const{cropType:e}=t,n=this._drawingManagerService.getFocusDrawings();if(n.length!==1)return;const s=n[0],{unitId:a,subUnitId:o,drawingId:l}=s,d=this._renderManagerService.getRenderById(a),u=d==null?void 0:d.scene;if(u==null)return!0;this._searchCropObject(u)!=null&&this._commandService.syncExecuteCommand(ne.id,{isAuto:!0});const f=D.getDrawingShapeKeyByDrawingSearch({unitId:a,subUnitId:o,drawingId:l}),p=u.getObject(f);if(!(p instanceof y.Image)){this._messageService.show({type:P.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}p!=null&&(this._updateCropperObject(e,p),this._commandService.executeCommand(Se.id,{unitId:a,subUnitId:o,drawingId:l}))}))}_calculateSrcRectByRatio(r,t,e,n,s,a){const o=e/n,l=s/a;let d=e,u=n;o>l?d=n*l:u=e/l;const g=(e-d)/2,f=(n-u)/2;return{left:y.precisionTo(g,1),top:y.precisionTo(f,1),right:y.precisionTo(e-(g+d),1),bottom:y.precisionTo(n-(f+u),1)}}_updateCropperObject(r,t){const{left:e,top:n,width:s,height:a}=t.calculateTransformWithSrcRect();let o;switch(r){case G.R1_1:o=this._calculateSrcRectByRatio(e,n,s,a,1,1);break;case G.R16_9:o=this._calculateSrcRectByRatio(e,n,s,a,16,9);break;case G.R9_16:o=this._calculateSrcRectByRatio(e,n,s,a,9,16);break;case G.R5_4:o=this._calculateSrcRectByRatio(e,n,s,a,5,4);break;case G.R4_5:o=this._calculateSrcRectByRatio(e,n,s,a,4,5);break;case G.R4_3:o=this._calculateSrcRectByRatio(e,n,s,a,4,3);break;case G.R3_4:o=this._calculateSrcRectByRatio(e,n,s,a,3,4);break;case G.R3_2:o=this._calculateSrcRectByRatio(e,n,s,a,3,2);break;case G.R2_3:o=this._calculateSrcRectByRatio(e,n,s,a,2,3);break;case G.FREE:}if(o==null)return;t.setSrcRect(o);const{left:l=0,top:d=0,bottom:u=0,right:g=0}=o;t.transformByStateCloseCropper({left:e+l,top:n+d,width:s-g-l,height:a-u-d})}_initOpenCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id!==Se.id)return;const t=r.params;if(t==null)return;const{unitId:e,subUnitId:n,drawingId:s}=t,a=this._renderManagerService.getRenderById(e),o=a==null?void 0:a.scene;if(o==null)return!0;if(this._sceneListenerOnImageMap.has(o)||(this._addListenerOnImage(o),this._sceneListenerOnImageMap.add(o)),this._drawingManagerService.getDrawingByParam({unitId:e,subUnitId:n,drawingId:s})==null)return;const d=D.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:s}),u=o.getObject(d);if(u==null)return;if(!(u instanceof y.Image)){this._messageService.show({type:P.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}const g=o.getTransformer();g==null||g.clearControls();const f=new fe(`${d}-crop`,{srcRect:u.srcRect,prstGeom:u.prstGeom,applyTransform:u.calculateTransformWithSrcRect()});o.addObject(f,u.getLayerIndex()+1).attachTransformerTo(f),g==null||g.createControlForCopper(f),this._addHoverForImageCopper(f),u.openRenderByCropper(),g==null||g.refreshControls(),f.makeDirty(!0),this._commandService.syncExecuteCommand(D.SetDrawingSelectedOperation.id,[{unitId:e,subUnitId:n,drawingId:s}])}))}_searchCropObject(r){const t=r.getAllObjectsByOrder();for(const e of t)if(e instanceof fe)return e}_initCloseCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id!==ne.id)return;const e=this._univerInstanceService.getFocusedUnit();if(e==null)return;const n=e.getUnitId(),s=this._renderManagerService.getRenderById(n),a=s==null?void 0:s.scene;if(a==null)return!0;const o=this._searchCropObject(a);if(o==null)return;const l=this._getApplyObjectByCropObject(o);if(l==null)return;const d=a.getTransformerByCreate();d.detachFrom(o),d.clearCopperControl();const u=this._getSrcRectByTransformState(l,o),g=this._drawingManagerService.getDrawingOKey(l.oKey);if(g!=null){const{left:f,top:p,height:S,width:w}=o;this._drawingManagerService.featurePluginUpdateNotification([{...g,transform:{...g.transform,left:f,top:p,height:S,width:w},srcRect:u.srcRectAngle}])}l.setSrcRect({...u.srcRectAngle}),l.closeRenderByCropper(),l.makeDirty(!0),o==null||o.dispose()}));const r=this._univerInstanceService.getCurrentTypeOfUnit$(h.UniverInstanceType.UNIVER_SHEET).pipe(Ee.switchMap(t=>t?t.activeSheet$:Ee.of(null)));this.disposeWithMe(r.subscribe(()=>{this._commandService.syncExecuteCommand(ne.id)}))}_getApplyObjectByCropObject(r){const t=r.oKey,e=t.slice(0,t.length-5),n=r.getScene();if(!n)return null;const s=n.getObject(e);return s==null?null:s}_addListenerOnImage(r){const t=r.getTransformerByCreate();let e=null;this.disposeWithMe(t.changeStart$.subscribe(n=>{const{objects:s}=n,a=s.values().next().value;if(a==null||!(a instanceof fe))return;const{left:o,top:l,height:d,width:u,angle:g}=a;e={left:o,top:l,height:d,width:u,angle:g},t.clearCopperControl()})),this.disposeWithMe(t.changeEnd$.subscribe(n=>{const{objects:s}=n,a=s.values().next().value;if(a==null||!(a instanceof fe))return;const{left:o,top:l,height:d,width:u,angle:g}=a;if(!h.checkIfMove({left:o,top:l,height:d,width:u,angle:g},e))return;const f=this._getApplyObjectByCropObject(a);if(f==null)return;const p=this._getSrcRectByTransformState(f,a);a.refreshSrcRect(p.srcRect,f.getState()),t.createControlForCopper(a)})),this._endCropListener(r)}_addHoverForImageCopper(r){this.disposeWithMe(r.onPointerEnter$.subscribeEvent(()=>{r.cursor=y.CURSOR_TYPE.MOVE})),this.disposeWithMe(r.onPointerLeave$.subscribeEvent(()=>{r.cursor=y.CURSOR_TYPE.DEFAULT}))}_endCropListener(r){const t=r.getTransformerByCreate();this.disposeWithMe(t.clearControl$.subscribe(e=>{e===!0&&this._commandService.syncExecuteCommand(ne.id)}))}_getSrcRectByTransformState(r,t){const{left:e,top:n,height:s,width:a,strokeWidth:o,angle:l}=t,{left:d,top:u,width:g,height:f,angle:p,strokeWidth:S}=r,w=e-d,m=n-u,b={left:w,top:m,right:g-w-a,bottom:f-m-s},C={...b};if(p!==0){const B=e+a/2,M=n+s/2,A=new y.Vector2(B,M),E=g/2+d,O=f/2+u,N=new y.Vector2(E,O),T=new y.Vector2(d,u);T.rotateByPoint(y.degToRad(p),N);const U=T.clone();U.rotateByPoint(y.degToRad(-p),A);const R=e-U.x,x=n-U.y;C.left=R,C.top=x,C.right=g-R-a,C.bottom=f-x-s}return{srcRect:b,srcRectAngle:C}}};be=bt([le(0,h.ICommandService),le(1,D.IDrawingManagerService),le(2,y.IRenderManagerService),le(3,h.IUniverInstanceService),le(4,V.IMessageService),le(5,h.Inject(h.LocaleService))],be);var It=Object.getOwnPropertyDescriptor,Dt=(i,r,t,e)=>{for(var n=e>1?void 0:e?It(r,t):r,s=i.length-1,a;s>=0;s--)(a=i[s])&&(n=a(n)||n);return n},ae=(i,r)=>(t,e)=>r(t,e,i);let Ie=class extends h.Disposable{constructor(i,r,t,e,n,s,a){super(),this._commandService=i,this._renderManagerService=r,this._drawingManagerService=t,this._dialogService=e,this._imageIoService=n,this._currentUniverService=s,this._drawingRenderService=a,this._initialize()}dispose(){super.dispose()}_initialize(){this._drawingAddListener(),this._commandExecutedListener(),this._imageUpdateListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===Me.id){const r=i.params;if(r==null)return;this._resetImageSize(r)}}))}_getSceneAndTransformerByDrawingSearch(i){if(i==null)return;const r=this._renderManagerService.getRenderById(i),t=r==null?void 0:r.scene;if(t==null)return null;const e=t.getTransformerByCreate();return{scene:t,transformer:e}}_resetImageSize(i){const r=[],t=[];i.forEach(e=>{const{unitId:n,subUnitId:s,drawingId:a}=e,o=this._getSceneAndTransformerByDrawingSearch(n);if(o==null)return;const{scene:l}=o,d=D.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:s,drawingId:a}),u=l.getObject(d);if(u==null)return!0;const g=this._drawingManagerService.getDrawingByParam(e);if(g==null)return!0;if(g.drawingType!==h.DrawingTypeEnum.DRAWING_IMAGE)return;u.resetSize();const{width:f,height:p}=u.getNativeSize();t.includes(l)===!1&&t.push(l),r.push({...g,transform:{...g.transform,height:p,width:f,angle:0},srcRect:null,prstGeom:null})}),this._drawingManagerService.featurePluginUpdateNotification(r),t.forEach(e=>{e.getTransformerByCreate().refreshControls().changeNotification()}),this._commandService.syncExecuteCommand(D.SetDrawingSelectedOperation.id,i)}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(i=>{this._insertImages(i)}))}_insertImages(i){i.forEach(async r=>{var l;const{unitId:t,subUnitId:e}=r,n=this._getSceneAndTransformerByDrawingSearch(t),s=(l=Pe(this._currentUniverService,t))==null?void 0:l.subUnitId;if(n==null||s!==e)return;const a=this._drawingManagerService.getDrawingByParam(r);if(a==null)return;const o=await this._drawingRenderService.renderImages(a,n.scene);if(this._drawingManagerService.refreshTransform([a]),!(o==null||o.length===0))for(const d of o)this._addHoverForImage(d),this._addDialogForImage(d)})}_imageUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(i=>{i.forEach(r=>{const{unitId:t,subUnitId:e,drawingId:n}=r,s=this._drawingManagerService.getDrawingByParam(r);if(s==null)return;const{transform:a,drawingType:o,srcRect:l,prstGeom:d,source:u,imageSourceType:g}=s;if(o!==h.DrawingTypeEnum.DRAWING_IMAGE)return;const f=this._getSceneAndTransformerByDrawingSearch(t);if(f==null)return;const{scene:p,transformer:S}=f;if(a==null)return!0;const w=D.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:e,drawingId:n}),m=p.getObject(w);if(m==null)return!0;m.setSrcRect(l),m.setPrstGeom(d),u!=null&&u.length>0&&(g===h.ImageSourceType.BASE64||g===h.ImageSourceType.URL)&&m.changeSource(u)})}))}_addHoverForImage(i){this.disposeWithMe(h.toDisposable(i.onPointerEnter$.subscribeEvent(()=>{i.cursor=y.CURSOR_TYPE.GRAB}))),this.disposeWithMe(h.toDisposable(i.onPointerLeave$.subscribeEvent(()=>{i.cursor=y.CURSOR_TYPE.DEFAULT})))}_addDialogForImage(i){this.disposeWithMe(h.toDisposable(i.onDblclick$.subscribeEvent(()=>{const r=`${i.oKey}-viewer-dialog`;this._drawingRenderService.previewImage(r,i.getNative().src,i.getNativeSize().width,i.getNativeSize().height)})))}};Ie=Dt([ae(0,h.ICommandService),ae(1,y.IRenderManagerService),ae(2,D.IDrawingManagerService),ae(3,V.IDialogService),ae(4,D.IImageIoService),ae(5,h.IUniverInstanceService),ae(6,h.Inject(I.DrawingRenderService))],Ie);var Mt=Object.getOwnPropertyDescriptor,Ot=(i,r,t,e)=>{for(var n=e>1?void 0:e?Mt(r,t):r,s=i.length-1,a;s>=0;s--)(a=i[s])&&(n=a(n)||n);return n},Ke=(i,r)=>(t,e)=>r(t,e,i);const Nt="UNIVER_DRAWING_UI_PLUGIN";I.UniverDrawingUIPlugin=(Oe=class extends h.Plugin{constructor(r=$e,t,e){super(),this._config=r,this._injector=t,this._configService=e;const{menu:n,...s}=h.merge({},$e,this._config);n&&this._configService.setConfig("menu",n,{merge:!0}),this._configService.setConfig(vt,s)}onStarting(){this._initDependencies()}onRendered(){this._injector.get(ye),this._injector.get(_e),this._injector.get(be),this._injector.get(Ie)}_initDependencies(){[[I.DrawingRenderService],[ye],[_e],[be],[Ie]].forEach(t=>this._injector.add(t))}},te(Oe,"pluginName",Nt),Oe),I.UniverDrawingUIPlugin=Ot([Ke(1,h.Inject(h.Injector)),Ke(2,h.IConfigService)],I.UniverDrawingUIPlugin),I.AutoImageCropOperation=he,I.COMPONENT_IMAGE_POPUP_MENU=We,I.CloseImageCropOperation=ne,I.DrawingCommonPanel=mt,I.ImageCropperObject=fe,I.ImagePopupMenu=Ve,I.ImageResetSizeOperation=Me,I.OpenImageCropOperation=Se,I.SetDrawingAlignOperation=ve,I.getUpdateParams=ge,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})});
|
|
19
|
+
`,{"univer-bg-gray-100":s,"univer-bg-white":!s}),children:[l.jsx(Ae,{className:"univer-fill-primary-600 univer-text-gray-900"}),p&&l.jsx(ke,{className:"univer-text-[10px] univer-text-gray-400"})]})})})},ze="COMPONENT_IMAGE_POPUP_MENU",St="drawing-ui.config",Ke={},Me={id:"sheet.operation.image-reset-size",type:h.CommandType.OPERATION,handler:(i,r)=>!0},_t=i=>{const{src:r}=i;return r?l.jsx("div",{className:"univer-py-2",children:l.jsx("img",{className:"univer-relative univer-block univer-size-full",src:r,alt:"Univer Image Viewer"})}):null};var Ct=Object.getOwnPropertyDescriptor,yt=(i,r,t,e)=>{for(var n=e>1?void 0:e?Ct(r,t):r,s=i.length-1,a;s>=0;s--)(a=i[s])&&(n=a(n)||n);return n},Fe=(i,r)=>(t,e)=>r(t,e,i);let _e=class extends h.Disposable{constructor(i,r){super(),this._componentManager=i,this._commandService=r,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(ze,$e)),this.disposeWithMe(i.register(Be,_t))}_initCommands(){[Se,ne,Me,ve,he].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_init(){this._initCommands(),this._initCustomComponents()}};_e=yt([Fe(0,h.Inject(W.ComponentManager)),Fe(1,h.ICommandService)],_e);var bt=Object.getOwnPropertyDescriptor,It=(i,r,t,e)=>{for(var n=e>1?void 0:e?bt(r,t):r,s=i.length-1,a;s>=0;s--)(a=i[s])&&(n=a(n)||n);return n},Ce=(i,r)=>(t,e)=>r(t,e,i);let ye=class extends h.Disposable{constructor(r,t,e,n){super();te(this,"_sceneListenerOnDrawingMap",new WeakSet);this._currentUniverService=r,this._commandService=t,this._renderManagerService=e,this._drawingManagerService=n,this._initialize()}dispose(){super.dispose()}_initialize(){this._recoveryImages(),this._drawingAddListener(),this._drawingRemoveListener(),this._drawingUpdateListener(),this._commandExecutedListener(),this._drawingArrangeListener(),this._drawingGroupListener(),this._drawingRefreshListener(),this._drawingVisibleListener()}_recoveryImages(){const r=this._drawingManagerService.drawingManagerData,t=Pe(this._currentUniverService);if(t==null)return;const{unitId:e,subUnitId:n}=t;Object.keys(r).forEach(s=>{Object.keys(r[s]).forEach(a=>{const o=r[s][a].data;o==null||s!==e||a!==n||Object.keys(o).forEach(c=>{o[c]&&this._insertDrawing([{unitId:s,subUnitId:a,drawingId:c}])})})})}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id===ve.id){const t=r.params;if(t==null)return;this._drawingAlign(t)}}))}_drawingGroupListener(){this.disposeWithMe(this._drawingManagerService.group$.subscribe(r=>{this._groupDrawings(r)})),this.disposeWithMe(this._drawingManagerService.ungroup$.subscribe(r=>{this._ungroupDrawings(r)}))}_getSceneAndTransformerByDrawingSearch(r){if(r==null)return;const t=this._renderManagerService.getRenderById(r),e=t==null?void 0:t.scene;if(e==null)return null;const n=e.getTransformerByCreate();return{scene:e,transformer:n}}_groupDrawings(r){r.forEach(t=>{this._groupDrawing(t)})}_groupDrawing(r){const{parent:t,children:e}=r,{unitId:n,subUnitId:s,drawingId:a}=t,o=this._getSceneAndTransformerByDrawingSearch(t.unitId);if(o==null)return;const{scene:c,transformer:d}=o;this._commandService.syncExecuteCommand(ne.id);const u=[];if(e.forEach(p=>{const S=D.getDrawingShapeKeyByDrawingSearch(p),w=c.getObjectIncludeInGroup(S);if(w==null||u.includes(w))return;u.push(w);const{transform:m}=p;m!=null&&(w.classType===y.RENDER_CLASS_TYPE.GROUP?w.transformByState({left:m.left,top:m.top}):w.transformByState(m))}),u.length===0)return;const g=D.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:s,drawingId:a}),f=new y.Group(g);c.addObject(f,y.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(f),f.addObjects(...u),t.transform&&f.transformByState({left:t.transform.left,top:t.transform.top}),d.clearSelectedObjects(),d.setSelectedControl(f)}_ungroupDrawings(r){r.forEach(t=>{this._ungroupDrawing(t)})}_ungroupDrawing(r){const{parent:t,children:e}=r,n=this._getSceneAndTransformerByDrawingSearch(t.unitId);if(n==null)return;const{scene:s,transformer:a}=n;e.forEach(g=>{const f=D.getDrawingShapeKeyByDrawingSearch(g),p=s.getObjectIncludeInGroup(f);if(p==null)return!0;if(p==null)return;const{transform:S}=g;S!=null&&(p.classType===y.RENDER_CLASS_TYPE.GROUP?p.transformByState({left:S.left,top:S.top}):p.transformByState(S))});const o=D.getDrawingShapeKeyByDrawingSearch(t),c=s.getObject(o),{width:d,height:u}=c;c.getObjects().forEach(g=>{c.removeSelfObjectAndTransform(g.oKey,d,u)}),c.dispose(),a.clearSelectedObjects()}_drawingAlign(r){const{alignType:t}=r,e=this._drawingManagerService.getFocusDrawings();if(t===j.default)return;const n=[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY,d=0;e.forEach(u=>{const{unitId:g,subUnitId:f,drawingId:p,drawingType:S}=u,w=this._drawingManagerService.getDrawingByParam({unitId:g,subUnitId:f,drawingId:p});if(w==null||w.transform==null)return;n.push({unitId:g,subUnitId:f,drawingId:p,drawingType:S,transform:w.transform});const{left:m=0,top:b=0,width:C=0,height:B=0}=w.transform;s=Math.min(s,m),a=Math.min(a,b),o=Math.max(o,m+C),c=Math.max(c,b+B),d++}),d!==0&&(this._sortDrawingTransform(n,t),this._applyAlignType(n,t,s,a,o,c,d))}_applyAlignType(r,t,e,n,s,a,o){const c=Math.round((s-e)/o*10)/10,d=Math.round((a-n)/o*10)/10,u=[],g=this._getSceneAndTransformerByDrawingSearch(r[0].unitId);if(g==null)return;const{scene:f,transformer:p}=g;r.forEach((S,w)=>{const{unitId:m,subUnitId:b,drawingId:C,transform:B,drawingType:M}=S,{left:A=0,top:E=0,width:O=0,height:N=0}=B;let T=A,U=E;switch(t){case j.left:T=e;break;case j.center:T=e+(s-e)/2-O/2;break;case j.right:T=s-O;break;case j.top:U=n;break;case j.middle:U=n+(a-n)/2-N/2;break;case j.bottom:U=a-N;break;case j.horizon:T=e+c*w;break;case j.vertical:U=n+d*w;break}(T!==A||U!==E)&&u.push({unitId:m,subUnitId:b,drawingId:C,drawingType:M,transform:{left:T,top:U}})}),this._drawingManagerService.featurePluginUpdateNotification(u),p.refreshControls().changeNotification()}_sortDrawingTransform(r,t){r.sort((e,n)=>{const s=e.transform,a=n.transform,{left:o=0,top:c=0,width:d=0,height:u=0}=s,{left:g=0,top:f=0,width:p=0,height:S=0}=a;switch(t){case j.left:return o-g;case j.center:return o+d/2-(g+p/2);case j.right:return o+d-(g+p);case j.top:return c-f;case j.middle:return c+u/2-(f+S/2);case j.bottom:return c+u-(f+S);case j.horizon:return o+d/2-(g+p/2);case j.vertical:return c+u/2-(f+S/2);default:return 0}})}_drawingArrangeListener(){this.disposeWithMe(this._drawingManagerService.order$.subscribe(r=>{this._drawingArrange(r)}))}_drawingArrange(r){const{unitId:t,subUnitId:e,drawingIds:n}=r,s=this._getSceneAndTransformerByDrawingSearch(t);if(s==null)return;const{scene:a}=s;n.forEach(o=>{const c=D.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:e,drawingId:o}),d=a.fuzzyMathObjects(c,!0);if(d==null||d.length===0)return;const u=this._drawingManagerService.getDrawingOrder(t,e).indexOf(o);for(const g of d)g.setProps({zIndex:u}),g.makeDirty()})}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(r=>{this._insertDrawing(r)}))}_insertDrawing(r){const t=[];r.forEach(e=>{const{unitId:n}=e;if(this._drawingManagerService.getDrawingByParam(e)==null)return;const a=this._getSceneAndTransformerByDrawingSearch(n);if(a==null)return;const{scene:o}=a;t.includes(o)||t.push(o)}),t.forEach(e=>{this._sceneListenerOnDrawingMap.has(e)||(this._addListenerOnDrawing(e),this._sceneListenerOnDrawingMap.add(e))})}_drawingRemoveListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(r=>{r.forEach(t=>{var u;const{unitId:e,subUnitId:n,drawingId:s}=t,a=this._getSceneAndTransformerByDrawingSearch(e);if(a==null)return;const{scene:o}=a,c=D.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:s}),d=o.fuzzyMathObjects(c,!0);if(d.length>0){for(const g of d)g.dispose();(u=o.getTransformer())==null||u.clearSelectedObjects()}})}))}_drawingUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(r=>{r.forEach(t=>{var O;const{unitId:e,subUnitId:n,drawingId:s}=t,a=this._drawingManagerService.getDrawingByParam(t);if(a==null)return;const{transform:o,drawingType:c}=a,d=this._getSceneAndTransformerByDrawingSearch(e);if(d==null)return;const{scene:u,transformer:g}=d;if(o==null)return!0;const{left:f=0,top:p=0,width:S=0,height:w=0,angle:m=0,flipX:b=!1,flipY:C=!1,skewX:B=0,skewY:M=0}=o,A=D.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:s}),E=u.getObject(A);if(E==null)return!0;E.transformByState({left:f,top:p,width:S,height:w,angle:m,flipX:b,flipY:C,skewX:B,skewY:M}),(O=u.getTransformer())==null||O.debounceRefreshControls()})}))}_drawingRefreshListener(){this.disposeWithMe(this._drawingManagerService.refreshTransform$.subscribe(r=>{r.forEach(t=>{const{unitId:e,subUnitId:n,drawingId:s}=t,a=this._getSceneAndTransformerByDrawingSearch(e);if(a==null)return;const o=this._drawingManagerService.getDrawingByParam(t);if(o==null)return;const{transform:c}=o,{scene:d}=a,u=D.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:s}),g=d.getObject(u);if(g==null||c==null)return!0;const{left:f=0,top:p=0,width:S=0,height:w=0,angle:m=0,flipX:b=!1,flipY:C=!1,skewX:B=0,skewY:M=0}=c;g.transformByState({left:f,top:p,width:S,height:w,angle:m,flipX:b,flipY:C,skewX:B,skewY:M})})}))}_drawingVisibleListener(){this.disposeWithMe(this._drawingManagerService.visible$.subscribe(r=>{r.forEach(t=>{const{unitId:e,subUnitId:n,drawingId:s,visible:a}=t,o=this._getSceneAndTransformerByDrawingSearch(e);if(o==null)return;const{scene:c}=o,d=D.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:s}),u=c.getObject(d);if(u==null)return!0;a?u.show():u.hide()})}))}_filterUpdateParams(r,t){return r.filter((e,n)=>{if(e==null)return!1;const{transform:s}=e;return h.checkIfMove(s,t==null?void 0:t[n])})}_addListenerOnDrawing(r){const t=r.getTransformerByCreate();let e=null;this.disposeWithMe(h.toDisposable(t.changeStart$.subscribe(n=>{const{objects:s}=n,a=Array.from(s.values()),o=[];e=a.map(c=>{const{left:d,top:u,height:g,width:f,angle:p,oKey:S,isInGroup:w}=c,m=this._drawingManagerService.getDrawingOKey(S);if(w||c instanceof y.Group){let b=c.ancestorGroup;if(b==null&&c instanceof y.Group&&(b=c),b==null)return null;const C=this._drawingManagerService.getDrawingOKey(b.oKey);if(C){const{unitId:B,subUnitId:M,drawingId:A}=C;o.push({unitId:B,subUnitId:M,drawingId:A});const{left:E,top:O,height:N,width:T,angle:U}=b;return{left:E,top:O,height:N,width:T,angle:U}}}else if(m!=null){const{unitId:b,subUnitId:C,drawingId:B}=m;return o.push({unitId:b,subUnitId:C,drawingId:B}),{left:d,top:u,height:g,width:f,angle:p}}return null}).filter(c=>c!=null),o.length>0?this._commandService.syncExecuteCommand(D.SetDrawingSelectedOperation.id,o):this._commandService.syncExecuteCommand(D.SetDrawingSelectedOperation.id,[])}))),this.disposeWithMe(h.toDisposable(t.changeEnd$.subscribe(n=>{const{objects:s}=n,a=this._filterUpdateParams(ge(s,this._drawingManagerService),e);a.length>0&&this._drawingManagerService.featurePluginUpdateNotification(a)})))}};ye=It([Ce(0,h.IUniverInstanceService),Ce(1,h.ICommandService),Ce(2,y.IRenderManagerService),Ce(3,D.IDrawingManagerService)],ye);class fe extends y.Shape{constructor(t,e){e==null&&(e={}),e.transformerConfig={keepRatio:!1,isCropper:!0,anchorFill:"rgb(0, 0, 0)",anchorStroke:"rgb(255, 255, 255)",anchorSize:24};super(t,e);te(this,"_srcRect");te(this,"_prstGeom");te(this,"_applyTransform");te(this,"_dragPadding",8);te(this,"_cacheCanvas");e!=null&&e.srcRect&&(this._srcRect=e.srcRect),e!=null&&e.prstGeom&&(this._prstGeom=e.prstGeom),e!=null&&e.applyTransform&&(this._applyTransform=e.applyTransform),e!=null&&e.dragPadding&&(this._dragPadding=e.dragPadding),this._applyProps()}refreshSrcRect(t,e){this._srcRect=t,this._applyTransform=e,this._applyProps()}get srcRect(){return this._srcRect}dispose(){var t;super.dispose(),(t=this._cacheCanvas)==null||t.dispose(),this._srcRect=null}isHit(t){const e=this.getInverseCoord(t);return e.x>=-this.strokeWidth/2&&e.x<=this.width+this.strokeWidth/2&&e.y>=-this.strokeWidth/2&&e.y<=this.height+this.strokeWidth/2&&!this._inSurround(e)}_inSurround(t){const e=this._dragPadding;return t.x>=e-this.strokeWidth/2&&t.x<=this.width+this.strokeWidth/2-e&&t.y>=e-this.strokeWidth/2&&t.y<=this.height+this.strokeWidth/2-e}render(t,e){return this.visible?(t.save(),this._draw(t),t.restore(),this.makeDirty(!1),this):(this.makeDirty(!1),this)}_draw(t){var c,d;const n=this.getScene().getEngine(),{width:s,height:a}=n;this._initialCacheCanvas(),(c=this._cacheCanvas)==null||c.clear();const o=(d=this._cacheCanvas)==null?void 0:d.getContext();o!=null&&(o.save(),y.Rect.drawWith(o,{left:0,top:0,width:s,height:a,fill:"rgba(0, 0, 0, 0.5)"}),o.setTransform(t.getTransform()),this._clipForApplyObject(o),this._applyCache(t),o.restore())}_clipForApplyObject(t){let e=0;if(this._prstGeom!=null&&(e=1),t.globalCompositeOperation="destination-out",t.beginPath(),e===0){const n=this.transform.getMatrix();t.transform(n[0],n[1],n[2],n[3],n[4],n[5]),t.rect(0,0,this.width,this.height),t.fill()}}_applyProps(){if(this._applyTransform==null)return;let t=0,e=0,n=0,s=0;const{left:a=0,top:o=0,width:c=0,height:d=0,angle:u}=this._applyTransform;if(this._srcRect!=null){const{left:p=0,top:S=0,right:w=0,bottom:m=0}=this._srcRect;t=p,e=S,n=w,s=m}const g=a+t,f=o+e;this.transformByState({left:g,top:f,width:a+c-n-g,height:o+d-s-f,angle:u})}_applyCache(t){if(!t||this._cacheCanvas==null)return;const e=this._cacheCanvas.getContext();e.save(),t.save(),t.setTransform(1,0,0,1,0,0),e.setTransform(1,0,0,1,0,0),t.drawImage(this._cacheCanvas.getCanvasEle(),0,0),t.restore(),e.restore()}_initialCacheCanvas(){if(this._cacheCanvas!=null)return;const t=this.getScene();if(t==null)return;this._cacheCanvas=new y.Canvas;const e=t.getEngine();this._cacheCanvas.setSize(e.width,e.height),e.onTransformChange$.subscribeEvent(()=>{var n;(n=this._cacheCanvas)==null||n.setSize(e.width,e.height),this.makeDirty(!0)})}}var Dt=Object.getOwnPropertyDescriptor,Mt=(i,r,t,e)=>{for(var n=e>1?void 0:e?Dt(r,t):r,s=i.length-1,a;s>=0;s--)(a=i[s])&&(n=a(n)||n);return n},le=(i,r)=>(t,e)=>r(t,e,i);let be=class extends h.Disposable{constructor(r,t,e,n,s,a){super();te(this,"_sceneListenerOnImageMap",new WeakSet);this._commandService=r,this._drawingManagerService=t,this._renderManagerService=e,this._univerInstanceService=n,this._messageService=s,this._localeService=a,this._init()}_init(){this._initOpenCrop(),this._initCloseCrop(),this._initAutoCrop()}_initAutoCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id!==he.id)return;const t=r.params;if(t==null)return;const{cropType:e}=t,n=this._drawingManagerService.getFocusDrawings();if(n.length!==1)return;const s=n[0],{unitId:a,subUnitId:o,drawingId:c}=s,d=this._renderManagerService.getRenderById(a),u=d==null?void 0:d.scene;if(u==null)return!0;this._searchCropObject(u)!=null&&this._commandService.syncExecuteCommand(ne.id,{isAuto:!0});const f=D.getDrawingShapeKeyByDrawingSearch({unitId:a,subUnitId:o,drawingId:c}),p=u.getObject(f);if(!(p instanceof y.Image)){this._messageService.show({type:P.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}p!=null&&(this._updateCropperObject(e,p),this._commandService.executeCommand(Se.id,{unitId:a,subUnitId:o,drawingId:c}))}))}_calculateSrcRectByRatio(r,t,e,n,s,a){const o=e/n,c=s/a;let d=e,u=n;o>c?d=n*c:u=e/c;const g=(e-d)/2,f=(n-u)/2;return{left:y.precisionTo(g,1),top:y.precisionTo(f,1),right:y.precisionTo(e-(g+d),1),bottom:y.precisionTo(n-(f+u),1)}}_updateCropperObject(r,t){const{left:e,top:n,width:s,height:a}=t.calculateTransformWithSrcRect();let o;switch(r){case G.R1_1:o=this._calculateSrcRectByRatio(e,n,s,a,1,1);break;case G.R16_9:o=this._calculateSrcRectByRatio(e,n,s,a,16,9);break;case G.R9_16:o=this._calculateSrcRectByRatio(e,n,s,a,9,16);break;case G.R5_4:o=this._calculateSrcRectByRatio(e,n,s,a,5,4);break;case G.R4_5:o=this._calculateSrcRectByRatio(e,n,s,a,4,5);break;case G.R4_3:o=this._calculateSrcRectByRatio(e,n,s,a,4,3);break;case G.R3_4:o=this._calculateSrcRectByRatio(e,n,s,a,3,4);break;case G.R3_2:o=this._calculateSrcRectByRatio(e,n,s,a,3,2);break;case G.R2_3:o=this._calculateSrcRectByRatio(e,n,s,a,2,3);break;case G.FREE:}if(o==null)return;t.setSrcRect(o);const{left:c=0,top:d=0,bottom:u=0,right:g=0}=o;t.transformByStateCloseCropper({left:e+c,top:n+d,width:s-g-c,height:a-u-d})}_initOpenCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id!==Se.id)return;const t=r.params;if(t==null)return;const{unitId:e,subUnitId:n,drawingId:s}=t,a=this._renderManagerService.getRenderById(e),o=a==null?void 0:a.scene;if(o==null)return!0;if(this._sceneListenerOnImageMap.has(o)||(this._addListenerOnImage(o),this._sceneListenerOnImageMap.add(o)),this._drawingManagerService.getDrawingByParam({unitId:e,subUnitId:n,drawingId:s})==null)return;const d=D.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:s}),u=o.getObject(d);if(u==null)return;if(!(u instanceof y.Image)){this._messageService.show({type:P.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}const g=o.getTransformer();g==null||g.clearControls();const f=new fe(`${d}-crop`,{srcRect:u.srcRect,prstGeom:u.prstGeom,applyTransform:u.calculateTransformWithSrcRect()});o.addObject(f,u.getLayerIndex()+1).attachTransformerTo(f),g==null||g.createControlForCopper(f),this._addHoverForImageCopper(f),u.openRenderByCropper(),g==null||g.refreshControls(),f.makeDirty(!0),this._commandService.syncExecuteCommand(D.SetDrawingSelectedOperation.id,[{unitId:e,subUnitId:n,drawingId:s}])}))}_searchCropObject(r){const t=r.getAllObjectsByOrder();for(const e of t)if(e instanceof fe)return e}_initCloseCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id!==ne.id)return;const e=this._univerInstanceService.getFocusedUnit();if(e==null)return;const n=e.getUnitId(),s=this._renderManagerService.getRenderById(n),a=s==null?void 0:s.scene;if(a==null)return!0;const o=this._searchCropObject(a);if(o==null)return;const c=this._getApplyObjectByCropObject(o);if(c==null)return;const d=a.getTransformerByCreate();d.detachFrom(o),d.clearCopperControl();const u=this._getSrcRectByTransformState(c,o),g=this._drawingManagerService.getDrawingOKey(c.oKey);if(g!=null){const{left:f,top:p,height:S,width:w}=o;this._drawingManagerService.featurePluginUpdateNotification([{...g,transform:{...g.transform,left:f,top:p,height:S,width:w},srcRect:u.srcRectAngle}])}c.setSrcRect({...u.srcRectAngle}),c.closeRenderByCropper(),c.makeDirty(!0),o==null||o.dispose()}));const r=this._univerInstanceService.getCurrentTypeOfUnit$(h.UniverInstanceType.UNIVER_SHEET).pipe(Ee.switchMap(t=>t?t.activeSheet$:Ee.of(null)));this.disposeWithMe(r.subscribe(()=>{this._commandService.syncExecuteCommand(ne.id)}))}_getApplyObjectByCropObject(r){const t=r.oKey,e=t.slice(0,t.length-5),n=r.getScene();if(!n)return null;const s=n.getObject(e);return s==null?null:s}_addListenerOnImage(r){const t=r.getTransformerByCreate();let e=null;this.disposeWithMe(t.changeStart$.subscribe(n=>{const{objects:s}=n,a=s.values().next().value;if(a==null||!(a instanceof fe))return;const{left:o,top:c,height:d,width:u,angle:g}=a;e={left:o,top:c,height:d,width:u,angle:g},t.clearCopperControl()})),this.disposeWithMe(t.changeEnd$.subscribe(n=>{const{objects:s}=n,a=s.values().next().value;if(a==null||!(a instanceof fe))return;const{left:o,top:c,height:d,width:u,angle:g}=a;if(!h.checkIfMove({left:o,top:c,height:d,width:u,angle:g},e))return;const f=this._getApplyObjectByCropObject(a);if(f==null)return;const p=this._getSrcRectByTransformState(f,a);a.refreshSrcRect(p.srcRect,f.getState()),t.createControlForCopper(a)})),this._endCropListener(r)}_addHoverForImageCopper(r){this.disposeWithMe(r.onPointerEnter$.subscribeEvent(()=>{r.cursor=y.CURSOR_TYPE.MOVE})),this.disposeWithMe(r.onPointerLeave$.subscribeEvent(()=>{r.cursor=y.CURSOR_TYPE.DEFAULT}))}_endCropListener(r){const t=r.getTransformerByCreate();this.disposeWithMe(t.clearControl$.subscribe(e=>{e===!0&&this._commandService.syncExecuteCommand(ne.id)}))}_getSrcRectByTransformState(r,t){const{left:e,top:n,height:s,width:a,strokeWidth:o,angle:c}=t,{left:d,top:u,width:g,height:f,angle:p,strokeWidth:S}=r,w=e-d,m=n-u,b={left:w,top:m,right:g-w-a,bottom:f-m-s},C={...b};if(p!==0){const B=e+a/2,M=n+s/2,A=new y.Vector2(B,M),E=g/2+d,O=f/2+u,N=new y.Vector2(E,O),T=new y.Vector2(d,u);T.rotateByPoint(y.degToRad(p),N);const U=T.clone();U.rotateByPoint(y.degToRad(-p),A);const V=e-U.x,x=n-U.y;C.left=V,C.top=x,C.right=g-V-a,C.bottom=f-x-s}return{srcRect:b,srcRectAngle:C}}};be=Mt([le(0,h.ICommandService),le(1,D.IDrawingManagerService),le(2,y.IRenderManagerService),le(3,h.IUniverInstanceService),le(4,W.IMessageService),le(5,h.Inject(h.LocaleService))],be);var Ot=Object.getOwnPropertyDescriptor,Nt=(i,r,t,e)=>{for(var n=e>1?void 0:e?Ot(r,t):r,s=i.length-1,a;s>=0;s--)(a=i[s])&&(n=a(n)||n);return n},ae=(i,r)=>(t,e)=>r(t,e,i);let Ie=class extends h.Disposable{constructor(i,r,t,e,n,s,a){super(),this._commandService=i,this._renderManagerService=r,this._drawingManagerService=t,this._dialogService=e,this._imageIoService=n,this._currentUniverService=s,this._drawingRenderService=a,this._initialize()}dispose(){super.dispose()}_initialize(){this._drawingAddListener(),this._commandExecutedListener(),this._imageUpdateListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===Me.id){const r=i.params;if(r==null)return;this._resetImageSize(r)}}))}_getSceneAndTransformerByDrawingSearch(i){if(i==null)return;const r=this._renderManagerService.getRenderById(i),t=r==null?void 0:r.scene;if(t==null)return null;const e=t.getTransformerByCreate();return{scene:t,transformer:e}}_resetImageSize(i){const r=[],t=[];i.forEach(e=>{const{unitId:n,subUnitId:s,drawingId:a}=e,o=this._getSceneAndTransformerByDrawingSearch(n);if(o==null)return;const{scene:c}=o,d=D.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:s,drawingId:a}),u=c.getObject(d);if(u==null)return!0;const g=this._drawingManagerService.getDrawingByParam(e);if(g==null)return!0;if(g.drawingType!==h.DrawingTypeEnum.DRAWING_IMAGE)return;u.resetSize();const{width:f,height:p}=u.getNativeSize();t.includes(c)===!1&&t.push(c),r.push({...g,transform:{...g.transform,height:p,width:f,angle:0},srcRect:null,prstGeom:null})}),this._drawingManagerService.featurePluginUpdateNotification(r),t.forEach(e=>{e.getTransformerByCreate().refreshControls().changeNotification()}),this._commandService.syncExecuteCommand(D.SetDrawingSelectedOperation.id,i)}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(i=>{this._insertImages(i)}))}_insertImages(i){i.forEach(async r=>{var c;const{unitId:t,subUnitId:e}=r,n=this._getSceneAndTransformerByDrawingSearch(t),s=(c=Pe(this._currentUniverService,t))==null?void 0:c.subUnitId;if(n==null||s!==e)return;const a=this._drawingManagerService.getDrawingByParam(r);if(a==null)return;const o=await this._drawingRenderService.renderImages(a,n.scene);if(this._drawingManagerService.refreshTransform([a]),!(o==null||o.length===0))for(const d of o)this._addHoverForImage(d),this._addDialogForImage(d)})}_imageUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(i=>{i.forEach(r=>{const{unitId:t,subUnitId:e,drawingId:n}=r,s=this._drawingManagerService.getDrawingByParam(r);if(s==null)return;const{transform:a,drawingType:o,srcRect:c,prstGeom:d,source:u,imageSourceType:g}=s;if(o!==h.DrawingTypeEnum.DRAWING_IMAGE)return;const f=this._getSceneAndTransformerByDrawingSearch(t);if(f==null)return;const{scene:p,transformer:S}=f;if(a==null)return!0;const w=D.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:e,drawingId:n}),m=p.getObject(w);if(m==null)return!0;m.setSrcRect(c),m.setPrstGeom(d),u!=null&&u.length>0&&(g===h.ImageSourceType.BASE64||g===h.ImageSourceType.URL)&&m.changeSource(u)})}))}_addHoverForImage(i){this.disposeWithMe(h.toDisposable(i.onPointerEnter$.subscribeEvent(()=>{i.cursor=y.CURSOR_TYPE.GRAB}))),this.disposeWithMe(h.toDisposable(i.onPointerLeave$.subscribeEvent(()=>{i.cursor=y.CURSOR_TYPE.DEFAULT})))}_addDialogForImage(i){this.disposeWithMe(h.toDisposable(i.onDblclick$.subscribeEvent(()=>{const r=`${i.oKey}-viewer-dialog`;this._drawingRenderService.previewImage(r,i.getNative().src,i.getNativeSize().width,i.getNativeSize().height)})))}};Ie=Nt([ae(0,h.ICommandService),ae(1,y.IRenderManagerService),ae(2,D.IDrawingManagerService),ae(3,W.IDialogService),ae(4,D.IImageIoService),ae(5,h.IUniverInstanceService),ae(6,h.Inject(I.DrawingRenderService))],Ie);var Et=Object.getOwnPropertyDescriptor,Tt=(i,r,t,e)=>{for(var n=e>1?void 0:e?Et(r,t):r,s=i.length-1,a;s>=0;s--)(a=i[s])&&(n=a(n)||n);return n},Ye=(i,r)=>(t,e)=>r(t,e,i);const Pt="UNIVER_DRAWING_UI_PLUGIN";I.UniverDrawingUIPlugin=(Oe=class extends h.Plugin{constructor(r=Ke,t,e){super(),this._config=r,this._injector=t,this._configService=e;const{menu:n,...s}=h.merge({},Ke,this._config);n&&this._configService.setConfig("menu",n,{merge:!0}),this._configService.setConfig(St,s)}onStarting(){this._initDependencies()}onRendered(){this._injector.get(ye),this._injector.get(_e),this._injector.get(be),this._injector.get(Ie)}_initDependencies(){[[I.DrawingRenderService],[ye],[_e],[be],[Ie]].forEach(t=>this._injector.add(t))}},te(Oe,"pluginName",Pt),Oe),I.UniverDrawingUIPlugin=Tt([Ye(1,h.Inject(h.Injector)),Ye(2,h.IConfigService)],I.UniverDrawingUIPlugin),I.AutoImageCropOperation=he,I.COMPONENT_IMAGE_POPUP_MENU=ze,I.CloseImageCropOperation=ne,I.DrawingCommonPanel=wt,I.ImageCropperObject=fe,I.ImagePopupMenu=$e,I.ImageResetSizeOperation=Me,I.OpenImageCropOperation=Se,I.SetDrawingAlignOperation=ve,I.getUpdateParams=ge,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})});
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
// @univerjs/docs-drawing/index
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/preset-docs-drawing",
|
|
3
|
-
"version": "0.7.0-
|
|
3
|
+
"version": "0.7.0-nightly.202505071607",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -57,18 +57,17 @@
|
|
|
57
57
|
"rxjs": ">=7.0.0"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@univerjs/docs-drawing": "0.7.0-
|
|
61
|
-
"@univerjs/docs-drawing-ui": "0.7.0-
|
|
62
|
-
"@univerjs/drawing": "0.7.0-
|
|
63
|
-
"@univerjs/drawing-ui": "0.7.0-
|
|
64
|
-
"rxjs": ">=7.0.0"
|
|
60
|
+
"@univerjs/docs-drawing": "0.7.0-nightly.202505071607",
|
|
61
|
+
"@univerjs/docs-drawing-ui": "0.7.0-nightly.202505071607",
|
|
62
|
+
"@univerjs/drawing": "0.7.0-nightly.202505071607",
|
|
63
|
+
"@univerjs/drawing-ui": "0.7.0-nightly.202505071607"
|
|
65
64
|
},
|
|
66
65
|
"devDependencies": {
|
|
67
|
-
"@univerjs/core": "0.7.0-
|
|
66
|
+
"@univerjs/core": "0.7.0-nightly.202505071607",
|
|
68
67
|
"react": "18.3.1",
|
|
69
68
|
"react-dom": "18.3.1",
|
|
70
|
-
"typescript": "^5.8.
|
|
71
|
-
"@univerjs-infra/shared": "0.
|
|
69
|
+
"typescript": "^5.8.2",
|
|
70
|
+
"@univerjs-infra/shared": "0.6.10"
|
|
72
71
|
},
|
|
73
72
|
"scripts": {
|
|
74
73
|
"prebuild:preset": "tsx prepare.ts",
|