@univerjs/sheets-hyper-link-ui 0.2.4-alpha.0 → 0.2.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,4 +1,4 @@
1
- "use strict";var De=Object.defineProperty;var $e=(i,e,n)=>e in i?De(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n;var B=(i,e,n)=>$e(i,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),u=require("@univerjs/sheets"),m=require("@univerjs/sheets-hyper-link"),S=require("@univerjs/sheets-ui"),ye=require("@univerjs/engine-render"),ge=require("rxjs"),_=require("react"),ke=require("clsx"),k=require("@univerjs/design"),H=require("@univerjs/ui"),N=require("@univerjs/engine-formula"),Ae=require("@univerjs/docs-hyper-link"),Ve=require("@univerjs/docs");var Be=Object.defineProperty,We=Object.getOwnPropertyDescriptor,Fe=(i,e,n,t)=>{for(var r=t>1?void 0:t?We(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Be(e,n,r),r},he=(i,e)=>(n,t)=>e(n,t,i);exports.SheetsHyperLinkRemoveSheetController=class extends a.Disposable{constructor(e,n,t){super(),this._sheetInterceptorService=e,this._univerInstanceService=n,this._hyperLinkModel=t,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var n;if(e.id===u.RemoveSheetCommand.id){const t=e.params,r=t.unitId?this._univerInstanceService.getUnit(t.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!r)return{redos:[],undos:[]};const o=r.getUnitId(),s=t.subUnitId||((n=r.getActiveSheet())==null?void 0:n.getSheetId());if(!s)return{redos:[],undos:[]};const c=this._hyperLinkModel.getSubUnit(o,s),l=c.map(v=>({id:m.RemoveHyperLinkMutation.id,params:{unitId:o,subUnitId:s,id:v.id}})),p=c.map(v=>({id:m.AddHyperLinkMutation.id,params:{unitId:o,subUnitId:s,link:v}}));return{redos:l,undos:p}}return{redos:[],undos:[]}}}))}};exports.SheetsHyperLinkRemoveSheetController=Fe([a.OnLifecycle(a.LifecycleStages.Ready,exports.SheetsHyperLinkRemoveSheetController),he(0,a.Inject(u.SheetInterceptorService)),he(1,a.IUniverInstanceService),he(2,a.Inject(m.HyperLinkModel))],exports.SheetsHyperLinkRemoveSheetController);var Ye=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,be=(i,e,n,t)=>{for(var r=t>1?void 0:t?Ke(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Ye(e,n,r),r},z=(i,e)=>(n,t)=>e(n,t,i);exports.SheetsHyperLinkRenderController=class extends a.Disposable{constructor(e,n,t,r){super(),this._context=e,this._hyperLinkModel=n,this._sheetSkeletonManagerService=t,this._renderManagerService=r,this._initSkeletonChange()}_initSkeletonChange(){const e=()=>{var c;const n=this._context.unit,t=n.getUnitId(),r=(c=n.getActiveSheet())==null?void 0:c.getSheetId();if(!r){console.warn("No active sheet found");return}const o=this._sheetSkeletonManagerService.getOrCreateSkeleton({sheetId:r}),s=this._renderManagerService.getRenderById(t);o==null||o.makeDirty(!0),o==null||o.calculate(),s&&s.mainComponent.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.subscribe(()=>{e()}))}};exports.SheetsHyperLinkRenderController=be([z(1,a.Inject(m.HyperLinkModel)),z(2,a.Inject(S.SheetSkeletonManagerService)),z(3,ye.IRenderManagerService)],exports.SheetsHyperLinkRenderController);exports.SheetsHyperLinkRenderManagerController=class extends a.Disposable{constructor(e,n,t){super(),this._sheetInterceptorService=e,this._hyperLinkModel=n,this._themeService=t,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(u.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(e,n,t)=>{const{row:r,col:o,unitId:s,subUnitId:c}=n,l=this._hyperLinkModel.getHyperLinkByLocation(s,c,r,o),p=this._themeService.getCurrentTheme();return t(l?{...e,interceptorStyle:{ul:{s:a.BooleanNumber.TRUE},cl:{rgb:p.blue500}}}:e)},priority:100}))}};exports.SheetsHyperLinkRenderManagerController=be([a.OnLifecycle(a.LifecycleStages.Ready,exports.SheetsHyperLinkRenderManagerController),z(0,a.Inject(u.SheetInterceptorService)),z(1,a.Inject(m.HyperLinkModel)),z(2,a.Inject(a.ThemeService))],exports.SheetsHyperLinkRenderManagerController);var He={exports:{}},ae={};/**
1
+ "use strict";var Ae=Object.defineProperty;var Ve=(i,e,n)=>e in i?Ae(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n;var F=(i,e,n)=>Ve(i,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),u=require("@univerjs/sheets"),y=require("@wendellhu/redi"),m=require("@univerjs/sheets-hyper-link"),f=require("@univerjs/sheets-ui"),fe=require("@univerjs/engine-render"),se=require("rxjs"),L=require("react"),U=require("@wendellhu/redi/react-bindings"),Re=require("clsx"),I=require("@univerjs/design"),E=require("@univerjs/ui"),$=require("@univerjs/engine-formula"),Be=require("@univerjs/docs-hyper-link"),We=require("@univerjs/docs");var Fe=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,qe=(i,e,n,t)=>{for(var r=t>1?void 0:t?Ye(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Fe(e,n,r),r},ve=(i,e)=>(n,t)=>e(n,t,i);exports.SheetsHyperLinkRemoveSheetController=class extends a.Disposable{constructor(e,n,t){super(),this._sheetInterceptorService=e,this._univerInstanceService=n,this._hyperLinkModel=t,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var n;if(e.id===u.RemoveSheetCommand.id){const t=e.params,r=t.unitId?this._univerInstanceService.getUnit(t.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!r)return{redos:[],undos:[]};const o=r.getUnitId(),s=t.subUnitId||((n=r.getActiveSheet())==null?void 0:n.getSheetId());if(!s)return{redos:[],undos:[]};const c=this._hyperLinkModel.getSubUnit(o,s),l=c.map(v=>({id:m.RemoveHyperLinkMutation.id,params:{unitId:o,subUnitId:s,id:v.id}})),p=c.map(v=>({id:m.AddHyperLinkMutation.id,params:{unitId:o,subUnitId:s,link:v}}));return{redos:l,undos:p}}return{redos:[],undos:[]}}}))}};exports.SheetsHyperLinkRemoveSheetController=qe([a.OnLifecycle(a.LifecycleStages.Ready,exports.SheetsHyperLinkRemoveSheetController),ve(0,y.Inject(u.SheetInterceptorService)),ve(1,a.IUniverInstanceService),ve(2,y.Inject(m.HyperLinkModel))],exports.SheetsHyperLinkRemoveSheetController);var Ke=Object.defineProperty,ze=Object.getOwnPropertyDescriptor,Ee=(i,e,n,t)=>{for(var r=t>1?void 0:t?ze(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Ke(e,n,r),r},Z=(i,e)=>(n,t)=>e(n,t,i);exports.SheetsHyperLinkRenderController=class extends a.Disposable{constructor(e,n,t,r){super(),this._context=e,this._hyperLinkModel=n,this._sheetSkeletonManagerService=t,this._renderManagerService=r,this._initSkeletonChange()}_initSkeletonChange(){const e=()=>{var c;const n=this._context.unit,t=n.getUnitId(),r=(c=n.getActiveSheet())==null?void 0:c.getSheetId();if(!r){console.warn("No active sheet found");return}const o=this._sheetSkeletonManagerService.getOrCreateSkeleton({sheetId:r}),s=this._renderManagerService.getRenderById(t);o==null||o.makeDirty(!0),o==null||o.calculate(),s&&s.mainComponent.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(se.debounceTime(16)).subscribe(()=>{e()}))}};exports.SheetsHyperLinkRenderController=Ee([Z(1,y.Inject(m.HyperLinkModel)),Z(2,y.Inject(f.SheetSkeletonManagerService)),Z(3,fe.IRenderManagerService)],exports.SheetsHyperLinkRenderController);exports.SheetsHyperLinkRenderManagerController=class extends a.Disposable{constructor(e,n,t){super(),this._sheetInterceptorService=e,this._hyperLinkModel=n,this._themeService=t,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(u.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(e,n,t)=>{const{row:r,col:o,unitId:s,subUnitId:c}=n,l=this._hyperLinkModel.getHyperLinkByLocation(s,c,r,o),p=this._themeService.getCurrentTheme();return t(l?{...e,interceptorStyle:{ul:{s:a.BooleanNumber.TRUE},cl:{rgb:p.blue500}}}:e)},priority:100}))}};exports.SheetsHyperLinkRenderManagerController=Ee([a.OnLifecycle(a.LifecycleStages.Ready,exports.SheetsHyperLinkRenderManagerController),Z(0,y.Inject(u.SheetInterceptorService)),Z(1,y.Inject(m.HyperLinkModel)),Z(2,y.Inject(a.ThemeService))],exports.SheetsHyperLinkRenderManagerController);var Oe={exports:{}},de={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var ze=_,qe=Symbol.for("react.element"),Ze=Symbol.for("react.fragment"),Ge=Object.prototype.hasOwnProperty,Xe=ze.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Je={key:!0,ref:!0,__self:!0,__source:!0};function Ee(i,e,n){var t,r={},o=null,s=null;n!==void 0&&(o=""+n),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(s=e.ref);for(t in e)Ge.call(e,t)&&!Je.hasOwnProperty(t)&&(r[t]=e[t]);if(i&&i.defaultProps)for(t in e=i.defaultProps,e)r[t]===void 0&&(r[t]=e[t]);return{$$typeof:qe,type:i,key:o,ref:s,props:r,_owner:Xe.current}}ae.Fragment=Ze;ae.jsx=Ee;ae.jsxs=Ee;He.exports=ae;var h=He.exports,U=function(){return U=Object.assign||function(i){for(var e,n=1,t=arguments.length;n<t;n++){e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=e[r])}return i},U.apply(this,arguments)},Qe=function(i,e){var n={};for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&e.indexOf(t)<0&&(n[t]=i[t]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(i);r<t.length;r++)e.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(i,t[r])&&(n[t[r]]=i[t[r]]);return n},W=_.forwardRef(function(i,e){var n=i.icon,t=i.id,r=i.className,o=i.extend,s=Qe(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(t," ").concat(r||"").trim(),l=_.useRef("_".concat(nt()));return Oe(n,"".concat(t),{defIds:n.defIds,idSuffix:l.current},U({ref:e,className:c},s),o)});function Oe(i,e,n,t,r){return _.createElement(i.tag,U(U({key:e},et(i,n,r)),t),(tt(i,n).children||[]).map(function(o,s){return Oe(o,"".concat(e,"-").concat(i.tag,"-").concat(s),n,void 0,r)}))}function et(i,e,n){var t=U({},i.attrs);n!=null&&n.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=n.colorChannel1);var r=e.defIds;return!r||r.length===0||(i.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(function(o){var s=o[0],c=o[1];typeof c=="string"&&(t[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),t}function tt(i,e){var n,t=e.defIds;return!t||t.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?U(U({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&t&&t.indexOf(r.attrs.id)>-1?U(U({},r),{attrs:U(U({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):i}function nt(){return Math.random().toString(36).substring(2,8)}W.displayName="UniverIcon";var rt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ne=_.forwardRef(function(i,e){return _.createElement(W,Object.assign({},i,{id:"all-border-single",ref:e,icon:rt}))});ne.displayName="AllBorderSingle";var it={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.02547 12.4251C5.15328 13.7417 6.26305 14.7708 7.61318 14.7708H12.6132C14.0491 14.7708 15.2132 13.6067 15.2132 12.1708V6.1708C15.2132 4.78586 14.1303 3.65383 12.7651 3.57517C12.6373 2.25858 11.5275 1.22949 10.1774 1.22949H5.17739C3.74145 1.22949 2.57739 2.39355 2.57739 3.82949V9.82949C2.57739 11.2144 3.66024 12.3465 5.02547 12.4251ZM11.5535 3.5708H7.61318C6.17724 3.5708 5.01318 4.73486 5.01318 6.1708V11.22C4.31736 11.1387 3.77739 10.5471 3.77739 9.82949V3.82949C3.77739 3.05629 4.40419 2.42949 5.17739 2.42949H10.1774C10.8622 2.42949 11.4322 2.92119 11.5535 3.5708ZM14.0132 6.1708C14.0132 5.3976 13.3864 4.7708 12.6132 4.7708H7.61318C6.83998 4.7708 6.21318 5.3976 6.21318 6.1708V12.1708C6.21318 12.944 6.83998 13.5708 7.61318 13.5708H12.6132C13.3864 13.5708 14.0132 12.944 14.0132 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Me=_.forwardRef(function(i,e){return _.createElement(W,Object.assign({},i,{id:"copy-single",ref:e,icon:it}))});Me.displayName="CopySingle";var ot={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332",fillRule:"evenodd",clipRule:"evenodd"}}]},ie=_.forwardRef(function(i,e){return _.createElement(W,Object.assign({},i,{id:"link-single",ref:e,icon:ot}))});ie.displayName="LinkSingle";var st={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z"}}]},we=_.forwardRef(function(i,e){return _.createElement(W,Object.assign({},i,{id:"unlink-single",ref:e,icon:st}))});we.displayName="UnlinkSingle";var at={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},Te=_.forwardRef(function(i,e){return _.createElement(W,Object.assign({},i,{id:"write-single",ref:e,icon:at}))});Te.displayName="WriteSingle";var ct={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#35BD4B",d:"M3.36396 1.12549C2.61066 1.12549 2 1.73615 2 2.48945V13.5104C2 14.2637 2.61066 14.8744 3.36396 14.8744H12.457C13.2103 14.8744 13.821 14.2637 13.821 13.5104V5.0992L9.91954 1.12549H3.36396Z"}},{tag:"path",attrs:{fill:"#32A846",d:"M9.91797 1.12549L13.8209 5.09842H10.5846C10.2164 5.09842 9.91797 4.79994 9.91797 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.71926 10.2949L6.28687 12.403C6.17306 12.5705 5.94501 12.614 5.77751 12.5002C5.61002 12.3864 5.56649 12.1584 5.6803 11.9909L7.27596 9.64252L5.85088 7.54519C5.73707 7.37769 5.78059 7.14964 5.94809 7.03583C6.11558 6.92202 6.34363 6.96555 6.45744 7.13304L7.71926 8.9901L8.98108 7.13304C9.09489 6.96555 9.32294 6.92202 9.49044 7.03583C9.65793 7.14964 9.70146 7.37769 9.58765 7.54519L8.16256 9.64252L9.75822 11.9909C9.87203 12.1584 9.82851 12.3864 9.66101 12.5002C9.49351 12.614 9.26547 12.5705 9.15166 12.403L7.71926 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ve=_.forwardRef(function(i,e){return _.createElement(W,Object.assign({},i,{id:"xlsx",ref:e,icon:ct}))});ve.displayName="Xlsx";var lt=Object.defineProperty,dt=Object.getOwnPropertyDescriptor,pt=(i,e,n,t)=>{for(var r=t>1?void 0:t?dt(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&lt(e,n,r),r},G=(i,e)=>(n,t)=>e(n,t,i);function ut(i,e){const n=e.getMergeData(),t=e.getMaxColumns()-1,r=e.getMaxRows()-1;if(t<i.endColumn&&(i.endColumn=t),r<i.endRow&&(i.endRow=r),i.rangeType===a.RANGE_TYPE.COLUMN||a.RANGE_TYPE.ROW)return i;const o=[];return n.forEach(s=>{a.Rectangle.intersects(i,s)&&o.push(s)}),a.Rectangle.realUnion(i,...o)}exports.SheetsHyperLinkResolverService=class{constructor(e,n,t,r,o){this._univerInstanceService=e,this._commandService=n,this._definedNamesService=t,this._messageService=r,this._localeService=o}_getURLName(e){var l;const{gid:n,range:t,rangeid:r}=e,o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!o)return null;const s=n?o.getSheetBySheetId(n):o.getActiveSheet(),c=(l=s==null?void 0:s.getName())!=null?l:"";if(t){const p=N.deserializeRangeWithSheet(t).range;return a.isValidRange(p)&&t!==m.ERROR_RANGE?{type:"range",name:N.serializeRangeWithSheet(c,p)}:{type:"range-error",name:this._localeService.t("hyperLink.message.refError")}}if(r){const p=this._definedNamesService.getValueById(o.getUnitId(),r);return p?{type:"defineName",name:p.formulaOrRefString}:{type:"range-error",name:this._localeService.t("hyperLink.message.refError")}}if(n){const p=o.getSheetBySheetId(n);return p?{type:"sheet",name:p.getName()}:{type:"sheet-error",name:this._localeService.t("hyperLink.message.refError")}}return null}navigateTo(e){const{gid:n,range:t,rangeid:r}=e,o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!o)return;const s=o.getUnitId();if(r&&this.navigateToDefineName(s,r),!!n){if(t){const c=N.deserializeRangeWithSheet(t);a.isValidRange(c.range)&&t!==m.ERROR_RANGE&&this.navigateToRange(s,n,c.range);return}this.navigateToSheetById(s,n)}}parseHyperLink(e){var n,t,r;if(e!=null&&e.startsWith("#")){const o=new URLSearchParams(e.slice(1)),s={gid:(n=o.get("gid"))!=null?n:"",range:(t=o.get("range"))!=null?t:"",rangeid:(r=o.get("rangeid"))!=null?r:""},c=this._getURLName(s);return{type:(c==null?void 0:c.type)||"link",name:(c==null?void 0:c.name)||e,url:e,searchObj:s,handler:()=>{this.navigateTo(s)}}}else return{type:"outer",name:e,url:e,handler:()=>{this.navigateToOtherWebsite(e)}}}async navigateToRange(e,n,t){const r=await this.navigateToSheetById(e,n);if(r){const o=ut(t,r);await this._commandService.executeCommand(u.SetSelectionsOperation.id,{unitId:e,subUnitId:n,selections:[{range:o}]}),await this._commandService.executeCommand(S.ScrollToRangeOperation.id,{range:o})}}async navigateToSheet(e,n){const t=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET);if(!t)return!1;const r=t.getActiveSheet();if((r==null?void 0:r.getName())===n)return!0;const o=t.getSheetBySheetName(n);if(!o){this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:k.MessageType.Error});return}const s=o.getSheetId();return t.getHiddenWorksheets().indexOf(s)>-1&&this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:k.MessageType.Error}),await this._commandService.executeCommand(u.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:s})}async navigateToSheetById(e,n){const t=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET);if(!t)return!1;const r=t.getActiveSheet();if(!r)return!1;if(r.getSheetId()===n)return r;const o=t.getSheetBySheetId(n);return o?t.getHiddenWorksheets().indexOf(n)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:k.MessageType.Error}),!1):await this._commandService.executeCommand(u.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:n})?o:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:k.MessageType.Error}),!1)}async navigateToDefineName(e,n){return this._definedNamesService.focusRange(e,n),!0}async navigateToOtherWebsite(e){window.open(e,"_blank","noopener noreferrer")}};exports.SheetsHyperLinkResolverService=pt([G(0,a.IUniverInstanceService),G(1,a.ICommandService),G(2,N.IDefinedNamesService),G(3,H.IMessageService),G(4,a.Inject(a.LocaleService))],exports.SheetsHyperLinkResolverService);function J(i){return a.Tools.isLegalUrl(i)}function ht(i){return/^[a-zA-Z]+:\/\//.test(i)}function mt(i){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(i)}function Se(i){if(J(i)){const e=ht(i)?i:mt(i)?`mailto://${i}`:`http://${i}`,n=new URL(e);return n.hostname===location.hostname&&n.port===location.port&&n.protocol===location.protocol&&n.pathname===location.pathname&&n.hash&&!n.search?n.hash:e}return i}function gt(i){if(i===null)return"";if(i!=null&&i.p){const e=i==null?void 0:i.p.body;if(e==null)return"";const n=e.dataStream;return n.substring(n.length-2,n.length)===a.DEFAULT_EMPTY_DOCUMENT_VALUE?n.substring(0,n.length-2):n}return i==null?void 0:i.v}const vt="univer-cell-link-edit-buttons",yt={cellLinkEditButtons:vt},oe=()=>{var Z;const[i,e]=_.useState(""),[n,t]=_.useState(""),[r,o]=_.useState("link"),[s,c]=_.useState(""),l=a.useDependency(a.LocaleService),p=a.useDependency(N.IDefinedNamesService),v=a.useDependency(a.IUniverInstanceService),f=a.useDependency(exports.SheetsHyperLinkPopupService),d=H.useObservable(f.currentEditing$),C=a.useDependency(m.HyperLinkModel),y=a.useDependency(exports.SheetsHyperLinkResolverService),L=a.useDependency(a.ICommandService),[I,M]=_.useState(!1),b=_.useRef(!1);_.useEffect(()=>{var g,R,O;if((d==null?void 0:d.row)!==void 0&&d.column!==void 0){const P=C.getHyperLinkByLocationSync(d.unitId,d.subUnitId,d.row,d.column);if(P){const ee=y.parseHyperLink(P.payload);if(e(P.id),t(P.display),ee.type==="outer"){o("link"),c(ee.url),ee.url===P.display&&(b.current=!0);return}else{const D=ee.searchObj;if(D.rangeid){o("rangeid"),c(D.rangeid);return}if(D.range){const Ne=D.gid&&(O=(R=(g=v.getUnit(d.unitId))==null?void 0:g.getSheetBySheetId(D.gid))==null?void 0:R.getName())!=null?O:"";if(o("range"),D.range===m.ERROR_RANGE)c("");else{const Ce=N.serializeRangeWithSheet(Ne,N.deserializeRangeWithSheet(D.range).range);c(Ce),Ce===P.display&&(b.current=!0)}return}if(D.gid){o("gid"),c(D.gid);return}}}const w=v.getUnit(d.unitId),j=w==null?void 0:w.getSheetBySheetId(d.subUnitId),xe=j==null?void 0:j.getCellRaw(d.row,d.column),ue=gt(xe);o("link"),c(""),t((ue!=null?ue:"").toString()),e("");return}o("link"),c(""),t(""),e("")},[d,C,y,v]);const T=_.useMemo(()=>s,[r]),$=[{label:l.t("hyperLink.form.link"),value:"link"},{label:l.t("hyperLink.form.range"),value:"range"},{label:l.t("hyperLink.form.worksheet"),value:"gid"},{label:l.t("hyperLink.form.definedName"),value:"rangeid"}],E=v.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!E)return;const F=E.getHiddenWorksheets(),A=E.getSheets().map(g=>({label:g.getName(),value:g.getSheetId()})).filter(g=>F.indexOf(g.value)===-1),V=Object.values((Z=p.getDefinedNameMap(E.getUnitId()))!=null?Z:{}).map(g=>({label:g.name,value:g.id})),q=(g,R)=>{if(g==="link")return Se(R);if(g==="range"){const O=N.deserializeRangeWithSheet(R),P=E.getSheetBySheetName(O.sheetName);if(P)return`#gid=${P.getSheetId()}&range=${N.serializeRange(O.range)}`}return`#${g}=${R}`},de=H.useEvent(g=>{var P;const R=g[0];if(!R||!a.isValidRange(R.range))return;R.sheetName||(R.sheetName=((P=E.getActiveSheet())==null?void 0:P.getName())||"");const O=N.serializeRangeToRefString(R);c(O),O&&(b.current||!n)&&(t(O),b.current=!0)}),pe=async()=>{if(d&&(i?await L.executeCommand(m.UpdateHyperLinkCommand.id,{unitId:d.unitId,subUnitId:d.subUnitId,id:i,payload:{display:n,payload:q(r,s)}}):await L.executeCommand(m.AddHyperLinkCommand.id,{unitId:d.unitId,subUnitId:d.subUnitId,link:{id:a.Tools.generateRandomId(),row:d.row,column:d.column,payload:q(r,s),display:n}})),d){await L.executeCommand(u.SetWorksheetActiveOperation.id,{unitId:d.unitId,subUnitId:d.subUnitId});const g=1;await L.executeCommand(S.ScrollToRangeOperation.id,{range:{startRow:Math.max(d.row-g,0),endRow:d.row+g,startColumn:Math.max(d.column-g,0),endColumn:d.column+g}})}L.executeCommand(Q.id)};return h.jsxs("div",{children:[h.jsx(k.FormLayout,{label:l.t("hyperLink.form.label"),error:I&&!n?l.t("hyperLink.form.inputError"):"",children:h.jsx(k.Input,{value:n,onChange:g=>{t(g),b.current=!1},placeholder:l.t("hyperLink.form.labelPlaceholder")})}),h.jsx(k.FormLayout,{label:l.t("hyperLink.form.type"),children:h.jsx(k.Select,{options:$,value:r,onChange:g=>{o(g),c("")}})}),r==="link"&&h.jsx(k.FormLayout,{error:I?s?J(s)?"":l.t("hyperLink.form.linkError"):l.t("hyperLink.form.inputError"):"",children:h.jsx(k.Input,{value:s,onChange:g=>{c(g),g&&(b.current||!n||n===s)&&(t(g),b.current=!0)},placeholder:l.t("hyperLink.form.linkPlaceholder")})}),r==="range"&&h.jsx(k.FormLayout,{error:I&&!s?l.t("hyperLink.form.inputError"):"",children:h.jsx(H.RangeSelector,{openForSheetUnitId:E.getUnitId(),id:a.createInternalEditorID("hyper-link-edit"),isSingleChoice:!0,value:T,onChange:de})}),r==="gid"&&h.jsx(k.FormLayout,{error:I&&!s?l.t("hyperLink.form.selectError"):"",children:h.jsx(k.Select,{options:A,value:s,onChange:g=>{var P,w;c(g);const R=(P=A.find(j=>j.value===g))==null?void 0:P.label,O=(w=A.find(j=>j.value===s))==null?void 0:w.label;R&&(b.current||!n||n===O)&&(t(R),b.current=!0)}})}),r==="rangeid"&&h.jsx(k.FormLayout,{error:I&&!s?l.t("hyperLink.form.selectError"):"",children:h.jsx(k.Select,{options:V,value:s,onChange:g=>{var P,w;c(g);const R=(P=V.find(j=>j.value===g))==null?void 0:P.label,O=(w=V.find(j=>j.value===s))==null?void 0:w.label;R&&(b.current||!n||n===O)&&(t(R),b.current=!0)}})}),h.jsxs("div",{className:yt.cellLinkEditButtons,children:[h.jsx(k.Button,{onClick:()=>{d&&L.executeCommand(u.SetWorksheetActiveOperation.id,{unitId:d.unitId,subUnitId:d.subUnitId}),L.executeCommand(Q.id)},children:l.t("hyperLink.form.cancel")}),h.jsx(k.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{if(!n||!s||r==="link"&&!J(s)){M(!0);return}pe()},children:l.t("hyperLink.form.ok")})]})]})};oe.componentKey="univer.sheet.cell-link-edit";const ce={type:a.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-sidebar",handler(i,e){if(!e)return!1;const{unitId:n,subUnitId:t,row:r,column:o}=e,s=i.get(m.HyperLinkModel),c=i.get(H.ISidebarService),l=i.get(exports.SheetsHyperLinkPopupService),p=s.getHyperLinkByLocation(n,t,r,o);return l.startEditing(e),c.open({header:{title:p?"hyperLink.form.editTitle":"hyperLink.form.addTitle"},children:{label:oe.componentKey}}),!0}},Q={type:a.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-sidebar",handler(i){const e=i.get(H.ISidebarService),n=i.get(exports.SheetsHyperLinkPopupService);return e.close(),n.endEditing(),!0}},le={type:a.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(i){const e=i.get(a.IUniverInstanceService),n=u.getSheetCommandTarget(e);if(!n)return!1;const t=i.get(a.ICommandService),o=i.get(u.SheetsSelectionsService).getCurrentLastSelection();if(!o)return!1;const s=o.primary.startRow,c=o.primary.startColumn;return t.executeCommand(ce.id,{unitId:n.unitId,subUnitId:n.subUnitId,row:s,column:c})}},fe={type:a.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(i){const e=i.get(a.ICommandService);return i.get(exports.SheetsHyperLinkPopupService).currentEditing?e.executeCommand(Q.id):e.executeCommand(le.id)}},St="univer-cell-link",ft="univer-cell-link-type",_t="univer-cell-link-content",Lt="univer-cell-link-content-error",Ct="univer-cell-link-url",kt="univer-cell-link-operations",It="univer-cell-link-operation",Rt="univer-cell-link-operation-error",x={cellLink:St,cellLinkType:ft,cellLinkContent:_t,cellLinkContentError:Lt,cellLinkUrl:Ct,cellLinkOperations:kt,cellLinkOperation:It,cellLinkOperationError:Rt},Pt={outer:h.jsx(ie,{}),link:h.jsx(ie,{}),sheet:h.jsx(ve,{}),range:h.jsx(ne,{}),defineName:h.jsx(ne,{}),"range-error":h.jsx(ne,{}),"sheet-error":h.jsx(ve,{})},se=()=>{const i=a.useDependency(exports.SheetsHyperLinkPopupService),e=a.useDependency(m.HyperLinkModel),n=a.useDependency(a.ICommandService),t=a.useDependency(H.IMessageService),r=a.useDependency(a.LocaleService),[o,s]=_.useState(null),c=a.useDependency(exports.SheetsHyperLinkResolverService);if(_.useEffect(()=>{s(i.currentPopup);const y=i.currentPopup$.subscribe(L=>{s(L)});return()=>{y.unsubscribe()}},[i.currentPopup,i.currentPopup$]),!o)return null;const{unitId:l,subUnitId:p,id:v}=o,f=e.getHyperLink(l,p,v);if(!f)return null;const d=c.parseHyperLink(f.payload),C=d.type.indexOf("error")>-1;return h.jsxs("div",{className:x.cellLink,onClick:()=>i.hideCurrentPopup(),children:[h.jsxs("div",{className:ke(x.cellLinkContent,{[x.cellLinkContentError]:C}),onClick:d.handler,children:[h.jsx("div",{className:x.cellLinkType,children:Pt[d.type]}),h.jsx(k.Tooltip,{showIfEllipsis:!0,title:d.name,children:h.jsx("span",{className:x.cellLinkUrl,children:d.name})})]}),h.jsxs("div",{className:x.cellLinkOperations,children:[o.copyPermission&&h.jsx("div",{className:ke(x.cellLinkOperation,{[x.cellLinkOperationError]:C}),onClick:()=>{if(!C){if(d.type!=="outer"){const y=new URL(window.location.href);y.hash=d.url.slice(1),navigator.clipboard.writeText(y.href)}else navigator.clipboard.writeText(d.url);t.show({content:r.t("hyperLink.message.coped"),type:k.MessageType.Info})}},children:h.jsx(k.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:h.jsx(Me,{})})}),o.editPermission&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:x.cellLinkOperation,onClick:()=>{n.executeCommand(ce.id,{unitId:l,subUnitId:p,row:f.row,column:f.column})},children:h.jsx(k.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:h.jsx(Te,{})})}),h.jsx("div",{className:x.cellLinkOperation,onClick:()=>{n.executeCommand(m.CancelHyperLinkCommand.id,{unitId:l,subUnitId:p,id:f.id})},children:h.jsx(k.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:h.jsx(we,{})})})]})]})]})};se.componentKey="univer.sheet.cell-link-popup";var bt=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor,Et=(i,e,n,t)=>{for(var r=t>1?void 0:t?Ht(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&bt(e,n,r),r},Ie=(i,e)=>(n,t)=>e(n,t,i);const Ot=(i,e)=>i.unitId===e.unitId&&i.subUnitId===e.subUnitId&&i.row===e.row&&i.col===e.col;exports.SheetsHyperLinkPopupService=class extends a.Disposable{constructor(n,t){super();B(this,"_currentPopup",null);B(this,"_currentPopup$",new ge.Subject);B(this,"currentPopup$",this._currentPopup$.asObservable());B(this,"_currentEditing$",new ge.BehaviorSubject(null));B(this,"currentEditing$",this._currentEditing$.asObservable());this._hyperLinkModel=n,this._sheetCanvasPopManagerService=t,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}showPopup(n){if(this._currentPopup&&Ot(n,this._currentPopup))return;this.hideCurrentPopup();const{unitId:t,subUnitId:r,row:o,col:s}=n,c=this._hyperLinkModel.getHyperLinkByLocation(t,r,o,s);if(!c)return;const l=this._sheetCanvasPopManagerService.attachPopupToCell(o,s,{componentKey:se.componentKey,direction:"bottom",closeOnSelfTarget:!0,onClickOutside:()=>{this.hideCurrentPopup()}});l&&(this._currentPopup={unitId:t,subUnitId:r,id:c.id,disposable:l,row:o,col:s,editPermission:!!n.editPermission,copyPermission:!!n.copyPermission},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(){var n;this._currentPopup&&((n=this._currentPopup.disposable)==null||n.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}startEditing(n){this._currentEditing$.next(n)}endEditing(){this._currentEditing$.next(null)}};exports.SheetsHyperLinkPopupService=Et([Ie(0,a.Inject(m.HyperLinkModel)),Ie(1,a.Inject(S.SheetCanvasPopManagerService))],exports.SheetsHyperLinkPopupService);var Mt=Object.defineProperty,wt=Object.getOwnPropertyDescriptor,Tt=(i,e,n,t)=>{for(var r=t>1?void 0:t?wt(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Mt(e,n,r),r},Y=(i,e)=>(n,t)=>e(n,t,i);exports.SheetHyperLinkSetRangeController=class extends a.Disposable{constructor(e,n,t,r,o,s){super(),this._sheetInterceptorService=e,this._injector=n,this._hyperLinkModel=t,this._selectionManagerService=r,this._univerInstanceService=o,this._editorBridgeService=s,this._initCommandInterceptor()}_initCommandInterceptor(){this._initAddHyperLinkCommandInterceptor(),this._initSetRangeValuesCommandInterceptor(),this._initUpdateHyperLinkCommandInterceptor(),this._initClearSelectionCommandInterceptor(),this._initRichTextEditorInterceptor()}_getCurrentCell(e,n,t,r){var o,s;return(s=(o=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET))==null?void 0:o.getSheetBySheetId(n))==null?void 0:s.getCell(t,r)}_initAddHyperLinkCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var n;if(e.id===m.AddHyperLinkCommand.id){const t=e.params,{unitId:r,subUnitId:o,link:s}=t,c=this._getCurrentCell(r,o,s.row,s.column),l={unitId:r,subUnitId:o,cellValue:{[s.row]:{[s.column]:{v:s.display,p:null,t:(n=c==null?void 0:c.t)!=null?n:void 0}}}};return{redos:[{id:u.SetRangeValuesMutation.id,params:l}],undos:[{id:u.SetRangeValuesMutation.id,params:u.SetRangeValuesUndoMutationFactory(this._injector,l)}]}}return{redos:[],undos:[]}}}))}_initUpdateHyperLinkCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===m.UpdateHyperLinkCommand.id){const n=e.params,{unitId:t,subUnitId:r,id:o,payload:s}=n,c=this._hyperLinkModel.getHyperLink(t,r,o);if(c&&c.display!==s.display){const l={unitId:t,subUnitId:r,cellValue:{[c.row]:{[c.column]:{v:s.display,t:a.CellValueType.STRING,p:null}}}};return{redos:[{id:u.SetRangeValuesMutation.id,params:l}],undos:[{id:u.SetRangeValuesMutation.id,params:u.SetRangeValuesUndoMutationFactory(this._injector,l)}]}}}return{redos:[],undos:[]}}}))}_initSetRangeValuesCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===u.SetRangeValuesCommand.id){const n=e.params,{unitId:t,subUnitId:r}=n,o=[],s=[];return n.cellValue&&new a.ObjectMatrix(n.cellValue).forValue((c,l,p)=>{var C,y,L,I,M,b,T;const v=(L=p==null?void 0:p.v)!=null?L:(y=(C=p==null?void 0:p.p)==null?void 0:C.body)==null?void 0:y.dataStream.slice(0,-2),f=(v!=null?v:"").toString(),d=this._hyperLinkModel.getHyperLinkByLocation(t,r,c,l);if(!d){if(J(f)||(I=p==null?void 0:p.custom)!=null&&I.__link_url){const $=(b=(M=p==null?void 0:p.custom)==null?void 0:M.__link_url)!=null?b:f,E=a.Tools.generateRandomId();s.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:t,subUnitId:r,id:E}}),o.push({id:m.AddHyperLinkMutation.id,params:{unitId:t,subUnitId:r,link:{id:E,row:c,column:l,display:f,payload:Se($)}}})}return}(v===""||((T=p==null?void 0:p.custom)==null?void 0:T.__link_url)==="")&&(o.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:t,subUnitId:r,id:d.id}}),s.push({id:m.AddHyperLinkMutation.id,params:{unitId:t,subUnitId:r,link:d}}))}),{undos:s,redos:o}}return{redos:[],undos:[]}}}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===u.ClearSelectionContentCommand.id||e.id===u.ClearSelectionAllCommand.id||e.id===u.ClearSelectionFormatCommand.id){const n=[],t=[],r=this._selectionManagerService.getCurrentLastSelection(),o=u.getSheetCommandTarget(this._univerInstanceService);if(r&&o){const{unitId:s,subUnitId:c}=o;a.Range.foreach(r.range,(l,p)=>{const v=this._hyperLinkModel.getHyperLinkByLocation(s,c,l,p);v&&(n.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:v.id}}),t.push({id:m.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:v}}))})}return{redos:n,undos:t}}return{redos:[],undos:[]}}}))}_initRichTextEditorInterceptor(){this.disposeWithMe(this._editorBridgeService.interceptor.intercept(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT,{handler:(e,n,t)=>{var r,o,s,c,l,p;if(e!=null&&e.p){const v=(o=(r=e.p.body)==null?void 0:r.customRanges)==null?void 0:o.find(d=>d.rangeType===a.CustomRangeType.HYPERLINK),f=(s=e.p.resources)==null?void 0:s.find(d=>d.name===Ae.DOC_HYPER_LINK_PLUGIN);if(v&&f){const d=v.rangeId,C=(p=(l=(c=JSON.parse(f.data))==null?void 0:c.links)==null?void 0:l.find(y=>y.id===d))==null?void 0:p.payload;return t({...e,p:null,v:Ve.getPlainTextFormDocument(e.p),t:a.CellValueType.STRING,custom:{__link_url:C}})}}return t(e)}}))}};exports.SheetHyperLinkSetRangeController=Tt([a.OnLifecycle(a.LifecycleStages.Starting,exports.SheetHyperLinkSetRangeController),Y(0,a.Inject(u.SheetInterceptorService)),Y(1,a.Inject(a.Injector)),Y(2,a.Inject(m.HyperLinkModel)),Y(3,a.Inject(u.SheetsSelectionsService)),Y(4,a.IUniverInstanceService),Y(5,S.IEditorBridgeService)],exports.SheetHyperLinkSetRangeController);var Ut=Object.defineProperty,jt=Object.getOwnPropertyDescriptor,xt=(i,e,n,t)=>{for(var r=t>1?void 0:t?jt(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Ut(e,n,r),r},X=(i,e)=>(n,t)=>e(n,t,i);exports.SheetsHyperLinkPopupController=class extends a.Disposable{constructor(e,n,t,r,o){super(),this._hoverManagerService=e,this._sheetsHyperLinkPopupService=n,this._renderManagerService=t,this._permissionService=r,this._sheetPermissionInterceptorBaseController=o,this._initHoverListener()}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(ge.debounceTime(100)).subscribe(e=>{var d,C;if(!e){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const n=(C=(d=this._renderManagerService.getRenderById(e.location.unitId))==null?void 0:d.with(S.SheetSkeletonManagerService).getWorksheetSkeleton(e.location.subUnitId))==null?void 0:C.skeleton,t=e.location.col,r=e.location.row;let o=r,s=t;if(n&&n.overflowCache.forValue((y,L,I)=>{a.Rectangle.contains(I,{startColumn:t,endColumn:t,startRow:r,endRow:r})&&(o=y,s=L)}),!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[u.WorkbookViewPermission],worksheetTypes:[u.WorksheetViewPermission],rangeTypes:[u.RangeProtectionPermissionViewPoint]},[{startRow:r,startColumn:t,endRow:r,endColumn:t}])){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const l=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetEditPermission,u.WorksheetInsertHyperlinkPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]},[{startRow:r,startColumn:t,endRow:r,endColumn:t}]),p=e.location.unitId,v=e.location.subUnitId,f=this._permissionService.composePermission([new u.WorkbookCopyPermission(p).id,new u.WorksheetCopyPermission(p,v).id]).every(y=>y.value);this._sheetsHyperLinkPopupService.showPopup({...e.location,row:o,col:s,editPermission:l,copyPermission:f})}))}};exports.SheetsHyperLinkPopupController=xt([a.OnLifecycle(a.LifecycleStages.Rendered,exports.SheetsHyperLinkPopupController),X(0,a.Inject(S.HoverManagerService)),X(1,a.Inject(exports.SheetsHyperLinkPopupService)),X(2,a.Inject(ye.IRenderManagerService)),X(3,a.Inject(a.IPermissionService)),X(4,a.Inject(S.SheetPermissionInterceptorBaseController))],exports.SheetsHyperLinkPopupController);const Nt=i=>({id:le.id,type:H.MenuItemType.BUTTON,positions:[H.MenuPosition.CONTEXT_MENU],title:"hyperLink.menu.add",hidden$:H.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),icon:"LinkSingle",disabled$:S.getCurrentRangeDisable$(i,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetEditPermission,u.WorksheetSetCellValuePermission,u.WorksheetInsertHyperlinkPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}),Dt=i=>({tooltip:"hyperLink.form.addTitle",positions:H.MenuPosition.TOOLBAR_START,group:H.MenuGroup.TOOLBAR_OTHERS,id:fe.id,type:H.MenuItemType.BUTTON,icon:"LinkSingle",hidden$:H.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:S.getCurrentRangeDisable$(i,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetEditPermission,u.WorksheetSetCellValuePermission,u.WorksheetInsertHyperlinkPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}),_e={id:fe.id,binding:H.KeyCode.K|H.MetaKeys.CTRL_COMMAND,preconditions:S.whenSheetEditorFocused};var $t=Object.defineProperty,At=Object.getOwnPropertyDescriptor,Vt=(i,e,n,t)=>{for(var r=t>1?void 0:t?At(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&$t(e,n,r),r},K=(i,e)=>(n,t)=>e(n,t,i);exports.SheetsHyperLinkUIController=class extends a.Disposable{constructor(e,n,t,r,o,s,c){super(),this._config=e,this._componentManager=n,this._commandService=t,this._localeService=r,this._menuService=o,this._injector=s,this._shortcutService=c,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[se,se.componentKey],[oe,oe.componentKey],[ie,"LinkSingle"]].forEach(([e,n])=>{this._componentManager.register(n,e)})}_initCommands(){[ce,Q,le,fe].forEach(e=>{this._commandService.registerCommand(e)})}_initMenus(){var e,n,t,r;this._menuService.addMenuItem(Nt(this._injector),(n=(e=this._config)==null?void 0:e.menu)!=null?n:{}),this._menuService.addMenuItem(Dt(this._injector),(r=(t=this._config)==null?void 0:t.menu)!=null?r:{})}_initShortCut(){this._shortcutService.registerShortcut(_e)}};exports.SheetsHyperLinkUIController=Vt([a.OnLifecycle(a.LifecycleStages.Ready,exports.SheetsHyperLinkUIController),K(1,a.Inject(H.ComponentManager)),K(2,a.ICommandService),K(3,a.Inject(a.LocaleService)),K(4,H.IMenuService),K(5,a.Inject(a.Injector)),K(6,a.Inject(H.IShortcutService))],exports.SheetsHyperLinkUIController);const Le="SHEET_HYPER_LINK_UI_PLUGIN";var Bt=Object.defineProperty,Wt=Object.getOwnPropertyDescriptor,Ft=(i,e,n,t)=>{for(var r=t>1?void 0:t?Wt(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Bt(e,n,r),r},Re=(i,e)=>(n,t)=>e(n,t,i);exports.SheetsHyperLinkAutoFillController=class extends a.Disposable{constructor(e,n){super(),this._autoFillService=e,this._hyperLinkModel=n,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),n=(r,o)=>{const{source:s,target:c,unitId:l,subUnitId:p}=r,v=S.virtualizeDiscreteRanges([s,c]),[f,d]=v.ranges,{mapFunc:C}=v,y={row:f.startRow,col:f.startColumn},L=S.getAutoFillRepeatRange(f,d),I=[],M=[];return L.forEach(b=>{const T=b.repeatStartCell,$=b.relativeRange,E={startRow:y.row,startColumn:y.col,endColumn:y.col,endRow:y.row},F={startRow:T.row,startColumn:T.col,endColumn:T.col,endRow:T.row};a.Range.foreach($,(A,V)=>{const q=a.Rectangle.getPositionRange({startRow:A,startColumn:V,endColumn:V,endRow:A},E),{row:de,col:pe}=C(q.startRow,q.startColumn),Z=this._hyperLinkModel.getHyperLinkByLocation(l,p,de,pe);if(Z){const g=a.Rectangle.getPositionRange({startRow:A,startColumn:V,endColumn:V,endRow:A},F),{row:R,col:O}=C(g.startRow,g.startColumn),P=a.Tools.generateRandomId(),w=this._hyperLinkModel.getHyperLinkByLocation(l,p,R,O);w&&I.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:p,id:w.id}}),(S.APPLY_TYPE.COPY===o||S.APPLY_TYPE.SERIES===o)&&(I.push({id:m.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:p,link:{...Z,id:P,row:R,column:O}}}),M.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:p,id:P}})),w&&M.push({id:m.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:p,link:w}})}})}),{undos:M,redos:I}},t={id:Le,onFillData:(r,o,s)=>s===S.APPLY_TYPE.COPY||s===S.APPLY_TYPE.ONLY_FORMAT||s===S.APPLY_TYPE.SERIES?n(r,s):e()};this.disposeWithMe(this._autoFillService.addHook(t))}};exports.SheetsHyperLinkAutoFillController=Ft([a.OnLifecycle(a.LifecycleStages.Ready,exports.SheetsHyperLinkAutoFillController),Re(0,S.IAutoFillService),Re(1,a.Inject(m.HyperLinkModel))],exports.SheetsHyperLinkAutoFillController);var Yt=Object.defineProperty,Kt=Object.getOwnPropertyDescriptor,zt=(i,e,n,t)=>{for(var r=t>1?void 0:t?Kt(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Yt(e,n,r),r},te=(i,e)=>(n,t)=>e(n,t,i);exports.SheetsHyperLinkCopyPasteController=class extends a.Disposable{constructor(n,t,r,o){super();B(this,"_copyInfo");this._sheetClipboardService=n,this._hyperLinkModel=t,this._injector=r,this._resolverService=o,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:Le,onBeforeCopy:(n,t,r)=>this._collect(n,t,r),onPasteCells:(n,t,r,o)=>{const{copyType:s=S.COPY_TYPE.COPY,pasteType:c}=o,{range:l}=n||{},{range:p,unitId:v,subUnitId:f}=t;return this._generateMutations(p,{copyType:s,pasteType:c,copyRange:l,unitId:v,subUnitId:f})},onPastePlainText:(n,t)=>{if(J(t)){const r=Se(t),{range:o,unitId:s,subUnitId:c}=n,{ranges:[l],mapFunc:p}=S.virtualizeDiscreteRanges([o]),v=[],f=[];return a.Range.foreach(l,(d,C)=>{const{row:y,col:L}=p(d,C),I=this._hyperLinkModel.getHyperLinkByLocation(s,c,y,L);I&&v.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:I.id}});const M=a.Tools.generateRandomId();v.push({id:m.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:{id:M,row:y,column:L,payload:r}}}),f.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:M}}),I&&f.push({id:m.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:I}})}),{redos:v,undos:f}}return{undos:[],redos:[]}}})}_collect(n,t,r){const o=new a.ObjectMatrix;this._copyInfo={unitId:n,subUnitId:t,matrix:o};const s={get:this._injector.get.bind(this._injector)},c=S.rangeToDiscreteRange(r,s,n,t);if(!c)return;const{rows:l,cols:p}=c;l.forEach((v,f)=>{p.forEach((d,C)=>{var L;const y=this._hyperLinkModel.getHyperLinkByLocation(n,t,v,d);o.setValue(f,C,(L=y==null?void 0:y.id)!=null?L:"")})})}_generateMutations(n,t){if(!this._copyInfo)return{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!t.copyRange)return{redos:[],undos:[]};if([S.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,S.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,S.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,S.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(t.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:o}=this._copyInfo,s=[],c=[],{ranges:[l,p],mapFunc:v}=S.virtualizeDiscreteRanges([t.copyRange,n]);return S.getRepeatRange(l,p,!0).forEach(({startRange:d})=>{var C;(C=this._copyInfo)==null||C.matrix.forValue((y,L,I)=>{const M=a.Rectangle.getPositionRange({startRow:y,endRow:y,startColumn:L,endColumn:L},d),b=this._hyperLinkModel.getHyperLink(r,o,I),{row:T,col:$}=v(M.startRow,M.startColumn),E=this._hyperLinkModel.getHyperLinkByLocation(t.unitId,t.subUnitId,T,$),F=a.Tools.generateRandomId();E&&s.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:t.unitId,subUnitId:t.subUnitId,id:E.id}}),b&&(s.push({id:m.AddHyperLinkMutation.id,params:{unitId:t.unitId,subUnitId:t.subUnitId,link:{...b,id:F,row:T,column:$}}}),c.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:t.unitId,subUnitId:t.subUnitId,id:F}})),E&&c.push({id:m.AddHyperLinkMutation.id,params:{unitId:t.unitId,subUnitId:t.subUnitId,link:E}})})}),{redos:s,undos:c}}};exports.SheetsHyperLinkCopyPasteController=zt([a.OnLifecycle(a.LifecycleStages.Ready,exports.SheetsHyperLinkCopyPasteController),te(0,S.ISheetClipboardService),te(1,a.Inject(m.HyperLinkModel)),te(2,a.Inject(a.Injector)),te(3,a.Inject(exports.SheetsHyperLinkResolverService))],exports.SheetsHyperLinkCopyPasteController);var qt=Object.defineProperty,Zt=Object.getOwnPropertyDescriptor,Gt=(i,e,n,t)=>{for(var r=t>1?void 0:t?Zt(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&qt(e,n,r),r},Xt=(i,e)=>(n,t)=>e(n,t,i);exports.SheetHyperLinkUrlController=class extends a.Disposable{constructor(e){super(),this._resolverService=e,this._handleInitUrl()}_handleInitUrl(){const e=location.hash;e&&this._resolverService.parseHyperLink(e).handler()}};exports.SheetHyperLinkUrlController=Gt([a.OnLifecycle(a.LifecycleStages.Rendered,exports.SheetHyperLinkUrlController),Xt(0,a.Inject(exports.SheetsHyperLinkResolverService))],exports.SheetHyperLinkUrlController);var Jt=Object.defineProperty,Qt=Object.getOwnPropertyDescriptor,en=(i,e,n,t)=>{for(var r=t>1?void 0:t?Qt(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Jt(e,n,r),r},me=(i,e)=>(n,t)=>e(n,t,i);let re=class extends a.Disposable{constructor(i,e,n){super(),this._localeService=i,this._commandService=e,this._sheetPermissionInterceptorBaseController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(i=>{i.id===_e.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[u.WorkbookEditablePermission],rangeTypes:[u.RangeProtectionPermissionEditPoint],worksheetTypes:[u.WorksheetEditPermission,u.WorksheetSetCellValuePermission,u.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};re=en([a.OnLifecycle(a.LifecycleStages.Rendered,re),me(0,a.Inject(a.LocaleService)),me(1,a.ICommandService),me(2,a.Inject(S.SheetPermissionInterceptorBaseController))],re);var Ue=Object.defineProperty,tn=Object.getOwnPropertyDescriptor,nn=(i,e,n)=>e in i?Ue(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,rn=(i,e,n,t)=>{for(var r=t>1?void 0:t?tn(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Ue(e,n,r),r},Pe=(i,e)=>(n,t)=>e(n,t,i),je=(i,e,n)=>nn(i,typeof e!="symbol"?e+"":e,n);exports.UniverSheetsHyperLinkUIPlugin=class extends a.Plugin{constructor(e,n,t){super(),this._config=e,this._injector=n,this._renderManagerService=t}onStarting(e){[[exports.SheetsHyperLinkResolverService],[exports.SheetsHyperLinkPopupService],[exports.SheetsHyperLinkRemoveSheetController],[exports.SheetsHyperLinkRenderManagerController],[exports.SheetHyperLinkSetRangeController],[exports.SheetsHyperLinkPopupController],[exports.SheetsHyperLinkUIController,{useFactory:()=>this._injector.createInstance(exports.SheetsHyperLinkUIController,this._config)}],[exports.SheetsHyperLinkAutoFillController],[exports.SheetsHyperLinkCopyPasteController],[re],[exports.SheetHyperLinkUrlController]].forEach(t=>e.add(t))}onReady(){[[exports.SheetsHyperLinkRenderController]].forEach(n=>this._renderManagerService.registerRenderModule(a.UniverInstanceType.UNIVER_SHEET,n))}};je(exports.UniverSheetsHyperLinkUIPlugin,"pluginName",Le);je(exports.UniverSheetsHyperLinkUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsHyperLinkUIPlugin=rn([a.DependentOn(m.UniverSheetsHyperLinkPlugin),Pe(1,a.Inject(a.Injector)),Pe(2,ye.IRenderManagerService)],exports.UniverSheetsHyperLinkUIPlugin);exports.CloseHyperLinkSidebarOperation=Q;exports.InsertHyperLinkOperation=le;exports.InsertLinkShortcut=_e;exports.OpenHyperLinkSidebarOperation=ce;
9
+ */var Ze=L,Ge=Symbol.for("react.element"),Xe=Symbol.for("react.fragment"),Je=Object.prototype.hasOwnProperty,Qe=Ze.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,et={key:!0,ref:!0,__self:!0,__source:!0};function Me(i,e,n){var t,r={},o=null,s=null;n!==void 0&&(o=""+n),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(s=e.ref);for(t in e)Je.call(e,t)&&!et.hasOwnProperty(t)&&(r[t]=e[t]);if(i&&i.defaultProps)for(t in e=i.defaultProps,e)r[t]===void 0&&(r[t]=e[t]);return{$$typeof:Ge,type:i,key:o,ref:s,props:r,_owner:Qe.current}}de.Fragment=Xe;de.jsx=Me;de.jsxs=Me;Oe.exports=de;var h=Oe.exports,x=function(){return x=Object.assign||function(i){for(var e,n=1,t=arguments.length;n<t;n++){e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=e[r])}return i},x.apply(this,arguments)},tt=function(i,e){var n={};for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&e.indexOf(t)<0&&(n[t]=i[t]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(i);r<t.length;r++)e.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(i,t[r])&&(n[t[r]]=i[t[r]]);return n},Y=L.forwardRef(function(i,e){var n=i.icon,t=i.id,r=i.className,o=i.extend,s=tt(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(t," ").concat(r||"").trim(),l=L.useRef("_".concat(it()));return we(n,"".concat(t),{defIds:n.defIds,idSuffix:l.current},x({ref:e,className:c},s),o)});function we(i,e,n,t,r){return L.createElement(i.tag,x(x({key:e},nt(i,n,r)),t),(rt(i,n).children||[]).map(function(o,s){return we(o,"".concat(e,"-").concat(i.tag,"-").concat(s),n,void 0,r)}))}function nt(i,e,n){var t=x({},i.attrs);n!=null&&n.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=n.colorChannel1);var r=e.defIds;return!r||r.length===0||(i.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(function(o){var s=o[0],c=o[1];typeof c=="string"&&(t[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),t}function rt(i,e){var n,t=e.defIds;return!t||t.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?x(x({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&t&&t.indexOf(r.attrs.id)>-1?x(x({},r),{attrs:x(x({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):i}function it(){return Math.random().toString(36).substring(2,8)}Y.displayName="UniverIcon";var ot={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ie=L.forwardRef(function(i,e){return L.createElement(Y,Object.assign({},i,{id:"all-border-single",ref:e,icon:ot}))});ie.displayName="AllBorderSingle";var st={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.02547 12.4251C5.15328 13.7417 6.26305 14.7708 7.61318 14.7708H12.6132C14.0491 14.7708 15.2132 13.6067 15.2132 12.1708V6.1708C15.2132 4.78586 14.1303 3.65383 12.7651 3.57517C12.6373 2.25858 11.5275 1.22949 10.1774 1.22949H5.17739C3.74145 1.22949 2.57739 2.39355 2.57739 3.82949V9.82949C2.57739 11.2144 3.66024 12.3465 5.02547 12.4251ZM11.5535 3.5708H7.61318C6.17724 3.5708 5.01318 4.73486 5.01318 6.1708V11.22C4.31736 11.1387 3.77739 10.5471 3.77739 9.82949V3.82949C3.77739 3.05629 4.40419 2.42949 5.17739 2.42949H10.1774C10.8622 2.42949 11.4322 2.92119 11.5535 3.5708ZM14.0132 6.1708C14.0132 5.3976 13.3864 4.7708 12.6132 4.7708H7.61318C6.83998 4.7708 6.21318 5.3976 6.21318 6.1708V12.1708C6.21318 12.944 6.83998 13.5708 7.61318 13.5708H12.6132C13.3864 13.5708 14.0132 12.944 14.0132 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Te=L.forwardRef(function(i,e){return L.createElement(Y,Object.assign({},i,{id:"copy-single",ref:e,icon:st}))});Te.displayName="CopySingle";var at={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332",fillRule:"evenodd",clipRule:"evenodd"}}]},ae=L.forwardRef(function(i,e){return L.createElement(Y,Object.assign({},i,{id:"link-single",ref:e,icon:at}))});ae.displayName="LinkSingle";var ct={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z"}}]},Ue=L.forwardRef(function(i,e){return L.createElement(Y,Object.assign({},i,{id:"unlink-single",ref:e,icon:ct}))});Ue.displayName="UnlinkSingle";var lt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},je=L.forwardRef(function(i,e){return L.createElement(Y,Object.assign({},i,{id:"write-single",ref:e,icon:lt}))});je.displayName="WriteSingle";var dt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#35BD4B",d:"M3.36396 1.12549C2.61066 1.12549 2 1.73615 2 2.48945V13.5104C2 14.2637 2.61066 14.8744 3.36396 14.8744H12.457C13.2103 14.8744 13.821 14.2637 13.821 13.5104V5.0992L9.91954 1.12549H3.36396Z"}},{tag:"path",attrs:{fill:"#32A846",d:"M9.91797 1.12549L13.8209 5.09842H10.5846C10.2164 5.09842 9.91797 4.79994 9.91797 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.71926 10.2949L6.28687 12.403C6.17306 12.5705 5.94501 12.614 5.77751 12.5002C5.61002 12.3864 5.56649 12.1584 5.6803 11.9909L7.27596 9.64252L5.85088 7.54519C5.73707 7.37769 5.78059 7.14964 5.94809 7.03583C6.11558 6.92202 6.34363 6.96555 6.45744 7.13304L7.71926 8.9901L8.98108 7.13304C9.09489 6.96555 9.32294 6.92202 9.49044 7.03583C9.65793 7.14964 9.70146 7.37769 9.58765 7.54519L8.16256 9.64252L9.75822 11.9909C9.87203 12.1584 9.82851 12.3864 9.66101 12.5002C9.49351 12.614 9.26547 12.5705 9.15166 12.403L7.71926 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Se=L.forwardRef(function(i,e){return L.createElement(Y,Object.assign({},i,{id:"xlsx",ref:e,icon:dt}))});Se.displayName="Xlsx";var pt=Object.defineProperty,ut=Object.getOwnPropertyDescriptor,ht=(i,e,n,t)=>{for(var r=t>1?void 0:t?ut(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&pt(e,n,r),r},J=(i,e)=>(n,t)=>e(n,t,i);function mt(i,e){const n=e.getMergeData(),t=e.getMaxColumns()-1,r=e.getMaxRows()-1;if(t<i.endColumn&&(i.endColumn=t),r<i.endRow&&(i.endRow=r),i.rangeType===a.RANGE_TYPE.COLUMN||a.RANGE_TYPE.ROW)return i;const o=[];return n.forEach(s=>{a.Rectangle.intersects(i,s)&&o.push(s)}),a.Rectangle.realUnion(i,...o)}exports.SheetsHyperLinkResolverService=class{constructor(e,n,t,r,o){this._univerInstanceService=e,this._commandService=n,this._definedNamesService=t,this._messageService=r,this._localeService=o}_getURLName(e){var l;const{gid:n,range:t,rangeid:r}=e,o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!o)return null;const s=n?o.getSheetBySheetId(n):o.getActiveSheet(),c=(l=s==null?void 0:s.getName())!=null?l:"";if(t){const p=$.deserializeRangeWithSheet(t).range;return a.isValidRange(p)&&t!==m.ERROR_RANGE?{type:"range",name:$.serializeRangeWithSheet(c,p)}:{type:"range-error",name:this._localeService.t("hyperLink.message.refError")}}if(r){const p=this._definedNamesService.getValueById(o.getUnitId(),r);return p?{type:"defineName",name:p.formulaOrRefString}:{type:"range-error",name:this._localeService.t("hyperLink.message.refError")}}if(n){const p=o.getSheetBySheetId(n);return p?{type:"sheet",name:p.getName()}:{type:"sheet-error",name:this._localeService.t("hyperLink.message.refError")}}return null}navigateTo(e){const{gid:n,range:t,rangeid:r}=e,o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!o)return;const s=o.getUnitId();if(r&&this.navigateToDefineName(s,r),!!n){if(t){const c=$.deserializeRangeWithSheet(t);a.isValidRange(c.range)&&t!==m.ERROR_RANGE&&this.navigateToRange(s,n,c.range);return}this.navigateToSheetById(s,n)}}parseHyperLink(e){var n,t,r;if(e!=null&&e.startsWith("#")){const o=new URLSearchParams(e.slice(1)),s={gid:(n=o.get("gid"))!=null?n:"",range:(t=o.get("range"))!=null?t:"",rangeid:(r=o.get("rangeid"))!=null?r:""},c=this._getURLName(s);return{type:(c==null?void 0:c.type)||"link",name:(c==null?void 0:c.name)||e,url:e,searchObj:s,handler:()=>{this.navigateTo(s)}}}else return{type:"outer",name:e,url:e,handler:()=>{this.navigateToOtherWebsite(e)}}}async navigateToRange(e,n,t){const r=await this.navigateToSheetById(e,n);if(r){const o=mt(t,r);await this._commandService.executeCommand(u.SetSelectionsOperation.id,{unitId:e,subUnitId:n,selections:[{range:o}]}),await this._commandService.executeCommand(f.ScrollToRangeOperation.id,{range:o})}}async navigateToSheet(e,n){const t=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET);if(!t)return!1;const r=t.getActiveSheet();if((r==null?void 0:r.getName())===n)return!0;const o=t.getSheetBySheetName(n);if(!o){this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:I.MessageType.Error});return}const s=o.getSheetId();return t.getHiddenWorksheets().indexOf(s)>-1&&this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:I.MessageType.Error}),await this._commandService.executeCommand(u.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:s})}async navigateToSheetById(e,n){const t=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET);if(!t)return!1;const r=t.getActiveSheet();if(!r)return!1;if(r.getSheetId()===n)return r;const o=t.getSheetBySheetId(n);return o?t.getHiddenWorksheets().indexOf(n)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:I.MessageType.Error}),!1):await this._commandService.executeCommand(u.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:n})?o:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:I.MessageType.Error}),!1)}async navigateToDefineName(e,n){return this._definedNamesService.focusRange(e,n),!0}async navigateToOtherWebsite(e){window.open(e,"_blank","noopener noreferrer")}};exports.SheetsHyperLinkResolverService=ht([J(0,a.IUniverInstanceService),J(1,a.ICommandService),J(2,$.IDefinedNamesService),J(3,E.IMessageService),J(4,y.Inject(a.LocaleService))],exports.SheetsHyperLinkResolverService);function ee(i){return a.Tools.isLegalUrl(i)}function gt(i){return/^[a-zA-Z]+:\/\//.test(i)}function vt(i){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(i)}function _e(i){if(ee(i)){const e=gt(i)?i:vt(i)?`mailto://${i}`:`http://${i}`,n=new URL(e);return n.hostname===location.hostname&&n.port===location.port&&n.protocol===location.protocol&&n.pathname===location.pathname&&n.hash&&!n.search?n.hash:e}return i}function yt(i){if(i===null)return"";if(i!=null&&i.p){const e=i==null?void 0:i.p.body;if(e==null)return"";const n=e.dataStream;return n.substring(n.length-2,n.length)===a.DEFAULT_EMPTY_DOCUMENT_VALUE?n.substring(0,n.length-2):n}return i==null?void 0:i.v}const St="univer-cell-link-edit-buttons",ft={cellLinkEditButtons:St},ce=()=>{var X;const[i,e]=L.useState(""),[n,t]=L.useState(""),[r,o]=L.useState("link"),[s,c]=L.useState(""),l=U.useDependency(a.LocaleService),p=U.useDependency($.IDefinedNamesService),v=U.useDependency(a.IUniverInstanceService),_=U.useDependency(exports.SheetsHyperLinkPopupService),d=E.useObservable(_.currentEditing$),k=U.useDependency(m.HyperLinkModel),S=U.useDependency(exports.SheetsHyperLinkResolverService),C=U.useDependency(a.ICommandService),[R,w]=L.useState(!1),H=L.useRef(!1);L.useEffect(()=>{var g,P,M;if((d==null?void 0:d.row)!==void 0&&d.column!==void 0){const b=k.getHyperLinkByLocationSync(d.unitId,d.subUnitId,d.row,d.column);if(b){const ne=S.parseHyperLink(b.payload);if(e(b.id),t(b.display),ne.type==="outer"){o("link"),c(ne.url),ne.url===b.display&&(H.current=!0);return}else{const A=ne.searchObj;if(A.rangeid){o("rangeid"),c(A.rangeid);return}if(A.range){const $e=A.gid&&(M=(P=(g=v.getUnit(d.unitId))==null?void 0:g.getSheetBySheetId(A.gid))==null?void 0:P.getName())!=null?M:"";if(o("range"),A.range===m.ERROR_RANGE)c("");else{const Ie=$.serializeRangeWithSheet($e,$.deserializeRangeWithSheet(A.range).range);c(Ie),Ie===b.display&&(H.current=!0)}return}if(A.gid){o("gid"),c(A.gid);return}}}const T=v.getUnit(d.unitId),N=T==null?void 0:T.getSheetBySheetId(d.subUnitId),De=N==null?void 0:N.getCellRaw(d.row,d.column),ge=yt(De);o("link"),c(""),t((ge!=null?ge:"").toString()),e("");return}o("link"),c(""),t(""),e("")},[d,k,S,v]);const j=L.useMemo(()=>s,[r]),V=[{label:l.t("hyperLink.form.link"),value:"link"},{label:l.t("hyperLink.form.range"),value:"range"},{label:l.t("hyperLink.form.worksheet"),value:"gid"},{label:l.t("hyperLink.form.definedName"),value:"rangeid"}],O=v.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!O)return;const q=O.getHiddenWorksheets(),B=O.getSheets().map(g=>({label:g.getName(),value:g.getSheetId()})).filter(g=>q.indexOf(g.value)===-1),W=Object.values((X=p.getDefinedNameMap(O.getUnitId()))!=null?X:{}).map(g=>({label:g.name,value:g.id})),G=(g,P)=>{if(g==="link")return _e(P);if(g==="range"){const M=$.deserializeRangeWithSheet(P),b=O.getSheetBySheetName(M.sheetName);if(b)return`#gid=${b.getSheetId()}&range=${$.serializeRange(M.range)}`}return`#${g}=${P}`},he=E.useEvent(g=>{var b;const P=g[0];if(!P||!a.isValidRange(P.range))return;P.sheetName||(P.sheetName=((b=O.getActiveSheet())==null?void 0:b.getName())||"");const M=$.serializeRangeToRefString(P);c(M),M&&(H.current||!n)&&(t(M),H.current=!0)}),me=async()=>{if(d&&(i?await C.executeCommand(m.UpdateHyperLinkCommand.id,{unitId:d.unitId,subUnitId:d.subUnitId,id:i,payload:{display:n,payload:G(r,s)}}):await C.executeCommand(m.AddHyperLinkCommand.id,{unitId:d.unitId,subUnitId:d.subUnitId,link:{id:a.Tools.generateRandomId(),row:d.row,column:d.column,payload:G(r,s),display:n}})),d){await C.executeCommand(u.SetWorksheetActiveOperation.id,{unitId:d.unitId,subUnitId:d.subUnitId});const g=1;await C.executeCommand(f.ScrollToRangeOperation.id,{range:{startRow:Math.max(d.row-g,0),endRow:d.row+g,startColumn:Math.max(d.column-g,0),endColumn:d.column+g}})}C.executeCommand(te.id)};return h.jsxs("div",{children:[h.jsx(I.FormLayout,{label:l.t("hyperLink.form.label"),error:R&&!n?l.t("hyperLink.form.inputError"):"",children:h.jsx(I.Input,{value:n,onChange:g=>{t(g),H.current=!1},placeholder:l.t("hyperLink.form.labelPlaceholder")})}),h.jsx(I.FormLayout,{label:l.t("hyperLink.form.type"),children:h.jsx(I.Select,{options:V,value:r,onChange:g=>{o(g),c("")}})}),r==="link"&&h.jsx(I.FormLayout,{error:R?s?ee(s)?"":l.t("hyperLink.form.linkError"):l.t("hyperLink.form.inputError"):"",children:h.jsx(I.Input,{value:s,onChange:g=>{c(g),g&&(H.current||!n||n===s)&&(t(g),H.current=!0)},placeholder:l.t("hyperLink.form.linkPlaceholder")})}),r==="range"&&h.jsx(I.FormLayout,{error:R&&!s?l.t("hyperLink.form.inputError"):"",children:h.jsx(E.RangeSelector,{openForSheetUnitId:O.getUnitId(),id:a.createInternalEditorID("hyper-link-edit"),isSingleChoice:!0,value:j,onChange:he})}),r==="gid"&&h.jsx(I.FormLayout,{error:R&&!s?l.t("hyperLink.form.selectError"):"",children:h.jsx(I.Select,{options:B,value:s,onChange:g=>{var b,T;c(g);const P=(b=B.find(N=>N.value===g))==null?void 0:b.label,M=(T=B.find(N=>N.value===s))==null?void 0:T.label;P&&(H.current||!n||n===M)&&(t(P),H.current=!0)}})}),r==="rangeid"&&h.jsx(I.FormLayout,{error:R&&!s?l.t("hyperLink.form.selectError"):"",children:h.jsx(I.Select,{options:W,value:s,onChange:g=>{var b,T;c(g);const P=(b=W.find(N=>N.value===g))==null?void 0:b.label,M=(T=W.find(N=>N.value===s))==null?void 0:T.label;P&&(H.current||!n||n===M)&&(t(P),H.current=!0)}})}),h.jsxs("div",{className:ft.cellLinkEditButtons,children:[h.jsx(I.Button,{onClick:()=>{d&&C.executeCommand(u.SetWorksheetActiveOperation.id,{unitId:d.unitId,subUnitId:d.subUnitId}),C.executeCommand(te.id)},children:l.t("hyperLink.form.cancel")}),h.jsx(I.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{if(!n||!s||r==="link"&&!ee(s)){w(!0);return}me()},children:l.t("hyperLink.form.ok")})]})]})};ce.componentKey="univer.sheet.cell-link-edit";const pe={type:a.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-sidebar",handler(i,e){if(!e)return!1;const{unitId:n,subUnitId:t,row:r,column:o}=e,s=i.get(m.HyperLinkModel),c=i.get(E.ISidebarService),l=i.get(exports.SheetsHyperLinkPopupService),p=s.getHyperLinkByLocation(n,t,r,o);return l.startEditing(e),c.open({header:{title:p?"hyperLink.form.editTitle":"hyperLink.form.addTitle"},children:{label:ce.componentKey}}),!0}},te={type:a.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-sidebar",handler(i){const e=i.get(E.ISidebarService),n=i.get(exports.SheetsHyperLinkPopupService);return e.close(),n.endEditing(),!0}},ue={type:a.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(i){const e=i.get(a.IUniverInstanceService),n=u.getSheetCommandTarget(e);if(!n)return!1;const t=i.get(a.ICommandService),o=i.get(u.SheetsSelectionsService).getCurrentLastSelection();if(!o)return!1;const s=o.primary.startRow,c=o.primary.startColumn;return t.executeCommand(pe.id,{unitId:n.unitId,subUnitId:n.subUnitId,row:s,column:c})}},Le={type:a.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(i){const e=i.get(a.ICommandService);return i.get(exports.SheetsHyperLinkPopupService).currentEditing?e.executeCommand(te.id):e.executeCommand(ue.id)}},_t="univer-cell-link",Lt="univer-cell-link-type",Ct="univer-cell-link-content",kt="univer-cell-link-content-error",It="univer-cell-link-url",Rt="univer-cell-link-operations",Pt="univer-cell-link-operation",bt="univer-cell-link-operation-error",D={cellLink:_t,cellLinkType:Lt,cellLinkContent:Ct,cellLinkContentError:kt,cellLinkUrl:It,cellLinkOperations:Rt,cellLinkOperation:Pt,cellLinkOperationError:bt},Ht={outer:h.jsx(ae,{}),link:h.jsx(ae,{}),sheet:h.jsx(Se,{}),range:h.jsx(ie,{}),defineName:h.jsx(ie,{}),"range-error":h.jsx(ie,{}),"sheet-error":h.jsx(Se,{})},le=()=>{const i=U.useDependency(exports.SheetsHyperLinkPopupService),e=U.useDependency(m.HyperLinkModel),n=U.useDependency(a.ICommandService),t=U.useDependency(E.IMessageService),r=U.useDependency(a.LocaleService),[o,s]=L.useState(null),c=U.useDependency(exports.SheetsHyperLinkResolverService);if(L.useEffect(()=>{s(i.currentPopup);const S=i.currentPopup$.subscribe(C=>{s(C)});return()=>{S.unsubscribe()}},[i.currentPopup,i.currentPopup$]),!o)return null;const{unitId:l,subUnitId:p,id:v}=o,_=e.getHyperLink(l,p,v);if(!_)return null;const d=c.parseHyperLink(_.payload),k=d.type.indexOf("error")>-1;return h.jsxs("div",{className:D.cellLink,onClick:()=>i.hideCurrentPopup(),children:[h.jsxs("div",{className:Re(D.cellLinkContent,{[D.cellLinkContentError]:k}),onClick:d.handler,children:[h.jsx("div",{className:D.cellLinkType,children:Ht[d.type]}),h.jsx(I.Tooltip,{showIfEllipsis:!0,title:d.name,children:h.jsx("span",{className:D.cellLinkUrl,children:d.name})})]}),h.jsxs("div",{className:D.cellLinkOperations,children:[o.copyPermission&&h.jsx("div",{className:Re(D.cellLinkOperation,{[D.cellLinkOperationError]:k}),onClick:()=>{if(!k){if(d.type!=="outer"){const S=new URL(window.location.href);S.hash=d.url.slice(1),navigator.clipboard.writeText(S.href)}else navigator.clipboard.writeText(d.url);t.show({content:r.t("hyperLink.message.coped"),type:I.MessageType.Info})}},children:h.jsx(I.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:h.jsx(Te,{})})}),o.editPermission&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:D.cellLinkOperation,onClick:()=>{n.executeCommand(pe.id,{unitId:l,subUnitId:p,row:_.row,column:_.column})},children:h.jsx(I.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:h.jsx(je,{})})}),h.jsx("div",{className:D.cellLinkOperation,onClick:()=>{n.executeCommand(m.CancelHyperLinkCommand.id,{unitId:l,subUnitId:p,id:_.id})},children:h.jsx(I.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:h.jsx(Ue,{})})})]})]})]})};le.componentKey="univer.sheet.cell-link-popup";var Et=Object.defineProperty,Ot=Object.getOwnPropertyDescriptor,Mt=(i,e,n,t)=>{for(var r=t>1?void 0:t?Ot(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Et(e,n,r),r},Pe=(i,e)=>(n,t)=>e(n,t,i);const wt=(i,e)=>i.unitId===e.unitId&&i.subUnitId===e.subUnitId&&i.row===e.row&&i.col===e.col;exports.SheetsHyperLinkPopupService=class extends a.Disposable{constructor(n,t){super();F(this,"_currentPopup",null);F(this,"_currentPopup$",new se.Subject);F(this,"currentPopup$",this._currentPopup$.asObservable());F(this,"_currentEditing$",new se.BehaviorSubject(null));F(this,"currentEditing$",this._currentEditing$.asObservable());this._hyperLinkModel=n,this._sheetCanvasPopManagerService=t,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}showPopup(n){if(this._currentPopup&&wt(n,this._currentPopup))return;this.hideCurrentPopup();const{unitId:t,subUnitId:r,row:o,col:s}=n,c=this._hyperLinkModel.getHyperLinkByLocation(t,r,o,s);if(!c)return;const l=this._sheetCanvasPopManagerService.attachPopupToCell(o,s,{componentKey:le.componentKey,direction:"bottom",closeOnSelfTarget:!0,onClickOutside:()=>{this.hideCurrentPopup()}});l&&(this._currentPopup={unitId:t,subUnitId:r,id:c.id,disposable:l,row:o,col:s,editPermission:!!n.editPermission,copyPermission:!!n.copyPermission},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(){var n;this._currentPopup&&((n=this._currentPopup.disposable)==null||n.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}startEditing(n){this._currentEditing$.next(n)}endEditing(){this._currentEditing$.next(null)}};exports.SheetsHyperLinkPopupService=Mt([Pe(0,y.Inject(m.HyperLinkModel)),Pe(1,y.Inject(f.SheetCanvasPopManagerService))],exports.SheetsHyperLinkPopupService);var Tt=Object.defineProperty,Ut=Object.getOwnPropertyDescriptor,jt=(i,e,n,t)=>{for(var r=t>1?void 0:t?Ut(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Tt(e,n,r),r},K=(i,e)=>(n,t)=>e(n,t,i);exports.SheetHyperLinkSetRangeController=class extends a.Disposable{constructor(e,n,t,r,o,s){super(),this._sheetInterceptorService=e,this._injector=n,this._hyperLinkModel=t,this._selectionManagerService=r,this._univerInstanceService=o,this._editorBridgeService=s,this._initCommandInterceptor()}_initCommandInterceptor(){this._initAddHyperLinkCommandInterceptor(),this._initSetRangeValuesCommandInterceptor(),this._initUpdateHyperLinkCommandInterceptor(),this._initClearSelectionCommandInterceptor(),this._initRichTextEditorInterceptor()}_getCurrentCell(e,n,t,r){var o,s;return(s=(o=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET))==null?void 0:o.getSheetBySheetId(n))==null?void 0:s.getCell(t,r)}_initAddHyperLinkCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var n;if(e.id===m.AddHyperLinkCommand.id){const t=e.params,{unitId:r,subUnitId:o,link:s}=t,c=this._getCurrentCell(r,o,s.row,s.column),l={unitId:r,subUnitId:o,cellValue:{[s.row]:{[s.column]:{v:s.display,p:null,t:(n=c==null?void 0:c.t)!=null?n:void 0}}}};return{redos:[{id:u.SetRangeValuesMutation.id,params:l}],undos:[{id:u.SetRangeValuesMutation.id,params:u.SetRangeValuesUndoMutationFactory(this._injector,l)}]}}return{redos:[],undos:[]}}}))}_initUpdateHyperLinkCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===m.UpdateHyperLinkCommand.id){const n=e.params,{unitId:t,subUnitId:r,id:o,payload:s}=n,c=this._hyperLinkModel.getHyperLink(t,r,o);if(c&&c.display!==s.display){const l={unitId:t,subUnitId:r,cellValue:{[c.row]:{[c.column]:{v:s.display,t:a.CellValueType.STRING,p:null}}}};return{redos:[{id:u.SetRangeValuesMutation.id,params:l}],undos:[{id:u.SetRangeValuesMutation.id,params:u.SetRangeValuesUndoMutationFactory(this._injector,l)}]}}}return{redos:[],undos:[]}}}))}_initSetRangeValuesCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===u.SetRangeValuesCommand.id){const n=e.params,{unitId:t,subUnitId:r}=n,o=[],s=[];return n.cellValue&&new a.ObjectMatrix(n.cellValue).forValue((c,l,p)=>{var k,S,C,R,w,H,j;const v=(C=p==null?void 0:p.v)!=null?C:(S=(k=p==null?void 0:p.p)==null?void 0:k.body)==null?void 0:S.dataStream.slice(0,-2),_=(v!=null?v:"").toString(),d=this._hyperLinkModel.getHyperLinkByLocation(t,r,c,l);if(!d){if(ee(_)||(R=p==null?void 0:p.custom)!=null&&R.__link_url){const V=(H=(w=p==null?void 0:p.custom)==null?void 0:w.__link_url)!=null?H:_,O=a.Tools.generateRandomId();s.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:t,subUnitId:r,id:O}}),o.push({id:m.AddHyperLinkMutation.id,params:{unitId:t,subUnitId:r,link:{id:O,row:c,column:l,display:_,payload:_e(V)}}})}return}(v===""||((j=p==null?void 0:p.custom)==null?void 0:j.__link_url)==="")&&(o.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:t,subUnitId:r,id:d.id}}),s.push({id:m.AddHyperLinkMutation.id,params:{unitId:t,subUnitId:r,link:d}}))}),{undos:s,redos:o}}return{redos:[],undos:[]}}}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===u.ClearSelectionContentCommand.id||e.id===u.ClearSelectionAllCommand.id||e.id===u.ClearSelectionFormatCommand.id){const n=[],t=[],r=this._selectionManagerService.getCurrentLastSelection(),o=u.getSheetCommandTarget(this._univerInstanceService);if(r&&o){const{unitId:s,subUnitId:c}=o;a.Range.foreach(r.range,(l,p)=>{const v=this._hyperLinkModel.getHyperLinkByLocation(s,c,l,p);v&&(n.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:v.id}}),t.push({id:m.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:v}}))})}return{redos:n,undos:t}}return{redos:[],undos:[]}}}))}_initRichTextEditorInterceptor(){this.disposeWithMe(this._editorBridgeService.interceptor.intercept(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT,{handler:(e,n,t)=>{var r,o,s,c,l,p;if(e!=null&&e.p){const v=(o=(r=e.p.body)==null?void 0:r.customRanges)==null?void 0:o.find(d=>d.rangeType===a.CustomRangeType.HYPERLINK),_=(s=e.p.resources)==null?void 0:s.find(d=>d.name===Be.DOC_HYPER_LINK_PLUGIN);if(v&&_){const d=v.rangeId,k=(p=(l=(c=JSON.parse(_.data))==null?void 0:c.links)==null?void 0:l.find(S=>S.id===d))==null?void 0:p.payload;return t({...e,p:null,v:We.getPlainTextFormDocument(e.p),t:a.CellValueType.STRING,custom:{__link_url:k}})}}return t(e)}}))}};exports.SheetHyperLinkSetRangeController=jt([a.OnLifecycle(a.LifecycleStages.Starting,exports.SheetHyperLinkSetRangeController),K(0,y.Inject(u.SheetInterceptorService)),K(1,y.Inject(y.Injector)),K(2,y.Inject(m.HyperLinkModel)),K(3,y.Inject(u.SheetsSelectionsService)),K(4,a.IUniverInstanceService),K(5,f.IEditorBridgeService)],exports.SheetHyperLinkSetRangeController);var xt=Object.defineProperty,Nt=Object.getOwnPropertyDescriptor,Dt=(i,e,n,t)=>{for(var r=t>1?void 0:t?Nt(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&xt(e,n,r),r},Q=(i,e)=>(n,t)=>e(n,t,i);exports.SheetsHyperLinkPopupController=class extends a.Disposable{constructor(e,n,t,r,o){super(),this._hoverManagerService=e,this._sheetsHyperLinkPopupService=n,this._renderManagerService=t,this._permissionService=r,this._sheetPermissionInterceptorBaseController=o,this._initHoverListener()}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(se.debounceTime(100)).subscribe(e=>{var d,k;if(!e){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const n=(k=(d=this._renderManagerService.getRenderById(e.location.unitId))==null?void 0:d.with(f.SheetSkeletonManagerService).getWorksheetSkeleton(e.location.subUnitId))==null?void 0:k.skeleton,t=e.location.col,r=e.location.row;let o=r,s=t;if(n&&n.overflowCache.forValue((S,C,R)=>{a.Rectangle.contains(R,{startColumn:t,endColumn:t,startRow:r,endRow:r})&&(o=S,s=C)}),!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[u.WorkbookViewPermission],worksheetTypes:[u.WorksheetViewPermission],rangeTypes:[u.RangeProtectionPermissionViewPoint]},[{startRow:r,startColumn:t,endRow:r,endColumn:t}])){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const l=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetEditPermission,u.WorksheetInsertHyperlinkPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]},[{startRow:r,startColumn:t,endRow:r,endColumn:t}]),p=e.location.unitId,v=e.location.subUnitId,_=this._permissionService.composePermission([new u.WorkbookCopyPermission(p).id,new u.WorksheetCopyPermission(p,v).id]).every(S=>S.value);this._sheetsHyperLinkPopupService.showPopup({...e.location,row:o,col:s,editPermission:l,copyPermission:_})}))}};exports.SheetsHyperLinkPopupController=Dt([a.OnLifecycle(a.LifecycleStages.Rendered,exports.SheetsHyperLinkPopupController),Q(0,y.Inject(f.HoverManagerService)),Q(1,y.Inject(exports.SheetsHyperLinkPopupService)),Q(2,y.Inject(fe.IRenderManagerService)),Q(3,y.Inject(a.IPermissionService)),Q(4,y.Inject(f.SheetPermissionInterceptorBaseController))],exports.SheetsHyperLinkPopupController);const $t=i=>({id:ue.id,type:E.MenuItemType.BUTTON,positions:[E.MenuPosition.CONTEXT_MENU],title:"hyperLink.menu.add",hidden$:E.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),icon:"LinkSingle",disabled$:f.getCurrentRangeDisable$(i,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetEditPermission,u.WorksheetSetCellValuePermission,u.WorksheetInsertHyperlinkPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}),At=i=>({tooltip:"hyperLink.form.addTitle",positions:E.MenuPosition.TOOLBAR_START,group:E.MenuGroup.TOOLBAR_OTHERS,id:Le.id,type:E.MenuItemType.BUTTON,icon:"LinkSingle",hidden$:E.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:f.getCurrentRangeDisable$(i,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetEditPermission,u.WorksheetSetCellValuePermission,u.WorksheetInsertHyperlinkPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}),Ce={id:Le.id,binding:E.KeyCode.K|E.MetaKeys.CTRL_COMMAND,preconditions:f.whenSheetEditorFocused};var Vt=Object.defineProperty,Bt=Object.getOwnPropertyDescriptor,Wt=(i,e,n,t)=>{for(var r=t>1?void 0:t?Bt(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Vt(e,n,r),r},z=(i,e)=>(n,t)=>e(n,t,i);exports.SheetsHyperLinkUIController=class extends a.Disposable{constructor(e,n,t,r,o,s,c){super(),this._config=e,this._componentManager=n,this._commandService=t,this._localeService=r,this._menuService=o,this._injector=s,this._shortcutService=c,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[le,le.componentKey],[ce,ce.componentKey],[ae,"LinkSingle"]].forEach(([e,n])=>{this._componentManager.register(n,e)})}_initCommands(){[pe,te,ue,Le].forEach(e=>{this._commandService.registerCommand(e)})}_initMenus(){var e,n,t,r;this._menuService.addMenuItem($t(this._injector),(n=(e=this._config)==null?void 0:e.menu)!=null?n:{}),this._menuService.addMenuItem(At(this._injector),(r=(t=this._config)==null?void 0:t.menu)!=null?r:{})}_initShortCut(){this._shortcutService.registerShortcut(Ce)}};exports.SheetsHyperLinkUIController=Wt([a.OnLifecycle(a.LifecycleStages.Ready,exports.SheetsHyperLinkUIController),z(1,y.Inject(E.ComponentManager)),z(2,a.ICommandService),z(3,y.Inject(a.LocaleService)),z(4,E.IMenuService),z(5,y.Inject(y.Injector)),z(6,y.Inject(E.IShortcutService))],exports.SheetsHyperLinkUIController);const ke="SHEET_HYPER_LINK_UI_PLUGIN";var Ft=Object.defineProperty,Yt=Object.getOwnPropertyDescriptor,qt=(i,e,n,t)=>{for(var r=t>1?void 0:t?Yt(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Ft(e,n,r),r},be=(i,e)=>(n,t)=>e(n,t,i);exports.SheetsHyperLinkAutoFillController=class extends a.Disposable{constructor(e,n){super(),this._autoFillService=e,this._hyperLinkModel=n,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),n=(r,o)=>{const{source:s,target:c,unitId:l,subUnitId:p}=r,v=f.virtualizeDiscreteRanges([s,c]),[_,d]=v.ranges,{mapFunc:k}=v,S={row:_.startRow,col:_.startColumn},C=f.getAutoFillRepeatRange(_,d),R=[],w=[];return C.forEach(H=>{const j=H.repeatStartCell,V=H.relativeRange,O={startRow:S.row,startColumn:S.col,endColumn:S.col,endRow:S.row},q={startRow:j.row,startColumn:j.col,endColumn:j.col,endRow:j.row};a.Range.foreach(V,(B,W)=>{const G=a.Rectangle.getPositionRange({startRow:B,startColumn:W,endColumn:W,endRow:B},O),{row:he,col:me}=k(G.startRow,G.startColumn),X=this._hyperLinkModel.getHyperLinkByLocation(l,p,he,me);if(X){const g=a.Rectangle.getPositionRange({startRow:B,startColumn:W,endColumn:W,endRow:B},q),{row:P,col:M}=k(g.startRow,g.startColumn),b=a.Tools.generateRandomId(),T=this._hyperLinkModel.getHyperLinkByLocation(l,p,P,M);T&&R.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:p,id:T.id}}),(f.APPLY_TYPE.COPY===o||f.APPLY_TYPE.SERIES===o)&&(R.push({id:m.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:p,link:{...X,id:b,row:P,column:M}}}),w.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:p,id:b}})),T&&w.push({id:m.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:p,link:T}})}})}),{undos:w,redos:R}},t={id:ke,onFillData:(r,o,s)=>s===f.APPLY_TYPE.COPY||s===f.APPLY_TYPE.ONLY_FORMAT||s===f.APPLY_TYPE.SERIES?n(r,s):e()};this.disposeWithMe(this._autoFillService.addHook(t))}};exports.SheetsHyperLinkAutoFillController=qt([a.OnLifecycle(a.LifecycleStages.Ready,exports.SheetsHyperLinkAutoFillController),be(0,f.IAutoFillService),be(1,y.Inject(m.HyperLinkModel))],exports.SheetsHyperLinkAutoFillController);var Kt=Object.defineProperty,zt=Object.getOwnPropertyDescriptor,Zt=(i,e,n,t)=>{for(var r=t>1?void 0:t?zt(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Kt(e,n,r),r},re=(i,e)=>(n,t)=>e(n,t,i);exports.SheetsHyperLinkCopyPasteController=class extends a.Disposable{constructor(n,t,r,o){super();F(this,"_copyInfo");this._sheetClipboardService=n,this._hyperLinkModel=t,this._injector=r,this._resolverService=o,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:ke,onBeforeCopy:(n,t,r)=>this._collect(n,t,r),onPasteCells:(n,t,r,o)=>{const{copyType:s=f.COPY_TYPE.COPY,pasteType:c}=o,{range:l}=n||{},{range:p,unitId:v,subUnitId:_}=t;return this._generateMutations(p,{copyType:s,pasteType:c,copyRange:l,unitId:v,subUnitId:_})},onPastePlainText:(n,t)=>{if(ee(t)){const r=_e(t),{range:o,unitId:s,subUnitId:c}=n,{ranges:[l],mapFunc:p}=f.virtualizeDiscreteRanges([o]),v=[],_=[];return a.Range.foreach(l,(d,k)=>{const{row:S,col:C}=p(d,k),R=this._hyperLinkModel.getHyperLinkByLocation(s,c,S,C);R&&v.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:R.id}});const w=a.Tools.generateRandomId();v.push({id:m.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:{id:w,row:S,column:C,payload:r}}}),_.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:w}}),R&&_.push({id:m.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:R}})}),{redos:v,undos:_}}return{undos:[],redos:[]}}})}_collect(n,t,r){const o=new a.ObjectMatrix;this._copyInfo={unitId:n,subUnitId:t,matrix:o};const s={get:this._injector.get.bind(this._injector)},c=f.rangeToDiscreteRange(r,s,n,t);if(!c)return;const{rows:l,cols:p}=c;l.forEach((v,_)=>{p.forEach((d,k)=>{var C;const S=this._hyperLinkModel.getHyperLinkByLocation(n,t,v,d);o.setValue(_,k,(C=S==null?void 0:S.id)!=null?C:"")})})}_generateMutations(n,t){if(!this._copyInfo)return{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!t.copyRange)return{redos:[],undos:[]};if([f.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,f.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,f.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,f.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(t.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:o}=this._copyInfo,s=[],c=[],{ranges:[l,p],mapFunc:v}=f.virtualizeDiscreteRanges([t.copyRange,n]);return f.getRepeatRange(l,p,!0).forEach(({startRange:d})=>{var k;(k=this._copyInfo)==null||k.matrix.forValue((S,C,R)=>{const w=a.Rectangle.getPositionRange({startRow:S,endRow:S,startColumn:C,endColumn:C},d),H=this._hyperLinkModel.getHyperLink(r,o,R),{row:j,col:V}=v(w.startRow,w.startColumn),O=this._hyperLinkModel.getHyperLinkByLocation(t.unitId,t.subUnitId,j,V),q=a.Tools.generateRandomId();O&&s.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:t.unitId,subUnitId:t.subUnitId,id:O.id}}),H&&(s.push({id:m.AddHyperLinkMutation.id,params:{unitId:t.unitId,subUnitId:t.subUnitId,link:{...H,id:q,row:j,column:V}}}),c.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:t.unitId,subUnitId:t.subUnitId,id:q}})),O&&c.push({id:m.AddHyperLinkMutation.id,params:{unitId:t.unitId,subUnitId:t.subUnitId,link:O}})})}),{redos:s,undos:c}}};exports.SheetsHyperLinkCopyPasteController=Zt([a.OnLifecycle(a.LifecycleStages.Ready,exports.SheetsHyperLinkCopyPasteController),re(0,f.ISheetClipboardService),re(1,y.Inject(m.HyperLinkModel)),re(2,y.Inject(y.Injector)),re(3,y.Inject(exports.SheetsHyperLinkResolverService))],exports.SheetsHyperLinkCopyPasteController);var Gt=Object.defineProperty,Xt=Object.getOwnPropertyDescriptor,Jt=(i,e,n,t)=>{for(var r=t>1?void 0:t?Xt(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Gt(e,n,r),r},Qt=(i,e)=>(n,t)=>e(n,t,i);exports.SheetHyperLinkUrlController=class extends a.Disposable{constructor(e){super(),this._resolverService=e,this._handleInitUrl()}_handleInitUrl(){const e=location.hash;e&&this._resolverService.parseHyperLink(e).handler()}};exports.SheetHyperLinkUrlController=Jt([a.OnLifecycle(a.LifecycleStages.Rendered,exports.SheetHyperLinkUrlController),Qt(0,y.Inject(exports.SheetsHyperLinkResolverService))],exports.SheetHyperLinkUrlController);var en=Object.defineProperty,tn=Object.getOwnPropertyDescriptor,nn=(i,e,n,t)=>{for(var r=t>1?void 0:t?tn(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&en(e,n,r),r},ye=(i,e)=>(n,t)=>e(n,t,i);let oe=class extends a.Disposable{constructor(i,e,n){super(),this._localeService=i,this._commandService=e,this._sheetPermissionInterceptorBaseController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(i=>{i.id===Ce.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[u.WorkbookEditablePermission],rangeTypes:[u.RangeProtectionPermissionEditPoint],worksheetTypes:[u.WorksheetEditPermission,u.WorksheetSetCellValuePermission,u.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};oe=nn([a.OnLifecycle(a.LifecycleStages.Rendered,oe),ye(0,y.Inject(a.LocaleService)),ye(1,a.ICommandService),ye(2,y.Inject(f.SheetPermissionInterceptorBaseController))],oe);var xe=Object.defineProperty,rn=Object.getOwnPropertyDescriptor,on=(i,e,n)=>e in i?xe(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,sn=(i,e,n,t)=>{for(var r=t>1?void 0:t?rn(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&xe(e,n,r),r},He=(i,e)=>(n,t)=>e(n,t,i),Ne=(i,e,n)=>on(i,typeof e!="symbol"?e+"":e,n);exports.UniverSheetsHyperLinkUIPlugin=class extends a.Plugin{constructor(e,n,t){super(),this._config=e,this._injector=n,this._renderManagerService=t}onStarting(e){[[exports.SheetsHyperLinkResolverService],[exports.SheetsHyperLinkPopupService],[exports.SheetsHyperLinkRemoveSheetController],[exports.SheetsHyperLinkRenderManagerController],[exports.SheetHyperLinkSetRangeController],[exports.SheetsHyperLinkPopupController],[exports.SheetsHyperLinkUIController,{useFactory:()=>this._injector.createInstance(exports.SheetsHyperLinkUIController,this._config)}],[exports.SheetsHyperLinkAutoFillController],[exports.SheetsHyperLinkCopyPasteController],[oe],[exports.SheetHyperLinkUrlController]].forEach(t=>e.add(t))}onReady(){[[exports.SheetsHyperLinkRenderController]].forEach(n=>this._renderManagerService.registerRenderModule(a.UniverInstanceType.UNIVER_SHEET,n))}};Ne(exports.UniverSheetsHyperLinkUIPlugin,"pluginName",ke);Ne(exports.UniverSheetsHyperLinkUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsHyperLinkUIPlugin=sn([a.DependentOn(m.UniverSheetsHyperLinkPlugin),He(1,y.Inject(y.Injector)),He(2,fe.IRenderManagerService)],exports.UniverSheetsHyperLinkUIPlugin);exports.CloseHyperLinkSidebarOperation=te;exports.InsertHyperLinkOperation=ue;exports.InsertLinkShortcut=Ce;exports.OpenHyperLinkSidebarOperation=pe;