@univerjs/sheets-hyper-link-ui 0.1.17 → 0.2.1

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 $e=Object.defineProperty;var Ve=(i,e,n)=>e in i?$e(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n;var W=(i,e,n)=>Ve(i,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),p=require("@univerjs/sheets"),y=require("@wendellhu/redi"),m=require("@univerjs/sheets-hyper-link"),S=require("@univerjs/sheets-ui"),fe=require("@univerjs/engine-render"),ye=require("rxjs"),L=require("react"),U=require("@wendellhu/redi/react-bindings"),Re=require("clsx"),k=require("@univerjs/design"),H=require("@univerjs/ui"),A=require("@univerjs/engine-formula");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},ge=(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===p.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(g=>({id:m.RemoveHyperLinkMutation.id,params:{unitId:o,subUnitId:s,id:g.id}})),u=c.map(g=>({id:m.AddHyperLinkMutation.id,params:{unitId:o,subUnitId:s,link:g}}));return{redos:l,undos:u}}return{redos:[],undos:[]}}}))}};exports.SheetsHyperLinkRemoveSheetController=Fe([a.OnLifecycle(a.LifecycleStages.Ready,exports.SheetsHyperLinkRemoveSheetController),ge(0,y.Inject(p.SheetInterceptorService)),ge(1,a.IUniverInstanceService),ge(2,y.Inject(m.HyperLinkModel))],exports.SheetsHyperLinkRemoveSheetController);var Ye=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&&Ye(e,n,r),r},q=(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=Ee([q(1,y.Inject(m.HyperLinkModel)),q(2,y.Inject(S.SheetSkeletonManagerService)),q(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(p.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),u=this._themeService.getCurrentTheme();return t(l?{...e,interceptorStyle:{ul:{s:a.BooleanNumber.TRUE},cl:{rgb:u.blue500}}}:e)},priority:100}))}};exports.SheetsHyperLinkRenderManagerController=Ee([a.OnLifecycle(a.LifecycleStages.Ready,exports.SheetsHyperLinkRenderManagerController),q(0,y.Inject(p.SheetInterceptorService)),q(1,y.Inject(m.HyperLinkModel)),q(2,y.Inject(a.ThemeService))],exports.SheetsHyperLinkRenderManagerController);var Oe={exports:{}},le={};/**
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 W=(i,e,n)=>Ve(i,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),p=require("@univerjs/sheets"),y=require("@wendellhu/redi"),m=require("@univerjs/sheets-hyper-link"),S=require("@univerjs/sheets-ui"),fe=require("@univerjs/engine-render"),ye=require("rxjs"),L=require("react"),U=require("@wendellhu/redi/react-bindings"),Re=require("clsx"),k=require("@univerjs/design"),H=require("@univerjs/ui"),D=require("@univerjs/engine-formula");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},ge=(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===p.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(g=>({id:m.RemoveHyperLinkMutation.id,params:{unitId:o,subUnitId:s,id:g.id}})),u=c.map(g=>({id:m.AddHyperLinkMutation.id,params:{unitId:o,subUnitId:s,link:g}}));return{redos:l,undos:u}}return{redos:[],undos:[]}}}))}};exports.SheetsHyperLinkRemoveSheetController=Fe([a.OnLifecycle(a.LifecycleStages.Ready,exports.SheetsHyperLinkRemoveSheetController),ge(0,y.Inject(p.SheetInterceptorService)),ge(1,a.IUniverInstanceService),ge(2,y.Inject(m.HyperLinkModel))],exports.SheetsHyperLinkRemoveSheetController);var Ye=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&&Ye(e,n,r),r},K=(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=Ee([K(1,y.Inject(m.HyperLinkModel)),K(2,y.Inject(S.SheetSkeletonManagerService)),K(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(p.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),u=this._themeService.getCurrentTheme();return t(l?{...e,interceptorStyle:{ul:{s:a.BooleanNumber.TRUE},cl:{rgb:u.blue500}}}:e)},priority:100}))}};exports.SheetsHyperLinkRenderManagerController=Ee([a.OnLifecycle(a.LifecycleStages.Ready,exports.SheetsHyperLinkRenderManagerController),K(0,y.Inject(p.SheetInterceptorService)),K(1,y.Inject(m.HyperLinkModel)),K(2,y.Inject(a.ThemeService))],exports.SheetsHyperLinkRenderManagerController);var Oe={exports:{}},le={};/**
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=L,qe=Symbol.for("react.element"),Ke=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 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)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}}le.Fragment=Ke;le.jsx=Me;le.jsxs=Me;Oe.exports=le;var h=Oe.exports,T=function(){return T=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},T.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},F=L.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=L.useRef("_".concat(nt()));return we(n,"".concat(t),{defIds:n.defIds,idSuffix:l.current},T({ref:e,className:c},s),o)});function we(i,e,n,t,r){return L.createElement(i.tag,T(T({key:e},et(i,n,r)),t),(tt(i,n).children||[]).map(function(o,s){return we(o,"".concat(e,"-").concat(i.tag,"-").concat(s),n,void 0,r)}))}function et(i,e,n){var t=T({},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)?T(T({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&t&&t.indexOf(r.attrs.id)>-1?T(T({},r),{attrs:T(T({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):i}function nt(){return Math.random().toString(36).substring(2,8)}F.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"}}]},ie=L.forwardRef(function(i,e){return L.createElement(F,Object.assign({},i,{id:"all-border-single",ref:e,icon:rt}))});ie.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"}}]},Ue=L.forwardRef(function(i,e){return L.createElement(F,Object.assign({},i,{id:"copy-single",ref:e,icon:it}))});Ue.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"}}]},se=L.forwardRef(function(i,e){return L.createElement(F,Object.assign({},i,{id:"link-single",ref:e,icon:ot}))});se.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"}}]},Te=L.forwardRef(function(i,e){return L.createElement(F,Object.assign({},i,{id:"unlink-single",ref:e,icon:st}))});Te.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"}}]},je=L.forwardRef(function(i,e){return L.createElement(F,Object.assign({},i,{id:"write-single",ref:e,icon:at}))});je.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"}}]},Se=L.forwardRef(function(i,e){return L.createElement(F,Object.assign({},i,{id:"xlsx",ref:e,icon:ct}))});Se.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},X=(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 u=A.deserializeRangeWithSheet(t).range;return a.isValidRange(u)&&t!==m.ERROR_RANGE?{type:"range",name:A.serializeRangeWithSheet(c,u)}:{type:"range-error",name:this._localeService.t("hyperLink.message.refError")}}if(r){const u=this._definedNamesService.getValueById(o.getUnitId(),r);return u?{type:"defineName",name:u.formulaOrRefString}:{type:"range-error",name:this._localeService.t("hyperLink.message.refError")}}if(n){const u=o.getSheetBySheetId(n);return u?{type:"sheet",name:u.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=A.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(p.SetSelectionsOperation.id,{unitId:e,subUnitId:n,pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,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(p.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(p.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([X(0,a.IUniverInstanceService),X(1,a.ICommandService),X(2,A.IDefinedNamesService),X(3,H.IMessageService),X(4,y.Inject(a.LocaleService))],exports.SheetsHyperLinkResolverService);const ht=/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi,mt=new RegExp(ht);function ee(i){return Number.isNaN(+i)?i.startsWith("http://localhost:3002")||i.startsWith("localhost:3002")?!0:!!i.match(mt):!1}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},ae=()=>{var G;const[i,e]=L.useState(""),[n,t]=L.useState(""),[r,o]=L.useState("link"),[s,c]=L.useState(""),l=U.useDependency(a.LocaleService),u=U.useDependency(A.IDefinedNamesService),g=U.useDependency(a.IUniverInstanceService),f=U.useDependency(exports.SheetsHyperLinkPopupService),d=H.useObservable(f.currentEditing$),I=U.useDependency(m.HyperLinkModel),_=U.useDependency(exports.SheetsHyperLinkResolverService),C=U.useDependency(a.ICommandService),[R,j]=L.useState(!1),E=L.useRef(!1);L.useEffect(()=>{var v,P,O;if((d==null?void 0:d.row)!==void 0&&d.column!==void 0){const b=I.getHyperLinkByLocationSync(d.unitId,d.subUnitId,d.row,d.column);if(b){const ne=_.parseHyperLink(b.payload);if(e(b.id),t(b.display),ne.type==="outer"){o("link"),c(ne.url),ne.url===b.display&&(E.current=!0);return}else{const $=ne.searchObj;if($.rangeid){o("rangeid"),c($.rangeid);return}if($.range){const De=$.gid&&(O=(P=(v=g.getUnit(d.unitId))==null?void 0:v.getSheetBySheetId($.gid))==null?void 0:P.getName())!=null?O:"";if(o("range"),$.range===m.ERROR_RANGE)c("");else{const Ie=A.serializeRangeWithSheet(De,A.deserializeRangeWithSheet($.range).range);c(Ie),Ie===b.display&&(E.current=!0)}return}if($.gid){o("gid"),c($.gid);return}}}const w=g.getUnit(d.unitId),x=w==null?void 0:w.getSheetBySheetId(d.subUnitId),Ae=x==null?void 0:x.getCellRaw(d.row,d.column),me=yt(Ae);o("link"),c(""),t((me!=null?me:"").toString()),e("");return}o("link"),c(""),t(""),e("")},[d,I,_,g]);const D=L.useMemo(()=>s,[r]),Y=[{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"}],M=g.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!M)return;const z=M.getHiddenWorksheets(),V=M.getSheets().map(v=>({label:v.getName(),value:v.getSheetId()})).filter(v=>z.indexOf(v.value)===-1),B=Object.values((G=u.getDefinedNameMap(M.getUnitId()))!=null?G:{}).map(v=>({label:v.name,value:v.id})),K=(v,P)=>{if(v==="link")return _e(P);if(v==="range"){const O=A.deserializeRangeWithSheet(P),b=M.getSheetBySheetName(O.sheetName);if(b)return`#gid=${b.getSheetId()}&range=${A.serializeRange(O.range)}`}return`#${v}=${P}`},ue=H.useEvent(v=>{var b;const P=v[0];if(!P||!a.isValidRange(P.range))return;P.sheetName||(P.sheetName=((b=M.getActiveSheet())==null?void 0:b.getName())||"");const O=A.serializeRangeToRefString(P);c(O),O&&(E.current||!n)&&(t(O),E.current=!0)}),he=async()=>{if(d&&(i?await C.executeCommand(m.UpdateHyperLinkCommand.id,{unitId:d.unitId,subUnitId:d.subUnitId,id:i,payload:{display:n,payload:K(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:K(r,s),display:n}})),d){await C.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:d.unitId,subUnitId:d.subUnitId});const v=5;await C.executeCommand(S.ScrollToRangeOperation.id,{range:{startRow:Math.max(d.row-v,0),endRow:d.row+v,startColumn:Math.max(d.column-v,0),endColumn:d.column+v}})}C.executeCommand(te.id)};return h.jsxs("div",{children:[h.jsx(k.FormLayout,{label:l.t("hyperLink.form.label"),error:R&&!n?l.t("hyperLink.form.inputError"):"",children:h.jsx(k.Input,{value:n,onChange:v=>{t(v),E.current=!1},placeholder:l.t("hyperLink.form.labelPlaceholder")})}),h.jsx(k.FormLayout,{label:l.t("hyperLink.form.type"),children:h.jsx(k.Select,{options:Y,value:r,onChange:v=>{o(v),c("")}})}),r==="link"&&h.jsx(k.FormLayout,{error:R?s?ee(s)?"":l.t("hyperLink.form.linkError"):l.t("hyperLink.form.inputError"):"",children:h.jsx(k.Input,{value:s,onChange:v=>{c(v),v&&(E.current||!n||n===s)&&(t(v),E.current=!0)},placeholder:l.t("hyperLink.form.linkPlaceholder")})}),r==="range"&&h.jsx(k.FormLayout,{error:R&&!s?l.t("hyperLink.form.inputError"):"",children:h.jsx(H.RangeSelector,{openForSheetUnitId:M.getUnitId(),id:a.createInternalEditorID("hyper-link-edit"),isSingleChoice:!0,value:D,onChange:ue})}),r==="gid"&&h.jsx(k.FormLayout,{error:R&&!s?l.t("hyperLink.form.selectError"):"",children:h.jsx(k.Select,{options:V,value:s,onChange:v=>{var b,w;c(v);const P=(b=V.find(x=>x.value===v))==null?void 0:b.label,O=(w=V.find(x=>x.value===s))==null?void 0:w.label;P&&(E.current||!n||n===O)&&(t(P),E.current=!0)}})}),r==="rangeid"&&h.jsx(k.FormLayout,{error:R&&!s?l.t("hyperLink.form.selectError"):"",children:h.jsx(k.Select,{options:B,value:s,onChange:v=>{var b,w;c(v);const P=(b=B.find(x=>x.value===v))==null?void 0:b.label,O=(w=B.find(x=>x.value===s))==null?void 0:w.label;P&&(E.current||!n||n===O)&&(t(P),E.current=!0)}})}),h.jsxs("div",{className:ft.cellLinkEditButtons,children:[h.jsx(k.Button,{onClick:()=>{d&&C.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:d.unitId,subUnitId:d.subUnitId}),C.executeCommand(te.id)},children:l.t("hyperLink.form.cancel")}),h.jsx(k.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{if(!n||!s||r==="link"&&!ee(s)){j(!0);return}he()},children:l.t("hyperLink.form.ok")})]})]})};ae.componentKey="univer.sheet.cell-link-edit";const de={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),u=s.getHyperLinkByLocation(n,t,r,o);return l.startEditing(e),c.open({header:{title:u?"hyperLink.form.editTitle":"hyperLink.form.addTitle"},children:{label:ae.componentKey}}),!0}},te={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}},pe={type:a.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(i){const e=i.get(a.IUniverInstanceService),n=p.getSheetCommandTarget(e);if(!n)return!1;const t=i.get(a.ICommandService),o=i.get(p.SelectionManagerService).getFirst();if(!(o!=null&&o.primary))return!1;const s=o.primary.startRow,c=o.primary.startColumn;return t.executeCommand(de.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(pe.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",N={cellLink:_t,cellLinkType:Lt,cellLinkContent:Ct,cellLinkContentError:kt,cellLinkUrl:It,cellLinkOperations:Rt,cellLinkOperation:Pt,cellLinkOperationError:bt},Ht={outer:h.jsx(se,{}),link:h.jsx(se,{}),sheet:h.jsx(Se,{}),range:h.jsx(ie,{}),defineName:h.jsx(ie,{}),"range-error":h.jsx(ie,{}),"sheet-error":h.jsx(Se,{})},ce=()=>{const i=U.useDependency(exports.SheetsHyperLinkPopupService),e=U.useDependency(m.HyperLinkModel),n=U.useDependency(a.ICommandService),t=U.useDependency(H.IMessageService),r=U.useDependency(a.LocaleService),o=H.useObservable(i.currentPopup$,i.currentPopup),s=U.useDependency(exports.SheetsHyperLinkResolverService);if(!o)return null;const{unitId:c,subUnitId:l,id:u}=o,g=e.getHyperLink(c,l,u);if(!g)return null;const f=s.parseHyperLink(g.payload),d=f.type.indexOf("error")>-1;return h.jsxs("div",{className:N.cellLink,onClick:()=>i.hideCurrentPopup(),children:[h.jsxs("div",{className:Re(N.cellLinkContent,{[N.cellLinkContentError]:d}),onClick:f.handler,children:[h.jsx("div",{className:N.cellLinkType,children:Ht[f.type]}),h.jsx(k.Tooltip,{showIfEllipsis:!0,title:f.name,children:h.jsx("span",{className:N.cellLinkUrl,children:f.name})})]}),h.jsxs("div",{className:N.cellLinkOperations,children:[o.copyPermission&&h.jsx("div",{className:Re(N.cellLinkOperation,{[N.cellLinkOperationError]:d}),onClick:()=>{if(!d){if(f.type!=="outer"){const I=new URL(window.location.href);I.hash=f.url.slice(1),navigator.clipboard.writeText(I.href)}else navigator.clipboard.writeText(f.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(Ue,{})})}),o.editPermission&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:N.cellLinkOperation,onClick:()=>{n.executeCommand(de.id,{unitId:c,subUnitId:l,row:g.row,column:g.column})},children:h.jsx(k.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:h.jsx(je,{})})}),h.jsx("div",{className:N.cellLinkOperation,onClick:()=>{n.executeCommand(m.CancelHyperLinkCommand.id,{unitId:c,subUnitId:l,id:g.id})},children:h.jsx(k.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:h.jsx(Te,{})})})]})]})]})};ce.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();W(this,"_currentPopup",null);W(this,"_currentPopup$",new ye.Subject);W(this,"currentPopup$",this._currentPopup$.asObservable());W(this,"_currentEditing$",new ye.BehaviorSubject(null));W(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:ce.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(S.SheetCanvasPopManagerService))],exports.SheetsHyperLinkPopupService);var Ut=Object.defineProperty,Tt=Object.getOwnPropertyDescriptor,jt=(i,e,n,t)=>{for(var r=t>1?void 0:t?Tt(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},J=(i,e)=>(n,t)=>e(n,t,i);exports.SheetHyperLinkSetRangeController=class extends a.Disposable{constructor(e,n,t,r,o){super(),this._sheetInterceptorService=e,this._injector=n,this._hyperLinkModel=t,this._selectionManagerService=r,this._univerInstanceService=o,this._initCommandInterceptor()}_initCommandInterceptor(){this._initAddHyperLinkCommandInterceptor(),this._initSetRangeValuesCommandInterceptor(),this._initUpdateHyperLinkCommandInterceptor(),this._initClearSelectionCommandInterceptor()}_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:p.SetRangeValuesMutation.id,params:l}],undos:[{id:p.SetRangeValuesMutation.id,params:p.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:p.SetRangeValuesMutation.id,params:l}],undos:[{id:p.SetRangeValuesMutation.id,params:p.SetRangeValuesUndoMutationFactory(this._injector,l)}]}}}return{redos:[],undos:[]}}}))}_initSetRangeValuesCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===p.SetRangeValuesCommand.id){const n=e.params,{unitId:t,subUnitId:r}=n,o=[],s=[];return n.cellValue&&new a.ObjectMatrix(n.cellValue).forValue((c,l,u)=>{var I,_,C;const g=(C=u==null?void 0:u.v)!=null?C:(_=(I=u==null?void 0:u.p)==null?void 0:I.body)==null?void 0:_.dataStream.slice(0,-2),f=(g!=null?g:"").toString(),d=this._hyperLinkModel.getHyperLinkByLocation(t,r,c,l);if(!d){if(ee(f)){const R=a.Tools.generateRandomId();s.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:t,subUnitId:r,id:R}}),o.push({id:m.AddHyperLinkMutation.id,params:{unitId:t,subUnitId:r,link:{id:R,row:c,column:l,display:f,payload:_e(f)}}})}return}g===""&&(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===p.ClearSelectionContentCommand.id||e.id===p.ClearSelectionAllCommand.id||e.id===p.ClearSelectionFormatCommand.id){const n=[],t=[],r=this._selectionManagerService.getFirst(),o=p.getSheetCommandTarget(this._univerInstanceService);if(r&&o){const{unitId:s,subUnitId:c}=o;a.Range.foreach(r.range,(l,u)=>{const g=this._hyperLinkModel.getHyperLinkByLocation(s,c,l,u);g&&(n.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:g.id}}),t.push({id:m.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:g}}))})}return{redos:n,undos:t}}return{redos:[],undos:[]}}}))}_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)}};exports.SheetHyperLinkSetRangeController=jt([a.OnLifecycle(a.LifecycleStages.Starting,exports.SheetHyperLinkSetRangeController),J(0,y.Inject(p.SheetInterceptorService)),J(1,y.Inject(y.Injector)),J(2,y.Inject(m.HyperLinkModel)),J(3,y.Inject(p.SelectionManagerService)),J(4,a.IUniverInstanceService)],exports.SheetHyperLinkSetRangeController);var xt=Object.defineProperty,Nt=Object.getOwnPropertyDescriptor,At=(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(ye.debounceTime(100)).subscribe(e=>{var d,I;if(!e){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const n=(I=(d=this._renderManagerService.getRenderById(e.location.unitId))==null?void 0:d.with(S.SheetSkeletonManagerService).getUnitSkeleton(e.location.unitId,e.location.subUnitId))==null?void 0:I.skeleton,t=e.location.col,r=e.location.row;let o=r,s=t;if(n&&n.overflowCache.forValue((_,C,R)=>{a.Rectangle.contains(R,{startColumn:t,endColumn:t,startRow:r,endRow:r})&&(o=_,s=C)}),!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[p.WorkbookViewPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]},[{startRow:r,startColumn:t,endRow:r,endColumn:t}])){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const l=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[p.WorkbookEditablePermission],worksheetTypes:[p.WorksheetEditPermission,p.WorksheetInsertHyperlinkPermission],rangeTypes:[p.RangeProtectionPermissionEditPoint]},[{startRow:r,startColumn:t,endRow:r,endColumn:t}]),u=e.location.unitId,g=e.location.subUnitId,f=this._permissionService.composePermission([new p.WorkbookCopyPermission(u).id,new p.WorksheetCopyPermission(u,g).id]).every(_=>_.value);this._sheetsHyperLinkPopupService.showPopup({...e.location,row:o,col:s,editPermission:l,copyPermission:f})}))}};exports.SheetsHyperLinkPopupController=At([a.OnLifecycle(a.LifecycleStages.Rendered,exports.SheetsHyperLinkPopupController),Q(0,y.Inject(S.HoverManagerService)),Q(1,y.Inject(exports.SheetsHyperLinkPopupService)),Q(2,y.Inject(fe.IRenderManagerService)),Q(3,y.Inject(a.IPermissionService)),Q(4,y.Inject(S.SheetPermissionInterceptorBaseController))],exports.SheetsHyperLinkPopupController);const Dt=i=>({id:pe.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:[p.WorkbookEditablePermission],worksheetTypes:[p.WorksheetEditPermission,p.WorksheetSetCellValuePermission,p.WorksheetInsertHyperlinkPermission],rangeTypes:[p.RangeProtectionPermissionEditPoint]})}),$t=i=>({tooltip:"hyperLink.form.addTitle",positions:H.MenuPosition.TOOLBAR_START,group:H.MenuGroup.TOOLBAR_OTHERS,id:Le.id,type:H.MenuItemType.BUTTON,icon:"LinkSingle",hidden$:H.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:S.getCurrentRangeDisable$(i,{workbookTypes:[p.WorkbookEditablePermission],worksheetTypes:[p.WorksheetEditPermission,p.WorksheetSetCellValuePermission,p.WorksheetInsertHyperlinkPermission],rangeTypes:[p.RangeProtectionPermissionEditPoint]})}),Ce={id:Le.id,binding:H.KeyCode.K|H.MetaKeys.CTRL_COMMAND,preconditions:S.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(){[[ce,ce.componentKey],[ae,ae.componentKey],[se,"LinkSingle"]].forEach(([e,n])=>{this._componentManager.register(n,e)})}_initCommands(){[de,te,pe,Le].forEach(e=>{this._commandService.registerCommand(e)})}_initMenus(){var e,n,t,r;this._menuService.addMenuItem(Dt(this._injector),(n=(e=this._config)==null?void 0:e.menu)!=null?n:{}),this._menuService.addMenuItem($t(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(H.ComponentManager)),Z(2,a.ICommandService),Z(3,y.Inject(a.LocaleService)),Z(4,H.IMenuService),Z(5,y.Inject(y.Injector)),Z(6,y.Inject(H.IShortcutService))],exports.SheetsHyperLinkUIController);const ke="SHEET_HYPER_LINK_UI_PLUGIN";var Ft=Object.defineProperty,Yt=Object.getOwnPropertyDescriptor,zt=(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:u}=r,g=S.virtualizeDiscreteRanges([s,c]),[f,d]=g.ranges,{mapFunc:I}=g,_={row:f.startRow,col:f.startColumn},C=S.getAutoFillRepeatRange(f,d),R=[],j=[];return C.forEach(E=>{const D=E.repeatStartCell,Y=E.relativeRange,M={startRow:_.row,startColumn:_.col,endColumn:_.col,endRow:_.row},z={startRow:D.row,startColumn:D.col,endColumn:D.col,endRow:D.row};a.Range.foreach(Y,(V,B)=>{const K=a.Rectangle.getPositionRange({startRow:V,startColumn:B,endColumn:B,endRow:V},M),{row:ue,col:he}=I(K.startRow,K.startColumn),G=this._hyperLinkModel.getHyperLinkByLocation(l,u,ue,he);if(G){const v=a.Rectangle.getPositionRange({startRow:V,startColumn:B,endColumn:B,endRow:V},z),{row:P,col:O}=I(v.startRow,v.startColumn),b=a.Tools.generateRandomId(),w=this._hyperLinkModel.getHyperLinkByLocation(l,u,P,O);w&&R.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:w.id}}),(S.APPLY_TYPE.COPY===o||S.APPLY_TYPE.SERIES===o)&&(R.push({id:m.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:{...G,id:b,row:P,column:O}}}),j.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:b}})),w&&j.push({id:m.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:w}})}})}),{undos:j,redos:R}},t={id:ke,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=zt([a.OnLifecycle(a.LifecycleStages.Ready,exports.SheetsHyperLinkAutoFillController),be(0,S.IAutoFillService),be(1,y.Inject(m.HyperLinkModel))],exports.SheetsHyperLinkAutoFillController);var Zt=Object.defineProperty,qt=Object.getOwnPropertyDescriptor,Kt=(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&&Zt(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();W(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=S.COPY_TYPE.COPY,pasteType:c}=o,{range:l}=n||{},{range:u,unitId:g,subUnitId:f}=t;return this._generateMutations(u,{copyType:s,pasteType:c,copyRange:l,unitId:g,subUnitId:f})},onPastePlainText:(n,t)=>{if(ee(t)){const r=_e(t),{range:o,unitId:s,subUnitId:c}=n,{ranges:[l],mapFunc:u}=S.virtualizeDiscreteRanges([o]),g=[],f=[];return a.Range.foreach(l,(d,I)=>{const{row:_,col:C}=u(d,I),R=this._hyperLinkModel.getHyperLinkByLocation(s,c,_,C);R&&g.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:R.id}});const j=a.Tools.generateRandomId();g.push({id:m.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:{id:j,row:_,column:C,payload:r}}}),f.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:j}}),R&&f.push({id:m.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:R}})}),{redos:g,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:u}=c;l.forEach((g,f)=>{u.forEach((d,I)=>{var C;const _=this._hyperLinkModel.getHyperLinkByLocation(n,t,g,d);o.setValue(f,I,(C=_==null?void 0:_.id)!=null?C:"")})})}_generateMutations(n,t){if(!this._copyInfo)return{redos:[],undos:[]};if(t.copyType===S.COPY_TYPE.CUT)return this._copyInfo=null,{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,u],mapFunc:g}=S.virtualizeDiscreteRanges([t.copyRange,n]);return S.getRepeatRange(l,u,!0).forEach(({startRange:d})=>{var I;(I=this._copyInfo)==null||I.matrix.forValue((_,C,R)=>{const j=a.Rectangle.getPositionRange({startRow:_,endRow:_,startColumn:C,endColumn:C},d),E=this._hyperLinkModel.getHyperLink(r,o,R),{row:D,col:Y}=g(j.startRow,j.startColumn),M=this._hyperLinkModel.getHyperLinkByLocation(t.unitId,t.subUnitId,D,Y),z=a.Tools.generateRandomId();M&&s.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:t.unitId,subUnitId:t.subUnitId,id:M.id}}),E&&(s.push({id:m.AddHyperLinkMutation.id,params:{unitId:t.unitId,subUnitId:t.subUnitId,link:{...E,id:z,row:D,column:Y}}}),c.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:t.unitId,subUnitId:t.subUnitId,id:z}})),M&&c.push({id:m.AddHyperLinkMutation.id,params:{unitId:t.unitId,subUnitId:t.subUnitId,link:M}})})}),{redos:s,undos:c}}};exports.SheetsHyperLinkCopyPasteController=Kt([a.OnLifecycle(a.LifecycleStages.Ready,exports.SheetsHyperLinkCopyPasteController),re(0,S.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},ve=(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:[p.WorkbookEditablePermission],rangeTypes:[p.RangeProtectionPermissionEditPoint],worksheetTypes:[p.WorksheetEditPermission,p.WorksheetSetCellValuePermission,p.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};oe=nn([a.OnLifecycle(a.LifecycleStages.Rendered,oe),ve(0,y.Inject(a.LocaleService)),ve(1,a.ICommandService),ve(2,y.Inject(S.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)),this._renderManagerService.registerRenderModule(a.UniverInstanceType.UNIVER_SHEET,exports.SheetsHyperLinkRenderController)}};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=pe;exports.InsertLinkShortcut=Ce;exports.OpenHyperLinkSidebarOperation=de;
9
+ */var qe=L,Ke=Symbol.for("react.element"),Ze=Symbol.for("react.fragment"),Ge=Object.prototype.hasOwnProperty,Xe=qe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Je={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)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:Ke,type:i,key:o,ref:s,props:r,_owner:Xe.current}}le.Fragment=Ze;le.jsx=Me;le.jsxs=Me;Oe.exports=le;var h=Oe.exports,T=function(){return T=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},T.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},F=L.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=L.useRef("_".concat(nt()));return we(n,"".concat(t),{defIds:n.defIds,idSuffix:l.current},T({ref:e,className:c},s),o)});function we(i,e,n,t,r){return L.createElement(i.tag,T(T({key:e},et(i,n,r)),t),(tt(i,n).children||[]).map(function(o,s){return we(o,"".concat(e,"-").concat(i.tag,"-").concat(s),n,void 0,r)}))}function et(i,e,n){var t=T({},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)?T(T({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&t&&t.indexOf(r.attrs.id)>-1?T(T({},r),{attrs:T(T({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):i}function nt(){return Math.random().toString(36).substring(2,8)}F.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"}}]},ie=L.forwardRef(function(i,e){return L.createElement(F,Object.assign({},i,{id:"all-border-single",ref:e,icon:rt}))});ie.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"}}]},Ue=L.forwardRef(function(i,e){return L.createElement(F,Object.assign({},i,{id:"copy-single",ref:e,icon:it}))});Ue.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"}}]},se=L.forwardRef(function(i,e){return L.createElement(F,Object.assign({},i,{id:"link-single",ref:e,icon:ot}))});se.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"}}]},Te=L.forwardRef(function(i,e){return L.createElement(F,Object.assign({},i,{id:"unlink-single",ref:e,icon:st}))});Te.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"}}]},je=L.forwardRef(function(i,e){return L.createElement(F,Object.assign({},i,{id:"write-single",ref:e,icon:at}))});je.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"}}]},Se=L.forwardRef(function(i,e){return L.createElement(F,Object.assign({},i,{id:"xlsx",ref:e,icon:ct}))});Se.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},X=(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 u=D.deserializeRangeWithSheet(t).range;return a.isValidRange(u)&&t!==m.ERROR_RANGE?{type:"range",name:D.serializeRangeWithSheet(c,u)}:{type:"range-error",name:this._localeService.t("hyperLink.message.refError")}}if(r){const u=this._definedNamesService.getValueById(o.getUnitId(),r);return u?{type:"defineName",name:u.formulaOrRefString}:{type:"range-error",name:this._localeService.t("hyperLink.message.refError")}}if(n){const u=o.getSheetBySheetId(n);return u?{type:"sheet",name:u.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=D.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(p.SetSelectionsOperation.id,{unitId:e,subUnitId:n,pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,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(p.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(p.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([X(0,a.IUniverInstanceService),X(1,a.ICommandService),X(2,D.IDefinedNamesService),X(3,H.IMessageService),X(4,y.Inject(a.LocaleService))],exports.SheetsHyperLinkResolverService);function ee(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 _e(i){if(ee(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},ae=()=>{var G;const[i,e]=L.useState(""),[n,t]=L.useState(""),[r,o]=L.useState("link"),[s,c]=L.useState(""),l=U.useDependency(a.LocaleService),u=U.useDependency(D.IDefinedNamesService),g=U.useDependency(a.IUniverInstanceService),f=U.useDependency(exports.SheetsHyperLinkPopupService),d=H.useObservable(f.currentEditing$),I=U.useDependency(m.HyperLinkModel),_=U.useDependency(exports.SheetsHyperLinkResolverService),C=U.useDependency(a.ICommandService),[R,j]=L.useState(!1),E=L.useRef(!1);L.useEffect(()=>{var v,P,O;if((d==null?void 0:d.row)!==void 0&&d.column!==void 0){const b=I.getHyperLinkByLocationSync(d.unitId,d.subUnitId,d.row,d.column);if(b){const ne=_.parseHyperLink(b.payload);if(e(b.id),t(b.display),ne.type==="outer"){o("link"),c(ne.url),ne.url===b.display&&(E.current=!0);return}else{const A=ne.searchObj;if(A.rangeid){o("rangeid"),c(A.rangeid);return}if(A.range){const $e=A.gid&&(O=(P=(v=g.getUnit(d.unitId))==null?void 0:v.getSheetBySheetId(A.gid))==null?void 0:P.getName())!=null?O:"";if(o("range"),A.range===m.ERROR_RANGE)c("");else{const Ie=D.serializeRangeWithSheet($e,D.deserializeRangeWithSheet(A.range).range);c(Ie),Ie===b.display&&(E.current=!0)}return}if(A.gid){o("gid"),c(A.gid);return}}}const w=g.getUnit(d.unitId),x=w==null?void 0:w.getSheetBySheetId(d.subUnitId),De=x==null?void 0:x.getCellRaw(d.row,d.column),me=gt(De);o("link"),c(""),t((me!=null?me:"").toString()),e("");return}o("link"),c(""),t(""),e("")},[d,I,_,g]);const $=L.useMemo(()=>s,[r]),Y=[{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"}],M=g.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!M)return;const z=M.getHiddenWorksheets(),V=M.getSheets().map(v=>({label:v.getName(),value:v.getSheetId()})).filter(v=>z.indexOf(v.value)===-1),B=Object.values((G=u.getDefinedNameMap(M.getUnitId()))!=null?G:{}).map(v=>({label:v.name,value:v.id})),Z=(v,P)=>{if(v==="link")return _e(P);if(v==="range"){const O=D.deserializeRangeWithSheet(P),b=M.getSheetBySheetName(O.sheetName);if(b)return`#gid=${b.getSheetId()}&range=${D.serializeRange(O.range)}`}return`#${v}=${P}`},ue=H.useEvent(v=>{var b;const P=v[0];if(!P||!a.isValidRange(P.range))return;P.sheetName||(P.sheetName=((b=M.getActiveSheet())==null?void 0:b.getName())||"");const O=D.serializeRangeToRefString(P);c(O),O&&(E.current||!n)&&(t(O),E.current=!0)}),he=async()=>{if(d&&(i?await C.executeCommand(m.UpdateHyperLinkCommand.id,{unitId:d.unitId,subUnitId:d.subUnitId,id:i,payload:{display:n,payload:Z(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:Z(r,s),display:n}})),d){await C.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:d.unitId,subUnitId:d.subUnitId});const v=1;await C.executeCommand(S.ScrollToRangeOperation.id,{range:{startRow:Math.max(d.row-v,0),endRow:d.row+v,startColumn:Math.max(d.column-v,0),endColumn:d.column+v}})}C.executeCommand(te.id)};return h.jsxs("div",{children:[h.jsx(k.FormLayout,{label:l.t("hyperLink.form.label"),error:R&&!n?l.t("hyperLink.form.inputError"):"",children:h.jsx(k.Input,{value:n,onChange:v=>{t(v),E.current=!1},placeholder:l.t("hyperLink.form.labelPlaceholder")})}),h.jsx(k.FormLayout,{label:l.t("hyperLink.form.type"),children:h.jsx(k.Select,{options:Y,value:r,onChange:v=>{o(v),c("")}})}),r==="link"&&h.jsx(k.FormLayout,{error:R?s?ee(s)?"":l.t("hyperLink.form.linkError"):l.t("hyperLink.form.inputError"):"",children:h.jsx(k.Input,{value:s,onChange:v=>{c(v),v&&(E.current||!n||n===s)&&(t(v),E.current=!0)},placeholder:l.t("hyperLink.form.linkPlaceholder")})}),r==="range"&&h.jsx(k.FormLayout,{error:R&&!s?l.t("hyperLink.form.inputError"):"",children:h.jsx(H.RangeSelector,{openForSheetUnitId:M.getUnitId(),id:a.createInternalEditorID("hyper-link-edit"),isSingleChoice:!0,value:$,onChange:ue})}),r==="gid"&&h.jsx(k.FormLayout,{error:R&&!s?l.t("hyperLink.form.selectError"):"",children:h.jsx(k.Select,{options:V,value:s,onChange:v=>{var b,w;c(v);const P=(b=V.find(x=>x.value===v))==null?void 0:b.label,O=(w=V.find(x=>x.value===s))==null?void 0:w.label;P&&(E.current||!n||n===O)&&(t(P),E.current=!0)}})}),r==="rangeid"&&h.jsx(k.FormLayout,{error:R&&!s?l.t("hyperLink.form.selectError"):"",children:h.jsx(k.Select,{options:B,value:s,onChange:v=>{var b,w;c(v);const P=(b=B.find(x=>x.value===v))==null?void 0:b.label,O=(w=B.find(x=>x.value===s))==null?void 0:w.label;P&&(E.current||!n||n===O)&&(t(P),E.current=!0)}})}),h.jsxs("div",{className:yt.cellLinkEditButtons,children:[h.jsx(k.Button,{onClick:()=>{d&&C.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:d.unitId,subUnitId:d.subUnitId}),C.executeCommand(te.id)},children:l.t("hyperLink.form.cancel")}),h.jsx(k.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{if(!n||!s||r==="link"&&!ee(s)){j(!0);return}he()},children:l.t("hyperLink.form.ok")})]})]})};ae.componentKey="univer.sheet.cell-link-edit";const de={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),u=s.getHyperLinkByLocation(n,t,r,o);return l.startEditing(e),c.open({header:{title:u?"hyperLink.form.editTitle":"hyperLink.form.addTitle"},children:{label:ae.componentKey}}),!0}},te={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}},pe={type:a.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(i){const e=i.get(a.IUniverInstanceService),n=p.getSheetCommandTarget(e);if(!n)return!1;const t=i.get(a.ICommandService),o=i.get(p.SelectionManagerService).getFirst();if(!(o!=null&&o.primary))return!1;const s=o.primary.startRow,c=o.primary.startColumn;return t.executeCommand(de.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(pe.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",N={cellLink:St,cellLinkType:ft,cellLinkContent:_t,cellLinkContentError:Lt,cellLinkUrl:Ct,cellLinkOperations:kt,cellLinkOperation:It,cellLinkOperationError:Rt},Pt={outer:h.jsx(se,{}),link:h.jsx(se,{}),sheet:h.jsx(Se,{}),range:h.jsx(ie,{}),defineName:h.jsx(ie,{}),"range-error":h.jsx(ie,{}),"sheet-error":h.jsx(Se,{})},ce=()=>{const i=U.useDependency(exports.SheetsHyperLinkPopupService),e=U.useDependency(m.HyperLinkModel),n=U.useDependency(a.ICommandService),t=U.useDependency(H.IMessageService),r=U.useDependency(a.LocaleService),o=H.useObservable(i.currentPopup$,i.currentPopup),s=U.useDependency(exports.SheetsHyperLinkResolverService);if(!o)return null;const{unitId:c,subUnitId:l,id:u}=o,g=e.getHyperLink(c,l,u);if(!g)return null;const f=s.parseHyperLink(g.payload),d=f.type.indexOf("error")>-1;return h.jsxs("div",{className:N.cellLink,onClick:()=>i.hideCurrentPopup(),children:[h.jsxs("div",{className:Re(N.cellLinkContent,{[N.cellLinkContentError]:d}),onClick:f.handler,children:[h.jsx("div",{className:N.cellLinkType,children:Pt[f.type]}),h.jsx(k.Tooltip,{showIfEllipsis:!0,title:f.name,children:h.jsx("span",{className:N.cellLinkUrl,children:f.name})})]}),h.jsxs("div",{className:N.cellLinkOperations,children:[o.copyPermission&&h.jsx("div",{className:Re(N.cellLinkOperation,{[N.cellLinkOperationError]:d}),onClick:()=>{if(!d){if(f.type!=="outer"){const I=new URL(window.location.href);I.hash=f.url.slice(1),navigator.clipboard.writeText(I.href)}else navigator.clipboard.writeText(f.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(Ue,{})})}),o.editPermission&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:N.cellLinkOperation,onClick:()=>{n.executeCommand(de.id,{unitId:c,subUnitId:l,row:g.row,column:g.column})},children:h.jsx(k.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:h.jsx(je,{})})}),h.jsx("div",{className:N.cellLinkOperation,onClick:()=>{n.executeCommand(m.CancelHyperLinkCommand.id,{unitId:c,subUnitId:l,id:g.id})},children:h.jsx(k.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:h.jsx(Te,{})})})]})]})]})};ce.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},Pe=(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();W(this,"_currentPopup",null);W(this,"_currentPopup$",new ye.Subject);W(this,"currentPopup$",this._currentPopup$.asObservable());W(this,"_currentEditing$",new ye.BehaviorSubject(null));W(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:ce.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([Pe(0,y.Inject(m.HyperLinkModel)),Pe(1,y.Inject(S.SheetCanvasPopManagerService))],exports.SheetsHyperLinkPopupService);var Mt=Object.defineProperty,wt=Object.getOwnPropertyDescriptor,Ut=(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},J=(i,e)=>(n,t)=>e(n,t,i);exports.SheetHyperLinkSetRangeController=class extends a.Disposable{constructor(e,n,t,r,o){super(),this._sheetInterceptorService=e,this._injector=n,this._hyperLinkModel=t,this._selectionManagerService=r,this._univerInstanceService=o,this._initCommandInterceptor()}_initCommandInterceptor(){this._initAddHyperLinkCommandInterceptor(),this._initSetRangeValuesCommandInterceptor(),this._initUpdateHyperLinkCommandInterceptor(),this._initClearSelectionCommandInterceptor()}_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:p.SetRangeValuesMutation.id,params:l}],undos:[{id:p.SetRangeValuesMutation.id,params:p.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:p.SetRangeValuesMutation.id,params:l}],undos:[{id:p.SetRangeValuesMutation.id,params:p.SetRangeValuesUndoMutationFactory(this._injector,l)}]}}}return{redos:[],undos:[]}}}))}_initSetRangeValuesCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===p.SetRangeValuesCommand.id){const n=e.params,{unitId:t,subUnitId:r}=n,o=[],s=[];return n.cellValue&&new a.ObjectMatrix(n.cellValue).forValue((c,l,u)=>{var I,_,C;const g=(C=u==null?void 0:u.v)!=null?C:(_=(I=u==null?void 0:u.p)==null?void 0:I.body)==null?void 0:_.dataStream.slice(0,-2),f=(g!=null?g:"").toString(),d=this._hyperLinkModel.getHyperLinkByLocation(t,r,c,l);if(!d){if(ee(f)){const R=a.Tools.generateRandomId();s.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:t,subUnitId:r,id:R}}),o.push({id:m.AddHyperLinkMutation.id,params:{unitId:t,subUnitId:r,link:{id:R,row:c,column:l,display:f,payload:_e(f)}}})}return}g===""&&(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===p.ClearSelectionContentCommand.id||e.id===p.ClearSelectionAllCommand.id||e.id===p.ClearSelectionFormatCommand.id){const n=[],t=[],r=this._selectionManagerService.getFirst(),o=p.getSheetCommandTarget(this._univerInstanceService);if(r&&o){const{unitId:s,subUnitId:c}=o;a.Range.foreach(r.range,(l,u)=>{const g=this._hyperLinkModel.getHyperLinkByLocation(s,c,l,u);g&&(n.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:g.id}}),t.push({id:m.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:g}}))})}return{redos:n,undos:t}}return{redos:[],undos:[]}}}))}_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)}};exports.SheetHyperLinkSetRangeController=Ut([a.OnLifecycle(a.LifecycleStages.Starting,exports.SheetHyperLinkSetRangeController),J(0,y.Inject(p.SheetInterceptorService)),J(1,y.Inject(y.Injector)),J(2,y.Inject(m.HyperLinkModel)),J(3,y.Inject(p.SelectionManagerService)),J(4,a.IUniverInstanceService)],exports.SheetHyperLinkSetRangeController);var Tt=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&&Tt(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(ye.debounceTime(100)).subscribe(e=>{var d,I;if(!e){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const n=(I=(d=this._renderManagerService.getRenderById(e.location.unitId))==null?void 0:d.with(S.SheetSkeletonManagerService).getUnitSkeleton(e.location.unitId,e.location.subUnitId))==null?void 0:I.skeleton,t=e.location.col,r=e.location.row;let o=r,s=t;if(n&&n.overflowCache.forValue((_,C,R)=>{a.Rectangle.contains(R,{startColumn:t,endColumn:t,startRow:r,endRow:r})&&(o=_,s=C)}),!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[p.WorkbookViewPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]},[{startRow:r,startColumn:t,endRow:r,endColumn:t}])){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const l=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[p.WorkbookEditablePermission],worksheetTypes:[p.WorksheetEditPermission,p.WorksheetInsertHyperlinkPermission],rangeTypes:[p.RangeProtectionPermissionEditPoint]},[{startRow:r,startColumn:t,endRow:r,endColumn:t}]),u=e.location.unitId,g=e.location.subUnitId,f=this._permissionService.composePermission([new p.WorkbookCopyPermission(u).id,new p.WorksheetCopyPermission(u,g).id]).every(_=>_.value);this._sheetsHyperLinkPopupService.showPopup({...e.location,row:o,col:s,editPermission:l,copyPermission:f})}))}};exports.SheetsHyperLinkPopupController=xt([a.OnLifecycle(a.LifecycleStages.Rendered,exports.SheetsHyperLinkPopupController),Q(0,y.Inject(S.HoverManagerService)),Q(1,y.Inject(exports.SheetsHyperLinkPopupService)),Q(2,y.Inject(fe.IRenderManagerService)),Q(3,y.Inject(a.IPermissionService)),Q(4,y.Inject(S.SheetPermissionInterceptorBaseController))],exports.SheetsHyperLinkPopupController);const Nt=i=>({id:pe.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:[p.WorkbookEditablePermission],worksheetTypes:[p.WorksheetEditPermission,p.WorksheetSetCellValuePermission,p.WorksheetInsertHyperlinkPermission],rangeTypes:[p.RangeProtectionPermissionEditPoint]})}),Dt=i=>({tooltip:"hyperLink.form.addTitle",positions:H.MenuPosition.TOOLBAR_START,group:H.MenuGroup.TOOLBAR_OTHERS,id:Le.id,type:H.MenuItemType.BUTTON,icon:"LinkSingle",hidden$:H.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:S.getCurrentRangeDisable$(i,{workbookTypes:[p.WorkbookEditablePermission],worksheetTypes:[p.WorksheetEditPermission,p.WorksheetSetCellValuePermission,p.WorksheetInsertHyperlinkPermission],rangeTypes:[p.RangeProtectionPermissionEditPoint]})}),Ce={id:Le.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},q=(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(){[[ce,ce.componentKey],[ae,ae.componentKey],[se,"LinkSingle"]].forEach(([e,n])=>{this._componentManager.register(n,e)})}_initCommands(){[de,te,pe,Le].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(Ce)}};exports.SheetsHyperLinkUIController=Vt([a.OnLifecycle(a.LifecycleStages.Ready,exports.SheetsHyperLinkUIController),q(1,y.Inject(H.ComponentManager)),q(2,a.ICommandService),q(3,y.Inject(a.LocaleService)),q(4,H.IMenuService),q(5,y.Inject(y.Injector)),q(6,y.Inject(H.IShortcutService))],exports.SheetsHyperLinkUIController);const ke="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},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:u}=r,g=S.virtualizeDiscreteRanges([s,c]),[f,d]=g.ranges,{mapFunc:I}=g,_={row:f.startRow,col:f.startColumn},C=S.getAutoFillRepeatRange(f,d),R=[],j=[];return C.forEach(E=>{const $=E.repeatStartCell,Y=E.relativeRange,M={startRow:_.row,startColumn:_.col,endColumn:_.col,endRow:_.row},z={startRow:$.row,startColumn:$.col,endColumn:$.col,endRow:$.row};a.Range.foreach(Y,(V,B)=>{const Z=a.Rectangle.getPositionRange({startRow:V,startColumn:B,endColumn:B,endRow:V},M),{row:ue,col:he}=I(Z.startRow,Z.startColumn),G=this._hyperLinkModel.getHyperLinkByLocation(l,u,ue,he);if(G){const v=a.Rectangle.getPositionRange({startRow:V,startColumn:B,endColumn:B,endRow:V},z),{row:P,col:O}=I(v.startRow,v.startColumn),b=a.Tools.generateRandomId(),w=this._hyperLinkModel.getHyperLinkByLocation(l,u,P,O);w&&R.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:w.id}}),(S.APPLY_TYPE.COPY===o||S.APPLY_TYPE.SERIES===o)&&(R.push({id:m.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:{...G,id:b,row:P,column:O}}}),j.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:b}})),w&&j.push({id:m.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:w}})}})}),{undos:j,redos:R}},t={id:ke,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),be(0,S.IAutoFillService),be(1,y.Inject(m.HyperLinkModel))],exports.SheetsHyperLinkAutoFillController);var Yt=Object.defineProperty,zt=Object.getOwnPropertyDescriptor,qt=(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&&Yt(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();W(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=S.COPY_TYPE.COPY,pasteType:c}=o,{range:l}=n||{},{range:u,unitId:g,subUnitId:f}=t;return this._generateMutations(u,{copyType:s,pasteType:c,copyRange:l,unitId:g,subUnitId:f})},onPastePlainText:(n,t)=>{if(ee(t)){const r=_e(t),{range:o,unitId:s,subUnitId:c}=n,{ranges:[l],mapFunc:u}=S.virtualizeDiscreteRanges([o]),g=[],f=[];return a.Range.foreach(l,(d,I)=>{const{row:_,col:C}=u(d,I),R=this._hyperLinkModel.getHyperLinkByLocation(s,c,_,C);R&&g.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:R.id}});const j=a.Tools.generateRandomId();g.push({id:m.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:{id:j,row:_,column:C,payload:r}}}),f.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:j}}),R&&f.push({id:m.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:R}})}),{redos:g,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:u}=c;l.forEach((g,f)=>{u.forEach((d,I)=>{var C;const _=this._hyperLinkModel.getHyperLinkByLocation(n,t,g,d);o.setValue(f,I,(C=_==null?void 0:_.id)!=null?C:"")})})}_generateMutations(n,t){if(!this._copyInfo)return{redos:[],undos:[]};if(t.copyType===S.COPY_TYPE.CUT)return this._copyInfo=null,{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,u],mapFunc:g}=S.virtualizeDiscreteRanges([t.copyRange,n]);return S.getRepeatRange(l,u,!0).forEach(({startRange:d})=>{var I;(I=this._copyInfo)==null||I.matrix.forValue((_,C,R)=>{const j=a.Rectangle.getPositionRange({startRow:_,endRow:_,startColumn:C,endColumn:C},d),E=this._hyperLinkModel.getHyperLink(r,o,R),{row:$,col:Y}=g(j.startRow,j.startColumn),M=this._hyperLinkModel.getHyperLinkByLocation(t.unitId,t.subUnitId,$,Y),z=a.Tools.generateRandomId();M&&s.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:t.unitId,subUnitId:t.subUnitId,id:M.id}}),E&&(s.push({id:m.AddHyperLinkMutation.id,params:{unitId:t.unitId,subUnitId:t.subUnitId,link:{...E,id:z,row:$,column:Y}}}),c.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:t.unitId,subUnitId:t.subUnitId,id:z}})),M&&c.push({id:m.AddHyperLinkMutation.id,params:{unitId:t.unitId,subUnitId:t.subUnitId,link:M}})})}),{redos:s,undos:c}}};exports.SheetsHyperLinkCopyPasteController=qt([a.OnLifecycle(a.LifecycleStages.Ready,exports.SheetsHyperLinkCopyPasteController),re(0,S.ISheetClipboardService),re(1,y.Inject(m.HyperLinkModel)),re(2,y.Inject(y.Injector)),re(3,y.Inject(exports.SheetsHyperLinkResolverService))],exports.SheetsHyperLinkCopyPasteController);var Kt=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&&Kt(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,y.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},ve=(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:[p.WorkbookEditablePermission],rangeTypes:[p.RangeProtectionPermissionEditPoint],worksheetTypes:[p.WorksheetEditPermission,p.WorksheetSetCellValuePermission,p.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};oe=en([a.OnLifecycle(a.LifecycleStages.Rendered,oe),ve(0,y.Inject(a.LocaleService)),ve(1,a.ICommandService),ve(2,y.Inject(S.SheetPermissionInterceptorBaseController))],oe);var xe=Object.defineProperty,tn=Object.getOwnPropertyDescriptor,nn=(i,e,n)=>e in i?xe(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&&xe(e,n,r),r},He=(i,e)=>(n,t)=>e(n,t,i),Ne=(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],[oe],[exports.SheetHyperLinkUrlController]].forEach(t=>e.add(t)),this._renderManagerService.registerRenderModule(a.UniverInstanceType.UNIVER_SHEET,exports.SheetsHyperLinkRenderController)}};Ne(exports.UniverSheetsHyperLinkUIPlugin,"pluginName",ke);Ne(exports.UniverSheetsHyperLinkUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsHyperLinkUIPlugin=rn([a.DependentOn(m.UniverSheetsHyperLinkPlugin),He(1,y.Inject(y.Injector)),He(2,fe.IRenderManagerService)],exports.UniverSheetsHyperLinkUIPlugin);exports.CloseHyperLinkSidebarOperation=te;exports.InsertHyperLinkOperation=pe;exports.InsertLinkShortcut=Ce;exports.OpenHyperLinkSidebarOperation=de;