@univerjs/drawing-ui 0.15.3 → 0.15.4

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/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var Ye=Object.defineProperty;var Xe=(s,r,e)=>r in s?Ye(s,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[r]=e;var J=(s,r,e)=>Xe(s,typeof r!="symbol"?r+"":r,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("@univerjs/core"),M=require("@univerjs/drawing"),y=require("@univerjs/engine-render"),H=require("@univerjs/ui"),h=require("react/jsx-runtime"),P=require("@univerjs/design"),_=require("react"),Oe=require("rxjs");var T=(s=>(s.default="0",s.left="1",s.center="2",s.right="3",s.top="4",s.middle="5",s.bottom="6",s.horizon="7",s.vertical="8",s))(T||{});const Ie={id:"sheet.operation.set-image-align",type:f.CommandType.OPERATION,handler:(s,r)=>!0},we={id:"sheet.operation.open-image-crop",type:f.CommandType.OPERATION,handler:(s,r)=>!0},Q={id:"sheet.operation.close-image-crop",type:f.CommandType.OPERATION,handler:(s,r)=>!0};var U=(s=>(s.FREE="0",s.R1_1="1",s.R16_9="2",s.R9_16="3",s.R5_4="4",s.R4_5="5",s.R4_3="6",s.R3_4="7",s.R3_2="8",s.R2_3="9",s))(U||{});const ge={id:"sheet.operation.Auto-image-crop",type:f.CommandType.OPERATION,handler:(s,r)=>!0},De={id:"sheet.operation.image-reset-size",type:f.CommandType.OPERATION,handler:(s,r)=>!0};function be(s,r,e,t){const n=t.getDrawingByParam(s);if(n==null)return;const i=M.getDrawingShapeKeyByDrawingSearch(s),a=e.getObject(i);if(a&&!(a instanceof y.Group))return;if(a!=null){a.addObject(r);return}const o=new y.Group(i);e.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 Re(s,r){var i;const e=r?s.getUnit(r):s.getFocusedUnit();if(e==null)return;const t=e.getUnitId();let n;return e.type===f.UniverInstanceType.UNIVER_SHEET?n=(i=e.getActiveSheet())==null?void 0:i.getSheetId():(e.type===f.UniverInstanceType.UNIVER_DOC||e.type===f.UniverInstanceType.UNIVER_SLIDE)&&(n=t),{unitId:t,subUnitId:n,current:e}}const qe="drawing-ui.config",xe={},Pe="COMPONENT_IMAGE_POPUP_MENU";function F({ref:s,...r}){const{icon:e,id:t,className:n,extend:i,...a}=r,o=`univerjs-icon univerjs-icon-${t} ${n||""}`.trim(),c=_.useRef(`_${et()}`);return Ne(e,`${t}`,{defIds:e.defIds,idSuffix:c.current},{ref:s,className:o,...a},i)}function Ne(s,r,e,t,n){return _.createElement(s.tag,{key:r,...Je(s,e,n),...t},(Qe(s,e).children||[]).map((i,a)=>Ne(i,`${r}-${s.tag}-${a}`,e,void 0,n)))}function Je(s,r,e){const t={...s.attrs};e!=null&&e.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=e.colorChannel1),s.tag==="mask"&&t.id&&(t.id=t.id+r.idSuffix),Object.entries(t).forEach(([i,a])=>{i==="mask"&&typeof a=="string"&&(t[i]=a.replace(/url\(#(.*)\)/,`url(#$1${r.idSuffix})`))});const{defIds:n}=r;return!n||n.length===0||(s.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+r.idSuffix),Object.entries(t).forEach(([i,a])=>{typeof a=="string"&&(t[i]=a.replace(/url\(#(.*)\)/,`url(#$1${r.idSuffix})`))})),t}function Qe(s,r){var t;const{defIds:e}=r;return!e||e.length===0?s:s.tag==="defs"&&((t=s.children)!=null&&t.length)?{...s,children:s.children.map(n=>typeof n.attrs.id=="string"&&e&&e.includes(n.attrs.id)?{...n,attrs:{...n.attrs,id:n.attrs.id+r.idSuffix}}:n)}:s}function et(){return Math.random().toString(36).substring(2,8)}F.displayName="UniverIcon";const tt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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.8334C15.6045 1.94974 14.8881 1.2334 14.0045 1.2334H3.70449C2.82084 1.2334 2.10449 1.94974 2.10449 2.8334C2.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.8334C3.30449 2.61248 3.48358 2.4334 3.70449 2.4334H14.0045C14.2254 2.4334 14.4045 2.61249 14.4045 2.8334Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 8.5999C15.038 8.5999 15.7544 7.88356 15.7544 6.9999C15.7544 6.11625 15.038 5.3999 14.1544 5.3999H3.85439C2.97074 5.3999 2.25439 6.11625 2.25439 6.9999C2.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.9999C3.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.7421C6.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.56641C9.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.7421C11.6631 11.9765 11.6631 12.3564 11.4288 12.5907L9.42923 14.5902"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.57975 14.5902C8.58121 14.5917 8.58268 14.5931 8.58416 14.5946C8.64077 14.6502 8.70566 14.6923 8.77482 14.7209C8.84557 14.7502 8.92314 14.7664 9.00449 14.7664C9.08585 14.7664 9.16342 14.7502 9.23416 14.7209C9.30332 14.6923 9.36821 14.6502 9.42482 14.5946"}}]},Be=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"bottom-icon",ref:e,icon:tt}))});Be.displayName="BottomIcon";const rt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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.51296C9.08632 7.84433 8.81769 8.11296 8.48632 8.11296H6.57705C6.24568 8.11296 5.97705 7.84433 5.97705 7.51296Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.57705 9.41028C6.24568 9.41028 5.97705 9.67891 5.97705 10.0103C5.97705 10.3416 6.24568 10.6103 6.57705 10.6103H10.8199C11.1512 10.6103 11.4199 10.3416 11.4199 10.0103C11.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"}}]},Ue=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"create-copy-icon",ref:e,icon:rt}))});Ue.displayName="CreateCopyIcon";const nt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},Ae=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"group-icon",ref:e,icon:nt}))});Ae.displayName="GroupIcon";const it={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},Le=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"more-down-icon",ref:e,icon:it}))});Le.displayName="MoreDownIcon";const at={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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(r,e){return _.createElement(F,Object.assign({},r,{id:"move-down-icon",ref:e,icon:at}))});He.displayName="MoveDownIcon";const st={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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(r,e){return _.createElement(F,Object.assign({},r,{id:"move-up-icon",ref:e,icon:st}))});ke.displayName="MoveUpIcon";const ot={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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 9C15.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 9C2.70439 9.22091 2.88348 9.4 3.1044 9.4H13.4044C13.6253 9.4 13.8044 9.22091 13.8044 9C13.8044 8.77909 13.6253 8.6 13.4044 8.6H3.10439Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.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.1665C15.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.1665C2.8543 13.3874 3.03338 13.5665 3.2543 13.5665H13.5543C13.7752 13.5665 13.9543 13.3874 13.9543 13.1665C13.9543 12.9456 13.7752 12.7665 13.5543 12.7665H3.2543Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ge=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"topmost-icon",ref:e,icon:ot}))});Ge.displayName="TopmostIcon";const ct={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},$e=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"ungroup-icon",ref:e,icon:ct}))});$e.displayName="UngroupIcon";const lt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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.56377Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.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.83647Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M9.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"}}]},Ve=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"autofill-double-icon",ref:e,icon:lt}))});Ve.displayName="AutofillDoubleIcon";function We(s){var m;const{popup:r}=s,e=(m=r==null?void 0:r.extraProps)==null?void 0:m.menuItems;if(!e)return null;const t=H.useDependency(f.ICommandService),n=H.useDependency(f.LocaleService),[i,a]=_.useState(!1),[o,c]=_.useState(!1),g=()=>{c(!0)},l=()=>{c(!1)},u=w=>{a(w)},d=w=>{t.executeCommand(w.commandId,w.commandParams),a(!1)},p=i||o,S=e.filter(w=>!w.disable);return h.jsx("div",{onMouseEnter:g,onMouseLeave:l,children:h.jsx(P.DropdownMenu,{align:"start",items:S.map(w=>({type:"item",children:n.t(w.label),onSelect:()=>d(w)})),open:i,onOpenChange:u,children:h.jsxs("div",{className:P.clsx("univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-800",P.borderClassName,{"univer-bg-gray-100 dark:!univer-bg-gray-800":i,"univer-bg-white dark:!univer-bg-gray-900":!i}),children:[h.jsx(Ve,{className:"univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-white"}),p&&h.jsx(Le,{className:"dark:!univer-text-white"})]})})})}var gt=Object.getOwnPropertyDescriptor,ut=(s,r,e,t)=>{for(var n=t>1?void 0:t?gt(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(n=a(n)||n);return n},je=(s,r)=>(e,t)=>r(e,t,s);let ve=class extends f.Disposable{constructor(s,r){super(),this._componentManager=s,this._commandService=r,this._init()}_initCustomComponents(){const s=this._componentManager;this.disposeWithMe(s.register(Pe,We))}_initCommands(){[we,Q,De,Ie,ge].forEach(s=>this.disposeWithMe(this._commandService.registerCommand(s)))}_init(){this._initCommands(),this._initCustomComponents()}};ve=ut([je(0,f.Inject(H.ComponentManager)),je(1,f.ICommandService)],ve);function ue(s,r){const e=[];return s.forEach(t=>{const{oKey:n,left:i,top:a,height:o,width:c,angle:g}=t,l=r.getDrawingOKey(n);if(l==null)return e.push(null),!0;const{unitId:u,subUnitId:d,drawingId:p,drawingType:S}=l,m={unitId:u,subUnitId:d,drawingId:p,drawingType:S,transform:{left:i,top:a,height:o,width:c,angle:g}};S===f.DrawingTypeEnum.DRAWING_IMAGE&&(m.srcRect=t.srcRect),e.push(m)}),e}var dt=Object.getOwnPropertyDescriptor,ht=(s,r,e,t)=>{for(var n=t>1?void 0:t?dt(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(n=a(n)||n);return n},de=(s,r)=>(e,t)=>r(e,t,s);let Se=class extends f.Disposable{constructor(r,e,t,n){super();J(this,"_sceneListenerOnDrawingMap",new WeakSet);this._currentUniverService=r,this._commandService=e,this._renderManagerService=t,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,e=Re(this._currentUniverService);if(e==null)return;const{unitId:t,subUnitId:n}=e;Object.keys(r).forEach(i=>{Object.keys(r[i]).forEach(a=>{const o=r[i][a].data;o==null||i!==t||a!==n||Object.keys(o).forEach(c=>{o[c]&&this._insertDrawing([{unitId:i,subUnitId:a,drawingId:c}])})})})}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id===Ie.id){const e=r.params;if(e==null)return;this._drawingAlign(e)}}))}_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 e=this._renderManagerService.getRenderById(r),t=e==null?void 0:e.scene;if(t==null)return null;const n=t.getTransformerByCreate();return{scene:t,transformer:n}}_groupDrawings(r){r.forEach(e=>{this._groupDrawing(e)})}_groupDrawing(r){const{parent:e,children:t}=r,{unitId:n,subUnitId:i,drawingId:a}=e,o=this._getSceneAndTransformerByDrawingSearch(e.unitId);if(o==null)return;const{scene:c,transformer:g}=o;this._commandService.syncExecuteCommand(Q.id);const l=[];if(t.forEach(p=>{const S=M.getDrawingShapeKeyByDrawingSearch(p),m=c.getObjectIncludeInGroup(S);if(m==null||l.includes(m))return;l.push(m);const{transform:w}=p;w!=null&&(m.classType===y.RENDER_CLASS_TYPE.GROUP?m.transformByState({left:w.left,top:w.top}):m.transformByState(w))}),l.length===0)return;const u=M.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:i,drawingId:a}),d=new y.Group(u);c.addObject(d,y.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(d),d.addObjects(...l),e.transform&&d.transformByState({left:e.transform.left,top:e.transform.top}),g.clearSelectedObjects(),g.setSelectedControl(d)}_ungroupDrawings(r){r.forEach(e=>{this._ungroupDrawing(e)})}_ungroupDrawing(r){const{parent:e,children:t}=r,n=this._getSceneAndTransformerByDrawingSearch(e.unitId);if(n==null)return;const{scene:i,transformer:a}=n;t.forEach(u=>{const d=M.getDrawingShapeKeyByDrawingSearch(u),p=i.getObjectIncludeInGroup(d);if(p==null)return!0;if(p==null)return;const{transform:S}=u;S!=null&&(p.classType===y.RENDER_CLASS_TYPE.GROUP?p.transformByState({left:S.left,top:S.top}):p.transformByState(S))});const o=M.getDrawingShapeKeyByDrawingSearch(e),c=i.getObject(o),{width:g,height:l}=c;c.getObjects().forEach(u=>{c.removeSelfObjectAndTransform(u.oKey,g,l)}),c.dispose(),a.clearSelectedObjects()}_drawingAlign(r){const{alignType:e}=r,t=this._drawingManagerService.getFocusDrawings();if(e===T.default)return;const n=[];let i=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY,g=0;t.forEach(l=>{const{unitId:u,subUnitId:d,drawingId:p,drawingType:S}=l,m=this._drawingManagerService.getDrawingByParam({unitId:u,subUnitId:d,drawingId:p});if(m==null||m.transform==null)return;n.push({unitId:u,subUnitId:d,drawingId:p,drawingType:S,transform:m.transform});const{left:w=0,top:C=0,width:I=0,height:D=0}=m.transform;i=Math.min(i,w),a=Math.min(a,C),o=Math.max(o,w+I),c=Math.max(c,C+D),g++}),g!==0&&(this._sortDrawingTransform(n,e),this._applyAlignType(n,e,i,a,o,c,g))}_applyAlignType(r,e,t,n,i,a,o){const c=Math.round((i-t)/o*10)/10,g=Math.round((a-n)/o*10)/10,l=[],u=this._getSceneAndTransformerByDrawingSearch(r[0].unitId);if(u==null)return;const{scene:d,transformer:p}=u;r.forEach((S,m)=>{const{unitId:w,subUnitId:C,drawingId:I,transform:D,drawingType:j}=S,{left:N=0,top:b=0,width:O=0,height:R=0}=D;let E=N,x=b;switch(e){case T.left:E=t;break;case T.center:E=t+(i-t)/2-O/2;break;case T.right:E=i-O;break;case T.top:x=n;break;case T.middle:x=n+(a-n)/2-R/2;break;case T.bottom:x=a-R;break;case T.horizon:E=t+c*m;break;case T.vertical:x=n+g*m;break}(E!==N||x!==b)&&l.push({unitId:w,subUnitId:C,drawingId:I,drawingType:j,transform:{left:E,top:x}})}),this._drawingManagerService.featurePluginUpdateNotification(l),p.refreshControls().changeNotification()}_sortDrawingTransform(r,e){r.sort((t,n)=>{const i=t.transform,a=n.transform,{left:o=0,top:c=0,width:g=0,height:l=0}=i,{left:u=0,top:d=0,width:p=0,height:S=0}=a;switch(e){case T.left:return o-u;case T.center:return o+g/2-(u+p/2);case T.right:return o+g-(u+p);case T.top:return c-d;case T.middle:return c+l/2-(d+S/2);case T.bottom:return c+l-(d+S);case T.horizon:return o+g/2-(u+p/2);case T.vertical:return c+l/2-(d+S/2);default:return 0}})}_drawingArrangeListener(){this.disposeWithMe(this._drawingManagerService.order$.subscribe(r=>{this._drawingArrange(r)}))}_drawingArrange(r){const{unitId:e,subUnitId:t,drawingIds:n}=r,i=this._getSceneAndTransformerByDrawingSearch(e);if(i==null)return;const{scene:a}=i;n.forEach(o=>{const c=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:t,drawingId:o}),g=a.fuzzyMathObjects(c,!0);if(g==null||g.length===0)return;const l=this._drawingManagerService.getDrawingOrder(e,t).indexOf(o);for(const u of g)u.setProps({zIndex:l}),u.makeDirty()})}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(r=>{this._insertDrawing(r)}))}_insertDrawing(r){const e=[];r.forEach(t=>{const{unitId:n}=t;if(this._drawingManagerService.getDrawingByParam(t)==null)return;const a=this._getSceneAndTransformerByDrawingSearch(n);if(a==null)return;const{scene:o}=a;e.includes(o)||e.push(o)}),e.forEach(t=>{this._sceneListenerOnDrawingMap.has(t)||(this._addListenerOnDrawing(t),this._sceneListenerOnDrawingMap.add(t))})}_drawingRemoveListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(r=>{r.forEach(e=>{var l;const{unitId:t,subUnitId:n,drawingId:i}=e,a=this._getSceneAndTransformerByDrawingSearch(t);if(a==null)return;const{scene:o}=a,c=M.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:n,drawingId:i}),g=o.fuzzyMathObjects(c,!0);if(g.length>0){for(const u of g)u.dispose();(l=o.getTransformer())==null||l.clearSelectedObjects()}})}))}_drawingUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(r=>{r.forEach(e=>{var O;const{unitId:t,subUnitId:n,drawingId:i}=e,a=this._drawingManagerService.getDrawingByParam(e);if(a==null)return;const{transform:o,drawingType:c}=a,g=this._getSceneAndTransformerByDrawingSearch(t);if(g==null)return;const{scene:l,transformer:u}=g;if(o==null)return!0;const{left:d=0,top:p=0,width:S=0,height:m=0,angle:w=0,flipX:C=!1,flipY:I=!1,skewX:D=0,skewY:j=0}=o,N=M.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:n,drawingId:i}),b=l.getObject(N);if(b==null)return!0;b.transformByState({left:d,top:p,width:S,height:m,angle:w,flipX:C,flipY:I,skewX:D,skewY:j}),(O=l.getTransformer())==null||O.debounceRefreshControls()})}))}_drawingRefreshListener(){this.disposeWithMe(this._drawingManagerService.refreshTransform$.subscribe(r=>{r.forEach(e=>{const{unitId:t,subUnitId:n,drawingId:i}=e,a=this._getSceneAndTransformerByDrawingSearch(t);if(a==null)return;const o=this._drawingManagerService.getDrawingByParam(e);if(o==null)return;const{transform:c}=o,{scene:g}=a,l=M.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:n,drawingId:i}),u=g.getObject(l);if(u==null||c==null)return!0;const{left:d=0,top:p=0,width:S=0,height:m=0,angle:w=0,flipX:C=!1,flipY:I=!1,skewX:D=0,skewY:j=0}=c;u.transformByState({left:d,top:p,width:S,height:m,angle:w,flipX:C,flipY:I,skewX:D,skewY:j})})}))}_drawingVisibleListener(){this.disposeWithMe(this._drawingManagerService.visible$.subscribe(r=>{r.forEach(e=>{const{unitId:t,subUnitId:n,drawingId:i,visible:a}=e,o=this._getSceneAndTransformerByDrawingSearch(t);if(o==null)return;const{scene:c}=o,g=M.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:n,drawingId:i}),l=c.getObject(g);if(l==null)return!0;a?l.show():l.hide()})}))}_filterUpdateParams(r,e){return r.filter((t,n)=>{if(t==null)return!1;const{transform:i}=t;return f.checkIfMove(i,e==null?void 0:e[n])})}_addListenerOnDrawing(r){const e=r.getTransformerByCreate();let t=null;this.disposeWithMe(f.toDisposable(e.changeStart$.subscribe(n=>{const{objects:i}=n,a=Array.from(i.values()),o=[];t=a.map(c=>{const{left:g,top:l,height:u,width:d,angle:p,oKey:S,isInGroup:m}=c,w=this._drawingManagerService.getDrawingOKey(S);if(m||c instanceof y.Group){let C=c.ancestorGroup;if(C==null&&c instanceof y.Group&&(C=c),C==null)return null;const I=this._drawingManagerService.getDrawingOKey(C.oKey);if(I){const{unitId:D,subUnitId:j,drawingId:N}=I;o.push({unitId:D,subUnitId:j,drawingId:N});const{left:b,top:O,height:R,width:E,angle:x}=C;return{left:b,top:O,height:R,width:E,angle:x}}}else if(w!=null){const{unitId:C,subUnitId:I,drawingId:D}=w;return o.push({unitId:C,subUnitId:I,drawingId:D}),{left:g,top:l,height:u,width:d,angle:p}}return null}).filter(c=>c!=null),o.length>0?this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,o):this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,[])}))),this.disposeWithMe(f.toDisposable(e.changeEnd$.subscribe(n=>{const{objects:i}=n,a=this._filterUpdateParams(ue(i,this._drawingManagerService),t);a.length>0&&this._drawingManagerService.featurePluginUpdateNotification(a)})))}};Se=ht([de(0,f.IUniverInstanceService),de(1,f.ICommandService),de(2,y.IRenderManagerService),de(3,M.IDrawingManagerService)],Se);class le extends y.Shape{constructor(e,t){t==null&&(t={}),t.transformerConfig={keepRatio:!1,isCropper:!0,anchorFill:"rgb(0, 0, 0)",anchorStroke:"rgb(255, 255, 255)",anchorSize:24};super(e,t);J(this,"_srcRect");J(this,"_prstGeom");J(this,"_applyTransform");J(this,"_dragPadding",8);J(this,"_cacheCanvas");t!=null&&t.srcRect&&(this._srcRect=t.srcRect),t!=null&&t.prstGeom&&(this._prstGeom=t.prstGeom),t!=null&&t.applyTransform&&(this._applyTransform=t.applyTransform),t!=null&&t.dragPadding&&(this._dragPadding=t.dragPadding),this._applyProps()}refreshSrcRect(e,t){this._srcRect=e,this._applyTransform=t,this._applyProps()}get srcRect(){return this._srcRect}dispose(){var e;super.dispose(),(e=this._cacheCanvas)==null||e.dispose(),this._srcRect=null}isHit(e){const t=this.getInverseCoord(e);return t.x>=-this.strokeWidth/2&&t.x<=this.width+this.strokeWidth/2&&t.y>=-this.strokeWidth/2&&t.y<=this.height+this.strokeWidth/2&&!this._inSurround(t)}_inSurround(e){const t=this._dragPadding;return e.x>=t-this.strokeWidth/2&&e.x<=this.width+this.strokeWidth/2-t&&e.y>=t-this.strokeWidth/2&&e.y<=this.height+this.strokeWidth/2-t}render(e,t){return this.visible?(e.save(),this._draw(e),e.restore(),this.makeDirty(!1),this):(this.makeDirty(!1),this)}_draw(e){var c,g;const n=this.getScene().getEngine(),{width:i,height:a}=n;this._initialCacheCanvas(),(c=this._cacheCanvas)==null||c.clear();const o=(g=this._cacheCanvas)==null?void 0:g.getContext();o!=null&&(o.save(),y.Rect.drawWith(o,{left:0,top:0,width:i,height:a,fill:"rgba(0, 0, 0, 0.5)"}),o.setTransform(e.getTransform()),this._clipForApplyObject(o),this._applyCache(e),o.restore())}_clipForApplyObject(e){let t=0;if(this._prstGeom!=null&&(t=1),e.globalCompositeOperation="destination-out",e.beginPath(),t===0){const n=this.transform.getMatrix();e.transform(n[0],n[1],n[2],n[3],n[4],n[5]),e.rect(0,0,this.width,this.height),e.fill()}}_applyProps(){if(this._applyTransform==null)return;let e=0,t=0,n=0,i=0;const{left:a=0,top:o=0,width:c=0,height:g=0,angle:l}=this._applyTransform;if(this._srcRect!=null){const{left:p=0,top:S=0,right:m=0,bottom:w=0}=this._srcRect;e=p,t=S,n=m,i=w}const u=a+e,d=o+t;this.transformByState({left:u,top:d,width:a+c-n-u,height:o+g-i-d,angle:l})}_applyCache(e){if(!e||this._cacheCanvas==null)return;const t=this._cacheCanvas.getContext();t.save(),e.save(),e.setTransform(1,0,0,1,0,0),t.setTransform(1,0,0,1,0,0),e.drawImage(this._cacheCanvas.getCanvasEle(),0,0),e.restore(),t.restore()}_initialCacheCanvas(){if(this._cacheCanvas!=null)return;const e=this.getScene();if(e==null)return;this._cacheCanvas=new y.Canvas;const t=e.getEngine();this._cacheCanvas.setSize(t.width,t.height),t.onTransformChange$.subscribeEvent(()=>{var n;(n=this._cacheCanvas)==null||n.setSize(t.width,t.height),this.makeDirty(!0)})}}var ft=Object.getOwnPropertyDescriptor,pt=(s,r,e,t)=>{for(var n=t>1?void 0:t?ft(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(n=a(n)||n);return n},ae=(s,r)=>(e,t)=>r(e,t,s);let _e=class extends f.Disposable{constructor(r,e,t,n,i,a){super();J(this,"_sceneListenerOnImageMap",new WeakSet);this._commandService=r,this._drawingManagerService=e,this._renderManagerService=t,this._univerInstanceService=n,this._messageService=i,this._localeService=a,this._init()}_init(){this._initOpenCrop(),this._initCloseCrop(),this._initAutoCrop()}_initAutoCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id!==ge.id)return;const e=r.params;if(e==null)return;const{cropType:t}=e,n=this._drawingManagerService.getFocusDrawings();if(n.length!==1)return;const i=n[0],{unitId:a,subUnitId:o,drawingId:c}=i,g=this._renderManagerService.getRenderById(a),l=g==null?void 0:g.scene;if(l==null)return!0;this._searchCropObject(l)!=null&&this._commandService.syncExecuteCommand(Q.id,{isAuto:!0});const d=M.getDrawingShapeKeyByDrawingSearch({unitId:a,subUnitId:o,drawingId:c}),p=l.getObject(d);if(!(p instanceof y.Image)){this._messageService.show({type:P.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}p!=null&&(this._updateCropperObject(t,p),this._commandService.executeCommand(we.id,{unitId:a,subUnitId:o,drawingId:c}))}))}_calculateSrcRectByRatio(r,e,t,n,i,a){const o=t/n,c=i/a;let g=t,l=n;o>c?g=n*c:l=t/c;const u=(t-g)/2,d=(n-l)/2;return{left:y.precisionTo(u,1),top:y.precisionTo(d,1),right:y.precisionTo(t-(u+g),1),bottom:y.precisionTo(n-(d+l),1)}}_updateCropperObject(r,e){const{left:t,top:n,width:i,height:a}=e.calculateTransformWithSrcRect();let o;switch(r){case U.R1_1:o=this._calculateSrcRectByRatio(t,n,i,a,1,1);break;case U.R16_9:o=this._calculateSrcRectByRatio(t,n,i,a,16,9);break;case U.R9_16:o=this._calculateSrcRectByRatio(t,n,i,a,9,16);break;case U.R5_4:o=this._calculateSrcRectByRatio(t,n,i,a,5,4);break;case U.R4_5:o=this._calculateSrcRectByRatio(t,n,i,a,4,5);break;case U.R4_3:o=this._calculateSrcRectByRatio(t,n,i,a,4,3);break;case U.R3_4:o=this._calculateSrcRectByRatio(t,n,i,a,3,4);break;case U.R3_2:o=this._calculateSrcRectByRatio(t,n,i,a,3,2);break;case U.R2_3:o=this._calculateSrcRectByRatio(t,n,i,a,2,3);break;case U.FREE:}if(o==null)return;e.setSrcRect(o);const{left:c=0,top:g=0,bottom:l=0,right:u=0}=o;e.transformByStateCloseCropper({left:t+c,top:n+g,width:i-u-c,height:a-l-g})}_initOpenCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id!==we.id)return;const e=r.params;if(e==null)return;const{unitId:t,subUnitId:n,drawingId:i}=e,a=this._renderManagerService.getRenderById(t),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:t,subUnitId:n,drawingId:i})==null)return;const g=M.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:n,drawingId:i}),l=o.getObject(g);if(l==null)return;if(!(l instanceof y.Image)){this._messageService.show({type:P.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}const u=o.getTransformer();u==null||u.clearControls();const d=new le(`${g}-crop`,{srcRect:l.srcRect,prstGeom:l.prstGeom,applyTransform:l.calculateTransformWithSrcRect()});o.addObject(d,l.getLayerIndex()+1).attachTransformerTo(d),u==null||u.createControlForCopper(d),this._addHoverForImageCopper(d),l.openRenderByCropper(),u==null||u.refreshControls(),d.makeDirty(!0),this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,[{unitId:t,subUnitId:n,drawingId:i}])}))}_searchCropObject(r){const e=r.getAllObjectsByOrder();for(const t of e)if(t instanceof le)return t}_initCloseCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==Q.id)return;const t=this._univerInstanceService.getFocusedUnit();if(t==null)return;const n=t.getUnitId(),i=this._renderManagerService.getRenderById(n),a=i==null?void 0:i.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 g=a.getTransformerByCreate();g.detachFrom(o),g.clearCopperControl();const l=this._getSrcRectByTransformState(c,o),u=this._drawingManagerService.getDrawingOKey(c.oKey);if(u!=null){const{left:d,top:p,height:S,width:m}=o;this._drawingManagerService.featurePluginUpdateNotification([{...u,transform:{...u.transform,left:d,top:p,height:S,width:m},srcRect:l.srcRectAngle}])}c.setSrcRect({...l.srcRectAngle}),c.closeRenderByCropper(),c.makeDirty(!0),o==null||o.dispose()}));const r=this._univerInstanceService.getCurrentTypeOfUnit$(f.UniverInstanceType.UNIVER_SHEET).pipe(Oe.switchMap(e=>e?e.activeSheet$:Oe.of(null)));this.disposeWithMe(r.subscribe(()=>{this._commandService.syncExecuteCommand(Q.id)}))}_getApplyObjectByCropObject(r){const e=r.oKey,t=e.slice(0,e.length-5),n=r.getScene();if(!n)return null;const i=n.getObject(t);return i==null?null:i}_addListenerOnImage(r){const e=r.getTransformerByCreate();let t=null;this.disposeWithMe(e.changeStart$.subscribe(n=>{const{objects:i}=n,a=i.values().next().value;if(a==null||!(a instanceof le))return;const{left:o,top:c,height:g,width:l,angle:u}=a;t={left:o,top:c,height:g,width:l,angle:u},e.clearCopperControl()})),this.disposeWithMe(e.changeEnd$.subscribe(n=>{const{objects:i}=n,a=i.values().next().value;if(a==null||!(a instanceof le))return;const{left:o,top:c,height:g,width:l,angle:u}=a;if(!f.checkIfMove({left:o,top:c,height:g,width:l,angle:u},t))return;const d=this._getApplyObjectByCropObject(a);if(d==null)return;const p=this._getSrcRectByTransformState(d,a);a.refreshSrcRect(p.srcRect,d.getState()),e.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 e=r.getTransformerByCreate();this.disposeWithMe(e.clearControl$.subscribe(t=>{t===!0&&this._commandService.syncExecuteCommand(Q.id)}))}_getSrcRectByTransformState(r,e){const{left:t,top:n,height:i,width:a,strokeWidth:o,angle:c}=e,{left:g,top:l,width:u,height:d,angle:p,strokeWidth:S}=r,m=t-g,w=n-l,C={left:m,top:w,right:u-m-a,bottom:d-w-i},I={...C};if(p!==0){const D=t+a/2,j=n+i/2,N=new y.Vector2(D,j),b=u/2+g,O=d/2+l,R=new y.Vector2(b,O),E=new y.Vector2(g,l);E.rotateByPoint(y.degToRad(p),R);const x=E.clone();x.rotateByPoint(y.degToRad(-p),N);const k=t-x.x,A=n-x.y;I.left=k,I.top=A,I.right=u-k-a,I.bottom=d-A-i}return{srcRect:C,srcRectAngle:I}}};_e=pt([ae(0,f.ICommandService),ae(1,M.IDrawingManagerService),ae(2,y.IRenderManagerService),ae(3,f.IUniverInstanceService),ae(4,H.IMessageService),ae(5,f.Inject(f.LocaleService))],_e);var mt=Object.getOwnPropertyDescriptor,wt=(s,r,e,t)=>{for(var n=t>1?void 0:t?mt(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(n=a(n)||n);return n},he=(s,r)=>(e,t)=>r(e,t,s);exports.DrawingRenderService=class{constructor(r,e,t,n){this._drawingManagerService=r,this._imageIoService=e,this._galleryService=t,this._urlImageService=n}async renderImages(r,e){const{transform:t,drawingType:n,source:i,imageSourceType:a,srcRect:o,prstGeom:c,groupId:g,unitId:l,subUnitId:u,drawingId:d,isMultiTransform:p,transforms:S}=r;if(n!==f.DrawingTypeEnum.DRAWING_IMAGE||!this._drawingManagerService.getDrawingVisible()||t==null)return;const m=p&&S?S:[t],w=[];for(const C of m){const{left:I,top:D,width:j,height:N,angle:b,flipX:O,flipY:R,skewX:E,skewY:x}=C,k=m.indexOf(C),A=M.getDrawingShapeKeyByDrawingSearch({unitId:l,subUnitId:u,drawingId:d},p?k:void 0),$=e.getObject(A);if($!=null){$.transformByState({left:I,top:D,width:j,height:N,angle:b,flipX:O,flipY:R,skewX:E,skewY:x});continue}const z=this._drawingManagerService.getDrawingOrder(l,u),ie=z.indexOf(d),Y={...C,zIndex:ie===-1?z.length-1:ie},ee=this._imageIoService.getImageSourceCache(i,a);let te=!1;if(ee!=null)Y.image=ee;else if(a===M.ImageSourceType.UUID)try{Y.url=await this._imageIoService.getImage(i)}catch(se){console.error(se);continue}else if(a===M.ImageSourceType.URL){try{Y.url=await this._urlImageService.getImage(i)}catch(se){console.error(se),Y.url=i}te=!0}else Y.url=i,te=!0;if(e.getObject(A))continue;Y.printable=!0;const X=new y.Image(A,Y);te&&this._imageIoService.addImageSourceCache(i,a,X.getNative()),this._drawingManagerService.getDrawingVisible()&&(e.addObject(X,y.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&e.attachTransformerTo(X),g&&be({drawingId:g,unitId:l,subUnitId:u},X,e,this._drawingManagerService),c!=null&&X.setPrstGeom(c),o!=null&&X.setSrcRect(o),w.push(X))}return w}renderFloatDom(r,e){const{transform:t,drawingType:n,groupId:i,unitId:a,subUnitId:o,drawingId:c,isMultiTransform:g,transforms:l}=r;if(n!==f.DrawingTypeEnum.DRAWING_DOM||!this._drawingManagerService.getDrawingVisible()||t==null)return;const u=g&&l?l:[t],d=[];for(const p of u){const{left:S,top:m,width:w,height:C,angle:I,flipX:D,flipY:j,skewX:N,skewY:b}=p,O=u.indexOf(p),R=M.getDrawingShapeKeyByDrawingSearch({unitId:a,subUnitId:o,drawingId:c},g?O:void 0),E=e.getObject(R);if(E!=null){E.transformByState({left:S,top:m,width:w,height:C,angle:I,flipX:D,flipY:j,skewX:N,skewY:b});continue}const x=this._drawingManagerService.getDrawingOrder(a,o),k=x.indexOf(c),A={...p,zIndex:k===-1?x.length-1:k};if(e.getObject(R))continue;A.printable=!1;const $=new y.Rect(R,A);this._drawingManagerService.getDrawingVisible()&&(e.addObject($,y.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&r.allowTransform!==!1&&e.attachTransformerTo($),i&&be({drawingId:i,unitId:a,subUnitId:o},$,e,this._drawingManagerService),d.push($))}return d}renderDrawing(r,e){const t=this._drawingManagerService.getDrawingByParam(r);if(t!=null&&t.drawingType===f.DrawingTypeEnum.DRAWING_IMAGE)return this.renderImages(t,e)}previewImage(r,e,t,n){this._galleryService.open({images:[e],onOpenChange:i=>{i||this._galleryService.close()}})}_adjustImageSize(r,e,t,n){if(r<=t&&e<=n)return{width:r,height:e};const i=t/r,a=n/e,o=Math.min(i,a);return{width:Math.floor(r*o),height:Math.floor(e*o)}}};exports.DrawingRenderService=wt([he(0,M.IDrawingManagerService),he(1,M.IImageIoService),he(2,H.IGalleryService),he(3,f.IURLImageService)],exports.DrawingRenderService);var vt=Object.getOwnPropertyDescriptor,St=(s,r,e,t)=>{for(var n=t>1?void 0:t?vt(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(n=a(n)||n);return n},ne=(s,r)=>(e,t)=>r(e,t,s);let Ce=class extends f.Disposable{constructor(s,r,e,t,n,i,a){super(),this._commandService=s,this._renderManagerService=r,this._drawingManagerService=e,this._dialogService=t,this._imageIoService=n,this._currentUniverService=i,this._drawingRenderService=a,this._initialize()}dispose(){super.dispose()}_initialize(){this._drawingAddListener(),this._commandExecutedListener(),this._imageUpdateListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(s=>{if(s.id===De.id){const r=s.params;if(r==null)return;this._resetImageSize(r)}}))}_getSceneAndTransformerByDrawingSearch(s){if(s==null)return;const r=this._renderManagerService.getRenderById(s),e=r==null?void 0:r.scene;if(e==null)return null;const t=e.getTransformerByCreate();return{scene:e,transformer:t}}_resetImageSize(s){const r=[],e=[];s.forEach(t=>{const{unitId:n,subUnitId:i,drawingId:a}=t,o=this._getSceneAndTransformerByDrawingSearch(n);if(o==null)return;const{scene:c}=o,g=M.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:i,drawingId:a}),l=c.getObject(g);if(l==null)return!0;const u=this._drawingManagerService.getDrawingByParam(t);if(u==null)return!0;if(u.drawingType!==f.DrawingTypeEnum.DRAWING_IMAGE)return;l.resetSize();const{width:d,height:p}=l.getNativeSize();e.includes(c)===!1&&e.push(c),r.push({...u,transform:{...u.transform,height:p,width:d,angle:0},srcRect:null,prstGeom:null})}),this._drawingManagerService.featurePluginUpdateNotification(r),e.forEach(t=>{t.getTransformerByCreate().refreshControls().changeNotification()}),this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,s)}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(s=>{this._insertImages(s)}))}_insertImages(s){s.forEach(async r=>{var c;const{unitId:e,subUnitId:t}=r,n=this._getSceneAndTransformerByDrawingSearch(e),i=(c=Re(this._currentUniverService,e))==null?void 0:c.subUnitId;if(n==null||i!==t)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 g of o)this._addHoverForImage(g),this._addDialogForImage(g)})}_imageUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(s=>{s.forEach(r=>{const{unitId:e,subUnitId:t,drawingId:n}=r,i=this._drawingManagerService.getDrawingByParam(r);if(i==null)return;const{transform:a,drawingType:o,srcRect:c,prstGeom:g,source:l,imageSourceType:u}=i;if(o!==f.DrawingTypeEnum.DRAWING_IMAGE)return;const d=this._getSceneAndTransformerByDrawingSearch(e);if(d==null)return;const{scene:p,transformer:S}=d;if(a==null)return!0;const m=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:t,drawingId:n}),w=p.getObject(m);if(w==null)return!0;w.setSrcRect(c),w.setPrstGeom(g),l!=null&&l.length>0&&(u===f.ImageSourceType.BASE64||u===f.ImageSourceType.URL)&&w.changeSource(l)})}))}_addHoverForImage(s){this.disposeWithMe(f.toDisposable(s.onPointerEnter$.subscribeEvent(()=>{s.cursor=y.CURSOR_TYPE.GRAB}))),this.disposeWithMe(f.toDisposable(s.onPointerLeave$.subscribeEvent(()=>{s.cursor=y.CURSOR_TYPE.DEFAULT})))}_addDialogForImage(s){this.disposeWithMe(f.toDisposable(s.onDblclick$.subscribeEvent(()=>{const r=`${s.oKey}-viewer-dialog`;this._drawingRenderService.previewImage(r,s.getNative().src,s.getNativeSize().width,s.getNativeSize().height)})))}};Ce=St([ne(0,f.ICommandService),ne(1,y.IRenderManagerService),ne(2,M.IDrawingManagerService),ne(3,H.IDialogService),ne(4,M.IImageIoService),ne(5,f.IUniverInstanceService),ne(6,f.Inject(exports.DrawingRenderService))],Ce);var _t=Object.getOwnPropertyDescriptor,Ct=(s,r,e,t)=>{for(var n=t>1?void 0:t?_t(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(n=a(n)||n);return n},Ee=(s,r)=>(e,t)=>r(e,t,s);const It="UNIVER_DRAWING_UI_PLUGIN";var ye;exports.UniverDrawingUIPlugin=(ye=class extends f.Plugin{constructor(r=xe,e,t){super(),this._config=r,this._injector=e,this._configService=t;const{menu:n,...i}=f.merge({},xe,this._config);n&&this._configService.setConfig("menu",n,{merge:!0}),this._configService.setConfig(qe,i)}onStarting(){this._initDependencies()}onRendered(){this._injector.get(Se),this._injector.get(ve),this._injector.get(_e),this._injector.get(Ce)}_initDependencies(){[[exports.DrawingRenderService],[Se],[ve],[_e],[Ce]].forEach(e=>this._injector.add(e))}},J(ye,"pluginName",It),ye);exports.UniverDrawingUIPlugin=Ct([Ee(1,f.Inject(f.Injector)),Ee(2,f.IConfigService)],exports.UniverDrawingUIPlugin);const yt=s=>{const r=H.useDependency(f.ICommandService),e=H.useDependency(f.LocaleService),{alignShow:t}=s,[n,i]=_.useState(T.default),a=[{label:e.t("image-panel.align.default"),value:T.default},{options:[{label:e.t("image-panel.align.left"),value:T.left},{label:e.t("image-panel.align.center"),value:T.center},{label:e.t("image-panel.align.right"),value:T.right}]},{options:[{label:e.t("image-panel.align.top"),value:T.top},{label:e.t("image-panel.align.middle"),value:T.middle},{label:e.t("image-panel.align.bottom"),value:T.bottom}]},{options:[{label:e.t("image-panel.align.horizon"),value:T.horizon},{label:e.t("image-panel.align.vertical"),value:T.vertical}]}];function o(c){i(c),r.executeCommand(Ie.id,{alignType:c})}return h.jsxs("div",{className:P.clsx("univer-relative univer-w-full",{"univer-hidden":!t}),children:[h.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:h.jsx("div",{children:e.t("image-panel.align.title")})}),h.jsx("div",{className:"univer-relative univer-mt-2.5 univer-flex univer-h-full",children:h.jsx("div",{className:"univer-w-full univer-text-gray-900 dark:!univer-text-white",children:h.jsx(P.Select,{value:n,options:a,onChange:o})})})]})},bt=s=>{const{arrangeShow:r,drawings:e}=s,t=H.useDependency(f.LocaleService),n=H.useDependency(M.IDrawingManagerService),[i,a]=_.useState(e);_.useEffect(()=>{const c=n.focus$.subscribe(g=>{a(g)});return()=>{c.unsubscribe()}},[]);const o=c=>{const g=i[0].unitId,l=i[0].subUnitId,u=i.map(d=>d.drawingId);n.featurePluginOrderUpdateNotification({unitId:g,subUnitId:l,drawingIds:u,arrangeType:c})};return h.jsxs("div",{className:P.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!r}),children:[h.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:h.jsx("div",{children:t.t("image-panel.arrange.title")})}),h.jsxs("div",{className:"univer-grid univer-grid-cols-2 univer-gap-2",children:[h.jsxs(P.Button,{onClick:()=>{o(f.ArrangeTypeEnum.forward)},children:[h.jsx(ke,{}),t.t("image-panel.arrange.forward")]}),h.jsxs(P.Button,{onClick:()=>{o(f.ArrangeTypeEnum.backward)},children:[h.jsx(He,{}),t.t("image-panel.arrange.backward")]}),h.jsxs(P.Button,{onClick:()=>{o(f.ArrangeTypeEnum.front)},children:[h.jsx(Ge,{}),t.t("image-panel.arrange.front")]}),h.jsxs(P.Button,{onClick:()=>{o(f.ArrangeTypeEnum.back)},children:[h.jsx(Be,{}),t.t("image-panel.arrange.back")]})]})]})},Dt=s=>{const r=H.useDependency(f.LocaleService),e=H.useDependency(y.IRenderManagerService),t=H.useDependency(M.IDrawingManagerService),{hasGroup:n,drawings:i}=s,[a,o]=_.useState(!1),[c,g]=_.useState(!0),[l,u]=_.useState(!0),d=()=>{const m=t.getFocusDrawings(),{unitId:w,subUnitId:C}=m[0],I=f.generateRandomId(10),D=y.getGroupState(0,0,m.map(b=>b.transform||{})),j={unitId:w,subUnitId:C,drawingId:I,drawingType:f.DrawingTypeEnum.DRAWING_GROUP,transform:D},N=m.map(b=>{const O=b.transform||{left:0,top:0},{unitId:R,subUnitId:E,drawingId:x}=b;return{unitId:R,subUnitId:E,drawingId:x,transform:{...O,left:O.left-D.left,top:O.top-D.top},groupId:I}});t.featurePluginGroupUpdateNotification([{parent:j,children:N}])},p=m=>{if(m.drawingType!==f.DrawingTypeEnum.DRAWING_GROUP)return;const{unitId:w,subUnitId:C,drawingId:I,transform:D={width:0,height:0}}=m;if(D==null)return;const j=t.getDrawingsByGroup({unitId:w,subUnitId:C,drawingId:I});if(j.length===0)return;const N=j.map(b=>{const{transform:O}=b,{unitId:R,subUnitId:E,drawingId:x}=b,k=y.transformObjectOutOfGroup(O||{},D,D.width||0,D.height||0);return{unitId:R,subUnitId:E,drawingId:x,transform:{...O,...k},groupId:void 0}});return{parent:m,children:N}},S=()=>{const w=t.getFocusDrawings().map(C=>p(C)).filter(C=>C!=null);w.length!==0&&t.featurePluginUngroupUpdateNotification(w)};return _.useEffect(()=>{const m=i[0];if(m==null)return;const{unitId:w}=m,C=e.getRenderById(w),I=C==null?void 0:C.scene;if(I==null)return;const D=I.getTransformerByCreate(),j=D.clearControl$.subscribe(b=>{b===!0&&o(!1)}),N=D.changeStart$.subscribe(b=>{const{objects:O}=b,R=ue(O,t),E=R.filter($=>($==null?void 0:$.drawingType)===f.DrawingTypeEnum.DRAWING_GROUP);let x=!1,k=!1;R.length>1&&(x=!0),E.length>0&&(k=!0),o(x||k),g(x),u(k)});return()=>{N.unsubscribe(),j.unsubscribe()}},[]),h.jsxs("div",{className:P.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":n===!0&&a===!1||n===!1}),children:[h.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:h.jsx("div",{children:r.t("image-panel.group.title")})}),h.jsxs("div",{className:"univer-flex univer-items-center univer-justify-center univer-gap-2",children:[h.jsxs(P.Button,{className:P.clsx({"univer-hidden":!c}),onClick:d,children:[h.jsx(Ae,{}),r.t("image-panel.group.group")]}),h.jsxs(P.Button,{className:P.clsx({"univer-hidden":!l}),onClick:S,children:[h.jsx($e,{}),r.t("image-panel.group.unGroup")]})]})]})},fe=20,pe=20,Te=[-360,360],me=300,Rt=s=>{var Me;const r=H.useDependency(f.LocaleService),e=H.useDependency(M.IDrawingManagerService),t=H.useDependency(y.IRenderManagerService),{drawings:n,transformShow:i}=s,a=n[0];if(a==null)return;const o=a.transform;if(o==null)return;const{unitId:c,subUnitId:g,drawingId:l,drawingType:u}=a,d=t.getRenderById(c),p=d==null?void 0:d.scene;if(p==null)return;const S=(Me=p.getEngine())==null?void 0:Me.activeScene;if(S==null)return;const m=p.getTransformerByCreate(),{width:w=0,height:C=0,left:I=0,top:D=0,angle:j=0}=o,[N,b]=_.useState(w),[O,R]=_.useState(C),[E,x]=_.useState(I),[k,A]=_.useState(D),[$,z]=_.useState(j),[ie,Y]=_.useState(m.keepRatio),ee=(v,B,G,V)=>{const{width:L,height:q}=S,{ancestorLeft:W,ancestorTop:K}=p;let Z=v,re=B,oe=G,ce=V;return v+W<0&&(Z=-W),B+K<0&&(re=-K),oe=L-Z-W,oe<fe&&(oe=fe),ce=q-re-K,ce<pe&&(ce=pe),v+oe+W>L&&(Z=L-G-W),B+ce+K>q&&(re=q-V-K),{limitLeft:Z,limitTop:re,limitWidth:oe,limitHeight:ce}},te=v=>{const{objects:B}=v,G=ue(B,e);if(G.length!==1)return;const V=G[0];if(V==null)return;const{transform:L}=V;if(L==null)return;const{width:q,height:W,left:K,top:Z,angle:re}=L;q!=null&&b(q),W!=null&&R(W),K!=null&&x(K),Z!=null&&A(Z),re!=null&&z(re)};_.useEffect(()=>{const v=[m.changeStart$.subscribe(B=>{te(B)}),m.changing$.subscribe(B=>{te(B)}),m.changeEnd$.subscribe(B=>{te(B)}),e.focus$.subscribe(B=>{if(B.length!==1)return;const G=e.getDrawingByParam(B[0]);if(G==null)return;const V=G.transform;if(V==null)return;const{width:L,height:q,left:W,top:K,angle:Z}=V;L!=null&&b(L),q!=null&&R(q),W!=null&&x(W),K!=null&&A(K),Z!=null&&z(Z)})];return()=>{v.forEach(B=>B.unsubscribe())}},[]);const X=f.debounce(v=>{if(v==null)return;const{limitWidth:B,limitHeight:G}=ee(E,k,v,O);v=Math.min(v,B);const V={unitId:c,subUnitId:g,drawingId:l,drawingType:u,transform:{width:v}};if(ie){let L=v/N*O;if(L=Math.max(L,pe),L>G)return;R(L),V.transform.height=L}b(v),e.featurePluginUpdateNotification([V]),m.refreshControls().changeNotification()},me),se=f.debounce(v=>{if(v==null)return;const{limitHeight:B,limitWidth:G}=ee(E,k,N,v);v=Math.min(v,B);const V={unitId:c,subUnitId:g,drawingId:l,drawingType:u,transform:{height:v}};if(ie){let L=v/O*N;if(L=Math.max(L,fe),L>G)return;b(L),V.transform.width=L}R(v),e.featurePluginUpdateNotification([V]),m.refreshControls().changeNotification()},me),Ke=f.debounce(v=>{if(v==null)return;const{limitLeft:B}=ee(v,k,N,O);v=B;const G={unitId:c,subUnitId:g,drawingId:l,drawingType:u,transform:{left:v}};x(v),e.featurePluginUpdateNotification([G]),m.refreshControls().changeNotification()},me),Ze=f.debounce(v=>{if(v==null)return;const{limitTop:B}=ee(E,v,N,O);v=B;const G={unitId:c,subUnitId:g,drawingId:l,drawingType:u,transform:{top:v}};A(v),e.featurePluginUpdateNotification([G]),m.refreshControls().changeNotification()},me),Fe=v=>{if(v==null)return;const B={unitId:c,subUnitId:g,drawingId:l,drawingType:u,transform:{angle:v}};z(v),e.featurePluginUpdateNotification([B]),m.refreshControls().changeNotification()},ze=v=>{Y(v),m.keepRatio=v};return h.jsxs("div",{className:P.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!i}),children:[h.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:h.jsx("div",{children:r.t("image-panel.transform.title")})}),h.jsxs("div",{className:"univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2",children:[h.jsxs("div",{children:[h.jsx("span",{children:r.t("image-panel.transform.width")}),h.jsx(P.InputNumber,{precision:1,value:N,min:fe,onChange:v=>{X(v)}})]}),h.jsxs("div",{children:[h.jsx("span",{children:r.t("image-panel.transform.height")}),h.jsx(P.InputNumber,{precision:1,value:O,min:pe,onChange:v=>{se(v)}})]}),h.jsxs("div",{children:[h.jsx("span",{children:r.t("image-panel.transform.lock")}),h.jsx("div",{className:"univer-text-center",children:h.jsx(P.Checkbox,{checked:ie,onChange:ze})})]})]}),h.jsxs("div",{className:"univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2",children:[h.jsxs("div",{children:[h.jsx("span",{children:r.t("image-panel.transform.x")}),h.jsx(P.InputNumber,{precision:1,value:E,onChange:v=>{Ke(v)}})]}),h.jsxs("div",{children:[h.jsx("span",{children:r.t("image-panel.transform.y")}),h.jsx(P.InputNumber,{precision:1,value:k,onChange:v=>{Ze(v)}})]}),h.jsxs("div",{children:[h.jsx("span",{children:r.t("image-panel.transform.rotate")}),h.jsx(P.InputNumber,{precision:1,value:$,min:Te[0],max:Te[1],onChange:Fe})]})]})]})},Mt=s=>{const r=H.useDependency(f.ICommandService),e=H.useDependency(f.LocaleService),{drawings:t,cropperShow:n}=s;if(t[0]==null)return;const[a,o]=_.useState(U.FREE),c=_.useRef(!1),g=[{label:e.t("image-panel.crop.mode"),value:U.FREE},{label:"1:1",value:U.R1_1},{label:"16:9",value:U.R16_9},{label:"9:16",value:U.R9_16},{label:"5:4",value:U.R5_4},{label:"4:5",value:U.R4_5},{label:"4:3",value:U.R4_3},{label:"3:4",value:U.R3_4},{label:"3:2",value:U.R3_2},{label:"2:3",value:U.R2_3}];_.useEffect(()=>{const d=r.onCommandExecuted(p=>{if(p.id===Q.id){const S=p.params;S!=null&&S.isAuto||(c.current=!1)}});return()=>{d==null||d.dispose()}},[]);function l(d){o(d),c.current&&r.executeCommand(ge.id,{cropType:d})}const u=d=>{r.executeCommand(ge.id,{cropType:d}),c.current=!0};return h.jsxs("div",{className:P.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!n}),children:[h.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:h.jsx("div",{children:e.t("image-panel.crop.title")})}),h.jsxs("div",{className:"univer-flex univer-items-center univer-justify-center univer-gap-2",children:[h.jsxs(P.Button,{onClick:()=>{u(a)},children:[h.jsx(Ue,{}),e.t("image-panel.crop.start")]}),h.jsx(P.Select,{value:a,options:g,onChange:l})]})]})},Ot=s=>{const r=H.useDependency(M.IDrawingManagerService),e=H.useDependency(y.IRenderManagerService),t=H.useDependency(f.LocaleService),{drawings:n,hasArrange:i=!0,hasTransform:a=!0,hasAlign:o=!0,hasCropper:c=!0,hasGroup:g=!0}=s,l=n[0];if(l==null)return;const{unitId:u}=l,d=e.getRenderById(u),p=d==null?void 0:d.scene;if(p==null)return;const S=p.getTransformerByCreate(),[m,w]=_.useState(!0),[C,I]=_.useState(!0),[D,j]=_.useState(!1),[N,b]=_.useState(!0),[O,R]=_.useState(!1);return _.useEffect(()=>{const E=S.clearControl$.subscribe(A=>{A===!0&&(w(!1),I(!1),j(!1),b(!1),R(!0))}),x=S.changeStart$.subscribe(A=>{const{objects:$}=A,z=ue($,r);z.length===0?(w(!1),I(!1),j(!1),b(!1),R(!0)):z.length===1?(w(!0),I(!0),j(!1),b(!0),R(!1)):(w(!0),I(!1),j(!0),b(!1),R(!1))}),k=r.focus$.subscribe(A=>{A.length===0?(w(!1),I(!1),j(!1),b(!1),R(!0)):A.length===1?(w(!0),I(!0),j(!1),b(!0),R(!1)):(w(!0),I(!1),j(!0),b(!1),R(!1))});return()=>{x.unsubscribe(),E.unsubscribe(),k.unsubscribe()}},[]),h.jsxs(h.Fragment,{children:[h.jsx("div",{className:P.clsx("univer-h-full",{"univer-hidden":!O}),children:h.jsx("div",{className:"univer-flex univer-h-full univer-items-center univer-justify-center",children:h.jsx("span",{children:t.t("image-panel.null")})})}),h.jsx(bt,{arrangeShow:i===!0?m:!1,drawings:n}),h.jsx(Rt,{transformShow:a===!0?C:!1,drawings:n}),h.jsx(yt,{alignShow:o===!0?D:!1,drawings:n}),h.jsx(Mt,{cropperShow:c===!0?N:!1,drawings:n}),h.jsx(Dt,{hasGroup:g,drawings:n})]})};exports.AutoImageCropOperation=ge;exports.COMPONENT_IMAGE_POPUP_MENU=Pe;exports.CloseImageCropOperation=Q;exports.DrawingCommonPanel=Ot;exports.ImageCropperObject=le;exports.ImagePopupMenu=We;exports.ImageResetSizeOperation=De;exports.OpenImageCropOperation=we;exports.SetDrawingAlignOperation=Ie;exports.getCurrentUnitInfo=Re;exports.getUpdateParams=ue;exports.insertGroupObject=be;
1
+ "use strict";var Ye=Object.defineProperty;var Xe=(s,r,e)=>r in s?Ye(s,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[r]=e;var J=(s,r,e)=>Xe(s,typeof r!="symbol"?r+"":r,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("@univerjs/core"),M=require("@univerjs/drawing"),y=require("@univerjs/engine-render"),H=require("@univerjs/ui"),h=require("react/jsx-runtime"),P=require("@univerjs/design"),_=require("react"),ie=require("rxjs");var T=(s=>(s.default="0",s.left="1",s.center="2",s.right="3",s.top="4",s.middle="5",s.bottom="6",s.horizon="7",s.vertical="8",s))(T||{});const ye={id:"sheet.operation.set-image-align",type:f.CommandType.OPERATION,handler:(s,r)=>!0},ve={id:"sheet.operation.open-image-crop",type:f.CommandType.OPERATION,handler:(s,r)=>!0},Q={id:"sheet.operation.close-image-crop",type:f.CommandType.OPERATION,handler:(s,r)=>!0};var U=(s=>(s.FREE="0",s.R1_1="1",s.R16_9="2",s.R9_16="3",s.R5_4="4",s.R4_5="5",s.R4_3="6",s.R3_4="7",s.R3_2="8",s.R2_3="9",s))(U||{});const de={id:"sheet.operation.Auto-image-crop",type:f.CommandType.OPERATION,handler:(s,r)=>!0},Re={id:"sheet.operation.image-reset-size",type:f.CommandType.OPERATION,handler:(s,r)=>!0};function De(s,r,e,t){const n=t.getDrawingByParam(s);if(n==null)return;const i=M.getDrawingShapeKeyByDrawingSearch(s),a=e.getObject(i);if(a&&!(a instanceof y.Group))return;if(a!=null){a.addObject(r);return}const o=new y.Group(i);e.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 Me(s,r){var i;const e=r?s.getUnit(r):s.getFocusedUnit();if(e==null)return;const t=e.getUnitId();let n;return e.type===f.UniverInstanceType.UNIVER_SHEET?n=(i=e.getActiveSheet())==null?void 0:i.getSheetId():(e.type===f.UniverInstanceType.UNIVER_DOC||e.type===f.UniverInstanceType.UNIVER_SLIDE)&&(n=t),{unitId:t,subUnitId:n,current:e}}const qe="drawing-ui.config",xe={},Pe="COMPONENT_IMAGE_POPUP_MENU";function F({ref:s,...r}){const{icon:e,id:t,className:n,extend:i,...a}=r,o=`univerjs-icon univerjs-icon-${t} ${n||""}`.trim(),c=_.useRef(`_${et()}`);return Ne(e,`${t}`,{defIds:e.defIds,idSuffix:c.current},{ref:s,className:o,...a},i)}function Ne(s,r,e,t,n){return _.createElement(s.tag,{key:r,...Je(s,e,n),...t},(Qe(s,e).children||[]).map((i,a)=>Ne(i,`${r}-${s.tag}-${a}`,e,void 0,n)))}function Je(s,r,e){const t={...s.attrs};e!=null&&e.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=e.colorChannel1),s.tag==="mask"&&t.id&&(t.id=t.id+r.idSuffix),Object.entries(t).forEach(([i,a])=>{i==="mask"&&typeof a=="string"&&(t[i]=a.replace(/url\(#(.*)\)/,`url(#$1${r.idSuffix})`))});const{defIds:n}=r;return!n||n.length===0||(s.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+r.idSuffix),Object.entries(t).forEach(([i,a])=>{typeof a=="string"&&(t[i]=a.replace(/url\(#(.*)\)/,`url(#$1${r.idSuffix})`))})),t}function Qe(s,r){var t;const{defIds:e}=r;return!e||e.length===0?s:s.tag==="defs"&&((t=s.children)!=null&&t.length)?{...s,children:s.children.map(n=>typeof n.attrs.id=="string"&&e&&e.includes(n.attrs.id)?{...n,attrs:{...n.attrs,id:n.attrs.id+r.idSuffix}}:n)}:s}function et(){return Math.random().toString(36).substring(2,8)}F.displayName="UniverIcon";const tt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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.8334C15.6045 1.94974 14.8881 1.2334 14.0045 1.2334H3.70449C2.82084 1.2334 2.10449 1.94974 2.10449 2.8334C2.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.8334C3.30449 2.61248 3.48358 2.4334 3.70449 2.4334H14.0045C14.2254 2.4334 14.4045 2.61249 14.4045 2.8334Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 8.5999C15.038 8.5999 15.7544 7.88356 15.7544 6.9999C15.7544 6.11625 15.038 5.3999 14.1544 5.3999H3.85439C2.97074 5.3999 2.25439 6.11625 2.25439 6.9999C2.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.9999C3.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.7421C6.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.56641C9.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.7421C11.6631 11.9765 11.6631 12.3564 11.4288 12.5907L9.42923 14.5902"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.57975 14.5902C8.58121 14.5917 8.58268 14.5931 8.58416 14.5946C8.64077 14.6502 8.70566 14.6923 8.77482 14.7209C8.84557 14.7502 8.92314 14.7664 9.00449 14.7664C9.08585 14.7664 9.16342 14.7502 9.23416 14.7209C9.30332 14.6923 9.36821 14.6502 9.42482 14.5946"}}]},Be=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"bottom-icon",ref:e,icon:tt}))});Be.displayName="BottomIcon";const rt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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.51296C9.08632 7.84433 8.81769 8.11296 8.48632 8.11296H6.57705C6.24568 8.11296 5.97705 7.84433 5.97705 7.51296Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.57705 9.41028C6.24568 9.41028 5.97705 9.67891 5.97705 10.0103C5.97705 10.3416 6.24568 10.6103 6.57705 10.6103H10.8199C11.1512 10.6103 11.4199 10.3416 11.4199 10.0103C11.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"}}]},Ue=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"create-copy-icon",ref:e,icon:rt}))});Ue.displayName="CreateCopyIcon";const nt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},Ae=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"group-icon",ref:e,icon:nt}))});Ae.displayName="GroupIcon";const it={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},Le=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"more-down-icon",ref:e,icon:it}))});Le.displayName="MoreDownIcon";const at={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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(r,e){return _.createElement(F,Object.assign({},r,{id:"move-down-icon",ref:e,icon:at}))});He.displayName="MoveDownIcon";const st={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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(r,e){return _.createElement(F,Object.assign({},r,{id:"move-up-icon",ref:e,icon:st}))});ke.displayName="MoveUpIcon";const ot={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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 9C15.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 9C2.70439 9.22091 2.88348 9.4 3.1044 9.4H13.4044C13.6253 9.4 13.8044 9.22091 13.8044 9C13.8044 8.77909 13.6253 8.6 13.4044 8.6H3.10439Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.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.1665C15.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.1665C2.8543 13.3874 3.03338 13.5665 3.2543 13.5665H13.5543C13.7752 13.5665 13.9543 13.3874 13.9543 13.1665C13.9543 12.9456 13.7752 12.7665 13.5543 12.7665H3.2543Z",fillRule:"evenodd",clipRule:"evenodd"}}]},$e=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"topmost-icon",ref:e,icon:ot}))});$e.displayName="TopmostIcon";const ct={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},Ge=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"ungroup-icon",ref:e,icon:ct}))});Ge.displayName="UngroupIcon";const lt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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.56377Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.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.83647Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M9.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"}}]},Ve=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"autofill-double-icon",ref:e,icon:lt}))});Ve.displayName="AutofillDoubleIcon";function We(s){var m;const{popup:r}=s,e=(m=r==null?void 0:r.extraProps)==null?void 0:m.menuItems;if(!e)return null;const t=H.useDependency(f.ICommandService),n=H.useDependency(f.LocaleService),[i,a]=_.useState(!1),[o,c]=_.useState(!1),g=()=>{c(!0)},l=()=>{c(!1)},u=w=>{a(w)},d=w=>{t.executeCommand(w.commandId,w.commandParams),a(!1)},p=i||o,S=e.filter(w=>!w.disable);return h.jsx("div",{onMouseEnter:g,onMouseLeave:l,children:h.jsx(P.DropdownMenu,{align:"start",items:S.map(w=>({type:"item",children:n.t(w.label),onSelect:()=>d(w)})),open:i,onOpenChange:u,children:h.jsxs("div",{className:P.clsx("univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-800",P.borderClassName,{"univer-bg-gray-100 dark:!univer-bg-gray-800":i,"univer-bg-white dark:!univer-bg-gray-900":!i}),children:[h.jsx(Ve,{className:"univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-white"}),p&&h.jsx(Le,{className:"dark:!univer-text-white"})]})})})}var gt=Object.getOwnPropertyDescriptor,ut=(s,r,e,t)=>{for(var n=t>1?void 0:t?gt(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(n=a(n)||n);return n},je=(s,r)=>(e,t)=>r(e,t,s);let Se=class extends f.Disposable{constructor(s,r){super(),this._componentManager=s,this._commandService=r,this._init()}_initCustomComponents(){const s=this._componentManager;this.disposeWithMe(s.register(Pe,We))}_initCommands(){[ve,Q,Re,ye,de].forEach(s=>this.disposeWithMe(this._commandService.registerCommand(s)))}_init(){this._initCommands(),this._initCustomComponents()}};Se=ut([je(0,f.Inject(H.ComponentManager)),je(1,f.ICommandService)],Se);function he(s,r){const e=[];return s.forEach(t=>{const{oKey:n,left:i,top:a,height:o,width:c,angle:g}=t,l=r.getDrawingOKey(n);if(l==null)return e.push(null),!0;const{unitId:u,subUnitId:d,drawingId:p,drawingType:S}=l,m={unitId:u,subUnitId:d,drawingId:p,drawingType:S,transform:{left:i,top:a,height:o,width:c,angle:g}};S===f.DrawingTypeEnum.DRAWING_IMAGE&&(m.srcRect=t.srcRect),e.push(m)}),e}var dt=Object.getOwnPropertyDescriptor,ht=(s,r,e,t)=>{for(var n=t>1?void 0:t?dt(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(n=a(n)||n);return n},fe=(s,r)=>(e,t)=>r(e,t,s);let _e=class extends f.Disposable{constructor(r,e,t,n){super();J(this,"_sceneListenerOnDrawingMap",new WeakSet);this._currentUniverService=r,this._commandService=e,this._renderManagerService=t,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,e=Me(this._currentUniverService);if(e==null)return;const{unitId:t,subUnitId:n}=e;Object.keys(r).forEach(i=>{Object.keys(r[i]).forEach(a=>{const o=r[i][a].data;o==null||i!==t||a!==n||Object.keys(o).forEach(c=>{o[c]&&this._insertDrawing([{unitId:i,subUnitId:a,drawingId:c}])})})})}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id===ye.id){const e=r.params;if(e==null)return;this._drawingAlign(e)}}))}_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 e=this._renderManagerService.getRenderById(r),t=e==null?void 0:e.scene;if(t==null)return null;const n=t.getTransformerByCreate();return{scene:t,transformer:n}}_groupDrawings(r){r.forEach(e=>{this._groupDrawing(e)})}_groupDrawing(r){const{parent:e,children:t}=r,{unitId:n,subUnitId:i,drawingId:a}=e,o=this._getSceneAndTransformerByDrawingSearch(e.unitId);if(o==null)return;const{scene:c,transformer:g}=o;this._commandService.syncExecuteCommand(Q.id);const l=[];if(t.forEach(p=>{const S=M.getDrawingShapeKeyByDrawingSearch(p),m=c.getObjectIncludeInGroup(S);if(m==null||l.includes(m))return;l.push(m);const{transform:w}=p;w!=null&&(m.classType===y.RENDER_CLASS_TYPE.GROUP?m.transformByState({left:w.left,top:w.top}):m.transformByState(w))}),l.length===0)return;const u=M.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:i,drawingId:a}),d=new y.Group(u);c.addObject(d,y.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(d),d.addObjects(...l),e.transform&&d.transformByState({left:e.transform.left,top:e.transform.top}),g.clearSelectedObjects(),g.setSelectedControl(d)}_ungroupDrawings(r){r.forEach(e=>{this._ungroupDrawing(e)})}_ungroupDrawing(r){const{parent:e,children:t}=r,n=this._getSceneAndTransformerByDrawingSearch(e.unitId);if(n==null)return;const{scene:i,transformer:a}=n;t.forEach(u=>{const d=M.getDrawingShapeKeyByDrawingSearch(u),p=i.getObjectIncludeInGroup(d);if(p==null)return!0;if(p==null)return;const{transform:S}=u;S!=null&&(p.classType===y.RENDER_CLASS_TYPE.GROUP?p.transformByState({left:S.left,top:S.top}):p.transformByState(S))});const o=M.getDrawingShapeKeyByDrawingSearch(e),c=i.getObject(o),{width:g,height:l}=c;c.getObjects().forEach(u=>{c.removeSelfObjectAndTransform(u.oKey,g,l)}),c.dispose(),a.clearSelectedObjects()}_drawingAlign(r){const{alignType:e}=r,t=this._drawingManagerService.getFocusDrawings();if(e===T.default)return;const n=[];let i=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY,g=0;t.forEach(l=>{const{unitId:u,subUnitId:d,drawingId:p,drawingType:S}=l,m=this._drawingManagerService.getDrawingByParam({unitId:u,subUnitId:d,drawingId:p});if(m==null||m.transform==null)return;n.push({unitId:u,subUnitId:d,drawingId:p,drawingType:S,transform:m.transform});const{left:w=0,top:C=0,width:I=0,height:D=0}=m.transform;i=Math.min(i,w),a=Math.min(a,C),o=Math.max(o,w+I),c=Math.max(c,C+D),g++}),g!==0&&(this._sortDrawingTransform(n,e),this._applyAlignType(n,e,i,a,o,c,g))}_applyAlignType(r,e,t,n,i,a,o){const c=Math.round((i-t)/o*10)/10,g=Math.round((a-n)/o*10)/10,l=[],u=this._getSceneAndTransformerByDrawingSearch(r[0].unitId);if(u==null)return;const{scene:d,transformer:p}=u;r.forEach((S,m)=>{const{unitId:w,subUnitId:C,drawingId:I,transform:D,drawingType:j}=S,{left:N=0,top:b=0,width:O=0,height:R=0}=D;let E=N,x=b;switch(e){case T.left:E=t;break;case T.center:E=t+(i-t)/2-O/2;break;case T.right:E=i-O;break;case T.top:x=n;break;case T.middle:x=n+(a-n)/2-R/2;break;case T.bottom:x=a-R;break;case T.horizon:E=t+c*m;break;case T.vertical:x=n+g*m;break}(E!==N||x!==b)&&l.push({unitId:w,subUnitId:C,drawingId:I,drawingType:j,transform:{left:E,top:x}})}),this._drawingManagerService.featurePluginUpdateNotification(l),p.refreshControls().changeNotification()}_sortDrawingTransform(r,e){r.sort((t,n)=>{const i=t.transform,a=n.transform,{left:o=0,top:c=0,width:g=0,height:l=0}=i,{left:u=0,top:d=0,width:p=0,height:S=0}=a;switch(e){case T.left:return o-u;case T.center:return o+g/2-(u+p/2);case T.right:return o+g-(u+p);case T.top:return c-d;case T.middle:return c+l/2-(d+S/2);case T.bottom:return c+l-(d+S);case T.horizon:return o+g/2-(u+p/2);case T.vertical:return c+l/2-(d+S/2);default:return 0}})}_drawingArrangeListener(){this.disposeWithMe(this._drawingManagerService.order$.subscribe(r=>{this._drawingArrange(r)}))}_drawingArrange(r){const{unitId:e,subUnitId:t,drawingIds:n}=r,i=this._getSceneAndTransformerByDrawingSearch(e);if(i==null)return;const{scene:a}=i;n.forEach(o=>{const c=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:t,drawingId:o}),g=a.fuzzyMathObjects(c,!0);if(g==null||g.length===0)return;const l=this._drawingManagerService.getDrawingOrder(e,t).indexOf(o);for(const u of g)u.setProps({zIndex:l}),u.makeDirty()})}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(r=>{this._insertDrawing(r)}))}_insertDrawing(r){const e=[];r.forEach(t=>{const{unitId:n}=t;if(this._drawingManagerService.getDrawingByParam(t)==null)return;const a=this._getSceneAndTransformerByDrawingSearch(n);if(a==null)return;const{scene:o}=a;e.includes(o)||e.push(o)}),e.forEach(t=>{this._sceneListenerOnDrawingMap.has(t)||(this._addListenerOnDrawing(t),this._sceneListenerOnDrawingMap.add(t))})}_drawingRemoveListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(r=>{r.forEach(e=>{var l;const{unitId:t,subUnitId:n,drawingId:i}=e,a=this._getSceneAndTransformerByDrawingSearch(t);if(a==null)return;const{scene:o}=a,c=M.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:n,drawingId:i}),g=o.fuzzyMathObjects(c,!0);if(g.length>0){for(const u of g)u.dispose();(l=o.getTransformer())==null||l.clearSelectedObjects()}})}))}_drawingUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(r=>{r.forEach(e=>{var O;const{unitId:t,subUnitId:n,drawingId:i}=e,a=this._drawingManagerService.getDrawingByParam(e);if(a==null)return;const{transform:o,drawingType:c}=a,g=this._getSceneAndTransformerByDrawingSearch(t);if(g==null)return;const{scene:l,transformer:u}=g;if(o==null)return!0;const{left:d=0,top:p=0,width:S=0,height:m=0,angle:w=0,flipX:C=!1,flipY:I=!1,skewX:D=0,skewY:j=0}=o,N=M.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:n,drawingId:i}),b=l.getObject(N);if(b==null)return!0;b.transformByState({left:d,top:p,width:S,height:m,angle:w,flipX:C,flipY:I,skewX:D,skewY:j}),(O=l.getTransformer())==null||O.debounceRefreshControls()})}))}_drawingRefreshListener(){this.disposeWithMe(this._drawingManagerService.refreshTransform$.subscribe(r=>{r.forEach(e=>{const{unitId:t,subUnitId:n,drawingId:i}=e,a=this._getSceneAndTransformerByDrawingSearch(t);if(a==null)return;const o=this._drawingManagerService.getDrawingByParam(e);if(o==null)return;const{transform:c}=o,{scene:g}=a,l=M.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:n,drawingId:i}),u=g.getObject(l);if(u==null||c==null)return!0;const{left:d=0,top:p=0,width:S=0,height:m=0,angle:w=0,flipX:C=!1,flipY:I=!1,skewX:D=0,skewY:j=0}=c;u.transformByState({left:d,top:p,width:S,height:m,angle:w,flipX:C,flipY:I,skewX:D,skewY:j})})}))}_drawingVisibleListener(){this.disposeWithMe(this._drawingManagerService.visible$.subscribe(r=>{r.forEach(e=>{const{unitId:t,subUnitId:n,drawingId:i,visible:a}=e,o=this._getSceneAndTransformerByDrawingSearch(t);if(o==null)return;const{scene:c}=o,g=M.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:n,drawingId:i}),l=c.getObject(g);if(l==null)return!0;a?l.show():l.hide()})}))}_filterUpdateParams(r,e){return r.filter((t,n)=>{if(t==null)return!1;const{transform:i}=t;return f.checkIfMove(i,e==null?void 0:e[n])})}_addListenerOnDrawing(r){const e=r.getTransformerByCreate();let t=null;this.disposeWithMe(f.toDisposable(e.changeStart$.subscribe(n=>{const{objects:i}=n,a=Array.from(i.values()),o=[];t=a.map(c=>{const{left:g,top:l,height:u,width:d,angle:p,oKey:S,isInGroup:m}=c,w=this._drawingManagerService.getDrawingOKey(S);if(m||c instanceof y.Group){let C=c.ancestorGroup;if(C==null&&c instanceof y.Group&&(C=c),C==null)return null;const I=this._drawingManagerService.getDrawingOKey(C.oKey);if(I){const{unitId:D,subUnitId:j,drawingId:N}=I;o.push({unitId:D,subUnitId:j,drawingId:N});const{left:b,top:O,height:R,width:E,angle:x}=C;return{left:b,top:O,height:R,width:E,angle:x}}}else if(w!=null){const{unitId:C,subUnitId:I,drawingId:D}=w;return o.push({unitId:C,subUnitId:I,drawingId:D}),{left:g,top:l,height:u,width:d,angle:p}}return null}).filter(c=>c!=null),o.length>0?this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,o):this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,[])}))),this.disposeWithMe(f.toDisposable(e.changeEnd$.subscribe(n=>{const{objects:i}=n,a=this._filterUpdateParams(he(i,this._drawingManagerService),t);a.length>0&&this._drawingManagerService.featurePluginUpdateNotification(a)})))}};_e=ht([fe(0,f.IUniverInstanceService),fe(1,f.ICommandService),fe(2,y.IRenderManagerService),fe(3,M.IDrawingManagerService)],_e);class ue extends y.Shape{constructor(e,t){t==null&&(t={}),t.transformerConfig={keepRatio:!1,isCropper:!0,anchorFill:"rgb(0, 0, 0)",anchorStroke:"rgb(255, 255, 255)",anchorSize:24};super(e,t);J(this,"_srcRect");J(this,"_prstGeom");J(this,"_applyTransform");J(this,"_dragPadding",8);J(this,"_cacheCanvas");t!=null&&t.srcRect&&(this._srcRect=t.srcRect),t!=null&&t.prstGeom&&(this._prstGeom=t.prstGeom),t!=null&&t.applyTransform&&(this._applyTransform=t.applyTransform),t!=null&&t.dragPadding&&(this._dragPadding=t.dragPadding),this._applyProps()}refreshSrcRect(e,t){this._srcRect=e,this._applyTransform=t,this._applyProps()}get srcRect(){return this._srcRect}dispose(){var e;super.dispose(),(e=this._cacheCanvas)==null||e.dispose(),this._srcRect=null}isHit(e){const t=this.getInverseCoord(e);return t.x>=-this.strokeWidth/2&&t.x<=this.width+this.strokeWidth/2&&t.y>=-this.strokeWidth/2&&t.y<=this.height+this.strokeWidth/2&&!this._inSurround(t)}_inSurround(e){const t=this._dragPadding;return e.x>=t-this.strokeWidth/2&&e.x<=this.width+this.strokeWidth/2-t&&e.y>=t-this.strokeWidth/2&&e.y<=this.height+this.strokeWidth/2-t}render(e,t){return this.visible?(e.save(),this._draw(e),e.restore(),this.makeDirty(!1),this):(this.makeDirty(!1),this)}_draw(e){var c,g;const n=this.getScene().getEngine(),{width:i,height:a}=n;this._initialCacheCanvas(),(c=this._cacheCanvas)==null||c.clear();const o=(g=this._cacheCanvas)==null?void 0:g.getContext();o!=null&&(o.save(),y.Rect.drawWith(o,{left:0,top:0,width:i,height:a,fill:"rgba(0, 0, 0, 0.5)"}),o.setTransform(e.getTransform()),this._clipForApplyObject(o),this._applyCache(e),o.restore())}_clipForApplyObject(e){let t=0;if(this._prstGeom!=null&&(t=1),e.globalCompositeOperation="destination-out",e.beginPath(),t===0){const n=this.transform.getMatrix();e.transform(n[0],n[1],n[2],n[3],n[4],n[5]),e.rect(0,0,this.width,this.height),e.fill()}}_applyProps(){if(this._applyTransform==null)return;let e=0,t=0,n=0,i=0;const{left:a=0,top:o=0,width:c=0,height:g=0,angle:l}=this._applyTransform;if(this._srcRect!=null){const{left:p=0,top:S=0,right:m=0,bottom:w=0}=this._srcRect;e=p,t=S,n=m,i=w}const u=a+e,d=o+t;this.transformByState({left:u,top:d,width:a+c-n-u,height:o+g-i-d,angle:l})}_applyCache(e){if(!e||this._cacheCanvas==null)return;const t=this._cacheCanvas.getContext();t.save(),e.save(),e.setTransform(1,0,0,1,0,0),t.setTransform(1,0,0,1,0,0),e.drawImage(this._cacheCanvas.getCanvasEle(),0,0),e.restore(),t.restore()}_initialCacheCanvas(){if(this._cacheCanvas!=null)return;const e=this.getScene();if(e==null)return;this._cacheCanvas=new y.Canvas;const t=e.getEngine();this._cacheCanvas.setSize(t.width,t.height),t.onTransformChange$.subscribeEvent(()=>{var n;(n=this._cacheCanvas)==null||n.setSize(t.width,t.height),this.makeDirty(!0)})}}var ft=Object.getOwnPropertyDescriptor,pt=(s,r,e,t)=>{for(var n=t>1?void 0:t?ft(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(n=a(n)||n);return n},se=(s,r)=>(e,t)=>r(e,t,s);let Ce=class extends f.Disposable{constructor(r,e,t,n,i,a){super();J(this,"_sceneListenerOnImageMap",new WeakSet);this._commandService=r,this._drawingManagerService=e,this._renderManagerService=t,this._univerInstanceService=n,this._messageService=i,this._localeService=a,this._init()}_init(){this._initOpenCrop(),this._initCloseCrop(),this._initAutoCrop()}_initAutoCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id!==de.id)return;const e=r.params;if(e==null)return;const{cropType:t}=e,n=this._drawingManagerService.getFocusDrawings();if(n.length!==1)return;const i=n[0],{unitId:a,subUnitId:o,drawingId:c}=i,g=this._renderManagerService.getRenderById(a),l=g==null?void 0:g.scene;if(l==null)return!0;this._searchCropObject(l)!=null&&this._commandService.syncExecuteCommand(Q.id,{isAuto:!0});const d=M.getDrawingShapeKeyByDrawingSearch({unitId:a,subUnitId:o,drawingId:c}),p=l.getObject(d);if(!(p instanceof y.Image)){this._messageService.show({type:P.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}p!=null&&(this._updateCropperObject(t,p),this._commandService.executeCommand(ve.id,{unitId:a,subUnitId:o,drawingId:c}))}))}_calculateSrcRectByRatio(r,e,t,n,i,a){const o=t/n,c=i/a;let g=t,l=n;o>c?g=n*c:l=t/c;const u=(t-g)/2,d=(n-l)/2;return{left:y.precisionTo(u,1),top:y.precisionTo(d,1),right:y.precisionTo(t-(u+g),1),bottom:y.precisionTo(n-(d+l),1)}}_updateCropperObject(r,e){const{left:t,top:n,width:i,height:a}=e.calculateTransformWithSrcRect();let o;switch(r){case U.R1_1:o=this._calculateSrcRectByRatio(t,n,i,a,1,1);break;case U.R16_9:o=this._calculateSrcRectByRatio(t,n,i,a,16,9);break;case U.R9_16:o=this._calculateSrcRectByRatio(t,n,i,a,9,16);break;case U.R5_4:o=this._calculateSrcRectByRatio(t,n,i,a,5,4);break;case U.R4_5:o=this._calculateSrcRectByRatio(t,n,i,a,4,5);break;case U.R4_3:o=this._calculateSrcRectByRatio(t,n,i,a,4,3);break;case U.R3_4:o=this._calculateSrcRectByRatio(t,n,i,a,3,4);break;case U.R3_2:o=this._calculateSrcRectByRatio(t,n,i,a,3,2);break;case U.R2_3:o=this._calculateSrcRectByRatio(t,n,i,a,2,3);break;case U.FREE:}if(o==null)return;e.setSrcRect(o);const{left:c=0,top:g=0,bottom:l=0,right:u=0}=o;e.transformByStateCloseCropper({left:t+c,top:n+g,width:i-u-c,height:a-l-g})}_initOpenCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id!==ve.id)return;const e=r.params;if(e==null)return;const{unitId:t,subUnitId:n,drawingId:i}=e,a=this._renderManagerService.getRenderById(t),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:t,subUnitId:n,drawingId:i})==null)return;const g=M.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:n,drawingId:i}),l=o.getObject(g);if(l==null)return;if(!(l instanceof y.Image)){this._messageService.show({type:P.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}const u=o.getTransformer();u==null||u.clearControls();const d=new ue(`${g}-crop`,{srcRect:l.srcRect,prstGeom:l.prstGeom,applyTransform:l.calculateTransformWithSrcRect()});o.addObject(d,l.getLayerIndex()+1).attachTransformerTo(d),u==null||u.createControlForCopper(d),this._addHoverForImageCopper(d),l.openRenderByCropper(),u==null||u.refreshControls(),d.makeDirty(!0),this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,[{unitId:t,subUnitId:n,drawingId:i}])}))}_searchCropObject(r){const e=r.getAllObjectsByOrder();for(const t of e)if(t instanceof ue)return t}_initCloseCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==Q.id)return;const t=this._univerInstanceService.getFocusedUnit();if(t==null)return;const n=t.getUnitId(),i=this._renderManagerService.getRenderById(n),a=i==null?void 0:i.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 g=a.getTransformerByCreate();g.detachFrom(o),g.clearCopperControl();const l=this._getSrcRectByTransformState(c,o),u=this._drawingManagerService.getDrawingOKey(c.oKey);if(u!=null){const{left:d,top:p,height:S,width:m}=o;this._drawingManagerService.featurePluginUpdateNotification([{...u,transform:{...u.transform,left:d,top:p,height:S,width:m},srcRect:l.srcRectAngle}])}c.setSrcRect({...l.srcRectAngle}),c.closeRenderByCropper(),c.makeDirty(!0),o==null||o.dispose()}));const r=this._univerInstanceService.getCurrentTypeOfUnit$(f.UniverInstanceType.UNIVER_SHEET).pipe(ie.switchMap(e=>e?e.activeSheet$:ie.of(null)));this.disposeWithMe(r.subscribe(()=>{this._commandService.syncExecuteCommand(Q.id)}))}_getApplyObjectByCropObject(r){const e=r.oKey,t=e.slice(0,e.length-5),n=r.getScene();if(!n)return null;const i=n.getObject(t);return i==null?null:i}_addListenerOnImage(r){const e=r.getTransformerByCreate();let t=null;this.disposeWithMe(e.changeStart$.subscribe(n=>{const{objects:i}=n,a=i.values().next().value;if(a==null||!(a instanceof ue))return;const{left:o,top:c,height:g,width:l,angle:u}=a;t={left:o,top:c,height:g,width:l,angle:u},e.clearCopperControl()})),this.disposeWithMe(e.changeEnd$.subscribe(n=>{const{objects:i}=n,a=i.values().next().value;if(a==null||!(a instanceof ue))return;const{left:o,top:c,height:g,width:l,angle:u}=a;if(!f.checkIfMove({left:o,top:c,height:g,width:l,angle:u},t))return;const d=this._getApplyObjectByCropObject(a);if(d==null)return;const p=this._getSrcRectByTransformState(d,a);a.refreshSrcRect(p.srcRect,d.getState()),e.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 e=r.getTransformerByCreate();this.disposeWithMe(e.clearControl$.subscribe(t=>{t===!0&&this._commandService.syncExecuteCommand(Q.id)}))}_getSrcRectByTransformState(r,e){const{left:t,top:n,height:i,width:a,strokeWidth:o,angle:c}=e,{left:g,top:l,width:u,height:d,angle:p,strokeWidth:S}=r,m=t-g,w=n-l,C={left:m,top:w,right:u-m-a,bottom:d-w-i},I={...C};if(p!==0){const D=t+a/2,j=n+i/2,N=new y.Vector2(D,j),b=u/2+g,O=d/2+l,R=new y.Vector2(b,O),E=new y.Vector2(g,l);E.rotateByPoint(y.degToRad(p),R);const x=E.clone();x.rotateByPoint(y.degToRad(-p),N);const k=t-x.x,A=n-x.y;I.left=k,I.top=A,I.right=u-k-a,I.bottom=d-A-i}return{srcRect:C,srcRectAngle:I}}};Ce=pt([se(0,f.ICommandService),se(1,M.IDrawingManagerService),se(2,y.IRenderManagerService),se(3,f.IUniverInstanceService),se(4,H.IMessageService),se(5,f.Inject(f.LocaleService))],Ce);var mt=Object.getOwnPropertyDescriptor,wt=(s,r,e,t)=>{for(var n=t>1?void 0:t?mt(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(n=a(n)||n);return n},ge=(s,r)=>(e,t)=>r(e,t,s);exports.DrawingRenderService=class{constructor(r,e,t,n,i){this._drawingManagerService=r,this._imageIoService=e,this._galleryService=t,this._urlImageService=n,this._univerInstanceService=i}async renderImages(r,e){const{transform:t,drawingType:n,source:i,imageSourceType:a,srcRect:o,prstGeom:c,groupId:g,unitId:l,subUnitId:u,drawingId:d,isMultiTransform:p,transforms:S}=r;if(n!==f.DrawingTypeEnum.DRAWING_IMAGE||!this._drawingManagerService.getDrawingVisible()||t==null)return;const m=p&&S?S:[t],w=[];for(const C of m){const{left:I,top:D,width:j,height:N,angle:b,flipX:O,flipY:R,skewX:E,skewY:x}=C,k=m.indexOf(C),A=M.getDrawingShapeKeyByDrawingSearch({unitId:l,subUnitId:u,drawingId:d},p?k:void 0),G=e.getObject(A);if(G!=null){G.transformByState({left:I,top:D,width:j,height:N,angle:b,flipX:O,flipY:R,skewX:E,skewY:x});continue}if(!this._drawingManagerService.getDrawingVisible()||u!==this._getActiveSheetId())continue;const z=this._drawingManagerService.getDrawingOrder(l,u),ae=z.indexOf(d),Y={...C,zIndex:ae===-1?z.length-1:ae},ee=this._imageIoService.getImageSourceCache(i,a);let te=!1;if(ee!=null)Y.image=ee;else if(a===M.ImageSourceType.UUID)try{Y.url=await this._imageIoService.getImage(i)}catch(oe){console.error(oe);continue}else if(a===M.ImageSourceType.URL){try{Y.url=await this._urlImageService.getImage(i)}catch(oe){console.error(oe),Y.url=i}te=!0}else Y.url=i,te=!0;if(e.getObject(A))continue;Y.printable=!0;const X=new y.Image(A,Y);te&&this._imageIoService.addImageSourceCache(i,a,X.getNative()),e.addObject(X,y.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&e.attachTransformerTo(X),g&&De({drawingId:g,unitId:l,subUnitId:u},X,e,this._drawingManagerService),c!=null&&X.setPrstGeom(c),o!=null&&X.setSrcRect(o),w.push(X)}return w}_getActiveSheetId(){var r,e;return(e=(r=this._univerInstanceService.getCurrentUnitOfType(f.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getActiveSheet())==null?void 0:e.getSheetId()}renderFloatDom(r,e){const{transform:t,drawingType:n,groupId:i,unitId:a,subUnitId:o,drawingId:c,isMultiTransform:g,transforms:l}=r;if(n!==f.DrawingTypeEnum.DRAWING_DOM||!this._drawingManagerService.getDrawingVisible()||t==null)return;const u=g&&l?l:[t],d=[];for(const p of u){const{left:S,top:m,width:w,height:C,angle:I,flipX:D,flipY:j,skewX:N,skewY:b}=p,O=u.indexOf(p),R=M.getDrawingShapeKeyByDrawingSearch({unitId:a,subUnitId:o,drawingId:c},g?O:void 0),E=e.getObject(R);if(E!=null){E.transformByState({left:S,top:m,width:w,height:C,angle:I,flipX:D,flipY:j,skewX:N,skewY:b});continue}const x=this._drawingManagerService.getDrawingOrder(a,o),k=x.indexOf(c),A={...p,zIndex:k===-1?x.length-1:k};if(e.getObject(R))continue;A.printable=!1;const G=new y.Rect(R,A);this._drawingManagerService.getDrawingVisible()&&(e.addObject(G,y.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&r.allowTransform!==!1&&e.attachTransformerTo(G),i&&De({drawingId:i,unitId:a,subUnitId:o},G,e,this._drawingManagerService),d.push(G))}return d}renderDrawing(r,e){const t=this._drawingManagerService.getDrawingByParam(r);if(t!=null&&t.drawingType===f.DrawingTypeEnum.DRAWING_IMAGE)return this.renderImages(t,e)}previewImage(r,e,t,n){this._galleryService.open({images:[e],onOpenChange:i=>{i||this._galleryService.close()}})}_adjustImageSize(r,e,t,n){if(r<=t&&e<=n)return{width:r,height:e};const i=t/r,a=n/e,o=Math.min(i,a);return{width:Math.floor(r*o),height:Math.floor(e*o)}}};exports.DrawingRenderService=wt([ge(0,M.IDrawingManagerService),ge(1,M.IImageIoService),ge(2,H.IGalleryService),ge(3,f.IURLImageService),ge(4,f.IUniverInstanceService)],exports.DrawingRenderService);var vt=Object.getOwnPropertyDescriptor,St=(s,r,e,t)=>{for(var n=t>1?void 0:t?vt(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(n=a(n)||n);return n},ne=(s,r)=>(e,t)=>r(e,t,s);let Ie=class extends f.Disposable{constructor(s,r,e,t,n,i,a){super(),this._commandService=s,this._renderManagerService=r,this._drawingManagerService=e,this._dialogService=t,this._imageIoService=n,this._currentUniverService=i,this._drawingRenderService=a,this._initialize()}dispose(){super.dispose()}_initialize(){this._drawingAddListener(),this._commandExecutedListener(),this._imageUpdateListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(s=>{if(s.id===Re.id){const r=s.params;if(r==null)return;this._resetImageSize(r)}}))}_getSceneAndTransformerByDrawingSearch(s){if(s==null)return;const r=this._renderManagerService.getRenderById(s),e=r==null?void 0:r.scene;if(e==null)return null;const t=e.getTransformerByCreate();return{scene:e,transformer:t}}_resetImageSize(s){const r=[],e=[];s.forEach(t=>{const{unitId:n,subUnitId:i,drawingId:a}=t,o=this._getSceneAndTransformerByDrawingSearch(n);if(o==null)return;const{scene:c}=o,g=M.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:i,drawingId:a}),l=c.getObject(g);if(l==null)return!0;const u=this._drawingManagerService.getDrawingByParam(t);if(u==null)return!0;if(u.drawingType!==f.DrawingTypeEnum.DRAWING_IMAGE)return;l.resetSize();const{width:d,height:p}=l.getNativeSize();e.includes(c)===!1&&e.push(c),r.push({...u,transform:{...u.transform,height:p,width:d,angle:0},srcRect:null,prstGeom:null})}),this._drawingManagerService.featurePluginUpdateNotification(r),e.forEach(t=>{t.getTransformerByCreate().refreshControls().changeNotification()}),this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,s)}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.pipe(ie.bufferTime(33),ie.filter(s=>s.length>0),ie.map(s=>s.flat()),ie.map(s=>{const r=new Map;for(const e of s)r.set(`${e.unitId}|${e.subUnitId}|${e.drawingId}`,e);return[...r.values()]}),ie.filter(s=>s.length>0)).subscribe(s=>{this._insertImages(s)}))}_insertImages(s){s.forEach(async r=>{var c;const{unitId:e,subUnitId:t}=r,n=this._getSceneAndTransformerByDrawingSearch(e),i=(c=Me(this._currentUniverService,e))==null?void 0:c.subUnitId;if(n==null||i!==t)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 g of o)this._addHoverForImage(g),this._addDialogForImage(g)})}_imageUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(s=>{s.forEach(r=>{const{unitId:e,subUnitId:t,drawingId:n}=r,i=this._drawingManagerService.getDrawingByParam(r);if(i==null)return;const{transform:a,drawingType:o,srcRect:c,prstGeom:g,source:l,imageSourceType:u}=i;if(o!==f.DrawingTypeEnum.DRAWING_IMAGE)return;const d=this._getSceneAndTransformerByDrawingSearch(e);if(d==null)return;const{scene:p,transformer:S}=d;if(a==null)return!0;const m=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:t,drawingId:n}),w=p.getObject(m);if(w==null)return!0;w.setSrcRect(c),w.setPrstGeom(g),l!=null&&l.length>0&&(u===f.ImageSourceType.BASE64||u===f.ImageSourceType.URL)&&w.changeSource(l)})}))}_addHoverForImage(s){this.disposeWithMe(f.toDisposable(s.onPointerEnter$.subscribeEvent(()=>{s.cursor=y.CURSOR_TYPE.GRAB}))),this.disposeWithMe(f.toDisposable(s.onPointerLeave$.subscribeEvent(()=>{s.cursor=y.CURSOR_TYPE.DEFAULT})))}_addDialogForImage(s){this.disposeWithMe(f.toDisposable(s.onDblclick$.subscribeEvent(()=>{const r=`${s.oKey}-viewer-dialog`;this._drawingRenderService.previewImage(r,s.getNative().src,s.getNativeSize().width,s.getNativeSize().height)})))}};Ie=St([ne(0,f.ICommandService),ne(1,y.IRenderManagerService),ne(2,M.IDrawingManagerService),ne(3,H.IDialogService),ne(4,M.IImageIoService),ne(5,f.IUniverInstanceService),ne(6,f.Inject(exports.DrawingRenderService))],Ie);var _t=Object.getOwnPropertyDescriptor,Ct=(s,r,e,t)=>{for(var n=t>1?void 0:t?_t(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(n=a(n)||n);return n},Ee=(s,r)=>(e,t)=>r(e,t,s);const It="UNIVER_DRAWING_UI_PLUGIN";var be;exports.UniverDrawingUIPlugin=(be=class extends f.Plugin{constructor(r=xe,e,t){super(),this._config=r,this._injector=e,this._configService=t;const{menu:n,...i}=f.merge({},xe,this._config);n&&this._configService.setConfig("menu",n,{merge:!0}),this._configService.setConfig(qe,i)}onStarting(){this._initDependencies()}onRendered(){this._injector.get(_e),this._injector.get(Se),this._injector.get(Ce),this._injector.get(Ie)}_initDependencies(){[[exports.DrawingRenderService],[_e],[Se],[Ce],[Ie]].forEach(e=>this._injector.add(e))}},J(be,"pluginName",It),be);exports.UniverDrawingUIPlugin=Ct([Ee(1,f.Inject(f.Injector)),Ee(2,f.IConfigService)],exports.UniverDrawingUIPlugin);const yt=s=>{const r=H.useDependency(f.ICommandService),e=H.useDependency(f.LocaleService),{alignShow:t}=s,[n,i]=_.useState(T.default),a=[{label:e.t("image-panel.align.default"),value:T.default},{options:[{label:e.t("image-panel.align.left"),value:T.left},{label:e.t("image-panel.align.center"),value:T.center},{label:e.t("image-panel.align.right"),value:T.right}]},{options:[{label:e.t("image-panel.align.top"),value:T.top},{label:e.t("image-panel.align.middle"),value:T.middle},{label:e.t("image-panel.align.bottom"),value:T.bottom}]},{options:[{label:e.t("image-panel.align.horizon"),value:T.horizon},{label:e.t("image-panel.align.vertical"),value:T.vertical}]}];function o(c){i(c),r.executeCommand(ye.id,{alignType:c})}return h.jsxs("div",{className:P.clsx("univer-relative univer-w-full",{"univer-hidden":!t}),children:[h.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:h.jsx("div",{children:e.t("image-panel.align.title")})}),h.jsx("div",{className:"univer-relative univer-mt-2.5 univer-flex univer-h-full",children:h.jsx("div",{className:"univer-w-full univer-text-gray-900 dark:!univer-text-white",children:h.jsx(P.Select,{value:n,options:a,onChange:o})})})]})},bt=s=>{const{arrangeShow:r,drawings:e}=s,t=H.useDependency(f.LocaleService),n=H.useDependency(M.IDrawingManagerService),[i,a]=_.useState(e);_.useEffect(()=>{const c=n.focus$.subscribe(g=>{a(g)});return()=>{c.unsubscribe()}},[]);const o=c=>{const g=i[0].unitId,l=i[0].subUnitId,u=i.map(d=>d.drawingId);n.featurePluginOrderUpdateNotification({unitId:g,subUnitId:l,drawingIds:u,arrangeType:c})};return h.jsxs("div",{className:P.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!r}),children:[h.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:h.jsx("div",{children:t.t("image-panel.arrange.title")})}),h.jsxs("div",{className:"univer-grid univer-grid-cols-2 univer-gap-2",children:[h.jsxs(P.Button,{onClick:()=>{o(f.ArrangeTypeEnum.forward)},children:[h.jsx(ke,{}),t.t("image-panel.arrange.forward")]}),h.jsxs(P.Button,{onClick:()=>{o(f.ArrangeTypeEnum.backward)},children:[h.jsx(He,{}),t.t("image-panel.arrange.backward")]}),h.jsxs(P.Button,{onClick:()=>{o(f.ArrangeTypeEnum.front)},children:[h.jsx($e,{}),t.t("image-panel.arrange.front")]}),h.jsxs(P.Button,{onClick:()=>{o(f.ArrangeTypeEnum.back)},children:[h.jsx(Be,{}),t.t("image-panel.arrange.back")]})]})]})},Dt=s=>{const r=H.useDependency(f.LocaleService),e=H.useDependency(y.IRenderManagerService),t=H.useDependency(M.IDrawingManagerService),{hasGroup:n,drawings:i}=s,[a,o]=_.useState(!1),[c,g]=_.useState(!0),[l,u]=_.useState(!0),d=()=>{const m=t.getFocusDrawings(),{unitId:w,subUnitId:C}=m[0],I=f.generateRandomId(10),D=y.getGroupState(0,0,m.map(b=>b.transform||{})),j={unitId:w,subUnitId:C,drawingId:I,drawingType:f.DrawingTypeEnum.DRAWING_GROUP,transform:D},N=m.map(b=>{const O=b.transform||{left:0,top:0},{unitId:R,subUnitId:E,drawingId:x}=b;return{unitId:R,subUnitId:E,drawingId:x,transform:{...O,left:O.left-D.left,top:O.top-D.top},groupId:I}});t.featurePluginGroupUpdateNotification([{parent:j,children:N}])},p=m=>{if(m.drawingType!==f.DrawingTypeEnum.DRAWING_GROUP)return;const{unitId:w,subUnitId:C,drawingId:I,transform:D={width:0,height:0}}=m;if(D==null)return;const j=t.getDrawingsByGroup({unitId:w,subUnitId:C,drawingId:I});if(j.length===0)return;const N=j.map(b=>{const{transform:O}=b,{unitId:R,subUnitId:E,drawingId:x}=b,k=y.transformObjectOutOfGroup(O||{},D,D.width||0,D.height||0);return{unitId:R,subUnitId:E,drawingId:x,transform:{...O,...k},groupId:void 0}});return{parent:m,children:N}},S=()=>{const w=t.getFocusDrawings().map(C=>p(C)).filter(C=>C!=null);w.length!==0&&t.featurePluginUngroupUpdateNotification(w)};return _.useEffect(()=>{const m=i[0];if(m==null)return;const{unitId:w}=m,C=e.getRenderById(w),I=C==null?void 0:C.scene;if(I==null)return;const D=I.getTransformerByCreate(),j=D.clearControl$.subscribe(b=>{b===!0&&o(!1)}),N=D.changeStart$.subscribe(b=>{const{objects:O}=b,R=he(O,t),E=R.filter(G=>(G==null?void 0:G.drawingType)===f.DrawingTypeEnum.DRAWING_GROUP);let x=!1,k=!1;R.length>1&&(x=!0),E.length>0&&(k=!0),o(x||k),g(x),u(k)});return()=>{N.unsubscribe(),j.unsubscribe()}},[]),h.jsxs("div",{className:P.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":n===!0&&a===!1||n===!1}),children:[h.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:h.jsx("div",{children:r.t("image-panel.group.title")})}),h.jsxs("div",{className:"univer-flex univer-items-center univer-justify-center univer-gap-2",children:[h.jsxs(P.Button,{className:P.clsx({"univer-hidden":!c}),onClick:d,children:[h.jsx(Ae,{}),r.t("image-panel.group.group")]}),h.jsxs(P.Button,{className:P.clsx({"univer-hidden":!l}),onClick:S,children:[h.jsx(Ge,{}),r.t("image-panel.group.unGroup")]})]})]})},pe=20,me=20,Te=[-360,360],we=300,Rt=s=>{var Oe;const r=H.useDependency(f.LocaleService),e=H.useDependency(M.IDrawingManagerService),t=H.useDependency(y.IRenderManagerService),{drawings:n,transformShow:i}=s,a=n[0];if(a==null)return;const o=a.transform;if(o==null)return;const{unitId:c,subUnitId:g,drawingId:l,drawingType:u}=a,d=t.getRenderById(c),p=d==null?void 0:d.scene;if(p==null)return;const S=(Oe=p.getEngine())==null?void 0:Oe.activeScene;if(S==null)return;const m=p.getTransformerByCreate(),{width:w=0,height:C=0,left:I=0,top:D=0,angle:j=0}=o,[N,b]=_.useState(w),[O,R]=_.useState(C),[E,x]=_.useState(I),[k,A]=_.useState(D),[G,z]=_.useState(j),[ae,Y]=_.useState(m.keepRatio),ee=(v,B,$,V)=>{const{width:L,height:q}=S,{ancestorLeft:W,ancestorTop:K}=p;let Z=v,re=B,ce=$,le=V;return v+W<0&&(Z=-W),B+K<0&&(re=-K),ce=L-Z-W,ce<pe&&(ce=pe),le=q-re-K,le<me&&(le=me),v+ce+W>L&&(Z=L-$-W),B+le+K>q&&(re=q-V-K),{limitLeft:Z,limitTop:re,limitWidth:ce,limitHeight:le}},te=v=>{const{objects:B}=v,$=he(B,e);if($.length!==1)return;const V=$[0];if(V==null)return;const{transform:L}=V;if(L==null)return;const{width:q,height:W,left:K,top:Z,angle:re}=L;q!=null&&b(q),W!=null&&R(W),K!=null&&x(K),Z!=null&&A(Z),re!=null&&z(re)};_.useEffect(()=>{const v=[m.changeStart$.subscribe(B=>{te(B)}),m.changing$.subscribe(B=>{te(B)}),m.changeEnd$.subscribe(B=>{te(B)}),e.focus$.subscribe(B=>{if(B.length!==1)return;const $=e.getDrawingByParam(B[0]);if($==null)return;const V=$.transform;if(V==null)return;const{width:L,height:q,left:W,top:K,angle:Z}=V;L!=null&&b(L),q!=null&&R(q),W!=null&&x(W),K!=null&&A(K),Z!=null&&z(Z)})];return()=>{v.forEach(B=>B.unsubscribe())}},[]);const X=f.debounce(v=>{if(v==null)return;const{limitWidth:B,limitHeight:$}=ee(E,k,v,O);v=Math.min(v,B);const V={unitId:c,subUnitId:g,drawingId:l,drawingType:u,transform:{width:v}};if(ae){let L=v/N*O;if(L=Math.max(L,me),L>$)return;R(L),V.transform.height=L}b(v),e.featurePluginUpdateNotification([V]),m.refreshControls().changeNotification()},we),oe=f.debounce(v=>{if(v==null)return;const{limitHeight:B,limitWidth:$}=ee(E,k,N,v);v=Math.min(v,B);const V={unitId:c,subUnitId:g,drawingId:l,drawingType:u,transform:{height:v}};if(ae){let L=v/O*N;if(L=Math.max(L,pe),L>$)return;b(L),V.transform.width=L}R(v),e.featurePluginUpdateNotification([V]),m.refreshControls().changeNotification()},we),Ke=f.debounce(v=>{if(v==null)return;const{limitLeft:B}=ee(v,k,N,O);v=B;const $={unitId:c,subUnitId:g,drawingId:l,drawingType:u,transform:{left:v}};x(v),e.featurePluginUpdateNotification([$]),m.refreshControls().changeNotification()},we),Ze=f.debounce(v=>{if(v==null)return;const{limitTop:B}=ee(E,v,N,O);v=B;const $={unitId:c,subUnitId:g,drawingId:l,drawingType:u,transform:{top:v}};A(v),e.featurePluginUpdateNotification([$]),m.refreshControls().changeNotification()},we),Fe=v=>{if(v==null)return;const B={unitId:c,subUnitId:g,drawingId:l,drawingType:u,transform:{angle:v}};z(v),e.featurePluginUpdateNotification([B]),m.refreshControls().changeNotification()},ze=v=>{Y(v),m.keepRatio=v};return h.jsxs("div",{className:P.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!i}),children:[h.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:h.jsx("div",{children:r.t("image-panel.transform.title")})}),h.jsxs("div",{className:"univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2",children:[h.jsxs("div",{children:[h.jsx("span",{children:r.t("image-panel.transform.width")}),h.jsx(P.InputNumber,{precision:1,value:N,min:pe,onChange:v=>{X(v)}})]}),h.jsxs("div",{children:[h.jsx("span",{children:r.t("image-panel.transform.height")}),h.jsx(P.InputNumber,{precision:1,value:O,min:me,onChange:v=>{oe(v)}})]}),h.jsxs("div",{children:[h.jsx("span",{children:r.t("image-panel.transform.lock")}),h.jsx("div",{className:"univer-text-center",children:h.jsx(P.Checkbox,{checked:ae,onChange:ze})})]})]}),h.jsxs("div",{className:"univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2",children:[h.jsxs("div",{children:[h.jsx("span",{children:r.t("image-panel.transform.x")}),h.jsx(P.InputNumber,{precision:1,value:E,onChange:v=>{Ke(v)}})]}),h.jsxs("div",{children:[h.jsx("span",{children:r.t("image-panel.transform.y")}),h.jsx(P.InputNumber,{precision:1,value:k,onChange:v=>{Ze(v)}})]}),h.jsxs("div",{children:[h.jsx("span",{children:r.t("image-panel.transform.rotate")}),h.jsx(P.InputNumber,{precision:1,value:G,min:Te[0],max:Te[1],onChange:Fe})]})]})]})},Mt=s=>{const r=H.useDependency(f.ICommandService),e=H.useDependency(f.LocaleService),{drawings:t,cropperShow:n}=s;if(t[0]==null)return;const[a,o]=_.useState(U.FREE),c=_.useRef(!1),g=[{label:e.t("image-panel.crop.mode"),value:U.FREE},{label:"1:1",value:U.R1_1},{label:"16:9",value:U.R16_9},{label:"9:16",value:U.R9_16},{label:"5:4",value:U.R5_4},{label:"4:5",value:U.R4_5},{label:"4:3",value:U.R4_3},{label:"3:4",value:U.R3_4},{label:"3:2",value:U.R3_2},{label:"2:3",value:U.R2_3}];_.useEffect(()=>{const d=r.onCommandExecuted(p=>{if(p.id===Q.id){const S=p.params;S!=null&&S.isAuto||(c.current=!1)}});return()=>{d==null||d.dispose()}},[]);function l(d){o(d),c.current&&r.executeCommand(de.id,{cropType:d})}const u=d=>{r.executeCommand(de.id,{cropType:d}),c.current=!0};return h.jsxs("div",{className:P.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!n}),children:[h.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:h.jsx("div",{children:e.t("image-panel.crop.title")})}),h.jsxs("div",{className:"univer-flex univer-items-center univer-justify-center univer-gap-2",children:[h.jsxs(P.Button,{onClick:()=>{u(a)},children:[h.jsx(Ue,{}),e.t("image-panel.crop.start")]}),h.jsx(P.Select,{value:a,options:g,onChange:l})]})]})},Ot=s=>{const r=H.useDependency(M.IDrawingManagerService),e=H.useDependency(y.IRenderManagerService),t=H.useDependency(f.LocaleService),{drawings:n,hasArrange:i=!0,hasTransform:a=!0,hasAlign:o=!0,hasCropper:c=!0,hasGroup:g=!0}=s,l=n[0];if(l==null)return;const{unitId:u}=l,d=e.getRenderById(u),p=d==null?void 0:d.scene;if(p==null)return;const S=p.getTransformerByCreate(),[m,w]=_.useState(!0),[C,I]=_.useState(!0),[D,j]=_.useState(!1),[N,b]=_.useState(!0),[O,R]=_.useState(!1);return _.useEffect(()=>{const E=S.clearControl$.subscribe(A=>{A===!0&&(w(!1),I(!1),j(!1),b(!1),R(!0))}),x=S.changeStart$.subscribe(A=>{const{objects:G}=A,z=he(G,r);z.length===0?(w(!1),I(!1),j(!1),b(!1),R(!0)):z.length===1?(w(!0),I(!0),j(!1),b(!0),R(!1)):(w(!0),I(!1),j(!0),b(!1),R(!1))}),k=r.focus$.subscribe(A=>{A.length===0?(w(!1),I(!1),j(!1),b(!1),R(!0)):A.length===1?(w(!0),I(!0),j(!1),b(!0),R(!1)):(w(!0),I(!1),j(!0),b(!1),R(!1))});return()=>{x.unsubscribe(),E.unsubscribe(),k.unsubscribe()}},[]),h.jsxs(h.Fragment,{children:[h.jsx("div",{className:P.clsx("univer-h-full",{"univer-hidden":!O}),children:h.jsx("div",{className:"univer-flex univer-h-full univer-items-center univer-justify-center",children:h.jsx("span",{children:t.t("image-panel.null")})})}),h.jsx(bt,{arrangeShow:i===!0?m:!1,drawings:n}),h.jsx(Rt,{transformShow:a===!0?C:!1,drawings:n}),h.jsx(yt,{alignShow:o===!0?D:!1,drawings:n}),h.jsx(Mt,{cropperShow:c===!0?N:!1,drawings:n}),h.jsx(Dt,{hasGroup:g,drawings:n})]})};exports.AutoImageCropOperation=de;exports.COMPONENT_IMAGE_POPUP_MENU=Pe;exports.CloseImageCropOperation=Q;exports.DrawingCommonPanel=Ot;exports.ImageCropperObject=ue;exports.ImagePopupMenu=We;exports.ImageResetSizeOperation=Re;exports.OpenImageCropOperation=ve;exports.SetDrawingAlignOperation=ye;exports.getCurrentUnitInfo=Me;exports.getUpdateParams=he;exports.insertGroupObject=De;
@@ -0,0 +1 @@
1
+ "use strict";const o={"image-popup":{replace:"Nahradiť",delete:"Odstrániť",edit:"Upraviť",crop:"Orezať",reset:"Obnoviť veľkosť"},"image-cropper":{error:"Nedá sa orezať neobrázkový objekt."},"image-panel":{arrange:{title:"Usporiadať",forward:"Posunúť dopredu",backward:"Posunúť dozadu",front:"Presunúť do popredia",back:"Presunúť do pozadia"},transform:{title:"Transformovať",rotate:"Otočiť (°)",x:"X (px)",y:"Y (px)",width:"Šírka (px)",height:"Výška (px)",lock:"Uzamknúť pomer (%)"},crop:{title:"Orezanie",start:"Začať orezanie",mode:"Voľne"},group:{title:"Zoskupiť",group:"Zoskupiť",reGroup:"Znovu zoskupiť",unGroup:"Zrušiť zoskupenie"},align:{title:"Zarovnať",default:"Vyberte typ zarovnania",left:"Zarovnať doľava",center:"Zarovnať na stred",right:"Zarovnať doprava",top:"Zarovnať hore",middle:"Zarovnať na stred",bottom:"Zarovnať dole",horizon:"Rozložiť vodorovne",vertical:"Rozložiť zvisle"},null:"Nie je vybraný žiadny objekt"},"drawing-view":"Kresba",shortcut:{"drawing-move-down":"Posunúť kresbu nadol","drawing-move-up":"Posunúť kresbu nahor","drawing-move-left":"Posunúť kresbu doľava","drawing-move-right":"Posunúť kresbu doprava","drawing-delete":"Odstrániť kresbu"}};module.exports=o;